[QUESTION] Adds image block trough Editor API
Question
Hi @artf ,
When I drag and drop a Image block within the canvas it triggers the active event for the image block thats runs the openModal method. Shows a modal to upload the image.
I'm trying to run editor.addComponents({ type: 'image' }); and shows the modal to upload the image.
I didn't find any API methods that provides such functionality. Am I missing something?
If GrapesJS doesn't provides that, what do you think if I try to improve the editor.addComponents to check the component type and triggers the active event?
Answers (3)
yes, you are right @artf . I didn't think about dumb cases like that you mentioned.
It worked very fine to me. I just thought if was not the case to embedded such behaviour within the addComponents or somewhere else.
Thanks for all the help btw! Closing the issue in 3, 2, 1.....
@chiqui3d, thanks for the feedback but the image block was just an example. In my case I have created a new Type and I was trying to trigger the active event for my component. It works exactly like the image block that's why I used the image block as an example.
@artf, thanks for the response! it worked fine!
Why the active event is not triggered internally when we call the editor.addComponents method?
I think this will help you.
editor.runCommand('open-assets');
https://github.com/artf/grapesjs/wiki/Assets
Related Questions and Answers
Continue research with similar issue discussions.
Issue #861
[Question] Help adding images to the canvas
I've followed the docs and have been able to upload images. When I drag an image block (using the newsletter preset) and select an image fr...
Issue #905
[Question] need to find nessesary event.
Hello to all! When dragging block into canvas, and drop it: ... we have an event to detect, what block we drop in. ?: but when i drop block...
Issue #1218
[QUESTION] Asset Manager - Upload Image
Hey @artf , I have a question around Asset Manager. When uploading an image via computer or url the preview shows up at the asset collectio...
Issue #1875
[QUESTION] ID changes when importing html or passing html in components prop in config.
Hi, I built a component and block that I can drag and drop in the canvas. My issue is that some styles rely on the ID. I know this might no...
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.