@ckeditor/ckeditor5-html-support 39.0.1 → 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.
Files changed (97) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +3 -3
  3. package/build/html-support.js +1 -1
  4. package/build/html-support.js.map +1 -0
  5. package/lang/translations/ar.po +1 -0
  6. package/lang/translations/bg.po +1 -0
  7. package/lang/translations/bn.po +1 -0
  8. package/lang/translations/ca.po +1 -0
  9. package/lang/translations/cs.po +1 -0
  10. package/lang/translations/da.po +1 -0
  11. package/lang/translations/de.po +1 -0
  12. package/lang/translations/el.po +1 -0
  13. package/lang/translations/en-au.po +1 -0
  14. package/lang/translations/en.po +1 -0
  15. package/lang/translations/es.po +1 -0
  16. package/lang/translations/et.po +1 -0
  17. package/lang/translations/fi.po +1 -0
  18. package/lang/translations/fr.po +1 -0
  19. package/lang/translations/gl.po +1 -0
  20. package/lang/translations/he.po +1 -0
  21. package/lang/translations/hi.po +1 -0
  22. package/lang/translations/hr.po +1 -0
  23. package/lang/translations/hu.po +1 -0
  24. package/lang/translations/id.po +1 -0
  25. package/lang/translations/it.po +1 -0
  26. package/lang/translations/ja.po +1 -0
  27. package/lang/translations/jv.po +1 -0
  28. package/lang/translations/ko.po +1 -0
  29. package/lang/translations/lt.po +1 -0
  30. package/lang/translations/lv.po +1 -0
  31. package/lang/translations/ms.po +1 -0
  32. package/lang/translations/nl.po +1 -0
  33. package/lang/translations/no.po +1 -0
  34. package/lang/translations/pl.po +1 -0
  35. package/lang/translations/pt-br.po +1 -0
  36. package/lang/translations/pt.po +1 -0
  37. package/lang/translations/ro.po +1 -0
  38. package/lang/translations/ru.po +1 -0
  39. package/lang/translations/sk.po +1 -0
  40. package/lang/translations/sr-latn.po +1 -0
  41. package/lang/translations/sr.po +1 -0
  42. package/lang/translations/sv.po +1 -0
  43. package/lang/translations/th.po +1 -0
  44. package/lang/translations/tr.po +1 -0
  45. package/lang/translations/ug.po +1 -0
  46. package/lang/translations/uk.po +1 -0
  47. package/lang/translations/ur.po +1 -0
  48. package/lang/translations/vi.po +1 -0
  49. package/lang/translations/zh-cn.po +1 -0
  50. package/lang/translations/zh.po +1 -0
  51. package/package.json +2 -6
  52. package/src/augmentation.d.ts +33 -33
  53. package/src/augmentation.js +5 -5
  54. package/src/converters.d.ts +60 -60
  55. package/src/converters.js +180 -180
  56. package/src/datafilter.d.ts +304 -304
  57. package/src/datafilter.js +720 -720
  58. package/src/dataschema.d.ts +183 -183
  59. package/src/dataschema.js +196 -196
  60. package/src/fullpage.d.ts +21 -21
  61. package/src/fullpage.js +80 -80
  62. package/src/generalhtmlsupport.d.ts +98 -98
  63. package/src/generalhtmlsupport.js +240 -240
  64. package/src/generalhtmlsupportconfig.d.ts +77 -77
  65. package/src/generalhtmlsupportconfig.js +5 -5
  66. package/src/htmlcomment.d.ts +71 -71
  67. package/src/htmlcomment.js +218 -218
  68. package/src/htmlpagedataprocessor.d.ts +22 -22
  69. package/src/htmlpagedataprocessor.js +67 -67
  70. package/src/index.d.ts +25 -25
  71. package/src/index.js +14 -14
  72. package/src/integrations/codeblock.d.ts +23 -23
  73. package/src/integrations/codeblock.js +101 -101
  74. package/src/integrations/customelement.d.ts +27 -27
  75. package/src/integrations/customelement.js +146 -146
  76. package/src/integrations/documentlist.d.ts +27 -27
  77. package/src/integrations/documentlist.js +178 -203
  78. package/src/integrations/dualcontent.d.ts +45 -45
  79. package/src/integrations/dualcontent.js +119 -119
  80. package/src/integrations/heading.d.ts +31 -31
  81. package/src/integrations/heading.js +60 -60
  82. package/src/integrations/image.d.ts +26 -26
  83. package/src/integrations/image.js +189 -189
  84. package/src/integrations/integrationutils.d.ts +15 -15
  85. package/src/integrations/integrationutils.js +21 -21
  86. package/src/integrations/mediaembed.d.ts +26 -26
  87. package/src/integrations/mediaembed.js +119 -119
  88. package/src/integrations/script.d.ts +26 -26
  89. package/src/integrations/script.js +59 -59
  90. package/src/integrations/style.d.ts +26 -26
  91. package/src/integrations/style.js +59 -59
  92. package/src/integrations/table.d.ts +23 -23
  93. package/src/integrations/table.js +163 -163
  94. package/src/schemadefinitions.d.ts +13 -13
  95. package/src/schemadefinitions.js +956 -956
  96. package/src/utils.d.ts +72 -72
  97. package/src/utils.js +139 -139
@@ -1,146 +1,146 @@
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/customelement
7
- */
8
- /* globals document */
9
- import { Plugin } from 'ckeditor5/src/core';
10
- import { UpcastWriter } from 'ckeditor5/src/engine';
11
- import DataSchema from '../dataschema';
12
- import DataFilter from '../datafilter';
13
- import { setViewAttributes } from '../utils';
14
- /**
15
- * Provides the General HTML Support for custom elements (not registered in the {@link module:html-support/dataschema~DataSchema}).
16
- */
17
- export default class CustomElementSupport extends Plugin {
18
- /**
19
- * @inheritDoc
20
- */
21
- static get requires() {
22
- return [DataFilter, DataSchema];
23
- }
24
- /**
25
- * @inheritDoc
26
- */
27
- static get pluginName() {
28
- return 'CustomElementSupport';
29
- }
30
- /**
31
- * @inheritDoc
32
- */
33
- init() {
34
- const dataFilter = this.editor.plugins.get(DataFilter);
35
- const dataSchema = this.editor.plugins.get(DataSchema);
36
- dataFilter.on('register:$customElement', (evt, definition) => {
37
- evt.stop();
38
- const editor = this.editor;
39
- const schema = editor.model.schema;
40
- const conversion = editor.conversion;
41
- const unsafeElements = editor.editing.view.domConverter.unsafeElements;
42
- const preLikeElements = editor.data.htmlProcessor.domConverter.preElements;
43
- schema.register(definition.model, definition.modelSchema);
44
- schema.extend(definition.model, {
45
- allowAttributes: ['htmlElementName', 'htmlCustomElementAttributes', 'htmlContent'],
46
- isContent: true
47
- });
48
- // Being executed on the low priority, it will catch all elements that were not caught by other converters.
49
- conversion.for('upcast').elementToElement({
50
- view: /.*/,
51
- model: (viewElement, conversionApi) => {
52
- // Do not try to convert $comment fake element.
53
- if (viewElement.name == '$comment') {
54
- return null;
55
- }
56
- if (!isValidElementName(viewElement.name)) {
57
- return null;
58
- }
59
- // Allow for fallback only if this element is not defined in data schema to make sure
60
- // that this will handle only custom elements not registered in the data schema.
61
- if (dataSchema.getDefinitionsForView(viewElement.name).size) {
62
- return null;
63
- }
64
- // Make sure that this element will not render in the editing view.
65
- if (!unsafeElements.includes(viewElement.name)) {
66
- unsafeElements.push(viewElement.name);
67
- }
68
- // Make sure that whitespaces will not be trimmed or replaced by nbsps while stringify content.
69
- if (!preLikeElements.includes(viewElement.name)) {
70
- preLikeElements.push(viewElement.name);
71
- }
72
- const modelElement = conversionApi.writer.createElement(definition.model, {
73
- htmlElementName: viewElement.name
74
- });
75
- const htmlAttributes = dataFilter.processViewAttributes(viewElement, conversionApi);
76
- if (htmlAttributes) {
77
- conversionApi.writer.setAttribute('htmlCustomElementAttributes', htmlAttributes, modelElement);
78
- }
79
- // Store the whole element in the attribute so that DomConverter will be able to use the pre like element context.
80
- const viewWriter = new UpcastWriter(viewElement.document);
81
- const documentFragment = viewWriter.createDocumentFragment(viewElement);
82
- const htmlContent = editor.data.processor.toData(documentFragment);
83
- conversionApi.writer.setAttribute('htmlContent', htmlContent, modelElement);
84
- // Consume the content of the element.
85
- for (const { item } of editor.editing.view.createRangeIn(viewElement)) {
86
- conversionApi.consumable.consume(item, { name: true });
87
- }
88
- return modelElement;
89
- },
90
- converterPriority: 'low'
91
- });
92
- // Because this element is unsafe (DomConverter#unsafeElements), it will render as a transparent <span> but it must
93
- // be rendered anyway for the mapping between the model and the view to exist.
94
- conversion.for('editingDowncast').elementToElement({
95
- model: {
96
- name: definition.model,
97
- attributes: ['htmlElementName', 'htmlCustomElementAttributes', 'htmlContent']
98
- },
99
- view: (modelElement, { writer }) => {
100
- const viewName = modelElement.getAttribute('htmlElementName');
101
- const viewElement = writer.createRawElement(viewName);
102
- if (modelElement.hasAttribute('htmlCustomElementAttributes')) {
103
- setViewAttributes(writer, modelElement.getAttribute('htmlCustomElementAttributes'), viewElement);
104
- }
105
- return viewElement;
106
- }
107
- });
108
- conversion.for('dataDowncast').elementToElement({
109
- model: {
110
- name: definition.model,
111
- attributes: ['htmlElementName', 'htmlCustomElementAttributes', 'htmlContent']
112
- },
113
- view: (modelElement, { writer }) => {
114
- const viewName = modelElement.getAttribute('htmlElementName');
115
- const htmlContent = modelElement.getAttribute('htmlContent');
116
- const viewElement = writer.createRawElement(viewName, null, (domElement, domConverter) => {
117
- domConverter.setContentOf(domElement, htmlContent);
118
- // Unwrap the custom element content (it was stored in the attribute as the whole custom element).
119
- // See the upcast conversion for the "htmlContent" attribute to learn more.
120
- const customElement = domElement.firstChild;
121
- customElement.remove();
122
- while (customElement.firstChild) {
123
- domElement.appendChild(customElement.firstChild);
124
- }
125
- });
126
- if (modelElement.hasAttribute('htmlCustomElementAttributes')) {
127
- setViewAttributes(writer, modelElement.getAttribute('htmlCustomElementAttributes'), viewElement);
128
- }
129
- return viewElement;
130
- }
131
- });
132
- });
133
- }
134
- }
135
- /**
136
- * Returns true if name is valid for a DOM element name.
137
- */
138
- function isValidElementName(name) {
139
- try {
140
- document.createElement(name);
141
- }
142
- catch (error) {
143
- return false;
144
- }
145
- return true;
146
- }
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/customelement
7
+ */
8
+ /* globals document */
9
+ import { Plugin } from 'ckeditor5/src/core';
10
+ import { UpcastWriter } from 'ckeditor5/src/engine';
11
+ import DataSchema from '../dataschema';
12
+ import DataFilter from '../datafilter';
13
+ import { setViewAttributes } from '../utils';
14
+ /**
15
+ * Provides the General HTML Support for custom elements (not registered in the {@link module:html-support/dataschema~DataSchema}).
16
+ */
17
+ export default class CustomElementSupport extends Plugin {
18
+ /**
19
+ * @inheritDoc
20
+ */
21
+ static get requires() {
22
+ return [DataFilter, DataSchema];
23
+ }
24
+ /**
25
+ * @inheritDoc
26
+ */
27
+ static get pluginName() {
28
+ return 'CustomElementSupport';
29
+ }
30
+ /**
31
+ * @inheritDoc
32
+ */
33
+ init() {
34
+ const dataFilter = this.editor.plugins.get(DataFilter);
35
+ const dataSchema = this.editor.plugins.get(DataSchema);
36
+ dataFilter.on('register:$customElement', (evt, definition) => {
37
+ evt.stop();
38
+ const editor = this.editor;
39
+ const schema = editor.model.schema;
40
+ const conversion = editor.conversion;
41
+ const unsafeElements = editor.editing.view.domConverter.unsafeElements;
42
+ const preLikeElements = editor.data.htmlProcessor.domConverter.preElements;
43
+ schema.register(definition.model, definition.modelSchema);
44
+ schema.extend(definition.model, {
45
+ allowAttributes: ['htmlElementName', 'htmlCustomElementAttributes', 'htmlContent'],
46
+ isContent: true
47
+ });
48
+ // Being executed on the low priority, it will catch all elements that were not caught by other converters.
49
+ conversion.for('upcast').elementToElement({
50
+ view: /.*/,
51
+ model: (viewElement, conversionApi) => {
52
+ // Do not try to convert $comment fake element.
53
+ if (viewElement.name == '$comment') {
54
+ return null;
55
+ }
56
+ if (!isValidElementName(viewElement.name)) {
57
+ return null;
58
+ }
59
+ // Allow for fallback only if this element is not defined in data schema to make sure
60
+ // that this will handle only custom elements not registered in the data schema.
61
+ if (dataSchema.getDefinitionsForView(viewElement.name).size) {
62
+ return null;
63
+ }
64
+ // Make sure that this element will not render in the editing view.
65
+ if (!unsafeElements.includes(viewElement.name)) {
66
+ unsafeElements.push(viewElement.name);
67
+ }
68
+ // Make sure that whitespaces will not be trimmed or replaced by nbsps while stringify content.
69
+ if (!preLikeElements.includes(viewElement.name)) {
70
+ preLikeElements.push(viewElement.name);
71
+ }
72
+ const modelElement = conversionApi.writer.createElement(definition.model, {
73
+ htmlElementName: viewElement.name
74
+ });
75
+ const htmlAttributes = dataFilter.processViewAttributes(viewElement, conversionApi);
76
+ if (htmlAttributes) {
77
+ conversionApi.writer.setAttribute('htmlCustomElementAttributes', htmlAttributes, modelElement);
78
+ }
79
+ // Store the whole element in the attribute so that DomConverter will be able to use the pre like element context.
80
+ const viewWriter = new UpcastWriter(viewElement.document);
81
+ const documentFragment = viewWriter.createDocumentFragment(viewElement);
82
+ const htmlContent = editor.data.processor.toData(documentFragment);
83
+ conversionApi.writer.setAttribute('htmlContent', htmlContent, modelElement);
84
+ // Consume the content of the element.
85
+ for (const { item } of editor.editing.view.createRangeIn(viewElement)) {
86
+ conversionApi.consumable.consume(item, { name: true });
87
+ }
88
+ return modelElement;
89
+ },
90
+ converterPriority: 'low'
91
+ });
92
+ // Because this element is unsafe (DomConverter#unsafeElements), it will render as a transparent <span> but it must
93
+ // be rendered anyway for the mapping between the model and the view to exist.
94
+ conversion.for('editingDowncast').elementToElement({
95
+ model: {
96
+ name: definition.model,
97
+ attributes: ['htmlElementName', 'htmlCustomElementAttributes', 'htmlContent']
98
+ },
99
+ view: (modelElement, { writer }) => {
100
+ const viewName = modelElement.getAttribute('htmlElementName');
101
+ const viewElement = writer.createRawElement(viewName);
102
+ if (modelElement.hasAttribute('htmlCustomElementAttributes')) {
103
+ setViewAttributes(writer, modelElement.getAttribute('htmlCustomElementAttributes'), viewElement);
104
+ }
105
+ return viewElement;
106
+ }
107
+ });
108
+ conversion.for('dataDowncast').elementToElement({
109
+ model: {
110
+ name: definition.model,
111
+ attributes: ['htmlElementName', 'htmlCustomElementAttributes', 'htmlContent']
112
+ },
113
+ view: (modelElement, { writer }) => {
114
+ const viewName = modelElement.getAttribute('htmlElementName');
115
+ const htmlContent = modelElement.getAttribute('htmlContent');
116
+ const viewElement = writer.createRawElement(viewName, null, (domElement, domConverter) => {
117
+ domConverter.setContentOf(domElement, htmlContent);
118
+ // Unwrap the custom element content (it was stored in the attribute as the whole custom element).
119
+ // See the upcast conversion for the "htmlContent" attribute to learn more.
120
+ const customElement = domElement.firstChild;
121
+ customElement.remove();
122
+ while (customElement.firstChild) {
123
+ domElement.appendChild(customElement.firstChild);
124
+ }
125
+ });
126
+ if (modelElement.hasAttribute('htmlCustomElementAttributes')) {
127
+ setViewAttributes(writer, modelElement.getAttribute('htmlCustomElementAttributes'), viewElement);
128
+ }
129
+ return viewElement;
130
+ }
131
+ });
132
+ });
133
+ }
134
+ }
135
+ /**
136
+ * Returns true if name is valid for a DOM element name.
137
+ */
138
+ function isValidElementName(name) {
139
+ try {
140
+ document.createElement(name);
141
+ }
142
+ catch (error) {
143
+ return false;
144
+ }
145
+ return true;
146
+ }
@@ -1,27 +1,27 @@
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 DataFilter from '../datafilter';
7
- /**
8
- * Provides the General HTML Support integration with the {@link module:list/documentlist~DocumentList Document List} feature.
9
- */
10
- export default class DocumentListElementSupport extends Plugin {
11
- /**
12
- * @inheritDoc
13
- */
14
- static get requires(): readonly [typeof DataFilter];
15
- /**
16
- * @inheritDoc
17
- */
18
- static get pluginName(): "DocumentListElementSupport";
19
- /**
20
- * @inheritDoc
21
- */
22
- init(): void;
23
- /**
24
- * @inheritDoc
25
- */
26
- afterInit(): void;
27
- }
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 DataFilter from '../datafilter';
7
+ /**
8
+ * Provides the General HTML Support integration with the {@link module:list/documentlist~DocumentList Document List} feature.
9
+ */
10
+ export default class DocumentListElementSupport extends Plugin {
11
+ /**
12
+ * @inheritDoc
13
+ */
14
+ static get requires(): readonly [typeof DataFilter];
15
+ /**
16
+ * @inheritDoc
17
+ */
18
+ static get pluginName(): "DocumentListElementSupport";
19
+ /**
20
+ * @inheritDoc
21
+ */
22
+ init(): void;
23
+ /**
24
+ * @inheritDoc
25
+ */
26
+ afterInit(): void;
27
+ }