Ticket #6865: 6865_3.patch

File 6865_3.patch, 6.0 KB (added by Garry Yao, 13 years ago)
  • _source/core/tools.js

     
    727727                genKey : function()
    728728                {
    729729                        return Array.prototype.slice.call( arguments ).join( '-' );
     730                },
     731
     732                /**
     733                 * Turn piece of inline style text properties into one hash.
     734                 * @param styleText
     735                 */
     736                parseStyleText : function( styleText )
     737                {
     738                        var retval = {};
     739                        styleText
     740                           .replace( /"/g, '"' )
     741                           .replace( /\s*([^ :;]+)\s*:\s*([^;]+)\s*(?=;|$)/g, function( match, name, value )
     742                        {
     743                                retval[ name ] = value;
     744                        } );
     745                        return retval;
    730746                }
    731747        };
    732748})();
  • _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                return function( name, val )
     275                {
     276                        if ( !this.getDocument().equals( CKEDITOR.document ) )
     277                        {
     278                                if ( name == ( isAttribute ? 'dir' : 'direction' ) && this.getDirection() != val )
     279                                {
     280                                        var retval = org.apply( this, arguments );
     281                                        this.getDocument().fire( 'dirChanged', this );
     282                                        return retval;
     283                                }
     284                                else if ( isAttribute && name == 'style' )
     285                                        this.setStyles( CKEDITOR.tools.parseStyleText( val ) );
     286                        }
     287
     288                        return org.apply( this, arguments );
     289                };
     290        }
     291
     292        var elementProto = CKEDITOR.dom.element.prototype;
     293        elementProto.setStyle = CKEDITOR.tools.override( elementProto.setStyle, dirChangeNotifier );
     294        elementProto.setAttribute = CKEDITOR.tools.override( elementProto.setAttribute, dirChangeNotifier );
     295
    267296})();
    268297
    269298/**
  • _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
  • _source/plugins/styles/plugin.js

     
    14621462                                                         .toLowerCase();
    14631463        }
    14641464
    1465         // Turn inline style text properties into one hash.
    1466         function parseStyleText( styleText )
    1467         {
    1468                 var retval = {};
    1469                 styleText
    1470                    .replace( /"/g, '"' )
    1471                    .replace( /\s*([^ :;]+)\s*:\s*([^;]+)\s*(?=;|$)/g, function( match, name, value )
    1472                 {
    1473                         retval[ name ] = value;
    1474                 } );
    1475                 return retval;
    1476         }
    1477 
    14781465        /**
    14791466         * Compare two bunch of styles, with the speciality that value 'inherit'
    14801467         * is treated as a wildcard which will match any value.
     
    14831470         */
    14841471        function compareCssText( source, target )
    14851472        {
    1486                 typeof source == 'string' && ( source = parseStyleText( source ) );
    1487                 typeof target == 'string' && ( target = parseStyleText( target ) );
     1473                typeof source == 'string' && ( source = CKEDITOR.tools.parseStyleText( source ) );
     1474                typeof target == 'string' && ( target = CKEDITOR.tools.parseStyleText( target ) );
    14881475                for( var name in source )
    14891476                {
    14901477                        if ( !( name in target &&
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy