- Add insert below and copy option

This commit is contained in:
Philipinho
2026-02-06 12:14:33 -08:00
parent 06c81a4fed
commit 4f20b43222
3 changed files with 23 additions and 4 deletions
@@ -128,7 +128,7 @@ const EditorAiMenu = ({ editor }: EditorAiMenuProps): JSX.Element | null => {
if (item.id === "back") {
return setActiveCommandSet("main");
}
if (item.id === "result-insert") {
if (item.id === "result-replace") {
const chain = editor.chain().focus();
if (lastAction.action === AiAction.CONTINUE_WRITING) {
@@ -139,6 +139,21 @@ const EditorAiMenu = ({ editor }: EditorAiMenuProps): JSX.Element | null => {
return setShowAiMenu(false);
}
if (item.id === "result-insert-below") {
editor
.chain()
.focus()
.setTextSelection(editor.state.selection.to)
.insertContent(marked.parse(output))
.run();
return setShowAiMenu(false);
}
if (item.id === "result-copy") {
navigator.clipboard.writeText(output);
return setShowAiMenu(false);
}
if (item.id === "result-discard") {
setOutput("");
@@ -1,7 +1,6 @@
import { AiAction } from "@/ee/ai/types/ai.types";
import {
IconSparkles,
IconCheck,
IconArrowsMaximize,
IconArrowsMinimize,
IconWriting,
@@ -12,6 +11,9 @@ import {
IconTrash,
IconRefresh,
IconChevronLeft,
IconCheck,
IconArrowDownLeft,
IconCopy,
} from "@tabler/icons-react";
interface CommandItem {
@@ -139,7 +141,9 @@ const translateItems: CommandItem[] = [
},
];
const resultItems: CommandItem[] = [
{ id: "result-insert", name: "Insert", icon: IconCheck },
{ id: "result-replace", name: "Replace", icon: IconCheck },
{ id: "result-insert-below", name: "Insert below", icon: IconArrowDownLeft },
{ id: "result-copy", name: "Copy", icon: IconCopy },
{ id: "result-discard", name: "Discard", icon: IconTrash },
{
id: "result-try-again",