diff --git a/.prettierignore b/.prettierignore index 400e2a8..d02fd3a 100644 --- a/.prettierignore +++ b/.prettierignore @@ -3,3 +3,4 @@ dist/ build/ .env *.log +src/app/pico.jade.css \ No newline at end of file diff --git a/src/app/foldernav.ts b/src/app/foldernav.ts index 8342309..efbbd4a 100644 --- a/src/app/foldernav.ts +++ b/src/app/foldernav.ts @@ -1,8 +1,7 @@ -import van from "vanjs-core" -const v = van.tags +import van from "vanjs-core"; +const v = van.tags; document.getElementById("openFolder").addEventListener("click", async () => { const folderPath = await window.electronAPI.openFolder(); document.getElementById("currentFolder").innerText = folderPath; -}) - +}); diff --git a/src/app/index.css b/src/app/index.css index 40efc3b..a9ccef8 100644 --- a/src/app/index.css +++ b/src/app/index.css @@ -1,54 +1,54 @@ /* Grid layout stuff (main) */ body { - width: 100vw; - height: 100vh; - display: grid; - grid-template-rows: auto minmax(0, 1fr); - grid-template-columns: auto minmax(0, 4fr); + width: 100vw; + height: 100vh; + display: grid; + grid-template-rows: auto minmax(0, 1fr); + grid-template-columns: auto minmax(0, 4fr); } body > header { - padding: 0px; - grid-column: 1 / -1; - grid-row: 1; + padding: 0px; + grid-column: 1 / -1; + grid-row: 1; } body > main { - grid-column: 2; - grid-row: 2; - padding: 0; + grid-column: 2; + grid-row: 2; + padding: 0; } aside { - grid-column: 1; - grid-row: 2; - resize: horizontal; - overflow: hidden; - border: 1px solid green; - white-space: nowrap; + grid-column: 1; + grid-row: 2; + resize: horizontal; + overflow: hidden; + border: 1px solid green; + white-space: nowrap; - min-width: 90px; - max-width: 50vw; - width: 200px; + min-width: 90px; + max-width: 50vw; + width: 200px; } /* Editor grid stuff */ #editorGrid { - display: grid; - height: minmax(0, 100%); - width: minmax(0, 100%); - overflow: auto; - grid-auto-flow: column; - grid-auto-columns: min-content; - grid-gap: 1em; - grid-template-columns: none; - /* grid-template-columns: 1fr; */ - overflow-x: auto; + display: grid; + height: minmax(0, 100%); + width: minmax(0, 100%); + overflow: auto; + grid-auto-flow: column; + grid-auto-columns: min-content; + grid-gap: 1em; + grid-template-columns: none; + /* grid-template-columns: 1fr; */ + overflow-x: auto; } .editorWrapper { - min-width: fit-content; + min-width: fit-content; } /* Navbar styling */ diff --git a/src/app/renderer.ts b/src/app/renderer.ts index c6cef21..eda488b 100644 --- a/src/app/renderer.ts +++ b/src/app/renderer.ts @@ -26,18 +26,18 @@ * ``` */ -import './pico.jade.css'; -import './index.css'; +import "./pico.jade.css"; +import "./index.css"; -import van from "vanjs-core" -import * as vanX from "vanjs-ext" -const v = van.tags +import van from "vanjs-core"; +import * as vanX from "vanjs-ext"; +const v = van.tags; -import { basicSetup } from "codemirror" -import { EditorView } from "@codemirror/view" -import { oneDark } from "@codemirror/theme-one-dark" +import { basicSetup } from "codemirror"; +import { EditorView } from "@codemirror/view"; +import { oneDark } from "@codemirror/theme-one-dark"; -import './foldernav.ts' +import "./foldernav.ts"; const fixedHeightEditor = EditorView.theme({ "&": { @@ -48,8 +48,8 @@ const fixedHeightEditor = EditorView.theme({ width: "600px", minWidth: "8em", }, - ".cm-scroller": { overflow: "auto" } -}) + ".cm-scroller": { overflow: "auto" }, +}); class EditorColumn { view: EditorView; @@ -58,8 +58,8 @@ class EditorColumn { constructor() { this.view = new EditorView({ doc: "Start document", - extensions: [basicSetup, oneDark, fixedHeightEditor] - }) + extensions: [basicSetup, oneDark, fixedHeightEditor], + }); console.log("Character width: ", this.view.defaultCharacterWidth); this.wrapper = v.div({ class: "editorWrapper" }, this.view.dom); } @@ -70,7 +70,7 @@ class EditorColumn { // Create and mount editor list const editors = vanX.reactive([]); -vanX.list(document.getElementById("editorGrid"), editors, v => v.val.dom); +vanX.list(document.getElementById("editorGrid"), editors, (v) => v.val.dom); function addView() { editors.push(vanX.noreactive(new EditorColumn())); diff --git a/src/main/fileOperations.ts b/src/main/fileOperations.ts index 9e31f02..f3b1cb3 100644 --- a/src/main/fileOperations.ts +++ b/src/main/fileOperations.ts @@ -1,26 +1,28 @@ // src/main/fileOperations.ts // Handles file operations for the main process -import { dialog, BrowserWindow } from 'electron'; -import fs from 'fs'; -import path from 'path'; +import { dialog, BrowserWindow } from "electron"; +import fs from "fs"; +import path from "path"; export async function handleOpenFolder(mainWindow: BrowserWindow) { - const result = await dialog.showOpenDialog(mainWindow, { - properties: ['openDirectory'] - }); - if (!result.canceled && result.filePaths.length > 0) { - const folderPath = result.filePaths[0]; - return folderPath; - } - return null; + const result = await dialog.showOpenDialog(mainWindow, { + properties: ["openDirectory"], + }); + if (!result.canceled && result.filePaths.length > 0) { + const folderPath = result.filePaths[0]; + return folderPath; + } + return null; } export function readFolderContents(folderPath: string): string[] { - try { - return fs.readdirSync(folderPath).map(file => path.join(folderPath, file)); - } catch (err) { - console.error('Error reading folder:', err); - return []; - } + try { + return fs + .readdirSync(folderPath) + .map((file) => path.join(folderPath, file)); + } catch (err) { + console.error("Error reading folder:", err); + return []; + } } diff --git a/src/main/main.ts b/src/main/main.ts index 9aadba2..d7710ec 100644 --- a/src/main/main.ts +++ b/src/main/main.ts @@ -1,62 +1,62 @@ -import { app, BrowserWindow, ipcMain } from 'electron'; -import { handleOpenFolder, readFolderContents } from './fileOperations'; -import path from 'node:path'; -import started from 'electron-squirrel-startup'; +import { app, BrowserWindow, ipcMain } from "electron"; +import { handleOpenFolder, readFolderContents } from "./fileOperations"; +import path from "node:path"; +import started from "electron-squirrel-startup"; // Handle creating/removing shortcuts on Windows when installing/uninstalling. if (started) { - app.quit(); + app.quit(); } const createWindow = () => { - // Create the browser window. - const mainWindow = new BrowserWindow({ - width: 800, - height: 600, - webPreferences: { - preload: path.join(__dirname, 'preload.js'), - }, - }); + // Create the browser window. + const mainWindow = new BrowserWindow({ + width: 800, + height: 600, + webPreferences: { + preload: path.join(__dirname, "preload.js"), + }, + }); - // and load the index.html of the app. - if (MAIN_WINDOW_VITE_DEV_SERVER_URL) { - mainWindow.loadURL(MAIN_WINDOW_VITE_DEV_SERVER_URL); - } else { - mainWindow.loadFile(path.join(__dirname, `../renderer/${MAIN_WINDOW_VITE_NAME}/index.html`)); - } + // and load the index.html of the app. + if (MAIN_WINDOW_VITE_DEV_SERVER_URL) { + mainWindow.loadURL(MAIN_WINDOW_VITE_DEV_SERVER_URL); + } else { + mainWindow.loadFile( + path.join( + __dirname, + `../renderer/${MAIN_WINDOW_VITE_NAME}/index.html`, + ), + ); + } - // Open the DevTools. - mainWindow.webContents.openDevTools(); + // Open the DevTools. + mainWindow.webContents.openDevTools(); }; // This method will be called when Electron has finished // initialization and is ready to create browser windows. // Some APIs can only be used after this event occurs. - app.whenReady().then(() => { - ipcMain.handle("dialog:openFolder", async (event) => { - // Use the sender's window for correct dialog association - const senderWindow = BrowserWindow.fromWebContents(event.sender); - return await handleOpenFolder(senderWindow); - }); - createWindow(); - app.on('activate', function () { - if (BrowserWindow.getAllWindows().length === 0) createWindow(); - }); + ipcMain.handle("dialog:openFolder", async (event) => { + // Use the sender's window for correct dialog association + const senderWindow = BrowserWindow.fromWebContents(event.sender); + return await handleOpenFolder(senderWindow); + }); + createWindow(); + app.on("activate", function () { + if (BrowserWindow.getAllWindows().length === 0) createWindow(); + }); }); - -app.on('ready', createWindow); - - - +app.on("ready", createWindow); // Quit when all windows are closed, except on macOS. There, it's common // for applications and their menu bar to stay active until the user quits // explicitly with Cmd + Q. -app.on('window-all-closed', () => { - if (process.platform !== 'darwin') { - app.quit(); - } +app.on("window-all-closed", () => { + if (process.platform !== "darwin") { + app.quit(); + } }); diff --git a/src/preload.ts b/src/preload.ts index 412c25b..4ce1923 100644 --- a/src/preload.ts +++ b/src/preload.ts @@ -1,8 +1,8 @@ // See the Electron documentation for details on how to use preload scripts: // https://www.electronjs.org/docs/latest/tutorial/process-model#preload-scripts -import { contextBridge, ipcRenderer } from 'electron' +import { contextBridge, ipcRenderer } from "electron"; -contextBridge.exposeInMainWorld('electronAPI', { - openFolder: () => ipcRenderer.invoke('dialog:openFolder') -}) +contextBridge.exposeInMainWorld("electronAPI", { + openFolder: () => ipcRenderer.invoke("dialog:openFolder"), +});