@ckeditor/ckeditor5-html-support 39.0.2 → 40.0.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/build/html-support.js.map +1 -0
- package/package.json +2 -2
- package/src/augmentation.d.ts +33 -33
- package/src/augmentation.js +5 -5
- package/src/converters.d.ts +60 -60
- package/src/converters.js +180 -180
- package/src/datafilter.d.ts +304 -304
- package/src/datafilter.js +720 -720
- package/src/dataschema.d.ts +183 -183
- package/src/dataschema.js +196 -196
- package/src/fullpage.d.ts +21 -21
- package/src/fullpage.js +80 -80
- package/src/generalhtmlsupport.d.ts +98 -98
- package/src/generalhtmlsupport.js +240 -240
- package/src/generalhtmlsupportconfig.d.ts +77 -77
- package/src/generalhtmlsupportconfig.js +5 -5
- package/src/htmlcomment.d.ts +71 -71
- package/src/htmlcomment.js +218 -218
- package/src/htmlpagedataprocessor.d.ts +22 -22
- package/src/htmlpagedataprocessor.js +67 -67
- package/src/index.d.ts +25 -25
- package/src/index.js +14 -14
- package/src/integrations/codeblock.d.ts +23 -23
- package/src/integrations/codeblock.js +101 -101
- package/src/integrations/customelement.d.ts +27 -27
- package/src/integrations/customelement.js +146 -146
- package/src/integrations/documentlist.d.ts +27 -27
- package/src/integrations/documentlist.js +178 -203
- package/src/integrations/dualcontent.d.ts +45 -45
- package/src/integrations/dualcontent.js +119 -119
- package/src/integrations/heading.d.ts +31 -31
- package/src/integrations/heading.js +60 -60
- package/src/integrations/image.d.ts +26 -26
- package/src/integrations/image.js +189 -189
- package/src/integrations/integrationutils.d.ts +15 -15
- package/src/integrations/integrationutils.js +21 -21
- package/src/integrations/mediaembed.d.ts +26 -26
- package/src/integrations/mediaembed.js +119 -119
- package/src/integrations/script.d.ts +26 -26
- package/src/integrations/script.js +59 -59
- package/src/integrations/style.d.ts +26 -26
- package/src/integrations/style.js +59 -59
- package/src/integrations/table.d.ts +23 -23
- package/src/integrations/table.js +163 -163
- package/src/schemadefinitions.d.ts +13 -13
- package/src/schemadefinitions.js +956 -956
- package/src/utils.d.ts +72 -72
- package/src/utils.js +139 -139
|
@@ -1,119 +1,119 @@
|
|
|
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
|
-
import { Plugin } from 'ckeditor5/src/core';
|
|
6
|
-
import { priorities } from 'ckeditor5/src/utils';
|
|
7
|
-
import { modelToViewBlockAttributeConverter, viewToModelBlockAttributeConverter } from '../converters';
|
|
8
|
-
import DataFilter from '../datafilter';
|
|
9
|
-
import { getHtmlAttributeName } from '../utils';
|
|
10
|
-
/**
|
|
11
|
-
* Provides the General HTML Support integration for elements which can behave like sectioning element (e.g. article) or
|
|
12
|
-
* element accepting only inline content (e.g. paragraph).
|
|
13
|
-
*
|
|
14
|
-
* The distinction between this two content models is important for choosing correct schema model and proper content conversion.
|
|
15
|
-
* As an example, it ensures that:
|
|
16
|
-
*
|
|
17
|
-
* * children elements paragraphing is enabled for sectioning elements only,
|
|
18
|
-
* * element and its content can be correctly handled by editing view (splitting and merging elements),
|
|
19
|
-
* * model element HTML is semantically correct and easier to work with.
|
|
20
|
-
*
|
|
21
|
-
* If element contains any block element, it will be treated as a sectioning element and registered using
|
|
22
|
-
* {@link module:html-support/dataschema~DataSchemaDefinition#model} and
|
|
23
|
-
* {@link module:html-support/dataschema~DataSchemaDefinition#modelSchema} in editor schema.
|
|
24
|
-
* Otherwise, it will be registered under {@link module:html-support/dataschema~DataSchemaBlockElementDefinition#paragraphLikeModel} model
|
|
25
|
-
* name with model schema accepting only inline content (inheriting from `$block`).
|
|
26
|
-
*/
|
|
27
|
-
export default class DualContentModelElementSupport extends Plugin {
|
|
28
|
-
/**
|
|
29
|
-
* @inheritDoc
|
|
30
|
-
*/
|
|
31
|
-
static get requires() {
|
|
32
|
-
return [DataFilter];
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* @inheritDoc
|
|
36
|
-
*/
|
|
37
|
-
static get pluginName() {
|
|
38
|
-
return 'DualContentModelElementSupport';
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* @inheritDoc
|
|
42
|
-
*/
|
|
43
|
-
init() {
|
|
44
|
-
const dataFilter = this.editor.plugins.get(DataFilter);
|
|
45
|
-
dataFilter.on('register', (evt, definition) => {
|
|
46
|
-
const blockDefinition = definition;
|
|
47
|
-
const editor = this.editor;
|
|
48
|
-
const schema = editor.model.schema;
|
|
49
|
-
const conversion = editor.conversion;
|
|
50
|
-
if (!blockDefinition.paragraphLikeModel) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
// Can only apply to newly registered features.
|
|
54
|
-
if (schema.isRegistered(blockDefinition.model) || schema.isRegistered(blockDefinition.paragraphLikeModel)) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
const paragraphLikeModelDefinition = {
|
|
58
|
-
model: blockDefinition.paragraphLikeModel,
|
|
59
|
-
view: blockDefinition.view
|
|
60
|
-
};
|
|
61
|
-
schema.register(blockDefinition.model, blockDefinition.modelSchema);
|
|
62
|
-
schema.register(paragraphLikeModelDefinition.model, {
|
|
63
|
-
inheritAllFrom: '$block'
|
|
64
|
-
});
|
|
65
|
-
conversion.for('upcast').elementToElement({
|
|
66
|
-
view: blockDefinition.view,
|
|
67
|
-
model: (viewElement, { writer }) => {
|
|
68
|
-
if (this._hasBlockContent(viewElement)) {
|
|
69
|
-
return writer.createElement(blockDefinition.model);
|
|
70
|
-
}
|
|
71
|
-
return writer.createElement(paragraphLikeModelDefinition.model);
|
|
72
|
-
},
|
|
73
|
-
// With a `low` priority, `paragraph` plugin auto-paragraphing mechanism is executed. Make sure
|
|
74
|
-
// this listener is called before it. If not, some elements will be transformed into a paragraph.
|
|
75
|
-
converterPriority: priorities.low + 0.5
|
|
76
|
-
});
|
|
77
|
-
conversion.for('downcast').elementToElement({
|
|
78
|
-
view: blockDefinition.view,
|
|
79
|
-
model: blockDefinition.model
|
|
80
|
-
});
|
|
81
|
-
this._addAttributeConversion(blockDefinition);
|
|
82
|
-
conversion.for('downcast').elementToElement({
|
|
83
|
-
view: paragraphLikeModelDefinition.view,
|
|
84
|
-
model: paragraphLikeModelDefinition.model
|
|
85
|
-
});
|
|
86
|
-
this._addAttributeConversion(paragraphLikeModelDefinition);
|
|
87
|
-
evt.stop();
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Checks whether the given view element includes any other block element.
|
|
92
|
-
*/
|
|
93
|
-
_hasBlockContent(viewElement) {
|
|
94
|
-
const view = this.editor.editing.view;
|
|
95
|
-
const blockElements = view.domConverter.blockElements;
|
|
96
|
-
// Traversing the viewElement subtree looking for block elements.
|
|
97
|
-
// Especially for the cases like <div><a href="#"><p>foo</p></a></div>.
|
|
98
|
-
// https://github.com/ckeditor/ckeditor5/issues/11513
|
|
99
|
-
for (const viewItem of view.createRangeIn(viewElement).getItems()) {
|
|
100
|
-
if (viewItem.is('element') && blockElements.includes(viewItem.name)) {
|
|
101
|
-
return true;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
return false;
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Adds attribute filtering conversion for the given data schema.
|
|
108
|
-
*/
|
|
109
|
-
_addAttributeConversion(definition) {
|
|
110
|
-
const editor = this.editor;
|
|
111
|
-
const conversion = editor.conversion;
|
|
112
|
-
const dataFilter = editor.plugins.get(DataFilter);
|
|
113
|
-
editor.model.schema.extend(definition.model, {
|
|
114
|
-
allowAttributes: getHtmlAttributeName(definition.view)
|
|
115
|
-
});
|
|
116
|
-
conversion.for('upcast').add(viewToModelBlockAttributeConverter(definition, dataFilter));
|
|
117
|
-
conversion.for('downcast').add(modelToViewBlockAttributeConverter(definition));
|
|
118
|
-
}
|
|
119
|
-
}
|
|
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
|
+
import { Plugin } from 'ckeditor5/src/core';
|
|
6
|
+
import { priorities } from 'ckeditor5/src/utils';
|
|
7
|
+
import { modelToViewBlockAttributeConverter, viewToModelBlockAttributeConverter } from '../converters';
|
|
8
|
+
import DataFilter from '../datafilter';
|
|
9
|
+
import { getHtmlAttributeName } from '../utils';
|
|
10
|
+
/**
|
|
11
|
+
* Provides the General HTML Support integration for elements which can behave like sectioning element (e.g. article) or
|
|
12
|
+
* element accepting only inline content (e.g. paragraph).
|
|
13
|
+
*
|
|
14
|
+
* The distinction between this two content models is important for choosing correct schema model and proper content conversion.
|
|
15
|
+
* As an example, it ensures that:
|
|
16
|
+
*
|
|
17
|
+
* * children elements paragraphing is enabled for sectioning elements only,
|
|
18
|
+
* * element and its content can be correctly handled by editing view (splitting and merging elements),
|
|
19
|
+
* * model element HTML is semantically correct and easier to work with.
|
|
20
|
+
*
|
|
21
|
+
* If element contains any block element, it will be treated as a sectioning element and registered using
|
|
22
|
+
* {@link module:html-support/dataschema~DataSchemaDefinition#model} and
|
|
23
|
+
* {@link module:html-support/dataschema~DataSchemaDefinition#modelSchema} in editor schema.
|
|
24
|
+
* Otherwise, it will be registered under {@link module:html-support/dataschema~DataSchemaBlockElementDefinition#paragraphLikeModel} model
|
|
25
|
+
* name with model schema accepting only inline content (inheriting from `$block`).
|
|
26
|
+
*/
|
|
27
|
+
export default class DualContentModelElementSupport extends Plugin {
|
|
28
|
+
/**
|
|
29
|
+
* @inheritDoc
|
|
30
|
+
*/
|
|
31
|
+
static get requires() {
|
|
32
|
+
return [DataFilter];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* @inheritDoc
|
|
36
|
+
*/
|
|
37
|
+
static get pluginName() {
|
|
38
|
+
return 'DualContentModelElementSupport';
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* @inheritDoc
|
|
42
|
+
*/
|
|
43
|
+
init() {
|
|
44
|
+
const dataFilter = this.editor.plugins.get(DataFilter);
|
|
45
|
+
dataFilter.on('register', (evt, definition) => {
|
|
46
|
+
const blockDefinition = definition;
|
|
47
|
+
const editor = this.editor;
|
|
48
|
+
const schema = editor.model.schema;
|
|
49
|
+
const conversion = editor.conversion;
|
|
50
|
+
if (!blockDefinition.paragraphLikeModel) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
// Can only apply to newly registered features.
|
|
54
|
+
if (schema.isRegistered(blockDefinition.model) || schema.isRegistered(blockDefinition.paragraphLikeModel)) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const paragraphLikeModelDefinition = {
|
|
58
|
+
model: blockDefinition.paragraphLikeModel,
|
|
59
|
+
view: blockDefinition.view
|
|
60
|
+
};
|
|
61
|
+
schema.register(blockDefinition.model, blockDefinition.modelSchema);
|
|
62
|
+
schema.register(paragraphLikeModelDefinition.model, {
|
|
63
|
+
inheritAllFrom: '$block'
|
|
64
|
+
});
|
|
65
|
+
conversion.for('upcast').elementToElement({
|
|
66
|
+
view: blockDefinition.view,
|
|
67
|
+
model: (viewElement, { writer }) => {
|
|
68
|
+
if (this._hasBlockContent(viewElement)) {
|
|
69
|
+
return writer.createElement(blockDefinition.model);
|
|
70
|
+
}
|
|
71
|
+
return writer.createElement(paragraphLikeModelDefinition.model);
|
|
72
|
+
},
|
|
73
|
+
// With a `low` priority, `paragraph` plugin auto-paragraphing mechanism is executed. Make sure
|
|
74
|
+
// this listener is called before it. If not, some elements will be transformed into a paragraph.
|
|
75
|
+
converterPriority: priorities.low + 0.5
|
|
76
|
+
});
|
|
77
|
+
conversion.for('downcast').elementToElement({
|
|
78
|
+
view: blockDefinition.view,
|
|
79
|
+
model: blockDefinition.model
|
|
80
|
+
});
|
|
81
|
+
this._addAttributeConversion(blockDefinition);
|
|
82
|
+
conversion.for('downcast').elementToElement({
|
|
83
|
+
view: paragraphLikeModelDefinition.view,
|
|
84
|
+
model: paragraphLikeModelDefinition.model
|
|
85
|
+
});
|
|
86
|
+
this._addAttributeConversion(paragraphLikeModelDefinition);
|
|
87
|
+
evt.stop();
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Checks whether the given view element includes any other block element.
|
|
92
|
+
*/
|
|
93
|
+
_hasBlockContent(viewElement) {
|
|
94
|
+
const view = this.editor.editing.view;
|
|
95
|
+
const blockElements = view.domConverter.blockElements;
|
|
96
|
+
// Traversing the viewElement subtree looking for block elements.
|
|
97
|
+
// Especially for the cases like <div><a href="#"><p>foo</p></a></div>.
|
|
98
|
+
// https://github.com/ckeditor/ckeditor5/issues/11513
|
|
99
|
+
for (const viewItem of view.createRangeIn(viewElement).getItems()) {
|
|
100
|
+
if (viewItem.is('element') && blockElements.includes(viewItem.name)) {
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Adds attribute filtering conversion for the given data schema.
|
|
108
|
+
*/
|
|
109
|
+
_addAttributeConversion(definition) {
|
|
110
|
+
const editor = this.editor;
|
|
111
|
+
const conversion = editor.conversion;
|
|
112
|
+
const dataFilter = editor.plugins.get(DataFilter);
|
|
113
|
+
editor.model.schema.extend(definition.model, {
|
|
114
|
+
allowAttributes: getHtmlAttributeName(definition.view)
|
|
115
|
+
});
|
|
116
|
+
conversion.for('upcast').add(viewToModelBlockAttributeConverter(definition, dataFilter));
|
|
117
|
+
conversion.for('downcast').add(modelToViewBlockAttributeConverter(definition));
|
|
118
|
+
}
|
|
119
|
+
}
|
|
@@ -1,31 +1,31 @@
|
|
|
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 } from 'ckeditor5/src/core';
|
|
9
|
-
import { Enter } from 'ckeditor5/src/enter';
|
|
10
|
-
import DataSchema from '../dataschema';
|
|
11
|
-
/**
|
|
12
|
-
* Provides the General HTML Support integration with {@link module:heading/heading~Heading Heading} feature.
|
|
13
|
-
*/
|
|
14
|
-
export default class HeadingElementSupport extends Plugin {
|
|
15
|
-
/**
|
|
16
|
-
* @inheritDoc
|
|
17
|
-
*/
|
|
18
|
-
static get requires(): readonly [typeof DataSchema, typeof Enter];
|
|
19
|
-
/**
|
|
20
|
-
* @inheritDoc
|
|
21
|
-
*/
|
|
22
|
-
static get pluginName(): "HeadingElementSupport";
|
|
23
|
-
/**
|
|
24
|
-
* @inheritDoc
|
|
25
|
-
*/
|
|
26
|
-
init(): void;
|
|
27
|
-
/**
|
|
28
|
-
* Registers all elements supported by HeadingEditing to enable custom attributes for those elements.
|
|
29
|
-
*/
|
|
30
|
-
private registerHeadingElements;
|
|
31
|
-
}
|
|
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 } from 'ckeditor5/src/core';
|
|
9
|
+
import { Enter } from 'ckeditor5/src/enter';
|
|
10
|
+
import DataSchema from '../dataschema';
|
|
11
|
+
/**
|
|
12
|
+
* Provides the General HTML Support integration with {@link module:heading/heading~Heading Heading} feature.
|
|
13
|
+
*/
|
|
14
|
+
export default class HeadingElementSupport extends Plugin {
|
|
15
|
+
/**
|
|
16
|
+
* @inheritDoc
|
|
17
|
+
*/
|
|
18
|
+
static get requires(): readonly [typeof DataSchema, typeof Enter];
|
|
19
|
+
/**
|
|
20
|
+
* @inheritDoc
|
|
21
|
+
*/
|
|
22
|
+
static get pluginName(): "HeadingElementSupport";
|
|
23
|
+
/**
|
|
24
|
+
* @inheritDoc
|
|
25
|
+
*/
|
|
26
|
+
init(): void;
|
|
27
|
+
/**
|
|
28
|
+
* Registers all elements supported by HeadingEditing to enable custom attributes for those elements.
|
|
29
|
+
*/
|
|
30
|
+
private registerHeadingElements;
|
|
31
|
+
}
|
|
@@ -1,60 +1,60 @@
|
|
|
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 } from 'ckeditor5/src/core';
|
|
9
|
-
import { Enter } from 'ckeditor5/src/enter';
|
|
10
|
-
import DataSchema from '../dataschema';
|
|
11
|
-
/**
|
|
12
|
-
* Provides the General HTML Support integration with {@link module:heading/heading~Heading Heading} feature.
|
|
13
|
-
*/
|
|
14
|
-
export default class HeadingElementSupport extends Plugin {
|
|
15
|
-
/**
|
|
16
|
-
* @inheritDoc
|
|
17
|
-
*/
|
|
18
|
-
static get requires() {
|
|
19
|
-
return [DataSchema, Enter];
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* @inheritDoc
|
|
23
|
-
*/
|
|
24
|
-
static get pluginName() {
|
|
25
|
-
return 'HeadingElementSupport';
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* @inheritDoc
|
|
29
|
-
*/
|
|
30
|
-
init() {
|
|
31
|
-
const editor = this.editor;
|
|
32
|
-
if (!editor.plugins.has('HeadingEditing')) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
const options = editor.config.get('heading.options');
|
|
36
|
-
this.registerHeadingElements(editor, options);
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Registers all elements supported by HeadingEditing to enable custom attributes for those elements.
|
|
40
|
-
*/
|
|
41
|
-
registerHeadingElements(editor, options) {
|
|
42
|
-
const dataSchema = editor.plugins.get(DataSchema);
|
|
43
|
-
const headerModels = [];
|
|
44
|
-
for (const option of options) {
|
|
45
|
-
if ('model' in option && 'view' in option) {
|
|
46
|
-
dataSchema.registerBlockElement({
|
|
47
|
-
view: option.view,
|
|
48
|
-
model: option.model
|
|
49
|
-
});
|
|
50
|
-
headerModels.push(option.model);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
dataSchema.extendBlockElement({
|
|
54
|
-
model: 'htmlHgroup',
|
|
55
|
-
modelSchema: {
|
|
56
|
-
allowChildren: headerModels
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
}
|
|
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 } from 'ckeditor5/src/core';
|
|
9
|
+
import { Enter } from 'ckeditor5/src/enter';
|
|
10
|
+
import DataSchema from '../dataschema';
|
|
11
|
+
/**
|
|
12
|
+
* Provides the General HTML Support integration with {@link module:heading/heading~Heading Heading} feature.
|
|
13
|
+
*/
|
|
14
|
+
export default class HeadingElementSupport extends Plugin {
|
|
15
|
+
/**
|
|
16
|
+
* @inheritDoc
|
|
17
|
+
*/
|
|
18
|
+
static get requires() {
|
|
19
|
+
return [DataSchema, Enter];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* @inheritDoc
|
|
23
|
+
*/
|
|
24
|
+
static get pluginName() {
|
|
25
|
+
return 'HeadingElementSupport';
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* @inheritDoc
|
|
29
|
+
*/
|
|
30
|
+
init() {
|
|
31
|
+
const editor = this.editor;
|
|
32
|
+
if (!editor.plugins.has('HeadingEditing')) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const options = editor.config.get('heading.options');
|
|
36
|
+
this.registerHeadingElements(editor, options);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Registers all elements supported by HeadingEditing to enable custom attributes for those elements.
|
|
40
|
+
*/
|
|
41
|
+
registerHeadingElements(editor, options) {
|
|
42
|
+
const dataSchema = editor.plugins.get(DataSchema);
|
|
43
|
+
const headerModels = [];
|
|
44
|
+
for (const option of options) {
|
|
45
|
+
if ('model' in option && 'view' in option) {
|
|
46
|
+
dataSchema.registerBlockElement({
|
|
47
|
+
view: option.view,
|
|
48
|
+
model: option.model
|
|
49
|
+
});
|
|
50
|
+
headerModels.push(option.model);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
dataSchema.extendBlockElement({
|
|
54
|
+
model: 'htmlHgroup',
|
|
55
|
+
modelSchema: {
|
|
56
|
+
allowChildren: headerModels
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -1,26 +1,26 @@
|
|
|
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 } from 'ckeditor5/src/core';
|
|
9
|
-
import DataFilter from '../datafilter';
|
|
10
|
-
/**
|
|
11
|
-
* Provides the General HTML Support integration with the {@link module:image/image~Image Image} feature.
|
|
12
|
-
*/
|
|
13
|
-
export default class ImageElementSupport extends Plugin {
|
|
14
|
-
/**
|
|
15
|
-
* @inheritDoc
|
|
16
|
-
*/
|
|
17
|
-
static get requires(): readonly [typeof DataFilter];
|
|
18
|
-
/**
|
|
19
|
-
* @inheritDoc
|
|
20
|
-
*/
|
|
21
|
-
static get pluginName(): "ImageElementSupport";
|
|
22
|
-
/**
|
|
23
|
-
* @inheritDoc
|
|
24
|
-
*/
|
|
25
|
-
init(): void;
|
|
26
|
-
}
|
|
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 } from 'ckeditor5/src/core';
|
|
9
|
+
import DataFilter from '../datafilter';
|
|
10
|
+
/**
|
|
11
|
+
* Provides the General HTML Support integration with the {@link module:image/image~Image Image} feature.
|
|
12
|
+
*/
|
|
13
|
+
export default class ImageElementSupport extends Plugin {
|
|
14
|
+
/**
|
|
15
|
+
* @inheritDoc
|
|
16
|
+
*/
|
|
17
|
+
static get requires(): readonly [typeof DataFilter];
|
|
18
|
+
/**
|
|
19
|
+
* @inheritDoc
|
|
20
|
+
*/
|
|
21
|
+
static get pluginName(): "ImageElementSupport";
|
|
22
|
+
/**
|
|
23
|
+
* @inheritDoc
|
|
24
|
+
*/
|
|
25
|
+
init(): void;
|
|
26
|
+
}
|