camunda-bpmn-js 4.3.1 → 4.3.3
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/README.md +5 -0
- package/dist/base-modeler.development.js +5 -1
- package/dist/base-modeler.production.min.js +2 -2
- package/dist/camunda-cloud-modeler.development.js +370 -360
- package/dist/camunda-cloud-modeler.production.min.js +3 -3
- package/dist/camunda-platform-modeler.development.js +359 -352
- package/dist/camunda-platform-modeler.production.min.js +2 -2
- package/package.json +4 -4
|
@@ -97451,6 +97451,7 @@
|
|
|
97451
97451
|
function FeelEditor({
|
|
97452
97452
|
extensions: editorExtensions = [],
|
|
97453
97453
|
container,
|
|
97454
|
+
contentAttributes = {},
|
|
97454
97455
|
tooltipContainer,
|
|
97455
97456
|
onChange = () => {},
|
|
97456
97457
|
onKeyDown = () => {},
|
|
@@ -97502,6 +97503,7 @@
|
|
|
97502
97503
|
bracketMatching(),
|
|
97503
97504
|
changeHandler,
|
|
97504
97505
|
closeBrackets(),
|
|
97506
|
+
EditorView.contentAttributes.of(contentAttributes),
|
|
97505
97507
|
indentOnInput(),
|
|
97506
97508
|
keyHandler,
|
|
97507
97509
|
keymap.of([
|
|
@@ -100011,6 +100013,7 @@
|
|
|
100011
100013
|
};
|
|
100012
100014
|
const CodeEditor = N((props, ref) => {
|
|
100013
100015
|
const {
|
|
100016
|
+
contentAttributes,
|
|
100014
100017
|
enableGutters,
|
|
100015
100018
|
value,
|
|
100016
100019
|
onInput,
|
|
@@ -100056,7 +100059,8 @@
|
|
|
100056
100059
|
tooltipContainer: tooltipContainer,
|
|
100057
100060
|
value: localValue,
|
|
100058
100061
|
variables: variables,
|
|
100059
|
-
extensions: [...(enableGutters ? [lineNumbers()] : []), EditorView.lineWrapping]
|
|
100062
|
+
extensions: [...(enableGutters ? [lineNumbers()] : []), EditorView.lineWrapping],
|
|
100063
|
+
contentAttributes
|
|
100060
100064
|
});
|
|
100061
100065
|
setEditor(editor);
|
|
100062
100066
|
return () => {
|
|
@@ -129747,9 +129751,9 @@
|
|
|
129747
129751
|
target[property] = [];
|
|
129748
129752
|
}
|
|
129749
129753
|
|
|
129750
|
-
const
|
|
129754
|
+
const propertiesToAdd = source[property].filter(o => !target[property].includes(o));
|
|
129751
129755
|
|
|
129752
|
-
target[property].push(...
|
|
129756
|
+
target[property].push(...propertiesToAdd);
|
|
129753
129757
|
}
|
|
129754
129758
|
|
|
129755
129759
|
function mergeEntries(target, source, visited = []) {
|
|
@@ -132216,99 +132220,102 @@
|
|
|
132216
132220
|
return true;
|
|
132217
132221
|
};
|
|
132218
132222
|
|
|
132219
|
-
const appendIcon = `<svg width="22" height="22" viewBox="0 0 5.82 5.82" xmlns="http://www.w3.org/2000/svg" fill="currentColor">
|
|
132220
|
-
<path d="M1.3 3.4c.3 0 .5-.2.5-.5s-.2-.4-.5-.4c-.2 0-.4.1-.4.4 0 .3.2.5.4.5zM3 3.4c.2 0 .4-.2.4-.5s-.2-.4-.4-.4c-.3 0-.5.1-.5.4 0 .3.2.5.5.5zM4.6 3.4c.2 0 .4-.2.4-.5s-.2-.4-.4-.4c-.3 0-.5.1-.5.4 0 .3.2.5.5.5z"/>
|
|
132221
|
-
</svg>`;
|
|
132222
|
-
const createIcon = `<svg width="46" height="46" viewBox="-2 -2 9.82 9.82" xmlns="http://www.w3.org/2000/svg" fill="currentColor">
|
|
132223
|
-
<path d="M1.3 3.4c.3 0 .5-.2.5-.5s-.2-.4-.5-.4c-.2 0-.4.1-.4.4 0 .3.2.5.4.5zM3 3.4c.2 0 .4-.2.4-.5s-.2-.4-.4-.4c-.3 0-.5.1-.5.4 0 .3.2.5.5.5zM4.6 3.4c.2 0 .4-.2.4-.5s-.2-.4-.4-.4c-.3 0-.5.1-.5.4 0 .3.2.5.5.5z"/>
|
|
132223
|
+
const appendIcon = `<svg width="22" height="22" viewBox="0 0 5.82 5.82" xmlns="http://www.w3.org/2000/svg" fill="currentColor">
|
|
132224
|
+
<path d="M1.3 3.4c.3 0 .5-.2.5-.5s-.2-.4-.5-.4c-.2 0-.4.1-.4.4 0 .3.2.5.4.5zM3 3.4c.2 0 .4-.2.4-.5s-.2-.4-.4-.4c-.3 0-.5.1-.5.4 0 .3.2.5.5.5zM4.6 3.4c.2 0 .4-.2.4-.5s-.2-.4-.4-.4c-.3 0-.5.1-.5.4 0 .3.2.5.5.5z"/>
|
|
132225
|
+
</svg>`;
|
|
132226
|
+
const createIcon = `<svg width="46" height="46" viewBox="-2 -2 9.82 9.82" xmlns="http://www.w3.org/2000/svg" fill="currentColor">
|
|
132227
|
+
<path d="M1.3 3.4c.3 0 .5-.2.5-.5s-.2-.4-.5-.4c-.2 0-.4.1-.4.4 0 .3.2.5.4.5zM3 3.4c.2 0 .4-.2.4-.5s-.2-.4-.4-.4c-.3 0-.5.1-.5.4 0 .3.2.5.5.5zM4.6 3.4c.2 0 .4-.2.4-.5s-.2-.4-.4-.4c-.3 0-.5.1-.5.4 0 .3.2.5.5.5z"/>
|
|
132224
132228
|
</svg>`;
|
|
132225
132229
|
|
|
132226
|
-
/**
|
|
132227
|
-
* A provider for append context pad button
|
|
132228
|
-
*/
|
|
132229
|
-
function AppendContextPadProvider(contextPad, popupMenu, translate, canvas) {
|
|
132230
|
-
|
|
132231
|
-
this._contextPad = contextPad;
|
|
132232
|
-
this._popupMenu = popupMenu;
|
|
132233
|
-
this._translate = translate;
|
|
132234
|
-
this._canvas = canvas;
|
|
132235
|
-
|
|
132236
|
-
|
|
132237
|
-
|
|
132238
|
-
|
|
132239
|
-
|
|
132240
|
-
|
|
132241
|
-
'
|
|
132242
|
-
'
|
|
132243
|
-
'
|
|
132244
|
-
|
|
132245
|
-
|
|
132246
|
-
|
|
132247
|
-
|
|
132248
|
-
|
|
132249
|
-
|
|
132250
|
-
|
|
132251
|
-
|
|
132252
|
-
|
|
132253
|
-
|
|
132254
|
-
|
|
132255
|
-
|
|
132256
|
-
*
|
|
132257
|
-
*
|
|
132258
|
-
|
|
132259
|
-
|
|
132260
|
-
|
|
132261
|
-
|
|
132262
|
-
const
|
|
132263
|
-
|
|
132264
|
-
|
|
132265
|
-
|
|
132266
|
-
|
|
132267
|
-
|
|
132268
|
-
|
|
132269
|
-
|
|
132270
|
-
|
|
132271
|
-
|
|
132272
|
-
|
|
132273
|
-
|
|
132274
|
-
|
|
132275
|
-
|
|
132276
|
-
|
|
132277
|
-
|
|
132278
|
-
|
|
132279
|
-
|
|
132280
|
-
|
|
132281
|
-
|
|
132282
|
-
|
|
132283
|
-
|
|
132284
|
-
|
|
132285
|
-
|
|
132286
|
-
|
|
132287
|
-
|
|
132288
|
-
|
|
132289
|
-
|
|
132290
|
-
|
|
132291
|
-
|
|
132292
|
-
|
|
132293
|
-
|
|
132294
|
-
|
|
132295
|
-
*
|
|
132296
|
-
|
|
132297
|
-
|
|
132298
|
-
|
|
132299
|
-
|
|
132300
|
-
|
|
132301
|
-
|
|
132302
|
-
|
|
132303
|
-
|
|
132304
|
-
|
|
132305
|
-
|
|
132306
|
-
|
|
132307
|
-
|
|
132308
|
-
|
|
132309
|
-
|
|
132310
|
-
|
|
132311
|
-
|
|
132230
|
+
/**
|
|
132231
|
+
* A provider for append context pad button
|
|
132232
|
+
*/
|
|
132233
|
+
function AppendContextPadProvider(contextPad, popupMenu, translate, canvas, rules) {
|
|
132234
|
+
|
|
132235
|
+
this._contextPad = contextPad;
|
|
132236
|
+
this._popupMenu = popupMenu;
|
|
132237
|
+
this._translate = translate;
|
|
132238
|
+
this._canvas = canvas;
|
|
132239
|
+
this._rules = rules;
|
|
132240
|
+
|
|
132241
|
+
this.register();
|
|
132242
|
+
}
|
|
132243
|
+
|
|
132244
|
+
AppendContextPadProvider.$inject = [
|
|
132245
|
+
'contextPad',
|
|
132246
|
+
'popupMenu',
|
|
132247
|
+
'translate',
|
|
132248
|
+
'canvas',
|
|
132249
|
+
'rules'
|
|
132250
|
+
];
|
|
132251
|
+
|
|
132252
|
+
/**
|
|
132253
|
+
* Register append button provider in the context pad
|
|
132254
|
+
*/
|
|
132255
|
+
AppendContextPadProvider.prototype.register = function() {
|
|
132256
|
+
this._contextPad.registerProvider(this);
|
|
132257
|
+
};
|
|
132258
|
+
|
|
132259
|
+
/**
|
|
132260
|
+
* Gets the append context pad entry
|
|
132261
|
+
*
|
|
132262
|
+
* @param {djs.model.Base} element
|
|
132263
|
+
* @returns {Object} entries
|
|
132264
|
+
*/
|
|
132265
|
+
AppendContextPadProvider.prototype.getContextPadEntries = function(element) {
|
|
132266
|
+
const popupMenu = this._popupMenu;
|
|
132267
|
+
const translate = this._translate;
|
|
132268
|
+
const rules = this._rules;
|
|
132269
|
+
const getAppendMenuPosition = this._getAppendMenuPosition.bind(this);
|
|
132270
|
+
|
|
132271
|
+
if (rules.allowed('shape.append', { element })) {
|
|
132272
|
+
|
|
132273
|
+
// append menu entry
|
|
132274
|
+
return {
|
|
132275
|
+
'append': {
|
|
132276
|
+
group: 'model',
|
|
132277
|
+
html: `<div class="entry">${appendIcon}</div>`,
|
|
132278
|
+
title: translate('Append element'),
|
|
132279
|
+
action: {
|
|
132280
|
+
click: function(event, element) {
|
|
132281
|
+
|
|
132282
|
+
const position = assign(getAppendMenuPosition(element), {
|
|
132283
|
+
cursor: { x: event.x, y: event.y }
|
|
132284
|
+
});
|
|
132285
|
+
|
|
132286
|
+
popupMenu.open(element, 'bpmn-append', position, {
|
|
132287
|
+
title: translate('Append element'),
|
|
132288
|
+
width: 300,
|
|
132289
|
+
search: true
|
|
132290
|
+
});
|
|
132291
|
+
}
|
|
132292
|
+
}
|
|
132293
|
+
}
|
|
132294
|
+
};
|
|
132295
|
+
}
|
|
132296
|
+
};
|
|
132297
|
+
|
|
132298
|
+
/**
|
|
132299
|
+
* Calculates the position for the append menu relatively to the element
|
|
132300
|
+
*
|
|
132301
|
+
* @param {djs.model.Base} element
|
|
132302
|
+
* @returns {Object}
|
|
132303
|
+
*/
|
|
132304
|
+
AppendContextPadProvider.prototype._getAppendMenuPosition = function(element) {
|
|
132305
|
+
const contextPad = this._contextPad;
|
|
132306
|
+
|
|
132307
|
+
const X_OFFSET = 5;
|
|
132308
|
+
|
|
132309
|
+
const pad = contextPad.getPad(element).html;
|
|
132310
|
+
|
|
132311
|
+
const padRect = pad.getBoundingClientRect();
|
|
132312
|
+
|
|
132313
|
+
const pos = {
|
|
132314
|
+
x: padRect.right + X_OFFSET,
|
|
132315
|
+
y: padRect.top
|
|
132316
|
+
};
|
|
132317
|
+
|
|
132318
|
+
return pos;
|
|
132312
132319
|
};
|
|
132313
132320
|
|
|
132314
132321
|
function e(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}));}
|
|
@@ -132921,87 +132928,87 @@
|
|
|
132921
132928
|
return el.querySelector(selector);
|
|
132922
132929
|
}
|
|
132923
132930
|
|
|
132924
|
-
const LOWER_PRIORITY = 900;
|
|
132925
|
-
|
|
132926
|
-
/**
|
|
132927
|
-
* A palette provider for the create elements menu.
|
|
132928
|
-
*/
|
|
132929
|
-
function CreatePaletteProvider(palette, translate, popupMenu, canvas, mouse) {
|
|
132930
|
-
|
|
132931
|
-
this._palette = palette;
|
|
132932
|
-
this._translate = translate;
|
|
132933
|
-
this._popupMenu = popupMenu;
|
|
132934
|
-
this._canvas = canvas;
|
|
132935
|
-
this._mouse = mouse;
|
|
132936
|
-
|
|
132937
|
-
this.register();
|
|
132938
|
-
}
|
|
132939
|
-
|
|
132940
|
-
CreatePaletteProvider.$inject = [
|
|
132941
|
-
'palette',
|
|
132942
|
-
'translate',
|
|
132943
|
-
'popupMenu',
|
|
132944
|
-
'canvas',
|
|
132945
|
-
'mouse'
|
|
132946
|
-
];
|
|
132947
|
-
|
|
132948
|
-
/**
|
|
132949
|
-
* Register create button provider in the palette
|
|
132950
|
-
*/
|
|
132951
|
-
CreatePaletteProvider.prototype.register = function() {
|
|
132952
|
-
this._palette.registerProvider(LOWER_PRIORITY, this);
|
|
132953
|
-
};
|
|
132954
|
-
|
|
132955
|
-
/**
|
|
132956
|
-
* Gets the palette create entry
|
|
132957
|
-
*
|
|
132958
|
-
* @param {djs.model.Base} element
|
|
132959
|
-
* @returns {Object}
|
|
132960
|
-
*/
|
|
132961
|
-
CreatePaletteProvider.prototype.getPaletteEntries = function(element) {
|
|
132962
|
-
const translate = this._translate,
|
|
132963
|
-
popupMenu = this._popupMenu,
|
|
132964
|
-
canvas = this._canvas,
|
|
132965
|
-
mouse = this._mouse;
|
|
132966
|
-
|
|
132967
|
-
const getPosition = (event) => {
|
|
132968
|
-
const X_OFFSET = 35;
|
|
132969
|
-
const Y_OFFSET = 10;
|
|
132970
|
-
|
|
132971
|
-
if (event instanceof KeyboardEvent) {
|
|
132972
|
-
event = mouse.getLastMoveEvent();
|
|
132973
|
-
return { x: event.x, y: event.y };
|
|
132974
|
-
}
|
|
132975
|
-
|
|
132976
|
-
const target = event && event.target || query('.djs-palette [data-action="create"]');
|
|
132977
|
-
const targetPosition = target.getBoundingClientRect();
|
|
132978
|
-
|
|
132979
|
-
return target && {
|
|
132980
|
-
x: targetPosition.left + targetPosition.width / 2 + X_OFFSET,
|
|
132981
|
-
y: targetPosition.top + targetPosition.height / 2 + Y_OFFSET
|
|
132982
|
-
};
|
|
132983
|
-
};
|
|
132984
|
-
|
|
132985
|
-
return {
|
|
132986
|
-
'create': {
|
|
132987
|
-
group: 'create',
|
|
132988
|
-
html: `<div class="entry"> ${createIcon}</div>`,
|
|
132989
|
-
title: translate('Create element'),
|
|
132990
|
-
action: {
|
|
132991
|
-
click: function(event) {
|
|
132992
|
-
const position = getPosition(event);
|
|
132993
|
-
|
|
132994
|
-
const element = canvas.getRootElement();
|
|
132995
|
-
|
|
132996
|
-
popupMenu.open(element, 'bpmn-create', position, {
|
|
132997
|
-
title: translate('Create element'),
|
|
132998
|
-
width: 300,
|
|
132999
|
-
search: true
|
|
133000
|
-
});
|
|
133001
|
-
}
|
|
133002
|
-
}
|
|
133003
|
-
}
|
|
133004
|
-
};
|
|
132931
|
+
const LOWER_PRIORITY = 900;
|
|
132932
|
+
|
|
132933
|
+
/**
|
|
132934
|
+
* A palette provider for the create elements menu.
|
|
132935
|
+
*/
|
|
132936
|
+
function CreatePaletteProvider(palette, translate, popupMenu, canvas, mouse) {
|
|
132937
|
+
|
|
132938
|
+
this._palette = palette;
|
|
132939
|
+
this._translate = translate;
|
|
132940
|
+
this._popupMenu = popupMenu;
|
|
132941
|
+
this._canvas = canvas;
|
|
132942
|
+
this._mouse = mouse;
|
|
132943
|
+
|
|
132944
|
+
this.register();
|
|
132945
|
+
}
|
|
132946
|
+
|
|
132947
|
+
CreatePaletteProvider.$inject = [
|
|
132948
|
+
'palette',
|
|
132949
|
+
'translate',
|
|
132950
|
+
'popupMenu',
|
|
132951
|
+
'canvas',
|
|
132952
|
+
'mouse'
|
|
132953
|
+
];
|
|
132954
|
+
|
|
132955
|
+
/**
|
|
132956
|
+
* Register create button provider in the palette
|
|
132957
|
+
*/
|
|
132958
|
+
CreatePaletteProvider.prototype.register = function() {
|
|
132959
|
+
this._palette.registerProvider(LOWER_PRIORITY, this);
|
|
132960
|
+
};
|
|
132961
|
+
|
|
132962
|
+
/**
|
|
132963
|
+
* Gets the palette create entry
|
|
132964
|
+
*
|
|
132965
|
+
* @param {djs.model.Base} element
|
|
132966
|
+
* @returns {Object}
|
|
132967
|
+
*/
|
|
132968
|
+
CreatePaletteProvider.prototype.getPaletteEntries = function(element) {
|
|
132969
|
+
const translate = this._translate,
|
|
132970
|
+
popupMenu = this._popupMenu,
|
|
132971
|
+
canvas = this._canvas,
|
|
132972
|
+
mouse = this._mouse;
|
|
132973
|
+
|
|
132974
|
+
const getPosition = (event) => {
|
|
132975
|
+
const X_OFFSET = 35;
|
|
132976
|
+
const Y_OFFSET = 10;
|
|
132977
|
+
|
|
132978
|
+
if (event instanceof KeyboardEvent) {
|
|
132979
|
+
event = mouse.getLastMoveEvent();
|
|
132980
|
+
return { x: event.x, y: event.y };
|
|
132981
|
+
}
|
|
132982
|
+
|
|
132983
|
+
const target = event && event.target || query('.djs-palette [data-action="create"]');
|
|
132984
|
+
const targetPosition = target.getBoundingClientRect();
|
|
132985
|
+
|
|
132986
|
+
return target && {
|
|
132987
|
+
x: targetPosition.left + targetPosition.width / 2 + X_OFFSET,
|
|
132988
|
+
y: targetPosition.top + targetPosition.height / 2 + Y_OFFSET
|
|
132989
|
+
};
|
|
132990
|
+
};
|
|
132991
|
+
|
|
132992
|
+
return {
|
|
132993
|
+
'create': {
|
|
132994
|
+
group: 'create',
|
|
132995
|
+
html: `<div class="entry"> ${createIcon}</div>`,
|
|
132996
|
+
title: translate('Create element'),
|
|
132997
|
+
action: {
|
|
132998
|
+
click: function(event) {
|
|
132999
|
+
const position = getPosition(event);
|
|
133000
|
+
|
|
133001
|
+
const element = canvas.getRootElement();
|
|
133002
|
+
|
|
133003
|
+
popupMenu.open(element, 'bpmn-create', position, {
|
|
133004
|
+
title: translate('Create element'),
|
|
133005
|
+
width: 300,
|
|
133006
|
+
search: true
|
|
133007
|
+
});
|
|
133008
|
+
}
|
|
133009
|
+
}
|
|
133010
|
+
}
|
|
133011
|
+
};
|
|
133005
133012
|
};
|
|
133006
133013
|
|
|
133007
133014
|
var CreateMenuModule = {
|
|
@@ -134444,185 +134451,185 @@
|
|
|
134444
134451
|
return ALL_OPTIONS;
|
|
134445
134452
|
}
|
|
134446
134453
|
|
|
134447
|
-
/**
|
|
134448
|
-
* A replace menu provider that allows to replace elements with
|
|
134449
|
-
* templates applied with the correspondent plain element.
|
|
134450
|
-
*/
|
|
134451
|
-
function RemoveTemplateReplaceProvider(popupMenu, translate, elementTemplates) {
|
|
134452
|
-
|
|
134453
|
-
this._popupMenu = popupMenu;
|
|
134454
|
-
this._translate = translate;
|
|
134455
|
-
this._elementTemplates = elementTemplates;
|
|
134456
|
-
|
|
134457
|
-
this.register();
|
|
134458
|
-
}
|
|
134459
|
-
|
|
134460
|
-
RemoveTemplateReplaceProvider.$inject = [
|
|
134461
|
-
'popupMenu',
|
|
134462
|
-
'translate',
|
|
134463
|
-
'elementTemplates'
|
|
134464
|
-
];
|
|
134465
|
-
|
|
134466
|
-
/**
|
|
134467
|
-
* Register replace menu provider in the popup menu
|
|
134468
|
-
*/
|
|
134469
|
-
RemoveTemplateReplaceProvider.prototype.register = function() {
|
|
134470
|
-
this._popupMenu.registerProvider('bpmn-replace', this);
|
|
134471
|
-
};
|
|
134472
|
-
|
|
134473
|
-
/**
|
|
134474
|
-
* Adds the element templates to the replace menu.
|
|
134475
|
-
* @param {djs.model.Base} element
|
|
134476
|
-
*
|
|
134477
|
-
* @returns {Object}
|
|
134478
|
-
*/
|
|
134479
|
-
RemoveTemplateReplaceProvider.prototype.getPopupMenuEntries = function(element) {
|
|
134480
|
-
|
|
134481
|
-
return (entries) => {
|
|
134482
|
-
|
|
134483
|
-
// convert our entries into something sortable
|
|
134484
|
-
let entrySet = Object.entries(entries);
|
|
134485
|
-
|
|
134486
|
-
if (this._elementTemplates && this._elementTemplates.get(element)) {
|
|
134487
|
-
|
|
134488
|
-
// add remove template option
|
|
134489
|
-
this.addPlainElementEntry(element, entrySet, this._translate, this._elementTemplates);
|
|
134490
|
-
}
|
|
134491
|
-
|
|
134492
|
-
// convert back to object
|
|
134493
|
-
return entrySet.reduce((entries, [ key, value ]) => {
|
|
134494
|
-
entries[key] = value;
|
|
134495
|
-
|
|
134496
|
-
return entries;
|
|
134497
|
-
}, {});
|
|
134498
|
-
};
|
|
134499
|
-
};
|
|
134500
|
-
|
|
134501
|
-
|
|
134502
|
-
/**
|
|
134503
|
-
* Adds the option to replace with plain element (remove template).
|
|
134504
|
-
*
|
|
134505
|
-
* @param {djs.model.Base} element
|
|
134506
|
-
* @param {Array<Object>} entries
|
|
134507
|
-
*/
|
|
134508
|
-
RemoveTemplateReplaceProvider.prototype.addPlainElementEntry = function(element, entries, translate, elementTemplates) {
|
|
134509
|
-
|
|
134510
|
-
const replaceOption = this.getPlainEntry(element, entries, translate, elementTemplates);
|
|
134511
|
-
|
|
134512
|
-
if (!replaceOption) {
|
|
134513
|
-
return;
|
|
134514
|
-
}
|
|
134515
|
-
|
|
134516
|
-
const [
|
|
134517
|
-
insertIndex,
|
|
134518
|
-
entry
|
|
134519
|
-
] = replaceOption;
|
|
134520
|
-
|
|
134521
|
-
// insert remove entry
|
|
134522
|
-
entries.splice(insertIndex, 0, [ entry.id, entry ]);
|
|
134523
|
-
};
|
|
134524
|
-
|
|
134525
|
-
/**
|
|
134526
|
-
* Returns the option to replace with plain element and the index where it should be inserted.
|
|
134527
|
-
*
|
|
134528
|
-
* @param {djs.model.Base} element
|
|
134529
|
-
* @param {Array<Object>} entries
|
|
134530
|
-
*
|
|
134531
|
-
* @returns {Array<Object, number>}
|
|
134532
|
-
*/
|
|
134533
|
-
RemoveTemplateReplaceProvider.prototype.getPlainEntry = function(element, entries, translate, elementTemplates) {
|
|
134534
|
-
|
|
134535
|
-
const {
|
|
134536
|
-
options,
|
|
134537
|
-
option,
|
|
134538
|
-
optionIndex
|
|
134539
|
-
} = findReplaceOptions(element) || { };
|
|
134540
|
-
|
|
134541
|
-
if (!options) {
|
|
134542
|
-
return null;
|
|
134543
|
-
}
|
|
134544
|
-
|
|
134545
|
-
const entry = {
|
|
134546
|
-
id: 'replace-remove-element-template',
|
|
134547
|
-
action: () => {
|
|
134548
|
-
elementTemplates.removeTemplate(element);
|
|
134549
|
-
},
|
|
134550
|
-
label: translate(option.label),
|
|
134551
|
-
className: option.className
|
|
134552
|
-
};
|
|
134553
|
-
|
|
134554
|
-
// insert after previous option, if it exists
|
|
134555
|
-
const previousIndex = getOptionIndex(options, optionIndex - 1, entries);
|
|
134556
|
-
|
|
134557
|
-
if (previousIndex) {
|
|
134558
|
-
return [
|
|
134559
|
-
previousIndex + 1,
|
|
134560
|
-
entry
|
|
134561
|
-
];
|
|
134562
|
-
}
|
|
134563
|
-
|
|
134564
|
-
// insert before next option, if it exists
|
|
134565
|
-
const nextIndex = getOptionIndex(options, optionIndex + 1, entries);
|
|
134566
|
-
|
|
134567
|
-
if (nextIndex) {
|
|
134568
|
-
return [
|
|
134569
|
-
nextIndex,
|
|
134570
|
-
entry
|
|
134571
|
-
];
|
|
134572
|
-
}
|
|
134573
|
-
|
|
134574
|
-
// fallback to insert at start
|
|
134575
|
-
return [
|
|
134576
|
-
0,
|
|
134577
|
-
entry
|
|
134578
|
-
];
|
|
134579
|
-
};
|
|
134580
|
-
|
|
134581
|
-
|
|
134582
|
-
/**
|
|
134583
|
-
* @param {ModdleElement} element
|
|
134584
|
-
*
|
|
134585
|
-
* @return { { options: Array<any>, option: any, optionIndex: number } | null }
|
|
134586
|
-
*/
|
|
134587
|
-
function findReplaceOptions(element) {
|
|
134588
|
-
|
|
134589
|
-
const isSameType = (element, option) => option.target && !isDifferentType(element)(option);
|
|
134590
|
-
|
|
134591
|
-
return getReplaceOptionGroups().reduce((result, options) => {
|
|
134592
|
-
|
|
134593
|
-
if (result) {
|
|
134594
|
-
return result;
|
|
134595
|
-
}
|
|
134596
|
-
|
|
134597
|
-
const optionIndex = options.findIndex(option => isSameType(element, option));
|
|
134598
|
-
|
|
134599
|
-
if (optionIndex === -1) {
|
|
134600
|
-
return;
|
|
134601
|
-
}
|
|
134602
|
-
|
|
134603
|
-
return {
|
|
134604
|
-
options,
|
|
134605
|
-
option: options[optionIndex],
|
|
134606
|
-
optionIndex
|
|
134607
|
-
};
|
|
134608
|
-
}, null);
|
|
134609
|
-
}
|
|
134610
|
-
|
|
134611
|
-
function getOptionIndex(options, index, entries) {
|
|
134612
|
-
const option = options[index];
|
|
134613
|
-
|
|
134614
|
-
if (!option) {
|
|
134615
|
-
return false;
|
|
134616
|
-
}
|
|
134617
|
-
|
|
134618
|
-
return entries.findIndex(
|
|
134619
|
-
([ key ]) => key === option.actionName
|
|
134620
|
-
);
|
|
134454
|
+
/**
|
|
134455
|
+
* A replace menu provider that allows to replace elements with
|
|
134456
|
+
* templates applied with the correspondent plain element.
|
|
134457
|
+
*/
|
|
134458
|
+
function RemoveTemplateReplaceProvider(popupMenu, translate, elementTemplates) {
|
|
134459
|
+
|
|
134460
|
+
this._popupMenu = popupMenu;
|
|
134461
|
+
this._translate = translate;
|
|
134462
|
+
this._elementTemplates = elementTemplates;
|
|
134463
|
+
|
|
134464
|
+
this.register();
|
|
134465
|
+
}
|
|
134466
|
+
|
|
134467
|
+
RemoveTemplateReplaceProvider.$inject = [
|
|
134468
|
+
'popupMenu',
|
|
134469
|
+
'translate',
|
|
134470
|
+
'elementTemplates'
|
|
134471
|
+
];
|
|
134472
|
+
|
|
134473
|
+
/**
|
|
134474
|
+
* Register replace menu provider in the popup menu
|
|
134475
|
+
*/
|
|
134476
|
+
RemoveTemplateReplaceProvider.prototype.register = function() {
|
|
134477
|
+
this._popupMenu.registerProvider('bpmn-replace', this);
|
|
134478
|
+
};
|
|
134479
|
+
|
|
134480
|
+
/**
|
|
134481
|
+
* Adds the element templates to the replace menu.
|
|
134482
|
+
* @param {djs.model.Base} element
|
|
134483
|
+
*
|
|
134484
|
+
* @returns {Object}
|
|
134485
|
+
*/
|
|
134486
|
+
RemoveTemplateReplaceProvider.prototype.getPopupMenuEntries = function(element) {
|
|
134487
|
+
|
|
134488
|
+
return (entries) => {
|
|
134489
|
+
|
|
134490
|
+
// convert our entries into something sortable
|
|
134491
|
+
let entrySet = Object.entries(entries);
|
|
134492
|
+
|
|
134493
|
+
if (this._elementTemplates && this._elementTemplates.get(element)) {
|
|
134494
|
+
|
|
134495
|
+
// add remove template option
|
|
134496
|
+
this.addPlainElementEntry(element, entrySet, this._translate, this._elementTemplates);
|
|
134497
|
+
}
|
|
134498
|
+
|
|
134499
|
+
// convert back to object
|
|
134500
|
+
return entrySet.reduce((entries, [ key, value ]) => {
|
|
134501
|
+
entries[key] = value;
|
|
134502
|
+
|
|
134503
|
+
return entries;
|
|
134504
|
+
}, {});
|
|
134505
|
+
};
|
|
134506
|
+
};
|
|
134507
|
+
|
|
134508
|
+
|
|
134509
|
+
/**
|
|
134510
|
+
* Adds the option to replace with plain element (remove template).
|
|
134511
|
+
*
|
|
134512
|
+
* @param {djs.model.Base} element
|
|
134513
|
+
* @param {Array<Object>} entries
|
|
134514
|
+
*/
|
|
134515
|
+
RemoveTemplateReplaceProvider.prototype.addPlainElementEntry = function(element, entries, translate, elementTemplates) {
|
|
134516
|
+
|
|
134517
|
+
const replaceOption = this.getPlainEntry(element, entries, translate, elementTemplates);
|
|
134518
|
+
|
|
134519
|
+
if (!replaceOption) {
|
|
134520
|
+
return;
|
|
134521
|
+
}
|
|
134522
|
+
|
|
134523
|
+
const [
|
|
134524
|
+
insertIndex,
|
|
134525
|
+
entry
|
|
134526
|
+
] = replaceOption;
|
|
134527
|
+
|
|
134528
|
+
// insert remove entry
|
|
134529
|
+
entries.splice(insertIndex, 0, [ entry.id, entry ]);
|
|
134530
|
+
};
|
|
134531
|
+
|
|
134532
|
+
/**
|
|
134533
|
+
* Returns the option to replace with plain element and the index where it should be inserted.
|
|
134534
|
+
*
|
|
134535
|
+
* @param {djs.model.Base} element
|
|
134536
|
+
* @param {Array<Object>} entries
|
|
134537
|
+
*
|
|
134538
|
+
* @returns {Array<Object, number>}
|
|
134539
|
+
*/
|
|
134540
|
+
RemoveTemplateReplaceProvider.prototype.getPlainEntry = function(element, entries, translate, elementTemplates) {
|
|
134541
|
+
|
|
134542
|
+
const {
|
|
134543
|
+
options,
|
|
134544
|
+
option,
|
|
134545
|
+
optionIndex
|
|
134546
|
+
} = findReplaceOptions(element) || { };
|
|
134547
|
+
|
|
134548
|
+
if (!options) {
|
|
134549
|
+
return null;
|
|
134550
|
+
}
|
|
134551
|
+
|
|
134552
|
+
const entry = {
|
|
134553
|
+
id: 'replace-remove-element-template',
|
|
134554
|
+
action: () => {
|
|
134555
|
+
elementTemplates.removeTemplate(element);
|
|
134556
|
+
},
|
|
134557
|
+
label: translate(option.label),
|
|
134558
|
+
className: option.className
|
|
134559
|
+
};
|
|
134560
|
+
|
|
134561
|
+
// insert after previous option, if it exists
|
|
134562
|
+
const previousIndex = getOptionIndex(options, optionIndex - 1, entries);
|
|
134563
|
+
|
|
134564
|
+
if (previousIndex) {
|
|
134565
|
+
return [
|
|
134566
|
+
previousIndex + 1,
|
|
134567
|
+
entry
|
|
134568
|
+
];
|
|
134569
|
+
}
|
|
134570
|
+
|
|
134571
|
+
// insert before next option, if it exists
|
|
134572
|
+
const nextIndex = getOptionIndex(options, optionIndex + 1, entries);
|
|
134573
|
+
|
|
134574
|
+
if (nextIndex) {
|
|
134575
|
+
return [
|
|
134576
|
+
nextIndex,
|
|
134577
|
+
entry
|
|
134578
|
+
];
|
|
134579
|
+
}
|
|
134580
|
+
|
|
134581
|
+
// fallback to insert at start
|
|
134582
|
+
return [
|
|
134583
|
+
0,
|
|
134584
|
+
entry
|
|
134585
|
+
];
|
|
134586
|
+
};
|
|
134587
|
+
|
|
134588
|
+
|
|
134589
|
+
/**
|
|
134590
|
+
* @param {ModdleElement} element
|
|
134591
|
+
*
|
|
134592
|
+
* @return { { options: Array<any>, option: any, optionIndex: number } | null }
|
|
134593
|
+
*/
|
|
134594
|
+
function findReplaceOptions(element) {
|
|
134595
|
+
|
|
134596
|
+
const isSameType = (element, option) => option.target && !isDifferentType(element)(option);
|
|
134597
|
+
|
|
134598
|
+
return getReplaceOptionGroups().reduce((result, options) => {
|
|
134599
|
+
|
|
134600
|
+
if (result) {
|
|
134601
|
+
return result;
|
|
134602
|
+
}
|
|
134603
|
+
|
|
134604
|
+
const optionIndex = options.findIndex(option => isSameType(element, option));
|
|
134605
|
+
|
|
134606
|
+
if (optionIndex === -1) {
|
|
134607
|
+
return;
|
|
134608
|
+
}
|
|
134609
|
+
|
|
134610
|
+
return {
|
|
134611
|
+
options,
|
|
134612
|
+
option: options[optionIndex],
|
|
134613
|
+
optionIndex
|
|
134614
|
+
};
|
|
134615
|
+
}, null);
|
|
134616
|
+
}
|
|
134617
|
+
|
|
134618
|
+
function getOptionIndex(options, index, entries) {
|
|
134619
|
+
const option = options[index];
|
|
134620
|
+
|
|
134621
|
+
if (!option) {
|
|
134622
|
+
return false;
|
|
134623
|
+
}
|
|
134624
|
+
|
|
134625
|
+
return entries.findIndex(
|
|
134626
|
+
([ key ]) => key === option.actionName
|
|
134627
|
+
);
|
|
134621
134628
|
}
|
|
134622
134629
|
|
|
134623
|
-
var RemoveTemplatesModule = {
|
|
134624
|
-
__init__: [ 'removeTemplateReplaceProvider' ],
|
|
134625
|
-
removeTemplateReplaceProvider: [ 'type', RemoveTemplateReplaceProvider ]
|
|
134630
|
+
var RemoveTemplatesModule = {
|
|
134631
|
+
__init__: [ 'removeTemplateReplaceProvider' ],
|
|
134632
|
+
removeTemplateReplaceProvider: [ 'type', RemoveTemplateReplaceProvider ]
|
|
134626
134633
|
};
|
|
134627
134634
|
|
|
134628
134635
|
/**
|