Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

label置于节点下方问题 #25

Closed
11010cy opened this issue Dec 1, 2021 · 1 comment
Closed

label置于节点下方问题 #25

11010cy opened this issue Dec 1, 2021 · 1 comment

Comments

@11010cy
Copy link

11010cy commented Dec 1, 2021

如在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修改默认标签行为。

如果你有更好的办法,欢迎讨论。

@LinDaiDai
Copy link
Owner

不错不错,好像还可以参考一下这里:https://juejin.cn/post/6983940380085452813

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants