Programmatically populate collapsed subprocess from XML

Interesting, pasting into the collapsed subprocess (and not in its plane) works by:

  var context = evt.context,
      element = context.shape,
      businessObject = element.businessObject;

//  const parent = targetElementRegistry.get(businessObject.id + '_plane');

  // remember size of collapsed subprocess shape
  var x = element.x,
      y = element.y,
      height = element.height, 
      width = element.width;

  var pasteContext = {
    element,
//    element: parent, 
//    element: targetElementRegistry.get('Process_1'),
    point: {x:100, y:100}
  };

  // paste tree
  targetCopyPaste.paste(pasteContext);

  // restore size of collapsed subprocess shape
  modeling.resizeShape(element, { width, height, x, y } );

Unfortunately, a workaround is needed to restore the size of the element, so the solution is probably not perfect.

@nikku: This is almost the same problem as discussed in Programmatically populate collapsed subprocess - #3 by nikku but using the element referring to the subprocess plane doesn’t work in this case :thinking: