@ckeditor/ckeditor5-html-support 36.0.1 → 37.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/README.md +2 -2
- package/build/html-support.js +1 -1
- package/ckeditor5-metadata.json +2 -2
- package/package.json +42 -36
- package/src/augmentation.d.ts +33 -0
- package/src/augmentation.js +5 -0
- 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 +250 -0
- package/src/datafilter.js +566 -782
- package/src/dataschema.d.ts +169 -0
- package/src/dataschema.js +143 -229
- package/src/fullpage.d.ts +21 -0
- package/src/fullpage.js +65 -86
- package/src/generalhtmlsupport.d.ts +88 -0
- package/src/generalhtmlsupport.js +244 -327
- package/src/generalhtmlsupportconfig.d.ts +67 -0
- package/src/generalhtmlsupportconfig.js +5 -0
- package/src/htmlcomment.d.ts +72 -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 +25 -0
- package/src/index.js +1 -2
- package/src/integrations/codeblock.d.ts +22 -0
- package/src/integrations/codeblock.js +87 -115
- package/src/integrations/customelement.d.ts +25 -0
- package/src/integrations/customelement.js +127 -160
- package/src/integrations/documentlist.d.ts +26 -0
- package/src/integrations/documentlist.js +154 -191
- package/src/integrations/dualcontent.d.ts +44 -0
- package/src/integrations/dualcontent.js +92 -128
- package/src/integrations/heading.d.ts +25 -0
- package/src/integrations/heading.js +41 -54
- package/src/integrations/image.d.ts +25 -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 +25 -0
- package/src/integrations/mediaembed.js +101 -147
- package/src/integrations/script.d.ts +25 -0
- package/src/integrations/script.js +45 -67
- package/src/integrations/style.d.ts +25 -0
- package/src/integrations/style.js +45 -67
- package/src/integrations/table.d.ts +22 -0
- package/src/integrations/table.js +113 -160
- package/src/schemadefinitions.d.ts +13 -0
- package/src/schemadefinitions.js +846 -835
package/src/fullpage.js
CHANGED
|
@@ -2,100 +2,79 @@
|
|
|
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/fullpage
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
8
|
import { Plugin } from 'ckeditor5/src/core';
|
|
11
9
|
import { UpcastWriter } from 'ckeditor5/src/engine';
|
|
12
10
|
import HtmlPageDataProcessor from './htmlpagedataprocessor';
|
|
13
|
-
|
|
14
11
|
/**
|
|
15
12
|
* The full page editing feature. It preserves the whole HTML page in the editor data.
|
|
16
|
-
*
|
|
17
|
-
* @extends module:core/plugin~Plugin
|
|
18
13
|
*/
|
|
19
14
|
export default class FullPage 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
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
if ( root.hasAttribute( name ) ) {
|
|
86
|
-
writer.removeAttribute( name, root );
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
} );
|
|
90
|
-
}, { priority: 'high' } );
|
|
91
|
-
|
|
92
|
-
// Make sure that document is returned even if there is no content in the page body.
|
|
93
|
-
editor.data.on( 'get', ( evt, args ) => {
|
|
94
|
-
if ( !args[ 0 ] ) {
|
|
95
|
-
args[ 0 ] = {};
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
args[ 0 ].trim = false;
|
|
99
|
-
}, { priority: 'high' } );
|
|
100
|
-
}
|
|
15
|
+
/**
|
|
16
|
+
* @inheritDoc
|
|
17
|
+
*/
|
|
18
|
+
static get pluginName() {
|
|
19
|
+
return 'FullPage';
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* @inheritDoc
|
|
23
|
+
*/
|
|
24
|
+
init() {
|
|
25
|
+
const editor = this.editor;
|
|
26
|
+
const properties = ['$fullPageDocument', '$fullPageDocType', '$fullPageXmlDeclaration'];
|
|
27
|
+
editor.data.processor = new HtmlPageDataProcessor(editor.data.viewDocument);
|
|
28
|
+
editor.model.schema.extend('$root', {
|
|
29
|
+
allowAttributes: properties
|
|
30
|
+
});
|
|
31
|
+
// Apply custom properties from view document fragment to the model root attributes.
|
|
32
|
+
editor.data.on('toModel', (evt, [viewElementOrFragment]) => {
|
|
33
|
+
const root = editor.model.document.getRoot();
|
|
34
|
+
editor.model.change(writer => {
|
|
35
|
+
for (const name of properties) {
|
|
36
|
+
const value = viewElementOrFragment.getCustomProperty(name);
|
|
37
|
+
if (value) {
|
|
38
|
+
writer.setAttribute(name, value, root);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}, { priority: 'low' });
|
|
43
|
+
// Apply root attributes to the view document fragment.
|
|
44
|
+
editor.data.on('toView', (evt, [modelElementOrFragment]) => {
|
|
45
|
+
if (!modelElementOrFragment.is('rootElement')) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const root = modelElementOrFragment;
|
|
49
|
+
const viewFragment = evt.return;
|
|
50
|
+
if (!root.hasAttribute('$fullPageDocument')) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const writer = new UpcastWriter(viewFragment.document);
|
|
54
|
+
for (const name of properties) {
|
|
55
|
+
const value = root.getAttribute(name);
|
|
56
|
+
if (value) {
|
|
57
|
+
writer.setCustomProperty(name, value, viewFragment);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}, { priority: 'low' });
|
|
61
|
+
// Clear root attributes related to full page editing on editor content reset.
|
|
62
|
+
editor.data.on('set', () => {
|
|
63
|
+
const root = editor.model.document.getRoot();
|
|
64
|
+
editor.model.change(writer => {
|
|
65
|
+
for (const name of properties) {
|
|
66
|
+
if (root.hasAttribute(name)) {
|
|
67
|
+
writer.removeAttribute(name, root);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}, { priority: 'high' });
|
|
72
|
+
// Make sure that document is returned even if there is no content in the page body.
|
|
73
|
+
editor.data.on('get', (evt, args) => {
|
|
74
|
+
if (!args[0]) {
|
|
75
|
+
args[0] = {};
|
|
76
|
+
}
|
|
77
|
+
args[0].trim = false;
|
|
78
|
+
}, { priority: 'high' });
|
|
79
|
+
}
|
|
101
80
|
}
|
|
@@ -0,0 +1,88 @@
|
|
|
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/generalhtmlsupport
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin, type PluginDependencies } from 'ckeditor5/src/core';
|
|
9
|
+
import { type ArrayOrItem } from 'ckeditor5/src/utils';
|
|
10
|
+
import type { Range, Selectable } from 'ckeditor5/src/engine';
|
|
11
|
+
type LimitedSelectable = Exclude<Selectable, Iterable<Range> | null>;
|
|
12
|
+
/**
|
|
13
|
+
* The General HTML Support feature.
|
|
14
|
+
*
|
|
15
|
+
* This is a "glue" plugin which initializes the {@link module:html-support/datafilter~DataFilter data filter} configuration
|
|
16
|
+
* and features integration with the General HTML Support.
|
|
17
|
+
*/
|
|
18
|
+
export default class GeneralHtmlSupport extends Plugin {
|
|
19
|
+
/**
|
|
20
|
+
* @inheritDoc
|
|
21
|
+
*/
|
|
22
|
+
static get pluginName(): 'GeneralHtmlSupport';
|
|
23
|
+
/**
|
|
24
|
+
* @inheritDoc
|
|
25
|
+
*/
|
|
26
|
+
static get requires(): PluginDependencies;
|
|
27
|
+
/**
|
|
28
|
+
* @inheritDoc
|
|
29
|
+
*/
|
|
30
|
+
init(): void;
|
|
31
|
+
/**
|
|
32
|
+
* Returns a GHS model attribute name related to a given view element name.
|
|
33
|
+
*
|
|
34
|
+
* @param viewElementName A view element name.
|
|
35
|
+
*/
|
|
36
|
+
private getGhsAttributeNameForElement;
|
|
37
|
+
/**
|
|
38
|
+
* Updates GHS model attribute for a specified view element name, so it includes the given class name.
|
|
39
|
+
*
|
|
40
|
+
* @internal
|
|
41
|
+
* @param viewElementName A view element name.
|
|
42
|
+
* @param className The css class to add.
|
|
43
|
+
* @param selectable The selection or element to update.
|
|
44
|
+
*/
|
|
45
|
+
addModelHtmlClass(viewElementName: string, className: ArrayOrItem<string>, selectable: LimitedSelectable): void;
|
|
46
|
+
/**
|
|
47
|
+
* Updates GHS model attribute for a specified view element name, so it does not include the given class name.
|
|
48
|
+
*
|
|
49
|
+
* @internal
|
|
50
|
+
* @param viewElementName A view element name.
|
|
51
|
+
* @param className The css class to remove.
|
|
52
|
+
* @param selectable The selection or element to update.
|
|
53
|
+
*/
|
|
54
|
+
removeModelHtmlClass(viewElementName: string, className: ArrayOrItem<string>, selectable: LimitedSelectable): void;
|
|
55
|
+
/**
|
|
56
|
+
* Updates GHS model attribute for a specified view element name, so it includes the given attribute.
|
|
57
|
+
*
|
|
58
|
+
* @param viewElementName A view element name.
|
|
59
|
+
* @param attributes The object with attributes to set.
|
|
60
|
+
* @param selectable The selection or element to update.
|
|
61
|
+
*/
|
|
62
|
+
private setModelHtmlAttributes;
|
|
63
|
+
/**
|
|
64
|
+
* Updates GHS model attribute for a specified view element name, so it does not include the given attribute.
|
|
65
|
+
*
|
|
66
|
+
* @param viewElementName A view element name.
|
|
67
|
+
* @param attributeName The attribute name (or names) to remove.
|
|
68
|
+
* @param selectable The selection or element to update.
|
|
69
|
+
*/
|
|
70
|
+
private removeModelHtmlAttributes;
|
|
71
|
+
/**
|
|
72
|
+
* Updates GHS model attribute for a specified view element name, so it includes a given style.
|
|
73
|
+
*
|
|
74
|
+
* @param viewElementName A view element name.
|
|
75
|
+
* @param styles The object with styles to set.
|
|
76
|
+
* @param selectable The selection or element to update.
|
|
77
|
+
*/
|
|
78
|
+
private setModelHtmlStyles;
|
|
79
|
+
/**
|
|
80
|
+
* Updates GHS model attribute for a specified view element name, so it does not include a given style.
|
|
81
|
+
*
|
|
82
|
+
* @param viewElementName A view element name.
|
|
83
|
+
* @param properties The style (or styles list) to remove.
|
|
84
|
+
* @param selectable The selection or element to update.
|
|
85
|
+
*/
|
|
86
|
+
private removeModelHtmlStyles;
|
|
87
|
+
}
|
|
88
|
+
export {};
|