Commit 63632233 authored by Kantz's avatar Kantz
Browse files

new shortkeys

parent 76ecaef2
......@@ -256,12 +256,21 @@ export default function MessageInput({
onSend(message);
}, [clearEditor, isSending, onSend]);
const saveFormula = useCallback(() => {
saveMathRef.current?.(mathFieldRef.current?.value || "");
const closeMathEditor = useCallback(() => {
saveMathRef.current = null;
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 editor = useEditor({
......@@ -449,7 +458,10 @@ export default function MessageInput({
onClose={(event) => {
const dialog = event.currentTarget;
if (dialog.returnValue === "save") {
saveMathRef.current?.(mathFieldRef.current?.value || "");
const latex = stripMathDelimiters(mathFieldRef.current?.value || "");
if (latex) {
saveMathRef.current?.(latex);
}
}
saveMathRef.current = null;
}}
......@@ -462,6 +474,10 @@ export default function MessageInput({
event.preventDefault();
saveFormula();
}
if (event.key === "Escape") {
event.preventDefault();
closeMathEditor();
}
}}
/>
<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