@ckeditor/ckeditor5-ui 36.0.1 → 37.0.0-alpha.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.
Files changed (114) hide show
  1. package/package.json +24 -23
  2. package/src/augmentation.d.ts +86 -0
  3. package/src/augmentation.js +5 -0
  4. package/src/bindings/addkeyboardhandlingforgrid.d.ts +27 -0
  5. package/src/bindings/addkeyboardhandlingforgrid.js +42 -34
  6. package/src/bindings/clickoutsidehandler.d.ts +28 -0
  7. package/src/bindings/clickoutsidehandler.js +5 -6
  8. package/src/bindings/csstransitiondisablermixin.d.ts +40 -0
  9. package/src/bindings/csstransitiondisablermixin.js +55 -0
  10. package/src/bindings/injectcsstransitiondisabler.d.ts +59 -0
  11. package/src/bindings/injectcsstransitiondisabler.js +23 -20
  12. package/src/bindings/preventdefault.d.ts +33 -0
  13. package/src/bindings/preventdefault.js +13 -15
  14. package/src/bindings/submithandler.d.ts +57 -0
  15. package/src/bindings/submithandler.js +23 -24
  16. package/src/button/button.d.ts +154 -0
  17. package/src/button/buttonview.d.ts +155 -0
  18. package/src/button/buttonview.js +16 -60
  19. package/src/button/switchbuttonview.d.ts +45 -0
  20. package/src/button/switchbuttonview.js +9 -18
  21. package/src/colorgrid/colorgridview.d.ts +132 -0
  22. package/src/colorgrid/colorgridview.js +13 -44
  23. package/src/colorgrid/colortileview.d.ts +28 -0
  24. package/src/colorgrid/colortileview.js +2 -15
  25. package/src/colorgrid/utils.d.ts +47 -0
  26. package/src/colorgrid/utils.js +7 -13
  27. package/src/componentfactory.d.ts +81 -0
  28. package/src/componentfactory.js +22 -36
  29. package/src/dropdown/button/dropdownbutton.d.ts +25 -0
  30. package/src/dropdown/button/dropdownbuttonview.d.ts +48 -0
  31. package/src/dropdown/button/dropdownbuttonview.js +11 -21
  32. package/src/dropdown/button/splitbuttonview.d.ts +145 -0
  33. package/src/dropdown/button/splitbuttonview.js +11 -52
  34. package/src/dropdown/dropdownpanelfocusable.d.ts +21 -0
  35. package/src/dropdown/dropdownpanelview.d.ts +62 -0
  36. package/src/dropdown/dropdownpanelview.js +2 -30
  37. package/src/dropdown/dropdownview.d.ts +315 -0
  38. package/src/dropdown/dropdownview.js +121 -222
  39. package/src/dropdown/utils.d.ts +219 -0
  40. package/src/dropdown/utils.js +112 -106
  41. package/src/editableui/editableuiview.d.ts +72 -0
  42. package/src/editableui/editableuiview.js +16 -44
  43. package/src/editableui/inline/inlineeditableuiview.d.ts +40 -0
  44. package/src/editableui/inline/inlineeditableuiview.js +5 -15
  45. package/src/editorui/bodycollection.d.ts +51 -0
  46. package/src/editorui/bodycollection.js +2 -16
  47. package/src/editorui/boxed/boxededitoruiview.d.ts +40 -0
  48. package/src/editorui/boxed/boxededitoruiview.js +1 -27
  49. package/src/editorui/editorui.d.ts +263 -0
  50. package/src/editorui/editorui.js +27 -134
  51. package/src/editorui/editoruiview.d.ts +39 -0
  52. package/src/editorui/editoruiview.js +1 -10
  53. package/src/focuscycler.d.ts +183 -0
  54. package/src/focuscycler.js +34 -90
  55. package/src/formheader/formheaderview.d.ts +53 -0
  56. package/src/formheader/formheaderview.js +3 -24
  57. package/src/icon/iconview.d.ts +78 -0
  58. package/src/icon/iconview.js +0 -50
  59. package/src/iframe/iframeview.d.ts +50 -0
  60. package/src/iframe/iframeview.js +2 -2
  61. package/src/index.d.ts +55 -0
  62. package/src/index.js +2 -0
  63. package/src/input/inputview.d.ts +121 -0
  64. package/src/input/inputview.js +0 -82
  65. package/src/inputnumber/inputnumberview.d.ts +49 -0
  66. package/src/inputnumber/inputnumberview.js +5 -28
  67. package/src/inputtext/inputtextview.d.ts +18 -0
  68. package/src/inputtext/inputtextview.js +0 -2
  69. package/src/label/labelview.d.ts +36 -0
  70. package/src/label/labelview.js +0 -20
  71. package/src/labeledfield/labeledfieldview.d.ts +182 -0
  72. package/src/labeledfield/labeledfieldview.js +20 -126
  73. package/src/labeledfield/utils.d.ts +93 -0
  74. package/src/labeledfield/utils.js +24 -18
  75. package/src/labeledinput/labeledinputview.d.ts +125 -0
  76. package/src/labeledinput/labeledinputview.js +7 -90
  77. package/src/list/listitemview.d.ts +35 -0
  78. package/src/list/listitemview.js +0 -16
  79. package/src/list/listseparatorview.d.ts +18 -0
  80. package/src/list/listseparatorview.js +0 -2
  81. package/src/list/listview.d.ts +59 -0
  82. package/src/list/listview.js +0 -33
  83. package/src/model.d.ts +22 -0
  84. package/src/model.js +2 -4
  85. package/src/notification/notification.d.ts +211 -0
  86. package/src/notification/notification.js +64 -51
  87. package/src/panel/balloon/balloonpanelview.d.ts +685 -0
  88. package/src/panel/balloon/balloonpanelview.js +146 -168
  89. package/src/panel/balloon/contextualballoon.d.ts +299 -0
  90. package/src/panel/balloon/contextualballoon.js +42 -172
  91. package/src/panel/sticky/stickypanelview.d.ts +132 -0
  92. package/src/panel/sticky/stickypanelview.js +0 -115
  93. package/src/template.d.ts +942 -0
  94. package/src/template.js +397 -461
  95. package/src/toolbar/balloon/balloontoolbar.d.ts +118 -0
  96. package/src/toolbar/balloon/balloontoolbar.js +14 -81
  97. package/src/toolbar/block/blockbuttonview.d.ts +35 -0
  98. package/src/toolbar/block/blockbuttonview.js +1 -13
  99. package/src/toolbar/block/blocktoolbar.d.ts +153 -0
  100. package/src/toolbar/block/blocktoolbar.js +31 -69
  101. package/src/toolbar/normalizetoolbarconfig.d.ts +39 -0
  102. package/src/toolbar/normalizetoolbarconfig.js +12 -8
  103. package/src/toolbar/toolbarlinebreakview.d.ts +18 -0
  104. package/src/toolbar/toolbarlinebreakview.js +0 -2
  105. package/src/toolbar/toolbarseparatorview.d.ts +18 -0
  106. package/src/toolbar/toolbarseparatorview.js +0 -2
  107. package/src/toolbar/toolbarview.d.ts +265 -0
  108. package/src/toolbar/toolbarview.js +54 -305
  109. package/src/tooltipmanager.d.ts +180 -0
  110. package/src/tooltipmanager.js +48 -95
  111. package/src/view.d.ts +422 -0
  112. package/src/view.js +182 -251
  113. package/src/viewcollection.d.ts +139 -0
  114. package/src/viewcollection.js +62 -56
@@ -24,24 +24,16 @@ import { createElement } from '@ckeditor/ckeditor5-utils';
24
24
  * If you create multiple body collections, this class will create a special wrapper element in the DOM to limit the number of
25
25
  * elements created directly in the body and remove it when the last body collection will be
26
26
  * {@link ~BodyCollection#detachFromDom detached}.
27
- *
28
- * @extends module:ui/viewcollection~ViewCollection
29
27
  */
30
28
  export default class BodyCollection extends ViewCollection {
31
29
  /**
32
30
  * Creates a new instance of the {@link module:ui/editorui/bodycollection~BodyCollection}.
33
31
  *
34
- * @param {module:utils/locale~Locale} locale The {@link module:core/editor/editor~Editor editor's locale} instance.
35
- * @param {Iterable.<module:ui/view~View>} [initialItems] The initial items of the collection.
32
+ * @param locale The {@link module:core/editor/editor~Editor editor's locale} instance.
33
+ * @param initialItems The initial items of the collection.
36
34
  */
37
35
  constructor(locale, initialItems = []) {
38
36
  super(initialItems);
39
- /**
40
- * The {@link module:core/editor/editor~Editor#locale editor's locale} instance.
41
- * See the view {@link module:ui/view~View#locale locale} property.
42
- *
43
- * @member {module:utils/locale~Locale}
44
- */
45
37
  this.locale = locale;
46
38
  }
47
39
  /**
@@ -49,12 +41,6 @@ export default class BodyCollection extends ViewCollection {
49
41
  * the body collection.
50
42
  */
51
43
  attachToDom() {
52
- /**
53
- * The element holding elements of the body region.
54
- *
55
- * @protected
56
- * @member {HTMLElement} #_bodyCollectionContainer
57
- */
58
44
  this._bodyCollectionContainer = new Template({
59
45
  tag: 'div',
60
46
  attributes: {
@@ -0,0 +1,40 @@
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/editorui/boxed/boxededitoruiview
7
+ */
8
+ import EditorUIView from '../editoruiview';
9
+ import type ViewCollection from '../../viewcollection';
10
+ import type { Locale } from '@ckeditor/ckeditor5-utils';
11
+ /**
12
+ * The boxed editor UI view class. This class represents an editor interface
13
+ * consisting of a toolbar and an editable area, enclosed within a box.
14
+ */
15
+ export default abstract class BoxedEditorUIView extends EditorUIView {
16
+ /**
17
+ * Collection of the child views located in the top (`.ck-editor__top`)
18
+ * area of the UI.
19
+ */
20
+ readonly top: ViewCollection;
21
+ /**
22
+ * Collection of the child views located in the main (`.ck-editor__main`)
23
+ * area of the UI.
24
+ */
25
+ readonly main: ViewCollection;
26
+ /**
27
+ * Voice label of the UI.
28
+ */
29
+ private readonly _voiceLabelView;
30
+ /**
31
+ * Creates an instance of the boxed editor UI view class.
32
+ *
33
+ * @param locale The locale instance..
34
+ */
35
+ constructor(locale: Locale);
36
+ /**
37
+ * Creates a voice label view instance.
38
+ */
39
+ private _createVoiceLabel;
40
+ }
@@ -10,40 +10,17 @@ import LabelView from '../../label/labelview';
10
10
  /**
11
11
  * The boxed editor UI view class. This class represents an editor interface
12
12
  * consisting of a toolbar and an editable area, enclosed within a box.
13
- *
14
- * @extends module:ui/editorui/editoruiview~EditorUIView
15
13
  */
16
14
  export default class BoxedEditorUIView extends EditorUIView {
17
15
  /**
18
16
  * Creates an instance of the boxed editor UI view class.
19
17
  *
20
- * @param {module:utils/locale~Locale} locale The locale instance..
18
+ * @param locale The locale instance..
21
19
  */
22
20
  constructor(locale) {
23
21
  super(locale);
24
- /**
25
- * Collection of the child views located in the top (`.ck-editor__top`)
26
- * area of the UI.
27
- *
28
- * @readonly
29
- * @member {module:ui/viewcollection~ViewCollection}
30
- */
31
22
  this.top = this.createCollection();
32
- /**
33
- * Collection of the child views located in the main (`.ck-editor__main`)
34
- * area of the UI.
35
- *
36
- * @readonly
37
- * @member {module:ui/viewcollection~ViewCollection}
38
- */
39
23
  this.main = this.createCollection();
40
- /**
41
- * Voice label of the UI.
42
- *
43
- * @protected
44
- * @readonly
45
- * @member {module:ui/view~View} #_voiceLabelView
46
- */
47
24
  this._voiceLabelView = this._createVoiceLabel();
48
25
  this.setTemplate({
49
26
  tag: 'div',
@@ -89,9 +66,6 @@ export default class BoxedEditorUIView extends EditorUIView {
89
66
  }
90
67
  /**
91
68
  * Creates a voice label view instance.
92
- *
93
- * @private
94
- * @returns {module:ui/label/labelview~LabelView}
95
69
  */
96
70
  _createVoiceLabel() {
97
71
  const t = this.t;
@@ -0,0 +1,263 @@
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/editorui/editorui
7
+ */
8
+ import ComponentFactory from '../componentfactory';
9
+ import TooltipManager from '../tooltipmanager';
10
+ import type EditorUIView from './editoruiview';
11
+ import type ToolbarView from '../toolbar/toolbarview';
12
+ import { FocusTracker } from '@ckeditor/ckeditor5-utils';
13
+ import type { Editor } from '@ckeditor/ckeditor5-core';
14
+ declare const EditorUI_base: {
15
+ new (): import("@ckeditor/ckeditor5-utils").Observable;
16
+ prototype: import("@ckeditor/ckeditor5-utils").Observable;
17
+ };
18
+ /**
19
+ * A class providing the minimal interface that is required to successfully bootstrap any editor UI.
20
+ */
21
+ export default abstract class EditorUI extends EditorUI_base {
22
+ /**
23
+ * The editor that the UI belongs to.
24
+ */
25
+ readonly editor: Editor;
26
+ /**
27
+ * An instance of the {@link module:ui/componentfactory~ComponentFactory}, a registry used by plugins
28
+ * to register factories of specific UI components.
29
+ */
30
+ readonly componentFactory: ComponentFactory;
31
+ /**
32
+ * Stores the information about the editor UI focus and propagates it so various plugins and components
33
+ * are unified as a focus group.
34
+ */
35
+ readonly focusTracker: FocusTracker;
36
+ /**
37
+ * Manages the tooltips displayed on mouseover and focus across the UI.
38
+ */
39
+ readonly tooltipManager: TooltipManager;
40
+ /**
41
+ * Indicates the UI is ready. Set `true` after {@link #event:ready} event is fired.
42
+ *
43
+ * @readonly
44
+ * @default false
45
+ */
46
+ isReady: boolean;
47
+ abstract get view(): EditorUIView;
48
+ /**
49
+ * Stores viewport offsets from every direction.
50
+ *
51
+ * Viewport offset can be used to constrain balloons or other UI elements into an element smaller than the viewport.
52
+ * This can be useful if there are any other absolutely positioned elements that may interfere with editor UI.
53
+ *
54
+ * Example `editor.ui.viewportOffset` returns:
55
+ *
56
+ * ```js
57
+ * {
58
+ * top: 50,
59
+ * right: 50,
60
+ * bottom: 50,
61
+ * left: 50
62
+ * }
63
+ * ```
64
+ *
65
+ * This property can be overriden after editor already being initialized:
66
+ *
67
+ * ```js
68
+ * editor.ui.viewportOffset = {
69
+ * top: 100,
70
+ * right: 0,
71
+ * bottom: 0,
72
+ * left: 0
73
+ * };
74
+ * ```
75
+ *
76
+ * @observable
77
+ */
78
+ viewportOffset: {
79
+ left?: number;
80
+ right?: number;
81
+ top?: number;
82
+ bottom?: number;
83
+ };
84
+ /**
85
+ * Stores all editable elements used by the editor instance.
86
+ */
87
+ private _editableElementsMap;
88
+ /**
89
+ * All available & focusable toolbars.
90
+ */
91
+ private _focusableToolbarDefinitions;
92
+ /**
93
+ * Creates an instance of the editor UI class.
94
+ *
95
+ * @param editor The editor instance.
96
+ */
97
+ constructor(editor: Editor);
98
+ /**
99
+ * The main (outermost) DOM element of the editor UI.
100
+ *
101
+ * For example, in {@link module:editor-classic/classiceditor~ClassicEditor} it is a `<div>` which
102
+ * wraps the editable element and the toolbar. In {@link module:editor-inline/inlineeditor~InlineEditor}
103
+ * it is the editable element itself (as there is no other wrapper). However, in
104
+ * {@link module:editor-decoupled/decouplededitor~DecoupledEditor} it is set to `null` because this editor does not
105
+ * come with a single "main" HTML element (its editable element and toolbar are separate).
106
+ *
107
+ * This property can be understood as a shorthand for retrieving the element that a specific editor integration
108
+ * considers to be its main DOM element.
109
+ */
110
+ get element(): HTMLElement | null;
111
+ /**
112
+ * Fires the {@link module:ui/editorui/editorui~EditorUI#event:update `update`} event.
113
+ *
114
+ * This method should be called when the editor UI (e.g. positions of its balloons) needs to be updated due to
115
+ * some environmental change which CKEditor 5 is not aware of (e.g. resize of a container in which it is used).
116
+ */
117
+ update(): void;
118
+ /**
119
+ * Destroys the UI.
120
+ */
121
+ destroy(): void;
122
+ /**
123
+ * Stores the native DOM editable element used by the editor under a unique name.
124
+ *
125
+ * Also, registers the element in the editor to maintain the accessibility of the UI. When the user is editing text in a focusable
126
+ * editable area, they can use the <kbd>Alt</kbd> + <kbd>F10</kbd> keystroke to navigate over editor toolbars. See {@link #addToolbar}.
127
+ *
128
+ * @param rootName The unique name of the editable element.
129
+ * @param domElement The native DOM editable element.
130
+ */
131
+ setEditableElement(rootName: string, domElement: HTMLElement): void;
132
+ /**
133
+ * Returns the editable editor element with the given name or null if editable does not exist.
134
+ *
135
+ * @param rootName The editable name.
136
+ */
137
+ getEditableElement(rootName?: string): HTMLElement | undefined;
138
+ /**
139
+ * Returns array of names of all editor editable elements.
140
+ */
141
+ getEditableElementsNames(): IterableIterator<string>;
142
+ /**
143
+ * Adds a toolbar to the editor UI. Used primarily to maintain the accessibility of the UI.
144
+ *
145
+ * Focusable toolbars can be accessed (focused) by users by pressing the <kbd>Alt</kbd> + <kbd>F10</kbd> keystroke.
146
+ * Successive keystroke presses navigate over available toolbars.
147
+ *
148
+ * @param toolbarView A instance of the toolbar to be registered.
149
+ */
150
+ addToolbar(toolbarView: ToolbarView, options?: FocusableToolbarOptions): void;
151
+ /**
152
+ * Stores all editable elements used by the editor instance.
153
+ *
154
+ * @deprecated
155
+ */
156
+ protected get _editableElements(): unknown;
157
+ /**
158
+ * Returns viewport offsets object:
159
+ *
160
+ * ```js
161
+ * {
162
+ * top: Number,
163
+ * right: Number,
164
+ * bottom: Number,
165
+ * left: Number
166
+ * }
167
+ * ```
168
+ *
169
+ * Only top property is currently supported.
170
+ */
171
+ private _readViewportOffsetFromConfig;
172
+ /**
173
+ * Starts listening for <kbd>Alt</kbd> + <kbd>F10</kbd> and <kbd>Esc</kbd> keystrokes in the context of focusable
174
+ * {@link #setEditableElement editable elements} and {@link #addToolbar toolbars}
175
+ * to allow users navigate across the UI.
176
+ */
177
+ private _initFocusTracking;
178
+ /**
179
+ * Returns definitions of toolbars that could potentially be focused, sorted by their importance for the user.
180
+ *
181
+ * Focusable toolbars candidates are either:
182
+ * * already visible,
183
+ * * have `beforeFocus()` set in their {@link module:ui/editorui/editorui~FocusableToolbarDefinition definition} that suggests that
184
+ * they might show up when called. Keep in mind that determining whether a toolbar will show up (and become focusable) is impossible
185
+ * at this stage because it depends on its implementation, that in turn depends on the editing context (selection).
186
+ *
187
+ * **Note**: Contextual toolbars take precedence over regular toolbars.
188
+ */
189
+ private _getFocusableCandidateToolbarDefinitions;
190
+ /**
191
+ * Returns a definition of the toolbar that is currently visible and focused (one of its children has focus).
192
+ *
193
+ * `null` is returned when no toolbar is currently focused.
194
+ */
195
+ private _getCurrentFocusedToolbarDefinition;
196
+ /**
197
+ * Focuses a focusable toolbar candidate using its definition.
198
+ *
199
+ * @param candidateToolbarDefinition A definition of the toolbar to focus.
200
+ * @returns `true` when the toolbar candidate was focused. `false` otherwise.
201
+ */
202
+ private _focusFocusableCandidateToolbar;
203
+ }
204
+ /**
205
+ * Fired when the editor UI is ready.
206
+ *
207
+ * Fired before {@link module:engine/controller/datacontroller~DataController#event:ready}.
208
+ *
209
+ * @eventName ~EditorUI#ready
210
+ */
211
+ export type EditorUIReadyEvent = {
212
+ name: 'ready';
213
+ args: [];
214
+ };
215
+ /**
216
+ * Fired whenever the UI (all related components) should be refreshed.
217
+ *
218
+ * **Note:**: The event is fired after each {@link module:engine/view/document~Document#event:layoutChanged}.
219
+ * It can also be fired manually via the {@link module:ui/editorui/editorui~EditorUI#update} method.
220
+ *
221
+ * @eventName ~EditorUI#update
222
+ */
223
+ export type EditorUIUpdateEvent = {
224
+ name: 'update';
225
+ args: [];
226
+ };
227
+ /**
228
+ * A definition of a focusable toolbar. Used by {@link module:ui/editorui/editorui~EditorUI#addToolbar}.
229
+ */
230
+ export interface FocusableToolbarDefinition {
231
+ /**
232
+ * An instance of a focusable toolbar view.
233
+ */
234
+ toolbarView: ToolbarView;
235
+ /**
236
+ * Options of a focusable toolbar view:
237
+ *
238
+ * * `isContextual`: Marks the higher priority toolbar. For example when there are 2 visible toolbars,
239
+ * it allows to distinguish which toolbar should be focused first after the `alt+f10` keystroke
240
+ * * `beforeFocus`: A callback executed before the `ToolbarView` gains focus upon the `Alt+F10` keystroke.
241
+ * * `afterBlur`: A callback executed after `ToolbarView` loses focus upon `Esc` keystroke but before
242
+ * the focus goes back to the `origin`.
243
+ */
244
+ options: FocusableToolbarOptions;
245
+ }
246
+ export interface FocusableToolbarOptions {
247
+ /**
248
+ * Set `true` if the toolbar is attached to the content of the editor. Such toolbar takes
249
+ * a precedence over other toolbars when a user pressed <kbd>Alt</kbd> + <kbd>F10</kbd>.
250
+ */
251
+ isContextual?: boolean;
252
+ /**
253
+ * Specify a callback executed before the toolbar instance DOM element gains focus
254
+ * upon the <kbd>Alt</kbd> + <kbd>F10</kbd> keystroke.
255
+ */
256
+ beforeFocus?: () => void;
257
+ /**
258
+ * Specify a callback executed after the toolbar instance DOM element loses focus upon
259
+ * <kbd>Esc</kbd> keystroke but before the focus goes back to the {@link ~EditorUI#setEditableElement editable element}.
260
+ */
261
+ afterBlur?: () => void;
262
+ }
263
+ export {};