@ckeditor/ckeditor5-core 40.0.0 → 40.2.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 (115) hide show
  1. package/CHANGELOG.md +28 -28
  2. package/LICENSE.md +3 -3
  3. package/README.md +1 -1
  4. package/lang/contexts.json +5 -1
  5. package/lang/translations/af.po +16 -0
  6. package/lang/translations/ar.po +16 -0
  7. package/lang/translations/ast.po +16 -0
  8. package/lang/translations/az.po +16 -0
  9. package/lang/translations/bg.po +16 -0
  10. package/lang/translations/bn.po +16 -0
  11. package/lang/translations/bs.po +16 -0
  12. package/lang/translations/ca.po +16 -0
  13. package/lang/translations/cs.po +16 -0
  14. package/lang/translations/da.po +16 -0
  15. package/lang/translations/de-ch.po +16 -0
  16. package/lang/translations/de.po +16 -0
  17. package/lang/translations/el.po +16 -0
  18. package/lang/translations/en-au.po +16 -0
  19. package/lang/translations/en-gb.po +16 -0
  20. package/lang/translations/en.po +16 -0
  21. package/lang/translations/eo.po +16 -0
  22. package/lang/translations/es-co.po +16 -0
  23. package/lang/translations/es.po +16 -0
  24. package/lang/translations/et.po +16 -0
  25. package/lang/translations/eu.po +16 -0
  26. package/lang/translations/fa.po +16 -0
  27. package/lang/translations/fi.po +16 -0
  28. package/lang/translations/fr.po +16 -0
  29. package/lang/translations/gl.po +16 -0
  30. package/lang/translations/gu.po +16 -0
  31. package/lang/translations/he.po +16 -0
  32. package/lang/translations/hi.po +16 -0
  33. package/lang/translations/hr.po +16 -0
  34. package/lang/translations/hu.po +16 -0
  35. package/lang/translations/hy.po +16 -0
  36. package/lang/translations/id.po +16 -0
  37. package/lang/translations/it.po +16 -0
  38. package/lang/translations/ja.po +16 -0
  39. package/lang/translations/jv.po +16 -0
  40. package/lang/translations/km.po +16 -0
  41. package/lang/translations/kn.po +16 -0
  42. package/lang/translations/ko.po +16 -0
  43. package/lang/translations/ku.po +16 -0
  44. package/lang/translations/lt.po +16 -0
  45. package/lang/translations/lv.po +16 -0
  46. package/lang/translations/ms.po +16 -0
  47. package/lang/translations/nb.po +16 -0
  48. package/lang/translations/ne.po +16 -0
  49. package/lang/translations/nl.po +16 -0
  50. package/lang/translations/no.po +16 -0
  51. package/lang/translations/oc.po +16 -0
  52. package/lang/translations/pl.po +16 -0
  53. package/lang/translations/pt-br.po +16 -0
  54. package/lang/translations/pt.po +16 -0
  55. package/lang/translations/ro.po +16 -0
  56. package/lang/translations/ru.po +16 -0
  57. package/lang/translations/si.po +16 -0
  58. package/lang/translations/sk.po +16 -0
  59. package/lang/translations/sl.po +16 -0
  60. package/lang/translations/sq.po +16 -0
  61. package/lang/translations/sr-latn.po +17 -1
  62. package/lang/translations/sr.po +16 -0
  63. package/lang/translations/sv.po +16 -0
  64. package/lang/translations/th.po +16 -0
  65. package/lang/translations/tk.po +16 -0
  66. package/lang/translations/tr.po +16 -0
  67. package/lang/translations/tt.po +16 -0
  68. package/lang/translations/ug.po +17 -1
  69. package/lang/translations/uk.po +16 -0
  70. package/lang/translations/ur.po +16 -0
  71. package/lang/translations/uz.po +16 -0
  72. package/lang/translations/vi.po +16 -0
  73. package/lang/translations/zh-cn.po +16 -0
  74. package/lang/translations/zh.po +16 -0
  75. package/package.json +3 -3
  76. package/src/augmentation.d.ts +10 -10
  77. package/src/augmentation.js +5 -5
  78. package/src/command.d.ts +189 -189
  79. package/src/command.js +185 -185
  80. package/src/commandcollection.d.ts +83 -83
  81. package/src/commandcollection.js +83 -83
  82. package/src/context.d.ts +237 -237
  83. package/src/context.js +225 -225
  84. package/src/contextplugin.d.ts +61 -61
  85. package/src/contextplugin.js +43 -43
  86. package/src/editingkeystrokehandler.d.ts +56 -56
  87. package/src/editingkeystrokehandler.js +57 -57
  88. package/src/editor/editor.d.ts +417 -417
  89. package/src/editor/editor.js +316 -316
  90. package/src/editor/editorconfig.d.ts +661 -660
  91. package/src/editor/editorconfig.js +5 -5
  92. package/src/editor/utils/attachtoform.d.ts +15 -15
  93. package/src/editor/utils/attachtoform.js +57 -57
  94. package/src/editor/utils/dataapimixin.d.ts +75 -75
  95. package/src/editor/utils/dataapimixin.js +24 -24
  96. package/src/editor/utils/elementapimixin.d.ts +35 -31
  97. package/src/editor/utils/elementapimixin.js +43 -42
  98. package/src/editor/utils/securesourceelement.d.ts +17 -17
  99. package/src/editor/utils/securesourceelement.js +35 -35
  100. package/src/index.d.ts +66 -62
  101. package/src/index.js +103 -95
  102. package/src/multicommand.d.ts +66 -66
  103. package/src/multicommand.js +82 -82
  104. package/src/pendingactions.d.ts +117 -117
  105. package/src/pendingactions.js +116 -116
  106. package/src/plugin.d.ts +274 -274
  107. package/src/plugin.js +106 -106
  108. package/src/plugincollection.d.ts +117 -117
  109. package/src/plugincollection.js +473 -473
  110. package/theme/icons/image-asset-manager.svg +1 -0
  111. package/theme/icons/image-upload.svg +1 -0
  112. package/theme/icons/image-url.svg +1 -0
  113. package/theme/icons/image.svg +1 -1
  114. package/theme/icons/low-vision.svg +1 -1
  115. package/theme/icons/text-alternative.svg +1 -0
package/src/index.d.ts CHANGED
@@ -1,62 +1,66 @@
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
7
- */
8
- export { default as Plugin, type PluginDependencies, type PluginConstructor } from './plugin';
9
- export { default as Command, type CommandExecuteEvent } from './command';
10
- export { default as MultiCommand } from './multicommand';
11
- export type { CommandsMap } from './commandcollection';
12
- export type { PluginsMap, default as PluginCollection } from './plugincollection';
13
- export { default as Context, type ContextConfig } from './context';
14
- export { default as ContextPlugin, type ContextPluginDependencies } from './contextplugin';
15
- export { type EditingKeystrokeCallback } from './editingkeystrokehandler';
16
- export { default as Editor, type EditorReadyEvent, type EditorDestroyEvent } from './editor/editor';
17
- export type { EditorConfig, LanguageConfig, ToolbarConfig, ToolbarConfigItem, UiConfig } from './editor/editorconfig';
18
- export { default as attachToForm } from './editor/utils/attachtoform';
19
- export { default as DataApiMixin, type DataApi } from './editor/utils/dataapimixin';
20
- export { default as ElementApiMixin, type ElementApi } from './editor/utils/elementapimixin';
21
- export { default as secureSourceElement } from './editor/utils/securesourceelement';
22
- export { default as PendingActions, type PendingAction } from './pendingactions';
23
- export declare const icons: {
24
- bold: string;
25
- cancel: string;
26
- caption: string;
27
- check: string;
28
- cog: string;
29
- eraser: string;
30
- history: string;
31
- image: string;
32
- lowVision: string;
33
- loupe: string;
34
- importExport: string;
35
- paragraph: string;
36
- plus: string;
37
- text: string;
38
- alignBottom: string;
39
- alignMiddle: string;
40
- alignTop: string;
41
- alignLeft: string;
42
- alignCenter: string;
43
- alignRight: string;
44
- alignJustify: string;
45
- objectLeft: string;
46
- objectCenter: string;
47
- objectRight: string;
48
- objectFullWidth: string;
49
- objectInline: string;
50
- objectBlockLeft: string;
51
- objectBlockRight: string;
52
- objectSizeFull: string;
53
- objectSizeLarge: string;
54
- objectSizeSmall: string;
55
- objectSizeMedium: string;
56
- pencil: string;
57
- pilcrow: string;
58
- quote: string;
59
- threeVerticalDots: string;
60
- dragIndicator: string;
61
- };
62
- import './augmentation';
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
7
+ */
8
+ export { default as Plugin, type PluginDependencies, type PluginConstructor } from './plugin';
9
+ export { default as Command, type CommandExecuteEvent } from './command';
10
+ export { default as MultiCommand } from './multicommand';
11
+ export type { CommandsMap } from './commandcollection';
12
+ export type { PluginsMap, default as PluginCollection } from './plugincollection';
13
+ export { default as Context, type ContextConfig } from './context';
14
+ export { default as ContextPlugin, type ContextPluginDependencies } from './contextplugin';
15
+ export { type EditingKeystrokeCallback } from './editingkeystrokehandler';
16
+ export { default as Editor, type EditorReadyEvent, type EditorDestroyEvent } from './editor/editor';
17
+ export type { EditorConfig, LanguageConfig, ToolbarConfig, ToolbarConfigItem, UiConfig } from './editor/editorconfig';
18
+ export { default as attachToForm } from './editor/utils/attachtoform';
19
+ export { default as DataApiMixin, type DataApi } from './editor/utils/dataapimixin';
20
+ export { default as ElementApiMixin, type ElementApi } from './editor/utils/elementapimixin';
21
+ export { default as secureSourceElement } from './editor/utils/securesourceelement';
22
+ export { default as PendingActions, type PendingAction } from './pendingactions';
23
+ export declare const icons: {
24
+ bold: string;
25
+ cancel: string;
26
+ caption: string;
27
+ check: string;
28
+ cog: string;
29
+ eraser: string;
30
+ history: string;
31
+ image: string;
32
+ imageUpload: string;
33
+ imageAssetManager: string;
34
+ imageUrl: string;
35
+ lowVision: string;
36
+ textAlternative: string;
37
+ loupe: string;
38
+ importExport: string;
39
+ paragraph: string;
40
+ plus: string;
41
+ text: string;
42
+ alignBottom: string;
43
+ alignMiddle: string;
44
+ alignTop: string;
45
+ alignLeft: string;
46
+ alignCenter: string;
47
+ alignRight: string;
48
+ alignJustify: string;
49
+ objectLeft: string;
50
+ objectCenter: string;
51
+ objectRight: string;
52
+ objectFullWidth: string;
53
+ objectInline: string;
54
+ objectBlockLeft: string;
55
+ objectBlockRight: string;
56
+ objectSizeFull: string;
57
+ objectSizeLarge: string;
58
+ objectSizeSmall: string;
59
+ objectSizeMedium: string;
60
+ pencil: string;
61
+ pilcrow: string;
62
+ quote: string;
63
+ threeVerticalDots: string;
64
+ dragIndicator: string;
65
+ };
66
+ import './augmentation';
package/src/index.js CHANGED
@@ -1,95 +1,103 @@
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
7
- */
8
- export { default as Plugin } from './plugin';
9
- export { default as Command } from './command';
10
- export { default as MultiCommand } from './multicommand';
11
- export { default as Context } from './context';
12
- export { default as ContextPlugin } from './contextplugin';
13
- export { default as Editor } from './editor/editor';
14
- export { default as attachToForm } from './editor/utils/attachtoform';
15
- export { default as DataApiMixin } from './editor/utils/dataapimixin';
16
- export { default as ElementApiMixin } from './editor/utils/elementapimixin';
17
- export { default as secureSourceElement } from './editor/utils/securesourceelement';
18
- export { default as PendingActions } from './pendingactions';
19
- import cancel from './../theme/icons/cancel.svg';
20
- import caption from './../theme/icons/caption.svg';
21
- import check from './../theme/icons/check.svg';
22
- import cog from './../theme/icons/cog.svg';
23
- import eraser from './../theme/icons/eraser.svg';
24
- import history from './../theme/icons/history.svg';
25
- import lowVision from './../theme/icons/low-vision.svg';
26
- import loupe from './../theme/icons/loupe.svg';
27
- import image from './../theme/icons/image.svg';
28
- import alignBottom from './../theme/icons/align-bottom.svg';
29
- import alignMiddle from './../theme/icons/align-middle.svg';
30
- import alignTop from './../theme/icons/align-top.svg';
31
- import alignLeft from './../theme/icons/align-left.svg';
32
- import alignCenter from './../theme/icons/align-center.svg';
33
- import alignRight from './../theme/icons/align-right.svg';
34
- import alignJustify from './../theme/icons/align-justify.svg';
35
- import objectBlockLeft from './../theme/icons/object-left.svg';
36
- import objectCenter from './../theme/icons/object-center.svg';
37
- import objectBlockRight from './../theme/icons/object-right.svg';
38
- import objectFullWidth from './../theme/icons/object-full-width.svg';
39
- import objectInline from './../theme/icons/object-inline.svg';
40
- import objectLeft from './../theme/icons/object-inline-left.svg';
41
- import objectRight from './../theme/icons/object-inline-right.svg';
42
- import objectSizeFull from './../theme/icons/object-size-full.svg';
43
- import objectSizeLarge from './../theme/icons/object-size-large.svg';
44
- import objectSizeSmall from './../theme/icons/object-size-small.svg';
45
- import objectSizeMedium from './../theme/icons/object-size-medium.svg';
46
- import pencil from './../theme/icons/pencil.svg';
47
- import pilcrow from './../theme/icons/pilcrow.svg';
48
- import quote from './../theme/icons/quote.svg';
49
- import threeVerticalDots from './../theme/icons/three-vertical-dots.svg';
50
- import dragIndicator from './../theme/icons/drag-indicator.svg';
51
- import bold from './../theme/icons/bold.svg';
52
- import paragraph from './../theme/icons/paragraph.svg';
53
- import plus from './../theme/icons/plus.svg';
54
- import text from './../theme/icons/text.svg';
55
- import importExport from './../theme/icons/importexport.svg';
56
- export const icons = {
57
- bold,
58
- cancel,
59
- caption,
60
- check,
61
- cog,
62
- eraser,
63
- history,
64
- image,
65
- lowVision,
66
- loupe,
67
- importExport,
68
- paragraph,
69
- plus,
70
- text,
71
- alignBottom,
72
- alignMiddle,
73
- alignTop,
74
- alignLeft,
75
- alignCenter,
76
- alignRight,
77
- alignJustify,
78
- objectLeft,
79
- objectCenter,
80
- objectRight,
81
- objectFullWidth,
82
- objectInline,
83
- objectBlockLeft,
84
- objectBlockRight,
85
- objectSizeFull,
86
- objectSizeLarge,
87
- objectSizeSmall,
88
- objectSizeMedium,
89
- pencil,
90
- pilcrow,
91
- quote,
92
- threeVerticalDots,
93
- dragIndicator
94
- };
95
- import './augmentation';
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
7
+ */
8
+ export { default as Plugin } from './plugin';
9
+ export { default as Command } from './command';
10
+ export { default as MultiCommand } from './multicommand';
11
+ export { default as Context } from './context';
12
+ export { default as ContextPlugin } from './contextplugin';
13
+ export { default as Editor } from './editor/editor';
14
+ export { default as attachToForm } from './editor/utils/attachtoform';
15
+ export { default as DataApiMixin } from './editor/utils/dataapimixin';
16
+ export { default as ElementApiMixin } from './editor/utils/elementapimixin';
17
+ export { default as secureSourceElement } from './editor/utils/securesourceelement';
18
+ export { default as PendingActions } from './pendingactions';
19
+ import cancel from './../theme/icons/cancel.svg';
20
+ import caption from './../theme/icons/caption.svg';
21
+ import check from './../theme/icons/check.svg';
22
+ import cog from './../theme/icons/cog.svg';
23
+ import eraser from './../theme/icons/eraser.svg';
24
+ import history from './../theme/icons/history.svg';
25
+ import lowVision from './../theme/icons/low-vision.svg';
26
+ import textAlternative from './../theme/icons/text-alternative.svg';
27
+ import loupe from './../theme/icons/loupe.svg';
28
+ import image from './../theme/icons/image.svg';
29
+ import imageUpload from './../theme/icons/image-upload.svg';
30
+ import imageAssetManager from './../theme/icons/image-asset-manager.svg';
31
+ import imageUrl from './../theme/icons/image-url.svg';
32
+ import alignBottom from './../theme/icons/align-bottom.svg';
33
+ import alignMiddle from './../theme/icons/align-middle.svg';
34
+ import alignTop from './../theme/icons/align-top.svg';
35
+ import alignLeft from './../theme/icons/align-left.svg';
36
+ import alignCenter from './../theme/icons/align-center.svg';
37
+ import alignRight from './../theme/icons/align-right.svg';
38
+ import alignJustify from './../theme/icons/align-justify.svg';
39
+ import objectBlockLeft from './../theme/icons/object-left.svg';
40
+ import objectCenter from './../theme/icons/object-center.svg';
41
+ import objectBlockRight from './../theme/icons/object-right.svg';
42
+ import objectFullWidth from './../theme/icons/object-full-width.svg';
43
+ import objectInline from './../theme/icons/object-inline.svg';
44
+ import objectLeft from './../theme/icons/object-inline-left.svg';
45
+ import objectRight from './../theme/icons/object-inline-right.svg';
46
+ import objectSizeFull from './../theme/icons/object-size-full.svg';
47
+ import objectSizeLarge from './../theme/icons/object-size-large.svg';
48
+ import objectSizeSmall from './../theme/icons/object-size-small.svg';
49
+ import objectSizeMedium from './../theme/icons/object-size-medium.svg';
50
+ import pencil from './../theme/icons/pencil.svg';
51
+ import pilcrow from './../theme/icons/pilcrow.svg';
52
+ import quote from './../theme/icons/quote.svg';
53
+ import threeVerticalDots from './../theme/icons/three-vertical-dots.svg';
54
+ import dragIndicator from './../theme/icons/drag-indicator.svg';
55
+ import bold from './../theme/icons/bold.svg';
56
+ import paragraph from './../theme/icons/paragraph.svg';
57
+ import plus from './../theme/icons/plus.svg';
58
+ import text from './../theme/icons/text.svg';
59
+ import importExport from './../theme/icons/importexport.svg';
60
+ export const icons = {
61
+ bold,
62
+ cancel,
63
+ caption,
64
+ check,
65
+ cog,
66
+ eraser,
67
+ history,
68
+ image,
69
+ imageUpload,
70
+ imageAssetManager,
71
+ imageUrl,
72
+ lowVision,
73
+ textAlternative,
74
+ loupe,
75
+ importExport,
76
+ paragraph,
77
+ plus,
78
+ text,
79
+ alignBottom,
80
+ alignMiddle,
81
+ alignTop,
82
+ alignLeft,
83
+ alignCenter,
84
+ alignRight,
85
+ alignJustify,
86
+ objectLeft,
87
+ objectCenter,
88
+ objectRight,
89
+ objectFullWidth,
90
+ objectInline,
91
+ objectBlockLeft,
92
+ objectBlockRight,
93
+ objectSizeFull,
94
+ objectSizeLarge,
95
+ objectSizeSmall,
96
+ objectSizeMedium,
97
+ pencil,
98
+ pilcrow,
99
+ quote,
100
+ threeVerticalDots,
101
+ dragIndicator
102
+ };
103
+ import './augmentation';
@@ -1,66 +1,66 @@
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/multicommand
7
- */
8
- import Command from './command';
9
- import { type PriorityString } from '@ckeditor/ckeditor5-utils';
10
- /**
11
- * A CKEditor command that aggregates other commands.
12
- *
13
- * This command is used to proxy multiple commands. The multi-command is enabled when
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.
16
- *
17
- * ```ts
18
- * const multiCommand = new MultiCommand( editor );
19
- *
20
- * const commandFoo = new Command( editor );
21
- * const commandBar = new Command( editor );
22
- *
23
- * // Register a child command.
24
- * multiCommand.registerChildCommand( commandFoo );
25
- * // Register a child command with a low priority.
26
- * multiCommand.registerChildCommand( commandBar, { priority: 'low' } );
27
- *
28
- * // Enable one of the commands.
29
- * commandBar.isEnabled = true;
30
- *
31
- * multiCommand.execute(); // Will execute commandBar.
32
- * ```
33
- */
34
- export default class MultiCommand extends Command {
35
- /**
36
- * Registered child commands definitions.
37
- */
38
- private _childCommandsDefinitions;
39
- /**
40
- * @inheritDoc
41
- */
42
- refresh(): void;
43
- /**
44
- * Executes the first enabled command which has the highest priority of all registered child commands.
45
- *
46
- * @returns The value returned by the {@link module:core/command~Command#execute `command.execute()`}.
47
- */
48
- execute(...args: Array<unknown>): unknown;
49
- /**
50
- * Registers a child command.
51
- *
52
- * @param options An object with configuration options.
53
- * @param options.priority Priority of a command to register.
54
- */
55
- registerChildCommand(command: Command, options?: {
56
- priority?: PriorityString;
57
- }): void;
58
- /**
59
- * Checks if any of child commands is enabled.
60
- */
61
- private _checkEnabled;
62
- /**
63
- * Returns a first enabled command with the highest priority or `undefined` if none of them is enabled.
64
- */
65
- private _getFirstEnabledCommand;
66
- }
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/multicommand
7
+ */
8
+ import Command from './command';
9
+ import { type PriorityString } from '@ckeditor/ckeditor5-utils';
10
+ /**
11
+ * A CKEditor command that aggregates other commands.
12
+ *
13
+ * This command is used to proxy multiple commands. The multi-command is enabled when
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.
16
+ *
17
+ * ```ts
18
+ * const multiCommand = new MultiCommand( editor );
19
+ *
20
+ * const commandFoo = new Command( editor );
21
+ * const commandBar = new Command( editor );
22
+ *
23
+ * // Register a child command.
24
+ * multiCommand.registerChildCommand( commandFoo );
25
+ * // Register a child command with a low priority.
26
+ * multiCommand.registerChildCommand( commandBar, { priority: 'low' } );
27
+ *
28
+ * // Enable one of the commands.
29
+ * commandBar.isEnabled = true;
30
+ *
31
+ * multiCommand.execute(); // Will execute commandBar.
32
+ * ```
33
+ */
34
+ export default class MultiCommand extends Command {
35
+ /**
36
+ * Registered child commands definitions.
37
+ */
38
+ private _childCommandsDefinitions;
39
+ /**
40
+ * @inheritDoc
41
+ */
42
+ refresh(): void;
43
+ /**
44
+ * Executes the first enabled command which has the highest priority of all registered child commands.
45
+ *
46
+ * @returns The value returned by the {@link module:core/command~Command#execute `command.execute()`}.
47
+ */
48
+ execute(...args: Array<unknown>): unknown;
49
+ /**
50
+ * Registers a child command.
51
+ *
52
+ * @param options An object with configuration options.
53
+ * @param options.priority Priority of a command to register.
54
+ */
55
+ registerChildCommand(command: Command, options?: {
56
+ priority?: PriorityString;
57
+ }): void;
58
+ /**
59
+ * Checks if any of child commands is enabled.
60
+ */
61
+ private _checkEnabled;
62
+ /**
63
+ * Returns a first enabled command with the highest priority or `undefined` if none of them is enabled.
64
+ */
65
+ private _getFirstEnabledCommand;
66
+ }
@@ -1,82 +1,82 @@
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/multicommand
7
- */
8
- import Command from './command';
9
- import { insertToPriorityArray } from '@ckeditor/ckeditor5-utils';
10
- /**
11
- * A CKEditor command that aggregates other commands.
12
- *
13
- * This command is used to proxy multiple commands. The multi-command is enabled when
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.
16
- *
17
- * ```ts
18
- * const multiCommand = new MultiCommand( editor );
19
- *
20
- * const commandFoo = new Command( editor );
21
- * const commandBar = new Command( editor );
22
- *
23
- * // Register a child command.
24
- * multiCommand.registerChildCommand( commandFoo );
25
- * // Register a child command with a low priority.
26
- * multiCommand.registerChildCommand( commandBar, { priority: 'low' } );
27
- *
28
- * // Enable one of the commands.
29
- * commandBar.isEnabled = true;
30
- *
31
- * multiCommand.execute(); // Will execute commandBar.
32
- * ```
33
- */
34
- export default class MultiCommand extends Command {
35
- constructor() {
36
- super(...arguments);
37
- /**
38
- * Registered child commands definitions.
39
- */
40
- this._childCommandsDefinitions = [];
41
- }
42
- /**
43
- * @inheritDoc
44
- */
45
- refresh() {
46
- // Override base command refresh(): the command's state is changed when one of child commands changes states.
47
- }
48
- /**
49
- * Executes the first enabled command which has the highest priority of all registered child commands.
50
- *
51
- * @returns The value returned by the {@link module:core/command~Command#execute `command.execute()`}.
52
- */
53
- execute(...args) {
54
- const command = this._getFirstEnabledCommand();
55
- return !!command && command.execute(args);
56
- }
57
- /**
58
- * Registers a child command.
59
- *
60
- * @param options An object with configuration options.
61
- * @param options.priority Priority of a command to register.
62
- */
63
- registerChildCommand(command, options = {}) {
64
- insertToPriorityArray(this._childCommandsDefinitions, { command, priority: options.priority || 'normal' });
65
- // Change multi-command enabled state when one of registered commands changes state.
66
- command.on('change:isEnabled', () => this._checkEnabled());
67
- this._checkEnabled();
68
- }
69
- /**
70
- * Checks if any of child commands is enabled.
71
- */
72
- _checkEnabled() {
73
- this.isEnabled = !!this._getFirstEnabledCommand();
74
- }
75
- /**
76
- * Returns a first enabled command with the highest priority or `undefined` if none of them is enabled.
77
- */
78
- _getFirstEnabledCommand() {
79
- const commandDefinition = this._childCommandsDefinitions.find(({ command }) => command.isEnabled);
80
- return commandDefinition && commandDefinition.command;
81
- }
82
- }
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/multicommand
7
+ */
8
+ import Command from './command';
9
+ import { insertToPriorityArray } from '@ckeditor/ckeditor5-utils';
10
+ /**
11
+ * A CKEditor command that aggregates other commands.
12
+ *
13
+ * This command is used to proxy multiple commands. The multi-command is enabled when
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.
16
+ *
17
+ * ```ts
18
+ * const multiCommand = new MultiCommand( editor );
19
+ *
20
+ * const commandFoo = new Command( editor );
21
+ * const commandBar = new Command( editor );
22
+ *
23
+ * // Register a child command.
24
+ * multiCommand.registerChildCommand( commandFoo );
25
+ * // Register a child command with a low priority.
26
+ * multiCommand.registerChildCommand( commandBar, { priority: 'low' } );
27
+ *
28
+ * // Enable one of the commands.
29
+ * commandBar.isEnabled = true;
30
+ *
31
+ * multiCommand.execute(); // Will execute commandBar.
32
+ * ```
33
+ */
34
+ export default class MultiCommand extends Command {
35
+ constructor() {
36
+ super(...arguments);
37
+ /**
38
+ * Registered child commands definitions.
39
+ */
40
+ this._childCommandsDefinitions = [];
41
+ }
42
+ /**
43
+ * @inheritDoc
44
+ */
45
+ refresh() {
46
+ // Override base command refresh(): the command's state is changed when one of child commands changes states.
47
+ }
48
+ /**
49
+ * Executes the first enabled command which has the highest priority of all registered child commands.
50
+ *
51
+ * @returns The value returned by the {@link module:core/command~Command#execute `command.execute()`}.
52
+ */
53
+ execute(...args) {
54
+ const command = this._getFirstEnabledCommand();
55
+ return !!command && command.execute(args);
56
+ }
57
+ /**
58
+ * Registers a child command.
59
+ *
60
+ * @param options An object with configuration options.
61
+ * @param options.priority Priority of a command to register.
62
+ */
63
+ registerChildCommand(command, options = {}) {
64
+ insertToPriorityArray(this._childCommandsDefinitions, { command, priority: options.priority || 'normal' });
65
+ // Change multi-command enabled state when one of registered commands changes state.
66
+ command.on('change:isEnabled', () => this._checkEnabled());
67
+ this._checkEnabled();
68
+ }
69
+ /**
70
+ * Checks if any of child commands is enabled.
71
+ */
72
+ _checkEnabled() {
73
+ this.isEnabled = !!this._getFirstEnabledCommand();
74
+ }
75
+ /**
76
+ * Returns a first enabled command with the highest priority or `undefined` if none of them is enabled.
77
+ */
78
+ _getFirstEnabledCommand() {
79
+ const commandDefinition = this._childCommandsDefinitions.find(({ command }) => command.isEnabled);
80
+ return commandDefinition && commandDefinition.command;
81
+ }
82
+ }