Skip to content
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

[FEATURE REQUESTS] - block's toolbar at bottom option. #1728

Closed
arthuralmeidap opened this issue Jan 14, 2019 · 3 comments
Closed

[FEATURE REQUESTS] - block's toolbar at bottom option. #1728

arthuralmeidap opened this issue Jan 14, 2019 · 3 comments

Comments

@arthuralmeidap
Copy link
Contributor

hi @artf

How are you?
I'm facing a small issue on GrapesJS and I would like to hear your thoughts about the best approach here.
My issue is: When I have a small block, like a Link, placed at the top left corner of the Canvas, the toolbar totally covers the block and I can't see it. I would have to unselect that block to see it again.
What do you think as the best solution to this problem? I was thinking about to create a new option for GrapesJS to let the user select to display the toolbar at the bottom or the top of the block. This fixes my bug but introduces another, that's when the block is at the bottom of the canvas I would have to display the toolbar at the top this time.
What do you think? Is there any chance this new option be added to GrapesJS code? Do you have a better approach? Please let me know!

@artf
Copy link
Member

artf commented Jan 15, 2019

Hi @arthuralmeidap I think the #1434 talks about the same problem.
Honestly, I've already solved, basically the same issue, with the RTE toolbar, so I guess, if you have time, you could copy/share the same functionality for the Component's toolbar.

I'll place below a few hints about the current implementation in RTE:
Currently, if you activate the RTE, its toolbar will be placed at the top. Once the top canvas edge is reached, the toolbar is placed below the component.
Reproducible on the demo
Implemented here: https://github.com/artf/grapesjs/blob/8af686cb7fa66863c04b786ed1aa704e5406252e/src/rich_text_editor/index.js#L234-L253

As you might see I pass also rteToolbarPosUpdate event to the getTargetToElementDim method, which allows to customize the position extarnally (example usage in the CKEditor plugin: https://github.com/artf/grapesjs-plugin-ckeditor/blob/7c227de0b187da8cb7b1e22b3da34837659977d1/src/index.js#L110-L132)

The only problem with this implementetion is when you have to deal with big component (eg. section), not that common in text components. For instance, when you reach the top canvas edge but the bottom of the component it's still below the canvas. So, in that case, it might be good to leave the current positioning: https://github.com/artf/grapesjs/blob/8af686cb7fa66863c04b786ed1aa704e5406252e/src/commands/view/SelectComponent.js#L529-L544

@arthuralmeidap
Copy link
Contributor Author

@artf I created the PR #1730 for this. Take a look when possible! Thanks for your help as always!

@artf artf added this to To do in Release v0.14.55 via automation Jan 17, 2019
@artf artf closed this as completed in c3174da Jan 17, 2019
Release v0.14.55 automation moved this from To do to Done Jan 17, 2019
@lock
Copy link

lock bot commented Jan 17, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot added the outdated label Jan 17, 2020
@lock lock bot locked as resolved and limited conversation to collaborators Jan 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
No open projects
Development

No branches or pull requests

2 participants