|
|
@ -2,12 +2,12 @@ |
|
|
|
import 'monaco-editor/esm/vs/basic-languages/javascript/javascript.contribution' |
|
|
|
import 'monaco-editor/esm/vs/basic-languages/javascript/javascript.contribution' |
|
|
|
import 'monaco-editor/esm/vs/basic-languages/typescript/typescript.contribution' |
|
|
|
import 'monaco-editor/esm/vs/basic-languages/typescript/typescript.contribution' |
|
|
|
|
|
|
|
|
|
|
|
import EditorWorkerUrl from 'monaco-editor/esm/vs/editor/editor.worker?worker&url' |
|
|
|
import EditorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker&inline' |
|
|
|
import TsWorkerUrl from 'monaco-editor/esm/vs/language/typescript/ts.worker?worker&url' |
|
|
|
import TsWorker from 'monaco-editor/esm/vs/language/typescript/ts.worker?worker&inline' |
|
|
|
import JsonWorkerUrl from 'monaco-editor/esm/vs/language/json/json.worker?worker&url' |
|
|
|
import JsonWorker from 'monaco-editor/esm/vs/language/json/json.worker?worker&inline' |
|
|
|
|
|
|
|
|
|
|
|
import type { editor as MonacoEditor } from 'monaco-editor' |
|
|
|
import type { editor as MonacoEditor } from 'monaco-editor' |
|
|
|
import { deepCompare, isDrawerOrModalExist, onMounted, ref, watch, initWorker } from '#imports' |
|
|
|
import { deepCompare, initWorker, isDrawerOrModalExist, onMounted, ref, watch } from '#imports' |
|
|
|
|
|
|
|
|
|
|
|
interface Props { |
|
|
|
interface Props { |
|
|
|
modelValue: string | Record<string, any> |
|
|
|
modelValue: string | Record<string, any> |
|
|
@ -49,15 +49,22 @@ const isValid = ref(true) |
|
|
|
* Adding monaco editor to Vite |
|
|
|
* Adding monaco editor to Vite |
|
|
|
* |
|
|
|
* |
|
|
|
* @ts-expect-error */ |
|
|
|
* @ts-expect-error */ |
|
|
|
self.MonacoEnvironment = { |
|
|
|
self.MonacoEnvironment = window.MonacoEnvironment = { |
|
|
|
getWorker(_: any, label: string) { |
|
|
|
getWorker(_: any, label: string) { |
|
|
|
|
|
|
|
console.log(JsonWorker, TsWorker, EditorWorker) |
|
|
|
switch (label) { |
|
|
|
switch (label) { |
|
|
|
case 'json': |
|
|
|
case 'json': { |
|
|
|
return initWorker(JsonWorkerUrl) |
|
|
|
const workerBlob = new Blob([JsonWorker], { type: 'text/javascript' }) |
|
|
|
case 'typescript': |
|
|
|
return initWorker(URL.createObjectURL(workerBlob)) |
|
|
|
return initWorker(TsWorkerUrl) |
|
|
|
} |
|
|
|
default: |
|
|
|
case 'typescript': { |
|
|
|
return initWorker(EditorWorkerUrl) |
|
|
|
const workerBlob = new Blob([TsWorker], { type: 'text/javascript' }) |
|
|
|
|
|
|
|
return initWorker(URL.createObjectURL(workerBlob)) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
default: { |
|
|
|
|
|
|
|
const workerBlob = new Blob([EditorWorker], { type: 'text/javascript' }) |
|
|
|
|
|
|
|
return initWorker(URL.createObjectURL(workerBlob)) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
} |
|
|
|
} |
|
|
|