From 00176d007ff5eb74e216abff3de87e625cde543b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=92=B2=E6=99=BA=E5=AD=90=20Kevin=20Deng?= Date: Tue, 27 Aug 2024 16:31:16 +0800 Subject: [PATCH] feat: expose `editorOptions.monacoOptions` closes #277, closes #232 --- src/Repl.vue | 2 ++ src/monaco/Monaco.vue | 8 +++++++- test/main.ts | 5 +++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Repl.vue b/src/Repl.vue index a75773be..9b05795a 100644 --- a/src/Repl.vue +++ b/src/Repl.vue @@ -9,6 +9,7 @@ import { injectKeyProps, } from './types' import EditorContainer from './editor/EditorContainer.vue' +import type * as monaco from 'monaco-editor-core' export interface Props { theme?: 'dark' | 'light' @@ -37,6 +38,7 @@ export interface Props { } editorOptions?: { showErrorText?: string + monacoOptions?: monaco.editor.IStandaloneEditorConstructionOptions } } diff --git a/src/monaco/Monaco.vue b/src/monaco/Monaco.vue index 608d5bd6..797081aa 100644 --- a/src/monaco/Monaco.vue +++ b/src/monaco/Monaco.vue @@ -35,7 +35,12 @@ const emit = defineEmits<{ const containerRef = ref() const ready = ref(false) const editor = shallowRef() -const { store, autoSave, theme: replTheme } = inject(injectKeyProps)! +const { + store, + autoSave, + theme: replTheme, + editorOptions, +} = inject(injectKeyProps)! initMonaco(store.value) @@ -67,6 +72,7 @@ onMounted(async () => { enabled: false, }, fixedOverflowWidgets: true, + ...editorOptions.value.monacoOptions, }) editor.value = editorInstance diff --git a/test/main.ts b/test/main.ts index b10b6f23..79a7beb8 100644 --- a/test/main.ts +++ b/test/main.ts @@ -67,6 +67,11 @@ const App = { }, // showCompileOutput: false, // showImportMap: false + editorOptions: { + monacoOptions: { + // wordWrap: 'on', + }, + }, }) }, }