@oml/markdown 0.7.0 → 0.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.
@@ -43857,7 +43857,7 @@
43857
43857
  attrs: { text: Object.assign({}, BaseLabelAttr) },
43858
43858
  propHooks(metadata) {
43859
43859
  const { label } = metadata, others = __rest(metadata, ["label"]);
43860
- if (label) {
43860
+ if (label != null) {
43861
43861
  object_exports.setByPath(others, "attrs/text/text", label);
43862
43862
  }
43863
43863
  return others;
@@ -44301,6 +44301,28 @@
44301
44301
  }
44302
44302
  });
44303
44303
  this.updatePorts();
44304
+ this.cleanCache();
44305
+ this.updateConnectedEdges();
44306
+ }
44307
+ updateConnectedEdges() {
44308
+ const graph = this.graph;
44309
+ const node = this.cell;
44310
+ const edges = graph.model.getConnectedEdges(node);
44311
+ for (let i = 0, n = edges.length; i < n; i += 1) {
44312
+ const edge = edges[i];
44313
+ const edgeView = edge.findView(graph);
44314
+ if (!edgeView || !graph.renderer.isViewMounted(edgeView)) {
44315
+ continue;
44316
+ }
44317
+ const actions = ["update"];
44318
+ if (edge.getSourceCell() === node) {
44319
+ actions.push("source");
44320
+ }
44321
+ if (edge.getTargetCell() === node) {
44322
+ actions.push("target");
44323
+ }
44324
+ graph.renderer.requestViewUpdate(edgeView, edgeView.getFlag(actions));
44325
+ }
44304
44326
  }
44305
44327
  appendPorts(ports, zIndex, refs) {
44306
44328
  const elems = ports.map((p) => this.getPortElement(p));
@@ -54374,8 +54396,11 @@
54374
54396
  this.dragRafId = null;
54375
54397
  this.transformRafId = null;
54376
54398
  this.dragPendingOffset = null;
54399
+ this.containerLocalOffsetX = 0;
54400
+ this.containerLocalOffsetY = 0;
54377
54401
  this.containerOffsetX = 0;
54378
54402
  this.containerOffsetY = 0;
54403
+ this.draggingPreviewMode = "translate";
54379
54404
  this.translatingCache = null;
54380
54405
  this.movingRouterRestoreCache = null;
54381
54406
  this.movingRouterRestoreTimer = null;
@@ -54450,9 +54475,19 @@
54450
54475
  if (this.transformRafId == null) {
54451
54476
  this.transformRafId = window.requestAnimationFrame(() => {
54452
54477
  this.transformRafId = null;
54453
- if (!this.isDragging && this.collection.length > 0) {
54454
- this.refreshSelectionBoxes();
54478
+ if (this.collection.length <= 0) {
54479
+ return;
54455
54480
  }
54481
+ if (this.isDragging) {
54482
+ this.repositionSelectionBoxesInPlace();
54483
+ if (this.options.following) {
54484
+ this.resetContainerPosition();
54485
+ } else {
54486
+ this.syncContainerPosition();
54487
+ }
54488
+ return;
54489
+ }
54490
+ this.refreshSelectionBoxes();
54456
54491
  });
54457
54492
  }
54458
54493
  }
@@ -54547,9 +54582,8 @@
54547
54582
  if (this.length) {
54548
54583
  this.unselect(this.cells, options);
54549
54584
  }
54550
- this.containerOffsetX = 0;
54551
- this.containerOffsetY = 0;
54552
- main_exports2.css(this.container, "transform", "");
54585
+ this.resetContainerPosition();
54586
+ this.draggingPreviewMode = "translate";
54553
54587
  return this;
54554
54588
  }
54555
54589
  setFilter(filter2) {
@@ -54590,6 +54624,8 @@
54590
54624
  scrollerY: 0,
54591
54625
  moving: false
54592
54626
  });
54627
+ const client = this.graph.snapToGrid(evt.clientX, evt.clientY);
54628
+ this.notifyBoxEvent("box:mousedown", evt, client.x, client.y, []);
54593
54629
  this.delegateDocumentEvents(documentEvents, evt.data);
54594
54630
  }
54595
54631
  filter(cells) {
@@ -54621,17 +54657,12 @@
54621
54657
  const action = eventData.action;
54622
54658
  switch (action) {
54623
54659
  case "selecting": {
54624
- let width2 = main_exports2.width(this.container);
54625
- let height2 = main_exports2.height(this.container);
54626
- const offset4 = main_exports2.offset(this.container);
54627
- const origin = graph.pageToLocal(offset4.left, offset4.top);
54628
- const scale2 = graph.transform.getScale();
54629
- width2 /= scale2.sx;
54630
- height2 /= scale2.sy;
54631
- const rect2 = new Rectangle(origin.x, origin.y, width2, height2);
54632
- const cells = this.getCellViewsInArea(rect2).map((view) => view.cell);
54660
+ const client = graph.snapToGrid(evt.clientX, evt.clientY);
54661
+ const rect2 = this.getSelectingRect();
54662
+ const cells = this.getCellsInArea(rect2);
54633
54663
  this.reset(cells, { batch: true });
54634
54664
  this.hideRubberband();
54665
+ this.notifyBoxEvent("box:mouseup", evt, client.x, client.y, cells);
54635
54666
  break;
54636
54667
  }
54637
54668
  case "translating": {
@@ -54639,16 +54670,13 @@
54639
54670
  if (this.dragPendingOffset) {
54640
54671
  const toApply = this.dragPendingOffset;
54641
54672
  this.dragPendingOffset = null;
54642
- this.translateSelectedNodes(toApply.dx, toApply.dy);
54643
- this.updateContainerPosition(toApply);
54673
+ this.applyDraggingPreview(toApply);
54644
54674
  }
54645
54675
  if (this.dragRafId != null) {
54646
54676
  cancelAnimationFrame(this.dragRafId);
54647
54677
  this.dragRafId = null;
54648
54678
  }
54649
- this.containerOffsetX = 0;
54650
- this.containerOffsetY = 0;
54651
- main_exports2.css(this.container, "transform", "");
54679
+ this.resetContainerPosition();
54652
54680
  if (this.movingRouterRestoreTimer) {
54653
54681
  clearTimeout(this.movingRouterRestoreTimer);
54654
54682
  this.movingRouterRestoreTimer = null;
@@ -54656,6 +54684,7 @@
54656
54684
  this.restoreMovingRouters();
54657
54685
  this.graph.model.stopBatch("move-selection");
54658
54686
  this.translatingCache = null;
54687
+ this.draggingPreviewMode = "translate";
54659
54688
  this.notifyBoxEvent("box:mouseup", evt, client.x, client.y);
54660
54689
  this.repositionSelectionBoxesInPlace();
54661
54690
  break;
@@ -54736,6 +54765,7 @@
54736
54765
  originY: client.y
54737
54766
  });
54738
54767
  this.prepareTranslatingCache();
54768
+ this.draggingPreviewMode = this.getDraggingPreviewMode();
54739
54769
  }
54740
54770
  getRestrictArea() {
54741
54771
  const restrict = this.graph.options.translating.restrict;
@@ -54910,8 +54940,7 @@
54910
54940
  const toApply = this.dragPendingOffset || { dx: 0, dy: 0 };
54911
54941
  this.dragPendingOffset = null;
54912
54942
  this.dragRafId = null;
54913
- this.translateSelectedNodes(toApply.dx, toApply.dy);
54914
- this.updateContainerPosition(toApply);
54943
+ this.applyDraggingPreview(toApply);
54915
54944
  this.boxesUpdated = true;
54916
54945
  this.isDragging = true;
54917
54946
  });
@@ -54947,6 +54976,10 @@
54947
54976
  width: Math.abs(dx),
54948
54977
  height: Math.abs(dy)
54949
54978
  });
54979
+ const client = this.graph.snapToGrid(e.clientX, e.clientY);
54980
+ const rect2 = this.getSelectingRect();
54981
+ const cells = this.getCellsInArea(rect2);
54982
+ this.notifyBoxEvent("box:mousemove", evt, client.x, client.y, cells);
54950
54983
  break;
54951
54984
  }
54952
54985
  case "translating": {
@@ -55054,10 +55087,50 @@
55054
55087
  }
55055
55088
  return views;
55056
55089
  }
55057
- notifyBoxEvent(name, e, x, y2) {
55058
- const data2 = this.getEventData(e);
55059
- const view = data2.activeView;
55060
- this.trigger(name, { e, view, x, y: y2, cell: view.cell });
55090
+ getCellsInArea(rect2) {
55091
+ return this.filter(this.getCellViewsInArea(rect2).map((view) => view.cell));
55092
+ }
55093
+ getSelectingRect() {
55094
+ let width2 = main_exports2.width(this.container);
55095
+ let height2 = main_exports2.height(this.container);
55096
+ const offset4 = main_exports2.offset(this.container);
55097
+ const origin = this.graph.pageToLocal(offset4.left, offset4.top);
55098
+ const scale2 = this.graph.transform.getScale();
55099
+ width2 /= scale2.sx;
55100
+ height2 /= scale2.sy;
55101
+ return new Rectangle(origin.x, origin.y, width2, height2);
55102
+ }
55103
+ getBoxEventCells(cells, activeView = null) {
55104
+ var _a2;
55105
+ const nodes = [];
55106
+ const edges = [];
55107
+ let view = activeView;
55108
+ (cells !== null && cells !== void 0 ? cells : this.cells).forEach((cell) => {
55109
+ const current = this.graph.getCellById(cell.id);
55110
+ if (!current) {
55111
+ return;
55112
+ }
55113
+ if (!view) {
55114
+ view = this.graph.renderer.findViewByCell(current);
55115
+ }
55116
+ if (current.isNode()) {
55117
+ nodes.push(current);
55118
+ } else if (current.isEdge()) {
55119
+ edges.push(current);
55120
+ }
55121
+ });
55122
+ return {
55123
+ view,
55124
+ cell: (_a2 = view === null || view === void 0 ? void 0 : view.cell) !== null && _a2 !== void 0 ? _a2 : null,
55125
+ nodes,
55126
+ edges
55127
+ };
55128
+ }
55129
+ notifyBoxEvent(name, e, x, y2, cells) {
55130
+ var _a2, _b;
55131
+ const activeView = (_b = (_a2 = this.getEventData(e)) === null || _a2 === void 0 ? void 0 : _a2.activeView) !== null && _b !== void 0 ? _b : null;
55132
+ const { view, cell, nodes, edges } = this.getBoxEventCells(cells, activeView);
55133
+ this.trigger(name, { e, view, x, y: y2, cell, nodes, edges });
55061
55134
  }
55062
55135
  getSelectedClassName(cell) {
55063
55136
  return this.prefixClassName(`${cell.isNode() ? "node" : "edge"}-selected`);
@@ -55123,12 +55196,50 @@
55123
55196
  main_exports2.attr(this.selectionContainer, "data-selection-length", this.collection.length);
55124
55197
  main_exports2.prepend(this.container, this.selectionContainer);
55125
55198
  }
55199
+ getDraggingPreviewMode() {
55200
+ if (!this.options.following) {
55201
+ return "translate";
55202
+ }
55203
+ const hasVisibleEdgeSelectionBox = this.collection.toArray().some((cell) => cell.isEdge() && this.canShowSelectionBox(cell));
55204
+ return hasVisibleEdgeSelectionBox ? "geometry" : "translate";
55205
+ }
55206
+ applyDraggingPreview(offset4) {
55207
+ if (offset4.dx === 0 && offset4.dy === 0) {
55208
+ return;
55209
+ }
55210
+ if (this.options.following) {
55211
+ this.translateSelectedNodes(offset4.dx, offset4.dy);
55212
+ if (this.draggingPreviewMode === "geometry") {
55213
+ this.repositionSelectionBoxesInPlace();
55214
+ this.resetContainerPosition();
55215
+ return;
55216
+ }
55217
+ }
55218
+ this.updateContainerPosition(offset4);
55219
+ }
55220
+ resetContainerPosition() {
55221
+ this.containerLocalOffsetX = 0;
55222
+ this.containerLocalOffsetY = 0;
55223
+ this.containerOffsetX = 0;
55224
+ this.containerOffsetY = 0;
55225
+ main_exports2.css(this.container, "transform", "");
55226
+ }
55227
+ syncContainerPosition() {
55228
+ const origin = this.graph.coord.localToGraphPoint(0, 0);
55229
+ const offset4 = this.graph.coord.localToGraphPoint(this.containerLocalOffsetX, this.containerLocalOffsetY);
55230
+ this.containerOffsetX = offset4.x - origin.x;
55231
+ this.containerOffsetY = offset4.y - origin.y;
55232
+ if (this.containerOffsetX === 0 && this.containerOffsetY === 0) {
55233
+ main_exports2.css(this.container, "transform", "");
55234
+ return;
55235
+ }
55236
+ main_exports2.css(this.container, "transform", `translate3d(${this.containerOffsetX}px, ${this.containerOffsetY}px, 0)`);
55237
+ }
55126
55238
  updateContainerPosition(offset4) {
55127
55239
  if (offset4.dx || offset4.dy) {
55128
- const scale2 = this.graph.transform.getScale();
55129
- this.containerOffsetX += offset4.dx * scale2.sx;
55130
- this.containerOffsetY += offset4.dy * scale2.sy;
55131
- main_exports2.css(this.container, "transform", `translate3d(${this.containerOffsetX}px, ${this.containerOffsetY}px, 0)`);
55240
+ this.containerLocalOffsetX += offset4.dx;
55241
+ this.containerLocalOffsetY += offset4.dy;
55242
+ this.syncContainerPosition();
55132
55243
  }
55133
55244
  }
55134
55245
  updateContainer() {
@@ -55993,7 +56104,7 @@
55993
56104
  this.movedMap.delete(cell);
55994
56105
  }
55995
56106
  onBoxMouseDown({ e, cell }) {
55996
- if (!this.disabled) {
56107
+ if (!this.disabled && cell) {
55997
56108
  if (this.allowMultipleSelection(e)) {
55998
56109
  this.unselect(cell);
55999
56110
  this.unselectMap.set(cell, true);