From 382d4d528ab8916da39de641ad47836993b72969 Mon Sep 17 00:00:00 2001 From: gabriele-cusato Date: Mon, 18 May 2026 22:01:18 +0200 Subject: [PATCH] fixato il bug del tema sul pad 5 e anche reso piu solido il cambio tema in generale per altri dispositivi --- HandTranscriptMd/src/main.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/HandTranscriptMd/src/main.ts b/HandTranscriptMd/src/main.ts index 95f1189..0e6d996 100644 --- a/HandTranscriptMd/src/main.ts +++ b/HandTranscriptMd/src/main.ts @@ -51,8 +51,14 @@ export default class HandwritingPlugin extends Plugin { // Applica la lingua interfaccia salvata (o la lingua di sistema se 'auto') setLocale(this.settings.uiLanguage); - // Rileva cambio tema Obsidian (aggiunta/rimozione classe 'theme-dark' sul body). - // Se bgMode è 'auto', notifica tutti i listener per aggiornare colori e SVG. + // Rileva cambio tema Obsidian. Doppio meccanismo per massima compatibilità Android: + // - css-change: evento Obsidian garantito al cambio tema (più affidabile su alcuni WebView Android) + // - MutationObserver: fallback per cambii di classe body da plugin terzi o versioni vecchie + this.registerEvent( + this.app.workspace.on('css-change', () => { + if (this.settings.bgMode === 'auto') this.notifyBgModeChange(); + }) + ); const themeObserver = new MutationObserver(() => { if (this.settings.bgMode === 'auto') this.notifyBgModeChange(); });