const { app, BrowserWindow, ipcMain, dialog } = require('electron'); const path = require('path'); const fs = require('fs'); function createWindow() { const win = new BrowserWindow({ width: 1000, height: 800, webPreferences: { preload: path.join(__dirname, 'preload.js'), nodeIntegration: false, contextIsolation: true, sandbox: true }, // Modern dark theme background backgroundColor: '#0f172a', titleBarStyle: 'hiddenInset' // Looks cleaner on macOS, normal on others }); win.loadFile('index.html'); } app.whenReady().then(() => { createWindow(); app.on('activate', () => { if (BrowserWindow.getAllWindows().length === 0) { createWindow(); } }); }); app.on('window-all-closed', () => { if (process.platform !== 'darwin') { app.quit(); } }); ipcMain.handle('open-file-dialog', async () => { const { canceled, filePaths } = await dialog.showOpenDialog({ properties: ['openFile'], filters: [ { name: 'Markdown', extensions: ['md', 'markdown', 'txt'] }, { name: 'All Files', extensions: ['*'] } ] }); if (canceled) { return null; } else { return filePaths[0]; } }); ipcMain.handle('read-file', async (event, filePath) => { try { const content = fs.readFileSync(filePath, 'utf-8'); return content; } catch (err) { console.error("Error reading file", err); throw err; } });