Skip to content

Conversation

wangcch
Copy link
Collaborator

@wangcch wangcch commented Sep 12, 2025

close #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>>()

Copy link

vercel bot commented Sep 12, 2025

@wangcch is attempting to deploy a commit to the vuejs Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

pkg-pr-new bot commented Sep 12, 2025

Open in StackBlitz

npm i https://pkg.pr.new/@vue/repl@364

commit: b47a95f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request] Expose Monacoeditor instance for theming options
1 participant