2021-08-28 13:31:34 +00:00
|
|
|
import { getDi } from '../../util/ModelUtil';
|
2020-03-13 12:26:16 +00:00
|
|
|
|
|
|
|
import {
|
|
|
|
filter,
|
|
|
|
map
|
|
|
|
} from 'min-dash';
|
|
|
|
|
|
|
|
import { selfAndAllChildren } from 'diagram-js/lib/util/Elements';
|
|
|
|
|
|
|
|
|
|
|
|
var HIGH_PRIORITY = 2000;
|
|
|
|
|
|
|
|
export default function BpmnDiOrdering(eventBus, canvas) {
|
|
|
|
|
|
|
|
eventBus.on('saveXML.start', HIGH_PRIORITY, orderDi);
|
|
|
|
|
|
|
|
function orderDi() {
|
|
|
|
var root = canvas.getRootElement(),
|
2021-08-06 08:45:10 +00:00
|
|
|
rootDi = getDi(root),
|
2020-03-13 12:26:16 +00:00
|
|
|
elements,
|
|
|
|
diElements;
|
|
|
|
|
|
|
|
elements = selfAndAllChildren([ root ], false);
|
|
|
|
|
|
|
|
// only bpmndi:Shape and bpmndi:Edge can be direct children of bpmndi:Plane
|
|
|
|
elements = filter(elements, function(element) {
|
|
|
|
return element !== root && !element.labelTarget;
|
|
|
|
});
|
|
|
|
|
|
|
|
diElements = map(elements, getDi);
|
|
|
|
|
|
|
|
rootDi.set('planeElement', diElements);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
BpmnDiOrdering.$inject = [ 'eventBus', 'canvas' ];
|