@ckeditor/ckeditor5-html-support 45.2.1 → 46.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/build/html-support.js +2 -2
- package/dist/index.js +110 -54
- package/dist/index.js.map +1 -1
- package/package.json +13 -12
- package/src/converters.d.ts +21 -11
- package/src/converters.js +10 -0
- package/src/datafilter.d.ts +6 -6
- package/src/datafilter.js +7 -5
- package/src/dataschema.d.ts +14 -14
- package/src/dataschema.js +2 -2
- package/src/emptyblock.d.ts +1 -1
- package/src/emptyblock.js +1 -1
- package/src/fullpage.d.ts +1 -1
- package/src/fullpage.js +4 -4
- package/src/generalhtmlsupport.d.ts +20 -16
- package/src/generalhtmlsupport.js +21 -14
- package/src/generalhtmlsupportconfig.d.ts +5 -5
- package/src/htmlcomment.d.ts +6 -6
- package/src/htmlcomment.js +1 -1
- package/src/htmlpagedataprocessor.d.ts +1 -1
- package/src/htmlpagedataprocessor.js +3 -3
- package/src/index.d.ts +23 -19
- package/src/index.js +11 -7
- package/src/integrations/codeblock.d.ts +2 -2
- package/src/integrations/codeblock.js +2 -2
- package/src/integrations/customelement.d.ts +3 -3
- package/src/integrations/customelement.js +7 -6
- package/src/integrations/dualcontent.d.ts +6 -5
- package/src/integrations/dualcontent.js +6 -5
- package/src/integrations/heading.d.ts +2 -2
- package/src/integrations/heading.js +2 -2
- package/src/integrations/horizontalline.d.ts +2 -2
- package/src/integrations/horizontalline.js +2 -2
- package/src/integrations/image.d.ts +2 -2
- package/src/integrations/image.js +2 -2
- package/src/integrations/integrationutils.d.ts +2 -2
- package/src/integrations/list.d.ts +2 -2
- package/src/integrations/list.js +2 -2
- package/src/integrations/mediaembed.d.ts +2 -2
- package/src/integrations/mediaembed.js +3 -3
- package/src/integrations/script.d.ts +2 -2
- package/src/integrations/script.js +4 -3
- package/src/integrations/style.d.ts +2 -2
- package/src/integrations/style.js +4 -3
- package/src/integrations/table.d.ts +2 -2
- package/src/integrations/table.js +2 -2
- package/src/schemadefinitions.d.ts +49 -5
- package/src/schemadefinitions.js +50 -43
- package/src/utils.d.ts +26 -7
- package/src/utils.js +30 -0
|
@@ -2,12 +2,56 @@
|
|
|
2
2
|
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
4
|
*/
|
|
5
|
-
import type {
|
|
5
|
+
import type { HtmlSupportDataSchemaBlockElementDefinition, HtmlSupportDataSchemaInlineElementDefinition } from './dataschema.js';
|
|
6
6
|
/**
|
|
7
7
|
* @module html-support/schemadefinitions
|
|
8
8
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Skipped elements due to HTML deprecation:
|
|
11
|
+
* * noframes (not sure if we should provide support for this element. CKE4 is not supporting frameset and frame,
|
|
12
|
+
* but it will unpack <frameset><noframes>foobar</noframes></frameset> to <noframes>foobar</noframes>, so there
|
|
13
|
+
* may be some content loss. Although using noframes as a standalone element seems invalid)
|
|
14
|
+
* * keygen (this one is also empty)
|
|
15
|
+
* * applet (support is limited mostly to old IE)
|
|
16
|
+
* * basefont (this one is also empty)
|
|
17
|
+
* * isindex (basically no support for modern browsers at all)
|
|
18
|
+
*
|
|
19
|
+
* Skipped elements due to lack empty element support:
|
|
20
|
+
* * hr
|
|
21
|
+
* * area
|
|
22
|
+
* * br
|
|
23
|
+
* * command
|
|
24
|
+
* * map
|
|
25
|
+
* * wbr
|
|
26
|
+
* * colgroup -> col
|
|
27
|
+
*
|
|
28
|
+
* Skipped elements due to complexity:
|
|
29
|
+
* * datalist with option elements used as a data source for input[list] element
|
|
30
|
+
*
|
|
31
|
+
* Skipped elements as they are handled as an object content:
|
|
32
|
+
* * track
|
|
33
|
+
* * source
|
|
34
|
+
* * option
|
|
35
|
+
* * param
|
|
36
|
+
* * optgroup
|
|
37
|
+
*
|
|
38
|
+
* Skipped full page HTML elements:
|
|
39
|
+
* * body
|
|
40
|
+
* * html
|
|
41
|
+
* * title
|
|
42
|
+
* * head
|
|
43
|
+
* * meta
|
|
44
|
+
* * link
|
|
45
|
+
* * etc...
|
|
46
|
+
*
|
|
47
|
+
* Skipped hidden elements:
|
|
48
|
+
* noscript
|
|
49
|
+
*
|
|
50
|
+
* When adding elements to this list, update the feature guide listing, too.
|
|
51
|
+
*
|
|
52
|
+
* @internal
|
|
53
|
+
*/
|
|
54
|
+
export declare const defaultConfig: {
|
|
55
|
+
block: HtmlSupportDataSchemaBlockElementDefinition[];
|
|
56
|
+
inline: HtmlSupportDataSchemaInlineElementDefinition[];
|
|
12
57
|
};
|
|
13
|
-
export default _default;
|
package/src/schemadefinitions.js
CHANGED
|
@@ -5,48 +5,52 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module html-support/schemadefinitions
|
|
7
7
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Skipped elements due to HTML deprecation:
|
|
10
|
+
* * noframes (not sure if we should provide support for this element. CKE4 is not supporting frameset and frame,
|
|
11
|
+
* but it will unpack <frameset><noframes>foobar</noframes></frameset> to <noframes>foobar</noframes>, so there
|
|
12
|
+
* may be some content loss. Although using noframes as a standalone element seems invalid)
|
|
13
|
+
* * keygen (this one is also empty)
|
|
14
|
+
* * applet (support is limited mostly to old IE)
|
|
15
|
+
* * basefont (this one is also empty)
|
|
16
|
+
* * isindex (basically no support for modern browsers at all)
|
|
17
|
+
*
|
|
18
|
+
* Skipped elements due to lack empty element support:
|
|
19
|
+
* * hr
|
|
20
|
+
* * area
|
|
21
|
+
* * br
|
|
22
|
+
* * command
|
|
23
|
+
* * map
|
|
24
|
+
* * wbr
|
|
25
|
+
* * colgroup -> col
|
|
26
|
+
*
|
|
27
|
+
* Skipped elements due to complexity:
|
|
28
|
+
* * datalist with option elements used as a data source for input[list] element
|
|
29
|
+
*
|
|
30
|
+
* Skipped elements as they are handled as an object content:
|
|
31
|
+
* * track
|
|
32
|
+
* * source
|
|
33
|
+
* * option
|
|
34
|
+
* * param
|
|
35
|
+
* * optgroup
|
|
36
|
+
*
|
|
37
|
+
* Skipped full page HTML elements:
|
|
38
|
+
* * body
|
|
39
|
+
* * html
|
|
40
|
+
* * title
|
|
41
|
+
* * head
|
|
42
|
+
* * meta
|
|
43
|
+
* * link
|
|
44
|
+
* * etc...
|
|
45
|
+
*
|
|
46
|
+
* Skipped hidden elements:
|
|
47
|
+
* noscript
|
|
48
|
+
*
|
|
49
|
+
* When adding elements to this list, update the feature guide listing, too.
|
|
50
|
+
*
|
|
51
|
+
* @internal
|
|
52
|
+
*/
|
|
53
|
+
export const defaultConfig = {
|
|
50
54
|
block: [
|
|
51
55
|
// Existing features.
|
|
52
56
|
{
|
|
@@ -690,7 +694,10 @@ export default {
|
|
|
690
694
|
model: 'htmlA',
|
|
691
695
|
view: 'a',
|
|
692
696
|
priority: 5,
|
|
693
|
-
coupledAttribute: 'linkHref'
|
|
697
|
+
coupledAttribute: 'linkHref',
|
|
698
|
+
attributeProperties: {
|
|
699
|
+
isFormatting: true
|
|
700
|
+
}
|
|
694
701
|
},
|
|
695
702
|
{
|
|
696
703
|
model: 'htmlStrong',
|
package/src/utils.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module html-support/utils
|
|
7
7
|
*/
|
|
8
|
-
import type {
|
|
8
|
+
import type { ModelDocumentSelection, ViewDowncastWriter, ModelItem, ModelRange, ViewElement, ModelWriter } from 'ckeditor5/src/engine.js';
|
|
9
9
|
export interface GHSViewAttributes {
|
|
10
10
|
attributes?: Record<string, unknown>;
|
|
11
11
|
classes?: Array<string>;
|
|
@@ -18,26 +18,31 @@ export interface GHSViewAttributes {
|
|
|
18
18
|
* @param oldViewAttributes The previous GHS attribute value.
|
|
19
19
|
* @param newViewAttributes The current GHS attribute value.
|
|
20
20
|
* @param viewElement The view element to update.
|
|
21
|
+
* @internal
|
|
21
22
|
*/
|
|
22
|
-
export declare function updateViewAttributes(writer:
|
|
23
|
+
export declare function updateViewAttributes(writer: ViewDowncastWriter, oldViewAttributes: GHSViewAttributes, newViewAttributes: GHSViewAttributes, viewElement: ViewElement): void;
|
|
23
24
|
/**
|
|
24
25
|
* Helper function for the downcast converter. Sets attributes on the given view element.
|
|
25
26
|
*
|
|
26
27
|
* @param writer The view writer.
|
|
27
28
|
* @param viewAttributes The GHS attribute value.
|
|
28
29
|
* @param viewElement The view element to update.
|
|
30
|
+
* @internal
|
|
29
31
|
*/
|
|
30
|
-
export declare function setViewAttributes(writer:
|
|
32
|
+
export declare function setViewAttributes(writer: ViewDowncastWriter, viewAttributes: GHSViewAttributes, viewElement: ViewElement): void;
|
|
31
33
|
/**
|
|
32
34
|
* Helper function for the downcast converter. Removes attributes on the given view element.
|
|
33
35
|
*
|
|
34
36
|
* @param writer The view writer.
|
|
35
37
|
* @param viewAttributes The GHS attribute value.
|
|
36
38
|
* @param viewElement The view element to update.
|
|
39
|
+
* @internal
|
|
37
40
|
*/
|
|
38
|
-
export declare function removeViewAttributes(writer:
|
|
41
|
+
export declare function removeViewAttributes(writer: ViewDowncastWriter, viewAttributes: GHSViewAttributes, viewElement: ViewElement): void;
|
|
39
42
|
/**
|
|
40
43
|
* Merges view element attribute objects.
|
|
44
|
+
*
|
|
45
|
+
* @internal
|
|
41
46
|
*/
|
|
42
47
|
export declare function mergeViewElementAttributes(target: GHSViewAttributes, source: GHSViewAttributes): GHSViewAttributes;
|
|
43
48
|
type ModifyGhsAttributesCallback = (t: Map<string, unknown>) => void;
|
|
@@ -45,28 +50,42 @@ type ModifyGhsClassesCallback = (t: Set<string>) => void;
|
|
|
45
50
|
type ModifyGhsStylesCallback = (t: Map<string, string>) => void;
|
|
46
51
|
/**
|
|
47
52
|
* Updates a GHS attribute on a specified item.
|
|
53
|
+
*
|
|
48
54
|
* @param callback That receives a map as an argument and should modify it (add or remove entries).
|
|
55
|
+
* @internal
|
|
49
56
|
*/
|
|
50
|
-
export declare function modifyGhsAttribute(writer:
|
|
57
|
+
export declare function modifyGhsAttribute(writer: ModelWriter, item: ModelItem | ModelDocumentSelection, ghsAttributeName: string, subject: 'attributes', callback: ModifyGhsAttributesCallback): void;
|
|
51
58
|
/**
|
|
52
59
|
* Updates a GHS attribute on a specified item.
|
|
60
|
+
*
|
|
53
61
|
* @param callback That receives a set as an argument and should modify it (add or remove entries).
|
|
62
|
+
* @internal
|
|
54
63
|
*/
|
|
55
|
-
export declare function modifyGhsAttribute(writer:
|
|
64
|
+
export declare function modifyGhsAttribute(writer: ModelWriter, item: ModelItem | ModelDocumentSelection, ghsAttributeName: string, subject: 'classes', callback: ModifyGhsClassesCallback): void;
|
|
56
65
|
/**
|
|
57
66
|
* Updates a GHS attribute on a specified item.
|
|
58
67
|
* @param callback That receives a map as an argument and should modify it (add or remove entries).
|
|
59
68
|
*/
|
|
60
|
-
export declare function modifyGhsAttribute(writer:
|
|
69
|
+
export declare function modifyGhsAttribute(writer: ModelWriter, item: ModelItem | ModelDocumentSelection, ghsAttributeName: string, subject: 'styles', callback: ModifyGhsStylesCallback): void;
|
|
70
|
+
/**
|
|
71
|
+
* Strips the `styles`, and `classes` keys from the GHS attribute value on the given item.
|
|
72
|
+
*
|
|
73
|
+
* @internal
|
|
74
|
+
*/
|
|
75
|
+
export declare function removeFormatting(ghsAttributeName: string, itemRange: ModelRange, writer: ModelWriter): void;
|
|
61
76
|
/**
|
|
62
77
|
* Transforms passed string to PascalCase format. Examples:
|
|
63
78
|
* * `div` => `Div`
|
|
64
79
|
* * `h1` => `H1`
|
|
65
80
|
* * `table` => `Table`
|
|
81
|
+
*
|
|
82
|
+
* @internal
|
|
66
83
|
*/
|
|
67
84
|
export declare function toPascalCase(data: string): string;
|
|
68
85
|
/**
|
|
69
86
|
* Returns the attribute name of the model element that holds raw HTML attributes.
|
|
87
|
+
*
|
|
88
|
+
* @internal
|
|
70
89
|
*/
|
|
71
90
|
export declare function getHtmlAttributeName(viewElementName: string): string;
|
|
72
91
|
export {};
|
package/src/utils.js
CHANGED
|
@@ -10,6 +10,7 @@ import { startCase, cloneDeep } from 'es-toolkit/compat';
|
|
|
10
10
|
* @param oldViewAttributes The previous GHS attribute value.
|
|
11
11
|
* @param newViewAttributes The current GHS attribute value.
|
|
12
12
|
* @param viewElement The view element to update.
|
|
13
|
+
* @internal
|
|
13
14
|
*/
|
|
14
15
|
export function updateViewAttributes(writer, oldViewAttributes, newViewAttributes, viewElement) {
|
|
15
16
|
if (oldViewAttributes) {
|
|
@@ -25,6 +26,7 @@ export function updateViewAttributes(writer, oldViewAttributes, newViewAttribute
|
|
|
25
26
|
* @param writer The view writer.
|
|
26
27
|
* @param viewAttributes The GHS attribute value.
|
|
27
28
|
* @param viewElement The view element to update.
|
|
29
|
+
* @internal
|
|
28
30
|
*/
|
|
29
31
|
export function setViewAttributes(writer, viewAttributes, viewElement) {
|
|
30
32
|
if (viewAttributes.attributes) {
|
|
@@ -45,6 +47,7 @@ export function setViewAttributes(writer, viewAttributes, viewElement) {
|
|
|
45
47
|
* @param writer The view writer.
|
|
46
48
|
* @param viewAttributes The GHS attribute value.
|
|
47
49
|
* @param viewElement The view element to update.
|
|
50
|
+
* @internal
|
|
48
51
|
*/
|
|
49
52
|
export function removeViewAttributes(writer, viewAttributes, viewElement) {
|
|
50
53
|
if (viewAttributes.attributes) {
|
|
@@ -63,6 +66,8 @@ export function removeViewAttributes(writer, viewAttributes, viewElement) {
|
|
|
63
66
|
}
|
|
64
67
|
/**
|
|
65
68
|
* Merges view element attribute objects.
|
|
69
|
+
*
|
|
70
|
+
* @internal
|
|
66
71
|
*/
|
|
67
72
|
export function mergeViewElementAttributes(target, source) {
|
|
68
73
|
const result = cloneDeep(target);
|
|
@@ -122,17 +127,42 @@ export function modifyGhsAttribute(writer, item, ghsAttributeName, subject, call
|
|
|
122
127
|
}
|
|
123
128
|
}
|
|
124
129
|
}
|
|
130
|
+
/**
|
|
131
|
+
* Strips the `styles`, and `classes` keys from the GHS attribute value on the given item.
|
|
132
|
+
*
|
|
133
|
+
* @internal
|
|
134
|
+
*/
|
|
135
|
+
export function removeFormatting(ghsAttributeName, itemRange, writer) {
|
|
136
|
+
for (const item of itemRange.getItems({ shallow: true })) {
|
|
137
|
+
const value = item.getAttribute(ghsAttributeName);
|
|
138
|
+
// Copy only attributes to the new attribute value.
|
|
139
|
+
if (value && value.attributes && Object.keys(value.attributes).length) {
|
|
140
|
+
// But reset the GHS attribute only when there is anything more than just attributes.
|
|
141
|
+
if (Object.keys(value).length > 1) {
|
|
142
|
+
writer.setAttribute(ghsAttributeName, { attributes: value.attributes }, item);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
// There are no attributes, so remove the GHS attribute completely.
|
|
147
|
+
writer.removeAttribute(ghsAttributeName, item);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
125
151
|
/**
|
|
126
152
|
* Transforms passed string to PascalCase format. Examples:
|
|
127
153
|
* * `div` => `Div`
|
|
128
154
|
* * `h1` => `H1`
|
|
129
155
|
* * `table` => `Table`
|
|
156
|
+
*
|
|
157
|
+
* @internal
|
|
130
158
|
*/
|
|
131
159
|
export function toPascalCase(data) {
|
|
132
160
|
return startCase(data).replace(/ /g, '');
|
|
133
161
|
}
|
|
134
162
|
/**
|
|
135
163
|
* Returns the attribute name of the model element that holds raw HTML attributes.
|
|
164
|
+
*
|
|
165
|
+
* @internal
|
|
136
166
|
*/
|
|
137
167
|
export function getHtmlAttributeName(viewElementName) {
|
|
138
168
|
return `html${toPascalCase(viewElementName)}Attributes`;
|