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.
This commit is contained in:
2026-08-23 19:31:33 +05:30
parent cd3385ec69
commit 58868eece0
2 changed files with 28 additions and 0 deletions
+24
View File
@@ -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());
// ============================================
+4
View File
@@ -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 = [