@ckeditor/ckeditor5-table 41.2.0 → 41.3.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/content-index.css +55 -0
- package/dist/editor-index.css +150 -0
- package/dist/index.css +362 -0
- package/dist/index.css.map +1 -0
- package/dist/index.js +11660 -0
- package/dist/index.js.map +1 -0
- package/dist/types/augmentation.d.ts +76 -0
- package/dist/types/commands/insertcolumncommand.d.ts +55 -0
- package/dist/types/commands/insertrowcommand.d.ts +54 -0
- package/dist/types/commands/inserttablecommand.d.ts +44 -0
- package/dist/types/commands/mergecellcommand.d.ts +68 -0
- package/dist/types/commands/mergecellscommand.d.ts +28 -0
- package/dist/types/commands/removecolumncommand.d.ts +29 -0
- package/dist/types/commands/removerowcommand.d.ts +29 -0
- package/dist/types/commands/selectcolumncommand.d.ts +33 -0
- package/dist/types/commands/selectrowcommand.d.ts +33 -0
- package/dist/types/commands/setheadercolumncommand.d.ts +50 -0
- package/dist/types/commands/setheaderrowcommand.d.ts +53 -0
- package/dist/types/commands/splitcellcommand.d.ts +43 -0
- package/dist/types/converters/downcast.d.ts +63 -0
- package/dist/types/converters/table-caption-post-fixer.d.ts +20 -0
- package/dist/types/converters/table-cell-paragraph-post-fixer.d.ts +32 -0
- package/dist/types/converters/table-cell-refresh-handler.d.ts +18 -0
- package/dist/types/converters/table-headings-refresh-handler.d.ts +17 -0
- package/dist/types/converters/table-layout-post-fixer.d.ts +226 -0
- package/dist/types/converters/tableproperties.d.ts +54 -0
- package/dist/types/converters/upcasttable.d.ts +49 -0
- package/dist/types/index.d.ts +60 -0
- package/dist/types/plaintableoutput.d.ts +26 -0
- package/dist/types/table.d.ts +40 -0
- package/dist/types/tablecaption/tablecaptionediting.d.ts +63 -0
- package/dist/types/tablecaption/tablecaptionui.d.ts +21 -0
- package/dist/types/tablecaption/toggletablecaptioncommand.d.ts +68 -0
- package/dist/types/tablecaption/utils.d.ts +38 -0
- package/dist/types/tablecaption.d.ts +24 -0
- package/dist/types/tablecellproperties/commands/tablecellbackgroundcolorcommand.d.ts +32 -0
- package/dist/types/tablecellproperties/commands/tablecellbordercolorcommand.d.ts +37 -0
- package/dist/types/tablecellproperties/commands/tablecellborderstylecommand.d.ts +37 -0
- package/dist/types/tablecellproperties/commands/tablecellborderwidthcommand.d.ts +51 -0
- package/dist/types/tablecellproperties/commands/tablecellheightcommand.d.ts +46 -0
- package/dist/types/tablecellproperties/commands/tablecellhorizontalalignmentcommand.d.ts +32 -0
- package/dist/types/tablecellproperties/commands/tablecellpaddingcommand.d.ts +51 -0
- package/dist/types/tablecellproperties/commands/tablecellpropertycommand.d.ts +62 -0
- package/dist/types/tablecellproperties/commands/tablecellverticalalignmentcommand.d.ts +40 -0
- package/dist/types/tablecellproperties/tablecellpropertiesediting.d.ts +43 -0
- package/dist/types/tablecellproperties/tablecellpropertiesui.d.ts +112 -0
- package/dist/types/tablecellproperties/ui/tablecellpropertiesview.d.ts +228 -0
- package/dist/types/tablecellproperties.d.ts +30 -0
- package/dist/types/tablecellwidth/commands/tablecellwidthcommand.d.ts +46 -0
- package/dist/types/tablecellwidth/tablecellwidthediting.d.ts +29 -0
- package/dist/types/tableclipboard.d.ts +70 -0
- package/dist/types/tablecolumnresize/constants.d.ts +20 -0
- package/dist/types/tablecolumnresize/converters.d.ts +18 -0
- package/dist/types/tablecolumnresize/tablecolumnresizeediting.d.ts +139 -0
- package/dist/types/tablecolumnresize/tablewidthscommand.d.ts +38 -0
- package/dist/types/tablecolumnresize/utils.d.ts +148 -0
- package/dist/types/tablecolumnresize.d.ts +26 -0
- package/dist/types/tableconfig.d.ts +343 -0
- package/dist/types/tableediting.d.ts +98 -0
- package/dist/types/tablekeyboard.d.ts +68 -0
- package/dist/types/tablemouse/mouseeventsobserver.d.ts +62 -0
- package/dist/types/tablemouse.d.ts +48 -0
- package/dist/types/tableproperties/commands/tablealignmentcommand.d.ts +32 -0
- package/dist/types/tableproperties/commands/tablebackgroundcolorcommand.d.ts +32 -0
- package/dist/types/tableproperties/commands/tablebordercolorcommand.d.ts +37 -0
- package/dist/types/tableproperties/commands/tableborderstylecommand.d.ts +37 -0
- package/dist/types/tableproperties/commands/tableborderwidthcommand.d.ts +51 -0
- package/dist/types/tableproperties/commands/tableheightcommand.d.ts +46 -0
- package/dist/types/tableproperties/commands/tablepropertycommand.d.ts +61 -0
- package/dist/types/tableproperties/commands/tablewidthcommand.d.ts +46 -0
- package/dist/types/tableproperties/tablepropertiesediting.d.ts +40 -0
- package/dist/types/tableproperties/tablepropertiesui.d.ts +114 -0
- package/dist/types/tableproperties/ui/tablepropertiesview.d.ts +207 -0
- package/dist/types/tableproperties.d.ts +30 -0
- package/dist/types/tableselection.d.ts +107 -0
- package/dist/types/tabletoolbar.d.ts +32 -0
- package/dist/types/tableui.d.ts +53 -0
- package/dist/types/tableutils.d.ts +448 -0
- package/dist/types/tablewalker.d.ts +362 -0
- package/dist/types/ui/colorinputview.d.ts +140 -0
- package/dist/types/ui/formrowview.d.ts +61 -0
- package/dist/types/ui/inserttableview.d.ts +77 -0
- package/dist/types/utils/common.d.ts +46 -0
- package/dist/types/utils/structure.d.ts +245 -0
- package/dist/types/utils/table-properties.d.ts +67 -0
- package/dist/types/utils/ui/contextualballoon.d.ts +34 -0
- package/dist/types/utils/ui/table-properties.d.ts +195 -0
- package/dist/types/utils/ui/widget.d.ts +20 -0
- package/package.json +3 -2
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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
|
+
import { Plugin, type Editor } from 'ckeditor5/src/core.js';
|
|
6
|
+
import type { Element } from 'ckeditor5/src/engine.js';
|
|
7
|
+
import TableEditing from '../tableediting.js';
|
|
8
|
+
import TableUtils from '../tableutils.js';
|
|
9
|
+
/**
|
|
10
|
+
* The table column resize editing plugin.
|
|
11
|
+
*/
|
|
12
|
+
export default class TableColumnResizeEditing extends Plugin {
|
|
13
|
+
/**
|
|
14
|
+
* A flag indicating if the column resizing is in progress.
|
|
15
|
+
*/
|
|
16
|
+
private _isResizingActive;
|
|
17
|
+
/**
|
|
18
|
+
* A flag indicating if the column resizing is allowed. It is not allowed if the editor is in read-only
|
|
19
|
+
* or comments-only mode or the `TableColumnResize` plugin is disabled.
|
|
20
|
+
*
|
|
21
|
+
* @observable
|
|
22
|
+
* @internal
|
|
23
|
+
*/
|
|
24
|
+
_isResizingAllowed: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* A temporary storage for the required data needed to correctly calculate the widths of the resized columns. This storage is
|
|
27
|
+
* initialized when column resizing begins, and is purged upon completion.
|
|
28
|
+
*/
|
|
29
|
+
private _resizingData;
|
|
30
|
+
/**
|
|
31
|
+
* DOM emitter.
|
|
32
|
+
*/
|
|
33
|
+
private _domEmitter;
|
|
34
|
+
/**
|
|
35
|
+
* A local reference to the {@link module:table/tableutils~TableUtils} plugin.
|
|
36
|
+
*/
|
|
37
|
+
private _tableUtilsPlugin;
|
|
38
|
+
/**
|
|
39
|
+
* @inheritDoc
|
|
40
|
+
*/
|
|
41
|
+
static get requires(): readonly [typeof TableEditing, typeof TableUtils];
|
|
42
|
+
/**
|
|
43
|
+
* @inheritDoc
|
|
44
|
+
*/
|
|
45
|
+
static get pluginName(): "TableColumnResizeEditing";
|
|
46
|
+
/**
|
|
47
|
+
* @inheritDoc
|
|
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
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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/tablecolumnresize/tablewidthscommand
|
|
7
|
+
*/
|
|
8
|
+
import type { Element } from 'ckeditor5/src/engine.js';
|
|
9
|
+
import { Command } from 'ckeditor5/src/core.js';
|
|
10
|
+
/**
|
|
11
|
+
* Command used by the {@link module:table/tablecolumnresize~TableColumnResize Table column resize feature} that
|
|
12
|
+
* updates the width of the whole table as well as its individual columns.
|
|
13
|
+
*/
|
|
14
|
+
export default class TableWidthsCommand extends Command {
|
|
15
|
+
/**
|
|
16
|
+
* @inheritDoc
|
|
17
|
+
*/
|
|
18
|
+
refresh(): void;
|
|
19
|
+
/**
|
|
20
|
+
* Updated the `tableWidth` attribute of the table and the `columnWidth` attribute of the columns of that table.
|
|
21
|
+
*/
|
|
22
|
+
execute(options?: TableWidthsCommandOptions): void;
|
|
23
|
+
}
|
|
24
|
+
export interface TableWidthsCommandOptions {
|
|
25
|
+
/**
|
|
26
|
+
* New value of the `columnWidths` attribute. Must be array of strings or string with comma-separated values.
|
|
27
|
+
* If skipped, the column widths information will be deleted.
|
|
28
|
+
*/
|
|
29
|
+
columnWidths?: Array<string> | string;
|
|
30
|
+
/**
|
|
31
|
+
* The new table width. If skipped, the model attribute will be removed.
|
|
32
|
+
*/
|
|
33
|
+
tableWidth?: string;
|
|
34
|
+
/**
|
|
35
|
+
* The table that is having the columns resized.
|
|
36
|
+
*/
|
|
37
|
+
table?: Element;
|
|
38
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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/tablecolumnresize/utils
|
|
7
|
+
*/
|
|
8
|
+
import type { Editor } from 'ckeditor5/src/core.js';
|
|
9
|
+
import type { Element, Model, Writer } from 'ckeditor5/src/engine.js';
|
|
10
|
+
import type TableUtils from '../tableutils.js';
|
|
11
|
+
/**
|
|
12
|
+
* Returns all the inserted or changed table model elements in a given change set. Only the tables
|
|
13
|
+
* with 'columnsWidth' attribute are taken into account. The returned set may be empty.
|
|
14
|
+
*
|
|
15
|
+
* Most notably if an entire table is removed it will not be included in returned set.
|
|
16
|
+
*
|
|
17
|
+
* @param model The model to collect the affected elements from.
|
|
18
|
+
* @returns A set of table model elements.
|
|
19
|
+
*/
|
|
20
|
+
export declare function getChangedResizedTables(model: Model): Set<Element>;
|
|
21
|
+
/**
|
|
22
|
+
* Calculates the percentage of the minimum column width given in pixels for a given table.
|
|
23
|
+
*
|
|
24
|
+
* @param modelTable A table model element.
|
|
25
|
+
* @param editor The editor instance.
|
|
26
|
+
* @returns The minimal column width in percentage.
|
|
27
|
+
*/
|
|
28
|
+
export declare function getColumnMinWidthAsPercentage(modelTable: Element, editor: Editor): number;
|
|
29
|
+
/**
|
|
30
|
+
* Calculates the table width in pixels.
|
|
31
|
+
*
|
|
32
|
+
* @param modelTable A table model element.
|
|
33
|
+
* @param editor The editor instance.
|
|
34
|
+
* @returns The width of the table in pixels.
|
|
35
|
+
*/
|
|
36
|
+
export declare function getTableWidthInPixels(modelTable: Element, editor: Editor): number;
|
|
37
|
+
/**
|
|
38
|
+
* Returns the computed width (in pixels) of the DOM element without padding and borders.
|
|
39
|
+
*
|
|
40
|
+
* @param domElement A DOM element.
|
|
41
|
+
* @returns The width of the DOM element in pixels.
|
|
42
|
+
*/
|
|
43
|
+
export declare function getElementWidthInPixels(domElement: HTMLElement): number;
|
|
44
|
+
/**
|
|
45
|
+
* Returns the column indexes on the left and right edges of a cell. They differ if the cell spans
|
|
46
|
+
* across multiple columns.
|
|
47
|
+
*
|
|
48
|
+
* @param cell A table cell model element.
|
|
49
|
+
* @param tableUtils The Table Utils plugin instance.
|
|
50
|
+
* @returns An object containing the indexes of the left and right edges of the cell.
|
|
51
|
+
*/
|
|
52
|
+
export declare function getColumnEdgesIndexes(cell: Element, tableUtils: TableUtils): {
|
|
53
|
+
leftEdge: number;
|
|
54
|
+
rightEdge: number;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Rounds the provided value to a fixed-point number with defined number of digits after the decimal point.
|
|
58
|
+
*
|
|
59
|
+
* @param value A number to be rounded.
|
|
60
|
+
* @returns The rounded number.
|
|
61
|
+
*/
|
|
62
|
+
export declare function toPrecision(value: number | string): number;
|
|
63
|
+
/**
|
|
64
|
+
* Clamps the number within the inclusive lower (min) and upper (max) bounds. Returned number is rounded using the
|
|
65
|
+
* {@link ~toPrecision `toPrecision()`} function.
|
|
66
|
+
*
|
|
67
|
+
* @param number A number to be clamped.
|
|
68
|
+
* @param min A lower bound.
|
|
69
|
+
* @param max An upper bound.
|
|
70
|
+
* @returns The clamped number.
|
|
71
|
+
*/
|
|
72
|
+
export declare function clamp(number: number, min: number, max: number): number;
|
|
73
|
+
/**
|
|
74
|
+
* Creates an array with defined length and fills all elements with defined value.
|
|
75
|
+
*
|
|
76
|
+
* @param length The length of the array.
|
|
77
|
+
* @param value The value to fill the array with.
|
|
78
|
+
* @returns An array with defined length and filled with defined value.
|
|
79
|
+
*/
|
|
80
|
+
export declare function createFilledArray<T>(length: number, value: T): Array<T>;
|
|
81
|
+
/**
|
|
82
|
+
* Sums all array values that can be parsed to a float.
|
|
83
|
+
*
|
|
84
|
+
* @param array An array of numbers.
|
|
85
|
+
* @returns The sum of all array values.
|
|
86
|
+
*/
|
|
87
|
+
export declare function sumArray(array: Array<number | string>): number;
|
|
88
|
+
/**
|
|
89
|
+
* Makes sure that the sum of the widths from all columns is 100%. If the sum of all the widths is not equal 100%, all the widths are
|
|
90
|
+
* changed proportionally so that they all sum back to 100%. If there are columns without specified width, the amount remaining
|
|
91
|
+
* after assigning the known widths will be distributed equally between them.
|
|
92
|
+
*
|
|
93
|
+
* @param columnWidths An array of column widths.
|
|
94
|
+
* @returns An array of column widths guaranteed to sum up to 100%.
|
|
95
|
+
*/
|
|
96
|
+
export declare function normalizeColumnWidths(columnWidths: Array<string>): Array<string>;
|
|
97
|
+
/**
|
|
98
|
+
* Calculates the total horizontal space taken by the cell. That includes:
|
|
99
|
+
* * width,
|
|
100
|
+
* * left and red padding,
|
|
101
|
+
* * border width.
|
|
102
|
+
*
|
|
103
|
+
* @param domCell A DOM cell element.
|
|
104
|
+
* @returns Width in pixels without `px` at the end.
|
|
105
|
+
*/
|
|
106
|
+
export declare function getDomCellOuterWidth(domCell: HTMLElement): number;
|
|
107
|
+
/**
|
|
108
|
+
* Updates column elements to match columns widths.
|
|
109
|
+
*
|
|
110
|
+
* @param columns
|
|
111
|
+
* @param tableColumnGroup
|
|
112
|
+
* @param normalizedWidths
|
|
113
|
+
* @param writer
|
|
114
|
+
*/
|
|
115
|
+
export declare function updateColumnElements(columns: Array<Element>, tableColumnGroup: Element, normalizedWidths: Array<string>, writer: Writer): void;
|
|
116
|
+
/**
|
|
117
|
+
* Returns a 'tableColumnGroup' element from the 'table'.
|
|
118
|
+
*
|
|
119
|
+
* @internal
|
|
120
|
+
* @param element A 'table' or 'tableColumnGroup' element.
|
|
121
|
+
* @returns A 'tableColumnGroup' element.
|
|
122
|
+
*/
|
|
123
|
+
export declare function getColumnGroupElement(element: Element): Element;
|
|
124
|
+
/**
|
|
125
|
+
* Returns an array of 'tableColumn' elements. It may be empty if there's no `tableColumnGroup` element.
|
|
126
|
+
*
|
|
127
|
+
* @internal
|
|
128
|
+
* @param element A 'table' or 'tableColumnGroup' element.
|
|
129
|
+
* @returns An array of 'tableColumn' elements.
|
|
130
|
+
*/
|
|
131
|
+
export declare function getTableColumnElements(element: Element): Array<Element>;
|
|
132
|
+
/**
|
|
133
|
+
* Returns an array of table column widths.
|
|
134
|
+
*
|
|
135
|
+
* @internal
|
|
136
|
+
* @param element A 'table' or 'tableColumnGroup' element.
|
|
137
|
+
* @returns An array of table column widths.
|
|
138
|
+
*/
|
|
139
|
+
export declare function getTableColumnsWidths(element: Element): Array<string>;
|
|
140
|
+
/**
|
|
141
|
+
* Translates the `colSpan` model attribute into additional column widths and returns the resulting array.
|
|
142
|
+
*
|
|
143
|
+
* @internal
|
|
144
|
+
* @param element A 'table' or 'tableColumnGroup' element.
|
|
145
|
+
* @param writer A writer instance.
|
|
146
|
+
* @returns An array of table column widths.
|
|
147
|
+
*/
|
|
148
|
+
export declare function translateColSpanAttribute(element: Element, writer: Writer): Array<string>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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/tablecolumnresize
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin } from 'ckeditor5/src/core.js';
|
|
9
|
+
import TableColumnResizeEditing from './tablecolumnresize/tablecolumnresizeediting.js';
|
|
10
|
+
import TableCellWidthEditing from './tablecellwidth/tablecellwidthediting.js';
|
|
11
|
+
import '../theme/tablecolumnresize.css';
|
|
12
|
+
/**
|
|
13
|
+
* The table column resize feature.
|
|
14
|
+
*
|
|
15
|
+
* It provides the possibility to set the width of each column in a table using a resize handler.
|
|
16
|
+
*/
|
|
17
|
+
export default class TableColumnResize extends Plugin {
|
|
18
|
+
/**
|
|
19
|
+
* @inheritDoc
|
|
20
|
+
*/
|
|
21
|
+
static get requires(): readonly [typeof TableColumnResizeEditing, typeof TableCellWidthEditing];
|
|
22
|
+
/**
|
|
23
|
+
* @inheritDoc
|
|
24
|
+
*/
|
|
25
|
+
static get pluginName(): "TableColumnResize";
|
|
26
|
+
}
|
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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/tableconfig
|
|
7
|
+
*/
|
|
8
|
+
import type { ToolbarConfigItem } from 'ckeditor5/src/core.js';
|
|
9
|
+
import type { ColorOption, ColorPickerConfig } from 'ckeditor5/src/ui.js';
|
|
10
|
+
/**
|
|
11
|
+
* The configuration of the table feature. Used by the table feature in the `@ckeditor/ckeditor5-table` package.
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* ClassicEditor
|
|
15
|
+
* .create( editorElement, {
|
|
16
|
+
* table: ... // Table feature options.
|
|
17
|
+
* } )
|
|
18
|
+
* .then( ... )
|
|
19
|
+
* .catch( ... );
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
|
|
23
|
+
*/
|
|
24
|
+
export interface TableConfig {
|
|
25
|
+
/**
|
|
26
|
+
* Number of rows and columns to render by default as table heading when inserting new tables.
|
|
27
|
+
*
|
|
28
|
+
* You can configure it like this:
|
|
29
|
+
*
|
|
30
|
+
* ```ts
|
|
31
|
+
* const tableConfig = {
|
|
32
|
+
* defaultHeadings: {
|
|
33
|
+
* rows: 1,
|
|
34
|
+
* columns: 1
|
|
35
|
+
* }
|
|
36
|
+
* };
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* Both rows and columns properties are optional defaulting to 0 (no heading).
|
|
40
|
+
*/
|
|
41
|
+
defaultHeadings?: {
|
|
42
|
+
rows?: number;
|
|
43
|
+
columns?: number;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Items to be placed in the table content toolbar.
|
|
47
|
+
* The {@link module:table/tabletoolbar~TableToolbar} plugin is required to make this toolbar work.
|
|
48
|
+
*
|
|
49
|
+
* Assuming that you use the {@link module:table/tableui~TableUI} feature, the following toolbar items will be available
|
|
50
|
+
* in {@link module:ui/componentfactory~ComponentFactory}:
|
|
51
|
+
*
|
|
52
|
+
* * `'tableRow'`,
|
|
53
|
+
* * `'tableColumn'`,
|
|
54
|
+
* * `'mergeTableCells'`.
|
|
55
|
+
*
|
|
56
|
+
* You can thus configure the toolbar like this:
|
|
57
|
+
*
|
|
58
|
+
* ```ts
|
|
59
|
+
* const tableConfig = {
|
|
60
|
+
* contentToolbar: [ 'tableRow', 'tableColumn', 'mergeTableCells' ]
|
|
61
|
+
* };
|
|
62
|
+
* ```
|
|
63
|
+
*
|
|
64
|
+
* Of course, the same buttons can also be used in the
|
|
65
|
+
* {@link module:core/editor/editorconfig~EditorConfig#toolbar main editor toolbar}.
|
|
66
|
+
*
|
|
67
|
+
* Read more about configuring the toolbar in {@link module:core/editor/editorconfig~EditorConfig#toolbar}.
|
|
68
|
+
*/
|
|
69
|
+
contentToolbar?: Array<ToolbarConfigItem>;
|
|
70
|
+
/**
|
|
71
|
+
* Items to be placed in the table toolbar.
|
|
72
|
+
* The {@link module:table/tabletoolbar~TableToolbar} plugin is required to make this toolbar work.
|
|
73
|
+
*
|
|
74
|
+
* You can thus configure the toolbar like this:
|
|
75
|
+
*
|
|
76
|
+
* ```ts
|
|
77
|
+
* const tableConfig = {
|
|
78
|
+
* tableToolbar: [ 'blockQuote' ]
|
|
79
|
+
* };
|
|
80
|
+
* ```
|
|
81
|
+
*
|
|
82
|
+
* Of course, the same buttons can also be used in the
|
|
83
|
+
* {@link module:core/editor/editorconfig~EditorConfig#toolbar main editor toolbar}.
|
|
84
|
+
*
|
|
85
|
+
* Read more about configuring the toolbar in {@link module:core/editor/editorconfig~EditorConfig#toolbar}.
|
|
86
|
+
*/
|
|
87
|
+
tableToolbar?: Array<ToolbarConfigItem>;
|
|
88
|
+
/**
|
|
89
|
+
* The configuration of the table properties user interface (balloon). It allows to define:
|
|
90
|
+
*
|
|
91
|
+
* * The color palette for the table border color style field (`tableProperties.borderColors`),
|
|
92
|
+
* * The color palette for the table background style field (`tableProperties.backgroundColors`).
|
|
93
|
+
*
|
|
94
|
+
* ```ts
|
|
95
|
+
* const tableConfig = {
|
|
96
|
+
* tableProperties: {
|
|
97
|
+
* borderColors: [
|
|
98
|
+
* {
|
|
99
|
+
* color: 'hsl(0, 0%, 90%)',
|
|
100
|
+
* label: 'Light grey'
|
|
101
|
+
* },
|
|
102
|
+
* // ...
|
|
103
|
+
* ],
|
|
104
|
+
* backgroundColors: [
|
|
105
|
+
* {
|
|
106
|
+
* color: 'hsl(120, 75%, 60%)',
|
|
107
|
+
* label: 'Green'
|
|
108
|
+
* },
|
|
109
|
+
* // ...
|
|
110
|
+
* ]
|
|
111
|
+
* }
|
|
112
|
+
* };
|
|
113
|
+
* ```
|
|
114
|
+
*
|
|
115
|
+
* * The default styles for tables (`tableProperties.defaultProperties`):
|
|
116
|
+
*
|
|
117
|
+
* ```
|
|
118
|
+
* const tableConfig = {
|
|
119
|
+
* tableProperties: {
|
|
120
|
+
* defaultProperties: {
|
|
121
|
+
* borderStyle: 'dashed',
|
|
122
|
+
* borderColor: 'hsl(0, 0%, 90%)',
|
|
123
|
+
* borderWidth: '3px',
|
|
124
|
+
* alignment: 'left'
|
|
125
|
+
* }
|
|
126
|
+
* }
|
|
127
|
+
* }
|
|
128
|
+
* ```
|
|
129
|
+
*
|
|
130
|
+
* {@link module:table/tableconfig~TablePropertiesOptions Read more about the supported properties.}
|
|
131
|
+
*
|
|
132
|
+
* **Note**: The `borderColors` and `backgroundColors` options do not impact the data loaded into the editor,
|
|
133
|
+
* i.e. they do not limit or filter the colors in the data. They are used only in the user interface
|
|
134
|
+
* allowing users to pick colors in a more convenient way. The `defaultProperties` option does impact the data.
|
|
135
|
+
* Default values will not be kept in the editor model.
|
|
136
|
+
*
|
|
137
|
+
* The default color palettes for the table background and the table border are the same
|
|
138
|
+
* ({@link module:table/utils/ui/table-properties#defaultColors check out their content}).
|
|
139
|
+
*
|
|
140
|
+
* Both color palette configurations must follow the
|
|
141
|
+
* {@link module:table/tableconfig~TableColorConfig table color configuration format}.
|
|
142
|
+
*
|
|
143
|
+
* Read more about configuring the table feature in {@link module:table/tableconfig~TableConfig}.
|
|
144
|
+
*/
|
|
145
|
+
tableProperties?: TablePropertiesConfig;
|
|
146
|
+
/**
|
|
147
|
+
* The configuration of the table cell properties user interface (balloon). It allows to define:
|
|
148
|
+
*
|
|
149
|
+
* * The color palette for the cell border color style field (`tableCellProperties.borderColors`),
|
|
150
|
+
* * The color palette for the cell background style field (`tableCellProperties.backgroundColors`).
|
|
151
|
+
*
|
|
152
|
+
* ```ts
|
|
153
|
+
* const tableConfig = {
|
|
154
|
+
* tableCellProperties: {
|
|
155
|
+
* borderColors: [
|
|
156
|
+
* {
|
|
157
|
+
* color: 'hsl(0, 0%, 90%)',
|
|
158
|
+
* label: 'Light grey'
|
|
159
|
+
* },
|
|
160
|
+
* // ...
|
|
161
|
+
* ],
|
|
162
|
+
* backgroundColors: [
|
|
163
|
+
* {
|
|
164
|
+
* color: 'hsl(120, 75%, 60%)',
|
|
165
|
+
* label: 'Green'
|
|
166
|
+
* },
|
|
167
|
+
* // ...
|
|
168
|
+
* ]
|
|
169
|
+
* }
|
|
170
|
+
* };
|
|
171
|
+
* ```
|
|
172
|
+
*
|
|
173
|
+
* * The default styles for table cells (`tableCellProperties.defaultProperties`):
|
|
174
|
+
*
|
|
175
|
+
* ```ts
|
|
176
|
+
* const tableConfig = {
|
|
177
|
+
* tableCellProperties: {
|
|
178
|
+
* defaultProperties: {
|
|
179
|
+
* horizontalAlignment: 'right',
|
|
180
|
+
* verticalAlignment: 'bottom',
|
|
181
|
+
* padding: '5px'
|
|
182
|
+
* }
|
|
183
|
+
* }
|
|
184
|
+
* }
|
|
185
|
+
* ```
|
|
186
|
+
*
|
|
187
|
+
* {@link module:table/tableconfig~TablePropertiesOptions Read more about the supported properties.}
|
|
188
|
+
*
|
|
189
|
+
* **Note**: The `borderColors` and `backgroundColors` options do not impact the data loaded into the editor,
|
|
190
|
+
* i.e. they do not limit or filter the colors in the data. They are used only in the user interface
|
|
191
|
+
* allowing users to pick colors in a more convenient way. The `defaultProperties` option does impact the data.
|
|
192
|
+
* Default values will not be kept in the editor model.
|
|
193
|
+
*
|
|
194
|
+
* The default color palettes for the cell background and the cell border are the same
|
|
195
|
+
* ({@link module:table/utils/ui/table-properties#defaultColors check out their content}).
|
|
196
|
+
*
|
|
197
|
+
* Both color palette configurations must follow the
|
|
198
|
+
* {@link module:table/tableconfig~TableColorConfig table color configuration format}.
|
|
199
|
+
*
|
|
200
|
+
* Read more about configuring the table feature in {@link module:table/tableconfig~TableConfig}.
|
|
201
|
+
*/
|
|
202
|
+
tableCellProperties?: TableCellPropertiesConfig;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* The configuration of the table properties user interface (balloon).
|
|
206
|
+
*/
|
|
207
|
+
export interface TablePropertiesConfig {
|
|
208
|
+
borderColors?: TableColorConfig;
|
|
209
|
+
backgroundColors?: TableColorConfig;
|
|
210
|
+
defaultProperties?: TablePropertiesOptions;
|
|
211
|
+
/**
|
|
212
|
+
* Configuration of the color picker in the table properties balloon.
|
|
213
|
+
*
|
|
214
|
+
* If set to `false` the picker will not appear.
|
|
215
|
+
*/
|
|
216
|
+
colorPicker?: false | ColorPickerConfig;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* The configuration of the table default properties feature.
|
|
220
|
+
*/
|
|
221
|
+
export interface TablePropertiesOptions {
|
|
222
|
+
/**
|
|
223
|
+
* The default `width` of the table.
|
|
224
|
+
*/
|
|
225
|
+
width?: string;
|
|
226
|
+
/**
|
|
227
|
+
* The default `height` of the table.
|
|
228
|
+
*/
|
|
229
|
+
height?: string;
|
|
230
|
+
/**
|
|
231
|
+
* The default `background-color` of the table.
|
|
232
|
+
*/
|
|
233
|
+
backgroundColor?: string;
|
|
234
|
+
/**
|
|
235
|
+
* The default `border-color` of the table.
|
|
236
|
+
*/
|
|
237
|
+
borderColor?: string;
|
|
238
|
+
/**
|
|
239
|
+
* The default `border-width` of the table.
|
|
240
|
+
*/
|
|
241
|
+
borderWidth?: string;
|
|
242
|
+
/**
|
|
243
|
+
* The default `border-style` of the table.
|
|
244
|
+
*
|
|
245
|
+
* @default 'none'
|
|
246
|
+
*/
|
|
247
|
+
borderStyle?: string;
|
|
248
|
+
/**
|
|
249
|
+
* The default `alignment` of the table.
|
|
250
|
+
*
|
|
251
|
+
* @default 'center'
|
|
252
|
+
*/
|
|
253
|
+
alignment?: string;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* The configuration of the table cell properties user interface (balloon).
|
|
257
|
+
*/
|
|
258
|
+
export interface TableCellPropertiesConfig {
|
|
259
|
+
borderColors?: TableColorConfig;
|
|
260
|
+
backgroundColors?: TableColorConfig;
|
|
261
|
+
defaultProperties?: TableCellPropertiesOptions;
|
|
262
|
+
/**
|
|
263
|
+
* Configuration of the color picker in the table cell properties balloon.
|
|
264
|
+
*
|
|
265
|
+
* If set to `false` the picker will not appear.
|
|
266
|
+
*/
|
|
267
|
+
colorPicker?: false | ColorPickerConfig;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* An array of color definitions (either strings or objects).
|
|
271
|
+
*
|
|
272
|
+
* ```ts
|
|
273
|
+
* const colors = [
|
|
274
|
+
* {
|
|
275
|
+
* color: 'hsl(0, 0%, 60%)',
|
|
276
|
+
* label: 'Grey'
|
|
277
|
+
* },
|
|
278
|
+
* 'hsl(0, 0%, 80%)',
|
|
279
|
+
* {
|
|
280
|
+
* color: 'hsl(0, 0%, 90%)',
|
|
281
|
+
* label: 'Light grey'
|
|
282
|
+
* },
|
|
283
|
+
* {
|
|
284
|
+
* color: 'hsl(0, 0%, 100%)',
|
|
285
|
+
* label: 'White',
|
|
286
|
+
* hasBorder: true
|
|
287
|
+
* },
|
|
288
|
+
* '#FF0000'
|
|
289
|
+
* ]
|
|
290
|
+
* ```
|
|
291
|
+
*
|
|
292
|
+
* Usually used as a configuration parameter, for instance in
|
|
293
|
+
* {@link module:table/tableconfig~TableConfig#tableProperties `config.table.tableProperties`}
|
|
294
|
+
* or {@link module:table/tableconfig~TableConfig#tableCellProperties `config.table.tableCellProperties`}.
|
|
295
|
+
*/
|
|
296
|
+
export type TableColorConfig = Array<ColorOption>;
|
|
297
|
+
/**
|
|
298
|
+
* The configuration of the table cell default properties feature.
|
|
299
|
+
*/
|
|
300
|
+
export interface TableCellPropertiesOptions {
|
|
301
|
+
/**
|
|
302
|
+
* The default `width` of the table cell.
|
|
303
|
+
*/
|
|
304
|
+
width?: string;
|
|
305
|
+
/**
|
|
306
|
+
* The default `height` of the table cell.
|
|
307
|
+
*/
|
|
308
|
+
height?: string;
|
|
309
|
+
/**
|
|
310
|
+
* The default `padding` of the table cell.
|
|
311
|
+
*/
|
|
312
|
+
padding?: string;
|
|
313
|
+
/**
|
|
314
|
+
* The default `background-color` of the table cell.
|
|
315
|
+
*/
|
|
316
|
+
backgroundColor?: string;
|
|
317
|
+
/**
|
|
318
|
+
* The default `border-color` of the table cell.
|
|
319
|
+
*/
|
|
320
|
+
borderColor?: string;
|
|
321
|
+
/**
|
|
322
|
+
* The default `border-width` of the table cell.
|
|
323
|
+
*/
|
|
324
|
+
borderWidth?: string;
|
|
325
|
+
/**
|
|
326
|
+
* The default `border-style` of the table cell.
|
|
327
|
+
*
|
|
328
|
+
* @default 'none'
|
|
329
|
+
*/
|
|
330
|
+
borderStyle?: string;
|
|
331
|
+
/**
|
|
332
|
+
* The default `horizontalAlignment` of the table cell.
|
|
333
|
+
*
|
|
334
|
+
* @default 'center'
|
|
335
|
+
*/
|
|
336
|
+
horizontalAlignment?: string;
|
|
337
|
+
/**
|
|
338
|
+
* The default `verticalAlignment` of the table cell.
|
|
339
|
+
*
|
|
340
|
+
* @default 'middle'
|
|
341
|
+
*/
|
|
342
|
+
verticalAlignment?: string;
|
|
343
|
+
}
|