Ticket #7645: 7645_4.patch

File 7645_4.patch, 9.6 KB (added by Garry Yao, 13 years ago)
  • _source/plugins/wysiwygarea/plugin.js

     
    759759                                                keystrokeHandler.blockedKeystrokes[ 8 ] = !editable;
    760760                                                keystrokeHandler.attach( domDocument );
    761761
    762                                                 if ( CKEDITOR.env.ie )
    763                                                 {
    764                                                         domDocument.getDocumentElement().addClass( domDocument.$.compatMode );
    765                                                         // Override keystrokes which should have deletion behavior
    766                                                         //  on control types in IE . (#4047)
    767                                                         editable && domDocument.on( 'keydown', function( evt )
    768                                                         {
    769                                                                 var keyCode = evt.data.getKeystroke();
     762                                                domDocument.getDocumentElement().addClass( domDocument.$.compatMode );
     763                                                // Override keystroke behaviors.
     764                                                editable && domDocument.on( 'keydown', function( evt )
     765                                                {
     766                                                        var keyCode = evt.data.getKeystroke();
    770767
    771                                                                 // Backspace OR Delete.
    772                                                                 if ( keyCode in { 8 : 1, 46 : 1 } )
    773                                                                 {
    774                                                                         var sel = editor.getSelection(),
    775                                                                                 control = sel.getSelectedElement();
     768                                                        // Backspace OR Delete.
     769                                                        if ( keyCode in { 8 : 1, 46 : 1 } )
     770                                                        {
     771                                                                var sel = editor.getSelection(),
     772                                                                        selected = sel.getSelectedElement(),
     773                                                                        range  = sel.getRanges()[ 0 ];
    776774
    777                                                                         if ( control )
    778                                                                         {
    779                                                                                 // Make undo snapshot.
    780                                                                                 editor.fire( 'saveSnapshot' );
     775                                                                // Override keystrokes which should have deletion behavior
     776                                                                //  on control types in IE . (#4047)
     777                                                                if ( CKEDITOR.env.ie && selected )
     778                                                                {
     779                                                                        // Make undo snapshot.
     780                                                                        editor.fire( 'saveSnapshot' );
    781781
    782                                                                                 // Delete any element that 'hasLayout' (e.g. hr,table) in IE8 will
    783                                                                                 // break up the selection, safely manage it here. (#4795)
    784                                                                                 var bookmark = sel.getRanges()[ 0 ].createBookmark();
    785                                                                                 // Remove the control manually.
    786                                                                                 control.remove();
    787                                                                                 sel.selectBookmarks( [ bookmark ] );
     782                                                                        // Delete any element that 'hasLayout' (e.g. hr,table) in IE8 will
     783                                                                        // break up the selection, safely manage it here. (#4795)
     784                                                                        var bookmark = range.createBookmark();
     785                                                                        // Remove the control manually.
     786                                                                        selected.remove();
     787                                                                        sel.selectBookmarks( [ bookmark ] );
    788788
    789                                                                                 editor.fire( 'saveSnapshot' );
     789                                                                        editor.fire( 'saveSnapshot' );
    790790
    791                                                                                 evt.data.preventDefault();
    792                                                                         }
    793                                                                 }
    794                                                         } );
     791                                                                        evt.data.preventDefault();
     792                                                                        return;
     793                                                                }
     794
     795                                                                // A fully selected table/list produces a range anchors only at inner boundaries, enlarge it here. (#7645)
     796                                                                if ( range.enlarge( CKEDITOR.ENLARGE_LIST_TABLE ) )
     797                                                                        range.select();
     798                                                                debugger;
     799                                                        }
     800                                                } );
    795801
    796                                                         // PageUp/PageDown scrolling is broken in document
    797                                                         // with standard doctype, manually fix it. (#4736)
    798                                                         if ( domDocument.$.compatMode == 'CSS1Compat' )
    799                                                         {
    800                                                                 var pageUpDownKeys = { 33 : 1, 34 : 1 };
    801                                                                 domDocument.on( 'keydown', function( evt )
    802                                                                 {
    803                                                                         if ( evt.data.getKeystroke() in pageUpDownKeys )
    804                                                                         {
    805                                                                                 setTimeout( function ()
    806                                                                                 {
    807                                                                                         editor.getSelection().scrollIntoView();
    808                                                                                 }, 0 );
    809                                                                         }
    810                                                                 } );
    811                                                         }
     802                                                // PageUp/PageDown scrolling is broken in document
     803                                                // with standard doctype, manually fix it. (#4736)
     804                                                if ( CKEDITOR.env.ie && domDocument.$.compatMode == 'CSS1Compat' )
     805                                                {
     806                                                        var pageUpDownKeys = { 33 : 1, 34 : 1 };
     807                                                        domDocument.on( 'keydown', function( evt )
     808                                                        {
     809                                                                if ( evt.data.getKeystroke() in pageUpDownKeys )
     810                                                                {
     811                                                                        setTimeout( function ()
     812                                                                        {
     813                                                                                editor.getSelection().scrollIntoView();
     814                                                                        }, 0 );
     815                                                                }
     816                                                        } );
     817                                                }
    812818
    813                                                         // Prevent IE from leaving new paragraph after deleting all contents in body. (#6966)
    814                                                         editor.config.enterMode != CKEDITOR.ENTER_P
    815                                                                 && domDocument.on( 'selectionchange', function()
    816                                                                 {
    817                                                                         var body = domDocument.getBody(),
    818                                                                                 range = editor.getSelection().getRanges()[ 0 ];
     819                                                // Prevent IE from leaving new paragraph after deleting all contents in body. (#6966)
     820                                                if ( CKEDITOR.env.ie && editor.config.enterMode != CKEDITOR.ENTER_P )
     821                                                {
     822                                                        domDocument.on( 'selectionchange', function()
     823                                                        {
     824                                                                var body = domDocument.getBody(),
     825                                                                        range = editor.getSelection().getRanges()[ 0 ];
    819826
    820                                                                         if ( body.getHtml().match( /^<p>&nbsp;<\/p>$/i )
    821                                                                                 && range.startContainer.equals( body ) )
    822                                                                         {
    823                                                                                 // Avoid the ambiguity from a real user cursor position.
    824                                                                                 setTimeout( function ()
    825                                                                                 {
    826                                                                                         range = editor.getSelection().getRanges()[ 0 ];
    827                                                                                         if ( !range.startContainer.equals ( 'body' ) )
    828                                                                                         {
    829                                                                                                 body.getFirst().remove( 1 );
    830                                                                                                 range.moveToElementEditEnd( body );
    831                                                                                                 range.select( 1 );
    832                                                                                         }
    833                                                                                 }, 0 );
    834                                                                         }
    835                                                                 });
     827                                                                if ( body.getHtml().match( /^<p>&nbsp;<\/p>$/i )
     828                                                                        && range.startContainer.equals( body ) )
     829                                                                {
     830                                                                        // Avoid the ambiguity from a real user cursor position.
     831                                                                        setTimeout( function ()
     832                                                                        {
     833                                                                                range = editor.getSelection().getRanges()[ 0 ];
     834                                                                                if ( !range.startContainer.equals ( 'body' ) )
     835                                                                                {
     836                                                                                        body.getFirst().remove( 1 );
     837                                                                                        range.moveToElementEditEnd( body );
     838                                                                                        range.select( 1 );
     839                                                                                }
     840                                                                        }, 0 );
     841                                                                }
     842                                                        });
    836843                                                }
    837844
    838845                                                // Adds the document body as a context menu target.
  • _source/plugins/selection/plugin.js

     
    463463
    464464                                                doc.on( 'mouseup', checkSelectionChangeTimeout, editor );
    465465                                                doc.on( 'keyup', checkSelectionChangeTimeout, editor );
     466                                                doc.on( 'selectionchange', checkSelectionChangeTimeout, editor );
    466467                                        }
    467468                                });
    468469
     
    14321433                                        sel.addRange( nativeRange );
    14331434                                }
    14341435
     1436                                // Don't miss selection change event for non-IEs.
     1437                                this.document.fire( 'selectionchange' );
    14351438                                this.reset();
    14361439                        }
    14371440                },
  • _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(),
     
    13651364                                        // one and we're expanding list item contents
    13661365                                        if ( tailBr )
    13671366                                                this.setEndAfter( tailBr );
    1368                         }
     1367                                        break;
     1368
     1369                                case CKEDITOR.ENLARGE_LIST_TABLE:
     1370
     1371                                        var ancestor = this.getCommonAncestor( 1, 1 ),
     1372                                                root;
     1373
     1374                                        var tags = { table:1,ul:1,ol:1,dl:1};
     1375                                        for ( var t in tags )
     1376                                        {
     1377                                                root = ancestor.getAscendant( t, 1 );
     1378                                                if ( root ) break;
     1379                                        }
     1380
     1381                                        if ( !root )
     1382                                                return false;
     1383
     1384                                        // Enlarging the start boundary.
     1385                                        walkerRange = new CKEDITOR.dom.range( this.document );
     1386                                        walkerRange.setStartAt( root, CKEDITOR.POSITION_AFTER_START );
     1387                                        walkerRange.setEnd( this.startContainer, this.startOffset );
     1388
     1389                                        var enlargeables = CKEDITOR.tools.extend( tags, CKEDITOR.dtd.$listItem, CKEDITOR.dtd.$tableContent );
     1390                                        walker = new CKEDITOR.dom.walker( walkerRange ),
     1391
     1392                                        // Check the range is at the inner boundary of the structural element.
     1393                                        guard = function( walker, isEnd )
     1394                                        {
     1395                                                return function( node, isWalkOut )
     1396                                                {
     1397                                                        if ( node.type == CKEDITOR.NODE_TEXT && ( !CKEDITOR.tools.trim( node.getText() ) || node.getParent().data( 'cke-bookmark' ) ) )
     1398                                                                return true;
     1399
     1400                                                        var tag;
     1401                                                        if ( node.type == CKEDITOR.NODE_ELEMENT )
     1402                                                        {
     1403                                                                tag = node.getName();
     1404
     1405                                                                // Bypass bogus br at the end of block.
     1406                                                                if ( tag == 'br' && isEnd && node.equals( node.getParent().getBogus() ) )
     1407                                                                        return true;
     1408
     1409                                                                if ( isWalkOut && tag in enlargeables || tag in CKEDITOR.dtd.$removeEmpty )
     1410                                                                        return true;
     1411                                                        }
     1412
     1413                                                        walker.halted = 1;
     1414                                                        return false;
     1415                                                };
     1416                                        };
     1417
     1418                                        walker.guard = guard( walker );
     1419
     1420                                        if ( walker.checkBackward() && !walker.halted )
     1421                                        {
     1422                                                walker = new CKEDITOR.dom.walker( walkerRange );
     1423                                                walkerRange.setStart( this.endContainer, this.endOffset );
     1424                                                walkerRange.setEndAt( root, CKEDITOR.POSITION_BEFORE_END );
     1425                                                walker.guard = guard( walker, 1 );
     1426                                                if ( walker.checkForward() && !walker.halted )
     1427                                                {
     1428                                                        this.setStartBefore( root );
     1429                                                        this.setEndAfter( root );
     1430                                                        return true;
     1431                                                }
     1432                                        }
     1433                        }
    13691434                },
    13701435
    13711436                /**
     
    20352100CKEDITOR.ENLARGE_ELEMENT = 1;
    20362101CKEDITOR.ENLARGE_BLOCK_CONTENTS = 2;
    20372102CKEDITOR.ENLARGE_LIST_ITEM_CONTENTS = 3;
     2103CKEDITOR.ENLARGE_LIST_TABLE = 4;
    20382104
    20392105// Check boundary types.
    20402106// @see CKEDITOR.dom.range.prototype.checkBoundaryOfElement
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy