@platejs/ai 50.3.3 → 50.3.5
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/react/index.d.mts +1 -1
- package/dist/react/index.d.ts +1 -1
- package/dist/react/index.js +19 -7
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +19 -7
- package/dist/react/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/react/index.mjs
CHANGED
|
@@ -569,7 +569,7 @@ var resetAIChat = (editor, { undo = true } = {}) => {
|
|
|
569
569
|
_replaceIds: [],
|
|
570
570
|
chatNodes: [],
|
|
571
571
|
mode: "insert",
|
|
572
|
-
toolName:
|
|
572
|
+
toolName: null
|
|
573
573
|
});
|
|
574
574
|
if (undo) {
|
|
575
575
|
editor.getTransforms(AIPlugin).ai.undo();
|
|
@@ -585,7 +585,7 @@ var submitAIChat = (editor, input, {
|
|
|
585
585
|
mode,
|
|
586
586
|
options,
|
|
587
587
|
prompt,
|
|
588
|
-
toolName
|
|
588
|
+
toolName: toolNameProps
|
|
589
589
|
} = {}) => {
|
|
590
590
|
const { getOptions, setOption } = getEditorPlugin3(
|
|
591
591
|
editor,
|
|
@@ -593,7 +593,8 @@ var submitAIChat = (editor, input, {
|
|
|
593
593
|
key: KEYS9.aiChat
|
|
594
594
|
}
|
|
595
595
|
);
|
|
596
|
-
const { chat } = getOptions();
|
|
596
|
+
const { chat, toolName: toolNameOption } = getOptions();
|
|
597
|
+
const toolName = toolNameProps ?? toolNameOption ?? null;
|
|
597
598
|
if (!prompt && input?.length === 0) {
|
|
598
599
|
return;
|
|
599
600
|
}
|
|
@@ -607,20 +608,30 @@ var submitAIChat = (editor, input, {
|
|
|
607
608
|
editor.getTransforms(AIPlugin).ai.undo();
|
|
608
609
|
}
|
|
609
610
|
setOption("mode", mode);
|
|
610
|
-
setOption("toolName", toolName
|
|
611
|
+
setOption("toolName", toolName);
|
|
611
612
|
const blocks = editor.getApi(BlockSelectionPlugin3).blockSelection.getNodes();
|
|
612
613
|
const blocksRange = editor.api.nodesRange(blocks);
|
|
613
614
|
const promptText = getEditorPrompt(editor, {
|
|
614
615
|
prompt
|
|
615
616
|
});
|
|
616
617
|
const selection = blocks.length > 0 ? blocksRange : editor.selection;
|
|
617
|
-
|
|
618
|
+
let chatNodes;
|
|
619
|
+
if (blocks.length > 0) {
|
|
620
|
+
chatNodes = blocks.map((block) => block[0]);
|
|
621
|
+
} else {
|
|
622
|
+
const selectionBlocks = editor.api.blocks({ mode: "highest" });
|
|
623
|
+
if (selectionBlocks.length > 1) {
|
|
624
|
+
chatNodes = selectionBlocks.map((block) => block[0]);
|
|
625
|
+
} else {
|
|
626
|
+
chatNodes = editor.api.fragment();
|
|
627
|
+
}
|
|
628
|
+
}
|
|
618
629
|
setOption("chatNodes", chatNodes);
|
|
619
630
|
setOption("chatSelection", blocks.length > 0 ? null : editor.selection);
|
|
620
631
|
const ctx = {
|
|
621
632
|
children: editor.children,
|
|
622
633
|
selection: selection ?? null,
|
|
623
|
-
toolName
|
|
634
|
+
toolName
|
|
624
635
|
};
|
|
625
636
|
void chat.sendMessage?.(
|
|
626
637
|
{
|
|
@@ -1354,12 +1365,13 @@ import {
|
|
|
1354
1365
|
TextApi as TextApi5
|
|
1355
1366
|
} from "platejs";
|
|
1356
1367
|
var applyAISuggestions = (editor, content) => {
|
|
1368
|
+
editor.getApi({ key: KEYS17.cursorOverlay })?.cursorOverlay?.removeCursor("selection");
|
|
1357
1369
|
const isBlockSelecting = editor.getOption(
|
|
1358
1370
|
BlockSelectionPlugin6,
|
|
1359
1371
|
"isSelectingSome"
|
|
1360
1372
|
);
|
|
1361
1373
|
const { chatNodes } = editor.getOptions(AIChatPlugin);
|
|
1362
|
-
if (isBlockSelecting) {
|
|
1374
|
+
if (isBlockSelecting || editor.api.blocks({ mode: "highest" }).length > 1) {
|
|
1363
1375
|
const setReplaceIds = (ids) => {
|
|
1364
1376
|
editor.setOption(AIChatPlugin, "_replaceIds", ids);
|
|
1365
1377
|
};
|