@ckeditor/ckeditor5-engine 35.3.2 → 36.0.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/package.json +22 -22
- package/src/controller/datacontroller.js +10 -8
- package/src/controller/editingcontroller.js +3 -4
- package/src/conversion/conversion.js +2 -3
- package/src/conversion/conversionhelpers.js +1 -1
- package/src/conversion/downcastdispatcher.js +3 -3
- package/src/conversion/downcasthelpers.js +2 -3
- package/src/conversion/mapper.js +3 -4
- package/src/conversion/modelconsumable.js +2 -2
- package/src/conversion/upcastdispatcher.js +3 -4
- package/src/conversion/upcasthelpers.js +10 -3
- package/src/conversion/viewconsumable.js +2 -2
- package/src/dataprocessor/basichtmlwriter.js +1 -1
- package/src/dataprocessor/dataprocessor.js +1 -1
- package/src/dataprocessor/htmldataprocessor.js +3 -3
- package/src/dataprocessor/htmlwriter.js +1 -1
- package/src/dataprocessor/xmldataprocessor.js +6 -2
- package/src/dev-utils/model.js +3 -3
- package/src/dev-utils/operationreplayer.js +1 -1
- package/src/dev-utils/utils.js +1 -1
- package/src/dev-utils/view.js +1 -1
- package/src/index.js +13 -3
- package/src/model/batch.js +10 -47
- package/src/model/differ.js +81 -174
- package/src/model/document.js +38 -97
- package/src/model/documentfragment.js +44 -97
- package/src/model/documentselection.js +152 -251
- package/src/model/element.js +48 -101
- package/src/model/history.js +15 -46
- package/src/model/item.js +1 -1
- package/src/model/liveposition.js +11 -39
- package/src/model/liverange.js +14 -38
- package/src/model/markercollection.js +42 -115
- package/src/model/model.js +214 -292
- package/src/model/node.js +36 -128
- package/src/model/nodelist.js +12 -41
- package/src/model/operation/attributeoperation.js +14 -45
- package/src/model/operation/detachoperation.js +4 -17
- package/src/model/operation/insertoperation.js +7 -35
- package/src/model/operation/markeroperation.js +9 -48
- package/src/model/operation/mergeoperation.js +9 -42
- package/src/model/operation/moveoperation.js +15 -39
- package/src/model/operation/nooperation.js +1 -7
- package/src/model/operation/operation.js +5 -63
- package/src/model/operation/operationfactory.js +3 -6
- package/src/model/operation/renameoperation.js +9 -29
- package/src/model/operation/rootattributeoperation.js +19 -48
- package/src/model/operation/splitoperation.js +10 -48
- package/src/model/operation/transform.js +110 -151
- package/src/model/operation/utils.js +37 -52
- package/src/model/position.js +118 -230
- package/src/model/range.js +146 -202
- package/src/model/rootelement.js +8 -47
- package/src/model/schema.js +245 -282
- package/src/model/selection.js +135 -196
- package/src/model/text.js +10 -37
- package/src/model/textproxy.js +16 -70
- package/src/model/treewalker.js +11 -102
- package/src/model/typecheckable.js +1 -1
- package/src/model/utils/autoparagraphing.js +11 -12
- package/src/model/utils/deletecontent.js +93 -62
- package/src/model/utils/findoptimalinsertionrange.js +25 -25
- package/src/model/utils/getselectedcontent.js +3 -6
- package/src/model/utils/insertcontent.js +37 -130
- package/src/model/utils/insertobject.js +40 -40
- package/src/model/utils/modifyselection.js +24 -34
- package/src/model/utils/selection-post-fixer.js +53 -59
- package/src/model/writer.js +209 -316
- package/src/view/attributeelement.js +2 -2
- package/src/view/containerelement.js +1 -1
- package/src/view/datatransfer.js +1 -1
- package/src/view/document.js +3 -5
- package/src/view/documentfragment.js +50 -4
- package/src/view/documentselection.js +2 -3
- package/src/view/domconverter.js +4 -8
- package/src/view/downcastwriter.js +2 -3
- package/src/view/editableelement.js +2 -3
- package/src/view/element.js +6 -8
- package/src/view/elementdefinition.js +1 -1
- package/src/view/emptyelement.js +2 -2
- package/src/view/filler.js +2 -3
- package/src/view/item.js +1 -1
- package/src/view/matcher.js +2 -2
- package/src/view/node.js +2 -5
- package/src/view/observer/arrowkeysobserver.js +1 -1
- package/src/view/observer/bubblingemittermixin.js +3 -6
- package/src/view/observer/bubblingeventinfo.js +2 -2
- package/src/view/observer/clickobserver.js +1 -1
- package/src/view/observer/compositionobserver.js +1 -1
- package/src/view/observer/domeventdata.js +1 -1
- package/src/view/observer/domeventobserver.js +1 -1
- package/src/view/observer/fakeselectionobserver.js +2 -2
- package/src/view/observer/focusobserver.js +25 -3
- package/src/view/observer/inputobserver.js +2 -2
- package/src/view/observer/keyobserver.js +2 -2
- package/src/view/observer/mouseobserver.js +1 -1
- package/src/view/observer/mutationobserver.js +1 -1
- package/src/view/observer/observer.js +3 -3
- package/src/view/observer/selectionobserver.js +21 -3
- package/src/view/observer/tabobserver.js +2 -2
- package/src/view/placeholder.js +1 -1
- package/src/view/position.js +2 -3
- package/src/view/range.js +1 -1
- package/src/view/rawelement.js +2 -2
- package/src/view/renderer.js +3 -12
- package/src/view/rooteditableelement.js +1 -1
- package/src/view/selection.js +2 -6
- package/src/view/styles/background.js +1 -1
- package/src/view/styles/border.js +1 -1
- package/src/view/styles/margin.js +1 -1
- package/src/view/styles/padding.js +1 -1
- package/src/view/styles/utils.js +1 -1
- package/src/view/stylesmap.js +1 -1
- package/src/view/text.js +1 -1
- package/src/view/textproxy.js +2 -2
- package/src/view/treewalker.js +2 -2
- package/src/view/typecheckable.js +1 -1
- package/src/view/uielement.js +2 -3
- package/src/view/upcastwriter.js +1 -1
- package/src/view/view.js +7 -7
- package/theme/placeholder.css +1 -1
- package/theme/renderer.css +1 -1
package/src/model/liverange.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
|
-
/* eslint-disable new-cap */
|
|
6
5
|
/**
|
|
7
6
|
* @module engine/model/liverange
|
|
8
7
|
*/
|
|
9
8
|
import Range from './range';
|
|
10
|
-
import EmitterMixin from '@ckeditor/ckeditor5-utils
|
|
9
|
+
import { EmitterMixin } from '@ckeditor/ckeditor5-utils';
|
|
11
10
|
/**
|
|
12
11
|
* `LiveRange` is a type of {@link module:engine/model/range~Range Range}
|
|
13
12
|
* that updates itself as {@link module:engine/model/document~Document document}
|
|
@@ -36,47 +35,28 @@ export default class LiveRange extends EmitterMixin(Range) {
|
|
|
36
35
|
}
|
|
37
36
|
/**
|
|
38
37
|
* Creates a {@link module:engine/model/range~Range range instance} that is equal to this live range.
|
|
39
|
-
*
|
|
40
|
-
* @returns {module:engine/model/range~Range}
|
|
41
38
|
*/
|
|
42
39
|
toRange() {
|
|
43
40
|
return new Range(this.start, this.end);
|
|
44
41
|
}
|
|
45
42
|
/**
|
|
46
43
|
* Creates a `LiveRange` instance that is equal to the given range.
|
|
47
|
-
*
|
|
48
|
-
* @param {module:engine/model/range~Range} range
|
|
49
|
-
* @returns {module:engine/model/liverange~LiveRange}
|
|
50
44
|
*/
|
|
51
45
|
static fromRange(range) {
|
|
52
46
|
return new LiveRange(range.start, range.end);
|
|
53
47
|
}
|
|
54
48
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
*
|
|
58
|
-
* liveRange.is( 'range' ); // -> true
|
|
59
|
-
* liveRange.is( 'model:range' ); // -> true
|
|
60
|
-
* liveRange.is( 'liveRange' ); // -> true
|
|
61
|
-
* liveRange.is( 'model:liveRange' ); // -> true
|
|
62
|
-
*
|
|
63
|
-
* liveRange.is( 'view:range' ); // -> false
|
|
64
|
-
* liveRange.is( 'documentSelection' ); // -> false
|
|
65
|
-
*
|
|
66
|
-
* {@link module:engine/model/node~Node#is Check the entire list of model objects} which implement the `is()` method.
|
|
67
|
-
*
|
|
68
|
-
* @param {String} type
|
|
69
|
-
* @returns {Boolean}
|
|
70
|
-
*/
|
|
49
|
+
// The magic of type inference using `is` method is centralized in `TypeCheckable` class.
|
|
50
|
+
// Proper overload would interfere with that.
|
|
71
51
|
LiveRange.prototype.is = function (type) {
|
|
72
52
|
return type === 'liveRange' || type === 'model:liveRange' ||
|
|
73
53
|
// From super.is(). This is highly utilised method and cannot call super. See ckeditor/ckeditor5#6529.
|
|
74
54
|
type == 'range' || type === 'model:range';
|
|
75
55
|
};
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
56
|
+
/**
|
|
57
|
+
* Binds this `LiveRange` to the {@link module:engine/model/document~Document document}
|
|
58
|
+
* that owns this range's {@link module:engine/model/range~Range#root root}.
|
|
59
|
+
*/
|
|
80
60
|
function bindWithDocument() {
|
|
81
61
|
this.listenTo(this.root.document.model, 'applyOperation', (event, args) => {
|
|
82
62
|
const operation = args[0];
|
|
@@ -86,10 +66,9 @@ function bindWithDocument() {
|
|
|
86
66
|
transform.call(this, operation);
|
|
87
67
|
}, { priority: 'low' });
|
|
88
68
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
// @param {module:engine/model/operation/operation~Operation} operation Executed operation.
|
|
69
|
+
/**
|
|
70
|
+
* Updates this range accordingly to the updates applied to the model. Bases on change events.
|
|
71
|
+
*/
|
|
93
72
|
function transform(operation) {
|
|
94
73
|
// Transform the range by the operation. Join the result ranges if needed.
|
|
95
74
|
const ranges = this.getTransformedByOperation(operation);
|
|
@@ -120,12 +99,9 @@ function transform(operation) {
|
|
|
120
99
|
this.fire('change:content', this.toRange(), { deletionPosition });
|
|
121
100
|
}
|
|
122
101
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
// @param {module:engine/model/range~Range} range Range to check.
|
|
127
|
-
// @param {module:engine/model/operation/operation~Operation} operation Executed operation.
|
|
128
|
-
// @returns {Boolean}
|
|
102
|
+
/**
|
|
103
|
+
* Checks whether given operation changes something inside the range (even if it does not change boundaries).
|
|
104
|
+
*/
|
|
129
105
|
function doesOperationChangeRangeContent(range, operation) {
|
|
130
106
|
switch (operation.type) {
|
|
131
107
|
case 'insert':
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
|
-
/* eslint-disable new-cap */
|
|
6
5
|
/**
|
|
7
6
|
* @module engine/model/markercollection
|
|
8
7
|
*/
|
|
9
8
|
import TypeCheckable from './typecheckable';
|
|
10
9
|
import LiveRange from './liverange';
|
|
11
|
-
import
|
|
12
|
-
import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
|
|
10
|
+
import { CKEditorError, EmitterMixin } from '@ckeditor/ckeditor5-utils';
|
|
13
11
|
/**
|
|
14
12
|
* The collection of all {@link module:engine/model/markercollection~Marker markers} attached to the document.
|
|
15
13
|
* It lets you {@link module:engine/model/markercollection~MarkerCollection#get get} markers or track them using
|
|
@@ -24,17 +22,11 @@ import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
|
|
|
24
22
|
*
|
|
25
23
|
* @see module:engine/model/markercollection~Marker
|
|
26
24
|
*/
|
|
27
|
-
export default class MarkerCollection extends
|
|
28
|
-
/**
|
|
29
|
-
* Creates a markers collection.
|
|
30
|
-
*/
|
|
25
|
+
export default class MarkerCollection extends EmitterMixin() {
|
|
31
26
|
constructor() {
|
|
32
|
-
super();
|
|
27
|
+
super(...arguments);
|
|
33
28
|
/**
|
|
34
29
|
* Stores {@link ~Marker markers} added to the collection.
|
|
35
|
-
*
|
|
36
|
-
* @private
|
|
37
|
-
* @member {Map} #_markers
|
|
38
30
|
*/
|
|
39
31
|
this._markers = new Map();
|
|
40
32
|
}
|
|
@@ -42,8 +34,6 @@ export default class MarkerCollection extends Emitter {
|
|
|
42
34
|
* Iterable interface.
|
|
43
35
|
*
|
|
44
36
|
* Iterates over all {@link ~Marker markers} added to the collection.
|
|
45
|
-
*
|
|
46
|
-
* @returns {Iterator}
|
|
47
37
|
*/
|
|
48
38
|
[Symbol.iterator]() {
|
|
49
39
|
return this._markers.values();
|
|
@@ -51,8 +41,8 @@ export default class MarkerCollection extends Emitter {
|
|
|
51
41
|
/**
|
|
52
42
|
* Checks if given {@link ~Marker marker} or marker name is in the collection.
|
|
53
43
|
*
|
|
54
|
-
* @param
|
|
55
|
-
* @returns
|
|
44
|
+
* @param markerOrName Name of marker or marker instance to check.
|
|
45
|
+
* @returns `true` if marker is in the collection, `false` otherwise.
|
|
56
46
|
*/
|
|
57
47
|
has(markerOrName) {
|
|
58
48
|
const markerName = markerOrName instanceof Marker ? markerOrName.name : markerOrName;
|
|
@@ -61,8 +51,8 @@ export default class MarkerCollection extends Emitter {
|
|
|
61
51
|
/**
|
|
62
52
|
* Returns {@link ~Marker marker} with given `markerName`.
|
|
63
53
|
*
|
|
64
|
-
* @param
|
|
65
|
-
* @returns
|
|
54
|
+
* @param markerName Name of marker to get.
|
|
55
|
+
* @returns Marker with given name or `null` if such marker was
|
|
66
56
|
* not added to the collection.
|
|
67
57
|
*/
|
|
68
58
|
get(markerName) {
|
|
@@ -78,14 +68,13 @@ export default class MarkerCollection extends Emitter {
|
|
|
78
68
|
* flag has changed.
|
|
79
69
|
*
|
|
80
70
|
* @internal
|
|
81
|
-
* @
|
|
82
|
-
* @
|
|
83
|
-
* @param
|
|
84
|
-
* @param
|
|
85
|
-
* @param
|
|
86
|
-
* @param {Boolean} [affectsData=false] Specifies whether the marker affects the data produced by the data pipeline
|
|
71
|
+
* @fires update
|
|
72
|
+
* @param markerOrName Name of marker to set or marker instance to update.
|
|
73
|
+
* @param range Marker range.
|
|
74
|
+
* @param managedUsingOperations Specifies whether the marker is managed using operations.
|
|
75
|
+
* @param affectsData Specifies whether the marker affects the data produced by the data pipeline
|
|
87
76
|
* (is persisted in the editor's data).
|
|
88
|
-
* @returns
|
|
77
|
+
* @returns `Marker` instance which was added or updated.
|
|
89
78
|
*/
|
|
90
79
|
_set(markerOrName, range, managedUsingOperations = false, affectsData = false) {
|
|
91
80
|
const markerName = markerOrName instanceof Marker ? markerOrName.name : markerOrName;
|
|
@@ -129,10 +118,9 @@ export default class MarkerCollection extends Emitter {
|
|
|
129
118
|
* Removes given {@link ~Marker marker} or a marker with given name from the `MarkerCollection`.
|
|
130
119
|
*
|
|
131
120
|
* @internal
|
|
132
|
-
* @
|
|
133
|
-
* @
|
|
134
|
-
* @
|
|
135
|
-
* @returns {Boolean} `true` if marker was found and removed, `false` otherwise.
|
|
121
|
+
* @fires update
|
|
122
|
+
* @param markerOrName Marker or name of a marker to remove.
|
|
123
|
+
* @returns `true` if marker was found and removed, `false` otherwise.
|
|
136
124
|
*/
|
|
137
125
|
_remove(markerOrName) {
|
|
138
126
|
const markerName = markerOrName instanceof Marker ? markerOrName.name : markerOrName;
|
|
@@ -151,9 +139,8 @@ export default class MarkerCollection extends Emitter {
|
|
|
151
139
|
* conversion} for the marker.
|
|
152
140
|
*
|
|
153
141
|
* @internal
|
|
154
|
-
* @
|
|
155
|
-
* @
|
|
156
|
-
* @param {String|module:engine/model/markercollection~Marker} markerOrName Marker or name of a marker to refresh.
|
|
142
|
+
* @fires update
|
|
143
|
+
* @param markerOrName Marker or name of a marker to refresh.
|
|
157
144
|
*/
|
|
158
145
|
_refresh(markerOrName) {
|
|
159
146
|
const markerName = markerOrName instanceof Marker ? markerOrName.name : markerOrName;
|
|
@@ -171,9 +158,6 @@ export default class MarkerCollection extends Emitter {
|
|
|
171
158
|
}
|
|
172
159
|
/**
|
|
173
160
|
* Returns iterator that iterates over all markers, which ranges contain given {@link module:engine/model/position~Position position}.
|
|
174
|
-
*
|
|
175
|
-
* @param {module:engine/model/position~Position} position
|
|
176
|
-
* @returns {Iterable.<module:engine/model/markercollection~Marker>}
|
|
177
161
|
*/
|
|
178
162
|
*getMarkersAtPosition(position) {
|
|
179
163
|
for (const marker of this) {
|
|
@@ -184,9 +168,6 @@ export default class MarkerCollection extends Emitter {
|
|
|
184
168
|
}
|
|
185
169
|
/**
|
|
186
170
|
* Returns iterator that iterates over all markers, which intersects with given {@link module:engine/model/range~Range range}.
|
|
187
|
-
*
|
|
188
|
-
* @param {module:engine/model/range~Range} range
|
|
189
|
-
* @returns {Iterable.<module:engine/model/markercollection~Marker>}
|
|
190
171
|
*/
|
|
191
172
|
*getMarkersIntersectingRange(range) {
|
|
192
173
|
for (const marker of this) {
|
|
@@ -208,15 +189,14 @@ export default class MarkerCollection extends Emitter {
|
|
|
208
189
|
/**
|
|
209
190
|
* Iterates over all markers that starts with given `prefix`.
|
|
210
191
|
*
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
*
|
|
214
|
-
*
|
|
215
|
-
*
|
|
216
|
-
*
|
|
217
|
-
*
|
|
218
|
-
*
|
|
219
|
-
* @returns {Iterable.<module:engine/model/markercollection~Marker>}
|
|
192
|
+
* ```ts
|
|
193
|
+
* const markerFooA = markersCollection.set( 'foo:a', rangeFooA );
|
|
194
|
+
* const markerFooB = markersCollection.set( 'foo:b', rangeFooB );
|
|
195
|
+
* const markerBarA = markersCollection.set( 'bar:a', rangeBarA );
|
|
196
|
+
* const markerFooBarA = markersCollection.set( 'foobar:a', rangeFooBarA );
|
|
197
|
+
* Array.from( markersCollection.getMarkersGroup( 'foo' ) ); // [ markerFooA, markerFooB ]
|
|
198
|
+
* Array.from( markersCollection.getMarkersGroup( 'a' ) ); // []
|
|
199
|
+
* ```
|
|
220
200
|
*/
|
|
221
201
|
*getMarkersGroup(prefix) {
|
|
222
202
|
for (const marker of this._markers.values()) {
|
|
@@ -227,9 +207,6 @@ export default class MarkerCollection extends Emitter {
|
|
|
227
207
|
}
|
|
228
208
|
/**
|
|
229
209
|
* Destroys the marker.
|
|
230
|
-
*
|
|
231
|
-
* @private
|
|
232
|
-
* @param {module:engine/model/markercollection~Marker} marker Marker to destroy.
|
|
233
210
|
*/
|
|
234
211
|
_destroyMarker(marker) {
|
|
235
212
|
marker.stopListening();
|
|
@@ -279,13 +256,15 @@ export default class MarkerCollection extends Emitter {
|
|
|
279
256
|
* Both type of them should be added / updated by {@link module:engine/model/writer~Writer#addMarker}
|
|
280
257
|
* and removed by {@link module:engine/model/writer~Writer#removeMarker} methods.
|
|
281
258
|
*
|
|
282
|
-
*
|
|
283
|
-
*
|
|
259
|
+
* ```ts
|
|
260
|
+
* model.change( ( writer ) => {
|
|
261
|
+
* const marker = writer.addMarker( name, { range, usingOperation: true } );
|
|
284
262
|
*
|
|
285
|
-
*
|
|
263
|
+
* // ...
|
|
286
264
|
*
|
|
287
|
-
*
|
|
288
|
-
*
|
|
265
|
+
* writer.removeMarker( marker );
|
|
266
|
+
* } );
|
|
267
|
+
* ```
|
|
289
268
|
*
|
|
290
269
|
* See {@link module:engine/model/writer~Writer} to find more examples.
|
|
291
270
|
*
|
|
@@ -307,50 +286,22 @@ class Marker extends EmitterMixin(TypeCheckable) {
|
|
|
307
286
|
/**
|
|
308
287
|
* Creates a marker instance.
|
|
309
288
|
*
|
|
310
|
-
* @param
|
|
311
|
-
* @param
|
|
312
|
-
* @param
|
|
313
|
-
* @param
|
|
314
|
-
* (is persisted in the editor's data).
|
|
289
|
+
* @param name Marker name.
|
|
290
|
+
* @param liveRange Range marked by the marker.
|
|
291
|
+
* @param managedUsingOperations Specifies whether the marker is managed using operations.
|
|
292
|
+
* @param affectsData Specifies whether the marker affects the data produced by the data pipeline (is persisted in the editor's data).
|
|
315
293
|
*/
|
|
316
294
|
constructor(name, liveRange, managedUsingOperations, affectsData) {
|
|
317
295
|
super();
|
|
318
|
-
/**
|
|
319
|
-
* Marker's name.
|
|
320
|
-
*
|
|
321
|
-
* @readonly
|
|
322
|
-
* @type {String}
|
|
323
|
-
*/
|
|
324
296
|
this.name = name;
|
|
325
|
-
/**
|
|
326
|
-
* Range marked by the marker.
|
|
327
|
-
*
|
|
328
|
-
* @protected
|
|
329
|
-
* @member {module:engine/model/liverange~LiveRange}
|
|
330
|
-
*/
|
|
331
297
|
this._liveRange = this._attachLiveRange(liveRange);
|
|
332
|
-
/**
|
|
333
|
-
* Flag indicates if the marker is managed using operations or not.
|
|
334
|
-
*
|
|
335
|
-
* @private
|
|
336
|
-
* @member {Boolean}
|
|
337
|
-
*/
|
|
338
298
|
this._managedUsingOperations = managedUsingOperations;
|
|
339
|
-
/**
|
|
340
|
-
* Specifies whether the marker affects the data produced by the data pipeline
|
|
341
|
-
* (is persisted in the editor's data).
|
|
342
|
-
*
|
|
343
|
-
* @private
|
|
344
|
-
* @member {Boolean}
|
|
345
|
-
*/
|
|
346
299
|
this._affectsData = affectsData;
|
|
347
300
|
}
|
|
348
301
|
/**
|
|
349
302
|
* A value indicating if the marker is managed using operations.
|
|
350
303
|
* See {@link ~Marker marker class description} to learn more about marker types.
|
|
351
304
|
* See {@link module:engine/model/writer~Writer#addMarker}.
|
|
352
|
-
*
|
|
353
|
-
* @returns {Boolean}
|
|
354
305
|
*/
|
|
355
306
|
get managedUsingOperations() {
|
|
356
307
|
if (!this._liveRange) {
|
|
@@ -360,8 +311,6 @@ class Marker extends EmitterMixin(TypeCheckable) {
|
|
|
360
311
|
}
|
|
361
312
|
/**
|
|
362
313
|
* A value indicating if the marker changes the data.
|
|
363
|
-
*
|
|
364
|
-
* @returns {Boolean}
|
|
365
314
|
*/
|
|
366
315
|
get affectsData() {
|
|
367
316
|
if (!this._liveRange) {
|
|
@@ -371,8 +320,6 @@ class Marker extends EmitterMixin(TypeCheckable) {
|
|
|
371
320
|
}
|
|
372
321
|
/**
|
|
373
322
|
* Returns the marker data (properties defining the marker).
|
|
374
|
-
*
|
|
375
|
-
* @returns {module:engine/model/markercollection~MarkerData}
|
|
376
323
|
*/
|
|
377
324
|
getData() {
|
|
378
325
|
return {
|
|
@@ -383,8 +330,6 @@ class Marker extends EmitterMixin(TypeCheckable) {
|
|
|
383
330
|
}
|
|
384
331
|
/**
|
|
385
332
|
* Returns current marker start position.
|
|
386
|
-
*
|
|
387
|
-
* @returns {module:engine/model/position~Position}
|
|
388
333
|
*/
|
|
389
334
|
getStart() {
|
|
390
335
|
if (!this._liveRange) {
|
|
@@ -394,8 +339,6 @@ class Marker extends EmitterMixin(TypeCheckable) {
|
|
|
394
339
|
}
|
|
395
340
|
/**
|
|
396
341
|
* Returns current marker end position.
|
|
397
|
-
*
|
|
398
|
-
* @returns {module:engine/model/position~Position}
|
|
399
342
|
*/
|
|
400
343
|
getEnd() {
|
|
401
344
|
if (!this._liveRange) {
|
|
@@ -412,8 +355,6 @@ class Marker extends EmitterMixin(TypeCheckable) {
|
|
|
412
355
|
* and get `Marker` instance from {@link module:engine/model/markercollection~MarkerCollection MarkerCollection} every
|
|
413
356
|
* time there is a need to read marker properties. This will guarantee that the marker has not been removed and
|
|
414
357
|
* that it's data is up-to-date.
|
|
415
|
-
*
|
|
416
|
-
* @returns {module:engine/model/range~Range}
|
|
417
358
|
*/
|
|
418
359
|
getRange() {
|
|
419
360
|
if (!this._liveRange) {
|
|
@@ -425,9 +366,8 @@ class Marker extends EmitterMixin(TypeCheckable) {
|
|
|
425
366
|
* Binds new live range to the marker and detach the old one if is attached.
|
|
426
367
|
*
|
|
427
368
|
* @internal
|
|
428
|
-
* @
|
|
429
|
-
* @
|
|
430
|
-
* @returns {module:engine/model/liverange~LiveRange} Attached live range.
|
|
369
|
+
* @param liveRange Live range to attach
|
|
370
|
+
* @returns Attached live range.
|
|
431
371
|
*/
|
|
432
372
|
_attachLiveRange(liveRange) {
|
|
433
373
|
if (this._liveRange) {
|
|
@@ -443,7 +383,6 @@ class Marker extends EmitterMixin(TypeCheckable) {
|
|
|
443
383
|
* Unbinds and destroys currently attached live range.
|
|
444
384
|
*
|
|
445
385
|
* @internal
|
|
446
|
-
* @protected
|
|
447
386
|
*/
|
|
448
387
|
_detachLiveRange() {
|
|
449
388
|
this._liveRange.stopDelegating('change:range', this);
|
|
@@ -452,20 +391,8 @@ class Marker extends EmitterMixin(TypeCheckable) {
|
|
|
452
391
|
this._liveRange = null;
|
|
453
392
|
}
|
|
454
393
|
}
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
*
|
|
458
|
-
* marker.is( 'marker' ); // -> true
|
|
459
|
-
* marker.is( 'model:marker' ); // -> true
|
|
460
|
-
*
|
|
461
|
-
* marker.is( 'view:element' ); // -> false
|
|
462
|
-
* marker.is( 'documentSelection' ); // -> false
|
|
463
|
-
*
|
|
464
|
-
* {@link module:engine/model/node~Node#is Check the entire list of model objects} which implement the `is()` method.
|
|
465
|
-
*
|
|
466
|
-
* @param {String} type
|
|
467
|
-
* @returns {Boolean}
|
|
468
|
-
*/
|
|
394
|
+
// The magic of type inference using `is` method is centralized in `TypeCheckable` class.
|
|
395
|
+
// Proper overload would interfere with that.
|
|
469
396
|
Marker.prototype.is = function (type) {
|
|
470
397
|
return type === 'marker' || type === 'model:marker';
|
|
471
398
|
};
|