Ticket #5336: 5336.patch

File 5336.patch, 2.2 KB (added by Tobiasz Cudnik, 14 years ago)
  • _source/plugins/styles/plugin.js

     
    137137                        return ( this.removeFromRange =
    138138                                                this.type == CKEDITOR.STYLE_INLINE ?
    139139                                                        removeInlineStyle
     140                                                : this.type == CKEDITOR.STYLE_OBJECT ?
     141                                                        removeObjectStyle
    140142                                                : null ).call( this, range );
    141143                },
    142144
     
    719721                element && setupElement( element, this );
    720722        }
    721723
     724        function removeObjectStyle( range )
     725        {
     726                var root = range.getCommonAncestor( true, true ),
     727                                element = root.getAscendant( this.element, true );
     728
     729                if ( !element )
     730                        return;
     731
     732                var style = this;
     733                var def = style._.definition;
     734                var attributes = def.attributes;
     735                var styles = CKEDITOR.style.getStyleText( def );
     736
     737                // Remove all defined attributes.
     738                if ( attributes )
     739                {
     740                        for ( var att in attributes )
     741                        {
     742                                element.removeAttribute( att, attributes[ att ] );
     743                        }
     744                }
     745
     746                // Assign all defined styles.
     747                if ( def.styles )
     748                {
     749                        for ( var i in def.styles )
     750                        {
     751                                if ( !def.styles.hasOwnProperty( i ) )
     752                                        continue;
     753                               
     754                                element.removeStyle( i );
     755                        }
     756                }
     757        }
     758
    722759        function applyBlockStyle( range )
    723760        {
    724761                // Serializible bookmarks is needed here since
     
    10801117                }
    10811118
    10821119                // Assign all defined styles.
    1083                 if ( styles )
    1084                         el.setAttribute( 'style', styles );
     1120                if ( def.styles )
     1121                {
     1122                        for ( var i in def.styles )
     1123                        {
     1124                                if ( !def.styles.hasOwnProperty( i ) )
     1125                                        continue;
    10851126
     1127                                el.setStyle( i, def.styles[ i ] );
     1128                        }
     1129                }
     1130
    10861131                return el;
    10871132        }
    10881133
  • _source/plugins/stylescombo/plugin.js

     
    108108
    109109                                                if ( style.type == CKEDITOR.STYLE_INLINE && style.checkActive( elementPath ) )
    110110                                                        style.remove( editor.document );
     111                                                else if ( style.type == CKEDITOR.STYLE_OBJECT && style.checkActive( elementPath ) )
     112                                                        style.remove( editor.document );
    111113                                                else
    112114                                                        style.apply( editor.document );
    113115
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy