UNPKG

phx-react

Version:

PHX REACT

18 lines 597 B
import { $isAtNodeEnd } from '@lexical/selection'; export function getSelectedNode(selection) { const anchor = selection.anchor; const focus = selection.focus; const anchorNode = selection.anchor.getNode(); const focusNode = selection.focus.getNode(); if (anchorNode === focusNode) { return anchorNode; } const isBackward = selection.isBackward(); if (isBackward) { return $isAtNodeEnd(focus) ? anchorNode : focusNode; } else { return $isAtNodeEnd(anchor) ? anchorNode : focusNode; } } //# sourceMappingURL=getSelectedNode.js.map