Ticket #7035: 7035.patch

File 7035.patch, 4.9 KB (added by Garry Yao, 13 years ago)
  • _source/core/dom/element.js

     
    947947                        }
    948948                },
    949949
     950                /**
     951                 * @param {Boolean} [inlineOnly=true] Allow only inline elements to be merged.
     952                 */
    950953                mergeSiblings : ( function()
    951954                {
    952955                        function mergeElements( element, sibling, isNext )
     
    986989                                }
    987990                        }
    988991
    989                         return function()
     992                        return function( inlineOnly )
    990993                                {
    991                                         // Merge empty links and anchors also. (#5567)
    992                                         if ( !( CKEDITOR.dtd.$removeEmpty[ this.getName() ] || this.is( 'a' ) ) )
     994                                        if ( ! ( inlineOnly === false
     995                                                        || CKEDITOR.dtd.$removeEmpty[ this.getName() ]
     996                                                        || this.is( 'a' ) ) )   // Merge empty links and anchors also. (#5567)
     997                                        {
    993998                                                return;
     999                                        }
    9941000
    9951001                                        mergeElements( this, this.getNext(), true );
    9961002                                        mergeElements( this, this.getPrevious() );
  • _source/plugins/wysiwygarea/plugin.js

     
    205205
    206206                                if ( !range.checkReadOnly() )
    207207                                {
    208                                         // Remove the original contents.
    209                                         range.deleteContents();
     208                                        // Remove the original contents, merge splitted nodes.
     209                                        range.deleteContents( 1 );
    210210
    211211                                        clone = !i && element || element.clone( 1 );
    212212
  • _source/core/dom/range.js

     
    3232        // This is a shared function used to delete, extract and clone the range
    3333        // contents.
    3434        // V2
    35         var execContentsAction = function( range, action, docFrag )
     35        var execContentsAction = function( range, action, docFrag, mergeThen )
    3636        {
    3737                range.optimizeBookmark();
    3838
     
    247247                                if ( removeStartNode && topEnd.$.parentNode == startNode.$.parentNode )
    248248                                        endIndex--;
    249249
    250                                 range.setStart( topEnd.getParent(), endIndex );
     250                                // Merge splitted parents.
     251                                if ( mergeThen )
     252                                {
     253                                        var span = CKEDITOR.dom.element.createFromHtml( '<span ' +
     254                                                'data-cke-bookmark="1" style="display:none">&nbsp;</span>', range.document );
     255                                        span.insertAfter( topStart );
     256                                        topStart.mergeSiblings( false );
     257                                        range.moveToBookmark( { startNode : span } );
     258                                }
     259                                else
     260                                        range.setStart( topEnd.getParent(), endIndex );
    251261                        }
    252262
    253263                        // Collapse it to the start.
     
    367377
    368378                /**
    369379                 * Deletes the content nodes of the range permanently from the DOM tree.
     380                 * @param {Boolean} [mergeThen] Merge any splitted elements result in DOM true due to partial selection.
    370381                 */
    371                 deleteContents : function()
     382                deleteContents : function( mergeThen )
    372383                {
    373384                        if ( this.collapsed )
    374385                                return;
    375386
    376                         this.fixListRange();
    377                         execContentsAction( this, 0 );
     387                        execContentsAction( this, 0, null, mergeThen );
    378388                },
    379389
    380390                /**
    381391                 *  The content nodes of the range are cloned and added to a document fragment,
    382392                 * meanwhile they're removed permanently from the DOM tree.
     393                 * @param {Boolean} [mergeThen] Merge any splitted elements result in DOM true due to partial selection.
    383394                 */
    384                 extractContents : function()
     395                extractContents : function( mergeThen )
    385396                {
    386397                        var docFrag = new CKEDITOR.dom.documentFragment( this.document );
    387398
    388399                        if ( !this.collapsed )
    389                                 execContentsAction( this, 1, docFrag );
     400                                execContentsAction( this, 1, docFrag, mergeThen );
    390401
    391402                        return docFrag;
    392403                },
     
    19101921                                return container ;
    19111922
    19121923                        return container.getChild( this.endOffset - 1 ) || container ;
    1913                 },
    1914 
    1915                 // Fix list selection range where entire range is selected from the inner side.
    1916                 // <ul><li>[...]</li></ul> =>   [<ul><li>...</li></ul>]
    1917                 fixListRange : (function()
    1918                 {
    1919                         function moveListBoundary( fixEnd )
    1920                         {
    1921                                 var listItem, listRoot;
    1922                                 if ( ( listItem = this[ fixEnd ? 'endContainer' : 'startContainer' ].getAscendant( 'li', 1 ) )
    1923                                                 && this.checkBoundaryOfElement( listItem, fixEnd ? CKEDITOR.END : CKEDITOR.START )
    1924                                                 && ( listRoot = listItem.getParent() )
    1925                                                 && ( listItem.equals( listRoot[ fixEnd ? 'getLast' : 'getFirst' ]( CKEDITOR.dom.walker.nodeType( CKEDITOR.NODE_ELEMENT ) ) ) )
    1926                                                 // Make the fix only when both sides are in same situation.
    1927                                                 && ( fixEnd || moveListBoundary.call( this, 1 ) ) )
    1928                                 {
    1929                                         this[ fixEnd ? 'setEndAt' : 'setStartAt' ]( listRoot, fixEnd ?
    1930                                                 CKEDITOR.POSITION_AFTER_END : CKEDITOR.POSITION_BEFORE_START );
    1931                                         return true;
    1932                                 }
    1933                         }
    1934 
    1935                         return function()
    1936                         {
    1937                                 moveListBoundary.call( this );
    1938                         };
    1939                 })()
    1940         };
     1924                }
     1925        };
    19411926})();
    19421927
    19431928CKEDITOR.POSITION_AFTER_START   = 1;    // <element>^contents</element>         "^text"
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy