CKEDITOR.plugins.add('pagebreak',{init:function(a){a.addCommand('pagebreak',CKEDITOR.plugins.pagebreakCmd);a.ui.addButton('PageBreak',{label:a.lang.pagebreak,command:'pagebreak'});var b=['{','background: url('+CKEDITOR.getUrl(this.path+'images/pagebreak.gif')+') no-repeat center center;','clear: both;','width:100%; _width:99.9%;','border-top: #999999 1px dotted;','border-bottom: #999999 1px dotted;','padding:0;','height: 5px;','cursor: default;','}'].join('').replace(/;/g,' !important;');a.addCss('div.cke_pagebreak'+b);CKEDITOR.env.opera&&a.on('contentDom',function(){a.document.on('click',function(c){var d=c.data.getTarget();if(d.is('div')&&d.hasClass('cke_pagebreak'))a.getSelection().selectElement(d);});});},afterInit:function(a){var b=a.lang.pagebreakAlt,c=a.dataProcessor,d=c&&c.dataFilter,e=c&&c.htmlFilter;if(e)e.addRules({attributes:{'class':function(f,g){var h=f.replace('cke_pagebreak','');if(h!=f){var i=CKEDITOR.htmlParser.fragment.fromHtml('<span style="display: none;">&nbsp;</span>');g.children.length=0;g.add(i);var j=g.attributes;delete j['aria-label'];delete j.contenteditable;delete j.title;}return h;}}},5);if(d)d.addRules({elements:{div:function(f){var g=f.attributes,h=g&&g.style,i=h&&f.children.length==1&&f.children[0],j=i&&i.name=='span'&&i.attributes.style;if(j&&/page-break-after\s*:\s*always/i.test(h)&&/display\s*:\s*none/i.test(j)){g.contenteditable='false';g['class']='cke_pagebreak';g['data-cke-display-name']='pagebreak';g['aria-label']=b;g.title=b;f.children.length=0;}}}});},requires:['fakeobjects']});CKEDITOR.plugins.pagebreakCmd={exec:function(a){var b=a.lang.pagebreakAlt,c=CKEDITOR.dom.element.createFromHtml('<div style="page-break-after: always;"contenteditable="false" title="'+b+'" '+'aria-label="'+b+'" '+'data-cke-display-name="pagebreak" '+'class="cke_pagebreak">'+'</div>'),d=a.getSelection().getRanges(true);a.fire('saveSnapshot');for(var e,f=d.length-1;f>=0;f--){e=d[f];if(f<d.length-1)c=c.clone(true);e.splitBlock('p');e.insertNode(c);if(f==d.length-1){var g=c.getNext();e.moveToPosition(c,CKEDITOR.POSITION_AFTER_END);if(!g||g.type==CKEDITOR.NODE_ELEMENT&&!g.isEditable())e.fixBlock(true,a.config.enterMode==CKEDITOR.ENTER_DIV?'div':'p');e.select();}}a.fire('saveSnapshot');}};
