This commit is contained in:
hanjian
2024-08-14 15:17:51 +08:00
parent 20a221c1a2
commit b610f94b2e
3483 changed files with 650965 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
import AutoResize from 'diagram-js/lib/features/auto-resize/AutoResize';
import inherits from 'inherits';
import { is } from '../../util/ModelUtil';
/**
* Sub class of the AutoResize module which implements a BPMN
* specific resize function.
*/
export default function BpmnAutoResize(injector) {
injector.invoke(AutoResize, this);
}
BpmnAutoResize.$inject = [
'injector'
];
inherits(BpmnAutoResize, AutoResize);
/**
* Resize shapes and lanes.
*
* @param {djs.model.Shape} target
* @param {Bounds} newBounds
* @param {Object} hints
*/
BpmnAutoResize.prototype.resize = function(target, newBounds, hints) {
if (is(target, 'bpmn:Participant')) {
this._modeling.resizeLane(target, newBounds, null, hints);
} else {
this._modeling.resizeShape(target, newBounds, null, hints);
}
};

View File

@@ -0,0 +1,51 @@
import { is } from '../../util/ModelUtil';
import inherits from 'inherits';
import { forEach } from 'min-dash';
import AutoResizeProvider from 'diagram-js/lib/features/auto-resize/AutoResizeProvider';
/**
* This module is a provider for automatically resizing parent BPMN elements
*/
export default function BpmnAutoResizeProvider(eventBus, modeling) {
AutoResizeProvider.call(this, eventBus);
this._modeling = modeling;
}
inherits(BpmnAutoResizeProvider, AutoResizeProvider);
BpmnAutoResizeProvider.$inject = [
'eventBus',
'modeling'
];
/**
* Check if the given target can be expanded
*
* @param {djs.model.Shape} target
*
* @return {boolean}
*/
BpmnAutoResizeProvider.prototype.canResize = function(elements, target) {
if (!is(target, 'bpmn:Participant') && !is(target, 'bpmn:Lane') && !(is(target, 'bpmn:SubProcess'))) {
return false;
}
var canResize = true;
forEach(elements, function(element) {
if (is(element, 'bpmn:Lane') || element.labelTarget) {
canResize = false;
return;
}
});
return canResize;
};

View File

@@ -0,0 +1,12 @@
import BpmnAutoResize from './BpmnAutoResize';
import BpmnAutoResizeProvider from './BpmnAutoResizeProvider';
export default {
__init__: [
'bpmnAutoResize',
'bpmnAutoResizeProvider'
],
bpmnAutoResize: [ 'type', BpmnAutoResize ],
bpmnAutoResizeProvider: [ 'type', BpmnAutoResizeProvider ]
};