X-Git-Url: https://jasonwoof.com/gitweb/?p=ckeditor.git;a=blobdiff_plain;f=_source%2Fplugins%2Fjustify%2Fplugin.js;h=2de9b0b77f37393e5530b2b0f6b7cebf893fe8bc;hp=ad134c532636066e3bb497b37d048754859f6b84;hb=614511639979907ceb0da3614122a4d8eb963ad4;hpb=039a051ccf3901311661022a30afd60fc38130c9 diff --git a/_source/plugins/justify/plugin.js b/_source/plugins/justify/plugin.js index ad134c5..2de9b0b 100644 --- a/_source/plugins/justify/plugin.js +++ b/_source/plugins/justify/plugin.js @@ -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 );