@ckeditor/ckeditor5-table 36.0.0 → 37.0.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 (166) hide show
  1. package/build/table.js +1 -1
  2. package/package.json +34 -29
  3. package/src/commands/insertcolumncommand.d.ts +61 -0
  4. package/src/commands/insertcolumncommand.js +45 -60
  5. package/src/commands/insertrowcommand.d.ts +60 -0
  6. package/src/commands/insertrowcommand.js +44 -59
  7. package/src/commands/inserttablecommand.d.ts +50 -0
  8. package/src/commands/inserttablecommand.js +51 -68
  9. package/src/commands/mergecellcommand.d.ts +76 -0
  10. package/src/commands/mergecellcommand.js +169 -244
  11. package/src/commands/mergecellscommand.d.ts +33 -0
  12. package/src/commands/mergecellscommand.js +72 -101
  13. package/src/commands/removecolumncommand.d.ts +34 -0
  14. package/src/commands/removecolumncommand.js +88 -102
  15. package/src/commands/removerowcommand.d.ts +34 -0
  16. package/src/commands/removerowcommand.js +63 -80
  17. package/src/commands/selectcolumncommand.d.ts +38 -0
  18. package/src/commands/selectcolumncommand.js +41 -54
  19. package/src/commands/selectrowcommand.d.ts +38 -0
  20. package/src/commands/selectrowcommand.js +38 -48
  21. package/src/commands/setheadercolumncommand.d.ts +55 -0
  22. package/src/commands/setheadercolumncommand.js +48 -73
  23. package/src/commands/setheaderrowcommand.d.ts +58 -0
  24. package/src/commands/setheaderrowcommand.js +56 -85
  25. package/src/commands/splitcellcommand.d.ts +49 -0
  26. package/src/commands/splitcellcommand.js +35 -49
  27. package/src/converters/downcast.d.ts +63 -0
  28. package/src/converters/downcast.js +98 -130
  29. package/src/converters/table-caption-post-fixer.d.ts +20 -0
  30. package/src/converters/table-caption-post-fixer.js +36 -52
  31. package/src/converters/table-cell-paragraph-post-fixer.d.ts +32 -0
  32. package/src/converters/table-cell-paragraph-post-fixer.js +88 -119
  33. package/src/converters/table-cell-refresh-handler.d.ts +18 -0
  34. package/src/converters/table-cell-refresh-handler.js +29 -48
  35. package/src/converters/table-headings-refresh-handler.d.ts +17 -0
  36. package/src/converters/table-headings-refresh-handler.js +35 -54
  37. package/src/converters/table-layout-post-fixer.d.ts +226 -0
  38. package/src/converters/table-layout-post-fixer.js +276 -313
  39. package/src/converters/tableproperties.d.ts +54 -0
  40. package/src/converters/tableproperties.js +136 -168
  41. package/src/converters/upcasttable.d.ts +49 -0
  42. package/src/converters/upcasttable.js +196 -251
  43. package/src/index.d.ts +29 -0
  44. package/src/index.js +0 -2
  45. package/src/plaintableoutput.d.ts +30 -0
  46. package/src/plaintableoutput.js +107 -135
  47. package/src/table.d.ts +38 -0
  48. package/src/table.js +12 -88
  49. package/src/tablecaption/tablecaptionediting.d.ts +68 -0
  50. package/src/tablecaption/tablecaptionediting.js +104 -135
  51. package/src/tablecaption/tablecaptionui.d.ts +26 -0
  52. package/src/tablecaption/tablecaptionui.js +42 -58
  53. package/src/tablecaption/toggletablecaptioncommand.d.ts +73 -0
  54. package/src/tablecaption/toggletablecaptioncommand.js +77 -92
  55. package/src/tablecaption/utils.d.ts +42 -0
  56. package/src/tablecaption/utils.js +35 -61
  57. package/src/tablecaption.d.ts +27 -0
  58. package/src/tablecaption.js +12 -19
  59. package/src/tablecellproperties/commands/tablecellbackgroundcolorcommand.d.ts +37 -0
  60. package/src/tablecellproperties/commands/tablecellbackgroundcolorcommand.js +14 -20
  61. package/src/tablecellproperties/commands/tablecellbordercolorcommand.d.ts +42 -0
  62. package/src/tablecellproperties/commands/tablecellbordercolorcommand.js +27 -37
  63. package/src/tablecellproperties/commands/tablecellborderstylecommand.d.ts +42 -0
  64. package/src/tablecellproperties/commands/tablecellborderstylecommand.js +27 -37
  65. package/src/tablecellproperties/commands/tablecellborderwidthcommand.d.ts +56 -0
  66. package/src/tablecellproperties/commands/tablecellborderwidthcommand.js +42 -53
  67. package/src/tablecellproperties/commands/tablecellheightcommand.d.ts +51 -0
  68. package/src/tablecellproperties/commands/tablecellheightcommand.js +29 -36
  69. package/src/tablecellproperties/commands/tablecellhorizontalalignmentcommand.d.ts +37 -0
  70. package/src/tablecellproperties/commands/tablecellhorizontalalignmentcommand.js +14 -20
  71. package/src/tablecellproperties/commands/tablecellpaddingcommand.d.ts +56 -0
  72. package/src/tablecellproperties/commands/tablecellpaddingcommand.js +42 -53
  73. package/src/tablecellproperties/commands/tablecellpropertycommand.d.ts +62 -0
  74. package/src/tablecellproperties/commands/tablecellpropertycommand.js +77 -122
  75. package/src/tablecellproperties/commands/tablecellverticalalignmentcommand.d.ts +45 -0
  76. package/src/tablecellproperties/commands/tablecellverticalalignmentcommand.js +14 -20
  77. package/src/tablecellproperties/tablecellpropertiesediting.d.ts +47 -0
  78. package/src/tablecellproperties/tablecellpropertiesediting.js +194 -236
  79. package/src/tablecellproperties/tablecellpropertiesui.d.ts +117 -0
  80. package/src/tablecellproperties/tablecellpropertiesui.js +303 -456
  81. package/src/tablecellproperties/ui/tablecellpropertiesview.d.ts +227 -0
  82. package/src/tablecellproperties/ui/tablecellpropertiesview.js +509 -844
  83. package/src/tablecellproperties.d.ts +33 -0
  84. package/src/tablecellproperties.js +12 -98
  85. package/src/tablecellwidth/commands/tablecellwidthcommand.d.ts +51 -0
  86. package/src/tablecellwidth/commands/tablecellwidthcommand.js +29 -35
  87. package/src/tablecellwidth/tablecellwidthediting.d.ts +34 -0
  88. package/src/tablecellwidth/tablecellwidthediting.js +26 -38
  89. package/src/tableclipboard.d.ts +68 -0
  90. package/src/tableclipboard.js +429 -568
  91. package/src/tablecolumnresize/constants.d.ts +20 -0
  92. package/src/tablecolumnresize/constants.js +0 -10
  93. package/src/tablecolumnresize/converters.d.ts +18 -0
  94. package/src/tablecolumnresize/converters.js +35 -119
  95. package/src/tablecolumnresize/tablecolumnresizeediting.d.ts +142 -0
  96. package/src/tablecolumnresize/tablecolumnresizeediting.js +545 -711
  97. package/src/tablecolumnresize/tablewidthscommand.d.ts +38 -0
  98. package/src/tablecolumnresize/tablewidthscommand.js +61 -0
  99. package/src/tablecolumnresize/utils.d.ts +141 -0
  100. package/src/tablecolumnresize/utils.js +256 -233
  101. package/src/tablecolumnresize.d.ts +29 -0
  102. package/src/tablecolumnresize.js +12 -19
  103. package/src/tableconfig.d.ts +341 -0
  104. package/src/tableconfig.js +5 -0
  105. package/src/tableediting.d.ts +102 -0
  106. package/src/tableediting.js +157 -176
  107. package/src/tablekeyboard.d.ts +68 -0
  108. package/src/tablekeyboard.js +261 -344
  109. package/src/tablemouse/mouseeventsobserver.d.ts +62 -0
  110. package/src/tablemouse/mouseeventsobserver.js +12 -49
  111. package/src/tablemouse.d.ts +51 -0
  112. package/src/tablemouse.js +154 -202
  113. package/src/tableproperties/commands/tablealignmentcommand.d.ts +37 -0
  114. package/src/tableproperties/commands/tablealignmentcommand.js +14 -20
  115. package/src/tableproperties/commands/tablebackgroundcolorcommand.d.ts +37 -0
  116. package/src/tableproperties/commands/tablebackgroundcolorcommand.js +14 -20
  117. package/src/tableproperties/commands/tablebordercolorcommand.d.ts +42 -0
  118. package/src/tableproperties/commands/tablebordercolorcommand.js +27 -37
  119. package/src/tableproperties/commands/tableborderstylecommand.d.ts +42 -0
  120. package/src/tableproperties/commands/tableborderstylecommand.js +27 -37
  121. package/src/tableproperties/commands/tableborderwidthcommand.d.ts +56 -0
  122. package/src/tableproperties/commands/tableborderwidthcommand.js +42 -53
  123. package/src/tableproperties/commands/tableheightcommand.d.ts +51 -0
  124. package/src/tableproperties/commands/tableheightcommand.js +29 -33
  125. package/src/tableproperties/commands/tablepropertycommand.d.ts +61 -0
  126. package/src/tableproperties/commands/tablepropertycommand.js +68 -112
  127. package/src/tableproperties/commands/tablewidthcommand.d.ts +51 -0
  128. package/src/tableproperties/commands/tablewidthcommand.js +29 -33
  129. package/src/tableproperties/tablepropertiesediting.d.ts +45 -0
  130. package/src/tableproperties/tablepropertiesediting.js +164 -210
  131. package/src/tableproperties/tablepropertiesui.d.ts +119 -0
  132. package/src/tableproperties/tablepropertiesui.js +294 -439
  133. package/src/tableproperties/ui/tablepropertiesview.d.ts +203 -0
  134. package/src/tableproperties/ui/tablepropertiesview.js +427 -718
  135. package/src/tableproperties.d.ts +33 -0
  136. package/src/tableproperties.js +12 -95
  137. package/src/tableselection.d.ts +111 -0
  138. package/src/tableselection.js +279 -376
  139. package/src/tabletoolbar.d.ts +37 -0
  140. package/src/tabletoolbar.js +39 -92
  141. package/src/tableui.d.ts +58 -0
  142. package/src/tableui.js +281 -338
  143. package/src/tableutils.d.ts +453 -0
  144. package/src/tableutils.js +1015 -1229
  145. package/src/tablewalker.d.ts +323 -0
  146. package/src/tablewalker.js +308 -548
  147. package/src/ui/colorinputview.d.ts +143 -0
  148. package/src/ui/colorinputview.js +229 -366
  149. package/src/ui/formrowview.d.ts +61 -0
  150. package/src/ui/formrowview.js +38 -84
  151. package/src/ui/inserttableview.d.ts +77 -0
  152. package/src/ui/inserttableview.js +152 -242
  153. package/src/utils/common.d.ts +42 -0
  154. package/src/utils/common.js +33 -57
  155. package/src/utils/structure.d.ts +245 -0
  156. package/src/utils/structure.js +261 -379
  157. package/src/utils/table-properties.d.ts +67 -0
  158. package/src/utils/table-properties.js +60 -81
  159. package/src/utils/ui/contextualballoon.d.ts +34 -0
  160. package/src/utils/ui/contextualballoon.js +70 -89
  161. package/src/utils/ui/table-properties.d.ts +193 -0
  162. package/src/utils/ui/table-properties.js +259 -319
  163. package/src/utils/ui/widget.d.ts +16 -0
  164. package/src/utils/ui/widget.js +24 -46
  165. package/src/tablecolumnresize/tablecolumnwidthscommand.js +0 -55
  166. 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
- left: icons.objectLeft,
41
- center: icons.objectCenter,
42
- right: icons.objectRight
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
- * @param {module:utils/locale~Locale} locale The {@link module:core/editor/editor~Editor#locale} instance.
54
- * @param {Object} options Additional configuration of the view.
55
- * @param {module:table/table~TableColorConfig} options.borderColors A configuration of the border
56
- * color palette used by the
57
- * {@link module:table/tableproperties/ui/tablepropertiesview~TablePropertiesView#borderColorInput}.
58
- * @param {module:table/table~TableColorConfig} options.backgroundColors A configuration of the background
59
- * color palette used by the
60
- * {@link module:table/tableproperties/ui/tablepropertiesview~TablePropertiesView#backgroundInput}.
61
- * @param {module:table/tableproperties~TablePropertiesOptions} options.defaultTableProperties The default table properties.
62
- */
63
- constructor( locale, options ) {
64
- super( locale );
65
-
66
- this.set( {
67
- /**
68
- * The value of the border style.
69
- *
70
- * @observable
71
- * @default ''
72
- * @member #borderStyle
73
- */
74
- borderStyle: '',
75
-
76
- /**
77
- * The value of the border width style.
78
- *
79
- * @observable
80
- * @default ''
81
- * @member #borderWidth
82
- */
83
- borderWidth: '',
84
-
85
- /**
86
- * The value of the border color style.
87
- *
88
- * @observable
89
- * @default ''
90
- * @member #borderColor
91
- */
92
- borderColor: '',
93
-
94
- /**
95
- * The value of the background color style.
96
- *
97
- * @observable
98
- * @default ''
99
- * @member #backgroundColor
100
- */
101
- backgroundColor: '',
102
-
103
- /**
104
- * The value of the table width style.
105
- *
106
- * @observable
107
- * @default ''
108
- * @member #width
109
- */
110
- width: '',
111
-
112
- /**
113
- * The value of the table height style.
114
- *
115
- * @observable
116
- * @default ''
117
- * @member #height
118
- */
119
- height: '',
120
-
121
- /**
122
- * The value of the table alignment style.
123
- *
124
- * @observable
125
- * @default ''
126
- * @member #alignment
127
- */
128
- alignment: ''
129
- } );
130
-
131
- /**
132
- * Options passed to the view. See {@link #constructor} to learn more.
133
- *
134
- * @protected
135
- * @member {Object}
136
- */
137
- this.options = options;
138
-
139
- const { borderStyleDropdown, borderWidthInput, borderColorInput, borderRowLabel } = this._createBorderFields();
140
- const { backgroundRowLabel, backgroundInput } = this._createBackgroundFields();
141
- const { widthInput, operatorLabel, heightInput, dimensionsLabel } = this._createDimensionFields();
142
- const { alignmentToolbar, alignmentLabel } = this._createAlignmentFields();
143
-
144
- /**
145
- * Tracks information about the DOM focus in the form.
146
- *
147
- * @readonly
148
- * @member {module:utils/focustracker~FocusTracker}
149
- */
150
- this.focusTracker = new FocusTracker();
151
-
152
- /**
153
- * An instance of the {@link module:utils/keystrokehandler~KeystrokeHandler}.
154
- *
155
- * @readonly
156
- * @member {module:utils/keystrokehandler~KeystrokeHandler}
157
- */
158
- this.keystrokes = new KeystrokeHandler();
159
-
160
- /**
161
- * A collection of child views in the form.
162
- *
163
- * @readonly
164
- * @type {module:ui/viewcollection~ViewCollection}
165
- */
166
- this.children = this.createCollection();
167
-
168
- /**
169
- * A dropdown that allows selecting the style of the table border.
170
- *
171
- * @readonly
172
- * @member {module:ui/dropdown/dropdownview~DropdownView}
173
- */
174
- this.borderStyleDropdown = borderStyleDropdown;
175
-
176
- /**
177
- * An input that allows specifying the width of the table border.
178
- *
179
- * @readonly
180
- * @member {module:ui/inputtext/inputtextview~InputTextView}
181
- */
182
- this.borderWidthInput = borderWidthInput;
183
-
184
- /**
185
- * An input that allows specifying the color of the table border.
186
- *
187
- * @readonly
188
- * @member {module:table/ui/colorinputview~ColorInputView}
189
- */
190
- this.borderColorInput = borderColorInput;
191
-
192
- /**
193
- * An input that allows specifying the table background color.
194
- *
195
- * @readonly
196
- * @member {module:table/ui/colorinputview~ColorInputView}
197
- */
198
- this.backgroundInput = backgroundInput;
199
-
200
- /**
201
- * An input that allows specifying the table width.
202
- *
203
- * @readonly
204
- * @member {module:ui/inputtext/inputtextview~InputTextView}
205
- */
206
- this.widthInput = widthInput;
207
-
208
- /**
209
- * An input that allows specifying the table height.
210
- *
211
- * @readonly
212
- * @member {module:ui/inputtext/inputtextview~InputTextView}
213
- */
214
- this.heightInput = heightInput;
215
-
216
- /**
217
- * A toolbar with buttons that allow changing the alignment of an entire table.
218
- * @readonly
219
- * @member {module:ui/toolbar/toolbarview~ToolbarView}
220
- */
221
- this.alignmentToolbar = alignmentToolbar;
222
-
223
- // Defer creating to make sure other fields are present and the Save button can
224
- // bind its #isEnabled to their error messages so there's no way to save unless all
225
- // fields are valid.
226
- const { saveButtonView, cancelButtonView } = this._createActionButtons();
227
-
228
- /**
229
- * The "Save" button view.
230
- *
231
- * @member {module:ui/button/buttonview~ButtonView}
232
- */
233
- this.saveButtonView = saveButtonView;
234
-
235
- /**
236
- * The "Cancel" button view.
237
- *
238
- * @member {module:ui/button/buttonview~ButtonView}
239
- */
240
- this.cancelButtonView = cancelButtonView;
241
-
242
- /**
243
- * A collection of views that can be focused in the form.
244
- *
245
- * @readonly
246
- * @protected
247
- * @member {module:ui/viewcollection~ViewCollection}
248
- */
249
- this._focusables = new ViewCollection();
250
-
251
- /**
252
- * Helps cycling over {@link #_focusables} in the form.
253
- *
254
- * @readonly
255
- * @protected
256
- * @member {module:ui/focuscycler~FocusCycler}
257
- */
258
- this._focusCycler = new FocusCycler( {
259
- focusables: this._focusables,
260
- focusTracker: this.focusTracker,
261
- keystrokeHandler: this.keystrokes,
262
- actions: {
263
- // Navigate form fields backwards using the Shift + Tab keystroke.
264
- focusPrevious: 'shift + tab',
265
-
266
- // Navigate form fields forwards using the Tab key.
267
- focusNext: 'tab'
268
- }
269
- } );
270
-
271
- // Form header.
272
- this.children.add( new FormHeaderView( locale, {
273
- label: this.t( 'Table properties' )
274
- } ) );
275
-
276
- // Border row.
277
- this.children.add( new FormRowView( locale, {
278
- labelView: borderRowLabel,
279
- children: [
280
- borderRowLabel,
281
- borderStyleDropdown,
282
- borderColorInput,
283
- borderWidthInput
284
- ],
285
- class: 'ck-table-form__border-row'
286
- } ) );
287
-
288
- // Background row.
289
- this.children.add( new FormRowView( locale, {
290
- labelView: backgroundRowLabel,
291
- children: [
292
- backgroundRowLabel,
293
- backgroundInput
294
- ],
295
- class: 'ck-table-form__background-row'
296
- } ) );
297
-
298
- this.children.add( new FormRowView( locale, {
299
- children: [
300
- // Dimensions row.
301
- new FormRowView( locale, {
302
- labelView: dimensionsLabel,
303
- children: [
304
- dimensionsLabel,
305
- widthInput,
306
- operatorLabel,
307
- heightInput
308
- ],
309
- class: 'ck-table-form__dimensions-row'
310
- } ),
311
- // Alignment row.
312
- new FormRowView( locale, {
313
- labelView: alignmentLabel,
314
- children: [
315
- alignmentLabel,
316
- alignmentToolbar
317
- ],
318
- class: 'ck-table-properties-form__alignment-row'
319
- } )
320
- ]
321
- } ) );
322
-
323
- // Action row.
324
- this.children.add( new FormRowView( locale, {
325
- children: [
326
- this.saveButtonView,
327
- this.cancelButtonView
328
- ],
329
- class: 'ck-table-form__action-row'
330
- } ) );
331
-
332
- this.setTemplate( {
333
- tag: 'form',
334
- attributes: {
335
- class: [
336
- 'ck',
337
- 'ck-form',
338
- 'ck-table-form',
339
- 'ck-table-properties-form'
340
- ],
341
- // https://github.com/ckeditor/ckeditor5-link/issues/90
342
- tabindex: '-1'
343
- },
344
- children: this.children
345
- } );
346
- }
347
-
348
- /**
349
- * @inheritDoc
350
- */
351
- render() {
352
- super.render();
353
-
354
- // Enable the "submit" event for this view. It can be triggered by the #saveButtonView
355
- // which is of the "submit" DOM "type".
356
- submitHandler( {
357
- view: this
358
- } );
359
-
360
- [
361
- this.borderStyleDropdown,
362
- this.borderColorInput,
363
- this.borderColorInput.fieldView.dropdownView.buttonView,
364
- this.borderWidthInput,
365
- this.backgroundInput,
366
- this.backgroundInput.fieldView.dropdownView.buttonView,
367
- this.widthInput,
368
- this.heightInput,
369
- this.alignmentToolbar,
370
- this.saveButtonView,
371
- this.cancelButtonView
372
- ].forEach( view => {
373
- // Register the view as focusable.
374
- this._focusables.add( view );
375
-
376
- // Register the view in the focus tracker.
377
- this.focusTracker.add( view.element );
378
- } );
379
-
380
- // Mainly for closing using "Esc" and navigation using "Tab".
381
- this.keystrokes.listenTo( this.element );
382
- }
383
-
384
- /**
385
- * @inheritDoc
386
- */
387
- destroy() {
388
- super.destroy();
389
-
390
- this.focusTracker.destroy();
391
- this.keystrokes.destroy();
392
- }
393
-
394
- /**
395
- * Focuses the fist focusable field in the form.
396
- */
397
- focus() {
398
- this._focusCycler.focusFirst();
399
- }
400
-
401
- /**
402
- * Creates the following form fields:
403
- *
404
- * * {@link #borderStyleDropdown},
405
- * * {@link #borderWidthInput},
406
- * * {@link #borderColorInput}.
407
- *
408
- * @private
409
- * @returns {Object.<String,module:ui/view~View>}
410
- */
411
- _createBorderFields() {
412
- const defaultTableProperties = this.options.defaultTableProperties;
413
- const defaultBorder = {
414
- style: defaultTableProperties.borderStyle,
415
- width: defaultTableProperties.borderWidth,
416
- color: defaultTableProperties.borderColor
417
- };
418
-
419
- const colorInputCreator = getLabeledColorInputCreator( {
420
- colorConfig: this.options.borderColors,
421
- columns: 5,
422
- defaultColorValue: defaultBorder.color
423
- } );
424
- const locale = this.locale;
425
- const t = this.t;
426
-
427
- // -- Group label ---------------------------------------------
428
-
429
- const borderRowLabel = new LabelView( locale );
430
- borderRowLabel.text = t( 'Border' );
431
-
432
- // -- Style ---------------------------------------------------
433
-
434
- const styleLabels = getBorderStyleLabels( this.t );
435
- const borderStyleDropdown = new LabeledFieldView( locale, createLabeledDropdown );
436
- borderStyleDropdown.set( {
437
- label: t( 'Style' ),
438
- class: 'ck-table-form__border-style'
439
- } );
440
-
441
- borderStyleDropdown.fieldView.buttonView.set( {
442
- isOn: false,
443
- withText: true,
444
- tooltip: t( 'Style' )
445
- } );
446
-
447
- borderStyleDropdown.fieldView.buttonView.bind( 'label' ).to( this, 'borderStyle', value => {
448
- return styleLabels[ value ? value : 'none' ];
449
- } );
450
-
451
- borderStyleDropdown.fieldView.on( 'execute', evt => {
452
- this.borderStyle = evt.source._borderStyleValue;
453
- } );
454
-
455
- borderStyleDropdown.bind( 'isEmpty' ).to( this, 'borderStyle', value => !value );
456
-
457
- addListToDropdown( borderStyleDropdown.fieldView, getBorderStyleDefinitions( this, defaultBorder.style ) );
458
-
459
- // -- Width ---------------------------------------------------
460
-
461
- const borderWidthInput = new LabeledFieldView( locale, createLabeledInputText );
462
-
463
- borderWidthInput.set( {
464
- label: t( 'Width' ),
465
- class: 'ck-table-form__border-width'
466
- } );
467
-
468
- borderWidthInput.fieldView.bind( 'value' ).to( this, 'borderWidth' );
469
- borderWidthInput.bind( 'isEnabled' ).to( this, 'borderStyle', isBorderStyleSet );
470
- borderWidthInput.fieldView.on( 'input', () => {
471
- this.borderWidth = borderWidthInput.fieldView.element.value;
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
- function isBorderStyleSet( value ) {
739
- return value !== 'none';
447
+ function isBorderStyleSet(value) {
448
+ return value !== 'none';
740
449
  }