@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
|
@@ -11,103 +11,26 @@ import { uid } from '@ckeditor/ckeditor5-utils';
|
|
|
11
11
|
import '../../theme/components/labeledinput/labeledinput.css';
|
|
12
12
|
/**
|
|
13
13
|
* The labeled input view class.
|
|
14
|
-
*
|
|
15
|
-
* @extends module:ui/view~View
|
|
16
14
|
*/
|
|
17
15
|
export default class LabeledInputView extends View {
|
|
18
16
|
/**
|
|
19
17
|
* Creates an instance of the labeled input view class.
|
|
20
18
|
*
|
|
21
|
-
* @param
|
|
22
|
-
* @param
|
|
19
|
+
* @param locale The locale instance.
|
|
20
|
+
* @param InputView Constructor of the input view.
|
|
23
21
|
*/
|
|
24
22
|
constructor(locale, InputView) {
|
|
25
23
|
super(locale);
|
|
26
24
|
const inputUid = `ck-input-${uid()}`;
|
|
27
25
|
const statusUid = `ck-status-${uid()}`;
|
|
28
|
-
/**
|
|
29
|
-
* The text of the label.
|
|
30
|
-
*
|
|
31
|
-
* @observable
|
|
32
|
-
* @member {String} #label
|
|
33
|
-
*/
|
|
34
26
|
this.set('label', undefined);
|
|
35
|
-
/**
|
|
36
|
-
* The value of the input.
|
|
37
|
-
*
|
|
38
|
-
* @observable
|
|
39
|
-
* @member {String} #value
|
|
40
|
-
*/
|
|
41
27
|
this.set('value', undefined);
|
|
42
|
-
/**
|
|
43
|
-
* Controls whether the component is in read-only mode.
|
|
44
|
-
*
|
|
45
|
-
* @observable
|
|
46
|
-
* @member {Boolean} #isReadOnly
|
|
47
|
-
*/
|
|
48
28
|
this.set('isReadOnly', false);
|
|
49
|
-
/**
|
|
50
|
-
* The validation error text. When set, it will be displayed
|
|
51
|
-
* next to the {@link #inputView} as a typical validation error message.
|
|
52
|
-
* Set it to `null` to hide the message.
|
|
53
|
-
*
|
|
54
|
-
* **Note:** Setting this property to anything but `null` will automatically
|
|
55
|
-
* make the {@link module:ui/inputtext/inputtextview~InputTextView#hasError `hasError`}
|
|
56
|
-
* of the {@link #inputView} `true`.
|
|
57
|
-
*
|
|
58
|
-
* **Note:** Typing in the {@link #inputView} which fires the
|
|
59
|
-
* {@link module:ui/inputtext/inputtextview~InputTextView#event:input `input` event}
|
|
60
|
-
* resets this property back to `null`, indicating that the input field can be re–validated.
|
|
61
|
-
*
|
|
62
|
-
* @observable
|
|
63
|
-
* @member {String|null} #errorText
|
|
64
|
-
*/
|
|
65
29
|
this.set('errorText', null);
|
|
66
|
-
/**
|
|
67
|
-
* The additional information text displayed next to the {@link #inputView} which can
|
|
68
|
-
* be used to inform the user about the purpose of the input, provide help or hints.
|
|
69
|
-
*
|
|
70
|
-
* Set it to `null` to hide the message.
|
|
71
|
-
*
|
|
72
|
-
* **Note:** This text will be displayed in the same place as {@link #errorText} but the
|
|
73
|
-
* latter always takes precedence: if the {@link #errorText} is set, it replaces
|
|
74
|
-
* {@link #errorText} for as long as the value of the input is invalid.
|
|
75
|
-
*
|
|
76
|
-
* @observable
|
|
77
|
-
* @member {String|null} #infoText
|
|
78
|
-
*/
|
|
79
30
|
this.set('infoText', null);
|
|
80
|
-
/**
|
|
81
|
-
* The label view.
|
|
82
|
-
*
|
|
83
|
-
* @member {module:ui/label/labelview~LabelView} #labelView
|
|
84
|
-
*/
|
|
85
31
|
this.labelView = this._createLabelView(inputUid);
|
|
86
|
-
/**
|
|
87
|
-
* The input view.
|
|
88
|
-
*
|
|
89
|
-
* @member {module:ui/inputtext/inputtextview~InputTextView} #inputView
|
|
90
|
-
*/
|
|
91
32
|
this.inputView = this._createInputView(InputView, inputUid, statusUid);
|
|
92
|
-
/**
|
|
93
|
-
* The status view for the {@link #inputView}. It displays {@link #errorText} and
|
|
94
|
-
* {@link #infoText}.
|
|
95
|
-
*
|
|
96
|
-
* @member {module:ui/view~View} #statusView
|
|
97
|
-
*/
|
|
98
33
|
this.statusView = this._createStatusView(statusUid);
|
|
99
|
-
/**
|
|
100
|
-
* The combined status text made of {@link #errorText} and {@link #infoText}.
|
|
101
|
-
* Note that when present, {@link #errorText} always takes precedence in the
|
|
102
|
-
* status.
|
|
103
|
-
*
|
|
104
|
-
* @see #errorText
|
|
105
|
-
* @see #infoText
|
|
106
|
-
* @see #statusView
|
|
107
|
-
* @private
|
|
108
|
-
* @observable
|
|
109
|
-
* @member {String|null} #_statusText
|
|
110
|
-
*/
|
|
111
34
|
this.bind('_statusText').to(this, 'errorText', this, 'infoText', (errorText, infoText) => errorText || infoText);
|
|
112
35
|
const bind = this.bindTemplate;
|
|
113
36
|
this.setTemplate({
|
|
@@ -129,9 +52,7 @@ export default class LabeledInputView extends View {
|
|
|
129
52
|
/**
|
|
130
53
|
* Creates label view class instance and bind with view.
|
|
131
54
|
*
|
|
132
|
-
* @
|
|
133
|
-
* @param {String} id Unique id to set as labelView#for attribute.
|
|
134
|
-
* @returns {module:ui/label/labelview~LabelView}
|
|
55
|
+
* @param id Unique id to set as labelView#for attribute.
|
|
135
56
|
*/
|
|
136
57
|
_createLabelView(id) {
|
|
137
58
|
const labelView = new LabelView(this.locale);
|
|
@@ -142,11 +63,9 @@ export default class LabeledInputView extends View {
|
|
|
142
63
|
/**
|
|
143
64
|
* Creates input view class instance and bind with view.
|
|
144
65
|
*
|
|
145
|
-
* @
|
|
146
|
-
* @param
|
|
147
|
-
* @param
|
|
148
|
-
* @param {String} statusUid Unique id of the status for the input's `aria-describedby` attribute.
|
|
149
|
-
* @returns {module:ui/inputtext/inputtextview~InputTextView}
|
|
66
|
+
* @param InputView Input view constructor.
|
|
67
|
+
* @param inputUid Unique id to set as inputView#id attribute.
|
|
68
|
+
* @param statusUid Unique id of the status for the input's `aria-describedby` attribute.
|
|
150
69
|
*/
|
|
151
70
|
_createInputView(InputView, inputUid, statusUid) {
|
|
152
71
|
const inputView = new InputView(this.locale, statusUid);
|
|
@@ -166,9 +85,7 @@ export default class LabeledInputView extends View {
|
|
|
166
85
|
* Creates the status view instance. It displays {@link #errorText} and {@link #infoText}
|
|
167
86
|
* next to the {@link #inputView}. See {@link #_statusText}.
|
|
168
87
|
*
|
|
169
|
-
* @
|
|
170
|
-
* @param {String} statusUid Unique id of the status, shared with the input's `aria-describedby` attribute.
|
|
171
|
-
* @returns {module:ui/view~View}
|
|
88
|
+
* @param statusUid Unique id of the status, shared with the input's `aria-describedby` attribute.
|
|
172
89
|
*/
|
|
173
90
|
_createStatusView(statusUid) {
|
|
174
91
|
const statusView = new View(this.locale);
|
|
@@ -0,0 +1,35 @@
|
|
|
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/list/listitemview
|
|
7
|
+
*/
|
|
8
|
+
import View from '../view';
|
|
9
|
+
import type ViewCollection from '../viewcollection';
|
|
10
|
+
import type { Locale } from '@ckeditor/ckeditor5-utils';
|
|
11
|
+
/**
|
|
12
|
+
* The list item view class.
|
|
13
|
+
*/
|
|
14
|
+
export default class ListItemView extends View {
|
|
15
|
+
/**
|
|
16
|
+
* Collection of the child views inside of the list item {@link #element}.
|
|
17
|
+
*/
|
|
18
|
+
readonly children: ViewCollection;
|
|
19
|
+
/**
|
|
20
|
+
* Controls whether the item view is visible. Visible by default, list items are hidden
|
|
21
|
+
* using a CSS class.
|
|
22
|
+
*
|
|
23
|
+
* @observable
|
|
24
|
+
* @default true
|
|
25
|
+
*/
|
|
26
|
+
isVisible: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* @inheritDoc
|
|
29
|
+
*/
|
|
30
|
+
constructor(locale?: Locale);
|
|
31
|
+
/**
|
|
32
|
+
* Focuses the list item.
|
|
33
|
+
*/
|
|
34
|
+
focus(): void;
|
|
35
|
+
}
|
package/src/list/listitemview.js
CHANGED
|
@@ -8,8 +8,6 @@
|
|
|
8
8
|
import View from '../view';
|
|
9
9
|
/**
|
|
10
10
|
* The list item view class.
|
|
11
|
-
*
|
|
12
|
-
* @extends module:ui/view~View
|
|
13
11
|
*/
|
|
14
12
|
export default class ListItemView extends View {
|
|
15
13
|
/**
|
|
@@ -18,21 +16,7 @@ export default class ListItemView extends View {
|
|
|
18
16
|
constructor(locale) {
|
|
19
17
|
super(locale);
|
|
20
18
|
const bind = this.bindTemplate;
|
|
21
|
-
/**
|
|
22
|
-
* Controls whether the item view is visible. Visible by default, list items are hidden
|
|
23
|
-
* using a CSS class.
|
|
24
|
-
*
|
|
25
|
-
* @observable
|
|
26
|
-
* @default true
|
|
27
|
-
* @member {Boolean} #isVisible
|
|
28
|
-
*/
|
|
29
19
|
this.set('isVisible', true);
|
|
30
|
-
/**
|
|
31
|
-
* Collection of the child views inside of the list item {@link #element}.
|
|
32
|
-
*
|
|
33
|
-
* @readonly
|
|
34
|
-
* @member {module:ui/viewcollection~ViewCollection}
|
|
35
|
-
*/
|
|
36
20
|
this.children = this.createCollection();
|
|
37
21
|
this.setTemplate({
|
|
38
22
|
tag: 'li',
|
|
@@ -0,0 +1,18 @@
|
|
|
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/list/listseparatorview
|
|
7
|
+
*/
|
|
8
|
+
import View from '../view';
|
|
9
|
+
import type { Locale } from '@ckeditor/ckeditor5-utils';
|
|
10
|
+
/**
|
|
11
|
+
* The list separator view class.
|
|
12
|
+
*/
|
|
13
|
+
export default class ListSeparatorView extends View {
|
|
14
|
+
/**
|
|
15
|
+
* @inheritDoc
|
|
16
|
+
*/
|
|
17
|
+
constructor(locale?: Locale);
|
|
18
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
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/list/listview
|
|
7
|
+
*/
|
|
8
|
+
import View from '../view';
|
|
9
|
+
import type DropdownPanelFocusable from '../dropdown/dropdownpanelfocusable';
|
|
10
|
+
import type ViewCollection from '../viewcollection';
|
|
11
|
+
import { FocusTracker, KeystrokeHandler, type Locale } from '@ckeditor/ckeditor5-utils';
|
|
12
|
+
import '../../theme/components/list/list.css';
|
|
13
|
+
/**
|
|
14
|
+
* The list view class.
|
|
15
|
+
*/
|
|
16
|
+
export default class ListView extends View<HTMLUListElement> implements DropdownPanelFocusable {
|
|
17
|
+
/**
|
|
18
|
+
* Collection of the child list views.
|
|
19
|
+
*/
|
|
20
|
+
readonly items: ViewCollection;
|
|
21
|
+
/**
|
|
22
|
+
* Tracks information about DOM focus in the list.
|
|
23
|
+
*/
|
|
24
|
+
readonly focusTracker: FocusTracker;
|
|
25
|
+
/**
|
|
26
|
+
* Instance of the {@link module:utils/keystrokehandler~KeystrokeHandler}.
|
|
27
|
+
*/
|
|
28
|
+
readonly keystrokes: KeystrokeHandler;
|
|
29
|
+
/**
|
|
30
|
+
* Label used by assistive technologies to describe this list element.
|
|
31
|
+
*
|
|
32
|
+
* @observable
|
|
33
|
+
*/
|
|
34
|
+
ariaLabel: string | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* Helps cycling over focusable {@link #items} in the list.
|
|
37
|
+
*/
|
|
38
|
+
private readonly _focusCycler;
|
|
39
|
+
/**
|
|
40
|
+
* @inheritDoc
|
|
41
|
+
*/
|
|
42
|
+
constructor(locale?: Locale);
|
|
43
|
+
/**
|
|
44
|
+
* @inheritDoc
|
|
45
|
+
*/
|
|
46
|
+
render(): void;
|
|
47
|
+
/**
|
|
48
|
+
* @inheritDoc
|
|
49
|
+
*/
|
|
50
|
+
destroy(): void;
|
|
51
|
+
/**
|
|
52
|
+
* Focuses the first focusable in {@link #items}.
|
|
53
|
+
*/
|
|
54
|
+
focus(): void;
|
|
55
|
+
/**
|
|
56
|
+
* Focuses the last focusable in {@link #items}.
|
|
57
|
+
*/
|
|
58
|
+
focusLast(): void;
|
|
59
|
+
}
|
package/src/list/listview.js
CHANGED
|
@@ -11,9 +11,6 @@ import { FocusTracker, KeystrokeHandler } from '@ckeditor/ckeditor5-utils';
|
|
|
11
11
|
import '../../theme/components/list/list.css';
|
|
12
12
|
/**
|
|
13
13
|
* The list view class.
|
|
14
|
-
*
|
|
15
|
-
* @extends module:ui/view~View
|
|
16
|
-
* @implements module:ui/dropdown/dropdownpanelfocusable~DropdownPanelFocusable
|
|
17
14
|
*/
|
|
18
15
|
export default class ListView extends View {
|
|
19
16
|
/**
|
|
@@ -22,34 +19,9 @@ export default class ListView extends View {
|
|
|
22
19
|
constructor(locale) {
|
|
23
20
|
super(locale);
|
|
24
21
|
const bind = this.bindTemplate;
|
|
25
|
-
/**
|
|
26
|
-
* Collection of the child list views.
|
|
27
|
-
*
|
|
28
|
-
* @readonly
|
|
29
|
-
* @member {module:ui/viewcollection~ViewCollection}
|
|
30
|
-
*/
|
|
31
22
|
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
23
|
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
24
|
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
25
|
this._focusCycler = new FocusCycler({
|
|
54
26
|
focusables: this.items,
|
|
55
27
|
focusTracker: this.focusTracker,
|
|
@@ -61,11 +33,6 @@ export default class ListView extends View {
|
|
|
61
33
|
focusNext: 'arrowdown'
|
|
62
34
|
}
|
|
63
35
|
});
|
|
64
|
-
/**
|
|
65
|
-
* Label used by assistive technologies to describe this list element.
|
|
66
|
-
*
|
|
67
|
-
* @member {String} #ariaLabel
|
|
68
|
-
*/
|
|
69
36
|
this.set('ariaLabel', undefined);
|
|
70
37
|
this.setTemplate({
|
|
71
38
|
tag: 'ul',
|
package/src/model.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+
declare const Model_base: {
|
|
6
|
+
new (): import("@ckeditor/ckeditor5-utils").Observable;
|
|
7
|
+
prototype: import("@ckeditor/ckeditor5-utils").Observable;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* The base MVC model class.
|
|
11
|
+
*/
|
|
12
|
+
export default class Model extends Model_base {
|
|
13
|
+
[x: string]: unknown;
|
|
14
|
+
/**
|
|
15
|
+
* Creates a new Model instance.
|
|
16
|
+
*
|
|
17
|
+
* @param attributes The model state attributes to be defined during the instance creation.
|
|
18
|
+
* @param properties The (out of state) properties to be appended to the instance during creation.
|
|
19
|
+
*/
|
|
20
|
+
constructor(attributes?: Record<string, unknown>, properties?: Record<string, unknown>);
|
|
21
|
+
}
|
|
22
|
+
export {};
|
package/src/model.js
CHANGED
|
@@ -9,15 +9,13 @@ import { ObservableMixin } from '@ckeditor/ckeditor5-utils';
|
|
|
9
9
|
import { extend } from 'lodash-es';
|
|
10
10
|
/**
|
|
11
11
|
* The base MVC model class.
|
|
12
|
-
*
|
|
13
|
-
* @mixes module:utils/observablemixin~ObservableMixin
|
|
14
12
|
*/
|
|
15
13
|
export default class Model extends ObservableMixin() {
|
|
16
14
|
/**
|
|
17
15
|
* Creates a new Model instance.
|
|
18
16
|
*
|
|
19
|
-
* @param
|
|
20
|
-
* @param
|
|
17
|
+
* @param attributes The model state attributes to be defined during the instance creation.
|
|
18
|
+
* @param properties The (out of state) properties to be appended to the instance during creation.
|
|
21
19
|
*/
|
|
22
20
|
constructor(attributes, properties) {
|
|
23
21
|
super();
|
|
@@ -0,0 +1,216 @@
|
|
|
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/notification/notification
|
|
7
|
+
*/
|
|
8
|
+
import { ContextPlugin } from '@ckeditor/ckeditor5-core';
|
|
9
|
+
/**
|
|
10
|
+
* The Notification plugin.
|
|
11
|
+
*
|
|
12
|
+
* This plugin sends a few types of notifications: `success`, `info` and `warning`. The notifications need to be
|
|
13
|
+
* handled and displayed by a plugin responsible for showing the UI of the notifications. Using this plugin for dispatching
|
|
14
|
+
* notifications makes it possible to switch the notifications UI.
|
|
15
|
+
*
|
|
16
|
+
* Note that every unhandled and not stopped `warning` notification will be displayed as a system alert.
|
|
17
|
+
* See {@link module:ui/notification/notification~Notification#showWarning}.
|
|
18
|
+
*/
|
|
19
|
+
export default class Notification extends ContextPlugin {
|
|
20
|
+
/**
|
|
21
|
+
* @inheritDoc
|
|
22
|
+
*/
|
|
23
|
+
static get pluginName(): 'Notification';
|
|
24
|
+
/**
|
|
25
|
+
* @inheritDoc
|
|
26
|
+
*/
|
|
27
|
+
init(): void;
|
|
28
|
+
/**
|
|
29
|
+
* Shows a success notification.
|
|
30
|
+
*
|
|
31
|
+
* By default, it fires the {@link #event:show:success `show:success` event} with the given `data`. The event namespace can be extended
|
|
32
|
+
* using the `data.namespace` option. For example:
|
|
33
|
+
*
|
|
34
|
+
* ```ts
|
|
35
|
+
* showSuccess( 'Image is uploaded.', {
|
|
36
|
+
* namespace: 'upload:image'
|
|
37
|
+
* } );
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* will fire the `show:success:upload:image` event.
|
|
41
|
+
*
|
|
42
|
+
* You can provide the title of the notification:
|
|
43
|
+
*
|
|
44
|
+
* ```ts
|
|
45
|
+
* showSuccess( 'Image is uploaded.', {
|
|
46
|
+
* title: 'Image upload success'
|
|
47
|
+
* } );
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* @param message The content of the notification.
|
|
51
|
+
* @param data Additional data.
|
|
52
|
+
* @param data.namespace Additional event namespace.
|
|
53
|
+
* @param data.title The title of the notification.
|
|
54
|
+
*/
|
|
55
|
+
showSuccess(message: string, data?: {
|
|
56
|
+
namespace?: string;
|
|
57
|
+
title?: string;
|
|
58
|
+
}): void;
|
|
59
|
+
/**
|
|
60
|
+
* Shows an information notification.
|
|
61
|
+
*
|
|
62
|
+
* By default, it fires the {@link #event:show:info `show:info` event} with the given `data`. The event namespace can be extended
|
|
63
|
+
* using the `data.namespace` option. For example:
|
|
64
|
+
*
|
|
65
|
+
* ```ts
|
|
66
|
+
* showInfo( 'Editor is offline.', {
|
|
67
|
+
* namespace: 'editor:status'
|
|
68
|
+
* } );
|
|
69
|
+
* ```
|
|
70
|
+
*
|
|
71
|
+
* will fire the `show:info:editor:status` event.
|
|
72
|
+
*
|
|
73
|
+
* You can provide the title of the notification:
|
|
74
|
+
*
|
|
75
|
+
* ```ts
|
|
76
|
+
* showInfo( 'Editor is offline.', {
|
|
77
|
+
* title: 'Network information'
|
|
78
|
+
* } );
|
|
79
|
+
* ```
|
|
80
|
+
*
|
|
81
|
+
* @param message The content of the notification.
|
|
82
|
+
* @param data Additional data.
|
|
83
|
+
* @param data.namespace Additional event namespace.
|
|
84
|
+
* @param data.title The title of the notification.
|
|
85
|
+
*/
|
|
86
|
+
showInfo(message: string, data?: {
|
|
87
|
+
namespace?: string;
|
|
88
|
+
title?: string;
|
|
89
|
+
}): void;
|
|
90
|
+
/**
|
|
91
|
+
* Shows a warning notification.
|
|
92
|
+
*
|
|
93
|
+
* By default, it fires the {@link #event:show:warning `show:warning` event}
|
|
94
|
+
* with the given `data`. The event namespace can be extended using the `data.namespace` option. For example:
|
|
95
|
+
*
|
|
96
|
+
* ```ts
|
|
97
|
+
* showWarning( 'Image upload error.', {
|
|
98
|
+
* namespace: 'upload:image'
|
|
99
|
+
* } );
|
|
100
|
+
* ```
|
|
101
|
+
*
|
|
102
|
+
* will fire the `show:warning:upload:image` event.
|
|
103
|
+
*
|
|
104
|
+
* You can provide the title of the notification:
|
|
105
|
+
*
|
|
106
|
+
* ```ts
|
|
107
|
+
* showWarning( 'Image upload error.', {
|
|
108
|
+
* title: 'Upload failed'
|
|
109
|
+
* } );
|
|
110
|
+
* ```
|
|
111
|
+
*
|
|
112
|
+
* Note that each unhandled and not stopped `warning` notification will be displayed as a system alert.
|
|
113
|
+
* The plugin responsible for displaying warnings should `stop()` the event to prevent displaying it as an alert:
|
|
114
|
+
*
|
|
115
|
+
* ```ts
|
|
116
|
+
* notifications.on( 'show:warning', ( evt, data ) => {
|
|
117
|
+
* // Do something with the data.
|
|
118
|
+
*
|
|
119
|
+
* // Stop this event to prevent displaying it as an alert.
|
|
120
|
+
* evt.stop();
|
|
121
|
+
* } );
|
|
122
|
+
* ```
|
|
123
|
+
*
|
|
124
|
+
* You can attach many listeners to the same event and `stop()` this event in a listener with a low priority:
|
|
125
|
+
*
|
|
126
|
+
* ```ts
|
|
127
|
+
* notifications.on( 'show:warning', ( evt, data ) => {
|
|
128
|
+
* // Show the warning in the UI, but do not stop it.
|
|
129
|
+
* } );
|
|
130
|
+
*
|
|
131
|
+
* notifications.on( 'show:warning', ( evt, data ) => {
|
|
132
|
+
* // Log the warning to some error tracker.
|
|
133
|
+
*
|
|
134
|
+
* // Stop this event to prevent displaying it as an alert.
|
|
135
|
+
* evt.stop();
|
|
136
|
+
* }, { priority: 'low' } );
|
|
137
|
+
* ```
|
|
138
|
+
*
|
|
139
|
+
* @param message The content of the notification.
|
|
140
|
+
* @param data Additional data.
|
|
141
|
+
* @param data.namespace Additional event namespace.
|
|
142
|
+
* @param data.title The title of the notification.
|
|
143
|
+
*/
|
|
144
|
+
showWarning(message: string, data?: {
|
|
145
|
+
namespace?: string;
|
|
146
|
+
title?: string;
|
|
147
|
+
}): void;
|
|
148
|
+
/**
|
|
149
|
+
* Fires the `show` event with the specified type, namespace and message.
|
|
150
|
+
*
|
|
151
|
+
* @param data The message data.
|
|
152
|
+
* @param data.message The content of the notification.
|
|
153
|
+
* @param data.type The type of the message.
|
|
154
|
+
* @param data.namespace Additional event namespace.
|
|
155
|
+
* @param data.title The title of the notification.
|
|
156
|
+
*/
|
|
157
|
+
private _showNotification;
|
|
158
|
+
}
|
|
159
|
+
export type NotificationEventType = 'success' | 'info' | 'warning';
|
|
160
|
+
/**
|
|
161
|
+
* Fired when one of the `showSuccess()`, `showInfo()`, `showWarning()` methods is called.
|
|
162
|
+
*
|
|
163
|
+
* @eventName show
|
|
164
|
+
* @param data The notification data.
|
|
165
|
+
*/
|
|
166
|
+
export type NotificationShowEvent = {
|
|
167
|
+
name: 'show';
|
|
168
|
+
args: [data: NotificationShowEventData];
|
|
169
|
+
};
|
|
170
|
+
/**
|
|
171
|
+
* Fired when the `showSuccess()` method is called.
|
|
172
|
+
*
|
|
173
|
+
* @eventName show:success
|
|
174
|
+
* @param data The notification data.
|
|
175
|
+
*/
|
|
176
|
+
export type NotificationShowSuccessEvent = NotificationShowTypeEvent<'success'>;
|
|
177
|
+
/**
|
|
178
|
+
* Fired when the `showInfo()` method is called.
|
|
179
|
+
*
|
|
180
|
+
* @eventName show:info
|
|
181
|
+
* @param data The notification data.
|
|
182
|
+
*/
|
|
183
|
+
export type NotificationShowInfoEvent = NotificationShowTypeEvent<'info'>;
|
|
184
|
+
/**
|
|
185
|
+
* Fired when the `showWarning()` method is called.
|
|
186
|
+
*
|
|
187
|
+
* When this event is not handled or stopped by `event.stop()`, the `data.message` of this event will
|
|
188
|
+
* be automatically displayed as a system alert.
|
|
189
|
+
*
|
|
190
|
+
* @eventName show:warning
|
|
191
|
+
* @param data The notification data.
|
|
192
|
+
*/
|
|
193
|
+
export type NotificationShowWarningEvent = NotificationShowTypeEvent<'warning'>;
|
|
194
|
+
export type NotificationShowTypeEvent<NotificationType extends NotificationEventType> = {
|
|
195
|
+
name: `show:${NotificationType}` | `show:${NotificationType}:${string}`;
|
|
196
|
+
args: [data: NotificationShowEventData<NotificationType>];
|
|
197
|
+
};
|
|
198
|
+
export type NotificationShowEventData<NotificationType extends NotificationEventType = NotificationEventType> = {
|
|
199
|
+
/**
|
|
200
|
+
* The content of the notification.
|
|
201
|
+
*/
|
|
202
|
+
message: string;
|
|
203
|
+
/**
|
|
204
|
+
* The title of the notification.
|
|
205
|
+
*/
|
|
206
|
+
title: string;
|
|
207
|
+
/**
|
|
208
|
+
* The type of the notification.
|
|
209
|
+
*/
|
|
210
|
+
type: NotificationType;
|
|
211
|
+
};
|
|
212
|
+
declare module '@ckeditor/ckeditor5-core' {
|
|
213
|
+
interface PluginsMap {
|
|
214
|
+
[Notification.pluginName]: Notification;
|
|
215
|
+
}
|
|
216
|
+
}
|