agenda-libre-ruby/public/assets/tinymce/plugins/autolink/plugin-39fd5f06a1105972f517e648fe7d894142f204967c0e1941bc4d3c4eb6f4c81a.js

2 lines
2.1 KiB
JavaScript
Raw Normal View History

2018-02-19 14:21:53 +01:00
!function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager"),t=tinymce.util.Tools.resolve("tinymce.Env"),n=function(e){return e.getParam("autolink_pattern",/^(https?:\/\/|ssh:\/\/|ftp:\/\/|file:\/|www\.|(?:mailto:)?[A-Z0-9._%+\-]+@)(.+)$/i)},i=function(e){return e.getParam("default_link_target","")},o=function(e,t){if(t<0&&(t=0),3===e.nodeType){var n=e.data.length;t>n&&(t=n)}return t},r=function(e,t,n){1!==t.nodeType||t.hasChildNodes()?e.setStart(t,o(t,n)):e.setStartBefore(t)},a=function(e,t,n){1!==t.nodeType||t.hasChildNodes()?e.setEnd(t,o(t,n)):e.setEndAfter(t)},d=function(e,t,o){var d,f,s,l,c,u,g,h,C,m,y=n(e),k=i(e);if("A"!==e.selection.getNode().tagName){if((d=e.selection.getRng(!0).cloneRange()).startOffset<5){if(!(h=d.endContainer.previousSibling)){if(!d.endContainer.firstChild||!d.endContainer.firstChild.nextSibling)return;h=d.endContainer.firstChild.nextSibling}if(C=h.length,r(d,h,C),a(d,h,C),d.endOffset<5)return;f=d.endOffset,l=h}else{if(3!==(l=d.endContainer).nodeType&&l.firstChild){for(;3!==l.nodeType&&l.firstChild;)l=l.firstChild;3===l.nodeType&&(r(d,l,0),a(d,l,l.nodeValue.length))}f=1===d.endOffset?2:d.endOffset-1-t}s=f;do{r(d,l,f>=2?f-2:0),a(d,l,f>=1?f-1:0),f-=1,m=d.toString()}while(" "!==m&&""!==m&&160!==m.charCodeAt(0)&&f-2>=0&&m!==o);var p;(p=d.toString())===o||" "===p||160===p.charCodeAt(0)?(r(d,l,f),a(d,l,s),f+=1):0===d.startOffset?(r(d,l,0),a(d,l,s)):(r(d,l,f),a(d,l,s)),"."===(u=d.toString()).charAt(u.length-1)&&a(d,l,s-1),(g=(u=d.toString().trim()).match(y))&&("www."===g[1]?g[1]="http://www.":/@$/.test(g[1])&&!/^mailto:/.test(g[1])&&(g[1]="mailto:"+g[1]),c=e.selection.getBookmark(),e.selection.setRng(d),e.execCommand("createlink",!1,g[1]+g[2]),k&&e.dom.setAttrib(e.selection.getNode(),"target",k),e.selection.moveToBookmark(c),e.nodeChanged())}},f=function(e){var n;e.on("keydown",function(t){13!==t.keyCode||d(e,-1,"")}),t.ie?e.on("focus",function(){if(!n){n=!0;try{e.execCommand("AutoUrlDetect",!1,!0)}catch(t){}}}):(e.on("keypress",function(t){41!==t.keyCode||d(e,-1,"(")}),e.on("keyup",function(t){32!==t.keyCode||d(e,0,"")}))};e.add("autolink",function(e){f(e)})}();