Our custom meta-model contains references, which are not part of the parameters itself. Thus, they are loaded manually in a custom property panel, in which they can be set, resulting in something like this:
const myCustomProperty = { custom: 'test' }
const modeling = this.bpmnModeler.get('modeling')
if (this.element) {
modeling.updateProperties(this.element, myCustomProperty)
}
While setting the parameters works without trouble, problems occur as soon as we copyPaste
or replace
the element. Since the “parameters” are not set as parameters, but instead added as a part of $attrs
, they do not get copied on these actions and are missing afterwards.
For replace
, I could use the following workaround:
this.postExecute('shape.replace', ({ context }) => {
const { oldShape, newShape } = context
const oldShapeCustom = oldShape?.businessObject?.$attrs?.custom
if (!oldShapeCustom || !newShape.id) {
return
}
const customProperty = {
custom: oldShapeCustom
}
modeling.updateProperties(elementRegistry.get(newShape.id), customProperty)
})
However, I could not use postExecute
on events like copyPaste.pasteElements
.
- Is it possible to copy “custom” properties / $attrs that are not part of the defined meta-model?
- … or is it possible to add a workaround using a
postExecute
on acopyPaste
event ? Usingshape.create
, I cannot receive the copied element’s attributes.
Thank you for any help.