@ckeditor/ckeditor5-html-support 48.2.0-alpha.7 → 48.3.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.
@@ -1,108 +1,108 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
- */
2
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
+ */
5
5
  /**
6
- * @module html-support/generalhtmlsupport
7
- */
8
- import { Plugin } from '@ckeditor/ckeditor5-core';
9
- import { type ArrayOrItem } from '@ckeditor/ckeditor5-utils';
10
- import { DataFilter } from './datafilter.js';
11
- import { CodeBlockElementSupport } from './integrations/codeblock.js';
12
- import { DualContentModelElementSupport } from './integrations/dualcontent.js';
13
- import { HeadingElementSupport } from './integrations/heading.js';
14
- import { ImageElementSupport } from './integrations/image.js';
15
- import { MediaEmbedElementSupport } from './integrations/mediaembed.js';
16
- import { ScriptElementSupport } from './integrations/script.js';
17
- import { TableElementSupport } from './integrations/table.js';
18
- import { StyleElementSupport } from './integrations/style.js';
19
- import { ListElementSupport } from './integrations/list.js';
20
- import { HorizontalLineElementSupport } from './integrations/horizontalline.js';
21
- import { IframeElementSupport } from './integrations/iframe.js';
22
- import { CustomElementSupport } from './integrations/customelement.js';
23
- import type { ModelSelectable } from '@ckeditor/ckeditor5-engine';
6
+ * @module html-support/generalhtmlsupport
7
+ */
8
+ import { Plugin, type PluginDependenciesOf } from "@ckeditor/ckeditor5-core";
9
+ import { type ArrayOrItem } from "@ckeditor/ckeditor5-utils";
10
+ import { DataFilter } from "./datafilter.js";
11
+ import { CodeBlockElementSupport } from "./integrations/codeblock.js";
12
+ import { DualContentModelElementSupport } from "./integrations/dualcontent.js";
13
+ import { HeadingElementSupport } from "./integrations/heading.js";
14
+ import { ImageElementSupport } from "./integrations/image.js";
15
+ import { MediaEmbedElementSupport } from "./integrations/mediaembed.js";
16
+ import { ScriptElementSupport } from "./integrations/script.js";
17
+ import { TableElementSupport } from "./integrations/table.js";
18
+ import { StyleElementSupport } from "./integrations/style.js";
19
+ import { ListElementSupport } from "./integrations/list.js";
20
+ import { HorizontalLineElementSupport } from "./integrations/horizontalline.js";
21
+ import { IframeElementSupport } from "./integrations/iframe.js";
22
+ import { CustomElementSupport } from "./integrations/customelement.js";
23
+ import type { ModelSelectable } from "@ckeditor/ckeditor5-engine";
24
24
  /**
25
- * The General HTML Support feature.
26
- *
27
- * This is a "glue" plugin which initializes the {@link module:html-support/datafilter~DataFilter data filter} configuration
28
- * and features integration with the General HTML Support.
29
- */
25
+ * The General HTML Support feature.
26
+ *
27
+ * This is a "glue" plugin which initializes the {@link module:html-support/datafilter~DataFilter data filter} configuration
28
+ * and features integration with the General HTML Support.
29
+ */
30
30
  export declare class GeneralHtmlSupport extends Plugin {
31
- /**
32
- * @inheritDoc
33
- */
34
- static get pluginName(): "GeneralHtmlSupport";
35
- /**
36
- * @inheritDoc
37
- */
38
- static get isOfficialPlugin(): true;
39
- /**
40
- * @inheritDoc
41
- */
42
- static get requires(): readonly [typeof DataFilter, typeof CodeBlockElementSupport, typeof DualContentModelElementSupport, typeof HeadingElementSupport, typeof ImageElementSupport, typeof MediaEmbedElementSupport, typeof ScriptElementSupport, typeof TableElementSupport, typeof StyleElementSupport, typeof ListElementSupport, typeof HorizontalLineElementSupport, typeof IframeElementSupport, typeof CustomElementSupport];
43
- /**
44
- * @inheritDoc
45
- */
46
- init(): void;
47
- /**
48
- * @inheritDoc
49
- */
50
- afterInit(): void;
51
- /**
52
- * Returns a GHS model attribute name related to a given view element name.
53
- *
54
- * @internal
55
- * @param viewElementName A view element name.
56
- */
57
- getGhsAttributeNameForElement(viewElementName: string): string;
58
- /**
59
- * Updates GHS model attribute for a specified view element name, so it includes the given class name.
60
- *
61
- * @internal
62
- * @param viewElementName A view element name.
63
- * @param className The css class to add.
64
- * @param selectable The selection or element to update.
65
- */
66
- addModelHtmlClass(viewElementName: string, className: ArrayOrItem<string>, selectable: ModelSelectable): void;
67
- /**
68
- * Updates GHS model attribute for a specified view element name, so it does not include the given class name.
69
- *
70
- * @internal
71
- * @param viewElementName A view element name.
72
- * @param className The css class to remove.
73
- * @param selectable The selection or element to update.
74
- */
75
- removeModelHtmlClass(viewElementName: string, className: ArrayOrItem<string>, selectable: ModelSelectable): void;
76
- /**
77
- * Updates GHS model attribute for a specified view element name, so it includes the given attribute.
78
- *
79
- * @param viewElementName A view element name.
80
- * @param attributes The object with attributes to set.
81
- * @param selectable The selection or element to update.
82
- */
83
- private setModelHtmlAttributes;
84
- /**
85
- * Updates GHS model attribute for a specified view element name, so it does not include the given attribute.
86
- *
87
- * @param viewElementName A view element name.
88
- * @param attributeName The attribute name (or names) to remove.
89
- * @param selectable The selection or element to update.
90
- */
91
- private removeModelHtmlAttributes;
92
- /**
93
- * Updates GHS model attribute for a specified view element name, so it includes a given style.
94
- *
95
- * @param viewElementName A view element name.
96
- * @param styles The object with styles to set.
97
- * @param selectable The selection or element to update.
98
- */
99
- private setModelHtmlStyles;
100
- /**
101
- * Updates GHS model attribute for a specified view element name, so it does not include a given style.
102
- *
103
- * @param viewElementName A view element name.
104
- * @param properties The style (or styles list) to remove.
105
- * @param selectable The selection or element to update.
106
- */
107
- private removeModelHtmlStyles;
31
+ /**
32
+ * @inheritDoc
33
+ */
34
+ static get pluginName(): "GeneralHtmlSupport";
35
+ /**
36
+ * @inheritDoc
37
+ */
38
+ static override get isOfficialPlugin(): true;
39
+ /**
40
+ * @inheritDoc
41
+ */
42
+ static get requires(): PluginDependenciesOf<[DataFilter, CodeBlockElementSupport, DualContentModelElementSupport, HeadingElementSupport, ImageElementSupport, MediaEmbedElementSupport, ScriptElementSupport, TableElementSupport, StyleElementSupport, ListElementSupport, HorizontalLineElementSupport, IframeElementSupport, CustomElementSupport]>;
43
+ /**
44
+ * @inheritDoc
45
+ */
46
+ init(): void;
47
+ /**
48
+ * @inheritDoc
49
+ */
50
+ afterInit(): void;
51
+ /**
52
+ * Returns a GHS model attribute name related to a given view element name.
53
+ *
54
+ * @internal
55
+ * @param viewElementName A view element name.
56
+ */
57
+ getGhsAttributeNameForElement(viewElementName: string): string;
58
+ /**
59
+ * Updates GHS model attribute for a specified view element name, so it includes the given class name.
60
+ *
61
+ * @internal
62
+ * @param viewElementName A view element name.
63
+ * @param className The css class to add.
64
+ * @param selectable The selection or element to update.
65
+ */
66
+ addModelHtmlClass(viewElementName: string, className: ArrayOrItem<string>, selectable: ModelSelectable): void;
67
+ /**
68
+ * Updates GHS model attribute for a specified view element name, so it does not include the given class name.
69
+ *
70
+ * @internal
71
+ * @param viewElementName A view element name.
72
+ * @param className The css class to remove.
73
+ * @param selectable The selection or element to update.
74
+ */
75
+ removeModelHtmlClass(viewElementName: string, className: ArrayOrItem<string>, selectable: ModelSelectable): void;
76
+ /**
77
+ * Updates GHS model attribute for a specified view element name, so it includes the given attribute.
78
+ *
79
+ * @param viewElementName A view element name.
80
+ * @param attributes The object with attributes to set.
81
+ * @param selectable The selection or element to update.
82
+ */
83
+ private setModelHtmlAttributes;
84
+ /**
85
+ * Updates GHS model attribute for a specified view element name, so it does not include the given attribute.
86
+ *
87
+ * @param viewElementName A view element name.
88
+ * @param attributeName The attribute name (or names) to remove.
89
+ * @param selectable The selection or element to update.
90
+ */
91
+ private removeModelHtmlAttributes;
92
+ /**
93
+ * Updates GHS model attribute for a specified view element name, so it includes a given style.
94
+ *
95
+ * @param viewElementName A view element name.
96
+ * @param styles The object with styles to set.
97
+ * @param selectable The selection or element to update.
98
+ */
99
+ private setModelHtmlStyles;
100
+ /**
101
+ * Updates GHS model attribute for a specified view element name, so it does not include a given style.
102
+ *
103
+ * @param viewElementName A view element name.
104
+ * @param properties The style (or styles list) to remove.
105
+ * @param selectable The selection or element to update.
106
+ */
107
+ private removeModelHtmlStyles;
108
108
  }
@@ -1,209 +1,209 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
- */
2
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
+ */
5
5
  /**
6
- * @module html-support/generalhtmlsupportconfig
7
- */
8
- import type { MatcherObjectPattern } from '@ckeditor/ckeditor5-engine';
6
+ * @module html-support/generalhtmlsupportconfig
7
+ */
8
+ import type { MatcherObjectPattern } from "@ckeditor/ckeditor5-engine";
9
9
  /**
10
- * The configuration of the General HTML Support feature.
11
- * The option is used by the {@link module:html-support/generalhtmlsupport~GeneralHtmlSupport} feature.
12
- *
13
- * ```ts
14
- * ClassicEditor
15
- * .create( {
16
- * htmlSupport: ... // General HTML Support feature config.
17
- * } )
18
- * .then( ... )
19
- * .catch( ... );
20
- * ```
21
- *
22
- * See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
23
- */
10
+ * The configuration of the General HTML Support feature.
11
+ * The option is used by the {@link module:html-support/generalhtmlsupport~GeneralHtmlSupport} feature.
12
+ *
13
+ * ```ts
14
+ * ClassicEditor
15
+ * .create( {
16
+ * htmlSupport: ... // General HTML Support feature config.
17
+ * } )
18
+ * .then( ... )
19
+ * .catch( ... );
20
+ * ```
21
+ *
22
+ * See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
23
+ */
24
24
  export interface GeneralHtmlSupportConfig {
25
- /**
26
- * The configuration of allowed content rules used by General HTML Support.
27
- *
28
- * Setting this configuration option will enable HTML features that are not explicitly supported by any other
29
- * dedicated CKEditor 5 features.
30
- *
31
- * ```ts
32
- * const htmlSupportConfig.allow = [
33
- * {
34
- * name: 'div', // Enable 'div' element support,
35
- * classes: [ 'special-container' ], // allow 'special-container' class,
36
- * styles: 'background', // allow 'background' style,
37
- * attributes: true // allow any attribute (can be empty).
38
- * },
39
- * {
40
- * name: 'p', // Extend existing Paragraph feature,
41
- * classes: 'highlighted' // with 'highlighted' class,
42
- * attributes: [
43
- * { key: 'data-i18n-context, value: true } // and i18n attribute.
44
- * ]
45
- * }
46
- * ];
47
- * ```
48
- */
49
- allow?: Array<MatcherObjectPattern>;
50
- /**
51
- * The configuration of disallowed content rules used by General HTML Support.
52
- *
53
- * Setting this configuration option will disable listed HTML features.
54
- *
55
- * ```ts
56
- * const htmlSupportConfig.disallow = [
57
- * {
58
- * name: /[\s\S]+/ // For every HTML feature,
59
- * attributes: {
60
- * key: /^on.*$/ // disable 'on*' attributes, like 'onClick', 'onError' etc.
61
- * }
62
- * }
63
- * ];
64
- * ```
65
- */
66
- disallow?: Array<MatcherObjectPattern>;
67
- /**
68
- * The configuration of allowed empty inline elements that should not be removed.
69
- *
70
- * Note that you should also add an appropriate entry to {@link #allow} list.
71
- *
72
- * ```ts
73
- * const htmlSupportConfig.allowEmpty = [ 'i', 'span' ];
74
- * ```
75
- */
76
- allowEmpty?: Array<string>;
77
- /**
78
- * Whether a filler text (non-breaking space entity — `&nbsp;`) will be inserted into empty block elements in HTML output.
79
- * This is used to render block elements properly with line-height.
80
- *
81
- * When set to `true`, empty blocks will be preserved in the editing view.
82
- * When `false` (default), empty blocks are only preserved in the data output.
83
- *
84
- * The option is used by the {@link module:html-support/emptyblock~EmptyBlock} feature.
85
- *
86
- * @default false
87
- */
88
- preserveEmptyBlocksInEditingView?: boolean;
89
- /**
90
- * The configuration of the Full page editing feature.
91
- * The option is used by the {@link module:html-support/fullpage~FullPage} feature.
92
- *
93
- * ```ts
94
- * ClassicEditor
95
- * .create( {
96
- * htmlSupport: {
97
- * fullPage: ... // Full page feature config.
98
- * }
99
- * } )
100
- * .then( ... )
101
- * .catch( ... );
102
- * ```
103
- */
104
- fullPage?: GHSFullPageConfig;
105
- /**
106
- * Controls the `sandbox` attribute on iframe elements by specifying allowed sandbox flags.
107
- *
108
- * **Note:** This option only affects the editing view and does not modify the data output.
109
- *
110
- * When set to `false`:
111
- *
112
- * * The sandbox attribute will not be modified or added to iframe elements.
113
- *
114
- * When set to `true`:
115
- *
116
- * * All restrictions are enforced by adding an empty `sandbox` attribute to iframe elements.
117
- *
118
- * When set to an array of strings:
119
- *
120
- * * Only the specified sandbox flags will be preserved on iframe elements.
121
- * * Any sandbox flags not in the list will be automatically removed.
122
- * * If an empty array is provided, the `sandbox` attribute will be added with no flags (enforcing all restrictions).
123
- *
124
- * ```ts
125
- * ClassicEditor
126
- * .create( {
127
- * htmlSupport: {
128
- * // All restrictions are enforced (empty sandbox attribute).
129
- * htmlIframeSandbox: true
130
- * }
131
- * } )
132
- * .then( ... )
133
- * .catch( ... );
134
- * ```
135
- *
136
- * @default true
137
- */
138
- htmlIframeSandbox?: boolean | Array<string>;
25
+ /**
26
+ * The configuration of allowed content rules used by General HTML Support.
27
+ *
28
+ * Setting this configuration option will enable HTML features that are not explicitly supported by any other
29
+ * dedicated CKEditor 5 features.
30
+ *
31
+ * ```ts
32
+ * const htmlSupportConfig.allow = [
33
+ * {
34
+ * name: 'div', // Enable 'div' element support,
35
+ * classes: [ 'special-container' ], // allow 'special-container' class,
36
+ * styles: 'background', // allow 'background' style,
37
+ * attributes: true // allow any attribute (can be empty).
38
+ * },
39
+ * {
40
+ * name: 'p', // Extend existing Paragraph feature,
41
+ * classes: 'highlighted' // with 'highlighted' class,
42
+ * attributes: [
43
+ * { key: 'data-i18n-context, value: true } // and i18n attribute.
44
+ * ]
45
+ * }
46
+ * ];
47
+ * ```
48
+ */
49
+ allow?: Array<MatcherObjectPattern>;
50
+ /**
51
+ * The configuration of disallowed content rules used by General HTML Support.
52
+ *
53
+ * Setting this configuration option will disable listed HTML features.
54
+ *
55
+ * ```ts
56
+ * const htmlSupportConfig.disallow = [
57
+ * {
58
+ * name: /[\s\S]+/ // For every HTML feature,
59
+ * attributes: {
60
+ * key: /^on.*$/ // disable 'on*' attributes, like 'onClick', 'onError' etc.
61
+ * }
62
+ * }
63
+ * ];
64
+ * ```
65
+ */
66
+ disallow?: Array<MatcherObjectPattern>;
67
+ /**
68
+ * The configuration of allowed empty inline elements that should not be removed.
69
+ *
70
+ * Note that you should also add an appropriate entry to {@link #allow} list.
71
+ *
72
+ * ```ts
73
+ * const htmlSupportConfig.allowEmpty = [ 'i', 'span' ];
74
+ * ```
75
+ */
76
+ allowEmpty?: Array<string>;
77
+ /**
78
+ * Whether a filler text (non-breaking space entity — `&nbsp;`) will be inserted into empty block elements in HTML output.
79
+ * This is used to render block elements properly with line-height.
80
+ *
81
+ * When set to `true`, empty blocks will be preserved in the editing view.
82
+ * When `false` (default), empty blocks are only preserved in the data output.
83
+ *
84
+ * The option is used by the {@link module:html-support/emptyblock~EmptyBlock} feature.
85
+ *
86
+ * @default false
87
+ */
88
+ preserveEmptyBlocksInEditingView?: boolean;
89
+ /**
90
+ * The configuration of the Full page editing feature.
91
+ * The option is used by the {@link module:html-support/fullpage~FullPage} feature.
92
+ *
93
+ * ```ts
94
+ * ClassicEditor
95
+ * .create( {
96
+ * htmlSupport: {
97
+ * fullPage: ... // Full page feature config.
98
+ * }
99
+ * } )
100
+ * .then( ... )
101
+ * .catch( ... );
102
+ * ```
103
+ */
104
+ fullPage?: GHSFullPageConfig;
105
+ /**
106
+ * Controls the `sandbox` attribute on iframe elements by specifying allowed sandbox flags.
107
+ *
108
+ * **Note:** This option only affects the editing view and does not modify the data output.
109
+ *
110
+ * When set to `false`:
111
+ *
112
+ * * The sandbox attribute will not be modified or added to iframe elements.
113
+ *
114
+ * When set to `true`:
115
+ *
116
+ * * All restrictions are enforced by adding an empty `sandbox` attribute to iframe elements.
117
+ *
118
+ * When set to an array of strings:
119
+ *
120
+ * * Only the specified sandbox flags will be preserved on iframe elements.
121
+ * * Any sandbox flags not in the list will be automatically removed.
122
+ * * If an empty array is provided, the `sandbox` attribute will be added with no flags (enforcing all restrictions).
123
+ *
124
+ * ```ts
125
+ * ClassicEditor
126
+ * .create( {
127
+ * htmlSupport: {
128
+ * // All restrictions are enforced (empty sandbox attribute).
129
+ * htmlIframeSandbox: true
130
+ * }
131
+ * } )
132
+ * .then( ... )
133
+ * .catch( ... );
134
+ * ```
135
+ *
136
+ * @default true
137
+ */
138
+ htmlIframeSandbox?: boolean | Array<string>;
139
139
  }
140
140
  /**
141
- * The configuration of the Full page editing feature.
142
- */
141
+ * The configuration of the Full page editing feature.
142
+ */
143
143
  export interface GHSFullPageConfig {
144
- /**
145
- * Whether the feature should allow the editor to render styles from the `<head>` section of editor data content.
146
- *
147
- * When set to `true`, the editor will render styles from the `<head>` section of editor data content.
148
- *
149
- * ```ts
150
- * ClassicEditor
151
- * .create( {
152
- * htmlSupport: {
153
- * fullPage: {
154
- * allowRenderStylesFromHead: true
155
- * }
156
- * }
157
- * } )
158
- * .then( ... )
159
- * .catch( ... );
160
- * ```
161
- *
162
- * @default false
163
- */
164
- allowRenderStylesFromHead?: boolean;
165
- /**
166
- * Callback used to sanitize the CSS provided by the user in editor content
167
- * when option `htmlSupport.fullPage.allowRenderStylesFromHead` is set to `true`.
168
- *
169
- * We strongly recommend overwriting the default function to avoid XSS vulnerabilities.
170
- *
171
- * The function receives the CSS (as a string), and should return an object
172
- * that matches the {@link module:html-support/generalhtmlsupportconfig~GHSCssSanitizeOutput} interface.
173
- *
174
- * ```ts
175
- * ClassicEditor
176
- * .create( {
177
- * htmlSupport: {
178
- * fullPage: {
179
- * allowRenderStylesFromHead: true,
180
- *
181
- * sanitizeCss( CssString ) {
182
- * const sanitizedCss = sanitize( CssString );
183
- *
184
- * return {
185
- * css: sanitizedCss,
186
- * // true or false depending on whether the sanitizer stripped anything.
187
- * hasChanged: ...
188
- * };
189
- * }
190
- * }
191
- * }
192
- * } )
193
- * .then( ... )
194
- * .catch( ... );
195
- * ```
196
- *
197
- */
198
- sanitizeCss?: (css: string) => GHSCssSanitizeOutput;
144
+ /**
145
+ * Whether the feature should allow the editor to render styles from the `<head>` section of editor data content.
146
+ *
147
+ * When set to `true`, the editor will render styles from the `<head>` section of editor data content.
148
+ *
149
+ * ```ts
150
+ * ClassicEditor
151
+ * .create( {
152
+ * htmlSupport: {
153
+ * fullPage: {
154
+ * allowRenderStylesFromHead: true
155
+ * }
156
+ * }
157
+ * } )
158
+ * .then( ... )
159
+ * .catch( ... );
160
+ * ```
161
+ *
162
+ * @default false
163
+ */
164
+ allowRenderStylesFromHead?: boolean;
165
+ /**
166
+ * Callback used to sanitize the CSS provided by the user in editor content
167
+ * when option `htmlSupport.fullPage.allowRenderStylesFromHead` is set to `true`.
168
+ *
169
+ * We strongly recommend overwriting the default function to avoid XSS vulnerabilities.
170
+ *
171
+ * The function receives the CSS (as a string), and should return an object
172
+ * that matches the {@link module:html-support/generalhtmlsupportconfig~GHSCssSanitizeOutput} interface.
173
+ *
174
+ * ```ts
175
+ * ClassicEditor
176
+ * .create( {
177
+ * htmlSupport: {
178
+ * fullPage: {
179
+ * allowRenderStylesFromHead: true,
180
+ *
181
+ * sanitizeCss( CssString ) {
182
+ * const sanitizedCss = sanitize( CssString );
183
+ *
184
+ * return {
185
+ * css: sanitizedCss,
186
+ * // true or false depending on whether the sanitizer stripped anything.
187
+ * hasChanged: ...
188
+ * };
189
+ * }
190
+ * }
191
+ * }
192
+ * } )
193
+ * .then( ... )
194
+ * .catch( ... );
195
+ * ```
196
+ *
197
+ */
198
+ sanitizeCss?: (css: string) => GHSCssSanitizeOutput;
199
199
  }
200
200
  export interface GHSCssSanitizeOutput {
201
- /**
202
- * An output (safe) CSS that will be inserted into the document.
203
- */
204
- css: string;
205
- /**
206
- * A flag that indicates whether the output CSS is different than the input value.
207
- */
208
- hasChanged: boolean;
201
+ /**
202
+ * An output (safe) CSS that will be inserted into the document.
203
+ */
204
+ css: string;
205
+ /**
206
+ * A flag that indicates whether the output CSS is different than the input value.
207
+ */
208
+ hasChanged: boolean;
209
209
  }