@platejs/ai 52.3.8 → 52.3.10

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,3 +1,4 @@
1
+ import * as platejs5 from "platejs";
1
2
  import { Descendant, History, OmitFirst, Path, PluginConfig, SlateEditor, TLocation } from "platejs";
2
3
 
3
4
  //#region src/lib/transforms/insertAINodes.d.ts
@@ -42,7 +43,18 @@ type BaseAIPluginConfig = PluginConfig<'ai', {}, {}, {
42
43
  removeNodes: OmitFirst<typeof removeAINodes>;
43
44
  };
44
45
  }>;
45
- declare const BaseAIPlugin: any;
46
+ declare const BaseAIPlugin: platejs5.SlatePlugin<PluginConfig<any, {}, {}, Record<any, {
47
+ insertNodes: (nodes: platejs5.Descendant[], args_1?: {
48
+ target?: platejs5.Path;
49
+ } | undefined) => void;
50
+ removeMarks: (args_0?: {
51
+ at?: platejs5.TLocation;
52
+ } | undefined) => void;
53
+ removeNodes: (args_0?: {
54
+ at?: platejs5.Path;
55
+ } | undefined) => void;
56
+ undo: () => void;
57
+ }>, {}>>;
46
58
  //#endregion
47
59
  //#region src/lib/types.d.ts
48
60
  type AIToolName = 'comment' | 'edit' | 'generate' | null;
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { _ as insertAINodes, a as EditorPromptParams, c as AIMode, d as BaseAIPluginConfig, f as AIBatch, g as removeAIMarks, h as removeAINodes, i as EditorPrompt, l as AIToolName, m as undoAI, n as MarkdownType, o as PromptConfig, p as withAIBatch, r as replacePlaceholders, s as getEditorPrompt, t as getMarkdown, u as BaseAIPlugin } from "./index-B_bqJoKL";
1
+ import { _ as insertAINodes, a as EditorPromptParams, c as AIMode, d as BaseAIPluginConfig, f as AIBatch, g as removeAIMarks, h as removeAINodes, i as EditorPrompt, l as AIToolName, m as undoAI, n as MarkdownType, o as PromptConfig, p as withAIBatch, r as replacePlaceholders, s as getEditorPrompt, t as getMarkdown, u as BaseAIPlugin } from "./index-Dyi5V2wm";
2
2
  export { AIBatch, AIMode, AIToolName, BaseAIPlugin, BaseAIPluginConfig, EditorPrompt, EditorPromptParams, MarkdownType, PromptConfig, getEditorPrompt, getMarkdown, insertAINodes, removeAIMarks, removeAINodes, replacePlaceholders, undoAI, withAIBatch };
@@ -1,6 +1,8 @@
1
- import { c as AIMode, d as BaseAIPluginConfig, i as EditorPrompt, l as AIToolName } from "../index-B_bqJoKL";
2
- import { Descendant, EditorNodesOptions, ExtendConfig, NodeEntry, OmitFirst, Path, PluginConfig, Range, RemoveNodesOptions, SlateEditor, TElement as TElement$1, TIdElement, TRange, TTableElement, TText } from "platejs";
1
+ import { c as AIMode, d as BaseAIPluginConfig, i as EditorPrompt, l as AIToolName } from "../index-Dyi5V2wm";
2
+ import * as platejs0 from "platejs";
3
+ import { Descendant, EditorNodesOptions, ExtendConfig, NodeEntry, OmitFirst, Path, PluginConfig, Range, RemoveNodesOptions, SlateEditor, TElement, TIdElement, TRange, TTableElement, TText } from "platejs";
3
4
  import { DeserializeMdOptions, SerializeMdOptions } from "@platejs/markdown";
5
+ import * as platejs_react0 from "platejs/react";
4
6
  import { OverrideEditor, PlateEditor, RenderNodeWrapperProps } from "platejs/react";
5
7
  import React from "react";
6
8
  import { ChatRequestOptions, UIMessage } from "ai";
@@ -9,7 +11,18 @@ import { TriggerComboboxPluginOptions } from "@platejs/combobox";
9
11
 
10
12
  //#region src/react/ai/AIPlugin.d.ts
11
13
  type AIPluginConfig = ExtendConfig<BaseAIPluginConfig>;
12
- declare const AIPlugin: any;
14
+ declare const AIPlugin: platejs_react0.PlatePlugin<platejs0.PluginConfig<any, {}, {}, Record<any, {
15
+ insertNodes: (nodes: platejs0.Descendant[], args_1?: {
16
+ target?: platejs0.Path;
17
+ } | undefined) => void;
18
+ removeMarks: (args_0?: {
19
+ at?: platejs0.TLocation;
20
+ } | undefined) => void;
21
+ removeNodes: (args_0?: {
22
+ at?: platejs0.Path;
23
+ } | undefined) => void;
24
+ undo: () => void;
25
+ }>, {}>>;
13
26
  //#endregion
14
27
  //#region src/react/ai-chat/internal/types.d.ts
15
28
  type ToolName = 'comment' | 'edit' | 'generate';
@@ -58,10 +71,10 @@ declare const createFormattedBlocks: ({
58
71
  format,
59
72
  sourceBlock
60
73
  }: {
61
- blocks: TElement$1[];
74
+ blocks: TElement[];
62
75
  format: "all" | "none" | "single";
63
76
  sourceBlock: NodeEntry;
64
- }) => TElement$1[] | null;
77
+ }) => any[] | null;
65
78
  declare const replaceSelectionAIChat: (editor: PlateEditor, sourceEditor: SlateEditor, {
66
79
  format
67
80
  }?: {
@@ -138,7 +151,87 @@ type AIChatPluginConfig = PluginConfig<'aiChat', {
138
151
  removeAnchor: (options?: EditorNodesOptions) => void;
139
152
  };
140
153
  }>;
141
- declare const AIChatPlugin: any;
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;
179
+ } & TriggerComboboxPluginOptions, {
180
+ aiChat: {
181
+ reset: OmitFirst<typeof resetAIChat>;
182
+ submit: OmitFirst<typeof submitAIChat>;
183
+ hide: (options?: {
184
+ focus?: boolean;
185
+ undo?: boolean;
186
+ }) => void;
187
+ node: (options?: EditorNodesOptions & {
188
+ anchor?: boolean;
189
+ streaming?: boolean;
190
+ }) => NodeEntry | undefined;
191
+ reload: () => void;
192
+ show: () => void;
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;
209
+ }, "node" | "stop" | "reset" | "submit">> & Record<"aiChat", {
210
+ hide: ({
211
+ focus,
212
+ undo
213
+ }?: {
214
+ focus?: boolean;
215
+ undo?: boolean;
216
+ }) => void;
217
+ show: () => void;
218
+ }>, {
219
+ aiChat: {
220
+ accept: OmitFirst<typeof acceptAIChat>;
221
+ insertBelow: OmitFirst<typeof insertBelowAIChat>;
222
+ replaceSelection: OmitFirst<typeof replaceSelectionAIChat>;
223
+ removeAnchor: (options?: EditorNodesOptions) => void;
224
+ };
225
+ } & Record<"aiChat", {
226
+ accept: () => void;
227
+ insertBelow: (sourceEditor: SlateEditor, args_1?: {
228
+ format?: "all" | "none" | "single";
229
+ } | undefined) => void;
230
+ removeAnchor: (options?: platejs0.RemoveNodesOptions | undefined) => void;
231
+ replaceSelection: (sourceEditor: SlateEditor, args_1?: {
232
+ format?: "all" | "none" | "single";
233
+ } | undefined) => void;
234
+ }>, {}>>;
142
235
  //#endregion
143
236
  //#region src/react/ai-chat/withAIChat.d.ts
144
237
  declare const withAIChat: OverrideEditor<AIChatPluginConfig>;
@@ -152,7 +245,7 @@ declare const withAIChat: OverrideEditor<AIChatPluginConfig>;
152
245
  */
153
246
  declare const useAIChatEditor: (editor: SlateEditor, content: string, {
154
247
  parser
155
- }?: DeserializeMdOptions) => any;
248
+ }?: DeserializeMdOptions) => platejs0.Value;
156
249
  //#endregion
157
250
  //#region src/react/ai-chat/hooks/useChatChunk.d.ts
158
251
  declare const useChatChunk: ({
@@ -188,10 +281,17 @@ declare const useEditorChat: ({
188
281
  }: UseEditorChatOptions) => void;
189
282
  //#endregion
190
283
  //#region src/react/ai-chat/streaming/streamDeserializeInlineMd.d.ts
191
- declare const streamDeserializeInlineMd: (editor: PlateEditor, text: string, options?: DeserializeMdOptions) => any;
284
+ declare const streamDeserializeInlineMd: (editor: PlateEditor, text: string, options?: DeserializeMdOptions) => platejs0.Descendant[] | {
285
+ text: string;
286
+ }[];
192
287
  //#endregion
193
288
  //#region src/react/ai-chat/streaming/streamDeserializeMd.d.ts
194
- declare const streamDeserializeMd: (editor: PlateEditor, data: string, options?: DeserializeMdOptions) => TElement[];
289
+ declare const streamDeserializeMd: (editor: PlateEditor, data: string, options?: DeserializeMdOptions) => TElement[] | {
290
+ children: {
291
+ text: string;
292
+ }[];
293
+ type: string;
294
+ }[];
195
295
  //#endregion
196
296
  //#region src/react/ai-chat/streaming/streamInsertChunk.d.ts
197
297
  type SteamInsertChunkOptions = {
@@ -200,7 +300,7 @@ type SteamInsertChunkOptions = {
200
300
  };
201
301
  /** @experimental */
202
302
  declare function streamInsertChunk(editor: PlateEditor, chunk: string, options?: SteamInsertChunkOptions): void;
203
- declare const getCurrentBlockPath: (editor: SlateEditor) => any;
303
+ declare const getCurrentBlockPath: (editor: SlateEditor) => Path;
204
304
  //#endregion
205
305
  //#region src/react/ai-chat/streaming/streamSerializeMd.d.ts
206
306
  declare const streamSerializeMd: (editor: PlateEditor, options: SerializeMdOptions, chunk: string) => string;
@@ -209,10 +309,10 @@ declare const streamSerializeMd: (editor: PlateEditor, options: SerializeMdOptio
209
309
  declare const escapeInput: (data: string) => string;
210
310
  //#endregion
211
311
  //#region src/react/ai-chat/streaming/utils/getListNode.d.ts
212
- declare const getListNode: (editor: PlateEditor, node: TElement$1) => TElement$1;
312
+ declare const getListNode: (editor: PlateEditor, node: TElement) => TElement;
213
313
  //#endregion
214
314
  //#region src/react/ai-chat/streaming/utils/isSameNode.d.ts
215
- declare const isSameNode: (editor: PlateEditor, node1: TElement$1 | TText, node2: TElement$1 | TText) => boolean;
315
+ declare const isSameNode: (editor: PlateEditor, node1: TElement | TText, node2: TElement | TText) => boolean;
216
316
  //#endregion
217
317
  //#region src/react/ai-chat/streaming/utils/nodesWithProps.d.ts
218
318
  declare const nodesWithProps: (editor: PlateEditor, nodes: Descendant[], options: SteamInsertChunkOptions) => Descendant[];
@@ -250,8 +350,8 @@ type TableCellUpdate = {
250
350
  declare const applyTableCellSuggestion: (editor: SlateEditor, cellUpdate: TableCellUpdate) => void;
251
351
  //#endregion
252
352
  //#region src/react/ai-chat/utils/getLastAssistantMessage.d.ts
253
- declare function getLastAssistantMessage(editor: PlateEditor): any;
254
- declare function useLastAssistantMessage(): any;
353
+ declare function getLastAssistantMessage(editor: PlateEditor): ChatMessage | undefined;
354
+ declare function useLastAssistantMessage(): ChatMessage | undefined;
255
355
  //#endregion
256
356
  //#region src/react/ai-chat/utils/nestedContainerUtils.d.ts
257
357
  /** Check if nodes is a single table with single cell */
@@ -388,7 +488,86 @@ type CompletionState = {
388
488
  error?: Error | null;
389
489
  isLoading?: boolean;
390
490
  };
391
- declare const CopilotPlugin: any;
491
+ declare const CopilotPlugin: platejs_react0.PlatePlugin<PluginConfig<"copilot", CompletionState & {
492
+ /**
493
+ * AI completion options. See:
494
+ * {@link https://sdk.vercel.ai/docs/reference/ai-sdk-ui/use-completion#parameters | AI SDK UI useCompletion Parameters}
495
+ */
496
+ completeOptions?: Partial<CompleteOptions>;
497
+ /**
498
+ * Debounce delay for auto triggering AI completion.
499
+ *
500
+ * @default 0
501
+ */
502
+ debounceDelay?: number;
503
+ /** Get the next word to be inserted. */
504
+ getNextWord?: GetNextWord;
505
+ /** Render the ghost text. */
506
+ renderGhostText?: (() => React.ReactNode) | null;
507
+ shouldAbort?: boolean;
508
+ /** The node id where the suggestion is located. */
509
+ suggestionNodeId?: string | null;
510
+ /** The text of the suggestion. */
511
+ suggestionText?: string | null;
512
+ /**
513
+ * Conditions to auto trigger copilot, used in addition to triggerQuery.
514
+ * Disabling defaults to:
515
+ *
516
+ * - Block above is empty
517
+ * - Block above ends with a space
518
+ * - There is already a suggestion
519
+ */
520
+ autoTriggerQuery?: (options: {
521
+ editor: PlateEditor;
522
+ }) => boolean;
523
+ /**
524
+ * Get the prompt for AI completion.
525
+ *
526
+ * @default serializeMdNodes(editor.api.block({ highest: true }))
527
+ */
528
+ getPrompt?: (options: {
529
+ editor: PlateEditor;
530
+ }) => string;
531
+ /**
532
+ * Conditions to trigger copilot. Disabling defaults to:
533
+ *
534
+ * - Selection is expanded
535
+ * - Selection is not at the end of block
536
+ */
537
+ triggerQuery?: (options: {
538
+ editor: PlateEditor;
539
+ }) => boolean;
540
+ }, {
541
+ copilot: {
542
+ triggerSuggestion: OmitFirst<typeof triggerCopilotSuggestion>;
543
+ reject: () => false | undefined;
544
+ setBlockSuggestion: (options: {
545
+ text: string;
546
+ id?: string;
547
+ }) => void;
548
+ stop: () => void;
549
+ };
550
+ } & Record<"copilot", Omit<{
551
+ triggerSuggestion: OmitFirst<typeof triggerCopilotSuggestion>;
552
+ reject: () => false | undefined;
553
+ setBlockSuggestion: (options: {
554
+ text: string;
555
+ id?: string;
556
+ }) => void;
557
+ stop: () => void;
558
+ }, "reject">> & Record<"copilot", {
559
+ reject: () => false | undefined;
560
+ }>, {
561
+ copilot: {
562
+ accept: OmitFirst<typeof acceptCopilot>;
563
+ acceptNextWord: OmitFirst<typeof acceptCopilotNextWord>;
564
+ };
565
+ } & Record<"copilot", {
566
+ accept: () => false | undefined;
567
+ acceptNextWord: () => false | undefined;
568
+ }>, {
569
+ isSuggested?: (id: string) => boolean;
570
+ }>>;
392
571
  //#endregion
393
572
  //#region src/react/copilot/renderCopilotBelowNodes.d.ts
394
573
  declare const renderCopilotBelowNodes: ({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platejs/ai",
3
- "version": "52.3.8",
3
+ "version": "52.3.10",
4
4
  "description": "Text AI plugin for Plate",
5
5
  "keywords": [
6
6
  "plate",
@@ -32,15 +32,16 @@
32
32
  "fastest-levenshtein": "1.0.16",
33
33
  "lodash": "^4.17.21",
34
34
  "react-compiler-runtime": "^1.0.0",
35
- "@platejs/markdown": "^52.3.7",
36
- "@platejs/selection": "^52.3.6",
37
- "@platejs/suggestion": "^52.3.8",
38
- "@platejs/table": "^52.3.6"
35
+ "@platejs/markdown": "^52.3.10",
36
+ "@platejs/selection": "^52.3.10",
37
+ "@platejs/suggestion": "^52.3.10",
38
+ "@platejs/table": "^52.3.10"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@ai-sdk/react": "^3.0.0",
42
42
  "ai": "^6.0.0",
43
- "@plate/scripts": "1.0.0"
43
+ "@plate/scripts": "1.0.0",
44
+ "platejs": "^52.3.9"
44
45
  },
45
46
  "peerDependencies": {
46
47
  "platejs": ">=52.0.15",