@ckeditor/ckeditor5-ui 36.0.0 → 37.0.0-alpha.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 +23 -22
- package/src/bindings/addkeyboardhandlingforgrid.d.ts +27 -0
- package/src/bindings/addkeyboardhandlingforgrid.js +42 -34
- package/src/bindings/clickoutsidehandler.d.ts +28 -0
- package/src/bindings/clickoutsidehandler.js +5 -6
- package/src/bindings/csstransitiondisablermixin.d.ts +40 -0
- package/src/bindings/csstransitiondisablermixin.js +55 -0
- package/src/bindings/injectcsstransitiondisabler.d.ts +59 -0
- package/src/bindings/injectcsstransitiondisabler.js +23 -20
- package/src/bindings/preventdefault.d.ts +33 -0
- package/src/bindings/preventdefault.js +13 -15
- package/src/bindings/submithandler.d.ts +57 -0
- package/src/bindings/submithandler.js +22 -23
- package/src/button/button.d.ts +154 -0
- package/src/button/buttonview.d.ts +155 -0
- package/src/button/buttonview.js +16 -60
- package/src/button/switchbuttonview.d.ts +45 -0
- package/src/button/switchbuttonview.js +9 -18
- package/src/colorgrid/colorgridview.d.ts +132 -0
- package/src/colorgrid/colorgridview.js +8 -40
- package/src/colorgrid/colortileview.d.ts +28 -0
- package/src/colorgrid/colortileview.js +0 -13
- package/src/colorgrid/utils.d.ts +47 -0
- package/src/colorgrid/utils.js +7 -13
- package/src/componentfactory.d.ts +81 -0
- package/src/componentfactory.js +21 -35
- package/src/dropdown/button/dropdownbutton.d.ts +25 -0
- package/src/dropdown/button/dropdownbuttonview.d.ts +48 -0
- package/src/dropdown/button/dropdownbuttonview.js +11 -21
- package/src/dropdown/button/splitbuttonview.d.ts +145 -0
- package/src/dropdown/button/splitbuttonview.js +10 -51
- package/src/dropdown/dropdownpanelfocusable.d.ts +21 -0
- package/src/dropdown/dropdownpanelview.d.ts +62 -0
- package/src/dropdown/dropdownpanelview.js +2 -30
- package/src/dropdown/dropdownview.d.ts +315 -0
- package/src/dropdown/dropdownview.js +121 -222
- package/src/dropdown/utils.d.ts +219 -0
- package/src/dropdown/utils.js +112 -106
- package/src/editableui/editableuiview.d.ts +71 -0
- package/src/editableui/editableuiview.js +14 -43
- package/src/editableui/inline/inlineeditableuiview.d.ts +40 -0
- package/src/editableui/inline/inlineeditableuiview.js +5 -15
- package/src/editorui/bodycollection.d.ts +51 -0
- package/src/editorui/bodycollection.js +2 -16
- package/src/editorui/boxed/boxededitoruiview.d.ts +40 -0
- package/src/editorui/boxed/boxededitoruiview.js +1 -27
- package/src/editorui/editorui.d.ts +264 -0
- package/src/editorui/editorui.js +21 -128
- package/src/editorui/editoruiview.d.ts +39 -0
- package/src/editorui/editoruiview.js +1 -10
- package/src/focuscycler.d.ts +183 -0
- package/src/focuscycler.js +34 -90
- package/src/formheader/formheaderview.d.ts +53 -0
- package/src/formheader/formheaderview.js +3 -24
- package/src/icon/iconview.d.ts +78 -0
- package/src/icon/iconview.js +0 -50
- package/src/iframe/iframeview.d.ts +50 -0
- package/src/iframe/iframeview.js +2 -2
- package/src/index.d.ts +54 -0
- package/src/index.js +1 -0
- package/src/input/inputview.d.ts +121 -0
- package/src/input/inputview.js +0 -82
- package/src/inputnumber/inputnumberview.d.ts +49 -0
- package/src/inputnumber/inputnumberview.js +5 -28
- package/src/inputtext/inputtextview.d.ts +18 -0
- package/src/inputtext/inputtextview.js +0 -2
- package/src/label/labelview.d.ts +36 -0
- package/src/label/labelview.js +0 -20
- package/src/labeledfield/labeledfieldview.d.ts +182 -0
- package/src/labeledfield/labeledfieldview.js +20 -126
- package/src/labeledfield/utils.d.ts +93 -0
- package/src/labeledfield/utils.js +24 -18
- package/src/labeledinput/labeledinputview.d.ts +125 -0
- package/src/labeledinput/labeledinputview.js +7 -90
- package/src/list/listitemview.d.ts +35 -0
- package/src/list/listitemview.js +0 -16
- package/src/list/listseparatorview.d.ts +18 -0
- package/src/list/listseparatorview.js +0 -2
- package/src/list/listview.d.ts +59 -0
- package/src/list/listview.js +0 -33
- package/src/model.d.ts +22 -0
- package/src/model.js +2 -4
- package/src/notification/notification.d.ts +216 -0
- package/src/notification/notification.js +64 -51
- package/src/panel/balloon/balloonpanelview.d.ts +685 -0
- package/src/panel/balloon/balloonpanelview.js +146 -168
- package/src/panel/balloon/contextualballoon.d.ts +240 -0
- package/src/panel/balloon/contextualballoon.js +41 -171
- package/src/panel/sticky/stickypanelview.d.ts +132 -0
- package/src/panel/sticky/stickypanelview.js +0 -115
- package/src/template.d.ts +940 -0
- package/src/template.js +396 -460
- package/src/toolbar/balloon/balloontoolbar.d.ts +124 -0
- package/src/toolbar/balloon/balloontoolbar.js +15 -81
- package/src/toolbar/block/blockbuttonview.d.ts +35 -0
- package/src/toolbar/block/blockbuttonview.js +1 -13
- package/src/toolbar/block/blocktoolbar.d.ts +159 -0
- package/src/toolbar/block/blocktoolbar.js +32 -69
- package/src/toolbar/normalizetoolbarconfig.d.ts +39 -0
- package/src/toolbar/normalizetoolbarconfig.js +12 -8
- package/src/toolbar/toolbarlinebreakview.d.ts +18 -0
- package/src/toolbar/toolbarlinebreakview.js +0 -2
- package/src/toolbar/toolbarseparatorview.d.ts +18 -0
- package/src/toolbar/toolbarseparatorview.js +0 -2
- package/src/toolbar/toolbarview.d.ts +241 -0
- package/src/toolbar/toolbarview.js +54 -305
- package/src/tooltipmanager.d.ts +180 -0
- package/src/tooltipmanager.js +47 -94
- package/src/uiconfig.d.ts +82 -0
- package/src/uiconfig.js +5 -0
- package/src/view.d.ts +422 -0
- package/src/view.js +182 -251
- package/src/viewcollection.d.ts +139 -0
- package/src/viewcollection.js +62 -56
|
@@ -0,0 +1,139 @@
|
|
|
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/viewcollection
|
|
7
|
+
*/
|
|
8
|
+
import { Collection, type EmitterMixinDelegateChain } from '@ckeditor/ckeditor5-utils';
|
|
9
|
+
import type View from './view';
|
|
10
|
+
/**
|
|
11
|
+
* Collects {@link module:ui/view~View} instances.
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* const parentView = new ParentView( locale );
|
|
15
|
+
* const collection = new ViewCollection( locale );
|
|
16
|
+
*
|
|
17
|
+
* collection.setParent( parentView.element );
|
|
18
|
+
*
|
|
19
|
+
* const viewA = new ChildView( locale );
|
|
20
|
+
* const viewB = new ChildView( locale );
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* View collection renders and manages view {@link module:ui/view~View#element elements}:
|
|
24
|
+
*
|
|
25
|
+
* ```ts
|
|
26
|
+
* collection.add( viewA );
|
|
27
|
+
* collection.add( viewB );
|
|
28
|
+
*
|
|
29
|
+
* console.log( parentView.element.firsChild ); // -> viewA.element
|
|
30
|
+
* console.log( parentView.element.lastChild ); // -> viewB.element
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* It {@link module:ui/viewcollection~ViewCollection#delegate propagates} DOM events too:
|
|
34
|
+
*
|
|
35
|
+
* ```ts
|
|
36
|
+
* // Delegate #click and #keydown events from viewA and viewB to the parentView.
|
|
37
|
+
* collection.delegate( 'click' ).to( parentView );
|
|
38
|
+
*
|
|
39
|
+
* parentView.on( 'click', ( evt ) => {
|
|
40
|
+
* console.log( `${ evt.source } has been clicked.` );
|
|
41
|
+
* } );
|
|
42
|
+
*
|
|
43
|
+
* // This event will be delegated to the parentView.
|
|
44
|
+
* viewB.fire( 'click' );
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* **Note**: A view collection can be used directly in the {@link module:ui/template~TemplateDefinition definition}
|
|
48
|
+
* of a {@link module:ui/template~Template template}.
|
|
49
|
+
*/
|
|
50
|
+
export default class ViewCollection<TView extends View = View> extends Collection<TView> {
|
|
51
|
+
id?: string;
|
|
52
|
+
/**
|
|
53
|
+
* A parent element within which child views are rendered and managed in DOM.
|
|
54
|
+
*/
|
|
55
|
+
private _parentElement;
|
|
56
|
+
/**
|
|
57
|
+
* Creates a new instance of the {@link module:ui/viewcollection~ViewCollection}.
|
|
58
|
+
*
|
|
59
|
+
* @param initialItems The initial items of the collection.
|
|
60
|
+
*/
|
|
61
|
+
constructor(initialItems?: Iterable<TView>);
|
|
62
|
+
/**
|
|
63
|
+
* Destroys the view collection along with child views.
|
|
64
|
+
* See the view {@link module:ui/view~View#destroy} method.
|
|
65
|
+
*/
|
|
66
|
+
destroy(): void;
|
|
67
|
+
/**
|
|
68
|
+
* Sets the parent HTML element of this collection. When parent is set, {@link #add adding} and
|
|
69
|
+
* {@link #remove removing} views in the collection synchronizes their
|
|
70
|
+
* {@link module:ui/view~View#element elements} in the parent element.
|
|
71
|
+
*
|
|
72
|
+
* @param element A new parent element.
|
|
73
|
+
*/
|
|
74
|
+
setParent(elementOrDocFragment: DocumentFragment | HTMLElement): void;
|
|
75
|
+
/**
|
|
76
|
+
* Delegates selected events coming from within views in the collection to any
|
|
77
|
+
* {@link module:utils/emittermixin~Emitter}.
|
|
78
|
+
*
|
|
79
|
+
* For the following views and collection:
|
|
80
|
+
*
|
|
81
|
+
* ```ts
|
|
82
|
+
* const viewA = new View();
|
|
83
|
+
* const viewB = new View();
|
|
84
|
+
* const viewC = new View();
|
|
85
|
+
*
|
|
86
|
+
* const views = parentView.createCollection();
|
|
87
|
+
*
|
|
88
|
+
* views.delegate( 'eventX' ).to( viewB );
|
|
89
|
+
* views.delegate( 'eventX', 'eventY' ).to( viewC );
|
|
90
|
+
*
|
|
91
|
+
* views.add( viewA );
|
|
92
|
+
* ```
|
|
93
|
+
*
|
|
94
|
+
* the `eventX` is delegated (fired by) `viewB` and `viewC` along with `customData`:
|
|
95
|
+
*
|
|
96
|
+
* ```ts
|
|
97
|
+
* viewA.fire( 'eventX', customData );
|
|
98
|
+
* ```
|
|
99
|
+
*
|
|
100
|
+
* and `eventY` is delegated (fired by) `viewC` along with `customData`:
|
|
101
|
+
*
|
|
102
|
+
* ```ts
|
|
103
|
+
* viewA.fire( 'eventY', customData );
|
|
104
|
+
* ```
|
|
105
|
+
*
|
|
106
|
+
* See {@link module:utils/emittermixin~Emitter#delegate}.
|
|
107
|
+
*
|
|
108
|
+
* @param events {@link module:ui/view~View} event names to be delegated to another
|
|
109
|
+
* {@link module:utils/emittermixin~Emitter}.
|
|
110
|
+
* @returns Object with `to` property, a function which accepts the destination
|
|
111
|
+
* of {@link module:utils/emittermixin~Emitter#delegate delegated} events.
|
|
112
|
+
*/
|
|
113
|
+
delegate(...events: Array<string>): EmitterMixinDelegateChain;
|
|
114
|
+
/**
|
|
115
|
+
* This method {@link module:ui/view~View#render renders} a new view added to the collection.
|
|
116
|
+
*
|
|
117
|
+
* If the {@link #_parentElement parent element} of the collection is set, this method also adds
|
|
118
|
+
* the view's {@link module:ui/view~View#element} as a child of the parent in DOM at a specified index.
|
|
119
|
+
*
|
|
120
|
+
* **Note**: If index is not specified, the view's element is pushed as the last child
|
|
121
|
+
* of the parent element.
|
|
122
|
+
*
|
|
123
|
+
* @param view A new view added to the collection.
|
|
124
|
+
* @param index An index the view holds in the collection. When not specified,
|
|
125
|
+
* the view is added at the end.
|
|
126
|
+
*/
|
|
127
|
+
private _renderViewIntoCollectionParent;
|
|
128
|
+
/**
|
|
129
|
+
* Removes a child view from the collection. If the {@link #setParent parent element} of the
|
|
130
|
+
* collection has been set, the {@link module:ui/view~View#element element} of the view is also removed
|
|
131
|
+
* in DOM, reflecting the order of the collection.
|
|
132
|
+
*
|
|
133
|
+
* See the {@link #add} method.
|
|
134
|
+
*
|
|
135
|
+
* @param subject The view to remove, its id or index in the collection.
|
|
136
|
+
* @returns The removed view.
|
|
137
|
+
*/
|
|
138
|
+
remove(subject: TView | number | string): TView;
|
|
139
|
+
}
|
package/src/viewcollection.js
CHANGED
|
@@ -9,45 +9,48 @@ import { CKEditorError, Collection } from '@ckeditor/ckeditor5-utils';
|
|
|
9
9
|
/**
|
|
10
10
|
* Collects {@link module:ui/view~View} instances.
|
|
11
11
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
12
|
+
* ```ts
|
|
13
|
+
* const parentView = new ParentView( locale );
|
|
14
|
+
* const collection = new ViewCollection( locale );
|
|
14
15
|
*
|
|
15
|
-
*
|
|
16
|
+
* collection.setParent( parentView.element );
|
|
16
17
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
18
|
+
* const viewA = new ChildView( locale );
|
|
19
|
+
* const viewB = new ChildView( locale );
|
|
20
|
+
* ```
|
|
19
21
|
*
|
|
20
22
|
* View collection renders and manages view {@link module:ui/view~View#element elements}:
|
|
21
23
|
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
+
* ```ts
|
|
25
|
+
* collection.add( viewA );
|
|
26
|
+
* collection.add( viewB );
|
|
24
27
|
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
28
|
+
* console.log( parentView.element.firsChild ); // -> viewA.element
|
|
29
|
+
* console.log( parentView.element.lastChild ); // -> viewB.element
|
|
30
|
+
* ```
|
|
27
31
|
*
|
|
28
32
|
* It {@link module:ui/viewcollection~ViewCollection#delegate propagates} DOM events too:
|
|
29
33
|
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
34
|
+
* ```ts
|
|
35
|
+
* // Delegate #click and #keydown events from viewA and viewB to the parentView.
|
|
36
|
+
* collection.delegate( 'click' ).to( parentView );
|
|
32
37
|
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
38
|
+
* parentView.on( 'click', ( evt ) => {
|
|
39
|
+
* console.log( `${ evt.source } has been clicked.` );
|
|
40
|
+
* } );
|
|
36
41
|
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
42
|
+
* // This event will be delegated to the parentView.
|
|
43
|
+
* viewB.fire( 'click' );
|
|
44
|
+
* ```
|
|
39
45
|
*
|
|
40
46
|
* **Note**: A view collection can be used directly in the {@link module:ui/template~TemplateDefinition definition}
|
|
41
47
|
* of a {@link module:ui/template~Template template}.
|
|
42
|
-
*
|
|
43
|
-
* @extends module:utils/collection~Collection
|
|
44
|
-
* @mixes module:utils/observablemixin~ObservableMixin
|
|
45
48
|
*/
|
|
46
49
|
export default class ViewCollection extends Collection {
|
|
47
50
|
/**
|
|
48
51
|
* Creates a new instance of the {@link module:ui/viewcollection~ViewCollection}.
|
|
49
52
|
*
|
|
50
|
-
* @param
|
|
53
|
+
* @param initialItems The initial items of the collection.
|
|
51
54
|
*/
|
|
52
55
|
constructor(initialItems = []) {
|
|
53
56
|
super(initialItems, {
|
|
@@ -65,12 +68,6 @@ export default class ViewCollection extends Collection {
|
|
|
65
68
|
view.element.remove();
|
|
66
69
|
}
|
|
67
70
|
});
|
|
68
|
-
/**
|
|
69
|
-
* A parent element within which child views are rendered and managed in DOM.
|
|
70
|
-
*
|
|
71
|
-
* @protected
|
|
72
|
-
* @member {HTMLElement}
|
|
73
|
-
*/
|
|
74
71
|
this._parentElement = null;
|
|
75
72
|
}
|
|
76
73
|
/**
|
|
@@ -85,7 +82,7 @@ export default class ViewCollection extends Collection {
|
|
|
85
82
|
* {@link #remove removing} views in the collection synchronizes their
|
|
86
83
|
* {@link module:ui/view~View#element elements} in the parent element.
|
|
87
84
|
*
|
|
88
|
-
* @param
|
|
85
|
+
* @param element A new parent element.
|
|
89
86
|
*/
|
|
90
87
|
setParent(elementOrDocFragment) {
|
|
91
88
|
this._parentElement = elementOrDocFragment;
|
|
@@ -100,32 +97,37 @@ export default class ViewCollection extends Collection {
|
|
|
100
97
|
*
|
|
101
98
|
* For the following views and collection:
|
|
102
99
|
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
100
|
+
* ```ts
|
|
101
|
+
* const viewA = new View();
|
|
102
|
+
* const viewB = new View();
|
|
103
|
+
* const viewC = new View();
|
|
106
104
|
*
|
|
107
|
-
*
|
|
105
|
+
* const views = parentView.createCollection();
|
|
108
106
|
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
107
|
+
* views.delegate( 'eventX' ).to( viewB );
|
|
108
|
+
* views.delegate( 'eventX', 'eventY' ).to( viewC );
|
|
111
109
|
*
|
|
112
|
-
*
|
|
110
|
+
* views.add( viewA );
|
|
111
|
+
* ```
|
|
113
112
|
*
|
|
114
113
|
* the `eventX` is delegated (fired by) `viewB` and `viewC` along with `customData`:
|
|
115
114
|
*
|
|
116
|
-
*
|
|
115
|
+
* ```ts
|
|
116
|
+
* viewA.fire( 'eventX', customData );
|
|
117
|
+
* ```
|
|
117
118
|
*
|
|
118
119
|
* and `eventY` is delegated (fired by) `viewC` along with `customData`:
|
|
119
120
|
*
|
|
120
|
-
*
|
|
121
|
+
* ```ts
|
|
122
|
+
* viewA.fire( 'eventY', customData );
|
|
123
|
+
* ```
|
|
121
124
|
*
|
|
122
125
|
* See {@link module:utils/emittermixin~Emitter#delegate}.
|
|
123
126
|
*
|
|
124
|
-
* @param
|
|
127
|
+
* @param events {@link module:ui/view~View} event names to be delegated to another
|
|
125
128
|
* {@link module:utils/emittermixin~Emitter}.
|
|
126
|
-
* @returns
|
|
127
|
-
* @
|
|
128
|
-
* {@link module:utils/emittermixin~Emitter#delegate delegated} events.
|
|
129
|
+
* @returns Object with `to` property, a function which accepts the destination
|
|
130
|
+
* of {@link module:utils/emittermixin~Emitter#delegate delegated} events.
|
|
129
131
|
*/
|
|
130
132
|
delegate(...events) {
|
|
131
133
|
if (!events.length || !isStringArray(events)) {
|
|
@@ -137,14 +139,6 @@ export default class ViewCollection extends Collection {
|
|
|
137
139
|
throw new CKEditorError('ui-viewcollection-delegate-wrong-events', this);
|
|
138
140
|
}
|
|
139
141
|
return {
|
|
140
|
-
/**
|
|
141
|
-
* Selects destination for {@link module:utils/emittermixin~Emitter#delegate} events.
|
|
142
|
-
*
|
|
143
|
-
* @memberOf module:ui/viewcollection~ViewCollection#delegate
|
|
144
|
-
* @function module:ui/viewcollection~ViewCollection#delegate.to
|
|
145
|
-
* @param {module:utils/emittermixin~Emitter} dest An `Emitter` instance which is
|
|
146
|
-
* the destination for delegated events.
|
|
147
|
-
*/
|
|
148
142
|
to: dest => {
|
|
149
143
|
// Activate delegating on existing views in this collection.
|
|
150
144
|
for (const view of this) {
|
|
@@ -176,9 +170,8 @@ export default class ViewCollection extends Collection {
|
|
|
176
170
|
* **Note**: If index is not specified, the view's element is pushed as the last child
|
|
177
171
|
* of the parent element.
|
|
178
172
|
*
|
|
179
|
-
* @
|
|
180
|
-
* @param
|
|
181
|
-
* @param {Number} [index] An index the view holds in the collection. When not specified,
|
|
173
|
+
* @param view A new view added to the collection.
|
|
174
|
+
* @param index An index the view holds in the collection. When not specified,
|
|
182
175
|
* the view is added at the end.
|
|
183
176
|
*/
|
|
184
177
|
_renderViewIntoCollectionParent(view, index) {
|
|
@@ -189,12 +182,25 @@ export default class ViewCollection extends Collection {
|
|
|
189
182
|
this._parentElement.insertBefore(view.element, this._parentElement.children[index]);
|
|
190
183
|
}
|
|
191
184
|
}
|
|
185
|
+
/**
|
|
186
|
+
* Removes a child view from the collection. If the {@link #setParent parent element} of the
|
|
187
|
+
* collection has been set, the {@link module:ui/view~View#element element} of the view is also removed
|
|
188
|
+
* in DOM, reflecting the order of the collection.
|
|
189
|
+
*
|
|
190
|
+
* See the {@link #add} method.
|
|
191
|
+
*
|
|
192
|
+
* @param subject The view to remove, its id or index in the collection.
|
|
193
|
+
* @returns The removed view.
|
|
194
|
+
*/
|
|
195
|
+
remove(subject) {
|
|
196
|
+
return super.remove(subject);
|
|
197
|
+
}
|
|
192
198
|
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
199
|
+
/**
|
|
200
|
+
* Check if all entries of the array are of `String` type.
|
|
201
|
+
*
|
|
202
|
+
* @param arr An array to be checked.
|
|
203
|
+
*/
|
|
198
204
|
function isStringArray(arr) {
|
|
199
205
|
return arr.every(a => typeof a == 'string');
|
|
200
206
|
}
|