@ckeditor/ckeditor5-html-support 31.1.0 → 34.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/LICENSE.md +2 -2
- package/README.md +2 -1
- package/build/html-support.js +3 -3
- package/build/html-support.js.map +1 -0
- package/build/translations/cs.js +1 -0
- package/build/translations/el.js +1 -0
- package/build/translations/en-au.js +1 -0
- package/build/translations/hr.js +1 -0
- package/build/translations/jv.js +1 -0
- package/build/translations/sk.js +1 -0
- package/lang/translations/cs.po +21 -0
- package/lang/translations/de.po +1 -1
- package/lang/translations/el.po +21 -0
- package/lang/translations/en-au.po +21 -0
- package/lang/translations/en.po +1 -1
- package/lang/translations/es.po +1 -1
- package/lang/translations/gl.po +1 -1
- package/lang/translations/hr.po +21 -0
- package/lang/translations/hu.po +1 -1
- package/lang/translations/id.po +1 -1
- package/lang/translations/it.po +1 -1
- package/lang/translations/jv.po +21 -0
- package/lang/translations/nl.po +1 -1
- package/lang/translations/pl.po +1 -1
- package/lang/translations/pt-br.po +1 -1
- package/lang/translations/ru.po +1 -1
- package/lang/translations/sk.po +21 -0
- package/lang/translations/sr-latn.po +1 -1
- package/lang/translations/sr.po +1 -1
- package/lang/translations/zh.po +1 -1
- package/package.json +34 -34
- package/src/conversionutils.js +49 -6
- package/src/converters.js +27 -19
- package/src/datafilter.js +17 -7
- package/src/dataschema.js +1 -1
- package/src/generalhtmlsupport.js +234 -2
- package/src/htmlcomment.js +1 -1
- package/src/index.js +1 -1
- package/src/integrations/codeblock.js +6 -4
- package/src/integrations/documentlist.js +200 -0
- package/src/integrations/dualcontent.js +1 -1
- package/src/integrations/heading.js +1 -1
- package/src/integrations/image.js +29 -18
- package/src/integrations/mediaembed.js +4 -3
- package/src/integrations/script.js +74 -0
- package/src/integrations/style.js +74 -0
- package/src/integrations/table.js +1 -1
- package/src/schemadefinitions.js +65 -69
- package/theme/datafilter.css +5 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(c){const i=c.cs=c.cs||{};i.dictionary=Object.assign(i.dictionary||{},{"HTML object":"HTML objekt"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(i){const n=i.el=i.el||{};n.dictionary=Object.assign(n.dictionary||{},{"HTML object":"Αντικείμενο HTML"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(n){const i=n["en-au"]=n["en-au"]||{};i.dictionary=Object.assign(i.dictionary||{},{"HTML object":"HTML object"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(i){const n=i.hr=i.hr||{};n.dictionary=Object.assign(n.dictionary||{},{"HTML object":"HTML objekt"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(i){const n=i.jv=i.jv||{};n.dictionary=Object.assign(n.dictionary||{},{"HTML object":"Obyek HTML"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(i){const n=i.sk=i.sk||{};n.dictionary=Object.assign(n.dictionary||{},{"HTML object":"HTML objekt"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
|
|
2
|
+
#
|
|
3
|
+
# !!! IMPORTANT !!!
|
|
4
|
+
#
|
|
5
|
+
# Before you edit this file, please keep in mind that contributing to the project
|
|
6
|
+
# translations is possible ONLY via the Transifex online service.
|
|
7
|
+
#
|
|
8
|
+
# To submit your translations, visit https://www.transifex.com/ckeditor/ckeditor5.
|
|
9
|
+
#
|
|
10
|
+
# To learn more, check out the official contributor's guide:
|
|
11
|
+
# https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
|
|
12
|
+
#
|
|
13
|
+
msgid ""
|
|
14
|
+
msgstr ""
|
|
15
|
+
"Language-Team: Czech (https://www.transifex.com/ckeditor/teams/11143/cs/)\n"
|
|
16
|
+
"Language: cs\n"
|
|
17
|
+
"Plural-Forms: nplurals=4; plural=(n == 1 && n % 1 == 0) ? 0 : (n >= 2 && n <= 4 && n % 1 == 0) ? 1: (n % 1 != 0 ) ? 2 : 3;\n"
|
|
18
|
+
|
|
19
|
+
msgctxt "A label describing an HTML object widget."
|
|
20
|
+
msgid "HTML object"
|
|
21
|
+
msgstr "HTML objekt"
|
package/lang/translations/de.po
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
|
|
2
|
+
#
|
|
3
|
+
# !!! IMPORTANT !!!
|
|
4
|
+
#
|
|
5
|
+
# Before you edit this file, please keep in mind that contributing to the project
|
|
6
|
+
# translations is possible ONLY via the Transifex online service.
|
|
7
|
+
#
|
|
8
|
+
# To submit your translations, visit https://www.transifex.com/ckeditor/ckeditor5.
|
|
9
|
+
#
|
|
10
|
+
# To learn more, check out the official contributor's guide:
|
|
11
|
+
# https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
|
|
12
|
+
#
|
|
13
|
+
msgid ""
|
|
14
|
+
msgstr ""
|
|
15
|
+
"Language-Team: Greek (https://www.transifex.com/ckeditor/teams/11143/el/)\n"
|
|
16
|
+
"Language: el\n"
|
|
17
|
+
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
|
18
|
+
|
|
19
|
+
msgctxt "A label describing an HTML object widget."
|
|
20
|
+
msgid "HTML object"
|
|
21
|
+
msgstr "Αντικείμενο HTML"
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
|
|
2
|
+
#
|
|
3
|
+
# !!! IMPORTANT !!!
|
|
4
|
+
#
|
|
5
|
+
# Before you edit this file, please keep in mind that contributing to the project
|
|
6
|
+
# translations is possible ONLY via the Transifex online service.
|
|
7
|
+
#
|
|
8
|
+
# To submit your translations, visit https://www.transifex.com/ckeditor/ckeditor5.
|
|
9
|
+
#
|
|
10
|
+
# To learn more, check out the official contributor's guide:
|
|
11
|
+
# https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
|
|
12
|
+
#
|
|
13
|
+
msgid ""
|
|
14
|
+
msgstr ""
|
|
15
|
+
"Language-Team: English (Australia) (https://www.transifex.com/ckeditor/teams/11143/en_AU/)\n"
|
|
16
|
+
"Language: en_AU\n"
|
|
17
|
+
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
|
18
|
+
|
|
19
|
+
msgctxt "A label describing an HTML object widget."
|
|
20
|
+
msgid "HTML object"
|
|
21
|
+
msgstr "HTML object"
|
package/lang/translations/en.po
CHANGED
package/lang/translations/es.po
CHANGED
package/lang/translations/gl.po
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
|
|
2
|
+
#
|
|
3
|
+
# !!! IMPORTANT !!!
|
|
4
|
+
#
|
|
5
|
+
# Before you edit this file, please keep in mind that contributing to the project
|
|
6
|
+
# translations is possible ONLY via the Transifex online service.
|
|
7
|
+
#
|
|
8
|
+
# To submit your translations, visit https://www.transifex.com/ckeditor/ckeditor5.
|
|
9
|
+
#
|
|
10
|
+
# To learn more, check out the official contributor's guide:
|
|
11
|
+
# https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
|
|
12
|
+
#
|
|
13
|
+
msgid ""
|
|
14
|
+
msgstr ""
|
|
15
|
+
"Language-Team: Croatian (https://www.transifex.com/ckeditor/teams/11143/hr/)\n"
|
|
16
|
+
"Language: hr\n"
|
|
17
|
+
"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"
|
|
18
|
+
|
|
19
|
+
msgctxt "A label describing an HTML object widget."
|
|
20
|
+
msgid "HTML object"
|
|
21
|
+
msgstr "HTML objekt"
|
package/lang/translations/hu.po
CHANGED
package/lang/translations/id.po
CHANGED
package/lang/translations/it.po
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
|
|
2
|
+
#
|
|
3
|
+
# !!! IMPORTANT !!!
|
|
4
|
+
#
|
|
5
|
+
# Before you edit this file, please keep in mind that contributing to the project
|
|
6
|
+
# translations is possible ONLY via the Transifex online service.
|
|
7
|
+
#
|
|
8
|
+
# To submit your translations, visit https://www.transifex.com/ckeditor/ckeditor5.
|
|
9
|
+
#
|
|
10
|
+
# To learn more, check out the official contributor's guide:
|
|
11
|
+
# https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
|
|
12
|
+
#
|
|
13
|
+
msgid ""
|
|
14
|
+
msgstr ""
|
|
15
|
+
"Language-Team: Javanese (https://www.transifex.com/ckeditor/teams/11143/jv/)\n"
|
|
16
|
+
"Language: jv\n"
|
|
17
|
+
"Plural-Forms: nplurals=1; plural=0;\n"
|
|
18
|
+
|
|
19
|
+
msgctxt "A label describing an HTML object widget."
|
|
20
|
+
msgid "HTML object"
|
|
21
|
+
msgstr "Obyek HTML"
|
package/lang/translations/nl.po
CHANGED
package/lang/translations/pl.po
CHANGED
package/lang/translations/ru.po
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
|
|
2
|
+
#
|
|
3
|
+
# !!! IMPORTANT !!!
|
|
4
|
+
#
|
|
5
|
+
# Before you edit this file, please keep in mind that contributing to the project
|
|
6
|
+
# translations is possible ONLY via the Transifex online service.
|
|
7
|
+
#
|
|
8
|
+
# To submit your translations, visit https://www.transifex.com/ckeditor/ckeditor5.
|
|
9
|
+
#
|
|
10
|
+
# To learn more, check out the official contributor's guide:
|
|
11
|
+
# https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
|
|
12
|
+
#
|
|
13
|
+
msgid ""
|
|
14
|
+
msgstr ""
|
|
15
|
+
"Language-Team: Slovak (https://www.transifex.com/ckeditor/teams/11143/sk/)\n"
|
|
16
|
+
"Language: sk\n"
|
|
17
|
+
"Plural-Forms: nplurals=4; plural=(n % 1 == 0 && n == 1 ? 0 : n % 1 == 0 && n >= 2 && n <= 4 ? 1 : n % 1 != 0 ? 2: 3);\n"
|
|
18
|
+
|
|
19
|
+
msgctxt "A label describing an HTML object widget."
|
|
20
|
+
msgid "HTML object"
|
|
21
|
+
msgstr "HTML objekt"
|
package/lang/translations/sr.po
CHANGED
package/lang/translations/zh.po
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckeditor/ckeditor5-html-support",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "34.0.0",
|
|
4
4
|
"description": "HTML Support feature for CKEditor 5.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ckeditor",
|
|
@@ -16,44 +16,44 @@
|
|
|
16
16
|
],
|
|
17
17
|
"main": "src/index.js",
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"ckeditor5": "^
|
|
19
|
+
"ckeditor5": "^34.0.0",
|
|
20
20
|
"lodash-es": "^4.17.15"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@ckeditor/ckeditor5-alignment": "^
|
|
24
|
-
"@ckeditor/ckeditor5-basic-styles": "^
|
|
25
|
-
"@ckeditor/ckeditor5-block-quote": "^
|
|
26
|
-
"@ckeditor/ckeditor5-cloud-services": "^
|
|
27
|
-
"@ckeditor/ckeditor5-code-block": "^
|
|
28
|
-
"@ckeditor/ckeditor5-core": "^
|
|
29
|
-
"@ckeditor/ckeditor5-dev-utils": "^
|
|
30
|
-
"@ckeditor/ckeditor5-easy-image": "^
|
|
31
|
-
"@ckeditor/ckeditor5-editor-classic": "^
|
|
32
|
-
"@ckeditor/ckeditor5-engine": "^
|
|
33
|
-
"@ckeditor/ckeditor5-enter": "^
|
|
34
|
-
"@ckeditor/ckeditor5-essentials": "^
|
|
35
|
-
"@ckeditor/ckeditor5-font": "^
|
|
36
|
-
"@ckeditor/ckeditor5-heading": "^
|
|
37
|
-
"@ckeditor/ckeditor5-highlight": "^
|
|
38
|
-
"@ckeditor/ckeditor5-horizontal-line": "^
|
|
39
|
-
"@ckeditor/ckeditor5-html-embed": "^
|
|
40
|
-
"@ckeditor/ckeditor5-image": "^
|
|
41
|
-
"@ckeditor/ckeditor5-indent": "^
|
|
42
|
-
"@ckeditor/ckeditor5-link": "^
|
|
43
|
-
"@ckeditor/ckeditor5-list": "^
|
|
44
|
-
"@ckeditor/ckeditor5-media-embed": "^
|
|
45
|
-
"@ckeditor/ckeditor5-page-break": "^
|
|
46
|
-
"@ckeditor/ckeditor5-paragraph": "^
|
|
47
|
-
"@ckeditor/ckeditor5-paste-from-office": "^
|
|
48
|
-
"@ckeditor/ckeditor5-source-editing": "^
|
|
49
|
-
"@ckeditor/ckeditor5-table": "^
|
|
50
|
-
"@ckeditor/ckeditor5-theme-lark": "^
|
|
51
|
-
"@ckeditor/ckeditor5-utils": "^
|
|
52
|
-
"webpack": "^
|
|
53
|
-
"webpack-cli": "^
|
|
23
|
+
"@ckeditor/ckeditor5-alignment": "^34.0.0",
|
|
24
|
+
"@ckeditor/ckeditor5-basic-styles": "^34.0.0",
|
|
25
|
+
"@ckeditor/ckeditor5-block-quote": "^34.0.0",
|
|
26
|
+
"@ckeditor/ckeditor5-cloud-services": "^34.0.0",
|
|
27
|
+
"@ckeditor/ckeditor5-code-block": "^34.0.0",
|
|
28
|
+
"@ckeditor/ckeditor5-core": "^34.0.0",
|
|
29
|
+
"@ckeditor/ckeditor5-dev-utils": "^30.0.0",
|
|
30
|
+
"@ckeditor/ckeditor5-easy-image": "^34.0.0",
|
|
31
|
+
"@ckeditor/ckeditor5-editor-classic": "^34.0.0",
|
|
32
|
+
"@ckeditor/ckeditor5-engine": "^34.0.0",
|
|
33
|
+
"@ckeditor/ckeditor5-enter": "^34.0.0",
|
|
34
|
+
"@ckeditor/ckeditor5-essentials": "^34.0.0",
|
|
35
|
+
"@ckeditor/ckeditor5-font": "^34.0.0",
|
|
36
|
+
"@ckeditor/ckeditor5-heading": "^34.0.0",
|
|
37
|
+
"@ckeditor/ckeditor5-highlight": "^34.0.0",
|
|
38
|
+
"@ckeditor/ckeditor5-horizontal-line": "^34.0.0",
|
|
39
|
+
"@ckeditor/ckeditor5-html-embed": "^34.0.0",
|
|
40
|
+
"@ckeditor/ckeditor5-image": "^34.0.0",
|
|
41
|
+
"@ckeditor/ckeditor5-indent": "^34.0.0",
|
|
42
|
+
"@ckeditor/ckeditor5-link": "^34.0.0",
|
|
43
|
+
"@ckeditor/ckeditor5-list": "^34.0.0",
|
|
44
|
+
"@ckeditor/ckeditor5-media-embed": "^34.0.0",
|
|
45
|
+
"@ckeditor/ckeditor5-page-break": "^34.0.0",
|
|
46
|
+
"@ckeditor/ckeditor5-paragraph": "^34.0.0",
|
|
47
|
+
"@ckeditor/ckeditor5-paste-from-office": "^34.0.0",
|
|
48
|
+
"@ckeditor/ckeditor5-source-editing": "^34.0.0",
|
|
49
|
+
"@ckeditor/ckeditor5-table": "^34.0.0",
|
|
50
|
+
"@ckeditor/ckeditor5-theme-lark": "^34.0.0",
|
|
51
|
+
"@ckeditor/ckeditor5-utils": "^34.0.0",
|
|
52
|
+
"webpack": "^5.58.1",
|
|
53
|
+
"webpack-cli": "^4.9.0"
|
|
54
54
|
},
|
|
55
55
|
"engines": {
|
|
56
|
-
"node": ">=
|
|
56
|
+
"node": ">=14.0.0",
|
|
57
57
|
"npm": ">=5.7.1"
|
|
58
58
|
},
|
|
59
59
|
"author": "CKSource (http://cksource.com/)",
|
package/src/conversionutils.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2022, 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
5
|
|
|
@@ -10,12 +10,30 @@
|
|
|
10
10
|
import { cloneDeep } from 'lodash-es';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
* Helper function for downcast converter.
|
|
13
|
+
* Helper function for the downcast converter. Updates attributes on the given view element.
|
|
14
14
|
*
|
|
15
|
-
* @param {module:engine/view/downcastwriter~DowncastWriter} writer
|
|
16
|
-
* @param {Object}
|
|
17
|
-
* @param {
|
|
15
|
+
* @param {module:engine/view/downcastwriter~DowncastWriter} writer The view writer.
|
|
16
|
+
* @param {Object} oldViewAttributes The previous GHS attribute value.
|
|
17
|
+
* @param {Object} newViewAttributes The current GHS attribute value.
|
|
18
|
+
* @param {module:engine/view/element~Element} viewElement The view element to update.
|
|
18
19
|
*/
|
|
20
|
+
export function updateViewAttributes( writer, oldViewAttributes, newViewAttributes, viewElement ) {
|
|
21
|
+
if ( oldViewAttributes ) {
|
|
22
|
+
removeViewAttributes( writer, oldViewAttributes, viewElement );
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if ( newViewAttributes ) {
|
|
26
|
+
setViewAttributes( writer, newViewAttributes, viewElement );
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Helper function for the downcast converter. Sets attributes on the given view element.
|
|
32
|
+
*
|
|
33
|
+
* @param {module:engine/view/downcastwriter~DowncastWriter} writer The view writer.
|
|
34
|
+
* @param {Object} viewAttributes The GHS attribute value.
|
|
35
|
+
* @param {module:engine/view/element~Element} viewElement The view element to update.
|
|
36
|
+
*/
|
|
19
37
|
export function setViewAttributes( writer, viewAttributes, viewElement ) {
|
|
20
38
|
if ( viewAttributes.attributes ) {
|
|
21
39
|
for ( const [ key, value ] of Object.entries( viewAttributes.attributes ) ) {
|
|
@@ -32,6 +50,31 @@ export function setViewAttributes( writer, viewAttributes, viewElement ) {
|
|
|
32
50
|
}
|
|
33
51
|
}
|
|
34
52
|
|
|
53
|
+
/**
|
|
54
|
+
* Helper function for the downcast converter. Removes attributes on the given view element.
|
|
55
|
+
*
|
|
56
|
+
* @param {module:engine/view/downcastwriter~DowncastWriter} writer The view writer.
|
|
57
|
+
* @param {Object} viewAttributes The GHS attribute value.
|
|
58
|
+
* @param {module:engine/view/element~Element} viewElement The view element to update.
|
|
59
|
+
*/
|
|
60
|
+
export function removeViewAttributes( writer, viewAttributes, viewElement ) {
|
|
61
|
+
if ( viewAttributes.attributes ) {
|
|
62
|
+
for ( const [ key ] of Object.entries( viewAttributes.attributes ) ) {
|
|
63
|
+
writer.removeAttribute( key, viewElement );
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if ( viewAttributes.styles ) {
|
|
68
|
+
for ( const style of Object.keys( viewAttributes.styles ) ) {
|
|
69
|
+
writer.removeStyle( style, viewElement );
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if ( viewAttributes.classes ) {
|
|
74
|
+
writer.removeClass( viewAttributes.classes, viewElement );
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
35
78
|
/**
|
|
36
79
|
* Merges view element attribute objects.
|
|
37
80
|
*
|
|
@@ -45,7 +88,7 @@ export function mergeViewElementAttributes( target, source ) {
|
|
|
45
88
|
for ( const key in source ) {
|
|
46
89
|
// Merge classes.
|
|
47
90
|
if ( Array.isArray( source[ key ] ) ) {
|
|
48
|
-
result[ key ] = Array.from( new Set( [ ...target[ key ], ...source[ key ] ] ) );
|
|
91
|
+
result[ key ] = Array.from( new Set( [ ...( target[ key ] || [] ), ...source[ key ] ] ) );
|
|
49
92
|
}
|
|
50
93
|
|
|
51
94
|
// Merge attributes or styles.
|
package/src/converters.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2022, 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
5
|
|
|
@@ -8,7 +8,11 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import { toWidget } from 'ckeditor5/src/widget';
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
setViewAttributes,
|
|
13
|
+
mergeViewElementAttributes,
|
|
14
|
+
updateViewAttributes
|
|
15
|
+
} from './conversionutils';
|
|
12
16
|
|
|
13
17
|
/**
|
|
14
18
|
* View-to-model conversion helper for object elements.
|
|
@@ -28,7 +32,7 @@ export function viewToModelObjectConverter( { model: modelName } ) {
|
|
|
28
32
|
}
|
|
29
33
|
|
|
30
34
|
/**
|
|
31
|
-
* Conversion helper converting object element to HTML object widget.
|
|
35
|
+
* Conversion helper converting an object element to an HTML object widget.
|
|
32
36
|
*
|
|
33
37
|
* @param {module:core/editor/editor~Editor} editor
|
|
34
38
|
* @param {module:html-support/dataschema~DataSchemaInlineElementDefinition} definition
|
|
@@ -37,27 +41,27 @@ export function viewToModelObjectConverter( { model: modelName } ) {
|
|
|
37
41
|
export function toObjectWidgetConverter( editor, { view: viewName, isInline } ) {
|
|
38
42
|
const t = editor.t;
|
|
39
43
|
|
|
40
|
-
return ( modelElement, { writer
|
|
44
|
+
return ( modelElement, { writer } ) => {
|
|
41
45
|
const widgetLabel = t( 'HTML object' );
|
|
42
46
|
|
|
43
|
-
// Widget cannot be a raw element because the widget system would not be able
|
|
44
|
-
// to add its UI to it. Thus, we need separate view container.
|
|
45
|
-
const viewContainer = writer.createContainerElement( isInline ? 'span' : 'div', {
|
|
46
|
-
class: 'html-object-embed',
|
|
47
|
-
'data-html-object-embed-label': widgetLabel
|
|
48
|
-
}, {
|
|
49
|
-
isAllowedInsideAttributeElement: isInline
|
|
50
|
-
} );
|
|
51
|
-
|
|
52
47
|
const viewElement = createObjectView( viewName, modelElement, writer );
|
|
48
|
+
const viewAttributes = modelElement.getAttribute( 'htmlAttributes' );
|
|
49
|
+
|
|
53
50
|
writer.addClass( 'html-object-embed__content', viewElement );
|
|
54
51
|
|
|
55
|
-
|
|
56
|
-
if ( viewAttributes && consumable.consume( modelElement, `attribute:htmlAttributes:${ modelElement.name }` ) ) {
|
|
52
|
+
if ( viewAttributes ) {
|
|
57
53
|
setViewAttributes( writer, viewAttributes, viewElement );
|
|
58
54
|
}
|
|
59
55
|
|
|
60
|
-
|
|
56
|
+
// Widget cannot be a raw element because the widget system would not be able
|
|
57
|
+
// to add its UI to it. Thus, we need separate view container.
|
|
58
|
+
const viewContainer = writer.createContainerElement( isInline ? 'span' : 'div',
|
|
59
|
+
{
|
|
60
|
+
class: 'html-object-embed',
|
|
61
|
+
'data-html-object-embed-label': widgetLabel
|
|
62
|
+
},
|
|
63
|
+
viewElement
|
|
64
|
+
);
|
|
61
65
|
|
|
62
66
|
return toWidget( viewContainer, writer, { widgetLabel } );
|
|
63
67
|
};
|
|
@@ -89,6 +93,11 @@ export function viewToAttributeInlineConverter( { view: viewName, model: attribu
|
|
|
89
93
|
dispatcher.on( `element:${ viewName }`, ( evt, data, conversionApi ) => {
|
|
90
94
|
const viewAttributes = dataFilter._consumeAllowedAttributes( data.viewItem, conversionApi );
|
|
91
95
|
|
|
96
|
+
// Do not apply the attribute if the element itself is already consumed and there is no view attributes to store.
|
|
97
|
+
if ( !viewAttributes && !conversionApi.consumable.test( data.viewItem, { name: true } ) ) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
|
|
92
101
|
// Since we are converting to attribute we need a range on which we will set the attribute.
|
|
93
102
|
// If the range is not created yet, we will create it.
|
|
94
103
|
if ( !data.modelRange ) {
|
|
@@ -166,16 +175,15 @@ export function viewToModelBlockAttributeConverter( { view: viewName }, dataFilt
|
|
|
166
175
|
export function modelToViewBlockAttributeConverter( { model: modelName } ) {
|
|
167
176
|
return dispatcher => {
|
|
168
177
|
dispatcher.on( `attribute:htmlAttributes:${ modelName }`, ( evt, data, conversionApi ) => {
|
|
169
|
-
const viewAttributes = data.attributeNewValue;
|
|
170
|
-
|
|
171
178
|
if ( !conversionApi.consumable.consume( data.item, evt.name ) ) {
|
|
172
179
|
return;
|
|
173
180
|
}
|
|
174
181
|
|
|
182
|
+
const { attributeOldValue, attributeNewValue } = data;
|
|
175
183
|
const viewWriter = conversionApi.writer;
|
|
176
184
|
const viewElement = conversionApi.mapper.toViewElement( data.item );
|
|
177
185
|
|
|
178
|
-
|
|
186
|
+
updateViewAttributes( viewWriter, attributeOldValue, attributeNewValue, viewElement );
|
|
179
187
|
} );
|
|
180
188
|
};
|
|
181
189
|
}
|
package/src/datafilter.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2022, 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
5
|
|
|
@@ -240,10 +240,14 @@ export default class DataFilter extends Plugin {
|
|
|
240
240
|
this._fireRegisterEvent( definition );
|
|
241
241
|
}
|
|
242
242
|
}, {
|
|
243
|
-
// With
|
|
244
|
-
// running data conversion.
|
|
245
|
-
//
|
|
246
|
-
|
|
243
|
+
// With highest priority listener we are able to register elements right before
|
|
244
|
+
// running data conversion. Also:
|
|
245
|
+
// * Make sure that priority is higher than the one used by `RealTimeCollaborationClient`,
|
|
246
|
+
// as RTC is stopping event propagation.
|
|
247
|
+
// * Make sure no other features hook into this event before GHS because otherwise the
|
|
248
|
+
// downcast conversion (for these features) could run before GHS registered its converters
|
|
249
|
+
// (https://github.com/ckeditor/ckeditor5/issues/11356).
|
|
250
|
+
priority: priorities.get( 'highest' ) + 1
|
|
247
251
|
} );
|
|
248
252
|
}
|
|
249
253
|
|
|
@@ -308,6 +312,7 @@ export default class DataFilter extends Plugin {
|
|
|
308
312
|
|
|
309
313
|
schema.register( modelName, definition.modelSchema );
|
|
310
314
|
|
|
315
|
+
/* istanbul ignore next: paranoid check */
|
|
311
316
|
if ( !viewName ) {
|
|
312
317
|
return;
|
|
313
318
|
}
|
|
@@ -331,8 +336,13 @@ export default class DataFilter extends Plugin {
|
|
|
331
336
|
} );
|
|
332
337
|
conversion.for( 'upcast' ).add( viewToModelBlockAttributeConverter( definition, this ) );
|
|
333
338
|
|
|
334
|
-
conversion.for( 'editingDowncast' ).
|
|
335
|
-
model:
|
|
339
|
+
conversion.for( 'editingDowncast' ).elementToStructure( {
|
|
340
|
+
model: {
|
|
341
|
+
name: modelName,
|
|
342
|
+
attributes: [
|
|
343
|
+
'htmlAttributes'
|
|
344
|
+
]
|
|
345
|
+
},
|
|
336
346
|
view: toObjectWidgetConverter( editor, definition )
|
|
337
347
|
} );
|
|
338
348
|
|
package/src/dataschema.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2022, 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
5
|
|