-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Implement editor size config #636
Comments
My idea about this:
I think that all the reasonable cases could be covered by the above. |
@fredck I was going to write more on this but for the editor setting Then editing area grows with outer container - still I'm searching if it is the right way.
I guess that this is just to add an option for developers. I'd add the Also changing dynamically |
Ugh.. I've mischeck how height behave. Obviously I was wrong as the editable area has parent's height and thus overlaps parent by the height of the toolbar. I think that to be consistent it would make more sense to make editable view of desired height rather then whole editor. WDYT? |
AFAIR in CKEditor 4 the height of the editor includes both the toolbar and the bottom space (with element path). I'm pretty sure this is what users actually need because otherwise, setting the height of the editable is pretty easy with CSS. Setting the height of the editor isn't because both the UI and the editable must be taken into consideration and the geometry of the UI changes e.g. as the webpage is resized. In other words, the height of the editable must be adjusted so the entire editor (with toolbars etc.) is of desired height. OTOH... I'm not sure config is the right way to do this. It will require a lot of effort from us to maintain it because it must be viewport–resize–proof etc. I think this is the job for Check out the fiddle I created that shows how easy it is to set up a fixed–height editor with flex. |
And this indeed may be something to check with IE11, because later on, it could be troublesome to bring it there, if we'll ever want it. |
As I understand this adding flex sizing to editor would not require If so adding such option to editor would add bloat to API and I'd stick to CSS-only approach (with good docs for that ;) ). |
@oleq I've also checked that and it looks like it works :) |
CSS only approach will not work because devs will not be able to predict the class names in all cases. A config option is necessary. |
Can you provide an example where CSS only approach falls short? |
@fredck I meant that with CSS only approach you have to style main editor |
Also I've pushed sample solution for this case on https://github.com/ckeditor/ckeditor5/tree/t/636. But changes are simple: |
Suppose that the application has several different editors inside different forms. If you want to have different heights for each of them, you would have to enclose the editor in a "known" div, just for that purpose. But let's say that the above is doable... what is even more complicated is when you have systems that let you create and configure specific fields on forms, like Drupal, through and administration panel. Here, the editors are created and configured programmatically and CSS has no idea about them. I love the CSS only approach and I think we could even go with it only for now. It makes a lot of sense. But then we'll wait for people to scream so we'll introduce this configuration... and I'm sure people will scream. So maybe better to anticipate the trouble. |
@jodator: So what you did in your recent changes is a hybrid approach? To use flex to manage the layout of the editor and the config to simply pass the In other words: flex does the magic and we don't have to worry about UI and viewport resizing, toolbar heights and any sort of math here? |
In case of CKEditor 4 you set the height of the editing area via And it makes sense. For me the use case for setting height is that I have some idea what kind of content users will be entering (e.g. short comments, contact form), I know what font size I use so I want the user/customer to enter e.g. 4 lines of text (comments) or 8 lines (contact form) before the scrollbar is shown (indicating this way to the user that he's writing too much :P). At the same time, I have no idea how the toolbar will render, will it span into two or three rows etc.
Nope. It's not easy, because you have to apply a style using class of some nested div element, |
I disagree. CSS classes are public API of the editor. They should not change in patches (1.0.x) and developers can totally depend on them. Setting height of editable boils down to
So the question "what should be resized: editor or editable?" is back again. Because there's this case:
and they clearly contradict each other. TBH, I'd go with editor height resize using the config because it's tricky and leave editable resizing to CSS because it's reliable and straightforward as I pointed out. |
I think that this is just one of the use cases. It is definitely expected as an additional use case that the designer would like to set the precise height of the editor as a whole, to fit it into a specific ui (for example a limited size dialog box). Btw, we did that in that way in CKEditor 4 just because it was the easiest option. At first we wanted to set it as the whole UI height but it was way too difficult to do it because we didn't have things like the CSS flex to help us. We ended up with the "good enough" option ;) |
Don't get me wrong: I'm fine with any solution you develop here, but I had to show you a different POV. If you implement setting height via config that sets the whole height of the editor and leave the possibility of defining manually the CSS for |
@oleq Yes in those commit I have hybrid approach. You can either set styles with external stylesheet like: .ck-editor {
width: 700px;
height: 500px;
}
@media (max-width: 1200px) {
.ck-editor {
width: 450px;
height: 200px;
}
} or pass config to editor instance: ClassicEditor
.create( document.querySelector( '#editor' ), {
plugins: [ Enter, Typing, Paragraph, Undo, Heading, Bold, Italic ],
toolbar: [ 'headings', 'bold', 'italic', 'undo', 'redo' ],
config: {
ui: {
width: '500px',
height: '300px'
}
}
} ) or change it dynamically: editor.ui.view.width = '1000px'; Now out-of-the-box viewport resizing adapting is best done with CSS IMHO since the programmatic way of setting I think that safer is to use CSS properly and check how editor components will work with flex. Current issues that I see with CSS-only approach are:
|
The toolbar part of the editor has flex growing disabled so the rest (editable) will adapt to its height.
Can you show the issue in the fiddle (maybe clone this one)? |
@oleq: here you go: https://jsfiddle.net/jodator/zbzok303/. The problem is when you have less text then minimum to fill either |
@jodator It boils down to |
Cool to see this working. No are we going with hybrid approach (to enable Drupal case) or CSS-only? Or we should delay this issue with more investigation on flex? |
I just noticed that it's broken in IE11 because of this bug. I wonder if we can get away with that if we say that min-height does not work properly in this browser. @wwalc?
Let's go with the hybrid (config for editor height, CSS for editable height) but we should wait for the research before merging. |
It is broken when the |
I'm not able to read through all the discussions, but I'd like to leave a comment anyway. If you want to add support for setting the size through a configuration option, please be really sure that we need it. Why?
I can see that doing this research we realised that using flex helps and will be good for the overall styling abilities and we should do that change. We should also document how to change the size of the editor. But we should be super careful when adding new config options as this has several important implications for the future. |
We are not asked about this and @wwalc's answer on SO does great: https://stackoverflow.com/questions/46559354/how-to-set-the-height-of-ckeditor-5-classic-editor So I don't think that we need to change anything. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
editor.ui.view.editable.editableElement.style.height = '300px'; |
Am I the only person who thinks this is a terribly complex way to set what was previously a very simple config option? Surely there is a more common sense way to make a height option available. |
The
|
I'm thinking more about the React syntax. With components like those in Material-UI, you can pass props down to key DOM elements. For example, the TextField component takes an It would be cool if the React component took an |
@halfnibble No you are not the only one who thinks that setting the editor height here is a little ridiculous. Calling an implementation detail as part of the public api is a little nonsensical. |
Am I right in assuming that there is no |
This comment was marked as off-topic.
This comment was marked as off-topic.
What do you think about this solution? ((React Example)) We can get current editor height like this:
CKEditor loses height style set by resize on blur/focus, so we must set it explicitly:
|
For those who've been looking for a solution to dynamically adjust the height of CKEditor 5 and add resize capabilities, I'm excited to share a new plugin I've developed: https://github.com/pikulinpw/ckeditor5-resizableheight Key Features:
It's now available on npm and easy to integrate with your existing CKEditor setup. Check out the README for installation and usage instructions. Feedback, bug reports, and contributions are welcome. Let's make our CKEditor experience even better! |
This feature is becoming more and more popular and already has some SO answer. So I'd like to bootstrap talks about this.
This issue is rather self explanatory but it would be nice to gather requirements or any known gotchas.
Probably the only current build that it makes sense is Classic Editor.
The minimal approach is to set
width
and/orheight
of the editor.As for the behavior - current Classic editor will grow with content so how
height
setting should play with this? As minimal height or should it disable auto grow?The other requested things (that was available in CKEditor 4) were to make height of the editor comparable to replaced
textarea
size settings (in my opinion we should skip it for now) and make editor resizeable (I think this is also separate issue).The text was updated successfully, but these errors were encountered: