prosemirror-view
Advanced tools
Comparing version 1.23.1 to 1.23.2
{ | ||
"name": "prosemirror-view", | ||
"version": "1.23.1", | ||
"version": "1.23.2", | ||
"description": "ProseMirror's view component", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -1094,3 +1094,3 @@ import {DOMSerializer, Fragment, Mark} from "prosemirror-model" | ||
this.preMatch = preMatch(top.node.content, top.children) | ||
this.preMatch = preMatch(top.node.content, top) | ||
} | ||
@@ -1156,13 +1156,10 @@ | ||
findNodeMatch(node, outerDeco, innerDeco, index) { | ||
let children = this.top.children, found = -1 | ||
if (index >= this.preMatch.index) { | ||
for (let i = this.index; i < children.length; i++) { | ||
if (this.preMatch.matched.get(children[i]) == index) { | ||
if (children[i].matchesNode(node, outerDeco, innerDeco)) found = i | ||
break | ||
} | ||
} | ||
let found = -1, targetDesc | ||
if (index >= this.preMatch.index && | ||
(targetDesc = this.preMatch.matches[index - this.preMatch.index]).parent == this.top && | ||
targetDesc.matchesNode(node, outerDeco, innerDeco)) { | ||
found = this.top.children.indexOf(targetDesc, this.index) | ||
} else { | ||
for (let i = this.index, e = Math.min(children.length, i + 5); i < e; i++) { | ||
let child = children[i] | ||
for (let i = this.index, e = Math.min(this.top.children.length, i + 5); i < e; i++) { | ||
let child = this.top.children[i] | ||
if (child.matchesNode(node, outerDeco, innerDeco) && !this.preMatch.matched.has(child)) { | ||
@@ -1279,3 +1276,3 @@ found = i | ||
// : (Fragment, [ViewDesc]) → {index: number, matched: Map<ViewDesc, number>} | ||
// : (Fragment, [ViewDesc]) → {index: number, matched: Map<ViewDesc, number>, matches: ViewDesc[]} | ||
// Iterate from the end of the fragment and array of descs to find | ||
@@ -1286,6 +1283,27 @@ // directly matching ones, in order to avoid overeagerly reusing those | ||
// fragment. | ||
function preMatch(frag, descs) { | ||
let fI = frag.childCount, dI = descs.length, matched = new Map | ||
for (; fI > 0 && dI > 0; dI--) { | ||
let desc = descs[dI - 1], node = desc.node | ||
function preMatch(frag, parentDesc) { | ||
let curDesc = parentDesc, descI = curDesc.children.length | ||
let fI = frag.childCount, matched = new Map, matches = [] | ||
outer: while (fI > 0) { | ||
let desc | ||
for (;;) { | ||
if (descI) { | ||
let next = curDesc.children[descI - 1] | ||
if (next instanceof MarkViewDesc) { | ||
curDesc = next | ||
descI = next.children.length | ||
} else { | ||
desc = next | ||
descI-- | ||
break | ||
} | ||
} else if (curDesc == parentDesc) { | ||
break outer | ||
} else { | ||
// FIXME | ||
descI = curDesc.parent.children.indexOf(curDesc) | ||
curDesc = curDesc.parent | ||
} | ||
} | ||
let node = desc.node | ||
if (!node) continue | ||
@@ -1295,4 +1313,5 @@ if (node != frag.child(fI - 1)) break | ||
matched.set(desc, fI) | ||
matches.push(desc) | ||
} | ||
return {index: fI, matched} | ||
return {index: fI, matched, matches: matches.reverse()} | ||
} | ||
@@ -1299,0 +1318,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1590238
14811