Difference between label and non-label-obj in businessObject?


#1

What is the best way to differentiate between label and non-label-objects in businessObject?
(elementRegistry.get(“EndEvent_07gaa7k_label”).businessObject.$type is “bpmn:EndEvent”)


#2

Please see LabelUtil to check how it is done in bpmn-js: https://github.com/bpmn-io/bpmn-js/blob/master/lib/features/label-editing/LabelUtil.js


#3

Thank you!!

stupid question: how can I load module LabelUtil w.i.t.h.o.u.t. require?
(lib is browserified in modeler.bundled.js)


#4

I am not sure what you want to achieve. Can you please provide a code example with explanation why import is not possible?


#5

53

import is new for me, first tries didn’t work out in chrome. I’ll read.


#6

You’d have to bundle it if you want to use it in the browser. Alternatively you can simply copy the code or even easier:

if (myElement.labelTarget) {
  // ... this element is a label
}

#7

Thank you! So, next to browserifying of modeler, the respective module has to be bundled? There is no bpmnModeler.get?

Actually, which objects belong to the official API? Everything I can get with elementRegistry.get? So more than businessObject?


#8

LabelUtil is only a utility that is used by other modules. Therefore it’s not available through modeler.get.

You can get diagram shapes through ElementRegistry#get. All of these have a businessObject property containing the BPMN-specific information of the element.


#9

Thank you very much!!