Also reduce unnecessary imports
This commit is contained in:
omuretsu 2023-05-16 11:41:55 -04:00
parent 00522fb8f3
commit 27a6b619eb
3 changed files with 11 additions and 14 deletions

@ -2,8 +2,6 @@ import * as monaco from "monaco-editor";
import * as React from "react";
import { useEffect, useRef } from "react";
export type Monaco = typeof monaco;
interface EditorProps {
/** Editor options */
options: monaco.editor.IEditorOptions;

@ -1,11 +1,10 @@
import React, { useState, useEffect, useRef } from "react";
import { Editor, Monaco } from "./Editor";
import { Editor } from "./Editor";
import * as monaco from "monaco-editor";
// @ts-expect-error This library does not have types.
import * as MonacoVim from "monaco-vim";
type IStandaloneCodeEditor = monaco.editor.IStandaloneCodeEditor;
type EditorDecorations = monaco.editor.IEditorDecorationsCollection;
type ITextModel = monaco.editor.ITextModel;
import { OptionsModal } from "./OptionsModal";
import { Options } from "./Options";
@ -321,7 +320,7 @@ export function Root(props: IProps): React.ReactElement {
const source = (libSource + "").replace(/export /g, "");
monaco.languages.typescript.javascriptDefaults.addExtraLib(source, "netscript.d.ts");
monaco.languages.typescript.typescriptDefaults.addExtraLib(source, "netscript.d.ts");
loadThemes(monaco);
loadThemes(monaco.editor.defineTheme);
sanitizeTheme(Settings.EditorTheme);
monaco.editor.defineTheme("customTheme", makeTheme(Settings.EditorTheme));
}

@ -1,5 +1,5 @@
import * as monaco from "monaco-editor";
import type { Monaco } from "./Editor";
import type { editor } from "monaco-editor";
type DefineThemeFn = typeof editor.defineTheme;
export interface IScriptEditorTheme {
base: "vs" | "vs-dark" | "hc-black";
@ -93,7 +93,7 @@ export const sanitizeTheme = (theme: IScriptEditorTheme): void => {
}
};
export function makeTheme(theme: IScriptEditorTheme): monaco.editor.IStandaloneThemeData {
export function makeTheme(theme: IScriptEditorTheme): editor.IStandaloneThemeData {
const themeRules = [
{
token: "",
@ -208,8 +208,8 @@ export function makeTheme(theme: IScriptEditorTheme): monaco.editor.IStandaloneT
return { base: theme.base, inherit: theme.inherit, rules: themeRules, colors: themeColors };
}
export async function loadThemes(monaco: Monaco): Promise<void> {
monaco.editor.defineTheme("monokai", {
export async function loadThemes(defineTheme: DefineThemeFn): Promise<void> {
defineTheme("monokai", {
base: "vs-dark",
inherit: true,
rules: [
@ -274,7 +274,7 @@ export async function loadThemes(monaco: Monaco): Promise<void> {
},
});
monaco.editor.defineTheme("solarized-dark", {
defineTheme("solarized-dark", {
base: "vs-dark",
inherit: true,
rules: [
@ -351,7 +351,7 @@ export async function loadThemes(monaco: Monaco): Promise<void> {
},
});
monaco.editor.defineTheme("solarized-light", {
defineTheme("solarized-light", {
base: "vs",
inherit: true,
rules: [
@ -429,7 +429,7 @@ export async function loadThemes(monaco: Monaco): Promise<void> {
},
});
monaco.editor.defineTheme("dracula", {
defineTheme("dracula", {
base: "vs-dark",
inherit: true,
rules: [
@ -525,7 +525,7 @@ export async function loadThemes(monaco: Monaco): Promise<void> {
},
});
monaco.editor.defineTheme("one-dark", {
defineTheme("one-dark", {
base: "vs-dark",
inherit: true,
rules: [