Ticket #7193: 7193_3.patch

File 7193_3.patch, 2.2 KB (added by Garry Yao, 13 years ago)
  • _source/plugins/selection/plugin.js

     
    183183                                editor.on( 'getData', afterData );
    184184                        }
    185185
    186                         editor.on( 'contentDom', function()
     186                        // Editable HR element fixes for IE9 (#7193).
     187                        if ( CKEDITOR.env.ie && document.documentMode == 9 )
     188                        {
     189                                editor.on( 'contentDom', function()
    187190                                {
    188191                                        var doc = editor.document,
     192                                                sel, range;
     193
     194                                        doc.on( 'selectionchange', function()
     195                                        {
     196                                                sel = doc.$.selection;
     197                                                range = sel && sel.type == 'None' && sel.createRange();
     198                                                var rangeParent =  range && new CKEDITOR.dom.element( range.parentElement() );
     199
     200                                                // Browser must be crazy by allowing editing hr, we fix it by selecting it as control.
     201                                                if ( rangeParent && rangeParent.is( 'hr' ) )
     202                                                {
     203                                                        range = new CKEDITOR.dom.range( doc );
     204                                                        range.selectNodeContents( rangeParent );
     205                                                        range.select();
     206                                                }
     207                                        }, null, null, 1 );
     208
     209                                        doc.on( 'keydown', function( evt )
     210                                        {
     211                                                var key = evt.data.getKeystroke();
     212                                                sel = doc.$.selection;
     213                                                var control = sel.type == 'Control' && new CKEDITOR.dom.element( sel.createRange().item( 0 ) );
     214                                                if ( control && ( key == '37' || key == '39' ) && control.is( 'hr' ) )
     215                                                {
     216                                                        range = new CKEDITOR.dom.range( doc );
     217                                                        var sibling = key == '37' ? control.getPrevious() : control.getNext();
     218
     219                                                        // We're not able to fix the situation when sibling is text node - selection is sticky
     220                                                        // to the hr element in that case.
     221                                                        if ( sibling && sibling.type == CKEDITOR.NODE_ELEMENT )
     222                                                        {
     223                                                                range[ sibling.getName() in CKEDITOR.dtd.$empty ? 'selectNodeContents' : 'moveToElementEdit' + ( key == '37' ? 'End' : 'Start' ) ]( sibling );
     224                                                                range.select();
     225                                                                evt.data.preventDefault();
     226                                                        }
     227                                                }
     228                                        });
     229                                });
     230                        }
     231
     232                        editor.on( 'contentDom', function()
     233                                {
     234                                        var doc = editor.document,
    189235                                                body = doc.getBody(),
    190236                                                html = doc.getDocumentElement();
    191237
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy