Memento Pattern for BPMN Shapes

Hey,

what would be the easiest way to save and restore Diagram JS Shapes programatically in the modeler? I’m writing a plugin that creates its own shapes and deletes them for our use case. I also want to be able to “pack” shapes into a parent shape which should also be able to restore them at will.

Right now I’ve written a solution that simply extends the parent shape and stores the needed data as BPMN Extension fields. The problem with that approach is that meta information like placement and incoming and outgoing flows are lost on packing and unpacking.

Would there be a simpler solution to this problem?

Best regards

Crosslink to Camunda Forums: https://forum.camunda.org/t/memento-pattern-for-bpmn-shapes/16858