@ckeditor/ckeditor5-engine 45.2.1 → 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
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module engine/model/utils/insertcontent
|
|
7
7
|
*/
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
8
|
+
import { ModelDocumentSelection } from '../documentselection.js';
|
|
9
|
+
import { ModelElement } from '../element.js';
|
|
10
|
+
import { ModelLivePosition } from '../liveposition.js';
|
|
11
|
+
import { ModelLiveRange } from '../liverange.js';
|
|
12
|
+
import { ModelPosition } from '../position.js';
|
|
13
|
+
import { ModelRange } from '../range.js';
|
|
14
14
|
import { CKEditorError } from '@ckeditor/ckeditor5-utils';
|
|
15
15
|
/**
|
|
16
16
|
* Inserts content into the editor (specified selection) as one would expect the paste functionality to work.
|
|
@@ -27,7 +27,7 @@ import { CKEditorError } from '@ckeditor/ckeditor5-utils';
|
|
|
27
27
|
* <p>x</p>[<img />]<p>z</p> + <p>y</p> => <p>x</p>^<p>z</p> + <p>y</p> => <p>x</p><p>y[]</p><p>z</p>
|
|
28
28
|
* ```
|
|
29
29
|
*
|
|
30
|
-
* If an instance of {@link module:engine/model/selection~
|
|
30
|
+
* If an instance of {@link module:engine/model/selection~ModelSelection} is passed as `selectable` it will be modified
|
|
31
31
|
* to the insertion selection (equal to a range to be selected after insertion).
|
|
32
32
|
*
|
|
33
33
|
* If `selectable` is not passed, the content will be inserted using the current selection of the model document.
|
|
@@ -42,8 +42,9 @@ import { CKEditorError } from '@ckeditor/ckeditor5-utils';
|
|
|
42
42
|
* @returns Range which contains all the performed changes. This is a range that, if removed,
|
|
43
43
|
* would return the model to the state before the insertion. If no changes were preformed by `insertContent`, returns a range collapsed
|
|
44
44
|
* at the insertion position.
|
|
45
|
+
* @internal
|
|
45
46
|
*/
|
|
46
|
-
export
|
|
47
|
+
export function insertContent(model, content, selectable) {
|
|
47
48
|
return model.change(writer => {
|
|
48
49
|
const selection = selectable ? selectable : model.document.selection;
|
|
49
50
|
if (!selection.isCollapsed) {
|
|
@@ -105,7 +106,7 @@ export default function insertContent(model, content, selectable) {
|
|
|
105
106
|
// After insertion was done, the selection was set but the model contains fake <$marker> elements.
|
|
106
107
|
// These <$marker> elements will be now removed. Because of that, we will need to fix the selection.
|
|
107
108
|
// We will create a live range that will automatically be update as <$marker> elements are removed.
|
|
108
|
-
const selectionLiveRange = newRange ?
|
|
109
|
+
const selectionLiveRange = newRange ? ModelLiveRange.fromRange(newRange) : null;
|
|
109
110
|
// Marker name -> [ start position, end position ].
|
|
110
111
|
const markersData = {};
|
|
111
112
|
// Note: `fakeMarkerElements` are sorted backwards. However, now, we want to handle the markers
|
|
@@ -152,7 +153,7 @@ export default function insertContent(model, content, selectable) {
|
|
|
152
153
|
writer.addMarker(name, {
|
|
153
154
|
usingOperation: true,
|
|
154
155
|
affectsData: true,
|
|
155
|
-
range: new
|
|
156
|
+
range: new ModelRange(start, end)
|
|
156
157
|
});
|
|
157
158
|
}
|
|
158
159
|
}
|
|
@@ -163,7 +164,7 @@ export default function insertContent(model, content, selectable) {
|
|
|
163
164
|
}
|
|
164
165
|
/* istanbul ignore else -- @preserve */
|
|
165
166
|
if (newRange) {
|
|
166
|
-
if (selection instanceof
|
|
167
|
+
if (selection instanceof ModelDocumentSelection) {
|
|
167
168
|
writer.setSelection(newRange);
|
|
168
169
|
}
|
|
169
170
|
else {
|
|
@@ -213,11 +214,11 @@ class Insertion {
|
|
|
213
214
|
*/
|
|
214
215
|
schema;
|
|
215
216
|
/**
|
|
216
|
-
* The temporary
|
|
217
|
+
* The temporary ModelDocumentFragment used for grouping multiple nodes for single insert operation.
|
|
217
218
|
*/
|
|
218
219
|
_documentFragment;
|
|
219
220
|
/**
|
|
220
|
-
* The current position in the temporary
|
|
221
|
+
* The current position in the temporary ModelDocumentFragment.
|
|
221
222
|
*/
|
|
222
223
|
_documentFragmentPosition;
|
|
223
224
|
/**
|
|
@@ -263,7 +264,7 @@ class Insertion {
|
|
|
263
264
|
for (const node of Array.from(nodes)) {
|
|
264
265
|
this._handleNode(node);
|
|
265
266
|
}
|
|
266
|
-
// Insert nodes collected in temporary
|
|
267
|
+
// Insert nodes collected in temporary ModelDocumentFragment.
|
|
267
268
|
this._insertPartialFragment();
|
|
268
269
|
// If there was an auto paragraph then we might need to adjust the end of insertion.
|
|
269
270
|
if (this._lastAutoParagraph) {
|
|
@@ -304,7 +305,7 @@ class Insertion {
|
|
|
304
305
|
*/
|
|
305
306
|
getSelectionRange() {
|
|
306
307
|
if (this._nodeToSelect) {
|
|
307
|
-
return
|
|
308
|
+
return ModelRange._createOn(this._nodeToSelect);
|
|
308
309
|
}
|
|
309
310
|
return this.model.schema.getNearestSelectionRange(this.position);
|
|
310
311
|
}
|
|
@@ -316,7 +317,7 @@ class Insertion {
|
|
|
316
317
|
if (!this._affectedStart) {
|
|
317
318
|
return null;
|
|
318
319
|
}
|
|
319
|
-
return new
|
|
320
|
+
return new ModelRange(this._affectedStart, this._affectedEnd);
|
|
320
321
|
}
|
|
321
322
|
/**
|
|
322
323
|
* Destroys `Insertion` instance.
|
|
@@ -342,7 +343,7 @@ class Insertion {
|
|
|
342
343
|
}
|
|
343
344
|
return;
|
|
344
345
|
}
|
|
345
|
-
// Add node to the current temporary
|
|
346
|
+
// Add node to the current temporary ModelDocumentFragment.
|
|
346
347
|
this._appendToFragment(node);
|
|
347
348
|
// Store the first and last nodes for easy access for merging with sibling nodes.
|
|
348
349
|
if (!this._firstNode) {
|
|
@@ -351,13 +352,13 @@ class Insertion {
|
|
|
351
352
|
this._lastNode = node;
|
|
352
353
|
}
|
|
353
354
|
/**
|
|
354
|
-
* Inserts the temporary
|
|
355
|
+
* Inserts the temporary ModelDocumentFragment into the model.
|
|
355
356
|
*/
|
|
356
357
|
_insertPartialFragment() {
|
|
357
358
|
if (this._documentFragment.isEmpty) {
|
|
358
359
|
return;
|
|
359
360
|
}
|
|
360
|
-
const livePosition =
|
|
361
|
+
const livePosition = ModelLivePosition.fromPosition(this.position, 'toNext');
|
|
361
362
|
this._setAffectedBoundaries(this.position);
|
|
362
363
|
// If the very first node of the whole insertion process is inserted, insert it separately for OT reasons (undo).
|
|
363
364
|
// Note: there can be multiple calls to `_insertPartialFragment()` during one insertion process.
|
|
@@ -387,7 +388,7 @@ class Insertion {
|
|
|
387
388
|
}
|
|
388
389
|
}
|
|
389
390
|
/**
|
|
390
|
-
* Append a node to the temporary
|
|
391
|
+
* Append a node to the temporary ModelDocumentFragment.
|
|
391
392
|
*
|
|
392
393
|
* @param node The node to insert.
|
|
393
394
|
*/
|
|
@@ -400,8 +401,8 @@ class Insertion {
|
|
|
400
401
|
* Given node cannot be inserted on the given position.
|
|
401
402
|
*
|
|
402
403
|
* @error insertcontent-wrong-position
|
|
403
|
-
* @param {module:engine/model/node~
|
|
404
|
-
* @param {module:engine/model/position~
|
|
404
|
+
* @param {module:engine/model/node~ModelNode} node Node to insert.
|
|
405
|
+
* @param {module:engine/model/position~ModelPosition} position Position to insert the node at.
|
|
405
406
|
*/
|
|
406
407
|
throw new CKEditorError('insertcontent-wrong-position', this, { node, position: this.position });
|
|
407
408
|
}
|
|
@@ -428,7 +429,7 @@ class Insertion {
|
|
|
428
429
|
// <paragraph>Foo][bar</paragraph> -> <paragraph>Foo]xx[bar</paragraph>
|
|
429
430
|
// This is why it cannot be a range but two separate positions.
|
|
430
431
|
if (!this._affectedStart) {
|
|
431
|
-
this._affectedStart =
|
|
432
|
+
this._affectedStart = ModelLivePosition.fromPosition(position, 'toPrevious');
|
|
432
433
|
}
|
|
433
434
|
// If `_affectedEnd` is before the new boundary position, expand `_affectedEnd`. This can happen if first inserted node was
|
|
434
435
|
// inserted into the parent but the next node is moved-out of that parent:
|
|
@@ -438,7 +439,7 @@ class Insertion {
|
|
|
438
439
|
if (this._affectedEnd) {
|
|
439
440
|
this._affectedEnd.detach();
|
|
440
441
|
}
|
|
441
|
-
this._affectedEnd =
|
|
442
|
+
this._affectedEnd = ModelLivePosition.fromPosition(position, 'toNext');
|
|
442
443
|
}
|
|
443
444
|
}
|
|
444
445
|
/**
|
|
@@ -449,17 +450,17 @@ class Insertion {
|
|
|
449
450
|
*/
|
|
450
451
|
_mergeOnLeft() {
|
|
451
452
|
const node = this._firstNode;
|
|
452
|
-
if (!(node instanceof
|
|
453
|
+
if (!(node instanceof ModelElement)) {
|
|
453
454
|
return;
|
|
454
455
|
}
|
|
455
456
|
if (!this._canMergeLeft(node)) {
|
|
456
457
|
return;
|
|
457
458
|
}
|
|
458
|
-
const mergePosLeft =
|
|
459
|
+
const mergePosLeft = ModelLivePosition._createBefore(node);
|
|
459
460
|
mergePosLeft.stickiness = 'toNext';
|
|
460
|
-
const livePosition =
|
|
461
|
+
const livePosition = ModelLivePosition.fromPosition(this.position, 'toNext');
|
|
461
462
|
// If `_affectedStart` is sames as merge position, it means that the element "marked" by `_affectedStart` is going to be
|
|
462
|
-
// removed and its contents will be moved. This won't transform `
|
|
463
|
+
// removed and its contents will be moved. This won't transform `ModelLivePosition` so `_affectedStart` needs to be moved
|
|
463
464
|
// by hand to properly reflect affected range. (Due to `_affectedStart` and `_affectedEnd` stickiness, the "range" is
|
|
464
465
|
// shown as `][`).
|
|
465
466
|
//
|
|
@@ -472,7 +473,7 @@ class Insertion {
|
|
|
472
473
|
// Note, that if we are here then something must have been inserted, so `_affectedStart` and `_affectedEnd` have to be set.
|
|
473
474
|
if (this._affectedStart.isEqual(mergePosLeft)) {
|
|
474
475
|
this._affectedStart.detach();
|
|
475
|
-
this._affectedStart =
|
|
476
|
+
this._affectedStart = ModelLivePosition._createAt(mergePosLeft.nodeBefore, 'end', 'toPrevious');
|
|
476
477
|
}
|
|
477
478
|
// We need to update the references to the first and last nodes if they will be merged into the previous sibling node
|
|
478
479
|
// because the reference would point to the removed node.
|
|
@@ -498,7 +499,7 @@ class Insertion {
|
|
|
498
499
|
// <paragraph>Foo]Abc[</paragraph><paragraph>Bar</paragraph>
|
|
499
500
|
if (mergePosLeft.isEqual(this._affectedEnd) && this._firstNode === this._lastNode) {
|
|
500
501
|
this._affectedEnd.detach();
|
|
501
|
-
this._affectedEnd =
|
|
502
|
+
this._affectedEnd = ModelLivePosition._createAt(mergePosLeft.nodeBefore, 'end', 'toNext');
|
|
502
503
|
}
|
|
503
504
|
this.position = livePosition.toPosition();
|
|
504
505
|
livePosition.detach();
|
|
@@ -515,13 +516,13 @@ class Insertion {
|
|
|
515
516
|
*/
|
|
516
517
|
_mergeOnRight() {
|
|
517
518
|
const node = this._lastNode;
|
|
518
|
-
if (!(node instanceof
|
|
519
|
+
if (!(node instanceof ModelElement)) {
|
|
519
520
|
return;
|
|
520
521
|
}
|
|
521
522
|
if (!this._canMergeRight(node)) {
|
|
522
523
|
return;
|
|
523
524
|
}
|
|
524
|
-
const mergePosRight =
|
|
525
|
+
const mergePosRight = ModelLivePosition._createAfter(node);
|
|
525
526
|
mergePosRight.stickiness = 'toNext';
|
|
526
527
|
/* istanbul ignore if -- @preserve */
|
|
527
528
|
if (!this.position.isEqual(mergePosRight)) {
|
|
@@ -541,15 +542,15 @@ class Insertion {
|
|
|
541
542
|
}
|
|
542
543
|
// Move the position to the previous node, so it isn't moved to the graveyard on merge.
|
|
543
544
|
// <p>x</p>[]<p>y</p> => <p>x[]</p><p>y</p>
|
|
544
|
-
this.position =
|
|
545
|
+
this.position = ModelPosition._createAt(mergePosRight.nodeBefore, 'end');
|
|
545
546
|
// Explanation of setting position stickiness to `'toPrevious'`:
|
|
546
547
|
// OK: <p>xx[]</p> + <p>yy</p> => <p>xx[]yy</p> (when sticks to previous)
|
|
547
548
|
// NOK: <p>xx[]</p> + <p>yy</p> => <p>xxyy[]</p> (when sticks to next)
|
|
548
|
-
const livePosition =
|
|
549
|
+
const livePosition = ModelLivePosition.fromPosition(this.position, 'toPrevious');
|
|
549
550
|
// See comment in `_mergeOnLeft()` on moving `_affectedStart`.
|
|
550
551
|
if (this._affectedEnd.isEqual(mergePosRight)) {
|
|
551
552
|
this._affectedEnd.detach();
|
|
552
|
-
this._affectedEnd =
|
|
553
|
+
this._affectedEnd = ModelLivePosition._createAt(mergePosRight.nodeBefore, 'end', 'toNext');
|
|
553
554
|
}
|
|
554
555
|
// We need to update the references to the first and last nodes if they will be merged into the previous sibling node
|
|
555
556
|
// because the reference would point to the removed node.
|
|
@@ -568,7 +569,7 @@ class Insertion {
|
|
|
568
569
|
// See comment in `_mergeOnLeft()` on moving `_affectedStart`.
|
|
569
570
|
if (mergePosRight.getShiftedBy(-1).isEqual(this._affectedStart) && this._firstNode === this._lastNode) {
|
|
570
571
|
this._affectedStart.detach();
|
|
571
|
-
this._affectedStart =
|
|
572
|
+
this._affectedStart = ModelLivePosition._createAt(mergePosRight.nodeBefore, 0, 'toPrevious');
|
|
572
573
|
}
|
|
573
574
|
this.position = livePosition.toPosition();
|
|
574
575
|
livePosition.detach();
|
|
@@ -584,7 +585,7 @@ class Insertion {
|
|
|
584
585
|
*/
|
|
585
586
|
_canMergeLeft(node) {
|
|
586
587
|
const previousSibling = node.previousSibling;
|
|
587
|
-
return (previousSibling instanceof
|
|
588
|
+
return (previousSibling instanceof ModelElement) &&
|
|
588
589
|
this.canMergeWith.has(previousSibling) &&
|
|
589
590
|
this.model.schema.checkMerge(previousSibling, node);
|
|
590
591
|
}
|
|
@@ -595,7 +596,7 @@ class Insertion {
|
|
|
595
596
|
*/
|
|
596
597
|
_canMergeRight(node) {
|
|
597
598
|
const nextSibling = node.nextSibling;
|
|
598
|
-
return (nextSibling instanceof
|
|
599
|
+
return (nextSibling instanceof ModelElement) &&
|
|
599
600
|
this.canMergeWith.has(nextSibling) &&
|
|
600
601
|
this.model.schema.checkMerge(node, nextSibling);
|
|
601
602
|
}
|
|
@@ -603,7 +604,7 @@ class Insertion {
|
|
|
603
604
|
* Inserts a paragraph and moves the insertion position into it.
|
|
604
605
|
*/
|
|
605
606
|
_insertAutoParagraph() {
|
|
606
|
-
// Insert nodes collected in temporary
|
|
607
|
+
// Insert nodes collected in temporary ModelDocumentFragment if the position parent needs change to process further nodes.
|
|
607
608
|
this._insertPartialFragment();
|
|
608
609
|
// Insert a paragraph and move insertion position to it.
|
|
609
610
|
const paragraph = this.writer.createElement('paragraph');
|
|
@@ -621,7 +622,7 @@ class Insertion {
|
|
|
621
622
|
if (!allowedIn) {
|
|
622
623
|
return false;
|
|
623
624
|
}
|
|
624
|
-
// Insert nodes collected in temporary
|
|
625
|
+
// Insert nodes collected in temporary ModelDocumentFragment if the position parent needs change to process further nodes.
|
|
625
626
|
if (allowedIn != this.position.parent) {
|
|
626
627
|
this._insertPartialFragment();
|
|
627
628
|
}
|
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module engine/model/utils/insertobject
|
|
7
7
|
*/
|
|
8
|
-
import type
|
|
9
|
-
import type
|
|
10
|
-
import type
|
|
11
|
-
import type Model from '../model.js';
|
|
12
|
-
import type
|
|
8
|
+
import { type ModelDocumentSelection } from '../documentselection.js';
|
|
9
|
+
import { type ModelSelection } from '../selection.js';
|
|
10
|
+
import { type ModelElement } from '../element.js';
|
|
11
|
+
import { type Model } from '../model.js';
|
|
12
|
+
import { type ModelRange } from '../range.js';
|
|
13
13
|
/**
|
|
14
14
|
* Inserts an {@glink framework/deep-dive/schema#object-elements object element} at a specific position in the editor content.
|
|
15
15
|
*
|
|
@@ -22,7 +22,7 @@ import type Range from '../range.js';
|
|
|
22
22
|
* @param model The model in context of which the insertion should be performed.
|
|
23
23
|
* @param object An object to be inserted into the model document.
|
|
24
24
|
* @param selectable A selectable where the content should be inserted. If not specified, the current
|
|
25
|
-
* {@link module:engine/model/document~
|
|
25
|
+
* {@link module:engine/model/document~ModelDocument#selection document selection} will be used instead.
|
|
26
26
|
* @param options Additional options.
|
|
27
27
|
* @param options.findOptimalPosition An option that, when set, adjusts the insertion position (relative to
|
|
28
28
|
* `selectable` and `placeOrOffset`) so that the content of `selectable` is not split upon insertion (a.k.a. non-destructive insertion).
|
|
@@ -32,7 +32,7 @@ import type Range from '../range.js';
|
|
|
32
32
|
*
|
|
33
33
|
* Note that this option works only for block objects. Inline objects are inserted into text and do not split blocks.
|
|
34
34
|
* @param options.setSelection An option that, when set, moves the
|
|
35
|
-
* {@link module:engine/model/document~
|
|
35
|
+
* {@link module:engine/model/document~ModelDocument#selection document selection} after inserting the object.
|
|
36
36
|
* * When `'on'`, the document selection will be set on the inserted object.
|
|
37
37
|
* * When `'after'`, the document selection will move to the closest text node after the inserted object. If there is no
|
|
38
38
|
* such text node, a paragraph will be created and the document selection will be moved inside it.
|
|
@@ -40,7 +40,7 @@ import type Range from '../range.js';
|
|
|
40
40
|
* would return the model to the state before the insertion. If no changes were preformed by `insertObject()`, returns a range collapsed
|
|
41
41
|
* at the insertion position.
|
|
42
42
|
*/
|
|
43
|
-
export
|
|
43
|
+
export declare function insertObject(model: Model, object: ModelElement, selectable?: ModelSelection | ModelDocumentSelection | null, options?: {
|
|
44
44
|
findOptimalPosition?: 'auto' | 'before' | 'after';
|
|
45
45
|
setSelection?: 'on' | 'after';
|
|
46
|
-
}):
|
|
46
|
+
}): ModelRange;
|
|
@@ -15,7 +15,7 @@ import { CKEditorError, first } from '@ckeditor/ckeditor5-utils';
|
|
|
15
15
|
* @param model The model in context of which the insertion should be performed.
|
|
16
16
|
* @param object An object to be inserted into the model document.
|
|
17
17
|
* @param selectable A selectable where the content should be inserted. If not specified, the current
|
|
18
|
-
* {@link module:engine/model/document~
|
|
18
|
+
* {@link module:engine/model/document~ModelDocument#selection document selection} will be used instead.
|
|
19
19
|
* @param options Additional options.
|
|
20
20
|
* @param options.findOptimalPosition An option that, when set, adjusts the insertion position (relative to
|
|
21
21
|
* `selectable` and `placeOrOffset`) so that the content of `selectable` is not split upon insertion (a.k.a. non-destructive insertion).
|
|
@@ -25,7 +25,7 @@ import { CKEditorError, first } from '@ckeditor/ckeditor5-utils';
|
|
|
25
25
|
*
|
|
26
26
|
* Note that this option works only for block objects. Inline objects are inserted into text and do not split blocks.
|
|
27
27
|
* @param options.setSelection An option that, when set, moves the
|
|
28
|
-
* {@link module:engine/model/document~
|
|
28
|
+
* {@link module:engine/model/document~ModelDocument#selection document selection} after inserting the object.
|
|
29
29
|
* * When `'on'`, the document selection will be set on the inserted object.
|
|
30
30
|
* * When `'after'`, the document selection will move to the closest text node after the inserted object. If there is no
|
|
31
31
|
* such text node, a paragraph will be created and the document selection will be moved inside it.
|
|
@@ -33,12 +33,12 @@ import { CKEditorError, first } from '@ckeditor/ckeditor5-utils';
|
|
|
33
33
|
* would return the model to the state before the insertion. If no changes were preformed by `insertObject()`, returns a range collapsed
|
|
34
34
|
* at the insertion position.
|
|
35
35
|
*/
|
|
36
|
-
export
|
|
36
|
+
export function insertObject(model, object, selectable, options = {}) {
|
|
37
37
|
if (!model.schema.isObject(object)) {
|
|
38
38
|
/**
|
|
39
39
|
* Tried to insert an element with {@link module:engine/model/utils/insertobject insertObject()} function
|
|
40
40
|
* that is not defined as an object in schema.
|
|
41
|
-
* See {@link module:engine/model/schema~
|
|
41
|
+
* See {@link module:engine/model/schema~ModelSchemaItemDefinition#isObject `SchemaItemDefinition`}.
|
|
42
42
|
* If you want to insert content that is not an object you might want to use
|
|
43
43
|
* {@link module:engine/model/utils/insertcontent insertContent()} function.
|
|
44
44
|
* @error insertobject-element-not-an-object
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module engine/model/utils/modifyselection
|
|
7
7
|
*/
|
|
8
|
-
import
|
|
9
|
-
import type Model from '../model.js';
|
|
10
|
-
import type
|
|
8
|
+
import { ModelDocumentSelection } from '../documentselection.js';
|
|
9
|
+
import { type Model } from '../model.js';
|
|
10
|
+
import { type ModelSelection } from '../selection.js';
|
|
11
11
|
/**
|
|
12
12
|
* Modifies the selection. Currently, the supported modifications are:
|
|
13
13
|
*
|
|
@@ -40,8 +40,9 @@ import type Selection from '../selection.js';
|
|
|
40
40
|
* @param options.direction The direction in which the selection should be modified. Default 'forward'.
|
|
41
41
|
* @param options.unit The unit by which selection should be modified. Default 'character'.
|
|
42
42
|
* @param options.treatEmojiAsSingleUnit Whether multi-characer emoji sequences should be handled as single unit.
|
|
43
|
+
* @internal
|
|
43
44
|
*/
|
|
44
|
-
export
|
|
45
|
+
export declare function modifySelection(model: Model, selection: ModelSelection | ModelDocumentSelection, options?: {
|
|
45
46
|
direction?: 'forward' | 'backward';
|
|
46
47
|
unit?: 'character' | 'codePoint' | 'word';
|
|
47
48
|
treatEmojiAsSingleUnit?: boolean;
|
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module engine/model/utils/modifyselection
|
|
7
7
|
*/
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
8
|
+
import { ModelDocumentSelection } from '../documentselection.js';
|
|
9
|
+
import { ModelPosition } from '../position.js';
|
|
10
|
+
import { ModelRange } from '../range.js';
|
|
11
|
+
import { ModelTreeWalker } from '../treewalker.js';
|
|
12
12
|
import { isInsideSurrogatePair, isInsideCombinedSymbol, isInsideEmojiSequence } from '@ckeditor/ckeditor5-utils';
|
|
13
13
|
const wordBoundaryCharacters = ' ,.?!:;"-()';
|
|
14
14
|
/**
|
|
@@ -43,14 +43,15 @@ const wordBoundaryCharacters = ' ,.?!:;"-()';
|
|
|
43
43
|
* @param options.direction The direction in which the selection should be modified. Default 'forward'.
|
|
44
44
|
* @param options.unit The unit by which selection should be modified. Default 'character'.
|
|
45
45
|
* @param options.treatEmojiAsSingleUnit Whether multi-characer emoji sequences should be handled as single unit.
|
|
46
|
+
* @internal
|
|
46
47
|
*/
|
|
47
|
-
export
|
|
48
|
+
export function modifySelection(model, selection, options = {}) {
|
|
48
49
|
const schema = model.schema;
|
|
49
50
|
const isForward = options.direction != 'backward';
|
|
50
51
|
const unit = options.unit ? options.unit : 'character';
|
|
51
52
|
const treatEmojiAsSingleUnit = !!options.treatEmojiAsSingleUnit;
|
|
52
53
|
const focus = selection.focus;
|
|
53
|
-
const walker = new
|
|
54
|
+
const walker = new ModelTreeWalker({
|
|
54
55
|
boundaries: getSearchRange(focus, isForward),
|
|
55
56
|
singleCharacters: true,
|
|
56
57
|
direction: isForward ? 'forward' : 'backward'
|
|
@@ -63,7 +64,7 @@ export default function modifySelection(model, selection, options = {}) {
|
|
|
63
64
|
}
|
|
64
65
|
const position = tryExtendingTo(data, next.value);
|
|
65
66
|
if (position) {
|
|
66
|
-
if (selection instanceof
|
|
67
|
+
if (selection instanceof ModelDocumentSelection) {
|
|
67
68
|
model.change(writer => {
|
|
68
69
|
writer.setSelectionFocus(position);
|
|
69
70
|
});
|
|
@@ -93,7 +94,7 @@ function tryExtendingTo(data, value) {
|
|
|
93
94
|
if (type == (isForward ? 'elementStart' : 'elementEnd')) {
|
|
94
95
|
// If it's a selectable, we can select it now.
|
|
95
96
|
if (schema.isSelectable(item)) {
|
|
96
|
-
return
|
|
97
|
+
return ModelPosition._createAt(item, isForward ? 'after' : 'before');
|
|
97
98
|
}
|
|
98
99
|
// If text allowed on this position, extend to this place.
|
|
99
100
|
if (schema.checkChild(nextPosition, '$text')) {
|
|
@@ -162,12 +163,12 @@ function getCorrectWordBreakPosition(walker, isForward) {
|
|
|
162
163
|
}
|
|
163
164
|
function getSearchRange(start, isForward) {
|
|
164
165
|
const root = start.root;
|
|
165
|
-
const searchEnd =
|
|
166
|
+
const searchEnd = ModelPosition._createAt(root, isForward ? 'end' : 0);
|
|
166
167
|
if (isForward) {
|
|
167
|
-
return new
|
|
168
|
+
return new ModelRange(start, searchEnd);
|
|
168
169
|
}
|
|
169
170
|
else {
|
|
170
|
-
return new
|
|
171
|
+
return new ModelRange(searchEnd, start);
|
|
171
172
|
}
|
|
172
173
|
}
|
|
173
174
|
/**
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
4
|
*/
|
|
5
|
-
import
|
|
6
|
-
import type Model from '../model.js';
|
|
7
|
-
import type
|
|
5
|
+
import { ModelRange } from '../range.js';
|
|
6
|
+
import { type Model } from '../model.js';
|
|
7
|
+
import { type ModelSchema } from '../schema.js';
|
|
8
8
|
/**
|
|
9
9
|
* Injects selection post-fixer to the model.
|
|
10
10
|
*
|
|
@@ -13,11 +13,11 @@ import type Schema from '../schema.js';
|
|
|
13
13
|
*
|
|
14
14
|
* The correct position means that:
|
|
15
15
|
*
|
|
16
|
-
* * All collapsed selection ranges are in a place where the {@link module:engine/model/schema~
|
|
16
|
+
* * All collapsed selection ranges are in a place where the {@link module:engine/model/schema~ModelSchema}
|
|
17
17
|
* allows a `$text`.
|
|
18
|
-
* * None of the selection's non-collapsed ranges crosses a {@link module:engine/model/schema~
|
|
18
|
+
* * None of the selection's non-collapsed ranges crosses a {@link module:engine/model/schema~ModelSchema#isLimit limit element}
|
|
19
19
|
* boundary (a range must be rooted within one limit element).
|
|
20
|
-
* * Only {@link module:engine/model/schema~
|
|
20
|
+
* * Only {@link module:engine/model/schema~ModelSchema#isSelectable selectable elements} can be selected from the outside
|
|
21
21
|
* (e.g. `[<paragraph>foo</paragraph>]` is invalid). This rule applies independently to both selection ends, so this
|
|
22
22
|
* selection is correct: `<paragraph>f[oo</paragraph><imageBlock></imageBlock>]`.
|
|
23
23
|
*
|
|
@@ -55,6 +55,8 @@ import type Schema from '../schema.js';
|
|
|
55
55
|
*
|
|
56
56
|
* **Note** If the selection contains multiple ranges, the method returns a minimal set of ranges that are not intersecting after expanding
|
|
57
57
|
* them to select `isLimit=true` elements.
|
|
58
|
+
*
|
|
59
|
+
* @internal
|
|
58
60
|
*/
|
|
59
61
|
export declare function injectSelectionPostFixer(model: Model): void;
|
|
60
62
|
/**
|
|
@@ -63,12 +65,14 @@ export declare function injectSelectionPostFixer(model: Model): void;
|
|
|
63
65
|
* **Note:** This helper is used by the selection post-fixer and to fix the `beforeinput` target ranges.
|
|
64
66
|
*
|
|
65
67
|
* @returns Returns fixed range or null if range is valid.
|
|
68
|
+
* @internal
|
|
66
69
|
*/
|
|
67
|
-
export declare function tryFixingRange(range:
|
|
70
|
+
export declare function tryFixingRange(range: ModelRange, schema: ModelSchema): ModelRange | null;
|
|
68
71
|
/**
|
|
69
72
|
* Returns a minimal non-intersecting array of ranges without duplicates.
|
|
70
73
|
*
|
|
71
74
|
* @param ranges Ranges to merge.
|
|
72
75
|
* @returns Array of unique and non-intersecting ranges.
|
|
76
|
+
* @internal
|
|
73
77
|
*/
|
|
74
|
-
export declare function mergeIntersectingRanges(ranges: Array<
|
|
78
|
+
export declare function mergeIntersectingRanges(ranges: Array<ModelRange>): Array<ModelRange>;
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module engine/model/utils/selection-post-fixer
|
|
7
7
|
*/
|
|
8
|
-
import
|
|
9
|
-
import
|
|
8
|
+
import { ModelPosition } from '../position.js';
|
|
9
|
+
import { ModelRange } from '../range.js';
|
|
10
10
|
/**
|
|
11
11
|
* Injects selection post-fixer to the model.
|
|
12
12
|
*
|
|
@@ -15,11 +15,11 @@ import Range from '../range.js';
|
|
|
15
15
|
*
|
|
16
16
|
* The correct position means that:
|
|
17
17
|
*
|
|
18
|
-
* * All collapsed selection ranges are in a place where the {@link module:engine/model/schema~
|
|
18
|
+
* * All collapsed selection ranges are in a place where the {@link module:engine/model/schema~ModelSchema}
|
|
19
19
|
* allows a `$text`.
|
|
20
|
-
* * None of the selection's non-collapsed ranges crosses a {@link module:engine/model/schema~
|
|
20
|
+
* * None of the selection's non-collapsed ranges crosses a {@link module:engine/model/schema~ModelSchema#isLimit limit element}
|
|
21
21
|
* boundary (a range must be rooted within one limit element).
|
|
22
|
-
* * Only {@link module:engine/model/schema~
|
|
22
|
+
* * Only {@link module:engine/model/schema~ModelSchema#isSelectable selectable elements} can be selected from the outside
|
|
23
23
|
* (e.g. `[<paragraph>foo</paragraph>]` is invalid). This rule applies independently to both selection ends, so this
|
|
24
24
|
* selection is correct: `<paragraph>f[oo</paragraph><imageBlock></imageBlock>]`.
|
|
25
25
|
*
|
|
@@ -57,6 +57,8 @@ import Range from '../range.js';
|
|
|
57
57
|
*
|
|
58
58
|
* **Note** If the selection contains multiple ranges, the method returns a minimal set of ranges that are not intersecting after expanding
|
|
59
59
|
* them to select `isLimit=true` elements.
|
|
60
|
+
*
|
|
61
|
+
* @internal
|
|
60
62
|
*/
|
|
61
63
|
export function injectSelectionPostFixer(model) {
|
|
62
64
|
model.document.registerPostFixer(writer => selectionPostFixer(writer, model));
|
|
@@ -100,6 +102,7 @@ function selectionPostFixer(writer, model) {
|
|
|
100
102
|
* **Note:** This helper is used by the selection post-fixer and to fix the `beforeinput` target ranges.
|
|
101
103
|
*
|
|
102
104
|
* @returns Returns fixed range or null if range is valid.
|
|
105
|
+
* @internal
|
|
103
106
|
*/
|
|
104
107
|
export function tryFixingRange(range, schema) {
|
|
105
108
|
if (range.isCollapsed) {
|
|
@@ -125,7 +128,7 @@ function tryFixingCollapsedRange(range, schema) {
|
|
|
125
128
|
if (!nearestSelectionRange) {
|
|
126
129
|
const ancestorObject = originalPosition.getAncestors().reverse().find((item) => schema.isObject(item));
|
|
127
130
|
if (ancestorObject) {
|
|
128
|
-
return
|
|
131
|
+
return ModelRange._createOn(ancestorObject);
|
|
129
132
|
}
|
|
130
133
|
return null;
|
|
131
134
|
}
|
|
@@ -137,7 +140,7 @@ function tryFixingCollapsedRange(range, schema) {
|
|
|
137
140
|
if (originalPosition.isEqual(fixedPosition)) {
|
|
138
141
|
return null;
|
|
139
142
|
}
|
|
140
|
-
return new
|
|
143
|
+
return new ModelRange(fixedPosition);
|
|
141
144
|
}
|
|
142
145
|
/**
|
|
143
146
|
* Tries to fix an expanded range.
|
|
@@ -172,7 +175,7 @@ function tryFixingNonCollapsedRage(range, schema) {
|
|
|
172
175
|
// The schema.getNearestSelectionRange might return null - if that happens use original position.
|
|
173
176
|
const rangeStart = fixedStart ? fixedStart.start : start;
|
|
174
177
|
const rangeEnd = fixedEnd ? fixedEnd.end : end;
|
|
175
|
-
return new
|
|
178
|
+
return new ModelRange(rangeStart, rangeEnd);
|
|
176
179
|
}
|
|
177
180
|
}
|
|
178
181
|
const isStartInLimit = startLimitElement && !startLimitElement.is('rootElement');
|
|
@@ -188,12 +191,12 @@ function tryFixingNonCollapsedRage(range, schema) {
|
|
|
188
191
|
let fixedStart = start;
|
|
189
192
|
let fixedEnd = end;
|
|
190
193
|
if (expandStart) {
|
|
191
|
-
fixedStart =
|
|
194
|
+
fixedStart = ModelPosition._createBefore(findOutermostLimitAncestor(startLimitElement, schema));
|
|
192
195
|
}
|
|
193
196
|
if (expandEnd) {
|
|
194
|
-
fixedEnd =
|
|
197
|
+
fixedEnd = ModelPosition._createAfter(findOutermostLimitAncestor(endLimitElement, schema));
|
|
195
198
|
}
|
|
196
|
-
return new
|
|
199
|
+
return new ModelRange(fixedStart, fixedEnd);
|
|
197
200
|
}
|
|
198
201
|
// Range was not fixed at this point so it is valid - ie it was placed around limit element already.
|
|
199
202
|
return null;
|
|
@@ -225,6 +228,7 @@ function checkSelectionOnNonLimitElements(start, end, schema) {
|
|
|
225
228
|
*
|
|
226
229
|
* @param ranges Ranges to merge.
|
|
227
230
|
* @returns Array of unique and non-intersecting ranges.
|
|
231
|
+
* @internal
|
|
228
232
|
*/
|
|
229
233
|
export function mergeIntersectingRanges(ranges) {
|
|
230
234
|
const rangesToMerge = [...ranges];
|