@ckeditor/ckeditor5-core 35.3.2 → 36.0.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/LICENSE.md +1 -1
- package/lang/translations/ug.po +7 -7
- package/package.json +17 -17
- package/src/command.js +17 -14
- package/src/commandcollection.js +2 -2
- package/src/context.js +4 -7
- package/src/contextplugin.js +3 -3
- package/src/editingkeystrokehandler.js +2 -2
- package/src/editor/editor.js +4 -10
- package/src/editor/editorconfig.js +1 -1
- package/src/editor/utils/attachtoform.js +2 -2
- package/src/editor/utils/dataapimixin.js +1 -1
- package/src/editor/utils/elementapimixin.js +2 -3
- package/src/editor/utils/securesourceelement.js +2 -2
- package/src/index.js +1 -2
- package/src/multicommand.js +4 -4
- package/src/pendingactions.js +5 -7
- package/src/plugin.js +3 -3
- package/src/plugincollection.js +3 -4
- package/src/editor/editorui.js +0 -474
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-
|
|
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
|
|
package/lang/translations/ug.po
CHANGED
|
@@ -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": "
|
|
3
|
+
"version": "36.0.0",
|
|
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": "^
|
|
27
|
-
"@ckeditor/ckeditor5-
|
|
28
|
-
"@ckeditor/ckeditor5-utils": "^35.3.2",
|
|
26
|
+
"@ckeditor/ckeditor5-engine": "^36.0.0",
|
|
27
|
+
"@ckeditor/ckeditor5-utils": "^36.0.0",
|
|
29
28
|
"lodash-es": "^4.17.15"
|
|
30
29
|
},
|
|
31
30
|
"devDependencies": {
|
|
32
|
-
"@ckeditor/ckeditor5-autoformat": "^
|
|
33
|
-
"@ckeditor/ckeditor5-basic-styles": "^
|
|
34
|
-
"@ckeditor/ckeditor5-block-quote": "^
|
|
35
|
-
"@ckeditor/ckeditor5-editor-classic": "^
|
|
36
|
-
"@ckeditor/ckeditor5-essentials": "^
|
|
37
|
-
"@ckeditor/ckeditor5-heading": "^
|
|
38
|
-
"@ckeditor/ckeditor5-image": "^
|
|
39
|
-
"@ckeditor/ckeditor5-indent": "^
|
|
40
|
-
"@ckeditor/ckeditor5-link": "^
|
|
41
|
-
"@ckeditor/ckeditor5-list": "^
|
|
42
|
-
"@ckeditor/ckeditor5-media-embed": "^
|
|
43
|
-
"@ckeditor/ckeditor5-paragraph": "^
|
|
44
|
-
"@ckeditor/ckeditor5-table": "^
|
|
31
|
+
"@ckeditor/ckeditor5-autoformat": "^36.0.0",
|
|
32
|
+
"@ckeditor/ckeditor5-basic-styles": "^36.0.0",
|
|
33
|
+
"@ckeditor/ckeditor5-block-quote": "^36.0.0",
|
|
34
|
+
"@ckeditor/ckeditor5-editor-classic": "^36.0.0",
|
|
35
|
+
"@ckeditor/ckeditor5-essentials": "^36.0.0",
|
|
36
|
+
"@ckeditor/ckeditor5-heading": "^36.0.0",
|
|
37
|
+
"@ckeditor/ckeditor5-image": "^36.0.0",
|
|
38
|
+
"@ckeditor/ckeditor5-indent": "^36.0.0",
|
|
39
|
+
"@ckeditor/ckeditor5-link": "^36.0.0",
|
|
40
|
+
"@ckeditor/ckeditor5-list": "^36.0.0",
|
|
41
|
+
"@ckeditor/ckeditor5-media-embed": "^36.0.0",
|
|
42
|
+
"@ckeditor/ckeditor5-paragraph": "^36.0.0",
|
|
43
|
+
"@ckeditor/ckeditor5-table": "^36.0.0",
|
|
44
|
+
"@ckeditor/ckeditor5-ui": "^36.0.0",
|
|
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,28 +1,31 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
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
|
-
import { Observable } from '@ckeditor/ckeditor5-utils/src/observablemixin';
|
|
6
5
|
/**
|
|
7
|
-
*
|
|
6
|
+
* @module core/command
|
|
7
|
+
*/
|
|
8
|
+
import { ObservableMixin } from '@ckeditor/ckeditor5-utils';
|
|
9
|
+
/**
|
|
10
|
+
* Base class for the CKEditor commands.
|
|
8
11
|
*
|
|
9
|
-
* Commands are the main way to manipulate editor contents and state. They are mostly used by UI elements (or by other
|
|
10
|
-
* commands) to make changes in the model. Commands are available in every part of code that has access to
|
|
12
|
+
* Commands are the main way to manipulate the editor contents and state. They are mostly used by UI elements (or by other
|
|
13
|
+
* commands) to make changes in the model. Commands are available in every part of the code that has access to
|
|
11
14
|
* the {@link module:core/editor/editor~Editor editor} instance.
|
|
12
15
|
*
|
|
13
16
|
* Instances of registered commands can be retrieved from {@link module:core/editor/editor~Editor#commands `editor.commands`}.
|
|
14
17
|
* The easiest way to execute a command is through {@link module:core/editor/editor~Editor#execute `editor.execute()`}.
|
|
15
18
|
*
|
|
16
|
-
* By default, commands are disabled when the editor is in {@link module:core/editor/editor~Editor#isReadOnly read-only} mode
|
|
19
|
+
* By default, commands are disabled when the editor is in the {@link module:core/editor/editor~Editor#isReadOnly read-only} mode
|
|
17
20
|
* but commands with the {@link module:core/command~Command#affectsData `affectsData`} flag set to `false` will not be disabled.
|
|
18
21
|
*
|
|
19
22
|
* @mixes module:utils/observablemixin~ObservableMixin
|
|
20
23
|
*/
|
|
21
|
-
export default class Command extends
|
|
24
|
+
export default class Command extends ObservableMixin() {
|
|
22
25
|
/**
|
|
23
26
|
* Creates a new `Command` instance.
|
|
24
27
|
*
|
|
25
|
-
* @param {module:core/editor/editor~Editor} editor
|
|
28
|
+
* @param {module:core/editor/editor~Editor} editor The editor on which this command will be used.
|
|
26
29
|
*/
|
|
27
30
|
constructor(editor) {
|
|
28
31
|
super();
|
|
@@ -34,14 +37,14 @@ export default class Command extends Observable {
|
|
|
34
37
|
*/
|
|
35
38
|
this.editor = editor;
|
|
36
39
|
/**
|
|
37
|
-
* The value of the command. A
|
|
40
|
+
* The value of the command. A given command class should define what it represents for it.
|
|
38
41
|
*
|
|
39
42
|
* For example, the `'bold'` command's value indicates whether the selection starts in a bolded text.
|
|
40
|
-
* And the value of the `'link'` command may be an object with
|
|
43
|
+
* And the value of the `'link'` command may be an object with link details.
|
|
41
44
|
*
|
|
42
45
|
* It is possible for a command to have no value (e.g. for stateless actions such as `'uploadImage'`).
|
|
43
46
|
*
|
|
44
|
-
* A
|
|
47
|
+
* A given command class should control this value by overriding the {@link #refresh `refresh()`} method.
|
|
45
48
|
*
|
|
46
49
|
* @observable
|
|
47
50
|
* @readonly
|
|
@@ -52,9 +55,9 @@ export default class Command extends Observable {
|
|
|
52
55
|
* Flag indicating whether a command is enabled or disabled.
|
|
53
56
|
* A disabled command will do nothing when executed.
|
|
54
57
|
*
|
|
55
|
-
* A
|
|
58
|
+
* A given command class should control this value by overriding the {@link #refresh `refresh()`} method.
|
|
56
59
|
*
|
|
57
|
-
* It is possible to disable a command from
|
|
60
|
+
* It is possible to disable a command "from outside". For instance, in your integration you may want to disable
|
|
58
61
|
* a certain set of commands for the time being. To do that, you can use the fact that `isEnabled` is observable
|
|
59
62
|
* and it fires the `set:isEnabled` event every time anyone tries to modify its value:
|
|
60
63
|
*
|
|
@@ -149,7 +152,7 @@ export default class Command extends Observable {
|
|
|
149
152
|
* Disables the command.
|
|
150
153
|
*
|
|
151
154
|
* Command may be disabled by multiple features or algorithms (at once). When disabling a command, unique id should be passed
|
|
152
|
-
* (e.g. feature name). The same identifier should be used when {@link #clearForceDisabled enabling back} the command.
|
|
155
|
+
* (e.g. the feature name). The same identifier should be used when {@link #clearForceDisabled enabling back} the command.
|
|
153
156
|
* The command becomes enabled only after all features {@link #clearForceDisabled enabled it back}.
|
|
154
157
|
*
|
|
155
158
|
* Disabling and enabling a command:
|
package/src/commandcollection.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
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
|
/**
|
|
6
6
|
* @module core/commandcollection
|
|
7
7
|
*/
|
|
8
|
-
import CKEditorError from '@ckeditor/ckeditor5-utils
|
|
8
|
+
import { CKEditorError } from '@ckeditor/ckeditor5-utils';
|
|
9
9
|
/**
|
|
10
10
|
* Collection of commands. Its instance is available in {@link module:core/editor/editor~Editor#commands `editor.commands`}.
|
|
11
11
|
*/
|
package/src/context.js
CHANGED
|
@@ -1,21 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
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
|
/**
|
|
6
6
|
* @module core/context
|
|
7
7
|
*/
|
|
8
|
-
import Config from '@ckeditor/ckeditor5-utils
|
|
9
|
-
import Collection from '@ckeditor/ckeditor5-utils/src/collection';
|
|
8
|
+
import { Config, Collection, CKEditorError, Locale } from '@ckeditor/ckeditor5-utils';
|
|
10
9
|
import PluginCollection from './plugincollection';
|
|
11
|
-
import Locale from '@ckeditor/ckeditor5-utils/src/locale';
|
|
12
|
-
import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
|
|
13
10
|
/**
|
|
14
11
|
* Provides a common, higher-level environment for solutions that use multiple {@link module:core/editor/editor~Editor editors}
|
|
15
12
|
* or plugins that work outside the editor. Use it instead of {@link module:core/editor/editor~Editor.create `Editor.create()`}
|
|
16
13
|
* in advanced application integrations.
|
|
17
14
|
*
|
|
18
|
-
* All configuration options passed to a context will be used as default options for editor instances initialized in that context.
|
|
15
|
+
* All configuration options passed to a context will be used as default options for the editor instances initialized in that context.
|
|
19
16
|
*
|
|
20
17
|
* {@link module:core/contextplugin~ContextPlugin Context plugins} passed to a context instance will be shared among all
|
|
21
18
|
* editor instances initialized in this context. These will be the same plugin instances for all the editors.
|
|
@@ -33,7 +30,7 @@ import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
|
|
|
33
30
|
* enable and configure them using the context.
|
|
34
31
|
*
|
|
35
32
|
* If you are using only a single editor on each page, use {@link module:core/editor/editor~Editor.create `Editor.create()`} instead.
|
|
36
|
-
* In such case, a context instance will be created by the editor instance in a transparent way.
|
|
33
|
+
* In such a case, a context instance will be created by the editor instance in a transparent way.
|
|
37
34
|
*
|
|
38
35
|
* See {@link module:core/context~Context.create `Context.create()`} for usage examples.
|
|
39
36
|
*/
|
package/src/contextplugin.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
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
|
/**
|
|
6
6
|
* @module core/contextplugin
|
|
7
7
|
*/
|
|
8
|
-
import {
|
|
8
|
+
import { ObservableMixin } from '@ckeditor/ckeditor5-utils';
|
|
9
9
|
/**
|
|
10
10
|
* The base class for {@link module:core/context~Context} plugin classes.
|
|
11
11
|
*
|
|
@@ -23,7 +23,7 @@ import { Observable } from '@ckeditor/ckeditor5-utils/src/observablemixin';
|
|
|
23
23
|
* @implements module:core/plugin~PluginInterface
|
|
24
24
|
* @mixes module:utils/observablemixin~ObservableMixin
|
|
25
25
|
*/
|
|
26
|
-
export default class ContextPlugin extends
|
|
26
|
+
export default class ContextPlugin extends ObservableMixin() {
|
|
27
27
|
/**
|
|
28
28
|
* Creates a new plugin instance.
|
|
29
29
|
*
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
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
|
/**
|
|
6
6
|
* @module core/editingkeystrokehandler
|
|
7
7
|
*/
|
|
8
|
-
import KeystrokeHandler from '@ckeditor/ckeditor5-utils
|
|
8
|
+
import { KeystrokeHandler } from '@ckeditor/ckeditor5-utils';
|
|
9
9
|
/**
|
|
10
10
|
* A keystroke handler for editor editing. Its instance is available
|
|
11
11
|
* in {@link module:core/editor/editor~Editor#keystrokes} so plugins
|
package/src/editor/editor.js
CHANGED
|
@@ -1,22 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
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
|
/**
|
|
6
6
|
* @module core/editor/editor
|
|
7
7
|
*/
|
|
8
|
+
import { Config, CKEditorError, ObservableMixin } from '@ckeditor/ckeditor5-utils';
|
|
9
|
+
import { Conversion, DataController, EditingController, Model, StylesProcessor } from '@ckeditor/ckeditor5-engine';
|
|
8
10
|
import Context from '../context';
|
|
9
|
-
import Config from '@ckeditor/ckeditor5-utils/src/config';
|
|
10
|
-
import EditingController from '@ckeditor/ckeditor5-engine/src/controller/editingcontroller';
|
|
11
11
|
import PluginCollection from '../plugincollection';
|
|
12
12
|
import CommandCollection from '../commandcollection';
|
|
13
|
-
import DataController from '@ckeditor/ckeditor5-engine/src/controller/datacontroller';
|
|
14
|
-
import Conversion from '@ckeditor/ckeditor5-engine/src/conversion/conversion';
|
|
15
|
-
import Model from '@ckeditor/ckeditor5-engine/src/model/model';
|
|
16
13
|
import EditingKeystrokeHandler from '../editingkeystrokehandler';
|
|
17
|
-
import { Observable } from '@ckeditor/ckeditor5-utils/src/observablemixin';
|
|
18
|
-
import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
|
|
19
|
-
import { StylesProcessor } from '@ckeditor/ckeditor5-engine/src/view/stylesmap';
|
|
20
14
|
/**
|
|
21
15
|
* The class representing a basic, generic editor.
|
|
22
16
|
*
|
|
@@ -38,7 +32,7 @@ import { StylesProcessor } from '@ckeditor/ckeditor5-engine/src/view/stylesmap';
|
|
|
38
32
|
* @abstract
|
|
39
33
|
* @mixes module:utils/observablemixin~ObservableMixin
|
|
40
34
|
*/
|
|
41
|
-
export default class Editor extends
|
|
35
|
+
export default class Editor extends ObservableMixin() {
|
|
42
36
|
/**
|
|
43
37
|
* Creates a new instance of the editor class.
|
|
44
38
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
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,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
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';
|
|
6
|
-
import CKEditorError from '@ckeditor/ckeditor5-utils
|
|
6
|
+
import { CKEditorError } from '@ckeditor/ckeditor5-utils';
|
|
7
7
|
/**
|
|
8
8
|
* @module core/editor/utils/attachtoform
|
|
9
9
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
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,10 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
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 */
|
|
6
|
-
import CKEditorError from '@ckeditor/ckeditor5-utils
|
|
7
|
-
import setDataInElement from '@ckeditor/ckeditor5-utils/src/dom/setdatainelement';
|
|
6
|
+
import { CKEditorError, setDataInElement } from '@ckeditor/ckeditor5-utils';
|
|
8
7
|
/**
|
|
9
8
|
* @module core/editor/utils/elementapimixin
|
|
10
9
|
*/
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
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
|
-
import CKEditorError from '@ckeditor/ckeditor5-utils
|
|
5
|
+
import { CKEditorError } from '@ckeditor/ckeditor5-utils';
|
|
6
6
|
/**
|
|
7
7
|
* @module core/editor/utils/securesourceelement
|
|
8
8
|
*/
|
package/src/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
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';
|
package/src/multicommand.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
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';
|
|
6
|
-
import insertToPriorityArray from '@ckeditor/ckeditor5-utils
|
|
6
|
+
import { insertToPriorityArray } from '@ckeditor/ckeditor5-utils';
|
|
7
7
|
/**
|
|
8
8
|
* @module core/multicommand
|
|
9
9
|
*/
|
|
@@ -12,7 +12,7 @@ import insertToPriorityArray from '@ckeditor/ckeditor5-utils/src/inserttopriorit
|
|
|
12
12
|
*
|
|
13
13
|
* This command is used to proxy multiple commands. The multi-command is enabled when
|
|
14
14
|
* at least one of its registered child commands is enabled.
|
|
15
|
-
* When executing a multi-command the first enabled command with highest priority will be executed.
|
|
15
|
+
* When executing a multi-command, the first enabled command with highest priority will be executed.
|
|
16
16
|
*
|
|
17
17
|
* const multiCommand = new MultiCommand( editor );
|
|
18
18
|
*
|
|
@@ -69,7 +69,7 @@ export default class MultiCommand extends Command {
|
|
|
69
69
|
*/
|
|
70
70
|
registerChildCommand(command, options = {}) {
|
|
71
71
|
insertToPriorityArray(this._childCommandsDefinitions, { command, priority: options.priority || 'normal' });
|
|
72
|
-
// Change multi
|
|
72
|
+
// Change multi-command enabled state when one of registered commands changes state.
|
|
73
73
|
command.on('change:isEnabled', () => this._checkEnabled());
|
|
74
74
|
this._checkEnabled();
|
|
75
75
|
}
|
package/src/pendingactions.js
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
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
|
/**
|
|
6
6
|
* @module core/pendingactions
|
|
7
7
|
*/
|
|
8
8
|
import ContextPlugin from './contextplugin';
|
|
9
|
-
import {
|
|
10
|
-
import Collection from '@ckeditor/ckeditor5-utils/src/collection';
|
|
11
|
-
import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
|
|
9
|
+
import { CKEditorError, Collection, ObservableMixin } from '@ckeditor/ckeditor5-utils';
|
|
12
10
|
/**
|
|
13
11
|
* The list of pending editor actions.
|
|
14
12
|
*
|
|
@@ -45,7 +43,7 @@ import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
|
|
|
45
43
|
*
|
|
46
44
|
* This plugin is used by features like {@link module:upload/filerepository~FileRepository} to register their ongoing actions
|
|
47
45
|
* and by features like {@link module:autosave/autosave~Autosave} to detect whether there are any ongoing actions.
|
|
48
|
-
* Read more about saving the data in the {@glink installation/
|
|
46
|
+
* Read more about saving the data in the {@glink installation/getting-started/getting-and-setting-data Saving and getting data} guide.
|
|
49
47
|
*
|
|
50
48
|
* @extends module:core/contextplugin~ContextPlugin
|
|
51
49
|
*/
|
|
@@ -95,7 +93,7 @@ export default class PendingActions extends ContextPlugin {
|
|
|
95
93
|
*/
|
|
96
94
|
throw new CKEditorError('pendingactions-add-invalid-message', this);
|
|
97
95
|
}
|
|
98
|
-
const action = new
|
|
96
|
+
const action = new (ObservableMixin())();
|
|
99
97
|
action.set('message', message);
|
|
100
98
|
this._actions.add(action);
|
|
101
99
|
this.hasAny = true;
|
|
@@ -111,7 +109,7 @@ export default class PendingActions extends ContextPlugin {
|
|
|
111
109
|
this.hasAny = !!this._actions.length;
|
|
112
110
|
}
|
|
113
111
|
/**
|
|
114
|
-
* Returns the first action from the list or null
|
|
112
|
+
* Returns the first action from the list or null if the list is empty
|
|
115
113
|
*
|
|
116
114
|
* returns {Object|null} The pending action object.
|
|
117
115
|
*/
|
package/src/plugin.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
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 */
|
|
6
6
|
/**
|
|
7
7
|
* @module core/plugin
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
9
|
+
import { ObservableMixin } from '@ckeditor/ckeditor5-utils';
|
|
10
10
|
/**
|
|
11
11
|
* The base class for CKEditor plugin classes.
|
|
12
12
|
*
|
|
13
13
|
* @implements module:core/plugin~PluginInterface
|
|
14
14
|
* @mixes module:utils/observablemixin~ObservableMixin
|
|
15
15
|
*/
|
|
16
|
-
export default class Plugin extends
|
|
16
|
+
export default class Plugin extends ObservableMixin() {
|
|
17
17
|
/**
|
|
18
18
|
* @inheritDoc
|
|
19
19
|
*/
|
package/src/plugincollection.js
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
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
|
/**
|
|
6
6
|
* @module core/plugincollection
|
|
7
7
|
*/
|
|
8
|
-
import CKEditorError from '@ckeditor/ckeditor5-utils
|
|
9
|
-
import { Emitter } from '@ckeditor/ckeditor5-utils/src/emittermixin';
|
|
8
|
+
import { CKEditorError, EmitterMixin } from '@ckeditor/ckeditor5-utils';
|
|
10
9
|
/**
|
|
11
10
|
* Manages a list of CKEditor plugins, including loading, resolving dependencies and initialization.
|
|
12
11
|
*
|
|
13
12
|
* @mixes module:utils/emittermixin~EmitterMixin
|
|
14
13
|
*/
|
|
15
|
-
export default class PluginCollection extends
|
|
14
|
+
export default class PluginCollection extends EmitterMixin() {
|
|
16
15
|
/**
|
|
17
16
|
* Creates an instance of the plugin collection class.
|
|
18
17
|
* Allows loading and initializing plugins and their dependencies.
|
package/src/editor/editorui.js
DELETED
|
@@ -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
|
-
import ComponentFactory from '@ckeditor/ckeditor5-ui/src/componentfactory';
|
|
6
|
-
import FocusTracker from '@ckeditor/ckeditor5-utils/src/focustracker';
|
|
7
|
-
import TooltipManager from '@ckeditor/ckeditor5-ui/src/tooltipmanager';
|
|
8
|
-
import { Observable } from '@ckeditor/ckeditor5-utils/src/observablemixin';
|
|
9
|
-
import isVisible from '@ckeditor/ckeditor5-utils/src/dom/isvisible';
|
|
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 Observable {
|
|
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
|
-
}
|