Ticket #7437: 7437.patch

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

     
    186186                                                }
    187187                                        }, null, null, 10 );
    188188
    189                                 var fillingCharBefore;
     189                                var fillingCharBefore,
     190                                        resetSelection;
     191
    190192                                function beforeData()
    191193                                {
    192                                         var fillingChar = getFillingChar( editor.document );
    193                                         fillingCharBefore = fillingChar && fillingChar.getText();
    194                                         fillingCharBefore && fillingChar.setText( fillingCharBefore.replace( /\u200B/g, '' ) );
    195                                 }
     194                                        var doc = editor.document,
     195                                                fillingChar = getFillingChar( doc );
     196
     197                                        if ( fillingChar )
     198                                        {
     199                                                // If cursor is right blinking by side of the filler node, save it for restoring,
     200                                                // as the following text substitution will blind it. (#7437)
     201                                                var sel = doc.$.defaultView.getSelection();
     202                                                if ( sel.type == 'Caret' && sel.anchorNode == fillingChar.$ )
     203                                                        resetSelection = 1;
     204
     205                                                fillingCharBefore = fillingChar.getText();
     206                                                fillingChar.setText( fillingCharBefore.replace( /\u200B/g, '' ) );
     207                                        }
     208                                }
    196209                                function afterData()
    197210                                {
    198                                                 var fillingChar = getFillingChar( editor.document );
    199                                                 fillingChar && fillingChar.setText( fillingCharBefore );
    200                                 }
     211                                        var doc = editor.document,
     212                                                fillingChar = getFillingChar( doc );
     213
     214                                        if ( fillingChar )
     215                                        {
     216                                                fillingChar.setText( fillingCharBefore );
     217
     218                                                if ( resetSelection )
     219                                                {
     220                                                        doc.$.defaultView.getSelection().setPosition( fillingChar.$,fillingChar.getLength() );
     221                                                        resetSelection = 0;
     222                                                }
     223                                        }
     224                                }
    201225                                editor.on( 'beforeUndoImage', beforeData );
    202226                                editor.on( 'afterUndoImage', afterData );
    203227                                editor.on( 'beforeGetData', beforeData, null, null, 0 );
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy