Skip to content

Selectors

Selectors are pure functions that act like shortcuts for deriving state from the editor context.

import * as selectors from '@portabletext/editor/selectors'

Selectors are commonly used for creating behaviors and toolbar components.

Condition selectors

Condition selectors return a truth response if the condition is met.

  • isActiveAnnotation
  • isActiveDecorator
  • isActiveListItem
  • isActiveStyle
  • isSelectionCollapsed
  • isSelectionExpanded

Getters

Getter type selectors retrieve information from the editor context.

  • getActiveListItem
  • getActiveStyle
  • getSelectedSpans
  • getSelectionText
  • getBlockTextBefore
  • getFocusBlock
  • getFocusListBlock
  • getFocusTextBlock
  • getFocusBlockObjects
  • getFocusChild
  • getFocusSpan
  • getFirstBlock
  • getLastBlock
  • getSelectedBlocks
  • getSelectionStartBlock
  • getSelectionEndBlock
  • getPreviousBlock
  • getNextBlock