|
|
@@ -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( {
|