From 1aabff9248de96eb99cc3b1f7e8680c0f1ae3c2d Mon Sep 17 00:00:00 2001 From: Hikaru Y Date: Mon, 19 Jun 2023 12:55:40 +0900 Subject: [PATCH] Fix two issues with MathJax editor (#2550) * Fix MathJax editor not closing when changing notes via shortcut Another commit will remove the on:blur handler set for , in which case the function will also be called when changing notes with a mouse click. * Don't close MathJax editor on blur event Closing MathJax editor on a blur event caused it to close even when it should not. e.g. - when switching to another application - when right-clicking to bring up the context menu - when clicking on the empty space around CodeMirror --- ts/editor/NoteEditor.svelte | 2 ++ ts/editor/mathjax-overlay/MathjaxEditor.svelte | 13 +++++++++++++ ts/editor/mathjax-overlay/MathjaxOverlay.svelte | 4 ---- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/ts/editor/NoteEditor.svelte b/ts/editor/NoteEditor.svelte index 2fdf9f069..a9b78624c 100644 --- a/ts/editor/NoteEditor.svelte +++ b/ts/editor/NoteEditor.svelte @@ -60,6 +60,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html import ImageOverlay from "./image-overlay"; import { shrinkImagesByDefault } from "./image-overlay/ImageOverlay.svelte"; import MathjaxOverlay from "./mathjax-overlay"; + import { closeMathjaxEditor } from "./mathjax-overlay/MathjaxEditor.svelte"; import Notification from "./Notification.svelte"; import PlainTextInput from "./plain-text-input"; import { closeHTMLTags } from "./plain-text-input/PlainTextInput.svelte"; @@ -292,6 +293,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html } function saveNow(): void { + closeMathjaxEditor?.(); $commitTagEdits(); saveFieldNow(); } diff --git a/ts/editor/mathjax-overlay/MathjaxEditor.svelte b/ts/editor/mathjax-overlay/MathjaxEditor.svelte index 31456ffa1..e9f43b386 100644 --- a/ts/editor/mathjax-overlay/MathjaxEditor.svelte +++ b/ts/editor/mathjax-overlay/MathjaxEditor.svelte @@ -2,6 +2,17 @@ Copyright: Ankitects Pty Ltd and contributors License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html --> + +
diff --git a/ts/editor/mathjax-overlay/MathjaxOverlay.svelte b/ts/editor/mathjax-overlay/MathjaxOverlay.svelte index 04c72af5d..ec5fd5121 100644 --- a/ts/editor/mathjax-overlay/MathjaxOverlay.svelte +++ b/ts/editor/mathjax-overlay/MathjaxOverlay.svelte @@ -229,10 +229,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html placeHandle(true); resetHandle(); }} - on:blur={async () => { - await tick(); - await resetHandle(); - }} on:close={resetHandle} let:editor={mathjaxEditor} >