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/node.js CHANGED
@@ -8341,17 +8341,29 @@ class TransformationCommand {
8341
8341
  switch (this.operation.method) {
8342
8342
  case "applyMatrix": {
8343
8343
  const op2 = this.operation;
8344
- return mapItemsByOperation(this.transformation, () => ({
8345
- ...op2,
8346
- matrix: {
8347
- translateX: -op2.matrix.translateX,
8348
- translateY: -op2.matrix.translateY,
8349
- scaleX: 1 / op2.matrix.scaleX,
8350
- scaleY: 1 / op2.matrix.scaleY,
8351
- shearX: 0,
8352
- shearY: 0
8353
- }
8354
- }));
8344
+ return this.transformation.map((t3) => {
8345
+ const itemOp = op2.items.find((i) => i.id === t3.getId());
8346
+ if (!itemOp)
8347
+ return { item: t3, operation: op2 };
8348
+ return {
8349
+ item: t3,
8350
+ operation: {
8351
+ class: "Transformation",
8352
+ method: "applyMatrix",
8353
+ items: [{
8354
+ id: t3.getId(),
8355
+ matrix: {
8356
+ translateX: -itemOp.matrix.translateX,
8357
+ translateY: -itemOp.matrix.translateY,
8358
+ scaleX: 1 / itemOp.matrix.scaleX,
8359
+ scaleY: 1 / itemOp.matrix.scaleY,
8360
+ shearX: 0,
8361
+ shearY: 0
8362
+ }
8363
+ }]
8364
+ }
8365
+ };
8366
+ });
8355
8367
  }
8356
8368
  case "translateTo":
8357
8369
  return mapItemsByOperation(this.transformation, (transformation) => {
@@ -8433,60 +8445,25 @@ class TransformationCommand {
8433
8445
  const { operation, transformation } = this;
8434
8446
  return transformation.map((currTrans) => {
8435
8447
  const op2 = operation.items[currTrans.getId()];
8436
- let reverseOp;
8437
- if (op2.method === "applyMatrix") {
8438
- reverseOp = {
8439
- ...op2,
8440
- matrix: {
8441
- translateX: -op2.matrix.translateX,
8442
- translateY: -op2.matrix.translateY,
8443
- scaleX: 1 / op2.matrix.scaleX,
8444
- scaleY: 1 / op2.matrix.scaleY,
8445
- shearX: 0,
8446
- shearY: 0
8447
- }
8448
- };
8449
- } else if (op2.method === "scaleByTranslateBy") {
8450
- reverseOp = {
8451
- ...op2,
8452
- scale: { x: 1 / op2.scale.x, y: 1 / op2.scale.y },
8453
- translate: {
8454
- x: -op2.translate.x,
8455
- y: -op2.translate.y
8456
- }
8457
- };
8458
- } else if (op2.method === "translateTo") {
8459
- reverseOp = {
8460
- ...op2,
8461
- x: currTrans.getTranslation().x,
8462
- y: currTrans.getTranslation().y
8463
- };
8464
- } else if (op2.method === "translateBy") {
8465
- reverseOp = {
8466
- ...op2,
8467
- x: -op2.x,
8468
- y: -op2.y
8469
- };
8470
- } else if (op2.method === "scaleTo") {
8471
- reverseOp = {
8472
- ...op2,
8473
- x: currTrans.getScale().x,
8474
- y: currTrans.getScale().y
8475
- };
8476
- } else if (op2.method === "scaleBy") {
8477
- reverseOp = {
8478
- ...op2,
8479
- x: 1 / op2.x,
8480
- y: 1 / op2.y
8481
- };
8482
- } else {
8483
- reverseOp = {
8484
- ...op2,
8485
- x: 1,
8486
- y: 1
8487
- };
8488
- }
8489
- return { item: currTrans, operation: reverseOp };
8448
+ 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 };
8449
+ return {
8450
+ item: currTrans,
8451
+ operation: {
8452
+ class: "Transformation",
8453
+ method: "applyMatrix",
8454
+ items: [{
8455
+ id: currTrans.getId(),
8456
+ matrix: {
8457
+ translateX: op2.method === "applyMatrix" ? -m.translateX : m.translateX,
8458
+ translateY: op2.method === "applyMatrix" ? -m.translateY : m.translateY,
8459
+ scaleX: op2.method === "applyMatrix" ? 1 / m.scaleX : m.scaleX,
8460
+ scaleY: op2.method === "applyMatrix" ? 1 / m.scaleY : m.scaleY,
8461
+ shearX: 0,
8462
+ shearY: 0
8463
+ }
8464
+ }]
8465
+ }
8466
+ };
8490
8467
  });
8491
8468
  }
8492
8469
  case "locked": {
@@ -8617,10 +8594,14 @@ class Transformation {
8617
8594
  apply(op) {
8618
8595
  this.previous = this.matrix.copy();
8619
8596
  switch (op.method) {
8620
- case "applyMatrix":
8621
- this.matrix.scale(op.matrix.scaleX, op.matrix.scaleY);
8622
- this.matrix.translate(op.matrix.translateX, op.matrix.translateY);
8597
+ case "applyMatrix": {
8598
+ const itemOp = op.items.find((i) => i.id === this.id);
8599
+ if (itemOp) {
8600
+ this.matrix.scale(itemOp.matrix.scaleX, itemOp.matrix.scaleY);
8601
+ this.matrix.translate(itemOp.matrix.translateX, itemOp.matrix.translateY);
8602
+ }
8623
8603
  break;
8604
+ }
8624
8605
  case "translateTo":
8625
8606
  this.applyTranslateTo(op.x, op.y);
8626
8607
  break;
@@ -8755,8 +8736,7 @@ class Transformation {
8755
8736
  this.emit({
8756
8737
  class: "Transformation",
8757
8738
  method: "applyMatrix",
8758
- item: [this.id],
8759
- matrix,
8739
+ items: [{ id: this.id, matrix }],
8760
8740
  timeStamp
8761
8741
  });
8762
8742
  }
@@ -22244,7 +22224,7 @@ function createCommand(board, operation) {
22244
22224
  }
22245
22225
  default: {
22246
22226
  const itemType = operation.class;
22247
- 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);
22227
+ 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);
22248
22228
  const items = itemIdList.map((itemId) => board.items.findById(itemId) ?? itemId).filter((item) => {
22249
22229
  if (typeof item === "string") {
22250
22230
  console.warn(`Item with ID ${item} not found for operation ${operation.class}.${operation.method}`);
@@ -24419,7 +24399,8 @@ class RichText extends BaseItem {
24419
24399
  this.transformation.subject.subscribe((tr, op) => {
24420
24400
  this.prevMbr = this.getMbr();
24421
24401
  if (op.method === "applyMatrix") {
24422
- if (op.matrix.scaleX !== 1 || op.matrix.scaleY !== 1) {
24402
+ const itemOp = op.items.find((i) => i.id === this.id);
24403
+ if (itemOp && (itemOp.matrix.scaleX !== 1 || itemOp.matrix.scaleY !== 1)) {
24423
24404
  this.setAINodeShirkWidth();
24424
24405
  if (!this.isInShape) {
24425
24406
  this.transformCanvas();
@@ -24429,8 +24410,6 @@ class RichText extends BaseItem {
24429
24410
  } else {
24430
24411
  this.transformCanvas();
24431
24412
  }
24432
- } else if (op.method === "transformMany") {
24433
- this.transformCanvas();
24434
24413
  } else if (op.method === "deserialize") {
24435
24414
  this.setAINodeShirkWidth();
24436
24415
  this.updateElement();
@@ -38374,19 +38353,15 @@ class AINode extends BaseItem {
38374
38353
  this.text = new RichText(this.board, new Mbr, this.id, this.transformation, this.linkTo, " ", false, false, "AINode");
38375
38354
  this.transformation.subject.subscribe((_subject, op) => {
38376
38355
  if (op.method === "applyMatrix") {
38377
- if (op.matrix.scaleX !== 1 || op.matrix.scaleY !== 1) {
38356
+ const itemOp = op.items.find((i) => i.id === this.getId());
38357
+ if (itemOp && (itemOp.matrix.scaleX !== 1 || itemOp.matrix.scaleY !== 1)) {
38378
38358
  this.prevMbr = this.path?.getMbr();
38379
38359
  this.text.handleInshapeScale();
38380
- } else {
38381
- this.text.transformCanvas();
38382
- }
38383
- } else if (op.method === "transformMany") {
38384
- const currItemOp = op.items[this.getId()];
38385
- this.prevMbr = this.path?.getMbr();
38386
- if (currItemOp.method === "applyMatrix" && currItemOp.matrix.scaleX === 1 && currItemOp.matrix.scaleY === 1) {
38360
+ } else if (itemOp) {
38387
38361
  this.text.transformCanvas();
38388
38362
  } else {
38389
- this.text.handleInshapeScale();
38363
+ this.prevMbr = this.path?.getMbr();
38364
+ this.text.updateElement();
38390
38365
  }
38391
38366
  } else {
38392
38367
  this.prevMbr = this.path?.getMbr();
@@ -39598,13 +39573,9 @@ class Connector2 extends BaseItem {
39598
39573
  this.endPointer = getEndPointer(this.endPoint, this.endPointerStyle, this.lineStyle, this.lines, this.lineWidth * 0.1 + 0.3);
39599
39574
  this.middlePoint = null;
39600
39575
  this.transformation.subject.subscribe((_sub, op) => {
39601
- if (op.method === "transformMany") {
39602
- const operation = op.items[this.getId()];
39603
- if (operation.method === "applyMatrix") {
39604
- if (operation.matrix.scaleX !== 1 || operation.matrix.scaleY !== 1) {
39605
- this.scalePoints();
39606
- }
39607
- } else if (operation.method === "scaleByTranslateBy" && (operation.scale.x !== 1 || operation.scale.y !== 1)) {
39576
+ if (op.method === "applyMatrix") {
39577
+ const itemOp = op.items.find((i) => i.id === this.getId());
39578
+ if (itemOp && (itemOp.matrix.scaleX !== 1 || itemOp.matrix.scaleY !== 1)) {
39608
39579
  this.scalePoints();
39609
39580
  }
39610
39581
  }
@@ -41895,8 +41866,13 @@ class Shape extends BaseItem {
41895
41866
  this.transformation.subject.subscribe((_subject, op) => {
41896
41867
  this.transformPath();
41897
41868
  this.updateMbr();
41898
- if (op.method === "applyMatrix" && op.matrix.scaleX === 1 && op.matrix.scaleY === 1) {
41899
- this.text.transformCanvas();
41869
+ if (op.method === "applyMatrix") {
41870
+ const itemOp = op.items.find((i) => i.id === this.id);
41871
+ if (itemOp && itemOp.matrix.scaleX === 1 && itemOp.matrix.scaleY === 1) {
41872
+ this.text.transformCanvas();
41873
+ } else {
41874
+ this.text.updateElement();
41875
+ }
41900
41876
  } else {
41901
41877
  this.text.updateElement();
41902
41878
  }
@@ -42423,20 +42399,14 @@ class Sticker extends BaseItem {
42423
42399
  this.transformation.subject.subscribe((_subject, op) => {
42424
42400
  this.transformPath();
42425
42401
  if (op.method === "applyMatrix") {
42426
- if (op.matrix.scaleX !== 1 || op.matrix.scaleY !== 1) {
42427
- if (this.text.isAutosize()) {
42428
- this.text.scaleAutoSizeScale(Math.min(op.matrix.scaleX, op.matrix.scaleY));
42429
- this.text.recoordinate();
42430
- this.text.transformCanvas();
42431
- } else {
42432
- this.text.handleInshapeScale();
42433
- }
42434
- }
42435
- } else if (op.method === "transformMany") {
42436
- const transformOp = op.items[this.id];
42437
- if (transformOp.method === "applyMatrix" && (transformOp.matrix.scaleX !== 1 || transformOp.matrix.scaleY !== 1)) {
42402
+ const itemOp = op.items.find((i) => i.id === this.id);
42403
+ if (itemOp && (itemOp.matrix.scaleX !== 1 || itemOp.matrix.scaleY !== 1)) {
42438
42404
  if (this.text.isAutosize()) {
42439
- this.text.scaleAutoSizeScale(Math.min(transformOp.matrix.scaleX, transformOp.matrix.scaleY));
42405
+ if (itemOp.matrix.scaleX !== itemOp.matrix.scaleY) {
42406
+ this.text.applyAutoSizeScale(this.text.calcAutoSize());
42407
+ } else {
42408
+ this.text.scaleAutoSizeScale(itemOp.matrix.scaleX);
42409
+ }
42440
42410
  this.text.recoordinate();
42441
42411
  this.text.transformCanvas();
42442
42412
  } else {
@@ -48673,14 +48643,7 @@ class AlignmentHelper {
48673
48643
  this.board.selection.transformMany(translation, timeStamp);
48674
48644
  } else {
48675
48645
  const id = item.getId();
48676
- const transformMap = {};
48677
- transformMap[id] = {
48678
- class: "Transformation",
48679
- item: [id],
48680
- method: "applyMatrix",
48681
- matrix: { translateX: x, translateY: y, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 }
48682
- };
48683
- this.board.selection.transformMany(transformMap, timeStamp);
48646
+ this.board.selection.transformMany([{ id, matrix: { translateX: x, translateY: y, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 } }], timeStamp);
48684
48647
  }
48685
48648
  }
48686
48649
  translateCanvas(x, y, timeStamp) {
@@ -50529,7 +50492,7 @@ class Card extends BaseItem {
50529
50492
  this.board.bringToFront(this);
50530
50493
  }, 1000);
50531
50494
  this.transformation.subject.subscribe((_, op) => {
50532
- if (this.parent === "Board" && op.method === "applyMatrix" && op.matrix.scaleX === 1 && op.matrix.scaleY === 1) {
50495
+ 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) {
50533
50496
  this.throttledBringToFront();
50534
50497
  }
50535
50498
  this.updateMbr();
@@ -54284,7 +54247,7 @@ function handleMultipleItemsResize({
54284
54247
  isShiftPressed
54285
54248
  }) {
54286
54249
  const { matrix } = resize;
54287
- const translation = {};
54250
+ const result = [];
54288
54251
  const items = itemsToResize ? itemsToResize : board.selection.items.list();
54289
54252
  board.items.getComments().forEach((comment2) => {
54290
54253
  if (items.some((item) => item.getId() === comment2.getItemToFollow())) {
@@ -54303,25 +54266,25 @@ function handleMultipleItemsResize({
54303
54266
  const deltaY = itemY - initMbr.top;
54304
54267
  const translateY = deltaY * matrix.scaleY - deltaY + matrix.translateY;
54305
54268
  if (item instanceof RichText) {
54306
- translation[item.getId()] = getRichTextTranslation({
54269
+ result.push(getRichTextTranslation({
54307
54270
  item,
54308
54271
  isWidth,
54309
54272
  isHeight,
54310
54273
  matrix,
54311
54274
  translateX,
54312
54275
  translateY
54313
- });
54276
+ }));
54314
54277
  } else if (item instanceof AINode) {
54315
- translation[item.getId()] = getAINodeTranslation({
54278
+ result.push(getAINodeTranslation({
54316
54279
  item,
54317
54280
  isWidth,
54318
54281
  isHeight,
54319
54282
  matrix,
54320
54283
  translateX,
54321
54284
  translateY
54322
- });
54285
+ }));
54323
54286
  } else {
54324
- translation[item.getId()] = getItemTranslation({
54287
+ result.push(getItemTranslation({
54325
54288
  item,
54326
54289
  isWidth,
54327
54290
  isHeight,
@@ -54329,10 +54292,10 @@ function handleMultipleItemsResize({
54329
54292
  translateX,
54330
54293
  translateY,
54331
54294
  isShiftPressed
54332
- });
54295
+ }));
54333
54296
  }
54334
54297
  }
54335
- return translation;
54298
+ return result;
54336
54299
  }
54337
54300
  function getRichTextTranslation({
54338
54301
  item,
@@ -54344,26 +54307,11 @@ function getRichTextTranslation({
54344
54307
  }) {
54345
54308
  if (isWidth) {
54346
54309
  item.editor.setMaxWidth(item.getWidth() / item.transformation.getScale().x * matrix.scaleX);
54347
- return {
54348
- class: "Transformation",
54349
- method: "applyMatrix",
54350
- item: [item.getId()],
54351
- matrix: { translateX: matrix.translateX, translateY: 0, scaleX: matrix.scaleX, scaleY: matrix.scaleX, shearX: 0, shearY: 0 }
54352
- };
54310
+ return { id: item.getId(), matrix: { translateX: matrix.translateX, translateY: 0, scaleX: matrix.scaleX, scaleY: matrix.scaleX, shearX: 0, shearY: 0 } };
54353
54311
  } else if (isHeight) {
54354
- return {
54355
- class: "Transformation",
54356
- method: "applyMatrix",
54357
- item: [item.getId()],
54358
- matrix: { translateX, translateY, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 }
54359
- };
54312
+ return { id: item.getId(), matrix: { translateX, translateY, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 } };
54360
54313
  } else {
54361
- return {
54362
- class: "Transformation",
54363
- method: "applyMatrix",
54364
- item: [item.getId()],
54365
- matrix: { translateX, translateY, scaleX: matrix.scaleX, scaleY: matrix.scaleX, shearX: 0, shearY: 0 }
54366
- };
54314
+ return { id: item.getId(), matrix: { translateX, translateY, scaleX: matrix.scaleX, scaleY: matrix.scaleX, shearX: 0, shearY: 0 } };
54367
54315
  }
54368
54316
  }
54369
54317
  function getAINodeTranslation({
@@ -54376,26 +54324,11 @@ function getAINodeTranslation({
54376
54324
  }) {
54377
54325
  if (isWidth) {
54378
54326
  item.text.editor.setMaxWidth(item.text.getWidth() / item.transformation.getScale().x * matrix.scaleX);
54379
- return {
54380
- class: "Transformation",
54381
- method: "applyMatrix",
54382
- item: [item.getId()],
54383
- matrix: { translateX: matrix.translateX, translateY: 0, scaleX: matrix.scaleX, scaleY: matrix.scaleX, shearX: 0, shearY: 0 }
54384
- };
54327
+ return { id: item.getId(), matrix: { translateX: matrix.translateX, translateY: 0, scaleX: matrix.scaleX, scaleY: matrix.scaleX, shearX: 0, shearY: 0 } };
54385
54328
  } else if (isHeight) {
54386
- return {
54387
- class: "Transformation",
54388
- method: "applyMatrix",
54389
- item: [item.getId()],
54390
- matrix: { translateX, translateY, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 }
54391
- };
54329
+ return { id: item.getId(), matrix: { translateX, translateY, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 } };
54392
54330
  } else {
54393
- return {
54394
- class: "Transformation",
54395
- method: "applyMatrix",
54396
- item: [item.getId()],
54397
- matrix: { translateX, translateY, scaleX: matrix.scaleX, scaleY: matrix.scaleX, shearX: 0, shearY: 0 }
54398
- };
54331
+ return { id: item.getId(), matrix: { translateX, translateY, scaleX: matrix.scaleX, scaleY: matrix.scaleX, shearX: 0, shearY: 0 } };
54399
54332
  }
54400
54333
  }
54401
54334
  function getItemTranslation({
@@ -54408,22 +54341,12 @@ function getItemTranslation({
54408
54341
  isShiftPressed
54409
54342
  }) {
54410
54343
  if (item instanceof Sticker && (isWidth || isHeight)) {
54411
- return {
54412
- class: "Transformation",
54413
- method: "applyMatrix",
54414
- item: [item.getId()],
54415
- matrix: { translateX, translateY, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 }
54416
- };
54344
+ return { id: item.getId(), matrix: { translateX, translateY, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 } };
54417
54345
  } else {
54418
54346
  if (item instanceof Frame2 && item.getCanChangeRatio() && isShiftPressed && item.getFrameType() !== "Custom") {
54419
54347
  item.setFrameType("Custom");
54420
54348
  }
54421
- return {
54422
- class: "Transformation",
54423
- method: "applyMatrix",
54424
- item: [item.getId()],
54425
- matrix: { translateX, translateY, scaleX: matrix.scaleX, scaleY: matrix.scaleY, shearX: 0, shearY: 0 }
54426
- };
54349
+ return { id: item.getId(), matrix: { translateX, translateY, scaleX: matrix.scaleX, scaleY: matrix.scaleY, shearX: 0, shearY: 0 } };
54427
54350
  }
54428
54351
  }
54429
54352
 
@@ -55788,53 +55711,41 @@ class BoardSelection {
55788
55711
  this.shouldPublish = false;
55789
55712
  this.emit({
55790
55713
  class: "Transformation",
55791
- method: "transformMany",
55714
+ method: "applyMatrix",
55792
55715
  items,
55793
55716
  timeStamp
55794
55717
  });
55795
55718
  this.shouldPublish = true;
55796
55719
  }
55797
55720
  getManyItemsTranslation(x, y, unselectedItem) {
55798
- const translation = {};
55799
- function addItemToTranslation(itemId) {
55800
- translation[itemId] = {
55801
- class: "Transformation",
55802
- method: "applyMatrix",
55803
- item: [itemId],
55804
- matrix: { translateX: x, translateY: y, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 }
55805
- };
55806
- }
55807
- function tryToAddFrameChildrenToTranslation(selectedItem) {
55721
+ const items = [];
55722
+ const addItem = (itemId) => {
55723
+ items.push({ id: itemId, matrix: { translateX: x, translateY: y, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 } });
55724
+ };
55725
+ const tryToAddFrameChildren = (selectedItem) => {
55808
55726
  if (!("index" in selectedItem) || !selectedItem.index) {
55809
55727
  return;
55810
55728
  }
55811
55729
  for (const childId of selectedItem.getChildrenIds()) {
55812
- addItemToTranslation(childId);
55730
+ addItem(childId);
55813
55731
  }
55814
- }
55815
- const createTranslationWithComments = (item) => {
55732
+ };
55733
+ const addWithComments = (item) => {
55734
+ addItem(item.getId());
55735
+ tryToAddFrameChildren(item);
55816
55736
  const followedComments = this.board.items.getComments().filter((comment2) => comment2.getItemToFollow() === item.getId());
55817
55737
  for (const comment2 of followedComments) {
55818
- translation[comment2.getId()] = {
55819
- class: "Transformation",
55820
- method: "applyMatrix",
55821
- item: [comment2.getId()],
55822
- matrix: { translateX: x, translateY: y, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 }
55823
- };
55738
+ addItem(comment2.getId());
55824
55739
  }
55825
55740
  };
55826
55741
  if (unselectedItem) {
55827
- addItemToTranslation(unselectedItem.getId());
55828
- tryToAddFrameChildrenToTranslation(unselectedItem);
55829
- createTranslationWithComments(unselectedItem);
55830
- return translation;
55742
+ addWithComments(unselectedItem);
55743
+ return items;
55831
55744
  }
55832
55745
  for (const selectedItem of this.board.selection.list()) {
55833
- addItemToTranslation(selectedItem.getId());
55834
- tryToAddFrameChildrenToTranslation(selectedItem);
55835
- createTranslationWithComments(selectedItem);
55746
+ addWithComments(selectedItem);
55836
55747
  }
55837
- return translation;
55748
+ return items;
55838
55749
  }
55839
55750
  setStrokeStyle(borderStyle) {
55840
55751
  const shapes = this.items.getIdsByItemTypes(["Shape"]);
@@ -57377,32 +57288,40 @@ function mergeOperations(opA, opB) {
57377
57288
  return;
57378
57289
  }
57379
57290
  function mergeTransformationOperations(opA, opB) {
57380
- if (!areItemsTheSame(opA, opB)) {
57291
+ if (opA.timeStamp && opB.timeStamp && opA.timeStamp !== opB.timeStamp) {
57381
57292
  return;
57382
57293
  }
57383
- if (opA.timeStamp && opB.timeStamp && opA.timeStamp !== opB.timeStamp) {
57294
+ if (opA.method === "applyMatrix" && opB.method === "applyMatrix") {
57295
+ if (opA.items.length !== opB.items.length)
57296
+ return;
57297
+ const idsA = new Set(opA.items.map((i) => i.id));
57298
+ if (!opB.items.every((b) => idsA.has(b.id)))
57299
+ return;
57300
+ return {
57301
+ class: "Transformation",
57302
+ method: "applyMatrix",
57303
+ items: opB.items.map((b) => {
57304
+ const a2 = opA.items.find((i) => i.id === b.id);
57305
+ return {
57306
+ id: b.id,
57307
+ matrix: {
57308
+ translateX: a2.matrix.translateX + b.matrix.translateX,
57309
+ translateY: a2.matrix.translateY + b.matrix.translateY,
57310
+ scaleX: a2.matrix.scaleX * b.matrix.scaleX,
57311
+ scaleY: a2.matrix.scaleY * b.matrix.scaleY,
57312
+ shearX: 0,
57313
+ shearY: 0
57314
+ }
57315
+ };
57316
+ }),
57317
+ timeStamp: opB.timeStamp
57318
+ };
57319
+ }
57320
+ if (!areItemsTheSame(opA, opB)) {
57384
57321
  return;
57385
57322
  }
57386
57323
  const method = opA.method;
57387
57324
  switch (method) {
57388
- case "applyMatrix":
57389
- if (opB.method !== method) {
57390
- return;
57391
- }
57392
- return {
57393
- class: "Transformation",
57394
- method: "applyMatrix",
57395
- item: opA.item,
57396
- matrix: {
57397
- translateX: opA.matrix.translateX + opB.matrix.translateX,
57398
- translateY: opA.matrix.translateY + opB.matrix.translateY,
57399
- scaleX: opA.matrix.scaleX * opB.matrix.scaleX,
57400
- scaleY: opA.matrix.scaleY * opB.matrix.scaleY,
57401
- shearX: 0,
57402
- shearY: 0
57403
- },
57404
- timeStamp: opB.timeStamp
57405
- };
57406
57325
  case "translateBy":
57407
57326
  if (opB.method !== method) {
57408
57327
  return;
@@ -57456,130 +57375,10 @@ function mergeTransformationOperations(opA, opB) {
57456
57375
  },
57457
57376
  timeStamp: opB.timeStamp
57458
57377
  };
57459
- case "transformMany":
57460
- const items = mergeItems(opA, opB);
57461
- if (opB.method !== method) {
57462
- return;
57463
- }
57464
- return {
57465
- class: "Transformation",
57466
- method: "transformMany",
57467
- items,
57468
- timeStamp: opB.timeStamp
57469
- };
57470
57378
  default:
57471
57379
  return;
57472
57380
  }
57473
57381
  }
57474
- function mergeItems(opA, opB) {
57475
- if (opA.method === "transformMany" && opB.method === "transformMany") {
57476
- const resolve2 = (currScale, currTranslate, opB2) => {
57477
- switch (opB2.method) {
57478
- case "scaleByTranslateBy":
57479
- return {
57480
- scale: {
57481
- x: currScale ? currScale.x * opB2.scale.x : opB2.scale.x,
57482
- y: currScale ? currScale.y * opB2.scale.y : opB2.scale.y
57483
- },
57484
- translate: {
57485
- x: currTranslate ? currTranslate.x + opB2.translate.x : opB2.translate.x,
57486
- y: currTranslate ? currTranslate.y + opB2.translate.y : opB2.translate.y
57487
- }
57488
- };
57489
- case "scaleBy":
57490
- return {
57491
- scale: {
57492
- x: currScale ? currScale.x * opB2.x : opB2.x,
57493
- y: currScale ? currScale.y * opB2.y : opB2.y
57494
- },
57495
- translate: {
57496
- x: currTranslate ? currTranslate.x : 0,
57497
- y: currTranslate ? currTranslate.y : 0
57498
- }
57499
- };
57500
- case "translateBy":
57501
- return {
57502
- scale: {
57503
- x: currScale ? currScale.x : 1,
57504
- y: currScale ? currScale.y : 1
57505
- },
57506
- translate: {
57507
- x: currTranslate ? currTranslate.x + opB2.x : opB2.x,
57508
- y: currTranslate ? currTranslate.y + opB2.y : opB2.y
57509
- }
57510
- };
57511
- }
57512
- return;
57513
- };
57514
- const items = {};
57515
- Object.keys(opB.items).forEach((itemId) => {
57516
- if (opA.items[itemId] !== undefined) {
57517
- if (opA.items[itemId].method === "applyMatrix" && opB.items[itemId].method === "applyMatrix") {
57518
- const a2 = opA.items[itemId].matrix;
57519
- const b = opB.items[itemId].matrix;
57520
- items[itemId] = {
57521
- class: "Transformation",
57522
- method: "applyMatrix",
57523
- item: [itemId],
57524
- matrix: {
57525
- translateX: a2.translateX + b.translateX,
57526
- translateY: a2.translateY + b.translateY,
57527
- scaleX: a2.scaleX * b.scaleX,
57528
- scaleY: a2.scaleY * b.scaleY,
57529
- shearX: 0,
57530
- shearY: 0
57531
- }
57532
- };
57533
- } else if (opA.items[itemId].method === "scaleByTranslateBy") {
57534
- const newTransformation = resolve2(opA.items[itemId].scale, opA.items[itemId].translate, opB.items[itemId]);
57535
- if (!newTransformation) {
57536
- items[itemId] = opB.items[itemId];
57537
- } else {
57538
- items[itemId] = {
57539
- class: "Transformation",
57540
- method: "scaleByTranslateBy",
57541
- item: [itemId],
57542
- scale: newTransformation.scale,
57543
- translate: newTransformation.translate
57544
- };
57545
- }
57546
- } else if (opA.items[itemId].method === "scaleBy") {
57547
- const newTransformation = resolve2({ x: opA.items[itemId].x, y: opA.items[itemId].y }, undefined, opB.items[itemId]);
57548
- if (!newTransformation) {
57549
- items[itemId] = opB.items[itemId];
57550
- } else {
57551
- items[itemId] = {
57552
- class: "Transformation",
57553
- method: "scaleByTranslateBy",
57554
- item: [itemId],
57555
- scale: newTransformation.scale,
57556
- translate: newTransformation.translate
57557
- };
57558
- }
57559
- } else if (opA.items[itemId].method === "translateBy") {
57560
- const newTransformation = resolve2(undefined, { x: opA.items[itemId].x, y: opA.items[itemId].y }, opB.items[itemId]);
57561
- if (!newTransformation) {
57562
- items[itemId] = opB.items[itemId];
57563
- } else {
57564
- items[itemId] = {
57565
- class: "Transformation",
57566
- method: "scaleByTranslateBy",
57567
- item: [itemId],
57568
- scale: newTransformation.scale,
57569
- translate: newTransformation.translate
57570
- };
57571
- }
57572
- } else {
57573
- items[itemId] = opB.items[itemId];
57574
- }
57575
- } else {
57576
- items[itemId] = opB.items[itemId];
57577
- }
57578
- });
57579
- return items;
57580
- }
57581
- return;
57582
- }
57583
57382
  function mergeRichTextOperations(opA, opB) {
57584
57383
  if (!areItemsTheSame(opA, opB)) {
57585
57384
  return;