From b5a5d9f668939c529bbf9e02e49d152366383e37 Mon Sep 17 00:00:00 2001 From: julmis Date: Fri, 14 Apr 2006 09:57:41 +0000 Subject: [PATCH] Another fix for creating links. --- lib/editor/htmlarea/htmlarea.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/editor/htmlarea/htmlarea.php b/lib/editor/htmlarea/htmlarea.php index 1f4ad94919..b2e4697229 100644 --- a/lib/editor/htmlarea/htmlarea.php +++ b/lib/editor/htmlarea/htmlarea.php @@ -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(); -- 2.39.5