@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
package/src/componentfactory.js
CHANGED
|
@@ -2,13 +2,10 @@
|
|
|
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/componentfactory
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
8
|
import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
|
|
11
|
-
|
|
12
9
|
/**
|
|
13
10
|
* A helper class implementing the UI component ({@link module:ui/view~View view}) factory.
|
|
14
11
|
*
|
|
@@ -32,101 +29,90 @@ import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
|
|
|
32
29
|
* function when {@link module:ui/componentfactory~ComponentFactory#create} is called.
|
|
33
30
|
*/
|
|
34
31
|
export default class ComponentFactory {
|
|
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
|
-
* Checks if a component of a given name is registered in the factory.
|
|
115
|
-
*
|
|
116
|
-
* @param {String} name The name of the component.
|
|
117
|
-
* @returns {Boolean}
|
|
118
|
-
*/
|
|
119
|
-
has( name ) {
|
|
120
|
-
return this._components.has( getNormalized( name ) );
|
|
121
|
-
}
|
|
32
|
+
/**
|
|
33
|
+
* Creates an instance of the factory.
|
|
34
|
+
*
|
|
35
|
+
* @constructor
|
|
36
|
+
* @param {module:core/editor/editor~Editor} editor The editor instance.
|
|
37
|
+
*/
|
|
38
|
+
constructor(editor) {
|
|
39
|
+
/**
|
|
40
|
+
* The editor instance that the factory belongs to.
|
|
41
|
+
*
|
|
42
|
+
* @readonly
|
|
43
|
+
* @member {module:core/editor/editor~Editor}
|
|
44
|
+
*/
|
|
45
|
+
this.editor = editor;
|
|
46
|
+
/**
|
|
47
|
+
* Registered component factories.
|
|
48
|
+
*
|
|
49
|
+
* @private
|
|
50
|
+
* @member {Map}
|
|
51
|
+
*/
|
|
52
|
+
this._components = new Map();
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Returns an iterator of registered component names. Names are returned in lower case.
|
|
56
|
+
*
|
|
57
|
+
* @returns {Iterable.<String>}
|
|
58
|
+
*/
|
|
59
|
+
*names() {
|
|
60
|
+
for (const value of this._components.values()) {
|
|
61
|
+
yield value.originalName;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Registers a component factory function that will be used by the
|
|
66
|
+
* {@link #create create} method and called with the
|
|
67
|
+
* {@link module:core/editor/editor~Editor#locale editor locale} as an argument,
|
|
68
|
+
* allowing localization of the {@link module:ui/view~View view}.
|
|
69
|
+
*
|
|
70
|
+
* @param {String} name The name of the component.
|
|
71
|
+
* @param {Function} callback The callback that returns the component.
|
|
72
|
+
*/
|
|
73
|
+
add(name, callback) {
|
|
74
|
+
this._components.set(getNormalized(name), { callback, originalName: name });
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Creates an instance of a component registered in the factory under a specific name.
|
|
78
|
+
*
|
|
79
|
+
* When called, the {@link module:core/editor/editor~Editor#locale editor locale} is passed to
|
|
80
|
+
* the previously {@link #add added} factory function, allowing localization of the
|
|
81
|
+
* {@link module:ui/view~View view}.
|
|
82
|
+
*
|
|
83
|
+
* @param {String} name The name of the component.
|
|
84
|
+
* @returns {module:ui/view~View} The instantiated component view.
|
|
85
|
+
*/
|
|
86
|
+
create(name) {
|
|
87
|
+
if (!this.has(name)) {
|
|
88
|
+
/**
|
|
89
|
+
* The required component is not registered in the component factory. Please make sure
|
|
90
|
+
* the provided name is correct and the component has been correctly
|
|
91
|
+
* {@link #add added} to the factory.
|
|
92
|
+
*
|
|
93
|
+
* @error componentfactory-item-missing
|
|
94
|
+
* @param {String} name The name of the missing component.
|
|
95
|
+
*/
|
|
96
|
+
throw new CKEditorError('componentfactory-item-missing', this, { name });
|
|
97
|
+
}
|
|
98
|
+
return this._components.get(getNormalized(name)).callback(this.editor.locale);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Checks if a component of a given name is registered in the factory.
|
|
102
|
+
*
|
|
103
|
+
* @param {String} name The name of the component.
|
|
104
|
+
* @returns {Boolean}
|
|
105
|
+
*/
|
|
106
|
+
has(name) {
|
|
107
|
+
return this._components.has(getNormalized(name));
|
|
108
|
+
}
|
|
122
109
|
}
|
|
123
|
-
|
|
124
110
|
//
|
|
125
111
|
// Ensures that the component name used as the key in the internal map is in lower case.
|
|
126
112
|
//
|
|
127
113
|
// @private
|
|
128
114
|
// @param {String} name
|
|
129
115
|
// @returns {String}
|
|
130
|
-
function getNormalized(
|
|
131
|
-
|
|
116
|
+
function getNormalized(name) {
|
|
117
|
+
return String(name).toLowerCase();
|
|
132
118
|
}
|
|
@@ -2,16 +2,12 @@
|
|
|
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/dropdown/button/dropdownbuttonview
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
8
|
import ButtonView from '../../button/buttonview';
|
|
11
|
-
|
|
12
9
|
import dropdownArrowIcon from '../../../theme/icons/dropdown-arrow.svg';
|
|
13
10
|
import IconView from '../../icon/iconview';
|
|
14
|
-
|
|
15
11
|
/**
|
|
16
12
|
* The default dropdown button view class.
|
|
17
13
|
*
|
|
@@ -33,57 +29,48 @@ import IconView from '../../icon/iconview';
|
|
|
33
29
|
* @extends module:ui/button/buttonview~ButtonView
|
|
34
30
|
*/
|
|
35
31
|
export default class DropdownButtonView extends ButtonView {
|
|
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
|
-
arrowView.extendTemplate( {
|
|
82
|
-
attributes: {
|
|
83
|
-
class: 'ck-dropdown__arrow'
|
|
84
|
-
}
|
|
85
|
-
} );
|
|
86
|
-
|
|
87
|
-
return arrowView;
|
|
88
|
-
}
|
|
32
|
+
/**
|
|
33
|
+
* @inheritDoc
|
|
34
|
+
*/
|
|
35
|
+
constructor(locale) {
|
|
36
|
+
super(locale);
|
|
37
|
+
/**
|
|
38
|
+
* An icon that displays arrow to indicate a dropdown button.
|
|
39
|
+
*
|
|
40
|
+
* @readonly
|
|
41
|
+
* @member {module:ui/icon/iconview~IconView}
|
|
42
|
+
*/
|
|
43
|
+
this.arrowView = this._createArrowView();
|
|
44
|
+
this.extendTemplate({
|
|
45
|
+
attributes: {
|
|
46
|
+
'aria-haspopup': true,
|
|
47
|
+
'aria-expanded': this.bindTemplate.to('isOn', value => String(value))
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
// The DropdownButton interface expects the open event upon which will open the dropdown.
|
|
51
|
+
this.delegate('execute').to(this, 'open');
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* @inheritDoc
|
|
55
|
+
*/
|
|
56
|
+
render() {
|
|
57
|
+
super.render();
|
|
58
|
+
this.children.add(this.arrowView);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Creates a {@link module:ui/icon/iconview~IconView} instance as {@link #arrowView}.
|
|
62
|
+
*
|
|
63
|
+
* @private
|
|
64
|
+
* @returns {module:ui/icon/iconview~IconView}
|
|
65
|
+
*/
|
|
66
|
+
_createArrowView() {
|
|
67
|
+
const arrowView = new IconView();
|
|
68
|
+
arrowView.content = dropdownArrowIcon;
|
|
69
|
+
arrowView.extendTemplate({
|
|
70
|
+
attributes: {
|
|
71
|
+
class: 'ck-dropdown__arrow'
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
return arrowView;
|
|
75
|
+
}
|
|
89
76
|
}
|