camunda-bpmn-js 0.24.0 → 1.0.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/assets/color-picker.css +10 -0
- package/dist/assets/diagram-js.css +26 -24
- package/dist/base-modeler.development.js +144 -48
- package/dist/base-modeler.production.min.js +39 -25
- package/dist/base-navigated-viewer.development.js +3 -0
- package/dist/base-navigated-viewer.production.min.js +1 -1
- package/dist/base-viewer.development.js +3 -0
- package/dist/base-viewer.production.min.js +1 -1
- package/dist/camunda-cloud-modeler.development.js +480 -144
- package/dist/camunda-cloud-modeler.production.min.js +50 -36
- package/dist/camunda-cloud-navigated-viewer.development.js +3 -0
- package/dist/camunda-cloud-navigated-viewer.production.min.js +1 -1
- package/dist/camunda-cloud-viewer.development.js +3 -0
- package/dist/camunda-cloud-viewer.production.min.js +1 -1
- package/dist/camunda-platform-modeler.development.js +534 -49
- package/dist/camunda-platform-modeler.production.min.js +41 -27
- package/dist/camunda-platform-navigated-viewer.development.js +3 -0
- package/dist/camunda-platform-navigated-viewer.production.min.js +1 -1
- package/dist/camunda-platform-viewer.development.js +3 -0
- package/dist/camunda-platform-viewer.production.min.js +1 -1
- package/lib/camunda-cloud/Modeler.js +5 -1
- package/lib/camunda-cloud/features/replace/ElementTemplatesReplaceProvider.js +4 -135
- package/lib/camunda-platform/Modeler.js +6 -1
- package/lib/shared/features/replace/UnlinkTemplateReplaceProvider.js +178 -0
- package/lib/shared/features/replace/index.js +8 -0
- package/lib/{camunda-cloud/features/replace → shared/features/replace/util}/ReplaceOptionsUtil.js +0 -0
- package/package.json +8 -6
|
@@ -22147,6 +22147,9 @@
|
|
|
22147
22147
|
|
|
22148
22148
|
};
|
|
22149
22149
|
|
|
22150
|
+
Overlays.prototype.isShown = function() {
|
|
22151
|
+
return this._overlayRoot.style.display !== 'none';
|
|
22152
|
+
};
|
|
22150
22153
|
|
|
22151
22154
|
Overlays.prototype.show = function() {
|
|
22152
22155
|
setVisible$1(this._overlayRoot);
|
|
@@ -28053,7 +28056,9 @@
|
|
|
28053
28056
|
|
|
28054
28057
|
|
|
28055
28058
|
/**
|
|
28056
|
-
* Trigger context pad
|
|
28059
|
+
* Trigger context pad via DOM event.
|
|
28060
|
+
*
|
|
28061
|
+
* The entry to trigger is determined by the target element.
|
|
28057
28062
|
*
|
|
28058
28063
|
* @param {string} action
|
|
28059
28064
|
* @param {Event} event
|
|
@@ -28061,10 +28066,7 @@
|
|
|
28061
28066
|
*/
|
|
28062
28067
|
ContextPad.prototype.trigger = function(action, event, autoActivate) {
|
|
28063
28068
|
|
|
28064
|
-
var
|
|
28065
|
-
entries = this._current.entries,
|
|
28066
|
-
entry,
|
|
28067
|
-
handler,
|
|
28069
|
+
var entry,
|
|
28068
28070
|
originalEvent,
|
|
28069
28071
|
button = event.delegateTarget || event.target;
|
|
28070
28072
|
|
|
@@ -28072,19 +28074,45 @@
|
|
|
28072
28074
|
return event.preventDefault();
|
|
28073
28075
|
}
|
|
28074
28076
|
|
|
28075
|
-
entry =
|
|
28076
|
-
handler = entry.action;
|
|
28077
|
-
|
|
28077
|
+
entry = attr$1(button, 'data-action');
|
|
28078
28078
|
originalEvent = event.originalEvent || event;
|
|
28079
28079
|
|
|
28080
|
+
return this.triggerEntry(entry, action, originalEvent, autoActivate);
|
|
28081
|
+
};
|
|
28082
|
+
|
|
28083
|
+
/**
|
|
28084
|
+
* Trigger context pad entry entry.
|
|
28085
|
+
*
|
|
28086
|
+
* @param {string} entryId
|
|
28087
|
+
* @param {string} action
|
|
28088
|
+
* @param {Event} event
|
|
28089
|
+
* @param {boolean} [autoActivate=false]
|
|
28090
|
+
*/
|
|
28091
|
+
ContextPad.prototype.triggerEntry = function(entryId, action, event, autoActivate) {
|
|
28092
|
+
|
|
28093
|
+
if (!this.isShown()) {
|
|
28094
|
+
return;
|
|
28095
|
+
}
|
|
28096
|
+
|
|
28097
|
+
var target = this._current.target,
|
|
28098
|
+
entries = this._current.entries;
|
|
28099
|
+
|
|
28100
|
+
var entry = entries[entryId];
|
|
28101
|
+
|
|
28102
|
+
if (!entry) {
|
|
28103
|
+
return;
|
|
28104
|
+
}
|
|
28105
|
+
|
|
28106
|
+
var handler = entry.action;
|
|
28107
|
+
|
|
28080
28108
|
// simple action (via callback function)
|
|
28081
28109
|
if (isFunction(handler)) {
|
|
28082
28110
|
if (action === 'click') {
|
|
28083
|
-
return handler(
|
|
28111
|
+
return handler(event, target, autoActivate);
|
|
28084
28112
|
}
|
|
28085
28113
|
} else {
|
|
28086
28114
|
if (handler[action]) {
|
|
28087
|
-
return handler[action](
|
|
28115
|
+
return handler[action](event, target, autoActivate);
|
|
28088
28116
|
}
|
|
28089
28117
|
}
|
|
28090
28118
|
|
|
@@ -28285,6 +28313,16 @@
|
|
|
28285
28313
|
};
|
|
28286
28314
|
|
|
28287
28315
|
|
|
28316
|
+
/**
|
|
28317
|
+
* Check if pad is open and not hidden.
|
|
28318
|
+
*
|
|
28319
|
+
* @return {boolean}
|
|
28320
|
+
*/
|
|
28321
|
+
ContextPad.prototype.isShown = function() {
|
|
28322
|
+
return this.isOpen() && this._overlays.isShown();
|
|
28323
|
+
};
|
|
28324
|
+
|
|
28325
|
+
|
|
28288
28326
|
/**
|
|
28289
28327
|
* Get contex pad position.
|
|
28290
28328
|
*
|
|
@@ -28364,14 +28402,11 @@
|
|
|
28364
28402
|
onClick
|
|
28365
28403
|
} = props;
|
|
28366
28404
|
|
|
28367
|
-
const createImage = imageUrl => {
|
|
28368
|
-
return m$2`<img src=${ imageUrl } class="djs-popup-entry-icon" />`;
|
|
28369
|
-
};
|
|
28370
|
-
|
|
28371
28405
|
return m$2`
|
|
28372
28406
|
<li
|
|
28373
28407
|
class=${ clsx('entry', { selected }) }
|
|
28374
28408
|
data-id=${ entry.id }
|
|
28409
|
+
title=${ entry.title || entry.label }
|
|
28375
28410
|
onClick=${ onClick }
|
|
28376
28411
|
onMouseEnter=${ onMouseEnter }
|
|
28377
28412
|
onMouseLeave=${ onMouseLeave }
|
|
@@ -28379,10 +28414,16 @@
|
|
|
28379
28414
|
<div class="djs-popup-entry-content">
|
|
28380
28415
|
<span
|
|
28381
28416
|
class=${ clsx('djs-popup-entry-name', entry.className) }
|
|
28382
|
-
title=${ entry.label || entry.name }
|
|
28383
28417
|
>
|
|
28384
|
-
${ entry.imageUrl ?
|
|
28385
|
-
|
|
28418
|
+
${ entry.imageUrl ? m$2`
|
|
28419
|
+
<img class="djs-popup-entry-icon" src=${ entry.imageUrl } />
|
|
28420
|
+
` : null }
|
|
28421
|
+
|
|
28422
|
+
${ entry.label ? m$2`
|
|
28423
|
+
<span class="djs-popup-label">
|
|
28424
|
+
${ entry.label }
|
|
28425
|
+
</span>
|
|
28426
|
+
` : null }
|
|
28386
28427
|
</span>
|
|
28387
28428
|
${ entry.description && m$2`
|
|
28388
28429
|
<span
|
|
@@ -28452,7 +28493,7 @@
|
|
|
28452
28493
|
<div class="djs-popup-results" ref=${ resultsRef }>
|
|
28453
28494
|
${ groups.map(group => m$2`
|
|
28454
28495
|
${ group.name && m$2`
|
|
28455
|
-
<div key=${ group.id } class="entry-header">
|
|
28496
|
+
<div key=${ group.id } class="entry-header" title=${ group.name }>
|
|
28456
28497
|
${ group.name }
|
|
28457
28498
|
</div>
|
|
28458
28499
|
` }
|
|
@@ -28538,7 +28579,9 @@
|
|
|
28538
28579
|
width,
|
|
28539
28580
|
scale,
|
|
28540
28581
|
search,
|
|
28541
|
-
entries: originalEntries
|
|
28582
|
+
entries: originalEntries,
|
|
28583
|
+
onOpened,
|
|
28584
|
+
onClosed
|
|
28542
28585
|
} = props;
|
|
28543
28586
|
|
|
28544
28587
|
const searchable = F$2(() => {
|
|
@@ -28556,6 +28599,14 @@
|
|
|
28556
28599
|
const [ entries, setEntries ] = p$3(originalEntries);
|
|
28557
28600
|
const [ selectedEntry, setSelectedEntry ] = p$3(entries[0]);
|
|
28558
28601
|
|
|
28602
|
+
h$2(() => {
|
|
28603
|
+
onOpened();
|
|
28604
|
+
|
|
28605
|
+
return () => {
|
|
28606
|
+
onClosed();
|
|
28607
|
+
};
|
|
28608
|
+
}, []);
|
|
28609
|
+
|
|
28559
28610
|
const updateEntries = T$3((newEntries) => {
|
|
28560
28611
|
|
|
28561
28612
|
// select first entry if non is selected
|
|
@@ -28578,10 +28629,8 @@
|
|
|
28578
28629
|
}
|
|
28579
28630
|
|
|
28580
28631
|
const search = [
|
|
28581
|
-
entry.name,
|
|
28582
28632
|
entry.description || '',
|
|
28583
|
-
entry.label || ''
|
|
28584
|
-
entry.id || ''
|
|
28633
|
+
entry.label || ''
|
|
28585
28634
|
]
|
|
28586
28635
|
.join('---')
|
|
28587
28636
|
.toLowerCase();
|
|
@@ -28680,18 +28729,23 @@
|
|
|
28680
28729
|
>
|
|
28681
28730
|
${ displayHeader && m$2`
|
|
28682
28731
|
<div class="djs-popup-header">
|
|
28683
|
-
<h3 class="djs-popup-title">${ title }</h3>
|
|
28732
|
+
<h3 class="djs-popup-title" title=${ title }>${ title }</h3>
|
|
28684
28733
|
${ headerEntries.map(entry => m$2`
|
|
28685
28734
|
<span
|
|
28686
28735
|
class=${ getHeaderClasses(entry, entry === selectedEntry) }
|
|
28687
28736
|
onClick=${ event => onSelect(event, entry) }
|
|
28688
|
-
title=${ entry.title }
|
|
28737
|
+
title=${ entry.title || entry.label }
|
|
28689
28738
|
data-id=${ entry.id }
|
|
28690
28739
|
onMouseEnter=${ () => setSelectedEntry(entry) }
|
|
28691
28740
|
onMouseLeave=${ () => setSelectedEntry(null) }
|
|
28692
28741
|
>
|
|
28693
|
-
${ entry.imageUrl ? m$2
|
|
28694
|
-
|
|
28742
|
+
${ entry.imageUrl ? m$2`
|
|
28743
|
+
<img class="djs-popup-entry-icon" src=${ entry.imageUrl } />
|
|
28744
|
+
` : null }
|
|
28745
|
+
|
|
28746
|
+
${ entry.label ? m$2`
|
|
28747
|
+
<span class="djs-popup-label">${ entry.label }</span>
|
|
28748
|
+
` : null }
|
|
28695
28749
|
</span>
|
|
28696
28750
|
`) }
|
|
28697
28751
|
</div>
|
|
@@ -28911,6 +28965,8 @@
|
|
|
28911
28965
|
entries=${ entriesArray }
|
|
28912
28966
|
headerEntries=${ headerEntriesArray }
|
|
28913
28967
|
scale=${ scale }
|
|
28968
|
+
onOpened=${ this._onOpened.bind(this) }
|
|
28969
|
+
onClosed=${ this._onClosed.bind(this) }
|
|
28914
28970
|
...${{ ...options }}
|
|
28915
28971
|
/>
|
|
28916
28972
|
`,
|
|
@@ -29014,6 +29070,14 @@
|
|
|
29014
29070
|
this._eventBus.fire(`popupMenu.${ event }`, payload);
|
|
29015
29071
|
};
|
|
29016
29072
|
|
|
29073
|
+
PopupMenu.prototype._onOpened = function() {
|
|
29074
|
+
this._emit('opened');
|
|
29075
|
+
};
|
|
29076
|
+
|
|
29077
|
+
PopupMenu.prototype._onClosed = function() {
|
|
29078
|
+
this._emit('closed');
|
|
29079
|
+
};
|
|
29080
|
+
|
|
29017
29081
|
PopupMenu.prototype._createContainer = function(config) {
|
|
29018
29082
|
|
|
29019
29083
|
let parent = config && config.parent || 'body';
|
|
@@ -29145,7 +29209,7 @@
|
|
|
29145
29209
|
*
|
|
29146
29210
|
* @example
|
|
29147
29211
|
* const popupMenuProvider = {
|
|
29148
|
-
* getPopupMenuEntries
|
|
29212
|
+
* getPopupMenuEntries(element) {
|
|
29149
29213
|
* return {
|
|
29150
29214
|
* 'entry-1': {
|
|
29151
29215
|
* label: 'My Entry',
|
|
@@ -29156,6 +29220,22 @@
|
|
|
29156
29220
|
* };
|
|
29157
29221
|
*
|
|
29158
29222
|
* popupMenu.registerProvider('myMenuID', popupMenuProvider);
|
|
29223
|
+
*
|
|
29224
|
+
* @example
|
|
29225
|
+
* const replacingPopupMenuProvider = {
|
|
29226
|
+
* getPopupMenuEntries(element) {
|
|
29227
|
+
* return (entries) => {
|
|
29228
|
+
* const {
|
|
29229
|
+
* someEntry,
|
|
29230
|
+
* ...remainingEntries
|
|
29231
|
+
* } = entries;
|
|
29232
|
+
*
|
|
29233
|
+
* return remainingEntries;
|
|
29234
|
+
* };
|
|
29235
|
+
* }
|
|
29236
|
+
* };
|
|
29237
|
+
*
|
|
29238
|
+
* popupMenu.registerProvider('myMenuID', replacingPopupMenuProvider);
|
|
29159
29239
|
*/
|
|
29160
29240
|
PopupMenu.prototype.registerProvider = function(id, priority, provider) {
|
|
29161
29241
|
if (!provider) {
|
|
@@ -36913,7 +36993,9 @@
|
|
|
36913
36993
|
);
|
|
36914
36994
|
|
|
36915
36995
|
var isTriggeredByEventEqual = (
|
|
36916
|
-
|
|
36996
|
+
|
|
36997
|
+
// coherse to <false>
|
|
36998
|
+
!!target.triggeredByEvent === !!businessObject.triggeredByEvent
|
|
36917
36999
|
);
|
|
36918
37000
|
|
|
36919
37001
|
var isExpandedEqual = (
|
|
@@ -37329,6 +37411,15 @@
|
|
|
37329
37411
|
];
|
|
37330
37412
|
|
|
37331
37413
|
var TRANSACTION = [
|
|
37414
|
+
{
|
|
37415
|
+
label: 'Transaction',
|
|
37416
|
+
actionName: 'replace-with-transaction',
|
|
37417
|
+
className: 'bpmn-icon-transaction',
|
|
37418
|
+
target: {
|
|
37419
|
+
type: 'bpmn:Transaction',
|
|
37420
|
+
isExpanded: true
|
|
37421
|
+
}
|
|
37422
|
+
},
|
|
37332
37423
|
{
|
|
37333
37424
|
label: 'Sub Process',
|
|
37334
37425
|
actionName: 'replace-with-subprocess',
|
|
@@ -37350,26 +37441,7 @@
|
|
|
37350
37441
|
}
|
|
37351
37442
|
];
|
|
37352
37443
|
|
|
37353
|
-
var EVENT_SUB_PROCESS =
|
|
37354
|
-
{
|
|
37355
|
-
label: 'Sub Process',
|
|
37356
|
-
actionName: 'replace-with-subprocess',
|
|
37357
|
-
className: 'bpmn-icon-subprocess-expanded',
|
|
37358
|
-
target: {
|
|
37359
|
-
type: 'bpmn:SubProcess',
|
|
37360
|
-
isExpanded: true
|
|
37361
|
-
}
|
|
37362
|
-
},
|
|
37363
|
-
{
|
|
37364
|
-
label: 'Transaction',
|
|
37365
|
-
actionName: 'replace-with-transaction',
|
|
37366
|
-
className: 'bpmn-icon-transaction',
|
|
37367
|
-
target: {
|
|
37368
|
-
type: 'bpmn:Transaction',
|
|
37369
|
-
isExpanded: true
|
|
37370
|
-
}
|
|
37371
|
-
}
|
|
37372
|
-
];
|
|
37444
|
+
var EVENT_SUB_PROCESS = TRANSACTION;
|
|
37373
37445
|
|
|
37374
37446
|
var TASK = [
|
|
37375
37447
|
{
|
|
@@ -39893,6 +39965,7 @@
|
|
|
39893
39965
|
var directEditing = injector.get('directEditing', false);
|
|
39894
39966
|
var searchPad = injector.get('searchPad', false);
|
|
39895
39967
|
var modeling = injector.get('modeling', false);
|
|
39968
|
+
var contextPad = injector.get('contextPad', false);
|
|
39896
39969
|
|
|
39897
39970
|
// (2) check components and register actions
|
|
39898
39971
|
|
|
@@ -40016,6 +40089,12 @@
|
|
|
40016
40089
|
});
|
|
40017
40090
|
}
|
|
40018
40091
|
|
|
40092
|
+
if (selection && contextPad) {
|
|
40093
|
+
this._registerAction('replaceElement', function(event) {
|
|
40094
|
+
contextPad.triggerEntry('replace', 'click', event);
|
|
40095
|
+
});
|
|
40096
|
+
}
|
|
40097
|
+
|
|
40019
40098
|
};
|
|
40020
40099
|
|
|
40021
40100
|
var EditorActionsModule = {
|
|
@@ -41134,6 +41213,23 @@
|
|
|
41134
41213
|
}
|
|
41135
41214
|
});
|
|
41136
41215
|
|
|
41216
|
+
// activate replace element
|
|
41217
|
+
// R
|
|
41218
|
+
addListener('replaceElement', function(context) {
|
|
41219
|
+
|
|
41220
|
+
var event = context.keyEvent;
|
|
41221
|
+
|
|
41222
|
+
if (keyboard.hasModifier(event)) {
|
|
41223
|
+
return;
|
|
41224
|
+
}
|
|
41225
|
+
|
|
41226
|
+
if (keyboard.isKey([ 'r', 'R' ], event)) {
|
|
41227
|
+
editorActions.trigger('replaceElement', event);
|
|
41228
|
+
|
|
41229
|
+
return true;
|
|
41230
|
+
}
|
|
41231
|
+
});
|
|
41232
|
+
|
|
41137
41233
|
};
|
|
41138
41234
|
|
|
41139
41235
|
var KeyboardModule = {
|
|
@@ -102042,6 +102138,124 @@
|
|
|
102042
102138
|
bpmnRules: [ 'type', CustomRules ]
|
|
102043
102139
|
};
|
|
102044
102140
|
|
|
102141
|
+
/**
|
|
102142
|
+
* A replace menu provider that allows to replace elements with
|
|
102143
|
+
* element templates.
|
|
102144
|
+
*/
|
|
102145
|
+
function ElementTemplatesReplaceProvider(popupMenu, translate, elementTemplates) {
|
|
102146
|
+
|
|
102147
|
+
this._popupMenu = popupMenu;
|
|
102148
|
+
this._translate = translate;
|
|
102149
|
+
this._elementTemplates = elementTemplates;
|
|
102150
|
+
|
|
102151
|
+
this.register();
|
|
102152
|
+
}
|
|
102153
|
+
|
|
102154
|
+
ElementTemplatesReplaceProvider.$inject = [
|
|
102155
|
+
'popupMenu',
|
|
102156
|
+
'translate',
|
|
102157
|
+
'elementTemplates'
|
|
102158
|
+
];
|
|
102159
|
+
|
|
102160
|
+
/**
|
|
102161
|
+
* Register replace menu provider in the popup menu
|
|
102162
|
+
*/
|
|
102163
|
+
ElementTemplatesReplaceProvider.prototype.register = function() {
|
|
102164
|
+
this._popupMenu.registerProvider('bpmn-replace', this);
|
|
102165
|
+
};
|
|
102166
|
+
|
|
102167
|
+
/**
|
|
102168
|
+
* Adds the element templates to the replace menu.
|
|
102169
|
+
* @param {djs.model.Base} element
|
|
102170
|
+
*
|
|
102171
|
+
* @returns {Object}
|
|
102172
|
+
*/
|
|
102173
|
+
ElementTemplatesReplaceProvider.prototype.getPopupMenuEntries = function(element) {
|
|
102174
|
+
|
|
102175
|
+
return (entries) => {
|
|
102176
|
+
|
|
102177
|
+
// convert our entries into something sortable
|
|
102178
|
+
let entrySet = Object.entries(entries);
|
|
102179
|
+
|
|
102180
|
+
// add template entries
|
|
102181
|
+
entrySet = [ ...entrySet, ...this.getTemplateEntries(element) ];
|
|
102182
|
+
|
|
102183
|
+
// convert back to object
|
|
102184
|
+
return entrySet.reduce((entries, [ key, value ]) => {
|
|
102185
|
+
entries[key] = value;
|
|
102186
|
+
|
|
102187
|
+
return entries;
|
|
102188
|
+
}, {});
|
|
102189
|
+
};
|
|
102190
|
+
};
|
|
102191
|
+
|
|
102192
|
+
/**
|
|
102193
|
+
* Get all element templates that can be used to replace the given element.
|
|
102194
|
+
*
|
|
102195
|
+
* @param {djs.model.Base} element
|
|
102196
|
+
*
|
|
102197
|
+
* @return {Array<Object>} a list of element templates as menu entries
|
|
102198
|
+
*/
|
|
102199
|
+
ElementTemplatesReplaceProvider.prototype.getTemplateEntries = function(element) {
|
|
102200
|
+
|
|
102201
|
+
const templates = this._getMatchingTemplates(element);
|
|
102202
|
+
return templates.map(template => {
|
|
102203
|
+
|
|
102204
|
+
const {
|
|
102205
|
+
icon = {},
|
|
102206
|
+
category,
|
|
102207
|
+
} = template;
|
|
102208
|
+
|
|
102209
|
+
const entryId = `replace.template-${template.id}`;
|
|
102210
|
+
|
|
102211
|
+
const defaultGroup = {
|
|
102212
|
+
id: 'templates',
|
|
102213
|
+
name: this._translate('Templates')
|
|
102214
|
+
};
|
|
102215
|
+
|
|
102216
|
+
return [ entryId, {
|
|
102217
|
+
label: template.name,
|
|
102218
|
+
description: template.description,
|
|
102219
|
+
documentationRef: template.documentationRef,
|
|
102220
|
+
imageUrl: icon.contents,
|
|
102221
|
+
group: category || defaultGroup,
|
|
102222
|
+
action: () => {
|
|
102223
|
+
this._elementTemplates.applyTemplate(element, template);
|
|
102224
|
+
}
|
|
102225
|
+
} ];
|
|
102226
|
+
});
|
|
102227
|
+
};
|
|
102228
|
+
|
|
102229
|
+
/**
|
|
102230
|
+
* Returns the templates that can the element can be replaced with.
|
|
102231
|
+
*
|
|
102232
|
+
* @param {djs.model.Base} element
|
|
102233
|
+
*
|
|
102234
|
+
* @return {Array<ElementTemplate>}
|
|
102235
|
+
*/
|
|
102236
|
+
ElementTemplatesReplaceProvider.prototype._getMatchingTemplates = function(element) {
|
|
102237
|
+
return this._elementTemplates.getLatest().filter(template => {
|
|
102238
|
+
return isAny(element, template.appliesTo) && !isTemplateApplied(element, template);
|
|
102239
|
+
});
|
|
102240
|
+
};
|
|
102241
|
+
|
|
102242
|
+
|
|
102243
|
+
// helpers ////////////
|
|
102244
|
+
function isTemplateApplied(element, template) {
|
|
102245
|
+
const businessObject = getBusinessObject$1(element);
|
|
102246
|
+
|
|
102247
|
+
if (businessObject) {
|
|
102248
|
+
return businessObject.get('zeebe:modelerTemplate') === template.id;
|
|
102249
|
+
}
|
|
102250
|
+
|
|
102251
|
+
return false;
|
|
102252
|
+
}
|
|
102253
|
+
|
|
102254
|
+
var replaceModule = {
|
|
102255
|
+
__init__: [ 'elementTemplatesProvider' ],
|
|
102256
|
+
elementTemplatesProvider: [ 'type', ElementTemplatesReplaceProvider ]
|
|
102257
|
+
};
|
|
102258
|
+
|
|
102045
102259
|
const ALL_OPTIONS = Object.values(replaceOptions);
|
|
102046
102260
|
|
|
102047
102261
|
function getReplaceOptionGroups() {
|
|
@@ -102050,23 +102264,18 @@
|
|
|
102050
102264
|
|
|
102051
102265
|
/**
|
|
102052
102266
|
* A replace menu provider that allows to replace elements with
|
|
102053
|
-
* element
|
|
102267
|
+
* templates applied with the correspondent plain element.
|
|
102054
102268
|
*/
|
|
102055
|
-
function
|
|
102269
|
+
function UnlinkTemplateReplaceProvider(popupMenu, translate, elementTemplates) {
|
|
102056
102270
|
|
|
102057
102271
|
this._popupMenu = popupMenu;
|
|
102058
102272
|
this._translate = translate;
|
|
102059
102273
|
this._elementTemplates = elementTemplates;
|
|
102060
102274
|
|
|
102061
|
-
|
|
102062
|
-
|
|
102063
|
-
if (enabled) {
|
|
102064
|
-
this.register();
|
|
102065
|
-
}
|
|
102275
|
+
this.register();
|
|
102066
102276
|
}
|
|
102067
102277
|
|
|
102068
|
-
|
|
102069
|
-
'config.elementTemplatesReplaceProvider',
|
|
102278
|
+
UnlinkTemplateReplaceProvider.$inject = [
|
|
102070
102279
|
'popupMenu',
|
|
102071
102280
|
'translate',
|
|
102072
102281
|
'elementTemplates'
|
|
@@ -102075,7 +102284,7 @@
|
|
|
102075
102284
|
/**
|
|
102076
102285
|
* Register replace menu provider in the popup menu
|
|
102077
102286
|
*/
|
|
102078
|
-
|
|
102287
|
+
UnlinkTemplateReplaceProvider.prototype.register = function() {
|
|
102079
102288
|
this._popupMenu.registerProvider('bpmn-replace', this);
|
|
102080
102289
|
};
|
|
102081
102290
|
|
|
@@ -102085,18 +102294,18 @@
|
|
|
102085
102294
|
*
|
|
102086
102295
|
* @returns {Object}
|
|
102087
102296
|
*/
|
|
102088
|
-
|
|
102297
|
+
UnlinkTemplateReplaceProvider.prototype.getPopupMenuEntries = function(element) {
|
|
102089
102298
|
|
|
102090
102299
|
return (entries) => {
|
|
102091
102300
|
|
|
102092
102301
|
// convert our entries into something sortable
|
|
102093
102302
|
let entrySet = Object.entries(entries);
|
|
102094
102303
|
|
|
102095
|
-
|
|
102096
|
-
this._addPlainElementEntry(element, entrySet);
|
|
102304
|
+
if (this._elementTemplates.get(element)) {
|
|
102097
102305
|
|
|
102098
|
-
|
|
102099
|
-
|
|
102306
|
+
// add unlink template option
|
|
102307
|
+
this.addPlainElementEntry(element, entrySet, this._translate, this._elementTemplates);
|
|
102308
|
+
}
|
|
102100
102309
|
|
|
102101
102310
|
// convert back to object
|
|
102102
102311
|
return entrySet.reduce((entries, [ key, value ]) => {
|
|
@@ -102107,15 +102316,20 @@
|
|
|
102107
102316
|
};
|
|
102108
102317
|
};
|
|
102109
102318
|
|
|
102319
|
+
|
|
102110
102320
|
/**
|
|
102111
102321
|
* Adds the option to replace with plain element (unlink template).
|
|
102112
102322
|
*
|
|
102113
102323
|
* @param {djs.model.Base} element
|
|
102114
102324
|
* @param {Array<Object>} entries
|
|
102115
102325
|
*/
|
|
102116
|
-
|
|
102326
|
+
UnlinkTemplateReplaceProvider.prototype.addPlainElementEntry = function(element, entries, translate, elementTemplates) {
|
|
102117
102327
|
|
|
102118
|
-
const replaceOption = this.
|
|
102328
|
+
const replaceOption = this.getPlainEntry(element, entries, translate, elementTemplates);
|
|
102329
|
+
|
|
102330
|
+
if (!replaceOption) {
|
|
102331
|
+
return;
|
|
102332
|
+
}
|
|
102119
102333
|
|
|
102120
102334
|
const [
|
|
102121
102335
|
insertIndex,
|
|
@@ -102134,7 +102348,7 @@
|
|
|
102134
102348
|
*
|
|
102135
102349
|
* @returns {Array<Object, number>}
|
|
102136
102350
|
*/
|
|
102137
|
-
|
|
102351
|
+
UnlinkTemplateReplaceProvider.prototype.getPlainEntry = function(element, entries, translate, elementTemplates) {
|
|
102138
102352
|
|
|
102139
102353
|
const {
|
|
102140
102354
|
options,
|
|
@@ -102143,15 +102357,15 @@
|
|
|
102143
102357
|
} = findReplaceOptions(element) || { };
|
|
102144
102358
|
|
|
102145
102359
|
if (!options) {
|
|
102146
|
-
return;
|
|
102360
|
+
return null;
|
|
102147
102361
|
}
|
|
102148
102362
|
|
|
102149
102363
|
const entry = {
|
|
102150
|
-
id:
|
|
102364
|
+
id: 'replace-unlink-element-template',
|
|
102151
102365
|
action: () => {
|
|
102152
|
-
|
|
102366
|
+
elementTemplates.applyTemplate(element, null);
|
|
102153
102367
|
},
|
|
102154
|
-
label:
|
|
102368
|
+
label: translate(option.label),
|
|
102155
102369
|
className: option.className
|
|
102156
102370
|
};
|
|
102157
102371
|
|
|
@@ -102182,66 +102396,34 @@
|
|
|
102182
102396
|
];
|
|
102183
102397
|
};
|
|
102184
102398
|
|
|
102399
|
+
|
|
102185
102400
|
/**
|
|
102186
|
-
*
|
|
102187
|
-
*
|
|
102188
|
-
* @param {djs.model.Base} element
|
|
102401
|
+
* @param {ModdleElement} element
|
|
102189
102402
|
*
|
|
102190
|
-
* @return {Array<
|
|
102403
|
+
* @return { { options: Array<any>, option: any, optionIndex: number } | null }
|
|
102191
102404
|
*/
|
|
102192
|
-
|
|
102193
|
-
|
|
102194
|
-
const templates = this._getMatchingTemplates(element);
|
|
102195
|
-
return templates.map(template => {
|
|
102196
|
-
|
|
102197
|
-
const {
|
|
102198
|
-
icon = {},
|
|
102199
|
-
category,
|
|
102200
|
-
} = template;
|
|
102201
|
-
|
|
102202
|
-
const entryId = `replace-with-template-${template.id}`;
|
|
102203
|
-
|
|
102204
|
-
const defaultGroup = {
|
|
102205
|
-
id: 'templates',
|
|
102206
|
-
name: this._translate('Templates')
|
|
102207
|
-
};
|
|
102405
|
+
function findReplaceOptions(element) {
|
|
102208
102406
|
|
|
102209
|
-
|
|
102210
|
-
name: template.name,
|
|
102211
|
-
description: template.description,
|
|
102212
|
-
documentationRef: template.documentationRef,
|
|
102213
|
-
imageUrl: icon.contents,
|
|
102214
|
-
group: category || defaultGroup,
|
|
102215
|
-
action: () => {
|
|
102216
|
-
this._elementTemplates.applyTemplate(element, template);
|
|
102217
|
-
}
|
|
102218
|
-
} ];
|
|
102219
|
-
});
|
|
102220
|
-
};
|
|
102407
|
+
const isSameType = (element, option) => option.target && !isDifferentType(element)(option);
|
|
102221
102408
|
|
|
102222
|
-
|
|
102223
|
-
* Returns the templates that can the element can be replaced with.
|
|
102224
|
-
*
|
|
102225
|
-
* @param {djs.model.Base} element
|
|
102226
|
-
*
|
|
102227
|
-
* @return {Array<ElementTemplate>}
|
|
102228
|
-
*/
|
|
102229
|
-
ElementTemplatesReplaceProvider.prototype._getMatchingTemplates = function(element) {
|
|
102230
|
-
return this._elementTemplates.getLatest().filter(template => {
|
|
102231
|
-
return isAny(element, template.appliesTo) && !isTemplateApplied(element, template);
|
|
102232
|
-
});
|
|
102233
|
-
};
|
|
102409
|
+
return getReplaceOptionGroups().reduce((result, options) => {
|
|
102234
102410
|
|
|
102411
|
+
if (result) {
|
|
102412
|
+
return result;
|
|
102413
|
+
}
|
|
102235
102414
|
|
|
102236
|
-
|
|
102237
|
-
function isTemplateApplied(element, template) {
|
|
102238
|
-
const businessObject = getBusinessObject$1(element);
|
|
102415
|
+
const optionIndex = options.findIndex(option => isSameType(element, option));
|
|
102239
102416
|
|
|
102240
|
-
|
|
102241
|
-
|
|
102242
|
-
|
|
102417
|
+
if (optionIndex === -1) {
|
|
102418
|
+
return;
|
|
102419
|
+
}
|
|
102243
102420
|
|
|
102244
|
-
|
|
102421
|
+
return {
|
|
102422
|
+
options,
|
|
102423
|
+
option: options[optionIndex],
|
|
102424
|
+
optionIndex
|
|
102425
|
+
};
|
|
102426
|
+
}, null);
|
|
102245
102427
|
}
|
|
102246
102428
|
|
|
102247
102429
|
function getOptionIndex(options, index, entries) {
|
|
@@ -102256,38 +102438,190 @@
|
|
|
102256
102438
|
);
|
|
102257
102439
|
}
|
|
102258
102440
|
|
|
102259
|
-
|
|
102260
|
-
|
|
102261
|
-
|
|
102262
|
-
|
|
102263
|
-
|
|
102264
|
-
|
|
102441
|
+
var sharedReplaceModule = {
|
|
102442
|
+
__init__: [
|
|
102443
|
+
'unlinkTemplateReplaceProvider'
|
|
102444
|
+
],
|
|
102445
|
+
unlinkTemplateReplaceProvider: [ 'type', UnlinkTemplateReplaceProvider ]
|
|
102446
|
+
};
|
|
102265
102447
|
|
|
102266
|
-
|
|
102448
|
+
const colorImageSvg = '<svg xmlns="http://www.w3.org/2000/svg" width="22" height="22"><path d="m12.5 5.5.3-.4 3.6-3.6c.5-.5 1.3-.5 1.7 0l1 1c.5.4.5 1.2 0 1.7l-3.6 3.6-.4.2v.2c0 1.4.6 2 1 2.7v.6l-1.7 1.6c-.2.2-.4.2-.6 0L7.3 6.6a.4.4 0 0 1 0-.6l.3-.3.5-.5.8-.8c.2-.2.4-.1.6 0 .9.5 1.5 1.1 3 1.1zm-9.9 6 4.2-4.2 6.3 6.3-4.2 4.2c-.3.3-.9.3-1.2 0l-.8-.8-.9-.8-2.3-2.9" /></svg>';
|
|
102449
|
+
|
|
102450
|
+
const colorImageUrl = 'data:image/svg+xml;utf8,' + encodeURIComponent(colorImageSvg);
|
|
102451
|
+
|
|
102452
|
+
|
|
102453
|
+
function ColorContextPadProvider(contextPad, popupMenu, canvas, translate) {
|
|
102454
|
+
|
|
102455
|
+
this._contextPad = contextPad;
|
|
102456
|
+
this._popupMenu = popupMenu;
|
|
102457
|
+
this._canvas = canvas;
|
|
102458
|
+
this._translate = translate;
|
|
102459
|
+
|
|
102460
|
+
contextPad.registerProvider(this);
|
|
102461
|
+
}
|
|
102462
|
+
|
|
102463
|
+
|
|
102464
|
+
ColorContextPadProvider.$inject = [
|
|
102465
|
+
'contextPad',
|
|
102466
|
+
'popupMenu',
|
|
102467
|
+
'canvas',
|
|
102468
|
+
'translate'
|
|
102469
|
+
];
|
|
102470
|
+
|
|
102471
|
+
|
|
102472
|
+
ColorContextPadProvider.prototype.getContextPadEntries = function(element) {
|
|
102473
|
+
return this._createPopupAction([ element ]);
|
|
102474
|
+
};
|
|
102475
|
+
|
|
102476
|
+
|
|
102477
|
+
ColorContextPadProvider.prototype.getMultiElementContextPadEntries = function(elements) {
|
|
102478
|
+
|
|
102479
|
+
return this._createPopupAction(elements);
|
|
102480
|
+
};
|
|
102481
|
+
|
|
102482
|
+
ColorContextPadProvider.prototype._createPopupAction = function(elements) {
|
|
102483
|
+
|
|
102484
|
+
const canvas = this._canvas;
|
|
102485
|
+
const translate = this._translate;
|
|
102486
|
+
const contextPad = this._contextPad;
|
|
102487
|
+
const popupMenu = this._popupMenu;
|
|
102488
|
+
|
|
102489
|
+
return {
|
|
102490
|
+
'set-color': {
|
|
102491
|
+
group: 'edit',
|
|
102492
|
+
className: 'bpmn-icon-color',
|
|
102493
|
+
title: translate('Set Color'),
|
|
102494
|
+
imageUrl: colorImageUrl,
|
|
102495
|
+
action: {
|
|
102496
|
+
click: (event, element) => {
|
|
102497
|
+
|
|
102498
|
+
// get start popup draw start position
|
|
102499
|
+
var position = {
|
|
102500
|
+
...getStartPosition(canvas, contextPad, elements),
|
|
102501
|
+
cursor: {
|
|
102502
|
+
x: event.x,
|
|
102503
|
+
y: event.y
|
|
102504
|
+
}
|
|
102505
|
+
};
|
|
102506
|
+
|
|
102507
|
+
// open new color-picker popup
|
|
102508
|
+
popupMenu.open(elements, 'color-picker', position);
|
|
102509
|
+
}
|
|
102510
|
+
}
|
|
102511
|
+
}
|
|
102512
|
+
};
|
|
102513
|
+
|
|
102514
|
+
};
|
|
102515
|
+
|
|
102516
|
+
|
|
102517
|
+
// helpers //////////////////////
|
|
102518
|
+
|
|
102519
|
+
function getStartPosition(canvas, contextPad, elements) {
|
|
102520
|
+
|
|
102521
|
+
var Y_OFFSET = 5;
|
|
102522
|
+
|
|
102523
|
+
var diagramContainer = canvas.getContainer(),
|
|
102524
|
+
pad = contextPad.getPad(elements).html;
|
|
102525
|
+
|
|
102526
|
+
var diagramRect = diagramContainer.getBoundingClientRect(),
|
|
102527
|
+
padRect = pad.getBoundingClientRect();
|
|
102528
|
+
|
|
102529
|
+
var top = padRect.top - diagramRect.top;
|
|
102530
|
+
var left = padRect.left - diagramRect.left;
|
|
102531
|
+
|
|
102532
|
+
var pos = {
|
|
102533
|
+
x: left,
|
|
102534
|
+
y: top + padRect.height + Y_OFFSET
|
|
102535
|
+
};
|
|
102536
|
+
|
|
102537
|
+
return pos;
|
|
102538
|
+
}
|
|
102267
102539
|
|
|
102268
|
-
|
|
102540
|
+
const COLORS = [ {
|
|
102541
|
+
label: 'Default',
|
|
102542
|
+
fill: undefined,
|
|
102543
|
+
stroke: undefined
|
|
102544
|
+
}, {
|
|
102545
|
+
label: 'Blue',
|
|
102546
|
+
fill: '#BBDEFB',
|
|
102547
|
+
stroke: '#0D4372'
|
|
102548
|
+
}, {
|
|
102549
|
+
label: 'Orange',
|
|
102550
|
+
fill: '#FFE0B2',
|
|
102551
|
+
stroke: '#6B3C00'
|
|
102552
|
+
}, {
|
|
102553
|
+
label: 'Green',
|
|
102554
|
+
fill: '#C8E6C9',
|
|
102555
|
+
stroke: '#205022'
|
|
102556
|
+
}, {
|
|
102557
|
+
label: 'Red',
|
|
102558
|
+
fill: '#FFCDD2',
|
|
102559
|
+
stroke: '#831311'
|
|
102560
|
+
}, {
|
|
102561
|
+
label: 'Purple',
|
|
102562
|
+
fill: '#E1BEE7',
|
|
102563
|
+
stroke: '#5B176D'
|
|
102564
|
+
} ];
|
|
102269
102565
|
|
|
102270
|
-
if (result) {
|
|
102271
|
-
return result;
|
|
102272
|
-
}
|
|
102273
102566
|
|
|
102274
|
-
|
|
102567
|
+
function ColorPopupProvider(config, popupMenu, modeling, translate) {
|
|
102568
|
+
this._popupMenu = popupMenu;
|
|
102569
|
+
this._modeling = modeling;
|
|
102570
|
+
this._translate = translate;
|
|
102571
|
+
|
|
102572
|
+
this._colors = config && config.colors || COLORS;
|
|
102573
|
+
|
|
102574
|
+
this._popupMenu.registerProvider('color-picker', this);
|
|
102575
|
+
}
|
|
102275
102576
|
|
|
102276
|
-
|
|
102277
|
-
|
|
102278
|
-
|
|
102577
|
+
|
|
102578
|
+
ColorPopupProvider.$inject = [
|
|
102579
|
+
'config.colorPicker',
|
|
102580
|
+
'popupMenu',
|
|
102581
|
+
'modeling',
|
|
102582
|
+
'translate'
|
|
102583
|
+
];
|
|
102584
|
+
|
|
102585
|
+
|
|
102586
|
+
ColorPopupProvider.prototype.getEntries = function(elements) {
|
|
102587
|
+
var self = this;
|
|
102588
|
+
|
|
102589
|
+
var colorIcon = domify$1(`
|
|
102590
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" height="100%">
|
|
102591
|
+
<rect rx="2" x="1" y="1" width="22" height="22" fill="var(--fill-color)" stroke="var(--stroke-color)"></rect>
|
|
102592
|
+
</svg>
|
|
102593
|
+
`);
|
|
102594
|
+
|
|
102595
|
+
var entries = this._colors.map(function(color) {
|
|
102596
|
+
|
|
102597
|
+
colorIcon.style.setProperty('--fill-color', color.fill || 'white');
|
|
102598
|
+
colorIcon.style.setProperty('--stroke-color', color.stroke || 'rgb(34, 36, 42)');
|
|
102279
102599
|
|
|
102280
102600
|
return {
|
|
102281
|
-
|
|
102282
|
-
|
|
102283
|
-
|
|
102601
|
+
title: self._translate(color.label),
|
|
102602
|
+
id: color.label.toLowerCase() + '-color',
|
|
102603
|
+
imageUrl: `data:image/svg+xml;utf8,${ encodeURIComponent(colorIcon.outerHTML) }`,
|
|
102604
|
+
action: createAction(self._modeling, elements, color)
|
|
102284
102605
|
};
|
|
102285
|
-
}
|
|
102606
|
+
});
|
|
102607
|
+
|
|
102608
|
+
return entries;
|
|
102609
|
+
};
|
|
102610
|
+
|
|
102611
|
+
|
|
102612
|
+
function createAction(modeling, element, color) {
|
|
102613
|
+
return function() {
|
|
102614
|
+
modeling.setColor(element, color);
|
|
102615
|
+
};
|
|
102286
102616
|
}
|
|
102287
102617
|
|
|
102288
|
-
var
|
|
102289
|
-
__init__: [
|
|
102290
|
-
|
|
102618
|
+
var colorPickerModule = {
|
|
102619
|
+
__init__: [
|
|
102620
|
+
'colorContextPadProvider',
|
|
102621
|
+
'colorPopupProvider'
|
|
102622
|
+
],
|
|
102623
|
+
colorContextPadProvider: [ 'type', ColorContextPadProvider ],
|
|
102624
|
+
colorPopupProvider: [ 'type', ColorPopupProvider ]
|
|
102291
102625
|
};
|
|
102292
102626
|
|
|
102293
102627
|
function getModelerTemplateIcon(element) {
|
|
@@ -102831,7 +103165,9 @@
|
|
|
102831
103165
|
rulesModule,
|
|
102832
103166
|
zeebePropertiesProviderModule,
|
|
102833
103167
|
index$1,
|
|
102834
|
-
replaceModule
|
|
103168
|
+
replaceModule,
|
|
103169
|
+
sharedReplaceModule,
|
|
103170
|
+
colorPickerModule
|
|
102835
103171
|
];
|
|
102836
103172
|
|
|
102837
103173
|
Modeler.prototype._modules = [].concat(
|