Ticket #7645: 7645_2.patch

File 7645_2.patch, 4.7 KB (added by Garry Yao, 14 years ago)
  • _source/plugins/wysiwygarea/plugin.js

     
    758758
    759759                                                                                // Delete any element that 'hasLayout' (e.g. hr,table) in IE8 will
    760760                                                                                // break up the selection, safely manage it here. (#4795)
    761                                                                                 var bookmark = sel.getRanges()[ 0 ].createBookmark();
     761                                                                                var bookmark = range.createBookmark();
    762762                                                                                // Remove the control manually.
    763763                                                                                control.remove();
    764764                                                                                sel.selectBookmarks( [ bookmark ] );
     
    767767
    768768                                                                                evt.data.preventDefault();
    769769                                                                        }
     770
     771                                                                        // A fully selected table/list produces a range anchors only at inner boundaries, enlarge it here. (#7645)
     772                                                                        var range  = sel.getRanges()[ 0 ];
     773                                                                        if ( range.enlarge( CKEDITOR.ENLARGE_LIST_TABLE ) )
     774                                                                                range.select();
    770775                                                                }
    771776                                                        } );
    772777
  • _source/core/dom/walker.js

     
    446446        // Check if there's a filler node at the end of an element, and return it.
    447447        CKEDITOR.dom.element.prototype.getBogus = function()
    448448        {
     449                if ( !this.isBlockBoundary() )
     450                        return null;
     451
    449452                // Bogus are not always at the end, e.g. <p><a>text<br /></a></p> (#7070).
    450453                var tail = this;
    451454                do { tail = tail.getPreviousSourceNode(); }
  • _source/core/dom/range.js

     
    386386        {
    387387                // Reject any text node unless it's being bookmark
    388388                // OR it's spaces. (#3883)
    389                 return node.type != CKEDITOR.NODE_TEXT
    390                             && node.getName() in CKEDITOR.dtd.$removeEmpty
    391                             || !CKEDITOR.tools.trim( node.getText() )
    392                             || !!node.getParent().data( 'cke-bookmark' );
     389                return node.type == CKEDITOR.NODE_TEXT ?
     390                        !CKEDITOR.tools.trim( node.getText() ) || node.getParent().data( 'cke-bookmark' )
     391                        : node.getName() in CKEDITOR.dtd.$removeEmpty;
    393392        }
    394393
    395394        var whitespaceEval = new CKEDITOR.dom.walker.whitespaces(),
     
    13491348                                        // one and we're expanding list item contents
    13501349                                        if ( tailBr )
    13511350                                                this.setEndAfter( tailBr );
    1352                         }
     1351                                        break;
     1352
     1353                                case CKEDITOR.ENLARGE_LIST_TABLE:
     1354
     1355                                        var ancestor = this.getCommonAncestor( 1, 1 ),
     1356                                                root;
     1357
     1358                                        var tags = { table:1,ul:1,ol:1,dl:1};
     1359                                        for ( var t in tags )
     1360                                        {
     1361                                                root = ancestor.getAscendant( t, 1 );
     1362                                                if ( root ) break;
     1363                                        }
     1364
     1365                                        if ( !root )
     1366                                                return false;
     1367
     1368                                        // Enlarging the start boundary.
     1369                                        walkerRange = new CKEDITOR.dom.range( this.document );
     1370                                        walkerRange.setStartAt( root, CKEDITOR.POSITION_AFTER_START );
     1371                                        walkerRange.setEnd( this.startContainer, this.startOffset );
     1372
     1373                                        var enlargeables = CKEDITOR.tools.extend( tags, CKEDITOR.dtd.$listItem, CKEDITOR.dtd.$tableContent );
     1374                                        walker = new CKEDITOR.dom.walker( walkerRange ),
     1375
     1376                                        // Check the range is at the inner boundary of the structural element.
     1377                                        guard = function( walker, isEnd )
     1378                                        {
     1379                                                return function( node, isWalkOut )
     1380                                                {
     1381                                                        if ( node.type == CKEDITOR.NODE_TEXT && ( !CKEDITOR.tools.trim( node.getText() ) || node.getParent().data( 'cke-bookmark' ) ) )
     1382                                                                return true;
     1383
     1384                                                        var tag;
     1385                                                        if ( node.type == CKEDITOR.NODE_ELEMENT )
     1386                                                        {
     1387                                                                tag = node.getName();
     1388
     1389                                                                // Bypass bogus br at the end of block.
     1390                                                                if ( tag == 'br' && isEnd && node.equals( node.getParent().getBogus() ) )
     1391                                                                        return true;
     1392
     1393                                                                if ( isWalkOut && tag in enlargeables || tag in CKEDITOR.dtd.$removeEmpty )
     1394                                                                        return true;
     1395                                                        }
     1396
     1397                                                        walker.halted = 1;
     1398                                                        return false;
     1399                                                };
     1400                                        };
     1401
     1402                                        walker.guard = guard( walker );
     1403
     1404                                        if ( walker.checkBackward() && !walker.halted )
     1405                                        {
     1406                                                walker = new CKEDITOR.dom.walker( walkerRange );
     1407                                                walkerRange.setStart( this.endContainer, this.endOffset );
     1408                                                walkerRange.setEndAt( root, CKEDITOR.POSITION_BEFORE_END );
     1409                                                walker.guard = guard( walker, 1 );
     1410                                                if ( walker.checkForward() && !walker.halted )
     1411                                                {
     1412                                                        this.setStartBefore( root );
     1413                                                        this.setEndAfter( root );
     1414                                                        return true;
     1415                                                }
     1416                                        }
     1417                        }
    13531418                },
    13541419
    13551420                /**
     
    20192084CKEDITOR.ENLARGE_ELEMENT = 1;
    20202085CKEDITOR.ENLARGE_BLOCK_CONTENTS = 2;
    20212086CKEDITOR.ENLARGE_LIST_ITEM_CONTENTS = 3;
     2087CKEDITOR.ENLARGE_LIST_TABLE = 4;
    20222088
    20232089// Check boundary types.
    20242090// @see CKEDITOR.dom.range.prototype.checkBoundaryOfElement
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy