repl
repl copied to clipboard
feat(repl): `getEditorInstance`, `getMonacoEditor` (expose)
close https://github.com/vuejs/repl/issues/335
Repl methods
getEditorInstance: get monaco/codemirror editor instance
getMonacoEditor: get editor from monaco-editor-core
export interface EditorMethods {
getEditorIns<T extends 'monaco' | 'codemirror' = 'monaco'>():
| (T extends 'codemirror'
? CodeMirror.Editor
: monaco.editor.IStandaloneCodeEditor)
| undefined
getMonacoEditor?(): typeof monaco.editor | undefined
}
usage
onMounted(() => {
const editor = repl.value?.getEditorInstance<'monaco'>()
const monacoEditor = repl.value?.getMonacoEditor()
monacoEditor?.defineTheme('my-dark', {
base: 'vs-dark',
inherit: true,
rules: [],
colors: {
'editor.background': '#ff0000',
},
})
editor?.updateOptions({
theme: 'my-dark',
})
})
<script setup lang="ts">
const repl = useTemplateRef('repl')
</script>
<template>
<Repl ref="repl" />
</template>
const repl = ref<InstanceType<typeof Repl>>()
@wangcch is attempting to deploy a commit to the vuejs Team on Vercel.
A member of the Team first needs to authorize it.