update
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import {
|
||||
isString,
|
||||
assign
|
||||
} from 'min-dash';
|
||||
|
||||
/**
|
||||
* Create a fake key event for testing purposes.
|
||||
*
|
||||
* @param {String|Number} key the key or keyCode/charCode
|
||||
* @param {Object} [attrs]
|
||||
*
|
||||
* @return {Event}
|
||||
*/
|
||||
export 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 || {});
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
import {
|
||||
assign
|
||||
} from 'min-dash';
|
||||
|
||||
import {
|
||||
getBpmnJS
|
||||
} from 'test/TestHelper';
|
||||
|
||||
|
||||
/**
|
||||
* Create an event with global coordinates
|
||||
* computed based on the loaded diagrams canvas position and the
|
||||
* specified canvas local coordinates.
|
||||
*
|
||||
* @param {Point} point of the event local the canvas (closure)
|
||||
* @param {Object} data
|
||||
*
|
||||
* @return {Event} event, scoped to the given canvas
|
||||
*/
|
||||
export function createCanvasEvent(position, data) {
|
||||
|
||||
return getBpmnJS().invoke(function(canvas) {
|
||||
|
||||
var target = canvas._svg;
|
||||
|
||||
var clientRect = canvas._container.getBoundingClientRect();
|
||||
|
||||
var absolutePosition = {
|
||||
x: position.x + clientRect.left,
|
||||
y: position.y + clientRect.top
|
||||
};
|
||||
|
||||
return createEvent(target, absolutePosition, data);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
export function createEvent(target, position, data) {
|
||||
|
||||
return getBpmnJS().invoke(function(eventBus) {
|
||||
data = assign({
|
||||
target: target,
|
||||
x: position.x,
|
||||
y: position.y,
|
||||
clientX: position.x,
|
||||
clientY: position.y,
|
||||
offsetX: position.x,
|
||||
offsetY: position.y
|
||||
}, data || {});
|
||||
|
||||
return eventBus.createEvent(data);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import inherits from 'inherits';
|
||||
|
||||
import RuleProvider from 'diagram-js/lib/features/rules/RuleProvider';
|
||||
|
||||
|
||||
export default function CustomRules(eventBus) {
|
||||
RuleProvider.call(this, eventBus);
|
||||
}
|
||||
|
||||
CustomRules.$inject = [ 'eventBus' ];
|
||||
|
||||
inherits(CustomRules, RuleProvider);
|
||||
|
||||
CustomRules.prototype.init = function() {
|
||||
// placeholder
|
||||
};
|
||||
@@ -0,0 +1,6 @@
|
||||
import CustomRules from './CustomRules';
|
||||
|
||||
export default {
|
||||
__init__: [ 'customRules' ],
|
||||
customRules: [ 'type', CustomRules ]
|
||||
};
|
||||
Reference in New Issue
Block a user