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.
- package/dist/cjs/browser.js +116 -110
- package/dist/cjs/index.js +116 -110
- package/dist/cjs/node.js +116 -110
- package/dist/esm/browser.js +116 -110
- package/dist/esm/index.js +116 -110
- package/dist/esm/node.js +116 -110
- package/dist/types/ForceGraph/ForceGraphEngine.d.ts +0 -1
- package/dist/types/Items/BaseItem/BaseItem.d.ts +1 -0
- package/dist/types/Items/RichText/RichTextOperations.d.ts +1 -1
- package/dist/types/Selection/Selection.d.ts +1 -0
- package/dist/types/SessionStorage.d.ts +2 -2
- package/dist/types/Settings.d.ts +1 -0
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -4488,11 +4488,12 @@ var conf = {
|
|
|
4488
4488
|
DEFAULT_GAME_ITEM_DIMENSIONS: { width: 200, height: 200 },
|
|
4489
4489
|
MAX_CARD_SIZE: 500,
|
|
4490
4490
|
CONNECTOR_ITEM_OFFSET: 20,
|
|
4491
|
-
FG_SPRING_K:
|
|
4491
|
+
FG_SPRING_K: 0.2,
|
|
4492
4492
|
FG_TARGET_GAP: 20,
|
|
4493
|
-
FG_REPULSION:
|
|
4494
|
-
|
|
4495
|
-
|
|
4493
|
+
FG_REPULSION: 100,
|
|
4494
|
+
FG_MIN_DIST_SQ: 100,
|
|
4495
|
+
FG_DAMPING: 0.6,
|
|
4496
|
+
FG_SLEEP_THRESHOLD: 0.5,
|
|
4496
4497
|
GRAVITY_G: 80,
|
|
4497
4498
|
GRAVITY_G_CENTER: 120,
|
|
4498
4499
|
GRAVITY_DAMPING: 0.96,
|
|
@@ -7268,11 +7269,11 @@ class SessionStorage {
|
|
|
7268
7269
|
getFontHighlight(itemType) {
|
|
7269
7270
|
return this.get(`fontHighlightColor_${itemType}`);
|
|
7270
7271
|
}
|
|
7271
|
-
|
|
7272
|
-
this.set(`
|
|
7272
|
+
setHorisontalAlignment(itemType, horisontalAlignment) {
|
|
7273
|
+
this.set(`fontHorisontalAlignment_${itemType}`, horisontalAlignment);
|
|
7273
7274
|
}
|
|
7274
|
-
|
|
7275
|
-
return this.get(`
|
|
7275
|
+
getHorisontalAlignment(itemType) {
|
|
7276
|
+
return this.get(`fontHorisontalAlignment_${itemType}`);
|
|
7276
7277
|
}
|
|
7277
7278
|
setVerticalAlignment(itemType, verticalAlignment) {
|
|
7278
7279
|
this.set(`fontVerticalAlignment_${itemType}`, verticalAlignment);
|
|
@@ -17211,7 +17212,7 @@ class EditorContainer {
|
|
|
17211
17212
|
break;
|
|
17212
17213
|
case "setSelectionFontHighlight":
|
|
17213
17214
|
case "setSelectionFontStyle":
|
|
17214
|
-
case "
|
|
17215
|
+
case "setSelectionHorisontalAlignment":
|
|
17215
17216
|
this.applySelectionOp(op);
|
|
17216
17217
|
break;
|
|
17217
17218
|
case "setFontStyle":
|
|
@@ -20898,14 +20899,14 @@ class SpatialIndex {
|
|
|
20898
20899
|
if ("index" in item && item.index) {
|
|
20899
20900
|
item.removeChildItems(item.index.list());
|
|
20900
20901
|
}
|
|
20902
|
+
this.itemsArray.splice(this.itemsArray.indexOf(item), 1);
|
|
20903
|
+
this.itemsIndex.remove(item);
|
|
20901
20904
|
if (item.parent !== "Board") {
|
|
20902
20905
|
const parentFrame = this.items.getById(item.parent);
|
|
20903
20906
|
parentFrame?.removeChildItems(item);
|
|
20904
20907
|
this.subject.publish(this.items);
|
|
20905
20908
|
return;
|
|
20906
20909
|
}
|
|
20907
|
-
this.itemsArray.splice(this.itemsArray.indexOf(item), 1);
|
|
20908
|
-
this.itemsIndex.remove(item);
|
|
20909
20910
|
if (this.itemsArray.length === 0) {
|
|
20910
20911
|
this.Mbr = new Mbr;
|
|
20911
20912
|
} else {
|
|
@@ -20926,7 +20927,8 @@ class SpatialIndex {
|
|
|
20926
20927
|
translateX: worldMatrix.translateX,
|
|
20927
20928
|
translateY: worldMatrix.translateY,
|
|
20928
20929
|
scaleX: worldMatrix.scaleX,
|
|
20929
|
-
scaleY: worldMatrix.scaleY
|
|
20930
|
+
scaleY: worldMatrix.scaleY,
|
|
20931
|
+
isLocked: false
|
|
20930
20932
|
};
|
|
20931
20933
|
}
|
|
20932
20934
|
return serialized;
|
|
@@ -21273,10 +21275,6 @@ class Items {
|
|
|
21273
21275
|
const unmodifiedSize = size;
|
|
21274
21276
|
size = 16;
|
|
21275
21277
|
const tolerated = this.index.getEnclosedOrCrossed(x - size, y - size, x + size, y + size);
|
|
21276
|
-
const groups = tolerated.filter((item) => item.itemType === "Group");
|
|
21277
|
-
if (groups.length > 0) {
|
|
21278
|
-
return groups;
|
|
21279
|
-
}
|
|
21280
21278
|
let enclosed = tolerated.some((item) => item instanceof Connector2) ? tolerated : this.index.getEnclosedOrCrossed(x, y, x, y);
|
|
21281
21279
|
const underPointer = this.getUnderPoint(new Point(x, y), size);
|
|
21282
21280
|
if (enclosed.length === 0) {
|
|
@@ -21290,7 +21288,7 @@ class Items {
|
|
|
21290
21288
|
if (item.itemType === "Drawing" && !item.isPointNearLine(this.pointer.point)) {
|
|
21291
21289
|
return acc;
|
|
21292
21290
|
}
|
|
21293
|
-
const isItemTransparent = item instanceof Shape && item
|
|
21291
|
+
const isItemTransparent = item instanceof Shape && item.getBackgroundColor() === "none";
|
|
21294
21292
|
const itemZIndex = this.getZIndex(item);
|
|
21295
21293
|
const accZIndex = this.getZIndex(acc.nearest);
|
|
21296
21294
|
if (itemZIndex > accZIndex && (!isItemTransparent || area === acc.area) || area < acc.area) {
|
|
@@ -21386,7 +21384,7 @@ class Items {
|
|
|
21386
21384
|
});
|
|
21387
21385
|
const childrenMap = new Map;
|
|
21388
21386
|
const GroupsHTML = groups.map((group) => {
|
|
21389
|
-
group.getChildrenIds()
|
|
21387
|
+
group.getChildrenIds()?.forEach((childId) => childrenMap.set(childId, group.getId()));
|
|
21390
21388
|
const html = group.renderHTML(documentFactory);
|
|
21391
21389
|
translateElementBy(html, -lowestCoordinates.left, -lowestCoordinates.top);
|
|
21392
21390
|
return html;
|
|
@@ -21402,7 +21400,10 @@ class Items {
|
|
|
21402
21400
|
item.setAttribute("data-end-point-x", (endX - lowestCoordinates.left).toString());
|
|
21403
21401
|
item.setAttribute("data-end-point-y", (endY - lowestCoordinates.top).toString());
|
|
21404
21402
|
}
|
|
21405
|
-
|
|
21403
|
+
if (!childrenMap.get(item.id)) {
|
|
21404
|
+
return translateElementBy(item, -lowestCoordinates.left, -lowestCoordinates.top);
|
|
21405
|
+
}
|
|
21406
|
+
return item;
|
|
21406
21407
|
});
|
|
21407
21408
|
for (const item of restHTML) {
|
|
21408
21409
|
const parentFrameId = childrenMap.get(item.id);
|
|
@@ -21816,6 +21817,20 @@ class BaseItem extends Mbr {
|
|
|
21816
21817
|
parentMatrix.apply(c);
|
|
21817
21818
|
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));
|
|
21818
21819
|
}
|
|
21820
|
+
hasAncestor(itemId) {
|
|
21821
|
+
let parentId = this.parent;
|
|
21822
|
+
while (parentId && parentId !== "Board") {
|
|
21823
|
+
if (parentId === itemId) {
|
|
21824
|
+
return true;
|
|
21825
|
+
}
|
|
21826
|
+
const parent = this.board.items.getById(parentId);
|
|
21827
|
+
if (!parent || parent.parent === parentId) {
|
|
21828
|
+
break;
|
|
21829
|
+
}
|
|
21830
|
+
parentId = parent.parent;
|
|
21831
|
+
}
|
|
21832
|
+
return false;
|
|
21833
|
+
}
|
|
21819
21834
|
applyAddChildren(childIds) {
|
|
21820
21835
|
if (!this.index) {
|
|
21821
21836
|
return;
|
|
@@ -21823,7 +21838,7 @@ class BaseItem extends Mbr {
|
|
|
21823
21838
|
const containerNestingMatrix = this.getNestingMatrix();
|
|
21824
21839
|
childIds.forEach((childId) => {
|
|
21825
21840
|
const foundItem = this.board.items.getById(childId);
|
|
21826
|
-
if (this.parent !== childId && this.getId() !== childId) {
|
|
21841
|
+
if (this.parent !== childId && this.getId() !== childId && !this.hasAncestor(childId)) {
|
|
21827
21842
|
if (!this.index?.getById(childId) && foundItem) {
|
|
21828
21843
|
const localMatrix = foundItem.transformation.toMatrix().toLocalOf(containerNestingMatrix);
|
|
21829
21844
|
this.board.items.index.remove(foundItem);
|
|
@@ -22046,8 +22061,8 @@ class BaseItem extends Mbr {
|
|
|
22046
22061
|
}
|
|
22047
22062
|
renderHTML(documentFactory) {
|
|
22048
22063
|
const div = documentFactory.createElement("base-item");
|
|
22049
|
-
const { translateX, translateY } = this.transformation.getMatrixData();
|
|
22050
|
-
const transform = `translate(${translateX}px, ${translateY}px) scale(
|
|
22064
|
+
const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
|
|
22065
|
+
const transform = `translate(${translateX}px, ${translateY}px) scale(${scaleX}, ${scaleY})`;
|
|
22051
22066
|
div.style.backgroundColor = "#b2b0c3";
|
|
22052
22067
|
div.id = this.getId();
|
|
22053
22068
|
div.style.width = `${this.getWidth()}px`;
|
|
@@ -22318,12 +22333,14 @@ class RichText extends BaseItem {
|
|
|
22318
22333
|
top = container.top;
|
|
22319
22334
|
}
|
|
22320
22335
|
const point3 = new Point(left, top);
|
|
22321
|
-
this.
|
|
22336
|
+
if (!this.isInShape || this.autoSize) {
|
|
22337
|
+
this.getParentWorldMatrix().apply(point3);
|
|
22338
|
+
}
|
|
22322
22339
|
return {
|
|
22323
22340
|
point: point3,
|
|
22324
22341
|
width,
|
|
22325
22342
|
height,
|
|
22326
|
-
maxWidth: maxWidth ? maxWidth
|
|
22343
|
+
maxWidth: maxWidth ? maxWidth : undefined,
|
|
22327
22344
|
maxHeight,
|
|
22328
22345
|
textScale: this.isInShape && !this.autoSize ? 1 : this.getScale()
|
|
22329
22346
|
};
|
|
@@ -40011,6 +40028,7 @@ class Shape extends BaseItem {
|
|
|
40011
40028
|
this.text.deserialize(data.text);
|
|
40012
40029
|
}
|
|
40013
40030
|
this.transformPath();
|
|
40031
|
+
this.text.updateElement();
|
|
40014
40032
|
this.subject.publish(this);
|
|
40015
40033
|
return this;
|
|
40016
40034
|
}
|
|
@@ -40228,7 +40246,7 @@ class Shape extends BaseItem {
|
|
|
40228
40246
|
if (Shapes[this.shapeType].useMbrUnderPointer) {
|
|
40229
40247
|
return this.mbr.isUnderPoint(point5);
|
|
40230
40248
|
}
|
|
40231
|
-
if (this.text.isEmpty() && (this.backgroundOpacity === 0 || this.backgroundColor === "none" || this.backgroundColor === "")) {
|
|
40249
|
+
if (this.text.isEmpty() && (this.backgroundOpacity === 0 || this.backgroundColor === "none" || this.backgroundColor === "transparent" || this.backgroundColor === "")) {
|
|
40232
40250
|
return this.path.isPointOverEdges(point5, tolerance);
|
|
40233
40251
|
} else {
|
|
40234
40252
|
return this.textContainer.isUnderPoint(point5) || this.path.isUnderPoint(point5);
|
|
@@ -40280,8 +40298,8 @@ class Shape extends BaseItem {
|
|
|
40280
40298
|
const pathElement = Shapes[this.shapeType].path.copy().renderHTML(documentFactory);
|
|
40281
40299
|
const paths = Array.isArray(pathElement) ? pathElement : [pathElement];
|
|
40282
40300
|
paths.forEach((element4) => {
|
|
40283
|
-
element4.setAttribute("fill", this.backgroundColor);
|
|
40284
|
-
element4.setAttribute("stroke", this.borderColor);
|
|
40301
|
+
element4.setAttribute("fill", resolveColor(this.backgroundColor, conf.theme, "background"));
|
|
40302
|
+
element4.setAttribute("stroke", resolveColor(this.borderColor, conf.theme, "foreground"));
|
|
40285
40303
|
element4.setAttribute("stroke-dasharray", LinePatterns[this.borderStyle].join(", "));
|
|
40286
40304
|
element4.setAttribute("stroke-width", this.borderWidth.toString());
|
|
40287
40305
|
element4.setAttribute("transform-origin", "0 0");
|
|
@@ -40296,8 +40314,8 @@ class Shape extends BaseItem {
|
|
|
40296
40314
|
div.style.transform = `translate(${translateX}px, ${translateY}px) scale(${scaleX}, ${scaleY})`;
|
|
40297
40315
|
div.style.position = "absolute";
|
|
40298
40316
|
div.setAttribute("data-shape-type", this.shapeType);
|
|
40299
|
-
div.setAttribute("fill", this.backgroundColor);
|
|
40300
|
-
div.setAttribute("stroke", this.borderColor);
|
|
40317
|
+
div.setAttribute("fill", resolveColor(this.backgroundColor, conf.theme, "background"));
|
|
40318
|
+
div.setAttribute("stroke", resolveColor(this.borderColor, conf.theme, "foreground"));
|
|
40301
40319
|
div.setAttribute("data-border-style", this.borderStyle);
|
|
40302
40320
|
div.setAttribute("stroke-dasharray", LinePatterns[this.borderStyle].join(", "));
|
|
40303
40321
|
div.setAttribute("stroke-width", this.borderWidth.toString());
|
|
@@ -40341,9 +40359,6 @@ class Shape extends BaseItem {
|
|
|
40341
40359
|
this.text.updateElement();
|
|
40342
40360
|
}
|
|
40343
40361
|
transformPath() {
|
|
40344
|
-
if (conf.isNode()) {
|
|
40345
|
-
return;
|
|
40346
|
-
}
|
|
40347
40362
|
this.path = Shapes[this.shapeType].createPath(this.mbr);
|
|
40348
40363
|
this.textContainer = Shapes[this.shapeType].textBounds.copy();
|
|
40349
40364
|
this.text.setContainer(this.textContainer.copy());
|
|
@@ -43508,6 +43523,7 @@ class Group extends BaseItem {
|
|
|
43508
43523
|
constructor(board, events, children = [], id = "") {
|
|
43509
43524
|
super(board, id, undefined, true);
|
|
43510
43525
|
this.events = events;
|
|
43526
|
+
this.canBeNested = true;
|
|
43511
43527
|
this.linkTo = new LinkTo(this.id, this.events);
|
|
43512
43528
|
this.transformation = new Transformation(this.id, this.events);
|
|
43513
43529
|
this.transformation.subject.subscribe(() => {
|
|
@@ -43650,7 +43666,13 @@ class Group extends BaseItem {
|
|
|
43650
43666
|
ctx.restore();
|
|
43651
43667
|
}
|
|
43652
43668
|
renderHTML(documentFactory) {
|
|
43653
|
-
|
|
43669
|
+
const div = documentFactory.createElement("div");
|
|
43670
|
+
div.id = this.id;
|
|
43671
|
+
const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
|
|
43672
|
+
div.style.transform = `translate(${translateX}px, ${translateY}px) scale(${scaleX}, ${scaleY})`;
|
|
43673
|
+
div.style.position = "absolute";
|
|
43674
|
+
div.style.transformOrigin = "0 0";
|
|
43675
|
+
return div;
|
|
43654
43676
|
}
|
|
43655
43677
|
}
|
|
43656
43678
|
// src/itemFactories.ts
|
|
@@ -46936,7 +46958,8 @@ class Select extends Tool {
|
|
|
46936
46958
|
this.beginTimeStamp = Date.now();
|
|
46937
46959
|
const selectionMbr = selection.getMbr();
|
|
46938
46960
|
const selectionItems = selection.list();
|
|
46939
|
-
|
|
46961
|
+
const selectableHover = hover.map((item) => this.board.selection.getSelectableItem(item));
|
|
46962
|
+
this.isDownOnSelection = selectionMbr !== undefined && selectionMbr.isUnderPoint(pointer.point) && selectableHover.every((hovered) => hovered && selectionItems.some((selected) => selected.getId() === hovered.getId()));
|
|
46940
46963
|
this.isDraggingSelection = this.isDownOnSelection;
|
|
46941
46964
|
if (this.isDraggingSelection) {
|
|
46942
46965
|
this.board.selection.transformationRenderBlock = true;
|
|
@@ -47262,7 +47285,7 @@ class Select extends Tool {
|
|
|
47262
47285
|
const hovered = this.board.items.getUnderPointer();
|
|
47263
47286
|
this.board.pointer.subject.publish(this.board.pointer);
|
|
47264
47287
|
if (isCtrl || isShift) {
|
|
47265
|
-
const underPointer = hovered[0];
|
|
47288
|
+
const underPointer = this.board.selection.getSelectableItem(hovered[0]);
|
|
47266
47289
|
const isEmptySelection = this.board.selection.items.list().length === 0;
|
|
47267
47290
|
if (!underPointer && !isEmptySelection && isShift) {
|
|
47268
47291
|
this.board.selection.add(this.board.selection.items.list());
|
|
@@ -47278,14 +47301,6 @@ class Select extends Tool {
|
|
|
47278
47301
|
const isNotInSelection = this.board.selection.items.findById(underPointer.getId()) === null;
|
|
47279
47302
|
if (isNotInSelection) {
|
|
47280
47303
|
this.board.selection.add(underPointer);
|
|
47281
|
-
if ("index" in underPointer && underPointer.index) {
|
|
47282
|
-
const { left, right, top, bottom } = underPointer.getMbr();
|
|
47283
|
-
const childrenIds = underPointer.getChildrenIds();
|
|
47284
|
-
console.log("UNDERPOINTER", underPointer);
|
|
47285
|
-
console.log("CHILDREN", childrenIds);
|
|
47286
|
-
const itemsInFrame = this.board.items.getEnclosedOrCrossed(left, top, right, bottom).filter((item) => childrenIds && childrenIds.includes(item.getId()));
|
|
47287
|
-
this.board.selection.add(itemsInFrame);
|
|
47288
|
-
}
|
|
47289
47304
|
this.board.selection.setContext("EditUnderPointer");
|
|
47290
47305
|
} else {
|
|
47291
47306
|
this.board.selection.remove(underPointer);
|
|
@@ -47302,10 +47317,6 @@ class Select extends Tool {
|
|
|
47302
47317
|
} else {
|
|
47303
47318
|
this.board.selection.editUnderPointer();
|
|
47304
47319
|
}
|
|
47305
|
-
if (topItem2 instanceof Group) {
|
|
47306
|
-
const groupChildren = topItem2.getChildren();
|
|
47307
|
-
this.board.selection.add(groupChildren);
|
|
47308
|
-
}
|
|
47309
47320
|
this.board.tools.publish();
|
|
47310
47321
|
this.clear();
|
|
47311
47322
|
return false;
|
|
@@ -53341,10 +53352,23 @@ class BoardSelection {
|
|
|
53341
53352
|
getMbr() {
|
|
53342
53353
|
return this.items.getMbr();
|
|
53343
53354
|
}
|
|
53355
|
+
getSelectableItem(item) {
|
|
53356
|
+
if (!item) {
|
|
53357
|
+
return null;
|
|
53358
|
+
}
|
|
53359
|
+
if (!(item instanceof BaseItem) || item.parent === "Board") {
|
|
53360
|
+
return item;
|
|
53361
|
+
}
|
|
53362
|
+
const parent = this.board.items.getById(item.parent);
|
|
53363
|
+
if (parent instanceof Group) {
|
|
53364
|
+
return parent;
|
|
53365
|
+
}
|
|
53366
|
+
return item;
|
|
53367
|
+
}
|
|
53344
53368
|
selectUnderPointer() {
|
|
53345
53369
|
this.removeAll();
|
|
53346
53370
|
const stack = this.board.items.getUnderPointer();
|
|
53347
|
-
const top = stack.pop();
|
|
53371
|
+
const top = this.getSelectableItem(stack.pop());
|
|
53348
53372
|
if (top) {
|
|
53349
53373
|
this.add(top);
|
|
53350
53374
|
this.setTextToEdit(undefined);
|
|
@@ -53398,7 +53422,7 @@ class BoardSelection {
|
|
|
53398
53422
|
editUnderPointer() {
|
|
53399
53423
|
this.removeAll();
|
|
53400
53424
|
const stack = this.board.items.getUnderPointer();
|
|
53401
|
-
const item = stack.pop();
|
|
53425
|
+
const item = this.getSelectableItem(stack.pop());
|
|
53402
53426
|
if (item) {
|
|
53403
53427
|
this.add(item);
|
|
53404
53428
|
this.setTextToEdit(undefined);
|
|
@@ -53432,7 +53456,7 @@ class BoardSelection {
|
|
|
53432
53456
|
const textSize = tempStorage.getFontSize(item.itemType);
|
|
53433
53457
|
const highlightColor = tempStorage.getFontHighlight(item.itemType);
|
|
53434
53458
|
const styles = tempStorage.getFontStyles(item.itemType);
|
|
53435
|
-
const
|
|
53459
|
+
const horisontalAlignment = tempStorage.getHorisontalAlignment(item.itemType);
|
|
53436
53460
|
const verticalAlignment = tempStorage.getVerticalAlignment(item.itemType);
|
|
53437
53461
|
if (textColor) {
|
|
53438
53462
|
text5.setSelectionFontColor(textColor, "None");
|
|
@@ -53453,8 +53477,8 @@ class BoardSelection {
|
|
|
53453
53477
|
const stylesArr = styles;
|
|
53454
53478
|
text5.setSelectionFontStyle(stylesArr, "None");
|
|
53455
53479
|
}
|
|
53456
|
-
if (
|
|
53457
|
-
text5.setSelectionHorisontalAlignment(
|
|
53480
|
+
if (horisontalAlignment && !(item instanceof Sticker)) {
|
|
53481
|
+
text5.setSelectionHorisontalAlignment(horisontalAlignment);
|
|
53458
53482
|
}
|
|
53459
53483
|
if (verticalAlignment && !(item instanceof Sticker)) {
|
|
53460
53484
|
this.setVerticalAlignment(verticalAlignment);
|
|
@@ -53467,7 +53491,7 @@ class BoardSelection {
|
|
|
53467
53491
|
editTextUnderPointer() {
|
|
53468
53492
|
this.removeAll();
|
|
53469
53493
|
const stack = this.board.items.getUnderPointer();
|
|
53470
|
-
const top = stack.pop();
|
|
53494
|
+
const top = this.getSelectableItem(stack.pop());
|
|
53471
53495
|
if (top) {
|
|
53472
53496
|
this.add(top);
|
|
53473
53497
|
this.setContext("EditTextUnderPointer");
|
|
@@ -54077,7 +54101,7 @@ class BoardSelection {
|
|
|
54077
54101
|
selection: text5.editor.getSelection(),
|
|
54078
54102
|
ops
|
|
54079
54103
|
});
|
|
54080
|
-
tempStorage.
|
|
54104
|
+
tempStorage.setHorisontalAlignment(item.itemType, horisontalAlignment);
|
|
54081
54105
|
}
|
|
54082
54106
|
this.emitApplied({
|
|
54083
54107
|
class: "RichText",
|
|
@@ -54502,7 +54526,6 @@ class ForceGraphEngine {
|
|
|
54502
54526
|
activeComponents = new Map;
|
|
54503
54527
|
TICK_MS = 33;
|
|
54504
54528
|
SYNC_MS = 300;
|
|
54505
|
-
SOFTENING_SQ = 100 * 100;
|
|
54506
54529
|
MIN_MOVE_PX = 0.05;
|
|
54507
54530
|
constructor(board) {
|
|
54508
54531
|
this.board = board;
|
|
@@ -54651,42 +54674,27 @@ class ForceGraphEngine {
|
|
|
54651
54674
|
return this.board.items.listAll().filter((item) => item.itemType === "Connector");
|
|
54652
54675
|
}
|
|
54653
54676
|
tick() {
|
|
54654
|
-
const dt = this.TICK_MS / 1000;
|
|
54655
54677
|
const activeIds = this.getActiveNodeIds();
|
|
54656
54678
|
const draggedIds = this.board.getDraggedItemIds();
|
|
54657
54679
|
const allNodes = this.getNodes();
|
|
54658
|
-
const nodes = allNodes.filter((item) => {
|
|
54659
|
-
if (!activeIds.has(item.getId()))
|
|
54660
|
-
return false;
|
|
54661
|
-
if (draggedIds.has(item.getId()))
|
|
54662
|
-
return false;
|
|
54663
|
-
if (item.parent !== "Board" && draggedIds.has(item.parent))
|
|
54664
|
-
return false;
|
|
54665
|
-
return true;
|
|
54666
|
-
});
|
|
54667
|
-
if (nodes.length < 1)
|
|
54668
|
-
return;
|
|
54669
54680
|
const snapMap = new Map;
|
|
54670
|
-
for (const item of
|
|
54681
|
+
for (const item of allNodes) {
|
|
54682
|
+
if (!activeIds.has(item.getId()))
|
|
54683
|
+
continue;
|
|
54671
54684
|
const pos = item.transformation.getTranslation();
|
|
54672
54685
|
const mbr = item.getMbr();
|
|
54673
54686
|
const w = Math.max(mbr.getWidth(), 1);
|
|
54674
54687
|
const h2 = Math.max(mbr.getHeight(), 1);
|
|
54675
|
-
snapMap.set(item.getId(), {
|
|
54676
|
-
id: item.getId(),
|
|
54677
|
-
cx: pos.x + w * 0.5,
|
|
54678
|
-
cy: pos.y + h2 * 0.5,
|
|
54679
|
-
w,
|
|
54680
|
-
h: h2
|
|
54681
|
-
});
|
|
54688
|
+
snapMap.set(item.getId(), { id: item.getId(), cx: pos.x + w * 0.5, cy: pos.y + h2 * 0.5, w, h: h2 });
|
|
54682
54689
|
}
|
|
54683
54690
|
const snap = Array.from(snapMap.values());
|
|
54691
|
+
if (snap.length < 1)
|
|
54692
|
+
return;
|
|
54684
54693
|
const uf = new UnionFind;
|
|
54685
54694
|
for (const connector of this.getConnectors()) {
|
|
54686
54695
|
const { startItem, endItem } = connector.getConnectedItems();
|
|
54687
|
-
if (startItem && endItem)
|
|
54696
|
+
if (startItem && endItem)
|
|
54688
54697
|
uf.union(startItem.getId(), endItem.getId());
|
|
54689
|
-
}
|
|
54690
54698
|
}
|
|
54691
54699
|
const ax = new Map;
|
|
54692
54700
|
const ay = new Map;
|
|
@@ -54704,14 +54712,13 @@ class ForceGraphEngine {
|
|
|
54704
54712
|
continue;
|
|
54705
54713
|
const dx = s2.cx - s1.cx;
|
|
54706
54714
|
const dy = s2.cy - s1.cy;
|
|
54707
|
-
const dist = Math.sqrt(dx * dx + dy * dy)
|
|
54715
|
+
const dist = Math.sqrt(dx * dx + dy * dy) || 1;
|
|
54708
54716
|
const compId = this.findComponentId(s1.id);
|
|
54709
54717
|
const targetGap = compId ? this.activeComponents.get(compId)?.targetGap ?? conf.FG_TARGET_GAP : conf.FG_TARGET_GAP;
|
|
54710
54718
|
const targetDist = (Math.max(s1.w, s1.h) + Math.max(s2.w, s2.h)) * 0.5 + targetGap;
|
|
54711
|
-
const
|
|
54712
|
-
const
|
|
54713
|
-
const
|
|
54714
|
-
const fy = dy / dist * forceMag;
|
|
54719
|
+
const force = (dist - targetDist) * conf.FG_SPRING_K;
|
|
54720
|
+
const fx = dx / dist * force;
|
|
54721
|
+
const fy = dy / dist * force;
|
|
54715
54722
|
ax.set(s1.id, (ax.get(s1.id) ?? 0) + fx);
|
|
54716
54723
|
ay.set(s1.id, (ay.get(s1.id) ?? 0) + fy);
|
|
54717
54724
|
ax.set(s2.id, (ax.get(s2.id) ?? 0) - fx);
|
|
@@ -54725,35 +54732,35 @@ class ForceGraphEngine {
|
|
|
54725
54732
|
continue;
|
|
54726
54733
|
const dx = s2.cx - s1.cx;
|
|
54727
54734
|
const dy = s2.cy - s1.cy;
|
|
54728
|
-
const
|
|
54729
|
-
const
|
|
54730
|
-
|
|
54731
|
-
|
|
54732
|
-
|
|
54733
|
-
|
|
54734
|
-
const fy = dy / centerDist * repMag;
|
|
54735
|
-
ax.set(s1.id, (ax.get(s1.id) ?? 0) - fx);
|
|
54736
|
-
ay.set(s1.id, (ay.get(s1.id) ?? 0) - fy);
|
|
54737
|
-
ax.set(s2.id, (ax.get(s2.id) ?? 0) + fx);
|
|
54738
|
-
ay.set(s2.id, (ay.get(s2.id) ?? 0) + fy);
|
|
54735
|
+
const distSq = Math.max(dx * dx + dy * dy, conf.FG_MIN_DIST_SQ);
|
|
54736
|
+
const force = conf.FG_REPULSION / distSq;
|
|
54737
|
+
ax.set(s1.id, (ax.get(s1.id) ?? 0) - dx * force);
|
|
54738
|
+
ay.set(s1.id, (ay.get(s1.id) ?? 0) - dy * force);
|
|
54739
|
+
ax.set(s2.id, (ax.get(s2.id) ?? 0) + dx * force);
|
|
54740
|
+
ay.set(s2.id, (ay.get(s2.id) ?? 0) + dy * force);
|
|
54739
54741
|
}
|
|
54740
54742
|
}
|
|
54741
54743
|
let totalEnergy = 0;
|
|
54742
|
-
for (const item of
|
|
54744
|
+
for (const item of allNodes) {
|
|
54743
54745
|
const id = item.getId();
|
|
54744
|
-
if (!
|
|
54746
|
+
if (!activeIds.has(id))
|
|
54747
|
+
continue;
|
|
54748
|
+
if (!this.velocities.has(id))
|
|
54745
54749
|
this.velocities.set(id, { vx: 0, vy: 0 });
|
|
54746
|
-
}
|
|
54747
54750
|
const vel = this.velocities.get(id);
|
|
54748
|
-
|
|
54749
|
-
|
|
54750
|
-
|
|
54751
|
-
|
|
54752
|
-
|
|
54753
|
-
|
|
54751
|
+
const isDragged = draggedIds.has(id) || item.parent !== "Board" && draggedIds.has(item.parent);
|
|
54752
|
+
if (isDragged) {
|
|
54753
|
+
vel.vx = 0;
|
|
54754
|
+
vel.vy = 0;
|
|
54755
|
+
continue;
|
|
54756
|
+
}
|
|
54757
|
+
vel.vx = (vel.vx + (ax.get(id) ?? 0)) * conf.FG_DAMPING;
|
|
54758
|
+
vel.vy = (vel.vy + (ay.get(id) ?? 0)) * conf.FG_DAMPING;
|
|
54759
|
+
totalEnergy += Math.abs(vel.vx) + Math.abs(vel.vy);
|
|
54760
|
+
if (Math.abs(vel.vx) >= this.MIN_MOVE_PX || Math.abs(vel.vy) >= this.MIN_MOVE_PX) {
|
|
54754
54761
|
item.transformation.applyMatrixSilent({
|
|
54755
|
-
translateX:
|
|
54756
|
-
translateY:
|
|
54762
|
+
translateX: vel.vx,
|
|
54763
|
+
translateY: vel.vy,
|
|
54757
54764
|
scaleX: 1,
|
|
54758
54765
|
scaleY: 1,
|
|
54759
54766
|
shearX: 0,
|
|
@@ -55014,9 +55021,10 @@ class Board {
|
|
|
55014
55021
|
if (!item || !(item instanceof Group)) {
|
|
55015
55022
|
return;
|
|
55016
55023
|
}
|
|
55017
|
-
item.getChildren()
|
|
55018
|
-
|
|
55019
|
-
|
|
55024
|
+
const children = [...item.getChildren()];
|
|
55025
|
+
item.applyRemoveChildren(children.map((child) => child.getId()));
|
|
55026
|
+
children.forEach((child) => {
|
|
55027
|
+
child.transformation.isLocked = false;
|
|
55020
55028
|
});
|
|
55021
55029
|
item.transformation.isLocked = false;
|
|
55022
55030
|
const removedItems = [];
|
|
@@ -55031,9 +55039,7 @@ class Board {
|
|
|
55031
55039
|
if (!item || !(item instanceof Group)) {
|
|
55032
55040
|
return;
|
|
55033
55041
|
}
|
|
55034
|
-
item.
|
|
55035
|
-
item2.parent = "Board";
|
|
55036
|
-
});
|
|
55042
|
+
item.applyRemoveChildren(item.getChildrenIds());
|
|
55037
55043
|
const removedItems = [];
|
|
55038
55044
|
this.findItemAndApply(op.item, (item2) => {
|
|
55039
55045
|
this.index.remove(item2);
|