Преглед на файлове

Prevented from two-steps movement when alt or ctrl key is pressed.

Oskar Wróbel преди 7 години
родител
ревизия
67e0f8d786

+ 3 - 2
packages/ckeditor5-engine/src/utils/bindtwostepcarettoattribute.js

@@ -53,8 +53,9 @@ export default function bindTwoStepCaretToAttribute( view, model, emitter, attri
 			return;
 		}
 
-		// User tries to expand selection, so two-steps movement is not necessary.
-		if ( data.shiftKey ) {
+		// When user tries to expand selection or jump over the whole word or to the beginning/end then
+		// two-steps movement is not necessary.
+		if ( data.shiftKey || data.altKey || data.ctrlKey ) {
 			return;
 		}
 

+ 22 - 0
packages/ckeditor5-engine/tests/utils/bindtwostepcarettoattribute.js

@@ -330,6 +330,28 @@ describe( 'bindTwoStepCaretToAttribute()', () => {
 		expect( selection.isGravityOverridden ).to.false;
 	} );
 
+	it( 'should do nothing when alt key is pressed', () => {
+		setData( model, '<$text c="true">foo</$text><$text a="true" b="true">b[]ar</$text>' );
+
+		fireKeyDownEvent( {
+			keyCode: keyCodes.arrowleft,
+			altKey: true
+		} );
+
+		expect( selection.isGravityOverridden ).to.false;
+	} );
+
+	it( 'should do nothing when ctrl key is pressed', () => {
+		setData( model, '<$text c="true">foo</$text><$text a="true" b="true">b[]ar</$text>' );
+
+		fireKeyDownEvent( {
+			keyCode: keyCodes.arrowleft,
+			ctrlKey: true
+		} );
+
+		expect( selection.isGravityOverridden ).to.false;
+	} );
+
 	function fireKeyDownEvent( options ) {
 		const eventData = Object.assign( { domTarget: document.body }, options );