UNPKG

@portabletext/editor

Version:

Portable Text Editor made in React

16 lines (13 loc) 451 B
import {Transforms} from 'slate' import {toSlateRange} from '../internal-utils/ranges' import type {BehaviorActionImplementation} from './behavior.actions' export const selectActionImplementation: BehaviorActionImplementation< 'select' > = ({action}) => { const newSelection = toSlateRange(action.at, action.editor) if (newSelection) { Transforms.select(action.editor, newSelection) } else { Transforms.deselect(action.editor) } }