revise 3.1.6 → 4.0.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 (91) hide show
  1. package/CHANGELOG.md +1680 -168
  2. package/FONT-LICENSE-HAN-EXT-B.txt +91 -0
  3. package/FONT-LICENSE-KATEX.txt +95 -0
  4. package/FONT-LICENSE-LIBERATION.txt +102 -0
  5. package/FONT-LICENSE-NOTO-MULTILINGUAL.txt +93 -0
  6. package/FONT-LICENSE-NOTO-SANS-SC.txt +93 -0
  7. package/FONT-LICENSE-NOTO.txt +94 -0
  8. package/FONT-LICENSE-SOURCE-CODE-PRO.txt +94 -0
  9. package/FONT-LICENSE-SOURCE-SERIF-4.txt +93 -0
  10. package/LICENSE +41 -21
  11. package/README.md +32 -119
  12. package/THIRD-PARTY-NOTICES.md +2751 -0
  13. package/assets/historyMaterializeWorker-ZFUHJDWr.js +619 -0
  14. package/chunks/AgentPageRenderer-5mZ6fxqO.js +1 -0
  15. package/chunks/AgentPageRenderer-C3jIBoeM.js +1 -0
  16. package/chunks/AttachmentDocumentImporter-CXkM4VoT.js +1 -0
  17. package/chunks/AttachmentDocumentImporter-Kox5By7a.js +1 -0
  18. package/chunks/ColorParserFull-BKH72fK8.js +446 -0
  19. package/chunks/DocumentScrubber-BxmlzNNz.js +1 -0
  20. package/chunks/DocumentScrubber-wmjRnX7C.js +1 -0
  21. package/chunks/DocxConverter-BH3E7nfQ.js +13 -0
  22. package/chunks/DocxConverter-DEHGCdib.js +13 -0
  23. package/chunks/DocxGraft-BMvTAnGi.js +1 -0
  24. package/chunks/DocxGraft-V2YXiUmK.js +1 -0
  25. package/chunks/FileImporter-CtX8ZPjV.js +1 -0
  26. package/chunks/FileImporter-Da-7eRh3.js +1 -0
  27. package/chunks/OdtConverter-CMkSeU8e.js +6 -0
  28. package/chunks/OdtConverter-DV94rkDL.js +6 -0
  29. package/chunks/OfficeImportShared-CA3dia_A.js +1 -0
  30. package/chunks/OfficeImportShared-hxIa69By.js +1 -0
  31. package/chunks/PdfConverter-B-uRwLux.js +21 -0
  32. package/chunks/PdfConverter-B8J_5yim.js +21 -0
  33. package/chunks/PdfImportService-BjQ4rl-Z.js +2 -0
  34. package/chunks/PdfImportService-RtFCP6hh.js +2 -0
  35. package/chunks/RtfConverter-CFDnUApT.js +15 -0
  36. package/chunks/RtfConverter-CpJGtC5U.js +15 -0
  37. package/chunks/XmlConverter-CQCrgTf7.js +2 -0
  38. package/chunks/XmlConverter-CePTE21k.js +2 -0
  39. package/chunks/__vite-browser-external-l0sNRNKZ.js +0 -0
  40. package/chunks/_revise-sdk-lazy-harfbuzz-X8gnYTZL.js +1 -0
  41. package/chunks/ar-vDYSGTpE.js +13 -0
  42. package/chunks/browser-module-B-uafDG6.js +3 -0
  43. package/chunks/browser-module-jwkhffzv.js +3 -0
  44. package/chunks/bundle.min-DRpfgV69.js +782 -0
  45. package/chunks/de-CWX4cvtt.js +13 -0
  46. package/chunks/es-DoAhvF6_.js +13 -0
  47. package/chunks/fil-DdAeD8Br.js +13 -0
  48. package/chunks/fr-CazsUjNQ.js +13 -0
  49. package/chunks/html2canvas.esm-CntiHiYW.js +997 -0
  50. package/chunks/index-BWdRWxoH.js +1807 -0
  51. package/chunks/index-C7VhCKXe.js +402 -0
  52. package/chunks/index-p6UytRm8.js +402 -0
  53. package/chunks/ja-alh_QHTB.js +13 -0
  54. package/chunks/jspdf.es.min-BuJNZ-oY.js +1882 -0
  55. package/chunks/katex-DWj8TvwO.js +1462 -0
  56. package/chunks/pdf-BLWDCiFF.js +1828 -0
  57. package/chunks/persistInlineDocumentImages-DQj2iaqg.js +1 -0
  58. package/chunks/pseudoLocale-Bkzfsfiw.js +1 -0
  59. package/chunks/pseudoLocale-D-AfwRwa.js +1 -0
  60. package/chunks/tree-sitter-D6zWWUMP.js +4 -0
  61. package/chunks/wasmInline.generated-CBYFkdSM.js +1 -0
  62. package/chunks/web-tree-sitter-BXGZGnNj.js +2 -0
  63. package/chunks/zh-20eXwzFZ.js +13 -0
  64. package/cli-shim.js +34 -0
  65. package/full.js +1 -0
  66. package/index.d.ts +995 -13
  67. package/index.js +1 -31
  68. package/legacy/server.d.ts +19 -19
  69. package/legacy/server.js +39 -23
  70. package/package.json +55 -45
  71. package/serverToolContract.d.ts +420 -0
  72. package/serverToolInputs.generated.d.ts +269 -0
  73. package/style.css +1 -0
  74. package/version.d.ts +4 -0
  75. package/version.js +2 -0
  76. package/agent.d.ts +0 -139
  77. package/chunks/chunk-SMTOJL2X.js +0 -2436
  78. package/chunks/chunk-U5X47PZ6.js +0 -135
  79. package/chunks/chunk-U6YKQBKL.js +0 -15
  80. package/chunks/package-5SHL5FOJ.js +0 -14
  81. package/chunks/render-QD5VWKSV.js +0 -109
  82. package/cli-output.schema.json +0 -2159
  83. package/cli.js +0 -4152
  84. package/document.d.ts +0 -439
  85. package/docx.d.ts +0 -73
  86. package/errors.d.ts +0 -14
  87. package/legacy/editor.d.ts +0 -19
  88. package/legacy/editor.js +0 -16
  89. package/legacy/style.css +0 -2
  90. package/package.d.ts +0 -23
  91. package/render.d.ts +0 -27
package/index.d.ts CHANGED
@@ -1,17 +1,999 @@
1
+ import * as React from "react";
2
+ // The canonical tool contract, shared verbatim with the backend entry: the
3
+ // browser surface returns the same envelopes and throws the same error.
4
+ import type {
5
+ ReviseHostToolInput,
6
+ ReviseSuggestionDecision,
7
+ ReviseToolName,
8
+ ReviseToolResponse,
9
+ ReviseToolResult,
10
+ } from "./serverToolContract.js";
11
+ export type * from "./serverToolContract.js";
12
+
13
+ export declare class ReviseToolError<Name extends string = string> extends Error {
14
+ readonly failure: import("./serverToolContract.js").ReviseToolFailure<Name>;
15
+ readonly callId: string;
16
+ readonly tool: Name;
17
+ readonly code: string;
18
+ constructor(failure: import("./serverToolContract.js").ReviseToolFailure<Name>);
19
+ }
20
+
21
+ /** The version of this package, at runtime. Include it when you escalate. */
22
+ export declare const REVISE_SDK_VERSION: string;
23
+
24
+ /** The commit this bundle was built from. Empty in a development build. */
25
+ export declare const REVISE_SDK_BUILD: string;
26
+
27
+ export interface ReviseDocument {
28
+ type: "doc";
29
+ children: unknown[];
30
+ [key: string]: unknown;
31
+ }
32
+
33
+ export interface EditorUserIdentity {
34
+ id?: string;
35
+ name?: string;
36
+ email?: string;
37
+ image?: string;
38
+ /** Caret and presence color. Any CSS color. Without one, a stable color
39
+ * is derived from the id. */
40
+ color?: string;
41
+ }
42
+
43
+ export interface ReviseAgentMessage {
44
+ role: string;
45
+ content: string;
46
+ timestamp?: number;
47
+ toolName?: string;
48
+ incomplete?: boolean;
49
+ [key: string]: unknown;
50
+ }
51
+
52
+ export interface ReviseAgentTurnRequest {
53
+ prompt: string;
54
+ currentDocument: ReviseDocument;
55
+ currentTurn: number;
56
+ config: Record<string, unknown>;
57
+ [key: string]: unknown;
58
+ }
59
+
60
+ export interface ReviseAgentStreamEvent {
61
+ type: "text" | "tool_call" | "tool_result" | "tool_start" | "usage" | "error" | "done" | "request_mode" | "web_search" | "reasoning" | "history_repair";
62
+ data: any;
63
+ }
64
+
65
+ export type ReviseAgentTurnStream = (
66
+ request: ReviseAgentTurnRequest,
67
+ ) => AsyncGenerator<ReviseAgentStreamEvent, void, unknown>;
68
+
69
+ /** Where agent work goes, and how it is signed. Configure one transport —
70
+ * `turnStream`, `baseUrl`, or `token` — or agent runs fail fast with
71
+ * `agent_not_configured` and send nothing. */
72
+ export interface ReviseAgentConfig {
73
+ /** Display name for comments and tracked changes made through
74
+ * `tools.execute` and agent runs. Defaults to "Revise Agent". */
75
+ name?: string;
76
+ /** Your own Revise agent backend. Without it, runs go to Revise's hosted
77
+ * agent, which needs a `token`. */
78
+ baseUrl?: string;
79
+ /** Bearer token. Required for Revise's hosted agent; an anonymous
80
+ * `baseUrl` backend needs none. */
81
+ token?: string;
82
+ conversationId?: string;
83
+ provider?: string;
84
+ model?: string;
85
+ /** Run turns through your own model or gateway. Changing it takes effect on
86
+ * the next run, without reopening the document. */
87
+ turnStream?: ReviseAgentTurnStream;
88
+ /** Skip the run-completion call (cost accounting) to the agent backend at
89
+ * `baseUrl`. Implied by `turnStream`. */
90
+ disableMetrics?: boolean;
91
+ }
92
+
93
+ export interface ReviseAgentEvent {
94
+ state: "idle" | "streaming" | "complete" | "error";
95
+ activeTool: string | null;
96
+ status: string | null;
97
+ error?: string;
98
+ messages: ReviseAgentMessage[];
99
+ }
100
+
101
+ export interface ReviseAgentRunOptions {
102
+ /** Narrows host authority for this run; cannot raise it. */
103
+ executionPolicy?: {
104
+ documentAccess: "read" | "comment" | "edit";
105
+ interaction: "interactive" | "best_effort";
106
+ allowedTools?: readonly string[] | null;
107
+ };
108
+ developerPrePrompt?: string;
109
+ allowedToolNames?: string[];
110
+ providerOverride?: string;
111
+ modelOverride?: string;
112
+ forceFirstTurnNoTools?: boolean;
113
+ attachments?: unknown[];
114
+ directMode?: boolean;
115
+ }
116
+
117
+ export interface ReviseAgentRunResult extends ReviseAgentEvent {
118
+ actionCount: number;
119
+ }
120
+
121
+ export interface ReviseEditorToolDefinition {
122
+ name: string;
123
+ description: string;
124
+ inputSchema: Record<string, unknown>;
125
+ }
126
+
127
+ export interface ReviseEditorToolExecutionOptions {
128
+ /** Target an open document. Omit to use the active document. */
129
+ documentId?: string;
130
+ /** Apply mutation tools directly instead of leaving tracked suggestions. */
131
+ directMode?: boolean;
132
+ }
133
+
134
+ /** Tool arguments, with input optional only when its schema has no required
135
+ * fields — the browser twin of the server contract's argument tuple. */
136
+ /** Typed host arguments. `context_notes` is optional here and defaults to
137
+ * "N/A"; `executeDynamic()`, for model-provided calls, still requires it. */
138
+ export type ReviseEditorToolArguments<Name extends ReviseToolName> =
139
+ Record<string, never> extends ReviseHostToolInput<Name>
140
+ ? [input?: ReviseHostToolInput<Name>, options?: ReviseEditorToolExecutionOptions]
141
+ : [input: ReviseHostToolInput<Name>, options?: ReviseEditorToolExecutionOptions];
142
+
143
+ export interface ReviseEditorTool extends ReviseEditorToolDefinition {
144
+ execute(
145
+ input?: Record<string, unknown>,
146
+ options?: ReviseEditorToolExecutionOptions,
147
+ ): Promise<ReviseToolResult<string>>;
148
+ }
149
+
150
+ /** The document tool surface. Speaks the same contract as
151
+ * the backend entry: the same discriminated result envelope, the
152
+ * same typed inputs, the same execute/executeDynamic/call split. */
153
+ export interface ReviseEditorTools {
154
+ /** Execute a known tool; expected failures come back as { ok: false }. */
155
+ execute<Name extends ReviseToolName>(
156
+ name: Name,
157
+ ...args: ReviseEditorToolArguments<Name>
158
+ ): Promise<ReviseToolResult<Name>>;
159
+ /** Execute an untrusted model-provided name and JSON input; also the door
160
+ * to browser-only tools (get_selection, view_image, revise_run_agent) and
161
+ * model-facing document_id routing. */
162
+ executeDynamic(
163
+ name: string,
164
+ input?: Record<string, unknown>,
165
+ options?: ReviseEditorToolExecutionOptions,
166
+ ): Promise<ReviseToolResult<string>>;
167
+ /** Returns only the successful response and throws ReviseToolError when
168
+ * the tool rejects the call. */
169
+ call<Name extends ReviseToolName>(
170
+ name: Name,
171
+ ...args: ReviseEditorToolArguments<Name>
172
+ ): Promise<ReviseToolResponse<Name>>;
173
+ getDefinitions(): ReviseEditorToolDefinition[];
174
+ exportDocx(): Promise<Blob>;
175
+ /**
176
+ * Export the document as a file. `format` defaults to "docx". In
177
+ * "review" mode (the default) a .docx keeps pending tracked changes and
178
+ * comments; other formats show the text with changes accepted. "final"
179
+ * accepts every pending change and drops comments first: a clean copy.
180
+ */
181
+ export(options?: ReviseExportOptions): Promise<Blob>;
182
+ /** Settle every open suggestion, collaborators' included. Prefer ID-based
183
+ * review.acceptSuggestions() with IDs from mutation results. */
184
+ acceptAllSuggestions(): ReviseSuggestionDecision;
185
+ rejectAllSuggestions(): ReviseSuggestionDecision;
186
+ }
187
+
188
+ export interface ReviseAgentSubagent {
189
+ run(task: string, options?: ReviseAgentRunOptions): Promise<ReviseAgentRunResult>;
190
+ steer(message: string): boolean;
191
+ cancel(): void;
192
+ subscribe(listener: (event: ReviseAgentEvent) => void): () => void;
193
+ }
194
+
195
+ export function createEmptyDocx(title?: string): Promise<Blob>;
1
196
  /**
2
- * `revise`: read, edit, review, render, and convert documents from Node.
197
+ * Where Revise's static assets load from: PDF export and math fonts, the
198
+ * KaTeX stylesheet, the pdf.js worker, and (revise/full) Tree-sitter
199
+ * grammars. Defaults to https://revise.io. To self-host, mirror revise.io's
200
+ * fonts/, katex.min.css, pdfjs/, and tree-sitter/ at your own origin and pass
201
+ * it here; null restores the default.
202
+ */
203
+ export declare function setAssetBaseUrl(url: string | null): void;
204
+
205
+ export type ReviseCommentAgentStatus =
206
+ | "running"
207
+ | "complete"
208
+ | "error"
209
+ | "interrupted"
210
+ | "canceled";
211
+
212
+ export interface ReviseCommentAgentState {
213
+ threadId: string;
214
+ status: ReviseCommentAgentStatus;
215
+ statusText?: string;
216
+ error?: string;
217
+ relatedSuggestionIds?: string[];
218
+ updatedAt: number;
219
+ [key: string]: unknown;
220
+ }
221
+
222
+ export interface ReviseCommentAgentRunResult {
223
+ threadId: string;
224
+ status: ReviseCommentAgentStatus;
225
+ reply?: string;
226
+ relatedSuggestionIds: string[];
227
+ error?: string;
228
+ }
229
+
230
+ export interface ReviseCommentAgent {
231
+ run(threadId: string, prompt?: string): Promise<ReviseCommentAgentRunResult>;
232
+ steer(threadId: string, message: string): boolean;
233
+ cancel(threadId: string): void;
234
+ getState(threadId: string): ReviseCommentAgentState | undefined;
235
+ subscribe(
236
+ listener: (states: ReadonlyMap<string, ReviseCommentAgentState>) => void,
237
+ ): () => void;
238
+ }
239
+
240
+ export type InlineFormattingCommand =
241
+ | "bold"
242
+ | "italic"
243
+ | "underline"
244
+ | "strikethrough"
245
+ | "doubleStrikethrough"
246
+ | "smallCaps"
247
+ | "allCaps"
248
+ | "code"
249
+ | "latex"
250
+ | "superscript"
251
+ | "subscript";
252
+
253
+ /** File formats `tools.export()` can produce. */
254
+ export type ReviseExportFormat = "docx" | "pdf" | "html" | "markdown" | "txt";
255
+
256
+ export interface ReviseExportOptions {
257
+ format?: ReviseExportFormat;
258
+ mode?: "review" | "final";
259
+ }
260
+
261
+ export type ReviseToolbarMode = "native" | "compact" | "floating" | "none";
262
+ export type ReviseZoom = number | "fit-width";
263
+
264
+ export interface ReviseFontDefinition {
265
+ family: string;
266
+ label?: string;
267
+ cssFamily?: string;
268
+ fontWeight?: number | string;
269
+ }
270
+
271
+ export interface ReviseZoomState {
272
+ zoom: ReviseZoom;
273
+ scale: number;
274
+ }
275
+
276
+ export interface ReviseEditorZoomController {
277
+ getState(): ReviseZoomState;
278
+ setZoom(zoom: ReviseZoom): void;
279
+ fitWidth(): void;
280
+ subscribe(listener: (state: ReviseZoomState) => void): () => void;
281
+ }
282
+
283
+ export interface ReviseSelectionPosition {
284
+ kind: "text";
285
+ blockId: string;
286
+ offset: number;
287
+ }
288
+
289
+ export interface ReviseTextTargetSegment {
290
+ blockId: string;
291
+ range: { start: number; end: number };
292
+ }
293
+
294
+ export interface ReviseTextTarget {
295
+ kind: "text";
296
+ segments: ReviseTextTargetSegment[];
297
+ }
298
+
299
+ export interface ReviseSelectionTarget {
300
+ kind: "selection";
301
+ start: ReviseSelectionPosition;
302
+ end: ReviseSelectionPosition;
303
+ }
304
+
305
+ export interface ReviseSelectionSnapshot {
306
+ documentId: string | null;
307
+ anchor: ReviseSelectionPosition | null;
308
+ focus: ReviseSelectionPosition | null;
309
+ start: ReviseSelectionPosition | null;
310
+ end: ReviseSelectionPosition | null;
311
+ target: ReviseTextTarget | null;
312
+ selectionTarget: ReviseSelectionTarget | null;
313
+ activeMarks: string[];
314
+ activeCommentIds: string[];
315
+ activeChangeIds: string[];
316
+ quotedText: string;
317
+ text: string;
318
+ collapsed: boolean;
319
+ empty: boolean;
320
+ }
321
+
322
+ export type ReviseSelectionCapture = ReviseSelectionSnapshot & {
323
+ documentId: string;
324
+ target: ReviseTextTarget;
325
+ selectionTarget: ReviseSelectionTarget;
326
+ };
327
+
328
+ export type ReviseSelectionRestoreResult =
329
+ | { success: true }
330
+ | {
331
+ success: false;
332
+ reason: "not-ready" | "read-only" | "missing-target" | "stale";
333
+ };
334
+
335
+ export interface ReviseEditorSelection {
336
+ getSnapshot(): ReviseSelectionSnapshot;
337
+ subscribe(listener: (event: { snapshot: ReviseSelectionSnapshot }) => void): () => void;
338
+ observe(listener: (snapshot: ReviseSelectionSnapshot) => void): () => void;
339
+ capture(): ReviseSelectionCapture | null;
340
+ restore(capture: ReviseSelectionCapture): ReviseSelectionRestoreResult;
341
+ clear(): void;
342
+ }
343
+
344
+ export interface ReviseToolbarState {
345
+ ready: boolean;
346
+ readOnly: boolean;
347
+ documentMode: ReviseDocumentMode;
348
+ activeTab: "edit" | "layout" | "insert" | "tools" | "review";
349
+ hasSelection: boolean;
350
+ canUndo: boolean;
351
+ canRedo: boolean;
352
+ formatting: Record<string, unknown> & {
353
+ bold?: boolean;
354
+ italic?: boolean;
355
+ underline?: boolean;
356
+ strikethrough?: boolean;
357
+ color?: string;
358
+ backgroundColor?: string;
359
+ fontFamily?: string;
360
+ };
361
+ heading?: 1 | 2 | 3 | 4 | 5 | 6;
362
+ alignment?: "left" | "center" | "right" | "justify";
363
+ lineSpacing?: number;
364
+ fontSizePt?: number;
365
+ blockType: { type: string; variant?: string } | null;
366
+ review: {
367
+ open: boolean;
368
+ targetCount: number;
369
+ currentTargetSuggestionCount: number;
370
+ allOpenSuggestionCount: number;
371
+ showRemovals: boolean;
372
+ viewMode: "all-markup" | "final" | "original";
373
+ };
374
+ }
375
+
376
+ export interface ReviseDocumentStatistics {
377
+ wordCount: number;
378
+ characterCount: number;
379
+ }
380
+
381
+ /**
382
+ * DOCX-mode fidelity: what relationship the next export has to the original
383
+ * .docx file.
3
384
  *
4
- * const doc = await ReviseDocument.open("contract.docx", { author: "Legal bot" });
5
- * await doc.replaceAll("Provider", "Northstar"); // tracked changes
6
- * await doc.reject({ section: "8" });
7
- * const { bytes } = await doc.export({ format: "docx" });
8
- * fs.writeFileSync("contract-out.docx", bytes);
385
+ * "exact" — byte-identical to the imported file
386
+ * "grafted" — original bytes plus this document's edits; untouched
387
+ * content exports byte-for-byte
388
+ * "converted" — no usable original; export regenerates everything
389
+ */
390
+ export type ReviseSourceFidelity = "exact" | "grafted" | "converted";
391
+
392
+ export interface ReviseSourceFidelityReport {
393
+ fidelity: ReviseSourceFidelity;
394
+ /** Body blocks an export would regenerate (empty for "exact"). */
395
+ regeneratedBlockIds: string[];
396
+ /** Part domains an export would regenerate (notes, chrome, comments…). */
397
+ changedDomains: string[];
398
+ /** Why "converted", when it is. */
399
+ convertedReason?:
400
+ | "no-capture"
401
+ | "no-carrier"
402
+ | "carrier-hash-mismatch"
403
+ | "unpaired-capture";
404
+ }
405
+
406
+ export interface ReviseEditorToolbar {
407
+ getState(): ReviseToolbarState;
408
+ subscribe(listener: (state: ReviseToolbarState) => void): () => void;
409
+ /** Switches the ribbon row. "tools" is Revise-app chrome and is ignored in
410
+ * the SDK — use `getStatistics()` for word and character counts. */
411
+ setActiveTab(tab: ReviseToolbarState["activeTab"]): void;
412
+ openFind(): void;
413
+ undo(): boolean;
414
+ redo(): boolean;
415
+ copy(): Promise<void>;
416
+ copyAs(format: "plaintext" | "markdown" | "html"): Promise<void>;
417
+ cut(): boolean;
418
+ paste(): Promise<boolean>;
419
+ pasteTextOnly(): Promise<boolean>;
420
+ pasteFormattingOnly(): Promise<boolean>;
421
+ toggleInline(command: InlineFormattingCommand): boolean;
422
+ toggleBold(): boolean;
423
+ toggleItalic(): boolean;
424
+ toggleUnderline(): boolean;
425
+ toggleStrikethrough(): boolean;
426
+ toggleDoubleStrikethrough(): boolean;
427
+ toggleSmallCaps(): boolean;
428
+ toggleAllCaps(): boolean;
429
+ toggleCode(): boolean;
430
+ toggleLatex(): boolean;
431
+ toggleSuperscript(): boolean;
432
+ toggleSubscript(): boolean;
433
+ clearFormatting(): boolean;
434
+ setFontFamily(fontFamily?: string): boolean;
435
+ setFontSize(fontSizePt?: number): boolean;
436
+ setLetterSpacing(spacing?: number): boolean;
437
+ setTextColor(color?: string): boolean;
438
+ setHighlightColor(color?: string): boolean;
439
+ setHeading(level?: 1 | 2 | 3 | 4 | 5 | 6): boolean;
440
+ setAlignment(alignment?: "left" | "center" | "right" | "justify"): boolean;
441
+ setLineSpacing(spacing?: number): boolean;
442
+ toggleList(variant: "ordered" | "unordered" | "todo"): boolean;
443
+ createLink(): boolean;
444
+ increaseIndent(): boolean;
445
+ decreaseIndent(): boolean;
446
+ insertTable(rows: number, columns: number): boolean;
447
+ insertImage(file: File): Promise<boolean>;
448
+ insertContainer(): boolean;
449
+ insertCodeBlock(language?: string): boolean;
450
+ insertMathBlock(content?: string): boolean;
451
+ insertDiagram(content?: string): boolean;
452
+ insertFootnote(kind?: "footnote" | "endnote"): boolean;
453
+ insertPageNumber(): boolean;
454
+ insertPageBreak(): boolean;
455
+ insertSectionBreak(): boolean;
456
+ openReview(): void;
457
+ closeReview(): void;
458
+ reviewPrevious(): boolean;
459
+ reviewNext(): boolean;
460
+ acceptCurrent(): boolean;
461
+ rejectCurrent(): boolean;
462
+ acceptAll(): boolean;
463
+ rejectAll(): boolean;
464
+ setShowRemovals(show: boolean): void;
465
+ setSuggestionViewMode(mode: "all-markup" | "final" | "original"): void;
466
+ }
467
+
468
+ export interface ReviseCommentMention {
469
+ id: string;
470
+ type: "user" | "agent";
471
+ label: string;
472
+ start: number;
473
+ end: number;
474
+ email?: string;
475
+ }
476
+
477
+ export interface ReviseCommentRecord {
478
+ id: string;
479
+ author: string;
480
+ initials?: string;
481
+ authorId?: string;
482
+ authorImageUrl?: string;
483
+ createdAt: string;
484
+ bodyMd: string;
485
+ mentions?: ReviseCommentMention[];
486
+ parentId?: string;
487
+ relatedSuggestionIds?: string[];
488
+ resolved?: boolean;
489
+ }
490
+
491
+ export interface ReviseCommentAnchor {
492
+ blockId: string;
493
+ start: number;
494
+ end: number;
495
+ }
496
+
497
+ export interface ReviseCommentThread {
498
+ root: ReviseCommentRecord;
499
+ replies: ReviseCommentRecord[];
500
+ anchor: ReviseCommentAnchor | null;
501
+ relatedSuggestionIds: string[];
502
+ }
503
+
504
+ export interface ReviseReviewState {
505
+ open: boolean;
506
+ commentsOpen: boolean;
507
+ targetCount: number;
508
+ currentTargetSuggestionCount: number;
509
+ allOpenSuggestionCount: number;
510
+ openSuggestionIds: string[];
511
+ currentSuggestionIds: string[];
512
+ visibleAgentSuggestionIds: string[];
513
+ activeCommentId: string | null;
514
+ showRemovals: boolean;
515
+ viewMode: "all-markup" | "final" | "original";
516
+ commentThreads: ReviseCommentThread[];
517
+ }
518
+
519
+ export interface ReviseEditorReview {
520
+ getState(): ReviseReviewState;
521
+ subscribe(listener: (state: ReviseReviewState) => void): () => void;
522
+ open(): void;
523
+ close(): void;
524
+ previous(): boolean;
525
+ next(): boolean;
526
+ nextAgentSuggestion(): boolean;
527
+ acceptCurrent(): boolean;
528
+ rejectCurrent(): boolean;
529
+ acceptAll(): boolean;
530
+ rejectAll(): boolean;
531
+ previewCurrent(mode: "accept" | "reject" | null): boolean;
532
+ previewAll(mode: "accept" | "reject" | null): boolean;
533
+ getOpenSuggestionIds(): string[];
534
+ /** Every pending change with its kind, author, timestamp, location, and
535
+ * text. A pull, not part of the subscribed state. */
536
+ listChanges(): ReviseTrackedChange[];
537
+ getChange(suggestionId: string): ReviseTrackedChange | null;
538
+ navigateToSuggestion(suggestionId: string): boolean;
539
+ navigateWithinSuggestions(suggestionIds: string[], direction: "previous" | "next"): boolean;
540
+ previewSuggestions(suggestionIds: string[], mode: "accept" | "reject" | null): void;
541
+ /** Per-ID outcome, same shape as the server surface: stale IDs land in
542
+ * missing; a role that may not resolve reports all unresolved. */
543
+ acceptSuggestions(suggestionIds: string[]): ReviseSuggestionDecision;
544
+ rejectSuggestions(suggestionIds: string[]): ReviseSuggestionDecision;
545
+ setShowRemovals(show: boolean): void;
546
+ setSuggestionViewMode(mode: "all-markup" | "final" | "original"): void;
547
+ openComments(): void;
548
+ closeComments(): void;
549
+ selectComment(commentId: string | null): boolean;
550
+ addCommentAtSelection(bodyMd: string, mentions?: ReviseCommentMention[]): string | null;
551
+ addCommentToRanges(ranges: ReviseCommentAnchor[], bodyMd: string, mentions?: ReviseCommentMention[]): string | null;
552
+ addCommentToBlock(blockId: string, bodyMd: string, mentions?: ReviseCommentMention[]): string | null;
553
+ addCommentForSuggestion(suggestionId: string, bodyMd: string, mentions?: ReviseCommentMention[]): string | null;
554
+ replyToComment(commentId: string, bodyMd: string, mentions?: ReviseCommentMention[]): string | null;
555
+ setCommentResolved(commentId: string, resolved: boolean): boolean;
556
+ deleteComment(commentId: string): boolean;
557
+ getRelatedSuggestionIds(commentId: string): string[];
558
+ acceptCommentSuggestions(commentId: string): ReviseSuggestionDecision;
559
+ rejectCommentSuggestions(commentId: string): ReviseSuggestionDecision;
560
+ }
561
+
562
+ /** Chrome the SDK no longer renders buttons for; the host drives it. */
563
+ export interface ReviseViewState {
564
+ ready: boolean;
565
+ title: string;
566
+ documentMode: ReviseDocumentMode;
567
+ readOnly: boolean;
568
+ commentsOpen: boolean;
569
+ /** Comment threads in the document, open panel or not. */
570
+ commentCount: number;
571
+ reviewOpen: boolean;
572
+ /** Suggestions and comment threads Review would step through. */
573
+ reviewTargetCount: number;
574
+ }
575
+
576
+ export interface ReviseEditorView {
577
+ getState(): ReviseViewState;
578
+ subscribe(listener: (state: ReviseViewState) => void): () => void;
579
+ setTitle(title: string): void;
580
+ setDocumentMode(mode: ReviseDocumentMode): void;
581
+ setCommentsOpen(open: boolean): void;
582
+ setReviewOpen(open: boolean): void;
583
+ }
584
+
585
+ export interface ReviseDocumentHandle {
586
+ readonly id: string;
587
+ readonly title: string;
588
+ tools: ReviseEditorTools;
589
+ toolbar: ReviseEditorToolbar;
590
+ review: ReviseEditorReview;
591
+ /** Title and the comments/review/document-mode chrome the host now owns. */
592
+ view: ReviseEditorView;
593
+ zoom: ReviseEditorZoomController;
594
+ selection: ReviseEditorSelection;
595
+ agent: ReviseAgentSubagent;
596
+ comments: ReviseCommentAgent;
597
+ /** Presence and sync state for a shared document. */
598
+ collaboration: ReviseCollaborationController;
599
+ /** What this participant is permitted to do. */
600
+ getRole(): ReviseDocumentRole;
601
+ getDocument(): ReviseDocument;
602
+ /** DOCX-mode fidelity of the next export relative to the original file.
603
+ * Computed on demand from content signatures; cheap enough for UI
604
+ * badges, not for per-keystroke calls. */
605
+ getSourceFidelity(): ReviseSourceFidelityReport;
606
+ /** Live word and character counts (text statistics, no layout pass). */
607
+ getStatistics(): ReviseDocumentStatistics;
608
+ getDocumentMode(): ReviseDocumentMode;
609
+ setDocumentMode(mode: ReviseDocumentMode): void;
610
+ getToolDefinitions(): ReviseEditorTool[];
611
+ focus(): void;
612
+ openReview(): void;
613
+ closeReview(): void;
614
+ openComments(): void;
615
+ closeComments(): void;
616
+ }
617
+
618
+ export type ReviseDocumentMode = "editing" | "suggesting" | "viewing";
619
+
620
+ export type ReviseDocumentSource = File | Blob | ArrayBuffer;
621
+
622
+ /** Input formats the SDK parses. DOCX is the high-fidelity path and the only
623
+ * one that round-trips back out; ODT and RTF import formatting, lists,
624
+ * tables, images, footnotes, headers and footers, comments, and tracked
625
+ * changes. */
626
+ export type ReviseDocumentFormat =
627
+ | "docx"
628
+ | "odt"
629
+ | "rtf"
630
+ | "markdown"
631
+ | "txt"
632
+ | "html";
633
+
634
+ /**
635
+ * Yjs types, left deliberately loose.
9
636
  *
10
- * The `revise` CLI is built on exactly this API.
637
+ * Naming them structurally made the package dependency-free but broke the
638
+ * thing hosts actually write: a `connect` callback annotated with the real
639
+ * `Y.Doc` is not assignable to a minimal stand-in, because callback
640
+ * parameters are contravariant. Declaring them permissively keeps your own
641
+ * code fully typed — annotate the callback with yjs's types, as you would
642
+ * anyway — without this package importing yjs for every consumer, including
643
+ * those who never collaborate.
11
644
  */
12
- export { ReviseDocument, compare, convert, formatForPath, seedYDoc, type ChangeEntry, type ChangeFilter, type ChangeSelection, type CompareResult, type DocumentMode, type DocumentSource, type DocumentSummary, type ExportFormat, type ExportOptions, type ExportResult, type GrepHit, type GrepMatch, type ReadView, type OpenOptions, type ReplaceAllOptions, type ReplaceTextResult, type TextRegion, type SettleResult, type TextDiff, } from "./document.js";
13
- export { agentTools, formatToolResult, type AgentProvider, type AgentTools, type AgentToolsOptions, type AnthropicToolUse, type OpenAIResponsesFunctionCall, type OpenAIToolCall, } from "./agent.js";
14
- export { catPart, listParts, patchPackage, type PatchRequest, type PatchResult, } from "./package.js";
15
- export type { ImageFetchPolicy, ReviseJsonObject, ReviseToolName, ReviseToolResult, ServerDocumentSession, } from "@reviseio/engine";
16
- export type { RenderOptions, RenderResult, RenderView } from "./render.js";
17
- export { ReviseError } from "./errors.js";
645
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
646
+ export type ReviseYDoc = any;
647
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
648
+ export type ReviseAwareness = any;
649
+
650
+ /** Any Yjs provider: Hocuspocus exposes `document`, y-websocket and y-webrtc
651
+ * expose `doc`, and some wrappers expose `getYDoc()`. */
652
+ export interface ReviseCollaborationProvider {
653
+ document?: ReviseYDoc;
654
+ doc?: ReviseYDoc;
655
+ getYDoc?: () => ReviseYDoc;
656
+ awareness?: ReviseAwareness | null;
657
+ }
658
+
659
+ /** Attach a transport to a document the SDK built. Return the provider so the
660
+ * editor can recognize its transactions as remote. */
661
+ export type ReviseCollaborationConnect = (
662
+ ydoc: ReviseYDoc,
663
+ awareness: ReviseAwareness,
664
+ ) => ReviseCollaborationProvider | { destroy?: () => void } | void;
665
+
666
+ export interface ReviseCollaborationConfig {
667
+ /**
668
+ * The recommended form: the editor builds the document and awareness with
669
+ * the settings it requires, and this connects them.
670
+ *
671
+ * The editor reserves the top-level keys listed in RESERVED_DOCUMENT_KEYS
672
+ * (content, comments, metadata, and others), so a document built elsewhere
673
+ * may already use those names or hold another schema. Let the editor build
674
+ * its own.
675
+ */
676
+ connect?: ReviseCollaborationConnect;
677
+ /** A provider that already owns its document. The document is validated
678
+ * before use. */
679
+ provider?: ReviseCollaborationProvider;
680
+ /** A document you own. Validated before use; prefer `connect`. */
681
+ ydoc?: ReviseYDoc;
682
+ /** Awareness, for remote carets and presence. Pass null to opt out. */
683
+ awareness?: ReviseAwareness | null;
684
+ /** The transaction origin your transport applies remote updates with.
685
+ * Required when passing `ydoc` without a `provider`. */
686
+ remoteOrigin?: unknown;
687
+ /** Whether the transport has finished its initial sync. The document stays
688
+ * closed until this is true. */
689
+ synced?: boolean;
690
+ /** "if-empty" (default) writes the source file into an empty room;
691
+ * "never" always joins. */
692
+ seed?: "if-empty" | "never";
693
+ }
694
+
695
+ export interface RevisePeer {
696
+ clientId: number;
697
+ isLocal: boolean;
698
+ id?: string;
699
+ name?: string;
700
+ email?: string;
701
+ image?: string;
702
+ color: string;
703
+ }
704
+
705
+ export interface ReviseCollaborationState {
706
+ enabled: boolean;
707
+ synced: boolean;
708
+ peers: RevisePeer[];
709
+ }
710
+
711
+ export interface ReviseCollaborationController {
712
+ getState(): ReviseCollaborationState;
713
+ subscribe(listener: (state: ReviseCollaborationState) => void): () => void;
714
+ }
715
+
716
+ /** What a participant may do. A boundary, not a starting point: unlike
717
+ * `documentMode` it cannot be escaped from inside the editor. */
718
+ export type ReviseDocumentRole = "editor" | "suggester" | "viewer";
719
+
720
+ export interface ReviseRolePolicy {
721
+ readonly modes: readonly ReviseDocumentMode[];
722
+ readonly canEdit: boolean;
723
+ readonly canEditDirectly: boolean;
724
+ readonly canResolveSuggestions: boolean;
725
+ readonly canComment: boolean;
726
+ }
727
+
728
+ export declare function rolePolicy(role: ReviseDocumentRole): ReviseRolePolicy;
729
+
730
+ /** Thrown by `agent.run()` and UI controllers when a role forbids an
731
+ * action. Tool calls report role denials as structured
732
+ * `{ ok: false, error: { code: "role_not_permitted" } }` results instead. */
733
+ export declare class ReviseRoleError extends Error {
734
+ readonly role: ReviseDocumentRole;
735
+ readonly action: string;
736
+ }
737
+
738
+ /** A pending tracked change, with the metadata a review panel needs. */
739
+ export interface ReviseTrackedChange {
740
+ id: string;
741
+ /** Word's three revision kinds, plus "move" for a linked move pair. A
742
+ * replacement made in one operation (the agent's `replace` tool) is ONE
743
+ * change with both `deletedText` and `insertedText` set; its kind is
744
+ * the one it was recorded with, usually "delete". A linked move is also ONE
745
+ * change: `deletedText` is the text at the source, `insertedText` the
746
+ * text at the destination, and resolving it settles both locations. */
747
+ kind: "insert" | "delete" | "format" | "move";
748
+ /** A person, "Revise Agent", an external agent, or "Anonymous". */
749
+ author: string;
750
+ authorType: "human" | "ai";
751
+ agentModel?: string;
752
+ /** Epoch milliseconds. */
753
+ createdAt?: number;
754
+ description?: string;
755
+ /** Blocks this change touches, in document order. */
756
+ blockIds: string[];
757
+ /** For kind "move": blocks the text moved out of, in document order. */
758
+ moveSourceBlockIds?: string[];
759
+ /** For kind "move": blocks the text moved into, in document order. */
760
+ moveDestinationBlockIds?: string[];
761
+ insertedText?: string;
762
+ deletedText?: string;
763
+ commentThreadId?: string;
764
+ }
765
+
766
+ export interface ReviseDocumentInput {
767
+ /** Stable host-owned ID used by APIs, agent tools, and callbacks. */
768
+ id: string;
769
+ /** The document to open: DOCX, ODT, RTF, Markdown, plain text, or HTML.
770
+ * Optional when joining an established collaborative document. */
771
+ source?: ReviseDocumentSource;
772
+ /** The original name for `source`, accepted for compatibility. Pass one
773
+ * or the other. */
774
+ docx?: ReviseDocumentSource;
775
+ /** Share this document over a Yjs transport you own. */
776
+ collaboration?: ReviseCollaborationConfig;
777
+ /** Overrides the editor-wide role for this document. */
778
+ role?: ReviseDocumentRole;
779
+ /** Declare the format explicitly. Inferred from filename, then MIME type,
780
+ * defaulting to DOCX. */
781
+ format?: ReviseDocumentFormat;
782
+ title?: string;
783
+ documentMode?: ReviseDocumentMode;
784
+ readOnly?: boolean;
785
+ zoom?: ReviseZoom;
786
+ defaultCommentsOpen?: boolean;
787
+ /** Per-document agent settings override the editor-wide defaults. */
788
+ agent?: ReviseAgentConfig;
789
+ }
790
+
791
+ export interface ReviseOpenDocument {
792
+ id: string;
793
+ title: string;
794
+ status: "opening" | "ready" | "error";
795
+ active: boolean;
796
+ error?: string;
797
+ }
798
+
799
+ export interface ReviseDocumentCollectionState {
800
+ activeDocumentId: string | null;
801
+ documents: ReviseOpenDocument[];
802
+ }
803
+
804
+ export interface ReviseOpenDocumentOptions {
805
+ /** Newly opened documents become active by default. */
806
+ activate?: boolean;
807
+ }
808
+
809
+ export interface ReviseEditorDocuments {
810
+ open(
811
+ document: ReviseDocumentInput,
812
+ options?: ReviseOpenDocumentOptions,
813
+ ): Promise<ReviseDocumentHandle>;
814
+ close(documentId: string): boolean;
815
+ activate(documentId: string): boolean;
816
+ get(documentId?: string): ReviseDocumentHandle | null;
817
+ require(documentId?: string): ReviseDocumentHandle;
818
+ getActiveId(): string | null;
819
+ list(): ReviseOpenDocument[];
820
+ getState(): ReviseDocumentCollectionState;
821
+ subscribe(
822
+ listener: (state: ReviseDocumentCollectionState) => void,
823
+ ): () => void;
824
+ }
825
+
826
+ export type ReviseDocumentScoped<T> = T & {
827
+ /** Bind this controller to one open document instead of the active one. */
828
+ forDocument(documentId: string): T;
829
+ };
830
+
831
+ export interface ReviseMultiDocumentTools extends ReviseEditorTools {
832
+ forDocument(documentId: string): ReviseEditorTools;
833
+ exportDocx(documentId?: string): Promise<Blob>;
834
+ export(options?: ReviseExportOptions, documentId?: string): Promise<Blob>;
835
+ acceptAllSuggestions(documentId?: string): ReviseSuggestionDecision;
836
+ rejectAllSuggestions(documentId?: string): ReviseSuggestionDecision;
837
+ }
838
+
839
+ export interface ReviseEditorHandle {
840
+ documents: ReviseEditorDocuments;
841
+ /** Resolve an explicit document, or the active document when omitted. */
842
+ document(documentId?: string): ReviseDocumentHandle;
843
+ tools: ReviseMultiDocumentTools;
844
+ toolbar: ReviseDocumentScoped<ReviseEditorToolbar>;
845
+ review: ReviseDocumentScoped<ReviseEditorReview>;
846
+ /** Title and the comments/review/document-mode chrome the host now owns. */
847
+ view: ReviseDocumentScoped<ReviseEditorView>;
848
+ zoom: ReviseDocumentScoped<ReviseEditorZoomController>;
849
+ selection: ReviseDocumentScoped<ReviseEditorSelection>;
850
+ agent: ReviseDocumentScoped<ReviseAgentSubagent>;
851
+ comments: ReviseDocumentScoped<ReviseCommentAgent>;
852
+ /** Presence and sync state for shared documents. */
853
+ collaboration: ReviseDocumentScoped<ReviseCollaborationController>;
854
+ /** What this participant may do with a document. */
855
+ getRole(documentId?: string): ReviseDocumentRole;
856
+ /**
857
+ * Resolves once a document is open and its controllers are usable.
858
+ *
859
+ * `onReady` hands you the editor before any document exists; everything
860
+ * that acts on a document throws until one does. Subscriptions are the
861
+ * exception and can be placed immediately.
862
+ */
863
+ whenReady(documentId?: string): Promise<ReviseDocumentHandle>;
864
+ getDocument(documentId?: string): ReviseDocument;
865
+ /** Live word and character counts for a document (active by default). */
866
+ getStatistics(documentId?: string): ReviseDocumentStatistics;
867
+ getDocumentMode(documentId?: string): ReviseDocumentMode;
868
+ setDocumentMode(mode: ReviseDocumentMode, documentId?: string): void;
869
+ getToolDefinitions(documentId?: string): ReviseEditorTool[];
870
+ focus(documentId?: string): void;
871
+ openReview(documentId?: string): void;
872
+ closeReview(documentId?: string): void;
873
+ openComments(documentId?: string): void;
874
+ closeComments(documentId?: string): void;
875
+ }
876
+
877
+ /** Behavior settings for tracked changes. */
878
+ export interface ReviseTrackedChangesSettings {
879
+ /** Start review with deleted text shown inline (strikethrough). Reviewers
880
+ * used to Word usually want this on. Default false. */
881
+ showRemovalsInReview?: boolean;
882
+ /** "revise" (default): per-kind colors with a soft background tint.
883
+ * "word": classic redlines — all revisions in red, insertions underlined,
884
+ * deletions struck through, no background tint. */
885
+ markupStyle?: "revise" | "word";
886
+ }
887
+
888
+ export interface ReviseEditorSettings {
889
+ trackedChanges?: ReviseTrackedChangesSettings;
890
+ }
891
+
892
+ export interface ReviseEditorProps {
893
+ findShortcut?: "editor" | "browser";
894
+ /** Behavior settings. */
895
+ settings?: ReviseEditorSettings;
896
+ /** Receive the editor's internal instrumentation events (tool
897
+ * invocations, exports, review interactions, …) for the host's own
898
+ * analytics. These events never leave the page except through this
899
+ * callback. Event names and property shapes may change between versions. */
900
+ onAnalyticsEvent?: (
901
+ event: string,
902
+ properties?: Record<string, unknown>,
903
+ ) => void;
904
+ /** Once per page load, the SDK sends Revise one anonymous ping carrying
905
+ * its version; the browser adds your site's origin. Development hosts
906
+ * (localhost and similar) are only counted, never named. No cookies, user
907
+ * data, or document content. Set false to turn it off. Defaults to true.
908
+ * An agent, when you configure one, talks only to the backend you chose. */
909
+ telemetry?: boolean;
910
+ initialDocuments?: readonly ReviseDocumentInput[];
911
+ /** Controlled active document ID. */
912
+ activeDocumentId?: string | null;
913
+ /** Initial active ID for uncontrolled use. Defaults to the first document. */
914
+ defaultActiveDocumentId?: string | null;
915
+ currentUser?: EditorUserIdentity | null;
916
+ agent?: ReviseAgentConfig;
917
+ theme?: "light" | "dark";
918
+ /** What this participant may do, across every open document. Overridden per
919
+ * document by `ReviseDocumentInput.role`. */
920
+ role?: ReviseDocumentRole;
921
+ defaultDocumentMode?: ReviseDocumentMode;
922
+ defaultZoom?: ReviseZoom;
923
+ defaultCommentsOpen?: boolean;
924
+ showDocumentModeToggle?: boolean;
925
+ /**
926
+ * Render the built-in tab strip (one tab per open document). Off by default:
927
+ * hosts with their own file switcher drive `documents` instead.
928
+ */
929
+ showTabs?: boolean;
930
+ /**
931
+ * Render the built-in title bar above the ribbon. Hosts that build their own
932
+ * chrome turn this off and drive `view` (title, mode, review) themselves.
933
+ */
934
+ showTitleBar?: boolean;
935
+ /**
936
+ * With onImportFile, show Import in the ribbon. Defaults to true. Hosts that
937
+ * only import into an empty document (through uploadPlaceholder) or by drop
938
+ * turn it off.
939
+ */
940
+ showImportButton?: boolean;
941
+ /** Adds a "+" button to the tab strip. Without it, no button is rendered. */
942
+ onNewTab?: () => void;
943
+ /**
944
+ * Take keyboard focus when a document becomes active. Defaults to true; set
945
+ * false when the editor sits inside a larger page and should wait for a click.
946
+ */
947
+ autoFocus?: boolean;
948
+ /** Opt in to the Rust/WASM hot paths (word diff, agent text matching,
949
+ * document stats). Off by default; the TypeScript implementations remain the
950
+ * fallback, so this only ever changes speed, never behavior. Available only
951
+ * from the explicit `revise/full` entry point. */
952
+ wasmHotPaths?: boolean;
953
+ /** The area behind the page — not the page itself. Any CSS background. */
954
+ canvasBackground?: string;
955
+ /** The paper color. Any CSS color. */
956
+ pageBackground?: string;
957
+ /** The 1px outline around each page. Any CSS color. */
958
+ pageBorderColor?: string;
959
+ /** "native" is the full ribbon, "compact" the everyday-formatting subset for
960
+ * narrow fixed-width hosts (about 760px), centered. "floating" is the full
961
+ * ribbon as a centered card over the canvas, as in the Revise app. "none"
962
+ * renders no toolbar. */
963
+ toolbarMode?: ReviseToolbarMode;
964
+ fonts?: readonly ReviseFontDefinition[];
965
+ /**
966
+ * Store an image the user inserts, pastes, or drops, and resolve to the URL
967
+ * the document should reference. Without it, images are embedded in the
968
+ * document as data URLs, which export into the .docx like any other image.
969
+ * A rejection shows the user a notice and reaches onError.
970
+ */
971
+ onImageUpload?: (file: File, documentId: string) => Promise<string>;
972
+ /** Shows Import before Export in the ribbon and accepts document files
973
+ * dropped on the editor (image drops still insert images). The editor only
974
+ * collects the file; what importing means is up to the host. */
975
+ onImportFile?: (file: File, documentId: string) => void;
976
+ /**
977
+ * With onImportFile, an empty document shows "Type or paste your text or
978
+ * [Upload] a document" until something is typed; the button imports through
979
+ * onImportFile. Defaults to false.
980
+ */
981
+ uploadPlaceholder?: boolean;
982
+ className?: string;
983
+ style?: React.CSSProperties;
984
+ onReady?: (editor: ReviseEditorHandle) => void;
985
+ onDocumentReady?: (document: ReviseDocumentHandle) => void;
986
+ onDocumentsChange?: (state: ReviseDocumentCollectionState) => void;
987
+ onActiveDocumentChange?: (documentId: string | null) => void;
988
+ onChange?: (documentId: string, document: ReviseDocument) => void;
989
+ onDocumentTitleChange?: (documentId: string, title: string) => void;
990
+ onDocumentModeChange?: (documentId: string, mode: ReviseDocumentMode) => void;
991
+ onZoomChange?: (documentId: string, zoom: ReviseZoom) => void;
992
+ onAgentEvent?: (documentId: string, event: ReviseAgentEvent) => void;
993
+ onError?: (error: Error, documentId?: string) => void;
994
+ }
995
+
996
+ export const ReviseEditor: React.ForwardRefExoticComponent<
997
+ ReviseEditorProps & React.RefAttributes<ReviseEditorHandle>
998
+ >;
999
+ export default ReviseEditor;