Skip to content
Permalink
Browse files

fix(disable-modeling): fix editor actions disabling

  • Loading branch information...
philippfromme authored and nikku committed Nov 29, 2018
1 parent 9459df1 commit 273ce65136ab633cbc0fe366ad376089939be541
Showing with 32 additions and 12 deletions.
  1. +32 −12 lib/features/disable-modeling/DisableModeling.js
@@ -67,17 +67,9 @@ function DisableModeling(

ignoreIfModelingDisabled(directEditing, 'activate');

ignoreIfModelingDisabled(editorActions._actions, 'undo');
ignoreIfModelingDisabled(editorActions._actions, 'redo');
ignoreIfModelingDisabled(editorActions._actions, 'copy');
ignoreIfModelingDisabled(editorActions._actions, 'paste');
ignoreIfModelingDisabled(editorActions._actions, 'removeSelection');
ignoreIfModelingDisabled(editorActions._actions, 'spaceTool');
ignoreIfModelingDisabled(editorActions._actions, 'lassoTool');
ignoreIfModelingDisabled(editorActions._actions, 'globalConnectTool');
ignoreIfModelingDisabled(editorActions._actions, 'distributeElements');
ignoreIfModelingDisabled(editorActions._actions, 'alignElements');
ignoreIfModelingDisabled(editorActions._actions, 'directEditing');
ignoreIfModelingDisabled(dragging, 'init');

ignoreIfModelingDisabled(directEditing, 'activate');

throwIfModelingDisabled(modeling, 'moveShape');
throwIfModelingDisabled(modeling, 'updateAttachment');
@@ -100,6 +92,28 @@ function DisableModeling(
throwIfModelingDisabled(modeling, 'updateWaypoints');
throwIfModelingDisabled(modeling, 'reconnectStart');
throwIfModelingDisabled(modeling, 'reconnectEnd');

intercept(editorActions, 'trigger', function(fn, args) {
var action = args[0];

if (self.modelingDisabled && isAnyAction([
'undo',
'redo',
'copy',
'paste',
'removeSelection',
'spaceTool',
'lassoTool',
'globalConnectTool',
'distributeElements',
'alignElements',
'directEditing',
], action)) {
return;
}

return fn.apply(this, args);
});
}

DisableModeling.$inject = [
@@ -113,4 +127,10 @@ DisableModeling.$inject = [
'paletteProvider',
];

module.exports = DisableModeling;
module.exports = DisableModeling;

// helpers //////////

function isAnyAction(actions, action) {
return actions.indexOf(action) > -1;
}

0 comments on commit 273ce65

Please sign in to comment.
You can’t perform that action at this time.