@ckeditor/ckeditor5-table 41.3.0 → 41.4.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.
Files changed (205) hide show
  1. package/dist/index-content.css +55 -0
  2. package/dist/index-editor.css +150 -0
  3. package/dist/index.css +362 -0
  4. package/dist/index.css.map +1 -0
  5. package/dist/index.js +10464 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/translations/ar.d.ts +8 -0
  8. package/dist/translations/ar.js +5 -0
  9. package/dist/translations/az.d.ts +8 -0
  10. package/dist/translations/az.js +5 -0
  11. package/dist/translations/bg.d.ts +8 -0
  12. package/dist/translations/bg.js +5 -0
  13. package/dist/translations/bn.d.ts +8 -0
  14. package/dist/translations/bn.js +5 -0
  15. package/dist/translations/ca.d.ts +8 -0
  16. package/dist/translations/ca.js +5 -0
  17. package/dist/translations/cs.d.ts +8 -0
  18. package/dist/translations/cs.js +5 -0
  19. package/dist/translations/da.d.ts +8 -0
  20. package/dist/translations/da.js +5 -0
  21. package/dist/translations/de-ch.d.ts +8 -0
  22. package/dist/translations/de-ch.js +5 -0
  23. package/dist/translations/de.d.ts +8 -0
  24. package/dist/translations/de.js +5 -0
  25. package/dist/translations/el.d.ts +8 -0
  26. package/dist/translations/el.js +5 -0
  27. package/dist/translations/en-au.d.ts +8 -0
  28. package/dist/translations/en-au.js +5 -0
  29. package/dist/translations/en-gb.d.ts +8 -0
  30. package/dist/translations/en-gb.js +5 -0
  31. package/dist/translations/en.d.ts +8 -0
  32. package/dist/translations/en.js +5 -0
  33. package/dist/translations/es.d.ts +8 -0
  34. package/dist/translations/es.js +5 -0
  35. package/dist/translations/et.d.ts +8 -0
  36. package/dist/translations/et.js +5 -0
  37. package/dist/translations/fa.d.ts +8 -0
  38. package/dist/translations/fa.js +5 -0
  39. package/dist/translations/fi.d.ts +8 -0
  40. package/dist/translations/fi.js +5 -0
  41. package/dist/translations/fr.d.ts +8 -0
  42. package/dist/translations/fr.js +5 -0
  43. package/dist/translations/gl.d.ts +8 -0
  44. package/dist/translations/gl.js +5 -0
  45. package/dist/translations/he.d.ts +8 -0
  46. package/dist/translations/he.js +5 -0
  47. package/dist/translations/hi.d.ts +8 -0
  48. package/dist/translations/hi.js +5 -0
  49. package/dist/translations/hr.d.ts +8 -0
  50. package/dist/translations/hr.js +5 -0
  51. package/dist/translations/hu.d.ts +8 -0
  52. package/dist/translations/hu.js +5 -0
  53. package/dist/translations/hy.d.ts +8 -0
  54. package/dist/translations/hy.js +5 -0
  55. package/dist/translations/id.d.ts +8 -0
  56. package/dist/translations/id.js +5 -0
  57. package/dist/translations/it.d.ts +8 -0
  58. package/dist/translations/it.js +5 -0
  59. package/dist/translations/ja.d.ts +8 -0
  60. package/dist/translations/ja.js +5 -0
  61. package/dist/translations/ko.d.ts +8 -0
  62. package/dist/translations/ko.js +5 -0
  63. package/dist/translations/ku.d.ts +8 -0
  64. package/dist/translations/ku.js +5 -0
  65. package/dist/translations/lt.d.ts +8 -0
  66. package/dist/translations/lt.js +5 -0
  67. package/dist/translations/lv.d.ts +8 -0
  68. package/dist/translations/lv.js +5 -0
  69. package/dist/translations/ms.d.ts +8 -0
  70. package/dist/translations/ms.js +5 -0
  71. package/dist/translations/nb.d.ts +8 -0
  72. package/dist/translations/nb.js +5 -0
  73. package/dist/translations/ne.d.ts +8 -0
  74. package/dist/translations/ne.js +5 -0
  75. package/dist/translations/nl.d.ts +8 -0
  76. package/dist/translations/nl.js +5 -0
  77. package/dist/translations/no.d.ts +8 -0
  78. package/dist/translations/no.js +5 -0
  79. package/dist/translations/pl.d.ts +8 -0
  80. package/dist/translations/pl.js +5 -0
  81. package/dist/translations/pt-br.d.ts +8 -0
  82. package/dist/translations/pt-br.js +5 -0
  83. package/dist/translations/pt.d.ts +8 -0
  84. package/dist/translations/pt.js +5 -0
  85. package/dist/translations/ro.d.ts +8 -0
  86. package/dist/translations/ro.js +5 -0
  87. package/dist/translations/ru.d.ts +8 -0
  88. package/dist/translations/ru.js +5 -0
  89. package/dist/translations/sk.d.ts +8 -0
  90. package/dist/translations/sk.js +5 -0
  91. package/dist/translations/sl.d.ts +8 -0
  92. package/dist/translations/sl.js +5 -0
  93. package/dist/translations/sq.d.ts +8 -0
  94. package/dist/translations/sq.js +5 -0
  95. package/dist/translations/sr-latn.d.ts +8 -0
  96. package/dist/translations/sr-latn.js +5 -0
  97. package/dist/translations/sr.d.ts +8 -0
  98. package/dist/translations/sr.js +5 -0
  99. package/dist/translations/sv.d.ts +8 -0
  100. package/dist/translations/sv.js +5 -0
  101. package/dist/translations/th.d.ts +8 -0
  102. package/dist/translations/th.js +5 -0
  103. package/dist/translations/tk.d.ts +8 -0
  104. package/dist/translations/tk.js +5 -0
  105. package/dist/translations/tr.d.ts +8 -0
  106. package/dist/translations/tr.js +5 -0
  107. package/dist/translations/tt.d.ts +8 -0
  108. package/dist/translations/tt.js +5 -0
  109. package/dist/translations/ug.d.ts +8 -0
  110. package/dist/translations/ug.js +5 -0
  111. package/dist/translations/uk.d.ts +8 -0
  112. package/dist/translations/uk.js +5 -0
  113. package/dist/translations/ur.d.ts +8 -0
  114. package/dist/translations/ur.js +5 -0
  115. package/dist/translations/uz.d.ts +8 -0
  116. package/dist/translations/uz.js +5 -0
  117. package/dist/translations/vi.d.ts +8 -0
  118. package/dist/translations/vi.js +5 -0
  119. package/dist/translations/zh-cn.d.ts +8 -0
  120. package/dist/translations/zh-cn.js +5 -0
  121. package/dist/translations/zh.d.ts +8 -0
  122. package/dist/translations/zh.js +5 -0
  123. package/dist/types/augmentation.d.ts +80 -0
  124. package/dist/types/commands/insertcolumncommand.d.ts +59 -0
  125. package/dist/types/commands/insertrowcommand.d.ts +58 -0
  126. package/dist/types/commands/inserttablecommand.d.ts +48 -0
  127. package/dist/types/commands/mergecellcommand.d.ts +72 -0
  128. package/dist/types/commands/mergecellscommand.d.ts +32 -0
  129. package/dist/types/commands/removecolumncommand.d.ts +33 -0
  130. package/dist/types/commands/removerowcommand.d.ts +33 -0
  131. package/dist/types/commands/selectcolumncommand.d.ts +37 -0
  132. package/dist/types/commands/selectrowcommand.d.ts +37 -0
  133. package/dist/types/commands/setheadercolumncommand.d.ts +54 -0
  134. package/dist/types/commands/setheaderrowcommand.d.ts +57 -0
  135. package/dist/types/commands/splitcellcommand.d.ts +47 -0
  136. package/dist/types/converters/downcast.d.ts +67 -0
  137. package/dist/types/converters/table-caption-post-fixer.d.ts +24 -0
  138. package/dist/types/converters/table-cell-paragraph-post-fixer.d.ts +36 -0
  139. package/dist/types/converters/table-cell-refresh-handler.d.ts +22 -0
  140. package/dist/types/converters/table-headings-refresh-handler.d.ts +21 -0
  141. package/dist/types/converters/table-layout-post-fixer.d.ts +230 -0
  142. package/dist/types/converters/tableproperties.d.ts +58 -0
  143. package/dist/types/converters/upcasttable.d.ts +53 -0
  144. package/dist/types/index.d.ts +64 -0
  145. package/dist/types/plaintableoutput.d.ts +30 -0
  146. package/dist/types/table.d.ts +44 -0
  147. package/dist/types/tablecaption/tablecaptionediting.d.ts +67 -0
  148. package/dist/types/tablecaption/tablecaptionui.d.ts +25 -0
  149. package/dist/types/tablecaption/toggletablecaptioncommand.d.ts +72 -0
  150. package/dist/types/tablecaption/utils.d.ts +42 -0
  151. package/dist/types/tablecaption.d.ts +28 -0
  152. package/dist/types/tablecellproperties/commands/tablecellbackgroundcolorcommand.d.ts +36 -0
  153. package/dist/types/tablecellproperties/commands/tablecellbordercolorcommand.d.ts +41 -0
  154. package/dist/types/tablecellproperties/commands/tablecellborderstylecommand.d.ts +41 -0
  155. package/dist/types/tablecellproperties/commands/tablecellborderwidthcommand.d.ts +55 -0
  156. package/dist/types/tablecellproperties/commands/tablecellheightcommand.d.ts +50 -0
  157. package/dist/types/tablecellproperties/commands/tablecellhorizontalalignmentcommand.d.ts +36 -0
  158. package/dist/types/tablecellproperties/commands/tablecellpaddingcommand.d.ts +55 -0
  159. package/dist/types/tablecellproperties/commands/tablecellpropertycommand.d.ts +66 -0
  160. package/dist/types/tablecellproperties/commands/tablecellverticalalignmentcommand.d.ts +44 -0
  161. package/dist/types/tablecellproperties/tablecellpropertiesediting.d.ts +47 -0
  162. package/dist/types/tablecellproperties/tablecellpropertiesui.d.ts +116 -0
  163. package/dist/types/tablecellproperties/ui/tablecellpropertiesview.d.ts +232 -0
  164. package/dist/types/tablecellproperties.d.ts +34 -0
  165. package/dist/types/tablecellwidth/commands/tablecellwidthcommand.d.ts +50 -0
  166. package/dist/types/tablecellwidth/tablecellwidthediting.d.ts +33 -0
  167. package/dist/types/tableclipboard.d.ts +74 -0
  168. package/dist/types/tablecolumnresize/constants.d.ts +24 -0
  169. package/dist/types/tablecolumnresize/converters.d.ts +22 -0
  170. package/dist/types/tablecolumnresize/tablecolumnresizeediting.d.ts +143 -0
  171. package/dist/types/tablecolumnresize/tablewidthscommand.d.ts +42 -0
  172. package/dist/types/tablecolumnresize/utils.d.ts +152 -0
  173. package/dist/types/tablecolumnresize.d.ts +30 -0
  174. package/dist/types/tableconfig.d.ts +347 -0
  175. package/dist/types/tableediting.d.ts +102 -0
  176. package/dist/types/tablekeyboard.d.ts +72 -0
  177. package/dist/types/tablemouse/mouseeventsobserver.d.ts +66 -0
  178. package/dist/types/tablemouse.d.ts +52 -0
  179. package/dist/types/tableproperties/commands/tablealignmentcommand.d.ts +36 -0
  180. package/dist/types/tableproperties/commands/tablebackgroundcolorcommand.d.ts +36 -0
  181. package/dist/types/tableproperties/commands/tablebordercolorcommand.d.ts +41 -0
  182. package/dist/types/tableproperties/commands/tableborderstylecommand.d.ts +41 -0
  183. package/dist/types/tableproperties/commands/tableborderwidthcommand.d.ts +55 -0
  184. package/dist/types/tableproperties/commands/tableheightcommand.d.ts +50 -0
  185. package/dist/types/tableproperties/commands/tablepropertycommand.d.ts +65 -0
  186. package/dist/types/tableproperties/commands/tablewidthcommand.d.ts +50 -0
  187. package/dist/types/tableproperties/tablepropertiesediting.d.ts +44 -0
  188. package/dist/types/tableproperties/tablepropertiesui.d.ts +118 -0
  189. package/dist/types/tableproperties/ui/tablepropertiesview.d.ts +211 -0
  190. package/dist/types/tableproperties.d.ts +34 -0
  191. package/dist/types/tableselection.d.ts +111 -0
  192. package/dist/types/tabletoolbar.d.ts +36 -0
  193. package/dist/types/tableui.d.ts +58 -0
  194. package/dist/types/tableutils.d.ts +452 -0
  195. package/dist/types/tablewalker.d.ts +366 -0
  196. package/dist/types/ui/colorinputview.d.ts +144 -0
  197. package/dist/types/ui/formrowview.d.ts +65 -0
  198. package/dist/types/ui/inserttableview.d.ts +85 -0
  199. package/dist/types/utils/common.d.ts +50 -0
  200. package/dist/types/utils/structure.d.ts +249 -0
  201. package/dist/types/utils/table-properties.d.ts +71 -0
  202. package/dist/types/utils/ui/contextualballoon.d.ts +38 -0
  203. package/dist/types/utils/ui/table-properties.d.ts +199 -0
  204. package/dist/types/utils/ui/widget.d.ts +24 -0
  205. package/package.json +3 -2
@@ -0,0 +1,152 @@
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
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
+ */
9
+ /**
10
+ * @module table/tablecolumnresize/utils
11
+ */
12
+ import type { Editor } from 'ckeditor5/src/core.js';
13
+ import type { Element, Model, Writer } from 'ckeditor5/src/engine.js';
14
+ import type TableUtils from '../tableutils.js';
15
+ /**
16
+ * Returns all the inserted or changed table model elements in a given change set. Only the tables
17
+ * with 'columnsWidth' attribute are taken into account. The returned set may be empty.
18
+ *
19
+ * Most notably if an entire table is removed it will not be included in returned set.
20
+ *
21
+ * @param model The model to collect the affected elements from.
22
+ * @returns A set of table model elements.
23
+ */
24
+ export declare function getChangedResizedTables(model: Model): Set<Element>;
25
+ /**
26
+ * Calculates the percentage of the minimum column width given in pixels for a given table.
27
+ *
28
+ * @param modelTable A table model element.
29
+ * @param editor The editor instance.
30
+ * @returns The minimal column width in percentage.
31
+ */
32
+ export declare function getColumnMinWidthAsPercentage(modelTable: Element, editor: Editor): number;
33
+ /**
34
+ * Calculates the table width in pixels.
35
+ *
36
+ * @param modelTable A table model element.
37
+ * @param editor The editor instance.
38
+ * @returns The width of the table in pixels.
39
+ */
40
+ export declare function getTableWidthInPixels(modelTable: Element, editor: Editor): number;
41
+ /**
42
+ * Returns the computed width (in pixels) of the DOM element without padding and borders.
43
+ *
44
+ * @param domElement A DOM element.
45
+ * @returns The width of the DOM element in pixels.
46
+ */
47
+ export declare function getElementWidthInPixels(domElement: HTMLElement): number;
48
+ /**
49
+ * Returns the column indexes on the left and right edges of a cell. They differ if the cell spans
50
+ * across multiple columns.
51
+ *
52
+ * @param cell A table cell model element.
53
+ * @param tableUtils The Table Utils plugin instance.
54
+ * @returns An object containing the indexes of the left and right edges of the cell.
55
+ */
56
+ export declare function getColumnEdgesIndexes(cell: Element, tableUtils: TableUtils): {
57
+ leftEdge: number;
58
+ rightEdge: number;
59
+ };
60
+ /**
61
+ * Rounds the provided value to a fixed-point number with defined number of digits after the decimal point.
62
+ *
63
+ * @param value A number to be rounded.
64
+ * @returns The rounded number.
65
+ */
66
+ export declare function toPrecision(value: number | string): number;
67
+ /**
68
+ * Clamps the number within the inclusive lower (min) and upper (max) bounds. Returned number is rounded using the
69
+ * {@link ~toPrecision `toPrecision()`} function.
70
+ *
71
+ * @param number A number to be clamped.
72
+ * @param min A lower bound.
73
+ * @param max An upper bound.
74
+ * @returns The clamped number.
75
+ */
76
+ export declare function clamp(number: number, min: number, max: number): number;
77
+ /**
78
+ * Creates an array with defined length and fills all elements with defined value.
79
+ *
80
+ * @param length The length of the array.
81
+ * @param value The value to fill the array with.
82
+ * @returns An array with defined length and filled with defined value.
83
+ */
84
+ export declare function createFilledArray<T>(length: number, value: T): Array<T>;
85
+ /**
86
+ * Sums all array values that can be parsed to a float.
87
+ *
88
+ * @param array An array of numbers.
89
+ * @returns The sum of all array values.
90
+ */
91
+ export declare function sumArray(array: Array<number | string>): number;
92
+ /**
93
+ * 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
94
+ * changed proportionally so that they all sum back to 100%. If there are columns without specified width, the amount remaining
95
+ * after assigning the known widths will be distributed equally between them.
96
+ *
97
+ * @param columnWidths An array of column widths.
98
+ * @returns An array of column widths guaranteed to sum up to 100%.
99
+ */
100
+ export declare function normalizeColumnWidths(columnWidths: Array<string>): Array<string>;
101
+ /**
102
+ * Calculates the total horizontal space taken by the cell. That includes:
103
+ * * width,
104
+ * * left and red padding,
105
+ * * border width.
106
+ *
107
+ * @param domCell A DOM cell element.
108
+ * @returns Width in pixels without `px` at the end.
109
+ */
110
+ export declare function getDomCellOuterWidth(domCell: HTMLElement): number;
111
+ /**
112
+ * Updates column elements to match columns widths.
113
+ *
114
+ * @param columns
115
+ * @param tableColumnGroup
116
+ * @param normalizedWidths
117
+ * @param writer
118
+ */
119
+ export declare function updateColumnElements(columns: Array<Element>, tableColumnGroup: Element, normalizedWidths: Array<string>, writer: Writer): void;
120
+ /**
121
+ * Returns a 'tableColumnGroup' element from the 'table'.
122
+ *
123
+ * @internal
124
+ * @param element A 'table' or 'tableColumnGroup' element.
125
+ * @returns A 'tableColumnGroup' element.
126
+ */
127
+ export declare function getColumnGroupElement(element: Element): Element;
128
+ /**
129
+ * Returns an array of 'tableColumn' elements. It may be empty if there's no `tableColumnGroup` element.
130
+ *
131
+ * @internal
132
+ * @param element A 'table' or 'tableColumnGroup' element.
133
+ * @returns An array of 'tableColumn' elements.
134
+ */
135
+ export declare function getTableColumnElements(element: Element): Array<Element>;
136
+ /**
137
+ * Returns an array of table column widths.
138
+ *
139
+ * @internal
140
+ * @param element A 'table' or 'tableColumnGroup' element.
141
+ * @returns An array of table column widths.
142
+ */
143
+ export declare function getTableColumnsWidths(element: Element): Array<string>;
144
+ /**
145
+ * Translates the `colSpan` model attribute into additional column widths and returns the resulting array.
146
+ *
147
+ * @internal
148
+ * @param element A 'table' or 'tableColumnGroup' element.
149
+ * @param writer A writer instance.
150
+ * @returns An array of table column widths.
151
+ */
152
+ export declare function translateColSpanAttribute(element: Element, writer: Writer): Array<string>;
@@ -0,0 +1,30 @@
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
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
+ */
9
+ /**
10
+ * @module table/tablecolumnresize
11
+ */
12
+ import { Plugin } from 'ckeditor5/src/core.js';
13
+ import TableColumnResizeEditing from './tablecolumnresize/tablecolumnresizeediting.js';
14
+ import TableCellWidthEditing from './tablecellwidth/tablecellwidthediting.js';
15
+ import '../theme/tablecolumnresize.css';
16
+ /**
17
+ * The table column resize feature.
18
+ *
19
+ * It provides the possibility to set the width of each column in a table using a resize handler.
20
+ */
21
+ export default class TableColumnResize extends Plugin {
22
+ /**
23
+ * @inheritDoc
24
+ */
25
+ static get requires(): readonly [typeof TableColumnResizeEditing, typeof TableCellWidthEditing];
26
+ /**
27
+ * @inheritDoc
28
+ */
29
+ static get pluginName(): "TableColumnResize";
30
+ }
@@ -0,0 +1,347 @@
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
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
+ */
9
+ /**
10
+ * @module table/tableconfig
11
+ */
12
+ import type { ToolbarConfigItem } from 'ckeditor5/src/core.js';
13
+ import type { ColorOption, ColorPickerConfig } from 'ckeditor5/src/ui.js';
14
+ /**
15
+ * The configuration of the table feature. Used by the table feature in the `@ckeditor/ckeditor5-table` package.
16
+ *
17
+ * ```ts
18
+ * ClassicEditor
19
+ * .create( editorElement, {
20
+ * table: ... // Table feature options.
21
+ * } )
22
+ * .then( ... )
23
+ * .catch( ... );
24
+ * ```
25
+ *
26
+ * See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
27
+ */
28
+ export interface TableConfig {
29
+ /**
30
+ * Number of rows and columns to render by default as table heading when inserting new tables.
31
+ *
32
+ * You can configure it like this:
33
+ *
34
+ * ```ts
35
+ * const tableConfig = {
36
+ * defaultHeadings: {
37
+ * rows: 1,
38
+ * columns: 1
39
+ * }
40
+ * };
41
+ * ```
42
+ *
43
+ * Both rows and columns properties are optional defaulting to 0 (no heading).
44
+ */
45
+ defaultHeadings?: {
46
+ rows?: number;
47
+ columns?: number;
48
+ };
49
+ /**
50
+ * Items to be placed in the table content toolbar.
51
+ * The {@link module:table/tabletoolbar~TableToolbar} plugin is required to make this toolbar work.
52
+ *
53
+ * Assuming that you use the {@link module:table/tableui~TableUI} feature, the following toolbar items will be available
54
+ * in {@link module:ui/componentfactory~ComponentFactory}:
55
+ *
56
+ * * `'tableRow'`,
57
+ * * `'tableColumn'`,
58
+ * * `'mergeTableCells'`.
59
+ *
60
+ * You can thus configure the toolbar like this:
61
+ *
62
+ * ```ts
63
+ * const tableConfig = {
64
+ * contentToolbar: [ 'tableRow', 'tableColumn', 'mergeTableCells' ]
65
+ * };
66
+ * ```
67
+ *
68
+ * Of course, the same buttons can also be used in the
69
+ * {@link module:core/editor/editorconfig~EditorConfig#toolbar main editor toolbar}.
70
+ *
71
+ * Read more about configuring the toolbar in {@link module:core/editor/editorconfig~EditorConfig#toolbar}.
72
+ */
73
+ contentToolbar?: Array<ToolbarConfigItem>;
74
+ /**
75
+ * Items to be placed in the table toolbar.
76
+ * The {@link module:table/tabletoolbar~TableToolbar} plugin is required to make this toolbar work.
77
+ *
78
+ * You can thus configure the toolbar like this:
79
+ *
80
+ * ```ts
81
+ * const tableConfig = {
82
+ * tableToolbar: [ 'blockQuote' ]
83
+ * };
84
+ * ```
85
+ *
86
+ * Of course, the same buttons can also be used in the
87
+ * {@link module:core/editor/editorconfig~EditorConfig#toolbar main editor toolbar}.
88
+ *
89
+ * Read more about configuring the toolbar in {@link module:core/editor/editorconfig~EditorConfig#toolbar}.
90
+ */
91
+ tableToolbar?: Array<ToolbarConfigItem>;
92
+ /**
93
+ * The configuration of the table properties user interface (balloon). It allows to define:
94
+ *
95
+ * * The color palette for the table border color style field (`tableProperties.borderColors`),
96
+ * * The color palette for the table background style field (`tableProperties.backgroundColors`).
97
+ *
98
+ * ```ts
99
+ * const tableConfig = {
100
+ * tableProperties: {
101
+ * borderColors: [
102
+ * {
103
+ * color: 'hsl(0, 0%, 90%)',
104
+ * label: 'Light grey'
105
+ * },
106
+ * // ...
107
+ * ],
108
+ * backgroundColors: [
109
+ * {
110
+ * color: 'hsl(120, 75%, 60%)',
111
+ * label: 'Green'
112
+ * },
113
+ * // ...
114
+ * ]
115
+ * }
116
+ * };
117
+ * ```
118
+ *
119
+ * * The default styles for tables (`tableProperties.defaultProperties`):
120
+ *
121
+ * ```
122
+ * const tableConfig = {
123
+ * tableProperties: {
124
+ * defaultProperties: {
125
+ * borderStyle: 'dashed',
126
+ * borderColor: 'hsl(0, 0%, 90%)',
127
+ * borderWidth: '3px',
128
+ * alignment: 'left'
129
+ * }
130
+ * }
131
+ * }
132
+ * ```
133
+ *
134
+ * {@link module:table/tableconfig~TablePropertiesOptions Read more about the supported properties.}
135
+ *
136
+ * **Note**: The `borderColors` and `backgroundColors` options do not impact the data loaded into the editor,
137
+ * i.e. they do not limit or filter the colors in the data. They are used only in the user interface
138
+ * allowing users to pick colors in a more convenient way. The `defaultProperties` option does impact the data.
139
+ * Default values will not be kept in the editor model.
140
+ *
141
+ * The default color palettes for the table background and the table border are the same
142
+ * ({@link module:table/utils/ui/table-properties#defaultColors check out their content}).
143
+ *
144
+ * Both color palette configurations must follow the
145
+ * {@link module:table/tableconfig~TableColorConfig table color configuration format}.
146
+ *
147
+ * Read more about configuring the table feature in {@link module:table/tableconfig~TableConfig}.
148
+ */
149
+ tableProperties?: TablePropertiesConfig;
150
+ /**
151
+ * The configuration of the table cell properties user interface (balloon). It allows to define:
152
+ *
153
+ * * The color palette for the cell border color style field (`tableCellProperties.borderColors`),
154
+ * * The color palette for the cell background style field (`tableCellProperties.backgroundColors`).
155
+ *
156
+ * ```ts
157
+ * const tableConfig = {
158
+ * tableCellProperties: {
159
+ * borderColors: [
160
+ * {
161
+ * color: 'hsl(0, 0%, 90%)',
162
+ * label: 'Light grey'
163
+ * },
164
+ * // ...
165
+ * ],
166
+ * backgroundColors: [
167
+ * {
168
+ * color: 'hsl(120, 75%, 60%)',
169
+ * label: 'Green'
170
+ * },
171
+ * // ...
172
+ * ]
173
+ * }
174
+ * };
175
+ * ```
176
+ *
177
+ * * The default styles for table cells (`tableCellProperties.defaultProperties`):
178
+ *
179
+ * ```ts
180
+ * const tableConfig = {
181
+ * tableCellProperties: {
182
+ * defaultProperties: {
183
+ * horizontalAlignment: 'right',
184
+ * verticalAlignment: 'bottom',
185
+ * padding: '5px'
186
+ * }
187
+ * }
188
+ * }
189
+ * ```
190
+ *
191
+ * {@link module:table/tableconfig~TablePropertiesOptions Read more about the supported properties.}
192
+ *
193
+ * **Note**: The `borderColors` and `backgroundColors` options do not impact the data loaded into the editor,
194
+ * i.e. they do not limit or filter the colors in the data. They are used only in the user interface
195
+ * allowing users to pick colors in a more convenient way. The `defaultProperties` option does impact the data.
196
+ * Default values will not be kept in the editor model.
197
+ *
198
+ * The default color palettes for the cell background and the cell border are the same
199
+ * ({@link module:table/utils/ui/table-properties#defaultColors check out their content}).
200
+ *
201
+ * Both color palette configurations must follow the
202
+ * {@link module:table/tableconfig~TableColorConfig table color configuration format}.
203
+ *
204
+ * Read more about configuring the table feature in {@link module:table/tableconfig~TableConfig}.
205
+ */
206
+ tableCellProperties?: TableCellPropertiesConfig;
207
+ }
208
+ /**
209
+ * The configuration of the table properties user interface (balloon).
210
+ */
211
+ export interface TablePropertiesConfig {
212
+ borderColors?: TableColorConfig;
213
+ backgroundColors?: TableColorConfig;
214
+ defaultProperties?: TablePropertiesOptions;
215
+ /**
216
+ * Configuration of the color picker in the table properties balloon.
217
+ *
218
+ * If set to `false` the picker will not appear.
219
+ */
220
+ colorPicker?: false | ColorPickerConfig;
221
+ }
222
+ /**
223
+ * The configuration of the table default properties feature.
224
+ */
225
+ export interface TablePropertiesOptions {
226
+ /**
227
+ * The default `width` of the table.
228
+ */
229
+ width?: string;
230
+ /**
231
+ * The default `height` of the table.
232
+ */
233
+ height?: string;
234
+ /**
235
+ * The default `background-color` of the table.
236
+ */
237
+ backgroundColor?: string;
238
+ /**
239
+ * The default `border-color` of the table.
240
+ */
241
+ borderColor?: string;
242
+ /**
243
+ * The default `border-width` of the table.
244
+ */
245
+ borderWidth?: string;
246
+ /**
247
+ * The default `border-style` of the table.
248
+ *
249
+ * @default 'none'
250
+ */
251
+ borderStyle?: string;
252
+ /**
253
+ * The default `alignment` of the table.
254
+ *
255
+ * @default 'center'
256
+ */
257
+ alignment?: string;
258
+ }
259
+ /**
260
+ * The configuration of the table cell properties user interface (balloon).
261
+ */
262
+ export interface TableCellPropertiesConfig {
263
+ borderColors?: TableColorConfig;
264
+ backgroundColors?: TableColorConfig;
265
+ defaultProperties?: TableCellPropertiesOptions;
266
+ /**
267
+ * Configuration of the color picker in the table cell properties balloon.
268
+ *
269
+ * If set to `false` the picker will not appear.
270
+ */
271
+ colorPicker?: false | ColorPickerConfig;
272
+ }
273
+ /**
274
+ * An array of color definitions (either strings or objects).
275
+ *
276
+ * ```ts
277
+ * const colors = [
278
+ * {
279
+ * color: 'hsl(0, 0%, 60%)',
280
+ * label: 'Grey'
281
+ * },
282
+ * 'hsl(0, 0%, 80%)',
283
+ * {
284
+ * color: 'hsl(0, 0%, 90%)',
285
+ * label: 'Light grey'
286
+ * },
287
+ * {
288
+ * color: 'hsl(0, 0%, 100%)',
289
+ * label: 'White',
290
+ * hasBorder: true
291
+ * },
292
+ * '#FF0000'
293
+ * ]
294
+ * ```
295
+ *
296
+ * Usually used as a configuration parameter, for instance in
297
+ * {@link module:table/tableconfig~TableConfig#tableProperties `config.table.tableProperties`}
298
+ * or {@link module:table/tableconfig~TableConfig#tableCellProperties `config.table.tableCellProperties`}.
299
+ */
300
+ export type TableColorConfig = Array<ColorOption>;
301
+ /**
302
+ * The configuration of the table cell default properties feature.
303
+ */
304
+ export interface TableCellPropertiesOptions {
305
+ /**
306
+ * The default `width` of the table cell.
307
+ */
308
+ width?: string;
309
+ /**
310
+ * The default `height` of the table cell.
311
+ */
312
+ height?: string;
313
+ /**
314
+ * The default `padding` of the table cell.
315
+ */
316
+ padding?: string;
317
+ /**
318
+ * The default `background-color` of the table cell.
319
+ */
320
+ backgroundColor?: string;
321
+ /**
322
+ * The default `border-color` of the table cell.
323
+ */
324
+ borderColor?: string;
325
+ /**
326
+ * The default `border-width` of the table cell.
327
+ */
328
+ borderWidth?: string;
329
+ /**
330
+ * The default `border-style` of the table cell.
331
+ *
332
+ * @default 'none'
333
+ */
334
+ borderStyle?: string;
335
+ /**
336
+ * The default `horizontalAlignment` of the table cell.
337
+ *
338
+ * @default 'center'
339
+ */
340
+ horizontalAlignment?: string;
341
+ /**
342
+ * The default `verticalAlignment` of the table cell.
343
+ *
344
+ * @default 'middle'
345
+ */
346
+ verticalAlignment?: string;
347
+ }
@@ -0,0 +1,102 @@
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
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
+ */
9
+ /**
10
+ * @module table/tableediting
11
+ */
12
+ import { Plugin, type Editor } from 'ckeditor5/src/core.js';
13
+ import type { PositionOffset, SlotFilter } from 'ckeditor5/src/engine.js';
14
+ import TableUtils from '../src/tableutils.js';
15
+ import '../theme/tableediting.css';
16
+ /**
17
+ * The table editing feature.
18
+ */
19
+ export default class TableEditing extends Plugin {
20
+ /**
21
+ * Handlers for creating additional slots in the table.
22
+ */
23
+ private _additionalSlots;
24
+ /**
25
+ * @inheritDoc
26
+ */
27
+ static get pluginName(): "TableEditing";
28
+ /**
29
+ * @inheritDoc
30
+ */
31
+ static get requires(): readonly [typeof TableUtils];
32
+ /**
33
+ * @inheritDoc
34
+ */
35
+ constructor(editor: Editor);
36
+ /**
37
+ * @inheritDoc
38
+ */
39
+ init(): void;
40
+ /**
41
+ * Registers downcast handler for the additional table slot.
42
+ */
43
+ registerAdditionalSlot(slotHandler: AdditionalSlot): void;
44
+ }
45
+ /**
46
+ * By default, only the `tableRow` elements from the `table` model are downcast inside the `<table>` and
47
+ * all other elements are pushed outside the table. This handler allows creating additional slots inside
48
+ * the table for other elements.
49
+ *
50
+ * Take this model as an example:
51
+ *
52
+ * ```xml
53
+ * <table>
54
+ * <tableRow>...</tableRow>
55
+ * <tableRow>...</tableRow>
56
+ * <tableColumnGroup>...</tableColumnGroup>
57
+ * </table>
58
+ * ```
59
+ *
60
+ * By default, downcasting result will be:
61
+ *
62
+ * ```xml
63
+ * <table>
64
+ * <tbody>
65
+ * <tr>...</tr>
66
+ * <tr>...</tr>
67
+ * </tbody>
68
+ * </table>
69
+ * <colgroup>...</colgroup>
70
+ * ```
71
+ *
72
+ * To allow the `tableColumnGroup` element at the end of the table, use the following configuration:
73
+ *
74
+ * ```ts
75
+ * const additionalSlot = {
76
+ * filter: element => element.is( 'element', 'tableColumnGroup' ),
77
+ * positionOffset: 'end'
78
+ * }
79
+ * ```
80
+ *
81
+ * Now, the downcast result will be:
82
+ *
83
+ * ```xml
84
+ * <table>
85
+ * <tbody>
86
+ * <tr>...</tr>
87
+ * <tr>...</tr>
88
+ * </tbody>
89
+ * <colgroup>...</colgroup>
90
+ * </table>
91
+ * ```
92
+ */
93
+ export interface AdditionalSlot {
94
+ /**
95
+ * Filter for elements that should be placed inside given slot.
96
+ */
97
+ filter: SlotFilter;
98
+ /**
99
+ * Position of the slot within the table.
100
+ */
101
+ positionOffset: PositionOffset;
102
+ }
@@ -0,0 +1,72 @@
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
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
+ */
9
+ /**
10
+ * @module table/tablekeyboard
11
+ */
12
+ import TableSelection from './tableselection.js';
13
+ import TableUtils from './tableutils.js';
14
+ import { Plugin } from 'ckeditor5/src/core.js';
15
+ import { type ArrowKeyCodeDirection } from 'ckeditor5/src/utils.js';
16
+ import type { Element } from 'ckeditor5/src/engine.js';
17
+ /**
18
+ * This plugin enables keyboard navigation for tables.
19
+ * It is loaded automatically by the {@link module:table/table~Table} plugin.
20
+ */
21
+ export default class TableKeyboard extends Plugin {
22
+ /**
23
+ * @inheritDoc
24
+ */
25
+ static get pluginName(): "TableKeyboard";
26
+ /**
27
+ * @inheritDoc
28
+ */
29
+ static get requires(): readonly [typeof TableSelection, typeof TableUtils];
30
+ /**
31
+ * @inheritDoc
32
+ */
33
+ init(): void;
34
+ /**
35
+ * Handles {@link module:engine/view/document~Document#event:tab tab} events for the <kbd>Tab</kbd> key executed
36
+ * when the table widget is selected.
37
+ */
38
+ private _handleTabOnSelectedTable;
39
+ /**
40
+ * Handles {@link module:engine/view/document~Document#event:tab tab} events for the <kbd>Tab</kbd> key executed
41
+ * inside table cells.
42
+ */
43
+ private _handleTab;
44
+ /**
45
+ * Handles {@link module:engine/view/document~Document#event:keydown keydown} events.
46
+ */
47
+ private _onArrowKey;
48
+ /**
49
+ * Handles arrow keys to move the selection around the table.
50
+ *
51
+ * @param direction The direction of the arrow key.
52
+ * @param expandSelection If the current selection should be expanded.
53
+ * @returns Returns `true` if key was handled.
54
+ */
55
+ private _handleArrowKeys;
56
+ /**
57
+ * Returns `true` if the selection is at the boundary of a table cell according to the navigation direction.
58
+ *
59
+ * @param selection The current selection.
60
+ * @param tableCell The current table cell element.
61
+ * @param isForward The expected navigation direction.
62
+ */
63
+ private _isSelectionAtCellEdge;
64
+ /**
65
+ * Moves the selection from the given table cell in the specified direction.
66
+ *
67
+ * @param focusCell The table cell that is current multi-cell selection focus.
68
+ * @param direction Direction in which selection should move.
69
+ * @param expandSelection If the current selection should be expanded. Default value is false.
70
+ */
71
+ protected _navigateFromCellInDirection(focusCell: Element, direction: ArrowKeyCodeDirection, expandSelection?: boolean): void;
72
+ }