-
-
Notifications
You must be signed in to change notification settings - Fork 269
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to make editor autoresizable #82
Comments
I see, thanks for your answer, i'll check what wrong with my code that the editor doesn't autoresize to fit code height |
@saulpalv please let me know if you'll find something that we can close the issue. Thank you! |
@KalebMatthews thank you for your response, it makes sense now, i'll close the issue as found no solution on monaco, i changed to codemirror wich provides this feature out of the box |
@saulpalv Can we keep this open for a chance that it might be resolved in this repo? |
@saulpalv @KalebMatthews guys it is completely autosizeble. Please, create a reproducible snippet, so I can understand your particular case. For example, check here; move splitter to see how it's autosizeble. Plus, we already support |
@suren-atoyan hello suren, in your provided example the editor does indeed auto resize, but only the code view, not the monaco container, in other words it's resizing internally/virtually, that's why it has a vertical slider, i seek for autoresize for both the code view and the editor container so all the code is visible and without the slider, this behaviour option is built-in (or default) in editors like codemirror editor -> example and ace editor ->xample, try to add new lines on those examples, you'll get what i mean. Maybe monaco does not have an built in option to enable this behaviour, the container will retain it's fixed size once provided as @KalebMatthews commented . |
@KalebMatthews, @saulpalv now I understand what you meant and also found the problem. Now, I suggest keeping it open until the Thank you for your support guys. |
@suren-atoyan i get the idea with your example and yes it's broken on monaco shure a solution will come in 0.21.0 |
okay, we are on the same line. So, let's leave it open for a while, at least until the 0.21.0 version arrives, after that, I'll update the package and we will see what we have. |
There is a way to do this, This solution comes from an issue in monaco microsoft/monaco-editor#794. |
I tried to update the package to use monaco-editor 0.21.2 and the issue still persists |
https://codesandbox.io/s/monaco-editor-react-forked-im1gc Working at |
Sorry probably this is unrelated, but since it is "hardcoded" to true, can we override it to false and use a custom resize detector (microsoft/monaco-editor#28 (comment))? Ref: microsoft/monaco-editor#28 (comment). |
I was able to get it to work on "DiffEditor" like so: diffEditor.onDidUpdateDiff(() => {
const originalHeight = originalEditor.getContentHeight();
const modifiedHeight = modifiedEditor.getContentHeight();
setHeight(
Math.max(Math.min(600, Math.max(originalHeight, modifiedHeight)), 200)
);
diffEditor.layout();
}); This has a min-height of 200 and a max height of 600. You can play with the values of min/max if you'd like accordingly. |
In the new version, <DiffEditor language="json" options={{ automaticLayout: true }} /> |
@Dreamacro |
The I am using the latest version of the monacoEditor. It seems like I might have to create a resize hook for this, but of course it'd be preferable for the monaco editor can handle its sizing itself. Some notes: The component will grow and shrink vertically perfectly fine. It will also grow horizontally as expected. The Please let me know if there is anything I'm doing wrong here! :) |
@Jaryt were you ever able to solve this problem? I think I'm running into this problem as well. |
You are my life saver. |
In the
IEditorConstructionOptions
has a property calledautomaticLayout
, that enables autoresizeas 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?
The text was updated successfully, but these errors were encountered: