@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,417 +1,417 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
5
- /**
6
- * @module core/editor/editor
7
- */
8
- import { Config, type Locale, type LocaleTranslate } from '@ckeditor/ckeditor5-utils';
9
- import { Conversion, DataController, EditingController, Model } from '@ckeditor/ckeditor5-engine';
10
- import type { EditorUI } from '@ckeditor/ckeditor5-ui';
11
- import Context from '../context';
12
- import PluginCollection from '../plugincollection';
13
- import CommandCollection, { type CommandsMap } from '../commandcollection';
14
- import EditingKeystrokeHandler from '../editingkeystrokehandler';
15
- import type { LoadedPlugins, PluginConstructor } from '../plugin';
16
- import type { EditorConfig } from './editorconfig';
17
- declare const Editor_base: {
18
- new (): import("@ckeditor/ckeditor5-utils").Observable;
19
- prototype: import("@ckeditor/ckeditor5-utils").Observable;
20
- };
21
- /**
22
- * The class representing a basic, generic editor.
23
- *
24
- * Check out the list of its subclasses to learn about specific editor implementations.
25
- *
26
- * All editor implementations (like {@link module:editor-classic/classiceditor~ClassicEditor} or
27
- * {@link module:editor-inline/inlineeditor~InlineEditor}) should extend this class. They can add their
28
- * own methods and properties.
29
- *
30
- * When you are implementing a plugin, this editor represents the API
31
- * which your plugin can expect to get when using its {@link module:core/plugin~Plugin#editor} property.
32
- *
33
- * This API should be sufficient in order to implement the "editing" part of your feature
34
- * (schema definition, conversion, commands, keystrokes, etc.).
35
- * It does not define the editor UI, which is available only if
36
- * the specific editor implements also the {@link ~Editor#ui} property
37
- * (as most editor implementations do).
38
- */
39
- export default abstract class Editor extends Editor_base {
40
- /**
41
- * Commands registered to the editor.
42
- *
43
- * Use the shorthand {@link #execute `editor.execute()`} method to execute commands:
44
- *
45
- * ```ts
46
- * // Execute the bold command:
47
- * editor.execute( 'bold' );
48
- *
49
- * // Check the state of the bold command:
50
- * editor.commands.get( 'bold' ).value;
51
- * ```
52
- */
53
- readonly commands: CommandCollection;
54
- /**
55
- * Stores all configurations specific to this editor instance.
56
- *
57
- * ```ts
58
- * editor.config.get( 'image.toolbar' );
59
- * // -> [ 'imageStyle:block', 'imageStyle:side', '|', 'toggleImageCaption', 'imageTextAlternative' ]
60
- * ```
61
- */
62
- readonly config: Config<EditorConfig>;
63
- /**
64
- * Conversion manager through which you can register model-to-view and view-to-model converters.
65
- *
66
- * See the {@link module:engine/conversion/conversion~Conversion} documentation to learn how to add converters.
67
- */
68
- readonly conversion: Conversion;
69
- /**
70
- * The {@link module:engine/controller/datacontroller~DataController data controller}.
71
- * Used e.g. for setting and retrieving the editor data.
72
- */
73
- readonly data: DataController;
74
- /**
75
- * The {@link module:engine/controller/editingcontroller~EditingController editing controller}.
76
- * Controls user input and rendering the content for editing.
77
- */
78
- readonly editing: EditingController;
79
- /**
80
- * The locale instance.
81
- */
82
- readonly locale: Locale;
83
- /**
84
- * The editor's model.
85
- *
86
- * The central point of the editor's abstract data model.
87
- */
88
- readonly model: Model;
89
- /**
90
- * The plugins loaded and in use by this editor instance.
91
- *
92
- * ```ts
93
- * editor.plugins.get( 'ClipboardPipeline' ); // -> An instance of the clipboard pipeline plugin.
94
- * ```
95
- */
96
- readonly plugins: PluginCollection<Editor>;
97
- /**
98
- * An instance of the {@link module:core/editingkeystrokehandler~EditingKeystrokeHandler}.
99
- *
100
- * It allows setting simple keystrokes:
101
- *
102
- * ```ts
103
- * // Execute the bold command on Ctrl+E:
104
- * editor.keystrokes.set( 'Ctrl+E', 'bold' );
105
- *
106
- * // Execute your own callback:
107
- * editor.keystrokes.set( 'Ctrl+E', ( data, cancel ) => {
108
- * console.log( data.keyCode );
109
- *
110
- * // Prevent the default (native) action and stop the underlying keydown event
111
- * // so no other editor feature will interfere.
112
- * cancel();
113
- * } );
114
- * ```
115
- *
116
- * Note: Certain typing-oriented keystrokes (like <kbd>Backspace</kbd> or <kbd>Enter</kbd>) are handled
117
- * by a low-level mechanism and trying to listen to them via the keystroke handler will not work reliably.
118
- * To handle these specific keystrokes, see the events fired by the
119
- * {@link module:engine/view/document~Document editing view document} (`editor.editing.view.document`).
120
- */
121
- readonly keystrokes: EditingKeystrokeHandler;
122
- /**
123
- * Shorthand for {@link module:utils/locale~Locale#t}.
124
- *
125
- * @see module:utils/locale~Locale#t
126
- */
127
- readonly t: LocaleTranslate;
128
- readonly id: string;
129
- /**
130
- * Indicates the editor life-cycle state.
131
- *
132
- * The editor is in one of the following states:
133
- *
134
- * * `initializing` &ndash; During the editor initialization (before
135
- * {@link module:core/editor/editor~Editor.create `Editor.create()`}) finished its job.
136
- * * `ready` &ndash; After the promise returned by the {@link module:core/editor/editor~Editor.create `Editor.create()`}
137
- * method is resolved.
138
- * * `destroyed` &ndash; Once the {@link #destroy `editor.destroy()`} method was called.
139
- *
140
- * @observable
141
- */
142
- state: 'initializing' | 'ready' | 'destroyed';
143
- /**
144
- * The default configuration which is built into the editor class.
145
- *
146
- * It is used in CKEditor 5 builds to provide the default configuration options which are later used during the editor initialization.
147
- *
148
- * ```ts
149
- * ClassicEditor.defaultConfig = {
150
- * foo: 1,
151
- * bar: 2
152
- * };
153
- *
154
- * ClassicEditor
155
- * .create( sourceElement )
156
- * .then( editor => {
157
- * editor.config.get( 'foo' ); // -> 1
158
- * editor.config.get( 'bar' ); // -> 2
159
- * } );
160
- *
161
- * // The default options can be overridden by the configuration passed to create().
162
- * ClassicEditor
163
- * .create( sourceElement, { bar: 3 } )
164
- * .then( editor => {
165
- * editor.config.get( 'foo' ); // -> 1
166
- * editor.config.get( 'bar' ); // -> 3
167
- * } );
168
- * ```
169
- *
170
- * See also {@link module:core/editor/editor~Editor.builtinPlugins}.
171
- */
172
- static defaultConfig?: EditorConfig;
173
- /**
174
- * An array of plugins built into this editor class.
175
- *
176
- * It is used in CKEditor 5 builds to provide a list of plugins which are later automatically initialized
177
- * during the editor initialization.
178
- *
179
- * They will be automatically initialized by the editor, unless listed in `config.removePlugins` and
180
- * unless `config.plugins` is passed.
181
- *
182
- * ```ts
183
- * // Build some plugins into the editor class first.
184
- * ClassicEditor.builtinPlugins = [ FooPlugin, BarPlugin ];
185
- *
186
- * // Normally, you need to define config.plugins, but since ClassicEditor.builtinPlugins was
187
- * // defined, now you can call create() without any configuration.
188
- * ClassicEditor
189
- * .create( sourceElement )
190
- * .then( editor => {
191
- * editor.plugins.get( FooPlugin ); // -> An instance of the Foo plugin.
192
- * editor.plugins.get( BarPlugin ); // -> An instance of the Bar plugin.
193
- * } );
194
- *
195
- * ClassicEditor
196
- * .create( sourceElement, {
197
- * // Do not initialize these plugins (note: it is defined by a string):
198
- * removePlugins: [ 'Foo' ]
199
- * } )
200
- * .then( editor => {
201
- * editor.plugins.get( FooPlugin ); // -> Undefined.
202
- * editor.config.get( BarPlugin ); // -> An instance of the Bar plugin.
203
- * } );
204
- *
205
- * ClassicEditor
206
- * .create( sourceElement, {
207
- * // Load only this plugin. It can also be defined by a string if
208
- * // this plugin was built into the editor class.
209
- * plugins: [ FooPlugin ]
210
- * } )
211
- * .then( editor => {
212
- * editor.plugins.get( FooPlugin ); // -> An instance of the Foo plugin.
213
- * editor.config.get( BarPlugin ); // -> Undefined.
214
- * } );
215
- * ```
216
- *
217
- * See also {@link module:core/editor/editor~Editor.defaultConfig}.
218
- */
219
- static builtinPlugins?: Array<PluginConstructor<Editor>>;
220
- /**
221
- * The editor UI instance.
222
- */
223
- abstract get ui(): EditorUI;
224
- /**
225
- * The editor context.
226
- * When it is not provided through the configuration, the editor creates it.
227
- */
228
- protected readonly _context: Context;
229
- /**
230
- * A set of lock IDs for the {@link #isReadOnly} getter.
231
- */
232
- protected readonly _readOnlyLocks: Set<symbol | string>;
233
- /**
234
- * Creates a new instance of the editor class.
235
- *
236
- * Usually, not to be used directly. See the static {@link module:core/editor/editor~Editor.create `create()`} method.
237
- *
238
- * @param config The editor configuration.
239
- */
240
- constructor(config?: EditorConfig);
241
- /**
242
- * Defines whether the editor is in the read-only mode.
243
- *
244
- * In read-only mode the editor {@link #commands commands} are disabled so it is not possible
245
- * to modify the document by using them. Also, the editable element(s) become non-editable.
246
- *
247
- * In order to make the editor read-only, you need to call the {@link #enableReadOnlyMode} method:
248
- *
249
- * ```ts
250
- * editor.enableReadOnlyMode( 'feature-id' );
251
- * ```
252
- *
253
- * Later, to turn off the read-only mode, call {@link #disableReadOnlyMode}:
254
- *
255
- * ```ts
256
- * editor.disableReadOnlyMode( 'feature-id' );
257
- * ```
258
- *
259
- * @readonly
260
- * @observable
261
- */
262
- get isReadOnly(): boolean;
263
- set isReadOnly(value: boolean);
264
- /**
265
- * Turns on the read-only mode in the editor.
266
- *
267
- * Editor can be switched to or out of the read-only mode by many features, under various circumstances. The editor supports locking
268
- * mechanism for the read-only mode. It enables easy control over the read-only mode when many features wants to turn it on or off at
269
- * the same time, without conflicting with each other. It guarantees that you will not make the editor editable accidentally (which
270
- * could lead to errors).
271
- *
272
- * Each read-only mode request is identified by a unique id (also called "lock"). If multiple plugins requested to turn on the
273
- * read-only mode, then, the editor will become editable only after all these plugins turn the read-only mode off (using the same ids).
274
- *
275
- * Note, that you cannot force the editor to disable the read-only mode if other plugins set it.
276
- *
277
- * After the first `enableReadOnlyMode()` call, the {@link #isReadOnly `isReadOnly` property} will be set to `true`:
278
- *
279
- * ```ts
280
- * editor.isReadOnly; // `false`.
281
- * editor.enableReadOnlyMode( 'my-feature-id' );
282
- * editor.isReadOnly; // `true`.
283
- * ```
284
- *
285
- * You can turn off the read-only mode ("clear the lock") using the {@link #disableReadOnlyMode `disableReadOnlyMode()`} method:
286
- *
287
- * ```ts
288
- * editor.enableReadOnlyMode( 'my-feature-id' );
289
- * // ...
290
- * editor.disableReadOnlyMode( 'my-feature-id' );
291
- * editor.isReadOnly; // `false`.
292
- * ```
293
- *
294
- * All "locks" need to be removed to enable editing:
295
- *
296
- * ```ts
297
- * editor.enableReadOnlyMode( 'my-feature-id' );
298
- * editor.enableReadOnlyMode( 'my-other-feature-id' );
299
- * // ...
300
- * editor.disableReadOnlyMode( 'my-feature-id' );
301
- * editor.isReadOnly; // `true`.
302
- * editor.disableReadOnlyMode( 'my-other-feature-id' );
303
- * editor.isReadOnly; // `false`.
304
- * ```
305
- *
306
- * @param lockId A unique ID for setting the editor to the read-only state.
307
- */
308
- enableReadOnlyMode(lockId: string | symbol): void;
309
- /**
310
- * Removes the read-only lock from the editor with given lock ID.
311
- *
312
- * When no lock is present on the editor anymore, then the {@link #isReadOnly `isReadOnly` property} will be set to `false`.
313
- *
314
- * @param lockId The lock ID for setting the editor to the read-only state.
315
- */
316
- disableReadOnlyMode(lockId: string | symbol): void;
317
- /**
318
- * Loads and initializes plugins specified in the configuration.
319
- *
320
- * @returns A promise which resolves once the initialization is completed, providing an array of loaded plugins.
321
- */
322
- initPlugins(): Promise<LoadedPlugins>;
323
- /**
324
- * Destroys the editor instance, releasing all resources used by it.
325
- *
326
- * **Note** The editor cannot be destroyed during the initialization phase so if it is called
327
- * while the editor {@link #state is being initialized}, it will wait for the editor initialization before destroying it.
328
- *
329
- * @fires destroy
330
- * @returns A promise that resolves once the editor instance is fully destroyed.
331
- */
332
- destroy(): Promise<unknown>;
333
- /**
334
- * Executes the specified command with given parameters.
335
- *
336
- * Shorthand for:
337
- *
338
- * ```ts
339
- * editor.commands.get( commandName ).execute( ... );
340
- * ```
341
- *
342
- * @param commandName The name of the command to execute.
343
- * @param commandParams Command parameters.
344
- * @returns The value returned by the {@link module:core/commandcollection~CommandCollection#execute `commands.execute()`}.
345
- */
346
- execute<TName extends string>(commandName: TName, ...commandParams: Parameters<CommandsMap[TName]['execute']>): ReturnType<CommandsMap[TName]['execute']>;
347
- /**
348
- * Focuses the editor.
349
- *
350
- * **Note** To explicitly focus the editing area of the editor, use the
351
- * {@link module:engine/view/view~View#focus `editor.editing.view.focus()`} method of the editing view.
352
- *
353
- * Check out the {@glink framework/deep-dive/ui/focus-tracking#focus-in-the-editor-ui Focus in the editor UI} section
354
- * of the {@glink framework/deep-dive/ui/focus-tracking Deep dive into focus tracking} guide to learn more.
355
- */
356
- focus(): void;
357
- /**
358
- * Creates and initializes a new editor instance.
359
- *
360
- * This is an abstract method. Every editor type needs to implement its own initialization logic.
361
- *
362
- * See the `create()` methods of the existing editor types to learn how to use them:
363
- *
364
- * * {@link module:editor-classic/classiceditor~ClassicEditor.create `ClassicEditor.create()`}
365
- * * {@link module:editor-balloon/ballooneditor~BalloonEditor.create `BalloonEditor.create()`}
366
- * * {@link module:editor-decoupled/decouplededitor~DecoupledEditor.create `DecoupledEditor.create()`}
367
- * * {@link module:editor-inline/inlineeditor~InlineEditor.create `InlineEditor.create()`}
368
- */
369
- static create(...args: Array<unknown>): void;
370
- }
371
- /**
372
- * Fired when the {@link module:engine/controller/datacontroller~DataController#event:ready data} and all additional
373
- * editor components are ready.
374
- *
375
- * Note: This event is most useful for plugin developers. When integrating the editor with your website or
376
- * application, you do not have to listen to `editor#ready` because when the promise returned by the static
377
- * {@link module:core/editor/editor~Editor.create `Editor.create()`} event is resolved, the editor is already ready.
378
- * In fact, since the first moment when the editor instance is available to you is inside `then()`'s callback,
379
- * you cannot even add a listener to the `editor#ready` event.
380
- *
381
- * See also the {@link module:core/editor/editor~Editor#state `editor.state`} property.
382
- *
383
- * @eventName ~Editor#ready
384
- */
385
- export type EditorReadyEvent = {
386
- name: 'ready';
387
- args: [];
388
- };
389
- /**
390
- * Fired when this editor instance is destroyed. The editor at this point is not usable and this event should be used to
391
- * perform the clean-up in any plugin.
392
- *
393
- * See also the {@link module:core/editor/editor~Editor#state `editor.state`} property.
394
- *
395
- * @eventName ~Editor#destroy
396
- */
397
- export type EditorDestroyEvent = {
398
- name: 'destroy';
399
- args: [];
400
- };
401
- export {};
402
- /**
403
- * This error is thrown when trying to pass a `<textarea>` element to a `create()` function of an editor class.
404
- *
405
- * The only editor type which can be initialized on `<textarea>` elements is
406
- * the {@glink installation/getting-started/predefined-builds#classic-editor classic editor}.
407
- * This editor hides the passed element and inserts its own UI next to it. Other types of editors reuse the passed element as their root
408
- * editable element and therefore `<textarea>` is not appropriate for them. Use a `<div>` or another text container instead:
409
- *
410
- * ```html
411
- * <div id="editor">
412
- * <p>Initial content.</p>
413
- * </div>
414
- * ```
415
- *
416
- * @error editor-wrong-element
417
- */
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module core/editor/editor
7
+ */
8
+ import { Config, type Locale, type LocaleTranslate } from '@ckeditor/ckeditor5-utils';
9
+ import { Conversion, DataController, EditingController, Model } from '@ckeditor/ckeditor5-engine';
10
+ import type { EditorUI } from '@ckeditor/ckeditor5-ui';
11
+ import Context from '../context';
12
+ import PluginCollection from '../plugincollection';
13
+ import CommandCollection, { type CommandsMap } from '../commandcollection';
14
+ import EditingKeystrokeHandler from '../editingkeystrokehandler';
15
+ import type { LoadedPlugins, PluginConstructor } from '../plugin';
16
+ import type { EditorConfig } from './editorconfig';
17
+ declare const Editor_base: {
18
+ new (): import("@ckeditor/ckeditor5-utils").Observable;
19
+ prototype: import("@ckeditor/ckeditor5-utils").Observable;
20
+ };
21
+ /**
22
+ * The class representing a basic, generic editor.
23
+ *
24
+ * Check out the list of its subclasses to learn about specific editor implementations.
25
+ *
26
+ * All editor implementations (like {@link module:editor-classic/classiceditor~ClassicEditor} or
27
+ * {@link module:editor-inline/inlineeditor~InlineEditor}) should extend this class. They can add their
28
+ * own methods and properties.
29
+ *
30
+ * When you are implementing a plugin, this editor represents the API
31
+ * which your plugin can expect to get when using its {@link module:core/plugin~Plugin#editor} property.
32
+ *
33
+ * This API should be sufficient in order to implement the "editing" part of your feature
34
+ * (schema definition, conversion, commands, keystrokes, etc.).
35
+ * It does not define the editor UI, which is available only if
36
+ * the specific editor implements also the {@link ~Editor#ui} property
37
+ * (as most editor implementations do).
38
+ */
39
+ export default abstract class Editor extends Editor_base {
40
+ /**
41
+ * Commands registered to the editor.
42
+ *
43
+ * Use the shorthand {@link #execute `editor.execute()`} method to execute commands:
44
+ *
45
+ * ```ts
46
+ * // Execute the bold command:
47
+ * editor.execute( 'bold' );
48
+ *
49
+ * // Check the state of the bold command:
50
+ * editor.commands.get( 'bold' ).value;
51
+ * ```
52
+ */
53
+ readonly commands: CommandCollection;
54
+ /**
55
+ * Stores all configurations specific to this editor instance.
56
+ *
57
+ * ```ts
58
+ * editor.config.get( 'image.toolbar' );
59
+ * // -> [ 'imageStyle:block', 'imageStyle:side', '|', 'toggleImageCaption', 'imageTextAlternative' ]
60
+ * ```
61
+ */
62
+ readonly config: Config<EditorConfig>;
63
+ /**
64
+ * Conversion manager through which you can register model-to-view and view-to-model converters.
65
+ *
66
+ * See the {@link module:engine/conversion/conversion~Conversion} documentation to learn how to add converters.
67
+ */
68
+ readonly conversion: Conversion;
69
+ /**
70
+ * The {@link module:engine/controller/datacontroller~DataController data controller}.
71
+ * Used e.g. for setting and retrieving the editor data.
72
+ */
73
+ readonly data: DataController;
74
+ /**
75
+ * The {@link module:engine/controller/editingcontroller~EditingController editing controller}.
76
+ * Controls user input and rendering the content for editing.
77
+ */
78
+ readonly editing: EditingController;
79
+ /**
80
+ * The locale instance.
81
+ */
82
+ readonly locale: Locale;
83
+ /**
84
+ * The editor's model.
85
+ *
86
+ * The central point of the editor's abstract data model.
87
+ */
88
+ readonly model: Model;
89
+ /**
90
+ * The plugins loaded and in use by this editor instance.
91
+ *
92
+ * ```ts
93
+ * editor.plugins.get( 'ClipboardPipeline' ); // -> An instance of the clipboard pipeline plugin.
94
+ * ```
95
+ */
96
+ readonly plugins: PluginCollection<Editor>;
97
+ /**
98
+ * An instance of the {@link module:core/editingkeystrokehandler~EditingKeystrokeHandler}.
99
+ *
100
+ * It allows setting simple keystrokes:
101
+ *
102
+ * ```ts
103
+ * // Execute the bold command on Ctrl+E:
104
+ * editor.keystrokes.set( 'Ctrl+E', 'bold' );
105
+ *
106
+ * // Execute your own callback:
107
+ * editor.keystrokes.set( 'Ctrl+E', ( data, cancel ) => {
108
+ * console.log( data.keyCode );
109
+ *
110
+ * // Prevent the default (native) action and stop the underlying keydown event
111
+ * // so no other editor feature will interfere.
112
+ * cancel();
113
+ * } );
114
+ * ```
115
+ *
116
+ * Note: Certain typing-oriented keystrokes (like <kbd>Backspace</kbd> or <kbd>Enter</kbd>) are handled
117
+ * by a low-level mechanism and trying to listen to them via the keystroke handler will not work reliably.
118
+ * To handle these specific keystrokes, see the events fired by the
119
+ * {@link module:engine/view/document~Document editing view document} (`editor.editing.view.document`).
120
+ */
121
+ readonly keystrokes: EditingKeystrokeHandler;
122
+ /**
123
+ * Shorthand for {@link module:utils/locale~Locale#t}.
124
+ *
125
+ * @see module:utils/locale~Locale#t
126
+ */
127
+ readonly t: LocaleTranslate;
128
+ readonly id: string;
129
+ /**
130
+ * Indicates the editor life-cycle state.
131
+ *
132
+ * The editor is in one of the following states:
133
+ *
134
+ * * `initializing` &ndash; During the editor initialization (before
135
+ * {@link module:core/editor/editor~Editor.create `Editor.create()`}) finished its job.
136
+ * * `ready` &ndash; After the promise returned by the {@link module:core/editor/editor~Editor.create `Editor.create()`}
137
+ * method is resolved.
138
+ * * `destroyed` &ndash; Once the {@link #destroy `editor.destroy()`} method was called.
139
+ *
140
+ * @observable
141
+ */
142
+ state: 'initializing' | 'ready' | 'destroyed';
143
+ /**
144
+ * The default configuration which is built into the editor class.
145
+ *
146
+ * It is used in CKEditor 5 builds to provide the default configuration options which are later used during the editor initialization.
147
+ *
148
+ * ```ts
149
+ * ClassicEditor.defaultConfig = {
150
+ * foo: 1,
151
+ * bar: 2
152
+ * };
153
+ *
154
+ * ClassicEditor
155
+ * .create( sourceElement )
156
+ * .then( editor => {
157
+ * editor.config.get( 'foo' ); // -> 1
158
+ * editor.config.get( 'bar' ); // -> 2
159
+ * } );
160
+ *
161
+ * // The default options can be overridden by the configuration passed to create().
162
+ * ClassicEditor
163
+ * .create( sourceElement, { bar: 3 } )
164
+ * .then( editor => {
165
+ * editor.config.get( 'foo' ); // -> 1
166
+ * editor.config.get( 'bar' ); // -> 3
167
+ * } );
168
+ * ```
169
+ *
170
+ * See also {@link module:core/editor/editor~Editor.builtinPlugins}.
171
+ */
172
+ static defaultConfig?: EditorConfig;
173
+ /**
174
+ * An array of plugins built into this editor class.
175
+ *
176
+ * It is used in CKEditor 5 builds to provide a list of plugins which are later automatically initialized
177
+ * during the editor initialization.
178
+ *
179
+ * They will be automatically initialized by the editor, unless listed in `config.removePlugins` and
180
+ * unless `config.plugins` is passed.
181
+ *
182
+ * ```ts
183
+ * // Build some plugins into the editor class first.
184
+ * ClassicEditor.builtinPlugins = [ FooPlugin, BarPlugin ];
185
+ *
186
+ * // Normally, you need to define config.plugins, but since ClassicEditor.builtinPlugins was
187
+ * // defined, now you can call create() without any configuration.
188
+ * ClassicEditor
189
+ * .create( sourceElement )
190
+ * .then( editor => {
191
+ * editor.plugins.get( FooPlugin ); // -> An instance of the Foo plugin.
192
+ * editor.plugins.get( BarPlugin ); // -> An instance of the Bar plugin.
193
+ * } );
194
+ *
195
+ * ClassicEditor
196
+ * .create( sourceElement, {
197
+ * // Do not initialize these plugins (note: it is defined by a string):
198
+ * removePlugins: [ 'Foo' ]
199
+ * } )
200
+ * .then( editor => {
201
+ * editor.plugins.get( FooPlugin ); // -> Undefined.
202
+ * editor.config.get( BarPlugin ); // -> An instance of the Bar plugin.
203
+ * } );
204
+ *
205
+ * ClassicEditor
206
+ * .create( sourceElement, {
207
+ * // Load only this plugin. It can also be defined by a string if
208
+ * // this plugin was built into the editor class.
209
+ * plugins: [ FooPlugin ]
210
+ * } )
211
+ * .then( editor => {
212
+ * editor.plugins.get( FooPlugin ); // -> An instance of the Foo plugin.
213
+ * editor.config.get( BarPlugin ); // -> Undefined.
214
+ * } );
215
+ * ```
216
+ *
217
+ * See also {@link module:core/editor/editor~Editor.defaultConfig}.
218
+ */
219
+ static builtinPlugins?: Array<PluginConstructor<Editor>>;
220
+ /**
221
+ * The editor UI instance.
222
+ */
223
+ abstract get ui(): EditorUI;
224
+ /**
225
+ * The editor context.
226
+ * When it is not provided through the configuration, the editor creates it.
227
+ */
228
+ protected readonly _context: Context;
229
+ /**
230
+ * A set of lock IDs for the {@link #isReadOnly} getter.
231
+ */
232
+ protected readonly _readOnlyLocks: Set<symbol | string>;
233
+ /**
234
+ * Creates a new instance of the editor class.
235
+ *
236
+ * Usually, not to be used directly. See the static {@link module:core/editor/editor~Editor.create `create()`} method.
237
+ *
238
+ * @param config The editor configuration.
239
+ */
240
+ constructor(config?: EditorConfig);
241
+ /**
242
+ * Defines whether the editor is in the read-only mode.
243
+ *
244
+ * In read-only mode the editor {@link #commands commands} are disabled so it is not possible
245
+ * to modify the document by using them. Also, the editable element(s) become non-editable.
246
+ *
247
+ * In order to make the editor read-only, you need to call the {@link #enableReadOnlyMode} method:
248
+ *
249
+ * ```ts
250
+ * editor.enableReadOnlyMode( 'feature-id' );
251
+ * ```
252
+ *
253
+ * Later, to turn off the read-only mode, call {@link #disableReadOnlyMode}:
254
+ *
255
+ * ```ts
256
+ * editor.disableReadOnlyMode( 'feature-id' );
257
+ * ```
258
+ *
259
+ * @readonly
260
+ * @observable
261
+ */
262
+ get isReadOnly(): boolean;
263
+ set isReadOnly(value: boolean);
264
+ /**
265
+ * Turns on the read-only mode in the editor.
266
+ *
267
+ * Editor can be switched to or out of the read-only mode by many features, under various circumstances. The editor supports locking
268
+ * mechanism for the read-only mode. It enables easy control over the read-only mode when many features wants to turn it on or off at
269
+ * the same time, without conflicting with each other. It guarantees that you will not make the editor editable accidentally (which
270
+ * could lead to errors).
271
+ *
272
+ * Each read-only mode request is identified by a unique id (also called "lock"). If multiple plugins requested to turn on the
273
+ * read-only mode, then, the editor will become editable only after all these plugins turn the read-only mode off (using the same ids).
274
+ *
275
+ * Note, that you cannot force the editor to disable the read-only mode if other plugins set it.
276
+ *
277
+ * After the first `enableReadOnlyMode()` call, the {@link #isReadOnly `isReadOnly` property} will be set to `true`:
278
+ *
279
+ * ```ts
280
+ * editor.isReadOnly; // `false`.
281
+ * editor.enableReadOnlyMode( 'my-feature-id' );
282
+ * editor.isReadOnly; // `true`.
283
+ * ```
284
+ *
285
+ * You can turn off the read-only mode ("clear the lock") using the {@link #disableReadOnlyMode `disableReadOnlyMode()`} method:
286
+ *
287
+ * ```ts
288
+ * editor.enableReadOnlyMode( 'my-feature-id' );
289
+ * // ...
290
+ * editor.disableReadOnlyMode( 'my-feature-id' );
291
+ * editor.isReadOnly; // `false`.
292
+ * ```
293
+ *
294
+ * All "locks" need to be removed to enable editing:
295
+ *
296
+ * ```ts
297
+ * editor.enableReadOnlyMode( 'my-feature-id' );
298
+ * editor.enableReadOnlyMode( 'my-other-feature-id' );
299
+ * // ...
300
+ * editor.disableReadOnlyMode( 'my-feature-id' );
301
+ * editor.isReadOnly; // `true`.
302
+ * editor.disableReadOnlyMode( 'my-other-feature-id' );
303
+ * editor.isReadOnly; // `false`.
304
+ * ```
305
+ *
306
+ * @param lockId A unique ID for setting the editor to the read-only state.
307
+ */
308
+ enableReadOnlyMode(lockId: string | symbol): void;
309
+ /**
310
+ * Removes the read-only lock from the editor with given lock ID.
311
+ *
312
+ * When no lock is present on the editor anymore, then the {@link #isReadOnly `isReadOnly` property} will be set to `false`.
313
+ *
314
+ * @param lockId The lock ID for setting the editor to the read-only state.
315
+ */
316
+ disableReadOnlyMode(lockId: string | symbol): void;
317
+ /**
318
+ * Loads and initializes plugins specified in the configuration.
319
+ *
320
+ * @returns A promise which resolves once the initialization is completed, providing an array of loaded plugins.
321
+ */
322
+ initPlugins(): Promise<LoadedPlugins>;
323
+ /**
324
+ * Destroys the editor instance, releasing all resources used by it.
325
+ *
326
+ * **Note** The editor cannot be destroyed during the initialization phase so if it is called
327
+ * while the editor {@link #state is being initialized}, it will wait for the editor initialization before destroying it.
328
+ *
329
+ * @fires destroy
330
+ * @returns A promise that resolves once the editor instance is fully destroyed.
331
+ */
332
+ destroy(): Promise<unknown>;
333
+ /**
334
+ * Executes the specified command with given parameters.
335
+ *
336
+ * Shorthand for:
337
+ *
338
+ * ```ts
339
+ * editor.commands.get( commandName ).execute( ... );
340
+ * ```
341
+ *
342
+ * @param commandName The name of the command to execute.
343
+ * @param commandParams Command parameters.
344
+ * @returns The value returned by the {@link module:core/commandcollection~CommandCollection#execute `commands.execute()`}.
345
+ */
346
+ execute<TName extends string>(commandName: TName, ...commandParams: Parameters<CommandsMap[TName]['execute']>): ReturnType<CommandsMap[TName]['execute']>;
347
+ /**
348
+ * Focuses the editor.
349
+ *
350
+ * **Note** To explicitly focus the editing area of the editor, use the
351
+ * {@link module:engine/view/view~View#focus `editor.editing.view.focus()`} method of the editing view.
352
+ *
353
+ * Check out the {@glink framework/deep-dive/ui/focus-tracking#focus-in-the-editor-ui Focus in the editor UI} section
354
+ * of the {@glink framework/deep-dive/ui/focus-tracking Deep dive into focus tracking} guide to learn more.
355
+ */
356
+ focus(): void;
357
+ /**
358
+ * Creates and initializes a new editor instance.
359
+ *
360
+ * This is an abstract method. Every editor type needs to implement its own initialization logic.
361
+ *
362
+ * See the `create()` methods of the existing editor types to learn how to use them:
363
+ *
364
+ * * {@link module:editor-classic/classiceditor~ClassicEditor.create `ClassicEditor.create()`}
365
+ * * {@link module:editor-balloon/ballooneditor~BalloonEditor.create `BalloonEditor.create()`}
366
+ * * {@link module:editor-decoupled/decouplededitor~DecoupledEditor.create `DecoupledEditor.create()`}
367
+ * * {@link module:editor-inline/inlineeditor~InlineEditor.create `InlineEditor.create()`}
368
+ */
369
+ static create(...args: Array<unknown>): void;
370
+ }
371
+ /**
372
+ * Fired when the {@link module:engine/controller/datacontroller~DataController#event:ready data} and all additional
373
+ * editor components are ready.
374
+ *
375
+ * Note: This event is most useful for plugin developers. When integrating the editor with your website or
376
+ * application, you do not have to listen to `editor#ready` because when the promise returned by the static
377
+ * {@link module:core/editor/editor~Editor.create `Editor.create()`} event is resolved, the editor is already ready.
378
+ * In fact, since the first moment when the editor instance is available to you is inside `then()`'s callback,
379
+ * you cannot even add a listener to the `editor#ready` event.
380
+ *
381
+ * See also the {@link module:core/editor/editor~Editor#state `editor.state`} property.
382
+ *
383
+ * @eventName ~Editor#ready
384
+ */
385
+ export type EditorReadyEvent = {
386
+ name: 'ready';
387
+ args: [];
388
+ };
389
+ /**
390
+ * Fired when this editor instance is destroyed. The editor at this point is not usable and this event should be used to
391
+ * perform the clean-up in any plugin.
392
+ *
393
+ * See also the {@link module:core/editor/editor~Editor#state `editor.state`} property.
394
+ *
395
+ * @eventName ~Editor#destroy
396
+ */
397
+ export type EditorDestroyEvent = {
398
+ name: 'destroy';
399
+ args: [];
400
+ };
401
+ export {};
402
+ /**
403
+ * This error is thrown when trying to pass a `<textarea>` element to a `create()` function of an editor class.
404
+ *
405
+ * The only editor type which can be initialized on `<textarea>` elements is
406
+ * the {@glink installation/getting-started/predefined-builds#classic-editor classic editor}.
407
+ * This editor hides the passed element and inserts its own UI next to it. Other types of editors reuse the passed element as their root
408
+ * editable element and therefore `<textarea>` is not appropriate for them. Use a `<div>` or another text container instead:
409
+ *
410
+ * ```html
411
+ * <div id="editor">
412
+ * <p>Initial content.</p>
413
+ * </div>
414
+ * ```
415
+ *
416
+ * @error editor-wrong-element
417
+ */