e-chan1007 / nuxt-monaco-editor

Integrate monaco-editor with Nuxt
https://e-chan1007.github.io/nuxt-monaco-editor
MIT License
119 stars 15 forks source link

Monaco Editor mounting issue #44

Closed XStarlink closed 11 months ago

XStarlink commented 11 months ago

Hello, thank you for this module!

I'm trying to use the editor but I have a problem, when the page loads the first time, the editor loads badly, it looks like there's an mounting problem in the dom.

But after making any modification in the code, the nuxt HMR reloads the view and now the editor appears.

I've made a reproduction here: https://stackblitz.com/edit/node-nxxysk?file=nuxt.config.ts,app.vue,components%2FAppTopbar.vue,components%2FAppSidebar.vue

Here's a screenshot of the problem

Capture d’écran 2023-12-07 à 12 26 04

After any code modification, the editor loads

Capture d’écran 2023-12-07 à 12 23 28
e-chan1007 commented 11 months ago

Adding automaticLayout: true should fix this.

  <MonacoEditor
      ref="monacoEditor"
      v-model="editor"
      lang="typescript"
      :options="{
        theme: 'vs-dark',
+       automaticLayout: true,
        lineNumbers: 'on',
        roundedSelection: true,
        scrollBeyondLastLine: false,
        readOnly: false,
      }"
      :style="{
        height: '100%',
        width: '100%',
      }"
   />
XStarlink commented 11 months ago

Adding automaticLayout: true should fix this.

  <MonacoEditor
      ref="monacoEditor"
      v-model="editor"
      lang="typescript"
      :options="{
        theme: 'vs-dark',
+       automaticLayout: true,
        lineNumbers: 'on',
        roundedSelection: true,
        scrollBeyondLastLine: false,
        readOnly: false,
      }"
      :style="{
        height: '100%',
        width: '100%',
      }"
   />

Thanks a lot for your answer, it works!

Maybe we can put it somewhere in the documentation, for future users who encounter the same problem?