/* Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license */ (function(){function k(a,b,d,e){var c=new CKEDITOR.dom.walker(a);if(a=a.startContainer.getAscendant(b,!0)||a.endContainer.getAscendant(b,!0))if(d(a),e)return;for(;a=c.next();)if(a=a.getAscendant(b,!0))if(d(a),e)break}function u(a,b){var d={ul:"ol",ol:"ul"};return-1!==l(b,function(b){return b.element===a||b.element===d[a]})}function q(a){this.styles=null;this.sticky=!1;this.editor=a;this.filter=new CKEDITOR.filter(a.config.copyFormatting_allowRules);!0===a.config.copyFormatting_allowRules&&(this.filter.disabled= !0);a.config.copyFormatting_disallowRules&&this.filter.disallow(a.config.copyFormatting_disallowRules)}var l=CKEDITOR.tools.indexOf,r=CKEDITOR.tools.getMouseButton,t=!1;CKEDITOR.plugins.add("copyformatting",{lang:"az,de,en,it,ja,nb,nl,oc,pl,pt-br,ru,sv,tr,zh,zh-cn",icons:"copyformatting",hidpi:!0,init:function(a){var b=CKEDITOR.plugins.copyformatting;b._addScreenReaderContainer();t||(CKEDITOR.document.appendStyleSheet(this.path+"styles/copyformatting.css"),t=!0);a.addContentsCss&&a.addContentsCss(this.path+ "styles/copyformatting.css");a.copyFormatting=new b.state(a);a.addCommand("copyFormatting",b.commands.copyFormatting);a.addCommand("applyFormatting",b.commands.applyFormatting);a.ui.addButton("CopyFormatting",{label:a.lang.copyformatting.label,command:"copyFormatting",toolbar:"cleanup,0"});a.on("contentDom",function(){var d=a.editable(),b=d.isInline()?d:a.document,c=a.ui.get("CopyFormatting");d.attachListener(b,"mouseup",function(b){r(b)===CKEDITOR.MOUSE_BUTTON_LEFT&&a.execCommand("applyFormatting")}); d.attachListener(CKEDITOR.document,"mouseup",function(b){var e=a.getCommand("copyFormatting");r(b)!==CKEDITOR.MOUSE_BUTTON_LEFT||e.state!==CKEDITOR.TRISTATE_ON||d.contains(b.data.getTarget())||a.execCommand("copyFormatting")});c&&(b=CKEDITOR.document.getById(c._.id),d.attachListener(b,"dblclick",function(){a.execCommand("copyFormatting",{sticky:!0})}),d.attachListener(b,"mouseup",function(a){a.data.stopPropagation()}))});a.config.copyFormatting_keystrokeCopy&&a.setKeystroke(a.config.copyFormatting_keystrokeCopy, "copyFormatting");a.on("key",function(b){var e=a.getCommand("copyFormatting");b=b.data.domEvent;b.getKeystroke&&27===b.getKeystroke()&&e.state===CKEDITOR.TRISTATE_ON&&a.execCommand("copyFormatting")});a.copyFormatting.on("extractFormatting",function(d){var e=d.data.element;if(e.contains(a.editable())||e.equals(a.editable()))return d.cancel();e=b._convertElementToStyleDef(e);if(!a.copyFormatting.filter.check(new CKEDITOR.style(e),!0,!0))return d.cancel();d.data.styleDef=e});a.copyFormatting.on("applyFormatting", function(d){if(!d.data.preventFormatStripping){var e=d.data.range,c=b._extractStylesFromRange(a,e),f=b._determineContext(e),g,h;if(a.copyFormatting._isContextAllowed(f))for(h=0;h <\/span>/g,""),a.replace(/<.*?>/g,"")):a.getText()}function e(a, c){var f=a,g=/\s/g,h="p br ol ul li td th div caption body".split(" "),m=!1,k=!1,p,n;do{for(p=b(f,c);!p&&f.getParent();){f=f.getParent();if(-1!==l(h,f.getName())){k=m=!0;break}p=b(f,c)}if(p&&p.getName&&-1!==l(h,p.getName())){m=!0;break}f=p}while(f&&f.getStyle&&("none"==f.getStyle("display")||!f.getText()));for(f||(f=a);f.type!==CKEDITOR.NODE_TEXT;)f=!m||c||k?f.getChild(0):f.getChild(f.getChildCount()-1);for(h=d(f);null!=(k=g.exec(h))&&(n=k.index,c););if("number"!==typeof n&&!m)return e(f,c);if(m)c? n=0:(g=/([\.\b]*$)/,n=(k=g.exec(h))?k.index:h.length);else if(c&&(n+=1,n>h.length))return e(f);return{node:f,offset:n}}var c=/\b\w+\b/ig,f,g,h,m,k;h=m=k=a.startContainer;for(f=d(h);null!=(g=c.exec(f));)if(g.index+g[0].length>=a.startOffset)return a=g.index,c=g.index+g[0].length,0===g.index&&(g=e(h,!0),m=g.node,a=g.offset),c>=f.length&&(f=e(h),k=f.node,c=f.offset),{startNode:m,startOffset:a,endNode:k,endOffset:c};return null},_filterStyles:function(a){var b=CKEDITOR.tools.isEmpty,d=[],e,c;for(c=0;c< a.length;c++)e=a[c]._.definition,-1!==CKEDITOR.tools.indexOf(CKEDITOR.plugins.copyformatting.inlineBoundary,e.element)&&(e.element=a[c].element="span"),"span"===e.element&&b(e.attributes)&&b(e.styles)||d.push(a[c]);return d},_determineContext:function(a){function b(b){var e=new CKEDITOR.dom.walker(a),c;if(a.startContainer.getAscendant(b,!0)||a.endContainer.getAscendant(b,!0))return!0;for(;c=e.next();)if(c.getAscendant(b,!0))return!0}return b({ul:1,ol:1})?"list":b("table")?"table":"text"},_applyStylesToTextContext:function(a, b,d){var e=CKEDITOR.plugins.copyformatting,c=e.excludedAttributesFromInlineTransform,f,g;CKEDITOR.env.webkit&&!CKEDITOR.env.chrome&&a.getSelection().selectRanges([b]);for(f=0;f