Selectors API Overview
Selectors are pure functions that act like shortcuts for deriving state from the editor snapshot.
import * as selectors from '@portabletext/editor/selectors'
Selectors are commonly used for creating behaviors and toolbar components.
Create a behavior Custom behaviors let you control how the editor reacts to events and input.
Customize the toolbar Create custom toolbar components for your editor.
Condition selectors
Section titled “Condition selectors”Condition selectors return a truth response if the condition is met.
- isActiveAnnotation
- isActiveDecorator
- isActiveListItem
- isActiveStyle
- isSelectionCollapsed
- isSelectionExpanded
Getters
Section titled “Getters”Getter type selectors retrieve information from the editor snapshot.
- getActiveListItem
- getActiveStyle
- getSelectedSpans
- getSelectionText
- getBlockTextBefore
- getFocusBlock
- getFocusListBlock
- getFocusTextBlock
- getFocusBlockObjects
- getFocusChild
- getFocusSpan
- getFirstBlock
- getLastBlock
- getSelectedBlocks
- getSelectionStartBlock
- getSelectionEndBlock
- getPreviousBlock
- getNextBlock