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

@@ -78,6 +78,11 @@ import "./themes/add-custom-theme";
import "./themes/delete-custom-theme";
import "./themes/get-all-custom-themes";
import "./themes/delete-all-custom-themes";
import "./themes/update-custom-theme";
import "./themes/open-editor-window";
import "./themes/get-custom-theme-by-id";
import "./themes/get-active-custom-theme";
import "./themes/css-injector";
import { isPortableVersion } from "@main/helpers";
ipcMain.handle("ping", () => "pong");

View File

@@ -0,0 +1,12 @@
import { registerEvent } from "../register-event";
import { WindowManager } from "@main/services";
const injectCSS = async (
_event: Electron.IpcMainInvokeEvent,
cssString: string
) => {
WindowManager.mainWindow?.webContents.send("css-injected", cssString);
return;
};
registerEvent("injectCSS", injectCSS);

View File

@@ -0,0 +1,10 @@
import { registerEvent } from "../register-event";
import { themes } from "@main/level/sublevels/themes";
import { Theme } from "@types";
const getActiveCustomTheme = async () => {
const allThemes = await themes.values().all();
return allThemes.find((theme: Theme) => theme.isActive);
};
registerEvent("getActiveCustomTheme", getActiveCustomTheme);

View File

@@ -0,0 +1,8 @@
import { themes } from "@main/level/sublevels/themes";
import { registerEvent } from "../register-event";
const getCustomThemeById = async (_event: Electron.IpcMainInvokeEvent, themeId: string) => {
return await themes.get(themeId);
};
registerEvent("getCustomThemeById", getCustomThemeById);

View File

@@ -0,0 +1,8 @@
import { WindowManager } from "@main/services";
import { registerEvent } from "../register-event";
const openEditorWindow = async (_event: Electron.IpcMainInvokeEvent, themeId: string) => {
WindowManager.openEditorWindow(themeId);
};
registerEvent("openEditorWindow", openEditorWindow);

View File

@@ -0,0 +1,13 @@
import { themes } from "@main/level/sublevels/themes";
import { registerEvent } from "../register-event";
import { Theme } from "@types";
const updateCustomTheme = async (
_event: Electron.IpcMainInvokeEvent,
themeId: string,
theme: Theme
) => {
await themes.put(themeId, theme);
};
registerEvent("updateCustomTheme", updateCustomTheme);