Ticket #6865: 6865_4.patch

File 6865_4.patch, 4.3 KB (added by Garry Yao, 14 years ago)
  • _source/plugins/editingblock/plugin.js

     
    195195         */
    196196        CKEDITOR.editor.prototype.focus = function()
    197197        {
     198                this.forceNextSelectionCheck();
    198199                var mode = getMode( this );
    199200                if ( mode )
    200201                        mode.focus();
  • _source/plugins/bidi/plugin.js

     
    7676
    7777        function switchDir( element, dir, editor, database )
    7878        {
     79                if ( element.isReadOnly() )
     80                        return;
     81
    7982                // Mark this element as processed by switchDir.
    8083                CKEDITOR.dom.element.setMarker( database, element, 'bidi_processed', 1 );
    8184
     
    119122                        // Set new direction for this element.
    120123                        element.setAttribute( 'dir', dir );
    121124
    122                 // If the element direction changed, we need to switch the margins of
    123                 // the element and all its children, so it will get really reflected
    124                 // like a mirror. (#5910)
    125                 if ( dir != dirBefore )
    126                 {
    127                         editor.fire( 'dirChanged',
    128                                 {
    129                                         node : element,
    130                                         dir : dir
    131                                 } );
    132                 }
    133 
    134125                editor.forceNextSelectionCheck();
    135126
    136127                return null;
     
    191182                                                )
    192183                                                selectedElement = getFullySelected( range, guardElements, enterMode );
    193184
    194                                         if ( selectedElement && !selectedElement.isReadOnly() )
    195                                                 switchDir( selectedElement, dir, editor, database );
     185                                        selectedElement && switchDir( selectedElement, dir, editor, database );
    196186
    197187                                        var iterator,
    198188                                                block;
     
    222212                                        iterator.enlargeBr = enterMode != CKEDITOR.ENTER_BR;
    223213
    224214                                        while ( ( block = iterator.getNextParagraph( enterMode == CKEDITOR.ENTER_P ? 'p' : 'div' ) ) )
    225                                                 !block.isReadOnly() && switchDir( block, dir, editor, database );
     215                                                switchDir( block, dir, editor, database );
    226216                                        }
    227217
    228218                                CKEDITOR.dom.element.clearAllMarkers( database );
     
    261251                        addButtonCommand( 'BidiRtl', lang.rtl, 'bidirtl', bidiCommand( 'rtl' ) );
    262252
    263253                        editor.on( 'selectionChange', onSelectionChange );
     254                        editor.on( 'contentDom', function()
     255                        {
     256                                editor.document.on( 'dirChanged', function( evt )
     257                                {
     258                                        editor.fire( 'dirChanged',
     259                                                {
     260                                                        node : evt.data,
     261                                                        dir : evt.data.getDirection()
     262                                                } );
     263                                })
     264                        });
    264265                }
    265266        });
    266267
     268        // If the element direction changed, we need to switch the margins of
     269        // the element and all its children, so it will get really reflected
     270        // like a mirror. (#5910)
     271        function dirChangeNotifier( org )
     272        {
     273                var isAttribute = org == elementProto.setAttribute,
     274                        dirStyleRegexp = /\bdirection\s*:\s*(.*?)\s*(:?$|;)/;
     275
     276                return function( name, val )
     277                {
     278                        if ( !this.getDocument().equals( CKEDITOR.document ) )
     279                        {
     280                                var dirStyleMatch, dir;
     281                                if ( name == ( isAttribute ? 'dir' : 'direction' ) ||
     282                                         isAttribute && name == 'style' && ( dirStyleMatch = val.match( dirStyleRegexp ) )      )
     283                                {
     284                                        dir = dirStyleMatch ? dirStyleMatch[ 1 ] : val;
     285
     286                                        if ( this.getDirection() != dir )
     287                                        {
     288                                                var retval = org.apply( this, arguments );
     289                                                this.getDocument().fire( 'dirChanged', this );
     290                                                return retval;
     291                                        }
     292                                }
     293                        }
     294
     295                        return org.apply( this, arguments );
     296                };
     297        }
     298
     299        var elementProto = CKEDITOR.dom.element.prototype;
     300        elementProto.setStyle = CKEDITOR.tools.override( elementProto.setStyle, dirChangeNotifier );
     301        elementProto.setAttribute = CKEDITOR.tools.override( elementProto.setAttribute, dirChangeNotifier );
     302
    267303})();
    268304
    269305/**
  • _source/plugins/dialogadvtab/plugin.js

     
    3636                var attrName = this.att,
    3737                        value = this.getValue();
    3838
    39                 // Broadcast Lang Dir change
    40                 if ( attrName == 'dir' )
    41                 {
    42                         var dir = element.getAttribute( attrName );
    43                         if ( dir != value && element.getParent() )
    44                                 this._.dialog._.editor.fire( 'dirChanged', { node : element, dir : value || element.getDirection( 1 ) } );
    45                 }
    46 
    4739                if ( value )
    4840                        element.setAttribute( attrName, value );
    4941                else
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy