prosemirror-view 1.23.1 → 1.23.2
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/CHANGELOG.md +6 -0
- package/dist/index.es.js +37 -18
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +37 -18
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/viewdesc.js +36 -17
package/CHANGELOG.md
CHANGED
package/dist/index.es.js
CHANGED
|
@@ -1747,7 +1747,7 @@ var ViewTreeUpdater = function ViewTreeUpdater(top, lockedNode) {
|
|
|
1747
1747
|
// Tracks whether anything was changed
|
|
1748
1748
|
this.changed = false;
|
|
1749
1749
|
|
|
1750
|
-
this.preMatch = preMatch(top.node.content, top
|
|
1750
|
+
this.preMatch = preMatch(top.node.content, top);
|
|
1751
1751
|
};
|
|
1752
1752
|
|
|
1753
1753
|
// Destroy and remove the children between the given indices in
|
|
@@ -1808,19 +1808,16 @@ ViewTreeUpdater.prototype.syncToMarks = function syncToMarks (marks, inline, vie
|
|
|
1808
1808
|
// Try to find a node desc matching the given data. Skip over it and
|
|
1809
1809
|
// return true when successful.
|
|
1810
1810
|
ViewTreeUpdater.prototype.findNodeMatch = function findNodeMatch (node, outerDeco, innerDeco, index) {
|
|
1811
|
-
var
|
|
1812
|
-
if (index >= this.preMatch.index
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
break
|
|
1817
|
-
}
|
|
1818
|
-
}
|
|
1811
|
+
var found = -1, targetDesc;
|
|
1812
|
+
if (index >= this.preMatch.index &&
|
|
1813
|
+
(targetDesc = this.preMatch.matches[index - this.preMatch.index]).parent == this.top &&
|
|
1814
|
+
targetDesc.matchesNode(node, outerDeco, innerDeco)) {
|
|
1815
|
+
found = this.top.children.indexOf(targetDesc, this.index);
|
|
1819
1816
|
} else {
|
|
1820
|
-
for (var i
|
|
1821
|
-
var child = children[i
|
|
1817
|
+
for (var i = this.index, e = Math.min(this.top.children.length, i + 5); i < e; i++) {
|
|
1818
|
+
var child = this.top.children[i];
|
|
1822
1819
|
if (child.matchesNode(node, outerDeco, innerDeco) && !this.preMatch.matched.has(child)) {
|
|
1823
|
-
found = i
|
|
1820
|
+
found = i;
|
|
1824
1821
|
break
|
|
1825
1822
|
}
|
|
1826
1823
|
}
|
|
@@ -1929,22 +1926,44 @@ ViewTreeUpdater.prototype.addHackNode = function addHackNode (nodeName) {
|
|
|
1929
1926
|
}
|
|
1930
1927
|
};
|
|
1931
1928
|
|
|
1932
|
-
// : (Fragment, [ViewDesc]) → {index: number, matched: Map<ViewDesc, number
|
|
1929
|
+
// : (Fragment, [ViewDesc]) → {index: number, matched: Map<ViewDesc, number>, matches: ViewDesc[]}
|
|
1933
1930
|
// Iterate from the end of the fragment and array of descs to find
|
|
1934
1931
|
// directly matching ones, in order to avoid overeagerly reusing those
|
|
1935
1932
|
// for other nodes. Returns the fragment index of the first node that
|
|
1936
1933
|
// is part of the sequence of matched nodes at the end of the
|
|
1937
1934
|
// fragment.
|
|
1938
|
-
function preMatch(frag,
|
|
1939
|
-
var
|
|
1940
|
-
|
|
1941
|
-
|
|
1935
|
+
function preMatch(frag, parentDesc) {
|
|
1936
|
+
var curDesc = parentDesc, descI = curDesc.children.length;
|
|
1937
|
+
var fI = frag.childCount, matched = new Map, matches = [];
|
|
1938
|
+
outer: while (fI > 0) {
|
|
1939
|
+
var desc = (void 0);
|
|
1940
|
+
for (;;) {
|
|
1941
|
+
if (descI) {
|
|
1942
|
+
var next = curDesc.children[descI - 1];
|
|
1943
|
+
if (next instanceof MarkViewDesc) {
|
|
1944
|
+
curDesc = next;
|
|
1945
|
+
descI = next.children.length;
|
|
1946
|
+
} else {
|
|
1947
|
+
desc = next;
|
|
1948
|
+
descI--;
|
|
1949
|
+
break
|
|
1950
|
+
}
|
|
1951
|
+
} else if (curDesc == parentDesc) {
|
|
1952
|
+
break outer
|
|
1953
|
+
} else {
|
|
1954
|
+
// FIXME
|
|
1955
|
+
descI = curDesc.parent.children.indexOf(curDesc);
|
|
1956
|
+
curDesc = curDesc.parent;
|
|
1957
|
+
}
|
|
1958
|
+
}
|
|
1959
|
+
var node = desc.node;
|
|
1942
1960
|
if (!node) { continue }
|
|
1943
1961
|
if (node != frag.child(fI - 1)) { break }
|
|
1944
1962
|
--fI;
|
|
1945
1963
|
matched.set(desc, fI);
|
|
1964
|
+
matches.push(desc);
|
|
1946
1965
|
}
|
|
1947
|
-
return {index: fI, matched: matched}
|
|
1966
|
+
return {index: fI, matched: matched, matches: matches.reverse()}
|
|
1948
1967
|
}
|
|
1949
1968
|
|
|
1950
1969
|
function compareSide(a, b) { return a.type.side - b.type.side }
|