X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Fjustify%2Fplugin.js;h=695f91010eceb77ba08f49a380c882b385b9c1f0;hb=48b1db88210b4160dce439c6e3e32e14af8c106b;hp=ad134c532636066e3bb497b37d048754859f6b84;hpb=039a051ccf3901311661022a30afd60fc38130c9;p=ckeditor.git diff --git a/_source/plugins/justify/plugin.js b/_source/plugins/justify/plugin.js index ad134c5..695f910 100644 --- a/_source/plugins/justify/plugin.js +++ b/_source/plugins/justify/plugin.js @@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. +Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ @@ -87,8 +87,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license var editor = e.editor; var range = new CKEDITOR.dom.range( editor.document ); - range.setStartBefore( e.data ); - range.setEndAfter( e.data ); + range.setStartBefore( e.data.node ); + range.setEndAfter( e.data.node ); var walker = new CKEDITOR.dom.walker( range ), node; @@ -98,7 +98,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license if ( node.type == CKEDITOR.NODE_ELEMENT ) { // A child with the defined dir is to be ignored. - if ( !node.equals( e.data ) && node.getDirection() ) + if ( !node.equals( e.data.node ) && node.getDirection() ) { range.setStartAfter( node ); walker = new CKEDITOR.dom.walker( range ); @@ -106,6 +106,24 @@ For licensing, see LICENSE.html or http://ckeditor.com/license } // Switch the alignment. + var classes = editor.config.justifyClasses; + if ( classes ) + { + // The left align class. + if ( node.hasClass( classes[ 0 ] ) ) + { + node.removeClass( classes[ 0 ] ); + node.addClass( classes[ 2 ] ); + } + // The right align class. + else if ( node.hasClass( classes[ 2 ] ) ) + { + node.removeClass( classes[ 2 ] ); + node.addClass( classes[ 0 ] ); + } + } + + // Always switch CSS margins. var style = 'text-align'; var align = node.getStyle( style ); @@ -141,7 +159,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license iterator = ranges[ i ].createIterator(); iterator.enlargeBr = enterMode != CKEDITOR.ENTER_BR; - while ( ( block = iterator.getNextParagraph() ) ) + while ( ( block = iterator.getNextParagraph( enterMode == CKEDITOR.ENTER_P ? 'p' : 'div' ) ) ) { block.removeAttribute( 'align' ); block.removeStyle( 'text-align' );