microboard-ui-temp 0.10.0 → 0.10.2
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/{chunk-kh8veacg.js → chunk-e1r2sk6e.js} +108 -51
- package/dist/example.html +1 -1
- package/dist/index.html +1 -1
- package/dist/index.js +108 -51
- package/dist/spa.css +0 -6
- package/dist/spa.js +108 -51
- package/package.json +2 -2
|
@@ -248398,7 +248398,13 @@ var conf = {
|
|
|
248398
248398
|
CARD_DIMENSIONS: { width: 250, height: 400 },
|
|
248399
248399
|
DEFAULT_GAME_ITEM_DIMENSIONS: { width: 200, height: 200 },
|
|
248400
248400
|
MAX_CARD_SIZE: 500,
|
|
248401
|
-
CONNECTOR_ITEM_OFFSET: 20
|
|
248401
|
+
CONNECTOR_ITEM_OFFSET: 20,
|
|
248402
|
+
GRAVITY_G: 80,
|
|
248403
|
+
GRAVITY_G_CENTER: 120,
|
|
248404
|
+
GRAVITY_DAMPING: 0.96,
|
|
248405
|
+
GRAVITY_RESTITUTION: 0.5,
|
|
248406
|
+
GRAVITY_REPULSION: 200,
|
|
248407
|
+
GRAVITY_MAX_DISTANCE: 3000
|
|
248402
248408
|
};
|
|
248403
248409
|
initDefaultI18N();
|
|
248404
248410
|
var BG_LIGHT = "rgb(248, 249, 251)";
|
|
@@ -265469,7 +265475,7 @@ class BaseItem extends Mbr {
|
|
|
265469
265475
|
if (!this.isHoverHighlighted) {
|
|
265470
265476
|
return;
|
|
265471
265477
|
}
|
|
265472
|
-
const mbr = this.
|
|
265478
|
+
const mbr = this.getWorldMbr();
|
|
265473
265479
|
mbr.strokeWidth = 2 / context.matrix.scaleX;
|
|
265474
265480
|
mbr.borderColor = BaseItem.HOVER_HIGHLIGHT_COLOR;
|
|
265475
265481
|
mbr.render(context);
|
|
@@ -265528,6 +265534,8 @@ class RichText extends BaseItem {
|
|
|
265528
265534
|
_onLimitReached = () => {};
|
|
265529
265535
|
shrinkWidth = false;
|
|
265530
265536
|
prevMbr = null;
|
|
265537
|
+
customTransformationMatrix;
|
|
265538
|
+
renderingScale;
|
|
265531
265539
|
rtCounter = 0;
|
|
265532
265540
|
constructor(board, container, id2 = "", transformation = new Transformation(id2, board.events), linkTo, placeholderText = conf.i18n?.t("board.textPlaceholder"), isInShape = false, autoSize = false, insideOf, initialTextStyles = conf.DEFAULT_TEXT_STYLES) {
|
|
265533
265541
|
super(board, id2);
|
|
@@ -265650,10 +265658,10 @@ class RichText extends BaseItem {
|
|
|
265650
265658
|
const shouldUpdateLayout = this.getTextWidth() > (maxWidth || 0);
|
|
265651
265659
|
if (shouldUpdateLayout) {
|
|
265652
265660
|
this.updateElement();
|
|
265653
|
-
this.subject.publish(this);
|
|
265654
265661
|
} else {
|
|
265655
265662
|
this.transformCanvas();
|
|
265656
265663
|
this.recoordinate(maxWidth);
|
|
265664
|
+
this.subject.publish(this);
|
|
265657
265665
|
}
|
|
265658
265666
|
}
|
|
265659
265667
|
handleFocus = () => {
|
|
@@ -265717,10 +265725,10 @@ class RichText extends BaseItem {
|
|
|
265717
265725
|
}
|
|
265718
265726
|
getMaxWidth() {
|
|
265719
265727
|
if (this.autoSize) {
|
|
265720
|
-
return this.editor.maxWidth || this.
|
|
265728
|
+
return this.editor.maxWidth || this.container.getWidth();
|
|
265721
265729
|
}
|
|
265722
265730
|
if (this.isContainerSet) {
|
|
265723
|
-
return this.
|
|
265731
|
+
return this.container.getWidth();
|
|
265724
265732
|
} else {
|
|
265725
265733
|
return this.containerMaxWidth || this.editor.maxWidth;
|
|
265726
265734
|
}
|
|
@@ -265821,13 +265829,17 @@ class RichText extends BaseItem {
|
|
|
265821
265829
|
return this.shrinkWidth;
|
|
265822
265830
|
}
|
|
265823
265831
|
getTransformedContainer() {
|
|
265824
|
-
|
|
265825
|
-
|
|
265826
|
-
|
|
265827
|
-
|
|
265828
|
-
|
|
265832
|
+
const cameraScale = this.board.camera.getScale();
|
|
265833
|
+
const extraScale = this.renderingScale ? this.renderingScale(cameraScale) : 1;
|
|
265834
|
+
let matrix;
|
|
265835
|
+
if (this.customTransformationMatrix) {
|
|
265836
|
+
matrix = this.customTransformationMatrix();
|
|
265837
|
+
} else {
|
|
265838
|
+
matrix = this.transformation.toMatrix();
|
|
265829
265839
|
}
|
|
265830
|
-
|
|
265840
|
+
const { translateX, translateY, scaleX, scaleY } = matrix;
|
|
265841
|
+
const scaledMatrix = new Matrix(translateX, translateY, scaleX, scaleY);
|
|
265842
|
+
return this.container.getTransformed(scaledMatrix);
|
|
265831
265843
|
}
|
|
265832
265844
|
emitWithoutApplying = (op) => {
|
|
265833
265845
|
if (this.board.events) {
|
|
@@ -266186,10 +266198,20 @@ class RichText extends BaseItem {
|
|
|
266186
266198
|
const { ctx } = context;
|
|
266187
266199
|
ctx.save();
|
|
266188
266200
|
ctx.translate(this.left, this.top);
|
|
266201
|
+
const cameraScale = context.getCameraScale();
|
|
266202
|
+
const extraScale = this.renderingScale ? this.renderingScale(cameraScale) : 1;
|
|
266203
|
+
let matrix;
|
|
266204
|
+
if (this.customTransformationMatrix) {
|
|
266205
|
+
matrix = this.customTransformationMatrix();
|
|
266206
|
+
} else {
|
|
266207
|
+
matrix = this.transformation.toMatrix();
|
|
266208
|
+
}
|
|
266209
|
+
const { scaleX, scaleY } = matrix;
|
|
266189
266210
|
const shouldScale = !this.isInShape && !this.autoSize;
|
|
266190
266211
|
if (shouldScale) {
|
|
266191
|
-
|
|
266192
|
-
|
|
266212
|
+
ctx.scale(scaleX * extraScale, scaleY * extraScale);
|
|
266213
|
+
} else if (extraScale !== 1) {
|
|
266214
|
+
ctx.scale(extraScale, extraScale);
|
|
266193
266215
|
}
|
|
266194
266216
|
const shouldClip = this.insideOf === "Shape" || this.insideOf === "Sticker";
|
|
266195
266217
|
if (shouldClip) {
|
|
@@ -266321,10 +266343,18 @@ class RichText extends BaseItem {
|
|
|
266321
266343
|
return unsafe.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
266322
266344
|
};
|
|
266323
266345
|
const elements = this.editor.editor.children.map(renderNode);
|
|
266324
|
-
const
|
|
266325
|
-
const
|
|
266326
|
-
|
|
266327
|
-
|
|
266346
|
+
const cameraScale = this.board.camera.getScale();
|
|
266347
|
+
const extraScale = this.renderingScale ? this.renderingScale(cameraScale) : 1;
|
|
266348
|
+
let matrix;
|
|
266349
|
+
if (this.customTransformationMatrix) {
|
|
266350
|
+
matrix = this.customTransformationMatrix();
|
|
266351
|
+
} else {
|
|
266352
|
+
matrix = this.transformation.toMatrix();
|
|
266353
|
+
}
|
|
266354
|
+
const { scaleX, scaleY } = matrix;
|
|
266355
|
+
const transform = `translate(${this.left}px, ${this.top}px) scale(${scaleX * extraScale}, ${scaleY * extraScale})`;
|
|
266356
|
+
const transformedWidth = this.getMbr().getWidth();
|
|
266357
|
+
const transformedHeight = this.getMbr().getHeight();
|
|
266328
266358
|
const div = documentFactory.createElement("rich-text");
|
|
266329
266359
|
div.id = this.getId();
|
|
266330
266360
|
div.style.width = `${transformedWidth + 5}px`;
|
|
@@ -282909,7 +282939,9 @@ class Shape extends BaseItem {
|
|
|
282909
282939
|
this.subject.publish(this);
|
|
282910
282940
|
});
|
|
282911
282941
|
this.text.insideOf = this.itemType;
|
|
282942
|
+
this.transformPath();
|
|
282912
282943
|
this.updateMbr();
|
|
282944
|
+
this.subject.publish(this);
|
|
282913
282945
|
}
|
|
282914
282946
|
saveShapeData() {
|
|
282915
282947
|
tempStorage.setShapeData({
|
|
@@ -283458,6 +283490,8 @@ class Sticker extends BaseItem {
|
|
|
283458
283490
|
this.subject.publish(this);
|
|
283459
283491
|
});
|
|
283460
283492
|
this.text.updateElement();
|
|
283493
|
+
this.transformPath();
|
|
283494
|
+
this.subject.publish(this);
|
|
283461
283495
|
}
|
|
283462
283496
|
emit(operation) {
|
|
283463
283497
|
if (this.board.events) {
|
|
@@ -283844,11 +283878,11 @@ function convertBlobToDataUrl(blob) {
|
|
|
283844
283878
|
};
|
|
283845
283879
|
});
|
|
283846
283880
|
}
|
|
283847
|
-
var FRAME_BORDER_COLOR = "
|
|
283881
|
+
var FRAME_BORDER_COLOR = semanticColor("contrastGray");
|
|
283848
283882
|
var FRAME_HIGHLIGHTER_BORDER_COLOR = "#93AFF6";
|
|
283849
283883
|
var FRAME_CHILDREN_HIGHLIGHTER_COLOR = "rgb(10, 15, 41, .08)";
|
|
283850
283884
|
var FRAME_CHILDREN_HIGHLIGHTER_BORDER_COLOR = "#4778F5";
|
|
283851
|
-
var FRAME_TITLE_COLOR = "
|
|
283885
|
+
var FRAME_TITLE_COLOR = semanticColor("contrastNeutral");
|
|
283852
283886
|
var FRAME_TYPES = [
|
|
283853
283887
|
{ id: "Custom", label: "Custom" },
|
|
283854
283888
|
{ id: "Frame16x9", label: "16:9" },
|
|
@@ -283893,7 +283927,7 @@ class DefaultFrameData {
|
|
|
283893
283927
|
canChangeRatio;
|
|
283894
283928
|
linkTo;
|
|
283895
283929
|
itemType = "Frame";
|
|
283896
|
-
constructor(shapeType = "Custom", backgroundColor =
|
|
283930
|
+
constructor(shapeType = "Custom", backgroundColor = semanticColor("contrastNeutral"), backgroundOpacity = 1, borderColor = FRAME_BORDER_COLOR, borderOpacity = 1, borderStyle = "solid", borderWidth = 0.2, transformation = new DefaultTransformationData, children = [], text5 = new DefaultRichTextData([], "top", 600), canChangeRatio = true, linkTo) {
|
|
283897
283931
|
this.shapeType = shapeType;
|
|
283898
283932
|
this.backgroundColor = backgroundColor;
|
|
283899
283933
|
this.backgroundOpacity = backgroundOpacity;
|
|
@@ -283909,6 +283943,8 @@ class DefaultFrameData {
|
|
|
283909
283943
|
}
|
|
283910
283944
|
}
|
|
283911
283945
|
var defaultFrameData = new DefaultFrameData;
|
|
283946
|
+
var HEADING_TOP_OFFSET = -33;
|
|
283947
|
+
var HEADING_BOTTOM_OFFSET = -5;
|
|
283912
283948
|
|
|
283913
283949
|
class Frame2 extends BaseItem {
|
|
283914
283950
|
getItemById;
|
|
@@ -283924,7 +283960,7 @@ class Frame2 extends BaseItem {
|
|
|
283924
283960
|
parent = "Board";
|
|
283925
283961
|
transformation;
|
|
283926
283962
|
subject = new Subject;
|
|
283927
|
-
textContainer;
|
|
283963
|
+
textContainer = new Mbr;
|
|
283928
283964
|
path;
|
|
283929
283965
|
children = [];
|
|
283930
283966
|
mbr = new Mbr;
|
|
@@ -283945,12 +283981,23 @@ class Frame2 extends BaseItem {
|
|
|
283945
283981
|
this.borderOpacity = borderOpacity;
|
|
283946
283982
|
this.borderStyle = borderStyle;
|
|
283947
283983
|
this.borderWidth = borderWidth;
|
|
283948
|
-
this.textContainer = Frames[this.shapeType].textBounds.copy();
|
|
283949
283984
|
this.path = Frames[this.shapeType].path.copy();
|
|
283950
283985
|
this.transformation = new Transformation(this.id, board.events);
|
|
283951
283986
|
this.linkTo = new LinkTo(this.id, board.events);
|
|
283952
|
-
|
|
283987
|
+
const textBounds = Frames[this.shapeType].textBounds.copy();
|
|
283988
|
+
textBounds.top = HEADING_TOP_OFFSET;
|
|
283989
|
+
textBounds.bottom = HEADING_BOTTOM_OFFSET;
|
|
283990
|
+
this.textContainer = textBounds;
|
|
283991
|
+
this.text = new RichText(board, this.textContainer, this.id, this.transformation, this.linkTo, this.name, true, false, "Frame", { ...conf.DEFAULT_TEXT_STYLES, fontSize: 18, fontColor: FRAME_TITLE_COLOR });
|
|
283992
|
+
this.text.editor.verticalAlignment = "bottom";
|
|
283953
283993
|
this.text.setSelectionHorisontalAlignment("left");
|
|
283994
|
+
this.text.customTransformationMatrix = () => {
|
|
283995
|
+
const matrix = this.transformation.toMatrix();
|
|
283996
|
+
return new Matrix(matrix.translateX, matrix.translateY, 1, 1);
|
|
283997
|
+
};
|
|
283998
|
+
this.text.renderingScale = (cameraScale) => {
|
|
283999
|
+
return Math.max(1, Math.min(6, 1.2 / cameraScale));
|
|
284000
|
+
};
|
|
283954
284001
|
this.transformation.subject.subscribe(() => {
|
|
283955
284002
|
this.transformPath();
|
|
283956
284003
|
this.updateMbr();
|
|
@@ -283975,9 +284022,17 @@ class Frame2 extends BaseItem {
|
|
|
283975
284022
|
}
|
|
283976
284023
|
initPath() {
|
|
283977
284024
|
this.path = Frames[this.shapeType].path.copy();
|
|
283978
|
-
this.
|
|
283979
|
-
|
|
283980
|
-
|
|
284025
|
+
this.updateTextContainer();
|
|
284026
|
+
}
|
|
284027
|
+
updateTextContainer() {
|
|
284028
|
+
const textBounds = Frames[this.shapeType].textBounds.copy();
|
|
284029
|
+
textBounds.top = HEADING_TOP_OFFSET;
|
|
284030
|
+
textBounds.bottom = HEADING_BOTTOM_OFFSET;
|
|
284031
|
+
this.textContainer = textBounds;
|
|
284032
|
+
if (this.text) {
|
|
284033
|
+
this.text.setContainer(this.textContainer.copy());
|
|
284034
|
+
this.text.updateElement();
|
|
284035
|
+
}
|
|
283981
284036
|
}
|
|
283982
284037
|
getPaths() {
|
|
283983
284038
|
return this.path;
|
|
@@ -284120,6 +284175,7 @@ class Frame2 extends BaseItem {
|
|
|
284120
284175
|
}
|
|
284121
284176
|
if (data.text) {
|
|
284122
284177
|
this.text.deserialize(data.text);
|
|
284178
|
+
this.updateTextContainer();
|
|
284123
284179
|
}
|
|
284124
284180
|
this.canChangeRatio = data.canChangeRatio ?? this.canChangeRatio;
|
|
284125
284181
|
this.subject.publish(this);
|
|
@@ -284135,15 +284191,13 @@ class Frame2 extends BaseItem {
|
|
|
284135
284191
|
}
|
|
284136
284192
|
transformPath(saveProportions = false) {
|
|
284137
284193
|
this.path = Frames[this.shapeType].path.copy();
|
|
284138
|
-
this.
|
|
284194
|
+
this.updateTextContainer();
|
|
284139
284195
|
if (saveProportions) {
|
|
284140
284196
|
const newMatrix = this.getSavedProportionsMatrix();
|
|
284141
284197
|
this.path.transform(newMatrix);
|
|
284142
|
-
this.textContainer.transform(newMatrix);
|
|
284143
284198
|
this.transformation.applyScaleTo(newMatrix.scaleX, newMatrix.scaleY);
|
|
284144
284199
|
} else {
|
|
284145
284200
|
this.path.transform(this.transformation.toMatrix());
|
|
284146
|
-
this.textContainer.transform(this.transformation.toMatrix());
|
|
284147
284201
|
}
|
|
284148
284202
|
this.path.setBackgroundOpacity(this.backgroundOpacity);
|
|
284149
284203
|
this.path.setBorderWidth(this.borderWidth);
|
|
@@ -288931,8 +288985,9 @@ function getQuickAddButtons(selection, board) {
|
|
|
288931
288985
|
let quickAddItems = undefined;
|
|
288932
288986
|
function calculateQuickAddPosition(index2, selectedItem, connectorStartPoint) {
|
|
288933
288987
|
const connectorStorage = new SessionStorage;
|
|
288934
|
-
const currMbr = selectedItem.getPathMbr();
|
|
288988
|
+
const currMbr = selectedItem instanceof BaseItem ? selectedItem.getWorldMbr() : selectedItem.getPathMbr();
|
|
288935
288989
|
const selectedItemData = selectedItem.serialize();
|
|
288990
|
+
const selectedMatrix = selectedItem instanceof BaseItem ? selectedItem.getWorldMatrix() : new Matrix(selectedItemData.transformation?.translateX || 0, selectedItemData.transformation?.translateY || 0);
|
|
288936
288991
|
const width2 = currMbr.getWidth();
|
|
288937
288992
|
const height3 = currMbr.getHeight();
|
|
288938
288993
|
let offsetX = width2;
|
|
@@ -288972,8 +289027,8 @@ function getQuickAddButtons(selection, board) {
|
|
|
288972
289027
|
const adjustment = baseAdjustments[index2];
|
|
288973
289028
|
const newItemData = { ...itemData };
|
|
288974
289029
|
if (newItemData.transformation) {
|
|
288975
|
-
newItemData.transformation.translateX = adjustment.translateX +
|
|
288976
|
-
newItemData.transformation.translateY = adjustment.translateY +
|
|
289030
|
+
newItemData.transformation.translateX = adjustment.translateX + selectedMatrix.translateX;
|
|
289031
|
+
newItemData.transformation.translateY = adjustment.translateY + selectedMatrix.translateY + height3 / 2 - newHeight / 2;
|
|
288977
289032
|
}
|
|
288978
289033
|
const newMbr = new Mbr(newItemData.transformation?.translateX, newItemData.transformation?.translateY, (newItemData.transformation?.translateX || 0) + newWidth, (newItemData.transformation?.translateY || 0) + newHeight);
|
|
288979
289034
|
let step = 1;
|
|
@@ -289064,7 +289119,7 @@ function getQuickAddButtons(selection, board) {
|
|
|
289064
289119
|
}
|
|
289065
289120
|
function getQuickButtonsPositions(customMbr) {
|
|
289066
289121
|
const single = selection.items.getSingle();
|
|
289067
|
-
const itemMbr = customMbr ? customMbr : single?.getMbr();
|
|
289122
|
+
const itemMbr = customMbr ? customMbr : single instanceof BaseItem ? single.getWorldMbr() : single?.getMbr();
|
|
289068
289123
|
if (!itemMbr || single?.itemType !== "Sticker" && single?.itemType !== "Shape" && single?.itemType !== "AINode" && single?.itemType !== "RichText") {
|
|
289069
289124
|
return;
|
|
289070
289125
|
}
|
|
@@ -296469,9 +296524,9 @@ class BoardSelection {
|
|
|
296469
296524
|
}
|
|
296470
296525
|
const selectedMbr = selected.reduce((acc, item) => {
|
|
296471
296526
|
if (!acc) {
|
|
296472
|
-
return item.getMbr();
|
|
296527
|
+
return item instanceof BaseItem ? item.getWorldMbr() : item.getMbr();
|
|
296473
296528
|
}
|
|
296474
|
-
return acc.combine(item.getMbr());
|
|
296529
|
+
return acc.combine(item instanceof BaseItem ? item.getWorldMbr() : item.getMbr());
|
|
296475
296530
|
}, undefined);
|
|
296476
296531
|
if (selectedMbr) {
|
|
296477
296532
|
const selectedMap = Object.fromEntries(selected.map((item) => [item.getId(), { item, nested: false }]));
|
|
@@ -296503,7 +296558,7 @@ class BoardSelection {
|
|
|
296503
296558
|
const childrenIds = val.item.getChildrenIds();
|
|
296504
296559
|
if (childrenIds) {
|
|
296505
296560
|
const currGroup = val.item;
|
|
296506
|
-
const currMbr = currGroup.
|
|
296561
|
+
const currMbr = currGroup.getWorldMbr();
|
|
296507
296562
|
const children = childrenIds.map((childId) => this.board.items.getById(childId)).filter((item) => !!item);
|
|
296508
296563
|
const underGroup = this.board.items.getEnclosedOrCrossed(currMbr.left, currMbr.top, currMbr.right, currMbr.bottom).filter((item) => item.parent === "Board" || item.parent === currGroup.getId());
|
|
296509
296564
|
const uniqueItems = new Set;
|
|
@@ -296984,7 +297039,7 @@ class BoardSelection {
|
|
|
296984
297039
|
};
|
|
296985
297040
|
}
|
|
296986
297041
|
renderItemMbr(context, item, customScale) {
|
|
296987
|
-
const mbr = item.getMbr();
|
|
297042
|
+
const mbr = item instanceof BaseItem ? item.getWorldMbr() : item.getMbr();
|
|
296988
297043
|
mbr.strokeWidth = !customScale ? 1 / context.matrix.scaleX : 1 / customScale;
|
|
296989
297044
|
const selectionColor = item.transformation.isLocked ? conf.SELECTION_LOCKED_COLOR : conf.SELECTION_COLOR;
|
|
296990
297045
|
mbr.borderColor = selectionColor;
|
|
@@ -297041,7 +297096,7 @@ class BoardSelection {
|
|
|
297041
297096
|
path22.setBackgroundColor("none");
|
|
297042
297097
|
path22.render(context);
|
|
297043
297098
|
} else {
|
|
297044
|
-
const itemRect = item.getMbr();
|
|
297099
|
+
const itemRect = item instanceof BaseItem ? item.getWorldMbr() : item.getMbr();
|
|
297045
297100
|
itemRect.borderColor = CONTEXT_NODE_HIGHLIGHT_COLOR;
|
|
297046
297101
|
itemRect.strokeWidth = 2;
|
|
297047
297102
|
itemRect.render(context);
|
|
@@ -297057,13 +297112,8 @@ class GravityEngine {
|
|
|
297057
297112
|
tickTimer = null;
|
|
297058
297113
|
syncTimer = null;
|
|
297059
297114
|
lastSyncedPositions = new Map;
|
|
297060
|
-
G = 80;
|
|
297061
|
-
G_CENTER = 120;
|
|
297062
|
-
DAMPING = 0.92;
|
|
297063
|
-
REPULSION = 800;
|
|
297064
297115
|
TICK_MS = 33;
|
|
297065
297116
|
SYNC_MS = 300;
|
|
297066
|
-
MAX_DISTANCE = 3000;
|
|
297067
297117
|
SOFTENING_SQ = 50 * 50;
|
|
297068
297118
|
MIN_MOVE_PX = 0.1;
|
|
297069
297119
|
constructor(board) {
|
|
@@ -297132,8 +297182,8 @@ class GravityEngine {
|
|
|
297132
297182
|
const dcx = centerX - s1.cx;
|
|
297133
297183
|
const dcy = centerY - s1.cy;
|
|
297134
297184
|
const distCenter = Math.sqrt(dcx * dcx + dcy * dcy) + 1;
|
|
297135
|
-
ax +=
|
|
297136
|
-
ay +=
|
|
297185
|
+
ax += conf.GRAVITY_G_CENTER * dcx / distCenter;
|
|
297186
|
+
ay += conf.GRAVITY_G_CENTER * dcy / distCenter;
|
|
297137
297187
|
for (let j = 0;j < snap.length; j++) {
|
|
297138
297188
|
if (i === j)
|
|
297139
297189
|
continue;
|
|
@@ -297141,7 +297191,7 @@ class GravityEngine {
|
|
|
297141
297191
|
const dx = s2.cx - s1.cx;
|
|
297142
297192
|
const dy = s2.cy - s1.cy;
|
|
297143
297193
|
const dist = Math.sqrt(dx * dx + dy * dy) + 0.001;
|
|
297144
|
-
if (dist >
|
|
297194
|
+
if (dist > conf.GRAVITY_MAX_DISTANCE)
|
|
297145
297195
|
continue;
|
|
297146
297196
|
const overlapping = s1.right > s2.left && s2.right > s1.left && s1.bottom > s2.top && s2.bottom > s1.top;
|
|
297147
297197
|
if (overlapping) {
|
|
@@ -297149,20 +297199,27 @@ class GravityEngine {
|
|
|
297149
297199
|
const overlapY = Math.min(s1.bottom, s2.bottom) - Math.max(s1.top, s2.top);
|
|
297150
297200
|
if (overlapX < overlapY) {
|
|
297151
297201
|
const sign = s1.cx < s2.cx ? -1 : 1;
|
|
297152
|
-
|
|
297202
|
+
if (sign * vel.vx < 0)
|
|
297203
|
+
vel.vx = -vel.vx * conf.GRAVITY_RESTITUTION;
|
|
297204
|
+
ax += sign * conf.GRAVITY_REPULSION * overlapX;
|
|
297153
297205
|
} else {
|
|
297154
297206
|
const sign = s1.cy < s2.cy ? -1 : 1;
|
|
297155
|
-
|
|
297207
|
+
if (sign * vel.vy < 0)
|
|
297208
|
+
vel.vy = -vel.vy * conf.GRAVITY_RESTITUTION;
|
|
297209
|
+
ay += sign * conf.GRAVITY_REPULSION * overlapY;
|
|
297156
297210
|
}
|
|
297157
297211
|
} else {
|
|
297212
|
+
const touchDist = (s1.w + s2.w + s1.h + s2.h) * 0.25;
|
|
297213
|
+
if (dist < touchDist + 5)
|
|
297214
|
+
continue;
|
|
297158
297215
|
const distSq = dx * dx + dy * dy;
|
|
297159
|
-
const gravAcc =
|
|
297216
|
+
const gravAcc = conf.GRAVITY_G * s2.mass / (distSq + this.SOFTENING_SQ);
|
|
297160
297217
|
ax += gravAcc * dx / dist;
|
|
297161
297218
|
ay += gravAcc * dy / dist;
|
|
297162
297219
|
}
|
|
297163
297220
|
}
|
|
297164
|
-
vel.vx = (vel.vx + ax * dt) *
|
|
297165
|
-
vel.vy = (vel.vy + ay * dt) *
|
|
297221
|
+
vel.vx = (vel.vx + ax * dt) * conf.GRAVITY_DAMPING;
|
|
297222
|
+
vel.vy = (vel.vy + ay * dt) * conf.GRAVITY_DAMPING;
|
|
297166
297223
|
const moveX = vel.vx * dt;
|
|
297167
297224
|
const moveY = vel.vy * dt;
|
|
297168
297225
|
if (Math.abs(moveX) >= this.MIN_MOVE_PX || Math.abs(moveY) >= this.MIN_MOVE_PX) {
|
package/dist/example.html
CHANGED
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
document.documentElement.setAttribute("data-theme", t);
|
|
45
45
|
})();
|
|
46
46
|
</script>
|
|
47
|
-
<link rel="stylesheet" crossorigin href="/chunk-ccbp3q1g.css"><script type="module" crossorigin src="/chunk-
|
|
47
|
+
<link rel="stylesheet" crossorigin href="/chunk-ccbp3q1g.css"><script type="module" crossorigin src="/chunk-e1r2sk6e.js"></script></head>
|
|
48
48
|
|
|
49
49
|
<body
|
|
50
50
|
style="
|
package/dist/index.html
CHANGED
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
document.documentElement.setAttribute("data-theme", t);
|
|
45
45
|
})();
|
|
46
46
|
</script>
|
|
47
|
-
<link rel="stylesheet" crossorigin href="/chunk-ccbp3q1g.css"><script type="module" crossorigin src="/chunk-
|
|
47
|
+
<link rel="stylesheet" crossorigin href="/chunk-ccbp3q1g.css"><script type="module" crossorigin src="/chunk-e1r2sk6e.js"></script></head>
|
|
48
48
|
|
|
49
49
|
<body
|
|
50
50
|
style="
|
package/dist/index.js
CHANGED
|
@@ -248398,7 +248398,13 @@ var conf = {
|
|
|
248398
248398
|
CARD_DIMENSIONS: { width: 250, height: 400 },
|
|
248399
248399
|
DEFAULT_GAME_ITEM_DIMENSIONS: { width: 200, height: 200 },
|
|
248400
248400
|
MAX_CARD_SIZE: 500,
|
|
248401
|
-
CONNECTOR_ITEM_OFFSET: 20
|
|
248401
|
+
CONNECTOR_ITEM_OFFSET: 20,
|
|
248402
|
+
GRAVITY_G: 80,
|
|
248403
|
+
GRAVITY_G_CENTER: 120,
|
|
248404
|
+
GRAVITY_DAMPING: 0.96,
|
|
248405
|
+
GRAVITY_RESTITUTION: 0.5,
|
|
248406
|
+
GRAVITY_REPULSION: 200,
|
|
248407
|
+
GRAVITY_MAX_DISTANCE: 3000
|
|
248402
248408
|
};
|
|
248403
248409
|
initDefaultI18N();
|
|
248404
248410
|
var BG_LIGHT = "rgb(248, 249, 251)";
|
|
@@ -265469,7 +265475,7 @@ class BaseItem extends Mbr {
|
|
|
265469
265475
|
if (!this.isHoverHighlighted) {
|
|
265470
265476
|
return;
|
|
265471
265477
|
}
|
|
265472
|
-
const mbr = this.
|
|
265478
|
+
const mbr = this.getWorldMbr();
|
|
265473
265479
|
mbr.strokeWidth = 2 / context.matrix.scaleX;
|
|
265474
265480
|
mbr.borderColor = BaseItem.HOVER_HIGHLIGHT_COLOR;
|
|
265475
265481
|
mbr.render(context);
|
|
@@ -265528,6 +265534,8 @@ class RichText extends BaseItem {
|
|
|
265528
265534
|
_onLimitReached = () => {};
|
|
265529
265535
|
shrinkWidth = false;
|
|
265530
265536
|
prevMbr = null;
|
|
265537
|
+
customTransformationMatrix;
|
|
265538
|
+
renderingScale;
|
|
265531
265539
|
rtCounter = 0;
|
|
265532
265540
|
constructor(board, container, id2 = "", transformation = new Transformation(id2, board.events), linkTo, placeholderText = conf.i18n?.t("board.textPlaceholder"), isInShape = false, autoSize = false, insideOf, initialTextStyles = conf.DEFAULT_TEXT_STYLES) {
|
|
265533
265541
|
super(board, id2);
|
|
@@ -265650,10 +265658,10 @@ class RichText extends BaseItem {
|
|
|
265650
265658
|
const shouldUpdateLayout = this.getTextWidth() > (maxWidth || 0);
|
|
265651
265659
|
if (shouldUpdateLayout) {
|
|
265652
265660
|
this.updateElement();
|
|
265653
|
-
this.subject.publish(this);
|
|
265654
265661
|
} else {
|
|
265655
265662
|
this.transformCanvas();
|
|
265656
265663
|
this.recoordinate(maxWidth);
|
|
265664
|
+
this.subject.publish(this);
|
|
265657
265665
|
}
|
|
265658
265666
|
}
|
|
265659
265667
|
handleFocus = () => {
|
|
@@ -265717,10 +265725,10 @@ class RichText extends BaseItem {
|
|
|
265717
265725
|
}
|
|
265718
265726
|
getMaxWidth() {
|
|
265719
265727
|
if (this.autoSize) {
|
|
265720
|
-
return this.editor.maxWidth || this.
|
|
265728
|
+
return this.editor.maxWidth || this.container.getWidth();
|
|
265721
265729
|
}
|
|
265722
265730
|
if (this.isContainerSet) {
|
|
265723
|
-
return this.
|
|
265731
|
+
return this.container.getWidth();
|
|
265724
265732
|
} else {
|
|
265725
265733
|
return this.containerMaxWidth || this.editor.maxWidth;
|
|
265726
265734
|
}
|
|
@@ -265821,13 +265829,17 @@ class RichText extends BaseItem {
|
|
|
265821
265829
|
return this.shrinkWidth;
|
|
265822
265830
|
}
|
|
265823
265831
|
getTransformedContainer() {
|
|
265824
|
-
|
|
265825
|
-
|
|
265826
|
-
|
|
265827
|
-
|
|
265828
|
-
|
|
265832
|
+
const cameraScale = this.board.camera.getScale();
|
|
265833
|
+
const extraScale = this.renderingScale ? this.renderingScale(cameraScale) : 1;
|
|
265834
|
+
let matrix;
|
|
265835
|
+
if (this.customTransformationMatrix) {
|
|
265836
|
+
matrix = this.customTransformationMatrix();
|
|
265837
|
+
} else {
|
|
265838
|
+
matrix = this.transformation.toMatrix();
|
|
265829
265839
|
}
|
|
265830
|
-
|
|
265840
|
+
const { translateX, translateY, scaleX, scaleY } = matrix;
|
|
265841
|
+
const scaledMatrix = new Matrix(translateX, translateY, scaleX, scaleY);
|
|
265842
|
+
return this.container.getTransformed(scaledMatrix);
|
|
265831
265843
|
}
|
|
265832
265844
|
emitWithoutApplying = (op) => {
|
|
265833
265845
|
if (this.board.events) {
|
|
@@ -266186,10 +266198,20 @@ class RichText extends BaseItem {
|
|
|
266186
266198
|
const { ctx } = context;
|
|
266187
266199
|
ctx.save();
|
|
266188
266200
|
ctx.translate(this.left, this.top);
|
|
266201
|
+
const cameraScale = context.getCameraScale();
|
|
266202
|
+
const extraScale = this.renderingScale ? this.renderingScale(cameraScale) : 1;
|
|
266203
|
+
let matrix;
|
|
266204
|
+
if (this.customTransformationMatrix) {
|
|
266205
|
+
matrix = this.customTransformationMatrix();
|
|
266206
|
+
} else {
|
|
266207
|
+
matrix = this.transformation.toMatrix();
|
|
266208
|
+
}
|
|
266209
|
+
const { scaleX, scaleY } = matrix;
|
|
266189
266210
|
const shouldScale = !this.isInShape && !this.autoSize;
|
|
266190
266211
|
if (shouldScale) {
|
|
266191
|
-
|
|
266192
|
-
|
|
266212
|
+
ctx.scale(scaleX * extraScale, scaleY * extraScale);
|
|
266213
|
+
} else if (extraScale !== 1) {
|
|
266214
|
+
ctx.scale(extraScale, extraScale);
|
|
266193
266215
|
}
|
|
266194
266216
|
const shouldClip = this.insideOf === "Shape" || this.insideOf === "Sticker";
|
|
266195
266217
|
if (shouldClip) {
|
|
@@ -266321,10 +266343,18 @@ class RichText extends BaseItem {
|
|
|
266321
266343
|
return unsafe.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
266322
266344
|
};
|
|
266323
266345
|
const elements = this.editor.editor.children.map(renderNode);
|
|
266324
|
-
const
|
|
266325
|
-
const
|
|
266326
|
-
|
|
266327
|
-
|
|
266346
|
+
const cameraScale = this.board.camera.getScale();
|
|
266347
|
+
const extraScale = this.renderingScale ? this.renderingScale(cameraScale) : 1;
|
|
266348
|
+
let matrix;
|
|
266349
|
+
if (this.customTransformationMatrix) {
|
|
266350
|
+
matrix = this.customTransformationMatrix();
|
|
266351
|
+
} else {
|
|
266352
|
+
matrix = this.transformation.toMatrix();
|
|
266353
|
+
}
|
|
266354
|
+
const { scaleX, scaleY } = matrix;
|
|
266355
|
+
const transform = `translate(${this.left}px, ${this.top}px) scale(${scaleX * extraScale}, ${scaleY * extraScale})`;
|
|
266356
|
+
const transformedWidth = this.getMbr().getWidth();
|
|
266357
|
+
const transformedHeight = this.getMbr().getHeight();
|
|
266328
266358
|
const div = documentFactory.createElement("rich-text");
|
|
266329
266359
|
div.id = this.getId();
|
|
266330
266360
|
div.style.width = `${transformedWidth + 5}px`;
|
|
@@ -282909,7 +282939,9 @@ class Shape extends BaseItem {
|
|
|
282909
282939
|
this.subject.publish(this);
|
|
282910
282940
|
});
|
|
282911
282941
|
this.text.insideOf = this.itemType;
|
|
282942
|
+
this.transformPath();
|
|
282912
282943
|
this.updateMbr();
|
|
282944
|
+
this.subject.publish(this);
|
|
282913
282945
|
}
|
|
282914
282946
|
saveShapeData() {
|
|
282915
282947
|
tempStorage.setShapeData({
|
|
@@ -283458,6 +283490,8 @@ class Sticker extends BaseItem {
|
|
|
283458
283490
|
this.subject.publish(this);
|
|
283459
283491
|
});
|
|
283460
283492
|
this.text.updateElement();
|
|
283493
|
+
this.transformPath();
|
|
283494
|
+
this.subject.publish(this);
|
|
283461
283495
|
}
|
|
283462
283496
|
emit(operation) {
|
|
283463
283497
|
if (this.board.events) {
|
|
@@ -283844,11 +283878,11 @@ function convertBlobToDataUrl(blob) {
|
|
|
283844
283878
|
};
|
|
283845
283879
|
});
|
|
283846
283880
|
}
|
|
283847
|
-
var FRAME_BORDER_COLOR = "
|
|
283881
|
+
var FRAME_BORDER_COLOR = semanticColor("contrastGray");
|
|
283848
283882
|
var FRAME_HIGHLIGHTER_BORDER_COLOR = "#93AFF6";
|
|
283849
283883
|
var FRAME_CHILDREN_HIGHLIGHTER_COLOR = "rgb(10, 15, 41, .08)";
|
|
283850
283884
|
var FRAME_CHILDREN_HIGHLIGHTER_BORDER_COLOR = "#4778F5";
|
|
283851
|
-
var FRAME_TITLE_COLOR = "
|
|
283885
|
+
var FRAME_TITLE_COLOR = semanticColor("contrastNeutral");
|
|
283852
283886
|
var FRAME_TYPES = [
|
|
283853
283887
|
{ id: "Custom", label: "Custom" },
|
|
283854
283888
|
{ id: "Frame16x9", label: "16:9" },
|
|
@@ -283893,7 +283927,7 @@ class DefaultFrameData {
|
|
|
283893
283927
|
canChangeRatio;
|
|
283894
283928
|
linkTo;
|
|
283895
283929
|
itemType = "Frame";
|
|
283896
|
-
constructor(shapeType = "Custom", backgroundColor =
|
|
283930
|
+
constructor(shapeType = "Custom", backgroundColor = semanticColor("contrastNeutral"), backgroundOpacity = 1, borderColor = FRAME_BORDER_COLOR, borderOpacity = 1, borderStyle = "solid", borderWidth = 0.2, transformation = new DefaultTransformationData, children = [], text5 = new DefaultRichTextData([], "top", 600), canChangeRatio = true, linkTo) {
|
|
283897
283931
|
this.shapeType = shapeType;
|
|
283898
283932
|
this.backgroundColor = backgroundColor;
|
|
283899
283933
|
this.backgroundOpacity = backgroundOpacity;
|
|
@@ -283909,6 +283943,8 @@ class DefaultFrameData {
|
|
|
283909
283943
|
}
|
|
283910
283944
|
}
|
|
283911
283945
|
var defaultFrameData = new DefaultFrameData;
|
|
283946
|
+
var HEADING_TOP_OFFSET = -33;
|
|
283947
|
+
var HEADING_BOTTOM_OFFSET = -5;
|
|
283912
283948
|
|
|
283913
283949
|
class Frame2 extends BaseItem {
|
|
283914
283950
|
getItemById;
|
|
@@ -283924,7 +283960,7 @@ class Frame2 extends BaseItem {
|
|
|
283924
283960
|
parent = "Board";
|
|
283925
283961
|
transformation;
|
|
283926
283962
|
subject = new Subject;
|
|
283927
|
-
textContainer;
|
|
283963
|
+
textContainer = new Mbr;
|
|
283928
283964
|
path;
|
|
283929
283965
|
children = [];
|
|
283930
283966
|
mbr = new Mbr;
|
|
@@ -283945,12 +283981,23 @@ class Frame2 extends BaseItem {
|
|
|
283945
283981
|
this.borderOpacity = borderOpacity;
|
|
283946
283982
|
this.borderStyle = borderStyle;
|
|
283947
283983
|
this.borderWidth = borderWidth;
|
|
283948
|
-
this.textContainer = Frames[this.shapeType].textBounds.copy();
|
|
283949
283984
|
this.path = Frames[this.shapeType].path.copy();
|
|
283950
283985
|
this.transformation = new Transformation(this.id, board.events);
|
|
283951
283986
|
this.linkTo = new LinkTo(this.id, board.events);
|
|
283952
|
-
|
|
283987
|
+
const textBounds = Frames[this.shapeType].textBounds.copy();
|
|
283988
|
+
textBounds.top = HEADING_TOP_OFFSET;
|
|
283989
|
+
textBounds.bottom = HEADING_BOTTOM_OFFSET;
|
|
283990
|
+
this.textContainer = textBounds;
|
|
283991
|
+
this.text = new RichText(board, this.textContainer, this.id, this.transformation, this.linkTo, this.name, true, false, "Frame", { ...conf.DEFAULT_TEXT_STYLES, fontSize: 18, fontColor: FRAME_TITLE_COLOR });
|
|
283992
|
+
this.text.editor.verticalAlignment = "bottom";
|
|
283953
283993
|
this.text.setSelectionHorisontalAlignment("left");
|
|
283994
|
+
this.text.customTransformationMatrix = () => {
|
|
283995
|
+
const matrix = this.transformation.toMatrix();
|
|
283996
|
+
return new Matrix(matrix.translateX, matrix.translateY, 1, 1);
|
|
283997
|
+
};
|
|
283998
|
+
this.text.renderingScale = (cameraScale) => {
|
|
283999
|
+
return Math.max(1, Math.min(6, 1.2 / cameraScale));
|
|
284000
|
+
};
|
|
283954
284001
|
this.transformation.subject.subscribe(() => {
|
|
283955
284002
|
this.transformPath();
|
|
283956
284003
|
this.updateMbr();
|
|
@@ -283975,9 +284022,17 @@ class Frame2 extends BaseItem {
|
|
|
283975
284022
|
}
|
|
283976
284023
|
initPath() {
|
|
283977
284024
|
this.path = Frames[this.shapeType].path.copy();
|
|
283978
|
-
this.
|
|
283979
|
-
|
|
283980
|
-
|
|
284025
|
+
this.updateTextContainer();
|
|
284026
|
+
}
|
|
284027
|
+
updateTextContainer() {
|
|
284028
|
+
const textBounds = Frames[this.shapeType].textBounds.copy();
|
|
284029
|
+
textBounds.top = HEADING_TOP_OFFSET;
|
|
284030
|
+
textBounds.bottom = HEADING_BOTTOM_OFFSET;
|
|
284031
|
+
this.textContainer = textBounds;
|
|
284032
|
+
if (this.text) {
|
|
284033
|
+
this.text.setContainer(this.textContainer.copy());
|
|
284034
|
+
this.text.updateElement();
|
|
284035
|
+
}
|
|
283981
284036
|
}
|
|
283982
284037
|
getPaths() {
|
|
283983
284038
|
return this.path;
|
|
@@ -284120,6 +284175,7 @@ class Frame2 extends BaseItem {
|
|
|
284120
284175
|
}
|
|
284121
284176
|
if (data.text) {
|
|
284122
284177
|
this.text.deserialize(data.text);
|
|
284178
|
+
this.updateTextContainer();
|
|
284123
284179
|
}
|
|
284124
284180
|
this.canChangeRatio = data.canChangeRatio ?? this.canChangeRatio;
|
|
284125
284181
|
this.subject.publish(this);
|
|
@@ -284135,15 +284191,13 @@ class Frame2 extends BaseItem {
|
|
|
284135
284191
|
}
|
|
284136
284192
|
transformPath(saveProportions = false) {
|
|
284137
284193
|
this.path = Frames[this.shapeType].path.copy();
|
|
284138
|
-
this.
|
|
284194
|
+
this.updateTextContainer();
|
|
284139
284195
|
if (saveProportions) {
|
|
284140
284196
|
const newMatrix = this.getSavedProportionsMatrix();
|
|
284141
284197
|
this.path.transform(newMatrix);
|
|
284142
|
-
this.textContainer.transform(newMatrix);
|
|
284143
284198
|
this.transformation.applyScaleTo(newMatrix.scaleX, newMatrix.scaleY);
|
|
284144
284199
|
} else {
|
|
284145
284200
|
this.path.transform(this.transformation.toMatrix());
|
|
284146
|
-
this.textContainer.transform(this.transformation.toMatrix());
|
|
284147
284201
|
}
|
|
284148
284202
|
this.path.setBackgroundOpacity(this.backgroundOpacity);
|
|
284149
284203
|
this.path.setBorderWidth(this.borderWidth);
|
|
@@ -288931,8 +288985,9 @@ function getQuickAddButtons(selection, board) {
|
|
|
288931
288985
|
let quickAddItems = undefined;
|
|
288932
288986
|
function calculateQuickAddPosition(index2, selectedItem, connectorStartPoint) {
|
|
288933
288987
|
const connectorStorage = new SessionStorage;
|
|
288934
|
-
const currMbr = selectedItem.getPathMbr();
|
|
288988
|
+
const currMbr = selectedItem instanceof BaseItem ? selectedItem.getWorldMbr() : selectedItem.getPathMbr();
|
|
288935
288989
|
const selectedItemData = selectedItem.serialize();
|
|
288990
|
+
const selectedMatrix = selectedItem instanceof BaseItem ? selectedItem.getWorldMatrix() : new Matrix(selectedItemData.transformation?.translateX || 0, selectedItemData.transformation?.translateY || 0);
|
|
288936
288991
|
const width2 = currMbr.getWidth();
|
|
288937
288992
|
const height3 = currMbr.getHeight();
|
|
288938
288993
|
let offsetX = width2;
|
|
@@ -288972,8 +289027,8 @@ function getQuickAddButtons(selection, board) {
|
|
|
288972
289027
|
const adjustment = baseAdjustments[index2];
|
|
288973
289028
|
const newItemData = { ...itemData };
|
|
288974
289029
|
if (newItemData.transformation) {
|
|
288975
|
-
newItemData.transformation.translateX = adjustment.translateX +
|
|
288976
|
-
newItemData.transformation.translateY = adjustment.translateY +
|
|
289030
|
+
newItemData.transformation.translateX = adjustment.translateX + selectedMatrix.translateX;
|
|
289031
|
+
newItemData.transformation.translateY = adjustment.translateY + selectedMatrix.translateY + height3 / 2 - newHeight / 2;
|
|
288977
289032
|
}
|
|
288978
289033
|
const newMbr = new Mbr(newItemData.transformation?.translateX, newItemData.transformation?.translateY, (newItemData.transformation?.translateX || 0) + newWidth, (newItemData.transformation?.translateY || 0) + newHeight);
|
|
288979
289034
|
let step = 1;
|
|
@@ -289064,7 +289119,7 @@ function getQuickAddButtons(selection, board) {
|
|
|
289064
289119
|
}
|
|
289065
289120
|
function getQuickButtonsPositions(customMbr) {
|
|
289066
289121
|
const single = selection.items.getSingle();
|
|
289067
|
-
const itemMbr = customMbr ? customMbr : single?.getMbr();
|
|
289122
|
+
const itemMbr = customMbr ? customMbr : single instanceof BaseItem ? single.getWorldMbr() : single?.getMbr();
|
|
289068
289123
|
if (!itemMbr || single?.itemType !== "Sticker" && single?.itemType !== "Shape" && single?.itemType !== "AINode" && single?.itemType !== "RichText") {
|
|
289069
289124
|
return;
|
|
289070
289125
|
}
|
|
@@ -296469,9 +296524,9 @@ class BoardSelection {
|
|
|
296469
296524
|
}
|
|
296470
296525
|
const selectedMbr = selected.reduce((acc, item) => {
|
|
296471
296526
|
if (!acc) {
|
|
296472
|
-
return item.getMbr();
|
|
296527
|
+
return item instanceof BaseItem ? item.getWorldMbr() : item.getMbr();
|
|
296473
296528
|
}
|
|
296474
|
-
return acc.combine(item.getMbr());
|
|
296529
|
+
return acc.combine(item instanceof BaseItem ? item.getWorldMbr() : item.getMbr());
|
|
296475
296530
|
}, undefined);
|
|
296476
296531
|
if (selectedMbr) {
|
|
296477
296532
|
const selectedMap = Object.fromEntries(selected.map((item) => [item.getId(), { item, nested: false }]));
|
|
@@ -296503,7 +296558,7 @@ class BoardSelection {
|
|
|
296503
296558
|
const childrenIds = val.item.getChildrenIds();
|
|
296504
296559
|
if (childrenIds) {
|
|
296505
296560
|
const currGroup = val.item;
|
|
296506
|
-
const currMbr = currGroup.
|
|
296561
|
+
const currMbr = currGroup.getWorldMbr();
|
|
296507
296562
|
const children = childrenIds.map((childId) => this.board.items.getById(childId)).filter((item) => !!item);
|
|
296508
296563
|
const underGroup = this.board.items.getEnclosedOrCrossed(currMbr.left, currMbr.top, currMbr.right, currMbr.bottom).filter((item) => item.parent === "Board" || item.parent === currGroup.getId());
|
|
296509
296564
|
const uniqueItems = new Set;
|
|
@@ -296984,7 +297039,7 @@ class BoardSelection {
|
|
|
296984
297039
|
};
|
|
296985
297040
|
}
|
|
296986
297041
|
renderItemMbr(context, item, customScale) {
|
|
296987
|
-
const mbr = item.getMbr();
|
|
297042
|
+
const mbr = item instanceof BaseItem ? item.getWorldMbr() : item.getMbr();
|
|
296988
297043
|
mbr.strokeWidth = !customScale ? 1 / context.matrix.scaleX : 1 / customScale;
|
|
296989
297044
|
const selectionColor = item.transformation.isLocked ? conf.SELECTION_LOCKED_COLOR : conf.SELECTION_COLOR;
|
|
296990
297045
|
mbr.borderColor = selectionColor;
|
|
@@ -297041,7 +297096,7 @@ class BoardSelection {
|
|
|
297041
297096
|
path22.setBackgroundColor("none");
|
|
297042
297097
|
path22.render(context);
|
|
297043
297098
|
} else {
|
|
297044
|
-
const itemRect = item.getMbr();
|
|
297099
|
+
const itemRect = item instanceof BaseItem ? item.getWorldMbr() : item.getMbr();
|
|
297045
297100
|
itemRect.borderColor = CONTEXT_NODE_HIGHLIGHT_COLOR;
|
|
297046
297101
|
itemRect.strokeWidth = 2;
|
|
297047
297102
|
itemRect.render(context);
|
|
@@ -297057,13 +297112,8 @@ class GravityEngine {
|
|
|
297057
297112
|
tickTimer = null;
|
|
297058
297113
|
syncTimer = null;
|
|
297059
297114
|
lastSyncedPositions = new Map;
|
|
297060
|
-
G = 80;
|
|
297061
|
-
G_CENTER = 120;
|
|
297062
|
-
DAMPING = 0.92;
|
|
297063
|
-
REPULSION = 800;
|
|
297064
297115
|
TICK_MS = 33;
|
|
297065
297116
|
SYNC_MS = 300;
|
|
297066
|
-
MAX_DISTANCE = 3000;
|
|
297067
297117
|
SOFTENING_SQ = 50 * 50;
|
|
297068
297118
|
MIN_MOVE_PX = 0.1;
|
|
297069
297119
|
constructor(board) {
|
|
@@ -297132,8 +297182,8 @@ class GravityEngine {
|
|
|
297132
297182
|
const dcx = centerX - s1.cx;
|
|
297133
297183
|
const dcy = centerY - s1.cy;
|
|
297134
297184
|
const distCenter = Math.sqrt(dcx * dcx + dcy * dcy) + 1;
|
|
297135
|
-
ax +=
|
|
297136
|
-
ay +=
|
|
297185
|
+
ax += conf.GRAVITY_G_CENTER * dcx / distCenter;
|
|
297186
|
+
ay += conf.GRAVITY_G_CENTER * dcy / distCenter;
|
|
297137
297187
|
for (let j = 0;j < snap.length; j++) {
|
|
297138
297188
|
if (i === j)
|
|
297139
297189
|
continue;
|
|
@@ -297141,7 +297191,7 @@ class GravityEngine {
|
|
|
297141
297191
|
const dx = s2.cx - s1.cx;
|
|
297142
297192
|
const dy = s2.cy - s1.cy;
|
|
297143
297193
|
const dist = Math.sqrt(dx * dx + dy * dy) + 0.001;
|
|
297144
|
-
if (dist >
|
|
297194
|
+
if (dist > conf.GRAVITY_MAX_DISTANCE)
|
|
297145
297195
|
continue;
|
|
297146
297196
|
const overlapping = s1.right > s2.left && s2.right > s1.left && s1.bottom > s2.top && s2.bottom > s1.top;
|
|
297147
297197
|
if (overlapping) {
|
|
@@ -297149,20 +297199,27 @@ class GravityEngine {
|
|
|
297149
297199
|
const overlapY = Math.min(s1.bottom, s2.bottom) - Math.max(s1.top, s2.top);
|
|
297150
297200
|
if (overlapX < overlapY) {
|
|
297151
297201
|
const sign = s1.cx < s2.cx ? -1 : 1;
|
|
297152
|
-
|
|
297202
|
+
if (sign * vel.vx < 0)
|
|
297203
|
+
vel.vx = -vel.vx * conf.GRAVITY_RESTITUTION;
|
|
297204
|
+
ax += sign * conf.GRAVITY_REPULSION * overlapX;
|
|
297153
297205
|
} else {
|
|
297154
297206
|
const sign = s1.cy < s2.cy ? -1 : 1;
|
|
297155
|
-
|
|
297207
|
+
if (sign * vel.vy < 0)
|
|
297208
|
+
vel.vy = -vel.vy * conf.GRAVITY_RESTITUTION;
|
|
297209
|
+
ay += sign * conf.GRAVITY_REPULSION * overlapY;
|
|
297156
297210
|
}
|
|
297157
297211
|
} else {
|
|
297212
|
+
const touchDist = (s1.w + s2.w + s1.h + s2.h) * 0.25;
|
|
297213
|
+
if (dist < touchDist + 5)
|
|
297214
|
+
continue;
|
|
297158
297215
|
const distSq = dx * dx + dy * dy;
|
|
297159
|
-
const gravAcc =
|
|
297216
|
+
const gravAcc = conf.GRAVITY_G * s2.mass / (distSq + this.SOFTENING_SQ);
|
|
297160
297217
|
ax += gravAcc * dx / dist;
|
|
297161
297218
|
ay += gravAcc * dy / dist;
|
|
297162
297219
|
}
|
|
297163
297220
|
}
|
|
297164
|
-
vel.vx = (vel.vx + ax * dt) *
|
|
297165
|
-
vel.vy = (vel.vy + ay * dt) *
|
|
297221
|
+
vel.vx = (vel.vx + ax * dt) * conf.GRAVITY_DAMPING;
|
|
297222
|
+
vel.vy = (vel.vy + ay * dt) * conf.GRAVITY_DAMPING;
|
|
297166
297223
|
const moveX = vel.vx * dt;
|
|
297167
297224
|
const moveY = vel.vy * dt;
|
|
297168
297225
|
if (Math.abs(moveX) >= this.MIN_MOVE_PX || Math.abs(moveY) >= this.MIN_MOVE_PX) {
|
package/dist/spa.css
CHANGED
|
@@ -2883,12 +2883,6 @@ a.link_jFMnzg {
|
|
|
2883
2883
|
background-color: #f7f7f8;
|
|
2884
2884
|
}
|
|
2885
2885
|
|
|
2886
|
-
.quaternary_Lhh5GA {
|
|
2887
|
-
color: #fff;
|
|
2888
|
-
background-color: #924fe8;
|
|
2889
|
-
border: 1px solid #924fe8;
|
|
2890
|
-
}
|
|
2891
|
-
|
|
2892
2886
|
.quaternary_Lhh5GA:hover {
|
|
2893
2887
|
background-color: #b799f5;
|
|
2894
2888
|
border: 1px solid #924fe8;
|
package/dist/spa.js
CHANGED
|
@@ -248398,7 +248398,13 @@ var conf = {
|
|
|
248398
248398
|
CARD_DIMENSIONS: { width: 250, height: 400 },
|
|
248399
248399
|
DEFAULT_GAME_ITEM_DIMENSIONS: { width: 200, height: 200 },
|
|
248400
248400
|
MAX_CARD_SIZE: 500,
|
|
248401
|
-
CONNECTOR_ITEM_OFFSET: 20
|
|
248401
|
+
CONNECTOR_ITEM_OFFSET: 20,
|
|
248402
|
+
GRAVITY_G: 80,
|
|
248403
|
+
GRAVITY_G_CENTER: 120,
|
|
248404
|
+
GRAVITY_DAMPING: 0.96,
|
|
248405
|
+
GRAVITY_RESTITUTION: 0.5,
|
|
248406
|
+
GRAVITY_REPULSION: 200,
|
|
248407
|
+
GRAVITY_MAX_DISTANCE: 3000
|
|
248402
248408
|
};
|
|
248403
248409
|
initDefaultI18N();
|
|
248404
248410
|
var BG_LIGHT = "rgb(248, 249, 251)";
|
|
@@ -265469,7 +265475,7 @@ class BaseItem extends Mbr {
|
|
|
265469
265475
|
if (!this.isHoverHighlighted) {
|
|
265470
265476
|
return;
|
|
265471
265477
|
}
|
|
265472
|
-
const mbr = this.
|
|
265478
|
+
const mbr = this.getWorldMbr();
|
|
265473
265479
|
mbr.strokeWidth = 2 / context.matrix.scaleX;
|
|
265474
265480
|
mbr.borderColor = BaseItem.HOVER_HIGHLIGHT_COLOR;
|
|
265475
265481
|
mbr.render(context);
|
|
@@ -265528,6 +265534,8 @@ class RichText extends BaseItem {
|
|
|
265528
265534
|
_onLimitReached = () => {};
|
|
265529
265535
|
shrinkWidth = false;
|
|
265530
265536
|
prevMbr = null;
|
|
265537
|
+
customTransformationMatrix;
|
|
265538
|
+
renderingScale;
|
|
265531
265539
|
rtCounter = 0;
|
|
265532
265540
|
constructor(board, container, id2 = "", transformation = new Transformation(id2, board.events), linkTo, placeholderText = conf.i18n?.t("board.textPlaceholder"), isInShape = false, autoSize = false, insideOf, initialTextStyles = conf.DEFAULT_TEXT_STYLES) {
|
|
265533
265541
|
super(board, id2);
|
|
@@ -265650,10 +265658,10 @@ class RichText extends BaseItem {
|
|
|
265650
265658
|
const shouldUpdateLayout = this.getTextWidth() > (maxWidth || 0);
|
|
265651
265659
|
if (shouldUpdateLayout) {
|
|
265652
265660
|
this.updateElement();
|
|
265653
|
-
this.subject.publish(this);
|
|
265654
265661
|
} else {
|
|
265655
265662
|
this.transformCanvas();
|
|
265656
265663
|
this.recoordinate(maxWidth);
|
|
265664
|
+
this.subject.publish(this);
|
|
265657
265665
|
}
|
|
265658
265666
|
}
|
|
265659
265667
|
handleFocus = () => {
|
|
@@ -265717,10 +265725,10 @@ class RichText extends BaseItem {
|
|
|
265717
265725
|
}
|
|
265718
265726
|
getMaxWidth() {
|
|
265719
265727
|
if (this.autoSize) {
|
|
265720
|
-
return this.editor.maxWidth || this.
|
|
265728
|
+
return this.editor.maxWidth || this.container.getWidth();
|
|
265721
265729
|
}
|
|
265722
265730
|
if (this.isContainerSet) {
|
|
265723
|
-
return this.
|
|
265731
|
+
return this.container.getWidth();
|
|
265724
265732
|
} else {
|
|
265725
265733
|
return this.containerMaxWidth || this.editor.maxWidth;
|
|
265726
265734
|
}
|
|
@@ -265821,13 +265829,17 @@ class RichText extends BaseItem {
|
|
|
265821
265829
|
return this.shrinkWidth;
|
|
265822
265830
|
}
|
|
265823
265831
|
getTransformedContainer() {
|
|
265824
|
-
|
|
265825
|
-
|
|
265826
|
-
|
|
265827
|
-
|
|
265828
|
-
|
|
265832
|
+
const cameraScale = this.board.camera.getScale();
|
|
265833
|
+
const extraScale = this.renderingScale ? this.renderingScale(cameraScale) : 1;
|
|
265834
|
+
let matrix;
|
|
265835
|
+
if (this.customTransformationMatrix) {
|
|
265836
|
+
matrix = this.customTransformationMatrix();
|
|
265837
|
+
} else {
|
|
265838
|
+
matrix = this.transformation.toMatrix();
|
|
265829
265839
|
}
|
|
265830
|
-
|
|
265840
|
+
const { translateX, translateY, scaleX, scaleY } = matrix;
|
|
265841
|
+
const scaledMatrix = new Matrix(translateX, translateY, scaleX, scaleY);
|
|
265842
|
+
return this.container.getTransformed(scaledMatrix);
|
|
265831
265843
|
}
|
|
265832
265844
|
emitWithoutApplying = (op) => {
|
|
265833
265845
|
if (this.board.events) {
|
|
@@ -266186,10 +266198,20 @@ class RichText extends BaseItem {
|
|
|
266186
266198
|
const { ctx } = context;
|
|
266187
266199
|
ctx.save();
|
|
266188
266200
|
ctx.translate(this.left, this.top);
|
|
266201
|
+
const cameraScale = context.getCameraScale();
|
|
266202
|
+
const extraScale = this.renderingScale ? this.renderingScale(cameraScale) : 1;
|
|
266203
|
+
let matrix;
|
|
266204
|
+
if (this.customTransformationMatrix) {
|
|
266205
|
+
matrix = this.customTransformationMatrix();
|
|
266206
|
+
} else {
|
|
266207
|
+
matrix = this.transformation.toMatrix();
|
|
266208
|
+
}
|
|
266209
|
+
const { scaleX, scaleY } = matrix;
|
|
266189
266210
|
const shouldScale = !this.isInShape && !this.autoSize;
|
|
266190
266211
|
if (shouldScale) {
|
|
266191
|
-
|
|
266192
|
-
|
|
266212
|
+
ctx.scale(scaleX * extraScale, scaleY * extraScale);
|
|
266213
|
+
} else if (extraScale !== 1) {
|
|
266214
|
+
ctx.scale(extraScale, extraScale);
|
|
266193
266215
|
}
|
|
266194
266216
|
const shouldClip = this.insideOf === "Shape" || this.insideOf === "Sticker";
|
|
266195
266217
|
if (shouldClip) {
|
|
@@ -266321,10 +266343,18 @@ class RichText extends BaseItem {
|
|
|
266321
266343
|
return unsafe.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
266322
266344
|
};
|
|
266323
266345
|
const elements = this.editor.editor.children.map(renderNode);
|
|
266324
|
-
const
|
|
266325
|
-
const
|
|
266326
|
-
|
|
266327
|
-
|
|
266346
|
+
const cameraScale = this.board.camera.getScale();
|
|
266347
|
+
const extraScale = this.renderingScale ? this.renderingScale(cameraScale) : 1;
|
|
266348
|
+
let matrix;
|
|
266349
|
+
if (this.customTransformationMatrix) {
|
|
266350
|
+
matrix = this.customTransformationMatrix();
|
|
266351
|
+
} else {
|
|
266352
|
+
matrix = this.transformation.toMatrix();
|
|
266353
|
+
}
|
|
266354
|
+
const { scaleX, scaleY } = matrix;
|
|
266355
|
+
const transform = `translate(${this.left}px, ${this.top}px) scale(${scaleX * extraScale}, ${scaleY * extraScale})`;
|
|
266356
|
+
const transformedWidth = this.getMbr().getWidth();
|
|
266357
|
+
const transformedHeight = this.getMbr().getHeight();
|
|
266328
266358
|
const div = documentFactory.createElement("rich-text");
|
|
266329
266359
|
div.id = this.getId();
|
|
266330
266360
|
div.style.width = `${transformedWidth + 5}px`;
|
|
@@ -282909,7 +282939,9 @@ class Shape extends BaseItem {
|
|
|
282909
282939
|
this.subject.publish(this);
|
|
282910
282940
|
});
|
|
282911
282941
|
this.text.insideOf = this.itemType;
|
|
282942
|
+
this.transformPath();
|
|
282912
282943
|
this.updateMbr();
|
|
282944
|
+
this.subject.publish(this);
|
|
282913
282945
|
}
|
|
282914
282946
|
saveShapeData() {
|
|
282915
282947
|
tempStorage.setShapeData({
|
|
@@ -283458,6 +283490,8 @@ class Sticker extends BaseItem {
|
|
|
283458
283490
|
this.subject.publish(this);
|
|
283459
283491
|
});
|
|
283460
283492
|
this.text.updateElement();
|
|
283493
|
+
this.transformPath();
|
|
283494
|
+
this.subject.publish(this);
|
|
283461
283495
|
}
|
|
283462
283496
|
emit(operation) {
|
|
283463
283497
|
if (this.board.events) {
|
|
@@ -283844,11 +283878,11 @@ function convertBlobToDataUrl(blob) {
|
|
|
283844
283878
|
};
|
|
283845
283879
|
});
|
|
283846
283880
|
}
|
|
283847
|
-
var FRAME_BORDER_COLOR = "
|
|
283881
|
+
var FRAME_BORDER_COLOR = semanticColor("contrastGray");
|
|
283848
283882
|
var FRAME_HIGHLIGHTER_BORDER_COLOR = "#93AFF6";
|
|
283849
283883
|
var FRAME_CHILDREN_HIGHLIGHTER_COLOR = "rgb(10, 15, 41, .08)";
|
|
283850
283884
|
var FRAME_CHILDREN_HIGHLIGHTER_BORDER_COLOR = "#4778F5";
|
|
283851
|
-
var FRAME_TITLE_COLOR = "
|
|
283885
|
+
var FRAME_TITLE_COLOR = semanticColor("contrastNeutral");
|
|
283852
283886
|
var FRAME_TYPES = [
|
|
283853
283887
|
{ id: "Custom", label: "Custom" },
|
|
283854
283888
|
{ id: "Frame16x9", label: "16:9" },
|
|
@@ -283893,7 +283927,7 @@ class DefaultFrameData {
|
|
|
283893
283927
|
canChangeRatio;
|
|
283894
283928
|
linkTo;
|
|
283895
283929
|
itemType = "Frame";
|
|
283896
|
-
constructor(shapeType = "Custom", backgroundColor =
|
|
283930
|
+
constructor(shapeType = "Custom", backgroundColor = semanticColor("contrastNeutral"), backgroundOpacity = 1, borderColor = FRAME_BORDER_COLOR, borderOpacity = 1, borderStyle = "solid", borderWidth = 0.2, transformation = new DefaultTransformationData, children = [], text5 = new DefaultRichTextData([], "top", 600), canChangeRatio = true, linkTo) {
|
|
283897
283931
|
this.shapeType = shapeType;
|
|
283898
283932
|
this.backgroundColor = backgroundColor;
|
|
283899
283933
|
this.backgroundOpacity = backgroundOpacity;
|
|
@@ -283909,6 +283943,8 @@ class DefaultFrameData {
|
|
|
283909
283943
|
}
|
|
283910
283944
|
}
|
|
283911
283945
|
var defaultFrameData = new DefaultFrameData;
|
|
283946
|
+
var HEADING_TOP_OFFSET = -33;
|
|
283947
|
+
var HEADING_BOTTOM_OFFSET = -5;
|
|
283912
283948
|
|
|
283913
283949
|
class Frame2 extends BaseItem {
|
|
283914
283950
|
getItemById;
|
|
@@ -283924,7 +283960,7 @@ class Frame2 extends BaseItem {
|
|
|
283924
283960
|
parent = "Board";
|
|
283925
283961
|
transformation;
|
|
283926
283962
|
subject = new Subject;
|
|
283927
|
-
textContainer;
|
|
283963
|
+
textContainer = new Mbr;
|
|
283928
283964
|
path;
|
|
283929
283965
|
children = [];
|
|
283930
283966
|
mbr = new Mbr;
|
|
@@ -283945,12 +283981,23 @@ class Frame2 extends BaseItem {
|
|
|
283945
283981
|
this.borderOpacity = borderOpacity;
|
|
283946
283982
|
this.borderStyle = borderStyle;
|
|
283947
283983
|
this.borderWidth = borderWidth;
|
|
283948
|
-
this.textContainer = Frames[this.shapeType].textBounds.copy();
|
|
283949
283984
|
this.path = Frames[this.shapeType].path.copy();
|
|
283950
283985
|
this.transformation = new Transformation(this.id, board.events);
|
|
283951
283986
|
this.linkTo = new LinkTo(this.id, board.events);
|
|
283952
|
-
|
|
283987
|
+
const textBounds = Frames[this.shapeType].textBounds.copy();
|
|
283988
|
+
textBounds.top = HEADING_TOP_OFFSET;
|
|
283989
|
+
textBounds.bottom = HEADING_BOTTOM_OFFSET;
|
|
283990
|
+
this.textContainer = textBounds;
|
|
283991
|
+
this.text = new RichText(board, this.textContainer, this.id, this.transformation, this.linkTo, this.name, true, false, "Frame", { ...conf.DEFAULT_TEXT_STYLES, fontSize: 18, fontColor: FRAME_TITLE_COLOR });
|
|
283992
|
+
this.text.editor.verticalAlignment = "bottom";
|
|
283953
283993
|
this.text.setSelectionHorisontalAlignment("left");
|
|
283994
|
+
this.text.customTransformationMatrix = () => {
|
|
283995
|
+
const matrix = this.transformation.toMatrix();
|
|
283996
|
+
return new Matrix(matrix.translateX, matrix.translateY, 1, 1);
|
|
283997
|
+
};
|
|
283998
|
+
this.text.renderingScale = (cameraScale) => {
|
|
283999
|
+
return Math.max(1, Math.min(6, 1.2 / cameraScale));
|
|
284000
|
+
};
|
|
283954
284001
|
this.transformation.subject.subscribe(() => {
|
|
283955
284002
|
this.transformPath();
|
|
283956
284003
|
this.updateMbr();
|
|
@@ -283975,9 +284022,17 @@ class Frame2 extends BaseItem {
|
|
|
283975
284022
|
}
|
|
283976
284023
|
initPath() {
|
|
283977
284024
|
this.path = Frames[this.shapeType].path.copy();
|
|
283978
|
-
this.
|
|
283979
|
-
|
|
283980
|
-
|
|
284025
|
+
this.updateTextContainer();
|
|
284026
|
+
}
|
|
284027
|
+
updateTextContainer() {
|
|
284028
|
+
const textBounds = Frames[this.shapeType].textBounds.copy();
|
|
284029
|
+
textBounds.top = HEADING_TOP_OFFSET;
|
|
284030
|
+
textBounds.bottom = HEADING_BOTTOM_OFFSET;
|
|
284031
|
+
this.textContainer = textBounds;
|
|
284032
|
+
if (this.text) {
|
|
284033
|
+
this.text.setContainer(this.textContainer.copy());
|
|
284034
|
+
this.text.updateElement();
|
|
284035
|
+
}
|
|
283981
284036
|
}
|
|
283982
284037
|
getPaths() {
|
|
283983
284038
|
return this.path;
|
|
@@ -284120,6 +284175,7 @@ class Frame2 extends BaseItem {
|
|
|
284120
284175
|
}
|
|
284121
284176
|
if (data.text) {
|
|
284122
284177
|
this.text.deserialize(data.text);
|
|
284178
|
+
this.updateTextContainer();
|
|
284123
284179
|
}
|
|
284124
284180
|
this.canChangeRatio = data.canChangeRatio ?? this.canChangeRatio;
|
|
284125
284181
|
this.subject.publish(this);
|
|
@@ -284135,15 +284191,13 @@ class Frame2 extends BaseItem {
|
|
|
284135
284191
|
}
|
|
284136
284192
|
transformPath(saveProportions = false) {
|
|
284137
284193
|
this.path = Frames[this.shapeType].path.copy();
|
|
284138
|
-
this.
|
|
284194
|
+
this.updateTextContainer();
|
|
284139
284195
|
if (saveProportions) {
|
|
284140
284196
|
const newMatrix = this.getSavedProportionsMatrix();
|
|
284141
284197
|
this.path.transform(newMatrix);
|
|
284142
|
-
this.textContainer.transform(newMatrix);
|
|
284143
284198
|
this.transformation.applyScaleTo(newMatrix.scaleX, newMatrix.scaleY);
|
|
284144
284199
|
} else {
|
|
284145
284200
|
this.path.transform(this.transformation.toMatrix());
|
|
284146
|
-
this.textContainer.transform(this.transformation.toMatrix());
|
|
284147
284201
|
}
|
|
284148
284202
|
this.path.setBackgroundOpacity(this.backgroundOpacity);
|
|
284149
284203
|
this.path.setBorderWidth(this.borderWidth);
|
|
@@ -288931,8 +288985,9 @@ function getQuickAddButtons(selection, board) {
|
|
|
288931
288985
|
let quickAddItems = undefined;
|
|
288932
288986
|
function calculateQuickAddPosition(index2, selectedItem, connectorStartPoint) {
|
|
288933
288987
|
const connectorStorage = new SessionStorage;
|
|
288934
|
-
const currMbr = selectedItem.getPathMbr();
|
|
288988
|
+
const currMbr = selectedItem instanceof BaseItem ? selectedItem.getWorldMbr() : selectedItem.getPathMbr();
|
|
288935
288989
|
const selectedItemData = selectedItem.serialize();
|
|
288990
|
+
const selectedMatrix = selectedItem instanceof BaseItem ? selectedItem.getWorldMatrix() : new Matrix(selectedItemData.transformation?.translateX || 0, selectedItemData.transformation?.translateY || 0);
|
|
288936
288991
|
const width2 = currMbr.getWidth();
|
|
288937
288992
|
const height3 = currMbr.getHeight();
|
|
288938
288993
|
let offsetX = width2;
|
|
@@ -288972,8 +289027,8 @@ function getQuickAddButtons(selection, board) {
|
|
|
288972
289027
|
const adjustment = baseAdjustments[index2];
|
|
288973
289028
|
const newItemData = { ...itemData };
|
|
288974
289029
|
if (newItemData.transformation) {
|
|
288975
|
-
newItemData.transformation.translateX = adjustment.translateX +
|
|
288976
|
-
newItemData.transformation.translateY = adjustment.translateY +
|
|
289030
|
+
newItemData.transformation.translateX = adjustment.translateX + selectedMatrix.translateX;
|
|
289031
|
+
newItemData.transformation.translateY = adjustment.translateY + selectedMatrix.translateY + height3 / 2 - newHeight / 2;
|
|
288977
289032
|
}
|
|
288978
289033
|
const newMbr = new Mbr(newItemData.transformation?.translateX, newItemData.transformation?.translateY, (newItemData.transformation?.translateX || 0) + newWidth, (newItemData.transformation?.translateY || 0) + newHeight);
|
|
288979
289034
|
let step = 1;
|
|
@@ -289064,7 +289119,7 @@ function getQuickAddButtons(selection, board) {
|
|
|
289064
289119
|
}
|
|
289065
289120
|
function getQuickButtonsPositions(customMbr) {
|
|
289066
289121
|
const single = selection.items.getSingle();
|
|
289067
|
-
const itemMbr = customMbr ? customMbr : single?.getMbr();
|
|
289122
|
+
const itemMbr = customMbr ? customMbr : single instanceof BaseItem ? single.getWorldMbr() : single?.getMbr();
|
|
289068
289123
|
if (!itemMbr || single?.itemType !== "Sticker" && single?.itemType !== "Shape" && single?.itemType !== "AINode" && single?.itemType !== "RichText") {
|
|
289069
289124
|
return;
|
|
289070
289125
|
}
|
|
@@ -296469,9 +296524,9 @@ class BoardSelection {
|
|
|
296469
296524
|
}
|
|
296470
296525
|
const selectedMbr = selected.reduce((acc, item) => {
|
|
296471
296526
|
if (!acc) {
|
|
296472
|
-
return item.getMbr();
|
|
296527
|
+
return item instanceof BaseItem ? item.getWorldMbr() : item.getMbr();
|
|
296473
296528
|
}
|
|
296474
|
-
return acc.combine(item.getMbr());
|
|
296529
|
+
return acc.combine(item instanceof BaseItem ? item.getWorldMbr() : item.getMbr());
|
|
296475
296530
|
}, undefined);
|
|
296476
296531
|
if (selectedMbr) {
|
|
296477
296532
|
const selectedMap = Object.fromEntries(selected.map((item) => [item.getId(), { item, nested: false }]));
|
|
@@ -296503,7 +296558,7 @@ class BoardSelection {
|
|
|
296503
296558
|
const childrenIds = val.item.getChildrenIds();
|
|
296504
296559
|
if (childrenIds) {
|
|
296505
296560
|
const currGroup = val.item;
|
|
296506
|
-
const currMbr = currGroup.
|
|
296561
|
+
const currMbr = currGroup.getWorldMbr();
|
|
296507
296562
|
const children = childrenIds.map((childId) => this.board.items.getById(childId)).filter((item) => !!item);
|
|
296508
296563
|
const underGroup = this.board.items.getEnclosedOrCrossed(currMbr.left, currMbr.top, currMbr.right, currMbr.bottom).filter((item) => item.parent === "Board" || item.parent === currGroup.getId());
|
|
296509
296564
|
const uniqueItems = new Set;
|
|
@@ -296984,7 +297039,7 @@ class BoardSelection {
|
|
|
296984
297039
|
};
|
|
296985
297040
|
}
|
|
296986
297041
|
renderItemMbr(context, item, customScale) {
|
|
296987
|
-
const mbr = item.getMbr();
|
|
297042
|
+
const mbr = item instanceof BaseItem ? item.getWorldMbr() : item.getMbr();
|
|
296988
297043
|
mbr.strokeWidth = !customScale ? 1 / context.matrix.scaleX : 1 / customScale;
|
|
296989
297044
|
const selectionColor = item.transformation.isLocked ? conf.SELECTION_LOCKED_COLOR : conf.SELECTION_COLOR;
|
|
296990
297045
|
mbr.borderColor = selectionColor;
|
|
@@ -297041,7 +297096,7 @@ class BoardSelection {
|
|
|
297041
297096
|
path22.setBackgroundColor("none");
|
|
297042
297097
|
path22.render(context);
|
|
297043
297098
|
} else {
|
|
297044
|
-
const itemRect = item.getMbr();
|
|
297099
|
+
const itemRect = item instanceof BaseItem ? item.getWorldMbr() : item.getMbr();
|
|
297045
297100
|
itemRect.borderColor = CONTEXT_NODE_HIGHLIGHT_COLOR;
|
|
297046
297101
|
itemRect.strokeWidth = 2;
|
|
297047
297102
|
itemRect.render(context);
|
|
@@ -297057,13 +297112,8 @@ class GravityEngine {
|
|
|
297057
297112
|
tickTimer = null;
|
|
297058
297113
|
syncTimer = null;
|
|
297059
297114
|
lastSyncedPositions = new Map;
|
|
297060
|
-
G = 80;
|
|
297061
|
-
G_CENTER = 120;
|
|
297062
|
-
DAMPING = 0.92;
|
|
297063
|
-
REPULSION = 800;
|
|
297064
297115
|
TICK_MS = 33;
|
|
297065
297116
|
SYNC_MS = 300;
|
|
297066
|
-
MAX_DISTANCE = 3000;
|
|
297067
297117
|
SOFTENING_SQ = 50 * 50;
|
|
297068
297118
|
MIN_MOVE_PX = 0.1;
|
|
297069
297119
|
constructor(board) {
|
|
@@ -297132,8 +297182,8 @@ class GravityEngine {
|
|
|
297132
297182
|
const dcx = centerX - s1.cx;
|
|
297133
297183
|
const dcy = centerY - s1.cy;
|
|
297134
297184
|
const distCenter = Math.sqrt(dcx * dcx + dcy * dcy) + 1;
|
|
297135
|
-
ax +=
|
|
297136
|
-
ay +=
|
|
297185
|
+
ax += conf.GRAVITY_G_CENTER * dcx / distCenter;
|
|
297186
|
+
ay += conf.GRAVITY_G_CENTER * dcy / distCenter;
|
|
297137
297187
|
for (let j = 0;j < snap.length; j++) {
|
|
297138
297188
|
if (i === j)
|
|
297139
297189
|
continue;
|
|
@@ -297141,7 +297191,7 @@ class GravityEngine {
|
|
|
297141
297191
|
const dx = s2.cx - s1.cx;
|
|
297142
297192
|
const dy = s2.cy - s1.cy;
|
|
297143
297193
|
const dist = Math.sqrt(dx * dx + dy * dy) + 0.001;
|
|
297144
|
-
if (dist >
|
|
297194
|
+
if (dist > conf.GRAVITY_MAX_DISTANCE)
|
|
297145
297195
|
continue;
|
|
297146
297196
|
const overlapping = s1.right > s2.left && s2.right > s1.left && s1.bottom > s2.top && s2.bottom > s1.top;
|
|
297147
297197
|
if (overlapping) {
|
|
@@ -297149,20 +297199,27 @@ class GravityEngine {
|
|
|
297149
297199
|
const overlapY = Math.min(s1.bottom, s2.bottom) - Math.max(s1.top, s2.top);
|
|
297150
297200
|
if (overlapX < overlapY) {
|
|
297151
297201
|
const sign = s1.cx < s2.cx ? -1 : 1;
|
|
297152
|
-
|
|
297202
|
+
if (sign * vel.vx < 0)
|
|
297203
|
+
vel.vx = -vel.vx * conf.GRAVITY_RESTITUTION;
|
|
297204
|
+
ax += sign * conf.GRAVITY_REPULSION * overlapX;
|
|
297153
297205
|
} else {
|
|
297154
297206
|
const sign = s1.cy < s2.cy ? -1 : 1;
|
|
297155
|
-
|
|
297207
|
+
if (sign * vel.vy < 0)
|
|
297208
|
+
vel.vy = -vel.vy * conf.GRAVITY_RESTITUTION;
|
|
297209
|
+
ay += sign * conf.GRAVITY_REPULSION * overlapY;
|
|
297156
297210
|
}
|
|
297157
297211
|
} else {
|
|
297212
|
+
const touchDist = (s1.w + s2.w + s1.h + s2.h) * 0.25;
|
|
297213
|
+
if (dist < touchDist + 5)
|
|
297214
|
+
continue;
|
|
297158
297215
|
const distSq = dx * dx + dy * dy;
|
|
297159
|
-
const gravAcc =
|
|
297216
|
+
const gravAcc = conf.GRAVITY_G * s2.mass / (distSq + this.SOFTENING_SQ);
|
|
297160
297217
|
ax += gravAcc * dx / dist;
|
|
297161
297218
|
ay += gravAcc * dy / dist;
|
|
297162
297219
|
}
|
|
297163
297220
|
}
|
|
297164
|
-
vel.vx = (vel.vx + ax * dt) *
|
|
297165
|
-
vel.vy = (vel.vy + ay * dt) *
|
|
297221
|
+
vel.vx = (vel.vx + ax * dt) * conf.GRAVITY_DAMPING;
|
|
297222
|
+
vel.vy = (vel.vy + ay * dt) * conf.GRAVITY_DAMPING;
|
|
297166
297223
|
const moveX = vel.vx * dt;
|
|
297167
297224
|
const moveY = vel.vy * dt;
|
|
297168
297225
|
if (Math.abs(moveX) >= this.MIN_MOVE_PX || Math.abs(moveY) >= this.MIN_MOVE_PX) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "microboard-ui-temp",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.2",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"i18next-browser-languagedetector": "^8.2.0",
|
|
80
80
|
"js-cookie": "^3.0.5",
|
|
81
81
|
"jwt-decode": "^4.0.0",
|
|
82
|
-
"microboard-temp": "0.12
|
|
82
|
+
"microboard-temp": "0.13.12",
|
|
83
83
|
"nanoid": "^5.1.5",
|
|
84
84
|
"prop-types": "^15.8.1",
|
|
85
85
|
"react-hot-toast": "2.4.1",
|