working with monaco anys

This commit is contained in:
Olivier Gagnon
2022-07-19 20:10:30 -04:00
parent 0c07dddb36
commit dfadfe6eb2
3 changed files with 10 additions and 7 deletions
+7 -4
View File
@@ -1,6 +1,9 @@
import * as monaco from "monaco-editor";
import type { Monaco } from "@monaco-editor/react";
export interface IScriptEditorTheme {
[key: string]: any;
base: string;
base: "vs" | "vs-dark" | "hc-black";
inherit: boolean;
common: {
[key: string]: string;
@@ -85,7 +88,7 @@ export const sanitizeTheme = (theme: IScriptEditorTheme): void => {
continue;
}
const repairBlock = (block: { [key: string]: any }): void => {
const repairBlock = (block: { [key: string]: object | string }): void => {
for (const [k, v] of Object.entries(block)) {
if (typeof v === "object") {
repairBlock(v as { [key: string]: string });
@@ -96,7 +99,7 @@ export const sanitizeTheme = (theme: IScriptEditorTheme): void => {
}
};
export function makeTheme(theme: IScriptEditorTheme): any {
export function makeTheme(theme: IScriptEditorTheme): monaco.editor.IStandaloneThemeData {
const themeRules = [
{
token: "",
@@ -211,7 +214,7 @@ export function makeTheme(theme: IScriptEditorTheme): any {
return { base: theme.base, inherit: theme.inherit, rules: themeRules, colors: themeColors };
}
export async function loadThemes(monaco: { editor: any }): Promise<void> {
export async function loadThemes(monaco: Monaco): Promise<void> {
monaco.editor.defineTheme("monokai", {
base: "vs-dark",
inherit: true,