UNPKG

1.78 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/tablemouse
7 */
8import { Plugin } from 'ckeditor5/src/core';
9import TableSelection from './tableselection';
10import TableUtils from './tableutils';
11/**
12 * This plugin enables a table cells' selection with the mouse.
13 * It is loaded automatically by the {@link module:table/table~Table} plugin.
14 */
15export default class TableMouse extends Plugin {
16 /**
17 * @inheritDoc
18 */
19 static get pluginName(): 'TableMouse';
20 /**
21 * @inheritDoc
22 */
23 static get requires(): readonly [typeof TableSelection, typeof TableUtils];
24 /**
25 * @inheritDoc
26 */
27 init(): void;
28 /**
29 * Enables making cells selection by <kbd>Shift</kbd>+click. Creates a selection from the cell which previously held
30 * the selection to the cell which was clicked. It can be the same cell, in which case it selects a single cell.
31 */
32 private _enableShiftClickSelection;
33 /**
34 * Enables making cells selection by dragging.
35 *
36 * The selection is made only on mousemove. Mouse tracking is started on mousedown.
37 * However, the cells selection is enabled only after the mouse cursor left the anchor cell.
38 * Thanks to that normal text selection within one cell works just fine. However, you can still select
39 * just one cell by leaving the anchor cell and moving back to it.
40 */
41 private _enableMouseDragSelection;
42 /**
43 * Returns the model table cell element based on the target element of the passed DOM event.
44 *
45 * @returns Returns the table cell or `undefined`.
46 */
47 private _getModelTableCellFromDomEvent;
48}