@zeke-02/docx-editor 0.5.1 → 0.5.3

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 (211) hide show
  1. package/LICENSE +204 -0
  2. package/dist/FindReplaceDialog-7SQOVQWH.js +1 -0
  3. package/dist/FindReplaceDialog-RK3A7MSK.mjs +1 -0
  4. package/dist/{FootnotePropertiesDialog-XQ7NIFIU.js → FootnotePropertiesDialog-2Q2SHVMR.js} +1 -1
  5. package/dist/{FootnotePropertiesDialog-TNVJJCY6.mjs → FootnotePropertiesDialog-ZKQXW3YO.mjs} +1 -1
  6. package/dist/{HyperlinkDialog-FR4IZZ7E.mjs → HyperlinkDialog-QV3CVFQU.mjs} +1 -1
  7. package/dist/HyperlinkDialog-XVAF7FVN.js +1 -0
  8. package/dist/{ImagePositionDialog-JSZSIKF5.mjs → ImagePositionDialog-EGRH3HPP.mjs} +1 -1
  9. package/dist/{ImagePositionDialog-2YXRAGZS.js → ImagePositionDialog-HIVHUTBT.js} +1 -1
  10. package/dist/ImagePropertiesDialog-67WLFIIZ.mjs +1 -0
  11. package/dist/ImagePropertiesDialog-HSM3JJ22.js +1 -0
  12. package/dist/KeyboardShortcutsDialog-5D_FoAp6.d.ts +395 -0
  13. package/dist/KeyboardShortcutsDialog-D7ihAj18.d.mts +395 -0
  14. package/dist/PageSetupDialog-642IAVG2.js +1 -0
  15. package/dist/PageSetupDialog-ERUQDHAY.mjs +1 -0
  16. package/dist/{SplitCellDialog-NP3JJYHD.mjs → SplitCellDialog-GFWCFCTD.mjs} +1 -1
  17. package/dist/{SplitCellDialog-JIAC3RYV.js → SplitCellDialog-M7WF7ANE.js} +1 -1
  18. package/dist/{TablePropertiesDialog-TIK4AA5M.mjs → TablePropertiesDialog-TZ7VCL6V.mjs} +1 -1
  19. package/dist/{TablePropertiesDialog-T7D4HSVP.js → TablePropertiesDialog-ZKU2FTUX.js} +1 -1
  20. package/dist/agentApi-C41hiW-n.d.mts +486 -0
  21. package/dist/agentApi-D4AZmNfB.d.ts +486 -0
  22. package/dist/chunk-2XXILKEQ.js +1 -0
  23. package/dist/chunk-35DG3R42.js +2 -0
  24. package/dist/chunk-47VJOBJD.mjs +60 -0
  25. package/dist/chunk-5UX5CD4C.js +1 -0
  26. package/dist/chunk-7QQSDIWK.mjs +2 -0
  27. package/dist/chunk-AW5TISUL.js +3 -0
  28. package/dist/chunk-AYMGSTNG.js +1 -0
  29. package/dist/chunk-B45ECEGY.js +18 -0
  30. package/dist/chunk-B7CCL7SL.mjs +2 -0
  31. package/dist/chunk-BRMTZRLJ.js +2 -0
  32. package/dist/chunk-D47GTKGU.js +2 -0
  33. package/dist/chunk-E6MQXELR.js +1 -0
  34. package/dist/chunk-F5SERL7X.mjs +2 -0
  35. package/dist/chunk-FWPVBFKQ.mjs +1 -0
  36. package/dist/chunk-GGQK26JO.js +2 -0
  37. package/dist/chunk-GM2S2WMT.mjs +1 -0
  38. package/dist/chunk-ILYKDR3C.js +1 -0
  39. package/dist/chunk-IP5NAYHL.js +60 -0
  40. package/dist/chunk-JPF5R2ZM.mjs +1 -0
  41. package/dist/chunk-KOXCF3CL.mjs +1 -0
  42. package/dist/chunk-KRLNX56Y.mjs +2 -0
  43. package/dist/chunk-LUJ6HCMH.mjs +1 -0
  44. package/dist/chunk-MKNSJOCN.js +70 -0
  45. package/dist/chunk-NIBCC7WQ.js +1 -0
  46. package/dist/chunk-NLFXR2VH.js +2 -0
  47. package/dist/chunk-ONIYA2FU.mjs +2 -0
  48. package/dist/chunk-ONNHQWAX.mjs +1 -0
  49. package/dist/chunk-RCIZ7OM3.mjs +70 -0
  50. package/dist/{chunk-EHFEG3TX.js → chunk-SNZ57XBI.js} +1 -1
  51. package/dist/chunk-SOTWG3KJ.mjs +1 -0
  52. package/dist/chunk-TYPGB4KF.js +1 -0
  53. package/dist/chunk-U7ZW2DOO.mjs +2 -0
  54. package/dist/{chunk-PKEOQIQO.mjs → chunk-WPI3YRFO.mjs} +1 -1
  55. package/dist/chunk-XQZTWWRF.mjs +18 -0
  56. package/dist/chunk-ZVAFVHWR.mjs +3 -0
  57. package/dist/chunk-ZXPCJWVY.js +2 -0
  58. package/dist/{agentApi-DLt94vXk.d.mts → content-B2MzIMwA.d.mts} +8 -755
  59. package/dist/{agentApi-DLt94vXk.d.ts → content-B2MzIMwA.d.ts} +8 -755
  60. package/dist/dialogs.d.mts +25 -0
  61. package/dist/dialogs.d.ts +25 -0
  62. package/dist/dialogs.js +1 -0
  63. package/dist/dialogs.mjs +1 -0
  64. package/dist/document-DZ_ZeZEH.d.ts +294 -0
  65. package/dist/document-Di1qGqLS.d.mts +294 -0
  66. package/dist/executor-EPEB53SJ.js +1 -0
  67. package/dist/executor-TVJ6K6MW.mjs +1 -0
  68. package/dist/findReplace-CpIoILbP.d.mts +138 -0
  69. package/dist/findReplace-pkMskVJU.d.ts +138 -0
  70. package/dist/hooks.d.mts +598 -0
  71. package/dist/hooks.d.ts +598 -0
  72. package/dist/hooks.js +1 -0
  73. package/dist/hooks.mjs +1 -0
  74. package/dist/index.d.mts +1013 -483
  75. package/dist/index.d.ts +1013 -483
  76. package/dist/index.js +40 -120
  77. package/dist/index.mjs +40 -120
  78. package/dist/layout-bridge-5GYGYKM5.mjs +1 -0
  79. package/dist/layout-bridge-QQDA7ELH.js +1 -0
  80. package/dist/plugin-api.d.mts +176 -0
  81. package/dist/plugin-api.d.ts +176 -0
  82. package/dist/plugin-api.js +260 -0
  83. package/dist/plugin-api.mjs +260 -0
  84. package/dist/processTemplate-BTBTR7AM.js +1 -0
  85. package/dist/{processTemplate-W2C5PXZB.mjs → processTemplate-MBX2KDLE.mjs} +1 -1
  86. package/dist/styles.css +1 -1
  87. package/dist/styles.d.mts +18 -0
  88. package/dist/styles.d.ts +18 -0
  89. package/dist/styles.js +1 -0
  90. package/dist/styles.mjs +1 -0
  91. package/dist/types-Bd_YzkhG.d.mts +281 -0
  92. package/dist/types-Bd_YzkhG.d.ts +281 -0
  93. package/dist/types-CkfDgB0O.d.mts +39 -0
  94. package/dist/types-DZUhB7Ao.d.mts +18 -0
  95. package/dist/types-DZUhB7Ao.d.ts +18 -0
  96. package/dist/types-DcxHFUSc.d.ts +39 -0
  97. package/dist/ui.d.mts +111 -552
  98. package/dist/ui.d.ts +111 -552
  99. package/dist/ui.js +111 -1
  100. package/dist/ui.mjs +111 -1
  101. package/dist/useFindReplace-DDs533b-.d.mts +261 -0
  102. package/dist/useFindReplace-eyhMSZZf.d.ts +261 -0
  103. package/package.json +41 -43
  104. package/dist/ClipboardManager-CVKX0v9q.d.ts +0 -464
  105. package/dist/ClipboardManager-V3aaMnWE.d.mts +0 -464
  106. package/dist/DocumentAgent-BWflKHpH.d.mts +0 -442
  107. package/dist/DocumentAgent-DsdXtetF.d.ts +0 -442
  108. package/dist/FindReplaceDialog-L3YF5HIS.mjs +0 -1
  109. package/dist/FindReplaceDialog-SEBWC5P7.js +0 -1
  110. package/dist/HyperlinkDialog-WEK6JSAC.js +0 -1
  111. package/dist/ImagePropertiesDialog-527MFLQO.mjs +0 -1
  112. package/dist/ImagePropertiesDialog-HG4K3IE7.js +0 -1
  113. package/dist/PageSetupDialog-GALVJMUB.js +0 -1
  114. package/dist/PageSetupDialog-TGQIAMI7.mjs +0 -1
  115. package/dist/TableToolbar-DUgmob2I.d.ts +0 -1273
  116. package/dist/TableToolbar-YL74HNS1.d.mts +0 -1273
  117. package/dist/chunk-23SXXIZS.js +0 -111
  118. package/dist/chunk-3F52AP2Q.js +0 -1
  119. package/dist/chunk-42O5GXM5.mjs +0 -82
  120. package/dist/chunk-54ULJEHM.mjs +0 -1
  121. package/dist/chunk-5XK326FI.mjs +0 -1
  122. package/dist/chunk-6WPRCJ5A.mjs +0 -1
  123. package/dist/chunk-76IYR7C7.mjs +0 -1
  124. package/dist/chunk-7BG7QY7I.js +0 -182
  125. package/dist/chunk-AGRIVA4G.js +0 -1
  126. package/dist/chunk-BTCQ2QI3.mjs +0 -3
  127. package/dist/chunk-BUEMG4NW.js +0 -1
  128. package/dist/chunk-BXRC4U3X.mjs +0 -2
  129. package/dist/chunk-CPAYKE6X.mjs +0 -1
  130. package/dist/chunk-DACWLFKI.mjs +0 -1
  131. package/dist/chunk-EPBFWE36.js +0 -2
  132. package/dist/chunk-FXES3YDB.js +0 -82
  133. package/dist/chunk-HI66BSGS.mjs +0 -9
  134. package/dist/chunk-INTPVEO6.mjs +0 -9
  135. package/dist/chunk-IOAGVW6Q.mjs +0 -2
  136. package/dist/chunk-JCEWC5QL.mjs +0 -4
  137. package/dist/chunk-JTIUFACT.js +0 -1
  138. package/dist/chunk-KUTCCI4X.mjs +0 -182
  139. package/dist/chunk-LUF7PWIC.js +0 -10
  140. package/dist/chunk-MGEN6GOE.mjs +0 -2
  141. package/dist/chunk-MOE2ZGUE.js +0 -18
  142. package/dist/chunk-MWLHJWB6.js +0 -9
  143. package/dist/chunk-OFYVDN3U.mjs +0 -2
  144. package/dist/chunk-P4VSHBGZ.js +0 -2
  145. package/dist/chunk-P5FQHIES.mjs +0 -1
  146. package/dist/chunk-PBC7XAYZ.js +0 -3
  147. package/dist/chunk-PEMB6SZT.js +0 -2
  148. package/dist/chunk-PQMSZTBB.js +0 -9
  149. package/dist/chunk-Q7UDQXAF.js +0 -1
  150. package/dist/chunk-QGTAIC5E.js +0 -1
  151. package/dist/chunk-QVPR2W5S.js +0 -1
  152. package/dist/chunk-R3QMYPL5.mjs +0 -59
  153. package/dist/chunk-RBUTXXQJ.mjs +0 -18
  154. package/dist/chunk-RRWYZ2TS.mjs +0 -111
  155. package/dist/chunk-SFUM35DH.js +0 -2
  156. package/dist/chunk-SNLC6EK2.js +0 -1
  157. package/dist/chunk-TMTLIGLZ.js +0 -59
  158. package/dist/chunk-TSE2PWFX.mjs +0 -10
  159. package/dist/chunk-UWYD42WV.js +0 -4
  160. package/dist/chunk-UXVACQCY.mjs +0 -1
  161. package/dist/chunk-W4EIKDM6.mjs +0 -2
  162. package/dist/chunk-W53SI3XW.mjs +0 -1
  163. package/dist/chunk-WNS2RBQD.js +0 -2
  164. package/dist/chunk-Z3KMSHUP.js +0 -1
  165. package/dist/core-plugins-reexport.d.mts +0 -31
  166. package/dist/core-plugins-reexport.d.ts +0 -31
  167. package/dist/core-plugins-reexport.js +0 -1
  168. package/dist/core-plugins-reexport.mjs +0 -1
  169. package/dist/core-reexport.d.mts +0 -340
  170. package/dist/core-reexport.d.ts +0 -340
  171. package/dist/core-reexport.js +0 -1
  172. package/dist/core-reexport.mjs +0 -1
  173. package/dist/documentSerializer-DtS_-oGA.d.mts +0 -664
  174. package/dist/documentSerializer-Wj1p2ASa.d.ts +0 -664
  175. package/dist/executor-C3VXF7QA.mjs +0 -1
  176. package/dist/executor-GDBV3AGV.js +0 -1
  177. package/dist/headless-reexport.d.mts +0 -197
  178. package/dist/headless-reexport.d.ts +0 -197
  179. package/dist/headless-reexport.js +0 -1
  180. package/dist/headless-reexport.mjs +0 -1
  181. package/dist/insertOperations-BTH1Asas.d.mts +0 -176
  182. package/dist/insertOperations-CbUnXAXH.d.ts +0 -176
  183. package/dist/layout-bridge-EA4DJ227.js +0 -1
  184. package/dist/layout-bridge-XDPSO6GO.mjs +0 -1
  185. package/dist/mcp-reexport.d.mts +0 -156
  186. package/dist/mcp-reexport.d.ts +0 -156
  187. package/dist/mcp-reexport.js +0 -16
  188. package/dist/mcp-reexport.mjs +0 -16
  189. package/dist/processTemplate-MJ2PCSO5.js +0 -1
  190. package/dist/react-B0W16SV6.d.ts +0 -1330
  191. package/dist/react-D0Pn1nww.d.mts +0 -1330
  192. package/dist/react.css +0 -1
  193. package/dist/react.d.mts +0 -10
  194. package/dist/react.d.ts +0 -10
  195. package/dist/react.js +0 -1
  196. package/dist/react.mjs +0 -1
  197. package/dist/registry-CH9V-IX0.d.ts +0 -165
  198. package/dist/registry-CWBKYlNW.d.mts +0 -165
  199. package/dist/types-UDsUq8D3.d.mts +0 -310
  200. package/dist/types-jbivc9Lj.d.ts +0 -310
  201. package/dist/variableDetector-CdQ7ZTzA.d.mts +0 -204
  202. package/dist/variableDetector-DsRV3A9z.d.ts +0 -204
  203. package/i18n/de.json +0 -792
  204. package/i18n/en.json +0 -792
  205. package/i18n/he.json +0 -792
  206. package/i18n/pl.json +0 -792
  207. package/i18n/pt-BR.json +0 -792
  208. package/i18n/tr.json +0 -792
  209. package/i18n/zh-CN.json +0 -792
  210. /package/dist/{chunk-YC5KZSYD.js → chunk-ESZ6JRTW.js} +0 -0
  211. /package/dist/{chunk-LVGJKS7Y.mjs → chunk-TZMMD6RR.mjs} +0 -0
@@ -0,0 +1,598 @@
1
+ import { D as Document, T as Theme } from './document-Di1qGqLS.mjs';
2
+ import { b as TableContext, T as TableAction, d as TableSplitConfig } from './useFindReplace-DDs533b-.mjs';
3
+ export { F as FindReplaceOptions, a as FindReplaceState, U as UseFindReplaceReturn, u as useFindReplace } from './useFindReplace-DDs533b-.mjs';
4
+ import { R as Run, d as Table } from './content-B2MzIMwA.mjs';
5
+ import * as React$1 from 'react';
6
+ import React__default, { CSSProperties as CSSProperties$1, RefObject } from 'react';
7
+ import { P as ParsedClipboardContent } from './findReplace-CpIoILbP.mjs';
8
+ import { A as AutoSaveStatus, S as SavedDocumentData } from './types-CkfDgB0O.mjs';
9
+ import { EditorView } from 'prosemirror-view';
10
+
11
+ /**
12
+ * Selection Highlight Utilities
13
+ *
14
+ * Provides visual highlighting for text selection across multiple runs.
15
+ * Browsers handle ::selection pseudo-element differently, especially when
16
+ * selection spans multiple elements with different backgrounds or styling.
17
+ *
18
+ * This module provides:
19
+ * - Custom selection highlight rendering
20
+ * - Programmatic selection range marking
21
+ * - Visual feedback for selection across runs
22
+ */
23
+ /** Framework-agnostic CSS properties type (compatible with React.CSSProperties) */
24
+ type CSSProperties = Record<string, any>;
25
+ /**
26
+ * Highlight rectangle representing a selected region
27
+ */
28
+ interface HighlightRect {
29
+ /** Left position in pixels */
30
+ left: number;
31
+ /** Top position in pixels */
32
+ top: number;
33
+ /** Width in pixels */
34
+ width: number;
35
+ /** Height in pixels */
36
+ height: number;
37
+ }
38
+ /**
39
+ * Selection highlight configuration
40
+ */
41
+ interface SelectionHighlightConfig {
42
+ /** Background color for selection */
43
+ backgroundColor: string;
44
+ /** Optional border color for selection */
45
+ borderColor?: string;
46
+ /** Optional border radius */
47
+ borderRadius?: number;
48
+ /** Z-index for overlay */
49
+ zIndex?: number;
50
+ /** Opacity for highlight */
51
+ opacity?: number;
52
+ /** Mix blend mode */
53
+ mixBlendMode?: CSSProperties['mixBlendMode'];
54
+ }
55
+
56
+ /**
57
+ * AutoSaveManager
58
+ *
59
+ * Framework-agnostic class for auto-saving documents to localStorage.
60
+ * Extracted from the React `useAutoSave` hook.
61
+ *
62
+ * Usage with React:
63
+ * ```ts
64
+ * const snapshot = useSyncExternalStore(manager.subscribe, manager.getSnapshot);
65
+ * ```
66
+ */
67
+
68
+ /** Format last save time for display */
69
+ declare function formatLastSaveTime(date: Date | null): string;
70
+ /** Get auto-save status label */
71
+ declare function getAutoSaveStatusLabel(status: AutoSaveStatus): string;
72
+ /** Get storage size used by auto-save */
73
+ declare function getAutoSaveStorageSize(storageKey?: string): number;
74
+ /** Format storage size for display */
75
+ declare function formatStorageSize(bytes: number): string;
76
+ /** Check if auto-save is supported */
77
+ declare function isAutoSaveSupported(): boolean;
78
+
79
+ /**
80
+ * TableSelectionManager
81
+ *
82
+ * Framework-agnostic class for managing table cell selection state.
83
+ * Extracted from the React `useTableSelection` hook.
84
+ *
85
+ * Handles:
86
+ * - Cell selection via data-attribute queries on the DOM
87
+ * - Table document operations (add/delete rows/columns, merge/split)
88
+ */
89
+
90
+ /** Data attributes for table elements in the rendered DOM */
91
+ declare const TABLE_DATA_ATTRIBUTES: {
92
+ readonly TABLE_INDEX: "data-table-index";
93
+ readonly ROW_INDEX: "data-row";
94
+ readonly COLUMN_INDEX: "data-col";
95
+ readonly TABLE_CELL: "data-table-cell";
96
+ };
97
+
98
+ /**
99
+ * ClipboardManager
100
+ *
101
+ * Framework-agnostic class for clipboard operations in the editor.
102
+ * Extracted from the React `useClipboard` hook.
103
+ *
104
+ * Handles:
105
+ * - DOM selection traversal and run extraction
106
+ * - Formatting extraction from computed styles
107
+ * - Clipboard read/write operations
108
+ */
109
+
110
+ /** Selection data for clipboard operations */
111
+ interface ClipboardSelection {
112
+ text: string;
113
+ runs: Run[];
114
+ startParagraphIndex: number;
115
+ startRunIndex: number;
116
+ startOffset: number;
117
+ endParagraphIndex: number;
118
+ endRunIndex: number;
119
+ endOffset: number;
120
+ isMultiParagraph: boolean;
121
+ }
122
+ /** Get selected runs from the current DOM selection. */
123
+ declare function getSelectionRuns(): Run[];
124
+ /** Create a ClipboardSelection from the current DOM selection. */
125
+ declare function createSelectionFromDOM(): ClipboardSelection | null;
126
+
127
+ /**
128
+ * History hook for undo/redo functionality
129
+ *
130
+ * Maintains undo/redo stacks with support for:
131
+ * - undo() and redo() operations
132
+ * - canUndo and canRedo state
133
+ * - Keyboard shortcuts (Ctrl+Z, Ctrl+Y, Ctrl+Shift+Z)
134
+ * - Grouping rapid changes to avoid cluttering history
135
+ */
136
+ /**
137
+ * History entry containing state and metadata
138
+ */
139
+ interface HistoryEntry<T> {
140
+ /** The state at this point */
141
+ state: T;
142
+ /** Timestamp when this entry was created */
143
+ timestamp: number;
144
+ /** Optional description of what changed */
145
+ description?: string;
146
+ }
147
+ /**
148
+ * Options for the useHistory hook
149
+ */
150
+ interface UseHistoryOptions<T> {
151
+ /** Maximum number of entries in history (default: 100) */
152
+ maxEntries?: number;
153
+ /** Time in ms to group rapid changes (default: 500) */
154
+ groupingInterval?: number;
155
+ /** Whether to enable keyboard shortcuts (default: true) */
156
+ enableKeyboardShortcuts?: boolean;
157
+ /** Custom comparison function for detecting changes */
158
+ isEqual?: (a: T, b: T) => boolean;
159
+ /** Callback when undo is triggered */
160
+ onUndo?: (state: T) => void;
161
+ /** Callback when redo is triggered */
162
+ onRedo?: (state: T) => void;
163
+ /** Ref to the container element for keyboard events */
164
+ containerRef?: React.RefObject<HTMLElement>;
165
+ }
166
+ /**
167
+ * Return type of the useHistory hook
168
+ */
169
+ interface UseHistoryReturn<T> {
170
+ /** Current state */
171
+ state: T;
172
+ /** Whether undo is available */
173
+ canUndo: boolean;
174
+ /** Whether redo is available */
175
+ canRedo: boolean;
176
+ /** Number of entries in undo stack */
177
+ undoCount: number;
178
+ /** Number of entries in redo stack */
179
+ redoCount: number;
180
+ /** Push a new state to history */
181
+ push: (newState: T, description?: string) => void;
182
+ /** Undo to previous state */
183
+ undo: () => T | undefined;
184
+ /** Redo to next state */
185
+ redo: () => T | undefined;
186
+ /** Clear all history */
187
+ clear: () => void;
188
+ /** Reset to initial state and clear history */
189
+ reset: (newInitialState?: T) => void;
190
+ /** Get all undo entries (for debugging/display) */
191
+ getUndoStack: () => HistoryEntry<T>[];
192
+ /** Get all redo entries (for debugging/display) */
193
+ getRedoStack: () => HistoryEntry<T>[];
194
+ /** Transform all stored states (current + undo/redo stacks) */
195
+ transformAll: (fn: (state: T) => T) => void;
196
+ }
197
+ /**
198
+ * Custom hook for managing undo/redo history
199
+ */
200
+ declare function useHistory<T>(initialState: T, options?: UseHistoryOptions<T>): UseHistoryReturn<T>;
201
+ /**
202
+ * Simplified hook that just tracks state changes automatically
203
+ */
204
+ declare function useAutoHistory<T>(value: T, options?: UseHistoryOptions<T>): Omit<UseHistoryReturn<T>, 'push'>;
205
+ /**
206
+ * Hook for document history with specialized comparison
207
+ */
208
+ declare function useDocumentHistory<T extends {
209
+ package?: {
210
+ document?: unknown;
211
+ headers?: unknown;
212
+ footers?: unknown;
213
+ } | null;
214
+ } | null>(document: T, options?: Omit<UseHistoryOptions<T>, 'isEqual'>): UseHistoryReturn<T>;
215
+ /**
216
+ * Create a history manager for non-React usage
217
+ */
218
+ declare class HistoryManager<T> {
219
+ private undoStack;
220
+ private redoStack;
221
+ private currentState;
222
+ private maxEntries;
223
+ private groupingInterval;
224
+ private lastPushTime;
225
+ private isEqual;
226
+ constructor(initialState: T, options?: {
227
+ maxEntries?: number;
228
+ groupingInterval?: number;
229
+ isEqual?: (a: T, b: T) => boolean;
230
+ });
231
+ get state(): T;
232
+ get canUndo(): boolean;
233
+ get canRedo(): boolean;
234
+ push(newState: T, description?: string): void;
235
+ undo(): T | undefined;
236
+ redo(): T | undefined;
237
+ clear(): void;
238
+ reset(newInitialState?: T): void;
239
+ }
240
+
241
+ /**
242
+ * useTableSelection Hook
243
+ *
244
+ * Thin React wrapper around the framework-agnostic TableSelectionManager.
245
+ * Provides table selection tracking and table operation dispatch.
246
+ */
247
+
248
+ interface TableSelectionState {
249
+ context: TableContext | null;
250
+ table: Table | null;
251
+ tableIndex: number | null;
252
+ rowIndex: number | null;
253
+ columnIndex: number | null;
254
+ }
255
+ interface UseTableSelectionReturn {
256
+ state: TableSelectionState;
257
+ handleCellClick: (tableIndex: number, rowIndex: number, columnIndex: number) => void;
258
+ handleAction: (action: TableAction) => void;
259
+ getSplitCellConfig: () => TableSplitConfig | null;
260
+ applySplitCell: (rows: number, cols: number) => void;
261
+ clearSelection: () => void;
262
+ isCellSelected: (tableIndex: number, rowIndex: number, columnIndex: number) => boolean;
263
+ tableContext: TableContext | null;
264
+ }
265
+ interface UseTableSelectionOptions {
266
+ document: Document | null;
267
+ onChange?: (document: Document) => void;
268
+ onSelectionChange?: (context: TableContext | null) => void;
269
+ }
270
+ declare function useTableSelection({ document: doc, onChange, onSelectionChange, }: UseTableSelectionOptions): UseTableSelectionReturn;
271
+
272
+ /**
273
+ * Selection Highlight Hook
274
+ *
275
+ * A React hook that manages visual selection highlighting across multiple runs.
276
+ * Uses a combination of CSS ::selection pseudo-element styling and optional
277
+ * overlay rectangles for complex scenarios.
278
+ *
279
+ * Features:
280
+ * - Consistent selection highlighting across all text runs
281
+ * - Support for text with different backgrounds (highlighted, dark bg)
282
+ * - Optional overlay rectangles for custom highlight effects
283
+ * - Debounced updates for performance
284
+ */
285
+
286
+ /**
287
+ * Options for the useSelectionHighlight hook
288
+ */
289
+ interface UseSelectionHighlightOptions {
290
+ /** Reference to the container element */
291
+ containerRef: React__default.RefObject<HTMLElement>;
292
+ /** Whether to enable selection highlighting */
293
+ enabled?: boolean;
294
+ /** Custom highlight configuration */
295
+ config?: SelectionHighlightConfig;
296
+ /** Whether to use overlay rectangles (default: false, uses CSS) */
297
+ useOverlay?: boolean;
298
+ /** Debounce delay for rect updates in ms (default: 16) */
299
+ debounceMs?: number;
300
+ /** Callback when selection changes */
301
+ onSelectionChange?: (hasSelection: boolean, text: string) => void;
302
+ }
303
+ /**
304
+ * Return value from the useSelectionHighlight hook
305
+ */
306
+ interface UseSelectionHighlightReturn {
307
+ /** Whether there is an active selection */
308
+ hasSelection: boolean;
309
+ /** The selected text */
310
+ selectedText: string;
311
+ /** Highlight rectangles (only populated if useOverlay is true) */
312
+ highlightRects: HighlightRect[];
313
+ /** Whether selection is within the container */
314
+ isSelectionInContainer: boolean;
315
+ /** Refresh the highlight state */
316
+ refresh: () => void;
317
+ /** Get styles for a highlight rect overlay */
318
+ getOverlayStyle: (rect: HighlightRect) => CSSProperties$1;
319
+ }
320
+ /**
321
+ * Hook to manage selection highlighting in the editor
322
+ */
323
+ declare function useSelectionHighlight(options: UseSelectionHighlightOptions): UseSelectionHighlightReturn;
324
+ /**
325
+ * Props for selection overlay component
326
+ */
327
+ interface SelectionOverlayProps {
328
+ /** Highlight rectangles to render */
329
+ rects: HighlightRect[];
330
+ /** Style configuration */
331
+ config?: SelectionHighlightConfig;
332
+ /** Additional class name */
333
+ className?: string;
334
+ }
335
+ /**
336
+ * Generate selection overlay elements (for use in JSX)
337
+ *
338
+ * Usage:
339
+ * ```tsx
340
+ * const { highlightRects } = useSelectionHighlight({ ... });
341
+ * return (
342
+ * <div style={{ position: 'relative' }}>
343
+ * {generateOverlayElements(highlightRects)}
344
+ * <div>... content ...</div>
345
+ * </div>
346
+ * );
347
+ * ```
348
+ */
349
+ declare function generateOverlayElements(rects: HighlightRect[], config?: SelectionHighlightConfig): React__default.ReactNode[];
350
+
351
+ /**
352
+ * useClipboard Hook
353
+ *
354
+ * Thin React wrapper around the framework-agnostic ClipboardManager.
355
+ * Handles clipboard operations with formatting preservation.
356
+ */
357
+
358
+ interface UseClipboardOptions {
359
+ onCopy?: (selection: ClipboardSelection) => void;
360
+ onCut?: (selection: ClipboardSelection) => void;
361
+ onPaste?: (content: ParsedClipboardContent, asPlainText: boolean) => void;
362
+ cleanWordFormatting?: boolean;
363
+ editable?: boolean;
364
+ onError?: (error: Error) => void;
365
+ /** Document theme — used to resolve themed colors in the HTML clipboard payload. */
366
+ theme?: Theme | null;
367
+ }
368
+ interface UseClipboardReturn {
369
+ copy: (selection: ClipboardSelection) => Promise<boolean>;
370
+ cut: (selection: ClipboardSelection) => Promise<boolean>;
371
+ paste: (asPlainText?: boolean) => Promise<ParsedClipboardContent | null>;
372
+ handleCopy: (event: ClipboardEvent) => void;
373
+ handleCut: (event: ClipboardEvent) => void;
374
+ handlePaste: (event: ClipboardEvent) => void;
375
+ handleKeyDown: (event: KeyboardEvent) => void;
376
+ isProcessing: boolean;
377
+ lastPastedContent: ParsedClipboardContent | null;
378
+ }
379
+ declare function useClipboard(options?: UseClipboardOptions): UseClipboardReturn;
380
+
381
+ /**
382
+ * useAutoSave Hook
383
+ *
384
+ * Thin React wrapper around the framework-agnostic AutoSaveManager.
385
+ * Bridges AutoSaveManager's subscribe/getSnapshot pattern with React state.
386
+ */
387
+
388
+ /** Options for useAutoSave hook */
389
+ interface UseAutoSaveOptions {
390
+ /** Storage key for localStorage (default: 'docx-editor-autosave') */
391
+ storageKey?: string;
392
+ /** Save interval in milliseconds (default: 30000 - 30 seconds) */
393
+ interval?: number;
394
+ /** Whether auto-save is enabled (default: true) */
395
+ enabled?: boolean;
396
+ /** Maximum age of auto-save in milliseconds before it's considered stale (default: 24 hours) */
397
+ maxAge?: number;
398
+ /** Callback when save succeeds */
399
+ onSave?: (timestamp: Date) => void;
400
+ /** Callback when save fails */
401
+ onError?: (error: Error) => void;
402
+ /** Callback when recovery data is found */
403
+ onRecoveryAvailable?: (savedDocument: SavedDocumentData) => void;
404
+ /** Whether to save immediately when document changes (debounced) */
405
+ saveOnChange?: boolean;
406
+ /** Debounce delay for saveOnChange in milliseconds (default: 2000) */
407
+ debounceDelay?: number;
408
+ }
409
+ /** Return value of useAutoSave hook */
410
+ interface UseAutoSaveReturn {
411
+ status: AutoSaveStatus;
412
+ lastSaveTime: Date | null;
413
+ save: () => Promise<boolean>;
414
+ clearAutoSave: () => void;
415
+ hasRecoveryData: boolean;
416
+ getRecoveryData: () => SavedDocumentData | null;
417
+ acceptRecovery: () => Document | null;
418
+ dismissRecovery: () => void;
419
+ isEnabled: boolean;
420
+ enable: () => void;
421
+ disable: () => void;
422
+ }
423
+ declare function useAutoSave(document: Document | null | undefined, options?: UseAutoSaveOptions): UseAutoSaveReturn;
424
+
425
+ /**
426
+ * Drag Auto-Scroll Hook
427
+ *
428
+ * When the user is drag-selecting text and moves the mouse near the
429
+ * top or bottom edge of the scroll container, this hook auto-scrolls
430
+ * the container and continues extending the selection.
431
+ */
432
+ interface DragAutoScrollOptions {
433
+ /** Ref to the pages container (used to find the scroll parent). */
434
+ pagesContainerRef: React.RefObject<HTMLDivElement | null>;
435
+ /** Called during auto-scroll to extend the selection at the current mouse position. */
436
+ onScrollExtendSelection: (clientX: number, clientY: number) => void;
437
+ }
438
+ declare function useDragAutoScroll({ pagesContainerRef, onScrollExtendSelection, }: DragAutoScrollOptions): {
439
+ updateMousePosition: (clientX: number, clientY: number) => void;
440
+ stopAutoScroll: () => void;
441
+ };
442
+
443
+ /**
444
+ * Hook for toolbar dropdowns that need position:fixed to escape overflow:auto/hidden ancestors.
445
+ *
446
+ * Returns refs and styles for a dropdown that positions itself below its trigger
447
+ * using fixed coordinates (like MenuDropdown), so it isn't clipped by the toolbar's
448
+ * overflow-x-auto container.
449
+ */
450
+
451
+ interface UseFixedDropdownOptions {
452
+ isOpen: boolean;
453
+ onClose: () => void;
454
+ /** 'left' aligns dropdown left edge to trigger, 'right' aligns right edge */
455
+ align?: 'left' | 'right';
456
+ }
457
+ interface UseFixedDropdownReturn {
458
+ containerRef: RefObject<HTMLDivElement | null>;
459
+ dropdownRef: RefObject<HTMLDivElement | null>;
460
+ dropdownStyle: CSSProperties$1;
461
+ handleMouseDown: (e: React.MouseEvent) => void;
462
+ }
463
+ declare function useFixedDropdown({ isOpen, onClose, align, }: UseFixedDropdownOptions): UseFixedDropdownReturn;
464
+
465
+ /**
466
+ * Width/height inputs with an optional aspect-ratio lock. `width`/`height`
467
+ * are `number | ''` so a cleared field shows empty instead of 0.
468
+ */
469
+ interface UseAspectLockedSizeReturn {
470
+ width: number | '';
471
+ height: number | '';
472
+ lockAspect: boolean;
473
+ setLockAspect: (locked: boolean) => void;
474
+ /** Number-input onChange handlers. Empty string clears, otherwise clamps to >= 1. */
475
+ handleWidthChange: (raw: string) => void;
476
+ handleHeightChange: (raw: string) => void;
477
+ /** Seed both fields and re-lock. Null/undefined values clear the input. */
478
+ seed: (w: number | null | undefined, h: number | null | undefined) => void;
479
+ }
480
+ declare function useAspectLockedSize(): UseAspectLockedSizeReturn;
481
+
482
+ interface VisualLineNavigationOptions {
483
+ pagesContainerRef: React.RefObject<HTMLDivElement | null>;
484
+ }
485
+ declare function useVisualLineNavigation({ pagesContainerRef }: VisualLineNavigationOptions): {
486
+ stickyXRef: React$1.RefObject<number | null>;
487
+ lastVisualLineIndexRef: React$1.RefObject<number>;
488
+ getCaretClientX: (pmPos: number) => number | null;
489
+ findLineElementAtPosition: (pmPos: number) => HTMLElement | null;
490
+ findPositionOnLineAtClientX: (lineEl: HTMLElement, clientX: number) => number | null;
491
+ handlePMKeyDown: (view: EditorView, event: KeyboardEvent) => boolean;
492
+ };
493
+
494
+ /**
495
+ * useWheelZoom Hook
496
+ *
497
+ * Enables Ctrl+scroll (or Cmd+scroll on Mac) to zoom in/out.
498
+ * Features:
499
+ * - Configurable zoom range and step
500
+ * - Smooth zoom transitions
501
+ * - Pinch-to-zoom support on trackpads
502
+ * - Zoom reset (Ctrl+0)
503
+ * - Zoom in/out shortcuts (Ctrl++, Ctrl+-)
504
+ */
505
+ /**
506
+ * Options for useWheelZoom hook
507
+ */
508
+ interface UseWheelZoomOptions {
509
+ /** Initial zoom level (default: 1.0) */
510
+ initialZoom?: number;
511
+ /** Minimum zoom level (default: 0.25) */
512
+ minZoom?: number;
513
+ /** Maximum zoom level (default: 4.0) */
514
+ maxZoom?: number;
515
+ /** Zoom step for each scroll event (default: 0.1) */
516
+ zoomStep?: number;
517
+ /** Whether zoom is enabled (default: true) */
518
+ enabled?: boolean;
519
+ /** Container element ref to attach wheel listener */
520
+ containerRef?: React.RefObject<HTMLElement>;
521
+ /** Callback when zoom changes */
522
+ onZoomChange?: (zoom: number) => void;
523
+ /** Whether to enable keyboard shortcuts (Ctrl++, Ctrl+-, Ctrl+0) */
524
+ enableKeyboardShortcuts?: boolean;
525
+ /** Whether to prevent default browser zoom behavior */
526
+ preventDefault?: boolean;
527
+ }
528
+ /**
529
+ * Return value of useWheelZoom hook
530
+ */
531
+ interface UseWheelZoomReturn {
532
+ /** Current zoom level */
533
+ zoom: number;
534
+ /** Set zoom level directly */
535
+ setZoom: (zoom: number) => void;
536
+ /** Zoom in by step */
537
+ zoomIn: () => void;
538
+ /** Zoom out by step */
539
+ zoomOut: () => void;
540
+ /** Reset zoom to initial level */
541
+ resetZoom: () => void;
542
+ /** Reset zoom to 100% */
543
+ zoomTo100: () => void;
544
+ /** Zoom to fit width */
545
+ zoomToFit: (containerWidth: number, contentWidth: number) => void;
546
+ /** Whether currently at minimum zoom */
547
+ isMinZoom: boolean;
548
+ /** Whether currently at maximum zoom */
549
+ isMaxZoom: boolean;
550
+ /** Zoom percentage (e.g., 100 for zoom level 1.0) */
551
+ zoomPercent: number;
552
+ /** Wheel event handler (for manual attachment) */
553
+ handleWheel: (event: WheelEvent) => void;
554
+ /** Keyboard event handler (for manual attachment) */
555
+ handleKeyDown: (event: KeyboardEvent) => void;
556
+ }
557
+ /**
558
+ * Preset zoom levels for snapping
559
+ */
560
+ declare const ZOOM_PRESETS: number[];
561
+ /**
562
+ * React hook for Ctrl+scroll zoom functionality
563
+ */
564
+ declare function useWheelZoom(options?: UseWheelZoomOptions): UseWheelZoomReturn;
565
+ /**
566
+ * Get zoom presets
567
+ */
568
+ declare function getZoomPresets(): number[];
569
+ /**
570
+ * Find nearest zoom preset
571
+ */
572
+ declare function findNearestZoomPreset(zoom: number): number;
573
+ /**
574
+ * Get next zoom preset (for zoom in)
575
+ */
576
+ declare function getNextZoomPreset(zoom: number): number;
577
+ /**
578
+ * Get previous zoom preset (for zoom out)
579
+ */
580
+ declare function getPreviousZoomPreset(zoom: number): number;
581
+ /**
582
+ * Format zoom level for display
583
+ */
584
+ declare function formatZoom(zoom: number): string;
585
+ /**
586
+ * Parse zoom from percentage string
587
+ */
588
+ declare function parseZoom(zoomString: string): number | null;
589
+ /**
590
+ * Check if zoom level is at a preset
591
+ */
592
+ declare function isZoomPreset(zoom: number): boolean;
593
+ /**
594
+ * Clamp zoom to valid range
595
+ */
596
+ declare function clampZoom(zoom: number, minZoom?: number, maxZoom?: number): number;
597
+
598
+ export { AutoSaveStatus, type ClipboardSelection, type DragAutoScrollOptions, type HistoryEntry, HistoryManager, SavedDocumentData, type SelectionOverlayProps, TABLE_DATA_ATTRIBUTES, 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, createSelectionFromDOM, findNearestZoomPreset, formatLastSaveTime, formatStorageSize, formatZoom, generateOverlayElements, getAutoSaveStatusLabel, getAutoSaveStorageSize, getNextZoomPreset, getPreviousZoomPreset, getSelectionRuns, getZoomPresets, isAutoSaveSupported, isZoomPreset, parseZoom, useAspectLockedSize, useAutoHistory, useAutoSave, useClipboard, useDocumentHistory, useDragAutoScroll, useFixedDropdown, useHistory, useSelectionHighlight, useTableSelection, useVisualLineNavigation, useWheelZoom };