Ticket #6107: 6107_3.patch

File 6107_3.patch, 3.9 KB (added by Sa'ar Zac Elias, 13 years ago)
  • _source/plugins/format/plugin.js

     
    5454                                        editor.focus();
    5555                                        editor.fire( 'saveSnapshot' );
    5656
    57                                         styles[ value ].apply( editor.document );
     57                                        var style = styles[ value ],
     58                                                elementPath = new CKEDITOR.dom.elementPath( editor.getSelection().getStartElement() );
    5859
     60                                        style[ style.checkActive( elementPath ) ? 'remove' : 'apply' ]( editor.document );
     61
    5962                                        // Save the undo snapshot after all changes are affected. (#4899)
    6063                                        setTimeout( function()
    6164                                        {
  • _source/plugins/styles/plugin.js

     
    149149                        return ( this.removeFromRange =
    150150                                                this.type == CKEDITOR.STYLE_INLINE ?
    151151                                                        removeInlineStyle
     152                                                : this.type == CKEDITOR.STYLE_BLOCK ?
     153                                                        removeBlockStyle
    152154                                                : this.type == CKEDITOR.STYLE_OBJECT ?
    153155                                                        removeObjectStyle
    154156                                                : null ).call( this, range );
     
    881883                range.moveToBookmark( bookmark );
    882884        }
    883885
     886        function removeBlockStyle( range )
     887        {
     888                // Serializible bookmarks is needed here since
     889                // elements may be merged.
     890                var bookmark = range.createBookmark( 1 );
     891
     892                var iterator = range.createIterator();
     893                iterator.enforceRealBlocks = true;
     894                iterator.enlargeBr = this._.enterMode != CKEDITOR.ENTER_BR;
     895
     896                var block;
     897                while ( ( block = iterator.getNextParagraph() ) )
     898                {
     899                        if ( !this.checkElementRemovable( block ) )
     900                                continue;
     901
     902                        removeFromElement( this, block, 1 );
     903                }
     904
     905                range.moveToBookmark( bookmark );
     906        }
     907
    884908        // Replace the original block with new one, with special treatment
    885909        // for <pre> blocks to make sure content format is well preserved, and merging/splitting adjacent
    886910        // when necessary.(#3188)
     
    10571081        }
    10581082
    10591083        // Removes a style from an element itself, don't care about its subtree.
    1060         function removeFromElement( style, element )
     1084        function removeFromElement( style, element, removeMatch )
    10611085        {
    10621086                var def = style._.definition,
    10631087                        attributes = CKEDITOR.tools.extend( {}, def.attributes, getOverrides( style )[ element.getName() ] ),
     
    10871111                        element.removeStyle( styleName );
    10881112                }
    10891113
    1090                 removeEmpty && removeNoAttribsElement( element );
     1114                // Rename the element if the element is the same element in the style definition and has attributes left.
     1115                if ( removeEmpty && removeMatch && element.hasAttributes() && element.getName() == def.element )
     1116                        element.renameNode( CKEDITOR.dtd.$inline[ element.getName() ] ? 'span' : style._.enterMode == CKEDITOR.ENTER_P ? 'p' : 'div' );
     1117                else if ( removeEmpty )
     1118                        removeNoAttribsElement( element );
    10911119        }
    10921120
    10931121        // Removes a style from inside an element.
     
    14331461
    14341462                var iterator = ranges.createIterator();
    14351463                while ( ( range = iterator.getNextRange() ) )
    1436                 {
    14371464                        func.call( this, range );
    1438                 }
    14391465
    14401466                selection.selectRanges( ranges );
    14411467
  • _source/plugins/stylescombo/plugin.js

     
    106106
    107107                                                var elementPath = new CKEDITOR.dom.elementPath( selection.getStartElement() );
    108108
    109                                                 if ( style.type == CKEDITOR.STYLE_INLINE && style.checkActive( elementPath ) )
    110                                                         style.remove( editor.document );
    111                                                 else if ( style.type == CKEDITOR.STYLE_OBJECT && style.checkActive( elementPath ) )
    112                                                         style.remove( editor.document );
    113                                                 else
    114                                                         style.apply( editor.document );
     109                                                style[ style.checkActive( elementPath ) ? 'remove' : 'apply' ]( editor.document );
    115110
    116111                                                editor.fire( 'saveSnapshot' );
    117112                                        },
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy