import { CommandGroup, CommandItem, CommandSeparator } from "../ui/command"; import { useEditor } from "novel"; import { Check, TextQuote, TrashIcon } from "lucide-react"; const AICompletionCommands = ({ completion, onDiscard, }: { completion: string; onDiscard: () => void; }) => { const { editor } = useEditor(); return ( <> { const selection = editor?.view.state.selection; if (!selection) return; editor ?.chain() .focus() .insertContentAt( { from: selection.from, to: selection.to, }, completion, ) .run(); }} > Replace selection { const selection = editor?.view.state.selection; if (!selection) return; editor ?.chain() .focus() .insertContentAt(selection.to + 1, completion) .run(); }} > Insert below Discard ); }; export default AICompletionCommands;