12345 |
- /*
- Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
- For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */
- !function(){CKEDITOR.plugins.add("autolink",{requires:"clipboard,textmatch,link",isSupportedEnvironment:function(){return!CKEDITOR.env.ie||CKEDITOR.env.edge},init:function(t){function e(e){e=CKEDITOR.tools.htmlDecodeAttr(e);var n=new CKEDITOR.dom.element("a"),a=e.replace(/"/g,"%22"),a=a.match(CKEDITOR.config.autolink_urlRegex)?a:"mailto:"+a;return n.setText(e),n.setAttribute("href",a),e=CKEDITOR.plugins.link.parseLinkAttributes(t,n),e=CKEDITOR.plugins.link.getLinkAttributes(t,e),CKEDITOR.tools.isEmpty(e.set)||n.setAttributes(e.set),e.removed.length&&n.removeAttributes(e.removed),n.removeAttribute("data-cke-saved-href"),n.getOuterHtml()}function n(t,e){var n=t.slice(0,e).split(/\s+/);return(n=n[n.length-1])&&a(n)?{start:t.lastIndexOf(n),end:e}:null}function a(e){return e.match(t.config.autolink_urlRegex)||e.match(t.config.autolink_emailRegex)}this.isSupportedEnvironment()&&(t.on("paste",function(n){if(n.data.dataTransfer.getTransferType(t)!=CKEDITOR.DATA_TRANSFER_INTERNAL){var i=n.data.dataValue;-1<i.indexOf("<")||!a(i)||(n.data.dataValue=e(i),n.data.type="html")}}),t.on("key",function(a){if("wysiwyg"===t.mode&&-1!=CKEDITOR.tools.indexOf(t.config.autolink_commitKeystrokes,a.data.keyCode)){var i=CKEDITOR.plugins.textMatch.match(t.getSelection().getRanges()[0],n);if(i&&(a=t.getSelection(),!a.getRanges()[0].startContainer.getAscendant("a",!0)&&(a.selectRanges([i.range]),t.insertHtml(e(i.text),"text"),!CKEDITOR.env.webkit))){var i=a.getRanges()[0],r=t.createRange();r.setStartAfter(i.startContainer),a.selectRanges([r])}}}))}}),CKEDITOR.config.autolink_commitKeystrokes=[13,32],CKEDITOR.config.autolink_urlRegex=/^(https?|ftp):\/\/(-\.)?([^\s\/?\.#]\.?)+(\/[^\s]*)?[^\s\.,]$/i,CKEDITOR.config.autolink_emailRegex=/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/}();
|