@ckeditor/ckeditor5-html-support 44.3.0 → 45.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/LICENSE.md +1 -1
- package/build/html-support.js +2 -2
- package/build/translations/be.js +1 -0
- package/dist/index.js +135 -5
- package/dist/index.js.map +1 -1
- package/dist/translations/be.d.ts +8 -0
- package/dist/translations/be.js +5 -0
- package/dist/translations/be.umd.js +11 -0
- package/lang/translations/be.po +16 -0
- package/package.json +12 -12
- package/src/datafilter.js +33 -1
- package/src/dataschema.js +5 -8
- package/src/fullpage.d.ts +24 -1
- package/src/fullpage.js +87 -2
- package/src/generalhtmlsupportconfig.d.ts +86 -0
- package/src/htmlpagedataprocessor.js +3 -0
- package/src/index.d.ts +1 -1
- package/src/integrations/list.js +1 -1
- package/src/integrations/table.js +39 -1
- package/src/utils.js +1 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { Translations } from '@ckeditor/ckeditor5-utils';
|
|
7
|
+
declare const translations: Translations;
|
|
8
|
+
export default translations;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
+
*/
|
|
5
|
+
export default {"be":{"dictionary":{"HTML object":"HTML аб'ект"},getPluralForm(n){return (n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);}}}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
( e => {
|
|
7
|
+
const { [ 'be' ]: { dictionary, getPluralForm } } = {"be":{"dictionary":{"HTML object":"HTML аб'ект"},getPluralForm(n){return (n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);}}};
|
|
8
|
+
e[ 'be' ] ||= { dictionary: {}, getPluralForm: null };
|
|
9
|
+
e[ 'be' ].dictionary = Object.assign( e[ 'be' ].dictionary, dictionary );
|
|
10
|
+
e[ 'be' ].getPluralForm = getPluralForm;
|
|
11
|
+
} )( window.CKEDITOR_TRANSLATIONS ||= {} );
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
|
|
2
|
+
#
|
|
3
|
+
# Want to contribute to this file? Submit your changes via a GitHub Pull Request.
|
|
4
|
+
#
|
|
5
|
+
# Check out the official contributor's guide:
|
|
6
|
+
# https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
|
|
7
|
+
#
|
|
8
|
+
msgid ""
|
|
9
|
+
msgstr ""
|
|
10
|
+
"Language: be\n"
|
|
11
|
+
"Plural-Forms: nplurals=3; plural=(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);\n"
|
|
12
|
+
"Content-Type: text/plain; charset=UTF-8\n"
|
|
13
|
+
|
|
14
|
+
msgctxt "A label describing an HTML object widget."
|
|
15
|
+
msgid "HTML object"
|
|
16
|
+
msgstr "HTML аб'ект"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckeditor/ckeditor5-html-support",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "45.0.0-alpha.0",
|
|
4
4
|
"description": "HTML Support feature for CKEditor 5.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ckeditor",
|
|
@@ -17,17 +17,17 @@
|
|
|
17
17
|
"type": "module",
|
|
18
18
|
"main": "src/index.js",
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@ckeditor/ckeditor5-core": "
|
|
21
|
-
"@ckeditor/ckeditor5-engine": "
|
|
22
|
-
"@ckeditor/ckeditor5-enter": "
|
|
23
|
-
"@ckeditor/ckeditor5-heading": "
|
|
24
|
-
"@ckeditor/ckeditor5-image": "
|
|
25
|
-
"@ckeditor/ckeditor5-list": "
|
|
26
|
-
"@ckeditor/ckeditor5-table": "
|
|
27
|
-
"@ckeditor/ckeditor5-utils": "
|
|
28
|
-
"@ckeditor/ckeditor5-widget": "
|
|
29
|
-
"ckeditor5": "
|
|
30
|
-
"
|
|
20
|
+
"@ckeditor/ckeditor5-core": "45.0.0-alpha.0",
|
|
21
|
+
"@ckeditor/ckeditor5-engine": "45.0.0-alpha.0",
|
|
22
|
+
"@ckeditor/ckeditor5-enter": "45.0.0-alpha.0",
|
|
23
|
+
"@ckeditor/ckeditor5-heading": "45.0.0-alpha.0",
|
|
24
|
+
"@ckeditor/ckeditor5-image": "45.0.0-alpha.0",
|
|
25
|
+
"@ckeditor/ckeditor5-list": "45.0.0-alpha.0",
|
|
26
|
+
"@ckeditor/ckeditor5-table": "45.0.0-alpha.0",
|
|
27
|
+
"@ckeditor/ckeditor5-utils": "45.0.0-alpha.0",
|
|
28
|
+
"@ckeditor/ckeditor5-widget": "45.0.0-alpha.0",
|
|
29
|
+
"ckeditor5": "45.0.0-alpha.0",
|
|
30
|
+
"es-toolkit": "1.32.0"
|
|
31
31
|
},
|
|
32
32
|
"author": "CKSource (http://cksource.com/)",
|
|
33
33
|
"license": "SEE LICENSE IN LICENSE.md",
|
package/src/datafilter.js
CHANGED
|
@@ -12,7 +12,7 @@ import { Widget } from 'ckeditor5/src/widget.js';
|
|
|
12
12
|
import { viewToModelObjectConverter, toObjectWidgetConverter, createObjectView, viewToAttributeInlineConverter, attributeToViewInlineConverter, emptyInlineModelElementToViewConverter, viewToModelBlockAttributeConverter, modelToViewBlockAttributeConverter } from './converters.js';
|
|
13
13
|
import { default as DataSchema } from './dataschema.js';
|
|
14
14
|
import { getHtmlAttributeName } from './utils.js';
|
|
15
|
-
import { isPlainObject } from '
|
|
15
|
+
import { isPlainObject } from 'es-toolkit/compat';
|
|
16
16
|
import '../theme/datafilter.css';
|
|
17
17
|
/**
|
|
18
18
|
* Allows to validate elements and element attributes registered by {@link module:html-support/dataschema~DataSchema}.
|
|
@@ -47,6 +47,38 @@ import '../theme/datafilter.css';
|
|
|
47
47
|
* use the {@link module:html-support/datafilter~DataFilter#processViewAttributes `processViewAttributes()`} method.
|
|
48
48
|
*/
|
|
49
49
|
export default class DataFilter extends Plugin {
|
|
50
|
+
/**
|
|
51
|
+
* An instance of the {@link module:html-support/dataschema~DataSchema}.
|
|
52
|
+
*/
|
|
53
|
+
_dataSchema;
|
|
54
|
+
/**
|
|
55
|
+
* {@link module:engine/view/matcher~Matcher Matcher} instance describing rules upon which
|
|
56
|
+
* content attributes should be allowed.
|
|
57
|
+
*/
|
|
58
|
+
_allowedAttributes;
|
|
59
|
+
/**
|
|
60
|
+
* {@link module:engine/view/matcher~Matcher Matcher} instance describing rules upon which
|
|
61
|
+
* content attributes should be disallowed.
|
|
62
|
+
*/
|
|
63
|
+
_disallowedAttributes;
|
|
64
|
+
/**
|
|
65
|
+
* Allowed element definitions by {@link module:html-support/datafilter~DataFilter#allowElement} method.
|
|
66
|
+
*/
|
|
67
|
+
_allowedElements;
|
|
68
|
+
/**
|
|
69
|
+
* Disallowed element names by {@link module:html-support/datafilter~DataFilter#disallowElement} method.
|
|
70
|
+
*/
|
|
71
|
+
_disallowedElements;
|
|
72
|
+
/**
|
|
73
|
+
* Indicates if {@link module:engine/controller/datacontroller~DataController editor's data controller}
|
|
74
|
+
* data has been already initialized.
|
|
75
|
+
*/
|
|
76
|
+
_dataInitialized;
|
|
77
|
+
/**
|
|
78
|
+
* Cached map of coupled attributes. Keys are the feature attributes names
|
|
79
|
+
* and values are arrays with coupled GHS attributes names.
|
|
80
|
+
*/
|
|
81
|
+
_coupledAttributes;
|
|
50
82
|
constructor(editor) {
|
|
51
83
|
super(editor);
|
|
52
84
|
this._dataSchema = editor.plugins.get('DataSchema');
|
package/src/dataschema.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import { Plugin } from 'ckeditor5/src/core.js';
|
|
9
9
|
import { toArray } from 'ckeditor5/src/utils.js';
|
|
10
10
|
import defaultConfig from './schemadefinitions.js';
|
|
11
|
-
import { mergeWith } from '
|
|
11
|
+
import { mergeWith } from 'es-toolkit/compat';
|
|
12
12
|
/**
|
|
13
13
|
* Holds representation of the extended HTML document type definitions to be used by the
|
|
14
14
|
* editor in HTML support.
|
|
@@ -42,13 +42,10 @@ import { mergeWith } from 'lodash-es';
|
|
|
42
42
|
* ```
|
|
43
43
|
*/
|
|
44
44
|
export default class DataSchema extends Plugin {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
*/
|
|
50
|
-
this._definitions = [];
|
|
51
|
-
}
|
|
45
|
+
/**
|
|
46
|
+
* A map of registered data schema definitions.
|
|
47
|
+
*/
|
|
48
|
+
_definitions = [];
|
|
52
49
|
/**
|
|
53
50
|
* @inheritDoc
|
|
54
51
|
*/
|
package/src/fullpage.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module html-support/fullpage
|
|
7
7
|
*/
|
|
8
|
-
import { Plugin } from 'ckeditor5/src/core.js';
|
|
8
|
+
import { Plugin, type Editor } from 'ckeditor5/src/core.js';
|
|
9
9
|
/**
|
|
10
10
|
* The full page editing feature. It preserves the whole HTML page in the editor data.
|
|
11
11
|
*/
|
|
@@ -18,8 +18,31 @@ export default class FullPage extends Plugin {
|
|
|
18
18
|
* @inheritDoc
|
|
19
19
|
*/
|
|
20
20
|
static get isOfficialPlugin(): true;
|
|
21
|
+
/**
|
|
22
|
+
* @inheritDoc
|
|
23
|
+
*/
|
|
24
|
+
constructor(editor: Editor);
|
|
21
25
|
/**
|
|
22
26
|
* @inheritDoc
|
|
23
27
|
*/
|
|
24
28
|
init(): void;
|
|
29
|
+
/**
|
|
30
|
+
* @inheritDoc
|
|
31
|
+
*/
|
|
32
|
+
destroy(): void;
|
|
33
|
+
/**
|
|
34
|
+
* Checks if in the document exists any `<style>` elements injected by the plugin and removes them,
|
|
35
|
+
* so these could be re-rendered later.
|
|
36
|
+
* There is used `data-full-page-style-id` attribute to recognize styles injected by the feature.
|
|
37
|
+
*/
|
|
38
|
+
private _removeStyleElementsFromDom;
|
|
39
|
+
/**
|
|
40
|
+
* Extracts `<style>` elements from the full page data and renders them in the main document `<head>`.
|
|
41
|
+
* CSS content is sanitized before rendering.
|
|
42
|
+
*/
|
|
43
|
+
private _renderStyleElementsInDom;
|
|
44
|
+
/**
|
|
45
|
+
* Removes existing `<style>` elements injected by the plugin and renders new ones from the full page data.
|
|
46
|
+
*/
|
|
47
|
+
private _renderStylesFromHead;
|
|
25
48
|
}
|
package/src/fullpage.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* @module html-support/fullpage
|
|
7
7
|
*/
|
|
8
8
|
import { Plugin } from 'ckeditor5/src/core.js';
|
|
9
|
+
import { logWarning, global } from 'ckeditor5/src/utils.js';
|
|
9
10
|
import { UpcastWriter } from 'ckeditor5/src/engine.js';
|
|
10
11
|
import HtmlPageDataProcessor from './htmlpagedataprocessor.js';
|
|
11
12
|
/**
|
|
@@ -24,13 +25,38 @@ export default class FullPage extends Plugin {
|
|
|
24
25
|
static get isOfficialPlugin() {
|
|
25
26
|
return true;
|
|
26
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* @inheritDoc
|
|
30
|
+
*/
|
|
31
|
+
constructor(editor) {
|
|
32
|
+
super(editor);
|
|
33
|
+
editor.config.define('htmlSupport.fullPage', {
|
|
34
|
+
allowRenderStylesFromHead: false,
|
|
35
|
+
sanitizeCss: rawCss => {
|
|
36
|
+
/**
|
|
37
|
+
* When using the Full page with the `config.htmlSupport.fullPage.allowRenderStylesFromHead` set to `true`,
|
|
38
|
+
* it is strongly recommended to define a sanitize function that will clean up the CSS
|
|
39
|
+
* which is present in the `<head>` in editors content in order to avoid XSS vulnerability.
|
|
40
|
+
*
|
|
41
|
+
* For a detailed overview, check the {@glink features/html/full-page-html Full page HTML feature} documentation.
|
|
42
|
+
*
|
|
43
|
+
* @error css-full-page-provide-sanitize-function
|
|
44
|
+
*/
|
|
45
|
+
logWarning('css-full-page-provide-sanitize-function');
|
|
46
|
+
return {
|
|
47
|
+
css: rawCss,
|
|
48
|
+
hasChanged: false
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
editor.data.processor = new HtmlPageDataProcessor(editor.data.viewDocument);
|
|
53
|
+
}
|
|
27
54
|
/**
|
|
28
55
|
* @inheritDoc
|
|
29
56
|
*/
|
|
30
57
|
init() {
|
|
31
58
|
const editor = this.editor;
|
|
32
|
-
const properties = ['$fullPageDocument', '$fullPageDocType', '$fullPageXmlDeclaration'];
|
|
33
|
-
editor.data.processor = new HtmlPageDataProcessor(editor.data.viewDocument);
|
|
59
|
+
const properties = ['$fullPageDocument', '$fullPageDocType', '$fullPageXmlDeclaration', '$fullPageHeadStyles'];
|
|
34
60
|
editor.model.schema.extend('$root', {
|
|
35
61
|
allowAttributes: properties
|
|
36
62
|
});
|
|
@@ -45,6 +71,9 @@ export default class FullPage extends Plugin {
|
|
|
45
71
|
}
|
|
46
72
|
}
|
|
47
73
|
});
|
|
74
|
+
if (isAllowedRenderStylesFromHead(editor)) {
|
|
75
|
+
this._renderStylesFromHead(root);
|
|
76
|
+
}
|
|
48
77
|
}, { priority: 'low' });
|
|
49
78
|
// Apply root attributes to the view document fragment.
|
|
50
79
|
editor.data.on('toView', (evt, [modelElementOrFragment]) => {
|
|
@@ -83,4 +112,60 @@ export default class FullPage extends Plugin {
|
|
|
83
112
|
args[0].trim = false;
|
|
84
113
|
}, { priority: 'high' });
|
|
85
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
* @inheritDoc
|
|
117
|
+
*/
|
|
118
|
+
destroy() {
|
|
119
|
+
super.destroy();
|
|
120
|
+
if (isAllowedRenderStylesFromHead(this.editor)) {
|
|
121
|
+
this._removeStyleElementsFromDom();
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Checks if in the document exists any `<style>` elements injected by the plugin and removes them,
|
|
126
|
+
* so these could be re-rendered later.
|
|
127
|
+
* There is used `data-full-page-style-id` attribute to recognize styles injected by the feature.
|
|
128
|
+
*/
|
|
129
|
+
_removeStyleElementsFromDom() {
|
|
130
|
+
const existingStyleElements = Array.from(global.document.querySelectorAll(`[data-full-page-style-id="${this.editor.id}"]`));
|
|
131
|
+
for (const style of existingStyleElements) {
|
|
132
|
+
style.remove();
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Extracts `<style>` elements from the full page data and renders them in the main document `<head>`.
|
|
137
|
+
* CSS content is sanitized before rendering.
|
|
138
|
+
*/
|
|
139
|
+
_renderStyleElementsInDom(root) {
|
|
140
|
+
const editor = this.editor;
|
|
141
|
+
// Get `<style>` elements list from the `<head>` from the full page data.
|
|
142
|
+
const styleElements = root.getAttribute('$fullPageHeadStyles');
|
|
143
|
+
if (!styleElements) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
const sanitizeCss = editor.config.get('htmlSupport.fullPage.sanitizeCss');
|
|
147
|
+
// Add `data-full-page-style-id` attribute to the `<style>` element and render it in `<head>` in the main document.
|
|
148
|
+
for (const style of styleElements) {
|
|
149
|
+
style.setAttribute('data-full-page-style-id', editor.id);
|
|
150
|
+
// Sanitize the CSS content before rendering it in the editor.
|
|
151
|
+
const sanitizedCss = sanitizeCss(style.innerText);
|
|
152
|
+
if (sanitizedCss.hasChanged) {
|
|
153
|
+
style.innerText = sanitizedCss.css;
|
|
154
|
+
}
|
|
155
|
+
global.document.head.append(style);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Removes existing `<style>` elements injected by the plugin and renders new ones from the full page data.
|
|
160
|
+
*/
|
|
161
|
+
_renderStylesFromHead(root) {
|
|
162
|
+
this._removeStyleElementsFromDom();
|
|
163
|
+
this._renderStyleElementsInDom(root);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Normalize the Full page configuration option `allowRenderStylesFromHead`.
|
|
168
|
+
*/
|
|
169
|
+
function isAllowedRenderStylesFromHead(editor) {
|
|
170
|
+
return editor.config.get('htmlSupport.fullPage.allowRenderStylesFromHead');
|
|
86
171
|
}
|
|
@@ -86,4 +86,90 @@ export interface GeneralHtmlSupportConfig {
|
|
|
86
86
|
* @default false
|
|
87
87
|
*/
|
|
88
88
|
preserveEmptyBlocksInEditingView?: boolean;
|
|
89
|
+
/**
|
|
90
|
+
* The configuration of the Full page editing feature.
|
|
91
|
+
* The option is used by the {@link module:html-support/fullpage~FullPage} feature.
|
|
92
|
+
*
|
|
93
|
+
* ```ts
|
|
94
|
+
* ClassicEditor
|
|
95
|
+
* .create( {
|
|
96
|
+
* htmlSupport: {
|
|
97
|
+
* fullPage: ... // Full page feature config.
|
|
98
|
+
* }
|
|
99
|
+
* } )
|
|
100
|
+
* .then( ... )
|
|
101
|
+
* .catch( ... );
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
fullPage?: FullPageConfig;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* The configuration of the Full page editing feature.
|
|
108
|
+
*/
|
|
109
|
+
export interface FullPageConfig {
|
|
110
|
+
/**
|
|
111
|
+
* Whether the feature should allow the editor to render styles from the `<head>` section of editor data content.
|
|
112
|
+
*
|
|
113
|
+
* When set to `true`, the editor will render styles from the `<head>` section of editor data content.
|
|
114
|
+
*
|
|
115
|
+
* ```ts
|
|
116
|
+
* ClassicEditor
|
|
117
|
+
* .create( {
|
|
118
|
+
* htmlSupport: {
|
|
119
|
+
* fullPage: {
|
|
120
|
+
* allowRenderStylesFromHead: true
|
|
121
|
+
* }
|
|
122
|
+
* }
|
|
123
|
+
* } )
|
|
124
|
+
* .then( ... )
|
|
125
|
+
* .catch( ... );
|
|
126
|
+
* ```
|
|
127
|
+
*
|
|
128
|
+
* @default false
|
|
129
|
+
*/
|
|
130
|
+
allowRenderStylesFromHead?: boolean;
|
|
131
|
+
/**
|
|
132
|
+
* Callback used to sanitize the CSS provided by the user in editor content
|
|
133
|
+
* when option `htmlSupport.fullPage.allowRenderStylesFromHead` is set to `true`.
|
|
134
|
+
*
|
|
135
|
+
* We strongly recommend overwriting the default function to avoid XSS vulnerabilities.
|
|
136
|
+
*
|
|
137
|
+
* The function receives the CSS (as a string), and should return an object
|
|
138
|
+
* that matches the {@link module:html-support/generalhtmlsupportconfig~CssSanitizeOutput} interface.
|
|
139
|
+
*
|
|
140
|
+
* ```ts
|
|
141
|
+
* ClassicEditor
|
|
142
|
+
* .create( editorElement, {
|
|
143
|
+
* htmlSupport: {
|
|
144
|
+
* fullPage: {
|
|
145
|
+
* allowRenderStylesFromHead: true,
|
|
146
|
+
*
|
|
147
|
+
* sanitizeCss( CssString ) {
|
|
148
|
+
* const sanitizedCss = sanitize( CssString );
|
|
149
|
+
*
|
|
150
|
+
* return {
|
|
151
|
+
* css: sanitizedCss,
|
|
152
|
+
* // true or false depending on whether the sanitizer stripped anything.
|
|
153
|
+
* hasChanged: ...
|
|
154
|
+
* };
|
|
155
|
+
* }
|
|
156
|
+
* }
|
|
157
|
+
* }
|
|
158
|
+
* } )
|
|
159
|
+
* .then( ... )
|
|
160
|
+
* .catch( ... );
|
|
161
|
+
* ```
|
|
162
|
+
*
|
|
163
|
+
*/
|
|
164
|
+
sanitizeCss?: (css: string) => CssSanitizeOutput;
|
|
165
|
+
}
|
|
166
|
+
export interface CssSanitizeOutput {
|
|
167
|
+
/**
|
|
168
|
+
* An output (safe) CSS that will be inserted into the document.
|
|
169
|
+
*/
|
|
170
|
+
css: string;
|
|
171
|
+
/**
|
|
172
|
+
* A flag that indicates whether the output CSS is different than the input value.
|
|
173
|
+
*/
|
|
174
|
+
hasChanged: boolean;
|
|
89
175
|
}
|
|
@@ -37,6 +37,9 @@ export default class HtmlPageDataProcessor extends HtmlDataProcessor {
|
|
|
37
37
|
const writer = new UpcastWriter(viewFragment.document);
|
|
38
38
|
// Using the DOM document with body content extracted as a skeleton of the page.
|
|
39
39
|
writer.setCustomProperty('$fullPageDocument', domFragment.ownerDocument.documentElement.outerHTML, viewFragment);
|
|
40
|
+
// List of `<style>` elements extracted from document's `<head>` element.
|
|
41
|
+
const headStylesElements = Array.from(domFragment.ownerDocument.querySelectorAll('head style'));
|
|
42
|
+
writer.setCustomProperty('$fullPageHeadStyles', headStylesElements, viewFragment);
|
|
40
43
|
if (docType) {
|
|
41
44
|
writer.setCustomProperty('$fullPageDocType', docType, viewFragment);
|
|
42
45
|
}
|
package/src/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @module html-support
|
|
7
7
|
*/
|
|
8
8
|
export { default as GeneralHtmlSupport } from './generalhtmlsupport.js';
|
|
9
|
-
export { default as DataFilter } from './datafilter.js';
|
|
9
|
+
export { default as DataFilter, type DataFilterRegisterEvent } from './datafilter.js';
|
|
10
10
|
export { default as DataSchema, type DataSchemaBlockElementDefinition } from './dataschema.js';
|
|
11
11
|
export { default as HtmlComment } from './htmlcomment.js';
|
|
12
12
|
export { default as FullPage } from './fullpage.js';
|
package/src/integrations/list.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module html-support/integrations/list
|
|
7
7
|
*/
|
|
8
|
-
import { isEqual } from '
|
|
8
|
+
import { isEqual } from 'es-toolkit/compat';
|
|
9
9
|
import { Plugin } from 'ckeditor5/src/core.js';
|
|
10
10
|
import { getHtmlAttributeName, setViewAttributes } from '../utils.js';
|
|
11
11
|
import DataFilter from '../datafilter.js';
|
|
@@ -6,6 +6,14 @@ import { Plugin } from 'ckeditor5/src/core.js';
|
|
|
6
6
|
import { updateViewAttributes } from '../utils.js';
|
|
7
7
|
import DataFilter from '../datafilter.js';
|
|
8
8
|
import { getDescendantElement } from './integrationutils.js';
|
|
9
|
+
const STYLE_ATTRIBUTES_TO_PROPAGATE = [
|
|
10
|
+
'width',
|
|
11
|
+
'max-width',
|
|
12
|
+
'min-width',
|
|
13
|
+
'height',
|
|
14
|
+
'min-height',
|
|
15
|
+
'max-height'
|
|
16
|
+
];
|
|
9
17
|
/**
|
|
10
18
|
* Provides the General HTML Support integration with {@link module:table/table~Table Table} feature.
|
|
11
19
|
*/
|
|
@@ -162,8 +170,38 @@ function modelToViewTableAttributeConverter() {
|
|
|
162
170
|
return;
|
|
163
171
|
}
|
|
164
172
|
conversionApi.consumable.consume(data.item, evt.name);
|
|
165
|
-
|
|
173
|
+
// Downcast selected styles to a figure element instead of a table element.
|
|
174
|
+
if (attributeName === 'htmlTableAttributes' && containerElement !== viewElement) {
|
|
175
|
+
const oldAttributes = splitAttributesForFigureAndTable(data.attributeOldValue);
|
|
176
|
+
const newAttributes = splitAttributesForFigureAndTable(data.attributeNewValue);
|
|
177
|
+
updateViewAttributes(conversionApi.writer, oldAttributes.tableAttributes, newAttributes.tableAttributes, viewElement);
|
|
178
|
+
updateViewAttributes(conversionApi.writer, oldAttributes.figureAttributes, newAttributes.figureAttributes, containerElement);
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
updateViewAttributes(conversionApi.writer, data.attributeOldValue, data.attributeNewValue, viewElement);
|
|
182
|
+
}
|
|
166
183
|
});
|
|
167
184
|
}
|
|
168
185
|
};
|
|
169
186
|
}
|
|
187
|
+
/**
|
|
188
|
+
* Splits styles based on the `STYLE_ATTRIBUTES_TO_PROPAGATE` pattern that should be moved to the parent element
|
|
189
|
+
* and those that should remain on element.
|
|
190
|
+
*/
|
|
191
|
+
function splitAttributesForFigureAndTable(data) {
|
|
192
|
+
const figureAttributes = {};
|
|
193
|
+
const tableAttributes = { ...data };
|
|
194
|
+
if (!data || !('styles' in data)) {
|
|
195
|
+
return { figureAttributes, tableAttributes };
|
|
196
|
+
}
|
|
197
|
+
tableAttributes.styles = {};
|
|
198
|
+
for (const [key, value] of Object.entries(data.styles)) {
|
|
199
|
+
if (STYLE_ATTRIBUTES_TO_PROPAGATE.includes(key)) {
|
|
200
|
+
figureAttributes.styles = { ...figureAttributes.styles, [key]: value };
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
tableAttributes.styles = { ...tableAttributes.styles, [key]: value };
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
return { figureAttributes, tableAttributes };
|
|
207
|
+
}
|
package/src/utils.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
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 { startCase, cloneDeep } from '
|
|
5
|
+
import { startCase, cloneDeep } from 'es-toolkit/compat';
|
|
6
6
|
/**
|
|
7
7
|
* Helper function for the downcast converter. Updates attributes on the given view element.
|
|
8
8
|
*
|