@metadev/daga 1.5.4 → 1.5.5

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.
package/Changelog.md CHANGED
@@ -6,6 +6,12 @@ List of releases and changes.
6
6
 
7
7
  ## Next release Lobera
8
8
 
9
+ ## v. 1.5.5
10
+
11
+ Date: _2024-10-02_
12
+
13
+ - Ensure that decorators are always removed [#167](https://github.com/metadevpro/daga/pull/167)
14
+
9
15
  ## v. 1.5.4
10
16
 
11
17
  Date: _2024-09-21_
@@ -3061,6 +3061,10 @@ class DiagramNodeSet extends DiagramEntitySet {
3061
3061
  while (node.ports.length > 0) {
3062
3062
  this.model.ports.remove(node.ports[0].id);
3063
3063
  }
3064
+ // remove all decorators
3065
+ while (node.decorators.length > 0) {
3066
+ this.model.decorators.remove(node.decorators[0].id);
3067
+ }
3064
3068
  // remove label
3065
3069
  if (node.label) {
3066
3070
  this.model.fields.remove(node.label.id);
@@ -3827,6 +3831,8 @@ class SetSelfRemovedCollabAction {
3827
3831
  this.canvas.updatePortsInView(...this.portIds);
3828
3832
  this.canvas.updateConnectionsInView(...this.connectionIds);
3829
3833
  this.canvas.updateFieldsInView(...this.fieldIds);
3834
+ // some of the nodes and sections may have decorators, so update them
3835
+ this.canvas.updateDecoratorsInView();
3830
3836
  }
3831
3837
  serialize() {
3832
3838
  return {
@@ -5424,11 +5430,12 @@ class DiagramEvent {
5424
5430
  * @public
5425
5431
  */
5426
5432
  class DiagramDecorator extends DiagramElement {
5427
- constructor(model, coords, width, height, priority, html, id) {
5433
+ constructor(model, rootElement, coords, width, height, priority, html, id) {
5428
5434
  if (model.objects.get(id) !== undefined) {
5429
5435
  throw new Error(`DiagramObject with id "${id}" already exists`);
5430
5436
  }
5431
5437
  super(model, id);
5438
+ this.rootElement = rootElement;
5432
5439
  this.coords = coords;
5433
5440
  this.width = width;
5434
5441
  this.height = height;
@@ -5441,7 +5448,8 @@ class DiagramDecorator extends DiagramElement {
5441
5448
  ?.select(`foreignObject#${this.id}`);
5442
5449
  }
5443
5450
  get removed() {
5444
- return this.selfRemoved;
5451
+ return (this.selfRemoved ||
5452
+ (this.rootElement !== undefined && this.rootElement.removed));
5445
5453
  }
5446
5454
  updateInView() {
5447
5455
  this.model.canvas?.updateDecoratorsInView(this.id);
@@ -5473,7 +5481,7 @@ class DiagramDecoratorSet extends DiagramEntitySet {
5473
5481
  * @private
5474
5482
  */
5475
5483
  new(rootElement, coords, width, height, priority, html, id) {
5476
- const decorator = new DiagramDecorator(this.model, coords, width, height, priority, html, id);
5484
+ const decorator = new DiagramDecorator(this.model, rootElement, coords, width, height, priority, html, id);
5477
5485
  super.add(decorator);
5478
5486
  decorator.updateInView();
5479
5487
  // add this port to its root element
@@ -5483,12 +5491,17 @@ class DiagramDecoratorSet extends DiagramEntitySet {
5483
5491
  return decorator;
5484
5492
  }
5485
5493
  remove(id) {
5486
- const object = this.get(id);
5487
- if (object) {
5494
+ const decorator = this.get(id);
5495
+ if (decorator) {
5496
+ // remove from root element
5497
+ if (decorator.rootElement instanceof DiagramNode ||
5498
+ decorator.rootElement instanceof DiagramSection) {
5499
+ removeIfExists(decorator.rootElement.decorators, decorator);
5500
+ }
5488
5501
  // remove from set of objects
5489
5502
  super.remove(id);
5490
5503
  // remove from canvas
5491
- object.updateInView();
5504
+ decorator.updateInView();
5492
5505
  }
5493
5506
  }
5494
5507
  }
@@ -5641,6 +5654,7 @@ class DiagramModel {
5641
5654
  this.connections.clear();
5642
5655
  this.fields.clear();
5643
5656
  this.objects.clear();
5657
+ this.decorators.clear();
5644
5658
  this.valueSet.resetValues();
5645
5659
  this.canvas?.updateModelInView();
5646
5660
  }