@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,163 +1,163 @@
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 { updateViewAttributes } from '../utils';
7
- import DataFilter from '../datafilter';
8
- import { getDescendantElement } from './integrationutils';
9
- /**
10
- * Provides the General HTML Support integration with {@link module:table/table~Table Table} feature.
11
- */
12
- export default class TableElementSupport extends Plugin {
13
- /**
14
- * @inheritDoc
15
- */
16
- static get requires() {
17
- return [DataFilter];
18
- }
19
- /**
20
- * @inheritDoc
21
- */
22
- static get pluginName() {
23
- return 'TableElementSupport';
24
- }
25
- /**
26
- * @inheritDoc
27
- */
28
- init() {
29
- const editor = this.editor;
30
- if (!editor.plugins.has('TableEditing')) {
31
- return;
32
- }
33
- const schema = editor.model.schema;
34
- const conversion = editor.conversion;
35
- const dataFilter = editor.plugins.get(DataFilter);
36
- const tableUtils = editor.plugins.get('TableUtils');
37
- dataFilter.on('register:figure', () => {
38
- conversion.for('upcast').add(viewToModelFigureAttributeConverter(dataFilter));
39
- });
40
- dataFilter.on('register:table', (evt, definition) => {
41
- if (definition.model !== 'table') {
42
- return;
43
- }
44
- schema.extend('table', {
45
- allowAttributes: [
46
- 'htmlTableAttributes',
47
- // Figure, thead and tbody elements don't have model counterparts.
48
- // We will be preserving attributes on table element using these attribute keys.
49
- 'htmlFigureAttributes', 'htmlTheadAttributes', 'htmlTbodyAttributes'
50
- ]
51
- });
52
- conversion.for('upcast').add(viewToModelTableAttributeConverter(dataFilter));
53
- conversion.for('downcast').add(modelToViewTableAttributeConverter());
54
- editor.model.document.registerPostFixer(createHeadingRowsPostFixer(editor.model, tableUtils));
55
- evt.stop();
56
- });
57
- }
58
- }
59
- /**
60
- * Creates a model post-fixer for thead and tbody GHS related attributes.
61
- */
62
- function createHeadingRowsPostFixer(model, tableUtils) {
63
- return writer => {
64
- const changes = model.document.differ.getChanges();
65
- let wasFixed = false;
66
- for (const change of changes) {
67
- if (change.type != 'attribute' || change.attributeKey != 'headingRows') {
68
- continue;
69
- }
70
- const table = change.range.start.nodeAfter;
71
- const hasTHeadAttributes = table.getAttribute('htmlTheadAttributes');
72
- const hasTBodyAttributes = table.getAttribute('htmlTbodyAttributes');
73
- if (hasTHeadAttributes && !change.attributeNewValue) {
74
- writer.removeAttribute('htmlTheadAttributes', table);
75
- wasFixed = true;
76
- }
77
- else if (hasTBodyAttributes && change.attributeNewValue == tableUtils.getRows(table)) {
78
- writer.removeAttribute('htmlTbodyAttributes', table);
79
- wasFixed = true;
80
- }
81
- }
82
- return wasFixed;
83
- };
84
- }
85
- /**
86
- * View-to-model conversion helper preserving allowed attributes on {@link module:table/table~Table Table}
87
- * feature model element.
88
- *
89
- * @returns Returns a conversion callback.
90
- */
91
- function viewToModelTableAttributeConverter(dataFilter) {
92
- return (dispatcher) => {
93
- dispatcher.on('element:table', (evt, data, conversionApi) => {
94
- if (!data.modelRange) {
95
- return;
96
- }
97
- const viewTableElement = data.viewItem;
98
- preserveElementAttributes(viewTableElement, 'htmlTableAttributes');
99
- for (const childNode of viewTableElement.getChildren()) {
100
- if (childNode.is('element', 'thead')) {
101
- preserveElementAttributes(childNode, 'htmlTheadAttributes');
102
- }
103
- if (childNode.is('element', 'tbody')) {
104
- preserveElementAttributes(childNode, 'htmlTbodyAttributes');
105
- }
106
- }
107
- function preserveElementAttributes(viewElement, attributeName) {
108
- const viewAttributes = dataFilter.processViewAttributes(viewElement, conversionApi);
109
- if (viewAttributes) {
110
- conversionApi.writer.setAttribute(attributeName, viewAttributes, data.modelRange);
111
- }
112
- }
113
- }, { priority: 'low' });
114
- };
115
- }
116
- /**
117
- * View-to-model conversion helper preserving allowed attributes on {@link module:table/table~Table Table}
118
- * feature model element from figure view element.
119
- *
120
- * @returns Returns a conversion callback.
121
- */
122
- function viewToModelFigureAttributeConverter(dataFilter) {
123
- return (dispatcher) => {
124
- dispatcher.on('element:figure', (evt, data, conversionApi) => {
125
- const viewFigureElement = data.viewItem;
126
- if (!data.modelRange || !viewFigureElement.hasClass('table')) {
127
- return;
128
- }
129
- const viewAttributes = dataFilter.processViewAttributes(viewFigureElement, conversionApi);
130
- if (viewAttributes) {
131
- conversionApi.writer.setAttribute('htmlFigureAttributes', viewAttributes, data.modelRange);
132
- }
133
- }, { priority: 'low' });
134
- };
135
- }
136
- /**
137
- * Model-to-view conversion helper applying attributes from {@link module:table/table~Table Table}
138
- * feature.
139
- *
140
- * @returns Returns a conversion callback.
141
- */
142
- function modelToViewTableAttributeConverter() {
143
- return (dispatcher) => {
144
- addAttributeConversionDispatcherHandler('table', 'htmlTableAttributes');
145
- addAttributeConversionDispatcherHandler('figure', 'htmlFigureAttributes');
146
- addAttributeConversionDispatcherHandler('thead', 'htmlTheadAttributes');
147
- addAttributeConversionDispatcherHandler('tbody', 'htmlTbodyAttributes');
148
- function addAttributeConversionDispatcherHandler(elementName, attributeName) {
149
- dispatcher.on(`attribute:${attributeName}:table`, (evt, data, conversionApi) => {
150
- if (!conversionApi.consumable.test(data.item, evt.name)) {
151
- return;
152
- }
153
- const containerElement = conversionApi.mapper.toViewElement(data.item);
154
- const viewElement = getDescendantElement(conversionApi.writer, containerElement, elementName);
155
- if (!viewElement) {
156
- return;
157
- }
158
- conversionApi.consumable.consume(data.item, evt.name);
159
- updateViewAttributes(conversionApi.writer, data.attributeOldValue, data.attributeNewValue, viewElement);
160
- });
161
- }
162
- };
163
- }
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 { updateViewAttributes } from '../utils';
7
+ import DataFilter from '../datafilter';
8
+ import { getDescendantElement } from './integrationutils';
9
+ /**
10
+ * Provides the General HTML Support integration with {@link module:table/table~Table Table} feature.
11
+ */
12
+ export default class TableElementSupport extends Plugin {
13
+ /**
14
+ * @inheritDoc
15
+ */
16
+ static get requires() {
17
+ return [DataFilter];
18
+ }
19
+ /**
20
+ * @inheritDoc
21
+ */
22
+ static get pluginName() {
23
+ return 'TableElementSupport';
24
+ }
25
+ /**
26
+ * @inheritDoc
27
+ */
28
+ init() {
29
+ const editor = this.editor;
30
+ if (!editor.plugins.has('TableEditing')) {
31
+ return;
32
+ }
33
+ const schema = editor.model.schema;
34
+ const conversion = editor.conversion;
35
+ const dataFilter = editor.plugins.get(DataFilter);
36
+ const tableUtils = editor.plugins.get('TableUtils');
37
+ dataFilter.on('register:figure', () => {
38
+ conversion.for('upcast').add(viewToModelFigureAttributeConverter(dataFilter));
39
+ });
40
+ dataFilter.on('register:table', (evt, definition) => {
41
+ if (definition.model !== 'table') {
42
+ return;
43
+ }
44
+ schema.extend('table', {
45
+ allowAttributes: [
46
+ 'htmlTableAttributes',
47
+ // Figure, thead and tbody elements don't have model counterparts.
48
+ // We will be preserving attributes on table element using these attribute keys.
49
+ 'htmlFigureAttributes', 'htmlTheadAttributes', 'htmlTbodyAttributes'
50
+ ]
51
+ });
52
+ conversion.for('upcast').add(viewToModelTableAttributeConverter(dataFilter));
53
+ conversion.for('downcast').add(modelToViewTableAttributeConverter());
54
+ editor.model.document.registerPostFixer(createHeadingRowsPostFixer(editor.model, tableUtils));
55
+ evt.stop();
56
+ });
57
+ }
58
+ }
59
+ /**
60
+ * Creates a model post-fixer for thead and tbody GHS related attributes.
61
+ */
62
+ function createHeadingRowsPostFixer(model, tableUtils) {
63
+ return writer => {
64
+ const changes = model.document.differ.getChanges();
65
+ let wasFixed = false;
66
+ for (const change of changes) {
67
+ if (change.type != 'attribute' || change.attributeKey != 'headingRows') {
68
+ continue;
69
+ }
70
+ const table = change.range.start.nodeAfter;
71
+ const hasTHeadAttributes = table.getAttribute('htmlTheadAttributes');
72
+ const hasTBodyAttributes = table.getAttribute('htmlTbodyAttributes');
73
+ if (hasTHeadAttributes && !change.attributeNewValue) {
74
+ writer.removeAttribute('htmlTheadAttributes', table);
75
+ wasFixed = true;
76
+ }
77
+ else if (hasTBodyAttributes && change.attributeNewValue == tableUtils.getRows(table)) {
78
+ writer.removeAttribute('htmlTbodyAttributes', table);
79
+ wasFixed = true;
80
+ }
81
+ }
82
+ return wasFixed;
83
+ };
84
+ }
85
+ /**
86
+ * View-to-model conversion helper preserving allowed attributes on {@link module:table/table~Table Table}
87
+ * feature model element.
88
+ *
89
+ * @returns Returns a conversion callback.
90
+ */
91
+ function viewToModelTableAttributeConverter(dataFilter) {
92
+ return (dispatcher) => {
93
+ dispatcher.on('element:table', (evt, data, conversionApi) => {
94
+ if (!data.modelRange) {
95
+ return;
96
+ }
97
+ const viewTableElement = data.viewItem;
98
+ preserveElementAttributes(viewTableElement, 'htmlTableAttributes');
99
+ for (const childNode of viewTableElement.getChildren()) {
100
+ if (childNode.is('element', 'thead')) {
101
+ preserveElementAttributes(childNode, 'htmlTheadAttributes');
102
+ }
103
+ if (childNode.is('element', 'tbody')) {
104
+ preserveElementAttributes(childNode, 'htmlTbodyAttributes');
105
+ }
106
+ }
107
+ function preserveElementAttributes(viewElement, attributeName) {
108
+ const viewAttributes = dataFilter.processViewAttributes(viewElement, conversionApi);
109
+ if (viewAttributes) {
110
+ conversionApi.writer.setAttribute(attributeName, viewAttributes, data.modelRange);
111
+ }
112
+ }
113
+ }, { priority: 'low' });
114
+ };
115
+ }
116
+ /**
117
+ * View-to-model conversion helper preserving allowed attributes on {@link module:table/table~Table Table}
118
+ * feature model element from figure view element.
119
+ *
120
+ * @returns Returns a conversion callback.
121
+ */
122
+ function viewToModelFigureAttributeConverter(dataFilter) {
123
+ return (dispatcher) => {
124
+ dispatcher.on('element:figure', (evt, data, conversionApi) => {
125
+ const viewFigureElement = data.viewItem;
126
+ if (!data.modelRange || !viewFigureElement.hasClass('table')) {
127
+ return;
128
+ }
129
+ const viewAttributes = dataFilter.processViewAttributes(viewFigureElement, conversionApi);
130
+ if (viewAttributes) {
131
+ conversionApi.writer.setAttribute('htmlFigureAttributes', viewAttributes, data.modelRange);
132
+ }
133
+ }, { priority: 'low' });
134
+ };
135
+ }
136
+ /**
137
+ * Model-to-view conversion helper applying attributes from {@link module:table/table~Table Table}
138
+ * feature.
139
+ *
140
+ * @returns Returns a conversion callback.
141
+ */
142
+ function modelToViewTableAttributeConverter() {
143
+ return (dispatcher) => {
144
+ addAttributeConversionDispatcherHandler('table', 'htmlTableAttributes');
145
+ addAttributeConversionDispatcherHandler('figure', 'htmlFigureAttributes');
146
+ addAttributeConversionDispatcherHandler('thead', 'htmlTheadAttributes');
147
+ addAttributeConversionDispatcherHandler('tbody', 'htmlTbodyAttributes');
148
+ function addAttributeConversionDispatcherHandler(elementName, attributeName) {
149
+ dispatcher.on(`attribute:${attributeName}:table`, (evt, data, conversionApi) => {
150
+ if (!conversionApi.consumable.test(data.item, evt.name)) {
151
+ return;
152
+ }
153
+ const containerElement = conversionApi.mapper.toViewElement(data.item);
154
+ const viewElement = getDescendantElement(conversionApi.writer, containerElement, elementName);
155
+ if (!viewElement) {
156
+ return;
157
+ }
158
+ conversionApi.consumable.consume(data.item, evt.name);
159
+ updateViewAttributes(conversionApi.writer, data.attributeOldValue, data.attributeNewValue, viewElement);
160
+ });
161
+ }
162
+ };
163
+ }
@@ -1,13 +1,13 @@
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 type { DataSchemaBlockElementDefinition, DataSchemaInlineElementDefinition } from './dataschema';
6
- /**
7
- * @module html-support/schemadefinitions
8
- */
9
- declare const _default: {
10
- block: DataSchemaBlockElementDefinition[];
11
- inline: DataSchemaInlineElementDefinition[];
12
- };
13
- export default _default;
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 type { DataSchemaBlockElementDefinition, DataSchemaInlineElementDefinition } from './dataschema';
6
+ /**
7
+ * @module html-support/schemadefinitions
8
+ */
9
+ declare const _default: {
10
+ block: DataSchemaBlockElementDefinition[];
11
+ inline: DataSchemaInlineElementDefinition[];
12
+ };
13
+ export default _default;