mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-09-01 03:11:44 +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) => {
|
isInEditor = (target) => {
|
||||||
const { element } = this
|
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 (
|
return (
|
||||||
(target.isContentEditable) &&
|
(el.isContentEditable) &&
|
||||||
(target == element || findClosestNode(target, '[data-slate-editor]') == element)
|
(el === element || findClosestNode(el, '[data-slate-editor]') === element)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user