Fix hotfix

This commit is contained in:
omuretsu 2023-05-30 20:47:01 -04:00
parent 8bc67f542a
commit 7240bbe8b7

@ -1,6 +1,7 @@
import type { editor } from "monaco-editor"; import type { editor } from "monaco-editor";
import { getRecordKeys } from "../../Types/Record"; import { getRecordKeys } from "../../Types/Record";
import { Settings } from "../../Settings/Settings"; import { Settings } from "../../Settings/Settings";
import { cloneDeep } from "lodash";
type DefineThemeFn = typeof editor.defineTheme; type DefineThemeFn = typeof editor.defineTheme;
export interface IScriptEditorTheme { export interface IScriptEditorTheme {
@ -75,7 +76,7 @@ const colorRegExp = /^#?([0-9A-Fa-f]{6})([0-9A-Fa-f]{2})?$/;
// Invalid data will be replaced with FF0000 (bright red) // Invalid data will be replaced with FF0000 (bright red)
export const sanitizeTheme = (theme: IScriptEditorTheme): void => { export const sanitizeTheme = (theme: IScriptEditorTheme): void => {
if (typeof theme !== "object") { if (typeof theme !== "object") {
Settings.EditorTheme = defaultMonacoTheme; Settings.EditorTheme = cloneDeep(defaultMonacoTheme);
return; return;
} }
for (const themeKey of getRecordKeys(theme)) { for (const themeKey of getRecordKeys(theme)) {
@ -94,7 +95,7 @@ export const sanitizeTheme = (theme: IScriptEditorTheme): void => {
for (const [blockKey, blockValue] of Object.entries(block) as [keyof T, unknown][]) { for (const [blockKey, blockValue] of Object.entries(block) as [keyof T, unknown][]) {
if (!blockValue || (typeof blockValue !== "string" && typeof blockValue !== "object")) if (!blockValue || (typeof blockValue !== "string" && typeof blockValue !== "object"))
(block[blockKey] as string) = "FF0000"; (block[blockKey] as string) = "FF0000";
else if (typeof blockValue === "object") repairBlock(block); else if (typeof blockValue === "object") repairBlock(blockValue as Record<string, unknown>);
else if (!blockValue.match(colorRegExp)) (block[blockKey] as string) = "FF0000"; else if (!blockValue.match(colorRegExp)) (block[blockKey] as string) = "FF0000";
} }
}; };