/*
 Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.

 For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license

*/
(function(){function l(a,f,e){var h=CKEDITOR.cleanWord;h?e():(a=CKEDITOR.getUrl(a.config.pasteFromWordCleanupFile||f+"filter/default.js"),CKEDITOR.scriptLoader.load(a,e,null,!0));return!h}CKEDITOR.plugins.add("pastefromword",{requires:"clipboard",lang:"en",icons:"pastefromword,pastefromword-rtl",hidpi:!0,init:function(a){function f(a){var b=CKEDITOR.plugins.pastefromword&&CKEDITOR.plugins.pastefromword.images,c,d=[];if(b&&a.editor.filter.check("img[src]")&&(c=b.extractTagsFromHtml(a.data.dataValue),
0!==c.length&&(b=b.extractFromRtf(a.data.dataTransfer["text/rtf"]),0!==b.length&&(CKEDITOR.tools.array.forEach(b,function(a){d.push(a.type?"data:"+a.type+";base64,"+CKEDITOR.tools.convertBytesToBase64(CKEDITOR.tools.convertHexStringToBytes(a.hex)):null)},this),c.length===d.length))))for(b=0;b<c.length;b++)0===c[b].indexOf("file://")&&d[b]&&(a.data.dataValue=a.data.dataValue.replace(c[b],d[b]))}var e=0,h=this.path,m=void 0===a.config.pasteFromWord_inlineImages?!0:a.config.pasteFromWord_inlineImages;
a.addCommand("pastefromword",{canUndo:!1,async:!0,exec:function(a,b){e=1;a.execCommand("paste",{type:"html",notification:b&&"undefined"!==typeof b.notification?b.notification:!0})}});CKEDITOR.plugins.clipboard.addPasteButton(a,"PasteFromWord",{label:a.lang.pastefromword.toolbar,command:"pastefromword",toolbar:"clipboard,50"});a.on("paste",function(f){var b=f.data,c=CKEDITOR.plugins.clipboard.isCustomDataTypesSupported?b.dataTransfer.getData("text/html",!0):null,d=CKEDITOR.plugins.clipboard.isCustomDataTypesSupported?
b.dataTransfer.getData("text/rtf"):null,c=c||b.dataValue,g={dataValue:c,dataTransfer:{"text/rtf":d}},d=/(class=\"?Mso|style=(?:\"|\')[^\"]*?\bmso\-|w:WordDocument|<o:\w+>|<\/font>)/,d=/<meta\s*name=(?:\"|\')?generator(?:\"|\')?\s*content=(?:\"|\')?microsoft/gi.test(c)||d.test(c);if(c&&(e||d)&&(!1!==a.fire("pasteFromWord",g)||e)){b.dontFilter=!0;var k=l(a,h,function(){if(k)a.fire("paste",b);else if(!a.config.pasteFromWordPromptCleanup||e||confirm(a.lang.pastefromword.confirmCleanup))g.dataValue=CKEDITOR.cleanWord(g.dataValue,
a),a.fire("afterPasteFromWord",g),b.dataValue=g.dataValue,!0===a.config.forcePasteAsPlainText?b.type="text":CKEDITOR.env.ie&&"allow-word"===a.config.forcePasteAsPlainText&&(b.type="html");e=0});k&&f.cancel()}},null,null,3);if(CKEDITOR.plugins.clipboard.isCustomDataTypesSupported&&m)a.on("afterPasteFromWord",f)}})})();