microboard-temp 0.13.32 → 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.
- 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/node.js
CHANGED
|
@@ -5712,11 +5712,12 @@ var conf = {
|
|
|
5712
5712
|
DEFAULT_GAME_ITEM_DIMENSIONS: { width: 200, height: 200 },
|
|
5713
5713
|
MAX_CARD_SIZE: 500,
|
|
5714
5714
|
CONNECTOR_ITEM_OFFSET: 20,
|
|
5715
|
-
FG_SPRING_K:
|
|
5715
|
+
FG_SPRING_K: 0.2,
|
|
5716
5716
|
FG_TARGET_GAP: 20,
|
|
5717
|
-
FG_REPULSION:
|
|
5718
|
-
|
|
5719
|
-
|
|
5717
|
+
FG_REPULSION: 100,
|
|
5718
|
+
FG_MIN_DIST_SQ: 100,
|
|
5719
|
+
FG_DAMPING: 0.6,
|
|
5720
|
+
FG_SLEEP_THRESHOLD: 0.5,
|
|
5720
5721
|
GRAVITY_G: 80,
|
|
5721
5722
|
GRAVITY_G_CENTER: 120,
|
|
5722
5723
|
GRAVITY_DAMPING: 0.96,
|
|
@@ -23548,14 +23549,14 @@ class SpatialIndex {
|
|
|
23548
23549
|
if ("index" in item && item.index) {
|
|
23549
23550
|
item.removeChildItems(item.index.list());
|
|
23550
23551
|
}
|
|
23552
|
+
this.itemsArray.splice(this.itemsArray.indexOf(item), 1);
|
|
23553
|
+
this.itemsIndex.remove(item);
|
|
23551
23554
|
if (item.parent !== "Board") {
|
|
23552
23555
|
const parentFrame = this.items.getById(item.parent);
|
|
23553
23556
|
parentFrame?.removeChildItems(item);
|
|
23554
23557
|
this.subject.publish(this.items);
|
|
23555
23558
|
return;
|
|
23556
23559
|
}
|
|
23557
|
-
this.itemsArray.splice(this.itemsArray.indexOf(item), 1);
|
|
23558
|
-
this.itemsIndex.remove(item);
|
|
23559
23560
|
if (this.itemsArray.length === 0) {
|
|
23560
23561
|
this.Mbr = new Mbr;
|
|
23561
23562
|
} else {
|
|
@@ -23576,7 +23577,8 @@ class SpatialIndex {
|
|
|
23576
23577
|
translateX: worldMatrix.translateX,
|
|
23577
23578
|
translateY: worldMatrix.translateY,
|
|
23578
23579
|
scaleX: worldMatrix.scaleX,
|
|
23579
|
-
scaleY: worldMatrix.scaleY
|
|
23580
|
+
scaleY: worldMatrix.scaleY,
|
|
23581
|
+
isLocked: false
|
|
23580
23582
|
};
|
|
23581
23583
|
}
|
|
23582
23584
|
return serialized;
|
|
@@ -23936,7 +23938,7 @@ class Items {
|
|
|
23936
23938
|
if (item.itemType === "Drawing" && !item.isPointNearLine(this.pointer.point)) {
|
|
23937
23939
|
return acc;
|
|
23938
23940
|
}
|
|
23939
|
-
const isItemTransparent = item instanceof Shape && item
|
|
23941
|
+
const isItemTransparent = item instanceof Shape && item.getBackgroundColor() === "none";
|
|
23940
23942
|
const itemZIndex = this.getZIndex(item);
|
|
23941
23943
|
const accZIndex = this.getZIndex(acc.nearest);
|
|
23942
23944
|
if (itemZIndex > accZIndex && (!isItemTransparent || area === acc.area) || area < acc.area) {
|
|
@@ -24032,7 +24034,7 @@ class Items {
|
|
|
24032
24034
|
});
|
|
24033
24035
|
const childrenMap = new Map;
|
|
24034
24036
|
const GroupsHTML = groups.map((group) => {
|
|
24035
|
-
group.getChildrenIds()
|
|
24037
|
+
group.getChildrenIds()?.forEach((childId) => childrenMap.set(childId, group.getId()));
|
|
24036
24038
|
const html = group.renderHTML(documentFactory);
|
|
24037
24039
|
translateElementBy(html, -lowestCoordinates.left, -lowestCoordinates.top);
|
|
24038
24040
|
return html;
|
|
@@ -24048,7 +24050,10 @@ class Items {
|
|
|
24048
24050
|
item.setAttribute("data-end-point-x", (endX - lowestCoordinates.left).toString());
|
|
24049
24051
|
item.setAttribute("data-end-point-y", (endY - lowestCoordinates.top).toString());
|
|
24050
24052
|
}
|
|
24051
|
-
|
|
24053
|
+
if (!childrenMap.get(item.id)) {
|
|
24054
|
+
return translateElementBy(item, -lowestCoordinates.left, -lowestCoordinates.top);
|
|
24055
|
+
}
|
|
24056
|
+
return item;
|
|
24052
24057
|
});
|
|
24053
24058
|
for (const item of restHTML) {
|
|
24054
24059
|
const parentFrameId = childrenMap.get(item.id);
|
|
@@ -24706,8 +24711,8 @@ class BaseItem extends Mbr {
|
|
|
24706
24711
|
}
|
|
24707
24712
|
renderHTML(documentFactory) {
|
|
24708
24713
|
const div = documentFactory.createElement("base-item");
|
|
24709
|
-
const { translateX, translateY } = this.transformation.getMatrixData();
|
|
24710
|
-
const transform = `translate(${translateX}px, ${translateY}px) scale(
|
|
24714
|
+
const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
|
|
24715
|
+
const transform = `translate(${translateX}px, ${translateY}px) scale(${scaleX}, ${scaleY})`;
|
|
24711
24716
|
div.style.backgroundColor = "#b2b0c3";
|
|
24712
24717
|
div.id = this.getId();
|
|
24713
24718
|
div.style.width = `${this.getWidth()}px`;
|
|
@@ -42892,7 +42897,7 @@ class Shape extends BaseItem {
|
|
|
42892
42897
|
if (Shapes[this.shapeType].useMbrUnderPointer) {
|
|
42893
42898
|
return this.mbr.isUnderPoint(point5);
|
|
42894
42899
|
}
|
|
42895
|
-
if (this.text.isEmpty() && (this.backgroundOpacity === 0 || this.backgroundColor === "none" || this.backgroundColor === "")) {
|
|
42900
|
+
if (this.text.isEmpty() && (this.backgroundOpacity === 0 || this.backgroundColor === "none" || this.backgroundColor === "transparent" || this.backgroundColor === "")) {
|
|
42896
42901
|
return this.path.isPointOverEdges(point5, tolerance);
|
|
42897
42902
|
} else {
|
|
42898
42903
|
return this.textContainer.isUnderPoint(point5) || this.path.isUnderPoint(point5);
|
|
@@ -42944,8 +42949,8 @@ class Shape extends BaseItem {
|
|
|
42944
42949
|
const pathElement = Shapes[this.shapeType].path.copy().renderHTML(documentFactory);
|
|
42945
42950
|
const paths = Array.isArray(pathElement) ? pathElement : [pathElement];
|
|
42946
42951
|
paths.forEach((element3) => {
|
|
42947
|
-
element3.setAttribute("fill", this.backgroundColor);
|
|
42948
|
-
element3.setAttribute("stroke", this.borderColor);
|
|
42952
|
+
element3.setAttribute("fill", resolveColor(this.backgroundColor, conf.theme, "background"));
|
|
42953
|
+
element3.setAttribute("stroke", resolveColor(this.borderColor, conf.theme, "foreground"));
|
|
42949
42954
|
element3.setAttribute("stroke-dasharray", LinePatterns[this.borderStyle].join(", "));
|
|
42950
42955
|
element3.setAttribute("stroke-width", this.borderWidth.toString());
|
|
42951
42956
|
element3.setAttribute("transform-origin", "0 0");
|
|
@@ -42960,8 +42965,8 @@ class Shape extends BaseItem {
|
|
|
42960
42965
|
div.style.transform = `translate(${translateX}px, ${translateY}px) scale(${scaleX}, ${scaleY})`;
|
|
42961
42966
|
div.style.position = "absolute";
|
|
42962
42967
|
div.setAttribute("data-shape-type", this.shapeType);
|
|
42963
|
-
div.setAttribute("fill", this.backgroundColor);
|
|
42964
|
-
div.setAttribute("stroke", this.borderColor);
|
|
42968
|
+
div.setAttribute("fill", resolveColor(this.backgroundColor, conf.theme, "background"));
|
|
42969
|
+
div.setAttribute("stroke", resolveColor(this.borderColor, conf.theme, "foreground"));
|
|
42965
42970
|
div.setAttribute("data-border-style", this.borderStyle);
|
|
42966
42971
|
div.setAttribute("stroke-dasharray", LinePatterns[this.borderStyle].join(", "));
|
|
42967
42972
|
div.setAttribute("stroke-width", this.borderWidth.toString());
|
|
@@ -43005,9 +43010,6 @@ class Shape extends BaseItem {
|
|
|
43005
43010
|
this.text.updateElement();
|
|
43006
43011
|
}
|
|
43007
43012
|
transformPath() {
|
|
43008
|
-
if (conf.isNode()) {
|
|
43009
|
-
return;
|
|
43010
|
-
}
|
|
43011
43013
|
this.path = Shapes[this.shapeType].createPath(this.mbr);
|
|
43012
43014
|
this.textContainer = Shapes[this.shapeType].textBounds.copy();
|
|
43013
43015
|
this.text.setContainer(this.textContainer.copy());
|
|
@@ -46315,7 +46317,13 @@ class Group extends BaseItem {
|
|
|
46315
46317
|
ctx.restore();
|
|
46316
46318
|
}
|
|
46317
46319
|
renderHTML(documentFactory) {
|
|
46318
|
-
|
|
46320
|
+
const div = documentFactory.createElement("div");
|
|
46321
|
+
div.id = this.id;
|
|
46322
|
+
const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
|
|
46323
|
+
div.style.transform = `translate(${translateX}px, ${translateY}px) scale(${scaleX}, ${scaleY})`;
|
|
46324
|
+
div.style.position = "absolute";
|
|
46325
|
+
div.style.transformOrigin = "0 0";
|
|
46326
|
+
return div;
|
|
46319
46327
|
}
|
|
46320
46328
|
}
|
|
46321
46329
|
// src/itemFactories.ts
|
|
@@ -57169,7 +57177,6 @@ class ForceGraphEngine {
|
|
|
57169
57177
|
activeComponents = new Map;
|
|
57170
57178
|
TICK_MS = 33;
|
|
57171
57179
|
SYNC_MS = 300;
|
|
57172
|
-
SOFTENING_SQ = 100 * 100;
|
|
57173
57180
|
MIN_MOVE_PX = 0.05;
|
|
57174
57181
|
constructor(board) {
|
|
57175
57182
|
this.board = board;
|
|
@@ -57318,42 +57325,27 @@ class ForceGraphEngine {
|
|
|
57318
57325
|
return this.board.items.listAll().filter((item) => item.itemType === "Connector");
|
|
57319
57326
|
}
|
|
57320
57327
|
tick() {
|
|
57321
|
-
const dt = this.TICK_MS / 1000;
|
|
57322
57328
|
const activeIds = this.getActiveNodeIds();
|
|
57323
57329
|
const draggedIds = this.board.getDraggedItemIds();
|
|
57324
57330
|
const allNodes = this.getNodes();
|
|
57325
|
-
const nodes = allNodes.filter((item) => {
|
|
57326
|
-
if (!activeIds.has(item.getId()))
|
|
57327
|
-
return false;
|
|
57328
|
-
if (draggedIds.has(item.getId()))
|
|
57329
|
-
return false;
|
|
57330
|
-
if (item.parent !== "Board" && draggedIds.has(item.parent))
|
|
57331
|
-
return false;
|
|
57332
|
-
return true;
|
|
57333
|
-
});
|
|
57334
|
-
if (nodes.length < 1)
|
|
57335
|
-
return;
|
|
57336
57331
|
const snapMap = new Map;
|
|
57337
|
-
for (const item of
|
|
57332
|
+
for (const item of allNodes) {
|
|
57333
|
+
if (!activeIds.has(item.getId()))
|
|
57334
|
+
continue;
|
|
57338
57335
|
const pos = item.transformation.getTranslation();
|
|
57339
57336
|
const mbr = item.getMbr();
|
|
57340
57337
|
const w = Math.max(mbr.getWidth(), 1);
|
|
57341
57338
|
const h2 = Math.max(mbr.getHeight(), 1);
|
|
57342
|
-
snapMap.set(item.getId(), {
|
|
57343
|
-
id: item.getId(),
|
|
57344
|
-
cx: pos.x + w * 0.5,
|
|
57345
|
-
cy: pos.y + h2 * 0.5,
|
|
57346
|
-
w,
|
|
57347
|
-
h: h2
|
|
57348
|
-
});
|
|
57339
|
+
snapMap.set(item.getId(), { id: item.getId(), cx: pos.x + w * 0.5, cy: pos.y + h2 * 0.5, w, h: h2 });
|
|
57349
57340
|
}
|
|
57350
57341
|
const snap = Array.from(snapMap.values());
|
|
57342
|
+
if (snap.length < 1)
|
|
57343
|
+
return;
|
|
57351
57344
|
const uf = new UnionFind;
|
|
57352
57345
|
for (const connector of this.getConnectors()) {
|
|
57353
57346
|
const { startItem, endItem } = connector.getConnectedItems();
|
|
57354
|
-
if (startItem && endItem)
|
|
57347
|
+
if (startItem && endItem)
|
|
57355
57348
|
uf.union(startItem.getId(), endItem.getId());
|
|
57356
|
-
}
|
|
57357
57349
|
}
|
|
57358
57350
|
const ax = new Map;
|
|
57359
57351
|
const ay = new Map;
|
|
@@ -57371,14 +57363,13 @@ class ForceGraphEngine {
|
|
|
57371
57363
|
continue;
|
|
57372
57364
|
const dx = s2.cx - s1.cx;
|
|
57373
57365
|
const dy = s2.cy - s1.cy;
|
|
57374
|
-
const dist = Math.sqrt(dx * dx + dy * dy)
|
|
57366
|
+
const dist = Math.sqrt(dx * dx + dy * dy) || 1;
|
|
57375
57367
|
const compId = this.findComponentId(s1.id);
|
|
57376
57368
|
const targetGap = compId ? this.activeComponents.get(compId)?.targetGap ?? conf.FG_TARGET_GAP : conf.FG_TARGET_GAP;
|
|
57377
57369
|
const targetDist = (Math.max(s1.w, s1.h) + Math.max(s2.w, s2.h)) * 0.5 + targetGap;
|
|
57378
|
-
const
|
|
57379
|
-
const
|
|
57380
|
-
const
|
|
57381
|
-
const fy = dy / dist * forceMag;
|
|
57370
|
+
const force = (dist - targetDist) * conf.FG_SPRING_K;
|
|
57371
|
+
const fx = dx / dist * force;
|
|
57372
|
+
const fy = dy / dist * force;
|
|
57382
57373
|
ax.set(s1.id, (ax.get(s1.id) ?? 0) + fx);
|
|
57383
57374
|
ay.set(s1.id, (ay.get(s1.id) ?? 0) + fy);
|
|
57384
57375
|
ax.set(s2.id, (ax.get(s2.id) ?? 0) - fx);
|
|
@@ -57392,35 +57383,35 @@ class ForceGraphEngine {
|
|
|
57392
57383
|
continue;
|
|
57393
57384
|
const dx = s2.cx - s1.cx;
|
|
57394
57385
|
const dy = s2.cy - s1.cy;
|
|
57395
|
-
const
|
|
57396
|
-
const
|
|
57397
|
-
|
|
57398
|
-
|
|
57399
|
-
|
|
57400
|
-
|
|
57401
|
-
const fy = dy / centerDist * repMag;
|
|
57402
|
-
ax.set(s1.id, (ax.get(s1.id) ?? 0) - fx);
|
|
57403
|
-
ay.set(s1.id, (ay.get(s1.id) ?? 0) - fy);
|
|
57404
|
-
ax.set(s2.id, (ax.get(s2.id) ?? 0) + fx);
|
|
57405
|
-
ay.set(s2.id, (ay.get(s2.id) ?? 0) + fy);
|
|
57386
|
+
const distSq = Math.max(dx * dx + dy * dy, conf.FG_MIN_DIST_SQ);
|
|
57387
|
+
const force = conf.FG_REPULSION / distSq;
|
|
57388
|
+
ax.set(s1.id, (ax.get(s1.id) ?? 0) - dx * force);
|
|
57389
|
+
ay.set(s1.id, (ay.get(s1.id) ?? 0) - dy * force);
|
|
57390
|
+
ax.set(s2.id, (ax.get(s2.id) ?? 0) + dx * force);
|
|
57391
|
+
ay.set(s2.id, (ay.get(s2.id) ?? 0) + dy * force);
|
|
57406
57392
|
}
|
|
57407
57393
|
}
|
|
57408
57394
|
let totalEnergy = 0;
|
|
57409
|
-
for (const item of
|
|
57395
|
+
for (const item of allNodes) {
|
|
57410
57396
|
const id = item.getId();
|
|
57411
|
-
if (!
|
|
57397
|
+
if (!activeIds.has(id))
|
|
57398
|
+
continue;
|
|
57399
|
+
if (!this.velocities.has(id))
|
|
57412
57400
|
this.velocities.set(id, { vx: 0, vy: 0 });
|
|
57413
|
-
}
|
|
57414
57401
|
const vel = this.velocities.get(id);
|
|
57415
|
-
|
|
57416
|
-
|
|
57417
|
-
|
|
57418
|
-
|
|
57419
|
-
|
|
57420
|
-
|
|
57402
|
+
const isDragged = draggedIds.has(id) || item.parent !== "Board" && draggedIds.has(item.parent);
|
|
57403
|
+
if (isDragged) {
|
|
57404
|
+
vel.vx = 0;
|
|
57405
|
+
vel.vy = 0;
|
|
57406
|
+
continue;
|
|
57407
|
+
}
|
|
57408
|
+
vel.vx = (vel.vx + (ax.get(id) ?? 0)) * conf.FG_DAMPING;
|
|
57409
|
+
vel.vy = (vel.vy + (ay.get(id) ?? 0)) * conf.FG_DAMPING;
|
|
57410
|
+
totalEnergy += Math.abs(vel.vx) + Math.abs(vel.vy);
|
|
57411
|
+
if (Math.abs(vel.vx) >= this.MIN_MOVE_PX || Math.abs(vel.vy) >= this.MIN_MOVE_PX) {
|
|
57421
57412
|
item.transformation.applyMatrixSilent({
|
|
57422
|
-
translateX:
|
|
57423
|
-
translateY:
|
|
57413
|
+
translateX: vel.vx,
|
|
57414
|
+
translateY: vel.vy,
|
|
57424
57415
|
scaleX: 1,
|
|
57425
57416
|
scaleY: 1,
|
|
57426
57417
|
shearX: 0,
|
package/dist/esm/browser.js
CHANGED
|
@@ -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:
|
|
4498
|
+
FG_SPRING_K: 0.2,
|
|
4499
4499
|
FG_TARGET_GAP: 20,
|
|
4500
|
-
FG_REPULSION:
|
|
4501
|
-
|
|
4502
|
-
|
|
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,
|
|
@@ -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;
|
|
@@ -21293,7 +21295,7 @@ class Items {
|
|
|
21293
21295
|
if (item.itemType === "Drawing" && !item.isPointNearLine(this.pointer.point)) {
|
|
21294
21296
|
return acc;
|
|
21295
21297
|
}
|
|
21296
|
-
const isItemTransparent = item instanceof Shape && item
|
|
21298
|
+
const isItemTransparent = item instanceof Shape && item.getBackgroundColor() === "none";
|
|
21297
21299
|
const itemZIndex = this.getZIndex(item);
|
|
21298
21300
|
const accZIndex = this.getZIndex(acc.nearest);
|
|
21299
21301
|
if (itemZIndex > accZIndex && (!isItemTransparent || area === acc.area) || area < acc.area) {
|
|
@@ -21389,7 +21391,7 @@ class Items {
|
|
|
21389
21391
|
});
|
|
21390
21392
|
const childrenMap = new Map;
|
|
21391
21393
|
const GroupsHTML = groups.map((group) => {
|
|
21392
|
-
group.getChildrenIds()
|
|
21394
|
+
group.getChildrenIds()?.forEach((childId) => childrenMap.set(childId, group.getId()));
|
|
21393
21395
|
const html = group.renderHTML(documentFactory);
|
|
21394
21396
|
translateElementBy(html, -lowestCoordinates.left, -lowestCoordinates.top);
|
|
21395
21397
|
return html;
|
|
@@ -21405,7 +21407,10 @@ class Items {
|
|
|
21405
21407
|
item.setAttribute("data-end-point-x", (endX - lowestCoordinates.left).toString());
|
|
21406
21408
|
item.setAttribute("data-end-point-y", (endY - lowestCoordinates.top).toString());
|
|
21407
21409
|
}
|
|
21408
|
-
|
|
21410
|
+
if (!childrenMap.get(item.id)) {
|
|
21411
|
+
return translateElementBy(item, -lowestCoordinates.left, -lowestCoordinates.top);
|
|
21412
|
+
}
|
|
21413
|
+
return item;
|
|
21409
21414
|
});
|
|
21410
21415
|
for (const item of restHTML) {
|
|
21411
21416
|
const parentFrameId = childrenMap.get(item.id);
|
|
@@ -22063,8 +22068,8 @@ class BaseItem extends Mbr {
|
|
|
22063
22068
|
}
|
|
22064
22069
|
renderHTML(documentFactory) {
|
|
22065
22070
|
const div = documentFactory.createElement("base-item");
|
|
22066
|
-
const { translateX, translateY } = this.transformation.getMatrixData();
|
|
22067
|
-
const transform = `translate(${translateX}px, ${translateY}px) scale(
|
|
22071
|
+
const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
|
|
22072
|
+
const transform = `translate(${translateX}px, ${translateY}px) scale(${scaleX}, ${scaleY})`;
|
|
22068
22073
|
div.style.backgroundColor = "#b2b0c3";
|
|
22069
22074
|
div.id = this.getId();
|
|
22070
22075
|
div.style.width = `${this.getWidth()}px`;
|
|
@@ -40248,7 +40253,7 @@ class Shape extends BaseItem {
|
|
|
40248
40253
|
if (Shapes[this.shapeType].useMbrUnderPointer) {
|
|
40249
40254
|
return this.mbr.isUnderPoint(point5);
|
|
40250
40255
|
}
|
|
40251
|
-
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 === "")) {
|
|
40252
40257
|
return this.path.isPointOverEdges(point5, tolerance);
|
|
40253
40258
|
} else {
|
|
40254
40259
|
return this.textContainer.isUnderPoint(point5) || this.path.isUnderPoint(point5);
|
|
@@ -40300,8 +40305,8 @@ class Shape extends BaseItem {
|
|
|
40300
40305
|
const pathElement = Shapes[this.shapeType].path.copy().renderHTML(documentFactory);
|
|
40301
40306
|
const paths = Array.isArray(pathElement) ? pathElement : [pathElement];
|
|
40302
40307
|
paths.forEach((element4) => {
|
|
40303
|
-
element4.setAttribute("fill", this.backgroundColor);
|
|
40304
|
-
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"));
|
|
40305
40310
|
element4.setAttribute("stroke-dasharray", LinePatterns[this.borderStyle].join(", "));
|
|
40306
40311
|
element4.setAttribute("stroke-width", this.borderWidth.toString());
|
|
40307
40312
|
element4.setAttribute("transform-origin", "0 0");
|
|
@@ -40316,8 +40321,8 @@ class Shape extends BaseItem {
|
|
|
40316
40321
|
div.style.transform = `translate(${translateX}px, ${translateY}px) scale(${scaleX}, ${scaleY})`;
|
|
40317
40322
|
div.style.position = "absolute";
|
|
40318
40323
|
div.setAttribute("data-shape-type", this.shapeType);
|
|
40319
|
-
div.setAttribute("fill", this.backgroundColor);
|
|
40320
|
-
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"));
|
|
40321
40326
|
div.setAttribute("data-border-style", this.borderStyle);
|
|
40322
40327
|
div.setAttribute("stroke-dasharray", LinePatterns[this.borderStyle].join(", "));
|
|
40323
40328
|
div.setAttribute("stroke-width", this.borderWidth.toString());
|
|
@@ -40361,9 +40366,6 @@ class Shape extends BaseItem {
|
|
|
40361
40366
|
this.text.updateElement();
|
|
40362
40367
|
}
|
|
40363
40368
|
transformPath() {
|
|
40364
|
-
if (conf.isNode()) {
|
|
40365
|
-
return;
|
|
40366
|
-
}
|
|
40367
40369
|
this.path = Shapes[this.shapeType].createPath(this.mbr);
|
|
40368
40370
|
this.textContainer = Shapes[this.shapeType].textBounds.copy();
|
|
40369
40371
|
this.text.setContainer(this.textContainer.copy());
|
|
@@ -43671,7 +43673,13 @@ class Group extends BaseItem {
|
|
|
43671
43673
|
ctx.restore();
|
|
43672
43674
|
}
|
|
43673
43675
|
renderHTML(documentFactory) {
|
|
43674
|
-
|
|
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;
|
|
43675
43683
|
}
|
|
43676
43684
|
}
|
|
43677
43685
|
// src/itemFactories.ts
|
|
@@ -54525,7 +54533,6 @@ class ForceGraphEngine {
|
|
|
54525
54533
|
activeComponents = new Map;
|
|
54526
54534
|
TICK_MS = 33;
|
|
54527
54535
|
SYNC_MS = 300;
|
|
54528
|
-
SOFTENING_SQ = 100 * 100;
|
|
54529
54536
|
MIN_MOVE_PX = 0.05;
|
|
54530
54537
|
constructor(board) {
|
|
54531
54538
|
this.board = board;
|
|
@@ -54674,42 +54681,27 @@ class ForceGraphEngine {
|
|
|
54674
54681
|
return this.board.items.listAll().filter((item) => item.itemType === "Connector");
|
|
54675
54682
|
}
|
|
54676
54683
|
tick() {
|
|
54677
|
-
const dt = this.TICK_MS / 1000;
|
|
54678
54684
|
const activeIds = this.getActiveNodeIds();
|
|
54679
54685
|
const draggedIds = this.board.getDraggedItemIds();
|
|
54680
54686
|
const allNodes = this.getNodes();
|
|
54681
|
-
const nodes = allNodes.filter((item) => {
|
|
54682
|
-
if (!activeIds.has(item.getId()))
|
|
54683
|
-
return false;
|
|
54684
|
-
if (draggedIds.has(item.getId()))
|
|
54685
|
-
return false;
|
|
54686
|
-
if (item.parent !== "Board" && draggedIds.has(item.parent))
|
|
54687
|
-
return false;
|
|
54688
|
-
return true;
|
|
54689
|
-
});
|
|
54690
|
-
if (nodes.length < 1)
|
|
54691
|
-
return;
|
|
54692
54687
|
const snapMap = new Map;
|
|
54693
|
-
for (const item of
|
|
54688
|
+
for (const item of allNodes) {
|
|
54689
|
+
if (!activeIds.has(item.getId()))
|
|
54690
|
+
continue;
|
|
54694
54691
|
const pos = item.transformation.getTranslation();
|
|
54695
54692
|
const mbr = item.getMbr();
|
|
54696
54693
|
const w = Math.max(mbr.getWidth(), 1);
|
|
54697
54694
|
const h2 = Math.max(mbr.getHeight(), 1);
|
|
54698
|
-
snapMap.set(item.getId(), {
|
|
54699
|
-
id: item.getId(),
|
|
54700
|
-
cx: pos.x + w * 0.5,
|
|
54701
|
-
cy: pos.y + h2 * 0.5,
|
|
54702
|
-
w,
|
|
54703
|
-
h: h2
|
|
54704
|
-
});
|
|
54695
|
+
snapMap.set(item.getId(), { id: item.getId(), cx: pos.x + w * 0.5, cy: pos.y + h2 * 0.5, w, h: h2 });
|
|
54705
54696
|
}
|
|
54706
54697
|
const snap = Array.from(snapMap.values());
|
|
54698
|
+
if (snap.length < 1)
|
|
54699
|
+
return;
|
|
54707
54700
|
const uf = new UnionFind;
|
|
54708
54701
|
for (const connector of this.getConnectors()) {
|
|
54709
54702
|
const { startItem, endItem } = connector.getConnectedItems();
|
|
54710
|
-
if (startItem && endItem)
|
|
54703
|
+
if (startItem && endItem)
|
|
54711
54704
|
uf.union(startItem.getId(), endItem.getId());
|
|
54712
|
-
}
|
|
54713
54705
|
}
|
|
54714
54706
|
const ax = new Map;
|
|
54715
54707
|
const ay = new Map;
|
|
@@ -54727,14 +54719,13 @@ class ForceGraphEngine {
|
|
|
54727
54719
|
continue;
|
|
54728
54720
|
const dx = s2.cx - s1.cx;
|
|
54729
54721
|
const dy = s2.cy - s1.cy;
|
|
54730
|
-
const dist = Math.sqrt(dx * dx + dy * dy)
|
|
54722
|
+
const dist = Math.sqrt(dx * dx + dy * dy) || 1;
|
|
54731
54723
|
const compId = this.findComponentId(s1.id);
|
|
54732
54724
|
const targetGap = compId ? this.activeComponents.get(compId)?.targetGap ?? conf.FG_TARGET_GAP : conf.FG_TARGET_GAP;
|
|
54733
54725
|
const targetDist = (Math.max(s1.w, s1.h) + Math.max(s2.w, s2.h)) * 0.5 + targetGap;
|
|
54734
|
-
const
|
|
54735
|
-
const
|
|
54736
|
-
const
|
|
54737
|
-
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;
|
|
54738
54729
|
ax.set(s1.id, (ax.get(s1.id) ?? 0) + fx);
|
|
54739
54730
|
ay.set(s1.id, (ay.get(s1.id) ?? 0) + fy);
|
|
54740
54731
|
ax.set(s2.id, (ax.get(s2.id) ?? 0) - fx);
|
|
@@ -54748,35 +54739,35 @@ class ForceGraphEngine {
|
|
|
54748
54739
|
continue;
|
|
54749
54740
|
const dx = s2.cx - s1.cx;
|
|
54750
54741
|
const dy = s2.cy - s1.cy;
|
|
54751
|
-
const
|
|
54752
|
-
const
|
|
54753
|
-
|
|
54754
|
-
|
|
54755
|
-
|
|
54756
|
-
|
|
54757
|
-
const fy = dy / centerDist * repMag;
|
|
54758
|
-
ax.set(s1.id, (ax.get(s1.id) ?? 0) - fx);
|
|
54759
|
-
ay.set(s1.id, (ay.get(s1.id) ?? 0) - fy);
|
|
54760
|
-
ax.set(s2.id, (ax.get(s2.id) ?? 0) + fx);
|
|
54761
|
-
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);
|
|
54762
54748
|
}
|
|
54763
54749
|
}
|
|
54764
54750
|
let totalEnergy = 0;
|
|
54765
|
-
for (const item of
|
|
54751
|
+
for (const item of allNodes) {
|
|
54766
54752
|
const id = item.getId();
|
|
54767
|
-
if (!
|
|
54753
|
+
if (!activeIds.has(id))
|
|
54754
|
+
continue;
|
|
54755
|
+
if (!this.velocities.has(id))
|
|
54768
54756
|
this.velocities.set(id, { vx: 0, vy: 0 });
|
|
54769
|
-
}
|
|
54770
54757
|
const vel = this.velocities.get(id);
|
|
54771
|
-
|
|
54772
|
-
|
|
54773
|
-
|
|
54774
|
-
|
|
54775
|
-
|
|
54776
|
-
|
|
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) {
|
|
54777
54768
|
item.transformation.applyMatrixSilent({
|
|
54778
|
-
translateX:
|
|
54779
|
-
translateY:
|
|
54769
|
+
translateX: vel.vx,
|
|
54770
|
+
translateY: vel.vy,
|
|
54780
54771
|
scaleX: 1,
|
|
54781
54772
|
scaleY: 1,
|
|
54782
54773
|
shearX: 0,
|