@ckeditor/ckeditor5-ui 35.2.0 → 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.
Files changed (59) hide show
  1. package/package.json +31 -23
  2. package/src/bindings/addkeyboardhandlingforgrid.js +45 -57
  3. package/src/bindings/clickoutsidehandler.js +15 -21
  4. package/src/bindings/injectcsstransitiondisabler.js +16 -20
  5. package/src/bindings/preventdefault.js +6 -8
  6. package/src/bindings/submithandler.js +5 -7
  7. package/src/button/button.js +5 -0
  8. package/src/button/buttonview.js +220 -259
  9. package/src/button/switchbuttonview.js +56 -71
  10. package/src/colorgrid/colorgridview.js +135 -197
  11. package/src/colorgrid/colortileview.js +37 -47
  12. package/src/colorgrid/utils.js +57 -66
  13. package/src/componentfactory.js +79 -93
  14. package/src/dropdown/button/dropdownbutton.js +5 -0
  15. package/src/dropdown/button/dropdownbuttonview.js +44 -57
  16. package/src/dropdown/button/splitbuttonview.js +159 -207
  17. package/src/dropdown/dropdownpanelfocusable.js +5 -0
  18. package/src/dropdown/dropdownpanelview.js +101 -112
  19. package/src/dropdown/dropdownview.js +396 -438
  20. package/src/dropdown/utils.js +164 -213
  21. package/src/editableui/editableuiview.js +125 -141
  22. package/src/editableui/inline/inlineeditableuiview.js +44 -54
  23. package/src/editorui/bodycollection.js +61 -75
  24. package/src/editorui/boxed/boxededitoruiview.js +91 -104
  25. package/src/editorui/editoruiview.js +30 -39
  26. package/src/focuscycler.js +214 -245
  27. package/src/formheader/formheaderview.js +58 -70
  28. package/src/icon/iconview.js +145 -111
  29. package/src/iframe/iframeview.js +37 -49
  30. package/src/index.js +0 -17
  31. package/src/input/inputview.js +170 -198
  32. package/src/inputnumber/inputnumberview.js +48 -56
  33. package/src/inputtext/inputtextview.js +14 -18
  34. package/src/label/labelview.js +44 -53
  35. package/src/labeledfield/labeledfieldview.js +212 -235
  36. package/src/labeledfield/utils.js +39 -57
  37. package/src/labeledinput/labeledinputview.js +190 -221
  38. package/src/list/listitemview.js +40 -50
  39. package/src/list/listseparatorview.js +15 -19
  40. package/src/list/listview.js +94 -115
  41. package/src/model.js +19 -25
  42. package/src/notification/notification.js +151 -202
  43. package/src/panel/balloon/balloonpanelview.js +535 -628
  44. package/src/panel/balloon/contextualballoon.js +611 -732
  45. package/src/panel/sticky/stickypanelview.js +238 -270
  46. package/src/template.js +1049 -1479
  47. package/src/toolbar/balloon/balloontoolbar.js +337 -424
  48. package/src/toolbar/block/blockbuttonview.js +32 -42
  49. package/src/toolbar/block/blocktoolbar.js +375 -477
  50. package/src/toolbar/normalizetoolbarconfig.js +17 -21
  51. package/src/toolbar/toolbarlinebreakview.js +15 -19
  52. package/src/toolbar/toolbarseparatorview.js +15 -19
  53. package/src/toolbar/toolbarview.js +866 -1053
  54. package/src/tooltipmanager.js +324 -353
  55. package/src/view.js +389 -430
  56. package/src/viewcollection.js +147 -178
  57. package/src/button/button.jsdoc +0 -165
  58. package/src/dropdown/button/dropdownbutton.jsdoc +0 -22
  59. package/src/dropdown/dropdownpanelfocusable.jsdoc +0 -27
@@ -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
- * @inheritDoc
23
- */
24
- constructor( locale ) {
25
- super( locale );
26
-
27
- /**
28
- * The value of the input.
29
- *
30
- * @observable
31
- * @member {String} #value
32
- */
33
- this.set( 'value' );
34
-
35
- /**
36
- * The `id` attribute of the input (i.e. to pair with a `<label>` element).
37
- *
38
- * @observable
39
- * @member {String} #id
40
- */
41
- this.set( 'id' );
42
-
43
- /**
44
- * The `placeholder` attribute of the input.
45
- *
46
- * @observable
47
- * @member {String} #placeholder
48
- */
49
- this.set( 'placeholder' );
50
-
51
- /**
52
- * Controls whether the input view is in read-only mode.
53
- *
54
- * @observable
55
- * @member {Boolean} #isReadOnly
56
- */
57
- this.set( 'isReadOnly', false );
58
-
59
- /**
60
- * Set to `true` when the field has some error. Usually controlled via
61
- * {@link module:ui/labeledinput/labeledinputview~LabeledInputView#errorText}.
62
- *
63
- * @observable
64
- * @member {Boolean} #hasError
65
- */
66
- this.set( 'hasError', false );
67
-
68
- /**
69
- * The `id` of the element describing this field, e.g. when it has
70
- * some error; it helps screen readers read the error text.
71
- *
72
- * @observable
73
- * @member {Boolean} #ariaDescribedById
74
- */
75
- this.set( 'ariaDescribedById' );
76
-
77
- /**
78
- * Stores information about the editor UI focus and propagates it so various plugins and components
79
- * are unified as a focus group.
80
- *
81
- * @readonly
82
- * @member {module:utils/focustracker~FocusTracker} #focusTracker
83
- */
84
- this.focusTracker = new FocusTracker();
85
-
86
- /**
87
- * An observable flag set to `true` when the input is currently focused by the user.
88
- * Set to `false` otherwise.
89
- *
90
- * @readonly
91
- * @observable
92
- * @member {Boolean} #isFocused
93
- * @default false
94
- */
95
- this.bind( 'isFocused' ).to( this.focusTracker );
96
-
97
- /**
98
- * An observable flag set to `true` when the input contains no text, i.e.
99
- * when {@link #value} is `''`, `null`, or `false`.
100
- *
101
- * @readonly
102
- * @observable
103
- * @member {Boolean} #isEmpty
104
- * @default true
105
- */
106
- this.set( 'isEmpty', true );
107
-
108
- /**
109
- * Corresponds to the `inputmode` DOM attribute. Can be `text`, `numeric`, `decimal`, etc.
110
- *
111
- * @observable
112
- * @member {Boolean} #inputMode
113
- * @default 'text'
114
- */
115
- this.set( 'inputMode', 'text' );
116
-
117
- const bind = this.bindTemplate;
118
-
119
- this.setTemplate( {
120
- tag: 'input',
121
- attributes: {
122
- class: [
123
- 'ck',
124
- 'ck-input',
125
- bind.if( 'isFocused', 'ck-input_focused' ),
126
- bind.if( 'isEmpty', 'ck-input-text_empty' ),
127
- bind.if( 'hasError', 'ck-error' )
128
- ],
129
- id: bind.to( 'id' ),
130
- placeholder: bind.to( 'placeholder' ),
131
- readonly: bind.to( 'isReadOnly' ),
132
- inputmode: bind.to( 'inputMode' ),
133
- 'aria-invalid': bind.if( 'hasError', true ),
134
- 'aria-describedby': bind.to( 'ariaDescribedById' )
135
- },
136
- on: {
137
- input: bind.to( ( ...args ) => {
138
- this.fire( 'input', ...args );
139
- this._updateIsEmpty();
140
- } ),
141
- change: bind.to( this._updateIsEmpty.bind( this ) )
142
- }
143
- } );
144
-
145
- /**
146
- * Fired when the user types in the input. Corresponds to the native
147
- * DOM `input` event.
148
- *
149
- * @event input
150
- */
151
- }
152
-
153
- /**
154
- * @inheritDoc
155
- */
156
- render() {
157
- super.render();
158
-
159
- this.focusTracker.add( this.element );
160
-
161
- this._setDomElementValue( this.value );
162
- this._updateIsEmpty();
163
-
164
- // Bind `this.value` to the DOM element's value.
165
- // We cannot use `value` DOM attribute because removing it on Edge does not clear the DOM element's value property.
166
- this.on( 'change:value', ( evt, name, value ) => {
167
- this._setDomElementValue( value );
168
- this._updateIsEmpty();
169
- } );
170
- }
171
-
172
- /**
173
- * @inheritDoc
174
- */
175
- destroy() {
176
- super.destroy();
177
-
178
- this.focusTracker.destroy();
179
- }
180
-
181
- /**
182
- * Moves the focus to the input and selects the value.
183
- */
184
- select() {
185
- this.element.select();
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
- function isInputElementEmpty( domElement ) {
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
- * Creates an instance of the input number view.
20
- *
21
- * @param {module:utils/locale~Locale} locale The {@link module:core/editor/editor~Editor#locale} instance.
22
- * @param {Object} [options] The options of the input.
23
- * @param {Number} [options.min] The value of the `min` DOM attribute (the lowest accepted value).
24
- * @param {Number} [options.max] The value of the `max` DOM attribute (the highest accepted value).
25
- * @param {Number} [options.step] The value of the `step` DOM attribute.
26
- */
27
- constructor( locale, { min, max, step } = {} ) {
28
- super( locale );
29
-
30
- const bind = this.bindTemplate;
31
-
32
- /**
33
- * The value of the `min` DOM attribute (the lowest accepted value) set on the {@link #element}.
34
- *
35
- * @observable
36
- * @default undefined
37
- * @member {Number} #min
38
- */
39
- this.set( 'min', min );
40
-
41
- /**
42
- * The value of the `max` DOM attribute (the highest accepted value) set on the {@link #element}.
43
- *
44
- * @observable
45
- * @default undefined
46
- * @member {Number} #max
47
- */
48
- this.set( 'max', max );
49
-
50
- /**
51
- * The value of the `step` DOM attribute set on the {@link #element}.
52
- *
53
- * @observable
54
- * @default undefined
55
- * @member {Number} #step
56
- */
57
- this.set( 'step', step );
58
-
59
- this.extendTemplate( {
60
- attributes: {
61
- type: 'number',
62
- class: [
63
- 'ck-input-number'
64
- ],
65
- min: bind.to( 'min' ),
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
- * @inheritDoc
20
- */
21
- constructor( locale ) {
22
- super( locale );
23
-
24
- this.extendTemplate( {
25
- attributes: {
26
- type: 'text',
27
- class: [
28
- 'ck-input-text'
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
  }
@@ -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
- * @inheritDoc
23
- */
24
- constructor( locale ) {
25
- super( locale );
26
-
27
- /**
28
- * The text of the label.
29
- *
30
- * @observable
31
- * @member {String} #text
32
- */
33
- this.set( 'text' );
34
-
35
- /**
36
- * The `for` attribute of the label (i.e. to pair with an `<input>` element).
37
- *
38
- * @observable
39
- * @member {String} #for
40
- */
41
- this.set( 'for' );
42
-
43
- /**
44
- * An unique id of the label. It can be used by other UI components to reference
45
- * the label, for instance, using the `aria-describedby` DOM attribute.
46
- *
47
- * @member {String} #id
48
- */
49
- this.id = `ck-editor__label_${ uid() }`;
50
-
51
- const bind = this.bindTemplate;
52
-
53
- this.setTemplate( {
54
- tag: 'label',
55
- attributes: {
56
- class: [
57
- 'ck',
58
- 'ck-label'
59
- ],
60
- id: this.id,
61
- for: bind.to( 'for' )
62
- },
63
- children: [
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
  }