[Question] Any/Trigger event when any block is dropped inside canvas?
Question
Hey,
How can I trigger some event when any new block or content inside canvas is updated?
Something like editor.onCanvasUpdate()
Thanks!
Answers (3)
Hi @fsaiyedOB,
I've been able to accomplish this with the component:update event listed here: https://github.com/artf/grapesjs/wiki/API-Editor#available-events
My code looks something like
editor.on("component:update", function() {
// do stuff here
});
When I asked to find out when the canvas is dirty to provide an indicator, @artf told me:
editor.on('change:changesCount', (editorModel, changes) => {
if (changes) {
// do something with changes
} else {
// do something else with no changes
}
});
I'd add also a block specific event
editor.on('block:drag:stop', model => console.log('dropped ', model))
Related Questions and Answers
Continue research with similar issue discussions.
Issue #1831
[Question] How to run command for a block component?
I'd like to do something like this. so once a user drops the test component into the canvas, I'd like to open up asset manager modal where...
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...
Issue #1674
Render block after trait action .
I have created new block called sidebar that have dynamic updates by trait component ,trait contain checkboxes to dynamic change content by...
Issue #459
Error when including a custom component inside another block
Sorry for the vague title. I'm not sure how to describe this concisely. I have a custom block where i want to restrict that only images can...
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.