microboard-temp 0.5.143 → 0.5.144
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 +134 -343
- package/dist/cjs/index.js +134 -343
- package/dist/cjs/node.js +134 -343
- package/dist/esm/browser.js +134 -343
- package/dist/esm/index.js +134 -343
- package/dist/esm/node.js +134 -343
- package/dist/types/Items/Transformation/TransformationOperations.d.ts +7 -2
- package/dist/types/Selection/Selection.d.ts +4 -4
- package/dist/types/Selection/Transformer/TransformerHelpers/handleMultipleItemsResize.d.ts +2 -2
- package/package.json +1 -1
package/dist/cjs/browser.js
CHANGED
|
@@ -7304,17 +7304,29 @@ class TransformationCommand {
|
|
|
7304
7304
|
switch (this.operation.method) {
|
|
7305
7305
|
case "applyMatrix": {
|
|
7306
7306
|
const op2 = this.operation;
|
|
7307
|
-
return
|
|
7308
|
-
|
|
7309
|
-
|
|
7310
|
-
|
|
7311
|
-
|
|
7312
|
-
|
|
7313
|
-
|
|
7314
|
-
|
|
7315
|
-
|
|
7316
|
-
|
|
7317
|
-
|
|
7307
|
+
return this.transformation.map((t3) => {
|
|
7308
|
+
const itemOp = op2.items.find((i) => i.id === t3.getId());
|
|
7309
|
+
if (!itemOp)
|
|
7310
|
+
return { item: t3, operation: op2 };
|
|
7311
|
+
return {
|
|
7312
|
+
item: t3,
|
|
7313
|
+
operation: {
|
|
7314
|
+
class: "Transformation",
|
|
7315
|
+
method: "applyMatrix",
|
|
7316
|
+
items: [{
|
|
7317
|
+
id: t3.getId(),
|
|
7318
|
+
matrix: {
|
|
7319
|
+
translateX: -itemOp.matrix.translateX,
|
|
7320
|
+
translateY: -itemOp.matrix.translateY,
|
|
7321
|
+
scaleX: 1 / itemOp.matrix.scaleX,
|
|
7322
|
+
scaleY: 1 / itemOp.matrix.scaleY,
|
|
7323
|
+
shearX: 0,
|
|
7324
|
+
shearY: 0
|
|
7325
|
+
}
|
|
7326
|
+
}]
|
|
7327
|
+
}
|
|
7328
|
+
};
|
|
7329
|
+
});
|
|
7318
7330
|
}
|
|
7319
7331
|
case "translateTo":
|
|
7320
7332
|
return mapItemsByOperation(this.transformation, (transformation) => {
|
|
@@ -7396,60 +7408,25 @@ class TransformationCommand {
|
|
|
7396
7408
|
const { operation, transformation } = this;
|
|
7397
7409
|
return transformation.map((currTrans) => {
|
|
7398
7410
|
const op2 = operation.items[currTrans.getId()];
|
|
7399
|
-
|
|
7400
|
-
|
|
7401
|
-
|
|
7402
|
-
|
|
7403
|
-
|
|
7404
|
-
|
|
7405
|
-
|
|
7406
|
-
|
|
7407
|
-
|
|
7408
|
-
|
|
7409
|
-
|
|
7410
|
-
|
|
7411
|
-
|
|
7412
|
-
|
|
7413
|
-
|
|
7414
|
-
|
|
7415
|
-
|
|
7416
|
-
|
|
7417
|
-
|
|
7418
|
-
y: -op2.translate.y
|
|
7419
|
-
}
|
|
7420
|
-
};
|
|
7421
|
-
} else if (op2.method === "translateTo") {
|
|
7422
|
-
reverseOp = {
|
|
7423
|
-
...op2,
|
|
7424
|
-
x: currTrans.getTranslation().x,
|
|
7425
|
-
y: currTrans.getTranslation().y
|
|
7426
|
-
};
|
|
7427
|
-
} else if (op2.method === "translateBy") {
|
|
7428
|
-
reverseOp = {
|
|
7429
|
-
...op2,
|
|
7430
|
-
x: -op2.x,
|
|
7431
|
-
y: -op2.y
|
|
7432
|
-
};
|
|
7433
|
-
} else if (op2.method === "scaleTo") {
|
|
7434
|
-
reverseOp = {
|
|
7435
|
-
...op2,
|
|
7436
|
-
x: currTrans.getScale().x,
|
|
7437
|
-
y: currTrans.getScale().y
|
|
7438
|
-
};
|
|
7439
|
-
} else if (op2.method === "scaleBy") {
|
|
7440
|
-
reverseOp = {
|
|
7441
|
-
...op2,
|
|
7442
|
-
x: 1 / op2.x,
|
|
7443
|
-
y: 1 / op2.y
|
|
7444
|
-
};
|
|
7445
|
-
} else {
|
|
7446
|
-
reverseOp = {
|
|
7447
|
-
...op2,
|
|
7448
|
-
x: 1,
|
|
7449
|
-
y: 1
|
|
7450
|
-
};
|
|
7451
|
-
}
|
|
7452
|
-
return { item: currTrans, operation: reverseOp };
|
|
7411
|
+
const m = op2.method === "applyMatrix" ? op2.matrix : op2.method === "scaleByTranslateBy" ? { translateX: -op2.translate.x, translateY: -op2.translate.y, scaleX: 1 / op2.scale.x, scaleY: 1 / op2.scale.y, shearX: 0, shearY: 0 } : { translateX: 0, translateY: 0, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 };
|
|
7412
|
+
return {
|
|
7413
|
+
item: currTrans,
|
|
7414
|
+
operation: {
|
|
7415
|
+
class: "Transformation",
|
|
7416
|
+
method: "applyMatrix",
|
|
7417
|
+
items: [{
|
|
7418
|
+
id: currTrans.getId(),
|
|
7419
|
+
matrix: {
|
|
7420
|
+
translateX: op2.method === "applyMatrix" ? -m.translateX : m.translateX,
|
|
7421
|
+
translateY: op2.method === "applyMatrix" ? -m.translateY : m.translateY,
|
|
7422
|
+
scaleX: op2.method === "applyMatrix" ? 1 / m.scaleX : m.scaleX,
|
|
7423
|
+
scaleY: op2.method === "applyMatrix" ? 1 / m.scaleY : m.scaleY,
|
|
7424
|
+
shearX: 0,
|
|
7425
|
+
shearY: 0
|
|
7426
|
+
}
|
|
7427
|
+
}]
|
|
7428
|
+
}
|
|
7429
|
+
};
|
|
7453
7430
|
});
|
|
7454
7431
|
}
|
|
7455
7432
|
case "locked": {
|
|
@@ -7580,10 +7557,14 @@ class Transformation {
|
|
|
7580
7557
|
apply(op) {
|
|
7581
7558
|
this.previous = this.matrix.copy();
|
|
7582
7559
|
switch (op.method) {
|
|
7583
|
-
case "applyMatrix":
|
|
7584
|
-
|
|
7585
|
-
|
|
7560
|
+
case "applyMatrix": {
|
|
7561
|
+
const itemOp = op.items.find((i) => i.id === this.id);
|
|
7562
|
+
if (itemOp) {
|
|
7563
|
+
this.matrix.scale(itemOp.matrix.scaleX, itemOp.matrix.scaleY);
|
|
7564
|
+
this.matrix.translate(itemOp.matrix.translateX, itemOp.matrix.translateY);
|
|
7565
|
+
}
|
|
7586
7566
|
break;
|
|
7567
|
+
}
|
|
7587
7568
|
case "translateTo":
|
|
7588
7569
|
this.applyTranslateTo(op.x, op.y);
|
|
7589
7570
|
break;
|
|
@@ -7718,8 +7699,7 @@ class Transformation {
|
|
|
7718
7699
|
this.emit({
|
|
7719
7700
|
class: "Transformation",
|
|
7720
7701
|
method: "applyMatrix",
|
|
7721
|
-
|
|
7722
|
-
matrix,
|
|
7702
|
+
items: [{ id: this.id, matrix }],
|
|
7723
7703
|
timeStamp
|
|
7724
7704
|
});
|
|
7725
7705
|
}
|
|
@@ -19705,7 +19685,7 @@ function createCommand(board, operation) {
|
|
|
19705
19685
|
}
|
|
19706
19686
|
default: {
|
|
19707
19687
|
const itemType = operation.class;
|
|
19708
|
-
const itemIdList = "item" in operation ? Array.isArray(operation.item) ? operation.item : [operation.item] : ("items" in operation) ? Object.keys(operation.items) : operation.itemsOps.map((itemOp) => itemOp.item);
|
|
19688
|
+
const itemIdList = "item" in operation ? Array.isArray(operation.item) ? operation.item : [operation.item] : ("items" in operation) ? Array.isArray(operation.items) ? operation.items.map((i) => i.id) : Object.keys(operation.items) : operation.itemsOps.map((itemOp) => itemOp.item);
|
|
19709
19689
|
const items = itemIdList.map((itemId) => board.items.findById(itemId) ?? itemId).filter((item) => {
|
|
19710
19690
|
if (typeof item === "string") {
|
|
19711
19691
|
console.warn(`Item with ID ${item} not found for operation ${operation.class}.${operation.method}`);
|
|
@@ -21947,7 +21927,8 @@ class RichText extends BaseItem {
|
|
|
21947
21927
|
this.transformation.subject.subscribe((tr, op) => {
|
|
21948
21928
|
this.prevMbr = this.getMbr();
|
|
21949
21929
|
if (op.method === "applyMatrix") {
|
|
21950
|
-
|
|
21930
|
+
const itemOp = op.items.find((i) => i.id === this.id);
|
|
21931
|
+
if (itemOp && (itemOp.matrix.scaleX !== 1 || itemOp.matrix.scaleY !== 1)) {
|
|
21951
21932
|
this.setAINodeShirkWidth();
|
|
21952
21933
|
if (!this.isInShape) {
|
|
21953
21934
|
this.transformCanvas();
|
|
@@ -21957,8 +21938,6 @@ class RichText extends BaseItem {
|
|
|
21957
21938
|
} else {
|
|
21958
21939
|
this.transformCanvas();
|
|
21959
21940
|
}
|
|
21960
|
-
} else if (op.method === "transformMany") {
|
|
21961
|
-
this.transformCanvas();
|
|
21962
21941
|
} else if (op.method === "deserialize") {
|
|
21963
21942
|
this.setAINodeShirkWidth();
|
|
21964
21943
|
this.updateElement();
|
|
@@ -35901,19 +35880,15 @@ class AINode extends BaseItem {
|
|
|
35901
35880
|
this.text = new RichText(this.board, new Mbr, this.id, this.transformation, this.linkTo, " ", false, false, "AINode");
|
|
35902
35881
|
this.transformation.subject.subscribe((_subject, op) => {
|
|
35903
35882
|
if (op.method === "applyMatrix") {
|
|
35904
|
-
|
|
35883
|
+
const itemOp = op.items.find((i) => i.id === this.getId());
|
|
35884
|
+
if (itemOp && (itemOp.matrix.scaleX !== 1 || itemOp.matrix.scaleY !== 1)) {
|
|
35905
35885
|
this.prevMbr = this.path?.getMbr();
|
|
35906
35886
|
this.text.handleInshapeScale();
|
|
35907
|
-
} else {
|
|
35908
|
-
this.text.transformCanvas();
|
|
35909
|
-
}
|
|
35910
|
-
} else if (op.method === "transformMany") {
|
|
35911
|
-
const currItemOp = op.items[this.getId()];
|
|
35912
|
-
this.prevMbr = this.path?.getMbr();
|
|
35913
|
-
if (currItemOp.method === "applyMatrix" && currItemOp.matrix.scaleX === 1 && currItemOp.matrix.scaleY === 1) {
|
|
35887
|
+
} else if (itemOp) {
|
|
35914
35888
|
this.text.transformCanvas();
|
|
35915
35889
|
} else {
|
|
35916
|
-
this.
|
|
35890
|
+
this.prevMbr = this.path?.getMbr();
|
|
35891
|
+
this.text.updateElement();
|
|
35917
35892
|
}
|
|
35918
35893
|
} else {
|
|
35919
35894
|
this.prevMbr = this.path?.getMbr();
|
|
@@ -37125,13 +37100,9 @@ class Connector2 extends BaseItem {
|
|
|
37125
37100
|
this.endPointer = getEndPointer(this.endPoint, this.endPointerStyle, this.lineStyle, this.lines, this.lineWidth * 0.1 + 0.3);
|
|
37126
37101
|
this.middlePoint = null;
|
|
37127
37102
|
this.transformation.subject.subscribe((_sub, op) => {
|
|
37128
|
-
if (op.method === "
|
|
37129
|
-
const
|
|
37130
|
-
if (
|
|
37131
|
-
if (operation.matrix.scaleX !== 1 || operation.matrix.scaleY !== 1) {
|
|
37132
|
-
this.scalePoints();
|
|
37133
|
-
}
|
|
37134
|
-
} else if (operation.method === "scaleByTranslateBy" && (operation.scale.x !== 1 || operation.scale.y !== 1)) {
|
|
37103
|
+
if (op.method === "applyMatrix") {
|
|
37104
|
+
const itemOp = op.items.find((i) => i.id === this.getId());
|
|
37105
|
+
if (itemOp && (itemOp.matrix.scaleX !== 1 || itemOp.matrix.scaleY !== 1)) {
|
|
37135
37106
|
this.scalePoints();
|
|
37136
37107
|
}
|
|
37137
37108
|
}
|
|
@@ -39422,8 +39393,13 @@ class Shape extends BaseItem {
|
|
|
39422
39393
|
this.transformation.subject.subscribe((_subject, op) => {
|
|
39423
39394
|
this.transformPath();
|
|
39424
39395
|
this.updateMbr();
|
|
39425
|
-
if (op.method === "applyMatrix"
|
|
39426
|
-
|
|
39396
|
+
if (op.method === "applyMatrix") {
|
|
39397
|
+
const itemOp = op.items.find((i) => i.id === this.id);
|
|
39398
|
+
if (itemOp && itemOp.matrix.scaleX === 1 && itemOp.matrix.scaleY === 1) {
|
|
39399
|
+
this.text.transformCanvas();
|
|
39400
|
+
} else {
|
|
39401
|
+
this.text.updateElement();
|
|
39402
|
+
}
|
|
39427
39403
|
} else {
|
|
39428
39404
|
this.text.updateElement();
|
|
39429
39405
|
}
|
|
@@ -39950,27 +39926,13 @@ class Sticker extends BaseItem {
|
|
|
39950
39926
|
this.transformation.subject.subscribe((_subject, op) => {
|
|
39951
39927
|
this.transformPath();
|
|
39952
39928
|
if (op.method === "applyMatrix") {
|
|
39953
|
-
|
|
39954
|
-
|
|
39955
|
-
if (op.matrix.scaleX !== op.matrix.scaleY) {
|
|
39956
|
-
this.text.applyAutoSizeScale(this.text.calcAutoSize());
|
|
39957
|
-
} else {
|
|
39958
|
-
this.text.scaleAutoSizeScale(op.matrix.scaleX);
|
|
39959
|
-
}
|
|
39960
|
-
this.text.recoordinate();
|
|
39961
|
-
this.text.transformCanvas();
|
|
39962
|
-
} else {
|
|
39963
|
-
this.text.handleInshapeScale();
|
|
39964
|
-
}
|
|
39965
|
-
}
|
|
39966
|
-
} else if (op.method === "transformMany") {
|
|
39967
|
-
const transformOp = op.items[this.id];
|
|
39968
|
-
if (transformOp.method === "applyMatrix" && (transformOp.matrix.scaleX !== 1 || transformOp.matrix.scaleY !== 1)) {
|
|
39929
|
+
const itemOp = op.items.find((i) => i.id === this.id);
|
|
39930
|
+
if (itemOp && (itemOp.matrix.scaleX !== 1 || itemOp.matrix.scaleY !== 1)) {
|
|
39969
39931
|
if (this.text.isAutosize()) {
|
|
39970
|
-
if (
|
|
39932
|
+
if (itemOp.matrix.scaleX !== itemOp.matrix.scaleY) {
|
|
39971
39933
|
this.text.applyAutoSizeScale(this.text.calcAutoSize());
|
|
39972
39934
|
} else {
|
|
39973
|
-
this.text.scaleAutoSizeScale(
|
|
39935
|
+
this.text.scaleAutoSizeScale(itemOp.matrix.scaleX);
|
|
39974
39936
|
}
|
|
39975
39937
|
this.text.recoordinate();
|
|
39976
39938
|
this.text.transformCanvas();
|
|
@@ -46208,14 +46170,7 @@ class AlignmentHelper {
|
|
|
46208
46170
|
this.board.selection.transformMany(translation, timeStamp);
|
|
46209
46171
|
} else {
|
|
46210
46172
|
const id = item.getId();
|
|
46211
|
-
|
|
46212
|
-
transformMap[id] = {
|
|
46213
|
-
class: "Transformation",
|
|
46214
|
-
item: [id],
|
|
46215
|
-
method: "applyMatrix",
|
|
46216
|
-
matrix: { translateX: x, translateY: y, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 }
|
|
46217
|
-
};
|
|
46218
|
-
this.board.selection.transformMany(transformMap, timeStamp);
|
|
46173
|
+
this.board.selection.transformMany([{ id, matrix: { translateX: x, translateY: y, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 } }], timeStamp);
|
|
46219
46174
|
}
|
|
46220
46175
|
}
|
|
46221
46176
|
translateCanvas(x, y, timeStamp) {
|
|
@@ -48064,7 +48019,7 @@ class Card extends BaseItem {
|
|
|
48064
48019
|
this.board.bringToFront(this);
|
|
48065
48020
|
}, 1000);
|
|
48066
48021
|
this.transformation.subject.subscribe((_, op) => {
|
|
48067
|
-
if (this.parent === "Board" && op.method === "applyMatrix" && op.matrix.scaleX === 1 && op.matrix.scaleY === 1) {
|
|
48022
|
+
if (this.parent === "Board" && op.method === "applyMatrix" && op.items.find((i) => i.id === this.id)?.matrix.scaleX === 1 && op.items.find((i) => i.id === this.id)?.matrix.scaleY === 1) {
|
|
48068
48023
|
this.throttledBringToFront();
|
|
48069
48024
|
}
|
|
48070
48025
|
this.updateMbr();
|
|
@@ -51819,7 +51774,7 @@ function handleMultipleItemsResize({
|
|
|
51819
51774
|
isShiftPressed
|
|
51820
51775
|
}) {
|
|
51821
51776
|
const { matrix } = resize;
|
|
51822
|
-
const
|
|
51777
|
+
const result = [];
|
|
51823
51778
|
const items = itemsToResize ? itemsToResize : board.selection.items.list();
|
|
51824
51779
|
board.items.getComments().forEach((comment2) => {
|
|
51825
51780
|
if (items.some((item) => item.getId() === comment2.getItemToFollow())) {
|
|
@@ -51838,25 +51793,25 @@ function handleMultipleItemsResize({
|
|
|
51838
51793
|
const deltaY = itemY - initMbr.top;
|
|
51839
51794
|
const translateY = deltaY * matrix.scaleY - deltaY + matrix.translateY;
|
|
51840
51795
|
if (item instanceof RichText) {
|
|
51841
|
-
|
|
51796
|
+
result.push(getRichTextTranslation({
|
|
51842
51797
|
item,
|
|
51843
51798
|
isWidth,
|
|
51844
51799
|
isHeight,
|
|
51845
51800
|
matrix,
|
|
51846
51801
|
translateX,
|
|
51847
51802
|
translateY
|
|
51848
|
-
});
|
|
51803
|
+
}));
|
|
51849
51804
|
} else if (item instanceof AINode) {
|
|
51850
|
-
|
|
51805
|
+
result.push(getAINodeTranslation({
|
|
51851
51806
|
item,
|
|
51852
51807
|
isWidth,
|
|
51853
51808
|
isHeight,
|
|
51854
51809
|
matrix,
|
|
51855
51810
|
translateX,
|
|
51856
51811
|
translateY
|
|
51857
|
-
});
|
|
51812
|
+
}));
|
|
51858
51813
|
} else {
|
|
51859
|
-
|
|
51814
|
+
result.push(getItemTranslation({
|
|
51860
51815
|
item,
|
|
51861
51816
|
isWidth,
|
|
51862
51817
|
isHeight,
|
|
@@ -51864,10 +51819,10 @@ function handleMultipleItemsResize({
|
|
|
51864
51819
|
translateX,
|
|
51865
51820
|
translateY,
|
|
51866
51821
|
isShiftPressed
|
|
51867
|
-
});
|
|
51822
|
+
}));
|
|
51868
51823
|
}
|
|
51869
51824
|
}
|
|
51870
|
-
return
|
|
51825
|
+
return result;
|
|
51871
51826
|
}
|
|
51872
51827
|
function getRichTextTranslation({
|
|
51873
51828
|
item,
|
|
@@ -51879,26 +51834,11 @@ function getRichTextTranslation({
|
|
|
51879
51834
|
}) {
|
|
51880
51835
|
if (isWidth) {
|
|
51881
51836
|
item.editor.setMaxWidth(item.getWidth() / item.transformation.getScale().x * matrix.scaleX);
|
|
51882
|
-
return {
|
|
51883
|
-
class: "Transformation",
|
|
51884
|
-
method: "applyMatrix",
|
|
51885
|
-
item: [item.getId()],
|
|
51886
|
-
matrix: { translateX: matrix.translateX, translateY: 0, scaleX: matrix.scaleX, scaleY: matrix.scaleX, shearX: 0, shearY: 0 }
|
|
51887
|
-
};
|
|
51837
|
+
return { id: item.getId(), matrix: { translateX: matrix.translateX, translateY: 0, scaleX: matrix.scaleX, scaleY: matrix.scaleX, shearX: 0, shearY: 0 } };
|
|
51888
51838
|
} else if (isHeight) {
|
|
51889
|
-
return {
|
|
51890
|
-
class: "Transformation",
|
|
51891
|
-
method: "applyMatrix",
|
|
51892
|
-
item: [item.getId()],
|
|
51893
|
-
matrix: { translateX, translateY, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 }
|
|
51894
|
-
};
|
|
51839
|
+
return { id: item.getId(), matrix: { translateX, translateY, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 } };
|
|
51895
51840
|
} else {
|
|
51896
|
-
return {
|
|
51897
|
-
class: "Transformation",
|
|
51898
|
-
method: "applyMatrix",
|
|
51899
|
-
item: [item.getId()],
|
|
51900
|
-
matrix: { translateX, translateY, scaleX: matrix.scaleX, scaleY: matrix.scaleX, shearX: 0, shearY: 0 }
|
|
51901
|
-
};
|
|
51841
|
+
return { id: item.getId(), matrix: { translateX, translateY, scaleX: matrix.scaleX, scaleY: matrix.scaleX, shearX: 0, shearY: 0 } };
|
|
51902
51842
|
}
|
|
51903
51843
|
}
|
|
51904
51844
|
function getAINodeTranslation({
|
|
@@ -51911,26 +51851,11 @@ function getAINodeTranslation({
|
|
|
51911
51851
|
}) {
|
|
51912
51852
|
if (isWidth) {
|
|
51913
51853
|
item.text.editor.setMaxWidth(item.text.getWidth() / item.transformation.getScale().x * matrix.scaleX);
|
|
51914
|
-
return {
|
|
51915
|
-
class: "Transformation",
|
|
51916
|
-
method: "applyMatrix",
|
|
51917
|
-
item: [item.getId()],
|
|
51918
|
-
matrix: { translateX: matrix.translateX, translateY: 0, scaleX: matrix.scaleX, scaleY: matrix.scaleX, shearX: 0, shearY: 0 }
|
|
51919
|
-
};
|
|
51854
|
+
return { id: item.getId(), matrix: { translateX: matrix.translateX, translateY: 0, scaleX: matrix.scaleX, scaleY: matrix.scaleX, shearX: 0, shearY: 0 } };
|
|
51920
51855
|
} else if (isHeight) {
|
|
51921
|
-
return {
|
|
51922
|
-
class: "Transformation",
|
|
51923
|
-
method: "applyMatrix",
|
|
51924
|
-
item: [item.getId()],
|
|
51925
|
-
matrix: { translateX, translateY, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 }
|
|
51926
|
-
};
|
|
51856
|
+
return { id: item.getId(), matrix: { translateX, translateY, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 } };
|
|
51927
51857
|
} else {
|
|
51928
|
-
return {
|
|
51929
|
-
class: "Transformation",
|
|
51930
|
-
method: "applyMatrix",
|
|
51931
|
-
item: [item.getId()],
|
|
51932
|
-
matrix: { translateX, translateY, scaleX: matrix.scaleX, scaleY: matrix.scaleX, shearX: 0, shearY: 0 }
|
|
51933
|
-
};
|
|
51858
|
+
return { id: item.getId(), matrix: { translateX, translateY, scaleX: matrix.scaleX, scaleY: matrix.scaleX, shearX: 0, shearY: 0 } };
|
|
51934
51859
|
}
|
|
51935
51860
|
}
|
|
51936
51861
|
function getItemTranslation({
|
|
@@ -51943,22 +51868,12 @@ function getItemTranslation({
|
|
|
51943
51868
|
isShiftPressed
|
|
51944
51869
|
}) {
|
|
51945
51870
|
if (item instanceof Sticker && (isWidth || isHeight)) {
|
|
51946
|
-
return {
|
|
51947
|
-
class: "Transformation",
|
|
51948
|
-
method: "applyMatrix",
|
|
51949
|
-
item: [item.getId()],
|
|
51950
|
-
matrix: { translateX, translateY, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 }
|
|
51951
|
-
};
|
|
51871
|
+
return { id: item.getId(), matrix: { translateX, translateY, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 } };
|
|
51952
51872
|
} else {
|
|
51953
51873
|
if (item instanceof Frame2 && item.getCanChangeRatio() && isShiftPressed && item.getFrameType() !== "Custom") {
|
|
51954
51874
|
item.setFrameType("Custom");
|
|
51955
51875
|
}
|
|
51956
|
-
return {
|
|
51957
|
-
class: "Transformation",
|
|
51958
|
-
method: "applyMatrix",
|
|
51959
|
-
item: [item.getId()],
|
|
51960
|
-
matrix: { translateX, translateY, scaleX: matrix.scaleX, scaleY: matrix.scaleY, shearX: 0, shearY: 0 }
|
|
51961
|
-
};
|
|
51876
|
+
return { id: item.getId(), matrix: { translateX, translateY, scaleX: matrix.scaleX, scaleY: matrix.scaleY, shearX: 0, shearY: 0 } };
|
|
51962
51877
|
}
|
|
51963
51878
|
}
|
|
51964
51879
|
|
|
@@ -53323,53 +53238,41 @@ class BoardSelection {
|
|
|
53323
53238
|
this.shouldPublish = false;
|
|
53324
53239
|
this.emit({
|
|
53325
53240
|
class: "Transformation",
|
|
53326
|
-
method: "
|
|
53241
|
+
method: "applyMatrix",
|
|
53327
53242
|
items,
|
|
53328
53243
|
timeStamp
|
|
53329
53244
|
});
|
|
53330
53245
|
this.shouldPublish = true;
|
|
53331
53246
|
}
|
|
53332
53247
|
getManyItemsTranslation(x, y, unselectedItem) {
|
|
53333
|
-
const
|
|
53334
|
-
|
|
53335
|
-
|
|
53336
|
-
|
|
53337
|
-
|
|
53338
|
-
item: [itemId],
|
|
53339
|
-
matrix: { translateX: x, translateY: y, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 }
|
|
53340
|
-
};
|
|
53341
|
-
}
|
|
53342
|
-
function tryToAddFrameChildrenToTranslation(selectedItem) {
|
|
53248
|
+
const items = [];
|
|
53249
|
+
const addItem = (itemId) => {
|
|
53250
|
+
items.push({ id: itemId, matrix: { translateX: x, translateY: y, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 } });
|
|
53251
|
+
};
|
|
53252
|
+
const tryToAddFrameChildren = (selectedItem) => {
|
|
53343
53253
|
if (!("index" in selectedItem) || !selectedItem.index) {
|
|
53344
53254
|
return;
|
|
53345
53255
|
}
|
|
53346
53256
|
for (const childId of selectedItem.getChildrenIds()) {
|
|
53347
|
-
|
|
53257
|
+
addItem(childId);
|
|
53348
53258
|
}
|
|
53349
|
-
}
|
|
53350
|
-
const
|
|
53259
|
+
};
|
|
53260
|
+
const addWithComments = (item) => {
|
|
53261
|
+
addItem(item.getId());
|
|
53262
|
+
tryToAddFrameChildren(item);
|
|
53351
53263
|
const followedComments = this.board.items.getComments().filter((comment2) => comment2.getItemToFollow() === item.getId());
|
|
53352
53264
|
for (const comment2 of followedComments) {
|
|
53353
|
-
|
|
53354
|
-
class: "Transformation",
|
|
53355
|
-
method: "applyMatrix",
|
|
53356
|
-
item: [comment2.getId()],
|
|
53357
|
-
matrix: { translateX: x, translateY: y, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 }
|
|
53358
|
-
};
|
|
53265
|
+
addItem(comment2.getId());
|
|
53359
53266
|
}
|
|
53360
53267
|
};
|
|
53361
53268
|
if (unselectedItem) {
|
|
53362
|
-
|
|
53363
|
-
|
|
53364
|
-
createTranslationWithComments(unselectedItem);
|
|
53365
|
-
return translation;
|
|
53269
|
+
addWithComments(unselectedItem);
|
|
53270
|
+
return items;
|
|
53366
53271
|
}
|
|
53367
53272
|
for (const selectedItem of this.board.selection.list()) {
|
|
53368
|
-
|
|
53369
|
-
tryToAddFrameChildrenToTranslation(selectedItem);
|
|
53370
|
-
createTranslationWithComments(selectedItem);
|
|
53273
|
+
addWithComments(selectedItem);
|
|
53371
53274
|
}
|
|
53372
|
-
return
|
|
53275
|
+
return items;
|
|
53373
53276
|
}
|
|
53374
53277
|
setStrokeStyle(borderStyle) {
|
|
53375
53278
|
const shapes = this.items.getIdsByItemTypes(["Shape"]);
|
|
@@ -54912,32 +54815,40 @@ function mergeOperations(opA, opB) {
|
|
|
54912
54815
|
return;
|
|
54913
54816
|
}
|
|
54914
54817
|
function mergeTransformationOperations(opA, opB) {
|
|
54915
|
-
if (
|
|
54818
|
+
if (opA.timeStamp && opB.timeStamp && opA.timeStamp !== opB.timeStamp) {
|
|
54916
54819
|
return;
|
|
54917
54820
|
}
|
|
54918
|
-
if (opA.
|
|
54821
|
+
if (opA.method === "applyMatrix" && opB.method === "applyMatrix") {
|
|
54822
|
+
if (opA.items.length !== opB.items.length)
|
|
54823
|
+
return;
|
|
54824
|
+
const idsA = new Set(opA.items.map((i) => i.id));
|
|
54825
|
+
if (!opB.items.every((b) => idsA.has(b.id)))
|
|
54826
|
+
return;
|
|
54827
|
+
return {
|
|
54828
|
+
class: "Transformation",
|
|
54829
|
+
method: "applyMatrix",
|
|
54830
|
+
items: opB.items.map((b) => {
|
|
54831
|
+
const a2 = opA.items.find((i) => i.id === b.id);
|
|
54832
|
+
return {
|
|
54833
|
+
id: b.id,
|
|
54834
|
+
matrix: {
|
|
54835
|
+
translateX: a2.matrix.translateX + b.matrix.translateX,
|
|
54836
|
+
translateY: a2.matrix.translateY + b.matrix.translateY,
|
|
54837
|
+
scaleX: a2.matrix.scaleX * b.matrix.scaleX,
|
|
54838
|
+
scaleY: a2.matrix.scaleY * b.matrix.scaleY,
|
|
54839
|
+
shearX: 0,
|
|
54840
|
+
shearY: 0
|
|
54841
|
+
}
|
|
54842
|
+
};
|
|
54843
|
+
}),
|
|
54844
|
+
timeStamp: opB.timeStamp
|
|
54845
|
+
};
|
|
54846
|
+
}
|
|
54847
|
+
if (!areItemsTheSame(opA, opB)) {
|
|
54919
54848
|
return;
|
|
54920
54849
|
}
|
|
54921
54850
|
const method = opA.method;
|
|
54922
54851
|
switch (method) {
|
|
54923
|
-
case "applyMatrix":
|
|
54924
|
-
if (opB.method !== method) {
|
|
54925
|
-
return;
|
|
54926
|
-
}
|
|
54927
|
-
return {
|
|
54928
|
-
class: "Transformation",
|
|
54929
|
-
method: "applyMatrix",
|
|
54930
|
-
item: opA.item,
|
|
54931
|
-
matrix: {
|
|
54932
|
-
translateX: opA.matrix.translateX + opB.matrix.translateX,
|
|
54933
|
-
translateY: opA.matrix.translateY + opB.matrix.translateY,
|
|
54934
|
-
scaleX: opA.matrix.scaleX * opB.matrix.scaleX,
|
|
54935
|
-
scaleY: opA.matrix.scaleY * opB.matrix.scaleY,
|
|
54936
|
-
shearX: 0,
|
|
54937
|
-
shearY: 0
|
|
54938
|
-
},
|
|
54939
|
-
timeStamp: opB.timeStamp
|
|
54940
|
-
};
|
|
54941
54852
|
case "translateBy":
|
|
54942
54853
|
if (opB.method !== method) {
|
|
54943
54854
|
return;
|
|
@@ -54991,130 +54902,10 @@ function mergeTransformationOperations(opA, opB) {
|
|
|
54991
54902
|
},
|
|
54992
54903
|
timeStamp: opB.timeStamp
|
|
54993
54904
|
};
|
|
54994
|
-
case "transformMany":
|
|
54995
|
-
const items = mergeItems(opA, opB);
|
|
54996
|
-
if (opB.method !== method) {
|
|
54997
|
-
return;
|
|
54998
|
-
}
|
|
54999
|
-
return {
|
|
55000
|
-
class: "Transformation",
|
|
55001
|
-
method: "transformMany",
|
|
55002
|
-
items,
|
|
55003
|
-
timeStamp: opB.timeStamp
|
|
55004
|
-
};
|
|
55005
54905
|
default:
|
|
55006
54906
|
return;
|
|
55007
54907
|
}
|
|
55008
54908
|
}
|
|
55009
|
-
function mergeItems(opA, opB) {
|
|
55010
|
-
if (opA.method === "transformMany" && opB.method === "transformMany") {
|
|
55011
|
-
const resolve2 = (currScale, currTranslate, opB2) => {
|
|
55012
|
-
switch (opB2.method) {
|
|
55013
|
-
case "scaleByTranslateBy":
|
|
55014
|
-
return {
|
|
55015
|
-
scale: {
|
|
55016
|
-
x: currScale ? currScale.x * opB2.scale.x : opB2.scale.x,
|
|
55017
|
-
y: currScale ? currScale.y * opB2.scale.y : opB2.scale.y
|
|
55018
|
-
},
|
|
55019
|
-
translate: {
|
|
55020
|
-
x: currTranslate ? currTranslate.x + opB2.translate.x : opB2.translate.x,
|
|
55021
|
-
y: currTranslate ? currTranslate.y + opB2.translate.y : opB2.translate.y
|
|
55022
|
-
}
|
|
55023
|
-
};
|
|
55024
|
-
case "scaleBy":
|
|
55025
|
-
return {
|
|
55026
|
-
scale: {
|
|
55027
|
-
x: currScale ? currScale.x * opB2.x : opB2.x,
|
|
55028
|
-
y: currScale ? currScale.y * opB2.y : opB2.y
|
|
55029
|
-
},
|
|
55030
|
-
translate: {
|
|
55031
|
-
x: currTranslate ? currTranslate.x : 0,
|
|
55032
|
-
y: currTranslate ? currTranslate.y : 0
|
|
55033
|
-
}
|
|
55034
|
-
};
|
|
55035
|
-
case "translateBy":
|
|
55036
|
-
return {
|
|
55037
|
-
scale: {
|
|
55038
|
-
x: currScale ? currScale.x : 1,
|
|
55039
|
-
y: currScale ? currScale.y : 1
|
|
55040
|
-
},
|
|
55041
|
-
translate: {
|
|
55042
|
-
x: currTranslate ? currTranslate.x + opB2.x : opB2.x,
|
|
55043
|
-
y: currTranslate ? currTranslate.y + opB2.y : opB2.y
|
|
55044
|
-
}
|
|
55045
|
-
};
|
|
55046
|
-
}
|
|
55047
|
-
return;
|
|
55048
|
-
};
|
|
55049
|
-
const items = {};
|
|
55050
|
-
Object.keys(opB.items).forEach((itemId) => {
|
|
55051
|
-
if (opA.items[itemId] !== undefined) {
|
|
55052
|
-
if (opA.items[itemId].method === "applyMatrix" && opB.items[itemId].method === "applyMatrix") {
|
|
55053
|
-
const a2 = opA.items[itemId].matrix;
|
|
55054
|
-
const b = opB.items[itemId].matrix;
|
|
55055
|
-
items[itemId] = {
|
|
55056
|
-
class: "Transformation",
|
|
55057
|
-
method: "applyMatrix",
|
|
55058
|
-
item: [itemId],
|
|
55059
|
-
matrix: {
|
|
55060
|
-
translateX: a2.translateX + b.translateX,
|
|
55061
|
-
translateY: a2.translateY + b.translateY,
|
|
55062
|
-
scaleX: a2.scaleX * b.scaleX,
|
|
55063
|
-
scaleY: a2.scaleY * b.scaleY,
|
|
55064
|
-
shearX: 0,
|
|
55065
|
-
shearY: 0
|
|
55066
|
-
}
|
|
55067
|
-
};
|
|
55068
|
-
} else if (opA.items[itemId].method === "scaleByTranslateBy") {
|
|
55069
|
-
const newTransformation = resolve2(opA.items[itemId].scale, opA.items[itemId].translate, opB.items[itemId]);
|
|
55070
|
-
if (!newTransformation) {
|
|
55071
|
-
items[itemId] = opB.items[itemId];
|
|
55072
|
-
} else {
|
|
55073
|
-
items[itemId] = {
|
|
55074
|
-
class: "Transformation",
|
|
55075
|
-
method: "scaleByTranslateBy",
|
|
55076
|
-
item: [itemId],
|
|
55077
|
-
scale: newTransformation.scale,
|
|
55078
|
-
translate: newTransformation.translate
|
|
55079
|
-
};
|
|
55080
|
-
}
|
|
55081
|
-
} else if (opA.items[itemId].method === "scaleBy") {
|
|
55082
|
-
const newTransformation = resolve2({ x: opA.items[itemId].x, y: opA.items[itemId].y }, undefined, opB.items[itemId]);
|
|
55083
|
-
if (!newTransformation) {
|
|
55084
|
-
items[itemId] = opB.items[itemId];
|
|
55085
|
-
} else {
|
|
55086
|
-
items[itemId] = {
|
|
55087
|
-
class: "Transformation",
|
|
55088
|
-
method: "scaleByTranslateBy",
|
|
55089
|
-
item: [itemId],
|
|
55090
|
-
scale: newTransformation.scale,
|
|
55091
|
-
translate: newTransformation.translate
|
|
55092
|
-
};
|
|
55093
|
-
}
|
|
55094
|
-
} else if (opA.items[itemId].method === "translateBy") {
|
|
55095
|
-
const newTransformation = resolve2(undefined, { x: opA.items[itemId].x, y: opA.items[itemId].y }, opB.items[itemId]);
|
|
55096
|
-
if (!newTransformation) {
|
|
55097
|
-
items[itemId] = opB.items[itemId];
|
|
55098
|
-
} else {
|
|
55099
|
-
items[itemId] = {
|
|
55100
|
-
class: "Transformation",
|
|
55101
|
-
method: "scaleByTranslateBy",
|
|
55102
|
-
item: [itemId],
|
|
55103
|
-
scale: newTransformation.scale,
|
|
55104
|
-
translate: newTransformation.translate
|
|
55105
|
-
};
|
|
55106
|
-
}
|
|
55107
|
-
} else {
|
|
55108
|
-
items[itemId] = opB.items[itemId];
|
|
55109
|
-
}
|
|
55110
|
-
} else {
|
|
55111
|
-
items[itemId] = opB.items[itemId];
|
|
55112
|
-
}
|
|
55113
|
-
});
|
|
55114
|
-
return items;
|
|
55115
|
-
}
|
|
55116
|
-
return;
|
|
55117
|
-
}
|
|
55118
54909
|
function mergeRichTextOperations(opA, opB) {
|
|
55119
54910
|
if (!areItemsTheSame(opA, opB)) {
|
|
55120
54911
|
return;
|