prosemirror-view
Advanced tools
Comparing version 1.20.1 to 1.20.2
@@ -0,1 +1,7 @@ | ||
## 1.20.2 (2021-10-07) | ||
### Bug fixes | ||
Fix a crash when pasting whitespace-only content as text. | ||
## 1.20.1 (2021-09-09) | ||
@@ -2,0 +8,0 @@ |
{ | ||
"name": "prosemirror-view", | ||
"version": "1.20.1", | ||
"version": "1.20.2", | ||
"description": "ProseMirror's view component", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -49,3 +49,3 @@ import {Slice, Fragment, DOMParser, DOMSerializer} from "prosemirror-model" | ||
view.someProp("transformPastedText", f => { text = f(text, inCode || plainText) }) | ||
if (inCode) return new Slice(Fragment.from(view.state.schema.text(text.replace(/\r\n?/g, "\n"))), 0, 0) | ||
if (inCode) return text ? new Slice(Fragment.from(view.state.schema.text(text.replace(/\r\n?/g, "\n"))), 0, 0) : Slice.empty | ||
let parsed = view.someProp("clipboardTextParser", f => f(text, $context, plainText)) | ||
@@ -59,3 +59,4 @@ if (parsed) { | ||
text.trim().split(/(?:\r\n?|\n)+/).forEach(block => { | ||
dom.appendChild(document.createElement("p")).appendChild(serializer.serializeNode(schema.text(block, marks))) | ||
let p = dom.appendChild(document.createElement("p")) | ||
if (block) p.appendChild(serializer.serializeNode(schema.text(block, marks))) | ||
}) | ||
@@ -62,0 +63,0 @@ } |
@@ -233,15 +233,15 @@ import {nodeSize, textRange, parentNode} from "./dom" | ||
export function posAtCoords(view, coords) { | ||
let root = view.root, node, offset | ||
if (root.caretPositionFromPoint) { | ||
let doc = view.dom.ownerDocument, node, offset | ||
if (doc.caretPositionFromPoint) { | ||
try { // Firefox throws for this call in hard-to-predict circumstances (#994) | ||
let pos = root.caretPositionFromPoint(coords.left, coords.top) | ||
let pos = doc.caretPositionFromPoint(coords.left, coords.top) | ||
if (pos) ({offsetNode: node, offset} = pos) | ||
} catch (_) {} | ||
} | ||
if (!node && root.caretRangeFromPoint) { | ||
let range = root.caretRangeFromPoint(coords.left, coords.top) | ||
if (!node && doc.caretRangeFromPoint) { | ||
let range = doc.caretRangeFromPoint(coords.left, coords.top) | ||
if (range) ({startContainer: node, startOffset: offset} = range) | ||
} | ||
let elt = root.elementFromPoint(coords.left, coords.top + 1), pos | ||
let elt = (view.root.elementFromPoint ? view.root : doc).elementFromPoint(coords.left, coords.top + 1), pos | ||
if (!elt || !view.dom.contains(elt.nodeType != 1 ? elt.parentNode : elt)) { | ||
@@ -248,0 +248,0 @@ let box = view.dom.getBoundingClientRect() |
@@ -1261,2 +1261,3 @@ import {DOMSerializer, Fragment, Mark} from "prosemirror-model" | ||
if (nodeName == "IMG") dom.className = "ProseMirror-separator" | ||
if (nodeName == "BR") dom.className = "ProseMirror-trailingBreak" | ||
this.top.children.splice(this.index++, 0, new TrailingHackViewDesc(this.top, nothing, dom, null)) | ||
@@ -1263,0 +1264,0 @@ this.changed = true |
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
1574811
14634