microboard-temp 0.5.142 → 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 +137 -338
- package/dist/cjs/index.js +137 -338
- package/dist/cjs/node.js +137 -338
- package/dist/esm/browser.js +137 -338
- package/dist/esm/index.js +137 -338
- package/dist/esm/node.js +137 -338
- 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,20 +39926,14 @@ 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
|
-
this.text.scaleAutoSizeScale(Math.min(op.matrix.scaleX, op.matrix.scaleY));
|
|
39956
|
-
this.text.recoordinate();
|
|
39957
|
-
this.text.transformCanvas();
|
|
39958
|
-
} else {
|
|
39959
|
-
this.text.handleInshapeScale();
|
|
39960
|
-
}
|
|
39961
|
-
}
|
|
39962
|
-
} else if (op.method === "transformMany") {
|
|
39963
|
-
const transformOp = op.items[this.id];
|
|
39964
|
-
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)) {
|
|
39965
39931
|
if (this.text.isAutosize()) {
|
|
39966
|
-
|
|
39932
|
+
if (itemOp.matrix.scaleX !== itemOp.matrix.scaleY) {
|
|
39933
|
+
this.text.applyAutoSizeScale(this.text.calcAutoSize());
|
|
39934
|
+
} else {
|
|
39935
|
+
this.text.scaleAutoSizeScale(itemOp.matrix.scaleX);
|
|
39936
|
+
}
|
|
39967
39937
|
this.text.recoordinate();
|
|
39968
39938
|
this.text.transformCanvas();
|
|
39969
39939
|
} else {
|
|
@@ -46200,14 +46170,7 @@ class AlignmentHelper {
|
|
|
46200
46170
|
this.board.selection.transformMany(translation, timeStamp);
|
|
46201
46171
|
} else {
|
|
46202
46172
|
const id = item.getId();
|
|
46203
|
-
|
|
46204
|
-
transformMap[id] = {
|
|
46205
|
-
class: "Transformation",
|
|
46206
|
-
item: [id],
|
|
46207
|
-
method: "applyMatrix",
|
|
46208
|
-
matrix: { translateX: x, translateY: y, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 }
|
|
46209
|
-
};
|
|
46210
|
-
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);
|
|
46211
46174
|
}
|
|
46212
46175
|
}
|
|
46213
46176
|
translateCanvas(x, y, timeStamp) {
|
|
@@ -48056,7 +48019,7 @@ class Card extends BaseItem {
|
|
|
48056
48019
|
this.board.bringToFront(this);
|
|
48057
48020
|
}, 1000);
|
|
48058
48021
|
this.transformation.subject.subscribe((_, op) => {
|
|
48059
|
-
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) {
|
|
48060
48023
|
this.throttledBringToFront();
|
|
48061
48024
|
}
|
|
48062
48025
|
this.updateMbr();
|
|
@@ -51811,7 +51774,7 @@ function handleMultipleItemsResize({
|
|
|
51811
51774
|
isShiftPressed
|
|
51812
51775
|
}) {
|
|
51813
51776
|
const { matrix } = resize;
|
|
51814
|
-
const
|
|
51777
|
+
const result = [];
|
|
51815
51778
|
const items = itemsToResize ? itemsToResize : board.selection.items.list();
|
|
51816
51779
|
board.items.getComments().forEach((comment2) => {
|
|
51817
51780
|
if (items.some((item) => item.getId() === comment2.getItemToFollow())) {
|
|
@@ -51830,25 +51793,25 @@ function handleMultipleItemsResize({
|
|
|
51830
51793
|
const deltaY = itemY - initMbr.top;
|
|
51831
51794
|
const translateY = deltaY * matrix.scaleY - deltaY + matrix.translateY;
|
|
51832
51795
|
if (item instanceof RichText) {
|
|
51833
|
-
|
|
51796
|
+
result.push(getRichTextTranslation({
|
|
51834
51797
|
item,
|
|
51835
51798
|
isWidth,
|
|
51836
51799
|
isHeight,
|
|
51837
51800
|
matrix,
|
|
51838
51801
|
translateX,
|
|
51839
51802
|
translateY
|
|
51840
|
-
});
|
|
51803
|
+
}));
|
|
51841
51804
|
} else if (item instanceof AINode) {
|
|
51842
|
-
|
|
51805
|
+
result.push(getAINodeTranslation({
|
|
51843
51806
|
item,
|
|
51844
51807
|
isWidth,
|
|
51845
51808
|
isHeight,
|
|
51846
51809
|
matrix,
|
|
51847
51810
|
translateX,
|
|
51848
51811
|
translateY
|
|
51849
|
-
});
|
|
51812
|
+
}));
|
|
51850
51813
|
} else {
|
|
51851
|
-
|
|
51814
|
+
result.push(getItemTranslation({
|
|
51852
51815
|
item,
|
|
51853
51816
|
isWidth,
|
|
51854
51817
|
isHeight,
|
|
@@ -51856,10 +51819,10 @@ function handleMultipleItemsResize({
|
|
|
51856
51819
|
translateX,
|
|
51857
51820
|
translateY,
|
|
51858
51821
|
isShiftPressed
|
|
51859
|
-
});
|
|
51822
|
+
}));
|
|
51860
51823
|
}
|
|
51861
51824
|
}
|
|
51862
|
-
return
|
|
51825
|
+
return result;
|
|
51863
51826
|
}
|
|
51864
51827
|
function getRichTextTranslation({
|
|
51865
51828
|
item,
|
|
@@ -51871,26 +51834,11 @@ function getRichTextTranslation({
|
|
|
51871
51834
|
}) {
|
|
51872
51835
|
if (isWidth) {
|
|
51873
51836
|
item.editor.setMaxWidth(item.getWidth() / item.transformation.getScale().x * matrix.scaleX);
|
|
51874
|
-
return {
|
|
51875
|
-
class: "Transformation",
|
|
51876
|
-
method: "applyMatrix",
|
|
51877
|
-
item: [item.getId()],
|
|
51878
|
-
matrix: { translateX: matrix.translateX, translateY: 0, scaleX: matrix.scaleX, scaleY: matrix.scaleX, shearX: 0, shearY: 0 }
|
|
51879
|
-
};
|
|
51837
|
+
return { id: item.getId(), matrix: { translateX: matrix.translateX, translateY: 0, scaleX: matrix.scaleX, scaleY: matrix.scaleX, shearX: 0, shearY: 0 } };
|
|
51880
51838
|
} else if (isHeight) {
|
|
51881
|
-
return {
|
|
51882
|
-
class: "Transformation",
|
|
51883
|
-
method: "applyMatrix",
|
|
51884
|
-
item: [item.getId()],
|
|
51885
|
-
matrix: { translateX, translateY, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 }
|
|
51886
|
-
};
|
|
51839
|
+
return { id: item.getId(), matrix: { translateX, translateY, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 } };
|
|
51887
51840
|
} else {
|
|
51888
|
-
return {
|
|
51889
|
-
class: "Transformation",
|
|
51890
|
-
method: "applyMatrix",
|
|
51891
|
-
item: [item.getId()],
|
|
51892
|
-
matrix: { translateX, translateY, scaleX: matrix.scaleX, scaleY: matrix.scaleX, shearX: 0, shearY: 0 }
|
|
51893
|
-
};
|
|
51841
|
+
return { id: item.getId(), matrix: { translateX, translateY, scaleX: matrix.scaleX, scaleY: matrix.scaleX, shearX: 0, shearY: 0 } };
|
|
51894
51842
|
}
|
|
51895
51843
|
}
|
|
51896
51844
|
function getAINodeTranslation({
|
|
@@ -51903,26 +51851,11 @@ function getAINodeTranslation({
|
|
|
51903
51851
|
}) {
|
|
51904
51852
|
if (isWidth) {
|
|
51905
51853
|
item.text.editor.setMaxWidth(item.text.getWidth() / item.transformation.getScale().x * matrix.scaleX);
|
|
51906
|
-
return {
|
|
51907
|
-
class: "Transformation",
|
|
51908
|
-
method: "applyMatrix",
|
|
51909
|
-
item: [item.getId()],
|
|
51910
|
-
matrix: { translateX: matrix.translateX, translateY: 0, scaleX: matrix.scaleX, scaleY: matrix.scaleX, shearX: 0, shearY: 0 }
|
|
51911
|
-
};
|
|
51854
|
+
return { id: item.getId(), matrix: { translateX: matrix.translateX, translateY: 0, scaleX: matrix.scaleX, scaleY: matrix.scaleX, shearX: 0, shearY: 0 } };
|
|
51912
51855
|
} else if (isHeight) {
|
|
51913
|
-
return {
|
|
51914
|
-
class: "Transformation",
|
|
51915
|
-
method: "applyMatrix",
|
|
51916
|
-
item: [item.getId()],
|
|
51917
|
-
matrix: { translateX, translateY, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 }
|
|
51918
|
-
};
|
|
51856
|
+
return { id: item.getId(), matrix: { translateX, translateY, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 } };
|
|
51919
51857
|
} else {
|
|
51920
|
-
return {
|
|
51921
|
-
class: "Transformation",
|
|
51922
|
-
method: "applyMatrix",
|
|
51923
|
-
item: [item.getId()],
|
|
51924
|
-
matrix: { translateX, translateY, scaleX: matrix.scaleX, scaleY: matrix.scaleX, shearX: 0, shearY: 0 }
|
|
51925
|
-
};
|
|
51858
|
+
return { id: item.getId(), matrix: { translateX, translateY, scaleX: matrix.scaleX, scaleY: matrix.scaleX, shearX: 0, shearY: 0 } };
|
|
51926
51859
|
}
|
|
51927
51860
|
}
|
|
51928
51861
|
function getItemTranslation({
|
|
@@ -51935,22 +51868,12 @@ function getItemTranslation({
|
|
|
51935
51868
|
isShiftPressed
|
|
51936
51869
|
}) {
|
|
51937
51870
|
if (item instanceof Sticker && (isWidth || isHeight)) {
|
|
51938
|
-
return {
|
|
51939
|
-
class: "Transformation",
|
|
51940
|
-
method: "applyMatrix",
|
|
51941
|
-
item: [item.getId()],
|
|
51942
|
-
matrix: { translateX, translateY, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 }
|
|
51943
|
-
};
|
|
51871
|
+
return { id: item.getId(), matrix: { translateX, translateY, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 } };
|
|
51944
51872
|
} else {
|
|
51945
51873
|
if (item instanceof Frame2 && item.getCanChangeRatio() && isShiftPressed && item.getFrameType() !== "Custom") {
|
|
51946
51874
|
item.setFrameType("Custom");
|
|
51947
51875
|
}
|
|
51948
|
-
return {
|
|
51949
|
-
class: "Transformation",
|
|
51950
|
-
method: "applyMatrix",
|
|
51951
|
-
item: [item.getId()],
|
|
51952
|
-
matrix: { translateX, translateY, scaleX: matrix.scaleX, scaleY: matrix.scaleY, shearX: 0, shearY: 0 }
|
|
51953
|
-
};
|
|
51876
|
+
return { id: item.getId(), matrix: { translateX, translateY, scaleX: matrix.scaleX, scaleY: matrix.scaleY, shearX: 0, shearY: 0 } };
|
|
51954
51877
|
}
|
|
51955
51878
|
}
|
|
51956
51879
|
|
|
@@ -53315,53 +53238,41 @@ class BoardSelection {
|
|
|
53315
53238
|
this.shouldPublish = false;
|
|
53316
53239
|
this.emit({
|
|
53317
53240
|
class: "Transformation",
|
|
53318
|
-
method: "
|
|
53241
|
+
method: "applyMatrix",
|
|
53319
53242
|
items,
|
|
53320
53243
|
timeStamp
|
|
53321
53244
|
});
|
|
53322
53245
|
this.shouldPublish = true;
|
|
53323
53246
|
}
|
|
53324
53247
|
getManyItemsTranslation(x, y, unselectedItem) {
|
|
53325
|
-
const
|
|
53326
|
-
|
|
53327
|
-
|
|
53328
|
-
|
|
53329
|
-
|
|
53330
|
-
item: [itemId],
|
|
53331
|
-
matrix: { translateX: x, translateY: y, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 }
|
|
53332
|
-
};
|
|
53333
|
-
}
|
|
53334
|
-
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) => {
|
|
53335
53253
|
if (!("index" in selectedItem) || !selectedItem.index) {
|
|
53336
53254
|
return;
|
|
53337
53255
|
}
|
|
53338
53256
|
for (const childId of selectedItem.getChildrenIds()) {
|
|
53339
|
-
|
|
53257
|
+
addItem(childId);
|
|
53340
53258
|
}
|
|
53341
|
-
}
|
|
53342
|
-
const
|
|
53259
|
+
};
|
|
53260
|
+
const addWithComments = (item) => {
|
|
53261
|
+
addItem(item.getId());
|
|
53262
|
+
tryToAddFrameChildren(item);
|
|
53343
53263
|
const followedComments = this.board.items.getComments().filter((comment2) => comment2.getItemToFollow() === item.getId());
|
|
53344
53264
|
for (const comment2 of followedComments) {
|
|
53345
|
-
|
|
53346
|
-
class: "Transformation",
|
|
53347
|
-
method: "applyMatrix",
|
|
53348
|
-
item: [comment2.getId()],
|
|
53349
|
-
matrix: { translateX: x, translateY: y, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 }
|
|
53350
|
-
};
|
|
53265
|
+
addItem(comment2.getId());
|
|
53351
53266
|
}
|
|
53352
53267
|
};
|
|
53353
53268
|
if (unselectedItem) {
|
|
53354
|
-
|
|
53355
|
-
|
|
53356
|
-
createTranslationWithComments(unselectedItem);
|
|
53357
|
-
return translation;
|
|
53269
|
+
addWithComments(unselectedItem);
|
|
53270
|
+
return items;
|
|
53358
53271
|
}
|
|
53359
53272
|
for (const selectedItem of this.board.selection.list()) {
|
|
53360
|
-
|
|
53361
|
-
tryToAddFrameChildrenToTranslation(selectedItem);
|
|
53362
|
-
createTranslationWithComments(selectedItem);
|
|
53273
|
+
addWithComments(selectedItem);
|
|
53363
53274
|
}
|
|
53364
|
-
return
|
|
53275
|
+
return items;
|
|
53365
53276
|
}
|
|
53366
53277
|
setStrokeStyle(borderStyle) {
|
|
53367
53278
|
const shapes = this.items.getIdsByItemTypes(["Shape"]);
|
|
@@ -54904,32 +54815,40 @@ function mergeOperations(opA, opB) {
|
|
|
54904
54815
|
return;
|
|
54905
54816
|
}
|
|
54906
54817
|
function mergeTransformationOperations(opA, opB) {
|
|
54907
|
-
if (
|
|
54818
|
+
if (opA.timeStamp && opB.timeStamp && opA.timeStamp !== opB.timeStamp) {
|
|
54908
54819
|
return;
|
|
54909
54820
|
}
|
|
54910
|
-
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)) {
|
|
54911
54848
|
return;
|
|
54912
54849
|
}
|
|
54913
54850
|
const method = opA.method;
|
|
54914
54851
|
switch (method) {
|
|
54915
|
-
case "applyMatrix":
|
|
54916
|
-
if (opB.method !== method) {
|
|
54917
|
-
return;
|
|
54918
|
-
}
|
|
54919
|
-
return {
|
|
54920
|
-
class: "Transformation",
|
|
54921
|
-
method: "applyMatrix",
|
|
54922
|
-
item: opA.item,
|
|
54923
|
-
matrix: {
|
|
54924
|
-
translateX: opA.matrix.translateX + opB.matrix.translateX,
|
|
54925
|
-
translateY: opA.matrix.translateY + opB.matrix.translateY,
|
|
54926
|
-
scaleX: opA.matrix.scaleX * opB.matrix.scaleX,
|
|
54927
|
-
scaleY: opA.matrix.scaleY * opB.matrix.scaleY,
|
|
54928
|
-
shearX: 0,
|
|
54929
|
-
shearY: 0
|
|
54930
|
-
},
|
|
54931
|
-
timeStamp: opB.timeStamp
|
|
54932
|
-
};
|
|
54933
54852
|
case "translateBy":
|
|
54934
54853
|
if (opB.method !== method) {
|
|
54935
54854
|
return;
|
|
@@ -54983,130 +54902,10 @@ function mergeTransformationOperations(opA, opB) {
|
|
|
54983
54902
|
},
|
|
54984
54903
|
timeStamp: opB.timeStamp
|
|
54985
54904
|
};
|
|
54986
|
-
case "transformMany":
|
|
54987
|
-
const items = mergeItems(opA, opB);
|
|
54988
|
-
if (opB.method !== method) {
|
|
54989
|
-
return;
|
|
54990
|
-
}
|
|
54991
|
-
return {
|
|
54992
|
-
class: "Transformation",
|
|
54993
|
-
method: "transformMany",
|
|
54994
|
-
items,
|
|
54995
|
-
timeStamp: opB.timeStamp
|
|
54996
|
-
};
|
|
54997
54905
|
default:
|
|
54998
54906
|
return;
|
|
54999
54907
|
}
|
|
55000
54908
|
}
|
|
55001
|
-
function mergeItems(opA, opB) {
|
|
55002
|
-
if (opA.method === "transformMany" && opB.method === "transformMany") {
|
|
55003
|
-
const resolve2 = (currScale, currTranslate, opB2) => {
|
|
55004
|
-
switch (opB2.method) {
|
|
55005
|
-
case "scaleByTranslateBy":
|
|
55006
|
-
return {
|
|
55007
|
-
scale: {
|
|
55008
|
-
x: currScale ? currScale.x * opB2.scale.x : opB2.scale.x,
|
|
55009
|
-
y: currScale ? currScale.y * opB2.scale.y : opB2.scale.y
|
|
55010
|
-
},
|
|
55011
|
-
translate: {
|
|
55012
|
-
x: currTranslate ? currTranslate.x + opB2.translate.x : opB2.translate.x,
|
|
55013
|
-
y: currTranslate ? currTranslate.y + opB2.translate.y : opB2.translate.y
|
|
55014
|
-
}
|
|
55015
|
-
};
|
|
55016
|
-
case "scaleBy":
|
|
55017
|
-
return {
|
|
55018
|
-
scale: {
|
|
55019
|
-
x: currScale ? currScale.x * opB2.x : opB2.x,
|
|
55020
|
-
y: currScale ? currScale.y * opB2.y : opB2.y
|
|
55021
|
-
},
|
|
55022
|
-
translate: {
|
|
55023
|
-
x: currTranslate ? currTranslate.x : 0,
|
|
55024
|
-
y: currTranslate ? currTranslate.y : 0
|
|
55025
|
-
}
|
|
55026
|
-
};
|
|
55027
|
-
case "translateBy":
|
|
55028
|
-
return {
|
|
55029
|
-
scale: {
|
|
55030
|
-
x: currScale ? currScale.x : 1,
|
|
55031
|
-
y: currScale ? currScale.y : 1
|
|
55032
|
-
},
|
|
55033
|
-
translate: {
|
|
55034
|
-
x: currTranslate ? currTranslate.x + opB2.x : opB2.x,
|
|
55035
|
-
y: currTranslate ? currTranslate.y + opB2.y : opB2.y
|
|
55036
|
-
}
|
|
55037
|
-
};
|
|
55038
|
-
}
|
|
55039
|
-
return;
|
|
55040
|
-
};
|
|
55041
|
-
const items = {};
|
|
55042
|
-
Object.keys(opB.items).forEach((itemId) => {
|
|
55043
|
-
if (opA.items[itemId] !== undefined) {
|
|
55044
|
-
if (opA.items[itemId].method === "applyMatrix" && opB.items[itemId].method === "applyMatrix") {
|
|
55045
|
-
const a2 = opA.items[itemId].matrix;
|
|
55046
|
-
const b = opB.items[itemId].matrix;
|
|
55047
|
-
items[itemId] = {
|
|
55048
|
-
class: "Transformation",
|
|
55049
|
-
method: "applyMatrix",
|
|
55050
|
-
item: [itemId],
|
|
55051
|
-
matrix: {
|
|
55052
|
-
translateX: a2.translateX + b.translateX,
|
|
55053
|
-
translateY: a2.translateY + b.translateY,
|
|
55054
|
-
scaleX: a2.scaleX * b.scaleX,
|
|
55055
|
-
scaleY: a2.scaleY * b.scaleY,
|
|
55056
|
-
shearX: 0,
|
|
55057
|
-
shearY: 0
|
|
55058
|
-
}
|
|
55059
|
-
};
|
|
55060
|
-
} else if (opA.items[itemId].method === "scaleByTranslateBy") {
|
|
55061
|
-
const newTransformation = resolve2(opA.items[itemId].scale, opA.items[itemId].translate, opB.items[itemId]);
|
|
55062
|
-
if (!newTransformation) {
|
|
55063
|
-
items[itemId] = opB.items[itemId];
|
|
55064
|
-
} else {
|
|
55065
|
-
items[itemId] = {
|
|
55066
|
-
class: "Transformation",
|
|
55067
|
-
method: "scaleByTranslateBy",
|
|
55068
|
-
item: [itemId],
|
|
55069
|
-
scale: newTransformation.scale,
|
|
55070
|
-
translate: newTransformation.translate
|
|
55071
|
-
};
|
|
55072
|
-
}
|
|
55073
|
-
} else if (opA.items[itemId].method === "scaleBy") {
|
|
55074
|
-
const newTransformation = resolve2({ x: opA.items[itemId].x, y: opA.items[itemId].y }, undefined, opB.items[itemId]);
|
|
55075
|
-
if (!newTransformation) {
|
|
55076
|
-
items[itemId] = opB.items[itemId];
|
|
55077
|
-
} else {
|
|
55078
|
-
items[itemId] = {
|
|
55079
|
-
class: "Transformation",
|
|
55080
|
-
method: "scaleByTranslateBy",
|
|
55081
|
-
item: [itemId],
|
|
55082
|
-
scale: newTransformation.scale,
|
|
55083
|
-
translate: newTransformation.translate
|
|
55084
|
-
};
|
|
55085
|
-
}
|
|
55086
|
-
} else if (opA.items[itemId].method === "translateBy") {
|
|
55087
|
-
const newTransformation = resolve2(undefined, { x: opA.items[itemId].x, y: opA.items[itemId].y }, opB.items[itemId]);
|
|
55088
|
-
if (!newTransformation) {
|
|
55089
|
-
items[itemId] = opB.items[itemId];
|
|
55090
|
-
} else {
|
|
55091
|
-
items[itemId] = {
|
|
55092
|
-
class: "Transformation",
|
|
55093
|
-
method: "scaleByTranslateBy",
|
|
55094
|
-
item: [itemId],
|
|
55095
|
-
scale: newTransformation.scale,
|
|
55096
|
-
translate: newTransformation.translate
|
|
55097
|
-
};
|
|
55098
|
-
}
|
|
55099
|
-
} else {
|
|
55100
|
-
items[itemId] = opB.items[itemId];
|
|
55101
|
-
}
|
|
55102
|
-
} else {
|
|
55103
|
-
items[itemId] = opB.items[itemId];
|
|
55104
|
-
}
|
|
55105
|
-
});
|
|
55106
|
-
return items;
|
|
55107
|
-
}
|
|
55108
|
-
return;
|
|
55109
|
-
}
|
|
55110
54909
|
function mergeRichTextOperations(opA, opB) {
|
|
55111
54910
|
if (!areItemsTheSame(opA, opB)) {
|
|
55112
54911
|
return;
|