Skip to content

Commit

Permalink
Merge branch 'main' into feat/add-embed-mode
Browse files Browse the repository at this point in the history
  • Loading branch information
lecepin committed Aug 30, 2024
2 parents f08956e + f9f650a commit 91c9bc2
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/Repl.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -37,6 +38,7 @@ export interface Props {
}
editorOptions?: {
showErrorText?: string
monacoOptions?: monaco.editor.IStandaloneEditorConstructionOptions
}
splitPaneOptions?: {
CodeTogglerButtonText?: string
Expand Down
8 changes: 7 additions & 1 deletion src/monaco/Monaco.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ const emit = defineEmits<{
const containerRef = ref<HTMLDivElement>()
const ready = ref(false)
const editor = shallowRef<monaco.editor.IStandaloneCodeEditor>()
const { store, autoSave, theme: replTheme } = inject(injectKeyProps)!
const {
store,
autoSave,
theme: replTheme,
editorOptions,
} = inject(injectKeyProps)!
initMonaco(store.value)
Expand Down Expand Up @@ -67,6 +72,7 @@ onMounted(async () => {
enabled: false,
},
fixedOverflowWidgets: true,
...editorOptions.value.monacoOptions,
})
editor.value = editorInstance
Expand Down
8 changes: 7 additions & 1 deletion src/monaco/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type { CreateData } from './vue.worker'
import vueWorker from './vue.worker?worker'
import * as languageConfigs from './language-configs'
import type { LanguageService } from '@vue/language-service'
import { debounce } from '../utils'

let initted = false
export function initMonaco(store: Store) {
Expand Down Expand Up @@ -155,7 +156,12 @@ export function loadMonacoEnv(store: Store) {
languages.setLanguageConfiguration('typescript', languageConfigs.ts)
languages.setLanguageConfiguration('css', languageConfigs.css)

store.reloadLanguageTools = () => reloadLanguageTools(store)
let languageToolsPromise: Promise<void> | undefined
store.reloadLanguageTools = debounce(async () => {
;(languageToolsPromise ||= reloadLanguageTools(store)).finally(() => {
languageToolsPromise = undefined
})
}, 250)
languages.onLanguage('vue', () => store.reloadLanguageTools!())

// Support for go to definition
Expand Down
5 changes: 5 additions & 0 deletions test/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ const App = {
// OutputTogglerButtonText: '输出 >',
// },
// isEmbedMode: true,
editorOptions: {
monacoOptions: {
// wordWrap: 'on',
},
},
})
},
}
Expand Down

0 comments on commit 91c9bc2

Please sign in to comment.