New

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

API Referencev1.0.2

@eigenpal/docx-editor-vue/composables

Vue composables mirroring the React `hooks` subpath — history, table selection, find/replace, autosave, clipboard, zoom, and the high-level `useDocxEditor` host composable.

Functions(14)

export declare function useAutoSave(document: MaybeRef<Document | null | undefined>, options?: UseAutoSaveOptions): UseAutoSaveReturn;
export declare function useClipboard(options?: UseClipboardOptions): UseClipboardReturn;
export declare function useCommentSidebarItems(input: UseCommentSidebarItemsOptions): import('vue').ComputedRef<CommentSidebarItem[]>;
export declare function useDocxEditor(options: UseDocxEditorOptions): UseDocxEditorReturn;
export declare function useDragAutoScroll(input: DragAutoScrollOptions): UseDragAutoScrollReturn;
export declare function useFindReplace(hookOptions?: FindReplaceOptions): UseFindReplaceReturn;
export declare function useFixedDropdown(input: UseFixedDropdownOptions): UseFixedDropdownReturn;
export declare function useHistory(view: Ref<EditorView | null>, stateTick: Ref<number>): UseHistoryReturn;
export declare function useSelectionHighlight(options: UseSelectionHighlightOptions): UseSelectionHighlightReturn;
export declare function useTableResize(): UseTableResizeReturn;
export declare function useTableSelection(): UseTableSelectionReturn;

Pass the editor view ref + a stateTick that bumps on every PM transaction (the same tick the Toolbar listens to). The computed re-runs whenever the tick advances.

export declare function useTrackedChanges(view: Ref<EditorView | null>, stateTick: Ref<number>): import('vue').ComputedRef<TrackedChangesResult>;
export declare function useVisualLineNavigation(pagesContainer: Ref<HTMLElement | null>): UseVisualLineNavigationReturn;
export declare function useZoom(initialZoom?: number): UseZoomReturn;

Interfaces(22)

export interface CommentSidebarItem
MemberTypeSummary
anchorKey?string
anchorPosnumber
change?TrackedChangeEntry
comment?Comment
estimatedHeight?number
fixedY?number
idstring
isTemporary?boolean
kind'add-comment' | 'comment' | 'tracked-change'
priority?number
replies?Comment[]
export interface DragAutoScrollOptions
MemberTypeSummary
onScrollExtendSelection(clientX: number, clientY: number) => voidCalled during auto-scroll to extend the selection at the current mouse position.
pagesContainerRef<HTMLElement | null>
export interface FindReplaceOptions
MemberTypeSummary
initialReplaceMode?boolean
onCurrentMatchChange?(match: FindMatch | null, index: number) => void
onMatchesChange?(matches: FindMatch[]) => void
export interface FindReplaceState
MemberTypeSummary
currentIndexnumber
isOpenboolean
matchesFindMatch[]
optionsFindOptions
replaceModeboolean
replaceTextstring
searchTextstring
export interface UseAutoSaveOptions
MemberTypeSummary
debounceDelay?numberDebounce delay for saveOnChange in milliseconds.
enabled?booleanWhether auto-save starts enabled (default: true).
interval?numberAuto-save interval in ms (default: 30000)
maxAge?numberMaximum age of auto-save before it is considered stale.
onError?(error: Error) => voidCallback when save fails.
onRecoveryAvailable?(savedDocument: SavedDocumentData) => voidCallback when recovery data is found.
onSave?(timestamp: Date) => voidCallback when save succeeds.
saveOnChange?booleanWhether document changes trigger a debounced save.
storageKey?stringlocalStorage key (default: 'docx-editor-autosave')
export interface UseAutoSaveReturn
MemberTypeSummary
acceptRecovery() => Document | null
clearAutoSave() => void
disable() => void
dismissRecovery() => void
enable() => void
getRecoveryData() => SavedDocumentData | null
hasRecoveryDataRef<boolean>
isEnabledRef<boolean>
lastSaveTimeRef<Date | null>
save() => Promise<boolean>
statusRef<AutoSaveStatus>
export interface UseClipboardOptions
MemberTypeSummary
cleanWordFormatting?boolean
editable?boolean
onCopy?(selection: ClipboardSelection) => void
onCut?(selection: ClipboardSelection) => void
onError?(error: Error) => void
onPaste?(content: ParsedClipboardContent, asPlainText: boolean) => void
theme?Theme | null
export interface UseClipboardReturn
MemberTypeSummary
copy(selection: ClipboardSelection) => Promise<boolean>
cut(selection: ClipboardSelection) => Promise<boolean>
isProcessingRef<boolean>
lastPastedContentRef<ParsedClipboardContent | null>
paste(asPlainText?: boolean) => Promise<ParsedClipboardContent | null>
export interface UseCommentSidebarItemsOptions
MemberTypeSummary
addCommentYPosition?Ref<number | null>
commentsRef<Comment[]>
isAddingComment?Ref<boolean>
showResolved?Ref<boolean>
trackedChangesRef<TrackedChangeEntry[]>
export interface UseDocxEditorOptions
MemberTypeSummary
externalPlugins?Plugin[]External ProseMirror plugins supplied by the host app.
hiddenContainerRef<HTMLElement | null>Container element for the hidden ProseMirror editor
onChange?(doc: Document) => voidCallback on document change
onError?(error: Error) => voidCallback on error
onSelectionUpdate?() => voidCallback on selection change
pageGap?numberPage gap in pixels
pagesContainerRef<HTMLElement | null>Container element for the visible pages
readOnly?MaybeRef<boolean>Whether the editor is read-only
syncCoordinator?LayoutSelectionGateCoordinates layout updates with visible selection/decoration overlays.
export interface UseDocxEditorReturn
MemberTypeSummary
destroy() => voidDestroy the editor view and clean up listeners.
editorStateShallowRef<EditorState | null>Latest editor state. Updated on each transaction.
editorViewShallowRef<EditorView | null>ProseMirror editor view (hidden).
focus() => voidFocus the hidden ProseMirror view.
getCommands() => CommandMapAccess the extension command map for invoking marks/nodes/features.
getDocument() => Document | nullSnapshot the current document model.
isReadyRef<boolean>True once the editor view has mounted and a document is loaded.
layoutShallowRef<Layout | null>Computed page layout.
loadBuffer(buffer: ArrayBuffer | Uint8Array | Blob | File) => Promise<void>Load a DOCX from a binary buffer.
loadDocument(doc: Document) => voidLoad a parsed `Document` directly.
parseErrorRef<string | null>Last parse error message, or null if the most recent load succeeded.
reLayout() => voidForce a re-layout without a doc change (e.g. after page-setup changes).
save() => Promise<Blob | null>Serialize the current document to a DOCX blob.
export interface UseDragAutoScrollReturn
MemberTypeSummary
stopAutoScroll() => void
updateMousePosition(clientX: number, clientY: number) => void
export interface UseFindReplaceReturn
MemberTypeSummary
close() => void
currentMatchComputedRef<FindMatch | null>
goToMatch(index: number) => void
goToNextMatch() => number
goToPreviousMatch() => number
hasMatchesComputedRef<boolean>
openFind(selectedText?: string) => void
openReplace(selectedText?: string) => void
setMatches(matches: FindMatch[], currentIndex?: number) => void
setOptions(opts: Partial<FindOptions>) => void
setReplaceText(text: string) => void
setSearchText(text: string) => void
stateFindReplaceState
toggle() => void
export interface UseFixedDropdownOptions
MemberTypeSummary
align?'left' | 'right''left' aligns dropdown left edge to trigger, 'right' aligns right edge.
isOpenRef<boolean>
onClose() => void
export interface UseFixedDropdownReturn
MemberTypeSummary
containerRefRef<HTMLElement | null>
dropdownRefRef<HTMLElement | null>
dropdownStyleRef<CSSProperties>
handleMouseDown(e: MouseEvent) => void
export interface UseHistoryReturn
MemberTypeSummary
canRedoComputedRef<boolean>
canUndoComputedRef<boolean>
redo() => boolean
undo() => boolean
export interface UseSelectionHighlightOptions
MemberTypeSummary
config?SelectionHighlightConfig
containerRefRef<HTMLElement | null>
debounceMs?number
enabled?boolean
onSelectionChange?(hasSelection: boolean, text: string) => void
useOverlay?boolean
export interface UseSelectionHighlightReturn
MemberTypeSummary
getOverlayStyle(rect: HighlightRect) => CSSProperties
hasSelectionComputedRef<boolean>
highlightRectsComputedRef<HighlightRect[]>
isSelectionInContainerComputedRef<boolean>
refresh() => void
selectedTextComputedRef<string>
export interface UseTableResizeReturn
MemberTypeSummary
install() => () => void
isResizing() => boolean
tryStartResize(e: MouseEvent, view: EditorView) => boolean
export interface UseTableSelectionReturn
MemberTypeSummary
clearSelection() => void
handleCellClick(tableIndex: number, rowIndex: number, columnIndex: number) => void
handleClickTarget(target: EventTarget | null, container?: HTMLElement | null) => void
isCellSelected(tableIndex: number, rowIndex: number, columnIndex: number) => boolean
selectedCellRef<CellCoordinates | null>
export interface UseVisualLineNavigationReturn
MemberTypeSummary
findLineElementAtPosition(pmPos: number) => HTMLElement | null
findPositionOnLineAtClientX(line: HTMLElement, clientX: number) => number | null
getCaretClientX(pmPos: number) => number | null
handlePMKeyDown(view: EditorView, event: KeyboardEvent) => boolean
stateReturnType<typeof createVisualLineState>
export interface UseZoomReturn
MemberTypeSummary
handleKeyDown(e: KeyboardEvent) => void
handleWheel(e: WheelEvent) => void
installShortcuts() => void
isMaxZoomComputedRef<boolean>
isMinZoomComputedRef<boolean>
resetZoom() => void
setZoom(level: number) => void
ZOOM_PRESETSnumber[]
zoomRef<number>
zoomIn() => void
zoomOut() => void
zoomPercentComputedRef<number>