@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.
- package/CHANGELOG.md +4 -4
- package/package.json +30 -24
- package/src/controller/datacontroller.js +467 -561
- package/src/controller/editingcontroller.js +168 -204
- package/src/conversion/conversion.js +541 -565
- package/src/conversion/conversionhelpers.js +24 -28
- package/src/conversion/downcastdispatcher.js +457 -686
- package/src/conversion/downcasthelpers.js +1583 -1965
- package/src/conversion/mapper.js +518 -707
- package/src/conversion/modelconsumable.js +240 -283
- package/src/conversion/upcastdispatcher.js +372 -718
- package/src/conversion/upcasthelpers.js +707 -818
- package/src/conversion/viewconsumable.js +524 -581
- package/src/dataprocessor/basichtmlwriter.js +12 -16
- package/src/dataprocessor/dataprocessor.js +5 -0
- package/src/dataprocessor/htmldataprocessor.js +100 -116
- package/src/dataprocessor/htmlwriter.js +1 -18
- package/src/dataprocessor/xmldataprocessor.js +116 -137
- package/src/dev-utils/model.js +260 -352
- package/src/dev-utils/operationreplayer.js +106 -126
- package/src/dev-utils/utils.js +34 -51
- package/src/dev-utils/view.js +632 -753
- package/src/index.js +0 -11
- package/src/model/batch.js +111 -127
- package/src/model/differ.js +988 -1233
- package/src/model/document.js +340 -449
- package/src/model/documentfragment.js +327 -364
- package/src/model/documentselection.js +996 -1189
- package/src/model/element.js +306 -410
- package/src/model/history.js +224 -262
- package/src/model/item.js +5 -0
- package/src/model/liveposition.js +84 -145
- package/src/model/liverange.js +108 -185
- package/src/model/markercollection.js +379 -480
- package/src/model/model.js +883 -1034
- package/src/model/node.js +419 -463
- package/src/model/nodelist.js +175 -201
- package/src/model/operation/attributeoperation.js +153 -182
- package/src/model/operation/detachoperation.js +64 -83
- package/src/model/operation/insertoperation.js +135 -166
- package/src/model/operation/markeroperation.js +114 -140
- package/src/model/operation/mergeoperation.js +163 -191
- package/src/model/operation/moveoperation.js +157 -187
- package/src/model/operation/nooperation.js +28 -38
- package/src/model/operation/operation.js +106 -125
- package/src/model/operation/operationfactory.js +30 -34
- package/src/model/operation/renameoperation.js +109 -135
- package/src/model/operation/rootattributeoperation.js +155 -188
- package/src/model/operation/splitoperation.js +196 -232
- package/src/model/operation/transform.js +1833 -2204
- package/src/model/operation/utils.js +140 -204
- package/src/model/position.js +899 -1053
- package/src/model/range.js +910 -1028
- package/src/model/rootelement.js +77 -97
- package/src/model/schema.js +1189 -1835
- package/src/model/selection.js +745 -862
- package/src/model/text.js +90 -114
- package/src/model/textproxy.js +204 -240
- package/src/model/treewalker.js +316 -397
- package/src/model/typecheckable.js +16 -0
- package/src/model/utils/autoparagraphing.js +32 -44
- package/src/model/utils/deletecontent.js +334 -418
- package/src/model/utils/findoptimalinsertionrange.js +25 -36
- package/src/model/utils/getselectedcontent.js +96 -118
- package/src/model/utils/insertcontent.js +654 -773
- package/src/model/utils/insertobject.js +96 -119
- package/src/model/utils/modifyselection.js +120 -158
- package/src/model/utils/selection-post-fixer.js +153 -201
- package/src/model/writer.js +1305 -1474
- package/src/view/attributeelement.js +189 -225
- package/src/view/containerelement.js +75 -85
- package/src/view/document.js +172 -215
- package/src/view/documentfragment.js +200 -249
- package/src/view/documentselection.js +338 -367
- package/src/view/domconverter.js +1370 -1617
- package/src/view/downcastwriter.js +1747 -2076
- package/src/view/editableelement.js +81 -97
- package/src/view/element.js +739 -890
- package/src/view/elementdefinition.js +5 -0
- package/src/view/emptyelement.js +82 -92
- package/src/view/filler.js +35 -50
- package/src/view/item.js +5 -0
- package/src/view/matcher.js +260 -559
- package/src/view/node.js +274 -360
- package/src/view/observer/arrowkeysobserver.js +19 -28
- package/src/view/observer/bubblingemittermixin.js +120 -263
- package/src/view/observer/bubblingeventinfo.js +47 -55
- package/src/view/observer/clickobserver.js +7 -13
- package/src/view/observer/compositionobserver.js +14 -24
- package/src/view/observer/domeventdata.js +57 -67
- package/src/view/observer/domeventobserver.js +40 -64
- package/src/view/observer/fakeselectionobserver.js +81 -96
- package/src/view/observer/focusobserver.js +45 -61
- package/src/view/observer/inputobserver.js +7 -13
- package/src/view/observer/keyobserver.js +17 -27
- package/src/view/observer/mouseobserver.js +7 -14
- package/src/view/observer/mutationobserver.js +220 -315
- package/src/view/observer/observer.js +81 -102
- package/src/view/observer/selectionobserver.js +191 -246
- package/src/view/observer/tabobserver.js +23 -36
- package/src/view/placeholder.js +128 -173
- package/src/view/position.js +350 -401
- package/src/view/range.js +453 -513
- package/src/view/rawelement.js +85 -112
- package/src/view/renderer.js +874 -1018
- package/src/view/rooteditableelement.js +80 -90
- package/src/view/selection.js +608 -689
- package/src/view/styles/background.js +43 -44
- package/src/view/styles/border.js +220 -276
- package/src/view/styles/margin.js +8 -17
- package/src/view/styles/padding.js +8 -16
- package/src/view/styles/utils.js +127 -160
- package/src/view/stylesmap.js +728 -905
- package/src/view/text.js +102 -126
- package/src/view/textproxy.js +144 -170
- package/src/view/treewalker.js +383 -479
- package/src/view/typecheckable.js +19 -0
- package/src/view/uielement.js +166 -187
- package/src/view/upcastwriter.js +395 -449
- package/src/view/view.js +569 -664
- package/src/dataprocessor/dataprocessor.jsdoc +0 -64
- package/src/model/item.jsdoc +0 -14
- package/src/view/elementdefinition.jsdoc +0 -59
- 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(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
}
|
package/src/view/styles/utils.js
CHANGED
|
@@ -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
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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(
|
|
91
|
-
|
|
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(
|
|
103
|
-
|
|
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(
|
|
115
|
-
|
|
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(
|
|
127
|
-
|
|
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(
|
|
139
|
-
|
|
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(
|
|
151
|
-
|
|
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(
|
|
163
|
-
|
|
138
|
+
export function isURL(string) {
|
|
139
|
+
return urlRegExp.test(string);
|
|
164
140
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
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(
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
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(
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
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(
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
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(
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
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
|
}
|