imguolao / monaco-vue

Use monaco-editor loaded from CDN in Vue 2&3, no need to bundling.
https://imguolao.github.io/monaco-vue/
MIT License
234 stars 21 forks source link

Modify monaco before loader.config({ monaco }) #32

Closed Zehir closed 1 year ago

Zehir commented 1 year ago

Hello,

I am trying to enable SchemaRequest of the JSON language and tried this :

import { install as VueMonacoEditorPlugin, loader } from '@guolao/vue-monaco-editor'
import * as monaco from 'monaco-editor'

import { type UserModule } from '~/types'

// Setup Monaco Editor
// https://www.npmjs.com/package/@guolao/vue-monaco-editor
export const install: UserModule = ({ app }) => {
  monaco.languages.json.jsonDefaults.setDiagnosticsOptions({
    ...monaco.languages.json.jsonDefaults.diagnosticsOptions,
    allowComments: true,
    enableSchemaRequest: true,
  })

  loader.config({ monaco })

  app.use(VueMonacoEditorPlugin, {})
}

But this don't seems to work, what is the correct way to do it ?

Thanks

Zehir commented 1 year ago

Nevermind I found by reading the loader code;

There is how to do it

export const install: UserModule = ({ app }) => {
  monaco.languages.json.jsonDefaults.setDiagnosticsOptions({
    ...monaco.languages.json.jsonDefaults.diagnosticsOptions,
    enableSchemaRequest: true,
  })

  loader.config({ monaco })
  loader.init()

  app.use(VueMonacoEditorPlugin, {})
}