feat: 记录selection位置以及自动清空UserInput内容

This commit is contained in:
liuweiqing 2024-02-13 14:13:40 +08:00
parent e3a874780e
commit 9e85552d89

View File

@ -79,8 +79,11 @@ const QEditor = ({ lng }) => {
//询问ai用户输入
const [userInput, setUserInput] = useState("");
//quill编辑器鼠标位置
const [cursorPosition, setCursorPosition] = useState<number | null>(null);
const [cursorPosition, setCursorPosition] = useLocalStorage<number | null>(
"光标位置",
null
);
//
// 初始化 Quill 编辑器
const isMounted = useRef(false);
const editor = useRef<Quill | null>(null);
@ -236,6 +239,8 @@ const QEditor = ({ lng }) => {
upsreamUrl,
prompt
);
// 清空input内容
setUserInput("");
// 重新获取更新后的内容并更新 Redux store
const updatedContent = quill.root.innerHTML;
dispatch(setEditorContent(updatedContent));