Skip to content

feat(repl): getEditorInstance, getMonacoEditor (expose)#364

Merged
edison1105 merged 3 commits intovuejs:mainfrom
wangcch:feat-expose-editor-instance
Apr 13, 2026
Merged

feat(repl): getEditorInstance, getMonacoEditor (expose)#364
edison1105 merged 3 commits intovuejs:mainfrom
wangcch:feat-expose-editor-instance

Conversation

@wangcch
Copy link
Copy Markdown
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>>()

@vercel
Copy link
Copy Markdown

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.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Sep 12, 2025

Open in StackBlitz

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

commit: 8195871

@oodavid oodavid mentioned this pull request Feb 27, 2026
@edison1105 edison1105 merged commit 7ac4b95 into vuejs:main Apr 13, 2026
2 of 3 checks passed
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

2 participants