-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11244 from ckeditor/ck/10880-tab-key
Feature (engine): Introduced `TabObserver` that allows listening to pressing down the `Tab` key in a specified context. Feature (core): The `MultiCommand` accepts priorities for child commands. Other (table, code-block, list): `Tab` and `Tab+Shift` keystrokes handlers now listen to `tab` events and are executed with respect to context. Internal (list): Implemented handling of `Tab` and `Tab+Shift` keys in document lists. Closes #10880. Internal (list): `indentList` and `outdentList` commands are now registered with priority in 'Indent' `MultiCommand` , `Tab` and `Tab+Shift` listeners now executes in `li` context in order to not interfere with other plugins' listeners . Closes #11072.
- Loading branch information
Showing
19 changed files
with
3,935 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
packages/ckeditor5-engine/src/view/observer/tabobserver.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/** | ||
* @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved. | ||
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license | ||
*/ | ||
|
||
/** | ||
* @module engine/view/observer/tabobserver | ||
*/ | ||
|
||
import Observer from './observer'; | ||
import BubblingEventInfo from './bubblingeventinfo'; | ||
|
||
import { keyCodes } from '@ckeditor/ckeditor5-utils/src/keyboard'; | ||
|
||
/** | ||
* Tab observer introduces the {@link module:engine/view/document~Document#event:tab `Document#tab`} event. | ||
* | ||
* Note that because {@link module:engine/view/observer/tabobserver~TabObserver} is attached by the | ||
* {@link module:engine/view/view~View} this event is available by default. | ||
* | ||
* @extends module:engine/view/observer/observer~Observer | ||
*/ | ||
export default class TabObserver extends Observer { | ||
/** | ||
* @inheritDoc | ||
*/ | ||
constructor( view ) { | ||
super( view ); | ||
|
||
const doc = this.document; | ||
|
||
doc.on( 'keydown', ( evt, data ) => { | ||
if ( | ||
!this.isEnabled || | ||
data.keyCode != keyCodes.tab || | ||
data.ctrlKey | ||
) { | ||
return; | ||
} | ||
|
||
const event = new BubblingEventInfo( doc, 'tab', doc.selection.getFirstRange() ); | ||
|
||
doc.fire( event, data ); | ||
|
||
if ( event.stop.called ) { | ||
evt.stop(); | ||
} | ||
} ); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
observe() {} | ||
} | ||
|
||
/** | ||
* Event fired when the user presses a tab key. | ||
* | ||
* Introduced by {@link module:engine/view/observer/tabobserver~TabObserver}. | ||
* | ||
* Note that because {@link module:engine/view/observer/tabobserver~TabObserver} is attached by the | ||
* {@link module:engine/view/view~View} this event is available by default. | ||
* | ||
* @event module:engine/view/document~Document#event:tab | ||
* | ||
* @param {module:engine/view/observer/domeventdata~DomEventData} data | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.