bpmn-js 9.3.2 → 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 (24) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/assets/diagram-js.css +18 -8
  3. package/dist/bpmn-modeler.development.js +533 -356
  4. package/dist/bpmn-modeler.production.min.js +6 -6
  5. package/dist/bpmn-navigated-viewer.development.js +78 -73
  6. package/dist/bpmn-navigated-viewer.production.min.js +6 -6
  7. package/dist/bpmn-viewer.development.js +20 -17
  8. package/dist/bpmn-viewer.production.min.js +6 -6
  9. package/lib/features/copy-paste/BpmnCopyPaste.js +75 -69
  10. package/lib/features/copy-paste/ModdleCopy.js +26 -13
  11. package/lib/features/grid-snapping/behavior/{AutoPlaceBehavior.js → GridSnappingAutoPlaceBehavior.js} +2 -2
  12. package/lib/features/grid-snapping/behavior/{LayoutConnectionBehavior.js → GridSnappingLayoutConnectionBehavior.js} +4 -4
  13. package/lib/features/grid-snapping/behavior/{CreateParticipantBehavior.js → GridSnappingParticipantBehavior.js} +2 -2
  14. package/lib/features/grid-snapping/behavior/index.js +7 -7
  15. package/lib/features/label-editing/LabelEditingProvider.js +0 -22
  16. package/lib/features/modeling/ElementFactory.js +18 -8
  17. package/lib/features/modeling/behavior/BoundaryEventBehavior.js +1 -16
  18. package/lib/features/modeling/behavior/GroupBehavior.js +205 -93
  19. package/lib/features/modeling/behavior/ResizeBehavior.js +2 -0
  20. package/lib/features/modeling/behavior/RootElementReferenceBehavior.js +7 -8
  21. package/lib/features/modeling/behavior/SpaceToolBehavior.js +5 -0
  22. package/lib/features/modeling/behavior/util/CategoryUtil.js +66 -13
  23. package/lib/features/modeling/cmd/UpdateModdlePropertiesHandler.js +3 -0
  24. package/package.json +2 -2
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * bpmn-js - bpmn-modeler v9.3.2
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-08-04
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
 
@@ -23478,6 +23481,16 @@
23478
23481
  // default moddle extensions the viewer is composed of
23479
23482
  Viewer.prototype._moddleExtensions = {};
23480
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
+
23481
23494
  /**
23482
23495
  * Returns true if event was triggered with any modifier
23483
23496
  * @param {KeyboardEvent} event
@@ -23517,15 +23530,36 @@
23517
23530
  */
23518
23531
  function isShift(event) {
23519
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
+ );
23520
23553
  }
23521
23554
 
23522
23555
  var KEYDOWN_EVENT = 'keyboard.keydown',
23523
23556
  KEYUP_EVENT = 'keyboard.keyup';
23524
23557
 
23525
- var HANDLE_MODIFIER_ATTRIBUTE = 'input-handle-modified-keys';
23526
-
23527
23558
  var DEFAULT_PRIORITY$3 = 1000;
23528
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
+
23529
23563
  /**
23530
23564
  * A keyboard abstraction that may be activated and
23531
23565
  * deactivated by users at will, consuming key events
@@ -23544,8 +23578,8 @@
23544
23578
  *
23545
23579
  * All events contain one field which is node.
23546
23580
  *
23547
- * A default binding for the keyboard may be specified via the
23548
- * `keyboard.bindTo` configuration option.
23581
+ * Specify the initial keyboard binding state via the
23582
+ * `keyboard.bind=true|false` configuration option.
23549
23583
  *
23550
23584
  * @param {Config} config
23551
23585
  * @param {EventBus} eventBus
@@ -23553,7 +23587,8 @@
23553
23587
  function Keyboard(config, eventBus) {
23554
23588
  var self = this;
23555
23589
 
23556
- this._config = config || {};
23590
+ this._config = config = config || {};
23591
+
23557
23592
  this._eventBus = eventBus;
23558
23593
 
23559
23594
  this._keydownHandler = this._keydownHandler.bind(this);
@@ -23566,19 +23601,22 @@
23566
23601
  self.unbind();
23567
23602
  });
23568
23603
 
23569
- eventBus.on('diagram.init', function() {
23570
- self._fire('init');
23571
- });
23604
+ if (config.bindTo) {
23605
+ console.error('unsupported configuration <keyboard.bindTo>', new Error(compatMessage));
23606
+ }
23607
+
23608
+ var bind = config && config.bind !== false;
23572
23609
 
23573
- eventBus.on('attach', function() {
23574
- if (config && config.bindTo) {
23575
- self.bind(config.bindTo);
23610
+ eventBus.on('canvas.init', function(event) {
23611
+ self._target = event.svg;
23612
+
23613
+ if (bind) {
23614
+ self.bind();
23576
23615
  }
23577
- });
23578
23616
 
23579
- eventBus.on('detach', function() {
23580
- self.unbind();
23617
+ self._fire('init');
23581
23618
  });
23619
+
23582
23620
  }
23583
23621
 
23584
23622
  Keyboard.$inject = [
@@ -23613,34 +23651,19 @@
23613
23651
  };
23614
23652
 
23615
23653
  Keyboard.prototype._isEventIgnored = function(event) {
23616
- return isInput(event.target) && this._isModifiedKeyIgnored(event);
23617
- };
23618
-
23619
- Keyboard.prototype._isModifiedKeyIgnored = function(event) {
23620
- if (!isCmd(event)) {
23621
- return true;
23622
- }
23623
-
23624
- var allowedModifiers = this._getAllowedModifiers(event.target);
23625
- return allowedModifiers.indexOf(event.key) === -1;
23654
+ return false;
23626
23655
  };
23627
23656
 
23628
- Keyboard.prototype._getAllowedModifiers = function(element) {
23629
- var modifierContainer = closest(element, '[' + HANDLE_MODIFIER_ATTRIBUTE + ']', true);
23657
+ Keyboard.prototype.bind = function(node) {
23630
23658
 
23631
- if (!modifierContainer || (this._node && !this._node.contains(modifierContainer))) {
23632
- return [];
23659
+ if (node) {
23660
+ console.error('unsupported argument <node>', new Error(compatMessage));
23633
23661
  }
23634
23662
 
23635
- return modifierContainer.getAttribute(HANDLE_MODIFIER_ATTRIBUTE).split(',');
23636
- };
23637
-
23638
- Keyboard.prototype.bind = function(node) {
23639
-
23640
23663
  // make sure that the keyboard is only bound once to the DOM
23641
23664
  this.unbind();
23642
23665
 
23643
- this._node = node;
23666
+ node = this._node = this._target;
23644
23667
 
23645
23668
  // bind key events
23646
23669
  componentEvent.bind(node, 'keydown', this._keydownHandler, true);
@@ -23699,26 +23722,8 @@
23699
23722
  Keyboard.prototype.isShift = isShift;
23700
23723
  Keyboard.prototype.isKey = isKey;
23701
23724
 
23702
-
23703
-
23704
- // helpers ///////
23705
-
23706
- function isInput(target) {
23707
- return target && (matchesSelector(target, 'input, textarea') || target.contentEditable === 'true');
23708
- }
23709
-
23710
23725
  var LOW_PRIORITY$m = 500;
23711
23726
 
23712
- var KEYCODE_C = 67;
23713
- var KEYCODE_V = 86;
23714
- var KEYCODE_Y = 89;
23715
- var KEYCODE_Z = 90;
23716
-
23717
- var KEYS_COPY = [ 'c', 'C', KEYCODE_C ];
23718
- var KEYS_PASTE = [ 'v', 'V', KEYCODE_V ];
23719
- var KEYS_REDO = [ 'y', 'Y', KEYCODE_Y ];
23720
- var KEYS_UNDO = [ 'z', 'Z', KEYCODE_Z ];
23721
-
23722
23727
 
23723
23728
  /**
23724
23729
  * Adds default keyboard bindings.
@@ -23776,7 +23781,7 @@
23776
23781
 
23777
23782
  var event = context.keyEvent;
23778
23783
 
23779
- if (isCmd(event) && !isShift(event) && isKey(KEYS_UNDO, event)) {
23784
+ if (isUndo(event)) {
23780
23785
  editorActions.trigger('undo');
23781
23786
 
23782
23787
  return true;
@@ -23790,7 +23795,7 @@
23790
23795
 
23791
23796
  var event = context.keyEvent;
23792
23797
 
23793
- if (isCmd(event) && (isKey(KEYS_REDO, event) || (isKey(KEYS_UNDO, event) && isShift(event)))) {
23798
+ if (isRedo(event)) {
23794
23799
  editorActions.trigger('redo');
23795
23800
 
23796
23801
  return true;
@@ -23803,7 +23808,7 @@
23803
23808
 
23804
23809
  var event = context.keyEvent;
23805
23810
 
23806
- if (isCmd(event) && isKey(KEYS_COPY, event)) {
23811
+ if (isCopy(event)) {
23807
23812
  editorActions.trigger('copy');
23808
23813
 
23809
23814
  return true;
@@ -23816,7 +23821,7 @@
23816
23821
 
23817
23822
  var event = context.keyEvent;
23818
23823
 
23819
- if (isCmd(event) && isKey(KEYS_PASTE, event)) {
23824
+ if (isPaste(event)) {
23820
23825
  editorActions.trigger('paste');
23821
23826
 
23822
23827
  return true;
@@ -29988,7 +29993,7 @@
29988
29993
  bpmnAutoResizeProvider: [ 'type', BpmnAutoResizeProvider ]
29989
29994
  };
29990
29995
 
29991
- var HIGH_PRIORITY$l = 1500;
29996
+ var HIGH_PRIORITY$j = 1500;
29992
29997
 
29993
29998
 
29994
29999
  /**
@@ -30056,7 +30061,7 @@
30056
30061
  */
30057
30062
  eventBus.on('drag.start', function(event) {
30058
30063
 
30059
- eventBus.once('drag.move', HIGH_PRIORITY$l, function(event) {
30064
+ eventBus.once('drag.move', HIGH_PRIORITY$j, function(event) {
30060
30065
 
30061
30066
  ensureHover(event);
30062
30067
 
@@ -30087,7 +30092,7 @@
30087
30092
  hover = event.element;
30088
30093
  });
30089
30094
 
30090
- eventBus.on('element.hover', HIGH_PRIORITY$l, function(event) {
30095
+ eventBus.on('element.hover', HIGH_PRIORITY$j, function(event) {
30091
30096
 
30092
30097
  // (3) am I on an element still?
30093
30098
  if (hover) {
@@ -31917,7 +31922,7 @@
31917
31922
  MARKER_CONNECT_UPDATING$1 = 'djs-updating',
31918
31923
  MARKER_ELEMENT_HIDDEN = 'djs-element-hidden';
31919
31924
 
31920
- var HIGH_PRIORITY$k = 1100;
31925
+ var HIGH_PRIORITY$i = 1100;
31921
31926
 
31922
31927
  /**
31923
31928
  * Preview connection while moving bendpoints.
@@ -31980,7 +31985,7 @@
31980
31985
  eventBus.on([
31981
31986
  'bendpoint.move.out',
31982
31987
  'bendpoint.move.cleanup'
31983
- ], HIGH_PRIORITY$k, function(event) {
31988
+ ], HIGH_PRIORITY$i, function(event) {
31984
31989
  var context = event.context,
31985
31990
  hover = context.hover,
31986
31991
  target = context.target;
@@ -32066,7 +32071,7 @@
32066
32071
  eventBus.on([
32067
32072
  'bendpoint.move.end',
32068
32073
  'bendpoint.move.cancel'
32069
- ], HIGH_PRIORITY$k, function(event) {
32074
+ ], HIGH_PRIORITY$i, function(event) {
32070
32075
  var context = event.context,
32071
32076
  connection = context.connection,
32072
32077
  draggerGfx = context.draggerGfx,
@@ -33027,7 +33032,7 @@
33027
33032
  return hover && source && hover === source && source !== target;
33028
33033
  }
33029
33034
 
33030
- var HIGH_PRIORITY$j = 1100,
33035
+ var HIGH_PRIORITY$h = 1100,
33031
33036
  LOW_PRIORITY$j = 900;
33032
33037
 
33033
33038
  var MARKER_OK$3 = 'connect-ok',
@@ -33088,7 +33093,7 @@
33088
33093
  eventBus.on([
33089
33094
  'connect.out',
33090
33095
  'connect.cleanup'
33091
- ], HIGH_PRIORITY$j, function(event) {
33096
+ ], HIGH_PRIORITY$h, function(event) {
33092
33097
  var hover = event.hover;
33093
33098
 
33094
33099
  if (hover) {
@@ -34286,7 +34291,7 @@
34286
34291
 
34287
34292
  var PREFIX = 'create';
34288
34293
 
34289
- var HIGH_PRIORITY$i = 2000;
34294
+ var HIGH_PRIORITY$g = 2000;
34290
34295
 
34291
34296
 
34292
34297
  /**
@@ -34514,7 +34519,7 @@
34514
34519
  eventBus.on('create.init', function() {
34515
34520
  eventBus.on('elements.changed', cancel);
34516
34521
 
34517
- eventBus.once([ 'create.cancel', 'create.end' ], HIGH_PRIORITY$i, function() {
34522
+ eventBus.once([ 'create.cancel', 'create.end' ], HIGH_PRIORITY$g, function() {
34518
34523
  eventBus.off('elements.changed', cancel);
34519
34524
  });
34520
34525
  });
@@ -35462,67 +35467,52 @@
35462
35467
  });
35463
35468
  }
35464
35469
 
35465
- function removeProperties(element, properties) {
35466
- if (!isArray$3(properties)) {
35467
- properties = [ properties ];
35468
- }
35469
-
35470
- forEach$1(properties, function(property) {
35471
- if (element[property]) {
35472
- delete element[property];
35473
- }
35474
- });
35475
- }
35476
-
35477
35470
  var LOW_PRIORITY$h = 750;
35478
35471
 
35479
35472
 
35480
35473
  function BpmnCopyPaste(bpmnFactory, eventBus, moddleCopy) {
35481
35474
 
35482
- eventBus.on('copyPaste.copyElement', LOW_PRIORITY$h, function(context) {
35483
- var descriptor = context.descriptor,
35484
- element = context.element;
35485
-
35486
- var businessObject = descriptor.oldBusinessObject = getBusinessObject(element);
35487
- var di = descriptor.oldDi = getDi(element);
35475
+ function copy(bo, clone) {
35476
+ var targetBo = bpmnFactory.create(bo.$type);
35488
35477
 
35489
- descriptor.type = element.type;
35490
-
35491
- copyProperties$1(businessObject, descriptor, 'name');
35478
+ return moddleCopy.copyElement(bo, targetBo, null, clone);
35479
+ }
35492
35480
 
35493
- 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);
35494
35485
 
35495
- 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)) {
35496
35489
  return descriptor;
35497
35490
  }
35498
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
+
35499
35499
  // default sequence flow
35500
35500
  if (businessObject.default) {
35501
35501
  descriptor.default = businessObject.default.id;
35502
35502
  }
35503
35503
  });
35504
35504
 
35505
- eventBus.on('moddleCopy.canCopyProperty', function(context) {
35506
- var parent = context.parent,
35507
- property = context.property,
35508
- propertyName = context.propertyName,
35509
- bpmnProcess;
35510
-
35511
- if (
35512
- propertyName === 'processRef' &&
35513
- is$1(parent, 'bpmn:Participant') &&
35514
- is$1(property, 'bpmn:Process')
35515
- ) {
35516
- bpmnProcess = bpmnFactory.create('bpmn:Process');
35505
+ var referencesKey = '-bpmn-js-refs';
35517
35506
 
35518
- // return copy of process
35519
- return moddleCopy.copyElement(property, bpmnProcess);
35520
- }
35521
- });
35507
+ function getReferences(cache) {
35508
+ return (cache[referencesKey] = cache[referencesKey] || {});
35509
+ }
35522
35510
 
35523
- var references;
35511
+ function setReferences(cache, references) {
35512
+ cache[referencesKey] = references;
35513
+ }
35524
35514
 
35525
- function resolveReferences(descriptor, cache) {
35515
+ function resolveReferences(descriptor, cache, references) {
35526
35516
  var businessObject = getBusinessObject(descriptor);
35527
35517
 
35528
35518
  // default sequence flows
@@ -35542,7 +35532,7 @@
35542
35532
  getBusinessObject(descriptor).attachedToRef = getBusinessObject(cache[ descriptor.host ]);
35543
35533
  }
35544
35534
 
35545
- references = omit(references, reduce(references, function(array, reference, key) {
35535
+ return omit(references, reduce(references, function(array, reference, key) {
35546
35536
  var element = reference.element,
35547
35537
  property = reference.property;
35548
35538
 
@@ -35556,18 +35546,13 @@
35556
35546
  }, []));
35557
35547
  }
35558
35548
 
35559
- eventBus.on('copyPaste.pasteElements', function() {
35560
- references = {};
35561
- });
35562
-
35563
35549
  eventBus.on('copyPaste.pasteElement', function(context) {
35564
35550
  var cache = context.cache,
35565
35551
  descriptor = context.descriptor,
35566
- oldBusinessObject = descriptor.oldBusinessObject,
35567
- oldDi = descriptor.oldDi,
35568
- newBusinessObject, newDi;
35552
+ businessObject = descriptor.businessObject,
35553
+ di = descriptor.di;
35569
35554
 
35570
- // do NOT copy business object if external label
35555
+ // wire existing di + businessObject for external label
35571
35556
  if (isLabel$3(descriptor)) {
35572
35557
  descriptor.businessObject = getBusinessObject(cache[ descriptor.labelTarget ]);
35573
35558
  descriptor.di = getDi(cache[ descriptor.labelTarget ]);
@@ -35575,30 +35560,56 @@
35575
35560
  return;
35576
35561
  }
35577
35562
 
35578
- newBusinessObject = bpmnFactory.create(oldBusinessObject.$type);
35579
-
35580
- descriptor.businessObject = moddleCopy.copyElement(
35581
- oldBusinessObject,
35582
- newBusinessObject
35583
- );
35584
-
35585
- newDi = bpmnFactory.create(oldDi.$type);
35586
- newDi.bpmnElement = newBusinessObject;
35563
+ businessObject = descriptor.businessObject = copy(businessObject);
35587
35564
 
35588
- descriptor.di = moddleCopy.copyElement(
35589
- oldDi,
35590
- newDi
35591
- );
35592
-
35593
- // resolve references e.g. default sequence flow
35594
- resolveReferences(descriptor, cache);
35565
+ di = descriptor.di = copy(di);
35566
+ di.bpmnElement = businessObject;
35595
35567
 
35596
- copyProperties$1(descriptor, newBusinessObject, [
35568
+ copyProperties$1(descriptor, businessObject, [
35597
35569
  'isExpanded',
35598
35570
  'name'
35599
35571
  ]);
35600
35572
 
35601
- 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
+ );
35602
35613
  });
35603
35614
 
35604
35615
  }
@@ -35624,7 +35635,8 @@
35624
35635
  'flowElements',
35625
35636
  'lanes',
35626
35637
  'incoming',
35627
- 'outgoing'
35638
+ 'outgoing',
35639
+ 'categoryValue'
35628
35640
  ];
35629
35641
 
35630
35642
  /**
@@ -35733,10 +35745,11 @@
35733
35745
  * @param {ModdleElement} sourceElement
35734
35746
  * @param {ModdleElement} targetElement
35735
35747
  * @param {Array<string>} [propertyNames]
35748
+ * @param {boolean} clone
35736
35749
  *
35737
35750
  * @param {ModdleElement}
35738
35751
  */
35739
- ModdleCopy.prototype.copyElement = function(sourceElement, targetElement, propertyNames) {
35752
+ ModdleCopy.prototype.copyElement = function(sourceElement, targetElement, propertyNames, clone) {
35740
35753
  var self = this;
35741
35754
 
35742
35755
  if (propertyNames && !isArray$3(propertyNames)) {
@@ -35748,7 +35761,8 @@
35748
35761
  var canCopyProperties = this._eventBus.fire('moddleCopy.canCopyProperties', {
35749
35762
  propertyNames: propertyNames,
35750
35763
  sourceElement: sourceElement,
35751
- targetElement: targetElement
35764
+ targetElement: targetElement,
35765
+ clone: clone
35752
35766
  });
35753
35767
 
35754
35768
  if (canCopyProperties === false) {
@@ -35767,7 +35781,11 @@
35767
35781
  sourceProperty = sourceElement.get(propertyName);
35768
35782
  }
35769
35783
 
35770
- var copiedProperty = self.copyProperty(sourceProperty, targetElement, propertyName);
35784
+ var copiedProperty = self.copyProperty(sourceProperty, targetElement, propertyName, clone);
35785
+
35786
+ if (!isDefined(copiedProperty)) {
35787
+ return;
35788
+ }
35771
35789
 
35772
35790
  var canSetProperty = self._eventBus.fire('moddleCopy.canSetCopiedProperty', {
35773
35791
  parent: targetElement,
@@ -35779,9 +35797,9 @@
35779
35797
  return;
35780
35798
  }
35781
35799
 
35782
- if (isDefined(copiedProperty)) {
35783
- targetElement.set(propertyName, copiedProperty);
35784
- }
35800
+ // TODO(nikku): unclaim old IDs if ID property is copied over
35801
+ // this._moddle.getPropertyDescriptor(parent, propertyName)
35802
+ targetElement.set(propertyName, copiedProperty);
35785
35803
  });
35786
35804
 
35787
35805
  return targetElement;
@@ -35793,17 +35811,19 @@
35793
35811
  * @param {*} property
35794
35812
  * @param {ModdleElement} parent
35795
35813
  * @param {string} propertyName
35814
+ * @param {boolean} clone
35796
35815
  *
35797
35816
  * @returns {*}
35798
35817
  */
35799
- ModdleCopy.prototype.copyProperty = function(property, parent, propertyName) {
35818
+ ModdleCopy.prototype.copyProperty = function(property, parent, propertyName, clone) {
35800
35819
  var self = this;
35801
35820
 
35802
35821
  // allow others to copy property
35803
35822
  var copiedProperty = this._eventBus.fire('moddleCopy.canCopyProperty', {
35804
35823
  parent: parent,
35805
35824
  property: property,
35806
- propertyName: propertyName
35825
+ propertyName: propertyName,
35826
+ clone: clone
35807
35827
  });
35808
35828
 
35809
35829
  // return if copying is NOT allowed
@@ -35828,7 +35848,7 @@
35828
35848
 
35829
35849
  // copy id
35830
35850
  if (propertyDescriptor.isId) {
35831
- return this._copyId(property, parent);
35851
+ return property && this._copyId(property, parent, clone);
35832
35852
  }
35833
35853
 
35834
35854
  // copy arrays
@@ -35836,7 +35856,7 @@
35836
35856
  return reduce(property, function(childProperties, childProperty) {
35837
35857
 
35838
35858
  // recursion
35839
- copiedProperty = self.copyProperty(childProperty, parent, propertyName);
35859
+ copiedProperty = self.copyProperty(childProperty, parent, propertyName, clone);
35840
35860
 
35841
35861
  // copying might NOT be allowed
35842
35862
  if (copiedProperty) {
@@ -35858,7 +35878,7 @@
35858
35878
  copiedProperty.$parent = parent;
35859
35879
 
35860
35880
  // recursion
35861
- copiedProperty = self.copyElement(property, copiedProperty);
35881
+ copiedProperty = self.copyElement(property, copiedProperty, null, clone);
35862
35882
 
35863
35883
  return copiedProperty;
35864
35884
  }
@@ -35867,7 +35887,11 @@
35867
35887
  return property;
35868
35888
  };
35869
35889
 
35870
- ModdleCopy.prototype._copyId = function(id, element) {
35890
+ ModdleCopy.prototype._copyId = function(id, element, clone) {
35891
+
35892
+ if (clone) {
35893
+ return id;
35894
+ }
35871
35895
 
35872
35896
  // disallow if already taken
35873
35897
  if (this._moddle.ids.assigned(id)) {
@@ -39040,7 +39064,9 @@
39040
39064
  this.register('copy', function() {
39041
39065
  var selectedElements = selection.get();
39042
39066
 
39043
- copyPaste.copy(selectedElements);
39067
+ if (selectedElements.length) {
39068
+ return copyPaste.copy(selectedElements);
39069
+ }
39044
39070
  });
39045
39071
  }
39046
39072
 
@@ -39419,7 +39445,7 @@
39419
39445
  return Math[ fn ](value / quantum) * quantum;
39420
39446
  }
39421
39447
 
39422
- var LOWER_PRIORITY = 1200;
39448
+ var LOWER_PRIORITY$1 = 1200;
39423
39449
  var LOW_PRIORITY$f = 800;
39424
39450
 
39425
39451
  /**
@@ -39451,7 +39477,7 @@
39451
39477
  'resize.end',
39452
39478
  'shape.move.move',
39453
39479
  'shape.move.end'
39454
- ], LOWER_PRIORITY, function(event) {
39480
+ ], LOWER_PRIORITY$1, function(event) {
39455
39481
  var originalEvent = event.originalEvent;
39456
39482
 
39457
39483
  if (!self.active || (originalEvent && isCmd(originalEvent))) {
@@ -39919,7 +39945,7 @@
39919
39945
  return newBounds;
39920
39946
  };
39921
39947
 
39922
- var HIGH_PRIORITY$h = 2000;
39948
+ var HIGH_PRIORITY$f = 2000;
39923
39949
 
39924
39950
  /**
39925
39951
  * Integrates space tool with grid snapping.
@@ -39928,7 +39954,7 @@
39928
39954
  eventBus.on([
39929
39955
  'spaceTool.move',
39930
39956
  'spaceTool.end'
39931
- ], HIGH_PRIORITY$h, function(event) {
39957
+ ], HIGH_PRIORITY$f, function(event) {
39932
39958
  var context = event.context;
39933
39959
 
39934
39960
  if (!context.initialized) {
@@ -39977,11 +40003,11 @@
39977
40003
  gridSnapping: [ 'type', GridSnapping ]
39978
40004
  };
39979
40005
 
39980
- var HIGH_PRIORITY$g = 2000;
40006
+ var HIGH_PRIORITY$e = 2000;
39981
40007
 
39982
40008
 
39983
- function AutoPlaceBehavior(eventBus, gridSnapping) {
39984
- eventBus.on('autoPlace', HIGH_PRIORITY$g, function(context) {
40009
+ function GridSnappingAutoPlaceBehavior(eventBus, gridSnapping) {
40010
+ eventBus.on('autoPlace', HIGH_PRIORITY$e, function(context) {
39985
40011
  var source = context.source,
39986
40012
  sourceMid = getMid(source),
39987
40013
  shape = context.shape;
@@ -40021,7 +40047,7 @@
40021
40047
  });
40022
40048
  }
40023
40049
 
40024
- AutoPlaceBehavior.$inject = [
40050
+ GridSnappingAutoPlaceBehavior.$inject = [
40025
40051
  'eventBus',
40026
40052
  'gridSnapping'
40027
40053
  ];
@@ -40035,7 +40061,7 @@
40035
40061
  var HIGHER_PRIORITY$4 = 1750;
40036
40062
 
40037
40063
 
40038
- function CreateParticipantBehavior$1(canvas, eventBus, gridSnapping) {
40064
+ function GridSnappingParticipantBehavior(canvas, eventBus, gridSnapping) {
40039
40065
  eventBus.on([
40040
40066
  'create.start',
40041
40067
  'shape.move.start'
@@ -40061,19 +40087,19 @@
40061
40087
  });
40062
40088
  }
40063
40089
 
40064
- CreateParticipantBehavior$1.$inject = [
40090
+ GridSnappingParticipantBehavior.$inject = [
40065
40091
  'canvas',
40066
40092
  'eventBus',
40067
40093
  'gridSnapping'
40068
40094
  ];
40069
40095
 
40070
- var HIGH_PRIORITY$f = 3000;
40096
+ var HIGH_PRIORITY$d = 3000;
40071
40097
 
40072
40098
 
40073
40099
  /**
40074
40100
  * Snaps connections with Manhattan layout.
40075
40101
  */
40076
- function LayoutConnectionBehavior$1(eventBus, gridSnapping, modeling) {
40102
+ function GridSnappingLayoutConnectionBehavior(eventBus, gridSnapping, modeling) {
40077
40103
  CommandInterceptor.call(this, eventBus);
40078
40104
 
40079
40105
  this._gridSnapping = gridSnapping;
@@ -40083,7 +40109,7 @@
40083
40109
  this.postExecuted([
40084
40110
  'connection.create',
40085
40111
  'connection.layout'
40086
- ], HIGH_PRIORITY$f, function(event) {
40112
+ ], HIGH_PRIORITY$d, function(event) {
40087
40113
  var context = event.context,
40088
40114
  connection = context.connection,
40089
40115
  hints = context.hints || {},
@@ -40101,13 +40127,13 @@
40101
40127
  });
40102
40128
  }
40103
40129
 
40104
- LayoutConnectionBehavior$1.$inject = [
40130
+ GridSnappingLayoutConnectionBehavior.$inject = [
40105
40131
  'eventBus',
40106
40132
  'gridSnapping',
40107
40133
  'modeling'
40108
40134
  ];
40109
40135
 
40110
- e(LayoutConnectionBehavior$1, CommandInterceptor);
40136
+ e(GridSnappingLayoutConnectionBehavior, CommandInterceptor);
40111
40137
 
40112
40138
  /**
40113
40139
  * Snap middle segments of a given connection.
@@ -40116,7 +40142,7 @@
40116
40142
  *
40117
40143
  * @returns {Array<Point>}
40118
40144
  */
40119
- LayoutConnectionBehavior$1.prototype.snapMiddleSegments = function(waypoints) {
40145
+ GridSnappingLayoutConnectionBehavior.prototype.snapMiddleSegments = function(waypoints) {
40120
40146
  var gridSnapping = this._gridSnapping,
40121
40147
  snapped;
40122
40148
 
@@ -40205,12 +40231,12 @@
40205
40231
  var GridSnappingBehaviorModule = {
40206
40232
  __init__: [
40207
40233
  'gridSnappingAutoPlaceBehavior',
40208
- 'gridSnappingCreateParticipantBehavior',
40234
+ 'gridSnappingParticipantBehavior',
40209
40235
  'gridSnappingLayoutConnectionBehavior',
40210
40236
  ],
40211
- gridSnappingAutoPlaceBehavior: [ 'type', AutoPlaceBehavior ],
40212
- gridSnappingCreateParticipantBehavior: [ 'type', CreateParticipantBehavior$1 ],
40213
- gridSnappingLayoutConnectionBehavior: [ 'type', LayoutConnectionBehavior$1 ]
40237
+ gridSnappingAutoPlaceBehavior: [ 'type', GridSnappingAutoPlaceBehavior ],
40238
+ gridSnappingParticipantBehavior: [ 'type', GridSnappingParticipantBehavior ],
40239
+ gridSnappingLayoutConnectionBehavior: [ 'type', GridSnappingLayoutConnectionBehavior ]
40214
40240
  };
40215
40241
 
40216
40242
  var GridSnappingModule = {
@@ -41199,30 +41225,7 @@
41199
41225
  resizeHandles: [ 'type', ResizeHandles ]
41200
41226
  };
41201
41227
 
41202
- /**
41203
- * Creates a new bpmn:CategoryValue inside a new bpmn:Category
41204
- *
41205
- * @param {ModdleElement} definitions
41206
- * @param {BpmnFactory} bpmnFactory
41207
- *
41208
- * @return {ModdleElement} categoryValue.
41209
- */
41210
- function createCategoryValue(definitions, bpmnFactory) {
41211
- var categoryValue = bpmnFactory.create('bpmn:CategoryValue'),
41212
- category = bpmnFactory.create('bpmn:Category', {
41213
- categoryValue: [ categoryValue ]
41214
- });
41215
-
41216
- // add to correct place
41217
- add(definitions.get('rootElements'), category);
41218
- getBusinessObject(category).$parent = definitions;
41219
- getBusinessObject(categoryValue).$parent = category;
41220
-
41221
- return categoryValue;
41222
-
41223
- }
41224
-
41225
- var HIGH_PRIORITY$e = 2000;
41228
+ var HIGH_PRIORITY$c = 2000;
41226
41229
 
41227
41230
 
41228
41231
  function LabelEditingProvider(
@@ -41260,7 +41263,7 @@
41260
41263
  eventBus.on([
41261
41264
  'shape.remove',
41262
41265
  'connection.remove'
41263
- ], HIGH_PRIORITY$e, function(event) {
41266
+ ], HIGH_PRIORITY$c, function(event) {
41264
41267
 
41265
41268
  if (directEditing.isActive(event.element)) {
41266
41269
  directEditing.cancel();
@@ -41596,23 +41599,6 @@
41596
41599
  };
41597
41600
  }
41598
41601
 
41599
- if (is$1(element, 'bpmn:Group')) {
41600
-
41601
- var businessObject = getBusinessObject(element);
41602
-
41603
- // initialize categoryValue if not existing
41604
- if (!businessObject.categoryValueRef) {
41605
-
41606
- var rootElement = this._canvas.getRootElement(),
41607
- definitions = getBusinessObject(rootElement).$parent;
41608
-
41609
- var categoryValue = createCategoryValue(definitions, this._bpmnFactory);
41610
-
41611
- getBusinessObject(element).categoryValueRef = categoryValue;
41612
- }
41613
-
41614
- }
41615
-
41616
41602
  if (isEmptyText$1(newLabel)) {
41617
41603
  newLabel = null;
41618
41604
  }
@@ -42187,13 +42173,10 @@
42187
42173
  isAny(shape, [ 'bpmn:IntermediateThrowEvent', 'bpmn:IntermediateCatchEvent' ]) && !!host;
42188
42174
  }
42189
42175
 
42190
- var HIGH_PRIORITY$d = 2000;
42191
-
42192
-
42193
42176
  /**
42194
42177
  * BPMN specific boundary event behavior
42195
42178
  */
42196
- function BoundaryEventBehavior(eventBus, moddle, modeling) {
42179
+ function BoundaryEventBehavior(eventBus, modeling) {
42197
42180
 
42198
42181
  CommandInterceptor.call(this, eventBus);
42199
42182
 
@@ -42238,23 +42221,10 @@
42238
42221
  }
42239
42222
  });
42240
42223
 
42241
- // copy reference to root element on replace
42242
- eventBus.on('moddleCopy.canCopyProperty', HIGH_PRIORITY$d, function(context) {
42243
- var parent = context.parent,
42244
- property = context.property,
42245
- propertyName = context.propertyName;
42246
-
42247
- var propertyDescriptor = moddle.getPropertyDescriptor(parent, propertyName);
42248
-
42249
- if (propertyDescriptor && propertyDescriptor.isReference && is$1(property, 'bpmn:RootElement')) {
42250
- parent.set(propertyName, property);
42251
- }
42252
- });
42253
42224
  }
42254
42225
 
42255
42226
  BoundaryEventBehavior.$inject = [
42256
42227
  'eventBus',
42257
- 'moddle',
42258
42228
  'modeling'
42259
42229
  ];
42260
42230
 
@@ -42317,7 +42287,7 @@
42317
42287
 
42318
42288
  var PARTICIPANT_BORDER_WIDTH = 30;
42319
42289
 
42320
- var HIGH_PRIORITY$c = 2000;
42290
+ var HIGH_PRIORITY$b = 2000;
42321
42291
 
42322
42292
 
42323
42293
  /**
@@ -42330,7 +42300,7 @@
42330
42300
  eventBus.on([
42331
42301
  'create.start',
42332
42302
  'shape.move.start'
42333
- ], HIGH_PRIORITY$c, function(event) {
42303
+ ], HIGH_PRIORITY$b, function(event) {
42334
42304
  var context = event.context,
42335
42305
  shape = context.shape,
42336
42306
  rootElement = canvas.getRootElement();
@@ -42365,7 +42335,7 @@
42365
42335
  });
42366
42336
 
42367
42337
  // force hovering process when creating first participant
42368
- eventBus.on('create.start', HIGH_PRIORITY$c, function(event) {
42338
+ eventBus.on('create.start', HIGH_PRIORITY$b, function(event) {
42369
42339
  var context = event.context,
42370
42340
  shape = context.shape,
42371
42341
  rootElement = canvas.getRootElement(),
@@ -42377,7 +42347,7 @@
42377
42347
  }
42378
42348
 
42379
42349
  if (is$1(shape, 'bpmn:Participant') && is$1(rootElement, 'bpmn:Process')) {
42380
- eventBus.on('element.hover', HIGH_PRIORITY$c, ensureHoveringProcess);
42350
+ eventBus.on('element.hover', HIGH_PRIORITY$b, ensureHoveringProcess);
42381
42351
 
42382
42352
  eventBus.once('create.cleanup', function() {
42383
42353
  eventBus.off('element.hover', ensureHoveringProcess);
@@ -42398,7 +42368,7 @@
42398
42368
 
42399
42369
  // when creating mutliple elements through `elements.create` parent must be set to collaboration
42400
42370
  // and passed to `shape.create` as hint
42401
- this.preExecute('elements.create', HIGH_PRIORITY$c, function(context) {
42371
+ this.preExecute('elements.create', HIGH_PRIORITY$b, function(context) {
42402
42372
  var elements = context.elements,
42403
42373
  parent = context.parent,
42404
42374
  participant = findParticipant(elements),
@@ -43357,7 +43327,7 @@
43357
43327
  return is$1(connection, 'bpmn:SequenceFlow');
43358
43328
  }
43359
43329
 
43360
- var HIGH_PRIORITY$b = 1500;
43330
+ var HIGH_PRIORITY$a = 1500;
43361
43331
  var HIGHEST_PRIORITY = 2000;
43362
43332
 
43363
43333
 
@@ -43379,7 +43349,7 @@
43379
43349
  'shape.move.move',
43380
43350
  'shape.move.out',
43381
43351
  'shape.move.end'
43382
- ], HIGH_PRIORITY$b, function(event) {
43352
+ ], HIGH_PRIORITY$a, function(event) {
43383
43353
  var context = event.context,
43384
43354
  shape = context.shape || event.shape,
43385
43355
  hover = event.hover;
@@ -43410,7 +43380,7 @@
43410
43380
  'global-connect.out',
43411
43381
  'global-connect.end',
43412
43382
  'global-connect.cleanup'
43413
- ], HIGH_PRIORITY$b, function(event) {
43383
+ ], HIGH_PRIORITY$a, function(event) {
43414
43384
  var hover = event.hover;
43415
43385
 
43416
43386
  // ensure connections start/end on bpmn:Participant,
@@ -43424,7 +43394,7 @@
43424
43394
 
43425
43395
  eventBus.on([
43426
43396
  'bendpoint.move.hover'
43427
- ], HIGH_PRIORITY$b, function(event) {
43397
+ ], HIGH_PRIORITY$a, function(event) {
43428
43398
  var context = event.context,
43429
43399
  hover = event.hover,
43430
43400
  type = context.type;
@@ -43440,7 +43410,7 @@
43440
43410
 
43441
43411
  eventBus.on([
43442
43412
  'connect.start'
43443
- ], HIGH_PRIORITY$b, function(event) {
43413
+ ], HIGH_PRIORITY$a, function(event) {
43444
43414
  var context = event.context,
43445
43415
  start = context.start;
43446
43416
 
@@ -43469,7 +43439,85 @@
43469
43439
  'canvas'
43470
43440
  ];
43471
43441
 
43472
- 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;
43473
43521
 
43474
43522
 
43475
43523
  /**
@@ -43486,156 +43534,268 @@
43486
43534
  injector.invoke(CommandInterceptor, this);
43487
43535
 
43488
43536
  /**
43489
- * Removes a referenced category value for a given group shape
43537
+ * Returns all group element in the current registry
43490
43538
  *
43491
- * @param {djs.model.Shape} shape
43539
+ * @return {Array<djs.model.shape>} a list of group shapes
43492
43540
  */
43493
- function removeReferencedCategoryValue(shape) {
43494
-
43495
- var businessObject = getBusinessObject(shape),
43496
- categoryValue = businessObject.categoryValueRef;
43497
-
43498
- if (!categoryValue) {
43499
- return;
43500
- }
43501
-
43502
- var category = categoryValue.$parent;
43503
-
43504
- if (!categoryValue) {
43505
- return;
43506
- }
43507
-
43508
- remove(category.categoryValue, categoryValue);
43509
-
43510
- // cleanup category if it is empty
43511
- if (category && !category.categoryValue.length) {
43512
- removeCategory(category);
43513
- }
43541
+ function getGroupElements() {
43542
+ return elementRegistry.filter(function(e) {
43543
+ return is$1(e, 'bpmn:Group');
43544
+ });
43514
43545
  }
43515
43546
 
43516
43547
  /**
43517
- * Removes a given category from the definitions
43548
+ * Returns true if given category is referenced in one of the given elements
43518
43549
  *
43519
- * @param {ModdleElement} category
43550
+ * @param { djs.model.Element[] } elements
43551
+ * @param { ModdleElement } category
43552
+ *
43553
+ * @return { boolean }
43520
43554
  */
43521
- function removeCategory(category) {
43555
+ function isReferencedCategory(elements, category) {
43556
+ return elements.some(function(element) {
43557
+ var businessObject = getBusinessObject(element);
43522
43558
 
43523
- var definitions = bpmnjs.getDefinitions();
43559
+ var _category = businessObject.categoryValueRef && businessObject.categoryValueRef.$parent;
43524
43560
 
43525
- remove(definitions.get('rootElements'), category);
43561
+ return _category === category;
43562
+ });
43526
43563
  }
43527
43564
 
43528
43565
  /**
43529
- * Returns all group element in the current registry
43566
+ * Returns true if given categoryValue is referenced in one of the given elements
43530
43567
  *
43531
- * @return {Array<djs.model.shape>} a list of group shapes
43568
+ * @param { djs.model.Element[] } elements
43569
+ * @param { ModdleElement } categoryValue
43570
+ *
43571
+ * @return { boolean }
43532
43572
  */
43533
- function getGroupElements() {
43534
- return elementRegistry.filter(function(e) {
43535
- 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;
43536
43578
  });
43537
43579
  }
43538
43580
 
43539
43581
  /**
43540
- * Returns true if given categoryValue is referenced in one of the given elements
43582
+ * Remove category value unless it is still referenced
43541
43583
  *
43542
- * @param {Array<djs.model.shape>} elements
43543
43584
  * @param {ModdleElement} categoryValue
43544
- * @return {boolean}
43585
+ * @param {ModdleElement} category
43586
+ * @param {ModdleElement} businessObject
43545
43587
  */
43546
- function isReferenced(elements, categoryValue) {
43547
- return elements.some(function(e) {
43588
+ function removeCategoryValue(categoryValue, category, businessObject) {
43548
43589
 
43549
- var businessObject = getBusinessObject(e);
43550
-
43551
- return businessObject.categoryValueRef
43552
- && businessObject.categoryValueRef === categoryValue;
43590
+ var groups = getGroupElements().filter(function(element) {
43591
+ return element.businessObject !== businessObject;
43553
43592
  });
43593
+
43594
+ if (category && !isReferencedCategory(groups, category)) {
43595
+ unlinkCategory(category);
43596
+ }
43597
+
43598
+ if (categoryValue && !isReferencedCategoryValue(groups, categoryValue)) {
43599
+ unlinkCategoryValue(categoryValue);
43600
+ }
43554
43601
  }
43555
43602
 
43556
43603
  /**
43557
- * remove referenced category + value when group was deleted
43604
+ * Add category value
43605
+ *
43606
+ * @param {ModdleElement} categoryValue
43607
+ * @param {ModdleElement} category
43558
43608
  */
43559
- this.executed('shape.delete', function(event) {
43609
+ function addCategoryValue(categoryValue, category) {
43610
+ return linkCategoryValue(categoryValue, category, bpmnjs.getDefinitions());
43611
+ }
43560
43612
 
43561
- var context = event.context,
43562
- shape = context.shape;
43613
+ function setCategoryValue(element, context) {
43614
+ var businessObject = getBusinessObject(element),
43615
+ categoryValue = businessObject.categoryValueRef;
43563
43616
 
43564
- if (is$1(shape, 'bpmn:Group')) {
43617
+ if (!categoryValue) {
43618
+ categoryValue =
43619
+ businessObject.categoryValueRef =
43620
+ context.categoryValue = (
43621
+ context.categoryValue || createCategoryValue(bpmnFactory)
43622
+ );
43623
+ }
43565
43624
 
43566
- var businessObject = getBusinessObject(shape),
43567
- categoryValueRef = businessObject.categoryValueRef,
43568
- groupElements = getGroupElements();
43625
+ var category = categoryValue.$parent;
43569
43626
 
43570
- if (!isReferenced(groupElements, categoryValueRef)) {
43571
- removeReferencedCategoryValue(shape);
43572
- }
43627
+ if (!category) {
43628
+ category =
43629
+ categoryValue.$parent =
43630
+ context.category = (
43631
+ context.category || createCategory(bpmnFactory)
43632
+ );
43573
43633
  }
43574
- });
43575
43634
 
43576
- /**
43577
- * re-attach removed category
43578
- */
43579
- 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);
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
43580
43654
 
43655
+ this.execute('label.create', function(event) {
43581
43656
  var context = event.context,
43582
- shape = context.shape;
43657
+ labelTarget = context.labelTarget;
43658
+
43659
+ if (!is$1(labelTarget, 'bpmn:Group')) {
43660
+ return;
43661
+ }
43583
43662
 
43584
- if (is$1(shape, 'bpmn:Group')) {
43663
+ setCategoryValue(labelTarget, context);
43664
+ });
43585
43665
 
43586
- var businessObject = getBusinessObject(shape),
43587
- categoryValueRef = businessObject.categoryValueRef,
43588
- definitions = bpmnjs.getDefinitions(),
43589
- category = categoryValueRef ? categoryValueRef.$parent : null;
43666
+ this.revert('label.create', function(event) {
43667
+ var context = event.context,
43668
+ labelTarget = context.labelTarget;
43590
43669
 
43591
- add(category.get('categoryValue'), categoryValueRef);
43592
- add(definitions.get('rootElements'), category);
43670
+ if (!is$1(labelTarget, 'bpmn:Group')) {
43671
+ return;
43593
43672
  }
43673
+
43674
+ unsetCategoryValue(labelTarget, context);
43594
43675
  });
43595
43676
 
43596
- /**
43597
- * create new category + value when group was created
43598
- */
43599
- 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
+
43600
43682
  var context = event.context,
43601
43683
  shape = context.shape,
43602
43684
  businessObject = getBusinessObject(shape);
43603
43685
 
43604
- 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;
43692
+
43693
+ if (categoryValue) {
43694
+ category = context.category = categoryValue.$parent;
43695
+
43696
+ removeCategoryValue(categoryValue, category, businessObject);
43697
+
43698
+ businessObject.categoryValueRef = null;
43699
+ }
43700
+ });
43701
+
43702
+ this.reverted('shape.delete', function(event) {
43605
43703
 
43606
- var definitions = bpmnjs.getDefinitions(),
43607
- categoryValue = createCategoryValue(definitions, bpmnFactory);
43704
+ var context = event.context,
43705
+ shape = context.shape;
43608
43706
 
43609
- // link the reference to the Group
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) {
43610
43716
  businessObject.categoryValueRef = categoryValue;
43717
+
43718
+ addCategoryValue(categoryValue, category);
43611
43719
  }
43612
43720
  });
43613
43721
 
43614
43722
 
43615
- this.revert('shape.create', function(event) {
43723
+ // create new category + value when group was created
43616
43724
 
43725
+ this.execute('shape.create', function(event) {
43617
43726
  var context = event.context,
43618
43727
  shape = context.shape;
43619
43728
 
43620
- if (is$1(shape, 'bpmn:Group')) {
43621
- 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
+ });
43622
43737
 
43623
- delete getBusinessObject(shape).categoryValueRef;
43738
+ this.reverted('shape.create', function(event) {
43624
43739
 
43740
+ var context = event.context,
43741
+ shape = context.shape;
43742
+
43743
+ if (!is$1(shape, 'bpmn:Group') || shape.labelTarget) {
43744
+ return;
43745
+ }
43746
+
43747
+ if (getBusinessObject(shape).categoryValueRef) {
43748
+ unsetCategoryValue(shape, context);
43749
+ }
43750
+ });
43751
+
43752
+
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;
43774
+
43775
+ descriptor.categoryValue = copy(categoryValue, true);
43776
+
43777
+ if (categoryValue.$parent) {
43778
+ descriptor.category = copy(categoryValue.$parent, true);
43779
+ }
43625
43780
  }
43626
43781
  });
43627
43782
 
43628
- // copy bpmn:CategoryValue when copying element
43629
- eventBus.on('moddleCopy.canCopyProperty', HIGH_PRIORITY$a, function(context) {
43630
- var property = context.property,
43631
- categoryValue;
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;
43632
43788
 
43633
- if (is$1(property, 'bpmn:CategoryValue')) {
43634
- categoryValue = createCategoryValue(bpmnjs.getDefinitions(), bpmnFactory);
43789
+ if (categoryValue) {
43790
+ categoryValue = businessObject.categoryValueRef = copy(categoryValue);
43791
+ }
43635
43792
 
43636
- // return copy of category
43637
- return moddleCopy.copyElement(property, categoryValue);
43793
+ if (category) {
43794
+ categoryValue.$parent = copy(category);
43638
43795
  }
43796
+
43797
+ delete descriptor.category;
43798
+ delete descriptor.categoryValue;
43639
43799
  });
43640
43800
 
43641
43801
  }
@@ -45526,6 +45686,8 @@
45526
45686
 
45527
45687
  var HIGH_PRIORITY$9 = 1500;
45528
45688
 
45689
+ var GROUP_MIN_DIMENSIONS = { width: 140, height: 120 };
45690
+
45529
45691
  var LANE_MIN_DIMENSIONS = { width: 300, height: 60 };
45530
45692
 
45531
45693
  var PARTICIPANT_MIN_DIMENSIONS = { width: 300, height: 150 };
@@ -45842,7 +46004,7 @@
45842
46004
  var descriptor = context.descriptor,
45843
46005
  element = context.element;
45844
46006
 
45845
- if (!canHaveRootElementReference(element)) {
46007
+ if (element.labelTarget || !canHaveRootElementReference(element)) {
45846
46008
  return;
45847
46009
  }
45848
46010
 
@@ -45850,19 +46012,16 @@
45850
46012
  rootElement = getRootElement(businessObject);
45851
46013
 
45852
46014
  if (rootElement) {
46015
+
46016
+ // TODO(nikku): clone on copy
45853
46017
  descriptor.referencedRootElement = rootElement;
45854
46018
  }
45855
46019
  });
45856
46020
 
45857
46021
  eventBus.on('copyPaste.pasteElement', LOW_PRIORITY$a, function(context) {
45858
46022
  var descriptor = context.descriptor,
45859
- businessObject = descriptor.businessObject;
45860
-
45861
- if (!canHaveRootElementReference(businessObject)) {
45862
- return;
45863
- }
45864
-
45865
- var referencedRootElement = descriptor.referencedRootElement;
46023
+ businessObject = descriptor.businessObject,
46024
+ referencedRootElement = descriptor.referencedRootElement;
45866
46025
 
45867
46026
  if (!referencedRootElement) {
45868
46027
  return;
@@ -45876,6 +46035,8 @@
45876
46035
  }
45877
46036
 
45878
46037
  setRootElement(businessObject, referencedRootElement);
46038
+
46039
+ delete descriptor.referencedRootElement;
45879
46040
  });
45880
46041
  }
45881
46042
 
@@ -45934,6 +46095,10 @@
45934
46095
  if (is$1(shape, 'bpmn:TextAnnotation')) {
45935
46096
  minDimensions[ id ] = TEXT_ANNOTATION_MIN_DIMENSIONS;
45936
46097
  }
46098
+
46099
+ if (is$1(shape, 'bpmn:Group')) {
46100
+ minDimensions[ id ] = GROUP_MIN_DIMENSIONS;
46101
+ }
45937
46102
  });
45938
46103
 
45939
46104
  return minDimensions;
@@ -51645,7 +51810,7 @@
51645
51810
  var size,
51646
51811
  translate = this._translate;
51647
51812
 
51648
- attrs = attrs || {};
51813
+ attrs = assign({}, attrs || {});
51649
51814
 
51650
51815
  var businessObject = attrs.businessObject,
51651
51816
  di = attrs.di;
@@ -51662,6 +51827,7 @@
51662
51827
 
51663
51828
  if (!isModdleDi(di)) {
51664
51829
  var diAttrs = assign(
51830
+ {},
51665
51831
  di || {},
51666
51832
  { id: businessObject.id + '_di' }
51667
51833
  );
@@ -51682,7 +51848,7 @@
51682
51848
  }, attrs);
51683
51849
  }
51684
51850
 
51685
- applyAttributes(businessObject, attrs, [
51851
+ attrs = applyAttributes(businessObject, attrs, [
51686
51852
  'processRef',
51687
51853
  'isInterrupting',
51688
51854
  'associationDirection',
@@ -51690,7 +51856,7 @@
51690
51856
  ]);
51691
51857
 
51692
51858
  if (attrs.isExpanded) {
51693
- applyAttribute(di, attrs, 'isExpanded');
51859
+ attrs = applyAttribute(di, attrs, 'isExpanded');
51694
51860
  }
51695
51861
 
51696
51862
  if (is$1(businessObject, 'bpmn:SubProcess')) {
@@ -51823,14 +51989,16 @@
51823
51989
  * @param {Base} element
51824
51990
  * @param {Object} attrs (in/out map of attributes)
51825
51991
  * @param {Array<string>} attributeNames name of attributes to apply
51992
+ *
51993
+ * @return {Object} changed attrs
51826
51994
  */
51827
51995
  function applyAttributes(element, attrs, attributeNames) {
51828
51996
 
51829
51997
  forEach$1(attributeNames, function(property) {
51830
- if (attrs[property] !== undefined) {
51831
- applyAttribute(element, attrs, property);
51832
- }
51998
+ attrs = applyAttribute(element, attrs, property);
51833
51999
  });
52000
+
52001
+ return attrs;
51834
52002
  }
51835
52003
 
51836
52004
  /**
@@ -51840,11 +52008,17 @@
51840
52008
  * @param {Base} element
51841
52009
  * @param {Object} attrs (in/out map of attributes)
51842
52010
  * @param {string} attributeName to apply
52011
+ *
52012
+ * @return {Object} changed attrs
51843
52013
  */
51844
52014
  function applyAttribute(element, attrs, attributeName) {
52015
+ if (attrs[attributeName] === undefined) {
52016
+ return attrs;
52017
+ }
52018
+
51845
52019
  element[attributeName] = attrs[attributeName];
51846
52020
 
51847
- delete attrs[attributeName];
52021
+ return omit(attrs, [ attributeName ]);
51848
52022
  }
51849
52023
 
51850
52024
 
@@ -54223,6 +54397,9 @@
54223
54397
  throw new Error('<moddleElement> required');
54224
54398
  }
54225
54399
 
54400
+ // TODO(nikku): we need to ensure that ID properties
54401
+ // are properly registered / unregistered via
54402
+ // this._moddle.ids.assigned(id)
54226
54403
  var changed = context.changed || this.getVisualReferences(moddleElement).concat(element);
54227
54404
  var oldProperties = context.oldProperties || getModdleProperties(moddleElement, keys(properties));
54228
54405