Skip to content

Commit

Permalink
feat: save \n in prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
Echo-minn committed Apr 10, 2024
1 parent 006e55b commit d2259ef
Showing 1 changed file with 2 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,6 @@ const PromptInput = () => {
const [isComposing, setIsComposing] = useState(false);
const [isEmpty, setIsEmpty] = useState(true);

/** clean input
* @param html innerHTML
* Use hiddenRef as an intermediary to solve the bug of missing line breaks
*/
const cleanInput = (html: string) => {
html = html.replace(/<span class="modelName">.*?<\/span>/g, '');
hiddenRef.current.innerHTML = html;
return hiddenRef.current.innerText || '';
};

/** filter html tags to prevent XSS attacks
* @param content innerHTML
* @param updateCaretFlag whether to update caret position
Expand Down Expand Up @@ -169,7 +159,7 @@ const PromptInput = () => {
return;
}
const target = e.target as HTMLDivElement;
setCurrPrompt(cleanInput(target.innerHTML));
setCurrPrompt(target.innerText);
const content = target.innerHTML;
handleContentChange(content);
};
Expand All @@ -184,7 +174,7 @@ const PromptInput = () => {
return;
}
const target = e.target as HTMLDivElement;
setCurrPrompt(cleanInput(target.innerHTML));
setCurrPrompt(target.innerText);
const content = target.innerHTML;
handleContentChange(content);
};
Expand Down

0 comments on commit d2259ef

Please sign in to comment.