Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.start = function(event, elements, context) {
if (!isArray(elements)) {
elements = [ elements ];
}
var shape = find(elements, function(element) {
return !isConnection(element);
});
if (!shape) {
// at least one shape is required
return;
}
context = assign({
elements: elements,
hints: {},
CopyPaste.prototype.copy = function(elements) {
var allowed,
tree;
if (!isArray(elements)) {
elements = elements ? [ elements ] : [];
}
allowed = this._eventBus.fire('copyPaste.canCopyElements', {
elements: elements
});
if (allowed === false) {
tree = {};
} else {
tree = this.createTree(isArray(allowed) ? allowed : elements);
}
// we set an empty tree, selection of elements
// to copy was empty.
this._clipboard.set(tree);
this._eventBus.fire('copyPaste.elementsCopied', {
elements: elements,
tree: tree
});
return tree;
};
var position = assign(getReplaceMenuPosition(element), {
cursor: { x: event.x, y: event.y }
});
popupMenu.open(element, 'dmn-replace', position);
}
}
}
});
}
// delete element entry, only show if allowed by rules
var deleteAllowed = rules.allowed('elements.delete', { elements: [ element ] });
if (isArray(deleteAllowed)) {
// was the element returned as a deletion candidate?
deleteAllowed = deleteAllowed[0] === element;
}
if (deleteAllowed) {
assign(actions, {
'delete': {
group: 'edit',
className: 'dmn-icon-trash',
title: translate('Remove'),
action: {
click: removeElement
}
}
});
export function repairConnection(source, target, start, end, waypoints, hints) {
if (isArray(start)) {
waypoints = start;
hints = end;
start = getMid(source);
end = getMid(target);
}
hints = assign({ preferredLayouts: [] }, hints);
waypoints = waypoints || [];
var preferredLayouts = hints.preferredLayouts,
preferStraight = preferredLayouts.indexOf('straight') !== -1,
repairedWaypoints;
// just layout non-existing or simple connections
// attempt to render straight lines, if required
'connect': {
group: 'connect',
className: 'bpmn-icon-connection-multi',
title: translate('Connect using DataInputAssociation'),
action: {
click: startConnect,
dragstart: startConnect
}
}
});
}
// delete element entry, only show if allowed by rules
var deleteAllowed = rules.allowed('elements.delete', { elements: [ element ] });
if (isArray(deleteAllowed)) {
// was the element returned as a deletion candidate?
deleteAllowed = deleteAllowed[0] === element;
}
if (deleteAllowed) {
assign(actions, {
'delete': {
group: 'edit',
className: 'bpmn-icon-trash',
title: translate('Remove'),
action: {
click: removeElement
}
}
});
CommandStack.prototype._markDirty = function(elements) {
var execution = this._currentExecution;
if (!elements) {
return;
}
elements = isArray(elements) ? elements : [ elements ];
execution.dirty = execution.dirty.concat(elements);
};
function computeStyle(custom, traits, defaultStyles) {
if (!isArray(traits)) {
defaultStyles = traits;
traits = [];
}
return styles.style(traits || [], assign(defaultStyles, custom || {}));
}
copy(elements) {
if (!isArray(elements)) {
elements = [ elements ];
}
const data = {
elements: createDescriptor(elements)
};
this._eventBus.fire('copyCutPaste.copy', { data });
this._clipboard.set(data);
}
export function createDescriptor(element, cache, hooks) {
hooks = hooks || createHooks;
cache = cache || {};
if (isArray(element)) {
return createDescriptors0(element, cache, hooks);
} else {
return createDescriptor0(element, cache, hooks);
}
}
function snapTo(values, value) {
if (isArray(values)) {
var i = values.length;
while (i--) if (abs(values[i] - value) <= TOLERANCE) {
return values[i];
}
} else {
values = +values;
var rem = value % values;
if (rem < TOLERANCE) {
return value - rem;
}
if (rem > values - TOLERANCE) {
return value - rem + values;
}