@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,567 @@
1
+ /**
2
+ * @zeke-02/docx-editor-react
3
+ *
4
+ * Curated root entry for the documented React editor API. Advanced surfaces
5
+ * stay public through explicit subpaths:
6
+ * - `@zeke-02/docx-editor-react/ui`
7
+ * - `@zeke-02/docx-editor-react/dialogs`
8
+ * - `@zeke-02/docx-editor-react/hooks`
9
+ * - `@zeke-02/docx-editor-react/plugin-api`
10
+ *
11
+ * Framework-agnostic document utilities live in `@zeke-02/docx-editor-core`.
12
+ * Agent/MCP surfaces live in `@zeke-02/docx-editor-agents`.
13
+ *
14
+ * @packageDocumentation
15
+ * @public
16
+ */
17
+ import * as React from 'react';
18
+ import { ReactNode, CSSProperties } from 'react';
19
+ import * as prosemirror_view from 'prosemirror-view';
20
+ import { EditorView } from 'prosemirror-view';
21
+ import * as prosemirror_state from 'prosemirror-state';
22
+ import { EditorState, Transaction } from 'prosemirror-state';
23
+ import { Document, HeaderFooter, Theme } from '@zeke-02/docx-editor-core/types/document';
24
+ import { FontOption } from '@zeke-02/docx-editor-core/utils/fontOptions';
25
+ import { R as ReactSidebarItem } from './types-DaQbko33.js';
26
+ import { Comment } from '@zeke-02/docx-editor-core/types/content';
27
+ import { Translations, TFunction } from '@eigenpal/docx-editor-i18n';
28
+ import { P as PrintOptions } from './PrintPreview-DEhwRBC_.js';
29
+ import { DocumentAgent } from '@zeke-02/docx-editor-core/agent';
30
+ import { DocxInput, FontDefinition } from '@zeke-02/docx-editor-core/utils';
31
+ import { SelectionState } from '@zeke-02/docx-editor-core/prosemirror';
32
+ import { Layout } from '@zeke-02/docx-editor-core/layout-engine';
33
+ import { RenderedDomContext } from '@zeke-02/docx-editor-core/plugin-api';
34
+ import { EditorHandle } from '@zeke-02/docx-editor-core';
35
+ export { CreateEmptyDocumentOptions, createDocumentWithText, createEmptyDocument } from '@zeke-02/docx-editor-core';
36
+ import * as react_jsx_runtime from 'react/jsx-runtime';
37
+
38
+ /**
39
+ * Options for the agent panel mount on the right side of the editor.
40
+ *
41
+ * Three control patterns:
42
+ * - **Uncontrolled**: `agentPanel={{ render }}` — toolbar button + panel
43
+ * close button toggle the panel. Width persists to localStorage.
44
+ * - **Controlled**: `agentPanel={{ render, open, onOpenChange }}` — the
45
+ * consumer owns open state (e.g. tied to a global menu).
46
+ * - **Headless**: omit `agentPanel`, use the toolkit directly via
47
+ * `useDocxAgentTools` — render the panel anywhere you want.
48
+ */
49
+ interface AgentPanelOptions {
50
+ /** Render-prop returning the panel content. Called only when open. */
51
+ render: (ctx: {
52
+ close: () => void;
53
+ }) => ReactNode;
54
+ /** Controlled open state. Omit for uncontrolled. */
55
+ open?: boolean;
56
+ /** Fires when toolbar button or panel close button is clicked. */
57
+ onOpenChange?: (open: boolean) => void;
58
+ /** Show the toolbar toggle button. Default: true. */
59
+ showToolbarButton?: boolean;
60
+ /** Optional badge / dot on the toolbar button. */
61
+ toolbarBadge?: ReactNode;
62
+ /** Optional panel title. Default: t('agentPanel.defaultTitle'). */
63
+ title?: string;
64
+ /** Optional panel header icon. Default: sparkle. */
65
+ icon?: ReactNode;
66
+ /** Initial panel width in px (uncontrolled). Default: 360. */
67
+ defaultWidth?: number;
68
+ /** Min drag width. Default: 280. */
69
+ minWidth?: number;
70
+ /** Max drag width. Default: 600. */
71
+ maxWidth?: number;
72
+ }
73
+
74
+ interface PagedEditorRef {
75
+ /** Get the current document. */
76
+ getDocument(): Document | null;
77
+ /** Get the ProseMirror EditorState. */
78
+ getState(): EditorState | null;
79
+ /** Get the ProseMirror EditorView. */
80
+ getView(): EditorView | null;
81
+ /** Focus the editor. */
82
+ focus(): void;
83
+ /** Blur the editor. */
84
+ blur(): void;
85
+ /** Check if focused. */
86
+ isFocused(): boolean;
87
+ /** Dispatch a transaction. */
88
+ dispatch(tr: Transaction): void;
89
+ /** Undo. */
90
+ undo(): boolean;
91
+ /** Redo. */
92
+ redo(): boolean;
93
+ /** Set selection by PM position. */
94
+ setSelection(anchor: number, head?: number): void;
95
+ /** Get current layout. */
96
+ getLayout(): Layout | null;
97
+ /** Force re-layout. */
98
+ relayout(): void;
99
+ /** Scroll the visible pages to bring a PM position into view. */
100
+ scrollToPosition(pmPos: number): void;
101
+ /**
102
+ * Scroll to the paragraph identified by Word `w14:paraId` / PM `paraId`.
103
+ * @returns whether a matching paragraph was found
104
+ */
105
+ scrollToParaId(paraId: string): boolean;
106
+ /**
107
+ * Scroll the paginated view so `pageNumber` (1-indexed) is in view.
108
+ * No-op if the layout isn't ready yet or pageNumber is out of range.
109
+ */
110
+ scrollToPage(pageNumber: number): void;
111
+ /**
112
+ * Look up the persistent hidden HF PM EditorView for a given HeaderFooter
113
+ * instance. Returns null when none is mounted (no document, or `hf` is not
114
+ * present in `Document.package.headers/footers`). Phase 2 of the HF
115
+ * unification: the inline overlay uses this to replicate edits into the
116
+ * persistent PM so the painter — which reads from the persistent PM per
117
+ * phase 1 — re-renders live during typing. Phase 5 deletes the inline
118
+ * overlay's PM and this method's only remaining caller is the click /
119
+ * focus router (phase 3).
120
+ */
121
+ getHfPmView(hf: HeaderFooter): EditorView | null;
122
+ }
123
+
124
+ /**
125
+ * EditorMode union + the catalog the editing-mode dropdown renders.
126
+ * Lives next to DocxEditor.tsx so the dropdown component and the parent
127
+ * forwardRef body share one source of truth.
128
+ */
129
+
130
+ type EditorMode = 'editing' | 'suggesting' | 'viewing';
131
+
132
+ /**
133
+ * DocxEditor props
134
+ */
135
+ interface DocxEditorProps {
136
+ /** Document data — ArrayBuffer, Uint8Array, Blob, or File */
137
+ documentBuffer?: DocxInput | null;
138
+ /** Pre-parsed document (alternative to documentBuffer) */
139
+ document?: Document | null;
140
+ /** Callback when document is saved */
141
+ onSave?: (buffer: ArrayBuffer) => void;
142
+ /** Author name used for comments and track changes */
143
+ author?: string;
144
+ /** Callback when document changes */
145
+ onChange?: (document: Document) => void;
146
+ /** Callback when selection changes */
147
+ onSelectionChange?: (state: SelectionState | null) => void;
148
+ /** Callback on error */
149
+ onError?: (error: Error) => void;
150
+ /** Callback when fonts are loaded */
151
+ onFontsLoaded?: () => void;
152
+ /** External ProseMirror plugins (from PluginHost) */
153
+ externalPlugins?: prosemirror_state.Plugin[];
154
+ /**
155
+ * When true, the editor treats the `document` prop as a schema seed only and
156
+ * does not load it into ProseMirror on mount. Content is expected to come from
157
+ * external sources — typically `externalPlugins` such as `ySyncPlugin` from
158
+ * `y-prosemirror`, but also any code that dispatches transactions directly.
159
+ *
160
+ * You must still pass a `document` prop (e.g., `createEmptyDocument()`) so the
161
+ * editor can build its schema and render the shell.
162
+ */
163
+ externalContent?: boolean;
164
+ /** Callback when editor view is ready (for PluginHost) */
165
+ onEditorViewReady?: (view: prosemirror_view.EditorView) => void;
166
+ /** Theme for styling */
167
+ theme?: Theme | null;
168
+ /** Whether to show toolbar (default: true) */
169
+ showToolbar?: boolean;
170
+ /** Whether to show zoom control (default: true) */
171
+ showZoomControl?: boolean;
172
+ /** Whether to show the comments sidebar toggle in the toolbar (default: true) */
173
+ showCommentsSidebarToggle?: boolean;
174
+ /** Whether to show the editing-mode dropdown in the toolbar (default: true) */
175
+ showModeSwitcher?: boolean;
176
+ /** Whether to show the print button in the toolbar (default: true when `onPrint` is provided) */
177
+ showPrintButton?: boolean;
178
+ /** Whether to show page margin guides/boundaries (default: false) */
179
+ showMarginGuides?: boolean;
180
+ /** Color for margin guides (default: '#c0c0c0') */
181
+ marginGuideColor?: string;
182
+ /** Whether to show horizontal ruler (default: false) */
183
+ showRuler?: boolean;
184
+ /** Unit for ruler display (default: 'inch') */
185
+ rulerUnit?: 'inch' | 'cm';
186
+ /** Initial zoom level (default: 1.0) */
187
+ initialZoom?: number;
188
+ /** Whether the editor is read-only. When true, hides toolbar and rulers */
189
+ readOnly?: boolean;
190
+ /**
191
+ * When true, the editor does not intercept Cmd/Ctrl+F or Cmd/Ctrl+H.
192
+ * This lets the browser or host app handle native find/history shortcuts.
193
+ */
194
+ disableFindReplaceShortcuts?: boolean;
195
+ /** Custom toolbar actions */
196
+ toolbarExtra?: ReactNode;
197
+ /** Additional CSS class name */
198
+ className?: string;
199
+ /** Additional inline styles */
200
+ style?: CSSProperties;
201
+ /** Placeholder when no document */
202
+ placeholder?: ReactNode;
203
+ /** Loading indicator */
204
+ loadingIndicator?: ReactNode;
205
+ /** Whether to show the document outline sidebar (default: false) */
206
+ showOutline?: boolean;
207
+ /** Whether to show the floating outline toggle button (default: true) */
208
+ showOutlineButton?: boolean;
209
+ /**
210
+ * Custom list of fonts shown in the toolbar's font-family dropdown.
211
+ * Strings render in the "Other" group; pass `FontOption[]` for category
212
+ * grouping and CSS fallback chains. Omit to use the built-in 12-font
213
+ * default. An empty array renders an empty (but enabled) dropdown.
214
+ *
215
+ * Pass a stable reference (memoized or module-level) — inline arrays
216
+ * create a new identity per render and invalidate the picker's memo.
217
+ *
218
+ * @example fontFamilies={['Arial', 'Roboto']}
219
+ * @example fontFamilies={[{ name: 'Roboto', fontFamily: 'Roboto, sans-serif', category: 'sans-serif' }]}
220
+ */
221
+ fontFamilies?: ReadonlyArray<string | FontOption>;
222
+ /**
223
+ * Custom font faces to register with the browser before the editor measures
224
+ * text. Each entry injects an `@font-face` rule. Pass a URL (woff2/woff/
225
+ * ttf/otf), an ArrayBuffer, or omit `src` to load by name from Google Fonts.
226
+ * Multiple entries can share `family` to register different weights/styles.
227
+ *
228
+ * Pass a stable reference — inline arrays re-register faces on each render
229
+ * (the loader dedupes by `family|weight|style`, so it's harmless but wastes
230
+ * work).
231
+ *
232
+ * @example
233
+ * fonts={[
234
+ * { family: 'Custom Sans', src: '/fonts/CustomSans-Regular.woff2' },
235
+ * { family: 'Custom Sans', src: '/fonts/CustomSans-Bold.woff2', weight: 700 },
236
+ * ]}
237
+ */
238
+ fonts?: ReadonlyArray<FontDefinition>;
239
+ /** Print options for print preview */
240
+ printOptions?: PrintOptions;
241
+ /**
242
+ * Callback when print is triggered. Pass it to enable the `File > Print`
243
+ * menu entry; omit to hide. The imperative `ref.current.print()` also
244
+ * invokes this callback.
245
+ */
246
+ onPrint?: () => void;
247
+ /** Callback when content is copied */
248
+ onCopy?: () => void;
249
+ /** Callback when content is cut */
250
+ onCut?: () => void;
251
+ /** Callback when content is pasted */
252
+ onPaste?: () => void;
253
+ /** Editor mode: 'editing' (direct edits), 'suggesting' (track changes), or 'viewing' (read-only). Default: 'editing' */
254
+ mode?: EditorMode;
255
+ /** Callback when the editing mode changes */
256
+ onModeChange?: (mode: EditorMode) => void;
257
+ /** Callback when a comment is added via the UI */
258
+ onCommentAdd?: (comment: Comment) => void;
259
+ /** Callback when a comment is resolved via the UI */
260
+ onCommentResolve?: (comment: Comment) => void;
261
+ /** Callback when a comment is deleted via the UI */
262
+ onCommentDelete?: (comment: Comment) => void;
263
+ /** Callback when a reply is added to a comment via the UI */
264
+ onCommentReply?: (reply: Comment, parent: Comment) => void;
265
+ /**
266
+ * Controlled comments array. When provided, the editor reads comment thread
267
+ * metadata (text, author, replies, resolved status) from this prop instead
268
+ * of internal state, and emits every change through `onCommentsChange`.
269
+ *
270
+ * Use this with collaboration backends (Yjs, Liveblocks, Automerge, …) so
271
+ * comment threads sync across peers — the PM document only carries the
272
+ * range markers; thread metadata lives outside the doc and needs its own
273
+ * sync channel.
274
+ *
275
+ * If omitted, the editor falls back to internal state (current behavior).
276
+ * The granular `onCommentAdd`/`onCommentResolve`/`onCommentDelete`/
277
+ * `onCommentReply` callbacks fire in both modes.
278
+ */
279
+ comments?: Comment[];
280
+ /** Fires whenever the comments array changes (controlled mode). */
281
+ onCommentsChange?: (comments: Comment[]) => void;
282
+ /**
283
+ * Callback when rendered DOM context is ready (for plugin overlays).
284
+ * Used by PluginHost to get access to the rendered page DOM for positioning.
285
+ */
286
+ onRenderedDomContextReady?: (context: RenderedDomContext) => void;
287
+ /**
288
+ * Plugin overlays to render inside the editor viewport.
289
+ * Passed from PluginHost to render plugin-specific overlays.
290
+ */
291
+ pluginOverlays?: ReactNode;
292
+ /** Sidebar items from plugins (passed from PluginHost). */
293
+ pluginSidebarItems?: ReactSidebarItem[];
294
+ /** Rendered DOM context from PluginHost (for sidebar position resolution). */
295
+ pluginRenderedDomContext?: RenderedDomContext | null;
296
+ /** Custom logo/icon for the title bar */
297
+ renderLogo?: () => ReactNode;
298
+ /** Document name shown in the title bar */
299
+ documentName?: string;
300
+ /** Callback when document name changes */
301
+ onDocumentNameChange?: (name: string) => void;
302
+ /** Whether the document name is editable (default: true) */
303
+ documentNameEditable?: boolean;
304
+ /** Custom right-side actions for the title bar */
305
+ renderTitleBarRight?: () => ReactNode;
306
+ /** Translation overrides. Import a locale JSON file and pass it directly. */
307
+ i18n?: Translations;
308
+ /**
309
+ * Mount a controllable agent panel on the right side of the editor. The
310
+ * panel is the chrome (header, close button, drag-resize); the consumer
311
+ * supplies whatever content goes inside via `render` — typically a chat
312
+ * UI from `@ai-sdk/react`'s `useChat`, `assistant-ui`, or any other
313
+ * framework. We do not ship message bubbles, a composer, or a chat engine.
314
+ *
315
+ * Three control patterns:
316
+ * - **Uncontrolled**: `agentPanel={{ render }}` — toolbar button + panel
317
+ * close button toggle the panel. Width persists to localStorage.
318
+ * - **Controlled**: `agentPanel={{ render, open, onOpenChange }}` — the
319
+ * consumer owns open state (e.g. tied to a global menu).
320
+ * - **Headless**: omit `agentPanel`, use the toolkit directly via
321
+ * `useDocxAgentTools` — render the panel anywhere you want.
322
+ */
323
+ agentPanel?: AgentPanelOptions;
324
+ }
325
+ /**
326
+ * DocxEditor ref interface
327
+ */
328
+ interface DocxEditorRef {
329
+ /** Get the DocumentAgent for programmatic access */
330
+ getAgent: () => DocumentAgent | null;
331
+ /** Get the current document */
332
+ getDocument: () => Document | null;
333
+ /** Get the editor ref */
334
+ getEditorRef: () => PagedEditorRef | null;
335
+ /** Save the document to buffer. Pass { selective: false } to force full repack. */
336
+ save: (options?: {
337
+ selective?: boolean;
338
+ }) => Promise<ArrayBuffer | null>;
339
+ /** Set zoom level */
340
+ setZoom: (zoom: number) => void;
341
+ /** Get current zoom level */
342
+ getZoom: () => number;
343
+ /** Focus the editor */
344
+ focus: () => void;
345
+ /** Get current page number */
346
+ getCurrentPage: () => number;
347
+ /** Get total page count */
348
+ getTotalPages: () => number;
349
+ /**
350
+ * Scroll the paginated view so the given page is in view.
351
+ * Page numbers are 1-indexed (matches `getCurrentPage` / `getTotalPages`).
352
+ * No-op for out-of-range or non-integer values.
353
+ * @example ref.current?.scrollToPage(2)
354
+ */
355
+ scrollToPage: (pageNumber: number) => void;
356
+ /**
357
+ * Scroll the paginated view to the paragraph with the given Word `w14:paraId`.
358
+ * @returns whether a matching paragraph exists in the ProseMirror document
359
+ * @example ref.current?.scrollToParaId('1A2B3C4D')
360
+ */
361
+ scrollToParaId: (paraId: string) => boolean;
362
+ /**
363
+ * Scroll the paginated view to a specific ProseMirror document position.
364
+ * Use this when you have a raw PM offset; for Word `w14:paraId` use
365
+ * `scrollToParaId` instead.
366
+ * @example ref.current?.scrollToPosition(42)
367
+ */
368
+ scrollToPosition: (pmPos: number) => void;
369
+ /** Open print preview */
370
+ openPrintPreview: () => void;
371
+ /** Print the document directly */
372
+ print: () => void;
373
+ /** Load a pre-parsed document programmatically */
374
+ loadDocument: (doc: Document) => void;
375
+ /** Load a DOCX buffer programmatically (ArrayBuffer, Uint8Array, Blob, or File) */
376
+ loadDocumentBuffer: (buffer: DocxInput) => Promise<void>;
377
+ /**
378
+ * Replace the editor's content with a programmatically-modified `Document`,
379
+ * preserving undo/redo and the existing PM view. Use this when an external
380
+ * agent (or plugin) has mutated the `Document` object and needs the editor
381
+ * to reflect those changes without a full reload.
382
+ * Returns false if the editor view is not yet mounted.
383
+ */
384
+ applyDocumentChanges: (doc: Document) => boolean;
385
+ /** Add a comment programmatically. Anchored by Word `w14:paraId` so
386
+ * it survives unrelated edits. Returns the comment ID, or null if
387
+ * the paraId is unknown or the search text isn't found / is ambiguous. */
388
+ addComment: (options: {
389
+ paraId: string;
390
+ text: string;
391
+ author: string;
392
+ /** Optional: anchor to a specific phrase within the paragraph (must be unique). */
393
+ search?: string;
394
+ }) => number | null;
395
+ /** Reply to an existing comment. Returns the reply comment ID. */
396
+ replyToComment: (commentId: number, text: string, author: string) => number | null;
397
+ /** Resolve (mark as done) a comment. */
398
+ resolveComment: (commentId: number) => void;
399
+ /** Suggest a tracked change. Pass `replaceWith: ''` to delete the matched text;
400
+ * pass `search: ''` to insert at paragraph end. Returns false on missing paraId,
401
+ * missing/ambiguous search, or attempt to layer on an existing tracked change. */
402
+ proposeChange: (options: {
403
+ paraId: string;
404
+ search: string;
405
+ replaceWith: string;
406
+ author: string;
407
+ }) => boolean;
408
+ /** Locate every paragraph containing `query` (case-insensitive substring).
409
+ * Returns a stable handle (paraId + the matched phrase) the agent can pass
410
+ * back to `addComment` / `proposeChange`. */
411
+ findInDocument: (query: string, options?: {
412
+ caseSensitive?: boolean;
413
+ limit?: number;
414
+ }) => Array<{
415
+ paraId: string;
416
+ match: string;
417
+ before: string;
418
+ after: string;
419
+ }>;
420
+ /**
421
+ * Apply character formatting (bold / italic / color / size / font / etc.)
422
+ * to a paragraph or to a unique phrase within it. This is a direct edit,
423
+ * not a tracked change. Returns false on missing paraId or ambiguous search.
424
+ */
425
+ applyFormatting: (options: {
426
+ paraId: string;
427
+ search?: string;
428
+ marks: {
429
+ bold?: boolean;
430
+ italic?: boolean;
431
+ underline?: boolean | {
432
+ style?: string;
433
+ };
434
+ strike?: boolean;
435
+ color?: {
436
+ rgb?: string;
437
+ themeColor?: string;
438
+ };
439
+ highlight?: string;
440
+ fontSize?: number;
441
+ fontFamily?: {
442
+ ascii?: string;
443
+ hAnsi?: string;
444
+ };
445
+ };
446
+ }) => boolean;
447
+ /**
448
+ * Apply a paragraph style by styleId (e.g. `'Heading1'`, `'Quote'`).
449
+ * Direct edit, not a tracked change. Returns false if paraId is unknown.
450
+ */
451
+ setParagraphStyle: (options: {
452
+ paraId: string;
453
+ styleId: string;
454
+ }) => boolean;
455
+ /**
456
+ * Read the contents of a single page. 1-indexed; returns null if the page
457
+ * does not exist. Each paragraph is returned with its stable paraId so the
458
+ * agent can comment on or modify it without an extra round-trip.
459
+ */
460
+ getPageContent: (pageNumber: number) => {
461
+ pageNumber: number;
462
+ text: string;
463
+ paragraphs: Array<{
464
+ paraId: string;
465
+ text: string;
466
+ styleId?: string;
467
+ }>;
468
+ } | null;
469
+ /** Read the user's current cursor / selection — what's highlighted right now. */
470
+ getSelectionInfo: () => {
471
+ paraId: string | null;
472
+ selectedText: string;
473
+ paragraphText: string;
474
+ before: string;
475
+ after: string;
476
+ } | null;
477
+ /** Get all comments. */
478
+ getComments: () => Comment[];
479
+ /** Subscribe to document changes. Fires after every committed edit. Returns unsubscribe. */
480
+ onContentChange: (listener: (document: Document) => void) => () => void;
481
+ /** Subscribe to selection changes (cursor moves / selection changes). Returns unsubscribe. */
482
+ onSelectionChange: (listener: (selection: SelectionState | null) => void) => () => void;
483
+ }
484
+
485
+ /**
486
+ * DocxEditor - Complete DOCX editor component
487
+ */
488
+ declare const DocxEditor: React.ForwardRefExoticComponent<DocxEditorProps & React.RefAttributes<DocxEditorRef>>;
489
+
490
+ /**
491
+ * Simple imperative API for rendering a DOCX editor into a DOM element.
492
+ *
493
+ * Returns an `EditorHandle` (from @zeke-02/docx-editor-core) that works with
494
+ * any framework implementation.
495
+ *
496
+ * Usage:
497
+ * ```ts
498
+ * import { renderAsync } from '@zeke-02/docx-editor-react';
499
+ *
500
+ * const editor = await renderAsync(docxBlob, document.getElementById('container'), {
501
+ * readOnly: false,
502
+ * showToolbar: true,
503
+ * });
504
+ *
505
+ * // Save the edited document
506
+ * const blob = await editor.save();
507
+ *
508
+ * // Clean up
509
+ * editor.destroy();
510
+ * ```
511
+ */
512
+
513
+ /**
514
+ * Options for {@link renderAsync}. A subset of DocxEditorProps minus
515
+ * `documentBuffer` / `document` (passed as the first argument instead).
516
+ */
517
+ type RenderAsyncOptions = Omit<DocxEditorProps, 'documentBuffer' | 'document'>;
518
+ /**
519
+ * React-specific handle that extends the framework-agnostic EditorHandle
520
+ * with zoom control.
521
+ */
522
+ interface DocxEditorHandle extends EditorHandle {
523
+ /** Set zoom level (1.0 = 100%). */
524
+ setZoom: (zoom: number) => void;
525
+ /** Scroll to a body paragraph by Word `w14:paraId`. */
526
+ scrollToParaId: (paraId: string) => boolean;
527
+ /** Scroll to a raw ProseMirror document position. */
528
+ scrollToPosition: (pmPos: number) => void;
529
+ }
530
+ /**
531
+ * Render a DOCX editor into a container element.
532
+ *
533
+ * @param input - DOCX data as ArrayBuffer, Uint8Array, Blob, or File
534
+ * @param container - DOM element to render into
535
+ * @param options - Editor configuration (toolbar, readOnly, callbacks, etc.)
536
+ * @returns A handle with save / destroy / getDocument methods
537
+ */
538
+ declare function renderAsync(input: DocxInput, container: HTMLElement, options?: RenderAsyncOptions): Promise<DocxEditorHandle>;
539
+
540
+ interface LocaleProviderProps {
541
+ i18n?: Translations;
542
+ children: ReactNode;
543
+ }
544
+ declare function LocaleProvider({ i18n, children }: LocaleProviderProps): react_jsx_runtime.JSX.Element;
545
+ declare function useTranslation(): {
546
+ t: TFunction;
547
+ };
548
+
549
+ /**
550
+ * @zeke-02/docx-editor-react
551
+ *
552
+ * Curated root entry for the documented React editor API. Advanced surfaces
553
+ * stay public through explicit subpaths:
554
+ * - `@zeke-02/docx-editor-react/ui`
555
+ * - `@zeke-02/docx-editor-react/dialogs`
556
+ * - `@zeke-02/docx-editor-react/hooks`
557
+ * - `@zeke-02/docx-editor-react/plugin-api`
558
+ *
559
+ * Framework-agnostic document utilities live in `@zeke-02/docx-editor-core`.
560
+ * Agent/MCP surfaces live in `@zeke-02/docx-editor-agents`.
561
+ *
562
+ * @packageDocumentation
563
+ * @public
564
+ */
565
+ declare const VERSION = "0.0.2";
566
+
567
+ export { DocxEditor, type DocxEditorHandle, type DocxEditorProps, type DocxEditorRef, type EditorMode, LocaleProvider, type LocaleProviderProps, type RenderAsyncOptions, VERSION, renderAsync, useTranslation };