bpmn-js 18.6.0 → 18.6.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.
@@ -951,7 +951,7 @@ export default function BpmnRenderer(
951
951
  taskMarkerRenderers[ type ](parentGfx, element, attrs);
952
952
  }
953
953
 
954
- function renderTaskMarkers(parentGfx, element, taskMarkers, attrs = {}) {
954
+ function renderTaskMarkers(parentGfx, element, taskMarkers = [], attrs = {}) {
955
955
  attrs = {
956
956
  fill: attrs.fill,
957
957
  stroke: attrs.stroke,
@@ -961,14 +961,14 @@ export default function BpmnRenderer(
961
961
 
962
962
  var semantic = getSemantic(element);
963
963
 
964
- var subprocess = taskMarkers && taskMarkers.includes('SubProcessMarker');
964
+ var subprocess = taskMarkers.includes('SubProcessMarker');
965
965
 
966
966
  if (subprocess) {
967
967
  attrs = {
968
968
  ...attrs,
969
969
  seq: -21,
970
970
  parallel: -22,
971
- compensation: -42,
971
+ compensation: -25,
972
972
  loop: -18,
973
973
  adhoc: 10
974
974
  };
@@ -977,22 +977,22 @@ export default function BpmnRenderer(
977
977
  ...attrs,
978
978
  seq: -5,
979
979
  parallel: -6,
980
- compensation: -27,
980
+ compensation: -7,
981
981
  loop: 0,
982
- adhoc: 10
982
+ adhoc: -8
983
983
  };
984
984
  }
985
985
 
986
- forEach(taskMarkers, function(marker) {
987
- renderTaskMarker(marker, parentGfx, element, attrs);
988
- });
989
-
990
986
  if (semantic.get('isForCompensation')) {
991
- renderTaskMarker('CompensationMarker', parentGfx, element, attrs);
987
+ taskMarkers.push('CompensationMarker');
992
988
  }
993
989
 
994
990
  if (is(semantic, 'bpmn:AdHocSubProcess')) {
995
- renderTaskMarker('AdhocMarker', parentGfx, element, attrs);
991
+ taskMarkers.push('AdhocMarker');
992
+
993
+ if (!subprocess) {
994
+ assign(attrs, { compensation: attrs.compensation - 18 });
995
+ }
996
996
  }
997
997
 
998
998
  var loopCharacteristics = semantic.get('loopCharacteristics'),
@@ -1000,18 +1000,40 @@ export default function BpmnRenderer(
1000
1000
 
1001
1001
  if (loopCharacteristics) {
1002
1002
 
1003
+ assign(attrs, {
1004
+ compensation: attrs.compensation - 18,
1005
+ });
1006
+
1007
+ if (taskMarkers.includes('AdhocMarker')) {
1008
+ assign(attrs, {
1009
+ seq: -23,
1010
+ loop: -18,
1011
+ parallel: -24
1012
+ });
1013
+ }
1014
+
1003
1015
  if (isSequential === undefined) {
1004
- renderTaskMarker('LoopMarker', parentGfx, element, attrs);
1016
+ taskMarkers.push('LoopMarker');
1005
1017
  }
1006
1018
 
1007
1019
  if (isSequential === false) {
1008
- renderTaskMarker('ParallelMarker', parentGfx, element, attrs);
1020
+ taskMarkers.push('ParallelMarker');
1009
1021
  }
1010
1022
 
1011
1023
  if (isSequential === true) {
1012
- renderTaskMarker('SequentialMarker', parentGfx, element, attrs);
1024
+ taskMarkers.push('SequentialMarker');
1013
1025
  }
1014
1026
  }
1027
+
1028
+ if (taskMarkers.includes('CompensationMarker') && taskMarkers.length === 1) {
1029
+ assign(attrs, {
1030
+ compensation: -8
1031
+ });
1032
+ }
1033
+
1034
+ forEach(taskMarkers, function(marker) {
1035
+ renderTaskMarker(marker, parentGfx, element, attrs);
1036
+ });
1015
1037
  }
1016
1038
 
1017
1039
  function renderLabel(parentGfx, label, attrs = {}) {
@@ -4,14 +4,15 @@ import {
4
4
  has,
5
5
  isArray,
6
6
  isDefined,
7
- isFunction,
8
7
  isObject,
9
8
  matchPattern,
10
9
  reduce,
11
10
  sortBy
12
11
  } from 'min-dash';
13
12
 
14
- var DISALLOWED_PROPERTIES = [
13
+ import { is } from '../../util/ModelUtil';
14
+
15
+ const DISALLOWED_PROPERTIES = [
15
16
  'artifacts',
16
17
  'dataInputAssociations',
17
18
  'dataOutputAssociations',
@@ -23,6 +24,13 @@ var DISALLOWED_PROPERTIES = [
23
24
  'categoryValue'
24
25
  ];
25
26
 
27
+ const ALLOWED_REFERENCES = [
28
+ 'errorRef',
29
+ 'escalationRef',
30
+ 'messageRef',
31
+ 'signalRef'
32
+ ];
33
+
26
34
  /**
27
35
  * @typedef {import('diagram-js/lib/core/EventBus').default} EventBus
28
36
  * @typedef {import('../modeling/BpmnFactory').default} BpmnFactory
@@ -44,25 +52,35 @@ export default function ModdleCopy(eventBus, bpmnFactory, moddle) {
44
52
  this._moddle = moddle;
45
53
 
46
54
  // copy extension elements last
47
- eventBus.on('moddleCopy.canCopyProperties', function(context) {
48
- var propertyNames = context.propertyNames;
55
+ eventBus.on('moddleCopy.canCopyProperties', (context) => {
56
+ const { propertyNames } = context;
49
57
 
50
58
  if (!propertyNames || !propertyNames.length) {
51
59
  return;
52
60
  }
53
61
 
54
- return sortBy(propertyNames, function(propertyName) {
62
+ return sortBy(propertyNames, (propertyName) => {
55
63
  return propertyName === 'extensionElements';
56
64
  });
57
65
  });
58
66
 
59
67
  // default check whether property can be copied
60
- eventBus.on('moddleCopy.canCopyProperty', function(context) {
61
- var parent = context.parent,
62
- parentDescriptor = isObject(parent) && parent.$descriptor,
63
- propertyName = context.propertyName;
68
+ eventBus.on('moddleCopy.canCopyProperty', (context) => {
69
+ const {
70
+ parent,
71
+ property,
72
+ propertyName
73
+ } = context;
74
+
75
+ const parentDescriptor = isObject(parent) && parent.$descriptor;
76
+
77
+ if (propertyName && ALLOWED_REFERENCES.includes(propertyName)) {
64
78
 
65
- if (propertyName && DISALLOWED_PROPERTIES.indexOf(propertyName) !== -1) {
79
+ // allow copying reference
80
+ return property;
81
+ }
82
+
83
+ if (propertyName && DISALLOWED_PROPERTIES.includes(propertyName)) {
66
84
 
67
85
  // disallow copying property
68
86
  return false;
@@ -78,8 +96,8 @@ export default function ModdleCopy(eventBus, bpmnFactory, moddle) {
78
96
  });
79
97
 
80
98
  // do NOT allow to copy empty extension elements
81
- eventBus.on('moddleCopy.canSetCopiedProperty', function(context) {
82
- var property = context.property;
99
+ eventBus.on('moddleCopy.canSetCopiedProperty', (context) => {
100
+ const { property } = context;
83
101
 
84
102
  if (is(property, 'bpmn:ExtensionElements') && (!property.values || !property.values.length)) {
85
103
 
@@ -106,15 +124,13 @@ ModdleCopy.$inject = [
106
124
  * @return {ModdleElement}
107
125
  */
108
126
  ModdleCopy.prototype.copyElement = function(sourceElement, targetElement, propertyNames, clone = false) {
109
- var self = this;
110
-
111
127
  if (propertyNames && !isArray(propertyNames)) {
112
128
  propertyNames = [ propertyNames ];
113
129
  }
114
130
 
115
131
  propertyNames = propertyNames || getPropertyNames(sourceElement.$descriptor);
116
132
 
117
- var canCopyProperties = this._eventBus.fire('moddleCopy.canCopyProperties', {
133
+ const canCopyProperties = this._eventBus.fire('moddleCopy.canCopyProperties', {
118
134
  propertyNames: propertyNames,
119
135
  sourceElement: sourceElement,
120
136
  targetElement: targetElement,
@@ -130,20 +146,20 @@ ModdleCopy.prototype.copyElement = function(sourceElement, targetElement, proper
130
146
  }
131
147
 
132
148
  // copy properties
133
- forEach(propertyNames, function(propertyName) {
134
- var sourceProperty;
149
+ forEach(propertyNames, (propertyName) => {
150
+ let sourceProperty;
135
151
 
136
152
  if (has(sourceElement, propertyName)) {
137
153
  sourceProperty = sourceElement.get(propertyName);
138
154
  }
139
155
 
140
- var copiedProperty = self.copyProperty(sourceProperty, targetElement, propertyName, clone);
156
+ const copiedProperty = this.copyProperty(sourceProperty, targetElement, propertyName, clone);
141
157
 
142
158
  if (!isDefined(copiedProperty)) {
143
159
  return;
144
160
  }
145
161
 
146
- var canSetProperty = self._eventBus.fire('moddleCopy.canSetCopiedProperty', {
162
+ const canSetProperty = this._eventBus.fire('moddleCopy.canSetCopiedProperty', {
147
163
  parent: targetElement,
148
164
  property: copiedProperty,
149
165
  propertyName: propertyName
@@ -172,10 +188,9 @@ ModdleCopy.prototype.copyElement = function(sourceElement, targetElement, proper
172
188
  * @return {any}
173
189
  */
174
190
  ModdleCopy.prototype.copyProperty = function(property, parent, propertyName, clone = false) {
175
- var self = this;
176
191
 
177
192
  // allow others to copy property
178
- var copiedProperty = this._eventBus.fire('moddleCopy.canCopyProperty', {
193
+ let copiedProperty = this._eventBus.fire('moddleCopy.canCopyProperty', {
179
194
  parent: parent,
180
195
  property: property,
181
196
  propertyName: propertyName,
@@ -195,7 +210,7 @@ ModdleCopy.prototype.copyProperty = function(property, parent, propertyName, clo
195
210
  return copiedProperty;
196
211
  }
197
212
 
198
- var propertyDescriptor = this._moddle.getPropertyDescriptor(parent, propertyName);
213
+ const propertyDescriptor = this._moddle.getPropertyDescriptor(parent, propertyName);
199
214
 
200
215
  // do NOT copy references
201
216
  if (propertyDescriptor.isReference) {
@@ -209,10 +224,10 @@ ModdleCopy.prototype.copyProperty = function(property, parent, propertyName, clo
209
224
 
210
225
  // copy arrays
211
226
  if (isArray(property)) {
212
- return reduce(property, function(childProperties, childProperty) {
227
+ return reduce(property, (childProperties, childProperty) => {
213
228
 
214
229
  // recursion
215
- copiedProperty = self.copyProperty(childProperty, parent, propertyName, clone);
230
+ const copiedProperty = this.copyProperty(childProperty, parent, propertyName, clone);
216
231
 
217
232
  // copying might NOT be allowed
218
233
  if (copiedProperty) {
@@ -229,12 +244,12 @@ ModdleCopy.prototype.copyProperty = function(property, parent, propertyName, clo
229
244
  return;
230
245
  }
231
246
 
232
- copiedProperty = self._bpmnFactory.create(property.$type);
247
+ copiedProperty = this._bpmnFactory.create(property.$type);
233
248
 
234
249
  copiedProperty.$parent = parent;
235
250
 
236
251
  // recursion
237
- copiedProperty = self.copyElement(property, copiedProperty, null, clone);
252
+ copiedProperty = this.copyElement(property, copiedProperty, null, clone);
238
253
 
239
254
  return copiedProperty;
240
255
  }
@@ -261,7 +276,7 @@ ModdleCopy.prototype._copyId = function(id, element, clone = false) {
261
276
  // helpers //////////
262
277
 
263
278
  export function getPropertyNames(descriptor, keepDefaultProperties) {
264
- return reduce(descriptor.properties, function(properties, property) {
279
+ return reduce(descriptor.properties, (properties, property) => {
265
280
 
266
281
  if (keepDefaultProperties && property.default) {
267
282
  return properties;
@@ -269,8 +284,4 @@ export function getPropertyNames(descriptor, keepDefaultProperties) {
269
284
 
270
285
  return properties.concat(property.name);
271
286
  }, []);
272
- }
273
-
274
- function is(element, type) {
275
- return element && isFunction(element.$instanceOf) && element.$instanceOf(type);
276
287
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bpmn-js",
3
- "version": "18.6.0",
3
+ "version": "18.6.2",
4
4
  "description": "A bpmn 2.0 toolkit and web modeler",
5
5
  "main": "lib/index.js",
6
6
  "files": [
@@ -97,7 +97,7 @@
97
97
  "karma-webpack": "^5.0.1",
98
98
  "mocha": "^10.8.2",
99
99
  "mocha-test-container-support": "0.2.0",
100
- "npm-run-all2": "^7.0.2",
100
+ "npm-run-all2": "^8.0.0",
101
101
  "puppeteer": "~24.5.0",
102
102
  "remark-cli": "^12.0.0",
103
103
  "remark-preset-bpmn-io": "^0.2.1",