@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.
- package/LICENSE.md +1 -1
- package/{src → dist}/engineconfig.d.ts +6 -15
- package/dist/index-editor.css +38 -15
- package/dist/index.css +37 -37
- package/dist/index.css.map +1 -1
- package/{src → dist}/index.d.ts +0 -1
- package/dist/index.js +588 -94
- package/dist/index.js.map +1 -1
- package/{src → dist}/model/model.d.ts +10 -4
- package/{src → dist}/model/selection.d.ts +1 -1
- package/{src → dist}/view/downcastwriter.d.ts +3 -2
- package/{src → dist}/view/element.d.ts +2 -2
- package/{src → dist}/view/matcher.d.ts +4 -2
- package/dist/view/styles/background.d.ts +18 -0
- package/{src → dist}/view/styles/border.d.ts +0 -12
- package/{src → dist}/view/styles/margin.d.ts +0 -13
- package/{src → dist}/view/styles/padding.d.ts +0 -13
- package/{src → dist}/view/styles/utils.d.ts +12 -0
- package/package.json +20 -39
- package/src/controller/datacontroller.js +0 -522
- package/src/controller/editingcontroller.js +0 -181
- package/src/conversion/conversion.js +0 -606
- package/src/conversion/conversionhelpers.js +0 -33
- package/src/conversion/downcastdispatcher.js +0 -563
- package/src/conversion/downcasthelpers.js +0 -2160
- package/src/conversion/mapper.js +0 -1050
- package/src/conversion/modelconsumable.js +0 -331
- package/src/conversion/upcastdispatcher.js +0 -470
- package/src/conversion/upcasthelpers.js +0 -952
- package/src/conversion/viewconsumable.js +0 -541
- package/src/dataprocessor/basichtmlwriter.js +0 -22
- package/src/dataprocessor/dataprocessor.js +0 -5
- package/src/dataprocessor/htmldataprocessor.js +0 -107
- package/src/dataprocessor/htmlwriter.js +0 -5
- package/src/dataprocessor/xmldataprocessor.js +0 -127
- package/src/dev-utils/model.js +0 -396
- package/src/dev-utils/operationreplayer.js +0 -116
- package/src/dev-utils/utils.js +0 -122
- package/src/dev-utils/view.js +0 -990
- package/src/engineconfig.js +0 -5
- package/src/index.js +0 -134
- package/src/legacyerrors.js +0 -17
- package/src/model/batch.js +0 -98
- package/src/model/differ.js +0 -1288
- package/src/model/document.js +0 -398
- package/src/model/documentfragment.js +0 -332
- package/src/model/documentselection.js +0 -1026
- package/src/model/element.js +0 -323
- package/src/model/history.js +0 -206
- package/src/model/item.js +0 -5
- package/src/model/liveposition.js +0 -93
- package/src/model/liverange.js +0 -121
- package/src/model/markercollection.js +0 -436
- package/src/model/model.js +0 -866
- package/src/model/node.js +0 -371
- package/src/model/nodelist.js +0 -244
- package/src/model/operation/attributeoperation.js +0 -172
- package/src/model/operation/detachoperation.js +0 -87
- package/src/model/operation/insertoperation.js +0 -153
- package/src/model/operation/markeroperation.js +0 -136
- package/src/model/operation/mergeoperation.js +0 -184
- package/src/model/operation/moveoperation.js +0 -179
- package/src/model/operation/nooperation.js +0 -48
- package/src/model/operation/operation.js +0 -78
- package/src/model/operation/operationfactory.js +0 -44
- package/src/model/operation/renameoperation.js +0 -128
- package/src/model/operation/rootattributeoperation.js +0 -173
- package/src/model/operation/rootoperation.js +0 -106
- package/src/model/operation/splitoperation.js +0 -214
- package/src/model/operation/transform.js +0 -2211
- package/src/model/operation/utils.js +0 -217
- package/src/model/position.js +0 -1041
- package/src/model/range.js +0 -880
- package/src/model/rootelement.js +0 -82
- package/src/model/schema.js +0 -1542
- package/src/model/selection.js +0 -814
- package/src/model/text.js +0 -92
- package/src/model/textproxy.js +0 -202
- package/src/model/treewalker.js +0 -313
- package/src/model/typecheckable.js +0 -16
- package/src/model/utils/autoparagraphing.js +0 -63
- package/src/model/utils/deletecontent.js +0 -509
- package/src/model/utils/getselectedcontent.js +0 -126
- package/src/model/utils/insertcontent.js +0 -750
- package/src/model/utils/insertobject.js +0 -135
- package/src/model/utils/modifyselection.js +0 -187
- package/src/model/utils/selection-post-fixer.js +0 -264
- package/src/model/writer.js +0 -1318
- package/src/view/attributeelement.js +0 -220
- package/src/view/containerelement.js +0 -91
- package/src/view/datatransfer.js +0 -106
- package/src/view/document.js +0 -139
- package/src/view/documentfragment.js +0 -251
- package/src/view/documentselection.js +0 -270
- package/src/view/domconverter.js +0 -1661
- package/src/view/downcastwriter.js +0 -1589
- package/src/view/editableelement.js +0 -74
- package/src/view/element.js +0 -1053
- package/src/view/elementdefinition.js +0 -5
- package/src/view/emptyelement.js +0 -83
- package/src/view/filler.js +0 -161
- package/src/view/item.js +0 -5
- package/src/view/matcher.js +0 -437
- package/src/view/node.js +0 -238
- package/src/view/observer/arrowkeysobserver.js +0 -40
- package/src/view/observer/bubblingemittermixin.js +0 -215
- package/src/view/observer/bubblingeventinfo.js +0 -49
- package/src/view/observer/clickobserver.js +0 -26
- package/src/view/observer/compositionobserver.js +0 -64
- package/src/view/observer/domeventdata.js +0 -63
- package/src/view/observer/domeventobserver.js +0 -81
- package/src/view/observer/fakeselectionobserver.js +0 -95
- package/src/view/observer/focusobserver.js +0 -166
- package/src/view/observer/inputobserver.js +0 -236
- package/src/view/observer/keyobserver.js +0 -36
- package/src/view/observer/mouseobserver.js +0 -26
- package/src/view/observer/mutationobserver.js +0 -219
- package/src/view/observer/observer.js +0 -92
- package/src/view/observer/pointerobserver.js +0 -26
- package/src/view/observer/selectionobserver.js +0 -318
- package/src/view/observer/tabobserver.js +0 -42
- package/src/view/observer/touchobserver.js +0 -26
- package/src/view/placeholder.js +0 -285
- package/src/view/position.js +0 -341
- package/src/view/range.js +0 -451
- package/src/view/rawelement.js +0 -115
- package/src/view/renderer.js +0 -1148
- package/src/view/rooteditableelement.js +0 -78
- package/src/view/selection.js +0 -594
- package/src/view/styles/background.d.ts +0 -33
- package/src/view/styles/background.js +0 -74
- package/src/view/styles/border.js +0 -316
- package/src/view/styles/margin.js +0 -34
- package/src/view/styles/padding.js +0 -34
- package/src/view/styles/utils.js +0 -219
- package/src/view/stylesmap.js +0 -941
- package/src/view/text.js +0 -110
- package/src/view/textproxy.js +0 -136
- package/src/view/tokenlist.js +0 -194
- package/src/view/treewalker.js +0 -389
- package/src/view/typecheckable.js +0 -19
- package/src/view/uielement.js +0 -194
- package/src/view/upcastwriter.js +0 -363
- package/src/view/view.js +0 -579
- package/theme/placeholder.css +0 -36
- package/theme/renderer.css +0 -9
- /package/{src → dist}/controller/datacontroller.d.ts +0 -0
- /package/{src → dist}/controller/editingcontroller.d.ts +0 -0
- /package/{src → dist}/conversion/conversion.d.ts +0 -0
- /package/{src → dist}/conversion/conversionhelpers.d.ts +0 -0
- /package/{src → dist}/conversion/downcastdispatcher.d.ts +0 -0
- /package/{src → dist}/conversion/downcasthelpers.d.ts +0 -0
- /package/{src → dist}/conversion/mapper.d.ts +0 -0
- /package/{src → dist}/conversion/modelconsumable.d.ts +0 -0
- /package/{src → dist}/conversion/upcastdispatcher.d.ts +0 -0
- /package/{src → dist}/conversion/upcasthelpers.d.ts +0 -0
- /package/{src → dist}/conversion/viewconsumable.d.ts +0 -0
- /package/{src → dist}/dataprocessor/basichtmlwriter.d.ts +0 -0
- /package/{src → dist}/dataprocessor/dataprocessor.d.ts +0 -0
- /package/{src → dist}/dataprocessor/htmldataprocessor.d.ts +0 -0
- /package/{src → dist}/dataprocessor/htmlwriter.d.ts +0 -0
- /package/{src → dist}/dataprocessor/xmldataprocessor.d.ts +0 -0
- /package/{src → dist}/dev-utils/model.d.ts +0 -0
- /package/{src → dist}/dev-utils/operationreplayer.d.ts +0 -0
- /package/{src → dist}/dev-utils/utils.d.ts +0 -0
- /package/{src → dist}/dev-utils/view.d.ts +0 -0
- /package/{src → dist}/legacyerrors.d.ts +0 -0
- /package/{src → dist}/model/batch.d.ts +0 -0
- /package/{src → dist}/model/differ.d.ts +0 -0
- /package/{src → dist}/model/document.d.ts +0 -0
- /package/{src → dist}/model/documentfragment.d.ts +0 -0
- /package/{src → dist}/model/documentselection.d.ts +0 -0
- /package/{src → dist}/model/element.d.ts +0 -0
- /package/{src → dist}/model/history.d.ts +0 -0
- /package/{src → dist}/model/item.d.ts +0 -0
- /package/{src → dist}/model/liveposition.d.ts +0 -0
- /package/{src → dist}/model/liverange.d.ts +0 -0
- /package/{src → dist}/model/markercollection.d.ts +0 -0
- /package/{src → dist}/model/node.d.ts +0 -0
- /package/{src → dist}/model/nodelist.d.ts +0 -0
- /package/{src → dist}/model/operation/attributeoperation.d.ts +0 -0
- /package/{src → dist}/model/operation/detachoperation.d.ts +0 -0
- /package/{src → dist}/model/operation/insertoperation.d.ts +0 -0
- /package/{src → dist}/model/operation/markeroperation.d.ts +0 -0
- /package/{src → dist}/model/operation/mergeoperation.d.ts +0 -0
- /package/{src → dist}/model/operation/moveoperation.d.ts +0 -0
- /package/{src → dist}/model/operation/nooperation.d.ts +0 -0
- /package/{src → dist}/model/operation/operation.d.ts +0 -0
- /package/{src → dist}/model/operation/operationfactory.d.ts +0 -0
- /package/{src → dist}/model/operation/renameoperation.d.ts +0 -0
- /package/{src → dist}/model/operation/rootattributeoperation.d.ts +0 -0
- /package/{src → dist}/model/operation/rootoperation.d.ts +0 -0
- /package/{src → dist}/model/operation/splitoperation.d.ts +0 -0
- /package/{src → dist}/model/operation/transform.d.ts +0 -0
- /package/{src → dist}/model/operation/utils.d.ts +0 -0
- /package/{src → dist}/model/position.d.ts +0 -0
- /package/{src → dist}/model/range.d.ts +0 -0
- /package/{src → dist}/model/rootelement.d.ts +0 -0
- /package/{src → dist}/model/schema.d.ts +0 -0
- /package/{src → dist}/model/text.d.ts +0 -0
- /package/{src → dist}/model/textproxy.d.ts +0 -0
- /package/{src → dist}/model/treewalker.d.ts +0 -0
- /package/{src → dist}/model/typecheckable.d.ts +0 -0
- /package/{src → dist}/model/utils/autoparagraphing.d.ts +0 -0
- /package/{src → dist}/model/utils/deletecontent.d.ts +0 -0
- /package/{src → dist}/model/utils/getselectedcontent.d.ts +0 -0
- /package/{src → dist}/model/utils/insertcontent.d.ts +0 -0
- /package/{src → dist}/model/utils/insertobject.d.ts +0 -0
- /package/{src → dist}/model/utils/modifyselection.d.ts +0 -0
- /package/{src → dist}/model/utils/selection-post-fixer.d.ts +0 -0
- /package/{src → dist}/model/writer.d.ts +0 -0
- /package/{src → dist}/view/attributeelement.d.ts +0 -0
- /package/{src → dist}/view/containerelement.d.ts +0 -0
- /package/{src → dist}/view/datatransfer.d.ts +0 -0
- /package/{src → dist}/view/document.d.ts +0 -0
- /package/{src → dist}/view/documentfragment.d.ts +0 -0
- /package/{src → dist}/view/documentselection.d.ts +0 -0
- /package/{src → dist}/view/domconverter.d.ts +0 -0
- /package/{src → dist}/view/editableelement.d.ts +0 -0
- /package/{src → dist}/view/elementdefinition.d.ts +0 -0
- /package/{src → dist}/view/emptyelement.d.ts +0 -0
- /package/{src → dist}/view/filler.d.ts +0 -0
- /package/{src → dist}/view/item.d.ts +0 -0
- /package/{src → dist}/view/node.d.ts +0 -0
- /package/{src → dist}/view/observer/arrowkeysobserver.d.ts +0 -0
- /package/{src → dist}/view/observer/bubblingemittermixin.d.ts +0 -0
- /package/{src → dist}/view/observer/bubblingeventinfo.d.ts +0 -0
- /package/{src → dist}/view/observer/clickobserver.d.ts +0 -0
- /package/{src → dist}/view/observer/compositionobserver.d.ts +0 -0
- /package/{src → dist}/view/observer/domeventdata.d.ts +0 -0
- /package/{src → dist}/view/observer/domeventobserver.d.ts +0 -0
- /package/{src → dist}/view/observer/fakeselectionobserver.d.ts +0 -0
- /package/{src → dist}/view/observer/focusobserver.d.ts +0 -0
- /package/{src → dist}/view/observer/inputobserver.d.ts +0 -0
- /package/{src → dist}/view/observer/keyobserver.d.ts +0 -0
- /package/{src → dist}/view/observer/mouseobserver.d.ts +0 -0
- /package/{src → dist}/view/observer/mutationobserver.d.ts +0 -0
- /package/{src → dist}/view/observer/observer.d.ts +0 -0
- /package/{src → dist}/view/observer/pointerobserver.d.ts +0 -0
- /package/{src → dist}/view/observer/selectionobserver.d.ts +0 -0
- /package/{src → dist}/view/observer/tabobserver.d.ts +0 -0
- /package/{src → dist}/view/observer/touchobserver.d.ts +0 -0
- /package/{src → dist}/view/placeholder.d.ts +0 -0
- /package/{src → dist}/view/position.d.ts +0 -0
- /package/{src → dist}/view/range.d.ts +0 -0
- /package/{src → dist}/view/rawelement.d.ts +0 -0
- /package/{src → dist}/view/renderer.d.ts +0 -0
- /package/{src → dist}/view/rooteditableelement.d.ts +0 -0
- /package/{src → dist}/view/selection.d.ts +0 -0
- /package/{src → dist}/view/stylesmap.d.ts +0 -0
- /package/{src → dist}/view/text.d.ts +0 -0
- /package/{src → dist}/view/textproxy.d.ts +0 -0
- /package/{src → dist}/view/tokenlist.d.ts +0 -0
- /package/{src → dist}/view/treewalker.d.ts +0 -0
- /package/{src → dist}/view/typecheckable.d.ts +0 -0
- /package/{src → dist}/view/uielement.d.ts +0 -0
- /package/{src → dist}/view/upcastwriter.d.ts +0 -0
- /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
|
-
}
|