Ticket #8386: Fix_working_copy.patch

File Fix_working_copy.patch, 2.2 KB (added by Yaswanth, 13 years ago)

Workaround 3_Working copy of Fix.

  • _source/plugins/wysiwygarea/plugin.js

     
    2121        function checkReadOnly( selection )
    2222        {
    2323                if ( selection.getType() == CKEDITOR.SELECTION_ELEMENT )
    2424                        return selection.getSelectedElement().isReadOnly();
    2525                else
    2626                        return selection.getCommonAncestor().isReadOnly();
    2727        }
     28       
     29        function cleanupOnInsertHtmlTest(selection, htmlData){
     30                       
     31                        var ranges = selection.getRanges(),
     32                                element = CKEDITOR.dom.element.createFromHtml(htmlData),
     33                                elementName = element.getName(),
     34                                isBlock = CKEDITOR.dtd.$block[ elementName ];
     35
     36                        var range;
     37
     38                        for ( var i = ranges.length - 1 ; i >= 0 ; i-- )
     39                        {
     40                                range = ranges[ i ];
     41
     42                                // Remove the original contents.
     43                                range.deleteContents();
     44
     45                                // If we're inserting a block at dtd-violated position, split
     46                                // the parent blocks until we reach blockLimit.
     47                                var current, dtd;
     48                                if ( isBlock )
     49                                {
     50                                        while ( ( current = range.getCommonAncestor( 0, 1 ) )
     51                                                        && ( dtd = CKEDITOR.dtd[ current.getName() ] )
     52                                                        && !( dtd && dtd [ elementName ] ) )
     53                                        {
     54                                                // Split up inline elements.
     55                                                if ( current.getName() in CKEDITOR.dtd.span )
     56                                                        range.splitElement( current );
     57                                                // If we're in an empty block which indicate a new paragraph,
     58                                                // simply replace it with the inserting block.(#3664)
     59                                                else if ( range.checkStartOfBlock()
     60                                                         && range.checkEndOfBlock() )
     61                                                {
     62                                                        range.setStartBefore( current );
     63                                                        range.collapse( true );
     64                                                        current.remove();
     65                                                }
     66                                                else
     67                                                        range.splitBlock();
     68                                        }
     69                                }
     70                        }
     71
     72                        selection.selectRanges( [ range ] );
     73
     74                        return ;
     75        }
    2876
    2977        function onInsertHtml( evt )
    3078        {
    3179                if ( this.mode == 'wysiwyg' )
    3280                {
    3381                        this.focus();
    3482
     
    3886
    3987                        var data = evt.data;
    4088                        this.fire( 'saveSnapshot' );
    4189
    4290                        if ( this.dataProcessor )
    4391                                data = this.dataProcessor.toHtml( data );
    4492
     93                        cleanupOnInsertHtmlTest(selection,data);
     94                       
    4595                        if ( CKEDITOR.env.ie )
    4696                        {
    4797                                var selIsLocked = selection.isLocked;
    4898
    4999                                if ( selIsLocked )
    50100                                        selection.unlock();
    51101
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy