@platejs/ai 50.2.1 → 50.2.2

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.
@@ -63,7 +63,9 @@ declare const replaceSelectionAIChat: (editor: PlateEditor, sourceEditor: SlateE
63
63
  format?: "all" | "none" | "single";
64
64
  }) => void;
65
65
 
66
- declare const resetAIChat: (editor: PlateEditor) => void;
66
+ declare const resetAIChat: (editor: PlateEditor, { undo }?: {
67
+ undo?: boolean;
68
+ }) => void;
67
69
 
68
70
  declare const submitAIChat: (editor: PlateEditor, input: string, { mode, options, prompt, toolName, }?: {
69
71
  mode?: AIMode;
@@ -103,6 +105,7 @@ type AIChatPluginConfig = PluginConfig<'aiChat', {
103
105
  submit: OmitFirst<typeof submitAIChat>;
104
106
  hide: (options?: {
105
107
  focus?: boolean;
108
+ undo?: boolean;
106
109
  }) => void;
107
110
  node: (options?: EditorNodesOptions & {
108
111
  anchor?: boolean;
@@ -151,6 +154,7 @@ declare const AIChatPlugin: platejs_react.PlatePlugin<PluginConfig<"aiChat", {
151
154
  submit: OmitFirst<typeof submitAIChat>;
152
155
  hide: (options?: {
153
156
  focus?: boolean;
157
+ undo?: boolean;
154
158
  }) => void;
155
159
  node: (options?: EditorNodesOptions & {
156
160
  anchor?: boolean;
@@ -165,6 +169,7 @@ declare const AIChatPlugin: platejs_react.PlatePlugin<PluginConfig<"aiChat", {
165
169
  submit: OmitFirst<typeof submitAIChat>;
166
170
  hide: (options?: {
167
171
  focus?: boolean;
172
+ undo?: boolean;
168
173
  }) => void;
169
174
  node: (options?: EditorNodesOptions & {
170
175
  anchor?: boolean;
@@ -174,8 +179,9 @@ declare const AIChatPlugin: platejs_react.PlatePlugin<PluginConfig<"aiChat", {
174
179
  show: () => void;
175
180
  stop: () => void;
176
181
  }, "node" | "stop" | "reset" | "submit">> & Record<"aiChat", {
177
- hide: ({ focus }?: {
182
+ hide: ({ focus, undo, }?: {
178
183
  focus?: boolean;
184
+ undo?: boolean;
179
185
  }) => void;
180
186
  show: () => void;
181
187
  }>, {
@@ -63,7 +63,9 @@ declare const replaceSelectionAIChat: (editor: PlateEditor, sourceEditor: SlateE
63
63
  format?: "all" | "none" | "single";
64
64
  }) => void;
65
65
 
66
- declare const resetAIChat: (editor: PlateEditor) => void;
66
+ declare const resetAIChat: (editor: PlateEditor, { undo }?: {
67
+ undo?: boolean;
68
+ }) => void;
67
69
 
68
70
  declare const submitAIChat: (editor: PlateEditor, input: string, { mode, options, prompt, toolName, }?: {
69
71
  mode?: AIMode;
@@ -103,6 +105,7 @@ type AIChatPluginConfig = PluginConfig<'aiChat', {
103
105
  submit: OmitFirst<typeof submitAIChat>;
104
106
  hide: (options?: {
105
107
  focus?: boolean;
108
+ undo?: boolean;
106
109
  }) => void;
107
110
  node: (options?: EditorNodesOptions & {
108
111
  anchor?: boolean;
@@ -151,6 +154,7 @@ declare const AIChatPlugin: platejs_react.PlatePlugin<PluginConfig<"aiChat", {
151
154
  submit: OmitFirst<typeof submitAIChat>;
152
155
  hide: (options?: {
153
156
  focus?: boolean;
157
+ undo?: boolean;
154
158
  }) => void;
155
159
  node: (options?: EditorNodesOptions & {
156
160
  anchor?: boolean;
@@ -165,6 +169,7 @@ declare const AIChatPlugin: platejs_react.PlatePlugin<PluginConfig<"aiChat", {
165
169
  submit: OmitFirst<typeof submitAIChat>;
166
170
  hide: (options?: {
167
171
  focus?: boolean;
172
+ undo?: boolean;
168
173
  }) => void;
169
174
  node: (options?: EditorNodesOptions & {
170
175
  anchor?: boolean;
@@ -174,8 +179,9 @@ declare const AIChatPlugin: platejs_react.PlatePlugin<PluginConfig<"aiChat", {
174
179
  show: () => void;
175
180
  stop: () => void;
176
181
  }, "node" | "stop" | "reset" | "submit">> & Record<"aiChat", {
177
- hide: ({ focus }?: {
182
+ hide: ({ focus, undo, }?: {
178
183
  focus?: boolean;
184
+ undo?: boolean;
179
185
  }) => void;
180
186
  show: () => void;
181
187
  }>, {
@@ -3252,7 +3252,7 @@ var removeAnchorAIChat = (editor, options) => {
3252
3252
  // src/react/ai-chat/utils/resetAIChat.ts
3253
3253
  var import_platejs10 = require("platejs");
3254
3254
  var import_react6 = require("platejs/react");
3255
- var resetAIChat = (editor) => {
3255
+ var resetAIChat = (editor, { undo = true } = {}) => {
3256
3256
  const { api, getOptions, setOptions } = (0, import_react6.getEditorPlugin)(
3257
3257
  editor,
3258
3258
  {
@@ -3270,7 +3270,9 @@ var resetAIChat = (editor) => {
3270
3270
  mode: "insert",
3271
3271
  toolName: "generate"
3272
3272
  });
3273
- editor.getTransforms(AIPlugin).ai.undo();
3273
+ if (undo) {
3274
+ editor.getTransforms(AIPlugin).ai.undo();
3275
+ }
3274
3276
  };
3275
3277
 
3276
3278
  // src/react/ai-chat/utils/submitAIChat.ts
@@ -3470,8 +3472,11 @@ var AIChatPlugin = (0, import_react10.createTPlatePlugin)({
3470
3472
  }
3471
3473
  };
3472
3474
  }).extendApi(({ api, editor, getOptions, setOption, tf, type }) => ({
3473
- hide: ({ focus = true } = {}) => {
3474
- api.aiChat.reset();
3475
+ hide: ({
3476
+ focus = true,
3477
+ undo = true
3478
+ } = {}) => {
3479
+ api.aiChat.reset({ undo });
3475
3480
  setOption("open", false);
3476
3481
  if (focus) {
3477
3482
  if (editor.getOption(import_react9.BlockSelectionPlugin, "isSelectingSome")) {