Skip to content

Commit b3db4a8

Browse files
author
Marco
committed
latest
1 parent 7106e72 commit b3db4a8

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

components/webui/client/src/components/SqlEditor/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
} from "@monaco-editor/react";
88
import {language as sqlLanguage} from "monaco-editor/esm/vs/basic-languages/sql/sql.js";
99

10+
import "./monaco-config";
1011

1112
type SqlEditorProps = Omit<EditorProps, "language">;
1213

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { loader } from '@monaco-editor/react';
2+
import * as monaco from 'monaco-editor';
3+
import editorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker';
4+
import jsonWorker from 'monaco-editor/esm/vs/language/json/json.worker?worker';
5+
import cssWorker from 'monaco-editor/esm/vs/language/css/css.worker?worker';
6+
import htmlWorker from 'monaco-editor/esm/vs/language/html/html.worker?worker';
7+
import tsWorker from 'monaco-editor/esm/vs/language/typescript/ts.worker?worker';
8+
9+
// Reference: https://github.com/suren-atoyan/monaco-react?tab=readme-ov-file#use-monaco-editor-as-an-npm-package
10+
self.MonacoEnvironment = {
11+
getWorker(_, label) {
12+
if (label === 'json') {
13+
return new jsonWorker();
14+
}
15+
if (label === 'css' || label === 'scss' || label === 'less') {
16+
return new cssWorker();
17+
}
18+
if (label === 'html' || label === 'handlebars' || label === 'razor') {
19+
return new htmlWorker();
20+
}
21+
if (label === 'typescript' || label === 'javascript') {
22+
return new tsWorker();
23+
}
24+
return new editorWorker();
25+
},
26+
};
27+
28+
loader.config({ monaco });

components/webui/client/src/components/SqlEditor/monaco-sql.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
declare module "monaco-editor/esm/vs/basic-languages/sql/sql.js" {
2-
import {languages} from "monaco-editor/esm/vs/editor/editor.api";
2+
import {languages} from "monaco-editor";
33

44

55
interface SqlLanguageDefinition extends languages.IMonarchLanguage {

0 commit comments

Comments
 (0)