Listen to any change in the canvas
Question
Hello Folks,
I have a requirement where I added a button which saves the configuration to the remote DB.Now I would like to listen to any change in the canvas to enable/disable the button.For example, If there is any change, enable the save button for user to save it.I have gone through available events but I found nothing which listen to any change (Style,Component add/remove).
Any help? @artf
Warm regards Milap
Answers (3)
Actually I think there is an event that could serve this purpose. Could you try defining your method callback on 'change:changesCount'?
grapesjs\src\editor\model\Editor.js:64
this.on('change:changesCount', this.updateChanges, this);
I'm not sure if there's one exclusive event that listens for any changes to the canvas. Perhaps you could have your method run on all of the canvas events instead?
https://github.com/artf/grapesjs/blob/dev/src/editor/index.js#L53 `* ## Canvas
-
canvas:dragenter- When something is dragged inside the canvas,DataTransferinstance passed as an argument
-
canvas:dragover- When something is dragging on canvas,DataTransferinstance passed as an argument
-
canvas:drop- Something is dropped in canvas,DataTransferinstance and the dropped model are passed as arguments
-
canvas:dragend- When a drag operation is ended,DataTransferinstance passed as an argument
-
canvas:dragdata- On any dataTransfer parse,DataTransferinstance and theresultare passed as arguments.`
@IStirton10 Let me try it out.I guess this should work.
Warm regards Milap
Related Questions and Answers
Continue research with similar issue discussions.
Issue #1811
changesCount change on clicking any element in editor
Hello, I have used changesCount to resizeEditor if any change occurs to the canvas. But when I select any element in canvas like, clicking...
Issue #1709
[QUESTION] Is it possible to affect child component's styling through parent component's style manager?
Hello there! Awesome project and thanks for your contribution. I would like to know if it is possible to change the styling of a child comp...
Issue #1762
image not change while we fetch html using editor.getHtml()
Hello @artf I am using grapes.js for my website-builder tool into my website. While i double click on any image the asset-manager will open...
Issue #1639
[Question]: Would it be possible to have change settings under style manager in a way that it has href when a link is created?
I'm using preset newsletter with built-in RTE (do not want to use ck editor like the demo) In order to make any text to link, i need to cli...
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.