[kupu-checkins] r35268 - in kupu/trunk/kupu: common doc tests

yuppie at codespeak.net yuppie at codespeak.net
Mon Dec 4 21:13:36 CET 2006


Author: yuppie
Date: Mon Dec  4 21:13:33 2006
New Revision: 35268

Modified:
   kupu/trunk/kupu/common/kupubasetools.js
   kupu/trunk/kupu/doc/CHANGES.txt
   kupu/trunk/kupu/tests/run_tests.html
   kupu/trunk/kupu/tests/test_kupubasetools.js
   kupu/trunk/kupu/tests/test_kupuhelpers.js
Log:
- fixed bug in createLink

Modified: kupu/trunk/kupu/common/kupubasetools.js
==============================================================================
--- kupu/trunk/kupu/common/kupubasetools.js	(original)
+++ kupu/trunk/kupu/common/kupubasetools.js	Mon Dec  4 21:13:33 2006
@@ -1111,6 +1111,11 @@
     // the order of the arguments is a bit odd here because of backward
     // compatibility
     this.createLink = function(url, type, name, target, title) {
+        url = url.strip();
+        if (!url) {
+            this.deleteLink();
+            return;
+        };
         if (!this.formatSelectedLink(url, type, name, target, title)) {
             // No links inside or outside.
             this.editor.execCommand("CreateLink", url);

Modified: kupu/trunk/kupu/doc/CHANGES.txt
==============================================================================
--- kupu/trunk/kupu/doc/CHANGES.txt	(original)
+++ kupu/trunk/kupu/doc/CHANGES.txt	Mon Dec  4 21:13:33 2006
@@ -2,6 +2,10 @@
 Kupu changes
 ============
 
+- 1.4 unreleased
+
+  - Fixed a bug where createLink deleted the selected text.
+
 - 1.4 Beta 2
 
   - Paragraph styling now permitted inside a table again (contributed

Modified: kupu/trunk/kupu/tests/run_tests.html
==============================================================================
--- kupu/trunk/kupu/tests/run_tests.html	(original)
+++ kupu/trunk/kupu/tests/run_tests.html	Mon Dec  4 21:13:33 2006
@@ -67,6 +67,7 @@
         testsuite.registerTest(InitKupuCheckersTestCase);
         testsuite.registerTest(KupuUITestCase);
         testsuite.registerTest(ImageToolTestCase);
+        testsuite.registerTest(LinkToolTestCase);
         testsuite.runSuite();
 
         // global tear down

Modified: kupu/trunk/kupu/tests/test_kupubasetools.js
==============================================================================
--- kupu/trunk/kupu/tests/test_kupubasetools.js	(original)
+++ kupu/trunk/kupu/tests/test_kupubasetools.js	Mon Dec  4 21:13:33 2006
@@ -291,7 +291,7 @@
 KupuUITestCase.prototype = new SelectionTestCase;
 
 function ImageToolTestCase() {
-    this.name = 'KupuUITestCase';
+    this.name = 'ImageToolTestCase';
     SelectionTestCase.apply(this);
     this.base_setUp = this.setUp;
 
@@ -325,3 +325,37 @@
 };
 
 ImageToolTestCase.prototype = new SelectionTestCase;
+
+function LinkToolTestCase() {
+    this.name = 'LinkToolTestCase';
+    SelectionTestCase.apply(this);
+    this.base_setUp = this.setUp;
+
+    this.setUp = function() {
+        this.base_setUp();
+        this.editor = new KupuEditor(this.kupudoc, {}, new DummyLogger());
+        this.editor._initialized = true;
+        this.linktool = new LinkTool();
+        this.linktool.editor = this.editor;
+    };
+
+    this.test_createLink = function() {
+        this.body.innerHTML = '<p>foo bar baz</p>';
+        // select                    |bar|
+        this._setSelection(4, null, 7, null, 'bar');
+        this.linktool.createLink('http://www.example.org');
+        this.assertEquals(this._cleanHtml(this.body.innerHTML),
+                          '<p>foo <a href="http://www.example.org">bar</a> baz</p>');
+    };
+
+    this.test_createLinkEmpty = function() {
+        this.body.innerHTML = '<p>foo bar baz</p>';
+        // select                    |bar|
+        this._setSelection(4, null, 7, null, 'bar');
+        this.linktool.createLink('');
+        this.assertEquals(this._cleanHtml(this.body.innerHTML),
+                          '<p>foo bar baz</p>');
+    };
+};
+
+LinkToolTestCase.prototype = new SelectionTestCase;

Modified: kupu/trunk/kupu/tests/test_kupuhelpers.js
==============================================================================
--- kupu/trunk/kupu/tests/test_kupuhelpers.js	(original)
+++ kupu/trunk/kupu/tests/test_kupuhelpers.js	Mon Dec  4 21:13:33 2006
@@ -101,6 +101,8 @@
         s = s.toLowerCase().replace(/[\r\n]/g, "");
         s = s.replace(/\>[ ]+\</g, "><");
         s = s.replace(/\/>/g, ">");
+        s = s.replace(' style=""', "");
+        s = s.replace(" style=''", "");
         return s;
     };
 


More information about the kupu-checkins mailing list