From 58868eece022a78b24227c44aedbecb862f23d10 Mon Sep 17 00:00:00 2001 From: Amit Haridas Date: Tue, 30 Jun 2026 23:38:15 +0530 Subject: [PATCH] feat(IPC): expose get-monospace-settings + set-monospace-settings to renderer Renderer already calls window.electronAPI.invoke('get-monospace-settings') to apply body classes; this wires up the channel allowlist and main-process handlers so the IPC actually returns the active monospace settings and persists updates. --- src/main.js | 24 ++++++++++++++++++++++++ src/preload.js | 4 ++++ 2 files changed, 28 insertions(+) diff --git a/src/main.js b/src/main.js index 4e2d160..35868e3 100644 --- a/src/main.js +++ b/src/main.js @@ -361,6 +361,30 @@ ipcMain.handle('plugin-settings:get', (_event, key) => { ipcMain.handle('plugin-settings:set', (_event, { key, value }) => { store.set(key, value); }); + +// Monospace settings IPC — consumed by the renderer to apply CSS classes +// and to feed the PrintPreview overlay. Returns the full settings object so +// defaults are applied centrally here. +ipcMain.handle('get-monospace-settings', () => { + const s = readSettingsJsonCached(); + return { + monospaceFont: s.monospaceFont || 'jetbrains-mono', + monospaceLigatures: s.monospaceLigatures === true, + }; +}); +ipcMain.handle('set-monospace-settings', (_event, partial) => { + const safe = partial && typeof partial === 'object' ? partial : {}; + if (safe.monospaceFont !== undefined) { + store.set('monospaceFont', safe.monospaceFont); + } + if (safe.monospaceLigatures !== undefined) { + store.set('monospaceLigatures', safe.monospaceLigatures === true); + } + return { + monospaceFont: readSettingsJsonCached().monospaceFont || 'jetbrains-mono', + monospaceLigatures: readSettingsJsonCached().monospaceLigatures === true, + }; +}); ipcMain.handle('get-app-version', () => app.getVersion()); // ============================================ diff --git a/src/preload.js b/src/preload.js index 910c821..0d36bdf 100644 --- a/src/preload.js +++ b/src/preload.js @@ -141,6 +141,10 @@ const ALLOWED_SEND_CHANNELS = [ // Plugin settings 'plugin-settings:get', 'plugin-settings:set', + + // Monospace font settings + 'get-monospace-settings', + 'set-monospace-settings', ]; const ALLOWED_RECEIVE_CHANNELS = [