Ticket #4973: 4973.patch

File 4973.patch, 6.5 KB (added by Garry Yao, 14 years ago)
  • _source/plugins/stylescombo/plugin.js

     
    3232
    3333                                        init : function()
    3434                                        {
    35                                                 var combo = this,
    36                                                         stylesSet = config.stylesCombo_stylesSet.split( ':' );
     35                                                var combo = this;
    3736
    38                                                 var stylesSetPath = stylesSet[ 1 ] ?
    39                                                                 stylesSet.slice( 1 ).join( ':' ) :              // #4481
    40                                                                 CKEDITOR.getUrl( pluginPath + 'styles/' + stylesSet[ 0 ] + '.js' ) ;
    41 
    42                                                 stylesSet = stylesSet[ 0 ];
    43 
    44                                                 CKEDITOR.loadStylesSet( stylesSet, stylesSetPath, function( stylesDefinitions )
     37                                                CKEDITOR.stylesSet.load( styleSetName, function( stylesSet )
    4538                                                        {
    46                                                                 var style,
     39                                                                var stylesDefinitions = stylesSet[ styleSetName ],
     40                                                                        style,
    4741                                                                        styleName,
    4842                                                                        stylesList = [];
    4943
     
    204198                                                        this.hideGroup( lang[ 'panelTitle' + String( CKEDITOR.STYLE_OBJECT ) ] );
    205199                                        }
    206200                                });
    207                 }
    208         });
    209201
    210         var stylesSets = {};
     202                        var stylesSet = config.stylesCombo_stylesSet.split( ':' ),
     203                                styleSetName = stylesSet[ 0 ],
     204                                externalPath = stylesSet[ 1 ];
    211205
    212         CKEDITOR.addStylesSet = function( name, styles )
    213         {
    214                 stylesSets[ name ] = styles;
    215         };
     206                        CKEDITOR.stylesSet.addExternal( styleSetName,
     207                                        externalPath ? stylesSet.slice( 1 ).join( ':' ) : pluginPath + 'styles/',
     208                                        externalPath ? '' : styleSetName + '.js' );
    216209
    217         CKEDITOR.loadStylesSet = function( name, url, callback )
    218         {
    219                 var stylesSet = stylesSets[ name ];
    220 
    221                 if ( stylesSet )
    222                 {
    223                         callback( stylesSet );
    224                         return ;
    225210                }
    226 
    227                 CKEDITOR.scriptLoader.load( url, function()
    228                         {
    229                                 callback( stylesSets[ name ] );
    230                         });
    231         };
     211        });
    232212
     213        // Custom stylesSets as global resources.
     214        CKEDITOR.stylesSet = new CKEDITOR.resourceManager( '', 'stylesSet' );
     215       
    233216        function buildPreview( styleDefinition )
    234217        {
    235218                var html = [];
  • _source/plugins/stylescombo/styles/default.js

     
    33For licensing, see LICENSE.html or http://ckeditor.com/license
    44*/
    55
    6 CKEDITOR.addStylesSet( 'default',
     6CKEDITOR.stylesSet.add( 'default',
    77[
    88        /* Block Styles */
    99
  • _source/plugins/div/dialogs/div.js

     
    259259                        return groups;
    260260                }
    261261
     262                // Registered 'CKEDITOR.style' instances.
     263                var styles = {} ;
    262264                /**
    263265                 * Hold a collection of created block container elements.
    264266                 */
     
    292294                                                                items : [],
    293295                                                                setup : function( element )
    294296                                                                {
    295                                                                         this.setValue( element.$.style.cssText || '' );
     297                                                                        for ( var name in styles )
     298                                                                                styles[ name ].checkElementRemovable( element, true ) && this.setValue( name );
    296299                                                                },
    297300                                                                commit: function( element )
    298301                                                                {
    299                                                                         if ( this.getValue() )
    300                                                                                 element.$.style.cssText = this.getValue();
    301                                                                         else
    302                                                                                 element.removeAttribute( 'style' );
     302                                                                        var styleName;
     303                                                                        if ( styleName = this.getValue() )
     304                                                                                styles[ styleName ].applyToObject( element )
    303305                                                                }
    304306                                                        },
    305307                                                        {
     
    351353                                                                                        id :'style',
    352354                                                                                        style :'width: 100%;',
    353355                                                                                        label :editor.lang.common.cssStyle,
    354                                                                                         'default' : ''
    355                                                                                 }
     356                                                                                        'default' : '',
     357                                                                                        commit : function( element )
     358                                                                                        {
     359                                                                                                var style = element.$.style;
     360                                                                                                // Element styles are of higher priority.
     361                                                                                                style.cssText = this.getValue() + ';' + style.cssText;
     362                                                                                        }
     363                                                                                }
    356364                                                                ]
    357365                                                        },
    358366                                                        {
     
    376384                                                                'default' : '',
    377385                                                                items :
    378386                                                                [
     387                                                                        [ editor.lang.common.notSet , '' ],
    379388                                                                        [
    380389                                                                                editor.lang.common.langDirLtr,
    381390                                                                                'ltr'
     
    394403                        onLoad : function()
    395404                        {
    396405                                setupFields.call(this);
     406
     407                                // Preparing for the 'elementStyle' field.
     408                                var dialog = this,
     409                                         stylesField = this.getContentElement( 'info', 'elementStyle' ),
     410                                         // Reuse the 'stylescombo' plugin's styles definition.
     411                                         customStylesConfig =  editor.config.stylesCombo_stylesSet,
     412                                         customStylesSetName = customStylesConfig && customStylesConfig.split( ':' )[ 0 ];
     413
     414                                stylesField.add( editor.lang.common.notSet, '' );
     415                                customStylesSetName && CKEDITOR.stylesSet.load( customStylesSetName,
     416                                        function( stylesSet )
     417                                        {
     418                                                var stylesDefinitions = stylesSet[ customStylesSetName ],
     419                                                        style, styleName;
     420
     421                                                if( stylesDefinitions )
     422                                                {
     423                                                        for ( var i = 0 ; i < stylesDefinitions.length ; i++ )
     424                                                        {
     425                                                                var styleDefinition = stylesDefinitions[ i ];
     426                                                                if( styleDefinition.element && styleDefinition.element == 'div' )
     427                                                                {
     428                                                                        styleName = styleDefinition.name;
     429                                                                        style = styles[ styleName ] = new CKEDITOR.style( styleDefinition );
     430                                                                        // Populate the styles field options with style name.
     431                                                                        stylesField.items.push( [ styleName, styleName ] );
     432                                                                        stylesField.add( styleName, styleName );
     433                                                                }
     434                                                        }
     435                                                }
     436
     437                                                // We should disable it if no styles are available.
     438                                                var fieldBox =  stylesField.getElement().getParent();
     439                                                stylesField.items.length ? fieldBox.removeStyle( 'display' ) : fieldBox.setStyle( 'display', 'none' );
     440                                                // Now setup the field value manually.
     441                                                setTimeout( function() { stylesField.setup( dialog._element ); }, 0 );
     442                                        } );
    397443                        },
    398444                        onShow : function()
    399445                        {
  • _source/core/resourcemanager.js

     
    127127                var external = this.externals[ name ];
    128128                return CKEDITOR.getUrl(
    129129                                this.getPath( name ) +
    130                                 ( ( external && external.file ) || ( this.fileName + '.js' ) ) );
     130                                // External file name could be an empty one,
     131                                // which indicate dir is already of the full path.
     132                                ( external ? external.file : this.fileName + '.js' ) );
    131133        },
    132134
    133135        /**
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy