feat: add theme editor with Monaco and custom CSS injection

This commit is contained in:
Hachi-R
2025-01-29 03:46:22 -03:00
parent 3e2d7a751c
commit 5a19e9fd12
23 changed files with 516 additions and 20 deletions

View File

@@ -194,6 +194,58 @@ export class WindowManager {
}
}
public static openEditorWindow(themeId: string) {
if (this.mainWindow) {
const editorWindow = new BrowserWindow({
width: 600,
height: 720,
minWidth: 600,
minHeight: 540,
backgroundColor: "#1c1c1c",
titleBarStyle: process.platform === "linux" ? "default" : "hidden",
...(process.platform === "linux" ? { icon } : {}),
trafficLightPosition: { x: 16, y: 16 },
titleBarOverlay: {
symbolColor: "#DADBE1",
color: "#151515",
height: 34,
},
webPreferences: {
preload: path.join(__dirname, "../preload/index.mjs"),
sandbox: false,
},
show: false,
});
if (!app.isPackaged) {
editorWindow.webContents.openDevTools();
} else {
this.mainWindow?.webContents.openDevTools();
}
editorWindow.removeMenu();
if (is.dev && process.env["ELECTRON_RENDERER_URL"]) {
editorWindow.loadURL(
`${process.env["ELECTRON_RENDERER_URL"]}#/editor?themeId=${themeId}`
);
} else {
editorWindow.loadFile(
path.join(__dirname, "../renderer/index.html"),
{
hash: "editor",
}
);
}
editorWindow.once("ready-to-show", () => {
editorWindow.show();
});
}
}
public static redirect(hash: string) {
if (!this.mainWindow) this.createMainWindow();
this.loadMainWindowURL(hash);