Ticket #5375: 5375.patch

File 5375.patch, 3.2 KB (added by Garry Yao, 14 years ago)
  • _source/core/config.js

     
    229229         * @type String
    230230         * @example
    231231         */
    232         plugins : 'about,a11yhelp,basicstyles,blockquote,button,clipboard,colorbutton,colordialog,contextmenu,div,elementspath,enterkey,entities,filebrowser,find,flash,font,format,forms,horizontalrule,htmldataprocessor,image,indent,justify,keystrokes,link,list,maximize,newpage,pagebreak,pastefromword,pastetext,popup,preview,print,removeformat,resize,save,scayt,smiley,showblocks,showborders,sourcearea,stylescombo,table,tabletools,specialchar,tab,templates,toolbar,undo,wysiwygarea,wsc',
     232        plugins : 'about,a11yhelp,basicstyles,blockquote,button,clipboard,colorbutton,colordialog,contextmenu,del,div,elementspath,enterkey,entities,filebrowser,find,flash,font,format,forms,horizontalrule,htmldataprocessor,image,indent,justify,keystrokes,link,list,maximize,newpage,pagebreak,pastefromword,pastetext,popup,preview,print,removeformat,resize,save,scayt,smiley,showblocks,showborders,sourcearea,stylescombo,table,tabletools,specialchar,tab,templates,toolbar,undo,wysiwygarea,wsc',
    233233
    234234        /**
    235235         * List of additional plugins to be loaded. This is a tool setting which
  • _source/plugins/del/plugin.js

     
     1/*
     2Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
     3For licensing, see LICENSE.html or http://ckeditor.com/license
     4*/
     5
     6(function()
     7{
     8        // TODO: Copied from 'styles' plugin.
     9        var blockElements       = { address:1,div:1,h1:1,h2:1,h3:1,h4:1,h5:1,h6:1,p:1,pre:1 };
     10
     11        function isEmptyBlock( block )
     12        {
     13                var range = new CKEDITOR.dom.range();
     14                range.moveToElementEditStart( block );
     15                return range.checkStartOfBlock( block ) && range.checkEndOfBlock( block );
     16        }
     17
     18        CKEDITOR.plugins.add( 'del',
     19        {
     20                requires : [ 'keystrokes' ],
     21
     22                init : function( editor )
     23                {
     24                        editor.on( 'key', function( evt )
     25                                {
     26                                        if ( editor.mode == 'wysiwyg' && evt.data.keyCode == 46 )       // Del
     27                                        {
     28                                                var range = editor.getSelection().getRanges()[ 0 ],
     29                                                        path = new CKEDITOR.dom.elementPath( range.startContainer );
     30
     31                                                if( CKEDITOR.env.gecko )
     32                                                {
     33                                                        // When cursor is at the end of one paragraph, Firefox doesn't remove the following block on 'delete' key as expected . (#5375)
     34                                                        if( range.collapsed && range.checkEndOfBlock() )
     35                                                        {
     36                                                                var block = path.block,
     37                                                                                nextBlock = block.getNextSourceNode( true, CKEDITOR.NODE_ELEMENT,
     38                                                                                function( element, isMovingOut )
     39                                                                                {
     40                                                                                        return isMovingOut || element.getName() in blockElements;
     41                                                                                });
     42
     43                                                                if( nextBlock && isEmptyBlock( nextBlock ) )
     44                                                                {
     45                                                                        editor.fire( 'saveSnapshot' );
     46                                                                        nextBlock.remove();
     47                                                                        editor.fire( 'saveSnapshot' );
     48                                                                        evt.cancel();
     49                                                                }
     50                                                        }
     51                                                }
     52                                        }
     53                                });
     54                }
     55        });
     56})();
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy