Skip to content

Commit

Permalink
0.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
aarkue committed Aug 18, 2024
1 parent 2d0af08 commit aecd348
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 3 deletions.
4 changes: 2 additions & 2 deletions frontend/src/components/CELEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { VisualEditorContext } from "@/routes/visual-editor/helper/VisualEditorC
import type { Variable } from "@/types/generated/Variable";
import { useMonaco, Editor, loader } from "@monaco-editor/react";
import { useContext, useEffect, useMemo } from "react";
import * as monaco from "monaco-editor";
loader.config({ monaco });
import { initEditorLoader } from "@/lib/editor-loader";
initEditorLoader();
export default function CELEditor({
cel,
onChange,
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/components/JsonEditor.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { initEditorLoader } from "@/lib/editor-loader";
import { Editor} from "@monaco-editor/react";

initEditorLoader();
export default function JSONEditor({
value,
onChange,
Expand Down
32 changes: 32 additions & 0 deletions frontend/src/lib/editor-loader.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { loader } from "@monaco-editor/react";

import * as monaco from "monaco-editor";
import EditorWorker from "monaco-editor/esm/vs/editor/editor.worker?worker";
import JsonWorker from "monaco-editor/esm/vs/language/json/json.worker?worker";
import CssWorker from "monaco-editor/esm/vs/language/css/css.worker?worker";
import HtmlWorker from "monaco-editor/esm/vs/language/html/html.worker?worker";
import TsWorker from "monaco-editor/esm/vs/language/typescript/ts.worker?worker";

self.MonacoEnvironment = {
getWorker(_, label) {
if (label === "json") {
return new JsonWorker();
}
if (label === "css" || label === "scss" || label === "less") {
return new CssWorker();
}
if (label === "html" || label === "handlebars" || label === "razor") {
return new HtmlWorker();
}
if (label === "typescript" || label === "javascript") {
return new TsWorker();
}
return new EditorWorker();
},
};

export function initEditorLoader() {
loader.config({ monaco });

void (loader.init().then(/* ... */));
}
3 changes: 3 additions & 0 deletions frontend/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ export default defineConfig({
"@": path.resolve(__dirname, "./src"),
},
},
optimizeDeps: {
exclude: ["monaco-editor"]
},
});
2 changes: 1 addition & 1 deletion tauri/src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"package": {
"productName": "ocedeclare-tauri",
"version": "0.3.1"
"version": "0.3.2"
},
"tauri": {
"allowlist": {
Expand Down
3 changes: 3 additions & 0 deletions tauri/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@ export default defineConfig({
"@": path.resolve(__dirname, "../frontend/src"),
},
},
optimizeDeps: {
exclude: ["monaco-editor"]
},
});

0 comments on commit aecd348

Please sign in to comment.