Skip to content

Commit

Permalink
feat(monaco-editor): add language and options watchers for dynamic up…
Browse files Browse the repository at this point in the history
…dates
  • Loading branch information
Red-Asuka committed Dec 27, 2024
1 parent 7386dbf commit 86b5dc3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
1 change: 0 additions & 1 deletion apps/web/auto-imports.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ declare module 'vue' {
interface GlobalComponents {}
interface ComponentCustomProperties {
readonly EffectScope: UnwrapRef<typeof import('vue')['EffectScope']>
readonly ElMessage: UnwrapRef<typeof import('element-plus/es')['ElMessage']>
readonly acceptHMRUpdate: UnwrapRef<typeof import('pinia')['acceptHMRUpdate']>
readonly computed: UnwrapRef<typeof import('vue')['computed']>
readonly createApp: UnwrapRef<typeof import('vue')['createApp']>
Expand Down
1 change: 0 additions & 1 deletion packages/ui/auto-imports.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ declare module 'vue' {
interface GlobalComponents {}
interface ComponentCustomProperties {
readonly EffectScope: UnwrapRef<typeof import('vue')['EffectScope']>
readonly ElMessage: UnwrapRef<typeof import('element-plus/es')['ElMessage']>
readonly acceptHMRUpdate: UnwrapRef<typeof import('pinia')['acceptHMRUpdate']>
readonly computed: UnwrapRef<typeof import('vue')['computed']>
readonly createApp: UnwrapRef<typeof import('vue')['createApp']>
Expand Down
10 changes: 10 additions & 0 deletions packages/ui/src/components/MonacoEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,16 @@ watch(value, (newValue) => {
}
})
watch(language, (newLanguage) => {
if (editor?.getModel()) {
monaco.editor.setModelLanguage(editor.getModel()!, newLanguage)
}
})
watch(options, (newOptions) => {
editor?.updateOptions(newOptions)
}, { deep: true })
defineDefaultTheme()
defineLogLanguage()
Expand Down

0 comments on commit 86b5dc3

Please sign in to comment.