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/esm/index.js CHANGED
@@ -7131,17 +7131,29 @@ class TransformationCommand {
7131
7131
  switch (this.operation.method) {
7132
7132
  case "applyMatrix": {
7133
7133
  const op2 = this.operation;
7134
- return mapItemsByOperation(this.transformation, () => ({
7135
- ...op2,
7136
- matrix: {
7137
- translateX: -op2.matrix.translateX,
7138
- translateY: -op2.matrix.translateY,
7139
- scaleX: 1 / op2.matrix.scaleX,
7140
- scaleY: 1 / op2.matrix.scaleY,
7141
- shearX: 0,
7142
- shearY: 0
7143
- }
7144
- }));
7134
+ return this.transformation.map((t3) => {
7135
+ const itemOp = op2.items.find((i) => i.id === t3.getId());
7136
+ if (!itemOp)
7137
+ return { item: t3, operation: op2 };
7138
+ return {
7139
+ item: t3,
7140
+ operation: {
7141
+ class: "Transformation",
7142
+ method: "applyMatrix",
7143
+ items: [{
7144
+ id: t3.getId(),
7145
+ matrix: {
7146
+ translateX: -itemOp.matrix.translateX,
7147
+ translateY: -itemOp.matrix.translateY,
7148
+ scaleX: 1 / itemOp.matrix.scaleX,
7149
+ scaleY: 1 / itemOp.matrix.scaleY,
7150
+ shearX: 0,
7151
+ shearY: 0
7152
+ }
7153
+ }]
7154
+ }
7155
+ };
7156
+ });
7145
7157
  }
7146
7158
  case "translateTo":
7147
7159
  return mapItemsByOperation(this.transformation, (transformation) => {
@@ -7223,60 +7235,25 @@ class TransformationCommand {
7223
7235
  const { operation, transformation } = this;
7224
7236
  return transformation.map((currTrans) => {
7225
7237
  const op2 = operation.items[currTrans.getId()];
7226
- let reverseOp;
7227
- if (op2.method === "applyMatrix") {
7228
- reverseOp = {
7229
- ...op2,
7230
- matrix: {
7231
- translateX: -op2.matrix.translateX,
7232
- translateY: -op2.matrix.translateY,
7233
- scaleX: 1 / op2.matrix.scaleX,
7234
- scaleY: 1 / op2.matrix.scaleY,
7235
- shearX: 0,
7236
- shearY: 0
7237
- }
7238
- };
7239
- } else if (op2.method === "scaleByTranslateBy") {
7240
- reverseOp = {
7241
- ...op2,
7242
- scale: { x: 1 / op2.scale.x, y: 1 / op2.scale.y },
7243
- translate: {
7244
- x: -op2.translate.x,
7245
- y: -op2.translate.y
7246
- }
7247
- };
7248
- } else if (op2.method === "translateTo") {
7249
- reverseOp = {
7250
- ...op2,
7251
- x: currTrans.getTranslation().x,
7252
- y: currTrans.getTranslation().y
7253
- };
7254
- } else if (op2.method === "translateBy") {
7255
- reverseOp = {
7256
- ...op2,
7257
- x: -op2.x,
7258
- y: -op2.y
7259
- };
7260
- } else if (op2.method === "scaleTo") {
7261
- reverseOp = {
7262
- ...op2,
7263
- x: currTrans.getScale().x,
7264
- y: currTrans.getScale().y
7265
- };
7266
- } else if (op2.method === "scaleBy") {
7267
- reverseOp = {
7268
- ...op2,
7269
- x: 1 / op2.x,
7270
- y: 1 / op2.y
7271
- };
7272
- } else {
7273
- reverseOp = {
7274
- ...op2,
7275
- x: 1,
7276
- y: 1
7277
- };
7278
- }
7279
- return { item: currTrans, operation: reverseOp };
7238
+ 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 };
7239
+ return {
7240
+ item: currTrans,
7241
+ operation: {
7242
+ class: "Transformation",
7243
+ method: "applyMatrix",
7244
+ items: [{
7245
+ id: currTrans.getId(),
7246
+ matrix: {
7247
+ translateX: op2.method === "applyMatrix" ? -m.translateX : m.translateX,
7248
+ translateY: op2.method === "applyMatrix" ? -m.translateY : m.translateY,
7249
+ scaleX: op2.method === "applyMatrix" ? 1 / m.scaleX : m.scaleX,
7250
+ scaleY: op2.method === "applyMatrix" ? 1 / m.scaleY : m.scaleY,
7251
+ shearX: 0,
7252
+ shearY: 0
7253
+ }
7254
+ }]
7255
+ }
7256
+ };
7280
7257
  });
7281
7258
  }
7282
7259
  case "locked": {
@@ -7407,10 +7384,14 @@ class Transformation {
7407
7384
  apply(op) {
7408
7385
  this.previous = this.matrix.copy();
7409
7386
  switch (op.method) {
7410
- case "applyMatrix":
7411
- this.matrix.scale(op.matrix.scaleX, op.matrix.scaleY);
7412
- this.matrix.translate(op.matrix.translateX, op.matrix.translateY);
7387
+ case "applyMatrix": {
7388
+ const itemOp = op.items.find((i) => i.id === this.id);
7389
+ if (itemOp) {
7390
+ this.matrix.scale(itemOp.matrix.scaleX, itemOp.matrix.scaleY);
7391
+ this.matrix.translate(itemOp.matrix.translateX, itemOp.matrix.translateY);
7392
+ }
7413
7393
  break;
7394
+ }
7414
7395
  case "translateTo":
7415
7396
  this.applyTranslateTo(op.x, op.y);
7416
7397
  break;
@@ -7545,8 +7526,7 @@ class Transformation {
7545
7526
  this.emit({
7546
7527
  class: "Transformation",
7547
7528
  method: "applyMatrix",
7548
- item: [this.id],
7549
- matrix,
7529
+ items: [{ id: this.id, matrix }],
7550
7530
  timeStamp
7551
7531
  });
7552
7532
  }
@@ -19541,7 +19521,7 @@ function createCommand(board, operation) {
19541
19521
  }
19542
19522
  default: {
19543
19523
  const itemType = operation.class;
19544
- 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);
19524
+ 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);
19545
19525
  const items = itemIdList.map((itemId) => board.items.findById(itemId) ?? itemId).filter((item) => {
19546
19526
  if (typeof item === "string") {
19547
19527
  console.warn(`Item with ID ${item} not found for operation ${operation.class}.${operation.method}`);
@@ -21783,7 +21763,8 @@ class RichText extends BaseItem {
21783
21763
  this.transformation.subject.subscribe((tr, op) => {
21784
21764
  this.prevMbr = this.getMbr();
21785
21765
  if (op.method === "applyMatrix") {
21786
- if (op.matrix.scaleX !== 1 || op.matrix.scaleY !== 1) {
21766
+ const itemOp = op.items.find((i) => i.id === this.id);
21767
+ if (itemOp && (itemOp.matrix.scaleX !== 1 || itemOp.matrix.scaleY !== 1)) {
21787
21768
  this.setAINodeShirkWidth();
21788
21769
  if (!this.isInShape) {
21789
21770
  this.transformCanvas();
@@ -21793,8 +21774,6 @@ class RichText extends BaseItem {
21793
21774
  } else {
21794
21775
  this.transformCanvas();
21795
21776
  }
21796
- } else if (op.method === "transformMany") {
21797
- this.transformCanvas();
21798
21777
  } else if (op.method === "deserialize") {
21799
21778
  this.setAINodeShirkWidth();
21800
21779
  this.updateElement();
@@ -35737,19 +35716,15 @@ class AINode extends BaseItem {
35737
35716
  this.text = new RichText(this.board, new Mbr, this.id, this.transformation, this.linkTo, " ", false, false, "AINode");
35738
35717
  this.transformation.subject.subscribe((_subject, op) => {
35739
35718
  if (op.method === "applyMatrix") {
35740
- if (op.matrix.scaleX !== 1 || op.matrix.scaleY !== 1) {
35719
+ const itemOp = op.items.find((i) => i.id === this.getId());
35720
+ if (itemOp && (itemOp.matrix.scaleX !== 1 || itemOp.matrix.scaleY !== 1)) {
35741
35721
  this.prevMbr = this.path?.getMbr();
35742
35722
  this.text.handleInshapeScale();
35743
- } else {
35744
- this.text.transformCanvas();
35745
- }
35746
- } else if (op.method === "transformMany") {
35747
- const currItemOp = op.items[this.getId()];
35748
- this.prevMbr = this.path?.getMbr();
35749
- if (currItemOp.method === "applyMatrix" && currItemOp.matrix.scaleX === 1 && currItemOp.matrix.scaleY === 1) {
35723
+ } else if (itemOp) {
35750
35724
  this.text.transformCanvas();
35751
35725
  } else {
35752
- this.text.handleInshapeScale();
35726
+ this.prevMbr = this.path?.getMbr();
35727
+ this.text.updateElement();
35753
35728
  }
35754
35729
  } else {
35755
35730
  this.prevMbr = this.path?.getMbr();
@@ -36961,13 +36936,9 @@ class Connector2 extends BaseItem {
36961
36936
  this.endPointer = getEndPointer(this.endPoint, this.endPointerStyle, this.lineStyle, this.lines, this.lineWidth * 0.1 + 0.3);
36962
36937
  this.middlePoint = null;
36963
36938
  this.transformation.subject.subscribe((_sub, op) => {
36964
- if (op.method === "transformMany") {
36965
- const operation = op.items[this.getId()];
36966
- if (operation.method === "applyMatrix") {
36967
- if (operation.matrix.scaleX !== 1 || operation.matrix.scaleY !== 1) {
36968
- this.scalePoints();
36969
- }
36970
- } else if (operation.method === "scaleByTranslateBy" && (operation.scale.x !== 1 || operation.scale.y !== 1)) {
36939
+ if (op.method === "applyMatrix") {
36940
+ const itemOp = op.items.find((i) => i.id === this.getId());
36941
+ if (itemOp && (itemOp.matrix.scaleX !== 1 || itemOp.matrix.scaleY !== 1)) {
36971
36942
  this.scalePoints();
36972
36943
  }
36973
36944
  }
@@ -39258,8 +39229,13 @@ class Shape extends BaseItem {
39258
39229
  this.transformation.subject.subscribe((_subject, op) => {
39259
39230
  this.transformPath();
39260
39231
  this.updateMbr();
39261
- if (op.method === "applyMatrix" && op.matrix.scaleX === 1 && op.matrix.scaleY === 1) {
39262
- this.text.transformCanvas();
39232
+ if (op.method === "applyMatrix") {
39233
+ const itemOp = op.items.find((i) => i.id === this.id);
39234
+ if (itemOp && itemOp.matrix.scaleX === 1 && itemOp.matrix.scaleY === 1) {
39235
+ this.text.transformCanvas();
39236
+ } else {
39237
+ this.text.updateElement();
39238
+ }
39263
39239
  } else {
39264
39240
  this.text.updateElement();
39265
39241
  }
@@ -39786,20 +39762,14 @@ class Sticker extends BaseItem {
39786
39762
  this.transformation.subject.subscribe((_subject, op) => {
39787
39763
  this.transformPath();
39788
39764
  if (op.method === "applyMatrix") {
39789
- if (op.matrix.scaleX !== 1 || op.matrix.scaleY !== 1) {
39790
- if (this.text.isAutosize()) {
39791
- this.text.scaleAutoSizeScale(Math.min(op.matrix.scaleX, op.matrix.scaleY));
39792
- this.text.recoordinate();
39793
- this.text.transformCanvas();
39794
- } else {
39795
- this.text.handleInshapeScale();
39796
- }
39797
- }
39798
- } else if (op.method === "transformMany") {
39799
- const transformOp = op.items[this.id];
39800
- if (transformOp.method === "applyMatrix" && (transformOp.matrix.scaleX !== 1 || transformOp.matrix.scaleY !== 1)) {
39765
+ const itemOp = op.items.find((i) => i.id === this.id);
39766
+ if (itemOp && (itemOp.matrix.scaleX !== 1 || itemOp.matrix.scaleY !== 1)) {
39801
39767
  if (this.text.isAutosize()) {
39802
- this.text.scaleAutoSizeScale(Math.min(transformOp.matrix.scaleX, transformOp.matrix.scaleY));
39768
+ if (itemOp.matrix.scaleX !== itemOp.matrix.scaleY) {
39769
+ this.text.applyAutoSizeScale(this.text.calcAutoSize());
39770
+ } else {
39771
+ this.text.scaleAutoSizeScale(itemOp.matrix.scaleX);
39772
+ }
39803
39773
  this.text.recoordinate();
39804
39774
  this.text.transformCanvas();
39805
39775
  } else {
@@ -46036,14 +46006,7 @@ class AlignmentHelper {
46036
46006
  this.board.selection.transformMany(translation, timeStamp);
46037
46007
  } else {
46038
46008
  const id = item.getId();
46039
- const transformMap = {};
46040
- transformMap[id] = {
46041
- class: "Transformation",
46042
- item: [id],
46043
- method: "applyMatrix",
46044
- matrix: { translateX: x, translateY: y, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 }
46045
- };
46046
- this.board.selection.transformMany(transformMap, timeStamp);
46009
+ this.board.selection.transformMany([{ id, matrix: { translateX: x, translateY: y, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 } }], timeStamp);
46047
46010
  }
46048
46011
  }
46049
46012
  translateCanvas(x, y, timeStamp) {
@@ -47892,7 +47855,7 @@ class Card extends BaseItem {
47892
47855
  this.board.bringToFront(this);
47893
47856
  }, 1000);
47894
47857
  this.transformation.subject.subscribe((_, op) => {
47895
- if (this.parent === "Board" && op.method === "applyMatrix" && op.matrix.scaleX === 1 && op.matrix.scaleY === 1) {
47858
+ 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) {
47896
47859
  this.throttledBringToFront();
47897
47860
  }
47898
47861
  this.updateMbr();
@@ -51647,7 +51610,7 @@ function handleMultipleItemsResize({
51647
51610
  isShiftPressed
51648
51611
  }) {
51649
51612
  const { matrix } = resize;
51650
- const translation = {};
51613
+ const result = [];
51651
51614
  const items = itemsToResize ? itemsToResize : board.selection.items.list();
51652
51615
  board.items.getComments().forEach((comment2) => {
51653
51616
  if (items.some((item) => item.getId() === comment2.getItemToFollow())) {
@@ -51666,25 +51629,25 @@ function handleMultipleItemsResize({
51666
51629
  const deltaY = itemY - initMbr.top;
51667
51630
  const translateY = deltaY * matrix.scaleY - deltaY + matrix.translateY;
51668
51631
  if (item instanceof RichText) {
51669
- translation[item.getId()] = getRichTextTranslation({
51632
+ result.push(getRichTextTranslation({
51670
51633
  item,
51671
51634
  isWidth,
51672
51635
  isHeight,
51673
51636
  matrix,
51674
51637
  translateX,
51675
51638
  translateY
51676
- });
51639
+ }));
51677
51640
  } else if (item instanceof AINode) {
51678
- translation[item.getId()] = getAINodeTranslation({
51641
+ result.push(getAINodeTranslation({
51679
51642
  item,
51680
51643
  isWidth,
51681
51644
  isHeight,
51682
51645
  matrix,
51683
51646
  translateX,
51684
51647
  translateY
51685
- });
51648
+ }));
51686
51649
  } else {
51687
- translation[item.getId()] = getItemTranslation({
51650
+ result.push(getItemTranslation({
51688
51651
  item,
51689
51652
  isWidth,
51690
51653
  isHeight,
@@ -51692,10 +51655,10 @@ function handleMultipleItemsResize({
51692
51655
  translateX,
51693
51656
  translateY,
51694
51657
  isShiftPressed
51695
- });
51658
+ }));
51696
51659
  }
51697
51660
  }
51698
- return translation;
51661
+ return result;
51699
51662
  }
51700
51663
  function getRichTextTranslation({
51701
51664
  item,
@@ -51707,26 +51670,11 @@ function getRichTextTranslation({
51707
51670
  }) {
51708
51671
  if (isWidth) {
51709
51672
  item.editor.setMaxWidth(item.getWidth() / item.transformation.getScale().x * matrix.scaleX);
51710
- return {
51711
- class: "Transformation",
51712
- method: "applyMatrix",
51713
- item: [item.getId()],
51714
- matrix: { translateX: matrix.translateX, translateY: 0, scaleX: matrix.scaleX, scaleY: matrix.scaleX, shearX: 0, shearY: 0 }
51715
- };
51673
+ return { id: item.getId(), matrix: { translateX: matrix.translateX, translateY: 0, scaleX: matrix.scaleX, scaleY: matrix.scaleX, shearX: 0, shearY: 0 } };
51716
51674
  } else if (isHeight) {
51717
- return {
51718
- class: "Transformation",
51719
- method: "applyMatrix",
51720
- item: [item.getId()],
51721
- matrix: { translateX, translateY, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 }
51722
- };
51675
+ return { id: item.getId(), matrix: { translateX, translateY, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 } };
51723
51676
  } else {
51724
- return {
51725
- class: "Transformation",
51726
- method: "applyMatrix",
51727
- item: [item.getId()],
51728
- matrix: { translateX, translateY, scaleX: matrix.scaleX, scaleY: matrix.scaleX, shearX: 0, shearY: 0 }
51729
- };
51677
+ return { id: item.getId(), matrix: { translateX, translateY, scaleX: matrix.scaleX, scaleY: matrix.scaleX, shearX: 0, shearY: 0 } };
51730
51678
  }
51731
51679
  }
51732
51680
  function getAINodeTranslation({
@@ -51739,26 +51687,11 @@ function getAINodeTranslation({
51739
51687
  }) {
51740
51688
  if (isWidth) {
51741
51689
  item.text.editor.setMaxWidth(item.text.getWidth() / item.transformation.getScale().x * matrix.scaleX);
51742
- return {
51743
- class: "Transformation",
51744
- method: "applyMatrix",
51745
- item: [item.getId()],
51746
- matrix: { translateX: matrix.translateX, translateY: 0, scaleX: matrix.scaleX, scaleY: matrix.scaleX, shearX: 0, shearY: 0 }
51747
- };
51690
+ return { id: item.getId(), matrix: { translateX: matrix.translateX, translateY: 0, scaleX: matrix.scaleX, scaleY: matrix.scaleX, shearX: 0, shearY: 0 } };
51748
51691
  } else if (isHeight) {
51749
- return {
51750
- class: "Transformation",
51751
- method: "applyMatrix",
51752
- item: [item.getId()],
51753
- matrix: { translateX, translateY, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 }
51754
- };
51692
+ return { id: item.getId(), matrix: { translateX, translateY, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 } };
51755
51693
  } else {
51756
- return {
51757
- class: "Transformation",
51758
- method: "applyMatrix",
51759
- item: [item.getId()],
51760
- matrix: { translateX, translateY, scaleX: matrix.scaleX, scaleY: matrix.scaleX, shearX: 0, shearY: 0 }
51761
- };
51694
+ return { id: item.getId(), matrix: { translateX, translateY, scaleX: matrix.scaleX, scaleY: matrix.scaleX, shearX: 0, shearY: 0 } };
51762
51695
  }
51763
51696
  }
51764
51697
  function getItemTranslation({
@@ -51771,22 +51704,12 @@ function getItemTranslation({
51771
51704
  isShiftPressed
51772
51705
  }) {
51773
51706
  if (item instanceof Sticker && (isWidth || isHeight)) {
51774
- return {
51775
- class: "Transformation",
51776
- method: "applyMatrix",
51777
- item: [item.getId()],
51778
- matrix: { translateX, translateY, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 }
51779
- };
51707
+ return { id: item.getId(), matrix: { translateX, translateY, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 } };
51780
51708
  } else {
51781
51709
  if (item instanceof Frame2 && item.getCanChangeRatio() && isShiftPressed && item.getFrameType() !== "Custom") {
51782
51710
  item.setFrameType("Custom");
51783
51711
  }
51784
- return {
51785
- class: "Transformation",
51786
- method: "applyMatrix",
51787
- item: [item.getId()],
51788
- matrix: { translateX, translateY, scaleX: matrix.scaleX, scaleY: matrix.scaleY, shearX: 0, shearY: 0 }
51789
- };
51712
+ return { id: item.getId(), matrix: { translateX, translateY, scaleX: matrix.scaleX, scaleY: matrix.scaleY, shearX: 0, shearY: 0 } };
51790
51713
  }
51791
51714
  }
51792
51715
 
@@ -53151,53 +53074,41 @@ class BoardSelection {
53151
53074
  this.shouldPublish = false;
53152
53075
  this.emit({
53153
53076
  class: "Transformation",
53154
- method: "transformMany",
53077
+ method: "applyMatrix",
53155
53078
  items,
53156
53079
  timeStamp
53157
53080
  });
53158
53081
  this.shouldPublish = true;
53159
53082
  }
53160
53083
  getManyItemsTranslation(x, y, unselectedItem) {
53161
- const translation = {};
53162
- function addItemToTranslation(itemId) {
53163
- translation[itemId] = {
53164
- class: "Transformation",
53165
- method: "applyMatrix",
53166
- item: [itemId],
53167
- matrix: { translateX: x, translateY: y, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 }
53168
- };
53169
- }
53170
- function tryToAddFrameChildrenToTranslation(selectedItem) {
53084
+ const items = [];
53085
+ const addItem = (itemId) => {
53086
+ items.push({ id: itemId, matrix: { translateX: x, translateY: y, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 } });
53087
+ };
53088
+ const tryToAddFrameChildren = (selectedItem) => {
53171
53089
  if (!("index" in selectedItem) || !selectedItem.index) {
53172
53090
  return;
53173
53091
  }
53174
53092
  for (const childId of selectedItem.getChildrenIds()) {
53175
- addItemToTranslation(childId);
53093
+ addItem(childId);
53176
53094
  }
53177
- }
53178
- const createTranslationWithComments = (item) => {
53095
+ };
53096
+ const addWithComments = (item) => {
53097
+ addItem(item.getId());
53098
+ tryToAddFrameChildren(item);
53179
53099
  const followedComments = this.board.items.getComments().filter((comment2) => comment2.getItemToFollow() === item.getId());
53180
53100
  for (const comment2 of followedComments) {
53181
- translation[comment2.getId()] = {
53182
- class: "Transformation",
53183
- method: "applyMatrix",
53184
- item: [comment2.getId()],
53185
- matrix: { translateX: x, translateY: y, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 }
53186
- };
53101
+ addItem(comment2.getId());
53187
53102
  }
53188
53103
  };
53189
53104
  if (unselectedItem) {
53190
- addItemToTranslation(unselectedItem.getId());
53191
- tryToAddFrameChildrenToTranslation(unselectedItem);
53192
- createTranslationWithComments(unselectedItem);
53193
- return translation;
53105
+ addWithComments(unselectedItem);
53106
+ return items;
53194
53107
  }
53195
53108
  for (const selectedItem of this.board.selection.list()) {
53196
- addItemToTranslation(selectedItem.getId());
53197
- tryToAddFrameChildrenToTranslation(selectedItem);
53198
- createTranslationWithComments(selectedItem);
53109
+ addWithComments(selectedItem);
53199
53110
  }
53200
- return translation;
53111
+ return items;
53201
53112
  }
53202
53113
  setStrokeStyle(borderStyle) {
53203
53114
  const shapes = this.items.getIdsByItemTypes(["Shape"]);
@@ -54740,32 +54651,40 @@ function mergeOperations(opA, opB) {
54740
54651
  return;
54741
54652
  }
54742
54653
  function mergeTransformationOperations(opA, opB) {
54743
- if (!areItemsTheSame(opA, opB)) {
54654
+ if (opA.timeStamp && opB.timeStamp && opA.timeStamp !== opB.timeStamp) {
54744
54655
  return;
54745
54656
  }
54746
- if (opA.timeStamp && opB.timeStamp && opA.timeStamp !== opB.timeStamp) {
54657
+ if (opA.method === "applyMatrix" && opB.method === "applyMatrix") {
54658
+ if (opA.items.length !== opB.items.length)
54659
+ return;
54660
+ const idsA = new Set(opA.items.map((i) => i.id));
54661
+ if (!opB.items.every((b) => idsA.has(b.id)))
54662
+ return;
54663
+ return {
54664
+ class: "Transformation",
54665
+ method: "applyMatrix",
54666
+ items: opB.items.map((b) => {
54667
+ const a2 = opA.items.find((i) => i.id === b.id);
54668
+ return {
54669
+ id: b.id,
54670
+ matrix: {
54671
+ translateX: a2.matrix.translateX + b.matrix.translateX,
54672
+ translateY: a2.matrix.translateY + b.matrix.translateY,
54673
+ scaleX: a2.matrix.scaleX * b.matrix.scaleX,
54674
+ scaleY: a2.matrix.scaleY * b.matrix.scaleY,
54675
+ shearX: 0,
54676
+ shearY: 0
54677
+ }
54678
+ };
54679
+ }),
54680
+ timeStamp: opB.timeStamp
54681
+ };
54682
+ }
54683
+ if (!areItemsTheSame(opA, opB)) {
54747
54684
  return;
54748
54685
  }
54749
54686
  const method = opA.method;
54750
54687
  switch (method) {
54751
- case "applyMatrix":
54752
- if (opB.method !== method) {
54753
- return;
54754
- }
54755
- return {
54756
- class: "Transformation",
54757
- method: "applyMatrix",
54758
- item: opA.item,
54759
- matrix: {
54760
- translateX: opA.matrix.translateX + opB.matrix.translateX,
54761
- translateY: opA.matrix.translateY + opB.matrix.translateY,
54762
- scaleX: opA.matrix.scaleX * opB.matrix.scaleX,
54763
- scaleY: opA.matrix.scaleY * opB.matrix.scaleY,
54764
- shearX: 0,
54765
- shearY: 0
54766
- },
54767
- timeStamp: opB.timeStamp
54768
- };
54769
54688
  case "translateBy":
54770
54689
  if (opB.method !== method) {
54771
54690
  return;
@@ -54819,130 +54738,10 @@ function mergeTransformationOperations(opA, opB) {
54819
54738
  },
54820
54739
  timeStamp: opB.timeStamp
54821
54740
  };
54822
- case "transformMany":
54823
- const items = mergeItems(opA, opB);
54824
- if (opB.method !== method) {
54825
- return;
54826
- }
54827
- return {
54828
- class: "Transformation",
54829
- method: "transformMany",
54830
- items,
54831
- timeStamp: opB.timeStamp
54832
- };
54833
54741
  default:
54834
54742
  return;
54835
54743
  }
54836
54744
  }
54837
- function mergeItems(opA, opB) {
54838
- if (opA.method === "transformMany" && opB.method === "transformMany") {
54839
- const resolve2 = (currScale, currTranslate, opB2) => {
54840
- switch (opB2.method) {
54841
- case "scaleByTranslateBy":
54842
- return {
54843
- scale: {
54844
- x: currScale ? currScale.x * opB2.scale.x : opB2.scale.x,
54845
- y: currScale ? currScale.y * opB2.scale.y : opB2.scale.y
54846
- },
54847
- translate: {
54848
- x: currTranslate ? currTranslate.x + opB2.translate.x : opB2.translate.x,
54849
- y: currTranslate ? currTranslate.y + opB2.translate.y : opB2.translate.y
54850
- }
54851
- };
54852
- case "scaleBy":
54853
- return {
54854
- scale: {
54855
- x: currScale ? currScale.x * opB2.x : opB2.x,
54856
- y: currScale ? currScale.y * opB2.y : opB2.y
54857
- },
54858
- translate: {
54859
- x: currTranslate ? currTranslate.x : 0,
54860
- y: currTranslate ? currTranslate.y : 0
54861
- }
54862
- };
54863
- case "translateBy":
54864
- return {
54865
- scale: {
54866
- x: currScale ? currScale.x : 1,
54867
- y: currScale ? currScale.y : 1
54868
- },
54869
- translate: {
54870
- x: currTranslate ? currTranslate.x + opB2.x : opB2.x,
54871
- y: currTranslate ? currTranslate.y + opB2.y : opB2.y
54872
- }
54873
- };
54874
- }
54875
- return;
54876
- };
54877
- const items = {};
54878
- Object.keys(opB.items).forEach((itemId) => {
54879
- if (opA.items[itemId] !== undefined) {
54880
- if (opA.items[itemId].method === "applyMatrix" && opB.items[itemId].method === "applyMatrix") {
54881
- const a2 = opA.items[itemId].matrix;
54882
- const b = opB.items[itemId].matrix;
54883
- items[itemId] = {
54884
- class: "Transformation",
54885
- method: "applyMatrix",
54886
- item: [itemId],
54887
- matrix: {
54888
- translateX: a2.translateX + b.translateX,
54889
- translateY: a2.translateY + b.translateY,
54890
- scaleX: a2.scaleX * b.scaleX,
54891
- scaleY: a2.scaleY * b.scaleY,
54892
- shearX: 0,
54893
- shearY: 0
54894
- }
54895
- };
54896
- } else if (opA.items[itemId].method === "scaleByTranslateBy") {
54897
- const newTransformation = resolve2(opA.items[itemId].scale, opA.items[itemId].translate, opB.items[itemId]);
54898
- if (!newTransformation) {
54899
- items[itemId] = opB.items[itemId];
54900
- } else {
54901
- items[itemId] = {
54902
- class: "Transformation",
54903
- method: "scaleByTranslateBy",
54904
- item: [itemId],
54905
- scale: newTransformation.scale,
54906
- translate: newTransformation.translate
54907
- };
54908
- }
54909
- } else if (opA.items[itemId].method === "scaleBy") {
54910
- const newTransformation = resolve2({ x: opA.items[itemId].x, y: opA.items[itemId].y }, undefined, opB.items[itemId]);
54911
- if (!newTransformation) {
54912
- items[itemId] = opB.items[itemId];
54913
- } else {
54914
- items[itemId] = {
54915
- class: "Transformation",
54916
- method: "scaleByTranslateBy",
54917
- item: [itemId],
54918
- scale: newTransformation.scale,
54919
- translate: newTransformation.translate
54920
- };
54921
- }
54922
- } else if (opA.items[itemId].method === "translateBy") {
54923
- const newTransformation = resolve2(undefined, { x: opA.items[itemId].x, y: opA.items[itemId].y }, opB.items[itemId]);
54924
- if (!newTransformation) {
54925
- items[itemId] = opB.items[itemId];
54926
- } else {
54927
- items[itemId] = {
54928
- class: "Transformation",
54929
- method: "scaleByTranslateBy",
54930
- item: [itemId],
54931
- scale: newTransformation.scale,
54932
- translate: newTransformation.translate
54933
- };
54934
- }
54935
- } else {
54936
- items[itemId] = opB.items[itemId];
54937
- }
54938
- } else {
54939
- items[itemId] = opB.items[itemId];
54940
- }
54941
- });
54942
- return items;
54943
- }
54944
- return;
54945
- }
54946
54745
  function mergeRichTextOperations(opA, opB) {
54947
54746
  if (!areItemsTheSame(opA, opB)) {
54948
54747
  return;