microboard-temp 0.13.31 → 0.13.33

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.
@@ -4675,11 +4675,12 @@ var conf = {
4675
4675
  DEFAULT_GAME_ITEM_DIMENSIONS: { width: 200, height: 200 },
4676
4676
  MAX_CARD_SIZE: 500,
4677
4677
  CONNECTOR_ITEM_OFFSET: 20,
4678
- FG_SPRING_K: 3,
4678
+ FG_SPRING_K: 0.2,
4679
4679
  FG_TARGET_GAP: 20,
4680
- FG_REPULSION: 400000,
4681
- FG_DAMPING: 0.9,
4682
- FG_SLEEP_THRESHOLD: 10,
4680
+ FG_REPULSION: 100,
4681
+ FG_MIN_DIST_SQ: 100,
4682
+ FG_DAMPING: 0.6,
4683
+ FG_SLEEP_THRESHOLD: 0.5,
4683
4684
  GRAVITY_G: 80,
4684
4685
  GRAVITY_G_CENTER: 120,
4685
4686
  GRAVITY_DAMPING: 0.96,
@@ -7455,11 +7456,11 @@ class SessionStorage {
7455
7456
  getFontHighlight(itemType) {
7456
7457
  return this.get(`fontHighlightColor_${itemType}`);
7457
7458
  }
7458
- setHorizontalAlignment(itemType, horizontalAlignment) {
7459
- this.set(`fontHorizontalAlignment_${itemType}`, horizontalAlignment);
7459
+ setHorisontalAlignment(itemType, horisontalAlignment) {
7460
+ this.set(`fontHorisontalAlignment_${itemType}`, horisontalAlignment);
7460
7461
  }
7461
- getHorizontalAlignment(itemType) {
7462
- return this.get(`fontHorizontalAlignment_${itemType}`);
7462
+ getHorisontalAlignment(itemType) {
7463
+ return this.get(`fontHorisontalAlignment_${itemType}`);
7463
7464
  }
7464
7465
  setVerticalAlignment(itemType, verticalAlignment) {
7465
7466
  this.set(`fontVerticalAlignment_${itemType}`, verticalAlignment);
@@ -17389,7 +17390,7 @@ class EditorContainer {
17389
17390
  break;
17390
17391
  case "setSelectionFontHighlight":
17391
17392
  case "setSelectionFontStyle":
17392
- case "setSelectionHorizontalAlignment":
17393
+ case "setSelectionHorisontalAlignment":
17393
17394
  this.applySelectionOp(op);
17394
17395
  break;
17395
17396
  case "setFontStyle":
@@ -21076,14 +21077,14 @@ class SpatialIndex {
21076
21077
  if ("index" in item && item.index) {
21077
21078
  item.removeChildItems(item.index.list());
21078
21079
  }
21080
+ this.itemsArray.splice(this.itemsArray.indexOf(item), 1);
21081
+ this.itemsIndex.remove(item);
21079
21082
  if (item.parent !== "Board") {
21080
21083
  const parentFrame = this.items.getById(item.parent);
21081
21084
  parentFrame?.removeChildItems(item);
21082
21085
  this.subject.publish(this.items);
21083
21086
  return;
21084
21087
  }
21085
- this.itemsArray.splice(this.itemsArray.indexOf(item), 1);
21086
- this.itemsIndex.remove(item);
21087
21088
  if (this.itemsArray.length === 0) {
21088
21089
  this.Mbr = new Mbr;
21089
21090
  } else {
@@ -21104,7 +21105,8 @@ class SpatialIndex {
21104
21105
  translateX: worldMatrix.translateX,
21105
21106
  translateY: worldMatrix.translateY,
21106
21107
  scaleX: worldMatrix.scaleX,
21107
- scaleY: worldMatrix.scaleY
21108
+ scaleY: worldMatrix.scaleY,
21109
+ isLocked: false
21108
21110
  };
21109
21111
  }
21110
21112
  return serialized;
@@ -21451,10 +21453,6 @@ class Items {
21451
21453
  const unmodifiedSize = size;
21452
21454
  size = 16;
21453
21455
  const tolerated = this.index.getEnclosedOrCrossed(x - size, y - size, x + size, y + size);
21454
- const groups = tolerated.filter((item) => item.itemType === "Group");
21455
- if (groups.length > 0) {
21456
- return groups;
21457
- }
21458
21456
  let enclosed = tolerated.some((item) => item instanceof Connector2) ? tolerated : this.index.getEnclosedOrCrossed(x, y, x, y);
21459
21457
  const underPointer = this.getUnderPoint(new Point(x, y), size);
21460
21458
  if (enclosed.length === 0) {
@@ -21468,7 +21466,7 @@ class Items {
21468
21466
  if (item.itemType === "Drawing" && !item.isPointNearLine(this.pointer.point)) {
21469
21467
  return acc;
21470
21468
  }
21471
- const isItemTransparent = item instanceof Shape && item?.getBackgroundColor() === "none";
21469
+ const isItemTransparent = item instanceof Shape && item.getBackgroundColor() === "none";
21472
21470
  const itemZIndex = this.getZIndex(item);
21473
21471
  const accZIndex = this.getZIndex(acc.nearest);
21474
21472
  if (itemZIndex > accZIndex && (!isItemTransparent || area === acc.area) || area < acc.area) {
@@ -21564,7 +21562,7 @@ class Items {
21564
21562
  });
21565
21563
  const childrenMap = new Map;
21566
21564
  const GroupsHTML = groups.map((group) => {
21567
- group.getChildrenIds().forEach((childId) => childrenMap.set(childId, group.getId()));
21565
+ group.getChildrenIds()?.forEach((childId) => childrenMap.set(childId, group.getId()));
21568
21566
  const html = group.renderHTML(documentFactory);
21569
21567
  translateElementBy(html, -lowestCoordinates.left, -lowestCoordinates.top);
21570
21568
  return html;
@@ -21580,7 +21578,10 @@ class Items {
21580
21578
  item.setAttribute("data-end-point-x", (endX - lowestCoordinates.left).toString());
21581
21579
  item.setAttribute("data-end-point-y", (endY - lowestCoordinates.top).toString());
21582
21580
  }
21583
- return translateElementBy(item, -lowestCoordinates.left, -lowestCoordinates.top);
21581
+ if (!childrenMap.get(item.id)) {
21582
+ return translateElementBy(item, -lowestCoordinates.left, -lowestCoordinates.top);
21583
+ }
21584
+ return item;
21584
21585
  });
21585
21586
  for (const item of restHTML) {
21586
21587
  const parentFrameId = childrenMap.get(item.id);
@@ -21994,6 +21995,20 @@ class BaseItem extends Mbr {
21994
21995
  parentMatrix.apply(c);
21995
21996
  return new Mbr(Math.min(corners[0].x, corners[1].x, corners[2].x, corners[3].x), Math.min(corners[0].y, corners[1].y, corners[2].y, corners[3].y), Math.max(corners[0].x, corners[1].x, corners[2].x, corners[3].x), Math.max(corners[0].y, corners[1].y, corners[2].y, corners[3].y));
21996
21997
  }
21998
+ hasAncestor(itemId) {
21999
+ let parentId = this.parent;
22000
+ while (parentId && parentId !== "Board") {
22001
+ if (parentId === itemId) {
22002
+ return true;
22003
+ }
22004
+ const parent = this.board.items.getById(parentId);
22005
+ if (!parent || parent.parent === parentId) {
22006
+ break;
22007
+ }
22008
+ parentId = parent.parent;
22009
+ }
22010
+ return false;
22011
+ }
21997
22012
  applyAddChildren(childIds) {
21998
22013
  if (!this.index) {
21999
22014
  return;
@@ -22001,7 +22016,7 @@ class BaseItem extends Mbr {
22001
22016
  const containerNestingMatrix = this.getNestingMatrix();
22002
22017
  childIds.forEach((childId) => {
22003
22018
  const foundItem = this.board.items.getById(childId);
22004
- if (this.parent !== childId && this.getId() !== childId) {
22019
+ if (this.parent !== childId && this.getId() !== childId && !this.hasAncestor(childId)) {
22005
22020
  if (!this.index?.getById(childId) && foundItem) {
22006
22021
  const localMatrix = foundItem.transformation.toMatrix().toLocalOf(containerNestingMatrix);
22007
22022
  this.board.items.index.remove(foundItem);
@@ -22224,8 +22239,8 @@ class BaseItem extends Mbr {
22224
22239
  }
22225
22240
  renderHTML(documentFactory) {
22226
22241
  const div = documentFactory.createElement("base-item");
22227
- const { translateX, translateY } = this.transformation.getMatrixData();
22228
- const transform = `translate(${translateX}px, ${translateY}px) scale(1, 1)`;
22242
+ const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
22243
+ const transform = `translate(${translateX}px, ${translateY}px) scale(${scaleX}, ${scaleY})`;
22229
22244
  div.style.backgroundColor = "#b2b0c3";
22230
22245
  div.id = this.getId();
22231
22246
  div.style.width = `${this.getWidth()}px`;
@@ -22496,12 +22511,14 @@ class RichText extends BaseItem {
22496
22511
  top = container.top;
22497
22512
  }
22498
22513
  const point3 = new Point(left, top);
22499
- this.getParentWorldMatrix().apply(point3);
22514
+ if (!this.isInShape || this.autoSize) {
22515
+ this.getParentWorldMatrix().apply(point3);
22516
+ }
22500
22517
  return {
22501
22518
  point: point3,
22502
22519
  width,
22503
22520
  height,
22504
- maxWidth: maxWidth ? maxWidth + 1 : undefined,
22521
+ maxWidth: maxWidth ? maxWidth : undefined,
22505
22522
  maxHeight,
22506
22523
  textScale: this.isInShape && !this.autoSize ? 1 : this.getScale()
22507
22524
  };
@@ -40189,6 +40206,7 @@ class Shape extends BaseItem {
40189
40206
  this.text.deserialize(data.text);
40190
40207
  }
40191
40208
  this.transformPath();
40209
+ this.text.updateElement();
40192
40210
  this.subject.publish(this);
40193
40211
  return this;
40194
40212
  }
@@ -40406,7 +40424,7 @@ class Shape extends BaseItem {
40406
40424
  if (Shapes[this.shapeType].useMbrUnderPointer) {
40407
40425
  return this.mbr.isUnderPoint(point5);
40408
40426
  }
40409
- if (this.text.isEmpty() && (this.backgroundOpacity === 0 || this.backgroundColor === "none" || this.backgroundColor === "")) {
40427
+ if (this.text.isEmpty() && (this.backgroundOpacity === 0 || this.backgroundColor === "none" || this.backgroundColor === "transparent" || this.backgroundColor === "")) {
40410
40428
  return this.path.isPointOverEdges(point5, tolerance);
40411
40429
  } else {
40412
40430
  return this.textContainer.isUnderPoint(point5) || this.path.isUnderPoint(point5);
@@ -40458,8 +40476,8 @@ class Shape extends BaseItem {
40458
40476
  const pathElement = Shapes[this.shapeType].path.copy().renderHTML(documentFactory);
40459
40477
  const paths = Array.isArray(pathElement) ? pathElement : [pathElement];
40460
40478
  paths.forEach((element4) => {
40461
- element4.setAttribute("fill", this.backgroundColor);
40462
- element4.setAttribute("stroke", this.borderColor);
40479
+ element4.setAttribute("fill", resolveColor(this.backgroundColor, conf.theme, "background"));
40480
+ element4.setAttribute("stroke", resolveColor(this.borderColor, conf.theme, "foreground"));
40463
40481
  element4.setAttribute("stroke-dasharray", LinePatterns[this.borderStyle].join(", "));
40464
40482
  element4.setAttribute("stroke-width", this.borderWidth.toString());
40465
40483
  element4.setAttribute("transform-origin", "0 0");
@@ -40474,8 +40492,8 @@ class Shape extends BaseItem {
40474
40492
  div.style.transform = `translate(${translateX}px, ${translateY}px) scale(${scaleX}, ${scaleY})`;
40475
40493
  div.style.position = "absolute";
40476
40494
  div.setAttribute("data-shape-type", this.shapeType);
40477
- div.setAttribute("fill", this.backgroundColor);
40478
- div.setAttribute("stroke", this.borderColor);
40495
+ div.setAttribute("fill", resolveColor(this.backgroundColor, conf.theme, "background"));
40496
+ div.setAttribute("stroke", resolveColor(this.borderColor, conf.theme, "foreground"));
40479
40497
  div.setAttribute("data-border-style", this.borderStyle);
40480
40498
  div.setAttribute("stroke-dasharray", LinePatterns[this.borderStyle].join(", "));
40481
40499
  div.setAttribute("stroke-width", this.borderWidth.toString());
@@ -40519,9 +40537,6 @@ class Shape extends BaseItem {
40519
40537
  this.text.updateElement();
40520
40538
  }
40521
40539
  transformPath() {
40522
- if (conf.isNode()) {
40523
- return;
40524
- }
40525
40540
  this.path = Shapes[this.shapeType].createPath(this.mbr);
40526
40541
  this.textContainer = Shapes[this.shapeType].textBounds.copy();
40527
40542
  this.text.setContainer(this.textContainer.copy());
@@ -43686,6 +43701,7 @@ class Group extends BaseItem {
43686
43701
  constructor(board, events, children = [], id = "") {
43687
43702
  super(board, id, undefined, true);
43688
43703
  this.events = events;
43704
+ this.canBeNested = true;
43689
43705
  this.linkTo = new LinkTo(this.id, this.events);
43690
43706
  this.transformation = new Transformation(this.id, this.events);
43691
43707
  this.transformation.subject.subscribe(() => {
@@ -43828,7 +43844,13 @@ class Group extends BaseItem {
43828
43844
  ctx.restore();
43829
43845
  }
43830
43846
  renderHTML(documentFactory) {
43831
- return documentFactory.createElement("div");
43847
+ const div = documentFactory.createElement("div");
43848
+ div.id = this.id;
43849
+ const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
43850
+ div.style.transform = `translate(${translateX}px, ${translateY}px) scale(${scaleX}, ${scaleY})`;
43851
+ div.style.position = "absolute";
43852
+ div.style.transformOrigin = "0 0";
43853
+ return div;
43832
43854
  }
43833
43855
  }
43834
43856
  // src/itemFactories.ts
@@ -47114,7 +47136,8 @@ class Select extends Tool {
47114
47136
  this.beginTimeStamp = Date.now();
47115
47137
  const selectionMbr = selection.getMbr();
47116
47138
  const selectionItems = selection.list();
47117
- this.isDownOnSelection = selectionMbr !== undefined && selectionMbr.isUnderPoint(pointer.point) && hover.every((hovered) => selectionItems.some((selected) => selected.getId() === hovered.getId()));
47139
+ const selectableHover = hover.map((item) => this.board.selection.getSelectableItem(item));
47140
+ this.isDownOnSelection = selectionMbr !== undefined && selectionMbr.isUnderPoint(pointer.point) && selectableHover.every((hovered) => hovered && selectionItems.some((selected) => selected.getId() === hovered.getId()));
47118
47141
  this.isDraggingSelection = this.isDownOnSelection;
47119
47142
  if (this.isDraggingSelection) {
47120
47143
  this.board.selection.transformationRenderBlock = true;
@@ -47440,7 +47463,7 @@ class Select extends Tool {
47440
47463
  const hovered = this.board.items.getUnderPointer();
47441
47464
  this.board.pointer.subject.publish(this.board.pointer);
47442
47465
  if (isCtrl || isShift) {
47443
- const underPointer = hovered[0];
47466
+ const underPointer = this.board.selection.getSelectableItem(hovered[0]);
47444
47467
  const isEmptySelection = this.board.selection.items.list().length === 0;
47445
47468
  if (!underPointer && !isEmptySelection && isShift) {
47446
47469
  this.board.selection.add(this.board.selection.items.list());
@@ -47456,14 +47479,6 @@ class Select extends Tool {
47456
47479
  const isNotInSelection = this.board.selection.items.findById(underPointer.getId()) === null;
47457
47480
  if (isNotInSelection) {
47458
47481
  this.board.selection.add(underPointer);
47459
- if ("index" in underPointer && underPointer.index) {
47460
- const { left, right, top, bottom } = underPointer.getMbr();
47461
- const childrenIds = underPointer.getChildrenIds();
47462
- console.log("UNDERPOINTER", underPointer);
47463
- console.log("CHILDREN", childrenIds);
47464
- const itemsInFrame = this.board.items.getEnclosedOrCrossed(left, top, right, bottom).filter((item) => childrenIds && childrenIds.includes(item.getId()));
47465
- this.board.selection.add(itemsInFrame);
47466
- }
47467
47482
  this.board.selection.setContext("EditUnderPointer");
47468
47483
  } else {
47469
47484
  this.board.selection.remove(underPointer);
@@ -47480,10 +47495,6 @@ class Select extends Tool {
47480
47495
  } else {
47481
47496
  this.board.selection.editUnderPointer();
47482
47497
  }
47483
- if (topItem2 instanceof Group) {
47484
- const groupChildren = topItem2.getChildren();
47485
- this.board.selection.add(groupChildren);
47486
- }
47487
47498
  this.board.tools.publish();
47488
47499
  this.clear();
47489
47500
  return false;
@@ -53519,10 +53530,23 @@ class BoardSelection {
53519
53530
  getMbr() {
53520
53531
  return this.items.getMbr();
53521
53532
  }
53533
+ getSelectableItem(item) {
53534
+ if (!item) {
53535
+ return null;
53536
+ }
53537
+ if (!(item instanceof BaseItem) || item.parent === "Board") {
53538
+ return item;
53539
+ }
53540
+ const parent = this.board.items.getById(item.parent);
53541
+ if (parent instanceof Group) {
53542
+ return parent;
53543
+ }
53544
+ return item;
53545
+ }
53522
53546
  selectUnderPointer() {
53523
53547
  this.removeAll();
53524
53548
  const stack = this.board.items.getUnderPointer();
53525
- const top = stack.pop();
53549
+ const top = this.getSelectableItem(stack.pop());
53526
53550
  if (top) {
53527
53551
  this.add(top);
53528
53552
  this.setTextToEdit(undefined);
@@ -53576,7 +53600,7 @@ class BoardSelection {
53576
53600
  editUnderPointer() {
53577
53601
  this.removeAll();
53578
53602
  const stack = this.board.items.getUnderPointer();
53579
- const item = stack.pop();
53603
+ const item = this.getSelectableItem(stack.pop());
53580
53604
  if (item) {
53581
53605
  this.add(item);
53582
53606
  this.setTextToEdit(undefined);
@@ -53610,7 +53634,7 @@ class BoardSelection {
53610
53634
  const textSize = tempStorage.getFontSize(item.itemType);
53611
53635
  const highlightColor = tempStorage.getFontHighlight(item.itemType);
53612
53636
  const styles = tempStorage.getFontStyles(item.itemType);
53613
- const horizontalAlignment = tempStorage.getHorizontalAlignment(item.itemType);
53637
+ const horisontalAlignment = tempStorage.getHorisontalAlignment(item.itemType);
53614
53638
  const verticalAlignment = tempStorage.getVerticalAlignment(item.itemType);
53615
53639
  if (textColor) {
53616
53640
  text5.setSelectionFontColor(textColor, "None");
@@ -53631,8 +53655,8 @@ class BoardSelection {
53631
53655
  const stylesArr = styles;
53632
53656
  text5.setSelectionFontStyle(stylesArr, "None");
53633
53657
  }
53634
- if (horizontalAlignment && !(item instanceof Sticker)) {
53635
- text5.setSelectionHorisontalAlignment(horizontalAlignment);
53658
+ if (horisontalAlignment && !(item instanceof Sticker)) {
53659
+ text5.setSelectionHorisontalAlignment(horisontalAlignment);
53636
53660
  }
53637
53661
  if (verticalAlignment && !(item instanceof Sticker)) {
53638
53662
  this.setVerticalAlignment(verticalAlignment);
@@ -53645,7 +53669,7 @@ class BoardSelection {
53645
53669
  editTextUnderPointer() {
53646
53670
  this.removeAll();
53647
53671
  const stack = this.board.items.getUnderPointer();
53648
- const top = stack.pop();
53672
+ const top = this.getSelectableItem(stack.pop());
53649
53673
  if (top) {
53650
53674
  this.add(top);
53651
53675
  this.setContext("EditTextUnderPointer");
@@ -54255,7 +54279,7 @@ class BoardSelection {
54255
54279
  selection: text5.editor.getSelection(),
54256
54280
  ops
54257
54281
  });
54258
- tempStorage.setHorizontalAlignment(item.itemType, horisontalAlignment);
54282
+ tempStorage.setHorisontalAlignment(item.itemType, horisontalAlignment);
54259
54283
  }
54260
54284
  this.emitApplied({
54261
54285
  class: "RichText",
@@ -54680,7 +54704,6 @@ class ForceGraphEngine {
54680
54704
  activeComponents = new Map;
54681
54705
  TICK_MS = 33;
54682
54706
  SYNC_MS = 300;
54683
- SOFTENING_SQ = 100 * 100;
54684
54707
  MIN_MOVE_PX = 0.05;
54685
54708
  constructor(board) {
54686
54709
  this.board = board;
@@ -54829,42 +54852,27 @@ class ForceGraphEngine {
54829
54852
  return this.board.items.listAll().filter((item) => item.itemType === "Connector");
54830
54853
  }
54831
54854
  tick() {
54832
- const dt = this.TICK_MS / 1000;
54833
54855
  const activeIds = this.getActiveNodeIds();
54834
54856
  const draggedIds = this.board.getDraggedItemIds();
54835
54857
  const allNodes = this.getNodes();
54836
- const nodes = allNodes.filter((item) => {
54837
- if (!activeIds.has(item.getId()))
54838
- return false;
54839
- if (draggedIds.has(item.getId()))
54840
- return false;
54841
- if (item.parent !== "Board" && draggedIds.has(item.parent))
54842
- return false;
54843
- return true;
54844
- });
54845
- if (nodes.length < 1)
54846
- return;
54847
54858
  const snapMap = new Map;
54848
- for (const item of nodes) {
54859
+ for (const item of allNodes) {
54860
+ if (!activeIds.has(item.getId()))
54861
+ continue;
54849
54862
  const pos = item.transformation.getTranslation();
54850
54863
  const mbr = item.getMbr();
54851
54864
  const w = Math.max(mbr.getWidth(), 1);
54852
54865
  const h2 = Math.max(mbr.getHeight(), 1);
54853
- snapMap.set(item.getId(), {
54854
- id: item.getId(),
54855
- cx: pos.x + w * 0.5,
54856
- cy: pos.y + h2 * 0.5,
54857
- w,
54858
- h: h2
54859
- });
54866
+ snapMap.set(item.getId(), { id: item.getId(), cx: pos.x + w * 0.5, cy: pos.y + h2 * 0.5, w, h: h2 });
54860
54867
  }
54861
54868
  const snap = Array.from(snapMap.values());
54869
+ if (snap.length < 1)
54870
+ return;
54862
54871
  const uf = new UnionFind;
54863
54872
  for (const connector of this.getConnectors()) {
54864
54873
  const { startItem, endItem } = connector.getConnectedItems();
54865
- if (startItem && endItem) {
54874
+ if (startItem && endItem)
54866
54875
  uf.union(startItem.getId(), endItem.getId());
54867
- }
54868
54876
  }
54869
54877
  const ax = new Map;
54870
54878
  const ay = new Map;
@@ -54882,14 +54890,13 @@ class ForceGraphEngine {
54882
54890
  continue;
54883
54891
  const dx = s2.cx - s1.cx;
54884
54892
  const dy = s2.cy - s1.cy;
54885
- const dist = Math.sqrt(dx * dx + dy * dy) + 0.001;
54893
+ const dist = Math.sqrt(dx * dx + dy * dy) || 1;
54886
54894
  const compId = this.findComponentId(s1.id);
54887
54895
  const targetGap = compId ? this.activeComponents.get(compId)?.targetGap ?? conf.FG_TARGET_GAP : conf.FG_TARGET_GAP;
54888
54896
  const targetDist = (Math.max(s1.w, s1.h) + Math.max(s2.w, s2.h)) * 0.5 + targetGap;
54889
- const stretch = dist - targetDist;
54890
- const forceMag = stretch * conf.FG_SPRING_K;
54891
- const fx = dx / dist * forceMag;
54892
- const fy = dy / dist * forceMag;
54897
+ const force = (dist - targetDist) * conf.FG_SPRING_K;
54898
+ const fx = dx / dist * force;
54899
+ const fy = dy / dist * force;
54893
54900
  ax.set(s1.id, (ax.get(s1.id) ?? 0) + fx);
54894
54901
  ay.set(s1.id, (ay.get(s1.id) ?? 0) + fy);
54895
54902
  ax.set(s2.id, (ax.get(s2.id) ?? 0) - fx);
@@ -54903,35 +54910,35 @@ class ForceGraphEngine {
54903
54910
  continue;
54904
54911
  const dx = s2.cx - s1.cx;
54905
54912
  const dy = s2.cy - s1.cy;
54906
- const centerDist = Math.sqrt(dx * dx + dy * dy) + 0.001;
54907
- const r1 = Math.max(s1.w, s1.h) * 0.5;
54908
- const r2 = Math.max(s2.w, s2.h) * 0.5;
54909
- const edgeDist = Math.max(centerDist - r1 - r2, 1);
54910
- const repMag = conf.FG_REPULSION / (edgeDist * edgeDist + this.SOFTENING_SQ);
54911
- const fx = dx / centerDist * repMag;
54912
- const fy = dy / centerDist * repMag;
54913
- ax.set(s1.id, (ax.get(s1.id) ?? 0) - fx);
54914
- ay.set(s1.id, (ay.get(s1.id) ?? 0) - fy);
54915
- ax.set(s2.id, (ax.get(s2.id) ?? 0) + fx);
54916
- ay.set(s2.id, (ay.get(s2.id) ?? 0) + fy);
54913
+ const distSq = Math.max(dx * dx + dy * dy, conf.FG_MIN_DIST_SQ);
54914
+ const force = conf.FG_REPULSION / distSq;
54915
+ ax.set(s1.id, (ax.get(s1.id) ?? 0) - dx * force);
54916
+ ay.set(s1.id, (ay.get(s1.id) ?? 0) - dy * force);
54917
+ ax.set(s2.id, (ax.get(s2.id) ?? 0) + dx * force);
54918
+ ay.set(s2.id, (ay.get(s2.id) ?? 0) + dy * force);
54917
54919
  }
54918
54920
  }
54919
54921
  let totalEnergy = 0;
54920
- for (const item of nodes) {
54922
+ for (const item of allNodes) {
54921
54923
  const id = item.getId();
54922
- if (!this.velocities.has(id)) {
54924
+ if (!activeIds.has(id))
54925
+ continue;
54926
+ if (!this.velocities.has(id))
54923
54927
  this.velocities.set(id, { vx: 0, vy: 0 });
54924
- }
54925
54928
  const vel = this.velocities.get(id);
54926
- vel.vx = (vel.vx + (ax.get(id) ?? 0) * dt) * conf.FG_DAMPING;
54927
- vel.vy = (vel.vy + (ay.get(id) ?? 0) * dt) * conf.FG_DAMPING;
54928
- totalEnergy += vel.vx * vel.vx + vel.vy * vel.vy;
54929
- const moveX = vel.vx * dt;
54930
- const moveY = vel.vy * dt;
54931
- if (Math.abs(moveX) >= this.MIN_MOVE_PX || Math.abs(moveY) >= this.MIN_MOVE_PX) {
54929
+ const isDragged = draggedIds.has(id) || item.parent !== "Board" && draggedIds.has(item.parent);
54930
+ if (isDragged) {
54931
+ vel.vx = 0;
54932
+ vel.vy = 0;
54933
+ continue;
54934
+ }
54935
+ vel.vx = (vel.vx + (ax.get(id) ?? 0)) * conf.FG_DAMPING;
54936
+ vel.vy = (vel.vy + (ay.get(id) ?? 0)) * conf.FG_DAMPING;
54937
+ totalEnergy += Math.abs(vel.vx) + Math.abs(vel.vy);
54938
+ if (Math.abs(vel.vx) >= this.MIN_MOVE_PX || Math.abs(vel.vy) >= this.MIN_MOVE_PX) {
54932
54939
  item.transformation.applyMatrixSilent({
54933
- translateX: moveX,
54934
- translateY: moveY,
54940
+ translateX: vel.vx,
54941
+ translateY: vel.vy,
54935
54942
  scaleX: 1,
54936
54943
  scaleY: 1,
54937
54944
  shearX: 0,
@@ -55192,9 +55199,10 @@ class Board {
55192
55199
  if (!item || !(item instanceof Group)) {
55193
55200
  return;
55194
55201
  }
55195
- item.getChildren().forEach((item2) => {
55196
- item2.transformation.isLocked = false;
55197
- item2.parent = "Board";
55202
+ const children = [...item.getChildren()];
55203
+ item.applyRemoveChildren(children.map((child) => child.getId()));
55204
+ children.forEach((child) => {
55205
+ child.transformation.isLocked = false;
55198
55206
  });
55199
55207
  item.transformation.isLocked = false;
55200
55208
  const removedItems = [];
@@ -55209,9 +55217,7 @@ class Board {
55209
55217
  if (!item || !(item instanceof Group)) {
55210
55218
  return;
55211
55219
  }
55212
- item.getChildren().forEach((item2) => {
55213
- item2.parent = "Board";
55214
- });
55220
+ item.applyRemoveChildren(item.getChildrenIds());
55215
55221
  const removedItems = [];
55216
55222
  this.findItemAndApply(op.item, (item2) => {
55217
55223
  this.index.remove(item2);