@ckeditor/ckeditor5-html-support 47.6.1 → 48.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.
Files changed (208) hide show
  1. package/LICENSE.md +1 -1
  2. package/ckeditor5-metadata.json +6 -6
  3. package/{src → dist}/converters.d.ts +2 -2
  4. package/{src → dist}/datafilter.d.ts +3 -3
  5. package/{src → dist}/dataschema.d.ts +2 -2
  6. package/{src → dist}/emptyblock.d.ts +1 -1
  7. package/{src → dist}/fullpage.d.ts +1 -1
  8. package/{src → dist}/generalhtmlsupport.d.ts +3 -3
  9. package/{src → dist}/generalhtmlsupportconfig.d.ts +1 -1
  10. package/{src → dist}/htmlcomment.d.ts +2 -2
  11. package/{src → dist}/htmlpagedataprocessor.d.ts +1 -1
  12. package/dist/index-editor.css +29 -29
  13. package/dist/index.css +30 -40
  14. package/dist/index.css.map +1 -1
  15. package/dist/index.js +29 -8
  16. package/dist/index.js.map +1 -1
  17. package/{src → dist}/integrations/codeblock.d.ts +1 -1
  18. package/{src → dist}/integrations/customelement.d.ts +1 -1
  19. package/{src → dist}/integrations/dualcontent.d.ts +1 -1
  20. package/{src → dist}/integrations/heading.d.ts +2 -2
  21. package/{src → dist}/integrations/horizontalline.d.ts +1 -1
  22. package/{src → dist}/integrations/iframe.d.ts +1 -1
  23. package/{src → dist}/integrations/image.d.ts +1 -1
  24. package/{src → dist}/integrations/integrationutils.d.ts +1 -1
  25. package/{src → dist}/integrations/list.d.ts +1 -1
  26. package/{src → dist}/integrations/mediaembed.d.ts +1 -1
  27. package/{src → dist}/integrations/script.d.ts +1 -1
  28. package/{src → dist}/integrations/style.d.ts +1 -1
  29. package/{src → dist}/integrations/table.d.ts +1 -1
  30. package/{src → dist}/schemadefinitions.d.ts +2 -2
  31. package/{src → dist}/utils.d.ts +1 -1
  32. package/package.json +30 -53
  33. package/build/html-support.js +0 -5
  34. package/build/translations/af.js +0 -1
  35. package/build/translations/ar.js +0 -1
  36. package/build/translations/ast.js +0 -1
  37. package/build/translations/az.js +0 -1
  38. package/build/translations/be.js +0 -1
  39. package/build/translations/bg.js +0 -1
  40. package/build/translations/bn.js +0 -1
  41. package/build/translations/bs.js +0 -1
  42. package/build/translations/ca.js +0 -1
  43. package/build/translations/cs.js +0 -1
  44. package/build/translations/da.js +0 -1
  45. package/build/translations/de-ch.js +0 -1
  46. package/build/translations/de.js +0 -1
  47. package/build/translations/el.js +0 -1
  48. package/build/translations/en-au.js +0 -1
  49. package/build/translations/en-gb.js +0 -1
  50. package/build/translations/eo.js +0 -1
  51. package/build/translations/es-co.js +0 -1
  52. package/build/translations/es.js +0 -1
  53. package/build/translations/et.js +0 -1
  54. package/build/translations/eu.js +0 -1
  55. package/build/translations/fa.js +0 -1
  56. package/build/translations/fi.js +0 -1
  57. package/build/translations/fr.js +0 -1
  58. package/build/translations/gl.js +0 -1
  59. package/build/translations/gu.js +0 -1
  60. package/build/translations/he.js +0 -1
  61. package/build/translations/hi.js +0 -1
  62. package/build/translations/hr.js +0 -1
  63. package/build/translations/hu.js +0 -1
  64. package/build/translations/hy.js +0 -1
  65. package/build/translations/id.js +0 -1
  66. package/build/translations/it.js +0 -1
  67. package/build/translations/ja.js +0 -1
  68. package/build/translations/jv.js +0 -1
  69. package/build/translations/kk.js +0 -1
  70. package/build/translations/km.js +0 -1
  71. package/build/translations/kn.js +0 -1
  72. package/build/translations/ko.js +0 -1
  73. package/build/translations/ku.js +0 -1
  74. package/build/translations/lt.js +0 -1
  75. package/build/translations/lv.js +0 -1
  76. package/build/translations/ms.js +0 -1
  77. package/build/translations/nb.js +0 -1
  78. package/build/translations/ne.js +0 -1
  79. package/build/translations/nl.js +0 -1
  80. package/build/translations/no.js +0 -1
  81. package/build/translations/oc.js +0 -1
  82. package/build/translations/pl.js +0 -1
  83. package/build/translations/pt-br.js +0 -1
  84. package/build/translations/pt.js +0 -1
  85. package/build/translations/ro.js +0 -1
  86. package/build/translations/ru.js +0 -1
  87. package/build/translations/si.js +0 -1
  88. package/build/translations/sk.js +0 -1
  89. package/build/translations/sl.js +0 -1
  90. package/build/translations/sq.js +0 -1
  91. package/build/translations/sr-latn.js +0 -1
  92. package/build/translations/sr.js +0 -1
  93. package/build/translations/sv.js +0 -1
  94. package/build/translations/th.js +0 -1
  95. package/build/translations/ti.js +0 -1
  96. package/build/translations/tk.js +0 -1
  97. package/build/translations/tr.js +0 -1
  98. package/build/translations/tt.js +0 -1
  99. package/build/translations/ug.js +0 -1
  100. package/build/translations/uk.js +0 -1
  101. package/build/translations/ur.js +0 -1
  102. package/build/translations/uz.js +0 -1
  103. package/build/translations/vi.js +0 -1
  104. package/build/translations/zh-cn.js +0 -1
  105. package/build/translations/zh.js +0 -1
  106. package/lang/contexts.json +0 -3
  107. package/lang/translations/af.po +0 -16
  108. package/lang/translations/ar.po +0 -16
  109. package/lang/translations/ast.po +0 -16
  110. package/lang/translations/az.po +0 -16
  111. package/lang/translations/be.po +0 -16
  112. package/lang/translations/bg.po +0 -16
  113. package/lang/translations/bn.po +0 -16
  114. package/lang/translations/bs.po +0 -16
  115. package/lang/translations/ca.po +0 -16
  116. package/lang/translations/cs.po +0 -16
  117. package/lang/translations/da.po +0 -16
  118. package/lang/translations/de-ch.po +0 -16
  119. package/lang/translations/de.po +0 -16
  120. package/lang/translations/el.po +0 -16
  121. package/lang/translations/en-au.po +0 -16
  122. package/lang/translations/en-gb.po +0 -16
  123. package/lang/translations/en.po +0 -16
  124. package/lang/translations/eo.po +0 -16
  125. package/lang/translations/es-co.po +0 -16
  126. package/lang/translations/es.po +0 -16
  127. package/lang/translations/et.po +0 -16
  128. package/lang/translations/eu.po +0 -16
  129. package/lang/translations/fa.po +0 -16
  130. package/lang/translations/fi.po +0 -16
  131. package/lang/translations/fr.po +0 -16
  132. package/lang/translations/gl.po +0 -16
  133. package/lang/translations/gu.po +0 -16
  134. package/lang/translations/he.po +0 -16
  135. package/lang/translations/hi.po +0 -16
  136. package/lang/translations/hr.po +0 -16
  137. package/lang/translations/hu.po +0 -16
  138. package/lang/translations/hy.po +0 -16
  139. package/lang/translations/id.po +0 -16
  140. package/lang/translations/it.po +0 -16
  141. package/lang/translations/ja.po +0 -16
  142. package/lang/translations/jv.po +0 -16
  143. package/lang/translations/kk.po +0 -16
  144. package/lang/translations/km.po +0 -16
  145. package/lang/translations/kn.po +0 -16
  146. package/lang/translations/ko.po +0 -16
  147. package/lang/translations/ku.po +0 -16
  148. package/lang/translations/lt.po +0 -16
  149. package/lang/translations/lv.po +0 -16
  150. package/lang/translations/ms.po +0 -16
  151. package/lang/translations/nb.po +0 -16
  152. package/lang/translations/ne.po +0 -16
  153. package/lang/translations/nl.po +0 -16
  154. package/lang/translations/no.po +0 -16
  155. package/lang/translations/oc.po +0 -16
  156. package/lang/translations/pl.po +0 -16
  157. package/lang/translations/pt-br.po +0 -16
  158. package/lang/translations/pt.po +0 -16
  159. package/lang/translations/ro.po +0 -16
  160. package/lang/translations/ru.po +0 -16
  161. package/lang/translations/si.po +0 -16
  162. package/lang/translations/sk.po +0 -16
  163. package/lang/translations/sl.po +0 -16
  164. package/lang/translations/sq.po +0 -16
  165. package/lang/translations/sr-latn.po +0 -16
  166. package/lang/translations/sr.po +0 -16
  167. package/lang/translations/sv.po +0 -16
  168. package/lang/translations/th.po +0 -16
  169. package/lang/translations/ti.po +0 -16
  170. package/lang/translations/tk.po +0 -16
  171. package/lang/translations/tr.po +0 -16
  172. package/lang/translations/tt.po +0 -16
  173. package/lang/translations/ug.po +0 -16
  174. package/lang/translations/uk.po +0 -16
  175. package/lang/translations/ur.po +0 -16
  176. package/lang/translations/uz.po +0 -16
  177. package/lang/translations/vi.po +0 -16
  178. package/lang/translations/zh-cn.po +0 -16
  179. package/lang/translations/zh.po +0 -16
  180. package/src/augmentation.js +0 -5
  181. package/src/converters.js +0 -190
  182. package/src/datafilter.js +0 -837
  183. package/src/dataschema.js +0 -199
  184. package/src/emptyblock.js +0 -146
  185. package/src/fullpage.js +0 -184
  186. package/src/generalhtmlsupport.js +0 -257
  187. package/src/generalhtmlsupportconfig.js +0 -5
  188. package/src/htmlcomment.js +0 -225
  189. package/src/htmlpagedataprocessor.js +0 -70
  190. package/src/index.js +0 -31
  191. package/src/integrations/codeblock.js +0 -107
  192. package/src/integrations/customelement.js +0 -166
  193. package/src/integrations/dualcontent.js +0 -126
  194. package/src/integrations/heading.js +0 -72
  195. package/src/integrations/horizontalline.js +0 -80
  196. package/src/integrations/iframe.js +0 -76
  197. package/src/integrations/image.js +0 -195
  198. package/src/integrations/integrationutils.js +0 -21
  199. package/src/integrations/list.js +0 -185
  200. package/src/integrations/mediaembed.js +0 -125
  201. package/src/integrations/script.js +0 -66
  202. package/src/integrations/style.js +0 -66
  203. package/src/integrations/table.js +0 -209
  204. package/src/schemadefinitions.js +0 -979
  205. package/src/utils.js +0 -169
  206. package/theme/datafilter.css +0 -56
  207. /package/{src → dist}/augmentation.d.ts +0 -0
  208. /package/{src → dist}/index.d.ts +0 -0
@@ -1,195 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2026, 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
- * @module html-support/integrations/image
7
- */
8
- import { Plugin } from 'ckeditor5/src/core.js';
9
- import { DataFilter } from '../datafilter.js';
10
- import { setViewAttributes, updateViewAttributes } from '../utils.js';
11
- import { getDescendantElement } from './integrationutils.js';
12
- /**
13
- * Provides the General HTML Support integration with the {@link module:image/image~Image Image} feature.
14
- */
15
- export class ImageElementSupport extends Plugin {
16
- /**
17
- * @inheritDoc
18
- */
19
- static get requires() {
20
- return [DataFilter];
21
- }
22
- /**
23
- * @inheritDoc
24
- */
25
- static get pluginName() {
26
- return 'ImageElementSupport';
27
- }
28
- /**
29
- * @inheritDoc
30
- */
31
- static get isOfficialPlugin() {
32
- return true;
33
- }
34
- /**
35
- * @inheritDoc
36
- */
37
- init() {
38
- const editor = this.editor;
39
- // At least one image plugin should be loaded for the integration to work properly.
40
- if (!editor.plugins.has('ImageInlineEditing') && !editor.plugins.has('ImageBlockEditing')) {
41
- return;
42
- }
43
- const schema = editor.model.schema;
44
- const conversion = editor.conversion;
45
- const dataFilter = editor.plugins.get(DataFilter);
46
- dataFilter.on('register:figure', () => {
47
- conversion.for('upcast').add(viewToModelFigureAttributeConverter(dataFilter));
48
- });
49
- dataFilter.on('register:img', (evt, definition) => {
50
- if (definition.model !== 'imageBlock' && definition.model !== 'imageInline') {
51
- return;
52
- }
53
- if (schema.isRegistered('imageBlock')) {
54
- schema.extend('imageBlock', {
55
- allowAttributes: [
56
- 'htmlImgAttributes',
57
- // Figure and Link don't have model counterpart.
58
- // We will preserve attributes on image model element using these attribute keys.
59
- 'htmlFigureAttributes',
60
- 'htmlLinkAttributes'
61
- ]
62
- });
63
- }
64
- if (schema.isRegistered('imageInline')) {
65
- schema.extend('imageInline', {
66
- allowAttributes: [
67
- // `htmlA` is needed for standard GHS link integration.
68
- 'htmlA',
69
- 'htmlImgAttributes'
70
- ]
71
- });
72
- }
73
- conversion.for('upcast').add(viewToModelImageAttributeConverter(dataFilter));
74
- conversion.for('downcast').add(modelToViewImageAttributeConverter());
75
- if (editor.plugins.has('LinkImage')) {
76
- conversion.for('upcast').add(viewToModelLinkImageAttributeConverter(dataFilter, editor));
77
- }
78
- evt.stop();
79
- });
80
- }
81
- }
82
- /**
83
- * View-to-model conversion helper preserving allowed attributes on the {@link module:image/image~Image Image}
84
- * feature model element.
85
- *
86
- * @returns Returns a conversion callback.
87
- */
88
- function viewToModelImageAttributeConverter(dataFilter) {
89
- return (dispatcher) => {
90
- dispatcher.on('element:img', (evt, data, conversionApi) => {
91
- if (!data.modelRange) {
92
- return;
93
- }
94
- const viewImageElement = data.viewItem;
95
- const viewAttributes = dataFilter.processViewAttributes(viewImageElement, conversionApi);
96
- if (viewAttributes) {
97
- conversionApi.writer.setAttribute('htmlImgAttributes', viewAttributes, data.modelRange);
98
- }
99
- }, { priority: 'low' });
100
- };
101
- }
102
- /**
103
- * View-to-model conversion helper preserving allowed attributes on {@link module:image/image~Image Image}
104
- * feature model element from link view element.
105
- *
106
- * @returns Returns a conversion callback.
107
- */
108
- function viewToModelLinkImageAttributeConverter(dataFilter, editor) {
109
- const imageUtils = editor.plugins.get('ImageUtils');
110
- return (dispatcher) => {
111
- dispatcher.on('element:a', (evt, data, conversionApi) => {
112
- const viewLink = data.viewItem;
113
- const viewImage = imageUtils.findViewImgElement(viewLink);
114
- if (!viewImage) {
115
- return;
116
- }
117
- const modelImage = data.modelCursor.parent;
118
- if (!modelImage.is('element', 'imageBlock')) {
119
- return;
120
- }
121
- const viewAttributes = dataFilter.processViewAttributes(viewLink, conversionApi);
122
- if (viewAttributes) {
123
- conversionApi.writer.setAttribute('htmlLinkAttributes', viewAttributes, modelImage);
124
- }
125
- }, { priority: 'low' });
126
- };
127
- }
128
- /**
129
- * View-to-model conversion helper preserving allowed attributes on {@link module:image/image~Image Image}
130
- * feature model element from figure view element.
131
- *
132
- * @returns Returns a conversion callback.
133
- */
134
- function viewToModelFigureAttributeConverter(dataFilter) {
135
- return (dispatcher) => {
136
- dispatcher.on('element:figure', (evt, data, conversionApi) => {
137
- const viewFigureElement = data.viewItem;
138
- if (!data.modelRange || !viewFigureElement.hasClass('image')) {
139
- return;
140
- }
141
- const viewAttributes = dataFilter.processViewAttributes(viewFigureElement, conversionApi);
142
- if (viewAttributes) {
143
- conversionApi.writer.setAttribute('htmlFigureAttributes', viewAttributes, data.modelRange);
144
- }
145
- }, { priority: 'low' });
146
- };
147
- }
148
- /**
149
- * A model-to-view conversion helper applying attributes from the {@link module:image/image~Image Image}
150
- * feature.
151
- * @returns Returns a conversion callback.
152
- */
153
- function modelToViewImageAttributeConverter() {
154
- return (dispatcher) => {
155
- addInlineAttributeConversion('htmlImgAttributes');
156
- addBlockAttributeConversion('img', 'htmlImgAttributes');
157
- addBlockAttributeConversion('figure', 'htmlFigureAttributes');
158
- addBlockAttributeConversion('a', 'htmlLinkAttributes');
159
- function addInlineAttributeConversion(attributeName) {
160
- dispatcher.on(`attribute:${attributeName}:imageInline`, (evt, data, conversionApi) => {
161
- if (!conversionApi.consumable.consume(data.item, evt.name)) {
162
- return;
163
- }
164
- const { attributeOldValue, attributeNewValue } = data;
165
- const viewElement = conversionApi.mapper.toViewElement(data.item);
166
- updateViewAttributes(conversionApi.writer, attributeOldValue, attributeNewValue, viewElement);
167
- }, { priority: 'low' });
168
- }
169
- function addBlockAttributeConversion(elementName, attributeName) {
170
- dispatcher.on(`attribute:${attributeName}:imageBlock`, (evt, data, conversionApi) => {
171
- if (!conversionApi.consumable.test(data.item, evt.name)) {
172
- return;
173
- }
174
- const { attributeOldValue, attributeNewValue } = data;
175
- const containerElement = conversionApi.mapper.toViewElement(data.item);
176
- const viewElement = getDescendantElement(conversionApi.writer, containerElement, elementName);
177
- if (viewElement) {
178
- updateViewAttributes(conversionApi.writer, attributeOldValue, attributeNewValue, viewElement);
179
- conversionApi.consumable.consume(data.item, evt.name);
180
- }
181
- }, { priority: 'low' });
182
- if (elementName === 'a') {
183
- // To have a link element in the view, we need to attach a converter to the `linkHref` attribute as well.
184
- dispatcher.on('attribute:linkHref:imageBlock', (evt, data, conversionApi) => {
185
- if (!conversionApi.consumable.consume(data.item, 'attribute:htmlLinkAttributes:imageBlock')) {
186
- return;
187
- }
188
- const containerElement = conversionApi.mapper.toViewElement(data.item);
189
- const viewElement = getDescendantElement(conversionApi.writer, containerElement, 'a');
190
- setViewAttributes(conversionApi.writer, data.item.getAttribute('htmlLinkAttributes'), viewElement);
191
- }, { priority: 'low' });
192
- }
193
- }
194
- };
195
- }
@@ -1,21 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2026, 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
- * @module html-support/integrations/integrationutils
7
- */
8
- /**
9
- * Returns the first view element descendant matching the given view name.
10
- * Includes view element itself.
11
- *
12
- * @internal
13
- */
14
- export function getDescendantElement(writer, containerElement, elementName) {
15
- const range = writer.createRangeOn(containerElement);
16
- for (const { item } of range.getWalker()) {
17
- if (item.is('element', elementName)) {
18
- return item;
19
- }
20
- }
21
- }
@@ -1,185 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2026, 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
- * @module html-support/integrations/list
7
- */
8
- import { isEqual } from 'es-toolkit/compat';
9
- import { Plugin } from 'ckeditor5/src/core.js';
10
- import { getHtmlAttributeName, setViewAttributes } from '../utils.js';
11
- import { DataFilter } from '../datafilter.js';
12
- /**
13
- * Provides the General HTML Support integration with the {@link module:list/list~List List} feature.
14
- */
15
- export class ListElementSupport extends Plugin {
16
- /**
17
- * @inheritDoc
18
- */
19
- static get requires() {
20
- return [DataFilter];
21
- }
22
- /**
23
- * @inheritDoc
24
- */
25
- static get pluginName() {
26
- return 'ListElementSupport';
27
- }
28
- /**
29
- * @inheritDoc
30
- */
31
- static get isOfficialPlugin() {
32
- return true;
33
- }
34
- /**
35
- * @inheritDoc
36
- */
37
- init() {
38
- const editor = this.editor;
39
- if (!editor.plugins.has('ListEditing')) {
40
- return;
41
- }
42
- const schema = editor.model.schema;
43
- const conversion = editor.conversion;
44
- const dataFilter = editor.plugins.get(DataFilter);
45
- const listEditing = editor.plugins.get('ListEditing');
46
- const listUtils = editor.plugins.get('ListUtils');
47
- const viewElements = ['ul', 'ol', 'li'];
48
- // Register downcast strategy.
49
- // Note that this must be done before document list editing registers conversion in afterInit.
50
- listEditing.registerDowncastStrategy({
51
- scope: 'item',
52
- attributeName: 'htmlLiAttributes',
53
- setAttributeOnDowncast: setViewAttributes
54
- });
55
- listEditing.registerDowncastStrategy({
56
- scope: 'list',
57
- attributeName: 'htmlUlAttributes',
58
- setAttributeOnDowncast: setViewAttributes
59
- });
60
- listEditing.registerDowncastStrategy({
61
- scope: 'list',
62
- attributeName: 'htmlOlAttributes',
63
- setAttributeOnDowncast: setViewAttributes
64
- });
65
- dataFilter.on('register', (evt, definition) => {
66
- if (!viewElements.includes(definition.view)) {
67
- return;
68
- }
69
- evt.stop();
70
- // Do not register same converters twice.
71
- if (schema.checkAttribute('$block', 'htmlLiAttributes')) {
72
- return;
73
- }
74
- const allowAttributes = viewElements.map(element => getHtmlAttributeName(element));
75
- schema.extend('$listItem', { allowAttributes });
76
- conversion.for('upcast').add(dispatcher => {
77
- dispatcher.on('element:ul', viewToModelListAttributeConverter('htmlUlAttributes', dataFilter), { priority: 'low' });
78
- dispatcher.on('element:ol', viewToModelListAttributeConverter('htmlOlAttributes', dataFilter), { priority: 'low' });
79
- dispatcher.on('element:li', viewToModelListAttributeConverter('htmlLiAttributes', dataFilter), { priority: 'low' });
80
- });
81
- });
82
- // Make sure that all items in a single list (items at the same level & listType) have the same properties.
83
- listEditing.on('postFixer', (evt, { listNodes, writer }) => {
84
- for (const { node, previousNodeInList } of listNodes) {
85
- // This is a first item of a nested list.
86
- if (!previousNodeInList) {
87
- continue;
88
- }
89
- if (previousNodeInList.getAttribute('listType') == node.getAttribute('listType')) {
90
- const attribute = getAttributeFromListType(previousNodeInList.getAttribute('listType'));
91
- const value = previousNodeInList.getAttribute(attribute);
92
- if (!isEqual(node.getAttribute(attribute), value) &&
93
- writer.model.schema.checkAttribute(node, attribute)) {
94
- writer.setAttribute(attribute, value, node);
95
- evt.return = true;
96
- }
97
- }
98
- if (previousNodeInList.getAttribute('listItemId') == node.getAttribute('listItemId')) {
99
- const value = previousNodeInList.getAttribute('htmlLiAttributes');
100
- if (!isEqual(node.getAttribute('htmlLiAttributes'), value) &&
101
- writer.model.schema.checkAttribute(node, 'htmlLiAttributes')) {
102
- writer.setAttribute('htmlLiAttributes', value, node);
103
- evt.return = true;
104
- }
105
- }
106
- }
107
- });
108
- // Remove `ol` attributes from `ul` elements and vice versa.
109
- listEditing.on('postFixer', (evt, { listNodes, writer }) => {
110
- for (const { node } of listNodes) {
111
- const listType = node.getAttribute('listType');
112
- if (!listUtils.isNumberedListType(listType) && node.getAttribute('htmlOlAttributes')) {
113
- writer.removeAttribute('htmlOlAttributes', node);
114
- evt.return = true;
115
- }
116
- if (listUtils.isNumberedListType(listType) && node.getAttribute('htmlUlAttributes')) {
117
- writer.removeAttribute('htmlUlAttributes', node);
118
- evt.return = true;
119
- }
120
- }
121
- });
122
- }
123
- /**
124
- * @inheritDoc
125
- */
126
- afterInit() {
127
- const editor = this.editor;
128
- if (!editor.commands.get('indentList')) {
129
- return;
130
- }
131
- // Reset list attributes after indenting list items.
132
- const indentList = editor.commands.get('indentList');
133
- this.listenTo(indentList, 'afterExecute', (evt, changedBlocks) => {
134
- editor.model.change(writer => {
135
- for (const node of changedBlocks) {
136
- const attribute = getAttributeFromListType(node.getAttribute('listType'));
137
- if (!editor.model.schema.checkAttribute(node, attribute)) {
138
- continue;
139
- }
140
- // Just reset the attribute.
141
- // If there is a previous indented list that this node should be merged into,
142
- // the postfixer will unify all the attributes of both sub-lists.
143
- writer.setAttribute(attribute, {}, node);
144
- }
145
- });
146
- });
147
- }
148
- }
149
- /**
150
- * View-to-model conversion helper preserving allowed attributes on {@link TODO}
151
- * feature model element.
152
- *
153
- * @returns Returns a conversion callback.
154
- */
155
- function viewToModelListAttributeConverter(attributeName, dataFilter) {
156
- return (evt, data, conversionApi) => {
157
- const viewElement = data.viewItem;
158
- if (!data.modelRange) {
159
- Object.assign(data, conversionApi.convertChildren(data.viewItem, data.modelCursor));
160
- }
161
- const viewAttributes = dataFilter.processViewAttributes(viewElement, conversionApi);
162
- for (const item of data.modelRange.getItems({ shallow: true })) {
163
- // Apply only to list item blocks.
164
- if (!item.hasAttribute('listItemId')) {
165
- continue;
166
- }
167
- // Set list attributes only on same level items, those nested deeper are already handled
168
- // by the recursive conversion.
169
- if (item.hasAttribute('htmlUlAttributes') || item.hasAttribute('htmlOlAttributes')) {
170
- continue;
171
- }
172
- if (conversionApi.writer.model.schema.checkAttribute(item, attributeName)) {
173
- conversionApi.writer.setAttribute(attributeName, viewAttributes || {}, item);
174
- }
175
- }
176
- };
177
- }
178
- /**
179
- * Returns HTML attribute name based on provided list type.
180
- */
181
- function getAttributeFromListType(listType) {
182
- return listType === 'numbered' || listType == 'customNumbered' ?
183
- 'htmlOlAttributes' :
184
- 'htmlUlAttributes';
185
- }
@@ -1,125 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2026, 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
- * @module html-support/integrations/mediaembed
7
- */
8
- import { Plugin } from 'ckeditor5/src/core.js';
9
- import { DataFilter } from '../datafilter.js';
10
- import { DataSchema } from '../dataschema.js';
11
- import { updateViewAttributes, getHtmlAttributeName } from '../utils.js';
12
- import { getDescendantElement } from './integrationutils.js';
13
- /**
14
- * Provides the General HTML Support integration with {@link module:media-embed/mediaembed~MediaEmbed Media Embed} feature.
15
- */
16
- export class MediaEmbedElementSupport extends Plugin {
17
- /**
18
- * @inheritDoc
19
- */
20
- static get requires() {
21
- return [DataFilter];
22
- }
23
- /**
24
- * @inheritDoc
25
- */
26
- static get pluginName() {
27
- return 'MediaEmbedElementSupport';
28
- }
29
- /**
30
- * @inheritDoc
31
- */
32
- static get isOfficialPlugin() {
33
- return true;
34
- }
35
- /**
36
- * @inheritDoc
37
- */
38
- init() {
39
- const editor = this.editor;
40
- // Stop here if MediaEmbed plugin is not provided or the integrator wants to output markup with previews as
41
- // we do not support filtering previews.
42
- if (!editor.plugins.has('MediaEmbed') || editor.config.get('mediaEmbed.previewsInData')) {
43
- return;
44
- }
45
- const schema = editor.model.schema;
46
- const conversion = editor.conversion;
47
- const dataFilter = this.editor.plugins.get(DataFilter);
48
- const dataSchema = this.editor.plugins.get(DataSchema);
49
- const mediaElementName = editor.config.get('mediaEmbed.elementName');
50
- // Overwrite GHS schema definition for a given elementName.
51
- dataSchema.registerBlockElement({
52
- model: 'media',
53
- view: mediaElementName
54
- });
55
- dataFilter.on('register:figure', () => {
56
- conversion.for('upcast').add(viewToModelFigureAttributesConverter(dataFilter));
57
- });
58
- dataFilter.on(`register:${mediaElementName}`, (evt, definition) => {
59
- if (definition.model !== 'media') {
60
- return;
61
- }
62
- schema.extend('media', {
63
- allowAttributes: [
64
- getHtmlAttributeName(mediaElementName),
65
- 'htmlFigureAttributes'
66
- ]
67
- });
68
- conversion.for('upcast').add(viewToModelMediaAttributesConverter(dataFilter, mediaElementName));
69
- conversion.for('dataDowncast').add(modelToViewMediaAttributeConverter(mediaElementName));
70
- evt.stop();
71
- });
72
- }
73
- }
74
- function viewToModelMediaAttributesConverter(dataFilter, mediaElementName) {
75
- const upcastMedia = (evt, data, conversionApi) => {
76
- const viewMediaElement = data.viewItem;
77
- preserveElementAttributes(viewMediaElement, getHtmlAttributeName(mediaElementName));
78
- function preserveElementAttributes(viewElement, attributeName) {
79
- const viewAttributes = dataFilter.processViewAttributes(viewElement, conversionApi);
80
- if (viewAttributes) {
81
- conversionApi.writer.setAttribute(attributeName, viewAttributes, data.modelRange);
82
- }
83
- }
84
- };
85
- return (dispatcher) => {
86
- dispatcher.on(`element:${mediaElementName}`, upcastMedia, { priority: 'low' });
87
- };
88
- }
89
- /**
90
- * View-to-model conversion helper preserving allowed attributes on {@link module:media-embed/mediaembed~MediaEmbed MediaEmbed}
91
- * feature model element from figure view element.
92
- *
93
- * @returns Returns a conversion callback.
94
- */
95
- function viewToModelFigureAttributesConverter(dataFilter) {
96
- return (dispatcher) => {
97
- dispatcher.on('element:figure', (evt, data, conversionApi) => {
98
- const viewFigureElement = data.viewItem;
99
- if (!data.modelRange || !viewFigureElement.hasClass('media')) {
100
- return;
101
- }
102
- const viewAttributes = dataFilter.processViewAttributes(viewFigureElement, conversionApi);
103
- if (viewAttributes) {
104
- conversionApi.writer.setAttribute('htmlFigureAttributes', viewAttributes, data.modelRange);
105
- }
106
- }, { priority: 'low' });
107
- };
108
- }
109
- function modelToViewMediaAttributeConverter(mediaElementName) {
110
- return (dispatcher) => {
111
- addAttributeConversionDispatcherHandler(mediaElementName, getHtmlAttributeName(mediaElementName));
112
- addAttributeConversionDispatcherHandler('figure', 'htmlFigureAttributes');
113
- function addAttributeConversionDispatcherHandler(elementName, attributeName) {
114
- dispatcher.on(`attribute:${attributeName}:media`, (evt, data, conversionApi) => {
115
- if (!conversionApi.consumable.consume(data.item, evt.name)) {
116
- return;
117
- }
118
- const { attributeOldValue, attributeNewValue } = data;
119
- const containerElement = conversionApi.mapper.toViewElement(data.item);
120
- const viewElement = getDescendantElement(conversionApi.writer, containerElement, elementName);
121
- updateViewAttributes(conversionApi.writer, attributeOldValue, attributeNewValue, viewElement);
122
- });
123
- }
124
- };
125
- }
@@ -1,66 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2026, 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
- * @module html-support/integrations/script
7
- */
8
- import { Plugin } from 'ckeditor5/src/core.js';
9
- import { createObjectView, modelToViewBlockAttributeConverter, viewToModelBlockAttributeConverter, viewToModelObjectConverter } from '../converters.js';
10
- import { DataFilter } from '../datafilter.js';
11
- /**
12
- * Provides the General HTML Support for `script` elements.
13
- */
14
- export class ScriptElementSupport extends Plugin {
15
- /**
16
- * @inheritDoc
17
- */
18
- static get requires() {
19
- return [DataFilter];
20
- }
21
- /**
22
- * @inheritDoc
23
- */
24
- static get pluginName() {
25
- return 'ScriptElementSupport';
26
- }
27
- /**
28
- * @inheritDoc
29
- */
30
- static get isOfficialPlugin() {
31
- return true;
32
- }
33
- /**
34
- * @inheritDoc
35
- */
36
- init() {
37
- const dataFilter = this.editor.plugins.get(DataFilter);
38
- dataFilter.on('register:script', (evt, definition) => {
39
- const editor = this.editor;
40
- const schema = editor.model.schema;
41
- const conversion = editor.conversion;
42
- schema.register('htmlScript', definition.modelSchema);
43
- schema.extend('htmlScript', {
44
- allowAttributes: ['htmlScriptAttributes', 'htmlContent'],
45
- isContent: true
46
- });
47
- editor.data.registerRawContentMatcher({
48
- name: 'script'
49
- });
50
- conversion.for('upcast').elementToElement({
51
- view: 'script',
52
- model: viewToModelObjectConverter(definition)
53
- });
54
- conversion.for('upcast').add(viewToModelBlockAttributeConverter(definition, dataFilter));
55
- conversion.for('downcast').elementToElement({
56
- model: 'htmlScript',
57
- view: (modelElement, { writer }) => {
58
- return createObjectView('script', modelElement, writer);
59
- }
60
- });
61
- conversion.for('downcast')
62
- .add(modelToViewBlockAttributeConverter(definition));
63
- evt.stop();
64
- });
65
- }
66
- }
@@ -1,66 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2026, 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
- * @module html-support/integrations/style
7
- */
8
- import { Plugin } from 'ckeditor5/src/core.js';
9
- import { createObjectView, modelToViewBlockAttributeConverter, viewToModelBlockAttributeConverter, viewToModelObjectConverter } from '../converters.js';
10
- import { DataFilter } from '../datafilter.js';
11
- /**
12
- * Provides the General HTML Support for `style` elements.
13
- */
14
- export class StyleElementSupport extends Plugin {
15
- /**
16
- * @inheritDoc
17
- */
18
- static get requires() {
19
- return [DataFilter];
20
- }
21
- /**
22
- * @inheritDoc
23
- */
24
- static get pluginName() {
25
- return 'StyleElementSupport';
26
- }
27
- /**
28
- * @inheritDoc
29
- */
30
- static get isOfficialPlugin() {
31
- return true;
32
- }
33
- /**
34
- * @inheritDoc
35
- */
36
- init() {
37
- const dataFilter = this.editor.plugins.get(DataFilter);
38
- dataFilter.on('register:style', (evt, definition) => {
39
- const editor = this.editor;
40
- const schema = editor.model.schema;
41
- const conversion = editor.conversion;
42
- schema.register('htmlStyle', definition.modelSchema);
43
- schema.extend('htmlStyle', {
44
- allowAttributes: ['htmlStyleAttributes', 'htmlContent'],
45
- isContent: true
46
- });
47
- editor.data.registerRawContentMatcher({
48
- name: 'style'
49
- });
50
- conversion.for('upcast').elementToElement({
51
- view: 'style',
52
- model: viewToModelObjectConverter(definition)
53
- });
54
- conversion.for('upcast').add(viewToModelBlockAttributeConverter(definition, dataFilter));
55
- conversion.for('downcast').elementToElement({
56
- model: 'htmlStyle',
57
- view: (modelElement, { writer }) => {
58
- return createObjectView('style', modelElement, writer);
59
- }
60
- });
61
- conversion.for('downcast')
62
- .add(modelToViewBlockAttributeConverter(definition));
63
- evt.stop();
64
- });
65
- }
66
- }