label置于节点下方问题
11010cy opened this issue · comments
yang commented
如在label标签自定义在元素下方中的讨论,发现了另外一种可行的方法。
经查源码,在 ./node_modules/bpmn-js/lib/import/BpmnImporter.js
185行可知,
// line 185
// (optional) LABEL
if (isLabelExternal(semantic) && semantic.name) {
this.addLabel(semantic, element);
}
而isLabelExternal定义在 ./node_modules/bpmn-js/lib/util/LabelUtil.js
// 22
// Returns true if the given semantic has an external label
// Params:
// semantic: BpmnElement
// Returns:
// Boolean - true if has label
export function isLabelExternal(semantic) {
return is(semantic, 'bpmn:Event') ||
is(semantic, 'bpmn:Gateway') ||
is(semantic, 'bpmn:DataStoreReference') ||
is(semantic, 'bpmn:DataObjectReference') ||
is(semantic, 'bpmn:DataInput') ||
is(semantic, 'bpmn:DataOutput') ||
is(semantic, 'bpmn:SequenceFlow') ||
is(semantic, 'bpmn:MessageFlow') ;
}
所以,event节点、gateway节点等标签在节点下方,而Task节点不是。
故,可以通过将我们的节点添加到isLabelExternal修改默认标签行为。
如果你有更好的办法,欢迎讨论。
wangpeilin commented
不错不错,好像还可以参考一下这里:https://juejin.cn/post/6983940380085452813