@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,187 @@
|
|
|
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/dataschema
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin } from 'ckeditor5/src/core.js';
|
|
9
|
+
import type { AttributeProperties, SchemaItemDefinition } from 'ckeditor5/src/engine.js';
|
|
10
|
+
/**
|
|
11
|
+
* Holds representation of the extended HTML document type definitions to be used by the
|
|
12
|
+
* editor in HTML support.
|
|
13
|
+
*
|
|
14
|
+
* Data schema is represented by data schema definitions.
|
|
15
|
+
*
|
|
16
|
+
* To add new definition for block element,
|
|
17
|
+
* use {@link module:html-support/dataschema~DataSchema#registerBlockElement} method:
|
|
18
|
+
*
|
|
19
|
+
* ```ts
|
|
20
|
+
* dataSchema.registerBlockElement( {
|
|
21
|
+
* view: 'section',
|
|
22
|
+
* model: 'my-section',
|
|
23
|
+
* modelSchema: {
|
|
24
|
+
* inheritAllFrom: '$block'
|
|
25
|
+
* }
|
|
26
|
+
* } );
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* To add new definition for inline element,
|
|
30
|
+
* use {@link module:html-support/dataschema~DataSchema#registerInlineElement} method:
|
|
31
|
+
*
|
|
32
|
+
* ```
|
|
33
|
+
* dataSchema.registerInlineElement( {
|
|
34
|
+
* view: 'span',
|
|
35
|
+
* model: 'my-span',
|
|
36
|
+
* attributeProperties: {
|
|
37
|
+
* copyOnEnter: true
|
|
38
|
+
* }
|
|
39
|
+
* } );
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export default class DataSchema extends Plugin {
|
|
43
|
+
/**
|
|
44
|
+
* A map of registered data schema definitions.
|
|
45
|
+
*/
|
|
46
|
+
private readonly _definitions;
|
|
47
|
+
/**
|
|
48
|
+
* @inheritDoc
|
|
49
|
+
*/
|
|
50
|
+
static get pluginName(): "DataSchema";
|
|
51
|
+
/**
|
|
52
|
+
* @inheritDoc
|
|
53
|
+
*/
|
|
54
|
+
static get isOfficialPlugin(): true;
|
|
55
|
+
/**
|
|
56
|
+
* @inheritDoc
|
|
57
|
+
*/
|
|
58
|
+
init(): void;
|
|
59
|
+
/**
|
|
60
|
+
* Add new data schema definition describing block element.
|
|
61
|
+
*/
|
|
62
|
+
registerBlockElement(definition: DataSchemaBlockElementDefinition): void;
|
|
63
|
+
/**
|
|
64
|
+
* Add new data schema definition describing inline element.
|
|
65
|
+
*/
|
|
66
|
+
registerInlineElement(definition: DataSchemaInlineElementDefinition): void;
|
|
67
|
+
/**
|
|
68
|
+
* Updates schema definition describing block element with new properties.
|
|
69
|
+
*
|
|
70
|
+
* Creates new scheme if it doesn't exist.
|
|
71
|
+
* Array properties are concatenated with original values.
|
|
72
|
+
*
|
|
73
|
+
* @param definition Definition update.
|
|
74
|
+
*/
|
|
75
|
+
extendBlockElement(definition: DataSchemaBlockElementDefinition): void;
|
|
76
|
+
/**
|
|
77
|
+
* Updates schema definition describing inline element with new properties.
|
|
78
|
+
*
|
|
79
|
+
* Creates new scheme if it doesn't exist.
|
|
80
|
+
* Array properties are concatenated with original values.
|
|
81
|
+
*
|
|
82
|
+
* @param definition Definition update.
|
|
83
|
+
*/
|
|
84
|
+
extendInlineElement(definition: DataSchemaInlineElementDefinition): void;
|
|
85
|
+
/**
|
|
86
|
+
* Returns all definitions matching the given view name.
|
|
87
|
+
*
|
|
88
|
+
* @param includeReferences Indicates if this method should also include definitions of referenced models.
|
|
89
|
+
*/
|
|
90
|
+
getDefinitionsForView(viewName: string | RegExp, includeReferences?: boolean): Set<DataSchemaDefinition>;
|
|
91
|
+
/**
|
|
92
|
+
* Returns definitions matching the given model name.
|
|
93
|
+
*/
|
|
94
|
+
getDefinitionsForModel(modelName: string): Array<DataSchemaDefinition>;
|
|
95
|
+
/**
|
|
96
|
+
* Returns definitions matching the given view name.
|
|
97
|
+
*/
|
|
98
|
+
private _getMatchingViewDefinitions;
|
|
99
|
+
/**
|
|
100
|
+
* Resolves all definition references registered for the given data schema definition.
|
|
101
|
+
*
|
|
102
|
+
* @param modelName Data schema model name.
|
|
103
|
+
*/
|
|
104
|
+
private _getReferences;
|
|
105
|
+
/**
|
|
106
|
+
* Updates schema definition with new properties.
|
|
107
|
+
*
|
|
108
|
+
* Creates new scheme if it doesn't exist.
|
|
109
|
+
* Array properties are concatenated with original values.
|
|
110
|
+
*
|
|
111
|
+
* @param definition Definition update.
|
|
112
|
+
*/
|
|
113
|
+
private _extendDefinition;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* A base definition of {@link module:html-support/dataschema~DataSchema data schema}.
|
|
117
|
+
*/
|
|
118
|
+
export interface DataSchemaDefinition {
|
|
119
|
+
/**
|
|
120
|
+
* Name of the model.
|
|
121
|
+
*/
|
|
122
|
+
model: string;
|
|
123
|
+
/**
|
|
124
|
+
* Name of the view element.
|
|
125
|
+
*/
|
|
126
|
+
view?: string;
|
|
127
|
+
/**
|
|
128
|
+
* Indicates that the definition describes object element.
|
|
129
|
+
*/
|
|
130
|
+
isObject?: boolean;
|
|
131
|
+
/**
|
|
132
|
+
* The model schema item definition describing registered model.
|
|
133
|
+
*/
|
|
134
|
+
modelSchema?: SchemaItemDefinition;
|
|
135
|
+
/**
|
|
136
|
+
* Indicates that the definition describes block element.
|
|
137
|
+
* Set by {@link module:html-support/dataschema~DataSchema#registerBlockElement} method.
|
|
138
|
+
*/
|
|
139
|
+
isBlock?: boolean;
|
|
140
|
+
/**
|
|
141
|
+
* Indicates that the definition describes inline element.
|
|
142
|
+
*/
|
|
143
|
+
isInline?: boolean;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* A definition of {@link module:html-support/dataschema~DataSchema data schema} for block elements.
|
|
147
|
+
*/
|
|
148
|
+
export interface DataSchemaBlockElementDefinition extends DataSchemaDefinition {
|
|
149
|
+
/**
|
|
150
|
+
* Should be used when an element can behave both as a sectioning element (e.g. article) and
|
|
151
|
+
* element accepting only inline content (e.g. paragraph).
|
|
152
|
+
* If an element contains only inline content, this option will be used as a model name.
|
|
153
|
+
*/
|
|
154
|
+
paragraphLikeModel?: string;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* A definition of {@link module:html-support/dataschema~DataSchema data schema} for inline elements.
|
|
158
|
+
*/
|
|
159
|
+
export interface DataSchemaInlineElementDefinition extends DataSchemaDefinition {
|
|
160
|
+
/**
|
|
161
|
+
* Additional metadata describing the model attribute.
|
|
162
|
+
*/
|
|
163
|
+
attributeProperties?: AttributeProperties;
|
|
164
|
+
/**
|
|
165
|
+
* Element priority. Decides in what order elements are wrapped by
|
|
166
|
+
* {@link module:engine/view/downcastwriter~DowncastWriter}.
|
|
167
|
+
* Set by {@link module:html-support/dataschema~DataSchema#registerInlineElement} method.
|
|
168
|
+
*/
|
|
169
|
+
priority?: number;
|
|
170
|
+
/**
|
|
171
|
+
* The name of the model attribute that generates the same view element. GHS inline attribute
|
|
172
|
+
* will be removed from the model tree as soon as the coupled attribute is removed. See
|
|
173
|
+
* {@link module:html-support/datafilter~DataFilter#_registerCoupledAttributesPostFixer GHS post-fixer} for more details.
|
|
174
|
+
*/
|
|
175
|
+
coupledAttribute?: string;
|
|
176
|
+
/**
|
|
177
|
+
* Indicates that element should not be converted as a model text attribute.
|
|
178
|
+
* It is used to map view elements that do not have a separate model element but their data is stored in a model attribute.
|
|
179
|
+
* For example `<tbody>` element does not have a dedicated model element and GHS stores attributes of `<tbody>`
|
|
180
|
+
* in the `htmlTbodyAttributes` model attribute of the `table` model element.
|
|
181
|
+
*/
|
|
182
|
+
appliesToBlock?: boolean | string;
|
|
183
|
+
/**
|
|
184
|
+
* Indicates that an element should be preserved even if it has no content.
|
|
185
|
+
*/
|
|
186
|
+
allowEmpty?: boolean;
|
|
187
|
+
}
|
|
@@ -0,0 +1,202 @@
|
|
|
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/dataschema
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin } from 'ckeditor5/src/core.js';
|
|
9
|
+
import { toArray } from 'ckeditor5/src/utils.js';
|
|
10
|
+
import defaultConfig from './schemadefinitions.js';
|
|
11
|
+
import { mergeWith } from 'lodash-es';
|
|
12
|
+
/**
|
|
13
|
+
* Holds representation of the extended HTML document type definitions to be used by the
|
|
14
|
+
* editor in HTML support.
|
|
15
|
+
*
|
|
16
|
+
* Data schema is represented by data schema definitions.
|
|
17
|
+
*
|
|
18
|
+
* To add new definition for block element,
|
|
19
|
+
* use {@link module:html-support/dataschema~DataSchema#registerBlockElement} method:
|
|
20
|
+
*
|
|
21
|
+
* ```ts
|
|
22
|
+
* dataSchema.registerBlockElement( {
|
|
23
|
+
* view: 'section',
|
|
24
|
+
* model: 'my-section',
|
|
25
|
+
* modelSchema: {
|
|
26
|
+
* inheritAllFrom: '$block'
|
|
27
|
+
* }
|
|
28
|
+
* } );
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* To add new definition for inline element,
|
|
32
|
+
* use {@link module:html-support/dataschema~DataSchema#registerInlineElement} method:
|
|
33
|
+
*
|
|
34
|
+
* ```
|
|
35
|
+
* dataSchema.registerInlineElement( {
|
|
36
|
+
* view: 'span',
|
|
37
|
+
* model: 'my-span',
|
|
38
|
+
* attributeProperties: {
|
|
39
|
+
* copyOnEnter: true
|
|
40
|
+
* }
|
|
41
|
+
* } );
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export default class DataSchema extends Plugin {
|
|
45
|
+
constructor() {
|
|
46
|
+
super(...arguments);
|
|
47
|
+
/**
|
|
48
|
+
* A map of registered data schema definitions.
|
|
49
|
+
*/
|
|
50
|
+
this._definitions = [];
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* @inheritDoc
|
|
54
|
+
*/
|
|
55
|
+
static get pluginName() {
|
|
56
|
+
return 'DataSchema';
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* @inheritDoc
|
|
60
|
+
*/
|
|
61
|
+
static get isOfficialPlugin() {
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* @inheritDoc
|
|
66
|
+
*/
|
|
67
|
+
init() {
|
|
68
|
+
for (const definition of defaultConfig.block) {
|
|
69
|
+
this.registerBlockElement(definition);
|
|
70
|
+
}
|
|
71
|
+
for (const definition of defaultConfig.inline) {
|
|
72
|
+
this.registerInlineElement(definition);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Add new data schema definition describing block element.
|
|
77
|
+
*/
|
|
78
|
+
registerBlockElement(definition) {
|
|
79
|
+
this._definitions.push({ ...definition, isBlock: true });
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Add new data schema definition describing inline element.
|
|
83
|
+
*/
|
|
84
|
+
registerInlineElement(definition) {
|
|
85
|
+
this._definitions.push({ ...definition, isInline: true });
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Updates schema definition describing block element with new properties.
|
|
89
|
+
*
|
|
90
|
+
* Creates new scheme if it doesn't exist.
|
|
91
|
+
* Array properties are concatenated with original values.
|
|
92
|
+
*
|
|
93
|
+
* @param definition Definition update.
|
|
94
|
+
*/
|
|
95
|
+
extendBlockElement(definition) {
|
|
96
|
+
this._extendDefinition({ ...definition, isBlock: true });
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Updates schema definition describing inline element with new properties.
|
|
100
|
+
*
|
|
101
|
+
* Creates new scheme if it doesn't exist.
|
|
102
|
+
* Array properties are concatenated with original values.
|
|
103
|
+
*
|
|
104
|
+
* @param definition Definition update.
|
|
105
|
+
*/
|
|
106
|
+
extendInlineElement(definition) {
|
|
107
|
+
this._extendDefinition({ ...definition, isInline: true });
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Returns all definitions matching the given view name.
|
|
111
|
+
*
|
|
112
|
+
* @param includeReferences Indicates if this method should also include definitions of referenced models.
|
|
113
|
+
*/
|
|
114
|
+
getDefinitionsForView(viewName, includeReferences = false) {
|
|
115
|
+
const definitions = new Set();
|
|
116
|
+
for (const definition of this._getMatchingViewDefinitions(viewName)) {
|
|
117
|
+
if (includeReferences) {
|
|
118
|
+
for (const reference of this._getReferences(definition.model)) {
|
|
119
|
+
definitions.add(reference);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
definitions.add(definition);
|
|
123
|
+
}
|
|
124
|
+
return definitions;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Returns definitions matching the given model name.
|
|
128
|
+
*/
|
|
129
|
+
getDefinitionsForModel(modelName) {
|
|
130
|
+
return this._definitions.filter(definition => definition.model == modelName);
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Returns definitions matching the given view name.
|
|
134
|
+
*/
|
|
135
|
+
_getMatchingViewDefinitions(viewName) {
|
|
136
|
+
return this._definitions.filter(def => def.view && testViewName(viewName, def.view));
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Resolves all definition references registered for the given data schema definition.
|
|
140
|
+
*
|
|
141
|
+
* @param modelName Data schema model name.
|
|
142
|
+
*/
|
|
143
|
+
*_getReferences(modelName) {
|
|
144
|
+
const inheritProperties = [
|
|
145
|
+
'inheritAllFrom',
|
|
146
|
+
'inheritTypesFrom',
|
|
147
|
+
'allowWhere',
|
|
148
|
+
'allowContentOf',
|
|
149
|
+
'allowAttributesOf'
|
|
150
|
+
];
|
|
151
|
+
const definitions = this._definitions.filter(definition => definition.model == modelName);
|
|
152
|
+
for (const { modelSchema } of definitions) {
|
|
153
|
+
if (!modelSchema) {
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
for (const property of inheritProperties) {
|
|
157
|
+
for (const referenceName of toArray(modelSchema[property] || [])) {
|
|
158
|
+
const definitions = this._definitions.filter(definition => definition.model == referenceName);
|
|
159
|
+
for (const definition of definitions) {
|
|
160
|
+
if (referenceName !== modelName) {
|
|
161
|
+
yield* this._getReferences(definition.model);
|
|
162
|
+
yield definition;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Updates schema definition with new properties.
|
|
171
|
+
*
|
|
172
|
+
* Creates new scheme if it doesn't exist.
|
|
173
|
+
* Array properties are concatenated with original values.
|
|
174
|
+
*
|
|
175
|
+
* @param definition Definition update.
|
|
176
|
+
*/
|
|
177
|
+
_extendDefinition(definition) {
|
|
178
|
+
const currentDefinitions = Array.from(this._definitions.entries())
|
|
179
|
+
.filter(([, currentDefinition]) => currentDefinition.model == definition.model);
|
|
180
|
+
if (currentDefinitions.length == 0) {
|
|
181
|
+
this._definitions.push(definition);
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
for (const [idx, currentDefinition] of currentDefinitions) {
|
|
185
|
+
this._definitions[idx] = mergeWith({}, currentDefinition, definition, (target, source) => {
|
|
186
|
+
return Array.isArray(target) ? target.concat(source) : undefined;
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Test view name against the given pattern.
|
|
193
|
+
*/
|
|
194
|
+
function testViewName(pattern, viewName) {
|
|
195
|
+
if (typeof pattern === 'string') {
|
|
196
|
+
return pattern === viewName;
|
|
197
|
+
}
|
|
198
|
+
if (pattern instanceof RegExp) {
|
|
199
|
+
return pattern.test(viewName);
|
|
200
|
+
}
|
|
201
|
+
return false;
|
|
202
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
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/fullpage
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin } from 'ckeditor5/src/core.js';
|
|
9
|
+
/**
|
|
10
|
+
* The full page editing feature. It preserves the whole HTML page in the editor data.
|
|
11
|
+
*/
|
|
12
|
+
export default class FullPage extends Plugin {
|
|
13
|
+
/**
|
|
14
|
+
* @inheritDoc
|
|
15
|
+
*/
|
|
16
|
+
static get pluginName(): "FullPage";
|
|
17
|
+
/**
|
|
18
|
+
* @inheritDoc
|
|
19
|
+
*/
|
|
20
|
+
static get isOfficialPlugin(): true;
|
|
21
|
+
/**
|
|
22
|
+
* @inheritDoc
|
|
23
|
+
*/
|
|
24
|
+
init(): void;
|
|
25
|
+
}
|
package/src/fullpage.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
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/fullpage
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin } from 'ckeditor5/src/core.js';
|
|
9
|
+
import { UpcastWriter } from 'ckeditor5/src/engine.js';
|
|
10
|
+
import HtmlPageDataProcessor from './htmlpagedataprocessor.js';
|
|
11
|
+
/**
|
|
12
|
+
* The full page editing feature. It preserves the whole HTML page in the editor data.
|
|
13
|
+
*/
|
|
14
|
+
export default class FullPage extends Plugin {
|
|
15
|
+
/**
|
|
16
|
+
* @inheritDoc
|
|
17
|
+
*/
|
|
18
|
+
static get pluginName() {
|
|
19
|
+
return 'FullPage';
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* @inheritDoc
|
|
23
|
+
*/
|
|
24
|
+
static get isOfficialPlugin() {
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* @inheritDoc
|
|
29
|
+
*/
|
|
30
|
+
init() {
|
|
31
|
+
const editor = this.editor;
|
|
32
|
+
const properties = ['$fullPageDocument', '$fullPageDocType', '$fullPageXmlDeclaration'];
|
|
33
|
+
editor.data.processor = new HtmlPageDataProcessor(editor.data.viewDocument);
|
|
34
|
+
editor.model.schema.extend('$root', {
|
|
35
|
+
allowAttributes: properties
|
|
36
|
+
});
|
|
37
|
+
// Apply custom properties from view document fragment to the model root attributes.
|
|
38
|
+
editor.data.on('toModel', (evt, [viewElementOrFragment]) => {
|
|
39
|
+
const root = editor.model.document.getRoot();
|
|
40
|
+
editor.model.change(writer => {
|
|
41
|
+
for (const name of properties) {
|
|
42
|
+
const value = viewElementOrFragment.getCustomProperty(name);
|
|
43
|
+
if (value) {
|
|
44
|
+
writer.setAttribute(name, value, root);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}, { priority: 'low' });
|
|
49
|
+
// Apply root attributes to the view document fragment.
|
|
50
|
+
editor.data.on('toView', (evt, [modelElementOrFragment]) => {
|
|
51
|
+
if (!modelElementOrFragment.is('rootElement')) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const root = modelElementOrFragment;
|
|
55
|
+
const viewFragment = evt.return;
|
|
56
|
+
if (!root.hasAttribute('$fullPageDocument')) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const writer = new UpcastWriter(viewFragment.document);
|
|
60
|
+
for (const name of properties) {
|
|
61
|
+
const value = root.getAttribute(name);
|
|
62
|
+
if (value) {
|
|
63
|
+
writer.setCustomProperty(name, value, viewFragment);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}, { priority: 'low' });
|
|
67
|
+
// Clear root attributes related to full page editing on editor content reset.
|
|
68
|
+
editor.data.on('set', () => {
|
|
69
|
+
const root = editor.model.document.getRoot();
|
|
70
|
+
editor.model.change(writer => {
|
|
71
|
+
for (const name of properties) {
|
|
72
|
+
if (root.hasAttribute(name)) {
|
|
73
|
+
writer.removeAttribute(name, root);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}, { priority: 'high' });
|
|
78
|
+
// Make sure that document is returned even if there is no content in the page body.
|
|
79
|
+
editor.data.on('get', (evt, args) => {
|
|
80
|
+
if (!args[0]) {
|
|
81
|
+
args[0] = {};
|
|
82
|
+
}
|
|
83
|
+
args[0].trim = false;
|
|
84
|
+
}, { priority: 'high' });
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
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/generalhtmlsupport
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin } from 'ckeditor5/src/core.js';
|
|
9
|
+
import { type ArrayOrItem } from 'ckeditor5/src/utils.js';
|
|
10
|
+
import DataFilter from './datafilter.js';
|
|
11
|
+
import CodeBlockElementSupport from './integrations/codeblock.js';
|
|
12
|
+
import DualContentModelElementSupport from './integrations/dualcontent.js';
|
|
13
|
+
import HeadingElementSupport from './integrations/heading.js';
|
|
14
|
+
import ImageElementSupport from './integrations/image.js';
|
|
15
|
+
import MediaEmbedElementSupport from './integrations/mediaembed.js';
|
|
16
|
+
import ScriptElementSupport from './integrations/script.js';
|
|
17
|
+
import TableElementSupport from './integrations/table.js';
|
|
18
|
+
import StyleElementSupport from './integrations/style.js';
|
|
19
|
+
import ListElementSupport from './integrations/list.js';
|
|
20
|
+
import CustomElementSupport from './integrations/customelement.js';
|
|
21
|
+
import type { Selectable } from 'ckeditor5/src/engine.js';
|
|
22
|
+
/**
|
|
23
|
+
* The General HTML Support feature.
|
|
24
|
+
*
|
|
25
|
+
* This is a "glue" plugin which initializes the {@link module:html-support/datafilter~DataFilter data filter} configuration
|
|
26
|
+
* and features integration with the General HTML Support.
|
|
27
|
+
*/
|
|
28
|
+
export default class GeneralHtmlSupport extends Plugin {
|
|
29
|
+
/**
|
|
30
|
+
* @inheritDoc
|
|
31
|
+
*/
|
|
32
|
+
static get pluginName(): "GeneralHtmlSupport";
|
|
33
|
+
/**
|
|
34
|
+
* @inheritDoc
|
|
35
|
+
*/
|
|
36
|
+
static get isOfficialPlugin(): true;
|
|
37
|
+
/**
|
|
38
|
+
* @inheritDoc
|
|
39
|
+
*/
|
|
40
|
+
static get requires(): readonly [typeof DataFilter, typeof CodeBlockElementSupport, typeof DualContentModelElementSupport, typeof HeadingElementSupport, typeof ImageElementSupport, typeof MediaEmbedElementSupport, typeof ScriptElementSupport, typeof TableElementSupport, typeof StyleElementSupport, typeof ListElementSupport, typeof CustomElementSupport];
|
|
41
|
+
/**
|
|
42
|
+
* @inheritDoc
|
|
43
|
+
*/
|
|
44
|
+
init(): void;
|
|
45
|
+
/**
|
|
46
|
+
* Returns a GHS model attribute name related to a given view element name.
|
|
47
|
+
*
|
|
48
|
+
* @internal
|
|
49
|
+
* @param viewElementName A view element name.
|
|
50
|
+
*/
|
|
51
|
+
getGhsAttributeNameForElement(viewElementName: string): string;
|
|
52
|
+
/**
|
|
53
|
+
* Updates GHS model attribute for a specified view element name, so it includes the given class name.
|
|
54
|
+
*
|
|
55
|
+
* @internal
|
|
56
|
+
* @param viewElementName A view element name.
|
|
57
|
+
* @param className The css class to add.
|
|
58
|
+
* @param selectable The selection or element to update.
|
|
59
|
+
*/
|
|
60
|
+
addModelHtmlClass(viewElementName: string, className: ArrayOrItem<string>, selectable: Selectable): void;
|
|
61
|
+
/**
|
|
62
|
+
* Updates GHS model attribute for a specified view element name, so it does not include the given class name.
|
|
63
|
+
*
|
|
64
|
+
* @internal
|
|
65
|
+
* @param viewElementName A view element name.
|
|
66
|
+
* @param className The css class to remove.
|
|
67
|
+
* @param selectable The selection or element to update.
|
|
68
|
+
*/
|
|
69
|
+
removeModelHtmlClass(viewElementName: string, className: ArrayOrItem<string>, selectable: Selectable): void;
|
|
70
|
+
/**
|
|
71
|
+
* Updates GHS model attribute for a specified view element name, so it includes the given attribute.
|
|
72
|
+
*
|
|
73
|
+
* @param viewElementName A view element name.
|
|
74
|
+
* @param attributes The object with attributes to set.
|
|
75
|
+
* @param selectable The selection or element to update.
|
|
76
|
+
*/
|
|
77
|
+
private setModelHtmlAttributes;
|
|
78
|
+
/**
|
|
79
|
+
* Updates GHS model attribute for a specified view element name, so it does not include the given attribute.
|
|
80
|
+
*
|
|
81
|
+
* @param viewElementName A view element name.
|
|
82
|
+
* @param attributeName The attribute name (or names) to remove.
|
|
83
|
+
* @param selectable The selection or element to update.
|
|
84
|
+
*/
|
|
85
|
+
private removeModelHtmlAttributes;
|
|
86
|
+
/**
|
|
87
|
+
* Updates GHS model attribute for a specified view element name, so it includes a given style.
|
|
88
|
+
*
|
|
89
|
+
* @param viewElementName A view element name.
|
|
90
|
+
* @param styles The object with styles to set.
|
|
91
|
+
* @param selectable The selection or element to update.
|
|
92
|
+
*/
|
|
93
|
+
private setModelHtmlStyles;
|
|
94
|
+
/**
|
|
95
|
+
* Updates GHS model attribute for a specified view element name, so it does not include a given style.
|
|
96
|
+
*
|
|
97
|
+
* @param viewElementName A view element name.
|
|
98
|
+
* @param properties The style (or styles list) to remove.
|
|
99
|
+
* @param selectable The selection or element to update.
|
|
100
|
+
*/
|
|
101
|
+
private removeModelHtmlStyles;
|
|
102
|
+
}
|