CKEDITOR.plugins.add("ipspaste",{requires:"clipboard",init:function(a){if(a.contextMenu)a.on("pluginsLoaded",function(){a.removeMenuItem("cut");a.removeMenuItem("copy")});a.addCommand("ipspasteplain",{canUndo:!1,async:!0,exec:function(a){a.getClipboardData({title:ips.getString("pasteAsPlaintext")},function(b){b&&a.fire("paste",{type:"text",dataValue:b.dataValue,method:"paste",dataTransfer:CKEDITOR.plugins.clipboard.initPasteDataTransfer(),force:!0});a.fire("afterCommandExec",{name:"pastetext",command:"ipspasteplain",
returnValue:!!b})})}});a.contextMenu&&(a.addMenuItem("ipspasteplain",{label:ips.getString("pasteAsPlaintext"),icon:this.path+"icons"+(CKEDITOR.env.hidpi?"/hidpi":"")+"/pastetext.png",command:"ipspasteplain",group:"clipboard",order:16}),a.contextMenu.addListener(function(a,b){inReadOnly=b.getRanges()[0].checkReadOnly();return{ipspasteplain:CKEDITOR.TRISTATE_OFF}}));if("force"==a.config.ipsPasteBehaviour)a.on("paste",function(a){if(a.data.method=="paste")a.data.type="text"},this,{},0);else a.on("paste",
function(d){if(d.data.method=="paste"&&d.data.dataValue.replace(/<((\/)?(p|a( href=["'].+?['"])?)|br(.+)?)>/g,"").indexOf("<")!==-1&&a.config.ipsPasteBehaviour!="force"&&!d.data.force){var b=a.getSnapshot(),f=a.getSelection().createBookmarks2(true),g=null;a.once("afterPaste",function(){g=a.getSelection().createBookmarks2(true);a.once("key",function(){e()});a.once("setData",function(){e()})});var c=$("."+a.id).closest("[data-ipsEditor]").find('[data-role="pasteMessage"]');c.slideDown();var e=function(){c.slideUp();
c.find('[data-action="keepPasteFormatting"]').off("click.ipsPaste");c.find('[data-action="removePasteFormatting"]').off("click.ipsPaste")};c.find('[data-action="keepPasteFormatting"]').on("click.ipsPaste",function(){a.focus();a.getSelection().selectBookmarks(g||f);e()});c.find('[data-action="removePasteFormatting"]').on("click.ipsPaste",function(){a.loadSnapshot(b);a.focus();a.getSelection().selectBookmarks(f);a.fire("paste",{type:"text",dataValue:d.data.dataValue,method:"paste",dataTransfer:CKEDITOR.plugins.clipboard.initPasteDataTransfer()});
e()})}},this)}});