@ckeditor/ckeditor5-table 36.0.1 → 37.0.0-alpha.1
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/README.md +1 -1
- package/build/table.js +1 -1
- package/ckeditor5-metadata.json +6 -6
- package/package.json +34 -29
- package/src/augmentation.d.ts +76 -0
- package/src/augmentation.js +5 -0
- package/src/commands/insertcolumncommand.d.ts +55 -0
- package/src/commands/insertcolumncommand.js +45 -60
- package/src/commands/insertrowcommand.d.ts +54 -0
- package/src/commands/insertrowcommand.js +44 -59
- package/src/commands/inserttablecommand.d.ts +44 -0
- package/src/commands/inserttablecommand.js +50 -68
- package/src/commands/mergecellcommand.d.ts +68 -0
- package/src/commands/mergecellcommand.js +169 -244
- package/src/commands/mergecellscommand.d.ts +28 -0
- package/src/commands/mergecellscommand.js +72 -101
- package/src/commands/removecolumncommand.d.ts +29 -0
- package/src/commands/removecolumncommand.js +88 -102
- package/src/commands/removerowcommand.d.ts +29 -0
- package/src/commands/removerowcommand.js +63 -80
- package/src/commands/selectcolumncommand.d.ts +33 -0
- package/src/commands/selectcolumncommand.js +41 -54
- package/src/commands/selectrowcommand.d.ts +33 -0
- package/src/commands/selectrowcommand.js +38 -48
- package/src/commands/setheadercolumncommand.d.ts +50 -0
- package/src/commands/setheadercolumncommand.js +48 -73
- package/src/commands/setheaderrowcommand.d.ts +53 -0
- package/src/commands/setheaderrowcommand.js +56 -85
- package/src/commands/splitcellcommand.d.ts +43 -0
- package/src/commands/splitcellcommand.js +35 -49
- package/src/converters/downcast.d.ts +63 -0
- package/src/converters/downcast.js +98 -130
- package/src/converters/table-caption-post-fixer.d.ts +20 -0
- package/src/converters/table-caption-post-fixer.js +36 -52
- package/src/converters/table-cell-paragraph-post-fixer.d.ts +32 -0
- package/src/converters/table-cell-paragraph-post-fixer.js +88 -119
- package/src/converters/table-cell-refresh-handler.d.ts +18 -0
- package/src/converters/table-cell-refresh-handler.js +29 -48
- package/src/converters/table-headings-refresh-handler.d.ts +17 -0
- package/src/converters/table-headings-refresh-handler.js +35 -54
- package/src/converters/table-layout-post-fixer.d.ts +226 -0
- package/src/converters/table-layout-post-fixer.js +276 -313
- package/src/converters/tableproperties.d.ts +54 -0
- package/src/converters/tableproperties.js +136 -168
- package/src/converters/upcasttable.d.ts +49 -0
- package/src/converters/upcasttable.js +199 -251
- package/src/index.d.ts +60 -0
- package/src/index.js +1 -2
- package/src/plaintableoutput.d.ts +25 -0
- package/src/plaintableoutput.js +107 -135
- package/src/table.d.ts +33 -0
- package/src/table.js +12 -88
- package/src/tablecaption/tablecaptionediting.d.ts +63 -0
- package/src/tablecaption/tablecaptionediting.js +104 -135
- package/src/tablecaption/tablecaptionui.d.ts +21 -0
- package/src/tablecaption/tablecaptionui.js +42 -58
- package/src/tablecaption/toggletablecaptioncommand.d.ts +68 -0
- package/src/tablecaption/toggletablecaptioncommand.js +77 -92
- package/src/tablecaption/utils.d.ts +42 -0
- package/src/tablecaption/utils.js +35 -61
- package/src/tablecaption.d.ts +22 -0
- package/src/tablecaption.js +12 -19
- package/src/tablecellproperties/commands/tablecellbackgroundcolorcommand.d.ts +32 -0
- package/src/tablecellproperties/commands/tablecellbackgroundcolorcommand.js +14 -20
- package/src/tablecellproperties/commands/tablecellbordercolorcommand.d.ts +37 -0
- package/src/tablecellproperties/commands/tablecellbordercolorcommand.js +27 -37
- package/src/tablecellproperties/commands/tablecellborderstylecommand.d.ts +37 -0
- package/src/tablecellproperties/commands/tablecellborderstylecommand.js +27 -37
- package/src/tablecellproperties/commands/tablecellborderwidthcommand.d.ts +51 -0
- package/src/tablecellproperties/commands/tablecellborderwidthcommand.js +42 -53
- package/src/tablecellproperties/commands/tablecellheightcommand.d.ts +46 -0
- package/src/tablecellproperties/commands/tablecellheightcommand.js +29 -36
- package/src/tablecellproperties/commands/tablecellhorizontalalignmentcommand.d.ts +32 -0
- package/src/tablecellproperties/commands/tablecellhorizontalalignmentcommand.js +14 -20
- package/src/tablecellproperties/commands/tablecellpaddingcommand.d.ts +51 -0
- package/src/tablecellproperties/commands/tablecellpaddingcommand.js +42 -53
- package/src/tablecellproperties/commands/tablecellpropertycommand.d.ts +62 -0
- package/src/tablecellproperties/commands/tablecellpropertycommand.js +77 -122
- package/src/tablecellproperties/commands/tablecellverticalalignmentcommand.d.ts +40 -0
- package/src/tablecellproperties/commands/tablecellverticalalignmentcommand.js +14 -20
- package/src/tablecellproperties/tablecellpropertiesediting.d.ts +41 -0
- package/src/tablecellproperties/tablecellpropertiesediting.js +193 -236
- package/src/tablecellproperties/tablecellpropertiesui.d.ts +111 -0
- package/src/tablecellproperties/tablecellpropertiesui.js +302 -456
- package/src/tablecellproperties/ui/tablecellpropertiesview.d.ts +227 -0
- package/src/tablecellproperties/ui/tablecellpropertiesview.js +509 -844
- package/src/tablecellproperties.d.ts +28 -0
- package/src/tablecellproperties.js +12 -98
- package/src/tablecellwidth/commands/tablecellwidthcommand.d.ts +46 -0
- package/src/tablecellwidth/commands/tablecellwidthcommand.js +29 -35
- package/src/tablecellwidth/tablecellwidthediting.d.ts +28 -0
- package/src/tablecellwidth/tablecellwidthediting.js +25 -38
- package/src/tableclipboard.d.ts +63 -0
- package/src/tableclipboard.js +429 -568
- package/src/tablecolumnresize/constants.d.ts +20 -0
- package/src/tablecolumnresize/constants.js +0 -10
- package/src/tablecolumnresize/converters.d.ts +18 -0
- package/src/tablecolumnresize/converters.js +35 -119
- package/src/tablecolumnresize/tablecolumnresizeediting.d.ts +137 -0
- package/src/tablecolumnresize/tablecolumnresizeediting.js +545 -711
- package/src/tablecolumnresize/tablewidthscommand.d.ts +38 -0
- package/src/tablecolumnresize/tablewidthscommand.js +61 -0
- package/src/tablecolumnresize/utils.d.ts +141 -0
- package/src/tablecolumnresize/utils.js +256 -233
- package/src/tablecolumnresize.d.ts +24 -0
- package/src/tablecolumnresize.js +12 -19
- package/src/tableconfig.d.ts +331 -0
- package/src/tableconfig.js +5 -0
- package/src/tableediting.d.ts +97 -0
- package/src/tableediting.js +157 -176
- package/src/tablekeyboard.d.ts +63 -0
- package/src/tablekeyboard.js +261 -344
- package/src/tablemouse/mouseeventsobserver.d.ts +62 -0
- package/src/tablemouse/mouseeventsobserver.js +13 -50
- package/src/tablemouse.d.ts +46 -0
- package/src/tablemouse.js +154 -202
- package/src/tableproperties/commands/tablealignmentcommand.d.ts +32 -0
- package/src/tableproperties/commands/tablealignmentcommand.js +14 -20
- package/src/tableproperties/commands/tablebackgroundcolorcommand.d.ts +32 -0
- package/src/tableproperties/commands/tablebackgroundcolorcommand.js +14 -20
- package/src/tableproperties/commands/tablebordercolorcommand.d.ts +37 -0
- package/src/tableproperties/commands/tablebordercolorcommand.js +27 -37
- package/src/tableproperties/commands/tableborderstylecommand.d.ts +37 -0
- package/src/tableproperties/commands/tableborderstylecommand.js +27 -37
- package/src/tableproperties/commands/tableborderwidthcommand.d.ts +51 -0
- package/src/tableproperties/commands/tableborderwidthcommand.js +42 -53
- package/src/tableproperties/commands/tableheightcommand.d.ts +46 -0
- package/src/tableproperties/commands/tableheightcommand.js +29 -33
- package/src/tableproperties/commands/tablepropertycommand.d.ts +61 -0
- package/src/tableproperties/commands/tablepropertycommand.js +68 -112
- package/src/tableproperties/commands/tablewidthcommand.d.ts +46 -0
- package/src/tableproperties/commands/tablewidthcommand.js +29 -33
- package/src/tableproperties/tablepropertiesediting.d.ts +39 -0
- package/src/tableproperties/tablepropertiesediting.js +163 -210
- package/src/tableproperties/tablepropertiesui.d.ts +113 -0
- package/src/tableproperties/tablepropertiesui.js +293 -439
- package/src/tableproperties/ui/tablepropertiesview.d.ts +203 -0
- package/src/tableproperties/ui/tablepropertiesview.js +427 -718
- package/src/tableproperties.d.ts +28 -0
- package/src/tableproperties.js +12 -95
- package/src/tableselection.d.ts +106 -0
- package/src/tableselection.js +279 -376
- package/src/tabletoolbar.d.ts +31 -0
- package/src/tabletoolbar.js +38 -92
- package/src/tableui.d.ts +53 -0
- package/src/tableui.js +281 -338
- package/src/tableutils.d.ts +448 -0
- package/src/tableutils.js +1015 -1229
- package/src/tablewalker.d.ts +323 -0
- package/src/tablewalker.js +308 -548
- package/src/ui/colorinputview.d.ts +143 -0
- package/src/ui/colorinputview.js +229 -366
- package/src/ui/formrowview.d.ts +61 -0
- package/src/ui/formrowview.js +38 -84
- package/src/ui/inserttableview.d.ts +77 -0
- package/src/ui/inserttableview.js +152 -242
- package/src/utils/common.d.ts +42 -0
- package/src/utils/common.js +33 -57
- package/src/utils/structure.d.ts +245 -0
- package/src/utils/structure.js +261 -379
- package/src/utils/table-properties.d.ts +67 -0
- package/src/utils/table-properties.js +60 -81
- package/src/utils/ui/contextualballoon.d.ts +34 -0
- package/src/utils/ui/contextualballoon.js +70 -89
- package/src/utils/ui/table-properties.d.ts +193 -0
- package/src/utils/ui/table-properties.js +259 -319
- package/src/utils/ui/widget.d.ts +16 -0
- package/src/utils/ui/widget.js +24 -46
- package/src/tablecolumnresize/tablecolumnwidthscommand.js +0 -55
- package/src/tablecolumnresize/tablewidthresizecommand.js +0 -65
|
@@ -2,739 +2,448 @@
|
|
|
2
2
|
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
5
|
/**
|
|
7
6
|
* @module table/tableproperties/ui/tablepropertiesview
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
|
-
import {
|
|
11
|
-
ButtonView,
|
|
12
|
-
FocusCycler,
|
|
13
|
-
FormHeaderView,
|
|
14
|
-
LabelView,
|
|
15
|
-
LabeledFieldView,
|
|
16
|
-
ToolbarView,
|
|
17
|
-
View,
|
|
18
|
-
ViewCollection,
|
|
19
|
-
addListToDropdown,
|
|
20
|
-
createLabeledDropdown,
|
|
21
|
-
createLabeledInputText,
|
|
22
|
-
submitHandler
|
|
23
|
-
} from 'ckeditor5/src/ui';
|
|
8
|
+
import { addListToDropdown, ButtonView, createLabeledDropdown, createLabeledInputText, FocusCycler, FormHeaderView, LabeledFieldView, LabelView, submitHandler, ToolbarView, View, ViewCollection } from 'ckeditor5/src/ui';
|
|
24
9
|
import { FocusTracker, KeystrokeHandler } from 'ckeditor5/src/utils';
|
|
25
10
|
import { icons } from 'ckeditor5/src/core';
|
|
26
|
-
|
|
27
|
-
import {
|
|
28
|
-
fillToolbar,
|
|
29
|
-
getBorderStyleDefinitions,
|
|
30
|
-
getBorderStyleLabels,
|
|
31
|
-
getLabeledColorInputCreator
|
|
32
|
-
} from '../../utils/ui/table-properties';
|
|
11
|
+
import { fillToolbar, getBorderStyleDefinitions, getBorderStyleLabels, getLabeledColorInputCreator } from '../../utils/ui/table-properties';
|
|
33
12
|
import FormRowView from '../../ui/formrowview';
|
|
34
|
-
|
|
35
13
|
import '../../../theme/form.css';
|
|
36
14
|
import '../../../theme/tableform.css';
|
|
37
15
|
import '../../../theme/tableproperties.css';
|
|
38
|
-
|
|
39
16
|
const ALIGNMENT_ICONS = {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
17
|
+
left: icons.objectLeft,
|
|
18
|
+
center: icons.objectCenter,
|
|
19
|
+
right: icons.objectRight
|
|
43
20
|
};
|
|
44
|
-
|
|
45
21
|
/**
|
|
46
22
|
* The class representing a table properties form, allowing users to customize
|
|
47
23
|
* certain style aspects of a table, for instance, border, background color, alignment, etc..
|
|
48
|
-
*
|
|
49
|
-
* @extends module:ui/view~View
|
|
50
24
|
*/
|
|
51
25
|
export default class TablePropertiesView extends View {
|
|
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
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
} );
|
|
473
|
-
|
|
474
|
-
// -- Color ---------------------------------------------------
|
|
475
|
-
|
|
476
|
-
const borderColorInput = new LabeledFieldView( locale, colorInputCreator );
|
|
477
|
-
|
|
478
|
-
borderColorInput.set( {
|
|
479
|
-
label: t( 'Color' ),
|
|
480
|
-
class: 'ck-table-form__border-color'
|
|
481
|
-
} );
|
|
482
|
-
|
|
483
|
-
borderColorInput.fieldView.bind( 'value' ).to( this, 'borderColor' );
|
|
484
|
-
borderColorInput.bind( 'isEnabled' ).to( this, 'borderStyle', isBorderStyleSet );
|
|
485
|
-
|
|
486
|
-
borderColorInput.fieldView.on( 'input', () => {
|
|
487
|
-
this.borderColor = borderColorInput.fieldView.value;
|
|
488
|
-
} );
|
|
489
|
-
|
|
490
|
-
// Reset the border color and width fields depending on the `border-style` value.
|
|
491
|
-
this.on( 'change:borderStyle', ( evt, name, newValue, oldValue ) => {
|
|
492
|
-
// When removing the border (`border-style:none`), clear the remaining `border-*` properties.
|
|
493
|
-
// See: https://github.com/ckeditor/ckeditor5/issues/6227.
|
|
494
|
-
if ( !isBorderStyleSet( newValue ) ) {
|
|
495
|
-
this.borderColor = '';
|
|
496
|
-
this.borderWidth = '';
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
// When setting the `border-style` from `none`, set the default `border-color` and `border-width` properties.
|
|
500
|
-
if ( !isBorderStyleSet( oldValue ) ) {
|
|
501
|
-
this.borderColor = defaultBorder.color;
|
|
502
|
-
this.borderWidth = defaultBorder.width;
|
|
503
|
-
}
|
|
504
|
-
} );
|
|
505
|
-
|
|
506
|
-
return {
|
|
507
|
-
borderRowLabel,
|
|
508
|
-
borderStyleDropdown,
|
|
509
|
-
borderColorInput,
|
|
510
|
-
borderWidthInput
|
|
511
|
-
};
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
/**
|
|
515
|
-
* Creates the following form fields:
|
|
516
|
-
*
|
|
517
|
-
* * {@link #backgroundInput}.
|
|
518
|
-
*
|
|
519
|
-
* @private
|
|
520
|
-
* @returns {Object.<String,module:ui/view~View>}
|
|
521
|
-
*/
|
|
522
|
-
_createBackgroundFields() {
|
|
523
|
-
const locale = this.locale;
|
|
524
|
-
const t = this.t;
|
|
525
|
-
|
|
526
|
-
// -- Group label ---------------------------------------------
|
|
527
|
-
|
|
528
|
-
const backgroundRowLabel = new LabelView( locale );
|
|
529
|
-
backgroundRowLabel.text = t( 'Background' );
|
|
530
|
-
|
|
531
|
-
// -- Background color input -----------------------------------
|
|
532
|
-
|
|
533
|
-
const backgroundInputCreator = getLabeledColorInputCreator( {
|
|
534
|
-
colorConfig: this.options.backgroundColors,
|
|
535
|
-
columns: 5,
|
|
536
|
-
defaultColorValue: this.options.defaultTableProperties.backgroundColor
|
|
537
|
-
} );
|
|
538
|
-
|
|
539
|
-
const backgroundInput = new LabeledFieldView( locale, backgroundInputCreator );
|
|
540
|
-
|
|
541
|
-
backgroundInput.set( {
|
|
542
|
-
label: t( 'Color' ),
|
|
543
|
-
class: 'ck-table-properties-form__background'
|
|
544
|
-
} );
|
|
545
|
-
|
|
546
|
-
backgroundInput.fieldView.bind( 'value' ).to( this, 'backgroundColor' );
|
|
547
|
-
backgroundInput.fieldView.on( 'input', () => {
|
|
548
|
-
this.backgroundColor = backgroundInput.fieldView.value;
|
|
549
|
-
} );
|
|
550
|
-
|
|
551
|
-
return {
|
|
552
|
-
backgroundRowLabel,
|
|
553
|
-
backgroundInput
|
|
554
|
-
};
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
/**
|
|
558
|
-
* Creates the following form fields:
|
|
559
|
-
*
|
|
560
|
-
* * {@link #widthInput}.
|
|
561
|
-
* * {@link #heightInput}.
|
|
562
|
-
*
|
|
563
|
-
* @private
|
|
564
|
-
* @returns {module:ui/labeledfield/labeledfieldview~LabeledFieldView}
|
|
565
|
-
*/
|
|
566
|
-
_createDimensionFields() {
|
|
567
|
-
const locale = this.locale;
|
|
568
|
-
const t = this.t;
|
|
569
|
-
|
|
570
|
-
// -- Label ---------------------------------------------------
|
|
571
|
-
|
|
572
|
-
const dimensionsLabel = new LabelView( locale );
|
|
573
|
-
dimensionsLabel.text = t( 'Dimensions' );
|
|
574
|
-
|
|
575
|
-
// -- Width ---------------------------------------------------
|
|
576
|
-
|
|
577
|
-
const widthInput = new LabeledFieldView( locale, createLabeledInputText );
|
|
578
|
-
|
|
579
|
-
widthInput.set( {
|
|
580
|
-
label: t( 'Width' ),
|
|
581
|
-
class: 'ck-table-form__dimensions-row__width'
|
|
582
|
-
} );
|
|
583
|
-
|
|
584
|
-
widthInput.fieldView.bind( 'value' ).to( this, 'width' );
|
|
585
|
-
widthInput.fieldView.on( 'input', () => {
|
|
586
|
-
this.width = widthInput.fieldView.element.value;
|
|
587
|
-
} );
|
|
588
|
-
|
|
589
|
-
// -- Operator ---------------------------------------------------
|
|
590
|
-
|
|
591
|
-
const operatorLabel = new View( locale );
|
|
592
|
-
operatorLabel.setTemplate( {
|
|
593
|
-
tag: 'span',
|
|
594
|
-
attributes: {
|
|
595
|
-
class: [
|
|
596
|
-
'ck-table-form__dimension-operator'
|
|
597
|
-
]
|
|
598
|
-
},
|
|
599
|
-
children: [
|
|
600
|
-
{ text: '×' }
|
|
601
|
-
]
|
|
602
|
-
} );
|
|
603
|
-
|
|
604
|
-
// -- Height ---------------------------------------------------
|
|
605
|
-
|
|
606
|
-
const heightInput = new LabeledFieldView( locale, createLabeledInputText );
|
|
607
|
-
|
|
608
|
-
heightInput.set( {
|
|
609
|
-
label: t( 'Height' ),
|
|
610
|
-
class: 'ck-table-form__dimensions-row__height'
|
|
611
|
-
} );
|
|
612
|
-
|
|
613
|
-
heightInput.fieldView.bind( 'value' ).to( this, 'height' );
|
|
614
|
-
heightInput.fieldView.on( 'input', () => {
|
|
615
|
-
this.height = heightInput.fieldView.element.value;
|
|
616
|
-
} );
|
|
617
|
-
|
|
618
|
-
return {
|
|
619
|
-
dimensionsLabel,
|
|
620
|
-
widthInput,
|
|
621
|
-
operatorLabel,
|
|
622
|
-
heightInput
|
|
623
|
-
};
|
|
624
|
-
}
|
|
625
|
-
|
|
626
|
-
/**
|
|
627
|
-
* Creates the following form fields:
|
|
628
|
-
*
|
|
629
|
-
* * {@link #alignmentToolbar},
|
|
630
|
-
*
|
|
631
|
-
* @private
|
|
632
|
-
* @returns {Object.<String,module:ui/view~View>}
|
|
633
|
-
*/
|
|
634
|
-
_createAlignmentFields() {
|
|
635
|
-
const locale = this.locale;
|
|
636
|
-
const t = this.t;
|
|
637
|
-
|
|
638
|
-
// -- Label ---------------------------------------------------
|
|
639
|
-
|
|
640
|
-
const alignmentLabel = new LabelView( locale );
|
|
641
|
-
alignmentLabel.text = t( 'Alignment' );
|
|
642
|
-
|
|
643
|
-
// -- Toolbar ---------------------------------------------------
|
|
644
|
-
|
|
645
|
-
const alignmentToolbar = new ToolbarView( locale );
|
|
646
|
-
alignmentToolbar.set( {
|
|
647
|
-
isCompact: true,
|
|
648
|
-
ariaLabel: t( 'Table alignment toolbar' )
|
|
649
|
-
} );
|
|
650
|
-
|
|
651
|
-
fillToolbar( {
|
|
652
|
-
view: this,
|
|
653
|
-
icons: ALIGNMENT_ICONS,
|
|
654
|
-
toolbar: alignmentToolbar,
|
|
655
|
-
labels: this._alignmentLabels,
|
|
656
|
-
propertyName: 'alignment',
|
|
657
|
-
defaultValue: this.options.defaultTableProperties.alignment
|
|
658
|
-
} );
|
|
659
|
-
|
|
660
|
-
return {
|
|
661
|
-
alignmentLabel,
|
|
662
|
-
alignmentToolbar
|
|
663
|
-
};
|
|
664
|
-
}
|
|
665
|
-
|
|
666
|
-
/**
|
|
667
|
-
* Creates the following form controls:
|
|
668
|
-
*
|
|
669
|
-
* * {@link #saveButtonView},
|
|
670
|
-
* * {@link #cancelButtonView}.
|
|
671
|
-
*
|
|
672
|
-
* @private
|
|
673
|
-
* @returns {Object.<String,module:ui/view~View>}
|
|
674
|
-
*/
|
|
675
|
-
_createActionButtons() {
|
|
676
|
-
const locale = this.locale;
|
|
677
|
-
const t = this.t;
|
|
678
|
-
|
|
679
|
-
const saveButtonView = new ButtonView( locale );
|
|
680
|
-
const cancelButtonView = new ButtonView( locale );
|
|
681
|
-
const fieldsThatShouldValidateToSave = [
|
|
682
|
-
this.borderWidthInput,
|
|
683
|
-
this.borderColorInput,
|
|
684
|
-
this.backgroundInput,
|
|
685
|
-
this.widthInput,
|
|
686
|
-
this.heightInput
|
|
687
|
-
];
|
|
688
|
-
|
|
689
|
-
saveButtonView.set( {
|
|
690
|
-
label: t( 'Save' ),
|
|
691
|
-
icon: icons.check,
|
|
692
|
-
class: 'ck-button-save',
|
|
693
|
-
type: 'submit',
|
|
694
|
-
withText: true
|
|
695
|
-
} );
|
|
696
|
-
|
|
697
|
-
saveButtonView.bind( 'isEnabled' ).toMany( fieldsThatShouldValidateToSave, 'errorText', ( ...errorTexts ) => {
|
|
698
|
-
return errorTexts.every( errorText => !errorText );
|
|
699
|
-
} );
|
|
700
|
-
|
|
701
|
-
cancelButtonView.set( {
|
|
702
|
-
label: t( 'Cancel' ),
|
|
703
|
-
icon: icons.cancel,
|
|
704
|
-
class: 'ck-button-cancel',
|
|
705
|
-
withText: true
|
|
706
|
-
} );
|
|
707
|
-
|
|
708
|
-
cancelButtonView.delegate( 'execute' ).to( this, 'cancel' );
|
|
709
|
-
|
|
710
|
-
return {
|
|
711
|
-
saveButtonView, cancelButtonView
|
|
712
|
-
};
|
|
713
|
-
}
|
|
714
|
-
|
|
715
|
-
/**
|
|
716
|
-
* Provides localized labels for {@link #alignmentToolbar} buttons.
|
|
717
|
-
*
|
|
718
|
-
* @private
|
|
719
|
-
* @type {Object.<String,String>}
|
|
720
|
-
*/
|
|
721
|
-
get _alignmentLabels() {
|
|
722
|
-
const locale = this.locale;
|
|
723
|
-
const t = this.t;
|
|
724
|
-
|
|
725
|
-
const left = t( 'Align table to the left' );
|
|
726
|
-
const center = t( 'Center table' );
|
|
727
|
-
const right = t( 'Align table to the right' );
|
|
728
|
-
|
|
729
|
-
// Returns object with a proper order of labels.
|
|
730
|
-
if ( locale.uiLanguageDirection === 'rtl' ) {
|
|
731
|
-
return { right, center, left };
|
|
732
|
-
} else {
|
|
733
|
-
return { left, center, right };
|
|
734
|
-
}
|
|
735
|
-
}
|
|
26
|
+
/**
|
|
27
|
+
* @param locale The {@link module:core/editor/editor~Editor#locale} instance.
|
|
28
|
+
* @param options Additional configuration of the view.
|
|
29
|
+
*/
|
|
30
|
+
constructor(locale, options) {
|
|
31
|
+
super(locale);
|
|
32
|
+
this.set({
|
|
33
|
+
borderStyle: '',
|
|
34
|
+
borderWidth: '',
|
|
35
|
+
borderColor: '',
|
|
36
|
+
backgroundColor: '',
|
|
37
|
+
width: '',
|
|
38
|
+
height: '',
|
|
39
|
+
alignment: ''
|
|
40
|
+
});
|
|
41
|
+
this.options = options;
|
|
42
|
+
const { borderStyleDropdown, borderWidthInput, borderColorInput, borderRowLabel } = this._createBorderFields();
|
|
43
|
+
const { backgroundRowLabel, backgroundInput } = this._createBackgroundFields();
|
|
44
|
+
const { widthInput, operatorLabel, heightInput, dimensionsLabel } = this._createDimensionFields();
|
|
45
|
+
const { alignmentToolbar, alignmentLabel } = this._createAlignmentFields();
|
|
46
|
+
this.focusTracker = new FocusTracker();
|
|
47
|
+
this.keystrokes = new KeystrokeHandler();
|
|
48
|
+
this.children = this.createCollection();
|
|
49
|
+
this.borderStyleDropdown = borderStyleDropdown;
|
|
50
|
+
this.borderWidthInput = borderWidthInput;
|
|
51
|
+
this.borderColorInput = borderColorInput;
|
|
52
|
+
this.backgroundInput = backgroundInput;
|
|
53
|
+
this.widthInput = widthInput;
|
|
54
|
+
this.heightInput = heightInput;
|
|
55
|
+
this.alignmentToolbar = alignmentToolbar;
|
|
56
|
+
// Defer creating to make sure other fields are present and the Save button can
|
|
57
|
+
// bind its #isEnabled to their error messages so there's no way to save unless all
|
|
58
|
+
// fields are valid.
|
|
59
|
+
const { saveButtonView, cancelButtonView } = this._createActionButtons();
|
|
60
|
+
this.saveButtonView = saveButtonView;
|
|
61
|
+
this.cancelButtonView = cancelButtonView;
|
|
62
|
+
this._focusables = new ViewCollection();
|
|
63
|
+
this._focusCycler = new FocusCycler({
|
|
64
|
+
focusables: this._focusables,
|
|
65
|
+
focusTracker: this.focusTracker,
|
|
66
|
+
keystrokeHandler: this.keystrokes,
|
|
67
|
+
actions: {
|
|
68
|
+
// Navigate form fields backwards using the Shift + Tab keystroke.
|
|
69
|
+
focusPrevious: 'shift + tab',
|
|
70
|
+
// Navigate form fields forwards using the Tab key.
|
|
71
|
+
focusNext: 'tab'
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
// Form header.
|
|
75
|
+
this.children.add(new FormHeaderView(locale, {
|
|
76
|
+
label: this.t('Table properties')
|
|
77
|
+
}));
|
|
78
|
+
// Border row.
|
|
79
|
+
this.children.add(new FormRowView(locale, {
|
|
80
|
+
labelView: borderRowLabel,
|
|
81
|
+
children: [
|
|
82
|
+
borderRowLabel,
|
|
83
|
+
borderStyleDropdown,
|
|
84
|
+
borderColorInput,
|
|
85
|
+
borderWidthInput
|
|
86
|
+
],
|
|
87
|
+
class: 'ck-table-form__border-row'
|
|
88
|
+
}));
|
|
89
|
+
// Background row.
|
|
90
|
+
this.children.add(new FormRowView(locale, {
|
|
91
|
+
labelView: backgroundRowLabel,
|
|
92
|
+
children: [
|
|
93
|
+
backgroundRowLabel,
|
|
94
|
+
backgroundInput
|
|
95
|
+
],
|
|
96
|
+
class: 'ck-table-form__background-row'
|
|
97
|
+
}));
|
|
98
|
+
this.children.add(new FormRowView(locale, {
|
|
99
|
+
children: [
|
|
100
|
+
// Dimensions row.
|
|
101
|
+
new FormRowView(locale, {
|
|
102
|
+
labelView: dimensionsLabel,
|
|
103
|
+
children: [
|
|
104
|
+
dimensionsLabel,
|
|
105
|
+
widthInput,
|
|
106
|
+
operatorLabel,
|
|
107
|
+
heightInput
|
|
108
|
+
],
|
|
109
|
+
class: 'ck-table-form__dimensions-row'
|
|
110
|
+
}),
|
|
111
|
+
// Alignment row.
|
|
112
|
+
new FormRowView(locale, {
|
|
113
|
+
labelView: alignmentLabel,
|
|
114
|
+
children: [
|
|
115
|
+
alignmentLabel,
|
|
116
|
+
alignmentToolbar
|
|
117
|
+
],
|
|
118
|
+
class: 'ck-table-properties-form__alignment-row'
|
|
119
|
+
})
|
|
120
|
+
]
|
|
121
|
+
}));
|
|
122
|
+
// Action row.
|
|
123
|
+
this.children.add(new FormRowView(locale, {
|
|
124
|
+
children: [
|
|
125
|
+
this.saveButtonView,
|
|
126
|
+
this.cancelButtonView
|
|
127
|
+
],
|
|
128
|
+
class: 'ck-table-form__action-row'
|
|
129
|
+
}));
|
|
130
|
+
this.setTemplate({
|
|
131
|
+
tag: 'form',
|
|
132
|
+
attributes: {
|
|
133
|
+
class: [
|
|
134
|
+
'ck',
|
|
135
|
+
'ck-form',
|
|
136
|
+
'ck-table-form',
|
|
137
|
+
'ck-table-properties-form'
|
|
138
|
+
],
|
|
139
|
+
// https://github.com/ckeditor/ckeditor5-link/issues/90
|
|
140
|
+
tabindex: '-1'
|
|
141
|
+
},
|
|
142
|
+
children: this.children
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* @inheritDoc
|
|
147
|
+
*/
|
|
148
|
+
render() {
|
|
149
|
+
super.render();
|
|
150
|
+
// Enable the "submit" event for this view. It can be triggered by the #saveButtonView
|
|
151
|
+
// which is of the "submit" DOM "type".
|
|
152
|
+
submitHandler({
|
|
153
|
+
view: this
|
|
154
|
+
});
|
|
155
|
+
[
|
|
156
|
+
this.borderStyleDropdown,
|
|
157
|
+
this.borderColorInput,
|
|
158
|
+
this.borderColorInput.fieldView.dropdownView.buttonView,
|
|
159
|
+
this.borderWidthInput,
|
|
160
|
+
this.backgroundInput,
|
|
161
|
+
this.backgroundInput.fieldView.dropdownView.buttonView,
|
|
162
|
+
this.widthInput,
|
|
163
|
+
this.heightInput,
|
|
164
|
+
this.alignmentToolbar,
|
|
165
|
+
this.saveButtonView,
|
|
166
|
+
this.cancelButtonView
|
|
167
|
+
].forEach(view => {
|
|
168
|
+
// Register the view as focusable.
|
|
169
|
+
this._focusables.add(view);
|
|
170
|
+
// Register the view in the focus tracker.
|
|
171
|
+
this.focusTracker.add(view.element);
|
|
172
|
+
});
|
|
173
|
+
// Mainly for closing using "Esc" and navigation using "Tab".
|
|
174
|
+
this.keystrokes.listenTo(this.element);
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* @inheritDoc
|
|
178
|
+
*/
|
|
179
|
+
destroy() {
|
|
180
|
+
super.destroy();
|
|
181
|
+
this.focusTracker.destroy();
|
|
182
|
+
this.keystrokes.destroy();
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Focuses the fist focusable field in the form.
|
|
186
|
+
*/
|
|
187
|
+
focus() {
|
|
188
|
+
this._focusCycler.focusFirst();
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Creates the following form fields:
|
|
192
|
+
*
|
|
193
|
+
* * {@link #borderStyleDropdown},
|
|
194
|
+
* * {@link #borderWidthInput},
|
|
195
|
+
* * {@link #borderColorInput}.
|
|
196
|
+
*/
|
|
197
|
+
_createBorderFields() {
|
|
198
|
+
const defaultTableProperties = this.options.defaultTableProperties;
|
|
199
|
+
const defaultBorder = {
|
|
200
|
+
style: defaultTableProperties.borderStyle,
|
|
201
|
+
width: defaultTableProperties.borderWidth,
|
|
202
|
+
color: defaultTableProperties.borderColor
|
|
203
|
+
};
|
|
204
|
+
const colorInputCreator = getLabeledColorInputCreator({
|
|
205
|
+
colorConfig: this.options.borderColors,
|
|
206
|
+
columns: 5,
|
|
207
|
+
defaultColorValue: defaultBorder.color
|
|
208
|
+
});
|
|
209
|
+
const locale = this.locale;
|
|
210
|
+
const t = this.t;
|
|
211
|
+
// -- Group label ---------------------------------------------
|
|
212
|
+
const borderRowLabel = new LabelView(locale);
|
|
213
|
+
borderRowLabel.text = t('Border');
|
|
214
|
+
// -- Style ---------------------------------------------------
|
|
215
|
+
const styleLabels = getBorderStyleLabels(t);
|
|
216
|
+
const borderStyleDropdown = new LabeledFieldView(locale, createLabeledDropdown);
|
|
217
|
+
borderStyleDropdown.set({
|
|
218
|
+
label: t('Style'),
|
|
219
|
+
class: 'ck-table-form__border-style'
|
|
220
|
+
});
|
|
221
|
+
borderStyleDropdown.fieldView.buttonView.set({
|
|
222
|
+
isOn: false,
|
|
223
|
+
withText: true,
|
|
224
|
+
tooltip: t('Style')
|
|
225
|
+
});
|
|
226
|
+
borderStyleDropdown.fieldView.buttonView.bind('label').to(this, 'borderStyle', value => {
|
|
227
|
+
return styleLabels[value ? value : 'none'];
|
|
228
|
+
});
|
|
229
|
+
borderStyleDropdown.fieldView.on('execute', evt => {
|
|
230
|
+
this.borderStyle = evt.source._borderStyleValue;
|
|
231
|
+
});
|
|
232
|
+
borderStyleDropdown.bind('isEmpty').to(this, 'borderStyle', value => !value);
|
|
233
|
+
addListToDropdown(borderStyleDropdown.fieldView, getBorderStyleDefinitions(this, defaultBorder.style));
|
|
234
|
+
// -- Width ---------------------------------------------------
|
|
235
|
+
const borderWidthInput = new LabeledFieldView(locale, createLabeledInputText);
|
|
236
|
+
borderWidthInput.set({
|
|
237
|
+
label: t('Width'),
|
|
238
|
+
class: 'ck-table-form__border-width'
|
|
239
|
+
});
|
|
240
|
+
borderWidthInput.fieldView.bind('value').to(this, 'borderWidth');
|
|
241
|
+
borderWidthInput.bind('isEnabled').to(this, 'borderStyle', isBorderStyleSet);
|
|
242
|
+
borderWidthInput.fieldView.on('input', () => {
|
|
243
|
+
this.borderWidth = borderWidthInput.fieldView.element.value;
|
|
244
|
+
});
|
|
245
|
+
// -- Color ---------------------------------------------------
|
|
246
|
+
const borderColorInput = new LabeledFieldView(locale, colorInputCreator);
|
|
247
|
+
borderColorInput.set({
|
|
248
|
+
label: t('Color'),
|
|
249
|
+
class: 'ck-table-form__border-color'
|
|
250
|
+
});
|
|
251
|
+
borderColorInput.fieldView.bind('value').to(this, 'borderColor');
|
|
252
|
+
borderColorInput.bind('isEnabled').to(this, 'borderStyle', isBorderStyleSet);
|
|
253
|
+
borderColorInput.fieldView.on('input', () => {
|
|
254
|
+
this.borderColor = borderColorInput.fieldView.value;
|
|
255
|
+
});
|
|
256
|
+
// Reset the border color and width fields depending on the `border-style` value.
|
|
257
|
+
this.on('change:borderStyle', (evt, name, newValue, oldValue) => {
|
|
258
|
+
// When removing the border (`border-style:none`), clear the remaining `border-*` properties.
|
|
259
|
+
// See: https://github.com/ckeditor/ckeditor5/issues/6227.
|
|
260
|
+
if (!isBorderStyleSet(newValue)) {
|
|
261
|
+
this.borderColor = '';
|
|
262
|
+
this.borderWidth = '';
|
|
263
|
+
}
|
|
264
|
+
// When setting the `border-style` from `none`, set the default `border-color` and `border-width` properties.
|
|
265
|
+
if (!isBorderStyleSet(oldValue)) {
|
|
266
|
+
this.borderColor = defaultBorder.color;
|
|
267
|
+
this.borderWidth = defaultBorder.width;
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
return {
|
|
271
|
+
borderRowLabel,
|
|
272
|
+
borderStyleDropdown,
|
|
273
|
+
borderColorInput,
|
|
274
|
+
borderWidthInput
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Creates the following form fields:
|
|
279
|
+
*
|
|
280
|
+
* * {@link #backgroundInput}.
|
|
281
|
+
*/
|
|
282
|
+
_createBackgroundFields() {
|
|
283
|
+
const locale = this.locale;
|
|
284
|
+
const t = this.t;
|
|
285
|
+
// -- Group label ---------------------------------------------
|
|
286
|
+
const backgroundRowLabel = new LabelView(locale);
|
|
287
|
+
backgroundRowLabel.text = t('Background');
|
|
288
|
+
// -- Background color input -----------------------------------
|
|
289
|
+
const backgroundInputCreator = getLabeledColorInputCreator({
|
|
290
|
+
colorConfig: this.options.backgroundColors,
|
|
291
|
+
columns: 5,
|
|
292
|
+
defaultColorValue: this.options.defaultTableProperties.backgroundColor
|
|
293
|
+
});
|
|
294
|
+
const backgroundInput = new LabeledFieldView(locale, backgroundInputCreator);
|
|
295
|
+
backgroundInput.set({
|
|
296
|
+
label: t('Color'),
|
|
297
|
+
class: 'ck-table-properties-form__background'
|
|
298
|
+
});
|
|
299
|
+
backgroundInput.fieldView.bind('value').to(this, 'backgroundColor');
|
|
300
|
+
backgroundInput.fieldView.on('input', () => {
|
|
301
|
+
this.backgroundColor = backgroundInput.fieldView.value;
|
|
302
|
+
});
|
|
303
|
+
return {
|
|
304
|
+
backgroundRowLabel,
|
|
305
|
+
backgroundInput
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Creates the following form fields:
|
|
310
|
+
*
|
|
311
|
+
* * {@link #widthInput},
|
|
312
|
+
* * {@link #heightInput}.
|
|
313
|
+
*/
|
|
314
|
+
_createDimensionFields() {
|
|
315
|
+
const locale = this.locale;
|
|
316
|
+
const t = this.t;
|
|
317
|
+
// -- Label ---------------------------------------------------
|
|
318
|
+
const dimensionsLabel = new LabelView(locale);
|
|
319
|
+
dimensionsLabel.text = t('Dimensions');
|
|
320
|
+
// -- Width ---------------------------------------------------
|
|
321
|
+
const widthInput = new LabeledFieldView(locale, createLabeledInputText);
|
|
322
|
+
widthInput.set({
|
|
323
|
+
label: t('Width'),
|
|
324
|
+
class: 'ck-table-form__dimensions-row__width'
|
|
325
|
+
});
|
|
326
|
+
widthInput.fieldView.bind('value').to(this, 'width');
|
|
327
|
+
widthInput.fieldView.on('input', () => {
|
|
328
|
+
this.width = widthInput.fieldView.element.value;
|
|
329
|
+
});
|
|
330
|
+
// -- Operator ---------------------------------------------------
|
|
331
|
+
const operatorLabel = new View(locale);
|
|
332
|
+
operatorLabel.setTemplate({
|
|
333
|
+
tag: 'span',
|
|
334
|
+
attributes: {
|
|
335
|
+
class: [
|
|
336
|
+
'ck-table-form__dimension-operator'
|
|
337
|
+
]
|
|
338
|
+
},
|
|
339
|
+
children: [
|
|
340
|
+
{ text: '×' }
|
|
341
|
+
]
|
|
342
|
+
});
|
|
343
|
+
// -- Height ---------------------------------------------------
|
|
344
|
+
const heightInput = new LabeledFieldView(locale, createLabeledInputText);
|
|
345
|
+
heightInput.set({
|
|
346
|
+
label: t('Height'),
|
|
347
|
+
class: 'ck-table-form__dimensions-row__height'
|
|
348
|
+
});
|
|
349
|
+
heightInput.fieldView.bind('value').to(this, 'height');
|
|
350
|
+
heightInput.fieldView.on('input', () => {
|
|
351
|
+
this.height = heightInput.fieldView.element.value;
|
|
352
|
+
});
|
|
353
|
+
return {
|
|
354
|
+
dimensionsLabel,
|
|
355
|
+
widthInput,
|
|
356
|
+
operatorLabel,
|
|
357
|
+
heightInput
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Creates the following form fields:
|
|
362
|
+
*
|
|
363
|
+
* * {@link #alignmentToolbar}.
|
|
364
|
+
*/
|
|
365
|
+
_createAlignmentFields() {
|
|
366
|
+
const locale = this.locale;
|
|
367
|
+
const t = this.t;
|
|
368
|
+
// -- Label ---------------------------------------------------
|
|
369
|
+
const alignmentLabel = new LabelView(locale);
|
|
370
|
+
alignmentLabel.text = t('Alignment');
|
|
371
|
+
// -- Toolbar ---------------------------------------------------
|
|
372
|
+
const alignmentToolbar = new ToolbarView(locale);
|
|
373
|
+
alignmentToolbar.set({
|
|
374
|
+
isCompact: true,
|
|
375
|
+
ariaLabel: t('Table alignment toolbar')
|
|
376
|
+
});
|
|
377
|
+
fillToolbar({
|
|
378
|
+
view: this,
|
|
379
|
+
icons: ALIGNMENT_ICONS,
|
|
380
|
+
toolbar: alignmentToolbar,
|
|
381
|
+
labels: this._alignmentLabels,
|
|
382
|
+
propertyName: 'alignment',
|
|
383
|
+
defaultValue: this.options.defaultTableProperties.alignment
|
|
384
|
+
});
|
|
385
|
+
return {
|
|
386
|
+
alignmentLabel,
|
|
387
|
+
alignmentToolbar
|
|
388
|
+
};
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* Creates the following form controls:
|
|
392
|
+
*
|
|
393
|
+
* * {@link #saveButtonView},
|
|
394
|
+
* * {@link #cancelButtonView}.
|
|
395
|
+
*/
|
|
396
|
+
_createActionButtons() {
|
|
397
|
+
const locale = this.locale;
|
|
398
|
+
const t = this.t;
|
|
399
|
+
const saveButtonView = new ButtonView(locale);
|
|
400
|
+
const cancelButtonView = new ButtonView(locale);
|
|
401
|
+
const fieldsThatShouldValidateToSave = [
|
|
402
|
+
this.borderWidthInput,
|
|
403
|
+
this.borderColorInput,
|
|
404
|
+
this.backgroundInput,
|
|
405
|
+
this.widthInput,
|
|
406
|
+
this.heightInput
|
|
407
|
+
];
|
|
408
|
+
saveButtonView.set({
|
|
409
|
+
label: t('Save'),
|
|
410
|
+
icon: icons.check,
|
|
411
|
+
class: 'ck-button-save',
|
|
412
|
+
type: 'submit',
|
|
413
|
+
withText: true
|
|
414
|
+
});
|
|
415
|
+
saveButtonView.bind('isEnabled').toMany(fieldsThatShouldValidateToSave, 'errorText', (...errorTexts) => {
|
|
416
|
+
return errorTexts.every(errorText => !errorText);
|
|
417
|
+
});
|
|
418
|
+
cancelButtonView.set({
|
|
419
|
+
label: t('Cancel'),
|
|
420
|
+
icon: icons.cancel,
|
|
421
|
+
class: 'ck-button-cancel',
|
|
422
|
+
withText: true
|
|
423
|
+
});
|
|
424
|
+
cancelButtonView.delegate('execute').to(this, 'cancel');
|
|
425
|
+
return {
|
|
426
|
+
saveButtonView, cancelButtonView
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
/**
|
|
430
|
+
* Provides localized labels for {@link #alignmentToolbar} buttons.
|
|
431
|
+
*/
|
|
432
|
+
get _alignmentLabels() {
|
|
433
|
+
const locale = this.locale;
|
|
434
|
+
const t = this.t;
|
|
435
|
+
const left = t('Align table to the left');
|
|
436
|
+
const center = t('Center table');
|
|
437
|
+
const right = t('Align table to the right');
|
|
438
|
+
// Returns object with a proper order of labels.
|
|
439
|
+
if (locale.uiLanguageDirection === 'rtl') {
|
|
440
|
+
return { right, center, left };
|
|
441
|
+
}
|
|
442
|
+
else {
|
|
443
|
+
return { left, center, right };
|
|
444
|
+
}
|
|
445
|
+
}
|
|
736
446
|
}
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
return value !== 'none';
|
|
447
|
+
function isBorderStyleSet(value) {
|
|
448
|
+
return value !== 'none';
|
|
740
449
|
}
|