Name of TextAnnotation resize eventhandler

Hello,

I also ran into this issue while using the ResizeAllRules module included in bpmn-js-nyan. I have a simple fix for it, details below. I know you’ve made a point about not supporting resizing in the past, so I’m not sure if this is considered a bug. If it is, let me know and I’ll make a pull request.

The text box sizes are hard-coded to 90x30 in couple spots. I just changed it to use the element’s dimensions.

In bpmn-js/lib/draw/TextRenderer.js:

this.getExternalLabelBounds = function(bounds, text) {

    var layoutedDimensions = textUtil.getDimensions(text, {
      box: {
        width: !bounds.width ? 90 : bounds.width, //was hardcoded to 90
        height: !bounds.height ? 30 : bounds.height, //was hardcoded to 30
        x: bounds.width / 2 + bounds.x,
        y: bounds.height / 2 + bounds.y
      },
      style: externalStyle
    });

    // resize label shape to fit label text
    return {
      x: Math.round(bounds.x + bounds.width / 2 - layoutedDimensions.width / 2),
      y: Math.round(bounds.y),
      width: Math.ceil(layoutedDimensions.width),
      height: Math.ceil(layoutedDimensions.height)
    };

  };

In bpmn-js/lib/draw/BpmnRenderer.js:

  function renderExternalLabel(parentGfx, element) {
    var semantic = getSemantic(element);
    var box = {
      width: !element.width ? 90 : element.width, //was hardcoded to 90
      height: !element.height ? 30 : element.height, //was hardcoded to 30
      x: element.width / 2 + element.x,
      y: element.height / 2 + element.y
    };

Thanks,
John

1 Like