Aleksander Machniak
2014-04-23 624031a7a1e26daba0be481165cab0da1af6be07
program/js/tiny_mce/plugins/autolink/editor_plugin_src.js
@@ -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, &nbsp;, delimeter, (end-2) >= 0
@@ -124,13 +127,19 @@
            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\.|[A-Z0-9._%+-]+@)(.+)$/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])) {
            } else if (/@$/.test(matches[1]) && !/^mailto:/.test(matches[1])) {
               matches[1] = 'mailto:' + matches[1];
            }
@@ -139,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) {