bpmn-js 18.7.0 → 18.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * bpmn-js - bpmn-modeler v18.7.0
2
+ * bpmn-js - bpmn-modeler v18.9.0
3
3
  *
4
4
  * Copyright (c) 2014-present, camunda Services GmbH
5
5
  *
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * Source Code: https://github.com/bpmn-io/bpmn-js
10
10
  *
11
- * Date: 2025-09-23
11
+ * Date: 2025-11-18
12
12
  */
13
13
  (function (global, factory) {
14
14
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -18354,6 +18354,17 @@
18354
18354
  return element;
18355
18355
  }
18356
18356
 
18357
+ /**
18358
+ * Returns true if the given element is an external label.
18359
+ *
18360
+ * @param {Element} element
18361
+ *
18362
+ * @return {boolean}
18363
+ */
18364
+ function isExternalLabel(element) {
18365
+ return isLabel(element) && isLabelExternal(element.labelTarget);
18366
+ }
18367
+
18357
18368
  var black = 'hsl(225, 10%, 15%)';
18358
18369
  var white = 'white';
18359
18370
 
@@ -18484,11 +18495,11 @@
18484
18495
  [ 'l', width - borderRadius * 2, 0 ],
18485
18496
  [ 'a', borderRadius, borderRadius, 0, 0, 1, borderRadius, borderRadius ],
18486
18497
  [ 'l', 0, height - borderRadius * 2 ],
18487
- [ 'a', borderRadius, borderRadius, 0, 0, 1, -10, borderRadius ],
18498
+ [ 'a', borderRadius, borderRadius, 0, 0, 1, -borderRadius, borderRadius ],
18488
18499
  [ 'l', borderRadius * 2 - width, 0 ],
18489
- [ 'a', borderRadius, borderRadius, 0, 0, 1, -10, -10 ],
18500
+ [ 'a', borderRadius, borderRadius, 0, 0, 1, -borderRadius, -borderRadius ],
18490
18501
  [ 'l', 0, borderRadius * 2 - height ],
18491
- [ 'a', borderRadius, borderRadius, 0, 0, 1, borderRadius, -10 ],
18502
+ [ 'a', borderRadius, borderRadius, 0, 0, 1, borderRadius, -borderRadius ],
18492
18503
  [ 'z' ]
18493
18504
  ];
18494
18505
 
@@ -18586,7 +18597,8 @@
18586
18597
  var ELEMENT_LABEL_DISTANCE$1 = 10,
18587
18598
  INNER_OUTER_DIST = 3,
18588
18599
  PARTICIPANT_STROKE_WIDTH = 1.5,
18589
- TASK_BORDER_RADIUS = 10;
18600
+ TASK_BORDER_RADIUS = 10,
18601
+ EXTERNAL_LABEL_BORDER_RADIUS = 4;
18590
18602
 
18591
18603
  var DEFAULT_OPACITY = 0.95,
18592
18604
  FULL_OPACITY = 1,
@@ -20895,6 +20907,11 @@
20895
20907
  * @return {string} path
20896
20908
  */
20897
20909
  BpmnRenderer.prototype.getShapePath = function(shape) {
20910
+
20911
+ if (isLabel(shape)) {
20912
+ return getRoundRectPath(shape, EXTERNAL_LABEL_BORDER_RADIUS);
20913
+ }
20914
+
20898
20915
  if (is(shape, 'bpmn:Event')) {
20899
20916
  return getCirclePath(shape);
20900
20917
  }
@@ -35460,6 +35477,9 @@
35460
35477
  // create a DataObject every time a DataObjectReference is created
35461
35478
  var dataObject = bpmnFactory.create('bpmn:DataObject');
35462
35479
 
35480
+ // Copy the isCollection property if needed.
35481
+ dataObject.isCollection = shape.businessObject.dataObjectRef?.isCollection || false;
35482
+
35463
35483
  // set the reference to the DataObject
35464
35484
  shape.businessObject.dataObjectRef = dataObject;
35465
35485
  }
@@ -44469,7 +44489,8 @@
44469
44489
  'errorRef',
44470
44490
  'escalationRef',
44471
44491
  'messageRef',
44472
- 'signalRef'
44492
+ 'signalRef',
44493
+ 'dataObjectRef'
44473
44494
  ];
44474
44495
 
44475
44496
  /**
@@ -61413,6 +61434,483 @@
61413
61434
  labelEditingPreview: [ 'type', LabelEditingPreview ]
61414
61435
  };
61415
61436
 
61437
+ var LOW_PRIORITY$3 = 500;
61438
+
61439
+ var DEFAULT_PRIORITY$1 = 1000;
61440
+
61441
+ /**
61442
+ * @typedef {import('../../model/Types').Element} Element
61443
+ *
61444
+ * @typedef {import('./OutlineProvider').default} OutlineProvider
61445
+ * @typedef {import('../../core/EventBus').default} EventBus
61446
+ * @typedef {import('../../draw/Styles').default} Styles
61447
+ */
61448
+
61449
+ /**
61450
+ * @class
61451
+ *
61452
+ * A plugin that adds an outline to shapes and connections that may be activated and styled
61453
+ * via CSS classes.
61454
+ *
61455
+ * @param {EventBus} eventBus
61456
+ * @param {Styles} styles
61457
+ */
61458
+ function Outline$1(eventBus, styles) {
61459
+
61460
+ this._eventBus = eventBus;
61461
+
61462
+ this.offset = 5;
61463
+
61464
+ var OUTLINE_STYLE = styles.cls('djs-outline', [ 'no-fill' ]);
61465
+
61466
+ var self = this;
61467
+
61468
+ /**
61469
+ * @param {SVGElement} gfx
61470
+ *
61471
+ * @return {SVGElement} outline
61472
+ */
61473
+ function createOutline(gfx) {
61474
+ var outline = create$1('rect');
61475
+
61476
+ attr(outline, assign$1({
61477
+ x: 0,
61478
+ y: 0,
61479
+ rx: 4,
61480
+ width: 100,
61481
+ height: 100
61482
+ }, OUTLINE_STYLE));
61483
+
61484
+ return outline;
61485
+ }
61486
+
61487
+ // A low priortity is necessary, because outlines of labels have to be updated
61488
+ // after the label bounds have been updated in the renderer.
61489
+ eventBus.on([ 'shape.added', 'shape.changed' ], LOW_PRIORITY$3, function(event) {
61490
+ var element = event.element,
61491
+ gfx = event.gfx;
61492
+
61493
+ var outline = query('.djs-outline', gfx);
61494
+
61495
+ if (!outline) {
61496
+ outline = self.getOutline(element) || createOutline();
61497
+ append(gfx, outline);
61498
+ }
61499
+
61500
+ self.updateShapeOutline(outline, element);
61501
+ });
61502
+
61503
+ eventBus.on([ 'connection.added', 'connection.changed' ], function(event) {
61504
+ var element = event.element,
61505
+ gfx = event.gfx;
61506
+
61507
+ var outline = query('.djs-outline', gfx);
61508
+
61509
+ if (!outline) {
61510
+ outline = createOutline();
61511
+ append(gfx, outline);
61512
+ }
61513
+
61514
+ self.updateConnectionOutline(outline, element);
61515
+ });
61516
+ }
61517
+
61518
+
61519
+ /**
61520
+ * Updates the outline of a shape respecting the dimension of the
61521
+ * element and an outline offset.
61522
+ *
61523
+ * @param {SVGElement} outline
61524
+ * @param {Element} element
61525
+ */
61526
+ Outline$1.prototype.updateShapeOutline = function(outline, element) {
61527
+
61528
+ var updated = false;
61529
+ var providers = this._getProviders();
61530
+
61531
+ if (providers.length) {
61532
+ forEach$1(providers, function(provider) {
61533
+ updated = updated || provider.updateOutline(element, outline);
61534
+ });
61535
+ }
61536
+
61537
+ if (!updated) {
61538
+ attr(outline, {
61539
+ x: -this.offset,
61540
+ y: -this.offset,
61541
+ width: element.width + this.offset * 2,
61542
+ height: element.height + this.offset * 2
61543
+ });
61544
+ }
61545
+ };
61546
+
61547
+ /**
61548
+ * Updates the outline of a connection respecting the bounding box of
61549
+ * the connection and an outline offset.
61550
+ * Register an outline provider with the given priority.
61551
+ *
61552
+ * @param {SVGElement} outline
61553
+ * @param {Element} connection
61554
+ */
61555
+ Outline$1.prototype.updateConnectionOutline = function(outline, connection) {
61556
+ var bbox = getBBox(connection);
61557
+
61558
+ attr(outline, {
61559
+ x: bbox.x - this.offset,
61560
+ y: bbox.y - this.offset,
61561
+ width: bbox.width + this.offset * 2,
61562
+ height: bbox.height + this.offset * 2
61563
+ });
61564
+ };
61565
+
61566
+ /**
61567
+ * Register an outline provider with the given priority.
61568
+ *
61569
+ * @param {number} priority
61570
+ * @param {OutlineProvider} provider
61571
+ */
61572
+ Outline$1.prototype.registerProvider = function(priority, provider) {
61573
+ if (!provider) {
61574
+ provider = priority;
61575
+ priority = DEFAULT_PRIORITY$1;
61576
+ }
61577
+
61578
+ this._eventBus.on('outline.getProviders', priority, function(event) {
61579
+ event.providers.push(provider);
61580
+ });
61581
+ };
61582
+
61583
+ /**
61584
+ * Returns the registered outline providers.
61585
+ *
61586
+ * @returns {OutlineProvider[]}
61587
+ */
61588
+ Outline$1.prototype._getProviders = function() {
61589
+ var event = this._eventBus.createEvent({
61590
+ type: 'outline.getProviders',
61591
+ providers: []
61592
+ });
61593
+
61594
+ this._eventBus.fire(event);
61595
+
61596
+ return event.providers;
61597
+ };
61598
+
61599
+ /**
61600
+ * Returns the outline for an element.
61601
+ *
61602
+ * @param {Element} element
61603
+ */
61604
+ Outline$1.prototype.getOutline = function(element) {
61605
+ var outline;
61606
+ var providers = this._getProviders();
61607
+
61608
+ forEach$1(providers, function(provider) {
61609
+
61610
+ if (!isFunction(provider.getOutline)) {
61611
+ return;
61612
+ }
61613
+
61614
+ outline = outline || provider.getOutline(element);
61615
+ });
61616
+
61617
+ return outline;
61618
+ };
61619
+
61620
+ Outline$1.$inject = [ 'eventBus', 'styles', 'elementRegistry' ];
61621
+
61622
+ var SELECTION_OUTLINE_PADDING = 6;
61623
+
61624
+ /**
61625
+ * @typedef {import('../../model/Types').Element} Element
61626
+ *
61627
+ * @typedef {import('../../core/EventBus').default} EventBus
61628
+ * @typedef {import('../selection/Selection').default} Selection
61629
+ * @typedef {import('../../core/Canvas').default} Canvas
61630
+ */
61631
+
61632
+ /**
61633
+ * @class
61634
+ *
61635
+ * A plugin that adds an outline to shapes and connections that may be activated and styled
61636
+ * via CSS classes.
61637
+ *
61638
+ * @param {EventBus} eventBus
61639
+ * @param {Canvas} canvas
61640
+ * @param {Selection} selection
61641
+ */
61642
+ function MultiSelectionOutline(eventBus, canvas, selection) {
61643
+ this._canvas = canvas;
61644
+
61645
+ var self = this;
61646
+
61647
+ eventBus.on('element.changed', function(event) {
61648
+ if (selection.isSelected(event.element)) {
61649
+ self._updateMultiSelectionOutline(selection.get());
61650
+ }
61651
+ });
61652
+
61653
+ eventBus.on('selection.changed', function(event) {
61654
+ var newSelection = event.newSelection;
61655
+
61656
+ self._updateMultiSelectionOutline(newSelection);
61657
+ });
61658
+ }
61659
+
61660
+
61661
+
61662
+ MultiSelectionOutline.prototype._updateMultiSelectionOutline = function(selection) {
61663
+ var layer = this._canvas.getLayer('selectionOutline');
61664
+
61665
+ clear(layer);
61666
+
61667
+ var enabled = selection.length > 1;
61668
+
61669
+ var container = this._canvas.getContainer();
61670
+
61671
+ classes(container)[enabled ? 'add' : 'remove']('djs-multi-select');
61672
+
61673
+ if (!enabled) {
61674
+ return;
61675
+ }
61676
+
61677
+ var bBox = addSelectionOutlinePadding(getBBox(selection));
61678
+
61679
+ var rect = create$1('rect');
61680
+
61681
+ attr(rect, assign$1({
61682
+ rx: 3
61683
+ }, bBox));
61684
+
61685
+ classes(rect).add('djs-selection-outline');
61686
+
61687
+ append(layer, rect);
61688
+ };
61689
+
61690
+
61691
+ MultiSelectionOutline.$inject = [ 'eventBus', 'canvas', 'selection' ];
61692
+
61693
+ // helpers //////////
61694
+
61695
+ function addSelectionOutlinePadding(bBox) {
61696
+ return {
61697
+ x: bBox.x - SELECTION_OUTLINE_PADDING,
61698
+ y: bBox.y - SELECTION_OUTLINE_PADDING,
61699
+ width: bBox.width + SELECTION_OUTLINE_PADDING * 2,
61700
+ height: bBox.height + SELECTION_OUTLINE_PADDING * 2
61701
+ };
61702
+ }
61703
+
61704
+ /**
61705
+ * @type { import('didi').ModuleDeclaration }
61706
+ */
61707
+ var Outline = {
61708
+ __depends__: [
61709
+ SelectionModule
61710
+ ],
61711
+ __init__: [ 'outline', 'multiSelectionOutline' ],
61712
+ outline: [ 'type', Outline$1 ],
61713
+ multiSelectionOutline: [ 'type', MultiSelectionOutline ]
61714
+ };
61715
+
61716
+ /**
61717
+ * @typedef {import('diagram-js/lib/core/EventBus').default} EventBus
61718
+ * @typedef {import('diagram-js/lib/core/Canvas').default} Canvas
61719
+ * @typedef {import('diagram-js/lib/core/GraphicsFactory').default} GraphicsFactory
61720
+ * @typedef {import('../outline/OutlineProvider').default} Outline
61721
+ * @typedef {import('diagram-js/lib/features/selection').default} Selection
61722
+ *
61723
+ * @typedef {import('diagram-js/lib/model/Types').Element} Element
61724
+ */
61725
+
61726
+ const ALLOWED_ELEMENTS = [ 'bpmn:Event', 'bpmn:SequenceFlow', 'bpmn:Gateway' ];
61727
+
61728
+ const LINE_STYLE = {
61729
+ class: 'bjs-label-link',
61730
+ stroke: 'var(--element-selected-outline-secondary-stroke-color)',
61731
+ strokeDasharray: '5, 5',
61732
+ };
61733
+
61734
+ const DISTANCE_THRESHOLD = 15;
61735
+ const PATH_OFFSET = 2;
61736
+
61737
+ /**
61738
+ * Render a line between an external label and its target element,
61739
+ * when either is selected.
61740
+ *
61741
+ * @param {EventBus} eventBus
61742
+ * @param {Canvas} canvas
61743
+ * @param {GraphicsFactory} graphicsFactory
61744
+ * @param {Outline} outline
61745
+ */
61746
+ function LabelLink$1(eventBus, canvas, graphicsFactory, outline, selection) {
61747
+
61748
+ const layer = canvas.getLayer('overlays');
61749
+
61750
+ eventBus.on([ 'selection.changed', 'shape.changed' ], function() {
61751
+ cleanUp();
61752
+ });
61753
+
61754
+ eventBus.on('selection.changed', function({ newSelection }) {
61755
+
61756
+ const allowedElements = newSelection.filter(element => isAny(element, ALLOWED_ELEMENTS));
61757
+
61758
+ if (allowedElements.length === 1) {
61759
+ const element = allowedElements[0];
61760
+ if (isLabel(element)) {
61761
+ createLink(element, element.labelTarget, newSelection);
61762
+ } else if (element.labels?.length) {
61763
+ createLink(element.labels[0], element, newSelection);
61764
+ }
61765
+ }
61766
+
61767
+ // Only allowed when both label and its target are selected
61768
+ if (allowedElements.length === 2) {
61769
+ const label = allowedElements.find(isLabel);
61770
+ const target = allowedElements.find(el => el.labels?.includes(label));
61771
+ if (label && target) {
61772
+ createLink(label, target, newSelection);
61773
+ }
61774
+ }
61775
+ });
61776
+
61777
+ eventBus.on('shape.changed', function({ element }) {
61778
+
61779
+ if (!isAny(element, ALLOWED_ELEMENTS)) {
61780
+ return;
61781
+ }
61782
+
61783
+ if (isLabel(element)) {
61784
+ createLink(element, element.labelTarget, selection.get());
61785
+ } else if (element.labels?.length) {
61786
+ createLink(element.labels[0], element, selection.get());
61787
+ }
61788
+ });
61789
+
61790
+ /**
61791
+ * Render a line between an external label and its target.
61792
+ *
61793
+ * @param {Element} label
61794
+ * @param {Element} target
61795
+ * @param {Element[]} selection
61796
+ */
61797
+ function createLink(label, target, selection = []) {
61798
+
61799
+ // Create an auxiliary line between label and target mid points
61800
+ const line = createLine(
61801
+ [ getMid(target), getMid(label) ],
61802
+ LINE_STYLE
61803
+ );
61804
+ const linePath = line.getAttribute('d');
61805
+
61806
+ // Calculate the intersection point between line and label
61807
+ const labelSelected = selection.includes(label);
61808
+ const labelPath = labelSelected ? getElementOutlinePath(label) : getElementPath(label);
61809
+ const labelInter = getElementLineIntersection(labelPath, linePath);
61810
+
61811
+ // Label on top of the target
61812
+ if (!labelInter) {
61813
+ return;
61814
+ }
61815
+
61816
+ // Calculate the intersection point between line and label
61817
+ // If the target is a sequence flow, there is no intersection,
61818
+ // so we link to the middle of it.
61819
+ const targetSelected = selection.includes(target);
61820
+ const targetPath = targetSelected ? getElementOutlinePath(target) : getElementPath(target);
61821
+ const targetInter = getElementLineIntersection(targetPath, linePath) || getMid(target);
61822
+
61823
+ // Do not draw a link if the points are too close
61824
+ const distance = getDistancePointPoint(targetInter, labelInter);
61825
+ if (distance < DISTANCE_THRESHOLD) {
61826
+ return;
61827
+ }
61828
+
61829
+ // Connect the actual closest points
61830
+ updateLine(line, [ targetInter, labelInter ]);
61831
+ append(layer, line);
61832
+ }
61833
+
61834
+ /**
61835
+ * Remove all existing label links.
61836
+ */
61837
+ function cleanUp() {
61838
+ all(`.${LINE_STYLE.class}`, layer).forEach(remove$1);
61839
+ }
61840
+
61841
+ /**
61842
+ * Get element's slightly expanded outline path.
61843
+ *
61844
+ * @param {Element} element
61845
+ * @returns {string} svg path
61846
+ */
61847
+ function getElementOutlinePath(element) {
61848
+ const outlineShape = outline.getOutline(element);
61849
+ const outlineOffset = outline.offset;
61850
+
61851
+ if (!outlineShape) {
61852
+ return getElementPath(element);
61853
+ }
61854
+
61855
+ if (outlineShape.x) {
61856
+ const shape = {
61857
+ x: element.x + parseSvgNumAttr(outlineShape, 'x') - PATH_OFFSET,
61858
+ y: element.y + parseSvgNumAttr(outlineShape, 'y') - PATH_OFFSET,
61859
+ width: parseSvgNumAttr(outlineShape, 'width') + PATH_OFFSET * 2,
61860
+ height: parseSvgNumAttr(outlineShape, 'height') + PATH_OFFSET * 2
61861
+ };
61862
+
61863
+ return getRoundRectPath(shape, parseSvgNumAttr(outlineShape, 'rx'));
61864
+ }
61865
+
61866
+ if (outlineShape.cx) {
61867
+ const shape = {
61868
+ x: element.x - outlineOffset,
61869
+ y: element.y - outlineOffset,
61870
+ width: parseSvgNumAttr(outlineShape, 'r') * 2,
61871
+ height: parseSvgNumAttr(outlineShape, 'r') * 2,
61872
+ };
61873
+
61874
+ return getCirclePath(shape);
61875
+ }
61876
+ }
61877
+
61878
+ function getElementPath(element) {
61879
+ return graphicsFactory.getShapePath(element);
61880
+ }
61881
+ }
61882
+
61883
+ LabelLink$1.$inject = [
61884
+ 'eventBus',
61885
+ 'canvas',
61886
+ 'graphicsFactory',
61887
+ 'outline',
61888
+ 'selection'
61889
+ ];
61890
+
61891
+ /**
61892
+ * Get numeric attribute from SVG element
61893
+ * or 0 if not present.
61894
+ *
61895
+ * @param {SVGElement} node
61896
+ * @param {string} attr
61897
+ * @returns {number}
61898
+ */
61899
+ function parseSvgNumAttr(node, attr$1) {
61900
+ return parseFloat(attr(node, attr$1) || 0);
61901
+ }
61902
+
61903
+ var LabelLink = {
61904
+ __depends__: [
61905
+ SelectionModule,
61906
+ Outline
61907
+ ],
61908
+ __init__: [
61909
+ 'labelLink'
61910
+ ],
61911
+ labelLink: [ 'type', LabelLink$1 ]
61912
+ };
61913
+
61416
61914
  /**
61417
61915
  * @typedef {import('../../core/Canvas').default} Canvas
61418
61916
  * @typedef {import('../../core/EventBus').default} EventBus
@@ -61860,285 +62358,6 @@
61860
62358
  modelingFeedback: [ 'type', ModelingFeedback ]
61861
62359
  };
61862
62360
 
61863
- var LOW_PRIORITY$3 = 500;
61864
-
61865
- var DEFAULT_PRIORITY$1 = 1000;
61866
-
61867
- /**
61868
- * @typedef {import('../../model/Types').Element} Element
61869
- *
61870
- * @typedef {import('./OutlineProvider').default} OutlineProvider
61871
- * @typedef {import('../../core/EventBus').default} EventBus
61872
- * @typedef {import('../../draw/Styles').default} Styles
61873
- */
61874
-
61875
- /**
61876
- * @class
61877
- *
61878
- * A plugin that adds an outline to shapes and connections that may be activated and styled
61879
- * via CSS classes.
61880
- *
61881
- * @param {EventBus} eventBus
61882
- * @param {Styles} styles
61883
- */
61884
- function Outline(eventBus, styles) {
61885
-
61886
- this._eventBus = eventBus;
61887
-
61888
- this.offset = 5;
61889
-
61890
- var OUTLINE_STYLE = styles.cls('djs-outline', [ 'no-fill' ]);
61891
-
61892
- var self = this;
61893
-
61894
- /**
61895
- * @param {SVGElement} gfx
61896
- *
61897
- * @return {SVGElement} outline
61898
- */
61899
- function createOutline(gfx) {
61900
- var outline = create$1('rect');
61901
-
61902
- attr(outline, assign$1({
61903
- x: 0,
61904
- y: 0,
61905
- rx: 4,
61906
- width: 100,
61907
- height: 100
61908
- }, OUTLINE_STYLE));
61909
-
61910
- return outline;
61911
- }
61912
-
61913
- // A low priortity is necessary, because outlines of labels have to be updated
61914
- // after the label bounds have been updated in the renderer.
61915
- eventBus.on([ 'shape.added', 'shape.changed' ], LOW_PRIORITY$3, function(event) {
61916
- var element = event.element,
61917
- gfx = event.gfx;
61918
-
61919
- var outline = query('.djs-outline', gfx);
61920
-
61921
- if (!outline) {
61922
- outline = self.getOutline(element) || createOutline();
61923
- append(gfx, outline);
61924
- }
61925
-
61926
- self.updateShapeOutline(outline, element);
61927
- });
61928
-
61929
- eventBus.on([ 'connection.added', 'connection.changed' ], function(event) {
61930
- var element = event.element,
61931
- gfx = event.gfx;
61932
-
61933
- var outline = query('.djs-outline', gfx);
61934
-
61935
- if (!outline) {
61936
- outline = createOutline();
61937
- append(gfx, outline);
61938
- }
61939
-
61940
- self.updateConnectionOutline(outline, element);
61941
- });
61942
- }
61943
-
61944
-
61945
- /**
61946
- * Updates the outline of a shape respecting the dimension of the
61947
- * element and an outline offset.
61948
- *
61949
- * @param {SVGElement} outline
61950
- * @param {Element} element
61951
- */
61952
- Outline.prototype.updateShapeOutline = function(outline, element) {
61953
-
61954
- var updated = false;
61955
- var providers = this._getProviders();
61956
-
61957
- if (providers.length) {
61958
- forEach$1(providers, function(provider) {
61959
- updated = updated || provider.updateOutline(element, outline);
61960
- });
61961
- }
61962
-
61963
- if (!updated) {
61964
- attr(outline, {
61965
- x: -this.offset,
61966
- y: -this.offset,
61967
- width: element.width + this.offset * 2,
61968
- height: element.height + this.offset * 2
61969
- });
61970
- }
61971
- };
61972
-
61973
- /**
61974
- * Updates the outline of a connection respecting the bounding box of
61975
- * the connection and an outline offset.
61976
- * Register an outline provider with the given priority.
61977
- *
61978
- * @param {SVGElement} outline
61979
- * @param {Element} connection
61980
- */
61981
- Outline.prototype.updateConnectionOutline = function(outline, connection) {
61982
- var bbox = getBBox(connection);
61983
-
61984
- attr(outline, {
61985
- x: bbox.x - this.offset,
61986
- y: bbox.y - this.offset,
61987
- width: bbox.width + this.offset * 2,
61988
- height: bbox.height + this.offset * 2
61989
- });
61990
- };
61991
-
61992
- /**
61993
- * Register an outline provider with the given priority.
61994
- *
61995
- * @param {number} priority
61996
- * @param {OutlineProvider} provider
61997
- */
61998
- Outline.prototype.registerProvider = function(priority, provider) {
61999
- if (!provider) {
62000
- provider = priority;
62001
- priority = DEFAULT_PRIORITY$1;
62002
- }
62003
-
62004
- this._eventBus.on('outline.getProviders', priority, function(event) {
62005
- event.providers.push(provider);
62006
- });
62007
- };
62008
-
62009
- /**
62010
- * Returns the registered outline providers.
62011
- *
62012
- * @returns {OutlineProvider[]}
62013
- */
62014
- Outline.prototype._getProviders = function() {
62015
- var event = this._eventBus.createEvent({
62016
- type: 'outline.getProviders',
62017
- providers: []
62018
- });
62019
-
62020
- this._eventBus.fire(event);
62021
-
62022
- return event.providers;
62023
- };
62024
-
62025
- /**
62026
- * Returns the outline for an element.
62027
- *
62028
- * @param {Element} element
62029
- */
62030
- Outline.prototype.getOutline = function(element) {
62031
- var outline;
62032
- var providers = this._getProviders();
62033
-
62034
- forEach$1(providers, function(provider) {
62035
-
62036
- if (!isFunction(provider.getOutline)) {
62037
- return;
62038
- }
62039
-
62040
- outline = outline || provider.getOutline(element);
62041
- });
62042
-
62043
- return outline;
62044
- };
62045
-
62046
- Outline.$inject = [ 'eventBus', 'styles', 'elementRegistry' ];
62047
-
62048
- var SELECTION_OUTLINE_PADDING = 6;
62049
-
62050
- /**
62051
- * @typedef {import('../../model/Types').Element} Element
62052
- *
62053
- * @typedef {import('../../core/EventBus').default} EventBus
62054
- * @typedef {import('../selection/Selection').default} Selection
62055
- * @typedef {import('../../core/Canvas').default} Canvas
62056
- */
62057
-
62058
- /**
62059
- * @class
62060
- *
62061
- * A plugin that adds an outline to shapes and connections that may be activated and styled
62062
- * via CSS classes.
62063
- *
62064
- * @param {EventBus} eventBus
62065
- * @param {Canvas} canvas
62066
- * @param {Selection} selection
62067
- */
62068
- function MultiSelectionOutline(eventBus, canvas, selection) {
62069
- this._canvas = canvas;
62070
-
62071
- var self = this;
62072
-
62073
- eventBus.on('element.changed', function(event) {
62074
- if (selection.isSelected(event.element)) {
62075
- self._updateMultiSelectionOutline(selection.get());
62076
- }
62077
- });
62078
-
62079
- eventBus.on('selection.changed', function(event) {
62080
- var newSelection = event.newSelection;
62081
-
62082
- self._updateMultiSelectionOutline(newSelection);
62083
- });
62084
- }
62085
-
62086
-
62087
-
62088
- MultiSelectionOutline.prototype._updateMultiSelectionOutline = function(selection) {
62089
- var layer = this._canvas.getLayer('selectionOutline');
62090
-
62091
- clear(layer);
62092
-
62093
- var enabled = selection.length > 1;
62094
-
62095
- var container = this._canvas.getContainer();
62096
-
62097
- classes(container)[enabled ? 'add' : 'remove']('djs-multi-select');
62098
-
62099
- if (!enabled) {
62100
- return;
62101
- }
62102
-
62103
- var bBox = addSelectionOutlinePadding(getBBox(selection));
62104
-
62105
- var rect = create$1('rect');
62106
-
62107
- attr(rect, assign$1({
62108
- rx: 3
62109
- }, bBox));
62110
-
62111
- classes(rect).add('djs-selection-outline');
62112
-
62113
- append(layer, rect);
62114
- };
62115
-
62116
-
62117
- MultiSelectionOutline.$inject = [ 'eventBus', 'canvas', 'selection' ];
62118
-
62119
- // helpers //////////
62120
-
62121
- function addSelectionOutlinePadding(bBox) {
62122
- return {
62123
- x: bBox.x - SELECTION_OUTLINE_PADDING,
62124
- y: bBox.y - SELECTION_OUTLINE_PADDING,
62125
- width: bBox.width + SELECTION_OUTLINE_PADDING * 2,
62126
- height: bBox.height + SELECTION_OUTLINE_PADDING * 2
62127
- };
62128
- }
62129
-
62130
- /**
62131
- * @type { import('didi').ModuleDeclaration }
62132
- */
62133
- var Ouline = {
62134
- __depends__: [
62135
- SelectionModule
62136
- ],
62137
- __init__: [ 'outline', 'multiSelectionOutline' ],
62138
- outline: [ 'type', Outline ],
62139
- multiSelectionOutline: [ 'type', MultiSelectionOutline ]
62140
- };
62141
-
62142
62361
  /**
62143
62362
  * @typedef {import('../../core/Types').ElementLike} Element
62144
62363
  * @typedef {import('../../core/Types').ShapeLike} Shape
@@ -62641,7 +62860,7 @@
62641
62860
  __depends__: [
62642
62861
  InteractionEventsModule$1,
62643
62862
  SelectionModule,
62644
- Ouline,
62863
+ Outline,
62645
62864
  RulesModule$1,
62646
62865
  DraggingModule,
62647
62866
  PreviewSupportModule
@@ -66129,6 +66348,20 @@
66129
66348
 
66130
66349
  var outline;
66131
66350
 
66351
+ if (isExternalLabel(element)) {
66352
+ outline = create$1('rect');
66353
+
66354
+ attr(outline, assign$1({
66355
+ x: -5,
66356
+ y: -5,
66357
+ rx: 4,
66358
+ width: element.width + DEFAULT_OFFSET * 2,
66359
+ height: element.height + DEFAULT_OFFSET * 2
66360
+ }, OUTLINE_STYLE));
66361
+
66362
+ return outline;
66363
+ }
66364
+
66132
66365
  if (isLabel(element)) {
66133
66366
  return;
66134
66367
  }
@@ -66256,7 +66489,7 @@
66256
66489
 
66257
66490
  var OutlineModule = {
66258
66491
  __depends__: [
66259
- Ouline
66492
+ Outline
66260
66493
  ],
66261
66494
  __init__: [ 'outlineProvider' ],
66262
66495
  outlineProvider: [ 'type', OutlineProvider ]
@@ -66407,6 +66640,7 @@
66407
66640
  KeyboardModule,
66408
66641
  KeyboardMoveSelectionModule,
66409
66642
  LabelEditingModule,
66643
+ LabelLink,
66410
66644
  ModelingModule,
66411
66645
  ModelingFeedbackModule,
66412
66646
  MoveModule,