bpmn-js 8.8.2 → 9.0.0-subprocesses.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/dist/assets/bpmn-js.css +79 -0
  3. package/dist/assets/diagram-js.css +82 -78
  4. package/dist/bpmn-modeler.development.js +929 -502
  5. package/dist/bpmn-modeler.production.min.js +7 -6
  6. package/dist/bpmn-navigated-viewer.development.js +20574 -19973
  7. package/dist/bpmn-navigated-viewer.production.min.js +22 -20
  8. package/dist/bpmn-viewer.development.js +19775 -19174
  9. package/dist/bpmn-viewer.production.min.js +22 -20
  10. package/lib/BaseViewer.js +0 -13
  11. package/lib/Viewer.js +3 -1
  12. package/lib/draw/BpmnRenderUtil.js +6 -4
  13. package/lib/features/context-pad/ContextPadProvider.js +1 -1
  14. package/lib/features/copy-paste/BpmnCopyPaste.js +13 -13
  15. package/lib/features/di-ordering/BpmnDiOrdering.js +2 -3
  16. package/lib/features/drilldown/DrilldownCentering.js +41 -0
  17. package/lib/features/drilldown/DrilldownOverlays.js +110 -0
  18. package/lib/features/drilldown/SubprocessCompatibility.js +193 -0
  19. package/lib/features/drilldown/index.js +14 -0
  20. package/lib/features/label-editing/LabelEditingPreview.js +3 -3
  21. package/lib/features/label-editing/cmd/UpdateLabelHandler.js +2 -1
  22. package/lib/features/modeling/BpmnFactory.js +8 -8
  23. package/lib/features/modeling/BpmnUpdater.js +35 -27
  24. package/lib/features/modeling/ElementFactory.js +60 -37
  25. package/lib/features/modeling/behavior/DataStoreBehavior.js +3 -1
  26. package/lib/features/modeling/behavior/IsHorizontalFix.js +7 -4
  27. package/lib/features/modeling/behavior/LabelBehavior.js +8 -7
  28. package/lib/features/modeling/behavior/ToggleElementCollapseBehaviour.js +6 -6
  29. package/lib/features/modeling/cmd/UpdateCanvasRootHandler.js +8 -6
  30. package/lib/features/modeling/cmd/UpdatePropertiesHandler.js +19 -12
  31. package/lib/features/modeling/cmd/UpdateSemanticParentHandler.js +5 -3
  32. package/lib/features/palette/PaletteProvider.js +3 -1
  33. package/lib/features/popup-menu/ReplaceMenuProvider.js +5 -5
  34. package/lib/features/popup-menu/util/TypeUtil.js +1 -1
  35. package/lib/features/replace/BpmnReplace.js +29 -29
  36. package/lib/import/BpmnImporter.js +27 -22
  37. package/lib/import/BpmnTreeWalker.js +19 -17
  38. package/lib/import/Importer.js +17 -6
  39. package/lib/util/CompatibilityUtil.js +21 -1
  40. package/lib/util/DiUtil.js +10 -3
  41. package/lib/util/LabelUtil.js +2 -3
  42. package/lib/util/ModelUtil.js +11 -0
  43. package/package.json +2 -2
  44. package/test/matchers/BoundsMatchers.js +10 -10
  45. package/test/matchers/ConnectionMatchers.js +5 -5
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * bpmn-js - bpmn-modeler v8.8.2
2
+ * bpmn-js - bpmn-modeler v9.0.0-subprocesses.3
3
3
  *
4
4
  * Copyright (c) 2014-present, camunda Services GmbH
5
5
  *
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * Source Code: https://github.com/bpmn-io/bpmn-js
10
10
  *
11
- * Date: 2021-10-20
11
+ * Date: 2021-11-19
12
12
  */
13
13
  (function (global, factory) {
14
14
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -2337,13 +2337,14 @@
2337
2337
  eventBus.on([ 'render.shape', 'render.connection' ], renderPriority, function(evt, context) {
2338
2338
  var type = evt.type,
2339
2339
  element = context.element,
2340
- visuals = context.gfx;
2340
+ visuals = context.gfx,
2341
+ attrs = context.attrs;
2341
2342
 
2342
2343
  if (self.canRender(element)) {
2343
2344
  if (type === 'render.shape') {
2344
- return self.drawShape(visuals, element);
2345
+ return self.drawShape(visuals, element, attrs);
2345
2346
  } else {
2346
- return self.drawConnection(visuals, element);
2347
+ return self.drawConnection(visuals, element, attrs);
2347
2348
  }
2348
2349
  }
2349
2350
  });
@@ -2803,7 +2804,7 @@
2803
2804
  return true;
2804
2805
  };
2805
2806
 
2806
- DefaultRenderer.prototype.drawShape = function drawShape(visuals, element) {
2807
+ DefaultRenderer.prototype.drawShape = function drawShape(visuals, element, attrs) {
2807
2808
  var rect = create$1('rect');
2808
2809
 
2809
2810
  attr(rect, {
@@ -2814,9 +2815,9 @@
2814
2815
  });
2815
2816
 
2816
2817
  if (isFrameElement$1(element)) {
2817
- attr(rect, this.FRAME_STYLE);
2818
+ attr(rect, assign({}, this.FRAME_STYLE, attrs || {}));
2818
2819
  } else {
2819
- attr(rect, this.SHAPE_STYLE);
2820
+ attr(rect, assign({}, this.SHAPE_STYLE, attrs || {}));
2820
2821
  }
2821
2822
 
2822
2823
  append(visuals, rect);
@@ -2824,9 +2825,9 @@
2824
2825
  return rect;
2825
2826
  };
2826
2827
 
2827
- DefaultRenderer.prototype.drawConnection = function drawConnection(visuals, connection) {
2828
+ DefaultRenderer.prototype.drawConnection = function drawConnection(visuals, connection, attrs) {
2828
2829
 
2829
- var line = createLine(connection.waypoints, this.CONNECTION_STYLE);
2830
+ var line = createLine(connection.waypoints, assign({}, this.CONNECTION_STYLE, attrs || {}));
2830
2831
  append(visuals, line);
2831
2832
 
2832
2833
  return line;
@@ -4365,6 +4366,10 @@
4365
4366
  var BASE_LAYER = 'base';
4366
4367
  var HIDDEN_MARKER = 'djs-element-hidden';
4367
4368
 
4369
+ // render plane contents behind utility layers
4370
+ var PLANE_LAYER_INDEX = 0;
4371
+ var UTILITY_LAYER_INDEX = 1;
4372
+
4368
4373
 
4369
4374
  var REQUIRED_MODEL_ATTRS = {
4370
4375
  shape: [ 'x', 'y', 'width', 'height' ],
@@ -4463,7 +4468,8 @@
4463
4468
  'connection.added',
4464
4469
  'shape.removed',
4465
4470
  'connection.removed',
4466
- 'elements.changed'
4471
+ 'elements.changed',
4472
+ 'plane.set'
4467
4473
  ], function() {
4468
4474
  delete this._cachedViewbox;
4469
4475
  }, this);
@@ -4524,7 +4530,7 @@
4524
4530
  * @returns {SVGElement}
4525
4531
  */
4526
4532
  Canvas.prototype.getDefaultLayer = function() {
4527
- return this.getLayer(BASE_LAYER);
4533
+ return this.getLayer(BASE_LAYER, PLANE_LAYER_INDEX);
4528
4534
  };
4529
4535
 
4530
4536
  /**
@@ -4573,8 +4579,8 @@
4573
4579
  */
4574
4580
  Canvas.prototype._createLayer = function(name, index) {
4575
4581
 
4576
- if (!index) {
4577
- index = 0;
4582
+ if (typeof index === 'undefined') {
4583
+ index = UTILITY_LAYER_INDEX;
4578
4584
  }
4579
4585
 
4580
4586
  var childIndex = reduce(this._layers, function(childIndex, layer) {
@@ -4604,9 +4610,7 @@
4604
4610
  throw new Error('must specify a name');
4605
4611
  }
4606
4612
 
4607
- var plane = this._planes[name];
4608
-
4609
- return plane;
4613
+ return this._planes[name];
4610
4614
  };
4611
4615
 
4612
4616
  /**
@@ -4635,7 +4639,7 @@
4635
4639
  };
4636
4640
  }
4637
4641
 
4638
- var svgLayer = this.getLayer(name);
4642
+ var svgLayer = this.getLayer(name, PLANE_LAYER_INDEX);
4639
4643
  classes(svgLayer).add(HIDDEN_MARKER);
4640
4644
 
4641
4645
  var plane = this._planes[name] = {
@@ -5244,9 +5248,10 @@
5244
5248
  if (!box) {
5245
5249
 
5246
5250
  // compute the inner box based on the
5247
- // diagrams default layer. This allows us to exclude
5251
+ // diagrams active plane. This allows us to exclude
5248
5252
  // external components, such as overlays
5249
- innerBox = this.getDefaultLayer().getBBox();
5253
+
5254
+ innerBox = (this._activePlane && this._activePlane.layer.getBBox()) || {};
5250
5255
 
5251
5256
  transform = transform$1(viewport);
5252
5257
  matrix = transform ? transform.matrix : createMatrix();
@@ -5262,10 +5267,10 @@
5262
5267
  height: outerBox.height / scale,
5263
5268
  scale: scale,
5264
5269
  inner: {
5265
- width: innerBox.width,
5266
- height: innerBox.height,
5267
- x: innerBox.x,
5268
- y: innerBox.y
5270
+ width: innerBox.width || 0,
5271
+ height: innerBox.height || 0,
5272
+ x: innerBox.x || 0,
5273
+ y: innerBox.y || 0
5269
5274
  },
5270
5275
  outer: outerBox
5271
5276
  };
@@ -5318,13 +5323,17 @@
5318
5323
  * Scrolls the viewbox to contain the given element.
5319
5324
  * Optionally specify a padding to be applied to the edges.
5320
5325
  *
5321
- * @param {Object} [element] the element to scroll to.
5326
+ * @param {Object|String} [element] the element to scroll to.
5322
5327
  * @param {Object|Number} [padding=100] the padding to be applied. Can also specify top, bottom, left and right.
5323
5328
  *
5324
5329
  */
5325
5330
  Canvas.prototype.scrollToElement = function(element, padding) {
5326
5331
  var defaultPadding = 100;
5327
5332
 
5333
+ if (typeof element === 'string') {
5334
+ element = this._elementRegistry.get(element);
5335
+ }
5336
+
5328
5337
  // switch to correct Plane
5329
5338
  var targetPlane = this.findPlane(element);
5330
5339
  if (targetPlane !== this._activePlane) {
@@ -14940,10 +14949,74 @@
14940
14949
  return '<' + e.$type + (e.id ? ' id="' + e.id : '') + '" />';
14941
14950
  }
14942
14951
 
14943
- var diRefs = new Refs(
14944
- { name: 'bpmnElement', enumerable: true },
14945
- { name: 'di', configurable: true }
14946
- );
14952
+ // TODO(nikku): remove with future bpmn-js version
14953
+
14954
+ /**
14955
+ * Wraps APIs to check:
14956
+ *
14957
+ * 1) If a callback is passed -> Warn users about callback deprecation.
14958
+ * 2) If Promise class is implemented in current environment.
14959
+ *
14960
+ * @private
14961
+ */
14962
+ function wrapForCompatibility(api) {
14963
+
14964
+ return function() {
14965
+
14966
+ if (!window.Promise) {
14967
+ throw new Error('Promises is not supported in this environment. Please polyfill Promise.');
14968
+ }
14969
+
14970
+ var argLen = arguments.length;
14971
+ if (argLen >= 1 && isFunction(arguments[argLen - 1])) {
14972
+
14973
+ var callback = arguments[argLen - 1];
14974
+
14975
+ console.warn(new Error(
14976
+ 'Passing callbacks to ' + api.name + ' is deprecated and will be removed in a future major release. ' +
14977
+ 'Please switch to promises: https://bpmn.io/l/moving-to-promises.html'
14978
+ ));
14979
+
14980
+ var argsWithoutCallback = Array.prototype.slice.call(arguments, 0, -1);
14981
+
14982
+ api.apply(this, argsWithoutCallback).then(function(result) {
14983
+
14984
+ var firstKey = Object.keys(result)[0];
14985
+
14986
+ // The APIs we are wrapping all resolve a single item depending on the API.
14987
+ // For instance, importXML resolves { warnings } and saveXML returns { xml }.
14988
+ // That's why we can call the callback with the first item of result.
14989
+ return callback(null, result[firstKey]);
14990
+
14991
+ // Passing a second paramter instead of catch because we don't want to
14992
+ // catch errors thrown by callback().
14993
+ }, function(err) {
14994
+
14995
+ return callback(err, err.warnings);
14996
+ });
14997
+ } else {
14998
+
14999
+ return api.apply(this, arguments);
15000
+ }
15001
+ };
15002
+ }
15003
+
15004
+
15005
+ // TODO(nikku): remove with future bpmn-js version
15006
+
15007
+ var DI_ERROR_MESSAGE = 'Tried to access di from the businessObject. The di is available through the diagram element only. For more information, see https://github.com/bpmn-io/bpmn-js/issues/1472';
15008
+
15009
+ function ensureCompatDiRef(businessObject) {
15010
+
15011
+ // bpmnElement can have multiple independent DIs
15012
+ if (!has(businessObject, 'di')) {
15013
+ Object.defineProperty(businessObject, 'di', {
15014
+ get: function() {
15015
+ throw new Error(DI_ERROR_MESSAGE);
15016
+ }
15017
+ });
15018
+ }
15019
+ }
14947
15020
 
14948
15021
  /**
14949
15022
  * Returns true if an element has the given meta-model type
@@ -14978,6 +15051,8 @@
14978
15051
  // prerequisites are drawn
14979
15052
  var deferred = [];
14980
15053
 
15054
+ var diMap = {};
15055
+
14981
15056
  // Helpers //////////////////////
14982
15057
 
14983
15058
  function contextual(fn, ctx) {
@@ -15006,17 +15081,17 @@
15006
15081
  }
15007
15082
 
15008
15083
  // call handler
15009
- return handler.element(element, ctx);
15084
+ return handler.element(element, diMap[element.id], ctx);
15010
15085
  }
15011
15086
 
15012
15087
  function visitRoot(element, diagram) {
15013
- return handler.root(element, diagram);
15088
+ return handler.root(element, diMap[element.id], diagram);
15014
15089
  }
15015
15090
 
15016
15091
  function visitIfDi(element, ctx) {
15017
15092
 
15018
15093
  try {
15019
- var gfx = element.di && visit(element, ctx);
15094
+ var gfx = diMap[element.id] && visit(element, ctx);
15020
15095
 
15021
15096
  handled(element);
15022
15097
 
@@ -15039,7 +15114,7 @@
15039
15114
  var bpmnElement = di.bpmnElement;
15040
15115
 
15041
15116
  if (bpmnElement) {
15042
- if (bpmnElement.di) {
15117
+ if (diMap[bpmnElement.id]) {
15043
15118
  logError(
15044
15119
  translate('multiple DI elements defined for {element}', {
15045
15120
  element: elementToString(bpmnElement)
@@ -15047,8 +15122,9 @@
15047
15122
  { element: bpmnElement }
15048
15123
  );
15049
15124
  } else {
15050
- diRefs.bind(bpmnElement, 'di');
15051
- bpmnElement.di = di;
15125
+ diMap[bpmnElement.id] = di;
15126
+
15127
+ ensureCompatDiRef(bpmnElement);
15052
15128
  }
15053
15129
  } else {
15054
15130
  logError(
@@ -15105,6 +15181,7 @@
15105
15181
  }
15106
15182
 
15107
15183
  // load DI from selected diagram only
15184
+ diMap = {};
15108
15185
  handleDiagram(diagram);
15109
15186
 
15110
15187
 
@@ -15144,10 +15221,10 @@
15144
15221
 
15145
15222
  var ctx = visitRoot(rootElement, plane);
15146
15223
 
15147
- if (is$2(rootElement, 'bpmn:Process')) {
15224
+ if (is$2(rootElement, 'bpmn:Process') || is$2(rootElement, 'bpmn:SubProcess')) {
15148
15225
  handleProcess(rootElement, ctx);
15149
15226
  } else if (is$2(rootElement, 'bpmn:Collaboration')) {
15150
- handleCollaboration(rootElement);
15227
+ handleCollaboration(rootElement, ctx);
15151
15228
 
15152
15229
  // force drawing of everything not yet drawn that is part of the target DI
15153
15230
  handleUnhandledProcesses(definitions.rootElements, ctx);
@@ -15354,15 +15431,15 @@
15354
15431
  }
15355
15432
  }
15356
15433
 
15357
- function handleCollaboration(collaboration) {
15434
+ function handleCollaboration(collaboration, context) {
15358
15435
 
15359
- forEach(collaboration.participants, contextual(handleParticipant));
15436
+ forEach(collaboration.participants, contextual(handleParticipant, context));
15360
15437
 
15361
- handleArtifacts(collaboration.artifacts);
15438
+ handleArtifacts(collaboration.artifacts, context);
15362
15439
 
15363
15440
  // handle message flows latest in the process
15364
15441
  deferred.push(function() {
15365
- handleMessageFlows(collaboration.messageFlows);
15442
+ handleMessageFlows(collaboration.messageFlows, context);
15366
15443
  });
15367
15444
  }
15368
15445
 
@@ -15421,7 +15498,8 @@
15421
15498
 
15422
15499
  var importer,
15423
15500
  eventBus,
15424
- translate;
15501
+ translate,
15502
+ canvas;
15425
15503
 
15426
15504
  var error,
15427
15505
  warnings = [];
@@ -15437,12 +15515,12 @@
15437
15515
 
15438
15516
  var visitor = {
15439
15517
 
15440
- root: function(element) {
15441
- return importer.add(element);
15518
+ root: function(element, di) {
15519
+ return importer.add(element, di);
15442
15520
  },
15443
15521
 
15444
- element: function(element, parentShape) {
15445
- return importer.add(element, parentShape);
15522
+ element: function(element, di, parentShape) {
15523
+ return importer.add(element, di, parentShape);
15446
15524
  },
15447
15525
 
15448
15526
  error: function(message, context) {
@@ -15454,7 +15532,16 @@
15454
15532
 
15455
15533
  // traverse BPMN 2.0 document model,
15456
15534
  // starting at definitions
15457
- walker.handleDefinitions(definitions, bpmnDiagram);
15535
+ if (!bpmnDiagram && definitions.diagrams) {
15536
+ for (var i = 0; i < definitions.diagrams.length; i++) {
15537
+ walker.handleDefinitions(definitions, definitions.diagrams[i]);
15538
+ }
15539
+ } else {
15540
+ walker.handleDefinitions(definitions, bpmnDiagram);
15541
+ }
15542
+
15543
+ var mainDiagram = bpmnDiagram || definitions.diagrams[0];
15544
+ canvas.setActivePlane(mainDiagram.plane.bpmnElement.id);
15458
15545
  }
15459
15546
 
15460
15547
  return new Promise(function(resolve, reject) {
@@ -15462,6 +15549,7 @@
15462
15549
  importer = diagram.get('bpmnImporter');
15463
15550
  eventBus = diagram.get('eventBus');
15464
15551
  translate = diagram.get('translate');
15552
+ canvas = diagram.get('canvas');
15465
15553
 
15466
15554
  eventBus.fire('import.render.start', { definitions: definitions });
15467
15555
 
@@ -15481,58 +15569,6 @@
15481
15569
  });
15482
15570
  }
15483
15571
 
15484
- // TODO(nikku): remove with future bpmn-js version
15485
-
15486
- /**
15487
- * Wraps APIs to check:
15488
- *
15489
- * 1) If a callback is passed -> Warn users about callback deprecation.
15490
- * 2) If Promise class is implemented in current environment.
15491
- *
15492
- * @private
15493
- */
15494
- function wrapForCompatibility(api) {
15495
-
15496
- return function() {
15497
-
15498
- if (!window.Promise) {
15499
- throw new Error('Promises is not supported in this environment. Please polyfill Promise.');
15500
- }
15501
-
15502
- var argLen = arguments.length;
15503
- if (argLen >= 1 && isFunction(arguments[argLen - 1])) {
15504
-
15505
- var callback = arguments[argLen - 1];
15506
-
15507
- console.warn(new Error(
15508
- 'Passing callbacks to ' + api.name + ' is deprecated and will be removed in a future major release. ' +
15509
- 'Please switch to promises: https://bpmn.io/l/moving-to-promises.html'
15510
- ));
15511
-
15512
- var argsWithoutCallback = Array.prototype.slice.call(arguments, 0, -1);
15513
-
15514
- api.apply(this, argsWithoutCallback).then(function(result) {
15515
-
15516
- var firstKey = Object.keys(result)[0];
15517
-
15518
- // The APIs we are wrapping all resolve a single item depending on the API.
15519
- // For instance, importXML resolves { warnings } and saveXML returns { xml }.
15520
- // That's why we can call the callback with the first item of result.
15521
- return callback(null, result[firstKey]);
15522
-
15523
- // Passing a second paramter instead of catch because we don't want to
15524
- // catch errors thrown by callback().
15525
- }, function(err) {
15526
-
15527
- return callback(err, err.warnings);
15528
- });
15529
- } else {
15530
-
15531
- return api.apply(this, arguments);
15532
- }
15533
- };
15534
- }
15535
-
15536
15572
  /**
15537
15573
  * This file must not be changed or exchanged.
15538
15574
  *
@@ -16112,19 +16148,6 @@
16112
16148
  return;
16113
16149
  }
16114
16150
 
16115
- // remove businessObject#di binding
16116
- //
16117
- // this is necessary, as we establish the bindings
16118
- // in the BpmnTreeWalker (and assume none are given
16119
- // on reimport)
16120
- this.get('elementRegistry').forEach(function(element) {
16121
- var bo = element.businessObject;
16122
-
16123
- if (bo && bo.di) {
16124
- delete bo.di;
16125
- }
16126
- });
16127
-
16128
16151
  // remove drawn elements
16129
16152
  Diagram.prototype.clear.call(this);
16130
16153
  };
@@ -16453,14 +16476,31 @@
16453
16476
  return (element && element.businessObject) || element;
16454
16477
  }
16455
16478
 
16456
- function isExpanded(element) {
16479
+ /**
16480
+ * Return the di object for a given element.
16481
+ *
16482
+ * @param {djs.model.Base} element
16483
+ *
16484
+ * @return {ModdleElement}
16485
+ */
16486
+ function getDi(element) {
16487
+ return element && element.di;
16488
+ }
16489
+
16490
+ function isExpanded(element, di) {
16457
16491
 
16458
16492
  if (is$1(element, 'bpmn:CallActivity')) {
16459
16493
  return false;
16460
16494
  }
16461
16495
 
16462
16496
  if (is$1(element, 'bpmn:SubProcess')) {
16463
- return getBusinessObject(element).di && !!getBusinessObject(element).di.isExpanded;
16497
+ di = di || getDi(element);
16498
+
16499
+ if (di && is$1(di, 'bpmndi:BPMNPlane')) {
16500
+ return true;
16501
+ }
16502
+
16503
+ return di && !!di.isExpanded;
16464
16504
  }
16465
16505
 
16466
16506
  if (is$1(element, 'bpmn:Participant')) {
@@ -16605,10 +16645,6 @@
16605
16645
  return element.isCollection || (dataObject && dataObject.isCollection);
16606
16646
  }
16607
16647
 
16608
- function getDi(element) {
16609
- return element.businessObject.di;
16610
- }
16611
-
16612
16648
  function getSemantic(element) {
16613
16649
  return element.businessObject;
16614
16650
  }
@@ -19679,15 +19715,14 @@
19679
19715
  * Returns the bounds of an elements label, parsed from the elements DI or
19680
19716
  * generated from its bounds.
19681
19717
  *
19682
- * @param {BpmnElement} semantic
19718
+ * @param {BpmndDi} di
19683
19719
  * @param {djs.model.Base} element
19684
19720
  */
19685
- function getExternalLabelBounds(semantic, element) {
19721
+ function getExternalLabelBounds(di, element) {
19686
19722
 
19687
19723
  var mid,
19688
19724
  size,
19689
19725
  bounds,
19690
- di = semantic.di,
19691
19726
  label = di.label;
19692
19727
 
19693
19728
  if (label && label.bounds) {
@@ -19719,17 +19754,18 @@
19719
19754
  return element && !!element.labelTarget;
19720
19755
  }
19721
19756
 
19722
- function elementData(semantic, attrs) {
19757
+ function elementData(semantic, di, attrs) {
19723
19758
  return assign({
19724
19759
  id: semantic.id,
19725
19760
  type: semantic.$type,
19726
- businessObject: semantic
19761
+ businessObject: semantic,
19762
+ di: di
19727
19763
  }, attrs);
19728
19764
  }
19729
19765
 
19730
- function getWaypoints(bo, source, target) {
19766
+ function getWaypoints(di, source, target) {
19731
19767
 
19732
- var waypoints = bo.di.waypoint;
19768
+ var waypoints = di.waypoint;
19733
19769
 
19734
19770
  if (!waypoints || waypoints.length < 2) {
19735
19771
  return [ getMid(source), getMid(target) ];
@@ -19785,10 +19821,8 @@
19785
19821
  * Add bpmn element (semantic) to the canvas onto the
19786
19822
  * specified parent shape.
19787
19823
  */
19788
- BpmnImporter.prototype.add = function(semantic, parentElement) {
19789
-
19790
- var di = semantic.di,
19791
- element,
19824
+ BpmnImporter.prototype.add = function(semantic, di, parentElement) {
19825
+ var element,
19792
19826
  translate = this._translate,
19793
19827
  hidden;
19794
19828
 
@@ -19796,25 +19830,31 @@
19796
19830
 
19797
19831
  // ROOT ELEMENT
19798
19832
  // handle the special case that we deal with a
19799
- // invisible root element (process or collaboration)
19833
+ // invisible root element (process, subprocess or collaboration)
19800
19834
  if (is$1(di, 'bpmndi:BPMNPlane')) {
19801
19835
 
19802
19836
  // add a virtual element (not being drawn)
19803
- element = this._elementFactory.createRoot(elementData(semantic));
19837
+ element = this._elementFactory.createRoot(elementData(semantic, di));
19804
19838
 
19805
- this._canvas.setRootElement(element);
19839
+ // for subprocesses, the id is already defined on the collapsed shape
19840
+ if (is$1(semantic, 'bpmn:SubProcess')) {
19841
+ element.id = element.id + '_plane';
19842
+ }
19843
+
19844
+ this._canvas.createPlane(semantic.id, element);
19806
19845
  }
19807
19846
 
19808
19847
  // SHAPE
19809
19848
  else if (is$1(di, 'bpmndi:BPMNShape')) {
19810
19849
 
19811
- var collapsed = !isExpanded(semantic),
19850
+ var collapsed = !isExpanded(semantic, di),
19812
19851
  isFrame = isFrameElement(semantic);
19852
+
19813
19853
  hidden = parentElement && (parentElement.hidden || parentElement.collapsed);
19814
19854
 
19815
- var bounds = semantic.di.bounds;
19855
+ var bounds = di.bounds;
19816
19856
 
19817
- element = this._elementFactory.createShape(elementData(semantic, {
19857
+ element = this._elementFactory.createShape(elementData(semantic, di, {
19818
19858
  collapsed: collapsed,
19819
19859
  hidden: hidden,
19820
19860
  x: Math.round(bounds.x),
@@ -19837,7 +19877,7 @@
19837
19877
 
19838
19878
  // check whether data store is inside our outside of its semantic parent
19839
19879
  if (!isPointInsideBBox$1(parentElement, getMid(bounds))) {
19840
- parentElement = this._canvas.getRootElement();
19880
+ parentElement = this._canvas.findPlane(parentElement).rootElement;
19841
19881
  }
19842
19882
  }
19843
19883
 
@@ -19852,11 +19892,11 @@
19852
19892
 
19853
19893
  hidden = parentElement && (parentElement.hidden || parentElement.collapsed);
19854
19894
 
19855
- element = this._elementFactory.createConnection(elementData(semantic, {
19895
+ element = this._elementFactory.createConnection(elementData(semantic, di, {
19856
19896
  hidden: hidden,
19857
19897
  source: source,
19858
19898
  target: target,
19859
- waypoints: getWaypoints(semantic, source, target)
19899
+ waypoints: getWaypoints(di, source, target)
19860
19900
  }));
19861
19901
 
19862
19902
  if (is$1(semantic, 'bpmn:DataAssociation')) {
@@ -19865,7 +19905,7 @@
19865
19905
  // are rendered correctly across different "hacks" people
19866
19906
  // love to model such as cross participant / sub process
19867
19907
  // associations
19868
- parentElement = null;
19908
+ parentElement = this._canvas.findPlane(parentElement).rootElement;
19869
19909
  }
19870
19910
 
19871
19911
  // insert sequence flows behind other flow nodes (cf. #727)
@@ -19883,7 +19923,7 @@
19883
19923
 
19884
19924
  // (optional) LABEL
19885
19925
  if (isLabelExternal(semantic) && getLabel(element)) {
19886
- this.addLabel(semantic, element);
19926
+ this.addLabel(semantic, di, element);
19887
19927
  }
19888
19928
 
19889
19929
 
@@ -19932,12 +19972,12 @@
19932
19972
  /**
19933
19973
  * add label for an element
19934
19974
  */
19935
- BpmnImporter.prototype.addLabel = function(semantic, element) {
19975
+ BpmnImporter.prototype.addLabel = function(semantic, di, element) {
19936
19976
  var bounds,
19937
19977
  text,
19938
19978
  label;
19939
19979
 
19940
- bounds = getExternalLabelBounds(semantic, element);
19980
+ bounds = getExternalLabelBounds(di, element);
19941
19981
 
19942
19982
  text = getLabel(element);
19943
19983
 
@@ -19947,7 +19987,7 @@
19947
19987
  bounds = this._textRenderer.getExternalLabelBounds(bounds, text);
19948
19988
  }
19949
19989
 
19950
- label = this._elementFactory.createLabel(elementData(semantic, {
19990
+ label = this._elementFactory.createLabel(elementData(semantic, di, {
19951
19991
  id: semantic.id + '_label',
19952
19992
  labelTarget: element,
19953
19993
  type: 'label',
@@ -21491,22 +21531,26 @@
21491
21531
 
21492
21532
  Overlays.prototype._updateOverlayVisibilty = function(overlay, viewbox) {
21493
21533
  var show = overlay.show,
21534
+ plane = overlay.plane,
21494
21535
  minZoom = show && show.minZoom,
21495
21536
  maxZoom = show && show.maxZoom,
21496
21537
  htmlContainer = overlay.htmlContainer,
21538
+ activePlane = this._canvas.getActivePlane(),
21497
21539
  visible = true;
21498
21540
 
21499
- if (show) {
21541
+ if (plane !== activePlane) {
21542
+ visible = false;
21543
+ } else if (show) {
21500
21544
  if (
21501
21545
  (isDefined(minZoom) && minZoom > viewbox.scale) ||
21502
21546
  (isDefined(maxZoom) && maxZoom < viewbox.scale)
21503
21547
  ) {
21504
21548
  visible = false;
21505
21549
  }
21506
-
21507
- setVisible$1(htmlContainer, visible);
21508
21550
  }
21509
21551
 
21552
+ setVisible$1(htmlContainer, visible);
21553
+
21510
21554
  this._updateOverlayScale(overlay, viewbox);
21511
21555
  };
21512
21556
 
@@ -21677,6 +21721,545 @@
21677
21721
  overlays: [ 'type', Overlays ]
21678
21722
  };
21679
21723
 
21724
+ /**
21725
+ * Adds change support to the diagram, including
21726
+ *
21727
+ * <ul>
21728
+ * <li>redrawing shapes and connections on change</li>
21729
+ * </ul>
21730
+ *
21731
+ * @param {EventBus} eventBus
21732
+ * @param {Canvas} canvas
21733
+ * @param {ElementRegistry} elementRegistry
21734
+ * @param {GraphicsFactory} graphicsFactory
21735
+ */
21736
+ function ChangeSupport(
21737
+ eventBus, canvas, elementRegistry,
21738
+ graphicsFactory) {
21739
+
21740
+
21741
+ // redraw shapes / connections on change
21742
+
21743
+ eventBus.on('element.changed', function(event) {
21744
+
21745
+ var element = event.element;
21746
+
21747
+ // element might have been deleted and replaced by new element with same ID
21748
+ // thus check for parent of element except for root element
21749
+ if (element.parent || element === canvas.getRootElement()) {
21750
+ event.gfx = elementRegistry.getGraphics(element);
21751
+ }
21752
+
21753
+ // shape + gfx may have been deleted
21754
+ if (!event.gfx) {
21755
+ return;
21756
+ }
21757
+
21758
+ eventBus.fire(getType(element) + '.changed', event);
21759
+ });
21760
+
21761
+ eventBus.on('elements.changed', function(event) {
21762
+
21763
+ var elements = event.elements;
21764
+
21765
+ elements.forEach(function(e) {
21766
+ eventBus.fire('element.changed', { element: e });
21767
+ });
21768
+
21769
+ graphicsFactory.updateContainments(elements);
21770
+ });
21771
+
21772
+ eventBus.on('shape.changed', function(event) {
21773
+ graphicsFactory.update('shape', event.element, event.gfx);
21774
+ });
21775
+
21776
+ eventBus.on('connection.changed', function(event) {
21777
+ graphicsFactory.update('connection', event.element, event.gfx);
21778
+ });
21779
+ }
21780
+
21781
+ ChangeSupport.$inject = [
21782
+ 'eventBus',
21783
+ 'canvas',
21784
+ 'elementRegistry',
21785
+ 'graphicsFactory'
21786
+ ];
21787
+
21788
+ var ChangeSupportModule = {
21789
+ __init__: [ 'changeSupport'],
21790
+ changeSupport: [ 'type', ChangeSupport ]
21791
+ };
21792
+
21793
+ var css_escape = {exports: {}};
21794
+
21795
+ /*! https://mths.be/cssescape v1.5.1 by @mathias | MIT license */
21796
+
21797
+ (function (module, exports) {
21798
+ (function(root, factory) {
21799
+ // https://github.com/umdjs/umd/blob/master/returnExports.js
21800
+ {
21801
+ // For Node.js.
21802
+ module.exports = factory(root);
21803
+ }
21804
+ }(typeof commonjsGlobal != 'undefined' ? commonjsGlobal : commonjsGlobal, function(root) {
21805
+
21806
+ if (root.CSS && root.CSS.escape) {
21807
+ return root.CSS.escape;
21808
+ }
21809
+
21810
+ // https://drafts.csswg.org/cssom/#serialize-an-identifier
21811
+ var cssEscape = function(value) {
21812
+ if (arguments.length == 0) {
21813
+ throw new TypeError('`CSS.escape` requires an argument.');
21814
+ }
21815
+ var string = String(value);
21816
+ var length = string.length;
21817
+ var index = -1;
21818
+ var codeUnit;
21819
+ var result = '';
21820
+ var firstCodeUnit = string.charCodeAt(0);
21821
+ while (++index < length) {
21822
+ codeUnit = string.charCodeAt(index);
21823
+ // Note: there’s no need to special-case astral symbols, surrogate
21824
+ // pairs, or lone surrogates.
21825
+
21826
+ // If the character is NULL (U+0000), then the REPLACEMENT CHARACTER
21827
+ // (U+FFFD).
21828
+ if (codeUnit == 0x0000) {
21829
+ result += '\uFFFD';
21830
+ continue;
21831
+ }
21832
+
21833
+ if (
21834
+ // If the character is in the range [\1-\1F] (U+0001 to U+001F) or is
21835
+ // U+007F, […]
21836
+ (codeUnit >= 0x0001 && codeUnit <= 0x001F) || codeUnit == 0x007F ||
21837
+ // If the character is the first character and is in the range [0-9]
21838
+ // (U+0030 to U+0039), […]
21839
+ (index == 0 && codeUnit >= 0x0030 && codeUnit <= 0x0039) ||
21840
+ // If the character is the second character and is in the range [0-9]
21841
+ // (U+0030 to U+0039) and the first character is a `-` (U+002D), […]
21842
+ (
21843
+ index == 1 &&
21844
+ codeUnit >= 0x0030 && codeUnit <= 0x0039 &&
21845
+ firstCodeUnit == 0x002D
21846
+ )
21847
+ ) {
21848
+ // https://drafts.csswg.org/cssom/#escape-a-character-as-code-point
21849
+ result += '\\' + codeUnit.toString(16) + ' ';
21850
+ continue;
21851
+ }
21852
+
21853
+ if (
21854
+ // If the character is the first character and is a `-` (U+002D), and
21855
+ // there is no second character, […]
21856
+ index == 0 &&
21857
+ length == 1 &&
21858
+ codeUnit == 0x002D
21859
+ ) {
21860
+ result += '\\' + string.charAt(index);
21861
+ continue;
21862
+ }
21863
+
21864
+ // If the character is not handled by one of the above rules and is
21865
+ // greater than or equal to U+0080, is `-` (U+002D) or `_` (U+005F), or
21866
+ // is in one of the ranges [0-9] (U+0030 to U+0039), [A-Z] (U+0041 to
21867
+ // U+005A), or [a-z] (U+0061 to U+007A), […]
21868
+ if (
21869
+ codeUnit >= 0x0080 ||
21870
+ codeUnit == 0x002D ||
21871
+ codeUnit == 0x005F ||
21872
+ codeUnit >= 0x0030 && codeUnit <= 0x0039 ||
21873
+ codeUnit >= 0x0041 && codeUnit <= 0x005A ||
21874
+ codeUnit >= 0x0061 && codeUnit <= 0x007A
21875
+ ) {
21876
+ // the character itself
21877
+ result += string.charAt(index);
21878
+ continue;
21879
+ }
21880
+
21881
+ // Otherwise, the escaped character.
21882
+ // https://drafts.csswg.org/cssom/#escape-a-character
21883
+ result += '\\' + string.charAt(index);
21884
+
21885
+ }
21886
+ return result;
21887
+ };
21888
+
21889
+ if (!root.CSS) {
21890
+ root.CSS = {};
21891
+ }
21892
+
21893
+ root.CSS.escape = cssEscape;
21894
+ return cssEscape;
21895
+
21896
+ }));
21897
+ }(css_escape));
21898
+
21899
+ var cssEscape = css_escape.exports;
21900
+
21901
+ var HTML_ESCAPE_MAP = {
21902
+ '&': '&amp;',
21903
+ '<': '&lt;',
21904
+ '>': '&gt;',
21905
+ '"': '&quot;',
21906
+ '\'': '&#39;'
21907
+ };
21908
+
21909
+ function escapeHTML(str) {
21910
+ str = '' + str;
21911
+
21912
+ return str && str.replace(/[&<>"']/g, function(match) {
21913
+ return HTML_ESCAPE_MAP[match];
21914
+ });
21915
+ }
21916
+
21917
+ var ARROW_DOWN_SVG = '<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M4.81801948,3.50735931 L10.4996894,9.1896894 L10.5,4 L12,4 L12,12 L4,12 L4,10.5 L9.6896894,10.4996894 L3.75735931,4.56801948 C3.46446609,4.27512627 3.46446609,3.80025253 3.75735931,3.50735931 C4.05025253,3.21446609 4.52512627,3.21446609 4.81801948,3.50735931 Z"/></svg>';
21918
+
21919
+ var OPEN_CLASS = 'bjs-breadcrumbs-shown';
21920
+
21921
+ /**
21922
+ * Adds Overlays that allow switching planes on collapsed subprocesses.
21923
+ *
21924
+ * @param {eventBus} eventBus
21925
+ * @param {elementRegistry} elementRegistry
21926
+ * @param {overlays} overlays
21927
+ * @param {canvas} canvas
21928
+ */
21929
+ function DrilldownOverlays(eventBus, elementRegistry, overlays, canvas) {
21930
+ var breadcrumbs = domify('<ul class="bjs-breadcrumbs"></ul>');
21931
+ var container = canvas.getContainer();
21932
+ var containerClasses = classes$1(container);
21933
+ container.appendChild(breadcrumbs);
21934
+
21935
+ function updateBreadcrumbs(plane) {
21936
+ var subProcess = elementRegistry.get(plane.name);
21937
+ var parents = getParentChain(subProcess);
21938
+
21939
+ var path = parents.map(function(el) {
21940
+ var title = escapeHTML(el.name || el.id);
21941
+ var link = domify('<li><span class="bjs-crumb"><a title="' + title + '">' + title + '</a></span></li>');
21942
+
21943
+ link.addEventListener('click', function() {
21944
+ if (canvas.getPlane(el.id)) {
21945
+ canvas.setActivePlane(el.id);
21946
+ } else {
21947
+ var plane = canvas.findPlane(el.id);
21948
+ canvas.setActivePlane(plane);
21949
+ }
21950
+ });
21951
+
21952
+ return link;
21953
+ });
21954
+
21955
+ breadcrumbs.innerHTML = '';
21956
+
21957
+ // show breadcrumbs and expose state to .djs-container
21958
+ var visible = path.length > 1;
21959
+ containerClasses.toggle(OPEN_CLASS, visible);
21960
+
21961
+ path.forEach(function(el) {
21962
+ breadcrumbs.appendChild(el);
21963
+ });
21964
+ }
21965
+
21966
+ eventBus.on('plane.set', function(event) {
21967
+ var plane = event.plane;
21968
+
21969
+ updateBreadcrumbs(plane);
21970
+ });
21971
+
21972
+ var createOverlay = function(element) {
21973
+ var html = domify('<button class="bjs-drilldown">' + ARROW_DOWN_SVG + '</button>');
21974
+
21975
+ html.addEventListener('click', function() {
21976
+ canvas.setActivePlane(element.id);
21977
+ });
21978
+
21979
+ overlays.add(element, {
21980
+ position: {
21981
+ bottom: -7,
21982
+ right: -8
21983
+ },
21984
+ html: html
21985
+ });
21986
+ };
21987
+
21988
+ var addOverlays = function(elements) {
21989
+ elements.forEach(function(element) {
21990
+ if (is$1(element, 'bpmn:SubProcess')
21991
+ && element.collapsed
21992
+ && canvas.getPlane(element.id)) {
21993
+ createOverlay(element);
21994
+ }
21995
+ });
21996
+ };
21997
+
21998
+ eventBus.on('import.done', function() {
21999
+ addOverlays(elementRegistry.filter(function(el) {
22000
+ return is$1(el, 'bpmn:SubProcess');
22001
+ }));
22002
+ });
22003
+ }
22004
+
22005
+ DrilldownOverlays.$inject = [ 'eventBus', 'elementRegistry', 'overlays', 'canvas' ];
22006
+
22007
+
22008
+ // helpers
22009
+ var getParentChain = function(child) {
22010
+ var bo = getBusinessObject(child);
22011
+
22012
+ var parents = [];
22013
+
22014
+ for (var element = bo; element; element = element.$parent) {
22015
+ if (is$1(element, 'bpmn:SubProcess') || is$1(element, 'bpmn:Process')) {
22016
+ parents.push(element);
22017
+ }
22018
+ }
22019
+
22020
+ return parents.reverse();
22021
+ };
22022
+
22023
+ /**
22024
+ * Move collapsed subprocesses into view when drilling down. Zoom and scroll
22025
+ * are saved in a session.
22026
+ *
22027
+ * @param {eventBus} eventBus
22028
+ * @param {canvas} canvas
22029
+ */
22030
+ function DrilldownCentering(eventBus, canvas) {
22031
+ var currentPlane = 'base';
22032
+ var positionMap = {};
22033
+
22034
+ eventBus.on('plane.set', function(event) {
22035
+ var currentViewbox = canvas.viewbox();
22036
+ positionMap[currentPlane] = {
22037
+ x: currentViewbox.x,
22038
+ y: currentViewbox.y,
22039
+ zoom: currentViewbox.scale
22040
+ };
22041
+
22042
+ var planeId = event.plane.name;
22043
+ var storedViewbox = positionMap[planeId] || { x: 0, y: 0, zoom: 1 };
22044
+
22045
+ var dx = (currentViewbox.x - storedViewbox.x) * currentViewbox.scale,
22046
+ dy = (currentViewbox.y - storedViewbox.y) * currentViewbox.scale;
22047
+
22048
+ if (dx !== 0 || dy !== 0) {
22049
+ canvas.scroll({
22050
+ dx: dx,
22051
+ dy: dy
22052
+ });
22053
+ }
22054
+
22055
+ if (storedViewbox.zoom !== currentViewbox.scale) {
22056
+ canvas.zoom(storedViewbox.zoom, { x: 0, y: 0 });
22057
+ }
22058
+
22059
+ currentPlane = planeId;
22060
+ });
22061
+ }
22062
+
22063
+ DrilldownCentering.$inject = [ 'eventBus', 'canvas' ];
22064
+
22065
+ var DEFAULT_POSITION = {
22066
+ x: 180,
22067
+ y: 160
22068
+ };
22069
+
22070
+ /**
22071
+ * Hook into `import.render.start` and create new planes for diagrams with
22072
+ * collapsed subprocesses and all dis on the same plane.
22073
+ *
22074
+ * @param {eventBus} eventBus
22075
+ * @param {moddle} moddle
22076
+ */
22077
+ function SubprocessCompatibility(eventBus, moddle) {
22078
+ this._eventBus = eventBus;
22079
+ this._moddle = moddle;
22080
+
22081
+ var self = this;
22082
+
22083
+ eventBus.on('import.render.start', 1500, function(e, context) {
22084
+ self.handleImport(context.definitions);
22085
+ });
22086
+ }
22087
+
22088
+ SubprocessCompatibility.prototype.handleImport = function(definitions) {
22089
+ if (!definitions.diagrams) {
22090
+ return;
22091
+ }
22092
+
22093
+ var self = this;
22094
+ this._definitions = definitions;
22095
+ this._processToDiagramMap = {};
22096
+
22097
+ definitions.diagrams.forEach(function(diagram) {
22098
+ if (!diagram.plane || !diagram.plane.bpmnElement) {
22099
+ return;
22100
+ }
22101
+
22102
+ self._processToDiagramMap[diagram.plane.bpmnElement.id] = diagram;
22103
+ });
22104
+
22105
+ var newDiagrams = [];
22106
+ definitions.diagrams.forEach(function(diagram) {
22107
+ var createdDiagrams = self.createNewDiagrams(diagram.plane);
22108
+ Array.prototype.push.apply(newDiagrams, createdDiagrams);
22109
+ });
22110
+
22111
+ newDiagrams.forEach(function(diagram) {
22112
+ self.movePlaneElementsToOrigin(diagram.plane);
22113
+ });
22114
+ };
22115
+
22116
+
22117
+ /**
22118
+ * Moves all DI elements from collapsed subprocesses to a new plane.
22119
+ *
22120
+ * @param {Object} plane
22121
+ * @return {Array} new diagrams created for the collapsed subprocesses
22122
+ */
22123
+ SubprocessCompatibility.prototype.createNewDiagrams = function(plane) {
22124
+ var self = this;
22125
+
22126
+ var collapsedElements = [];
22127
+ var elementsToMove = [];
22128
+
22129
+ plane.get('planeElement').forEach(function(diElement) {
22130
+ var bo = diElement.bpmnElement;
22131
+ var parent = bo.$parent;
22132
+
22133
+ if (is$1(bo, 'bpmn:SubProcess') && !diElement.isExpanded) {
22134
+ collapsedElements.push(bo);
22135
+ }
22136
+
22137
+ if (is$1(parent, 'bpmn:SubProcess') && parent !== plane.bpmnElement) {
22138
+
22139
+ // don't change the array while we iterate over it
22140
+ elementsToMove.push({ diElement: diElement, parent: parent });
22141
+ }
22142
+ });
22143
+
22144
+ var newDiagrams = [];
22145
+
22146
+ elementsToMove.forEach(function(element) {
22147
+ var diElement = element.diElement;
22148
+ var parent = element.parent;
22149
+
22150
+ // parent is expanded, get nearest collapsed parent
22151
+ while (parent && !collapsedElements.includes(parent)) {
22152
+ parent = parent.$parent;
22153
+ }
22154
+
22155
+ // false positive, all parents are expanded
22156
+ if (!parent) {
22157
+ return;
22158
+ }
22159
+
22160
+ var diagram = self._processToDiagramMap[parent.id];
22161
+ if (!diagram) {
22162
+ diagram = self.createDiagram(parent);
22163
+ self._processToDiagramMap[parent.id] = diagram;
22164
+ newDiagrams.push(diagram);
22165
+ }
22166
+
22167
+ self.moveToDiPlane(diElement, diagram.plane);
22168
+ });
22169
+
22170
+ return newDiagrams;
22171
+ };
22172
+
22173
+ SubprocessCompatibility.prototype.movePlaneElementsToOrigin = function(plane) {
22174
+ var elements = plane.get('planeElement');
22175
+
22176
+ // get bounding box of all elements
22177
+ var planeBounds = getPlaneBounds(plane);
22178
+
22179
+ var offset = {
22180
+ x: planeBounds.x - DEFAULT_POSITION.x,
22181
+ y: planeBounds.y - DEFAULT_POSITION.y
22182
+ };
22183
+
22184
+ elements.forEach(function(diElement) {
22185
+ if (diElement.waypoint) {
22186
+ diElement.waypoint.forEach(function(waypoint) {
22187
+ waypoint.x = waypoint.x - offset.x;
22188
+ waypoint.y = waypoint.y - offset.y;
22189
+ });
22190
+ } else if (diElement.bounds) {
22191
+ diElement.bounds.x = diElement.bounds.x - offset.x;
22192
+ diElement.bounds.y = diElement.bounds.y - offset.y;
22193
+ }
22194
+ });
22195
+ };
22196
+
22197
+
22198
+ SubprocessCompatibility.prototype.moveToDiPlane = function(diElement, newPlane) {
22199
+ var containingDiagram = findRootDiagram(diElement);
22200
+
22201
+ // remove DI from old Plane and add it to the new one
22202
+ var parentPlaneElement = containingDiagram.plane.get('planeElement');
22203
+ parentPlaneElement.splice(parentPlaneElement.indexOf(diElement), 1);
22204
+ newPlane.get('planeElement').push(diElement);
22205
+ };
22206
+
22207
+
22208
+ SubprocessCompatibility.prototype.createDiagram = function(bo) {
22209
+ var plane = this._moddle.create('bpmndi:BPMNPlane', { bpmnElement: bo });
22210
+ var diagram = this._moddle.create('bpmndi:BPMNDiagram', {
22211
+ plane: plane
22212
+ });
22213
+ plane.$parent = diagram;
22214
+ plane.bpmnElement = bo;
22215
+ diagram.$parent = this._definitions;
22216
+ this._definitions.diagrams.push(diagram);
22217
+ return diagram;
22218
+ };
22219
+
22220
+ SubprocessCompatibility.$inject = [ 'eventBus', 'moddle' ];
22221
+
22222
+
22223
+ // helpers
22224
+
22225
+ function findRootDiagram(element) {
22226
+ if (is$1(element, 'bpmndi:BPMNDiagram')) {
22227
+ return element;
22228
+ } else {
22229
+ return findRootDiagram(element.$parent);
22230
+ }
22231
+ }
22232
+
22233
+ function getPlaneBounds(plane) {
22234
+ var planeTrbl = {
22235
+ top: Infinity,
22236
+ right: -Infinity,
22237
+ bottom: -Infinity,
22238
+ left: Infinity
22239
+ };
22240
+
22241
+ plane.planeElement.forEach(function(element) {
22242
+ if (!element.bounds) {
22243
+ return;
22244
+ }
22245
+
22246
+ var trbl = asTRBL(element.bounds);
22247
+
22248
+ planeTrbl.top = Math.min(trbl.top, planeTrbl.top);
22249
+ planeTrbl.left = Math.min(trbl.left, planeTrbl.left);
22250
+ });
22251
+
22252
+ return asBounds(planeTrbl);
22253
+ }
22254
+
22255
+ var DrilldownModdule = {
22256
+ __depends__: [ OverlaysModule, ChangeSupportModule ],
22257
+ __init__: [ 'drilldownOverlays', 'drilldownCentering', 'subprocessCompatibility'],
22258
+ drilldownOverlays: [ 'type', DrilldownOverlays ],
22259
+ drilldownCentering: [ 'type', DrilldownCentering ],
22260
+ subprocessCompatibility: [ 'type', SubprocessCompatibility ]
22261
+ };
22262
+
21680
22263
  /**
21681
22264
  * A viewer for BPMN 2.0 diagrams.
21682
22265
  *
@@ -21735,7 +22318,8 @@
21735
22318
  CoreModule,
21736
22319
  translate,
21737
22320
  SelectionModule,
21738
- OverlaysModule
22321
+ OverlaysModule,
22322
+ DrilldownModdule
21739
22323
  ];
21740
22324
 
21741
22325
  // default moddle extensions the viewer is composed of
@@ -28263,130 +28847,6 @@
28263
28847
  calculateSegmentMoveRegion(segmentLengthYAxis);
28264
28848
  }
28265
28849
 
28266
- var css_escape = {exports: {}};
28267
-
28268
- /*! https://mths.be/cssescape v1.5.1 by @mathias | MIT license */
28269
-
28270
- (function (module, exports) {
28271
- (function(root, factory) {
28272
- // https://github.com/umdjs/umd/blob/master/returnExports.js
28273
- {
28274
- // For Node.js.
28275
- module.exports = factory(root);
28276
- }
28277
- }(typeof commonjsGlobal != 'undefined' ? commonjsGlobal : commonjsGlobal, function(root) {
28278
-
28279
- if (root.CSS && root.CSS.escape) {
28280
- return root.CSS.escape;
28281
- }
28282
-
28283
- // https://drafts.csswg.org/cssom/#serialize-an-identifier
28284
- var cssEscape = function(value) {
28285
- if (arguments.length == 0) {
28286
- throw new TypeError('`CSS.escape` requires an argument.');
28287
- }
28288
- var string = String(value);
28289
- var length = string.length;
28290
- var index = -1;
28291
- var codeUnit;
28292
- var result = '';
28293
- var firstCodeUnit = string.charCodeAt(0);
28294
- while (++index < length) {
28295
- codeUnit = string.charCodeAt(index);
28296
- // Note: there’s no need to special-case astral symbols, surrogate
28297
- // pairs, or lone surrogates.
28298
-
28299
- // If the character is NULL (U+0000), then the REPLACEMENT CHARACTER
28300
- // (U+FFFD).
28301
- if (codeUnit == 0x0000) {
28302
- result += '\uFFFD';
28303
- continue;
28304
- }
28305
-
28306
- if (
28307
- // If the character is in the range [\1-\1F] (U+0001 to U+001F) or is
28308
- // U+007F, […]
28309
- (codeUnit >= 0x0001 && codeUnit <= 0x001F) || codeUnit == 0x007F ||
28310
- // If the character is the first character and is in the range [0-9]
28311
- // (U+0030 to U+0039), […]
28312
- (index == 0 && codeUnit >= 0x0030 && codeUnit <= 0x0039) ||
28313
- // If the character is the second character and is in the range [0-9]
28314
- // (U+0030 to U+0039) and the first character is a `-` (U+002D), […]
28315
- (
28316
- index == 1 &&
28317
- codeUnit >= 0x0030 && codeUnit <= 0x0039 &&
28318
- firstCodeUnit == 0x002D
28319
- )
28320
- ) {
28321
- // https://drafts.csswg.org/cssom/#escape-a-character-as-code-point
28322
- result += '\\' + codeUnit.toString(16) + ' ';
28323
- continue;
28324
- }
28325
-
28326
- if (
28327
- // If the character is the first character and is a `-` (U+002D), and
28328
- // there is no second character, […]
28329
- index == 0 &&
28330
- length == 1 &&
28331
- codeUnit == 0x002D
28332
- ) {
28333
- result += '\\' + string.charAt(index);
28334
- continue;
28335
- }
28336
-
28337
- // If the character is not handled by one of the above rules and is
28338
- // greater than or equal to U+0080, is `-` (U+002D) or `_` (U+005F), or
28339
- // is in one of the ranges [0-9] (U+0030 to U+0039), [A-Z] (U+0041 to
28340
- // U+005A), or [a-z] (U+0061 to U+007A), […]
28341
- if (
28342
- codeUnit >= 0x0080 ||
28343
- codeUnit == 0x002D ||
28344
- codeUnit == 0x005F ||
28345
- codeUnit >= 0x0030 && codeUnit <= 0x0039 ||
28346
- codeUnit >= 0x0041 && codeUnit <= 0x005A ||
28347
- codeUnit >= 0x0061 && codeUnit <= 0x007A
28348
- ) {
28349
- // the character itself
28350
- result += string.charAt(index);
28351
- continue;
28352
- }
28353
-
28354
- // Otherwise, the escaped character.
28355
- // https://drafts.csswg.org/cssom/#escape-a-character
28356
- result += '\\' + string.charAt(index);
28357
-
28358
- }
28359
- return result;
28360
- };
28361
-
28362
- if (!root.CSS) {
28363
- root.CSS = {};
28364
- }
28365
-
28366
- root.CSS.escape = cssEscape;
28367
- return cssEscape;
28368
-
28369
- }));
28370
- }(css_escape));
28371
-
28372
- var cssEscape = css_escape.exports;
28373
-
28374
- var HTML_ESCAPE_MAP = {
28375
- '&': '&amp;',
28376
- '<': '&lt;',
28377
- '>': '&gt;',
28378
- '"': '&quot;',
28379
- '\'': '&#39;'
28380
- };
28381
-
28382
- function escapeHTML(str) {
28383
- str = '' + str;
28384
-
28385
- return str && str.replace(/[&<>"']/g, function(match) {
28386
- return HTML_ESCAPE_MAP[match];
28387
- });
28388
- }
28389
-
28390
28850
  /**
28391
28851
  * A service that adds editable bendpoints to connections.
28392
28852
  */
@@ -33447,23 +33907,13 @@
33447
33907
  element = context.element;
33448
33908
 
33449
33909
  var businessObject = descriptor.oldBusinessObject = getBusinessObject(element);
33910
+ var di = descriptor.oldDi = getDi(element);
33450
33911
 
33451
33912
  descriptor.type = element.type;
33452
33913
 
33453
33914
  copyProperties$1(businessObject, descriptor, 'name');
33454
33915
 
33455
- descriptor.di = {};
33456
-
33457
- // colors will be set to DI
33458
- copyProperties$1(businessObject.di, descriptor.di, [
33459
- 'fill',
33460
- 'stroke',
33461
- 'background-color',
33462
- 'border-color',
33463
- 'color'
33464
- ]);
33465
-
33466
- copyProperties$1(businessObject.di, descriptor, 'isExpanded');
33916
+ copyProperties$1(di, descriptor, 'isExpanded');
33467
33917
 
33468
33918
  if (isLabel$3(descriptor)) {
33469
33919
  return descriptor;
@@ -33537,11 +33987,13 @@
33537
33987
  var cache = context.cache,
33538
33988
  descriptor = context.descriptor,
33539
33989
  oldBusinessObject = descriptor.oldBusinessObject,
33540
- newBusinessObject;
33990
+ oldDi = descriptor.oldDi,
33991
+ newBusinessObject, newDi;
33541
33992
 
33542
33993
  // do NOT copy business object if external label
33543
33994
  if (isLabel$3(descriptor)) {
33544
33995
  descriptor.businessObject = getBusinessObject(cache[ descriptor.labelTarget ]);
33996
+ descriptor.di = getDi(cache[ descriptor.labelTarget ]);
33545
33997
 
33546
33998
  return;
33547
33999
  }
@@ -33553,6 +34005,13 @@
33553
34005
  newBusinessObject
33554
34006
  );
33555
34007
 
34008
+ newDi = bpmnFactory.create(oldDi.$type);
34009
+
34010
+ descriptor.di = moddleCopy.copyElement(
34011
+ oldDi,
34012
+ newDi
34013
+ );
34014
+
33556
34015
  // resolve references e.g. default sequence flow
33557
34016
  resolveReferences(descriptor, cache);
33558
34017
 
@@ -33944,6 +34403,7 @@
33944
34403
  });
33945
34404
  }
33946
34405
 
34406
+
33947
34407
  var CUSTOM_PROPERTIES = [
33948
34408
  'cancelActivity',
33949
34409
  'instantiate',
@@ -33952,8 +34412,10 @@
33952
34412
  'isInterrupting'
33953
34413
  ];
33954
34414
 
33955
-
33956
- function toggeling(element, target) {
34415
+ /**
34416
+ * Check if element should be collapsed or expanded.
34417
+ */
34418
+ function shouldToggleCollapsed(element, targetElement) {
33957
34419
 
33958
34420
  var oldCollapsed = (
33959
34421
  element && has(element, 'collapsed') ? element.collapsed : !isExpanded(element)
@@ -33961,11 +34423,11 @@
33961
34423
 
33962
34424
  var targetCollapsed;
33963
34425
 
33964
- if (target && (has(target, 'collapsed') || has(target, 'isExpanded'))) {
34426
+ if (targetElement && (has(targetElement, 'collapsed') || has(targetElement, 'isExpanded'))) {
33965
34427
 
33966
34428
  // property is explicitly set so use it
33967
34429
  targetCollapsed = (
33968
- has(target, 'collapsed') ? target.collapsed : !target.isExpanded
34430
+ has(targetElement, 'collapsed') ? targetElement.collapsed : !targetElement.isExpanded
33969
34431
  );
33970
34432
  } else {
33971
34433
 
@@ -33974,7 +34436,6 @@
33974
34436
  }
33975
34437
 
33976
34438
  if (oldCollapsed !== targetCollapsed) {
33977
- element.collapsed = oldCollapsed;
33978
34439
  return true;
33979
34440
  }
33980
34441
 
@@ -33982,7 +34443,6 @@
33982
34443
  }
33983
34444
 
33984
34445
 
33985
-
33986
34446
  /**
33987
34447
  * This module takes care of replacing BPMN elements
33988
34448
  */
@@ -34013,15 +34473,13 @@
34013
34473
  var type = target.type,
34014
34474
  oldBusinessObject = element.businessObject;
34015
34475
 
34016
- if (isSubProcess(oldBusinessObject)) {
34017
- if (type === 'bpmn:SubProcess') {
34018
- if (toggeling(element, target)) {
34476
+ if (isSubProcess(oldBusinessObject) && type === 'bpmn:SubProcess') {
34477
+ if (shouldToggleCollapsed(element, target)) {
34019
34478
 
34020
- // expanding or collapsing process
34021
- modeling.toggleCollapse(element);
34479
+ // expanding or collapsing process
34480
+ modeling.toggleCollapse(element);
34022
34481
 
34023
- return element;
34024
- }
34482
+ return element;
34025
34483
  }
34026
34484
  }
34027
34485
 
@@ -34029,9 +34487,20 @@
34029
34487
 
34030
34488
  var newElement = {
34031
34489
  type: type,
34032
- businessObject: newBusinessObject
34490
+ businessObject: newBusinessObject,
34033
34491
  };
34034
34492
 
34493
+ newElement.di = {};
34494
+
34495
+ // colors will be set to DI
34496
+ copyProperties(element.di, newElement.di, [
34497
+ 'fill',
34498
+ 'stroke',
34499
+ 'background-color',
34500
+ 'border-color',
34501
+ 'color'
34502
+ ]);
34503
+
34035
34504
  var elementProps = getPropertyNames(oldBusinessObject.$descriptor),
34036
34505
  newElementProps = getPropertyNames(newBusinessObject.$descriptor, true),
34037
34506
  copyProps = intersection(elementProps, newElementProps);
@@ -34091,7 +34560,7 @@
34091
34560
  if (isSubProcess(oldBusinessObject)) {
34092
34561
 
34093
34562
  // no toggeling, so keep old state
34094
- newElement.isExpanded = isExpanded(oldBusinessObject);
34563
+ newElement.isExpanded = isExpanded(element);
34095
34564
  }
34096
34565
 
34097
34566
  // else if property is explicitly set, use it
@@ -34102,7 +34571,7 @@
34102
34571
  // TODO: need also to respect min/max Size
34103
34572
  // copy size, from an expanded subprocess to an expanded alternative subprocess
34104
34573
  // except bpmn:Task, because Task is always expanded
34105
- if ((isExpanded(oldBusinessObject) && !is$1(oldBusinessObject, 'bpmn:Task')) && newElement.isExpanded) {
34574
+ if ((isExpanded(element) && !is$1(oldBusinessObject, 'bpmn:Task')) && newElement.isExpanded) {
34106
34575
  newElement.width = element.width;
34107
34576
  newElement.height = element.height;
34108
34577
  }
@@ -34127,12 +34596,12 @@
34127
34596
 
34128
34597
  // apply same width and default height
34129
34598
  newElement.width = element.width;
34130
- newElement.height = elementFactory._getDefaultSize(newBusinessObject).height;
34599
+ newElement.height = elementFactory.getDefaultSize(newElement).height;
34131
34600
  }
34132
34601
 
34133
34602
  if (!rules.allowed('shape.resize', { shape: newBusinessObject })) {
34134
- newElement.height = elementFactory._getDefaultSize(newBusinessObject).height;
34135
- newElement.width = elementFactory._getDefaultSize(newBusinessObject).width;
34603
+ newElement.height = elementFactory.getDefaultSize(newElement).height;
34604
+ newElement.width = elementFactory.getDefaultSize(newElement).width;
34136
34605
  }
34137
34606
 
34138
34607
  newBusinessObject.name = oldBusinessObject.name;
@@ -34170,16 +34639,6 @@
34170
34639
  newElement.x = element.x + (element.width - newElement.width) / 2;
34171
34640
  }
34172
34641
 
34173
- newElement.di = {};
34174
-
34175
- // colors will be set to DI
34176
- copyProperties(oldBusinessObject.di, newElement.di, [
34177
- 'fill',
34178
- 'stroke',
34179
- 'background-color',
34180
- 'border-color',
34181
- 'color'
34182
- ]);
34183
34642
 
34184
34643
  newElement = replace.replaceElement(element, newElement, hints);
34185
34644
 
@@ -34264,7 +34723,7 @@
34264
34723
 
34265
34724
  var isExpandedEqual = (
34266
34725
  target.isExpanded === undefined ||
34267
- target.isExpanded === isExpanded(businessObject)
34726
+ target.isExpanded === isExpanded(element)
34268
34727
  );
34269
34728
 
34270
34729
  return !isTypeEqual || !isEventDefinitionEqual || !isTriggeredByEventEqual || !isExpandedEqual;
@@ -35201,7 +35660,7 @@
35201
35660
  if (is$1(businessObject, 'bpmn:Participant')) {
35202
35661
 
35203
35662
  entries = filter(PARTICIPANT, function(entry) {
35204
- return isExpanded(businessObject) !== entry.target.isExpanded;
35663
+ return isExpanded(element) !== entry.target.isExpanded;
35205
35664
  });
35206
35665
 
35207
35666
  return this._createEntries(element, entries);
@@ -35297,7 +35756,7 @@
35297
35756
  }
35298
35757
 
35299
35758
  // expanded event sub processes
35300
- if (isEventSubProcess(businessObject) && isExpanded(businessObject)) {
35759
+ if (isEventSubProcess(businessObject) && isExpanded(element)) {
35301
35760
 
35302
35761
  entries = filter(EVENT_SUB_PROCESS, differentType);
35303
35762
 
@@ -35305,7 +35764,7 @@
35305
35764
  }
35306
35765
 
35307
35766
  // expanded sub processes
35308
- if (is$1(businessObject, 'bpmn:SubProcess') && isExpanded(businessObject)) {
35767
+ if (is$1(businessObject, 'bpmn:SubProcess') && isExpanded(element)) {
35309
35768
 
35310
35769
  entries = filter(SUBPROCESS_EXPANDED, differentType);
35311
35770
 
@@ -35313,7 +35772,7 @@
35313
35772
  }
35314
35773
 
35315
35774
  // collapsed ad hoc sub processes
35316
- if (is$1(businessObject, 'bpmn:AdHocSubProcess') && !isExpanded(businessObject)) {
35775
+ if (is$1(businessObject, 'bpmn:AdHocSubProcess') && !isExpanded(element)) {
35317
35776
 
35318
35777
  entries = filter(TASK, function(entry) {
35319
35778
 
@@ -35339,7 +35798,7 @@
35339
35798
  entries = filter(TASK, differentType);
35340
35799
 
35341
35800
  // collapsed SubProcess can not be replaced with itself
35342
- if (is$1(businessObject, 'bpmn:SubProcess') && !isExpanded(businessObject)) {
35801
+ if (is$1(businessObject, 'bpmn:SubProcess') && !isExpanded(element)) {
35343
35802
  entries = filter(entries, function(entry) {
35344
35803
  return entry.label !== 'Sub Process (collapsed)';
35345
35804
  });
@@ -36245,7 +36704,7 @@
36245
36704
  }
36246
36705
 
36247
36706
 
36248
- if (isAny(businessObject, [ 'bpmn:Lane', 'bpmn:Participant' ]) && isExpanded(businessObject)) {
36707
+ if (isAny(businessObject, [ 'bpmn:Lane', 'bpmn:Participant' ]) && isExpanded(element)) {
36249
36708
 
36250
36709
  var childLanes = getChildLanes(element);
36251
36710
 
@@ -38472,75 +38931,6 @@
38472
38931
  keyboardMoveSelection: [ 'type', KeyboardMoveSelection ]
38473
38932
  };
38474
38933
 
38475
- /**
38476
- * Adds change support to the diagram, including
38477
- *
38478
- * <ul>
38479
- * <li>redrawing shapes and connections on change</li>
38480
- * </ul>
38481
- *
38482
- * @param {EventBus} eventBus
38483
- * @param {Canvas} canvas
38484
- * @param {ElementRegistry} elementRegistry
38485
- * @param {GraphicsFactory} graphicsFactory
38486
- */
38487
- function ChangeSupport(
38488
- eventBus, canvas, elementRegistry,
38489
- graphicsFactory) {
38490
-
38491
-
38492
- // redraw shapes / connections on change
38493
-
38494
- eventBus.on('element.changed', function(event) {
38495
-
38496
- var element = event.element;
38497
-
38498
- // element might have been deleted and replaced by new element with same ID
38499
- // thus check for parent of element except for root element
38500
- if (element.parent || element === canvas.getRootElement()) {
38501
- event.gfx = elementRegistry.getGraphics(element);
38502
- }
38503
-
38504
- // shape + gfx may have been deleted
38505
- if (!event.gfx) {
38506
- return;
38507
- }
38508
-
38509
- eventBus.fire(getType(element) + '.changed', event);
38510
- });
38511
-
38512
- eventBus.on('elements.changed', function(event) {
38513
-
38514
- var elements = event.elements;
38515
-
38516
- elements.forEach(function(e) {
38517
- eventBus.fire('element.changed', { element: e });
38518
- });
38519
-
38520
- graphicsFactory.updateContainments(elements);
38521
- });
38522
-
38523
- eventBus.on('shape.changed', function(event) {
38524
- graphicsFactory.update('shape', event.element, event.gfx);
38525
- });
38526
-
38527
- eventBus.on('connection.changed', function(event) {
38528
- graphicsFactory.update('connection', event.element, event.gfx);
38529
- });
38530
- }
38531
-
38532
- ChangeSupport.$inject = [
38533
- 'eventBus',
38534
- 'canvas',
38535
- 'elementRegistry',
38536
- 'graphicsFactory'
38537
- ];
38538
-
38539
- var ChangeSupportModule = {
38540
- __init__: [ 'changeSupport'],
38541
- changeSupport: [ 'type', ChangeSupport ]
38542
- };
38543
-
38544
38934
  var DEFAULT_MIN_WIDTH = 10;
38545
38935
 
38546
38936
 
@@ -39632,9 +40022,9 @@
39632
40022
  // helpers ///////////////////
39633
40023
 
39634
40024
  function getStrokeColor(element, defaultColor) {
39635
- var bo = getBusinessObject(element);
40025
+ var di = getDi(element);
39636
40026
 
39637
- return bo.di.get('stroke') || defaultColor || 'black';
40027
+ return di.get('stroke') || defaultColor || 'black';
39638
40028
  }
39639
40029
 
39640
40030
  var LabelEditingModule = {
@@ -40845,21 +41235,23 @@
40845
41235
 
40846
41236
  UpdateSemanticParentHandler.prototype.execute = function(context) {
40847
41237
  var dataStoreBo = context.dataStoreBo,
41238
+ dataStoreDi = context.dataStoreDi,
40848
41239
  newSemanticParent = context.newSemanticParent,
40849
41240
  newDiParent = context.newDiParent;
40850
41241
 
40851
41242
  context.oldSemanticParent = dataStoreBo.$parent;
40852
- context.oldDiParent = dataStoreBo.di.$parent;
41243
+ context.oldDiParent = dataStoreDi.$parent;
40853
41244
 
40854
41245
  // update semantic parent
40855
41246
  this._bpmnUpdater.updateSemanticParent(dataStoreBo, newSemanticParent);
40856
41247
 
40857
41248
  // update DI parent
40858
- this._bpmnUpdater.updateDiParent(dataStoreBo.di, newDiParent);
41249
+ this._bpmnUpdater.updateDiParent(dataStoreDi, newDiParent);
40859
41250
  };
40860
41251
 
40861
41252
  UpdateSemanticParentHandler.prototype.revert = function(context) {
40862
41253
  var dataStoreBo = context.dataStoreBo,
41254
+ dataStoreDi = context.dataStoreDi,
40863
41255
  oldSemanticParent = context.oldSemanticParent,
40864
41256
  oldDiParent = context.oldDiParent;
40865
41257
 
@@ -40867,7 +41259,7 @@
40867
41259
  this._bpmnUpdater.updateSemanticParent(dataStoreBo, oldSemanticParent);
40868
41260
 
40869
41261
  // update DI parent
40870
- this._bpmnUpdater.updateDiParent(dataStoreBo.di, oldDiParent);
41262
+ this._bpmnUpdater.updateDiParent(dataStoreDi, oldDiParent);
40871
41263
  };
40872
41264
 
40873
41265
  /**
@@ -40903,8 +41295,9 @@
40903
41295
 
40904
41296
  commandStack.execute('dataStore.updateContainment', {
40905
41297
  dataStoreBo: dataStoreBo,
41298
+ dataStoreDi: getDi(dataStore),
40906
41299
  newSemanticParent: newDataStoreParentBo.processRef || newDataStoreParentBo,
40907
- newDiParent: newDataStoreParentBo.di
41300
+ newDiParent: getDi(newDataStoreParent)
40908
41301
  });
40909
41302
  }
40910
41303
  }
@@ -41844,12 +42237,14 @@
41844
42237
  ];
41845
42238
 
41846
42239
  this.executed([ 'shape.move', 'shape.create', 'shape.resize' ], function(event) {
41847
- var bo = getBusinessObject(event.context.shape);
42240
+ var shape = event.context.shape,
42241
+ bo = getBusinessObject(shape),
42242
+ di = getDi(shape);
41848
42243
 
41849
- if (isAny(bo, elementTypesToUpdate) && !bo.di.get('isHorizontal')) {
42244
+ if (isAny(bo, elementTypesToUpdate) && !di.get('isHorizontal')) {
41850
42245
 
41851
42246
  // set attribute directly to avoid modeling#updateProperty side effects
41852
- bo.di.set('isHorizontal', true);
42247
+ di.set('isHorizontal', true);
41853
42248
  }
41854
42249
  });
41855
42250
 
@@ -42655,27 +43050,27 @@
42655
43050
 
42656
43051
  var context = event.context,
42657
43052
  element = context.shape,
42658
- businessObject,
43053
+ labelTarget = context.labelTarget,
42659
43054
  di;
42660
43055
 
42661
43056
  // we want to trigger on real labels only
42662
- if (!element.labelTarget) {
43057
+ if (!labelTarget) {
42663
43058
  return;
42664
43059
  }
42665
43060
 
42666
43061
  // we want to trigger on BPMN elements only
42667
- if (!is$1(element.labelTarget || element, 'bpmn:BaseElement')) {
43062
+ if (!is$1(labelTarget, 'bpmn:BaseElement')) {
42668
43063
  return;
42669
43064
  }
42670
43065
 
42671
- businessObject = element.businessObject,
42672
- di = businessObject.di;
42673
-
43066
+ di = getDi(labelTarget);
42674
43067
 
42675
43068
  if (!di.label) {
42676
43069
  di.label = bpmnFactory.create('bpmndi:BPMNLabel', {
42677
43070
  bounds: bpmnFactory.create('dc:Bounds')
42678
43071
  });
43072
+
43073
+ element.di = di;
42679
43074
  }
42680
43075
 
42681
43076
  assign(di.label.bounds, {
@@ -43961,11 +44356,11 @@
43961
44356
  hideEmptyLabels(shape.children);
43962
44357
 
43963
44358
  // remove collapsed marker
43964
- getBusinessObject(shape).di.isExpanded = true;
44359
+ getDi(shape).isExpanded = true;
43965
44360
  } else {
43966
44361
 
43967
44362
  // place collapsed marker
43968
- getBusinessObject(shape).di.isExpanded = false;
44363
+ getDi(shape).isExpanded = false;
43969
44364
  }
43970
44365
  });
43971
44366
 
@@ -43977,16 +44372,16 @@
43977
44372
 
43978
44373
  // revert removing/placing collapsed marker
43979
44374
  if (!shape.collapsed) {
43980
- getBusinessObject(shape).di.isExpanded = true;
44375
+ getDi(shape).isExpanded = true;
43981
44376
 
43982
44377
  } else {
43983
- getBusinessObject(shape).di.isExpanded = false;
44378
+ getDi(shape).isExpanded = false;
43984
44379
  }
43985
44380
  });
43986
44381
 
43987
44382
  this.postExecuted([ 'shape.toggleCollapse' ], LOW_PRIORITY$8, function(e) {
43988
44383
  var shape = e.context.shape,
43989
- defaultSize = elementFactory._getDefaultSize(shape),
44384
+ defaultSize = elementFactory.getDefaultSize(shape),
43990
44385
  newBounds;
43991
44386
 
43992
44387
  if (shape.collapsed) {
@@ -45292,7 +45687,7 @@
45292
45687
 
45293
45688
  function orderDi() {
45294
45689
  var root = canvas.getRootElement(),
45295
- rootDi = getBusinessObject(root).di,
45690
+ rootDi = getDi(root),
45296
45691
  elements,
45297
45692
  diElements;
45298
45693
 
@@ -48053,11 +48448,10 @@
48053
48448
  };
48054
48449
 
48055
48450
 
48056
- BpmnFactory.prototype.createDiShape = function(semantic, bounds, attrs) {
48057
-
48451
+ BpmnFactory.prototype.createDiShape = function(semantic, attrs) {
48058
48452
  return this.create('bpmndi:BPMNShape', assign({
48059
48453
  bpmnElement: semantic,
48060
- bounds: this.createDiBounds(bounds)
48454
+ bounds: this.createDiBounds()
48061
48455
  }, attrs));
48062
48456
  };
48063
48457
 
@@ -48080,16 +48474,17 @@
48080
48474
  };
48081
48475
 
48082
48476
 
48083
- BpmnFactory.prototype.createDiEdge = function(semantic, waypoints, attrs) {
48477
+ BpmnFactory.prototype.createDiEdge = function(semantic, attrs) {
48084
48478
  return this.create('bpmndi:BPMNEdge', assign({
48085
- bpmnElement: semantic
48479
+ bpmnElement: semantic,
48480
+ waypoints: this.createDiWaypoints([])
48086
48481
  }, attrs));
48087
48482
  };
48088
48483
 
48089
- BpmnFactory.prototype.createDiPlane = function(semantic) {
48090
- return this.create('bpmndi:BPMNPlane', {
48484
+ BpmnFactory.prototype.createDiPlane = function(semantic, attrs) {
48485
+ return this.create('bpmndi:BPMNPlane', assign({
48091
48486
  bpmnElement: semantic
48092
- });
48487
+ }, attrs));
48093
48488
  };
48094
48489
 
48095
48490
  /**
@@ -48374,8 +48769,9 @@
48374
48769
  var parentShape = element.parent;
48375
48770
 
48376
48771
  var businessObject = element.businessObject,
48772
+ di = getDi(element),
48377
48773
  parentBusinessObject = parentShape && parentShape.businessObject,
48378
- parentDi = parentBusinessObject && parentBusinessObject.di;
48774
+ parentDi = getDi(parentShape);
48379
48775
 
48380
48776
  if (is$1(element, 'bpmn:FlowNode')) {
48381
48777
  this.updateFlowNodeRefs(businessObject, parentBusinessObject, oldParent && oldParent.businessObject);
@@ -48403,13 +48799,13 @@
48403
48799
  this.updateSemanticParent(businessObject.dataObjectRef, parentBusinessObject);
48404
48800
  }
48405
48801
 
48406
- this.updateDiParent(businessObject.di, parentDi);
48802
+ this.updateDiParent(di, parentDi);
48407
48803
  };
48408
48804
 
48409
48805
 
48410
48806
  BpmnUpdater.prototype.updateBounds = function(shape) {
48411
48807
 
48412
- var di = shape.businessObject.di;
48808
+ var di = getDi(shape);
48413
48809
 
48414
48810
  var target = (shape instanceof Label) ? this._getLabel(di) : di;
48415
48811
 
@@ -48449,14 +48845,17 @@
48449
48845
 
48450
48846
 
48451
48847
  // update existing sourceElement and targetElement di information
48452
- BpmnUpdater.prototype.updateDiConnection = function(di, newSource, newTarget) {
48848
+ BpmnUpdater.prototype.updateDiConnection = function(connection, newSource, newTarget) {
48849
+ var connectionDi = getDi(connection),
48850
+ newSourceDi = getDi(newSource),
48851
+ newTargetDi = getDi(newTarget);
48453
48852
 
48454
- if (di.sourceElement && di.sourceElement.bpmnElement !== newSource) {
48455
- di.sourceElement = newSource && newSource.di;
48853
+ if (connectionDi.sourceElement && connectionDi.sourceElement.bpmnElement !== getBusinessObject(newSource)) {
48854
+ connectionDi.sourceElement = newSource && newSourceDi;
48456
48855
  }
48457
48856
 
48458
- if (di.targetElement && di.targetElement.bpmnElement !== newTarget) {
48459
- di.targetElement = newTarget && newTarget.di;
48857
+ if (connectionDi.targetElement && connectionDi.targetElement.bpmnElement !== getBusinessObject(newTarget)) {
48858
+ connectionDi.targetElement = newTarget && newTargetDi;
48460
48859
  }
48461
48860
 
48462
48861
  };
@@ -48681,69 +49080,72 @@
48681
49080
 
48682
49081
 
48683
49082
  BpmnUpdater.prototype.updateConnectionWaypoints = function(connection) {
48684
- connection.businessObject.di.set('waypoint', this._bpmnFactory.createDiWaypoints(connection.waypoints));
49083
+ var di = getDi(connection);
49084
+
49085
+ di.set('waypoint', this._bpmnFactory.createDiWaypoints(connection.waypoints));
48685
49086
  };
48686
49087
 
48687
49088
 
48688
49089
  BpmnUpdater.prototype.updateConnection = function(context) {
48689
-
48690
49090
  var connection = context.connection,
48691
49091
  businessObject = getBusinessObject(connection),
48692
- newSource = getBusinessObject(connection.source),
48693
- newTarget = getBusinessObject(connection.target),
49092
+ newSource = connection.source,
49093
+ newSourceBo = getBusinessObject(newSource),
49094
+ newTarget = connection.target,
49095
+ newTargetBo = getBusinessObject(connection.target),
48694
49096
  visualParent;
48695
49097
 
48696
49098
  if (!is$1(businessObject, 'bpmn:DataAssociation')) {
48697
49099
 
48698
49100
  var inverseSet = is$1(businessObject, 'bpmn:SequenceFlow');
48699
49101
 
48700
- if (businessObject.sourceRef !== newSource) {
49102
+ if (businessObject.sourceRef !== newSourceBo) {
48701
49103
  if (inverseSet) {
48702
49104
  remove(businessObject.sourceRef && businessObject.sourceRef.get('outgoing'), businessObject);
48703
49105
 
48704
- if (newSource && newSource.get('outgoing')) {
48705
- newSource.get('outgoing').push(businessObject);
49106
+ if (newSourceBo && newSourceBo.get('outgoing')) {
49107
+ newSourceBo.get('outgoing').push(businessObject);
48706
49108
  }
48707
49109
  }
48708
49110
 
48709
- businessObject.sourceRef = newSource;
49111
+ businessObject.sourceRef = newSourceBo;
48710
49112
  }
48711
49113
 
48712
- if (businessObject.targetRef !== newTarget) {
49114
+ if (businessObject.targetRef !== newTargetBo) {
48713
49115
  if (inverseSet) {
48714
49116
  remove(businessObject.targetRef && businessObject.targetRef.get('incoming'), businessObject);
48715
49117
 
48716
- if (newTarget && newTarget.get('incoming')) {
48717
- newTarget.get('incoming').push(businessObject);
49118
+ if (newTargetBo && newTargetBo.get('incoming')) {
49119
+ newTargetBo.get('incoming').push(businessObject);
48718
49120
  }
48719
49121
  }
48720
49122
 
48721
- businessObject.targetRef = newTarget;
49123
+ businessObject.targetRef = newTargetBo;
48722
49124
  }
48723
49125
  } else
48724
49126
 
48725
49127
  if (is$1(businessObject, 'bpmn:DataInputAssociation')) {
48726
49128
 
48727
49129
  // handle obnoxious isMsome sourceRef
48728
- businessObject.get('sourceRef')[0] = newSource;
49130
+ businessObject.get('sourceRef')[0] = newSourceBo;
48729
49131
 
48730
- visualParent = context.parent || context.newParent || newTarget;
49132
+ visualParent = context.parent || context.newParent || newTargetBo;
48731
49133
 
48732
- this.updateSemanticParent(businessObject, newTarget, visualParent);
49134
+ this.updateSemanticParent(businessObject, newTargetBo, visualParent);
48733
49135
  } else
48734
49136
 
48735
49137
  if (is$1(businessObject, 'bpmn:DataOutputAssociation')) {
48736
- visualParent = context.parent || context.newParent || newSource;
49138
+ visualParent = context.parent || context.newParent || newSourceBo;
48737
49139
 
48738
- this.updateSemanticParent(businessObject, newSource, visualParent);
49140
+ this.updateSemanticParent(businessObject, newSourceBo, visualParent);
48739
49141
 
48740
49142
  // targetRef = new target
48741
- businessObject.targetRef = newTarget;
49143
+ businessObject.targetRef = newTargetBo;
48742
49144
  }
48743
49145
 
48744
49146
  this.updateConnectionWaypoints(connection);
48745
49147
 
48746
- this.updateDiConnection(businessObject.di, newSource, newTarget);
49148
+ this.updateDiConnection(connection, newSource, newTarget);
48747
49149
  };
48748
49150
 
48749
49151
 
@@ -48805,7 +49207,8 @@
48805
49207
  // we assume their businessObjects have already been created
48806
49208
  // and wired via attrs
48807
49209
  if (elementType === 'label') {
48808
- return this.baseCreate(elementType, assign({ type: 'label' }, DEFAULT_LABEL_SIZE, attrs));
49210
+ var di = attrs.di || this._bpmnFactory.createDiLabel();
49211
+ return this.baseCreate(elementType, assign({ type: 'label', di: di }, DEFAULT_LABEL_SIZE, attrs));
48809
49212
  }
48810
49213
 
48811
49214
  return this.createBpmnElement(elementType, attrs);
@@ -48817,7 +49220,8 @@
48817
49220
 
48818
49221
  attrs = attrs || {};
48819
49222
 
48820
- var businessObject = attrs.businessObject;
49223
+ var businessObject = attrs.businessObject,
49224
+ di = attrs.di;
48821
49225
 
48822
49226
  if (!businessObject) {
48823
49227
  if (!attrs.type) {
@@ -48825,22 +49229,23 @@
48825
49229
  }
48826
49230
 
48827
49231
  businessObject = this._bpmnFactory.create(attrs.type);
49232
+
49233
+ ensureCompatDiRef(businessObject);
48828
49234
  }
48829
49235
 
48830
- if (!businessObject.di) {
49236
+ if (!isModdleDi(di)) {
49237
+ var diAttrs = assign(
49238
+ di || {},
49239
+ { id: businessObject.id + '_di' }
49240
+ );
49241
+
48831
49242
  if (elementType === 'root') {
48832
- businessObject.di = this._bpmnFactory.createDiPlane(businessObject, [], {
48833
- id: businessObject.id + '_di'
48834
- });
49243
+ di = this._bpmnFactory.createDiPlane(businessObject, diAttrs);
48835
49244
  } else
48836
49245
  if (elementType === 'connection') {
48837
- businessObject.di = this._bpmnFactory.createDiEdge(businessObject, [], {
48838
- id: businessObject.id + '_di'
48839
- });
49246
+ di = this._bpmnFactory.createDiEdge(businessObject, diAttrs);
48840
49247
  } else {
48841
- businessObject.di = this._bpmnFactory.createDiShape(businessObject, {}, {
48842
- id: businessObject.id + '_di'
48843
- });
49248
+ di = this._bpmnFactory.createDiShape(businessObject, diAttrs);
48844
49249
  }
48845
49250
  }
48846
49251
 
@@ -48850,12 +49255,6 @@
48850
49255
  }, attrs);
48851
49256
  }
48852
49257
 
48853
- if (attrs.di) {
48854
- assign(businessObject.di, attrs.di);
48855
-
48856
- delete attrs.di;
48857
- }
48858
-
48859
49258
  applyAttributes(businessObject, attrs, [
48860
49259
  'processRef',
48861
49260
  'isInterrupting',
@@ -48864,11 +49263,11 @@
48864
49263
  ]);
48865
49264
 
48866
49265
  if (attrs.isExpanded) {
48867
- applyAttribute(businessObject.di, attrs, 'isExpanded');
49266
+ applyAttribute(di, attrs, 'isExpanded');
48868
49267
  }
48869
49268
 
48870
49269
  if (is$1(businessObject, 'bpmn:ExclusiveGateway')) {
48871
- businessObject.di.isMarkerVisible = true;
49270
+ di.isMarkerVisible = true;
48872
49271
  }
48873
49272
 
48874
49273
  var eventDefinitions,
@@ -48890,65 +49289,69 @@
48890
49289
  delete attrs.eventDefinitionType;
48891
49290
  }
48892
49291
 
48893
- size = this._getDefaultSize(businessObject);
49292
+ size = this.getDefaultSize(businessObject, di);
48894
49293
 
48895
49294
  attrs = assign({
48896
- businessObject: businessObject,
48897
49295
  id: businessObject.id
48898
- }, size, attrs);
49296
+ }, size, attrs, {
49297
+ businessObject: businessObject,
49298
+ di: di
49299
+ });
48899
49300
 
48900
49301
  return this.baseCreate(elementType, attrs);
48901
49302
  };
48902
49303
 
48903
49304
 
48904
- ElementFactory.prototype._getDefaultSize = function(semantic) {
49305
+ ElementFactory.prototype.getDefaultSize = function(element, di) {
48905
49306
 
48906
- if (is$1(semantic, 'bpmn:SubProcess')) {
49307
+ var bo = getBusinessObject(element);
49308
+ di = di || getDi(element);
48907
49309
 
48908
- if (isExpanded(semantic)) {
49310
+ if (is$1(bo, 'bpmn:SubProcess')) {
49311
+ if (isExpanded(bo, di)) {
48909
49312
  return { width: 350, height: 200 };
48910
49313
  } else {
48911
49314
  return { width: 100, height: 80 };
48912
49315
  }
48913
49316
  }
48914
49317
 
48915
- if (is$1(semantic, 'bpmn:Task')) {
49318
+ if (is$1(bo, 'bpmn:Task')) {
48916
49319
  return { width: 100, height: 80 };
48917
49320
  }
48918
49321
 
48919
- if (is$1(semantic, 'bpmn:Gateway')) {
49322
+ if (is$1(bo, 'bpmn:Gateway')) {
48920
49323
  return { width: 50, height: 50 };
48921
49324
  }
48922
49325
 
48923
- if (is$1(semantic, 'bpmn:Event')) {
49326
+ if (is$1(bo, 'bpmn:Event')) {
48924
49327
  return { width: 36, height: 36 };
48925
49328
  }
48926
49329
 
48927
- if (is$1(semantic, 'bpmn:Participant')) {
48928
- if (isExpanded(semantic)) {
49330
+ if (is$1(bo, 'bpmn:Participant')) {
49331
+ if (isExpanded(bo, di)) {
48929
49332
  return { width: 600, height: 250 };
48930
49333
  } else {
48931
49334
  return { width: 400, height: 60 };
48932
49335
  }
48933
49336
  }
48934
49337
 
48935
- if (is$1(semantic, 'bpmn:Lane')) {
49338
+ if (is$1(bo, 'bpmn:Lane')) {
48936
49339
  return { width: 400, height: 100 };
48937
49340
  }
48938
49341
 
48939
- if (is$1(semantic, 'bpmn:DataObjectReference')) {
49342
+ if (is$1(bo, 'bpmn:DataObjectReference')) {
48940
49343
  return { width: 36, height: 50 };
48941
49344
  }
48942
49345
 
48943
- if (is$1(semantic, 'bpmn:DataStoreReference')) {
49346
+ if (is$1(bo, 'bpmn:DataStoreReference')) {
48944
49347
  return { width: 50, height: 50 };
48945
49348
  }
48946
49349
 
48947
- if (is$1(semantic, 'bpmn:TextAnnotation')) {
49350
+ if (is$1(bo, 'bpmn:TextAnnotation')) {
48948
49351
  return { width: 100, height: 30 };
48949
49352
  }
48950
49353
 
48951
- if (is$1(semantic, 'bpmn:Group')) {
49354
+ if (is$1(bo, 'bpmn:Group')) {
48952
49355
  return { width: 300, height: 300 };
48953
49356
  }
48954
49357
 
@@ -49013,6 +49416,16 @@
49013
49416
  delete attrs[attributeName];
49014
49417
  }
49015
49418
 
49419
+
49420
+ function isModdleDi(element) {
49421
+ return isAny(element, [
49422
+ 'bpmndi:BPMNShape',
49423
+ 'bpmndi:BPMNEdge',
49424
+ 'bpmndi:BPMNDiagram',
49425
+ 'bpmndi:BPMNPlane',
49426
+ ]);
49427
+ }
49428
+
49016
49429
  /**
49017
49430
  * A handler that align elements in a certain way.
49018
49431
  *
@@ -51480,7 +51893,7 @@
51480
51893
 
51481
51894
  var businessObject = element.businessObject,
51482
51895
  properties = unwrapBusinessObjects(context.properties),
51483
- oldProperties = context.oldProperties || getProperties(businessObject, properties);
51896
+ oldProperties = context.oldProperties || getProperties(element, properties);
51484
51897
 
51485
51898
  if (isIdChange(properties, businessObject)) {
51486
51899
  ids.unclaim(businessObject[ID]);
@@ -51503,7 +51916,7 @@
51503
51916
  }
51504
51917
 
51505
51918
  // update properties
51506
- setProperties(businessObject, properties);
51919
+ setProperties(element, properties);
51507
51920
 
51508
51921
  // store old values
51509
51922
  context.oldProperties = oldProperties;
@@ -51548,7 +51961,7 @@
51548
51961
  ids = this._moddle.ids;
51549
51962
 
51550
51963
  // update properties
51551
- setProperties(businessObject, oldProperties);
51964
+ setProperties(element, oldProperties);
51552
51965
 
51553
51966
  if (isIdChange(properties, businessObject)) {
51554
51967
  ids.unclaim(properties[ID]);
@@ -51567,16 +51980,19 @@
51567
51980
  }
51568
51981
 
51569
51982
 
51570
- function getProperties(businessObject, properties) {
51571
- var propertyNames = keys(properties);
51983
+ function getProperties(element, properties) {
51984
+ var propertyNames = keys(properties),
51985
+ businessObject = element.businessObject,
51986
+ di = getDi(element);
51572
51987
 
51573
51988
  return reduce(propertyNames, function(result, key) {
51574
51989
 
51575
51990
  // handle DI separately
51576
51991
  if (key !== DI) {
51577
51992
  result[key] = businessObject.get(key);
51993
+
51578
51994
  } else {
51579
- result[key] = getDiProperties(businessObject.di, keys(properties.di));
51995
+ result[key] = getDiProperties(di, keys(properties.di));
51580
51996
  }
51581
51997
 
51582
51998
  return result;
@@ -51586,23 +52002,26 @@
51586
52002
 
51587
52003
  function getDiProperties(di, propertyNames) {
51588
52004
  return reduce(propertyNames, function(result, key) {
51589
- result[key] = di.get(key);
52005
+ result[key] = di && di.get(key);
51590
52006
 
51591
52007
  return result;
51592
52008
  }, {});
51593
52009
  }
51594
52010
 
51595
52011
 
51596
- function setProperties(businessObject, properties) {
52012
+ function setProperties(element, properties) {
52013
+ var businessObject = element.businessObject,
52014
+ di = getDi(element);
52015
+
51597
52016
  forEach(properties, function(value, key) {
51598
52017
 
51599
52018
  if (key !== DI) {
51600
52019
  businessObject.set(key, value);
51601
52020
  } else {
51602
52021
 
51603
- // only update, if businessObject.di exists
51604
- if (businessObject.di) {
51605
- setDiProperties(businessObject.di, value);
52022
+ // only update, if di exists
52023
+ if (di) {
52024
+ setDiProperties(di, value);
51606
52025
  }
51607
52026
  }
51608
52027
  });
@@ -51660,7 +52079,7 @@
51660
52079
  oldRoot = canvas.getRootElement(),
51661
52080
  oldRootBusinessObject = oldRoot.businessObject,
51662
52081
  bpmnDefinitions = oldRootBusinessObject.$parent,
51663
- diPlane = oldRootBusinessObject.di;
52082
+ diPlane = getDi(oldRoot);
51664
52083
 
51665
52084
  // (1) replace process old <> new root
51666
52085
  canvas.setRootElement(newRoot, true);
@@ -51673,10 +52092,10 @@
51673
52092
  oldRootBusinessObject.$parent = null;
51674
52093
 
51675
52094
  // (3) wire di
51676
- oldRootBusinessObject.di = null;
52095
+ oldRoot.di = null;
51677
52096
 
51678
52097
  diPlane.bpmnElement = newRootBusinessObject;
51679
- newRootBusinessObject.di = diPlane;
52098
+ newRoot.di = diPlane;
51680
52099
 
51681
52100
  context.oldRoot = oldRoot;
51682
52101
 
@@ -51694,7 +52113,7 @@
51694
52113
  oldRoot = context.oldRoot,
51695
52114
  oldRootBusinessObject = oldRoot.businessObject,
51696
52115
  bpmnDefinitions = newRootBusinessObject.$parent,
51697
- diPlane = newRootBusinessObject.di;
52116
+ diPlane = getDi(newRoot);
51698
52117
 
51699
52118
  // (1) replace process old <> new root
51700
52119
  canvas.setRootElement(oldRoot, true);
@@ -51707,10 +52126,10 @@
51707
52126
  oldRootBusinessObject.$parent = bpmnDefinitions;
51708
52127
 
51709
52128
  // (3) wire di
51710
- newRootBusinessObject.di = null;
52129
+ newRoot.di = null;
51711
52130
 
51712
52131
  diPlane.bpmnElement = oldRootBusinessObject;
51713
- oldRootBusinessObject.di = diPlane;
52132
+ oldRoot.di = diPlane;
51714
52133
 
51715
52134
  // TODO(nikku): return changed elements?
51716
52135
  // return [ newRoot, oldRoot ];
@@ -52379,7 +52798,8 @@
52379
52798
 
52380
52799
  modeling.createLabel(element, labelCenter, {
52381
52800
  id: businessObject.id + '_label',
52382
- businessObject: businessObject
52801
+ businessObject: businessObject,
52802
+ di: element.di
52383
52803
  });
52384
52804
  }
52385
52805
  }
@@ -54382,7 +54802,9 @@
54382
54802
  ENTRY_SELECTOR = '.entry',
54383
54803
  ELEMENT_SELECTOR = TOGGLE_SELECTOR + ', ' + ENTRY_SELECTOR;
54384
54804
 
54385
- var PALETTE_OPEN_CLS = 'open',
54805
+ var PALETTE_PREFIX = 'djs-palette-',
54806
+ PALETTE_SHOWN_CLS = 'shown',
54807
+ PALETTE_OPEN_CLS = 'open',
54386
54808
  PALETTE_TWO_COLUMN_CLS = 'two-column';
54387
54809
 
54388
54810
  var DEFAULT_PRIORITY = 1000;
@@ -54500,6 +54922,7 @@
54500
54922
  var container = this._container = domify(Palette.HTML_MARKUP);
54501
54923
 
54502
54924
  parentContainer.appendChild(container);
54925
+ classes$1(parentContainer).add(PALETTE_PREFIX + PALETTE_SHOWN_CLS);
54503
54926
 
54504
54927
  delegate.bind(container, ELEMENT_SELECTOR, 'click', function(event) {
54505
54928
 
@@ -54557,7 +54980,8 @@
54557
54980
 
54558
54981
  var twoColumn;
54559
54982
 
54560
- var cls = classes$1(container);
54983
+ var cls = classes$1(container),
54984
+ parentCls = classes$1(parent);
54561
54985
 
54562
54986
  if ('twoColumn' in state) {
54563
54987
  twoColumn = state.twoColumn;
@@ -54567,9 +54991,11 @@
54567
54991
 
54568
54992
  // always update two column
54569
54993
  cls.toggle(PALETTE_TWO_COLUMN_CLS, twoColumn);
54994
+ parentCls.toggle(PALETTE_PREFIX + PALETTE_TWO_COLUMN_CLS, twoColumn);
54570
54995
 
54571
54996
  if ('open' in state) {
54572
54997
  cls.toggle(PALETTE_OPEN_CLS, state.open);
54998
+ parentCls.toggle(PALETTE_PREFIX + PALETTE_OPEN_CLS, state.open);
54573
54999
  }
54574
55000
 
54575
55001
  eventBus.fire('palette.changed', {
@@ -55440,7 +55866,8 @@
55440
55866
  var shape = elementFactory.createShape(assign({ type: type }, options));
55441
55867
 
55442
55868
  if (options) {
55443
- shape.businessObject.di.isExpanded = options.isExpanded;
55869
+ var di = getDi(shape);
55870
+ di.isExpanded = options.isExpanded;
55444
55871
  }
55445
55872
 
55446
55873
  create.start(event, shape);