-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
/
Copy pathtableconfig.ts
374 lines (343 loc) · 9.51 KB
/
tableconfig.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/
/**
* @module table/tableconfig
*/
import type { ToolbarConfigItem } from 'ckeditor5/src/core.js';
import type { ColorOption, ColorPickerConfig } from 'ckeditor5/src/ui.js';
/**
* The configuration of the table feature. Used by the table feature in the `@ckeditor/ckeditor5-table` package.
*
* ```ts
* ClassicEditor
* .create( editorElement, {
* table: ... // Table feature options.
* } )
* .then( ... )
* .catch( ... );
* ```
*
* See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
*/
export interface TableConfig {
/**
* Number of rows and columns to render by default as table heading when inserting new tables.
*
* You can configure it like this:
*
* ```ts
* const tableConfig = {
* defaultHeadings: {
* rows: 1,
* columns: 1
* }
* };
* ```
*
* Both rows and columns properties are optional defaulting to 0 (no heading).
*/
defaultHeadings?: {
rows?: number;
columns?: number;
};
/**
* Items to be placed in the table content toolbar.
* The {@link module:table/tabletoolbar~TableToolbar} plugin is required to make this toolbar work.
*
* Assuming that you use the {@link module:table/tableui~TableUI} feature, the following toolbar items will be available
* in {@link module:ui/componentfactory~ComponentFactory}:
*
* * `'tableRow'`,
* * `'tableColumn'`,
* * `'mergeTableCells'`.
*
* You can thus configure the toolbar like this:
*
* ```ts
* const tableConfig = {
* contentToolbar: [ 'tableRow', 'tableColumn', 'mergeTableCells' ]
* };
* ```
*
* Of course, the same buttons can also be used in the
* {@link module:core/editor/editorconfig~EditorConfig#toolbar main editor toolbar}.
*
* Read more about configuring the toolbar in {@link module:core/editor/editorconfig~EditorConfig#toolbar}.
*/
contentToolbar?: Array<ToolbarConfigItem>;
/**
* Items to be placed in the table toolbar.
* The {@link module:table/tabletoolbar~TableToolbar} plugin is required to make this toolbar work.
*
* You can thus configure the toolbar like this:
*
* ```ts
* const tableConfig = {
* tableToolbar: [ 'blockQuote' ]
* };
* ```
*
* Of course, the same buttons can also be used in the
* {@link module:core/editor/editorconfig~EditorConfig#toolbar main editor toolbar}.
*
* Read more about configuring the toolbar in {@link module:core/editor/editorconfig~EditorConfig#toolbar}.
*/
tableToolbar?: Array<ToolbarConfigItem>;
/**
* The configuration of the table properties user interface (balloon). It allows to define:
*
* * The color palette for the table border color style field (`tableProperties.borderColors`),
* * The color palette for the table background style field (`tableProperties.backgroundColors`).
*
* ```ts
* const tableConfig = {
* tableProperties: {
* borderColors: [
* {
* color: 'hsl(0, 0%, 90%)',
* label: 'Light grey'
* },
* // ...
* ],
* backgroundColors: [
* {
* color: 'hsl(120, 75%, 60%)',
* label: 'Green'
* },
* // ...
* ]
* }
* };
* ```
*
* * The default styles for tables (`tableProperties.defaultProperties`):
*
* ```
* const tableConfig = {
* tableProperties: {
* defaultProperties: {
* borderStyle: 'dashed',
* borderColor: 'hsl(0, 0%, 90%)',
* borderWidth: '3px',
* alignment: 'left'
* }
* }
* }
* ```
*
* {@link module:table/tableconfig~TablePropertiesOptions Read more about the supported properties.}
*
* **Note**: The `borderColors` and `backgroundColors` options do not impact the data loaded into the editor,
* i.e. they do not limit or filter the colors in the data. They are used only in the user interface
* allowing users to pick colors in a more convenient way. The `defaultProperties` option does impact the data.
* Default values will not be kept in the editor model.
*
* The default color palettes for the table background and the table border are the same
* ({@link module:table/utils/ui/table-properties#defaultColors check out their content}).
*
* Both color palette configurations must follow the
* {@link module:table/tableconfig~TableColorConfig table color configuration format}.
*
* Read more about configuring the table feature in {@link module:table/tableconfig~TableConfig}.
*/
tableProperties?: TablePropertiesConfig;
/**
* The configuration of the table cell properties user interface (balloon). It allows to define:
*
* * The color palette for the cell border color style field (`tableCellProperties.borderColors`),
* * The color palette for the cell background style field (`tableCellProperties.backgroundColors`).
*
* ```ts
* const tableConfig = {
* tableCellProperties: {
* borderColors: [
* {
* color: 'hsl(0, 0%, 90%)',
* label: 'Light grey'
* },
* // ...
* ],
* backgroundColors: [
* {
* color: 'hsl(120, 75%, 60%)',
* label: 'Green'
* },
* // ...
* ]
* }
* };
* ```
*
* * The default styles for table cells (`tableCellProperties.defaultProperties`):
*
* ```ts
* const tableConfig = {
* tableCellProperties: {
* defaultProperties: {
* horizontalAlignment: 'right',
* verticalAlignment: 'bottom',
* padding: '5px'
* }
* }
* }
* ```
*
* {@link module:table/tableconfig~TablePropertiesOptions Read more about the supported properties.}
*
* **Note**: The `borderColors` and `backgroundColors` options do not impact the data loaded into the editor,
* i.e. they do not limit or filter the colors in the data. They are used only in the user interface
* allowing users to pick colors in a more convenient way. The `defaultProperties` option does impact the data.
* Default values will not be kept in the editor model.
*
* The default color palettes for the cell background and the cell border are the same
* ({@link module:table/utils/ui/table-properties#defaultColors check out their content}).
*
* Both color palette configurations must follow the
* {@link module:table/tableconfig~TableColorConfig table color configuration format}.
*
* Read more about configuring the table feature in {@link module:table/tableconfig~TableConfig}.
*/
tableCellProperties?: TableCellPropertiesConfig;
}
/**
* The configuration of the table properties user interface (balloon).
*/
export interface TablePropertiesConfig {
borderColors?: TableColorConfig;
backgroundColors?: TableColorConfig;
defaultProperties?: TablePropertiesOptions;
/**
* Configuration of the color picker in the table properties balloon.
*
* If set to `false` the picker will not appear.
*/
colorPicker?: false | ColorPickerConfig;
}
/**
* The configuration of the table default properties feature.
*/
export interface TablePropertiesOptions {
/**
* The default `width` of the table.
*/
width?: string;
/**
* The default `height` of the table.
*/
height?: string;
/**
* The default `background-color` of the table.
*/
backgroundColor?: string;
/**
* The default `border-color` of the table.
*/
borderColor?: string;
/**
* The default `border-width` of the table.
*/
borderWidth?: string;
/**
* The default `border-style` of the table.
*
* @default 'none'
*/
borderStyle?: string;
/**
* The default `alignment` of the table.
*
* @default 'center'
*/
alignment?: string;
}
/**
* The configuration of the table cell properties user interface (balloon).
*/
export interface TableCellPropertiesConfig {
borderColors?: TableColorConfig;
backgroundColors?: TableColorConfig;
defaultProperties?: TableCellPropertiesOptions;
/**
* Configuration of the color picker in the table cell properties balloon.
*
* If set to `false` the picker will not appear.
*/
colorPicker?: false | ColorPickerConfig;
}
/**
* An array of color definitions (either strings or objects).
*
* ```ts
* const colors = [
* {
* color: 'hsl(0, 0%, 60%)',
* label: 'Grey'
* },
* 'hsl(0, 0%, 80%)',
* {
* color: 'hsl(0, 0%, 90%)',
* label: 'Light grey'
* },
* {
* color: 'hsl(0, 0%, 100%)',
* label: 'White',
* hasBorder: true
* },
* '#FF0000'
* ]
* ```
*
* Usually used as a configuration parameter, for instance in
* {@link module:table/tableconfig~TableConfig#tableProperties `config.table.tableProperties`}
* or {@link module:table/tableconfig~TableConfig#tableCellProperties `config.table.tableCellProperties`}.
*/
export type TableColorConfig = Array<ColorOption>;
/**
* The configuration of the table cell default properties feature.
*/
export interface TableCellPropertiesOptions {
/**
* The default `width` of the table cell.
*/
width?: string;
/**
* The default `height` of the table cell.
*/
height?: string;
/**
* The default `padding` of the table cell.
*/
padding?: string;
/**
* The default `background-color` of the table cell.
*/
backgroundColor?: string;
/**
* The default `border-color` of the table cell.
*/
borderColor?: string;
/**
* The default `border-width` of the table cell.
*/
borderWidth?: string;
/**
* The default `border-style` of the table cell.
*
* @default 'none'
*/
borderStyle?: string;
/**
* The default `horizontalAlignment` of the table cell.
*
* @default 'center'
*/
horizontalAlignment?: string;
/**
* The default `verticalAlignment` of the table cell.
*
* @default 'middle'
*/
verticalAlignment?: string;
}