@ckeditor/ckeditor5-html-support 47.6.1 → 48.0.0-alpha.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/LICENSE.md +1 -1
- package/ckeditor5-metadata.json +6 -6
- package/{src → dist}/converters.d.ts +2 -2
- package/{src → dist}/datafilter.d.ts +3 -3
- package/{src → dist}/dataschema.d.ts +2 -2
- package/{src → dist}/emptyblock.d.ts +1 -1
- package/{src → dist}/fullpage.d.ts +1 -1
- package/{src → dist}/generalhtmlsupport.d.ts +3 -3
- package/{src → dist}/generalhtmlsupportconfig.d.ts +1 -1
- package/{src → dist}/htmlcomment.d.ts +2 -2
- package/{src → dist}/htmlpagedataprocessor.d.ts +1 -1
- package/dist/index-editor.css +29 -29
- package/dist/index.css +30 -40
- package/dist/index.css.map +1 -1
- package/dist/index.js +29 -8
- package/dist/index.js.map +1 -1
- package/{src → dist}/integrations/codeblock.d.ts +1 -1
- package/{src → dist}/integrations/customelement.d.ts +1 -1
- package/{src → dist}/integrations/dualcontent.d.ts +1 -1
- package/{src → dist}/integrations/heading.d.ts +2 -2
- package/{src → dist}/integrations/horizontalline.d.ts +1 -1
- package/{src → dist}/integrations/iframe.d.ts +1 -1
- package/{src → dist}/integrations/image.d.ts +1 -1
- package/{src → dist}/integrations/integrationutils.d.ts +1 -1
- package/{src → dist}/integrations/list.d.ts +1 -1
- package/{src → dist}/integrations/mediaembed.d.ts +1 -1
- package/{src → dist}/integrations/script.d.ts +1 -1
- package/{src → dist}/integrations/style.d.ts +1 -1
- package/{src → dist}/integrations/table.d.ts +1 -1
- package/{src → dist}/schemadefinitions.d.ts +2 -2
- package/{src → dist}/utils.d.ts +1 -1
- package/package.json +30 -53
- package/build/html-support.js +0 -5
- package/build/translations/af.js +0 -1
- package/build/translations/ar.js +0 -1
- package/build/translations/ast.js +0 -1
- package/build/translations/az.js +0 -1
- package/build/translations/be.js +0 -1
- package/build/translations/bg.js +0 -1
- package/build/translations/bn.js +0 -1
- package/build/translations/bs.js +0 -1
- package/build/translations/ca.js +0 -1
- package/build/translations/cs.js +0 -1
- package/build/translations/da.js +0 -1
- package/build/translations/de-ch.js +0 -1
- package/build/translations/de.js +0 -1
- package/build/translations/el.js +0 -1
- package/build/translations/en-au.js +0 -1
- package/build/translations/en-gb.js +0 -1
- package/build/translations/eo.js +0 -1
- package/build/translations/es-co.js +0 -1
- package/build/translations/es.js +0 -1
- package/build/translations/et.js +0 -1
- package/build/translations/eu.js +0 -1
- package/build/translations/fa.js +0 -1
- package/build/translations/fi.js +0 -1
- package/build/translations/fr.js +0 -1
- package/build/translations/gl.js +0 -1
- package/build/translations/gu.js +0 -1
- package/build/translations/he.js +0 -1
- package/build/translations/hi.js +0 -1
- package/build/translations/hr.js +0 -1
- package/build/translations/hu.js +0 -1
- package/build/translations/hy.js +0 -1
- package/build/translations/id.js +0 -1
- package/build/translations/it.js +0 -1
- package/build/translations/ja.js +0 -1
- package/build/translations/jv.js +0 -1
- package/build/translations/kk.js +0 -1
- package/build/translations/km.js +0 -1
- package/build/translations/kn.js +0 -1
- package/build/translations/ko.js +0 -1
- package/build/translations/ku.js +0 -1
- package/build/translations/lt.js +0 -1
- package/build/translations/lv.js +0 -1
- package/build/translations/ms.js +0 -1
- package/build/translations/nb.js +0 -1
- package/build/translations/ne.js +0 -1
- package/build/translations/nl.js +0 -1
- package/build/translations/no.js +0 -1
- package/build/translations/oc.js +0 -1
- package/build/translations/pl.js +0 -1
- package/build/translations/pt-br.js +0 -1
- package/build/translations/pt.js +0 -1
- package/build/translations/ro.js +0 -1
- package/build/translations/ru.js +0 -1
- package/build/translations/si.js +0 -1
- package/build/translations/sk.js +0 -1
- package/build/translations/sl.js +0 -1
- package/build/translations/sq.js +0 -1
- package/build/translations/sr-latn.js +0 -1
- package/build/translations/sr.js +0 -1
- package/build/translations/sv.js +0 -1
- package/build/translations/th.js +0 -1
- package/build/translations/ti.js +0 -1
- package/build/translations/tk.js +0 -1
- package/build/translations/tr.js +0 -1
- package/build/translations/tt.js +0 -1
- package/build/translations/ug.js +0 -1
- package/build/translations/uk.js +0 -1
- package/build/translations/ur.js +0 -1
- package/build/translations/uz.js +0 -1
- package/build/translations/vi.js +0 -1
- package/build/translations/zh-cn.js +0 -1
- package/build/translations/zh.js +0 -1
- package/lang/contexts.json +0 -3
- package/lang/translations/af.po +0 -16
- package/lang/translations/ar.po +0 -16
- package/lang/translations/ast.po +0 -16
- package/lang/translations/az.po +0 -16
- package/lang/translations/be.po +0 -16
- package/lang/translations/bg.po +0 -16
- package/lang/translations/bn.po +0 -16
- package/lang/translations/bs.po +0 -16
- package/lang/translations/ca.po +0 -16
- package/lang/translations/cs.po +0 -16
- package/lang/translations/da.po +0 -16
- package/lang/translations/de-ch.po +0 -16
- package/lang/translations/de.po +0 -16
- package/lang/translations/el.po +0 -16
- package/lang/translations/en-au.po +0 -16
- package/lang/translations/en-gb.po +0 -16
- package/lang/translations/en.po +0 -16
- package/lang/translations/eo.po +0 -16
- package/lang/translations/es-co.po +0 -16
- package/lang/translations/es.po +0 -16
- package/lang/translations/et.po +0 -16
- package/lang/translations/eu.po +0 -16
- package/lang/translations/fa.po +0 -16
- package/lang/translations/fi.po +0 -16
- package/lang/translations/fr.po +0 -16
- package/lang/translations/gl.po +0 -16
- package/lang/translations/gu.po +0 -16
- package/lang/translations/he.po +0 -16
- package/lang/translations/hi.po +0 -16
- package/lang/translations/hr.po +0 -16
- package/lang/translations/hu.po +0 -16
- package/lang/translations/hy.po +0 -16
- package/lang/translations/id.po +0 -16
- package/lang/translations/it.po +0 -16
- package/lang/translations/ja.po +0 -16
- package/lang/translations/jv.po +0 -16
- package/lang/translations/kk.po +0 -16
- package/lang/translations/km.po +0 -16
- package/lang/translations/kn.po +0 -16
- package/lang/translations/ko.po +0 -16
- package/lang/translations/ku.po +0 -16
- package/lang/translations/lt.po +0 -16
- package/lang/translations/lv.po +0 -16
- package/lang/translations/ms.po +0 -16
- package/lang/translations/nb.po +0 -16
- package/lang/translations/ne.po +0 -16
- package/lang/translations/nl.po +0 -16
- package/lang/translations/no.po +0 -16
- package/lang/translations/oc.po +0 -16
- package/lang/translations/pl.po +0 -16
- package/lang/translations/pt-br.po +0 -16
- package/lang/translations/pt.po +0 -16
- package/lang/translations/ro.po +0 -16
- package/lang/translations/ru.po +0 -16
- package/lang/translations/si.po +0 -16
- package/lang/translations/sk.po +0 -16
- package/lang/translations/sl.po +0 -16
- package/lang/translations/sq.po +0 -16
- package/lang/translations/sr-latn.po +0 -16
- package/lang/translations/sr.po +0 -16
- package/lang/translations/sv.po +0 -16
- package/lang/translations/th.po +0 -16
- package/lang/translations/ti.po +0 -16
- package/lang/translations/tk.po +0 -16
- package/lang/translations/tr.po +0 -16
- package/lang/translations/tt.po +0 -16
- package/lang/translations/ug.po +0 -16
- package/lang/translations/uk.po +0 -16
- package/lang/translations/ur.po +0 -16
- package/lang/translations/uz.po +0 -16
- package/lang/translations/vi.po +0 -16
- package/lang/translations/zh-cn.po +0 -16
- package/lang/translations/zh.po +0 -16
- package/src/augmentation.js +0 -5
- package/src/converters.js +0 -190
- package/src/datafilter.js +0 -837
- package/src/dataschema.js +0 -199
- package/src/emptyblock.js +0 -146
- package/src/fullpage.js +0 -184
- package/src/generalhtmlsupport.js +0 -257
- package/src/generalhtmlsupportconfig.js +0 -5
- package/src/htmlcomment.js +0 -225
- package/src/htmlpagedataprocessor.js +0 -70
- package/src/index.js +0 -31
- package/src/integrations/codeblock.js +0 -107
- package/src/integrations/customelement.js +0 -166
- package/src/integrations/dualcontent.js +0 -126
- package/src/integrations/heading.js +0 -72
- package/src/integrations/horizontalline.js +0 -80
- package/src/integrations/iframe.js +0 -76
- package/src/integrations/image.js +0 -195
- package/src/integrations/integrationutils.js +0 -21
- package/src/integrations/list.js +0 -185
- package/src/integrations/mediaembed.js +0 -125
- package/src/integrations/script.js +0 -66
- package/src/integrations/style.js +0 -66
- package/src/integrations/table.js +0 -209
- package/src/schemadefinitions.js +0 -979
- package/src/utils.js +0 -169
- package/theme/datafilter.css +0 -56
- /package/{src → dist}/augmentation.d.ts +0 -0
- /package/{src → dist}/index.d.ts +0 -0
package/lang/translations/ug.po
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
# Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
2
|
-
#
|
|
3
|
-
# Want to contribute to this file? Submit your changes via a GitHub Pull Request.
|
|
4
|
-
#
|
|
5
|
-
# Check out the official contributor's guide:
|
|
6
|
-
# https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
|
|
7
|
-
#
|
|
8
|
-
msgid ""
|
|
9
|
-
msgstr ""
|
|
10
|
-
"Language: ug\n"
|
|
11
|
-
"Plural-Forms: nplurals=1; plural=0;\n"
|
|
12
|
-
"Content-Type: text/plain; charset=UTF-8\n"
|
|
13
|
-
|
|
14
|
-
msgctxt "A label describing an HTML object widget."
|
|
15
|
-
msgid "HTML object"
|
|
16
|
-
msgstr "HTML جىسىم"
|
package/lang/translations/uk.po
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
# Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
2
|
-
#
|
|
3
|
-
# Want to contribute to this file? Submit your changes via a GitHub Pull Request.
|
|
4
|
-
#
|
|
5
|
-
# Check out the official contributor's guide:
|
|
6
|
-
# https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
|
|
7
|
-
#
|
|
8
|
-
msgid ""
|
|
9
|
-
msgstr ""
|
|
10
|
-
"Language: uk\n"
|
|
11
|
-
"Plural-Forms: nplurals=3; plural=(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);\n"
|
|
12
|
-
"Content-Type: text/plain; charset=UTF-8\n"
|
|
13
|
-
|
|
14
|
-
msgctxt "A label describing an HTML object widget."
|
|
15
|
-
msgid "HTML object"
|
|
16
|
-
msgstr "HTML об'єкт"
|
package/lang/translations/ur.po
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
# Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
2
|
-
#
|
|
3
|
-
# Want to contribute to this file? Submit your changes via a GitHub Pull Request.
|
|
4
|
-
#
|
|
5
|
-
# Check out the official contributor's guide:
|
|
6
|
-
# https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
|
|
7
|
-
#
|
|
8
|
-
msgid ""
|
|
9
|
-
msgstr ""
|
|
10
|
-
"Language: ur\n"
|
|
11
|
-
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
|
12
|
-
"Content-Type: text/plain; charset=UTF-8\n"
|
|
13
|
-
|
|
14
|
-
msgctxt "A label describing an HTML object widget."
|
|
15
|
-
msgid "HTML object"
|
|
16
|
-
msgstr "ایچ ٹی ایم ایل آبجیکٹ"
|
package/lang/translations/uz.po
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
# Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
2
|
-
#
|
|
3
|
-
# Want to contribute to this file? Submit your changes via a GitHub Pull Request.
|
|
4
|
-
#
|
|
5
|
-
# Check out the official contributor's guide:
|
|
6
|
-
# https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
|
|
7
|
-
#
|
|
8
|
-
msgid ""
|
|
9
|
-
msgstr ""
|
|
10
|
-
"Language: uz\n"
|
|
11
|
-
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
|
12
|
-
"Content-Type: text/plain; charset=UTF-8\n"
|
|
13
|
-
|
|
14
|
-
msgctxt "A label describing an HTML object widget."
|
|
15
|
-
msgid "HTML object"
|
|
16
|
-
msgstr ""
|
package/lang/translations/vi.po
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
# Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
2
|
-
#
|
|
3
|
-
# Want to contribute to this file? Submit your changes via a GitHub Pull Request.
|
|
4
|
-
#
|
|
5
|
-
# Check out the official contributor's guide:
|
|
6
|
-
# https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
|
|
7
|
-
#
|
|
8
|
-
msgid ""
|
|
9
|
-
msgstr ""
|
|
10
|
-
"Language: vi\n"
|
|
11
|
-
"Plural-Forms: nplurals=1; plural=0;\n"
|
|
12
|
-
"Content-Type: text/plain; charset=UTF-8\n"
|
|
13
|
-
|
|
14
|
-
msgctxt "A label describing an HTML object widget."
|
|
15
|
-
msgid "HTML object"
|
|
16
|
-
msgstr "Đối tượng HTML"
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
# Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
2
|
-
#
|
|
3
|
-
# Want to contribute to this file? Submit your changes via a GitHub Pull Request.
|
|
4
|
-
#
|
|
5
|
-
# Check out the official contributor's guide:
|
|
6
|
-
# https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
|
|
7
|
-
#
|
|
8
|
-
msgid ""
|
|
9
|
-
msgstr ""
|
|
10
|
-
"Language: zh_CN\n"
|
|
11
|
-
"Plural-Forms: nplurals=1; plural=0;\n"
|
|
12
|
-
"Content-Type: text/plain; charset=UTF-8\n"
|
|
13
|
-
|
|
14
|
-
msgctxt "A label describing an HTML object widget."
|
|
15
|
-
msgid "HTML object"
|
|
16
|
-
msgstr "HTML对象"
|
package/lang/translations/zh.po
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
# Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
2
|
-
#
|
|
3
|
-
# Want to contribute to this file? Submit your changes via a GitHub Pull Request.
|
|
4
|
-
#
|
|
5
|
-
# Check out the official contributor's guide:
|
|
6
|
-
# https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
|
|
7
|
-
#
|
|
8
|
-
msgid ""
|
|
9
|
-
msgstr ""
|
|
10
|
-
"Language: zh_TW\n"
|
|
11
|
-
"Plural-Forms: nplurals=1; plural=0;\n"
|
|
12
|
-
"Content-Type: text/plain; charset=UTF-8\n"
|
|
13
|
-
|
|
14
|
-
msgctxt "A label describing an HTML object widget."
|
|
15
|
-
msgid "HTML object"
|
|
16
|
-
msgstr "HTML 物件"
|
package/src/augmentation.js
DELETED
package/src/converters.js
DELETED
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
-
*/
|
|
5
|
-
import { toWidget } from 'ckeditor5/src/widget.js';
|
|
6
|
-
import { setViewAttributes, mergeViewElementAttributes, updateViewAttributes, getHtmlAttributeName } from './utils.js';
|
|
7
|
-
/**
|
|
8
|
-
* View-to-model conversion helper for object elements.
|
|
9
|
-
*
|
|
10
|
-
* Preserves object element content in `htmlContent` attribute.
|
|
11
|
-
*
|
|
12
|
-
* @returns Returns a conversion callback.
|
|
13
|
-
* @internal
|
|
14
|
-
*/
|
|
15
|
-
export function viewToModelObjectConverter({ model: modelName }) {
|
|
16
|
-
return (viewElement, conversionApi) => {
|
|
17
|
-
// Let's keep element HTML and its attributes, so we can rebuild element in downcast conversions.
|
|
18
|
-
return conversionApi.writer.createElement(modelName, {
|
|
19
|
-
htmlContent: viewElement.getCustomProperty('$rawContent')
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Conversion helper converting an object element to an HTML object widget.
|
|
25
|
-
*
|
|
26
|
-
* @returns Returns a conversion callback.
|
|
27
|
-
* @internal
|
|
28
|
-
*/
|
|
29
|
-
export function toObjectWidgetConverter(editor, { view: viewName, isInline }) {
|
|
30
|
-
const t = editor.t;
|
|
31
|
-
return (modelElement, { writer }) => {
|
|
32
|
-
const widgetLabel = t('HTML object');
|
|
33
|
-
const viewElement = createObjectView(viewName, modelElement, writer);
|
|
34
|
-
const viewAttributes = modelElement.getAttribute(getHtmlAttributeName(viewName));
|
|
35
|
-
writer.addClass('html-object-embed__content', viewElement);
|
|
36
|
-
if (viewAttributes) {
|
|
37
|
-
setViewAttributes(writer, viewAttributes, viewElement);
|
|
38
|
-
}
|
|
39
|
-
// Widget cannot be a raw element because the widget system would not be able
|
|
40
|
-
// to add its UI to it. Thus, we need separate view container.
|
|
41
|
-
const viewContainer = writer.createContainerElement(isInline ? 'span' : 'div', {
|
|
42
|
-
class: 'html-object-embed',
|
|
43
|
-
'data-html-object-embed-label': widgetLabel
|
|
44
|
-
}, viewElement);
|
|
45
|
-
return toWidget(viewContainer, writer, { label: widgetLabel });
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Creates object view element from the given model element.
|
|
50
|
-
*
|
|
51
|
-
* @internal
|
|
52
|
-
*/
|
|
53
|
-
export function createObjectView(viewName, modelElement, writer) {
|
|
54
|
-
return writer.createRawElement(viewName, null, (domElement, domConverter) => {
|
|
55
|
-
domConverter.setContentOf(domElement, modelElement.getAttribute('htmlContent'));
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* View-to-attribute conversion helper preserving inline element attributes on `$text`.
|
|
60
|
-
*
|
|
61
|
-
* @returns Returns a conversion callback.
|
|
62
|
-
* @internal
|
|
63
|
-
*/
|
|
64
|
-
export function viewToAttributeInlineConverter({ view: viewName, model: attributeKey, allowEmpty }, dataFilter) {
|
|
65
|
-
return dispatcher => {
|
|
66
|
-
dispatcher.on(`element:${viewName}`, (evt, data, conversionApi) => {
|
|
67
|
-
let viewAttributes = dataFilter.processViewAttributes(data.viewItem, conversionApi);
|
|
68
|
-
// Do not apply the attribute if the element itself is already consumed and there are no view attributes to store.
|
|
69
|
-
if (!viewAttributes && !conversionApi.consumable.test(data.viewItem, { name: true })) {
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
// Otherwise, we might need to convert it to an empty object just to preserve element itself,
|
|
73
|
-
// for example `<cite>` => <$text htmlCite="{}">.
|
|
74
|
-
viewAttributes = viewAttributes || {};
|
|
75
|
-
// Consume the element itself if it wasn't consumed by any other converter.
|
|
76
|
-
conversionApi.consumable.consume(data.viewItem, { name: true });
|
|
77
|
-
// Since we are converting to attribute we need a range on which we will set the attribute.
|
|
78
|
-
// If the range is not created yet, we will create it.
|
|
79
|
-
if (!data.modelRange) {
|
|
80
|
-
data = Object.assign(data, conversionApi.convertChildren(data.viewItem, data.modelCursor));
|
|
81
|
-
}
|
|
82
|
-
// Convert empty inline element if allowed and has any attributes.
|
|
83
|
-
if (allowEmpty && data.modelRange.isCollapsed && Object.keys(viewAttributes).length) {
|
|
84
|
-
const modelElement = conversionApi.writer.createElement('htmlEmptyElement');
|
|
85
|
-
if (!conversionApi.safeInsert(modelElement, data.modelCursor)) {
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
const parts = conversionApi.getSplitParts(modelElement);
|
|
89
|
-
data.modelRange = conversionApi.writer.createRange(data.modelRange.start, conversionApi.writer.createPositionAfter(parts[parts.length - 1]));
|
|
90
|
-
conversionApi.updateConversionResult(modelElement, data);
|
|
91
|
-
setAttributeOnItem(modelElement, viewAttributes, conversionApi);
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
// Set attribute on each item in range according to the schema.
|
|
95
|
-
for (const node of data.modelRange.getItems()) {
|
|
96
|
-
setAttributeOnItem(node, viewAttributes, conversionApi);
|
|
97
|
-
}
|
|
98
|
-
}, { priority: 'low' });
|
|
99
|
-
};
|
|
100
|
-
function setAttributeOnItem(node, viewAttributes, conversionApi) {
|
|
101
|
-
if (conversionApi.schema.checkAttribute(node, attributeKey)) {
|
|
102
|
-
// Node's children are converted recursively, so node can already include model attribute.
|
|
103
|
-
// We want to extend it, not replace.
|
|
104
|
-
const nodeAttributes = node.getAttribute(attributeKey);
|
|
105
|
-
const attributesToAdd = mergeViewElementAttributes(viewAttributes, nodeAttributes || {});
|
|
106
|
-
conversionApi.writer.setAttribute(attributeKey, attributesToAdd, node);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Conversion helper converting an empty inline model element to an HTML element or widget.
|
|
112
|
-
*
|
|
113
|
-
* @internal
|
|
114
|
-
*/
|
|
115
|
-
export function emptyInlineModelElementToViewConverter({ model: attributeKey, view: viewName }, asWidget) {
|
|
116
|
-
return (item, { writer, consumable }) => {
|
|
117
|
-
if (!item.hasAttribute(attributeKey)) {
|
|
118
|
-
return null;
|
|
119
|
-
}
|
|
120
|
-
const viewElement = writer.createContainerElement(viewName);
|
|
121
|
-
const attributeValue = item.getAttribute(attributeKey);
|
|
122
|
-
consumable.consume(item, `attribute:${attributeKey}`);
|
|
123
|
-
setViewAttributes(writer, attributeValue, viewElement);
|
|
124
|
-
viewElement.getFillerOffset = () => null;
|
|
125
|
-
return asWidget ? toWidget(viewElement, writer) : viewElement;
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Attribute-to-view conversion helper applying attributes to view element preserved on `$text`.
|
|
130
|
-
*
|
|
131
|
-
* @returns Returns a conversion callback.
|
|
132
|
-
* @internal
|
|
133
|
-
*/
|
|
134
|
-
export function attributeToViewInlineConverter({ priority, view: viewName }) {
|
|
135
|
-
return (attributeValue, conversionApi) => {
|
|
136
|
-
if (!attributeValue) {
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
const { writer } = conversionApi;
|
|
140
|
-
const viewElement = writer.createAttributeElement(viewName, null, { priority });
|
|
141
|
-
setViewAttributes(writer, attributeValue, viewElement);
|
|
142
|
-
return viewElement;
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* View-to-model conversion helper preserving allowed attributes on block element.
|
|
147
|
-
*
|
|
148
|
-
* All matched attributes will be preserved on `html*Attributes` attribute.
|
|
149
|
-
*
|
|
150
|
-
* @returns Returns a conversion callback.
|
|
151
|
-
* @internal
|
|
152
|
-
*/
|
|
153
|
-
export function viewToModelBlockAttributeConverter({ view: viewName }, dataFilter) {
|
|
154
|
-
return (dispatcher) => {
|
|
155
|
-
dispatcher.on(`element:${viewName}`, (evt, data, conversionApi) => {
|
|
156
|
-
// Converting an attribute of an element that has not been converted to anything does not make sense
|
|
157
|
-
// because there will be nowhere to set that attribute on. At this stage, the element should've already
|
|
158
|
-
// been converted. A collapsed range can show up in to-do lists (<input>) or complex widgets (e.g. table).
|
|
159
|
-
// (https://github.com/ckeditor/ckeditor5/issues/11000).
|
|
160
|
-
if (!data.modelRange || data.modelRange.isCollapsed) {
|
|
161
|
-
return;
|
|
162
|
-
}
|
|
163
|
-
const viewAttributes = dataFilter.processViewAttributes(data.viewItem, conversionApi);
|
|
164
|
-
if (!viewAttributes) {
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
|
-
conversionApi.writer.setAttribute(getHtmlAttributeName(data.viewItem.name), viewAttributes, data.modelRange);
|
|
168
|
-
}, { priority: 'low' });
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Model-to-view conversion helper applying attributes preserved in `html*Attributes` attribute
|
|
173
|
-
* for block elements.
|
|
174
|
-
*
|
|
175
|
-
* @returns Returns a conversion callback.
|
|
176
|
-
* @internal
|
|
177
|
-
*/
|
|
178
|
-
export function modelToViewBlockAttributeConverter({ view: viewName, model: modelName }) {
|
|
179
|
-
return (dispatcher) => {
|
|
180
|
-
dispatcher.on(`attribute:${getHtmlAttributeName(viewName)}:${modelName}`, (evt, data, conversionApi) => {
|
|
181
|
-
if (!conversionApi.consumable.consume(data.item, evt.name)) {
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
const { attributeOldValue, attributeNewValue } = data;
|
|
185
|
-
const viewWriter = conversionApi.writer;
|
|
186
|
-
const viewElement = conversionApi.mapper.toViewElement(data.item);
|
|
187
|
-
updateViewAttributes(viewWriter, attributeOldValue, attributeNewValue, viewElement);
|
|
188
|
-
});
|
|
189
|
-
};
|
|
190
|
-
}
|