@eigenpal/docx-js-editor 0.0.12 → 0.0.14

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 (115) hide show
  1. package/README.md +0 -3
  2. package/dist/DocumentAgent-Ci6_T-XM.d.ts +412 -0
  3. package/dist/DocumentAgent-DEGFgYEN.d.cts +412 -0
  4. package/dist/FindReplaceDialog-46BE7Q2G.cjs +1 -0
  5. package/dist/FindReplaceDialog-UMXCBBST.js +1 -0
  6. package/dist/FootnotePropertiesDialog-OBQXOBJE.cjs +1 -0
  7. package/dist/FootnotePropertiesDialog-TYQGPWPX.js +1 -0
  8. package/dist/HyperlinkDialog-22NH7ZLP.cjs +1 -0
  9. package/dist/HyperlinkDialog-UOERZIBM.js +1 -0
  10. package/dist/ImagePositionDialog-52FDANUK.js +1 -0
  11. package/dist/ImagePositionDialog-ZK5WFBRC.cjs +1 -0
  12. package/dist/ImagePropertiesDialog-LU44RDIY.cjs +1 -0
  13. package/dist/ImagePropertiesDialog-YPSLPSF6.js +1 -0
  14. package/dist/TablePropertiesDialog-KMOYHPGF.cjs +1 -0
  15. package/dist/TablePropertiesDialog-OUUJAA7D.js +1 -0
  16. package/dist/{types-BALm1KBi.d.cts → agentApi-CbVUCZRu.d.cts} +1 -308
  17. package/dist/{types-BALm1KBi.d.ts → agentApi-CbVUCZRu.d.ts} +1 -308
  18. package/dist/chunk-2ASOEN3V.js +1 -0
  19. package/dist/chunk-3VOXZKGT.js +2 -0
  20. package/dist/{chunk-P332HWDE.js → chunk-5MWH4N7I.js} +5 -5
  21. package/dist/chunk-5WBRHVOE.js +258 -0
  22. package/dist/chunk-6YFGCUHU.js +4 -0
  23. package/dist/chunk-7H2HP242.js +58 -0
  24. package/dist/chunk-CTYOM6BE.js +2 -0
  25. package/dist/chunk-EMKABJPH.js +1 -0
  26. package/dist/chunk-ESI4BSBF.js +1 -0
  27. package/dist/{chunk-A7VY2V4X.cjs → chunk-FYAWM7MP.cjs} +1 -1
  28. package/dist/{chunk-GIZ5CTBD.cjs → chunk-IHZIA6JP.cjs} +5 -5
  29. package/dist/chunk-ITWEFKGQ.cjs +1 -0
  30. package/dist/chunk-JGPRSZPI.cjs +2 -0
  31. package/dist/chunk-JS7TPZTF.cjs +10 -0
  32. package/dist/chunk-KESNGXGO.js +1 -0
  33. package/dist/chunk-L34XFLQZ.cjs +1 -0
  34. package/dist/chunk-L7UKJGRK.js +10 -0
  35. package/dist/chunk-MLSHZVL7.js +111 -0
  36. package/dist/chunk-NT2REEAA.cjs +1 -0
  37. package/dist/chunk-O7QVCJN6.cjs +4 -0
  38. package/dist/chunk-OEOUMSWH.cjs +111 -0
  39. package/dist/chunk-OW5H5DNE.cjs +1 -0
  40. package/dist/chunk-OWMXCVKB.js +1 -0
  41. package/dist/chunk-PJVI53AH.js +2 -0
  42. package/dist/{chunk-XVFMG77A.cjs → chunk-PXC7ARQB.cjs} +1 -1
  43. package/dist/chunk-QVVLXLRZ.cjs +258 -0
  44. package/dist/{chunk-QHWHCIUW.js → chunk-R5SKERM2.js} +1 -1
  45. package/dist/chunk-SF53KLDZ.cjs +1 -0
  46. package/dist/chunk-TOI5W3HK.js +8 -0
  47. package/dist/chunk-UAME5JHZ.cjs +58 -0
  48. package/dist/chunk-UAVOWAIF.cjs +8 -0
  49. package/dist/chunk-VOWKSURW.cjs +1 -0
  50. package/dist/chunk-VTAS7VZ6.cjs +2 -0
  51. package/dist/{chunk-MMJD2DLL.js → chunk-WFWLPKQA.js} +1 -1
  52. package/dist/chunk-XS2AQFMF.cjs +2 -0
  53. package/dist/chunk-ZDYHAYN6.js +1 -0
  54. package/dist/clipboard-BOocwmAM.d.ts +539 -0
  55. package/dist/clipboard-Cx7cb3kX.d.cts +539 -0
  56. package/dist/{colorResolver-BNj-uZ58.d.ts → colorResolver-CIDiSPWd.d.cts} +3 -411
  57. package/dist/{colorResolver-DiMquGWR.d.cts → colorResolver-KXbUgzWC.d.ts} +3 -411
  58. package/dist/core-plugins.cjs +1 -1
  59. package/dist/core-plugins.d.cts +11 -7
  60. package/dist/core-plugins.d.ts +11 -7
  61. package/dist/core-plugins.js +1 -1
  62. package/dist/core.cjs +1 -0
  63. package/dist/core.d.cts +23 -0
  64. package/dist/core.d.ts +23 -0
  65. package/dist/core.js +1 -0
  66. package/dist/executor-ITYZTNSH.cjs +1 -0
  67. package/dist/executor-TC7CLATE.js +1 -0
  68. package/dist/headless.cjs +2 -2
  69. package/dist/headless.d.cts +8 -175
  70. package/dist/headless.d.ts +8 -175
  71. package/dist/headless.js +1 -1
  72. package/dist/index.cjs +9 -378
  73. package/dist/index.d.cts +17 -4161
  74. package/dist/index.d.ts +17 -4161
  75. package/dist/index.js +9 -378
  76. package/dist/insertOperations-CzB5b-Of.d.ts +176 -0
  77. package/dist/insertOperations-DKVmCV32.d.cts +176 -0
  78. package/dist/mcp-cli.js +21 -21
  79. package/dist/mcp.cjs +10 -10
  80. package/dist/mcp.d.cts +2 -1
  81. package/dist/mcp.d.ts +2 -1
  82. package/dist/mcp.js +9 -9
  83. package/dist/processTemplate-525HZL4S.cjs +1 -0
  84. package/dist/processTemplate-RJN6452W.js +1 -0
  85. package/dist/react-BZxD04XV.d.ts +1350 -0
  86. package/dist/react-D8eAYckC.d.cts +1350 -0
  87. package/dist/react.cjs +1 -0
  88. package/dist/react.css +1 -0
  89. package/dist/react.d.cts +9 -0
  90. package/dist/react.d.ts +9 -0
  91. package/dist/react.js +1 -0
  92. package/dist/{registry-CzqAPdui.d.ts → registry-D4tvj9f3.d.ts} +1 -1
  93. package/dist/{registry-BUTMLqSj.d.cts → registry-ngv6Bumt.d.cts} +1 -1
  94. package/dist/{selectionRects-LO3FJT47.js → selectionRects-42JURU6D.js} +1 -1
  95. package/dist/{selectionRects-I5JVL73G.cjs → selectionRects-XGMQBMC5.cjs} +1 -1
  96. package/dist/styles.css +1 -1
  97. package/dist/types-D96elyJF.d.cts +310 -0
  98. package/dist/types-xMzSPT4i.d.ts +310 -0
  99. package/dist/ui.cjs +1 -0
  100. package/dist/ui.d.cts +2051 -0
  101. package/dist/ui.d.ts +2051 -0
  102. package/dist/ui.js +1 -0
  103. package/dist/variableDetector-CPxKo9jP.d.cts +173 -0
  104. package/dist/variableDetector-DeM1N-_L.d.ts +173 -0
  105. package/package.json +85 -11
  106. package/dist/chunk-3IYNTJO5.js +0 -1
  107. package/dist/chunk-56AGRHVO.cjs +0 -58
  108. package/dist/chunk-E23CAQXT.js +0 -9
  109. package/dist/chunk-HIBC7HTU.cjs +0 -9
  110. package/dist/chunk-ICEPOA7G.js +0 -58
  111. package/dist/chunk-IZGUXSCC.js +0 -10
  112. package/dist/chunk-RTESADL3.cjs +0 -1
  113. package/dist/chunk-XF3IPO7C.cjs +0 -10
  114. package/dist/executor-44OB3DFD.js +0 -1
  115. package/dist/executor-U3BZPPGN.cjs +0 -1
@@ -0,0 +1,1350 @@
1
+ import * as React$1 from 'react';
2
+ import React__default, { ReactNode, CSSProperties, Component, ErrorInfo } from 'react';
3
+ import * as prosemirror_view from 'prosemirror-view';
4
+ import { EditorView } from 'prosemirror-view';
5
+ import * as prosemirror_state from 'prosemirror-state';
6
+ import { Plugin, EditorState, Transaction } from 'prosemirror-state';
7
+ import { X as TextFormatting, u as ParagraphFormatting, h as Document, Y as Theme, T as Table, y as Run } from './agentApi-CbVUCZRu.cjs';
8
+ import { P as PageIndicatorPosition, e as PageNavigatorPosition, c as PageIndicatorVariant, g as PageNavigatorVariant, m as PrintOptions, o as TableContext, T as TableAction, j as ParsedClipboardContent } from './clipboard-Cx7cb3kX.cjs';
9
+ import { a as DocxInput, D as DocumentAgent } from './DocumentAgent-DEGFgYEN.cjs';
10
+ import { Node as Node$1 } from 'prosemirror-model';
11
+ import * as react_jsx_runtime from 'react/jsx-runtime';
12
+
13
+ /**
14
+ * Selection State Utilities
15
+ *
16
+ * Extracts selection state from ProseMirror for toolbar integration.
17
+ */
18
+
19
+ /**
20
+ * Selection state for toolbar integration
21
+ */
22
+ interface SelectionState {
23
+ /** Whether there's an active selection (not just cursor) */
24
+ hasSelection: boolean;
25
+ /** Whether selection spans multiple paragraphs */
26
+ isMultiParagraph: boolean;
27
+ /** Current text formatting at selection/cursor */
28
+ textFormatting: TextFormatting;
29
+ /** Current paragraph formatting */
30
+ paragraphFormatting: ParagraphFormatting;
31
+ /** Current paragraph style ID (e.g., 'Heading1', 'Normal') */
32
+ styleId: string | null;
33
+ /** Start paragraph index */
34
+ startParagraphIndex: number;
35
+ /** End paragraph index */
36
+ endParagraphIndex: number;
37
+ }
38
+
39
+ /**
40
+ * Layout Engine Types
41
+ *
42
+ * Core types for the paginated layout engine.
43
+ * Converts document blocks + measurements into positioned fragments on pages.
44
+ */
45
+ /**
46
+ * Unique identifier for a block in the document.
47
+ * Format: typically `${index}-${type}` or just the block index.
48
+ */
49
+ type BlockId = string | number;
50
+ /**
51
+ * Base fragment properties common to all fragment types.
52
+ */
53
+ type FragmentBase = {
54
+ /** Block ID this fragment belongs to. */
55
+ blockId: BlockId;
56
+ /** X position on page (relative to page left). */
57
+ x: number;
58
+ /** Y position on page (relative to page top). */
59
+ y: number;
60
+ /** Width of the fragment. */
61
+ width: number;
62
+ /** ProseMirror start position (for click mapping). */
63
+ pmStart?: number;
64
+ /** ProseMirror end position (for click mapping). */
65
+ pmEnd?: number;
66
+ };
67
+ /**
68
+ * A paragraph fragment positioned on a page.
69
+ * May span only part of the paragraph's lines if split across pages.
70
+ */
71
+ type ParagraphFragment = FragmentBase & {
72
+ kind: 'paragraph';
73
+ /** First line index (inclusive) from the measure. */
74
+ fromLine: number;
75
+ /** Last line index (exclusive) from the measure. */
76
+ toLine: number;
77
+ /** Height of this fragment. */
78
+ height: number;
79
+ /** True if this continues from a previous page. */
80
+ continuesFromPrev?: boolean;
81
+ /** True if this continues onto the next page. */
82
+ continuesOnNext?: boolean;
83
+ };
84
+ /**
85
+ * A table fragment positioned on a page.
86
+ * May span only part of the table's rows if split across pages.
87
+ */
88
+ type TableFragment = FragmentBase & {
89
+ kind: 'table';
90
+ /** First row index (inclusive). */
91
+ fromRow: number;
92
+ /** Last row index (exclusive). */
93
+ toRow: number;
94
+ /** Height of this fragment. */
95
+ height: number;
96
+ /** True if this is a floating table. */
97
+ isFloating?: boolean;
98
+ /** True if this continues from a previous page. */
99
+ continuesFromPrev?: boolean;
100
+ /** True if this continues onto the next page. */
101
+ continuesOnNext?: boolean;
102
+ };
103
+ /**
104
+ * An image fragment positioned on a page.
105
+ */
106
+ type ImageFragment = FragmentBase & {
107
+ kind: 'image';
108
+ /** Height of the image. */
109
+ height: number;
110
+ /** True if this is an anchored/floating image. */
111
+ isAnchored?: boolean;
112
+ /** Z-index for layering. */
113
+ zIndex?: number;
114
+ };
115
+ /**
116
+ * Union of all fragment types.
117
+ */
118
+ type Fragment = ParagraphFragment | TableFragment | ImageFragment;
119
+ /**
120
+ * Page margin configuration.
121
+ */
122
+ type PageMargins = {
123
+ top: number;
124
+ right: number;
125
+ bottom: number;
126
+ left: number;
127
+ /** Distance from page top to header content. */
128
+ header?: number;
129
+ /** Distance from page bottom to footer content. */
130
+ footer?: number;
131
+ };
132
+ /**
133
+ * A rendered page containing positioned fragments.
134
+ */
135
+ type Page = {
136
+ /** Page number (1-indexed). */
137
+ number: number;
138
+ /** Fragments positioned on this page. */
139
+ fragments: Fragment[];
140
+ /** Page margins. */
141
+ margins: PageMargins;
142
+ /** Page size (width, height). */
143
+ size: {
144
+ w: number;
145
+ h: number;
146
+ };
147
+ /** Page orientation. */
148
+ orientation?: 'portrait' | 'landscape';
149
+ /** Section index this page belongs to. */
150
+ sectionIndex?: number;
151
+ /** Header/footer references for this page. */
152
+ headerFooterRefs?: {
153
+ headerDefault?: string;
154
+ headerFirst?: string;
155
+ headerEven?: string;
156
+ footerDefault?: string;
157
+ footerFirst?: string;
158
+ footerEven?: string;
159
+ };
160
+ /** Footnote IDs that appear on this page (for rendering). */
161
+ footnoteIds?: number[];
162
+ /** Height reserved for the footnote area at page bottom (pixels). */
163
+ footnoteReservedHeight?: number;
164
+ };
165
+ /**
166
+ * Column layout configuration.
167
+ */
168
+ type ColumnLayout = {
169
+ count: number;
170
+ gap: number;
171
+ equalWidth?: boolean;
172
+ };
173
+ /**
174
+ * Header/footer layout for a specific type.
175
+ */
176
+ type HeaderFooterLayout = {
177
+ height: number;
178
+ fragments: Fragment[];
179
+ };
180
+ /**
181
+ * Final layout output ready for rendering/painting.
182
+ */
183
+ type Layout = {
184
+ /** Default page size for the document. */
185
+ pageSize: {
186
+ w: number;
187
+ h: number;
188
+ };
189
+ /** All rendered pages with positioned fragments. */
190
+ pages: Page[];
191
+ /** Column configuration (if multi-column). */
192
+ columns?: ColumnLayout;
193
+ /** Header layouts by type (default, first, even). */
194
+ headers?: Record<string, HeaderFooterLayout>;
195
+ /** Footer layouts by type (default, first, even). */
196
+ footers?: Record<string, HeaderFooterLayout>;
197
+ /** Gap between pages in pixels (for rendering). */
198
+ pageGap?: number;
199
+ };
200
+
201
+ /**
202
+ * Generic Plugin Interface for the DOCX Editor
203
+ *
204
+ * This module defines the EditorPlugin interface that allows
205
+ * external plugins to integrate with the ProseMirror-based editor.
206
+ */
207
+
208
+ /**
209
+ * Coordinates returned by position lookup in the rendered DOM.
210
+ */
211
+ interface PositionCoordinates {
212
+ x: number;
213
+ y: number;
214
+ height: number;
215
+ }
216
+ /**
217
+ * Context for accessing the rendered DOM in PagedEditor.
218
+ *
219
+ * This interface provides DOM-based position mapping that works with
220
+ * the LayoutPainter output (visible pages) rather than the hidden
221
+ * ProseMirror editor. Use this for rendering overlays, annotations,
222
+ * and other visual elements that need to be positioned relative to
223
+ * the actual rendered content.
224
+ *
225
+ * The rendered DOM uses data-pm-start/data-pm-end attributes on spans
226
+ * to map between ProseMirror positions and DOM elements.
227
+ */
228
+ interface RenderedDomContext {
229
+ /** The container element holding all rendered pages. */
230
+ pagesContainer: HTMLElement;
231
+ /**
232
+ * Get pixel coordinates for a ProseMirror position in the rendered DOM.
233
+ * Returns null if the position cannot be found.
234
+ *
235
+ * @param pmPos - ProseMirror document position
236
+ * @returns Coordinates relative to the pages container, or null
237
+ */
238
+ getCoordinatesForPosition(pmPos: number): PositionCoordinates | null;
239
+ /**
240
+ * Find DOM elements that overlap with a ProseMirror position range.
241
+ * Useful for highlighting or overlaying content.
242
+ *
243
+ * @param from - Start ProseMirror position
244
+ * @param to - End ProseMirror position
245
+ * @returns Array of DOM elements that intersect with the range
246
+ */
247
+ findElementsForRange(from: number, to: number): Element[];
248
+ /**
249
+ * Get bounding rectangles for a range of text, accounting for line wraps.
250
+ * Returns rects relative to the pages container.
251
+ *
252
+ * @param from - Start ProseMirror position
253
+ * @param to - End ProseMirror position
254
+ * @returns Array of DOMRect-like objects for the range
255
+ */
256
+ getRectsForRange(from: number, to: number): Array<{
257
+ x: number;
258
+ y: number;
259
+ width: number;
260
+ height: number;
261
+ }>;
262
+ /** Current zoom level (1 = 100%). */
263
+ zoom: number;
264
+ /**
265
+ * Offset of the pages container from its parent viewport.
266
+ * Use this to adjust coordinates when rendering overlays in the viewport
267
+ * container rather than directly in the pages container.
268
+ */
269
+ getContainerOffset(): {
270
+ x: number;
271
+ y: number;
272
+ };
273
+ }
274
+ /**
275
+ * Props passed to plugin panel components.
276
+ */
277
+ interface PluginPanelProps<TState = unknown> {
278
+ /** Current ProseMirror editor view */
279
+ editorView: EditorView | null;
280
+ /** Current ProseMirror document */
281
+ doc: Node$1 | null;
282
+ /** Scroll editor to a specific position */
283
+ scrollToPosition: (pos: number) => void;
284
+ /** Select a range in the editor */
285
+ selectRange: (from: number, to: number) => void;
286
+ /** Plugin-specific state (managed by the plugin) */
287
+ pluginState: TState;
288
+ /** Width of the panel in pixels */
289
+ panelWidth: number;
290
+ /**
291
+ * Context for the rendered DOM (LayoutPainter output).
292
+ * Use this for positioning annotations relative to the visible pages.
293
+ * May be null if layout hasn't completed yet.
294
+ */
295
+ renderedDomContext: RenderedDomContext | null;
296
+ }
297
+ /**
298
+ * Configuration for plugin panel rendering.
299
+ */
300
+ interface PanelConfig {
301
+ /** Where to render the panel */
302
+ position: 'left' | 'right' | 'bottom';
303
+ /** Default width/height of the panel */
304
+ defaultSize: number;
305
+ /** Minimum size */
306
+ minSize?: number;
307
+ /** Maximum size */
308
+ maxSize?: number;
309
+ /** Whether the panel is resizable */
310
+ resizable?: boolean;
311
+ /** Whether the panel can be collapsed */
312
+ collapsible?: boolean;
313
+ /** Initial collapsed state */
314
+ defaultCollapsed?: boolean;
315
+ }
316
+ /**
317
+ * Generic interface for editor plugins.
318
+ *
319
+ * Implement this interface to create custom plugins that can:
320
+ * - Add ProseMirror plugins (decorations, keymaps, etc.)
321
+ * - Render panels alongside the document
322
+ * - React to editor state changes
323
+ * - Inject custom styles
324
+ *
325
+ * @typeParam TState - The type of plugin-specific state
326
+ */
327
+ interface EditorPlugin<TState = any> {
328
+ /** Unique plugin identifier */
329
+ id: string;
330
+ /** Display name for the plugin */
331
+ name: string;
332
+ /**
333
+ * ProseMirror plugins to register with the editor.
334
+ * These are merged with the editor's internal plugins.
335
+ */
336
+ proseMirrorPlugins?: Plugin[];
337
+ /**
338
+ * React component to render in the annotation panel area.
339
+ * Receives editor state and callbacks for interaction.
340
+ */
341
+ Panel?: React.ComponentType<PluginPanelProps<TState>>;
342
+ /**
343
+ * Configuration for the panel (position, size, etc.)
344
+ */
345
+ panelConfig?: PanelConfig;
346
+ /**
347
+ * Called when the editor state changes.
348
+ * Use this to update plugin-specific state based on document changes.
349
+ *
350
+ * @param view - The current ProseMirror editor view
351
+ * @returns The new plugin state, or undefined to keep existing state
352
+ */
353
+ onStateChange?: (view: EditorView) => TState | undefined;
354
+ /**
355
+ * Initialize plugin state when the plugin is first loaded.
356
+ *
357
+ * @param view - The ProseMirror editor view (may be null initially)
358
+ * @returns Initial plugin state
359
+ */
360
+ initialize?: (view: EditorView | null) => TState;
361
+ /**
362
+ * Called when the plugin is being destroyed.
363
+ * Use this for cleanup (subscriptions, timers, etc.)
364
+ */
365
+ destroy?: () => void;
366
+ /**
367
+ * CSS styles to inject for this plugin.
368
+ * Can be a string of CSS or a URL to a stylesheet.
369
+ */
370
+ styles?: string;
371
+ /**
372
+ * Render an overlay on top of the rendered pages.
373
+ * Use this for highlights, annotations, or other visual elements
374
+ * that need to be positioned relative to the document content.
375
+ *
376
+ * The overlay is rendered inside the viewport, positioned absolutely
377
+ * over the pages container.
378
+ *
379
+ * @param context - The rendered DOM context for position lookup
380
+ * @param state - Current plugin state
381
+ * @param editorView - The editor view for dispatching transactions
382
+ * @returns React node to render as overlay, or null
383
+ */
384
+ renderOverlay?: (context: RenderedDomContext, state: TState, editorView: EditorView | null) => ReactNode;
385
+ }
386
+ /**
387
+ * Context value provided to plugins and panels.
388
+ */
389
+ interface PluginContext {
390
+ /** All registered plugins */
391
+ plugins: EditorPlugin[];
392
+ /** Current editor view */
393
+ editorView: EditorView | null;
394
+ /** Set the editor view (called by editor on mount) */
395
+ setEditorView: (view: EditorView | null) => void;
396
+ /** Get plugin state by plugin ID */
397
+ getPluginState: <T>(pluginId: string) => T | undefined;
398
+ /** Update plugin state */
399
+ setPluginState: <T>(pluginId: string, state: T) => void;
400
+ /** Scroll to a position in the editor */
401
+ scrollToPosition: (pos: number) => void;
402
+ /** Select a range in the editor */
403
+ selectRange: (from: number, to: number) => void;
404
+ }
405
+ /**
406
+ * Props for the PluginHost component.
407
+ */
408
+ interface PluginHostProps {
409
+ /** Plugins to enable */
410
+ plugins: EditorPlugin[];
411
+ /** The editor component (passed as child) */
412
+ children: React.ReactElement;
413
+ /** Class name for the host container */
414
+ className?: string;
415
+ }
416
+ /**
417
+ * Ref interface for the PluginHost component.
418
+ */
419
+ interface PluginHostRef {
420
+ /** Get plugin state by plugin ID */
421
+ getPluginState: <T>(pluginId: string) => T | undefined;
422
+ /** Update plugin state for a plugin */
423
+ setPluginState: <T>(pluginId: string, state: T) => void;
424
+ /** Get the current editor view */
425
+ getEditorView: () => EditorView | null;
426
+ /** Force a refresh of all plugin states */
427
+ refreshPluginStates: () => void;
428
+ }
429
+
430
+ interface PagedEditorRef {
431
+ /** Get the current document. */
432
+ getDocument(): Document | null;
433
+ /** Get the ProseMirror EditorState. */
434
+ getState(): EditorState | null;
435
+ /** Get the ProseMirror EditorView. */
436
+ getView(): EditorView | null;
437
+ /** Focus the editor. */
438
+ focus(): void;
439
+ /** Blur the editor. */
440
+ blur(): void;
441
+ /** Check if focused. */
442
+ isFocused(): boolean;
443
+ /** Dispatch a transaction. */
444
+ dispatch(tr: Transaction): void;
445
+ /** Undo. */
446
+ undo(): boolean;
447
+ /** Redo. */
448
+ redo(): boolean;
449
+ /** Set selection by PM position. */
450
+ setSelection(anchor: number, head?: number): void;
451
+ /** Get current layout. */
452
+ getLayout(): Layout | null;
453
+ /** Force re-layout. */
454
+ relayout(): void;
455
+ /** Scroll the visible pages to bring a PM position into view. */
456
+ scrollToPosition(pmPos: number): void;
457
+ }
458
+
459
+ /**
460
+ * DocxEditor props
461
+ */
462
+ interface DocxEditorProps {
463
+ /** Document data — ArrayBuffer, Uint8Array, Blob, or File */
464
+ documentBuffer?: DocxInput | null;
465
+ /** Pre-parsed document (alternative to documentBuffer) */
466
+ document?: Document | null;
467
+ /** Callback when document is saved */
468
+ onSave?: (buffer: ArrayBuffer) => void;
469
+ /** Callback when document changes */
470
+ onChange?: (document: Document) => void;
471
+ /** Callback when selection changes */
472
+ onSelectionChange?: (state: SelectionState | null) => void;
473
+ /** Callback on error */
474
+ onError?: (error: Error) => void;
475
+ /** Callback when fonts are loaded */
476
+ onFontsLoaded?: () => void;
477
+ /** External ProseMirror plugins (from PluginHost) */
478
+ externalPlugins?: prosemirror_state.Plugin[];
479
+ /** Callback when editor view is ready (for PluginHost) */
480
+ onEditorViewReady?: (view: prosemirror_view.EditorView) => void;
481
+ /** Theme for styling */
482
+ theme?: Theme | null;
483
+ /** Whether to show toolbar (default: true) */
484
+ showToolbar?: boolean;
485
+ /** Whether to show zoom control (default: true) */
486
+ showZoomControl?: boolean;
487
+ /** Whether to show page number indicator (default: true) */
488
+ showPageNumbers?: boolean;
489
+ /** Whether to enable interactive page navigation (default: true) */
490
+ enablePageNavigation?: boolean;
491
+ /** Position of page number indicator (default: 'bottom-center') */
492
+ pageNumberPosition?: PageIndicatorPosition | PageNavigatorPosition;
493
+ /** Variant of page number indicator (default: 'default') */
494
+ pageNumberVariant?: PageIndicatorVariant | PageNavigatorVariant;
495
+ /** Whether to show page margin guides/boundaries (default: false) */
496
+ showMarginGuides?: boolean;
497
+ /** Color for margin guides (default: '#c0c0c0') */
498
+ marginGuideColor?: string;
499
+ /** Whether to show horizontal ruler (default: false) */
500
+ showRuler?: boolean;
501
+ /** Unit for ruler display (default: 'inch') */
502
+ rulerUnit?: 'inch' | 'cm';
503
+ /** Initial zoom level (default: 1.0) */
504
+ initialZoom?: number;
505
+ /** Whether the editor is read-only. When true, hides toolbar and rulers */
506
+ readOnly?: boolean;
507
+ /** Custom toolbar actions */
508
+ toolbarExtra?: ReactNode;
509
+ /** Additional CSS class name */
510
+ className?: string;
511
+ /** Additional inline styles */
512
+ style?: CSSProperties;
513
+ /** Placeholder when no document */
514
+ placeholder?: ReactNode;
515
+ /** Loading indicator */
516
+ loadingIndicator?: ReactNode;
517
+ /** Whether to show the document outline sidebar (default: false) */
518
+ showOutline?: boolean;
519
+ /** Whether to show print button in toolbar (default: true) */
520
+ showPrintButton?: boolean;
521
+ /** Print options for print preview */
522
+ printOptions?: PrintOptions;
523
+ /** Callback when print is triggered */
524
+ onPrint?: () => void;
525
+ /** Callback when content is copied */
526
+ onCopy?: () => void;
527
+ /** Callback when content is cut */
528
+ onCut?: () => void;
529
+ /** Callback when content is pasted */
530
+ onPaste?: () => void;
531
+ /**
532
+ * Callback when rendered DOM context is ready (for plugin overlays).
533
+ * Used by PluginHost to get access to the rendered page DOM for positioning.
534
+ */
535
+ onRenderedDomContextReady?: (context: RenderedDomContext) => void;
536
+ /**
537
+ * Plugin overlays to render inside the editor viewport.
538
+ * Passed from PluginHost to render plugin-specific overlays.
539
+ */
540
+ pluginOverlays?: ReactNode;
541
+ }
542
+ /**
543
+ * DocxEditor ref interface
544
+ */
545
+ interface DocxEditorRef {
546
+ /** Get the DocumentAgent for programmatic access */
547
+ getAgent: () => DocumentAgent | null;
548
+ /** Get the current document */
549
+ getDocument: () => Document | null;
550
+ /** Get the editor ref */
551
+ getEditorRef: () => PagedEditorRef | null;
552
+ /** Save the document to buffer */
553
+ save: () => Promise<ArrayBuffer | null>;
554
+ /** Set zoom level */
555
+ setZoom: (zoom: number) => void;
556
+ /** Get current zoom level */
557
+ getZoom: () => number;
558
+ /** Focus the editor */
559
+ focus: () => void;
560
+ /** Get current page number */
561
+ getCurrentPage: () => number;
562
+ /** Get total page count */
563
+ getTotalPages: () => number;
564
+ /** Scroll to a specific page */
565
+ scrollToPage: (pageNumber: number) => void;
566
+ /** Open print preview */
567
+ openPrintPreview: () => void;
568
+ /** Print the document directly */
569
+ print: () => void;
570
+ }
571
+ /**
572
+ * DocxEditor - Complete DOCX editor component
573
+ */
574
+ declare const DocxEditor: React$1.ForwardRefExoticComponent<DocxEditorProps & React$1.RefAttributes<DocxEditorRef>>;
575
+
576
+ /**
577
+ * Simple imperative API for rendering a DOCX editor into a DOM element.
578
+ *
579
+ * Usage:
580
+ * ```ts
581
+ * import { renderAsync } from '@eigenpal/docx-js-editor';
582
+ *
583
+ * const editor = await renderAsync(docxBlob, document.getElementById('container'), {
584
+ * readOnly: false,
585
+ * showToolbar: true,
586
+ * });
587
+ *
588
+ * // Save the edited document
589
+ * const buffer = await editor.save();
590
+ *
591
+ * // Clean up
592
+ * editor.destroy();
593
+ * ```
594
+ */
595
+
596
+ /**
597
+ * Options for {@link renderAsync}. A subset of DocxEditorProps minus
598
+ * `documentBuffer` / `document` (passed as the first argument instead).
599
+ */
600
+ type RenderAsyncOptions = Omit<DocxEditorProps, 'documentBuffer' | 'document'>;
601
+ /**
602
+ * Handle returned by {@link renderAsync} for interacting with the editor.
603
+ */
604
+ interface DocxEditorHandle {
605
+ /** Save the document and return the DOCX as an ArrayBuffer. */
606
+ save: () => Promise<ArrayBuffer | null>;
607
+ /** Get the current parsed document model. */
608
+ getDocument: () => Document | null;
609
+ /** Focus the editor. */
610
+ focus: () => void;
611
+ /** Set zoom level (1.0 = 100%). */
612
+ setZoom: (zoom: number) => void;
613
+ /** Unmount the editor and clean up. */
614
+ destroy: () => void;
615
+ }
616
+ /**
617
+ * Render a DOCX editor into a container element.
618
+ *
619
+ * @param input - DOCX data as ArrayBuffer, Uint8Array, Blob, or File
620
+ * @param container - DOM element to render into
621
+ * @param options - Editor configuration (toolbar, readOnly, callbacks, etc.)
622
+ * @returns A handle with save / destroy / getDocument methods
623
+ */
624
+ declare function renderAsync(input: DocxInput, container: HTMLElement, options?: RenderAsyncOptions): Promise<DocxEditorHandle>;
625
+
626
+ /**
627
+ * Error severity levels
628
+ */
629
+ type ErrorSeverity = 'error' | 'warning' | 'info';
630
+ /**
631
+ * Error notification
632
+ */
633
+ interface ErrorNotification {
634
+ id: string;
635
+ message: string;
636
+ severity: ErrorSeverity;
637
+ details?: string;
638
+ timestamp: number;
639
+ dismissed?: boolean;
640
+ }
641
+ /**
642
+ * Error context value
643
+ */
644
+ interface ErrorContextValue {
645
+ /** Current notifications */
646
+ notifications: ErrorNotification[];
647
+ /** Show an error notification */
648
+ showError: (message: string, details?: string) => void;
649
+ /** Show a warning notification */
650
+ showWarning: (message: string, details?: string) => void;
651
+ /** Show an info notification */
652
+ showInfo: (message: string, details?: string) => void;
653
+ /** Dismiss a notification */
654
+ dismissNotification: (id: string) => void;
655
+ /** Clear all notifications */
656
+ clearNotifications: () => void;
657
+ }
658
+ /**
659
+ * Error boundary props
660
+ */
661
+ interface ErrorBoundaryProps {
662
+ /** Child components to render */
663
+ children: ReactNode;
664
+ /** Custom fallback UI */
665
+ fallback?: ReactNode | ((error: Error, reset: () => void) => ReactNode);
666
+ /** Callback when error occurs */
667
+ onError?: (error: Error, errorInfo: ErrorInfo) => void;
668
+ /** Whether to show error details */
669
+ showDetails?: boolean;
670
+ }
671
+ /**
672
+ * Error boundary state
673
+ */
674
+ interface ErrorBoundaryState {
675
+ hasError: boolean;
676
+ error: Error | null;
677
+ errorInfo: ErrorInfo | null;
678
+ }
679
+ /**
680
+ * Hook to use error notifications
681
+ */
682
+ declare function useErrorNotifications(): ErrorContextValue;
683
+ /**
684
+ * Error notification provider
685
+ */
686
+ declare function ErrorProvider({ children }: {
687
+ children: ReactNode;
688
+ }): react_jsx_runtime.JSX.Element;
689
+ /**
690
+ * Error Boundary class component
691
+ *
692
+ * Catches render errors in child components and displays fallback UI.
693
+ */
694
+ declare class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
695
+ constructor(props: ErrorBoundaryProps);
696
+ static getDerivedStateFromError(error: Error): Partial<ErrorBoundaryState>;
697
+ componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
698
+ resetError: () => void;
699
+ render(): ReactNode;
700
+ }
701
+ interface ParseErrorDisplayProps {
702
+ message: string;
703
+ details?: string;
704
+ onRetry?: () => void;
705
+ className?: string;
706
+ }
707
+ /**
708
+ * Parse error display component
709
+ *
710
+ * Shows a helpful message for DOCX parsing errors.
711
+ */
712
+ declare function ParseErrorDisplay({ message, details, onRetry, className, }: ParseErrorDisplayProps): React__default.ReactElement;
713
+ interface UnsupportedFeatureWarningProps {
714
+ feature: string;
715
+ description?: string;
716
+ className?: string;
717
+ }
718
+ /**
719
+ * Unsupported feature warning component
720
+ *
721
+ * Shows a non-blocking warning for unsupported features.
722
+ */
723
+ declare function UnsupportedFeatureWarning({ feature, description, className, }: UnsupportedFeatureWarningProps): React__default.ReactElement;
724
+ /**
725
+ * Check if an error is a parse error
726
+ */
727
+ declare function isParseError(error: Error): boolean;
728
+ /**
729
+ * Get user-friendly error message
730
+ */
731
+ declare function getUserFriendlyMessage(error: Error): string;
732
+
733
+ /**
734
+ * useTableSelection Hook
735
+ *
736
+ * Tracks table selection state based on user clicks.
737
+ * Provides:
738
+ * - Current table context when clicking in a table cell
739
+ * - Methods to handle table actions (add row, delete column, etc.)
740
+ * - Clears selection when clicking outside tables
741
+ */
742
+
743
+ /**
744
+ * Table selection state
745
+ */
746
+ interface TableSelectionState {
747
+ /** Current table context (null if not in a table) */
748
+ context: TableContext | null;
749
+ /** The selected table */
750
+ table: Table | null;
751
+ /** Index of the table in the document */
752
+ tableIndex: number | null;
753
+ /** Row index */
754
+ rowIndex: number | null;
755
+ /** Column index */
756
+ columnIndex: number | null;
757
+ }
758
+ /**
759
+ * Return type for useTableSelection hook
760
+ */
761
+ interface UseTableSelectionReturn {
762
+ /** Current table selection state */
763
+ state: TableSelectionState;
764
+ /** Handle click on a table cell */
765
+ handleCellClick: (tableIndex: number, rowIndex: number, columnIndex: number) => void;
766
+ /** Handle table action */
767
+ handleAction: (action: TableAction) => void;
768
+ /** Clear the selection */
769
+ clearSelection: () => void;
770
+ /** Check if a cell is selected */
771
+ isCellSelected: (tableIndex: number, rowIndex: number, columnIndex: number) => boolean;
772
+ /** The table context for the TableToolbar */
773
+ tableContext: TableContext | null;
774
+ }
775
+ /**
776
+ * Options for useTableSelection
777
+ */
778
+ interface UseTableSelectionOptions {
779
+ /** The document being edited */
780
+ document: Document | null;
781
+ /** Callback when document changes */
782
+ onChange?: (document: Document) => void;
783
+ /** Callback when table selection changes */
784
+ onSelectionChange?: (context: TableContext | null) => void;
785
+ }
786
+ /**
787
+ * Data attributes for table elements
788
+ */
789
+ declare const TABLE_DATA_ATTRIBUTES: {
790
+ /** Attribute for table index */
791
+ TABLE_INDEX: string;
792
+ /** Attribute for row index */
793
+ ROW_INDEX: string;
794
+ /** Attribute for column index */
795
+ COLUMN_INDEX: string;
796
+ /** Attribute marking a table cell */
797
+ TABLE_CELL: string;
798
+ };
799
+ /**
800
+ * Hook for tracking and managing table selection
801
+ */
802
+ declare function useTableSelection({ document: doc, onChange, onSelectionChange, }: UseTableSelectionOptions): UseTableSelectionReturn;
803
+
804
+ /**
805
+ * useAutoSave Hook
806
+ *
807
+ * Automatically saves document state to localStorage at configurable intervals.
808
+ *
809
+ * Features:
810
+ * - Configurable save interval (default: 30 seconds)
811
+ * - Saves document JSON to localStorage
812
+ * - Recovery of saved state on load
813
+ * - Manual save trigger
814
+ * - Last save timestamp tracking
815
+ * - Save status callbacks
816
+ */
817
+
818
+ /**
819
+ * Auto-save status
820
+ */
821
+ type AutoSaveStatus = 'idle' | 'saving' | 'saved' | 'error';
822
+ /**
823
+ * Options for useAutoSave hook
824
+ */
825
+ interface UseAutoSaveOptions {
826
+ /** Storage key for localStorage (default: 'docx-editor-autosave') */
827
+ storageKey?: string;
828
+ /** Save interval in milliseconds (default: 30000 - 30 seconds) */
829
+ interval?: number;
830
+ /** Whether auto-save is enabled (default: true) */
831
+ enabled?: boolean;
832
+ /** Maximum age of auto-save in milliseconds before it's considered stale (default: 24 hours) */
833
+ maxAge?: number;
834
+ /** Callback when save succeeds */
835
+ onSave?: (timestamp: Date) => void;
836
+ /** Callback when save fails */
837
+ onError?: (error: Error) => void;
838
+ /** Callback when recovery data is found */
839
+ onRecoveryAvailable?: (savedDocument: SavedDocumentData) => void;
840
+ /** Whether to save immediately when document changes (debounced) */
841
+ saveOnChange?: boolean;
842
+ /** Debounce delay for saveOnChange in milliseconds (default: 2000) */
843
+ debounceDelay?: number;
844
+ }
845
+ /**
846
+ * Return value of useAutoSave hook
847
+ */
848
+ interface UseAutoSaveReturn {
849
+ /** Current auto-save status */
850
+ status: AutoSaveStatus;
851
+ /** Last save timestamp */
852
+ lastSaveTime: Date | null;
853
+ /** Manually trigger a save */
854
+ save: () => Promise<boolean>;
855
+ /** Clear auto-saved data from storage */
856
+ clearAutoSave: () => void;
857
+ /** Check if there's recoverable data */
858
+ hasRecoveryData: boolean;
859
+ /** Get the saved document data for recovery */
860
+ getRecoveryData: () => SavedDocumentData | null;
861
+ /** Accept and apply recovered data */
862
+ acceptRecovery: () => Document | null;
863
+ /** Dismiss recovery (clears saved data) */
864
+ dismissRecovery: () => void;
865
+ /** Whether auto-save is currently enabled */
866
+ isEnabled: boolean;
867
+ /** Enable auto-save */
868
+ enable: () => void;
869
+ /** Disable auto-save */
870
+ disable: () => void;
871
+ }
872
+ /**
873
+ * Saved document data structure
874
+ */
875
+ interface SavedDocumentData {
876
+ /** The document JSON */
877
+ document: Document;
878
+ /** When the document was saved */
879
+ savedAt: string;
880
+ /** Version for format compatibility */
881
+ version: number;
882
+ /** Optional document identifier */
883
+ documentId?: string;
884
+ }
885
+ /**
886
+ * React hook for auto-saving document to localStorage
887
+ */
888
+ declare function useAutoSave(document: Document | null | undefined, options?: UseAutoSaveOptions): UseAutoSaveReturn;
889
+ /**
890
+ * Format last save time for display
891
+ */
892
+ declare function formatLastSaveTime(date: Date | null): string;
893
+ /**
894
+ * Get auto-save status label
895
+ */
896
+ declare function getAutoSaveStatusLabel(status: AutoSaveStatus): string;
897
+ /**
898
+ * Get storage size used by auto-save
899
+ */
900
+ declare function getAutoSaveStorageSize(storageKey?: string): number;
901
+ /**
902
+ * Format storage size for display
903
+ */
904
+ declare function formatStorageSize(bytes: number): string;
905
+ /**
906
+ * Check if auto-save is supported in this environment
907
+ */
908
+ declare function isAutoSaveSupported(): boolean;
909
+
910
+ /**
911
+ * useWheelZoom Hook
912
+ *
913
+ * Enables Ctrl+scroll (or Cmd+scroll on Mac) to zoom in/out.
914
+ * Features:
915
+ * - Configurable zoom range and step
916
+ * - Smooth zoom transitions
917
+ * - Pinch-to-zoom support on trackpads
918
+ * - Zoom reset (Ctrl+0)
919
+ * - Zoom in/out shortcuts (Ctrl++, Ctrl+-)
920
+ */
921
+ /**
922
+ * Options for useWheelZoom hook
923
+ */
924
+ interface UseWheelZoomOptions {
925
+ /** Initial zoom level (default: 1.0) */
926
+ initialZoom?: number;
927
+ /** Minimum zoom level (default: 0.25) */
928
+ minZoom?: number;
929
+ /** Maximum zoom level (default: 4.0) */
930
+ maxZoom?: number;
931
+ /** Zoom step for each scroll event (default: 0.1) */
932
+ zoomStep?: number;
933
+ /** Whether zoom is enabled (default: true) */
934
+ enabled?: boolean;
935
+ /** Container element ref to attach wheel listener */
936
+ containerRef?: React.RefObject<HTMLElement>;
937
+ /** Callback when zoom changes */
938
+ onZoomChange?: (zoom: number) => void;
939
+ /** Whether to enable keyboard shortcuts (Ctrl++, Ctrl+-, Ctrl+0) */
940
+ enableKeyboardShortcuts?: boolean;
941
+ /** Whether to prevent default browser zoom behavior */
942
+ preventDefault?: boolean;
943
+ }
944
+ /**
945
+ * Return value of useWheelZoom hook
946
+ */
947
+ interface UseWheelZoomReturn {
948
+ /** Current zoom level */
949
+ zoom: number;
950
+ /** Set zoom level directly */
951
+ setZoom: (zoom: number) => void;
952
+ /** Zoom in by step */
953
+ zoomIn: () => void;
954
+ /** Zoom out by step */
955
+ zoomOut: () => void;
956
+ /** Reset zoom to initial level */
957
+ resetZoom: () => void;
958
+ /** Reset zoom to 100% */
959
+ zoomTo100: () => void;
960
+ /** Zoom to fit width */
961
+ zoomToFit: (containerWidth: number, contentWidth: number) => void;
962
+ /** Whether currently at minimum zoom */
963
+ isMinZoom: boolean;
964
+ /** Whether currently at maximum zoom */
965
+ isMaxZoom: boolean;
966
+ /** Zoom percentage (e.g., 100 for zoom level 1.0) */
967
+ zoomPercent: number;
968
+ /** Wheel event handler (for manual attachment) */
969
+ handleWheel: (event: WheelEvent) => void;
970
+ /** Keyboard event handler (for manual attachment) */
971
+ handleKeyDown: (event: KeyboardEvent) => void;
972
+ }
973
+ /**
974
+ * Preset zoom levels for snapping
975
+ */
976
+ declare const ZOOM_PRESETS: number[];
977
+ /**
978
+ * React hook for Ctrl+scroll zoom functionality
979
+ */
980
+ declare function useWheelZoom(options?: UseWheelZoomOptions): UseWheelZoomReturn;
981
+ /**
982
+ * Get zoom presets
983
+ */
984
+ declare function getZoomPresets(): number[];
985
+ /**
986
+ * Find nearest zoom preset
987
+ */
988
+ declare function findNearestZoomPreset(zoom: number): number;
989
+ /**
990
+ * Get next zoom preset (for zoom in)
991
+ */
992
+ declare function getNextZoomPreset(zoom: number): number;
993
+ /**
994
+ * Get previous zoom preset (for zoom out)
995
+ */
996
+ declare function getPreviousZoomPreset(zoom: number): number;
997
+ /**
998
+ * Format zoom level for display
999
+ */
1000
+ declare function formatZoom(zoom: number): string;
1001
+ /**
1002
+ * Parse zoom from percentage string
1003
+ */
1004
+ declare function parseZoom(zoomString: string): number | null;
1005
+ /**
1006
+ * Check if zoom level is at a preset
1007
+ */
1008
+ declare function isZoomPreset(zoom: number): boolean;
1009
+ /**
1010
+ * Clamp zoom to valid range
1011
+ */
1012
+ declare function clampZoom(zoom: number, minZoom?: number, maxZoom?: number): number;
1013
+
1014
+ /**
1015
+ * Selection Highlight Utilities
1016
+ *
1017
+ * Provides visual highlighting for text selection across multiple runs.
1018
+ * Browsers handle ::selection pseudo-element differently, especially when
1019
+ * selection spans multiple elements with different backgrounds or styling.
1020
+ *
1021
+ * This module provides:
1022
+ * - Custom selection highlight rendering
1023
+ * - Programmatic selection range marking
1024
+ * - Visual feedback for selection across runs
1025
+ */
1026
+
1027
+ /**
1028
+ * Highlight rectangle representing a selected region
1029
+ */
1030
+ interface HighlightRect {
1031
+ /** Left position in pixels */
1032
+ left: number;
1033
+ /** Top position in pixels */
1034
+ top: number;
1035
+ /** Width in pixels */
1036
+ width: number;
1037
+ /** Height in pixels */
1038
+ height: number;
1039
+ }
1040
+ /**
1041
+ * Selection highlight configuration
1042
+ */
1043
+ interface SelectionHighlightConfig {
1044
+ /** Background color for selection */
1045
+ backgroundColor: string;
1046
+ /** Optional border color for selection */
1047
+ borderColor?: string;
1048
+ /** Optional border radius */
1049
+ borderRadius?: number;
1050
+ /** Z-index for overlay */
1051
+ zIndex?: number;
1052
+ /** Opacity for highlight */
1053
+ opacity?: number;
1054
+ /** Mix blend mode */
1055
+ mixBlendMode?: CSSProperties['mixBlendMode'];
1056
+ }
1057
+ /**
1058
+ * Selection range in document coordinates
1059
+ */
1060
+ interface SelectionRange {
1061
+ /** Start position */
1062
+ start: {
1063
+ paragraphIndex: number;
1064
+ contentIndex: number;
1065
+ offset: number;
1066
+ };
1067
+ /** End position */
1068
+ end: {
1069
+ paragraphIndex: number;
1070
+ contentIndex: number;
1071
+ offset: number;
1072
+ };
1073
+ }
1074
+ /**
1075
+ * Default selection highlight style (matches Word/Google Docs)
1076
+ */
1077
+ declare const DEFAULT_SELECTION_STYLE: SelectionHighlightConfig;
1078
+ /**
1079
+ * High contrast selection style
1080
+ */
1081
+ declare const HIGH_CONTRAST_SELECTION_STYLE: SelectionHighlightConfig;
1082
+ /**
1083
+ * Selection highlight CSS custom properties
1084
+ */
1085
+ declare const SELECTION_CSS_VARS: {
1086
+ readonly backgroundColor: "--docx-selection-bg";
1087
+ readonly borderColor: "--docx-selection-border";
1088
+ readonly textColor: "--docx-selection-text";
1089
+ };
1090
+ /**
1091
+ * Get all selection rectangles from the current DOM selection
1092
+ *
1093
+ * Uses getClientRects() to get accurate rectangles even when
1094
+ * selection spans multiple inline elements.
1095
+ */
1096
+ declare function getSelectionRects(containerElement?: HTMLElement | null): HighlightRect[];
1097
+ /**
1098
+ * Merge adjacent or overlapping rectangles
1099
+ *
1100
+ * This reduces the number of highlight elements needed and creates
1101
+ * a cleaner visual appearance.
1102
+ */
1103
+ declare function mergeAdjacentRects(rects: HighlightRect[], tolerance?: number): HighlightRect[];
1104
+ /**
1105
+ * Get selection rectangles with merging applied
1106
+ */
1107
+ declare function getMergedSelectionRects(containerElement?: HTMLElement | null): HighlightRect[];
1108
+ /**
1109
+ * Generate CSS styles for a highlight rectangle
1110
+ */
1111
+ declare function getHighlightRectStyle(rect: HighlightRect, config?: SelectionHighlightConfig): CSSProperties;
1112
+ /**
1113
+ * Generate inline CSS for selection pseudo-elements
1114
+ *
1115
+ * This is used to inject consistent selection styling
1116
+ * across all editable elements.
1117
+ */
1118
+ declare function generateSelectionCSS(selector: string, config?: SelectionHighlightConfig): string;
1119
+ /**
1120
+ * Check if there is an active text selection (not collapsed)
1121
+ */
1122
+ declare function hasActiveSelection(): boolean;
1123
+ /**
1124
+ * Get the selected text
1125
+ */
1126
+ declare function getSelectedText(): string;
1127
+ /**
1128
+ * Check if selection is within a specific element
1129
+ */
1130
+ declare function isSelectionWithin(element: HTMLElement): boolean;
1131
+ /**
1132
+ * Get the bounding rect of the current selection
1133
+ */
1134
+ declare function getSelectionBoundingRect(): DOMRect | null;
1135
+ /**
1136
+ * Create a selection highlight for a specific text range
1137
+ *
1138
+ * This is useful for find/replace highlighting, AI action previews, etc.
1139
+ */
1140
+ declare function highlightTextRange(_containerElement: HTMLElement, startNode: Node, startOffset: number, endNode: Node, endOffset: number): Range | null;
1141
+ /**
1142
+ * Select a text range programmatically
1143
+ */
1144
+ declare function selectRange(range: Range): void;
1145
+ /**
1146
+ * Clear the current selection
1147
+ */
1148
+ declare function clearSelection(): void;
1149
+ /**
1150
+ * Check if selection is backwards (focus before anchor)
1151
+ */
1152
+ declare function isSelectionBackwards(): boolean;
1153
+ /**
1154
+ * Normalize selection to always be forward (start before end)
1155
+ */
1156
+ declare function normalizeSelectionDirection(): void;
1157
+ /**
1158
+ * Inject selection highlight CSS into document
1159
+ */
1160
+ declare function injectSelectionStyles(config?: SelectionHighlightConfig): void;
1161
+ /**
1162
+ * Remove injected selection styles
1163
+ */
1164
+ declare function removeSelectionStyles(): void;
1165
+ /**
1166
+ * Check if selection styles are injected
1167
+ */
1168
+ declare function areSelectionStylesInjected(): boolean;
1169
+ /**
1170
+ * Create a selection change handler that updates highlight rects
1171
+ */
1172
+ declare function createSelectionChangeHandler(containerElement: HTMLElement | null, onRectsChange: (rects: HighlightRect[]) => void, merge?: boolean): () => void;
1173
+
1174
+ /**
1175
+ * Selection Highlight Hook
1176
+ *
1177
+ * A React hook that manages visual selection highlighting across multiple runs.
1178
+ * Uses a combination of CSS ::selection pseudo-element styling and optional
1179
+ * overlay rectangles for complex scenarios.
1180
+ *
1181
+ * Features:
1182
+ * - Consistent selection highlighting across all text runs
1183
+ * - Support for text with different backgrounds (highlighted, dark bg)
1184
+ * - Optional overlay rectangles for custom highlight effects
1185
+ * - Debounced updates for performance
1186
+ */
1187
+
1188
+ /**
1189
+ * Options for the useSelectionHighlight hook
1190
+ */
1191
+ interface UseSelectionHighlightOptions {
1192
+ /** Reference to the container element */
1193
+ containerRef: React__default.RefObject<HTMLElement>;
1194
+ /** Whether to enable selection highlighting */
1195
+ enabled?: boolean;
1196
+ /** Custom highlight configuration */
1197
+ config?: SelectionHighlightConfig;
1198
+ /** Whether to use overlay rectangles (default: false, uses CSS) */
1199
+ useOverlay?: boolean;
1200
+ /** Debounce delay for rect updates in ms (default: 16) */
1201
+ debounceMs?: number;
1202
+ /** Callback when selection changes */
1203
+ onSelectionChange?: (hasSelection: boolean, text: string) => void;
1204
+ }
1205
+ /**
1206
+ * Return value from the useSelectionHighlight hook
1207
+ */
1208
+ interface UseSelectionHighlightReturn {
1209
+ /** Whether there is an active selection */
1210
+ hasSelection: boolean;
1211
+ /** The selected text */
1212
+ selectedText: string;
1213
+ /** Highlight rectangles (only populated if useOverlay is true) */
1214
+ highlightRects: HighlightRect[];
1215
+ /** Whether selection is within the container */
1216
+ isSelectionInContainer: boolean;
1217
+ /** Refresh the highlight state */
1218
+ refresh: () => void;
1219
+ /** Get styles for a highlight rect overlay */
1220
+ getOverlayStyle: (rect: HighlightRect) => CSSProperties;
1221
+ }
1222
+ /**
1223
+ * Hook to manage selection highlighting in the editor
1224
+ */
1225
+ declare function useSelectionHighlight(options: UseSelectionHighlightOptions): UseSelectionHighlightReturn;
1226
+ /**
1227
+ * Props for selection overlay component
1228
+ */
1229
+ interface SelectionOverlayProps {
1230
+ /** Highlight rectangles to render */
1231
+ rects: HighlightRect[];
1232
+ /** Style configuration */
1233
+ config?: SelectionHighlightConfig;
1234
+ /** Additional class name */
1235
+ className?: string;
1236
+ }
1237
+ /**
1238
+ * Generate selection overlay elements (for use in JSX)
1239
+ *
1240
+ * Usage:
1241
+ * ```tsx
1242
+ * const { highlightRects } = useSelectionHighlight({ ... });
1243
+ * return (
1244
+ * <div style={{ position: 'relative' }}>
1245
+ * {generateOverlayElements(highlightRects)}
1246
+ * <div>... content ...</div>
1247
+ * </div>
1248
+ * );
1249
+ * ```
1250
+ */
1251
+ declare function generateOverlayElements(rects: HighlightRect[], config?: SelectionHighlightConfig): React__default.ReactNode[];
1252
+
1253
+ /**
1254
+ * useClipboard Hook
1255
+ *
1256
+ * React hook for managing clipboard operations in the editor with formatting preservation.
1257
+ *
1258
+ * Features:
1259
+ * - Copy: Copies selected runs/paragraphs to clipboard with formatting as HTML
1260
+ * - Cut: Copies and removes selected content
1261
+ * - Paste: Parses clipboard HTML/text and applies formatting
1262
+ * - Handles Word-pasted content (cleans Word-specific markup)
1263
+ * - Keyboard shortcuts (Ctrl+C, Ctrl+X, Ctrl+V)
1264
+ */
1265
+
1266
+ /**
1267
+ * Selection data for clipboard operations
1268
+ */
1269
+ interface ClipboardSelection {
1270
+ /** Selected text (plain text) */
1271
+ text: string;
1272
+ /** Selected runs */
1273
+ runs: Run[];
1274
+ /** Start position */
1275
+ startParagraphIndex: number;
1276
+ startRunIndex: number;
1277
+ startOffset: number;
1278
+ /** End position */
1279
+ endParagraphIndex: number;
1280
+ endRunIndex: number;
1281
+ endOffset: number;
1282
+ /** Whether selection spans multiple paragraphs */
1283
+ isMultiParagraph: boolean;
1284
+ }
1285
+ /**
1286
+ * Options for useClipboard hook
1287
+ */
1288
+ interface UseClipboardOptions {
1289
+ /** Callback when content is copied */
1290
+ onCopy?: (selection: ClipboardSelection) => void;
1291
+ /** Callback when content is cut */
1292
+ onCut?: (selection: ClipboardSelection) => void;
1293
+ /** Callback when content is pasted */
1294
+ onPaste?: (content: ParsedClipboardContent, asPlainText: boolean) => void;
1295
+ /** Whether to clean Word-specific formatting */
1296
+ cleanWordFormatting?: boolean;
1297
+ /** Whether the editor is editable */
1298
+ editable?: boolean;
1299
+ /** Callback for errors */
1300
+ onError?: (error: Error) => void;
1301
+ }
1302
+ /**
1303
+ * Return value of useClipboard hook
1304
+ */
1305
+ interface UseClipboardReturn {
1306
+ /** Copy the current selection to clipboard */
1307
+ copy: (selection: ClipboardSelection) => Promise<boolean>;
1308
+ /** Cut the current selection to clipboard */
1309
+ cut: (selection: ClipboardSelection) => Promise<boolean>;
1310
+ /** Paste from clipboard */
1311
+ paste: (asPlainText?: boolean) => Promise<ParsedClipboardContent | null>;
1312
+ /** Handle copy event from DOM */
1313
+ handleCopy: (event: ClipboardEvent) => void;
1314
+ /** Handle cut event from DOM */
1315
+ handleCut: (event: ClipboardEvent) => void;
1316
+ /** Handle paste event from DOM */
1317
+ handlePaste: (event: ClipboardEvent) => void;
1318
+ /** Handle keyboard shortcuts */
1319
+ handleKeyDown: (event: KeyboardEvent) => void;
1320
+ /** Whether a clipboard operation is in progress */
1321
+ isProcessing: boolean;
1322
+ /** Last pasted content */
1323
+ lastPastedContent: ParsedClipboardContent | null;
1324
+ }
1325
+ /**
1326
+ * Get selected runs from the current DOM selection
1327
+ */
1328
+ declare function getSelectionRuns(): Run[];
1329
+ /**
1330
+ * Create a selection object from the current DOM selection
1331
+ */
1332
+ declare function createSelectionFromDOM(): ClipboardSelection | null;
1333
+ /**
1334
+ * React hook for clipboard operations
1335
+ */
1336
+ declare function useClipboard(options?: UseClipboardOptions): UseClipboardReturn;
1337
+
1338
+ declare const PLUGIN_HOST_STYLES = "\n.plugin-host {\n display: flex;\n width: 100%;\n height: 100%;\n overflow: visible;\n position: relative;\n}\n\n.plugin-host-editor {\n flex: 1;\n display: flex;\n flex-direction: column;\n min-width: 0;\n overflow: visible;\n}\n\n\n.plugin-panels-left,\n.plugin-panels-right {\n display: flex;\n flex-direction: column;\n flex-shrink: 0;\n background: #f8f9fa;\n border-color: #e9ecef;\n}\n\n.plugin-panels-left {\n border-right: 1px solid #e9ecef;\n}\n\n.plugin-panels-right {\n border-left: 1px solid #e9ecef;\n}\n\n.plugin-panels-bottom {\n border-top: 1px solid #e9ecef;\n background: #f8f9fa;\n}\n\n.plugin-panel {\n position: relative;\n display: flex;\n flex-direction: column;\n overflow: hidden;\n transition: width 0.2s ease, height 0.2s ease;\n}\n\n.plugin-panel.collapsed {\n overflow: visible;\n}\n\n.plugin-panel-toggle {\n display: flex;\n align-items: center;\n gap: 4px;\n padding: 6px 8px;\n background: transparent;\n border: none;\n cursor: pointer;\n font-size: 12px;\n color: #6c757d;\n white-space: nowrap;\n}\n\n.plugin-panel.collapsed .plugin-panel-toggle {\n writing-mode: vertical-rl;\n text-orientation: mixed;\n flex-direction: column;\n height: 100%;\n padding: 8px 6px;\n}\n\n.plugin-panel-toggle:hover {\n background: #e9ecef;\n color: #495057;\n}\n\n.plugin-panel-toggle-icon {\n font-weight: bold;\n font-size: 14px;\n}\n\n.plugin-panel.collapsed .plugin-panel-toggle-icon {\n transform: rotate(90deg);\n}\n\n.plugin-panel-toggle-label {\n font-weight: 500;\n}\n\n.plugin-panel-content {\n flex: 1;\n overflow: auto;\n}\n\n/* Right panel rendered inside viewport - scrolls with content */\n.plugin-panel-in-viewport {\n position: absolute;\n top: 0;\n /* Position is set dynamically via inline styles based on page edge */\n width: 220px;\n pointer-events: auto;\n z-index: 10;\n overflow: visible;\n}\n\n.plugin-panel-in-viewport.collapsed {\n width: 32px;\n}\n\n.plugin-panel-in-viewport .plugin-panel-toggle {\n position: sticky;\n top: 0;\n background: rgba(255, 255, 255, 0.95);\n border-radius: 4px;\n box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);\n}\n\n.plugin-panel-in-viewport-content {\n overflow: visible;\n position: relative;\n}\n\n/* Plugin overlay container for rendering highlights/decorations */\n.plugin-overlays-container {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n pointer-events: none;\n overflow: visible;\n z-index: 5;\n}\n\n.plugin-overlay {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n pointer-events: none;\n}\n\n.plugin-overlay > * {\n pointer-events: auto;\n}\n";
1339
+ /**
1340
+ * PluginHost Component
1341
+ *
1342
+ * Wraps the editor and provides:
1343
+ * - Plugin state management
1344
+ * - Panel rendering for each plugin
1345
+ * - CSS injection for plugin styles
1346
+ * - Callbacks for editor interaction
1347
+ */
1348
+ declare const PluginHost: React$1.ForwardRefExoticComponent<PluginHostProps & React$1.RefAttributes<PluginHostRef>>;
1349
+
1350
+ export { findNearestZoomPreset as $, type AutoSaveStatus as A, type UnsupportedFeatureWarningProps as B, type ClipboardSelection as C, DEFAULT_SELECTION_STYLE as D, type EditorPlugin as E, type UseAutoSaveOptions as F, type UseAutoSaveReturn as G, HIGH_CONTRAST_SELECTION_STYLE as H, type UseClipboardOptions as I, type UseClipboardReturn as J, type UseSelectionHighlightOptions as K, type UseSelectionHighlightReturn as L, type UseTableSelectionOptions as M, type UseTableSelectionReturn as N, type UseWheelZoomOptions as O, type PluginPanelProps as P, type UseWheelZoomReturn as Q, type RenderAsyncOptions as R, SELECTION_CSS_VARS as S, TABLE_DATA_ATTRIBUTES as T, UnsupportedFeatureWarning as U, areSelectionStylesInjected as V, clampZoom as W, clearSelection as X, createSelectionChangeHandler as Y, ZOOM_PRESETS as Z, createSelectionFromDOM as _, DocxEditor as a, formatLastSaveTime as a0, formatStorageSize as a1, formatZoom as a2, generateOverlayElements as a3, generateSelectionCSS as a4, getAutoSaveStatusLabel as a5, getAutoSaveStorageSize as a6, getHighlightRectStyle as a7, getMergedSelectionRects as a8, getNextZoomPreset as a9, useWheelZoom as aA, getPreviousZoomPreset as aa, getSelectedText as ab, getSelectionBoundingRect as ac, getSelectionRects as ad, getSelectionRuns as ae, getUserFriendlyMessage as af, getZoomPresets as ag, hasActiveSelection as ah, highlightTextRange as ai, injectSelectionStyles as aj, isAutoSaveSupported as ak, isParseError as al, isSelectionBackwards as am, isSelectionWithin as an, isZoomPreset as ao, mergeAdjacentRects as ap, normalizeSelectionDirection as aq, parseZoom as ar, removeSelectionStyles as as, renderAsync as at, selectRange as au, useAutoSave as av, useClipboard as aw, useErrorNotifications as ax, useSelectionHighlight as ay, useTableSelection as az, type DocxEditorHandle as b, type DocxEditorProps as c, type DocxEditorRef as d, ErrorBoundary as e, type ErrorBoundaryProps as f, type ErrorContextValue as g, type ErrorNotification as h, ErrorProvider as i, type ErrorSeverity as j, type HighlightRect as k, PLUGIN_HOST_STYLES as l, type PanelConfig as m, ParseErrorDisplay as n, type ParseErrorDisplayProps as o, type PluginContext as p, PluginHost as q, type PluginHostProps as r, type PluginHostRef as s, type PositionCoordinates as t, type RenderedDomContext as u, type SavedDocumentData as v, type SelectionHighlightConfig as w, type SelectionOverlayProps as x, type SelectionRange as y, type TableSelectionState as z };