Przeglądaj źródła

Merge pull request #70 from ckeditor/t/69

Fix: Tab key should not delete selected text. Closes: #69.
Piotrek Koszuliński 9 lat temu
rodzic
commit
ae650434e1

+ 1 - 0
packages/ckeditor5-typing/src/input.js

@@ -286,6 +286,7 @@ const safeKeycodes = [
 	getCode( 'arrowRight' ),
 	getCode( 'arrowDown' ),
 	getCode( 'arrowLeft' ),
+	9,  // Tab
 	16, // Shift
 	17, // Ctrl
 	18, // Alt

+ 12 - 0
packages/ckeditor5-typing/tests/input.js

@@ -307,6 +307,18 @@ describe( 'Input feature', () => {
 			expect( getModelData( model ) ).to.equal( '<paragraph>fo[ob]ar</paragraph>' );
 		} );
 
+		// #69
+		it( 'should do nothing on tab key', () => {
+			model.enqueueChanges( () => {
+				model.selection.setRanges( [
+					ModelRange.createFromParentsAndOffsets( modelRoot.getChild( 0 ), 2, modelRoot.getChild( 0 ), 4 ) ] );
+			} );
+
+			view.fire( 'keydown', { keyCode: 9 } ); // Tab
+
+			expect( getModelData( model ) ).to.equal( '<paragraph>fo[ob]ar</paragraph>' );
+		} );
+
 		it( 'should do nothing if selection is collapsed', () => {
 			view.fire( 'keydown', { ctrlKey: true, keyCode: getCode( 'c' ) } );