config system + move api to frontend

This commit is contained in:
nicwands
2026-03-11 12:26:40 -04:00
parent efc9c73751
commit a1b339f668
26 changed files with 10833 additions and 1631 deletions

View File

@@ -1,5 +1,9 @@
import { contextBridge, ipcRenderer } from "electron";
const api = {
getConfig: () => ipcRenderer.invoke("getConfig"),
setConfig: (config) => ipcRenderer.invoke("setConfig", config),
listPlugins: () => ipcRenderer.invoke("listPlugins"),
setActivePlugin: (pluginId) => ipcRenderer.invoke("setActivePlugin", pluginId),
openNoteWindow: (noteId) => {
ipcRenderer.send("open-note-window", noteId);
},
@@ -11,18 +15,22 @@ const api = {
},
onNoteDeleted: (callback) => {
ipcRenderer.on("note-deleted", (_, data) => callback(data));
},
notifyNoteChanged: (event, data) => {
ipcRenderer.send("note-changed", event, data);
}
};
const notesAPI = {
call: (method, ...args) => ipcRenderer.invoke("notesAPI:call", method, args)
const adapter = {
call: (method, ...args) => ipcRenderer.invoke("adapter:call", method, args)
};
if (process.contextIsolated) {
try {
contextBridge.exposeInMainWorld("api", api);
contextBridge.exposeInMainWorld("notesAPI", notesAPI);
contextBridge.exposeInMainWorld("adapter", adapter);
} catch (error) {
console.error(error);
}
} else {
window.api = api;
window.adapter = adapter;
}