Skip to content

Commit e2e313b

Browse files
committed
Focus the editor after toggling the fullscreen mode via keystroke.
1 parent 32a4944 commit e2e313b

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

packages/ckeditor5-fullscreen/src/fullscreenediting.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,13 @@ export default class FullscreenEditing extends Plugin {
4747
const t = this.editor.locale.t;
4848

4949
// Set the Ctrl+Shift+F keystroke.
50-
this.editor.keystrokes.set( 'Ctrl+Shift+F', 'fullscreen' );
50+
this.editor.keystrokes.set( 'Ctrl+Shift+F', ( evt, cancel ) => {
51+
this.editor.execute( 'fullscreen' );
52+
53+
this.editor.editing.view.focus();
54+
55+
cancel();
56+
} );
5157

5258
// Add the information about the keystroke to the accessibility database.
5359
this.editor.accessibility.addKeystrokeInfos( {

packages/ckeditor5-fullscreen/tests/fullscreenediting.js

+23
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import Essentials from '@ckeditor/ckeditor5-essentials/src/essentials.js';
77
import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph.js';
88
import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor.js';
99
import global from '@ckeditor/ckeditor5-utils/src/dom/global.js';
10+
import { keyCodes } from '@ckeditor/ckeditor5-utils';
11+
import env from '@ckeditor/ckeditor5-utils/src/env.js';
1012

1113
import FullscreenEditing from '../src/fullscreenediting.js';
1214
import FullscreenCommand from '../src/fullscreencommand.js';
@@ -54,4 +56,25 @@ describe( 'FullscreenEditing', () => {
5456

5557
expect( spy ).to.have.been.calledOnce;
5658
} );
59+
60+
it( 'should toggle fullscreen mode on keystroke combination', () => {
61+
const spy = sinon.spy( editor, 'execute' );
62+
const keyEventData = {
63+
keyCode: keyCodes.f,
64+
ctrlKey: !env.isMac,
65+
metaKey: env.isMac,
66+
shiftKey: true,
67+
preventDefault: sinon.spy(),
68+
stopPropagation: sinon.spy()
69+
};
70+
71+
editor.keystrokes.press( keyEventData );
72+
73+
expect( spy.calledOnce ).to.be.true;
74+
expect( spy.calledWithExactly( 'fullscreen' ) ).to.be.true;
75+
76+
editor.keystrokes.press( keyEventData );
77+
78+
expect( spy.calledTwice ).to.be.true;
79+
} );
5780
} );

0 commit comments

Comments
 (0)