From 616556723837d2023592d4368b71a1f8584b4ff5 Mon Sep 17 00:00:00 2001 From: Abdo Date: Wed, 1 Oct 2025 11:50:27 +0300 Subject: [PATCH] Refresh fields after MathJax toggle There's probably a more efficient solution for this but I couldn't figure it out --- ts/lib/editable/mathjax-element.svelte.ts | 4 ++-- ts/routes/editor/EditorField.svelte | 17 ++++++++++------- .../editor/editor-toolbar/OptionsButton.svelte | 1 - 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/ts/lib/editable/mathjax-element.svelte.ts b/ts/lib/editable/mathjax-element.svelte.ts index c53844710..bea0390c7 100644 --- a/ts/lib/editable/mathjax-element.svelte.ts +++ b/ts/lib/editable/mathjax-element.svelte.ts @@ -22,9 +22,9 @@ function trimBreaks(text: string): string { .replace(/\n*$/, ""); } -export const mathjaxConfig = { +export const mathjaxConfig = $state({ enabled: true, -}; +}); interface MathjaxProps { mathjax: string; diff --git a/ts/routes/editor/EditorField.svelte b/ts/routes/editor/EditorField.svelte index c7f6fb9d8..da04d2627 100644 --- a/ts/routes/editor/EditorField.svelte +++ b/ts/routes/editor/EditorField.svelte @@ -6,6 +6,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html import type { Readable } from "svelte/store"; import type { EditingAreaAPI } from "./EditingArea.svelte"; + import { mathjaxConfig } from "$lib/editable/mathjax-element.svelte"; export interface FieldData { name: string; @@ -117,13 +118,15 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html fontSize={field.fontSize} api={editingArea} > - {#if flipInputs} - - - {:else} - - - {/if} + {#key mathjaxConfig.enabled} + {#if flipInputs} + + + {:else} + + + {/if} + {/key} diff --git a/ts/routes/editor/editor-toolbar/OptionsButton.svelte b/ts/routes/editor/editor-toolbar/OptionsButton.svelte index 7be70076a..952837fbb 100644 --- a/ts/routes/editor/editor-toolbar/OptionsButton.svelte +++ b/ts/routes/editor/editor-toolbar/OptionsButton.svelte @@ -34,7 +34,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html bridgeCommand("toggleMathjax"); } else { setColConfig("renderMathjax", mathjaxConfig.enabled); - // FIXME: refresh } }