Commit 63632233 authored by Kantz's avatar Kantz
Browse files

new shortkeys

parent 76ecaef2
...@@ -256,12 +256,21 @@ export default function MessageInput({ ...@@ -256,12 +256,21 @@ export default function MessageInput({
onSend(message); onSend(message);
}, [clearEditor, isSending, onSend]); }, [clearEditor, isSending, onSend]);
const saveFormula = useCallback(() => { const closeMathEditor = useCallback(() => {
saveMathRef.current?.(mathFieldRef.current?.value || "");
saveMathRef.current = null; saveMathRef.current = null;
dialogRef.current?.close(); dialogRef.current?.close();
}, []); }, []);
const saveFormula = useCallback(() => {
const latex = stripMathDelimiters(mathFieldRef.current?.value || "");
if (!latex) {
closeMathEditor();
return;
}
saveMathRef.current?.(latex);
closeMathEditor();
}, [closeMathEditor]);
const MathNode = useMemo(() => createMathNode(openMathEditor), [openMathEditor]); const MathNode = useMemo(() => createMathNode(openMathEditor), [openMathEditor]);
const editor = useEditor({ const editor = useEditor({
...@@ -449,7 +458,10 @@ export default function MessageInput({ ...@@ -449,7 +458,10 @@ export default function MessageInput({
onClose={(event) => { onClose={(event) => {
const dialog = event.currentTarget; const dialog = event.currentTarget;
if (dialog.returnValue === "save") { if (dialog.returnValue === "save") {
saveMathRef.current?.(mathFieldRef.current?.value || ""); const latex = stripMathDelimiters(mathFieldRef.current?.value || "");
if (latex) {
saveMathRef.current?.(latex);
}
} }
saveMathRef.current = null; saveMathRef.current = null;
}} }}
...@@ -462,6 +474,10 @@ export default function MessageInput({ ...@@ -462,6 +474,10 @@ export default function MessageInput({
event.preventDefault(); event.preventDefault();
saveFormula(); saveFormula();
} }
if (event.key === "Escape") {
event.preventDefault();
closeMathEditor();
}
}} }}
/> />
<div className="dialog-actions"> <div className="dialog-actions">
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment