@ckeditor/ckeditor5-engine 43.2.0 → 43.3.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.css.map +1 -1
- package/dist/index.js +149 -72
- package/dist/index.js.map +1 -1
- package/dist/model/documentfragment.d.ts +8 -1
- package/dist/model/element.d.ts +11 -1
- package/dist/model/node.d.ts +20 -17
- package/dist/model/nodelist.d.ts +23 -8
- package/dist/model/position.d.ts +9 -2
- package/package.json +2 -2
- package/src/model/document.js +2 -1
- package/src/model/documentfragment.d.ts +8 -1
- package/src/model/documentfragment.js +12 -3
- package/src/model/element.d.ts +11 -1
- package/src/model/element.js +15 -3
- package/src/model/node.d.ts +20 -17
- package/src/model/node.js +24 -30
- package/src/model/nodelist.d.ts +23 -8
- package/src/model/nodelist.js +78 -30
- package/src/model/position.d.ts +9 -2
- package/src/model/position.js +24 -5
- package/src/view/domconverter.js +3 -1
package/dist/index.css.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../theme/placeholder.css","index.css","../theme/renderer.css"],"names":[],"mappings":";;;;AAAA,CAAA
|
|
1
|
+
{"version":3,"sources":["../theme/placeholder.css","index.css","../theme/renderer.css"],"names":[],"mappings":";;;;AAAA,CAAA;ACCA,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ;AAC3E,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC;AAC5E,CAAC,CDAC;;AAEF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AA;ADmCA,CClCC,OAAA,CAAA,CAAA,IAAa;AACd;;ADoCA,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC","file":"index.css.map","sourcesContent":["/*\n * Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license\n */\n\n/* See ckeditor/ckeditor5#936. */\n.ck.ck-placeholder,\n.ck .ck-placeholder {\n\tposition: relative;\n\n\t&::before {\n\t\tposition: absolute;\n\t\tleft: 0;\n\t\tright: 0;\n\t\tcontent: attr(data-placeholder);\n\n\t\t/* See ckeditor/ckeditor5#469. */\n\t\tpointer-events: none;\n\t}\n}\n\n/* See ckeditor/ckeditor5#1987. */\n.ck.ck-read-only .ck-placeholder {\n\t&::before {\n\t\tdisplay: none;\n\t}\n}\n\n/*\n * Rules for the `ck-placeholder` are loaded before the rules for `ck-reset_all` in the base CKEditor 5 DLL build.\n * This fix overwrites the incorrectly set `position: static` from `ck-reset_all`.\n * See https://github.com/ckeditor/ckeditor5/issues/11418.\n */\n.ck.ck-reset_all .ck-placeholder {\n\tposition: relative;\n}\n","/*\n * Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license\n */\n\n/* See ckeditor/ckeditor5#936. */\n.ck.ck-placeholder,\n.ck .ck-placeholder {\n\tposition: relative;\n}\n.ck.ck-placeholder::before, .ck .ck-placeholder::before {\n\t\tposition: absolute;\n\t\tleft: 0;\n\t\tright: 0;\n\t\tcontent: attr(data-placeholder);\n\n\t\t/* See ckeditor/ckeditor5#469. */\n\t\tpointer-events: none;\n\t}\n\n/* See ckeditor/ckeditor5#1987. */\n.ck.ck-read-only .ck-placeholder::before {\n\t\tdisplay: none;\n\t}\n\n/*\n * Rules for the `ck-placeholder` are loaded before the rules for `ck-reset_all` in the base CKEditor 5 DLL build.\n * This fix overwrites the incorrectly set `position: static` from `ck-reset_all`.\n * See https://github.com/ckeditor/ckeditor5/issues/11418.\n */\n.ck.ck-reset_all .ck-placeholder {\n\tposition: relative;\n}\n\n/*\n * Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license\n */\n\n/* Elements marked by the Renderer as hidden should be invisible in the editor. */\n.ck.ck-editor__editable span[data-ck-unsafe-element] {\n\tdisplay: none;\n}\n\n/*# sourceMappingURL=index.css.map */","/*\n * Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license\n */\n\n/* Elements marked by the Renderer as hidden should be invisible in the editor. */\n.ck.ck-editor__editable span[data-ck-unsafe-element] {\n\tdisplay: none;\n}\n"]}
|
package/dist/index.js
CHANGED
|
@@ -8353,7 +8353,8 @@ const UNSAFE_ELEMENT_REPLACEMENT_ATTRIBUTE = 'data-ck-unsafe-element';
|
|
|
8353
8353
|
this.renderingMode = renderingMode;
|
|
8354
8354
|
this.blockFillerMode = blockFillerMode || (renderingMode === 'editing' ? 'br' : 'nbsp');
|
|
8355
8355
|
this.preElements = [
|
|
8356
|
-
'pre'
|
|
8356
|
+
'pre',
|
|
8357
|
+
'textarea'
|
|
8357
8358
|
];
|
|
8358
8359
|
this.blockElements = [
|
|
8359
8360
|
'address',
|
|
@@ -9382,6 +9383,8 @@ const UNSAFE_ELEMENT_REPLACEMENT_ATTRIBUTE = 'data-ck-unsafe-element';
|
|
|
9382
9383
|
// for inline objects can verify if the element is empty.
|
|
9383
9384
|
if (this._isInlineObjectElement(viewElement)) {
|
|
9384
9385
|
inlineNodes.push(viewElement);
|
|
9386
|
+
// Inline object content should be handled as a flow-root.
|
|
9387
|
+
this._processDomInlineNodes(null, nestedInlineNodes, options);
|
|
9385
9388
|
} else {
|
|
9386
9389
|
// It's an inline element that is not an object (like <b>, <i>) or a block element.
|
|
9387
9390
|
for (const inlineNode of nestedInlineNodes){
|
|
@@ -11562,6 +11565,16 @@ function getFiles(nativeDataTransfer) {
|
|
|
11562
11565
|
/**
|
|
11563
11566
|
* Attributes set on this node.
|
|
11564
11567
|
*/ _attrs;
|
|
11568
|
+
/**
|
|
11569
|
+
* Index of this node in its parent or `null` if the node has no parent.
|
|
11570
|
+
*
|
|
11571
|
+
* @internal
|
|
11572
|
+
*/ _index = null;
|
|
11573
|
+
/**
|
|
11574
|
+
* Offset at which this node starts in its parent or `null` if the node has no parent.
|
|
11575
|
+
*
|
|
11576
|
+
* @internal
|
|
11577
|
+
*/ _startOffset = null;
|
|
11565
11578
|
/**
|
|
11566
11579
|
* Creates a model node.
|
|
11567
11580
|
*
|
|
@@ -11579,49 +11592,31 @@ function getFiles(nativeDataTransfer) {
|
|
|
11579
11592
|
}
|
|
11580
11593
|
/**
|
|
11581
11594
|
* Index of this node in its parent or `null` if the node has no parent.
|
|
11582
|
-
*
|
|
11583
|
-
* Accessing this property throws an error if this node's parent element does not contain it.
|
|
11584
|
-
* This means that model tree got broken.
|
|
11585
11595
|
*/ get index() {
|
|
11586
|
-
|
|
11587
|
-
if (!this.parent) {
|
|
11588
|
-
return null;
|
|
11589
|
-
}
|
|
11590
|
-
if ((pos = this.parent.getChildIndex(this)) === null) {
|
|
11591
|
-
throw new CKEditorError('model-node-not-found-in-parent', this);
|
|
11592
|
-
}
|
|
11593
|
-
return pos;
|
|
11596
|
+
return this._index;
|
|
11594
11597
|
}
|
|
11595
11598
|
/**
|
|
11596
11599
|
* Offset at which this node starts in its parent. It is equal to the sum of {@link #offsetSize offsetSize}
|
|
11597
11600
|
* of all its previous siblings. Equals to `null` if node has no parent.
|
|
11598
|
-
*
|
|
11599
|
-
* Accessing this property throws an error if this node's parent element does not contain it.
|
|
11600
|
-
* This means that model tree got broken.
|
|
11601
11601
|
*/ get startOffset() {
|
|
11602
|
-
|
|
11603
|
-
if (!this.parent) {
|
|
11604
|
-
return null;
|
|
11605
|
-
}
|
|
11606
|
-
if ((pos = this.parent.getChildStartOffset(this)) === null) {
|
|
11607
|
-
throw new CKEditorError('model-node-not-found-in-parent', this);
|
|
11608
|
-
}
|
|
11609
|
-
return pos;
|
|
11602
|
+
return this._startOffset;
|
|
11610
11603
|
}
|
|
11611
11604
|
/**
|
|
11612
|
-
* Offset size of this node.
|
|
11613
|
-
*
|
|
11614
|
-
*
|
|
11615
|
-
*
|
|
11605
|
+
* Offset size of this node.
|
|
11606
|
+
*
|
|
11607
|
+
* Represents how much "offset space" is occupied by the node in its parent. It is important for
|
|
11608
|
+
* {@link module:engine/model/position~Position position}. When node has `offsetSize` greater than `1`, position can be placed between
|
|
11609
|
+
* that node start and end. `offsetSize` greater than `1` is for nodes that represents more than one entity, i.e.
|
|
11610
|
+
* a {@link module:engine/model/text~Text text node}.
|
|
11616
11611
|
*/ get offsetSize() {
|
|
11617
11612
|
return 1;
|
|
11618
11613
|
}
|
|
11619
11614
|
/**
|
|
11620
|
-
* Offset at which this node ends in
|
|
11615
|
+
* Offset at which this node ends in its parent. It is equal to the sum of this node's
|
|
11621
11616
|
* {@link module:engine/model/node~Node#startOffset start offset} and {@link #offsetSize offset size}.
|
|
11622
11617
|
* Equals to `null` if the node has no parent.
|
|
11623
11618
|
*/ get endOffset() {
|
|
11624
|
-
if (
|
|
11619
|
+
if (this.startOffset === null) {
|
|
11625
11620
|
return null;
|
|
11626
11621
|
}
|
|
11627
11622
|
return this.startOffset + this.offsetSize;
|
|
@@ -11814,7 +11809,7 @@ function getFiles(nativeDataTransfer) {
|
|
|
11814
11809
|
return new this.constructor(this._attrs);
|
|
11815
11810
|
}
|
|
11816
11811
|
/**
|
|
11817
|
-
* Removes this node from
|
|
11812
|
+
* Removes this node from its parent.
|
|
11818
11813
|
*
|
|
11819
11814
|
* @internal
|
|
11820
11815
|
* @see module:engine/model/writer~Writer#remove
|
|
@@ -11874,7 +11869,14 @@ Node$1.prototype.is = function(type) {
|
|
|
11874
11869
|
* Nodes contained in this node list.
|
|
11875
11870
|
*/ _nodes = [];
|
|
11876
11871
|
/**
|
|
11877
|
-
*
|
|
11872
|
+
* This array maps numbers (offsets) to node that is placed at that offset.
|
|
11873
|
+
*
|
|
11874
|
+
* This array is similar to `_nodes` with the difference that one node may occupy multiple consecutive items in the array.
|
|
11875
|
+
*
|
|
11876
|
+
* This array is needed to quickly retrieve a node that is placed at given offset.
|
|
11877
|
+
*/ _offsetToNode = [];
|
|
11878
|
+
/**
|
|
11879
|
+
* Creates a node list.
|
|
11878
11880
|
*
|
|
11879
11881
|
* @internal
|
|
11880
11882
|
* @param nodes Nodes contained in this node list.
|
|
@@ -11898,7 +11900,7 @@ Node$1.prototype.is = function(type) {
|
|
|
11898
11900
|
/**
|
|
11899
11901
|
* Sum of {@link module:engine/model/node~Node#offsetSize offset sizes} of all nodes contained inside this node list.
|
|
11900
11902
|
*/ get maxOffset() {
|
|
11901
|
-
return this.
|
|
11903
|
+
return this._offsetToNode.length;
|
|
11902
11904
|
}
|
|
11903
11905
|
/**
|
|
11904
11906
|
* Gets the node at the given index. Returns `null` if incorrect index was passed.
|
|
@@ -11906,30 +11908,29 @@ Node$1.prototype.is = function(type) {
|
|
|
11906
11908
|
return this._nodes[index] || null;
|
|
11907
11909
|
}
|
|
11908
11910
|
/**
|
|
11909
|
-
*
|
|
11911
|
+
* Gets the node at the given offset. Returns `null` if incorrect offset was passed.
|
|
11912
|
+
*/ getNodeAtOffset(offset) {
|
|
11913
|
+
return this._offsetToNode[offset] || null;
|
|
11914
|
+
}
|
|
11915
|
+
/**
|
|
11916
|
+
* Returns an index of the given node or `null` if given node does not have a parent.
|
|
11917
|
+
*
|
|
11918
|
+
* This is an alias to {@link module:engine/model/node~Node#index}.
|
|
11910
11919
|
*/ getNodeIndex(node) {
|
|
11911
|
-
|
|
11912
|
-
return index == -1 ? null : index;
|
|
11920
|
+
return node.index;
|
|
11913
11921
|
}
|
|
11914
11922
|
/**
|
|
11915
|
-
* Returns the
|
|
11916
|
-
*
|
|
11923
|
+
* Returns the offset at which given node is placed in its parent or `null` if given node does not have a parent.
|
|
11924
|
+
*
|
|
11925
|
+
* This is an alias to {@link module:engine/model/node~Node#startOffset}.
|
|
11917
11926
|
*/ getNodeStartOffset(node) {
|
|
11918
|
-
|
|
11919
|
-
if (index === null) {
|
|
11920
|
-
return null;
|
|
11921
|
-
}
|
|
11922
|
-
let sum = 0;
|
|
11923
|
-
for(let i = 0; i < index; i++){
|
|
11924
|
-
sum += this._nodes[i].offsetSize;
|
|
11925
|
-
}
|
|
11926
|
-
return sum;
|
|
11927
|
+
return node.startOffset;
|
|
11927
11928
|
}
|
|
11928
11929
|
/**
|
|
11929
11930
|
* Converts index to offset in node list.
|
|
11930
11931
|
*
|
|
11931
|
-
*
|
|
11932
|
-
*
|
|
11932
|
+
* Throws {@link module:utils/ckeditorerror~CKEditorError CKEditorError} `model-nodelist-index-out-of-bounds` if given index is less
|
|
11933
|
+
* than `0` or more than {@link #length}.
|
|
11933
11934
|
*/ indexToOffset(index) {
|
|
11934
11935
|
if (index == this._nodes.length) {
|
|
11935
11936
|
return this.maxOffset;
|
|
@@ -11947,17 +11948,14 @@ Node$1.prototype.is = function(type) {
|
|
|
11947
11948
|
/**
|
|
11948
11949
|
* Converts offset in node list to index.
|
|
11949
11950
|
*
|
|
11950
|
-
*
|
|
11951
|
-
*
|
|
11951
|
+
* Throws {@link module:utils/ckeditorerror~CKEditorError CKEditorError} `model-nodelist-offset-out-of-bounds` if given offset is less
|
|
11952
|
+
* than `0` or more than {@link #maxOffset}.
|
|
11952
11953
|
*/ offsetToIndex(offset) {
|
|
11953
|
-
|
|
11954
|
-
|
|
11955
|
-
if (offset >= totalOffset && offset < totalOffset + node.offsetSize) {
|
|
11956
|
-
return this.getNodeIndex(node);
|
|
11957
|
-
}
|
|
11958
|
-
totalOffset += node.offsetSize;
|
|
11954
|
+
if (offset == this._offsetToNode.length) {
|
|
11955
|
+
return this._nodes.length;
|
|
11959
11956
|
}
|
|
11960
|
-
|
|
11957
|
+
const node = this._offsetToNode[offset];
|
|
11958
|
+
if (!node) {
|
|
11961
11959
|
/**
|
|
11962
11960
|
* Given offset cannot be found in the node list.
|
|
11963
11961
|
*
|
|
@@ -11969,7 +11967,7 @@ Node$1.prototype.is = function(type) {
|
|
|
11969
11967
|
nodeList: this
|
|
11970
11968
|
});
|
|
11971
11969
|
}
|
|
11972
|
-
return this.
|
|
11970
|
+
return this.getNodeIndex(node);
|
|
11973
11971
|
}
|
|
11974
11972
|
/**
|
|
11975
11973
|
* Inserts given nodes at given index.
|
|
@@ -11988,7 +11986,18 @@ Node$1.prototype.is = function(type) {
|
|
|
11988
11986
|
*/ throw new CKEditorError('model-nodelist-insertnodes-not-node', this);
|
|
11989
11987
|
}
|
|
11990
11988
|
}
|
|
11991
|
-
|
|
11989
|
+
const nodesArray = Array.from(nodes);
|
|
11990
|
+
const offsetsArray = makeOffsetsArray(nodesArray);
|
|
11991
|
+
let offset = this.indexToOffset(index);
|
|
11992
|
+
// Splice nodes array and offsets array into the nodelist.
|
|
11993
|
+
this._nodes = spliceArray(this._nodes, nodesArray, index, 0);
|
|
11994
|
+
this._offsetToNode = spliceArray(this._offsetToNode, offsetsArray, offset, 0);
|
|
11995
|
+
// Refresh indexes and offsets for nodes inside this node list. We need to do this for all inserted nodes and all nodes after them.
|
|
11996
|
+
for(let i = index; i < this._nodes.length; i++){
|
|
11997
|
+
this._nodes[i]._index = i;
|
|
11998
|
+
this._nodes[i]._startOffset = offset;
|
|
11999
|
+
offset += this._nodes[i].offsetSize;
|
|
12000
|
+
}
|
|
11992
12001
|
}
|
|
11993
12002
|
/**
|
|
11994
12003
|
* Removes one or more nodes starting at the given index.
|
|
@@ -11998,7 +12007,26 @@ Node$1.prototype.is = function(type) {
|
|
|
11998
12007
|
* @param howMany Number of nodes to remove.
|
|
11999
12008
|
* @returns Array containing removed nodes.
|
|
12000
12009
|
*/ _removeNodes(indexStart, howMany = 1) {
|
|
12001
|
-
|
|
12010
|
+
if (howMany == 0) {
|
|
12011
|
+
return [];
|
|
12012
|
+
}
|
|
12013
|
+
// Remove nodes from this nodelist.
|
|
12014
|
+
let offset = this.indexToOffset(indexStart);
|
|
12015
|
+
const nodes = this._nodes.splice(indexStart, howMany);
|
|
12016
|
+
const lastNode = nodes[nodes.length - 1];
|
|
12017
|
+
const removedOffsetSum = lastNode.startOffset + lastNode.offsetSize - offset;
|
|
12018
|
+
this._offsetToNode.splice(offset, removedOffsetSum);
|
|
12019
|
+
// Reset index and start offset properties for the removed nodes -- they do not have a parent anymore.
|
|
12020
|
+
for (const node of nodes){
|
|
12021
|
+
node._index = null;
|
|
12022
|
+
node._startOffset = null;
|
|
12023
|
+
}
|
|
12024
|
+
for(let i = indexStart; i < this._nodes.length; i++){
|
|
12025
|
+
this._nodes[i]._index = i;
|
|
12026
|
+
this._nodes[i]._startOffset = offset;
|
|
12027
|
+
offset += this._nodes[i].offsetSize;
|
|
12028
|
+
}
|
|
12029
|
+
return nodes;
|
|
12002
12030
|
}
|
|
12003
12031
|
/**
|
|
12004
12032
|
* Converts `NodeList` instance to an array containing nodes that were inserted in the node list. Nodes
|
|
@@ -12009,6 +12037,18 @@ Node$1.prototype.is = function(type) {
|
|
|
12009
12037
|
return this._nodes.map((node)=>node.toJSON());
|
|
12010
12038
|
}
|
|
12011
12039
|
}
|
|
12040
|
+
/**
|
|
12041
|
+
* Creates an array of nodes in the format as in {@link module:engine/model/nodelist~NodeList#_offsetToNode}, i.e. one node will
|
|
12042
|
+
* occupy multiple items if its offset size is greater than one.
|
|
12043
|
+
*/ function makeOffsetsArray(nodes) {
|
|
12044
|
+
const offsets = [];
|
|
12045
|
+
for (const node of nodes){
|
|
12046
|
+
const start = offsets.length;
|
|
12047
|
+
offsets.length += node.offsetSize;
|
|
12048
|
+
offsets.fill(node, start);
|
|
12049
|
+
}
|
|
12050
|
+
return offsets;
|
|
12051
|
+
}
|
|
12012
12052
|
|
|
12013
12053
|
// @if CK_DEBUG_ENGINE // const { convertMapToStringifiedObject } = require( '../dev-utils/utils' );
|
|
12014
12054
|
/**
|
|
@@ -12303,10 +12343,21 @@ TextProxy.prototype.is = function(type) {
|
|
|
12303
12343
|
return this.childCount === 0;
|
|
12304
12344
|
}
|
|
12305
12345
|
/**
|
|
12306
|
-
* Gets the child at the given index.
|
|
12346
|
+
* Gets the child at the given index. Returns `null` if incorrect index was passed.
|
|
12347
|
+
*
|
|
12348
|
+
* @param index Index in this element.
|
|
12349
|
+
* @returns Child node.
|
|
12307
12350
|
*/ getChild(index) {
|
|
12308
12351
|
return this._children.getNode(index);
|
|
12309
12352
|
}
|
|
12353
|
+
/**
|
|
12354
|
+
* Gets the child at the given offset. Returns `null` if incorrect index was passed.
|
|
12355
|
+
*
|
|
12356
|
+
* @param offset Offset in this element.
|
|
12357
|
+
* @returns Child node.
|
|
12358
|
+
*/ getChildAtOffset(offset) {
|
|
12359
|
+
return this._children.getNodeAtOffset(offset);
|
|
12360
|
+
}
|
|
12310
12361
|
/**
|
|
12311
12362
|
* Returns an iterator that iterates over all of this element's children.
|
|
12312
12363
|
*/ getChildren() {
|
|
@@ -12362,8 +12413,8 @@ TextProxy.prototype.is = function(type) {
|
|
|
12362
12413
|
*/ getNodeByPath(relativePath) {
|
|
12363
12414
|
// eslint-disable-next-line @typescript-eslint/no-this-alias, consistent-this
|
|
12364
12415
|
let node = this;
|
|
12365
|
-
for (const
|
|
12366
|
-
node = node.
|
|
12416
|
+
for (const offset of relativePath){
|
|
12417
|
+
node = node.getChildAtOffset(offset);
|
|
12367
12418
|
}
|
|
12368
12419
|
return node;
|
|
12369
12420
|
}
|
|
@@ -12913,7 +12964,7 @@ function formatReturnValue(type, item, previousPosition, nextPosition, length) {
|
|
|
12913
12964
|
*/ get parent() {
|
|
12914
12965
|
let parent = this.root;
|
|
12915
12966
|
for(let i = 0; i < this.path.length - 1; i++){
|
|
12916
|
-
parent = parent.
|
|
12967
|
+
parent = parent.getChildAtOffset(this.path[i]);
|
|
12917
12968
|
if (!parent) {
|
|
12918
12969
|
/**
|
|
12919
12970
|
* The position's path is incorrect. This means that a position does not point to
|
|
@@ -12955,14 +13006,14 @@ function formatReturnValue(type, item, previousPosition, nextPosition, length) {
|
|
|
12955
13006
|
return getTextNodeAtPosition(this, this.parent);
|
|
12956
13007
|
}
|
|
12957
13008
|
/**
|
|
12958
|
-
* Node directly after this position
|
|
13009
|
+
* Node directly after this position. Returns `null` if this position is at the end of its parent, or if it is in a text node.
|
|
12959
13010
|
*/ get nodeAfter() {
|
|
12960
13011
|
// Cache the parent and reuse for performance reasons. See #6579 and #6582.
|
|
12961
13012
|
const parent = this.parent;
|
|
12962
13013
|
return getNodeAfterPosition(this, parent, getTextNodeAtPosition(this, parent));
|
|
12963
13014
|
}
|
|
12964
13015
|
/**
|
|
12965
|
-
* Node directly before this position
|
|
13016
|
+
* Node directly before this position. Returns `null` if this position is at the start of its parent, or if it is in a text node.
|
|
12966
13017
|
*/ get nodeBefore() {
|
|
12967
13018
|
// Cache the parent and reuse for performance reasons. See #6579 and #6582.
|
|
12968
13019
|
const parent = this.parent;
|
|
@@ -12978,6 +13029,21 @@ function formatReturnValue(type, item, previousPosition, nextPosition, length) {
|
|
|
12978
13029
|
*/ get isAtEnd() {
|
|
12979
13030
|
return this.offset == this.parent.maxOffset;
|
|
12980
13031
|
}
|
|
13032
|
+
/**
|
|
13033
|
+
* Checks whether the position is valid in current model tree, that is whether it points to an existing place in the model.
|
|
13034
|
+
*/ isValid() {
|
|
13035
|
+
if (this.offset < 0) {
|
|
13036
|
+
return false;
|
|
13037
|
+
}
|
|
13038
|
+
let parent = this.root;
|
|
13039
|
+
for(let i = 0; i < this.path.length - 1; i++){
|
|
13040
|
+
parent = parent.getChildAtOffset(this.path[i]);
|
|
13041
|
+
if (!parent) {
|
|
13042
|
+
return false;
|
|
13043
|
+
}
|
|
13044
|
+
}
|
|
13045
|
+
return this.offset <= parent.maxOffset;
|
|
13046
|
+
}
|
|
12981
13047
|
/**
|
|
12982
13048
|
* Checks whether this position is before or after given position.
|
|
12983
13049
|
*
|
|
@@ -13615,9 +13681,10 @@ Position.prototype.is = function(type) {
|
|
|
13615
13681
|
* * {@link module:engine/model/position~getNodeAfterPosition}
|
|
13616
13682
|
* * {@link module:engine/model/position~getNodeBeforePosition}
|
|
13617
13683
|
*
|
|
13684
|
+
* @param position
|
|
13618
13685
|
* @param positionParent The parent of the given position.
|
|
13619
13686
|
*/ function getTextNodeAtPosition(position, positionParent) {
|
|
13620
|
-
const node = positionParent.
|
|
13687
|
+
const node = positionParent.getChildAtOffset(position.offset);
|
|
13621
13688
|
if (node && node.is('$text') && node.startOffset < position.offset) {
|
|
13622
13689
|
return node;
|
|
13623
13690
|
}
|
|
@@ -13642,13 +13709,14 @@ Position.prototype.is = function(type) {
|
|
|
13642
13709
|
* * {@link module:engine/model/position~getTextNodeAtPosition}
|
|
13643
13710
|
* * {@link module:engine/model/position~getNodeBeforePosition}
|
|
13644
13711
|
*
|
|
13712
|
+
* @param position Position to check.
|
|
13645
13713
|
* @param positionParent The parent of the given position.
|
|
13646
13714
|
* @param textNode Text node at the given position.
|
|
13647
13715
|
*/ function getNodeAfterPosition(position, positionParent, textNode) {
|
|
13648
13716
|
if (textNode !== null) {
|
|
13649
13717
|
return null;
|
|
13650
13718
|
}
|
|
13651
|
-
return positionParent.
|
|
13719
|
+
return positionParent.getChildAtOffset(position.offset);
|
|
13652
13720
|
}
|
|
13653
13721
|
/**
|
|
13654
13722
|
* Returns the node before the given position.
|
|
@@ -13660,6 +13728,7 @@ Position.prototype.is = function(type) {
|
|
|
13660
13728
|
* * {@link module:engine/model/position~getTextNodeAtPosition}
|
|
13661
13729
|
* * {@link module:engine/model/position~getNodeAfterPosition}
|
|
13662
13730
|
*
|
|
13731
|
+
* @param position Position to check.
|
|
13663
13732
|
* @param positionParent The parent of the given position.
|
|
13664
13733
|
* @param textNode Text node at the given position.
|
|
13665
13734
|
*/ function getNodeBeforePosition(position, positionParent, textNode) {
|
|
@@ -30822,7 +30891,7 @@ const graveyardName = '$graveyard';
|
|
|
30822
30891
|
* @param range A range to check.
|
|
30823
30892
|
* @returns `true` if `range` is valid, `false` otherwise.
|
|
30824
30893
|
*/ _validateSelectionRange(range) {
|
|
30825
|
-
return validateTextNodePosition(range.start) && validateTextNodePosition(range.end);
|
|
30894
|
+
return range.start.isValid() && range.end.isValid() && validateTextNodePosition(range.start) && validateTextNodePosition(range.end);
|
|
30826
30895
|
}
|
|
30827
30896
|
/**
|
|
30828
30897
|
* Performs post-fixer loops. Executes post-fixer callbacks as long as none of them has done any changes to the model.
|
|
@@ -31399,11 +31468,19 @@ Marker.prototype.is = function(type) {
|
|
|
31399
31468
|
/**
|
|
31400
31469
|
* Gets the child at the given index. Returns `null` if incorrect index was passed.
|
|
31401
31470
|
*
|
|
31402
|
-
* @param index Index
|
|
31471
|
+
* @param index Index in this document fragment.
|
|
31403
31472
|
* @returns Child node.
|
|
31404
31473
|
*/ getChild(index) {
|
|
31405
31474
|
return this._children.getNode(index);
|
|
31406
31475
|
}
|
|
31476
|
+
/**
|
|
31477
|
+
* Gets the child at the given offset. Returns `null` if incorrect index was passed.
|
|
31478
|
+
*
|
|
31479
|
+
* @param offset Offset in this document fragment.
|
|
31480
|
+
* @returns Child node.
|
|
31481
|
+
*/ getChildAtOffset(offset) {
|
|
31482
|
+
return this._children.getNodeAtOffset(offset);
|
|
31483
|
+
}
|
|
31407
31484
|
/**
|
|
31408
31485
|
* Returns an iterator that iterates over all of this document fragment's children.
|
|
31409
31486
|
*/ getChildren() {
|
|
@@ -31446,8 +31523,8 @@ Marker.prototype.is = function(type) {
|
|
|
31446
31523
|
*/ getNodeByPath(relativePath) {
|
|
31447
31524
|
// eslint-disable-next-line @typescript-eslint/no-this-alias, consistent-this
|
|
31448
31525
|
let node = this;
|
|
31449
|
-
for (const
|
|
31450
|
-
node = node.
|
|
31526
|
+
for (const offset of relativePath){
|
|
31527
|
+
node = node.getChildAtOffset(offset);
|
|
31451
31528
|
}
|
|
31452
31529
|
return node;
|
|
31453
31530
|
}
|