API Referencev1.0.2
@eigenpal/docx-editor-core/prosemirror/plugins/selectionTracker
Selection Tracker Plugin
Tracks selection changes and emits events for toolbar state updates. Provides the current selection context including: - Text formatting at cursor/selection - Paragraph formatting - Selection range information
Functions(3)
fn
packages/core/src/prosemirror/plugins/selectionTracker.ts:244createSelectionTrackerPlugin
Create selection tracker plugin
declare function createSelectionTrackerPlugin(onSelectionChange?: SelectionChangeCallback): Plugin;fn
packages/core/src/prosemirror/plugins/selectionTracker.ts:61extractSelectionContext
Extract selection context from editor state
declare function extractSelectionContext(state: EditorState): SelectionContext;fn
packages/core/src/prosemirror/plugins/selectionTracker.ts:322getSelectionContext
Get current selection context from editor state
declare function getSelectionContext(state: EditorState): SelectionContext | null;Interfaces(1)
interface
packages/core/src/prosemirror/plugins/selectionTracker.ts:21SelectionContext
Selection context for toolbar state
interface SelectionContext| Member | Type | Summary |
|---|---|---|
| activeCommentIds | number[] | Active comment IDs at cursor position |
| endParagraphIndex | number | End paragraph index |
| hasSelection | boolean | Whether there's a non-collapsed selection |
| inDeletion | boolean | Whether cursor is inside a tracked deletion |
| inInsertion | boolean | Whether cursor is inside a tracked insertion |
| inList | boolean | Whether cursor is in a list |
| isMultiParagraph | boolean | Whether selection spans multiple paragraphs |
| listLevel? | number | List level (0-8) |
| listType? | 'bullet' | 'numbered' | List type if in list |
| paragraphFormatting | ParagraphFormatting | Current paragraph formatting |
| startParagraphIndex | number | Start paragraph index |
| textFormatting | TextFormatting | Current text formatting at cursor/selection |
Type aliases(1)
type
packages/core/src/prosemirror/plugins/selectionTracker.ts:56SelectionChangeCallback
Callback type for selection changes
type SelectionChangeCallback = (context: SelectionContext) => void;Variables(1)
const
packages/core/src/prosemirror/plugins/selectionTracker.ts:51selectionTrackerKey
Plugin key for accessing selection tracker state
selectionTrackerKey: PluginKey<SelectionContext>