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 bpmn.io forums: Memento Pattern for BPMN Shapes - Modeler - Forum - bpmn.io

Sounds like a question that’s best asked on the bpmn.io forum feel free to post here a link to any answer you get on that forum :slight_smile: