@ckeditor/ckeditor5-core 35.4.0 → 36.0.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/LICENSE.md CHANGED
@@ -2,7 +2,7 @@ Software License Agreement
2
2
  ==========================
3
3
 
4
4
  **CKEditor 5 core editor architecture** – https://github.com/ckeditor/ckeditor5-core <br>
5
- Copyright (c) 2003-2022, [CKSource Holding sp. z o.o.](https://cksource.com) All rights reserved.
5
+ Copyright (c) 2003-2023, [CKSource Holding sp. z o.o.](https://cksource.com) All rights reserved.
6
6
 
7
7
  Licensed under the terms of [GNU General Public License Version 2 or later](http://www.gnu.org/licenses/gpl.html).
8
8
 
@@ -18,27 +18,27 @@ msgstr ""
18
18
 
19
19
  msgctxt "Label for the Cancel button."
20
20
  msgid "Cancel"
21
- msgstr "ئىناۋەتسىز"
21
+ msgstr "ۋاز كەچ"
22
22
 
23
23
  msgctxt "The label used by a button next to the color palette in the color picker that removes the color (resets it to an empty value, example usages in font color or table properties)."
24
24
  msgid "Remove color"
25
- msgstr "رەڭنى چىقىرىۋېتىش"
25
+ msgstr "رەڭنى چىقىرىۋەت"
26
26
 
27
27
  msgctxt "The label used by a button next to the color palette in the color picker that restores the default value if the default table properties are specified."
28
28
  msgid "Restore default"
29
- msgstr ""
29
+ msgstr "كۆڭۈلدىكىگە قايتۇر"
30
30
 
31
31
  msgctxt "Label for the Save button."
32
32
  msgid "Save"
33
- msgstr "ساقلاش"
33
+ msgstr "ساقلا"
34
34
 
35
35
  msgctxt "Label of a toolbar button which reveals more toolbar items."
36
36
  msgid "Show more items"
37
- msgstr ""
37
+ msgstr "تېخىمۇ كۆپ تۈرنى كۆرسەت"
38
38
 
39
39
  msgctxt "Label for an ‘X of Y’ status of a typical next/previous navigation. For instance, ‘Page 5 of 20’ or 'Search result 5 of 20'."
40
40
  msgid "%0 of %1"
41
- msgstr ""
41
+ msgstr "%0 / %1"
42
42
 
43
43
  msgctxt "A generic error message displayed on upload failure. The file name is concatenated to this text."
44
44
  msgid "Cannot upload file:"
@@ -46,4 +46,4 @@ msgstr "يۈكلەشكە بولمايدىغان ھۆججەت:"
46
46
 
47
47
  msgctxt "Accessible label of the specific editing area of the editor acting as a root of the entire application."
48
48
  msgid "Rich Text Editor. Editing area: %0"
49
- msgstr ""
49
+ msgstr "مول تېكىست تەھرىرلىگۈچ. تەھرىرلەش رايونى: %0"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-core",
3
- "version": "35.4.0",
3
+ "version": "36.0.1",
4
4
  "description": "The core architecture of CKEditor 5 – the best browser-based rich text editor.",
5
5
  "keywords": [
6
6
  "wysiwyg",
@@ -23,25 +23,25 @@
23
23
  ],
24
24
  "main": "src/index.js",
25
25
  "dependencies": {
26
- "@ckeditor/ckeditor5-engine": "^35.4.0",
27
- "@ckeditor/ckeditor5-ui": "^35.4.0",
28
- "@ckeditor/ckeditor5-utils": "^35.4.0",
26
+ "@ckeditor/ckeditor5-engine": "^36.0.1",
27
+ "@ckeditor/ckeditor5-utils": "^36.0.1",
29
28
  "lodash-es": "^4.17.15"
30
29
  },
31
30
  "devDependencies": {
32
- "@ckeditor/ckeditor5-autoformat": "^35.4.0",
33
- "@ckeditor/ckeditor5-basic-styles": "^35.4.0",
34
- "@ckeditor/ckeditor5-block-quote": "^35.4.0",
35
- "@ckeditor/ckeditor5-editor-classic": "^35.4.0",
36
- "@ckeditor/ckeditor5-essentials": "^35.4.0",
37
- "@ckeditor/ckeditor5-heading": "^35.4.0",
38
- "@ckeditor/ckeditor5-image": "^35.4.0",
39
- "@ckeditor/ckeditor5-indent": "^35.4.0",
40
- "@ckeditor/ckeditor5-link": "^35.4.0",
41
- "@ckeditor/ckeditor5-list": "^35.4.0",
42
- "@ckeditor/ckeditor5-media-embed": "^35.4.0",
43
- "@ckeditor/ckeditor5-paragraph": "^35.4.0",
44
- "@ckeditor/ckeditor5-table": "^35.4.0",
31
+ "@ckeditor/ckeditor5-autoformat": "^36.0.1",
32
+ "@ckeditor/ckeditor5-basic-styles": "^36.0.1",
33
+ "@ckeditor/ckeditor5-block-quote": "^36.0.1",
34
+ "@ckeditor/ckeditor5-editor-classic": "^36.0.1",
35
+ "@ckeditor/ckeditor5-essentials": "^36.0.1",
36
+ "@ckeditor/ckeditor5-heading": "^36.0.1",
37
+ "@ckeditor/ckeditor5-image": "^36.0.1",
38
+ "@ckeditor/ckeditor5-indent": "^36.0.1",
39
+ "@ckeditor/ckeditor5-link": "^36.0.1",
40
+ "@ckeditor/ckeditor5-list": "^36.0.1",
41
+ "@ckeditor/ckeditor5-media-embed": "^36.0.1",
42
+ "@ckeditor/ckeditor5-paragraph": "^36.0.1",
43
+ "@ckeditor/ckeditor5-table": "^36.0.1",
44
+ "@ckeditor/ckeditor5-ui": "^36.0.1",
45
45
  "typescript": "^4.8.4",
46
46
  "webpack": "^5.58.1",
47
47
  "webpack-cli": "^4.9.0"
package/src/command.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, 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
5
  /**
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, 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
5
  /**
package/src/context.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, 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
5
  /**
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, 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
5
  /**
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, 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
5
  /**
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, 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
5
  /**
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, 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
5
  export {};
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, 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
5
  import { isFunction } from 'lodash-es';
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, 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
5
  /**
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, 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
5
  /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, 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
5
  import { CKEditorError } from '@ckeditor/ckeditor5-utils';
package/src/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, 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
5
  /**
@@ -11,7 +11,6 @@ export { default as MultiCommand } from './multicommand';
11
11
  export { default as Context } from './context';
12
12
  export { default as ContextPlugin } from './contextplugin';
13
13
  export { default as Editor } from './editor/editor';
14
- export { default as EditorUI } from './editor/editorui';
15
14
  export { default as attachToForm } from './editor/utils/attachtoform';
16
15
  export { default as DataApiMixin } from './editor/utils/dataapimixin';
17
16
  export { default as ElementApiMixin } from './editor/utils/elementapimixin';
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, 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
5
  import Command from './command';
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, 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
5
  /**
@@ -43,7 +43,7 @@ import { CKEditorError, Collection, ObservableMixin } from '@ckeditor/ckeditor5-
43
43
  *
44
44
  * This plugin is used by features like {@link module:upload/filerepository~FileRepository} to register their ongoing actions
45
45
  * and by features like {@link module:autosave/autosave~Autosave} to detect whether there are any ongoing actions.
46
- * Read more about saving the data in the {@glink installation/advanced/saving-data Saving and getting data} guide.
46
+ * Read more about saving the data in the {@glink installation/getting-started/getting-and-setting-data Saving and getting data} guide.
47
47
  *
48
48
  * @extends module:core/contextplugin~ContextPlugin
49
49
  */
package/src/plugin.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, 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
5
  /* eslint-disable @typescript-eslint/no-invalid-void-type */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, 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
5
  /**
@@ -1,474 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2022, 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
- // TODO: can't import it from `@ckeditor/ckeditor5-ui` because of indirect circular dependency
6
- // between `@ckeditor/ckeditor5-{ui,core}/src/index.ts`.
7
- import ComponentFactory from '@ckeditor/ckeditor5-ui/src/componentfactory';
8
- import TooltipManager from '@ckeditor/ckeditor5-ui/src/tooltipmanager';
9
- import { ObservableMixin, isVisible, FocusTracker } from '@ckeditor/ckeditor5-utils';
10
- /**
11
- * A class providing the minimal interface that is required to successfully bootstrap any editor UI.
12
- *
13
- * @mixes module:utils/emittermixin~EmitterMixin
14
- */
15
- export default class EditorUI extends ObservableMixin() {
16
- /**
17
- * Creates an instance of the editor UI class.
18
- *
19
- * @param {module:core/editor/editor~Editor} editor The editor instance.
20
- */
21
- constructor(editor) {
22
- super();
23
- /**
24
- * The editor that the UI belongs to.
25
- *
26
- * @readonly
27
- * @member {module:core/editor/editor~Editor} #editor
28
- */
29
- this.editor = editor;
30
- /**
31
- * An instance of the {@link module:ui/componentfactory~ComponentFactory}, a registry used by plugins
32
- * to register factories of specific UI components.
33
- *
34
- * @readonly
35
- * @member {module:ui/componentfactory~ComponentFactory} #componentFactory
36
- */
37
- this.componentFactory = new ComponentFactory(editor);
38
- /**
39
- * Stores the information about the editor UI focus and propagates it so various plugins and components
40
- * are unified as a focus group.
41
- *
42
- * @readonly
43
- * @member {module:utils/focustracker~FocusTracker} #focusTracker
44
- */
45
- this.focusTracker = new FocusTracker();
46
- /**
47
- * Manages the tooltips displayed on mouseover and focus across the UI.
48
- *
49
- * @readonly
50
- * @member {module:ui/tooltipmanager~TooltipManager}
51
- */
52
- this.tooltipManager = new TooltipManager(editor);
53
- /**
54
- * Stores viewport offsets from every direction.
55
- *
56
- * Viewport offset can be used to constrain balloons or other UI elements into an element smaller than the viewport.
57
- * This can be useful if there are any other absolutely positioned elements that may interfere with editor UI.
58
- *
59
- * Example `editor.ui.viewportOffset` returns:
60
- *
61
- * ```js
62
- * {
63
- * top: 50,
64
- * right: 50,
65
- * bottom: 50,
66
- * left: 50
67
- * }
68
- * ```
69
- *
70
- * This property can be overriden after editor already being initialized:
71
- *
72
- * ```js
73
- * editor.ui.viewportOffset = {
74
- * top: 100,
75
- * right: 0,
76
- * bottom: 0,
77
- * left: 0
78
- * };
79
- * ```
80
- *
81
- * @observable
82
- * @member {Object} #viewportOffset
83
- */
84
- this.set('viewportOffset', this._readViewportOffsetFromConfig());
85
- /**
86
- * Indicates the UI is ready. Set `true` after {@link #event:ready} event is fired.
87
- *
88
- * @readonly
89
- * @default false
90
- * @member {Boolean} #isReady
91
- */
92
- this.isReady = false;
93
- this.once('ready', () => {
94
- this.isReady = true;
95
- });
96
- /**
97
- * Stores all editable elements used by the editor instance.
98
- *
99
- * @private
100
- * @member {Map.<String,HTMLElement>}
101
- */
102
- this._editableElementsMap = new Map();
103
- /**
104
- * All available & focusable toolbars.
105
- *
106
- * @private
107
- * @type {Array.<module:core/editor/editorui~FocusableToolbarDefinition>}
108
- */
109
- this._focusableToolbarDefinitions = [];
110
- // Informs UI components that should be refreshed after layout change.
111
- this.listenTo(editor.editing.view.document, 'layoutChanged', () => this.update());
112
- this._initFocusTracking();
113
- }
114
- /**
115
- * The main (outermost) DOM element of the editor UI.
116
- *
117
- * For example, in {@link module:editor-classic/classiceditor~ClassicEditor} it is a `<div>` which
118
- * wraps the editable element and the toolbar. In {@link module:editor-inline/inlineeditor~InlineEditor}
119
- * it is the editable element itself (as there is no other wrapper). However, in
120
- * {@link module:editor-decoupled/decouplededitor~DecoupledEditor} it is set to `null` because this editor does not
121
- * come with a single "main" HTML element (its editable element and toolbar are separate).
122
- *
123
- * This property can be understood as a shorthand for retrieving the element that a specific editor integration
124
- * considers to be its main DOM element.
125
- *
126
- * @readonly
127
- * @member {HTMLElement|null} #element
128
- */
129
- get element() {
130
- return null;
131
- }
132
- /**
133
- * Fires the {@link module:core/editor/editorui~EditorUI#event:update `update`} event.
134
- *
135
- * This method should be called when the editor UI (e.g. positions of its balloons) needs to be updated due to
136
- * some environmental change which CKEditor 5 is not aware of (e.g. resize of a container in which it is used).
137
- */
138
- update() {
139
- this.fire('update');
140
- }
141
- /**
142
- * Destroys the UI.
143
- */
144
- destroy() {
145
- this.stopListening();
146
- this.focusTracker.destroy();
147
- this.tooltipManager.destroy(this.editor);
148
- // Clean–up the references to the CKEditor instance stored in the native editable DOM elements.
149
- for (const domElement of this._editableElementsMap.values()) {
150
- domElement.ckeditorInstance = null;
151
- }
152
- this._editableElementsMap = new Map();
153
- this._focusableToolbarDefinitions = [];
154
- }
155
- /**
156
- * Stores the native DOM editable element used by the editor under a unique name.
157
- *
158
- * Also, registers the element in the editor to maintain the accessibility of the UI. When the user is editing text in a focusable
159
- * editable area, they can use the <kbd>Alt</kbd> + <kbd>F10</kbd> keystroke to navigate over editor toolbars. See {@link #addToolbar}.
160
- *
161
- * @param {String} rootName The unique name of the editable element.
162
- * @param {HTMLElement} domElement The native DOM editable element.
163
- */
164
- setEditableElement(rootName, domElement) {
165
- this._editableElementsMap.set(rootName, domElement);
166
- // Put a reference to the CKEditor instance in the editable native DOM element.
167
- // It helps 3rd–party software (browser extensions, other libraries) access and recognize
168
- // CKEditor 5 instances (editing roots) and use their API (there is no global editor
169
- // instance registry).
170
- if (!domElement.ckeditorInstance) {
171
- domElement.ckeditorInstance = this.editor;
172
- }
173
- // Register the element so it becomes available for Alt+F10 and Esc navigation.
174
- this.focusTracker.add(domElement);
175
- const setUpKeystrokeHandler = () => {
176
- // The editing view of the editor is already listening to keystrokes from DOM roots (see: KeyObserver).
177
- // Do not duplicate listeners.
178
- if (this.editor.editing.view.getDomRoot(rootName)) {
179
- return;
180
- }
181
- this.editor.keystrokes.listenTo(domElement);
182
- };
183
- // For editable elements set by features after EditorUI is ready (e.g. source editing).
184
- if (this.isReady) {
185
- setUpKeystrokeHandler();
186
- }
187
- // For editable elements set while the editor is being created (e.g. DOM roots).
188
- else {
189
- this.once('ready', setUpKeystrokeHandler);
190
- }
191
- }
192
- /**
193
- * Returns the editable editor element with the given name or null if editable does not exist.
194
- *
195
- * @param {String} [rootName=main] The editable name.
196
- * @returns {HTMLElement|undefined}
197
- */
198
- getEditableElement(rootName = 'main') {
199
- return this._editableElementsMap.get(rootName);
200
- }
201
- /**
202
- * Returns array of names of all editor editable elements.
203
- *
204
- * @returns {Iterable.<String>}
205
- */
206
- getEditableElementsNames() {
207
- return this._editableElementsMap.keys();
208
- }
209
- /**
210
- * Adds a toolbar to the editor UI. Used primarily to maintain the accessibility of the UI.
211
- *
212
- * Focusable toolbars can be accessed (focused) by users by pressing the <kbd>Alt</kbd> + <kbd>F10</kbd> keystroke.
213
- * Successive keystroke presses navigate over available toolbars.
214
- *
215
- * @param {module:ui/toolbar/toolbarview~ToolbarView} toolbarView A instance of the toolbar to be registered.
216
- * @param {Object} [options]
217
- * @param {Boolean} [options.isContextual] Set `true` if the toolbar is attached to the content of the editor. Such toolbar takes
218
- * a precedence over other toolbars when a user pressed <kbd>Alt</kbd> + <kbd>F10</kbd>.
219
- * @param {Function} [options.beforeFocus] Specify a callback executed before the toolbar instance DOM element gains focus
220
- * upon the <kbd>Alt</kbd> + <kbd>F10</kbd> keystroke.
221
- * @param {Function} [options.afterBlur] Specify a callback executed after the toolbar instance DOM element loses focus upon
222
- * <kbd>Esc</kbd> keystroke but before the focus goes back to the {@link #setEditableElement editable element}.
223
- */
224
- addToolbar(toolbarView, options = {}) {
225
- if (toolbarView.isRendered) {
226
- this.focusTracker.add(toolbarView.element);
227
- this.editor.keystrokes.listenTo(toolbarView.element);
228
- }
229
- else {
230
- toolbarView.once('render', () => {
231
- this.focusTracker.add(toolbarView.element);
232
- this.editor.keystrokes.listenTo(toolbarView.element);
233
- });
234
- }
235
- this._focusableToolbarDefinitions.push({ toolbarView, options });
236
- }
237
- /**
238
- * Stores all editable elements used by the editor instance.
239
- *
240
- * @protected
241
- * @deprecated
242
- * @member {Map.<String,HTMLElement>}
243
- */
244
- get _editableElements() {
245
- /**
246
- * The {@link module:core/editor/editorui~EditorUI#_editableElements `EditorUI#_editableElements`} property has been
247
- * deprecated and will be removed in the near future. Please use {@link #setEditableElement `setEditableElement()`} and
248
- * {@link #getEditableElement `getEditableElement()`} methods instead.
249
- *
250
- * @error editor-ui-deprecated-editable-elements
251
- * @param {module:core/editor/editorui~EditorUI} editorUI Editor UI instance the deprecated property belongs to.
252
- */
253
- console.warn('editor-ui-deprecated-editable-elements: ' +
254
- 'The EditorUI#_editableElements property has been deprecated and will be removed in the near future.', { editorUI: this });
255
- return this._editableElementsMap;
256
- }
257
- /**
258
- * Returns viewport offsets object:
259
- *
260
- * ```js
261
- * {
262
- * top: Number,
263
- * right: Number,
264
- * bottom: Number,
265
- * left: Number
266
- * }
267
- * ```
268
- *
269
- * Only top property is currently supported.
270
- *
271
- * @private
272
- * @return {Object}
273
- */
274
- _readViewportOffsetFromConfig() {
275
- const editor = this.editor;
276
- const viewportOffsetConfig = editor.config.get('ui.viewportOffset');
277
- if (viewportOffsetConfig) {
278
- return viewportOffsetConfig;
279
- }
280
- // Not present in EditorConfig type, because it's legacy. Hence the `as` expression.
281
- const legacyOffsetConfig = editor.config.get('toolbar.viewportTopOffset');
282
- // Fall back to deprecated toolbar config.
283
- if (legacyOffsetConfig) {
284
- /**
285
- * The {@link module:core/editor/editorconfig~EditorConfig#toolbar `EditorConfig#toolbar.viewportTopOffset`}
286
- * property has been deprecated and will be removed in the near future. Please use
287
- * {@link module:core/editor/editorconfig~EditorConfig#ui `EditorConfig#ui.viewportOffset`} instead.
288
- *
289
- * @error editor-ui-deprecated-viewport-offset-config
290
- */
291
- console.warn('editor-ui-deprecated-viewport-offset-config: ' +
292
- 'The `toolbar.vieportTopOffset` configuration option is deprecated. ' +
293
- 'It will be removed from future CKEditor versions. Use `ui.viewportOffset.top` instead.');
294
- return { top: legacyOffsetConfig };
295
- }
296
- // More keys to come in the future.
297
- return { top: 0 };
298
- }
299
- /**
300
- * Starts listening for <kbd>Alt</kbd> + <kbd>F10</kbd> and <kbd>Esc</kbd> keystrokes in the context of focusable
301
- * {@link #setEditableElement editable elements} and {@link #addToolbar toolbars}
302
- * to allow users navigate across the UI.
303
- *
304
- * @private
305
- */
306
- _initFocusTracking() {
307
- const editor = this.editor;
308
- const editingView = editor.editing.view;
309
- let lastFocusedForeignElement;
310
- let candidateDefinitions;
311
- // Focus the next focusable toolbar on <kbd>Alt</kbd> + <kbd>F10</kbd>.
312
- editor.keystrokes.set('Alt+F10', (data, cancel) => {
313
- const focusedElement = this.focusTracker.focusedElement;
314
- // Focus moved out of a DOM element that
315
- // * is not a toolbar,
316
- // * does not belong to the editing view (e.g. source editing).
317
- if (Array.from(this._editableElementsMap.values()).includes(focusedElement) &&
318
- !Array.from(editingView.domRoots.values()).includes(focusedElement)) {
319
- lastFocusedForeignElement = focusedElement;
320
- }
321
- const currentFocusedToolbarDefinition = this._getCurrentFocusedToolbarDefinition();
322
- // * When focusing a toolbar for the first time, set the array of definitions for successive presses of Alt+F10.
323
- // This ensures, the navigation works always the same and no pair of toolbars takes over
324
- // (e.g. image and table toolbars when a selected image is inside a cell).
325
- // * It could be that the focus went to the toolbar by clicking a toolbar item (e.g. a dropdown). In this case,
326
- // there were no candidates so they must be obtained (#12339).
327
- if (!currentFocusedToolbarDefinition || !candidateDefinitions) {
328
- candidateDefinitions = this._getFocusableCandidateToolbarDefinitions();
329
- }
330
- // In a single Alt+F10 press, check all candidates but if none were focused, don't go any further.
331
- // This prevents an infinite loop.
332
- for (let i = 0; i < candidateDefinitions.length; i++) {
333
- const candidateDefinition = candidateDefinitions.shift();
334
- // Put the first definition to the back of the array. This allows circular navigation over all toolbars
335
- // on successive presses of Alt+F10.
336
- candidateDefinitions.push(candidateDefinition);
337
- // Don't focus the same toolbar again. If you did, this would move focus from the nth focused toolbar item back to the
338
- // first item as per ToolbarView#focus() if the user navigated inside the toolbar.
339
- if (candidateDefinition !== currentFocusedToolbarDefinition &&
340
- this._focusFocusableCandidateToolbar(candidateDefinition)) {
341
- // Clean up after a current visible toolbar when switching to the next one.
342
- if (currentFocusedToolbarDefinition && currentFocusedToolbarDefinition.options.afterBlur) {
343
- currentFocusedToolbarDefinition.options.afterBlur();
344
- }
345
- break;
346
- }
347
- }
348
- cancel();
349
- });
350
- // Blur the focused toolbar on <kbd>Esc</kbd> and bring the focus back to its origin.
351
- editor.keystrokes.set('Esc', (data, cancel) => {
352
- const focusedToolbarDef = this._getCurrentFocusedToolbarDefinition();
353
- if (!focusedToolbarDef) {
354
- return;
355
- }
356
- // Bring focus back to where it came from before focusing the toolbar:
357
- // 1. If it came from outside the engine view (e.g. source editing), move it there.
358
- if (lastFocusedForeignElement) {
359
- lastFocusedForeignElement.focus();
360
- lastFocusedForeignElement = null;
361
- }
362
- // 2. There are two possibilities left:
363
- // 2.1. It could be that the focus went from an editable element in the view (root or nested).
364
- // 2.2. It could be the focus went straight to the toolbar before even focusing the editing area.
365
- // In either case, just focus the view editing. The focus will land where it belongs.
366
- else {
367
- editor.editing.view.focus();
368
- }
369
- // Clean up after the toolbar if there is anything to do there.
370
- if (focusedToolbarDef.options.afterBlur) {
371
- focusedToolbarDef.options.afterBlur();
372
- }
373
- cancel();
374
- });
375
- }
376
- /**
377
- * Returns definitions of toolbars that could potentially be focused, sorted by their importance for the user.
378
- *
379
- * Focusable toolbars candidates are either:
380
- * * already visible,
381
- * * have `beforeFocus()` set in their {@link module:core/editor/editorui~FocusableToolbarDefinition definition} that suggests that
382
- * they might show up when called. Keep in mind that determining whether a toolbar will show up (and become focusable) is impossible
383
- * at this stage because it depends on its implementation, that in turn depends on the editing context (selection).
384
- *
385
- * **Note**: Contextual toolbars take precedence over regular toolbars.
386
- *
387
- * @private
388
- * @returns {Array.<module:core/editor/editorui~FocusableToolbarDefinition>}
389
- */
390
- _getFocusableCandidateToolbarDefinitions() {
391
- const definitions = [];
392
- for (const toolbarDef of this._focusableToolbarDefinitions) {
393
- const { toolbarView, options } = toolbarDef;
394
- if (isVisible(toolbarView.element) || options.beforeFocus) {
395
- definitions.push(toolbarDef);
396
- }
397
- }
398
- // Contextual and already visible toolbars have higher priority. If both are true, the toolbar will always focus first.
399
- // For instance, a selected widget toolbar vs inline editor toolbar: both are visible but the widget toolbar is contextual.
400
- definitions.sort((defA, defB) => getToolbarDefinitionWeight(defA) - getToolbarDefinitionWeight(defB));
401
- return definitions;
402
- }
403
- /**
404
- * Returns a definition of the toolbar that is currently visible and focused (one of its children has focus).
405
- *
406
- * `null` is returned when no toolbar is currently focused.
407
- *
408
- * @private
409
- * @returns {module:core/editor/editorui~FocusableToolbarDefinition|null}
410
- */
411
- _getCurrentFocusedToolbarDefinition() {
412
- for (const definition of this._focusableToolbarDefinitions) {
413
- if (definition.toolbarView.element && definition.toolbarView.element.contains(this.focusTracker.focusedElement)) {
414
- return definition;
415
- }
416
- }
417
- return null;
418
- }
419
- /**
420
- * Focuses a focusable toolbar candidate using its definition.
421
- *
422
- * @private
423
- * @param {module:core/editor/editorui~FocusableToolbarDefinition} candidateToolbarDefinition A definition of the toolbar to focus.
424
- * @returns {Boolean} `true` when the toolbar candidate was focused. `false` otherwise.
425
- */
426
- _focusFocusableCandidateToolbar(candidateToolbarDefinition) {
427
- const { toolbarView, options: { beforeFocus } } = candidateToolbarDefinition;
428
- if (beforeFocus) {
429
- beforeFocus();
430
- }
431
- // If it didn't show up after beforeFocus(), it's not focusable at all.
432
- if (!isVisible(toolbarView.element)) {
433
- return false;
434
- }
435
- toolbarView.focus();
436
- return true;
437
- }
438
- }
439
- /**
440
- * An instance of a focusable toolbar view.
441
- *
442
- * @member {module:ui/toolbar/toolbarview~ToolbarView} #toolbarView
443
- */
444
- /**
445
- * Options of a focusable toolbar view:
446
- *
447
- * * `isContextual`: Marks the higher priority toolbar. For example when there are 2 visible toolbars,
448
- * it allows to distinguish which toolbar should be focused first after the `alt+f10` keystroke
449
- * * `beforeFocus`: A callback executed before the `ToolbarView` gains focus upon the `Alt+F10` keystroke.
450
- * * `afterBlur`: A callback executed after `ToolbarView` loses focus upon `Esc` keystroke but before the focus goes back to the `origin`.
451
- *
452
- * @member {Object} #options
453
- */
454
- // Returns a number (weight) for a toolbar definition. Visible toolbars have a higher priority and so do
455
- // contextual toolbars (displayed in the context of a content, for instance, an image toolbar).
456
- //
457
- // A standard invisible toolbar is the heaviest. A visible contextual toolbar is the lightest.
458
- //
459
- // @private
460
- // @param {module:core/editor/editorui~FocusableToolbarDefinition} toolbarDef A toolbar definition to be weighted.
461
- // @returns {Number}
462
- function getToolbarDefinitionWeight(toolbarDef) {
463
- const { toolbarView, options } = toolbarDef;
464
- let weight = 10;
465
- // Prioritize already visible toolbars. They should get focused first.
466
- if (isVisible(toolbarView.element)) {
467
- weight--;
468
- }
469
- // Prioritize contextual toolbars. They are displayed at the selection.
470
- if (options.isContextual) {
471
- weight--;
472
- }
473
- return weight;
474
- }