Path: blob/master/src/packages/frontend/editors/slate/slate-react/components/dom-utils.ts
1698 views
/* Some utility functions factored out of editable.tsx */12import { ReactEditor } from "..";3import { Editor, Element } from "slate";45import { DOMNode, isDOMNode } from "../utils/dom";67/**8* Check if the target is inside void and in the editor.9*/1011export const isTargetInsideVoid = (12editor: ReactEditor,13target: EventTarget | null14): boolean => {15const slateNode =16hasTarget(editor, target) && ReactEditor.toSlateNode(editor, target);17return Element.isElement(slateNode) && Editor.isVoid(editor, slateNode);18};1920/**21* Check if the target is editable and in the editor.22*/2324export const hasEditableTarget = (25editor: ReactEditor,26target: EventTarget | null27): target is DOMNode => {28return (29isDOMNode(target) &&30ReactEditor.hasDOMNode(editor, target, { editable: true })31);32};3334/**35* Check if the target is in the editor.36*/3738export const hasTarget = (39editor: ReactEditor,40target: EventTarget | null41): target is DOMNode => {42return isDOMNode(target) && ReactEditor.hasDOMNode(editor, target);43};444546