grapesjs icon indicating copy to clipboard operation
grapesjs copied to clipboard

Prevent hover highlighter and prevent selecting certain components

Open ryandeba opened this issue 9 years ago • 4 comments

Hi @artf,

I would like to get your thoughts on the following 2 items before submitting a pull request. These are to satisfy requirements for a project that I'm currently working on, but I'm hoping that they could have a place in grapesjs core.

  1. Prevent the hover highlight effect on certain components. Components already have a "highlightable" property that is being used for the dotted outline style. I was thinking about using that same property to prevent the hover highlight effect, but it could also be a new property (maybe "hoverable" or "highlightOnHover"?). I haven't tested it yet, but it looks like I could just check the value of the property in SelectComponent.updateHighlighter() and return early if the value is set to false.

  2. Prevent selecting certain components. I would also like to completely prevent selecting certain components when they are clicked. I have some hacky code now that adds a "selectable" property to components, and if that property is set to false when the component:selected event fires then I un-select it (editor.select("")). I would prefer the component to not actually get selected in the first place to prevent other component:selected listeners from running, as well as to prevent the quick flash of the blue style outline & toolbar that briefly appears (I see this happen in chrome...not sure about other browsers). Is there an existing property that could be used for this? If not, what do you think about me adding a "selectable" property that could be used to prevent component selection?

Thanks for everything you do for this project, I really appreciate it!

ryandeba avatar Nov 21 '17 23:11 ryandeba

  1. Prevent the hover highlight effect on certain components. Components already have a "highlightable" property that is being used for the dotted outline style. I was thinking about using that same property to prevent the hover highlight effect, but it could also be a new property (maybe "hoverable" or "highlightOnHover"?). I haven't tested it yet, but it looks like I could just check the value of the property in SelectComponent.updateHighlighter() and return early if the value is set to false.

hoverable approved 👍 I'd like to point out not to use camelCase naming in Model's properties as it makes them invaluable via data-gjs-* attributes. Confirm also about your thoughts on SelectComponent.updateHighlighter

  1. Prevent selecting certain components. I would also like to completely prevent selecting certain components when they are clicked. I have some hacky code now that adds a "selectable" property to components, and if that property is set to false when the component:selected event fires then I un-select it (editor.select("")). I would prefer the component to not actually get selected in the first place to prevent other component:selected listeners from running, as well as to prevent the quick flash of the blue style outline & toolbar that briefly appears (I see this happen in chrome...not sure about other browsers). Is there an existing property that could be used for this? If not, what do you think about me adding a "selectable" property that could be used to prevent component selection?

I was already thinking about adding something like so go on.

Thanks to you for your help :)

artf avatar Nov 22 '17 22:11 artf

Thanks for the feedback! I've created a couple of pull requests for these items, let me know if you want to discuss further.

ryandeba avatar Nov 22 '17 23:11 ryandeba

Merged, Thanks Ryan 👍

artf avatar Nov 23 '17 00:11 artf

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[bot] avatar Sep 18 '19 06:09 lock[bot]