microboard-temp 0.5.22 → 0.5.24

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.
@@ -7493,14 +7493,7 @@ class Transformation {
7493
7493
  this.isLocked = data.isLocked;
7494
7494
  }
7495
7495
  if (data.rotate) {
7496
- if (data.dimension) {
7497
- this.matrix.rotateByObjectCenter(data.rotate, {
7498
- width: data.dimension.width,
7499
- height: data.dimension.height
7500
- }, { x: data.scaleX, y: data.scaleY });
7501
- } else {
7502
- this.matrix.rotateBy(data.rotate);
7503
- }
7496
+ this.rotate = data.rotate;
7504
7497
  }
7505
7498
  this.subject.publish(this, {
7506
7499
  class: "Transformation",
@@ -7635,7 +7628,6 @@ class Transformation {
7635
7628
  }
7636
7629
  }
7637
7630
  this.rotate = degree;
7638
- this.matrix.rotateBy(degree);
7639
7631
  }
7640
7632
  applyRotateBy(degree) {
7641
7633
  this.rotateTo(this.rotate + degree);
@@ -21554,6 +21546,9 @@ class BaseItem extends Mbr {
21554
21546
  newData: { childIds: childrenArr.map((child) => child.getId()) }
21555
21547
  });
21556
21548
  }
21549
+ rotate(clockwise = true) {
21550
+ this.transformation.rotateBy(clockwise ? 90 : -90);
21551
+ }
21557
21552
  emitNesting(children) {
21558
21553
  const itemsToAdd = [];
21559
21554
  const itemsToRemove = [];
@@ -21586,6 +21581,9 @@ class BaseItem extends Mbr {
21586
21581
  }
21587
21582
  return false;
21588
21583
  }
21584
+ getMbr() {
21585
+ return new Mbr(this.left, this.top, this.right, this.bottom);
21586
+ }
21589
21587
  applyAddChildren(childIds) {
21590
21588
  if (!this.index) {
21591
21589
  return;
@@ -47883,7 +47881,16 @@ class Card extends BaseItem {
47883
47881
  const ctx = context.ctx;
47884
47882
  if (this.imageToRender && this.imageToRender.complete) {
47885
47883
  ctx.save();
47886
- ctx.drawImage(this.imageToRender, typeof left === "number" ? left : this.left, typeof top === "number" ? top : this.top, conf.CARD_DIMENSIONS.width, conf.CARD_DIMENSIONS.height);
47884
+ let { x: centerX, y: centerY } = this.getMbr().getCenter();
47885
+ const width2 = this.getWidth();
47886
+ const height3 = this.getHeight();
47887
+ if (typeof left === "number" && typeof top === "number") {
47888
+ centerX = left + width2 / 2;
47889
+ centerX = top + height3 / 2;
47890
+ }
47891
+ ctx.translate(centerX, centerY);
47892
+ ctx.rotate(this.transformation.getRotation() * Math.PI / 180);
47893
+ ctx.drawImage(this.imageToRender, -width2 / 2, -height3 / 2, width2, height3);
47887
47894
  ctx.restore();
47888
47895
  }
47889
47896
  }
@@ -47903,10 +47910,22 @@ class Card extends BaseItem {
47903
47910
  }
47904
47911
  updateMbr() {
47905
47912
  const { translateX, translateY, scaleX, scaleY } = this.transformation.matrix;
47906
- this.left = translateX;
47907
- this.top = translateY;
47908
- this.right = this.left + conf.CARD_DIMENSIONS.width * scaleX;
47909
- this.bottom = this.top + conf.CARD_DIMENSIONS.height * scaleY;
47913
+ const rotation = this.transformation.getRotation();
47914
+ const height3 = conf.CARD_DIMENSIONS.height * scaleY;
47915
+ const width2 = conf.CARD_DIMENSIONS.width * scaleX;
47916
+ if (rotation % 180 === 0) {
47917
+ this.left = translateX;
47918
+ this.top = translateY;
47919
+ this.right = this.left + width2;
47920
+ this.bottom = this.top + height3;
47921
+ } else {
47922
+ const centerX = translateX + width2 / 2;
47923
+ const centerY = translateY + height3 / 2;
47924
+ this.left = centerX - height3 / 2;
47925
+ this.top = centerY - width2 / 2;
47926
+ this.right = this.left + height3;
47927
+ this.bottom = this.top + width2;
47928
+ }
47910
47929
  }
47911
47930
  getPath() {
47912
47931
  return new Path(this.getMbr().getLines());
@@ -54081,7 +54100,7 @@ class Board {
54081
54100
  itemData.transformation.translateX = translateX - minX + x;
54082
54101
  itemData.transformation.translateY = translateY - minY + y;
54083
54102
  }
54084
- if ("children" in itemData && itemData.children?.length) {
54103
+ if (itemData.itemType !== "RichText" && "children" in itemData && itemData.children?.length) {
54085
54104
  itemData.children = itemData.children.map((childId) => newItemIdMap[childId]);
54086
54105
  }
54087
54106
  newMap[newItemId] = itemData;
package/dist/cjs/index.js CHANGED
@@ -7493,14 +7493,7 @@ class Transformation {
7493
7493
  this.isLocked = data.isLocked;
7494
7494
  }
7495
7495
  if (data.rotate) {
7496
- if (data.dimension) {
7497
- this.matrix.rotateByObjectCenter(data.rotate, {
7498
- width: data.dimension.width,
7499
- height: data.dimension.height
7500
- }, { x: data.scaleX, y: data.scaleY });
7501
- } else {
7502
- this.matrix.rotateBy(data.rotate);
7503
- }
7496
+ this.rotate = data.rotate;
7504
7497
  }
7505
7498
  this.subject.publish(this, {
7506
7499
  class: "Transformation",
@@ -7635,7 +7628,6 @@ class Transformation {
7635
7628
  }
7636
7629
  }
7637
7630
  this.rotate = degree;
7638
- this.matrix.rotateBy(degree);
7639
7631
  }
7640
7632
  applyRotateBy(degree) {
7641
7633
  this.rotateTo(this.rotate + degree);
@@ -21554,6 +21546,9 @@ class BaseItem extends Mbr {
21554
21546
  newData: { childIds: childrenArr.map((child) => child.getId()) }
21555
21547
  });
21556
21548
  }
21549
+ rotate(clockwise = true) {
21550
+ this.transformation.rotateBy(clockwise ? 90 : -90);
21551
+ }
21557
21552
  emitNesting(children) {
21558
21553
  const itemsToAdd = [];
21559
21554
  const itemsToRemove = [];
@@ -21586,6 +21581,9 @@ class BaseItem extends Mbr {
21586
21581
  }
21587
21582
  return false;
21588
21583
  }
21584
+ getMbr() {
21585
+ return new Mbr(this.left, this.top, this.right, this.bottom);
21586
+ }
21589
21587
  applyAddChildren(childIds) {
21590
21588
  if (!this.index) {
21591
21589
  return;
@@ -47883,7 +47881,16 @@ class Card extends BaseItem {
47883
47881
  const ctx = context.ctx;
47884
47882
  if (this.imageToRender && this.imageToRender.complete) {
47885
47883
  ctx.save();
47886
- ctx.drawImage(this.imageToRender, typeof left === "number" ? left : this.left, typeof top === "number" ? top : this.top, conf.CARD_DIMENSIONS.width, conf.CARD_DIMENSIONS.height);
47884
+ let { x: centerX, y: centerY } = this.getMbr().getCenter();
47885
+ const width2 = this.getWidth();
47886
+ const height3 = this.getHeight();
47887
+ if (typeof left === "number" && typeof top === "number") {
47888
+ centerX = left + width2 / 2;
47889
+ centerX = top + height3 / 2;
47890
+ }
47891
+ ctx.translate(centerX, centerY);
47892
+ ctx.rotate(this.transformation.getRotation() * Math.PI / 180);
47893
+ ctx.drawImage(this.imageToRender, -width2 / 2, -height3 / 2, width2, height3);
47887
47894
  ctx.restore();
47888
47895
  }
47889
47896
  }
@@ -47903,10 +47910,22 @@ class Card extends BaseItem {
47903
47910
  }
47904
47911
  updateMbr() {
47905
47912
  const { translateX, translateY, scaleX, scaleY } = this.transformation.matrix;
47906
- this.left = translateX;
47907
- this.top = translateY;
47908
- this.right = this.left + conf.CARD_DIMENSIONS.width * scaleX;
47909
- this.bottom = this.top + conf.CARD_DIMENSIONS.height * scaleY;
47913
+ const rotation = this.transformation.getRotation();
47914
+ const height3 = conf.CARD_DIMENSIONS.height * scaleY;
47915
+ const width2 = conf.CARD_DIMENSIONS.width * scaleX;
47916
+ if (rotation % 180 === 0) {
47917
+ this.left = translateX;
47918
+ this.top = translateY;
47919
+ this.right = this.left + width2;
47920
+ this.bottom = this.top + height3;
47921
+ } else {
47922
+ const centerX = translateX + width2 / 2;
47923
+ const centerY = translateY + height3 / 2;
47924
+ this.left = centerX - height3 / 2;
47925
+ this.top = centerY - width2 / 2;
47926
+ this.right = this.left + height3;
47927
+ this.bottom = this.top + width2;
47928
+ }
47910
47929
  }
47911
47930
  getPath() {
47912
47931
  return new Path(this.getMbr().getLines());
@@ -54081,7 +54100,7 @@ class Board {
54081
54100
  itemData.transformation.translateX = translateX - minX + x;
54082
54101
  itemData.transformation.translateY = translateY - minY + y;
54083
54102
  }
54084
- if ("children" in itemData && itemData.children?.length) {
54103
+ if (itemData.itemType !== "RichText" && "children" in itemData && itemData.children?.length) {
54085
54104
  itemData.children = itemData.children.map((childId) => newItemIdMap[childId]);
54086
54105
  }
54087
54106
  newMap[newItemId] = itemData;
package/dist/cjs/node.js CHANGED
@@ -8530,14 +8530,7 @@ class Transformation {
8530
8530
  this.isLocked = data.isLocked;
8531
8531
  }
8532
8532
  if (data.rotate) {
8533
- if (data.dimension) {
8534
- this.matrix.rotateByObjectCenter(data.rotate, {
8535
- width: data.dimension.width,
8536
- height: data.dimension.height
8537
- }, { x: data.scaleX, y: data.scaleY });
8538
- } else {
8539
- this.matrix.rotateBy(data.rotate);
8540
- }
8533
+ this.rotate = data.rotate;
8541
8534
  }
8542
8535
  this.subject.publish(this, {
8543
8536
  class: "Transformation",
@@ -8672,7 +8665,6 @@ class Transformation {
8672
8665
  }
8673
8666
  }
8674
8667
  this.rotate = degree;
8675
- this.matrix.rotateBy(degree);
8676
8668
  }
8677
8669
  applyRotateBy(degree) {
8678
8670
  this.rotateTo(this.rotate + degree);
@@ -24026,6 +24018,9 @@ class BaseItem extends Mbr {
24026
24018
  newData: { childIds: childrenArr.map((child) => child.getId()) }
24027
24019
  });
24028
24020
  }
24021
+ rotate(clockwise = true) {
24022
+ this.transformation.rotateBy(clockwise ? 90 : -90);
24023
+ }
24029
24024
  emitNesting(children) {
24030
24025
  const itemsToAdd = [];
24031
24026
  const itemsToRemove = [];
@@ -24058,6 +24053,9 @@ class BaseItem extends Mbr {
24058
24053
  }
24059
24054
  return false;
24060
24055
  }
24056
+ getMbr() {
24057
+ return new Mbr(this.left, this.top, this.right, this.bottom);
24058
+ }
24061
24059
  applyAddChildren(childIds) {
24062
24060
  if (!this.index) {
24063
24061
  return;
@@ -50356,7 +50354,16 @@ class Card extends BaseItem {
50356
50354
  const ctx = context.ctx;
50357
50355
  if (this.imageToRender && this.imageToRender.complete) {
50358
50356
  ctx.save();
50359
- ctx.drawImage(this.imageToRender, typeof left === "number" ? left : this.left, typeof top === "number" ? top : this.top, conf.CARD_DIMENSIONS.width, conf.CARD_DIMENSIONS.height);
50357
+ let { x: centerX, y: centerY } = this.getMbr().getCenter();
50358
+ const width2 = this.getWidth();
50359
+ const height3 = this.getHeight();
50360
+ if (typeof left === "number" && typeof top === "number") {
50361
+ centerX = left + width2 / 2;
50362
+ centerX = top + height3 / 2;
50363
+ }
50364
+ ctx.translate(centerX, centerY);
50365
+ ctx.rotate(this.transformation.getRotation() * Math.PI / 180);
50366
+ ctx.drawImage(this.imageToRender, -width2 / 2, -height3 / 2, width2, height3);
50360
50367
  ctx.restore();
50361
50368
  }
50362
50369
  }
@@ -50376,10 +50383,22 @@ class Card extends BaseItem {
50376
50383
  }
50377
50384
  updateMbr() {
50378
50385
  const { translateX, translateY, scaleX, scaleY } = this.transformation.matrix;
50379
- this.left = translateX;
50380
- this.top = translateY;
50381
- this.right = this.left + conf.CARD_DIMENSIONS.width * scaleX;
50382
- this.bottom = this.top + conf.CARD_DIMENSIONS.height * scaleY;
50386
+ const rotation = this.transformation.getRotation();
50387
+ const height3 = conf.CARD_DIMENSIONS.height * scaleY;
50388
+ const width2 = conf.CARD_DIMENSIONS.width * scaleX;
50389
+ if (rotation % 180 === 0) {
50390
+ this.left = translateX;
50391
+ this.top = translateY;
50392
+ this.right = this.left + width2;
50393
+ this.bottom = this.top + height3;
50394
+ } else {
50395
+ const centerX = translateX + width2 / 2;
50396
+ const centerY = translateY + height3 / 2;
50397
+ this.left = centerX - height3 / 2;
50398
+ this.top = centerY - width2 / 2;
50399
+ this.right = this.left + height3;
50400
+ this.bottom = this.top + width2;
50401
+ }
50383
50402
  }
50384
50403
  getPath() {
50385
50404
  return new Path(this.getMbr().getLines());
@@ -56554,7 +56573,7 @@ class Board {
56554
56573
  itemData.transformation.translateX = translateX - minX + x;
56555
56574
  itemData.transformation.translateY = translateY - minY + y;
56556
56575
  }
56557
- if ("children" in itemData && itemData.children?.length) {
56576
+ if (itemData.itemType !== "RichText" && "children" in itemData && itemData.children?.length) {
56558
56577
  itemData.children = itemData.children.map((childId) => newItemIdMap[childId]);
56559
56578
  }
56560
56579
  newMap[newItemId] = itemData;
@@ -7330,14 +7330,7 @@ class Transformation {
7330
7330
  this.isLocked = data.isLocked;
7331
7331
  }
7332
7332
  if (data.rotate) {
7333
- if (data.dimension) {
7334
- this.matrix.rotateByObjectCenter(data.rotate, {
7335
- width: data.dimension.width,
7336
- height: data.dimension.height
7337
- }, { x: data.scaleX, y: data.scaleY });
7338
- } else {
7339
- this.matrix.rotateBy(data.rotate);
7340
- }
7333
+ this.rotate = data.rotate;
7341
7334
  }
7342
7335
  this.subject.publish(this, {
7343
7336
  class: "Transformation",
@@ -7472,7 +7465,6 @@ class Transformation {
7472
7465
  }
7473
7466
  }
7474
7467
  this.rotate = degree;
7475
- this.matrix.rotateBy(degree);
7476
7468
  }
7477
7469
  applyRotateBy(degree) {
7478
7470
  this.rotateTo(this.rotate + degree);
@@ -21400,6 +21392,9 @@ class BaseItem extends Mbr {
21400
21392
  newData: { childIds: childrenArr.map((child) => child.getId()) }
21401
21393
  });
21402
21394
  }
21395
+ rotate(clockwise = true) {
21396
+ this.transformation.rotateBy(clockwise ? 90 : -90);
21397
+ }
21403
21398
  emitNesting(children) {
21404
21399
  const itemsToAdd = [];
21405
21400
  const itemsToRemove = [];
@@ -21432,6 +21427,9 @@ class BaseItem extends Mbr {
21432
21427
  }
21433
21428
  return false;
21434
21429
  }
21430
+ getMbr() {
21431
+ return new Mbr(this.left, this.top, this.right, this.bottom);
21432
+ }
21435
21433
  applyAddChildren(childIds) {
21436
21434
  if (!this.index) {
21437
21435
  return;
@@ -47729,7 +47727,16 @@ class Card extends BaseItem {
47729
47727
  const ctx = context.ctx;
47730
47728
  if (this.imageToRender && this.imageToRender.complete) {
47731
47729
  ctx.save();
47732
- ctx.drawImage(this.imageToRender, typeof left === "number" ? left : this.left, typeof top === "number" ? top : this.top, conf.CARD_DIMENSIONS.width, conf.CARD_DIMENSIONS.height);
47730
+ let { x: centerX, y: centerY } = this.getMbr().getCenter();
47731
+ const width2 = this.getWidth();
47732
+ const height3 = this.getHeight();
47733
+ if (typeof left === "number" && typeof top === "number") {
47734
+ centerX = left + width2 / 2;
47735
+ centerX = top + height3 / 2;
47736
+ }
47737
+ ctx.translate(centerX, centerY);
47738
+ ctx.rotate(this.transformation.getRotation() * Math.PI / 180);
47739
+ ctx.drawImage(this.imageToRender, -width2 / 2, -height3 / 2, width2, height3);
47733
47740
  ctx.restore();
47734
47741
  }
47735
47742
  }
@@ -47749,10 +47756,22 @@ class Card extends BaseItem {
47749
47756
  }
47750
47757
  updateMbr() {
47751
47758
  const { translateX, translateY, scaleX, scaleY } = this.transformation.matrix;
47752
- this.left = translateX;
47753
- this.top = translateY;
47754
- this.right = this.left + conf.CARD_DIMENSIONS.width * scaleX;
47755
- this.bottom = this.top + conf.CARD_DIMENSIONS.height * scaleY;
47759
+ const rotation = this.transformation.getRotation();
47760
+ const height3 = conf.CARD_DIMENSIONS.height * scaleY;
47761
+ const width2 = conf.CARD_DIMENSIONS.width * scaleX;
47762
+ if (rotation % 180 === 0) {
47763
+ this.left = translateX;
47764
+ this.top = translateY;
47765
+ this.right = this.left + width2;
47766
+ this.bottom = this.top + height3;
47767
+ } else {
47768
+ const centerX = translateX + width2 / 2;
47769
+ const centerY = translateY + height3 / 2;
47770
+ this.left = centerX - height3 / 2;
47771
+ this.top = centerY - width2 / 2;
47772
+ this.right = this.left + height3;
47773
+ this.bottom = this.top + width2;
47774
+ }
47756
47775
  }
47757
47776
  getPath() {
47758
47777
  return new Path(this.getMbr().getLines());
@@ -53927,7 +53946,7 @@ class Board {
53927
53946
  itemData.transformation.translateX = translateX - minX + x;
53928
53947
  itemData.transformation.translateY = translateY - minY + y;
53929
53948
  }
53930
- if ("children" in itemData && itemData.children?.length) {
53949
+ if (itemData.itemType !== "RichText" && "children" in itemData && itemData.children?.length) {
53931
53950
  itemData.children = itemData.children.map((childId) => newItemIdMap[childId]);
53932
53951
  }
53933
53952
  newMap[newItemId] = itemData;
package/dist/esm/index.js CHANGED
@@ -7323,14 +7323,7 @@ class Transformation {
7323
7323
  this.isLocked = data.isLocked;
7324
7324
  }
7325
7325
  if (data.rotate) {
7326
- if (data.dimension) {
7327
- this.matrix.rotateByObjectCenter(data.rotate, {
7328
- width: data.dimension.width,
7329
- height: data.dimension.height
7330
- }, { x: data.scaleX, y: data.scaleY });
7331
- } else {
7332
- this.matrix.rotateBy(data.rotate);
7333
- }
7326
+ this.rotate = data.rotate;
7334
7327
  }
7335
7328
  this.subject.publish(this, {
7336
7329
  class: "Transformation",
@@ -7465,7 +7458,6 @@ class Transformation {
7465
7458
  }
7466
7459
  }
7467
7460
  this.rotate = degree;
7468
- this.matrix.rotateBy(degree);
7469
7461
  }
7470
7462
  applyRotateBy(degree) {
7471
7463
  this.rotateTo(this.rotate + degree);
@@ -21393,6 +21385,9 @@ class BaseItem extends Mbr {
21393
21385
  newData: { childIds: childrenArr.map((child) => child.getId()) }
21394
21386
  });
21395
21387
  }
21388
+ rotate(clockwise = true) {
21389
+ this.transformation.rotateBy(clockwise ? 90 : -90);
21390
+ }
21396
21391
  emitNesting(children) {
21397
21392
  const itemsToAdd = [];
21398
21393
  const itemsToRemove = [];
@@ -21425,6 +21420,9 @@ class BaseItem extends Mbr {
21425
21420
  }
21426
21421
  return false;
21427
21422
  }
21423
+ getMbr() {
21424
+ return new Mbr(this.left, this.top, this.right, this.bottom);
21425
+ }
21428
21426
  applyAddChildren(childIds) {
21429
21427
  if (!this.index) {
21430
21428
  return;
@@ -47722,7 +47720,16 @@ class Card extends BaseItem {
47722
47720
  const ctx = context.ctx;
47723
47721
  if (this.imageToRender && this.imageToRender.complete) {
47724
47722
  ctx.save();
47725
- ctx.drawImage(this.imageToRender, typeof left === "number" ? left : this.left, typeof top === "number" ? top : this.top, conf.CARD_DIMENSIONS.width, conf.CARD_DIMENSIONS.height);
47723
+ let { x: centerX, y: centerY } = this.getMbr().getCenter();
47724
+ const width2 = this.getWidth();
47725
+ const height3 = this.getHeight();
47726
+ if (typeof left === "number" && typeof top === "number") {
47727
+ centerX = left + width2 / 2;
47728
+ centerX = top + height3 / 2;
47729
+ }
47730
+ ctx.translate(centerX, centerY);
47731
+ ctx.rotate(this.transformation.getRotation() * Math.PI / 180);
47732
+ ctx.drawImage(this.imageToRender, -width2 / 2, -height3 / 2, width2, height3);
47726
47733
  ctx.restore();
47727
47734
  }
47728
47735
  }
@@ -47742,10 +47749,22 @@ class Card extends BaseItem {
47742
47749
  }
47743
47750
  updateMbr() {
47744
47751
  const { translateX, translateY, scaleX, scaleY } = this.transformation.matrix;
47745
- this.left = translateX;
47746
- this.top = translateY;
47747
- this.right = this.left + conf.CARD_DIMENSIONS.width * scaleX;
47748
- this.bottom = this.top + conf.CARD_DIMENSIONS.height * scaleY;
47752
+ const rotation = this.transformation.getRotation();
47753
+ const height3 = conf.CARD_DIMENSIONS.height * scaleY;
47754
+ const width2 = conf.CARD_DIMENSIONS.width * scaleX;
47755
+ if (rotation % 180 === 0) {
47756
+ this.left = translateX;
47757
+ this.top = translateY;
47758
+ this.right = this.left + width2;
47759
+ this.bottom = this.top + height3;
47760
+ } else {
47761
+ const centerX = translateX + width2 / 2;
47762
+ const centerY = translateY + height3 / 2;
47763
+ this.left = centerX - height3 / 2;
47764
+ this.top = centerY - width2 / 2;
47765
+ this.right = this.left + height3;
47766
+ this.bottom = this.top + width2;
47767
+ }
47749
47768
  }
47750
47769
  getPath() {
47751
47770
  return new Path(this.getMbr().getLines());
@@ -53920,7 +53939,7 @@ class Board {
53920
53939
  itemData.transformation.translateX = translateX - minX + x;
53921
53940
  itemData.transformation.translateY = translateY - minY + y;
53922
53941
  }
53923
- if ("children" in itemData && itemData.children?.length) {
53942
+ if (itemData.itemType !== "RichText" && "children" in itemData && itemData.children?.length) {
53924
53943
  itemData.children = itemData.children.map((childId) => newItemIdMap[childId]);
53925
53944
  }
53926
53945
  newMap[newItemId] = itemData;
package/dist/esm/node.js CHANGED
@@ -8107,14 +8107,7 @@ class Transformation {
8107
8107
  this.isLocked = data.isLocked;
8108
8108
  }
8109
8109
  if (data.rotate) {
8110
- if (data.dimension) {
8111
- this.matrix.rotateByObjectCenter(data.rotate, {
8112
- width: data.dimension.width,
8113
- height: data.dimension.height
8114
- }, { x: data.scaleX, y: data.scaleY });
8115
- } else {
8116
- this.matrix.rotateBy(data.rotate);
8117
- }
8110
+ this.rotate = data.rotate;
8118
8111
  }
8119
8112
  this.subject.publish(this, {
8120
8113
  class: "Transformation",
@@ -8249,7 +8242,6 @@ class Transformation {
8249
8242
  }
8250
8243
  }
8251
8244
  this.rotate = degree;
8252
- this.matrix.rotateBy(degree);
8253
8245
  }
8254
8246
  applyRotateBy(degree) {
8255
8247
  this.rotateTo(this.rotate + degree);
@@ -23860,6 +23852,9 @@ class BaseItem extends Mbr {
23860
23852
  newData: { childIds: childrenArr.map((child) => child.getId()) }
23861
23853
  });
23862
23854
  }
23855
+ rotate(clockwise = true) {
23856
+ this.transformation.rotateBy(clockwise ? 90 : -90);
23857
+ }
23863
23858
  emitNesting(children) {
23864
23859
  const itemsToAdd = [];
23865
23860
  const itemsToRemove = [];
@@ -23892,6 +23887,9 @@ class BaseItem extends Mbr {
23892
23887
  }
23893
23888
  return false;
23894
23889
  }
23890
+ getMbr() {
23891
+ return new Mbr(this.left, this.top, this.right, this.bottom);
23892
+ }
23895
23893
  applyAddChildren(childIds) {
23896
23894
  if (!this.index) {
23897
23895
  return;
@@ -50190,7 +50188,16 @@ class Card extends BaseItem {
50190
50188
  const ctx = context.ctx;
50191
50189
  if (this.imageToRender && this.imageToRender.complete) {
50192
50190
  ctx.save();
50193
- ctx.drawImage(this.imageToRender, typeof left === "number" ? left : this.left, typeof top === "number" ? top : this.top, conf.CARD_DIMENSIONS.width, conf.CARD_DIMENSIONS.height);
50191
+ let { x: centerX, y: centerY } = this.getMbr().getCenter();
50192
+ const width2 = this.getWidth();
50193
+ const height3 = this.getHeight();
50194
+ if (typeof left === "number" && typeof top === "number") {
50195
+ centerX = left + width2 / 2;
50196
+ centerX = top + height3 / 2;
50197
+ }
50198
+ ctx.translate(centerX, centerY);
50199
+ ctx.rotate(this.transformation.getRotation() * Math.PI / 180);
50200
+ ctx.drawImage(this.imageToRender, -width2 / 2, -height3 / 2, width2, height3);
50194
50201
  ctx.restore();
50195
50202
  }
50196
50203
  }
@@ -50210,10 +50217,22 @@ class Card extends BaseItem {
50210
50217
  }
50211
50218
  updateMbr() {
50212
50219
  const { translateX, translateY, scaleX, scaleY } = this.transformation.matrix;
50213
- this.left = translateX;
50214
- this.top = translateY;
50215
- this.right = this.left + conf.CARD_DIMENSIONS.width * scaleX;
50216
- this.bottom = this.top + conf.CARD_DIMENSIONS.height * scaleY;
50220
+ const rotation = this.transformation.getRotation();
50221
+ const height3 = conf.CARD_DIMENSIONS.height * scaleY;
50222
+ const width2 = conf.CARD_DIMENSIONS.width * scaleX;
50223
+ if (rotation % 180 === 0) {
50224
+ this.left = translateX;
50225
+ this.top = translateY;
50226
+ this.right = this.left + width2;
50227
+ this.bottom = this.top + height3;
50228
+ } else {
50229
+ const centerX = translateX + width2 / 2;
50230
+ const centerY = translateY + height3 / 2;
50231
+ this.left = centerX - height3 / 2;
50232
+ this.top = centerY - width2 / 2;
50233
+ this.right = this.left + height3;
50234
+ this.bottom = this.top + width2;
50235
+ }
50217
50236
  }
50218
50237
  getPath() {
50219
50238
  return new Path(this.getMbr().getLines());
@@ -56388,7 +56407,7 @@ class Board {
56388
56407
  itemData.transformation.translateX = translateX - minX + x;
56389
56408
  itemData.transformation.translateY = translateY - minY + y;
56390
56409
  }
56391
- if ("children" in itemData && itemData.children?.length) {
56410
+ if (itemData.itemType !== "RichText" && "children" in itemData && itemData.children?.length) {
56392
56411
  itemData.children = itemData.children.map((childId) => newItemIdMap[childId]);
56393
56412
  }
56394
56413
  newMap[newItemId] = itemData;
@@ -47,11 +47,13 @@ export declare class BaseItem extends Mbr implements Geometry {
47
47
  getChildrenIds(): string[] | null;
48
48
  addChildItems(children: BaseItem[]): void;
49
49
  removeChildItems(children: BaseItem[] | BaseItem): void;
50
+ rotate(clockwise?: boolean): void;
50
51
  emitNesting(children: BaseItem[]): void;
51
52
  handleNesting(item: BaseItem | Mbr, options?: {
52
53
  onlyForOut?: boolean;
53
54
  cancelIfChild?: boolean;
54
55
  }): boolean;
56
+ getMbr(): Mbr;
55
57
  applyAddChildren(childIds: string[]): void;
56
58
  applyRemoveChildren(childIds: string[]): void;
57
59
  updateMbr(): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "microboard-temp",
3
- "version": "0.5.22",
3
+ "version": "0.5.24",
4
4
  "description": "A flexible interactive whiteboard library",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",