Prevent modifying specific image components
Question
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!
Answers (3)
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')) {
...
}
Thanks @artf! Here's the pull request: https://github.com/artf/grapesjs/pull/496
Related Questions and Answers
Continue research with similar issue discussions.
Issue #710
Make an entire element draggable, not just the handle
I'm working on modifying the handle from draggable elements, in addition to having a handle, I'd like the entire element to be draggable. L...
Issue #1179
[Question] Cannot load styles saved as !important
Hi! I'm trying to make all the user-set styles have the "!important" flag, in order to prevent some other previous existent classes to over...
Issue #362
How to create custom link components that prompts users to type link/choose link similar to Images Component Modal
Image Components have logic to call Modal and prompt user's interaction for options/configuration of image url. Would like to do similar to...
Issue #554
Prevent hover highlighter and prevent selecting certain components
Hi @artf, I would like to get your thoughts on the following 2 items before submitting a pull request. These are to satisfy requirements fo...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.