@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,154 +2,117 @@
|
|
|
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/utils/ui/table-properties
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
8
|
import { ButtonView, Model } from 'ckeditor5/src/ui';
|
|
11
9
|
import { Collection } from 'ckeditor5/src/utils';
|
|
12
10
|
import { isColor, isLength, isPercentage } from 'ckeditor5/src/engine';
|
|
13
|
-
|
|
14
11
|
import ColorInputView from '../../ui/colorinputview';
|
|
15
|
-
|
|
16
|
-
const isEmpty = val => val === '';
|
|
17
|
-
|
|
12
|
+
const isEmpty = (val) => val === '';
|
|
18
13
|
/**
|
|
19
14
|
* Returns an object containing pairs of CSS border style values and their localized UI
|
|
20
15
|
* labels. Used by {@link module:table/tablecellproperties/ui/tablecellpropertiesview~TableCellPropertiesView}
|
|
21
16
|
* and {@link module:table/tableproperties/ui/tablepropertiesview~TablePropertiesView}.
|
|
22
17
|
*
|
|
23
|
-
* @param
|
|
24
|
-
* that is used to localize strings.
|
|
25
|
-
* @returns {Object.<String,String>}
|
|
18
|
+
* @param t The "t" function provided by the editor that is used to localize strings.
|
|
26
19
|
*/
|
|
27
|
-
export function getBorderStyleLabels(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
20
|
+
export function getBorderStyleLabels(t) {
|
|
21
|
+
return {
|
|
22
|
+
none: t('None'),
|
|
23
|
+
solid: t('Solid'),
|
|
24
|
+
dotted: t('Dotted'),
|
|
25
|
+
dashed: t('Dashed'),
|
|
26
|
+
double: t('Double'),
|
|
27
|
+
groove: t('Groove'),
|
|
28
|
+
ridge: t('Ridge'),
|
|
29
|
+
inset: t('Inset'),
|
|
30
|
+
outset: t('Outset')
|
|
31
|
+
};
|
|
39
32
|
}
|
|
40
|
-
|
|
41
33
|
/**
|
|
42
34
|
* Returns a localized error string that can be displayed next to color (background, border)
|
|
43
35
|
* fields that have an invalid value.
|
|
44
36
|
*
|
|
45
|
-
* @param
|
|
46
|
-
* that is used to localize strings.
|
|
47
|
-
* @returns {String}
|
|
37
|
+
* @param t The "t" function provided by the editor that is used to localize strings.
|
|
48
38
|
*/
|
|
49
|
-
export function getLocalizedColorErrorText(
|
|
50
|
-
|
|
39
|
+
export function getLocalizedColorErrorText(t) {
|
|
40
|
+
return t('The color is invalid. Try "#FF0000" or "rgb(255,0,0)" or "red".');
|
|
51
41
|
}
|
|
52
|
-
|
|
53
42
|
/**
|
|
54
43
|
* Returns a localized error string that can be displayed next to length (padding, border width)
|
|
55
44
|
* fields that have an invalid value.
|
|
56
45
|
*
|
|
57
|
-
* @param
|
|
58
|
-
* that is used to localize strings.
|
|
59
|
-
* @returns {String}
|
|
46
|
+
* @param t The "t" function provided by the editor that is used to localize strings.
|
|
60
47
|
*/
|
|
61
|
-
export function getLocalizedLengthErrorText(
|
|
62
|
-
|
|
48
|
+
export function getLocalizedLengthErrorText(t) {
|
|
49
|
+
return t('The value is invalid. Try "10px" or "2em" or simply "2".');
|
|
63
50
|
}
|
|
64
|
-
|
|
65
51
|
/**
|
|
66
52
|
* Returns `true` when the passed value is an empty string or a valid CSS color expression.
|
|
67
53
|
* Otherwise, `false` is returned.
|
|
68
54
|
*
|
|
69
55
|
* See {@link module:engine/view/styles/utils~isColor}.
|
|
70
|
-
*
|
|
71
|
-
* @param {String} value
|
|
72
|
-
* @returns {Boolean}
|
|
73
56
|
*/
|
|
74
|
-
export function colorFieldValidator(
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
return isEmpty( value ) || isColor( value );
|
|
57
|
+
export function colorFieldValidator(value) {
|
|
58
|
+
value = value.trim();
|
|
59
|
+
return isEmpty(value) || isColor(value);
|
|
78
60
|
}
|
|
79
|
-
|
|
80
61
|
/**
|
|
81
62
|
* Returns `true` when the passed value is an empty string, a number without a unit or a valid CSS length expression.
|
|
82
63
|
* Otherwise, `false` is returned.
|
|
83
64
|
*
|
|
84
65
|
* See {@link module:engine/view/styles/utils~isLength}.
|
|
85
66
|
* See {@link module:engine/view/styles/utils~isPercentage}.
|
|
86
|
-
*
|
|
87
|
-
* @param {String} value
|
|
88
|
-
* @returns {Boolean}
|
|
89
67
|
*/
|
|
90
|
-
export function lengthFieldValidator(
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
return isEmpty( value ) || isNumberString( value ) || isLength( value ) || isPercentage( value );
|
|
68
|
+
export function lengthFieldValidator(value) {
|
|
69
|
+
value = value.trim();
|
|
70
|
+
return isEmpty(value) || isNumberString(value) || isLength(value) || isPercentage(value);
|
|
94
71
|
}
|
|
95
|
-
|
|
96
72
|
/**
|
|
97
73
|
* Returns `true` when the passed value is an empty string, a number without a unit or a valid CSS length expression.
|
|
98
74
|
* Otherwise, `false` is returned.
|
|
99
75
|
*
|
|
100
76
|
* See {@link module:engine/view/styles/utils~isLength}.
|
|
101
|
-
*
|
|
102
|
-
* @param {String} value
|
|
103
|
-
* @returns {Boolean}
|
|
104
77
|
*/
|
|
105
|
-
export function lineWidthFieldValidator(
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
return isEmpty( value ) || isNumberString( value ) || isLength( value );
|
|
78
|
+
export function lineWidthFieldValidator(value) {
|
|
79
|
+
value = value.trim();
|
|
80
|
+
return isEmpty(value) || isNumberString(value) || isLength(value);
|
|
109
81
|
}
|
|
110
|
-
|
|
111
82
|
/**
|
|
112
83
|
* Generates item definitions for a UI dropdown that allows changing the border style of a table or a table cell.
|
|
113
84
|
*
|
|
114
|
-
* @param
|
|
115
|
-
* module:table/tableproperties/ui/tablepropertiesview~TablePropertiesView} view
|
|
116
|
-
* @param {String} defaultStyle The default border.
|
|
117
|
-
* @returns {Iterable.<module:ui/dropdown/utils~ListDropdownItemDefinition>}
|
|
85
|
+
* @param defaultStyle The default border.
|
|
118
86
|
*/
|
|
119
|
-
export function getBorderStyleDefinitions(
|
|
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
|
-
itemDefinitions.add( definition );
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
return itemDefinitions;
|
|
87
|
+
export function getBorderStyleDefinitions(view, defaultStyle) {
|
|
88
|
+
const itemDefinitions = new Collection();
|
|
89
|
+
const styleLabels = getBorderStyleLabels(view.t);
|
|
90
|
+
for (const style in styleLabels) {
|
|
91
|
+
const definition = {
|
|
92
|
+
type: 'button',
|
|
93
|
+
model: new Model({
|
|
94
|
+
_borderStyleValue: style,
|
|
95
|
+
label: styleLabels[style],
|
|
96
|
+
withText: true
|
|
97
|
+
})
|
|
98
|
+
};
|
|
99
|
+
if (style === 'none') {
|
|
100
|
+
definition.model.bind('isOn').to(view, 'borderStyle', value => {
|
|
101
|
+
if (defaultStyle === 'none') {
|
|
102
|
+
return !value;
|
|
103
|
+
}
|
|
104
|
+
return value === style;
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
definition.model.bind('isOn').to(view, 'borderStyle', value => {
|
|
109
|
+
return value === style;
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
itemDefinitions.add(definition);
|
|
113
|
+
}
|
|
114
|
+
return itemDefinitions;
|
|
151
115
|
}
|
|
152
|
-
|
|
153
116
|
/**
|
|
154
117
|
* A helper that fills a toolbar with buttons that:
|
|
155
118
|
*
|
|
@@ -157,185 +120,171 @@ export function getBorderStyleDefinitions( view, defaultStyle ) {
|
|
|
157
120
|
* * have some icons,
|
|
158
121
|
* * set a certain UI view property value upon execution.
|
|
159
122
|
*
|
|
160
|
-
* @param
|
|
161
|
-
* @param {module:table/tablecellproperties/ui/tablecellpropertiesview~TableCellPropertiesView|
|
|
162
|
-
* module:table/tableproperties/ui/tablepropertiesview~TablePropertiesView} options.view
|
|
163
|
-
* @param {Array.<String>} options.icons
|
|
164
|
-
* @param {module:ui/toolbar/toolbarview~ToolbarView} options.toolbar
|
|
165
|
-
* @param {Object.<String,String>} labels
|
|
166
|
-
* @param {String} propertyName
|
|
167
|
-
* @param {Function} nameToValue A function that maps a button name to a value. By default names are the same as values.
|
|
123
|
+
* @param nameToValue A function that maps a button name to a value. By default names are the same as values.
|
|
168
124
|
*/
|
|
169
|
-
export function fillToolbar(
|
|
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
|
-
button.on( 'execute', () => {
|
|
196
|
-
view[ propertyName ] = buttonValue;
|
|
197
|
-
} );
|
|
198
|
-
|
|
199
|
-
toolbar.items.add( button );
|
|
200
|
-
}
|
|
125
|
+
export function fillToolbar(options) {
|
|
126
|
+
const { view, icons, toolbar, labels, propertyName, nameToValue, defaultValue } = options;
|
|
127
|
+
for (const name in labels) {
|
|
128
|
+
const button = new ButtonView(view.locale);
|
|
129
|
+
button.set({
|
|
130
|
+
label: labels[name],
|
|
131
|
+
icon: icons[name],
|
|
132
|
+
tooltip: labels[name]
|
|
133
|
+
});
|
|
134
|
+
// If specified the `nameToValue()` callback, map the value based on the option's name.
|
|
135
|
+
const buttonValue = nameToValue ? nameToValue(name) : name;
|
|
136
|
+
button.bind('isOn').to(view, propertyName, value => {
|
|
137
|
+
// `value` comes from `view[ propertyName ]`.
|
|
138
|
+
let valueToCompare = value;
|
|
139
|
+
// If it's empty, and the `defaultValue` is specified, use it instead.
|
|
140
|
+
if (value === '' && defaultValue) {
|
|
141
|
+
valueToCompare = defaultValue;
|
|
142
|
+
}
|
|
143
|
+
return buttonValue === valueToCompare;
|
|
144
|
+
});
|
|
145
|
+
button.on('execute', () => {
|
|
146
|
+
view[propertyName] = buttonValue;
|
|
147
|
+
});
|
|
148
|
+
toolbar.items.add(button);
|
|
149
|
+
}
|
|
201
150
|
}
|
|
202
|
-
|
|
203
151
|
/**
|
|
204
152
|
* A default color palette used by various user interfaces related to tables, for instance,
|
|
205
153
|
* by {@link module:table/tablecellproperties/tablecellpropertiesui~TableCellPropertiesUI} or
|
|
206
154
|
* {@link module:table/tableproperties/tablepropertiesui~TablePropertiesUI}.
|
|
207
155
|
*
|
|
208
|
-
* The color palette follows the {@link module:table/
|
|
156
|
+
* The color palette follows the {@link module:table/tableconfig~TableColorConfig table color configuration format}
|
|
209
157
|
* and contains the following color definitions:
|
|
210
158
|
*
|
|
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
|
-
*
|
|
159
|
+
* ```ts
|
|
160
|
+
* const defaultColors = [
|
|
161
|
+
* {
|
|
162
|
+
* color: 'hsl(0, 0%, 0%)',
|
|
163
|
+
* label: 'Black'
|
|
164
|
+
* },
|
|
165
|
+
* {
|
|
166
|
+
* color: 'hsl(0, 0%, 30%)',
|
|
167
|
+
* label: 'Dim grey'
|
|
168
|
+
* },
|
|
169
|
+
* {
|
|
170
|
+
* color: 'hsl(0, 0%, 60%)',
|
|
171
|
+
* label: 'Grey'
|
|
172
|
+
* },
|
|
173
|
+
* {
|
|
174
|
+
* color: 'hsl(0, 0%, 90%)',
|
|
175
|
+
* label: 'Light grey'
|
|
176
|
+
* },
|
|
177
|
+
* {
|
|
178
|
+
* color: 'hsl(0, 0%, 100%)',
|
|
179
|
+
* label: 'White',
|
|
180
|
+
* hasBorder: true
|
|
181
|
+
* },
|
|
182
|
+
* {
|
|
183
|
+
* color: 'hsl(0, 75%, 60%)',
|
|
184
|
+
* label: 'Red'
|
|
185
|
+
* },
|
|
186
|
+
* {
|
|
187
|
+
* color: 'hsl(30, 75%, 60%)',
|
|
188
|
+
* label: 'Orange'
|
|
189
|
+
* },
|
|
190
|
+
* {
|
|
191
|
+
* color: 'hsl(60, 75%, 60%)',
|
|
192
|
+
* label: 'Yellow'
|
|
193
|
+
* },
|
|
194
|
+
* {
|
|
195
|
+
* color: 'hsl(90, 75%, 60%)',
|
|
196
|
+
* label: 'Light green'
|
|
197
|
+
* },
|
|
198
|
+
* {
|
|
199
|
+
* color: 'hsl(120, 75%, 60%)',
|
|
200
|
+
* label: 'Green'
|
|
201
|
+
* },
|
|
202
|
+
* {
|
|
203
|
+
* color: 'hsl(150, 75%, 60%)',
|
|
204
|
+
* label: 'Aquamarine'
|
|
205
|
+
* },
|
|
206
|
+
* {
|
|
207
|
+
* color: 'hsl(180, 75%, 60%)',
|
|
208
|
+
* label: 'Turquoise'
|
|
209
|
+
* },
|
|
210
|
+
* {
|
|
211
|
+
* color: 'hsl(210, 75%, 60%)',
|
|
212
|
+
* label: 'Light blue'
|
|
213
|
+
* },
|
|
214
|
+
* {
|
|
215
|
+
* color: 'hsl(240, 75%, 60%)',
|
|
216
|
+
* label: 'Blue'
|
|
217
|
+
* },
|
|
218
|
+
* {
|
|
219
|
+
* color: 'hsl(270, 75%, 60%)',
|
|
220
|
+
* label: 'Purple'
|
|
221
|
+
* }
|
|
222
|
+
* ];
|
|
223
|
+
* ```
|
|
274
224
|
*/
|
|
275
225
|
export const defaultColors = [
|
|
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
|
-
|
|
226
|
+
{
|
|
227
|
+
color: 'hsl(0, 0%, 0%)',
|
|
228
|
+
label: 'Black'
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
color: 'hsl(0, 0%, 30%)',
|
|
232
|
+
label: 'Dim grey'
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
color: 'hsl(0, 0%, 60%)',
|
|
236
|
+
label: 'Grey'
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
color: 'hsl(0, 0%, 90%)',
|
|
240
|
+
label: 'Light grey'
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
color: 'hsl(0, 0%, 100%)',
|
|
244
|
+
label: 'White',
|
|
245
|
+
hasBorder: true
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
color: 'hsl(0, 75%, 60%)',
|
|
249
|
+
label: 'Red'
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
color: 'hsl(30, 75%, 60%)',
|
|
253
|
+
label: 'Orange'
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
color: 'hsl(60, 75%, 60%)',
|
|
257
|
+
label: 'Yellow'
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
color: 'hsl(90, 75%, 60%)',
|
|
261
|
+
label: 'Light green'
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
color: 'hsl(120, 75%, 60%)',
|
|
265
|
+
label: 'Green'
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
color: 'hsl(150, 75%, 60%)',
|
|
269
|
+
label: 'Aquamarine'
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
color: 'hsl(180, 75%, 60%)',
|
|
273
|
+
label: 'Turquoise'
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
color: 'hsl(210, 75%, 60%)',
|
|
277
|
+
label: 'Light blue'
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
color: 'hsl(240, 75%, 60%)',
|
|
281
|
+
label: 'Blue'
|
|
282
|
+
},
|
|
283
|
+
{
|
|
284
|
+
color: 'hsl(270, 75%, 60%)',
|
|
285
|
+
label: 'Purple'
|
|
286
|
+
}
|
|
337
287
|
];
|
|
338
|
-
|
|
339
288
|
/**
|
|
340
289
|
* Returns a creator for a color input with a label.
|
|
341
290
|
*
|
|
@@ -352,68 +301,59 @@ export const defaultColors = [
|
|
|
352
301
|
*
|
|
353
302
|
* Usage:
|
|
354
303
|
*
|
|
355
|
-
*
|
|
356
|
-
*
|
|
357
|
-
*
|
|
358
|
-
*
|
|
304
|
+
* ```ts
|
|
305
|
+
* const colorInputCreator = getLabeledColorInputCreator( {
|
|
306
|
+
* colorConfig: [ ... ],
|
|
307
|
+
* columns: 3,
|
|
308
|
+
* } );
|
|
359
309
|
*
|
|
360
|
-
*
|
|
361
|
-
*
|
|
310
|
+
* const labeledInputView = new LabeledFieldView( locale, colorInputCreator );
|
|
311
|
+
* console.log( labeledInputView.view ); // A color input instance.
|
|
312
|
+
* ```
|
|
362
313
|
*
|
|
363
|
-
* @
|
|
314
|
+
* @internal
|
|
364
315
|
* @param options Color input options.
|
|
365
|
-
* @param
|
|
366
|
-
*
|
|
367
|
-
* @param
|
|
368
|
-
* in the input's dropdown.
|
|
369
|
-
* @param {String} [options.defaultColorValue] If specified, the color input view will replace the "Remove color" button with
|
|
316
|
+
* @param options.colorConfig The configuration of the color palette displayed in the input's dropdown.
|
|
317
|
+
* @param options.columns The configuration of the number of columns the color palette consists of in the input's dropdown.
|
|
318
|
+
* @param options.defaultColorValue If specified, the color input view will replace the "Remove color" button with
|
|
370
319
|
* the "Restore default" button. Instead of clearing the input field, the default color value will be set.
|
|
371
|
-
* @returns {Function}
|
|
372
320
|
*/
|
|
373
|
-
export function getLabeledColorInputCreator(
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
labeledFieldView.bind( 'isEmpty', 'isFocused' ).to( colorInputView );
|
|
396
|
-
|
|
397
|
-
return colorInputView;
|
|
398
|
-
};
|
|
321
|
+
export function getLabeledColorInputCreator(options) {
|
|
322
|
+
return (labeledFieldView, viewUid, statusUid) => {
|
|
323
|
+
const colorInputView = new ColorInputView(labeledFieldView.locale, {
|
|
324
|
+
colorDefinitions: colorConfigToColorGridDefinitions(options.colorConfig),
|
|
325
|
+
columns: options.columns,
|
|
326
|
+
defaultColorValue: options.defaultColorValue
|
|
327
|
+
});
|
|
328
|
+
colorInputView.inputView.set({
|
|
329
|
+
id: viewUid,
|
|
330
|
+
ariaDescribedById: statusUid
|
|
331
|
+
});
|
|
332
|
+
colorInputView.bind('isReadOnly').to(labeledFieldView, 'isEnabled', value => !value);
|
|
333
|
+
colorInputView.bind('hasError').to(labeledFieldView, 'errorText', value => !!value);
|
|
334
|
+
colorInputView.on('input', () => {
|
|
335
|
+
// UX: Make the error text disappear and disable the error indicator as the user
|
|
336
|
+
// starts fixing the errors.
|
|
337
|
+
labeledFieldView.errorText = null;
|
|
338
|
+
});
|
|
339
|
+
labeledFieldView.bind('isEmpty', 'isFocused').to(colorInputView);
|
|
340
|
+
return colorInputView;
|
|
341
|
+
};
|
|
399
342
|
}
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
343
|
+
/**
|
|
344
|
+
* A simple helper method to detect number strings.
|
|
345
|
+
* I allows full number notation, so omitting 0 is not allowed:
|
|
346
|
+
*/
|
|
347
|
+
function isNumberString(value) {
|
|
348
|
+
const parsedValue = parseFloat(value);
|
|
349
|
+
return !Number.isNaN(parsedValue) && value === String(parsedValue);
|
|
407
350
|
}
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
hasBorder: item.hasBorder
|
|
417
|
-
}
|
|
418
|
-
} ) );
|
|
351
|
+
function colorConfigToColorGridDefinitions(colorConfig) {
|
|
352
|
+
return colorConfig.map(item => ({
|
|
353
|
+
color: item.model,
|
|
354
|
+
label: item.label,
|
|
355
|
+
options: {
|
|
356
|
+
hasBorder: item.hasBorder
|
|
357
|
+
}
|
|
358
|
+
}));
|
|
419
359
|
}
|