camunda-bpmn-js 1.3.1 → 1.4.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.
- package/dist/base-modeler.development.js +48 -22
- package/dist/base-modeler.production.min.js +2 -2
- package/dist/base-navigated-viewer.development.js +20 -4
- package/dist/base-navigated-viewer.production.min.js +1 -1
- package/dist/base-viewer.development.js +20 -4
- package/dist/base-viewer.production.min.js +1 -1
- package/dist/camunda-cloud-modeler.development.js +331 -22
- package/dist/camunda-cloud-modeler.production.min.js +3 -3
- package/dist/camunda-cloud-navigated-viewer.development.js +20 -4
- package/dist/camunda-cloud-navigated-viewer.production.min.js +1 -1
- package/dist/camunda-cloud-viewer.development.js +20 -4
- package/dist/camunda-cloud-viewer.production.min.js +2 -2
- package/dist/camunda-platform-modeler.development.js +48 -22
- package/dist/camunda-platform-modeler.production.min.js +2 -2
- package/dist/camunda-platform-navigated-viewer.development.js +20 -4
- package/dist/camunda-platform-navigated-viewer.production.min.js +1 -1
- package/dist/camunda-platform-viewer.development.js +20 -4
- package/dist/camunda-platform-viewer.production.min.js +1 -1
- package/lib/camunda-cloud/Modeler.js +2 -0
- package/lib/camunda-cloud/features/create-append-anything/ElementTemplatesAppendProvider.js +162 -0
- package/lib/camunda-cloud/features/create-append-anything/ElementTemplatesCreateProvider.js +114 -0
- package/lib/camunda-cloud/features/create-append-anything/index.js +11 -0
- package/package.json +2 -2
|
@@ -16,6 +16,7 @@ import replaceModule from './features/replace';
|
|
|
16
16
|
import sharedReplaceModule from '../shared/features/replace';
|
|
17
17
|
import colorPickerModule from 'bpmn-js-color-picker';
|
|
18
18
|
import createAppendAnythingModule from 'bpmn-js/lib/features/create-append-anything';
|
|
19
|
+
import createAppendElementTemplatesModule from './features/create-append-anything';
|
|
19
20
|
|
|
20
21
|
import { commonModdleExtensions, commonModules } from './util/commonModules';
|
|
21
22
|
import { without } from 'min-dash';
|
|
@@ -60,6 +61,7 @@ Modeler.prototype._camundaCloudModules = [
|
|
|
60
61
|
rulesModule,
|
|
61
62
|
zeebePropertiesProviderModule,
|
|
62
63
|
cloudElementTemplatesPropertiesProvider,
|
|
64
|
+
createAppendElementTemplatesModule,
|
|
63
65
|
replaceModule,
|
|
64
66
|
sharedReplaceModule,
|
|
65
67
|
colorPickerModule
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { assign } from 'min-dash';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A popup menu provider that allows to append elements with
|
|
6
|
+
* element templates.
|
|
7
|
+
*/
|
|
8
|
+
export default function ElementTemplatesAppendProvider(
|
|
9
|
+
popupMenu, translate, elementTemplates,
|
|
10
|
+
autoPlace, create, mouse, rules) {
|
|
11
|
+
|
|
12
|
+
this._popupMenu = popupMenu;
|
|
13
|
+
this._translate = translate;
|
|
14
|
+
this._elementTemplates = elementTemplates;
|
|
15
|
+
this._autoPlace = autoPlace;
|
|
16
|
+
this._create = create;
|
|
17
|
+
this._mouse = mouse;
|
|
18
|
+
this._rules = rules;
|
|
19
|
+
|
|
20
|
+
this.register();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
ElementTemplatesAppendProvider.$inject = [
|
|
24
|
+
'popupMenu',
|
|
25
|
+
'translate',
|
|
26
|
+
'elementTemplates',
|
|
27
|
+
'autoPlace',
|
|
28
|
+
'create',
|
|
29
|
+
'move',
|
|
30
|
+
'rules'
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Register append menu provider in the popup menu
|
|
35
|
+
*/
|
|
36
|
+
ElementTemplatesAppendProvider.prototype.register = function() {
|
|
37
|
+
this._popupMenu.registerProvider('bpmn-append', this);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Adds the element templates to the append menu.
|
|
42
|
+
* @param {djs.model.Base} element
|
|
43
|
+
*
|
|
44
|
+
* @returns {Object}
|
|
45
|
+
*/
|
|
46
|
+
ElementTemplatesAppendProvider.prototype.getPopupMenuEntries = function(element) {
|
|
47
|
+
return (entries) => {
|
|
48
|
+
|
|
49
|
+
if (!this._rules.allowed('shape.append', { element: element })) {
|
|
50
|
+
return [];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const filteredTemplates = this._filterTemplates(this._elementTemplates.getLatest());
|
|
54
|
+
|
|
55
|
+
// add template entries
|
|
56
|
+
assign(entries, this.getTemplateEntries(element, filteredTemplates));
|
|
57
|
+
|
|
58
|
+
return entries;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Get all element templates.
|
|
64
|
+
*
|
|
65
|
+
* @param {djs.model.Base} element
|
|
66
|
+
*
|
|
67
|
+
* @return {Object} element templates as menu entries
|
|
68
|
+
*/
|
|
69
|
+
ElementTemplatesAppendProvider.prototype.getTemplateEntries = function(element, templates) {
|
|
70
|
+
|
|
71
|
+
const templateEntries = {};
|
|
72
|
+
|
|
73
|
+
templates.map(template => {
|
|
74
|
+
|
|
75
|
+
const {
|
|
76
|
+
icon = {},
|
|
77
|
+
category,
|
|
78
|
+
} = template;
|
|
79
|
+
|
|
80
|
+
const entryId = `append.template-${template.id}`;
|
|
81
|
+
|
|
82
|
+
const defaultGroup = {
|
|
83
|
+
id: 'templates',
|
|
84
|
+
name: this._translate('Templates')
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
templateEntries[entryId] = {
|
|
88
|
+
label: template.name,
|
|
89
|
+
description: template.description,
|
|
90
|
+
documentationRef: template.documentationRef,
|
|
91
|
+
imageUrl: icon.contents,
|
|
92
|
+
group: category || defaultGroup,
|
|
93
|
+
action: this._getEntryAction(element, template)
|
|
94
|
+
};
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
return templateEntries;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Filter out templates from the options.
|
|
102
|
+
*
|
|
103
|
+
* @param {Array<Object>} templates
|
|
104
|
+
*
|
|
105
|
+
* @returns {Array<Object>}
|
|
106
|
+
*/
|
|
107
|
+
ElementTemplatesAppendProvider.prototype._filterTemplates = function(templates) {
|
|
108
|
+
return templates.filter(template => {
|
|
109
|
+
const {
|
|
110
|
+
appliesTo,
|
|
111
|
+
elementType
|
|
112
|
+
} = template;
|
|
113
|
+
|
|
114
|
+
const type = (elementType && elementType.value) || appliesTo[0];
|
|
115
|
+
|
|
116
|
+
// elements that can not be appended
|
|
117
|
+
if ([
|
|
118
|
+
'bpmn:StartEvent',
|
|
119
|
+
'bpmn:Participant'
|
|
120
|
+
].includes(type)) {
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// sequence flow templates are supported
|
|
125
|
+
// but connections are not appendable
|
|
126
|
+
if ('bpmn:SequenceFlow' === type) {
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return true;
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Create an action for a given template.
|
|
136
|
+
*
|
|
137
|
+
* @param {djs.model.Base} element
|
|
138
|
+
* @param {Object} template
|
|
139
|
+
*
|
|
140
|
+
* @returns {Object}
|
|
141
|
+
*/
|
|
142
|
+
ElementTemplatesAppendProvider.prototype._getEntryAction = function(element, template) {
|
|
143
|
+
return {
|
|
144
|
+
|
|
145
|
+
click: () => {
|
|
146
|
+
const newElement = this._elementTemplates.createElement(template);
|
|
147
|
+
this._autoPlace.append(element, newElement);
|
|
148
|
+
},
|
|
149
|
+
|
|
150
|
+
dragstart: (event) => {
|
|
151
|
+
const newElement = this._elementTemplates.createElement(template);
|
|
152
|
+
|
|
153
|
+
if (event instanceof KeyboardEvent) {
|
|
154
|
+
event = this._mouse.getLastMoveEvent();
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
this._create.start(event, newElement, {
|
|
158
|
+
source: element
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
};
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { assign } from 'min-dash';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A popup menu provider that allows to create elements with
|
|
5
|
+
* element templates.
|
|
6
|
+
*/
|
|
7
|
+
export default function ElementTemplatesCreateProvider(
|
|
8
|
+
popupMenu, translate, elementTemplates,
|
|
9
|
+
mouse, create) {
|
|
10
|
+
|
|
11
|
+
this._popupMenu = popupMenu;
|
|
12
|
+
this._translate = translate;
|
|
13
|
+
this._elementTemplates = elementTemplates;
|
|
14
|
+
this._mouse = mouse;
|
|
15
|
+
this._create = create;
|
|
16
|
+
|
|
17
|
+
this.register();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
ElementTemplatesCreateProvider.$inject = [
|
|
21
|
+
'popupMenu',
|
|
22
|
+
'translate',
|
|
23
|
+
'elementTemplates',
|
|
24
|
+
'mouse',
|
|
25
|
+
'create'
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Register create menu provider in the popup menu
|
|
30
|
+
*/
|
|
31
|
+
ElementTemplatesCreateProvider.prototype.register = function() {
|
|
32
|
+
this._popupMenu.registerProvider('bpmn-create', this);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Adds the element templates to the create menu.
|
|
37
|
+
* @param {djs.model.Base} element
|
|
38
|
+
*
|
|
39
|
+
* @returns {Object}
|
|
40
|
+
*/
|
|
41
|
+
ElementTemplatesCreateProvider.prototype.getPopupMenuEntries = function(element) {
|
|
42
|
+
return (entries) => {
|
|
43
|
+
|
|
44
|
+
// add template entries
|
|
45
|
+
assign(entries, this.getTemplateEntries(element));
|
|
46
|
+
|
|
47
|
+
return entries;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Get all element templates.
|
|
53
|
+
*
|
|
54
|
+
* @param {djs.model.Base} element
|
|
55
|
+
*
|
|
56
|
+
* @return {Array<Object>} a list of element templates as menu entries
|
|
57
|
+
*/
|
|
58
|
+
ElementTemplatesCreateProvider.prototype.getTemplateEntries = function() {
|
|
59
|
+
|
|
60
|
+
const templates = this._elementTemplates.getLatest();
|
|
61
|
+
const templateEntries = {};
|
|
62
|
+
|
|
63
|
+
templates.map(template => {
|
|
64
|
+
|
|
65
|
+
const {
|
|
66
|
+
icon = {},
|
|
67
|
+
category,
|
|
68
|
+
} = template;
|
|
69
|
+
|
|
70
|
+
const entryId = `create.template-${template.id}`;
|
|
71
|
+
|
|
72
|
+
const defaultGroup = {
|
|
73
|
+
id: 'templates',
|
|
74
|
+
name: this._translate('Templates')
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
templateEntries[entryId] = {
|
|
78
|
+
label: template.name,
|
|
79
|
+
description: template.description,
|
|
80
|
+
documentationRef: template.documentationRef,
|
|
81
|
+
imageUrl: icon.contents,
|
|
82
|
+
group: category || defaultGroup,
|
|
83
|
+
action: {
|
|
84
|
+
click: this._getEntryAction(template),
|
|
85
|
+
dragstart: this._getEntryAction(template)
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
return templateEntries;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
ElementTemplatesCreateProvider.prototype._getEntryAction = function(template) {
|
|
95
|
+
const create = this._create;
|
|
96
|
+
const popupMenu = this._popupMenu;
|
|
97
|
+
const elementTemplates = this._elementTemplates;
|
|
98
|
+
const mouse = this._mouse;
|
|
99
|
+
|
|
100
|
+
return (event) => {
|
|
101
|
+
|
|
102
|
+
popupMenu.close();
|
|
103
|
+
|
|
104
|
+
// create the new element
|
|
105
|
+
let newElement = elementTemplates.createElement(template);
|
|
106
|
+
|
|
107
|
+
// use last mouse event if triggered via keyboard
|
|
108
|
+
if (event instanceof KeyboardEvent) {
|
|
109
|
+
event = mouse.getLastMoveEvent();
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return create.start(event, newElement);
|
|
113
|
+
};
|
|
114
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import ElementTemplatesAppendProvider from './ElementTemplatesAppendProvider';
|
|
2
|
+
import ElementTemplatesCreateProvider from './ElementTemplatesCreateProvider';
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
__init__: [
|
|
6
|
+
'elementTemplatesAppendProvider',
|
|
7
|
+
'elementTemplatesCreateProvider'
|
|
8
|
+
],
|
|
9
|
+
elementTemplatesAppendProvider: [ 'type', ElementTemplatesAppendProvider ],
|
|
10
|
+
elementTemplatesCreateProvider: [ 'type', ElementTemplatesCreateProvider ]
|
|
11
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "camunda-bpmn-js",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "Embeddable Camunda modeling distributions based on bpmn-js",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@bpmn-io/align-to-origin": "^0.7.0",
|
|
52
52
|
"@bpmn-io/element-templates-icons-renderer": "^0.3.0",
|
|
53
|
-
"bpmn-js": "^11.
|
|
53
|
+
"bpmn-js": "^11.4.0",
|
|
54
54
|
"bpmn-js-color-picker": "^0.5.0",
|
|
55
55
|
"bpmn-js-executable-fix": "^0.2.0",
|
|
56
56
|
"camunda-bpmn-js-behaviors": "^0.4.0",
|