Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merging from stable

  • Loading branch information...
commit bb9cd4503a8a48c46b76442c3385277b84a3dd75 1 parent 3d05094
julmis authored
Showing with 12 additions and 70 deletions.
  1. +12 −70 lib/editor/htmlarea/htmlarea.php
View
82 lib/editor/htmlarea/htmlarea.php
@@ -1470,26 +1470,21 @@ function (str, l1, l2, l3) {
}
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 <a> 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 = '<a href="'+ param.f_href.trim() +'"';
+ if ( param.f_title != "" ) {
+ strLink += ' title="'+ param.f_title.trim() +'"';
}
+ if ( param.f_target != "" ) {
+ strLink += ' target="'+ param.f_target.trim() +'"';
+ }
+ strLink += '>';
+ strLink += (!HTMLArea.is_ie) ? sel : range.text;
+ strLink += '</a>';
+ editor.insertHTML(strLink);
} else {
var href = param.f_href.trim();
editor.selectNodeContents(a);
@@ -2358,8 +2353,6 @@ function getMozSelection(txtarea) {
break; // skip comments, for now.
}
- // Still not workin' correctly...
- //return HTMLArea.formathtml(html);
return html;
};
@@ -2484,54 +2477,3 @@ function hex(d) {
return el;
return null;
};
-
-HTMLArea.formathtml = function (html) {
- // Original idea from FCKeditor
- // http://www.fckeditor.net/
- // by Frederico Caldeira Knabben
-
- var indentchar = ' ';
- var format = new Object();
- format.regex = new Object();
-
- format.regex.tagopen = /<[^\/](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.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;
-}
Please sign in to comment.
Something went wrong with that request. Please try again.