@ckeditor/ckeditor5-engine 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 (258) hide show
  1. package/LICENSE.md +1 -1
  2. package/{src → dist}/engineconfig.d.ts +6 -15
  3. package/dist/index-editor.css +38 -15
  4. package/dist/index.css +37 -37
  5. package/dist/index.css.map +1 -1
  6. package/{src → dist}/index.d.ts +0 -1
  7. package/dist/index.js +588 -94
  8. package/dist/index.js.map +1 -1
  9. package/{src → dist}/model/model.d.ts +10 -4
  10. package/{src → dist}/model/selection.d.ts +1 -1
  11. package/{src → dist}/view/downcastwriter.d.ts +3 -2
  12. package/{src → dist}/view/element.d.ts +2 -2
  13. package/{src → dist}/view/matcher.d.ts +4 -2
  14. package/dist/view/styles/background.d.ts +18 -0
  15. package/{src → dist}/view/styles/border.d.ts +0 -12
  16. package/{src → dist}/view/styles/margin.d.ts +0 -13
  17. package/{src → dist}/view/styles/padding.d.ts +0 -13
  18. package/{src → dist}/view/styles/utils.d.ts +12 -0
  19. package/package.json +20 -39
  20. package/src/controller/datacontroller.js +0 -522
  21. package/src/controller/editingcontroller.js +0 -181
  22. package/src/conversion/conversion.js +0 -606
  23. package/src/conversion/conversionhelpers.js +0 -33
  24. package/src/conversion/downcastdispatcher.js +0 -563
  25. package/src/conversion/downcasthelpers.js +0 -2160
  26. package/src/conversion/mapper.js +0 -1050
  27. package/src/conversion/modelconsumable.js +0 -331
  28. package/src/conversion/upcastdispatcher.js +0 -470
  29. package/src/conversion/upcasthelpers.js +0 -952
  30. package/src/conversion/viewconsumable.js +0 -541
  31. package/src/dataprocessor/basichtmlwriter.js +0 -22
  32. package/src/dataprocessor/dataprocessor.js +0 -5
  33. package/src/dataprocessor/htmldataprocessor.js +0 -107
  34. package/src/dataprocessor/htmlwriter.js +0 -5
  35. package/src/dataprocessor/xmldataprocessor.js +0 -127
  36. package/src/dev-utils/model.js +0 -396
  37. package/src/dev-utils/operationreplayer.js +0 -116
  38. package/src/dev-utils/utils.js +0 -122
  39. package/src/dev-utils/view.js +0 -990
  40. package/src/engineconfig.js +0 -5
  41. package/src/index.js +0 -134
  42. package/src/legacyerrors.js +0 -17
  43. package/src/model/batch.js +0 -98
  44. package/src/model/differ.js +0 -1288
  45. package/src/model/document.js +0 -398
  46. package/src/model/documentfragment.js +0 -332
  47. package/src/model/documentselection.js +0 -1026
  48. package/src/model/element.js +0 -323
  49. package/src/model/history.js +0 -206
  50. package/src/model/item.js +0 -5
  51. package/src/model/liveposition.js +0 -93
  52. package/src/model/liverange.js +0 -121
  53. package/src/model/markercollection.js +0 -436
  54. package/src/model/model.js +0 -866
  55. package/src/model/node.js +0 -371
  56. package/src/model/nodelist.js +0 -244
  57. package/src/model/operation/attributeoperation.js +0 -172
  58. package/src/model/operation/detachoperation.js +0 -87
  59. package/src/model/operation/insertoperation.js +0 -153
  60. package/src/model/operation/markeroperation.js +0 -136
  61. package/src/model/operation/mergeoperation.js +0 -184
  62. package/src/model/operation/moveoperation.js +0 -179
  63. package/src/model/operation/nooperation.js +0 -48
  64. package/src/model/operation/operation.js +0 -78
  65. package/src/model/operation/operationfactory.js +0 -44
  66. package/src/model/operation/renameoperation.js +0 -128
  67. package/src/model/operation/rootattributeoperation.js +0 -173
  68. package/src/model/operation/rootoperation.js +0 -106
  69. package/src/model/operation/splitoperation.js +0 -214
  70. package/src/model/operation/transform.js +0 -2211
  71. package/src/model/operation/utils.js +0 -217
  72. package/src/model/position.js +0 -1041
  73. package/src/model/range.js +0 -880
  74. package/src/model/rootelement.js +0 -82
  75. package/src/model/schema.js +0 -1542
  76. package/src/model/selection.js +0 -814
  77. package/src/model/text.js +0 -92
  78. package/src/model/textproxy.js +0 -202
  79. package/src/model/treewalker.js +0 -313
  80. package/src/model/typecheckable.js +0 -16
  81. package/src/model/utils/autoparagraphing.js +0 -63
  82. package/src/model/utils/deletecontent.js +0 -509
  83. package/src/model/utils/getselectedcontent.js +0 -126
  84. package/src/model/utils/insertcontent.js +0 -750
  85. package/src/model/utils/insertobject.js +0 -135
  86. package/src/model/utils/modifyselection.js +0 -187
  87. package/src/model/utils/selection-post-fixer.js +0 -264
  88. package/src/model/writer.js +0 -1318
  89. package/src/view/attributeelement.js +0 -220
  90. package/src/view/containerelement.js +0 -91
  91. package/src/view/datatransfer.js +0 -106
  92. package/src/view/document.js +0 -139
  93. package/src/view/documentfragment.js +0 -251
  94. package/src/view/documentselection.js +0 -270
  95. package/src/view/domconverter.js +0 -1661
  96. package/src/view/downcastwriter.js +0 -1589
  97. package/src/view/editableelement.js +0 -74
  98. package/src/view/element.js +0 -1053
  99. package/src/view/elementdefinition.js +0 -5
  100. package/src/view/emptyelement.js +0 -83
  101. package/src/view/filler.js +0 -161
  102. package/src/view/item.js +0 -5
  103. package/src/view/matcher.js +0 -437
  104. package/src/view/node.js +0 -238
  105. package/src/view/observer/arrowkeysobserver.js +0 -40
  106. package/src/view/observer/bubblingemittermixin.js +0 -215
  107. package/src/view/observer/bubblingeventinfo.js +0 -49
  108. package/src/view/observer/clickobserver.js +0 -26
  109. package/src/view/observer/compositionobserver.js +0 -64
  110. package/src/view/observer/domeventdata.js +0 -63
  111. package/src/view/observer/domeventobserver.js +0 -81
  112. package/src/view/observer/fakeselectionobserver.js +0 -95
  113. package/src/view/observer/focusobserver.js +0 -166
  114. package/src/view/observer/inputobserver.js +0 -236
  115. package/src/view/observer/keyobserver.js +0 -36
  116. package/src/view/observer/mouseobserver.js +0 -26
  117. package/src/view/observer/mutationobserver.js +0 -219
  118. package/src/view/observer/observer.js +0 -92
  119. package/src/view/observer/pointerobserver.js +0 -26
  120. package/src/view/observer/selectionobserver.js +0 -318
  121. package/src/view/observer/tabobserver.js +0 -42
  122. package/src/view/observer/touchobserver.js +0 -26
  123. package/src/view/placeholder.js +0 -285
  124. package/src/view/position.js +0 -341
  125. package/src/view/range.js +0 -451
  126. package/src/view/rawelement.js +0 -115
  127. package/src/view/renderer.js +0 -1148
  128. package/src/view/rooteditableelement.js +0 -78
  129. package/src/view/selection.js +0 -594
  130. package/src/view/styles/background.d.ts +0 -33
  131. package/src/view/styles/background.js +0 -74
  132. package/src/view/styles/border.js +0 -316
  133. package/src/view/styles/margin.js +0 -34
  134. package/src/view/styles/padding.js +0 -34
  135. package/src/view/styles/utils.js +0 -219
  136. package/src/view/stylesmap.js +0 -941
  137. package/src/view/text.js +0 -110
  138. package/src/view/textproxy.js +0 -136
  139. package/src/view/tokenlist.js +0 -194
  140. package/src/view/treewalker.js +0 -389
  141. package/src/view/typecheckable.js +0 -19
  142. package/src/view/uielement.js +0 -194
  143. package/src/view/upcastwriter.js +0 -363
  144. package/src/view/view.js +0 -579
  145. package/theme/placeholder.css +0 -36
  146. package/theme/renderer.css +0 -9
  147. /package/{src → dist}/controller/datacontroller.d.ts +0 -0
  148. /package/{src → dist}/controller/editingcontroller.d.ts +0 -0
  149. /package/{src → dist}/conversion/conversion.d.ts +0 -0
  150. /package/{src → dist}/conversion/conversionhelpers.d.ts +0 -0
  151. /package/{src → dist}/conversion/downcastdispatcher.d.ts +0 -0
  152. /package/{src → dist}/conversion/downcasthelpers.d.ts +0 -0
  153. /package/{src → dist}/conversion/mapper.d.ts +0 -0
  154. /package/{src → dist}/conversion/modelconsumable.d.ts +0 -0
  155. /package/{src → dist}/conversion/upcastdispatcher.d.ts +0 -0
  156. /package/{src → dist}/conversion/upcasthelpers.d.ts +0 -0
  157. /package/{src → dist}/conversion/viewconsumable.d.ts +0 -0
  158. /package/{src → dist}/dataprocessor/basichtmlwriter.d.ts +0 -0
  159. /package/{src → dist}/dataprocessor/dataprocessor.d.ts +0 -0
  160. /package/{src → dist}/dataprocessor/htmldataprocessor.d.ts +0 -0
  161. /package/{src → dist}/dataprocessor/htmlwriter.d.ts +0 -0
  162. /package/{src → dist}/dataprocessor/xmldataprocessor.d.ts +0 -0
  163. /package/{src → dist}/dev-utils/model.d.ts +0 -0
  164. /package/{src → dist}/dev-utils/operationreplayer.d.ts +0 -0
  165. /package/{src → dist}/dev-utils/utils.d.ts +0 -0
  166. /package/{src → dist}/dev-utils/view.d.ts +0 -0
  167. /package/{src → dist}/legacyerrors.d.ts +0 -0
  168. /package/{src → dist}/model/batch.d.ts +0 -0
  169. /package/{src → dist}/model/differ.d.ts +0 -0
  170. /package/{src → dist}/model/document.d.ts +0 -0
  171. /package/{src → dist}/model/documentfragment.d.ts +0 -0
  172. /package/{src → dist}/model/documentselection.d.ts +0 -0
  173. /package/{src → dist}/model/element.d.ts +0 -0
  174. /package/{src → dist}/model/history.d.ts +0 -0
  175. /package/{src → dist}/model/item.d.ts +0 -0
  176. /package/{src → dist}/model/liveposition.d.ts +0 -0
  177. /package/{src → dist}/model/liverange.d.ts +0 -0
  178. /package/{src → dist}/model/markercollection.d.ts +0 -0
  179. /package/{src → dist}/model/node.d.ts +0 -0
  180. /package/{src → dist}/model/nodelist.d.ts +0 -0
  181. /package/{src → dist}/model/operation/attributeoperation.d.ts +0 -0
  182. /package/{src → dist}/model/operation/detachoperation.d.ts +0 -0
  183. /package/{src → dist}/model/operation/insertoperation.d.ts +0 -0
  184. /package/{src → dist}/model/operation/markeroperation.d.ts +0 -0
  185. /package/{src → dist}/model/operation/mergeoperation.d.ts +0 -0
  186. /package/{src → dist}/model/operation/moveoperation.d.ts +0 -0
  187. /package/{src → dist}/model/operation/nooperation.d.ts +0 -0
  188. /package/{src → dist}/model/operation/operation.d.ts +0 -0
  189. /package/{src → dist}/model/operation/operationfactory.d.ts +0 -0
  190. /package/{src → dist}/model/operation/renameoperation.d.ts +0 -0
  191. /package/{src → dist}/model/operation/rootattributeoperation.d.ts +0 -0
  192. /package/{src → dist}/model/operation/rootoperation.d.ts +0 -0
  193. /package/{src → dist}/model/operation/splitoperation.d.ts +0 -0
  194. /package/{src → dist}/model/operation/transform.d.ts +0 -0
  195. /package/{src → dist}/model/operation/utils.d.ts +0 -0
  196. /package/{src → dist}/model/position.d.ts +0 -0
  197. /package/{src → dist}/model/range.d.ts +0 -0
  198. /package/{src → dist}/model/rootelement.d.ts +0 -0
  199. /package/{src → dist}/model/schema.d.ts +0 -0
  200. /package/{src → dist}/model/text.d.ts +0 -0
  201. /package/{src → dist}/model/textproxy.d.ts +0 -0
  202. /package/{src → dist}/model/treewalker.d.ts +0 -0
  203. /package/{src → dist}/model/typecheckable.d.ts +0 -0
  204. /package/{src → dist}/model/utils/autoparagraphing.d.ts +0 -0
  205. /package/{src → dist}/model/utils/deletecontent.d.ts +0 -0
  206. /package/{src → dist}/model/utils/getselectedcontent.d.ts +0 -0
  207. /package/{src → dist}/model/utils/insertcontent.d.ts +0 -0
  208. /package/{src → dist}/model/utils/insertobject.d.ts +0 -0
  209. /package/{src → dist}/model/utils/modifyselection.d.ts +0 -0
  210. /package/{src → dist}/model/utils/selection-post-fixer.d.ts +0 -0
  211. /package/{src → dist}/model/writer.d.ts +0 -0
  212. /package/{src → dist}/view/attributeelement.d.ts +0 -0
  213. /package/{src → dist}/view/containerelement.d.ts +0 -0
  214. /package/{src → dist}/view/datatransfer.d.ts +0 -0
  215. /package/{src → dist}/view/document.d.ts +0 -0
  216. /package/{src → dist}/view/documentfragment.d.ts +0 -0
  217. /package/{src → dist}/view/documentselection.d.ts +0 -0
  218. /package/{src → dist}/view/domconverter.d.ts +0 -0
  219. /package/{src → dist}/view/editableelement.d.ts +0 -0
  220. /package/{src → dist}/view/elementdefinition.d.ts +0 -0
  221. /package/{src → dist}/view/emptyelement.d.ts +0 -0
  222. /package/{src → dist}/view/filler.d.ts +0 -0
  223. /package/{src → dist}/view/item.d.ts +0 -0
  224. /package/{src → dist}/view/node.d.ts +0 -0
  225. /package/{src → dist}/view/observer/arrowkeysobserver.d.ts +0 -0
  226. /package/{src → dist}/view/observer/bubblingemittermixin.d.ts +0 -0
  227. /package/{src → dist}/view/observer/bubblingeventinfo.d.ts +0 -0
  228. /package/{src → dist}/view/observer/clickobserver.d.ts +0 -0
  229. /package/{src → dist}/view/observer/compositionobserver.d.ts +0 -0
  230. /package/{src → dist}/view/observer/domeventdata.d.ts +0 -0
  231. /package/{src → dist}/view/observer/domeventobserver.d.ts +0 -0
  232. /package/{src → dist}/view/observer/fakeselectionobserver.d.ts +0 -0
  233. /package/{src → dist}/view/observer/focusobserver.d.ts +0 -0
  234. /package/{src → dist}/view/observer/inputobserver.d.ts +0 -0
  235. /package/{src → dist}/view/observer/keyobserver.d.ts +0 -0
  236. /package/{src → dist}/view/observer/mouseobserver.d.ts +0 -0
  237. /package/{src → dist}/view/observer/mutationobserver.d.ts +0 -0
  238. /package/{src → dist}/view/observer/observer.d.ts +0 -0
  239. /package/{src → dist}/view/observer/pointerobserver.d.ts +0 -0
  240. /package/{src → dist}/view/observer/selectionobserver.d.ts +0 -0
  241. /package/{src → dist}/view/observer/tabobserver.d.ts +0 -0
  242. /package/{src → dist}/view/observer/touchobserver.d.ts +0 -0
  243. /package/{src → dist}/view/placeholder.d.ts +0 -0
  244. /package/{src → dist}/view/position.d.ts +0 -0
  245. /package/{src → dist}/view/range.d.ts +0 -0
  246. /package/{src → dist}/view/rawelement.d.ts +0 -0
  247. /package/{src → dist}/view/renderer.d.ts +0 -0
  248. /package/{src → dist}/view/rooteditableelement.d.ts +0 -0
  249. /package/{src → dist}/view/selection.d.ts +0 -0
  250. /package/{src → dist}/view/stylesmap.d.ts +0 -0
  251. /package/{src → dist}/view/text.d.ts +0 -0
  252. /package/{src → dist}/view/textproxy.d.ts +0 -0
  253. /package/{src → dist}/view/tokenlist.d.ts +0 -0
  254. /package/{src → dist}/view/treewalker.d.ts +0 -0
  255. /package/{src → dist}/view/typecheckable.d.ts +0 -0
  256. /package/{src → dist}/view/uielement.d.ts +0 -0
  257. /package/{src → dist}/view/upcastwriter.d.ts +0 -0
  258. /package/{src → dist}/view/view.d.ts +0 -0
@@ -1,33 +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 engine/view/styles/background
7
- */
8
- import type { StylesProcessor } from '../stylesmap.js';
9
- /**
10
- * Adds a background CSS styles processing rules.
11
- *
12
- * ```ts
13
- * editor.data.addStyleProcessorRules( addBackgroundStylesRules );
14
- * ```
15
- *
16
- * The normalized value is stored as:
17
- *
18
- * ```ts
19
- * const styles = {
20
- * background: {
21
- * color,
22
- * repeat,
23
- * position,
24
- * attachment,
25
- * image
26
- * }
27
- * };
28
- * ````
29
- *
30
- * **Note**: Currently only `'background-color'` longhand value is parsed besides `'background'` shorthand. The reducer also supports only
31
- * `'background-color'` value.
32
- */
33
- export declare function addBackgroundStylesRules(stylesProcessor: StylesProcessor): void;
@@ -1,74 +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
- import { getShorthandStylesValues, isAttachmentStyleValue, isColorStyleValue, isPositionStyleValue, isRepeatStyleValue, isURLStyleValue } from './utils.js';
6
- /**
7
- * Adds a background CSS styles processing rules.
8
- *
9
- * ```ts
10
- * editor.data.addStyleProcessorRules( addBackgroundStylesRules );
11
- * ```
12
- *
13
- * The normalized value is stored as:
14
- *
15
- * ```ts
16
- * const styles = {
17
- * background: {
18
- * color,
19
- * repeat,
20
- * position,
21
- * attachment,
22
- * image
23
- * }
24
- * };
25
- * ````
26
- *
27
- * **Note**: Currently only `'background-color'` longhand value is parsed besides `'background'` shorthand. The reducer also supports only
28
- * `'background-color'` value.
29
- */
30
- export function addBackgroundStylesRules(stylesProcessor) {
31
- stylesProcessor.setNormalizer('background', getBackgroundNormalizer());
32
- stylesProcessor.setNormalizer('background-color', getBackgroundColorNormalizer());
33
- stylesProcessor.setReducer('background', getBackgroundReducer());
34
- stylesProcessor.setStyleRelation('background', ['background-color']);
35
- }
36
- function getBackgroundNormalizer() {
37
- return value => {
38
- const background = {};
39
- const parts = getShorthandStylesValues(value);
40
- for (const part of parts) {
41
- if (isRepeatStyleValue(part)) {
42
- background.repeat = background.repeat || [];
43
- background.repeat.push(part);
44
- }
45
- else if (isPositionStyleValue(part)) {
46
- background.position = background.position || [];
47
- background.position.push(part);
48
- }
49
- else if (isAttachmentStyleValue(part)) {
50
- background.attachment = part;
51
- }
52
- else if (isColorStyleValue(part)) {
53
- background.color = part;
54
- }
55
- else if (isURLStyleValue(part)) {
56
- background.image = part;
57
- }
58
- }
59
- return {
60
- path: 'background',
61
- value: background
62
- };
63
- };
64
- }
65
- function getBackgroundColorNormalizer() {
66
- return value => ({ path: 'background.color', value });
67
- }
68
- function getBackgroundReducer() {
69
- return value => {
70
- const ret = [];
71
- ret.push(['background-color', value.color]);
72
- return ret;
73
- };
74
- }
@@ -1,316 +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
- import { getShorthandStylesValues, getBoxSidesStyleValueReducer, getBoxSidesStyleValues, isLengthStyleValue, isLineStyleValue } from './utils.js';
6
- /**
7
- * Adds a border CSS styles processing rules.
8
- *
9
- * ```ts
10
- * editor.data.addStyleProcessorRules( addBorderStylesRules );
11
- * ```
12
- *
13
- * This rules merges all [border](https://developer.mozilla.org/en-US/docs/Web/CSS/border) styles notation shorthands:
14
- *
15
- * - border
16
- * - border-top
17
- * - border-right
18
- * - border-bottom
19
- * - border-left
20
- * - border-color
21
- * - border-style
22
- * - border-width
23
- *
24
- * and all corresponding longhand forms (like `border-top-color`, `border-top-style`, etc).
25
- *
26
- * It does not handle other shorthands (like `border-radius` or `border-image`).
27
- *
28
- * The normalized model stores border values as:
29
- *
30
- * ```ts
31
- * const styles = {
32
- * border: {
33
- * color: { top, right, bottom, left },
34
- * style: { top, right, bottom, left },
35
- * width: { top, right, bottom, left },
36
- * }
37
- * };
38
- * ```
39
- */
40
- export function addBorderStylesRules(stylesProcessor) {
41
- stylesProcessor.setNormalizer('border', getBorderNormalizer());
42
- // Border-position shorthands.
43
- stylesProcessor.setNormalizer('border-top', getBorderPositionNormalizer('top'));
44
- stylesProcessor.setNormalizer('border-right', getBorderPositionNormalizer('right'));
45
- stylesProcessor.setNormalizer('border-bottom', getBorderPositionNormalizer('bottom'));
46
- stylesProcessor.setNormalizer('border-left', getBorderPositionNormalizer('left'));
47
- // Border-property shorthands.
48
- stylesProcessor.setNormalizer('border-color', getBorderPropertyNormalizer('color'));
49
- stylesProcessor.setNormalizer('border-width', getBorderPropertyNormalizer('width'));
50
- stylesProcessor.setNormalizer('border-style', getBorderPropertyNormalizer('style'));
51
- // Border longhands.
52
- stylesProcessor.setNormalizer('border-top-color', getBorderPropertyPositionNormalizer('color', 'top'));
53
- stylesProcessor.setNormalizer('border-top-style', getBorderPropertyPositionNormalizer('style', 'top'));
54
- stylesProcessor.setNormalizer('border-top-width', getBorderPropertyPositionNormalizer('width', 'top'));
55
- stylesProcessor.setNormalizer('border-right-color', getBorderPropertyPositionNormalizer('color', 'right'));
56
- stylesProcessor.setNormalizer('border-right-style', getBorderPropertyPositionNormalizer('style', 'right'));
57
- stylesProcessor.setNormalizer('border-right-width', getBorderPropertyPositionNormalizer('width', 'right'));
58
- stylesProcessor.setNormalizer('border-bottom-color', getBorderPropertyPositionNormalizer('color', 'bottom'));
59
- stylesProcessor.setNormalizer('border-bottom-style', getBorderPropertyPositionNormalizer('style', 'bottom'));
60
- stylesProcessor.setNormalizer('border-bottom-width', getBorderPropertyPositionNormalizer('width', 'bottom'));
61
- stylesProcessor.setNormalizer('border-left-color', getBorderPropertyPositionNormalizer('color', 'left'));
62
- stylesProcessor.setNormalizer('border-left-style', getBorderPropertyPositionNormalizer('style', 'left'));
63
- stylesProcessor.setNormalizer('border-left-width', getBorderPropertyPositionNormalizer('width', 'left'));
64
- stylesProcessor.setExtractor('border-top', getBorderPositionExtractor('top'));
65
- stylesProcessor.setExtractor('border-right', getBorderPositionExtractor('right'));
66
- stylesProcessor.setExtractor('border-bottom', getBorderPositionExtractor('bottom'));
67
- stylesProcessor.setExtractor('border-left', getBorderPositionExtractor('left'));
68
- stylesProcessor.setExtractor('border-top-color', 'border.color.top');
69
- stylesProcessor.setExtractor('border-right-color', 'border.color.right');
70
- stylesProcessor.setExtractor('border-bottom-color', 'border.color.bottom');
71
- stylesProcessor.setExtractor('border-left-color', 'border.color.left');
72
- stylesProcessor.setExtractor('border-top-width', 'border.width.top');
73
- stylesProcessor.setExtractor('border-right-width', 'border.width.right');
74
- stylesProcessor.setExtractor('border-bottom-width', 'border.width.bottom');
75
- stylesProcessor.setExtractor('border-left-width', 'border.width.left');
76
- stylesProcessor.setExtractor('border-top-style', 'border.style.top');
77
- stylesProcessor.setExtractor('border-right-style', 'border.style.right');
78
- stylesProcessor.setExtractor('border-bottom-style', 'border.style.bottom');
79
- stylesProcessor.setExtractor('border-left-style', 'border.style.left');
80
- stylesProcessor.setReducer('border-color', getBoxSidesStyleValueReducer('border-color'));
81
- stylesProcessor.setReducer('border-style', getBoxSidesStyleValueReducer('border-style'));
82
- stylesProcessor.setReducer('border-width', getBoxSidesStyleValueReducer('border-width'));
83
- stylesProcessor.setReducer('border-top', getBorderPositionReducer('top'));
84
- stylesProcessor.setReducer('border-right', getBorderPositionReducer('right'));
85
- stylesProcessor.setReducer('border-bottom', getBorderPositionReducer('bottom'));
86
- stylesProcessor.setReducer('border-left', getBorderPositionReducer('left'));
87
- stylesProcessor.setReducer('border', getBorderReducer());
88
- stylesProcessor.setStyleRelation('border', [
89
- 'border-color', 'border-style', 'border-width',
90
- 'border-top', 'border-right', 'border-bottom', 'border-left',
91
- 'border-top-color', 'border-right-color', 'border-bottom-color', 'border-left-color',
92
- 'border-top-style', 'border-right-style', 'border-bottom-style', 'border-left-style',
93
- 'border-top-width', 'border-right-width', 'border-bottom-width', 'border-left-width'
94
- ]);
95
- stylesProcessor.setStyleRelation('border-color', [
96
- 'border-top-color', 'border-right-color', 'border-bottom-color', 'border-left-color'
97
- ]);
98
- stylesProcessor.setStyleRelation('border-style', [
99
- 'border-top-style', 'border-right-style', 'border-bottom-style', 'border-left-style'
100
- ]);
101
- stylesProcessor.setStyleRelation('border-width', [
102
- 'border-top-width', 'border-right-width', 'border-bottom-width', 'border-left-width'
103
- ]);
104
- stylesProcessor.setStyleRelation('border-top', ['border-top-color', 'border-top-style', 'border-top-width']);
105
- stylesProcessor.setStyleRelation('border-right', ['border-right-color', 'border-right-style', 'border-right-width']);
106
- stylesProcessor.setStyleRelation('border-bottom', ['border-bottom-color', 'border-bottom-style', 'border-bottom-width']);
107
- stylesProcessor.setStyleRelation('border-left', ['border-left-color', 'border-left-style', 'border-left-width']);
108
- }
109
- function getBorderNormalizer() {
110
- return value => {
111
- const { color, style, width } = normalizeBorderShorthand(value);
112
- return {
113
- path: 'border',
114
- value: {
115
- color: getBoxSidesStyleValues(color),
116
- style: getBoxSidesStyleValues(style),
117
- width: getBoxSidesStyleValues(width)
118
- }
119
- };
120
- };
121
- }
122
- function getBorderPositionNormalizer(side) {
123
- return value => {
124
- const { color, style, width } = normalizeBorderShorthand(value);
125
- const border = {};
126
- if (color !== undefined) {
127
- border.color = { [side]: color };
128
- }
129
- if (style !== undefined) {
130
- border.style = { [side]: style };
131
- }
132
- if (width !== undefined) {
133
- border.width = { [side]: width };
134
- }
135
- return {
136
- path: 'border',
137
- value: border
138
- };
139
- };
140
- }
141
- function getBorderPropertyNormalizer(propertyName) {
142
- return value => {
143
- return {
144
- path: 'border',
145
- value: toBorderPropertyShorthand(value, propertyName)
146
- };
147
- };
148
- }
149
- function toBorderPropertyShorthand(value, property) {
150
- return {
151
- [property]: getBoxSidesStyleValues(value)
152
- };
153
- }
154
- function getBorderPropertyPositionNormalizer(property, side) {
155
- return value => {
156
- return {
157
- path: 'border',
158
- value: {
159
- [property]: {
160
- [side]: value
161
- }
162
- }
163
- };
164
- };
165
- }
166
- function getBorderPositionExtractor(which) {
167
- return (name, styles) => {
168
- if (styles.border) {
169
- return extractBorderPosition(styles.border, which);
170
- }
171
- };
172
- }
173
- function extractBorderPosition(border, which) {
174
- const value = {};
175
- if (border.width && border.width[which]) {
176
- value.width = border.width[which];
177
- }
178
- if (border.style && border.style[which]) {
179
- value.style = border.style[which];
180
- }
181
- if (border.color && border.color[which]) {
182
- value.color = border.color[which];
183
- }
184
- return value;
185
- }
186
- function normalizeBorderShorthand(string) {
187
- const result = {};
188
- const parts = getShorthandStylesValues(string);
189
- for (const part of parts) {
190
- if (isLengthStyleValue(part) || /thin|medium|thick/.test(part)) {
191
- result.width = part;
192
- }
193
- else if (isLineStyleValue(part)) {
194
- result.style = part;
195
- }
196
- else {
197
- result.color = part;
198
- }
199
- }
200
- return result;
201
- }
202
- /**
203
- * The border reducer factory.
204
- *
205
- * It tries to produce the most optimal output for the specified styles.
206
- *
207
- * For a border style:
208
- *
209
- * ```css
210
- * style: {top: "solid", bottom: "solid", right: "solid", left: "solid"}
211
- * ```
212
- *
213
- * It will produce: `border-style: solid`.
214
- * For a border style and color:
215
- *
216
- * ```css
217
- * color: {top: "#ff0", bottom: "#ff0", right: "#ff0", left: "#ff0"}
218
- * style: {top: "solid", bottom: "solid", right: "solid", left: "solid"}
219
- * ```
220
- *
221
- * It will produce: `border-color: #ff0; border-style: solid`.
222
- * If all border parameters are specified:
223
- *
224
- * ```css
225
- * color: {top: "#ff0", bottom: "#ff0", right: "#ff0", left: "#ff0"}
226
- * style: {top: "solid", bottom: "solid", right: "solid", left: "solid"}
227
- * width: {top: "2px", bottom: "2px", right: "2px", left: "2px"}
228
- * ```
229
- *
230
- * It will combine everything into a single property: `border: 2px solid #ff0`.
231
- *
232
- * The definitions are merged only if all border selectors have the same values.
233
- */
234
- function getBorderReducer() {
235
- return value => {
236
- const topStyles = extractBorderPosition(value, 'top');
237
- const rightStyles = extractBorderPosition(value, 'right');
238
- const bottomStyles = extractBorderPosition(value, 'bottom');
239
- const leftStyles = extractBorderPosition(value, 'left');
240
- const borderStyles = [topStyles, rightStyles, bottomStyles, leftStyles];
241
- const borderStylesByType = {
242
- width: getReducedStyleValueForType(borderStyles, 'width'),
243
- style: getReducedStyleValueForType(borderStyles, 'style'),
244
- color: getReducedStyleValueForType(borderStyles, 'color')
245
- };
246
- // Try reducing to a single `border:` property.
247
- const reducedBorderStyle = reduceBorderPosition(borderStylesByType, 'all');
248
- if (reducedBorderStyle.length) {
249
- return reducedBorderStyle;
250
- }
251
- // Try reducing to `border-style:`, `border-width:`, `border-color:` properties.
252
- const reducedStyleTypes = Object.entries(borderStylesByType).reduce((reducedStyleTypes, [type, value]) => {
253
- if (value) {
254
- reducedStyleTypes.push([`border-${type}`, value]);
255
- // Remove it from the full set to not include it in the most specific properties later.
256
- borderStyles.forEach(style => delete style[type]);
257
- }
258
- return reducedStyleTypes;
259
- }, []);
260
- // The reduced properties (by type) and all that remains that could not be reduced.
261
- return [
262
- ...reducedStyleTypes,
263
- ...reduceBorderPosition(topStyles, 'top'),
264
- ...reduceBorderPosition(rightStyles, 'right'),
265
- ...reduceBorderPosition(bottomStyles, 'bottom'),
266
- ...reduceBorderPosition(leftStyles, 'left')
267
- ];
268
- };
269
- /**
270
- * @param styles The array of objects with `style`, `color`, `width` properties.
271
- */
272
- function getReducedStyleValueForType(styles, type) {
273
- return styles
274
- .map(style => style[type])
275
- .reduce((result, style) => result == style ? result : null);
276
- }
277
- }
278
- function getBorderPositionReducer(which) {
279
- return value => reduceBorderPosition(value, which);
280
- }
281
- /**
282
- * Returns an array with reduced border styles depending on the specified values.
283
- *
284
- * If all border properties (width, style, color) are specified, the returned selector will be
285
- * merged into a group: `border-*: [width] [style] [color]`.
286
- *
287
- * Otherwise, the specific definitions will be returned: `border-(width|style|color)-*: [value]`.
288
- *
289
- * @param value Styles if defined.
290
- * @param which The border position.
291
- */
292
- function reduceBorderPosition(value, which) {
293
- const borderTypes = [];
294
- if (value && (value.width)) {
295
- borderTypes.push('width');
296
- }
297
- if (value && (value.style)) {
298
- borderTypes.push('style');
299
- }
300
- if (value && (value.color)) {
301
- borderTypes.push('color');
302
- }
303
- if (borderTypes.length == 3) {
304
- const borderValue = borderTypes.map(item => value[item]).join(' ');
305
- return [
306
- which == 'all' ? ['border', borderValue] : [`border-${which}`, borderValue]
307
- ];
308
- }
309
- // We are unable to reduce to a single `border:` property.
310
- if (which == 'all') {
311
- return [];
312
- }
313
- return borderTypes.map(type => {
314
- return [`border-${which}-${type}`, value[type]];
315
- });
316
- }
@@ -1,34 +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
- import { getPositionStyleShorthandNormalizer, getBoxSidesStyleValueReducer } from './utils.js';
6
- /**
7
- * Adds a margin CSS styles processing rules.
8
- *
9
- * ```ts
10
- * editor.data.addStyleProcessorRules( addMarginStylesRules );
11
- * ```
12
- *
13
- * The normalized value is stored as:
14
- *
15
- * ```ts
16
- * const styles = {
17
- * margin: {
18
- * top,
19
- * right,
20
- * bottom,
21
- * left
22
- * }
23
- * };
24
- * ```
25
- */
26
- export function addMarginStylesRules(stylesProcessor) {
27
- stylesProcessor.setNormalizer('margin', getPositionStyleShorthandNormalizer('margin'));
28
- stylesProcessor.setNormalizer('margin-top', value => ({ path: 'margin.top', value }));
29
- stylesProcessor.setNormalizer('margin-right', value => ({ path: 'margin.right', value }));
30
- stylesProcessor.setNormalizer('margin-bottom', value => ({ path: 'margin.bottom', value }));
31
- stylesProcessor.setNormalizer('margin-left', value => ({ path: 'margin.left', value }));
32
- stylesProcessor.setReducer('margin', getBoxSidesStyleValueReducer('margin'));
33
- stylesProcessor.setStyleRelation('margin', ['margin-top', 'margin-right', 'margin-bottom', 'margin-left']);
34
- }
@@ -1,34 +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
- import { getPositionStyleShorthandNormalizer, getBoxSidesStyleValueReducer } from './utils.js';
6
- /**
7
- * Adds a padding CSS styles processing rules.
8
- *
9
- * ```ts
10
- * editor.data.addStyleProcessorRules( addPaddingStylesRules );
11
- * ```
12
- *
13
- * The normalized value is stored as:
14
- *
15
- * ```ts
16
- * const styles = {
17
- * padding: {
18
- * top,
19
- * right,
20
- * bottom,
21
- * left
22
- * }
23
- * };
24
- * ```
25
- */
26
- export function addPaddingStylesRules(stylesProcessor) {
27
- stylesProcessor.setNormalizer('padding', getPositionStyleShorthandNormalizer('padding'));
28
- stylesProcessor.setNormalizer('padding-top', value => ({ path: 'padding.top', value }));
29
- stylesProcessor.setNormalizer('padding-right', value => ({ path: 'padding.right', value }));
30
- stylesProcessor.setNormalizer('padding-bottom', value => ({ path: 'padding.bottom', value }));
31
- stylesProcessor.setNormalizer('padding-left', value => ({ path: 'padding.left', value }));
32
- stylesProcessor.setReducer('padding', getBoxSidesStyleValueReducer('padding'));
33
- stylesProcessor.setStyleRelation('padding', ['padding-top', 'padding-right', 'padding-bottom', 'padding-left']);
34
- }