QUESTION: How to control the height of the editor dynamically to avoid clunky scrolling
Question
I've noticed if in the initialise function I set a height it will set based on a specific pixel amount e.g. height: "500px". However if you try to set with a percentage e.g. height: "90%" the editor has no height at all.
Also I'm wondering what is setting the height if nothing is set because it appears to be automatically calculating a pixel amount that consumes the entire page (e.g. 100%).
I actually have the editor wrapped inside a standard page template we have in the back-end of our CMS, and this page template actually has more content in side menu bars which forces the page to become a scrollable page (i.e. the content from the page template always goes below the fold of the screen). This makes the editor function really poorly, because if you want to scroll beneath the editor you have to move the cursor outside of the editor and scroll, and it leads to poor user experience.
I also have a "save" button which submits to a form and this is not part of the editor, so in order to get to the save button you have to again move the cursor out of the editor area and scroll - it's not ideal.
I have considered dropping my page template on the editor and allowing it to go almost full screen if you like, but I still have the issue of the save button needing to be directly below the editor. What is my best option here? I had thought if I dynamically set the height of the editor to say 80-90% that would leave room beneath it but it doesn't work.
Any insight would be greatly appreciated as I have been wrapping my brain on this one for days.
Answers (3)
try to work with vh instead of px.
eg: give the editor height: '80vh', your navbar height: '20vh'. This way, the vertical scroll will never be shown or needed as long as the sum of all elements's vh ≤ 100
Hope this helps.
try to work with
vhinstead ofpx.eg: give the editor
height: '80vh', your navbarheight: '20vh'. This way, the vertical scroll will never be shown or needed as long as the sum of all elements'svh≤ 100Hope this helps.
thanks this is useful!
This is more a layout issue and not related to the GrapesJS editor itself.
Related Questions and Answers
Continue research with similar issue discussions.
Issue #2839
[Question] I added one component named template in the blocks but when i try to drag another components inside this template component ,it will be dragged but after saving it removes all the components inside it. How to avoid this?
This is code of template component: I debugged it, so i got that : setComponents method in the dom_components clearing it ...but not gettin...
Issue #865
[QUESTION] How can I set default tagName
Hi ! I want to set tagName tr for all components(or specific component in use). Is there any predefined function to set tagName ?
Issue #3239
[Question] How to update attribute/properties dynamically from Component Script?
We have a use case where we want to insert charts dynamically using Highcharts Editor. I have created a component, which on drag and drop,...
Issue #1720
[QUESTION] How to add the button in custom traits
Hi, I try to add a button to my custom traits for my custom blocks but its not working fine as expected and also need to know how to call t...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.