@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
|
@@ -1,209 +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 { 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
|
-
const STYLE_ATTRIBUTES_TO_PROPAGATE = [
|
|
10
|
-
'width',
|
|
11
|
-
'max-width',
|
|
12
|
-
'min-width',
|
|
13
|
-
'height',
|
|
14
|
-
'min-height',
|
|
15
|
-
'max-height'
|
|
16
|
-
];
|
|
17
|
-
/**
|
|
18
|
-
* Provides the General HTML Support integration with {@link module:table/table~Table Table} feature.
|
|
19
|
-
*/
|
|
20
|
-
export class TableElementSupport extends Plugin {
|
|
21
|
-
/**
|
|
22
|
-
* @inheritDoc
|
|
23
|
-
*/
|
|
24
|
-
static get requires() {
|
|
25
|
-
return [DataFilter];
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* @inheritDoc
|
|
29
|
-
*/
|
|
30
|
-
static get pluginName() {
|
|
31
|
-
return 'TableElementSupport';
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* @inheritDoc
|
|
35
|
-
*/
|
|
36
|
-
static get isOfficialPlugin() {
|
|
37
|
-
return true;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* @inheritDoc
|
|
41
|
-
*/
|
|
42
|
-
init() {
|
|
43
|
-
const editor = this.editor;
|
|
44
|
-
if (!editor.plugins.has('TableEditing')) {
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
const schema = editor.model.schema;
|
|
48
|
-
const conversion = editor.conversion;
|
|
49
|
-
const dataFilter = editor.plugins.get(DataFilter);
|
|
50
|
-
const tableUtils = editor.plugins.get('TableUtils');
|
|
51
|
-
dataFilter.on('register:figure', () => {
|
|
52
|
-
conversion.for('upcast').add(viewToModelFigureAttributeConverter(dataFilter));
|
|
53
|
-
});
|
|
54
|
-
dataFilter.on('register:table', (evt, definition) => {
|
|
55
|
-
if (definition.model !== 'table') {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
schema.extend('table', {
|
|
59
|
-
allowAttributes: [
|
|
60
|
-
'htmlTableAttributes',
|
|
61
|
-
// Figure, thead and tbody elements don't have model counterparts.
|
|
62
|
-
// We will be preserving attributes on table element using these attribute keys.
|
|
63
|
-
'htmlFigureAttributes', 'htmlTheadAttributes', 'htmlTbodyAttributes'
|
|
64
|
-
]
|
|
65
|
-
});
|
|
66
|
-
conversion.for('upcast').add(viewToModelTableAttributeConverter(dataFilter));
|
|
67
|
-
conversion.for('downcast').add(modelToViewTableAttributeConverter());
|
|
68
|
-
editor.model.document.registerPostFixer(createHeadingRowsPostFixer(editor.model, tableUtils));
|
|
69
|
-
evt.stop();
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Creates a model post-fixer for thead and tbody GHS related attributes.
|
|
75
|
-
*/
|
|
76
|
-
function createHeadingRowsPostFixer(model, tableUtils) {
|
|
77
|
-
return writer => {
|
|
78
|
-
const changes = model.document.differ.getChanges();
|
|
79
|
-
let wasFixed = false;
|
|
80
|
-
for (const change of changes) {
|
|
81
|
-
if (change.type != 'attribute' || change.attributeKey != 'headingRows') {
|
|
82
|
-
continue;
|
|
83
|
-
}
|
|
84
|
-
const table = change.range.start.nodeAfter;
|
|
85
|
-
const hasTHeadAttributes = table.getAttribute('htmlTheadAttributes');
|
|
86
|
-
const hasTBodyAttributes = table.getAttribute('htmlTbodyAttributes');
|
|
87
|
-
if (hasTHeadAttributes && !change.attributeNewValue) {
|
|
88
|
-
writer.removeAttribute('htmlTheadAttributes', table);
|
|
89
|
-
wasFixed = true;
|
|
90
|
-
}
|
|
91
|
-
else if (hasTBodyAttributes && change.attributeNewValue == tableUtils.getRows(table)) {
|
|
92
|
-
writer.removeAttribute('htmlTbodyAttributes', table);
|
|
93
|
-
wasFixed = true;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
return wasFixed;
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* View-to-model conversion helper preserving allowed attributes on {@link module:table/table~Table Table}
|
|
101
|
-
* feature model element.
|
|
102
|
-
*
|
|
103
|
-
* @returns Returns a conversion callback.
|
|
104
|
-
*/
|
|
105
|
-
function viewToModelTableAttributeConverter(dataFilter) {
|
|
106
|
-
return (dispatcher) => {
|
|
107
|
-
dispatcher.on('element:table', (evt, data, conversionApi) => {
|
|
108
|
-
if (!data.modelRange) {
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
const viewTableElement = data.viewItem;
|
|
112
|
-
// Prevent `table` class on both <table> and <figure> elements simultaneously.
|
|
113
|
-
conversionApi.consumable.consume(viewTableElement, { classes: 'table' });
|
|
114
|
-
preserveElementAttributes(viewTableElement, 'htmlTableAttributes');
|
|
115
|
-
for (const childNode of viewTableElement.getChildren()) {
|
|
116
|
-
if (childNode.is('element', 'thead')) {
|
|
117
|
-
preserveElementAttributes(childNode, 'htmlTheadAttributes');
|
|
118
|
-
}
|
|
119
|
-
if (childNode.is('element', 'tbody')) {
|
|
120
|
-
preserveElementAttributes(childNode, 'htmlTbodyAttributes');
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
function preserveElementAttributes(viewElement, attributeName) {
|
|
124
|
-
const viewAttributes = dataFilter.processViewAttributes(viewElement, conversionApi);
|
|
125
|
-
if (viewAttributes) {
|
|
126
|
-
conversionApi.writer.setAttribute(attributeName, viewAttributes, data.modelRange);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}, { priority: 'low' });
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* View-to-model conversion helper preserving allowed attributes on {@link module:table/table~Table Table}
|
|
134
|
-
* feature model element from figure view element.
|
|
135
|
-
*
|
|
136
|
-
* @returns Returns a conversion callback.
|
|
137
|
-
*/
|
|
138
|
-
function viewToModelFigureAttributeConverter(dataFilter) {
|
|
139
|
-
return (dispatcher) => {
|
|
140
|
-
dispatcher.on('element:figure', (evt, data, conversionApi) => {
|
|
141
|
-
const viewFigureElement = data.viewItem;
|
|
142
|
-
if (!data.modelRange || !viewFigureElement.hasClass('table')) {
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
const viewAttributes = dataFilter.processViewAttributes(viewFigureElement, conversionApi);
|
|
146
|
-
if (viewAttributes) {
|
|
147
|
-
conversionApi.writer.setAttribute('htmlFigureAttributes', viewAttributes, data.modelRange);
|
|
148
|
-
}
|
|
149
|
-
}, { priority: 'low' });
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* Model-to-view conversion helper applying attributes from {@link module:table/table~Table Table}
|
|
154
|
-
* feature.
|
|
155
|
-
*
|
|
156
|
-
* @returns Returns a conversion callback.
|
|
157
|
-
*/
|
|
158
|
-
function modelToViewTableAttributeConverter() {
|
|
159
|
-
return (dispatcher) => {
|
|
160
|
-
addAttributeConversionDispatcherHandler('table', 'htmlTableAttributes');
|
|
161
|
-
addAttributeConversionDispatcherHandler('figure', 'htmlFigureAttributes');
|
|
162
|
-
addAttributeConversionDispatcherHandler('thead', 'htmlTheadAttributes');
|
|
163
|
-
addAttributeConversionDispatcherHandler('tbody', 'htmlTbodyAttributes');
|
|
164
|
-
function addAttributeConversionDispatcherHandler(elementName, attributeName) {
|
|
165
|
-
dispatcher.on(`attribute:${attributeName}:table`, (evt, data, conversionApi) => {
|
|
166
|
-
if (!conversionApi.consumable.test(data.item, evt.name)) {
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
const containerElement = conversionApi.mapper.toViewElement(data.item);
|
|
170
|
-
const viewElement = getDescendantElement(conversionApi.writer, containerElement, elementName);
|
|
171
|
-
if (!viewElement) {
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
conversionApi.consumable.consume(data.item, evt.name);
|
|
175
|
-
// Downcast selected styles to a figure element instead of a table element.
|
|
176
|
-
if (attributeName === 'htmlTableAttributes' && containerElement !== viewElement) {
|
|
177
|
-
const oldAttributes = splitAttributesForFigureAndTable(data.attributeOldValue);
|
|
178
|
-
const newAttributes = splitAttributesForFigureAndTable(data.attributeNewValue);
|
|
179
|
-
updateViewAttributes(conversionApi.writer, oldAttributes.tableAttributes, newAttributes.tableAttributes, viewElement);
|
|
180
|
-
updateViewAttributes(conversionApi.writer, oldAttributes.figureAttributes, newAttributes.figureAttributes, containerElement);
|
|
181
|
-
}
|
|
182
|
-
else {
|
|
183
|
-
updateViewAttributes(conversionApi.writer, data.attributeOldValue, data.attributeNewValue, viewElement);
|
|
184
|
-
}
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* Splits styles based on the `STYLE_ATTRIBUTES_TO_PROPAGATE` pattern that should be moved to the parent element
|
|
191
|
-
* and those that should remain on element.
|
|
192
|
-
*/
|
|
193
|
-
function splitAttributesForFigureAndTable(data) {
|
|
194
|
-
const figureAttributes = {};
|
|
195
|
-
const tableAttributes = { ...data };
|
|
196
|
-
if (!data || !('styles' in data)) {
|
|
197
|
-
return { figureAttributes, tableAttributes };
|
|
198
|
-
}
|
|
199
|
-
tableAttributes.styles = {};
|
|
200
|
-
for (const [key, value] of Object.entries(data.styles)) {
|
|
201
|
-
if (STYLE_ATTRIBUTES_TO_PROPAGATE.includes(key)) {
|
|
202
|
-
figureAttributes.styles = { ...figureAttributes.styles, [key]: value };
|
|
203
|
-
}
|
|
204
|
-
else {
|
|
205
|
-
tableAttributes.styles = { ...tableAttributes.styles, [key]: value };
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
return { figureAttributes, tableAttributes };
|
|
209
|
-
}
|