@ckeditor/ckeditor5-engine 35.0.1 → 35.1.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 (124) hide show
  1. package/CHANGELOG.md +4 -4
  2. package/package.json +30 -24
  3. package/src/controller/datacontroller.js +467 -561
  4. package/src/controller/editingcontroller.js +168 -204
  5. package/src/conversion/conversion.js +541 -565
  6. package/src/conversion/conversionhelpers.js +24 -28
  7. package/src/conversion/downcastdispatcher.js +457 -686
  8. package/src/conversion/downcasthelpers.js +1583 -1965
  9. package/src/conversion/mapper.js +518 -707
  10. package/src/conversion/modelconsumable.js +240 -283
  11. package/src/conversion/upcastdispatcher.js +372 -718
  12. package/src/conversion/upcasthelpers.js +707 -818
  13. package/src/conversion/viewconsumable.js +524 -581
  14. package/src/dataprocessor/basichtmlwriter.js +12 -16
  15. package/src/dataprocessor/dataprocessor.js +5 -0
  16. package/src/dataprocessor/htmldataprocessor.js +100 -116
  17. package/src/dataprocessor/htmlwriter.js +1 -18
  18. package/src/dataprocessor/xmldataprocessor.js +116 -137
  19. package/src/dev-utils/model.js +260 -352
  20. package/src/dev-utils/operationreplayer.js +106 -126
  21. package/src/dev-utils/utils.js +34 -51
  22. package/src/dev-utils/view.js +632 -753
  23. package/src/index.js +0 -11
  24. package/src/model/batch.js +111 -127
  25. package/src/model/differ.js +988 -1233
  26. package/src/model/document.js +340 -449
  27. package/src/model/documentfragment.js +327 -364
  28. package/src/model/documentselection.js +996 -1189
  29. package/src/model/element.js +306 -410
  30. package/src/model/history.js +224 -262
  31. package/src/model/item.js +5 -0
  32. package/src/model/liveposition.js +84 -145
  33. package/src/model/liverange.js +108 -185
  34. package/src/model/markercollection.js +379 -480
  35. package/src/model/model.js +883 -1034
  36. package/src/model/node.js +419 -463
  37. package/src/model/nodelist.js +175 -201
  38. package/src/model/operation/attributeoperation.js +153 -182
  39. package/src/model/operation/detachoperation.js +64 -83
  40. package/src/model/operation/insertoperation.js +135 -166
  41. package/src/model/operation/markeroperation.js +114 -140
  42. package/src/model/operation/mergeoperation.js +163 -191
  43. package/src/model/operation/moveoperation.js +157 -187
  44. package/src/model/operation/nooperation.js +28 -38
  45. package/src/model/operation/operation.js +106 -125
  46. package/src/model/operation/operationfactory.js +30 -34
  47. package/src/model/operation/renameoperation.js +109 -135
  48. package/src/model/operation/rootattributeoperation.js +155 -188
  49. package/src/model/operation/splitoperation.js +196 -232
  50. package/src/model/operation/transform.js +1833 -2204
  51. package/src/model/operation/utils.js +140 -204
  52. package/src/model/position.js +899 -1053
  53. package/src/model/range.js +910 -1028
  54. package/src/model/rootelement.js +77 -97
  55. package/src/model/schema.js +1189 -1835
  56. package/src/model/selection.js +745 -862
  57. package/src/model/text.js +90 -114
  58. package/src/model/textproxy.js +204 -240
  59. package/src/model/treewalker.js +316 -397
  60. package/src/model/typecheckable.js +16 -0
  61. package/src/model/utils/autoparagraphing.js +32 -44
  62. package/src/model/utils/deletecontent.js +334 -418
  63. package/src/model/utils/findoptimalinsertionrange.js +25 -36
  64. package/src/model/utils/getselectedcontent.js +96 -118
  65. package/src/model/utils/insertcontent.js +654 -773
  66. package/src/model/utils/insertobject.js +96 -119
  67. package/src/model/utils/modifyselection.js +120 -158
  68. package/src/model/utils/selection-post-fixer.js +153 -201
  69. package/src/model/writer.js +1305 -1474
  70. package/src/view/attributeelement.js +189 -225
  71. package/src/view/containerelement.js +75 -85
  72. package/src/view/document.js +172 -215
  73. package/src/view/documentfragment.js +200 -249
  74. package/src/view/documentselection.js +338 -367
  75. package/src/view/domconverter.js +1370 -1617
  76. package/src/view/downcastwriter.js +1747 -2076
  77. package/src/view/editableelement.js +81 -97
  78. package/src/view/element.js +739 -890
  79. package/src/view/elementdefinition.js +5 -0
  80. package/src/view/emptyelement.js +82 -92
  81. package/src/view/filler.js +35 -50
  82. package/src/view/item.js +5 -0
  83. package/src/view/matcher.js +260 -559
  84. package/src/view/node.js +274 -360
  85. package/src/view/observer/arrowkeysobserver.js +19 -28
  86. package/src/view/observer/bubblingemittermixin.js +120 -263
  87. package/src/view/observer/bubblingeventinfo.js +47 -55
  88. package/src/view/observer/clickobserver.js +7 -13
  89. package/src/view/observer/compositionobserver.js +14 -24
  90. package/src/view/observer/domeventdata.js +57 -67
  91. package/src/view/observer/domeventobserver.js +40 -64
  92. package/src/view/observer/fakeselectionobserver.js +81 -96
  93. package/src/view/observer/focusobserver.js +45 -61
  94. package/src/view/observer/inputobserver.js +7 -13
  95. package/src/view/observer/keyobserver.js +17 -27
  96. package/src/view/observer/mouseobserver.js +7 -14
  97. package/src/view/observer/mutationobserver.js +220 -315
  98. package/src/view/observer/observer.js +81 -102
  99. package/src/view/observer/selectionobserver.js +191 -246
  100. package/src/view/observer/tabobserver.js +23 -36
  101. package/src/view/placeholder.js +128 -173
  102. package/src/view/position.js +350 -401
  103. package/src/view/range.js +453 -513
  104. package/src/view/rawelement.js +85 -112
  105. package/src/view/renderer.js +874 -1018
  106. package/src/view/rooteditableelement.js +80 -90
  107. package/src/view/selection.js +608 -689
  108. package/src/view/styles/background.js +43 -44
  109. package/src/view/styles/border.js +220 -276
  110. package/src/view/styles/margin.js +8 -17
  111. package/src/view/styles/padding.js +8 -16
  112. package/src/view/styles/utils.js +127 -160
  113. package/src/view/stylesmap.js +728 -905
  114. package/src/view/text.js +102 -126
  115. package/src/view/textproxy.js +144 -170
  116. package/src/view/treewalker.js +383 -479
  117. package/src/view/typecheckable.js +19 -0
  118. package/src/view/uielement.js +166 -187
  119. package/src/view/upcastwriter.js +395 -449
  120. package/src/view/view.js +569 -664
  121. package/src/dataprocessor/dataprocessor.jsdoc +0 -64
  122. package/src/model/item.jsdoc +0 -14
  123. package/src/view/elementdefinition.jsdoc +0 -59
  124. package/src/view/item.jsdoc +0 -14
@@ -2,13 +2,7 @@
2
2
  * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
-
6
- /**
7
- * @module engine/view/styles/margin
8
- */
9
-
10
5
  import { getPositionShorthandNormalizer, getBoxSidesValueReducer } from './utils';
11
-
12
6
  /**
13
7
  * Adds a margin CSS styles processing rules.
14
8
  *
@@ -27,15 +21,12 @@ import { getPositionShorthandNormalizer, getBoxSidesValueReducer } from './utils
27
21
  *
28
22
  * @param {module:engine/view/stylesmap~StylesProcessor} stylesProcessor
29
23
  */
30
- export function addMarginRules( stylesProcessor ) {
31
- stylesProcessor.setNormalizer( 'margin', getPositionShorthandNormalizer( 'margin' ) );
32
-
33
- stylesProcessor.setNormalizer( 'margin-top', value => ( { path: 'margin.top', value } ) );
34
- stylesProcessor.setNormalizer( 'margin-right', value => ( { path: 'margin.right', value } ) );
35
- stylesProcessor.setNormalizer( 'margin-bottom', value => ( { path: 'margin.bottom', value } ) );
36
- stylesProcessor.setNormalizer( 'margin-left', value => ( { path: 'margin.left', value } ) );
37
-
38
- stylesProcessor.setReducer( 'margin', getBoxSidesValueReducer( 'margin' ) );
39
-
40
- stylesProcessor.setStyleRelation( 'margin', [ 'margin-top', 'margin-right', 'margin-bottom', 'margin-left' ] );
24
+ export function addMarginRules(stylesProcessor) {
25
+ stylesProcessor.setNormalizer('margin', getPositionShorthandNormalizer('margin'));
26
+ stylesProcessor.setNormalizer('margin-top', value => ({ path: 'margin.top', value }));
27
+ stylesProcessor.setNormalizer('margin-right', value => ({ path: 'margin.right', value }));
28
+ stylesProcessor.setNormalizer('margin-bottom', value => ({ path: 'margin.bottom', value }));
29
+ stylesProcessor.setNormalizer('margin-left', value => ({ path: 'margin.left', value }));
30
+ stylesProcessor.setReducer('margin', getBoxSidesValueReducer('margin'));
31
+ stylesProcessor.setStyleRelation('margin', ['margin-top', 'margin-right', 'margin-bottom', 'margin-left']);
41
32
  }
@@ -2,13 +2,7 @@
2
2
  * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
-
6
- /**
7
- * @module engine/view/styles/padding
8
- */
9
-
10
5
  import { getPositionShorthandNormalizer, getBoxSidesValueReducer } from './utils';
11
-
12
6
  /**
13
7
  * Adds a margin CSS styles processing rules.
14
8
  *
@@ -27,14 +21,12 @@ import { getPositionShorthandNormalizer, getBoxSidesValueReducer } from './utils
27
21
  *
28
22
  * @param {module:engine/view/stylesmap~StylesProcessor} stylesProcessor
29
23
  */
30
- export function addPaddingRules( stylesProcessor ) {
31
- stylesProcessor.setNormalizer( 'padding', getPositionShorthandNormalizer( 'padding' ) );
32
- stylesProcessor.setNormalizer( 'padding-top', value => ( { path: 'padding.top', value } ) );
33
- stylesProcessor.setNormalizer( 'padding-right', value => ( { path: 'padding.right', value } ) );
34
- stylesProcessor.setNormalizer( 'padding-bottom', value => ( { path: 'padding.bottom', value } ) );
35
- stylesProcessor.setNormalizer( 'padding-left', value => ( { path: 'padding.left', value } ) );
36
-
37
- stylesProcessor.setReducer( 'padding', getBoxSidesValueReducer( 'padding' ) );
38
-
39
- stylesProcessor.setStyleRelation( 'padding', [ 'padding-top', 'padding-right', 'padding-bottom', 'padding-left' ] );
24
+ export function addPaddingRules(stylesProcessor) {
25
+ stylesProcessor.setNormalizer('padding', getPositionShorthandNormalizer('padding'));
26
+ stylesProcessor.setNormalizer('padding-top', value => ({ path: 'padding.top', value }));
27
+ stylesProcessor.setNormalizer('padding-right', value => ({ path: 'padding.right', value }));
28
+ stylesProcessor.setNormalizer('padding-bottom', value => ({ path: 'padding.bottom', value }));
29
+ stylesProcessor.setNormalizer('padding-left', value => ({ path: 'padding.left', value }));
30
+ stylesProcessor.setReducer('padding', getBoxSidesValueReducer('padding'));
31
+ stylesProcessor.setStyleRelation('padding', ['padding-top', 'padding-right', 'padding-bottom', 'padding-left']);
40
32
  }
@@ -2,51 +2,44 @@
2
2
  * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
-
6
- /**
7
- * @module engine/view/styles/utils
8
- */
9
-
10
5
  const HEX_COLOR_REGEXP = /^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i;
11
6
  const RGB_COLOR_REGEXP = /^rgb\([ ]?([0-9]{1,3}[ %]?,[ ]?){2,3}[0-9]{1,3}[ %]?\)$/i;
12
7
  const RGBA_COLOR_REGEXP = /^rgba\([ ]?([0-9]{1,3}[ %]?,[ ]?){3}(1|[0-9]+%|[0]?\.?[0-9]+)\)$/i;
13
8
  const HSL_COLOR_REGEXP = /^hsl\([ ]?([0-9]{1,3}[ %]?[,]?[ ]*){3}(1|[0-9]+%|[0]?\.?[0-9]+)?\)$/i;
14
9
  const HSLA_COLOR_REGEXP = /^hsla\([ ]?([0-9]{1,3}[ %]?,[ ]?){2,3}(1|[0-9]+%|[0]?\.?[0-9]+)\)$/i;
15
-
16
- const COLOR_NAMES = new Set( [
17
- // CSS Level 1
18
- 'black', 'silver', 'gray', 'white', 'maroon', 'red', 'purple', 'fuchsia',
19
- 'green', 'lime', 'olive', 'yellow', 'navy', 'blue', 'teal', 'aqua',
20
- // CSS Level 2 (Revision 1)
21
- 'orange',
22
- // CSS Color Module Level 3
23
- 'aliceblue', 'antiquewhite', 'aquamarine', 'azure', 'beige', 'bisque', 'blanchedalmond', 'blueviolet', 'brown',
24
- 'burlywood', 'cadetblue', 'chartreuse', 'chocolate', 'coral', 'cornflowerblue', 'cornsilk', 'crimson', 'cyan',
25
- 'darkblue', 'darkcyan', 'darkgoldenrod', 'darkgray', 'darkgreen', 'darkgrey', 'darkkhaki', 'darkmagenta',
26
- 'darkolivegreen', 'darkorange', 'darkorchid', 'darkred', 'darksalmon', 'darkseagreen', 'darkslateblue',
27
- 'darkslategray', 'darkslategrey', 'darkturquoise', 'darkviolet', 'deeppink', 'deepskyblue', 'dimgray', 'dimgrey',
28
- 'dodgerblue', 'firebrick', 'floralwhite', 'forestgreen', 'gainsboro', 'ghostwhite', 'gold', 'goldenrod',
29
- 'greenyellow', 'grey', 'honeydew', 'hotpink', 'indianred', 'indigo', 'ivory', 'khaki', 'lavender', 'lavenderblush',
30
- 'lawngreen', 'lemonchiffon', 'lightblue', 'lightcoral', 'lightcyan', 'lightgoldenrodyellow', 'lightgray',
31
- 'lightgreen', 'lightgrey', 'lightpink', 'lightsalmon', 'lightseagreen', 'lightskyblue', 'lightslategray',
32
- 'lightslategrey', 'lightsteelblue', 'lightyellow', 'limegreen', 'linen', 'magenta', 'mediumaquamarine',
33
- 'mediumblue', 'mediumorchid', 'mediumpurple', 'mediumseagreen', 'mediumslateblue', 'mediumspringgreen',
34
- 'mediumturquoise', 'mediumvioletred', 'midnightblue', 'mintcream', 'mistyrose', 'moccasin', 'navajowhite',
35
- 'oldlace', 'olivedrab', 'orangered', 'orchid', 'palegoldenrod', 'palegreen', 'paleturquoise', 'palevioletred',
36
- 'papayawhip', 'peachpuff', 'peru', 'pink', 'plum', 'powderblue', 'rosybrown', 'royalblue', 'saddlebrown', 'salmon',
37
- 'sandybrown', 'seagreen', 'seashell', 'sienna', 'skyblue', 'slateblue', 'slategray', 'slategrey', 'snow',
38
- 'springgreen', 'steelblue', 'tan', 'thistle', 'tomato', 'turquoise', 'violet', 'wheat', 'whitesmoke', 'yellowgreen',
39
- // CSS Color Module Level 3 (System Colors)
40
- 'activeborder', 'activecaption', 'appworkspace', 'background', 'buttonface', 'buttonhighlight', 'buttonshadow',
41
- 'buttontext', 'captiontext', 'graytext', 'highlight', 'highlighttext', 'inactiveborder', 'inactivecaption',
42
- 'inactivecaptiontext', 'infobackground', 'infotext', 'menu', 'menutext', 'scrollbar', 'threeddarkshadow',
43
- 'threedface', 'threedhighlight', 'threedlightshadow', 'threedshadow', 'window', 'windowframe', 'windowtext',
44
- // CSS Color Module Level 4
45
- 'rebeccapurple',
46
- // Keywords
47
- 'currentcolor', 'transparent'
48
- ] );
49
-
10
+ const COLOR_NAMES = new Set([
11
+ // CSS Level 1
12
+ 'black', 'silver', 'gray', 'white', 'maroon', 'red', 'purple', 'fuchsia',
13
+ 'green', 'lime', 'olive', 'yellow', 'navy', 'blue', 'teal', 'aqua',
14
+ // CSS Level 2 (Revision 1)
15
+ 'orange',
16
+ // CSS Color Module Level 3
17
+ 'aliceblue', 'antiquewhite', 'aquamarine', 'azure', 'beige', 'bisque', 'blanchedalmond', 'blueviolet', 'brown',
18
+ 'burlywood', 'cadetblue', 'chartreuse', 'chocolate', 'coral', 'cornflowerblue', 'cornsilk', 'crimson', 'cyan',
19
+ 'darkblue', 'darkcyan', 'darkgoldenrod', 'darkgray', 'darkgreen', 'darkgrey', 'darkkhaki', 'darkmagenta',
20
+ 'darkolivegreen', 'darkorange', 'darkorchid', 'darkred', 'darksalmon', 'darkseagreen', 'darkslateblue',
21
+ 'darkslategray', 'darkslategrey', 'darkturquoise', 'darkviolet', 'deeppink', 'deepskyblue', 'dimgray', 'dimgrey',
22
+ 'dodgerblue', 'firebrick', 'floralwhite', 'forestgreen', 'gainsboro', 'ghostwhite', 'gold', 'goldenrod',
23
+ 'greenyellow', 'grey', 'honeydew', 'hotpink', 'indianred', 'indigo', 'ivory', 'khaki', 'lavender', 'lavenderblush',
24
+ 'lawngreen', 'lemonchiffon', 'lightblue', 'lightcoral', 'lightcyan', 'lightgoldenrodyellow', 'lightgray',
25
+ 'lightgreen', 'lightgrey', 'lightpink', 'lightsalmon', 'lightseagreen', 'lightskyblue', 'lightslategray',
26
+ 'lightslategrey', 'lightsteelblue', 'lightyellow', 'limegreen', 'linen', 'magenta', 'mediumaquamarine',
27
+ 'mediumblue', 'mediumorchid', 'mediumpurple', 'mediumseagreen', 'mediumslateblue', 'mediumspringgreen',
28
+ 'mediumturquoise', 'mediumvioletred', 'midnightblue', 'mintcream', 'mistyrose', 'moccasin', 'navajowhite',
29
+ 'oldlace', 'olivedrab', 'orangered', 'orchid', 'palegoldenrod', 'palegreen', 'paleturquoise', 'palevioletred',
30
+ 'papayawhip', 'peachpuff', 'peru', 'pink', 'plum', 'powderblue', 'rosybrown', 'royalblue', 'saddlebrown', 'salmon',
31
+ 'sandybrown', 'seagreen', 'seashell', 'sienna', 'skyblue', 'slateblue', 'slategray', 'slategrey', 'snow',
32
+ 'springgreen', 'steelblue', 'tan', 'thistle', 'tomato', 'turquoise', 'violet', 'wheat', 'whitesmoke', 'yellowgreen',
33
+ // CSS Color Module Level 3 (System Colors)
34
+ 'activeborder', 'activecaption', 'appworkspace', 'background', 'buttonface', 'buttonhighlight', 'buttonshadow',
35
+ 'buttontext', 'captiontext', 'graytext', 'highlight', 'highlighttext', 'inactiveborder', 'inactivecaption',
36
+ 'inactivecaptiontext', 'infobackground', 'infotext', 'menu', 'menutext', 'scrollbar', 'threeddarkshadow',
37
+ 'threedface', 'threedhighlight', 'threedlightshadow', 'threedshadow', 'window', 'windowframe', 'windowtext',
38
+ // CSS Color Module Level 4
39
+ 'rebeccapurple',
40
+ // Keywords
41
+ 'currentcolor', 'transparent'
42
+ ]);
50
43
  /**
51
44
  * Checks if string contains [color](https://developer.mozilla.org/en-US/docs/Web/CSS/color) CSS value.
52
45
  *
@@ -61,123 +54,104 @@ const COLOR_NAMES = new Set( [
61
54
  * @param {String} string
62
55
  * @returns {Boolean}
63
56
  */
64
- export function isColor( string ) {
65
- // As far as I was able to test checking some pre-conditions is faster than joining each test with ||.
66
- if ( string.startsWith( '#' ) ) {
67
- return HEX_COLOR_REGEXP.test( string );
68
- }
69
-
70
- if ( string.startsWith( 'rgb' ) ) {
71
- return RGB_COLOR_REGEXP.test( string ) || RGBA_COLOR_REGEXP.test( string );
72
- }
73
-
74
- if ( string.startsWith( 'hsl' ) ) {
75
- return HSL_COLOR_REGEXP.test( string ) || HSLA_COLOR_REGEXP.test( string );
76
- }
77
-
78
- // Array check > RegExp test.
79
- return COLOR_NAMES.has( string.toLowerCase() );
57
+ export function isColor(string) {
58
+ // As far as I was able to test checking some pre-conditions is faster than joining each test with ||.
59
+ if (string.startsWith('#')) {
60
+ return HEX_COLOR_REGEXP.test(string);
61
+ }
62
+ if (string.startsWith('rgb')) {
63
+ return RGB_COLOR_REGEXP.test(string) || RGBA_COLOR_REGEXP.test(string);
64
+ }
65
+ if (string.startsWith('hsl')) {
66
+ return HSL_COLOR_REGEXP.test(string) || HSLA_COLOR_REGEXP.test(string);
67
+ }
68
+ // Array check > RegExp test.
69
+ return COLOR_NAMES.has(string.toLowerCase());
80
70
  }
81
-
82
- const lineStyleValues = [ 'none', 'hidden', 'dotted', 'dashed', 'solid', 'double', 'groove', 'ridge', 'inset', 'outset' ];
83
-
71
+ const lineStyleValues = ['none', 'hidden', 'dotted', 'dashed', 'solid', 'double', 'groove', 'ridge', 'inset', 'outset'];
84
72
  /**
85
73
  * Checks if string contains [line style](https://developer.mozilla.org/en-US/docs/Web/CSS/border-style) CSS value.
86
74
  *
87
75
  * @param {String} string
88
76
  * @returns {Boolean}
89
77
  */
90
- export function isLineStyle( string ) {
91
- return lineStyleValues.includes( string );
78
+ export function isLineStyle(string) {
79
+ return lineStyleValues.includes(string);
92
80
  }
93
-
94
81
  const lengthRegExp = /^([+-]?[0-9]*([.][0-9]+)?(px|cm|mm|in|pc|pt|ch|em|ex|rem|vh|vw|vmin|vmax)|0)$/;
95
-
96
82
  /**
97
83
  * Checks if string contains [length](https://developer.mozilla.org/en-US/docs/Web/CSS/length) CSS value.
98
84
  *
99
85
  * @param {String} string
100
86
  * @returns {Boolean}
101
87
  */
102
- export function isLength( string ) {
103
- return lengthRegExp.test( string );
88
+ export function isLength(string) {
89
+ return lengthRegExp.test(string);
104
90
  }
105
-
106
91
  const PERCENTAGE_VALUE_REGEXP = /^[+-]?[0-9]*([.][0-9]+)?%$/;
107
-
108
92
  /**
109
93
  * Checks if string contains [percentage](https://developer.mozilla.org/en-US/docs/Web/CSS/percentage) CSS value.
110
94
  *
111
95
  * @param {String} string
112
96
  * @returns {Boolean}
113
97
  */
114
- export function isPercentage( string ) {
115
- return PERCENTAGE_VALUE_REGEXP.test( string );
98
+ export function isPercentage(string) {
99
+ return PERCENTAGE_VALUE_REGEXP.test(string);
116
100
  }
117
-
118
- const repeatValues = [ 'repeat-x', 'repeat-y', 'repeat', 'space', 'round', 'no-repeat' ];
119
-
101
+ const repeatValues = ['repeat-x', 'repeat-y', 'repeat', 'space', 'round', 'no-repeat'];
120
102
  /**
121
103
  * Checks if string contains [background repeat](https://developer.mozilla.org/en-US/docs/Web/CSS/background-repeat) CSS value.
122
104
  *
123
105
  * @param {String} string
124
106
  * @returns {Boolean}
125
107
  */
126
- export function isRepeat( string ) {
127
- return repeatValues.includes( string );
108
+ export function isRepeat(string) {
109
+ return repeatValues.includes(string);
128
110
  }
129
-
130
- const positionValues = [ 'center', 'top', 'bottom', 'left', 'right' ];
131
-
111
+ const positionValues = ['center', 'top', 'bottom', 'left', 'right'];
132
112
  /**
133
113
  * Checks if string contains [background position](https://developer.mozilla.org/en-US/docs/Web/CSS/background-position) CSS value.
134
114
  *
135
115
  * @param {String} string
136
116
  * @returns {Boolean}
137
117
  */
138
- export function isPosition( string ) {
139
- return positionValues.includes( string );
118
+ export function isPosition(string) {
119
+ return positionValues.includes(string);
140
120
  }
141
-
142
- const attachmentValues = [ 'fixed', 'scroll', 'local' ];
143
-
121
+ const attachmentValues = ['fixed', 'scroll', 'local'];
144
122
  /**
145
123
  * Checks if string contains [background attachment](https://developer.mozilla.org/en-US/docs/Web/CSS/background-attachment) CSS value.
146
124
  *
147
125
  * @param {String} string
148
126
  * @returns {Boolean}
149
127
  */
150
- export function isAttachment( string ) {
151
- return attachmentValues.includes( string );
128
+ export function isAttachment(string) {
129
+ return attachmentValues.includes(string);
152
130
  }
153
-
154
131
  const urlRegExp = /^url\(/;
155
-
156
132
  /**
157
133
  * Checks if string contains [URL](https://developer.mozilla.org/en-US/docs/Web/CSS/url) CSS value.
158
134
  *
159
135
  * @param {String} string
160
136
  * @returns {Boolean}
161
137
  */
162
- export function isURL( string ) {
163
- return urlRegExp.test( string );
138
+ export function isURL(string) {
139
+ return urlRegExp.test(string);
164
140
  }
165
-
166
- export function getBoxSidesValues( value = '' ) {
167
- if ( value === '' ) {
168
- return { top: undefined, right: undefined, bottom: undefined, left: undefined };
169
- }
170
-
171
- const values = getShorthandValues( value );
172
-
173
- const top = values[ 0 ];
174
- const bottom = values[ 2 ] || top;
175
- const right = values[ 1 ] || top;
176
- const left = values[ 3 ] || right;
177
-
178
- return { top, bottom, right, left };
141
+ /**
142
+ * TODO: Docs
143
+ */
144
+ export function getBoxSidesValues(value = '') {
145
+ if (value === '') {
146
+ return { top: undefined, right: undefined, bottom: undefined, left: undefined };
147
+ }
148
+ const values = getShorthandValues(value);
149
+ const top = values[0];
150
+ const bottom = values[2] || top;
151
+ const right = values[1] || top;
152
+ const left = values[3] || right;
153
+ return { top, bottom, right, left };
179
154
  }
180
-
181
155
  /**
182
156
  * Default reducer for CSS properties that concerns edges of a box
183
157
  * [shorthand](https://developer.mozilla.org/en-US/docs/Web/CSS/Shorthand_properties) notations:
@@ -187,36 +161,30 @@ export function getBoxSidesValues( value = '' ) {
187
161
  * @param {String} styleShorthand
188
162
  * @returns {Function}
189
163
  */
190
- export function getBoxSidesValueReducer( styleShorthand ) {
191
- return value => {
192
- const { top, right, bottom, left } = value;
193
-
194
- const reduced = [];
195
-
196
- if ( ![ top, right, left, bottom ].every( value => !!value ) ) {
197
- if ( top ) {
198
- reduced.push( [ styleShorthand + '-top', top ] );
199
- }
200
-
201
- if ( right ) {
202
- reduced.push( [ styleShorthand + '-right', right ] );
203
- }
204
-
205
- if ( bottom ) {
206
- reduced.push( [ styleShorthand + '-bottom', bottom ] );
207
- }
208
-
209
- if ( left ) {
210
- reduced.push( [ styleShorthand + '-left', left ] );
211
- }
212
- } else {
213
- reduced.push( [ styleShorthand, getBoxSidesShorthandValue( value ) ] );
214
- }
215
-
216
- return reduced;
217
- };
164
+ export function getBoxSidesValueReducer(styleShorthand) {
165
+ return (value) => {
166
+ const { top, right, bottom, left } = value;
167
+ const reduced = [];
168
+ if (![top, right, left, bottom].every(value => !!value)) {
169
+ if (top) {
170
+ reduced.push([styleShorthand + '-top', top]);
171
+ }
172
+ if (right) {
173
+ reduced.push([styleShorthand + '-right', right]);
174
+ }
175
+ if (bottom) {
176
+ reduced.push([styleShorthand + '-bottom', bottom]);
177
+ }
178
+ if (left) {
179
+ reduced.push([styleShorthand + '-left', left]);
180
+ }
181
+ }
182
+ else {
183
+ reduced.push([styleShorthand, getBoxSidesShorthandValue(value)]);
184
+ }
185
+ return reduced;
186
+ };
218
187
  }
219
-
220
188
  /**
221
189
  * Returns a [shorthand](https://developer.mozilla.org/en-US/docs/Web/CSS/Shorthand_properties) notation
222
190
  * of a CSS property value.
@@ -227,22 +195,22 @@ export function getBoxSidesValueReducer( styleShorthand ) {
227
195
  * @param {module:engine/view/stylesmap~BoxSides} styleShorthand
228
196
  * @returns {String}
229
197
  */
230
- export function getBoxSidesShorthandValue( { top, right, bottom, left } ) {
231
- const out = [];
232
-
233
- if ( left !== right ) {
234
- out.push( top, right, bottom, left );
235
- } else if ( bottom !== top ) {
236
- out.push( top, right, bottom );
237
- } else if ( right !== top ) {
238
- out.push( top, right );
239
- } else {
240
- out.push( top );
241
- }
242
-
243
- return out.join( ' ' );
198
+ export function getBoxSidesShorthandValue({ top, right, bottom, left }) {
199
+ const out = [];
200
+ if (left !== right) {
201
+ out.push(top, right, bottom, left);
202
+ }
203
+ else if (bottom !== top) {
204
+ out.push(top, right, bottom);
205
+ }
206
+ else if (right !== top) {
207
+ out.push(top, right);
208
+ }
209
+ else {
210
+ out.push(top);
211
+ }
212
+ return out.join(' ');
244
213
  }
245
-
246
214
  /**
247
215
  * Creates a normalizer for a [shorthand](https://developer.mozilla.org/en-US/docs/Web/CSS/Shorthand_properties) 1-to-4 value.
248
216
  *
@@ -251,15 +219,14 @@ export function getBoxSidesShorthandValue( { top, right, bottom, left } ) {
251
219
  * @param {String} shorthand
252
220
  * @returns {Function}
253
221
  */
254
- export function getPositionShorthandNormalizer( shorthand ) {
255
- return value => {
256
- return {
257
- path: shorthand,
258
- value: getBoxSidesValues( value )
259
- };
260
- };
222
+ export function getPositionShorthandNormalizer(shorthand) {
223
+ return (value) => {
224
+ return {
225
+ path: shorthand,
226
+ value: getBoxSidesValues(value)
227
+ };
228
+ };
261
229
  }
262
-
263
230
  /**
264
231
  * Parses parts of a 1-to-4 value notation - handles some CSS values with spaces (like RGB()).
265
232
  *
@@ -269,9 +236,9 @@ export function getPositionShorthandNormalizer( shorthand ) {
269
236
  * @param {String} string
270
237
  * @returns {Array.<String>}
271
238
  */
272
- export function getShorthandValues( string ) {
273
- return string
274
- .replace( /, /g, ',' ) // Exclude comma from spaces evaluation as values are separated by spaces.
275
- .split( ' ' )
276
- .map( string => string.replace( /,/g, ', ' ) ); // Restore original notation.
239
+ export function getShorthandValues(string) {
240
+ return string
241
+ .replace(/, /g, ',') // Exclude comma from spaces evaluation as values are separated by spaces.
242
+ .split(' ')
243
+ .map(string => string.replace(/,/g, ', ')); // Restore original notation.
277
244
  }