Skip to content
Permalink
Browse files

Selection optimization - fixed editable key events listeners.

  • Loading branch information...
f1ames committed Sep 25, 2019
1 parent fc9e912 commit 89d947799b6b29e33fc3721ae7687f5352614c07
Showing with 30 additions and 4 deletions.
  1. +9 −3 core/selection/optimization.js
  2. +21 −1 tests/core/selection/optimization.js
@@ -21,12 +21,18 @@
preventOptimization = false;
} );

editor.on( 'instanceReady', function() {
this.editable().on( 'keydown', function( evt ) {
editor.on( 'contentDom', function() {
var editable = editor.editable();

if ( !editable ) {
return;
}

editable.attachListener( editable, 'keydown', function( evt ) {
this._.shiftPressed = evt.data.$.shiftKey;
}, this );

this.editable().on( 'keyup', function( evt ) {
editable.attachListener( editable, 'keyup', function( evt ) {
this._.shiftPressed = evt.data.$.shiftKey;
}, this );
} );
@@ -102,7 +102,27 @@
assertEditorHtml();
editor._.shiftPressed = false;
}
} )
} ),

'test selection optimization key listeners after setData() with keydown': function( editor, bot ) {
editor._.shiftPressed = null;

bot.setData( '<p>Foo</p><p><strong>bar</strong> baz</p>', function() {
bot.editor.editable().fire( 'keydown', new CKEDITOR.dom.event( { shiftKey: true } ) );

assert.isTrue( editor._.shiftPressed );
} );
},

'test selection optimization key listeners after setData() with keyup': function( editor, bot ) {
editor._.shiftPressed = null;

bot.setData( '<p>Foo</p><p><strong>bar</strong> baz</p>', function() {
bot.editor.editable().fire( 'keyup', new CKEDITOR.dom.event( { shiftKey: false } ) );

assert.isFalse( editor._.shiftPressed );
} );
}
};

tests = bender.tools.createTestsForEditors( CKEDITOR.tools.object.keys( bender.editors ), tests );

0 comments on commit 89d9477

Please sign in to comment.
You can’t perform that action at this time.