UNPKG

@portabletext/editor

Version:

Portable Text Editor made in React

18 lines (15 loc) 458 B
import type {EditorSelector} from '../editor/editor-selector' /** * @public */ export const isSelectionCollapsed: EditorSelector<boolean> = (snapshot) => { if (!snapshot.context.selection) { return false } return ( JSON.stringify(snapshot.context.selection.anchor.path) === JSON.stringify(snapshot.context.selection.focus.path) && snapshot.context.selection?.anchor.offset === snapshot.context.selection?.focus.offset ) }