mirror of
https://github.com/sartography/bpmn-js.git
synced 2025-01-11 09:36:07 +00:00
improve(resize): restrict resizable elements
related bpmn-io/bpmn-js#140
This commit is contained in:
parent
392dfaee41
commit
1e224370e2
@ -69,7 +69,8 @@ Modeler.prototype._modelingModules = [
|
||||
require('diagram-js/lib/features/resize'),
|
||||
require('./features/modeling'),
|
||||
require('./features/context-pad'),
|
||||
require('./features/palette')
|
||||
require('./features/palette'),
|
||||
require('./features/resize')
|
||||
];
|
||||
|
||||
|
||||
|
6
lib/features/resize/BpmnResizableElements.json
Normal file
6
lib/features/resize/BpmnResizableElements.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"elements": [
|
||||
"bpmn:Task",
|
||||
"bpmn:SubProcess"
|
||||
]
|
||||
}
|
28
lib/features/resize/BpmnResizeHandler.js
Normal file
28
lib/features/resize/BpmnResizeHandler.js
Normal file
@ -0,0 +1,28 @@
|
||||
'use strict';
|
||||
|
||||
var _ = require('lodash');
|
||||
|
||||
var resizableElements = require('./BpmnResizableElements.json').elements;
|
||||
|
||||
|
||||
function BpmnResizeHandler(eventBus, resize) {
|
||||
|
||||
var isResizeAllowed = function(element) {
|
||||
var isAllowed = _.contains(resizableElements, element.type);
|
||||
|
||||
if (isAllowed) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
// Register Handler
|
||||
eventBus.on('canvas.init', function() {
|
||||
resize.registerResizableHandler(isResizeAllowed);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = BpmnResizeHandler;
|
||||
|
||||
BpmnResizeHandler.$inject = [ 'eventBus', 'resize' ];
|
7
lib/features/resize/index.js
Normal file
7
lib/features/resize/index.js
Normal file
@ -0,0 +1,7 @@
|
||||
module.exports = {
|
||||
__depends__: [
|
||||
require('diagram-js/lib/features/resize')
|
||||
],
|
||||
__init__: [ 'bpmnResizeHandler' ],
|
||||
bpmnResizeHandler: [ 'type', require('./BpmnResizeHandler') ]
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user