bpmn-js 9.2.2 → 9.3.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 (30) hide show
  1. package/CHANGELOG.md +17 -2
  2. package/dist/assets/bpmn-js.css +32 -4
  3. package/dist/bpmn-modeler.development.js +5489 -5152
  4. package/dist/bpmn-modeler.production.min.js +7 -7
  5. package/dist/bpmn-navigated-viewer.development.js +9 -6
  6. package/dist/bpmn-navigated-viewer.production.min.js +2 -2
  7. package/dist/bpmn-viewer.development.js +9 -6
  8. package/dist/bpmn-viewer.production.min.js +2 -2
  9. package/lib/Modeler.js +1 -1
  10. package/lib/features/align-elements/AlignElementsContextPadProvider.js +87 -0
  11. package/lib/features/align-elements/AlignElementsIcons.js +15 -0
  12. package/lib/features/align-elements/AlignElementsMenuProvider.js +72 -0
  13. package/lib/features/align-elements/BpmnAlignElements.js +39 -0
  14. package/lib/features/align-elements/index.js +23 -0
  15. package/lib/features/align-elements/resources/align-bottom-tool.svg +5 -0
  16. package/lib/features/align-elements/resources/align-horizontal-center-tool.svg +5 -0
  17. package/lib/features/align-elements/resources/align-left-tool.svg +5 -0
  18. package/lib/features/align-elements/resources/align-right-tool.svg +5 -0
  19. package/lib/features/align-elements/resources/align-tool.svg +5 -0
  20. package/lib/features/align-elements/resources/align-top-tool.svg +5 -0
  21. package/lib/features/align-elements/resources/align-vertical-center-tool.svg +5 -0
  22. package/lib/features/distribute-elements/BpmnDistributeElements.js +27 -7
  23. package/lib/features/distribute-elements/DistributeElementsIcons.js +10 -0
  24. package/lib/features/distribute-elements/DistributeElementsMenuProvider.js +69 -0
  25. package/lib/features/distribute-elements/index.js +9 -2
  26. package/lib/features/distribute-elements/resources/distribute-horizontally-tool.svg +5 -0
  27. package/lib/features/distribute-elements/resources/distribute-vertically-tool.svg +5 -0
  28. package/lib/features/modeling/behavior/ReplaceElementBehaviour.js +8 -4
  29. package/package.json +2 -2
  30. package/test/helper/index.js +25 -0
package/lib/Modeler.js CHANGED
@@ -10,7 +10,7 @@ import MoveCanvasModule from 'diagram-js/lib/navigation/movecanvas';
10
10
  import TouchModule from 'diagram-js/lib/navigation/touch';
11
11
  import ZoomScrollModule from 'diagram-js/lib/navigation/zoomscroll';
12
12
 
13
- import AlignElementsModule from 'diagram-js/lib/features/align-elements';
13
+ import AlignElementsModule from './features/align-elements';
14
14
  import AutoPlaceModule from './features/auto-place';
15
15
  import AutoResizeModule from './features/auto-resize';
16
16
  import AutoScrollModule from 'diagram-js/lib/features/auto-scroll';
@@ -0,0 +1,87 @@
1
+ import {
2
+ assign
3
+ } from 'min-dash';
4
+
5
+ import ICONS from './AlignElementsIcons';
6
+
7
+ var LOW_PRIORITY = 900;
8
+
9
+ /**
10
+ * A provider for align elements context pad button
11
+ */
12
+ export default function AlignElementsContextPadProvider(contextPad, popupMenu, translate, canvas) {
13
+
14
+ contextPad.registerProvider(LOW_PRIORITY, this);
15
+
16
+ this._contextPad = contextPad;
17
+ this._popupMenu = popupMenu;
18
+ this._translate = translate;
19
+ this._canvas = canvas;
20
+ }
21
+
22
+ AlignElementsContextPadProvider.$inject = [
23
+ 'contextPad',
24
+ 'popupMenu',
25
+ 'translate',
26
+ 'canvas'
27
+ ];
28
+
29
+ AlignElementsContextPadProvider.prototype.getMultiElementContextPadEntries = function(elements) {
30
+ var actions = {};
31
+
32
+ if (this._isAllowed(elements)) {
33
+ assign(actions, this._getEntries(elements));
34
+ }
35
+
36
+ return actions;
37
+ };
38
+
39
+ AlignElementsContextPadProvider.prototype._isAllowed = function(elements) {
40
+ return !this._popupMenu.isEmpty(elements, 'align-elements');
41
+ };
42
+
43
+ AlignElementsContextPadProvider.prototype._getEntries = function(elements) {
44
+ var self = this;
45
+
46
+ return {
47
+ 'align-elements': {
48
+ group: 'align-elements',
49
+ title: self._translate('Align elements'),
50
+ imageUrl: ICONS['align'],
51
+ action: {
52
+ click: function(event, elements) {
53
+ var position = self._getMenuPosition(elements);
54
+
55
+ assign(position, {
56
+ cursor: {
57
+ x: event.x,
58
+ y: event.y
59
+ }
60
+ });
61
+
62
+ self._popupMenu.open(elements, 'align-elements', position);
63
+ }
64
+ }
65
+ }
66
+ };
67
+ };
68
+
69
+ AlignElementsContextPadProvider.prototype._getMenuPosition = function(elements) {
70
+ var Y_OFFSET = 5;
71
+
72
+ var diagramContainer = this._canvas.getContainer(),
73
+ pad = this._contextPad.getPad(elements).html;
74
+
75
+ var diagramRect = diagramContainer.getBoundingClientRect(),
76
+ padRect = pad.getBoundingClientRect();
77
+
78
+ var top = padRect.top - diagramRect.top;
79
+ var left = padRect.left - diagramRect.left;
80
+
81
+ var pos = {
82
+ x: left,
83
+ y: top + padRect.height + Y_OFFSET
84
+ };
85
+
86
+ return pos;
87
+ };
@@ -0,0 +1,15 @@
1
+ /**
2
+ * To change the icons, modify the SVGs in `./resources`, execute `npx svgo -f resources --datauri enc -o dist`,
3
+ * and then replace respective icons with the optimized data URIs in `./dist`.
4
+ */
5
+ var icons = {
6
+ align: 'data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%202000%202000%22%3E%3Cpath%20style%3D%22stroke%3AcurrentColor%3Bstroke-width%3A100%3Bstroke-linecap%3Around%22%20d%3D%22M200%20150v1700%22%2F%3E%3Crect%20x%3D%22500%22%20y%3D%22150%22%20width%3D%221300%22%20height%3D%22700%22%20rx%3D%221%22%20style%3D%22fill%3Anone%3Bstroke%3AcurrentColor%3Bstroke-width%3A100%22%2F%3E%3Crect%20x%3D%22500%22%20y%3D%221150%22%20width%3D%22700%22%20height%3D%22700%22%20rx%3D%221%22%20style%3D%22fill%3AcurrentColor%3Bstroke%3AcurrentColor%3Bstroke-width%3A100%3Bopacity%3A.5%22%2F%3E%3C%2Fsvg%3E',
7
+ bottom: 'data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%201800%201800%22%3E%3Cpath%20style%3D%22stroke%3AcurrentColor%3Bstroke-width%3A100%3Bstroke-linecap%3Around%22%20d%3D%22M150%201650h1500%22%2F%3E%3Crect%20x%3D%22150%22%20y%3D%22350%22%20width%3D%22600%22%20height%3D%221300%22%20rx%3D%221%22%20style%3D%22fill%3Anone%3Bstroke%3AcurrentColor%3Bstroke-width%3A100%22%2F%3E%3Crect%20x%3D%221050%22%20y%3D%22850%22%20width%3D%22600%22%20height%3D%22800%22%20rx%3D%221%22%20style%3D%22fill%3AcurrentColor%3Bstroke%3AcurrentColor%3Bstroke-width%3A100%3Bopacity%3A.5%22%2F%3E%3C%2Fsvg%3E',
8
+ center: 'data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%201800%201800%22%3E%3Cpath%20style%3D%22stroke%3AcurrentColor%3Bstroke-width%3A100%3Bstroke-linecap%3Around%22%20d%3D%22M900%20150v1500%22%2F%3E%3Crect%20x%3D%22250%22%20y%3D%22150%22%20width%3D%221300%22%20height%3D%22600%22%20rx%3D%221%22%20style%3D%22fill%3Anone%3Bstroke%3AcurrentColor%3Bstroke-width%3A100%22%2F%3E%3Crect%20x%3D%22500%22%20y%3D%221050%22%20width%3D%22800%22%20height%3D%22600%22%20rx%3D%221%22%20style%3D%22fill%3AcurrentColor%3Bstroke%3AcurrentColor%3Bstroke-width%3A100%3Bopacity%3A.5%22%2F%3E%3C%2Fsvg%3E',
9
+ left: 'data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%201800%201800%22%3E%3Cpath%20style%3D%22stroke%3AcurrentColor%3Bstroke-width%3A100%3Bstroke-linecap%3Around%22%20d%3D%22M100%20150v1500%22%2F%3E%3Crect%20x%3D%22100%22%20y%3D%22150%22%20width%3D%221300%22%20height%3D%22600%22%20rx%3D%221%22%20style%3D%22fill%3Anone%3Bstroke%3AcurrentColor%3Bstroke-width%3A100%22%2F%3E%3Crect%20x%3D%22100%22%20y%3D%221050%22%20width%3D%22800%22%20height%3D%22600%22%20rx%3D%221%22%20style%3D%22fill%3AcurrentColor%3Bstroke%3AcurrentColor%3Bstroke-width%3A100%3Bopacity%3A.5%22%2F%3E%3C%2Fsvg%3E',
10
+ right: 'data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%201800%201800%22%3E%3Cpath%20style%3D%22stroke%3AcurrentColor%3Bstroke-width%3A100%3Bstroke-linecap%3Around%22%20d%3D%22M1650%20150v1500%22%2F%3E%3Crect%20x%3D%22350%22%20y%3D%22150%22%20width%3D%221300%22%20height%3D%22600%22%20rx%3D%221%22%20style%3D%22fill%3Anone%3Bstroke%3AcurrentColor%3Bstroke-width%3A100%22%2F%3E%3Crect%20x%3D%22850%22%20y%3D%221050%22%20width%3D%22800%22%20height%3D%22600%22%20rx%3D%221%22%20style%3D%22fill%3AcurrentColor%3Bstroke%3AcurrentColor%3Bstroke-width%3A100%3Bopacity%3A.5%22%2F%3E%3C%2Fsvg%3E',
11
+ top: 'data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%201800%201800%22%3E%3Cpath%20style%3D%22stroke%3AcurrentColor%3Bstroke-width%3A100%3Bstroke-linecap%3Around%22%20d%3D%22M150%20150h1500%22%2F%3E%3Crect%20x%3D%22150%22%20y%3D%22150%22%20width%3D%22600%22%20height%3D%221300%22%20rx%3D%221%22%20style%3D%22fill%3Anone%3Bstroke%3AcurrentColor%3Bstroke-width%3A100%22%2F%3E%3Crect%20x%3D%221050%22%20y%3D%22150%22%20width%3D%22600%22%20height%3D%22800%22%20rx%3D%221%22%20style%3D%22fill%3AcurrentColor%3Bstroke%3AcurrentColor%3Bstroke-width%3A100%3Bopacity%3A.5%22%2F%3E%3C%2Fsvg%3E',
12
+ middle: 'data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%201800%201800%22%3E%3Cpath%20style%3D%22stroke%3AcurrentColor%3Bstroke-width%3A100%3Bstroke-linecap%3Around%22%20d%3D%22M150%20900h1500%22%2F%3E%3Crect%20x%3D%22150%22%20y%3D%22250%22%20width%3D%22600%22%20height%3D%221300%22%20rx%3D%221%22%20style%3D%22fill%3Anone%3Bstroke%3AcurrentColor%3Bstroke-width%3A100%22%2F%3E%3Crect%20x%3D%221050%22%20y%3D%22500%22%20width%3D%22600%22%20height%3D%22800%22%20rx%3D%221%22%20style%3D%22fill%3AcurrentColor%3Bstroke%3AcurrentColor%3Bstroke-width%3A100%3Bopacity%3A.5%22%2F%3E%3C%2Fsvg%3E'
13
+ };
14
+
15
+ export default icons;
@@ -0,0 +1,72 @@
1
+ import ICONS from './AlignElementsIcons';
2
+
3
+ import {
4
+ assign,
5
+ forEach,
6
+ } from 'min-dash';
7
+
8
+ var ALIGNMENT_OPTIONS = [
9
+ 'left',
10
+ 'center',
11
+ 'right',
12
+ 'top',
13
+ 'middle',
14
+ 'bottom'
15
+ ];
16
+
17
+ /**
18
+ * A provider for align elements popup menu.
19
+ */
20
+ export default function AlignElementsMenuProvider(popupMenu, alignElements, translate, rules) {
21
+
22
+ this._alignElements = alignElements;
23
+ this._translate = translate;
24
+ this._popupMenu = popupMenu;
25
+ this._rules = rules;
26
+
27
+ popupMenu.registerProvider('align-elements', this);
28
+ }
29
+
30
+ AlignElementsMenuProvider.$inject = [
31
+ 'popupMenu',
32
+ 'alignElements',
33
+ 'translate',
34
+ 'rules'
35
+ ];
36
+
37
+ AlignElementsMenuProvider.prototype.getPopupMenuEntries = function(elements) {
38
+ var entries = {};
39
+
40
+ if (this._isAllowed(elements)) {
41
+ assign(entries, this._getEntries(elements));
42
+ }
43
+
44
+ return entries;
45
+ };
46
+
47
+ AlignElementsMenuProvider.prototype._isAllowed = function(elements) {
48
+ return this._rules.allowed('elements.align', { elements: elements });
49
+ };
50
+
51
+ AlignElementsMenuProvider.prototype._getEntries = function(elements) {
52
+ var alignElements = this._alignElements,
53
+ translate = this._translate,
54
+ popupMenu = this._popupMenu;
55
+
56
+ var entries = {};
57
+
58
+ forEach(ALIGNMENT_OPTIONS, function(alignment) {
59
+ entries[ 'align-elements-' + alignment ] = {
60
+ group: 'align',
61
+ title: translate('Align elements ' + alignment),
62
+ className: 'bjs-align-elements-menu-entry',
63
+ imageUrl: ICONS[alignment],
64
+ action: function(event, entry) {
65
+ alignElements.trigger(elements, alignment);
66
+ popupMenu.close();
67
+ }
68
+ };
69
+ });
70
+
71
+ return entries;
72
+ };
@@ -0,0 +1,39 @@
1
+ import inherits from 'inherits-browser';
2
+
3
+ import RuleProvider from 'diagram-js/lib/features/rules/RuleProvider';
4
+ import { getParents } from 'diagram-js/lib/util/Elements';
5
+
6
+ import {
7
+ filter
8
+ } from 'min-dash';
9
+
10
+ /**
11
+ * Rule provider for alignment of BPMN elements.
12
+ */
13
+ export default function BpmnAlignElements(eventBus) {
14
+ RuleProvider.call(this, eventBus);
15
+ }
16
+
17
+ BpmnAlignElements.$inject = [ 'eventBus' ];
18
+
19
+ inherits(BpmnAlignElements, RuleProvider);
20
+
21
+ BpmnAlignElements.prototype.init = function() {
22
+ this.addRule('elements.align', function(context) {
23
+ var elements = context.elements;
24
+
25
+ // filter out elements which cannot be aligned
26
+ var filteredElements = filter(elements, function(element) {
27
+ return !(element.waypoints || element.host || element.labelTarget);
28
+ });
29
+
30
+ // filter out elements which are children of any of the selected elements
31
+ filteredElements = getParents(filteredElements);
32
+
33
+ if (filteredElements.length < 2) {
34
+ return false;
35
+ }
36
+
37
+ return filteredElements;
38
+ });
39
+ };
@@ -0,0 +1,23 @@
1
+ import AlignElementsModule from 'diagram-js/lib/features/align-elements';
2
+ import ContextPadModule from 'diagram-js/lib/features/context-pad';
3
+ import PopupMenuModule from 'diagram-js/lib/features/popup-menu';
4
+
5
+ import AlignElementsContextPadProvider from './AlignElementsContextPadProvider';
6
+ import AlignElementsMenuProvider from './AlignElementsMenuProvider';
7
+ import BpmnAlignElements from './BpmnAlignElements';
8
+
9
+ export default {
10
+ __depends__: [
11
+ AlignElementsModule,
12
+ ContextPadModule,
13
+ PopupMenuModule
14
+ ],
15
+ __init__: [
16
+ 'alignElementsContextPadProvider',
17
+ 'alignElementsMenuProvider',
18
+ 'bpmnAlignElements'
19
+ ],
20
+ alignElementsContextPadProvider: [ 'type', AlignElementsContextPadProvider ],
21
+ alignElementsMenuProvider: [ 'type', AlignElementsMenuProvider ],
22
+ bpmnAlignElements: [ 'type', BpmnAlignElements]
23
+ };
@@ -0,0 +1,5 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1800 1800">
2
+ <line x1="150" y1="1650" x2="1650" y2="1650" style="stroke:currentColor;stroke-width:100;stroke-linecap:round;"/>
3
+ <rect x="150" y="350" width="600" height="1300" rx="1" style="fill:none;stroke:currentColor;stroke-width:100;"></rect>
4
+ <rect x="1050" y="850" width="600" height="800" rx="1" style="fill:currentColor;stroke:currentColor;stroke-width:100;opacity:.5;"></rect>
5
+ </svg>
@@ -0,0 +1,5 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1800 1800">
2
+ <line x1="900" y1="150" x2="900" y2="1650" style="stroke:currentColor;stroke-width:100;stroke-linecap:round;"/>
3
+ <rect x="250" y="150" width="1300" height="600" rx="1" style="fill:none;stroke:currentColor;stroke-width:100;"></rect>
4
+ <rect x="500" y="1050" width="800" height="600" rx="1" style="fill:currentColor;stroke:currentColor;stroke-width:100;opacity:.5;"></rect>
5
+ </svg>
@@ -0,0 +1,5 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1800 1800">
2
+ <line x1="100" y1="150" x2="100" y2="1650" style="stroke:currentColor;stroke-width:100;stroke-linecap:round;"/>
3
+ <rect x="100" y="150" width="1300" height="600" rx="1" style="fill:none;stroke:currentColor;stroke-width:100;"></rect>
4
+ <rect x="100" y="1050" width="800" height="600" rx="1" style="fill:currentColor;stroke:currentColor;stroke-width:100;opacity:.5;"></rect>
5
+ </svg>
@@ -0,0 +1,5 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1800 1800">
2
+ <line x1="1650" y1="150" x2="1650" y2="1650" style="stroke:currentColor;stroke-width:100;stroke-linecap:round;"/>
3
+ <rect x="350" y="150" width="1300" height="600" rx="1" style="fill:none;stroke:currentColor;stroke-width:100;"></rect>
4
+ <rect x="850" y="1050" width="800" height="600" rx="1" style="fill:currentColor;stroke:currentColor;stroke-width:100;opacity:.5;"></rect>
5
+ </svg>
@@ -0,0 +1,5 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 2000 2000">
2
+ <line x1="200" y1="150" x2="200" y2="1850" style="stroke:currentColor;stroke-width:100;stroke-linecap:round;"/>
3
+ <rect x="500" y="150" width="1300" height="700" rx="1" style="fill:none;stroke:currentColor;stroke-width:100;"></rect>
4
+ <rect x="500" y="1150" width="700" height="700" rx="1" style="fill:currentColor;stroke:currentColor;stroke-width:100;opacity:.5;"></rect>
5
+ </svg>
@@ -0,0 +1,5 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1800 1800">
2
+ <line x1="150" y1="150" x2="1650" y2="150" style="stroke:currentColor;stroke-width:100;stroke-linecap:round;"/>
3
+ <rect x="150" y="150" width="600" height="1300" rx="1" style="fill:none;stroke:currentColor;stroke-width:100;"></rect>
4
+ <rect x="1050" y="150" width="600" height="800" rx="1" style="fill:currentColor;stroke:currentColor;stroke-width:100;opacity:.5;"></rect>
5
+ </svg>
@@ -0,0 +1,5 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1800 1800">
2
+ <line x1="150" y1="900" x2="1650" y2="900" style="stroke:currentColor;stroke-width:100;stroke-linecap:round;"/>
3
+ <rect x="150" y="250" width="600" height="1300" rx="1" style="fill:none;stroke:currentColor;stroke-width:100;"></rect>
4
+ <rect x="1050" y="500" width="600" height="800" rx="1" style="fill:currentColor;stroke:currentColor;stroke-width:100;opacity:.5;"></rect>
5
+ </svg>
@@ -1,3 +1,8 @@
1
+ import inherits from 'inherits-browser';
2
+
3
+ import RuleProvider from 'diagram-js/lib/features/rules/RuleProvider';
4
+ import { getParents } from 'diagram-js/lib/util/Elements';
5
+
1
6
  import {
2
7
  filter
3
8
  } from 'min-dash';
@@ -11,10 +16,19 @@ import {
11
16
  * Registers element exclude filters for elements that
12
17
  * currently do not support distribution.
13
18
  */
14
- export default function BpmnDistributeElements(distributeElements) {
19
+ export default function BpmnDistributeElements(distributeElements, eventBus, rules) {
20
+ RuleProvider.call(this, eventBus);
21
+ }
22
+
23
+ BpmnDistributeElements.$inject = [ 'distributeElements', 'eventBus', 'rules' ];
24
+
25
+ inherits(BpmnDistributeElements, RuleProvider);
26
+
27
+ BpmnDistributeElements.prototype.init = function() {
28
+ this.addRule('elements.distribute', function(context) {
29
+ var elements = context.elements;
15
30
 
16
- distributeElements.registerFilter(function(elements) {
17
- return filter(elements, function(element) {
31
+ elements = filter(elements, function(element) {
18
32
  var cannotDistribute = isAny(element, [
19
33
  'bpmn:Association',
20
34
  'bpmn:BoundaryEvent',
@@ -22,14 +36,20 @@ export default function BpmnDistributeElements(distributeElements) {
22
36
  'bpmn:DataOutputAssociation',
23
37
  'bpmn:Lane',
24
38
  'bpmn:MessageFlow',
25
- 'bpmn:Participant',
26
39
  'bpmn:SequenceFlow',
27
40
  'bpmn:TextAnnotation'
28
41
  ]);
29
42
 
30
43
  return !(element.labelTarget || cannotDistribute);
31
44
  });
32
- });
33
- }
34
45
 
35
- BpmnDistributeElements.$inject = [ 'distributeElements' ];
46
+ // filter out elements which are children of any of the selected elements
47
+ elements = getParents(elements);
48
+
49
+ if (elements.length < 3) {
50
+ return false;
51
+ }
52
+
53
+ return elements;
54
+ });
55
+ };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * To change the icons, modify the SVGs in `./resources`, execute `npx svgo -f resources --datauri enc -o dist`,
3
+ * and then replace respective icons with the optimized data URIs in `./dist`.
4
+ */
5
+ var icons = {
6
+ horizontal: 'data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%201800%201800%22%3E%3Cpath%20style%3D%22fill%3Anone%3Bstroke%3AcurrentColor%3Bstroke-width%3A100%3Bstroke-linejoin%3Around%22%20d%3D%22M450%20400V150h900v250%22%2F%3E%3Crect%20x%3D%22150%22%20y%3D%22450%22%20width%3D%22600%22%20height%3D%221200%22%20rx%3D%221%22%20style%3D%22fill%3Anone%3Bstroke%3AcurrentColor%3Bstroke-width%3A100%22%2F%3E%3Crect%20x%3D%221050%22%20y%3D%22450%22%20width%3D%22600%22%20height%3D%22800%22%20rx%3D%221%22%20style%3D%22fill%3AcurrentColor%3Bstroke%3AcurrentColor%3Bstroke-width%3A100%3Bopacity%3A.5%22%2F%3E%3C%2Fsvg%3E',
7
+ vertical: 'data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%201800%201800%22%3E%3Cpath%20style%3D%22fill%3Anone%3Bstroke%3AcurrentColor%3Bstroke-width%3A100%3Bstroke-linejoin%3Around%22%20d%3D%22M400%201350H150V450h250%22%2F%3E%3Crect%20x%3D%22450%22%20y%3D%22150%22%20width%3D%221200%22%20height%3D%22600%22%20rx%3D%221%22%20style%3D%22fill%3Anone%3Bstroke%3AcurrentColor%3Bstroke-width%3A100%22%2F%3E%3Crect%20x%3D%22450%22%20y%3D%221050%22%20width%3D%22800%22%20height%3D%22600%22%20rx%3D%221%22%20style%3D%22fill%3AcurrentColor%3Bstroke%3AcurrentColor%3Bstroke-width%3A100%3Bopacity%3A.5%22%2F%3E%3C%2Fsvg%3E',
8
+ };
9
+
10
+ export default icons;
@@ -0,0 +1,69 @@
1
+ import ICONS from './DistributeElementsIcons';
2
+
3
+ import { assign } from 'min-dash';
4
+
5
+ var LOW_PRIORITY = 900;
6
+
7
+ /**
8
+ * A provider for distribute elements popup menu.
9
+ */
10
+ export default function DistributeElementsMenuProvider(
11
+ popupMenu, distributeElements, translate, rules) {
12
+ this._distributeElements = distributeElements;
13
+ this._translate = translate;
14
+ this._popupMenu = popupMenu;
15
+ this._rules = rules;
16
+
17
+ popupMenu.registerProvider('align-elements', LOW_PRIORITY, this);
18
+ }
19
+
20
+ DistributeElementsMenuProvider.$inject = [
21
+ 'popupMenu',
22
+ 'distributeElements',
23
+ 'translate',
24
+ 'rules'
25
+ ];
26
+
27
+ DistributeElementsMenuProvider.prototype.getPopupMenuEntries = function(elements) {
28
+ var entries = {};
29
+
30
+ if (this._isAllowed(elements)) {
31
+ assign(entries, this._getEntries(elements));
32
+ }
33
+
34
+ return entries;
35
+ };
36
+
37
+ DistributeElementsMenuProvider.prototype._isAllowed = function(elements) {
38
+ return this._rules.allowed('elements.distribute', { elements: elements });
39
+ };
40
+
41
+ DistributeElementsMenuProvider.prototype._getEntries = function(elements) {
42
+ var distributeElements = this._distributeElements,
43
+ translate = this._translate,
44
+ popupMenu = this._popupMenu;
45
+
46
+ var entries = {
47
+ 'distribute-elements-horizontal': {
48
+ group: 'distribute',
49
+ title: translate('Distribute elements horizontally'),
50
+ className: 'bjs-align-elements-menu-entry',
51
+ imageUrl: ICONS['horizontal'],
52
+ action: function(event, entry) {
53
+ distributeElements.trigger(elements, 'horizontal');
54
+ popupMenu.close();
55
+ }
56
+ },
57
+ 'distribute-elements-vertical': {
58
+ group: 'distribute',
59
+ title: translate('Distribute elements vertically'),
60
+ imageUrl: ICONS['vertical'],
61
+ action: function(event, entry) {
62
+ distributeElements.trigger(elements, 'vertical');
63
+ popupMenu.close();
64
+ }
65
+ },
66
+ };
67
+
68
+ return entries;
69
+ };
@@ -1,12 +1,19 @@
1
1
  import DistributeElementsModule from 'diagram-js/lib/features/distribute-elements';
2
+ import PopupMenuModule from 'diagram-js/lib/features/popup-menu';
2
3
 
3
4
  import BpmnDistributeElements from './BpmnDistributeElements';
5
+ import DistributeElementsMenuProvider from './DistributeElementsMenuProvider';
4
6
 
5
7
 
6
8
  export default {
7
9
  __depends__: [
10
+ PopupMenuModule,
8
11
  DistributeElementsModule
9
12
  ],
10
- __init__: [ 'bpmnDistributeElements' ],
11
- bpmnDistributeElements: [ 'type', BpmnDistributeElements ]
13
+ __init__: [
14
+ 'bpmnDistributeElements',
15
+ 'distributeElementsMenuProvider'
16
+ ],
17
+ bpmnDistributeElements: [ 'type', BpmnDistributeElements ],
18
+ distributeElementsMenuProvider: [ 'type', DistributeElementsMenuProvider ]
12
19
  };
@@ -0,0 +1,5 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1800 1800">
2
+ <polyline points="450 400 450 150 1350 150 1350 400" style="fill:none;stroke:currentColor;stroke-width:100;stroke-linejoin:round;"/>
3
+ <rect x="150" y="450" width="600" height="1200" rx="1" style="fill:none;stroke:currentColor;stroke-width:100;"></rect>
4
+ <rect x="1050" y="450" width="600" height="800" rx="1" style="fill:currentColor;stroke:currentColor;stroke-width:100;opacity:.5;"></rect>
5
+ </svg>
@@ -0,0 +1,5 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1800 1800">
2
+ <polyline points="400 1350 150 1350 150 450 400 450" style="fill:none;stroke:currentColor;stroke-width:100;stroke-linejoin:round;"/>
3
+ <rect x="450" y="150" width="1200" height="600" rx="1" style="fill:none;stroke:currentColor;stroke-width:100;"></rect>
4
+ <rect x="450" y="1050" width="800" height="600" rx="1" style="fill:currentColor;stroke:currentColor;stroke-width:100;opacity:.5;"></rect>
5
+ </svg>
@@ -1,6 +1,6 @@
1
1
  import inherits from 'inherits-browser';
2
2
 
3
- import { forEach } from 'min-dash';
3
+ import { forEach, reduce } from 'min-dash';
4
4
 
5
5
  import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
6
6
 
@@ -30,10 +30,14 @@ export default function ReplaceElementBehaviour(
30
30
  target = context.parent,
31
31
  elements = context.elements;
32
32
 
33
- var canReplace = bpmnRules.canReplace(elements, target);
33
+ var elementReplacements = reduce(elements, function(replacements, element) {
34
+ var canReplace = bpmnRules.canReplace([ element ], element.host || element.parent || target);
34
35
 
35
- if (canReplace) {
36
- this.replaceElements(elements, canReplace.replacements);
36
+ return canReplace ? replacements.concat(canReplace.replacements) : replacements;
37
+ }, []);
38
+
39
+ if (elementReplacements.length) {
40
+ this.replaceElements(elements, elementReplacements);
37
41
  }
38
42
  }, this);
39
43
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bpmn-js",
3
- "version": "9.2.2",
3
+ "version": "9.3.2",
4
4
  "description": "A bpmn 2.0 toolkit and web modeler",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -100,7 +100,7 @@
100
100
  "dependencies": {
101
101
  "bpmn-moddle": "^7.1.2",
102
102
  "css.escape": "^1.5.1",
103
- "diagram-js": "^8.5.0",
103
+ "diagram-js": "^8.7.1",
104
104
  "diagram-js-direct-editing": "^1.7.0",
105
105
  "ids": "^1.0.0",
106
106
  "inherits-browser": "0.0.1",
@@ -267,6 +267,31 @@ export function createViewer(container, viewerInstance, xml, diagramId) {
267
267
  });
268
268
  }
269
269
 
270
+ function logConfigured(type, force) {
271
+ var url = new URL(window.location.href);
272
+
273
+ var log = ('searchParams' in url) && url.searchParams.get('log') || '';
274
+
275
+ return force || log.includes('save-xml');
276
+ }
277
+
278
+ /**
279
+ * Enable logging on a modeler instance.
280
+ *
281
+ * @param {import('bpmn-js')} modeler
282
+ * @param {boolean} [force=false]
283
+ */
284
+ export function enableLogging(modeler, force) {
285
+
286
+ var saveXML = logConfigured('save-xml', force);
287
+
288
+ saveXML && modeler.on('commandStack.changed', function() {
289
+ modeler.saveXML({ format: true }).then(function(result) {
290
+ console.log(result.xml);
291
+ });
292
+ });
293
+ }
294
+
270
295
  export function setBpmnJS(instance) {
271
296
  BPMN_JS = instance;
272
297
  }