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

ProseMirror Plugins

Selection tracker plugin for the DOCX editor. Keymap plugins are now provided by the extension system.

Functions(7)

Create selection tracker plugin

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

Create the suggestion mode plugin. When active, text edits become tracked changes.

declare function createSuggestionModePlugin(initialActive?: boolean, author?: string): 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;

Check if suggestion mode is currently active.

declare function isSuggestionModeActive(state: EditorState): boolean;

Set suggestion mode active state and author.

declare function setSuggestionMode(active: boolean, state: EditorState, dispatch?: (tr: Transaction) => void, author?: string): boolean;

Toggle suggestion mode on/off.

declare function toggleSuggestionMode(state: EditorState, dispatch?: (tr: Transaction) => void): boolean;

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(2)

Plugin key for accessing selection tracker state

selectionTrackerKey: PluginKey<SelectionContext>

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>