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.
@@ -4495,11 +4495,12 @@ var conf = {
4495
4495
  DEFAULT_GAME_ITEM_DIMENSIONS: { width: 200, height: 200 },
4496
4496
  MAX_CARD_SIZE: 500,
4497
4497
  CONNECTOR_ITEM_OFFSET: 20,
4498
- FG_SPRING_K: 3,
4498
+ FG_SPRING_K: 0.2,
4499
4499
  FG_TARGET_GAP: 20,
4500
- FG_REPULSION: 400000,
4501
- FG_DAMPING: 0.9,
4502
- FG_SLEEP_THRESHOLD: 10,
4500
+ FG_REPULSION: 100,
4501
+ FG_MIN_DIST_SQ: 100,
4502
+ FG_DAMPING: 0.6,
4503
+ FG_SLEEP_THRESHOLD: 0.5,
4503
4504
  GRAVITY_G: 80,
4504
4505
  GRAVITY_G_CENTER: 120,
4505
4506
  GRAVITY_DAMPING: 0.96,
@@ -7275,11 +7276,11 @@ class SessionStorage {
7275
7276
  getFontHighlight(itemType) {
7276
7277
  return this.get(`fontHighlightColor_${itemType}`);
7277
7278
  }
7278
- setHorizontalAlignment(itemType, horizontalAlignment) {
7279
- this.set(`fontHorizontalAlignment_${itemType}`, horizontalAlignment);
7279
+ setHorisontalAlignment(itemType, horisontalAlignment) {
7280
+ this.set(`fontHorisontalAlignment_${itemType}`, horisontalAlignment);
7280
7281
  }
7281
- getHorizontalAlignment(itemType) {
7282
- return this.get(`fontHorizontalAlignment_${itemType}`);
7282
+ getHorisontalAlignment(itemType) {
7283
+ return this.get(`fontHorisontalAlignment_${itemType}`);
7283
7284
  }
7284
7285
  setVerticalAlignment(itemType, verticalAlignment) {
7285
7286
  this.set(`fontVerticalAlignment_${itemType}`, verticalAlignment);
@@ -17218,7 +17219,7 @@ class EditorContainer {
17218
17219
  break;
17219
17220
  case "setSelectionFontHighlight":
17220
17221
  case "setSelectionFontStyle":
17221
- case "setSelectionHorizontalAlignment":
17222
+ case "setSelectionHorisontalAlignment":
17222
17223
  this.applySelectionOp(op);
17223
17224
  break;
17224
17225
  case "setFontStyle":
@@ -20905,14 +20906,14 @@ class SpatialIndex {
20905
20906
  if ("index" in item && item.index) {
20906
20907
  item.removeChildItems(item.index.list());
20907
20908
  }
20909
+ this.itemsArray.splice(this.itemsArray.indexOf(item), 1);
20910
+ this.itemsIndex.remove(item);
20908
20911
  if (item.parent !== "Board") {
20909
20912
  const parentFrame = this.items.getById(item.parent);
20910
20913
  parentFrame?.removeChildItems(item);
20911
20914
  this.subject.publish(this.items);
20912
20915
  return;
20913
20916
  }
20914
- this.itemsArray.splice(this.itemsArray.indexOf(item), 1);
20915
- this.itemsIndex.remove(item);
20916
20917
  if (this.itemsArray.length === 0) {
20917
20918
  this.Mbr = new Mbr;
20918
20919
  } else {
@@ -20933,7 +20934,8 @@ class SpatialIndex {
20933
20934
  translateX: worldMatrix.translateX,
20934
20935
  translateY: worldMatrix.translateY,
20935
20936
  scaleX: worldMatrix.scaleX,
20936
- scaleY: worldMatrix.scaleY
20937
+ scaleY: worldMatrix.scaleY,
20938
+ isLocked: false
20937
20939
  };
20938
20940
  }
20939
20941
  return serialized;
@@ -21280,10 +21282,6 @@ class Items {
21280
21282
  const unmodifiedSize = size;
21281
21283
  size = 16;
21282
21284
  const tolerated = this.index.getEnclosedOrCrossed(x - size, y - size, x + size, y + size);
21283
- const groups = tolerated.filter((item) => item.itemType === "Group");
21284
- if (groups.length > 0) {
21285
- return groups;
21286
- }
21287
21285
  let enclosed = tolerated.some((item) => item instanceof Connector2) ? tolerated : this.index.getEnclosedOrCrossed(x, y, x, y);
21288
21286
  const underPointer = this.getUnderPoint(new Point(x, y), size);
21289
21287
  if (enclosed.length === 0) {
@@ -21297,7 +21295,7 @@ class Items {
21297
21295
  if (item.itemType === "Drawing" && !item.isPointNearLine(this.pointer.point)) {
21298
21296
  return acc;
21299
21297
  }
21300
- const isItemTransparent = item instanceof Shape && item?.getBackgroundColor() === "none";
21298
+ const isItemTransparent = item instanceof Shape && item.getBackgroundColor() === "none";
21301
21299
  const itemZIndex = this.getZIndex(item);
21302
21300
  const accZIndex = this.getZIndex(acc.nearest);
21303
21301
  if (itemZIndex > accZIndex && (!isItemTransparent || area === acc.area) || area < acc.area) {
@@ -21393,7 +21391,7 @@ class Items {
21393
21391
  });
21394
21392
  const childrenMap = new Map;
21395
21393
  const GroupsHTML = groups.map((group) => {
21396
- group.getChildrenIds().forEach((childId) => childrenMap.set(childId, group.getId()));
21394
+ group.getChildrenIds()?.forEach((childId) => childrenMap.set(childId, group.getId()));
21397
21395
  const html = group.renderHTML(documentFactory);
21398
21396
  translateElementBy(html, -lowestCoordinates.left, -lowestCoordinates.top);
21399
21397
  return html;
@@ -21409,7 +21407,10 @@ class Items {
21409
21407
  item.setAttribute("data-end-point-x", (endX - lowestCoordinates.left).toString());
21410
21408
  item.setAttribute("data-end-point-y", (endY - lowestCoordinates.top).toString());
21411
21409
  }
21412
- return translateElementBy(item, -lowestCoordinates.left, -lowestCoordinates.top);
21410
+ if (!childrenMap.get(item.id)) {
21411
+ return translateElementBy(item, -lowestCoordinates.left, -lowestCoordinates.top);
21412
+ }
21413
+ return item;
21413
21414
  });
21414
21415
  for (const item of restHTML) {
21415
21416
  const parentFrameId = childrenMap.get(item.id);
@@ -21823,6 +21824,20 @@ class BaseItem extends Mbr {
21823
21824
  parentMatrix.apply(c);
21824
21825
  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));
21825
21826
  }
21827
+ hasAncestor(itemId) {
21828
+ let parentId = this.parent;
21829
+ while (parentId && parentId !== "Board") {
21830
+ if (parentId === itemId) {
21831
+ return true;
21832
+ }
21833
+ const parent = this.board.items.getById(parentId);
21834
+ if (!parent || parent.parent === parentId) {
21835
+ break;
21836
+ }
21837
+ parentId = parent.parent;
21838
+ }
21839
+ return false;
21840
+ }
21826
21841
  applyAddChildren(childIds) {
21827
21842
  if (!this.index) {
21828
21843
  return;
@@ -21830,7 +21845,7 @@ class BaseItem extends Mbr {
21830
21845
  const containerNestingMatrix = this.getNestingMatrix();
21831
21846
  childIds.forEach((childId) => {
21832
21847
  const foundItem = this.board.items.getById(childId);
21833
- if (this.parent !== childId && this.getId() !== childId) {
21848
+ if (this.parent !== childId && this.getId() !== childId && !this.hasAncestor(childId)) {
21834
21849
  if (!this.index?.getById(childId) && foundItem) {
21835
21850
  const localMatrix = foundItem.transformation.toMatrix().toLocalOf(containerNestingMatrix);
21836
21851
  this.board.items.index.remove(foundItem);
@@ -22053,8 +22068,8 @@ class BaseItem extends Mbr {
22053
22068
  }
22054
22069
  renderHTML(documentFactory) {
22055
22070
  const div = documentFactory.createElement("base-item");
22056
- const { translateX, translateY } = this.transformation.getMatrixData();
22057
- const transform = `translate(${translateX}px, ${translateY}px) scale(1, 1)`;
22071
+ const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
22072
+ const transform = `translate(${translateX}px, ${translateY}px) scale(${scaleX}, ${scaleY})`;
22058
22073
  div.style.backgroundColor = "#b2b0c3";
22059
22074
  div.id = this.getId();
22060
22075
  div.style.width = `${this.getWidth()}px`;
@@ -22325,12 +22340,14 @@ class RichText extends BaseItem {
22325
22340
  top = container.top;
22326
22341
  }
22327
22342
  const point3 = new Point(left, top);
22328
- this.getParentWorldMatrix().apply(point3);
22343
+ if (!this.isInShape || this.autoSize) {
22344
+ this.getParentWorldMatrix().apply(point3);
22345
+ }
22329
22346
  return {
22330
22347
  point: point3,
22331
22348
  width,
22332
22349
  height,
22333
- maxWidth: maxWidth ? maxWidth + 1 : undefined,
22350
+ maxWidth: maxWidth ? maxWidth : undefined,
22334
22351
  maxHeight,
22335
22352
  textScale: this.isInShape && !this.autoSize ? 1 : this.getScale()
22336
22353
  };
@@ -40018,6 +40035,7 @@ class Shape extends BaseItem {
40018
40035
  this.text.deserialize(data.text);
40019
40036
  }
40020
40037
  this.transformPath();
40038
+ this.text.updateElement();
40021
40039
  this.subject.publish(this);
40022
40040
  return this;
40023
40041
  }
@@ -40235,7 +40253,7 @@ class Shape extends BaseItem {
40235
40253
  if (Shapes[this.shapeType].useMbrUnderPointer) {
40236
40254
  return this.mbr.isUnderPoint(point5);
40237
40255
  }
40238
- if (this.text.isEmpty() && (this.backgroundOpacity === 0 || this.backgroundColor === "none" || this.backgroundColor === "")) {
40256
+ if (this.text.isEmpty() && (this.backgroundOpacity === 0 || this.backgroundColor === "none" || this.backgroundColor === "transparent" || this.backgroundColor === "")) {
40239
40257
  return this.path.isPointOverEdges(point5, tolerance);
40240
40258
  } else {
40241
40259
  return this.textContainer.isUnderPoint(point5) || this.path.isUnderPoint(point5);
@@ -40287,8 +40305,8 @@ class Shape extends BaseItem {
40287
40305
  const pathElement = Shapes[this.shapeType].path.copy().renderHTML(documentFactory);
40288
40306
  const paths = Array.isArray(pathElement) ? pathElement : [pathElement];
40289
40307
  paths.forEach((element4) => {
40290
- element4.setAttribute("fill", this.backgroundColor);
40291
- element4.setAttribute("stroke", this.borderColor);
40308
+ element4.setAttribute("fill", resolveColor(this.backgroundColor, conf.theme, "background"));
40309
+ element4.setAttribute("stroke", resolveColor(this.borderColor, conf.theme, "foreground"));
40292
40310
  element4.setAttribute("stroke-dasharray", LinePatterns[this.borderStyle].join(", "));
40293
40311
  element4.setAttribute("stroke-width", this.borderWidth.toString());
40294
40312
  element4.setAttribute("transform-origin", "0 0");
@@ -40303,8 +40321,8 @@ class Shape extends BaseItem {
40303
40321
  div.style.transform = `translate(${translateX}px, ${translateY}px) scale(${scaleX}, ${scaleY})`;
40304
40322
  div.style.position = "absolute";
40305
40323
  div.setAttribute("data-shape-type", this.shapeType);
40306
- div.setAttribute("fill", this.backgroundColor);
40307
- div.setAttribute("stroke", this.borderColor);
40324
+ div.setAttribute("fill", resolveColor(this.backgroundColor, conf.theme, "background"));
40325
+ div.setAttribute("stroke", resolveColor(this.borderColor, conf.theme, "foreground"));
40308
40326
  div.setAttribute("data-border-style", this.borderStyle);
40309
40327
  div.setAttribute("stroke-dasharray", LinePatterns[this.borderStyle].join(", "));
40310
40328
  div.setAttribute("stroke-width", this.borderWidth.toString());
@@ -40348,9 +40366,6 @@ class Shape extends BaseItem {
40348
40366
  this.text.updateElement();
40349
40367
  }
40350
40368
  transformPath() {
40351
- if (conf.isNode()) {
40352
- return;
40353
- }
40354
40369
  this.path = Shapes[this.shapeType].createPath(this.mbr);
40355
40370
  this.textContainer = Shapes[this.shapeType].textBounds.copy();
40356
40371
  this.text.setContainer(this.textContainer.copy());
@@ -43515,6 +43530,7 @@ class Group extends BaseItem {
43515
43530
  constructor(board, events, children = [], id = "") {
43516
43531
  super(board, id, undefined, true);
43517
43532
  this.events = events;
43533
+ this.canBeNested = true;
43518
43534
  this.linkTo = new LinkTo(this.id, this.events);
43519
43535
  this.transformation = new Transformation(this.id, this.events);
43520
43536
  this.transformation.subject.subscribe(() => {
@@ -43657,7 +43673,13 @@ class Group extends BaseItem {
43657
43673
  ctx.restore();
43658
43674
  }
43659
43675
  renderHTML(documentFactory) {
43660
- return documentFactory.createElement("div");
43676
+ const div = documentFactory.createElement("div");
43677
+ div.id = this.id;
43678
+ const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
43679
+ div.style.transform = `translate(${translateX}px, ${translateY}px) scale(${scaleX}, ${scaleY})`;
43680
+ div.style.position = "absolute";
43681
+ div.style.transformOrigin = "0 0";
43682
+ return div;
43661
43683
  }
43662
43684
  }
43663
43685
  // src/itemFactories.ts
@@ -46943,7 +46965,8 @@ class Select extends Tool {
46943
46965
  this.beginTimeStamp = Date.now();
46944
46966
  const selectionMbr = selection.getMbr();
46945
46967
  const selectionItems = selection.list();
46946
- this.isDownOnSelection = selectionMbr !== undefined && selectionMbr.isUnderPoint(pointer.point) && hover.every((hovered) => selectionItems.some((selected) => selected.getId() === hovered.getId()));
46968
+ const selectableHover = hover.map((item) => this.board.selection.getSelectableItem(item));
46969
+ this.isDownOnSelection = selectionMbr !== undefined && selectionMbr.isUnderPoint(pointer.point) && selectableHover.every((hovered) => hovered && selectionItems.some((selected) => selected.getId() === hovered.getId()));
46947
46970
  this.isDraggingSelection = this.isDownOnSelection;
46948
46971
  if (this.isDraggingSelection) {
46949
46972
  this.board.selection.transformationRenderBlock = true;
@@ -47269,7 +47292,7 @@ class Select extends Tool {
47269
47292
  const hovered = this.board.items.getUnderPointer();
47270
47293
  this.board.pointer.subject.publish(this.board.pointer);
47271
47294
  if (isCtrl || isShift) {
47272
- const underPointer = hovered[0];
47295
+ const underPointer = this.board.selection.getSelectableItem(hovered[0]);
47273
47296
  const isEmptySelection = this.board.selection.items.list().length === 0;
47274
47297
  if (!underPointer && !isEmptySelection && isShift) {
47275
47298
  this.board.selection.add(this.board.selection.items.list());
@@ -47285,14 +47308,6 @@ class Select extends Tool {
47285
47308
  const isNotInSelection = this.board.selection.items.findById(underPointer.getId()) === null;
47286
47309
  if (isNotInSelection) {
47287
47310
  this.board.selection.add(underPointer);
47288
- if ("index" in underPointer && underPointer.index) {
47289
- const { left, right, top, bottom } = underPointer.getMbr();
47290
- const childrenIds = underPointer.getChildrenIds();
47291
- console.log("UNDERPOINTER", underPointer);
47292
- console.log("CHILDREN", childrenIds);
47293
- const itemsInFrame = this.board.items.getEnclosedOrCrossed(left, top, right, bottom).filter((item) => childrenIds && childrenIds.includes(item.getId()));
47294
- this.board.selection.add(itemsInFrame);
47295
- }
47296
47311
  this.board.selection.setContext("EditUnderPointer");
47297
47312
  } else {
47298
47313
  this.board.selection.remove(underPointer);
@@ -47309,10 +47324,6 @@ class Select extends Tool {
47309
47324
  } else {
47310
47325
  this.board.selection.editUnderPointer();
47311
47326
  }
47312
- if (topItem2 instanceof Group) {
47313
- const groupChildren = topItem2.getChildren();
47314
- this.board.selection.add(groupChildren);
47315
- }
47316
47327
  this.board.tools.publish();
47317
47328
  this.clear();
47318
47329
  return false;
@@ -53348,10 +53359,23 @@ class BoardSelection {
53348
53359
  getMbr() {
53349
53360
  return this.items.getMbr();
53350
53361
  }
53362
+ getSelectableItem(item) {
53363
+ if (!item) {
53364
+ return null;
53365
+ }
53366
+ if (!(item instanceof BaseItem) || item.parent === "Board") {
53367
+ return item;
53368
+ }
53369
+ const parent = this.board.items.getById(item.parent);
53370
+ if (parent instanceof Group) {
53371
+ return parent;
53372
+ }
53373
+ return item;
53374
+ }
53351
53375
  selectUnderPointer() {
53352
53376
  this.removeAll();
53353
53377
  const stack = this.board.items.getUnderPointer();
53354
- const top = stack.pop();
53378
+ const top = this.getSelectableItem(stack.pop());
53355
53379
  if (top) {
53356
53380
  this.add(top);
53357
53381
  this.setTextToEdit(undefined);
@@ -53405,7 +53429,7 @@ class BoardSelection {
53405
53429
  editUnderPointer() {
53406
53430
  this.removeAll();
53407
53431
  const stack = this.board.items.getUnderPointer();
53408
- const item = stack.pop();
53432
+ const item = this.getSelectableItem(stack.pop());
53409
53433
  if (item) {
53410
53434
  this.add(item);
53411
53435
  this.setTextToEdit(undefined);
@@ -53439,7 +53463,7 @@ class BoardSelection {
53439
53463
  const textSize = tempStorage.getFontSize(item.itemType);
53440
53464
  const highlightColor = tempStorage.getFontHighlight(item.itemType);
53441
53465
  const styles = tempStorage.getFontStyles(item.itemType);
53442
- const horizontalAlignment = tempStorage.getHorizontalAlignment(item.itemType);
53466
+ const horisontalAlignment = tempStorage.getHorisontalAlignment(item.itemType);
53443
53467
  const verticalAlignment = tempStorage.getVerticalAlignment(item.itemType);
53444
53468
  if (textColor) {
53445
53469
  text5.setSelectionFontColor(textColor, "None");
@@ -53460,8 +53484,8 @@ class BoardSelection {
53460
53484
  const stylesArr = styles;
53461
53485
  text5.setSelectionFontStyle(stylesArr, "None");
53462
53486
  }
53463
- if (horizontalAlignment && !(item instanceof Sticker)) {
53464
- text5.setSelectionHorisontalAlignment(horizontalAlignment);
53487
+ if (horisontalAlignment && !(item instanceof Sticker)) {
53488
+ text5.setSelectionHorisontalAlignment(horisontalAlignment);
53465
53489
  }
53466
53490
  if (verticalAlignment && !(item instanceof Sticker)) {
53467
53491
  this.setVerticalAlignment(verticalAlignment);
@@ -53474,7 +53498,7 @@ class BoardSelection {
53474
53498
  editTextUnderPointer() {
53475
53499
  this.removeAll();
53476
53500
  const stack = this.board.items.getUnderPointer();
53477
- const top = stack.pop();
53501
+ const top = this.getSelectableItem(stack.pop());
53478
53502
  if (top) {
53479
53503
  this.add(top);
53480
53504
  this.setContext("EditTextUnderPointer");
@@ -54084,7 +54108,7 @@ class BoardSelection {
54084
54108
  selection: text5.editor.getSelection(),
54085
54109
  ops
54086
54110
  });
54087
- tempStorage.setHorizontalAlignment(item.itemType, horisontalAlignment);
54111
+ tempStorage.setHorisontalAlignment(item.itemType, horisontalAlignment);
54088
54112
  }
54089
54113
  this.emitApplied({
54090
54114
  class: "RichText",
@@ -54509,7 +54533,6 @@ class ForceGraphEngine {
54509
54533
  activeComponents = new Map;
54510
54534
  TICK_MS = 33;
54511
54535
  SYNC_MS = 300;
54512
- SOFTENING_SQ = 100 * 100;
54513
54536
  MIN_MOVE_PX = 0.05;
54514
54537
  constructor(board) {
54515
54538
  this.board = board;
@@ -54658,42 +54681,27 @@ class ForceGraphEngine {
54658
54681
  return this.board.items.listAll().filter((item) => item.itemType === "Connector");
54659
54682
  }
54660
54683
  tick() {
54661
- const dt = this.TICK_MS / 1000;
54662
54684
  const activeIds = this.getActiveNodeIds();
54663
54685
  const draggedIds = this.board.getDraggedItemIds();
54664
54686
  const allNodes = this.getNodes();
54665
- const nodes = allNodes.filter((item) => {
54666
- if (!activeIds.has(item.getId()))
54667
- return false;
54668
- if (draggedIds.has(item.getId()))
54669
- return false;
54670
- if (item.parent !== "Board" && draggedIds.has(item.parent))
54671
- return false;
54672
- return true;
54673
- });
54674
- if (nodes.length < 1)
54675
- return;
54676
54687
  const snapMap = new Map;
54677
- for (const item of nodes) {
54688
+ for (const item of allNodes) {
54689
+ if (!activeIds.has(item.getId()))
54690
+ continue;
54678
54691
  const pos = item.transformation.getTranslation();
54679
54692
  const mbr = item.getMbr();
54680
54693
  const w = Math.max(mbr.getWidth(), 1);
54681
54694
  const h2 = Math.max(mbr.getHeight(), 1);
54682
- snapMap.set(item.getId(), {
54683
- id: item.getId(),
54684
- cx: pos.x + w * 0.5,
54685
- cy: pos.y + h2 * 0.5,
54686
- w,
54687
- h: h2
54688
- });
54695
+ snapMap.set(item.getId(), { id: item.getId(), cx: pos.x + w * 0.5, cy: pos.y + h2 * 0.5, w, h: h2 });
54689
54696
  }
54690
54697
  const snap = Array.from(snapMap.values());
54698
+ if (snap.length < 1)
54699
+ return;
54691
54700
  const uf = new UnionFind;
54692
54701
  for (const connector of this.getConnectors()) {
54693
54702
  const { startItem, endItem } = connector.getConnectedItems();
54694
- if (startItem && endItem) {
54703
+ if (startItem && endItem)
54695
54704
  uf.union(startItem.getId(), endItem.getId());
54696
- }
54697
54705
  }
54698
54706
  const ax = new Map;
54699
54707
  const ay = new Map;
@@ -54711,14 +54719,13 @@ class ForceGraphEngine {
54711
54719
  continue;
54712
54720
  const dx = s2.cx - s1.cx;
54713
54721
  const dy = s2.cy - s1.cy;
54714
- const dist = Math.sqrt(dx * dx + dy * dy) + 0.001;
54722
+ const dist = Math.sqrt(dx * dx + dy * dy) || 1;
54715
54723
  const compId = this.findComponentId(s1.id);
54716
54724
  const targetGap = compId ? this.activeComponents.get(compId)?.targetGap ?? conf.FG_TARGET_GAP : conf.FG_TARGET_GAP;
54717
54725
  const targetDist = (Math.max(s1.w, s1.h) + Math.max(s2.w, s2.h)) * 0.5 + targetGap;
54718
- const stretch = dist - targetDist;
54719
- const forceMag = stretch * conf.FG_SPRING_K;
54720
- const fx = dx / dist * forceMag;
54721
- const fy = dy / dist * forceMag;
54726
+ const force = (dist - targetDist) * conf.FG_SPRING_K;
54727
+ const fx = dx / dist * force;
54728
+ const fy = dy / dist * force;
54722
54729
  ax.set(s1.id, (ax.get(s1.id) ?? 0) + fx);
54723
54730
  ay.set(s1.id, (ay.get(s1.id) ?? 0) + fy);
54724
54731
  ax.set(s2.id, (ax.get(s2.id) ?? 0) - fx);
@@ -54732,35 +54739,35 @@ class ForceGraphEngine {
54732
54739
  continue;
54733
54740
  const dx = s2.cx - s1.cx;
54734
54741
  const dy = s2.cy - s1.cy;
54735
- const centerDist = Math.sqrt(dx * dx + dy * dy) + 0.001;
54736
- const r1 = Math.max(s1.w, s1.h) * 0.5;
54737
- const r2 = Math.max(s2.w, s2.h) * 0.5;
54738
- const edgeDist = Math.max(centerDist - r1 - r2, 1);
54739
- const repMag = conf.FG_REPULSION / (edgeDist * edgeDist + this.SOFTENING_SQ);
54740
- const fx = dx / centerDist * repMag;
54741
- const fy = dy / centerDist * repMag;
54742
- ax.set(s1.id, (ax.get(s1.id) ?? 0) - fx);
54743
- ay.set(s1.id, (ay.get(s1.id) ?? 0) - fy);
54744
- ax.set(s2.id, (ax.get(s2.id) ?? 0) + fx);
54745
- ay.set(s2.id, (ay.get(s2.id) ?? 0) + fy);
54742
+ const distSq = Math.max(dx * dx + dy * dy, conf.FG_MIN_DIST_SQ);
54743
+ const force = conf.FG_REPULSION / distSq;
54744
+ ax.set(s1.id, (ax.get(s1.id) ?? 0) - dx * force);
54745
+ ay.set(s1.id, (ay.get(s1.id) ?? 0) - dy * force);
54746
+ ax.set(s2.id, (ax.get(s2.id) ?? 0) + dx * force);
54747
+ ay.set(s2.id, (ay.get(s2.id) ?? 0) + dy * force);
54746
54748
  }
54747
54749
  }
54748
54750
  let totalEnergy = 0;
54749
- for (const item of nodes) {
54751
+ for (const item of allNodes) {
54750
54752
  const id = item.getId();
54751
- if (!this.velocities.has(id)) {
54753
+ if (!activeIds.has(id))
54754
+ continue;
54755
+ if (!this.velocities.has(id))
54752
54756
  this.velocities.set(id, { vx: 0, vy: 0 });
54753
- }
54754
54757
  const vel = this.velocities.get(id);
54755
- vel.vx = (vel.vx + (ax.get(id) ?? 0) * dt) * conf.FG_DAMPING;
54756
- vel.vy = (vel.vy + (ay.get(id) ?? 0) * dt) * conf.FG_DAMPING;
54757
- totalEnergy += vel.vx * vel.vx + vel.vy * vel.vy;
54758
- const moveX = vel.vx * dt;
54759
- const moveY = vel.vy * dt;
54760
- if (Math.abs(moveX) >= this.MIN_MOVE_PX || Math.abs(moveY) >= this.MIN_MOVE_PX) {
54758
+ const isDragged = draggedIds.has(id) || item.parent !== "Board" && draggedIds.has(item.parent);
54759
+ if (isDragged) {
54760
+ vel.vx = 0;
54761
+ vel.vy = 0;
54762
+ continue;
54763
+ }
54764
+ vel.vx = (vel.vx + (ax.get(id) ?? 0)) * conf.FG_DAMPING;
54765
+ vel.vy = (vel.vy + (ay.get(id) ?? 0)) * conf.FG_DAMPING;
54766
+ totalEnergy += Math.abs(vel.vx) + Math.abs(vel.vy);
54767
+ if (Math.abs(vel.vx) >= this.MIN_MOVE_PX || Math.abs(vel.vy) >= this.MIN_MOVE_PX) {
54761
54768
  item.transformation.applyMatrixSilent({
54762
- translateX: moveX,
54763
- translateY: moveY,
54769
+ translateX: vel.vx,
54770
+ translateY: vel.vy,
54764
54771
  scaleX: 1,
54765
54772
  scaleY: 1,
54766
54773
  shearX: 0,
@@ -55021,9 +55028,10 @@ class Board {
55021
55028
  if (!item || !(item instanceof Group)) {
55022
55029
  return;
55023
55030
  }
55024
- item.getChildren().forEach((item2) => {
55025
- item2.transformation.isLocked = false;
55026
- item2.parent = "Board";
55031
+ const children = [...item.getChildren()];
55032
+ item.applyRemoveChildren(children.map((child) => child.getId()));
55033
+ children.forEach((child) => {
55034
+ child.transformation.isLocked = false;
55027
55035
  });
55028
55036
  item.transformation.isLocked = false;
55029
55037
  const removedItems = [];
@@ -55038,9 +55046,7 @@ class Board {
55038
55046
  if (!item || !(item instanceof Group)) {
55039
55047
  return;
55040
55048
  }
55041
- item.getChildren().forEach((item2) => {
55042
- item2.parent = "Board";
55043
- });
55049
+ item.applyRemoveChildren(item.getChildrenIds());
55044
55050
  const removedItems = [];
55045
55051
  this.findItemAndApply(op.item, (item2) => {
55046
55052
  this.index.remove(item2);