@ckeditor/ckeditor5-html-support 0.0.0-internal-20241017.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.
- package/CHANGELOG.md +4 -0
- package/LICENSE.md +21 -0
- package/README.md +26 -0
- package/build/html-support.js +5 -0
- package/build/translations/ar.js +1 -0
- package/build/translations/bg.js +1 -0
- package/build/translations/bn.js +1 -0
- package/build/translations/ca.js +1 -0
- package/build/translations/cs.js +1 -0
- package/build/translations/da.js +1 -0
- package/build/translations/de.js +1 -0
- package/build/translations/el.js +1 -0
- package/build/translations/en-au.js +1 -0
- package/build/translations/es.js +1 -0
- package/build/translations/et.js +1 -0
- package/build/translations/fi.js +1 -0
- package/build/translations/fr.js +1 -0
- package/build/translations/gl.js +1 -0
- package/build/translations/he.js +1 -0
- package/build/translations/hi.js +1 -0
- package/build/translations/hr.js +1 -0
- package/build/translations/hu.js +1 -0
- package/build/translations/id.js +1 -0
- package/build/translations/it.js +1 -0
- package/build/translations/ja.js +1 -0
- package/build/translations/jv.js +1 -0
- package/build/translations/ko.js +1 -0
- package/build/translations/lt.js +1 -0
- package/build/translations/lv.js +1 -0
- package/build/translations/ms.js +1 -0
- package/build/translations/nl.js +1 -0
- package/build/translations/no.js +1 -0
- package/build/translations/pl.js +1 -0
- package/build/translations/pt-br.js +1 -0
- package/build/translations/pt.js +1 -0
- package/build/translations/ro.js +1 -0
- package/build/translations/ru.js +1 -0
- package/build/translations/sk.js +1 -0
- package/build/translations/sr-latn.js +1 -0
- package/build/translations/sr.js +1 -0
- package/build/translations/sv.js +1 -0
- package/build/translations/th.js +1 -0
- package/build/translations/tr.js +1 -0
- package/build/translations/ug.js +1 -0
- package/build/translations/uk.js +1 -0
- package/build/translations/ur.js +1 -0
- package/build/translations/vi.js +1 -0
- package/build/translations/zh-cn.js +1 -0
- package/build/translations/zh.js +1 -0
- package/ckeditor5-metadata.json +60 -0
- package/dist/augmentation.d.ts +37 -0
- package/dist/converters.d.ts +64 -0
- package/dist/datafilter.d.ts +312 -0
- package/dist/dataschema.d.ts +191 -0
- package/dist/fullpage.d.ts +29 -0
- package/dist/generalhtmlsupport.d.ts +106 -0
- package/dist/generalhtmlsupportconfig.d.ts +81 -0
- package/dist/htmlcomment.d.ts +79 -0
- package/dist/htmlpagedataprocessor.d.ts +26 -0
- package/dist/index-content.css +4 -0
- package/dist/index-editor.css +51 -0
- package/dist/index.css +63 -0
- package/dist/index.css.map +1 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +4040 -0
- package/dist/index.js.map +1 -0
- package/dist/integrations/codeblock.d.ts +31 -0
- package/dist/integrations/customelement.d.ts +35 -0
- package/dist/integrations/dualcontent.d.ts +53 -0
- package/dist/integrations/heading.d.ts +39 -0
- package/dist/integrations/image.d.ts +34 -0
- package/dist/integrations/integrationutils.d.ts +19 -0
- package/dist/integrations/list.d.ts +35 -0
- package/dist/integrations/mediaembed.d.ts +34 -0
- package/dist/integrations/script.d.ts +34 -0
- package/dist/integrations/style.d.ts +34 -0
- package/dist/integrations/table.d.ts +31 -0
- package/dist/schemadefinitions.d.ts +17 -0
- package/dist/translations/ar.d.ts +8 -0
- package/dist/translations/ar.js +5 -0
- package/dist/translations/ar.umd.js +11 -0
- package/dist/translations/bg.d.ts +8 -0
- package/dist/translations/bg.js +5 -0
- package/dist/translations/bg.umd.js +11 -0
- package/dist/translations/bn.d.ts +8 -0
- package/dist/translations/bn.js +5 -0
- package/dist/translations/bn.umd.js +11 -0
- package/dist/translations/ca.d.ts +8 -0
- package/dist/translations/ca.js +5 -0
- package/dist/translations/ca.umd.js +11 -0
- package/dist/translations/cs.d.ts +8 -0
- package/dist/translations/cs.js +5 -0
- package/dist/translations/cs.umd.js +11 -0
- package/dist/translations/da.d.ts +8 -0
- package/dist/translations/da.js +5 -0
- package/dist/translations/da.umd.js +11 -0
- package/dist/translations/de.d.ts +8 -0
- package/dist/translations/de.js +5 -0
- package/dist/translations/de.umd.js +11 -0
- package/dist/translations/el.d.ts +8 -0
- package/dist/translations/el.js +5 -0
- package/dist/translations/el.umd.js +11 -0
- package/dist/translations/en-au.d.ts +8 -0
- package/dist/translations/en-au.js +5 -0
- package/dist/translations/en-au.umd.js +11 -0
- package/dist/translations/en.d.ts +8 -0
- package/dist/translations/en.js +5 -0
- package/dist/translations/en.umd.js +11 -0
- package/dist/translations/es.d.ts +8 -0
- package/dist/translations/es.js +5 -0
- package/dist/translations/es.umd.js +11 -0
- package/dist/translations/et.d.ts +8 -0
- package/dist/translations/et.js +5 -0
- package/dist/translations/et.umd.js +11 -0
- package/dist/translations/fi.d.ts +8 -0
- package/dist/translations/fi.js +5 -0
- package/dist/translations/fi.umd.js +11 -0
- package/dist/translations/fr.d.ts +8 -0
- package/dist/translations/fr.js +5 -0
- package/dist/translations/fr.umd.js +11 -0
- package/dist/translations/gl.d.ts +8 -0
- package/dist/translations/gl.js +5 -0
- package/dist/translations/gl.umd.js +11 -0
- package/dist/translations/he.d.ts +8 -0
- package/dist/translations/he.js +5 -0
- package/dist/translations/he.umd.js +11 -0
- package/dist/translations/hi.d.ts +8 -0
- package/dist/translations/hi.js +5 -0
- package/dist/translations/hi.umd.js +11 -0
- package/dist/translations/hr.d.ts +8 -0
- package/dist/translations/hr.js +5 -0
- package/dist/translations/hr.umd.js +11 -0
- package/dist/translations/hu.d.ts +8 -0
- package/dist/translations/hu.js +5 -0
- package/dist/translations/hu.umd.js +11 -0
- package/dist/translations/id.d.ts +8 -0
- package/dist/translations/id.js +5 -0
- package/dist/translations/id.umd.js +11 -0
- package/dist/translations/it.d.ts +8 -0
- package/dist/translations/it.js +5 -0
- package/dist/translations/it.umd.js +11 -0
- package/dist/translations/ja.d.ts +8 -0
- package/dist/translations/ja.js +5 -0
- package/dist/translations/ja.umd.js +11 -0
- package/dist/translations/jv.d.ts +8 -0
- package/dist/translations/jv.js +5 -0
- package/dist/translations/jv.umd.js +11 -0
- package/dist/translations/ko.d.ts +8 -0
- package/dist/translations/ko.js +5 -0
- package/dist/translations/ko.umd.js +11 -0
- package/dist/translations/lt.d.ts +8 -0
- package/dist/translations/lt.js +5 -0
- package/dist/translations/lt.umd.js +11 -0
- package/dist/translations/lv.d.ts +8 -0
- package/dist/translations/lv.js +5 -0
- package/dist/translations/lv.umd.js +11 -0
- package/dist/translations/ms.d.ts +8 -0
- package/dist/translations/ms.js +5 -0
- package/dist/translations/ms.umd.js +11 -0
- package/dist/translations/nl.d.ts +8 -0
- package/dist/translations/nl.js +5 -0
- package/dist/translations/nl.umd.js +11 -0
- package/dist/translations/no.d.ts +8 -0
- package/dist/translations/no.js +5 -0
- package/dist/translations/no.umd.js +11 -0
- package/dist/translations/pl.d.ts +8 -0
- package/dist/translations/pl.js +5 -0
- package/dist/translations/pl.umd.js +11 -0
- package/dist/translations/pt-br.d.ts +8 -0
- package/dist/translations/pt-br.js +5 -0
- package/dist/translations/pt-br.umd.js +11 -0
- package/dist/translations/pt.d.ts +8 -0
- package/dist/translations/pt.js +5 -0
- package/dist/translations/pt.umd.js +11 -0
- package/dist/translations/ro.d.ts +8 -0
- package/dist/translations/ro.js +5 -0
- package/dist/translations/ro.umd.js +11 -0
- package/dist/translations/ru.d.ts +8 -0
- package/dist/translations/ru.js +5 -0
- package/dist/translations/ru.umd.js +11 -0
- package/dist/translations/sk.d.ts +8 -0
- package/dist/translations/sk.js +5 -0
- package/dist/translations/sk.umd.js +11 -0
- package/dist/translations/sr-latn.d.ts +8 -0
- package/dist/translations/sr-latn.js +5 -0
- package/dist/translations/sr-latn.umd.js +11 -0
- package/dist/translations/sr.d.ts +8 -0
- package/dist/translations/sr.js +5 -0
- package/dist/translations/sr.umd.js +11 -0
- package/dist/translations/sv.d.ts +8 -0
- package/dist/translations/sv.js +5 -0
- package/dist/translations/sv.umd.js +11 -0
- package/dist/translations/th.d.ts +8 -0
- package/dist/translations/th.js +5 -0
- package/dist/translations/th.umd.js +11 -0
- package/dist/translations/tr.d.ts +8 -0
- package/dist/translations/tr.js +5 -0
- package/dist/translations/tr.umd.js +11 -0
- package/dist/translations/ug.d.ts +8 -0
- package/dist/translations/ug.js +5 -0
- package/dist/translations/ug.umd.js +11 -0
- package/dist/translations/uk.d.ts +8 -0
- package/dist/translations/uk.js +5 -0
- package/dist/translations/uk.umd.js +11 -0
- package/dist/translations/ur.d.ts +8 -0
- package/dist/translations/ur.js +5 -0
- package/dist/translations/ur.umd.js +11 -0
- package/dist/translations/vi.d.ts +8 -0
- package/dist/translations/vi.js +5 -0
- package/dist/translations/vi.umd.js +11 -0
- package/dist/translations/zh-cn.d.ts +8 -0
- package/dist/translations/zh-cn.js +5 -0
- package/dist/translations/zh-cn.umd.js +11 -0
- package/dist/translations/zh.d.ts +8 -0
- package/dist/translations/zh.js +5 -0
- package/dist/translations/zh.umd.js +11 -0
- package/dist/utils.d.ts +76 -0
- package/lang/contexts.json +3 -0
- package/lang/translations/ar.po +22 -0
- package/lang/translations/bg.po +22 -0
- package/lang/translations/bn.po +22 -0
- package/lang/translations/ca.po +22 -0
- package/lang/translations/cs.po +22 -0
- package/lang/translations/da.po +22 -0
- package/lang/translations/de.po +22 -0
- package/lang/translations/el.po +22 -0
- package/lang/translations/en-au.po +22 -0
- package/lang/translations/en.po +22 -0
- package/lang/translations/es.po +22 -0
- package/lang/translations/et.po +22 -0
- package/lang/translations/fi.po +22 -0
- package/lang/translations/fr.po +22 -0
- package/lang/translations/gl.po +22 -0
- package/lang/translations/he.po +22 -0
- package/lang/translations/hi.po +22 -0
- package/lang/translations/hr.po +22 -0
- package/lang/translations/hu.po +22 -0
- package/lang/translations/id.po +22 -0
- package/lang/translations/it.po +22 -0
- package/lang/translations/ja.po +22 -0
- package/lang/translations/jv.po +22 -0
- package/lang/translations/ko.po +22 -0
- package/lang/translations/lt.po +22 -0
- package/lang/translations/lv.po +22 -0
- package/lang/translations/ms.po +22 -0
- package/lang/translations/nl.po +22 -0
- package/lang/translations/no.po +22 -0
- package/lang/translations/pl.po +22 -0
- package/lang/translations/pt-br.po +22 -0
- package/lang/translations/pt.po +22 -0
- package/lang/translations/ro.po +22 -0
- package/lang/translations/ru.po +22 -0
- package/lang/translations/sk.po +22 -0
- package/lang/translations/sr-latn.po +22 -0
- package/lang/translations/sr.po +22 -0
- package/lang/translations/sv.po +22 -0
- package/lang/translations/th.po +22 -0
- package/lang/translations/tr.po +22 -0
- package/lang/translations/ug.po +22 -0
- package/lang/translations/uk.po +22 -0
- package/lang/translations/ur.po +22 -0
- package/lang/translations/vi.po +22 -0
- package/lang/translations/zh-cn.po +22 -0
- package/lang/translations/zh.po +22 -0
- package/package.json +48 -0
- package/src/augmentation.d.ts +33 -0
- package/src/augmentation.js +5 -0
- package/src/converters.d.ts +60 -0
- package/src/converters.js +180 -0
- package/src/datafilter.d.ts +308 -0
- package/src/datafilter.js +755 -0
- package/src/dataschema.d.ts +187 -0
- package/src/dataschema.js +202 -0
- package/src/fullpage.d.ts +25 -0
- package/src/fullpage.js +86 -0
- package/src/generalhtmlsupport.d.ts +102 -0
- package/src/generalhtmlsupport.js +246 -0
- package/src/generalhtmlsupportconfig.d.ts +77 -0
- package/src/generalhtmlsupportconfig.js +5 -0
- package/src/htmlcomment.d.ts +75 -0
- package/src/htmlcomment.js +224 -0
- package/src/htmlpagedataprocessor.d.ts +22 -0
- package/src/htmlpagedataprocessor.js +67 -0
- package/src/index.d.ts +25 -0
- package/src/index.js +14 -0
- package/src/integrations/codeblock.d.ts +27 -0
- package/src/integrations/codeblock.js +107 -0
- package/src/integrations/customelement.d.ts +31 -0
- package/src/integrations/customelement.js +162 -0
- package/src/integrations/dualcontent.d.ts +49 -0
- package/src/integrations/dualcontent.js +125 -0
- package/src/integrations/heading.d.ts +35 -0
- package/src/integrations/heading.js +72 -0
- package/src/integrations/image.d.ts +30 -0
- package/src/integrations/image.js +195 -0
- package/src/integrations/integrationutils.d.ts +15 -0
- package/src/integrations/integrationutils.js +21 -0
- package/src/integrations/list.d.ts +31 -0
- package/src/integrations/list.js +185 -0
- package/src/integrations/mediaembed.d.ts +30 -0
- package/src/integrations/mediaembed.js +125 -0
- package/src/integrations/script.d.ts +30 -0
- package/src/integrations/script.js +65 -0
- package/src/integrations/style.d.ts +30 -0
- package/src/integrations/style.js +65 -0
- package/src/integrations/table.d.ts +27 -0
- package/src/integrations/table.js +169 -0
- package/src/schemadefinitions.d.ts +13 -0
- package/src/schemadefinitions.js +964 -0
- package/src/utils.d.ts +72 -0
- package/src/utils.js +139 -0
- package/theme/datafilter.css +56 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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.js';
|
|
9
|
+
import DataFilter from '../datafilter.js';
|
|
10
|
+
import DataSchema from '../dataschema.js';
|
|
11
|
+
import { updateViewAttributes, getHtmlAttributeName } from '../utils.js';
|
|
12
|
+
import { getDescendantElement } from './integrationutils.js';
|
|
13
|
+
/**
|
|
14
|
+
* Provides the General HTML Support integration with {@link module:media-embed/mediaembed~MediaEmbed Media Embed} feature.
|
|
15
|
+
*/
|
|
16
|
+
export default class MediaEmbedElementSupport extends Plugin {
|
|
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
|
+
static get isOfficialPlugin() {
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* @inheritDoc
|
|
37
|
+
*/
|
|
38
|
+
init() {
|
|
39
|
+
const editor = this.editor;
|
|
40
|
+
// Stop here if MediaEmbed plugin is not provided or the integrator wants to output markup with previews as
|
|
41
|
+
// we do not support filtering previews.
|
|
42
|
+
if (!editor.plugins.has('MediaEmbed') || editor.config.get('mediaEmbed.previewsInData')) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const schema = editor.model.schema;
|
|
46
|
+
const conversion = editor.conversion;
|
|
47
|
+
const dataFilter = this.editor.plugins.get(DataFilter);
|
|
48
|
+
const dataSchema = this.editor.plugins.get(DataSchema);
|
|
49
|
+
const mediaElementName = editor.config.get('mediaEmbed.elementName');
|
|
50
|
+
// Overwrite GHS schema definition for a given elementName.
|
|
51
|
+
dataSchema.registerBlockElement({
|
|
52
|
+
model: 'media',
|
|
53
|
+
view: mediaElementName
|
|
54
|
+
});
|
|
55
|
+
dataFilter.on('register:figure', () => {
|
|
56
|
+
conversion.for('upcast').add(viewToModelFigureAttributesConverter(dataFilter));
|
|
57
|
+
});
|
|
58
|
+
dataFilter.on(`register:${mediaElementName}`, (evt, definition) => {
|
|
59
|
+
if (definition.model !== 'media') {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
schema.extend('media', {
|
|
63
|
+
allowAttributes: [
|
|
64
|
+
getHtmlAttributeName(mediaElementName),
|
|
65
|
+
'htmlFigureAttributes'
|
|
66
|
+
]
|
|
67
|
+
});
|
|
68
|
+
conversion.for('upcast').add(viewToModelMediaAttributesConverter(dataFilter, mediaElementName));
|
|
69
|
+
conversion.for('dataDowncast').add(modelToViewMediaAttributeConverter(mediaElementName));
|
|
70
|
+
evt.stop();
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function viewToModelMediaAttributesConverter(dataFilter, mediaElementName) {
|
|
75
|
+
const upcastMedia = (evt, data, conversionApi) => {
|
|
76
|
+
const viewMediaElement = data.viewItem;
|
|
77
|
+
preserveElementAttributes(viewMediaElement, getHtmlAttributeName(mediaElementName));
|
|
78
|
+
function preserveElementAttributes(viewElement, attributeName) {
|
|
79
|
+
const viewAttributes = dataFilter.processViewAttributes(viewElement, conversionApi);
|
|
80
|
+
if (viewAttributes) {
|
|
81
|
+
conversionApi.writer.setAttribute(attributeName, viewAttributes, data.modelRange);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
return (dispatcher) => {
|
|
86
|
+
dispatcher.on(`element:${mediaElementName}`, upcastMedia, { priority: 'low' });
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* View-to-model conversion helper preserving allowed attributes on {@link module:media-embed/mediaembed~MediaEmbed MediaEmbed}
|
|
91
|
+
* feature model element from figure view element.
|
|
92
|
+
*
|
|
93
|
+
* @returns Returns a conversion callback.
|
|
94
|
+
*/
|
|
95
|
+
function viewToModelFigureAttributesConverter(dataFilter) {
|
|
96
|
+
return (dispatcher) => {
|
|
97
|
+
dispatcher.on('element:figure', (evt, data, conversionApi) => {
|
|
98
|
+
const viewFigureElement = data.viewItem;
|
|
99
|
+
if (!data.modelRange || !viewFigureElement.hasClass('media')) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
const viewAttributes = dataFilter.processViewAttributes(viewFigureElement, conversionApi);
|
|
103
|
+
if (viewAttributes) {
|
|
104
|
+
conversionApi.writer.setAttribute('htmlFigureAttributes', viewAttributes, data.modelRange);
|
|
105
|
+
}
|
|
106
|
+
}, { priority: 'low' });
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
function modelToViewMediaAttributeConverter(mediaElementName) {
|
|
110
|
+
return (dispatcher) => {
|
|
111
|
+
addAttributeConversionDispatcherHandler(mediaElementName, getHtmlAttributeName(mediaElementName));
|
|
112
|
+
addAttributeConversionDispatcherHandler('figure', 'htmlFigureAttributes');
|
|
113
|
+
function addAttributeConversionDispatcherHandler(elementName, attributeName) {
|
|
114
|
+
dispatcher.on(`attribute:${attributeName}:media`, (evt, data, conversionApi) => {
|
|
115
|
+
if (!conversionApi.consumable.consume(data.item, evt.name)) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const { attributeOldValue, attributeNewValue } = data;
|
|
119
|
+
const containerElement = conversionApi.mapper.toViewElement(data.item);
|
|
120
|
+
const viewElement = getDescendantElement(conversionApi.writer, containerElement, elementName);
|
|
121
|
+
updateViewAttributes(conversionApi.writer, attributeOldValue, attributeNewValue, viewElement);
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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 } from 'ckeditor5/src/core.js';
|
|
9
|
+
import DataFilter from '../datafilter.js';
|
|
10
|
+
/**
|
|
11
|
+
* Provides the General HTML Support for `script` elements.
|
|
12
|
+
*/
|
|
13
|
+
export default class ScriptElementSupport extends Plugin {
|
|
14
|
+
/**
|
|
15
|
+
* @inheritDoc
|
|
16
|
+
*/
|
|
17
|
+
static get requires(): readonly [typeof DataFilter];
|
|
18
|
+
/**
|
|
19
|
+
* @inheritDoc
|
|
20
|
+
*/
|
|
21
|
+
static get pluginName(): "ScriptElementSupport";
|
|
22
|
+
/**
|
|
23
|
+
* @inheritDoc
|
|
24
|
+
*/
|
|
25
|
+
static get isOfficialPlugin(): true;
|
|
26
|
+
/**
|
|
27
|
+
* @inheritDoc
|
|
28
|
+
*/
|
|
29
|
+
init(): void;
|
|
30
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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 } from 'ckeditor5/src/core.js';
|
|
9
|
+
import { createObjectView, modelToViewBlockAttributeConverter, viewToModelBlockAttributeConverter, viewToModelObjectConverter } from '../converters.js';
|
|
10
|
+
import DataFilter from '../datafilter.js';
|
|
11
|
+
/**
|
|
12
|
+
* Provides the General HTML Support for `script` elements.
|
|
13
|
+
*/
|
|
14
|
+
export default class ScriptElementSupport extends Plugin {
|
|
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
|
+
static get isOfficialPlugin() {
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* @inheritDoc
|
|
35
|
+
*/
|
|
36
|
+
init() {
|
|
37
|
+
const dataFilter = this.editor.plugins.get(DataFilter);
|
|
38
|
+
dataFilter.on('register:script', (evt, definition) => {
|
|
39
|
+
const editor = this.editor;
|
|
40
|
+
const schema = editor.model.schema;
|
|
41
|
+
const conversion = editor.conversion;
|
|
42
|
+
schema.register('htmlScript', definition.modelSchema);
|
|
43
|
+
schema.extend('htmlScript', {
|
|
44
|
+
allowAttributes: ['htmlScriptAttributes', 'htmlContent'],
|
|
45
|
+
isContent: true
|
|
46
|
+
});
|
|
47
|
+
editor.data.registerRawContentMatcher({
|
|
48
|
+
name: 'script'
|
|
49
|
+
});
|
|
50
|
+
conversion.for('upcast').elementToElement({
|
|
51
|
+
view: 'script',
|
|
52
|
+
model: viewToModelObjectConverter(definition)
|
|
53
|
+
});
|
|
54
|
+
conversion.for('upcast').add(viewToModelBlockAttributeConverter(definition, dataFilter));
|
|
55
|
+
conversion.for('downcast').elementToElement({
|
|
56
|
+
model: 'htmlScript',
|
|
57
|
+
view: (modelElement, { writer }) => {
|
|
58
|
+
return createObjectView('script', modelElement, writer);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
conversion.for('downcast').add(modelToViewBlockAttributeConverter(definition));
|
|
62
|
+
evt.stop();
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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 } from 'ckeditor5/src/core.js';
|
|
9
|
+
import DataFilter from '../datafilter.js';
|
|
10
|
+
/**
|
|
11
|
+
* Provides the General HTML Support for `style` elements.
|
|
12
|
+
*/
|
|
13
|
+
export default class StyleElementSupport extends Plugin {
|
|
14
|
+
/**
|
|
15
|
+
* @inheritDoc
|
|
16
|
+
*/
|
|
17
|
+
static get requires(): readonly [typeof DataFilter];
|
|
18
|
+
/**
|
|
19
|
+
* @inheritDoc
|
|
20
|
+
*/
|
|
21
|
+
static get pluginName(): "StyleElementSupport";
|
|
22
|
+
/**
|
|
23
|
+
* @inheritDoc
|
|
24
|
+
*/
|
|
25
|
+
static get isOfficialPlugin(): true;
|
|
26
|
+
/**
|
|
27
|
+
* @inheritDoc
|
|
28
|
+
*/
|
|
29
|
+
init(): void;
|
|
30
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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 } from 'ckeditor5/src/core.js';
|
|
9
|
+
import { createObjectView, modelToViewBlockAttributeConverter, viewToModelBlockAttributeConverter, viewToModelObjectConverter } from '../converters.js';
|
|
10
|
+
import DataFilter from '../datafilter.js';
|
|
11
|
+
/**
|
|
12
|
+
* Provides the General HTML Support for `style` elements.
|
|
13
|
+
*/
|
|
14
|
+
export default class StyleElementSupport extends Plugin {
|
|
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
|
+
static get isOfficialPlugin() {
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* @inheritDoc
|
|
35
|
+
*/
|
|
36
|
+
init() {
|
|
37
|
+
const dataFilter = this.editor.plugins.get(DataFilter);
|
|
38
|
+
dataFilter.on('register:style', (evt, definition) => {
|
|
39
|
+
const editor = this.editor;
|
|
40
|
+
const schema = editor.model.schema;
|
|
41
|
+
const conversion = editor.conversion;
|
|
42
|
+
schema.register('htmlStyle', definition.modelSchema);
|
|
43
|
+
schema.extend('htmlStyle', {
|
|
44
|
+
allowAttributes: ['htmlStyleAttributes', 'htmlContent'],
|
|
45
|
+
isContent: true
|
|
46
|
+
});
|
|
47
|
+
editor.data.registerRawContentMatcher({
|
|
48
|
+
name: 'style'
|
|
49
|
+
});
|
|
50
|
+
conversion.for('upcast').elementToElement({
|
|
51
|
+
view: 'style',
|
|
52
|
+
model: viewToModelObjectConverter(definition)
|
|
53
|
+
});
|
|
54
|
+
conversion.for('upcast').add(viewToModelBlockAttributeConverter(definition, dataFilter));
|
|
55
|
+
conversion.for('downcast').elementToElement({
|
|
56
|
+
model: 'htmlStyle',
|
|
57
|
+
view: (modelElement, { writer }) => {
|
|
58
|
+
return createObjectView('style', modelElement, writer);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
conversion.for('downcast').add(modelToViewBlockAttributeConverter(definition));
|
|
62
|
+
evt.stop();
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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 } from 'ckeditor5/src/core.js';
|
|
6
|
+
import DataFilter from '../datafilter.js';
|
|
7
|
+
/**
|
|
8
|
+
* Provides the General HTML Support integration with {@link module:table/table~Table Table} feature.
|
|
9
|
+
*/
|
|
10
|
+
export default class TableElementSupport extends Plugin {
|
|
11
|
+
/**
|
|
12
|
+
* @inheritDoc
|
|
13
|
+
*/
|
|
14
|
+
static get requires(): readonly [typeof DataFilter];
|
|
15
|
+
/**
|
|
16
|
+
* @inheritDoc
|
|
17
|
+
*/
|
|
18
|
+
static get pluginName(): "TableElementSupport";
|
|
19
|
+
/**
|
|
20
|
+
* @inheritDoc
|
|
21
|
+
*/
|
|
22
|
+
static get isOfficialPlugin(): true;
|
|
23
|
+
/**
|
|
24
|
+
* @inheritDoc
|
|
25
|
+
*/
|
|
26
|
+
init(): void;
|
|
27
|
+
}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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 } from 'ckeditor5/src/core.js';
|
|
6
|
+
import { updateViewAttributes } from '../utils.js';
|
|
7
|
+
import DataFilter from '../datafilter.js';
|
|
8
|
+
import { getDescendantElement } from './integrationutils.js';
|
|
9
|
+
/**
|
|
10
|
+
* Provides the General HTML Support integration with {@link module:table/table~Table Table} feature.
|
|
11
|
+
*/
|
|
12
|
+
export default class TableElementSupport extends Plugin {
|
|
13
|
+
/**
|
|
14
|
+
* @inheritDoc
|
|
15
|
+
*/
|
|
16
|
+
static get requires() {
|
|
17
|
+
return [DataFilter];
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* @inheritDoc
|
|
21
|
+
*/
|
|
22
|
+
static get pluginName() {
|
|
23
|
+
return 'TableElementSupport';
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* @inheritDoc
|
|
27
|
+
*/
|
|
28
|
+
static get isOfficialPlugin() {
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* @inheritDoc
|
|
33
|
+
*/
|
|
34
|
+
init() {
|
|
35
|
+
const editor = this.editor;
|
|
36
|
+
if (!editor.plugins.has('TableEditing')) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const schema = editor.model.schema;
|
|
40
|
+
const conversion = editor.conversion;
|
|
41
|
+
const dataFilter = editor.plugins.get(DataFilter);
|
|
42
|
+
const tableUtils = editor.plugins.get('TableUtils');
|
|
43
|
+
dataFilter.on('register:figure', () => {
|
|
44
|
+
conversion.for('upcast').add(viewToModelFigureAttributeConverter(dataFilter));
|
|
45
|
+
});
|
|
46
|
+
dataFilter.on('register:table', (evt, definition) => {
|
|
47
|
+
if (definition.model !== 'table') {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
schema.extend('table', {
|
|
51
|
+
allowAttributes: [
|
|
52
|
+
'htmlTableAttributes',
|
|
53
|
+
// Figure, thead and tbody elements don't have model counterparts.
|
|
54
|
+
// We will be preserving attributes on table element using these attribute keys.
|
|
55
|
+
'htmlFigureAttributes', 'htmlTheadAttributes', 'htmlTbodyAttributes'
|
|
56
|
+
]
|
|
57
|
+
});
|
|
58
|
+
conversion.for('upcast').add(viewToModelTableAttributeConverter(dataFilter));
|
|
59
|
+
conversion.for('downcast').add(modelToViewTableAttributeConverter());
|
|
60
|
+
editor.model.document.registerPostFixer(createHeadingRowsPostFixer(editor.model, tableUtils));
|
|
61
|
+
evt.stop();
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Creates a model post-fixer for thead and tbody GHS related attributes.
|
|
67
|
+
*/
|
|
68
|
+
function createHeadingRowsPostFixer(model, tableUtils) {
|
|
69
|
+
return writer => {
|
|
70
|
+
const changes = model.document.differ.getChanges();
|
|
71
|
+
let wasFixed = false;
|
|
72
|
+
for (const change of changes) {
|
|
73
|
+
if (change.type != 'attribute' || change.attributeKey != 'headingRows') {
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
const table = change.range.start.nodeAfter;
|
|
77
|
+
const hasTHeadAttributes = table.getAttribute('htmlTheadAttributes');
|
|
78
|
+
const hasTBodyAttributes = table.getAttribute('htmlTbodyAttributes');
|
|
79
|
+
if (hasTHeadAttributes && !change.attributeNewValue) {
|
|
80
|
+
writer.removeAttribute('htmlTheadAttributes', table);
|
|
81
|
+
wasFixed = true;
|
|
82
|
+
}
|
|
83
|
+
else if (hasTBodyAttributes && change.attributeNewValue == tableUtils.getRows(table)) {
|
|
84
|
+
writer.removeAttribute('htmlTbodyAttributes', table);
|
|
85
|
+
wasFixed = true;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return wasFixed;
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* View-to-model conversion helper preserving allowed attributes on {@link module:table/table~Table Table}
|
|
93
|
+
* feature model element.
|
|
94
|
+
*
|
|
95
|
+
* @returns Returns a conversion callback.
|
|
96
|
+
*/
|
|
97
|
+
function viewToModelTableAttributeConverter(dataFilter) {
|
|
98
|
+
return (dispatcher) => {
|
|
99
|
+
dispatcher.on('element:table', (evt, data, conversionApi) => {
|
|
100
|
+
if (!data.modelRange) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
const viewTableElement = data.viewItem;
|
|
104
|
+
preserveElementAttributes(viewTableElement, 'htmlTableAttributes');
|
|
105
|
+
for (const childNode of viewTableElement.getChildren()) {
|
|
106
|
+
if (childNode.is('element', 'thead')) {
|
|
107
|
+
preserveElementAttributes(childNode, 'htmlTheadAttributes');
|
|
108
|
+
}
|
|
109
|
+
if (childNode.is('element', 'tbody')) {
|
|
110
|
+
preserveElementAttributes(childNode, 'htmlTbodyAttributes');
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
function preserveElementAttributes(viewElement, attributeName) {
|
|
114
|
+
const viewAttributes = dataFilter.processViewAttributes(viewElement, conversionApi);
|
|
115
|
+
if (viewAttributes) {
|
|
116
|
+
conversionApi.writer.setAttribute(attributeName, viewAttributes, data.modelRange);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}, { priority: 'low' });
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* View-to-model conversion helper preserving allowed attributes on {@link module:table/table~Table Table}
|
|
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('table')) {
|
|
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
|
+
* Model-to-view conversion helper applying attributes from {@link module:table/table~Table Table}
|
|
144
|
+
* feature.
|
|
145
|
+
*
|
|
146
|
+
* @returns Returns a conversion callback.
|
|
147
|
+
*/
|
|
148
|
+
function modelToViewTableAttributeConverter() {
|
|
149
|
+
return (dispatcher) => {
|
|
150
|
+
addAttributeConversionDispatcherHandler('table', 'htmlTableAttributes');
|
|
151
|
+
addAttributeConversionDispatcherHandler('figure', 'htmlFigureAttributes');
|
|
152
|
+
addAttributeConversionDispatcherHandler('thead', 'htmlTheadAttributes');
|
|
153
|
+
addAttributeConversionDispatcherHandler('tbody', 'htmlTbodyAttributes');
|
|
154
|
+
function addAttributeConversionDispatcherHandler(elementName, attributeName) {
|
|
155
|
+
dispatcher.on(`attribute:${attributeName}:table`, (evt, data, conversionApi) => {
|
|
156
|
+
if (!conversionApi.consumable.test(data.item, evt.name)) {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
const containerElement = conversionApi.mapper.toViewElement(data.item);
|
|
160
|
+
const viewElement = getDescendantElement(conversionApi.writer, containerElement, elementName);
|
|
161
|
+
if (!viewElement) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
conversionApi.consumable.consume(data.item, evt.name);
|
|
165
|
+
updateViewAttributes(conversionApi.writer, data.attributeOldValue, data.attributeNewValue, viewElement);
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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 { DataSchemaBlockElementDefinition, DataSchemaInlineElementDefinition } from './dataschema.js';
|
|
6
|
+
/**
|
|
7
|
+
* @module html-support/schemadefinitions
|
|
8
|
+
*/
|
|
9
|
+
declare const _default: {
|
|
10
|
+
block: DataSchemaBlockElementDefinition[];
|
|
11
|
+
inline: DataSchemaInlineElementDefinition[];
|
|
12
|
+
};
|
|
13
|
+
export default _default;
|