microboard-temp 0.13.32 → 0.13.34
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/dist/cjs/browser.js +62 -71
- package/dist/cjs/index.js +62 -71
- package/dist/cjs/node.js +62 -71
- package/dist/esm/browser.js +62 -71
- package/dist/esm/index.js +62 -71
- package/dist/esm/node.js +62 -71
- package/dist/types/ForceGraph/ForceGraphEngine.d.ts +0 -1
- package/dist/types/Settings.d.ts +1 -0
- package/package.json +1 -1
package/dist/cjs/browser.js
CHANGED
|
@@ -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:
|
|
4678
|
+
FG_SPRING_K: 0.2,
|
|
4679
4679
|
FG_TARGET_GAP: 20,
|
|
4680
|
-
FG_REPULSION:
|
|
4681
|
-
|
|
4682
|
-
|
|
4680
|
+
FG_REPULSION: 500,
|
|
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,
|
|
@@ -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;
|
|
@@ -21464,7 +21466,7 @@ class Items {
|
|
|
21464
21466
|
if (item.itemType === "Drawing" && !item.isPointNearLine(this.pointer.point)) {
|
|
21465
21467
|
return acc;
|
|
21466
21468
|
}
|
|
21467
|
-
const isItemTransparent = item instanceof Shape && item
|
|
21469
|
+
const isItemTransparent = item instanceof Shape && item.getBackgroundColor() === "none";
|
|
21468
21470
|
const itemZIndex = this.getZIndex(item);
|
|
21469
21471
|
const accZIndex = this.getZIndex(acc.nearest);
|
|
21470
21472
|
if (itemZIndex > accZIndex && (!isItemTransparent || area === acc.area) || area < acc.area) {
|
|
@@ -21560,7 +21562,7 @@ class Items {
|
|
|
21560
21562
|
});
|
|
21561
21563
|
const childrenMap = new Map;
|
|
21562
21564
|
const GroupsHTML = groups.map((group) => {
|
|
21563
|
-
group.getChildrenIds()
|
|
21565
|
+
group.getChildrenIds()?.forEach((childId) => childrenMap.set(childId, group.getId()));
|
|
21564
21566
|
const html = group.renderHTML(documentFactory);
|
|
21565
21567
|
translateElementBy(html, -lowestCoordinates.left, -lowestCoordinates.top);
|
|
21566
21568
|
return html;
|
|
@@ -21576,7 +21578,10 @@ class Items {
|
|
|
21576
21578
|
item.setAttribute("data-end-point-x", (endX - lowestCoordinates.left).toString());
|
|
21577
21579
|
item.setAttribute("data-end-point-y", (endY - lowestCoordinates.top).toString());
|
|
21578
21580
|
}
|
|
21579
|
-
|
|
21581
|
+
if (!childrenMap.get(item.id)) {
|
|
21582
|
+
return translateElementBy(item, -lowestCoordinates.left, -lowestCoordinates.top);
|
|
21583
|
+
}
|
|
21584
|
+
return item;
|
|
21580
21585
|
});
|
|
21581
21586
|
for (const item of restHTML) {
|
|
21582
21587
|
const parentFrameId = childrenMap.get(item.id);
|
|
@@ -22234,8 +22239,8 @@ class BaseItem extends Mbr {
|
|
|
22234
22239
|
}
|
|
22235
22240
|
renderHTML(documentFactory) {
|
|
22236
22241
|
const div = documentFactory.createElement("base-item");
|
|
22237
|
-
const { translateX, translateY } = this.transformation.getMatrixData();
|
|
22238
|
-
const transform = `translate(${translateX}px, ${translateY}px) scale(
|
|
22242
|
+
const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
|
|
22243
|
+
const transform = `translate(${translateX}px, ${translateY}px) scale(${scaleX}, ${scaleY})`;
|
|
22239
22244
|
div.style.backgroundColor = "#b2b0c3";
|
|
22240
22245
|
div.id = this.getId();
|
|
22241
22246
|
div.style.width = `${this.getWidth()}px`;
|
|
@@ -40419,7 +40424,7 @@ class Shape extends BaseItem {
|
|
|
40419
40424
|
if (Shapes[this.shapeType].useMbrUnderPointer) {
|
|
40420
40425
|
return this.mbr.isUnderPoint(point5);
|
|
40421
40426
|
}
|
|
40422
|
-
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 === "")) {
|
|
40423
40428
|
return this.path.isPointOverEdges(point5, tolerance);
|
|
40424
40429
|
} else {
|
|
40425
40430
|
return this.textContainer.isUnderPoint(point5) || this.path.isUnderPoint(point5);
|
|
@@ -40471,8 +40476,8 @@ class Shape extends BaseItem {
|
|
|
40471
40476
|
const pathElement = Shapes[this.shapeType].path.copy().renderHTML(documentFactory);
|
|
40472
40477
|
const paths = Array.isArray(pathElement) ? pathElement : [pathElement];
|
|
40473
40478
|
paths.forEach((element4) => {
|
|
40474
|
-
element4.setAttribute("fill", this.backgroundColor);
|
|
40475
|
-
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"));
|
|
40476
40481
|
element4.setAttribute("stroke-dasharray", LinePatterns[this.borderStyle].join(", "));
|
|
40477
40482
|
element4.setAttribute("stroke-width", this.borderWidth.toString());
|
|
40478
40483
|
element4.setAttribute("transform-origin", "0 0");
|
|
@@ -40487,8 +40492,8 @@ class Shape extends BaseItem {
|
|
|
40487
40492
|
div.style.transform = `translate(${translateX}px, ${translateY}px) scale(${scaleX}, ${scaleY})`;
|
|
40488
40493
|
div.style.position = "absolute";
|
|
40489
40494
|
div.setAttribute("data-shape-type", this.shapeType);
|
|
40490
|
-
div.setAttribute("fill", this.backgroundColor);
|
|
40491
|
-
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"));
|
|
40492
40497
|
div.setAttribute("data-border-style", this.borderStyle);
|
|
40493
40498
|
div.setAttribute("stroke-dasharray", LinePatterns[this.borderStyle].join(", "));
|
|
40494
40499
|
div.setAttribute("stroke-width", this.borderWidth.toString());
|
|
@@ -40532,9 +40537,6 @@ class Shape extends BaseItem {
|
|
|
40532
40537
|
this.text.updateElement();
|
|
40533
40538
|
}
|
|
40534
40539
|
transformPath() {
|
|
40535
|
-
if (conf.isNode()) {
|
|
40536
|
-
return;
|
|
40537
|
-
}
|
|
40538
40540
|
this.path = Shapes[this.shapeType].createPath(this.mbr);
|
|
40539
40541
|
this.textContainer = Shapes[this.shapeType].textBounds.copy();
|
|
40540
40542
|
this.text.setContainer(this.textContainer.copy());
|
|
@@ -43842,7 +43844,13 @@ class Group extends BaseItem {
|
|
|
43842
43844
|
ctx.restore();
|
|
43843
43845
|
}
|
|
43844
43846
|
renderHTML(documentFactory) {
|
|
43845
|
-
|
|
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;
|
|
43846
43854
|
}
|
|
43847
43855
|
}
|
|
43848
43856
|
// src/itemFactories.ts
|
|
@@ -54696,7 +54704,6 @@ class ForceGraphEngine {
|
|
|
54696
54704
|
activeComponents = new Map;
|
|
54697
54705
|
TICK_MS = 33;
|
|
54698
54706
|
SYNC_MS = 300;
|
|
54699
|
-
SOFTENING_SQ = 100 * 100;
|
|
54700
54707
|
MIN_MOVE_PX = 0.05;
|
|
54701
54708
|
constructor(board) {
|
|
54702
54709
|
this.board = board;
|
|
@@ -54845,42 +54852,27 @@ class ForceGraphEngine {
|
|
|
54845
54852
|
return this.board.items.listAll().filter((item) => item.itemType === "Connector");
|
|
54846
54853
|
}
|
|
54847
54854
|
tick() {
|
|
54848
|
-
const dt = this.TICK_MS / 1000;
|
|
54849
54855
|
const activeIds = this.getActiveNodeIds();
|
|
54850
54856
|
const draggedIds = this.board.getDraggedItemIds();
|
|
54851
54857
|
const allNodes = this.getNodes();
|
|
54852
|
-
const nodes = allNodes.filter((item) => {
|
|
54853
|
-
if (!activeIds.has(item.getId()))
|
|
54854
|
-
return false;
|
|
54855
|
-
if (draggedIds.has(item.getId()))
|
|
54856
|
-
return false;
|
|
54857
|
-
if (item.parent !== "Board" && draggedIds.has(item.parent))
|
|
54858
|
-
return false;
|
|
54859
|
-
return true;
|
|
54860
|
-
});
|
|
54861
|
-
if (nodes.length < 1)
|
|
54862
|
-
return;
|
|
54863
54858
|
const snapMap = new Map;
|
|
54864
|
-
for (const item of
|
|
54859
|
+
for (const item of allNodes) {
|
|
54860
|
+
if (!activeIds.has(item.getId()))
|
|
54861
|
+
continue;
|
|
54865
54862
|
const pos = item.transformation.getTranslation();
|
|
54866
54863
|
const mbr = item.getMbr();
|
|
54867
54864
|
const w = Math.max(mbr.getWidth(), 1);
|
|
54868
54865
|
const h2 = Math.max(mbr.getHeight(), 1);
|
|
54869
|
-
snapMap.set(item.getId(), {
|
|
54870
|
-
id: item.getId(),
|
|
54871
|
-
cx: pos.x + w * 0.5,
|
|
54872
|
-
cy: pos.y + h2 * 0.5,
|
|
54873
|
-
w,
|
|
54874
|
-
h: h2
|
|
54875
|
-
});
|
|
54866
|
+
snapMap.set(item.getId(), { id: item.getId(), cx: pos.x + w * 0.5, cy: pos.y + h2 * 0.5, w, h: h2 });
|
|
54876
54867
|
}
|
|
54877
54868
|
const snap = Array.from(snapMap.values());
|
|
54869
|
+
if (snap.length < 1)
|
|
54870
|
+
return;
|
|
54878
54871
|
const uf = new UnionFind;
|
|
54879
54872
|
for (const connector of this.getConnectors()) {
|
|
54880
54873
|
const { startItem, endItem } = connector.getConnectedItems();
|
|
54881
|
-
if (startItem && endItem)
|
|
54874
|
+
if (startItem && endItem)
|
|
54882
54875
|
uf.union(startItem.getId(), endItem.getId());
|
|
54883
|
-
}
|
|
54884
54876
|
}
|
|
54885
54877
|
const ax = new Map;
|
|
54886
54878
|
const ay = new Map;
|
|
@@ -54898,14 +54890,13 @@ class ForceGraphEngine {
|
|
|
54898
54890
|
continue;
|
|
54899
54891
|
const dx = s2.cx - s1.cx;
|
|
54900
54892
|
const dy = s2.cy - s1.cy;
|
|
54901
|
-
const dist = Math.sqrt(dx * dx + dy * dy)
|
|
54893
|
+
const dist = Math.sqrt(dx * dx + dy * dy) || 1;
|
|
54902
54894
|
const compId = this.findComponentId(s1.id);
|
|
54903
54895
|
const targetGap = compId ? this.activeComponents.get(compId)?.targetGap ?? conf.FG_TARGET_GAP : conf.FG_TARGET_GAP;
|
|
54904
54896
|
const targetDist = (Math.max(s1.w, s1.h) + Math.max(s2.w, s2.h)) * 0.5 + targetGap;
|
|
54905
|
-
const
|
|
54906
|
-
const
|
|
54907
|
-
const
|
|
54908
|
-
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;
|
|
54909
54900
|
ax.set(s1.id, (ax.get(s1.id) ?? 0) + fx);
|
|
54910
54901
|
ay.set(s1.id, (ay.get(s1.id) ?? 0) + fy);
|
|
54911
54902
|
ax.set(s2.id, (ax.get(s2.id) ?? 0) - fx);
|
|
@@ -54919,35 +54910,35 @@ class ForceGraphEngine {
|
|
|
54919
54910
|
continue;
|
|
54920
54911
|
const dx = s2.cx - s1.cx;
|
|
54921
54912
|
const dy = s2.cy - s1.cy;
|
|
54922
|
-
const
|
|
54923
|
-
const
|
|
54924
|
-
|
|
54925
|
-
|
|
54926
|
-
|
|
54927
|
-
|
|
54928
|
-
const fy = dy / centerDist * repMag;
|
|
54929
|
-
ax.set(s1.id, (ax.get(s1.id) ?? 0) - fx);
|
|
54930
|
-
ay.set(s1.id, (ay.get(s1.id) ?? 0) - fy);
|
|
54931
|
-
ax.set(s2.id, (ax.get(s2.id) ?? 0) + fx);
|
|
54932
|
-
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);
|
|
54933
54919
|
}
|
|
54934
54920
|
}
|
|
54935
54921
|
let totalEnergy = 0;
|
|
54936
|
-
for (const item of
|
|
54922
|
+
for (const item of allNodes) {
|
|
54937
54923
|
const id = item.getId();
|
|
54938
|
-
if (!
|
|
54924
|
+
if (!activeIds.has(id))
|
|
54925
|
+
continue;
|
|
54926
|
+
if (!this.velocities.has(id))
|
|
54939
54927
|
this.velocities.set(id, { vx: 0, vy: 0 });
|
|
54940
|
-
}
|
|
54941
54928
|
const vel = this.velocities.get(id);
|
|
54942
|
-
|
|
54943
|
-
|
|
54944
|
-
|
|
54945
|
-
|
|
54946
|
-
|
|
54947
|
-
|
|
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) {
|
|
54948
54939
|
item.transformation.applyMatrixSilent({
|
|
54949
|
-
translateX:
|
|
54950
|
-
translateY:
|
|
54940
|
+
translateX: vel.vx,
|
|
54941
|
+
translateY: vel.vy,
|
|
54951
54942
|
scaleX: 1,
|
|
54952
54943
|
scaleY: 1,
|
|
54953
54944
|
shearX: 0,
|
package/dist/cjs/index.js
CHANGED
|
@@ -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:
|
|
4678
|
+
FG_SPRING_K: 0.2,
|
|
4679
4679
|
FG_TARGET_GAP: 20,
|
|
4680
|
-
FG_REPULSION:
|
|
4681
|
-
|
|
4682
|
-
|
|
4680
|
+
FG_REPULSION: 500,
|
|
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,
|
|
@@ -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;
|
|
@@ -21464,7 +21466,7 @@ class Items {
|
|
|
21464
21466
|
if (item.itemType === "Drawing" && !item.isPointNearLine(this.pointer.point)) {
|
|
21465
21467
|
return acc;
|
|
21466
21468
|
}
|
|
21467
|
-
const isItemTransparent = item instanceof Shape && item
|
|
21469
|
+
const isItemTransparent = item instanceof Shape && item.getBackgroundColor() === "none";
|
|
21468
21470
|
const itemZIndex = this.getZIndex(item);
|
|
21469
21471
|
const accZIndex = this.getZIndex(acc.nearest);
|
|
21470
21472
|
if (itemZIndex > accZIndex && (!isItemTransparent || area === acc.area) || area < acc.area) {
|
|
@@ -21560,7 +21562,7 @@ class Items {
|
|
|
21560
21562
|
});
|
|
21561
21563
|
const childrenMap = new Map;
|
|
21562
21564
|
const GroupsHTML = groups.map((group) => {
|
|
21563
|
-
group.getChildrenIds()
|
|
21565
|
+
group.getChildrenIds()?.forEach((childId) => childrenMap.set(childId, group.getId()));
|
|
21564
21566
|
const html = group.renderHTML(documentFactory);
|
|
21565
21567
|
translateElementBy(html, -lowestCoordinates.left, -lowestCoordinates.top);
|
|
21566
21568
|
return html;
|
|
@@ -21576,7 +21578,10 @@ class Items {
|
|
|
21576
21578
|
item.setAttribute("data-end-point-x", (endX - lowestCoordinates.left).toString());
|
|
21577
21579
|
item.setAttribute("data-end-point-y", (endY - lowestCoordinates.top).toString());
|
|
21578
21580
|
}
|
|
21579
|
-
|
|
21581
|
+
if (!childrenMap.get(item.id)) {
|
|
21582
|
+
return translateElementBy(item, -lowestCoordinates.left, -lowestCoordinates.top);
|
|
21583
|
+
}
|
|
21584
|
+
return item;
|
|
21580
21585
|
});
|
|
21581
21586
|
for (const item of restHTML) {
|
|
21582
21587
|
const parentFrameId = childrenMap.get(item.id);
|
|
@@ -22234,8 +22239,8 @@ class BaseItem extends Mbr {
|
|
|
22234
22239
|
}
|
|
22235
22240
|
renderHTML(documentFactory) {
|
|
22236
22241
|
const div = documentFactory.createElement("base-item");
|
|
22237
|
-
const { translateX, translateY } = this.transformation.getMatrixData();
|
|
22238
|
-
const transform = `translate(${translateX}px, ${translateY}px) scale(
|
|
22242
|
+
const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
|
|
22243
|
+
const transform = `translate(${translateX}px, ${translateY}px) scale(${scaleX}, ${scaleY})`;
|
|
22239
22244
|
div.style.backgroundColor = "#b2b0c3";
|
|
22240
22245
|
div.id = this.getId();
|
|
22241
22246
|
div.style.width = `${this.getWidth()}px`;
|
|
@@ -40419,7 +40424,7 @@ class Shape extends BaseItem {
|
|
|
40419
40424
|
if (Shapes[this.shapeType].useMbrUnderPointer) {
|
|
40420
40425
|
return this.mbr.isUnderPoint(point5);
|
|
40421
40426
|
}
|
|
40422
|
-
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 === "")) {
|
|
40423
40428
|
return this.path.isPointOverEdges(point5, tolerance);
|
|
40424
40429
|
} else {
|
|
40425
40430
|
return this.textContainer.isUnderPoint(point5) || this.path.isUnderPoint(point5);
|
|
@@ -40471,8 +40476,8 @@ class Shape extends BaseItem {
|
|
|
40471
40476
|
const pathElement = Shapes[this.shapeType].path.copy().renderHTML(documentFactory);
|
|
40472
40477
|
const paths = Array.isArray(pathElement) ? pathElement : [pathElement];
|
|
40473
40478
|
paths.forEach((element4) => {
|
|
40474
|
-
element4.setAttribute("fill", this.backgroundColor);
|
|
40475
|
-
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"));
|
|
40476
40481
|
element4.setAttribute("stroke-dasharray", LinePatterns[this.borderStyle].join(", "));
|
|
40477
40482
|
element4.setAttribute("stroke-width", this.borderWidth.toString());
|
|
40478
40483
|
element4.setAttribute("transform-origin", "0 0");
|
|
@@ -40487,8 +40492,8 @@ class Shape extends BaseItem {
|
|
|
40487
40492
|
div.style.transform = `translate(${translateX}px, ${translateY}px) scale(${scaleX}, ${scaleY})`;
|
|
40488
40493
|
div.style.position = "absolute";
|
|
40489
40494
|
div.setAttribute("data-shape-type", this.shapeType);
|
|
40490
|
-
div.setAttribute("fill", this.backgroundColor);
|
|
40491
|
-
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"));
|
|
40492
40497
|
div.setAttribute("data-border-style", this.borderStyle);
|
|
40493
40498
|
div.setAttribute("stroke-dasharray", LinePatterns[this.borderStyle].join(", "));
|
|
40494
40499
|
div.setAttribute("stroke-width", this.borderWidth.toString());
|
|
@@ -40532,9 +40537,6 @@ class Shape extends BaseItem {
|
|
|
40532
40537
|
this.text.updateElement();
|
|
40533
40538
|
}
|
|
40534
40539
|
transformPath() {
|
|
40535
|
-
if (conf.isNode()) {
|
|
40536
|
-
return;
|
|
40537
|
-
}
|
|
40538
40540
|
this.path = Shapes[this.shapeType].createPath(this.mbr);
|
|
40539
40541
|
this.textContainer = Shapes[this.shapeType].textBounds.copy();
|
|
40540
40542
|
this.text.setContainer(this.textContainer.copy());
|
|
@@ -43842,7 +43844,13 @@ class Group extends BaseItem {
|
|
|
43842
43844
|
ctx.restore();
|
|
43843
43845
|
}
|
|
43844
43846
|
renderHTML(documentFactory) {
|
|
43845
|
-
|
|
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;
|
|
43846
43854
|
}
|
|
43847
43855
|
}
|
|
43848
43856
|
// src/itemFactories.ts
|
|
@@ -54696,7 +54704,6 @@ class ForceGraphEngine {
|
|
|
54696
54704
|
activeComponents = new Map;
|
|
54697
54705
|
TICK_MS = 33;
|
|
54698
54706
|
SYNC_MS = 300;
|
|
54699
|
-
SOFTENING_SQ = 100 * 100;
|
|
54700
54707
|
MIN_MOVE_PX = 0.05;
|
|
54701
54708
|
constructor(board) {
|
|
54702
54709
|
this.board = board;
|
|
@@ -54845,42 +54852,27 @@ class ForceGraphEngine {
|
|
|
54845
54852
|
return this.board.items.listAll().filter((item) => item.itemType === "Connector");
|
|
54846
54853
|
}
|
|
54847
54854
|
tick() {
|
|
54848
|
-
const dt = this.TICK_MS / 1000;
|
|
54849
54855
|
const activeIds = this.getActiveNodeIds();
|
|
54850
54856
|
const draggedIds = this.board.getDraggedItemIds();
|
|
54851
54857
|
const allNodes = this.getNodes();
|
|
54852
|
-
const nodes = allNodes.filter((item) => {
|
|
54853
|
-
if (!activeIds.has(item.getId()))
|
|
54854
|
-
return false;
|
|
54855
|
-
if (draggedIds.has(item.getId()))
|
|
54856
|
-
return false;
|
|
54857
|
-
if (item.parent !== "Board" && draggedIds.has(item.parent))
|
|
54858
|
-
return false;
|
|
54859
|
-
return true;
|
|
54860
|
-
});
|
|
54861
|
-
if (nodes.length < 1)
|
|
54862
|
-
return;
|
|
54863
54858
|
const snapMap = new Map;
|
|
54864
|
-
for (const item of
|
|
54859
|
+
for (const item of allNodes) {
|
|
54860
|
+
if (!activeIds.has(item.getId()))
|
|
54861
|
+
continue;
|
|
54865
54862
|
const pos = item.transformation.getTranslation();
|
|
54866
54863
|
const mbr = item.getMbr();
|
|
54867
54864
|
const w = Math.max(mbr.getWidth(), 1);
|
|
54868
54865
|
const h2 = Math.max(mbr.getHeight(), 1);
|
|
54869
|
-
snapMap.set(item.getId(), {
|
|
54870
|
-
id: item.getId(),
|
|
54871
|
-
cx: pos.x + w * 0.5,
|
|
54872
|
-
cy: pos.y + h2 * 0.5,
|
|
54873
|
-
w,
|
|
54874
|
-
h: h2
|
|
54875
|
-
});
|
|
54866
|
+
snapMap.set(item.getId(), { id: item.getId(), cx: pos.x + w * 0.5, cy: pos.y + h2 * 0.5, w, h: h2 });
|
|
54876
54867
|
}
|
|
54877
54868
|
const snap = Array.from(snapMap.values());
|
|
54869
|
+
if (snap.length < 1)
|
|
54870
|
+
return;
|
|
54878
54871
|
const uf = new UnionFind;
|
|
54879
54872
|
for (const connector of this.getConnectors()) {
|
|
54880
54873
|
const { startItem, endItem } = connector.getConnectedItems();
|
|
54881
|
-
if (startItem && endItem)
|
|
54874
|
+
if (startItem && endItem)
|
|
54882
54875
|
uf.union(startItem.getId(), endItem.getId());
|
|
54883
|
-
}
|
|
54884
54876
|
}
|
|
54885
54877
|
const ax = new Map;
|
|
54886
54878
|
const ay = new Map;
|
|
@@ -54898,14 +54890,13 @@ class ForceGraphEngine {
|
|
|
54898
54890
|
continue;
|
|
54899
54891
|
const dx = s2.cx - s1.cx;
|
|
54900
54892
|
const dy = s2.cy - s1.cy;
|
|
54901
|
-
const dist = Math.sqrt(dx * dx + dy * dy)
|
|
54893
|
+
const dist = Math.sqrt(dx * dx + dy * dy) || 1;
|
|
54902
54894
|
const compId = this.findComponentId(s1.id);
|
|
54903
54895
|
const targetGap = compId ? this.activeComponents.get(compId)?.targetGap ?? conf.FG_TARGET_GAP : conf.FG_TARGET_GAP;
|
|
54904
54896
|
const targetDist = (Math.max(s1.w, s1.h) + Math.max(s2.w, s2.h)) * 0.5 + targetGap;
|
|
54905
|
-
const
|
|
54906
|
-
const
|
|
54907
|
-
const
|
|
54908
|
-
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;
|
|
54909
54900
|
ax.set(s1.id, (ax.get(s1.id) ?? 0) + fx);
|
|
54910
54901
|
ay.set(s1.id, (ay.get(s1.id) ?? 0) + fy);
|
|
54911
54902
|
ax.set(s2.id, (ax.get(s2.id) ?? 0) - fx);
|
|
@@ -54919,35 +54910,35 @@ class ForceGraphEngine {
|
|
|
54919
54910
|
continue;
|
|
54920
54911
|
const dx = s2.cx - s1.cx;
|
|
54921
54912
|
const dy = s2.cy - s1.cy;
|
|
54922
|
-
const
|
|
54923
|
-
const
|
|
54924
|
-
|
|
54925
|
-
|
|
54926
|
-
|
|
54927
|
-
|
|
54928
|
-
const fy = dy / centerDist * repMag;
|
|
54929
|
-
ax.set(s1.id, (ax.get(s1.id) ?? 0) - fx);
|
|
54930
|
-
ay.set(s1.id, (ay.get(s1.id) ?? 0) - fy);
|
|
54931
|
-
ax.set(s2.id, (ax.get(s2.id) ?? 0) + fx);
|
|
54932
|
-
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);
|
|
54933
54919
|
}
|
|
54934
54920
|
}
|
|
54935
54921
|
let totalEnergy = 0;
|
|
54936
|
-
for (const item of
|
|
54922
|
+
for (const item of allNodes) {
|
|
54937
54923
|
const id = item.getId();
|
|
54938
|
-
if (!
|
|
54924
|
+
if (!activeIds.has(id))
|
|
54925
|
+
continue;
|
|
54926
|
+
if (!this.velocities.has(id))
|
|
54939
54927
|
this.velocities.set(id, { vx: 0, vy: 0 });
|
|
54940
|
-
}
|
|
54941
54928
|
const vel = this.velocities.get(id);
|
|
54942
|
-
|
|
54943
|
-
|
|
54944
|
-
|
|
54945
|
-
|
|
54946
|
-
|
|
54947
|
-
|
|
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) {
|
|
54948
54939
|
item.transformation.applyMatrixSilent({
|
|
54949
|
-
translateX:
|
|
54950
|
-
translateY:
|
|
54940
|
+
translateX: vel.vx,
|
|
54941
|
+
translateY: vel.vy,
|
|
54951
54942
|
scaleX: 1,
|
|
54952
54943
|
scaleY: 1,
|
|
54953
54944
|
shearX: 0,
|