Issue #580πŸ’¬ AnsweredOpened November 28, 2017by faizansaiyed3 reactions

Any/Trigger event when any block is dropped inside canvas?

Quick answerby ryandeba❀ 1

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

Read full answer below ↓

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)

duskhackerβ€’ November 29, 2017

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 
    }
  });
  
artfβ€’ November 30, 2017

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.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Free option

Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.

Browse free plugins β†’
Premium option

Premium plugins ship with support, regular updates, and production-ready features β€” save days of integration work.

Browse premium plugins β†’

Related tutorials

In-depth guides on the same topic.

All tutorials β†’

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.