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.

How to make editor autoresizable

See original GitHub issue

In the IEditorConstructionOptions has a property called automaticLayout, that enables autoresize image as commented here https://stackoverflow.com/questions/49923334/how-to-make-monaco-editor-auto-fit-content-like-codemirror-auto-resize-mode

how can i pass this boolean property in react component? and will this override the default sizes passed in the monaco-react component?

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:19 (7 by maintainers)

github_iconTop GitHub Comments

7reactions
MatthewCaserescommented, Nov 14, 2020

There is a way to do this, This solution comes from an issue in monaco https://github.com/microsoft/monaco-editor/issues/794. https://codesandbox.io/s/empty-dust-h6z4y?file=/src/App.js

2reactions
KalebMatthewscommented, Jun 26, 2020

The editor will not resize after its initialization because the child elements are setting a static width based on the init.

Component:

<ControlledEditor
            width={"100%"}
            height={height}
            language={language}
            theme="dark"
            value={code}
            options={{
                automaticLayout: true,
            }}
            onChange={onChange}
        />

Rendered Html of monaco-react parent sections: Screen Shot 2020-06-26 at 1 32 44 PM

Cut off monaco editor display: Screen Shot 2020-06-26 at 1 34 36 PM

Please let me know if more information is needed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Monaco editor dynamically resizable - Stack Overflow
Monaco has a built-in auto resize to parent container functionality: createEditorWithAutoResize(){ this.editor = monaco.editor.create( this.
Read more >
Resizing Customization - CKEditor 4 Documentation
To achieve this, use the editor.resize() method to define the dimensions of the editor interface, assigning the window a width and height value...
Read more >
Autoresize plugin | Docs - TinyMCE
Automatically resize TinyMCE to fit content. ... This plugin automatically resizes the editor to the content inside it. It is typically used to...
Read more >
Is there a better way of auto resizing the grid pop up editor?
4) On the auto resize re-center the popup editor. I guess what I am trying to do is make this as "responsive" as...
Read more >
Autoresize Demo - CodeMirror
By setting an editor's height style to auto and giving the viewportMargin a value of Infinity , CodeMirror can be made to automatically...
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