X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Fpagebreak%2Fplugin.js;h=8c0c9f75fcc918772bd04495a61d0a3a638cf8d4;hb=e371ddf8abcb89013e20e6d0dd746adec344d0e5;hp=eaee4a6868a6b62499d87ce068199242fb04ea07;hpb=ea7e3453c7b0f023b050aca6d9f83ab372860d91;p=ckeditor.git diff --git a/_source/plugins/pagebreak/plugin.js b/_source/plugins/pagebreak/plugin.js index eaee4a6..8c0c9f7 100644 --- a/_source/plugins/pagebreak/plugin.js +++ b/_source/plugins/pagebreak/plugin.js @@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved. +Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ @@ -32,10 +32,11 @@ CKEDITOR.plugins.add( 'pagebreak', 'clear: both;' + 'display: block;' + 'float: none;' + - 'width: 100%;' + + 'width:100% !important; _width:99.9% !important;' + 'border-top: #999999 1px dotted;' + 'border-bottom: #999999 1px dotted;' + - 'height: 5px;' + + 'height: 5px !important;' + + 'page-break-after: always;' + '}' ); }, @@ -55,7 +56,8 @@ CKEDITOR.plugins.add( 'pagebreak', { div : function( element ) { - var style = element.attributes.style, + var attributes = element.attributes, + style = attributes && attributes.style, child = style && element.children.length == 1 && element.children[ 0 ], childStyle = child && ( child.name == 'span' ) && child.attributes.style; @@ -80,17 +82,31 @@ CKEDITOR.plugins.pagebreakCmd = // Creates the fake image used for this element. breakObject = editor.createFakeElement( breakObject, 'cke_pagebreak', 'div' ); - var ranges = editor.getSelection().getRanges(); + var ranges = editor.getSelection().getRanges( true ); - for ( var range, i = 0 ; i < ranges.length ; i++ ) + editor.fire( 'saveSnapshot' ); + + for ( var range, i = ranges.length - 1 ; i >= 0; i-- ) { range = ranges[ i ]; - if ( i > 0 ) + if ( i < ranges.length -1 ) breakObject = breakObject.clone( true ); range.splitBlock( 'p' ); range.insertNode( breakObject ); + if ( i == ranges.length - 1 ) + { + range.moveToPosition( breakObject, CKEDITOR.POSITION_AFTER_END ); + range.select(); + } + + var previous = breakObject.getPrevious(); + + if ( CKEDITOR.dtd[ previous.getName() ].div ) + breakObject.move( previous ); } + + editor.fire( 'saveSnapshot' ); } };