X-Git-Url: https://jasonwoof.com/gitweb/?p=ckeditor.git;a=blobdiff_plain;f=_source%2Fplugins%2Fjustify%2Fplugin.js;h=ad134c532636066e3bb497b37d048754859f6b84;hp=036434ddd4e8d6535c5056e047f81c78d3a74e02;hb=039a051ccf3901311661022a30afd60fc38130c9;hpb=c9fdde67e6384bd5a66adc2b3bba5c4ce9db56c7 diff --git a/_source/plugins/justify/plugin.js b/_source/plugins/justify/plugin.js index 036434d..ad134c5 100644 --- a/_source/plugins/justify/plugin.js +++ b/_source/plugins/justify/plugin.js @@ -82,6 +82,41 @@ For licensing, see LICENSE.html or http://ckeditor.com/license } } + function onDirChanged( e ) + { + var editor = e.editor; + + var range = new CKEDITOR.dom.range( editor.document ); + range.setStartBefore( e.data ); + range.setEndAfter( e.data ); + + var walker = new CKEDITOR.dom.walker( range ), + node; + + while ( ( node = walker.next() ) ) + { + if ( node.type == CKEDITOR.NODE_ELEMENT ) + { + // A child with the defined dir is to be ignored. + if ( !node.equals( e.data ) && node.getDirection() ) + { + range.setStartAfter( node ); + walker = new CKEDITOR.dom.walker( range ); + continue; + } + + // Switch the alignment. + var style = 'text-align'; + var align = node.getStyle( style ); + + if ( align == 'left' ) + node.setStyle( style, 'right' ); + else if ( align == 'right' ) + node.setStyle( style, 'left' ); + } + } + } + justifyCommand.prototype = { exec : function( editor ) { @@ -178,13 +213,9 @@ For licensing, see LICENSE.html or http://ckeditor.com/license editor.on( 'selectionChange', CKEDITOR.tools.bind( onSelectionChange, right ) ); editor.on( 'selectionChange', CKEDITOR.tools.bind( onSelectionChange, center ) ); editor.on( 'selectionChange', CKEDITOR.tools.bind( onSelectionChange, justify ) ); + editor.on( 'dirChanged', onDirChanged ); }, requires : [ 'domiterator' ] }); })(); - -CKEDITOR.tools.extend( CKEDITOR.config, - { - justifyClasses : null - } );