bpmn-js 8.9.0 → 9.0.0-alpha.2

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 (55) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/assets/bpmn-js.css +113 -0
  3. package/dist/bpmn-modeler.development.js +2600 -991
  4. package/dist/bpmn-modeler.production.min.js +9 -8
  5. package/dist/bpmn-navigated-viewer.development.js +21240 -19985
  6. package/dist/bpmn-navigated-viewer.production.min.js +22 -20
  7. package/dist/bpmn-viewer.development.js +20441 -19186
  8. package/dist/bpmn-viewer.production.min.js +22 -20
  9. package/lib/BaseViewer.js +1 -14
  10. package/lib/Viewer.js +3 -1
  11. package/lib/draw/BpmnRenderUtil.js +6 -4
  12. package/lib/features/auto-resize/BpmnAutoResizeProvider.js +6 -0
  13. package/lib/features/context-pad/ContextPadProvider.js +1 -1
  14. package/lib/features/copy-paste/BpmnCopyPaste.js +14 -13
  15. package/lib/features/di-ordering/BpmnDiOrdering.js +16 -13
  16. package/lib/features/drilldown/DrilldownBreadcrumbs.js +122 -0
  17. package/lib/features/drilldown/DrilldownCentering.js +118 -0
  18. package/lib/features/drilldown/DrilldownOverlayBehavior.js +181 -0
  19. package/lib/features/drilldown/SubprocessCompatibility.js +196 -0
  20. package/lib/features/drilldown/index.js +17 -0
  21. package/lib/features/label-editing/LabelEditingPreview.js +3 -3
  22. package/lib/features/label-editing/cmd/UpdateLabelHandler.js +31 -3
  23. package/lib/features/modeling/BpmnFactory.js +11 -8
  24. package/lib/features/modeling/BpmnUpdater.js +35 -27
  25. package/lib/features/modeling/ElementFactory.js +64 -37
  26. package/lib/features/modeling/behavior/CreateParticipantBehavior.js +59 -84
  27. package/lib/features/modeling/behavior/DataStoreBehavior.js +3 -1
  28. package/lib/features/modeling/behavior/IsHorizontalFix.js +7 -4
  29. package/lib/features/modeling/behavior/LabelBehavior.js +8 -7
  30. package/lib/features/modeling/behavior/SubProcessPlaneBehavior.js +550 -0
  31. package/lib/features/modeling/behavior/ToggleCollapseConnectionBehaviour.js +74 -0
  32. package/lib/features/modeling/behavior/ToggleElementCollapseBehaviour.js +6 -6
  33. package/lib/features/modeling/behavior/UnclaimIdBehavior.js +3 -1
  34. package/lib/features/modeling/behavior/index.js +6 -0
  35. package/lib/features/modeling/cmd/SetColorHandler.js +4 -1
  36. package/lib/features/modeling/cmd/UpdateCanvasRootHandler.js +12 -8
  37. package/lib/features/modeling/cmd/UpdatePropertiesHandler.js +19 -12
  38. package/lib/features/modeling/cmd/UpdateSemanticParentHandler.js +5 -3
  39. package/lib/features/modeling/util/ModelingUtil.js +2 -20
  40. package/lib/features/ordering/BpmnOrderingProvider.js +1 -1
  41. package/lib/features/palette/PaletteProvider.js +3 -1
  42. package/lib/features/popup-menu/ReplaceMenuProvider.js +6 -6
  43. package/lib/features/popup-menu/util/TypeUtil.js +1 -1
  44. package/lib/features/replace/BpmnReplace.js +29 -29
  45. package/lib/import/BpmnImporter.js +33 -22
  46. package/lib/import/BpmnTreeWalker.js +19 -17
  47. package/lib/import/Importer.js +137 -6
  48. package/lib/util/CompatibilityUtil.js +21 -1
  49. package/lib/util/DiUtil.js +10 -3
  50. package/lib/util/DrilldownUtil.js +66 -0
  51. package/lib/util/LabelUtil.js +2 -3
  52. package/lib/util/ModelUtil.js +30 -0
  53. package/package.json +2 -2
  54. package/test/matchers/BoundsMatchers.js +10 -10
  55. package/test/matchers/ConnectionMatchers.js +5 -5
@@ -6,7 +6,15 @@ import {
6
6
 
7
7
  import inherits from 'inherits';
8
8
 
9
- import { is } from '../../util/ModelUtil';
9
+ import {
10
+ getBusinessObject,
11
+ getDi,
12
+ is
13
+ } from '../../util/ModelUtil';
14
+
15
+ import {
16
+ isAny
17
+ } from '../modeling/util/ModelingUtil';
10
18
 
11
19
  import {
12
20
  isExpanded
@@ -18,6 +26,10 @@ import {
18
26
  DEFAULT_LABEL_SIZE
19
27
  } from '../../util/LabelUtil';
20
28
 
29
+ import {
30
+ ensureCompatDiRef
31
+ } from '../../util/CompatibilityUtil';
32
+
21
33
 
22
34
  /**
23
35
  * A bpmn-aware factory for diagram-js shapes
@@ -46,7 +58,8 @@ ElementFactory.prototype.create = function(elementType, attrs) {
46
58
  // we assume their businessObjects have already been created
47
59
  // and wired via attrs
48
60
  if (elementType === 'label') {
49
- return this.baseCreate(elementType, assign({ type: 'label' }, DEFAULT_LABEL_SIZE, attrs));
61
+ var di = attrs.di || this._bpmnFactory.createDiLabel();
62
+ return this.baseCreate(elementType, assign({ type: 'label', di: di }, DEFAULT_LABEL_SIZE, attrs));
50
63
  }
51
64
 
52
65
  return this.createBpmnElement(elementType, attrs);
@@ -58,7 +71,8 @@ ElementFactory.prototype.createBpmnElement = function(elementType, attrs) {
58
71
 
59
72
  attrs = attrs || {};
60
73
 
61
- var businessObject = attrs.businessObject;
74
+ var businessObject = attrs.businessObject,
75
+ di = attrs.di;
62
76
 
63
77
  if (!businessObject) {
64
78
  if (!attrs.type) {
@@ -66,22 +80,23 @@ ElementFactory.prototype.createBpmnElement = function(elementType, attrs) {
66
80
  }
67
81
 
68
82
  businessObject = this._bpmnFactory.create(attrs.type);
83
+
84
+ ensureCompatDiRef(businessObject);
69
85
  }
70
86
 
71
- if (!businessObject.di) {
87
+ if (!isModdleDi(di)) {
88
+ var diAttrs = assign(
89
+ di || {},
90
+ { id: businessObject.id + '_di' }
91
+ );
92
+
72
93
  if (elementType === 'root') {
73
- businessObject.di = this._bpmnFactory.createDiPlane(businessObject, [], {
74
- id: businessObject.id + '_di'
75
- });
94
+ di = this._bpmnFactory.createDiPlane(businessObject, diAttrs);
76
95
  } else
77
96
  if (elementType === 'connection') {
78
- businessObject.di = this._bpmnFactory.createDiEdge(businessObject, [], {
79
- id: businessObject.id + '_di'
80
- });
97
+ di = this._bpmnFactory.createDiEdge(businessObject, diAttrs);
81
98
  } else {
82
- businessObject.di = this._bpmnFactory.createDiShape(businessObject, {}, {
83
- id: businessObject.id + '_di'
84
- });
99
+ di = this._bpmnFactory.createDiShape(businessObject, diAttrs);
85
100
  }
86
101
  }
87
102
 
@@ -91,12 +106,6 @@ ElementFactory.prototype.createBpmnElement = function(elementType, attrs) {
91
106
  }, attrs);
92
107
  }
93
108
 
94
- if (attrs.di) {
95
- assign(businessObject.di, attrs.di);
96
-
97
- delete attrs.di;
98
- }
99
-
100
109
  applyAttributes(businessObject, attrs, [
101
110
  'processRef',
102
111
  'isInterrupting',
@@ -105,11 +114,15 @@ ElementFactory.prototype.createBpmnElement = function(elementType, attrs) {
105
114
  ]);
106
115
 
107
116
  if (attrs.isExpanded) {
108
- applyAttribute(businessObject.di, attrs, 'isExpanded');
117
+ applyAttribute(di, attrs, 'isExpanded');
118
+ }
119
+
120
+ if (is(businessObject, 'bpmn:SubProcess')) {
121
+ attrs.collapsed = !isExpanded(businessObject, di);
109
122
  }
110
123
 
111
124
  if (is(businessObject, 'bpmn:ExclusiveGateway')) {
112
- businessObject.di.isMarkerVisible = true;
125
+ di.isMarkerVisible = true;
113
126
  }
114
127
 
115
128
  var eventDefinitions,
@@ -131,65 +144,69 @@ ElementFactory.prototype.createBpmnElement = function(elementType, attrs) {
131
144
  delete attrs.eventDefinitionType;
132
145
  }
133
146
 
134
- size = this._getDefaultSize(businessObject);
147
+ size = this.getDefaultSize(businessObject, di);
135
148
 
136
149
  attrs = assign({
137
- businessObject: businessObject,
138
150
  id: businessObject.id
139
- }, size, attrs);
151
+ }, size, attrs, {
152
+ businessObject: businessObject,
153
+ di: di
154
+ });
140
155
 
141
156
  return this.baseCreate(elementType, attrs);
142
157
  };
143
158
 
144
159
 
145
- ElementFactory.prototype._getDefaultSize = function(semantic) {
160
+ ElementFactory.prototype.getDefaultSize = function(element, di) {
146
161
 
147
- if (is(semantic, 'bpmn:SubProcess')) {
162
+ var bo = getBusinessObject(element);
163
+ di = di || getDi(element);
148
164
 
149
- if (isExpanded(semantic)) {
165
+ if (is(bo, 'bpmn:SubProcess')) {
166
+ if (isExpanded(bo, di)) {
150
167
  return { width: 350, height: 200 };
151
168
  } else {
152
169
  return { width: 100, height: 80 };
153
170
  }
154
171
  }
155
172
 
156
- if (is(semantic, 'bpmn:Task')) {
173
+ if (is(bo, 'bpmn:Task')) {
157
174
  return { width: 100, height: 80 };
158
175
  }
159
176
 
160
- if (is(semantic, 'bpmn:Gateway')) {
177
+ if (is(bo, 'bpmn:Gateway')) {
161
178
  return { width: 50, height: 50 };
162
179
  }
163
180
 
164
- if (is(semantic, 'bpmn:Event')) {
181
+ if (is(bo, 'bpmn:Event')) {
165
182
  return { width: 36, height: 36 };
166
183
  }
167
184
 
168
- if (is(semantic, 'bpmn:Participant')) {
169
- if (isExpanded(semantic)) {
185
+ if (is(bo, 'bpmn:Participant')) {
186
+ if (isExpanded(bo, di)) {
170
187
  return { width: 600, height: 250 };
171
188
  } else {
172
189
  return { width: 400, height: 60 };
173
190
  }
174
191
  }
175
192
 
176
- if (is(semantic, 'bpmn:Lane')) {
193
+ if (is(bo, 'bpmn:Lane')) {
177
194
  return { width: 400, height: 100 };
178
195
  }
179
196
 
180
- if (is(semantic, 'bpmn:DataObjectReference')) {
197
+ if (is(bo, 'bpmn:DataObjectReference')) {
181
198
  return { width: 36, height: 50 };
182
199
  }
183
200
 
184
- if (is(semantic, 'bpmn:DataStoreReference')) {
201
+ if (is(bo, 'bpmn:DataStoreReference')) {
185
202
  return { width: 50, height: 50 };
186
203
  }
187
204
 
188
- if (is(semantic, 'bpmn:TextAnnotation')) {
205
+ if (is(bo, 'bpmn:TextAnnotation')) {
189
206
  return { width: 100, height: 30 };
190
207
  }
191
208
 
192
- if (is(semantic, 'bpmn:Group')) {
209
+ if (is(bo, 'bpmn:Group')) {
193
210
  return { width: 300, height: 300 };
194
211
  }
195
212
 
@@ -252,4 +269,14 @@ function applyAttribute(element, attrs, attributeName) {
252
269
  element[attributeName] = attrs[attributeName];
253
270
 
254
271
  delete attrs[attributeName];
272
+ }
273
+
274
+
275
+ function isModdleDi(element) {
276
+ return isAny(element, [
277
+ 'bpmndi:BPMNShape',
278
+ 'bpmndi:BPMNEdge',
279
+ 'bpmndi:BPMNDiagram',
280
+ 'bpmndi:BPMNPlane',
281
+ ]);
255
282
  }
@@ -2,7 +2,7 @@ import inherits from 'inherits';
2
2
 
3
3
  import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
4
4
 
5
- import { is } from '../../../util/ModelUtil';
5
+ import { getBusinessObject, is } from '../../../util/ModelUtil';
6
6
 
7
7
  import { isLabel } from '../../../util/LabelUtil';
8
8
 
@@ -88,122 +88,97 @@ export default function CreateParticipantBehavior(canvas, eventBus, modeling) {
88
88
  }
89
89
  });
90
90
 
91
- function ensureCollaboration(context) {
92
- var parent = context.parent,
93
- collaboration;
94
-
91
+ // turn process into collaboration when creating first participant
92
+ function getOrCreateCollaboration() {
95
93
  var rootElement = canvas.getRootElement();
96
94
 
97
95
  if (is(rootElement, 'bpmn:Collaboration')) {
98
- collaboration = rootElement;
99
- } else {
100
-
101
- // update root element by making collaboration
102
- collaboration = modeling.makeCollaboration();
103
-
104
- // re-use process when creating first participant
105
- context.process = parent;
96
+ return rootElement;
106
97
  }
107
98
 
108
- context.parent = collaboration;
99
+ return modeling.makeCollaboration();
109
100
  }
110
101
 
111
- // turn process into collaboration before adding participant
112
- this.preExecute('shape.create', function(context) {
113
- var parent = context.parent,
114
- shape = context.shape;
115
-
116
- if (is(shape, 'bpmn:Participant') && is(parent, 'bpmn:Process')) {
117
- ensureCollaboration(context);
118
- }
119
- }, true);
120
-
121
- this.execute('shape.create', function(context) {
122
- var process = context.process,
123
- shape = context.shape;
124
-
125
- if (process) {
126
- context.oldProcessRef = shape.businessObject.processRef;
127
-
128
- // re-use process when creating first participant
129
- shape.businessObject.processRef = process.businessObject;
130
- }
131
- }, true);
102
+ // when creating mutliple elements through `elements.create` parent must be set to collaboration
103
+ // and passed to `shape.create` as hint
104
+ this.preExecute('elements.create', HIGH_PRIORITY, function(context) {
105
+ var elements = context.elements,
106
+ parent = context.parent,
107
+ participant = findParticipant(elements),
108
+ hints;
132
109
 
133
- this.revert('shape.create', function(context) {
134
- var process = context.process,
135
- shape = context.shape;
110
+ if (participant && is(parent, 'bpmn:Process')) {
111
+ context.parent = getOrCreateCollaboration();
136
112
 
137
- if (process) {
113
+ hints = context.hints = context.hints || {};
138
114
 
139
- // re-use process when creating first participant
140
- shape.businessObject.processRef = context.oldProcessRef;
115
+ hints.participant = participant;
116
+ hints.process = parent;
117
+ hints.processRef = getBusinessObject(participant).get('processRef');
141
118
  }
142
119
  }, true);
143
120
 
144
- this.postExecute('shape.create', function(context) {
145
- var process = context.process,
121
+ // when creating single shape through `shape.create` parent must be set to collaboration
122
+ // unless it was already set through `elements.create`
123
+ this.preExecute('shape.create', function(context) {
124
+ var parent = context.parent,
146
125
  shape = context.shape;
147
126
 
148
- if (process) {
149
-
150
- // move children from process to participant
151
- var processChildren = process.children.slice();
127
+ if (is(shape, 'bpmn:Participant') && is(parent, 'bpmn:Process')) {
128
+ context.parent = getOrCreateCollaboration();
152
129
 
153
- modeling.moveElements(processChildren, { x: 0, y: 0 }, shape);
130
+ context.process = parent;
131
+ context.processRef = getBusinessObject(shape).get('processRef');
154
132
  }
155
-
156
133
  }, true);
157
134
 
158
- // turn process into collaboration when creating participants
159
- this.preExecute('elements.create', HIGH_PRIORITY, function(context) {
160
- var elements = context.elements,
161
- parent = context.parent,
162
- participant;
163
-
164
- var hasParticipants = findParticipant(elements);
165
-
166
- if (hasParticipants && is(parent, 'bpmn:Process')) {
167
- ensureCollaboration(context);
168
-
169
- participant = findParticipant(elements);
135
+ // #execute necessary because #preExecute not called on CommandStack#redo
136
+ this.execute('shape.create', function(context) {
137
+ var hints = context.hints || {},
138
+ process = context.process || hints.process,
139
+ shape = context.shape,
140
+ participant = hints.participant;
170
141
 
171
- context.oldProcessRef = participant.businessObject.processRef;
142
+ // both shape.create and elements.create must be handled
143
+ if (process && (!participant || shape === participant)) {
172
144
 
173
- // re-use process when creating first participant
174
- participant.businessObject.processRef = parent.businessObject;
145
+ // monkey-patch process ref
146
+ getBusinessObject(shape).set('processRef', getBusinessObject(process));
175
147
  }
176
148
  }, true);
177
149
 
178
- this.revert('elements.create', function(context) {
179
- var elements = context.elements,
180
- process = context.process,
181
- participant;
150
+ this.revert('shape.create', function(context) {
151
+ var hints = context.hints || {},
152
+ process = context.process || hints.process,
153
+ processRef = context.processRef || hints.processRef,
154
+ shape = context.shape,
155
+ participant = hints.participant;
182
156
 
183
- if (process) {
184
- participant = findParticipant(elements);
157
+ // both shape.create and elements.create must be handled
158
+ if (process && (!participant || shape === participant)) {
185
159
 
186
- // re-use process when creating first participant
187
- participant.businessObject.processRef = context.oldProcessRef;
160
+ // monkey-patch process ref
161
+ getBusinessObject(shape).set('processRef', processRef);
188
162
  }
189
163
  }, true);
190
164
 
191
- this.postExecute('elements.create', function(context) {
192
- var elements = context.elements,
193
- process = context.process,
194
- participant;
165
+ this.postExecute('shape.create', function(context) {
166
+ var hints = context.hints || {},
167
+ process = context.process || context.hints.process,
168
+ shape = context.shape,
169
+ participant = hints.participant;
195
170
 
196
171
  if (process) {
197
- participant = findParticipant(elements);
198
-
199
- // move children from process to first participant
200
- var processChildren = process.children.slice();
201
-
202
- modeling.moveElements(processChildren, { x: 0, y: 0 }, participant);
172
+ var children = process.children.slice();
173
+
174
+ // both shape.create and elements.create must be handled
175
+ if (!participant) {
176
+ modeling.moveElements(children, { x: 0, y: 0 }, shape);
177
+ } else if (shape === participant) {
178
+ modeling.moveElements(children, { x: 0, y: 0 }, participant);
179
+ }
203
180
  }
204
-
205
181
  }, true);
206
-
207
182
  }
208
183
 
209
184
  CreateParticipantBehavior.$inject = [
@@ -4,6 +4,7 @@ import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
4
4
 
5
5
  import {
6
6
  getBusinessObject,
7
+ getDi,
7
8
  is
8
9
  } from '../../../util/ModelUtil';
9
10
 
@@ -45,8 +46,9 @@ export default function DataStoreBehavior(
45
46
 
46
47
  commandStack.execute('dataStore.updateContainment', {
47
48
  dataStoreBo: dataStoreBo,
49
+ dataStoreDi: getDi(dataStore),
48
50
  newSemanticParent: newDataStoreParentBo.processRef || newDataStoreParentBo,
49
- newDiParent: newDataStoreParentBo.di
51
+ newDiParent: getDi(newDataStoreParent)
50
52
  });
51
53
  }
52
54
  }
@@ -3,7 +3,8 @@ import inherits from 'inherits';
3
3
  import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
4
4
 
5
5
  import {
6
- getBusinessObject
6
+ getBusinessObject,
7
+ getDi
7
8
  } from '../../../util/ModelUtil';
8
9
 
9
10
  import {
@@ -26,12 +27,14 @@ export default function IsHorizontalFix(eventBus) {
26
27
  ];
27
28
 
28
29
  this.executed([ 'shape.move', 'shape.create', 'shape.resize' ], function(event) {
29
- var bo = getBusinessObject(event.context.shape);
30
+ var shape = event.context.shape,
31
+ bo = getBusinessObject(shape),
32
+ di = getDi(shape);
30
33
 
31
- if (isAny(bo, elementTypesToUpdate) && !bo.di.get('isHorizontal')) {
34
+ if (isAny(bo, elementTypesToUpdate) && !di.get('isHorizontal')) {
32
35
 
33
36
  // set attribute directly to avoid modeling#updateProperty side effects
34
- bo.di.set('isHorizontal', true);
37
+ di.set('isHorizontal', true);
35
38
  }
36
39
  });
37
40
 
@@ -6,7 +6,8 @@ import inherits from 'inherits';
6
6
 
7
7
  import {
8
8
  is,
9
- getBusinessObject
9
+ getBusinessObject,
10
+ getDi
10
11
  } from '../../../util/ModelUtil';
11
12
 
12
13
  import {
@@ -153,27 +154,27 @@ export default function LabelBehavior(
153
154
 
154
155
  var context = event.context,
155
156
  element = context.shape,
156
- businessObject,
157
+ labelTarget = context.labelTarget,
157
158
  di;
158
159
 
159
160
  // we want to trigger on real labels only
160
- if (!element.labelTarget) {
161
+ if (!labelTarget) {
161
162
  return;
162
163
  }
163
164
 
164
165
  // we want to trigger on BPMN elements only
165
- if (!is(element.labelTarget || element, 'bpmn:BaseElement')) {
166
+ if (!is(labelTarget, 'bpmn:BaseElement')) {
166
167
  return;
167
168
  }
168
169
 
169
- businessObject = element.businessObject,
170
- di = businessObject.di;
171
-
170
+ di = getDi(labelTarget);
172
171
 
173
172
  if (!di.label) {
174
173
  di.label = bpmnFactory.create('bpmndi:BPMNLabel', {
175
174
  bounds: bpmnFactory.create('dc:Bounds')
176
175
  });
176
+
177
+ element.di = di;
177
178
  }
178
179
 
179
180
  assign(di.label.bounds, {