1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-30 02:19:52 +02:00

When the parameter passed to isInEditor is a text node use its parent instead (#857)

* When the parameter passed to `isInEditor` is a text node use its parent
for the check.

* Don't reuse `target` parameter. Add details to the comment.
This commit is contained in:
AlbertHilb
2017-06-10 19:47:00 +02:00
committed by Ian Storm Taylor
parent b967cf7c79
commit 56e568d063

View File

@@ -247,9 +247,12 @@ class Content extends React.Component {
isInEditor = (target) => {
const { element } = this
// COMPAT: Text nodes don't have `isContentEditable` property. So, when
// `target` is a text node use its parent element for check.
const el = target.nodeType === 3 ? target.parentElement : target
return (
(target.isContentEditable) &&
(target == element || findClosestNode(target, '[data-slate-editor]') == element)
(el.isContentEditable) &&
(el === element || findClosestNode(el, '[data-slate-editor]') === element)
)
}