Ticket #7645: 7645_5.patch

File 7645_5.patch, 10.3 KB (added by Garry Yao, 13 years ago)
  • _source/plugins/tab/plugin.js

     
    4646                                                var resultRange = new CKEDITOR.dom.range( editor.document ),
    4747                                                                next = CKEDITOR.tools.tryThese( function()
    4848                                                                {
    49                                                                         var row = cell.getParent(),
    50                                                                                         next = row.$.cells[ cell.$.cellIndex + ( backward ? - 1 : 1 ) ];
    51 
    52                                                                         // Invalid any empty value.
    53                                                                         next.parentNode.parentNode;
    54                                                                         return next;
     49                                                                        return cell.getParent().$.cells[ cell.$.cellIndex + ( backward ? - 1 : 1 ) ];
    5550                                                                },
    5651                                                                function()
    5752                                                                {
  • _source/plugins/pastetext/plugin.js

     
    1717                        var clipboardText = CKEDITOR.tools.tryThese(
    1818                                function()
    1919                                {
    20                                         var clipboardText = window.clipboardData.getData( 'Text' );
    21                                         if ( !clipboardText )
    22                                                 throw 0;
    23                                         return clipboardText;
     20                                        return window.clipboardData.getData( 'Text' );
    2421                                }
    2522                                // Any other approach that's working...
    2623                                );
  • _source/plugins/wysiwygarea/plugin.js

     
    749749                                                keystrokeHandler.blockedKeystrokes[ 8 ] = !editable;
    750750                                                keystrokeHandler.attach( domDocument );
    751751
    752                                                 if ( CKEDITOR.env.ie )
    753                                                 {
    754                                                         domDocument.getDocumentElement().addClass( domDocument.$.compatMode );
    755                                                         // Override keystrokes which should have deletion behavior
    756                                                         //  on control types in IE . (#4047)
    757                                                         editable && domDocument.on( 'keydown', function( evt )
    758                                                         {
    759                                                                 var keyCode = evt.data.getKeystroke();
     752                                                domDocument.getDocumentElement().addClass( domDocument.$.compatMode );
     753                                                // Override keystroke behaviors.
     754                                                editable && domDocument.on( 'keydown', function( evt )
     755                                                {
     756                                                        var keyCode = evt.data.getKeystroke();
    760757
    761                                                                 // Backspace OR Delete.
    762                                                                 if ( keyCode in { 8 : 1, 46 : 1 } )
    763                                                                 {
    764                                                                         var sel = editor.getSelection(),
    765                                                                                 control = sel.getSelectedElement();
     758                                                        // Backspace OR Delete.
     759                                                        if ( keyCode in { 8 : 1, 46 : 1 } )
     760                                                        {
     761                                                                var sel = editor.getSelection(),
     762                                                                        selected = sel.getSelectedElement(),
     763                                                                        range  = sel.getRanges()[ 0 ];
    766764
    767                                                                         if ( control )
    768                                                                         {
    769                                                                                 // Make undo snapshot.
    770                                                                                 editor.fire( 'saveSnapshot' );
     765                                                                // Override keystrokes which should have deletion behavior
     766                                                                //  on fully selected element . (#4047) (#7645)
     767                                                                if ( selected )
     768                                                                {
     769                                                                        // Make undo snapshot.
     770                                                                        editor.fire( 'saveSnapshot' );
    771771
    772                                                                                 // Delete any element that 'hasLayout' (e.g. hr,table) in IE8 will
    773                                                                                 // break up the selection, safely manage it here. (#4795)
    774                                                                                 var bookmark = sel.getRanges()[ 0 ].createBookmark();
    775                                                                                 // Remove the control manually.
    776                                                                                 control.remove();
    777                                                                                 sel.selectBookmarks( [ bookmark ] );
     772                                                                        // Delete any element that 'hasLayout' (e.g. hr,table) in IE8 will
     773                                                                        // break up the selection, safely manage it here. (#4795)
     774                                                                        range.moveToPosition( selected, CKEDITOR.POSITION_BEFORE_START );
     775                                                                        // Remove the control manually.
     776                                                                        selected.remove();
     777                                                                        range.select();
    778778
    779                                                                                 editor.fire( 'saveSnapshot' );
     779                                                                        editor.fire( 'saveSnapshot' );
    780780
    781                                                                                 evt.data.preventDefault();
    782                                                                         }
    783                                                                 }
    784                                                         } );
     781                                                                        evt.data.preventDefault();
     782                                                                        return;
     783                                                                }
     784                                                        }
     785                                                } );
    785786
    786                                                         // PageUp/PageDown scrolling is broken in document
    787                                                         // with standard doctype, manually fix it. (#4736)
    788                                                         if ( domDocument.$.compatMode == 'CSS1Compat' )
    789                                                         {
    790                                                                 var pageUpDownKeys = { 33 : 1, 34 : 1 };
    791                                                                 domDocument.on( 'keydown', function( evt )
    792                                                                 {
    793                                                                         if ( evt.data.getKeystroke() in pageUpDownKeys )
    794                                                                         {
    795                                                                                 setTimeout( function ()
    796                                                                                 {
    797                                                                                         editor.getSelection().scrollIntoView();
    798                                                                                 }, 0 );
    799                                                                         }
    800                                                                 } );
    801                                                         }
     787                                                // PageUp/PageDown scrolling is broken in document
     788                                                // with standard doctype, manually fix it. (#4736)
     789                                                if ( CKEDITOR.env.ie && domDocument.$.compatMode == 'CSS1Compat' )
     790                                                {
     791                                                        var pageUpDownKeys = { 33 : 1, 34 : 1 };
     792                                                        domDocument.on( 'keydown', function( evt )
     793                                                        {
     794                                                                if ( evt.data.getKeystroke() in pageUpDownKeys )
     795                                                                {
     796                                                                        setTimeout( function ()
     797                                                                        {
     798                                                                                editor.getSelection().scrollIntoView();
     799                                                                        }, 0 );
     800                                                                }
     801                                                        } );
     802                                                }
    802803
    803                                                         // Prevent IE from leaving new paragraph after deleting all contents in body. (#6966)
    804                                                         editor.config.enterMode != CKEDITOR.ENTER_P
    805                                                                 && domDocument.on( 'selectionchange', function()
    806                                                                 {
    807                                                                         var body = domDocument.getBody(),
    808                                                                                 range = editor.getSelection().getRanges()[ 0 ];
     804                                                // Prevent IE from leaving new paragraph after deleting all contents in body. (#6966)
     805                                                if ( CKEDITOR.env.ie && editor.config.enterMode != CKEDITOR.ENTER_P )
     806                                                {
     807                                                        domDocument.on( 'selectionchange', function()
     808                                                        {
     809                                                                var body = domDocument.getBody(),
     810                                                                        range = editor.getSelection().getRanges()[ 0 ];
    809811
    810                                                                         if ( body.getHtml().match( /^<p>&nbsp;<\/p>$/i )
    811                                                                                 && range.startContainer.equals( body ) )
    812                                                                         {
    813                                                                                 // Avoid the ambiguity from a real user cursor position.
    814                                                                                 setTimeout( function ()
    815                                                                                 {
    816                                                                                         range = editor.getSelection().getRanges()[ 0 ];
    817                                                                                         if ( !range.startContainer.equals ( 'body' ) )
    818                                                                                         {
    819                                                                                                 body.getFirst().remove( 1 );
    820                                                                                                 range.moveToElementEditEnd( body );
    821                                                                                                 range.select( 1 );
    822                                                                                         }
    823                                                                                 }, 0 );
    824                                                                         }
    825                                                                 });
     812                                                                if ( body.getHtml().match( /^<p>&nbsp;<\/p>$/i )
     813                                                                        && range.startContainer.equals( body ) )
     814                                                                {
     815                                                                        // Avoid the ambiguity from a real user cursor position.
     816                                                                        setTimeout( function ()
     817                                                                        {
     818                                                                                range = editor.getSelection().getRanges()[ 0 ];
     819                                                                                if ( !range.startContainer.equals ( 'body' ) )
     820                                                                                {
     821                                                                                        body.getFirst().remove( 1 );
     822                                                                                        range.moveToElementEditEnd( body );
     823                                                                                        range.select( 1 );
     824                                                                                }
     825                                                                        }, 0 );
     826                                                                }
     827                                                        });
    826828                                                }
    827829
    828830                                                // 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
     
    11451146                                {
    11461147                                        return self.getNative().createRange().item( 0 );
    11471148                                },
     1149                                // If a table or list is fully selected.
     1150                                function()
     1151                                {
     1152                                        var root,
     1153                                                range  = self.getRanges()[ 0 ],
     1154                                                ancestor = range.getCommonAncestor( 1, 1 ),
     1155                                                tags = { table:1,ul:1,ol:1,dl:1 };
     1156
     1157                                        for ( var t in tags )
     1158                                        {
     1159                                                if ( root = ancestor.getAscendant( t, 1 ) )
     1160                                                        break;
     1161                                        }
     1162
     1163                                        if ( root )
     1164                                        {
     1165                                                // Enlarging the start boundary.
     1166                                                var testRange = new CKEDITOR.dom.range( this.document );
     1167                                                testRange.setStartAt( root, CKEDITOR.POSITION_AFTER_START );
     1168                                                testRange.setEnd( range.startContainer, range.startOffset );
     1169
     1170                                                var enlargeables = CKEDITOR.tools.extend( tags, CKEDITOR.dtd.$listItem, CKEDITOR.dtd.$tableContent ),
     1171                                                        walker = new CKEDITOR.dom.walker( testRange ),
     1172                                                        // Check the range is at the inner boundary of the structural element.
     1173                                                        guard = function( walker, isEnd )
     1174                                                        {
     1175                                                                return function( node, isWalkOut )
     1176                                                                {
     1177                                                                        if ( node.type == CKEDITOR.NODE_TEXT && ( !CKEDITOR.tools.trim( node.getText() ) || node.getParent().data( 'cke-bookmark' ) ) )
     1178                                                                                return true;
     1179
     1180                                                                        var tag;
     1181                                                                        if ( node.type == CKEDITOR.NODE_ELEMENT )
     1182                                                                        {
     1183                                                                                tag = node.getName();
     1184
     1185                                                                                // Bypass bogus br at the end of block.
     1186                                                                                if ( tag == 'br' && isEnd && node.equals( node.getParent().getBogus() ) )
     1187                                                                                        return true;
     1188
     1189                                                                                if ( isWalkOut && tag in enlargeables || tag in CKEDITOR.dtd.$removeEmpty )
     1190                                                                                        return true;
     1191                                                                        }
     1192
     1193                                                                        walker.halted = 1;
     1194                                                                        return false;
     1195                                                                };
     1196                                                        };
     1197
     1198                                                walker.guard = guard( walker );
     1199
     1200                                                if ( walker.checkBackward() && !walker.halted )
     1201                                                {
     1202                                                        walker = new CKEDITOR.dom.walker( testRange );
     1203                                                        testRange.setStart( range.endContainer, range.endOffset );
     1204                                                        testRange.setEndAt( root, CKEDITOR.POSITION_BEFORE_END );
     1205                                                        walker.guard = guard( walker, 1 );
     1206                                                        if ( walker.checkForward() && !walker.halted )
     1207                                                                return root.$;
     1208                                                }
     1209                                        }       
     1210                                },
    11481211                                // Figure it out by checking if there's a single enclosed
    11491212                                // node of the range.
    11501213                                function()
     
    14441507                                        sel.addRange( nativeRange );
    14451508                                }
    14461509
     1510                                // Don't miss selection change event for non-IEs.
     1511                                this.document.fire( 'selectionchange' );
    14471512                                this.reset();
    14481513                        }
    14491514                },
  • _source/core/tools.js

     
    727727                },
    728728
    729729                /**
    730                  * Return the first successfully executed function's return value that
     730                 * Return the first successfully executed function's returned truthy value that
    731731                 * doesn't throw any exception.
    732732                 */
    733733                tryThese : function()
     
    738738                                var lambda = arguments[i];
    739739                                try
    740740                                {
    741                                         returnValue = lambda();
    742                                         break;
     741                                        if ( returnValue = lambda() );
     742                                                break;
    743743                                }
    744744                                catch (e) {}
    745745                        }
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy