Sfoglia il codice sorgente

Remove Tab key support from BlockIndent.

Maciej Gołaszewski 6 anni fa
parent
commit
da7c5f2197

+ 1 - 22
packages/ckeditor5-indent/src/indentblock.js

@@ -52,14 +52,7 @@ export default class IndentBlock extends Plugin {
 		const conversion = editor.conversion;
 		const configuration = editor.config.get( 'indentBlock' );
 
-		// TODO: supported in CKE4:
-		//  - p,
-		//  - h1, h2, h3, h4, h5, h6,
-		//  - ul, ol,
-		//  - div,
-		//  - dl,
-		//  - pre,
-		//  - table
+		// Enable block indentation by default in paragraph and default headings.
 		const knownElements = [ 'paragraph', 'heading1', 'heading2', 'heading3', 'heading4', 'heading5', 'heading6' ];
 
 		knownElements.forEach( elementName => {
@@ -82,20 +75,6 @@ export default class IndentBlock extends Plugin {
 			editor.commands.add( 'indentBlock', new IndentBlockCommand( editor, new IndentUsingClasses( indentConfig ) ) );
 			editor.commands.add( 'outdentBlock', new IndentBlockCommand( editor, new IndentUsingClasses( outdentConfig ) ) );
 		}
-
-		const getCommandExecuter = commandName => {
-			return ( data, cancel ) => {
-				const command = this.editor.commands.get( commandName );
-
-				if ( command.isEnabled ) {
-					this.editor.execute( commandName );
-					cancel();
-				}
-			};
-		};
-
-		editor.keystrokes.set( 'Tab', getCommandExecuter( 'indentBlock' ) );
-		editor.keystrokes.set( 'Shift+Tab', getCommandExecuter( 'outdentBlock' ) );
 	}
 
 	/**

+ 0 - 73
packages/ckeditor5-indent/tests/indentblock.js

@@ -225,79 +225,6 @@ describe( 'IndentBlock', () => {
 		} );
 	} );
 
-	describe( 'tab key handling callback', () => {
-		let domEvtDataStub;
-
-		beforeEach( () => {
-			return createTestEditor()
-				.then( newEditor => {
-					editor = newEditor;
-					model = editor.model;
-					doc = model.document;
-					domEvtDataStub = {
-						keyCode: getCode( 'Tab' ),
-						preventDefault: sinon.spy(),
-						stopPropagation: sinon.spy()
-					};
-
-					sinon.spy( editor, 'execute' );
-				} );
-		} );
-
-		it( 'should execute indentBlock command on tab key', () => {
-			editor.setData( '<p>foo</p>' );
-			editor.model.change( writer => writer.setSelection( doc.getRoot().getChild( 0 ), 0 ) );
-
-			editor.editing.view.document.fire( 'keydown', domEvtDataStub );
-
-			sinon.assert.calledOnce( editor.execute );
-			sinon.assert.calledWithExactly( editor.execute, 'indentBlock' );
-			sinon.assert.calledOnce( domEvtDataStub.preventDefault );
-			sinon.assert.calledOnce( domEvtDataStub.stopPropagation );
-		} );
-
-		it( 'should execute outdentBlock command on Shift+Tab keystroke', () => {
-			domEvtDataStub.keyCode += getCode( 'Shift' );
-
-			editor.setData( '<p style="margin-left:1em;">foo</p>' );
-			editor.model.change( writer => writer.setSelection( doc.getRoot().getChild( 0 ), 0 ) );
-
-			editor.editing.view.document.fire( 'keydown', domEvtDataStub );
-
-			sinon.assert.calledOnce( editor.execute );
-			sinon.assert.calledWithExactly( editor.execute, 'outdentBlock' );
-			sinon.assert.calledOnce( domEvtDataStub.preventDefault );
-			sinon.assert.calledOnce( domEvtDataStub.stopPropagation );
-		} );
-
-		it( 'should not indent if command is disabled', () => {
-			editor.model.schema.register( 'block', { inheritAllFrom: '$block' } );
-			editor.conversion.elementToElement( { model: 'block', view: 'block' } );
-
-			editor.setData( '<block>foo</block>' );
-			editor.model.change( writer => writer.setSelection( doc.getRoot().getChild( 0 ), 0 ) );
-
-			editor.editing.view.document.fire( 'keydown', domEvtDataStub );
-
-			expect( editor.execute.called ).to.be.false;
-			sinon.assert.notCalled( domEvtDataStub.preventDefault );
-			sinon.assert.notCalled( domEvtDataStub.stopPropagation );
-		} );
-
-		it( 'should not indent or outdent if alt+tab is pressed', () => {
-			domEvtDataStub.keyCode += getCode( 'alt' );
-
-			editor.setData( '<p style="margin-left:1em;">foo</p>' );
-			editor.model.change( writer => writer.setSelection( doc.getRoot().getChild( 0 ), 0 ) );
-
-			editor.editing.view.document.fire( 'keydown', domEvtDataStub );
-
-			expect( editor.execute.called ).to.be.false;
-			sinon.assert.notCalled( domEvtDataStub.preventDefault );
-			sinon.assert.notCalled( domEvtDataStub.stopPropagation );
-		} );
-	} );
-
 	function createTestEditor( extraConfig = {} ) {
 		return VirtualTestEditor
 			.create( Object.assign( {