@platejs/ai 50.1.1 → 50.2.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.
@@ -1,8 +1,8 @@
1
1
  import * as platejs_react from 'platejs/react';
2
2
  import { PlateEditor, OverrideEditor, RenderNodeWrapperProps } from 'platejs/react';
3
3
  import * as platejs from 'platejs';
4
- import { ExtendConfig, SlateEditor, Range, NodeEntry, TElement, PluginConfig, Path, OmitFirst, EditorNodesOptions, TText, Descendant, RemoveNodesOptions } from 'platejs';
5
- import { B as BaseAIPluginConfig, b as AIMode, E as EditorPrompt, A as AIToolName } from '../getEditorPrompt-FgyoD13L.js';
4
+ import { ExtendConfig, SlateEditor, Range, NodeEntry, TElement, PluginConfig, Path, TIdElement, OmitFirst, EditorNodesOptions, TText, Descendant, RemoveNodesOptions } from 'platejs';
5
+ import { B as BaseAIPluginConfig, b as AIMode, E as EditorPrompt, A as AIToolName } from '../getEditorPrompt-C7EEuMw8.js';
6
6
  import { UIMessage, ChatRequestOptions } from 'ai';
7
7
  import { Range as Range$1 } from 'slate';
8
8
  import { UseChatHelpers } from '@ai-sdk/react';
@@ -45,10 +45,14 @@ declare function findTextRangeInBlock({ block, findText, }: {
45
45
  }): Range$1 | null;
46
46
 
47
47
  declare const acceptAIChat: (editor: PlateEditor) => void;
48
+ declare const acceptSuggestions: (editor: PlateEditor) => void;
48
49
 
49
50
  declare const insertBelowAIChat: (editor: PlateEditor, sourceEditor: SlateEditor, { format }?: {
50
51
  format?: "all" | "none" | "single";
51
52
  }) => void;
53
+ declare const insertBelowGenerate: (editor: PlateEditor, sourceEditor: SlateEditor, { format }?: {
54
+ format?: "all" | "none" | "single";
55
+ }) => void;
52
56
 
53
57
  declare const createFormattedBlocks: ({ blocks, format, sourceBlock, }: {
54
58
  blocks: TElement[];
@@ -73,9 +77,11 @@ type AIChatPluginConfig = PluginConfig<'aiChat', {
73
77
  _blockPath: Path | null;
74
78
  /** @private Using For streamInsertChunk */
75
79
  _mdxName: string | null;
80
+ _replaceIds: string[];
76
81
  /** @private The Editor used to generate the AI response. */
77
82
  aiEditor: SlateEditor | null;
78
83
  chat: UseChatHelpers<ChatMessage>;
84
+ chatNodes: TIdElement[];
79
85
  /** @deprecated Use api.aiChat.node({streaming:true}) instead */
80
86
  experimental_lastTextId: string | null;
81
87
  /**
@@ -94,7 +100,9 @@ type AIChatPluginConfig = PluginConfig<'aiChat', {
94
100
  aiChat: {
95
101
  reset: OmitFirst<typeof resetAIChat>;
96
102
  submit: OmitFirst<typeof submitAIChat>;
97
- hide: () => void;
103
+ hide: (options?: {
104
+ focus?: boolean;
105
+ }) => void;
98
106
  node: (options?: EditorNodesOptions & {
99
107
  anchor?: boolean;
100
108
  streaming?: boolean;
@@ -116,9 +124,11 @@ declare const AIChatPlugin: platejs_react.PlatePlugin<PluginConfig<"aiChat", {
116
124
  _blockPath: Path | null;
117
125
  /** @private Using For streamInsertChunk */
118
126
  _mdxName: string | null;
127
+ _replaceIds: string[];
119
128
  /** @private The Editor used to generate the AI response. */
120
129
  aiEditor: SlateEditor | null;
121
130
  chat: UseChatHelpers<ChatMessage>;
131
+ chatNodes: TIdElement[];
122
132
  /** @deprecated Use api.aiChat.node({streaming:true}) instead */
123
133
  experimental_lastTextId: string | null;
124
134
  /**
@@ -137,7 +147,9 @@ declare const AIChatPlugin: platejs_react.PlatePlugin<PluginConfig<"aiChat", {
137
147
  aiChat: {
138
148
  reset: OmitFirst<typeof resetAIChat>;
139
149
  submit: OmitFirst<typeof submitAIChat>;
140
- hide: () => void;
150
+ hide: (options?: {
151
+ focus?: boolean;
152
+ }) => void;
141
153
  node: (options?: EditorNodesOptions & {
142
154
  anchor?: boolean;
143
155
  streaming?: boolean;
@@ -149,7 +161,9 @@ declare const AIChatPlugin: platejs_react.PlatePlugin<PluginConfig<"aiChat", {
149
161
  } & Record<"aiChat", Pick<{
150
162
  reset: OmitFirst<typeof resetAIChat>;
151
163
  submit: OmitFirst<typeof submitAIChat>;
152
- hide: () => void;
164
+ hide: (options?: {
165
+ focus?: boolean;
166
+ }) => void;
153
167
  node: (options?: EditorNodesOptions & {
154
168
  anchor?: boolean;
155
169
  streaming?: boolean;
@@ -157,8 +171,10 @@ declare const AIChatPlugin: platejs_react.PlatePlugin<PluginConfig<"aiChat", {
157
171
  reload: () => void;
158
172
  show: () => void;
159
173
  stop: () => void;
160
- }, "node" | "reset" | "stop" | "submit">> & Record<"aiChat", {
161
- hide: () => void;
174
+ }, "node" | "stop" | "reset" | "submit">> & Record<"aiChat", {
175
+ hide: ({ focus }?: {
176
+ focus?: boolean;
177
+ }) => void;
162
178
  show: () => void;
163
179
  }>, {
164
180
  aiChat: {
@@ -242,6 +258,8 @@ declare function isCompleteMath(str: string): boolean;
242
258
 
243
259
  declare const removeAnchorAIChat: (editor: PlateEditor, options?: RemoveNodesOptions) => void;
244
260
 
261
+ declare const applyAISuggestions: (editor: SlateEditor, content: string) => void;
262
+
245
263
  declare function getLastAssistantMessage(editor: PlateEditor): ChatMessage | undefined;
246
264
  declare function useLastAssistantMessage(): ChatMessage | undefined;
247
265
 
@@ -440,4 +458,4 @@ declare const withCopilot: OverrideEditor<CopilotPluginConfig>;
440
458
 
441
459
  declare const withoutAbort: (editor: PlateEditor, fn: () => void) => void;
442
460
 
443
- export { AIChatPlugin, type AIChatPluginConfig, AIPlugin, type AIPluginConfig, type CallCompletionApiOptions, type CompleteOptions, CopilotPlugin, type CopilotPluginConfig, type GetNextWord, type SteamInsertChunkOptions, type UseEditorChatOptions, acceptAIChat, acceptCopilot, acceptCopilotNextWord, aiCommentToRange, callCompletionApi, createFormattedBlocks, escapeInput, findTextRangeInBlock, getChunkTrimmed, getCurrentBlockPath, getLastAssistantMessage, getListNode, getNextWord, insertBelowAIChat, isCompleteCodeBlock, isCompleteMath, isSameNode, nodesWithProps, removeAnchorAIChat, renderCopilotBelowNodes, replaceSelectionAIChat, resetAIChat, streamDeserializeInlineMd, streamDeserializeMd, streamInsertChunk, streamSerializeMd, submitAIChat, triggerCopilotSuggestion, useAIChatEditor, useChatChunk, useEditorChat, useLastAssistantMessage, withAIChat, withCopilot, withoutAbort };
461
+ export { AIChatPlugin, type AIChatPluginConfig, AIPlugin, type AIPluginConfig, type CallCompletionApiOptions, type CompleteOptions, CopilotPlugin, type CopilotPluginConfig, type GetNextWord, type SteamInsertChunkOptions, type UseEditorChatOptions, acceptAIChat, acceptCopilot, acceptCopilotNextWord, acceptSuggestions, aiCommentToRange, applyAISuggestions, callCompletionApi, createFormattedBlocks, escapeInput, findTextRangeInBlock, getChunkTrimmed, getCurrentBlockPath, getLastAssistantMessage, getListNode, getNextWord, insertBelowAIChat, insertBelowGenerate, isCompleteCodeBlock, isCompleteMath, isSameNode, nodesWithProps, removeAnchorAIChat, renderCopilotBelowNodes, replaceSelectionAIChat, resetAIChat, streamDeserializeInlineMd, streamDeserializeMd, streamInsertChunk, streamSerializeMd, submitAIChat, triggerCopilotSuggestion, useAIChatEditor, useChatChunk, useEditorChat, useLastAssistantMessage, withAIChat, withCopilot, withoutAbort };