question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Instancing Monaco Editor is just 5 by 5 Pixels even with `automaticLayout: true` [Workaround] [Closed]

See original GitHub issue
  1. Try to reproduce in VS Code and file issue directly at: Impossible

  2. Otherwise, provide steps that reproduce the problem in VS Code web at:

  • Install Monaco Editor npm install monaco-editor
  • Install Monaco Editor WebPack Plugin npm install monaco-editor-webpack-plugin
  • Add to webpack.mix.js
const mix = require('laravel-mix');
const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin')
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
 
/*
 |--------------------------------------------------------------------------
 | Mix Asset Management
 |--------------------------------------------------------------------------
 |
 | Mix provides a clean, fluent API for defining some Webpack build steps
 | for your Laravel application. By default, we are compiling the Sass
 | file for the application as well as bundling up all the JS files.
 |
 */

mix.js('resources/js/app.js', 'public/js')
   .sass('resources/sass/app.scss', 'public/css')
   .webpackConfig(webpack => {
        return {
            plugins: [
                new MonacoWebpackPlugin({
                    // available options are documented at https://github.com/Microsoft/monaco-editor-webpack-plugin#options
                    languages: ['javascript', 'python'],
                    // Features doesn't work ( https://github.com/microsoft/monaco-editor-webpack-plugin/issues/109 )
                    features: [
                        'accessibilityHelp', 'bracketMatching', 'caretOperations', 'clipboard', 'codeAction',
                        'codelens', 'colorDetector', 'comment', 'contextmenu', 'coreCommands','cursorUndo',
                        'dnd', 'find', 'folding', 'fontZoom', 'format', 'gotoError', 'gotoLine', 'gotoSymbol',
                        'hover', 'iPadShowKeyboard', 'inPlaceReplace', 'inspectTokens', 'linesOperations',
                        'links', 'multicursor', 'parameterHints', 'quickCommand', 'quickOutline', 'referenceSearch',
                        'rename', 'smartSelect', 'snippets', 'suggest', 'toggleHighContrast', 'toggleTabFocusMode',
                        'transpose', 'wordHighlighter', 'wordOperations', 'wordPartOperations']
                }),
                // new BundleAnalyzerPlugin()
            ]
        };
    });
  • Add to Editor.vue
<template>
    <div id="monaco-editor-container"></div>
</template>

<script>
    import * as monaco from 'monaco-editor';

    export default {
        mounted() {
            monaco.editor.create(document.getElementById("monaco-editor-container"), {
                value: "function hello() {\n\talert('Hello world!');\n}",
                language: "python",
                automaticLayout: true
            });
        }
    }

</script>

<style>

</style>
  • Register Component:
...
Vue.component('vue-monaco-editor',                  require('./components/Monaco/Editor.vue').default);
...
  • Use Component:
<vue-monaco-editor></vue-monaco-editor>

image

  1. Otherwise, provide steps that reproduce the problem at the Monaco Editor homepage None

  2. Otherwise, provide a Playground code snippet None

  3. Otherwise, provide a self-contained git repository / HTML page None

monaco-editor version: npm -v monaco-editor 6.13.4 Browser: Chrome OS: Winows 10 Playground code that reproduces the issue: None

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
dschillercommented, Apr 11, 2020

Thanks David. I tried that but in fact that the Editor is inside a tab-pane from Bootstrap that doesn’t work. Also the automaticLayout: true Option doesn’t work and is expensive in general. I could remove my Workaround and fix it by using a ResizeObserver:

image

0reactions
luminaxstercommented, Apr 11, 2020

Starting release 0.21, Monaco will do exactly that =), or fallback to polling if not supported.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Monaco Editor
The Monaco Editor is the code editor that powers VS Code. A good page describing the code editor's features is here. It is...
Read more >
Monaco Editor force resize editor - Stack Overflow
I enlarge first and then reduce the height by making the developer console larger/smaller. ... I would expect that with automaticLayout: true you ......
Read more >
February 2020 (version 1.43) - Visual Studio Code
By default, Go to Definition via mouse opens a separate editor but with the new setting editor.definitionLinkOpensInPeek as true , the gesture will...
Read more >
Building a code editor with Monaco - Expo Blog
I work on Snack, an online code editor for React Native apps. In the past, Snack's code editor used Ace Editor, but we've...
Read more >
Graphik font github - Caritas Castellaneta
5. woff 2 Source: fonts[1]. 3. Influenced by other popular geometric, minimalist sans-serif typefaces of the new millennium. It is much faster and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found