import React, { useCallback, useEffect, useState } from "react"; import { $getRoot, $createParagraphNode, EditorState } from "lexical"; import { LexicalComposer } from "@lexical/react/LexicalComposer"; import { PlainTextPlugin } from "@lexical/react/LexicalPlainTextPlugin"; import { ContentEditable } from "@lexical/react/LexicalContentEditable"; import { HistoryPlugin } from "@lexical/react/LexicalHistoryPlugin"; import { OnChangePlugin } from "@lexical/react/LexicalOnChangePlugin"; import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext"; import { LexicalErrorBoundary } from "@lexical/react/LexicalErrorBoundary"; import { BeautifulMentionsPlugin, BeautifulMentionNode, type BeautifulMentionsTheme, type BeautifulMentionsMenuItemProps, } from "lexical-beautiful-mentions"; import { KEY_ENTER_COMMAND, COMMAND_PRIORITY_HIGH } from "lexical"; import { useLoadApps } from "@/hooks/useLoadApps"; import { forwardRef } from "react"; import { useAtomValue } from "jotai"; import { selectedAppIdAtom } from "@/atoms/appAtoms"; import { parseAppMentions } from "@/shared/parse_mention_apps"; // Define the theme for mentions const beautifulMentionsTheme: BeautifulMentionsTheme = { "@": "px-2 py-0.5 mx-0.5 bg-accent text-accent-foreground rounded-md", "@Focused": "outline-none ring-2 ring-ring", }; // Custom menu item component const CustomMenuItem = forwardRef< HTMLLIElement, BeautifulMentionsMenuItemProps >(({ selected, item, ...props }, ref) => (
  • App {typeof item === "string" ? item : item.value}
  • )); // Custom menu component function CustomMenu({ loading: _loading, ...props }: any) { return (