feat(desktop): deliver font settings to plugin sandboxes
This commit is contained in:
1 parent
ba6b74beea
commit
b1b99eccfb
15 files changed
+309
-25
No files matched your search
@@ -1,6 +1,11 @@
|
||||
// 插件沙箱外观快照:读取 DBX 根节点的设计令牌(随 .dark / 调色板类
|
||||
// 实时变化)加编辑器字体设置,组装成插件契约里的 appearance 对象,
|
||||
// 供 PluginHostBridge 在 init 下发、主题变化时实时推送。
|
||||
// 插件沙箱外观契约与快照工具:PluginAppearance 描述宿主下发的 appearance
|
||||
// 对象(1.0 部分下发、1.1 theme 通道只带颜色令牌);buildPluginAppearance
|
||||
// 组装快照,buildPluginEditorAppearance 产出结构化 editor 字段。实际推送
|
||||
// 链路在 PluginWorkbenchHost.currentBridgeTheme → PluginHostBridge.updateTheme。
|
||||
|
||||
import type { PluginEditorAppearance } from "./pluginHostBridge";
|
||||
|
||||
export type { PluginEditorAppearance } from "./pluginHostBridge";
|
||||
|
||||
export interface PluginAppearanceColors {
|
||||
background: string;
|
||||
@@ -16,8 +21,26 @@ export interface PluginAppearanceColors {
|
||||
export interface PluginAppearance {
|
||||
colorScheme: "light" | "dark";
|
||||
colors: PluginAppearanceColors;
|
||||
// terminal.fontFamily comes from the host's --font-mono token. It is a
|
||||
// mirror of the editor font for read-only following; terminal.fontSize is
|
||||
// NOT delivered and stays plugin-owned (the SSH terminal, for one, has its
|
||||
// own zoom that persists per workbench). The full editor settings — family,
|
||||
// size and SQL syntax theme — are delivered structured as `editor`.
|
||||
terminal: { fontFamily: string; fontSize: number };
|
||||
ui?: { fontFamily: string };
|
||||
editor?: PluginEditorAppearance;
|
||||
}
|
||||
|
||||
/** Structured editor appearance for the bridge theme: SQL editor settings that
|
||||
* have no CSS-token carrier (the size is a number, the syntax theme an id).
|
||||
* Returns undefined unless every field is usable, so snapshots for hosts with
|
||||
* incomplete settings stay unchanged instead of carrying partial data. */
|
||||
export function buildPluginEditorAppearance(editor: { fontFamily?: string; fontSize?: number; theme?: string }): PluginEditorAppearance | undefined {
|
||||
const fontFamily = typeof editor.fontFamily === "string" && editor.fontFamily.trim() ? editor.fontFamily : undefined;
|
||||
const fontSize = typeof editor.fontSize === "number" && Number.isFinite(editor.fontSize) && editor.fontSize > 0 ? editor.fontSize : undefined;
|
||||
const theme = typeof editor.theme === "string" && editor.theme.trim() ? editor.theme : undefined;
|
||||
if (!fontFamily || fontSize === undefined || !theme) return undefined;
|
||||
return { fontFamily, fontSize, theme };
|
||||
}
|
||||
|
||||
// camelCase 字段 → DBX globals.css 的 CSS 令牌名。
|
||||
|
||||
Reference in new issue
Block a user