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){"paste"==a.data.method&&(a.data.type="text")},this,{},0);else a.on("paste",
function(d){if("paste"==d.data.method&&-1!==d.data.dataValue.replace(/<((\/)?(p|a( href=["'].+?['"])?)|br(.+?)?)>/g,"").indexOf("\x3c")&&"force"!=a.config.ipsPasteBehaviour&&!d.data.force){var b=a.getSnapshot(),f=a.getSelection().createBookmarks2(!0),g=null;a.once("afterPaste",function(b){g=a.getSelection().createBookmarks2(!0);a.once("key",function(){e()});a.once("setData",function(){e()})});var c=$("."+a.id).closest("[data-ipsEditor]").find('[data-role\x3d"pasteMessage"]');c.slideDown({queue:!1});
var e=function(){c.slideUp({queue:!1});c.find('[data-action\x3d"keepPasteFormatting"]').off("click.ipsPaste");c.find('[data-action\x3d"removePasteFormatting"]').off("click.ipsPaste")};c.find('[data-action\x3d"keepPasteFormatting"]').on("click.ipsPaste",function(){a.focus();a.getSelection().selectBookmarks(g||f);e()});c.find('[data-action\x3d"removePasteFormatting"]').on("click.ipsPaste",function(){a.focus();a.loadSnapshot(b);a.getSelection().selectBookmarks(f);a.fire("paste",{type:"text",dataValue:d.data.dataValue,
method:"paste",dataTransfer:CKEDITOR.plugins.clipboard.initPasteDataTransfer()});e()})}},this)}});