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/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,
|
|
@@ -8492,11 +8493,11 @@ class SessionStorage {
|
|
|
8492
8493
|
getFontHighlight(itemType) {
|
|
8493
8494
|
return this.get(`fontHighlightColor_${itemType}`);
|
|
8494
8495
|
}
|
|
8495
|
-
|
|
8496
|
-
this.set(`
|
|
8496
|
+
setHorisontalAlignment(itemType, horisontalAlignment) {
|
|
8497
|
+
this.set(`fontHorisontalAlignment_${itemType}`, horisontalAlignment);
|
|
8497
8498
|
}
|
|
8498
|
-
|
|
8499
|
-
return this.get(`
|
|
8499
|
+
getHorisontalAlignment(itemType) {
|
|
8500
|
+
return this.get(`fontHorisontalAlignment_${itemType}`);
|
|
8500
8501
|
}
|
|
8501
8502
|
setVerticalAlignment(itemType, verticalAlignment) {
|
|
8502
8503
|
this.set(`fontVerticalAlignment_${itemType}`, verticalAlignment);
|
|
@@ -19929,7 +19930,7 @@ class EditorContainer {
|
|
|
19929
19930
|
break;
|
|
19930
19931
|
case "setSelectionFontHighlight":
|
|
19931
19932
|
case "setSelectionFontStyle":
|
|
19932
|
-
case "
|
|
19933
|
+
case "setSelectionHorisontalAlignment":
|
|
19933
19934
|
this.applySelectionOp(op);
|
|
19934
19935
|
break;
|
|
19935
19936
|
case "setFontStyle":
|
|
@@ -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;
|
|
@@ -23923,10 +23925,6 @@ class Items {
|
|
|
23923
23925
|
const unmodifiedSize = size;
|
|
23924
23926
|
size = 16;
|
|
23925
23927
|
const tolerated = this.index.getEnclosedOrCrossed(x - size, y - size, x + size, y + size);
|
|
23926
|
-
const groups = tolerated.filter((item) => item.itemType === "Group");
|
|
23927
|
-
if (groups.length > 0) {
|
|
23928
|
-
return groups;
|
|
23929
|
-
}
|
|
23930
23928
|
let enclosed = tolerated.some((item) => item instanceof Connector2) ? tolerated : this.index.getEnclosedOrCrossed(x, y, x, y);
|
|
23931
23929
|
const underPointer = this.getUnderPoint(new Point(x, y), size);
|
|
23932
23930
|
if (enclosed.length === 0) {
|
|
@@ -23940,7 +23938,7 @@ class Items {
|
|
|
23940
23938
|
if (item.itemType === "Drawing" && !item.isPointNearLine(this.pointer.point)) {
|
|
23941
23939
|
return acc;
|
|
23942
23940
|
}
|
|
23943
|
-
const isItemTransparent = item instanceof Shape && item
|
|
23941
|
+
const isItemTransparent = item instanceof Shape && item.getBackgroundColor() === "none";
|
|
23944
23942
|
const itemZIndex = this.getZIndex(item);
|
|
23945
23943
|
const accZIndex = this.getZIndex(acc.nearest);
|
|
23946
23944
|
if (itemZIndex > accZIndex && (!isItemTransparent || area === acc.area) || area < acc.area) {
|
|
@@ -24036,7 +24034,7 @@ class Items {
|
|
|
24036
24034
|
});
|
|
24037
24035
|
const childrenMap = new Map;
|
|
24038
24036
|
const GroupsHTML = groups.map((group) => {
|
|
24039
|
-
group.getChildrenIds()
|
|
24037
|
+
group.getChildrenIds()?.forEach((childId) => childrenMap.set(childId, group.getId()));
|
|
24040
24038
|
const html = group.renderHTML(documentFactory);
|
|
24041
24039
|
translateElementBy(html, -lowestCoordinates.left, -lowestCoordinates.top);
|
|
24042
24040
|
return html;
|
|
@@ -24052,7 +24050,10 @@ class Items {
|
|
|
24052
24050
|
item.setAttribute("data-end-point-x", (endX - lowestCoordinates.left).toString());
|
|
24053
24051
|
item.setAttribute("data-end-point-y", (endY - lowestCoordinates.top).toString());
|
|
24054
24052
|
}
|
|
24055
|
-
|
|
24053
|
+
if (!childrenMap.get(item.id)) {
|
|
24054
|
+
return translateElementBy(item, -lowestCoordinates.left, -lowestCoordinates.top);
|
|
24055
|
+
}
|
|
24056
|
+
return item;
|
|
24056
24057
|
});
|
|
24057
24058
|
for (const item of restHTML) {
|
|
24058
24059
|
const parentFrameId = childrenMap.get(item.id);
|
|
@@ -24466,6 +24467,20 @@ class BaseItem extends Mbr {
|
|
|
24466
24467
|
parentMatrix.apply(c);
|
|
24467
24468
|
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));
|
|
24468
24469
|
}
|
|
24470
|
+
hasAncestor(itemId) {
|
|
24471
|
+
let parentId = this.parent;
|
|
24472
|
+
while (parentId && parentId !== "Board") {
|
|
24473
|
+
if (parentId === itemId) {
|
|
24474
|
+
return true;
|
|
24475
|
+
}
|
|
24476
|
+
const parent = this.board.items.getById(parentId);
|
|
24477
|
+
if (!parent || parent.parent === parentId) {
|
|
24478
|
+
break;
|
|
24479
|
+
}
|
|
24480
|
+
parentId = parent.parent;
|
|
24481
|
+
}
|
|
24482
|
+
return false;
|
|
24483
|
+
}
|
|
24469
24484
|
applyAddChildren(childIds) {
|
|
24470
24485
|
if (!this.index) {
|
|
24471
24486
|
return;
|
|
@@ -24473,7 +24488,7 @@ class BaseItem extends Mbr {
|
|
|
24473
24488
|
const containerNestingMatrix = this.getNestingMatrix();
|
|
24474
24489
|
childIds.forEach((childId) => {
|
|
24475
24490
|
const foundItem = this.board.items.getById(childId);
|
|
24476
|
-
if (this.parent !== childId && this.getId() !== childId) {
|
|
24491
|
+
if (this.parent !== childId && this.getId() !== childId && !this.hasAncestor(childId)) {
|
|
24477
24492
|
if (!this.index?.getById(childId) && foundItem) {
|
|
24478
24493
|
const localMatrix = foundItem.transformation.toMatrix().toLocalOf(containerNestingMatrix);
|
|
24479
24494
|
this.board.items.index.remove(foundItem);
|
|
@@ -24696,8 +24711,8 @@ class BaseItem extends Mbr {
|
|
|
24696
24711
|
}
|
|
24697
24712
|
renderHTML(documentFactory) {
|
|
24698
24713
|
const div = documentFactory.createElement("base-item");
|
|
24699
|
-
const { translateX, translateY } = this.transformation.getMatrixData();
|
|
24700
|
-
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})`;
|
|
24701
24716
|
div.style.backgroundColor = "#b2b0c3";
|
|
24702
24717
|
div.id = this.getId();
|
|
24703
24718
|
div.style.width = `${this.getWidth()}px`;
|
|
@@ -24968,12 +24983,14 @@ class RichText extends BaseItem {
|
|
|
24968
24983
|
top = container.top;
|
|
24969
24984
|
}
|
|
24970
24985
|
const point3 = new Point(left, top);
|
|
24971
|
-
this.
|
|
24986
|
+
if (!this.isInShape || this.autoSize) {
|
|
24987
|
+
this.getParentWorldMatrix().apply(point3);
|
|
24988
|
+
}
|
|
24972
24989
|
return {
|
|
24973
24990
|
point: point3,
|
|
24974
24991
|
width,
|
|
24975
24992
|
height,
|
|
24976
|
-
maxWidth: maxWidth ? maxWidth
|
|
24993
|
+
maxWidth: maxWidth ? maxWidth : undefined,
|
|
24977
24994
|
maxHeight,
|
|
24978
24995
|
textScale: this.isInShape && !this.autoSize ? 1 : this.getScale()
|
|
24979
24996
|
};
|
|
@@ -42662,6 +42679,7 @@ class Shape extends BaseItem {
|
|
|
42662
42679
|
this.text.deserialize(data.text);
|
|
42663
42680
|
}
|
|
42664
42681
|
this.transformPath();
|
|
42682
|
+
this.text.updateElement();
|
|
42665
42683
|
this.subject.publish(this);
|
|
42666
42684
|
return this;
|
|
42667
42685
|
}
|
|
@@ -42879,7 +42897,7 @@ class Shape extends BaseItem {
|
|
|
42879
42897
|
if (Shapes[this.shapeType].useMbrUnderPointer) {
|
|
42880
42898
|
return this.mbr.isUnderPoint(point5);
|
|
42881
42899
|
}
|
|
42882
|
-
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 === "")) {
|
|
42883
42901
|
return this.path.isPointOverEdges(point5, tolerance);
|
|
42884
42902
|
} else {
|
|
42885
42903
|
return this.textContainer.isUnderPoint(point5) || this.path.isUnderPoint(point5);
|
|
@@ -42931,8 +42949,8 @@ class Shape extends BaseItem {
|
|
|
42931
42949
|
const pathElement = Shapes[this.shapeType].path.copy().renderHTML(documentFactory);
|
|
42932
42950
|
const paths = Array.isArray(pathElement) ? pathElement : [pathElement];
|
|
42933
42951
|
paths.forEach((element3) => {
|
|
42934
|
-
element3.setAttribute("fill", this.backgroundColor);
|
|
42935
|
-
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"));
|
|
42936
42954
|
element3.setAttribute("stroke-dasharray", LinePatterns[this.borderStyle].join(", "));
|
|
42937
42955
|
element3.setAttribute("stroke-width", this.borderWidth.toString());
|
|
42938
42956
|
element3.setAttribute("transform-origin", "0 0");
|
|
@@ -42947,8 +42965,8 @@ class Shape extends BaseItem {
|
|
|
42947
42965
|
div.style.transform = `translate(${translateX}px, ${translateY}px) scale(${scaleX}, ${scaleY})`;
|
|
42948
42966
|
div.style.position = "absolute";
|
|
42949
42967
|
div.setAttribute("data-shape-type", this.shapeType);
|
|
42950
|
-
div.setAttribute("fill", this.backgroundColor);
|
|
42951
|
-
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"));
|
|
42952
42970
|
div.setAttribute("data-border-style", this.borderStyle);
|
|
42953
42971
|
div.setAttribute("stroke-dasharray", LinePatterns[this.borderStyle].join(", "));
|
|
42954
42972
|
div.setAttribute("stroke-width", this.borderWidth.toString());
|
|
@@ -42992,9 +43010,6 @@ class Shape extends BaseItem {
|
|
|
42992
43010
|
this.text.updateElement();
|
|
42993
43011
|
}
|
|
42994
43012
|
transformPath() {
|
|
42995
|
-
if (conf.isNode()) {
|
|
42996
|
-
return;
|
|
42997
|
-
}
|
|
42998
43013
|
this.path = Shapes[this.shapeType].createPath(this.mbr);
|
|
42999
43014
|
this.textContainer = Shapes[this.shapeType].textBounds.copy();
|
|
43000
43015
|
this.text.setContainer(this.textContainer.copy());
|
|
@@ -46159,6 +46174,7 @@ class Group extends BaseItem {
|
|
|
46159
46174
|
constructor(board, events, children = [], id = "") {
|
|
46160
46175
|
super(board, id, undefined, true);
|
|
46161
46176
|
this.events = events;
|
|
46177
|
+
this.canBeNested = true;
|
|
46162
46178
|
this.linkTo = new LinkTo(this.id, this.events);
|
|
46163
46179
|
this.transformation = new Transformation(this.id, this.events);
|
|
46164
46180
|
this.transformation.subject.subscribe(() => {
|
|
@@ -46301,7 +46317,13 @@ class Group extends BaseItem {
|
|
|
46301
46317
|
ctx.restore();
|
|
46302
46318
|
}
|
|
46303
46319
|
renderHTML(documentFactory) {
|
|
46304
|
-
|
|
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;
|
|
46305
46327
|
}
|
|
46306
46328
|
}
|
|
46307
46329
|
// src/itemFactories.ts
|
|
@@ -49587,7 +49609,8 @@ class Select extends Tool {
|
|
|
49587
49609
|
this.beginTimeStamp = Date.now();
|
|
49588
49610
|
const selectionMbr = selection.getMbr();
|
|
49589
49611
|
const selectionItems = selection.list();
|
|
49590
|
-
|
|
49612
|
+
const selectableHover = hover.map((item) => this.board.selection.getSelectableItem(item));
|
|
49613
|
+
this.isDownOnSelection = selectionMbr !== undefined && selectionMbr.isUnderPoint(pointer.point) && selectableHover.every((hovered) => hovered && selectionItems.some((selected) => selected.getId() === hovered.getId()));
|
|
49591
49614
|
this.isDraggingSelection = this.isDownOnSelection;
|
|
49592
49615
|
if (this.isDraggingSelection) {
|
|
49593
49616
|
this.board.selection.transformationRenderBlock = true;
|
|
@@ -49913,7 +49936,7 @@ class Select extends Tool {
|
|
|
49913
49936
|
const hovered = this.board.items.getUnderPointer();
|
|
49914
49937
|
this.board.pointer.subject.publish(this.board.pointer);
|
|
49915
49938
|
if (isCtrl || isShift) {
|
|
49916
|
-
const underPointer = hovered[0];
|
|
49939
|
+
const underPointer = this.board.selection.getSelectableItem(hovered[0]);
|
|
49917
49940
|
const isEmptySelection = this.board.selection.items.list().length === 0;
|
|
49918
49941
|
if (!underPointer && !isEmptySelection && isShift) {
|
|
49919
49942
|
this.board.selection.add(this.board.selection.items.list());
|
|
@@ -49929,14 +49952,6 @@ class Select extends Tool {
|
|
|
49929
49952
|
const isNotInSelection = this.board.selection.items.findById(underPointer.getId()) === null;
|
|
49930
49953
|
if (isNotInSelection) {
|
|
49931
49954
|
this.board.selection.add(underPointer);
|
|
49932
|
-
if ("index" in underPointer && underPointer.index) {
|
|
49933
|
-
const { left, right, top, bottom } = underPointer.getMbr();
|
|
49934
|
-
const childrenIds = underPointer.getChildrenIds();
|
|
49935
|
-
console.log("UNDERPOINTER", underPointer);
|
|
49936
|
-
console.log("CHILDREN", childrenIds);
|
|
49937
|
-
const itemsInFrame = this.board.items.getEnclosedOrCrossed(left, top, right, bottom).filter((item) => childrenIds && childrenIds.includes(item.getId()));
|
|
49938
|
-
this.board.selection.add(itemsInFrame);
|
|
49939
|
-
}
|
|
49940
49955
|
this.board.selection.setContext("EditUnderPointer");
|
|
49941
49956
|
} else {
|
|
49942
49957
|
this.board.selection.remove(underPointer);
|
|
@@ -49953,10 +49968,6 @@ class Select extends Tool {
|
|
|
49953
49968
|
} else {
|
|
49954
49969
|
this.board.selection.editUnderPointer();
|
|
49955
49970
|
}
|
|
49956
|
-
if (topItem2 instanceof Group) {
|
|
49957
|
-
const groupChildren = topItem2.getChildren();
|
|
49958
|
-
this.board.selection.add(groupChildren);
|
|
49959
|
-
}
|
|
49960
49971
|
this.board.tools.publish();
|
|
49961
49972
|
this.clear();
|
|
49962
49973
|
return false;
|
|
@@ -55992,10 +56003,23 @@ class BoardSelection {
|
|
|
55992
56003
|
getMbr() {
|
|
55993
56004
|
return this.items.getMbr();
|
|
55994
56005
|
}
|
|
56006
|
+
getSelectableItem(item) {
|
|
56007
|
+
if (!item) {
|
|
56008
|
+
return null;
|
|
56009
|
+
}
|
|
56010
|
+
if (!(item instanceof BaseItem) || item.parent === "Board") {
|
|
56011
|
+
return item;
|
|
56012
|
+
}
|
|
56013
|
+
const parent = this.board.items.getById(item.parent);
|
|
56014
|
+
if (parent instanceof Group) {
|
|
56015
|
+
return parent;
|
|
56016
|
+
}
|
|
56017
|
+
return item;
|
|
56018
|
+
}
|
|
55995
56019
|
selectUnderPointer() {
|
|
55996
56020
|
this.removeAll();
|
|
55997
56021
|
const stack = this.board.items.getUnderPointer();
|
|
55998
|
-
const top = stack.pop();
|
|
56022
|
+
const top = this.getSelectableItem(stack.pop());
|
|
55999
56023
|
if (top) {
|
|
56000
56024
|
this.add(top);
|
|
56001
56025
|
this.setTextToEdit(undefined);
|
|
@@ -56049,7 +56073,7 @@ class BoardSelection {
|
|
|
56049
56073
|
editUnderPointer() {
|
|
56050
56074
|
this.removeAll();
|
|
56051
56075
|
const stack = this.board.items.getUnderPointer();
|
|
56052
|
-
const item = stack.pop();
|
|
56076
|
+
const item = this.getSelectableItem(stack.pop());
|
|
56053
56077
|
if (item) {
|
|
56054
56078
|
this.add(item);
|
|
56055
56079
|
this.setTextToEdit(undefined);
|
|
@@ -56083,7 +56107,7 @@ class BoardSelection {
|
|
|
56083
56107
|
const textSize = tempStorage.getFontSize(item.itemType);
|
|
56084
56108
|
const highlightColor = tempStorage.getFontHighlight(item.itemType);
|
|
56085
56109
|
const styles = tempStorage.getFontStyles(item.itemType);
|
|
56086
|
-
const
|
|
56110
|
+
const horisontalAlignment = tempStorage.getHorisontalAlignment(item.itemType);
|
|
56087
56111
|
const verticalAlignment = tempStorage.getVerticalAlignment(item.itemType);
|
|
56088
56112
|
if (textColor) {
|
|
56089
56113
|
text5.setSelectionFontColor(textColor, "None");
|
|
@@ -56104,8 +56128,8 @@ class BoardSelection {
|
|
|
56104
56128
|
const stylesArr = styles;
|
|
56105
56129
|
text5.setSelectionFontStyle(stylesArr, "None");
|
|
56106
56130
|
}
|
|
56107
|
-
if (
|
|
56108
|
-
text5.setSelectionHorisontalAlignment(
|
|
56131
|
+
if (horisontalAlignment && !(item instanceof Sticker)) {
|
|
56132
|
+
text5.setSelectionHorisontalAlignment(horisontalAlignment);
|
|
56109
56133
|
}
|
|
56110
56134
|
if (verticalAlignment && !(item instanceof Sticker)) {
|
|
56111
56135
|
this.setVerticalAlignment(verticalAlignment);
|
|
@@ -56118,7 +56142,7 @@ class BoardSelection {
|
|
|
56118
56142
|
editTextUnderPointer() {
|
|
56119
56143
|
this.removeAll();
|
|
56120
56144
|
const stack = this.board.items.getUnderPointer();
|
|
56121
|
-
const top = stack.pop();
|
|
56145
|
+
const top = this.getSelectableItem(stack.pop());
|
|
56122
56146
|
if (top) {
|
|
56123
56147
|
this.add(top);
|
|
56124
56148
|
this.setContext("EditTextUnderPointer");
|
|
@@ -56728,7 +56752,7 @@ class BoardSelection {
|
|
|
56728
56752
|
selection: text5.editor.getSelection(),
|
|
56729
56753
|
ops
|
|
56730
56754
|
});
|
|
56731
|
-
tempStorage.
|
|
56755
|
+
tempStorage.setHorisontalAlignment(item.itemType, horisontalAlignment);
|
|
56732
56756
|
}
|
|
56733
56757
|
this.emitApplied({
|
|
56734
56758
|
class: "RichText",
|
|
@@ -57153,7 +57177,6 @@ class ForceGraphEngine {
|
|
|
57153
57177
|
activeComponents = new Map;
|
|
57154
57178
|
TICK_MS = 33;
|
|
57155
57179
|
SYNC_MS = 300;
|
|
57156
|
-
SOFTENING_SQ = 100 * 100;
|
|
57157
57180
|
MIN_MOVE_PX = 0.05;
|
|
57158
57181
|
constructor(board) {
|
|
57159
57182
|
this.board = board;
|
|
@@ -57302,42 +57325,27 @@ class ForceGraphEngine {
|
|
|
57302
57325
|
return this.board.items.listAll().filter((item) => item.itemType === "Connector");
|
|
57303
57326
|
}
|
|
57304
57327
|
tick() {
|
|
57305
|
-
const dt = this.TICK_MS / 1000;
|
|
57306
57328
|
const activeIds = this.getActiveNodeIds();
|
|
57307
57329
|
const draggedIds = this.board.getDraggedItemIds();
|
|
57308
57330
|
const allNodes = this.getNodes();
|
|
57309
|
-
const nodes = allNodes.filter((item) => {
|
|
57310
|
-
if (!activeIds.has(item.getId()))
|
|
57311
|
-
return false;
|
|
57312
|
-
if (draggedIds.has(item.getId()))
|
|
57313
|
-
return false;
|
|
57314
|
-
if (item.parent !== "Board" && draggedIds.has(item.parent))
|
|
57315
|
-
return false;
|
|
57316
|
-
return true;
|
|
57317
|
-
});
|
|
57318
|
-
if (nodes.length < 1)
|
|
57319
|
-
return;
|
|
57320
57331
|
const snapMap = new Map;
|
|
57321
|
-
for (const item of
|
|
57332
|
+
for (const item of allNodes) {
|
|
57333
|
+
if (!activeIds.has(item.getId()))
|
|
57334
|
+
continue;
|
|
57322
57335
|
const pos = item.transformation.getTranslation();
|
|
57323
57336
|
const mbr = item.getMbr();
|
|
57324
57337
|
const w = Math.max(mbr.getWidth(), 1);
|
|
57325
57338
|
const h2 = Math.max(mbr.getHeight(), 1);
|
|
57326
|
-
snapMap.set(item.getId(), {
|
|
57327
|
-
id: item.getId(),
|
|
57328
|
-
cx: pos.x + w * 0.5,
|
|
57329
|
-
cy: pos.y + h2 * 0.5,
|
|
57330
|
-
w,
|
|
57331
|
-
h: h2
|
|
57332
|
-
});
|
|
57339
|
+
snapMap.set(item.getId(), { id: item.getId(), cx: pos.x + w * 0.5, cy: pos.y + h2 * 0.5, w, h: h2 });
|
|
57333
57340
|
}
|
|
57334
57341
|
const snap = Array.from(snapMap.values());
|
|
57342
|
+
if (snap.length < 1)
|
|
57343
|
+
return;
|
|
57335
57344
|
const uf = new UnionFind;
|
|
57336
57345
|
for (const connector of this.getConnectors()) {
|
|
57337
57346
|
const { startItem, endItem } = connector.getConnectedItems();
|
|
57338
|
-
if (startItem && endItem)
|
|
57347
|
+
if (startItem && endItem)
|
|
57339
57348
|
uf.union(startItem.getId(), endItem.getId());
|
|
57340
|
-
}
|
|
57341
57349
|
}
|
|
57342
57350
|
const ax = new Map;
|
|
57343
57351
|
const ay = new Map;
|
|
@@ -57355,14 +57363,13 @@ class ForceGraphEngine {
|
|
|
57355
57363
|
continue;
|
|
57356
57364
|
const dx = s2.cx - s1.cx;
|
|
57357
57365
|
const dy = s2.cy - s1.cy;
|
|
57358
|
-
const dist = Math.sqrt(dx * dx + dy * dy)
|
|
57366
|
+
const dist = Math.sqrt(dx * dx + dy * dy) || 1;
|
|
57359
57367
|
const compId = this.findComponentId(s1.id);
|
|
57360
57368
|
const targetGap = compId ? this.activeComponents.get(compId)?.targetGap ?? conf.FG_TARGET_GAP : conf.FG_TARGET_GAP;
|
|
57361
57369
|
const targetDist = (Math.max(s1.w, s1.h) + Math.max(s2.w, s2.h)) * 0.5 + targetGap;
|
|
57362
|
-
const
|
|
57363
|
-
const
|
|
57364
|
-
const
|
|
57365
|
-
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;
|
|
57366
57373
|
ax.set(s1.id, (ax.get(s1.id) ?? 0) + fx);
|
|
57367
57374
|
ay.set(s1.id, (ay.get(s1.id) ?? 0) + fy);
|
|
57368
57375
|
ax.set(s2.id, (ax.get(s2.id) ?? 0) - fx);
|
|
@@ -57376,35 +57383,35 @@ class ForceGraphEngine {
|
|
|
57376
57383
|
continue;
|
|
57377
57384
|
const dx = s2.cx - s1.cx;
|
|
57378
57385
|
const dy = s2.cy - s1.cy;
|
|
57379
|
-
const
|
|
57380
|
-
const
|
|
57381
|
-
|
|
57382
|
-
|
|
57383
|
-
|
|
57384
|
-
|
|
57385
|
-
const fy = dy / centerDist * repMag;
|
|
57386
|
-
ax.set(s1.id, (ax.get(s1.id) ?? 0) - fx);
|
|
57387
|
-
ay.set(s1.id, (ay.get(s1.id) ?? 0) - fy);
|
|
57388
|
-
ax.set(s2.id, (ax.get(s2.id) ?? 0) + fx);
|
|
57389
|
-
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);
|
|
57390
57392
|
}
|
|
57391
57393
|
}
|
|
57392
57394
|
let totalEnergy = 0;
|
|
57393
|
-
for (const item of
|
|
57395
|
+
for (const item of allNodes) {
|
|
57394
57396
|
const id = item.getId();
|
|
57395
|
-
if (!
|
|
57397
|
+
if (!activeIds.has(id))
|
|
57398
|
+
continue;
|
|
57399
|
+
if (!this.velocities.has(id))
|
|
57396
57400
|
this.velocities.set(id, { vx: 0, vy: 0 });
|
|
57397
|
-
}
|
|
57398
57401
|
const vel = this.velocities.get(id);
|
|
57399
|
-
|
|
57400
|
-
|
|
57401
|
-
|
|
57402
|
-
|
|
57403
|
-
|
|
57404
|
-
|
|
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) {
|
|
57405
57412
|
item.transformation.applyMatrixSilent({
|
|
57406
|
-
translateX:
|
|
57407
|
-
translateY:
|
|
57413
|
+
translateX: vel.vx,
|
|
57414
|
+
translateY: vel.vy,
|
|
57408
57415
|
scaleX: 1,
|
|
57409
57416
|
scaleY: 1,
|
|
57410
57417
|
shearX: 0,
|
|
@@ -57665,9 +57672,10 @@ class Board {
|
|
|
57665
57672
|
if (!item || !(item instanceof Group)) {
|
|
57666
57673
|
return;
|
|
57667
57674
|
}
|
|
57668
|
-
item.getChildren()
|
|
57669
|
-
|
|
57670
|
-
|
|
57675
|
+
const children = [...item.getChildren()];
|
|
57676
|
+
item.applyRemoveChildren(children.map((child) => child.getId()));
|
|
57677
|
+
children.forEach((child) => {
|
|
57678
|
+
child.transformation.isLocked = false;
|
|
57671
57679
|
});
|
|
57672
57680
|
item.transformation.isLocked = false;
|
|
57673
57681
|
const removedItems = [];
|
|
@@ -57682,9 +57690,7 @@ class Board {
|
|
|
57682
57690
|
if (!item || !(item instanceof Group)) {
|
|
57683
57691
|
return;
|
|
57684
57692
|
}
|
|
57685
|
-
item.
|
|
57686
|
-
item2.parent = "Board";
|
|
57687
|
-
});
|
|
57693
|
+
item.applyRemoveChildren(item.getChildrenIds());
|
|
57688
57694
|
const removedItems = [];
|
|
57689
57695
|
this.findItemAndApply(op.item, (item2) => {
|
|
57690
57696
|
this.index.remove(item2);
|