@eigenpal/docx-editor-core/prosemirror/plugins
ProseMirror Plugins
Selection tracker plugin for the DOCX editor. Keymap plugins are now provided by the extension system.
Functions(7)
createSelectionTrackerPlugin
Create selection tracker plugin
declare function createSelectionTrackerPlugin(onSelectionChange?: SelectionChangeCallback): Plugin;createSuggestionModePlugin
Create the suggestion mode plugin. When active, text edits become tracked changes.
declare function createSuggestionModePlugin(initialActive?: boolean, author?: string): Plugin;extractSelectionContext
Extract selection context from editor state
declare function extractSelectionContext(state: EditorState): SelectionContext;getSelectionContext
Get current selection context from editor state
declare function getSelectionContext(state: EditorState): SelectionContext | null;isSuggestionModeActive
Check if suggestion mode is currently active.
declare function isSuggestionModeActive(state: EditorState): boolean;setSuggestionMode
Set suggestion mode active state and author.
declare function setSuggestionMode(active: boolean, state: EditorState, dispatch?: (tr: Transaction) => void, author?: string): boolean;toggleSuggestionMode
Toggle suggestion mode on/off.
declare function toggleSuggestionMode(state: EditorState, dispatch?: (tr: Transaction) => void): boolean;Interfaces(1)
SelectionContext
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)
SelectionChangeCallback
Callback type for selection changes
type SelectionChangeCallback = (context: SelectionContext) => void;Variables(2)
selectionTrackerKey
Plugin key for accessing selection tracker state
selectionTrackerKey: PluginKey<SelectionContext>suggestionModeKey
Suggestion Mode Plugin
When active, intercepts all text insertions and deletions, wrapping them in tracked change marks (insertion/deletion) instead of modifying the document directly.
- Typed text is marked as insertion (green underline) - Deleted text is NOT removed — it's marked as deletion (red strikethrough) - Text already marked as insertion by the current author is deleted normally (retracting your own suggestion)
suggestionModeKey: PluginKey<SuggestionModeState>