]> git.mjollnir.org Git - moodle.git/commitdiff
Another fix for creating links.
authorjulmis <julmis>
Fri, 14 Apr 2006 09:57:41 +0000 (09:57 +0000)
committerjulmis <julmis>
Fri, 14 Apr 2006 09:57:41 +0000 (09:57 +0000)
lib/editor/htmlarea/htmlarea.php

index 1f4ad94919eb9a002666f6093c85f82d65970e66..b2e4697229c42d4b0d6ac381f0aee5bafb934e9b 100644 (file)
@@ -1470,15 +1470,26 @@ HTMLArea.prototype._createLink = function(link) {
                     a = range.startContainer;
                     if (!/^a$/i.test(a.tagName)) {
                         a = a.nextSibling;
+                        if ( a == null ) {
+                            a = range.startContainer.parentNode;
+                        }
                     }
                 } catch (e) {
                         alert("Send this message to bug tracker: " + e);
                 }
             }
         } else {
-            a.href = param.f_href.trim();
+            var href = param.f_href.trim();
+            editor.selectNodeContents(a);
+            if (href == "") {
+                editor._doc.execCommand("unlink", false, null);
+                editor.updateToolbar();
+                return false;
+            } else {
+                a.href = href;
+            }
         }
-        if (!/^a$/i.test(a.tagName)) {
+        if (!(a && /^a$/i.test(a.tagName))) {
             return false;
         }
         a.target = param.f_target.trim();