Ticket #3167: 3167.patch

File 3167.patch, 1.4 KB (added by Martin Kou, 15 years ago)
  • _source/plugins/enterkey/plugin.js

     
    211211
    212212                var isEndOfBlock = range.checkEndOfBlock();
    213213
    214                 var elementPath = new CKEDITOR.dom.elementPath( range.getBoundaryNodes().startNode );
     214                var startNode = range.getBoundaryNodes().startNode;
     215               
     216                /*
     217                 * It is possible (and correct) for getBoundaryNodes() to return a startNode
     218                 * that's outside of a collapsed selection's parent element in IE. e.g.
     219                 *
     220                 * <li>Some text here^</li></ul>extra   <-- extra becomes the startNode
     221                 *
     222                 * Such a startNode makes sense for the style system, but it doesn't make
     223                 * sense when we want to split that <li>.
     224                 *
     225                 * So for IE, we'll need to a do an extra check on the native range's parent
     226                 * element. (#3167)
     227                 */
     228                if ( CKEDITOR.env.ie )
     229                {
     230                        var $range = editor.getSelection().getNative().createRange();
    215231
     232                        if ( $range.parentElement )
     233                        {
     234                                var parentElement = new CKEDITOR.dom.element( $range.parentElement() );
     235                                if ( !parentElement.contains( startNode ) )
     236                                        startNode = parentElement;
     237                        }
     238                }
     239
     240                var elementPath = new CKEDITOR.dom.elementPath( startNode );
     241
    216242                var startBlock = elementPath.block,
    217243                        startBlockTag = startBlock && elementPath.block.getName();
    218244
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy