@platejs/ai 50.2.0 → 50.2.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.
@@ -3263,6 +3263,7 @@ var submitAIChat = (editor, input, {
3263
3263
  const selection = blocks.length > 0 ? blocksRange : editor.selection;
3264
3264
  const chatNodes = blocks.length > 0 ? blocks.map((block) => block[0]) : editor.api.fragment();
3265
3265
  setOption("chatNodes", chatNodes);
3266
+ setOption("chatSelection", blocks.length > 0 ? null : editor.selection);
3266
3267
  const ctx = {
3267
3268
  children: editor.children,
3268
3269
  selection: selection ?? null,
@@ -3353,6 +3354,7 @@ var AIChatPlugin = createTPlatePlugin({
3353
3354
  aiEditor: null,
3354
3355
  chat: { messages: [] },
3355
3356
  chatNodes: [],
3357
+ chatSelection: null,
3356
3358
  experimental_lastTextId: null,
3357
3359
  mode: "insert",
3358
3360
  open: false,
@@ -3392,8 +3394,13 @@ var AIChatPlugin = createTPlatePlugin({
3392
3394
  });
3393
3395
  },
3394
3396
  reload: () => {
3395
- const { chat } = getOptions();
3397
+ const { chat, chatNodes, chatSelection } = getOptions();
3396
3398
  editor.getTransforms(AIPlugin).ai.undo();
3399
+ if (chatSelection) {
3400
+ editor.tf.setSelection(chatSelection);
3401
+ } else {
3402
+ editor.getApi(BlockSelectionPlugin4).blockSelection.set(chatNodes.map((node) => node.id));
3403
+ }
3397
3404
  const blocks = editor.getApi(BlockSelectionPlugin4).blockSelection.getNodes();
3398
3405
  const selection = blocks.length > 0 ? editor.api.nodesRange(blocks) : editor.selection;
3399
3406
  const ctx = {
@@ -4028,6 +4035,7 @@ var applyAISuggestions = (editor, content) => {
4028
4035
  });
4029
4036
  }
4030
4037
  });
4038
+ editor.getApi(BlockSelectionPlugin6).blockSelection.set(diffNodes.map((node) => node.id));
4031
4039
  setReplaceIds(diffNodes.map((node) => node.id));
4032
4040
  } else {
4033
4041
  const diffNodes = getDiffNodes(editor, content);