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/node.js CHANGED
@@ -7915,17 +7915,29 @@ class TransformationCommand {
7915
7915
  switch (this.operation.method) {
7916
7916
  case "applyMatrix": {
7917
7917
  const op2 = this.operation;
7918
- return mapItemsByOperation(this.transformation, () => ({
7919
- ...op2,
7920
- matrix: {
7921
- translateX: -op2.matrix.translateX,
7922
- translateY: -op2.matrix.translateY,
7923
- scaleX: 1 / op2.matrix.scaleX,
7924
- scaleY: 1 / op2.matrix.scaleY,
7925
- shearX: 0,
7926
- shearY: 0
7927
- }
7928
- }));
7918
+ return this.transformation.map((t3) => {
7919
+ const itemOp = op2.items.find((i) => i.id === t3.getId());
7920
+ if (!itemOp)
7921
+ return { item: t3, operation: op2 };
7922
+ return {
7923
+ item: t3,
7924
+ operation: {
7925
+ class: "Transformation",
7926
+ method: "applyMatrix",
7927
+ items: [{
7928
+ id: t3.getId(),
7929
+ matrix: {
7930
+ translateX: -itemOp.matrix.translateX,
7931
+ translateY: -itemOp.matrix.translateY,
7932
+ scaleX: 1 / itemOp.matrix.scaleX,
7933
+ scaleY: 1 / itemOp.matrix.scaleY,
7934
+ shearX: 0,
7935
+ shearY: 0
7936
+ }
7937
+ }]
7938
+ }
7939
+ };
7940
+ });
7929
7941
  }
7930
7942
  case "translateTo":
7931
7943
  return mapItemsByOperation(this.transformation, (transformation) => {
@@ -8007,60 +8019,25 @@ class TransformationCommand {
8007
8019
  const { operation, transformation } = this;
8008
8020
  return transformation.map((currTrans) => {
8009
8021
  const op2 = operation.items[currTrans.getId()];
8010
- let reverseOp;
8011
- if (op2.method === "applyMatrix") {
8012
- reverseOp = {
8013
- ...op2,
8014
- matrix: {
8015
- translateX: -op2.matrix.translateX,
8016
- translateY: -op2.matrix.translateY,
8017
- scaleX: 1 / op2.matrix.scaleX,
8018
- scaleY: 1 / op2.matrix.scaleY,
8019
- shearX: 0,
8020
- shearY: 0
8021
- }
8022
- };
8023
- } else if (op2.method === "scaleByTranslateBy") {
8024
- reverseOp = {
8025
- ...op2,
8026
- scale: { x: 1 / op2.scale.x, y: 1 / op2.scale.y },
8027
- translate: {
8028
- x: -op2.translate.x,
8029
- y: -op2.translate.y
8030
- }
8031
- };
8032
- } else if (op2.method === "translateTo") {
8033
- reverseOp = {
8034
- ...op2,
8035
- x: currTrans.getTranslation().x,
8036
- y: currTrans.getTranslation().y
8037
- };
8038
- } else if (op2.method === "translateBy") {
8039
- reverseOp = {
8040
- ...op2,
8041
- x: -op2.x,
8042
- y: -op2.y
8043
- };
8044
- } else if (op2.method === "scaleTo") {
8045
- reverseOp = {
8046
- ...op2,
8047
- x: currTrans.getScale().x,
8048
- y: currTrans.getScale().y
8049
- };
8050
- } else if (op2.method === "scaleBy") {
8051
- reverseOp = {
8052
- ...op2,
8053
- x: 1 / op2.x,
8054
- y: 1 / op2.y
8055
- };
8056
- } else {
8057
- reverseOp = {
8058
- ...op2,
8059
- x: 1,
8060
- y: 1
8061
- };
8062
- }
8063
- return { item: currTrans, operation: reverseOp };
8022
+ 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 };
8023
+ return {
8024
+ item: currTrans,
8025
+ operation: {
8026
+ class: "Transformation",
8027
+ method: "applyMatrix",
8028
+ items: [{
8029
+ id: currTrans.getId(),
8030
+ matrix: {
8031
+ translateX: op2.method === "applyMatrix" ? -m.translateX : m.translateX,
8032
+ translateY: op2.method === "applyMatrix" ? -m.translateY : m.translateY,
8033
+ scaleX: op2.method === "applyMatrix" ? 1 / m.scaleX : m.scaleX,
8034
+ scaleY: op2.method === "applyMatrix" ? 1 / m.scaleY : m.scaleY,
8035
+ shearX: 0,
8036
+ shearY: 0
8037
+ }
8038
+ }]
8039
+ }
8040
+ };
8064
8041
  });
8065
8042
  }
8066
8043
  case "locked": {
@@ -8191,10 +8168,14 @@ class Transformation {
8191
8168
  apply(op) {
8192
8169
  this.previous = this.matrix.copy();
8193
8170
  switch (op.method) {
8194
- case "applyMatrix":
8195
- this.matrix.scale(op.matrix.scaleX, op.matrix.scaleY);
8196
- this.matrix.translate(op.matrix.translateX, op.matrix.translateY);
8171
+ case "applyMatrix": {
8172
+ const itemOp = op.items.find((i) => i.id === this.id);
8173
+ if (itemOp) {
8174
+ this.matrix.scale(itemOp.matrix.scaleX, itemOp.matrix.scaleY);
8175
+ this.matrix.translate(itemOp.matrix.translateX, itemOp.matrix.translateY);
8176
+ }
8197
8177
  break;
8178
+ }
8198
8179
  case "translateTo":
8199
8180
  this.applyTranslateTo(op.x, op.y);
8200
8181
  break;
@@ -8329,8 +8310,7 @@ class Transformation {
8329
8310
  this.emit({
8330
8311
  class: "Transformation",
8331
8312
  method: "applyMatrix",
8332
- item: [this.id],
8333
- matrix,
8313
+ items: [{ id: this.id, matrix }],
8334
8314
  timeStamp
8335
8315
  });
8336
8316
  }
@@ -22075,7 +22055,7 @@ function createCommand(board, operation) {
22075
22055
  }
22076
22056
  default: {
22077
22057
  const itemType = operation.class;
22078
- 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);
22058
+ 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);
22079
22059
  const items = itemIdList.map((itemId) => board.items.findById(itemId) ?? itemId).filter((item) => {
22080
22060
  if (typeof item === "string") {
22081
22061
  console.warn(`Item with ID ${item} not found for operation ${operation.class}.${operation.method}`);
@@ -24250,7 +24230,8 @@ class RichText extends BaseItem {
24250
24230
  this.transformation.subject.subscribe((tr, op) => {
24251
24231
  this.prevMbr = this.getMbr();
24252
24232
  if (op.method === "applyMatrix") {
24253
- if (op.matrix.scaleX !== 1 || op.matrix.scaleY !== 1) {
24233
+ const itemOp = op.items.find((i) => i.id === this.id);
24234
+ if (itemOp && (itemOp.matrix.scaleX !== 1 || itemOp.matrix.scaleY !== 1)) {
24254
24235
  this.setAINodeShirkWidth();
24255
24236
  if (!this.isInShape) {
24256
24237
  this.transformCanvas();
@@ -24260,8 +24241,6 @@ class RichText extends BaseItem {
24260
24241
  } else {
24261
24242
  this.transformCanvas();
24262
24243
  }
24263
- } else if (op.method === "transformMany") {
24264
- this.transformCanvas();
24265
24244
  } else if (op.method === "deserialize") {
24266
24245
  this.setAINodeShirkWidth();
24267
24246
  this.updateElement();
@@ -38205,19 +38184,15 @@ class AINode extends BaseItem {
38205
38184
  this.text = new RichText(this.board, new Mbr, this.id, this.transformation, this.linkTo, " ", false, false, "AINode");
38206
38185
  this.transformation.subject.subscribe((_subject, op) => {
38207
38186
  if (op.method === "applyMatrix") {
38208
- if (op.matrix.scaleX !== 1 || op.matrix.scaleY !== 1) {
38187
+ const itemOp = op.items.find((i) => i.id === this.getId());
38188
+ if (itemOp && (itemOp.matrix.scaleX !== 1 || itemOp.matrix.scaleY !== 1)) {
38209
38189
  this.prevMbr = this.path?.getMbr();
38210
38190
  this.text.handleInshapeScale();
38211
- } else {
38212
- this.text.transformCanvas();
38213
- }
38214
- } else if (op.method === "transformMany") {
38215
- const currItemOp = op.items[this.getId()];
38216
- this.prevMbr = this.path?.getMbr();
38217
- if (currItemOp.method === "applyMatrix" && currItemOp.matrix.scaleX === 1 && currItemOp.matrix.scaleY === 1) {
38191
+ } else if (itemOp) {
38218
38192
  this.text.transformCanvas();
38219
38193
  } else {
38220
- this.text.handleInshapeScale();
38194
+ this.prevMbr = this.path?.getMbr();
38195
+ this.text.updateElement();
38221
38196
  }
38222
38197
  } else {
38223
38198
  this.prevMbr = this.path?.getMbr();
@@ -39429,13 +39404,9 @@ class Connector2 extends BaseItem {
39429
39404
  this.endPointer = getEndPointer(this.endPoint, this.endPointerStyle, this.lineStyle, this.lines, this.lineWidth * 0.1 + 0.3);
39430
39405
  this.middlePoint = null;
39431
39406
  this.transformation.subject.subscribe((_sub, op) => {
39432
- if (op.method === "transformMany") {
39433
- const operation = op.items[this.getId()];
39434
- if (operation.method === "applyMatrix") {
39435
- if (operation.matrix.scaleX !== 1 || operation.matrix.scaleY !== 1) {
39436
- this.scalePoints();
39437
- }
39438
- } else if (operation.method === "scaleByTranslateBy" && (operation.scale.x !== 1 || operation.scale.y !== 1)) {
39407
+ if (op.method === "applyMatrix") {
39408
+ const itemOp = op.items.find((i) => i.id === this.getId());
39409
+ if (itemOp && (itemOp.matrix.scaleX !== 1 || itemOp.matrix.scaleY !== 1)) {
39439
39410
  this.scalePoints();
39440
39411
  }
39441
39412
  }
@@ -41726,8 +41697,13 @@ class Shape extends BaseItem {
41726
41697
  this.transformation.subject.subscribe((_subject, op) => {
41727
41698
  this.transformPath();
41728
41699
  this.updateMbr();
41729
- if (op.method === "applyMatrix" && op.matrix.scaleX === 1 && op.matrix.scaleY === 1) {
41730
- this.text.transformCanvas();
41700
+ if (op.method === "applyMatrix") {
41701
+ const itemOp = op.items.find((i) => i.id === this.id);
41702
+ if (itemOp && itemOp.matrix.scaleX === 1 && itemOp.matrix.scaleY === 1) {
41703
+ this.text.transformCanvas();
41704
+ } else {
41705
+ this.text.updateElement();
41706
+ }
41731
41707
  } else {
41732
41708
  this.text.updateElement();
41733
41709
  }
@@ -42254,20 +42230,14 @@ class Sticker extends BaseItem {
42254
42230
  this.transformation.subject.subscribe((_subject, op) => {
42255
42231
  this.transformPath();
42256
42232
  if (op.method === "applyMatrix") {
42257
- if (op.matrix.scaleX !== 1 || op.matrix.scaleY !== 1) {
42258
- if (this.text.isAutosize()) {
42259
- this.text.scaleAutoSizeScale(Math.min(op.matrix.scaleX, op.matrix.scaleY));
42260
- this.text.recoordinate();
42261
- this.text.transformCanvas();
42262
- } else {
42263
- this.text.handleInshapeScale();
42264
- }
42265
- }
42266
- } else if (op.method === "transformMany") {
42267
- const transformOp = op.items[this.id];
42268
- if (transformOp.method === "applyMatrix" && (transformOp.matrix.scaleX !== 1 || transformOp.matrix.scaleY !== 1)) {
42233
+ const itemOp = op.items.find((i) => i.id === this.id);
42234
+ if (itemOp && (itemOp.matrix.scaleX !== 1 || itemOp.matrix.scaleY !== 1)) {
42269
42235
  if (this.text.isAutosize()) {
42270
- this.text.scaleAutoSizeScale(Math.min(transformOp.matrix.scaleX, transformOp.matrix.scaleY));
42236
+ if (itemOp.matrix.scaleX !== itemOp.matrix.scaleY) {
42237
+ this.text.applyAutoSizeScale(this.text.calcAutoSize());
42238
+ } else {
42239
+ this.text.scaleAutoSizeScale(itemOp.matrix.scaleX);
42240
+ }
42271
42241
  this.text.recoordinate();
42272
42242
  this.text.transformCanvas();
42273
42243
  } else {
@@ -48504,14 +48474,7 @@ class AlignmentHelper {
48504
48474
  this.board.selection.transformMany(translation, timeStamp);
48505
48475
  } else {
48506
48476
  const id = item.getId();
48507
- const transformMap = {};
48508
- transformMap[id] = {
48509
- class: "Transformation",
48510
- item: [id],
48511
- method: "applyMatrix",
48512
- matrix: { translateX: x, translateY: y, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 }
48513
- };
48514
- this.board.selection.transformMany(transformMap, timeStamp);
48477
+ this.board.selection.transformMany([{ id, matrix: { translateX: x, translateY: y, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 } }], timeStamp);
48515
48478
  }
48516
48479
  }
48517
48480
  translateCanvas(x, y, timeStamp) {
@@ -50360,7 +50323,7 @@ class Card extends BaseItem {
50360
50323
  this.board.bringToFront(this);
50361
50324
  }, 1000);
50362
50325
  this.transformation.subject.subscribe((_, op) => {
50363
- if (this.parent === "Board" && op.method === "applyMatrix" && op.matrix.scaleX === 1 && op.matrix.scaleY === 1) {
50326
+ 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) {
50364
50327
  this.throttledBringToFront();
50365
50328
  }
50366
50329
  this.updateMbr();
@@ -54115,7 +54078,7 @@ function handleMultipleItemsResize({
54115
54078
  isShiftPressed
54116
54079
  }) {
54117
54080
  const { matrix } = resize;
54118
- const translation = {};
54081
+ const result = [];
54119
54082
  const items = itemsToResize ? itemsToResize : board.selection.items.list();
54120
54083
  board.items.getComments().forEach((comment2) => {
54121
54084
  if (items.some((item) => item.getId() === comment2.getItemToFollow())) {
@@ -54134,25 +54097,25 @@ function handleMultipleItemsResize({
54134
54097
  const deltaY = itemY - initMbr.top;
54135
54098
  const translateY = deltaY * matrix.scaleY - deltaY + matrix.translateY;
54136
54099
  if (item instanceof RichText) {
54137
- translation[item.getId()] = getRichTextTranslation({
54100
+ result.push(getRichTextTranslation({
54138
54101
  item,
54139
54102
  isWidth,
54140
54103
  isHeight,
54141
54104
  matrix,
54142
54105
  translateX,
54143
54106
  translateY
54144
- });
54107
+ }));
54145
54108
  } else if (item instanceof AINode) {
54146
- translation[item.getId()] = getAINodeTranslation({
54109
+ result.push(getAINodeTranslation({
54147
54110
  item,
54148
54111
  isWidth,
54149
54112
  isHeight,
54150
54113
  matrix,
54151
54114
  translateX,
54152
54115
  translateY
54153
- });
54116
+ }));
54154
54117
  } else {
54155
- translation[item.getId()] = getItemTranslation({
54118
+ result.push(getItemTranslation({
54156
54119
  item,
54157
54120
  isWidth,
54158
54121
  isHeight,
@@ -54160,10 +54123,10 @@ function handleMultipleItemsResize({
54160
54123
  translateX,
54161
54124
  translateY,
54162
54125
  isShiftPressed
54163
- });
54126
+ }));
54164
54127
  }
54165
54128
  }
54166
- return translation;
54129
+ return result;
54167
54130
  }
54168
54131
  function getRichTextTranslation({
54169
54132
  item,
@@ -54175,26 +54138,11 @@ function getRichTextTranslation({
54175
54138
  }) {
54176
54139
  if (isWidth) {
54177
54140
  item.editor.setMaxWidth(item.getWidth() / item.transformation.getScale().x * matrix.scaleX);
54178
- return {
54179
- class: "Transformation",
54180
- method: "applyMatrix",
54181
- item: [item.getId()],
54182
- matrix: { translateX: matrix.translateX, translateY: 0, scaleX: matrix.scaleX, scaleY: matrix.scaleX, shearX: 0, shearY: 0 }
54183
- };
54141
+ return { id: item.getId(), matrix: { translateX: matrix.translateX, translateY: 0, scaleX: matrix.scaleX, scaleY: matrix.scaleX, shearX: 0, shearY: 0 } };
54184
54142
  } else if (isHeight) {
54185
- return {
54186
- class: "Transformation",
54187
- method: "applyMatrix",
54188
- item: [item.getId()],
54189
- matrix: { translateX, translateY, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 }
54190
- };
54143
+ return { id: item.getId(), matrix: { translateX, translateY, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 } };
54191
54144
  } else {
54192
- return {
54193
- class: "Transformation",
54194
- method: "applyMatrix",
54195
- item: [item.getId()],
54196
- matrix: { translateX, translateY, scaleX: matrix.scaleX, scaleY: matrix.scaleX, shearX: 0, shearY: 0 }
54197
- };
54145
+ return { id: item.getId(), matrix: { translateX, translateY, scaleX: matrix.scaleX, scaleY: matrix.scaleX, shearX: 0, shearY: 0 } };
54198
54146
  }
54199
54147
  }
54200
54148
  function getAINodeTranslation({
@@ -54207,26 +54155,11 @@ function getAINodeTranslation({
54207
54155
  }) {
54208
54156
  if (isWidth) {
54209
54157
  item.text.editor.setMaxWidth(item.text.getWidth() / item.transformation.getScale().x * matrix.scaleX);
54210
- return {
54211
- class: "Transformation",
54212
- method: "applyMatrix",
54213
- item: [item.getId()],
54214
- matrix: { translateX: matrix.translateX, translateY: 0, scaleX: matrix.scaleX, scaleY: matrix.scaleX, shearX: 0, shearY: 0 }
54215
- };
54158
+ return { id: item.getId(), matrix: { translateX: matrix.translateX, translateY: 0, scaleX: matrix.scaleX, scaleY: matrix.scaleX, shearX: 0, shearY: 0 } };
54216
54159
  } else if (isHeight) {
54217
- return {
54218
- class: "Transformation",
54219
- method: "applyMatrix",
54220
- item: [item.getId()],
54221
- matrix: { translateX, translateY, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 }
54222
- };
54160
+ return { id: item.getId(), matrix: { translateX, translateY, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 } };
54223
54161
  } else {
54224
- return {
54225
- class: "Transformation",
54226
- method: "applyMatrix",
54227
- item: [item.getId()],
54228
- matrix: { translateX, translateY, scaleX: matrix.scaleX, scaleY: matrix.scaleX, shearX: 0, shearY: 0 }
54229
- };
54162
+ return { id: item.getId(), matrix: { translateX, translateY, scaleX: matrix.scaleX, scaleY: matrix.scaleX, shearX: 0, shearY: 0 } };
54230
54163
  }
54231
54164
  }
54232
54165
  function getItemTranslation({
@@ -54239,22 +54172,12 @@ function getItemTranslation({
54239
54172
  isShiftPressed
54240
54173
  }) {
54241
54174
  if (item instanceof Sticker && (isWidth || isHeight)) {
54242
- return {
54243
- class: "Transformation",
54244
- method: "applyMatrix",
54245
- item: [item.getId()],
54246
- matrix: { translateX, translateY, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 }
54247
- };
54175
+ return { id: item.getId(), matrix: { translateX, translateY, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 } };
54248
54176
  } else {
54249
54177
  if (item instanceof Frame2 && item.getCanChangeRatio() && isShiftPressed && item.getFrameType() !== "Custom") {
54250
54178
  item.setFrameType("Custom");
54251
54179
  }
54252
- return {
54253
- class: "Transformation",
54254
- method: "applyMatrix",
54255
- item: [item.getId()],
54256
- matrix: { translateX, translateY, scaleX: matrix.scaleX, scaleY: matrix.scaleY, shearX: 0, shearY: 0 }
54257
- };
54180
+ return { id: item.getId(), matrix: { translateX, translateY, scaleX: matrix.scaleX, scaleY: matrix.scaleY, shearX: 0, shearY: 0 } };
54258
54181
  }
54259
54182
  }
54260
54183
 
@@ -55619,53 +55542,41 @@ class BoardSelection {
55619
55542
  this.shouldPublish = false;
55620
55543
  this.emit({
55621
55544
  class: "Transformation",
55622
- method: "transformMany",
55545
+ method: "applyMatrix",
55623
55546
  items,
55624
55547
  timeStamp
55625
55548
  });
55626
55549
  this.shouldPublish = true;
55627
55550
  }
55628
55551
  getManyItemsTranslation(x, y, unselectedItem) {
55629
- const translation = {};
55630
- function addItemToTranslation(itemId) {
55631
- translation[itemId] = {
55632
- class: "Transformation",
55633
- method: "applyMatrix",
55634
- item: [itemId],
55635
- matrix: { translateX: x, translateY: y, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 }
55636
- };
55637
- }
55638
- function tryToAddFrameChildrenToTranslation(selectedItem) {
55552
+ const items = [];
55553
+ const addItem = (itemId) => {
55554
+ items.push({ id: itemId, matrix: { translateX: x, translateY: y, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 } });
55555
+ };
55556
+ const tryToAddFrameChildren = (selectedItem) => {
55639
55557
  if (!("index" in selectedItem) || !selectedItem.index) {
55640
55558
  return;
55641
55559
  }
55642
55560
  for (const childId of selectedItem.getChildrenIds()) {
55643
- addItemToTranslation(childId);
55561
+ addItem(childId);
55644
55562
  }
55645
- }
55646
- const createTranslationWithComments = (item) => {
55563
+ };
55564
+ const addWithComments = (item) => {
55565
+ addItem(item.getId());
55566
+ tryToAddFrameChildren(item);
55647
55567
  const followedComments = this.board.items.getComments().filter((comment2) => comment2.getItemToFollow() === item.getId());
55648
55568
  for (const comment2 of followedComments) {
55649
- translation[comment2.getId()] = {
55650
- class: "Transformation",
55651
- method: "applyMatrix",
55652
- item: [comment2.getId()],
55653
- matrix: { translateX: x, translateY: y, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 }
55654
- };
55569
+ addItem(comment2.getId());
55655
55570
  }
55656
55571
  };
55657
55572
  if (unselectedItem) {
55658
- addItemToTranslation(unselectedItem.getId());
55659
- tryToAddFrameChildrenToTranslation(unselectedItem);
55660
- createTranslationWithComments(unselectedItem);
55661
- return translation;
55573
+ addWithComments(unselectedItem);
55574
+ return items;
55662
55575
  }
55663
55576
  for (const selectedItem of this.board.selection.list()) {
55664
- addItemToTranslation(selectedItem.getId());
55665
- tryToAddFrameChildrenToTranslation(selectedItem);
55666
- createTranslationWithComments(selectedItem);
55577
+ addWithComments(selectedItem);
55667
55578
  }
55668
- return translation;
55579
+ return items;
55669
55580
  }
55670
55581
  setStrokeStyle(borderStyle) {
55671
55582
  const shapes = this.items.getIdsByItemTypes(["Shape"]);
@@ -57208,32 +57119,40 @@ function mergeOperations(opA, opB) {
57208
57119
  return;
57209
57120
  }
57210
57121
  function mergeTransformationOperations(opA, opB) {
57211
- if (!areItemsTheSame(opA, opB)) {
57122
+ if (opA.timeStamp && opB.timeStamp && opA.timeStamp !== opB.timeStamp) {
57212
57123
  return;
57213
57124
  }
57214
- if (opA.timeStamp && opB.timeStamp && opA.timeStamp !== opB.timeStamp) {
57125
+ if (opA.method === "applyMatrix" && opB.method === "applyMatrix") {
57126
+ if (opA.items.length !== opB.items.length)
57127
+ return;
57128
+ const idsA = new Set(opA.items.map((i) => i.id));
57129
+ if (!opB.items.every((b) => idsA.has(b.id)))
57130
+ return;
57131
+ return {
57132
+ class: "Transformation",
57133
+ method: "applyMatrix",
57134
+ items: opB.items.map((b) => {
57135
+ const a2 = opA.items.find((i) => i.id === b.id);
57136
+ return {
57137
+ id: b.id,
57138
+ matrix: {
57139
+ translateX: a2.matrix.translateX + b.matrix.translateX,
57140
+ translateY: a2.matrix.translateY + b.matrix.translateY,
57141
+ scaleX: a2.matrix.scaleX * b.matrix.scaleX,
57142
+ scaleY: a2.matrix.scaleY * b.matrix.scaleY,
57143
+ shearX: 0,
57144
+ shearY: 0
57145
+ }
57146
+ };
57147
+ }),
57148
+ timeStamp: opB.timeStamp
57149
+ };
57150
+ }
57151
+ if (!areItemsTheSame(opA, opB)) {
57215
57152
  return;
57216
57153
  }
57217
57154
  const method = opA.method;
57218
57155
  switch (method) {
57219
- case "applyMatrix":
57220
- if (opB.method !== method) {
57221
- return;
57222
- }
57223
- return {
57224
- class: "Transformation",
57225
- method: "applyMatrix",
57226
- item: opA.item,
57227
- matrix: {
57228
- translateX: opA.matrix.translateX + opB.matrix.translateX,
57229
- translateY: opA.matrix.translateY + opB.matrix.translateY,
57230
- scaleX: opA.matrix.scaleX * opB.matrix.scaleX,
57231
- scaleY: opA.matrix.scaleY * opB.matrix.scaleY,
57232
- shearX: 0,
57233
- shearY: 0
57234
- },
57235
- timeStamp: opB.timeStamp
57236
- };
57237
57156
  case "translateBy":
57238
57157
  if (opB.method !== method) {
57239
57158
  return;
@@ -57287,130 +57206,10 @@ function mergeTransformationOperations(opA, opB) {
57287
57206
  },
57288
57207
  timeStamp: opB.timeStamp
57289
57208
  };
57290
- case "transformMany":
57291
- const items = mergeItems(opA, opB);
57292
- if (opB.method !== method) {
57293
- return;
57294
- }
57295
- return {
57296
- class: "Transformation",
57297
- method: "transformMany",
57298
- items,
57299
- timeStamp: opB.timeStamp
57300
- };
57301
57209
  default:
57302
57210
  return;
57303
57211
  }
57304
57212
  }
57305
- function mergeItems(opA, opB) {
57306
- if (opA.method === "transformMany" && opB.method === "transformMany") {
57307
- const resolve2 = (currScale, currTranslate, opB2) => {
57308
- switch (opB2.method) {
57309
- case "scaleByTranslateBy":
57310
- return {
57311
- scale: {
57312
- x: currScale ? currScale.x * opB2.scale.x : opB2.scale.x,
57313
- y: currScale ? currScale.y * opB2.scale.y : opB2.scale.y
57314
- },
57315
- translate: {
57316
- x: currTranslate ? currTranslate.x + opB2.translate.x : opB2.translate.x,
57317
- y: currTranslate ? currTranslate.y + opB2.translate.y : opB2.translate.y
57318
- }
57319
- };
57320
- case "scaleBy":
57321
- return {
57322
- scale: {
57323
- x: currScale ? currScale.x * opB2.x : opB2.x,
57324
- y: currScale ? currScale.y * opB2.y : opB2.y
57325
- },
57326
- translate: {
57327
- x: currTranslate ? currTranslate.x : 0,
57328
- y: currTranslate ? currTranslate.y : 0
57329
- }
57330
- };
57331
- case "translateBy":
57332
- return {
57333
- scale: {
57334
- x: currScale ? currScale.x : 1,
57335
- y: currScale ? currScale.y : 1
57336
- },
57337
- translate: {
57338
- x: currTranslate ? currTranslate.x + opB2.x : opB2.x,
57339
- y: currTranslate ? currTranslate.y + opB2.y : opB2.y
57340
- }
57341
- };
57342
- }
57343
- return;
57344
- };
57345
- const items = {};
57346
- Object.keys(opB.items).forEach((itemId) => {
57347
- if (opA.items[itemId] !== undefined) {
57348
- if (opA.items[itemId].method === "applyMatrix" && opB.items[itemId].method === "applyMatrix") {
57349
- const a2 = opA.items[itemId].matrix;
57350
- const b = opB.items[itemId].matrix;
57351
- items[itemId] = {
57352
- class: "Transformation",
57353
- method: "applyMatrix",
57354
- item: [itemId],
57355
- matrix: {
57356
- translateX: a2.translateX + b.translateX,
57357
- translateY: a2.translateY + b.translateY,
57358
- scaleX: a2.scaleX * b.scaleX,
57359
- scaleY: a2.scaleY * b.scaleY,
57360
- shearX: 0,
57361
- shearY: 0
57362
- }
57363
- };
57364
- } else if (opA.items[itemId].method === "scaleByTranslateBy") {
57365
- const newTransformation = resolve2(opA.items[itemId].scale, opA.items[itemId].translate, opB.items[itemId]);
57366
- if (!newTransformation) {
57367
- items[itemId] = opB.items[itemId];
57368
- } else {
57369
- items[itemId] = {
57370
- class: "Transformation",
57371
- method: "scaleByTranslateBy",
57372
- item: [itemId],
57373
- scale: newTransformation.scale,
57374
- translate: newTransformation.translate
57375
- };
57376
- }
57377
- } else if (opA.items[itemId].method === "scaleBy") {
57378
- const newTransformation = resolve2({ x: opA.items[itemId].x, y: opA.items[itemId].y }, undefined, opB.items[itemId]);
57379
- if (!newTransformation) {
57380
- items[itemId] = opB.items[itemId];
57381
- } else {
57382
- items[itemId] = {
57383
- class: "Transformation",
57384
- method: "scaleByTranslateBy",
57385
- item: [itemId],
57386
- scale: newTransformation.scale,
57387
- translate: newTransformation.translate
57388
- };
57389
- }
57390
- } else if (opA.items[itemId].method === "translateBy") {
57391
- const newTransformation = resolve2(undefined, { x: opA.items[itemId].x, y: opA.items[itemId].y }, opB.items[itemId]);
57392
- if (!newTransformation) {
57393
- items[itemId] = opB.items[itemId];
57394
- } else {
57395
- items[itemId] = {
57396
- class: "Transformation",
57397
- method: "scaleByTranslateBy",
57398
- item: [itemId],
57399
- scale: newTransformation.scale,
57400
- translate: newTransformation.translate
57401
- };
57402
- }
57403
- } else {
57404
- items[itemId] = opB.items[itemId];
57405
- }
57406
- } else {
57407
- items[itemId] = opB.items[itemId];
57408
- }
57409
- });
57410
- return items;
57411
- }
57412
- return;
57413
- }
57414
57213
  function mergeRichTextOperations(opA, opB) {
57415
57214
  if (!areItemsTheSame(opA, opB)) {
57416
57215
  return;