@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,415 @@
1
+ import React__default, { CSSProperties } from 'react';
2
+ import { FindOptions, FindResult, FindMatch } from '@zeke-02/docx-editor-core/utils/findReplace';
3
+ import { ParsedClipboardContent } from '@zeke-02/docx-editor-core/utils';
4
+ import { TranslationKey } from '@eigenpal/docx-editor-i18n';
5
+
6
+ /**
7
+ * Find and Replace Dialog Component
8
+ *
9
+ * Modal dialog for searching and replacing text in the document.
10
+ * Supports find, find next/previous, replace, and replace all operations.
11
+ *
12
+ * Logic and utilities are in separate files:
13
+ * - findReplaceUtils.ts — Pure search/replace functions and types
14
+ * - useFindReplace.ts — React hook for dialog state management
15
+ */
16
+
17
+ /**
18
+ * Props for the FindReplaceDialog component
19
+ */
20
+ interface FindReplaceDialogProps {
21
+ /** Whether the dialog is open */
22
+ isOpen: boolean;
23
+ /** Callback when dialog is closed */
24
+ onClose: () => void;
25
+ /** Callback when searching for text */
26
+ onFind: (searchText: string, options: FindOptions) => FindResult | null;
27
+ /** Callback when navigating to next match */
28
+ onFindNext: () => FindMatch | null;
29
+ /** Callback when navigating to previous match */
30
+ onFindPrevious: () => FindMatch | null;
31
+ /** Callback when replacing current match */
32
+ onReplace: (replaceText: string) => boolean;
33
+ /** Callback when replacing all matches */
34
+ onReplaceAll: (searchText: string, replaceText: string, options: FindOptions) => number;
35
+ /** Callback to highlight matches in document */
36
+ onHighlightMatches?: (matches: FindMatch[]) => void;
37
+ /** Callback to clear highlights */
38
+ onClearHighlights?: () => void;
39
+ /** Initial search text (e.g., from selected text) */
40
+ initialSearchText?: string;
41
+ /** Whether to start in replace mode */
42
+ replaceMode?: boolean;
43
+ /** Current match result (from external state) */
44
+ currentResult?: FindResult | null;
45
+ /** Additional CSS class */
46
+ className?: string;
47
+ /** Additional inline styles */
48
+ style?: CSSProperties;
49
+ }
50
+ /**
51
+ * FindReplaceDialog component - Modal for finding and replacing text
52
+ */
53
+ declare function FindReplaceDialog({ isOpen, onClose, onFind, onFindNext, onFindPrevious, onReplace, onReplaceAll, onHighlightMatches, onClearHighlights, initialSearchText, replaceMode, currentResult, className, style, }: FindReplaceDialogProps): React__default.ReactElement | null;
54
+
55
+ /**
56
+ * Hyperlink Dialog Component
57
+ *
58
+ * Modal dialog for inserting and editing hyperlinks in the document.
59
+ * Supports both external URLs and internal bookmark links.
60
+ *
61
+ * Features:
62
+ * - Input for URL (http, https, mailto, tel, etc.)
63
+ * - Input for display text
64
+ * - Edit existing hyperlinks
65
+ * - Remove hyperlink option
66
+ * - Internal bookmark selection
67
+ * - Validation and error handling
68
+ */
69
+
70
+ /**
71
+ * Hyperlink data structure for dialog
72
+ */
73
+ interface HyperlinkData {
74
+ /** URL for external link */
75
+ url?: string;
76
+ /** Display text for the link */
77
+ displayText?: string;
78
+ /** Internal bookmark name */
79
+ bookmark?: string;
80
+ /** Tooltip text */
81
+ tooltip?: string;
82
+ }
83
+ /**
84
+ * Bookmark option for internal link selection
85
+ */
86
+ interface BookmarkOption {
87
+ /** Bookmark name/ID */
88
+ name: string;
89
+ /** Optional display label */
90
+ label?: string;
91
+ }
92
+ /**
93
+ * Props for the HyperlinkDialog component
94
+ */
95
+ interface HyperlinkDialogProps {
96
+ /** Whether the dialog is open */
97
+ isOpen: boolean;
98
+ /** Callback when dialog is closed */
99
+ onClose: () => void;
100
+ /** Callback when hyperlink is inserted/updated */
101
+ onSubmit: (data: HyperlinkData) => void;
102
+ /** Callback when hyperlink is removed */
103
+ onRemove?: () => void;
104
+ /** Initial data for editing existing hyperlink */
105
+ initialData?: HyperlinkData;
106
+ /** Currently selected text (used as default display text) */
107
+ selectedText?: string;
108
+ /** Whether we're editing an existing hyperlink */
109
+ isEditing?: boolean;
110
+ /** Available bookmarks for internal links */
111
+ bookmarks?: BookmarkOption[];
112
+ /** Additional CSS class */
113
+ className?: string;
114
+ /** Additional inline styles */
115
+ style?: CSSProperties;
116
+ }
117
+ /**
118
+ * Validate a URL string
119
+ * Supports http, https, mailto, tel, ftp protocols
120
+ */
121
+ declare function isValidUrl(url: string): boolean;
122
+ /**
123
+ * Normalize a URL by adding protocol if needed
124
+ */
125
+ declare function normalizeUrl(url: string): string;
126
+ /**
127
+ * Detect URL type from string
128
+ */
129
+ declare function getUrlType(url: string): 'web' | 'email' | 'phone' | 'ftp' | 'unknown';
130
+ /**
131
+ * HyperlinkDialog component - Modal for inserting/editing hyperlinks
132
+ */
133
+ declare function HyperlinkDialog({ isOpen, onClose, onSubmit, onRemove, initialData, selectedText, isEditing, bookmarks, className, style, }: HyperlinkDialogProps): React__default.ReactElement | null;
134
+ /**
135
+ * Create HyperlinkData from a URL string
136
+ */
137
+ declare function createHyperlinkData(url: string, displayText?: string): HyperlinkData;
138
+ /**
139
+ * Create HyperlinkData for an internal bookmark
140
+ */
141
+ declare function createBookmarkLinkData(bookmark: string, displayText?: string): HyperlinkData;
142
+ /**
143
+ * Check if HyperlinkData is for an external URL
144
+ */
145
+ declare function isExternalHyperlinkData(data: HyperlinkData): boolean;
146
+ /**
147
+ * Check if HyperlinkData is for an internal bookmark
148
+ */
149
+ declare function isBookmarkHyperlinkData(data: HyperlinkData): boolean;
150
+ /**
151
+ * Get display text from HyperlinkData, falling back to URL/bookmark
152
+ */
153
+ declare function getDisplayText(data: HyperlinkData): string;
154
+ /**
155
+ * Convert email address to mailto: link
156
+ */
157
+ declare function emailToMailto(email: string): string;
158
+ /**
159
+ * Convert phone number to tel: link
160
+ */
161
+ declare function phoneToTel(phone: string): string;
162
+ /**
163
+ * Extract bookmarks from document for the dialog
164
+ */
165
+ declare function extractBookmarksForDialog(bookmarks: {
166
+ name: string;
167
+ id: number;
168
+ }[]): BookmarkOption[];
169
+ /**
170
+ * Hook state for the Hyperlink dialog
171
+ */
172
+ interface UseHyperlinkDialogState {
173
+ /** Whether the dialog is open */
174
+ isOpen: boolean;
175
+ /** Initial data for the dialog (for editing) */
176
+ initialData?: HyperlinkData;
177
+ /** Currently selected text */
178
+ selectedText?: string;
179
+ /** Whether we're editing an existing hyperlink */
180
+ isEditing: boolean;
181
+ }
182
+ /**
183
+ * Hook return type for the Hyperlink dialog
184
+ */
185
+ interface UseHyperlinkDialogReturn {
186
+ /** Current state */
187
+ state: UseHyperlinkDialogState;
188
+ /** Open dialog for inserting new hyperlink */
189
+ openInsert: (selectedText?: string) => void;
190
+ /** Open dialog for editing existing hyperlink */
191
+ openEdit: (data: HyperlinkData) => void;
192
+ /** Close the dialog */
193
+ close: () => void;
194
+ /** Toggle dialog open/closed */
195
+ toggle: () => void;
196
+ }
197
+ /**
198
+ * Hook for managing Hyperlink dialog state
199
+ */
200
+ declare function useHyperlinkDialog(): UseHyperlinkDialogReturn;
201
+
202
+ /**
203
+ * Paste Special Dialog Component
204
+ *
205
+ * Provides paste options for pasting content with or without formatting.
206
+ * Features:
207
+ * - Paste with formatting (default)
208
+ * - Paste as plain text (unformatted)
209
+ * - Keyboard shortcut: Ctrl+Shift+V opens dialog
210
+ */
211
+
212
+ /**
213
+ * Paste option type
214
+ */
215
+ type PasteOption = 'formatted' | 'plainText';
216
+ /**
217
+ * Paste special dialog props
218
+ */
219
+ interface PasteSpecialDialogProps {
220
+ /** Whether the dialog is open */
221
+ isOpen: boolean;
222
+ /** Callback when dialog is closed */
223
+ onClose: () => void;
224
+ /** Callback when paste is confirmed */
225
+ onPaste: (content: ParsedClipboardContent, asPlainText: boolean) => void;
226
+ /** Optional custom position */
227
+ position?: {
228
+ x: number;
229
+ y: number;
230
+ };
231
+ /** Additional className */
232
+ className?: string;
233
+ }
234
+ /**
235
+ * Paste option definition with translation keys
236
+ */
237
+ interface PasteOptionDef {
238
+ id: PasteOption;
239
+ labelKey: TranslationKey;
240
+ descriptionKey: TranslationKey;
241
+ shortcutKey: TranslationKey;
242
+ }
243
+ /**
244
+ * Hook return value for paste special
245
+ */
246
+ interface UsePasteSpecialReturn {
247
+ /** Whether the dialog is open */
248
+ isOpen: boolean;
249
+ /** Open the paste special dialog */
250
+ openDialog: () => void;
251
+ /** Close the dialog */
252
+ closeDialog: () => void;
253
+ /** Handle keyboard shortcut (Ctrl+Shift+V) */
254
+ handleKeyDown: (event: KeyboardEvent) => boolean;
255
+ /** Paste as plain text directly */
256
+ pasteAsPlainText: () => Promise<void>;
257
+ }
258
+ /**
259
+ * Options for usePasteSpecial hook
260
+ */
261
+ interface UsePasteSpecialOptions {
262
+ /** Callback when paste is confirmed */
263
+ onPaste?: (content: ParsedClipboardContent, asPlainText: boolean) => void;
264
+ /** Whether paste operations are enabled */
265
+ enabled?: boolean;
266
+ }
267
+ declare const PasteSpecialDialog: React__default.FC<PasteSpecialDialogProps>;
268
+ /**
269
+ * Hook to manage paste special dialog
270
+ */
271
+ declare function usePasteSpecial(options?: UsePasteSpecialOptions): UsePasteSpecialReturn;
272
+ /**
273
+ * Get paste option definition by id
274
+ */
275
+ declare function getPasteOption(id: PasteOption): PasteOptionDef | undefined;
276
+ /**
277
+ * Get all paste option definitions
278
+ */
279
+ declare function getAllPasteOptions(): PasteOptionDef[];
280
+ /**
281
+ * Get default paste option
282
+ */
283
+ declare function getDefaultPasteOption(): PasteOption;
284
+ /**
285
+ * Check if paste special shortcut
286
+ */
287
+ declare function isPasteSpecialShortcut(event: KeyboardEvent): boolean;
288
+
289
+ /**
290
+ * Keyboard-shortcut catalog — categorized list of every shortcut surfaced
291
+ * in the KeyboardShortcutsDialog, plus the lookup helpers that filter and
292
+ * label them.
293
+ */
294
+
295
+ /**
296
+ * Get all default shortcuts
297
+ */
298
+ declare function getDefaultShortcuts(): KeyboardShortcut[];
299
+ /**
300
+ * Get shortcuts by category
301
+ */
302
+ declare function getShortcutsByCategory(category: ShortcutCategory): KeyboardShortcut[];
303
+ /**
304
+ * Get common/frequently used shortcuts
305
+ */
306
+ declare function getCommonShortcuts(): KeyboardShortcut[];
307
+ /**
308
+ * Get category label translation key
309
+ */
310
+ declare function getCategoryLabel(category: ShortcutCategory): string;
311
+ /**
312
+ * Get all categories
313
+ */
314
+ declare function getAllCategories(): ShortcutCategory[];
315
+
316
+ /**
317
+ * Single-row renderer for a keyboard shortcut inside the dialog, plus the
318
+ * platform-aware key formatter (Ctrl→⌘ on Mac). The formatter is exposed
319
+ * as `formatShortcutKeys` for callers that render kbd badges outside the
320
+ * dialog.
321
+ */
322
+
323
+ /**
324
+ * Format key combination for current platform
325
+ */
326
+ declare function formatKeys(keys: string): string;
327
+
328
+ /**
329
+ * Keyboard Shortcuts Dialog Component
330
+ *
331
+ * Displays all available keyboard shortcuts organized by category.
332
+ * Features:
333
+ * - Categorized shortcut list
334
+ * - Search/filter functionality
335
+ * - Platform-aware modifier keys (Ctrl/Cmd)
336
+ * - Keyboard shortcut to open (Ctrl+/)
337
+ *
338
+ * The shortcut catalog and category metadata live in
339
+ * `KeyboardShortcutsDialog/data.ts`. The per-row renderer and the
340
+ * platform-aware key formatter live in `KeyboardShortcutsDialog/ShortcutItem.tsx`.
341
+ */
342
+
343
+ /**
344
+ * Keyboard shortcut definition
345
+ */
346
+ interface KeyboardShortcut {
347
+ /** Unique identifier */
348
+ id: string;
349
+ /** Display name */
350
+ name: string;
351
+ /** Description of what the shortcut does */
352
+ description: string;
353
+ /** Primary key combination (e.g., 'Ctrl+C') */
354
+ keys: string;
355
+ /** Alternative key combination */
356
+ altKeys?: string;
357
+ /** Category for grouping */
358
+ category: ShortcutCategory;
359
+ /** Whether this is a common/frequently used shortcut */
360
+ common?: boolean;
361
+ /** Translation key for display name (used internally) */
362
+ nameKey?: TranslationKey;
363
+ /** Translation key for description (used internally) */
364
+ descriptionKey?: TranslationKey;
365
+ }
366
+ /**
367
+ * Shortcut category
368
+ */
369
+ type ShortcutCategory = 'editing' | 'formatting' | 'navigation' | 'clipboard' | 'selection' | 'view' | 'file' | 'other';
370
+ /**
371
+ * Dialog props
372
+ */
373
+ interface KeyboardShortcutsDialogProps {
374
+ /** Whether the dialog is open */
375
+ isOpen: boolean;
376
+ /** Close callback */
377
+ onClose: () => void;
378
+ /** Custom shortcuts (merged with defaults) */
379
+ customShortcuts?: KeyboardShortcut[];
380
+ /** Whether to show search */
381
+ showSearch?: boolean;
382
+ /** Additional className */
383
+ className?: string;
384
+ }
385
+ /**
386
+ * Hook options
387
+ */
388
+ interface UseKeyboardShortcutsDialogOptions {
389
+ /** Whether the dialog can be opened with Ctrl+? or F1 */
390
+ enabled?: boolean;
391
+ /** Custom open shortcut (default: Ctrl+/) */
392
+ openShortcut?: string;
393
+ }
394
+ /**
395
+ * Hook return value
396
+ */
397
+ interface UseKeyboardShortcutsDialogReturn {
398
+ /** Whether dialog is open */
399
+ isOpen: boolean;
400
+ /** Open the dialog */
401
+ open: () => void;
402
+ /** Close the dialog */
403
+ close: () => void;
404
+ /** Toggle the dialog */
405
+ toggle: () => void;
406
+ /** Keyboard event handler */
407
+ handleKeyDown: (event: KeyboardEvent) => void;
408
+ }
409
+ declare const KeyboardShortcutsDialog: React__default.FC<KeyboardShortcutsDialogProps>;
410
+ /**
411
+ * Hook to manage keyboard shortcuts dialog
412
+ */
413
+ declare function useKeyboardShortcutsDialog(options?: UseKeyboardShortcutsDialogOptions): UseKeyboardShortcutsDialogReturn;
414
+
415
+ export { extractBookmarksForDialog as A, type BookmarkOption as B, getDisplayText as C, getUrlType as D, isBookmarkHyperlinkData as E, FindReplaceDialog as F, isExternalHyperlinkData as G, type HyperlinkData as H, isValidUrl as I, normalizeUrl as J, type KeyboardShortcut as K, phoneToTel as L, type PasteOption as P, type ShortcutCategory as S, type UseKeyboardShortcutsDialogOptions as U, type FindReplaceDialogProps as a, HyperlinkDialog as b, type HyperlinkDialogProps as c, KeyboardShortcutsDialog as d, type KeyboardShortcutsDialogProps as e, PasteSpecialDialog as f, type PasteSpecialDialogProps as g, type UseKeyboardShortcutsDialogReturn as h, type UsePasteSpecialOptions as i, type UsePasteSpecialReturn as j, formatKeys as k, getAllCategories as l, getAllPasteOptions as m, getCategoryLabel as n, getCommonShortcuts as o, getDefaultPasteOption as p, getDefaultShortcuts as q, getPasteOption as r, getShortcutsByCategory as s, isPasteSpecialShortcut as t, useHyperlinkDialog as u, useKeyboardShortcutsDialog as v, usePasteSpecial as w, createBookmarkLinkData as x, createHyperlinkData as y, emailToMailto as z };