@ckeditor/ckeditor5-core 36.0.0 → 37.0.0-alpha.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.
@@ -0,0 +1,481 @@
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/editorconfig
7
+ */
8
+ import type Context from '../context';
9
+ import type { PluginConstructor } from '../plugin';
10
+ import type Editor from './editor';
11
+ /**
12
+ * CKEditor configuration options.
13
+ *
14
+ * An object defining the editor configuration can be passed when initializing the editor:
15
+ *
16
+ * ```ts
17
+ * EditorClass
18
+ * .create( {
19
+ * toolbar: [ 'bold', 'italic' ],
20
+ * image: {
21
+ * styles: [
22
+ * ...
23
+ * ]
24
+ * }
25
+ * } )
26
+ * .then( ... )
27
+ * .catch( ... );
28
+ * ```
29
+ *
30
+ * Check the {@glink installation/getting-started/predefined-builds Configuration} guide for more information
31
+ * about setting configuration options.
32
+ */
33
+ export interface EditorConfig {
34
+ context?: Context;
35
+ /**
36
+ * The list of additional plugins to load along those already available in the
37
+ * {@glink installation/getting-started/predefined-builds editor build}. It extends the {@link #plugins `plugins`} configuration.
38
+ *
39
+ * ```ts
40
+ * function MyPlugin( editor ) {
41
+ * // ...
42
+ * }
43
+ *
44
+ * const config = {
45
+ * extraPlugins: [ MyPlugin ]
46
+ * };
47
+ * ```
48
+ *
49
+ * **Note:** This configuration works only for simple plugins which utilize the
50
+ * {@link module:core/plugin~PluginInterface plugin interface} and have no dependencies. To extend a
51
+ * build with complex features, create a
52
+ * {@glink installation/getting-started/quick-start-other#creating-custom-builds-with-online-builder custom build}.
53
+ *
54
+ * **Note:** Make sure you include the new features in you toolbar configuration. Learn more
55
+ * about the {@glink features/toolbar/toolbar toolbar setup}.
56
+ */
57
+ extraPlugins?: Array<PluginConstructor<Editor>>;
58
+ /**
59
+ * The initial editor data to be used instead of the provided element's HTML content.
60
+ *
61
+ * ```ts
62
+ * ClassicEditor
63
+ * .create( document.querySelector( '#editor' ), {
64
+ * initialData: '<h2>Initial data</h2><p>Foo bar.</p>'
65
+ * } )
66
+ * .then( ... )
67
+ * .catch( ... );
68
+ * ```
69
+ *
70
+ * By default, the editor is initialized with the content of the element on which this editor is initialized.
71
+ * This configuration option lets you override this behavior and pass different initial data.
72
+ * It is especially useful if it is difficult for your integration to put the data inside the HTML element.
73
+ *
74
+ * See also {@link module:core/editor/editor~Editor.create Editor.create()}.
75
+ *
76
+ * **Note:** If initial data is passed to `Editor.create()` in the first parameter (instead of a DOM element), and,
77
+ * at the same time, `config.initialData` is set, an error will be thrown as those two options exclude themselves.
78
+ *
79
+ * If `config.initialData` is not set when the editor is initialized, the data received in `Editor.create()` call
80
+ * will be used to set `config.initialData`. As a result, `initialData` is always set in the editor's config and
81
+ * plugins can read and/or modify it during initialization.
82
+ */
83
+ initialData?: string;
84
+ /**
85
+ * The language of the editor UI and its content.
86
+ *
87
+ * Note: You do not have to specify this option if your build is optimized for one UI language or if it is
88
+ * the default language (English is the default language for CDN builds), unless you want to change
89
+ * the language of your content.
90
+ *
91
+ * Simple usage (change the language of the UI and the content):
92
+ *
93
+ * ```ts
94
+ * ClassicEditor
95
+ * .create( document.querySelector( '#editor' ), {
96
+ * // The UI of the editor as well as its content will be in German.
97
+ * language: 'de'
98
+ * } )
99
+ * .then( editor => {
100
+ * console.log( editor );
101
+ * } )
102
+ * .catch( error => {
103
+ * console.error( error );
104
+ * } );
105
+ * ```
106
+ *
107
+ * Use different languages for the UI and the content using the {@link module:core/editor/editorconfig~LanguageConfig configuration}
108
+ * syntax:
109
+ *
110
+ * ```ts
111
+ * ClassicEditor
112
+ * .create( document.querySelector( '#editor' ), {
113
+ * language: {
114
+ * // The UI will be in English.
115
+ * ui: 'en',
116
+ *
117
+ * // But the content will be edited in Arabic.
118
+ * content: 'ar'
119
+ * }
120
+ * } )
121
+ * .then( editor => {
122
+ * console.log( editor );
123
+ * } )
124
+ * .catch( error => {
125
+ * console.error( error );
126
+ * } );
127
+ * ```
128
+ *
129
+ * The language of the content has an impact on the editing experience, for instance it affects screen readers
130
+ * and spell checkers. It is also particularly useful for typing in certain languages (e.g. right–to–left ones)
131
+ * because it changes the default alignment of the text.
132
+ *
133
+ * The language codes are defined in the [ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1) standard.
134
+ *
135
+ * You need to add the corresponding translation file for the new UI language to work.
136
+ * Translation files are available on CDN for predefined builds:
137
+ *
138
+ * ```html
139
+ * `<script src="https://cdn.ckeditor.com/ckeditor5/[version.number]/[distribution]/lang/[lang].js"></script>`
140
+ * ```
141
+ *
142
+ * But you can add them manually by coping from the `node_modules/@ckeditor/ckeditor5-build-[name]/build/lang/[lang].js'`.
143
+ *
144
+ * Check the {@glink features/ui-language UI language} guide for more information about the localization options and translation
145
+ * process.
146
+ */
147
+ language?: string | LanguageConfig;
148
+ /**
149
+ * Specifies the text displayed in the editor when there is no content (editor is empty). It is intended to
150
+ * help users locate the editor in the application (form) and prompt them to input the content. Work similarly
151
+ * as to the native DOM
152
+ * [`placeholder` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#The_placeholder_attribute)
153
+ * used by inputs.
154
+ *
155
+ * ```ts
156
+ * const config = {
157
+ * placeholder: 'Type some text...'
158
+ * };
159
+ * ```
160
+ *
161
+ * The placeholder text is displayed as a pseudo–element of an empty paragraph in the editor content.
162
+ * The paragraph has the `.ck-placeholder` CSS class and the `data-placeholder` attribute.
163
+ *
164
+ * ```html
165
+ * <p data-placeholder="Type some text..." class="ck-placeholder">
166
+ * ::before
167
+ * </p>
168
+ * ```
169
+ *
170
+ * **Note**: Placeholder text can also be set using the `placeholder` attribute if a `<textarea>` is passed to
171
+ * the `create()` method, e.g. {@link module:editor-classic/classiceditor~ClassicEditor.create `ClassicEditor.create()`}.
172
+ *
173
+ * **Note**: This configuration has precedence over the value of the `placeholder` attribute of a `<textarea>`
174
+ * element passed to the `create()` method.
175
+ *
176
+ * See the {@glink features/editor-placeholder "Editor placeholder"} guide for more information and live examples.
177
+ */
178
+ placeholder?: string;
179
+ /**
180
+ * The list of plugins to load.
181
+ *
182
+ * If you use an {@glink installation/getting-started/predefined-builds editor build} you can define the list of plugins to load
183
+ * using the names of plugins that are available:
184
+ *
185
+ * ```ts
186
+ * const config = {
187
+ * plugins: [ 'Bold', 'Italic', 'Typing', 'Enter', ... ]
188
+ * };
189
+ * ```
190
+ *
191
+ * You can check the list of plugins available in a build using this snippet:
192
+ *
193
+ * ```ts
194
+ * ClassicEditor.builtinPlugins.map( plugin => plugin.pluginName );
195
+ * ```
196
+ *
197
+ * If you use an editor creator directly (imported from a package like `@ckeditor/ckeditor5-editor-classic`) or you
198
+ * want to load additional plugins which were not included in a build you use, then you need to specify
199
+ * the plugins using their constructors:
200
+ *
201
+ * ```ts
202
+ * // A preset of plugins is a plugin as well.
203
+ * import Essentials from '@ckeditor/ckeditor5-essentials/src/essentials';
204
+ * // The bold plugin.
205
+ * import Bold from '@ckeditor/ckeditor5-editor-basic-styles/src/bold';
206
+ *
207
+ * const config = {
208
+ * plugins: [ Essentials, Bold ]
209
+ * };
210
+ * ```
211
+ *
212
+ * **Note:** To load additional plugins, you should use the {@link #extraPlugins `extraPlugins`} configuration.
213
+ * To narrow the list of loaded plugins, use the {@link #removePlugins `removePlugins`} configuration.
214
+ */
215
+ plugins?: Array<PluginConstructor<Editor> | string>;
216
+ /**
217
+ * The list of plugins which should not be loaded despite being available in an {@glink installation/getting-started/predefined-builds
218
+ * editor build}.
219
+ *
220
+ * ```ts
221
+ * const config = {
222
+ * removePlugins: [ 'Bold', 'Italic' ]
223
+ * };
224
+ * ```
225
+ *
226
+ * **Note:** Be careful when removing plugins using `config.removePlugins` from CKEditor builds.
227
+ * If removed plugins were providing toolbar buttons, the default toolbar configuration included in a build
228
+ * will become invalid. In such case you need to provide the updated
229
+ * {@link module:core/editor/editorconfig~EditorConfig#toolbar toolbar configuration}.
230
+ */
231
+ removePlugins?: Array<PluginConstructor<Editor> | string>;
232
+ substitutePlugins?: Array<PluginConstructor<Editor>>;
233
+ /**
234
+ * The editor toolbar configuration.
235
+ *
236
+ * Simple format (specifies only toolbar items):
237
+ *
238
+ * ```ts
239
+ * const config = {
240
+ * toolbar: [ 'bold', 'italic', '|', 'undo', 'redo' ]
241
+ * };
242
+ * ```
243
+ *
244
+ * Extended format:
245
+ *
246
+ * ```ts
247
+ * const config = {
248
+ * toolbar: {
249
+ * items: [ 'bold', 'italic', '|', 'undo', 'redo', '-', 'numberedList', 'bulletedList' ],
250
+ *
251
+ * shouldNotGroupWhenFull: true
252
+ * }
253
+ * };
254
+ * ```
255
+ *
256
+ * Options which can be set using the extended format:
257
+ *
258
+ * * **`toolbar.items`** &ndash; An array of toolbar item names. The components (buttons, dropdowns, etc.) which can be used
259
+ * as toolbar items are defined in `editor.ui.componentFactory` and can be listed using the following snippet:
260
+ *
261
+ * ```ts
262
+ * Array.from( editor.ui.componentFactory.names() );
263
+ * ```
264
+ *
265
+ * You can also use `'|'` to create a separator between groups of items:
266
+ *
267
+ * ```
268
+ * toolbar: [ 'bold', 'italic', '|', 'undo', 'redo' ]
269
+ * ```
270
+ *
271
+ * or `'-'` to make a line break and render items in multiple lines:
272
+ *
273
+ * ```
274
+ * toolbar: [ 'bold', 'italic', '-', 'undo', 'redo' ]
275
+ * ```
276
+ *
277
+ * Line break will work only in the extended format when `shouldNotGroupWhenFull` option is set to `true`.
278
+ *
279
+ * **Note**: To save space in your toolbar, you can group several items into a dropdown:
280
+ *
281
+ * ```
282
+ * toolbar: [
283
+ * {
284
+ * label: 'Basic styles',
285
+ * icon: 'text',
286
+ * items: [ 'bold', 'italic', ... ]
287
+ * },
288
+ * '|',
289
+ * 'undo', 'redo'
290
+ * ]
291
+ * ```
292
+ *
293
+ * The code above will create a "Basic styles" dropdown with a "text" icon containing the "bold" and "italic" buttons.
294
+ * You can customize the look of the dropdown by setting the `withText`, `icon`, and `tooltip` properties:
295
+ *
296
+ * * **Displaying a label**
297
+ *
298
+ * For instance, to hide the icon and to display the label only, you can use the following configuration:
299
+ *
300
+ * ```ts
301
+ * {
302
+ * label: 'Basic styles',
303
+ * // Show the textual label of the drop-down. Note that the "icon" property is not configured.
304
+ * withText: true,
305
+ * items: [ 'bold', 'italic', ... ]
306
+ * }
307
+ * ```
308
+ *
309
+ * * **Selecting an icon**
310
+ *
311
+ * You can use one of the common icons provided by the editor (`'bold'`, `'plus'`, `'text'`, `'importExport'`, `'alignLeft'`,
312
+ * `'paragraph'`, `'threeVerticalDots'`):
313
+ *
314
+ * ```ts
315
+ * {
316
+ * label: '...',
317
+ * // A "plus" sign icon works best for content insertion tools.
318
+ * icon: 'plus',
319
+ * items: [ ... ]
320
+ * }
321
+ * ```
322
+ *
323
+ * If no icon is specified, `'threeVerticalDots'` will be used as a default:
324
+ *
325
+ * ```ts
326
+ * // No icon specified, using a default one.
327
+ * {
328
+ * label: 'Default icon',
329
+ * items: [ ... ]
330
+ * }
331
+ * ```
332
+ *
333
+ * If `icon: false` is configured, no icon will be displayed at all and the text label will show up instead:
334
+ *
335
+ * ```ts
336
+ * // This drop-down has no icon. The text label will be displayed instead.
337
+ * {
338
+ * label: 'No icon',
339
+ * icon: false,
340
+ * items: [ ... ]
341
+ * }
342
+ * ```
343
+ *
344
+ * You can also set a custom icon for the drop-down by passing an SVG string:
345
+ *
346
+ * ```ts
347
+ * {
348
+ * label: '...',
349
+ * // If you want your icon to change the color dynamically (e.g. when the dropdown opens), avoid fill="..."
350
+ * // and stroke="..." styling attributes. Use solid shapes and avoid paths with strokes.
351
+ * icon: '<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">...</svg>',
352
+ * items: [ ... ]
353
+ * }
354
+ * ```
355
+ *
356
+ * * **Customizing the tooltip**
357
+ *
358
+ * By default, the tooltip of the button shares its text with the label. You can customize it to better describe your dropdown
359
+ * using the `tooltip` property ({@link module:ui/button/buttonview~ButtonView#tooltip learn more}):
360
+ *
361
+ * ```ts
362
+ * {
363
+ * label: 'Drop-down label',
364
+ * tooltip: 'Custom tooltip of the drop-down',
365
+ * icon: '...',
366
+ * items: [ ... ]
367
+ * }
368
+ * ```
369
+ *
370
+ * * **`toolbar.viewportTopOffset` (deprecated)** &ndash; The offset (in pixels) from the top of the viewport used when positioning a
371
+ * sticky toolbar.
372
+ * Useful when a page with which the editor is being integrated has some other sticky or fixed elements
373
+ * (e.g. the top menu). Thanks to setting the toolbar offset the toolbar will not be positioned underneath or above the page's UI.
374
+ *
375
+ * **This property has been deprecated and will be removed in the future versions of CKEditor. Please use
376
+ * `{@link module:core/editor/editorconfig~EditorConfig#ui EditorConfig#ui.viewportOffset}` instead.**
377
+ *
378
+ * * **`toolbar.shouldNotGroupWhenFull`** &ndash; When set to `true`, the toolbar will stop grouping items
379
+ * and let them wrap to the next line if there is not enough space to display them in a single row.
380
+ */
381
+ toolbar?: ToolbarConfig;
382
+ /**
383
+ * The editor UI configuration.
384
+ *
385
+ * ```ts
386
+ * ClassicEditor
387
+ * .create( document.querySelector( '#editor' ), {
388
+ * ui: { ... }
389
+ * } )
390
+ * .then( ... )
391
+ * .catch( ... );
392
+ * ```
393
+ *
394
+ * Options which can be set using the UI config:
395
+ *
396
+ * * **`ui.viewportOffset`** &ndash; The offset (in pixels) of the viewport from every direction used when positioning a sticky toolbar
397
+ * or other absolutely positioned UI elements.
398
+ * Useful when a page with which the editor is being integrated has some other sticky or fixed elements
399
+ * (e.g. the top menu). Thanks to setting the UI viewport offset the toolbar and other contextual balloons will not be positioned
400
+ * underneath or above the page's UI.
401
+ *
402
+ * ```ts
403
+ * ui: {
404
+ * viewportOffset: { top: 10, right: 10, bottom: 10, left: 10 }
405
+ * }
406
+ * ```
407
+ *
408
+ * **Note:** If you want to modify the viewport offset in runtime (after editor was created), you can do that by overriding
409
+ * {@link module:ui/editorui/editorui~EditorUI#viewportOffset `editor.ui.viewportOffset`}.
410
+ */
411
+ ui?: UiConfig;
412
+ /**
413
+ * Enables updating the source element after the editor destroy.
414
+ *
415
+ * Enabling this option might have some security implications, as the editor doesn't have control over all data
416
+ * in the output.
417
+ *
418
+ * Be careful, especially while using
419
+ * {@glink features/markdown Markdown}, {@glink features/general-html-support General HTML Support} or
420
+ * {@glink features/html-embed HTML embed} features.
421
+ */
422
+ updateSourceElementOnDestroy?: boolean;
423
+ }
424
+ /**
425
+ * The `config.initialData` option cannot be used together with initial data passed as the first parameter of
426
+ * {@link module:core/editor/editor~Editor.create `Editor.create()`}.
427
+ *
428
+ * @error editor-create-initial-data
429
+ */
430
+ /**
431
+ * The configuration of the editor language.
432
+ *
433
+ * ```ts
434
+ * ClassicEditor
435
+ * .create( document.querySelector( '#editor' ), {
436
+ * language: ... // Editor language configuration.
437
+ * } )
438
+ * .then( editor => {
439
+ * console.log( editor );
440
+ * } )
441
+ * .catch( error => {
442
+ * console.error( error );
443
+ * } );
444
+ * ```
445
+ *
446
+ * See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
447
+ */
448
+ export interface LanguageConfig {
449
+ /**
450
+ * Allows to use different language for the editor UI.
451
+ *
452
+ * The language codes are defined in the [ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1) standard.
453
+ */
454
+ ui?: string;
455
+ /**
456
+ * Allows to use different language of the editor content.
457
+ *
458
+ * The language codes are defined in the [ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1) standard.
459
+ */
460
+ content?: string;
461
+ }
462
+ export type ToolbarConfig = Array<ToolbarConfigItem> | {
463
+ items?: Array<ToolbarConfigItem>;
464
+ removeItems?: Array<string>;
465
+ shouldNotGroupWhenFull?: boolean;
466
+ };
467
+ export type ToolbarConfigItem = string | {
468
+ items: Array<ToolbarConfigItem>;
469
+ label: string;
470
+ icon?: string | false;
471
+ withText?: boolean;
472
+ tooltip?: boolean | string | ((label: string, keystroke: string | undefined) => string);
473
+ };
474
+ export interface UiConfig {
475
+ viewportOffset?: {
476
+ bottom?: number;
477
+ left?: number;
478
+ right?: number;
479
+ top?: number;
480
+ };
481
+ }
@@ -0,0 +1,15 @@
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
+ import type { default as Editor } from '../editor';
6
+ import type { ElementApi } from './elementapimixin';
7
+ /**
8
+ * Checks if the editor is initialized on a `<textarea>` element that belongs to a form. If yes, it updates the editor's element
9
+ * content before submitting the form.
10
+ *
11
+ * This helper requires the {@link module:core/editor/utils/elementapimixin~ElementApi ElementApi interface}.
12
+ *
13
+ * @param editor Editor instance.
14
+ */
15
+ export default function attachToForm(editor: Editor & ElementApi): void;
@@ -2,18 +2,18 @@
2
2
  * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
- import { isFunction } from 'lodash-es';
6
- import { CKEditorError } from '@ckeditor/ckeditor5-utils';
7
5
  /**
8
6
  * @module core/editor/utils/attachtoform
9
7
  */
8
+ import { isFunction } from 'lodash-es';
9
+ import { CKEditorError } from '@ckeditor/ckeditor5-utils';
10
10
  /**
11
11
  * Checks if the editor is initialized on a `<textarea>` element that belongs to a form. If yes, it updates the editor's element
12
12
  * content before submitting the form.
13
13
  *
14
14
  * This helper requires the {@link module:core/editor/utils/elementapimixin~ElementApi ElementApi interface}.
15
15
  *
16
- * @param {module:core/editor/editor~Editor} editor Editor instance.
16
+ * @param editor Editor instance.
17
17
  */
18
18
  export default function attachToForm(editor) {
19
19
  if (!isFunction(editor.updateSourceElement)) {
@@ -0,0 +1,63 @@
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/utils/dataapimixin
7
+ */
8
+ import type Editor from '../editor';
9
+ import type { Constructor, Mixed } from '@ckeditor/ckeditor5-utils';
10
+ /**
11
+ * Implementation of the {@link module:core/editor/utils/dataapimixin~DataApi}.
12
+ */
13
+ export default function DataApiMixin<Base extends Constructor<Editor>>(base: Base): Mixed<Base, DataApi>;
14
+ /**
15
+ * Interface defining editor methods for setting and getting data to and from the editor's main root element
16
+ * using the {@link module:core/editor/editor~Editor#data data pipeline}.
17
+ *
18
+ * This interface is not a part of the {@link module:core/editor/editor~Editor} class because one may want to implement
19
+ * an editor with multiple root elements, in which case the methods for setting and getting data will need to be implemented
20
+ * differently.
21
+ */
22
+ export interface DataApi {
23
+ /**
24
+ * Sets the data in the editor.
25
+ *
26
+ * ```ts
27
+ * editor.setData( '<p>This is editor!</p>' );
28
+ * ```
29
+ *
30
+ * By default the editor accepts HTML. This can be controlled by injecting a different data processor.
31
+ * See the {@glink features/markdown Markdown output} guide for more details.
32
+ *
33
+ * Note: Not only is the format of the data configurable, but the type of the `setData()`'s parameter does not
34
+ * have to be a string either. You can e.g. accept an object or a DOM `DocumentFragment` if you consider this
35
+ * the right format for you.
36
+ *
37
+ * @param data Input data.
38
+ */
39
+ setData(data: string): void;
40
+ /**
41
+ * Gets the data from the editor.
42
+ *
43
+ * ```ts
44
+ * editor.getData(); // -> '<p>This is editor!</p>'
45
+ * ```
46
+ *
47
+ * By default the editor outputs HTML. This can be controlled by injecting a different data processor.
48
+ * See the {@glink features/markdown Markdown output} guide for more details.
49
+ *
50
+ * Note: Not only is the format of the data configurable, but the type of the `getData()`'s return value does not
51
+ * have to be a string either. You can e.g. return an object or a DOM `DocumentFragment` if you consider this
52
+ * the right format for you.
53
+ *
54
+ * @param options Additional configuration for the retrieved data.
55
+ * Editor features may introduce more configuration options that can be set through this parameter.
56
+ * @param options.rootName Root name. Default to `'main'`.
57
+ * @param options.trim Whether returned data should be trimmed. This option is set to `'empty'` by default,
58
+ * which means that whenever editor content is considered empty, an empty string is returned. To turn off trimming
59
+ * use `'none'`. In such cases exact content will be returned (for example `'<p>&nbsp;</p>'` for an empty editor).
60
+ * @returns Output data.
61
+ */
62
+ getData(options?: Record<string, unknown>): string;
63
+ }
@@ -2,14 +2,8 @@
2
2
  * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
- /**
6
- * @module core/editor/utils/dataapimixin
7
- */
8
5
  /**
9
6
  * Implementation of the {@link module:core/editor/utils/dataapimixin~DataApi}.
10
- *
11
- * @mixin DataApiMixin
12
- * @implements module:core/editor/utils/dataapimixin~DataApi
13
7
  */
14
8
  export default function DataApiMixin(base) {
15
9
  class Mixin extends base {
@@ -0,0 +1,31 @@
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/utils/elementapimixin
7
+ */
8
+ import { type Constructor, type Mixed } from '@ckeditor/ckeditor5-utils';
9
+ import type Editor from '../editor';
10
+ /**
11
+ * Implementation of the {@link module:core/editor/utils/elementapimixin~ElementApi}.
12
+ */
13
+ export default function ElementApiMixin<Base extends Constructor<Editor>>(base: Base): Mixed<Base, ElementApi>;
14
+ /**
15
+ * Interface describing an editor that replaced a DOM element (was "initialized on an element").
16
+ *
17
+ * Such an editor should provide a method to
18
+ * {@link module:core/editor/utils/elementapimixin~ElementApi#updateSourceElement update the replaced element with the current data}.
19
+ */
20
+ export interface ElementApi {
21
+ /**
22
+ * The element on which the editor has been initialized.
23
+ *
24
+ * @readonly
25
+ */
26
+ sourceElement: HTMLElement | undefined;
27
+ /**
28
+ * Updates the {@link #sourceElement editor source element}'s content with the data.
29
+ */
30
+ updateSourceElement(data?: string): void;
31
+ }
@@ -2,16 +2,12 @@
2
2
  * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
- /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
6
- import { CKEditorError, setDataInElement } from '@ckeditor/ckeditor5-utils';
7
5
  /**
8
6
  * @module core/editor/utils/elementapimixin
9
7
  */
8
+ import { CKEditorError, setDataInElement } from '@ckeditor/ckeditor5-utils';
10
9
  /**
11
10
  * Implementation of the {@link module:core/editor/utils/elementapimixin~ElementApi}.
12
- *
13
- * @mixin ElementApiMixin
14
- * @implements module:core/editor/utils/elementapimixin~ElementApi
15
11
  */
16
12
  export default function ElementApiMixin(base) {
17
13
  class Mixin extends base {
@@ -0,0 +1,15 @@
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
+ import type { default as Editor } from '../editor';
6
+ import type { ElementApi } from './elementapimixin';
7
+ /**
8
+ * Marks the source element on which the editor was initialized. This prevents other editor instances from using this element.
9
+ *
10
+ * Running multiple editor instances on the same source element causes various issues and it is
11
+ * crucial this helper is called as soon as the source element is known to prevent collisions.
12
+ *
13
+ * @param editor Editor instance.
14
+ */
15
+ export default function secureSourceElement(editor: Editor & ElementApi): void;