1 |
|
2 |
|
3 |
|
4 |
|
5 | import { Plugin, type Editor } from 'ckeditor5/src/core';
|
6 | import type { Element } from 'ckeditor5/src/engine';
|
7 | import TableEditing from '../tableediting';
|
8 | import TableUtils from '../tableutils';
|
9 |
|
10 |
|
11 |
|
12 | export default class TableColumnResizeEditing extends Plugin {
|
13 | |
14 |
|
15 |
|
16 | private _isResizingActive;
|
17 | |
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 | _isResizingAllowed: boolean;
|
25 | |
26 |
|
27 |
|
28 |
|
29 | private _resizingData;
|
30 | |
31 |
|
32 |
|
33 | private _domEmitter;
|
34 | |
35 |
|
36 |
|
37 | private _tableUtilsPlugin;
|
38 | |
39 |
|
40 |
|
41 | static get requires(): readonly [typeof TableEditing, typeof TableUtils];
|
42 | |
43 |
|
44 |
|
45 | static get pluginName(): 'TableColumnResizeEditing';
|
46 | |
47 |
|
48 |
|
49 | constructor(editor: Editor);
|
50 | /**
|
51 | * @inheritDoc
|
52 | */
|
53 | init(): void;
|
54 | /**
|
55 | * @inheritDoc
|
56 | */
|
57 | destroy(): void;
|
58 | /**
|
59 | * Returns a 'tableColumnGroup' element from the 'table'.
|
60 | *
|
61 | * @param element A 'table' or 'tableColumnGroup' element.
|
62 | * @returns A 'tableColumnGroup' element.
|
63 | */
|
64 | getColumnGroupElement(element: Element): Element | undefined;
|
65 | /**
|
66 | * Returns an array of 'tableColumn' elements.
|
67 | *
|
68 | * @param element A 'table' or 'tableColumnGroup' element.
|
69 | * @returns An array of 'tableColumn' elements.
|
70 | */
|
71 | getTableColumnElements(element: Element): Array<Element>;
|
72 | /**
|
73 | * Returns an array of table column widths.
|
74 | *
|
75 | * @param element A 'table' or 'tableColumnGroup' element.
|
76 | * @returns An array of table column widths.
|
77 | */
|
78 | getTableColumnsWidths(element: Element): Array<string>;
|
79 | /**
|
80 | * Registers new attributes for a table model element.
|
81 | */
|
82 | private _extendSchema;
|
83 | /**
|
84 | * Registers table column resize post-fixer.
|
85 | *
|
86 | * It checks if the change from the differ concerns a table-related element or attribute. For detected changes it:
|
87 | * * Adjusts the `columnWidths` attribute to guarantee that the sum of the widths from all columns is 100%.
|
88 | * * Checks if the `columnWidths` attribute gets updated accordingly after columns have been added or removed.
|
89 | */
|
90 | private _registerPostFixer;
|
91 | /**
|
92 | * Registers table column resize converters.
|
93 | */
|
94 | private _registerConverters;
|
95 | /**
|
96 | * Registers listeners to handle resizing process.
|
97 | */
|
98 | private _registerResizingListeners;
|
99 | /**
|
100 | * Handles the `mousedown` event on column resizer element:
|
101 | * * calculates the initial column pixel widths,
|
102 | * * inserts the `<colgroup>` element if it is not present in the `<table>`,
|
103 | * * puts the necessary data in the temporary storage,
|
104 | * * applies the attributes to the `<table>` view element.
|
105 | *
|
106 | * @param eventInfo An object containing information about the fired event.
|
107 | * @param domEventData The data related to the DOM event.
|
108 | */
|
109 | private _onMouseDownHandler;
|
110 | /**
|
111 | * Handles the `mousemove` event.
|
112 | * * If resizing process is not in progress, it does nothing.
|
113 | * * If resizing is active but not allowed, it stops the resizing process instantly calling the `mousedown` event handler.
|
114 | * * Otherwise it dynamically updates the widths of the resized columns.
|
115 | *
|
116 | * @param eventInfo An object containing information about the fired event.
|
117 | * @param mouseEventData The native DOM event.
|
118 | */
|
119 | private _onMouseMoveHandler;
|
120 | /**
|
121 | * Handles the `mouseup` event.
|
122 | * * If resizing process is not in progress, it does nothing.
|
123 | * * If resizing is active but not allowed, it cancels the resizing process restoring the original widths.
|
124 | * * Otherwise it propagates the changes from view to the model by executing the adequate commands.
|
125 | */
|
126 | private _onMouseUpHandler;
|
127 | /**
|
128 | * Retrieves and returns required data needed for the resizing process.
|
129 | *
|
130 | * @param domEventData The data of the `mousedown` event.
|
131 | * @param columnWidths The current widths of the columns.
|
132 | * @returns The data needed for the resizing process.
|
133 | */
|
134 | private _getResizingData;
|
135 | /**
|
136 | * Registers a listener ensuring that each resizable cell have a resizer handle.
|
137 | */
|
138 | private _registerResizerInserter;
|
139 | }
|