bpmn-js 18.22.0 → 18.23.0

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 (38) hide show
  1. package/dist/assets/diagram-js.css +4 -0
  2. package/dist/bpmn-modeler.development.js +1094 -326
  3. package/dist/bpmn-modeler.production.min.js +50 -50
  4. package/dist/bpmn-navigated-viewer.development.js +38 -5
  5. package/dist/bpmn-navigated-viewer.production.min.js +3 -3
  6. package/dist/bpmn-viewer.development.js +38 -5
  7. package/dist/bpmn-viewer.production.min.js +3 -3
  8. package/lib/BaseViewer.d.ts.map +1 -1
  9. package/lib/BaseViewer.js +37 -3
  10. package/lib/features/modeling/Modeling.d.ts +13 -0
  11. package/lib/features/modeling/Modeling.d.ts.map +1 -1
  12. package/lib/features/modeling/Modeling.js +21 -0
  13. package/lib/features/modeling/behavior/CategoryRootElementReferenceBehavior.d.ts +19 -0
  14. package/lib/features/modeling/behavior/CategoryRootElementReferenceBehavior.d.ts.map +1 -0
  15. package/lib/features/modeling/behavior/CategoryRootElementReferenceBehavior.js +157 -0
  16. package/lib/features/modeling/behavior/GroupBehavior.d.ts +2 -8
  17. package/lib/features/modeling/behavior/GroupBehavior.d.ts.map +1 -1
  18. package/lib/features/modeling/behavior/GroupBehavior.js +65 -134
  19. package/lib/features/modeling/behavior/UpdateCategoryValueRefsBehavior.d.ts +17 -0
  20. package/lib/features/modeling/behavior/UpdateCategoryValueRefsBehavior.d.ts.map +1 -0
  21. package/lib/features/modeling/behavior/UpdateCategoryValueRefsBehavior.js +169 -0
  22. package/lib/features/modeling/behavior/UpdateFlowNodeRefsBehavior.d.ts +1 -1
  23. package/lib/features/modeling/behavior/UpdateFlowNodeRefsBehavior.d.ts.map +1 -1
  24. package/lib/features/modeling/behavior/UpdateFlowNodeRefsBehavior.js +35 -37
  25. package/lib/features/modeling/behavior/index.d.ts +4 -0
  26. package/lib/features/modeling/behavior/index.d.ts.map +1 -1
  27. package/lib/features/modeling/behavior/index.js +6 -0
  28. package/lib/features/modeling/behavior/util/CategoryUtil.d.ts +12 -3
  29. package/lib/features/modeling/behavior/util/CategoryUtil.d.ts.map +1 -1
  30. package/lib/features/modeling/behavior/util/CategoryUtil.js +25 -2
  31. package/lib/features/modeling/cmd/UpdateCategoryValueRefsHandler.d.ts +40 -0
  32. package/lib/features/modeling/cmd/UpdateCategoryValueRefsHandler.d.ts.map +1 -0
  33. package/lib/features/modeling/cmd/UpdateCategoryValueRefsHandler.js +424 -0
  34. package/lib/features/modeling/cmd/UpdateFlowNodeRefsHandler.d.ts +0 -8
  35. package/lib/features/modeling/cmd/UpdateFlowNodeRefsHandler.d.ts.map +1 -1
  36. package/lib/features/modeling/cmd/UpdateFlowNodeRefsHandler.js +1 -9
  37. package/lib/features/rules/BpmnRules.js +38 -0
  38. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"BaseViewer.d.ts","mappings":";;;;;;;;;qBA8IAA;;;;EAAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAsDW,MAAM,gBACN,cAAa,EAAC,MAAM,GAEnB,OAAO,CAAC,eAAe,CAAC;;;;;;;;;;;;;;;;;;;;;;;;iCAuGzB,aAAa,gBACb,cAAa,EAAC,MAAM,GAEnB,OAAO,CAAC,uBAAuB,CAAC;;;;;;;;;;;;;;;;;;;;;;;wBA2BjC,cAAa,EAAC,MAAM,GAEnB,OAAO,CAAC,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;oBA4DpB,cAAc,GAEb,OAAO,CAAC,aAAa,CAAC;;;;;;;;;;;;;;;;;;;;;aAuEtB,OAAO,CAAC,aAAa,CAAC;;;;;;;EA0Db,cAFT,iBAAiB,EAAE;;;;;;;;;;;;;;;;;;;;EA+FV;;;;;;;;;;;;;;;;;;;;;;;;;EAAA;;;;;;;;;;;;;;;;;;;;;;;;;EAAA;;;;;;;;;;;;;;;;;;;;;EAAA;;;;;;;;;;;;;;;;;;;;;;;EAAA;;;;;;;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,aAAa;;+BAEZ;IACT,KAAK,CAAC,EAAE,KAAK;IACb,GAAG,EAAE,MAAM;CACb;;qBAIU,IAAG,IAEF,KAAG,QAAU;IAAE,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC;EAAE,EAAI,IAAI,KAAI;;oBAxHjD,YAAY","names":["BaseViewer class","BaseViewer constructor"],"ignoreList":[],"sources":["BaseViewer.js"]}
package/lib/BaseViewer.js CHANGED
@@ -14,6 +14,7 @@ import {
14
14
  import {
15
15
  domify,
16
16
  assignStyle,
17
+ classes as domClasses,
17
18
  query as domQuery,
18
19
  remove as domRemove
19
20
  } from 'min-dom';
@@ -31,6 +32,23 @@ import {
31
32
  importBpmnDiagram
32
33
  } from './import/Importer';
33
34
 
35
+ /**
36
+ * Padding added around the diagram bounds on SVG export.
37
+ *
38
+ * `getBBox` returns the geometry bounds only, excluding element strokes, so
39
+ * without padding strokes at the diagram edges get clipped. Historically this
40
+ * padding was provided implicitly by element outlines, which diagram-js now
41
+ * creates lazily (diagram-js@15.19, bpmn-io/diagram-js#1064).
42
+ */
43
+ const EXPORT_PADDING = 5;
44
+
45
+ /**
46
+ * Class set on the canvas container to hide element outlines, which diagram-js
47
+ * excludes from rendering while present. Applied when measuring the export
48
+ * bounds so lazily created outlines do not skew them.
49
+ */
50
+ const OUTLINE_HIDDEN_CLS = 'djs-outline-hidden';
51
+
34
52
  /**
35
53
  * @template T
36
54
  *
@@ -481,15 +499,31 @@ BaseViewer.prototype.saveSVG = async function saveSVG() {
481
499
  const contents = innerSVG(contentNode),
482
500
  defs = defsNode ? '<defs>' + innerSVG(defsNode) + '</defs>' : '';
483
501
 
484
- const bbox = contentNode.getBBox();
502
+ // hide outlines so they do not skew the measured bounds
503
+ const container = canvas.getContainer();
504
+
505
+ domClasses(container).add(OUTLINE_HIDDEN_CLS);
506
+
507
+ let bbox;
508
+
509
+ try {
510
+ bbox = contentNode.getBBox();
511
+ } finally {
512
+ domClasses(container).remove(OUTLINE_HIDDEN_CLS);
513
+ }
514
+
515
+ const x = bbox.x - EXPORT_PADDING,
516
+ y = bbox.y - EXPORT_PADDING,
517
+ width = bbox.width + EXPORT_PADDING * 2,
518
+ height = bbox.height + EXPORT_PADDING * 2;
485
519
 
486
520
  svg =
487
521
  '<?xml version="1.0" encoding="utf-8"?>\n' +
488
522
  '<!-- created with bpmn-js / http://bpmn.io -->\n' +
489
523
  '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n' +
490
524
  '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" ' +
491
- 'width="' + bbox.width + '" height="' + bbox.height + '" ' +
492
- 'viewBox="' + bbox.x + ' ' + bbox.y + ' ' + bbox.width + ' ' + bbox.height + '" version="1.1">' +
525
+ 'width="' + width + '" height="' + height + '" ' +
526
+ 'viewBox="' + x + ' ' + y + ' ' + width + ' ' + height + '" version="1.1">' +
493
527
  defs + contents +
494
528
  '</svg>';
495
529
  } catch (e) {
@@ -102,6 +102,14 @@ export default class Modeling<T extends Connection = import("../../model/Types")
102
102
  */
103
103
  updateLaneRefs(flowNodeShapes: Shape[], laneShapes: Shape[]): void;
104
104
 
105
+ /**
106
+ * Update the referenced category values of each flow element.
107
+ *
108
+ * @param affectedFlowElements The flow elements to update.
109
+ * @param affectedGroupEntries The groups to update.
110
+ */
111
+ updateCategoryValueRefs(affectedFlowElements: Element[], affectedGroupEntries: GroupEntry[]): void;
112
+
105
113
  /**
106
114
  * Claim an ID.
107
115
  *
@@ -146,5 +154,10 @@ export type UpdateLabelHints = {
146
154
  removeShape?: boolean;
147
155
  };
148
156
 
157
+ export type GroupEntry = {
158
+ categoryValue?: ModdleElement;
159
+ groupShape: Shape;
160
+ };
161
+
149
162
  import BaseModeling from 'diagram-js/lib/features/modeling/Modeling';
150
163
  //# sourceMappingURL=Modeling.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Modeling.d.ts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reList":[],"sources":["Modeling.js"]}
@@ -9,6 +9,7 @@ import AddLaneHandler from './cmd/AddLaneHandler';
9
9
  import SplitLaneHandler from './cmd/SplitLaneHandler';
10
10
  import ResizeLaneHandler from './cmd/ResizeLaneHandler';
11
11
  import UpdateFlowNodeRefsHandler from './cmd/UpdateFlowNodeRefsHandler';
12
+ import UpdateCategoryValueRefsHandler from './cmd/UpdateCategoryValueRefsHandler';
12
13
  import IdClaimHandler from './cmd/IdClaimHandler';
13
14
  import SetColorHandler from './cmd/SetColorHandler';
14
15
 
@@ -37,6 +38,11 @@ import UpdateLabelHandler from '../label-editing/cmd/UpdateLabelHandler';
37
38
  * @typedef { {
38
39
  * removeShape?: boolean;
39
40
  * } } UpdateLabelHints
41
+ *
42
+ * @typedef { {
43
+ * categoryValue?: ModdleElement;
44
+ * groupShape: Shape;
45
+ * } } GroupEntry
40
46
  */
41
47
 
42
48
  /**
@@ -87,6 +93,7 @@ Modeling.prototype.getHandlers = function() {
87
93
  handlers['lane.resize'] = ResizeLaneHandler;
88
94
  handlers['lane.split'] = SplitLaneHandler;
89
95
  handlers['lane.updateRefs'] = UpdateFlowNodeRefsHandler;
96
+ handlers['group.updateRefs'] = UpdateCategoryValueRefsHandler;
90
97
  handlers['id.updateClaim'] = IdClaimHandler;
91
98
  handlers['element.setColor'] = SetColorHandler;
92
99
  handlers['element.updateLabel'] = UpdateLabelHandler;
@@ -264,6 +271,20 @@ Modeling.prototype.updateLaneRefs = function(flowNodeShapes, laneShapes) {
264
271
  });
265
272
  };
266
273
 
274
+ /**
275
+ * Update the referenced category values of each flow element.
276
+ *
277
+ * @param {Element[]} affectedFlowElements The flow elements to update.
278
+ * @param {GroupEntry[]} affectedGroupEntries The groups to update.
279
+ */
280
+ Modeling.prototype.updateCategoryValueRefs = function(affectedFlowElements, affectedGroupEntries) {
281
+
282
+ this._commandStack.execute('group.updateRefs', {
283
+ affectedFlowElements: affectedFlowElements,
284
+ affectedGroupEntries: affectedGroupEntries
285
+ });
286
+ };
287
+
267
288
  /**
268
289
  * Claim an ID.
269
290
  *
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Maintains a group's category (value) inside definitions#rootElements.
3
+ *
4
+ */
5
+ export default class CategoryRootElementReferenceBehavior extends CommandInterceptor {
6
+ /**
7
+ * @param bpmnjs
8
+ * @param elementRegistry
9
+ * @param injector
10
+ */
11
+ constructor(bpmnjs: Modeler, elementRegistry: ElementRegistry, injector: Injector);
12
+ }
13
+
14
+ type Modeler = import("../../../Modeler").default;
15
+ type ElementRegistry = import("diagram-js/lib/core/ElementRegistry").default;
16
+ type Injector = import("didi").Injector;
17
+
18
+ import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
19
+ //# sourceMappingURL=CategoryRootElementReferenceBehavior.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CategoryRootElementReferenceBehavior.d.ts","mappings":";;;;qBA8BAA;;;;;;IAAAC;;;eAZa,OAAO,kBAAkB,EAAE;uBAC3B,OAAO,qCAAqC,EAAE;gBAC9C,OAAO,MAAM,EAAE;;+BAlBG,2CAA2C","names":["CategoryRootElementReferenceBehavior class","CategoryRootElementReferenceBehavior constructor"],"ignoreList":[],"sources":["CategoryRootElementReferenceBehavior.js"]}
@@ -0,0 +1,157 @@
1
+ import inherits from 'inherits-browser';
2
+
3
+ import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
4
+
5
+ import {
6
+ getBusinessObject,
7
+ is
8
+ } from '../../../util/ModelUtil';
9
+
10
+ import {
11
+ linkCategoryValue,
12
+ unlinkCategory,
13
+ unlinkCategoryValue
14
+ } from './util/CategoryUtil';
15
+
16
+ var LOW_PRIORITY = 500;
17
+
18
+ /**
19
+ * @typedef {import('../../../Modeler').default} Modeler
20
+ * @typedef {import('diagram-js/lib/core/ElementRegistry').default} ElementRegistry
21
+ * @typedef {import('didi').Injector} Injector
22
+ */
23
+
24
+ /**
25
+ * Maintains a group's category (value) inside definitions#rootElements.
26
+ *
27
+ * @param {Modeler} bpmnjs
28
+ * @param {ElementRegistry} elementRegistry
29
+ * @param {Injector} injector
30
+ */
31
+ export default function CategoryRootElementReferenceBehavior(
32
+ bpmnjs, elementRegistry, injector
33
+ ) {
34
+ injector.invoke(CommandInterceptor, this);
35
+
36
+ function getGroupBusinessObjects(ignoredBusinessObject) {
37
+ return elementRegistry.filter(function(element) {
38
+ return is(element, 'bpmn:Group') && !element.labelTarget;
39
+ }).map(getBusinessObject).filter(function(businessObject) {
40
+ return businessObject !== ignoredBusinessObject;
41
+ });
42
+ }
43
+
44
+ function isCategoryValueReferenced(categoryValue, ignoredBusinessObject) {
45
+ return getGroupBusinessObjects(ignoredBusinessObject).some(function(businessObject) {
46
+ return businessObject.get('categoryValueRef') === categoryValue;
47
+ });
48
+ }
49
+
50
+ function isCategoryReferenced(category, ignoredBusinessObject) {
51
+ return getGroupBusinessObjects(ignoredBusinessObject).some(function(businessObject) {
52
+ var categoryValue = businessObject.get('categoryValueRef');
53
+
54
+ return categoryValue && categoryValue.$parent === category;
55
+ });
56
+ }
57
+
58
+ function link(categoryValue, category) {
59
+ if (categoryValue && category) {
60
+ linkCategoryValue(categoryValue, category, bpmnjs.getDefinitions());
61
+ }
62
+ }
63
+
64
+ function unlink(categoryValue, category, ignoredBusinessObject) {
65
+ if (category && !isCategoryReferenced(category, ignoredBusinessObject)) {
66
+ unlinkCategory(category);
67
+ }
68
+
69
+ if (categoryValue && !isCategoryValueReferenced(categoryValue, ignoredBusinessObject)) {
70
+ unlinkCategoryValue(categoryValue);
71
+ }
72
+ }
73
+
74
+
75
+ this.executed([ 'shape.create', 'label.create' ], function(context) {
76
+ var shape = context.labelTarget || context.shape;
77
+
78
+ if (!is(shape, 'bpmn:Group') || shape.labelTarget) {
79
+ return;
80
+ }
81
+
82
+ link(context.categoryValue, context.category);
83
+ }, true);
84
+
85
+ this.reverted([ 'shape.create', 'label.create' ], function(context) {
86
+ var shape = context.labelTarget || context.shape;
87
+
88
+ if (!is(shape, 'bpmn:Group') || shape.labelTarget) {
89
+ return;
90
+ }
91
+
92
+ unlink(context.categoryValue, context.category, getBusinessObject(shape));
93
+ }, true);
94
+
95
+ this.executed([ 'shape.move', 'shape.resize' ], LOW_PRIORITY, function(context) {
96
+ link(context.categoryValue, context.category);
97
+ }, true);
98
+
99
+ this.reverted([ 'shape.move', 'shape.resize' ], function(context) {
100
+ var shape = context.shape;
101
+
102
+ if (context.categoryValue) {
103
+ unlink(context.categoryValue, context.category, getBusinessObject(shape));
104
+ }
105
+ }, true);
106
+
107
+ this.executed('group.updateRefs', function(context) {
108
+ getGroupUpdates(context).forEach(function(update) {
109
+ link(update.categoryValue, update.category);
110
+ });
111
+ }, true);
112
+
113
+ this.reverted('group.updateRefs', function(context) {
114
+ getGroupUpdates(context).forEach(function(update) {
115
+ unlink(
116
+ update.categoryValue,
117
+ update.category,
118
+ getBusinessObject(update.groupShape)
119
+ );
120
+ });
121
+ }, true);
122
+
123
+ this.executed('shape.delete', function(context) {
124
+ var shape = context.shape;
125
+
126
+ if (!is(shape, 'bpmn:Group') || shape.labelTarget) {
127
+ return;
128
+ }
129
+
130
+ unlink(context.categoryValue, context.category, getBusinessObject(shape));
131
+ }, true);
132
+
133
+ this.reverted('shape.delete', function(context) {
134
+ var shape = context.shape;
135
+
136
+ if (!is(shape, 'bpmn:Group') || shape.labelTarget) {
137
+ return;
138
+ }
139
+
140
+ link(context.categoryValue, context.category);
141
+ }, true);
142
+ }
143
+
144
+ CategoryRootElementReferenceBehavior.$inject = [
145
+ 'bpmnjs',
146
+ 'elementRegistry',
147
+ 'injector'
148
+ ];
149
+
150
+ inherits(CategoryRootElementReferenceBehavior, CommandInterceptor);
151
+
152
+
153
+ // helpers //////////
154
+
155
+ function getGroupUpdates(context) {
156
+ return context.updates?.groups || [];
157
+ }
@@ -5,24 +5,18 @@
5
5
  export default class GroupBehavior extends CommandInterceptor {
6
6
  /**
7
7
  * @param bpmnFactory
8
- * @param bpmnjs
9
- * @param elementRegistry
10
8
  * @param eventBus
11
9
  * @param injector
12
10
  * @param moddleCopy
13
11
  */
14
- constructor(bpmnFactory: BpmnFactory, bpmnjs: Modeler, elementRegistry: ElementRegistry, eventBus: EventBus, injector: Injector, moddleCopy: ModdleCopy);
12
+ constructor(bpmnFactory: BpmnFactory, eventBus: EventBus, injector: Injector, moddleCopy: ModdleCopy);
15
13
  }
16
14
 
17
15
  type BpmnFactory = import("../BpmnFactory").default;
18
- type Modeler = import("../../../Modeler").default;
19
- type ElementRegistry = import("diagram-js/lib/core/ElementRegistry").default;
20
16
  type EventBus = import("diagram-js/lib/core/EventBus").default;
17
+ type ElementRegistry = import("diagram-js/lib/core/ElementRegistry").default;
21
18
  type Injector = import("didi").Injector;
22
19
  type ModdleCopy = import("../../copy-paste/ModdleCopy").default;
23
- type Element = import("../../../model/Types").Element;
24
- type Shape = import("../../../model/Types").Shape;
25
- type DirectionTRBL = import("diagram-js/lib/util/Types").DirectionTRBL;
26
20
 
27
21
  import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
28
22
  //# sourceMappingURL=GroupBehavior.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"GroupBehavior.d.ts","mappings":";;;;AA4CAA;;;;;;;;;IAAAC;;;mBA1Ba,OAAO,gBAAgB,EAAE;eACzB,OAAO,kBAAkB,EAAE;uBAC3B,OAAO,qCAAqC,EAAE;gBAC9C,OAAO,8BAA8B,EAAE;gBACvC,OAAO,MAAM,EAAE;kBACf,OAAO,6BAA6B,EAAE;eAEtC,OAAO,sBAAsB,EAAE;aAC/B,OAAO,sBAAsB,EAAE;qBAE/B,OAAO,2BAA2B,EAAE;;+BA1BlB,2CAA2C","names":["GroupBehavior class","GroupBehavior constructor"],"ignoreList":[],"sources":["GroupBehavior.js"]}
1
+ {"version":3,"file":"GroupBehavior.d.ts","mappings":";;;;AAiCAA;;;;;;;IAAAC;;;mBAlBa,OAAO,gBAAgB,EAAE;gBACzB,OAAO,8BAA8B,EAAE;uBACvC,OAAO,qCAAqC,EAAE;gBAC9C,OAAO,MAAM,EAAE;kBACf,OAAO,6BAA6B,EAAE;;+BAjBpB,2CAA2C","names":["GroupBehavior class","GroupBehavior constructor"],"ignoreList":[],"sources":["GroupBehavior.js"]}
@@ -8,25 +8,16 @@ import {
8
8
  } from '../../../util/ModelUtil';
9
9
 
10
10
  import {
11
- createCategory,
12
- createCategoryValue,
13
- linkCategoryValue,
14
- unlinkCategory,
15
- unlinkCategoryValue
11
+ getOrCreateCategoryValueForGroup,
12
+ createCategory
16
13
  } from './util/CategoryUtil';
17
14
 
18
15
  /**
19
16
  * @typedef {import('../BpmnFactory').default} BpmnFactory
20
- * @typedef {import('../../../Modeler').default} Modeler
21
- * @typedef {import('diagram-js/lib/core/ElementRegistry').default} ElementRegistry
22
17
  * @typedef {import('diagram-js/lib/core/EventBus').default} EventBus
18
+ * @typedef {import('diagram-js/lib/core/ElementRegistry').default} ElementRegistry
23
19
  * @typedef {import('didi').Injector} Injector
24
20
  * @typedef {import('../../copy-paste/ModdleCopy').default} ModdleCopy
25
- *
26
- * @typedef {import('../../../model/Types').Element} Element
27
- * @typedef {import('../../../model/Types').Shape} Shape
28
- *
29
- * @typedef {import('diagram-js/lib/util/Types').DirectionTRBL} DirectionTRBL
30
21
  */
31
22
 
32
23
  var LOWER_PRIORITY = 770;
@@ -36,137 +27,45 @@ var LOWER_PRIORITY = 770;
36
27
  * BPMN specific group behavior.
37
28
  *
38
29
  * @param {BpmnFactory} bpmnFactory
39
- * @param {Modeler} bpmnjs
40
- * @param {ElementRegistry} elementRegistry
41
30
  * @param {EventBus} eventBus
42
31
  * @param {Injector} injector
43
32
  * @param {ModdleCopy} moddleCopy
44
33
  */
45
34
  export default function GroupBehavior(
46
35
  bpmnFactory,
47
- bpmnjs,
48
- elementRegistry,
49
36
  eventBus,
50
37
  injector,
51
38
  moddleCopy
52
39
  ) {
53
40
  injector.invoke(CommandInterceptor, this);
54
41
 
55
- /**
56
- * Returns all group element in the current registry.
57
- *
58
- * @return {Shape[]}
59
- */
60
- function getGroupElements() {
61
- return elementRegistry.filter(function(e) {
62
- return is(e, 'bpmn:Group');
63
- });
64
- }
65
-
66
- /**
67
- * Returns true if given category is referenced in one of the given elements.
68
- *
69
- * @param {Element[]} elements
70
- * @param {ModdleElement} category
71
- *
72
- * @return {boolean}
73
- */
74
- function isReferencedCategory(elements, category) {
75
- return elements.some(function(element) {
76
- var businessObject = getBusinessObject(element);
77
-
78
- var _category = businessObject.categoryValueRef && businessObject.categoryValueRef.$parent;
79
-
80
- return _category === category;
81
- });
82
- }
83
-
84
- /**
85
- * Returns true if given categoryValue is referenced in one of the given elements.
86
- *
87
- * @param {Element[]} elements
88
- * @param {ModdleElement} categoryValue
89
- *
90
- * @return {boolean}
91
- */
92
- function isReferencedCategoryValue(elements, categoryValue) {
93
- return elements.some(function(element) {
94
- var businessObject = getBusinessObject(element);
95
-
96
- return businessObject.categoryValueRef === categoryValue;
97
- });
98
- }
99
-
100
- /**
101
- * Remove category value unless it is still referenced.
102
- *
103
- * @param {ModdleElement} categoryValue
104
- * @param {ModdleElement} category
105
- * @param {ModdleElement} businessObject
106
- */
107
- function removeCategoryValue(categoryValue, category, businessObject) {
108
-
109
- var groups = getGroupElements().filter(function(element) {
110
- return element.businessObject !== businessObject;
111
- });
112
-
113
- if (category && !isReferencedCategory(groups, category)) {
114
- unlinkCategory(category);
115
- }
116
-
117
- if (categoryValue && !isReferencedCategoryValue(groups, categoryValue)) {
118
- unlinkCategoryValue(categoryValue);
119
- }
120
- }
121
-
122
- /**
123
- * Add category value.
124
- *
125
- * @param {ModdleElement} categoryValue
126
- * @param {ModdleElement} category
127
- *
128
- * @return {ModdleElement}
129
- */
130
- function addCategoryValue(categoryValue, category) {
131
- return linkCategoryValue(categoryValue, category, bpmnjs.getDefinitions());
132
- }
133
-
134
42
  function setCategoryValue(element, context) {
135
43
  var businessObject = getBusinessObject(element),
136
- categoryValue = businessObject.categoryValueRef;
44
+ categoryValue = context.categoryValue || businessObject.categoryValueRef;
137
45
 
138
46
  if (!categoryValue) {
139
- categoryValue =
140
- businessObject.categoryValueRef =
141
- context.categoryValue = (
142
- context.categoryValue || createCategoryValue(bpmnFactory)
143
- );
47
+ categoryValue = getOrCreateCategoryValueForGroup(bpmnFactory, businessObject);
144
48
  }
145
49
 
146
- var category = categoryValue.$parent;
50
+ var category = context.category || categoryValue.$parent || createCategory(bpmnFactory);
147
51
 
148
- if (!category) {
149
- category =
150
- categoryValue.$parent =
151
- context.category = (
152
- context.category || createCategory(bpmnFactory)
153
- );
154
- }
52
+ businessObject.categoryValueRef = categoryValue;
53
+ categoryValue.$parent = category;
155
54
 
156
- addCategoryValue(categoryValue, category, bpmnjs.getDefinitions());
55
+ context.categoryValue = categoryValue;
56
+ context.category = category;
157
57
  }
158
58
 
159
59
  function unsetCategoryValue(element, context) {
160
- var category = context.category,
161
- categoryValue = context.categoryValue,
162
- businessObject = getBusinessObject(element);
60
+ var businessObject = getBusinessObject(element),
61
+ categoryValue = context.categoryValue || businessObject.categoryValueRef,
62
+ category = context.category || (categoryValue && categoryValue.$parent);
163
63
 
164
64
  if (categoryValue) {
165
- businessObject.categoryValueRef = null;
65
+ context.categoryValue = categoryValue;
66
+ context.category = category;
166
67
 
167
- removeCategoryValue(categoryValue, category, businessObject);
168
- } else {
169
- removeCategoryValue(null, businessObject.categoryValueRef.$parent, businessObject);
68
+ businessObject.categoryValueRef = null;
170
69
  }
171
70
  }
172
71
 
@@ -208,14 +107,10 @@ export default function GroupBehavior(
208
107
  return;
209
108
  }
210
109
 
211
- var categoryValue = context.categoryValue = businessObject.categoryValueRef,
212
- category;
110
+ var categoryValue = context.categoryValue = businessObject.categoryValueRef;
213
111
 
214
112
  if (categoryValue) {
215
- category = context.category = categoryValue.$parent;
216
-
217
- removeCategoryValue(categoryValue, category, businessObject);
218
-
113
+ context.category = categoryValue.$parent;
219
114
  businessObject.categoryValueRef = null;
220
115
  }
221
116
  });
@@ -235,39 +130,77 @@ export default function GroupBehavior(
235
130
 
236
131
  if (categoryValue) {
237
132
  businessObject.categoryValueRef = categoryValue;
238
-
239
- addCategoryValue(categoryValue, category);
133
+ categoryValue.$parent = category;
240
134
  }
241
135
  });
242
136
 
243
137
 
244
- // create new category + value when group was created
138
+ // create new category + value when group was created so that visually
139
+ // enclosed elements can be categorized against it, even if it is unlabeled
245
140
 
246
141
  this.execute('shape.create', function(event) {
247
142
  var context = event.context,
248
- shape = context.shape;
143
+ shape = context.shape,
144
+ hints = context.hints || {};
249
145
 
250
146
  if (!is(shape, 'bpmn:Group') || shape.labelTarget) {
251
147
  return;
252
148
  }
253
149
 
254
- if (getBusinessObject(shape).categoryValueRef) {
255
- setCategoryValue(shape, context);
150
+ // during paste the category value (if any) is carried over from the
151
+ // source; only fabricate one for genuinely new groups
152
+ if (hints.createElementsBehavior === false &&
153
+ !getBusinessObject(shape).categoryValueRef &&
154
+ !context.categoryValue) {
155
+ return;
256
156
  }
157
+
158
+ setCategoryValue(shape, context);
257
159
  });
258
160
 
259
161
  this.reverted('shape.create', function(event) {
260
162
 
261
163
  var context = event.context,
262
- shape = context.shape;
164
+ shape = context.shape,
165
+ hints = context.hints || {};
263
166
 
264
167
  if (!is(shape, 'bpmn:Group') || shape.labelTarget) {
265
168
  return;
266
169
  }
267
170
 
268
- if (getBusinessObject(shape).categoryValueRef) {
269
- unsetCategoryValue(shape, context);
171
+ if (hints.createElementsBehavior === false &&
172
+ !getBusinessObject(shape).categoryValueRef &&
173
+ !context.categoryValue) {
174
+ return;
175
+ }
176
+
177
+ unsetCategoryValue(shape, context);
178
+ });
179
+
180
+
181
+ // add category -> categoryValue for groups when they change
182
+
183
+ this.executed([ 'shape.move', 'shape.resize' ], function(event) {
184
+ var context = event.context,
185
+ shape = context.shape;
186
+
187
+ if (!is(shape, 'bpmn:Group') || shape.labelTarget ||
188
+ getBusinessObject(shape).categoryValueRef) {
189
+ return;
190
+ }
191
+
192
+ setCategoryValue(shape, context);
193
+ });
194
+
195
+ this.reverted([ 'shape.move', 'shape.resize' ], function(event) {
196
+ var context = event.context,
197
+ shape = context.shape;
198
+
199
+ if (!is(shape, 'bpmn:Group') || shape.labelTarget || !context.categoryValue) {
200
+ return;
270
201
  }
202
+
203
+ unsetCategoryValue(shape, context);
271
204
  });
272
205
 
273
206
 
@@ -323,8 +256,6 @@ export default function GroupBehavior(
323
256
 
324
257
  GroupBehavior.$inject = [
325
258
  'bpmnFactory',
326
- 'bpmnjs',
327
- 'elementRegistry',
328
259
  'eventBus',
329
260
  'injector',
330
261
  'moddleCopy'