bpmn-js 9.3.0 → 10.0.0-alpha.1

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 (32) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/assets/bpmn-js.css +4 -5
  3. package/dist/assets/diagram-js.css +18 -8
  4. package/dist/bpmn-modeler.development.js +547 -363
  5. package/dist/bpmn-modeler.production.min.js +6 -6
  6. package/dist/bpmn-navigated-viewer.development.js +85 -77
  7. package/dist/bpmn-navigated-viewer.production.min.js +6 -6
  8. package/dist/bpmn-viewer.development.js +27 -21
  9. package/dist/bpmn-viewer.production.min.js +6 -6
  10. package/lib/features/copy-paste/BpmnCopyPaste.js +75 -69
  11. package/lib/features/copy-paste/ModdleCopy.js +26 -13
  12. package/lib/features/grid-snapping/behavior/{AutoPlaceBehavior.js → GridSnappingAutoPlaceBehavior.js} +2 -2
  13. package/lib/features/grid-snapping/behavior/{LayoutConnectionBehavior.js → GridSnappingLayoutConnectionBehavior.js} +4 -4
  14. package/lib/features/grid-snapping/behavior/{CreateParticipantBehavior.js → GridSnappingParticipantBehavior.js} +2 -2
  15. package/lib/features/grid-snapping/behavior/index.js +7 -7
  16. package/lib/features/label-editing/LabelEditingProvider.js +0 -22
  17. package/lib/features/modeling/ElementFactory.js +18 -8
  18. package/lib/features/modeling/behavior/BoundaryEventBehavior.js +1 -16
  19. package/lib/features/modeling/behavior/GroupBehavior.js +205 -93
  20. package/lib/features/modeling/behavior/ReplaceElementBehaviour.js +8 -4
  21. package/lib/features/modeling/behavior/ResizeBehavior.js +2 -0
  22. package/lib/features/modeling/behavior/RootElementReferenceBehavior.js +7 -8
  23. package/lib/features/modeling/behavior/SpaceToolBehavior.js +5 -0
  24. package/lib/features/modeling/behavior/util/CategoryUtil.js +66 -13
  25. package/lib/features/modeling/cmd/UpdateModdlePropertiesHandler.js +3 -0
  26. package/package.json +2 -2
  27. package/test/helper/index.js +25 -0
  28. package/lib/features/.DS_Store +0 -0
  29. package/lib/features/align-elements/.DS_Store +0 -0
  30. package/lib/features/distribute-elements/.DS_Store +0 -0
  31. package/lib/features/distribute-elements/dist/distribute-horizontally-tool.svg +0 -1
  32. package/lib/features/distribute-elements/dist/distribute-vertically-tool.svg +0 -1
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * bpmn-js - bpmn-modeler v9.3.0
2
+ * bpmn-js - bpmn-modeler v10.0.0-alpha.1
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: 2022-07-07
11
+ * Date: 2022-08-17
12
12
  */
13
13
  (function (global, factory) {
14
14
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -2393,20 +2393,11 @@
2393
2393
  return function() {
2394
2394
  initializers.forEach(function(initializer) {
2395
2395
 
2396
- try {
2397
-
2398
- // eagerly resolve component (fn or string)
2399
- if (typeof initializer === 'string') {
2400
- injector.get(initializer);
2401
- } else {
2402
- injector.invoke(initializer);
2403
- }
2404
- } catch (error) {
2405
- if (typeof AggregateError !== 'undefined') {
2406
- throw new AggregateError([ error ], 'Failed to initialize!');
2407
- }
2408
-
2409
- throw new Error('Failed to initialize! ' + error.message);
2396
+ // eagerly resolve component (fn or string)
2397
+ if (typeof initializer === 'string') {
2398
+ injector.get(initializer);
2399
+ } else {
2400
+ injector.invoke(initializer);
2410
2401
  }
2411
2402
  });
2412
2403
  };
@@ -4749,7 +4740,19 @@
4749
4740
  var container = this._container = createContainer(config);
4750
4741
 
4751
4742
  var svg = this._svg = create$1('svg');
4752
- attr(svg, { width: '100%', height: '100%' });
4743
+
4744
+ attr(svg, {
4745
+ width: '100%',
4746
+ height: '100%'
4747
+ });
4748
+
4749
+ attr$1(svg, 'tabindex', 0);
4750
+
4751
+ eventBus.on('element.hover', function() {
4752
+ if (document.activeElement === document.body) {
4753
+ svg.focus();
4754
+ }
4755
+ });
4753
4756
 
4754
4757
  append(container, svg);
4755
4758
 
@@ -19354,11 +19357,14 @@
19354
19357
  helperSvg = create$1('svg');
19355
19358
 
19356
19359
  attr(helperSvg, {
19357
- id: 'helper-svg',
19358
- width: 0,
19359
- height: 0,
19360
+ id: 'helper-svg'
19361
+ });
19362
+
19363
+ assign$1(helperSvg, {
19360
19364
  visibility: 'hidden',
19361
- position: 'fixed'
19365
+ position: 'fixed',
19366
+ width: 0,
19367
+ height: 0
19362
19368
  });
19363
19369
 
19364
19370
  document.body.appendChild(helperSvg);
@@ -23475,6 +23481,16 @@
23475
23481
  // default moddle extensions the viewer is composed of
23476
23482
  Viewer.prototype._moddleExtensions = {};
23477
23483
 
23484
+ var KEYCODE_C = 67;
23485
+ var KEYCODE_V = 86;
23486
+ var KEYCODE_Y = 89;
23487
+ var KEYCODE_Z = 90;
23488
+
23489
+ var KEYS_COPY = [ 'c', 'C', KEYCODE_C ];
23490
+ var KEYS_PASTE = [ 'v', 'V', KEYCODE_V ];
23491
+ var KEYS_REDO = [ 'y', 'Y', KEYCODE_Y ];
23492
+ var KEYS_UNDO = [ 'z', 'Z', KEYCODE_Z ];
23493
+
23478
23494
  /**
23479
23495
  * Returns true if event was triggered with any modifier
23480
23496
  * @param {KeyboardEvent} event
@@ -23514,15 +23530,36 @@
23514
23530
  */
23515
23531
  function isShift(event) {
23516
23532
  return event.shiftKey;
23533
+ }
23534
+
23535
+ function isCopy(event) {
23536
+ return isCmd(event) && isKey(KEYS_COPY, event);
23537
+ }
23538
+
23539
+ function isPaste(event) {
23540
+ return isCmd(event) && isKey(KEYS_PASTE, event);
23541
+ }
23542
+
23543
+ function isUndo(event) {
23544
+ return isCmd(event) && !isShift(event) && isKey(KEYS_UNDO, event);
23545
+ }
23546
+
23547
+ function isRedo(event) {
23548
+ return isCmd(event) && (
23549
+ isKey(KEYS_REDO, event) || (
23550
+ isKey(KEYS_UNDO, event) && isShift(event)
23551
+ )
23552
+ );
23517
23553
  }
23518
23554
 
23519
23555
  var KEYDOWN_EVENT = 'keyboard.keydown',
23520
23556
  KEYUP_EVENT = 'keyboard.keyup';
23521
23557
 
23522
- var HANDLE_MODIFIER_ATTRIBUTE = 'input-handle-modified-keys';
23523
-
23524
23558
  var DEFAULT_PRIORITY$3 = 1000;
23525
23559
 
23560
+ var compatMessage = 'Explicit binding of keyboard to an element got removed. For more information, see https://github.com/bpmn-io/diagram-js/issues/661';
23561
+
23562
+
23526
23563
  /**
23527
23564
  * A keyboard abstraction that may be activated and
23528
23565
  * deactivated by users at will, consuming key events
@@ -23541,8 +23578,8 @@
23541
23578
  *
23542
23579
  * All events contain one field which is node.
23543
23580
  *
23544
- * A default binding for the keyboard may be specified via the
23545
- * `keyboard.bindTo` configuration option.
23581
+ * Specify the initial keyboard binding state via the
23582
+ * `keyboard.bind=true|false` configuration option.
23546
23583
  *
23547
23584
  * @param {Config} config
23548
23585
  * @param {EventBus} eventBus
@@ -23550,7 +23587,8 @@
23550
23587
  function Keyboard(config, eventBus) {
23551
23588
  var self = this;
23552
23589
 
23553
- this._config = config || {};
23590
+ this._config = config = config || {};
23591
+
23554
23592
  this._eventBus = eventBus;
23555
23593
 
23556
23594
  this._keydownHandler = this._keydownHandler.bind(this);
@@ -23563,19 +23601,22 @@
23563
23601
  self.unbind();
23564
23602
  });
23565
23603
 
23566
- eventBus.on('diagram.init', function() {
23567
- self._fire('init');
23568
- });
23604
+ if (config.bindTo) {
23605
+ console.error('unsupported configuration <keyboard.bindTo>', new Error(compatMessage));
23606
+ }
23607
+
23608
+ var bind = config && config.bind !== false;
23609
+
23610
+ eventBus.on('canvas.init', function(event) {
23611
+ self._target = event.svg;
23569
23612
 
23570
- eventBus.on('attach', function() {
23571
- if (config && config.bindTo) {
23572
- self.bind(config.bindTo);
23613
+ if (bind) {
23614
+ self.bind();
23573
23615
  }
23574
- });
23575
23616
 
23576
- eventBus.on('detach', function() {
23577
- self.unbind();
23617
+ self._fire('init');
23578
23618
  });
23619
+
23579
23620
  }
23580
23621
 
23581
23622
  Keyboard.$inject = [
@@ -23610,34 +23651,19 @@
23610
23651
  };
23611
23652
 
23612
23653
  Keyboard.prototype._isEventIgnored = function(event) {
23613
- return isInput(event.target) && this._isModifiedKeyIgnored(event);
23614
- };
23615
-
23616
- Keyboard.prototype._isModifiedKeyIgnored = function(event) {
23617
- if (!isCmd(event)) {
23618
- return true;
23619
- }
23620
-
23621
- var allowedModifiers = this._getAllowedModifiers(event.target);
23622
- return allowedModifiers.indexOf(event.key) === -1;
23654
+ return false;
23623
23655
  };
23624
23656
 
23625
- Keyboard.prototype._getAllowedModifiers = function(element) {
23626
- var modifierContainer = closest(element, '[' + HANDLE_MODIFIER_ATTRIBUTE + ']', true);
23657
+ Keyboard.prototype.bind = function(node) {
23627
23658
 
23628
- if (!modifierContainer || (this._node && !this._node.contains(modifierContainer))) {
23629
- return [];
23659
+ if (node) {
23660
+ console.error('unsupported argument <node>', new Error(compatMessage));
23630
23661
  }
23631
23662
 
23632
- return modifierContainer.getAttribute(HANDLE_MODIFIER_ATTRIBUTE).split(',');
23633
- };
23634
-
23635
- Keyboard.prototype.bind = function(node) {
23636
-
23637
23663
  // make sure that the keyboard is only bound once to the DOM
23638
23664
  this.unbind();
23639
23665
 
23640
- this._node = node;
23666
+ node = this._node = this._target;
23641
23667
 
23642
23668
  // bind key events
23643
23669
  componentEvent.bind(node, 'keydown', this._keydownHandler, true);
@@ -23696,26 +23722,8 @@
23696
23722
  Keyboard.prototype.isShift = isShift;
23697
23723
  Keyboard.prototype.isKey = isKey;
23698
23724
 
23699
-
23700
-
23701
- // helpers ///////
23702
-
23703
- function isInput(target) {
23704
- return target && (matchesSelector(target, 'input, textarea') || target.contentEditable === 'true');
23705
- }
23706
-
23707
23725
  var LOW_PRIORITY$m = 500;
23708
23726
 
23709
- var KEYCODE_C = 67;
23710
- var KEYCODE_V = 86;
23711
- var KEYCODE_Y = 89;
23712
- var KEYCODE_Z = 90;
23713
-
23714
- var KEYS_COPY = [ 'c', 'C', KEYCODE_C ];
23715
- var KEYS_PASTE = [ 'v', 'V', KEYCODE_V ];
23716
- var KEYS_REDO = [ 'y', 'Y', KEYCODE_Y ];
23717
- var KEYS_UNDO = [ 'z', 'Z', KEYCODE_Z ];
23718
-
23719
23727
 
23720
23728
  /**
23721
23729
  * Adds default keyboard bindings.
@@ -23773,7 +23781,7 @@
23773
23781
 
23774
23782
  var event = context.keyEvent;
23775
23783
 
23776
- if (isCmd(event) && !isShift(event) && isKey(KEYS_UNDO, event)) {
23784
+ if (isUndo(event)) {
23777
23785
  editorActions.trigger('undo');
23778
23786
 
23779
23787
  return true;
@@ -23787,7 +23795,7 @@
23787
23795
 
23788
23796
  var event = context.keyEvent;
23789
23797
 
23790
- if (isCmd(event) && (isKey(KEYS_REDO, event) || (isKey(KEYS_UNDO, event) && isShift(event)))) {
23798
+ if (isRedo(event)) {
23791
23799
  editorActions.trigger('redo');
23792
23800
 
23793
23801
  return true;
@@ -23800,7 +23808,7 @@
23800
23808
 
23801
23809
  var event = context.keyEvent;
23802
23810
 
23803
- if (isCmd(event) && isKey(KEYS_COPY, event)) {
23811
+ if (isCopy(event)) {
23804
23812
  editorActions.trigger('copy');
23805
23813
 
23806
23814
  return true;
@@ -23813,7 +23821,7 @@
23813
23821
 
23814
23822
  var event = context.keyEvent;
23815
23823
 
23816
- if (isCmd(event) && isKey(KEYS_PASTE, event)) {
23824
+ if (isPaste(event)) {
23817
23825
  editorActions.trigger('paste');
23818
23826
 
23819
23827
  return true;
@@ -29985,7 +29993,7 @@
29985
29993
  bpmnAutoResizeProvider: [ 'type', BpmnAutoResizeProvider ]
29986
29994
  };
29987
29995
 
29988
- var HIGH_PRIORITY$l = 1500;
29996
+ var HIGH_PRIORITY$j = 1500;
29989
29997
 
29990
29998
 
29991
29999
  /**
@@ -30053,7 +30061,7 @@
30053
30061
  */
30054
30062
  eventBus.on('drag.start', function(event) {
30055
30063
 
30056
- eventBus.once('drag.move', HIGH_PRIORITY$l, function(event) {
30064
+ eventBus.once('drag.move', HIGH_PRIORITY$j, function(event) {
30057
30065
 
30058
30066
  ensureHover(event);
30059
30067
 
@@ -30084,7 +30092,7 @@
30084
30092
  hover = event.element;
30085
30093
  });
30086
30094
 
30087
- eventBus.on('element.hover', HIGH_PRIORITY$l, function(event) {
30095
+ eventBus.on('element.hover', HIGH_PRIORITY$j, function(event) {
30088
30096
 
30089
30097
  // (3) am I on an element still?
30090
30098
  if (hover) {
@@ -31914,7 +31922,7 @@
31914
31922
  MARKER_CONNECT_UPDATING$1 = 'djs-updating',
31915
31923
  MARKER_ELEMENT_HIDDEN = 'djs-element-hidden';
31916
31924
 
31917
- var HIGH_PRIORITY$k = 1100;
31925
+ var HIGH_PRIORITY$i = 1100;
31918
31926
 
31919
31927
  /**
31920
31928
  * Preview connection while moving bendpoints.
@@ -31977,7 +31985,7 @@
31977
31985
  eventBus.on([
31978
31986
  'bendpoint.move.out',
31979
31987
  'bendpoint.move.cleanup'
31980
- ], HIGH_PRIORITY$k, function(event) {
31988
+ ], HIGH_PRIORITY$i, function(event) {
31981
31989
  var context = event.context,
31982
31990
  hover = context.hover,
31983
31991
  target = context.target;
@@ -32063,7 +32071,7 @@
32063
32071
  eventBus.on([
32064
32072
  'bendpoint.move.end',
32065
32073
  'bendpoint.move.cancel'
32066
- ], HIGH_PRIORITY$k, function(event) {
32074
+ ], HIGH_PRIORITY$i, function(event) {
32067
32075
  var context = event.context,
32068
32076
  connection = context.connection,
32069
32077
  draggerGfx = context.draggerGfx,
@@ -33024,7 +33032,7 @@
33024
33032
  return hover && source && hover === source && source !== target;
33025
33033
  }
33026
33034
 
33027
- var HIGH_PRIORITY$j = 1100,
33035
+ var HIGH_PRIORITY$h = 1100,
33028
33036
  LOW_PRIORITY$j = 900;
33029
33037
 
33030
33038
  var MARKER_OK$3 = 'connect-ok',
@@ -33085,7 +33093,7 @@
33085
33093
  eventBus.on([
33086
33094
  'connect.out',
33087
33095
  'connect.cleanup'
33088
- ], HIGH_PRIORITY$j, function(event) {
33096
+ ], HIGH_PRIORITY$h, function(event) {
33089
33097
  var hover = event.hover;
33090
33098
 
33091
33099
  if (hover) {
@@ -34283,7 +34291,7 @@
34283
34291
 
34284
34292
  var PREFIX = 'create';
34285
34293
 
34286
- var HIGH_PRIORITY$i = 2000;
34294
+ var HIGH_PRIORITY$g = 2000;
34287
34295
 
34288
34296
 
34289
34297
  /**
@@ -34511,7 +34519,7 @@
34511
34519
  eventBus.on('create.init', function() {
34512
34520
  eventBus.on('elements.changed', cancel);
34513
34521
 
34514
- eventBus.once([ 'create.cancel', 'create.end' ], HIGH_PRIORITY$i, function() {
34522
+ eventBus.once([ 'create.cancel', 'create.end' ], HIGH_PRIORITY$g, function() {
34515
34523
  eventBus.off('elements.changed', cancel);
34516
34524
  });
34517
34525
  });
@@ -35459,67 +35467,52 @@
35459
35467
  });
35460
35468
  }
35461
35469
 
35462
- function removeProperties(element, properties) {
35463
- if (!isArray$3(properties)) {
35464
- properties = [ properties ];
35465
- }
35466
-
35467
- forEach$1(properties, function(property) {
35468
- if (element[property]) {
35469
- delete element[property];
35470
- }
35471
- });
35472
- }
35473
-
35474
35470
  var LOW_PRIORITY$h = 750;
35475
35471
 
35476
35472
 
35477
35473
  function BpmnCopyPaste(bpmnFactory, eventBus, moddleCopy) {
35478
35474
 
35479
- eventBus.on('copyPaste.copyElement', LOW_PRIORITY$h, function(context) {
35480
- var descriptor = context.descriptor,
35481
- element = context.element;
35482
-
35483
- var businessObject = descriptor.oldBusinessObject = getBusinessObject(element);
35484
- var di = descriptor.oldDi = getDi(element);
35475
+ function copy(bo, clone) {
35476
+ var targetBo = bpmnFactory.create(bo.$type);
35485
35477
 
35486
- descriptor.type = element.type;
35487
-
35488
- copyProperties$1(businessObject, descriptor, 'name');
35478
+ return moddleCopy.copyElement(bo, targetBo, null, clone);
35479
+ }
35489
35480
 
35490
- copyProperties$1(di, descriptor, 'isExpanded');
35481
+ eventBus.on('copyPaste.copyElement', LOW_PRIORITY$h, function(context) {
35482
+ var descriptor = context.descriptor,
35483
+ element = context.element,
35484
+ businessObject = getBusinessObject(element);
35491
35485
 
35492
- if (isLabel$3(descriptor)) {
35486
+ // do not copy business object + di for labels;
35487
+ // will be pulled from the referenced label target
35488
+ if (isLabel$3(element)) {
35493
35489
  return descriptor;
35494
35490
  }
35495
35491
 
35492
+ var businessObjectCopy = descriptor.businessObject = copy(businessObject, true);
35493
+ var diCopy = descriptor.di = copy(getDi(element), true);
35494
+ diCopy.bpmnElement = businessObjectCopy;
35495
+
35496
+ copyProperties$1(businessObjectCopy, descriptor, 'name');
35497
+ copyProperties$1(diCopy, descriptor, 'isExpanded');
35498
+
35496
35499
  // default sequence flow
35497
35500
  if (businessObject.default) {
35498
35501
  descriptor.default = businessObject.default.id;
35499
35502
  }
35500
35503
  });
35501
35504
 
35502
- eventBus.on('moddleCopy.canCopyProperty', function(context) {
35503
- var parent = context.parent,
35504
- property = context.property,
35505
- propertyName = context.propertyName,
35506
- bpmnProcess;
35507
-
35508
- if (
35509
- propertyName === 'processRef' &&
35510
- is$1(parent, 'bpmn:Participant') &&
35511
- is$1(property, 'bpmn:Process')
35512
- ) {
35513
- bpmnProcess = bpmnFactory.create('bpmn:Process');
35505
+ var referencesKey = '-bpmn-js-refs';
35514
35506
 
35515
- // return copy of process
35516
- return moddleCopy.copyElement(property, bpmnProcess);
35517
- }
35518
- });
35507
+ function getReferences(cache) {
35508
+ return (cache[referencesKey] = cache[referencesKey] || {});
35509
+ }
35519
35510
 
35520
- var references;
35511
+ function setReferences(cache, references) {
35512
+ cache[referencesKey] = references;
35513
+ }
35521
35514
 
35522
- function resolveReferences(descriptor, cache) {
35515
+ function resolveReferences(descriptor, cache, references) {
35523
35516
  var businessObject = getBusinessObject(descriptor);
35524
35517
 
35525
35518
  // default sequence flows
@@ -35539,7 +35532,7 @@
35539
35532
  getBusinessObject(descriptor).attachedToRef = getBusinessObject(cache[ descriptor.host ]);
35540
35533
  }
35541
35534
 
35542
- references = omit(references, reduce(references, function(array, reference, key) {
35535
+ return omit(references, reduce(references, function(array, reference, key) {
35543
35536
  var element = reference.element,
35544
35537
  property = reference.property;
35545
35538
 
@@ -35553,18 +35546,13 @@
35553
35546
  }, []));
35554
35547
  }
35555
35548
 
35556
- eventBus.on('copyPaste.pasteElements', function() {
35557
- references = {};
35558
- });
35559
-
35560
35549
  eventBus.on('copyPaste.pasteElement', function(context) {
35561
35550
  var cache = context.cache,
35562
35551
  descriptor = context.descriptor,
35563
- oldBusinessObject = descriptor.oldBusinessObject,
35564
- oldDi = descriptor.oldDi,
35565
- newBusinessObject, newDi;
35552
+ businessObject = descriptor.businessObject,
35553
+ di = descriptor.di;
35566
35554
 
35567
- // do NOT copy business object if external label
35555
+ // wire existing di + businessObject for external label
35568
35556
  if (isLabel$3(descriptor)) {
35569
35557
  descriptor.businessObject = getBusinessObject(cache[ descriptor.labelTarget ]);
35570
35558
  descriptor.di = getDi(cache[ descriptor.labelTarget ]);
@@ -35572,30 +35560,56 @@
35572
35560
  return;
35573
35561
  }
35574
35562
 
35575
- newBusinessObject = bpmnFactory.create(oldBusinessObject.$type);
35576
-
35577
- descriptor.businessObject = moddleCopy.copyElement(
35578
- oldBusinessObject,
35579
- newBusinessObject
35580
- );
35581
-
35582
- newDi = bpmnFactory.create(oldDi.$type);
35583
- newDi.bpmnElement = newBusinessObject;
35584
-
35585
- descriptor.di = moddleCopy.copyElement(
35586
- oldDi,
35587
- newDi
35588
- );
35563
+ businessObject = descriptor.businessObject = copy(businessObject);
35589
35564
 
35590
- // resolve references e.g. default sequence flow
35591
- resolveReferences(descriptor, cache);
35565
+ di = descriptor.di = copy(di);
35566
+ di.bpmnElement = businessObject;
35592
35567
 
35593
- copyProperties$1(descriptor, newBusinessObject, [
35568
+ copyProperties$1(descriptor, businessObject, [
35594
35569
  'isExpanded',
35595
35570
  'name'
35596
35571
  ]);
35597
35572
 
35598
- removeProperties(descriptor, 'oldBusinessObject');
35573
+ descriptor.type = businessObject.$type;
35574
+ });
35575
+
35576
+ // copy + paste processRef with participant
35577
+
35578
+ eventBus.on('copyPaste.copyElement', LOW_PRIORITY$h, function(context) {
35579
+ var descriptor = context.descriptor,
35580
+ element = context.element;
35581
+
35582
+ if (!is$1(element, 'bpmn:Participant')) {
35583
+ return;
35584
+ }
35585
+
35586
+ var participantBo = getBusinessObject(element);
35587
+
35588
+ if (participantBo.processRef) {
35589
+ descriptor.processRef = copy(participantBo.processRef, true);
35590
+ }
35591
+ });
35592
+
35593
+ eventBus.on('copyPaste.pasteElement', function(context) {
35594
+ var descriptor = context.descriptor,
35595
+ processRef = descriptor.processRef;
35596
+
35597
+ if (processRef) {
35598
+ descriptor.processRef = copy(processRef);
35599
+ }
35600
+ });
35601
+
35602
+ // resolve references
35603
+
35604
+ eventBus.on('copyPaste.pasteElement', LOW_PRIORITY$h, function(context) {
35605
+ var cache = context.cache,
35606
+ descriptor = context.descriptor;
35607
+
35608
+ // resolve references e.g. default sequence flow
35609
+ setReferences(
35610
+ cache,
35611
+ resolveReferences(descriptor, cache, getReferences(cache))
35612
+ );
35599
35613
  });
35600
35614
 
35601
35615
  }
@@ -35621,7 +35635,8 @@
35621
35635
  'flowElements',
35622
35636
  'lanes',
35623
35637
  'incoming',
35624
- 'outgoing'
35638
+ 'outgoing',
35639
+ 'categoryValue'
35625
35640
  ];
35626
35641
 
35627
35642
  /**
@@ -35730,10 +35745,11 @@
35730
35745
  * @param {ModdleElement} sourceElement
35731
35746
  * @param {ModdleElement} targetElement
35732
35747
  * @param {Array<string>} [propertyNames]
35748
+ * @param {boolean} clone
35733
35749
  *
35734
35750
  * @param {ModdleElement}
35735
35751
  */
35736
- ModdleCopy.prototype.copyElement = function(sourceElement, targetElement, propertyNames) {
35752
+ ModdleCopy.prototype.copyElement = function(sourceElement, targetElement, propertyNames, clone) {
35737
35753
  var self = this;
35738
35754
 
35739
35755
  if (propertyNames && !isArray$3(propertyNames)) {
@@ -35745,7 +35761,8 @@
35745
35761
  var canCopyProperties = this._eventBus.fire('moddleCopy.canCopyProperties', {
35746
35762
  propertyNames: propertyNames,
35747
35763
  sourceElement: sourceElement,
35748
- targetElement: targetElement
35764
+ targetElement: targetElement,
35765
+ clone: clone
35749
35766
  });
35750
35767
 
35751
35768
  if (canCopyProperties === false) {
@@ -35764,7 +35781,11 @@
35764
35781
  sourceProperty = sourceElement.get(propertyName);
35765
35782
  }
35766
35783
 
35767
- var copiedProperty = self.copyProperty(sourceProperty, targetElement, propertyName);
35784
+ var copiedProperty = self.copyProperty(sourceProperty, targetElement, propertyName, clone);
35785
+
35786
+ if (!isDefined(copiedProperty)) {
35787
+ return;
35788
+ }
35768
35789
 
35769
35790
  var canSetProperty = self._eventBus.fire('moddleCopy.canSetCopiedProperty', {
35770
35791
  parent: targetElement,
@@ -35776,9 +35797,9 @@
35776
35797
  return;
35777
35798
  }
35778
35799
 
35779
- if (isDefined(copiedProperty)) {
35780
- targetElement.set(propertyName, copiedProperty);
35781
- }
35800
+ // TODO(nikku): unclaim old IDs if ID property is copied over
35801
+ // this._moddle.getPropertyDescriptor(parent, propertyName)
35802
+ targetElement.set(propertyName, copiedProperty);
35782
35803
  });
35783
35804
 
35784
35805
  return targetElement;
@@ -35790,17 +35811,19 @@
35790
35811
  * @param {*} property
35791
35812
  * @param {ModdleElement} parent
35792
35813
  * @param {string} propertyName
35814
+ * @param {boolean} clone
35793
35815
  *
35794
35816
  * @returns {*}
35795
35817
  */
35796
- ModdleCopy.prototype.copyProperty = function(property, parent, propertyName) {
35818
+ ModdleCopy.prototype.copyProperty = function(property, parent, propertyName, clone) {
35797
35819
  var self = this;
35798
35820
 
35799
35821
  // allow others to copy property
35800
35822
  var copiedProperty = this._eventBus.fire('moddleCopy.canCopyProperty', {
35801
35823
  parent: parent,
35802
35824
  property: property,
35803
- propertyName: propertyName
35825
+ propertyName: propertyName,
35826
+ clone: clone
35804
35827
  });
35805
35828
 
35806
35829
  // return if copying is NOT allowed
@@ -35825,7 +35848,7 @@
35825
35848
 
35826
35849
  // copy id
35827
35850
  if (propertyDescriptor.isId) {
35828
- return this._copyId(property, parent);
35851
+ return property && this._copyId(property, parent, clone);
35829
35852
  }
35830
35853
 
35831
35854
  // copy arrays
@@ -35833,7 +35856,7 @@
35833
35856
  return reduce(property, function(childProperties, childProperty) {
35834
35857
 
35835
35858
  // recursion
35836
- copiedProperty = self.copyProperty(childProperty, parent, propertyName);
35859
+ copiedProperty = self.copyProperty(childProperty, parent, propertyName, clone);
35837
35860
 
35838
35861
  // copying might NOT be allowed
35839
35862
  if (copiedProperty) {
@@ -35855,7 +35878,7 @@
35855
35878
  copiedProperty.$parent = parent;
35856
35879
 
35857
35880
  // recursion
35858
- copiedProperty = self.copyElement(property, copiedProperty);
35881
+ copiedProperty = self.copyElement(property, copiedProperty, null, clone);
35859
35882
 
35860
35883
  return copiedProperty;
35861
35884
  }
@@ -35864,7 +35887,11 @@
35864
35887
  return property;
35865
35888
  };
35866
35889
 
35867
- ModdleCopy.prototype._copyId = function(id, element) {
35890
+ ModdleCopy.prototype._copyId = function(id, element, clone) {
35891
+
35892
+ if (clone) {
35893
+ return id;
35894
+ }
35868
35895
 
35869
35896
  // disallow if already taken
35870
35897
  if (this._moddle.ids.assigned(id)) {
@@ -39037,7 +39064,9 @@
39037
39064
  this.register('copy', function() {
39038
39065
  var selectedElements = selection.get();
39039
39066
 
39040
- copyPaste.copy(selectedElements);
39067
+ if (selectedElements.length) {
39068
+ return copyPaste.copy(selectedElements);
39069
+ }
39041
39070
  });
39042
39071
  }
39043
39072
 
@@ -39416,7 +39445,7 @@
39416
39445
  return Math[ fn ](value / quantum) * quantum;
39417
39446
  }
39418
39447
 
39419
- var LOWER_PRIORITY = 1200;
39448
+ var LOWER_PRIORITY$1 = 1200;
39420
39449
  var LOW_PRIORITY$f = 800;
39421
39450
 
39422
39451
  /**
@@ -39448,7 +39477,7 @@
39448
39477
  'resize.end',
39449
39478
  'shape.move.move',
39450
39479
  'shape.move.end'
39451
- ], LOWER_PRIORITY, function(event) {
39480
+ ], LOWER_PRIORITY$1, function(event) {
39452
39481
  var originalEvent = event.originalEvent;
39453
39482
 
39454
39483
  if (!self.active || (originalEvent && isCmd(originalEvent))) {
@@ -39916,7 +39945,7 @@
39916
39945
  return newBounds;
39917
39946
  };
39918
39947
 
39919
- var HIGH_PRIORITY$h = 2000;
39948
+ var HIGH_PRIORITY$f = 2000;
39920
39949
 
39921
39950
  /**
39922
39951
  * Integrates space tool with grid snapping.
@@ -39925,7 +39954,7 @@
39925
39954
  eventBus.on([
39926
39955
  'spaceTool.move',
39927
39956
  'spaceTool.end'
39928
- ], HIGH_PRIORITY$h, function(event) {
39957
+ ], HIGH_PRIORITY$f, function(event) {
39929
39958
  var context = event.context;
39930
39959
 
39931
39960
  if (!context.initialized) {
@@ -39974,11 +40003,11 @@
39974
40003
  gridSnapping: [ 'type', GridSnapping ]
39975
40004
  };
39976
40005
 
39977
- var HIGH_PRIORITY$g = 2000;
40006
+ var HIGH_PRIORITY$e = 2000;
39978
40007
 
39979
40008
 
39980
- function AutoPlaceBehavior(eventBus, gridSnapping) {
39981
- eventBus.on('autoPlace', HIGH_PRIORITY$g, function(context) {
40009
+ function GridSnappingAutoPlaceBehavior(eventBus, gridSnapping) {
40010
+ eventBus.on('autoPlace', HIGH_PRIORITY$e, function(context) {
39982
40011
  var source = context.source,
39983
40012
  sourceMid = getMid(source),
39984
40013
  shape = context.shape;
@@ -40018,7 +40047,7 @@
40018
40047
  });
40019
40048
  }
40020
40049
 
40021
- AutoPlaceBehavior.$inject = [
40050
+ GridSnappingAutoPlaceBehavior.$inject = [
40022
40051
  'eventBus',
40023
40052
  'gridSnapping'
40024
40053
  ];
@@ -40032,7 +40061,7 @@
40032
40061
  var HIGHER_PRIORITY$4 = 1750;
40033
40062
 
40034
40063
 
40035
- function CreateParticipantBehavior$1(canvas, eventBus, gridSnapping) {
40064
+ function GridSnappingParticipantBehavior(canvas, eventBus, gridSnapping) {
40036
40065
  eventBus.on([
40037
40066
  'create.start',
40038
40067
  'shape.move.start'
@@ -40058,19 +40087,19 @@
40058
40087
  });
40059
40088
  }
40060
40089
 
40061
- CreateParticipantBehavior$1.$inject = [
40090
+ GridSnappingParticipantBehavior.$inject = [
40062
40091
  'canvas',
40063
40092
  'eventBus',
40064
40093
  'gridSnapping'
40065
40094
  ];
40066
40095
 
40067
- var HIGH_PRIORITY$f = 3000;
40096
+ var HIGH_PRIORITY$d = 3000;
40068
40097
 
40069
40098
 
40070
40099
  /**
40071
40100
  * Snaps connections with Manhattan layout.
40072
40101
  */
40073
- function LayoutConnectionBehavior$1(eventBus, gridSnapping, modeling) {
40102
+ function GridSnappingLayoutConnectionBehavior(eventBus, gridSnapping, modeling) {
40074
40103
  CommandInterceptor.call(this, eventBus);
40075
40104
 
40076
40105
  this._gridSnapping = gridSnapping;
@@ -40080,7 +40109,7 @@
40080
40109
  this.postExecuted([
40081
40110
  'connection.create',
40082
40111
  'connection.layout'
40083
- ], HIGH_PRIORITY$f, function(event) {
40112
+ ], HIGH_PRIORITY$d, function(event) {
40084
40113
  var context = event.context,
40085
40114
  connection = context.connection,
40086
40115
  hints = context.hints || {},
@@ -40098,13 +40127,13 @@
40098
40127
  });
40099
40128
  }
40100
40129
 
40101
- LayoutConnectionBehavior$1.$inject = [
40130
+ GridSnappingLayoutConnectionBehavior.$inject = [
40102
40131
  'eventBus',
40103
40132
  'gridSnapping',
40104
40133
  'modeling'
40105
40134
  ];
40106
40135
 
40107
- e(LayoutConnectionBehavior$1, CommandInterceptor);
40136
+ e(GridSnappingLayoutConnectionBehavior, CommandInterceptor);
40108
40137
 
40109
40138
  /**
40110
40139
  * Snap middle segments of a given connection.
@@ -40113,7 +40142,7 @@
40113
40142
  *
40114
40143
  * @returns {Array<Point>}
40115
40144
  */
40116
- LayoutConnectionBehavior$1.prototype.snapMiddleSegments = function(waypoints) {
40145
+ GridSnappingLayoutConnectionBehavior.prototype.snapMiddleSegments = function(waypoints) {
40117
40146
  var gridSnapping = this._gridSnapping,
40118
40147
  snapped;
40119
40148
 
@@ -40202,12 +40231,12 @@
40202
40231
  var GridSnappingBehaviorModule = {
40203
40232
  __init__: [
40204
40233
  'gridSnappingAutoPlaceBehavior',
40205
- 'gridSnappingCreateParticipantBehavior',
40234
+ 'gridSnappingParticipantBehavior',
40206
40235
  'gridSnappingLayoutConnectionBehavior',
40207
40236
  ],
40208
- gridSnappingAutoPlaceBehavior: [ 'type', AutoPlaceBehavior ],
40209
- gridSnappingCreateParticipantBehavior: [ 'type', CreateParticipantBehavior$1 ],
40210
- gridSnappingLayoutConnectionBehavior: [ 'type', LayoutConnectionBehavior$1 ]
40237
+ gridSnappingAutoPlaceBehavior: [ 'type', GridSnappingAutoPlaceBehavior ],
40238
+ gridSnappingParticipantBehavior: [ 'type', GridSnappingParticipantBehavior ],
40239
+ gridSnappingLayoutConnectionBehavior: [ 'type', GridSnappingLayoutConnectionBehavior ]
40211
40240
  };
40212
40241
 
40213
40242
  var GridSnappingModule = {
@@ -41196,30 +41225,7 @@
41196
41225
  resizeHandles: [ 'type', ResizeHandles ]
41197
41226
  };
41198
41227
 
41199
- /**
41200
- * Creates a new bpmn:CategoryValue inside a new bpmn:Category
41201
- *
41202
- * @param {ModdleElement} definitions
41203
- * @param {BpmnFactory} bpmnFactory
41204
- *
41205
- * @return {ModdleElement} categoryValue.
41206
- */
41207
- function createCategoryValue(definitions, bpmnFactory) {
41208
- var categoryValue = bpmnFactory.create('bpmn:CategoryValue'),
41209
- category = bpmnFactory.create('bpmn:Category', {
41210
- categoryValue: [ categoryValue ]
41211
- });
41212
-
41213
- // add to correct place
41214
- add(definitions.get('rootElements'), category);
41215
- getBusinessObject(category).$parent = definitions;
41216
- getBusinessObject(categoryValue).$parent = category;
41217
-
41218
- return categoryValue;
41219
-
41220
- }
41221
-
41222
- var HIGH_PRIORITY$e = 2000;
41228
+ var HIGH_PRIORITY$c = 2000;
41223
41229
 
41224
41230
 
41225
41231
  function LabelEditingProvider(
@@ -41257,7 +41263,7 @@
41257
41263
  eventBus.on([
41258
41264
  'shape.remove',
41259
41265
  'connection.remove'
41260
- ], HIGH_PRIORITY$e, function(event) {
41266
+ ], HIGH_PRIORITY$c, function(event) {
41261
41267
 
41262
41268
  if (directEditing.isActive(event.element)) {
41263
41269
  directEditing.cancel();
@@ -41593,23 +41599,6 @@
41593
41599
  };
41594
41600
  }
41595
41601
 
41596
- if (is$1(element, 'bpmn:Group')) {
41597
-
41598
- var businessObject = getBusinessObject(element);
41599
-
41600
- // initialize categoryValue if not existing
41601
- if (!businessObject.categoryValueRef) {
41602
-
41603
- var rootElement = this._canvas.getRootElement(),
41604
- definitions = getBusinessObject(rootElement).$parent;
41605
-
41606
- var categoryValue = createCategoryValue(definitions, this._bpmnFactory);
41607
-
41608
- getBusinessObject(element).categoryValueRef = categoryValue;
41609
- }
41610
-
41611
- }
41612
-
41613
41602
  if (isEmptyText$1(newLabel)) {
41614
41603
  newLabel = null;
41615
41604
  }
@@ -42184,13 +42173,10 @@
42184
42173
  isAny(shape, [ 'bpmn:IntermediateThrowEvent', 'bpmn:IntermediateCatchEvent' ]) && !!host;
42185
42174
  }
42186
42175
 
42187
- var HIGH_PRIORITY$d = 2000;
42188
-
42189
-
42190
42176
  /**
42191
42177
  * BPMN specific boundary event behavior
42192
42178
  */
42193
- function BoundaryEventBehavior(eventBus, moddle, modeling) {
42179
+ function BoundaryEventBehavior(eventBus, modeling) {
42194
42180
 
42195
42181
  CommandInterceptor.call(this, eventBus);
42196
42182
 
@@ -42235,23 +42221,10 @@
42235
42221
  }
42236
42222
  });
42237
42223
 
42238
- // copy reference to root element on replace
42239
- eventBus.on('moddleCopy.canCopyProperty', HIGH_PRIORITY$d, function(context) {
42240
- var parent = context.parent,
42241
- property = context.property,
42242
- propertyName = context.propertyName;
42243
-
42244
- var propertyDescriptor = moddle.getPropertyDescriptor(parent, propertyName);
42245
-
42246
- if (propertyDescriptor && propertyDescriptor.isReference && is$1(property, 'bpmn:RootElement')) {
42247
- parent.set(propertyName, property);
42248
- }
42249
- });
42250
42224
  }
42251
42225
 
42252
42226
  BoundaryEventBehavior.$inject = [
42253
42227
  'eventBus',
42254
- 'moddle',
42255
42228
  'modeling'
42256
42229
  ];
42257
42230
 
@@ -42314,7 +42287,7 @@
42314
42287
 
42315
42288
  var PARTICIPANT_BORDER_WIDTH = 30;
42316
42289
 
42317
- var HIGH_PRIORITY$c = 2000;
42290
+ var HIGH_PRIORITY$b = 2000;
42318
42291
 
42319
42292
 
42320
42293
  /**
@@ -42327,7 +42300,7 @@
42327
42300
  eventBus.on([
42328
42301
  'create.start',
42329
42302
  'shape.move.start'
42330
- ], HIGH_PRIORITY$c, function(event) {
42303
+ ], HIGH_PRIORITY$b, function(event) {
42331
42304
  var context = event.context,
42332
42305
  shape = context.shape,
42333
42306
  rootElement = canvas.getRootElement();
@@ -42362,7 +42335,7 @@
42362
42335
  });
42363
42336
 
42364
42337
  // force hovering process when creating first participant
42365
- eventBus.on('create.start', HIGH_PRIORITY$c, function(event) {
42338
+ eventBus.on('create.start', HIGH_PRIORITY$b, function(event) {
42366
42339
  var context = event.context,
42367
42340
  shape = context.shape,
42368
42341
  rootElement = canvas.getRootElement(),
@@ -42374,7 +42347,7 @@
42374
42347
  }
42375
42348
 
42376
42349
  if (is$1(shape, 'bpmn:Participant') && is$1(rootElement, 'bpmn:Process')) {
42377
- eventBus.on('element.hover', HIGH_PRIORITY$c, ensureHoveringProcess);
42350
+ eventBus.on('element.hover', HIGH_PRIORITY$b, ensureHoveringProcess);
42378
42351
 
42379
42352
  eventBus.once('create.cleanup', function() {
42380
42353
  eventBus.off('element.hover', ensureHoveringProcess);
@@ -42395,7 +42368,7 @@
42395
42368
 
42396
42369
  // when creating mutliple elements through `elements.create` parent must be set to collaboration
42397
42370
  // and passed to `shape.create` as hint
42398
- this.preExecute('elements.create', HIGH_PRIORITY$c, function(context) {
42371
+ this.preExecute('elements.create', HIGH_PRIORITY$b, function(context) {
42399
42372
  var elements = context.elements,
42400
42373
  parent = context.parent,
42401
42374
  participant = findParticipant(elements),
@@ -43354,7 +43327,7 @@
43354
43327
  return is$1(connection, 'bpmn:SequenceFlow');
43355
43328
  }
43356
43329
 
43357
- var HIGH_PRIORITY$b = 1500;
43330
+ var HIGH_PRIORITY$a = 1500;
43358
43331
  var HIGHEST_PRIORITY = 2000;
43359
43332
 
43360
43333
 
@@ -43376,7 +43349,7 @@
43376
43349
  'shape.move.move',
43377
43350
  'shape.move.out',
43378
43351
  'shape.move.end'
43379
- ], HIGH_PRIORITY$b, function(event) {
43352
+ ], HIGH_PRIORITY$a, function(event) {
43380
43353
  var context = event.context,
43381
43354
  shape = context.shape || event.shape,
43382
43355
  hover = event.hover;
@@ -43407,7 +43380,7 @@
43407
43380
  'global-connect.out',
43408
43381
  'global-connect.end',
43409
43382
  'global-connect.cleanup'
43410
- ], HIGH_PRIORITY$b, function(event) {
43383
+ ], HIGH_PRIORITY$a, function(event) {
43411
43384
  var hover = event.hover;
43412
43385
 
43413
43386
  // ensure connections start/end on bpmn:Participant,
@@ -43421,7 +43394,7 @@
43421
43394
 
43422
43395
  eventBus.on([
43423
43396
  'bendpoint.move.hover'
43424
- ], HIGH_PRIORITY$b, function(event) {
43397
+ ], HIGH_PRIORITY$a, function(event) {
43425
43398
  var context = event.context,
43426
43399
  hover = event.hover,
43427
43400
  type = context.type;
@@ -43437,7 +43410,7 @@
43437
43410
 
43438
43411
  eventBus.on([
43439
43412
  'connect.start'
43440
- ], HIGH_PRIORITY$b, function(event) {
43413
+ ], HIGH_PRIORITY$a, function(event) {
43441
43414
  var context = event.context,
43442
43415
  start = context.start;
43443
43416
 
@@ -43466,7 +43439,85 @@
43466
43439
  'canvas'
43467
43440
  ];
43468
43441
 
43469
- var HIGH_PRIORITY$a = 2000;
43442
+ /**
43443
+ * Creates a new bpmn:CategoryValue inside a new bpmn:Category
43444
+ *
43445
+ * @param {BpmnFactory} bpmnFactory
43446
+ *
43447
+ * @return {ModdleElement} categoryValue.
43448
+ */
43449
+ function createCategory(bpmnFactory) {
43450
+ return bpmnFactory.create('bpmn:Category');
43451
+ }
43452
+
43453
+ /**
43454
+ * Creates a new bpmn:CategoryValue inside a new bpmn:Category
43455
+ *
43456
+ * @param {BpmnFactory} bpmnFactory
43457
+ *
43458
+ * @return {ModdleElement} categoryValue.
43459
+ */
43460
+ function createCategoryValue(bpmnFactory) {
43461
+ return bpmnFactory.create('bpmn:CategoryValue');
43462
+ }
43463
+
43464
+ /**
43465
+ * Adds category value to definitions
43466
+ *
43467
+ * @param {ModdleElement} categoryValue
43468
+ * @param {ModdleElement} category
43469
+ * @param {ModdleElement} definitions
43470
+ *
43471
+ * @return {ModdleElement} categoryValue
43472
+ */
43473
+ function linkCategoryValue(categoryValue, category, definitions) {
43474
+ add(category.get('categoryValue'), categoryValue);
43475
+ categoryValue.$parent = category;
43476
+
43477
+ add(definitions.get('rootElements'), category);
43478
+ category.$parent = definitions;
43479
+
43480
+ return categoryValue;
43481
+ }
43482
+
43483
+ /**
43484
+ * Unlink category value from parent
43485
+ *
43486
+ * @param {ModdleElement} categoryValue
43487
+ *
43488
+ * @return {ModdleElement} categoryValue
43489
+ */
43490
+ function unlinkCategoryValue(categoryValue) {
43491
+ var category = categoryValue.$parent;
43492
+
43493
+ if (category) {
43494
+ remove(category.get('categoryValue'), categoryValue);
43495
+ categoryValue.$parent = null;
43496
+ }
43497
+
43498
+ return categoryValue;
43499
+ }
43500
+
43501
+ /**
43502
+ * Unlink category from parent
43503
+ *
43504
+ * @param {ModdleElement} category
43505
+ * @param {ModdleElement} definitions
43506
+ *
43507
+ * @return {ModdleElement} categoryValue
43508
+ */
43509
+ function unlinkCategory(category) {
43510
+ var definitions = category.$parent;
43511
+
43512
+ if (definitions) {
43513
+ remove(definitions.get('rootElements'), category);
43514
+ category.$parent = null;
43515
+ }
43516
+
43517
+ return category;
43518
+ }
43519
+
43520
+ var LOWER_PRIORITY = 770;
43470
43521
 
43471
43522
 
43472
43523
  /**
@@ -43483,158 +43534,270 @@
43483
43534
  injector.invoke(CommandInterceptor, this);
43484
43535
 
43485
43536
  /**
43486
- * Removes a referenced category value for a given group shape
43537
+ * Returns all group element in the current registry
43487
43538
  *
43488
- * @param {djs.model.Shape} shape
43539
+ * @return {Array<djs.model.shape>} a list of group shapes
43489
43540
  */
43490
- function removeReferencedCategoryValue(shape) {
43491
-
43492
- var businessObject = getBusinessObject(shape),
43493
- categoryValue = businessObject.categoryValueRef;
43494
-
43495
- if (!categoryValue) {
43496
- return;
43497
- }
43498
-
43499
- var category = categoryValue.$parent;
43500
-
43501
- if (!categoryValue) {
43502
- return;
43503
- }
43504
-
43505
- remove(category.categoryValue, categoryValue);
43506
-
43507
- // cleanup category if it is empty
43508
- if (category && !category.categoryValue.length) {
43509
- removeCategory(category);
43510
- }
43541
+ function getGroupElements() {
43542
+ return elementRegistry.filter(function(e) {
43543
+ return is$1(e, 'bpmn:Group');
43544
+ });
43511
43545
  }
43512
43546
 
43513
43547
  /**
43514
- * Removes a given category from the definitions
43548
+ * Returns true if given category is referenced in one of the given elements
43515
43549
  *
43516
- * @param {ModdleElement} category
43550
+ * @param { djs.model.Element[] } elements
43551
+ * @param { ModdleElement } category
43552
+ *
43553
+ * @return { boolean }
43517
43554
  */
43518
- function removeCategory(category) {
43555
+ function isReferencedCategory(elements, category) {
43556
+ return elements.some(function(element) {
43557
+ var businessObject = getBusinessObject(element);
43519
43558
 
43520
- var definitions = bpmnjs.getDefinitions();
43559
+ var _category = businessObject.categoryValueRef && businessObject.categoryValueRef.$parent;
43521
43560
 
43522
- remove(definitions.get('rootElements'), category);
43561
+ return _category === category;
43562
+ });
43523
43563
  }
43524
43564
 
43525
43565
  /**
43526
- * Returns all group element in the current registry
43566
+ * Returns true if given categoryValue is referenced in one of the given elements
43527
43567
  *
43528
- * @return {Array<djs.model.shape>} a list of group shapes
43568
+ * @param { djs.model.Element[] } elements
43569
+ * @param { ModdleElement } categoryValue
43570
+ *
43571
+ * @return { boolean }
43529
43572
  */
43530
- function getGroupElements() {
43531
- return elementRegistry.filter(function(e) {
43532
- return is$1(e, 'bpmn:Group');
43573
+ function isReferencedCategoryValue(elements, categoryValue) {
43574
+ return elements.some(function(element) {
43575
+ var businessObject = getBusinessObject(element);
43576
+
43577
+ return businessObject.categoryValueRef === categoryValue;
43533
43578
  });
43534
43579
  }
43535
43580
 
43536
43581
  /**
43537
- * Returns true if given categoryValue is referenced in one of the given elements
43582
+ * Remove category value unless it is still referenced
43538
43583
  *
43539
- * @param {Array<djs.model.shape>} elements
43540
43584
  * @param {ModdleElement} categoryValue
43541
- * @return {boolean}
43585
+ * @param {ModdleElement} category
43586
+ * @param {ModdleElement} businessObject
43542
43587
  */
43543
- function isReferenced(elements, categoryValue) {
43544
- return elements.some(function(e) {
43545
-
43546
- var businessObject = getBusinessObject(e);
43588
+ function removeCategoryValue(categoryValue, category, businessObject) {
43547
43589
 
43548
- return businessObject.categoryValueRef
43549
- && businessObject.categoryValueRef === categoryValue;
43590
+ var groups = getGroupElements().filter(function(element) {
43591
+ return element.businessObject !== businessObject;
43550
43592
  });
43593
+
43594
+ if (category && !isReferencedCategory(groups, category)) {
43595
+ unlinkCategory(category);
43596
+ }
43597
+
43598
+ if (categoryValue && !isReferencedCategoryValue(groups, categoryValue)) {
43599
+ unlinkCategoryValue(categoryValue);
43600
+ }
43551
43601
  }
43552
43602
 
43553
43603
  /**
43554
- * remove referenced category + value when group was deleted
43604
+ * Add category value
43605
+ *
43606
+ * @param {ModdleElement} categoryValue
43607
+ * @param {ModdleElement} category
43555
43608
  */
43556
- this.executed('shape.delete', function(event) {
43609
+ function addCategoryValue(categoryValue, category) {
43610
+ return linkCategoryValue(categoryValue, category, bpmnjs.getDefinitions());
43611
+ }
43557
43612
 
43558
- var context = event.context,
43559
- shape = context.shape;
43613
+ function setCategoryValue(element, context) {
43614
+ var businessObject = getBusinessObject(element),
43615
+ categoryValue = businessObject.categoryValueRef;
43560
43616
 
43561
- if (is$1(shape, 'bpmn:Group')) {
43617
+ if (!categoryValue) {
43618
+ categoryValue =
43619
+ businessObject.categoryValueRef =
43620
+ context.categoryValue = (
43621
+ context.categoryValue || createCategoryValue(bpmnFactory)
43622
+ );
43623
+ }
43562
43624
 
43563
- var businessObject = getBusinessObject(shape),
43564
- categoryValueRef = businessObject.categoryValueRef,
43565
- groupElements = getGroupElements();
43625
+ var category = categoryValue.$parent;
43566
43626
 
43567
- if (!isReferenced(groupElements, categoryValueRef)) {
43568
- removeReferencedCategoryValue(shape);
43569
- }
43627
+ if (!category) {
43628
+ category =
43629
+ categoryValue.$parent =
43630
+ context.category = (
43631
+ context.category || createCategory(bpmnFactory)
43632
+ );
43570
43633
  }
43571
- });
43572
43634
 
43573
- /**
43574
- * re-attach removed category
43575
- */
43576
- this.reverted('shape.delete', function(event) {
43635
+ addCategoryValue(categoryValue, category, bpmnjs.getDefinitions());
43636
+ }
43637
+
43638
+ function unsetCategoryValue(element, context) {
43639
+ var category = context.category,
43640
+ categoryValue = context.categoryValue,
43641
+ businessObject = getBusinessObject(element);
43577
43642
 
43643
+ if (categoryValue) {
43644
+ businessObject.categoryValueRef = null;
43645
+
43646
+ removeCategoryValue(categoryValue, category, businessObject);
43647
+ } else {
43648
+ removeCategoryValue(null, businessObject.categoryValueRef.$parent, businessObject);
43649
+ }
43650
+ }
43651
+
43652
+
43653
+ // ensure category + value exist before label editing
43654
+
43655
+ this.execute('label.create', function(event) {
43578
43656
  var context = event.context,
43579
- shape = context.shape;
43657
+ labelTarget = context.labelTarget;
43658
+
43659
+ if (!is$1(labelTarget, 'bpmn:Group')) {
43660
+ return;
43661
+ }
43580
43662
 
43581
- if (is$1(shape, 'bpmn:Group')) {
43663
+ setCategoryValue(labelTarget, context);
43664
+ });
43582
43665
 
43583
- var businessObject = getBusinessObject(shape),
43584
- categoryValueRef = businessObject.categoryValueRef,
43585
- definitions = bpmnjs.getDefinitions(),
43586
- category = categoryValueRef ? categoryValueRef.$parent : null;
43666
+ this.revert('label.create', function(event) {
43667
+ var context = event.context,
43668
+ labelTarget = context.labelTarget;
43587
43669
 
43588
- add(category.get('categoryValue'), categoryValueRef);
43589
- add(definitions.get('rootElements'), category);
43670
+ if (!is$1(labelTarget, 'bpmn:Group')) {
43671
+ return;
43590
43672
  }
43673
+
43674
+ unsetCategoryValue(labelTarget, context);
43591
43675
  });
43592
43676
 
43593
- /**
43594
- * create new category + value when group was created
43595
- */
43596
- this.execute('shape.create', function(event) {
43677
+
43678
+ // remove referenced category + value when group was deleted
43679
+
43680
+ this.execute('shape.delete', function(event) {
43681
+
43597
43682
  var context = event.context,
43598
43683
  shape = context.shape,
43599
43684
  businessObject = getBusinessObject(shape);
43600
43685
 
43601
- if (is$1(businessObject, 'bpmn:Group') && !businessObject.categoryValueRef) {
43686
+ if (!is$1(shape, 'bpmn:Group') || shape.labelTarget) {
43687
+ return;
43688
+ }
43689
+
43690
+ var categoryValue = context.categoryValue = businessObject.categoryValueRef,
43691
+ category;
43602
43692
 
43603
- var definitions = bpmnjs.getDefinitions(),
43604
- categoryValue = createCategoryValue(definitions, bpmnFactory);
43693
+ if (categoryValue) {
43694
+ category = context.category = categoryValue.$parent;
43605
43695
 
43606
- // link the reference to the Group
43696
+ removeCategoryValue(categoryValue, category, businessObject);
43697
+
43698
+ businessObject.categoryValueRef = null;
43699
+ }
43700
+ });
43701
+
43702
+ this.reverted('shape.delete', function(event) {
43703
+
43704
+ var context = event.context,
43705
+ shape = context.shape;
43706
+
43707
+ if (!is$1(shape, 'bpmn:Group') || shape.labelTarget) {
43708
+ return;
43709
+ }
43710
+
43711
+ var category = context.category,
43712
+ categoryValue = context.categoryValue,
43713
+ businessObject = getBusinessObject(shape);
43714
+
43715
+ if (categoryValue) {
43607
43716
  businessObject.categoryValueRef = categoryValue;
43717
+
43718
+ addCategoryValue(categoryValue, category);
43608
43719
  }
43609
43720
  });
43610
43721
 
43611
43722
 
43612
- this.revert('shape.create', function(event) {
43723
+ // create new category + value when group was created
43613
43724
 
43725
+ this.execute('shape.create', function(event) {
43614
43726
  var context = event.context,
43615
43727
  shape = context.shape;
43616
43728
 
43617
- if (is$1(shape, 'bpmn:Group')) {
43618
- removeReferencedCategoryValue(shape);
43729
+ if (!is$1(shape, 'bpmn:Group') || shape.labelTarget) {
43730
+ return;
43731
+ }
43732
+
43733
+ if (getBusinessObject(shape).categoryValueRef) {
43734
+ setCategoryValue(shape, context);
43735
+ }
43736
+ });
43737
+
43738
+ this.reverted('shape.create', function(event) {
43619
43739
 
43620
- delete getBusinessObject(shape).categoryValueRef;
43740
+ var context = event.context,
43741
+ shape = context.shape;
43621
43742
 
43743
+ if (!is$1(shape, 'bpmn:Group') || shape.labelTarget) {
43744
+ return;
43745
+ }
43746
+
43747
+ if (getBusinessObject(shape).categoryValueRef) {
43748
+ unsetCategoryValue(shape, context);
43622
43749
  }
43623
43750
  });
43624
43751
 
43625
- // copy bpmn:CategoryValue when copying element
43626
- eventBus.on('moddleCopy.canCopyProperty', HIGH_PRIORITY$a, function(context) {
43627
- var property = context.property,
43628
- categoryValue;
43629
43752
 
43630
- if (is$1(property, 'bpmn:CategoryValue')) {
43631
- categoryValue = createCategoryValue(bpmnjs.getDefinitions(), bpmnFactory);
43753
+ // copy + paste categoryValueRef with group
43754
+
43755
+ function copy(bo, clone) {
43756
+ var targetBo = bpmnFactory.create(bo.$type);
43757
+
43758
+ return moddleCopy.copyElement(bo, targetBo, null, clone);
43759
+ }
43760
+
43761
+ eventBus.on('copyPaste.copyElement', LOWER_PRIORITY, function(context) {
43762
+ var descriptor = context.descriptor,
43763
+ element = context.element;
43764
+
43765
+ if (!is$1(element, 'bpmn:Group') || element.labelTarget) {
43766
+ return;
43767
+ }
43768
+
43769
+ var groupBo = getBusinessObject(element);
43770
+
43771
+ if (groupBo.categoryValueRef) {
43772
+
43773
+ var categoryValue = groupBo.categoryValueRef;
43632
43774
 
43633
- // return copy of category
43634
- return moddleCopy.copyElement(property, categoryValue);
43775
+ descriptor.categoryValue = copy(categoryValue, true);
43776
+
43777
+ if (categoryValue.$parent) {
43778
+ descriptor.category = copy(categoryValue.$parent, true);
43779
+ }
43635
43780
  }
43636
43781
  });
43637
43782
 
43783
+ eventBus.on('copyPaste.pasteElement', LOWER_PRIORITY, function(context) {
43784
+ var descriptor = context.descriptor,
43785
+ businessObject = descriptor.businessObject,
43786
+ categoryValue = descriptor.categoryValue,
43787
+ category = descriptor.category;
43788
+
43789
+ if (categoryValue) {
43790
+ categoryValue = businessObject.categoryValueRef = copy(categoryValue);
43791
+ }
43792
+
43793
+ if (category) {
43794
+ categoryValue.$parent = copy(category);
43795
+ }
43796
+
43797
+ delete descriptor.category;
43798
+ delete descriptor.categoryValue;
43799
+ });
43800
+
43638
43801
  }
43639
43802
 
43640
43803
  GroupBehavior.$inject = [
@@ -45423,10 +45586,14 @@
45423
45586
  target = context.parent,
45424
45587
  elements = context.elements;
45425
45588
 
45426
- var canReplace = bpmnRules.canReplace(elements, target);
45589
+ var elementReplacements = reduce(elements, function(replacements, element) {
45590
+ var canReplace = bpmnRules.canReplace([ element ], element.host || element.parent || target);
45427
45591
 
45428
- if (canReplace) {
45429
- this.replaceElements(elements, canReplace.replacements);
45592
+ return canReplace ? replacements.concat(canReplace.replacements) : replacements;
45593
+ }, []);
45594
+
45595
+ if (elementReplacements.length) {
45596
+ this.replaceElements(elements, elementReplacements);
45430
45597
  }
45431
45598
  }, this);
45432
45599
 
@@ -45519,6 +45686,8 @@
45519
45686
 
45520
45687
  var HIGH_PRIORITY$9 = 1500;
45521
45688
 
45689
+ var GROUP_MIN_DIMENSIONS = { width: 140, height: 120 };
45690
+
45522
45691
  var LANE_MIN_DIMENSIONS = { width: 300, height: 60 };
45523
45692
 
45524
45693
  var PARTICIPANT_MIN_DIMENSIONS = { width: 300, height: 150 };
@@ -45835,7 +46004,7 @@
45835
46004
  var descriptor = context.descriptor,
45836
46005
  element = context.element;
45837
46006
 
45838
- if (!canHaveRootElementReference(element)) {
46007
+ if (element.labelTarget || !canHaveRootElementReference(element)) {
45839
46008
  return;
45840
46009
  }
45841
46010
 
@@ -45843,19 +46012,16 @@
45843
46012
  rootElement = getRootElement(businessObject);
45844
46013
 
45845
46014
  if (rootElement) {
46015
+
46016
+ // TODO(nikku): clone on copy
45846
46017
  descriptor.referencedRootElement = rootElement;
45847
46018
  }
45848
46019
  });
45849
46020
 
45850
46021
  eventBus.on('copyPaste.pasteElement', LOW_PRIORITY$a, function(context) {
45851
46022
  var descriptor = context.descriptor,
45852
- businessObject = descriptor.businessObject;
45853
-
45854
- if (!canHaveRootElementReference(businessObject)) {
45855
- return;
45856
- }
45857
-
45858
- var referencedRootElement = descriptor.referencedRootElement;
46023
+ businessObject = descriptor.businessObject,
46024
+ referencedRootElement = descriptor.referencedRootElement;
45859
46025
 
45860
46026
  if (!referencedRootElement) {
45861
46027
  return;
@@ -45869,6 +46035,8 @@
45869
46035
  }
45870
46036
 
45871
46037
  setRootElement(businessObject, referencedRootElement);
46038
+
46039
+ delete descriptor.referencedRootElement;
45872
46040
  });
45873
46041
  }
45874
46042
 
@@ -45927,6 +46095,10 @@
45927
46095
  if (is$1(shape, 'bpmn:TextAnnotation')) {
45928
46096
  minDimensions[ id ] = TEXT_ANNOTATION_MIN_DIMENSIONS;
45929
46097
  }
46098
+
46099
+ if (is$1(shape, 'bpmn:Group')) {
46100
+ minDimensions[ id ] = GROUP_MIN_DIMENSIONS;
46101
+ }
45930
46102
  });
45931
46103
 
45932
46104
  return minDimensions;
@@ -51638,7 +51810,7 @@
51638
51810
  var size,
51639
51811
  translate = this._translate;
51640
51812
 
51641
- attrs = attrs || {};
51813
+ attrs = assign({}, attrs || {});
51642
51814
 
51643
51815
  var businessObject = attrs.businessObject,
51644
51816
  di = attrs.di;
@@ -51655,6 +51827,7 @@
51655
51827
 
51656
51828
  if (!isModdleDi(di)) {
51657
51829
  var diAttrs = assign(
51830
+ {},
51658
51831
  di || {},
51659
51832
  { id: businessObject.id + '_di' }
51660
51833
  );
@@ -51675,7 +51848,7 @@
51675
51848
  }, attrs);
51676
51849
  }
51677
51850
 
51678
- applyAttributes(businessObject, attrs, [
51851
+ attrs = applyAttributes(businessObject, attrs, [
51679
51852
  'processRef',
51680
51853
  'isInterrupting',
51681
51854
  'associationDirection',
@@ -51683,7 +51856,7 @@
51683
51856
  ]);
51684
51857
 
51685
51858
  if (attrs.isExpanded) {
51686
- applyAttribute(di, attrs, 'isExpanded');
51859
+ attrs = applyAttribute(di, attrs, 'isExpanded');
51687
51860
  }
51688
51861
 
51689
51862
  if (is$1(businessObject, 'bpmn:SubProcess')) {
@@ -51816,14 +51989,16 @@
51816
51989
  * @param {Base} element
51817
51990
  * @param {Object} attrs (in/out map of attributes)
51818
51991
  * @param {Array<string>} attributeNames name of attributes to apply
51992
+ *
51993
+ * @return {Object} changed attrs
51819
51994
  */
51820
51995
  function applyAttributes(element, attrs, attributeNames) {
51821
51996
 
51822
51997
  forEach$1(attributeNames, function(property) {
51823
- if (attrs[property] !== undefined) {
51824
- applyAttribute(element, attrs, property);
51825
- }
51998
+ attrs = applyAttribute(element, attrs, property);
51826
51999
  });
52000
+
52001
+ return attrs;
51827
52002
  }
51828
52003
 
51829
52004
  /**
@@ -51833,11 +52008,17 @@
51833
52008
  * @param {Base} element
51834
52009
  * @param {Object} attrs (in/out map of attributes)
51835
52010
  * @param {string} attributeName to apply
52011
+ *
52012
+ * @return {Object} changed attrs
51836
52013
  */
51837
52014
  function applyAttribute(element, attrs, attributeName) {
52015
+ if (attrs[attributeName] === undefined) {
52016
+ return attrs;
52017
+ }
52018
+
51838
52019
  element[attributeName] = attrs[attributeName];
51839
52020
 
51840
- delete attrs[attributeName];
52021
+ return omit(attrs, [ attributeName ]);
51841
52022
  }
51842
52023
 
51843
52024
 
@@ -54216,6 +54397,9 @@
54216
54397
  throw new Error('<moddleElement> required');
54217
54398
  }
54218
54399
 
54400
+ // TODO(nikku): we need to ensure that ID properties
54401
+ // are properly registered / unregistered via
54402
+ // this._moddle.ids.assigned(id)
54219
54403
  var changed = context.changed || this.getVisualReferences(moddleElement).concat(element);
54220
54404
  var oldProperties = context.oldProperties || getModdleProperties(moddleElement, keys(properties));
54221
54405