bpmn-js 9.3.1 → 9.4.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 (46) hide show
  1. package/CHANGELOG.md +817 -0
  2. package/dist/bpmn-modeler.development.js +3424 -3165
  3. package/dist/bpmn-modeler.production.min.js +8 -8
  4. package/dist/bpmn-navigated-viewer.development.js +357 -283
  5. package/dist/bpmn-navigated-viewer.production.min.js +6 -6
  6. package/dist/bpmn-viewer.development.js +323 -269
  7. package/dist/bpmn-viewer.production.min.js +6 -6
  8. package/lib/draw/BpmnRenderUtil.js +25 -25
  9. package/lib/draw/BpmnRenderer.js +4 -4
  10. package/lib/draw/PathMap.js +42 -42
  11. package/lib/features/align-elements/index.js +1 -1
  12. package/lib/features/copy-paste/BpmnCopyPaste.js +75 -69
  13. package/lib/features/copy-paste/ModdleCopy.js +26 -13
  14. package/lib/features/drilldown/DrilldownOverlayBehavior.js +2 -2
  15. package/lib/features/drilldown/SubprocessCompatibility.js +1 -1
  16. package/lib/features/drilldown/index.js +1 -1
  17. package/lib/features/grid-snapping/behavior/{AutoPlaceBehavior.js → GridSnappingAutoPlaceBehavior.js} +2 -2
  18. package/lib/features/grid-snapping/behavior/{LayoutConnectionBehavior.js → GridSnappingLayoutConnectionBehavior.js} +4 -4
  19. package/lib/features/grid-snapping/behavior/{CreateParticipantBehavior.js → GridSnappingParticipantBehavior.js} +2 -2
  20. package/lib/features/grid-snapping/behavior/index.js +7 -7
  21. package/lib/features/keyboard/BpmnKeyboardBindings.js +7 -7
  22. package/lib/features/label-editing/LabelEditingProvider.js +1 -23
  23. package/lib/features/modeling/ElementFactory.js +18 -8
  24. package/lib/features/modeling/behavior/BoundaryEventBehavior.js +1 -16
  25. package/lib/features/modeling/behavior/DropOnFlowBehavior.js +1 -1
  26. package/lib/features/modeling/behavior/GroupBehavior.js +205 -93
  27. package/lib/features/modeling/behavior/ReplaceElementBehaviour.js +8 -4
  28. package/lib/features/modeling/behavior/ResizeBehavior.js +2 -0
  29. package/lib/features/modeling/behavior/RootElementReferenceBehavior.js +7 -8
  30. package/lib/features/modeling/behavior/SpaceToolBehavior.js +5 -0
  31. package/lib/features/modeling/behavior/SubProcessPlaneBehavior.js +9 -0
  32. package/lib/features/modeling/behavior/index.js +1 -1
  33. package/lib/features/modeling/behavior/util/CategoryUtil.js +66 -13
  34. package/lib/features/modeling/behavior/util/LayoutUtil.js +6 -6
  35. package/lib/features/modeling/cmd/SetColorHandler.js +10 -3
  36. package/lib/features/modeling/cmd/UpdateModdlePropertiesHandler.js +4 -1
  37. package/lib/features/ordering/BpmnOrderingProvider.js +3 -1
  38. package/lib/features/replace/BpmnReplace.js +12 -0
  39. package/lib/features/search/index.js +1 -1
  40. package/lib/import/BpmnImporter.js +0 -5
  41. package/lib/util/CompatibilityUtil.js +1 -0
  42. package/package.json +21 -24
  43. package/test/helper/index.js +26 -1
  44. package/.babelrc +0 -3
  45. package/lib/features/distribute-elements/dist/distribute-horizontally-tool.svg +0 -1
  46. package/lib/features/distribute-elements/dist/distribute-vertically-tool.svg +0 -1
@@ -86,11 +86,11 @@ export function getCirclePath(shape) {
86
86
  radius = shape.width / 2;
87
87
 
88
88
  var circlePath = [
89
- ['M', cx, cy],
90
- ['m', 0, -radius],
91
- ['a', radius, radius, 0, 1, 1, 0, 2 * radius],
92
- ['a', radius, radius, 0, 1, 1, 0, -2 * radius],
93
- ['z']
89
+ [ 'M', cx, cy ],
90
+ [ 'm', 0, -radius ],
91
+ [ 'a', radius, radius, 0, 1, 1, 0, 2 * radius ],
92
+ [ 'a', radius, radius, 0, 1, 1, 0, -2 * radius ],
93
+ [ 'z' ]
94
94
  ];
95
95
 
96
96
  return componentsToPath(circlePath);
@@ -104,16 +104,16 @@ export function getRoundRectPath(shape, borderRadius) {
104
104
  height = shape.height;
105
105
 
106
106
  var roundRectPath = [
107
- ['M', x + borderRadius, y],
108
- ['l', width - borderRadius * 2, 0],
109
- ['a', borderRadius, borderRadius, 0, 0, 1, borderRadius, borderRadius],
110
- ['l', 0, height - borderRadius * 2],
111
- ['a', borderRadius, borderRadius, 0, 0, 1, -borderRadius, borderRadius],
112
- ['l', borderRadius * 2 - width, 0],
113
- ['a', borderRadius, borderRadius, 0, 0, 1, -borderRadius, -borderRadius],
114
- ['l', 0, borderRadius * 2 - height],
115
- ['a', borderRadius, borderRadius, 0, 0, 1, borderRadius, -borderRadius],
116
- ['z']
107
+ [ 'M', x + borderRadius, y ],
108
+ [ 'l', width - borderRadius * 2, 0 ],
109
+ [ 'a', borderRadius, borderRadius, 0, 0, 1, borderRadius, borderRadius ],
110
+ [ 'l', 0, height - borderRadius * 2 ],
111
+ [ 'a', borderRadius, borderRadius, 0, 0, 1, -borderRadius, borderRadius ],
112
+ [ 'l', borderRadius * 2 - width, 0 ],
113
+ [ 'a', borderRadius, borderRadius, 0, 0, 1, -borderRadius, -borderRadius ],
114
+ [ 'l', 0, borderRadius * 2 - height ],
115
+ [ 'a', borderRadius, borderRadius, 0, 0, 1, borderRadius, -borderRadius ],
116
+ [ 'z' ]
117
117
  ];
118
118
 
119
119
  return componentsToPath(roundRectPath);
@@ -129,11 +129,11 @@ export function getDiamondPath(shape) {
129
129
  halfHeight = height / 2;
130
130
 
131
131
  var diamondPath = [
132
- ['M', x + halfWidth, y],
133
- ['l', halfWidth, halfHeight],
134
- ['l', -halfWidth, halfHeight],
135
- ['l', -halfWidth, -halfHeight],
136
- ['z']
132
+ [ 'M', x + halfWidth, y ],
133
+ [ 'l', halfWidth, halfHeight ],
134
+ [ 'l', -halfWidth, halfHeight ],
135
+ [ 'l', -halfWidth, -halfHeight ],
136
+ [ 'z' ]
137
137
  ];
138
138
 
139
139
  return componentsToPath(diamondPath);
@@ -146,11 +146,11 @@ export function getRectPath(shape) {
146
146
  height = shape.height;
147
147
 
148
148
  var rectPath = [
149
- ['M', x, y],
150
- ['l', width, 0],
151
- ['l', 0, height],
152
- ['l', -width, 0],
153
- ['z']
149
+ [ 'M', x, y ],
150
+ [ 'l', width, 0 ],
151
+ [ 'l', 0, height ],
152
+ [ 'l', -width, 0 ],
153
+ [ 'z' ]
154
154
  ];
155
155
 
156
156
  return componentsToPath(rectPath);
@@ -100,7 +100,7 @@ export default function BpmnRenderer(
100
100
  // fix for safari / chrome / firefox bug not correctly
101
101
  // resetting stroke dash array
102
102
  if (attrs.strokeDasharray === 'none') {
103
- attrs.strokeDasharray = [10000, 1];
103
+ attrs.strokeDasharray = [ 10000, 1 ];
104
104
  }
105
105
 
106
106
  var marker = svgCreate('marker');
@@ -327,7 +327,7 @@ export default function BpmnRenderer(
327
327
  var x_2 = width / 2;
328
328
  var y_2 = height / 2;
329
329
 
330
- var points = [{ x: x_2, y: 0 }, { x: width, y: y_2 }, { x: x_2, y: height }, { x: 0, y: y_2 }];
330
+ var points = [ { x: x_2, y: 0 }, { x: width, y: y_2 }, { x: x_2, y: height }, { x: 0, y: y_2 } ];
331
331
 
332
332
  var pointsString = points.map(function(point) {
333
333
  return point.x + ',' + point.y;
@@ -399,7 +399,7 @@ export default function BpmnRenderer(
399
399
  var event = getSemantic(element);
400
400
  var isThrowing = isThrowEvent(event);
401
401
 
402
- if (event.eventDefinitions && event.eventDefinitions.length>1) {
402
+ if (event.eventDefinitions && event.eventDefinitions.length > 1) {
403
403
  if (event.parallelMultiple) {
404
404
  return renderer('bpmn:ParallelMultipleEventDefinition')(parentGfx, element, isThrowing);
405
405
  }
@@ -1115,7 +1115,7 @@ export default function BpmnRenderer(
1115
1115
  if (expanded) {
1116
1116
  attachTaskMarkers(parentGfx, element);
1117
1117
  } else {
1118
- attachTaskMarkers(parentGfx, element, ['SubProcessMarker']);
1118
+ attachTaskMarkers(parentGfx, element, [ 'SubProcessMarker' ]);
1119
1119
  }
1120
1120
 
1121
1121
  return rect;
@@ -40,22 +40,22 @@ export default function PathMap() {
40
40
  d: 'm {mx},{my} l 0,{e.y1} l {e.x1},0 l 0,-{e.y1} z l {e.x0},{e.y0} l {e.x0},-{e.y0}',
41
41
  height: 36,
42
42
  width: 36,
43
- heightElements: [6, 14],
44
- widthElements: [10.5, 21]
43
+ heightElements: [ 6, 14 ],
44
+ widthElements: [ 10.5, 21 ]
45
45
  },
46
46
  'EVENT_SIGNAL': {
47
47
  d: 'M {mx},{my} l {e.x0},{e.y0} l -{e.x1},0 Z',
48
48
  height: 36,
49
49
  width: 36,
50
- heightElements: [18],
51
- widthElements: [10, 20]
50
+ heightElements: [ 18 ],
51
+ widthElements: [ 10, 20 ]
52
52
  },
53
53
  'EVENT_ESCALATION': {
54
54
  d: 'M {mx},{my} l {e.x0},{e.y0} l -{e.x0},-{e.y1} l -{e.x0},{e.y1} Z',
55
55
  height: 36,
56
56
  width: 36,
57
- heightElements: [20, 7],
58
- widthElements: [8]
57
+ heightElements: [ 20, 7 ],
58
+ widthElements: [ 8 ]
59
59
  },
60
60
  'EVENT_CONDITIONAL': {
61
61
  d: 'M {e.x0},{e.y0} l {e.x1},0 l 0,{e.y2} l -{e.x1},0 Z ' +
@@ -67,67 +67,67 @@ export default function PathMap() {
67
67
  'M {e.x2},{e.y8} l {e.x0},0 ',
68
68
  height: 36,
69
69
  width: 36,
70
- heightElements: [8.5, 14.5, 18, 11.5, 14.5, 17.5, 20.5, 23.5, 26.5],
71
- widthElements: [10.5, 14.5, 12.5]
70
+ heightElements: [ 8.5, 14.5, 18, 11.5, 14.5, 17.5, 20.5, 23.5, 26.5 ],
71
+ widthElements: [ 10.5, 14.5, 12.5 ]
72
72
  },
73
73
  'EVENT_LINK': {
74
74
  d: 'm {mx},{my} 0,{e.y0} -{e.x1},0 0,{e.y1} {e.x1},0 0,{e.y0} {e.x0},-{e.y2} -{e.x0},-{e.y2} z',
75
75
  height: 36,
76
76
  width: 36,
77
- heightElements: [4.4375, 6.75, 7.8125],
78
- widthElements: [9.84375, 13.5]
77
+ heightElements: [ 4.4375, 6.75, 7.8125 ],
78
+ widthElements: [ 9.84375, 13.5 ]
79
79
  },
80
80
  'EVENT_ERROR': {
81
81
  d: 'm {mx},{my} {e.x0},-{e.y0} {e.x1},-{e.y1} {e.x2},{e.y2} {e.x3},-{e.y3} -{e.x4},{e.y4} -{e.x5},-{e.y5} z',
82
82
  height: 36,
83
83
  width: 36,
84
- heightElements: [0.023, 8.737, 8.151, 16.564, 10.591, 8.714],
85
- widthElements: [0.085, 6.672, 6.97, 4.273, 5.337, 6.636]
84
+ heightElements: [ 0.023, 8.737, 8.151, 16.564, 10.591, 8.714 ],
85
+ widthElements: [ 0.085, 6.672, 6.97, 4.273, 5.337, 6.636 ]
86
86
  },
87
87
  'EVENT_CANCEL_45': {
88
88
  d: 'm {mx},{my} -{e.x1},0 0,{e.x0} {e.x1},0 0,{e.y1} {e.x0},0 ' +
89
89
  '0,-{e.y1} {e.x1},0 0,-{e.y0} -{e.x1},0 0,-{e.y1} -{e.x0},0 z',
90
90
  height: 36,
91
91
  width: 36,
92
- heightElements: [4.75, 8.5],
93
- widthElements: [4.75, 8.5]
92
+ heightElements: [ 4.75, 8.5 ],
93
+ widthElements: [ 4.75, 8.5 ]
94
94
  },
95
95
  'EVENT_COMPENSATION': {
96
96
  d: 'm {mx},{my} {e.x0},-{e.y0} 0,{e.y1} z m {e.x1},-{e.y2} {e.x2},-{e.y3} 0,{e.y1} -{e.x2},-{e.y3} z',
97
97
  height: 36,
98
98
  width: 36,
99
- heightElements: [6.5, 13, 0.4, 6.1],
100
- widthElements: [9, 9.3, 8.7]
99
+ heightElements: [ 6.5, 13, 0.4, 6.1 ],
100
+ widthElements: [ 9, 9.3, 8.7 ]
101
101
  },
102
102
  'EVENT_TIMER_WH': {
103
103
  d: 'M {mx},{my} l {e.x0},-{e.y0} m -{e.x0},{e.y0} l {e.x1},{e.y1} ',
104
104
  height: 36,
105
105
  width: 36,
106
- heightElements: [10, 2],
107
- widthElements: [3, 7]
106
+ heightElements: [ 10, 2 ],
107
+ widthElements: [ 3, 7 ]
108
108
  },
109
109
  'EVENT_TIMER_LINE': {
110
110
  d: 'M {mx},{my} ' +
111
111
  'm {e.x0},{e.y0} l -{e.x1},{e.y1} ',
112
112
  height: 36,
113
113
  width: 36,
114
- heightElements: [10, 3],
115
- widthElements: [0, 0]
114
+ heightElements: [ 10, 3 ],
115
+ widthElements: [ 0, 0 ]
116
116
  },
117
117
  'EVENT_MULTIPLE': {
118
118
  d:'m {mx},{my} {e.x1},-{e.y0} {e.x1},{e.y0} -{e.x0},{e.y1} -{e.x2},0 z',
119
119
  height: 36,
120
120
  width: 36,
121
- heightElements: [6.28099, 12.56199],
122
- widthElements: [3.1405, 9.42149, 12.56198]
121
+ heightElements: [ 6.28099, 12.56199 ],
122
+ widthElements: [ 3.1405, 9.42149, 12.56198 ]
123
123
  },
124
124
  'EVENT_PARALLEL_MULTIPLE': {
125
125
  d:'m {mx},{my} {e.x0},0 0,{e.y1} {e.x1},0 0,{e.y0} -{e.x1},0 0,{e.y1} ' +
126
126
  '-{e.x0},0 0,-{e.y1} -{e.x1},0 0,-{e.y0} {e.x1},0 z',
127
127
  height: 36,
128
128
  width: 36,
129
- heightElements: [2.56228, 7.68683],
130
- widthElements: [2.56228, 7.68683]
129
+ heightElements: [ 2.56228, 7.68683 ],
130
+ widthElements: [ 2.56228, 7.68683 ]
131
131
  },
132
132
  'GATEWAY_EXCLUSIVE': {
133
133
  d:'m {mx},{my} {e.x0},{e.y0} {e.x1},{e.y0} {e.x2},0 {e.x4},{e.y2} ' +
@@ -135,23 +135,23 @@ export default function PathMap() {
135
135
  '{e.x3},0 {e.x5},{e.y1} {e.x5},{e.y2} {e.x3},0 z',
136
136
  height: 17.5,
137
137
  width: 17.5,
138
- heightElements: [8.5, 6.5312, -6.5312, -8.5],
139
- widthElements: [6.5, -6.5, 3, -3, 5, -5]
138
+ heightElements: [ 8.5, 6.5312, -6.5312, -8.5 ],
139
+ widthElements: [ 6.5, -6.5, 3, -3, 5, -5 ]
140
140
  },
141
141
  'GATEWAY_PARALLEL': {
142
142
  d:'m {mx},{my} 0,{e.y1} -{e.x1},0 0,{e.y0} {e.x1},0 0,{e.y1} {e.x0},0 ' +
143
143
  '0,-{e.y1} {e.x1},0 0,-{e.y0} -{e.x1},0 0,-{e.y1} -{e.x0},0 z',
144
144
  height: 30,
145
145
  width: 30,
146
- heightElements: [5, 12.5],
147
- widthElements: [5, 12.5]
146
+ heightElements: [ 5, 12.5 ],
147
+ widthElements: [ 5, 12.5 ]
148
148
  },
149
149
  'GATEWAY_EVENT_BASED': {
150
150
  d:'m {mx},{my} {e.x0},{e.y0} {e.x0},{e.y1} {e.x1},{e.y2} {e.x2},0 z',
151
151
  height: 11,
152
152
  width: 11,
153
- heightElements: [-6, 6, 12, -12],
154
- widthElements: [9, -3, -12]
153
+ heightElements: [ -6, 6, 12, -12 ],
154
+ widthElements: [ 9, -3, -12 ]
155
155
  },
156
156
  'GATEWAY_COMPLEX': {
157
157
  d:'m {mx},{my} 0,{e.y0} -{e.x0},-{e.y1} -{e.x1},{e.y2} {e.x0},{e.y1} -{e.x2},0 0,{e.y3} ' +
@@ -160,15 +160,15 @@ export default function PathMap() {
160
160
  '-{e.x0},{e.y1} 0,-{e.y0} -{e.x3},0 z',
161
161
  height: 17.125,
162
162
  width: 17.125,
163
- heightElements: [4.875, 3.4375, 2.125, 3],
164
- widthElements: [3.4375, 2.125, 4.875, 3]
163
+ heightElements: [ 4.875, 3.4375, 2.125, 3 ],
164
+ widthElements: [ 3.4375, 2.125, 4.875, 3 ]
165
165
  },
166
166
  'DATA_OBJECT_PATH': {
167
167
  d:'m 0,0 {e.x1},0 {e.x0},{e.y0} 0,{e.y1} -{e.x2},0 0,-{e.y2} {e.x1},0 0,{e.y0} {e.x0},0',
168
168
  height: 61,
169
169
  width: 51,
170
- heightElements: [10, 50, 60],
171
- widthElements: [10, 40, 50, 60]
170
+ heightElements: [ 10, 50, 60 ],
171
+ widthElements: [ 10, 40, 50, 60 ]
172
172
  },
173
173
  'DATA_OBJECT_COLLECTION_PATH': {
174
174
  d: 'm{mx},{my} m 3,2 l 0,10 m 3,-10 l 0,10 m 3,-10 l 0,10',
@@ -197,15 +197,15 @@ export default function PathMap() {
197
197
  'c {e.x0},{e.y1} {e.x1},{e.y1} {e.x2},0',
198
198
  height: 61,
199
199
  width: 61,
200
- heightElements: [7, 10, 45],
201
- widthElements: [2, 58, 60]
200
+ heightElements: [ 7, 10, 45 ],
201
+ widthElements: [ 2, 58, 60 ]
202
202
  },
203
203
  'TEXT_ANNOTATION': {
204
204
  d: 'm {mx}, {my} m 10,0 l -10,0 l 0,{e.y0} l 10,0',
205
205
  height: 30,
206
206
  width: 10,
207
- heightElements: [30],
208
- widthElements: [10]
207
+ heightElements: [ 30 ],
208
+ widthElements: [ 10 ]
209
209
  },
210
210
  'MARKER_SUB_PROCESS': {
211
211
  d: 'm{mx},{my} m 7,2 l 0,10 m -5,-5 l 10,0',
@@ -260,8 +260,8 @@ export default function PathMap() {
260
260
  d: 'm {mx},{my} l 0,{e.y1} l {e.x1},0 l 0,-{e.y1} z l {e.x0},{e.y0} l {e.x0},-{e.y0}',
261
261
  height: 14,
262
262
  width: 21,
263
- heightElements: [6, 14],
264
- widthElements: [10.5, 21]
263
+ heightElements: [ 6, 14 ],
264
+ widthElements: [ 10.5, 21 ]
265
265
  },
266
266
  'TASK_TYPE_SCRIPT': {
267
267
  d: 'm {mx},{my} c 9.966553,-6.27276 -8.000926,-7.91932 2.968968,-14.938 l -8.802728,0 ' +
@@ -272,8 +272,8 @@ export default function PathMap() {
272
272
  'm -4,3 l 5,0',
273
273
  height: 15,
274
274
  width: 12.6,
275
- heightElements: [6, 14],
276
- widthElements: [10.5, 21]
275
+ heightElements: [ 6, 14 ],
276
+ widthElements: [ 10.5, 21 ]
277
277
  },
278
278
  'TASK_TYPE_USER_1': {
279
279
  d: 'm {mx},{my} c 0.909,-0.845 1.594,-2.049 1.594,-3.385 0,-2.554 -1.805,-4.62199999 ' +
@@ -19,5 +19,5 @@ export default {
19
19
  ],
20
20
  alignElementsContextPadProvider: [ 'type', AlignElementsContextPadProvider ],
21
21
  alignElementsMenuProvider: [ 'type', AlignElementsMenuProvider ],
22
- bpmnAlignElements: [ 'type', BpmnAlignElements]
22
+ bpmnAlignElements: [ 'type', BpmnAlignElements ]
23
23
  };
@@ -24,67 +24,52 @@ function copyProperties(source, target, properties) {
24
24
  });
25
25
  }
26
26
 
27
- function removeProperties(element, properties) {
28
- if (!isArray(properties)) {
29
- properties = [ properties ];
30
- }
31
-
32
- forEach(properties, function(property) {
33
- if (element[property]) {
34
- delete element[property];
35
- }
36
- });
37
- }
38
-
39
27
  var LOW_PRIORITY = 750;
40
28
 
41
29
 
42
30
  export default function BpmnCopyPaste(bpmnFactory, eventBus, moddleCopy) {
43
31
 
44
- eventBus.on('copyPaste.copyElement', LOW_PRIORITY, function(context) {
45
- var descriptor = context.descriptor,
46
- element = context.element;
32
+ function copy(bo, clone) {
33
+ var targetBo = bpmnFactory.create(bo.$type);
47
34
 
48
- var businessObject = descriptor.oldBusinessObject = getBusinessObject(element);
49
- var di = descriptor.oldDi = getDi(element);
50
-
51
- descriptor.type = element.type;
52
-
53
- copyProperties(businessObject, descriptor, 'name');
35
+ return moddleCopy.copyElement(bo, targetBo, null, clone);
36
+ }
54
37
 
55
- copyProperties(di, descriptor, 'isExpanded');
38
+ eventBus.on('copyPaste.copyElement', LOW_PRIORITY, function(context) {
39
+ var descriptor = context.descriptor,
40
+ element = context.element,
41
+ businessObject = getBusinessObject(element);
56
42
 
57
- if (isLabel(descriptor)) {
43
+ // do not copy business object + di for labels;
44
+ // will be pulled from the referenced label target
45
+ if (isLabel(element)) {
58
46
  return descriptor;
59
47
  }
60
48
 
49
+ var businessObjectCopy = descriptor.businessObject = copy(businessObject, true);
50
+ var diCopy = descriptor.di = copy(getDi(element), true);
51
+ diCopy.bpmnElement = businessObjectCopy;
52
+
53
+ copyProperties(businessObjectCopy, descriptor, 'name');
54
+ copyProperties(diCopy, descriptor, 'isExpanded');
55
+
61
56
  // default sequence flow
62
57
  if (businessObject.default) {
63
58
  descriptor.default = businessObject.default.id;
64
59
  }
65
60
  });
66
61
 
67
- eventBus.on('moddleCopy.canCopyProperty', function(context) {
68
- var parent = context.parent,
69
- property = context.property,
70
- propertyName = context.propertyName,
71
- bpmnProcess;
72
-
73
- if (
74
- propertyName === 'processRef' &&
75
- is(parent, 'bpmn:Participant') &&
76
- is(property, 'bpmn:Process')
77
- ) {
78
- bpmnProcess = bpmnFactory.create('bpmn:Process');
79
-
80
- // return copy of process
81
- return moddleCopy.copyElement(property, bpmnProcess);
82
- }
83
- });
62
+ var referencesKey = '-bpmn-js-refs';
84
63
 
85
- var references;
64
+ function getReferences(cache) {
65
+ return (cache[referencesKey] = cache[referencesKey] || {});
66
+ }
67
+
68
+ function setReferences(cache, references) {
69
+ cache[referencesKey] = references;
70
+ }
86
71
 
87
- function resolveReferences(descriptor, cache) {
72
+ function resolveReferences(descriptor, cache, references) {
88
73
  var businessObject = getBusinessObject(descriptor);
89
74
 
90
75
  // default sequence flows
@@ -104,7 +89,7 @@ export default function BpmnCopyPaste(bpmnFactory, eventBus, moddleCopy) {
104
89
  getBusinessObject(descriptor).attachedToRef = getBusinessObject(cache[ descriptor.host ]);
105
90
  }
106
91
 
107
- references = omit(references, reduce(references, function(array, reference, key) {
92
+ return omit(references, reduce(references, function(array, reference, key) {
108
93
  var element = reference.element,
109
94
  property = reference.property;
110
95
 
@@ -118,18 +103,13 @@ export default function BpmnCopyPaste(bpmnFactory, eventBus, moddleCopy) {
118
103
  }, []));
119
104
  }
120
105
 
121
- eventBus.on('copyPaste.pasteElements', function() {
122
- references = {};
123
- });
124
-
125
106
  eventBus.on('copyPaste.pasteElement', function(context) {
126
107
  var cache = context.cache,
127
108
  descriptor = context.descriptor,
128
- oldBusinessObject = descriptor.oldBusinessObject,
129
- oldDi = descriptor.oldDi,
130
- newBusinessObject, newDi;
109
+ businessObject = descriptor.businessObject,
110
+ di = descriptor.di;
131
111
 
132
- // do NOT copy business object if external label
112
+ // wire existing di + businessObject for external label
133
113
  if (isLabel(descriptor)) {
134
114
  descriptor.businessObject = getBusinessObject(cache[ descriptor.labelTarget ]);
135
115
  descriptor.di = getDi(cache[ descriptor.labelTarget ]);
@@ -137,30 +117,56 @@ export default function BpmnCopyPaste(bpmnFactory, eventBus, moddleCopy) {
137
117
  return;
138
118
  }
139
119
 
140
- newBusinessObject = bpmnFactory.create(oldBusinessObject.$type);
141
-
142
- descriptor.businessObject = moddleCopy.copyElement(
143
- oldBusinessObject,
144
- newBusinessObject
145
- );
146
-
147
- newDi = bpmnFactory.create(oldDi.$type);
148
- newDi.bpmnElement = newBusinessObject;
149
-
150
- descriptor.di = moddleCopy.copyElement(
151
- oldDi,
152
- newDi
153
- );
120
+ businessObject = descriptor.businessObject = copy(businessObject);
154
121
 
155
- // resolve references e.g. default sequence flow
156
- resolveReferences(descriptor, cache);
122
+ di = descriptor.di = copy(di);
123
+ di.bpmnElement = businessObject;
157
124
 
158
- copyProperties(descriptor, newBusinessObject, [
125
+ copyProperties(descriptor, businessObject, [
159
126
  'isExpanded',
160
127
  'name'
161
128
  ]);
162
129
 
163
- removeProperties(descriptor, 'oldBusinessObject');
130
+ descriptor.type = businessObject.$type;
131
+ });
132
+
133
+ // copy + paste processRef with participant
134
+
135
+ eventBus.on('copyPaste.copyElement', LOW_PRIORITY, function(context) {
136
+ var descriptor = context.descriptor,
137
+ element = context.element;
138
+
139
+ if (!is(element, 'bpmn:Participant')) {
140
+ return;
141
+ }
142
+
143
+ var participantBo = getBusinessObject(element);
144
+
145
+ if (participantBo.processRef) {
146
+ descriptor.processRef = copy(participantBo.processRef, true);
147
+ }
148
+ });
149
+
150
+ eventBus.on('copyPaste.pasteElement', function(context) {
151
+ var descriptor = context.descriptor,
152
+ processRef = descriptor.processRef;
153
+
154
+ if (processRef) {
155
+ descriptor.processRef = copy(processRef);
156
+ }
157
+ });
158
+
159
+ // resolve references
160
+
161
+ eventBus.on('copyPaste.pasteElement', LOW_PRIORITY, function(context) {
162
+ var cache = context.cache,
163
+ descriptor = context.descriptor;
164
+
165
+ // resolve references e.g. default sequence flow
166
+ setReferences(
167
+ cache,
168
+ resolveReferences(descriptor, cache, getReferences(cache))
169
+ );
164
170
  });
165
171
 
166
172
  }
@@ -18,7 +18,8 @@ var DISALLOWED_PROPERTIES = [
18
18
  'flowElements',
19
19
  'lanes',
20
20
  'incoming',
21
- 'outgoing'
21
+ 'outgoing',
22
+ 'categoryValue'
22
23
  ];
23
24
 
24
25
  /**
@@ -127,10 +128,11 @@ ModdleCopy.$inject = [
127
128
  * @param {ModdleElement} sourceElement
128
129
  * @param {ModdleElement} targetElement
129
130
  * @param {Array<string>} [propertyNames]
131
+ * @param {boolean} clone
130
132
  *
131
133
  * @param {ModdleElement}
132
134
  */
133
- ModdleCopy.prototype.copyElement = function(sourceElement, targetElement, propertyNames) {
135
+ ModdleCopy.prototype.copyElement = function(sourceElement, targetElement, propertyNames, clone) {
134
136
  var self = this;
135
137
 
136
138
  if (propertyNames && !isArray(propertyNames)) {
@@ -142,7 +144,8 @@ ModdleCopy.prototype.copyElement = function(sourceElement, targetElement, proper
142
144
  var canCopyProperties = this._eventBus.fire('moddleCopy.canCopyProperties', {
143
145
  propertyNames: propertyNames,
144
146
  sourceElement: sourceElement,
145
- targetElement: targetElement
147
+ targetElement: targetElement,
148
+ clone: clone
146
149
  });
147
150
 
148
151
  if (canCopyProperties === false) {
@@ -161,7 +164,11 @@ ModdleCopy.prototype.copyElement = function(sourceElement, targetElement, proper
161
164
  sourceProperty = sourceElement.get(propertyName);
162
165
  }
163
166
 
164
- var copiedProperty = self.copyProperty(sourceProperty, targetElement, propertyName);
167
+ var copiedProperty = self.copyProperty(sourceProperty, targetElement, propertyName, clone);
168
+
169
+ if (!isDefined(copiedProperty)) {
170
+ return;
171
+ }
165
172
 
166
173
  var canSetProperty = self._eventBus.fire('moddleCopy.canSetCopiedProperty', {
167
174
  parent: targetElement,
@@ -173,9 +180,9 @@ ModdleCopy.prototype.copyElement = function(sourceElement, targetElement, proper
173
180
  return;
174
181
  }
175
182
 
176
- if (isDefined(copiedProperty)) {
177
- targetElement.set(propertyName, copiedProperty);
178
- }
183
+ // TODO(nikku): unclaim old IDs if ID property is copied over
184
+ // this._moddle.getPropertyDescriptor(parent, propertyName)
185
+ targetElement.set(propertyName, copiedProperty);
179
186
  });
180
187
 
181
188
  return targetElement;
@@ -187,17 +194,19 @@ ModdleCopy.prototype.copyElement = function(sourceElement, targetElement, proper
187
194
  * @param {*} property
188
195
  * @param {ModdleElement} parent
189
196
  * @param {string} propertyName
197
+ * @param {boolean} clone
190
198
  *
191
199
  * @returns {*}
192
200
  */
193
- ModdleCopy.prototype.copyProperty = function(property, parent, propertyName) {
201
+ ModdleCopy.prototype.copyProperty = function(property, parent, propertyName, clone) {
194
202
  var self = this;
195
203
 
196
204
  // allow others to copy property
197
205
  var copiedProperty = this._eventBus.fire('moddleCopy.canCopyProperty', {
198
206
  parent: parent,
199
207
  property: property,
200
- propertyName: propertyName
208
+ propertyName: propertyName,
209
+ clone: clone
201
210
  });
202
211
 
203
212
  // return if copying is NOT allowed
@@ -222,7 +231,7 @@ ModdleCopy.prototype.copyProperty = function(property, parent, propertyName) {
222
231
 
223
232
  // copy id
224
233
  if (propertyDescriptor.isId) {
225
- return this._copyId(property, parent);
234
+ return property && this._copyId(property, parent, clone);
226
235
  }
227
236
 
228
237
  // copy arrays
@@ -230,7 +239,7 @@ ModdleCopy.prototype.copyProperty = function(property, parent, propertyName) {
230
239
  return reduce(property, function(childProperties, childProperty) {
231
240
 
232
241
  // recursion
233
- copiedProperty = self.copyProperty(childProperty, parent, propertyName);
242
+ copiedProperty = self.copyProperty(childProperty, parent, propertyName, clone);
234
243
 
235
244
  // copying might NOT be allowed
236
245
  if (copiedProperty) {
@@ -252,7 +261,7 @@ ModdleCopy.prototype.copyProperty = function(property, parent, propertyName) {
252
261
  copiedProperty.$parent = parent;
253
262
 
254
263
  // recursion
255
- copiedProperty = self.copyElement(property, copiedProperty);
264
+ copiedProperty = self.copyElement(property, copiedProperty, null, clone);
256
265
 
257
266
  return copiedProperty;
258
267
  }
@@ -261,7 +270,11 @@ ModdleCopy.prototype.copyProperty = function(property, parent, propertyName) {
261
270
  return property;
262
271
  };
263
272
 
264
- ModdleCopy.prototype._copyId = function(id, element) {
273
+ ModdleCopy.prototype._copyId = function(id, element, clone) {
274
+
275
+ if (clone) {
276
+ return id;
277
+ }
265
278
 
266
279
  // disallow if already taken
267
280
  if (this._moddle.ids.assigned(id)) {
@@ -46,7 +46,7 @@ export default function DrilldownOverlayBehavior(
46
46
  }, true);
47
47
 
48
48
 
49
- this.executed(['shape.create', 'shape.move', 'shape.delete'], LOW_PRIORITY,
49
+ this.executed([ 'shape.create', 'shape.move', 'shape.delete' ], LOW_PRIORITY,
50
50
  function(context) {
51
51
  var oldParent = context.oldParent,
52
52
  newParent = context.newParent || context.parent,
@@ -63,7 +63,7 @@ export default function DrilldownOverlayBehavior(
63
63
  }, true);
64
64
 
65
65
 
66
- this.reverted(['shape.create', 'shape.move', 'shape.delete'], LOW_PRIORITY,
66
+ this.reverted([ 'shape.create', 'shape.move', 'shape.delete' ], LOW_PRIORITY,
67
67
  function(context) {
68
68
  var oldParent = context.oldParent,
69
69
  newParent = context.newParent || context.parent,
@@ -210,7 +210,7 @@ function shouldMoveToPlane(bo, plane) {
210
210
 
211
211
  // dataAssociations are children of the subprocess but rendered on process level
212
212
  // cf. https://github.com/bpmn-io/bpmn-js/issues/1619
213
- if (isAny(bo, ['bpmn:DataInputAssociation', 'bpmn:DataOutputAssociation'])) {
213
+ if (isAny(bo, [ 'bpmn:DataInputAssociation', 'bpmn:DataOutputAssociation' ])) {
214
214
  return false;
215
215
  }
216
216