mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-23 15:18:58 +01:00
1 line
20 KiB
JavaScript
1 line
20 KiB
JavaScript
!function(){"use strict";var u=function(e){var t=e,n=function(){return t};return{get:n,set:function(e){t=e},clone:function(){return u(n())}}},t=tinymce.util.Tools.resolve("tinymce.PluginManager"),a=function(e){return!(!/(^|[ ,])powerpaste([, ]|$)/.test(e.settings.plugins)||!t.get("powerpaste")||("undefined"!=typeof window.console&&window.console.log&&window.console.log("PowerPaste is incompatible with Paste plugin! Remove 'paste' from the 'plugins' option."),0))},s=function(e,t){return{clipboard:e,quirks:t}},f=function(e,t,n,r){return e.fire("PastePreProcess",{content:t,internal:n,wordContent:r})},d=function(e,t,n,r){return e.fire("PastePostProcess",{node:t,internal:n,wordContent:r})},l=function(e,t){return e.fire("PastePlainTextToggle",{state:t})},n=function(e,t){return e.fire("paste",{ieFake:t})},m={shouldPlainTextInform:function(e){return e.getParam("paste_plaintext_inform",!0)},shouldBlockDrop:function(e){return e.getParam("paste_block_drop",!1)},shouldPasteDataImages:function(e){return e.getParam("paste_data_images",!1)},shouldFilterDrop:function(e){return e.getParam("paste_filter_drop",!0)},getPreProcess:function(e){return e.getParam("paste_preprocess")},getPostProcess:function(e){return e.getParam("paste_postprocess")},getWebkitStyles:function(e){return e.getParam("paste_webkit_styles")},shouldRemoveWebKitStyles:function(e){return e.getParam("paste_remove_styles_if_webkit",!0)},shouldMergeFormats:function(e){return e.getParam("paste_merge_formats",!0)},isSmartPasteEnabled:function(e){return e.getParam("smart_paste",!0)},isPasteAsTextEnabled:function(e){return e.getParam("paste_as_text",!1)},getRetainStyleProps:function(e){return e.getParam("paste_retain_style_properties")},getWordValidElements:function(e){return e.getParam("paste_word_valid_elements","-strong/b,-em/i,-u,-span,-p,-ol,-ul,-li,-h1,-h2,-h3,-h4,-h5,-h6,-p/div,-a[href|name],sub,sup,strike,br,del,table[width],tr,td[colspan|rowspan|width],th[colspan|rowspan|width],thead,tfoot,tbody")},shouldConvertWordFakeLists:function(e){return e.getParam("paste_convert_word_fake_lists",!0)},shouldUseDefaultFilters:function(e){return e.getParam("paste_enable_default_filters",!0)}},r=function(e,t,n){var r,i,o;"text"===t.pasteFormat.get()?(t.pasteFormat.set("html"),l(e,!1)):(t.pasteFormat.set("text"),l(e,!0),o=e,!1===n.get()&&m.shouldPlainTextInform(o)&&(i="Paste is now in plain text mode. Contents will now be pasted as plain text until you toggle this option off.",(r=e).notificationManager.open({text:r.translate(i),type:"info"}),n.set(!0))),e.focus()},c=function(e,n,t){e.addCommand("mceTogglePlainTextPaste",function(){r(e,n,t)}),e.addCommand("mceInsertClipboardContent",function(e,t){t.content&&n.pasteHtml(t.content,t.internal),t.text&&n.pasteText(t.text)})},v=tinymce.util.Tools.resolve("tinymce.Env"),h=tinymce.util.Tools.resolve("tinymce.util.Delay"),b=tinymce.util.Tools.resolve("tinymce.util.Tools"),i=tinymce.util.Tools.resolve("tinymce.util.VK"),e="x-tinymce/html",o="\x3c!-- "+e+" --\x3e",p=function(e){return o+e},g=function(e){return e.replace(o,"")},y=function(e){return-1!==e.indexOf(o)},x=function(){return e},P=tinymce.util.Tools.resolve("tinymce.html.Entities"),w=function(e){return e.replace(/\r?\n/g,"<br>")},_=function(e,t,n){var r=e.split(/\n\n/),i=function(e,t){var n,r=[],i="<"+e;if("object"==typeof t){for(n in t)t.hasOwnProperty(n)&&r.push(n+'="'+P.encodeAllRaw(t[n])+'"');r.length&&(i+=" "+r.join(" "))}return i+">"}(t,n),o="</"+t+">",a=b.map(r,function(e){return e.split(/\n/).join("<br />")});return 1===a.length?a[0]:b.map(a,function(e){return i+e+o}).join("")},D=function(e){return!/<(?:\/?(?!(?:div|p|br|span)>)\w+|(?:(?!(?:span style="white-space:\s?pre;?">)|br\s?\/>))\w+\s[^>]+)>/i.test(e)},T=function(e,t,n){return t?_(e,t,n):w(e)},C=tinymce.util.Tools.resolve("tinymce.html.DomParser"),k=tinymce.util.Tools.resolve("tinymce.html.Node"),R=tinymce.util.Tools.resolve("tinymce.html.Schema"),S=tinymce.util.Tools.resolve("tinymce.html.Serializer");function E(t,e){return b.each(e,function(e){t=e.constructor===RegExp?t.replace(e,""):t.replace(e[0],e[1])}),t}var F={filter:E,innerText:function Ce(e){var t=R(),n=C({},t),r="",i=t.getShortEndedElements(),o=b.makeMap("script noscript style textarea video audio iframe object"," "),a=t.getBlockElements();return e=E(e,[/<!\[[^\]]+\]>/g]),function s(e){var t=e.name,n=e;if("br"!==t)if(i[t]&&(r+=" "),o[t])r+=" ";else{if(3===e.type&&(r+=e.value),!e.shortEnded&&(e=e.firstChild))for(;s(e),e=e.next;);a[t]&&n.next&&(r+="\n","p"===t&&(r+="\n"))}else r+="\n"}(n.parse(e)),r},trimHtml:function ke(e){return e=E(e,[/^[\s\S]*<body[^>]*>\s*|\s*<\/body[^>]*>[\s\S]*$/gi,/<!--StartFragment-->|<!--EndFragment-->/g,[/( ?)<span class="Apple-converted-space">\u00a0<\/span>( ?)/g,function r(e,t,n){return t||n?"\xa0":" "}],/<br class="Apple-interchange-newline">/g,/<br>$/i])},createIdGenerator:function Re(e){var t=0;return function(){return e+t++}},isMsEdge:function(){return-1!==navigator.userAgent.indexOf(" Edge/")}};function I(t){var n,e;return e=[/^[IVXLMCD]{1,2}\.[ \u00a0]/,/^[ivxlmcd]{1,2}\.[ \u00a0]/,/^[a-z]{1,2}[\.\)][ \u00a0]/,/^[A-Z]{1,2}[\.\)][ \u00a0]/,/^[0-9]+\.[ \u00a0]/,/^[\u3007\u4e00\u4e8c\u4e09\u56db\u4e94\u516d\u4e03\u516b\u4e5d]+\.[ \u00a0]/,/^[\u58f1\u5f10\u53c2\u56db\u4f0d\u516d\u4e03\u516b\u4e5d\u62fe]+\.[ \u00a0]/],t=t.replace(/^[\u00a0 ]+/,""),b.each(e,function(e){if(e.test(t))return!(n=!0)}),n}function M(e){var o,a,s=1;function n(e){var t="";if(3===e.type)return e.value;if(e=e.firstChild)for(;t+=n(e),e=e.next;);return t}function l(e,t){if(3===e.type&&t.test(e.value))return e.value=e.value.replace(t,""),!1;if(e=e.firstChild)do{if(!l(e,t))return!1}while(e=e.next);return!0}function t(e,t,n){var r=e._listLevel||s;r!==s&&(r<s?o&&(o=o.parent.parent):(a=o,o=null)),o&&o.name===t?o.append(e):(a=a||o,o=new k(t,1),1<n&&o.attr("start",""+n),e.wrap(o)),e.name="li",s<r&&a&&a.lastChild.append(o),s=r,function i(e){if(e._listIgnore)e.remove();else if(e=e.firstChild)for(;i(e),e=e.next;);}(e),l(e,/^\u00a0+/),l(e,/^\s*([\u2022\u00b7\u00a7\u25CF]|\w+\.)/),l(e,/^\u00a0+/)}for(var r=[],i=e.firstChild;null!=i;)if(r.push(i),null!==(i=i.walk()))for(;void 0!==i&&i.parent!==e;)i=i.walk();for(var u=0;u<r.length;u++)if("p"===(e=r[u]).name&&e.firstChild){var c=n(e);if(/^[\s\u00a0]*[\u2022\u00b7\u00a7\u25CF]\s*/.test(c)){t(e,"ul");continue}if(I(c)){var f=/([0-9]+)\./.exec(c),d=1;f&&(d=parseInt(f[1],10)),t(e,"ol",d);continue}if(e._listLevel){t(e,"ul",1);continue}o=null}else a=o,o=null}function A(n,r,i,o){var a,s={},e=n.dom.parseStyle(o);return b.each(e,function(e,t){switch(t){case"mso-list":(a=/\w+ \w+([0-9]+)/i.exec(o))&&(i._listLevel=parseInt(a[1],10)),/Ignore/i.test(e)&&i.firstChild&&(i._listIgnore=!0,i.firstChild._listIgnore=!0);break;case"horiz-align":t="text-align";break;case"vert-align":t="vertical-align";break;case"font-color":case"mso-foreground":t="color";break;case"mso-background":case"mso-highlight":t="background";break;case"font-weight":case"font-style":return void("normal"!==e&&(s[t]=e));case"mso-element":if(/^(comment|comment-list)$/i.test(e))return void i.remove()}0!==t.indexOf("mso-comment")?0!==t.indexOf("mso-")&&("all"===m.getRetainStyleProps(n)||r&&r[t])&&(s[t]=e):i.remove()}),/(bold)/i.test(s["font-weight"])&&(delete s["font-weight"],i.wrap(new k("b",1))),/(italic)/i.test(s["font-style"])&&(delete s["font-style"],i.wrap(new k("i",1))),(s=n.dom.serializeStyle(s,i.name))||null}var O={preProcess:function(e,t){return m.shouldUseDefaultFilters(e)?function(r,e){var t,i;(t=m.getRetainStyleProps(r))&&(i=b.makeMap(t.split(/[, ]/))),e=F.filter(e,[/<br class="?Apple-interchange-newline"?>/gi,/<b[^>]+id="?docs-internal-[^>]*>/gi,/<!--[\s\S]+?-->/gi,/<(!|script[^>]*>.*?<\/script(?=[>\s])|\/?(\?xml(:\w+)?|img|meta|link|style|\w:\w+)(?=[\s\/>]))[^>]*>/gi,[/<(\/?)s>/gi,"<$1strike>"],[/ /gi,"\xa0"],[/<span\s+style\s*=\s*"\s*mso-spacerun\s*:\s*yes\s*;?\s*"\s*>([\s\u00a0]*)<\/span>/gi,function(e,t){return 0<t.length?t.replace(/./," ").slice(Math.floor(t.length/2)).split("").join("\xa0"):""}]]);var n=m.getWordValidElements(r),o=R({valid_elements:n,valid_children:"-li[p]"});b.each(o.elements,function(e){e.attributes["class"]||(e.attributes["class"]={},e.attributesOrder.push("class")),e.attributes.style||(e.attributes.style={},e.attributesOrder.push("style"))});var a=C({},o);a.addAttributeFilter("style",function(e){for(var t,n=e.length;n--;)(t=e[n]).attr("style",A(r,i,t,t.attr("style"))),"span"===t.name&&t.parent&&!t.attributes.length&&t.unwrap()}),a.addAttributeFilter("class",function(e){for(var t,n,r=e.length;r--;)n=(t=e[r]).attr("class"),/^(MsoCommentReference|MsoCommentText|msoDel)$/i.test(n)&&t.remove(),t.attr("class",null)}),a.addNodeFilter("del",function(e){for(var t=e.length;t--;)e[t].remove()}),a.addNodeFilter("a",function(e){for(var t,n,r,i=e.length;i--;)if(n=(t=e[i]).attr("href"),r=t.attr("name"),n&&-1!==n.indexOf("#_msocom_"))t.remove();else if(n&&0===n.indexOf("file://")&&(n=n.split("#")[1])&&(n="#"+n),n||r){if(r&&!/^_?(?:toc|edn|ftn)/i.test(r)){t.unwrap();continue}t.attr({href:n,name:r})}else t.unwrap()});var s=a.parse(e);return m.shouldConvertWordFakeLists(r)&&M(s),e=S({validate:r.settings.validate},o).serialize(s)}(e,t):t},isWordContent:function Se(e){return/<font face="Times New Roman"|class="?Mso|style="[^"]*\bmso-|style='[^'']*\bmso-|w:WordDocument/i.test(e)||/class="OutlineElement/.test(e)||/id="?docs\-internal\-guid\-/.test(e)}},H=function(e,t){return{content:e,cancelled:t}},B=function(e,t,n,r){var i,o,a,s,l,u,c=f(e,t,n,r);return e.hasEventListeners("PastePostProcess")&&!c.isDefaultPrevented()?(i=e,o=c.content,a=n,s=r,l=i.dom.create("div",{style:"display:none"},o),u=d(i,l,a,s),H(u.node.innerHTML,u.isDefaultPrevented())):H(c.content,c.isDefaultPrevented())},L=function(e,t,n){var r=O.isWordContent(t),i=r?O.preProcess(e,t):t;return B(e,i,n,r)},$=function(e,t){return e.insertContent(t,{merge:m.shouldMergeFormats(e),paste:!0}),!0},j=function(e){return/^https?:\/\/[\w\?\-\/+=.&%@~#]+$/i.test(e)},W=function(e){return j(e)&&/.(gif|jpe?g|png)$/.test(e)},N=function(e,t,n){return!(!1!==e.selection.isCollapsed()||!j(t)||(i=t,o=n,(r=e).undoManager.extra(function(){o(r,i)},function(){r.execCommand("mceInsertLink",!1,i)}),0));var r,i,o},V=function(e,t,n){return!!W(t)&&(i=t,o=n,(r=e).undoManager.extra(function(){o(r,i)},function(){r.insertContent('<img src="'+i+'">')}),!0);var r,i,o},z=function(e,t){var n,r;!1===m.isSmartPasteEnabled(e)?$(e,t):(n=e,r=t,b.each([N,V,$],function(e){return!0!==e(n,r,$)}))},K=function(e,t,n){var r=n||y(t),i=L(e,g(t),r);!1===i.cancelled&&z(e,i.content)},U=function(e,t){t=e.dom.encode(t).replace(/\r\n/g,"\n"),t=T(t,e.settings.forced_root_block,e.settings.forced_root_block_attrs),K(e,t,!1)},G=function(e){var t={};if(e){if(e.getData){var n=e.getData("Text");n&&0<n.length&&-1===n.indexOf("data:text/mce-internal,")&&(t["text/plain"]=n)}if(e.types)for(var r=0;r<e.types.length;r++){var i=e.types[r];try{t[i]=e.getData(i)}catch(o){t[i]=""}}}return t},X=function(e,t){return t in e&&0<e[t].length},q=function(e){return X(e,"text/html")||X(e,"text/plain")},Y=F.createIdGenerator("mceclip"),Z=function(e,t,n,r){t&&(e.selection.setRng(t),t=null);var i,o,a,s,l,u,c,f=n.result,d=-1!==(o=(i=f).indexOf(","))?i.substr(o+1):null,m=Y(),p=e.settings.images_reuse_filename&&r.name?(a=e,s=r.name,(l=s.match(/([\s\S]+?)\.(?:jpeg|jpg|png|gif)$/i))?a.dom.encode(l[1]):null):m,g=new Image;if(g.src=f,u=e.settings,c=g,!u.images_dataimg_filter||u.images_dataimg_filter(c)){var v,h=e.editorUpload.blobCache,b=void 0;(v=h.findFirst(function(e){return e.base64()===d}))?b=v:(b=h.create(m,r,d,p),h.add(b)),K(e,'<img src="'+b.blobUri()+'">',!1)}else K(e,'<img src="'+f+'">',!1)},J=function(a,s,l){var e="paste"===s.type?s.clipboardData:s.dataTransfer;function t(e){var t,n,r,i=!1;if(e)for(t=0;t<e.length;t++)if(n=e[t],/^image\/(jpeg|png|gif|bmp)$/.test(n.type)){var o=n.getAsFile?n.getAsFile():n;(r=new window.FileReader).onload=Z.bind(null,a,l,r,o),r.readAsDataURL(o),s.preventDefault(),i=!0}return i}if(a.settings.paste_data_images&&e)return t(e.items)||t(e.files)},Q=function(e){return i.metaKeyPressed(e)&&86===e.keyCode||e.shiftKey&&45===e.keyCode},ee=function(c,f,d){var m,p=0;function g(e,t,n,r){var i,o;X(e,"text/html")?i=e["text/html"]:(i=f.getHtml(),r=r||y(i),f.isDefaultContent(i)&&(n=!0)),i=F.trimHtml(i),f.remove(),o=!1===r&&D(i),i.length&&!o||(n=!0),n&&(i=X(e,"text/plain")&&o?e["text/plain"]:F.innerText(i)),f.isDefaultContent(i)?t||c.windowManager.alert("Please use Ctrl+V/Cmd+V keyboard shortcuts to paste contents."):n?U(c,i):K(c,i,r)}c.on("keydown",function(e){function t(e){Q(e)&&!e.isDefaultPrevented()&&f.remove()}if(Q(e)&&!e.isDefaultPrevented()){if((m=e.shiftKey&&86===e.keyCode)&&v.webkit&&-1!==navigator.userAgent.indexOf("Version/"))return;if(e.stopImmediatePropagation(),p=(new Date).getTime(),v.ie&&m)return e.preventDefault(),void n(c,!0);f.remove(),f.create(),c.once("keyup",t),c.once("paste",function(){c.off("keyup",t)})}}),c.on("paste",function(e){var t,n,r,i=(new Date).getTime(),o=(t=c,n=G(e.clipboardData||t.getDoc().dataTransfer),F.isMsEdge()?b.extend(n,{"text/html":""}):n),a=(new Date).getTime()-i,s=(new Date).getTime()-p-a<1e3,l="text"===d.get()||m,u=X(o,x());m=!1,e.isDefaultPrevented()||(r=e.clipboardData,-1!==navigator.userAgent.indexOf("Android")&&r&&r.items&&0===r.items.length)?f.remove():q(o)||!J(c,e,f.getLastRng()||c.selection.getRng())?(s||e.preventDefault(),!v.ie||s&&!e.ieFake||X(o,"text/html")||(f.create(),c.dom.bind(f.getEl(),"paste",function(e){e.stopPropagation()}),c.getDoc().execCommand("Paste",!1,null),o["text/html"]=f.getHtml()),X(o,"text/html")?(e.preventDefault(),u||(u=y(o["text/html"])),g(o,s,l,u)):h.setEditorTimeout(c,function(){g(o,s,l,u)},0)):f.remove()})},te=function(e){return v.ie&&e.inline?document.body:e.getBody()},ne=function(t,e,n){var r;te(r=t)!==r.getBody()&&t.dom.bind(e,"paste keyup",function(e){oe(t,n)||t.fire("paste")})},re=function(e){return e.dom.get("mcepastebin")},ie=function(e,t){return t===e},oe=function(e,t){var n,r=re(e);return(n=r)&&"mcepastebin"===n.id&&ie(t,r.innerHTML)},ae=function(a){var s=u(null),l="%MCEPASTEBIN%";return{create:function(){return t=s,n=l,i=(e=a).dom,o=e.getBody(),t.set(e.selection.getRng()),r=e.dom.add(te(e),"div",{id:"mcepastebin","class":"mce-pastebin",contentEditable:!0,"data-mce-bogus":"all",style:"position: fixed; top: 50%; width: 10px; height: 10px; overflow: hidden; opacity: 0"},n),(v.ie||v.gecko)&&i.setStyle(r,"left","rtl"===i.getStyle(o,"direction",!0)?65535:-65535),i.bind(r,"beforedeactivate focusin focusout",function(e){e.stopPropagation()}),ne(e,r,n),r.focus(),void e.selection.select(r,!0);var e,t,n,r,i,o},remove:function(){return function(e,t){if(re(e)){for(var n=void 0,r=t.get();n=e.dom.get("mcepastebin");)e.dom.remove(n),e.dom.unbind(n);r&&e.selection.setRng(r)}t.set(null)}(a,s)},getEl:function(){return re(a)},getHtml:function(){return function(n){var t,e,r,i,o,a=function(e,t){e.appendChild(t),n.dom.remove(t,!0)};for(e=b.grep(te(n).childNodes,function(e){return"mcepastebin"===e.id}),t=e.shift(),b.each(e,function(e){a(t,e)}),r=(i=n.dom.select("div[id=mcepastebin]",t)).length-1;0<=r;r--)o=n.dom.create("div"),t.insertBefore(o,i[r]),a(o,i[r]);return t?t.innerHTML:""}(a)},getLastRng:function(){return s.get()},isDefault:function(){return oe(a,l)},isDefaultContent:function(e){return ie(l,e)}}},se=function(n,e){var t=ae(n);return n.on("preInit",function(){return ee(a=n,t,e),void a.parser.addNodeFilter("img",function(e,t,n){var r,i=function(e){e.attr("data-mce-object")||s===v.transparentSrc||e.remove()};if(!a.settings.paste_data_images&&(r=n).data&&!0===r.data.paste)for(var o=e.length;o--;)(s=e[o].attributes.map.src)&&(0===s.indexOf("webkit-fake-url")?i(e[o]):a.settings.allow_html_data_urls||0!==s.indexOf("data:")||i(e[o]))});var a,s}),{pasteFormat:e,pasteHtml:function(e,t){return K(n,e,t)},pasteText:function(e){return U(n,e)},pasteImageData:function(e,t){return J(n,e,t)},getDataTransferItems:G,hasHtmlOrText:q,hasContentType:X}},le=function(){},ue=function(e,t,n){if(r=e,!1!==v.iOS||r===undefined||"function"!=typeof r.setData||!0===F.isMsEdge())return!1;try{return e.clearData(),e.setData("text/html",t),e.setData("text/plain",n),e.setData(x(),t),!0}catch(i){return!1}var r},ce=function(e,t,n,r){ue(e.clipboardData,t.html,t.text)?(e.preventDefault(),r()):n(t.html,r)},fe=function(s){return function(e,t){var n=p(e),r=s.dom.create("div",{contenteditable:"false","data-mce-bogus":"all"}),i=s.dom.create("div",{contenteditable:"true"},n);s.dom.setStyles(r,{position:"fixed",top:"0",left:"-3000px",width:"1000px",overflow:"hidden"}),r.appendChild(i),s.dom.add(s.getBody(),r);var o=s.selection.getRng();i.focus();var a=s.dom.createRng();a.selectNodeContents(i),s.selection.setRng(a),setTimeout(function(){s.selection.setRng(o),r.parentNode.removeChild(r),t()},0)}},de=function(e){return{html:e.selection.getContent({contextual:!0}),text:e.selection.getContent({format:"text"})}},me=function(e){var t,n;e.on("cut",(t=e,function(e){!1===t.selection.isCollapsed()&&ce(e,de(t),fe(t),function(){setTimeout(function(){t.execCommand("Delete")},0)})})),e.on("copy",(n=e,function(e){!1===n.selection.isCollapsed()&&ce(e,de(n),fe(n),le)}))},pe=tinymce.util.Tools.resolve("tinymce.dom.RangeUtils"),ge=function(e,t){return pe.getCaretRangeFromPoint(t.clientX,t.clientY,e.getDoc())},ve=function(e,t){e.focus(),e.selection.setRng(t)},he=function(a,s,l){m.shouldBlockDrop(a)&&a.on("dragend dragover draggesture dragdrop drop drag",function(e){e.preventDefault(),e.stopPropagation()}),m.shouldPasteDataImages(a)||a.on("drop",function(e){var t=e.dataTransfer;t&&t.files&&0<t.files.length&&e.preventDefault()}),a.on("drop",function(e){var t,n;if(n=ge(a,e),!e.isDefaultPrevented()&&!l.get()){t=s.getDataTransferItems(e.dataTransfer);var r,i=s.hasContentType(t,x());if((s.hasHtmlOrText(t)&&(!(r=t["text/plain"])||0!==r.indexOf("file://"))||!s.pasteImageData(e,n))&&n&&m.shouldFilterDrop(a)){var o=t["mce-internal"]||t["text/html"]||t["text/plain"];o&&(e.preventDefault(),h.setEditorTimeout(a,function(){a.undoManager.transact(function(){t["mce-internal"]&&a.execCommand("Delete"),ve(a,n),o=F.trimHtml(o),t["text/html"]?s.pasteHtml(o,i):s.pasteText(o)})}))}}}),a.on("dragstart",function(e){l.set(!0)}),a.on("dragover dragend",function(e){m.shouldPasteDataImages(a)&&!1===l.get()&&(e.preventDefault(),ve(a,ge(a,e))),"dragend"===e.type&&l.set(!1)})},be=function(e){var t=e.plugins.paste,n=m.getPreProcess(e);n&&e.on("PastePreProcess",function(e){n.call(t,t,e)});var r=m.getPostProcess(e);r&&e.on("PastePostProcess",function(e){r.call(t,t,e)})};function ye(t,n){t.on("PastePreProcess",function(e){e.content=n(t,e.content,e.internal,e.wordContent)})}function xe(e,t){if(!O.isWordContent(t))return t;var n=[];b.each(e.schema.getBlockElements(),function(e,t){n.push(t)});var r=new RegExp("(?:<br> [\\s\\r\\n]+|<br>)*(<\\/?("+n.join("|")+")[^>]*>)(?:<br> [\\s\\r\\n]+|<br>)*","g");return t=F.filter(t,[[r,"$1"]]),t=F.filter(t,[[/<br><br>/g,"<BR><BR>"],[/<br>/g," "],[/<BR><BR>/g,"<br>"]])}function Pe(e,t,n,r){if(r||n)return t;var u,i=m.getWebkitStyles(e);if(!1===m.shouldRemoveWebKitStyles(e)||"all"===i)return t;if(i&&(u=i.split(/[, ]/)),u){var c=e.dom,f=e.selection.getNode();t=t.replace(/(<[^>]+) style="([^"]*)"([^>]*>)/gi,function(e,t,n,r){var i=c.parseStyle(c.decode(n)),o={};if("none"===u)return t+r;for(var a=0;a<u.length;a++){var s=i[u[a]],l=c.getStyle(f,u[a],!0);/color/.test(u[a])&&(s=c.toHex(s),l=c.toHex(l)),l!==s&&(o[u[a]]=s)}return(o=c.serializeStyle(o,"span"))?t+' style="'+o+'"'+r:t+r})}else t=t.replace(/(<[^>]+) style="([^"]*)"([^>]*>)/gi,"$1$3");return t=t.replace(/(<[^>]+) data-mce-style="([^"]+)"([^>]*>)/gi,function(e,t,n,r){return t+' style="'+n+'"'+r})}function we(n,e){n.$("a",e).find("font,u").each(function(e,t){n.dom.remove(t,!0)})}var _e=function(e){v.webkit&&ye(e,Pe),v.ie&&(ye(e,xe),function r(t,n){t.on("PastePostProcess",function(e){n(t,e.node)})}(e,we))},De=function(n,r){return function(t){t.setActive("text"===r.pasteFormat.get());var e=function(e){return t.setActive(e.state)};return n.on("PastePlainTextToggle",e),function(){return n.off("PastePlainTextToggle",e)}}},Te=function(e,t){e.ui.registry.addToggleButton("pastetext",{active:!1,icon:"paste-text",tooltip:"Paste as text",onAction:function(){return e.execCommand("mceTogglePlainTextPaste")},onSetup:De(e,t)}),e.ui.registry.addToggleMenuItem("pastetext",{text:"Paste as text",onAction:function(){return e.execCommand("mceTogglePlainTextPaste")},onSetup:De(e,t)})};t.add("paste",function(e){if(!1===a(e)){var t=u(!1),n=u(!1),r=u(m.isPasteAsTextEnabled(e)?"text":"html"),i=se(e,r),o=_e(e);return Te(e,i),c(e,i,t),be(e),me(e),he(e,i,n),s(i,o)}}),function Ee(){}}(); |