Skip to content

Commit

Permalink
feat: 记录selection位置以及自动清空UserInput内容
Browse files Browse the repository at this point in the history
  • Loading branch information
14790897 committed Feb 13, 2024
1 parent e3a8747 commit 9e85552
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions components/QuillEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -236,6 +239,8 @@ const QEditor = ({ lng }) => {
upsreamUrl,
prompt
);
// 清空input内容
setUserInput("");
// 重新获取更新后的内容并更新 Redux store
const updatedContent = quill.root.innerHTML;
dispatch(setEditorContent(updatedContent));
Expand Down

0 comments on commit 9e85552

Please sign in to comment.