local file saving/reading

This commit is contained in:
nicwands
2026-02-23 13:43:04 -05:00
parent 660b0825c5
commit 7a670aab92
10 changed files with 321 additions and 72 deletions

View File

@@ -1,24 +1,25 @@
import { contextBridge, ipcRenderer } from 'electron'
import { electronAPI } from '@electron-toolkit/preload'
// Custom APIs for renderer
const api = {
openNoteWindow: (noteId) => {
ipcRenderer.send('open-note-window', noteId)
},
listNotes: () => ipcRenderer.invoke('notes:list'),
createNote: (path, content) =>
ipcRenderer.invoke('notes:create', { path, content }),
createNoteDir: (path) => ipcRenderer.invoke('notes:createDir', path),
readNote: (path) => ipcRenderer.invoke('notes:read', path),
updateNote: (path, content) =>
ipcRenderer.invoke('notes:update', { path, content }),
}
// Use `contextBridge` APIs to expose Electron APIs to
// renderer only if context isolation is enabled, otherwise
// just add to the DOM global.
if (process.contextIsolated) {
try {
contextBridge.exposeInMainWorld('electron', electronAPI)
contextBridge.exposeInMainWorld('api', api)
} catch (error) {
console.error(error)
}
} else {
window.electron = electronAPI
window.api = api
}