Grapesjs: [Question] Any/Trigger event when any block is dropped inside canvas?

Created on 28 Nov 2017  路  6Comments  路  Source: artf/grapesjs

Hey,
How can I trigger some event when any new block or content inside canvas is updated?
Something like editor.onCanvasUpdate()

Thanks!

outdated

All 6 comments

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))

@artf what about doing this only for specific blocks?

@chrisrobbins85kw I'd put some check (eg. some attribute/property) inside the callback

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kosirm picture kosirm  路  3Comments

crazyxhz picture crazyxhz  路  3Comments

applibs picture applibs  路  3Comments

andre2 picture andre2  路  3Comments

krunal039 picture krunal039  路  3Comments