feat(desktop): deliver font settings to plugin sandboxes

This commit is contained in:
Jinpy authored and GitHub committed 2026-09-19 19:13:30 +08:00
1 parent ba6b74beea
commit b1b99eccfb
15 files changed
+309 -25

No files matched your search

@@ -5,6 +5,7 @@ import * as api from "@/lib/backend/api";
import { isTauriRuntime } from "@/lib/backend/tauriRuntime";
import { copyToClipboard } from "@/lib/common/clipboard";
import { PluginHostBridge, pluginSandboxDocument, type PluginBridgeTheme, type PluginSaveFileRequest, type PluginSaveFileResult, type PluginWorkbenchContext } from "@/lib/plugins/pluginHostBridge";
import { buildPluginEditorAppearance } from "@/lib/plugins/pluginAppearance";
import type { InstalledPlugin, PluginWorkbenchContribution } from "@/types/database";
import { useI18n } from "vue-i18n";
import { useTheme } from "@/composables/useTheme";
@@ -59,7 +60,11 @@ function currentBridgeTheme(): PluginBridgeTheme {
}
}
}
return { appearance: isDark.value ? "dark" : "light", tokens };
return {
appearance: isDark.value ? "dark" : "light",
tokens,
editor: buildPluginEditorAppearance(settingsStore.editorSettings),
};
}
function createBridge() {
@@ -249,11 +254,11 @@ watch(appLocale, (locale) => bridge?.updateLocale(locale));
// path — dark/light, palette switch, custom colors — re-pushes the resolved
// tokens; watching isDark/custom colors alone misses palette-only switches.
watch(themeRevision, () => bridge?.updateTheme(currentBridgeTheme()));
// Font settings are applied outside applyTheme() (see App.vue applyUiFontFamily)
// and therefore never bump themeRevision; watch them explicitly so font token
// changes reach live plugin bridges without waiting for the next theme switch.
// Font families are mirrored onto root tokens by App.vue (writeRootToken) and
// reach live bridges through the themeRevision bump above. fontSize and the
// SQL editor syntax theme have no CSS-token carrier — watch them explicitly.
watch(
() => [settingsStore.editorSettings.uiFontFamily, settingsStore.editorSettings.fontFamily, settingsStore.editorSettings.fontSize],
() => [settingsStore.editorSettings.fontSize, settingsStore.editorSettings.theme],
() => bridge?.updateTheme(currentBridgeTheme()),
);