@ckeditor/ckeditor5-html-support 36.0.1 → 37.0.0-alpha.1
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.
- package/README.md +2 -2
- package/build/html-support.js +1 -1
- package/ckeditor5-metadata.json +2 -2
- package/package.json +42 -36
- package/src/augmentation.d.ts +33 -0
- package/src/augmentation.js +5 -0
- package/src/conversionutils.d.ts +42 -0
- package/src/conversionutils.js +57 -77
- package/src/converters.d.ts +56 -0
- package/src/converters.js +104 -156
- package/src/datafilter.d.ts +250 -0
- package/src/datafilter.js +566 -782
- package/src/dataschema.d.ts +169 -0
- package/src/dataschema.js +143 -229
- package/src/fullpage.d.ts +21 -0
- package/src/fullpage.js +65 -86
- package/src/generalhtmlsupport.d.ts +88 -0
- package/src/generalhtmlsupport.js +244 -327
- package/src/generalhtmlsupportconfig.d.ts +67 -0
- package/src/generalhtmlsupportconfig.js +5 -0
- package/src/htmlcomment.d.ts +72 -0
- package/src/htmlcomment.js +175 -239
- package/src/htmlpagedataprocessor.d.ts +22 -0
- package/src/htmlpagedataprocessor.js +53 -76
- package/src/index.d.ts +25 -0
- package/src/index.js +1 -2
- package/src/integrations/codeblock.d.ts +22 -0
- package/src/integrations/codeblock.js +87 -115
- package/src/integrations/customelement.d.ts +25 -0
- package/src/integrations/customelement.js +127 -160
- package/src/integrations/documentlist.d.ts +26 -0
- package/src/integrations/documentlist.js +154 -191
- package/src/integrations/dualcontent.d.ts +44 -0
- package/src/integrations/dualcontent.js +92 -128
- package/src/integrations/heading.d.ts +25 -0
- package/src/integrations/heading.js +41 -54
- package/src/integrations/image.d.ts +25 -0
- package/src/integrations/image.js +154 -212
- package/src/integrations/integrationutils.d.ts +15 -0
- package/src/integrations/integrationutils.js +21 -0
- package/src/integrations/mediaembed.d.ts +25 -0
- package/src/integrations/mediaembed.js +101 -147
- package/src/integrations/script.d.ts +25 -0
- package/src/integrations/script.js +45 -67
- package/src/integrations/style.d.ts +25 -0
- package/src/integrations/style.js +45 -67
- package/src/integrations/table.d.ts +22 -0
- package/src/integrations/table.js +113 -160
- package/src/schemadefinitions.d.ts +13 -0
- package/src/schemadefinitions.js +846 -835
|
@@ -0,0 +1,25 @@
|
|
|
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/heading
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin, type PluginDependencies } from 'ckeditor5/src/core';
|
|
9
|
+
/**
|
|
10
|
+
* Provides the General HTML Support integration with {@link module:heading/heading~Heading Heading} feature.
|
|
11
|
+
*/
|
|
12
|
+
export default class HeadingElementSupport extends Plugin {
|
|
13
|
+
/**
|
|
14
|
+
* @inheritDoc
|
|
15
|
+
*/
|
|
16
|
+
static get requires(): PluginDependencies;
|
|
17
|
+
/**
|
|
18
|
+
* @inheritDoc
|
|
19
|
+
*/
|
|
20
|
+
static get pluginName(): 'HeadingElementSupport';
|
|
21
|
+
/**
|
|
22
|
+
* @inheritDoc
|
|
23
|
+
*/
|
|
24
|
+
init(): void;
|
|
25
|
+
}
|
|
@@ -2,67 +2,54 @@
|
|
|
2
2
|
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
5
|
/**
|
|
7
6
|
* @module html-support/integrations/heading
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
8
|
import { Plugin } from 'ckeditor5/src/core';
|
|
11
|
-
|
|
12
9
|
import DataSchema from '../dataschema';
|
|
13
|
-
|
|
14
10
|
/**
|
|
15
11
|
* Provides the General HTML Support integration with {@link module:heading/heading~Heading Heading} feature.
|
|
16
|
-
*
|
|
17
|
-
* @extends module:core/plugin~Plugin
|
|
18
12
|
*/
|
|
19
13
|
export default class HeadingElementSupport extends Plugin {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
dataSchema.extendBlockElement( {
|
|
62
|
-
model: 'htmlHgroup',
|
|
63
|
-
modelSchema: {
|
|
64
|
-
allowChildren: headerModels
|
|
65
|
-
}
|
|
66
|
-
} );
|
|
67
|
-
}
|
|
14
|
+
/**
|
|
15
|
+
* @inheritDoc
|
|
16
|
+
*/
|
|
17
|
+
static get requires() {
|
|
18
|
+
return [DataSchema];
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* @inheritDoc
|
|
22
|
+
*/
|
|
23
|
+
static get pluginName() {
|
|
24
|
+
return 'HeadingElementSupport';
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* @inheritDoc
|
|
28
|
+
*/
|
|
29
|
+
init() {
|
|
30
|
+
const editor = this.editor;
|
|
31
|
+
if (!editor.plugins.has('HeadingEditing')) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const dataSchema = editor.plugins.get(DataSchema);
|
|
35
|
+
const options = editor.config.get('heading.options');
|
|
36
|
+
const headerModels = [];
|
|
37
|
+
// We are registering all elements supported by HeadingEditing
|
|
38
|
+
// to enable custom attributes for those elements.
|
|
39
|
+
for (const option of options) {
|
|
40
|
+
if ('model' in option && 'view' in option) {
|
|
41
|
+
dataSchema.registerBlockElement({
|
|
42
|
+
view: option.view,
|
|
43
|
+
model: option.model
|
|
44
|
+
});
|
|
45
|
+
headerModels.push(option.model);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
dataSchema.extendBlockElement({
|
|
49
|
+
model: 'htmlHgroup',
|
|
50
|
+
modelSchema: {
|
|
51
|
+
allowChildren: headerModels
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
68
55
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
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, type PluginDependencies } from 'ckeditor5/src/core';
|
|
9
|
+
/**
|
|
10
|
+
* Provides the General HTML Support integration with the {@link module:image/image~Image Image} feature.
|
|
11
|
+
*/
|
|
12
|
+
export default class ImageElementSupport extends Plugin {
|
|
13
|
+
/**
|
|
14
|
+
* @inheritDoc
|
|
15
|
+
*/
|
|
16
|
+
static get requires(): PluginDependencies;
|
|
17
|
+
/**
|
|
18
|
+
* @inheritDoc
|
|
19
|
+
*/
|
|
20
|
+
static get pluginName(): 'ImageElementSupport';
|
|
21
|
+
/**
|
|
22
|
+
* @inheritDoc
|
|
23
|
+
*/
|
|
24
|
+
init(): void;
|
|
25
|
+
}
|
|
@@ -2,229 +2,171 @@
|
|
|
2
2
|
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
5
|
/**
|
|
7
6
|
* @module html-support/integrations/image
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
8
|
import { Plugin } from 'ckeditor5/src/core';
|
|
11
|
-
|
|
12
9
|
import DataFilter from '../datafilter';
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
updateViewAttributes
|
|
16
|
-
} from '../conversionutils.js';
|
|
17
|
-
|
|
10
|
+
import { setViewAttributes, updateViewAttributes } from '../conversionutils';
|
|
11
|
+
import { getDescendantElement } from './integrationutils';
|
|
18
12
|
/**
|
|
19
13
|
* Provides the General HTML Support integration with the {@link module:image/image~Image Image} feature.
|
|
20
|
-
*
|
|
21
|
-
* @extends module:core/plugin~Plugin
|
|
22
14
|
*/
|
|
23
15
|
export default class ImageElementSupport extends Plugin {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
]
|
|
81
|
-
} );
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
conversion.for( 'upcast' ).add( viewToModelImageAttributeConverter( dataFilter ) );
|
|
85
|
-
conversion.for( 'downcast' ).add( modelToViewImageAttributeConverter() );
|
|
86
|
-
|
|
87
|
-
evt.stop();
|
|
88
|
-
} );
|
|
89
|
-
}
|
|
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
|
+
'htmlAttributes',
|
|
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
|
+
'htmlAttributes'
|
|
64
|
+
]
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
conversion.for('upcast').add(viewToModelImageAttributeConverter(dataFilter));
|
|
68
|
+
conversion.for('downcast').add(modelToViewImageAttributeConverter());
|
|
69
|
+
evt.stop();
|
|
70
|
+
});
|
|
71
|
+
}
|
|
90
72
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
function preserveLinkAttributes( viewContainerElement ) {
|
|
123
|
-
if ( data.modelRange && data.modelRange.getContainedElement().is( 'element', 'imageBlock' ) ) {
|
|
124
|
-
preserveElementAttributes( viewContainerElement, 'htmlLinkAttributes' );
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}, { priority: 'low' } );
|
|
128
|
-
};
|
|
73
|
+
/**
|
|
74
|
+
* View-to-model conversion helper preserving allowed attributes on the {@link module:image/image~Image Image}
|
|
75
|
+
* feature model element.
|
|
76
|
+
*
|
|
77
|
+
* @returns Returns a conversion callback.
|
|
78
|
+
*/
|
|
79
|
+
function viewToModelImageAttributeConverter(dataFilter) {
|
|
80
|
+
return (dispatcher) => {
|
|
81
|
+
dispatcher.on('element:img', (evt, data, conversionApi) => {
|
|
82
|
+
if (!data.modelRange) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
const viewImageElement = data.viewItem;
|
|
86
|
+
const viewContainerElement = viewImageElement.parent;
|
|
87
|
+
preserveElementAttributes(viewImageElement, 'htmlAttributes');
|
|
88
|
+
if (viewContainerElement.is('element', 'a')) {
|
|
89
|
+
preserveLinkAttributes(viewContainerElement);
|
|
90
|
+
}
|
|
91
|
+
function preserveElementAttributes(viewElement, attributeName) {
|
|
92
|
+
const viewAttributes = dataFilter.processViewAttributes(viewElement, conversionApi);
|
|
93
|
+
if (viewAttributes) {
|
|
94
|
+
conversionApi.writer.setAttribute(attributeName, viewAttributes, data.modelRange);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
function preserveLinkAttributes(viewContainerElement) {
|
|
98
|
+
if (data.modelRange && data.modelRange.getContainedElement().is('element', 'imageBlock')) {
|
|
99
|
+
preserveElementAttributes(viewContainerElement, 'htmlLinkAttributes');
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}, { priority: 'low' });
|
|
103
|
+
};
|
|
129
104
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
conversionApi.writer.setAttribute( 'htmlFigureAttributes', viewAttributes, data.modelRange );
|
|
150
|
-
}
|
|
151
|
-
}, { priority: 'low' } );
|
|
152
|
-
};
|
|
105
|
+
/**
|
|
106
|
+
* View-to-model conversion helper preserving allowed attributes on {@link module:image/image~Image Image}
|
|
107
|
+
* feature model element from figure view element.
|
|
108
|
+
*
|
|
109
|
+
* @returns Returns a conversion callback.
|
|
110
|
+
*/
|
|
111
|
+
function viewToModelFigureAttributeConverter(dataFilter) {
|
|
112
|
+
return (dispatcher) => {
|
|
113
|
+
dispatcher.on('element:figure', (evt, data, conversionApi) => {
|
|
114
|
+
const viewFigureElement = data.viewItem;
|
|
115
|
+
if (!data.modelRange || !viewFigureElement.hasClass('image')) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const viewAttributes = dataFilter.processViewAttributes(viewFigureElement, conversionApi);
|
|
119
|
+
if (viewAttributes) {
|
|
120
|
+
conversionApi.writer.setAttribute('htmlFigureAttributes', viewAttributes, data.modelRange);
|
|
121
|
+
}
|
|
122
|
+
}, { priority: 'low' });
|
|
123
|
+
};
|
|
153
124
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
// @returns {Function} Returns a conversion callback.
|
|
125
|
+
/**
|
|
126
|
+
* A model-to-view conversion helper applying attributes from the {@link module:image/image~Image Image}
|
|
127
|
+
* feature.
|
|
128
|
+
* @returns Returns a conversion callback.
|
|
129
|
+
*/
|
|
160
130
|
function modelToViewImageAttributeConverter() {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
const containerElement = conversionApi.mapper.toViewElement( data.item );
|
|
205
|
-
const viewElement = getDescendantElement( conversionApi.writer, containerElement, 'a' );
|
|
206
|
-
|
|
207
|
-
setViewAttributes( conversionApi.writer, data.item.getAttribute( 'htmlLinkAttributes' ), viewElement );
|
|
208
|
-
}, { priority: 'low' } );
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
};
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
// Returns the first view element descendant matching the given view name.
|
|
215
|
-
// Includes view element itself.
|
|
216
|
-
//
|
|
217
|
-
// @private
|
|
218
|
-
// @param {module:engine/view/downcastwriter~DowncastWriter} writer
|
|
219
|
-
// @param {module:engine/view/element~Element} containerElement
|
|
220
|
-
// @param {String} elementName
|
|
221
|
-
// @returns {module:engine/view/element~Element|null}
|
|
222
|
-
function getDescendantElement( writer, containerElement, elementName ) {
|
|
223
|
-
const range = writer.createRangeOn( containerElement );
|
|
224
|
-
|
|
225
|
-
for ( const { item } of range.getWalker() ) {
|
|
226
|
-
if ( item.is( 'element', elementName ) ) {
|
|
227
|
-
return item;
|
|
228
|
-
}
|
|
229
|
-
}
|
|
131
|
+
return (dispatcher) => {
|
|
132
|
+
addInlineAttributeConversion('htmlAttributes');
|
|
133
|
+
addBlockAttributeConversion('img', 'htmlAttributes');
|
|
134
|
+
addBlockAttributeConversion('figure', 'htmlFigureAttributes');
|
|
135
|
+
addBlockAttributeConversion('a', 'htmlLinkAttributes');
|
|
136
|
+
function addInlineAttributeConversion(attributeName) {
|
|
137
|
+
dispatcher.on(`attribute:${attributeName}:imageInline`, (evt, data, conversionApi) => {
|
|
138
|
+
if (!conversionApi.consumable.consume(data.item, evt.name)) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
const { attributeOldValue, attributeNewValue } = data;
|
|
142
|
+
const viewElement = conversionApi.mapper.toViewElement(data.item);
|
|
143
|
+
updateViewAttributes(conversionApi.writer, attributeOldValue, attributeNewValue, viewElement);
|
|
144
|
+
}, { priority: 'low' });
|
|
145
|
+
}
|
|
146
|
+
function addBlockAttributeConversion(elementName, attributeName) {
|
|
147
|
+
dispatcher.on(`attribute:${attributeName}:imageBlock`, (evt, data, conversionApi) => {
|
|
148
|
+
if (!conversionApi.consumable.test(data.item, evt.name)) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
const { attributeOldValue, attributeNewValue } = data;
|
|
152
|
+
const containerElement = conversionApi.mapper.toViewElement(data.item);
|
|
153
|
+
const viewElement = getDescendantElement(conversionApi.writer, containerElement, elementName);
|
|
154
|
+
if (viewElement) {
|
|
155
|
+
updateViewAttributes(conversionApi.writer, attributeOldValue, attributeNewValue, viewElement);
|
|
156
|
+
conversionApi.consumable.consume(data.item, evt.name);
|
|
157
|
+
}
|
|
158
|
+
}, { priority: 'low' });
|
|
159
|
+
if (elementName === 'a') {
|
|
160
|
+
// To have a link element in the view, we need to attach a converter to the `linkHref` attribute as well.
|
|
161
|
+
dispatcher.on('attribute:linkHref:imageBlock', (evt, data, conversionApi) => {
|
|
162
|
+
if (!conversionApi.consumable.consume(data.item, 'attribute:htmlLinkAttributes:imageBlock')) {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
const containerElement = conversionApi.mapper.toViewElement(data.item);
|
|
166
|
+
const viewElement = getDescendantElement(conversionApi.writer, containerElement, 'a');
|
|
167
|
+
setViewAttributes(conversionApi.writer, data.item.getAttribute('htmlLinkAttributes'), viewElement);
|
|
168
|
+
}, { priority: 'low' });
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
};
|
|
230
172
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
import type { 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;
|
|
@@ -0,0 +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
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
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, type PluginDependencies } from 'ckeditor5/src/core';
|
|
9
|
+
/**
|
|
10
|
+
* Provides the General HTML Support integration with {@link module:media-embed/mediaembed~MediaEmbed Media Embed} feature.
|
|
11
|
+
*/
|
|
12
|
+
export default class MediaEmbedElementSupport extends Plugin {
|
|
13
|
+
/**
|
|
14
|
+
* @inheritDoc
|
|
15
|
+
*/
|
|
16
|
+
static get requires(): PluginDependencies;
|
|
17
|
+
/**
|
|
18
|
+
* @inheritDoc
|
|
19
|
+
*/
|
|
20
|
+
static get pluginName(): 'MediaEmbedElementSupport';
|
|
21
|
+
/**
|
|
22
|
+
* @inheritDoc
|
|
23
|
+
*/
|
|
24
|
+
init(): void;
|
|
25
|
+
}
|