Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function createKeyEvent(key, attrs) {
var event = document.createEvent('Events') || new document.defaultView.CustomEvent('keyEvent');
// init and mark as bubbles / cancelable
event.initEvent('keydown', false, true);
var keyAttrs = isString(key) ? { key: key } : { keyCode: key, which: key };
return assign(event, keyAttrs, attrs || {});
}
return function(args, options) {
if (isString(args)) {
args = args.split(',');
} else
if (!isArray(args)) {
args = [ args ];
}
return args.map(function(arg) {
// assume element passed is shape already
if (isObject(arg)) {
return arg;
}
var e = elementRegistry.get(arg);
if (!e) {
if (options.optional) {
Overlays.prototype.get = function(search) {
if (isString(search)) {
search = { id: search };
}
if (isString(search.element)) {
search.element = this._elementRegistry.get(search.element);
}
if (search.element) {
var container = this._getOverlayContainer(search.element, true);
// return a list of overlays when searching by element (+type)
if (container) {
return search.type ? filter(container.overlays, matchPattern({ type: search.type })) : container.overlays.slice();
} else {
return [];
}
} else
if (search.type) {
return filter(this._overlays, matchPattern({ type: search.type }));
} else {
Tooltips.prototype._addTooltip = function(tooltip) {
var id = tooltip.id,
html = tooltip.html,
htmlContainer,
tooltipRoot = this._tooltipRoot;
// unwrap jquery (for those who need it)
if (html.get && html.constructor.prototype.jquery) {
html = html.get(0);
}
// create proper html elements from
// tooltip HTML strings
if (isString(html)) {
html = domify(html);
}
htmlContainer = domify('<div style="position: absolute" class="' + tooltipClass + '" data-tooltip-id="' + id + '">');
htmlContainer.appendChild(html);
if (tooltip.type) {
domClasses(htmlContainer).add('djs-tooltip-' + tooltip.type);
}
if (tooltip.className) {
domClasses(htmlContainer).add(tooltip.className);
}
tooltip.htmlContainer = htmlContainer;</div>
function position(event) {
var orientation;
if (isString(event)) {
orientation = event;
return function(event) {
var shape = event.shape;
var x = event.x,
y = event.y;
if (/top/.test(orientation)) {
y -= shape.height / 2;
}
if (/right/.test(orientation)) {
x += shape.width / 2;
}
const get = (element) => {
let actualElement;
if (isString(element)) {
actualElement = getBpmnJS().invoke(function(elementRegistry) {
return elementRegistry.get(element);
});
if (!actualElement) {
throw new Error('element #' + element + ' not found');
}
return actualElement;
}
return element;
};
ElementSerializer.prototype.addAttribute = function(name, value) {
var attrs = this.attrs;
if (isString(value)) {
value = escapeAttr(value);
}
attrs.push({ name: name, value: value });
};
function trim(string) {
if (isString(string)) {
return string.trim();
}
return string;
}
this.preExecute('shape.resize', function(event) {
var context = event.context,
hints = context.hints || {},
autoResize = hints.autoResize;
if (!autoResize) {
return;
}
var shape = context.shape,
newBounds = context.newBounds;
if (isString(autoResize)) {
context.newBounds = self.snapComplex(newBounds, autoResize);
} else {
context.newBounds = self.snapSimple(shape, newBounds);
}
});
}
components.onGetComponent('context-menu', (context = {}) => {
if (context.contextMenuType
&& context.contextMenuType === 'cell-description') {
const element = elementRegistry.get(context.id);
const description = getDescription(element);
if (isString(description)) {
return DescriptionEditor;
}
}
});