Ticket #7784: 7784_3.patch

File 7784_3.patch, 1.9 KB (added by Garry Yao, 13 years ago)
  • _source/plugins/stylesheetparser/plugin.js

     
    9292        // Register a plugin named "stylesheetparser".
    9393        CKEDITOR.plugins.add( 'stylesheetparser',
    9494        {
    95                 init : function( editor )
     95                requires: [ 'styles' ],
     96                onLoad : function()
    9697                {
    97                         editor.on( 'mode', function( e )
     98                        var obj = CKEDITOR.editor.prototype;
     99                        obj.getStylesSet = CKEDITOR.tools.override( obj.getStylesSet,  function( org )
    98100                        {
    99                                 if ( editor.mode != 'wysiwyg' )
    100                                         return;
    101 
    102                                 // Do this only once
    103                                 e.removeListener();
    104 
    105                                 editor.getStylesSet( function( stylesDefinitions )
    106                                         {
    107                                                         // Rules that must be skipped
    108                                                 var skipSelectors = editor.config.stylesheetParser_skipSelectors || ( /(^body\.|^\.)/i ),
     101                                return function( callback )
     102                                {
     103                                        var self = this;
     104                                        org.call( this, function( definitions )
     105                                        {
     106                                                // Rules that must be skipped
     107                                                var skipSelectors = self.config.stylesheetParser_skipSelectors || ( /(^body\.|^\.)/i ),
    109108                                                        // Rules that are valid
    110                                                         validSelectors = editor.config.stylesheetParser_validSelectors || ( /\w+\.\w+/ );
     109                                                        validSelectors = self.config.stylesheetParser_validSelectors || ( /\w+\.\w+/ );
    111110
    112                                                 // Add the styles found in the document
    113                                                 editor._.stylesDefinitions = stylesDefinitions.concat( LoadStylesCSS( editor.document.$, skipSelectors, validSelectors ) );
    114 
    115                                                 // Refresh the styles combo
    116                                                 var combo = editor.ui._.items[ 'Styles' ];
    117                                                 combo && combo.args[ 0 ].reset();
    118                                         } );
     111                                                callback( ( self._.stylesDefinitions = definitions.concat( LoadStylesCSS( self.document.$, skipSelectors, validSelectors ) ) ) );
     112                                        });
     113                                };
    119114                        });
    120115
    121116                }
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy