@platejs/ai 51.1.2 → 52.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.
- package/dist/getEditorPrompt-BnVrgUl3.js +102 -0
- package/dist/index-CyVv31EV.d.ts +96 -0
- package/dist/index.d.ts +2 -22
- package/dist/index.js +47 -224
- package/dist/react/index.d.ts +466 -374
- package/dist/react/index.js +1246 -1894
- package/package.json +14 -22
- package/dist/getEditorPrompt-C6prTxft.d.mts +0 -54
- package/dist/getEditorPrompt-C6prTxft.d.ts +0 -54
- package/dist/index.d.mts +0 -22
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -193
- package/dist/index.mjs.map +0 -1
- package/dist/react/index.d.mts +0 -471
- package/dist/react/index.js.map +0 -1
- package/dist/react/index.mjs +0 -1965
- package/dist/react/index.mjs.map +0 -1
package/dist/react/index.d.mts
DELETED
|
@@ -1,471 +0,0 @@
|
|
|
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.mjs';
|
|
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
|
-
|
|
12
|
-
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;
|
|
24
|
-
}>, {}>>;
|
|
25
|
-
|
|
26
|
-
type ToolName = 'comment' | 'edit' | 'generate';
|
|
27
|
-
type TComment = {
|
|
28
|
-
blockId: string;
|
|
29
|
-
comment: string;
|
|
30
|
-
content: string;
|
|
31
|
-
};
|
|
32
|
-
type MessageDataPart = {
|
|
33
|
-
toolName: ToolName;
|
|
34
|
-
comment?: TComment;
|
|
35
|
-
};
|
|
36
|
-
type ChatMessage = UIMessage<{}, MessageDataPart>;
|
|
37
|
-
|
|
38
|
-
declare const aiCommentToRange: (editor: SlateEditor, aiComment: TComment) => Range | undefined;
|
|
39
|
-
|
|
40
|
-
/** Find text within a block, supporting fuzzy matching. */
|
|
41
|
-
declare function findTextRangeInBlock({ block, findText, }: {
|
|
42
|
-
block: NodeEntry;
|
|
43
|
-
findText: string;
|
|
44
|
-
}): Range | null;
|
|
45
|
-
|
|
46
|
-
declare const acceptAIChat: (editor: PlateEditor) => void;
|
|
47
|
-
|
|
48
|
-
declare const insertBelowAIChat: (editor: PlateEditor, sourceEditor: SlateEditor, { format }?: {
|
|
49
|
-
format?: "all" | "none" | "single";
|
|
50
|
-
}) => void;
|
|
51
|
-
declare const insertBelowGenerate: (editor: PlateEditor, sourceEditor: SlateEditor, { format }?: {
|
|
52
|
-
format?: "all" | "none" | "single";
|
|
53
|
-
}) => void;
|
|
54
|
-
|
|
55
|
-
declare const createFormattedBlocks: ({ blocks, format, sourceBlock, }: {
|
|
56
|
-
blocks: TElement[];
|
|
57
|
-
format: "all" | "none" | "single";
|
|
58
|
-
sourceBlock: NodeEntry;
|
|
59
|
-
}) => any[] | null;
|
|
60
|
-
declare const replaceSelectionAIChat: (editor: PlateEditor, sourceEditor: SlateEditor, { format }?: {
|
|
61
|
-
format?: "all" | "none" | "single";
|
|
62
|
-
}) => void;
|
|
63
|
-
|
|
64
|
-
declare const resetAIChat: (editor: PlateEditor, { undo }?: {
|
|
65
|
-
undo?: boolean;
|
|
66
|
-
}) => 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;
|
|
73
|
-
}) => void;
|
|
74
|
-
|
|
75
|
-
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;
|
|
100
|
-
} & 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
|
-
};
|
|
116
|
-
}, {
|
|
117
|
-
aiChat: {
|
|
118
|
-
accept: OmitFirst<typeof acceptAIChat>;
|
|
119
|
-
insertBelow: OmitFirst<typeof insertBelowAIChat>;
|
|
120
|
-
replaceSelection: OmitFirst<typeof replaceSelectionAIChat>;
|
|
121
|
-
removeAnchor: (options?: EditorNodesOptions) => void;
|
|
122
|
-
};
|
|
123
|
-
}>;
|
|
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;
|
|
149
|
-
} & 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<{
|
|
166
|
-
reset: OmitFirst<typeof resetAIChat>;
|
|
167
|
-
submit: OmitFirst<typeof submitAIChat>;
|
|
168
|
-
hide: (options?: {
|
|
169
|
-
focus?: boolean;
|
|
170
|
-
undo?: boolean;
|
|
171
|
-
}) => void;
|
|
172
|
-
node: (options?: EditorNodesOptions & {
|
|
173
|
-
anchor?: boolean;
|
|
174
|
-
streaming?: boolean;
|
|
175
|
-
}) => NodeEntry | undefined;
|
|
176
|
-
reload: () => void;
|
|
177
|
-
show: () => void;
|
|
178
|
-
stop: () => void;
|
|
179
|
-
}, "node" | "stop" | "reset" | "submit">> & Record<"aiChat", {
|
|
180
|
-
hide: ({ focus, undo, }?: {
|
|
181
|
-
focus?: boolean;
|
|
182
|
-
undo?: boolean;
|
|
183
|
-
}) => void;
|
|
184
|
-
show: () => void;
|
|
185
|
-
}>, {
|
|
186
|
-
aiChat: {
|
|
187
|
-
accept: OmitFirst<typeof acceptAIChat>;
|
|
188
|
-
insertBelow: OmitFirst<typeof insertBelowAIChat>;
|
|
189
|
-
replaceSelection: OmitFirst<typeof replaceSelectionAIChat>;
|
|
190
|
-
removeAnchor: (options?: EditorNodesOptions) => void;
|
|
191
|
-
};
|
|
192
|
-
} & 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;
|
|
201
|
-
}>, {}>>;
|
|
202
|
-
|
|
203
|
-
declare const withAIChat: OverrideEditor<AIChatPluginConfig>;
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* Register an editor in the AI chat plugin, and deserializes the content into
|
|
207
|
-
* `editor.children` with block-level memoization.
|
|
208
|
-
*/
|
|
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;
|
|
221
|
-
}) => void;
|
|
222
|
-
|
|
223
|
-
type UseEditorChatOptions = {
|
|
224
|
-
chat?: any;
|
|
225
|
-
onOpenBlockSelection?: (blocks: NodeEntry[]) => void;
|
|
226
|
-
onOpenChange?: (open: boolean) => void;
|
|
227
|
-
onOpenCursor?: () => void;
|
|
228
|
-
onOpenSelection?: () => void;
|
|
229
|
-
};
|
|
230
|
-
declare const useEditorChat: ({ onOpenBlockSelection, onOpenChange, onOpenCursor, onOpenSelection, }: UseEditorChatOptions) => void;
|
|
231
|
-
|
|
232
|
-
declare const streamDeserializeInlineMd: (editor: PlateEditor, text: string, options?: DeserializeMdOptions) => platejs.Descendant[];
|
|
233
|
-
|
|
234
|
-
declare const streamDeserializeMd: (editor: PlateEditor, data: string, options?: DeserializeMdOptions) => TElement[] | {
|
|
235
|
-
children: {
|
|
236
|
-
text: string;
|
|
237
|
-
}[];
|
|
238
|
-
type: string;
|
|
239
|
-
}[];
|
|
240
|
-
|
|
241
|
-
type SteamInsertChunkOptions = {
|
|
242
|
-
elementProps?: any;
|
|
243
|
-
textProps?: any;
|
|
244
|
-
};
|
|
245
|
-
/** @experimental */
|
|
246
|
-
declare function streamInsertChunk(editor: PlateEditor, chunk: string, options?: SteamInsertChunkOptions): void;
|
|
247
|
-
declare const getCurrentBlockPath: (editor: SlateEditor) => Path;
|
|
248
|
-
|
|
249
|
-
declare const streamSerializeMd: (editor: PlateEditor, options: SerializeMdOptions, chunk: string) => string;
|
|
250
|
-
|
|
251
|
-
declare const escapeInput: (data: string) => string;
|
|
252
|
-
|
|
253
|
-
declare const getListNode: (editor: PlateEditor, node: TElement) => TElement;
|
|
254
|
-
|
|
255
|
-
declare const isSameNode: (editor: PlateEditor, node1: TElement | TText, node2: TElement | TText) => boolean;
|
|
256
|
-
|
|
257
|
-
declare const nodesWithProps: (editor: PlateEditor, nodes: Descendant[], options: SteamInsertChunkOptions) => Descendant[];
|
|
258
|
-
|
|
259
|
-
declare const getChunkTrimmed: (chunk: string, { direction, }?: {
|
|
260
|
-
direction?: "left" | "right";
|
|
261
|
-
}) => string;
|
|
262
|
-
declare function isCompleteCodeBlock(str: string): boolean;
|
|
263
|
-
declare function isCompleteMath(str: string): boolean;
|
|
264
|
-
|
|
265
|
-
declare const removeAnchorAIChat: (editor: PlateEditor, options?: RemoveNodesOptions) => void;
|
|
266
|
-
|
|
267
|
-
declare const acceptAISuggestions: (editor: PlateEditor) => void;
|
|
268
|
-
|
|
269
|
-
declare const applyAISuggestions: (editor: SlateEditor, content: string) => void;
|
|
270
|
-
|
|
271
|
-
declare function getLastAssistantMessage(editor: PlateEditor): ChatMessage | undefined;
|
|
272
|
-
declare function useLastAssistantMessage(): ChatMessage | undefined;
|
|
273
|
-
|
|
274
|
-
declare const rejectAISuggestions: (editor: PlateEditor) => void;
|
|
275
|
-
|
|
276
|
-
declare const getOriginalFetch: () => typeof fetch;
|
|
277
|
-
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;
|
|
291
|
-
};
|
|
292
|
-
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
|
-
|
|
295
|
-
declare const acceptCopilot: (editor: PlateEditor) => false | undefined;
|
|
296
|
-
|
|
297
|
-
declare const acceptCopilotNextWord: (editor: PlateEditor) => false | undefined;
|
|
298
|
-
|
|
299
|
-
type GetNextWord = (options: {
|
|
300
|
-
text: string;
|
|
301
|
-
}) => {
|
|
302
|
-
firstWord: string;
|
|
303
|
-
remainingText: string;
|
|
304
|
-
};
|
|
305
|
-
declare const getNextWord: GetNextWord;
|
|
306
|
-
|
|
307
|
-
declare const triggerCopilotSuggestion: (editor: PlateEditor) => Promise<false | undefined>;
|
|
308
|
-
|
|
309
|
-
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;
|
|
358
|
-
}, {
|
|
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
|
-
};
|
|
368
|
-
}, {
|
|
369
|
-
copilot: {
|
|
370
|
-
accept: OmitFirst<typeof acceptCopilot>;
|
|
371
|
-
acceptNextWord: OmitFirst<typeof acceptCopilotNextWord>;
|
|
372
|
-
};
|
|
373
|
-
}, {
|
|
374
|
-
isSuggested?: (id: string) => boolean;
|
|
375
|
-
}>;
|
|
376
|
-
type CompletionState = {
|
|
377
|
-
abortController?: AbortController | null;
|
|
378
|
-
completion?: string | null;
|
|
379
|
-
error?: Error | null;
|
|
380
|
-
isLoading?: boolean;
|
|
381
|
-
};
|
|
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;
|
|
431
|
-
}, {
|
|
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<{
|
|
442
|
-
triggerSuggestion: OmitFirst<typeof triggerCopilotSuggestion>;
|
|
443
|
-
reject: () => false | undefined;
|
|
444
|
-
setBlockSuggestion: (options: {
|
|
445
|
-
text: string;
|
|
446
|
-
id?: string;
|
|
447
|
-
}) => void;
|
|
448
|
-
stop: () => void;
|
|
449
|
-
}, "reject">> & Record<"copilot", {
|
|
450
|
-
reject: () => false | undefined;
|
|
451
|
-
}>, {
|
|
452
|
-
copilot: {
|
|
453
|
-
accept: OmitFirst<typeof acceptCopilot>;
|
|
454
|
-
acceptNextWord: OmitFirst<typeof acceptCopilotNextWord>;
|
|
455
|
-
};
|
|
456
|
-
} & Record<"copilot", {
|
|
457
|
-
accept: () => false | undefined;
|
|
458
|
-
acceptNextWord: () => false | undefined;
|
|
459
|
-
}>, {
|
|
460
|
-
isSuggested?: (id: string) => boolean;
|
|
461
|
-
}>>;
|
|
462
|
-
|
|
463
|
-
declare const renderCopilotBelowNodes: ({ editor, }: RenderNodeWrapperProps<CopilotPluginConfig>) => (({ children }: {
|
|
464
|
-
children: React.ReactNode;
|
|
465
|
-
}) => React.JSX.Element) | undefined;
|
|
466
|
-
|
|
467
|
-
declare const withCopilot: OverrideEditor<CopilotPluginConfig>;
|
|
468
|
-
|
|
469
|
-
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 };
|