diff --git a/components/cmdk/index.tsx b/components/cmdk/index.tsx index 524e816b..ab4d3eca 100644 --- a/components/cmdk/index.tsx +++ b/components/cmdk/index.tsx @@ -29,6 +29,7 @@ import { CommandSeparator, CommandShortcut, } from "@/components/ui/command" +import { useLastOpened } from "@/app/[database]/hook" import { useSpaceAppStore } from "@/app/[database]/store" import { ActionList } from "./action" @@ -67,7 +68,7 @@ export function CommandDialogDemo() { }, [input, run, space]) const { isAiOpen, setIsAiOpen } = useSpaceAppStore() - const { lastOpenedDatabase } = useAppStore() + const { lastOpenedDatabase } = useLastOpened() const { createDoc } = useSqlite() const goto = useCMDKGoto() diff --git a/components/doc/plugins/AIEditorPlugin/index.tsx b/components/doc/plugins/AIEditorPlugin/index.tsx index 8250e739..300eb1ca 100644 --- a/components/doc/plugins/AIEditorPlugin/index.tsx +++ b/components/doc/plugins/AIEditorPlugin/index.tsx @@ -25,6 +25,7 @@ export const AIEditorPlugin = (props: any) => { useEffect(() => { return mergeRegister(() => { + // FIXME: is this only works in dev mode? fuck lexical fuck fuck fuck!!!!!!!!! editor.registerCommand( SELECTION_CHANGE_COMMAND, () => { @@ -65,9 +66,10 @@ export const AIEditorPlugin = (props: any) => { editor.update(() => { editor.focus() + const paragraphNode = $createParagraphNode() + $convertFromMarkdownString(text, __allTransformers, paragraphNode) + // FIXME: the selection is always null in production mode, append the paragraph node to the end of the root node yet if (selection) { - const paragraphNode = $createParagraphNode() - $convertFromMarkdownString(text, __allTransformers, paragraphNode) const newSelection = selection.clone() let node try { @@ -77,11 +79,11 @@ export const AIEditorPlugin = (props: any) => { node.insertAfter(paragraphNode) } else { const root = $getRoot() - $convertFromMarkdownString(text, __allTransformers, root) + root.append(paragraphNode) } } else { const root = $getRoot() - $convertFromMarkdownString(text, __allTransformers, root) + root.append(paragraphNode) } }) }