@zeke-02/docx-editor 0.5.2 → 0.5.4

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 (223) 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-B0UFuR4w.d.ts +395 -0
  13. package/dist/KeyboardShortcutsDialog-t6JKL4Aj.d.mts +395 -0
  14. package/dist/PageSetupDialog-642IAVG2.js +1 -0
  15. package/dist/PageSetupDialog-ERUQDHAY.mjs +1 -0
  16. package/dist/PluginHost-HS31VIuo.d.mts +16 -0
  17. package/dist/PluginHost-zILZO7zX.d.ts +16 -0
  18. package/dist/{SplitCellDialog-NP3JJYHD.mjs → SplitCellDialog-GFWCFCTD.mjs} +1 -1
  19. package/dist/{SplitCellDialog-JIAC3RYV.js → SplitCellDialog-M7WF7ANE.js} +1 -1
  20. package/dist/{TablePropertiesDialog-TIK4AA5M.mjs → TablePropertiesDialog-TZ7VCL6V.mjs} +1 -1
  21. package/dist/{TablePropertiesDialog-T7D4HSVP.js → TablePropertiesDialog-ZKU2FTUX.js} +1 -1
  22. package/dist/agentApi-B2Y7kexW.d.ts +486 -0
  23. package/dist/agentApi-BzUJ_kao.d.mts +486 -0
  24. package/dist/chunk-2XXILKEQ.js +1 -0
  25. package/dist/chunk-35DG3R42.js +2 -0
  26. package/dist/chunk-5UX5CD4C.js +1 -0
  27. package/dist/chunk-7QQSDIWK.mjs +2 -0
  28. package/dist/chunk-AW5TISUL.js +3 -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-F5SERL7X.mjs +2 -0
  34. package/dist/chunk-FWPVBFKQ.mjs +1 -0
  35. package/dist/chunk-GGQK26JO.js +2 -0
  36. package/dist/chunk-GM2S2WMT.mjs +1 -0
  37. package/dist/chunk-HXDMASAR.js +1 -0
  38. package/dist/chunk-ILYKDR3C.js +1 -0
  39. package/dist/chunk-JFRDFK7V.mjs +260 -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-LWOHVYKW.mjs +1 -0
  44. package/dist/chunk-MDTA25AN.mjs +60 -0
  45. package/dist/chunk-MKNSJOCN.js +70 -0
  46. package/dist/chunk-NIBCC7WQ.js +1 -0
  47. package/dist/chunk-NLFXR2VH.js +2 -0
  48. package/dist/chunk-NOLMVQNN.mjs +40 -0
  49. package/dist/chunk-ONIYA2FU.mjs +2 -0
  50. package/dist/chunk-RCIZ7OM3.mjs +70 -0
  51. package/dist/chunk-SGTUE33R.js +260 -0
  52. package/dist/{chunk-EHFEG3TX.js → chunk-SNZ57XBI.js} +1 -1
  53. package/dist/chunk-SOTWG3KJ.mjs +1 -0
  54. package/dist/chunk-TYPGB4KF.js +1 -0
  55. package/dist/chunk-U7ZW2DOO.mjs +2 -0
  56. package/dist/chunk-WO3FIV4B.js +40 -0
  57. package/dist/{chunk-PKEOQIQO.mjs → chunk-WPI3YRFO.mjs} +1 -1
  58. package/dist/chunk-XGJ2EORY.mjs +1 -0
  59. package/dist/chunk-XQZTWWRF.mjs +18 -0
  60. package/dist/chunk-Y3SEHWZ2.js +1 -0
  61. package/dist/chunk-YBEVHQCT.js +60 -0
  62. package/dist/chunk-ZVAFVHWR.mjs +3 -0
  63. package/dist/chunk-ZXPCJWVY.js +2 -0
  64. package/dist/{agentApi-DLt94vXk.d.mts → content-REFGFfEH.d.mts} +8 -755
  65. package/dist/{agentApi-DLt94vXk.d.ts → content-REFGFfEH.d.ts} +8 -755
  66. package/dist/dialogs.d.mts +25 -0
  67. package/dist/dialogs.d.ts +25 -0
  68. package/dist/dialogs.js +1 -0
  69. package/dist/dialogs.mjs +1 -0
  70. package/dist/document-Cu2vq_wS.d.mts +294 -0
  71. package/dist/document-CxOagoLQ.d.ts +294 -0
  72. package/dist/executor-WBHID2RK.mjs +1 -0
  73. package/dist/executor-Y5VUOAHY.js +1 -0
  74. package/dist/findReplace-Bue0JaXh.d.ts +138 -0
  75. package/dist/findReplace-shXbOjFQ.d.mts +138 -0
  76. package/dist/fork.d.mts +535 -0
  77. package/dist/fork.d.ts +535 -0
  78. package/dist/fork.js +1 -0
  79. package/dist/fork.mjs +1 -0
  80. package/dist/hooks.d.mts +598 -0
  81. package/dist/hooks.d.ts +598 -0
  82. package/dist/hooks.js +1 -0
  83. package/dist/hooks.mjs +1 -0
  84. package/dist/index-B5A-J9GC.d.ts +1119 -0
  85. package/dist/index-bw-PaozF.d.mts +1119 -0
  86. package/dist/index.d.mts +12 -591
  87. package/dist/index.d.ts +12 -591
  88. package/dist/index.js +1 -120
  89. package/dist/index.mjs +1 -120
  90. package/dist/layout-bridge-5GYGYKM5.mjs +1 -0
  91. package/dist/layout-bridge-QQDA7ELH.js +1 -0
  92. package/dist/plugin-api.d.mts +165 -0
  93. package/dist/plugin-api.d.ts +165 -0
  94. package/dist/plugin-api.js +1 -0
  95. package/dist/plugin-api.mjs +1 -0
  96. package/dist/processTemplate-BTBTR7AM.js +1 -0
  97. package/dist/{processTemplate-W2C5PXZB.mjs → processTemplate-MBX2KDLE.mjs} +1 -1
  98. package/dist/styles.css +1 -1
  99. package/dist/styles.d.mts +18 -0
  100. package/dist/styles.d.ts +18 -0
  101. package/dist/styles.js +1 -0
  102. package/dist/styles.mjs +1 -0
  103. package/dist/types-BF48VxkC.d.mts +18 -0
  104. package/dist/types-BF48VxkC.d.ts +18 -0
  105. package/dist/types-BnIs4sE7.d.mts +281 -0
  106. package/dist/types-BnIs4sE7.d.ts +281 -0
  107. package/dist/types-CW6HFAX6.d.ts +39 -0
  108. package/dist/types-DIsDCwTG.d.mts +39 -0
  109. package/dist/ui.d.mts +111 -552
  110. package/dist/ui.d.ts +111 -552
  111. package/dist/ui.js +111 -1
  112. package/dist/ui.mjs +111 -1
  113. package/dist/useFindReplace-DKy-s3gS.d.ts +261 -0
  114. package/dist/useFindReplace-vuoKpDKE.d.mts +261 -0
  115. package/package.json +47 -49
  116. package/dist/ClipboardManager-CVKX0v9q.d.ts +0 -464
  117. package/dist/ClipboardManager-V3aaMnWE.d.mts +0 -464
  118. package/dist/DocumentAgent-BWflKHpH.d.mts +0 -442
  119. package/dist/DocumentAgent-DsdXtetF.d.ts +0 -442
  120. package/dist/FindReplaceDialog-L3YF5HIS.mjs +0 -1
  121. package/dist/FindReplaceDialog-SEBWC5P7.js +0 -1
  122. package/dist/HyperlinkDialog-WEK6JSAC.js +0 -1
  123. package/dist/ImagePropertiesDialog-527MFLQO.mjs +0 -1
  124. package/dist/ImagePropertiesDialog-HG4K3IE7.js +0 -1
  125. package/dist/PageSetupDialog-GALVJMUB.js +0 -1
  126. package/dist/PageSetupDialog-TGQIAMI7.mjs +0 -1
  127. package/dist/TableToolbar-DUgmob2I.d.ts +0 -1273
  128. package/dist/TableToolbar-YL74HNS1.d.mts +0 -1273
  129. package/dist/chunk-23SXXIZS.js +0 -111
  130. package/dist/chunk-3F52AP2Q.js +0 -1
  131. package/dist/chunk-42O5GXM5.mjs +0 -82
  132. package/dist/chunk-54ULJEHM.mjs +0 -1
  133. package/dist/chunk-5XK326FI.mjs +0 -1
  134. package/dist/chunk-6WPRCJ5A.mjs +0 -1
  135. package/dist/chunk-76IYR7C7.mjs +0 -1
  136. package/dist/chunk-AGRIVA4G.js +0 -1
  137. package/dist/chunk-BTCQ2QI3.mjs +0 -3
  138. package/dist/chunk-BUEMG4NW.js +0 -1
  139. package/dist/chunk-BXRC4U3X.mjs +0 -2
  140. package/dist/chunk-CPAYKE6X.mjs +0 -1
  141. package/dist/chunk-DACWLFKI.mjs +0 -1
  142. package/dist/chunk-EPBFWE36.js +0 -2
  143. package/dist/chunk-FXES3YDB.js +0 -82
  144. package/dist/chunk-HI66BSGS.mjs +0 -9
  145. package/dist/chunk-INTPVEO6.mjs +0 -9
  146. package/dist/chunk-IOAGVW6Q.mjs +0 -2
  147. package/dist/chunk-JCEWC5QL.mjs +0 -4
  148. package/dist/chunk-JTIUFACT.js +0 -1
  149. package/dist/chunk-LUF7PWIC.js +0 -10
  150. package/dist/chunk-MGEN6GOE.mjs +0 -2
  151. package/dist/chunk-MOE2ZGUE.js +0 -18
  152. package/dist/chunk-MWLHJWB6.js +0 -9
  153. package/dist/chunk-OFYVDN3U.mjs +0 -2
  154. package/dist/chunk-P4VSHBGZ.js +0 -2
  155. package/dist/chunk-P5FQHIES.mjs +0 -1
  156. package/dist/chunk-PBC7XAYZ.js +0 -3
  157. package/dist/chunk-PEMB6SZT.js +0 -2
  158. package/dist/chunk-PQMSZTBB.js +0 -9
  159. package/dist/chunk-Q7UDQXAF.js +0 -1
  160. package/dist/chunk-QGTAIC5E.js +0 -1
  161. package/dist/chunk-QVPR2W5S.js +0 -1
  162. package/dist/chunk-R3QMYPL5.mjs +0 -59
  163. package/dist/chunk-RBUTXXQJ.mjs +0 -18
  164. package/dist/chunk-RRWYZ2TS.mjs +0 -111
  165. package/dist/chunk-S3STEPVO.js +0 -182
  166. package/dist/chunk-SFUM35DH.js +0 -2
  167. package/dist/chunk-SNLC6EK2.js +0 -1
  168. package/dist/chunk-TMTLIGLZ.js +0 -59
  169. package/dist/chunk-TSE2PWFX.mjs +0 -10
  170. package/dist/chunk-UKESXQS5.mjs +0 -182
  171. package/dist/chunk-UWYD42WV.js +0 -4
  172. package/dist/chunk-UXVACQCY.mjs +0 -1
  173. package/dist/chunk-W4EIKDM6.mjs +0 -2
  174. package/dist/chunk-W53SI3XW.mjs +0 -1
  175. package/dist/chunk-WNS2RBQD.js +0 -2
  176. package/dist/chunk-Z3KMSHUP.js +0 -1
  177. package/dist/core-plugins-reexport.d.mts +0 -31
  178. package/dist/core-plugins-reexport.d.ts +0 -31
  179. package/dist/core-plugins-reexport.js +0 -1
  180. package/dist/core-plugins-reexport.mjs +0 -1
  181. package/dist/core-reexport.d.mts +0 -340
  182. package/dist/core-reexport.d.ts +0 -340
  183. package/dist/core-reexport.js +0 -1
  184. package/dist/core-reexport.mjs +0 -1
  185. package/dist/documentSerializer-DtS_-oGA.d.mts +0 -664
  186. package/dist/documentSerializer-Wj1p2ASa.d.ts +0 -664
  187. package/dist/executor-C3VXF7QA.mjs +0 -1
  188. package/dist/executor-GDBV3AGV.js +0 -1
  189. package/dist/headless-reexport.d.mts +0 -197
  190. package/dist/headless-reexport.d.ts +0 -197
  191. package/dist/headless-reexport.js +0 -1
  192. package/dist/headless-reexport.mjs +0 -1
  193. package/dist/insertOperations-BTH1Asas.d.mts +0 -176
  194. package/dist/insertOperations-CbUnXAXH.d.ts +0 -176
  195. package/dist/layout-bridge-EA4DJ227.js +0 -1
  196. package/dist/layout-bridge-XDPSO6GO.mjs +0 -1
  197. package/dist/mcp-reexport.d.mts +0 -156
  198. package/dist/mcp-reexport.d.ts +0 -156
  199. package/dist/mcp-reexport.js +0 -16
  200. package/dist/mcp-reexport.mjs +0 -16
  201. package/dist/processTemplate-MJ2PCSO5.js +0 -1
  202. package/dist/react-B0W16SV6.d.ts +0 -1330
  203. package/dist/react-D0Pn1nww.d.mts +0 -1330
  204. package/dist/react.d.mts +0 -10
  205. package/dist/react.d.ts +0 -10
  206. package/dist/react.js +0 -1
  207. package/dist/react.mjs +0 -1
  208. package/dist/registry-CH9V-IX0.d.ts +0 -165
  209. package/dist/registry-CWBKYlNW.d.mts +0 -165
  210. package/dist/types-UDsUq8D3.d.mts +0 -310
  211. package/dist/types-jbivc9Lj.d.ts +0 -310
  212. package/dist/variableDetector-CdQ7ZTzA.d.mts +0 -204
  213. package/dist/variableDetector-DsRV3A9z.d.ts +0 -204
  214. package/i18n/de.json +0 -792
  215. package/i18n/en.json +0 -792
  216. package/i18n/he.json +0 -792
  217. package/i18n/pl.json +0 -792
  218. package/i18n/pt-BR.json +0 -792
  219. package/i18n/tr.json +0 -792
  220. package/i18n/zh-CN.json +0 -792
  221. /package/dist/{chunk-YC5KZSYD.js → chunk-ESZ6JRTW.js} +0 -0
  222. /package/dist/{chunk-LVGJKS7Y.mjs → chunk-TZMMD6RR.mjs} +0 -0
  223. /package/dist/{react.css → fork.css} +0 -0
@@ -0,0 +1,598 @@
1
+ import { D as Document, T as Theme } from './document-CxOagoLQ.js';
2
+ import { b as TableContext, T as TableAction, d as TableSplitConfig } from './useFindReplace-DKy-s3gS.js';
3
+ export { F as FindReplaceOptions, a as FindReplaceState, U as UseFindReplaceReturn, u as useFindReplace } from './useFindReplace-DKy-s3gS.js';
4
+ import { R as Run, f as Table } from './content-REFGFfEH.js';
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-Bue0JaXh.js';
8
+ import { A as AutoSaveStatus, S as SavedDocumentData } from './types-CW6HFAX6.js';
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 };
package/dist/hooks.js ADDED
@@ -0,0 +1 @@
1
+ 'use strict';var chunkY3SEHWZ2_js=require('./chunk-Y3SEHWZ2.js'),chunkNIBCC7WQ_js=require('./chunk-NIBCC7WQ.js'),chunkBRMTZRLJ_js=require('./chunk-BRMTZRLJ.js'),chunkMKNSJOCN_js=require('./chunk-MKNSJOCN.js'),chunk35DG3R42_js=require('./chunk-35DG3R42.js');require('./chunk-NLFXR2VH.js');var chunkYBEVHQCT_js=require('./chunk-YBEVHQCT.js');require('./chunk-HXDMASAR.js'),require('./chunk-IFPN3NT3.js'),require('./chunk-B45ECEGY.js'),require('./chunk-GGQK26JO.js');var chunkZXPCJWVY_js=require('./chunk-ZXPCJWVY.js');require('./chunk-ILYKDR3C.js'),require('./chunk-ESZ6JRTW.js'),require('./chunk-H5NTJZO4.js');var he=require('react');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var he__default=/*#__PURE__*/_interopDefault(he);function ve(n){let{containerRef:e,enabled:r=true,config:s=chunkMKNSJOCN_js.a,useOverlay:c=false,debounceMs:u=16,onSelectionChange:f}=n,[S,p]=he.useState(false),[x,v]=he.useState(""),[a,m]=he.useState([]),[d,y]=he.useState(false),h=he.useRef(null),C=he.useRef(0),o=he.useCallback(()=>{let t=e.current,b=chunkMKNSJOCN_js.c(),D=chunkMKNSJOCN_js.d(),U=t?chunkMKNSJOCN_js.e(t):false;if(p(b),v(D),y(U),c&&U){let ae=chunkMKNSJOCN_js.b(t);m(ae);}else m([]);f&&f(b&&U,D);},[e,c,f]),i=he.useCallback(()=>{let t=performance.now();if(t-C.current<u){h.current!==null&&clearTimeout(h.current),h.current=window.setTimeout(()=>{C.current=performance.now(),o(),h.current=null;},u);return}C.current=t,o();},[u,o]),l=he.useCallback(()=>{o();},[o]),R=he.useCallback(t=>({position:"absolute",left:`${t.left}px`,top:`${t.top}px`,width:`${t.width}px`,height:`${t.height}px`,backgroundColor:s.backgroundColor,borderRadius:s.borderRadius?`${s.borderRadius}px`:void 0,border:s.borderColor?`1px solid ${s.borderColor}`:void 0,zIndex:s.zIndex??0,opacity:s.opacity??1,mixBlendMode:s.mixBlendMode,pointerEvents:"none",userSelect:"none"}),[s]);return he.useEffect(()=>(r&&!chunkMKNSJOCN_js.g()&&chunkMKNSJOCN_js.f(s),()=>{}),[r,s]),he.useEffect(()=>{if(!r)return;let t=()=>{i();};return document.addEventListener("selectionchange",t),document.addEventListener("mouseup",t),o(),()=>{document.removeEventListener("selectionchange",t),document.removeEventListener("mouseup",t),h.current!==null&&clearTimeout(h.current);}},[r,i,o]),{hasSelection:S,selectedText:x,highlightRects:a,isSelectionInContainer:d,refresh:l,getOverlayStyle:R}}function ge(n,e=chunkMKNSJOCN_js.a){return n.map((r,s)=>he__default.default.createElement("div",{key:`selection-overlay-${s}`,style:{position:"absolute",left:`${r.left}px`,top:`${r.top}px`,width:`${r.width}px`,height:`${r.height}px`,backgroundColor:e.backgroundColor,borderRadius:e.borderRadius?`${e.borderRadius}px`:void 0,border:e.borderColor?`1px solid ${e.borderColor}`:void 0,zIndex:e.zIndex??0,opacity:e.opacity??1,mixBlendMode:e.mixBlendMode,pointerEvents:"none",userSelect:"none"}}))}function xe(n={}){let{onCopy:e,onCut:r,onPaste:s,cleanWordFormatting:c=true,editable:u=true,onError:f,theme:S}=n,p=he.useRef(false),x=he.useRef(null),v=he.useCallback(async o=>{if(p.current)return false;p.current=true;try{let i=await chunkZXPCJWVY_js.g(o.runs,{onError:f,theme:S});return i&&e?.(o),i}finally{p.current=false;}},[e,f,S]),a=he.useCallback(async o=>{if(p.current||!u)return false;p.current=true;try{let i=await chunkZXPCJWVY_js.g(o.runs,{onError:f,theme:S});return i&&r?.(o),i}finally{p.current=false;}},[r,u,f,S]),m=he.useCallback(async(o=false)=>{if(p.current||!u)return null;p.current=true;try{if(navigator.clipboard&&navigator.clipboard.read){let i=await navigator.clipboard.read(),l="",R="";for(let b of i)b.types.includes("text/html")&&(l=await(await b.getType("text/html")).text()),b.types.includes("text/plain")&&(R=await(await b.getType("text/plain")).text());o&&(l="");let t=chunkZXPCJWVY_js.k(l,R,c);return x.current=t,s?.(t,o),t}return null}catch(i){return f?.(i),null}finally{p.current=false;}},[u,c,s,f]),d=he.useCallback(o=>{let i=chunkYBEVHQCT_js.p();if(!i)return;o.preventDefault();let l=chunkZXPCJWVY_js.h(i.runs,true,S);o.clipboardData&&(o.clipboardData.setData("text/plain",l.plainText),o.clipboardData.setData("text/html",l.html),l.internal&&o.clipboardData.setData("application/x-docx-editor",l.internal)),e?.(i);},[e,S]),y=he.useCallback(o=>{if(!u)return;let i=chunkYBEVHQCT_js.p();if(!i)return;o.preventDefault();let l=chunkZXPCJWVY_js.h(i.runs,true,S);o.clipboardData&&(o.clipboardData.setData("text/plain",l.plainText),o.clipboardData.setData("text/html",l.html),l.internal&&o.clipboardData.setData("application/x-docx-editor",l.internal)),r?.(i);},[u,r,S]),h=he.useCallback(o=>{if(!u)return;o.preventDefault();let i=chunkZXPCJWVY_js.j(o,{cleanWordFormatting:c});if(i){x.current=i;let l=o.shiftKey??false;s?.(i,l);}},[u,c,s]),C=he.useCallback(o=>{},[]);return {copy:v,cut:a,paste:m,handleCopy:d,handleCut:y,handlePaste:h,handleKeyDown:C,isProcessing:p.current,lastPastedContent:x.current}}function Re(n,e={}){let{storageKey:r,interval:s,enabled:c=true,maxAge:u,onSave:f,onError:S,onRecoveryAvailable:p,saveOnChange:x,debounceDelay:v}=e,a=he.useMemo(()=>new chunkYBEVHQCT_js.d({storageKey:r,interval:s,maxAge:u,saveOnChange:x,debounceDelay:v,onSave:f,onError:S,onRecoveryAvailable:p}),[r]);he.useEffect(()=>{c?(a.enable(),a.startInterval()):a.disable();},[a,c]),he.useEffect(()=>{a.onDocumentChanged(n??null);},[a,n]),he.useEffect(()=>()=>{a.destroy();},[a]);let m=he.useSyncExternalStore(a.subscribe,a.getSnapshot),d=he.useCallback(()=>a.save(),[a]),y=he.useCallback(()=>a.clear(),[a]),h=he.useCallback(()=>a.getRecoveryData(),[a]),C=he.useCallback(()=>a.acceptRecovery(),[a]),o=he.useCallback(()=>a.dismissRecovery(),[a]),i=he.useCallback(()=>a.enable(),[a]),l=he.useCallback(()=>a.disable(),[a]);return {status:m.status,lastSaveTime:m.lastSaveTime,save:d,clearAutoSave:y,hasRecoveryData:m.hasRecoveryData,getRecoveryData:h,acceptRecovery:C,dismissRecovery:o,isEnabled:m.isEnabled,enable:i,disable:l}}var Oe=1,te=.25,oe=4,Pe=.1,g=[.25,.5,.75,1,1.25,1.5,2,3,4];function ne(n,e,r){return Math.max(e,Math.min(r,n))}function re(n){return Math.round(n*100)/100}function Ze(n){let e=g[0],r=Math.abs(n-e);for(let s of g){let c=Math.abs(n-s);c<r&&(r=c,e=s);}return e}function Te(n){for(let e of g)if(e>n+.01)return e;return g[g.length-1]}function Ae(n){for(let e=g.length-1;e>=0;e--)if(g[e]<n-.01)return g[e];return g[0]}function Ue(n={}){let{initialZoom:e=Oe,minZoom:r=te,maxZoom:s=oe,zoomStep:c=Pe,enabled:u=true,containerRef:f,onZoomChange:S,enableKeyboardShortcuts:p=true,preventDefault:x=true}=n,[v,a]=he.useState(e),m=he.useRef(v);he.useEffect(()=>{m.current=v;},[v]);let d=he.useCallback(t=>{let b=re(ne(t,r,s));b!==m.current&&(a(b),S?.(b));},[r,s,S]),y=he.useCallback(()=>{d(m.current+c);},[c,d]),h=he.useCallback(()=>{d(m.current-c);},[c,d]),C=he.useCallback(()=>{d(e);},[e,d]),o=he.useCallback(()=>{d(1);},[d]),i=he.useCallback((t,b)=>{if(b>0){let D=t/b;d(D);}},[d]),l=he.useCallback(t=>{if(!u||!(t.ctrlKey||t.metaKey))return;x&&t.preventDefault();let D=t.deltaY;D<0?d(m.current+c):D>0&&d(m.current-c);},[u,x,c,d]),R=he.useCallback(t=>{if(!(!u||!p||!(t.ctrlKey||t.metaKey))){if(t.key==="0"){t.preventDefault(),o();return}if(t.key==="+"||t.key==="="){t.preventDefault(),y();return}if(t.key==="-"){t.preventDefault(),h();return}}},[u,p,y,h,o]);return he.useEffect(()=>{if(!u)return;let t=f?.current;if(t)return t.addEventListener("wheel",l,{passive:false}),()=>{t.removeEventListener("wheel",l);}},[u,f,l]),he.useEffect(()=>{if(!(!u||!p))return document.addEventListener("keydown",R),()=>{document.removeEventListener("keydown",R);}},[u,p,R]),{zoom:v,setZoom:d,zoomIn:y,zoomOut:h,resetZoom:C,zoomTo100:o,zoomToFit:i,isMinZoom:v<=r,isMaxZoom:v>=s,zoomPercent:Math.round(v*100),handleWheel:l,handleKeyDown:R}}function Me(){return [...g]}function He(n){return Ze(n)}function we(n){return Te(n)}function Le(n){return Ae(n)}function ze(n){return `${Math.round(n*100)}%`}function Fe(n){let e=n.match(/(\d+(\.\d+)?)/);if(e){let r=parseFloat(e[1]);if(!isNaN(r))return r/100}return null}function ke(n){return g.some(e=>Math.abs(e-n)<.01)}function Ie(n,e=te,r=oe){return re(ne(n,e,r))}Object.defineProperty(exports,"HistoryManager",{enumerable:true,get:function(){return chunkY3SEHWZ2_js.e}});Object.defineProperty(exports,"useAutoHistory",{enumerable:true,get:function(){return chunkY3SEHWZ2_js.c}});Object.defineProperty(exports,"useDocumentHistory",{enumerable:true,get:function(){return chunkY3SEHWZ2_js.d}});Object.defineProperty(exports,"useDragAutoScroll",{enumerable:true,get:function(){return chunkY3SEHWZ2_js.h}});Object.defineProperty(exports,"useHistory",{enumerable:true,get:function(){return chunkY3SEHWZ2_js.b}});Object.defineProperty(exports,"useTableSelection",{enumerable:true,get:function(){return chunkY3SEHWZ2_js.a}});Object.defineProperty(exports,"useVisualLineNavigation",{enumerable:true,get:function(){return chunkY3SEHWZ2_js.g}});Object.defineProperty(exports,"useAspectLockedSize",{enumerable:true,get:function(){return chunkNIBCC7WQ_js.a}});Object.defineProperty(exports,"useFixedDropdown",{enumerable:true,get:function(){return chunkBRMTZRLJ_js.c}});Object.defineProperty(exports,"useFindReplace",{enumerable:true,get:function(){return chunk35DG3R42_js.m}});Object.defineProperty(exports,"TABLE_DATA_ATTRIBUTES",{enumerable:true,get:function(){return chunkYBEVHQCT_js.j}});Object.defineProperty(exports,"createSelectionFromDOM",{enumerable:true,get:function(){return chunkYBEVHQCT_js.p}});Object.defineProperty(exports,"formatLastSaveTime",{enumerable:true,get:function(){return chunkYBEVHQCT_js.e}});Object.defineProperty(exports,"formatStorageSize",{enumerable:true,get:function(){return chunkYBEVHQCT_js.h}});Object.defineProperty(exports,"getAutoSaveStatusLabel",{enumerable:true,get:function(){return chunkYBEVHQCT_js.f}});Object.defineProperty(exports,"getAutoSaveStorageSize",{enumerable:true,get:function(){return chunkYBEVHQCT_js.g}});Object.defineProperty(exports,"getSelectionRuns",{enumerable:true,get:function(){return chunkYBEVHQCT_js.o}});Object.defineProperty(exports,"isAutoSaveSupported",{enumerable:true,get:function(){return chunkYBEVHQCT_js.i}});exports.ZOOM_PRESETS=g;exports.clampZoom=Ie;exports.findNearestZoomPreset=He;exports.formatZoom=ze;exports.generateOverlayElements=ge;exports.getNextZoomPreset=we;exports.getPreviousZoomPreset=Le;exports.getZoomPresets=Me;exports.isZoomPreset=ke;exports.parseZoom=Fe;exports.useAutoSave=Re;exports.useClipboard=xe;exports.useSelectionHighlight=ve;exports.useWheelZoom=Ue;
package/dist/hooks.mjs ADDED
@@ -0,0 +1 @@
1
+ export{e as HistoryManager,c as useAutoHistory,d as useDocumentHistory,h as useDragAutoScroll,b as useHistory,a as useTableSelection,g as useVisualLineNavigation}from'./chunk-LWOHVYKW.mjs';export{a as useAspectLockedSize}from'./chunk-GM2S2WMT.mjs';export{c as useFixedDropdown}from'./chunk-U7ZW2DOO.mjs';import {a,c,d,e,b,g as g$1,f}from'./chunk-RCIZ7OM3.mjs';export{m as useFindReplace}from'./chunk-F5SERL7X.mjs';import'./chunk-7QQSDIWK.mjs';import {p,d as d$1}from'./chunk-MDTA25AN.mjs';export{j as TABLE_DATA_ATTRIBUTES,p as createSelectionFromDOM,e as formatLastSaveTime,h as formatStorageSize,f as getAutoSaveStatusLabel,g as getAutoSaveStorageSize,o as getSelectionRuns,i as isAutoSaveSupported}from'./chunk-MDTA25AN.mjs';import'./chunk-XGJ2EORY.mjs';import'./chunk-WOHFANC5.mjs';import'./chunk-XQZTWWRF.mjs';import'./chunk-B7CCL7SL.mjs';import {g as g$2,k,h,j}from'./chunk-ONIYA2FU.mjs';import'./chunk-FWPVBFKQ.mjs';import'./chunk-TZMMD6RR.mjs';import'./chunk-TAUMSKRE.mjs';import he,{useState,useRef,useCallback,useEffect,useMemo,useSyncExternalStore}from'react';function ve(n){let{containerRef:e$1,enabled:r=true,config:s=a,useOverlay:c$1=false,debounceMs:u=16,onSelectionChange:f$1}=n,[S,p]=useState(false),[x,v]=useState(""),[a$1,m]=useState([]),[d$1,y]=useState(false),h=useRef(null),C=useRef(0),o=useCallback(()=>{let t=e$1.current,b$1=c(),D=d(),U=t?e(t):false;if(p(b$1),v(D),y(U),c$1&&U){let ae=b(t);m(ae);}else m([]);f$1&&f$1(b$1&&U,D);},[e$1,c$1,f$1]),i=useCallback(()=>{let t=performance.now();if(t-C.current<u){h.current!==null&&clearTimeout(h.current),h.current=window.setTimeout(()=>{C.current=performance.now(),o(),h.current=null;},u);return}C.current=t,o();},[u,o]),l=useCallback(()=>{o();},[o]),R=useCallback(t=>({position:"absolute",left:`${t.left}px`,top:`${t.top}px`,width:`${t.width}px`,height:`${t.height}px`,backgroundColor:s.backgroundColor,borderRadius:s.borderRadius?`${s.borderRadius}px`:void 0,border:s.borderColor?`1px solid ${s.borderColor}`:void 0,zIndex:s.zIndex??0,opacity:s.opacity??1,mixBlendMode:s.mixBlendMode,pointerEvents:"none",userSelect:"none"}),[s]);return useEffect(()=>(r&&!g$1()&&f(s),()=>{}),[r,s]),useEffect(()=>{if(!r)return;let t=()=>{i();};return document.addEventListener("selectionchange",t),document.addEventListener("mouseup",t),o(),()=>{document.removeEventListener("selectionchange",t),document.removeEventListener("mouseup",t),h.current!==null&&clearTimeout(h.current);}},[r,i,o]),{hasSelection:S,selectedText:x,highlightRects:a$1,isSelectionInContainer:d$1,refresh:l,getOverlayStyle:R}}function ge(n,e=a){return n.map((r,s)=>he.createElement("div",{key:`selection-overlay-${s}`,style:{position:"absolute",left:`${r.left}px`,top:`${r.top}px`,width:`${r.width}px`,height:`${r.height}px`,backgroundColor:e.backgroundColor,borderRadius:e.borderRadius?`${e.borderRadius}px`:void 0,border:e.borderColor?`1px solid ${e.borderColor}`:void 0,zIndex:e.zIndex??0,opacity:e.opacity??1,mixBlendMode:e.mixBlendMode,pointerEvents:"none",userSelect:"none"}}))}function xe(n={}){let{onCopy:e,onCut:r,onPaste:s,cleanWordFormatting:c=true,editable:u=true,onError:f,theme:S}=n,p$1=useRef(false),x=useRef(null),v=useCallback(async o=>{if(p$1.current)return false;p$1.current=true;try{let i=await g$2(o.runs,{onError:f,theme:S});return i&&e?.(o),i}finally{p$1.current=false;}},[e,f,S]),a=useCallback(async o=>{if(p$1.current||!u)return false;p$1.current=true;try{let i=await g$2(o.runs,{onError:f,theme:S});return i&&r?.(o),i}finally{p$1.current=false;}},[r,u,f,S]),m=useCallback(async(o=false)=>{if(p$1.current||!u)return null;p$1.current=true;try{if(navigator.clipboard&&navigator.clipboard.read){let i=await navigator.clipboard.read(),l="",R="";for(let b of i)b.types.includes("text/html")&&(l=await(await b.getType("text/html")).text()),b.types.includes("text/plain")&&(R=await(await b.getType("text/plain")).text());o&&(l="");let t=k(l,R,c);return x.current=t,s?.(t,o),t}return null}catch(i){return f?.(i),null}finally{p$1.current=false;}},[u,c,s,f]),d=useCallback(o=>{let i=p();if(!i)return;o.preventDefault();let l=h(i.runs,true,S);o.clipboardData&&(o.clipboardData.setData("text/plain",l.plainText),o.clipboardData.setData("text/html",l.html),l.internal&&o.clipboardData.setData("application/x-docx-editor",l.internal)),e?.(i);},[e,S]),y=useCallback(o=>{if(!u)return;let i=p();if(!i)return;o.preventDefault();let l=h(i.runs,true,S);o.clipboardData&&(o.clipboardData.setData("text/plain",l.plainText),o.clipboardData.setData("text/html",l.html),l.internal&&o.clipboardData.setData("application/x-docx-editor",l.internal)),r?.(i);},[u,r,S]),h$1=useCallback(o=>{if(!u)return;o.preventDefault();let i=j(o,{cleanWordFormatting:c});if(i){x.current=i;let l=o.shiftKey??false;s?.(i,l);}},[u,c,s]),C=useCallback(o=>{},[]);return {copy:v,cut:a,paste:m,handleCopy:d,handleCut:y,handlePaste:h$1,handleKeyDown:C,isProcessing:p$1.current,lastPastedContent:x.current}}function Re(n,e={}){let{storageKey:r,interval:s,enabled:c=true,maxAge:u,onSave:f,onError:S,onRecoveryAvailable:p,saveOnChange:x,debounceDelay:v}=e,a=useMemo(()=>new d$1({storageKey:r,interval:s,maxAge:u,saveOnChange:x,debounceDelay:v,onSave:f,onError:S,onRecoveryAvailable:p}),[r]);useEffect(()=>{c?(a.enable(),a.startInterval()):a.disable();},[a,c]),useEffect(()=>{a.onDocumentChanged(n??null);},[a,n]),useEffect(()=>()=>{a.destroy();},[a]);let m=useSyncExternalStore(a.subscribe,a.getSnapshot),d=useCallback(()=>a.save(),[a]),y=useCallback(()=>a.clear(),[a]),h=useCallback(()=>a.getRecoveryData(),[a]),C=useCallback(()=>a.acceptRecovery(),[a]),o=useCallback(()=>a.dismissRecovery(),[a]),i=useCallback(()=>a.enable(),[a]),l=useCallback(()=>a.disable(),[a]);return {status:m.status,lastSaveTime:m.lastSaveTime,save:d,clearAutoSave:y,hasRecoveryData:m.hasRecoveryData,getRecoveryData:h,acceptRecovery:C,dismissRecovery:o,isEnabled:m.isEnabled,enable:i,disable:l}}var Oe=1,te=.25,oe=4,Pe=.1,g=[.25,.5,.75,1,1.25,1.5,2,3,4];function ne(n,e,r){return Math.max(e,Math.min(r,n))}function re(n){return Math.round(n*100)/100}function Ze(n){let e=g[0],r=Math.abs(n-e);for(let s of g){let c=Math.abs(n-s);c<r&&(r=c,e=s);}return e}function Te(n){for(let e of g)if(e>n+.01)return e;return g[g.length-1]}function Ae(n){for(let e=g.length-1;e>=0;e--)if(g[e]<n-.01)return g[e];return g[0]}function Ue(n={}){let{initialZoom:e=Oe,minZoom:r=te,maxZoom:s=oe,zoomStep:c=Pe,enabled:u=true,containerRef:f,onZoomChange:S,enableKeyboardShortcuts:p=true,preventDefault:x=true}=n,[v,a]=useState(e),m=useRef(v);useEffect(()=>{m.current=v;},[v]);let d=useCallback(t=>{let b=re(ne(t,r,s));b!==m.current&&(a(b),S?.(b));},[r,s,S]),y=useCallback(()=>{d(m.current+c);},[c,d]),h=useCallback(()=>{d(m.current-c);},[c,d]),C=useCallback(()=>{d(e);},[e,d]),o=useCallback(()=>{d(1);},[d]),i=useCallback((t,b)=>{if(b>0){let D=t/b;d(D);}},[d]),l=useCallback(t=>{if(!u||!(t.ctrlKey||t.metaKey))return;x&&t.preventDefault();let D=t.deltaY;D<0?d(m.current+c):D>0&&d(m.current-c);},[u,x,c,d]),R=useCallback(t=>{if(!(!u||!p||!(t.ctrlKey||t.metaKey))){if(t.key==="0"){t.preventDefault(),o();return}if(t.key==="+"||t.key==="="){t.preventDefault(),y();return}if(t.key==="-"){t.preventDefault(),h();return}}},[u,p,y,h,o]);return useEffect(()=>{if(!u)return;let t=f?.current;if(t)return t.addEventListener("wheel",l,{passive:false}),()=>{t.removeEventListener("wheel",l);}},[u,f,l]),useEffect(()=>{if(!(!u||!p))return document.addEventListener("keydown",R),()=>{document.removeEventListener("keydown",R);}},[u,p,R]),{zoom:v,setZoom:d,zoomIn:y,zoomOut:h,resetZoom:C,zoomTo100:o,zoomToFit:i,isMinZoom:v<=r,isMaxZoom:v>=s,zoomPercent:Math.round(v*100),handleWheel:l,handleKeyDown:R}}function Me(){return [...g]}function He(n){return Ze(n)}function we(n){return Te(n)}function Le(n){return Ae(n)}function ze(n){return `${Math.round(n*100)}%`}function Fe(n){let e=n.match(/(\d+(\.\d+)?)/);if(e){let r=parseFloat(e[1]);if(!isNaN(r))return r/100}return null}function ke(n){return g.some(e=>Math.abs(e-n)<.01)}function Ie(n,e=te,r=oe){return re(ne(n,e,r))}export{g as ZOOM_PRESETS,Ie as clampZoom,He as findNearestZoomPreset,ze as formatZoom,ge as generateOverlayElements,we as getNextZoomPreset,Le as getPreviousZoomPreset,Me as getZoomPresets,ke as isZoomPreset,Fe as parseZoom,Re as useAutoSave,xe as useClipboard,ve as useSelectionHighlight,Ue as useWheelZoom};