@ckeditor/ckeditor5-html-support 39.0.2 → 40.0.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 (49) hide show
  1. package/build/html-support.js +1 -1
  2. package/build/html-support.js.map +1 -0
  3. package/package.json +2 -2
  4. package/src/augmentation.d.ts +33 -33
  5. package/src/augmentation.js +5 -5
  6. package/src/converters.d.ts +60 -60
  7. package/src/converters.js +180 -180
  8. package/src/datafilter.d.ts +304 -304
  9. package/src/datafilter.js +720 -720
  10. package/src/dataschema.d.ts +183 -183
  11. package/src/dataschema.js +196 -196
  12. package/src/fullpage.d.ts +21 -21
  13. package/src/fullpage.js +80 -80
  14. package/src/generalhtmlsupport.d.ts +98 -98
  15. package/src/generalhtmlsupport.js +240 -240
  16. package/src/generalhtmlsupportconfig.d.ts +77 -77
  17. package/src/generalhtmlsupportconfig.js +5 -5
  18. package/src/htmlcomment.d.ts +71 -71
  19. package/src/htmlcomment.js +218 -218
  20. package/src/htmlpagedataprocessor.d.ts +22 -22
  21. package/src/htmlpagedataprocessor.js +67 -67
  22. package/src/index.d.ts +25 -25
  23. package/src/index.js +14 -14
  24. package/src/integrations/codeblock.d.ts +23 -23
  25. package/src/integrations/codeblock.js +101 -101
  26. package/src/integrations/customelement.d.ts +27 -27
  27. package/src/integrations/customelement.js +146 -146
  28. package/src/integrations/documentlist.d.ts +27 -27
  29. package/src/integrations/documentlist.js +178 -203
  30. package/src/integrations/dualcontent.d.ts +45 -45
  31. package/src/integrations/dualcontent.js +119 -119
  32. package/src/integrations/heading.d.ts +31 -31
  33. package/src/integrations/heading.js +60 -60
  34. package/src/integrations/image.d.ts +26 -26
  35. package/src/integrations/image.js +189 -189
  36. package/src/integrations/integrationutils.d.ts +15 -15
  37. package/src/integrations/integrationutils.js +21 -21
  38. package/src/integrations/mediaembed.d.ts +26 -26
  39. package/src/integrations/mediaembed.js +119 -119
  40. package/src/integrations/script.d.ts +26 -26
  41. package/src/integrations/script.js +59 -59
  42. package/src/integrations/style.d.ts +26 -26
  43. package/src/integrations/style.js +59 -59
  44. package/src/integrations/table.d.ts +23 -23
  45. package/src/integrations/table.js +163 -163
  46. package/src/schemadefinitions.d.ts +13 -13
  47. package/src/schemadefinitions.js +956 -956
  48. package/src/utils.d.ts +72 -72
  49. package/src/utils.js +139 -139
@@ -1,240 +1,240 @@
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 html-support/generalhtmlsupport
7
- */
8
- import { Plugin } from 'ckeditor5/src/core';
9
- import { toArray } from 'ckeditor5/src/utils';
10
- import DataFilter from './datafilter';
11
- import CodeBlockElementSupport from './integrations/codeblock';
12
- import DualContentModelElementSupport from './integrations/dualcontent';
13
- import HeadingElementSupport from './integrations/heading';
14
- import ImageElementSupport from './integrations/image';
15
- import MediaEmbedElementSupport from './integrations/mediaembed';
16
- import ScriptElementSupport from './integrations/script';
17
- import TableElementSupport from './integrations/table';
18
- import StyleElementSupport from './integrations/style';
19
- import DocumentListElementSupport from './integrations/documentlist';
20
- import CustomElementSupport from './integrations/customelement';
21
- import { getHtmlAttributeName, modifyGhsAttribute } from './utils';
22
- /**
23
- * The General HTML Support feature.
24
- *
25
- * This is a "glue" plugin which initializes the {@link module:html-support/datafilter~DataFilter data filter} configuration
26
- * and features integration with the General HTML Support.
27
- */
28
- export default class GeneralHtmlSupport extends Plugin {
29
- /**
30
- * @inheritDoc
31
- */
32
- static get pluginName() {
33
- return 'GeneralHtmlSupport';
34
- }
35
- /**
36
- * @inheritDoc
37
- */
38
- static get requires() {
39
- return [
40
- DataFilter,
41
- CodeBlockElementSupport,
42
- DualContentModelElementSupport,
43
- HeadingElementSupport,
44
- ImageElementSupport,
45
- MediaEmbedElementSupport,
46
- ScriptElementSupport,
47
- TableElementSupport,
48
- StyleElementSupport,
49
- DocumentListElementSupport,
50
- CustomElementSupport
51
- ];
52
- }
53
- /**
54
- * @inheritDoc
55
- */
56
- init() {
57
- const editor = this.editor;
58
- const dataFilter = editor.plugins.get(DataFilter);
59
- // Load the allowed empty inline elements' configuration.
60
- // Note that this modifies DataSchema so must be loaded before registering filtering rules.
61
- dataFilter.loadAllowedEmptyElementsConfig(editor.config.get('htmlSupport.allowEmpty') || []);
62
- // Load the filtering configuration.
63
- dataFilter.loadAllowedConfig(editor.config.get('htmlSupport.allow') || []);
64
- dataFilter.loadDisallowedConfig(editor.config.get('htmlSupport.disallow') || []);
65
- }
66
- /**
67
- * Returns a GHS model attribute name related to a given view element name.
68
- *
69
- * @internal
70
- * @param viewElementName A view element name.
71
- */
72
- getGhsAttributeNameForElement(viewElementName) {
73
- const dataSchema = this.editor.plugins.get('DataSchema');
74
- const definitions = Array.from(dataSchema.getDefinitionsForView(viewElementName, false));
75
- const inlineDefinition = definitions.find(definition => (definition.isInline && !definitions[0].isObject));
76
- if (inlineDefinition) {
77
- return inlineDefinition.model;
78
- }
79
- return getHtmlAttributeName(viewElementName);
80
- }
81
- /**
82
- * Updates GHS model attribute for a specified view element name, so it includes the given class name.
83
- *
84
- * @internal
85
- * @param viewElementName A view element name.
86
- * @param className The css class to add.
87
- * @param selectable The selection or element to update.
88
- */
89
- addModelHtmlClass(viewElementName, className, selectable) {
90
- const model = this.editor.model;
91
- const ghsAttributeName = this.getGhsAttributeNameForElement(viewElementName);
92
- model.change(writer => {
93
- for (const item of getItemsToUpdateGhsAttribute(model, selectable, ghsAttributeName)) {
94
- modifyGhsAttribute(writer, item, ghsAttributeName, 'classes', classes => {
95
- for (const value of toArray(className)) {
96
- classes.add(value);
97
- }
98
- });
99
- }
100
- });
101
- }
102
- /**
103
- * Updates GHS model attribute for a specified view element name, so it does not include the given class name.
104
- *
105
- * @internal
106
- * @param viewElementName A view element name.
107
- * @param className The css class to remove.
108
- * @param selectable The selection or element to update.
109
- */
110
- removeModelHtmlClass(viewElementName, className, selectable) {
111
- const model = this.editor.model;
112
- const ghsAttributeName = this.getGhsAttributeNameForElement(viewElementName);
113
- model.change(writer => {
114
- for (const item of getItemsToUpdateGhsAttribute(model, selectable, ghsAttributeName)) {
115
- modifyGhsAttribute(writer, item, ghsAttributeName, 'classes', classes => {
116
- for (const value of toArray(className)) {
117
- classes.delete(value);
118
- }
119
- });
120
- }
121
- });
122
- }
123
- /**
124
- * Updates GHS model attribute for a specified view element name, so it includes the given attribute.
125
- *
126
- * @param viewElementName A view element name.
127
- * @param attributes The object with attributes to set.
128
- * @param selectable The selection or element to update.
129
- */
130
- setModelHtmlAttributes(viewElementName, attributes, selectable) {
131
- const model = this.editor.model;
132
- const ghsAttributeName = this.getGhsAttributeNameForElement(viewElementName);
133
- model.change(writer => {
134
- for (const item of getItemsToUpdateGhsAttribute(model, selectable, ghsAttributeName)) {
135
- modifyGhsAttribute(writer, item, ghsAttributeName, 'attributes', attributesMap => {
136
- for (const [key, value] of Object.entries(attributes)) {
137
- attributesMap.set(key, value);
138
- }
139
- });
140
- }
141
- });
142
- }
143
- /**
144
- * Updates GHS model attribute for a specified view element name, so it does not include the given attribute.
145
- *
146
- * @param viewElementName A view element name.
147
- * @param attributeName The attribute name (or names) to remove.
148
- * @param selectable The selection or element to update.
149
- */
150
- removeModelHtmlAttributes(viewElementName, attributeName, selectable) {
151
- const model = this.editor.model;
152
- const ghsAttributeName = this.getGhsAttributeNameForElement(viewElementName);
153
- model.change(writer => {
154
- for (const item of getItemsToUpdateGhsAttribute(model, selectable, ghsAttributeName)) {
155
- modifyGhsAttribute(writer, item, ghsAttributeName, 'attributes', attributesMap => {
156
- for (const key of toArray(attributeName)) {
157
- attributesMap.delete(key);
158
- }
159
- });
160
- }
161
- });
162
- }
163
- /**
164
- * Updates GHS model attribute for a specified view element name, so it includes a given style.
165
- *
166
- * @param viewElementName A view element name.
167
- * @param styles The object with styles to set.
168
- * @param selectable The selection or element to update.
169
- */
170
- setModelHtmlStyles(viewElementName, styles, selectable) {
171
- const model = this.editor.model;
172
- const ghsAttributeName = this.getGhsAttributeNameForElement(viewElementName);
173
- model.change(writer => {
174
- for (const item of getItemsToUpdateGhsAttribute(model, selectable, ghsAttributeName)) {
175
- modifyGhsAttribute(writer, item, ghsAttributeName, 'styles', stylesMap => {
176
- for (const [key, value] of Object.entries(styles)) {
177
- stylesMap.set(key, value);
178
- }
179
- });
180
- }
181
- });
182
- }
183
- /**
184
- * Updates GHS model attribute for a specified view element name, so it does not include a given style.
185
- *
186
- * @param viewElementName A view element name.
187
- * @param properties The style (or styles list) to remove.
188
- * @param selectable The selection or element to update.
189
- */
190
- removeModelHtmlStyles(viewElementName, properties, selectable) {
191
- const model = this.editor.model;
192
- const ghsAttributeName = this.getGhsAttributeNameForElement(viewElementName);
193
- model.change(writer => {
194
- for (const item of getItemsToUpdateGhsAttribute(model, selectable, ghsAttributeName)) {
195
- modifyGhsAttribute(writer, item, ghsAttributeName, 'styles', stylesMap => {
196
- for (const key of toArray(properties)) {
197
- stylesMap.delete(key);
198
- }
199
- });
200
- }
201
- });
202
- }
203
- }
204
- /**
205
- * Returns an iterator over an items in the selectable that accept given GHS attribute.
206
- */
207
- function* getItemsToUpdateGhsAttribute(model, selectable, ghsAttributeName) {
208
- if (!selectable) {
209
- return;
210
- }
211
- if (!(Symbol.iterator in selectable) && selectable.is('documentSelection') && selectable.isCollapsed) {
212
- if (model.schema.checkAttributeInSelection(selectable, ghsAttributeName)) {
213
- yield selectable;
214
- }
215
- }
216
- else {
217
- for (const range of getValidRangesForSelectable(model, selectable, ghsAttributeName)) {
218
- yield* range.getItems({ shallow: true });
219
- }
220
- }
221
- }
222
- /**
223
- * Translates a given selectable to an iterable of ranges.
224
- */
225
- function getValidRangesForSelectable(model, selectable, ghsAttributeName) {
226
- if (!(Symbol.iterator in selectable) &&
227
- (selectable.is('node') ||
228
- selectable.is('$text') ||
229
- selectable.is('$textProxy'))) {
230
- if (model.schema.checkAttribute(selectable, ghsAttributeName)) {
231
- return [model.createRangeOn(selectable)];
232
- }
233
- else {
234
- return [];
235
- }
236
- }
237
- else {
238
- return model.schema.getValidRanges(model.createSelection(selectable).getRanges(), ghsAttributeName);
239
- }
240
- }
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 html-support/generalhtmlsupport
7
+ */
8
+ import { Plugin } from 'ckeditor5/src/core';
9
+ import { toArray } from 'ckeditor5/src/utils';
10
+ import DataFilter from './datafilter';
11
+ import CodeBlockElementSupport from './integrations/codeblock';
12
+ import DualContentModelElementSupport from './integrations/dualcontent';
13
+ import HeadingElementSupport from './integrations/heading';
14
+ import ImageElementSupport from './integrations/image';
15
+ import MediaEmbedElementSupport from './integrations/mediaembed';
16
+ import ScriptElementSupport from './integrations/script';
17
+ import TableElementSupport from './integrations/table';
18
+ import StyleElementSupport from './integrations/style';
19
+ import DocumentListElementSupport from './integrations/documentlist';
20
+ import CustomElementSupport from './integrations/customelement';
21
+ import { getHtmlAttributeName, modifyGhsAttribute } from './utils';
22
+ /**
23
+ * The General HTML Support feature.
24
+ *
25
+ * This is a "glue" plugin which initializes the {@link module:html-support/datafilter~DataFilter data filter} configuration
26
+ * and features integration with the General HTML Support.
27
+ */
28
+ export default class GeneralHtmlSupport extends Plugin {
29
+ /**
30
+ * @inheritDoc
31
+ */
32
+ static get pluginName() {
33
+ return 'GeneralHtmlSupport';
34
+ }
35
+ /**
36
+ * @inheritDoc
37
+ */
38
+ static get requires() {
39
+ return [
40
+ DataFilter,
41
+ CodeBlockElementSupport,
42
+ DualContentModelElementSupport,
43
+ HeadingElementSupport,
44
+ ImageElementSupport,
45
+ MediaEmbedElementSupport,
46
+ ScriptElementSupport,
47
+ TableElementSupport,
48
+ StyleElementSupport,
49
+ DocumentListElementSupport,
50
+ CustomElementSupport
51
+ ];
52
+ }
53
+ /**
54
+ * @inheritDoc
55
+ */
56
+ init() {
57
+ const editor = this.editor;
58
+ const dataFilter = editor.plugins.get(DataFilter);
59
+ // Load the allowed empty inline elements' configuration.
60
+ // Note that this modifies DataSchema so must be loaded before registering filtering rules.
61
+ dataFilter.loadAllowedEmptyElementsConfig(editor.config.get('htmlSupport.allowEmpty') || []);
62
+ // Load the filtering configuration.
63
+ dataFilter.loadAllowedConfig(editor.config.get('htmlSupport.allow') || []);
64
+ dataFilter.loadDisallowedConfig(editor.config.get('htmlSupport.disallow') || []);
65
+ }
66
+ /**
67
+ * Returns a GHS model attribute name related to a given view element name.
68
+ *
69
+ * @internal
70
+ * @param viewElementName A view element name.
71
+ */
72
+ getGhsAttributeNameForElement(viewElementName) {
73
+ const dataSchema = this.editor.plugins.get('DataSchema');
74
+ const definitions = Array.from(dataSchema.getDefinitionsForView(viewElementName, false));
75
+ const inlineDefinition = definitions.find(definition => (definition.isInline && !definitions[0].isObject));
76
+ if (inlineDefinition) {
77
+ return inlineDefinition.model;
78
+ }
79
+ return getHtmlAttributeName(viewElementName);
80
+ }
81
+ /**
82
+ * Updates GHS model attribute for a specified view element name, so it includes the given class name.
83
+ *
84
+ * @internal
85
+ * @param viewElementName A view element name.
86
+ * @param className The css class to add.
87
+ * @param selectable The selection or element to update.
88
+ */
89
+ addModelHtmlClass(viewElementName, className, selectable) {
90
+ const model = this.editor.model;
91
+ const ghsAttributeName = this.getGhsAttributeNameForElement(viewElementName);
92
+ model.change(writer => {
93
+ for (const item of getItemsToUpdateGhsAttribute(model, selectable, ghsAttributeName)) {
94
+ modifyGhsAttribute(writer, item, ghsAttributeName, 'classes', classes => {
95
+ for (const value of toArray(className)) {
96
+ classes.add(value);
97
+ }
98
+ });
99
+ }
100
+ });
101
+ }
102
+ /**
103
+ * Updates GHS model attribute for a specified view element name, so it does not include the given class name.
104
+ *
105
+ * @internal
106
+ * @param viewElementName A view element name.
107
+ * @param className The css class to remove.
108
+ * @param selectable The selection or element to update.
109
+ */
110
+ removeModelHtmlClass(viewElementName, className, selectable) {
111
+ const model = this.editor.model;
112
+ const ghsAttributeName = this.getGhsAttributeNameForElement(viewElementName);
113
+ model.change(writer => {
114
+ for (const item of getItemsToUpdateGhsAttribute(model, selectable, ghsAttributeName)) {
115
+ modifyGhsAttribute(writer, item, ghsAttributeName, 'classes', classes => {
116
+ for (const value of toArray(className)) {
117
+ classes.delete(value);
118
+ }
119
+ });
120
+ }
121
+ });
122
+ }
123
+ /**
124
+ * Updates GHS model attribute for a specified view element name, so it includes the given attribute.
125
+ *
126
+ * @param viewElementName A view element name.
127
+ * @param attributes The object with attributes to set.
128
+ * @param selectable The selection or element to update.
129
+ */
130
+ setModelHtmlAttributes(viewElementName, attributes, selectable) {
131
+ const model = this.editor.model;
132
+ const ghsAttributeName = this.getGhsAttributeNameForElement(viewElementName);
133
+ model.change(writer => {
134
+ for (const item of getItemsToUpdateGhsAttribute(model, selectable, ghsAttributeName)) {
135
+ modifyGhsAttribute(writer, item, ghsAttributeName, 'attributes', attributesMap => {
136
+ for (const [key, value] of Object.entries(attributes)) {
137
+ attributesMap.set(key, value);
138
+ }
139
+ });
140
+ }
141
+ });
142
+ }
143
+ /**
144
+ * Updates GHS model attribute for a specified view element name, so it does not include the given attribute.
145
+ *
146
+ * @param viewElementName A view element name.
147
+ * @param attributeName The attribute name (or names) to remove.
148
+ * @param selectable The selection or element to update.
149
+ */
150
+ removeModelHtmlAttributes(viewElementName, attributeName, selectable) {
151
+ const model = this.editor.model;
152
+ const ghsAttributeName = this.getGhsAttributeNameForElement(viewElementName);
153
+ model.change(writer => {
154
+ for (const item of getItemsToUpdateGhsAttribute(model, selectable, ghsAttributeName)) {
155
+ modifyGhsAttribute(writer, item, ghsAttributeName, 'attributes', attributesMap => {
156
+ for (const key of toArray(attributeName)) {
157
+ attributesMap.delete(key);
158
+ }
159
+ });
160
+ }
161
+ });
162
+ }
163
+ /**
164
+ * Updates GHS model attribute for a specified view element name, so it includes a given style.
165
+ *
166
+ * @param viewElementName A view element name.
167
+ * @param styles The object with styles to set.
168
+ * @param selectable The selection or element to update.
169
+ */
170
+ setModelHtmlStyles(viewElementName, styles, selectable) {
171
+ const model = this.editor.model;
172
+ const ghsAttributeName = this.getGhsAttributeNameForElement(viewElementName);
173
+ model.change(writer => {
174
+ for (const item of getItemsToUpdateGhsAttribute(model, selectable, ghsAttributeName)) {
175
+ modifyGhsAttribute(writer, item, ghsAttributeName, 'styles', stylesMap => {
176
+ for (const [key, value] of Object.entries(styles)) {
177
+ stylesMap.set(key, value);
178
+ }
179
+ });
180
+ }
181
+ });
182
+ }
183
+ /**
184
+ * Updates GHS model attribute for a specified view element name, so it does not include a given style.
185
+ *
186
+ * @param viewElementName A view element name.
187
+ * @param properties The style (or styles list) to remove.
188
+ * @param selectable The selection or element to update.
189
+ */
190
+ removeModelHtmlStyles(viewElementName, properties, selectable) {
191
+ const model = this.editor.model;
192
+ const ghsAttributeName = this.getGhsAttributeNameForElement(viewElementName);
193
+ model.change(writer => {
194
+ for (const item of getItemsToUpdateGhsAttribute(model, selectable, ghsAttributeName)) {
195
+ modifyGhsAttribute(writer, item, ghsAttributeName, 'styles', stylesMap => {
196
+ for (const key of toArray(properties)) {
197
+ stylesMap.delete(key);
198
+ }
199
+ });
200
+ }
201
+ });
202
+ }
203
+ }
204
+ /**
205
+ * Returns an iterator over an items in the selectable that accept given GHS attribute.
206
+ */
207
+ function* getItemsToUpdateGhsAttribute(model, selectable, ghsAttributeName) {
208
+ if (!selectable) {
209
+ return;
210
+ }
211
+ if (!(Symbol.iterator in selectable) && selectable.is('documentSelection') && selectable.isCollapsed) {
212
+ if (model.schema.checkAttributeInSelection(selectable, ghsAttributeName)) {
213
+ yield selectable;
214
+ }
215
+ }
216
+ else {
217
+ for (const range of getValidRangesForSelectable(model, selectable, ghsAttributeName)) {
218
+ yield* range.getItems({ shallow: true });
219
+ }
220
+ }
221
+ }
222
+ /**
223
+ * Translates a given selectable to an iterable of ranges.
224
+ */
225
+ function getValidRangesForSelectable(model, selectable, ghsAttributeName) {
226
+ if (!(Symbol.iterator in selectable) &&
227
+ (selectable.is('node') ||
228
+ selectable.is('$text') ||
229
+ selectable.is('$textProxy'))) {
230
+ if (model.schema.checkAttribute(selectable, ghsAttributeName)) {
231
+ return [model.createRangeOn(selectable)];
232
+ }
233
+ else {
234
+ return [];
235
+ }
236
+ }
237
+ else {
238
+ return model.schema.getValidRanges(model.createSelection(selectable).getRanges(), ghsAttributeName);
239
+ }
240
+ }
@@ -1,77 +1,77 @@
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 html-support/generalhtmlsupportconfig
7
- */
8
- import type { MatcherObjectPattern } from 'ckeditor5/src/engine';
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
- */
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
- }
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 html-support/generalhtmlsupportconfig
7
+ */
8
+ import type { MatcherObjectPattern } from 'ckeditor5/src/engine';
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
+ */
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
+ }
@@ -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 {};