@ckeditor/ckeditor5-ui 35.2.1 → 35.3.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/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
package/src/input/inputview.js
CHANGED
|
@@ -2,215 +2,187 @@
|
|
|
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/input/inputview
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
8
|
import View from '../view';
|
|
11
9
|
import FocusTracker from '@ckeditor/ckeditor5-utils/src/focustracker';
|
|
12
|
-
|
|
13
10
|
import '../../theme/components/input/input.css';
|
|
14
|
-
|
|
15
11
|
/**
|
|
16
12
|
* The base input view class.
|
|
17
13
|
*
|
|
18
14
|
* @extends module:ui/view~View
|
|
19
15
|
*/
|
|
20
16
|
export default class InputView extends View {
|
|
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
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
* Focuses the input.
|
|
190
|
-
*/
|
|
191
|
-
focus() {
|
|
192
|
-
this.element.focus();
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* Updates the {@link #isEmpty} property value on demand.
|
|
197
|
-
*
|
|
198
|
-
* @private
|
|
199
|
-
*/
|
|
200
|
-
_updateIsEmpty() {
|
|
201
|
-
this.isEmpty = isInputElementEmpty( this.element );
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* Sets the `value` property of the {@link #element DOM element} on demand.
|
|
206
|
-
*
|
|
207
|
-
* @private
|
|
208
|
-
*/
|
|
209
|
-
_setDomElementValue( value ) {
|
|
210
|
-
this.element.value = ( !value && value !== 0 ) ? '' : value;
|
|
211
|
-
}
|
|
17
|
+
/**
|
|
18
|
+
* @inheritDoc
|
|
19
|
+
*/
|
|
20
|
+
constructor(locale) {
|
|
21
|
+
super(locale);
|
|
22
|
+
/**
|
|
23
|
+
* The value of the input.
|
|
24
|
+
*
|
|
25
|
+
* @observable
|
|
26
|
+
* @member {String} #value
|
|
27
|
+
*/
|
|
28
|
+
this.set('value', undefined);
|
|
29
|
+
/**
|
|
30
|
+
* The `id` attribute of the input (i.e. to pair with a `<label>` element).
|
|
31
|
+
*
|
|
32
|
+
* @observable
|
|
33
|
+
* @member {String} #id
|
|
34
|
+
*/
|
|
35
|
+
this.set('id', undefined);
|
|
36
|
+
/**
|
|
37
|
+
* The `placeholder` attribute of the input.
|
|
38
|
+
*
|
|
39
|
+
* @observable
|
|
40
|
+
* @member {String} #placeholder
|
|
41
|
+
*/
|
|
42
|
+
this.set('placeholder', undefined);
|
|
43
|
+
/**
|
|
44
|
+
* Controls whether the input view is in read-only mode.
|
|
45
|
+
*
|
|
46
|
+
* @observable
|
|
47
|
+
* @member {Boolean} #isReadOnly
|
|
48
|
+
*/
|
|
49
|
+
this.set('isReadOnly', false);
|
|
50
|
+
/**
|
|
51
|
+
* Set to `true` when the field has some error. Usually controlled via
|
|
52
|
+
* {@link module:ui/labeledinput/labeledinputview~LabeledInputView#errorText}.
|
|
53
|
+
*
|
|
54
|
+
* @observable
|
|
55
|
+
* @member {Boolean} #hasError
|
|
56
|
+
*/
|
|
57
|
+
this.set('hasError', false);
|
|
58
|
+
/**
|
|
59
|
+
* The `id` of the element describing this field, e.g. when it has
|
|
60
|
+
* some error; it helps screen readers read the error text.
|
|
61
|
+
*
|
|
62
|
+
* @observable
|
|
63
|
+
* @member {Boolean} #ariaDescribedById
|
|
64
|
+
*/
|
|
65
|
+
this.set('ariaDescribedById', undefined);
|
|
66
|
+
/**
|
|
67
|
+
* Stores information about the editor UI focus and propagates it so various plugins and components
|
|
68
|
+
* are unified as a focus group.
|
|
69
|
+
*
|
|
70
|
+
* @readonly
|
|
71
|
+
* @member {module:utils/focustracker~FocusTracker} #focusTracker
|
|
72
|
+
*/
|
|
73
|
+
this.focusTracker = new FocusTracker();
|
|
74
|
+
/**
|
|
75
|
+
* An observable flag set to `true` when the input is currently focused by the user.
|
|
76
|
+
* Set to `false` otherwise.
|
|
77
|
+
*
|
|
78
|
+
* @readonly
|
|
79
|
+
* @observable
|
|
80
|
+
* @member {Boolean} #isFocused
|
|
81
|
+
* @default false
|
|
82
|
+
*/
|
|
83
|
+
this.bind('isFocused').to(this.focusTracker);
|
|
84
|
+
/**
|
|
85
|
+
* An observable flag set to `true` when the input contains no text, i.e.
|
|
86
|
+
* when {@link #value} is `''`, `null`, or `false`.
|
|
87
|
+
*
|
|
88
|
+
* @readonly
|
|
89
|
+
* @observable
|
|
90
|
+
* @member {Boolean} #isEmpty
|
|
91
|
+
* @default true
|
|
92
|
+
*/
|
|
93
|
+
this.set('isEmpty', true);
|
|
94
|
+
/**
|
|
95
|
+
* Corresponds to the `inputmode` DOM attribute. Can be `text`, `numeric`, `decimal`, etc.
|
|
96
|
+
*
|
|
97
|
+
* @observable
|
|
98
|
+
* @member {Boolean} #inputMode
|
|
99
|
+
* @default 'text'
|
|
100
|
+
*/
|
|
101
|
+
this.set('inputMode', 'text');
|
|
102
|
+
const bind = this.bindTemplate;
|
|
103
|
+
this.setTemplate({
|
|
104
|
+
tag: 'input',
|
|
105
|
+
attributes: {
|
|
106
|
+
class: [
|
|
107
|
+
'ck',
|
|
108
|
+
'ck-input',
|
|
109
|
+
bind.if('isFocused', 'ck-input_focused'),
|
|
110
|
+
bind.if('isEmpty', 'ck-input-text_empty'),
|
|
111
|
+
bind.if('hasError', 'ck-error')
|
|
112
|
+
],
|
|
113
|
+
id: bind.to('id'),
|
|
114
|
+
placeholder: bind.to('placeholder'),
|
|
115
|
+
readonly: bind.to('isReadOnly'),
|
|
116
|
+
inputmode: bind.to('inputMode'),
|
|
117
|
+
'aria-invalid': bind.if('hasError', true),
|
|
118
|
+
'aria-describedby': bind.to('ariaDescribedById')
|
|
119
|
+
},
|
|
120
|
+
on: {
|
|
121
|
+
input: bind.to((...args) => {
|
|
122
|
+
this.fire('input', ...args);
|
|
123
|
+
this._updateIsEmpty();
|
|
124
|
+
}),
|
|
125
|
+
change: bind.to(this._updateIsEmpty.bind(this))
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
/**
|
|
129
|
+
* Fired when the user types in the input. Corresponds to the native
|
|
130
|
+
* DOM `input` event.
|
|
131
|
+
*
|
|
132
|
+
* @event input
|
|
133
|
+
*/
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* @inheritDoc
|
|
137
|
+
*/
|
|
138
|
+
render() {
|
|
139
|
+
super.render();
|
|
140
|
+
this.focusTracker.add(this.element);
|
|
141
|
+
this._setDomElementValue(this.value);
|
|
142
|
+
this._updateIsEmpty();
|
|
143
|
+
// Bind `this.value` to the DOM element's value.
|
|
144
|
+
// We cannot use `value` DOM attribute because removing it on Edge does not clear the DOM element's value property.
|
|
145
|
+
this.on('change:value', (evt, name, value) => {
|
|
146
|
+
this._setDomElementValue(value);
|
|
147
|
+
this._updateIsEmpty();
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* @inheritDoc
|
|
152
|
+
*/
|
|
153
|
+
destroy() {
|
|
154
|
+
super.destroy();
|
|
155
|
+
this.focusTracker.destroy();
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Moves the focus to the input and selects the value.
|
|
159
|
+
*/
|
|
160
|
+
select() {
|
|
161
|
+
this.element.select();
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Focuses the input.
|
|
165
|
+
*/
|
|
166
|
+
focus() {
|
|
167
|
+
this.element.focus();
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Updates the {@link #isEmpty} property value on demand.
|
|
171
|
+
*
|
|
172
|
+
* @private
|
|
173
|
+
*/
|
|
174
|
+
_updateIsEmpty() {
|
|
175
|
+
this.isEmpty = isInputElementEmpty(this.element);
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Sets the `value` property of the {@link #element DOM element} on demand.
|
|
179
|
+
*
|
|
180
|
+
* @private
|
|
181
|
+
*/
|
|
182
|
+
_setDomElementValue(value) {
|
|
183
|
+
this.element.value = (!value && value !== 0) ? '' : value;
|
|
184
|
+
}
|
|
212
185
|
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
return !domElement.value;
|
|
186
|
+
function isInputElementEmpty(domElement) {
|
|
187
|
+
return !domElement.value;
|
|
216
188
|
}
|
|
@@ -2,70 +2,62 @@
|
|
|
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/inputnumber/inputnumberview
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
8
|
import InputView from '../input/inputview';
|
|
11
|
-
|
|
12
9
|
/**
|
|
13
10
|
* The number input view class.
|
|
14
11
|
*
|
|
15
12
|
* @extends module:ui/input/inputview~InputView
|
|
16
13
|
*/
|
|
17
14
|
export default class InputNumberView extends InputView {
|
|
18
|
-
|
|
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
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
max: bind.to( 'max' ),
|
|
67
|
-
step: bind.to( 'step' )
|
|
68
|
-
}
|
|
69
|
-
} );
|
|
70
|
-
}
|
|
15
|
+
/**
|
|
16
|
+
* Creates an instance of the input number view.
|
|
17
|
+
*
|
|
18
|
+
* @param {module:utils/locale~Locale} locale The {@link module:core/editor/editor~Editor#locale} instance.
|
|
19
|
+
* @param {Object} [options] The options of the input.
|
|
20
|
+
* @param {Number} [options.min] The value of the `min` DOM attribute (the lowest accepted value).
|
|
21
|
+
* @param {Number} [options.max] The value of the `max` DOM attribute (the highest accepted value).
|
|
22
|
+
* @param {Number} [options.step] The value of the `step` DOM attribute.
|
|
23
|
+
*/
|
|
24
|
+
constructor(locale, { min, max, step } = {}) {
|
|
25
|
+
super(locale);
|
|
26
|
+
const bind = this.bindTemplate;
|
|
27
|
+
/**
|
|
28
|
+
* The value of the `min` DOM attribute (the lowest accepted value) set on the {@link #element}.
|
|
29
|
+
*
|
|
30
|
+
* @observable
|
|
31
|
+
* @default undefined
|
|
32
|
+
* @member {Number} #min
|
|
33
|
+
*/
|
|
34
|
+
this.set('min', min);
|
|
35
|
+
/**
|
|
36
|
+
* The value of the `max` DOM attribute (the highest accepted value) set on the {@link #element}.
|
|
37
|
+
*
|
|
38
|
+
* @observable
|
|
39
|
+
* @default undefined
|
|
40
|
+
* @member {Number} #max
|
|
41
|
+
*/
|
|
42
|
+
this.set('max', max);
|
|
43
|
+
/**
|
|
44
|
+
* The value of the `step` DOM attribute set on the {@link #element}.
|
|
45
|
+
*
|
|
46
|
+
* @observable
|
|
47
|
+
* @default undefined
|
|
48
|
+
* @member {Number} #step
|
|
49
|
+
*/
|
|
50
|
+
this.set('step', step);
|
|
51
|
+
this.extendTemplate({
|
|
52
|
+
attributes: {
|
|
53
|
+
type: 'number',
|
|
54
|
+
class: [
|
|
55
|
+
'ck-input-number'
|
|
56
|
+
],
|
|
57
|
+
min: bind.to('min'),
|
|
58
|
+
max: bind.to('max'),
|
|
59
|
+
step: bind.to('step')
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}
|
|
71
63
|
}
|
|
@@ -2,32 +2,28 @@
|
|
|
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/inputtext/inputtextview
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
8
|
import InputView from '../input/inputview';
|
|
11
|
-
|
|
12
9
|
/**
|
|
13
10
|
* The text input view class.
|
|
14
11
|
*
|
|
15
12
|
* @extends module:ui/input/inputview~InputView
|
|
16
13
|
*/
|
|
17
14
|
export default class InputTextView extends InputView {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
15
|
+
/**
|
|
16
|
+
* @inheritDoc
|
|
17
|
+
*/
|
|
18
|
+
constructor(locale) {
|
|
19
|
+
super(locale);
|
|
20
|
+
this.extendTemplate({
|
|
21
|
+
attributes: {
|
|
22
|
+
type: 'text',
|
|
23
|
+
class: [
|
|
24
|
+
'ck-input-text'
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
33
29
|
}
|
package/src/label/labelview.js
CHANGED
|
@@ -2,69 +2,60 @@
|
|
|
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/label/labelview
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
8
|
import View from '../view';
|
|
11
9
|
import uid from '@ckeditor/ckeditor5-utils/src/uid';
|
|
12
|
-
|
|
13
10
|
import '../../theme/components/label/label.css';
|
|
14
|
-
|
|
15
11
|
/**
|
|
16
12
|
* The label view class.
|
|
17
13
|
*
|
|
18
14
|
* @extends module:ui/view~View
|
|
19
15
|
*/
|
|
20
16
|
export default class LabelView extends View {
|
|
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
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
text: bind.to( 'text' )
|
|
66
|
-
}
|
|
67
|
-
]
|
|
68
|
-
} );
|
|
69
|
-
}
|
|
17
|
+
/**
|
|
18
|
+
* @inheritDoc
|
|
19
|
+
*/
|
|
20
|
+
constructor(locale) {
|
|
21
|
+
super(locale);
|
|
22
|
+
/**
|
|
23
|
+
* The text of the label.
|
|
24
|
+
*
|
|
25
|
+
* @observable
|
|
26
|
+
* @member {String} #text
|
|
27
|
+
*/
|
|
28
|
+
this.set('text', undefined);
|
|
29
|
+
/**
|
|
30
|
+
* The `for` attribute of the label (i.e. to pair with an `<input>` element).
|
|
31
|
+
*
|
|
32
|
+
* @observable
|
|
33
|
+
* @member {String} #for
|
|
34
|
+
*/
|
|
35
|
+
this.set('for', undefined);
|
|
36
|
+
/**
|
|
37
|
+
* An unique id of the label. It can be used by other UI components to reference
|
|
38
|
+
* the label, for instance, using the `aria-describedby` DOM attribute.
|
|
39
|
+
*
|
|
40
|
+
* @member {String} #id
|
|
41
|
+
*/
|
|
42
|
+
this.id = `ck-editor__label_${uid()}`;
|
|
43
|
+
const bind = this.bindTemplate;
|
|
44
|
+
this.setTemplate({
|
|
45
|
+
tag: 'label',
|
|
46
|
+
attributes: {
|
|
47
|
+
class: [
|
|
48
|
+
'ck',
|
|
49
|
+
'ck-label'
|
|
50
|
+
],
|
|
51
|
+
id: this.id,
|
|
52
|
+
for: bind.to('for')
|
|
53
|
+
},
|
|
54
|
+
children: [
|
|
55
|
+
{
|
|
56
|
+
text: bind.to('text')
|
|
57
|
+
}
|
|
58
|
+
]
|
|
59
|
+
});
|
|
60
|
+
}
|
|
70
61
|
}
|