@ckeditor/ckeditor5-ui 35.2.1 → 35.3.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.
- package/package.json +31 -23
- package/src/bindings/addkeyboardhandlingforgrid.js +45 -57
- package/src/bindings/clickoutsidehandler.js +15 -21
- package/src/bindings/injectcsstransitiondisabler.js +16 -20
- package/src/bindings/preventdefault.js +6 -8
- package/src/bindings/submithandler.js +5 -7
- package/src/button/button.js +5 -0
- package/src/button/buttonview.js +220 -259
- package/src/button/switchbuttonview.js +56 -71
- package/src/colorgrid/colorgridview.js +135 -197
- package/src/colorgrid/colortileview.js +37 -47
- package/src/colorgrid/utils.js +57 -66
- package/src/componentfactory.js +79 -93
- package/src/dropdown/button/dropdownbutton.js +5 -0
- package/src/dropdown/button/dropdownbuttonview.js +44 -57
- package/src/dropdown/button/splitbuttonview.js +159 -207
- package/src/dropdown/dropdownpanelfocusable.js +5 -0
- package/src/dropdown/dropdownpanelview.js +101 -112
- package/src/dropdown/dropdownview.js +396 -438
- package/src/dropdown/utils.js +164 -213
- package/src/editableui/editableuiview.js +125 -141
- package/src/editableui/inline/inlineeditableuiview.js +44 -54
- package/src/editorui/bodycollection.js +61 -75
- package/src/editorui/boxed/boxededitoruiview.js +91 -104
- package/src/editorui/editoruiview.js +30 -39
- package/src/focuscycler.js +214 -245
- package/src/formheader/formheaderview.js +58 -70
- package/src/icon/iconview.js +145 -111
- package/src/iframe/iframeview.js +37 -49
- package/src/index.js +0 -17
- package/src/input/inputview.js +170 -198
- package/src/inputnumber/inputnumberview.js +48 -56
- package/src/inputtext/inputtextview.js +14 -18
- package/src/label/labelview.js +44 -53
- package/src/labeledfield/labeledfieldview.js +212 -235
- package/src/labeledfield/utils.js +39 -57
- package/src/labeledinput/labeledinputview.js +190 -221
- package/src/list/listitemview.js +40 -50
- package/src/list/listseparatorview.js +15 -19
- package/src/list/listview.js +94 -115
- package/src/model.js +19 -25
- package/src/notification/notification.js +151 -202
- package/src/panel/balloon/balloonpanelview.js +535 -628
- package/src/panel/balloon/contextualballoon.js +611 -732
- package/src/panel/sticky/stickypanelview.js +238 -270
- package/src/template.js +1049 -1479
- package/src/toolbar/balloon/balloontoolbar.js +337 -424
- package/src/toolbar/block/blockbuttonview.js +32 -42
- package/src/toolbar/block/blocktoolbar.js +375 -477
- package/src/toolbar/normalizetoolbarconfig.js +17 -21
- package/src/toolbar/toolbarlinebreakview.js +15 -19
- package/src/toolbar/toolbarseparatorview.js +15 -19
- package/src/toolbar/toolbarview.js +866 -1053
- package/src/tooltipmanager.js +324 -353
- package/src/view.js +389 -430
- package/src/viewcollection.js +147 -178
- package/src/button/button.jsdoc +0 -165
- package/src/dropdown/button/dropdownbutton.jsdoc +0 -22
- package/src/dropdown/dropdownpanelfocusable.jsdoc +0 -27
|
@@ -2,216 +2,154 @@
|
|
|
2
2
|
* @license Copyright (c) 2003-2022, 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 ui/colorgrid/colorgrid
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
8
|
import View from '../view';
|
|
11
9
|
import ColorTileView from './colortileview';
|
|
12
10
|
import FocusTracker from '@ckeditor/ckeditor5-utils/src/focustracker';
|
|
13
11
|
import KeystrokeHandler from '@ckeditor/ckeditor5-utils/src/keystrokehandler';
|
|
14
12
|
import addKeyboardHandlingForGrid from '../bindings/addkeyboardhandlingforgrid';
|
|
15
|
-
|
|
16
13
|
import '../../theme/components/colorgrid/colorgrid.css';
|
|
17
|
-
|
|
18
14
|
/**
|
|
19
15
|
* A grid of {@link module:ui/colorgrid/colortile~ColorTileView color tiles}.
|
|
20
16
|
*
|
|
21
17
|
* @extends module:ui/view~View
|
|
22
18
|
*/
|
|
23
19
|
export default class ColorGridView extends View {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
this.focusTracker.remove( item.element );
|
|
160
|
-
} );
|
|
161
|
-
|
|
162
|
-
// Start listening for the keystrokes coming from #element.
|
|
163
|
-
this.keystrokes.listenTo( this.element );
|
|
164
|
-
|
|
165
|
-
addKeyboardHandlingForGrid( {
|
|
166
|
-
keystrokeHandler: this.keystrokes,
|
|
167
|
-
focusTracker: this.focusTracker,
|
|
168
|
-
gridItems: this.items,
|
|
169
|
-
numberOfColumns: this.columns
|
|
170
|
-
} );
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* @inheritDoc
|
|
175
|
-
*/
|
|
176
|
-
destroy() {
|
|
177
|
-
super.destroy();
|
|
178
|
-
|
|
179
|
-
this.focusTracker.destroy();
|
|
180
|
-
this.keystrokes.destroy();
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* Fired when the `ColorTileView` for the picked item is executed.
|
|
185
|
-
*
|
|
186
|
-
* @event execute
|
|
187
|
-
* @param {Object} data Additional information about the event.
|
|
188
|
-
* @param {String} data.value The value of the selected color
|
|
189
|
-
* ({@link module:ui/colorgrid/colorgrid~ColorDefinition#color `color.color`}).
|
|
190
|
-
* @param {Boolean} data.hasBorder The `hasBorder` property of the selected color
|
|
191
|
-
* ({@link module:ui/colorgrid/colorgrid~ColorDefinition#options `color.options.hasBorder`}).
|
|
192
|
-
* @param {String} data.Label The label of the selected color
|
|
193
|
-
* ({@link module:ui/colorgrid/colorgrid~ColorDefinition#label `color.label`})
|
|
194
|
-
*/
|
|
20
|
+
/**
|
|
21
|
+
* Creates an instance of a color grid containing {@link module:ui/colorgrid/colortile~ColorTileView tiles}.
|
|
22
|
+
*
|
|
23
|
+
* @param {module:utils/locale~Locale} [locale] The localization services instance.
|
|
24
|
+
* @param {Object} options Component configuration
|
|
25
|
+
* @param {Array.<module:ui/colorgrid/colorgrid~ColorDefinition>} [options.colorDefinitions] Array with definitions
|
|
26
|
+
* required to create the {@link module:ui/colorgrid/colortile~ColorTileView tiles}.
|
|
27
|
+
* @param {Number} [options.columns=5] A number of columns to display the tiles.
|
|
28
|
+
*/
|
|
29
|
+
constructor(locale, options) {
|
|
30
|
+
super(locale);
|
|
31
|
+
const colorDefinitions = options && options.colorDefinitions || [];
|
|
32
|
+
/**
|
|
33
|
+
* A number of columns for the tiles grid.
|
|
34
|
+
*
|
|
35
|
+
* @readonly
|
|
36
|
+
* @member {Number}
|
|
37
|
+
*/
|
|
38
|
+
this.columns = options && options.columns ? options.columns : 5;
|
|
39
|
+
const viewStyleAttribute = {
|
|
40
|
+
gridTemplateColumns: `repeat( ${this.columns}, 1fr)`
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* The color of the currently selected color tile in {@link #items}.
|
|
44
|
+
*
|
|
45
|
+
* @observable
|
|
46
|
+
* @type {String}
|
|
47
|
+
*/
|
|
48
|
+
this.set('selectedColor', undefined);
|
|
49
|
+
/**
|
|
50
|
+
* Collection of the child tile views.
|
|
51
|
+
*
|
|
52
|
+
* @readonly
|
|
53
|
+
* @member {module:ui/viewcollection~ViewCollection}
|
|
54
|
+
*/
|
|
55
|
+
this.items = this.createCollection();
|
|
56
|
+
/**
|
|
57
|
+
* Tracks information about DOM focus in the grid.
|
|
58
|
+
*
|
|
59
|
+
* @readonly
|
|
60
|
+
* @member {module:utils/focustracker~FocusTracker}
|
|
61
|
+
*/
|
|
62
|
+
this.focusTracker = new FocusTracker();
|
|
63
|
+
/**
|
|
64
|
+
* Instance of the {@link module:utils/keystrokehandler~KeystrokeHandler}.
|
|
65
|
+
*
|
|
66
|
+
* @readonly
|
|
67
|
+
* @member {module:utils/keystrokehandler~KeystrokeHandler}
|
|
68
|
+
*/
|
|
69
|
+
this.keystrokes = new KeystrokeHandler();
|
|
70
|
+
this.items.on('add', (evt, colorTile) => {
|
|
71
|
+
colorTile.isOn = colorTile.color === this.selectedColor;
|
|
72
|
+
});
|
|
73
|
+
colorDefinitions.forEach(color => {
|
|
74
|
+
const colorTile = new ColorTileView();
|
|
75
|
+
colorTile.set({
|
|
76
|
+
color: color.color,
|
|
77
|
+
label: color.label,
|
|
78
|
+
tooltip: true,
|
|
79
|
+
hasBorder: color.options.hasBorder
|
|
80
|
+
});
|
|
81
|
+
colorTile.on('execute', () => {
|
|
82
|
+
this.fire('execute', {
|
|
83
|
+
value: color.color,
|
|
84
|
+
hasBorder: color.options.hasBorder,
|
|
85
|
+
label: color.label
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
this.items.add(colorTile);
|
|
89
|
+
});
|
|
90
|
+
this.setTemplate({
|
|
91
|
+
tag: 'div',
|
|
92
|
+
children: this.items,
|
|
93
|
+
attributes: {
|
|
94
|
+
class: [
|
|
95
|
+
'ck',
|
|
96
|
+
'ck-color-grid'
|
|
97
|
+
],
|
|
98
|
+
style: viewStyleAttribute
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
this.on('change:selectedColor', (evt, name, selectedColor) => {
|
|
102
|
+
for (const item of this.items) {
|
|
103
|
+
item.isOn = item.color === selectedColor;
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Focuses the first focusable in {@link #items}.
|
|
109
|
+
*/
|
|
110
|
+
focus() {
|
|
111
|
+
if (this.items.length) {
|
|
112
|
+
this.items.first.focus();
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Focuses the last focusable in {@link #items}.
|
|
117
|
+
*/
|
|
118
|
+
focusLast() {
|
|
119
|
+
if (this.items.length) {
|
|
120
|
+
this.items.last.focus();
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* @inheritDoc
|
|
125
|
+
*/
|
|
126
|
+
render() {
|
|
127
|
+
super.render();
|
|
128
|
+
// Items added before rendering should be known to the #focusTracker.
|
|
129
|
+
for (const item of this.items) {
|
|
130
|
+
this.focusTracker.add(item.element);
|
|
131
|
+
}
|
|
132
|
+
this.items.on('add', (evt, item) => {
|
|
133
|
+
this.focusTracker.add(item.element);
|
|
134
|
+
});
|
|
135
|
+
this.items.on('remove', (evt, item) => {
|
|
136
|
+
this.focusTracker.remove(item.element);
|
|
137
|
+
});
|
|
138
|
+
// Start listening for the keystrokes coming from #element.
|
|
139
|
+
this.keystrokes.listenTo(this.element);
|
|
140
|
+
addKeyboardHandlingForGrid({
|
|
141
|
+
keystrokeHandler: this.keystrokes,
|
|
142
|
+
focusTracker: this.focusTracker,
|
|
143
|
+
gridItems: this.items,
|
|
144
|
+
numberOfColumns: this.columns
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* @inheritDoc
|
|
149
|
+
*/
|
|
150
|
+
destroy() {
|
|
151
|
+
super.destroy();
|
|
152
|
+
this.focusTracker.destroy();
|
|
153
|
+
this.keystrokes.destroy();
|
|
154
|
+
}
|
|
195
155
|
}
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* A color definition used to create a {@link module:ui/colorgrid/colortile~ColorTileView}.
|
|
199
|
-
*
|
|
200
|
-
* {
|
|
201
|
-
* color: 'hsl(0, 0%, 75%)',
|
|
202
|
-
* label: 'Light Grey',
|
|
203
|
-
* options: {
|
|
204
|
-
* hasBorder: true
|
|
205
|
-
* }
|
|
206
|
-
* }
|
|
207
|
-
*
|
|
208
|
-
* @typedef {Object} module:ui/colorgrid/colorgrid~ColorDefinition
|
|
209
|
-
* @type Object
|
|
210
|
-
*
|
|
211
|
-
* @property {String} color String representing a color.
|
|
212
|
-
* It is used as value of background-color style in {@link module:ui/colorgrid/colortile~ColorTileView}.
|
|
213
|
-
* @property {String} label String used as label for {@link module:ui/colorgrid/colortile~ColorTileView}.
|
|
214
|
-
* @property {Object} options Additional options passed to create a {@link module:ui/colorgrid/colortile~ColorTileView}.
|
|
215
|
-
* @property {Boolean} options.hasBorder A flag that indicates if special a CSS class should be added
|
|
216
|
-
* to {@link module:ui/colorgrid/colortile~ColorTileView}, which renders a border around it.
|
|
217
|
-
*/
|
|
@@ -2,62 +2,52 @@
|
|
|
2
2
|
* @license Copyright (c) 2003-2022, 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 ui/colorgrid/colortile
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
8
|
import ButtonView from '../button/buttonview';
|
|
11
9
|
import checkIcon from '../../theme/icons/color-tile-check.svg';
|
|
12
|
-
|
|
13
10
|
/**
|
|
14
11
|
* This class represents a single color tile in the {@link module:ui/colorgrid/colorgrid~ColorGridView}.
|
|
15
12
|
*
|
|
16
13
|
* @extends module:ui/button/buttonview~ButtonView
|
|
17
14
|
*/
|
|
18
15
|
export default class ColorTileView extends ButtonView {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
* @inheritDoc
|
|
57
|
-
*/
|
|
58
|
-
render() {
|
|
59
|
-
super.render();
|
|
60
|
-
|
|
61
|
-
this.iconView.fillColor = 'hsl(0, 0%, 100%)';
|
|
62
|
-
}
|
|
16
|
+
constructor(locale) {
|
|
17
|
+
super(locale);
|
|
18
|
+
const bind = this.bindTemplate;
|
|
19
|
+
/**
|
|
20
|
+
* String representing a color shown as tile's background.
|
|
21
|
+
*
|
|
22
|
+
* @type {String}
|
|
23
|
+
*/
|
|
24
|
+
this.set('color', undefined);
|
|
25
|
+
/**
|
|
26
|
+
* A flag that toggles a special CSS class responsible for displaying
|
|
27
|
+
* a border around the button.
|
|
28
|
+
*
|
|
29
|
+
* @type {Boolean}
|
|
30
|
+
*/
|
|
31
|
+
this.set('hasBorder', false);
|
|
32
|
+
this.icon = checkIcon;
|
|
33
|
+
this.extendTemplate({
|
|
34
|
+
attributes: {
|
|
35
|
+
style: {
|
|
36
|
+
backgroundColor: bind.to('color')
|
|
37
|
+
},
|
|
38
|
+
class: [
|
|
39
|
+
'ck',
|
|
40
|
+
'ck-color-grid__tile',
|
|
41
|
+
bind.if('hasBorder', 'ck-color-table__color-tile_bordered')
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* @inheritDoc
|
|
48
|
+
*/
|
|
49
|
+
render() {
|
|
50
|
+
super.render();
|
|
51
|
+
this.iconView.fillColor = 'hsl(0, 0%, 100%)';
|
|
52
|
+
}
|
|
63
53
|
}
|
package/src/colorgrid/utils.js
CHANGED
|
@@ -2,11 +2,6 @@
|
|
|
2
2
|
* @license Copyright (c) 2003-2022, 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
|
-
/**
|
|
7
|
-
* @module ui/colorgrid/utils
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
5
|
/**
|
|
11
6
|
* Returns color configuration options as defined in `editor.config.(fontColor|fontBackgroundColor).colors` or
|
|
12
7
|
* `editor.config.table.(tableProperties|tableCellProperties).(background|border).colors
|
|
@@ -19,37 +14,33 @@
|
|
|
19
14
|
* @param {Array.<module:ui/colorgrid/colorgrid~ColorDefinition>} options
|
|
20
15
|
* @returns {Array.<module:ui/colorgrid/colorgrid~ColorDefinition>}.
|
|
21
16
|
*/
|
|
22
|
-
export function getLocalizedColorOptions(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
return colorOption;
|
|
50
|
-
} );
|
|
17
|
+
export function getLocalizedColorOptions(locale, options) {
|
|
18
|
+
const t = locale.t;
|
|
19
|
+
const localizedColorNames = {
|
|
20
|
+
Black: t('Black'),
|
|
21
|
+
'Dim grey': t('Dim grey'),
|
|
22
|
+
Grey: t('Grey'),
|
|
23
|
+
'Light grey': t('Light grey'),
|
|
24
|
+
White: t('White'),
|
|
25
|
+
Red: t('Red'),
|
|
26
|
+
Orange: t('Orange'),
|
|
27
|
+
Yellow: t('Yellow'),
|
|
28
|
+
'Light green': t('Light green'),
|
|
29
|
+
Green: t('Green'),
|
|
30
|
+
Aquamarine: t('Aquamarine'),
|
|
31
|
+
Turquoise: t('Turquoise'),
|
|
32
|
+
'Light blue': t('Light blue'),
|
|
33
|
+
Blue: t('Blue'),
|
|
34
|
+
Purple: t('Purple')
|
|
35
|
+
};
|
|
36
|
+
return options.map(colorOption => {
|
|
37
|
+
const label = localizedColorNames[colorOption.label];
|
|
38
|
+
if (label && label != colorOption.label) {
|
|
39
|
+
colorOption.label = label;
|
|
40
|
+
}
|
|
41
|
+
return colorOption;
|
|
42
|
+
});
|
|
51
43
|
}
|
|
52
|
-
|
|
53
44
|
/**
|
|
54
45
|
* Creates a unified color definition object from color configuration options.
|
|
55
46
|
* The object contains the information necessary to both render the UI and initialize the conversion.
|
|
@@ -57,12 +48,11 @@ export function getLocalizedColorOptions( locale, options ) {
|
|
|
57
48
|
* @param {module:ui/colorgrid/colorgrid~ColorDefinition} options
|
|
58
49
|
* @returns {Array.<module:ui/colorgrid/colorgrid~ColorDefinition>}
|
|
59
50
|
*/
|
|
60
|
-
export function normalizeColorOptions(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
51
|
+
export function normalizeColorOptions(options) {
|
|
52
|
+
return options
|
|
53
|
+
.map(normalizeSingleColorDefinition)
|
|
54
|
+
.filter(option => !!option);
|
|
64
55
|
}
|
|
65
|
-
|
|
66
56
|
// Creates a normalized color definition from the user-defined configuration.
|
|
67
57
|
// The "normalization" means it will create full
|
|
68
58
|
// {@link module:ui/colorgrid/colorgrid~ColorDefinition `ColorDefinition-like`}
|
|
@@ -70,30 +60,31 @@ export function normalizeColorOptions( options ) {
|
|
|
70
60
|
//
|
|
71
61
|
// @param {String|module:ui/colorgrid/colorgrid~ColorDefinition}
|
|
72
62
|
// @returns {module:ui/colorgrid/colorgrid~ColorDefinition}
|
|
73
|
-
export function normalizeSingleColorDefinition(
|
|
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
|
-
|
|
63
|
+
export function normalizeSingleColorDefinition(color) {
|
|
64
|
+
if (typeof color === 'string') {
|
|
65
|
+
return {
|
|
66
|
+
model: color,
|
|
67
|
+
label: color,
|
|
68
|
+
hasBorder: false,
|
|
69
|
+
view: {
|
|
70
|
+
name: 'span',
|
|
71
|
+
styles: {
|
|
72
|
+
color
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
return {
|
|
79
|
+
model: color.color,
|
|
80
|
+
label: color.label || color.color,
|
|
81
|
+
hasBorder: color.hasBorder === undefined ? false : color.hasBorder,
|
|
82
|
+
view: {
|
|
83
|
+
name: 'span',
|
|
84
|
+
styles: {
|
|
85
|
+
color: `${color.color}`
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
}
|
|
99
90
|
}
|