prosemirror-view
Advanced tools
Comparing version 1.20.0 to 1.20.1
@@ -0,1 +1,11 @@ | ||
## 1.20.1 (2021-09-09) | ||
### Bug fixes | ||
The library accidentally allowed node decorations on text nodes. It no longer does. | ||
Fix an issue on Chrome and Safari where coordinates for positions between uneditable nodes and the end of a textblock would return zero-height rectangles. | ||
Fix a bug where vertical `endOfTextblock` queries could inappropriately return true when a small line height is used. | ||
## 1.20.0 (2021-09-03) | ||
@@ -2,0 +12,0 @@ |
{ | ||
"name": "prosemirror-view", | ||
"version": "1.20.0", | ||
"version": "1.20.1", | ||
"description": "ProseMirror's view component", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -68,4 +68,4 @@ function compareObjs(a, b) { | ||
valid(node, span) { | ||
let {index, offset} = node.content.findIndex(span.from) | ||
return offset == span.from && offset + node.child(index).nodeSize == span.to | ||
let {index, offset} = node.content.findIndex(span.from), child | ||
return offset == span.from && !(child = node.child(index)).isText && offset + child.nodeSize == span.to | ||
} | ||
@@ -72,0 +72,0 @@ |
@@ -354,3 +354,4 @@ import {nodeSize, textRange, parentNode} from "./dom" | ||
let after = node.childNodes[offset] | ||
let target = after.nodeType == 3 ? textRange(after, 0, (supportEmptyRange ? 0 : 1)) | ||
while (after.pmViewDesc && after.pmViewDesc.ignoreForCoords) after = after.nextSibling | ||
let target = !after ? null : after.nodeType == 3 ? textRange(after, 0, (supportEmptyRange ? 0 : 1)) | ||
: after.nodeType == 1 ? after : null | ||
@@ -409,3 +410,5 @@ if (target) return flattenV(singleRect(target, -1), true) | ||
let box = boxes[i] | ||
if (box.bottom > box.top && (dir == "up" ? box.bottom < coords.top + 1 : box.top > coords.bottom - 1)) | ||
if (box.bottom > box.top + 1 && | ||
(dir == "up" ? coords.top - box.top > (box.bottom - coords.top) * 2 | ||
: box.bottom - coords.bottom > (coords.bottom - box.top) * 2)) | ||
return false | ||
@@ -412,0 +415,0 @@ } |
@@ -118,4 +118,2 @@ import {DOMSerializer, Fragment, Mark} from "prosemirror-model" | ||
get beforePosition() { return false } | ||
// : () → ?ParseRule | ||
@@ -269,19 +267,30 @@ // When parsing in-editor content (in domchange.js), we allow | ||
if (!this.contentDOM) return {node: this.dom, offset: 0} | ||
for (let offset = 0, i = 0, first = true;; i++, first = false) { | ||
// Skip removed or always-before children | ||
while (i < this.children.length && (this.children[i].beforePosition || | ||
this.children[i].dom.parentNode != this.contentDOM)) | ||
offset += this.children[i++].size | ||
let child = i == this.children.length ? null : this.children[i] | ||
if (offset == pos && (side == 0 || !child || !child.size || child.border || (side < 0 && first)) || | ||
child && child.domAtom && pos < offset + child.size) return { | ||
node: this.contentDOM, | ||
offset: child ? domIndex(child.dom) : this.contentDOM.childNodes.length | ||
// First find the position in the child array | ||
let i = 0, offset = 0 | ||
for (let curPos = 0; i < this.children.length; i++) { | ||
let child = this.children[i], end = curPos + child.size | ||
if (end > pos || child instanceof TrailingHackViewDesc) { offset = pos - curPos; break } | ||
curPos = end | ||
} | ||
// If this points into the middle of a child, call through | ||
if (offset) return this.children[i].domFromPos(offset - this.children[i].border, side) | ||
// Go back if there were any zero-length widgets with side >= 0 before this point | ||
for (let prev; i && !(prev = this.children[i - 1]).size && prev instanceof WidgetViewDesc && prev.widget.type.side >= 0; i--) {} | ||
// Scan towards the first useable node | ||
if (side <= 0) { | ||
let prev, enter = true | ||
for (;; i--, enter = false) { | ||
prev = i ? this.children[i - 1] : null | ||
if (!prev || prev.dom.parentNode == this.contentDOM) break | ||
} | ||
if (!child) throw new Error("Invalid position " + pos) | ||
let end = offset + child.size | ||
if (!child.domAtom && (side < 0 && !child.border ? end >= pos : end > pos) && | ||
(end > pos || i + 1 >= this.children.length || !this.children[i + 1].beforePosition)) | ||
return child.domFromPos(pos - offset - child.border, side) | ||
offset = end | ||
if (prev && side && enter && !prev.border && !prev.domAtom) return prev.domFromPos(prev.size, side) | ||
return {node: this.contentDOM, offset: prev ? domIndex(prev.dom) + 1 : 0} | ||
} else { | ||
let next, enter = true | ||
for (;; i++, enter = false) { | ||
next = i < this.children.length ? this.children[i] : null | ||
if (!next || next.dom.parentNode == this.contentDOM) break | ||
} | ||
if (next && enter && !next.border && !next.domAtom) return next.domFromPos(0, side) | ||
return {node: this.contentDOM, offset: next ? domIndex(next.dom) : this.contentDOM.childNodes.length} | ||
} | ||
@@ -475,2 +484,4 @@ } | ||
get domAtom() { return false } | ||
get ignoreForCoords() { return false } | ||
} | ||
@@ -506,6 +517,2 @@ | ||
get beforePosition() { | ||
return this.widget.type.side < 0 | ||
} | ||
matchesWidget(widget) { | ||
@@ -886,2 +893,3 @@ return this.dirty == NOT_DIRTY && widget.type.eq(this.widget.type) | ||
get domAtom() { return true } | ||
get ignoreForCoords() { return this.dom.nodeName == "IMG" } | ||
} | ||
@@ -888,0 +896,0 @@ |
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
1573391
14628