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