microboard-temp 0.11.1 → 0.11.2

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.
@@ -19225,7 +19225,7 @@ class Comment {
19225
19225
  this.transform();
19226
19226
  break;
19227
19227
  case "Transformation":
19228
- this.transformation.apply(op);
19228
+ super.apply(op);
19229
19229
  break;
19230
19230
  default:
19231
19231
  return;
@@ -21867,10 +21867,9 @@ class BaseItem extends Mbr {
21867
21867
  return this.getMbr();
21868
21868
  }
21869
21869
  const container = this.board.items.getById(this.parent);
21870
- if (!container) {
21870
+ if (!container)
21871
21871
  return this.getMbr();
21872
- }
21873
- const containerWorldMatrix = container.getWorldMatrix();
21872
+ const worldMatrix = container.getWorldMatrix();
21874
21873
  const local = this.getMbr();
21875
21874
  const corners = [
21876
21875
  new Point(local.left, local.top),
@@ -21879,7 +21878,7 @@ class BaseItem extends Mbr {
21879
21878
  new Point(local.left, local.bottom)
21880
21879
  ];
21881
21880
  for (const c of corners)
21882
- containerWorldMatrix.apply(c);
21881
+ worldMatrix.apply(c);
21883
21882
  return new Mbr(Math.min(corners[0].x, corners[1].x, corners[2].x, corners[3].x), Math.min(corners[0].y, corners[1].y, corners[2].y, corners[3].y), Math.max(corners[0].x, corners[1].x, corners[2].x, corners[3].x), Math.max(corners[0].y, corners[1].y, corners[2].y, corners[3].y));
21884
21883
  }
21885
21884
  applyAddChildren(childIds) {
@@ -22328,15 +22327,29 @@ class RichText extends BaseItem {
22328
22327
  };
22329
22328
  calcAutoSize(blockNodes) {
22330
22329
  const nodes = blockNodes ? blockNodes : this.getBlockNodes();
22331
- const container = this.getLayoutContainer();
22330
+ const container = this.getTransformedContainer();
22332
22331
  const containerWidth = container.getWidth();
22333
22332
  const containerHeight = container.getHeight();
22334
- const optimal = findOptimalMaxWidthForTextAutoSize(nodes, containerWidth, containerHeight, containerWidth);
22335
- return Math.min(containerWidth / optimal.bestMaxWidth, containerHeight / optimal.bestMaxHeight);
22333
+ const worldMatrix = this.worldMatrixGetter?.();
22334
+ let effectiveWidth = containerWidth;
22335
+ let effectiveHeight = containerHeight;
22336
+ if (worldMatrix) {
22337
+ const localScaleX = this.transformation.getScale().x || 1;
22338
+ const localScaleY = this.transformation.getScale().y || 1;
22339
+ effectiveWidth = containerWidth * (worldMatrix.scaleX / localScaleX);
22340
+ effectiveHeight = containerHeight * (worldMatrix.scaleY / localScaleY);
22341
+ }
22342
+ const optimal = findOptimalMaxWidthForTextAutoSize(nodes, effectiveWidth, effectiveHeight, effectiveWidth);
22343
+ const worldTextScale = Math.min(effectiveWidth / optimal.bestMaxWidth, effectiveHeight / optimal.bestMaxHeight);
22344
+ if (worldMatrix) {
22345
+ const localScaleX = this.transformation.getScale().x || 1;
22346
+ return worldTextScale * localScaleX / worldMatrix.scaleX;
22347
+ }
22348
+ return worldTextScale;
22336
22349
  }
22337
22350
  applyAutoSizeScale(textScale, blockNodes) {
22338
22351
  const nodes = blockNodes ? blockNodes : this.getBlockNodes();
22339
- const container = this.getLayoutContainer();
22352
+ const container = this.getTransformedContainer();
22340
22353
  const containerWidth = container.getWidth();
22341
22354
  const containerHeight = container.getHeight();
22342
22355
  this.layoutNodes = getBlockNodes(nodes, containerWidth / textScale);
@@ -22458,13 +22471,6 @@ class RichText extends BaseItem {
22458
22471
  }
22459
22472
  return this.container.getTransformed(this.transformation.toMatrix());
22460
22473
  }
22461
- getLayoutContainer() {
22462
- if (this.insideOf === "Frame") {
22463
- return this.getTransformedContainer();
22464
- }
22465
- const matrix = this.worldMatrixGetter ? this.worldMatrixGetter() : this.transformation.toMatrix();
22466
- return this.container.getTransformed(matrix);
22467
- }
22468
22474
  emitWithoutApplying = (op) => {
22469
22475
  if (this.board.events) {
22470
22476
  this.board.events.emit(op);
@@ -22480,7 +22486,7 @@ class RichText extends BaseItem {
22480
22486
  apply(op) {
22481
22487
  switch (op.class) {
22482
22488
  case "Transformation":
22483
- this.transformation.apply(op);
22489
+ super.apply(op);
22484
22490
  break;
22485
22491
  case "LinkTo":
22486
22492
  this.linkTo.apply(op);
@@ -36431,7 +36437,6 @@ class AINode extends BaseItem {
36431
36437
  this.subject.publish(this);
36432
36438
  });
36433
36439
  this.text.insideOf = "AINode";
36434
- this.text.worldMatrixGetter = () => this.getWorldMatrix();
36435
36440
  this.transformPath();
36436
36441
  }
36437
36442
  transformPath() {
@@ -40028,7 +40033,7 @@ class Shape extends BaseItem {
40028
40033
  this.text.apply(op);
40029
40034
  break;
40030
40035
  case "Transformation":
40031
- this.transformation.apply(op);
40036
+ super.apply(op);
40032
40037
  break;
40033
40038
  case "LinkTo":
40034
40039
  this.linkTo.apply(op);
@@ -41805,7 +41810,7 @@ class VideoItem extends BaseItem {
41805
41810
  apply(op) {
41806
41811
  switch (op.class) {
41807
41812
  case "Transformation":
41808
- this.transformation.apply(op);
41813
+ super.apply(op);
41809
41814
  break;
41810
41815
  case "LinkTo":
41811
41816
  this.linkTo.apply(op);
@@ -42281,7 +42286,7 @@ class AudioItem extends BaseItem {
42281
42286
  apply(op) {
42282
42287
  switch (op.class) {
42283
42288
  case "Transformation":
42284
- this.transformation.apply(op);
42289
+ super.apply(op);
42285
42290
  break;
42286
42291
  case "LinkTo":
42287
42292
  this.linkTo.apply(op);
@@ -42475,7 +42480,7 @@ class Placeholder extends BaseItem {
42475
42480
  this.updateMbr();
42476
42481
  break;
42477
42482
  case "Transformation":
42478
- this.transformation.apply(op);
42483
+ super.apply(op);
42479
42484
  break;
42480
42485
  default:
42481
42486
  return;
@@ -42902,7 +42907,7 @@ class ImageItem extends BaseItem {
42902
42907
  apply(op) {
42903
42908
  switch (op.class) {
42904
42909
  case "Transformation":
42905
- this.transformation.apply(op);
42910
+ super.apply(op);
42906
42911
  break;
42907
42912
  case "LinkTo":
42908
42913
  this.linkTo.apply(op);
@@ -43330,7 +43335,7 @@ class Drawing extends BaseItem {
43330
43335
  this.updateMbr();
43331
43336
  break;
43332
43337
  case "Transformation":
43333
- this.transformation.apply(op);
43338
+ super.apply(op);
43334
43339
  break;
43335
43340
  case "LinkTo":
43336
43341
  this.linkTo.apply(op);
@@ -43493,7 +43498,7 @@ class Group extends BaseItem {
43493
43498
  }
43494
43499
  break;
43495
43500
  case "Transformation":
43496
- this.transformation.apply(op);
43501
+ super.apply(op);
43497
43502
  break;
43498
43503
  default:
43499
43504
  return;
package/dist/cjs/index.js CHANGED
@@ -19225,7 +19225,7 @@ class Comment {
19225
19225
  this.transform();
19226
19226
  break;
19227
19227
  case "Transformation":
19228
- this.transformation.apply(op);
19228
+ super.apply(op);
19229
19229
  break;
19230
19230
  default:
19231
19231
  return;
@@ -21867,10 +21867,9 @@ class BaseItem extends Mbr {
21867
21867
  return this.getMbr();
21868
21868
  }
21869
21869
  const container = this.board.items.getById(this.parent);
21870
- if (!container) {
21870
+ if (!container)
21871
21871
  return this.getMbr();
21872
- }
21873
- const containerWorldMatrix = container.getWorldMatrix();
21872
+ const worldMatrix = container.getWorldMatrix();
21874
21873
  const local = this.getMbr();
21875
21874
  const corners = [
21876
21875
  new Point(local.left, local.top),
@@ -21879,7 +21878,7 @@ class BaseItem extends Mbr {
21879
21878
  new Point(local.left, local.bottom)
21880
21879
  ];
21881
21880
  for (const c of corners)
21882
- containerWorldMatrix.apply(c);
21881
+ worldMatrix.apply(c);
21883
21882
  return new Mbr(Math.min(corners[0].x, corners[1].x, corners[2].x, corners[3].x), Math.min(corners[0].y, corners[1].y, corners[2].y, corners[3].y), Math.max(corners[0].x, corners[1].x, corners[2].x, corners[3].x), Math.max(corners[0].y, corners[1].y, corners[2].y, corners[3].y));
21884
21883
  }
21885
21884
  applyAddChildren(childIds) {
@@ -22328,15 +22327,29 @@ class RichText extends BaseItem {
22328
22327
  };
22329
22328
  calcAutoSize(blockNodes) {
22330
22329
  const nodes = blockNodes ? blockNodes : this.getBlockNodes();
22331
- const container = this.getLayoutContainer();
22330
+ const container = this.getTransformedContainer();
22332
22331
  const containerWidth = container.getWidth();
22333
22332
  const containerHeight = container.getHeight();
22334
- const optimal = findOptimalMaxWidthForTextAutoSize(nodes, containerWidth, containerHeight, containerWidth);
22335
- return Math.min(containerWidth / optimal.bestMaxWidth, containerHeight / optimal.bestMaxHeight);
22333
+ const worldMatrix = this.worldMatrixGetter?.();
22334
+ let effectiveWidth = containerWidth;
22335
+ let effectiveHeight = containerHeight;
22336
+ if (worldMatrix) {
22337
+ const localScaleX = this.transformation.getScale().x || 1;
22338
+ const localScaleY = this.transformation.getScale().y || 1;
22339
+ effectiveWidth = containerWidth * (worldMatrix.scaleX / localScaleX);
22340
+ effectiveHeight = containerHeight * (worldMatrix.scaleY / localScaleY);
22341
+ }
22342
+ const optimal = findOptimalMaxWidthForTextAutoSize(nodes, effectiveWidth, effectiveHeight, effectiveWidth);
22343
+ const worldTextScale = Math.min(effectiveWidth / optimal.bestMaxWidth, effectiveHeight / optimal.bestMaxHeight);
22344
+ if (worldMatrix) {
22345
+ const localScaleX = this.transformation.getScale().x || 1;
22346
+ return worldTextScale * localScaleX / worldMatrix.scaleX;
22347
+ }
22348
+ return worldTextScale;
22336
22349
  }
22337
22350
  applyAutoSizeScale(textScale, blockNodes) {
22338
22351
  const nodes = blockNodes ? blockNodes : this.getBlockNodes();
22339
- const container = this.getLayoutContainer();
22352
+ const container = this.getTransformedContainer();
22340
22353
  const containerWidth = container.getWidth();
22341
22354
  const containerHeight = container.getHeight();
22342
22355
  this.layoutNodes = getBlockNodes(nodes, containerWidth / textScale);
@@ -22458,13 +22471,6 @@ class RichText extends BaseItem {
22458
22471
  }
22459
22472
  return this.container.getTransformed(this.transformation.toMatrix());
22460
22473
  }
22461
- getLayoutContainer() {
22462
- if (this.insideOf === "Frame") {
22463
- return this.getTransformedContainer();
22464
- }
22465
- const matrix = this.worldMatrixGetter ? this.worldMatrixGetter() : this.transformation.toMatrix();
22466
- return this.container.getTransformed(matrix);
22467
- }
22468
22474
  emitWithoutApplying = (op) => {
22469
22475
  if (this.board.events) {
22470
22476
  this.board.events.emit(op);
@@ -22480,7 +22486,7 @@ class RichText extends BaseItem {
22480
22486
  apply(op) {
22481
22487
  switch (op.class) {
22482
22488
  case "Transformation":
22483
- this.transformation.apply(op);
22489
+ super.apply(op);
22484
22490
  break;
22485
22491
  case "LinkTo":
22486
22492
  this.linkTo.apply(op);
@@ -36431,7 +36437,6 @@ class AINode extends BaseItem {
36431
36437
  this.subject.publish(this);
36432
36438
  });
36433
36439
  this.text.insideOf = "AINode";
36434
- this.text.worldMatrixGetter = () => this.getWorldMatrix();
36435
36440
  this.transformPath();
36436
36441
  }
36437
36442
  transformPath() {
@@ -40028,7 +40033,7 @@ class Shape extends BaseItem {
40028
40033
  this.text.apply(op);
40029
40034
  break;
40030
40035
  case "Transformation":
40031
- this.transformation.apply(op);
40036
+ super.apply(op);
40032
40037
  break;
40033
40038
  case "LinkTo":
40034
40039
  this.linkTo.apply(op);
@@ -41805,7 +41810,7 @@ class VideoItem extends BaseItem {
41805
41810
  apply(op) {
41806
41811
  switch (op.class) {
41807
41812
  case "Transformation":
41808
- this.transformation.apply(op);
41813
+ super.apply(op);
41809
41814
  break;
41810
41815
  case "LinkTo":
41811
41816
  this.linkTo.apply(op);
@@ -42281,7 +42286,7 @@ class AudioItem extends BaseItem {
42281
42286
  apply(op) {
42282
42287
  switch (op.class) {
42283
42288
  case "Transformation":
42284
- this.transformation.apply(op);
42289
+ super.apply(op);
42285
42290
  break;
42286
42291
  case "LinkTo":
42287
42292
  this.linkTo.apply(op);
@@ -42475,7 +42480,7 @@ class Placeholder extends BaseItem {
42475
42480
  this.updateMbr();
42476
42481
  break;
42477
42482
  case "Transformation":
42478
- this.transformation.apply(op);
42483
+ super.apply(op);
42479
42484
  break;
42480
42485
  default:
42481
42486
  return;
@@ -42902,7 +42907,7 @@ class ImageItem extends BaseItem {
42902
42907
  apply(op) {
42903
42908
  switch (op.class) {
42904
42909
  case "Transformation":
42905
- this.transformation.apply(op);
42910
+ super.apply(op);
42906
42911
  break;
42907
42912
  case "LinkTo":
42908
42913
  this.linkTo.apply(op);
@@ -43330,7 +43335,7 @@ class Drawing extends BaseItem {
43330
43335
  this.updateMbr();
43331
43336
  break;
43332
43337
  case "Transformation":
43333
- this.transformation.apply(op);
43338
+ super.apply(op);
43334
43339
  break;
43335
43340
  case "LinkTo":
43336
43341
  this.linkTo.apply(op);
@@ -43493,7 +43498,7 @@ class Group extends BaseItem {
43493
43498
  }
43494
43499
  break;
43495
43500
  case "Transformation":
43496
- this.transformation.apply(op);
43501
+ super.apply(op);
43497
43502
  break;
43498
43503
  default:
43499
43504
  return;
package/dist/cjs/node.js CHANGED
@@ -21764,7 +21764,7 @@ class Comment {
21764
21764
  this.transform();
21765
21765
  break;
21766
21766
  case "Transformation":
21767
- this.transformation.apply(op);
21767
+ super.apply(op);
21768
21768
  break;
21769
21769
  default:
21770
21770
  return;
@@ -24339,10 +24339,9 @@ class BaseItem extends Mbr {
24339
24339
  return this.getMbr();
24340
24340
  }
24341
24341
  const container = this.board.items.getById(this.parent);
24342
- if (!container) {
24342
+ if (!container)
24343
24343
  return this.getMbr();
24344
- }
24345
- const containerWorldMatrix = container.getWorldMatrix();
24344
+ const worldMatrix = container.getWorldMatrix();
24346
24345
  const local = this.getMbr();
24347
24346
  const corners = [
24348
24347
  new Point(local.left, local.top),
@@ -24351,7 +24350,7 @@ class BaseItem extends Mbr {
24351
24350
  new Point(local.left, local.bottom)
24352
24351
  ];
24353
24352
  for (const c of corners)
24354
- containerWorldMatrix.apply(c);
24353
+ worldMatrix.apply(c);
24355
24354
  return new Mbr(Math.min(corners[0].x, corners[1].x, corners[2].x, corners[3].x), Math.min(corners[0].y, corners[1].y, corners[2].y, corners[3].y), Math.max(corners[0].x, corners[1].x, corners[2].x, corners[3].x), Math.max(corners[0].y, corners[1].y, corners[2].y, corners[3].y));
24356
24355
  }
24357
24356
  applyAddChildren(childIds) {
@@ -24800,15 +24799,29 @@ class RichText extends BaseItem {
24800
24799
  };
24801
24800
  calcAutoSize(blockNodes) {
24802
24801
  const nodes = blockNodes ? blockNodes : this.getBlockNodes();
24803
- const container = this.getLayoutContainer();
24802
+ const container = this.getTransformedContainer();
24804
24803
  const containerWidth = container.getWidth();
24805
24804
  const containerHeight = container.getHeight();
24806
- const optimal = findOptimalMaxWidthForTextAutoSize(nodes, containerWidth, containerHeight, containerWidth);
24807
- return Math.min(containerWidth / optimal.bestMaxWidth, containerHeight / optimal.bestMaxHeight);
24805
+ const worldMatrix = this.worldMatrixGetter?.();
24806
+ let effectiveWidth = containerWidth;
24807
+ let effectiveHeight = containerHeight;
24808
+ if (worldMatrix) {
24809
+ const localScaleX = this.transformation.getScale().x || 1;
24810
+ const localScaleY = this.transformation.getScale().y || 1;
24811
+ effectiveWidth = containerWidth * (worldMatrix.scaleX / localScaleX);
24812
+ effectiveHeight = containerHeight * (worldMatrix.scaleY / localScaleY);
24813
+ }
24814
+ const optimal = findOptimalMaxWidthForTextAutoSize(nodes, effectiveWidth, effectiveHeight, effectiveWidth);
24815
+ const worldTextScale = Math.min(effectiveWidth / optimal.bestMaxWidth, effectiveHeight / optimal.bestMaxHeight);
24816
+ if (worldMatrix) {
24817
+ const localScaleX = this.transformation.getScale().x || 1;
24818
+ return worldTextScale * localScaleX / worldMatrix.scaleX;
24819
+ }
24820
+ return worldTextScale;
24808
24821
  }
24809
24822
  applyAutoSizeScale(textScale, blockNodes) {
24810
24823
  const nodes = blockNodes ? blockNodes : this.getBlockNodes();
24811
- const container = this.getLayoutContainer();
24824
+ const container = this.getTransformedContainer();
24812
24825
  const containerWidth = container.getWidth();
24813
24826
  const containerHeight = container.getHeight();
24814
24827
  this.layoutNodes = getBlockNodes(nodes, containerWidth / textScale);
@@ -24930,13 +24943,6 @@ class RichText extends BaseItem {
24930
24943
  }
24931
24944
  return this.container.getTransformed(this.transformation.toMatrix());
24932
24945
  }
24933
- getLayoutContainer() {
24934
- if (this.insideOf === "Frame") {
24935
- return this.getTransformedContainer();
24936
- }
24937
- const matrix = this.worldMatrixGetter ? this.worldMatrixGetter() : this.transformation.toMatrix();
24938
- return this.container.getTransformed(matrix);
24939
- }
24940
24946
  emitWithoutApplying = (op) => {
24941
24947
  if (this.board.events) {
24942
24948
  this.board.events.emit(op);
@@ -24952,7 +24958,7 @@ class RichText extends BaseItem {
24952
24958
  apply(op) {
24953
24959
  switch (op.class) {
24954
24960
  case "Transformation":
24955
- this.transformation.apply(op);
24961
+ super.apply(op);
24956
24962
  break;
24957
24963
  case "LinkTo":
24958
24964
  this.linkTo.apply(op);
@@ -38904,7 +38910,6 @@ class AINode extends BaseItem {
38904
38910
  this.subject.publish(this);
38905
38911
  });
38906
38912
  this.text.insideOf = "AINode";
38907
- this.text.worldMatrixGetter = () => this.getWorldMatrix();
38908
38913
  this.transformPath();
38909
38914
  }
38910
38915
  transformPath() {
@@ -42501,7 +42506,7 @@ class Shape extends BaseItem {
42501
42506
  this.text.apply(op);
42502
42507
  break;
42503
42508
  case "Transformation":
42504
- this.transformation.apply(op);
42509
+ super.apply(op);
42505
42510
  break;
42506
42511
  case "LinkTo":
42507
42512
  this.linkTo.apply(op);
@@ -44278,7 +44283,7 @@ class VideoItem extends BaseItem {
44278
44283
  apply(op) {
44279
44284
  switch (op.class) {
44280
44285
  case "Transformation":
44281
- this.transformation.apply(op);
44286
+ super.apply(op);
44282
44287
  break;
44283
44288
  case "LinkTo":
44284
44289
  this.linkTo.apply(op);
@@ -44754,7 +44759,7 @@ class AudioItem extends BaseItem {
44754
44759
  apply(op) {
44755
44760
  switch (op.class) {
44756
44761
  case "Transformation":
44757
- this.transformation.apply(op);
44762
+ super.apply(op);
44758
44763
  break;
44759
44764
  case "LinkTo":
44760
44765
  this.linkTo.apply(op);
@@ -44948,7 +44953,7 @@ class Placeholder extends BaseItem {
44948
44953
  this.updateMbr();
44949
44954
  break;
44950
44955
  case "Transformation":
44951
- this.transformation.apply(op);
44956
+ super.apply(op);
44952
44957
  break;
44953
44958
  default:
44954
44959
  return;
@@ -45375,7 +45380,7 @@ class ImageItem extends BaseItem {
45375
45380
  apply(op) {
45376
45381
  switch (op.class) {
45377
45382
  case "Transformation":
45378
- this.transformation.apply(op);
45383
+ super.apply(op);
45379
45384
  break;
45380
45385
  case "LinkTo":
45381
45386
  this.linkTo.apply(op);
@@ -45803,7 +45808,7 @@ class Drawing extends BaseItem {
45803
45808
  this.updateMbr();
45804
45809
  break;
45805
45810
  case "Transformation":
45806
- this.transformation.apply(op);
45811
+ super.apply(op);
45807
45812
  break;
45808
45813
  case "LinkTo":
45809
45814
  this.linkTo.apply(op);
@@ -45966,7 +45971,7 @@ class Group extends BaseItem {
45966
45971
  }
45967
45972
  break;
45968
45973
  case "Transformation":
45969
- this.transformation.apply(op);
45974
+ super.apply(op);
45970
45975
  break;
45971
45976
  default:
45972
45977
  return;
@@ -19054,7 +19054,7 @@ class Comment {
19054
19054
  this.transform();
19055
19055
  break;
19056
19056
  case "Transformation":
19057
- this.transformation.apply(op);
19057
+ super.apply(op);
19058
19058
  break;
19059
19059
  default:
19060
19060
  return;
@@ -21696,10 +21696,9 @@ class BaseItem extends Mbr {
21696
21696
  return this.getMbr();
21697
21697
  }
21698
21698
  const container = this.board.items.getById(this.parent);
21699
- if (!container) {
21699
+ if (!container)
21700
21700
  return this.getMbr();
21701
- }
21702
- const containerWorldMatrix = container.getWorldMatrix();
21701
+ const worldMatrix = container.getWorldMatrix();
21703
21702
  const local = this.getMbr();
21704
21703
  const corners = [
21705
21704
  new Point(local.left, local.top),
@@ -21708,7 +21707,7 @@ class BaseItem extends Mbr {
21708
21707
  new Point(local.left, local.bottom)
21709
21708
  ];
21710
21709
  for (const c of corners)
21711
- containerWorldMatrix.apply(c);
21710
+ worldMatrix.apply(c);
21712
21711
  return new Mbr(Math.min(corners[0].x, corners[1].x, corners[2].x, corners[3].x), Math.min(corners[0].y, corners[1].y, corners[2].y, corners[3].y), Math.max(corners[0].x, corners[1].x, corners[2].x, corners[3].x), Math.max(corners[0].y, corners[1].y, corners[2].y, corners[3].y));
21713
21712
  }
21714
21713
  applyAddChildren(childIds) {
@@ -22157,15 +22156,29 @@ class RichText extends BaseItem {
22157
22156
  };
22158
22157
  calcAutoSize(blockNodes) {
22159
22158
  const nodes = blockNodes ? blockNodes : this.getBlockNodes();
22160
- const container = this.getLayoutContainer();
22159
+ const container = this.getTransformedContainer();
22161
22160
  const containerWidth = container.getWidth();
22162
22161
  const containerHeight = container.getHeight();
22163
- const optimal = findOptimalMaxWidthForTextAutoSize(nodes, containerWidth, containerHeight, containerWidth);
22164
- return Math.min(containerWidth / optimal.bestMaxWidth, containerHeight / optimal.bestMaxHeight);
22162
+ const worldMatrix = this.worldMatrixGetter?.();
22163
+ let effectiveWidth = containerWidth;
22164
+ let effectiveHeight = containerHeight;
22165
+ if (worldMatrix) {
22166
+ const localScaleX = this.transformation.getScale().x || 1;
22167
+ const localScaleY = this.transformation.getScale().y || 1;
22168
+ effectiveWidth = containerWidth * (worldMatrix.scaleX / localScaleX);
22169
+ effectiveHeight = containerHeight * (worldMatrix.scaleY / localScaleY);
22170
+ }
22171
+ const optimal = findOptimalMaxWidthForTextAutoSize(nodes, effectiveWidth, effectiveHeight, effectiveWidth);
22172
+ const worldTextScale = Math.min(effectiveWidth / optimal.bestMaxWidth, effectiveHeight / optimal.bestMaxHeight);
22173
+ if (worldMatrix) {
22174
+ const localScaleX = this.transformation.getScale().x || 1;
22175
+ return worldTextScale * localScaleX / worldMatrix.scaleX;
22176
+ }
22177
+ return worldTextScale;
22165
22178
  }
22166
22179
  applyAutoSizeScale(textScale, blockNodes) {
22167
22180
  const nodes = blockNodes ? blockNodes : this.getBlockNodes();
22168
- const container = this.getLayoutContainer();
22181
+ const container = this.getTransformedContainer();
22169
22182
  const containerWidth = container.getWidth();
22170
22183
  const containerHeight = container.getHeight();
22171
22184
  this.layoutNodes = getBlockNodes(nodes, containerWidth / textScale);
@@ -22287,13 +22300,6 @@ class RichText extends BaseItem {
22287
22300
  }
22288
22301
  return this.container.getTransformed(this.transformation.toMatrix());
22289
22302
  }
22290
- getLayoutContainer() {
22291
- if (this.insideOf === "Frame") {
22292
- return this.getTransformedContainer();
22293
- }
22294
- const matrix = this.worldMatrixGetter ? this.worldMatrixGetter() : this.transformation.toMatrix();
22295
- return this.container.getTransformed(matrix);
22296
- }
22297
22303
  emitWithoutApplying = (op) => {
22298
22304
  if (this.board.events) {
22299
22305
  this.board.events.emit(op);
@@ -22309,7 +22315,7 @@ class RichText extends BaseItem {
22309
22315
  apply(op) {
22310
22316
  switch (op.class) {
22311
22317
  case "Transformation":
22312
- this.transformation.apply(op);
22318
+ super.apply(op);
22313
22319
  break;
22314
22320
  case "LinkTo":
22315
22321
  this.linkTo.apply(op);
@@ -36260,7 +36266,6 @@ class AINode extends BaseItem {
36260
36266
  this.subject.publish(this);
36261
36267
  });
36262
36268
  this.text.insideOf = "AINode";
36263
- this.text.worldMatrixGetter = () => this.getWorldMatrix();
36264
36269
  this.transformPath();
36265
36270
  }
36266
36271
  transformPath() {
@@ -39857,7 +39862,7 @@ class Shape extends BaseItem {
39857
39862
  this.text.apply(op);
39858
39863
  break;
39859
39864
  case "Transformation":
39860
- this.transformation.apply(op);
39865
+ super.apply(op);
39861
39866
  break;
39862
39867
  case "LinkTo":
39863
39868
  this.linkTo.apply(op);
@@ -41634,7 +41639,7 @@ class VideoItem extends BaseItem {
41634
41639
  apply(op) {
41635
41640
  switch (op.class) {
41636
41641
  case "Transformation":
41637
- this.transformation.apply(op);
41642
+ super.apply(op);
41638
41643
  break;
41639
41644
  case "LinkTo":
41640
41645
  this.linkTo.apply(op);
@@ -42110,7 +42115,7 @@ class AudioItem extends BaseItem {
42110
42115
  apply(op) {
42111
42116
  switch (op.class) {
42112
42117
  case "Transformation":
42113
- this.transformation.apply(op);
42118
+ super.apply(op);
42114
42119
  break;
42115
42120
  case "LinkTo":
42116
42121
  this.linkTo.apply(op);
@@ -42304,7 +42309,7 @@ class Placeholder extends BaseItem {
42304
42309
  this.updateMbr();
42305
42310
  break;
42306
42311
  case "Transformation":
42307
- this.transformation.apply(op);
42312
+ super.apply(op);
42308
42313
  break;
42309
42314
  default:
42310
42315
  return;
@@ -42731,7 +42736,7 @@ class ImageItem extends BaseItem {
42731
42736
  apply(op) {
42732
42737
  switch (op.class) {
42733
42738
  case "Transformation":
42734
- this.transformation.apply(op);
42739
+ super.apply(op);
42735
42740
  break;
42736
42741
  case "LinkTo":
42737
42742
  this.linkTo.apply(op);
@@ -43159,7 +43164,7 @@ class Drawing extends BaseItem {
43159
43164
  this.updateMbr();
43160
43165
  break;
43161
43166
  case "Transformation":
43162
- this.transformation.apply(op);
43167
+ super.apply(op);
43163
43168
  break;
43164
43169
  case "LinkTo":
43165
43170
  this.linkTo.apply(op);
@@ -43322,7 +43327,7 @@ class Group extends BaseItem {
43322
43327
  }
43323
43328
  break;
43324
43329
  case "Transformation":
43325
- this.transformation.apply(op);
43330
+ super.apply(op);
43326
43331
  break;
43327
43332
  default:
43328
43333
  return;
package/dist/esm/index.js CHANGED
@@ -19047,7 +19047,7 @@ class Comment {
19047
19047
  this.transform();
19048
19048
  break;
19049
19049
  case "Transformation":
19050
- this.transformation.apply(op);
19050
+ super.apply(op);
19051
19051
  break;
19052
19052
  default:
19053
19053
  return;
@@ -21689,10 +21689,9 @@ class BaseItem extends Mbr {
21689
21689
  return this.getMbr();
21690
21690
  }
21691
21691
  const container = this.board.items.getById(this.parent);
21692
- if (!container) {
21692
+ if (!container)
21693
21693
  return this.getMbr();
21694
- }
21695
- const containerWorldMatrix = container.getWorldMatrix();
21694
+ const worldMatrix = container.getWorldMatrix();
21696
21695
  const local = this.getMbr();
21697
21696
  const corners = [
21698
21697
  new Point(local.left, local.top),
@@ -21701,7 +21700,7 @@ class BaseItem extends Mbr {
21701
21700
  new Point(local.left, local.bottom)
21702
21701
  ];
21703
21702
  for (const c of corners)
21704
- containerWorldMatrix.apply(c);
21703
+ worldMatrix.apply(c);
21705
21704
  return new Mbr(Math.min(corners[0].x, corners[1].x, corners[2].x, corners[3].x), Math.min(corners[0].y, corners[1].y, corners[2].y, corners[3].y), Math.max(corners[0].x, corners[1].x, corners[2].x, corners[3].x), Math.max(corners[0].y, corners[1].y, corners[2].y, corners[3].y));
21706
21705
  }
21707
21706
  applyAddChildren(childIds) {
@@ -22150,15 +22149,29 @@ class RichText extends BaseItem {
22150
22149
  };
22151
22150
  calcAutoSize(blockNodes) {
22152
22151
  const nodes = blockNodes ? blockNodes : this.getBlockNodes();
22153
- const container = this.getLayoutContainer();
22152
+ const container = this.getTransformedContainer();
22154
22153
  const containerWidth = container.getWidth();
22155
22154
  const containerHeight = container.getHeight();
22156
- const optimal = findOptimalMaxWidthForTextAutoSize(nodes, containerWidth, containerHeight, containerWidth);
22157
- return Math.min(containerWidth / optimal.bestMaxWidth, containerHeight / optimal.bestMaxHeight);
22155
+ const worldMatrix = this.worldMatrixGetter?.();
22156
+ let effectiveWidth = containerWidth;
22157
+ let effectiveHeight = containerHeight;
22158
+ if (worldMatrix) {
22159
+ const localScaleX = this.transformation.getScale().x || 1;
22160
+ const localScaleY = this.transformation.getScale().y || 1;
22161
+ effectiveWidth = containerWidth * (worldMatrix.scaleX / localScaleX);
22162
+ effectiveHeight = containerHeight * (worldMatrix.scaleY / localScaleY);
22163
+ }
22164
+ const optimal = findOptimalMaxWidthForTextAutoSize(nodes, effectiveWidth, effectiveHeight, effectiveWidth);
22165
+ const worldTextScale = Math.min(effectiveWidth / optimal.bestMaxWidth, effectiveHeight / optimal.bestMaxHeight);
22166
+ if (worldMatrix) {
22167
+ const localScaleX = this.transformation.getScale().x || 1;
22168
+ return worldTextScale * localScaleX / worldMatrix.scaleX;
22169
+ }
22170
+ return worldTextScale;
22158
22171
  }
22159
22172
  applyAutoSizeScale(textScale, blockNodes) {
22160
22173
  const nodes = blockNodes ? blockNodes : this.getBlockNodes();
22161
- const container = this.getLayoutContainer();
22174
+ const container = this.getTransformedContainer();
22162
22175
  const containerWidth = container.getWidth();
22163
22176
  const containerHeight = container.getHeight();
22164
22177
  this.layoutNodes = getBlockNodes(nodes, containerWidth / textScale);
@@ -22280,13 +22293,6 @@ class RichText extends BaseItem {
22280
22293
  }
22281
22294
  return this.container.getTransformed(this.transformation.toMatrix());
22282
22295
  }
22283
- getLayoutContainer() {
22284
- if (this.insideOf === "Frame") {
22285
- return this.getTransformedContainer();
22286
- }
22287
- const matrix = this.worldMatrixGetter ? this.worldMatrixGetter() : this.transformation.toMatrix();
22288
- return this.container.getTransformed(matrix);
22289
- }
22290
22296
  emitWithoutApplying = (op) => {
22291
22297
  if (this.board.events) {
22292
22298
  this.board.events.emit(op);
@@ -22302,7 +22308,7 @@ class RichText extends BaseItem {
22302
22308
  apply(op) {
22303
22309
  switch (op.class) {
22304
22310
  case "Transformation":
22305
- this.transformation.apply(op);
22311
+ super.apply(op);
22306
22312
  break;
22307
22313
  case "LinkTo":
22308
22314
  this.linkTo.apply(op);
@@ -36253,7 +36259,6 @@ class AINode extends BaseItem {
36253
36259
  this.subject.publish(this);
36254
36260
  });
36255
36261
  this.text.insideOf = "AINode";
36256
- this.text.worldMatrixGetter = () => this.getWorldMatrix();
36257
36262
  this.transformPath();
36258
36263
  }
36259
36264
  transformPath() {
@@ -39850,7 +39855,7 @@ class Shape extends BaseItem {
39850
39855
  this.text.apply(op);
39851
39856
  break;
39852
39857
  case "Transformation":
39853
- this.transformation.apply(op);
39858
+ super.apply(op);
39854
39859
  break;
39855
39860
  case "LinkTo":
39856
39861
  this.linkTo.apply(op);
@@ -41627,7 +41632,7 @@ class VideoItem extends BaseItem {
41627
41632
  apply(op) {
41628
41633
  switch (op.class) {
41629
41634
  case "Transformation":
41630
- this.transformation.apply(op);
41635
+ super.apply(op);
41631
41636
  break;
41632
41637
  case "LinkTo":
41633
41638
  this.linkTo.apply(op);
@@ -42103,7 +42108,7 @@ class AudioItem extends BaseItem {
42103
42108
  apply(op) {
42104
42109
  switch (op.class) {
42105
42110
  case "Transformation":
42106
- this.transformation.apply(op);
42111
+ super.apply(op);
42107
42112
  break;
42108
42113
  case "LinkTo":
42109
42114
  this.linkTo.apply(op);
@@ -42297,7 +42302,7 @@ class Placeholder extends BaseItem {
42297
42302
  this.updateMbr();
42298
42303
  break;
42299
42304
  case "Transformation":
42300
- this.transformation.apply(op);
42305
+ super.apply(op);
42301
42306
  break;
42302
42307
  default:
42303
42308
  return;
@@ -42724,7 +42729,7 @@ class ImageItem extends BaseItem {
42724
42729
  apply(op) {
42725
42730
  switch (op.class) {
42726
42731
  case "Transformation":
42727
- this.transformation.apply(op);
42732
+ super.apply(op);
42728
42733
  break;
42729
42734
  case "LinkTo":
42730
42735
  this.linkTo.apply(op);
@@ -43152,7 +43157,7 @@ class Drawing extends BaseItem {
43152
43157
  this.updateMbr();
43153
43158
  break;
43154
43159
  case "Transformation":
43155
- this.transformation.apply(op);
43160
+ super.apply(op);
43156
43161
  break;
43157
43162
  case "LinkTo":
43158
43163
  this.linkTo.apply(op);
@@ -43315,7 +43320,7 @@ class Group extends BaseItem {
43315
43320
  }
43316
43321
  break;
43317
43322
  case "Transformation":
43318
- this.transformation.apply(op);
43323
+ super.apply(op);
43319
43324
  break;
43320
43325
  default:
43321
43326
  return;
package/dist/esm/node.js CHANGED
@@ -21581,7 +21581,7 @@ class Comment {
21581
21581
  this.transform();
21582
21582
  break;
21583
21583
  case "Transformation":
21584
- this.transformation.apply(op);
21584
+ super.apply(op);
21585
21585
  break;
21586
21586
  default:
21587
21587
  return;
@@ -24156,10 +24156,9 @@ class BaseItem extends Mbr {
24156
24156
  return this.getMbr();
24157
24157
  }
24158
24158
  const container = this.board.items.getById(this.parent);
24159
- if (!container) {
24159
+ if (!container)
24160
24160
  return this.getMbr();
24161
- }
24162
- const containerWorldMatrix = container.getWorldMatrix();
24161
+ const worldMatrix = container.getWorldMatrix();
24163
24162
  const local = this.getMbr();
24164
24163
  const corners = [
24165
24164
  new Point(local.left, local.top),
@@ -24168,7 +24167,7 @@ class BaseItem extends Mbr {
24168
24167
  new Point(local.left, local.bottom)
24169
24168
  ];
24170
24169
  for (const c of corners)
24171
- containerWorldMatrix.apply(c);
24170
+ worldMatrix.apply(c);
24172
24171
  return new Mbr(Math.min(corners[0].x, corners[1].x, corners[2].x, corners[3].x), Math.min(corners[0].y, corners[1].y, corners[2].y, corners[3].y), Math.max(corners[0].x, corners[1].x, corners[2].x, corners[3].x), Math.max(corners[0].y, corners[1].y, corners[2].y, corners[3].y));
24173
24172
  }
24174
24173
  applyAddChildren(childIds) {
@@ -24617,15 +24616,29 @@ class RichText extends BaseItem {
24617
24616
  };
24618
24617
  calcAutoSize(blockNodes) {
24619
24618
  const nodes = blockNodes ? blockNodes : this.getBlockNodes();
24620
- const container = this.getLayoutContainer();
24619
+ const container = this.getTransformedContainer();
24621
24620
  const containerWidth = container.getWidth();
24622
24621
  const containerHeight = container.getHeight();
24623
- const optimal = findOptimalMaxWidthForTextAutoSize(nodes, containerWidth, containerHeight, containerWidth);
24624
- return Math.min(containerWidth / optimal.bestMaxWidth, containerHeight / optimal.bestMaxHeight);
24622
+ const worldMatrix = this.worldMatrixGetter?.();
24623
+ let effectiveWidth = containerWidth;
24624
+ let effectiveHeight = containerHeight;
24625
+ if (worldMatrix) {
24626
+ const localScaleX = this.transformation.getScale().x || 1;
24627
+ const localScaleY = this.transformation.getScale().y || 1;
24628
+ effectiveWidth = containerWidth * (worldMatrix.scaleX / localScaleX);
24629
+ effectiveHeight = containerHeight * (worldMatrix.scaleY / localScaleY);
24630
+ }
24631
+ const optimal = findOptimalMaxWidthForTextAutoSize(nodes, effectiveWidth, effectiveHeight, effectiveWidth);
24632
+ const worldTextScale = Math.min(effectiveWidth / optimal.bestMaxWidth, effectiveHeight / optimal.bestMaxHeight);
24633
+ if (worldMatrix) {
24634
+ const localScaleX = this.transformation.getScale().x || 1;
24635
+ return worldTextScale * localScaleX / worldMatrix.scaleX;
24636
+ }
24637
+ return worldTextScale;
24625
24638
  }
24626
24639
  applyAutoSizeScale(textScale, blockNodes) {
24627
24640
  const nodes = blockNodes ? blockNodes : this.getBlockNodes();
24628
- const container = this.getLayoutContainer();
24641
+ const container = this.getTransformedContainer();
24629
24642
  const containerWidth = container.getWidth();
24630
24643
  const containerHeight = container.getHeight();
24631
24644
  this.layoutNodes = getBlockNodes(nodes, containerWidth / textScale);
@@ -24747,13 +24760,6 @@ class RichText extends BaseItem {
24747
24760
  }
24748
24761
  return this.container.getTransformed(this.transformation.toMatrix());
24749
24762
  }
24750
- getLayoutContainer() {
24751
- if (this.insideOf === "Frame") {
24752
- return this.getTransformedContainer();
24753
- }
24754
- const matrix = this.worldMatrixGetter ? this.worldMatrixGetter() : this.transformation.toMatrix();
24755
- return this.container.getTransformed(matrix);
24756
- }
24757
24763
  emitWithoutApplying = (op) => {
24758
24764
  if (this.board.events) {
24759
24765
  this.board.events.emit(op);
@@ -24769,7 +24775,7 @@ class RichText extends BaseItem {
24769
24775
  apply(op) {
24770
24776
  switch (op.class) {
24771
24777
  case "Transformation":
24772
- this.transformation.apply(op);
24778
+ super.apply(op);
24773
24779
  break;
24774
24780
  case "LinkTo":
24775
24781
  this.linkTo.apply(op);
@@ -38721,7 +38727,6 @@ class AINode extends BaseItem {
38721
38727
  this.subject.publish(this);
38722
38728
  });
38723
38729
  this.text.insideOf = "AINode";
38724
- this.text.worldMatrixGetter = () => this.getWorldMatrix();
38725
38730
  this.transformPath();
38726
38731
  }
38727
38732
  transformPath() {
@@ -42318,7 +42323,7 @@ class Shape extends BaseItem {
42318
42323
  this.text.apply(op);
42319
42324
  break;
42320
42325
  case "Transformation":
42321
- this.transformation.apply(op);
42326
+ super.apply(op);
42322
42327
  break;
42323
42328
  case "LinkTo":
42324
42329
  this.linkTo.apply(op);
@@ -44095,7 +44100,7 @@ class VideoItem extends BaseItem {
44095
44100
  apply(op) {
44096
44101
  switch (op.class) {
44097
44102
  case "Transformation":
44098
- this.transformation.apply(op);
44103
+ super.apply(op);
44099
44104
  break;
44100
44105
  case "LinkTo":
44101
44106
  this.linkTo.apply(op);
@@ -44571,7 +44576,7 @@ class AudioItem extends BaseItem {
44571
44576
  apply(op) {
44572
44577
  switch (op.class) {
44573
44578
  case "Transformation":
44574
- this.transformation.apply(op);
44579
+ super.apply(op);
44575
44580
  break;
44576
44581
  case "LinkTo":
44577
44582
  this.linkTo.apply(op);
@@ -44765,7 +44770,7 @@ class Placeholder extends BaseItem {
44765
44770
  this.updateMbr();
44766
44771
  break;
44767
44772
  case "Transformation":
44768
- this.transformation.apply(op);
44773
+ super.apply(op);
44769
44774
  break;
44770
44775
  default:
44771
44776
  return;
@@ -45192,7 +45197,7 @@ class ImageItem extends BaseItem {
45192
45197
  apply(op) {
45193
45198
  switch (op.class) {
45194
45199
  case "Transformation":
45195
- this.transformation.apply(op);
45200
+ super.apply(op);
45196
45201
  break;
45197
45202
  case "LinkTo":
45198
45203
  this.linkTo.apply(op);
@@ -45620,7 +45625,7 @@ class Drawing extends BaseItem {
45620
45625
  this.updateMbr();
45621
45626
  break;
45622
45627
  case "Transformation":
45623
- this.transformation.apply(op);
45628
+ super.apply(op);
45624
45629
  break;
45625
45630
  case "LinkTo":
45626
45631
  this.linkTo.apply(op);
@@ -45783,7 +45788,7 @@ class Group extends BaseItem {
45783
45788
  }
45784
45789
  break;
45785
45790
  case "Transformation":
45786
- this.transformation.apply(op);
45791
+ super.apply(op);
45787
45792
  break;
45788
45793
  default:
45789
45794
  return;
@@ -52,7 +52,6 @@ export declare class RichText extends BaseItem {
52
52
  private _onLimitReached;
53
53
  private shrinkWidth;
54
54
  prevMbr: Mbr | null;
55
- /** When set, used by calcAutoSize/applyAutoSizeScale to get world-space container dimensions. */
56
55
  worldMatrixGetter?: () => Matrix;
57
56
  rtCounter: number;
58
57
  constructor(board: Board, container: Mbr, id?: string, transformation?: Transformation, linkTo?: LinkTo, placeholderText?: string, isInShape?: boolean, autoSize?: boolean, insideOf?: ItemType | undefined, initialTextStyles?: DefaultTextStyles);
@@ -96,13 +95,6 @@ export declare class RichText extends BaseItem {
96
95
  * Get the container that would be used to align the CanvasDocument.
97
96
  */
98
97
  getTransformedContainer(): Mbr;
99
- /**
100
- * Like getTransformedContainer() but uses the world-space matrix when this
101
- * RichText belongs to a nested item (e.g. Sticker inside a Frame). This
102
- * ensures calcAutoSize and applyAutoSizeScale measure the correct pixel
103
- * dimensions instead of the compressed local-space dimensions.
104
- */
105
- private getLayoutContainer;
106
98
  emitWithoutApplying: (op: RichTextOperation) => void;
107
99
  emit: (op: RichTextOperation) => void;
108
100
  apply(op: Operation): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "microboard-temp",
3
- "version": "0.11.1",
3
+ "version": "0.11.2",
4
4
  "description": "A flexible interactive whiteboard library",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",