animaux / simplemde

Add SimpleMDE to markdown enabled fields.
MIT License
4 stars 4 forks source link

Make height of editor adjustable #1

Closed twiro closed 8 years ago

twiro commented 8 years ago

The editor currently always has the same default height, no matter what the value of Number of default rows in the text field's settings is. Would be great if the height could adapt to that setting.

animaux commented 8 years ago

Hmn, Editor for Symphony did ignore that as well. We’re able to add a minimum height via CSS before it grows. I guess that could be translated. Will have a look.

animaux commented 8 years ago

I’d rather ignore the field settings and start from a basic smaller height of about 1–3 lines. Since we’re growing with each row this seems more logical for me than to have an however large empty field from the start.

animaux commented 8 years ago

Initial height is now 1 line. I consider this fixed :)

twiro commented 8 years ago

I’d rather ignore the field settings and start from a basic smaller height of about 1–3 lines. Since we’re growing with each row this seems more logical for me than to have an however large empty field from the start.

Having the ability to define a minimum height via settings allows for a cleaner publish layout. Think of two textareas next to each other - looks way better with the same height. I actually use that a lot to structure my publish-area and try to give text-fields a height that won't be extended by its content (which only works for text-areas with somehow restricted amounts of text, but in my experience there are lots of them).

So I don't think it would be a good move to simply ignore the "rows"-settings. If you want a textbox that starts narrow you could simply choose "1" (or even "0") as value in the settings, but I wouldn't force that behavior - it's just taking away a useful opportunity in my eyes.

twiro commented 8 years ago

What about a tiny script that grabs the rows-attribute from the textfield, calculates a em/rem-based min-height for the editor and injects that in the markup?

animaux commented 8 years ago

Ok, fair enough. But this would have to be an option to choose between a fixed height with scroll-bar or a minimum height.

animaux commented 8 years ago

I’m open to pull requests :·D

twiro commented 8 years ago

But this would have to be an option to choose between a fixed height with scroll-bar or a minimum height.

That would even be better.

I’m open to pull requests :·D

I will give it a try... but that might take some days ;)

animaux commented 8 years ago

No hurries :)

animaux commented 8 years ago

For reference —> https://github.com/NextStepWebs/simplemde-markdown-editor/#height

twiro commented 8 years ago

For reference —> https://github.com/NextStepWebs/simplemde-markdown-editor/#height

Thank you!

What do you think about the following behavior:

That way we could use the existing settings for the field height to achieve both behaviors. Which on one hand makes sense and on the other might be the most easy and pragmatic solution to implement.

No hurries :)

...will fork and try as soon as I find the time...

animaux commented 8 years ago

Hmn, that would mean I’d have to set all my text-fields to 0 to get the behaviour I want, grrr :)

However making use of the already existing field setting makes sense.

twiro commented 8 years ago

Here you go: https://github.com/twiro/simplemde/tree/row-based-editor-height

Looked easy at first glance, but as the dynamic adjustments caused some ugly glitches whilte loading the page I had to rewrite the whole editor initialization. But it's working now and looking good in Firefox, Safari and Chrome...

Besides simply adjusting the height to the row-settings I also tried to keep smaller textareas (up to 10 rows) "in rhythm" with the vertical grid of the symphony backend. And while adjusting paddings and margins I also changed the styling a little bit to make it more in line with the symphony backend. If you're not ok with some of these adjustments I can surely revert them ;)

Have a look and let me know If I should send a PR or if we need to change something!

simplemde-row-based-editor-height

animaux commented 8 years ago

Nice! Will test it on monday and get back to you. Thanks.

animaux commented 8 years ago

Looks great to me. Thanks for fixing the repo name too :) Please send a PR!

twiro commented 8 years ago

Looks great to me.

Great - glad you like it :) I added another small tweak for active elements in the toolbar, but otherwise will submit it the way it was.

Thanks for fixing the repo name too :)

My pleasure!

Please send a PR!

Do you wanna set up an integration-branch for that? So my PR doesn't automatically become the official master version and we can improve some other details (will post separate issues for them) before releasing a new version?

Regarding releases - I noticed you didn't use any release-tags for this extension yet. They're a great feature as they not only make older versions of the extension accessible on github, but also are used for directly linking the version-numbers in the compatibility-table on symphonyextensions.com to the corresponding release on github. Would be cool if you could tag the current master as 0.2 and keep tagging as new versions are released :) (just getting familiar with all that myself...)

animaux commented 8 years ago

Thanks! I’m still a github noob :·) Version tags are definitely good to have!

Have to read a bit about branches before I can handle them. I’d be ok if you PR this into master for now.

twiro commented 8 years ago

I’d be ok if you PR this into master for now.

Alright - so I'll also update the meta with a new version 0.3 so it'll be a complete and release-ready PR.

We don't have to solve the font question now (https://github.com/animaux/simplemde/issues/4) but it would be cool if you could give me feedback on my screenshot-question: https://github.com/animaux/simplemde/issues/5 before I send my PR. Thank you!

animaux commented 8 years ago

Done. Go ahead :+1:

twiro commented 8 years ago

Done. Go ahead :+1:

Cool... PR is on it's way... hope I didn't miss anything!

animaux commented 8 years ago

Fixed in https://github.com/animaux/simplemde/tree/0.3