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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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