parent
5d5683ff64
commit
03b4a59f84
|
@ -1,16 +1,10 @@
|
|||
'use strict';
|
||||
|
||||
function BpmnKeyBindings(
|
||||
keyboard, spaceTool, lassoTool,
|
||||
directEditing, selection, canvas,
|
||||
elementRegistry) {
|
||||
|
||||
|
||||
keyboard.addListener(function(key, modifiers) {
|
||||
|
||||
// ctrl + a -> select all elements
|
||||
if (key === 65 && keyboard.isCmd(modifiers)) {
|
||||
function BpmnKeyBindings(keyboard, spaceTool, lassoTool, directEditing,
|
||||
selection, canvas, elementRegistry, editorActions) {
|
||||
|
||||
var actions = {
|
||||
selectElements: function() {
|
||||
// select all elements except for the invisible
|
||||
// root element
|
||||
var rootElement = canvas.getRootElement();
|
||||
|
@ -20,6 +14,29 @@ function BpmnKeyBindings(
|
|||
});
|
||||
|
||||
selection.select(elements);
|
||||
},
|
||||
spaceTool: function() {
|
||||
spaceTool.activateSelection();
|
||||
},
|
||||
lassoTool: function() {
|
||||
lassoTool.activateSelection();
|
||||
},
|
||||
directEditing: function() {
|
||||
var currentSelection = selection.get();
|
||||
|
||||
if (currentSelection.length) {
|
||||
directEditing.activate(currentSelection[0]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
editorActions.register(actions);
|
||||
|
||||
keyboard.addListener(function(key, modifiers) {
|
||||
|
||||
// ctrl + a -> select all elements
|
||||
if (key === 65 && keyboard.isCmd(modifiers)) {
|
||||
editorActions.trigger('selectElements');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -30,25 +47,21 @@ function BpmnKeyBindings(
|
|||
|
||||
// s -> activate space tool
|
||||
if (key === 83) {
|
||||
spaceTool.activateSelection();
|
||||
editorActions.trigger('spaceTool');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// l -> activate lasso tool
|
||||
if (key === 76) {
|
||||
lassoTool.activateSelection();
|
||||
editorActions.trigger('lassoTool');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
var currentSelection = selection.get();
|
||||
|
||||
// e -> activate direct editing
|
||||
if (key === 69) {
|
||||
if (currentSelection.length) {
|
||||
directEditing.activate(currentSelection[0]);
|
||||
}
|
||||
editorActions.trigger('directEditing');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -62,7 +75,8 @@ BpmnKeyBindings.$inject = [
|
|||
'directEditing',
|
||||
'selection',
|
||||
'canvas',
|
||||
'elementRegistry'
|
||||
'elementRegistry',
|
||||
'editorActions'
|
||||
];
|
||||
|
||||
module.exports = BpmnKeyBindings;
|
||||
|
|
|
@ -10,7 +10,8 @@ var coreModule = require('../../../../lib/core'),
|
|||
selectionModule = require('diagram-js/lib/features/selection'),
|
||||
spaceToolModule = require('diagram-js/lib/features/space-tool'),
|
||||
lassoToolModule = require('diagram-js/lib/features/lasso-tool'),
|
||||
zoomScrollModule = require('diagram-js/lib/navigation/zoomscroll');
|
||||
zoomScrollModule = require('diagram-js/lib/navigation/zoomscroll'),
|
||||
editorActionsModule = require('diagram-js/lib/features/editor-actions');
|
||||
|
||||
var createKeyEvent = require('diagram-js/test/util/KeyEvents').createKeyEvent;
|
||||
|
||||
|
@ -27,7 +28,8 @@ describe('features - keyboard', function() {
|
|||
spaceToolModule,
|
||||
lassoToolModule,
|
||||
keyboardModule,
|
||||
zoomScrollModule
|
||||
zoomScrollModule,
|
||||
editorActionsModule
|
||||
];
|
||||
|
||||
beforeEach(bootstrapViewer(diagramXML, { modules: testModules }));
|
||||
|
@ -40,6 +42,11 @@ describe('features - keyboard', function() {
|
|||
container = TestContainer.get(this);
|
||||
});
|
||||
|
||||
it('should include triggers inside editorActions', inject(function(editorActions) {
|
||||
// then
|
||||
expect(editorActions.length()).to.equal(10);
|
||||
}));
|
||||
|
||||
|
||||
it('should trigger lasso tool', inject(function(keyboard, lassoTool) {
|
||||
|
||||
|
|
Loading…
Reference in New Issue