UNPKG

@portabletext/editor

Version:

Portable Text Editor made in React

15 lines (12 loc) 408 B
import type {PortableTextBlock} from '@sanity/types' import type {EditorSelector} from '../editor/editor-selector' import type {BlockPath} from '../types/paths' /** * @public */ export const getFirstBlock: EditorSelector< {node: PortableTextBlock; path: BlockPath} | undefined > = (snapshot) => { const node = snapshot.context.value[0] return node ? {node, path: [{_key: node._key}]} : undefined }