@ckeditor/ckeditor5-html-support 36.0.0 → 37.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/build/html-support.js +1 -1
- package/package.json +42 -36
- package/src/conversionutils.d.ts +42 -0
- package/src/conversionutils.js +57 -77
- package/src/converters.d.ts +56 -0
- package/src/converters.js +104 -156
- package/src/datafilter.d.ts +255 -0
- package/src/datafilter.js +566 -782
- package/src/dataschema.d.ts +174 -0
- package/src/dataschema.js +143 -229
- package/src/fullpage.d.ts +26 -0
- package/src/fullpage.js +65 -86
- package/src/generalhtmlsupport.d.ts +93 -0
- package/src/generalhtmlsupport.js +244 -327
- package/src/generalhtmlsupportconfig.d.ts +76 -0
- package/src/generalhtmlsupportconfig.js +5 -0
- package/src/htmlcomment.d.ts +77 -0
- package/src/htmlcomment.js +175 -239
- package/src/htmlpagedataprocessor.d.ts +22 -0
- package/src/htmlpagedataprocessor.js +53 -76
- package/src/index.d.ts +13 -0
- package/src/index.js +0 -2
- package/src/integrations/codeblock.d.ts +27 -0
- package/src/integrations/codeblock.js +87 -115
- package/src/integrations/customelement.d.ts +30 -0
- package/src/integrations/customelement.js +127 -160
- package/src/integrations/documentlist.d.ts +31 -0
- package/src/integrations/documentlist.js +154 -191
- package/src/integrations/dualcontent.d.ts +49 -0
- package/src/integrations/dualcontent.js +92 -128
- package/src/integrations/heading.d.ts +30 -0
- package/src/integrations/heading.js +41 -54
- package/src/integrations/image.d.ts +30 -0
- package/src/integrations/image.js +154 -212
- package/src/integrations/integrationutils.d.ts +15 -0
- package/src/integrations/integrationutils.js +21 -0
- package/src/integrations/mediaembed.d.ts +30 -0
- package/src/integrations/mediaembed.js +101 -147
- package/src/integrations/script.d.ts +30 -0
- package/src/integrations/script.js +45 -67
- package/src/integrations/style.d.ts +30 -0
- package/src/integrations/style.js +45 -67
- package/src/integrations/table.d.ts +27 -0
- package/src/integrations/table.js +113 -160
- package/src/schemadefinitions.d.ts +13 -0
- package/src/schemadefinitions.js +846 -835
|
@@ -2,20 +2,10 @@
|
|
|
2
2
|
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @module html-support/integrations/dualcontent
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
5
|
import { Plugin } from 'ckeditor5/src/core';
|
|
11
6
|
import { priorities } from 'ckeditor5/src/utils';
|
|
12
|
-
import {
|
|
13
|
-
modelToViewBlockAttributeConverter,
|
|
14
|
-
viewToModelBlockAttributeConverter
|
|
15
|
-
} from '../converters';
|
|
16
|
-
|
|
7
|
+
import { modelToViewBlockAttributeConverter, viewToModelBlockAttributeConverter } from '../converters';
|
|
17
8
|
import DataFilter from '../datafilter';
|
|
18
|
-
|
|
19
9
|
/**
|
|
20
10
|
* Provides the General HTML Support integration for elements which can behave like sectioning element (e.g. article) or
|
|
21
11
|
* element accepting only inline content (e.g. paragraph).
|
|
@@ -32,123 +22,97 @@ import DataFilter from '../datafilter';
|
|
|
32
22
|
* {@link module:html-support/dataschema~DataSchemaDefinition#modelSchema} in editor schema.
|
|
33
23
|
* Otherwise, it will be registered under {@link module:html-support/dataschema~DataSchemaBlockElementDefinition#paragraphLikeModel} model
|
|
34
24
|
* name with model schema accepting only inline content (inheriting from `$block`).
|
|
35
|
-
*
|
|
36
|
-
* @extends module:core/plugin~Plugin
|
|
37
25
|
*/
|
|
38
26
|
export default class DualContentModelElementSupport extends Plugin {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
return false;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Adds attribute filtering conversion for the given data schema.
|
|
138
|
-
*
|
|
139
|
-
* @private
|
|
140
|
-
* @param {module:html-support/dataschema~DataSchemaBlockElementDefinition} definition
|
|
141
|
-
*/
|
|
142
|
-
_addAttributeConversion( definition ) {
|
|
143
|
-
const editor = this.editor;
|
|
144
|
-
const conversion = editor.conversion;
|
|
145
|
-
const dataFilter = editor.plugins.get( DataFilter );
|
|
146
|
-
|
|
147
|
-
editor.model.schema.extend( definition.model, {
|
|
148
|
-
allowAttributes: 'htmlAttributes'
|
|
149
|
-
} );
|
|
150
|
-
|
|
151
|
-
conversion.for( 'upcast' ).add( viewToModelBlockAttributeConverter( definition, dataFilter ) );
|
|
152
|
-
conversion.for( 'downcast' ).add( modelToViewBlockAttributeConverter( definition ) );
|
|
153
|
-
}
|
|
27
|
+
/**
|
|
28
|
+
* @inheritDoc
|
|
29
|
+
*/
|
|
30
|
+
static get requires() {
|
|
31
|
+
return [DataFilter];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* @inheritDoc
|
|
35
|
+
*/
|
|
36
|
+
static get pluginName() {
|
|
37
|
+
return 'DualContentModelElementSupport';
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* @inheritDoc
|
|
41
|
+
*/
|
|
42
|
+
init() {
|
|
43
|
+
const dataFilter = this.editor.plugins.get(DataFilter);
|
|
44
|
+
dataFilter.on('register', (evt, definition) => {
|
|
45
|
+
const blockDefinition = definition;
|
|
46
|
+
const editor = this.editor;
|
|
47
|
+
const schema = editor.model.schema;
|
|
48
|
+
const conversion = editor.conversion;
|
|
49
|
+
if (!blockDefinition.paragraphLikeModel) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
// Can only apply to newly registered features.
|
|
53
|
+
if (schema.isRegistered(blockDefinition.model) || schema.isRegistered(blockDefinition.paragraphLikeModel)) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const paragraphLikeModelDefinition = {
|
|
57
|
+
model: blockDefinition.paragraphLikeModel,
|
|
58
|
+
view: blockDefinition.view
|
|
59
|
+
};
|
|
60
|
+
schema.register(blockDefinition.model, blockDefinition.modelSchema);
|
|
61
|
+
schema.register(paragraphLikeModelDefinition.model, {
|
|
62
|
+
inheritAllFrom: '$block'
|
|
63
|
+
});
|
|
64
|
+
conversion.for('upcast').elementToElement({
|
|
65
|
+
view: blockDefinition.view,
|
|
66
|
+
model: (viewElement, { writer }) => {
|
|
67
|
+
if (this._hasBlockContent(viewElement)) {
|
|
68
|
+
return writer.createElement(blockDefinition.model);
|
|
69
|
+
}
|
|
70
|
+
return writer.createElement(paragraphLikeModelDefinition.model);
|
|
71
|
+
},
|
|
72
|
+
// With a `low` priority, `paragraph` plugin auto-paragraphing mechanism is executed. Make sure
|
|
73
|
+
// this listener is called before it. If not, some elements will be transformed into a paragraph.
|
|
74
|
+
converterPriority: priorities.get('low') + 0.5
|
|
75
|
+
});
|
|
76
|
+
conversion.for('downcast').elementToElement({
|
|
77
|
+
view: blockDefinition.view,
|
|
78
|
+
model: blockDefinition.model
|
|
79
|
+
});
|
|
80
|
+
this._addAttributeConversion(blockDefinition);
|
|
81
|
+
conversion.for('downcast').elementToElement({
|
|
82
|
+
view: paragraphLikeModelDefinition.view,
|
|
83
|
+
model: paragraphLikeModelDefinition.model
|
|
84
|
+
});
|
|
85
|
+
this._addAttributeConversion(paragraphLikeModelDefinition);
|
|
86
|
+
evt.stop();
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Checks whether the given view element includes any other block element.
|
|
91
|
+
*/
|
|
92
|
+
_hasBlockContent(viewElement) {
|
|
93
|
+
const view = this.editor.editing.view;
|
|
94
|
+
const blockElements = view.domConverter.blockElements;
|
|
95
|
+
// Traversing the viewElement subtree looking for block elements.
|
|
96
|
+
// Especially for the cases like <div><a href="#"><p>foo</p></a></div>.
|
|
97
|
+
// https://github.com/ckeditor/ckeditor5/issues/11513
|
|
98
|
+
for (const viewItem of view.createRangeIn(viewElement).getItems()) {
|
|
99
|
+
if (viewItem.is('element') && blockElements.includes(viewItem.name)) {
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Adds attribute filtering conversion for the given data schema.
|
|
107
|
+
*/
|
|
108
|
+
_addAttributeConversion(definition) {
|
|
109
|
+
const editor = this.editor;
|
|
110
|
+
const conversion = editor.conversion;
|
|
111
|
+
const dataFilter = editor.plugins.get(DataFilter);
|
|
112
|
+
editor.model.schema.extend(definition.model, {
|
|
113
|
+
allowAttributes: 'htmlAttributes'
|
|
114
|
+
});
|
|
115
|
+
conversion.for('upcast').add(viewToModelBlockAttributeConverter(definition, dataFilter));
|
|
116
|
+
conversion.for('downcast').add(modelToViewBlockAttributeConverter(definition));
|
|
117
|
+
}
|
|
154
118
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module html-support/integrations/heading
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin, type PluginDependencies } from 'ckeditor5/src/core';
|
|
9
|
+
/**
|
|
10
|
+
* Provides the General HTML Support integration with {@link module:heading/heading~Heading Heading} feature.
|
|
11
|
+
*/
|
|
12
|
+
export default class HeadingElementSupport extends Plugin {
|
|
13
|
+
/**
|
|
14
|
+
* @inheritDoc
|
|
15
|
+
*/
|
|
16
|
+
static get requires(): PluginDependencies;
|
|
17
|
+
/**
|
|
18
|
+
* @inheritDoc
|
|
19
|
+
*/
|
|
20
|
+
static get pluginName(): 'HeadingElementSupport';
|
|
21
|
+
/**
|
|
22
|
+
* @inheritDoc
|
|
23
|
+
*/
|
|
24
|
+
init(): void;
|
|
25
|
+
}
|
|
26
|
+
declare module '@ckeditor/ckeditor5-core' {
|
|
27
|
+
interface PluginsMap {
|
|
28
|
+
[HeadingElementSupport.pluginName]: HeadingElementSupport;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -2,67 +2,54 @@
|
|
|
2
2
|
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
5
|
/**
|
|
7
6
|
* @module html-support/integrations/heading
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
8
|
import { Plugin } from 'ckeditor5/src/core';
|
|
11
|
-
|
|
12
9
|
import DataSchema from '../dataschema';
|
|
13
|
-
|
|
14
10
|
/**
|
|
15
11
|
* Provides the General HTML Support integration with {@link module:heading/heading~Heading Heading} feature.
|
|
16
|
-
*
|
|
17
|
-
* @extends module:core/plugin~Plugin
|
|
18
12
|
*/
|
|
19
13
|
export default class HeadingElementSupport extends Plugin {
|
|
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
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
dataSchema.extendBlockElement( {
|
|
62
|
-
model: 'htmlHgroup',
|
|
63
|
-
modelSchema: {
|
|
64
|
-
allowChildren: headerModels
|
|
65
|
-
}
|
|
66
|
-
} );
|
|
67
|
-
}
|
|
14
|
+
/**
|
|
15
|
+
* @inheritDoc
|
|
16
|
+
*/
|
|
17
|
+
static get requires() {
|
|
18
|
+
return [DataSchema];
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* @inheritDoc
|
|
22
|
+
*/
|
|
23
|
+
static get pluginName() {
|
|
24
|
+
return 'HeadingElementSupport';
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* @inheritDoc
|
|
28
|
+
*/
|
|
29
|
+
init() {
|
|
30
|
+
const editor = this.editor;
|
|
31
|
+
if (!editor.plugins.has('HeadingEditing')) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const dataSchema = editor.plugins.get(DataSchema);
|
|
35
|
+
const options = editor.config.get('heading.options');
|
|
36
|
+
const headerModels = [];
|
|
37
|
+
// We are registering all elements supported by HeadingEditing
|
|
38
|
+
// to enable custom attributes for those elements.
|
|
39
|
+
for (const option of options) {
|
|
40
|
+
if ('model' in option && 'view' in option) {
|
|
41
|
+
dataSchema.registerBlockElement({
|
|
42
|
+
view: option.view,
|
|
43
|
+
model: option.model
|
|
44
|
+
});
|
|
45
|
+
headerModels.push(option.model);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
dataSchema.extendBlockElement({
|
|
49
|
+
model: 'htmlHgroup',
|
|
50
|
+
modelSchema: {
|
|
51
|
+
allowChildren: headerModels
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
68
55
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module html-support/integrations/image
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin, type PluginDependencies } from 'ckeditor5/src/core';
|
|
9
|
+
/**
|
|
10
|
+
* Provides the General HTML Support integration with the {@link module:image/image~Image Image} feature.
|
|
11
|
+
*/
|
|
12
|
+
export default class ImageElementSupport extends Plugin {
|
|
13
|
+
/**
|
|
14
|
+
* @inheritDoc
|
|
15
|
+
*/
|
|
16
|
+
static get requires(): PluginDependencies;
|
|
17
|
+
/**
|
|
18
|
+
* @inheritDoc
|
|
19
|
+
*/
|
|
20
|
+
static get pluginName(): 'ImageElementSupport';
|
|
21
|
+
/**
|
|
22
|
+
* @inheritDoc
|
|
23
|
+
*/
|
|
24
|
+
init(): void;
|
|
25
|
+
}
|
|
26
|
+
declare module '@ckeditor/ckeditor5-core' {
|
|
27
|
+
interface PluginsMap {
|
|
28
|
+
[ImageElementSupport.pluginName]: ImageElementSupport;
|
|
29
|
+
}
|
|
30
|
+
}
|