mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-30 10:29:48 +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:
committed by
Ian Storm Taylor
parent
b967cf7c79
commit
56e568d063
@@ -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)
|
||||
)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user