Ticket #6107: 6107.patch

File 6107.patch, 1.6 KB (added by Sa'ar Zac Elias, 14 years ago)
  • _source/plugins/styles/plugin.js

     
    738738
    739739                while ( ( block = iterator.getNextParagraph() ) )               // Only one =
    740740                {
    741                         var newBlock = getElement( this, doc );
    742                         replaceBlock( block, newBlock );
     741                        var newBlock = getElement( this, doc ),
     742                                def = this._.definition,
     743                                attributes = def.attributes,
     744                                styles = def.styles;
     745
     746                        if ( block.getName() == def.element )
     747                        {
     748                                for ( var attName in attributes )
     749                                {
     750                                        if ( newBlock.getAttribute( attName ) == block.getAttribute( attName ) )
     751                                                newBlock.removeAttribute( attName );
     752                                }
     753
     754                                for ( var styleName in styles )
     755                                {
     756                                        if ( newBlock.getStyle( styleName ) == block.getStyle( styleName ) )
     757                                                newBlock.removeStyle( styleName );
     758                                }
     759
     760                                if ( newBlock.hasAttributes() )
     761                                        replaceBlock( block, newBlock )
     762                                else
     763                                        removeBlockStyle( block, this._.enterMode );
     764                        }
     765                        else
     766                                replaceBlock( block, newBlock )
     767                       
    743768                }
    744769
    745770                range.moveToBookmark( bookmark );
    746771        }
     772        function removeBlockStyle( block, enterMode )
     773        {
     774                if ( enterMode == CKEDITOR.ENTER_BR )
     775                        block.remove( true );
     776                else
     777                        replaceBlock( block, new CKEDITOR.dom.element( enterMode == CKEDITOR.ENTER_DIV ? 'div' : 'p' ) );
     778        }
    747779
    748780        // Replace the original block with new one, with special treatment
    749781        // for <pre> blocks to make sure content format is well preserved, and merging/splitting adjacent
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy