@ckeditor/ckeditor5-engine 45.2.1-alpha.9 → 46.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/dist/index.js +2563 -2257
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/controller/datacontroller.d.ts +33 -32
- package/src/controller/datacontroller.js +29 -28
- package/src/controller/editingcontroller.d.ts +8 -8
- package/src/controller/editingcontroller.js +10 -10
- package/src/conversion/conversion.d.ts +18 -19
- package/src/conversion/conversion.js +4 -4
- package/src/conversion/conversionhelpers.d.ts +1 -1
- package/src/conversion/conversionhelpers.js +1 -1
- package/src/conversion/downcastdispatcher.d.ts +63 -69
- package/src/conversion/downcastdispatcher.js +16 -16
- package/src/conversion/downcasthelpers.d.ts +94 -83
- package/src/conversion/downcasthelpers.js +63 -53
- package/src/conversion/mapper.d.ts +27 -27
- package/src/conversion/mapper.js +15 -15
- package/src/conversion/modelconsumable.d.ts +26 -26
- package/src/conversion/modelconsumable.js +23 -23
- package/src/conversion/upcastdispatcher.d.ts +33 -32
- package/src/conversion/upcastdispatcher.js +19 -19
- package/src/conversion/upcasthelpers.d.ts +46 -38
- package/src/conversion/upcasthelpers.js +33 -24
- package/src/conversion/viewconsumable.d.ts +50 -45
- package/src/conversion/viewconsumable.js +32 -27
- package/src/dataprocessor/basichtmlwriter.d.ts +4 -2
- package/src/dataprocessor/basichtmlwriter.js +3 -1
- package/src/dataprocessor/dataprocessor.d.ts +7 -6
- package/src/dataprocessor/htmldataprocessor.d.ts +10 -10
- package/src/dataprocessor/htmldataprocessor.js +6 -6
- package/src/dataprocessor/htmlwriter.d.ts +1 -1
- package/src/dataprocessor/xmldataprocessor.d.ts +10 -10
- package/src/dataprocessor/xmldataprocessor.js +6 -6
- package/src/dev-utils/model.d.ts +25 -26
- package/src/dev-utils/model.js +35 -36
- package/src/dev-utils/operationreplayer.d.ts +5 -3
- package/src/dev-utils/operationreplayer.js +4 -2
- package/src/dev-utils/utils.d.ts +8 -0
- package/src/dev-utils/utils.js +8 -0
- package/src/dev-utils/view.d.ts +66 -63
- package/src/dev-utils/view.js +144 -134
- package/src/index.d.ts +135 -106
- package/src/index.js +120 -71
- package/src/legacyerrors.d.ts +5 -0
- package/src/legacyerrors.js +17 -0
- package/src/model/batch.d.ts +2 -15
- package/src/model/batch.js +1 -23
- package/src/model/differ.d.ts +54 -31
- package/src/model/differ.js +15 -15
- package/src/model/document.d.ts +31 -31
- package/src/model/document.js +13 -13
- package/src/model/documentfragment.d.ts +45 -45
- package/src/model/documentfragment.js +40 -40
- package/src/model/documentselection.d.ts +92 -92
- package/src/model/documentselection.js +71 -70
- package/src/model/element.d.ts +31 -31
- package/src/model/element.js +29 -29
- package/src/model/history.d.ts +3 -3
- package/src/model/history.js +2 -2
- package/src/model/item.d.ts +4 -5
- package/src/model/liveposition.d.ts +31 -31
- package/src/model/liveposition.js +18 -18
- package/src/model/liverange.d.ts +42 -38
- package/src/model/liverange.js +17 -16
- package/src/model/markercollection.d.ts +41 -40
- package/src/model/markercollection.js +22 -20
- package/src/model/model.d.ts +82 -81
- package/src/model/model.js +54 -54
- package/src/model/node.d.ts +48 -48
- package/src/model/node.js +31 -31
- package/src/model/nodelist.d.ts +17 -17
- package/src/model/nodelist.js +11 -11
- package/src/model/operation/attributeoperation.d.ts +10 -10
- package/src/model/operation/attributeoperation.js +7 -7
- package/src/model/operation/detachoperation.d.ts +11 -9
- package/src/model/operation/detachoperation.js +8 -6
- package/src/model/operation/insertoperation.d.ts +13 -13
- package/src/model/operation/insertoperation.js +15 -15
- package/src/model/operation/markeroperation.d.ts +12 -12
- package/src/model/operation/markeroperation.js +5 -5
- package/src/model/operation/mergeoperation.d.ts +16 -16
- package/src/model/operation/mergeoperation.js +18 -18
- package/src/model/operation/moveoperation.d.ts +16 -16
- package/src/model/operation/moveoperation.js +18 -15
- package/src/model/operation/nooperation.d.ts +4 -4
- package/src/model/operation/nooperation.js +2 -2
- package/src/model/operation/operation.d.ts +10 -10
- package/src/model/operation/operation.js +5 -5
- package/src/model/operation/operationfactory.d.ts +4 -4
- package/src/model/operation/operationfactory.js +12 -12
- package/src/model/operation/renameoperation.d.ts +10 -10
- package/src/model/operation/renameoperation.js +7 -7
- package/src/model/operation/rootattributeoperation.d.ts +12 -12
- package/src/model/operation/rootattributeoperation.js +8 -8
- package/src/model/operation/rootoperation.d.ts +8 -8
- package/src/model/operation/rootoperation.js +3 -3
- package/src/model/operation/splitoperation.d.ts +17 -17
- package/src/model/operation/splitoperation.js +19 -19
- package/src/model/operation/transform.d.ts +11 -8
- package/src/model/operation/transform.js +66 -49
- package/src/model/operation/utils.d.ts +24 -23
- package/src/model/operation/utils.js +20 -20
- package/src/model/position.d.ts +101 -97
- package/src/model/position.js +69 -64
- package/src/model/range.d.ts +90 -90
- package/src/model/range.js +87 -87
- package/src/model/rootelement.d.ts +11 -11
- package/src/model/rootelement.js +9 -9
- package/src/model/schema.d.ts +158 -154
- package/src/model/schema.js +93 -90
- package/src/model/selection.d.ts +73 -73
- package/src/model/selection.js +62 -62
- package/src/model/text.d.ts +11 -10
- package/src/model/text.js +11 -10
- package/src/model/textproxy.d.ts +39 -38
- package/src/model/textproxy.js +31 -30
- package/src/model/treewalker.d.ts +37 -37
- package/src/model/treewalker.js +14 -14
- package/src/model/typecheckable.d.ts +45 -45
- package/src/model/typecheckable.js +1 -1
- package/src/model/utils/autoparagraphing.d.ts +7 -7
- package/src/model/utils/deletecontent.d.ts +7 -5
- package/src/model/utils/deletecontent.js +13 -11
- package/src/model/utils/getselectedcontent.d.ts +6 -5
- package/src/model/utils/getselectedcontent.js +2 -1
- package/src/model/utils/insertcontent.d.ts +9 -8
- package/src/model/utils/insertcontent.js +41 -40
- package/src/model/utils/insertobject.d.ts +9 -9
- package/src/model/utils/insertobject.js +4 -4
- package/src/model/utils/modifyselection.d.ts +5 -4
- package/src/model/utils/modifyselection.js +12 -11
- package/src/model/utils/selection-post-fixer.d.ts +12 -8
- package/src/model/utils/selection-post-fixer.js +15 -11
- package/src/model/writer.d.ts +102 -101
- package/src/model/writer.js +99 -98
- package/src/view/attributeelement.d.ts +29 -29
- package/src/view/attributeelement.js +25 -25
- package/src/view/containerelement.d.ts +16 -15
- package/src/view/containerelement.js +15 -14
- package/src/view/datatransfer.d.ts +7 -7
- package/src/view/datatransfer.js +1 -1
- package/src/view/document.d.ts +25 -25
- package/src/view/document.js +15 -15
- package/src/view/documentfragment.d.ts +21 -21
- package/src/view/documentfragment.js +14 -14
- package/src/view/documentselection.d.ts +65 -63
- package/src/view/documentselection.js +27 -25
- package/src/view/domconverter.d.ts +94 -89
- package/src/view/domconverter.js +78 -73
- package/src/view/downcastwriter.d.ts +185 -181
- package/src/view/downcastwriter.js +222 -210
- package/src/view/editableelement.d.ts +13 -13
- package/src/view/editableelement.js +8 -8
- package/src/view/element.d.ts +75 -74
- package/src/view/element.js +58 -58
- package/src/view/elementdefinition.d.ts +3 -4
- package/src/view/emptyelement.d.ts +13 -13
- package/src/view/emptyelement.js +13 -13
- package/src/view/filler.d.ts +14 -3
- package/src/view/filler.js +12 -1
- package/src/view/item.d.ts +4 -5
- package/src/view/matcher.d.ts +22 -19
- package/src/view/matcher.js +6 -6
- package/src/view/node.d.ts +33 -33
- package/src/view/node.js +9 -9
- package/src/view/observer/arrowkeysobserver.d.ts +10 -10
- package/src/view/observer/arrowkeysobserver.js +5 -5
- package/src/view/observer/bubblingemittermixin.d.ts +5 -5
- package/src/view/observer/bubblingemittermixin.js +2 -9
- package/src/view/observer/bubblingeventinfo.d.ts +9 -9
- package/src/view/observer/bubblingeventinfo.js +1 -1
- package/src/view/observer/clickobserver.d.ts +8 -8
- package/src/view/observer/clickobserver.js +4 -4
- package/src/view/observer/compositionobserver.d.ts +19 -19
- package/src/view/observer/compositionobserver.js +6 -6
- package/src/view/observer/domeventdata.d.ts +9 -9
- package/src/view/observer/domeventdata.js +2 -2
- package/src/view/observer/domeventobserver.d.ts +3 -3
- package/src/view/observer/domeventobserver.js +5 -5
- package/src/view/observer/fakeselectionobserver.d.ts +9 -9
- package/src/view/observer/fakeselectionobserver.js +8 -8
- package/src/view/observer/focusobserver.d.ts +16 -16
- package/src/view/observer/focusobserver.js +7 -7
- package/src/view/observer/inputobserver.d.ts +18 -18
- package/src/view/observer/inputobserver.js +5 -5
- package/src/view/observer/keyobserver.d.ts +11 -11
- package/src/view/observer/keyobserver.js +3 -3
- package/src/view/observer/mouseobserver.d.ts +16 -16
- package/src/view/observer/mouseobserver.js +3 -3
- package/src/view/observer/mutationobserver.d.ts +21 -21
- package/src/view/observer/mutationobserver.js +7 -7
- package/src/view/observer/observer.d.ts +12 -12
- package/src/view/observer/observer.js +6 -6
- package/src/view/observer/selectionobserver.d.ts +33 -33
- package/src/view/observer/selectionobserver.js +14 -14
- package/src/view/observer/tabobserver.d.ts +10 -10
- package/src/view/observer/tabobserver.js +5 -5
- package/src/view/observer/touchobserver.d.ts +13 -13
- package/src/view/observer/touchobserver.js +3 -3
- package/src/view/placeholder.d.ts +21 -21
- package/src/view/placeholder.js +23 -23
- package/src/view/position.d.ts +49 -49
- package/src/view/position.js +42 -42
- package/src/view/range.d.ts +76 -74
- package/src/view/range.js +67 -65
- package/src/view/rawelement.d.ts +19 -19
- package/src/view/rawelement.js +16 -16
- package/src/view/renderer.d.ts +14 -14
- package/src/view/renderer.js +7 -7
- package/src/view/rooteditableelement.d.ts +8 -7
- package/src/view/rooteditableelement.js +7 -6
- package/src/view/selection.d.ts +66 -64
- package/src/view/selection.js +50 -48
- package/src/view/styles/background.d.ts +2 -2
- package/src/view/styles/background.js +9 -9
- package/src/view/styles/border.d.ts +2 -2
- package/src/view/styles/border.js +13 -13
- package/src/view/styles/margin.d.ts +2 -2
- package/src/view/styles/margin.js +5 -5
- package/src/view/styles/padding.d.ts +2 -2
- package/src/view/styles/padding.js +5 -5
- package/src/view/styles/utils.d.ts +24 -24
- package/src/view/styles/utils.js +25 -25
- package/src/view/stylesmap.d.ts +28 -32
- package/src/view/stylesmap.js +52 -39
- package/src/view/text.d.ts +11 -11
- package/src/view/text.js +10 -10
- package/src/view/textproxy.d.ts +33 -32
- package/src/view/textproxy.js +23 -22
- package/src/view/tokenlist.d.ts +14 -14
- package/src/view/tokenlist.js +10 -10
- package/src/view/treewalker.d.ts +42 -40
- package/src/view/treewalker.js +36 -35
- package/src/view/typecheckable.d.ts +76 -75
- package/src/view/typecheckable.js +1 -1
- package/src/view/uielement.d.ts +22 -21
- package/src/view/uielement.js +17 -16
- package/src/view/upcastwriter.d.ts +70 -70
- package/src/view/upcastwriter.js +42 -42
- package/src/view/view.d.ts +70 -69
- package/src/view/view.js +56 -55
package/src/model/writer.js
CHANGED
|
@@ -5,23 +5,23 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module engine/model/writer
|
|
7
7
|
*/
|
|
8
|
-
import AttributeOperation from './operation/attributeoperation.js';
|
|
9
|
-
import DetachOperation from './operation/detachoperation.js';
|
|
10
|
-
import InsertOperation from './operation/insertoperation.js';
|
|
11
|
-
import MarkerOperation from './operation/markeroperation.js';
|
|
12
|
-
import MergeOperation from './operation/mergeoperation.js';
|
|
13
|
-
import MoveOperation from './operation/moveoperation.js';
|
|
14
|
-
import RenameOperation from './operation/renameoperation.js';
|
|
15
|
-
import RootAttributeOperation from './operation/rootattributeoperation.js';
|
|
16
|
-
import RootOperation from './operation/rootoperation.js';
|
|
17
|
-
import SplitOperation from './operation/splitoperation.js';
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import
|
|
22
|
-
import
|
|
23
|
-
import
|
|
24
|
-
import
|
|
8
|
+
import { AttributeOperation } from './operation/attributeoperation.js';
|
|
9
|
+
import { DetachOperation } from './operation/detachoperation.js';
|
|
10
|
+
import { InsertOperation } from './operation/insertoperation.js';
|
|
11
|
+
import { MarkerOperation } from './operation/markeroperation.js';
|
|
12
|
+
import { MergeOperation } from './operation/mergeoperation.js';
|
|
13
|
+
import { MoveOperation } from './operation/moveoperation.js';
|
|
14
|
+
import { RenameOperation } from './operation/renameoperation.js';
|
|
15
|
+
import { RootAttributeOperation } from './operation/rootattributeoperation.js';
|
|
16
|
+
import { RootOperation } from './operation/rootoperation.js';
|
|
17
|
+
import { SplitOperation } from './operation/splitoperation.js';
|
|
18
|
+
import { ModelDocumentFragment } from './documentfragment.js';
|
|
19
|
+
import { ModelDocumentSelection } from './documentselection.js';
|
|
20
|
+
import { ModelElement } from './element.js';
|
|
21
|
+
import { ModelPosition } from './position.js';
|
|
22
|
+
import { ModelRange } from './range.js';
|
|
23
|
+
import { ModelRootElement } from './rootelement.js';
|
|
24
|
+
import { ModelText } from './text.js';
|
|
25
25
|
import { CKEditorError, logWarning, toMap } from '@ckeditor/ckeditor5-utils';
|
|
26
26
|
/**
|
|
27
27
|
* The model can only be modified by using the writer. It should be used whenever you want to create a node, modify
|
|
@@ -39,14 +39,14 @@ import { CKEditorError, logWarning, toMap } from '@ckeditor/ckeditor5-utils';
|
|
|
39
39
|
* Note that the writer should never be stored and used outside of the `change()` and
|
|
40
40
|
* `enqueueChange()` blocks.
|
|
41
41
|
*
|
|
42
|
-
* Note that writer's methods do not check the {@link module:engine/model/schema~
|
|
42
|
+
* Note that writer's methods do not check the {@link module:engine/model/schema~ModelSchema}. It is possible
|
|
43
43
|
* to create incorrect model structures by using the writer. Read more about in
|
|
44
44
|
* {@glink framework/deep-dive/schema#who-checks-the-schema "Who checks the schema?"}.
|
|
45
45
|
*
|
|
46
46
|
* @see module:engine/model/model~Model#change
|
|
47
47
|
* @see module:engine/model/model~Model#enqueueChange
|
|
48
48
|
*/
|
|
49
|
-
export
|
|
49
|
+
export class ModelWriter {
|
|
50
50
|
/**
|
|
51
51
|
* Instance of the model on which this writer operates.
|
|
52
52
|
*/
|
|
@@ -68,7 +68,7 @@ export default class Writer {
|
|
|
68
68
|
this.batch = batch;
|
|
69
69
|
}
|
|
70
70
|
/**
|
|
71
|
-
* Creates a new {@link module:engine/model/text~
|
|
71
|
+
* Creates a new {@link module:engine/model/text~ModelText text node}.
|
|
72
72
|
*
|
|
73
73
|
* ```ts
|
|
74
74
|
* writer.createText( 'foo' );
|
|
@@ -77,13 +77,13 @@ export default class Writer {
|
|
|
77
77
|
*
|
|
78
78
|
* @param data Text data.
|
|
79
79
|
* @param attributes Text attributes.
|
|
80
|
-
* @returns {module:engine/model/text~
|
|
80
|
+
* @returns {module:engine/model/text~ModelText} Created text node.
|
|
81
81
|
*/
|
|
82
82
|
createText(data, attributes) {
|
|
83
|
-
return new
|
|
83
|
+
return new ModelText(data, attributes);
|
|
84
84
|
}
|
|
85
85
|
/**
|
|
86
|
-
* Creates a new {@link module:engine/model/element~
|
|
86
|
+
* Creates a new {@link module:engine/model/element~ModelElement element}.
|
|
87
87
|
*
|
|
88
88
|
* ```ts
|
|
89
89
|
* writer.createElement( 'paragraph' );
|
|
@@ -95,15 +95,15 @@ export default class Writer {
|
|
|
95
95
|
* @returns Created element.
|
|
96
96
|
*/
|
|
97
97
|
createElement(name, attributes) {
|
|
98
|
-
return new
|
|
98
|
+
return new ModelElement(name, attributes);
|
|
99
99
|
}
|
|
100
100
|
/**
|
|
101
|
-
* Creates a new {@link module:engine/model/documentfragment~
|
|
101
|
+
* Creates a new {@link module:engine/model/documentfragment~ModelDocumentFragment document fragment}.
|
|
102
102
|
*
|
|
103
103
|
* @returns Created document fragment.
|
|
104
104
|
*/
|
|
105
105
|
createDocumentFragment() {
|
|
106
|
-
return new
|
|
106
|
+
return new ModelDocumentFragment();
|
|
107
107
|
}
|
|
108
108
|
/**
|
|
109
109
|
* Creates a copy of the element and returns it. Created element has the same name and attributes as the original element.
|
|
@@ -152,27 +152,27 @@ export default class Writer {
|
|
|
152
152
|
* Note that you cannot re-insert a node from a document to a different document or a document fragment. In this case,
|
|
153
153
|
* `model-writer-insert-forbidden-move` is thrown.
|
|
154
154
|
*
|
|
155
|
-
* If you want to move {@link module:engine/model/range~
|
|
156
|
-
* {@link module:engine/model/item~
|
|
155
|
+
* If you want to move {@link module:engine/model/range~ModelRange range} instead of an
|
|
156
|
+
* {@link module:engine/model/item~ModelItem item} use {@link module:engine/model/writer~ModelWriter#move `Writer#move()`}.
|
|
157
157
|
*
|
|
158
158
|
* **Note:** For a paste-like content insertion mechanism see
|
|
159
159
|
* {@link module:engine/model/model~Model#insertContent `model.insertContent()`}.
|
|
160
160
|
*
|
|
161
161
|
* @param item Item or document fragment to insert.
|
|
162
|
-
* @param offset Offset or one of the flags. Used only when second parameter is a {@link module:engine/model/item~
|
|
162
|
+
* @param offset Offset or one of the flags. Used only when second parameter is a {@link module:engine/model/item~ModelItem model item}.
|
|
163
163
|
*/
|
|
164
164
|
insert(item, itemOrPosition, offset = 0) {
|
|
165
165
|
this._assertWriterUsedCorrectly();
|
|
166
|
-
if (item instanceof
|
|
166
|
+
if (item instanceof ModelText && item.data == '') {
|
|
167
167
|
return;
|
|
168
168
|
}
|
|
169
|
-
const position =
|
|
169
|
+
const position = ModelPosition._createAt(itemOrPosition, offset);
|
|
170
170
|
// If item has a parent already.
|
|
171
171
|
if (item.parent) {
|
|
172
172
|
// We need to check if item is going to be inserted within the same document.
|
|
173
173
|
if (isSameTree(item.root, position.root)) {
|
|
174
174
|
// If it's we just need to move it.
|
|
175
|
-
this.move(
|
|
175
|
+
this.move(ModelRange._createOn(item), position);
|
|
176
176
|
return;
|
|
177
177
|
}
|
|
178
178
|
// If it isn't the same root.
|
|
@@ -194,21 +194,21 @@ export default class Writer {
|
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
196
|
const version = position.root.document ? position.root.document.version : null;
|
|
197
|
-
const children = item instanceof
|
|
197
|
+
const children = item instanceof ModelDocumentFragment ?
|
|
198
198
|
item._removeChildren(0, item.childCount) :
|
|
199
199
|
item;
|
|
200
200
|
const insert = new InsertOperation(position, children, version);
|
|
201
|
-
if (item instanceof
|
|
201
|
+
if (item instanceof ModelText) {
|
|
202
202
|
insert.shouldReceiveAttributes = true;
|
|
203
203
|
}
|
|
204
204
|
this.batch.addOperation(insert);
|
|
205
205
|
this.model.applyOperation(insert);
|
|
206
|
-
// When element is a
|
|
207
|
-
if (item instanceof
|
|
206
|
+
// When element is a ModelDocumentFragment we need to move its markers to Document#markers.
|
|
207
|
+
if (item instanceof ModelDocumentFragment) {
|
|
208
208
|
for (const [markerName, markerRange] of item.markers) {
|
|
209
|
-
// We need to migrate marker range from
|
|
210
|
-
const rangeRootPosition =
|
|
211
|
-
const range = new
|
|
209
|
+
// We need to migrate marker range from ModelDocumentFragment to Document.
|
|
210
|
+
const rangeRootPosition = ModelPosition._createAt(markerRange.root, 0);
|
|
211
|
+
const range = new ModelRange(markerRange.start._getCombined(rangeRootPosition, position), markerRange.end._getCombined(rangeRootPosition, position));
|
|
212
212
|
const options = { range, usingOperation: true, affectsData: true };
|
|
213
213
|
if (this.model.markers.has(markerName)) {
|
|
214
214
|
this.updateMarker(markerName, options);
|
|
@@ -223,7 +223,7 @@ export default class Writer {
|
|
|
223
223
|
itemOrPosition, // Too complicated when not using `any`.
|
|
224
224
|
offset // Too complicated when not using `any`.
|
|
225
225
|
) {
|
|
226
|
-
if (attributes instanceof
|
|
226
|
+
if (attributes instanceof ModelDocumentFragment || attributes instanceof ModelElement || attributes instanceof ModelPosition) {
|
|
227
227
|
this.insert(this.createText(text), attributes, itemOrPosition);
|
|
228
228
|
}
|
|
229
229
|
else {
|
|
@@ -234,7 +234,7 @@ export default class Writer {
|
|
|
234
234
|
itemOrPositionOrOffset, // Too complicated when not using `any`.
|
|
235
235
|
offset // Too complicated when not using `any`.
|
|
236
236
|
) {
|
|
237
|
-
if (attributes instanceof
|
|
237
|
+
if (attributes instanceof ModelDocumentFragment || attributes instanceof ModelElement || attributes instanceof ModelPosition) {
|
|
238
238
|
this.insert(this.createElement(name), attributes, itemOrPositionOrOffset);
|
|
239
239
|
}
|
|
240
240
|
else {
|
|
@@ -251,8 +251,8 @@ export default class Writer {
|
|
|
251
251
|
*
|
|
252
252
|
* Note that if the item already has parent it will be removed from the previous parent.
|
|
253
253
|
*
|
|
254
|
-
* If you want to move {@link module:engine/model/range~
|
|
255
|
-
* {@link module:engine/model/item~
|
|
254
|
+
* If you want to move {@link module:engine/model/range~ModelRange range} instead of an
|
|
255
|
+
* {@link module:engine/model/item~ModelItem item} use {@link module:engine/model/writer~ModelWriter#move `Writer#move()`}.
|
|
256
256
|
*
|
|
257
257
|
* @param item Item or document fragment to insert.
|
|
258
258
|
*/
|
|
@@ -260,7 +260,7 @@ export default class Writer {
|
|
|
260
260
|
this.insert(item, parent, 'end');
|
|
261
261
|
}
|
|
262
262
|
appendText(text, attributes, parent) {
|
|
263
|
-
if (attributes instanceof
|
|
263
|
+
if (attributes instanceof ModelDocumentFragment || attributes instanceof ModelElement) {
|
|
264
264
|
this.insert(this.createText(text), attributes, 'end');
|
|
265
265
|
}
|
|
266
266
|
else {
|
|
@@ -268,7 +268,7 @@ export default class Writer {
|
|
|
268
268
|
}
|
|
269
269
|
}
|
|
270
270
|
appendElement(name, attributes, parent) {
|
|
271
|
-
if (attributes instanceof
|
|
271
|
+
if (attributes instanceof ModelDocumentFragment || attributes instanceof ModelElement) {
|
|
272
272
|
this.insert(this.createElement(name), attributes, 'end');
|
|
273
273
|
}
|
|
274
274
|
else {
|
|
@@ -276,8 +276,8 @@ export default class Writer {
|
|
|
276
276
|
}
|
|
277
277
|
}
|
|
278
278
|
/**
|
|
279
|
-
* Sets value of the attribute with given key on a {@link module:engine/model/item~
|
|
280
|
-
* or on a {@link module:engine/model/range~
|
|
279
|
+
* Sets value of the attribute with given key on a {@link module:engine/model/item~ModelItem model item}
|
|
280
|
+
* or on a {@link module:engine/model/range~ModelRange range}.
|
|
281
281
|
*
|
|
282
282
|
* @param key Attribute key.
|
|
283
283
|
* @param value Attribute new value.
|
|
@@ -285,7 +285,7 @@ export default class Writer {
|
|
|
285
285
|
*/
|
|
286
286
|
setAttribute(key, value, itemOrRange) {
|
|
287
287
|
this._assertWriterUsedCorrectly();
|
|
288
|
-
if (itemOrRange instanceof
|
|
288
|
+
if (itemOrRange instanceof ModelRange) {
|
|
289
289
|
const ranges = itemOrRange.getMinimalFlatRanges();
|
|
290
290
|
for (const range of ranges) {
|
|
291
291
|
setAttributeOnRange(this, key, value, range);
|
|
@@ -296,8 +296,8 @@ export default class Writer {
|
|
|
296
296
|
}
|
|
297
297
|
}
|
|
298
298
|
/**
|
|
299
|
-
* Sets values of attributes on a {@link module:engine/model/item~
|
|
300
|
-
* or on a {@link module:engine/model/range~
|
|
299
|
+
* Sets values of attributes on a {@link module:engine/model/item~ModelItem model item}
|
|
300
|
+
* or on a {@link module:engine/model/range~ModelRange range}.
|
|
301
301
|
*
|
|
302
302
|
* ```ts
|
|
303
303
|
* writer.setAttributes( {
|
|
@@ -315,15 +315,15 @@ export default class Writer {
|
|
|
315
315
|
}
|
|
316
316
|
}
|
|
317
317
|
/**
|
|
318
|
-
* Removes an attribute with given key from a {@link module:engine/model/item~
|
|
319
|
-
* or from a {@link module:engine/model/range~
|
|
318
|
+
* Removes an attribute with given key from a {@link module:engine/model/item~ModelItem model item}
|
|
319
|
+
* or from a {@link module:engine/model/range~ModelRange range}.
|
|
320
320
|
*
|
|
321
321
|
* @param key Attribute key.
|
|
322
322
|
* @param itemOrRange Model item or range from which the attribute will be removed.
|
|
323
323
|
*/
|
|
324
324
|
removeAttribute(key, itemOrRange) {
|
|
325
325
|
this._assertWriterUsedCorrectly();
|
|
326
|
-
if (itemOrRange instanceof
|
|
326
|
+
if (itemOrRange instanceof ModelRange) {
|
|
327
327
|
const ranges = itemOrRange.getMinimalFlatRanges();
|
|
328
328
|
for (const range of ranges) {
|
|
329
329
|
setAttributeOnRange(this, key, null, range);
|
|
@@ -345,7 +345,7 @@ export default class Writer {
|
|
|
345
345
|
this.removeAttribute(attribute, item);
|
|
346
346
|
}
|
|
347
347
|
};
|
|
348
|
-
if (!(itemOrRange instanceof
|
|
348
|
+
if (!(itemOrRange instanceof ModelRange)) {
|
|
349
349
|
removeAttributesFromItem(itemOrRange);
|
|
350
350
|
}
|
|
351
351
|
else {
|
|
@@ -376,16 +376,16 @@ export default class Writer {
|
|
|
376
376
|
* These parameters work the same way as {@link #createPositionAt `writer.createPositionAt()`}.
|
|
377
377
|
*
|
|
378
378
|
* Note that items can be moved only within the same tree. It means that you can move items within the same root
|
|
379
|
-
* (element or document fragment) or between {@link module:engine/model/document~
|
|
379
|
+
* (element or document fragment) or between {@link module:engine/model/document~ModelDocument#roots documents roots},
|
|
380
380
|
* but you cannot move items from document fragment to the document or from one detached element to another. Use
|
|
381
|
-
* {@link module:engine/model/writer~
|
|
381
|
+
* {@link module:engine/model/writer~ModelWriter#insert} in such cases.
|
|
382
382
|
*
|
|
383
383
|
* @param range Source range.
|
|
384
|
-
* @param offset Offset or one of the flags. Used only when second parameter is a {@link module:engine/model/item~
|
|
384
|
+
* @param offset Offset or one of the flags. Used only when second parameter is a {@link module:engine/model/item~ModelItem model item}.
|
|
385
385
|
*/
|
|
386
386
|
move(range, itemOrPosition, offset) {
|
|
387
387
|
this._assertWriterUsedCorrectly();
|
|
388
|
-
if (!(range instanceof
|
|
388
|
+
if (!(range instanceof ModelRange)) {
|
|
389
389
|
/**
|
|
390
390
|
* Invalid range to move.
|
|
391
391
|
*
|
|
@@ -401,7 +401,7 @@ export default class Writer {
|
|
|
401
401
|
*/
|
|
402
402
|
throw new CKEditorError('writer-move-range-not-flat', this);
|
|
403
403
|
}
|
|
404
|
-
const position =
|
|
404
|
+
const position = ModelPosition._createAt(itemOrPosition, offset);
|
|
405
405
|
// Do not move anything if the move target is same as moved range start.
|
|
406
406
|
if (position.isEqual(range.start)) {
|
|
407
407
|
return;
|
|
@@ -411,7 +411,7 @@ export default class Writer {
|
|
|
411
411
|
if (!isSameTree(range.root, position.root)) {
|
|
412
412
|
/**
|
|
413
413
|
* Range is going to be moved within not the same document. Please use
|
|
414
|
-
* {@link module:engine/model/writer~
|
|
414
|
+
* {@link module:engine/model/writer~ModelWriter#insert insert} instead.
|
|
415
415
|
*
|
|
416
416
|
* @error writer-move-different-document
|
|
417
417
|
*/
|
|
@@ -423,13 +423,13 @@ export default class Writer {
|
|
|
423
423
|
this.model.applyOperation(operation);
|
|
424
424
|
}
|
|
425
425
|
/**
|
|
426
|
-
* Removes given model {@link module:engine/model/item~
|
|
426
|
+
* Removes given model {@link module:engine/model/item~ModelItem item} or {@link module:engine/model/range~ModelRange range}.
|
|
427
427
|
*
|
|
428
428
|
* @param itemOrRange Model item or range to remove.
|
|
429
429
|
*/
|
|
430
430
|
remove(itemOrRange) {
|
|
431
431
|
this._assertWriterUsedCorrectly();
|
|
432
|
-
const rangeToRemove = itemOrRange instanceof
|
|
432
|
+
const rangeToRemove = itemOrRange instanceof ModelRange ? itemOrRange : ModelRange._createOn(itemOrRange);
|
|
433
433
|
const ranges = rangeToRemove.getMinimalFlatRanges().reverse();
|
|
434
434
|
for (const flat of ranges) {
|
|
435
435
|
// If part of the marker is removed, create additional marker operation for undo purposes.
|
|
@@ -451,7 +451,7 @@ export default class Writer {
|
|
|
451
451
|
const nodeAfter = position.nodeAfter;
|
|
452
452
|
// If part of the marker is removed, create additional marker operation for undo purposes.
|
|
453
453
|
this._addOperationForAffectedMarkers('merge', position);
|
|
454
|
-
if (!(nodeBefore instanceof
|
|
454
|
+
if (!(nodeBefore instanceof ModelElement)) {
|
|
455
455
|
/**
|
|
456
456
|
* Node before merge position must be an element.
|
|
457
457
|
*
|
|
@@ -459,7 +459,7 @@ export default class Writer {
|
|
|
459
459
|
*/
|
|
460
460
|
throw new CKEditorError('writer-merge-no-element-before', this);
|
|
461
461
|
}
|
|
462
|
-
if (!(nodeAfter instanceof
|
|
462
|
+
if (!(nodeAfter instanceof ModelElement)) {
|
|
463
463
|
/**
|
|
464
464
|
* Node after merge position must be an element.
|
|
465
465
|
*
|
|
@@ -478,8 +478,8 @@ export default class Writer {
|
|
|
478
478
|
* Shortcut for {@link module:engine/model/model~Model#createPositionFromPath `Model#createPositionFromPath()`}.
|
|
479
479
|
*
|
|
480
480
|
* @param root Root of the position.
|
|
481
|
-
* @param path Position path. See {@link module:engine/model/position~
|
|
482
|
-
* @param stickiness Position stickiness. See {@link module:engine/model/position~
|
|
481
|
+
* @param path Position path. See {@link module:engine/model/position~ModelPosition#path}.
|
|
482
|
+
* @param stickiness Position stickiness. See {@link module:engine/model/position~ModelPositionStickiness}.
|
|
483
483
|
*/
|
|
484
484
|
createPositionFromPath(root, path, stickiness) {
|
|
485
485
|
return this.model.createPositionFromPath(root, path, stickiness);
|
|
@@ -487,7 +487,7 @@ export default class Writer {
|
|
|
487
487
|
/**
|
|
488
488
|
* Shortcut for {@link module:engine/model/model~Model#createPositionAt `Model#createPositionAt()`}.
|
|
489
489
|
*
|
|
490
|
-
* @param offset Offset or one of the flags. Used only when first parameter is a {@link module:engine/model/item~
|
|
490
|
+
* @param offset Offset or one of the flags. Used only when first parameter is a {@link module:engine/model/item~ModelItem model item}.
|
|
491
491
|
*/
|
|
492
492
|
createPositionAt(itemOrPosition, offset) {
|
|
493
493
|
return this.model.createPositionAt(itemOrPosition, offset);
|
|
@@ -544,7 +544,7 @@ export default class Writer {
|
|
|
544
544
|
_mergeDetached(position) {
|
|
545
545
|
const nodeBefore = position.nodeBefore;
|
|
546
546
|
const nodeAfter = position.nodeAfter;
|
|
547
|
-
this.move(
|
|
547
|
+
this.move(ModelRange._createIn(nodeAfter), ModelPosition._createAt(nodeBefore, 'end'));
|
|
548
548
|
this.remove(nodeAfter);
|
|
549
549
|
}
|
|
550
550
|
/**
|
|
@@ -553,10 +553,10 @@ export default class Writer {
|
|
|
553
553
|
* @param position Position between merged elements.
|
|
554
554
|
*/
|
|
555
555
|
_merge(position) {
|
|
556
|
-
const targetPosition =
|
|
557
|
-
const sourcePosition =
|
|
556
|
+
const targetPosition = ModelPosition._createAt(position.nodeBefore, 'end');
|
|
557
|
+
const sourcePosition = ModelPosition._createAt(position.nodeAfter, 0);
|
|
558
558
|
const graveyard = position.root.document.graveyard;
|
|
559
|
-
const graveyardPosition = new
|
|
559
|
+
const graveyardPosition = new ModelPosition(graveyard, [0]);
|
|
560
560
|
const version = position.root.document.version;
|
|
561
561
|
const merge = new MergeOperation(sourcePosition, position.nodeAfter.maxOffset, targetPosition, graveyardPosition, version);
|
|
562
562
|
this.batch.addOperation(merge);
|
|
@@ -570,7 +570,7 @@ export default class Writer {
|
|
|
570
570
|
*/
|
|
571
571
|
rename(element, newName) {
|
|
572
572
|
this._assertWriterUsedCorrectly();
|
|
573
|
-
if (!(element instanceof
|
|
573
|
+
if (!(element instanceof ModelElement)) {
|
|
574
574
|
/**
|
|
575
575
|
* Trying to rename an object which is not an instance of Element.
|
|
576
576
|
*
|
|
@@ -579,7 +579,7 @@ export default class Writer {
|
|
|
579
579
|
throw new CKEditorError('writer-rename-not-element-instance', this);
|
|
580
580
|
}
|
|
581
581
|
const version = element.root.document ? element.root.document.version : null;
|
|
582
|
-
const renameOperation = new RenameOperation(
|
|
582
|
+
const renameOperation = new RenameOperation(ModelPosition._createBefore(element), element.name, newName, version);
|
|
583
583
|
this.batch.addOperation(renameOperation);
|
|
584
584
|
this.model.applyOperation(renameOperation);
|
|
585
585
|
}
|
|
@@ -621,7 +621,7 @@ export default class Writer {
|
|
|
621
621
|
}
|
|
622
622
|
// We need to cache elements that will be created as a result of the first split because
|
|
623
623
|
// we need to create a range from the end of the first split element to the beginning of the
|
|
624
|
-
// first copy element. This should be handled by
|
|
624
|
+
// first copy element. This should be handled by ModelLiveRange but it doesn't work on detached nodes.
|
|
625
625
|
let firstSplitElement;
|
|
626
626
|
let firstCopyElement;
|
|
627
627
|
do {
|
|
@@ -641,13 +641,13 @@ export default class Writer {
|
|
|
641
641
|
} while (splitElement !== limitElement);
|
|
642
642
|
return {
|
|
643
643
|
position,
|
|
644
|
-
range: new
|
|
644
|
+
range: new ModelRange(ModelPosition._createAt(firstSplitElement, 'end'), ModelPosition._createAt(firstCopyElement, 0))
|
|
645
645
|
};
|
|
646
646
|
}
|
|
647
647
|
/**
|
|
648
648
|
* Wraps the given range with the given element or with a new element (if a string was passed).
|
|
649
649
|
*
|
|
650
|
-
* **Note:** range to wrap should be a "flat range" (see {@link module:engine/model/range~
|
|
650
|
+
* **Note:** range to wrap should be a "flat range" (see {@link module:engine/model/range~ModelRange#isFlat `Range#isFlat`}).
|
|
651
651
|
* If not, an error will be thrown.
|
|
652
652
|
*
|
|
653
653
|
* @param range Range to wrap.
|
|
@@ -663,7 +663,7 @@ export default class Writer {
|
|
|
663
663
|
*/
|
|
664
664
|
throw new CKEditorError('writer-wrap-range-not-flat', this);
|
|
665
665
|
}
|
|
666
|
-
const element = elementOrString instanceof
|
|
666
|
+
const element = elementOrString instanceof ModelElement ? elementOrString : new ModelElement(elementOrString);
|
|
667
667
|
if (element.childCount > 0) {
|
|
668
668
|
/**
|
|
669
669
|
* Element to wrap with is not empty.
|
|
@@ -682,8 +682,8 @@ export default class Writer {
|
|
|
682
682
|
}
|
|
683
683
|
this.insert(element, range.start);
|
|
684
684
|
// Shift the range-to-wrap because we just inserted an element before that range.
|
|
685
|
-
const shiftedRange = new
|
|
686
|
-
this.move(shiftedRange,
|
|
685
|
+
const shiftedRange = new ModelRange(range.start.getShiftedBy(1), range.end.getShiftedBy(1));
|
|
686
|
+
this.move(shiftedRange, ModelPosition._createAt(element, 0));
|
|
687
687
|
}
|
|
688
688
|
/**
|
|
689
689
|
* Unwraps children of the given element – all its children are moved before it and then the element is removed.
|
|
@@ -701,7 +701,7 @@ export default class Writer {
|
|
|
701
701
|
*/
|
|
702
702
|
throw new CKEditorError('writer-unwrap-element-no-parent', this);
|
|
703
703
|
}
|
|
704
|
-
this.move(
|
|
704
|
+
this.move(ModelRange._createIn(element), this.createPositionAfter(element));
|
|
705
705
|
this.remove(element);
|
|
706
706
|
}
|
|
707
707
|
/**
|
|
@@ -717,8 +717,8 @@ export default class Writer {
|
|
|
717
717
|
* The `options.affectsData` parameter, which defaults to `false`, allows you to define if a marker affects the data. It should be
|
|
718
718
|
* `true` when the marker change changes the data returned by the
|
|
719
719
|
* {@link module:core/editor/editor~Editor#getData `editor.getData()`} method.
|
|
720
|
-
* When set to `true` it fires the {@link module:engine/model/document~
|
|
721
|
-
* When set to `false` it fires the {@link module:engine/model/document~
|
|
720
|
+
* When set to `true` it fires the {@link module:engine/model/document~ModelDocument#event:change:data `change:data`} event.
|
|
721
|
+
* When set to `false` it fires the {@link module:engine/model/document~ModelDocument#event:change `change`} event.
|
|
722
722
|
*
|
|
723
723
|
* Create marker directly base on marker's name:
|
|
724
724
|
*
|
|
@@ -791,7 +791,8 @@ export default class Writer {
|
|
|
791
791
|
* As the first parameter you can set marker name or instance. If none of them is provided, new marker, with a unique
|
|
792
792
|
* name is created and returned.
|
|
793
793
|
*
|
|
794
|
-
* **Note**: If you want to change the {@link module:engine/view/element~
|
|
794
|
+
* **Note**: If you want to change the {@link module:engine/view/element~ViewElement view element}
|
|
795
|
+
* of the marker while its data in the model
|
|
795
796
|
* remains the same, use the dedicated {@link module:engine/controller/editingcontroller~EditingController#reconvertMarker} method.
|
|
796
797
|
*
|
|
797
798
|
* The `options.usingOperation` parameter lets you change if the marker should be managed by operations or not. See
|
|
@@ -801,8 +802,8 @@ export default class Writer {
|
|
|
801
802
|
* The `options.affectsData` parameter, which defaults to `false`, allows you to define if a marker affects the data. It should be
|
|
802
803
|
* `true` when the marker change changes the data returned by
|
|
803
804
|
* the {@link module:core/editor/editor~Editor#getData `editor.getData()`} method.
|
|
804
|
-
* When set to `true` it fires the {@link module:engine/model/document~
|
|
805
|
-
* When set to `false` it fires the {@link module:engine/model/document~
|
|
805
|
+
* When set to `true` it fires the {@link module:engine/model/document~ModelDocument#event:change:data `change:data`} event.
|
|
806
|
+
* When set to `false` it fires the {@link module:engine/model/document~ModelDocument#event:change `change`} event.
|
|
806
807
|
*
|
|
807
808
|
* Update marker directly base on marker's name:
|
|
808
809
|
*
|
|
@@ -1006,13 +1007,13 @@ export default class Writer {
|
|
|
1006
1007
|
this.model.document.selection._setTo(...args);
|
|
1007
1008
|
}
|
|
1008
1009
|
/**
|
|
1009
|
-
* Moves {@link module:engine/model/documentselection~
|
|
1010
|
+
* Moves {@link module:engine/model/documentselection~ModelDocumentSelection#focus} to the specified location.
|
|
1010
1011
|
*
|
|
1011
1012
|
* The location can be specified in the same form as
|
|
1012
1013
|
* {@link #createPositionAt `writer.createPositionAt()`} parameters.
|
|
1013
1014
|
*
|
|
1014
1015
|
* @param itemOrPosition
|
|
1015
|
-
* @param offset Offset or one of the flags. Used only when first parameter is a {@link module:engine/model/item~
|
|
1016
|
+
* @param offset Offset or one of the flags. Used only when first parameter is a {@link module:engine/model/item~ModelItem model item}.
|
|
1016
1017
|
*/
|
|
1017
1018
|
setSelectionFocus(itemOrPosition, offset) {
|
|
1018
1019
|
this._assertWriterUsedCorrectly();
|
|
@@ -1058,7 +1059,7 @@ export default class Writer {
|
|
|
1058
1059
|
}
|
|
1059
1060
|
}
|
|
1060
1061
|
/**
|
|
1061
|
-
* Temporarily changes the {@link module:engine/model/documentselection~
|
|
1062
|
+
* Temporarily changes the {@link module:engine/model/documentselection~ModelDocumentSelection#isGravityOverridden gravity}
|
|
1062
1063
|
* of the selection from left to right.
|
|
1063
1064
|
*
|
|
1064
1065
|
* The gravity defines from which direction the selection inherits its attributes. If it's the default left gravity,
|
|
@@ -1083,13 +1084,13 @@ export default class Writer {
|
|
|
1083
1084
|
return this.model.document.selection._overrideGravity();
|
|
1084
1085
|
}
|
|
1085
1086
|
/**
|
|
1086
|
-
* Restores {@link ~
|
|
1087
|
+
* Restores {@link ~ModelWriter#overrideSelectionGravity} gravity to default.
|
|
1087
1088
|
*
|
|
1088
1089
|
* Restoring the gravity is only possible using the unique identifier returned by
|
|
1089
|
-
* {@link ~
|
|
1090
|
+
* {@link ~ModelWriter#overrideSelectionGravity}. Note that the gravity remains overridden as long as won't be restored
|
|
1090
1091
|
* the same number of times it was overridden.
|
|
1091
1092
|
*
|
|
1092
|
-
* @param uid The unique id returned by {@link ~
|
|
1093
|
+
* @param uid The unique id returned by {@link ~ModelWriter#overrideSelectionGravity}.
|
|
1093
1094
|
*/
|
|
1094
1095
|
restoreSelectionGravity(uid) {
|
|
1095
1096
|
this.model.document.selection._restoreGravity(uid);
|
|
@@ -1102,7 +1103,7 @@ export default class Writer {
|
|
|
1102
1103
|
const selection = this.model.document.selection;
|
|
1103
1104
|
// Store attribute in parent element if the selection is collapsed in an empty node.
|
|
1104
1105
|
if (selection.isCollapsed && selection.anchor.parent.isEmpty) {
|
|
1105
|
-
const storeKey =
|
|
1106
|
+
const storeKey = ModelDocumentSelection._getStoreAttributeKey(key);
|
|
1106
1107
|
this.setAttribute(storeKey, value, selection.anchor.parent);
|
|
1107
1108
|
}
|
|
1108
1109
|
selection._setAttribute(key, value);
|
|
@@ -1114,7 +1115,7 @@ export default class Writer {
|
|
|
1114
1115
|
const selection = this.model.document.selection;
|
|
1115
1116
|
// Remove stored attribute from parent element if the selection is collapsed in an empty node.
|
|
1116
1117
|
if (selection.isCollapsed && selection.anchor.parent.isEmpty) {
|
|
1117
|
-
const storeKey =
|
|
1118
|
+
const storeKey = ModelDocumentSelection._getStoreAttributeKey(key);
|
|
1118
1119
|
this.removeAttribute(storeKey, selection.anchor.parent);
|
|
1119
1120
|
}
|
|
1120
1121
|
selection._removeAttribute(key);
|
|
@@ -1228,11 +1229,11 @@ function setAttributeOnRange(writer, key, value, range) {
|
|
|
1228
1229
|
}
|
|
1229
1230
|
// Because position in the loop is not the iterator position (see let position comment), the last position in
|
|
1230
1231
|
// the while loop will be last but one position in the range. We need to check the last position manually.
|
|
1231
|
-
if (position instanceof
|
|
1232
|
+
if (position instanceof ModelPosition && position != lastSplitPosition && valueBefore != value) {
|
|
1232
1233
|
addOperation();
|
|
1233
1234
|
}
|
|
1234
1235
|
function addOperation() {
|
|
1235
|
-
const range = new
|
|
1236
|
+
const range = new ModelRange(lastSplitPosition, position);
|
|
1236
1237
|
const version = range.root.document ? doc.version : null;
|
|
1237
1238
|
const operation = new AttributeOperation(range, key, valueBefore, value, version);
|
|
1238
1239
|
writer.batch.addOperation(operation);
|
|
@@ -1255,7 +1256,7 @@ function setAttributeOnItem(writer, key, value, item) {
|
|
|
1255
1256
|
operation = new RootAttributeOperation(item, key, previousValue, value, version);
|
|
1256
1257
|
}
|
|
1257
1258
|
else {
|
|
1258
|
-
range = new
|
|
1259
|
+
range = new ModelRange(ModelPosition._createBefore(item), writer.createPositionAfter(item));
|
|
1259
1260
|
const version = range.root.document ? doc.version : null;
|
|
1260
1261
|
operation = new AttributeOperation(range, key, previousValue, value, version);
|
|
1261
1262
|
}
|
|
@@ -1286,7 +1287,7 @@ function applyRemoveOperation(position, howMany, batch, model) {
|
|
|
1286
1287
|
let operation;
|
|
1287
1288
|
if (position.root.document) {
|
|
1288
1289
|
const doc = model.document;
|
|
1289
|
-
const graveyardPosition = new
|
|
1290
|
+
const graveyardPosition = new ModelPosition(doc.graveyard, [0]);
|
|
1290
1291
|
operation = new MoveOperation(position, howMany, graveyardPosition, doc.version);
|
|
1291
1292
|
}
|
|
1292
1293
|
else {
|
|
@@ -1310,7 +1311,7 @@ function isSameTree(rootA, rootB) {
|
|
|
1310
1311
|
return true;
|
|
1311
1312
|
}
|
|
1312
1313
|
// If both roots are documents root it is operation within the document what we still treat as the same tree.
|
|
1313
|
-
if (rootA instanceof
|
|
1314
|
+
if (rootA instanceof ModelRootElement && rootB instanceof ModelRootElement) {
|
|
1314
1315
|
return true;
|
|
1315
1316
|
}
|
|
1316
1317
|
return false;
|