From bb9cd4503a8a48c46b76442c3385277b84a3dd75 Mon Sep 17 00:00:00 2001 From: julmis Date: Sun, 30 Jul 2006 23:24:43 +0000 Subject: [PATCH] Merging from stable --- lib/editor/htmlarea/htmlarea.php | 82 +++++--------------------------- 1 file changed, 12 insertions(+), 70 deletions(-) diff --git a/lib/editor/htmlarea/htmlarea.php b/lib/editor/htmlarea/htmlarea.php index 9ea3292811..722eae5a7e 100644 --- a/lib/editor/htmlarea/htmlarea.php +++ b/lib/editor/htmlarea/htmlarea.php @@ -1470,26 +1470,21 @@ HTMLArea.prototype._createLink = function(link) { } var a = link; if (!a) { - editor._doc.execCommand("createlink", false, param.f_href); - a = editor.getParentElement(); + // Since startContainer check does not work + // very well in Moz use just insertHTML. var sel = editor._getSelection(); var range = editor._createRange(sel); - /// Removed by PJ and Martin, Moodle bug #1455 - /// Removed uncommenting since it prevents this function - /// to read given attributes for tag such as target, title etc... - if (!HTMLArea.is_ie) { - try { - 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); - } + var strLink = ']*>/gi ; - format.regex.tagclose = /<\/{1}(P|DIV|H1|H2|H3|H4|H5|H6|ADDRESS|PRE|OL|UL|LI|TITLE|META|LINK|BASE|SCRIPT|LINK|TD|AREA|OPTION)[^>]*>/gi ; - format.regex.newlines = /<(BR|HR)[^>]>/gi ; - format.regex.tagsmain = /<\/?(HTML|HEAD|BODY|FORM|TABLE|TBODY|THEAD|TR)[^>]*>/gi ; - format.regex.splitter = /\s*\n+\s*/g ; - format.regex.notouchy = /<\/?(span|font)[^>]*>/gi; - - format.regex.indent = /^<(HTML|HEAD|BODY|FORM|TABLE|TBODY|THEAD|TR|UL|OL)[ \/>]/i ; - format.regex.unindent = /^<\/(HTML|HEAD|BODY|FORM|TABLE|TBODY|THEAD|TR|UL|OL)[ >]/i ; - format.regex.inremove = new RegExp( indentchar ); - - //var formatted = html.replace( format.regex.tagopen, '\n$&' ); - //formatted = formatted.replace( format.regex.tagclose, '$&\n' ); - //formatted = formatted.replace( format.regex.taglines, '$&\n' ); - //formatted = formatted.replace( format.regex.tagsmain, '\n$&\n' ); - - var indentation = ''; - var tolines = html.split(format.regex.splitter); - var formatted = ''; - - for (var i = 0; i < tolines.length; i++) { - var line = tolines[i]; - if (line.length < 1) { - continue; - } - if (format.regex.unindent.test(line) && !format.regex.notouchy.test(line)) { - indentation = indentation.replace(format.regex.inremove, '') ; - } - - line = !format.regex.notouchy.test(line) ? line.replace(format.regex.tagopen, '\n$&') : line; - line = !format.regex.notouchy.test(line) ? line.replace(format.regex.tagclose, '$&\n'): line; - line = !format.regex.notouchy.test(line) ? line.replace(format.regex.tagsmain, '$&\n'): line; - - formatted += indentation + line; - - if (format.regex.indent.test(line)) { - indentation += indentchar; - } - } - return formatted; -} -- 2.39.5