tiptap-office 0.0.1
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.
- package/LICENSE +201 -0
- package/README.md +19 -0
- package/dist/ai-drafting-GIKFKPLS.css +63 -0
- package/dist/comments-36ASF3VI.css +171 -0
- package/dist/index.cjs +7031 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +509 -0
- package/dist/index.d.ts +509 -0
- package/dist/index.js +7064 -0
- package/dist/index.js.map +1 -0
- package/dist/tracked-changes-NCBRMECA.css +57 -0
- package/package.json +86 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,509 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import * as react from 'react';
|
|
3
|
+
import react__default, { ReactNode } from 'react';
|
|
4
|
+
import { Editor } from '@tiptap/react';
|
|
5
|
+
|
|
6
|
+
type ProviderName = 'anthropic' | 'openai' | 'google';
|
|
7
|
+
interface TiptapOfficeConfig {
|
|
8
|
+
/** Base URL of your backend (no trailing slash). All editor API calls and
|
|
9
|
+
* the LLM proxy are rooted here. */
|
|
10
|
+
apiBaseUrl: string;
|
|
11
|
+
/** Path under `apiBaseUrl` that proxies LLM provider requests. The library
|
|
12
|
+
* POSTs to `${apiBaseUrl}${llmProxyPath}` using the Vercel AI SDK's
|
|
13
|
+
* `baseURL` convention. Defaults to `/llm/proxy`. */
|
|
14
|
+
llmProxyPath?: string;
|
|
15
|
+
/** Credentials mode for backend fetches. Defaults to `'include'`
|
|
16
|
+
* (cookie-based auth). Set to `'omit'` for token-only auth. */
|
|
17
|
+
includeCredentials?: RequestCredentials;
|
|
18
|
+
/** Returns the headers (e.g. auth) to attach to every backend fetch.
|
|
19
|
+
* May return synchronously or as a promise. */
|
|
20
|
+
getAuthHeaders?: () => Record<string, string> | Promise<Record<string, string>>;
|
|
21
|
+
/** Returns extra headers for LLM proxy requests, scoped by provider and
|
|
22
|
+
* chat id. Use this if your proxy needs routing hints
|
|
23
|
+
* (e.g. provider selection, per-chat tracing). */
|
|
24
|
+
getProxyHeaders?: (params: {
|
|
25
|
+
provider: ProviderName;
|
|
26
|
+
chatId: string;
|
|
27
|
+
}) => Record<string, string>;
|
|
28
|
+
/** Default model id (e.g. `'gpt-4o'`, `'claude-3-7-sonnet-latest'`). The
|
|
29
|
+
* consumer must supply this — no vendor model is hardcoded in the library. */
|
|
30
|
+
defaultModel: string;
|
|
31
|
+
/** Default provider matching `defaultModel`. */
|
|
32
|
+
defaultProvider: ProviderName;
|
|
33
|
+
}
|
|
34
|
+
declare function TiptapOfficeProvider({ config, children, }: {
|
|
35
|
+
config: TiptapOfficeConfig;
|
|
36
|
+
children: ReactNode;
|
|
37
|
+
}): react_jsx_runtime.JSX.Element;
|
|
38
|
+
declare function useTiptapOfficeConfig(): TiptapOfficeConfig;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Edit operation types for the AI editing pipeline (ADR-014).
|
|
42
|
+
* 13 operation types across paragraph and table categories.
|
|
43
|
+
*/
|
|
44
|
+
interface ReplaceTextOp {
|
|
45
|
+
type: 'replace_text';
|
|
46
|
+
target: string;
|
|
47
|
+
find: string;
|
|
48
|
+
replace: string;
|
|
49
|
+
reasoning: string;
|
|
50
|
+
}
|
|
51
|
+
interface ReplaceParagraphOp {
|
|
52
|
+
type: 'replace_paragraph';
|
|
53
|
+
target: string;
|
|
54
|
+
content: string;
|
|
55
|
+
reasoning: string;
|
|
56
|
+
}
|
|
57
|
+
interface InsertAfterOp {
|
|
58
|
+
type: 'insert_after';
|
|
59
|
+
target: string;
|
|
60
|
+
new_id: string;
|
|
61
|
+
content: string;
|
|
62
|
+
reasoning: string;
|
|
63
|
+
}
|
|
64
|
+
interface InsertBeforeOp {
|
|
65
|
+
type: 'insert_before';
|
|
66
|
+
target: string;
|
|
67
|
+
new_id: string;
|
|
68
|
+
content: string;
|
|
69
|
+
reasoning: string;
|
|
70
|
+
}
|
|
71
|
+
interface DeleteOp {
|
|
72
|
+
type: 'delete';
|
|
73
|
+
target: string;
|
|
74
|
+
reasoning: string;
|
|
75
|
+
}
|
|
76
|
+
interface ReplaceSectionOp {
|
|
77
|
+
type: 'replace_section';
|
|
78
|
+
target: string;
|
|
79
|
+
content: string;
|
|
80
|
+
reasoning: string;
|
|
81
|
+
}
|
|
82
|
+
interface AddCommentOp {
|
|
83
|
+
type: 'add_comment';
|
|
84
|
+
target: string;
|
|
85
|
+
comment_text: string;
|
|
86
|
+
comment_author: string;
|
|
87
|
+
comment_severity: string;
|
|
88
|
+
comment_act: string;
|
|
89
|
+
comment_article: string;
|
|
90
|
+
reasoning: string;
|
|
91
|
+
}
|
|
92
|
+
interface ReplaceCellOp {
|
|
93
|
+
type: 'replace_cell';
|
|
94
|
+
target: string;
|
|
95
|
+
content?: string;
|
|
96
|
+
paragraphs?: {
|
|
97
|
+
id: string;
|
|
98
|
+
content: string;
|
|
99
|
+
}[];
|
|
100
|
+
reasoning: string;
|
|
101
|
+
}
|
|
102
|
+
interface InsertRowOp {
|
|
103
|
+
type: 'insert_row';
|
|
104
|
+
table: string;
|
|
105
|
+
after_row: number;
|
|
106
|
+
cells: {
|
|
107
|
+
id: string;
|
|
108
|
+
content: string;
|
|
109
|
+
}[];
|
|
110
|
+
reasoning: string;
|
|
111
|
+
}
|
|
112
|
+
interface DeleteRowOp {
|
|
113
|
+
type: 'delete_row';
|
|
114
|
+
table: string;
|
|
115
|
+
row: number;
|
|
116
|
+
reasoning: string;
|
|
117
|
+
}
|
|
118
|
+
interface InsertColumnOp {
|
|
119
|
+
type: 'insert_column';
|
|
120
|
+
table: string;
|
|
121
|
+
after_column: number;
|
|
122
|
+
header: {
|
|
123
|
+
id: string;
|
|
124
|
+
content: string;
|
|
125
|
+
};
|
|
126
|
+
cells: {
|
|
127
|
+
id: string;
|
|
128
|
+
content: string;
|
|
129
|
+
}[];
|
|
130
|
+
reasoning: string;
|
|
131
|
+
}
|
|
132
|
+
interface DeleteColumnOp {
|
|
133
|
+
type: 'delete_column';
|
|
134
|
+
table: string;
|
|
135
|
+
column: number;
|
|
136
|
+
reasoning: string;
|
|
137
|
+
}
|
|
138
|
+
interface InsertTableOp {
|
|
139
|
+
type: 'insert_table';
|
|
140
|
+
after: string;
|
|
141
|
+
table_id: string;
|
|
142
|
+
headers: {
|
|
143
|
+
id: string;
|
|
144
|
+
content: string;
|
|
145
|
+
}[];
|
|
146
|
+
rows: {
|
|
147
|
+
id: string;
|
|
148
|
+
content: string;
|
|
149
|
+
}[][];
|
|
150
|
+
reasoning: string;
|
|
151
|
+
}
|
|
152
|
+
interface ReplaceTableOp {
|
|
153
|
+
type: 'replace_table';
|
|
154
|
+
target: string;
|
|
155
|
+
headers: {
|
|
156
|
+
id: string;
|
|
157
|
+
content: string;
|
|
158
|
+
}[];
|
|
159
|
+
rows: {
|
|
160
|
+
id: string;
|
|
161
|
+
content: string;
|
|
162
|
+
}[][];
|
|
163
|
+
reasoning: string;
|
|
164
|
+
}
|
|
165
|
+
type EditOperation = ReplaceTextOp | ReplaceParagraphOp | InsertAfterOp | InsertBeforeOp | DeleteOp | ReplaceSectionOp | AddCommentOp | ReplaceCellOp | InsertRowOp | DeleteRowOp | InsertColumnOp | DeleteColumnOp | InsertTableOp | ReplaceTableOp;
|
|
166
|
+
type EditOperationType = EditOperation['type'];
|
|
167
|
+
interface EditPlan {
|
|
168
|
+
operations: EditOperationWithStatus[];
|
|
169
|
+
summary: string;
|
|
170
|
+
}
|
|
171
|
+
type OperationStatus = 'pending' | 'applied' | 'failed' | 'skipped' | 'conflicted';
|
|
172
|
+
type EditOperationWithStatus = EditOperation & {
|
|
173
|
+
/** Runtime status set by the client during preview/apply */
|
|
174
|
+
status?: OperationStatus;
|
|
175
|
+
/** Error message if status is 'failed' */
|
|
176
|
+
error?: string;
|
|
177
|
+
/** Section ID this operation belongs to (from backend edit_plan) */
|
|
178
|
+
target_section?: string;
|
|
179
|
+
/** When true, the target ID is a backend-generated placeholder for an empty section */
|
|
180
|
+
empty_section_placeholder?: boolean;
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
type SuggestionType = 'insertion' | 'deletion';
|
|
184
|
+
interface SuggestionAuthor {
|
|
185
|
+
username: string;
|
|
186
|
+
isAI: boolean;
|
|
187
|
+
}
|
|
188
|
+
interface Suggestion {
|
|
189
|
+
id: string;
|
|
190
|
+
type: SuggestionType;
|
|
191
|
+
author: SuggestionAuthor;
|
|
192
|
+
text: string;
|
|
193
|
+
from: number;
|
|
194
|
+
to: number;
|
|
195
|
+
data?: Record<string, any>;
|
|
196
|
+
}
|
|
197
|
+
interface TrackChangesState {
|
|
198
|
+
enabled: boolean;
|
|
199
|
+
suggestions: Suggestion[];
|
|
200
|
+
showPanel: boolean;
|
|
201
|
+
suggestionCount: number;
|
|
202
|
+
}
|
|
203
|
+
type CommentSeverity = 'high' | 'moderate' | 'low';
|
|
204
|
+
interface CommentAuthor {
|
|
205
|
+
username: string;
|
|
206
|
+
isAI: boolean;
|
|
207
|
+
}
|
|
208
|
+
interface CommentReply {
|
|
209
|
+
id: string;
|
|
210
|
+
author: CommentAuthor;
|
|
211
|
+
text: string;
|
|
212
|
+
createdAt: string;
|
|
213
|
+
}
|
|
214
|
+
interface Comment {
|
|
215
|
+
id: string;
|
|
216
|
+
author: CommentAuthor;
|
|
217
|
+
text: string;
|
|
218
|
+
replies: CommentReply[];
|
|
219
|
+
resolved: boolean;
|
|
220
|
+
severity: CommentSeverity;
|
|
221
|
+
createdAt: string;
|
|
222
|
+
from: number;
|
|
223
|
+
to: number;
|
|
224
|
+
selectedText: string;
|
|
225
|
+
}
|
|
226
|
+
interface CommentsState {
|
|
227
|
+
comments: Comment[];
|
|
228
|
+
showPanel: boolean;
|
|
229
|
+
commentCount: number;
|
|
230
|
+
activeCommentId: string | null;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
interface TiptapEditorProps {
|
|
234
|
+
content: string | Record<string, unknown>;
|
|
235
|
+
onChange?: (html: string) => void;
|
|
236
|
+
onJsonChange?: (json: Record<string, unknown>) => void;
|
|
237
|
+
onCommentsChange?: (comments: Comment[]) => void;
|
|
238
|
+
onEditorReady?: (editor: Editor) => void;
|
|
239
|
+
editable?: boolean;
|
|
240
|
+
/** Reviewer mode: editable but locked to suggestion mode + comments only */
|
|
241
|
+
reviewerMode?: boolean;
|
|
242
|
+
placeholder?: string;
|
|
243
|
+
username?: string;
|
|
244
|
+
draftId?: string;
|
|
245
|
+
documentId?: string;
|
|
246
|
+
/** Enable persistent node-id extension (needed for AI edit operations) */
|
|
247
|
+
enableNodeIds?: boolean;
|
|
248
|
+
/** Enable AI drafting panel + section indexing hooks */
|
|
249
|
+
enableAIDrafting?: boolean;
|
|
250
|
+
/** Override the prose content area class (e.g. to center/constrain width) */
|
|
251
|
+
contentClassName?: string;
|
|
252
|
+
/** Force show comment bubble even when not editable (e.g. locked canvas) */
|
|
253
|
+
forceShowCommentBubble?: boolean;
|
|
254
|
+
/** When viewing a historical version, comment actions are read-only */
|
|
255
|
+
isHistoricalVersion?: boolean;
|
|
256
|
+
/** Show toolbar even when editor is not editable (e.g. locked canvas still needs AI/comment tools) */
|
|
257
|
+
showToolbar?: boolean;
|
|
258
|
+
}
|
|
259
|
+
declare const TiptapEditor: react__default.FC<TiptapEditorProps>;
|
|
260
|
+
|
|
261
|
+
declare function useTrackChanges(editor: Editor | null): TrackChangesState & {
|
|
262
|
+
toggleSuggestionMode: () => void;
|
|
263
|
+
acceptSuggestion: (s: Suggestion) => void;
|
|
264
|
+
rejectSuggestion: (s: Suggestion) => void;
|
|
265
|
+
acceptAll: () => void;
|
|
266
|
+
rejectAll: () => void;
|
|
267
|
+
setShowPanel: (show: boolean) => void;
|
|
268
|
+
};
|
|
269
|
+
type UseTrackChangesReturn = ReturnType<typeof useTrackChanges>;
|
|
270
|
+
|
|
271
|
+
declare function useComments(editor: Editor | null, draftId: string, username: string, initialComments?: Comment[]): {
|
|
272
|
+
comments: Comment[];
|
|
273
|
+
showPanel: boolean;
|
|
274
|
+
commentCount: number;
|
|
275
|
+
activeCommentId: string | null;
|
|
276
|
+
pendingSelectionText: string | null;
|
|
277
|
+
clickedCommentInfo: {
|
|
278
|
+
commentId: string;
|
|
279
|
+
source: "dot" | "highlight";
|
|
280
|
+
} | null;
|
|
281
|
+
setActiveCommentId: react.Dispatch<react.SetStateAction<string | null>>;
|
|
282
|
+
setShowPanel: react.Dispatch<react.SetStateAction<boolean>>;
|
|
283
|
+
setClickedCommentInfo: react.Dispatch<react.SetStateAction<{
|
|
284
|
+
commentId: string;
|
|
285
|
+
source: "dot" | "highlight";
|
|
286
|
+
} | null>>;
|
|
287
|
+
captureSelection: () => void;
|
|
288
|
+
clearPendingHighlight: () => void;
|
|
289
|
+
addComment: (text: string, severity?: CommentSeverity) => void;
|
|
290
|
+
addBatchComments: (newComments: Comment[]) => void;
|
|
291
|
+
deleteComment: (commentId: string) => void;
|
|
292
|
+
resolveComment: (commentId: string) => void;
|
|
293
|
+
resolveCommentsByIds: (ids: string[]) => void;
|
|
294
|
+
unresolveComment: (commentId: string) => void;
|
|
295
|
+
setSeverity: (commentId: string, severity: CommentSeverity) => void;
|
|
296
|
+
addReply: (commentId: string, text: string) => void;
|
|
297
|
+
deleteReply: (commentId: string, replyId: string) => void;
|
|
298
|
+
resolveAll: () => void;
|
|
299
|
+
};
|
|
300
|
+
type UseCommentsReturn = ReturnType<typeof useComments>;
|
|
301
|
+
|
|
302
|
+
/** Subset of the agent hook the toolbar actually uses — keeps the toolbar
|
|
303
|
+
* decoupled from the full UseEditorAgentReturn surface. */
|
|
304
|
+
interface PanelController {
|
|
305
|
+
isPanelOpen: boolean;
|
|
306
|
+
openPanel: () => void;
|
|
307
|
+
closePanel: () => void;
|
|
308
|
+
}
|
|
309
|
+
interface EditorToolbarProps {
|
|
310
|
+
editor: Editor | null;
|
|
311
|
+
trackChanges?: UseTrackChangesReturn;
|
|
312
|
+
comments?: UseCommentsReturn;
|
|
313
|
+
aiDrafting?: PanelController;
|
|
314
|
+
/** Reviewer mode: only show track changes + comments toolbar */
|
|
315
|
+
reviewerMode?: boolean;
|
|
316
|
+
/** Whether the review panel is currently open */
|
|
317
|
+
reviewPanelOpen?: boolean;
|
|
318
|
+
/** Toggle the review panel */
|
|
319
|
+
onToggleReviewPanel?: () => void;
|
|
320
|
+
}
|
|
321
|
+
declare const EditorToolbar: react__default.FC<EditorToolbarProps>;
|
|
322
|
+
|
|
323
|
+
interface EditOperationCardProps {
|
|
324
|
+
operation: EditOperationWithStatus;
|
|
325
|
+
index: number;
|
|
326
|
+
editor: Editor | null;
|
|
327
|
+
onToggle: (index: number) => void;
|
|
328
|
+
onApplySingle: (index: number) => void;
|
|
329
|
+
}
|
|
330
|
+
declare const EditOperationCard: react__default.FC<EditOperationCardProps>;
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* Shared types for the agent module.
|
|
334
|
+
*/
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Lightweight content shape for a playbook surfaced to the system prompt.
|
|
338
|
+
* The editor's playbook system fetches raw text out-of-band; we only need
|
|
339
|
+
* a title + body for the prompt.
|
|
340
|
+
*/
|
|
341
|
+
interface AgentPlaybook {
|
|
342
|
+
id: string;
|
|
343
|
+
title: string;
|
|
344
|
+
content: string;
|
|
345
|
+
}
|
|
346
|
+
interface AgentComplianceAct {
|
|
347
|
+
id: string;
|
|
348
|
+
title: string;
|
|
349
|
+
description?: string;
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* A single agent-recorded change. Exactly one of `suggestionIds` (content op
|
|
353
|
+
* tracked via suggestion-mode marks) or `inverseOp` (structural op that bypassed
|
|
354
|
+
* suggestion mode) is populated.
|
|
355
|
+
*/
|
|
356
|
+
interface AgentChange {
|
|
357
|
+
id: string;
|
|
358
|
+
tool: EditOperationType;
|
|
359
|
+
args: unknown;
|
|
360
|
+
suggestionIds?: number[];
|
|
361
|
+
inverseOp?: EditOperation;
|
|
362
|
+
appliedAt: number;
|
|
363
|
+
revertedAt?: number;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* Backend API client for editor chat sessions, history, and per-turn cost.
|
|
368
|
+
*
|
|
369
|
+
* Every export takes a `TiptapOfficeConfig` as its first argument. The library
|
|
370
|
+
* itself owns no URL constants, no auth headers, and no env-var lookups —
|
|
371
|
+
* everything comes from the config you pass to <TiptapOfficeProvider>.
|
|
372
|
+
*
|
|
373
|
+
* Your backend must expose:
|
|
374
|
+
* POST {apiBaseUrl}/editor/chat → { chatId, created }
|
|
375
|
+
* GET {apiBaseUrl}/editor/history?page&pageSize → { sessions, total, page, pageSize }
|
|
376
|
+
* GET {apiBaseUrl}/editor/history/{chatId} → { chatId, documentId, chatTitle, messages }
|
|
377
|
+
* POST {apiBaseUrl}/editor/history/{chatId}/append → ack body ignored
|
|
378
|
+
* POST {apiBaseUrl}/llm/cost → cost breakdown (or omit; `null` is tolerated)
|
|
379
|
+
*
|
|
380
|
+
* The LLM provider proxy lives under `{apiBaseUrl}{llmProxyPath}` and is
|
|
381
|
+
* handled by `agent/providers.ts`.
|
|
382
|
+
*/
|
|
383
|
+
|
|
384
|
+
interface ChatSession {
|
|
385
|
+
chatId: string;
|
|
386
|
+
documentId: string;
|
|
387
|
+
chatTitle: string;
|
|
388
|
+
messageCount: number;
|
|
389
|
+
lastEdited: string;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* Phase 2a — Agent-loop hook for the rewritten AI editor (spec §11).
|
|
394
|
+
*
|
|
395
|
+
* Owns: state machine, message projection from the Vercel AI SDK `fullStream`,
|
|
396
|
+
* provider/model selection, journal lifetime, chat history persistence.
|
|
397
|
+
*
|
|
398
|
+
* Phase 1's `runAgent` drives the loop; this hook reduces stream parts into UI
|
|
399
|
+
* state and persists transcripts after each turn.
|
|
400
|
+
*/
|
|
401
|
+
|
|
402
|
+
type AgentUIState = 'IDLE' | 'INITIALIZING' | 'RUNNING' | 'AWAITING_USER' | 'ERROR';
|
|
403
|
+
type AgentToolProgressStatus = 'running' | 'done' | 'failed';
|
|
404
|
+
interface AgentToolProgress {
|
|
405
|
+
id: string;
|
|
406
|
+
tool: string;
|
|
407
|
+
label: string;
|
|
408
|
+
status: AgentToolProgressStatus;
|
|
409
|
+
error?: string;
|
|
410
|
+
}
|
|
411
|
+
interface AgentChatMessage {
|
|
412
|
+
id: string;
|
|
413
|
+
role: 'user' | 'assistant';
|
|
414
|
+
content: string;
|
|
415
|
+
timestamp: number;
|
|
416
|
+
toolProgress?: AgentToolProgress[];
|
|
417
|
+
clarificationQuestions?: string[];
|
|
418
|
+
}
|
|
419
|
+
interface UseEditorAgentReturn {
|
|
420
|
+
state: AgentUIState;
|
|
421
|
+
messages: AgentChatMessage[];
|
|
422
|
+
statusMessage: string;
|
|
423
|
+
errorMessage: string;
|
|
424
|
+
isPanelOpen: boolean;
|
|
425
|
+
streamingMessageId: string | null;
|
|
426
|
+
activeChanges: AgentChange[];
|
|
427
|
+
provider: ProviderName;
|
|
428
|
+
model: string;
|
|
429
|
+
setProvider: (p: ProviderName, model: string) => void;
|
|
430
|
+
/** USD cost of the most recently completed turn. `null` until the first turn finishes or if pricing lookup failed. */
|
|
431
|
+
lastTurnCostUsd: number | null;
|
|
432
|
+
/** Sum of all per-turn costs since the chat was opened or reset. */
|
|
433
|
+
cumulativeCostUsd: number;
|
|
434
|
+
openPanel: () => void;
|
|
435
|
+
closePanel: () => void;
|
|
436
|
+
submitPrompt: (prompt: string, opts?: {
|
|
437
|
+
playbook?: AgentPlaybook;
|
|
438
|
+
}) => void;
|
|
439
|
+
submitClarificationAnswer: (answers: string[]) => void;
|
|
440
|
+
cancel: () => void;
|
|
441
|
+
startNewChat: () => void;
|
|
442
|
+
historySessions: ChatSession[];
|
|
443
|
+
isHistoryLoading: boolean;
|
|
444
|
+
fetchHistory: () => void;
|
|
445
|
+
loadSession: (chatId: string) => void;
|
|
446
|
+
}
|
|
447
|
+
declare function useEditorAgent(editor: Editor | null, documentId: string, options?: {
|
|
448
|
+
onAICommentsCreated?: (comments: Comment[]) => void;
|
|
449
|
+
comments?: Comment[];
|
|
450
|
+
suggestions?: Suggestion[];
|
|
451
|
+
onCommentsResolved?: (commentIds: string[]) => void;
|
|
452
|
+
/** Optional callback the agent can use to fetch a playbook by id mid-turn
|
|
453
|
+
* (exposed via the `lookup_playbook` tool). */
|
|
454
|
+
loadPlaybook?: (playbookId: string) => Promise<AgentPlaybook | null>;
|
|
455
|
+
/** Optional callback the agent can use to fetch a compliance act by id mid-turn
|
|
456
|
+
* (exposed via the `lookup_compliance_act` tool). */
|
|
457
|
+
loadComplianceAct?: (actId: string) => Promise<AgentComplianceAct | null>;
|
|
458
|
+
}): UseEditorAgentReturn;
|
|
459
|
+
|
|
460
|
+
declare function docxToHtml(arrayBuffer: ArrayBuffer): Promise<string>;
|
|
461
|
+
|
|
462
|
+
/**
|
|
463
|
+
* Apply an AI-generated text suggestion as a tracked change.
|
|
464
|
+
* The suggestion appears as a reviewable change the user can accept/reject.
|
|
465
|
+
*
|
|
466
|
+
* Temporarily enables suggest-changes mode (if not already on), performs the
|
|
467
|
+
* replacement, then restores the original mode. The dispatchTransaction wrapper
|
|
468
|
+
* automatically converts the replacement into insertion/deletion marks.
|
|
469
|
+
*/
|
|
470
|
+
declare function applyAISuggestion(editor: Editor, suggestion: {
|
|
471
|
+
textToReplace: string;
|
|
472
|
+
textReplacement: string;
|
|
473
|
+
reason?: string;
|
|
474
|
+
textBefore?: string;
|
|
475
|
+
textAfter?: string;
|
|
476
|
+
}): boolean;
|
|
477
|
+
/**
|
|
478
|
+
* Apply multiple AI suggestions to the document.
|
|
479
|
+
* Applies them in order; each suggestion should have enough context
|
|
480
|
+
* (textBefore/textAfter) to locate the correct position.
|
|
481
|
+
*/
|
|
482
|
+
declare function applyAISuggestions(editor: Editor, suggestions: Array<{
|
|
483
|
+
textToReplace: string;
|
|
484
|
+
textReplacement: string;
|
|
485
|
+
reason?: string;
|
|
486
|
+
textBefore?: string;
|
|
487
|
+
textAfter?: string;
|
|
488
|
+
}>): {
|
|
489
|
+
applied: number;
|
|
490
|
+
failed: number;
|
|
491
|
+
};
|
|
492
|
+
|
|
493
|
+
/**
|
|
494
|
+
* Edit applicator — converts AI edit operations into a single ProseMirror transaction.
|
|
495
|
+
* Implements all 13 operation types from ADR-014.
|
|
496
|
+
*/
|
|
497
|
+
|
|
498
|
+
/**
|
|
499
|
+
* Apply a list of edit operations as a single ProseMirror transaction.
|
|
500
|
+
* One Ctrl+Z undoes the entire edit plan atomically.
|
|
501
|
+
* Returns the list of operations with updated status.
|
|
502
|
+
*/
|
|
503
|
+
declare function applyEditPlan(editor: Editor, operations: EditOperationWithStatus[]): EditOperationWithStatus[];
|
|
504
|
+
/**
|
|
505
|
+
* Generate a string key for an applied operation (used in confirm request).
|
|
506
|
+
*/
|
|
507
|
+
declare function operationKey(op: EditOperationWithStatus): string;
|
|
508
|
+
|
|
509
|
+
export { type AgentChange, type AgentChatMessage, type AgentComplianceAct, type AgentPlaybook, type AgentToolProgress, type AgentUIState, type Comment, type CommentAuthor, type CommentReply, type CommentSeverity, type CommentsState, type EditOperation, EditOperationCard, type EditOperationWithStatus, type EditPlan, EditorToolbar, type ProviderName, type Suggestion, type SuggestionAuthor, TiptapEditor, type TiptapOfficeConfig, TiptapOfficeProvider, type TrackChangesState, type UseEditorAgentReturn, applyAISuggestion, applyAISuggestions, applyEditPlan, docxToHtml, operationKey, useComments, useEditorAgent, useTiptapOfficeConfig, useTrackChanges };
|