Skip to content

Hooks

useEditor

Access the editor context. Commonly used when building toolbars or passing context to selectors.

import {useEditor} from '@portabletext/editor'
const editor = useEditor()

useEditorSelector

Access selectors in areas where the context is unavailable by combining with useEditor.

import {useEditor, useEditorSelector} from '@portabletext/editor'
import * as selectors from '@portabletext/editor/selectors'
const editor = useEditor()
const isActive = useEditorSelector(editor, selectors.isActiveDecorator('em'))