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/package.json
CHANGED
package/src/viewdesc.js
CHANGED
|
@@ -1091,7 +1091,7 @@ class ViewTreeUpdater {
|
|
|
1091
1091
|
// Tracks whether anything was changed
|
|
1092
1092
|
this.changed = false
|
|
1093
1093
|
|
|
1094
|
-
this.preMatch = preMatch(top.node.content, top
|
|
1094
|
+
this.preMatch = preMatch(top.node.content, top)
|
|
1095
1095
|
}
|
|
1096
1096
|
|
|
1097
1097
|
// Destroy and remove the children between the given indices in
|
|
@@ -1152,17 +1152,14 @@ class ViewTreeUpdater {
|
|
|
1152
1152
|
// Try to find a node desc matching the given data. Skip over it and
|
|
1153
1153
|
// return true when successful.
|
|
1154
1154
|
findNodeMatch(node, outerDeco, innerDeco, index) {
|
|
1155
|
-
let
|
|
1156
|
-
if (index >= this.preMatch.index
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
break
|
|
1161
|
-
}
|
|
1162
|
-
}
|
|
1155
|
+
let found = -1, targetDesc
|
|
1156
|
+
if (index >= this.preMatch.index &&
|
|
1157
|
+
(targetDesc = this.preMatch.matches[index - this.preMatch.index]).parent == this.top &&
|
|
1158
|
+
targetDesc.matchesNode(node, outerDeco, innerDeco)) {
|
|
1159
|
+
found = this.top.children.indexOf(targetDesc, this.index)
|
|
1163
1160
|
} else {
|
|
1164
|
-
for (let i = this.index, e = Math.min(children.length, i + 5); i < e; i++) {
|
|
1165
|
-
let child = children[i]
|
|
1161
|
+
for (let i = this.index, e = Math.min(this.top.children.length, i + 5); i < e; i++) {
|
|
1162
|
+
let child = this.top.children[i]
|
|
1166
1163
|
if (child.matchesNode(node, outerDeco, innerDeco) && !this.preMatch.matched.has(child)) {
|
|
1167
1164
|
found = i
|
|
1168
1165
|
break
|
|
@@ -1274,22 +1271,44 @@ class ViewTreeUpdater {
|
|
|
1274
1271
|
}
|
|
1275
1272
|
}
|
|
1276
1273
|
|
|
1277
|
-
// : (Fragment, [ViewDesc]) → {index: number, matched: Map<ViewDesc, number
|
|
1274
|
+
// : (Fragment, [ViewDesc]) → {index: number, matched: Map<ViewDesc, number>, matches: ViewDesc[]}
|
|
1278
1275
|
// Iterate from the end of the fragment and array of descs to find
|
|
1279
1276
|
// directly matching ones, in order to avoid overeagerly reusing those
|
|
1280
1277
|
// for other nodes. Returns the fragment index of the first node that
|
|
1281
1278
|
// is part of the sequence of matched nodes at the end of the
|
|
1282
1279
|
// fragment.
|
|
1283
|
-
function preMatch(frag,
|
|
1284
|
-
let
|
|
1285
|
-
|
|
1286
|
-
|
|
1280
|
+
function preMatch(frag, parentDesc) {
|
|
1281
|
+
let curDesc = parentDesc, descI = curDesc.children.length
|
|
1282
|
+
let fI = frag.childCount, matched = new Map, matches = []
|
|
1283
|
+
outer: while (fI > 0) {
|
|
1284
|
+
let desc
|
|
1285
|
+
for (;;) {
|
|
1286
|
+
if (descI) {
|
|
1287
|
+
let next = curDesc.children[descI - 1]
|
|
1288
|
+
if (next instanceof MarkViewDesc) {
|
|
1289
|
+
curDesc = next
|
|
1290
|
+
descI = next.children.length
|
|
1291
|
+
} else {
|
|
1292
|
+
desc = next
|
|
1293
|
+
descI--
|
|
1294
|
+
break
|
|
1295
|
+
}
|
|
1296
|
+
} else if (curDesc == parentDesc) {
|
|
1297
|
+
break outer
|
|
1298
|
+
} else {
|
|
1299
|
+
// FIXME
|
|
1300
|
+
descI = curDesc.parent.children.indexOf(curDesc)
|
|
1301
|
+
curDesc = curDesc.parent
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1304
|
+
let node = desc.node
|
|
1287
1305
|
if (!node) continue
|
|
1288
1306
|
if (node != frag.child(fI - 1)) break
|
|
1289
1307
|
--fI
|
|
1290
1308
|
matched.set(desc, fI)
|
|
1309
|
+
matches.push(desc)
|
|
1291
1310
|
}
|
|
1292
|
-
return {index: fI, matched}
|
|
1311
|
+
return {index: fI, matched, matches: matches.reverse()}
|
|
1293
1312
|
}
|
|
1294
1313
|
|
|
1295
1314
|
function compareSide(a, b) { return a.type.side - b.type.side }
|