Ticket #6865: 6865_5.patch

File 6865_5.patch, 4.7 KB (added by Garry Yao, 13 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
     
    101104                if ( elementDir == dir )
    102105                        return null;
    103106
    104                 // Reuse computedState if we already have it.
    105                 var dirBefore = useComputedState ? elementDir : element.getComputedStyle( 'direction' );
    106 
    107107                // Clear direction on this element.
    108108                element.removeStyle( 'direction' );
    109109
     
    119119                        // Set new direction for this element.
    120120                        element.setAttribute( 'dir', dir );
    121121
    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 
    134122                editor.forceNextSelectionCheck();
    135123
    136124                return null;
     
    191179                                                )
    192180                                                selectedElement = getFullySelected( range, guardElements, enterMode );
    193181
    194                                         if ( selectedElement && !selectedElement.isReadOnly() )
    195                                                 switchDir( selectedElement, dir, editor, database );
     182                                        selectedElement && switchDir( selectedElement, dir, editor, database );
    196183
    197184                                        var iterator,
    198185                                                block;
     
    222209                                        iterator.enlargeBr = enterMode != CKEDITOR.ENTER_BR;
    223210
    224211                                        while ( ( block = iterator.getNextParagraph( enterMode == CKEDITOR.ENTER_P ? 'p' : 'div' ) ) )
    225                                                 !block.isReadOnly() && switchDir( block, dir, editor, database );
     212                                                switchDir( block, dir, editor, database );
    226213                                        }
    227214
    228215                                CKEDITOR.dom.element.clearAllMarkers( database );
     
    261248                        addButtonCommand( 'BidiRtl', lang.rtl, 'bidirtl', bidiCommand( 'rtl' ) );
    262249
    263250                        editor.on( 'selectionChange', onSelectionChange );
     251                        editor.on( 'contentDom', function()
     252                        {
     253                                editor.document.on( 'dirChanged', function( evt )
     254                                {
     255                                        editor.fire( 'dirChanged',
     256                                                {
     257                                                        node : evt.data,
     258                                                        dir : evt.data.getDirection( 1 )
     259                                                } );
     260                                })
     261                        });
    264262                }
    265263        });
    266264
     265        // If the element direction changed, we need to switch the margins of
     266        // the element and all its children, so it will get really reflected
     267        // like a mirror. (#5910)
     268        function dirChangeNotifier( org )
     269        {
     270                var isAttribute = org == elementProto.setAttribute,
     271                        isRemoveAttribute = org == elementProto.removeAttribute,
     272                        dirStyleRegexp = /\bdirection\s*:\s*(.*?)\s*(:?$|;)/;
     273
     274                return function( name, val )
     275                {
     276                        if ( !this.getDocument().equals( CKEDITOR.document ) )
     277                        {
     278                                var orgDir, dir;
     279                                if ( name == ( isAttribute || isRemoveAttribute ? 'dir' : 'direction' ) ||
     280                                         name == 'style' && ( isRemoveAttribute || dirStyleRegexp.test( val ) ) )
     281                                {
     282                                        orgDir = this.getDirection( 1 );
     283                                        var retval = org.apply( this, arguments );
     284                                        if ( orgDir != this.getDirection( 1 ) )
     285                                        {
     286                                                this.getDocument().fire( 'dirChanged', this );
     287                                                return retval;
     288                                        }
     289                                }
     290                        }
     291
     292                        return org.apply( this, arguments );
     293                };
     294        }
     295
     296        var elementProto = CKEDITOR.dom.element.prototype,
     297                methods = [ 'setStyle', 'removeStyle', 'setAttribute', 'removeAttribute' ];
     298        for ( var i = 0; i < methods.length; i++ )
     299                elementProto[ methods[ i ] ] = CKEDITOR.tools.override( elementProto[ methods [ i ] ], dirChangeNotifier );
    267300})();
    268301
    269302/**
  • _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