Ticket #6043: 6043.patch

File 6043.patch, 1.5 KB (added by Tobiasz Cudnik, 13 years ago)
  • _source/plugins/justify/plugin.js

     
    8282                }
    8383        }
    8484
     85        function onDirChanged( e )
     86        {
     87                var editor = e.editor;
     88
     89                var range = new CKEDITOR.dom.range( editor.document );
     90                range.setStartBefore( e.data );
     91                range.setEndAfter( e.data );
     92
     93                var walker = new CKEDITOR.dom.walker( range ),
     94                        node;
     95
     96                while ( node = walker.next() )
     97                {
     98                        if ( node.type == CKEDITOR.NODE_ELEMENT )
     99                        {
     100                                // A child with the defined dir is to be ignored.
     101                                if ( !node.equals( e.data ) && node.getDirection() )
     102                                {
     103                                        range.setStartAfter( node );
     104                                        walker = new CKEDITOR.dom.walker( range );
     105                                        continue;
     106                                }
     107
     108                                // Switch the margins.
     109                                var style = 'text-align';
     110                                var align = node.getStyle( style );
     111
     112                                if ( align == 'left' )
     113                                        node.setStyle( style, 'right' );
     114                                else if ( align == 'right' )
     115                                        node.setStyle( style, 'left' );
     116                        }
     117                }
     118        }
     119
    85120        justifyCommand.prototype = {
    86121                exec : function( editor )
    87122                {
     
    178213                        editor.on( 'selectionChange', CKEDITOR.tools.bind( onSelectionChange, right ) );
    179214                        editor.on( 'selectionChange', CKEDITOR.tools.bind( onSelectionChange, center ) );
    180215                        editor.on( 'selectionChange', CKEDITOR.tools.bind( onSelectionChange, justify ) );
     216                        editor.on( 'dirChanged', onDirChanged );
    181217                },
    182218
    183219                requires : [ 'domiterator' ]
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy