Constrain from to non-negative numbers (#987)

Fix #954
This commit is contained in:
Max Reynolds
2021-03-29 20:07:28 +01:00
committed by GitHub
parent ab147048cc
commit 4f1dfbc1ff

View File

@@ -3,7 +3,7 @@ import { Plugin, PluginKey } from 'prosemirror-state'
function textRange(node, from, to) { function textRange(node, from, to) {
const range = document.createRange() const range = document.createRange()
range.setEnd(node, to == null ? node.nodeValue.length : to) range.setEnd(node, to == null ? node.nodeValue.length : to)
range.setStart(node, from || 0) range.setStart(node, Math.max(from, 0))
return range return range
} }