@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,189 +1,189 @@
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/integrations/image
7
- */
8
- import { Plugin } from 'ckeditor5/src/core';
9
- import DataFilter from '../datafilter';
10
- import { setViewAttributes, updateViewAttributes } from '../utils';
11
- import { getDescendantElement } from './integrationutils';
12
- /**
13
- * Provides the General HTML Support integration with the {@link module:image/image~Image Image} feature.
14
- */
15
- export default class ImageElementSupport extends Plugin {
16
- /**
17
- * @inheritDoc
18
- */
19
- static get requires() {
20
- return [DataFilter];
21
- }
22
- /**
23
- * @inheritDoc
24
- */
25
- static get pluginName() {
26
- return 'ImageElementSupport';
27
- }
28
- /**
29
- * @inheritDoc
30
- */
31
- init() {
32
- const editor = this.editor;
33
- // At least one image plugin should be loaded for the integration to work properly.
34
- if (!editor.plugins.has('ImageInlineEditing') && !editor.plugins.has('ImageBlockEditing')) {
35
- return;
36
- }
37
- const schema = editor.model.schema;
38
- const conversion = editor.conversion;
39
- const dataFilter = editor.plugins.get(DataFilter);
40
- dataFilter.on('register:figure', () => {
41
- conversion.for('upcast').add(viewToModelFigureAttributeConverter(dataFilter));
42
- });
43
- dataFilter.on('register:img', (evt, definition) => {
44
- if (definition.model !== 'imageBlock' && definition.model !== 'imageInline') {
45
- return;
46
- }
47
- if (schema.isRegistered('imageBlock')) {
48
- schema.extend('imageBlock', {
49
- allowAttributes: [
50
- 'htmlImgAttributes',
51
- // Figure and Link don't have model counterpart.
52
- // We will preserve attributes on image model element using these attribute keys.
53
- 'htmlFigureAttributes',
54
- 'htmlLinkAttributes'
55
- ]
56
- });
57
- }
58
- if (schema.isRegistered('imageInline')) {
59
- schema.extend('imageInline', {
60
- allowAttributes: [
61
- // `htmlA` is needed for standard GHS link integration.
62
- 'htmlA',
63
- 'htmlImgAttributes'
64
- ]
65
- });
66
- }
67
- conversion.for('upcast').add(viewToModelImageAttributeConverter(dataFilter));
68
- conversion.for('downcast').add(modelToViewImageAttributeConverter());
69
- if (editor.plugins.has('LinkImage')) {
70
- conversion.for('upcast').add(viewToModelLinkImageAttributeConverter(dataFilter, editor));
71
- }
72
- evt.stop();
73
- });
74
- }
75
- }
76
- /**
77
- * View-to-model conversion helper preserving allowed attributes on the {@link module:image/image~Image Image}
78
- * feature model element.
79
- *
80
- * @returns Returns a conversion callback.
81
- */
82
- function viewToModelImageAttributeConverter(dataFilter) {
83
- return (dispatcher) => {
84
- dispatcher.on('element:img', (evt, data, conversionApi) => {
85
- if (!data.modelRange) {
86
- return;
87
- }
88
- const viewImageElement = data.viewItem;
89
- const viewAttributes = dataFilter.processViewAttributes(viewImageElement, conversionApi);
90
- if (viewAttributes) {
91
- conversionApi.writer.setAttribute('htmlImgAttributes', viewAttributes, data.modelRange);
92
- }
93
- }, { priority: 'low' });
94
- };
95
- }
96
- /**
97
- * View-to-model conversion helper preserving allowed attributes on {@link module:image/image~Image Image}
98
- * feature model element from link view element.
99
- *
100
- * @returns Returns a conversion callback.
101
- */
102
- function viewToModelLinkImageAttributeConverter(dataFilter, editor) {
103
- const imageUtils = editor.plugins.get('ImageUtils');
104
- return (dispatcher) => {
105
- dispatcher.on('element:a', (evt, data, conversionApi) => {
106
- const viewLink = data.viewItem;
107
- const viewImage = imageUtils.findViewImgElement(viewLink);
108
- if (!viewImage) {
109
- return;
110
- }
111
- const modelImage = data.modelCursor.parent;
112
- if (!modelImage.is('element', 'imageBlock')) {
113
- return;
114
- }
115
- const viewAttributes = dataFilter.processViewAttributes(viewLink, conversionApi);
116
- if (viewAttributes) {
117
- conversionApi.writer.setAttribute('htmlLinkAttributes', viewAttributes, modelImage);
118
- }
119
- }, { priority: 'low' });
120
- };
121
- }
122
- /**
123
- * View-to-model conversion helper preserving allowed attributes on {@link module:image/image~Image Image}
124
- * feature model element from figure view element.
125
- *
126
- * @returns Returns a conversion callback.
127
- */
128
- function viewToModelFigureAttributeConverter(dataFilter) {
129
- return (dispatcher) => {
130
- dispatcher.on('element:figure', (evt, data, conversionApi) => {
131
- const viewFigureElement = data.viewItem;
132
- if (!data.modelRange || !viewFigureElement.hasClass('image')) {
133
- return;
134
- }
135
- const viewAttributes = dataFilter.processViewAttributes(viewFigureElement, conversionApi);
136
- if (viewAttributes) {
137
- conversionApi.writer.setAttribute('htmlFigureAttributes', viewAttributes, data.modelRange);
138
- }
139
- }, { priority: 'low' });
140
- };
141
- }
142
- /**
143
- * A model-to-view conversion helper applying attributes from the {@link module:image/image~Image Image}
144
- * feature.
145
- * @returns Returns a conversion callback.
146
- */
147
- function modelToViewImageAttributeConverter() {
148
- return (dispatcher) => {
149
- addInlineAttributeConversion('htmlImgAttributes');
150
- addBlockAttributeConversion('img', 'htmlImgAttributes');
151
- addBlockAttributeConversion('figure', 'htmlFigureAttributes');
152
- addBlockAttributeConversion('a', 'htmlLinkAttributes');
153
- function addInlineAttributeConversion(attributeName) {
154
- dispatcher.on(`attribute:${attributeName}:imageInline`, (evt, data, conversionApi) => {
155
- if (!conversionApi.consumable.consume(data.item, evt.name)) {
156
- return;
157
- }
158
- const { attributeOldValue, attributeNewValue } = data;
159
- const viewElement = conversionApi.mapper.toViewElement(data.item);
160
- updateViewAttributes(conversionApi.writer, attributeOldValue, attributeNewValue, viewElement);
161
- }, { priority: 'low' });
162
- }
163
- function addBlockAttributeConversion(elementName, attributeName) {
164
- dispatcher.on(`attribute:${attributeName}:imageBlock`, (evt, data, conversionApi) => {
165
- if (!conversionApi.consumable.test(data.item, evt.name)) {
166
- return;
167
- }
168
- const { attributeOldValue, attributeNewValue } = data;
169
- const containerElement = conversionApi.mapper.toViewElement(data.item);
170
- const viewElement = getDescendantElement(conversionApi.writer, containerElement, elementName);
171
- if (viewElement) {
172
- updateViewAttributes(conversionApi.writer, attributeOldValue, attributeNewValue, viewElement);
173
- conversionApi.consumable.consume(data.item, evt.name);
174
- }
175
- }, { priority: 'low' });
176
- if (elementName === 'a') {
177
- // To have a link element in the view, we need to attach a converter to the `linkHref` attribute as well.
178
- dispatcher.on('attribute:linkHref:imageBlock', (evt, data, conversionApi) => {
179
- if (!conversionApi.consumable.consume(data.item, 'attribute:htmlLinkAttributes:imageBlock')) {
180
- return;
181
- }
182
- const containerElement = conversionApi.mapper.toViewElement(data.item);
183
- const viewElement = getDescendantElement(conversionApi.writer, containerElement, 'a');
184
- setViewAttributes(conversionApi.writer, data.item.getAttribute('htmlLinkAttributes'), viewElement);
185
- }, { priority: 'low' });
186
- }
187
- }
188
- };
189
- }
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/integrations/image
7
+ */
8
+ import { Plugin } from 'ckeditor5/src/core';
9
+ import DataFilter from '../datafilter';
10
+ import { setViewAttributes, updateViewAttributes } from '../utils';
11
+ import { getDescendantElement } from './integrationutils';
12
+ /**
13
+ * Provides the General HTML Support integration with the {@link module:image/image~Image Image} feature.
14
+ */
15
+ export default class ImageElementSupport extends Plugin {
16
+ /**
17
+ * @inheritDoc
18
+ */
19
+ static get requires() {
20
+ return [DataFilter];
21
+ }
22
+ /**
23
+ * @inheritDoc
24
+ */
25
+ static get pluginName() {
26
+ return 'ImageElementSupport';
27
+ }
28
+ /**
29
+ * @inheritDoc
30
+ */
31
+ init() {
32
+ const editor = this.editor;
33
+ // At least one image plugin should be loaded for the integration to work properly.
34
+ if (!editor.plugins.has('ImageInlineEditing') && !editor.plugins.has('ImageBlockEditing')) {
35
+ return;
36
+ }
37
+ const schema = editor.model.schema;
38
+ const conversion = editor.conversion;
39
+ const dataFilter = editor.plugins.get(DataFilter);
40
+ dataFilter.on('register:figure', () => {
41
+ conversion.for('upcast').add(viewToModelFigureAttributeConverter(dataFilter));
42
+ });
43
+ dataFilter.on('register:img', (evt, definition) => {
44
+ if (definition.model !== 'imageBlock' && definition.model !== 'imageInline') {
45
+ return;
46
+ }
47
+ if (schema.isRegistered('imageBlock')) {
48
+ schema.extend('imageBlock', {
49
+ allowAttributes: [
50
+ 'htmlImgAttributes',
51
+ // Figure and Link don't have model counterpart.
52
+ // We will preserve attributes on image model element using these attribute keys.
53
+ 'htmlFigureAttributes',
54
+ 'htmlLinkAttributes'
55
+ ]
56
+ });
57
+ }
58
+ if (schema.isRegistered('imageInline')) {
59
+ schema.extend('imageInline', {
60
+ allowAttributes: [
61
+ // `htmlA` is needed for standard GHS link integration.
62
+ 'htmlA',
63
+ 'htmlImgAttributes'
64
+ ]
65
+ });
66
+ }
67
+ conversion.for('upcast').add(viewToModelImageAttributeConverter(dataFilter));
68
+ conversion.for('downcast').add(modelToViewImageAttributeConverter());
69
+ if (editor.plugins.has('LinkImage')) {
70
+ conversion.for('upcast').add(viewToModelLinkImageAttributeConverter(dataFilter, editor));
71
+ }
72
+ evt.stop();
73
+ });
74
+ }
75
+ }
76
+ /**
77
+ * View-to-model conversion helper preserving allowed attributes on the {@link module:image/image~Image Image}
78
+ * feature model element.
79
+ *
80
+ * @returns Returns a conversion callback.
81
+ */
82
+ function viewToModelImageAttributeConverter(dataFilter) {
83
+ return (dispatcher) => {
84
+ dispatcher.on('element:img', (evt, data, conversionApi) => {
85
+ if (!data.modelRange) {
86
+ return;
87
+ }
88
+ const viewImageElement = data.viewItem;
89
+ const viewAttributes = dataFilter.processViewAttributes(viewImageElement, conversionApi);
90
+ if (viewAttributes) {
91
+ conversionApi.writer.setAttribute('htmlImgAttributes', viewAttributes, data.modelRange);
92
+ }
93
+ }, { priority: 'low' });
94
+ };
95
+ }
96
+ /**
97
+ * View-to-model conversion helper preserving allowed attributes on {@link module:image/image~Image Image}
98
+ * feature model element from link view element.
99
+ *
100
+ * @returns Returns a conversion callback.
101
+ */
102
+ function viewToModelLinkImageAttributeConverter(dataFilter, editor) {
103
+ const imageUtils = editor.plugins.get('ImageUtils');
104
+ return (dispatcher) => {
105
+ dispatcher.on('element:a', (evt, data, conversionApi) => {
106
+ const viewLink = data.viewItem;
107
+ const viewImage = imageUtils.findViewImgElement(viewLink);
108
+ if (!viewImage) {
109
+ return;
110
+ }
111
+ const modelImage = data.modelCursor.parent;
112
+ if (!modelImage.is('element', 'imageBlock')) {
113
+ return;
114
+ }
115
+ const viewAttributes = dataFilter.processViewAttributes(viewLink, conversionApi);
116
+ if (viewAttributes) {
117
+ conversionApi.writer.setAttribute('htmlLinkAttributes', viewAttributes, modelImage);
118
+ }
119
+ }, { priority: 'low' });
120
+ };
121
+ }
122
+ /**
123
+ * View-to-model conversion helper preserving allowed attributes on {@link module:image/image~Image Image}
124
+ * feature model element from figure view element.
125
+ *
126
+ * @returns Returns a conversion callback.
127
+ */
128
+ function viewToModelFigureAttributeConverter(dataFilter) {
129
+ return (dispatcher) => {
130
+ dispatcher.on('element:figure', (evt, data, conversionApi) => {
131
+ const viewFigureElement = data.viewItem;
132
+ if (!data.modelRange || !viewFigureElement.hasClass('image')) {
133
+ return;
134
+ }
135
+ const viewAttributes = dataFilter.processViewAttributes(viewFigureElement, conversionApi);
136
+ if (viewAttributes) {
137
+ conversionApi.writer.setAttribute('htmlFigureAttributes', viewAttributes, data.modelRange);
138
+ }
139
+ }, { priority: 'low' });
140
+ };
141
+ }
142
+ /**
143
+ * A model-to-view conversion helper applying attributes from the {@link module:image/image~Image Image}
144
+ * feature.
145
+ * @returns Returns a conversion callback.
146
+ */
147
+ function modelToViewImageAttributeConverter() {
148
+ return (dispatcher) => {
149
+ addInlineAttributeConversion('htmlImgAttributes');
150
+ addBlockAttributeConversion('img', 'htmlImgAttributes');
151
+ addBlockAttributeConversion('figure', 'htmlFigureAttributes');
152
+ addBlockAttributeConversion('a', 'htmlLinkAttributes');
153
+ function addInlineAttributeConversion(attributeName) {
154
+ dispatcher.on(`attribute:${attributeName}:imageInline`, (evt, data, conversionApi) => {
155
+ if (!conversionApi.consumable.consume(data.item, evt.name)) {
156
+ return;
157
+ }
158
+ const { attributeOldValue, attributeNewValue } = data;
159
+ const viewElement = conversionApi.mapper.toViewElement(data.item);
160
+ updateViewAttributes(conversionApi.writer, attributeOldValue, attributeNewValue, viewElement);
161
+ }, { priority: 'low' });
162
+ }
163
+ function addBlockAttributeConversion(elementName, attributeName) {
164
+ dispatcher.on(`attribute:${attributeName}:imageBlock`, (evt, data, conversionApi) => {
165
+ if (!conversionApi.consumable.test(data.item, evt.name)) {
166
+ return;
167
+ }
168
+ const { attributeOldValue, attributeNewValue } = data;
169
+ const containerElement = conversionApi.mapper.toViewElement(data.item);
170
+ const viewElement = getDescendantElement(conversionApi.writer, containerElement, elementName);
171
+ if (viewElement) {
172
+ updateViewAttributes(conversionApi.writer, attributeOldValue, attributeNewValue, viewElement);
173
+ conversionApi.consumable.consume(data.item, evt.name);
174
+ }
175
+ }, { priority: 'low' });
176
+ if (elementName === 'a') {
177
+ // To have a link element in the view, we need to attach a converter to the `linkHref` attribute as well.
178
+ dispatcher.on('attribute:linkHref:imageBlock', (evt, data, conversionApi) => {
179
+ if (!conversionApi.consumable.consume(data.item, 'attribute:htmlLinkAttributes:imageBlock')) {
180
+ return;
181
+ }
182
+ const containerElement = conversionApi.mapper.toViewElement(data.item);
183
+ const viewElement = getDescendantElement(conversionApi.writer, containerElement, 'a');
184
+ setViewAttributes(conversionApi.writer, data.item.getAttribute('htmlLinkAttributes'), viewElement);
185
+ }, { priority: 'low' });
186
+ }
187
+ }
188
+ };
189
+ }
@@ -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 { DowncastWriter, ViewElement } from 'ckeditor5/src/engine';
6
- /**
7
- * @module html-support/integrations/integrationutils
8
- */
9
- /**
10
- * Returns the first view element descendant matching the given view name.
11
- * Includes view element itself.
12
- *
13
- * @internal
14
- */
15
- export declare function getDescendantElement(writer: DowncastWriter, containerElement: ViewElement, elementName: string): ViewElement | undefined;
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 { DowncastWriter, ViewElement } from 'ckeditor5/src/engine';
6
+ /**
7
+ * @module html-support/integrations/integrationutils
8
+ */
9
+ /**
10
+ * Returns the first view element descendant matching the given view name.
11
+ * Includes view element itself.
12
+ *
13
+ * @internal
14
+ */
15
+ export declare function getDescendantElement(writer: DowncastWriter, containerElement: ViewElement, elementName: string): ViewElement | undefined;
@@ -1,21 +1,21 @@
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/integrations/integrationutils
7
- */
8
- /**
9
- * Returns the first view element descendant matching the given view name.
10
- * Includes view element itself.
11
- *
12
- * @internal
13
- */
14
- export function getDescendantElement(writer, containerElement, elementName) {
15
- const range = writer.createRangeOn(containerElement);
16
- for (const { item } of range.getWalker()) {
17
- if (item.is('element', elementName)) {
18
- return item;
19
- }
20
- }
21
- }
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/integrations/integrationutils
7
+ */
8
+ /**
9
+ * Returns the first view element descendant matching the given view name.
10
+ * Includes view element itself.
11
+ *
12
+ * @internal
13
+ */
14
+ export function getDescendantElement(writer, containerElement, elementName) {
15
+ const range = writer.createRangeOn(containerElement);
16
+ for (const { item } of range.getWalker()) {
17
+ if (item.is('element', elementName)) {
18
+ return item;
19
+ }
20
+ }
21
+ }
@@ -1,26 +1,26 @@
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/integrations/mediaembed
7
- */
8
- import { Plugin } from 'ckeditor5/src/core';
9
- import DataFilter from '../datafilter';
10
- /**
11
- * Provides the General HTML Support integration with {@link module:media-embed/mediaembed~MediaEmbed Media Embed} feature.
12
- */
13
- export default class MediaEmbedElementSupport extends Plugin {
14
- /**
15
- * @inheritDoc
16
- */
17
- static get requires(): readonly [typeof DataFilter];
18
- /**
19
- * @inheritDoc
20
- */
21
- static get pluginName(): "MediaEmbedElementSupport";
22
- /**
23
- * @inheritDoc
24
- */
25
- init(): void;
26
- }
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/integrations/mediaembed
7
+ */
8
+ import { Plugin } from 'ckeditor5/src/core';
9
+ import DataFilter from '../datafilter';
10
+ /**
11
+ * Provides the General HTML Support integration with {@link module:media-embed/mediaembed~MediaEmbed Media Embed} feature.
12
+ */
13
+ export default class MediaEmbedElementSupport extends Plugin {
14
+ /**
15
+ * @inheritDoc
16
+ */
17
+ static get requires(): readonly [typeof DataFilter];
18
+ /**
19
+ * @inheritDoc
20
+ */
21
+ static get pluginName(): "MediaEmbedElementSupport";
22
+ /**
23
+ * @inheritDoc
24
+ */
25
+ init(): void;
26
+ }