UNPKG

@portabletext/editor

Version:

Portable Text Editor made in React

22 lines (19 loc) 567 B
import { isPortableTextSpan, type KeyedSegment, type PortableTextObject, } from '@sanity/types' import type {EditorSelector} from '../editor/editor-selector' import {getFocusChild} from './selectors' /** * @public */ export const getFocusInlineObject: EditorSelector< | {node: PortableTextObject; path: [KeyedSegment, 'children', KeyedSegment]} | undefined > = (snapshot) => { const focusChild = getFocusChild(snapshot) return focusChild && !isPortableTextSpan(focusChild.node) ? {node: focusChild.node, path: focusChild.path} : undefined }