|
|
@ -1,9 +1,9 @@ |
|
|
|
<script setup lang="ts"> |
|
|
|
<script setup lang="ts"> |
|
|
|
import JsonWorker from 'monaco-editor/esm/vs/language/json/json.worker?worker' |
|
|
|
import EditorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker&inline' |
|
|
|
import EditorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker' |
|
|
|
import JsonWorker from 'monaco-editor/esm/vs/language/json/json.worker?worker&inline' |
|
|
|
import TypescriptWorker from 'monaco-editor/esm/vs/language/typescript/ts.worker?worker' |
|
|
|
|
|
|
|
import type { editor as MonacoEditor } from 'monaco-editor' |
|
|
|
import type { editor as MonacoEditor } from 'monaco-editor' |
|
|
|
import { deepCompare, isDrawerOrModalExist, onMounted, ref, watch } 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> |
|
|
@ -45,15 +45,17 @@ 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) { |
|
|
|
async getWorker(_: any, label: string) { |
|
|
|
switch (label) { |
|
|
|
switch (label) { |
|
|
|
case 'json': |
|
|
|
case 'json': { |
|
|
|
return new JsonWorker() |
|
|
|
const workerBlob = new Blob([JsonWorker], { type: 'text/javascript' }) |
|
|
|
case 'typescript': |
|
|
|
return await initWorker(URL.createObjectURL(workerBlob)) |
|
|
|
return new TypescriptWorker() |
|
|
|
} |
|
|
|
default: |
|
|
|
default: { |
|
|
|
return new EditorWorker() |
|
|
|
const workerBlob = new Blob([EditorWorker], { type: 'text/javascript' }) |
|
|
|
|
|
|
|
return await initWorker(URL.createObjectURL(workerBlob)) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
} |
|
|
|
} |
|
|
|