grapesjs icon indicating copy to clipboard operation
grapesjs copied to clipboard

Prevent modifying specific image components

Open ryandeba opened this issue 9 years ago • 4 comments

I have a use case where I would like to make some specific components completely locked down (i.e. not resizable, not draggable, not copyable, not removable, etc). I have this mostly working, but I'm having a problem with images - I cannot seem to prevent the double-click functionality that opens the asset manager modal and allows the image source to be changed. Is it possible to prevent that modal from opening when double-clicking an image?

I've tried setting the component's "editable" attribute to false component.set({editable: false});, but that does not seem to give the desired behavior. In fact, it looks like the editable attribute is false by default on all image components, but I could be wrong about that. I would be happy to work on this feature myself and submit a pull request if you'd like.

Thanks!

ryandeba avatar Nov 07 '17 22:11 ryandeba

Yeah, you're right, I use editable only for text components, but what you're asking actually make sense. I'd be happy to accept your PR. You should add editable: true, to the model https://github.com/artf/grapesjs/blob/dev/src/dom_components/model/ComponentImage.js and then check it in the view here https://github.com/artf/grapesjs/blob/dev/src/dom_components/view/ComponentImageView.js#L44

...
if (editor && this.model.get('editable')) {
     ...
}

artf avatar Nov 08 '17 13:11 artf

Thanks @artf! Here's the pull request: https://github.com/artf/grapesjs/pull/496

ryandeba avatar Nov 08 '17 17:11 ryandeba

Merged https://github.com/artf/grapesjs/pull/496 👍

artf avatar Nov 08 '17 20: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 08:09 lock[bot]