UNPKG

2.56 kBTypeScriptView Raw
1/**
2 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4 */
5/**
6 * @module table/tablekeyboard
7 */
8import TableSelection from './tableselection';
9import TableUtils from './tableutils';
10import { Plugin } from 'ckeditor5/src/core';
11import { type ArrowKeyCodeDirection } from 'ckeditor5/src/utils';
12import type { Element } from 'ckeditor5/src/engine';
13/**
14 * This plugin enables keyboard navigation for tables.
15 * It is loaded automatically by the {@link module:table/table~Table} plugin.
16 */
17export default class TableKeyboard extends Plugin {
18 /**
19 * @inheritDoc
20 */
21 static get pluginName(): 'TableKeyboard';
22 /**
23 * @inheritDoc
24 */
25 static get requires(): readonly [typeof TableSelection, typeof TableUtils];
26 /**
27 * @inheritDoc
28 */
29 init(): void;
30 /**
31 * Handles {@link module:engine/view/document~Document#event:tab tab} events for the <kbd>Tab</kbd> key executed
32 * when the table widget is selected.
33 */
34 private _handleTabOnSelectedTable;
35 /**
36 * Handles {@link module:engine/view/document~Document#event:tab tab} events for the <kbd>Tab</kbd> key executed
37 * inside table cells.
38 */
39 private _handleTab;
40 /**
41 * Handles {@link module:engine/view/document~Document#event:keydown keydown} events.
42 */
43 private _onArrowKey;
44 /**
45 * Handles arrow keys to move the selection around the table.
46 *
47 * @param direction The direction of the arrow key.
48 * @param expandSelection If the current selection should be expanded.
49 * @returns Returns `true` if key was handled.
50 */
51 private _handleArrowKeys;
52 /**
53 * Returns `true` if the selection is at the boundary of a table cell according to the navigation direction.
54 *
55 * @param selection The current selection.
56 * @param tableCell The current table cell element.
57 * @param isForward The expected navigation direction.
58 */
59 private _isSelectionAtCellEdge;
60 /**
61 * Moves the selection from the given table cell in the specified direction.
62 *
63 * @param focusCell The table cell that is current multi-cell selection focus.
64 * @param direction Direction in which selection should move.
65 * @param expandSelection If the current selection should be expanded. Default value is false.
66 */
67 protected _navigateFromCellInDirection(focusCell: Element, direction: ArrowKeyCodeDirection, expandSelection?: boolean): void;
68}