@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
@@ -1,83 +1,83 @@
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/commandcollection
7
- */
8
- import { CKEditorError } from '@ckeditor/ckeditor5-utils';
9
- /**
10
- * Collection of commands. Its instance is available in {@link module:core/editor/editor~Editor#commands `editor.commands`}.
11
- */
12
- export default class CommandCollection {
13
- /**
14
- * Creates collection instance.
15
- */
16
- constructor() {
17
- this._commands = new Map();
18
- }
19
- /**
20
- * Registers a new command.
21
- *
22
- * @param commandName The name of the command.
23
- */
24
- add(commandName, command) {
25
- this._commands.set(commandName, command);
26
- }
27
- /**
28
- * Retrieves a command from the collection.
29
- *
30
- * @param commandName The name of the command.
31
- */
32
- get(commandName) {
33
- return this._commands.get(commandName);
34
- }
35
- /**
36
- * Executes a command.
37
- *
38
- * @param commandName The name of the command.
39
- * @param commandParams Command parameters.
40
- * @returns The value returned by the {@link module:core/command~Command#execute `command.execute()`}.
41
- */
42
- execute(commandName, ...commandParams) {
43
- const command = this.get(commandName);
44
- if (!command) {
45
- /**
46
- * Command does not exist.
47
- *
48
- * @error commandcollection-command-not-found
49
- * @param commandName Name of the command.
50
- */
51
- throw new CKEditorError('commandcollection-command-not-found', this, { commandName });
52
- }
53
- return command.execute(...commandParams);
54
- }
55
- /**
56
- * Returns iterator of command names.
57
- */
58
- *names() {
59
- yield* this._commands.keys();
60
- }
61
- /**
62
- * Returns iterator of command instances.
63
- */
64
- *commands() {
65
- yield* this._commands.values();
66
- }
67
- /**
68
- * Iterable interface.
69
- *
70
- * Returns `[ commandName, commandInstance ]` pairs.
71
- */
72
- [Symbol.iterator]() {
73
- return this._commands[Symbol.iterator]();
74
- }
75
- /**
76
- * Destroys all collection commands.
77
- */
78
- destroy() {
79
- for (const command of this.commands()) {
80
- command.destroy();
81
- }
82
- }
83
- }
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/commandcollection
7
+ */
8
+ import { CKEditorError } from '@ckeditor/ckeditor5-utils';
9
+ /**
10
+ * Collection of commands. Its instance is available in {@link module:core/editor/editor~Editor#commands `editor.commands`}.
11
+ */
12
+ export default class CommandCollection {
13
+ /**
14
+ * Creates collection instance.
15
+ */
16
+ constructor() {
17
+ this._commands = new Map();
18
+ }
19
+ /**
20
+ * Registers a new command.
21
+ *
22
+ * @param commandName The name of the command.
23
+ */
24
+ add(commandName, command) {
25
+ this._commands.set(commandName, command);
26
+ }
27
+ /**
28
+ * Retrieves a command from the collection.
29
+ *
30
+ * @param commandName The name of the command.
31
+ */
32
+ get(commandName) {
33
+ return this._commands.get(commandName);
34
+ }
35
+ /**
36
+ * Executes a command.
37
+ *
38
+ * @param commandName The name of the command.
39
+ * @param commandParams Command parameters.
40
+ * @returns The value returned by the {@link module:core/command~Command#execute `command.execute()`}.
41
+ */
42
+ execute(commandName, ...commandParams) {
43
+ const command = this.get(commandName);
44
+ if (!command) {
45
+ /**
46
+ * Command does not exist.
47
+ *
48
+ * @error commandcollection-command-not-found
49
+ * @param commandName Name of the command.
50
+ */
51
+ throw new CKEditorError('commandcollection-command-not-found', this, { commandName });
52
+ }
53
+ return command.execute(...commandParams);
54
+ }
55
+ /**
56
+ * Returns iterator of command names.
57
+ */
58
+ *names() {
59
+ yield* this._commands.keys();
60
+ }
61
+ /**
62
+ * Returns iterator of command instances.
63
+ */
64
+ *commands() {
65
+ yield* this._commands.values();
66
+ }
67
+ /**
68
+ * Iterable interface.
69
+ *
70
+ * Returns `[ commandName, commandInstance ]` pairs.
71
+ */
72
+ [Symbol.iterator]() {
73
+ return this._commands[Symbol.iterator]();
74
+ }
75
+ /**
76
+ * Destroys all collection commands.
77
+ */
78
+ destroy() {
79
+ for (const command of this.commands()) {
80
+ command.destroy();
81
+ }
82
+ }
83
+ }
package/src/context.d.ts CHANGED
@@ -1,237 +1,237 @@
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/context
7
- */
8
- import { Config, Collection, Locale, type LocaleTranslate } from '@ckeditor/ckeditor5-utils';
9
- import PluginCollection from './plugincollection';
10
- import type Editor from './editor/editor';
11
- import type { LoadedPlugins, PluginConstructor } from './plugin';
12
- import type { EditorConfig } from './editor/editorconfig';
13
- /**
14
- * Provides a common, higher-level environment for solutions that use multiple {@link module:core/editor/editor~Editor editors}
15
- * or plugins that work outside the editor. Use it instead of {@link module:core/editor/editor~Editor.create `Editor.create()`}
16
- * in advanced application integrations.
17
- *
18
- * All configuration options passed to a context will be used as default options for the editor instances initialized in that context.
19
- *
20
- * {@link module:core/contextplugin~ContextPlugin Context plugins} passed to a context instance will be shared among all
21
- * editor instances initialized in this context. These will be the same plugin instances for all the editors.
22
- *
23
- * **Note:** The context can only be initialized with {@link module:core/contextplugin~ContextPlugin context plugins}
24
- * (e.g. [comments](https://ckeditor.com/collaboration/comments/)). Regular {@link module:core/plugin~Plugin plugins} require an
25
- * editor instance to work and cannot be added to a context.
26
- *
27
- * **Note:** You can add a context plugin to an editor instance, though.
28
- *
29
- * If you are using multiple editor instances on one page and use any context plugins, create a context to share the configuration and
30
- * plugins among these editors. Some plugins will use the information about all existing editors to better integrate between them.
31
- *
32
- * If you are using plugins that do not require an editor to work (e.g. [comments](https://ckeditor.com/collaboration/comments/)),
33
- * enable and configure them using the context.
34
- *
35
- * 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 a case, a context instance will be created by the editor instance in a transparent way.
37
- *
38
- * See {@link ~Context.create `Context.create()`} for usage examples.
39
- */
40
- export default class Context {
41
- /**
42
- * Stores all the configurations specific to this context instance.
43
- */
44
- readonly config: Config<ContextConfig>;
45
- /**
46
- * The plugins loaded and in use by this context instance.
47
- */
48
- readonly plugins: PluginCollection<Context | Editor>;
49
- readonly locale: Locale;
50
- /**
51
- * Shorthand for {@link module:utils/locale~Locale#t}.
52
- */
53
- readonly t: LocaleTranslate;
54
- /**
55
- * A list of editors that this context instance is injected to.
56
- */
57
- readonly editors: Collection<Editor>;
58
- /**
59
- * The default configuration which is built into the `Context` class.
60
- *
61
- * It is used in CKEditor 5 builds featuring `Context` to provide the default configuration options which are later used during the
62
- * context initialization.
63
- *
64
- * ```ts
65
- * Context.defaultConfig = {
66
- * foo: 1,
67
- * bar: 2
68
- * };
69
- *
70
- * Context
71
- * .create()
72
- * .then( context => {
73
- * context.config.get( 'foo' ); // -> 1
74
- * context.config.get( 'bar' ); // -> 2
75
- * } );
76
- *
77
- * // The default options can be overridden by the configuration passed to create().
78
- * Context
79
- * .create( { bar: 3 } )
80
- * .then( context => {
81
- * context.config.get( 'foo' ); // -> 1
82
- * context.config.get( 'bar' ); // -> 3
83
- * } );
84
- * ```
85
- *
86
- * See also {@link module:core/context~Context.builtinPlugins `Context.builtinPlugins`}
87
- * and {@link module:core/editor/editor~Editor.defaultConfig `Editor.defaultConfig`}.
88
- */
89
- static defaultConfig: ContextConfig;
90
- /**
91
- * An array of plugins built into the `Context` class.
92
- *
93
- * It is used in CKEditor 5 builds featuring `Context` to provide a list of context plugins which are later automatically initialized
94
- * during the context initialization.
95
- *
96
- * They will be automatically initialized by `Context` unless `config.plugins` is passed.
97
- *
98
- * ```ts
99
- * // Build some context plugins into the Context class first.
100
- * Context.builtinPlugins = [ FooPlugin, BarPlugin ];
101
- *
102
- * // Normally, you need to define config.plugins, but since Context.builtinPlugins was
103
- * // defined, now you can call create() without any configuration.
104
- * Context
105
- * .create()
106
- * .then( context => {
107
- * context.plugins.get( FooPlugin ); // -> An instance of the Foo plugin.
108
- * context.plugins.get( BarPlugin ); // -> An instance of the Bar plugin.
109
- * } );
110
- * ```
111
- *
112
- * See also {@link module:core/context~Context.defaultConfig `Context.defaultConfig`}
113
- * and {@link module:core/editor/editor~Editor.builtinPlugins `Editor.builtinPlugins`}.
114
- */
115
- static builtinPlugins: Array<PluginConstructor<Context | Editor>>;
116
- /**
117
- * Reference to the editor which created the context.
118
- * Null when the context was created outside of the editor.
119
- *
120
- * It is used to destroy the context when removing the editor that has created the context.
121
- */
122
- private _contextOwner;
123
- /**
124
- * Creates a context instance with a given configuration.
125
- *
126
- * Usually not to be used directly. See the static {@link module:core/context~Context.create `create()`} method.
127
- *
128
- * @param config The context configuration.
129
- */
130
- constructor(config?: ContextConfig);
131
- /**
132
- * Loads and initializes plugins specified in the configuration.
133
- *
134
- * @returns A promise which resolves once the initialization is completed, providing an array of loaded plugins.
135
- */
136
- initPlugins(): Promise<LoadedPlugins>;
137
- /**
138
- * Destroys the context instance and all editors used with the context,
139
- * releasing all resources used by the context.
140
- *
141
- * @returns A promise that resolves once the context instance is fully destroyed.
142
- */
143
- destroy(): Promise<unknown>;
144
- /**
145
- * Adds a reference to the editor which is used with this context.
146
- *
147
- * When the given editor has created the context, the reference to this editor will be stored
148
- * as a {@link ~Context#_contextOwner}.
149
- *
150
- * This method should only be used by the editor.
151
- *
152
- * @internal
153
- * @param isContextOwner Stores the given editor as a context owner.
154
- */
155
- _addEditor(editor: Editor, isContextOwner: boolean): void;
156
- /**
157
- * Removes a reference to the editor which was used with this context.
158
- * When the context was created by the given editor, the context will be destroyed.
159
- *
160
- * This method should only be used by the editor.
161
- *
162
- * @internal
163
- * @return A promise that resolves once the editor is removed from the context or when the context was destroyed.
164
- */
165
- _removeEditor(editor: Editor): Promise<unknown>;
166
- /**
167
- * Returns the context configuration which will be copied to the editors created using this context.
168
- *
169
- * The configuration returned by this method has the plugins configuration removed &mdash; plugins are shared with all editors
170
- * through another mechanism.
171
- *
172
- * This method should only be used by the editor.
173
- *
174
- * @internal
175
- * @returns Configuration as a plain object.
176
- */
177
- _getEditorConfig(): Partial<EditorConfig>;
178
- /**
179
- * Creates and initializes a new context instance.
180
- *
181
- * ```ts
182
- * const commonConfig = { ... }; // Configuration for all the plugins and editors.
183
- * const editorPlugins = [ ... ]; // Regular plugins here.
184
- *
185
- * Context
186
- * .create( {
187
- * // Only context plugins here.
188
- * plugins: [ ... ],
189
- *
190
- * // Configure the language for all the editors (it cannot be overwritten).
191
- * language: { ... },
192
- *
193
- * // Configuration for context plugins.
194
- * comments: { ... },
195
- * ...
196
- *
197
- * // Default configuration for editor plugins.
198
- * toolbar: { ... },
199
- * image: { ... },
200
- * ...
201
- * } )
202
- * .then( context => {
203
- * const promises = [];
204
- *
205
- * promises.push( ClassicEditor.create(
206
- * document.getElementById( 'editor1' ),
207
- * {
208
- * editorPlugins,
209
- * context
210
- * }
211
- * ) );
212
- *
213
- * promises.push( ClassicEditor.create(
214
- * document.getElementById( 'editor2' ),
215
- * {
216
- * editorPlugins,
217
- * context,
218
- * toolbar: { ... } // You can overwrite the configuration of the context.
219
- * }
220
- * ) );
221
- *
222
- * return Promise.all( promises );
223
- * } );
224
- * ```
225
- *
226
- * @param config The context configuration.
227
- * @returns A promise resolved once the context is ready. The promise resolves with the created context instance.
228
- */
229
- static create(config?: ContextConfig): Promise<Context>;
230
- }
231
- /**
232
- * The context configuration.
233
- */
234
- export type ContextConfig = {
235
- plugins?: Array<PluginConstructor<Context | Editor>>;
236
- substitutePlugins?: Array<PluginConstructor<Context | Editor>>;
237
- } & Omit<EditorConfig, 'plugins' | 'substitutePlugins' | 'removePlugins' | 'extraPlugins'>;
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/context
7
+ */
8
+ import { Config, Collection, Locale, type LocaleTranslate } from '@ckeditor/ckeditor5-utils';
9
+ import PluginCollection from './plugincollection';
10
+ import type Editor from './editor/editor';
11
+ import type { LoadedPlugins, PluginConstructor } from './plugin';
12
+ import type { EditorConfig } from './editor/editorconfig';
13
+ /**
14
+ * Provides a common, higher-level environment for solutions that use multiple {@link module:core/editor/editor~Editor editors}
15
+ * or plugins that work outside the editor. Use it instead of {@link module:core/editor/editor~Editor.create `Editor.create()`}
16
+ * in advanced application integrations.
17
+ *
18
+ * All configuration options passed to a context will be used as default options for the editor instances initialized in that context.
19
+ *
20
+ * {@link module:core/contextplugin~ContextPlugin Context plugins} passed to a context instance will be shared among all
21
+ * editor instances initialized in this context. These will be the same plugin instances for all the editors.
22
+ *
23
+ * **Note:** The context can only be initialized with {@link module:core/contextplugin~ContextPlugin context plugins}
24
+ * (e.g. [comments](https://ckeditor.com/collaboration/comments/)). Regular {@link module:core/plugin~Plugin plugins} require an
25
+ * editor instance to work and cannot be added to a context.
26
+ *
27
+ * **Note:** You can add a context plugin to an editor instance, though.
28
+ *
29
+ * If you are using multiple editor instances on one page and use any context plugins, create a context to share the configuration and
30
+ * plugins among these editors. Some plugins will use the information about all existing editors to better integrate between them.
31
+ *
32
+ * If you are using plugins that do not require an editor to work (e.g. [comments](https://ckeditor.com/collaboration/comments/)),
33
+ * enable and configure them using the context.
34
+ *
35
+ * 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 a case, a context instance will be created by the editor instance in a transparent way.
37
+ *
38
+ * See {@link ~Context.create `Context.create()`} for usage examples.
39
+ */
40
+ export default class Context {
41
+ /**
42
+ * Stores all the configurations specific to this context instance.
43
+ */
44
+ readonly config: Config<ContextConfig>;
45
+ /**
46
+ * The plugins loaded and in use by this context instance.
47
+ */
48
+ readonly plugins: PluginCollection<Context | Editor>;
49
+ readonly locale: Locale;
50
+ /**
51
+ * Shorthand for {@link module:utils/locale~Locale#t}.
52
+ */
53
+ readonly t: LocaleTranslate;
54
+ /**
55
+ * A list of editors that this context instance is injected to.
56
+ */
57
+ readonly editors: Collection<Editor>;
58
+ /**
59
+ * The default configuration which is built into the `Context` class.
60
+ *
61
+ * It is used in CKEditor 5 builds featuring `Context` to provide the default configuration options which are later used during the
62
+ * context initialization.
63
+ *
64
+ * ```ts
65
+ * Context.defaultConfig = {
66
+ * foo: 1,
67
+ * bar: 2
68
+ * };
69
+ *
70
+ * Context
71
+ * .create()
72
+ * .then( context => {
73
+ * context.config.get( 'foo' ); // -> 1
74
+ * context.config.get( 'bar' ); // -> 2
75
+ * } );
76
+ *
77
+ * // The default options can be overridden by the configuration passed to create().
78
+ * Context
79
+ * .create( { bar: 3 } )
80
+ * .then( context => {
81
+ * context.config.get( 'foo' ); // -> 1
82
+ * context.config.get( 'bar' ); // -> 3
83
+ * } );
84
+ * ```
85
+ *
86
+ * See also {@link module:core/context~Context.builtinPlugins `Context.builtinPlugins`}
87
+ * and {@link module:core/editor/editor~Editor.defaultConfig `Editor.defaultConfig`}.
88
+ */
89
+ static defaultConfig: ContextConfig;
90
+ /**
91
+ * An array of plugins built into the `Context` class.
92
+ *
93
+ * It is used in CKEditor 5 builds featuring `Context` to provide a list of context plugins which are later automatically initialized
94
+ * during the context initialization.
95
+ *
96
+ * They will be automatically initialized by `Context` unless `config.plugins` is passed.
97
+ *
98
+ * ```ts
99
+ * // Build some context plugins into the Context class first.
100
+ * Context.builtinPlugins = [ FooPlugin, BarPlugin ];
101
+ *
102
+ * // Normally, you need to define config.plugins, but since Context.builtinPlugins was
103
+ * // defined, now you can call create() without any configuration.
104
+ * Context
105
+ * .create()
106
+ * .then( context => {
107
+ * context.plugins.get( FooPlugin ); // -> An instance of the Foo plugin.
108
+ * context.plugins.get( BarPlugin ); // -> An instance of the Bar plugin.
109
+ * } );
110
+ * ```
111
+ *
112
+ * See also {@link module:core/context~Context.defaultConfig `Context.defaultConfig`}
113
+ * and {@link module:core/editor/editor~Editor.builtinPlugins `Editor.builtinPlugins`}.
114
+ */
115
+ static builtinPlugins: Array<PluginConstructor<Context | Editor>>;
116
+ /**
117
+ * Reference to the editor which created the context.
118
+ * Null when the context was created outside of the editor.
119
+ *
120
+ * It is used to destroy the context when removing the editor that has created the context.
121
+ */
122
+ private _contextOwner;
123
+ /**
124
+ * Creates a context instance with a given configuration.
125
+ *
126
+ * Usually not to be used directly. See the static {@link module:core/context~Context.create `create()`} method.
127
+ *
128
+ * @param config The context configuration.
129
+ */
130
+ constructor(config?: ContextConfig);
131
+ /**
132
+ * Loads and initializes plugins specified in the configuration.
133
+ *
134
+ * @returns A promise which resolves once the initialization is completed, providing an array of loaded plugins.
135
+ */
136
+ initPlugins(): Promise<LoadedPlugins>;
137
+ /**
138
+ * Destroys the context instance and all editors used with the context,
139
+ * releasing all resources used by the context.
140
+ *
141
+ * @returns A promise that resolves once the context instance is fully destroyed.
142
+ */
143
+ destroy(): Promise<unknown>;
144
+ /**
145
+ * Adds a reference to the editor which is used with this context.
146
+ *
147
+ * When the given editor has created the context, the reference to this editor will be stored
148
+ * as a {@link ~Context#_contextOwner}.
149
+ *
150
+ * This method should only be used by the editor.
151
+ *
152
+ * @internal
153
+ * @param isContextOwner Stores the given editor as a context owner.
154
+ */
155
+ _addEditor(editor: Editor, isContextOwner: boolean): void;
156
+ /**
157
+ * Removes a reference to the editor which was used with this context.
158
+ * When the context was created by the given editor, the context will be destroyed.
159
+ *
160
+ * This method should only be used by the editor.
161
+ *
162
+ * @internal
163
+ * @return A promise that resolves once the editor is removed from the context or when the context was destroyed.
164
+ */
165
+ _removeEditor(editor: Editor): Promise<unknown>;
166
+ /**
167
+ * Returns the context configuration which will be copied to the editors created using this context.
168
+ *
169
+ * The configuration returned by this method has the plugins configuration removed &ndash; plugins are shared with all editors
170
+ * through another mechanism.
171
+ *
172
+ * This method should only be used by the editor.
173
+ *
174
+ * @internal
175
+ * @returns Configuration as a plain object.
176
+ */
177
+ _getEditorConfig(): Partial<EditorConfig>;
178
+ /**
179
+ * Creates and initializes a new context instance.
180
+ *
181
+ * ```ts
182
+ * const commonConfig = { ... }; // Configuration for all the plugins and editors.
183
+ * const editorPlugins = [ ... ]; // Regular plugins here.
184
+ *
185
+ * Context
186
+ * .create( {
187
+ * // Only context plugins here.
188
+ * plugins: [ ... ],
189
+ *
190
+ * // Configure the language for all the editors (it cannot be overwritten).
191
+ * language: { ... },
192
+ *
193
+ * // Configuration for context plugins.
194
+ * comments: { ... },
195
+ * ...
196
+ *
197
+ * // Default configuration for editor plugins.
198
+ * toolbar: { ... },
199
+ * image: { ... },
200
+ * ...
201
+ * } )
202
+ * .then( context => {
203
+ * const promises = [];
204
+ *
205
+ * promises.push( ClassicEditor.create(
206
+ * document.getElementById( 'editor1' ),
207
+ * {
208
+ * editorPlugins,
209
+ * context
210
+ * }
211
+ * ) );
212
+ *
213
+ * promises.push( ClassicEditor.create(
214
+ * document.getElementById( 'editor2' ),
215
+ * {
216
+ * editorPlugins,
217
+ * context,
218
+ * toolbar: { ... } // You can overwrite the configuration of the context.
219
+ * }
220
+ * ) );
221
+ *
222
+ * return Promise.all( promises );
223
+ * } );
224
+ * ```
225
+ *
226
+ * @param config The context configuration.
227
+ * @returns A promise resolved once the context is ready. The promise resolves with the created context instance.
228
+ */
229
+ static create(config?: ContextConfig): Promise<Context>;
230
+ }
231
+ /**
232
+ * The context configuration.
233
+ */
234
+ export type ContextConfig = {
235
+ plugins?: Array<PluginConstructor<Context | Editor>>;
236
+ substitutePlugins?: Array<PluginConstructor<Context | Editor>>;
237
+ } & Omit<EditorConfig, 'plugins' | 'substitutePlugins' | 'removePlugins' | 'extraPlugins'>;