@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.
- 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 +1257 -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.ts
CHANGED
|
@@ -1,471 +1,563 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
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:
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
blockId: string;
|
|
31
|
+
comment: string;
|
|
32
|
+
content: string;
|
|
31
33
|
};
|
|
32
34
|
type MessageDataPart = {
|
|
33
|
-
|
|
34
|
-
|
|
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({
|
|
42
|
-
|
|
43
|
-
|
|
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
|
-
|
|
49
|
-
|
|
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, {
|
|
52
|
-
|
|
62
|
+
declare const insertBelowGenerate: (editor: PlateEditor, sourceEditor: SlateEditor, {
|
|
63
|
+
format
|
|
64
|
+
}?: {
|
|
65
|
+
format?: "all" | "none" | "single";
|
|
53
66
|
}) => void;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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, {
|
|
61
|
-
|
|
78
|
+
declare const replaceSelectionAIChat: (editor: PlateEditor, sourceEditor: SlateEditor, {
|
|
79
|
+
format
|
|
80
|
+
}?: {
|
|
81
|
+
format?: "all" | "none" | "single";
|
|
62
82
|
}) => void;
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
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
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
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
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
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
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
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:
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
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
|
-
|
|
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
|
-
|
|
170
|
-
|
|
184
|
+
focus?: boolean;
|
|
185
|
+
undo?: boolean;
|
|
171
186
|
}) => void;
|
|
172
187
|
node: (options?: EditorNodesOptions & {
|
|
173
|
-
|
|
174
|
-
|
|
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
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
210
|
+
hide: ({
|
|
211
|
+
focus,
|
|
212
|
+
undo
|
|
213
|
+
}?: {
|
|
214
|
+
focus?: boolean;
|
|
215
|
+
undo?: boolean;
|
|
216
|
+
}) => void;
|
|
217
|
+
show: () => void;
|
|
185
218
|
}>, {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
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
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
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, {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
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
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
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: ({
|
|
231
|
-
|
|
232
|
-
|
|
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
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
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
|
-
|
|
243
|
-
|
|
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
|
-
|
|
260
|
-
|
|
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
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
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({
|
|
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
|
-
|
|
383
|
+
text: string;
|
|
301
384
|
}) => {
|
|
302
|
-
|
|
303
|
-
|
|
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
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
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
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
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
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
454
|
+
copilot: {
|
|
455
|
+
accept: OmitFirst<typeof acceptCopilot>;
|
|
456
|
+
acceptNextWord: OmitFirst<typeof acceptCopilotNextWord>;
|
|
457
|
+
};
|
|
373
458
|
}, {
|
|
374
|
-
|
|
459
|
+
isSuggested?: (id: string) => boolean;
|
|
375
460
|
}>;
|
|
376
461
|
type CompletionState = {
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
462
|
+
abortController?: AbortController | null;
|
|
463
|
+
completion?: string | null;
|
|
464
|
+
error?: Error | null;
|
|
465
|
+
isLoading?: boolean;
|
|
381
466
|
};
|
|
382
|
-
declare const CopilotPlugin:
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
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
|
-
|
|
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
|
-
|
|
446
|
-
|
|
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
|
-
|
|
535
|
+
reject: () => false | undefined;
|
|
451
536
|
}>, {
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
537
|
+
copilot: {
|
|
538
|
+
accept: OmitFirst<typeof acceptCopilot>;
|
|
539
|
+
acceptNextWord: OmitFirst<typeof acceptCopilotNextWord>;
|
|
540
|
+
};
|
|
456
541
|
} & Record<"copilot", {
|
|
457
|
-
|
|
458
|
-
|
|
542
|
+
accept: () => false | undefined;
|
|
543
|
+
acceptNextWord: () => false | undefined;
|
|
459
544
|
}>, {
|
|
460
|
-
|
|
545
|
+
isSuggested?: (id: string) => boolean;
|
|
461
546
|
}>>;
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
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,
|
|
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 };
|