@lobehub/chat
Version:
Lobe Chat - an open-source, high-performance chatbot framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.
37 lines (33 loc) • 938 B
text/typescript
import { IEditor } from '@lobehub/editor';
import { useMemo } from 'react';
import { useChatInputStore } from '@/features/ChatInput/store';
export interface ChatInputEditor {
clearContent: () => void;
focus: () => void;
getJSONState: () => any;
getMarkdownContent: () => string;
instance: IEditor;
setExpand: (expand: boolean) => void;
setJSONState: (content: any) => void;
}
export const useChatInputEditor = () => {
const [editor, getMarkdownContent, getJSONState, setExpand, setJSONState] = useChatInputStore(
(s) => [s.editor, s.getMarkdownContent, s.getJSONState, s.setExpand, s.setJSONState],
);
return useMemo<ChatInputEditor>(
() => ({
clearContent: () => {
editor?.cleanDocument();
},
focus: () => {
editor?.focus();
},
getJSONState,
getMarkdownContent,
instance: editor!,
setExpand,
setJSONState,
}),
[editor],
);
};