Ticket #6005: 6005.patch

File 6005.patch, 4.1 KB (added by Frederico Caldeira Knabben, 14 years ago)
  • _source/core/dom/range.js

     
    16321632                },
    16331633
    16341634                /**
    1635                  * Check whether current range is on the inner edge of the specified element.
    1636                  * @param {Number} checkType ( CKEDITOR.START | CKEDITOR.END ) The checking side.
     1635                 * Check whether a range boundary is at the inner boundary of a given
     1636                 * element.
    16371637                 * @param {CKEDITOR.dom.element} element The target element to check.
     1638                 * @param {Number} checkType The boundary to check for both the range
     1639                 *              and the element. It can be CKEDITOR.START or CKEDITOR.END.
     1640                 * @returns {Boolean} "true" if the range boundary is at the inner
     1641                 *              boundary of the element.
    16381642                 */
    16391643                checkBoundaryOfElement : function( element, checkType )
    16401644                {
     1645                        var checkStart = ( checkType == CKEDITOR.START );
     1646
     1647                        // Create a copy of this range, so we can manipulate it for our checks.
    16411648                        var walkerRange = this.clone();
     1649
     1650                        // Collapse the range at the proper size.
     1651                        walkerRange.collapse( checkStart );
     1652
    16421653                        // Expand the range to element boundary.
    1643                         walkerRange[ checkType == CKEDITOR.START ?
    1644                          'setStartAt' : 'setEndAt' ]
    1645                          ( element, checkType == CKEDITOR.START ?
    1646                            CKEDITOR.POSITION_AFTER_START
    1647                            : CKEDITOR.POSITION_BEFORE_END );
     1654                        walkerRange[ checkStart ? 'setStartAt' : 'setEndAt' ]
     1655                         ( element, checkStart ? CKEDITOR.POSITION_AFTER_START : CKEDITOR.POSITION_BEFORE_END );
    16481656
     1657                        // Create the walker, which will check if we have anything useful
     1658                        // in the range.
    16491659                        var walker = new CKEDITOR.dom.walker( walkerRange );
    16501660                        walker.evaluator = elementBoundaryEval;
    1651                         return walker[ checkType == CKEDITOR.START ?
    1652                                 'checkBackward' : 'checkForward' ]();
     1661
     1662                        return walker[ checkStart ? 'checkBackward' : 'checkForward' ]();
    16531663                },
    16541664
    16551665                // Calls to this function may produce changes to the DOM. The range may
  • _source/plugins/styles/plugin.js

     
    582582
    583583                                if ( this.checkElementRemovable( element ) )
    584584                                {
    585                                         var endOfElement = range.checkBoundaryOfElement( element, CKEDITOR.END ),
    586                                                         startOfElement = !endOfElement && range.checkBoundaryOfElement( element, CKEDITOR.START );
    587                                         if ( startOfElement || endOfElement )
     585                                        var isStart;
     586
     587                                        if ( range.collapsed && (
     588                                                 range.checkBoundaryOfElement( element, CKEDITOR.END ) ||
     589                                                 ( isStart = range.checkBoundaryOfElement( element, CKEDITOR.START ) ) ) )
    588590                                        {
    589591                                                boundaryElement = element;
    590                                                 boundaryElement.match = startOfElement ? 'start' : 'end';
     592                                                boundaryElement.match = isStart ? 'start' : 'end';
    591593                                        }
    592594                                        else
    593595                                        {
  • _source/plugins/wysiwygarea/plugin.js

     
    4545                                        selection.unlock();
    4646
    4747                                var $sel = selection.getNative();
     48
     49                                // Delete control selections to avoid IE bugs on pasteHTML.
    4850                                if ( $sel.type == 'Control' )
    4951                                        $sel.clear();
     52                                else if  ( selection.getType() == CKEDITOR.SELECTION_TEXT )
     53                                {
     54                                        // Due to IE bugs on handling contenteditable=false blocks
     55                                        // (#6005), we need to make some checks and eventually
     56                                        // delete the selection first.
     57
     58                                        var range = selection.getRanges()[0],
     59                                                endContainer = range && range.endContainer;
     60                                       
     61                                        if ( endContainer &&
     62                                                 endContainer.type == CKEDITOR.NODE_ELEMENT &&
     63                                                 endContainer.getAttribute( 'contenteditable' ) == 'false' &&
     64                                                 range.checkBoundaryOfElement( endContainer, CKEDITOR.END ) )
     65                                        {
     66                                                range.setEndAfter( range.endContainer );
     67                                                range.deleteContents();
     68                                        }
     69                                }
     70
    5071                                $sel.createRange().pasteHTML( data );
    5172
    5273                                if ( selIsLocked )
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy