bpmn-js 11.1.0 → 11.2.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 (44) hide show
  1. package/README.md +0 -8
  2. package/dist/assets/bpmn-font/css/bpmn-codes.css +6 -6
  3. package/dist/assets/bpmn-font/css/bpmn-embedded.css +18 -13
  4. package/dist/assets/bpmn-font/css/bpmn.css +14 -15
  5. package/dist/assets/bpmn-font/font/bpmn.eot +0 -0
  6. package/dist/assets/bpmn-font/font/bpmn.svg +12 -12
  7. package/dist/assets/bpmn-font/font/bpmn.ttf +0 -0
  8. package/dist/assets/bpmn-font/font/bpmn.woff +0 -0
  9. package/dist/assets/bpmn-font/font/bpmn.woff2 +0 -0
  10. package/dist/assets/diagram-js.css +7 -6
  11. package/dist/bpmn-modeler.development.js +2560 -1187
  12. package/dist/bpmn-modeler.production.min.js +44 -42
  13. package/dist/bpmn-navigated-viewer.development.js +310 -219
  14. package/dist/bpmn-navigated-viewer.production.min.js +6 -6
  15. package/dist/bpmn-viewer.development.js +310 -219
  16. package/dist/bpmn-viewer.production.min.js +6 -6
  17. package/lib/Modeler.js +2 -0
  18. package/lib/draw/BpmnRenderer.js +185 -196
  19. package/lib/features/align-elements/dist/align-bottom-tool.svg +1 -0
  20. package/lib/features/align-elements/dist/align-horizontal-center-tool.svg +1 -0
  21. package/lib/features/align-elements/dist/align-left-tool.svg +1 -0
  22. package/lib/features/align-elements/dist/align-right-tool.svg +1 -0
  23. package/lib/features/align-elements/dist/align-tool.svg +1 -0
  24. package/lib/features/align-elements/dist/align-top-tool.svg +1 -0
  25. package/lib/features/align-elements/dist/align-vertical-center-tool.svg +1 -0
  26. package/lib/features/context-pad/ContextPadProvider.js +0 -1
  27. package/lib/features/create-append-anything/AppendContextPadProvider.js +77 -0
  28. package/lib/features/create-append-anything/AppendMenuProvider.js +175 -0
  29. package/lib/features/create-append-anything/AppendRules.js +83 -0
  30. package/lib/features/create-append-anything/CreateAppendEditorActions.js +51 -0
  31. package/lib/features/create-append-anything/CreateAppendKeyboardBindings.js +97 -0
  32. package/lib/features/create-append-anything/CreateMenuProvider.js +112 -0
  33. package/lib/features/create-append-anything/CreatePaletteProvider.js +77 -0
  34. package/lib/features/create-append-anything/index.js +37 -0
  35. package/lib/features/create-append-anything/util/OptionsUtil.js +612 -0
  36. package/lib/features/editor-actions/BpmnEditorActions.js +0 -1
  37. package/lib/features/modeling/ElementFactory.js +11 -0
  38. package/lib/features/palette/dist/create.svg +1 -0
  39. package/lib/features/popup-menu/ReplaceMenuProvider.js +7 -2
  40. package/lib/features/popup-menu/index.js +6 -3
  41. package/lib/icons/Icons.js +11 -0
  42. package/lib/icons/resources/append.svg +3 -0
  43. package/lib/icons/resources/create.svg +3 -0
  44. package/package.json +20 -7
@@ -0,0 +1 @@
1
+ data:image/svg+xml,data%3Aimage%2Fsvg%2Bxml%2C%253Csvg%2520xmlns%253D%2522http%253A%252F%252Fwww.w3.org%252F2000%252Fsvg%2522%2520viewBox%253D%25220%25200%25201800%25201800%2522%253E%253Cpath%2520d%253D%2522M150%25201650h1500%2522%2520style%253D%2522stroke%253AcurrentColor%253Bstroke-width%253A100%253Bstroke-linecap%253Around%2522%252F%253E%253Crect%2520width%253D%2522600%2522%2520height%253D%25221300%2522%2520x%253D%2522150%2522%2520y%253D%2522350%2522%2520rx%253D%25221%2522%2520style%253D%2522fill%253Anone%253Bstroke%253AcurrentColor%253Bstroke-width%253A100%2522%252F%253E%253Crect%2520width%253D%2522600%2522%2520height%253D%2522800%2522%2520x%253D%25221050%2522%2520y%253D%2522850%2522%2520rx%253D%25221%2522%2520style%253D%2522fill%253AcurrentColor%253Bstroke%253AcurrentColor%253Bstroke-width%253A100%253Bopacity%253A.5%2522%252F%253E%253C%252Fsvg%253E
@@ -0,0 +1 @@
1
+ data:image/svg+xml,data%3Aimage%2Fsvg%2Bxml%2C%253Csvg%2520xmlns%253D%2522http%253A%252F%252Fwww.w3.org%252F2000%252Fsvg%2522%2520viewBox%253D%25220%25200%25201800%25201800%2522%253E%253Cpath%2520d%253D%2522M900%2520150v1500%2522%2520style%253D%2522stroke%253AcurrentColor%253Bstroke-width%253A100%253Bstroke-linecap%253Around%2522%252F%253E%253Crect%2520width%253D%25221300%2522%2520height%253D%2522600%2522%2520x%253D%2522250%2522%2520y%253D%2522150%2522%2520rx%253D%25221%2522%2520style%253D%2522fill%253Anone%253Bstroke%253AcurrentColor%253Bstroke-width%253A100%2522%252F%253E%253Crect%2520width%253D%2522800%2522%2520height%253D%2522600%2522%2520x%253D%2522500%2522%2520y%253D%25221050%2522%2520rx%253D%25221%2522%2520style%253D%2522fill%253AcurrentColor%253Bstroke%253AcurrentColor%253Bstroke-width%253A100%253Bopacity%253A.5%2522%252F%253E%253C%252Fsvg%253E
@@ -0,0 +1 @@
1
+ data:image/svg+xml,data%3Aimage%2Fsvg%2Bxml%2C%253Csvg%2520xmlns%253D%2522http%253A%252F%252Fwww.w3.org%252F2000%252Fsvg%2522%2520viewBox%253D%25220%25200%25201800%25201800%2522%253E%253Cpath%2520d%253D%2522M100%2520150v1500%2522%2520style%253D%2522stroke%253AcurrentColor%253Bstroke-width%253A100%253Bstroke-linecap%253Around%2522%252F%253E%253Crect%2520width%253D%25221300%2522%2520height%253D%2522600%2522%2520x%253D%2522100%2522%2520y%253D%2522150%2522%2520rx%253D%25221%2522%2520style%253D%2522fill%253Anone%253Bstroke%253AcurrentColor%253Bstroke-width%253A100%2522%252F%253E%253Crect%2520width%253D%2522800%2522%2520height%253D%2522600%2522%2520x%253D%2522100%2522%2520y%253D%25221050%2522%2520rx%253D%25221%2522%2520style%253D%2522fill%253AcurrentColor%253Bstroke%253AcurrentColor%253Bstroke-width%253A100%253Bopacity%253A.5%2522%252F%253E%253C%252Fsvg%253E
@@ -0,0 +1 @@
1
+ data:image/svg+xml,data%3Aimage%2Fsvg%2Bxml%2C%253Csvg%2520xmlns%253D%2522http%253A%252F%252Fwww.w3.org%252F2000%252Fsvg%2522%2520viewBox%253D%25220%25200%25201800%25201800%2522%253E%253Cpath%2520d%253D%2522M1650%2520150v1500%2522%2520style%253D%2522stroke%253AcurrentColor%253Bstroke-width%253A100%253Bstroke-linecap%253Around%2522%252F%253E%253Crect%2520width%253D%25221300%2522%2520height%253D%2522600%2522%2520x%253D%2522350%2522%2520y%253D%2522150%2522%2520rx%253D%25221%2522%2520style%253D%2522fill%253Anone%253Bstroke%253AcurrentColor%253Bstroke-width%253A100%2522%252F%253E%253Crect%2520width%253D%2522800%2522%2520height%253D%2522600%2522%2520x%253D%2522850%2522%2520y%253D%25221050%2522%2520rx%253D%25221%2522%2520style%253D%2522fill%253AcurrentColor%253Bstroke%253AcurrentColor%253Bstroke-width%253A100%253Bopacity%253A.5%2522%252F%253E%253C%252Fsvg%253E
@@ -0,0 +1 @@
1
+ data:image/svg+xml,data%3Aimage%2Fsvg%2Bxml%2C%253Csvg%2520xmlns%253D%2522http%253A%252F%252Fwww.w3.org%252F2000%252Fsvg%2522%2520viewBox%253D%25220%25200%25202000%25202000%2522%253E%253Cpath%2520d%253D%2522M200%2520150v1700%2522%2520style%253D%2522stroke%253AcurrentColor%253Bstroke-width%253A100%253Bstroke-linecap%253Around%2522%252F%253E%253Crect%2520width%253D%25221300%2522%2520height%253D%2522700%2522%2520x%253D%2522500%2522%2520y%253D%2522150%2522%2520rx%253D%25221%2522%2520style%253D%2522fill%253Anone%253Bstroke%253AcurrentColor%253Bstroke-width%253A100%2522%252F%253E%253Crect%2520width%253D%2522700%2522%2520height%253D%2522700%2522%2520x%253D%2522500%2522%2520y%253D%25221150%2522%2520rx%253D%25221%2522%2520style%253D%2522fill%253AcurrentColor%253Bstroke%253AcurrentColor%253Bstroke-width%253A100%253Bopacity%253A.5%2522%252F%253E%253C%252Fsvg%253E
@@ -0,0 +1 @@
1
+ data:image/svg+xml,data%3Aimage%2Fsvg%2Bxml%2C%253Csvg%2520xmlns%253D%2522http%253A%252F%252Fwww.w3.org%252F2000%252Fsvg%2522%2520viewBox%253D%25220%25200%25201800%25201800%2522%253E%253Cpath%2520d%253D%2522M150%2520150h1500%2522%2520style%253D%2522stroke%253AcurrentColor%253Bstroke-width%253A100%253Bstroke-linecap%253Around%2522%252F%253E%253Crect%2520width%253D%2522600%2522%2520height%253D%25221300%2522%2520x%253D%2522150%2522%2520y%253D%2522150%2522%2520rx%253D%25221%2522%2520style%253D%2522fill%253Anone%253Bstroke%253AcurrentColor%253Bstroke-width%253A100%2522%252F%253E%253Crect%2520width%253D%2522600%2522%2520height%253D%2522800%2522%2520x%253D%25221050%2522%2520y%253D%2522150%2522%2520rx%253D%25221%2522%2520style%253D%2522fill%253AcurrentColor%253Bstroke%253AcurrentColor%253Bstroke-width%253A100%253Bopacity%253A.5%2522%252F%253E%253C%252Fsvg%253E
@@ -0,0 +1 @@
1
+ data:image/svg+xml,data%3Aimage%2Fsvg%2Bxml%2C%253Csvg%2520xmlns%253D%2522http%253A%252F%252Fwww.w3.org%252F2000%252Fsvg%2522%2520viewBox%253D%25220%25200%25201800%25201800%2522%253E%253Cpath%2520d%253D%2522M150%2520900h1500%2522%2520style%253D%2522stroke%253AcurrentColor%253Bstroke-width%253A100%253Bstroke-linecap%253Around%2522%252F%253E%253Crect%2520width%253D%2522600%2522%2520height%253D%25221300%2522%2520x%253D%2522150%2522%2520y%253D%2522250%2522%2520rx%253D%25221%2522%2520style%253D%2522fill%253Anone%253Bstroke%253AcurrentColor%253Bstroke-width%253A100%2522%252F%253E%253Crect%2520width%253D%2522600%2522%2520height%253D%2522800%2522%2520x%253D%25221050%2522%2520y%253D%2522500%2522%2520rx%253D%25221%2522%2520style%253D%2522fill%253AcurrentColor%253Bstroke%253AcurrentColor%253Bstroke-width%253A100%253Bopacity%253A.5%2522%252F%253E%253C%252Fsvg%253E
@@ -173,7 +173,6 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) {
173
173
  return pos;
174
174
  }
175
175
 
176
-
177
176
  /**
178
177
  * Create an append action
179
178
  *
@@ -0,0 +1,77 @@
1
+ import {
2
+ assign
3
+ } from 'min-dash';
4
+
5
+ import {
6
+ appendIcon
7
+ } from '../../icons/Icons';
8
+
9
+ var LOW_PRIORITY = 900;
10
+
11
+ /**
12
+ * A provider for align elements context pad button
13
+ */
14
+ export default function AppendContextPadProvider(contextPad, popupMenu, translate, canvas) {
15
+ contextPad.registerProvider(LOW_PRIORITY, this);
16
+
17
+ this._contextPad = contextPad;
18
+ this._popupMenu = popupMenu;
19
+ this._translate = translate;
20
+ this._canvas = canvas;
21
+ }
22
+
23
+ AppendContextPadProvider.$inject = [
24
+ 'contextPad',
25
+ 'popupMenu',
26
+ 'translate',
27
+ 'canvas'
28
+ ];
29
+
30
+ AppendContextPadProvider.prototype.getContextPadEntries = function(element) {
31
+ const popupMenu = this._popupMenu;
32
+ const translate = this._translate;
33
+ const getAppendMenuPosition = this._getAppendMenuPosition.bind(this);
34
+
35
+ if (!popupMenu.isEmpty(element, 'bpmn-append')) {
36
+
37
+ // Replace menu entry
38
+ return {
39
+ 'append': {
40
+ group: 'model',
41
+ imageUrl: appendIcon,
42
+ title: translate('Append element'),
43
+ action: {
44
+ click: function(event, element) {
45
+
46
+ var position = assign(getAppendMenuPosition(element), {
47
+ cursor: { x: event.x, y: event.y }
48
+ });
49
+
50
+ popupMenu.open(element, 'bpmn-append', position, {
51
+ title: translate('Append element'),
52
+ width: 300,
53
+ search: true
54
+ });
55
+ }
56
+ }
57
+ }
58
+ };
59
+ }
60
+ };
61
+
62
+ AppendContextPadProvider.prototype._getAppendMenuPosition = function(element) {
63
+ const contextPad = this._contextPad;
64
+
65
+ const X_OFFSET = 5;
66
+
67
+ const pad = contextPad.getPad(element).html;
68
+
69
+ const padRect = pad.getBoundingClientRect();
70
+
71
+ const pos = {
72
+ x: padRect.right + X_OFFSET,
73
+ y: padRect.top
74
+ };
75
+
76
+ return pos;
77
+ };
@@ -0,0 +1,175 @@
1
+ import { isUndefined } from 'min-dash';
2
+ import { CREATE_OPTIONS } from './util/OptionsUtil';
3
+
4
+ /**
5
+ * This module is an append menu provider for the popup menu.
6
+ */
7
+ export default function AppendMenuProvider(
8
+ elementFactory,
9
+ popupMenu,
10
+ create,
11
+ autoPlace,
12
+ rules,
13
+ mouse
14
+ ) {
15
+ this._elementFactory = elementFactory;
16
+ this._popupMenu = popupMenu;
17
+ this._create = create;
18
+ this._autoPlace = autoPlace;
19
+ this._rules = rules;
20
+ this._create = create;
21
+ this._mouse = mouse;
22
+
23
+ this.register();
24
+ }
25
+
26
+ AppendMenuProvider.$inject = [
27
+ 'elementFactory',
28
+ 'popupMenu',
29
+ 'create',
30
+ 'autoPlace',
31
+ 'rules',
32
+ 'mouse'
33
+ ];
34
+
35
+ /**
36
+ * Register append menu provider in the popup menu
37
+ */
38
+ AppendMenuProvider.prototype.register = function() {
39
+ this._popupMenu.registerProvider('bpmn-append', this);
40
+ };
41
+
42
+ /**
43
+ * Get all entries from createOptions for the given element.
44
+ *
45
+ * @param {djs.model.Base} element
46
+ *
47
+ * @return {Array<Object>} a list of menu entry items
48
+ */
49
+ AppendMenuProvider.prototype.getPopupMenuEntries = function(element) {
50
+ const rules = this._rules;
51
+ const entries = {};
52
+
53
+ if (!rules.allowed('shape.append', { element: element })) {
54
+ return [];
55
+ }
56
+
57
+ // filter out elements with no incoming connections
58
+ const appendOptions = this._filterEntries(CREATE_OPTIONS);
59
+
60
+ // map options to menu entries
61
+ appendOptions.forEach(option => {
62
+ const {
63
+ actionName,
64
+ className,
65
+ label,
66
+ target,
67
+ description,
68
+ group,
69
+ search
70
+ } = option;
71
+
72
+ entries[`append-${actionName}`] = {
73
+ label,
74
+ className,
75
+ description,
76
+ group,
77
+ search,
78
+ action: this._createEntryAction(element, target)
79
+ };
80
+ });
81
+
82
+ return entries;
83
+ };
84
+
85
+ /**
86
+ * Filter out entries from the options.
87
+ *
88
+ * @param {Array<Object>} entries
89
+ *
90
+ * @return {Array<Object>} filtered entries
91
+ */
92
+ AppendMenuProvider.prototype._filterEntries = function(entries) {
93
+ return entries.filter(option => {
94
+
95
+ const target = option.target;
96
+ const {
97
+ type,
98
+ eventDefinitionType
99
+ } = target;
100
+
101
+ if ([
102
+ 'bpmn:StartEvent',
103
+ 'bpmn:Participant'
104
+ ].includes(type)) {
105
+ return false;
106
+ }
107
+
108
+ if (type === 'bpmn:BoundaryEvent' && isUndefined(eventDefinitionType)) {
109
+ return false;
110
+ }
111
+
112
+ return true;
113
+ });
114
+ };
115
+
116
+ /**
117
+ * Create an action for a given target.
118
+ *
119
+ * @param {djs.model.Base} element
120
+ * @param {Object} target
121
+ *
122
+ * @return {Object}
123
+ */
124
+ AppendMenuProvider.prototype._createEntryAction = function(element, target) {
125
+ const elementFactory = this._elementFactory;
126
+ const autoPlace = this._autoPlace;
127
+ const create = this._create;
128
+ const mouse = this._mouse;
129
+
130
+
131
+ const autoPlaceElement = () => {
132
+ const newElement = elementFactory.create('shape', target);
133
+ autoPlace.append(element, newElement);
134
+ };
135
+
136
+ const manualPlaceElement = (event) => {
137
+ const newElement = elementFactory.create('shape', target);
138
+
139
+ if (event instanceof KeyboardEvent) {
140
+ event = mouse.getLastMoveEvent();
141
+ }
142
+
143
+ return create.start(event, newElement);
144
+ };
145
+
146
+ return {
147
+ click: this._canAutoPlaceElement(target) ? autoPlaceElement : manualPlaceElement,
148
+ dragstart: manualPlaceElement
149
+ };
150
+ };
151
+
152
+ /**
153
+ * Check if the element should be auto placed.
154
+ *
155
+ * @param {Object} target
156
+ *
157
+ * @return {Boolean}
158
+ */
159
+ AppendMenuProvider.prototype._canAutoPlaceElement = (target) => {
160
+ const { type } = target;
161
+
162
+ if (type === 'bpmn:BoundaryEvent') {
163
+ return false;
164
+ }
165
+
166
+ if (type === 'bpmn:SubProcess' && target.triggeredByEvent) {
167
+ return false;
168
+ }
169
+
170
+ if (type === 'bpmn:IntermediateCatchEvent' && target.eventDefinitionType === 'bpmn:LinkEventDefinition') {
171
+ return false;
172
+ }
173
+
174
+ return true;
175
+ };
@@ -0,0 +1,83 @@
1
+ import {
2
+ find,
3
+ } from 'min-dash';
4
+
5
+ import inherits from 'inherits-browser';
6
+
7
+ import {
8
+ is,
9
+ isAny,
10
+ getBusinessObject
11
+ } from '../../util/ModelUtil';
12
+
13
+ import {
14
+ isLabel
15
+ } from '../../util/LabelUtil';
16
+
17
+ import RuleProvider from 'diagram-js/lib/features/rules/RuleProvider';
18
+
19
+
20
+ /**
21
+ * Append anything modeling rules
22
+ */
23
+ export default function AppendRules(eventBus) {
24
+ RuleProvider.call(this, eventBus);
25
+ }
26
+
27
+ inherits(AppendRules, RuleProvider);
28
+
29
+ AppendRules.$inject = [
30
+ 'eventBus'
31
+ ];
32
+
33
+ AppendRules.prototype.init = function() {
34
+ this.addRule('shape.append', function(context) {
35
+
36
+ var source = context.element;
37
+
38
+ const businessObject = getBusinessObject(source);
39
+
40
+ if (isLabel(source)) {
41
+ return false;
42
+ }
43
+
44
+ if (isAny(source, [
45
+ 'bpmn:EndEvent',
46
+ 'bpmn:Group',
47
+ 'bpmn:TextAnnotation',
48
+ 'bpmn:Lane',
49
+ 'bpmn:Participant',
50
+ 'bpmn:DataStoreReference',
51
+ 'bpmn:DataObjectReference'
52
+ ])) {
53
+ return false;
54
+ }
55
+
56
+ if (isConnection(source)) {
57
+ return false;
58
+ }
59
+
60
+ if (is(source, 'bpmn:IntermediateThrowEvent') && hasEventDefinition(source, 'bpmn:LinkEventDefinition')) {
61
+ return false;
62
+ }
63
+
64
+ if (is(source, 'bpmn:SubProcess') && businessObject.triggeredByEvent) {
65
+ return false;
66
+ }
67
+ });
68
+
69
+ };
70
+
71
+
72
+ // helpers //////////////
73
+ function hasEventDefinition(element, eventDefinition) {
74
+ var bo = getBusinessObject(element);
75
+
76
+ return !!find(bo.eventDefinitions || [], function(definition) {
77
+ return is(definition, eventDefinition);
78
+ });
79
+ }
80
+
81
+ function isConnection(element) {
82
+ return element.waypoints;
83
+ }
@@ -0,0 +1,51 @@
1
+ import { assign } from 'min-dash';
2
+
3
+ /**
4
+ * Registers and executes BPMN specific editor actions.
5
+ *
6
+ * @param {Injector} injector
7
+ */
8
+ export default function CreateAppendEditorActions(injector) {
9
+ this._injector = injector;
10
+
11
+ this.registerActions();
12
+ }
13
+
14
+ CreateAppendEditorActions.$inject = [
15
+ 'injector'
16
+ ];
17
+
18
+ /**
19
+ * Register actions.
20
+ *
21
+ * @param {Injector} injector
22
+ */
23
+ CreateAppendEditorActions.prototype.registerActions = function() {
24
+ var editorActions = this._injector.get('editorActions', false);
25
+ var selection = this._injector.get('selection', false);
26
+ var contextPad = this._injector.get('contextPad', false);
27
+ var palette = this._injector.get('palette', false);
28
+
29
+ const actions = {};
30
+
31
+ // append
32
+ if (selection && contextPad) {
33
+ assign(actions, {
34
+ 'appendElement': function(event) {
35
+ contextPad.triggerEntry('append', 'click', event);
36
+ } }
37
+ );
38
+ }
39
+
40
+ // create
41
+ if (palette) {
42
+ assign(actions, {
43
+ 'createElement': function(event) {
44
+ palette.triggerEntry('create', 'click', event);
45
+ } }
46
+ );
47
+ }
48
+
49
+ editorActions && editorActions.register(actions);
50
+
51
+ };
@@ -0,0 +1,97 @@
1
+ import inherits from 'inherits-browser';
2
+
3
+ import KeyboardBindings from 'diagram-js/lib/features/keyboard/KeyboardBindings';
4
+
5
+
6
+ /**
7
+ * BPMN 2.0 specific keyboard bindings.
8
+ *
9
+ * @param {Injector} injector
10
+ */
11
+ export default function CreateAppendKeyboardBindings(injector) {
12
+
13
+ this._injector = injector;
14
+ this._keyboard = this._injector.get('keyboard', false);
15
+ this._editorActions = this._injector.get('editorActions', false);
16
+ this._selection = this._injector.get('selection', false);
17
+
18
+ if (this._keyboard) {
19
+ this._injector.invoke(KeyboardBindings, this);
20
+ }
21
+ }
22
+
23
+ inherits(CreateAppendKeyboardBindings, KeyboardBindings);
24
+
25
+ CreateAppendKeyboardBindings.$inject = [
26
+ 'injector'
27
+ ];
28
+
29
+
30
+ /**
31
+ * Register available keyboard bindings.
32
+ *
33
+ * @param {Keyboard} keyboard
34
+ * @param {EditorActions} editorActions
35
+ */
36
+ CreateAppendKeyboardBindings.prototype.registerBindings = function() {
37
+
38
+ var keyboard = this._keyboard;
39
+ var editorActions = this._editorActions;
40
+ var selection = this._selection;
41
+
42
+ // inherit default bindings
43
+ KeyboardBindings.prototype.registerBindings.call(this, keyboard, editorActions);
44
+
45
+ /**
46
+ * Add keyboard binding if respective editor action
47
+ * is registered.
48
+ *
49
+ * @param {string} action name
50
+ * @param {Function} fn that implements the key binding
51
+ */
52
+ function addListener(action, fn) {
53
+
54
+ if (editorActions && editorActions.isRegistered(action)) {
55
+ keyboard && keyboard.addListener(fn);
56
+ }
57
+ }
58
+
59
+ // activate append/create element
60
+ // A
61
+ addListener('appendElement', function(context) {
62
+
63
+ var event = context.keyEvent;
64
+
65
+ if (keyboard && keyboard.hasModifier(event)) {
66
+ return;
67
+ }
68
+
69
+ if (keyboard && keyboard.isKey([ 'a', 'A' ], event)) {
70
+
71
+ if (selection && selection.get().length == 1) {
72
+ editorActions && editorActions.trigger('appendElement', event);
73
+ } else {
74
+ editorActions && editorActions.trigger('createElement', event);
75
+ }
76
+
77
+ return true;
78
+ }
79
+ });
80
+
81
+ // N
82
+ addListener('createElement', function(context) {
83
+
84
+ var event = context.keyEvent;
85
+
86
+ if (keyboard && keyboard.hasModifier(event)) {
87
+ return;
88
+ }
89
+
90
+ if (keyboard && keyboard.isKey([ 'n', 'N' ], event)) {
91
+ editorActions && editorActions.trigger('createElement', event);
92
+
93
+ return true;
94
+ }
95
+ });
96
+
97
+ };
@@ -0,0 +1,112 @@
1
+ import { CREATE_OPTIONS } from './util/OptionsUtil';
2
+
3
+ /**
4
+ * This module is a create menu provider for the popup menu.
5
+ */
6
+ export default function CreateMenuProvider(
7
+ elementFactory, popupMenu, create,
8
+ autoPlace, mouse, translate
9
+ ) {
10
+ this._elementFactory = elementFactory;
11
+ this._popupMenu = popupMenu;
12
+ this._create = create;
13
+ this._autoPlace = autoPlace;
14
+ this._mouse = mouse;
15
+ this._translate = translate;
16
+
17
+ this.register();
18
+ }
19
+
20
+ CreateMenuProvider.$inject = [
21
+ 'elementFactory',
22
+ 'popupMenu',
23
+ 'create',
24
+ 'autoPlace',
25
+ 'mouse',
26
+ 'translate'
27
+ ];
28
+
29
+ /**
30
+ * Register create menu provider in the popup menu
31
+ */
32
+ CreateMenuProvider.prototype.register = function() {
33
+ this._popupMenu.registerProvider('bpmn-create', this);
34
+ };
35
+
36
+ /**
37
+ * Get all entries
38
+ *
39
+ * @param {djs.model.Base} element
40
+ *
41
+ * @return {Array<Object>} a list of menu entry items
42
+ */
43
+ CreateMenuProvider.prototype.getPopupMenuEntries = function() {
44
+
45
+ const entries = {};
46
+
47
+ // map options to menu entries
48
+ CREATE_OPTIONS.forEach(option => {
49
+ const {
50
+ actionName,
51
+ className,
52
+ label,
53
+ target,
54
+ description,
55
+ group,
56
+ search
57
+ } = option;
58
+
59
+ const targetAction = this._createEntryAction(target);
60
+
61
+ entries[`create-${actionName}`] = {
62
+ label: label && this._translate(label),
63
+ className,
64
+ description,
65
+ group: group && {
66
+ ...group,
67
+ name: this._translate(group.name)
68
+ },
69
+ search,
70
+ action: {
71
+ click: targetAction,
72
+ dragstart: targetAction
73
+ }
74
+ };
75
+ });
76
+
77
+ return entries;
78
+ };
79
+
80
+ /**
81
+ * Create an action for a given target
82
+ *
83
+ * @param {Object} target
84
+ * @returns {Object}
85
+ */
86
+ CreateMenuProvider.prototype._createEntryAction = function(target) {
87
+
88
+ const create = this._create;
89
+ const mouse = this._mouse;
90
+ const popupMenu = this._popupMenu;
91
+ const elementFactory = this._elementFactory;
92
+
93
+ let newElement;
94
+
95
+ return (event) => {
96
+ popupMenu.close();
97
+
98
+ // create the new element
99
+ if (target.type === 'bpmn:Participant') {
100
+ newElement = elementFactory.createParticipantShape(target);
101
+ } else {
102
+ newElement = elementFactory.create('shape', target);
103
+ }
104
+
105
+ // use last mouse event if triggered via keyboard
106
+ if (event instanceof KeyboardEvent) {
107
+ event = mouse.getLastMoveEvent();
108
+ }
109
+
110
+ return create.start(event, newElement);
111
+ };
112
+ };