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