@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
|
@@ -2,164 +2,118 @@
|
|
|
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/mediaembed
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
8
|
import { Plugin } from 'ckeditor5/src/core';
|
|
11
|
-
|
|
12
9
|
import DataFilter from '../datafilter';
|
|
13
10
|
import DataSchema from '../dataschema';
|
|
14
|
-
import { updateViewAttributes } from '../conversionutils
|
|
15
|
-
|
|
11
|
+
import { updateViewAttributes } from '../conversionutils';
|
|
12
|
+
import { getDescendantElement } from './integrationutils';
|
|
16
13
|
/**
|
|
17
14
|
* Provides the General HTML Support integration with {@link module:media-embed/mediaembed~MediaEmbed Media Embed} feature.
|
|
18
|
-
*
|
|
19
|
-
* @extends module:core/plugin~Plugin
|
|
20
15
|
*/
|
|
21
16
|
export default class MediaEmbedElementSupport extends Plugin {
|
|
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
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
'htmlFigureAttributes'
|
|
73
|
-
]
|
|
74
|
-
} );
|
|
75
|
-
|
|
76
|
-
conversion.for( 'upcast' ).add( viewToModelMediaAttributesConverter( dataFilter, mediaElementName ) );
|
|
77
|
-
conversion.for( 'dataDowncast' ).add( modelToViewMediaAttributeConverter( mediaElementName ) );
|
|
78
|
-
|
|
79
|
-
evt.stop();
|
|
80
|
-
} );
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function viewToModelMediaAttributesConverter( dataFilter, mediaElementName ) {
|
|
85
|
-
return dispatcher => {
|
|
86
|
-
dispatcher.on( `element:${ mediaElementName }`, upcastMedia, { priority: 'low' } );
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
function upcastMedia( evt, data, conversionApi ) {
|
|
90
|
-
const viewMediaElement = data.viewItem;
|
|
91
|
-
|
|
92
|
-
preserveElementAttributes( viewMediaElement, 'htmlAttributes' );
|
|
93
|
-
|
|
94
|
-
function preserveElementAttributes( viewElement, attributeName ) {
|
|
95
|
-
const viewAttributes = dataFilter.processViewAttributes( viewElement, conversionApi );
|
|
96
|
-
|
|
97
|
-
if ( viewAttributes ) {
|
|
98
|
-
conversionApi.writer.setAttribute( attributeName, viewAttributes, data.modelRange );
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
17
|
+
/**
|
|
18
|
+
* @inheritDoc
|
|
19
|
+
*/
|
|
20
|
+
static get requires() {
|
|
21
|
+
return [DataFilter];
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* @inheritDoc
|
|
25
|
+
*/
|
|
26
|
+
static get pluginName() {
|
|
27
|
+
return 'MediaEmbedElementSupport';
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* @inheritDoc
|
|
31
|
+
*/
|
|
32
|
+
init() {
|
|
33
|
+
const editor = this.editor;
|
|
34
|
+
// Stop here if MediaEmbed plugin is not provided or the integrator wants to output markup with previews as
|
|
35
|
+
// we do not support filtering previews.
|
|
36
|
+
if (!editor.plugins.has('MediaEmbed') || editor.config.get('mediaEmbed.previewsInData')) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const schema = editor.model.schema;
|
|
40
|
+
const conversion = editor.conversion;
|
|
41
|
+
const dataFilter = this.editor.plugins.get(DataFilter);
|
|
42
|
+
const dataSchema = this.editor.plugins.get(DataSchema);
|
|
43
|
+
const mediaElementName = editor.config.get('mediaEmbed.elementName');
|
|
44
|
+
// Overwrite GHS schema definition for a given elementName.
|
|
45
|
+
dataSchema.registerBlockElement({
|
|
46
|
+
model: 'media',
|
|
47
|
+
view: mediaElementName
|
|
48
|
+
});
|
|
49
|
+
dataFilter.on('register:figure', () => {
|
|
50
|
+
conversion.for('upcast').add(viewToModelFigureAttributesConverter(dataFilter));
|
|
51
|
+
});
|
|
52
|
+
dataFilter.on(`register:${mediaElementName}`, (evt, definition) => {
|
|
53
|
+
if (definition.model !== 'media') {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
schema.extend('media', {
|
|
57
|
+
allowAttributes: [
|
|
58
|
+
'htmlAttributes',
|
|
59
|
+
'htmlFigureAttributes'
|
|
60
|
+
]
|
|
61
|
+
});
|
|
62
|
+
conversion.for('upcast').add(viewToModelMediaAttributesConverter(dataFilter, mediaElementName));
|
|
63
|
+
conversion.for('dataDowncast').add(modelToViewMediaAttributeConverter(mediaElementName));
|
|
64
|
+
evt.stop();
|
|
65
|
+
});
|
|
66
|
+
}
|
|
102
67
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
const viewAttributes = dataFilter.processViewAttributes( viewFigureElement, conversionApi );
|
|
120
|
-
|
|
121
|
-
if ( viewAttributes ) {
|
|
122
|
-
conversionApi.writer.setAttribute( 'htmlFigureAttributes', viewAttributes, data.modelRange );
|
|
123
|
-
}
|
|
124
|
-
}, { priority: 'low' } );
|
|
125
|
-
};
|
|
68
|
+
function viewToModelMediaAttributesConverter(dataFilter, mediaElementName) {
|
|
69
|
+
const upcastMedia = (evt, data, conversionApi) => {
|
|
70
|
+
const viewMediaElement = data.viewItem;
|
|
71
|
+
preserveElementAttributes(viewMediaElement, 'htmlAttributes');
|
|
72
|
+
function preserveElementAttributes(viewElement, attributeName) {
|
|
73
|
+
const viewAttributes = dataFilter.processViewAttributes(viewElement, conversionApi);
|
|
74
|
+
if (viewAttributes) {
|
|
75
|
+
conversionApi.writer.setAttribute(attributeName, viewAttributes, data.modelRange);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
return (dispatcher) => {
|
|
80
|
+
dispatcher.on(`element:${mediaElementName}`, upcastMedia, { priority: 'low' });
|
|
81
|
+
};
|
|
126
82
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
};
|
|
83
|
+
/**
|
|
84
|
+
* View-to-model conversion helper preserving allowed attributes on {@link module:media-embed/mediaembed~MediaEmbed MediaEmbed}
|
|
85
|
+
* feature model element from figure view element.
|
|
86
|
+
*
|
|
87
|
+
* @returns Returns a conversion callback.
|
|
88
|
+
*/
|
|
89
|
+
function viewToModelFigureAttributesConverter(dataFilter) {
|
|
90
|
+
return (dispatcher) => {
|
|
91
|
+
dispatcher.on('element:figure', (evt, data, conversionApi) => {
|
|
92
|
+
const viewFigureElement = data.viewItem;
|
|
93
|
+
if (!data.modelRange || !viewFigureElement.hasClass('media')) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
const viewAttributes = dataFilter.processViewAttributes(viewFigureElement, conversionApi);
|
|
97
|
+
if (viewAttributes) {
|
|
98
|
+
conversionApi.writer.setAttribute('htmlFigureAttributes', viewAttributes, data.modelRange);
|
|
99
|
+
}
|
|
100
|
+
}, { priority: 'low' });
|
|
101
|
+
};
|
|
147
102
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
}
|
|
103
|
+
function modelToViewMediaAttributeConverter(mediaElementName) {
|
|
104
|
+
return (dispatcher) => {
|
|
105
|
+
addAttributeConversionDispatcherHandler(mediaElementName, 'htmlAttributes');
|
|
106
|
+
addAttributeConversionDispatcherHandler('figure', 'htmlFigureAttributes');
|
|
107
|
+
function addAttributeConversionDispatcherHandler(elementName, attributeName) {
|
|
108
|
+
dispatcher.on(`attribute:${attributeName}:media`, (evt, data, conversionApi) => {
|
|
109
|
+
if (!conversionApi.consumable.consume(data.item, evt.name)) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
const { attributeOldValue, attributeNewValue } = data;
|
|
113
|
+
const containerElement = conversionApi.mapper.toViewElement(data.item);
|
|
114
|
+
const viewElement = getDescendantElement(conversionApi.writer, containerElement, elementName);
|
|
115
|
+
updateViewAttributes(conversionApi.writer, attributeOldValue, attributeNewValue, viewElement);
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
};
|
|
165
119
|
}
|
|
@@ -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/script
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin, type PluginDependencies } from 'ckeditor5/src/core';
|
|
9
|
+
/**
|
|
10
|
+
* Provides the General HTML Support for `script` elements.
|
|
11
|
+
*/
|
|
12
|
+
export default class ScriptElementSupport extends Plugin {
|
|
13
|
+
/**
|
|
14
|
+
* @inheritDoc
|
|
15
|
+
*/
|
|
16
|
+
static get requires(): PluginDependencies;
|
|
17
|
+
/**
|
|
18
|
+
* @inheritDoc
|
|
19
|
+
*/
|
|
20
|
+
static get pluginName(): 'ScriptElementSupport';
|
|
21
|
+
/**
|
|
22
|
+
* @inheritDoc
|
|
23
|
+
*/
|
|
24
|
+
init(): void;
|
|
25
|
+
}
|
|
@@ -2,80 +2,58 @@
|
|
|
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/script
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
8
|
import { Plugin } from 'ckeditor5/src/core';
|
|
11
|
-
import {
|
|
12
|
-
createObjectView,
|
|
13
|
-
modelToViewBlockAttributeConverter,
|
|
14
|
-
viewToModelBlockAttributeConverter,
|
|
15
|
-
viewToModelObjectConverter
|
|
16
|
-
} from '../converters.js';
|
|
17
|
-
|
|
9
|
+
import { createObjectView, modelToViewBlockAttributeConverter, viewToModelBlockAttributeConverter, viewToModelObjectConverter } from '../converters';
|
|
18
10
|
import DataFilter from '../datafilter';
|
|
19
|
-
|
|
20
11
|
/**
|
|
21
12
|
* Provides the General HTML Support for `script` elements.
|
|
22
|
-
*
|
|
23
|
-
* @extends module:core/plugin~Plugin
|
|
24
13
|
*/
|
|
25
14
|
export default class ScriptElementSupport extends Plugin {
|
|
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
|
-
model: 'htmlScript',
|
|
71
|
-
view: ( modelElement, { writer } ) => {
|
|
72
|
-
return createObjectView( 'script', modelElement, writer );
|
|
73
|
-
}
|
|
74
|
-
} );
|
|
75
|
-
|
|
76
|
-
conversion.for( 'downcast' ).add( modelToViewBlockAttributeConverter( definition ) );
|
|
77
|
-
|
|
78
|
-
evt.stop();
|
|
79
|
-
} );
|
|
80
|
-
}
|
|
15
|
+
/**
|
|
16
|
+
* @inheritDoc
|
|
17
|
+
*/
|
|
18
|
+
static get requires() {
|
|
19
|
+
return [DataFilter];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* @inheritDoc
|
|
23
|
+
*/
|
|
24
|
+
static get pluginName() {
|
|
25
|
+
return 'ScriptElementSupport';
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* @inheritDoc
|
|
29
|
+
*/
|
|
30
|
+
init() {
|
|
31
|
+
const dataFilter = this.editor.plugins.get(DataFilter);
|
|
32
|
+
dataFilter.on('register:script', (evt, definition) => {
|
|
33
|
+
const editor = this.editor;
|
|
34
|
+
const schema = editor.model.schema;
|
|
35
|
+
const conversion = editor.conversion;
|
|
36
|
+
schema.register('htmlScript', definition.modelSchema);
|
|
37
|
+
schema.extend('htmlScript', {
|
|
38
|
+
allowAttributes: ['htmlAttributes', 'htmlContent'],
|
|
39
|
+
isContent: true
|
|
40
|
+
});
|
|
41
|
+
editor.data.registerRawContentMatcher({
|
|
42
|
+
name: 'script'
|
|
43
|
+
});
|
|
44
|
+
conversion.for('upcast').elementToElement({
|
|
45
|
+
view: 'script',
|
|
46
|
+
model: viewToModelObjectConverter(definition)
|
|
47
|
+
});
|
|
48
|
+
conversion.for('upcast').add(viewToModelBlockAttributeConverter(definition, dataFilter));
|
|
49
|
+
conversion.for('downcast').elementToElement({
|
|
50
|
+
model: 'htmlScript',
|
|
51
|
+
view: (modelElement, { writer }) => {
|
|
52
|
+
return createObjectView('script', modelElement, writer);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
conversion.for('downcast').add(modelToViewBlockAttributeConverter(definition));
|
|
56
|
+
evt.stop();
|
|
57
|
+
});
|
|
58
|
+
}
|
|
81
59
|
}
|
|
@@ -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/style
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin, type PluginDependencies } from 'ckeditor5/src/core';
|
|
9
|
+
/**
|
|
10
|
+
* Provides the General HTML Support for `style` elements.
|
|
11
|
+
*/
|
|
12
|
+
export default class StyleElementSupport extends Plugin {
|
|
13
|
+
/**
|
|
14
|
+
* @inheritDoc
|
|
15
|
+
*/
|
|
16
|
+
static get requires(): PluginDependencies;
|
|
17
|
+
/**
|
|
18
|
+
* @inheritDoc
|
|
19
|
+
*/
|
|
20
|
+
static get pluginName(): 'StyleElementSupport';
|
|
21
|
+
/**
|
|
22
|
+
* @inheritDoc
|
|
23
|
+
*/
|
|
24
|
+
init(): void;
|
|
25
|
+
}
|
|
@@ -2,80 +2,58 @@
|
|
|
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/style
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
8
|
import { Plugin } from 'ckeditor5/src/core';
|
|
11
|
-
import {
|
|
12
|
-
createObjectView,
|
|
13
|
-
modelToViewBlockAttributeConverter,
|
|
14
|
-
viewToModelBlockAttributeConverter,
|
|
15
|
-
viewToModelObjectConverter
|
|
16
|
-
} from '../converters.js';
|
|
17
|
-
|
|
9
|
+
import { createObjectView, modelToViewBlockAttributeConverter, viewToModelBlockAttributeConverter, viewToModelObjectConverter } from '../converters';
|
|
18
10
|
import DataFilter from '../datafilter';
|
|
19
|
-
|
|
20
11
|
/**
|
|
21
12
|
* Provides the General HTML Support for `style` elements.
|
|
22
|
-
*
|
|
23
|
-
* @extends module:core/plugin~Plugin
|
|
24
13
|
*/
|
|
25
14
|
export default class StyleElementSupport extends Plugin {
|
|
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
|
-
model: 'htmlStyle',
|
|
71
|
-
view: ( modelElement, { writer } ) => {
|
|
72
|
-
return createObjectView( 'style', modelElement, writer );
|
|
73
|
-
}
|
|
74
|
-
} );
|
|
75
|
-
|
|
76
|
-
conversion.for( 'downcast' ).add( modelToViewBlockAttributeConverter( definition ) );
|
|
77
|
-
|
|
78
|
-
evt.stop();
|
|
79
|
-
} );
|
|
80
|
-
}
|
|
15
|
+
/**
|
|
16
|
+
* @inheritDoc
|
|
17
|
+
*/
|
|
18
|
+
static get requires() {
|
|
19
|
+
return [DataFilter];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* @inheritDoc
|
|
23
|
+
*/
|
|
24
|
+
static get pluginName() {
|
|
25
|
+
return 'StyleElementSupport';
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* @inheritDoc
|
|
29
|
+
*/
|
|
30
|
+
init() {
|
|
31
|
+
const dataFilter = this.editor.plugins.get(DataFilter);
|
|
32
|
+
dataFilter.on('register:style', (evt, definition) => {
|
|
33
|
+
const editor = this.editor;
|
|
34
|
+
const schema = editor.model.schema;
|
|
35
|
+
const conversion = editor.conversion;
|
|
36
|
+
schema.register('htmlStyle', definition.modelSchema);
|
|
37
|
+
schema.extend('htmlStyle', {
|
|
38
|
+
allowAttributes: ['htmlAttributes', 'htmlContent'],
|
|
39
|
+
isContent: true
|
|
40
|
+
});
|
|
41
|
+
editor.data.registerRawContentMatcher({
|
|
42
|
+
name: 'style'
|
|
43
|
+
});
|
|
44
|
+
conversion.for('upcast').elementToElement({
|
|
45
|
+
view: 'style',
|
|
46
|
+
model: viewToModelObjectConverter(definition)
|
|
47
|
+
});
|
|
48
|
+
conversion.for('upcast').add(viewToModelBlockAttributeConverter(definition, dataFilter));
|
|
49
|
+
conversion.for('downcast').elementToElement({
|
|
50
|
+
model: 'htmlStyle',
|
|
51
|
+
view: (modelElement, { writer }) => {
|
|
52
|
+
return createObjectView('style', modelElement, writer);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
conversion.for('downcast').add(modelToViewBlockAttributeConverter(definition));
|
|
56
|
+
evt.stop();
|
|
57
|
+
});
|
|
58
|
+
}
|
|
81
59
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
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 { Plugin, type PluginDependencies } from 'ckeditor5/src/core';
|
|
6
|
+
/**
|
|
7
|
+
* Provides the General HTML Support integration with {@link module:table/table~Table Table} feature.
|
|
8
|
+
*/
|
|
9
|
+
export default class TableElementSupport extends Plugin {
|
|
10
|
+
/**
|
|
11
|
+
* @inheritDoc
|
|
12
|
+
*/
|
|
13
|
+
static get requires(): PluginDependencies;
|
|
14
|
+
/**
|
|
15
|
+
* @inheritDoc
|
|
16
|
+
*/
|
|
17
|
+
static get pluginName(): 'TableElementSupport';
|
|
18
|
+
/**
|
|
19
|
+
* @inheritDoc
|
|
20
|
+
*/
|
|
21
|
+
init(): void;
|
|
22
|
+
}
|