@ckeditor/ckeditor5-ui 38.2.0-alpha.0 → 39.0.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/README.md +0 -1
- package/lang/contexts.json +2 -1
- package/lang/translations/ar.po +5 -1
- package/lang/translations/ast.po +4 -0
- package/lang/translations/az.po +4 -0
- package/lang/translations/bg.po +5 -1
- package/lang/translations/bn.po +5 -1
- package/lang/translations/ca.po +5 -1
- package/lang/translations/cs.po +5 -1
- package/lang/translations/da.po +5 -1
- package/lang/translations/de-ch.po +4 -0
- package/lang/translations/de.po +5 -1
- package/lang/translations/el.po +5 -1
- package/lang/translations/en-au.po +4 -0
- package/lang/translations/en-gb.po +4 -0
- package/lang/translations/en.po +4 -0
- package/lang/translations/eo.po +4 -0
- package/lang/translations/es.po +5 -1
- package/lang/translations/et.po +5 -1
- package/lang/translations/eu.po +4 -0
- package/lang/translations/fa.po +4 -0
- package/lang/translations/fi.po +5 -1
- package/lang/translations/fr.po +5 -1
- package/lang/translations/gl.po +7 -3
- package/lang/translations/he.po +5 -1
- package/lang/translations/hi.po +5 -1
- package/lang/translations/hr.po +6 -2
- package/lang/translations/hu.po +5 -1
- package/lang/translations/id.po +5 -1
- package/lang/translations/it.po +4 -0
- package/lang/translations/ja.po +5 -1
- package/lang/translations/km.po +4 -0
- package/lang/translations/kn.po +4 -0
- package/lang/translations/ko.po +5 -1
- package/lang/translations/ku.po +4 -0
- package/lang/translations/lt.po +5 -1
- package/lang/translations/lv.po +5 -1
- package/lang/translations/ms.po +5 -1
- package/lang/translations/nb.po +4 -0
- package/lang/translations/ne.po +4 -0
- package/lang/translations/nl.po +5 -1
- package/lang/translations/no.po +5 -1
- package/lang/translations/pl.po +5 -1
- package/lang/translations/pt-br.po +5 -1
- package/lang/translations/pt.po +5 -1
- package/lang/translations/ro.po +5 -1
- package/lang/translations/ru.po +5 -1
- package/lang/translations/sk.po +5 -1
- package/lang/translations/sl.po +4 -0
- package/lang/translations/sq.po +17 -13
- package/lang/translations/sr-latn.po +4 -0
- package/lang/translations/sr.po +5 -1
- package/lang/translations/sv.po +5 -1
- package/lang/translations/th.po +5 -1
- package/lang/translations/tk.po +4 -0
- package/lang/translations/tr.po +5 -1
- package/lang/translations/tt.po +4 -0
- package/lang/translations/ug.po +4 -0
- package/lang/translations/uk.po +5 -1
- package/lang/translations/ur.po +4 -0
- package/lang/translations/uz.po +4 -0
- package/lang/translations/vi.po +5 -1
- package/lang/translations/zh-cn.po +5 -1
- package/lang/translations/zh.po +5 -1
- package/package.json +4 -5
- package/src/colorgrid/colortileview.js +1 -1
- package/src/colorpicker/colorpickerview.d.ts +35 -8
- package/src/colorpicker/colorpickerview.js +29 -12
- package/src/colorpicker/utils.d.ts +8 -0
- package/src/colorselector/colorgridsfragmentview.d.ts +194 -0
- package/src/colorselector/colorgridsfragmentview.js +289 -0
- package/src/colorselector/colorpickerfragmentview.d.ts +128 -0
- package/src/colorselector/colorpickerfragmentview.js +205 -0
- package/src/colorselector/colorselectorview.d.ts +242 -0
- package/src/colorselector/colorselectorview.js +256 -0
- package/src/colorselector/documentcolorcollection.d.ts +70 -0
- package/src/colorselector/documentcolorcollection.js +42 -0
- package/src/dropdown/dropdownpanelview.js +2 -1
- package/src/dropdown/utils.js +4 -1
- package/src/editorui/poweredby.js +6 -1
- package/src/index.d.ts +2 -1
- package/src/index.js +1 -0
- package/src/panel/sticky/stickypanelview.d.ts +41 -15
- package/src/panel/sticky/stickypanelview.js +138 -46
- package/theme/components/colorpicker/colorpicker.css +10 -0
- package/theme/components/colorselector/colorselector.css +35 -0
- package/theme/icons/project-logo.svg +1 -1
package/lang/translations/sr.po
CHANGED
|
@@ -114,4 +114,8 @@ msgstr "Контекстуална трака са алаткама Едитор
|
|
|
114
114
|
|
|
115
115
|
msgctxt "Label of an input field for typing colors in the HEX color format."
|
|
116
116
|
msgid "HEX"
|
|
117
|
-
msgstr ""
|
|
117
|
+
msgstr "HEX"
|
|
118
|
+
|
|
119
|
+
msgctxt "Label of the button closing the color picker and confirming the changes done in the color selector component."
|
|
120
|
+
msgid "Accept"
|
|
121
|
+
msgstr "Prihvati"
|
package/lang/translations/sv.po
CHANGED
|
@@ -114,4 +114,8 @@ msgstr "Ordbehandlarens kontextuella verktygsfält"
|
|
|
114
114
|
|
|
115
115
|
msgctxt "Label of an input field for typing colors in the HEX color format."
|
|
116
116
|
msgid "HEX"
|
|
117
|
-
msgstr ""
|
|
117
|
+
msgstr "HEX"
|
|
118
|
+
|
|
119
|
+
msgctxt "Label of the button closing the color picker and confirming the changes done in the color selector component."
|
|
120
|
+
msgid "Accept"
|
|
121
|
+
msgstr "Acceptera"
|
package/lang/translations/th.po
CHANGED
|
@@ -114,4 +114,8 @@ msgstr "แถบเครื่องมือแก้ไขข้อควา
|
|
|
114
114
|
|
|
115
115
|
msgctxt "Label of an input field for typing colors in the HEX color format."
|
|
116
116
|
msgid "HEX"
|
|
117
|
-
msgstr ""
|
|
117
|
+
msgstr "HEX"
|
|
118
|
+
|
|
119
|
+
msgctxt "Label of the button closing the color picker and confirming the changes done in the color selector component."
|
|
120
|
+
msgid "Accept"
|
|
121
|
+
msgstr "ยอมรับ"
|
package/lang/translations/tk.po
CHANGED
|
@@ -115,3 +115,7 @@ msgstr ""
|
|
|
115
115
|
msgctxt "Label of an input field for typing colors in the HEX color format."
|
|
116
116
|
msgid "HEX"
|
|
117
117
|
msgstr ""
|
|
118
|
+
|
|
119
|
+
msgctxt "Label of the button closing the color picker and confirming the changes done in the color selector component."
|
|
120
|
+
msgid "Accept"
|
|
121
|
+
msgstr ""
|
package/lang/translations/tr.po
CHANGED
|
@@ -114,4 +114,8 @@ msgstr "Düzenleyici içeriksel araç çubuğu"
|
|
|
114
114
|
|
|
115
115
|
msgctxt "Label of an input field for typing colors in the HEX color format."
|
|
116
116
|
msgid "HEX"
|
|
117
|
-
msgstr ""
|
|
117
|
+
msgstr "ONALTILIK"
|
|
118
|
+
|
|
119
|
+
msgctxt "Label of the button closing the color picker and confirming the changes done in the color selector component."
|
|
120
|
+
msgid "Accept"
|
|
121
|
+
msgstr "Kabul et"
|
package/lang/translations/tt.po
CHANGED
|
@@ -115,3 +115,7 @@ msgstr ""
|
|
|
115
115
|
msgctxt "Label of an input field for typing colors in the HEX color format."
|
|
116
116
|
msgid "HEX"
|
|
117
117
|
msgstr ""
|
|
118
|
+
|
|
119
|
+
msgctxt "Label of the button closing the color picker and confirming the changes done in the color selector component."
|
|
120
|
+
msgid "Accept"
|
|
121
|
+
msgstr ""
|
package/lang/translations/ug.po
CHANGED
|
@@ -115,3 +115,7 @@ msgstr ""
|
|
|
115
115
|
msgctxt "Label of an input field for typing colors in the HEX color format."
|
|
116
116
|
msgid "HEX"
|
|
117
117
|
msgstr ""
|
|
118
|
+
|
|
119
|
+
msgctxt "Label of the button closing the color picker and confirming the changes done in the color selector component."
|
|
120
|
+
msgid "Accept"
|
|
121
|
+
msgstr "قوشۇل"
|
package/lang/translations/uk.po
CHANGED
|
@@ -114,4 +114,8 @@ msgstr "Контекстна панель інструментів редакт
|
|
|
114
114
|
|
|
115
115
|
msgctxt "Label of an input field for typing colors in the HEX color format."
|
|
116
116
|
msgid "HEX"
|
|
117
|
-
msgstr ""
|
|
117
|
+
msgstr "Шістнадцятковий"
|
|
118
|
+
|
|
119
|
+
msgctxt "Label of the button closing the color picker and confirming the changes done in the color selector component."
|
|
120
|
+
msgid "Accept"
|
|
121
|
+
msgstr "Прийняти"
|
package/lang/translations/ur.po
CHANGED
|
@@ -115,3 +115,7 @@ msgstr ""
|
|
|
115
115
|
msgctxt "Label of an input field for typing colors in the HEX color format."
|
|
116
116
|
msgid "HEX"
|
|
117
117
|
msgstr ""
|
|
118
|
+
|
|
119
|
+
msgctxt "Label of the button closing the color picker and confirming the changes done in the color selector component."
|
|
120
|
+
msgid "Accept"
|
|
121
|
+
msgstr ""
|
package/lang/translations/uz.po
CHANGED
|
@@ -115,3 +115,7 @@ msgstr ""
|
|
|
115
115
|
msgctxt "Label of an input field for typing colors in the HEX color format."
|
|
116
116
|
msgid "HEX"
|
|
117
117
|
msgstr ""
|
|
118
|
+
|
|
119
|
+
msgctxt "Label of the button closing the color picker and confirming the changes done in the color selector component."
|
|
120
|
+
msgid "Accept"
|
|
121
|
+
msgstr ""
|
package/lang/translations/vi.po
CHANGED
|
@@ -114,4 +114,8 @@ msgstr "Thanh công cụ chỉnh sửa theo ngữ cảnh"
|
|
|
114
114
|
|
|
115
115
|
msgctxt "Label of an input field for typing colors in the HEX color format."
|
|
116
116
|
msgid "HEX"
|
|
117
|
-
msgstr ""
|
|
117
|
+
msgstr "HEX"
|
|
118
|
+
|
|
119
|
+
msgctxt "Label of the button closing the color picker and confirming the changes done in the color selector component."
|
|
120
|
+
msgid "Accept"
|
|
121
|
+
msgstr "Chấp nhận"
|
|
@@ -114,4 +114,8 @@ msgstr "编辑器上下文工具栏"
|
|
|
114
114
|
|
|
115
115
|
msgctxt "Label of an input field for typing colors in the HEX color format."
|
|
116
116
|
msgid "HEX"
|
|
117
|
-
msgstr ""
|
|
117
|
+
msgstr "十六进制"
|
|
118
|
+
|
|
119
|
+
msgctxt "Label of the button closing the color picker and confirming the changes done in the color selector component."
|
|
120
|
+
msgid "Accept"
|
|
121
|
+
msgstr "接受"
|
package/lang/translations/zh.po
CHANGED
|
@@ -114,4 +114,8 @@ msgstr "編輯器關聯式工具列"
|
|
|
114
114
|
|
|
115
115
|
msgctxt "Label of an input field for typing colors in the HEX color format."
|
|
116
116
|
msgid "HEX"
|
|
117
|
-
msgstr ""
|
|
117
|
+
msgstr "十六進位"
|
|
118
|
+
|
|
119
|
+
msgctxt "Label of the button closing the color picker and confirming the changes done in the color selector component."
|
|
120
|
+
msgid "Accept"
|
|
121
|
+
msgstr "接受"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckeditor/ckeditor5-ui",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "39.0.0",
|
|
4
4
|
"description": "The UI framework and standard UI library of CKEditor 5.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ckeditor",
|
|
@@ -10,13 +10,12 @@
|
|
|
10
10
|
"ckeditor5-dll"
|
|
11
11
|
],
|
|
12
12
|
"main": "src/index.js",
|
|
13
|
-
"type": "module",
|
|
14
13
|
"dependencies": {
|
|
15
|
-
"@ckeditor/ckeditor5-core": "
|
|
16
|
-
"@ckeditor/ckeditor5-utils": "
|
|
14
|
+
"@ckeditor/ckeditor5-core": "39.0.0",
|
|
15
|
+
"@ckeditor/ckeditor5-utils": "39.0.0",
|
|
17
16
|
"color-convert": "2.0.1",
|
|
18
17
|
"color-parse": "1.4.2",
|
|
19
|
-
"lodash-es": "
|
|
18
|
+
"lodash-es": "4.17.21",
|
|
20
19
|
"vanilla-colorful": "0.7.2"
|
|
21
20
|
},
|
|
22
21
|
"engines": {
|
|
@@ -5,12 +5,15 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module ui/colorpicker/colorpickerview
|
|
7
7
|
*/
|
|
8
|
-
import { type
|
|
8
|
+
import { type ColorPickerViewConfig } from './utils';
|
|
9
9
|
import { type Locale } from '@ckeditor/ckeditor5-utils';
|
|
10
10
|
import View from '../view';
|
|
11
11
|
import type ViewCollection from '../viewcollection';
|
|
12
12
|
import 'vanilla-colorful/hex-color-picker.js';
|
|
13
13
|
import '../../theme/components/colorpicker/colorpicker.css';
|
|
14
|
+
/**
|
|
15
|
+
* A class which represents a color picker with an input field for defining custom colors.
|
|
16
|
+
*/
|
|
14
17
|
export default class ColorPickerView extends View {
|
|
15
18
|
/**
|
|
16
19
|
* Element with saturation and hue sliders.
|
|
@@ -22,7 +25,8 @@ export default class ColorPickerView extends View {
|
|
|
22
25
|
*/
|
|
23
26
|
hexInputRow: ColorPickerInputRowView;
|
|
24
27
|
/**
|
|
25
|
-
* Current color
|
|
28
|
+
* Current color selected in the color picker. It can be set by the component itself
|
|
29
|
+
* (through the palette or input) or from the outside (e.g. to reflect the current selection color).
|
|
26
30
|
*/
|
|
27
31
|
color: string;
|
|
28
32
|
/**
|
|
@@ -42,21 +46,26 @@ export default class ColorPickerView extends View {
|
|
|
42
46
|
*/
|
|
43
47
|
_hexColor: string;
|
|
44
48
|
/**
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
49
|
+
* Debounced function updating the `color` property in the component
|
|
50
|
+
* and firing the `ColorPickerColorSelectedEvent`. Executed whenever color in component
|
|
51
|
+
* is changed by the user interaction (through the palette or input).
|
|
52
|
+
*
|
|
53
|
+
* @private
|
|
54
|
+
*/
|
|
48
55
|
private _debounceColorPickerEvent;
|
|
49
56
|
/**
|
|
50
|
-
*
|
|
57
|
+
* A reference to the configuration of the color picker specified in the constructor.
|
|
58
|
+
*
|
|
59
|
+
* @private
|
|
51
60
|
*/
|
|
52
|
-
private
|
|
61
|
+
private _config;
|
|
53
62
|
/**
|
|
54
63
|
* Creates a view of color picker.
|
|
55
64
|
*
|
|
56
65
|
* @param locale
|
|
57
66
|
* @param config
|
|
58
67
|
*/
|
|
59
|
-
constructor(locale: Locale | undefined, config
|
|
68
|
+
constructor(locale: Locale | undefined, config?: ColorPickerViewConfig);
|
|
60
69
|
/**
|
|
61
70
|
* Renders color picker in the view.
|
|
62
71
|
*/
|
|
@@ -107,4 +116,22 @@ declare class ColorPickerInputRowView extends View {
|
|
|
107
116
|
*/
|
|
108
117
|
constructor(locale: Locale, children?: Array<View>);
|
|
109
118
|
}
|
|
119
|
+
/**
|
|
120
|
+
* An event fired whenever the color was selected through the color picker palette
|
|
121
|
+
* or the color picker input.
|
|
122
|
+
*
|
|
123
|
+
* This even fires only when the user changes the color. It does not fire when the color
|
|
124
|
+
* is changed programmatically, e.g. via
|
|
125
|
+
* {@link module:ui/colorpicker/colorpickerview~ColorPickerView#color}.
|
|
126
|
+
*
|
|
127
|
+
* @eventName ~ColorPickerView#colorSelected
|
|
128
|
+
*/
|
|
129
|
+
export type ColorPickerColorSelectedEvent = {
|
|
130
|
+
name: 'colorSelected';
|
|
131
|
+
args: [
|
|
132
|
+
{
|
|
133
|
+
color: string;
|
|
134
|
+
}
|
|
135
|
+
];
|
|
136
|
+
};
|
|
110
137
|
export {};
|
|
@@ -14,6 +14,9 @@ import { createLabeledInputText } from '../labeledfield/utils';
|
|
|
14
14
|
import 'vanilla-colorful/hex-color-picker.js';
|
|
15
15
|
import '../../theme/components/colorpicker/colorpicker.css';
|
|
16
16
|
const waitingTime = 150;
|
|
17
|
+
/**
|
|
18
|
+
* A class which represents a color picker with an input field for defining custom colors.
|
|
19
|
+
*/
|
|
17
20
|
export default class ColorPickerView extends View {
|
|
18
21
|
/**
|
|
19
22
|
* Creates a view of color picker.
|
|
@@ -21,14 +24,17 @@ export default class ColorPickerView extends View {
|
|
|
21
24
|
* @param locale
|
|
22
25
|
* @param config
|
|
23
26
|
*/
|
|
24
|
-
constructor(locale, config) {
|
|
27
|
+
constructor(locale, config = {}) {
|
|
25
28
|
super(locale);
|
|
26
|
-
this.set(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
this.set({
|
|
30
|
+
color: '',
|
|
31
|
+
_hexColor: ''
|
|
32
|
+
});
|
|
29
33
|
this.hexInputRow = this._createInputRow();
|
|
30
34
|
const children = this.createCollection();
|
|
31
|
-
|
|
35
|
+
if (!config.hideInput) {
|
|
36
|
+
children.add(this.hexInputRow);
|
|
37
|
+
}
|
|
32
38
|
this.setTemplate({
|
|
33
39
|
tag: 'div',
|
|
34
40
|
attributes: {
|
|
@@ -37,21 +43,27 @@ export default class ColorPickerView extends View {
|
|
|
37
43
|
},
|
|
38
44
|
children
|
|
39
45
|
});
|
|
46
|
+
this._config = config;
|
|
40
47
|
this._debounceColorPickerEvent = debounce((color) => {
|
|
48
|
+
// At first, set the color internally in the component. It's converted to the configured output format.
|
|
41
49
|
this.set('color', color);
|
|
50
|
+
// Then let the outside world know that the user changed the color.
|
|
51
|
+
this.fire('colorSelected', { color: this.color });
|
|
42
52
|
}, waitingTime, {
|
|
43
53
|
leading: true
|
|
44
54
|
});
|
|
45
|
-
//
|
|
55
|
+
// The `color` property holds the color in the configured output format.
|
|
56
|
+
// Ensure it before actually setting the value.
|
|
46
57
|
this.on('set:color', (evt, propertyName, newValue) => {
|
|
47
|
-
|
|
48
|
-
evt.return = convertColor(newValue, this._format);
|
|
58
|
+
evt.return = convertColor(newValue, this._config.format || 'hsl');
|
|
49
59
|
});
|
|
60
|
+
// The `_hexColor` property is bound to the `color` one, but requires conversion.
|
|
50
61
|
this.on('change:color', () => {
|
|
51
62
|
this._hexColor = convertColorToCommonHexFormat(this.color);
|
|
52
63
|
});
|
|
53
64
|
this.on('change:_hexColor', () => {
|
|
54
|
-
//
|
|
65
|
+
// Update the selected color in the color picker palette when it's not focused.
|
|
66
|
+
// It means the user typed the color in the input.
|
|
55
67
|
if (document.activeElement !== this.picker) {
|
|
56
68
|
this.picker.setAttribute('color', this._hexColor);
|
|
57
69
|
}
|
|
@@ -72,7 +84,12 @@ export default class ColorPickerView extends View {
|
|
|
72
84
|
this.picker.setAttribute('tabindex', '-1');
|
|
73
85
|
this._createSlidersView();
|
|
74
86
|
if (this.element) {
|
|
75
|
-
|
|
87
|
+
if (this.hexInputRow.element) {
|
|
88
|
+
this.element.insertBefore(this.picker, this.hexInputRow.element);
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
this.element.appendChild(this.picker);
|
|
92
|
+
}
|
|
76
93
|
// Create custom stylesheet with a look of focused pointer in color picker and append it into the color picker shadowDom
|
|
77
94
|
const styleSheetForFocusedColorPicker = document.createElement('style');
|
|
78
95
|
styleSheetForFocusedColorPicker.textContent = '[role="slider"]:focus [part$="pointer"] {' +
|
|
@@ -101,7 +118,7 @@ export default class ColorPickerView extends View {
|
|
|
101
118
|
// See: https://github.com/cksource/ckeditor5-internal/issues/3245, https://github.com/ckeditor/ckeditor5/issues/14119,
|
|
102
119
|
// https://github.com/cksource/ckeditor5-internal/issues/3268.
|
|
103
120
|
/* istanbul ignore next -- @preserve */
|
|
104
|
-
if (env.isGecko || env.isiOS || env.isSafari) {
|
|
121
|
+
if (!this._config.hideInput && (env.isGecko || env.isiOS || env.isSafari)) {
|
|
105
122
|
const input = this.hexInputRow.children.get(1);
|
|
106
123
|
input.focus();
|
|
107
124
|
}
|
|
@@ -209,7 +226,7 @@ class SliderView extends View {
|
|
|
209
226
|
this.element.focus();
|
|
210
227
|
}
|
|
211
228
|
}
|
|
212
|
-
// View
|
|
229
|
+
// View abstraction over the `#` character before color input.
|
|
213
230
|
class HashView extends View {
|
|
214
231
|
constructor(locale) {
|
|
215
232
|
super(locale);
|
|
@@ -18,6 +18,14 @@ export type ColorPickerOutputFormat = 'hex' | 'rgb' | 'hsl' | 'hwb' | 'lab' | 'l
|
|
|
18
18
|
export type ColorPickerConfig = {
|
|
19
19
|
format?: ColorPickerOutputFormat;
|
|
20
20
|
};
|
|
21
|
+
/**
|
|
22
|
+
* Configuration of the color picker view.
|
|
23
|
+
*
|
|
24
|
+
* It can be used to enforce a particular color format or hide the color input.
|
|
25
|
+
*/
|
|
26
|
+
export type ColorPickerViewConfig = ColorPickerConfig & {
|
|
27
|
+
hideInput?: boolean;
|
|
28
|
+
};
|
|
21
29
|
/**
|
|
22
30
|
* Parses and converts the color string to requested format. Handles variety of color spaces
|
|
23
31
|
* like `hsl`, `hex` or `rgb`.
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module ui/colorselector/colorgridsfragmentview
|
|
7
|
+
*/
|
|
8
|
+
import View from '../view';
|
|
9
|
+
import ButtonView from '../button/buttonview';
|
|
10
|
+
import ColorGridView, { type ColorDefinition } from '../colorgrid/colorgridview';
|
|
11
|
+
import DocumentColorCollection from './documentcolorcollection';
|
|
12
|
+
import type { Model } from '@ckeditor/ckeditor5-engine';
|
|
13
|
+
import type { FocusTracker, Locale } from '@ckeditor/ckeditor5-utils';
|
|
14
|
+
import type ViewCollection from '../viewcollection';
|
|
15
|
+
/**
|
|
16
|
+
* One of the fragments of {@link module:ui/colorselector/colorselectorview~ColorSelectorView}.
|
|
17
|
+
*
|
|
18
|
+
* It provides a UI that allows users to select colors from the a predefined set and from existing document colors.
|
|
19
|
+
*
|
|
20
|
+
* It consists of the following sub–components:
|
|
21
|
+
*
|
|
22
|
+
* * A "Remove color" button,
|
|
23
|
+
* * A static {@link module:ui/colorgrid/colorgridview~ColorGridView} of colors defined in the configuration,
|
|
24
|
+
* * A dynamic {@link module:ui/colorgrid/colorgridview~ColorGridView} of colors used in the document.
|
|
25
|
+
* * If color picker is configured, the "Color Picker" button is visible too.
|
|
26
|
+
*/
|
|
27
|
+
export default class ColorGridsFragmentView extends View {
|
|
28
|
+
/**
|
|
29
|
+
* A collection of the children of the table.
|
|
30
|
+
*/
|
|
31
|
+
readonly items: ViewCollection;
|
|
32
|
+
/**
|
|
33
|
+
* An array with objects representing colors to be displayed in the grid.
|
|
34
|
+
*/
|
|
35
|
+
colorDefinitions: Array<ColorDefinition>;
|
|
36
|
+
/**
|
|
37
|
+
* Tracks information about the DOM focus in the list.
|
|
38
|
+
*/
|
|
39
|
+
readonly focusTracker: FocusTracker;
|
|
40
|
+
/**
|
|
41
|
+
* The number of columns in the color grid.
|
|
42
|
+
*/
|
|
43
|
+
columns: number;
|
|
44
|
+
/**
|
|
45
|
+
* Preserves the reference to {@link module:ui/colorselector/documentcolorcollection~DocumentColorCollection} used to collect
|
|
46
|
+
* definitions that store the document colors.
|
|
47
|
+
*
|
|
48
|
+
* @readonly
|
|
49
|
+
*/
|
|
50
|
+
documentColors: DocumentColorCollection;
|
|
51
|
+
/**
|
|
52
|
+
* The maximum number of colors in the document colors section.
|
|
53
|
+
* If it equals 0, the document colors section is not added.
|
|
54
|
+
*
|
|
55
|
+
* @readonly
|
|
56
|
+
*/
|
|
57
|
+
documentColorsCount?: number;
|
|
58
|
+
/**
|
|
59
|
+
* Keeps the value of the command associated with the table for the current selection.
|
|
60
|
+
*/
|
|
61
|
+
selectedColor: string;
|
|
62
|
+
/**
|
|
63
|
+
* Preserves the reference to {@link module:ui/colorgrid/colorgridview~ColorGridView} used to create
|
|
64
|
+
* the default (static) color set.
|
|
65
|
+
*
|
|
66
|
+
* The property is loaded once the the parent dropdown is opened the first time.
|
|
67
|
+
*
|
|
68
|
+
* @readonly
|
|
69
|
+
*/
|
|
70
|
+
staticColorsGrid: ColorGridView | undefined;
|
|
71
|
+
/**
|
|
72
|
+
* Preserves the reference to {@link module:ui/colorgrid/colorgridview~ColorGridView} used to create
|
|
73
|
+
* the document colors. It remains undefined if the document colors feature is disabled.
|
|
74
|
+
*
|
|
75
|
+
* The property is loaded once the the parent dropdown is opened the first time.
|
|
76
|
+
*
|
|
77
|
+
* @readonly
|
|
78
|
+
*/
|
|
79
|
+
documentColorsGrid: ColorGridView | undefined;
|
|
80
|
+
/**
|
|
81
|
+
* The "Color picker" button view.
|
|
82
|
+
*/
|
|
83
|
+
colorPickerButtonView?: ButtonView;
|
|
84
|
+
/**
|
|
85
|
+
* The "Remove color" button view.
|
|
86
|
+
*/
|
|
87
|
+
removeColorButtonView: ButtonView;
|
|
88
|
+
/**
|
|
89
|
+
* The property which is responsible for is component visible or not.
|
|
90
|
+
*/
|
|
91
|
+
isVisible: boolean;
|
|
92
|
+
/**
|
|
93
|
+
* A collection of views that can be focused in the view.
|
|
94
|
+
*
|
|
95
|
+
* @readonly
|
|
96
|
+
*/
|
|
97
|
+
protected _focusables: ViewCollection;
|
|
98
|
+
/**
|
|
99
|
+
* Document color section's label.
|
|
100
|
+
*
|
|
101
|
+
* @readonly
|
|
102
|
+
*/
|
|
103
|
+
private _documentColorsLabel?;
|
|
104
|
+
/**
|
|
105
|
+
* The label of the button responsible for removing color attributes.
|
|
106
|
+
*/
|
|
107
|
+
private _removeButtonLabel;
|
|
108
|
+
/**
|
|
109
|
+
* The label of the button responsible for switching to the color picker component.
|
|
110
|
+
*/
|
|
111
|
+
private _colorPickerLabel;
|
|
112
|
+
/**
|
|
113
|
+
* Creates an instance of the view.
|
|
114
|
+
*
|
|
115
|
+
* @param locale The localization services instance.
|
|
116
|
+
* @param colors An array with definitions of colors to be displayed in the table.
|
|
117
|
+
* @param columns The number of columns in the color grid.
|
|
118
|
+
* @param removeButtonLabel The label of the button responsible for removing the color.
|
|
119
|
+
* @param colorPickerLabel The label of the button responsible for color picker appearing.
|
|
120
|
+
* @param documentColorsLabel The label for the section with the document colors.
|
|
121
|
+
* @param documentColorsCount The number of colors in the document colors section inside the color dropdown.
|
|
122
|
+
* @param focusTracker Tracks information about the DOM focus in the list.
|
|
123
|
+
* @param focusables A collection of views that can be focused in the view.
|
|
124
|
+
*/
|
|
125
|
+
constructor(locale: Locale, { colors, columns, removeButtonLabel, documentColorsLabel, documentColorsCount, colorPickerLabel, focusTracker, focusables }: {
|
|
126
|
+
colors: Array<ColorDefinition>;
|
|
127
|
+
columns: number;
|
|
128
|
+
removeButtonLabel: string;
|
|
129
|
+
colorPickerLabel: string;
|
|
130
|
+
documentColorsLabel?: string;
|
|
131
|
+
documentColorsCount?: number;
|
|
132
|
+
focusTracker: FocusTracker;
|
|
133
|
+
focusables: ViewCollection;
|
|
134
|
+
});
|
|
135
|
+
/**
|
|
136
|
+
* Scans through the editor model and searches for text node attributes with the given attribute name.
|
|
137
|
+
* Found entries are set as document colors.
|
|
138
|
+
*
|
|
139
|
+
* All the previously stored document colors will be lost in the process.
|
|
140
|
+
*
|
|
141
|
+
* @param model The model used as a source to obtain the document colors.
|
|
142
|
+
* @param attributeName Determines the name of the related model's attribute for a given dropdown.
|
|
143
|
+
*/
|
|
144
|
+
updateDocumentColors(model: Model, attributeName: string): void;
|
|
145
|
+
/**
|
|
146
|
+
* Refreshes the state of the selected color in one or both {@link module:ui/colorgrid/colorgridview~ColorGridView}s
|
|
147
|
+
* available in the {@link module:ui/colorselector/colorselectorview~ColorSelectorView}. It guarantees that the selection will
|
|
148
|
+
* occur only in one of them.
|
|
149
|
+
*/
|
|
150
|
+
updateSelectedColors(): void;
|
|
151
|
+
/**
|
|
152
|
+
* @inheritDoc
|
|
153
|
+
*/
|
|
154
|
+
render(): void;
|
|
155
|
+
/**
|
|
156
|
+
* Focuses the component.
|
|
157
|
+
*/
|
|
158
|
+
focus(): void;
|
|
159
|
+
/**
|
|
160
|
+
* @inheritDoc
|
|
161
|
+
*/
|
|
162
|
+
destroy(): void;
|
|
163
|
+
/**
|
|
164
|
+
* Handles displaying the color picker button (if it was previously created) and making it focusable.
|
|
165
|
+
*/
|
|
166
|
+
addColorPickerButton(): void;
|
|
167
|
+
/**
|
|
168
|
+
* Adds color selector elements to focus tracker.
|
|
169
|
+
*/
|
|
170
|
+
private _addColorSelectorElementsToFocusTracker;
|
|
171
|
+
/**
|
|
172
|
+
* Creates the button responsible for displaying the color picker component.
|
|
173
|
+
*/
|
|
174
|
+
private _createColorPickerButton;
|
|
175
|
+
/**
|
|
176
|
+
* Adds the remove color button as a child of the current view.
|
|
177
|
+
*/
|
|
178
|
+
private _createRemoveColorButton;
|
|
179
|
+
/**
|
|
180
|
+
* Creates a static color grid based on the editor configuration.
|
|
181
|
+
*/
|
|
182
|
+
private _createStaticColorsGrid;
|
|
183
|
+
/**
|
|
184
|
+
* Creates the document colors section view and binds it to {@link #documentColors}.
|
|
185
|
+
*/
|
|
186
|
+
private _createDocumentColorsGrid;
|
|
187
|
+
/**
|
|
188
|
+
* Adds a given color to the document colors list. If possible, the method will attempt to use
|
|
189
|
+
* data from the {@link #colorDefinitions} (label, color options).
|
|
190
|
+
*
|
|
191
|
+
* @param color A string that stores the value of the recently applied color.
|
|
192
|
+
*/
|
|
193
|
+
private _addColorToDocumentColors;
|
|
194
|
+
}
|