Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/sxzz/bundler-explorer. 🚧 WIP: A web tool to explore and compare different JavaScript bundlers. bundler.sxzz.dev
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879<script lang="ts" setup>import * as monaco from 'monaco-editor'
const modelValue = defineModel<string>({ default: '' })const props = withDefaults( defineProps<{ language?: string options?: monaco.editor.IStandaloneEditorConstructionOptions model?: monaco.editor.ITextModel readonly?: boolean }>(), { language: () => 'plaintext', options: () => ({}), },)
const isLoading = ref(true)const editorRef = shallowRef<monaco.editor.IStandaloneCodeEditor>()const editorElement = useTemplateRef<HTMLDivElement>('editorElement')
let editor: monaco.editor.IStandaloneCodeEditor
const options = computed(() => ({ ...getSharedMonacoOptions(), fontSize: 13, fontLigatures: true, readOnly: props.readonly, ...props.options,}))watch(options, () => editor?.updateOptions(options.value))
watch(modelValue, () => { if (model.value.getValue() !== modelValue.value) { model.value.setValue(modelValue.value) }})
const model = computedWithControl( () => [props.model, props.language], () => { return ( props.model || markRaw(monaco.editor.createModel(modelValue.value, props.language)) ) },)watch(model, () => { editor?.setModel(model.value) modelValue.value = model.value.getValue()})
watch(editorElement, (newValue, oldValue) => { if (!newValue || oldValue) return
editor = monaco.editor.create(newValue, options.value) editorRef.value = editor editor.layout() editor.setModel(model.value) editor.onDidChangeModelContent(() => { modelValue.value = editor.getValue() }) isLoading.value = false})
defineExpose({ /** * Monaco editor instance */ $editor: editorRef,})</script>
<template> <div ref="editorElement"> <Loading v-if="isLoading" /> </div></template>