diff options
author | Sem <sembrestels@riseup.net> | 2013-03-13 02:13:17 +0100 |
---|---|---|
committer | Sem <sembrestels@riseup.net> | 2013-03-13 02:13:17 +0100 |
commit | d730a0c5861c2e79faa3e58dd2b171ca4d197c6f (patch) | |
tree | cb4658e1c60a60c5f663845d49b108dd4608a89a /mod/tinymce/vendor/tinymce/jscripts/tiny_mce/plugins/autolink/editor_plugin_src.js | |
parent | 0fb3e5396d10d21323eb3bbc04727fd4a5a6d06d (diff) | |
parent | 34b14b305f5a106316fdc403c4ce80b25e89b51d (diff) | |
download | elgg-d730a0c5861c2e79faa3e58dd2b171ca4d197c6f.tar.gz elgg-d730a0c5861c2e79faa3e58dd2b171ca4d197c6f.tar.bz2 |
Merge tag '1.8.14' of git://github.com/Elgg/Elgg into foxglove-3
Elgg 1.8.14
Conflicts:
mod/tinymce/vendor/tinymce/jscripts/tiny_mce/langs/en.js
mod/tinymce/vendor/tinymce/jscripts/tiny_mce/themes/advanced/langs/en_dlg.js
Diffstat (limited to 'mod/tinymce/vendor/tinymce/jscripts/tiny_mce/plugins/autolink/editor_plugin_src.js')
-rw-r--r-- | mod/tinymce/vendor/tinymce/jscripts/tiny_mce/plugins/autolink/editor_plugin_src.js | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/mod/tinymce/vendor/tinymce/jscripts/tiny_mce/plugins/autolink/editor_plugin_src.js b/mod/tinymce/vendor/tinymce/jscripts/tiny_mce/plugins/autolink/editor_plugin_src.js index 604da8b42..5b61f7a20 100644 --- a/mod/tinymce/vendor/tinymce/jscripts/tiny_mce/plugins/autolink/editor_plugin_src.js +++ b/mod/tinymce/vendor/tinymce/jscripts/tiny_mce/plugins/autolink/editor_plugin_src.js @@ -22,15 +22,15 @@ init : function(ed, url) { var t = this; - // Internet Explorer has built-in automatic linking - if (tinyMCE.isIE) - return; - // Add a key down handler - ed.onKeyDown.add(function(ed, e) { + ed.onKeyDown.addToTop(function(ed, e) { if (e.keyCode == 13) return t.handleEnter(ed); - }); + }); + + // Internet Explorer has built-in automatic linking for most cases + if (tinyMCE.isIE) + return; ed.onKeyPress.add(function(ed, e) { if (e.which == 41) @@ -61,7 +61,7 @@ // We need at least five characters to form a URL, // hence, at minimum, five characters from the beginning of the line. - r = ed.selection.getRng().cloneRange(); + r = ed.selection.getRng(true).cloneRange(); if (r.startOffset < 5) { // During testing, the caret is placed inbetween two text nodes. // The previous text node contains the URL. @@ -89,8 +89,11 @@ while (endContainer.nodeType != 3 && endContainer.firstChild) endContainer = endContainer.firstChild; - r.setStart(endContainer, 0); - r.setEnd(endContainer, endContainer.nodeValue.length); + // Move range to text node + if (endContainer.nodeType == 3) { + r.setStart(endContainer, 0); + r.setEnd(endContainer, endContainer.nodeValue.length); + } } if (r.endOffset == 1) @@ -104,8 +107,8 @@ do { // Move the selection one character backwards. - r.setStart(endContainer, end - 2); - r.setEnd(endContainer, end - 1); + r.setStart(endContainer, end >= 2 ? end - 2 : 0); + r.setEnd(endContainer, end >= 1 ? end - 1 : 0); end -= 1; // Loop until one of the following is found: a blank space, , delimeter, (end-2) >= 0 @@ -124,12 +127,20 @@ r.setEnd(endContainer, start); } + // Exclude last . from word like "www.site.com." + var text = r.toString(); + if (text.charAt(text.length - 1) == '.') { + r.setEnd(endContainer, start - 1); + } + text = r.toString(); - matches = text.match(/^(https?:\/\/|ssh:\/\/|ftp:\/\/|file:\/|www\.)(.+)$/i); + matches = text.match(/^(https?:\/\/|ssh:\/\/|ftp:\/\/|file:\/|www\.|(?:mailto:)?[A-Z0-9._%+-]+@)(.+)$/i); if (matches) { if (matches[1] == 'www.') { matches[1] = 'http://www.'; + } else if (/@$/.test(matches[1]) && !/^mailto:/.test(matches[1])) { + matches[1] = 'mailto:' + matches[1]; } bookmark = ed.selection.getBookmark(); @@ -137,6 +148,7 @@ ed.selection.setRng(r); tinyMCE.execCommand('createlink',false, matches[1] + matches[2]); ed.selection.moveToBookmark(bookmark); + ed.nodeChanged(); // TODO: Determine if this is still needed. if (tinyMCE.isWebKit) { |