@@ -52,16 +52,23 @@ export default class Notification extends Plugin {
5252 * } );
5353 *
5454 * will fire `show:success:upload:image` event.
55+ * Title of the notification can be provided:
56+ *
57+ * showSuccess( 'Image is uploaded.', {
58+ * title: 'Image upload success'
59+ * });
5560 *
5661 * @param {String } message Content of the notification.
5762 * @param {Object } [data={}] Additional data.
5863 * @param {String } [data.namespace] Additional event namespace.
64+ * @param {String } [data.title] Title of the notification.
5965 */
6066 showSuccess ( message , data = { } ) {
6167 this . _showNotification ( {
6268 message,
6369 type : 'success' ,
64- namespace : data . namespace
70+ namespace : data . namespace ,
71+ title : data . title
6572 } ) ;
6673 }
6774
@@ -76,16 +83,23 @@ export default class Notification extends Plugin {
7683 * } );
7784 *
7885 * will fire `show:info:editor:status` event.
86+ * Title of the notification can be provided:
87+ *
88+ * showInfo( 'Editor is offline.', {
89+ * title: 'Network information'
90+ * });
7991 *
8092 * @param {String } message Content of the notification.
8193 * @param {Object } [data={}] Additional data.
8294 * @param {String } [data.namespace] Additional event namespace.
95+ * @param {String } [data.title] Title of the notification.
8396 */
8497 showInfo ( message , data = { } ) {
8598 this . _showNotification ( {
8699 message,
87100 type : 'info' ,
88- namespace : data . namespace
101+ namespace : data . namespace ,
102+ title : data . title
89103 } ) ;
90104 }
91105
@@ -100,6 +114,11 @@ export default class Notification extends Plugin {
100114 * } );
101115 *
102116 * will fire `show:warning:upload:image` event.
117+ * Title of the notification can be provided:
118+ *
119+ * showWarning( 'Image upload error.', {
120+ * title: 'Upload failed'
121+ * });
103122 *
104123 * Note that each unhandled and not stopped `warning` notification will be displayed as system alert.
105124 * Plugin responsible for displaying warnings should `stop()` the event to prevent of displaying it as alert:
@@ -127,12 +146,14 @@ export default class Notification extends Plugin {
127146 * @param {String } message Content of the notification.
128147 * @param {Object } [data={}] Additional data.
129148 * @param {String } [data.namespace] Additional event namespace.
149+ * @param {String } [data.title] Title of the notification.
130150 */
131151 showWarning ( message , data = { } ) {
132152 this . _showNotification ( {
133153 message,
134154 type : 'warning' ,
135- namespace : data . namespace
155+ namespace : data . namespace ,
156+ title : data . title
136157 } ) ;
137158 }
138159
@@ -144,13 +165,15 @@ export default class Notification extends Plugin {
144165 * @param {String } data.message Content of the notification.
145166 * @param {'success'|'info'|'warning' } data.type Type of message.
146167 * @param {String } [data.namespace] Additional event namespace.
168+ * @param {String } [data.title=''] Title of the notification.
147169 */
148170 _showNotification ( data ) {
149171 const event = `show:${ data . type } ` + ( data . namespace ? `:${ data . namespace } ` : '' ) ;
150172
151173 this . fire ( event , {
152174 message : data . message ,
153- type : data . type
175+ type : data . type ,
176+ title : data . title || ''
154177 } ) ;
155178 }
156179
@@ -160,6 +183,7 @@ export default class Notification extends Plugin {
160183 * @event show
161184 * @param {Object } data Notification data.
162185 * @param {String } data.message Content of the notification.
186+ * @param {String } data.title Title of the notification.
163187 * @param {'success'|'info'|'warning' } data.type Type of notification.
164188 */
165189
@@ -169,6 +193,7 @@ export default class Notification extends Plugin {
169193 * @event show:success
170194 * @param {Object } data Notification data.
171195 * @param {String } data.message Content of the notification.
196+ * @param {String } data.title Title of the notification.
172197 * @param {'success' } data.type Type of notification.
173198 */
174199
@@ -178,6 +203,7 @@ export default class Notification extends Plugin {
178203 * @event show:info
179204 * @param {Object } data Notification data.
180205 * @param {String } data.message Content of the notification.
206+ * @param {String } data.title Title of the notification.
181207 * @param {'info' } data.type Type of notification.
182208 */
183209
@@ -190,6 +216,7 @@ export default class Notification extends Plugin {
190216 * @event show:warning
191217 * @param {Object } data Notification data.
192218 * @param {String } data.message Content of the notification.
219+ * @param {String } data.title Title of the notification.
193220 * @param {'warning' } data.type Type of notification.
194221 */
195222}
0 commit comments