@ckeditor/ckeditor5-engine 36.0.1 → 37.0.0-alpha.1
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/README.md +1 -1
- package/package.json +25 -24
- package/src/controller/datacontroller.d.ts +331 -0
- package/src/controller/datacontroller.js +72 -116
- package/src/controller/editingcontroller.d.ts +98 -0
- package/src/controller/editingcontroller.js +22 -46
- package/src/conversion/conversion.d.ts +476 -0
- package/src/conversion/conversion.js +328 -347
- package/src/conversion/conversionhelpers.d.ts +26 -0
- package/src/conversion/conversionhelpers.js +1 -5
- package/src/conversion/downcastdispatcher.d.ts +547 -0
- package/src/conversion/downcastdispatcher.js +74 -152
- package/src/conversion/downcasthelpers.d.ts +1226 -0
- package/src/conversion/downcasthelpers.js +843 -762
- package/src/conversion/mapper.d.ts +503 -0
- package/src/conversion/mapper.js +84 -99
- package/src/conversion/modelconsumable.d.ts +201 -0
- package/src/conversion/modelconsumable.js +96 -99
- package/src/conversion/upcastdispatcher.d.ts +492 -0
- package/src/conversion/upcastdispatcher.js +73 -100
- package/src/conversion/upcasthelpers.d.ts +499 -0
- package/src/conversion/upcasthelpers.js +406 -373
- package/src/conversion/viewconsumable.d.ts +369 -0
- package/src/conversion/viewconsumable.js +139 -173
- package/src/dataprocessor/basichtmlwriter.d.ts +18 -0
- package/src/dataprocessor/basichtmlwriter.js +0 -9
- package/src/dataprocessor/dataprocessor.d.ts +61 -0
- package/src/dataprocessor/htmldataprocessor.d.ts +76 -0
- package/src/dataprocessor/htmldataprocessor.js +6 -28
- package/src/dataprocessor/htmlwriter.d.ts +16 -0
- package/src/dataprocessor/xmldataprocessor.d.ts +90 -0
- package/src/dataprocessor/xmldataprocessor.js +8 -40
- package/src/dev-utils/model.d.ts +124 -0
- package/src/dev-utils/model.js +41 -38
- package/src/dev-utils/operationreplayer.d.ts +51 -0
- package/src/dev-utils/operationreplayer.js +6 -14
- package/src/dev-utils/utils.d.ts +37 -0
- package/src/dev-utils/utils.js +5 -18
- package/src/dev-utils/view.d.ts +319 -0
- package/src/dev-utils/view.js +205 -226
- package/src/index.d.ts +108 -0
- package/src/index.js +4 -0
- package/src/model/batch.d.ts +106 -0
- package/src/model/differ.d.ts +329 -0
- package/src/model/document.d.ts +246 -0
- package/src/model/document.js +1 -1
- package/src/model/documentfragment.d.ts +196 -0
- package/src/model/documentfragment.js +2 -2
- package/src/model/documentselection.d.ts +420 -0
- package/src/model/element.d.ts +165 -0
- package/src/model/history.d.ts +114 -0
- package/src/model/item.d.ts +14 -0
- package/src/model/liveposition.d.ts +77 -0
- package/src/model/liverange.d.ts +102 -0
- package/src/model/markercollection.d.ts +335 -0
- package/src/model/model.d.ts +885 -0
- package/src/model/model.js +59 -81
- package/src/model/node.d.ts +256 -0
- package/src/model/nodelist.d.ts +91 -0
- package/src/model/operation/attributeoperation.d.ts +98 -0
- package/src/model/operation/detachoperation.d.ts +55 -0
- package/src/model/operation/insertoperation.d.ts +85 -0
- package/src/model/operation/markeroperation.d.ts +86 -0
- package/src/model/operation/mergeoperation.d.ts +95 -0
- package/src/model/operation/mergeoperation.js +1 -1
- package/src/model/operation/moveoperation.d.ts +91 -0
- package/src/model/operation/nooperation.d.ts +33 -0
- package/src/model/operation/operation.d.ts +89 -0
- package/src/model/operation/operationfactory.d.ts +18 -0
- package/src/model/operation/renameoperation.d.ts +78 -0
- package/src/model/operation/rootattributeoperation.d.ts +97 -0
- package/src/model/operation/rootattributeoperation.js +1 -1
- package/src/model/operation/splitoperation.d.ts +104 -0
- package/src/model/operation/splitoperation.js +1 -1
- package/src/model/operation/transform.d.ts +100 -0
- package/src/model/operation/utils.d.ts +71 -0
- package/src/model/operation/utils.js +1 -1
- package/src/model/position.d.ts +539 -0
- package/src/model/position.js +1 -1
- package/src/model/range.d.ts +458 -0
- package/src/model/range.js +1 -1
- package/src/model/rootelement.d.ts +40 -0
- package/src/model/schema.d.ts +1176 -0
- package/src/model/schema.js +19 -19
- package/src/model/selection.d.ts +472 -0
- package/src/model/text.d.ts +66 -0
- package/src/model/text.js +0 -2
- package/src/model/textproxy.d.ts +144 -0
- package/src/model/treewalker.d.ts +186 -0
- package/src/model/treewalker.js +19 -10
- package/src/model/typecheckable.d.ts +285 -0
- package/src/model/utils/autoparagraphing.d.ts +37 -0
- package/src/model/utils/deletecontent.d.ts +58 -0
- package/src/model/utils/findoptimalinsertionrange.d.ts +32 -0
- package/src/model/utils/getselectedcontent.d.ts +30 -0
- package/src/model/utils/insertcontent.d.ts +46 -0
- package/src/model/utils/insertcontent.js +2 -12
- package/src/model/utils/insertobject.d.ts +44 -0
- package/src/model/utils/insertobject.js +3 -14
- package/src/model/utils/modifyselection.d.ts +48 -0
- package/src/model/utils/selection-post-fixer.d.ts +65 -0
- package/src/model/writer.d.ts +823 -0
- package/src/model/writer.js +6 -61
- package/src/view/attributeelement.d.ts +108 -0
- package/src/view/attributeelement.js +25 -69
- package/src/view/containerelement.d.ts +49 -0
- package/src/view/containerelement.js +10 -43
- package/src/view/datatransfer.d.ts +75 -0
- package/src/view/document.d.ts +184 -0
- package/src/view/document.js +15 -84
- package/src/view/documentfragment.d.ts +149 -0
- package/src/view/documentfragment.js +39 -81
- package/src/view/documentselection.d.ts +306 -0
- package/src/view/documentselection.js +42 -143
- package/src/view/domconverter.d.ts +650 -0
- package/src/view/domconverter.js +157 -283
- package/src/view/downcastwriter.d.ts +996 -0
- package/src/view/downcastwriter.js +259 -426
- package/src/view/editableelement.d.ts +52 -0
- package/src/view/editableelement.js +9 -49
- package/src/view/element.d.ts +468 -0
- package/src/view/element.js +150 -222
- package/src/view/elementdefinition.d.ts +87 -0
- package/src/view/emptyelement.d.ts +41 -0
- package/src/view/emptyelement.js +11 -44
- package/src/view/filler.d.ts +111 -0
- package/src/view/filler.js +24 -21
- package/src/view/item.d.ts +14 -0
- package/src/view/matcher.d.ts +486 -0
- package/src/view/matcher.js +247 -218
- package/src/view/node.d.ts +163 -0
- package/src/view/node.js +26 -100
- package/src/view/observer/arrowkeysobserver.d.ts +41 -0
- package/src/view/observer/arrowkeysobserver.js +0 -13
- package/src/view/observer/bubblingemittermixin.d.ts +166 -0
- package/src/view/observer/bubblingemittermixin.js +36 -25
- package/src/view/observer/bubblingeventinfo.d.ts +47 -0
- package/src/view/observer/bubblingeventinfo.js +3 -29
- package/src/view/observer/clickobserver.d.ts +43 -0
- package/src/view/observer/clickobserver.js +9 -19
- package/src/view/observer/compositionobserver.d.ts +82 -0
- package/src/view/observer/compositionobserver.js +13 -42
- package/src/view/observer/domeventdata.d.ts +50 -0
- package/src/view/observer/domeventdata.js +5 -30
- package/src/view/observer/domeventobserver.d.ts +69 -0
- package/src/view/observer/domeventobserver.js +19 -21
- package/src/view/observer/fakeselectionobserver.d.ts +43 -0
- package/src/view/observer/fakeselectionobserver.js +0 -16
- package/src/view/observer/focusobserver.d.ts +82 -0
- package/src/view/observer/focusobserver.js +14 -40
- package/src/view/observer/inputobserver.d.ts +86 -0
- package/src/view/observer/inputobserver.js +18 -64
- package/src/view/observer/keyobserver.d.ts +66 -0
- package/src/view/observer/keyobserver.js +8 -42
- package/src/view/observer/mouseobserver.d.ts +89 -0
- package/src/view/observer/mouseobserver.js +8 -28
- package/src/view/observer/mutationobserver.d.ts +82 -0
- package/src/view/observer/mutationobserver.js +7 -37
- package/src/view/observer/observer.d.ts +84 -0
- package/src/view/observer/observer.js +12 -25
- package/src/view/observer/selectionobserver.d.ts +144 -0
- package/src/view/observer/selectionobserver.js +17 -107
- package/src/view/observer/tabobserver.d.ts +42 -0
- package/src/view/observer/tabobserver.js +0 -14
- package/src/view/placeholder.d.ts +85 -0
- package/src/view/placeholder.js +26 -43
- package/src/view/position.d.ts +189 -0
- package/src/view/position.js +36 -83
- package/src/view/range.d.ts +279 -0
- package/src/view/range.js +79 -122
- package/src/view/rawelement.d.ts +73 -0
- package/src/view/rawelement.js +34 -48
- package/src/view/renderer.d.ts +265 -0
- package/src/view/renderer.js +105 -193
- package/src/view/rooteditableelement.d.ts +41 -0
- package/src/view/rooteditableelement.js +12 -40
- package/src/view/selection.d.ts +375 -0
- package/src/view/selection.js +79 -153
- package/src/view/styles/background.d.ts +33 -0
- package/src/view/styles/background.js +14 -12
- package/src/view/styles/border.d.ts +43 -0
- package/src/view/styles/border.js +58 -48
- package/src/view/styles/margin.d.ts +29 -0
- package/src/view/styles/margin.js +13 -11
- package/src/view/styles/padding.d.ts +29 -0
- package/src/view/styles/padding.js +13 -11
- package/src/view/styles/utils.d.ts +93 -0
- package/src/view/styles/utils.js +22 -48
- package/src/view/stylesmap.d.ts +675 -0
- package/src/view/stylesmap.js +249 -244
- package/src/view/text.d.ts +74 -0
- package/src/view/text.js +16 -46
- package/src/view/textproxy.d.ts +97 -0
- package/src/view/textproxy.js +10 -59
- package/src/view/treewalker.d.ts +195 -0
- package/src/view/treewalker.js +43 -106
- package/src/view/typecheckable.d.ts +448 -0
- package/src/view/uielement.d.ts +96 -0
- package/src/view/uielement.js +29 -63
- package/src/view/upcastwriter.d.ts +417 -0
- package/src/view/upcastwriter.js +86 -157
- package/src/view/view.d.ts +417 -0
- package/src/view/view.js +47 -175
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module engine/model/operation/attributeoperation
|
|
7
|
+
*/
|
|
8
|
+
import Operation from './operation';
|
|
9
|
+
import Range from '../range';
|
|
10
|
+
import type Document from '../document';
|
|
11
|
+
/**
|
|
12
|
+
* Operation to change nodes' attribute.
|
|
13
|
+
*
|
|
14
|
+
* Using this class you can add, remove or change value of the attribute.
|
|
15
|
+
*/
|
|
16
|
+
export default class AttributeOperation extends Operation {
|
|
17
|
+
/**
|
|
18
|
+
* Range on which operation should be applied.
|
|
19
|
+
*
|
|
20
|
+
* @readonly
|
|
21
|
+
*/
|
|
22
|
+
range: Range;
|
|
23
|
+
/**
|
|
24
|
+
* Key of an attribute to change or remove.
|
|
25
|
+
*
|
|
26
|
+
* @readonly
|
|
27
|
+
*/
|
|
28
|
+
key: string;
|
|
29
|
+
/**
|
|
30
|
+
* Old value of the attribute with given key or `null`, if attribute was not set before.
|
|
31
|
+
*
|
|
32
|
+
* @readonly
|
|
33
|
+
*/
|
|
34
|
+
oldValue: unknown;
|
|
35
|
+
/**
|
|
36
|
+
* New value of the attribute with given key or `null`, if operation should remove attribute.
|
|
37
|
+
*
|
|
38
|
+
* @readonly
|
|
39
|
+
*/
|
|
40
|
+
newValue: unknown;
|
|
41
|
+
/**
|
|
42
|
+
* Creates an operation that changes, removes or adds attributes.
|
|
43
|
+
*
|
|
44
|
+
* If only `newValue` is set, attribute will be added on a node. Note that all nodes in operation's range must not
|
|
45
|
+
* have an attribute with the same key as the added attribute.
|
|
46
|
+
*
|
|
47
|
+
* If only `oldValue` is set, then attribute with given key will be removed. Note that all nodes in operation's range
|
|
48
|
+
* must have an attribute with that key added.
|
|
49
|
+
*
|
|
50
|
+
* If both `newValue` and `oldValue` are set, then the operation will change the attribute value. Note that all nodes in
|
|
51
|
+
* operation's ranges must already have an attribute with given key and `oldValue` as value
|
|
52
|
+
*
|
|
53
|
+
* @param range Range on which the operation should be applied. Must be a flat range.
|
|
54
|
+
* @param key Key of an attribute to change or remove.
|
|
55
|
+
* @param oldValue Old value of the attribute with given key or `null`, if attribute was not set before.
|
|
56
|
+
* @param newValue New value of the attribute with given key or `null`, if operation should remove attribute.
|
|
57
|
+
* @param baseVersion Document {@link module:engine/model/document~Document#version} on which operation
|
|
58
|
+
* can be applied or `null` if the operation operates on detached (non-document) tree.
|
|
59
|
+
*/
|
|
60
|
+
constructor(range: Range, key: string, oldValue: unknown, newValue: unknown, baseVersion: number | null);
|
|
61
|
+
/**
|
|
62
|
+
* @inheritDoc
|
|
63
|
+
*/
|
|
64
|
+
get type(): 'addAttribute' | 'removeAttribute' | 'changeAttribute';
|
|
65
|
+
/**
|
|
66
|
+
* Creates and returns an operation that has the same parameters as this operation.
|
|
67
|
+
*/
|
|
68
|
+
clone(): AttributeOperation;
|
|
69
|
+
/**
|
|
70
|
+
* See {@link module:engine/model/operation/operation~Operation#getReversed `Operation#getReversed()`}.
|
|
71
|
+
*/
|
|
72
|
+
getReversed(): Operation;
|
|
73
|
+
/**
|
|
74
|
+
* @inheritDoc
|
|
75
|
+
*/
|
|
76
|
+
toJSON(): unknown;
|
|
77
|
+
/**
|
|
78
|
+
* @inheritDoc
|
|
79
|
+
* @internal
|
|
80
|
+
*/
|
|
81
|
+
_validate(): void;
|
|
82
|
+
/**
|
|
83
|
+
* @inheritDoc
|
|
84
|
+
* @internal
|
|
85
|
+
*/
|
|
86
|
+
_execute(): void;
|
|
87
|
+
/**
|
|
88
|
+
* @inheritDoc
|
|
89
|
+
*/
|
|
90
|
+
static get className(): string;
|
|
91
|
+
/**
|
|
92
|
+
* Creates `AttributeOperation` object from deserilized object, i.e. from parsed JSON string.
|
|
93
|
+
*
|
|
94
|
+
* @param json Deserialized JSON object.
|
|
95
|
+
* @param document Document on which this operation will be applied.
|
|
96
|
+
*/
|
|
97
|
+
static fromJSON(json: any, document: Document): AttributeOperation;
|
|
98
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module engine/model/operation/detachoperation
|
|
7
|
+
*/
|
|
8
|
+
import Operation from './operation';
|
|
9
|
+
import type Position from '../position';
|
|
10
|
+
/**
|
|
11
|
+
* Operation to permanently remove node from detached root.
|
|
12
|
+
* Note this operation is only a local operation and won't be send to the other clients.
|
|
13
|
+
*/
|
|
14
|
+
export default class DetachOperation extends Operation {
|
|
15
|
+
/**
|
|
16
|
+
* Position before the first {@link module:engine/model/item~Item model item} to detach.
|
|
17
|
+
*/
|
|
18
|
+
sourcePosition: Position;
|
|
19
|
+
/**
|
|
20
|
+
* Offset size of moved range.
|
|
21
|
+
*/
|
|
22
|
+
howMany: number;
|
|
23
|
+
clone: never;
|
|
24
|
+
getReversed: never;
|
|
25
|
+
/**
|
|
26
|
+
* Creates an insert operation.
|
|
27
|
+
*
|
|
28
|
+
* @param sourcePosition Position before the first {@link module:engine/model/item~Item model item} to move.
|
|
29
|
+
* @param howMany Offset size of moved range. Moved range will start from `sourcePosition` and end at
|
|
30
|
+
* `sourcePosition` with offset shifted by `howMany`.
|
|
31
|
+
*/
|
|
32
|
+
constructor(sourcePosition: Position, howMany: number);
|
|
33
|
+
/**
|
|
34
|
+
* @inheritDoc
|
|
35
|
+
*/
|
|
36
|
+
get type(): 'detach';
|
|
37
|
+
/**
|
|
38
|
+
* @inheritDoc
|
|
39
|
+
*/
|
|
40
|
+
toJSON(): unknown;
|
|
41
|
+
/**
|
|
42
|
+
* @inheritDoc
|
|
43
|
+
* @internal
|
|
44
|
+
*/
|
|
45
|
+
_validate(): void;
|
|
46
|
+
/**
|
|
47
|
+
* @inheritDoc
|
|
48
|
+
* @internal
|
|
49
|
+
*/
|
|
50
|
+
_execute(): void;
|
|
51
|
+
/**
|
|
52
|
+
* @inheritDoc
|
|
53
|
+
*/
|
|
54
|
+
static get className(): string;
|
|
55
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module engine/model/operation/insertoperation
|
|
7
|
+
*/
|
|
8
|
+
import Operation from './operation';
|
|
9
|
+
import Position from '../position';
|
|
10
|
+
import NodeList from '../nodelist';
|
|
11
|
+
import { type NodeSet } from './utils';
|
|
12
|
+
import type Document from '../document';
|
|
13
|
+
/**
|
|
14
|
+
* Operation to insert one or more nodes at given position in the model.
|
|
15
|
+
*/
|
|
16
|
+
export default class InsertOperation extends Operation {
|
|
17
|
+
/**
|
|
18
|
+
* Position of insertion.
|
|
19
|
+
*
|
|
20
|
+
* @readonly
|
|
21
|
+
*/
|
|
22
|
+
position: Position;
|
|
23
|
+
/**
|
|
24
|
+
* List of nodes to insert.
|
|
25
|
+
*
|
|
26
|
+
* @readonly
|
|
27
|
+
*/
|
|
28
|
+
nodes: NodeList;
|
|
29
|
+
/**
|
|
30
|
+
* Flag deciding how the operation should be transformed. If set to `true`, nodes might get additional attributes
|
|
31
|
+
* during operational transformation. This happens when the operation insertion position is inside of a range
|
|
32
|
+
* where attributes have changed.
|
|
33
|
+
*/
|
|
34
|
+
shouldReceiveAttributes: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Creates an insert operation.
|
|
37
|
+
*
|
|
38
|
+
* @param position Position of insertion.
|
|
39
|
+
* @param nodes The list of nodes to be inserted.
|
|
40
|
+
* @param baseVersion Document {@link module:engine/model/document~Document#version} on which operation
|
|
41
|
+
* can be applied or `null` if the operation operates on detached (non-document) tree.
|
|
42
|
+
*/
|
|
43
|
+
constructor(position: Position, nodes: NodeSet, baseVersion: number | null);
|
|
44
|
+
/**
|
|
45
|
+
* @inheritDoc
|
|
46
|
+
*/
|
|
47
|
+
get type(): 'insert';
|
|
48
|
+
/**
|
|
49
|
+
* Total offset size of inserted nodes.
|
|
50
|
+
*/
|
|
51
|
+
get howMany(): number;
|
|
52
|
+
/**
|
|
53
|
+
* Creates and returns an operation that has the same parameters as this operation.
|
|
54
|
+
*/
|
|
55
|
+
clone(): InsertOperation;
|
|
56
|
+
/**
|
|
57
|
+
* See {@link module:engine/model/operation/operation~Operation#getReversed `Operation#getReversed()`}.
|
|
58
|
+
*/
|
|
59
|
+
getReversed(): Operation;
|
|
60
|
+
/**
|
|
61
|
+
* @inheritDoc
|
|
62
|
+
* @internal
|
|
63
|
+
*/
|
|
64
|
+
_validate(): void;
|
|
65
|
+
/**
|
|
66
|
+
* @inheritDoc
|
|
67
|
+
* @internal
|
|
68
|
+
*/
|
|
69
|
+
_execute(): void;
|
|
70
|
+
/**
|
|
71
|
+
* @inheritDoc
|
|
72
|
+
*/
|
|
73
|
+
toJSON(): unknown;
|
|
74
|
+
/**
|
|
75
|
+
* @inheritDoc
|
|
76
|
+
*/
|
|
77
|
+
static get className(): string;
|
|
78
|
+
/**
|
|
79
|
+
* Creates `InsertOperation` object from deserilized object, i.e. from parsed JSON string.
|
|
80
|
+
*
|
|
81
|
+
* @param json Deserialized JSON object.
|
|
82
|
+
* @param document Document on which this operation will be applied.
|
|
83
|
+
*/
|
|
84
|
+
static fromJSON(json: any, document: Document): InsertOperation;
|
|
85
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module engine/model/operation/markeroperation
|
|
7
|
+
*/
|
|
8
|
+
import Operation from './operation';
|
|
9
|
+
import Range from '../range';
|
|
10
|
+
import type Document from '../document';
|
|
11
|
+
import type MarkerCollection from '../markercollection';
|
|
12
|
+
export default class MarkerOperation extends Operation {
|
|
13
|
+
/**
|
|
14
|
+
* Marker name.
|
|
15
|
+
*
|
|
16
|
+
* @readonly
|
|
17
|
+
*/
|
|
18
|
+
name: string;
|
|
19
|
+
/**
|
|
20
|
+
* Marker range before the change.
|
|
21
|
+
*
|
|
22
|
+
* @readonly
|
|
23
|
+
*/
|
|
24
|
+
oldRange: Range | null;
|
|
25
|
+
/**
|
|
26
|
+
* Marker range after the change.
|
|
27
|
+
*
|
|
28
|
+
* @readonly
|
|
29
|
+
*/
|
|
30
|
+
newRange: Range | null;
|
|
31
|
+
/**
|
|
32
|
+
* Specifies whether the marker operation affects the data produced by the data pipeline
|
|
33
|
+
* (is persisted in the editor's data).
|
|
34
|
+
*
|
|
35
|
+
* @readonly
|
|
36
|
+
*/
|
|
37
|
+
affectsData: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Marker collection on which change should be executed.
|
|
40
|
+
*/
|
|
41
|
+
private readonly _markers;
|
|
42
|
+
/**
|
|
43
|
+
* @param name Marker name.
|
|
44
|
+
* @param oldRange Marker range before the change.
|
|
45
|
+
* @param newRange Marker range after the change.
|
|
46
|
+
* @param markers Marker collection on which change should be executed.
|
|
47
|
+
* @param affectsData Specifies whether the marker operation affects the data produced by the data pipeline
|
|
48
|
+
* (is persisted in the editor's data).
|
|
49
|
+
* @param baseVersion Document {@link module:engine/model/document~Document#version} on which operation
|
|
50
|
+
* can be applied or `null` if the operation operates on detached (non-document) tree.
|
|
51
|
+
*/
|
|
52
|
+
constructor(name: string, oldRange: Range | null, newRange: Range | null, markers: MarkerCollection, affectsData: boolean, baseVersion: number | null);
|
|
53
|
+
/**
|
|
54
|
+
* @inheritDoc
|
|
55
|
+
*/
|
|
56
|
+
get type(): 'marker';
|
|
57
|
+
/**
|
|
58
|
+
* Creates and returns an operation that has the same parameters as this operation.
|
|
59
|
+
*/
|
|
60
|
+
clone(): MarkerOperation;
|
|
61
|
+
/**
|
|
62
|
+
* See {@link module:engine/model/operation/operation~Operation#getReversed `Operation#getReversed()`}.
|
|
63
|
+
*/
|
|
64
|
+
getReversed(): Operation;
|
|
65
|
+
/**
|
|
66
|
+
* @inheritDoc
|
|
67
|
+
* @internal
|
|
68
|
+
*/
|
|
69
|
+
_execute(): void;
|
|
70
|
+
/**
|
|
71
|
+
* @inheritDoc
|
|
72
|
+
* @internal
|
|
73
|
+
*/
|
|
74
|
+
toJSON(): unknown;
|
|
75
|
+
/**
|
|
76
|
+
* @inheritDoc
|
|
77
|
+
*/
|
|
78
|
+
static get className(): string;
|
|
79
|
+
/**
|
|
80
|
+
* Creates `MarkerOperation` object from deserialized object, i.e. from parsed JSON string.
|
|
81
|
+
*
|
|
82
|
+
* @param json Deserialized JSON object.
|
|
83
|
+
* @param document Document on which this operation will be applied.
|
|
84
|
+
*/
|
|
85
|
+
static fromJSON(json: any, document: Document): MarkerOperation;
|
|
86
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module engine/model/operation/mergeoperation
|
|
7
|
+
*/
|
|
8
|
+
import Operation from './operation';
|
|
9
|
+
import Position from '../position';
|
|
10
|
+
import Range from '../range';
|
|
11
|
+
import type Document from '../document';
|
|
12
|
+
/**
|
|
13
|
+
* Operation to merge two {@link module:engine/model/element~Element elements}.
|
|
14
|
+
*
|
|
15
|
+
* The merged element is the parent of {@link ~MergeOperation#sourcePosition} and it is merged into the parent of
|
|
16
|
+
* {@link ~MergeOperation#targetPosition}. All nodes from the merged element are moved to {@link ~MergeOperation#targetPosition}.
|
|
17
|
+
*
|
|
18
|
+
* The merged element is moved to the graveyard at {@link ~MergeOperation#graveyardPosition}.
|
|
19
|
+
*/
|
|
20
|
+
export default class MergeOperation extends Operation {
|
|
21
|
+
/**
|
|
22
|
+
* Position inside the merged element. All nodes from that element after that position will be moved to {@link #targetPosition}.
|
|
23
|
+
*/
|
|
24
|
+
sourcePosition: Position;
|
|
25
|
+
/**
|
|
26
|
+
* Summary offset size of nodes which will be moved from the merged element to the new parent.
|
|
27
|
+
*/
|
|
28
|
+
howMany: number;
|
|
29
|
+
/**
|
|
30
|
+
* Position which the nodes from the merged elements will be moved to.
|
|
31
|
+
*/
|
|
32
|
+
targetPosition: Position;
|
|
33
|
+
/**
|
|
34
|
+
* Position in graveyard to which the merged element will be moved.
|
|
35
|
+
*/
|
|
36
|
+
graveyardPosition: Position;
|
|
37
|
+
/**
|
|
38
|
+
* Creates a merge operation.
|
|
39
|
+
*
|
|
40
|
+
* @param sourcePosition Position inside the merged element. All nodes from that
|
|
41
|
+
* element after that position will be moved to {@link #targetPosition}.
|
|
42
|
+
* @param howMany Summary offset size of nodes which will be moved from the merged element to the new parent.
|
|
43
|
+
* @param targetPosition Position which the nodes from the merged elements will be moved to.
|
|
44
|
+
* @param graveyardPosition Position in graveyard to which the merged element will be moved.
|
|
45
|
+
* @param baseVersion Document {@link module:engine/model/document~Document#version} on which operation
|
|
46
|
+
* can be applied or `null` if the operation operates on detached (non-document) tree.
|
|
47
|
+
*/
|
|
48
|
+
constructor(sourcePosition: Position, howMany: number, targetPosition: Position, graveyardPosition: Position, baseVersion: number | null);
|
|
49
|
+
/**
|
|
50
|
+
* @inheritDoc
|
|
51
|
+
*/
|
|
52
|
+
get type(): 'merge';
|
|
53
|
+
/**
|
|
54
|
+
* Position before the merged element (which will be deleted).
|
|
55
|
+
*/
|
|
56
|
+
get deletionPosition(): Position;
|
|
57
|
+
/**
|
|
58
|
+
* Artificial range that contains all the nodes from the merged element that will be moved to {@link ~MergeOperation#sourcePosition}.
|
|
59
|
+
* The range starts at {@link ~MergeOperation#sourcePosition} and ends in the same parent, at `POSITIVE_INFINITY` offset.
|
|
60
|
+
*/
|
|
61
|
+
get movedRange(): Range;
|
|
62
|
+
/**
|
|
63
|
+
* Creates and returns an operation that has the same parameters as this operation.
|
|
64
|
+
*/
|
|
65
|
+
clone(): MergeOperation;
|
|
66
|
+
/**
|
|
67
|
+
* See {@link module:engine/model/operation/operation~Operation#getReversed `Operation#getReversed()`}.
|
|
68
|
+
*/
|
|
69
|
+
getReversed(): Operation;
|
|
70
|
+
/**
|
|
71
|
+
* @inheritDoc
|
|
72
|
+
* @internal
|
|
73
|
+
*/
|
|
74
|
+
_validate(): void;
|
|
75
|
+
/**
|
|
76
|
+
* @inheritDoc
|
|
77
|
+
* @internal
|
|
78
|
+
*/
|
|
79
|
+
_execute(): void;
|
|
80
|
+
/**
|
|
81
|
+
* @inheritDoc
|
|
82
|
+
*/
|
|
83
|
+
toJSON(): unknown;
|
|
84
|
+
/**
|
|
85
|
+
* @inheritDoc
|
|
86
|
+
*/
|
|
87
|
+
static get className(): string;
|
|
88
|
+
/**
|
|
89
|
+
* Creates `MergeOperation` object from deserilized object, i.e. from parsed JSON string.
|
|
90
|
+
*
|
|
91
|
+
* @param json Deserialized JSON object.
|
|
92
|
+
* @param document Document on which this operation will be applied.
|
|
93
|
+
*/
|
|
94
|
+
static fromJSON(json: any, document: Document): MergeOperation;
|
|
95
|
+
}
|
|
@@ -24,7 +24,7 @@ export default class MergeOperation extends Operation {
|
|
|
24
24
|
* Creates a merge operation.
|
|
25
25
|
*
|
|
26
26
|
* @param sourcePosition Position inside the merged element. All nodes from that
|
|
27
|
-
* element after that position will be moved to {@link
|
|
27
|
+
* element after that position will be moved to {@link #targetPosition}.
|
|
28
28
|
* @param howMany Summary offset size of nodes which will be moved from the merged element to the new parent.
|
|
29
29
|
* @param targetPosition Position which the nodes from the merged elements will be moved to.
|
|
30
30
|
* @param graveyardPosition Position in graveyard to which the merged element will be moved.
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module engine/model/operation/moveoperation
|
|
7
|
+
*/
|
|
8
|
+
import Operation from './operation';
|
|
9
|
+
import Position from '../position';
|
|
10
|
+
import type Document from '../document';
|
|
11
|
+
/**
|
|
12
|
+
* Operation to move a range of {@link module:engine/model/item~Item model items}
|
|
13
|
+
* to given {@link module:engine/model/position~Position target position}.
|
|
14
|
+
*/
|
|
15
|
+
export default class MoveOperation extends Operation {
|
|
16
|
+
/**
|
|
17
|
+
* Position before the first {@link module:engine/model/item~Item model item} to move.
|
|
18
|
+
*/
|
|
19
|
+
sourcePosition: Position;
|
|
20
|
+
/**
|
|
21
|
+
* Offset size of moved range.
|
|
22
|
+
*/
|
|
23
|
+
howMany: number;
|
|
24
|
+
/**
|
|
25
|
+
* Position at which moved nodes will be inserted.
|
|
26
|
+
*/
|
|
27
|
+
targetPosition: Position;
|
|
28
|
+
/**
|
|
29
|
+
* Creates a move operation.
|
|
30
|
+
*
|
|
31
|
+
* @param sourcePosition Position before the first {@link module:engine/model/item~Item model item} to move.
|
|
32
|
+
* @param howMany Offset size of moved range. Moved range will start from `sourcePosition` and end at
|
|
33
|
+
* `sourcePosition` with offset shifted by `howMany`.
|
|
34
|
+
* @param targetPosition Position at which moved nodes will be inserted.
|
|
35
|
+
* @param baseVersion Document {@link module:engine/model/document~Document#version} on which operation
|
|
36
|
+
* can be applied or `null` if the operation operates on detached (non-document) tree.
|
|
37
|
+
*/
|
|
38
|
+
constructor(sourcePosition: Position, howMany: number, targetPosition: Position, baseVersion: number | null);
|
|
39
|
+
/**
|
|
40
|
+
* @inheritDoc
|
|
41
|
+
*/
|
|
42
|
+
get type(): 'move' | 'remove' | 'reinsert';
|
|
43
|
+
/**
|
|
44
|
+
* Creates and returns an operation that has the same parameters as this operation.
|
|
45
|
+
*/
|
|
46
|
+
clone(): MoveOperation;
|
|
47
|
+
/**
|
|
48
|
+
* Returns the start position of the moved range after it got moved. This may be different than
|
|
49
|
+
* {@link module:engine/model/operation/moveoperation~MoveOperation#targetPosition} in some cases, i.e. when a range is moved
|
|
50
|
+
* inside the same parent but {@link module:engine/model/operation/moveoperation~MoveOperation#targetPosition targetPosition}
|
|
51
|
+
* is after {@link module:engine/model/operation/moveoperation~MoveOperation#sourcePosition sourcePosition}.
|
|
52
|
+
*
|
|
53
|
+
* ```
|
|
54
|
+
* vv vv
|
|
55
|
+
* abcdefg ===> adefbcg
|
|
56
|
+
* ^ ^
|
|
57
|
+
* targetPos movedRangeStart
|
|
58
|
+
* offset 6 offset 4
|
|
59
|
+
*```
|
|
60
|
+
*/
|
|
61
|
+
getMovedRangeStart(): Position;
|
|
62
|
+
/**
|
|
63
|
+
* See {@link module:engine/model/operation/operation~Operation#getReversed `Operation#getReversed()`}.
|
|
64
|
+
*/
|
|
65
|
+
getReversed(): Operation;
|
|
66
|
+
/**
|
|
67
|
+
* @inheritDoc
|
|
68
|
+
* @internal
|
|
69
|
+
*/
|
|
70
|
+
_validate(): void;
|
|
71
|
+
/**
|
|
72
|
+
* @inheritDoc
|
|
73
|
+
* @internal
|
|
74
|
+
*/
|
|
75
|
+
_execute(): void;
|
|
76
|
+
/**
|
|
77
|
+
* @inheritDoc
|
|
78
|
+
*/
|
|
79
|
+
toJSON(): unknown;
|
|
80
|
+
/**
|
|
81
|
+
* @inheritDoc
|
|
82
|
+
*/
|
|
83
|
+
static get className(): string;
|
|
84
|
+
/**
|
|
85
|
+
* Creates `MoveOperation` object from deserilized object, i.e. from parsed JSON string.
|
|
86
|
+
*
|
|
87
|
+
* @param json Deserialized JSON object.
|
|
88
|
+
* @param document Document on which this operation will be applied.
|
|
89
|
+
*/
|
|
90
|
+
static fromJSON(json: any, document: Document): MoveOperation;
|
|
91
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module engine/model/operation/nooperation
|
|
7
|
+
*/
|
|
8
|
+
import Operation from './operation';
|
|
9
|
+
/**
|
|
10
|
+
* Operation which is doing nothing ("empty operation", "do-nothing operation", "noop"). This is an operation,
|
|
11
|
+
* which when executed does not change the tree model. It still has some parameters defined for transformation purposes.
|
|
12
|
+
*
|
|
13
|
+
* In most cases this operation is a result of transforming operations. When transformation returns
|
|
14
|
+
* {@link module:engine/model/operation/nooperation~NoOperation} it means that changes done by the transformed operation
|
|
15
|
+
* have already been applied.
|
|
16
|
+
*/
|
|
17
|
+
export default class NoOperation extends Operation {
|
|
18
|
+
get type(): 'noop';
|
|
19
|
+
/**
|
|
20
|
+
* Creates and returns an operation that has the same parameters as this operation.
|
|
21
|
+
*/
|
|
22
|
+
clone(): NoOperation;
|
|
23
|
+
/**
|
|
24
|
+
* See {@link module:engine/model/operation/operation~Operation#getReversed `Operation#getReversed()`}.
|
|
25
|
+
*/
|
|
26
|
+
getReversed(): Operation;
|
|
27
|
+
/** @internal */
|
|
28
|
+
_execute(): void;
|
|
29
|
+
/**
|
|
30
|
+
* @inheritDoc
|
|
31
|
+
*/
|
|
32
|
+
static get className(): string;
|
|
33
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
import type Batch from '../batch';
|
|
6
|
+
import type Document from '../document';
|
|
7
|
+
/**
|
|
8
|
+
* @module engine/model/operation/operation
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Abstract base operation class.
|
|
12
|
+
*/
|
|
13
|
+
export default abstract class Operation {
|
|
14
|
+
/**
|
|
15
|
+
* {@link module:engine/model/document~Document#version} on which operation can be applied. If you try to
|
|
16
|
+
* {@link module:engine/model/model~Model#applyOperation apply} operation with different base version than the
|
|
17
|
+
* {@link module:engine/model/document~Document#version document version} the
|
|
18
|
+
* {@link module:utils/ckeditorerror~CKEditorError model-document-applyOperation-wrong-version} error is thrown.
|
|
19
|
+
*/
|
|
20
|
+
baseVersion: number | null;
|
|
21
|
+
/**
|
|
22
|
+
* Defines whether operation is executed on attached or detached {@link module:engine/model/item~Item items}.
|
|
23
|
+
*/
|
|
24
|
+
readonly isDocumentOperation: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* {@link module:engine/model/batch~Batch Batch} to which the operation is added or `null` if the operation is not
|
|
27
|
+
* added to any batch yet.
|
|
28
|
+
*/
|
|
29
|
+
batch: Batch | null;
|
|
30
|
+
/**
|
|
31
|
+
* Operation type.
|
|
32
|
+
*/
|
|
33
|
+
abstract readonly type: string;
|
|
34
|
+
/**
|
|
35
|
+
* Base operation constructor.
|
|
36
|
+
*
|
|
37
|
+
* @param baseVersion Document {@link module:engine/model/document~Document#version} on which operation
|
|
38
|
+
* can be applied or `null` if the operation operates on detached (non-document) tree.
|
|
39
|
+
*/
|
|
40
|
+
constructor(baseVersion: number | null);
|
|
41
|
+
/**
|
|
42
|
+
* Creates and returns an operation that has the same parameters as this operation.
|
|
43
|
+
*
|
|
44
|
+
* @returns Clone of this operation.
|
|
45
|
+
*/
|
|
46
|
+
abstract clone(): Operation;
|
|
47
|
+
/**
|
|
48
|
+
* Creates and returns a reverse operation. Reverse operation when executed right after
|
|
49
|
+
* the original operation will bring back tree model state to the point before the original
|
|
50
|
+
* operation execution. In other words, it reverses changes done by the original operation.
|
|
51
|
+
*
|
|
52
|
+
* Keep in mind that tree model state may change since executing the original operation,
|
|
53
|
+
* so reverse operation will be "outdated". In that case you will need to transform it by
|
|
54
|
+
* all operations that were executed after the original operation.
|
|
55
|
+
*
|
|
56
|
+
* @returns Reversed operation.
|
|
57
|
+
*/
|
|
58
|
+
abstract getReversed(): Operation;
|
|
59
|
+
/**
|
|
60
|
+
* Executes the operation - modifications described by the operation properties will be applied to the model tree.
|
|
61
|
+
*
|
|
62
|
+
* @internal
|
|
63
|
+
*/
|
|
64
|
+
abstract _execute(): void;
|
|
65
|
+
/**
|
|
66
|
+
* Checks whether the operation's parameters are correct and the operation can be correctly executed. Throws
|
|
67
|
+
* an error if operation is not valid.
|
|
68
|
+
*
|
|
69
|
+
* @internal
|
|
70
|
+
*/
|
|
71
|
+
_validate(): void;
|
|
72
|
+
/**
|
|
73
|
+
* Custom toJSON method to solve child-parent circular dependencies.
|
|
74
|
+
*
|
|
75
|
+
* @returns Clone of this object with the operation property replaced with string.
|
|
76
|
+
*/
|
|
77
|
+
toJSON(): unknown;
|
|
78
|
+
/**
|
|
79
|
+
* Name of the operation class used for serialization.
|
|
80
|
+
*/
|
|
81
|
+
static get className(): string;
|
|
82
|
+
/**
|
|
83
|
+
* Creates Operation object from deserilized object, i.e. from parsed JSON string.
|
|
84
|
+
*
|
|
85
|
+
* @param json Deserialized JSON object.
|
|
86
|
+
* @param doc Document on which this operation will be applied.
|
|
87
|
+
*/
|
|
88
|
+
static fromJSON(json: any, document: Document): Operation;
|
|
89
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
import Operation from './operation';
|
|
6
|
+
import type Document from '../document';
|
|
7
|
+
/**
|
|
8
|
+
* A factory class for creating operations.
|
|
9
|
+
*/
|
|
10
|
+
export default abstract class OperationFactory {
|
|
11
|
+
/**
|
|
12
|
+
* Creates an operation instance from a JSON object (parsed JSON string).
|
|
13
|
+
*
|
|
14
|
+
* @param json Deserialized JSON object.
|
|
15
|
+
* @param document Document on which this operation will be applied.
|
|
16
|
+
*/
|
|
17
|
+
static fromJSON(json: any, document: Document): Operation;
|
|
18
|
+
}
|