@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/list/listview.js
CHANGED
|
@@ -2,18 +2,14 @@
|
|
|
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/list/listview
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
8
|
import View from '../view';
|
|
11
9
|
import FocusTracker from '@ckeditor/ckeditor5-utils/src/focustracker';
|
|
12
10
|
import FocusCycler from '../focuscycler';
|
|
13
11
|
import KeystrokeHandler from '@ckeditor/ckeditor5-utils/src/keystrokehandler';
|
|
14
|
-
|
|
15
12
|
import '../../theme/components/list/list.css';
|
|
16
|
-
|
|
17
13
|
/**
|
|
18
14
|
* The list view class.
|
|
19
15
|
*
|
|
@@ -21,115 +17,98 @@ import '../../theme/components/list/list.css';
|
|
|
21
17
|
* @implements module:ui/dropdown/dropdownpanelfocusable~DropdownPanelFocusable
|
|
22
18
|
*/
|
|
23
19
|
export default class ListView extends View {
|
|
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
|
-
this.focusTracker.destroy();
|
|
119
|
-
this.keystrokes.destroy();
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Focuses the first focusable in {@link #items}.
|
|
124
|
-
*/
|
|
125
|
-
focus() {
|
|
126
|
-
this._focusCycler.focusFirst();
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Focuses the last focusable in {@link #items}.
|
|
131
|
-
*/
|
|
132
|
-
focusLast() {
|
|
133
|
-
this._focusCycler.focusLast();
|
|
134
|
-
}
|
|
20
|
+
/**
|
|
21
|
+
* @inheritDoc
|
|
22
|
+
*/
|
|
23
|
+
constructor(locale) {
|
|
24
|
+
super(locale);
|
|
25
|
+
/**
|
|
26
|
+
* Collection of the child list views.
|
|
27
|
+
*
|
|
28
|
+
* @readonly
|
|
29
|
+
* @member {module:ui/viewcollection~ViewCollection}
|
|
30
|
+
*/
|
|
31
|
+
this.items = this.createCollection();
|
|
32
|
+
/**
|
|
33
|
+
* Tracks information about DOM focus in the list.
|
|
34
|
+
*
|
|
35
|
+
* @readonly
|
|
36
|
+
* @member {module:utils/focustracker~FocusTracker}
|
|
37
|
+
*/
|
|
38
|
+
this.focusTracker = new FocusTracker();
|
|
39
|
+
/**
|
|
40
|
+
* Instance of the {@link module:utils/keystrokehandler~KeystrokeHandler}.
|
|
41
|
+
*
|
|
42
|
+
* @readonly
|
|
43
|
+
* @member {module:utils/keystrokehandler~KeystrokeHandler}
|
|
44
|
+
*/
|
|
45
|
+
this.keystrokes = new KeystrokeHandler();
|
|
46
|
+
/**
|
|
47
|
+
* Helps cycling over focusable {@link #items} in the list.
|
|
48
|
+
*
|
|
49
|
+
* @readonly
|
|
50
|
+
* @protected
|
|
51
|
+
* @member {module:ui/focuscycler~FocusCycler}
|
|
52
|
+
*/
|
|
53
|
+
this._focusCycler = new FocusCycler({
|
|
54
|
+
focusables: this.items,
|
|
55
|
+
focusTracker: this.focusTracker,
|
|
56
|
+
keystrokeHandler: this.keystrokes,
|
|
57
|
+
actions: {
|
|
58
|
+
// Navigate list items backwards using the arrowup key.
|
|
59
|
+
focusPrevious: 'arrowup',
|
|
60
|
+
// Navigate toolbar items forwards using the arrowdown key.
|
|
61
|
+
focusNext: 'arrowdown'
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
this.setTemplate({
|
|
65
|
+
tag: 'ul',
|
|
66
|
+
attributes: {
|
|
67
|
+
class: [
|
|
68
|
+
'ck',
|
|
69
|
+
'ck-reset',
|
|
70
|
+
'ck-list'
|
|
71
|
+
]
|
|
72
|
+
},
|
|
73
|
+
children: this.items
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* @inheritDoc
|
|
78
|
+
*/
|
|
79
|
+
render() {
|
|
80
|
+
super.render();
|
|
81
|
+
// Items added before rendering should be known to the #focusTracker.
|
|
82
|
+
for (const item of this.items) {
|
|
83
|
+
this.focusTracker.add(item.element);
|
|
84
|
+
}
|
|
85
|
+
this.items.on('add', (evt, item) => {
|
|
86
|
+
this.focusTracker.add(item.element);
|
|
87
|
+
});
|
|
88
|
+
this.items.on('remove', (evt, item) => {
|
|
89
|
+
this.focusTracker.remove(item.element);
|
|
90
|
+
});
|
|
91
|
+
// Start listening for the keystrokes coming from #element.
|
|
92
|
+
this.keystrokes.listenTo(this.element);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* @inheritDoc
|
|
96
|
+
*/
|
|
97
|
+
destroy() {
|
|
98
|
+
super.destroy();
|
|
99
|
+
this.focusTracker.destroy();
|
|
100
|
+
this.keystrokes.destroy();
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Focuses the first focusable in {@link #items}.
|
|
104
|
+
*/
|
|
105
|
+
focus() {
|
|
106
|
+
this._focusCycler.focusFirst();
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Focuses the last focusable in {@link #items}.
|
|
110
|
+
*/
|
|
111
|
+
focusLast() {
|
|
112
|
+
this._focusCycler.focusLast();
|
|
113
|
+
}
|
|
135
114
|
}
|
package/src/model.js
CHANGED
|
@@ -2,38 +2,32 @@
|
|
|
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/model
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
|
-
import mix from '@ckeditor/ckeditor5-utils/src/mix';
|
|
11
|
-
import ObservableMixin from '@ckeditor/ckeditor5-utils/src/observablemixin';
|
|
8
|
+
import { Observable } from '@ckeditor/ckeditor5-utils/src/observablemixin';
|
|
12
9
|
import { extend } from 'lodash-es';
|
|
13
|
-
|
|
14
10
|
/**
|
|
15
11
|
* The base MVC model class.
|
|
16
12
|
*
|
|
17
13
|
* @mixes module:utils/observablemixin~ObservableMixin
|
|
18
14
|
*/
|
|
19
|
-
export default class Model {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
15
|
+
export default class Model extends Observable {
|
|
16
|
+
/**
|
|
17
|
+
* Creates a new Model instance.
|
|
18
|
+
*
|
|
19
|
+
* @param {Object} [attributes] The model state attributes to be defined during the instance creation.
|
|
20
|
+
* @param {Object} [properties] The (out of state) properties to be appended to the instance during creation.
|
|
21
|
+
*/
|
|
22
|
+
constructor(attributes, properties) {
|
|
23
|
+
super();
|
|
24
|
+
// Extend this instance with the additional (out of state) properties.
|
|
25
|
+
if (properties) {
|
|
26
|
+
extend(this, properties);
|
|
27
|
+
}
|
|
28
|
+
// Initialize the attributes.
|
|
29
|
+
if (attributes) {
|
|
30
|
+
this.set(attributes);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
37
33
|
}
|
|
38
|
-
|
|
39
|
-
mix( Model, ObservableMixin );
|
|
@@ -2,15 +2,11 @@
|
|
|
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/notification/notification
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
8
|
/* globals window */
|
|
11
|
-
|
|
12
9
|
import ContextPlugin from '@ckeditor/ckeditor5-core/src/contextplugin';
|
|
13
|
-
|
|
14
10
|
/**
|
|
15
11
|
* The Notification plugin.
|
|
16
12
|
*
|
|
@@ -24,202 +20,155 @@ import ContextPlugin from '@ckeditor/ckeditor5-core/src/contextplugin';
|
|
|
24
20
|
* @extends module:core/contextplugin~ContextPlugin
|
|
25
21
|
*/
|
|
26
22
|
export default class Notification extends ContextPlugin {
|
|
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
|
-
type: data.type,
|
|
179
|
-
title: data.title || ''
|
|
180
|
-
} );
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* Fired when one of the `showSuccess()`, `showInfo()`, `showWarning()` methods is called.
|
|
185
|
-
*
|
|
186
|
-
* @event show
|
|
187
|
-
* @param {Object} data The notification data.
|
|
188
|
-
* @param {String} data.message The content of the notification.
|
|
189
|
-
* @param {String} data.title The title of the notification.
|
|
190
|
-
* @param {'success'|'info'|'warning'} data.type The type of the notification.
|
|
191
|
-
*/
|
|
192
|
-
|
|
193
|
-
/**
|
|
194
|
-
* Fired when the `showSuccess()` method is called.
|
|
195
|
-
*
|
|
196
|
-
* @event show:success
|
|
197
|
-
* @param {Object} data The notification data.
|
|
198
|
-
* @param {String} data.message The content of the notification.
|
|
199
|
-
* @param {String} data.title The title of the notification.
|
|
200
|
-
* @param {'success'} data.type The type of the notification.
|
|
201
|
-
*/
|
|
202
|
-
|
|
203
|
-
/**
|
|
204
|
-
* Fired when the `showInfo()` method is called.
|
|
205
|
-
*
|
|
206
|
-
* @event show:info
|
|
207
|
-
* @param {Object} data The notification data.
|
|
208
|
-
* @param {String} data.message The content of the notification.
|
|
209
|
-
* @param {String} data.title The title of the notification.
|
|
210
|
-
* @param {'info'} data.type The type of the notification.
|
|
211
|
-
*/
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
* Fired when the `showWarning()` method is called.
|
|
215
|
-
*
|
|
216
|
-
* When this event is not handled or stopped by `event.stop()`, the `data.message` of this event will
|
|
217
|
-
* be automatically displayed as a system alert.
|
|
218
|
-
*
|
|
219
|
-
* @event show:warning
|
|
220
|
-
* @param {Object} data The notification data.
|
|
221
|
-
* @param {String} data.message The content of the notification.
|
|
222
|
-
* @param {String} data.title The title of the notification.
|
|
223
|
-
* @param {'warning'} data.type The type of the notification.
|
|
224
|
-
*/
|
|
23
|
+
/**
|
|
24
|
+
* @inheritDoc
|
|
25
|
+
*/
|
|
26
|
+
static get pluginName() {
|
|
27
|
+
return 'Notification';
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* @inheritDoc
|
|
31
|
+
*/
|
|
32
|
+
init() {
|
|
33
|
+
// Each unhandled and not stopped `show:warning` event is displayed as a system alert.
|
|
34
|
+
this.on('show:warning', (evt, data) => {
|
|
35
|
+
window.alert(data.message); // eslint-disable-line no-alert
|
|
36
|
+
}, { priority: 'lowest' });
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Shows a success notification.
|
|
40
|
+
*
|
|
41
|
+
* By default, it fires the {@link #event:show:success `show:success` event} with the given `data`. The event namespace can be extended
|
|
42
|
+
* using the `data.namespace` option. For example:
|
|
43
|
+
*
|
|
44
|
+
* showSuccess( 'Image is uploaded.', {
|
|
45
|
+
* namespace: 'upload:image'
|
|
46
|
+
* } );
|
|
47
|
+
*
|
|
48
|
+
* will fire the `show:success:upload:image` event.
|
|
49
|
+
*
|
|
50
|
+
* You can provide the title of the notification:
|
|
51
|
+
*
|
|
52
|
+
* showSuccess( 'Image is uploaded.', {
|
|
53
|
+
* title: 'Image upload success'
|
|
54
|
+
* } );
|
|
55
|
+
*
|
|
56
|
+
* @param {String} message The content of the notification.
|
|
57
|
+
* @param {Object} [data={}] Additional data.
|
|
58
|
+
* @param {String} [data.namespace] Additional event namespace.
|
|
59
|
+
* @param {String} [data.title] The title of the notification.
|
|
60
|
+
*/
|
|
61
|
+
showSuccess(message, data = {}) {
|
|
62
|
+
this._showNotification({
|
|
63
|
+
message,
|
|
64
|
+
type: 'success',
|
|
65
|
+
namespace: data.namespace,
|
|
66
|
+
title: data.title
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Shows an information notification.
|
|
71
|
+
*
|
|
72
|
+
* By default, it fires the {@link #event:show:info `show:info` event} with the given `data`. The event namespace can be extended
|
|
73
|
+
* using the `data.namespace` option. For example:
|
|
74
|
+
*
|
|
75
|
+
* showInfo( 'Editor is offline.', {
|
|
76
|
+
* namespace: 'editor:status'
|
|
77
|
+
* } );
|
|
78
|
+
*
|
|
79
|
+
* will fire the `show:info:editor:status` event.
|
|
80
|
+
*
|
|
81
|
+
* You can provide the title of the notification:
|
|
82
|
+
*
|
|
83
|
+
* showInfo( 'Editor is offline.', {
|
|
84
|
+
* title: 'Network information'
|
|
85
|
+
* } );
|
|
86
|
+
*
|
|
87
|
+
* @param {String} message The content of the notification.
|
|
88
|
+
* @param {Object} [data={}] Additional data.
|
|
89
|
+
* @param {String} [data.namespace] Additional event namespace.
|
|
90
|
+
* @param {String} [data.title] The title of the notification.
|
|
91
|
+
*/
|
|
92
|
+
showInfo(message, data = {}) {
|
|
93
|
+
this._showNotification({
|
|
94
|
+
message,
|
|
95
|
+
type: 'info',
|
|
96
|
+
namespace: data.namespace,
|
|
97
|
+
title: data.title
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Shows a warning notification.
|
|
102
|
+
*
|
|
103
|
+
* By default, it fires the {@link #event:show:warning `show:warning` event}
|
|
104
|
+
* with the given `data`. The event namespace can be extended using the `data.namespace` option. For example:
|
|
105
|
+
*
|
|
106
|
+
* showWarning( 'Image upload error.', {
|
|
107
|
+
* namespace: 'upload:image'
|
|
108
|
+
* } );
|
|
109
|
+
*
|
|
110
|
+
* will fire the `show:warning:upload:image` event.
|
|
111
|
+
*
|
|
112
|
+
* You can provide the title of the notification:
|
|
113
|
+
*
|
|
114
|
+
* showWarning( 'Image upload error.', {
|
|
115
|
+
* title: 'Upload failed'
|
|
116
|
+
* } );
|
|
117
|
+
*
|
|
118
|
+
* Note that each unhandled and not stopped `warning` notification will be displayed as a system alert.
|
|
119
|
+
* The plugin responsible for displaying warnings should `stop()` the event to prevent displaying it as an alert:
|
|
120
|
+
*
|
|
121
|
+
* notifications.on( 'show:warning', ( evt, data ) => {
|
|
122
|
+
* // Do something with the data.
|
|
123
|
+
*
|
|
124
|
+
* // Stop this event to prevent displaying it as an alert.
|
|
125
|
+
* evt.stop();
|
|
126
|
+
* } );
|
|
127
|
+
*
|
|
128
|
+
* You can attach many listeners to the same event and `stop()` this event in a listener with a low priority:
|
|
129
|
+
*
|
|
130
|
+
* notifications.on( 'show:warning', ( evt, data ) => {
|
|
131
|
+
* // Show the warning in the UI, but do not stop it.
|
|
132
|
+
* } );
|
|
133
|
+
*
|
|
134
|
+
* notifications.on( 'show:warning', ( evt, data ) => {
|
|
135
|
+
* // Log the warning to some error tracker.
|
|
136
|
+
*
|
|
137
|
+
* // Stop this event to prevent displaying it as an alert.
|
|
138
|
+
* evt.stop();
|
|
139
|
+
* }, { priority: 'low' } );
|
|
140
|
+
*
|
|
141
|
+
* @param {String} message The content of the notification.
|
|
142
|
+
* @param {Object} [data={}] Additional data.
|
|
143
|
+
* @param {String} [data.namespace] Additional event namespace.
|
|
144
|
+
* @param {String} [data.title] The title of the notification.
|
|
145
|
+
*/
|
|
146
|
+
showWarning(message, data = {}) {
|
|
147
|
+
this._showNotification({
|
|
148
|
+
message,
|
|
149
|
+
type: 'warning',
|
|
150
|
+
namespace: data.namespace,
|
|
151
|
+
title: data.title
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Fires the `show` event with the specified type, namespace and message.
|
|
156
|
+
*
|
|
157
|
+
* @private
|
|
158
|
+
* @param {Object} data The message data.
|
|
159
|
+
* @param {String} data.message The content of the notification.
|
|
160
|
+
* @param {'success'|'info'|'warning'} data.type The type of the message.
|
|
161
|
+
* @param {String} [data.namespace] Additional event namespace.
|
|
162
|
+
* @param {String} [data.title=''] The title of the notification.
|
|
163
|
+
*/
|
|
164
|
+
_showNotification(data) {
|
|
165
|
+
const event = data.namespace ?
|
|
166
|
+
`show:${data.type}:${data.namespace}` :
|
|
167
|
+
`show:${data.type}`;
|
|
168
|
+
this.fire(event, {
|
|
169
|
+
message: data.message,
|
|
170
|
+
type: data.type,
|
|
171
|
+
title: data.title || ''
|
|
172
|
+
});
|
|
173
|
+
}
|
|
225
174
|
}
|