Ticket #5290: 5290.patch

File 5290.patch, 5.5 KB (added by Alfonso Martínez de Lizarrondo, 14 years ago)

Proposed patch

  • _source/plugins/div/dialogs/div.js

     
    436436
    437437                                // Preparing for the 'elementStyle' field.
    438438                                var dialog = this,
    439                                          stylesField = this.getContentElement( 'info', 'elementStyle' ),
    440                                          // Reuse the 'stylescombo' plugin's styles definition.
    441                                          customStylesConfig =  editor.config.stylesCombo_stylesSet,
    442                                          stylesSetName = customStylesConfig && customStylesConfig.split( ':' )[ 0 ];
     439                                         stylesField = this.getContentElement( 'info', 'elementStyle' );
    443440
    444                                 if ( stylesSetName )
     441                                 // Reuse the 'stylescombo' plugin's styles definition.
     442                                editor.getStylesSet && editor.getStylesSet( function( stylesDefinitions )
    445443                                {
    446                                         CKEDITOR.stylesSet.load( stylesSetName,
    447                                                 function( stylesSet )
    448                                                 {
    449                                                         var stylesDefinitions = stylesSet[ stylesSetName ],
    450                                                                 styleName;
     444                                        var styleName;
    451445
    452                                                         if ( stylesDefinitions )
     446                                        if ( stylesDefinitions )
     447                                        {
     448                                                // Digg only those styles that apply to 'div'.
     449                                                for ( var i = 0 ; i < stylesDefinitions.length ; i++ )
     450                                                {
     451                                                        var styleDefinition = stylesDefinitions[ i ];
     452                                                        if ( styleDefinition.element && styleDefinition.element == 'div' )
    453453                                                        {
    454                                                                 // Digg only those styles that apply to 'div'.
    455                                                                 for ( var i = 0 ; i < stylesDefinitions.length ; i++ )
    456                                                                 {
    457                                                                         var styleDefinition = stylesDefinitions[ i ];
    458                                                                         if ( styleDefinition.element && styleDefinition.element == 'div' )
    459                                                                         {
    460                                                                                 styleName = styleDefinition.name;
    461                                                                                 styles[ styleName ] = new CKEDITOR.style( styleDefinition );
     454                                                                styleName = styleDefinition.name;
     455                                                                styles[ styleName ] = new CKEDITOR.style( styleDefinition );
    462456
    463                                                                                 // Populate the styles field options with style name.
    464                                                                                 stylesField.items.push( [ styleName, styleName ] );
    465                                                                                 stylesField.add( styleName, styleName );
    466                                                                         }
    467                                                                 }
     457                                                                // Populate the styles field options with style name.
     458                                                                stylesField.items.push( [ styleName, styleName ] );
     459                                                                stylesField.add( styleName, styleName );
    468460                                                        }
     461                                                }
     462                                        }
    469463
     464                                        // We should disable the content element
     465                                        // it if no options are available at all.
     466                                        stylesField[ stylesField.items.length > 1 ? 'enable' : 'disable' ]();
    470467
    471                                                         // We should disable the content element
    472                                                         // it if no options are available at all.
    473                                                         stylesField[ stylesField.items.length > 1 ? 'enable' : 'disable' ]();
    474 
    475                                                         // Now setup the field value manually.
    476                                                         setTimeout( function() { stylesField.setup( dialog._element ); }, 0 );
    477                                                 } );
    478                                 }
     468                                        // Now setup the field value manually.
     469                                        setTimeout( function() { stylesField.setup( dialog._element ); }, 0 );
     470                                } );
    479471                        },
    480472                        onShow : function()
    481473                        {
  • _source/plugins/stylescombo/plugin.js

     
    55
    66(function()
    77{
    8         var stylesManager;
    9 
    108        CKEDITOR.plugins.add( 'stylescombo',
    119        {
    1210                requires : [ 'richcombo', 'styles' ],
     
    1513                {
    1614                        var config = editor.config,
    1715                                lang = editor.lang.stylesCombo,
    18                                 pluginPath = this.path,
    1916                                styles;
    2017
    21                         if ( !stylesManager )
    22                                 stylesManager = CKEDITOR.stylesSet;
    23 
    24                         var comboStylesSet = config.stylesCombo_stylesSet.split( ':' ),
    25                                 styleSetName = comboStylesSet[ 0 ],
    26                                 externalPath = comboStylesSet[ 1 ];
    27 
    28                         stylesManager.addExternal( styleSetName,
    29                                         externalPath ?
    30                                                 comboStylesSet.slice( 1 ).join( ':' ) :
    31                                                 pluginPath + 'styles/' + styleSetName + '.js', '' );
    32 
    3318                        editor.ui.addRichCombo( 'Styles',
    3419                                {
    3520                                        label : lang.label,
     
    4732                                        {
    4833                                                var combo = this;
    4934
    50                                                 CKEDITOR.stylesSet.load( styleSetName, function( stylesSet )
     35                                                editor.getStylesSet( function( stylesDefinitions )
    5136                                                        {
    52                                                                 var stylesDefinitions = stylesSet[ styleSetName ],
    53                                                                         style,
     37                                                                var style,
    5438                                                                        styleName,
    5539                                                                        stylesList = [];
    5640
     
    260244})();
    261245
    262246/**
     247 * Gets the current styleset for this instance
     248 * @param {Function} The function to be called with the styles data.
     249 * @example
     250 * editor.getStylesSet( function( stylesDefinitions ) {} );
     251 */
     252CKEDITOR.editor.prototype.getStylesSet = function( callback )
     253{
     254        if (!this._.stylesDefinitions)
     255        {
     256                var editor = this,
     257                        comboStylesSet = editor.config.stylesCombo_stylesSet.split( ':' ),
     258                        styleSetName = comboStylesSet[ 0 ],
     259                        externalPath = comboStylesSet[ 1 ],
     260                        pluginPath = CKEDITOR.plugins.registered.stylescombo.path;
     261
     262                CKEDITOR.stylesSet.addExternal( styleSetName,
     263                                externalPath ?
     264                                        comboStylesSet.slice( 1 ).join( ':' ) :
     265                                        pluginPath + 'styles/' + styleSetName + '.js', '' );
     266
     267
     268                CKEDITOR.stylesSet.load( styleSetName, function( stylesSet )
     269                        {
     270                                editor._.stylesDefinitions = stylesSet[ styleSetName ];
     271                                callback( editor._.stylesDefinitions );
     272                        } ) ;
     273        }
     274        else
     275                callback( this._.stylesDefinitions );
     276};
     277
     278/**
    263279 * The "styles definition set" to load into the styles combo. The styles may
    264280 * be defined in the page containing the editor, or can be loaded on demand
    265281 * from an external file when opening the styles combo for the fist time. In
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy