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.
@@ -7138,17 +7138,29 @@ class TransformationCommand {
7138
7138
  switch (this.operation.method) {
7139
7139
  case "applyMatrix": {
7140
7140
  const op2 = this.operation;
7141
- return mapItemsByOperation(this.transformation, () => ({
7142
- ...op2,
7143
- matrix: {
7144
- translateX: -op2.matrix.translateX,
7145
- translateY: -op2.matrix.translateY,
7146
- scaleX: 1 / op2.matrix.scaleX,
7147
- scaleY: 1 / op2.matrix.scaleY,
7148
- shearX: 0,
7149
- shearY: 0
7150
- }
7151
- }));
7141
+ return this.transformation.map((t3) => {
7142
+ const itemOp = op2.items.find((i) => i.id === t3.getId());
7143
+ if (!itemOp)
7144
+ return { item: t3, operation: op2 };
7145
+ return {
7146
+ item: t3,
7147
+ operation: {
7148
+ class: "Transformation",
7149
+ method: "applyMatrix",
7150
+ items: [{
7151
+ id: t3.getId(),
7152
+ matrix: {
7153
+ translateX: -itemOp.matrix.translateX,
7154
+ translateY: -itemOp.matrix.translateY,
7155
+ scaleX: 1 / itemOp.matrix.scaleX,
7156
+ scaleY: 1 / itemOp.matrix.scaleY,
7157
+ shearX: 0,
7158
+ shearY: 0
7159
+ }
7160
+ }]
7161
+ }
7162
+ };
7163
+ });
7152
7164
  }
7153
7165
  case "translateTo":
7154
7166
  return mapItemsByOperation(this.transformation, (transformation) => {
@@ -7230,60 +7242,25 @@ class TransformationCommand {
7230
7242
  const { operation, transformation } = this;
7231
7243
  return transformation.map((currTrans) => {
7232
7244
  const op2 = operation.items[currTrans.getId()];
7233
- let reverseOp;
7234
- if (op2.method === "applyMatrix") {
7235
- reverseOp = {
7236
- ...op2,
7237
- matrix: {
7238
- translateX: -op2.matrix.translateX,
7239
- translateY: -op2.matrix.translateY,
7240
- scaleX: 1 / op2.matrix.scaleX,
7241
- scaleY: 1 / op2.matrix.scaleY,
7242
- shearX: 0,
7243
- shearY: 0
7244
- }
7245
- };
7246
- } else if (op2.method === "scaleByTranslateBy") {
7247
- reverseOp = {
7248
- ...op2,
7249
- scale: { x: 1 / op2.scale.x, y: 1 / op2.scale.y },
7250
- translate: {
7251
- x: -op2.translate.x,
7252
- y: -op2.translate.y
7253
- }
7254
- };
7255
- } else if (op2.method === "translateTo") {
7256
- reverseOp = {
7257
- ...op2,
7258
- x: currTrans.getTranslation().x,
7259
- y: currTrans.getTranslation().y
7260
- };
7261
- } else if (op2.method === "translateBy") {
7262
- reverseOp = {
7263
- ...op2,
7264
- x: -op2.x,
7265
- y: -op2.y
7266
- };
7267
- } else if (op2.method === "scaleTo") {
7268
- reverseOp = {
7269
- ...op2,
7270
- x: currTrans.getScale().x,
7271
- y: currTrans.getScale().y
7272
- };
7273
- } else if (op2.method === "scaleBy") {
7274
- reverseOp = {
7275
- ...op2,
7276
- x: 1 / op2.x,
7277
- y: 1 / op2.y
7278
- };
7279
- } else {
7280
- reverseOp = {
7281
- ...op2,
7282
- x: 1,
7283
- y: 1
7284
- };
7285
- }
7286
- return { item: currTrans, operation: reverseOp };
7245
+ 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 };
7246
+ return {
7247
+ item: currTrans,
7248
+ operation: {
7249
+ class: "Transformation",
7250
+ method: "applyMatrix",
7251
+ items: [{
7252
+ id: currTrans.getId(),
7253
+ matrix: {
7254
+ translateX: op2.method === "applyMatrix" ? -m.translateX : m.translateX,
7255
+ translateY: op2.method === "applyMatrix" ? -m.translateY : m.translateY,
7256
+ scaleX: op2.method === "applyMatrix" ? 1 / m.scaleX : m.scaleX,
7257
+ scaleY: op2.method === "applyMatrix" ? 1 / m.scaleY : m.scaleY,
7258
+ shearX: 0,
7259
+ shearY: 0
7260
+ }
7261
+ }]
7262
+ }
7263
+ };
7287
7264
  });
7288
7265
  }
7289
7266
  case "locked": {
@@ -7414,10 +7391,14 @@ class Transformation {
7414
7391
  apply(op) {
7415
7392
  this.previous = this.matrix.copy();
7416
7393
  switch (op.method) {
7417
- case "applyMatrix":
7418
- this.matrix.scale(op.matrix.scaleX, op.matrix.scaleY);
7419
- this.matrix.translate(op.matrix.translateX, op.matrix.translateY);
7394
+ case "applyMatrix": {
7395
+ const itemOp = op.items.find((i) => i.id === this.id);
7396
+ if (itemOp) {
7397
+ this.matrix.scale(itemOp.matrix.scaleX, itemOp.matrix.scaleY);
7398
+ this.matrix.translate(itemOp.matrix.translateX, itemOp.matrix.translateY);
7399
+ }
7420
7400
  break;
7401
+ }
7421
7402
  case "translateTo":
7422
7403
  this.applyTranslateTo(op.x, op.y);
7423
7404
  break;
@@ -7552,8 +7533,7 @@ class Transformation {
7552
7533
  this.emit({
7553
7534
  class: "Transformation",
7554
7535
  method: "applyMatrix",
7555
- item: [this.id],
7556
- matrix,
7536
+ items: [{ id: this.id, matrix }],
7557
7537
  timeStamp
7558
7538
  });
7559
7539
  }
@@ -19548,7 +19528,7 @@ function createCommand(board, operation) {
19548
19528
  }
19549
19529
  default: {
19550
19530
  const itemType = operation.class;
19551
- 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);
19531
+ 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);
19552
19532
  const items = itemIdList.map((itemId) => board.items.findById(itemId) ?? itemId).filter((item) => {
19553
19533
  if (typeof item === "string") {
19554
19534
  console.warn(`Item with ID ${item} not found for operation ${operation.class}.${operation.method}`);
@@ -21790,7 +21770,8 @@ class RichText extends BaseItem {
21790
21770
  this.transformation.subject.subscribe((tr, op) => {
21791
21771
  this.prevMbr = this.getMbr();
21792
21772
  if (op.method === "applyMatrix") {
21793
- if (op.matrix.scaleX !== 1 || op.matrix.scaleY !== 1) {
21773
+ const itemOp = op.items.find((i) => i.id === this.id);
21774
+ if (itemOp && (itemOp.matrix.scaleX !== 1 || itemOp.matrix.scaleY !== 1)) {
21794
21775
  this.setAINodeShirkWidth();
21795
21776
  if (!this.isInShape) {
21796
21777
  this.transformCanvas();
@@ -21800,8 +21781,6 @@ class RichText extends BaseItem {
21800
21781
  } else {
21801
21782
  this.transformCanvas();
21802
21783
  }
21803
- } else if (op.method === "transformMany") {
21804
- this.transformCanvas();
21805
21784
  } else if (op.method === "deserialize") {
21806
21785
  this.setAINodeShirkWidth();
21807
21786
  this.updateElement();
@@ -35744,19 +35723,15 @@ class AINode extends BaseItem {
35744
35723
  this.text = new RichText(this.board, new Mbr, this.id, this.transformation, this.linkTo, " ", false, false, "AINode");
35745
35724
  this.transformation.subject.subscribe((_subject, op) => {
35746
35725
  if (op.method === "applyMatrix") {
35747
- if (op.matrix.scaleX !== 1 || op.matrix.scaleY !== 1) {
35726
+ const itemOp = op.items.find((i) => i.id === this.getId());
35727
+ if (itemOp && (itemOp.matrix.scaleX !== 1 || itemOp.matrix.scaleY !== 1)) {
35748
35728
  this.prevMbr = this.path?.getMbr();
35749
35729
  this.text.handleInshapeScale();
35750
- } else {
35751
- this.text.transformCanvas();
35752
- }
35753
- } else if (op.method === "transformMany") {
35754
- const currItemOp = op.items[this.getId()];
35755
- this.prevMbr = this.path?.getMbr();
35756
- if (currItemOp.method === "applyMatrix" && currItemOp.matrix.scaleX === 1 && currItemOp.matrix.scaleY === 1) {
35730
+ } else if (itemOp) {
35757
35731
  this.text.transformCanvas();
35758
35732
  } else {
35759
- this.text.handleInshapeScale();
35733
+ this.prevMbr = this.path?.getMbr();
35734
+ this.text.updateElement();
35760
35735
  }
35761
35736
  } else {
35762
35737
  this.prevMbr = this.path?.getMbr();
@@ -36968,13 +36943,9 @@ class Connector2 extends BaseItem {
36968
36943
  this.endPointer = getEndPointer(this.endPoint, this.endPointerStyle, this.lineStyle, this.lines, this.lineWidth * 0.1 + 0.3);
36969
36944
  this.middlePoint = null;
36970
36945
  this.transformation.subject.subscribe((_sub, op) => {
36971
- if (op.method === "transformMany") {
36972
- const operation = op.items[this.getId()];
36973
- if (operation.method === "applyMatrix") {
36974
- if (operation.matrix.scaleX !== 1 || operation.matrix.scaleY !== 1) {
36975
- this.scalePoints();
36976
- }
36977
- } else if (operation.method === "scaleByTranslateBy" && (operation.scale.x !== 1 || operation.scale.y !== 1)) {
36946
+ if (op.method === "applyMatrix") {
36947
+ const itemOp = op.items.find((i) => i.id === this.getId());
36948
+ if (itemOp && (itemOp.matrix.scaleX !== 1 || itemOp.matrix.scaleY !== 1)) {
36978
36949
  this.scalePoints();
36979
36950
  }
36980
36951
  }
@@ -39265,8 +39236,13 @@ class Shape extends BaseItem {
39265
39236
  this.transformation.subject.subscribe((_subject, op) => {
39266
39237
  this.transformPath();
39267
39238
  this.updateMbr();
39268
- if (op.method === "applyMatrix" && op.matrix.scaleX === 1 && op.matrix.scaleY === 1) {
39269
- this.text.transformCanvas();
39239
+ if (op.method === "applyMatrix") {
39240
+ const itemOp = op.items.find((i) => i.id === this.id);
39241
+ if (itemOp && itemOp.matrix.scaleX === 1 && itemOp.matrix.scaleY === 1) {
39242
+ this.text.transformCanvas();
39243
+ } else {
39244
+ this.text.updateElement();
39245
+ }
39270
39246
  } else {
39271
39247
  this.text.updateElement();
39272
39248
  }
@@ -39793,20 +39769,14 @@ class Sticker extends BaseItem {
39793
39769
  this.transformation.subject.subscribe((_subject, op) => {
39794
39770
  this.transformPath();
39795
39771
  if (op.method === "applyMatrix") {
39796
- if (op.matrix.scaleX !== 1 || op.matrix.scaleY !== 1) {
39797
- if (this.text.isAutosize()) {
39798
- this.text.scaleAutoSizeScale(Math.min(op.matrix.scaleX, op.matrix.scaleY));
39799
- this.text.recoordinate();
39800
- this.text.transformCanvas();
39801
- } else {
39802
- this.text.handleInshapeScale();
39803
- }
39804
- }
39805
- } else if (op.method === "transformMany") {
39806
- const transformOp = op.items[this.id];
39807
- if (transformOp.method === "applyMatrix" && (transformOp.matrix.scaleX !== 1 || transformOp.matrix.scaleY !== 1)) {
39772
+ const itemOp = op.items.find((i) => i.id === this.id);
39773
+ if (itemOp && (itemOp.matrix.scaleX !== 1 || itemOp.matrix.scaleY !== 1)) {
39808
39774
  if (this.text.isAutosize()) {
39809
- this.text.scaleAutoSizeScale(Math.min(transformOp.matrix.scaleX, transformOp.matrix.scaleY));
39775
+ if (itemOp.matrix.scaleX !== itemOp.matrix.scaleY) {
39776
+ this.text.applyAutoSizeScale(this.text.calcAutoSize());
39777
+ } else {
39778
+ this.text.scaleAutoSizeScale(itemOp.matrix.scaleX);
39779
+ }
39810
39780
  this.text.recoordinate();
39811
39781
  this.text.transformCanvas();
39812
39782
  } else {
@@ -46043,14 +46013,7 @@ class AlignmentHelper {
46043
46013
  this.board.selection.transformMany(translation, timeStamp);
46044
46014
  } else {
46045
46015
  const id = item.getId();
46046
- const transformMap = {};
46047
- transformMap[id] = {
46048
- class: "Transformation",
46049
- item: [id],
46050
- method: "applyMatrix",
46051
- matrix: { translateX: x, translateY: y, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 }
46052
- };
46053
- this.board.selection.transformMany(transformMap, timeStamp);
46016
+ this.board.selection.transformMany([{ id, matrix: { translateX: x, translateY: y, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 } }], timeStamp);
46054
46017
  }
46055
46018
  }
46056
46019
  translateCanvas(x, y, timeStamp) {
@@ -47899,7 +47862,7 @@ class Card extends BaseItem {
47899
47862
  this.board.bringToFront(this);
47900
47863
  }, 1000);
47901
47864
  this.transformation.subject.subscribe((_, op) => {
47902
- if (this.parent === "Board" && op.method === "applyMatrix" && op.matrix.scaleX === 1 && op.matrix.scaleY === 1) {
47865
+ 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) {
47903
47866
  this.throttledBringToFront();
47904
47867
  }
47905
47868
  this.updateMbr();
@@ -51654,7 +51617,7 @@ function handleMultipleItemsResize({
51654
51617
  isShiftPressed
51655
51618
  }) {
51656
51619
  const { matrix } = resize;
51657
- const translation = {};
51620
+ const result = [];
51658
51621
  const items = itemsToResize ? itemsToResize : board.selection.items.list();
51659
51622
  board.items.getComments().forEach((comment2) => {
51660
51623
  if (items.some((item) => item.getId() === comment2.getItemToFollow())) {
@@ -51673,25 +51636,25 @@ function handleMultipleItemsResize({
51673
51636
  const deltaY = itemY - initMbr.top;
51674
51637
  const translateY = deltaY * matrix.scaleY - deltaY + matrix.translateY;
51675
51638
  if (item instanceof RichText) {
51676
- translation[item.getId()] = getRichTextTranslation({
51639
+ result.push(getRichTextTranslation({
51677
51640
  item,
51678
51641
  isWidth,
51679
51642
  isHeight,
51680
51643
  matrix,
51681
51644
  translateX,
51682
51645
  translateY
51683
- });
51646
+ }));
51684
51647
  } else if (item instanceof AINode) {
51685
- translation[item.getId()] = getAINodeTranslation({
51648
+ result.push(getAINodeTranslation({
51686
51649
  item,
51687
51650
  isWidth,
51688
51651
  isHeight,
51689
51652
  matrix,
51690
51653
  translateX,
51691
51654
  translateY
51692
- });
51655
+ }));
51693
51656
  } else {
51694
- translation[item.getId()] = getItemTranslation({
51657
+ result.push(getItemTranslation({
51695
51658
  item,
51696
51659
  isWidth,
51697
51660
  isHeight,
@@ -51699,10 +51662,10 @@ function handleMultipleItemsResize({
51699
51662
  translateX,
51700
51663
  translateY,
51701
51664
  isShiftPressed
51702
- });
51665
+ }));
51703
51666
  }
51704
51667
  }
51705
- return translation;
51668
+ return result;
51706
51669
  }
51707
51670
  function getRichTextTranslation({
51708
51671
  item,
@@ -51714,26 +51677,11 @@ function getRichTextTranslation({
51714
51677
  }) {
51715
51678
  if (isWidth) {
51716
51679
  item.editor.setMaxWidth(item.getWidth() / item.transformation.getScale().x * matrix.scaleX);
51717
- return {
51718
- class: "Transformation",
51719
- method: "applyMatrix",
51720
- item: [item.getId()],
51721
- matrix: { translateX: matrix.translateX, translateY: 0, scaleX: matrix.scaleX, scaleY: matrix.scaleX, shearX: 0, shearY: 0 }
51722
- };
51680
+ return { id: item.getId(), matrix: { translateX: matrix.translateX, translateY: 0, scaleX: matrix.scaleX, scaleY: matrix.scaleX, shearX: 0, shearY: 0 } };
51723
51681
  } else if (isHeight) {
51724
- return {
51725
- class: "Transformation",
51726
- method: "applyMatrix",
51727
- item: [item.getId()],
51728
- matrix: { translateX, translateY, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 }
51729
- };
51682
+ return { id: item.getId(), matrix: { translateX, translateY, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 } };
51730
51683
  } else {
51731
- return {
51732
- class: "Transformation",
51733
- method: "applyMatrix",
51734
- item: [item.getId()],
51735
- matrix: { translateX, translateY, scaleX: matrix.scaleX, scaleY: matrix.scaleX, shearX: 0, shearY: 0 }
51736
- };
51684
+ return { id: item.getId(), matrix: { translateX, translateY, scaleX: matrix.scaleX, scaleY: matrix.scaleX, shearX: 0, shearY: 0 } };
51737
51685
  }
51738
51686
  }
51739
51687
  function getAINodeTranslation({
@@ -51746,26 +51694,11 @@ function getAINodeTranslation({
51746
51694
  }) {
51747
51695
  if (isWidth) {
51748
51696
  item.text.editor.setMaxWidth(item.text.getWidth() / item.transformation.getScale().x * matrix.scaleX);
51749
- return {
51750
- class: "Transformation",
51751
- method: "applyMatrix",
51752
- item: [item.getId()],
51753
- matrix: { translateX: matrix.translateX, translateY: 0, scaleX: matrix.scaleX, scaleY: matrix.scaleX, shearX: 0, shearY: 0 }
51754
- };
51697
+ return { id: item.getId(), matrix: { translateX: matrix.translateX, translateY: 0, scaleX: matrix.scaleX, scaleY: matrix.scaleX, shearX: 0, shearY: 0 } };
51755
51698
  } else if (isHeight) {
51756
- return {
51757
- class: "Transformation",
51758
- method: "applyMatrix",
51759
- item: [item.getId()],
51760
- matrix: { translateX, translateY, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 }
51761
- };
51699
+ return { id: item.getId(), matrix: { translateX, translateY, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 } };
51762
51700
  } else {
51763
- return {
51764
- class: "Transformation",
51765
- method: "applyMatrix",
51766
- item: [item.getId()],
51767
- matrix: { translateX, translateY, scaleX: matrix.scaleX, scaleY: matrix.scaleX, shearX: 0, shearY: 0 }
51768
- };
51701
+ return { id: item.getId(), matrix: { translateX, translateY, scaleX: matrix.scaleX, scaleY: matrix.scaleX, shearX: 0, shearY: 0 } };
51769
51702
  }
51770
51703
  }
51771
51704
  function getItemTranslation({
@@ -51778,22 +51711,12 @@ function getItemTranslation({
51778
51711
  isShiftPressed
51779
51712
  }) {
51780
51713
  if (item instanceof Sticker && (isWidth || isHeight)) {
51781
- return {
51782
- class: "Transformation",
51783
- method: "applyMatrix",
51784
- item: [item.getId()],
51785
- matrix: { translateX, translateY, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 }
51786
- };
51714
+ return { id: item.getId(), matrix: { translateX, translateY, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 } };
51787
51715
  } else {
51788
51716
  if (item instanceof Frame2 && item.getCanChangeRatio() && isShiftPressed && item.getFrameType() !== "Custom") {
51789
51717
  item.setFrameType("Custom");
51790
51718
  }
51791
- return {
51792
- class: "Transformation",
51793
- method: "applyMatrix",
51794
- item: [item.getId()],
51795
- matrix: { translateX, translateY, scaleX: matrix.scaleX, scaleY: matrix.scaleY, shearX: 0, shearY: 0 }
51796
- };
51719
+ return { id: item.getId(), matrix: { translateX, translateY, scaleX: matrix.scaleX, scaleY: matrix.scaleY, shearX: 0, shearY: 0 } };
51797
51720
  }
51798
51721
  }
51799
51722
 
@@ -53158,53 +53081,41 @@ class BoardSelection {
53158
53081
  this.shouldPublish = false;
53159
53082
  this.emit({
53160
53083
  class: "Transformation",
53161
- method: "transformMany",
53084
+ method: "applyMatrix",
53162
53085
  items,
53163
53086
  timeStamp
53164
53087
  });
53165
53088
  this.shouldPublish = true;
53166
53089
  }
53167
53090
  getManyItemsTranslation(x, y, unselectedItem) {
53168
- const translation = {};
53169
- function addItemToTranslation(itemId) {
53170
- translation[itemId] = {
53171
- class: "Transformation",
53172
- method: "applyMatrix",
53173
- item: [itemId],
53174
- matrix: { translateX: x, translateY: y, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 }
53175
- };
53176
- }
53177
- function tryToAddFrameChildrenToTranslation(selectedItem) {
53091
+ const items = [];
53092
+ const addItem = (itemId) => {
53093
+ items.push({ id: itemId, matrix: { translateX: x, translateY: y, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 } });
53094
+ };
53095
+ const tryToAddFrameChildren = (selectedItem) => {
53178
53096
  if (!("index" in selectedItem) || !selectedItem.index) {
53179
53097
  return;
53180
53098
  }
53181
53099
  for (const childId of selectedItem.getChildrenIds()) {
53182
- addItemToTranslation(childId);
53100
+ addItem(childId);
53183
53101
  }
53184
- }
53185
- const createTranslationWithComments = (item) => {
53102
+ };
53103
+ const addWithComments = (item) => {
53104
+ addItem(item.getId());
53105
+ tryToAddFrameChildren(item);
53186
53106
  const followedComments = this.board.items.getComments().filter((comment2) => comment2.getItemToFollow() === item.getId());
53187
53107
  for (const comment2 of followedComments) {
53188
- translation[comment2.getId()] = {
53189
- class: "Transformation",
53190
- method: "applyMatrix",
53191
- item: [comment2.getId()],
53192
- matrix: { translateX: x, translateY: y, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 }
53193
- };
53108
+ addItem(comment2.getId());
53194
53109
  }
53195
53110
  };
53196
53111
  if (unselectedItem) {
53197
- addItemToTranslation(unselectedItem.getId());
53198
- tryToAddFrameChildrenToTranslation(unselectedItem);
53199
- createTranslationWithComments(unselectedItem);
53200
- return translation;
53112
+ addWithComments(unselectedItem);
53113
+ return items;
53201
53114
  }
53202
53115
  for (const selectedItem of this.board.selection.list()) {
53203
- addItemToTranslation(selectedItem.getId());
53204
- tryToAddFrameChildrenToTranslation(selectedItem);
53205
- createTranslationWithComments(selectedItem);
53116
+ addWithComments(selectedItem);
53206
53117
  }
53207
- return translation;
53118
+ return items;
53208
53119
  }
53209
53120
  setStrokeStyle(borderStyle) {
53210
53121
  const shapes = this.items.getIdsByItemTypes(["Shape"]);
@@ -54747,32 +54658,40 @@ function mergeOperations(opA, opB) {
54747
54658
  return;
54748
54659
  }
54749
54660
  function mergeTransformationOperations(opA, opB) {
54750
- if (!areItemsTheSame(opA, opB)) {
54661
+ if (opA.timeStamp && opB.timeStamp && opA.timeStamp !== opB.timeStamp) {
54751
54662
  return;
54752
54663
  }
54753
- if (opA.timeStamp && opB.timeStamp && opA.timeStamp !== opB.timeStamp) {
54664
+ if (opA.method === "applyMatrix" && opB.method === "applyMatrix") {
54665
+ if (opA.items.length !== opB.items.length)
54666
+ return;
54667
+ const idsA = new Set(opA.items.map((i) => i.id));
54668
+ if (!opB.items.every((b) => idsA.has(b.id)))
54669
+ return;
54670
+ return {
54671
+ class: "Transformation",
54672
+ method: "applyMatrix",
54673
+ items: opB.items.map((b) => {
54674
+ const a2 = opA.items.find((i) => i.id === b.id);
54675
+ return {
54676
+ id: b.id,
54677
+ matrix: {
54678
+ translateX: a2.matrix.translateX + b.matrix.translateX,
54679
+ translateY: a2.matrix.translateY + b.matrix.translateY,
54680
+ scaleX: a2.matrix.scaleX * b.matrix.scaleX,
54681
+ scaleY: a2.matrix.scaleY * b.matrix.scaleY,
54682
+ shearX: 0,
54683
+ shearY: 0
54684
+ }
54685
+ };
54686
+ }),
54687
+ timeStamp: opB.timeStamp
54688
+ };
54689
+ }
54690
+ if (!areItemsTheSame(opA, opB)) {
54754
54691
  return;
54755
54692
  }
54756
54693
  const method = opA.method;
54757
54694
  switch (method) {
54758
- case "applyMatrix":
54759
- if (opB.method !== method) {
54760
- return;
54761
- }
54762
- return {
54763
- class: "Transformation",
54764
- method: "applyMatrix",
54765
- item: opA.item,
54766
- matrix: {
54767
- translateX: opA.matrix.translateX + opB.matrix.translateX,
54768
- translateY: opA.matrix.translateY + opB.matrix.translateY,
54769
- scaleX: opA.matrix.scaleX * opB.matrix.scaleX,
54770
- scaleY: opA.matrix.scaleY * opB.matrix.scaleY,
54771
- shearX: 0,
54772
- shearY: 0
54773
- },
54774
- timeStamp: opB.timeStamp
54775
- };
54776
54695
  case "translateBy":
54777
54696
  if (opB.method !== method) {
54778
54697
  return;
@@ -54826,130 +54745,10 @@ function mergeTransformationOperations(opA, opB) {
54826
54745
  },
54827
54746
  timeStamp: opB.timeStamp
54828
54747
  };
54829
- case "transformMany":
54830
- const items = mergeItems(opA, opB);
54831
- if (opB.method !== method) {
54832
- return;
54833
- }
54834
- return {
54835
- class: "Transformation",
54836
- method: "transformMany",
54837
- items,
54838
- timeStamp: opB.timeStamp
54839
- };
54840
54748
  default:
54841
54749
  return;
54842
54750
  }
54843
54751
  }
54844
- function mergeItems(opA, opB) {
54845
- if (opA.method === "transformMany" && opB.method === "transformMany") {
54846
- const resolve2 = (currScale, currTranslate, opB2) => {
54847
- switch (opB2.method) {
54848
- case "scaleByTranslateBy":
54849
- return {
54850
- scale: {
54851
- x: currScale ? currScale.x * opB2.scale.x : opB2.scale.x,
54852
- y: currScale ? currScale.y * opB2.scale.y : opB2.scale.y
54853
- },
54854
- translate: {
54855
- x: currTranslate ? currTranslate.x + opB2.translate.x : opB2.translate.x,
54856
- y: currTranslate ? currTranslate.y + opB2.translate.y : opB2.translate.y
54857
- }
54858
- };
54859
- case "scaleBy":
54860
- return {
54861
- scale: {
54862
- x: currScale ? currScale.x * opB2.x : opB2.x,
54863
- y: currScale ? currScale.y * opB2.y : opB2.y
54864
- },
54865
- translate: {
54866
- x: currTranslate ? currTranslate.x : 0,
54867
- y: currTranslate ? currTranslate.y : 0
54868
- }
54869
- };
54870
- case "translateBy":
54871
- return {
54872
- scale: {
54873
- x: currScale ? currScale.x : 1,
54874
- y: currScale ? currScale.y : 1
54875
- },
54876
- translate: {
54877
- x: currTranslate ? currTranslate.x + opB2.x : opB2.x,
54878
- y: currTranslate ? currTranslate.y + opB2.y : opB2.y
54879
- }
54880
- };
54881
- }
54882
- return;
54883
- };
54884
- const items = {};
54885
- Object.keys(opB.items).forEach((itemId) => {
54886
- if (opA.items[itemId] !== undefined) {
54887
- if (opA.items[itemId].method === "applyMatrix" && opB.items[itemId].method === "applyMatrix") {
54888
- const a2 = opA.items[itemId].matrix;
54889
- const b = opB.items[itemId].matrix;
54890
- items[itemId] = {
54891
- class: "Transformation",
54892
- method: "applyMatrix",
54893
- item: [itemId],
54894
- matrix: {
54895
- translateX: a2.translateX + b.translateX,
54896
- translateY: a2.translateY + b.translateY,
54897
- scaleX: a2.scaleX * b.scaleX,
54898
- scaleY: a2.scaleY * b.scaleY,
54899
- shearX: 0,
54900
- shearY: 0
54901
- }
54902
- };
54903
- } else if (opA.items[itemId].method === "scaleByTranslateBy") {
54904
- const newTransformation = resolve2(opA.items[itemId].scale, opA.items[itemId].translate, opB.items[itemId]);
54905
- if (!newTransformation) {
54906
- items[itemId] = opB.items[itemId];
54907
- } else {
54908
- items[itemId] = {
54909
- class: "Transformation",
54910
- method: "scaleByTranslateBy",
54911
- item: [itemId],
54912
- scale: newTransformation.scale,
54913
- translate: newTransformation.translate
54914
- };
54915
- }
54916
- } else if (opA.items[itemId].method === "scaleBy") {
54917
- const newTransformation = resolve2({ x: opA.items[itemId].x, y: opA.items[itemId].y }, undefined, opB.items[itemId]);
54918
- if (!newTransformation) {
54919
- items[itemId] = opB.items[itemId];
54920
- } else {
54921
- items[itemId] = {
54922
- class: "Transformation",
54923
- method: "scaleByTranslateBy",
54924
- item: [itemId],
54925
- scale: newTransformation.scale,
54926
- translate: newTransformation.translate
54927
- };
54928
- }
54929
- } else if (opA.items[itemId].method === "translateBy") {
54930
- const newTransformation = resolve2(undefined, { x: opA.items[itemId].x, y: opA.items[itemId].y }, opB.items[itemId]);
54931
- if (!newTransformation) {
54932
- items[itemId] = opB.items[itemId];
54933
- } else {
54934
- items[itemId] = {
54935
- class: "Transformation",
54936
- method: "scaleByTranslateBy",
54937
- item: [itemId],
54938
- scale: newTransformation.scale,
54939
- translate: newTransformation.translate
54940
- };
54941
- }
54942
- } else {
54943
- items[itemId] = opB.items[itemId];
54944
- }
54945
- } else {
54946
- items[itemId] = opB.items[itemId];
54947
- }
54948
- });
54949
- return items;
54950
- }
54951
- return;
54952
- }
54953
54752
  function mergeRichTextOperations(opA, opB) {
54954
54753
  if (!areItemsTheSame(opA, opB)) {
54955
54754
  return;