@zeke-02/docx-editor-react 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +122 -0
  3. package/dist/FindReplaceDialog-25PDOTC7.js +1 -0
  4. package/dist/FindReplaceDialog-6PLDD22H.mjs +1 -0
  5. package/dist/FootnotePropertiesDialog-JIWAFAKL.js +1 -0
  6. package/dist/FootnotePropertiesDialog-SZYOYLR3.mjs +1 -0
  7. package/dist/HyperlinkDialog-G5FFKLWY.js +1 -0
  8. package/dist/HyperlinkDialog-PSJ6P3E3.mjs +1 -0
  9. package/dist/ImagePositionDialog-DTGYFFAR.js +1 -0
  10. package/dist/ImagePositionDialog-FKBG2MSL.mjs +1 -0
  11. package/dist/ImagePropertiesDialog-SO6RAOT6.js +1 -0
  12. package/dist/ImagePropertiesDialog-T77XMKJF.mjs +1 -0
  13. package/dist/KeyboardShortcutsDialog-04AoVwn3.d.mts +415 -0
  14. package/dist/KeyboardShortcutsDialog-04AoVwn3.d.ts +415 -0
  15. package/dist/PageSetupDialog-Q7UGLILM.mjs +1 -0
  16. package/dist/PageSetupDialog-XMG64O3T.js +1 -0
  17. package/dist/PrintPreview-DEhwRBC_.d.mts +93 -0
  18. package/dist/PrintPreview-DEhwRBC_.d.ts +93 -0
  19. package/dist/SplitCellDialog-NPGW4JGQ.mjs +1 -0
  20. package/dist/SplitCellDialog-RNP37SKZ.js +1 -0
  21. package/dist/TablePropertiesDialog-3QNCWNEG.mjs +1 -0
  22. package/dist/TablePropertiesDialog-AQVM7FGA.js +1 -0
  23. package/dist/chunk-2DBLZSGF.js +1 -0
  24. package/dist/chunk-3QCOIABL.js +2 -0
  25. package/dist/chunk-45GFZZ45.mjs +1 -0
  26. package/dist/chunk-4RTT4L2S.js +1 -0
  27. package/dist/chunk-7DAI755K.mjs +1 -0
  28. package/dist/chunk-BJ5RZW6Y.js +1 -0
  29. package/dist/chunk-BMBP5UFA.mjs +1 -0
  30. package/dist/chunk-DZHU5RSL.mjs +2 -0
  31. package/dist/chunk-FZ357PVD.mjs +2 -0
  32. package/dist/chunk-GM2S2WMT.mjs +1 -0
  33. package/dist/chunk-GNIO6SOS.js +1 -0
  34. package/dist/chunk-HAFRR4IT.js +1 -0
  35. package/dist/chunk-ICVBXT6V.mjs +2 -0
  36. package/dist/chunk-JGPOALUP.js +1 -0
  37. package/dist/chunk-JTUSMG6J.js +1 -0
  38. package/dist/chunk-K5DD2LSK.mjs +1 -0
  39. package/dist/chunk-NIBCC7WQ.js +1 -0
  40. package/dist/chunk-PBA4ERQP.js +2 -0
  41. package/dist/chunk-RK5GPBQ5.mjs +1 -0
  42. package/dist/chunk-UMM2BQ4N.mjs +1 -0
  43. package/dist/chunk-UT6DJWGC.js +2 -0
  44. package/dist/chunk-UZLKRJJK.js +2 -0
  45. package/dist/chunk-W3QFF3SQ.mjs +2 -0
  46. package/dist/chunk-XA53EBKC.js +1 -0
  47. package/dist/chunk-XRZKQOQJ.mjs +1 -0
  48. package/dist/chunk-ZFZJRL2R.mjs +1 -0
  49. package/dist/dialogs.d.mts +40 -0
  50. package/dist/dialogs.d.ts +40 -0
  51. package/dist/dialogs.js +1 -0
  52. package/dist/dialogs.mjs +1 -0
  53. package/dist/hooks.d.mts +513 -0
  54. package/dist/hooks.d.ts +513 -0
  55. package/dist/hooks.js +1 -0
  56. package/dist/hooks.mjs +1 -0
  57. package/dist/index.d.mts +567 -0
  58. package/dist/index.d.ts +567 -0
  59. package/dist/index.js +33 -0
  60. package/dist/index.mjs +33 -0
  61. package/dist/plugin-api.d.mts +90 -0
  62. package/dist/plugin-api.d.ts +90 -0
  63. package/dist/plugin-api.js +246 -0
  64. package/dist/plugin-api.mjs +246 -0
  65. package/dist/styles.css +1 -0
  66. package/dist/styles.d.mts +13 -0
  67. package/dist/styles.d.ts +13 -0
  68. package/dist/styles.js +1 -0
  69. package/dist/styles.mjs +1 -0
  70. package/dist/types-DaQbko33.d.mts +106 -0
  71. package/dist/types-DaQbko33.d.ts +106 -0
  72. package/dist/ui.d.mts +1565 -0
  73. package/dist/ui.d.ts +1565 -0
  74. package/dist/ui.js +111 -0
  75. package/dist/ui.mjs +111 -0
  76. package/dist/useFindReplace-C5gZIvkA.d.mts +219 -0
  77. package/dist/useFindReplace-C5gZIvkA.d.ts +219 -0
  78. package/package.json +137 -0
@@ -0,0 +1,40 @@
1
+ /**
2
+ * @zeke-02/docx-editor-react/dialogs
3
+ *
4
+ * Modal dialogs for hyperlinks, find/replace, paste-special, page setup,
5
+ * and keyboard shortcuts. Pair with the hooks under
6
+ * `@zeke-02/docx-editor-react/hooks` when wiring custom UI.
7
+ *
8
+ * @example
9
+ * ```tsx
10
+ * import { HyperlinkDialog, FindReplaceDialog } from '@zeke-02/docx-editor-react/dialogs';
11
+ * ```
12
+ *
13
+ * @packageDocumentation
14
+ * @public
15
+ */
16
+ export { B as BookmarkOption, F as FindReplaceDialog, a as FindReplaceDialogProps, H as HyperlinkData, b as HyperlinkDialog, c as HyperlinkDialogProps, K as KeyboardShortcut, d as KeyboardShortcutsDialog, e as KeyboardShortcutsDialogProps, P as PasteOption, f as PasteSpecialDialog, g as PasteSpecialDialogProps, S as ShortcutCategory, U as UseKeyboardShortcutsDialogOptions, h as UseKeyboardShortcutsDialogReturn, i as UsePasteSpecialOptions, j as UsePasteSpecialReturn, x as createBookmarkLinkData, y as createHyperlinkData, z as emailToMailto, A as extractBookmarksForDialog, k as formatShortcutKeys, l as getAllCategories, m as getAllPasteOptions, n as getCategoryLabel, o as getCommonShortcuts, p as getDefaultPasteOption, q as getDefaultShortcuts, C as getDisplayText, r as getPasteOption, s as getShortcutsByCategory, D as getUrlType, E as isBookmarkHyperlinkData, G as isExternalHyperlinkData, t as isPasteSpecialShortcut, I as isValidUrl, J as normalizeUrl, L as phoneToTel, v as useKeyboardShortcutsDialog, w as usePasteSpecial } from './KeyboardShortcutsDialog-04AoVwn3.js';
17
+ import React__default from 'react';
18
+ import { SectionProperties } from '@zeke-02/docx-editor-core/types/document';
19
+ export { FindMatch, FindOptions, FindResult, HighlightOptions, createDefaultFindOptions, createSearchPattern, escapeRegexString, findAllMatches, getDefaultHighlightOptions, getMatchCountText, isEmptySearch, replaceAllInContent, replaceFirstInContent } from '@zeke-02/docx-editor-core/utils/findReplace';
20
+ import '@zeke-02/docx-editor-core/utils';
21
+ import '@eigenpal/docx-editor-i18n';
22
+
23
+ /**
24
+ * Page Setup Dialog
25
+ *
26
+ * Modal for editing page layout properties:
27
+ * - Page size (Letter, A4, Legal, etc.)
28
+ * - Orientation (portrait/landscape)
29
+ * - Margins (top, bottom, left, right) in inches
30
+ */
31
+
32
+ interface PageSetupDialogProps {
33
+ isOpen: boolean;
34
+ onClose: () => void;
35
+ onApply: (props: Partial<SectionProperties>) => void;
36
+ currentProps?: SectionProperties;
37
+ }
38
+ declare function PageSetupDialog({ isOpen, onClose, onApply, currentProps, }: PageSetupDialogProps): React__default.ReactElement | null;
39
+
40
+ export { PageSetupDialog, type PageSetupDialogProps };
@@ -0,0 +1 @@
1
+ 'use strict';var chunk2DBLZSGF_js=require('./chunk-2DBLZSGF.js'),chunk3QCOIABL_js=require('./chunk-3QCOIABL.js'),chunkJGPOALUP_js=require('./chunk-JGPOALUP.js'),chunk4RTT4L2S_js=require('./chunk-4RTT4L2S.js'),chunkXA53EBKC_js=require('./chunk-XA53EBKC.js'),chunkUT6DJWGC_js=require('./chunk-UT6DJWGC.js');require('./chunk-GNIO6SOS.js'),require('./chunk-BJ5RZW6Y.js');var export_createDefaultFindOptions=chunkXA53EBKC_js.a.createDefaultFindOptions;var export_createSearchPattern=chunkXA53EBKC_js.a.createSearchPattern;var export_escapeRegexString=chunkXA53EBKC_js.a.escapeRegexString;var export_findAllMatches=chunkXA53EBKC_js.a.findAllMatches;var export_getDefaultHighlightOptions=chunkXA53EBKC_js.a.getDefaultHighlightOptions;var export_getMatchCountText=chunkXA53EBKC_js.a.getMatchCountText;var export_isEmptySearch=chunkXA53EBKC_js.a.isEmptySearch;var export_replaceAllInContent=chunkXA53EBKC_js.a.replaceAllInContent;var export_replaceFirstInContent=chunkXA53EBKC_js.a.replaceFirstInContent;Object.defineProperty(exports,"PageSetupDialog",{enumerable:true,get:function(){return chunk2DBLZSGF_js.a}});Object.defineProperty(exports,"KeyboardShortcutsDialog",{enumerable:true,get:function(){return chunk3QCOIABL_js.l}});Object.defineProperty(exports,"PasteSpecialDialog",{enumerable:true,get:function(){return chunk3QCOIABL_js.a}});Object.defineProperty(exports,"getAllCategories",{enumerable:true,get:function(){return chunk3QCOIABL_js.k}});Object.defineProperty(exports,"getAllPasteOptions",{enumerable:true,get:function(){return chunk3QCOIABL_js.d}});Object.defineProperty(exports,"getCategoryLabel",{enumerable:true,get:function(){return chunk3QCOIABL_js.j}});Object.defineProperty(exports,"getCommonShortcuts",{enumerable:true,get:function(){return chunk3QCOIABL_js.i}});Object.defineProperty(exports,"getDefaultPasteOption",{enumerable:true,get:function(){return chunk3QCOIABL_js.e}});Object.defineProperty(exports,"getDefaultShortcuts",{enumerable:true,get:function(){return chunk3QCOIABL_js.g}});Object.defineProperty(exports,"getPasteOption",{enumerable:true,get:function(){return chunk3QCOIABL_js.c}});Object.defineProperty(exports,"getShortcutsByCategory",{enumerable:true,get:function(){return chunk3QCOIABL_js.h}});Object.defineProperty(exports,"isPasteSpecialShortcut",{enumerable:true,get:function(){return chunk3QCOIABL_js.f}});Object.defineProperty(exports,"useKeyboardShortcutsDialog",{enumerable:true,get:function(){return chunk3QCOIABL_js.m}});Object.defineProperty(exports,"usePasteSpecial",{enumerable:true,get:function(){return chunk3QCOIABL_js.b}});Object.defineProperty(exports,"formatShortcutKeys",{enumerable:true,get:function(){return chunkJGPOALUP_js.a}});Object.defineProperty(exports,"FindReplaceDialog",{enumerable:true,get:function(){return chunk4RTT4L2S_js.a}});Object.defineProperty(exports,"HyperlinkDialog",{enumerable:true,get:function(){return chunkUT6DJWGC_js.d}});Object.defineProperty(exports,"createBookmarkLinkData",{enumerable:true,get:function(){return chunkUT6DJWGC_js.f}});Object.defineProperty(exports,"createHyperlinkData",{enumerable:true,get:function(){return chunkUT6DJWGC_js.e}});Object.defineProperty(exports,"emailToMailto",{enumerable:true,get:function(){return chunkUT6DJWGC_js.j}});Object.defineProperty(exports,"extractBookmarksForDialog",{enumerable:true,get:function(){return chunkUT6DJWGC_js.l}});Object.defineProperty(exports,"getDisplayText",{enumerable:true,get:function(){return chunkUT6DJWGC_js.i}});Object.defineProperty(exports,"getUrlType",{enumerable:true,get:function(){return chunkUT6DJWGC_js.c}});Object.defineProperty(exports,"isBookmarkHyperlinkData",{enumerable:true,get:function(){return chunkUT6DJWGC_js.h}});Object.defineProperty(exports,"isExternalHyperlinkData",{enumerable:true,get:function(){return chunkUT6DJWGC_js.g}});Object.defineProperty(exports,"isValidUrl",{enumerable:true,get:function(){return chunkUT6DJWGC_js.a}});Object.defineProperty(exports,"normalizeUrl",{enumerable:true,get:function(){return chunkUT6DJWGC_js.b}});Object.defineProperty(exports,"phoneToTel",{enumerable:true,get:function(){return chunkUT6DJWGC_js.k}});exports.createDefaultFindOptions=export_createDefaultFindOptions;exports.createSearchPattern=export_createSearchPattern;exports.escapeRegexString=export_escapeRegexString;exports.findAllMatches=export_findAllMatches;exports.getDefaultHighlightOptions=export_getDefaultHighlightOptions;exports.getMatchCountText=export_getMatchCountText;exports.isEmptySearch=export_isEmptySearch;exports.replaceAllInContent=export_replaceAllInContent;exports.replaceFirstInContent=export_replaceFirstInContent;
@@ -0,0 +1 @@
1
+ export{a as PageSetupDialog}from'./chunk-RK5GPBQ5.mjs';export{l as KeyboardShortcutsDialog,a as PasteSpecialDialog,k as getAllCategories,d as getAllPasteOptions,j as getCategoryLabel,i as getCommonShortcuts,e as getDefaultPasteOption,g as getDefaultShortcuts,c as getPasteOption,h as getShortcutsByCategory,f as isPasteSpecialShortcut,m as useKeyboardShortcutsDialog,b as usePasteSpecial}from'./chunk-W3QFF3SQ.mjs';export{a as formatShortcutKeys}from'./chunk-K5DD2LSK.mjs';export{a as FindReplaceDialog}from'./chunk-45GFZZ45.mjs';import {a}from'./chunk-7DAI755K.mjs';export{d as HyperlinkDialog,f as createBookmarkLinkData,e as createHyperlinkData,j as emailToMailto,l as extractBookmarksForDialog,i as getDisplayText,c as getUrlType,h as isBookmarkHyperlinkData,g as isExternalHyperlinkData,a as isValidUrl,b as normalizeUrl,k as phoneToTel}from'./chunk-ICVBXT6V.mjs';import'./chunk-ZFZJRL2R.mjs';import'./chunk-BMBP5UFA.mjs';var export_createDefaultFindOptions=a.createDefaultFindOptions;var export_createSearchPattern=a.createSearchPattern;var export_escapeRegexString=a.escapeRegexString;var export_findAllMatches=a.findAllMatches;var export_getDefaultHighlightOptions=a.getDefaultHighlightOptions;var export_getMatchCountText=a.getMatchCountText;var export_isEmptySearch=a.isEmptySearch;var export_replaceAllInContent=a.replaceAllInContent;var export_replaceFirstInContent=a.replaceFirstInContent;export{export_createDefaultFindOptions as createDefaultFindOptions,export_createSearchPattern as createSearchPattern,export_escapeRegexString as escapeRegexString,export_findAllMatches as findAllMatches,export_getDefaultHighlightOptions as getDefaultHighlightOptions,export_getMatchCountText as getMatchCountText,export_isEmptySearch as isEmptySearch,export_replaceAllInContent as replaceAllInContent,export_replaceFirstInContent as replaceFirstInContent};
@@ -0,0 +1,513 @@
1
+ /**
2
+ * @zeke-02/docx-editor-react/hooks
3
+ *
4
+ * React hooks for editor history, table selection, find/replace, autosave,
5
+ * clipboard, and zoom. Use alongside the main `DocxEditor` component.
6
+ *
7
+ * @example
8
+ * ```tsx
9
+ * import { useAutoSave, useFindReplace } from '@zeke-02/docx-editor-react/hooks';
10
+ * ```
11
+ *
12
+ * @packageDocumentation
13
+ * @public
14
+ */
15
+ import { Table, Document } from '@zeke-02/docx-editor-core/types/document';
16
+ import { a as TableContext, c as TableAction, b as TableSplitConfig } from './useFindReplace-C5gZIvkA.mjs';
17
+ export { F as FindReplaceOptions, d as FindReplaceState, U as UseFindReplaceReturn, u as useFindReplace } from './useFindReplace-C5gZIvkA.mjs';
18
+ import * as React$1 from 'react';
19
+ import React__default, { CSSProperties, RefObject } from 'react';
20
+ import { HighlightRect, SelectionHighlightConfig, ParsedClipboardContent } from '@zeke-02/docx-editor-core/utils';
21
+ import { ClipboardSelection, Theme, SavedDocumentData, AutoSaveStatus } from '@zeke-02/docx-editor-core';
22
+ export { AutoSaveStatus, ClipboardSelection, SavedDocumentData, TABLE_DATA_ATTRIBUTES, createSelectionFromDOM, formatLastSaveTime, formatStorageSize, getAutoSaveStatusLabel, getAutoSaveStorageSize, getSelectionRuns, isAutoSaveSupported } from '@zeke-02/docx-editor-core';
23
+ import { EditorView } from 'prosemirror-view';
24
+ import { EditorState } from 'prosemirror-state';
25
+ import { TrackedChangesResult } from '@zeke-02/docx-editor-core/prosemirror/utils/extractTrackedChanges';
26
+ export { TrackedChangesResult, extractTrackedChanges } from '@zeke-02/docx-editor-core/prosemirror/utils/extractTrackedChanges';
27
+ import '@zeke-02/docx-editor-core/utils/findReplace';
28
+
29
+ /**
30
+ * History hook for undo/redo functionality
31
+ *
32
+ * Maintains undo/redo stacks with support for:
33
+ * - undo() and redo() operations
34
+ * - canUndo and canRedo state
35
+ * - Keyboard shortcuts (Ctrl+Z, Ctrl+Y, Ctrl+Shift+Z)
36
+ * - Grouping rapid changes to avoid cluttering history
37
+ */
38
+ /**
39
+ * History entry containing state and metadata
40
+ */
41
+ interface HistoryEntry<T> {
42
+ /** The state at this point */
43
+ state: T;
44
+ /** Timestamp when this entry was created */
45
+ timestamp: number;
46
+ /** Optional description of what changed */
47
+ description?: string;
48
+ }
49
+ /**
50
+ * Options for the useHistory hook
51
+ */
52
+ interface UseHistoryOptions<T> {
53
+ /** Maximum number of entries in history (default: 100) */
54
+ maxEntries?: number;
55
+ /** Time in ms to group rapid changes (default: 500) */
56
+ groupingInterval?: number;
57
+ /** Whether to enable keyboard shortcuts (default: true) */
58
+ enableKeyboardShortcuts?: boolean;
59
+ /** Custom comparison function for detecting changes */
60
+ isEqual?: (a: T, b: T) => boolean;
61
+ /** Callback when undo is triggered */
62
+ onUndo?: (state: T) => void;
63
+ /** Callback when redo is triggered */
64
+ onRedo?: (state: T) => void;
65
+ /** Ref to the container element for keyboard events */
66
+ containerRef?: React.RefObject<HTMLElement>;
67
+ }
68
+ /**
69
+ * Return type of the useHistory hook
70
+ */
71
+ interface UseHistoryReturn<T> {
72
+ /** Current state */
73
+ state: T;
74
+ /** Whether undo is available */
75
+ canUndo: boolean;
76
+ /** Whether redo is available */
77
+ canRedo: boolean;
78
+ /** Number of entries in undo stack */
79
+ undoCount: number;
80
+ /** Number of entries in redo stack */
81
+ redoCount: number;
82
+ /** Push a new state to history */
83
+ push: (newState: T, description?: string) => void;
84
+ /** Undo to previous state */
85
+ undo: () => T | undefined;
86
+ /** Redo to next state */
87
+ redo: () => T | undefined;
88
+ /** Clear all history */
89
+ clear: () => void;
90
+ /** Reset to initial state and clear history */
91
+ reset: (newInitialState?: T) => void;
92
+ /** Get all undo entries (for debugging/display) */
93
+ getUndoStack: () => HistoryEntry<T>[];
94
+ /** Get all redo entries (for debugging/display) */
95
+ getRedoStack: () => HistoryEntry<T>[];
96
+ /** Transform all stored states (current + undo/redo stacks) */
97
+ transformAll: (fn: (state: T) => T) => void;
98
+ }
99
+ /**
100
+ * Custom hook for managing undo/redo history
101
+ */
102
+ declare function useHistory<T>(initialState: T, options?: UseHistoryOptions<T>): UseHistoryReturn<T>;
103
+ /**
104
+ * Simplified hook that just tracks state changes automatically
105
+ */
106
+ declare function useAutoHistory<T>(value: T, options?: UseHistoryOptions<T>): Omit<UseHistoryReturn<T>, 'push'>;
107
+ /**
108
+ * Hook for document history with specialized comparison
109
+ */
110
+ declare function useDocumentHistory<T extends {
111
+ package?: {
112
+ document?: unknown;
113
+ headers?: unknown;
114
+ footers?: unknown;
115
+ } | null;
116
+ } | null>(document: T, options?: Omit<UseHistoryOptions<T>, 'isEqual'>): UseHistoryReturn<T>;
117
+ /**
118
+ * Create a history manager for non-React usage
119
+ */
120
+ declare class HistoryManager<T> {
121
+ private undoStack;
122
+ private redoStack;
123
+ private currentState;
124
+ private maxEntries;
125
+ private groupingInterval;
126
+ private lastPushTime;
127
+ private isEqual;
128
+ constructor(initialState: T, options?: {
129
+ maxEntries?: number;
130
+ groupingInterval?: number;
131
+ isEqual?: (a: T, b: T) => boolean;
132
+ });
133
+ get state(): T;
134
+ get canUndo(): boolean;
135
+ get canRedo(): boolean;
136
+ push(newState: T, description?: string): void;
137
+ undo(): T | undefined;
138
+ redo(): T | undefined;
139
+ clear(): void;
140
+ reset(newInitialState?: T): void;
141
+ }
142
+
143
+ /**
144
+ * useTableSelection Hook
145
+ *
146
+ * Thin React wrapper around the framework-agnostic TableSelectionManager.
147
+ * Provides table selection tracking and table operation dispatch.
148
+ */
149
+
150
+ interface TableSelectionState {
151
+ context: TableContext | null;
152
+ table: Table | null;
153
+ tableIndex: number | null;
154
+ rowIndex: number | null;
155
+ columnIndex: number | null;
156
+ }
157
+ interface UseTableSelectionReturn {
158
+ state: TableSelectionState;
159
+ handleCellClick: (tableIndex: number, rowIndex: number, columnIndex: number) => void;
160
+ handleAction: (action: TableAction) => void;
161
+ getSplitCellConfig: () => TableSplitConfig | null;
162
+ applySplitCell: (rows: number, cols: number) => void;
163
+ clearSelection: () => void;
164
+ isCellSelected: (tableIndex: number, rowIndex: number, columnIndex: number) => boolean;
165
+ tableContext: TableContext | null;
166
+ }
167
+ interface UseTableSelectionOptions {
168
+ document: Document | null;
169
+ onChange?: (document: Document) => void;
170
+ onSelectionChange?: (context: TableContext | null) => void;
171
+ }
172
+ declare function useTableSelection({ document: doc, onChange, onSelectionChange, }: UseTableSelectionOptions): UseTableSelectionReturn;
173
+
174
+ /**
175
+ * Selection Highlight Hook
176
+ *
177
+ * A React hook that manages visual selection highlighting across multiple runs.
178
+ * Uses a combination of CSS ::selection pseudo-element styling and optional
179
+ * overlay rectangles for complex scenarios.
180
+ *
181
+ * Features:
182
+ * - Consistent selection highlighting across all text runs
183
+ * - Support for text with different backgrounds (highlighted, dark bg)
184
+ * - Optional overlay rectangles for custom highlight effects
185
+ * - Debounced updates for performance
186
+ */
187
+
188
+ /**
189
+ * Options for the useSelectionHighlight hook
190
+ */
191
+ interface UseSelectionHighlightOptions {
192
+ /** Reference to the container element */
193
+ containerRef: React__default.RefObject<HTMLElement>;
194
+ /** Whether to enable selection highlighting */
195
+ enabled?: boolean;
196
+ /** Custom highlight configuration */
197
+ config?: SelectionHighlightConfig;
198
+ /** Whether to use overlay rectangles (default: false, uses CSS) */
199
+ useOverlay?: boolean;
200
+ /** Debounce delay for rect updates in ms (default: 16) */
201
+ debounceMs?: number;
202
+ /** Callback when selection changes */
203
+ onSelectionChange?: (hasSelection: boolean, text: string) => void;
204
+ }
205
+ /**
206
+ * Return value from the useSelectionHighlight hook
207
+ */
208
+ interface UseSelectionHighlightReturn {
209
+ /** Whether there is an active selection */
210
+ hasSelection: boolean;
211
+ /** The selected text */
212
+ selectedText: string;
213
+ /** Highlight rectangles (only populated if useOverlay is true) */
214
+ highlightRects: HighlightRect[];
215
+ /** Whether selection is within the container */
216
+ isSelectionInContainer: boolean;
217
+ /** Refresh the highlight state */
218
+ refresh: () => void;
219
+ /** Get styles for a highlight rect overlay */
220
+ getOverlayStyle: (rect: HighlightRect) => CSSProperties;
221
+ }
222
+ /**
223
+ * Hook to manage selection highlighting in the editor
224
+ */
225
+ declare function useSelectionHighlight(options: UseSelectionHighlightOptions): UseSelectionHighlightReturn;
226
+ /**
227
+ * Props for selection overlay component
228
+ */
229
+ interface SelectionOverlayProps {
230
+ /** Highlight rectangles to render */
231
+ rects: HighlightRect[];
232
+ /** Style configuration */
233
+ config?: SelectionHighlightConfig;
234
+ /** Additional class name */
235
+ className?: string;
236
+ }
237
+ /**
238
+ * Generate selection overlay elements (for use in JSX)
239
+ *
240
+ * Usage:
241
+ * ```tsx
242
+ * const { highlightRects } = useSelectionHighlight({ ... });
243
+ * return (
244
+ * <div style={{ position: 'relative' }}>
245
+ * {generateOverlayElements(highlightRects)}
246
+ * <div>... content ...</div>
247
+ * </div>
248
+ * );
249
+ * ```
250
+ */
251
+ declare function generateOverlayElements(rects: HighlightRect[], config?: SelectionHighlightConfig): React__default.ReactNode[];
252
+
253
+ /**
254
+ * useClipboard Hook
255
+ *
256
+ * Thin React wrapper around the framework-agnostic ClipboardManager.
257
+ * Handles clipboard operations with formatting preservation.
258
+ */
259
+
260
+ interface UseClipboardOptions {
261
+ onCopy?: (selection: ClipboardSelection) => void;
262
+ onCut?: (selection: ClipboardSelection) => void;
263
+ onPaste?: (content: ParsedClipboardContent, asPlainText: boolean) => void;
264
+ cleanWordFormatting?: boolean;
265
+ editable?: boolean;
266
+ onError?: (error: Error) => void;
267
+ /** Document theme — used to resolve themed colors in the HTML clipboard payload. */
268
+ theme?: Theme | null;
269
+ }
270
+ interface UseClipboardReturn {
271
+ copy: (selection: ClipboardSelection) => Promise<boolean>;
272
+ cut: (selection: ClipboardSelection) => Promise<boolean>;
273
+ paste: (asPlainText?: boolean) => Promise<ParsedClipboardContent | null>;
274
+ handleCopy: (event: ClipboardEvent) => void;
275
+ handleCut: (event: ClipboardEvent) => void;
276
+ handlePaste: (event: ClipboardEvent) => void;
277
+ handleKeyDown: (event: KeyboardEvent) => void;
278
+ isProcessing: boolean;
279
+ lastPastedContent: ParsedClipboardContent | null;
280
+ }
281
+ declare function useClipboard(options?: UseClipboardOptions): UseClipboardReturn;
282
+
283
+ /**
284
+ * useAutoSave Hook
285
+ *
286
+ * Thin React wrapper around the framework-agnostic AutoSaveManager.
287
+ * Bridges AutoSaveManager's subscribe/getSnapshot pattern with React state.
288
+ */
289
+
290
+ /** Options for useAutoSave hook */
291
+ interface UseAutoSaveOptions {
292
+ /** Storage key for localStorage (default: 'docx-editor-autosave') */
293
+ storageKey?: string;
294
+ /** Save interval in milliseconds (default: 30000 - 30 seconds) */
295
+ interval?: number;
296
+ /** Whether auto-save is enabled (default: true) */
297
+ enabled?: boolean;
298
+ /** Maximum age of auto-save in milliseconds before it's considered stale (default: 24 hours) */
299
+ maxAge?: number;
300
+ /** Callback when save succeeds */
301
+ onSave?: (timestamp: Date) => void;
302
+ /** Callback when save fails */
303
+ onError?: (error: Error) => void;
304
+ /** Callback when recovery data is found */
305
+ onRecoveryAvailable?: (savedDocument: SavedDocumentData) => void;
306
+ /** Whether to save immediately when document changes (debounced) */
307
+ saveOnChange?: boolean;
308
+ /** Debounce delay for saveOnChange in milliseconds (default: 2000) */
309
+ debounceDelay?: number;
310
+ }
311
+ /** Return value of useAutoSave hook */
312
+ interface UseAutoSaveReturn {
313
+ status: AutoSaveStatus;
314
+ lastSaveTime: Date | null;
315
+ save: () => Promise<boolean>;
316
+ clearAutoSave: () => void;
317
+ hasRecoveryData: boolean;
318
+ getRecoveryData: () => SavedDocumentData | null;
319
+ acceptRecovery: () => Document | null;
320
+ dismissRecovery: () => void;
321
+ isEnabled: boolean;
322
+ enable: () => void;
323
+ disable: () => void;
324
+ }
325
+ declare function useAutoSave(document: Document | null | undefined, options?: UseAutoSaveOptions): UseAutoSaveReturn;
326
+
327
+ /**
328
+ * Drag Auto-Scroll Hook
329
+ *
330
+ * When the user is drag-selecting text and moves the mouse near the
331
+ * top or bottom edge of the scroll container, this hook auto-scrolls
332
+ * the container and continues extending the selection.
333
+ */
334
+ interface DragAutoScrollOptions {
335
+ /** Ref to the pages container (used to find the scroll parent). */
336
+ pagesContainerRef: React.RefObject<HTMLDivElement | null>;
337
+ /** Called during auto-scroll to extend the selection at the current mouse position. */
338
+ onScrollExtendSelection: (clientX: number, clientY: number) => void;
339
+ }
340
+ declare function useDragAutoScroll({ pagesContainerRef, onScrollExtendSelection, }: DragAutoScrollOptions): {
341
+ updateMousePosition: (clientX: number, clientY: number) => void;
342
+ stopAutoScroll: () => void;
343
+ };
344
+
345
+ /**
346
+ * Hook for toolbar dropdowns that need position:fixed to escape overflow:auto/hidden ancestors.
347
+ *
348
+ * Returns refs and styles for a dropdown that positions itself below its trigger
349
+ * using fixed coordinates (like MenuDropdown), so it isn't clipped by the toolbar's
350
+ * overflow-x-auto container.
351
+ */
352
+
353
+ interface UseFixedDropdownOptions {
354
+ isOpen: boolean;
355
+ onClose: () => void;
356
+ /** 'left' aligns dropdown left edge to trigger, 'right' aligns right edge */
357
+ align?: 'left' | 'right';
358
+ }
359
+ interface UseFixedDropdownReturn {
360
+ containerRef: RefObject<HTMLDivElement | null>;
361
+ dropdownRef: RefObject<HTMLDivElement | null>;
362
+ dropdownStyle: CSSProperties;
363
+ handleMouseDown: (e: React.MouseEvent) => void;
364
+ }
365
+ declare function useFixedDropdown({ isOpen, onClose, align, }: UseFixedDropdownOptions): UseFixedDropdownReturn;
366
+
367
+ /**
368
+ * Width/height inputs with an optional aspect-ratio lock. `width`/`height`
369
+ * are `number | ''` so a cleared field shows empty instead of 0.
370
+ */
371
+ interface UseAspectLockedSizeReturn {
372
+ width: number | '';
373
+ height: number | '';
374
+ lockAspect: boolean;
375
+ setLockAspect: (locked: boolean) => void;
376
+ /** Number-input onChange handlers. Empty string clears, otherwise clamps to >= 1. */
377
+ handleWidthChange: (raw: string) => void;
378
+ handleHeightChange: (raw: string) => void;
379
+ /** Seed both fields and re-lock. Null/undefined values clear the input. */
380
+ seed: (w: number | null | undefined, h: number | null | undefined) => void;
381
+ }
382
+ declare function useAspectLockedSize(): UseAspectLockedSizeReturn;
383
+
384
+ interface VisualLineNavigationOptions {
385
+ pagesContainerRef: React.RefObject<HTMLDivElement | null>;
386
+ }
387
+ declare function useVisualLineNavigation({ pagesContainerRef }: VisualLineNavigationOptions): {
388
+ stickyXRef: React$1.RefObject<number | null>;
389
+ lastVisualLineIndexRef: React$1.RefObject<number>;
390
+ getCaretClientX: (pmPos: number) => number | null;
391
+ findLineElementAtPosition: (pmPos: number) => HTMLElement | null;
392
+ findPositionOnLineAtClientX: (lineEl: HTMLElement, clientX: number) => number | null;
393
+ handlePMKeyDown: (view: EditorView, event: KeyboardEvent) => boolean;
394
+ };
395
+
396
+ /**
397
+ * useWheelZoom Hook
398
+ *
399
+ * Enables Ctrl+scroll (or Cmd+scroll on Mac) to zoom in/out.
400
+ * Features:
401
+ * - Configurable zoom range and step
402
+ * - Smooth zoom transitions
403
+ * - Pinch-to-zoom support on trackpads
404
+ * - Zoom reset (Ctrl+0)
405
+ * - Zoom in/out shortcuts (Ctrl++, Ctrl+-)
406
+ */
407
+ /**
408
+ * Options for useWheelZoom hook
409
+ */
410
+ interface UseWheelZoomOptions {
411
+ /** Initial zoom level (default: 1.0) */
412
+ initialZoom?: number;
413
+ /** Minimum zoom level (default: 0.25) */
414
+ minZoom?: number;
415
+ /** Maximum zoom level (default: 4.0) */
416
+ maxZoom?: number;
417
+ /** Zoom step for each scroll event (default: 0.1) */
418
+ zoomStep?: number;
419
+ /** Whether zoom is enabled (default: true) */
420
+ enabled?: boolean;
421
+ /** Container element ref to attach wheel listener */
422
+ containerRef?: React.RefObject<HTMLElement>;
423
+ /** Callback when zoom changes */
424
+ onZoomChange?: (zoom: number) => void;
425
+ /** Whether to enable keyboard shortcuts (Ctrl++, Ctrl+-, Ctrl+0) */
426
+ enableKeyboardShortcuts?: boolean;
427
+ /** Whether to prevent default browser zoom behavior */
428
+ preventDefault?: boolean;
429
+ }
430
+ /**
431
+ * Return value of useWheelZoom hook
432
+ */
433
+ interface UseWheelZoomReturn {
434
+ /** Current zoom level */
435
+ zoom: number;
436
+ /** Set zoom level directly */
437
+ setZoom: (zoom: number) => void;
438
+ /** Zoom in by step */
439
+ zoomIn: () => void;
440
+ /** Zoom out by step */
441
+ zoomOut: () => void;
442
+ /** Reset zoom to initial level */
443
+ resetZoom: () => void;
444
+ /** Reset zoom to 100% */
445
+ zoomTo100: () => void;
446
+ /** Zoom to fit width */
447
+ zoomToFit: (containerWidth: number, contentWidth: number) => void;
448
+ /** Whether currently at minimum zoom */
449
+ isMinZoom: boolean;
450
+ /** Whether currently at maximum zoom */
451
+ isMaxZoom: boolean;
452
+ /** Zoom percentage (e.g., 100 for zoom level 1.0) */
453
+ zoomPercent: number;
454
+ /** Wheel event handler (for manual attachment) */
455
+ handleWheel: (event: WheelEvent) => void;
456
+ /** Keyboard event handler (for manual attachment) */
457
+ handleKeyDown: (event: KeyboardEvent) => void;
458
+ }
459
+ /**
460
+ * Preset zoom levels for snapping
461
+ */
462
+ declare const ZOOM_PRESETS: number[];
463
+ /**
464
+ * React hook for Ctrl+scroll zoom functionality
465
+ */
466
+ declare function useWheelZoom(options?: UseWheelZoomOptions): UseWheelZoomReturn;
467
+ /**
468
+ * Get zoom presets
469
+ */
470
+ declare function getZoomPresets(): number[];
471
+ /**
472
+ * Find nearest zoom preset
473
+ */
474
+ declare function findNearestZoomPreset(zoom: number): number;
475
+ /**
476
+ * Get next zoom preset (for zoom in)
477
+ */
478
+ declare function getNextZoomPreset(zoom: number): number;
479
+ /**
480
+ * Get previous zoom preset (for zoom out)
481
+ */
482
+ declare function getPreviousZoomPreset(zoom: number): number;
483
+ /**
484
+ * Format zoom level for display
485
+ */
486
+ declare function formatZoom(zoom: number): string;
487
+ /**
488
+ * Parse zoom from percentage string
489
+ */
490
+ declare function parseZoom(zoomString: string): number | null;
491
+ /**
492
+ * Check if zoom level is at a preset
493
+ */
494
+ declare function isZoomPreset(zoom: number): boolean;
495
+ /**
496
+ * Clamp zoom to valid range
497
+ */
498
+ declare function clampZoom(zoom: number, minZoom?: number, maxZoom?: number): number;
499
+
500
+ /**
501
+ * Returns tracked changes (and the comment→revision overlap map for threading)
502
+ * derived from the latest PM state. Memoized on state identity, so derivation
503
+ * only re-runs when PM state changes (which happens on every doc-changing
504
+ * transaction, including remote ones via ySyncPlugin).
505
+ *
506
+ * No debounce: a single O(N) doc walk, cheap enough to run per transaction.
507
+ * If you see jank on huge documents, wrap the setter that drives the state
508
+ * argument in `requestAnimationFrame` rather than reintroducing a delay here —
509
+ * a delay makes the sidebar feel laggy.
510
+ */
511
+ declare function useTrackedChanges(state: EditorState | null): TrackedChangesResult;
512
+
513
+ export { type DragAutoScrollOptions, type HistoryEntry, HistoryManager, type SelectionOverlayProps, type TableSelectionState, type UseAspectLockedSizeReturn, type UseAutoSaveOptions, type UseAutoSaveReturn, type UseClipboardOptions, type UseClipboardReturn, type UseFixedDropdownOptions, type UseFixedDropdownReturn, type UseHistoryOptions, type UseHistoryReturn, type UseSelectionHighlightOptions, type UseSelectionHighlightReturn, type UseTableSelectionOptions, type UseTableSelectionReturn, type UseWheelZoomOptions, type UseWheelZoomReturn, type VisualLineNavigationOptions, ZOOM_PRESETS, clampZoom, findNearestZoomPreset, formatZoom, generateOverlayElements, getNextZoomPreset, getPreviousZoomPreset, getZoomPresets, isZoomPreset, parseZoom, useAspectLockedSize, useAutoHistory, useAutoSave, useClipboard, useDocumentHistory, useDragAutoScroll, useFixedDropdown, useHistory, useSelectionHighlight, useTableSelection, useTrackedChanges, useVisualLineNavigation, useWheelZoom };