zotero/resource/tinymce/plugins/paste/plugin.min.js

1 line
No EOL
21 KiB
JavaScript

!function(){var a={},b=function(b){for(var c=a[b],e=c.deps,f=c.defn,g=e.length,h=new Array(g),i=0;i<g;++i)h[i]=d(e[i]);var j=f.apply(null,h);if(void 0===j)throw"module ["+b+"] returned undefined";c.instance=j},c=function(b,c,d){if("string"!=typeof b)throw"module id must be a string";if(void 0===c)throw"no dependencies for "+b;if(void 0===d)throw"no definition function for "+b;a[b]={deps:c,defn:d,instance:void 0}},d=function(c){var d=a[c];if(void 0===d)throw"module ["+c+"] was undefined";return void 0===d.instance&&b(c),d.instance},e=function(a,b){for(var c=a.length,e=new Array(c),f=0;f<c;++f)e.push(d(a[f]));b.apply(null,b)},f={};f.bolt={module:{api:{define:c,require:e,demand:d}}};var g=c,h=function(a,b){g(a,[],function(){return b})};h("6",tinymce.util.Tools.resolve),g("1",["6"],function(a){return a("tinymce.PluginManager")}),g("2",[],function(){var a=function(a,b,c,d){return a.fire("PastePreProcess",{content:b,internal:c,wordContent:d})},b=function(a,b,c,d){return a.fire("PastePostProcess",{node:b,internal:c,wordContent:d})},c=function(a,b){return a.fire("PastePlainTextToggle",{state:b})};return{firePastePreProcess:a,firePastePostProcess:b,firePastePlainTextToggle:c}}),g("7",["6"],function(a){return a("tinymce.dom.RangeUtils")}),g("8",["6"],function(a){return a("tinymce.Env")}),g("9",["6"],function(a){return a("tinymce.util.Delay")}),g("a",["6"],function(a){return a("tinymce.util.Tools")}),g("b",["6"],function(a){return a("tinymce.util.VK")}),g("c",[],function(){var a="x-tinymce/html",b="<!-- "+a+" -->",c=function(a){return b+a},d=function(a){return a.replace(b,"")},e=function(a){return a.indexOf(b)!==-1};return{mark:c,unmark:d,isMarked:e,internalHtmlMime:function(){return a}}}),g("j",["6"],function(a){return a("tinymce.html.Entities")}),g("d",["a","j"],function(a,b){var c=function(a){return!/<(?:\/?(?!(?:div|p|br|span)>)\w+|(?:(?!(?:span style="white-space:\s?pre;?">)|br\s?\/>))\w+\s[^>]+)>/i.test(a)},d=function(a){return a.replace(/\r?\n/g,"<br>")},e=function(a,c){var d,e=[],f="<"+a;if("object"==typeof c){for(d in c)c.hasOwnProperty(d)&&e.push(d+'="'+b.encodeAllRaw(c[d])+'"');e.length&&(f+=" "+e.join(" "))}return f+">"},f=function(b,c,d){var f=b.split(/\n\n/),g=e(c,d),h="</"+c+">",i=a.map(f,function(a){return a.split(/\n/).join("<br />")}),j=function(a){return g+a+h};return 1===i.length?i[0]:a.map(i,j).join("")},g=function(a,b,c){return b?f(a,b,c):d(a)};return{isPlainText:c,convert:g,toBRs:d,toBlockElements:f}}),g("e",["a","8"],function(a,b){return function(c){var d,e="%MCEPASTEBIN%",f=function(){function a(a){var b,c,e,f=a.startContainer;if(b=a.getClientRects(),b.length)return b[0];if(a.collapsed&&1==f.nodeType){for(e=f.childNodes[d.startOffset];e&&3==e.nodeType&&!e.data.length;)e=e.nextSibling;if(e)return"BR"==e.tagName&&(c=h.doc.createTextNode("\ufeff"),e.parentNode.insertBefore(c,e),a=h.createRng(),a.setStartBefore(c),a.setEndAfter(c),b=a.getClientRects(),h.remove(c)),b.length?b[0]:void 0}}var f,g,h=c.dom,i=c.getBody(),j=c.dom.getViewPort(c.getWin()),k=j.y,l=20;if(d=c.selection.getRng(),c.inline&&(g=c.selection.getScrollContainer(),g&&g.scrollTop>0&&(k=g.scrollTop)),d.getClientRects){var m=a(d);if(m)l=k+(m.top-h.getPos(i).y);else{l=k;var n=d.startContainer;n&&(3==n.nodeType&&n.parentNode!=i&&(n=n.parentNode),1==n.nodeType&&(l=h.getPos(n,g||i).y))}}f=c.dom.add(c.getBody(),"div",{id:"mcepastebin",contentEditable:!0,"data-mce-bogus":"all",style:"position: absolute; top: "+l+"px; width: 10px; height: 10px; overflow: hidden; opacity: 0"},e),(b.ie||b.gecko)&&h.setStyle(f,"left","rtl"==h.getStyle(i,"direction",!0)?65535:-65535),h.bind(f,"beforedeactivate focusin focusout",function(a){a.stopPropagation()}),f.focus(),c.selection.select(f,!0)},g=function(){if(h()){for(var a;a=c.dom.get("mcepastebin");)c.dom.remove(a),c.dom.unbind(a);d&&c.selection.setRng(d)}d=null},h=function(){return c.dom.get("mcepastebin")},i=function(){var b,d,e,f,g,h=function(a,b){a.appendChild(b),c.dom.remove(b,!0)};for(d=a.grep(c.getBody().childNodes,function(a){return"mcepastebin"===a.id}),b=d.shift(),a.each(d,function(a){h(b,a)}),f=c.dom.select("div[id=mcepastebin]",b),e=f.length-1;e>=0;e--)g=c.dom.create("div"),b.insertBefore(g,f[e]),h(g,f[e]);return b?b.innerHTML:""},j=function(){return d},k=function(a){return a===e},l=function(a){return a&&"mcepastebin"===a.id},m=function(){var a=h();return l(a)&&k(a.innerHTML)};return{create:f,remove:g,getEl:h,getHtml:i,getLastRng:j,isDefault:m,isDefaultContent:k}}}),g("k",["6"],function(a){return a("tinymce.html.DomParser")}),g("l",["6"],function(a){return a("tinymce.html.Schema")}),g("m",["6"],function(a){return a("tinymce.html.Serializer")}),g("n",["6"],function(a){return a("tinymce.html.Node")}),g("h",["a","k","l"],function(a,b,c){function d(b,c){return a.each(c,function(a){b=a.constructor==RegExp?b.replace(a,""):b.replace(a[0],a[1])}),b}function e(e){function f(a){var b=a.name,c=a;if("br"===b)return void(i+="\n");if(j[b]&&(i+=" "),k[b])return void(i+=" ");if(3==a.type&&(i+=a.value),!a.shortEnded&&(a=a.firstChild))do f(a);while(a=a.next);l[b]&&c.next&&(i+="\n","p"==b&&(i+="\n"))}var g=new c,h=new b({},g),i="",j=g.getShortEndedElements(),k=a.makeMap("script noscript style textarea video audio iframe object"," "),l=g.getBlockElements();return e=d(e,[/<!\[[^\]]+\]>/g]),f(h.parse(e)),i}function f(a){function b(a,b,c){return b||c?"\xa0":" "}return a=d(a,[/^[\s\S]*<body[^>]*>\s*|\s*<\/body[^>]*>[\s\S]*$/gi,/<!--StartFragment-->|<!--EndFragment-->/g,[/( ?)<span class="Apple-converted-space">\u00a0<\/span>( ?)/g,b],/<br class="Apple-interchange-newline">/g,/<br>$/i])}function g(a){var b=0;return function(){return a+b++}}var h=function(){return navigator.userAgent.indexOf(" Edge/")!==-1};return{filter:d,innerText:e,trimHtml:f,createIdGenerator:g,isMsEdge:h}}),g("i",["a","k","l","m","n","h"],function(a,b,c,d,e,f){function g(a){return/<font face="Times New Roman"|class="?Mso|style="[^"]*\bmso-|style='[^'']*\bmso-|w:WordDocument/i.test(a)||/class="OutlineElement/.test(a)||/id="?docs\-internal\-guid\-/.test(a)}function h(b){var c,d;return d=[/^[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]/],b=b.replace(/^[\u00a0 ]+/,""),a.each(d,function(a){if(a.test(b))return c=!0,!1}),c}function i(a){return/^[\s\u00a0]*[\u2022\u00b7\u00a7\u25CF]\s*/.test(a)}function j(a){function b(a){var c="";if(3===a.type)return a.value;if(a=a.firstChild)do c+=b(a);while(a=a.next);return c}function c(a,b){if(3===a.type&&b.test(a.value))return a.value=a.value.replace(b,""),!1;if(a=a.firstChild)do if(!c(a,b))return!1;while(a=a.next);return!0}function d(a){if(a._listIgnore)return void a.remove();if(a=a.firstChild)do d(a);while(a=a.next)}function f(a,b,f){var h=a._listLevel||k;h!=k&&(h<k?g&&(g=g.parent.parent):(j=g,g=null)),g&&g.name==b?g.append(a):(j=j||g,g=new e(b,1),f>1&&g.attr("start",""+f),a.wrap(g)),a.name="li",h>k&&j&&j.lastChild.append(g),k=h,d(a),c(a,/^\u00a0+/),c(a,/^\s*([\u2022\u00b7\u00a7\u25CF]|\w+\.)/),c(a,/^\u00a0+/)}for(var g,j,k=1,l=[],m=a.firstChild;"undefined"!=typeof m&&null!==m;)if(l.push(m),m=m.walk(),null!==m)for(;"undefined"!=typeof m&&m.parent!==a;)m=m.walk();for(var n=0;n<l.length;n++)if(a=l[n],"p"==a.name&&a.firstChild){var o=b(a);if(i(o)){f(a,"ul");continue}if(h(o)){var p=/([0-9]+)\./.exec(o),q=1;p&&(q=parseInt(p[1],10)),f(a,"ol",q);continue}if(a._listLevel){f(a,"ul",1);continue}g=null}else j=g,g=null}function k(b,c,d,f){var g,h={},i=b.dom.parseStyle(f);return a.each(i,function(a,e){switch(e){case"mso-list":g=/\w+ \w+([0-9]+)/i.exec(f),g&&(d._listLevel=parseInt(g[1],10)),/Ignore/i.test(a)&&d.firstChild&&(d._listIgnore=!0,d.firstChild._listIgnore=!0);break;case"horiz-align":e="text-align";break;case"vert-align":e="vertical-align";break;case"font-color":case"mso-foreground":e="color";break;case"mso-background":case"mso-highlight":e="background";break;case"font-weight":case"font-style":return void("normal"!=a&&(h[e]=a));case"mso-element":if(/^(comment|comment-list)$/i.test(a))return void d.remove()}return 0===e.indexOf("mso-comment")?void d.remove():void(0!==e.indexOf("mso-")&&("all"==b.settings.paste_retain_style_properties||c&&c[e])&&(h[e]=a))}),/(bold)/i.test(h["font-weight"])&&(delete h["font-weight"],d.wrap(new e("b",1))),/(italic)/i.test(h["font-style"])&&(delete h["font-style"],d.wrap(new e("i",1))),h=b.dom.serializeStyle(h,d.name),h?h:null}var l=function(e,g){var h,i;h=e.settings.paste_retain_style_properties,h&&(i=a.makeMap(h.split(/[, ]/))),g=f.filter(g,[/<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>"],[/&nbsp;/gi,"\xa0"],[/<span\s+style\s*=\s*"\s*mso-spacerun\s*:\s*yes\s*;?\s*"\s*>([\s\u00a0]*)<\/span>/gi,function(a,b){return b.length>0?b.replace(/./," ").slice(Math.floor(b.length/2)).split("").join("\xa0"):""}]]);var l=e.settings.paste_word_valid_elements;l||(l="-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");var m=new c({valid_elements:l,valid_children:"-li[p]"});a.each(m.elements,function(a){a.attributes["class"]||(a.attributes["class"]={},a.attributesOrder.push("class")),a.attributes.style||(a.attributes.style={},a.attributesOrder.push("style"))});var n=new b({},m);n.addAttributeFilter("style",function(a){for(var b,c=a.length;c--;)b=a[c],b.attr("style",k(e,i,b,b.attr("style"))),"span"==b.name&&b.parent&&!b.attributes.length&&b.unwrap()}),n.addAttributeFilter("class",function(a){for(var b,c,d=a.length;d--;)b=a[d],c=b.attr("class"),/^(MsoCommentReference|MsoCommentText|msoDel)$/i.test(c)&&b.remove(),b.attr("class",null)}),n.addNodeFilter("del",function(a){for(var b=a.length;b--;)a[b].remove()}),n.addNodeFilter("a",function(a){for(var b,c,d,e=a.length;e--;)if(b=a[e],c=b.attr("href"),d=b.attr("name"),c&&c.indexOf("#_msocom_")!=-1)b.remove();else if(c&&0===c.indexOf("file://")&&(c=c.split("#")[1],c&&(c="#"+c)),c||d){if(d&&!/^_?(?:toc|edn|ftn)/i.test(d)){b.unwrap();continue}b.attr({href:c,name:d})}else b.unwrap()});var o=n.parse(g);return e.settings.paste_convert_word_fake_lists!==!1&&j(o),g=new d({validate:e.settings.validate},m).serialize(o)},m=function(a,b){return a.settings.paste_enable_default_filters===!1?b:l(a,b)};return{preProcess:m,isWordContent:g}}),g("f",["2","i"],function(a,b){var c=function(a,b){return{content:a,cancelled:b}},d=function(b,d,e,f){var g=b.dom.create("div",{style:"display:none"},d),h=a.firePastePostProcess(b,g,e,f);return c(h.node.innerHTML,h.isDefaultPrevented())},e=function(b,e,f,g){var h=a.firePastePreProcess(b,e,f,g);return b.hasEventListeners("PastePostProcess")&&!h.isDefaultPrevented()?d(b,h.content,f,g):c(h.content,h.isDefaultPrevented())},f=function(a,c,d){var f=b.isWordContent(c),g=f?b.preProcess(a,c):c;return e(a,g,d,f)};return{process:f}}),g("g",["a"],function(a){var b=function(a){return/^https?:\/\/[\w\?\-\/+=.&%@~#]+$/i.test(a)},c=function(a){return b(a)&&/.(gif|jpe?g|png)$/.test(a)},d=function(a,b,c){return a.undoManager.extra(function(){c(a,b)},function(){a.insertContent('<img src="'+b+'">')}),!0},e=function(a,b,c){return a.undoManager.extra(function(){c(a,b)},function(){a.execCommand("mceInsertLink",!1,b)}),!0},f=function(a,c,d){return!(a.selection.isCollapsed()!==!1||!b(c))&&e(a,c,d)},g=function(a,b,e){return!!c(b)&&d(a,b,e)},h=function(a,b){return a.insertContent(b,{merge:a.settings.paste_merge_formats!==!1,paste:!0}),!0},i=function(b,c){a.each([f,g,h],function(a){return a(b,c,h)!==!0})},j=function(a,b){a.settings.smart_paste===!1?h(a,b):i(a,b)};return{isImageUrl:c,isAbsoluteUrl:b,insertContent:j}}),g("3",["7","8","9","a","b","c","d","e","f","g","h"],function(a,b,c,d,e,f,g,h,i,j,k){return function(l){function m(a,b){var c=b?b:f.isMarked(a),d=i.process(l,f.unmark(a),c);d.cancelled===!1&&j.insertContent(l,d.content)}function n(a){a=l.dom.encode(a).replace(/\r\n/g,"\n"),a=g.convert(a,l.settings.forced_root_block,l.settings.forced_root_block_attrs),m(a,!1)}function o(a){var b={};if(a){if(a.getData){var c=a.getData("Text");c&&c.length>0&&c.indexOf(G)==-1&&(b["text/plain"]=c)}if(a.types)for(var d=0;d<a.types.length;d++){var e=a.types[d];try{b[e]=a.getData(e)}catch(a){b[e]=""}}}return b}function p(a){var b=o(a.clipboardData||l.getDoc().dataTransfer);return k.isMsEdge()?d.extend(b,{"text/html":""}):b}function q(a){return y(a,"text/html")||y(a,"text/plain")}function r(a){var b;return b=a.indexOf(","),b!==-1?a.substr(b+1):null}function s(a,b){return!a.images_dataimg_filter||a.images_dataimg_filter(b)}function t(a){var b=a.match(/([\s\S]+?)\.(?:jpeg|jpg|png|gif)$/i);return b?l.dom.encode(b[1]):null}function u(a,b,c){a&&(l.selection.setRng(a),a=null);var d=b.result,e=r(d),f=H(),g=l.settings.images_reuse_filename&&c.name?t(c.name):f,h=new Image;if(h.src=d,s(l.settings,h)){var i,j,k=l.editorUpload.blobCache;j=k.findFirst(function(a){return a.base64()===e}),j?i=j:(i=k.create(f,c,e,g),k.add(i)),m('<img src="'+i.blobUri()+'">',!1)}else m('<img src="'+d+'">',!1)}function v(a,b){function c(c){var d,e,f,g=!1;if(c)for(d=0;d<c.length;d++)if(e=c[d],/^image\/(jpeg|png|gif|bmp)$/.test(e.type)){var h=e.getAsFile?e.getAsFile():e;f=new FileReader,f.onload=u.bind(null,b,f,h),f.readAsDataURL(h),a.preventDefault(),g=!0}return g}var d=a.clipboardData||a.dataTransfer;if(l.settings.paste_data_images&&d)return c(d.items)||c(d.files)}function w(a){var b=a.clipboardData;return navigator.userAgent.indexOf("Android")!=-1&&b&&b.items&&0===b.items.length}function x(b){return a.getCaretRangeFromPoint(b.clientX,b.clientY,l.getDoc())}function y(a,b){return b in a&&a[b].length>0}function z(a){return e.metaKeyPressed(a)&&86==a.keyCode||a.shiftKey&&45==a.keyCode}function A(){function a(a,b,c,d){var e,h;return y(a,"text/html")?e=a["text/html"]:(e=F.getHtml(),d=d?d:f.isMarked(e),F.isDefaultContent(e)&&(c=!0)),e=k.trimHtml(e),F.remove(),h=d===!1&&g.isPlainText(e),e.length&&!h||(c=!0),c&&(e=y(a,"text/plain")&&h?a["text/plain"]:k.innerText(e)),F.isDefaultContent(e)?void(b||l.windowManager.alert("Please use Ctrl+V/Cmd+V keyboard shortcuts to paste contents.")):void(c?n(e):m(e,d))}function d(a){var b=a["text/plain"];return!!b&&0===b.indexOf("file://")}l.on("keydown",function(a){function c(a){z(a)&&!a.isDefaultPrevented()&&F.remove()}if(z(a)&&!a.isDefaultPrevented()){if(B=a.shiftKey&&86==a.keyCode,B&&b.webkit&&navigator.userAgent.indexOf("Version/")!=-1)return;if(a.stopImmediatePropagation(),D=(new Date).getTime(),b.ie&&B)return a.preventDefault(),void l.fire("paste",{ieFake:!0});F.remove(),F.create(),l.once("keyup",c),l.once("paste",function(){l.off("keyup",c)})}});var e=function(){return F.getLastRng()||l.selection.getRng()};l.on("paste",function(d){var g=(new Date).getTime(),h=p(d),i=(new Date).getTime()-g,j=(new Date).getTime()-D-i<1e3,k="text"==C.pasteFormat||B,m=y(h,f.internalHtmlMime());return B=!1,d.isDefaultPrevented()||w(d)?void F.remove():!q(h)&&v(d,e())?void F.remove():(j||d.preventDefault(),!b.ie||j&&!d.ieFake||y(h,"text/html")||(F.create(),l.dom.bind(F.getEl(),"paste",function(a){a.stopPropagation()}),l.getDoc().execCommand("Paste",!1,null),h["text/html"]=F.getHtml()),void(y(h,"text/html")?(d.preventDefault(),m||(m=f.isMarked(h["text/html"])),a(h,j,k,m)):c.setEditorTimeout(l,function(){a(h,j,k,m)},0)))}),l.on("dragstart dragend",function(a){E="dragstart"==a.type}),l.on("drop",function(a){var b,e;if(e=x(a),!a.isDefaultPrevented()&&!E){b=o(a.dataTransfer);var g=y(b,f.internalHtmlMime());if((q(b)&&!d(b)||!v(a,e))&&e&&l.settings.paste_filter_drop!==!1){var h=b["mce-internal"]||b["text/html"]||b["text/plain"];h&&(a.preventDefault(),c.setEditorTimeout(l,function(){l.undoManager.transact(function(){b["mce-internal"]&&l.execCommand("Delete"),l.selection.setRng(e),h=k.trimHtml(h),b["text/html"]?m(h,g):n(h)})}))}}}),l.on("dragover dragend",function(a){l.settings.paste_data_images&&a.preventDefault()})}var B,C=this,D=0,E=!1,F=new h(l),G="data:text/mce-internal,",H=k.createIdGenerator("mceclip");C.pasteHtml=m,C.pasteText=n,C.pasteImageData=v,l.on("preInit",function(){A(),l.parser.addNodeFilter("img",function(a,c,d){function e(a){return a.data&&a.data.paste===!0}function f(a){a.attr("data-mce-object")||j===b.transparentSrc||a.remove()}function g(a){return 0===a.indexOf("webkit-fake-url")}function h(a){return 0===a.indexOf("data:")}if(!l.settings.paste_data_images&&e(d))for(var i=a.length;i--;){var j=a[i].attributes.map.src;j&&(g(j)?f(a[i]):!l.settings.allow_html_data_urls&&h(j)&&f(a[i]))}})})}}),g("4",["8","c","h"],function(a,b,c){var d=function(){},e=function(b){return a.iOS===!1&&void 0!==b&&"function"==typeof b.setData&&c.isMsEdge()!==!0},f=function(a,c,d){if(!e(a))return!1;try{return a.clearData(),a.setData("text/html",c),a.setData("text/plain",d),a.setData(b.internalHtmlMime(),c),!0}catch(a){return!1}},g=function(a,b,c,d){f(a.clipboardData,b.html,b.text)?(a.preventDefault(),d()):c(b.html,d)},h=function(a){return function(c,d){var e=b.mark(c),f=a.dom.create("div",{contenteditable:"false","data-mce-bogus":"all"}),g=a.dom.create("div",{contenteditable:"true"},e);a.dom.setStyles(f,{position:"fixed",left:"-3000px",width:"1000px",overflow:"hidden"}),f.appendChild(g),a.dom.add(a.getBody(),f);var h=a.selection.getRng();g.focus();var i=a.dom.createRng();i.selectNodeContents(g),a.selection.setRng(i),setTimeout(function(){f.parentNode.removeChild(f),a.selection.setRng(h),d()},0)}},i=function(a){return{html:a.selection.getContent({contextual:!0}),text:a.selection.getContent({format:"text"})}},j=function(a){return function(b){a.selection.isCollapsed()===!1&&g(b,i(a),h(a),function(){setTimeout(function(){a.execCommand("Delete")},0)})}},k=function(a){return function(b){a.selection.isCollapsed()===!1&&g(b,i(a),h(a),d)}},l=function(a){a.on("cut",j(a)),a.on("copy",k(a))};return{register:l}}),g("5",["8","a","i","h"],function(a,b,c,d){function e(a,b){a.on("PastePreProcess",function(c){c.content=b(a,c.content,c.internal,c.wordContent)})}function f(a,b){a.on("PastePostProcess",function(c){b(a,c.node)})}function g(a,e){if(!c.isWordContent(e))return e;var f=[];b.each(a.schema.getBlockElements(),function(a,b){f.push(b)});var g=new RegExp("(?:<br>&nbsp;[\\s\\r\\n]+|<br>)*(<\\/?("+f.join("|")+")[^>]*>)(?:<br>&nbsp;[\\s\\r\\n]+|<br>)*","g");return e=d.filter(e,[[g,"$1"]]),e=d.filter(e,[[/<br><br>/g,"<BR><BR>"],[/<br>/g," "],[/<BR><BR>/g,"<br>"]])}function h(a,b,c,d){if(d||c)return b;var e=a.settings.paste_webkit_styles;if(a.settings.paste_remove_styles_if_webkit===!1||"all"==e)return b;if(e&&(e=e.split(/[, ]/)),e){var f=a.dom,g=a.selection.getNode();b=b.replace(/(<[^>]+) style="([^"]*)"([^>]*>)/gi,function(a,b,c,d){var h=f.parseStyle(f.decode(c),"span"),i={};if("none"===e)return b+d;for(var j=0;j<e.length;j++){var k=h[e[j]],l=f.getStyle(g,e[j],!0);/color/.test(e[j])&&(k=f.toHex(k),l=f.toHex(l)),l!=k&&(i[e[j]]=k)}return i=f.serializeStyle(i,"span"),i?b+' style="'+i+'"'+d:b+d})}else b=b.replace(/(<[^>]+) style="([^"]*)"([^>]*>)/gi,"$1$3");return b=b.replace(/(<[^>]+) data-mce-style="([^"]+)"([^>]*>)/gi,function(a,b,c,d){return b+' style="'+c+'"'+d})}function i(a,b){a.$("a",b).find("font,u").each(function(b,c){a.dom.remove(c,!0)})}var j=function(b){a.webkit&&e(b,h),a.ie&&(e(b,g),f(b,i))};return{setup:j}}),g("0",["1","2","3","4","5"],function(a,b,c,d,e){var f;return a.add("paste",function(g){function h(){return f||g.settings.paste_plaintext_inform===!1}function i(){if("text"==k.pasteFormat)k.pasteFormat="html",b.firePastePlainTextToggle(g,!1);else if(k.pasteFormat="text",b.firePastePlainTextToggle(g,!0),!h()){var a=g.translate("Paste is now in plain text mode. Contents will now be pasted as plain text until you toggle this option off.");g.notificationManager.open({text:a,type:"info"}),f=!0}g.focus()}function j(){var a=this;a.active("text"===k.pasteFormat),g.on("PastePlainTextToggle",function(b){a.active(b.state)})}var k,l=this,m=g.settings;return/(^|[ ,])powerpaste([, ]|$)/.test(m.plugins)&&a.get("powerpaste")?void("undefined"!=typeof console&&console.log&&console.log("PowerPaste is incompatible with Paste plugin! Remove 'paste' from the 'plugins' option.")):(l.clipboard=k=new c(g),l.quirks=e.setup(g),g.settings.paste_as_text&&(l.clipboard.pasteFormat="text"),m.paste_preprocess&&g.on("PastePreProcess",function(a){m.paste_preprocess.call(l,l,a)}),m.paste_postprocess&&g.on("PastePostProcess",function(a){m.paste_postprocess.call(l,l,a)}),g.addCommand("mceInsertClipboardContent",function(a,b){b.content&&l.clipboard.pasteHtml(b.content,b.internal),b.text&&l.clipboard.pasteText(b.text)}),g.settings.paste_block_drop&&g.on("dragend dragover draggesture dragdrop drop drag",function(a){a.preventDefault(),a.stopPropagation()}),g.settings.paste_data_images||g.on("drop",function(a){var b=a.dataTransfer;b&&b.files&&b.files.length>0&&a.preventDefault()}),g.addCommand("mceTogglePlainTextPaste",i),g.addButton("pastetext",{icon:"pastetext",tooltip:"Paste as text",onclick:i,onPostRender:j}),g.addMenuItem("pastetext",{text:"Paste as text",selectable:!0,active:k.pasteFormat,onclick:i,onPostRender:j}),void d.register(g))}),function(){}}),d("0")()}();