@platejs/ai 51.1.2 → 52.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.
@@ -1,471 +1,563 @@
1
- import * as platejs_react from 'platejs/react';
2
- import { PlateEditor, OverrideEditor, RenderNodeWrapperProps } from 'platejs/react';
3
- import * as platejs from 'platejs';
4
- import { ExtendConfig, SlateEditor, Range, NodeEntry, TElement, PluginConfig, Path, TIdElement, TRange, OmitFirst, EditorNodesOptions, TText, Descendant, RemoveNodesOptions } from 'platejs';
5
- import { B as BaseAIPluginConfig, b as AIMode, E as EditorPrompt, A as AIToolName } from '../getEditorPrompt-C6prTxft.js';
6
- import { UIMessage, ChatRequestOptions } from 'ai';
7
- import { UseChatHelpers } from '@ai-sdk/react';
8
- import { TriggerComboboxPluginOptions } from '@platejs/combobox';
9
- import { DeserializeMdOptions, SerializeMdOptions } from '@platejs/markdown';
10
- import React from 'react';
11
-
1
+ import { c as AIMode, d as BaseAIPluginConfig, i as EditorPrompt, l as AIToolName } from "../index-CyVv31EV.js";
2
+ import * as platejs4 from "platejs";
3
+ import { Descendant, EditorNodesOptions, ExtendConfig, NodeEntry, OmitFirst, Path, PluginConfig, Range, RemoveNodesOptions, SlateEditor, TElement, TIdElement, TRange, TText } from "platejs";
4
+ import { DeserializeMdOptions, SerializeMdOptions } from "@platejs/markdown";
5
+ import * as platejs_react0 from "platejs/react";
6
+ import { OverrideEditor, PlateEditor, RenderNodeWrapperProps } from "platejs/react";
7
+ import React from "react";
8
+ import { ChatRequestOptions, UIMessage } from "ai";
9
+ import { UseChatHelpers } from "@ai-sdk/react";
10
+ import { TriggerComboboxPluginOptions } from "@platejs/combobox";
11
+
12
+ //#region src/react/ai/AIPlugin.d.ts
12
13
  type AIPluginConfig = ExtendConfig<BaseAIPluginConfig>;
13
- declare const AIPlugin: platejs_react.PlatePlugin<platejs.PluginConfig<any, {}, {}, Record<any, {
14
- insertNodes: (nodes: platejs.Descendant[], args_1?: {
15
- target?: platejs.Path;
16
- } | undefined) => void;
17
- removeMarks: (args_0?: {
18
- at?: platejs.TLocation;
19
- } | undefined) => void;
20
- removeNodes: (args_0?: {
21
- at?: platejs.Path;
22
- } | undefined) => void;
23
- undo: () => void;
14
+ declare const AIPlugin: platejs_react0.PlatePlugin<platejs4.PluginConfig<any, {}, {}, Record<any, {
15
+ insertNodes: (nodes: platejs4.Descendant[], args_1?: {
16
+ target?: platejs4.Path;
17
+ } | undefined) => void;
18
+ removeMarks: (args_0?: {
19
+ at?: platejs4.TLocation;
20
+ } | undefined) => void;
21
+ removeNodes: (args_0?: {
22
+ at?: platejs4.Path;
23
+ } | undefined) => void;
24
+ undo: () => void;
24
25
  }>, {}>>;
25
-
26
+ //#endregion
27
+ //#region src/react/ai-chat/internal/types.d.ts
26
28
  type ToolName = 'comment' | 'edit' | 'generate';
27
29
  type TComment = {
28
- blockId: string;
29
- comment: string;
30
- content: string;
30
+ blockId: string;
31
+ comment: string;
32
+ content: string;
31
33
  };
32
34
  type MessageDataPart = {
33
- toolName: ToolName;
34
- comment?: TComment;
35
+ toolName: ToolName;
36
+ comment?: TComment;
35
37
  };
36
38
  type ChatMessage = UIMessage<{}, MessageDataPart>;
37
-
39
+ //#endregion
40
+ //#region src/react/ai/utils/aiCommentToRange.d.ts
38
41
  declare const aiCommentToRange: (editor: SlateEditor, aiComment: TComment) => Range | undefined;
39
-
42
+ //#endregion
43
+ //#region src/react/ai/utils/findTextRangeInBlock.d.ts
40
44
  /** Find text within a block, supporting fuzzy matching. */
41
- declare function findTextRangeInBlock({ block, findText, }: {
42
- block: NodeEntry;
43
- findText: string;
45
+ declare function findTextRangeInBlock({
46
+ block,
47
+ findText
48
+ }: {
49
+ block: NodeEntry;
50
+ findText: string;
44
51
  }): Range | null;
45
-
52
+ //#endregion
53
+ //#region src/react/ai-chat/transforms/acceptAIChat.d.ts
46
54
  declare const acceptAIChat: (editor: PlateEditor) => void;
47
-
48
- declare const insertBelowAIChat: (editor: PlateEditor, sourceEditor: SlateEditor, { format }?: {
49
- format?: "all" | "none" | "single";
55
+ //#endregion
56
+ //#region src/react/ai-chat/transforms/insertBelowAIChat.d.ts
57
+ declare const insertBelowAIChat: (editor: PlateEditor, sourceEditor: SlateEditor, {
58
+ format
59
+ }?: {
60
+ format?: "all" | "none" | "single";
50
61
  }) => void;
51
- declare const insertBelowGenerate: (editor: PlateEditor, sourceEditor: SlateEditor, { format }?: {
52
- format?: "all" | "none" | "single";
62
+ declare const insertBelowGenerate: (editor: PlateEditor, sourceEditor: SlateEditor, {
63
+ format
64
+ }?: {
65
+ format?: "all" | "none" | "single";
53
66
  }) => void;
54
-
55
- declare const createFormattedBlocks: ({ blocks, format, sourceBlock, }: {
56
- blocks: TElement[];
57
- format: "all" | "none" | "single";
58
- sourceBlock: NodeEntry;
67
+ //#endregion
68
+ //#region src/react/ai-chat/transforms/replaceSelectionAIChat.d.ts
69
+ declare const createFormattedBlocks: ({
70
+ blocks,
71
+ format,
72
+ sourceBlock
73
+ }: {
74
+ blocks: TElement[];
75
+ format: "all" | "none" | "single";
76
+ sourceBlock: NodeEntry;
59
77
  }) => any[] | null;
60
- declare const replaceSelectionAIChat: (editor: PlateEditor, sourceEditor: SlateEditor, { format }?: {
61
- format?: "all" | "none" | "single";
78
+ declare const replaceSelectionAIChat: (editor: PlateEditor, sourceEditor: SlateEditor, {
79
+ format
80
+ }?: {
81
+ format?: "all" | "none" | "single";
62
82
  }) => void;
63
-
64
- declare const resetAIChat: (editor: PlateEditor, { undo }?: {
65
- undo?: boolean;
83
+ //#endregion
84
+ //#region src/react/ai-chat/utils/resetAIChat.d.ts
85
+ declare const resetAIChat: (editor: PlateEditor, {
86
+ undo
87
+ }?: {
88
+ undo?: boolean;
66
89
  }) => void;
67
-
68
- declare const submitAIChat: (editor: PlateEditor, input: string, { mode, options, prompt, toolName: toolNameProps, }?: {
69
- mode?: AIMode;
70
- options?: ChatRequestOptions;
71
- prompt?: EditorPrompt;
72
- toolName?: AIToolName;
90
+ //#endregion
91
+ //#region src/react/ai-chat/utils/submitAIChat.d.ts
92
+ declare const submitAIChat: (editor: PlateEditor, input: string, {
93
+ mode,
94
+ options,
95
+ prompt,
96
+ toolName: toolNameProps
97
+ }?: {
98
+ mode?: AIMode;
99
+ options?: ChatRequestOptions;
100
+ prompt?: EditorPrompt;
101
+ toolName?: AIToolName;
73
102
  }) => void;
74
-
103
+ //#endregion
104
+ //#region src/react/ai-chat/AIChatPlugin.d.ts
75
105
  type AIChatPluginConfig = PluginConfig<'aiChat', {
76
- _blockChunks: string;
77
- _blockPath: Path | null;
78
- /** @private Using For streamInsertChunk */
79
- _mdxName: string | null;
80
- _replaceIds: string[];
81
- /** @private The Editor used to generate the AI response. */
82
- aiEditor: SlateEditor | null;
83
- chat: UseChatHelpers<ChatMessage>;
84
- chatNodes: TIdElement[];
85
- chatSelection: TRange | null;
86
- /** @deprecated Use api.aiChat.node({streaming:true}) instead */
87
- experimental_lastTextId: string | null;
88
- /**
89
- * Specifies how the assistant message is handled:
90
- *
91
- * - 'insert': Directly inserts content into the editor without preview.
92
- * - 'chat': Initiates an interactive session to review and refine content
93
- * before insertion.
94
- */
95
- mode: AIMode;
96
- open: boolean;
97
- /** Whether the AI response is currently streaming. Cursor mode only. */
98
- streaming: boolean;
99
- toolName: AIToolName;
106
+ _blockChunks: string;
107
+ _blockPath: Path | null;
108
+ /** @private Using For streamInsertChunk */
109
+ _mdxName: string | null;
110
+ _replaceIds: string[];
111
+ /** @private The Editor used to generate the AI response. */
112
+ aiEditor: SlateEditor | null;
113
+ chat: UseChatHelpers<ChatMessage>;
114
+ chatNodes: TIdElement[];
115
+ chatSelection: TRange | null;
116
+ /** @deprecated Use api.aiChat.node({streaming:true}) instead */
117
+ experimental_lastTextId: string | null;
118
+ /**
119
+ * Specifies how the assistant message is handled:
120
+ *
121
+ * - 'insert': Directly inserts content into the editor without preview.
122
+ * - 'chat': Initiates an interactive session to review and refine content
123
+ * before insertion.
124
+ */
125
+ mode: AIMode;
126
+ open: boolean;
127
+ /** Whether the AI response is currently streaming. Cursor mode only. */
128
+ streaming: boolean;
129
+ toolName: AIToolName;
100
130
  } & TriggerComboboxPluginOptions, {
101
- aiChat: {
102
- reset: OmitFirst<typeof resetAIChat>;
103
- submit: OmitFirst<typeof submitAIChat>;
104
- hide: (options?: {
105
- focus?: boolean;
106
- undo?: boolean;
107
- }) => void;
108
- node: (options?: EditorNodesOptions & {
109
- anchor?: boolean;
110
- streaming?: boolean;
111
- }) => NodeEntry | undefined;
112
- reload: () => void;
113
- show: () => void;
114
- stop: () => void;
115
- };
131
+ aiChat: {
132
+ reset: OmitFirst<typeof resetAIChat>;
133
+ submit: OmitFirst<typeof submitAIChat>;
134
+ hide: (options?: {
135
+ focus?: boolean;
136
+ undo?: boolean;
137
+ }) => void;
138
+ node: (options?: EditorNodesOptions & {
139
+ anchor?: boolean;
140
+ streaming?: boolean;
141
+ }) => NodeEntry | undefined;
142
+ reload: () => void;
143
+ show: () => void;
144
+ stop: () => void;
145
+ };
116
146
  }, {
117
- aiChat: {
118
- accept: OmitFirst<typeof acceptAIChat>;
119
- insertBelow: OmitFirst<typeof insertBelowAIChat>;
120
- replaceSelection: OmitFirst<typeof replaceSelectionAIChat>;
121
- removeAnchor: (options?: EditorNodesOptions) => void;
122
- };
147
+ aiChat: {
148
+ accept: OmitFirst<typeof acceptAIChat>;
149
+ insertBelow: OmitFirst<typeof insertBelowAIChat>;
150
+ replaceSelection: OmitFirst<typeof replaceSelectionAIChat>;
151
+ removeAnchor: (options?: EditorNodesOptions) => void;
152
+ };
123
153
  }>;
124
- declare const AIChatPlugin: platejs_react.PlatePlugin<PluginConfig<"aiChat", {
125
- _blockChunks: string;
126
- _blockPath: Path | null;
127
- /** @private Using For streamInsertChunk */
128
- _mdxName: string | null;
129
- _replaceIds: string[];
130
- /** @private The Editor used to generate the AI response. */
131
- aiEditor: SlateEditor | null;
132
- chat: UseChatHelpers<ChatMessage>;
133
- chatNodes: TIdElement[];
134
- chatSelection: TRange | null;
135
- /** @deprecated Use api.aiChat.node({streaming:true}) instead */
136
- experimental_lastTextId: string | null;
137
- /**
138
- * Specifies how the assistant message is handled:
139
- *
140
- * - 'insert': Directly inserts content into the editor without preview.
141
- * - 'chat': Initiates an interactive session to review and refine content
142
- * before insertion.
143
- */
144
- mode: AIMode;
145
- open: boolean;
146
- /** Whether the AI response is currently streaming. Cursor mode only. */
147
- streaming: boolean;
148
- toolName: AIToolName;
154
+ declare const AIChatPlugin: platejs_react0.PlatePlugin<PluginConfig<"aiChat", {
155
+ _blockChunks: string;
156
+ _blockPath: Path | null;
157
+ /** @private Using For streamInsertChunk */
158
+ _mdxName: string | null;
159
+ _replaceIds: string[];
160
+ /** @private The Editor used to generate the AI response. */
161
+ aiEditor: SlateEditor | null;
162
+ chat: UseChatHelpers<ChatMessage>;
163
+ chatNodes: TIdElement[];
164
+ chatSelection: TRange | null;
165
+ /** @deprecated Use api.aiChat.node({streaming:true}) instead */
166
+ experimental_lastTextId: string | null;
167
+ /**
168
+ * Specifies how the assistant message is handled:
169
+ *
170
+ * - 'insert': Directly inserts content into the editor without preview.
171
+ * - 'chat': Initiates an interactive session to review and refine content
172
+ * before insertion.
173
+ */
174
+ mode: AIMode;
175
+ open: boolean;
176
+ /** Whether the AI response is currently streaming. Cursor mode only. */
177
+ streaming: boolean;
178
+ toolName: AIToolName;
149
179
  } & TriggerComboboxPluginOptions, {
150
- aiChat: {
151
- reset: OmitFirst<typeof resetAIChat>;
152
- submit: OmitFirst<typeof submitAIChat>;
153
- hide: (options?: {
154
- focus?: boolean;
155
- undo?: boolean;
156
- }) => void;
157
- node: (options?: EditorNodesOptions & {
158
- anchor?: boolean;
159
- streaming?: boolean;
160
- }) => NodeEntry | undefined;
161
- reload: () => void;
162
- show: () => void;
163
- stop: () => void;
164
- };
165
- } & Record<"aiChat", Pick<{
180
+ aiChat: {
166
181
  reset: OmitFirst<typeof resetAIChat>;
167
182
  submit: OmitFirst<typeof submitAIChat>;
168
183
  hide: (options?: {
169
- focus?: boolean;
170
- undo?: boolean;
184
+ focus?: boolean;
185
+ undo?: boolean;
171
186
  }) => void;
172
187
  node: (options?: EditorNodesOptions & {
173
- anchor?: boolean;
174
- streaming?: boolean;
188
+ anchor?: boolean;
189
+ streaming?: boolean;
175
190
  }) => NodeEntry | undefined;
176
191
  reload: () => void;
177
192
  show: () => void;
178
193
  stop: () => void;
194
+ };
195
+ } & Record<"aiChat", Pick<{
196
+ reset: OmitFirst<typeof resetAIChat>;
197
+ submit: OmitFirst<typeof submitAIChat>;
198
+ hide: (options?: {
199
+ focus?: boolean;
200
+ undo?: boolean;
201
+ }) => void;
202
+ node: (options?: EditorNodesOptions & {
203
+ anchor?: boolean;
204
+ streaming?: boolean;
205
+ }) => NodeEntry | undefined;
206
+ reload: () => void;
207
+ show: () => void;
208
+ stop: () => void;
179
209
  }, "node" | "stop" | "reset" | "submit">> & Record<"aiChat", {
180
- hide: ({ focus, undo, }?: {
181
- focus?: boolean;
182
- undo?: boolean;
183
- }) => void;
184
- show: () => void;
210
+ hide: ({
211
+ focus,
212
+ undo
213
+ }?: {
214
+ focus?: boolean;
215
+ undo?: boolean;
216
+ }) => void;
217
+ show: () => void;
185
218
  }>, {
186
- aiChat: {
187
- accept: OmitFirst<typeof acceptAIChat>;
188
- insertBelow: OmitFirst<typeof insertBelowAIChat>;
189
- replaceSelection: OmitFirst<typeof replaceSelectionAIChat>;
190
- removeAnchor: (options?: EditorNodesOptions) => void;
191
- };
219
+ aiChat: {
220
+ accept: OmitFirst<typeof acceptAIChat>;
221
+ insertBelow: OmitFirst<typeof insertBelowAIChat>;
222
+ replaceSelection: OmitFirst<typeof replaceSelectionAIChat>;
223
+ removeAnchor: (options?: EditorNodesOptions) => void;
224
+ };
192
225
  } & Record<"aiChat", {
193
- accept: () => void;
194
- insertBelow: (sourceEditor: SlateEditor, args_1?: {
195
- format?: "all" | "none" | "single";
196
- } | undefined) => void;
197
- removeAnchor: (options?: platejs.RemoveNodesOptions | undefined) => void;
198
- replaceSelection: (sourceEditor: SlateEditor, args_1?: {
199
- format?: "all" | "none" | "single";
200
- } | undefined) => void;
226
+ accept: () => void;
227
+ insertBelow: (sourceEditor: SlateEditor, args_1?: {
228
+ format?: "all" | "none" | "single";
229
+ } | undefined) => void;
230
+ removeAnchor: (options?: platejs4.RemoveNodesOptions | undefined) => void;
231
+ replaceSelection: (sourceEditor: SlateEditor, args_1?: {
232
+ format?: "all" | "none" | "single";
233
+ } | undefined) => void;
201
234
  }>, {}>>;
202
-
235
+ //#endregion
236
+ //#region src/react/ai-chat/withAIChat.d.ts
203
237
  declare const withAIChat: OverrideEditor<AIChatPluginConfig>;
204
-
238
+ //#endregion
239
+ //#region src/react/ai-chat/hooks/useAIChatEditor.d.ts
205
240
  /**
206
241
  * Register an editor in the AI chat plugin, and deserializes the content into
207
242
  * `editor.children` with block-level memoization.
208
243
  */
209
- declare const useAIChatEditor: (editor: SlateEditor, content: string, { parser }?: DeserializeMdOptions) => void;
210
-
211
- declare const useChatChunk: ({ onChunk, onFinish, }: {
212
- onChunk: (chunk: {
213
- chunk: string;
214
- isFirst: boolean;
215
- nodes: TText[];
216
- text: string;
217
- }) => void;
218
- onFinish?: ({ content }: {
219
- content: string;
220
- }) => void;
244
+ declare const useAIChatEditor: (editor: SlateEditor, content: string, {
245
+ parser
246
+ }?: DeserializeMdOptions) => void;
247
+ //#endregion
248
+ //#region src/react/ai-chat/hooks/useChatChunk.d.ts
249
+ declare const useChatChunk: ({
250
+ onChunk,
251
+ onFinish
252
+ }: {
253
+ onChunk: (chunk: {
254
+ chunk: string;
255
+ isFirst: boolean;
256
+ nodes: TText[];
257
+ text: string;
258
+ }) => void;
259
+ onFinish?: ({
260
+ content
261
+ }: {
262
+ content: string;
263
+ }) => void;
221
264
  }) => void;
222
-
265
+ //#endregion
266
+ //#region src/react/ai-chat/hooks/useEditorChat.d.ts
223
267
  type UseEditorChatOptions = {
224
- chat?: any;
225
- onOpenBlockSelection?: (blocks: NodeEntry[]) => void;
226
- onOpenChange?: (open: boolean) => void;
227
- onOpenCursor?: () => void;
228
- onOpenSelection?: () => void;
268
+ chat?: any;
269
+ onOpenBlockSelection?: (blocks: NodeEntry[]) => void;
270
+ onOpenChange?: (open: boolean) => void;
271
+ onOpenCursor?: () => void;
272
+ onOpenSelection?: () => void;
229
273
  };
230
- declare const useEditorChat: ({ onOpenBlockSelection, onOpenChange, onOpenCursor, onOpenSelection, }: UseEditorChatOptions) => void;
231
-
232
- declare const streamDeserializeInlineMd: (editor: PlateEditor, text: string, options?: DeserializeMdOptions) => platejs.Descendant[];
233
-
274
+ declare const useEditorChat: ({
275
+ onOpenBlockSelection,
276
+ onOpenChange,
277
+ onOpenCursor,
278
+ onOpenSelection
279
+ }: UseEditorChatOptions) => void;
280
+ //#endregion
281
+ //#region src/react/ai-chat/streaming/streamDeserializeInlineMd.d.ts
282
+ declare const streamDeserializeInlineMd: (editor: PlateEditor, text: string, options?: DeserializeMdOptions) => platejs4.Descendant[];
283
+ //#endregion
284
+ //#region src/react/ai-chat/streaming/streamDeserializeMd.d.ts
234
285
  declare const streamDeserializeMd: (editor: PlateEditor, data: string, options?: DeserializeMdOptions) => TElement[] | {
235
- children: {
236
- text: string;
237
- }[];
238
- type: string;
286
+ children: {
287
+ text: string;
288
+ }[];
289
+ type: string;
239
290
  }[];
240
-
291
+ //#endregion
292
+ //#region src/react/ai-chat/streaming/streamInsertChunk.d.ts
241
293
  type SteamInsertChunkOptions = {
242
- elementProps?: any;
243
- textProps?: any;
294
+ elementProps?: any;
295
+ textProps?: any;
244
296
  };
245
297
  /** @experimental */
246
298
  declare function streamInsertChunk(editor: PlateEditor, chunk: string, options?: SteamInsertChunkOptions): void;
247
299
  declare const getCurrentBlockPath: (editor: SlateEditor) => Path;
248
-
300
+ //#endregion
301
+ //#region src/react/ai-chat/streaming/streamSerializeMd.d.ts
249
302
  declare const streamSerializeMd: (editor: PlateEditor, options: SerializeMdOptions, chunk: string) => string;
250
-
303
+ //#endregion
304
+ //#region src/react/ai-chat/streaming/utils/escapeInput.d.ts
251
305
  declare const escapeInput: (data: string) => string;
252
-
306
+ //#endregion
307
+ //#region src/react/ai-chat/streaming/utils/getListNode.d.ts
253
308
  declare const getListNode: (editor: PlateEditor, node: TElement) => TElement;
254
-
309
+ //#endregion
310
+ //#region src/react/ai-chat/streaming/utils/isSameNode.d.ts
255
311
  declare const isSameNode: (editor: PlateEditor, node1: TElement | TText, node2: TElement | TText) => boolean;
256
-
312
+ //#endregion
313
+ //#region src/react/ai-chat/streaming/utils/nodesWithProps.d.ts
257
314
  declare const nodesWithProps: (editor: PlateEditor, nodes: Descendant[], options: SteamInsertChunkOptions) => Descendant[];
258
-
259
- declare const getChunkTrimmed: (chunk: string, { direction, }?: {
260
- direction?: "left" | "right";
315
+ //#endregion
316
+ //#region src/react/ai-chat/streaming/utils/utils.d.ts
317
+ declare const getChunkTrimmed: (chunk: string, {
318
+ direction
319
+ }?: {
320
+ direction?: "left" | "right";
261
321
  }) => string;
262
322
  declare function isCompleteCodeBlock(str: string): boolean;
263
323
  declare function isCompleteMath(str: string): boolean;
264
-
324
+ //#endregion
325
+ //#region src/react/ai-chat/transforms/removeAnchorAIChat.d.ts
265
326
  declare const removeAnchorAIChat: (editor: PlateEditor, options?: RemoveNodesOptions) => void;
266
-
327
+ //#endregion
328
+ //#region src/react/ai-chat/utils/acceptAISuggestions.d.ts
267
329
  declare const acceptAISuggestions: (editor: PlateEditor) => void;
268
-
330
+ //#endregion
331
+ //#region src/react/ai-chat/utils/applyAISuggestions.d.ts
269
332
  declare const applyAISuggestions: (editor: SlateEditor, content: string) => void;
270
-
333
+ //#endregion
334
+ //#region src/react/ai-chat/utils/getLastAssistantMessage.d.ts
271
335
  declare function getLastAssistantMessage(editor: PlateEditor): ChatMessage | undefined;
272
336
  declare function useLastAssistantMessage(): ChatMessage | undefined;
273
-
337
+ //#endregion
338
+ //#region src/react/ai-chat/utils/rejectAISuggestions.d.ts
274
339
  declare const rejectAISuggestions: (editor: PlateEditor) => void;
275
-
340
+ //#endregion
341
+ //#region src/react/copilot/utils/callCompletionApi.d.ts
276
342
  declare const getOriginalFetch: () => typeof fetch;
277
343
  type CallCompletionApiOptions = {
278
- prompt: string;
279
- api?: string;
280
- body?: Record<string, any>;
281
- credentials?: RequestCredentials | undefined;
282
- fetch?: ReturnType<typeof getOriginalFetch> | undefined;
283
- headers?: HeadersInit | undefined;
284
- setAbortController?: (abortController: AbortController | null) => void;
285
- setCompletion?: (completion: string) => void;
286
- setError?: (error: Error | null) => void;
287
- setLoading?: (loading: boolean) => void;
288
- onError?: ((error: Error) => void) | undefined;
289
- onFinish?: ((prompt: string, completion: string) => void) | undefined;
290
- onResponse?: ((response: Response) => Promise<void> | void) | undefined;
344
+ prompt: string;
345
+ api?: string;
346
+ body?: Record<string, any>;
347
+ credentials?: RequestCredentials | undefined;
348
+ fetch?: ReturnType<typeof getOriginalFetch> | undefined;
349
+ headers?: HeadersInit | undefined;
350
+ setAbortController?: (abortController: AbortController | null) => void;
351
+ setCompletion?: (completion: string) => void;
352
+ setError?: (error: Error | null) => void;
353
+ setLoading?: (loading: boolean) => void;
354
+ onError?: ((error: Error) => void) | undefined;
355
+ onFinish?: ((prompt: string, completion: string) => void) | undefined;
356
+ onResponse?: ((response: Response) => Promise<void> | void) | undefined;
291
357
  };
292
358
  type CompleteOptions = Omit<CallCompletionApiOptions, 'setAbortController' | 'setCompletion' | 'setError' | 'setLoading'>;
293
- declare function callCompletionApi({ api, body, credentials, fetch, headers, prompt, setAbortController, setCompletion, setError, setLoading, onError, onFinish, onResponse, }: CallCompletionApiOptions): Promise<string | null | undefined>;
294
-
359
+ declare function callCompletionApi({
360
+ api,
361
+ body,
362
+ credentials,
363
+ fetch,
364
+ headers,
365
+ prompt,
366
+ setAbortController,
367
+ setCompletion,
368
+ setError,
369
+ setLoading,
370
+ onError,
371
+ onFinish,
372
+ onResponse
373
+ }: CallCompletionApiOptions): Promise<string | null | undefined>;
374
+ //#endregion
375
+ //#region src/react/copilot/transforms/acceptCopilot.d.ts
295
376
  declare const acceptCopilot: (editor: PlateEditor) => false | undefined;
296
-
377
+ //#endregion
378
+ //#region src/react/copilot/transforms/acceptCopilotNextWord.d.ts
297
379
  declare const acceptCopilotNextWord: (editor: PlateEditor) => false | undefined;
298
-
380
+ //#endregion
381
+ //#region src/react/copilot/utils/getNextWord.d.ts
299
382
  type GetNextWord = (options: {
300
- text: string;
383
+ text: string;
301
384
  }) => {
302
- firstWord: string;
303
- remainingText: string;
385
+ firstWord: string;
386
+ remainingText: string;
304
387
  };
305
388
  declare const getNextWord: GetNextWord;
306
-
389
+ //#endregion
390
+ //#region src/react/copilot/utils/triggerCopilotSuggestion.d.ts
307
391
  declare const triggerCopilotSuggestion: (editor: PlateEditor) => Promise<false | undefined>;
308
-
392
+ //#endregion
393
+ //#region src/react/copilot/CopilotPlugin.d.ts
309
394
  type CopilotPluginConfig = PluginConfig<'copilot', CompletionState & {
310
- /**
311
- * AI completion options. See:
312
- * {@link https://sdk.vercel.ai/docs/reference/ai-sdk-ui/use-completion#parameters | AI SDK UI useCompletion Parameters}
313
- */
314
- completeOptions?: Partial<CompleteOptions>;
315
- /**
316
- * Debounce delay for auto triggering AI completion.
317
- *
318
- * @default 0
319
- */
320
- debounceDelay?: number;
321
- /** Get the next word to be inserted. */
322
- getNextWord?: GetNextWord;
323
- /** Render the ghost text. */
324
- renderGhostText?: (() => React.ReactNode) | null;
325
- shouldAbort?: boolean;
326
- /** The node id where the suggestion is located. */
327
- suggestionNodeId?: string | null;
328
- /** The text of the suggestion. */
329
- suggestionText?: string | null;
330
- /**
331
- * Conditions to auto trigger copilot, used in addition to triggerQuery.
332
- * Disabling defaults to:
333
- *
334
- * - Block above is empty
335
- * - Block above ends with a space
336
- * - There is already a suggestion
337
- */
338
- autoTriggerQuery?: (options: {
339
- editor: PlateEditor;
340
- }) => boolean;
341
- /**
342
- * Get the prompt for AI completion.
343
- *
344
- * @default serializeMdNodes(editor.api.block({ highest: true }))
345
- */
346
- getPrompt?: (options: {
347
- editor: PlateEditor;
348
- }) => string;
349
- /**
350
- * Conditions to trigger copilot. Disabling defaults to:
351
- *
352
- * - Selection is expanded
353
- * - Selection is not at the end of block
354
- */
355
- triggerQuery?: (options: {
356
- editor: PlateEditor;
357
- }) => boolean;
395
+ /**
396
+ * AI completion options. See:
397
+ * {@link https://sdk.vercel.ai/docs/reference/ai-sdk-ui/use-completion#parameters | AI SDK UI useCompletion Parameters}
398
+ */
399
+ completeOptions?: Partial<CompleteOptions>;
400
+ /**
401
+ * Debounce delay for auto triggering AI completion.
402
+ *
403
+ * @default 0
404
+ */
405
+ debounceDelay?: number;
406
+ /** Get the next word to be inserted. */
407
+ getNextWord?: GetNextWord;
408
+ /** Render the ghost text. */
409
+ renderGhostText?: (() => React.ReactNode) | null;
410
+ shouldAbort?: boolean;
411
+ /** The node id where the suggestion is located. */
412
+ suggestionNodeId?: string | null;
413
+ /** The text of the suggestion. */
414
+ suggestionText?: string | null;
415
+ /**
416
+ * Conditions to auto trigger copilot, used in addition to triggerQuery.
417
+ * Disabling defaults to:
418
+ *
419
+ * - Block above is empty
420
+ * - Block above ends with a space
421
+ * - There is already a suggestion
422
+ */
423
+ autoTriggerQuery?: (options: {
424
+ editor: PlateEditor;
425
+ }) => boolean;
426
+ /**
427
+ * Get the prompt for AI completion.
428
+ *
429
+ * @default serializeMdNodes(editor.api.block({ highest: true }))
430
+ */
431
+ getPrompt?: (options: {
432
+ editor: PlateEditor;
433
+ }) => string;
434
+ /**
435
+ * Conditions to trigger copilot. Disabling defaults to:
436
+ *
437
+ * - Selection is expanded
438
+ * - Selection is not at the end of block
439
+ */
440
+ triggerQuery?: (options: {
441
+ editor: PlateEditor;
442
+ }) => boolean;
358
443
  }, {
359
- copilot: {
360
- triggerSuggestion: OmitFirst<typeof triggerCopilotSuggestion>;
361
- reject: () => false | undefined;
362
- setBlockSuggestion: (options: {
363
- text: string;
364
- id?: string;
365
- }) => void;
366
- stop: () => void;
367
- };
444
+ copilot: {
445
+ triggerSuggestion: OmitFirst<typeof triggerCopilotSuggestion>;
446
+ reject: () => false | undefined;
447
+ setBlockSuggestion: (options: {
448
+ text: string;
449
+ id?: string;
450
+ }) => void;
451
+ stop: () => void;
452
+ };
368
453
  }, {
369
- copilot: {
370
- accept: OmitFirst<typeof acceptCopilot>;
371
- acceptNextWord: OmitFirst<typeof acceptCopilotNextWord>;
372
- };
454
+ copilot: {
455
+ accept: OmitFirst<typeof acceptCopilot>;
456
+ acceptNextWord: OmitFirst<typeof acceptCopilotNextWord>;
457
+ };
373
458
  }, {
374
- isSuggested?: (id: string) => boolean;
459
+ isSuggested?: (id: string) => boolean;
375
460
  }>;
376
461
  type CompletionState = {
377
- abortController?: AbortController | null;
378
- completion?: string | null;
379
- error?: Error | null;
380
- isLoading?: boolean;
462
+ abortController?: AbortController | null;
463
+ completion?: string | null;
464
+ error?: Error | null;
465
+ isLoading?: boolean;
381
466
  };
382
- declare const CopilotPlugin: platejs_react.PlatePlugin<PluginConfig<"copilot", CompletionState & {
383
- /**
384
- * AI completion options. See:
385
- * {@link https://sdk.vercel.ai/docs/reference/ai-sdk-ui/use-completion#parameters | AI SDK UI useCompletion Parameters}
386
- */
387
- completeOptions?: Partial<CompleteOptions>;
388
- /**
389
- * Debounce delay for auto triggering AI completion.
390
- *
391
- * @default 0
392
- */
393
- debounceDelay?: number;
394
- /** Get the next word to be inserted. */
395
- getNextWord?: GetNextWord;
396
- /** Render the ghost text. */
397
- renderGhostText?: (() => React.ReactNode) | null;
398
- shouldAbort?: boolean;
399
- /** The node id where the suggestion is located. */
400
- suggestionNodeId?: string | null;
401
- /** The text of the suggestion. */
402
- suggestionText?: string | null;
403
- /**
404
- * Conditions to auto trigger copilot, used in addition to triggerQuery.
405
- * Disabling defaults to:
406
- *
407
- * - Block above is empty
408
- * - Block above ends with a space
409
- * - There is already a suggestion
410
- */
411
- autoTriggerQuery?: (options: {
412
- editor: PlateEditor;
413
- }) => boolean;
414
- /**
415
- * Get the prompt for AI completion.
416
- *
417
- * @default serializeMdNodes(editor.api.block({ highest: true }))
418
- */
419
- getPrompt?: (options: {
420
- editor: PlateEditor;
421
- }) => string;
422
- /**
423
- * Conditions to trigger copilot. Disabling defaults to:
424
- *
425
- * - Selection is expanded
426
- * - Selection is not at the end of block
427
- */
428
- triggerQuery?: (options: {
429
- editor: PlateEditor;
430
- }) => boolean;
467
+ declare const CopilotPlugin: platejs_react0.PlatePlugin<PluginConfig<"copilot", CompletionState & {
468
+ /**
469
+ * AI completion options. See:
470
+ * {@link https://sdk.vercel.ai/docs/reference/ai-sdk-ui/use-completion#parameters | AI SDK UI useCompletion Parameters}
471
+ */
472
+ completeOptions?: Partial<CompleteOptions>;
473
+ /**
474
+ * Debounce delay for auto triggering AI completion.
475
+ *
476
+ * @default 0
477
+ */
478
+ debounceDelay?: number;
479
+ /** Get the next word to be inserted. */
480
+ getNextWord?: GetNextWord;
481
+ /** Render the ghost text. */
482
+ renderGhostText?: (() => React.ReactNode) | null;
483
+ shouldAbort?: boolean;
484
+ /** The node id where the suggestion is located. */
485
+ suggestionNodeId?: string | null;
486
+ /** The text of the suggestion. */
487
+ suggestionText?: string | null;
488
+ /**
489
+ * Conditions to auto trigger copilot, used in addition to triggerQuery.
490
+ * Disabling defaults to:
491
+ *
492
+ * - Block above is empty
493
+ * - Block above ends with a space
494
+ * - There is already a suggestion
495
+ */
496
+ autoTriggerQuery?: (options: {
497
+ editor: PlateEditor;
498
+ }) => boolean;
499
+ /**
500
+ * Get the prompt for AI completion.
501
+ *
502
+ * @default serializeMdNodes(editor.api.block({ highest: true }))
503
+ */
504
+ getPrompt?: (options: {
505
+ editor: PlateEditor;
506
+ }) => string;
507
+ /**
508
+ * Conditions to trigger copilot. Disabling defaults to:
509
+ *
510
+ * - Selection is expanded
511
+ * - Selection is not at the end of block
512
+ */
513
+ triggerQuery?: (options: {
514
+ editor: PlateEditor;
515
+ }) => boolean;
431
516
  }, {
432
- copilot: {
433
- triggerSuggestion: OmitFirst<typeof triggerCopilotSuggestion>;
434
- reject: () => false | undefined;
435
- setBlockSuggestion: (options: {
436
- text: string;
437
- id?: string;
438
- }) => void;
439
- stop: () => void;
440
- };
441
- } & Record<"copilot", Omit<{
517
+ copilot: {
442
518
  triggerSuggestion: OmitFirst<typeof triggerCopilotSuggestion>;
443
519
  reject: () => false | undefined;
444
520
  setBlockSuggestion: (options: {
445
- text: string;
446
- id?: string;
521
+ text: string;
522
+ id?: string;
447
523
  }) => void;
448
524
  stop: () => void;
525
+ };
526
+ } & Record<"copilot", Omit<{
527
+ triggerSuggestion: OmitFirst<typeof triggerCopilotSuggestion>;
528
+ reject: () => false | undefined;
529
+ setBlockSuggestion: (options: {
530
+ text: string;
531
+ id?: string;
532
+ }) => void;
533
+ stop: () => void;
449
534
  }, "reject">> & Record<"copilot", {
450
- reject: () => false | undefined;
535
+ reject: () => false | undefined;
451
536
  }>, {
452
- copilot: {
453
- accept: OmitFirst<typeof acceptCopilot>;
454
- acceptNextWord: OmitFirst<typeof acceptCopilotNextWord>;
455
- };
537
+ copilot: {
538
+ accept: OmitFirst<typeof acceptCopilot>;
539
+ acceptNextWord: OmitFirst<typeof acceptCopilotNextWord>;
540
+ };
456
541
  } & Record<"copilot", {
457
- accept: () => false | undefined;
458
- acceptNextWord: () => false | undefined;
542
+ accept: () => false | undefined;
543
+ acceptNextWord: () => false | undefined;
459
544
  }>, {
460
- isSuggested?: (id: string) => boolean;
545
+ isSuggested?: (id: string) => boolean;
461
546
  }>>;
462
-
463
- declare const renderCopilotBelowNodes: ({ editor, }: RenderNodeWrapperProps<CopilotPluginConfig>) => (({ children }: {
464
- children: React.ReactNode;
547
+ //#endregion
548
+ //#region src/react/copilot/renderCopilotBelowNodes.d.ts
549
+ declare const renderCopilotBelowNodes: ({
550
+ editor
551
+ }: RenderNodeWrapperProps<CopilotPluginConfig>) => (({
552
+ children
553
+ }: {
554
+ children: React.ReactNode;
465
555
  }) => React.JSX.Element) | undefined;
466
-
556
+ //#endregion
557
+ //#region src/react/copilot/withCopilot.d.ts
467
558
  declare const withCopilot: OverrideEditor<CopilotPluginConfig>;
468
-
559
+ //#endregion
560
+ //#region src/react/copilot/utils/withoutAbort.d.ts
469
561
  declare const withoutAbort: (editor: PlateEditor, fn: () => void) => void;
470
-
471
- export { AIChatPlugin, type AIChatPluginConfig, AIPlugin, type AIPluginConfig, type CallCompletionApiOptions, type CompleteOptions, CopilotPlugin, type CopilotPluginConfig, type GetNextWord, type SteamInsertChunkOptions, type UseEditorChatOptions, acceptAIChat, acceptAISuggestions, acceptCopilot, acceptCopilotNextWord, aiCommentToRange, applyAISuggestions, callCompletionApi, createFormattedBlocks, escapeInput, findTextRangeInBlock, getChunkTrimmed, getCurrentBlockPath, getLastAssistantMessage, getListNode, getNextWord, insertBelowAIChat, insertBelowGenerate, isCompleteCodeBlock, isCompleteMath, isSameNode, nodesWithProps, rejectAISuggestions, removeAnchorAIChat, renderCopilotBelowNodes, replaceSelectionAIChat, resetAIChat, streamDeserializeInlineMd, streamDeserializeMd, streamInsertChunk, streamSerializeMd, submitAIChat, triggerCopilotSuggestion, useAIChatEditor, useChatChunk, useEditorChat, useLastAssistantMessage, withAIChat, withCopilot, withoutAbort };
562
+ //#endregion
563
+ export { AIChatPlugin, AIChatPluginConfig, AIPlugin, AIPluginConfig, CallCompletionApiOptions, CompleteOptions, CopilotPlugin, CopilotPluginConfig, GetNextWord, SteamInsertChunkOptions, UseEditorChatOptions, acceptAIChat, acceptAISuggestions, acceptCopilot, acceptCopilotNextWord, aiCommentToRange, applyAISuggestions, callCompletionApi, createFormattedBlocks, escapeInput, findTextRangeInBlock, getChunkTrimmed, getCurrentBlockPath, getLastAssistantMessage, getListNode, getNextWord, insertBelowAIChat, insertBelowGenerate, isCompleteCodeBlock, isCompleteMath, isSameNode, nodesWithProps, rejectAISuggestions, removeAnchorAIChat, renderCopilotBelowNodes, replaceSelectionAIChat, resetAIChat, streamDeserializeInlineMd, streamDeserializeMd, streamInsertChunk, streamSerializeMd, submitAIChat, triggerCopilotSuggestion, useAIChatEditor, useChatChunk, useEditorChat, useLastAssistantMessage, withAIChat, withCopilot, withoutAbort };