RemoveEmbeddedLabelBoundsBehavior.js 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import inherits from 'inherits-browser';
  2. import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
  3. import { getDi } from '../../../util/ModelUtil';
  4. /**
  5. * @typedef {import('diagram-js/lib/core/EventBus').default} EventBus
  6. * @typedef {import('../Modeling').default} Modeling
  7. */
  8. /**
  9. * BPMN specific behavior ensuring that bpmndi:Label's dc:Bounds are removed
  10. * when shape is resized.
  11. *
  12. * @param {EventBus} eventBus
  13. * @param {Modeling} modeling
  14. */
  15. export default function RemoveEmbeddedLabelBoundsBehavior(eventBus, modeling) {
  16. CommandInterceptor.call(this, eventBus);
  17. this.preExecute('shape.resize', function(context) {
  18. var shape = context.shape;
  19. var di = getDi(shape),
  20. label = di && di.get('label'),
  21. bounds = label && label.get('bounds');
  22. if (bounds) {
  23. modeling.updateModdleProperties(shape, label, {
  24. bounds: undefined
  25. });
  26. }
  27. }, true);
  28. }
  29. inherits(RemoveEmbeddedLabelBoundsBehavior, CommandInterceptor);
  30. RemoveEmbeddedLabelBoundsBehavior.$inject = [
  31. 'eventBus',
  32. 'modeling'
  33. ];