@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.
Files changed (114) hide show
  1. package/package.json +23 -22
  2. package/src/bindings/addkeyboardhandlingforgrid.d.ts +27 -0
  3. package/src/bindings/addkeyboardhandlingforgrid.js +42 -34
  4. package/src/bindings/clickoutsidehandler.d.ts +28 -0
  5. package/src/bindings/clickoutsidehandler.js +5 -6
  6. package/src/bindings/csstransitiondisablermixin.d.ts +40 -0
  7. package/src/bindings/csstransitiondisablermixin.js +55 -0
  8. package/src/bindings/injectcsstransitiondisabler.d.ts +59 -0
  9. package/src/bindings/injectcsstransitiondisabler.js +23 -20
  10. package/src/bindings/preventdefault.d.ts +33 -0
  11. package/src/bindings/preventdefault.js +13 -15
  12. package/src/bindings/submithandler.d.ts +57 -0
  13. package/src/bindings/submithandler.js +22 -23
  14. package/src/button/button.d.ts +154 -0
  15. package/src/button/buttonview.d.ts +155 -0
  16. package/src/button/buttonview.js +16 -60
  17. package/src/button/switchbuttonview.d.ts +45 -0
  18. package/src/button/switchbuttonview.js +9 -18
  19. package/src/colorgrid/colorgridview.d.ts +132 -0
  20. package/src/colorgrid/colorgridview.js +8 -40
  21. package/src/colorgrid/colortileview.d.ts +28 -0
  22. package/src/colorgrid/colortileview.js +0 -13
  23. package/src/colorgrid/utils.d.ts +47 -0
  24. package/src/colorgrid/utils.js +7 -13
  25. package/src/componentfactory.d.ts +81 -0
  26. package/src/componentfactory.js +21 -35
  27. package/src/dropdown/button/dropdownbutton.d.ts +25 -0
  28. package/src/dropdown/button/dropdownbuttonview.d.ts +48 -0
  29. package/src/dropdown/button/dropdownbuttonview.js +11 -21
  30. package/src/dropdown/button/splitbuttonview.d.ts +145 -0
  31. package/src/dropdown/button/splitbuttonview.js +10 -51
  32. package/src/dropdown/dropdownpanelfocusable.d.ts +21 -0
  33. package/src/dropdown/dropdownpanelview.d.ts +62 -0
  34. package/src/dropdown/dropdownpanelview.js +2 -30
  35. package/src/dropdown/dropdownview.d.ts +315 -0
  36. package/src/dropdown/dropdownview.js +121 -222
  37. package/src/dropdown/utils.d.ts +219 -0
  38. package/src/dropdown/utils.js +112 -106
  39. package/src/editableui/editableuiview.d.ts +71 -0
  40. package/src/editableui/editableuiview.js +14 -43
  41. package/src/editableui/inline/inlineeditableuiview.d.ts +40 -0
  42. package/src/editableui/inline/inlineeditableuiview.js +5 -15
  43. package/src/editorui/bodycollection.d.ts +51 -0
  44. package/src/editorui/bodycollection.js +2 -16
  45. package/src/editorui/boxed/boxededitoruiview.d.ts +40 -0
  46. package/src/editorui/boxed/boxededitoruiview.js +1 -27
  47. package/src/editorui/editorui.d.ts +264 -0
  48. package/src/editorui/editorui.js +21 -128
  49. package/src/editorui/editoruiview.d.ts +39 -0
  50. package/src/editorui/editoruiview.js +1 -10
  51. package/src/focuscycler.d.ts +183 -0
  52. package/src/focuscycler.js +34 -90
  53. package/src/formheader/formheaderview.d.ts +53 -0
  54. package/src/formheader/formheaderview.js +3 -24
  55. package/src/icon/iconview.d.ts +78 -0
  56. package/src/icon/iconview.js +0 -50
  57. package/src/iframe/iframeview.d.ts +50 -0
  58. package/src/iframe/iframeview.js +2 -2
  59. package/src/index.d.ts +54 -0
  60. package/src/index.js +1 -0
  61. package/src/input/inputview.d.ts +121 -0
  62. package/src/input/inputview.js +0 -82
  63. package/src/inputnumber/inputnumberview.d.ts +49 -0
  64. package/src/inputnumber/inputnumberview.js +5 -28
  65. package/src/inputtext/inputtextview.d.ts +18 -0
  66. package/src/inputtext/inputtextview.js +0 -2
  67. package/src/label/labelview.d.ts +36 -0
  68. package/src/label/labelview.js +0 -20
  69. package/src/labeledfield/labeledfieldview.d.ts +182 -0
  70. package/src/labeledfield/labeledfieldview.js +20 -126
  71. package/src/labeledfield/utils.d.ts +93 -0
  72. package/src/labeledfield/utils.js +24 -18
  73. package/src/labeledinput/labeledinputview.d.ts +125 -0
  74. package/src/labeledinput/labeledinputview.js +7 -90
  75. package/src/list/listitemview.d.ts +35 -0
  76. package/src/list/listitemview.js +0 -16
  77. package/src/list/listseparatorview.d.ts +18 -0
  78. package/src/list/listseparatorview.js +0 -2
  79. package/src/list/listview.d.ts +59 -0
  80. package/src/list/listview.js +0 -33
  81. package/src/model.d.ts +22 -0
  82. package/src/model.js +2 -4
  83. package/src/notification/notification.d.ts +216 -0
  84. package/src/notification/notification.js +64 -51
  85. package/src/panel/balloon/balloonpanelview.d.ts +685 -0
  86. package/src/panel/balloon/balloonpanelview.js +146 -168
  87. package/src/panel/balloon/contextualballoon.d.ts +240 -0
  88. package/src/panel/balloon/contextualballoon.js +41 -171
  89. package/src/panel/sticky/stickypanelview.d.ts +132 -0
  90. package/src/panel/sticky/stickypanelview.js +0 -115
  91. package/src/template.d.ts +940 -0
  92. package/src/template.js +396 -460
  93. package/src/toolbar/balloon/balloontoolbar.d.ts +124 -0
  94. package/src/toolbar/balloon/balloontoolbar.js +15 -81
  95. package/src/toolbar/block/blockbuttonview.d.ts +35 -0
  96. package/src/toolbar/block/blockbuttonview.js +1 -13
  97. package/src/toolbar/block/blocktoolbar.d.ts +159 -0
  98. package/src/toolbar/block/blocktoolbar.js +32 -69
  99. package/src/toolbar/normalizetoolbarconfig.d.ts +39 -0
  100. package/src/toolbar/normalizetoolbarconfig.js +12 -8
  101. package/src/toolbar/toolbarlinebreakview.d.ts +18 -0
  102. package/src/toolbar/toolbarlinebreakview.js +0 -2
  103. package/src/toolbar/toolbarseparatorview.d.ts +18 -0
  104. package/src/toolbar/toolbarseparatorview.js +0 -2
  105. package/src/toolbar/toolbarview.d.ts +241 -0
  106. package/src/toolbar/toolbarview.js +54 -305
  107. package/src/tooltipmanager.d.ts +180 -0
  108. package/src/tooltipmanager.js +47 -94
  109. package/src/uiconfig.d.ts +82 -0
  110. package/src/uiconfig.js +5 -0
  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,264 @@
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 core/editor/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
+ import '../uiconfig';
15
+ declare const EditorUI_base: {
16
+ new (): import("@ckeditor/ckeditor5-utils").Observable;
17
+ prototype: import("@ckeditor/ckeditor5-utils").Observable;
18
+ };
19
+ /**
20
+ * A class providing the minimal interface that is required to successfully bootstrap any editor UI.
21
+ */
22
+ export default abstract class EditorUI extends EditorUI_base {
23
+ /**
24
+ * The editor that the UI belongs to.
25
+ */
26
+ readonly editor: Editor;
27
+ /**
28
+ * An instance of the {@link module:ui/componentfactory~ComponentFactory}, a registry used by plugins
29
+ * to register factories of specific UI components.
30
+ */
31
+ readonly componentFactory: ComponentFactory;
32
+ /**
33
+ * Stores the information about the editor UI focus and propagates it so various plugins and components
34
+ * are unified as a focus group.
35
+ */
36
+ readonly focusTracker: FocusTracker;
37
+ /**
38
+ * Manages the tooltips displayed on mouseover and focus across the UI.
39
+ */
40
+ readonly tooltipManager: TooltipManager;
41
+ /**
42
+ * Indicates the UI is ready. Set `true` after {@link #event:ready} event is fired.
43
+ *
44
+ * @readonly
45
+ * @default false
46
+ */
47
+ isReady: boolean;
48
+ abstract get view(): EditorUIView;
49
+ /**
50
+ * Stores viewport offsets from every direction.
51
+ *
52
+ * Viewport offset can be used to constrain balloons or other UI elements into an element smaller than the viewport.
53
+ * This can be useful if there are any other absolutely positioned elements that may interfere with editor UI.
54
+ *
55
+ * Example `editor.ui.viewportOffset` returns:
56
+ *
57
+ * ```js
58
+ * {
59
+ * top: 50,
60
+ * right: 50,
61
+ * bottom: 50,
62
+ * left: 50
63
+ * }
64
+ * ```
65
+ *
66
+ * This property can be overriden after editor already being initialized:
67
+ *
68
+ * ```js
69
+ * editor.ui.viewportOffset = {
70
+ * top: 100,
71
+ * right: 0,
72
+ * bottom: 0,
73
+ * left: 0
74
+ * };
75
+ * ```
76
+ *
77
+ * @observable
78
+ */
79
+ viewportOffset: {
80
+ left?: number;
81
+ right?: number;
82
+ top?: number;
83
+ bottom?: number;
84
+ };
85
+ /**
86
+ * Stores all editable elements used by the editor instance.
87
+ */
88
+ private _editableElementsMap;
89
+ /**
90
+ * All available & focusable toolbars.
91
+ */
92
+ private _focusableToolbarDefinitions;
93
+ /**
94
+ * Creates an instance of the editor UI class.
95
+ *
96
+ * @param editor The editor instance.
97
+ */
98
+ constructor(editor: Editor);
99
+ /**
100
+ * The main (outermost) DOM element of the editor UI.
101
+ *
102
+ * For example, in {@link module:editor-classic/classiceditor~ClassicEditor} it is a `<div>` which
103
+ * wraps the editable element and the toolbar. In {@link module:editor-inline/inlineeditor~InlineEditor}
104
+ * it is the editable element itself (as there is no other wrapper). However, in
105
+ * {@link module:editor-decoupled/decouplededitor~DecoupledEditor} it is set to `null` because this editor does not
106
+ * come with a single "main" HTML element (its editable element and toolbar are separate).
107
+ *
108
+ * This property can be understood as a shorthand for retrieving the element that a specific editor integration
109
+ * considers to be its main DOM element.
110
+ */
111
+ get element(): HTMLElement | null;
112
+ /**
113
+ * Fires the {@link module:core/editor/editorui~EditorUI#event:update `update`} event.
114
+ *
115
+ * This method should be called when the editor UI (e.g. positions of its balloons) needs to be updated due to
116
+ * some environmental change which CKEditor 5 is not aware of (e.g. resize of a container in which it is used).
117
+ */
118
+ update(): void;
119
+ /**
120
+ * Destroys the UI.
121
+ */
122
+ destroy(): void;
123
+ /**
124
+ * Stores the native DOM editable element used by the editor under a unique name.
125
+ *
126
+ * Also, registers the element in the editor to maintain the accessibility of the UI. When the user is editing text in a focusable
127
+ * editable area, they can use the <kbd>Alt</kbd> + <kbd>F10</kbd> keystroke to navigate over editor toolbars. See {@link #addToolbar}.
128
+ *
129
+ * @param rootName The unique name of the editable element.
130
+ * @param domElement The native DOM editable element.
131
+ */
132
+ setEditableElement(rootName: string, domElement: HTMLElement): void;
133
+ /**
134
+ * Returns the editable editor element with the given name or null if editable does not exist.
135
+ *
136
+ * @param rootName The editable name.
137
+ */
138
+ getEditableElement(rootName?: string): HTMLElement | undefined;
139
+ /**
140
+ * Returns array of names of all editor editable elements.
141
+ */
142
+ getEditableElementsNames(): IterableIterator<string>;
143
+ /**
144
+ * Adds a toolbar to the editor UI. Used primarily to maintain the accessibility of the UI.
145
+ *
146
+ * Focusable toolbars can be accessed (focused) by users by pressing the <kbd>Alt</kbd> + <kbd>F10</kbd> keystroke.
147
+ * Successive keystroke presses navigate over available toolbars.
148
+ *
149
+ * @param toolbarView A instance of the toolbar to be registered.
150
+ */
151
+ addToolbar(toolbarView: ToolbarView, options?: FocusableToolbarOptions): void;
152
+ /**
153
+ * Stores all editable elements used by the editor instance.
154
+ *
155
+ * @deprecated
156
+ */
157
+ protected get _editableElements(): unknown;
158
+ /**
159
+ * Returns viewport offsets object:
160
+ *
161
+ * ```js
162
+ * {
163
+ * top: Number,
164
+ * right: Number,
165
+ * bottom: Number,
166
+ * left: Number
167
+ * }
168
+ * ```
169
+ *
170
+ * Only top property is currently supported.
171
+ */
172
+ private _readViewportOffsetFromConfig;
173
+ /**
174
+ * Starts listening for <kbd>Alt</kbd> + <kbd>F10</kbd> and <kbd>Esc</kbd> keystrokes in the context of focusable
175
+ * {@link #setEditableElement editable elements} and {@link #addToolbar toolbars}
176
+ * to allow users navigate across the UI.
177
+ */
178
+ private _initFocusTracking;
179
+ /**
180
+ * Returns definitions of toolbars that could potentially be focused, sorted by their importance for the user.
181
+ *
182
+ * Focusable toolbars candidates are either:
183
+ * * already visible,
184
+ * * have `beforeFocus()` set in their {@link module:core/editor/editorui~FocusableToolbarDefinition definition} that suggests that
185
+ * they might show up when called. Keep in mind that determining whether a toolbar will show up (and become focusable) is impossible
186
+ * at this stage because it depends on its implementation, that in turn depends on the editing context (selection).
187
+ *
188
+ * **Note**: Contextual toolbars take precedence over regular toolbars.
189
+ */
190
+ private _getFocusableCandidateToolbarDefinitions;
191
+ /**
192
+ * Returns a definition of the toolbar that is currently visible and focused (one of its children has focus).
193
+ *
194
+ * `null` is returned when no toolbar is currently focused.
195
+ */
196
+ private _getCurrentFocusedToolbarDefinition;
197
+ /**
198
+ * Focuses a focusable toolbar candidate using its definition.
199
+ *
200
+ * @param candidateToolbarDefinition A definition of the toolbar to focus.
201
+ * @returns `true` when the toolbar candidate was focused. `false` otherwise.
202
+ */
203
+ private _focusFocusableCandidateToolbar;
204
+ }
205
+ /**
206
+ * Fired when the editor UI is ready.
207
+ *
208
+ * Fired before {@link module:engine/controller/datacontroller~DataController#event:ready}.
209
+ *
210
+ * @eventName ready
211
+ */
212
+ export type EditorUIReadyEvent = {
213
+ name: 'ready';
214
+ args: [];
215
+ };
216
+ /**
217
+ * Fired whenever the UI (all related components) should be refreshed.
218
+ *
219
+ * **Note:**: The event is fired after each {@link module:engine/view/document~Document#event:layoutChanged}.
220
+ * It can also be fired manually via the {@link module:core/editor/editorui~EditorUI#update} method.
221
+ *
222
+ * @eventName update
223
+ */
224
+ export type EditorUIUpdateEvent = {
225
+ name: 'update';
226
+ args: [];
227
+ };
228
+ /**
229
+ * A definition of a focusable toolbar. Used by {@link module:core/editor/editorui~EditorUI#addToolbar}.
230
+ */
231
+ export interface FocusableToolbarDefinition {
232
+ /**
233
+ * An instance of a focusable toolbar view.
234
+ */
235
+ toolbarView: ToolbarView;
236
+ /**
237
+ * Options of a focusable toolbar view:
238
+ *
239
+ * * `isContextual`: Marks the higher priority toolbar. For example when there are 2 visible toolbars,
240
+ * it allows to distinguish which toolbar should be focused first after the `alt+f10` keystroke
241
+ * * `beforeFocus`: A callback executed before the `ToolbarView` gains focus upon the `Alt+F10` keystroke.
242
+ * * `afterBlur`: A callback executed after `ToolbarView` loses focus upon `Esc` keystroke but before
243
+ * the focus goes back to the `origin`.
244
+ */
245
+ options: FocusableToolbarOptions;
246
+ }
247
+ export interface FocusableToolbarOptions {
248
+ /**
249
+ * Set `true` if the toolbar is attached to the content of the editor. Such toolbar takes
250
+ * a precedence over other toolbars when a user pressed <kbd>Alt</kbd> + <kbd>F10</kbd>.
251
+ */
252
+ isContextual?: boolean;
253
+ /**
254
+ * Specify a callback executed before the toolbar instance DOM element gains focus
255
+ * upon the <kbd>Alt</kbd> + <kbd>F10</kbd> keystroke.
256
+ */
257
+ beforeFocus?: () => void;
258
+ /**
259
+ * Specify a callback executed after the toolbar instance DOM element loses focus upon
260
+ * <kbd>Esc</kbd> keystroke but before the focus goes back to the {@link #setEditableElement editable element}.
261
+ */
262
+ afterBlur?: () => void;
263
+ }
264
+ export {};
@@ -9,106 +9,41 @@
9
9
  import ComponentFactory from '../componentfactory';
10
10
  import TooltipManager from '../tooltipmanager';
11
11
  import { ObservableMixin, isVisible, FocusTracker } from '@ckeditor/ckeditor5-utils';
12
+ import '../uiconfig';
12
13
  /**
13
14
  * A class providing the minimal interface that is required to successfully bootstrap any editor UI.
14
- *
15
- * @mixes module:utils/emittermixin~EmitterMixin
16
15
  */
17
16
  export default class EditorUI extends ObservableMixin() {
18
17
  /**
19
18
  * Creates an instance of the editor UI class.
20
19
  *
21
- * @param {module:core/editor/editor~Editor} editor The editor instance.
20
+ * @param editor The editor instance.
22
21
  */
23
22
  constructor(editor) {
24
23
  super();
25
- /**
26
- * The editor that the UI belongs to.
27
- *
28
- * @readonly
29
- * @member {module:core/editor/editor~Editor} #editor
30
- */
31
- this.editor = editor;
32
- /**
33
- * An instance of the {@link module:ui/componentfactory~ComponentFactory}, a registry used by plugins
34
- * to register factories of specific UI components.
35
- *
36
- * @readonly
37
- * @member {module:ui/componentfactory~ComponentFactory} #componentFactory
38
- */
39
- this.componentFactory = new ComponentFactory(editor);
40
- /**
41
- * Stores the information about the editor UI focus and propagates it so various plugins and components
42
- * are unified as a focus group.
43
- *
44
- * @readonly
45
- * @member {module:utils/focustracker~FocusTracker} #focusTracker
46
- */
47
- this.focusTracker = new FocusTracker();
48
- /**
49
- * Manages the tooltips displayed on mouseover and focus across the UI.
50
- *
51
- * @readonly
52
- * @member {module:ui/tooltipmanager~TooltipManager}
53
- */
54
- this.tooltipManager = new TooltipManager(editor);
55
- /**
56
- * Stores viewport offsets from every direction.
57
- *
58
- * Viewport offset can be used to constrain balloons or other UI elements into an element smaller than the viewport.
59
- * This can be useful if there are any other absolutely positioned elements that may interfere with editor UI.
60
- *
61
- * Example `editor.ui.viewportOffset` returns:
62
- *
63
- * ```js
64
- * {
65
- * top: 50,
66
- * right: 50,
67
- * bottom: 50,
68
- * left: 50
69
- * }
70
- * ```
71
- *
72
- * This property can be overriden after editor already being initialized:
73
- *
74
- * ```js
75
- * editor.ui.viewportOffset = {
76
- * top: 100,
77
- * right: 0,
78
- * bottom: 0,
79
- * left: 0
80
- * };
81
- * ```
82
- *
83
- * @observable
84
- * @member {Object} #viewportOffset
85
- */
86
- this.set('viewportOffset', this._readViewportOffsetFromConfig());
87
24
  /**
88
25
  * Indicates the UI is ready. Set `true` after {@link #event:ready} event is fired.
89
26
  *
90
27
  * @readonly
91
28
  * @default false
92
- * @member {Boolean} #isReady
93
29
  */
94
30
  this.isReady = false;
95
- this.once('ready', () => {
96
- this.isReady = true;
97
- });
98
31
  /**
99
32
  * Stores all editable elements used by the editor instance.
100
- *
101
- * @private
102
- * @member {Map.<String,HTMLElement>}
103
33
  */
104
34
  this._editableElementsMap = new Map();
105
35
  /**
106
36
  * All available & focusable toolbars.
107
- *
108
- * @private
109
- * @type {Array.<module:core/editor/editorui~FocusableToolbarDefinition>}
110
37
  */
111
38
  this._focusableToolbarDefinitions = [];
39
+ this.editor = editor;
40
+ this.componentFactory = new ComponentFactory(editor);
41
+ this.focusTracker = new FocusTracker();
42
+ this.tooltipManager = new TooltipManager(editor);
43
+ this.set('viewportOffset', this._readViewportOffsetFromConfig());
44
+ this.once('ready', () => {
45
+ this.isReady = true;
46
+ });
112
47
  // Informs UI components that should be refreshed after layout change.
113
48
  this.listenTo(editor.editing.view.document, 'layoutChanged', () => this.update());
114
49
  this._initFocusTracking();
@@ -124,9 +59,6 @@ export default class EditorUI extends ObservableMixin() {
124
59
  *
125
60
  * This property can be understood as a shorthand for retrieving the element that a specific editor integration
126
61
  * considers to be its main DOM element.
127
- *
128
- * @readonly
129
- * @member {HTMLElement|null} #element
130
62
  */
131
63
  get element() {
132
64
  return null;
@@ -160,8 +92,8 @@ export default class EditorUI extends ObservableMixin() {
160
92
  * Also, registers the element in the editor to maintain the accessibility of the UI. When the user is editing text in a focusable
161
93
  * editable area, they can use the <kbd>Alt</kbd> + <kbd>F10</kbd> keystroke to navigate over editor toolbars. See {@link #addToolbar}.
162
94
  *
163
- * @param {String} rootName The unique name of the editable element.
164
- * @param {HTMLElement} domElement The native DOM editable element.
95
+ * @param rootName The unique name of the editable element.
96
+ * @param domElement The native DOM editable element.
165
97
  */
166
98
  setEditableElement(rootName, domElement) {
167
99
  this._editableElementsMap.set(rootName, domElement);
@@ -194,16 +126,13 @@ export default class EditorUI extends ObservableMixin() {
194
126
  /**
195
127
  * Returns the editable editor element with the given name or null if editable does not exist.
196
128
  *
197
- * @param {String} [rootName=main] The editable name.
198
- * @returns {HTMLElement|undefined}
129
+ * @param rootName The editable name.
199
130
  */
200
131
  getEditableElement(rootName = 'main') {
201
132
  return this._editableElementsMap.get(rootName);
202
133
  }
203
134
  /**
204
135
  * Returns array of names of all editor editable elements.
205
- *
206
- * @returns {Iterable.<String>}
207
136
  */
208
137
  getEditableElementsNames() {
209
138
  return this._editableElementsMap.keys();
@@ -214,14 +143,7 @@ export default class EditorUI extends ObservableMixin() {
214
143
  * Focusable toolbars can be accessed (focused) by users by pressing the <kbd>Alt</kbd> + <kbd>F10</kbd> keystroke.
215
144
  * Successive keystroke presses navigate over available toolbars.
216
145
  *
217
- * @param {module:ui/toolbar/toolbarview~ToolbarView} toolbarView A instance of the toolbar to be registered.
218
- * @param {Object} [options]
219
- * @param {Boolean} [options.isContextual] Set `true` if the toolbar is attached to the content of the editor. Such toolbar takes
220
- * a precedence over other toolbars when a user pressed <kbd>Alt</kbd> + <kbd>F10</kbd>.
221
- * @param {Function} [options.beforeFocus] Specify a callback executed before the toolbar instance DOM element gains focus
222
- * upon the <kbd>Alt</kbd> + <kbd>F10</kbd> keystroke.
223
- * @param {Function} [options.afterBlur] Specify a callback executed after the toolbar instance DOM element loses focus upon
224
- * <kbd>Esc</kbd> keystroke but before the focus goes back to the {@link #setEditableElement editable element}.
146
+ * @param toolbarView A instance of the toolbar to be registered.
225
147
  */
226
148
  addToolbar(toolbarView, options = {}) {
227
149
  if (toolbarView.isRendered) {
@@ -239,9 +161,7 @@ export default class EditorUI extends ObservableMixin() {
239
161
  /**
240
162
  * Stores all editable elements used by the editor instance.
241
163
  *
242
- * @protected
243
164
  * @deprecated
244
- * @member {Map.<String,HTMLElement>}
245
165
  */
246
166
  get _editableElements() {
247
167
  /**
@@ -250,7 +170,7 @@ export default class EditorUI extends ObservableMixin() {
250
170
  * {@link #getEditableElement `getEditableElement()`} methods instead.
251
171
  *
252
172
  * @error editor-ui-deprecated-editable-elements
253
- * @param {module:core/editor/editorui~EditorUI} editorUI Editor UI instance the deprecated property belongs to.
173
+ * @param editorUI Editor UI instance the deprecated property belongs to.
254
174
  */
255
175
  console.warn('editor-ui-deprecated-editable-elements: ' +
256
176
  'The EditorUI#_editableElements property has been deprecated and will be removed in the near future.', { editorUI: this });
@@ -269,9 +189,6 @@ export default class EditorUI extends ObservableMixin() {
269
189
  * ```
270
190
  *
271
191
  * Only top property is currently supported.
272
- *
273
- * @private
274
- * @return {Object}
275
192
  */
276
193
  _readViewportOffsetFromConfig() {
277
194
  const editor = this.editor;
@@ -302,8 +219,6 @@ export default class EditorUI extends ObservableMixin() {
302
219
  * Starts listening for <kbd>Alt</kbd> + <kbd>F10</kbd> and <kbd>Esc</kbd> keystrokes in the context of focusable
303
220
  * {@link #setEditableElement editable elements} and {@link #addToolbar toolbars}
304
221
  * to allow users navigate across the UI.
305
- *
306
- * @private
307
222
  */
308
223
  _initFocusTracking() {
309
224
  const editor = this.editor;
@@ -385,9 +300,6 @@ export default class EditorUI extends ObservableMixin() {
385
300
  * at this stage because it depends on its implementation, that in turn depends on the editing context (selection).
386
301
  *
387
302
  * **Note**: Contextual toolbars take precedence over regular toolbars.
388
- *
389
- * @private
390
- * @returns {Array.<module:core/editor/editorui~FocusableToolbarDefinition>}
391
303
  */
392
304
  _getFocusableCandidateToolbarDefinitions() {
393
305
  const definitions = [];
@@ -406,9 +318,6 @@ export default class EditorUI extends ObservableMixin() {
406
318
  * Returns a definition of the toolbar that is currently visible and focused (one of its children has focus).
407
319
  *
408
320
  * `null` is returned when no toolbar is currently focused.
409
- *
410
- * @private
411
- * @returns {module:core/editor/editorui~FocusableToolbarDefinition|null}
412
321
  */
413
322
  _getCurrentFocusedToolbarDefinition() {
414
323
  for (const definition of this._focusableToolbarDefinitions) {
@@ -421,9 +330,8 @@ export default class EditorUI extends ObservableMixin() {
421
330
  /**
422
331
  * Focuses a focusable toolbar candidate using its definition.
423
332
  *
424
- * @private
425
- * @param {module:core/editor/editorui~FocusableToolbarDefinition} candidateToolbarDefinition A definition of the toolbar to focus.
426
- * @returns {Boolean} `true` when the toolbar candidate was focused. `false` otherwise.
333
+ * @param candidateToolbarDefinition A definition of the toolbar to focus.
334
+ * @returns `true` when the toolbar candidate was focused. `false` otherwise.
427
335
  */
428
336
  _focusFocusableCandidateToolbar(candidateToolbarDefinition) {
429
337
  const { toolbarView, options: { beforeFocus } } = candidateToolbarDefinition;
@@ -439,28 +347,13 @@ export default class EditorUI extends ObservableMixin() {
439
347
  }
440
348
  }
441
349
  /**
442
- * An instance of a focusable toolbar view.
443
- *
444
- * @member {module:ui/toolbar/toolbarview~ToolbarView} #toolbarView
445
- */
446
- /**
447
- * Options of a focusable toolbar view:
350
+ * Returns a number (weight) for a toolbar definition. Visible toolbars have a higher priority and so do
351
+ * contextual toolbars (displayed in the context of a content, for instance, an image toolbar).
448
352
  *
449
- * * `isContextual`: Marks the higher priority toolbar. For example when there are 2 visible toolbars,
450
- * it allows to distinguish which toolbar should be focused first after the `alt+f10` keystroke
451
- * * `beforeFocus`: A callback executed before the `ToolbarView` gains focus upon the `Alt+F10` keystroke.
452
- * * `afterBlur`: A callback executed after `ToolbarView` loses focus upon `Esc` keystroke but before the focus goes back to the `origin`.
353
+ * A standard invisible toolbar is the heaviest. A visible contextual toolbar is the lightest.
453
354
  *
454
- * @member {Object} #options
355
+ * @param toolbarDef A toolbar definition to be weighted.
455
356
  */
456
- // Returns a number (weight) for a toolbar definition. Visible toolbars have a higher priority and so do
457
- // contextual toolbars (displayed in the context of a content, for instance, an image toolbar).
458
- //
459
- // A standard invisible toolbar is the heaviest. A visible contextual toolbar is the lightest.
460
- //
461
- // @private
462
- // @param {module:core/editor/editorui~FocusableToolbarDefinition} toolbarDef A toolbar definition to be weighted.
463
- // @returns {Number}
464
357
  function getToolbarDefinitionWeight(toolbarDef) {
465
358
  const { toolbarView, options } = toolbarDef;
466
359
  let weight = 10;