New

docx-editor 1.x has shipped. Vue support, i18n, agents. Read the migration guide →

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)

Create selection tracker plugin

declare function createSelectionTrackerPlugin(onSelectionChange?: SelectionChangeCallback): Plugin;

Extract selection context from editor state

declare function extractSelectionContext(state: EditorState): SelectionContext;

Get current selection context from editor state

declare function getSelectionContext(state: EditorState): SelectionContext | null;

Interfaces(1)

Selection context for toolbar state

interface SelectionContext
MemberTypeSummary
activeCommentIdsnumber[]Active comment IDs at cursor position
endParagraphIndexnumberEnd paragraph index
hasSelectionbooleanWhether there's a non-collapsed selection
inDeletionbooleanWhether cursor is inside a tracked deletion
inInsertionbooleanWhether cursor is inside a tracked insertion
inListbooleanWhether cursor is in a list
isMultiParagraphbooleanWhether selection spans multiple paragraphs
listLevel?numberList level (0-8)
listType?'bullet' | 'numbered'List type if in list
paragraphFormattingParagraphFormattingCurrent paragraph formatting
startParagraphIndexnumberStart paragraph index
textFormattingTextFormattingCurrent text formatting at cursor/selection

Type aliases(1)

Callback type for selection changes

type SelectionChangeCallback = (context: SelectionContext) => void;

Variables(1)

Plugin key for accessing selection tracker state

selectionTrackerKey: PluginKey<SelectionContext>