1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-02-01 05:16:10 +01:00

fix onClick when not finding a node

This commit is contained in:
Ian Storm Taylor 2018-09-26 13:12:35 -07:00
parent bf9b03e634
commit af8432f639

View File

@ -165,11 +165,18 @@ function AfterPlugin() {
*/
function onClick(event, change, editor) {
if (editor.props.readOnly) return true
if (editor.props.readOnly) {
return true
}
const { value } = change
const { document, schema } = value
const node = findNode(event.target, value)
if (!node) {
return
}
const ancestors = document.getAncestors(node.key)
const isVoid =
node && (schema.isVoid(node) || ancestors.some(a => schema.isVoid(a)))