UNPKG

@portabletext/editor

Version:

Portable Text Editor made in React

21 lines (17 loc) 442 B
import type {EditorSelection} from '../types/editor' import {isKeyedSegment} from '../utils' export function getSelectionBlockKeys(selection: EditorSelection) { if (!selection) { return undefined } if ( !isKeyedSegment(selection.anchor.path[0]) || !isKeyedSegment(selection.focus.path[0]) ) { return undefined } return { anchor: selection.anchor.path[0]._key, focus: selection.focus.path[0]._key, } }