@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,5 +1,5 @@
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
- export {};
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
+ export {};
@@ -1,15 +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;
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;
@@ -1,57 +1,57 @@
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/attachtoform
7
- */
8
- import { isFunction } from 'lodash-es';
9
- import { CKEditorError } from '@ckeditor/ckeditor5-utils';
10
- /**
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
- * content before submitting the form.
13
- *
14
- * This helper requires the {@link module:core/editor/utils/elementapimixin~ElementApi ElementApi interface}.
15
- *
16
- * @param editor Editor instance.
17
- */
18
- export default function attachToForm(editor) {
19
- if (!isFunction(editor.updateSourceElement)) {
20
- /**
21
- * The editor passed to `attachToForm()` must implement the
22
- * {@link module:core/editor/utils/elementapimixin~ElementApi} interface.
23
- *
24
- * @error attachtoform-missing-elementapi-interface
25
- */
26
- throw new CKEditorError('attachtoform-missing-elementapi-interface', editor);
27
- }
28
- const sourceElement = editor.sourceElement;
29
- // Only when replacing a textarea which is inside of a form element.
30
- if (isTextArea(sourceElement) && sourceElement.form) {
31
- let originalSubmit;
32
- const form = sourceElement.form;
33
- const onSubmit = () => editor.updateSourceElement();
34
- // Replace the original form#submit() to call a custom submit function first.
35
- // Check if #submit is a function because the form might have an input named "submit".
36
- if (isFunction(form.submit)) {
37
- originalSubmit = form.submit;
38
- form.submit = () => {
39
- onSubmit();
40
- originalSubmit.apply(form);
41
- };
42
- }
43
- // Update the replaced textarea with data before each form#submit event.
44
- form.addEventListener('submit', onSubmit);
45
- // Remove the submit listener and revert the original submit method on
46
- // editor#destroy.
47
- editor.on('destroy', () => {
48
- form.removeEventListener('submit', onSubmit);
49
- if (originalSubmit) {
50
- form.submit = originalSubmit;
51
- }
52
- });
53
- }
54
- }
55
- function isTextArea(sourceElement) {
56
- return !!sourceElement && sourceElement.tagName.toLowerCase() === 'textarea';
57
- }
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/attachtoform
7
+ */
8
+ import { isFunction } from 'lodash-es';
9
+ import { CKEditorError } from '@ckeditor/ckeditor5-utils';
10
+ /**
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
+ * content before submitting the form.
13
+ *
14
+ * This helper requires the {@link module:core/editor/utils/elementapimixin~ElementApi ElementApi interface}.
15
+ *
16
+ * @param editor Editor instance.
17
+ */
18
+ export default function attachToForm(editor) {
19
+ if (!isFunction(editor.updateSourceElement)) {
20
+ /**
21
+ * The editor passed to `attachToForm()` must implement the
22
+ * {@link module:core/editor/utils/elementapimixin~ElementApi} interface.
23
+ *
24
+ * @error attachtoform-missing-elementapi-interface
25
+ */
26
+ throw new CKEditorError('attachtoform-missing-elementapi-interface', editor);
27
+ }
28
+ const sourceElement = editor.sourceElement;
29
+ // Only when replacing a textarea which is inside of a form element.
30
+ if (isTextArea(sourceElement) && sourceElement.form) {
31
+ let originalSubmit;
32
+ const form = sourceElement.form;
33
+ const onSubmit = () => editor.updateSourceElement();
34
+ // Replace the original form#submit() to call a custom submit function first.
35
+ // Check if #submit is a function because the form might have an input named "submit".
36
+ if (isFunction(form.submit)) {
37
+ originalSubmit = form.submit;
38
+ form.submit = () => {
39
+ onSubmit();
40
+ originalSubmit.apply(form);
41
+ };
42
+ }
43
+ // Update the replaced textarea with data before each form#submit event.
44
+ form.addEventListener('submit', onSubmit);
45
+ // Remove the submit listener and revert the original submit method on
46
+ // editor#destroy.
47
+ editor.on('destroy', () => {
48
+ form.removeEventListener('submit', onSubmit);
49
+ if (originalSubmit) {
50
+ form.submit = originalSubmit;
51
+ }
52
+ });
53
+ }
54
+ }
55
+ function isTextArea(sourceElement) {
56
+ return !!sourceElement && sourceElement.tagName.toLowerCase() === 'textarea';
57
+ }
@@ -1,75 +1,75 @@
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
- * If your editor implementation uses multiple roots, you should pass an object with keys corresponding
31
- * to the editor root names and values equal to the data that should be set in each root:
32
- *
33
- * ```ts
34
- * editor.setData( {
35
- * header: '<p>Content for header part.</p>',
36
- * content: '<p>Content for main part.</p>',
37
- * footer: '<p>Content for footer part.</p>'
38
- * } );
39
- * ```
40
- *
41
- * By default the editor accepts HTML. This can be controlled by injecting a different data processor.
42
- * See the {@glink features/markdown Markdown output} guide for more details.
43
- *
44
- * @param data Input data.
45
- */
46
- setData(data: string | Record<string, string>): void;
47
- /**
48
- * Gets the data from the editor.
49
- *
50
- * ```ts
51
- * editor.getData(); // -> '<p>This is editor!</p>'
52
- * ```
53
- *
54
- * If your editor implementation uses multiple roots, you should pass root name as one of the options:
55
- *
56
- * ```ts
57
- * editor.getData( { rootName: 'header' } ); // -> '<p>Content for header part.</p>'
58
- * ```
59
- *
60
- * By default, the editor outputs HTML. This can be controlled by injecting a different data processor.
61
- * See the {@glink features/markdown Markdown output} guide for more details.
62
- *
63
- * A warning is logged when you try to retrieve data for a detached root, as most probably this is a mistake. A detached root should
64
- * be treated like it is removed, and you should not save its data. Note, that the detached root data is always an empty string.
65
- *
66
- * @param options Additional configuration for the retrieved data.
67
- * Editor features may introduce more configuration options that can be set through this parameter.
68
- * @param options.rootName Root name. Default to `'main'`.
69
- * @param options.trim Whether returned data should be trimmed. This option is set to `'empty'` by default,
70
- * which means that whenever editor content is considered empty, an empty string is returned. To turn off trimming
71
- * use `'none'`. In such cases exact content will be returned (for example `'<p>&nbsp;</p>'` for an empty editor).
72
- * @returns Output data.
73
- */
74
- getData(options?: Record<string, unknown>): string;
75
- }
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
+ * If your editor implementation uses multiple roots, you should pass an object with keys corresponding
31
+ * to the editor root names and values equal to the data that should be set in each root:
32
+ *
33
+ * ```ts
34
+ * editor.setData( {
35
+ * header: '<p>Content for header part.</p>',
36
+ * content: '<p>Content for main part.</p>',
37
+ * footer: '<p>Content for footer part.</p>'
38
+ * } );
39
+ * ```
40
+ *
41
+ * By default the editor accepts HTML. This can be controlled by injecting a different data processor.
42
+ * See the {@glink features/markdown Markdown output} guide for more details.
43
+ *
44
+ * @param data Input data.
45
+ */
46
+ setData(data: string | Record<string, string>): void;
47
+ /**
48
+ * Gets the data from the editor.
49
+ *
50
+ * ```ts
51
+ * editor.getData(); // -> '<p>This is editor!</p>'
52
+ * ```
53
+ *
54
+ * If your editor implementation uses multiple roots, you should pass root name as one of the options:
55
+ *
56
+ * ```ts
57
+ * editor.getData( { rootName: 'header' } ); // -> '<p>Content for header part.</p>'
58
+ * ```
59
+ *
60
+ * By default, the editor outputs HTML. This can be controlled by injecting a different data processor.
61
+ * See the {@glink features/markdown Markdown output} guide for more details.
62
+ *
63
+ * A warning is logged when you try to retrieve data for a detached root, as most probably this is a mistake. A detached root should
64
+ * be treated like it is removed, and you should not save its data. Note, that the detached root data is always an empty string.
65
+ *
66
+ * @param options Additional configuration for the retrieved data.
67
+ * Editor features may introduce more configuration options that can be set through this parameter.
68
+ * @param options.rootName Root name. Default to `'main'`.
69
+ * @param options.trim Whether returned data should be trimmed. This option is set to `'empty'` by default,
70
+ * which means that whenever editor content is considered empty, an empty string is returned. To turn off trimming
71
+ * use `'none'`. In such cases exact content will be returned (for example `'<p>&nbsp;</p>'` for an empty editor).
72
+ * @returns Output data.
73
+ */
74
+ getData(options?: Record<string, unknown>): string;
75
+ }
@@ -1,24 +1,24 @@
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
- * Implementation of the {@link module:core/editor/utils/dataapimixin~DataApi}.
7
- */
8
- export default function DataApiMixin(base) {
9
- class Mixin extends base {
10
- setData(data) {
11
- this.data.set(data);
12
- }
13
- getData(options) {
14
- return this.data.get(options);
15
- }
16
- }
17
- return Mixin;
18
- }
19
- // Backward compatibility with `mix`.
20
- {
21
- const mixin = DataApiMixin(Object);
22
- DataApiMixin.setData = mixin.prototype.setData;
23
- DataApiMixin.getData = mixin.prototype.getData;
24
- }
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
+ * Implementation of the {@link module:core/editor/utils/dataapimixin~DataApi}.
7
+ */
8
+ export default function DataApiMixin(base) {
9
+ class Mixin extends base {
10
+ setData(data) {
11
+ this.data.set(data);
12
+ }
13
+ getData(options) {
14
+ return this.data.get(options);
15
+ }
16
+ }
17
+ return Mixin;
18
+ }
19
+ // Backward compatibility with `mix`.
20
+ {
21
+ const mixin = DataApiMixin(Object);
22
+ DataApiMixin.setData = mixin.prototype.setData;
23
+ DataApiMixin.getData = mixin.prototype.getData;
24
+ }
@@ -1,31 +1,35 @@
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
- }
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 if the
29
+ * {@link module:core/editor/editorconfig~EditorConfig#updateSourceElementOnDestroy `updateSourceElementOnDestroy`}
30
+ * configuration option is set to `true`.
31
+ *
32
+ * @param data Data that the {@link #sourceElement editor source element} should be updated with.
33
+ */
34
+ updateSourceElement(data?: string): void;
35
+ }
@@ -1,42 +1,43 @@
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 { CKEditorError, setDataInElement } from '@ckeditor/ckeditor5-utils';
9
- /**
10
- * Implementation of the {@link module:core/editor/utils/elementapimixin~ElementApi}.
11
- */
12
- export default function ElementApiMixin(base) {
13
- class Mixin extends base {
14
- updateSourceElement(data = this.data.get()) {
15
- if (!this.sourceElement) {
16
- /**
17
- * Cannot update the source element of a detached editor.
18
- *
19
- * The {@link module:core/editor/utils/elementapimixin~ElementApi#updateSourceElement `updateSourceElement()`}
20
- * method cannot be called if you did not pass an element to `Editor.create()`.
21
- *
22
- * @error editor-missing-sourceelement
23
- */
24
- throw new CKEditorError('editor-missing-sourceelement', this);
25
- }
26
- const shouldUpdateSourceElement = this.config.get('updateSourceElementOnDestroy');
27
- const isSourceElementTextArea = this.sourceElement instanceof HTMLTextAreaElement;
28
- // The data returned by the editor might be unsafe, so we want to prevent rendering
29
- // unsafe content inside the source element different than <textarea>, which is considered
30
- // secure. This behaviour could be changed by setting the `updateSourceElementOnDestroy`
31
- // configuration option to `true`.
32
- if (!shouldUpdateSourceElement && !isSourceElementTextArea) {
33
- setDataInElement(this.sourceElement, '');
34
- return;
35
- }
36
- setDataInElement(this.sourceElement, data);
37
- }
38
- }
39
- return Mixin;
40
- }
41
- // Backward compatibility with `mix`.
42
- ElementApiMixin.updateSourceElement = ElementApiMixin(Object).prototype.updateSourceElement;
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 { CKEditorError, setDataInElement } from '@ckeditor/ckeditor5-utils';
9
+ /**
10
+ * Implementation of the {@link module:core/editor/utils/elementapimixin~ElementApi}.
11
+ */
12
+ export default function ElementApiMixin(base) {
13
+ class Mixin extends base {
14
+ updateSourceElement(data) {
15
+ if (!this.sourceElement) {
16
+ /**
17
+ * Cannot update the source element of a detached editor.
18
+ *
19
+ * The {@link module:core/editor/utils/elementapimixin~ElementApi#updateSourceElement `updateSourceElement()`}
20
+ * method cannot be called if you did not pass an element to `Editor.create()`.
21
+ *
22
+ * @error editor-missing-sourceelement
23
+ */
24
+ throw new CKEditorError('editor-missing-sourceelement', this);
25
+ }
26
+ const shouldUpdateSourceElement = this.config.get('updateSourceElementOnDestroy');
27
+ const isSourceElementTextArea = this.sourceElement instanceof HTMLTextAreaElement;
28
+ // The data returned by the editor might be unsafe, so we want to prevent rendering
29
+ // unsafe content inside the source element different than <textarea>, which is considered
30
+ // secure. This behavior could be changed by setting the `updateSourceElementOnDestroy`
31
+ // configuration option to `true`.
32
+ if (!shouldUpdateSourceElement && !isSourceElementTextArea) {
33
+ setDataInElement(this.sourceElement, '');
34
+ return;
35
+ }
36
+ const dataToSet = typeof data === 'string' ? data : this.data.get();
37
+ setDataInElement(this.sourceElement, dataToSet);
38
+ }
39
+ }
40
+ return Mixin;
41
+ }
42
+ // Backward compatibility with `mix`.
43
+ ElementApiMixin.updateSourceElement = ElementApiMixin(Object).prototype.updateSourceElement;
@@ -1,17 +1,17 @@
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
- /**
7
- * Marks the source element on which the editor was initialized. This prevents other editor instances from using this element.
8
- *
9
- * Running multiple editor instances on the same source element causes various issues and it is
10
- * crucial this helper is called as soon as the source element is known to prevent collisions.
11
- *
12
- * @param editor Editor instance.
13
- * @param sourceElement Element to bind with the editor instance.
14
- */
15
- export default function secureSourceElement(editor: Editor, sourceElement: HTMLElement & {
16
- ckeditorInstance?: Editor;
17
- }): void;
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
+ /**
7
+ * Marks the source element on which the editor was initialized. This prevents other editor instances from using this element.
8
+ *
9
+ * Running multiple editor instances on the same source element causes various issues and it is
10
+ * crucial this helper is called as soon as the source element is known to prevent collisions.
11
+ *
12
+ * @param editor Editor instance.
13
+ * @param sourceElement Element to bind with the editor instance.
14
+ */
15
+ export default function secureSourceElement(editor: Editor, sourceElement: HTMLElement & {
16
+ ckeditorInstance?: Editor;
17
+ }): void;
@@ -1,35 +1,35 @@
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/securesourceelement
7
- */
8
- import { CKEditorError } from '@ckeditor/ckeditor5-utils';
9
- /**
10
- * Marks the source element on which the editor was initialized. This prevents other editor instances from using this element.
11
- *
12
- * Running multiple editor instances on the same source element causes various issues and it is
13
- * crucial this helper is called as soon as the source element is known to prevent collisions.
14
- *
15
- * @param editor Editor instance.
16
- * @param sourceElement Element to bind with the editor instance.
17
- */
18
- export default function secureSourceElement(editor, sourceElement) {
19
- if (sourceElement.ckeditorInstance) {
20
- /**
21
- * A DOM element used to create the editor (e.g.
22
- * {@link module:editor-inline/inlineeditor~InlineEditor.create `InlineEditor.create()`})
23
- * has already been used to create another editor instance. Make sure each editor is
24
- * created with an unique DOM element.
25
- *
26
- * @error editor-source-element-already-used
27
- * @param element DOM element that caused the collision.
28
- */
29
- throw new CKEditorError('editor-source-element-already-used', editor);
30
- }
31
- sourceElement.ckeditorInstance = editor;
32
- editor.once('destroy', () => {
33
- delete sourceElement.ckeditorInstance;
34
- });
35
- }
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/securesourceelement
7
+ */
8
+ import { CKEditorError } from '@ckeditor/ckeditor5-utils';
9
+ /**
10
+ * Marks the source element on which the editor was initialized. This prevents other editor instances from using this element.
11
+ *
12
+ * Running multiple editor instances on the same source element causes various issues and it is
13
+ * crucial this helper is called as soon as the source element is known to prevent collisions.
14
+ *
15
+ * @param editor Editor instance.
16
+ * @param sourceElement Element to bind with the editor instance.
17
+ */
18
+ export default function secureSourceElement(editor, sourceElement) {
19
+ if (sourceElement.ckeditorInstance) {
20
+ /**
21
+ * A DOM element used to create the editor (e.g.
22
+ * {@link module:editor-inline/inlineeditor~InlineEditor.create `InlineEditor.create()`})
23
+ * has already been used to create another editor instance. Make sure each editor is
24
+ * created with an unique DOM element.
25
+ *
26
+ * @error editor-source-element-already-used
27
+ * @param element DOM element that caused the collision.
28
+ */
29
+ throw new CKEditorError('editor-source-element-already-used', editor);
30
+ }
31
+ sourceElement.ckeditorInstance = editor;
32
+ editor.once('destroy', () => {
33
+ delete sourceElement.ckeditorInstance;
34
+ });
35
+ }