bpmn-io / dmn-js

View and edit DMN diagrams in the browser.
https://bpmn.io/toolkit/dmn-js/
Other
292 stars 137 forks source link

Diagram changed handler #626

Open sualko opened 3 years ago

sualko commented 3 years ago

Is your feature request related to a problem? Please describe.

I would like to show an indicator if the diagram / table was changed and warn the user if he leaves the page or closes the document without saving it.

Describe the solution you'd like

The bpmn-js editor allows to listen for the element.changed event and I would like to have something similar for dms-js. I can listen for the same event on the right viewer (e.g. this.modeler.getActiveViewer().on('element.changed', ...)), but I guess I have to add this handler for every new view and I didn't find any comparative for the table view.

Describe alternatives you've considered

Export xml every few seconds and compare the outcome.

Additional context

In general I miss some documentation about the exposed API, since it is not using e.g. promises like bpmn-js.

pinussilvestrus commented 3 years ago

Thanks for reporting! As you already recognized, we have a multi-editor here, which makes it difficult to integrate a similar, universal element.changed event to the Modeler.

We are open to contributions that improve the situation. 👍

pinussilvestrus commented 3 years ago

In the meantime, maybe you find this workaround helpful. The commandStack.changed command is also used by the table editor, e.g. when adding rules. However, this is a very generic event, so use it wisely.