microboard-temp 0.11.0 → 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;
@@ -21866,7 +21866,10 @@ class BaseItem extends Mbr {
21866
21866
  if (this.parent === "Board" || !this.parent || !this.board?.items) {
21867
21867
  return this.getMbr();
21868
21868
  }
21869
- const worldMatrix = this.getWorldMatrix();
21869
+ const container = this.board.items.getById(this.parent);
21870
+ if (!container)
21871
+ return this.getMbr();
21872
+ const worldMatrix = container.getWorldMatrix();
21870
21873
  const local = this.getMbr();
21871
21874
  const corners = [
21872
21875
  new Point(local.left, local.top),
@@ -22154,6 +22157,7 @@ class RichText extends BaseItem {
22154
22157
  _onLimitReached = () => {};
22155
22158
  shrinkWidth = false;
22156
22159
  prevMbr = null;
22160
+ worldMatrixGetter;
22157
22161
  rtCounter = 0;
22158
22162
  constructor(board, container, id = "", transformation = new Transformation(id, board.events), linkTo, placeholderText = conf.i18n?.t("board.textPlaceholder"), isInShape = false, autoSize = false, insideOf, initialTextStyles = conf.DEFAULT_TEXT_STYLES) {
22159
22163
  super(board, id);
@@ -22326,8 +22330,22 @@ class RichText extends BaseItem {
22326
22330
  const container = this.getTransformedContainer();
22327
22331
  const containerWidth = container.getWidth();
22328
22332
  const containerHeight = container.getHeight();
22329
- const optimal = findOptimalMaxWidthForTextAutoSize(nodes, containerWidth, containerHeight, containerWidth);
22330
- 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;
22331
22349
  }
22332
22350
  applyAutoSizeScale(textScale, blockNodes) {
22333
22351
  const nodes = blockNodes ? blockNodes : this.getBlockNodes();
@@ -22468,7 +22486,7 @@ class RichText extends BaseItem {
22468
22486
  apply(op) {
22469
22487
  switch (op.class) {
22470
22488
  case "Transformation":
22471
- this.transformation.apply(op);
22489
+ super.apply(op);
22472
22490
  break;
22473
22491
  case "LinkTo":
22474
22492
  this.linkTo.apply(op);
@@ -36510,7 +36528,7 @@ class AINode extends BaseItem {
36510
36528
  this.text.apply(op);
36511
36529
  break;
36512
36530
  case "Transformation":
36513
- this.text.transformation.apply(op);
36531
+ super.apply(op);
36514
36532
  break;
36515
36533
  case "LinkTo":
36516
36534
  this.linkTo.apply(op);
@@ -40015,7 +40033,7 @@ class Shape extends BaseItem {
40015
40033
  this.text.apply(op);
40016
40034
  break;
40017
40035
  case "Transformation":
40018
- this.transformation.apply(op);
40036
+ super.apply(op);
40019
40037
  break;
40020
40038
  case "LinkTo":
40021
40039
  this.linkTo.apply(op);
@@ -40440,6 +40458,7 @@ class Sticker extends BaseItem {
40440
40458
  this.linkTo = new LinkTo(this.id, this.board.events);
40441
40459
  this.transformation = new Transformation(this.id, this.board.events);
40442
40460
  this.text = new RichText(board, this.textContainer, this.id, this.transformation, this.linkTo, " ", false, true, this.itemType);
40461
+ this.text.worldMatrixGetter = () => this.getWorldMatrix();
40443
40462
  this.transformation.subject.subscribe((_subject, op) => {
40444
40463
  this.transformPath();
40445
40464
  if (op.method === "applyMatrix") {
@@ -40543,7 +40562,7 @@ class Sticker extends BaseItem {
40543
40562
  this.text.apply(op);
40544
40563
  break;
40545
40564
  case "Transformation":
40546
- this.transformation.apply(op);
40565
+ super.apply(op);
40547
40566
  break;
40548
40567
  case "LinkTo":
40549
40568
  this.linkTo.apply(op);
@@ -41791,7 +41810,7 @@ class VideoItem extends BaseItem {
41791
41810
  apply(op) {
41792
41811
  switch (op.class) {
41793
41812
  case "Transformation":
41794
- this.transformation.apply(op);
41813
+ super.apply(op);
41795
41814
  break;
41796
41815
  case "LinkTo":
41797
41816
  this.linkTo.apply(op);
@@ -42267,7 +42286,7 @@ class AudioItem extends BaseItem {
42267
42286
  apply(op) {
42268
42287
  switch (op.class) {
42269
42288
  case "Transformation":
42270
- this.transformation.apply(op);
42289
+ super.apply(op);
42271
42290
  break;
42272
42291
  case "LinkTo":
42273
42292
  this.linkTo.apply(op);
@@ -42461,7 +42480,7 @@ class Placeholder extends BaseItem {
42461
42480
  this.updateMbr();
42462
42481
  break;
42463
42482
  case "Transformation":
42464
- this.transformation.apply(op);
42483
+ super.apply(op);
42465
42484
  break;
42466
42485
  default:
42467
42486
  return;
@@ -42888,7 +42907,7 @@ class ImageItem extends BaseItem {
42888
42907
  apply(op) {
42889
42908
  switch (op.class) {
42890
42909
  case "Transformation":
42891
- this.transformation.apply(op);
42910
+ super.apply(op);
42892
42911
  break;
42893
42912
  case "LinkTo":
42894
42913
  this.linkTo.apply(op);
@@ -43316,7 +43335,7 @@ class Drawing extends BaseItem {
43316
43335
  this.updateMbr();
43317
43336
  break;
43318
43337
  case "Transformation":
43319
- this.transformation.apply(op);
43338
+ super.apply(op);
43320
43339
  break;
43321
43340
  case "LinkTo":
43322
43341
  this.linkTo.apply(op);
@@ -43479,7 +43498,7 @@ class Group extends BaseItem {
43479
43498
  }
43480
43499
  break;
43481
43500
  case "Transformation":
43482
- this.transformation.apply(op);
43501
+ super.apply(op);
43483
43502
  break;
43484
43503
  default:
43485
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;
@@ -21866,7 +21866,10 @@ class BaseItem extends Mbr {
21866
21866
  if (this.parent === "Board" || !this.parent || !this.board?.items) {
21867
21867
  return this.getMbr();
21868
21868
  }
21869
- const worldMatrix = this.getWorldMatrix();
21869
+ const container = this.board.items.getById(this.parent);
21870
+ if (!container)
21871
+ return this.getMbr();
21872
+ const worldMatrix = container.getWorldMatrix();
21870
21873
  const local = this.getMbr();
21871
21874
  const corners = [
21872
21875
  new Point(local.left, local.top),
@@ -22154,6 +22157,7 @@ class RichText extends BaseItem {
22154
22157
  _onLimitReached = () => {};
22155
22158
  shrinkWidth = false;
22156
22159
  prevMbr = null;
22160
+ worldMatrixGetter;
22157
22161
  rtCounter = 0;
22158
22162
  constructor(board, container, id = "", transformation = new Transformation(id, board.events), linkTo, placeholderText = conf.i18n?.t("board.textPlaceholder"), isInShape = false, autoSize = false, insideOf, initialTextStyles = conf.DEFAULT_TEXT_STYLES) {
22159
22163
  super(board, id);
@@ -22326,8 +22330,22 @@ class RichText extends BaseItem {
22326
22330
  const container = this.getTransformedContainer();
22327
22331
  const containerWidth = container.getWidth();
22328
22332
  const containerHeight = container.getHeight();
22329
- const optimal = findOptimalMaxWidthForTextAutoSize(nodes, containerWidth, containerHeight, containerWidth);
22330
- 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;
22331
22349
  }
22332
22350
  applyAutoSizeScale(textScale, blockNodes) {
22333
22351
  const nodes = blockNodes ? blockNodes : this.getBlockNodes();
@@ -22468,7 +22486,7 @@ class RichText extends BaseItem {
22468
22486
  apply(op) {
22469
22487
  switch (op.class) {
22470
22488
  case "Transformation":
22471
- this.transformation.apply(op);
22489
+ super.apply(op);
22472
22490
  break;
22473
22491
  case "LinkTo":
22474
22492
  this.linkTo.apply(op);
@@ -36510,7 +36528,7 @@ class AINode extends BaseItem {
36510
36528
  this.text.apply(op);
36511
36529
  break;
36512
36530
  case "Transformation":
36513
- this.text.transformation.apply(op);
36531
+ super.apply(op);
36514
36532
  break;
36515
36533
  case "LinkTo":
36516
36534
  this.linkTo.apply(op);
@@ -40015,7 +40033,7 @@ class Shape extends BaseItem {
40015
40033
  this.text.apply(op);
40016
40034
  break;
40017
40035
  case "Transformation":
40018
- this.transformation.apply(op);
40036
+ super.apply(op);
40019
40037
  break;
40020
40038
  case "LinkTo":
40021
40039
  this.linkTo.apply(op);
@@ -40440,6 +40458,7 @@ class Sticker extends BaseItem {
40440
40458
  this.linkTo = new LinkTo(this.id, this.board.events);
40441
40459
  this.transformation = new Transformation(this.id, this.board.events);
40442
40460
  this.text = new RichText(board, this.textContainer, this.id, this.transformation, this.linkTo, " ", false, true, this.itemType);
40461
+ this.text.worldMatrixGetter = () => this.getWorldMatrix();
40443
40462
  this.transformation.subject.subscribe((_subject, op) => {
40444
40463
  this.transformPath();
40445
40464
  if (op.method === "applyMatrix") {
@@ -40543,7 +40562,7 @@ class Sticker extends BaseItem {
40543
40562
  this.text.apply(op);
40544
40563
  break;
40545
40564
  case "Transformation":
40546
- this.transformation.apply(op);
40565
+ super.apply(op);
40547
40566
  break;
40548
40567
  case "LinkTo":
40549
40568
  this.linkTo.apply(op);
@@ -41791,7 +41810,7 @@ class VideoItem extends BaseItem {
41791
41810
  apply(op) {
41792
41811
  switch (op.class) {
41793
41812
  case "Transformation":
41794
- this.transformation.apply(op);
41813
+ super.apply(op);
41795
41814
  break;
41796
41815
  case "LinkTo":
41797
41816
  this.linkTo.apply(op);
@@ -42267,7 +42286,7 @@ class AudioItem extends BaseItem {
42267
42286
  apply(op) {
42268
42287
  switch (op.class) {
42269
42288
  case "Transformation":
42270
- this.transformation.apply(op);
42289
+ super.apply(op);
42271
42290
  break;
42272
42291
  case "LinkTo":
42273
42292
  this.linkTo.apply(op);
@@ -42461,7 +42480,7 @@ class Placeholder extends BaseItem {
42461
42480
  this.updateMbr();
42462
42481
  break;
42463
42482
  case "Transformation":
42464
- this.transformation.apply(op);
42483
+ super.apply(op);
42465
42484
  break;
42466
42485
  default:
42467
42486
  return;
@@ -42888,7 +42907,7 @@ class ImageItem extends BaseItem {
42888
42907
  apply(op) {
42889
42908
  switch (op.class) {
42890
42909
  case "Transformation":
42891
- this.transformation.apply(op);
42910
+ super.apply(op);
42892
42911
  break;
42893
42912
  case "LinkTo":
42894
42913
  this.linkTo.apply(op);
@@ -43316,7 +43335,7 @@ class Drawing extends BaseItem {
43316
43335
  this.updateMbr();
43317
43336
  break;
43318
43337
  case "Transformation":
43319
- this.transformation.apply(op);
43338
+ super.apply(op);
43320
43339
  break;
43321
43340
  case "LinkTo":
43322
43341
  this.linkTo.apply(op);
@@ -43479,7 +43498,7 @@ class Group extends BaseItem {
43479
43498
  }
43480
43499
  break;
43481
43500
  case "Transformation":
43482
- this.transformation.apply(op);
43501
+ super.apply(op);
43483
43502
  break;
43484
43503
  default:
43485
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;
@@ -24338,7 +24338,10 @@ class BaseItem extends Mbr {
24338
24338
  if (this.parent === "Board" || !this.parent || !this.board?.items) {
24339
24339
  return this.getMbr();
24340
24340
  }
24341
- const worldMatrix = this.getWorldMatrix();
24341
+ const container = this.board.items.getById(this.parent);
24342
+ if (!container)
24343
+ return this.getMbr();
24344
+ const worldMatrix = container.getWorldMatrix();
24342
24345
  const local = this.getMbr();
24343
24346
  const corners = [
24344
24347
  new Point(local.left, local.top),
@@ -24626,6 +24629,7 @@ class RichText extends BaseItem {
24626
24629
  _onLimitReached = () => {};
24627
24630
  shrinkWidth = false;
24628
24631
  prevMbr = null;
24632
+ worldMatrixGetter;
24629
24633
  rtCounter = 0;
24630
24634
  constructor(board, container, id = "", transformation = new Transformation(id, board.events), linkTo, placeholderText = conf.i18n?.t("board.textPlaceholder"), isInShape = false, autoSize = false, insideOf, initialTextStyles = conf.DEFAULT_TEXT_STYLES) {
24631
24635
  super(board, id);
@@ -24798,8 +24802,22 @@ class RichText extends BaseItem {
24798
24802
  const container = this.getTransformedContainer();
24799
24803
  const containerWidth = container.getWidth();
24800
24804
  const containerHeight = container.getHeight();
24801
- const optimal = findOptimalMaxWidthForTextAutoSize(nodes, containerWidth, containerHeight, containerWidth);
24802
- 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;
24803
24821
  }
24804
24822
  applyAutoSizeScale(textScale, blockNodes) {
24805
24823
  const nodes = blockNodes ? blockNodes : this.getBlockNodes();
@@ -24940,7 +24958,7 @@ class RichText extends BaseItem {
24940
24958
  apply(op) {
24941
24959
  switch (op.class) {
24942
24960
  case "Transformation":
24943
- this.transformation.apply(op);
24961
+ super.apply(op);
24944
24962
  break;
24945
24963
  case "LinkTo":
24946
24964
  this.linkTo.apply(op);
@@ -38983,7 +39001,7 @@ class AINode extends BaseItem {
38983
39001
  this.text.apply(op);
38984
39002
  break;
38985
39003
  case "Transformation":
38986
- this.text.transformation.apply(op);
39004
+ super.apply(op);
38987
39005
  break;
38988
39006
  case "LinkTo":
38989
39007
  this.linkTo.apply(op);
@@ -42488,7 +42506,7 @@ class Shape extends BaseItem {
42488
42506
  this.text.apply(op);
42489
42507
  break;
42490
42508
  case "Transformation":
42491
- this.transformation.apply(op);
42509
+ super.apply(op);
42492
42510
  break;
42493
42511
  case "LinkTo":
42494
42512
  this.linkTo.apply(op);
@@ -42913,6 +42931,7 @@ class Sticker extends BaseItem {
42913
42931
  this.linkTo = new LinkTo(this.id, this.board.events);
42914
42932
  this.transformation = new Transformation(this.id, this.board.events);
42915
42933
  this.text = new RichText(board, this.textContainer, this.id, this.transformation, this.linkTo, " ", false, true, this.itemType);
42934
+ this.text.worldMatrixGetter = () => this.getWorldMatrix();
42916
42935
  this.transformation.subject.subscribe((_subject, op) => {
42917
42936
  this.transformPath();
42918
42937
  if (op.method === "applyMatrix") {
@@ -43016,7 +43035,7 @@ class Sticker extends BaseItem {
43016
43035
  this.text.apply(op);
43017
43036
  break;
43018
43037
  case "Transformation":
43019
- this.transformation.apply(op);
43038
+ super.apply(op);
43020
43039
  break;
43021
43040
  case "LinkTo":
43022
43041
  this.linkTo.apply(op);
@@ -44264,7 +44283,7 @@ class VideoItem extends BaseItem {
44264
44283
  apply(op) {
44265
44284
  switch (op.class) {
44266
44285
  case "Transformation":
44267
- this.transformation.apply(op);
44286
+ super.apply(op);
44268
44287
  break;
44269
44288
  case "LinkTo":
44270
44289
  this.linkTo.apply(op);
@@ -44740,7 +44759,7 @@ class AudioItem extends BaseItem {
44740
44759
  apply(op) {
44741
44760
  switch (op.class) {
44742
44761
  case "Transformation":
44743
- this.transformation.apply(op);
44762
+ super.apply(op);
44744
44763
  break;
44745
44764
  case "LinkTo":
44746
44765
  this.linkTo.apply(op);
@@ -44934,7 +44953,7 @@ class Placeholder extends BaseItem {
44934
44953
  this.updateMbr();
44935
44954
  break;
44936
44955
  case "Transformation":
44937
- this.transformation.apply(op);
44956
+ super.apply(op);
44938
44957
  break;
44939
44958
  default:
44940
44959
  return;
@@ -45361,7 +45380,7 @@ class ImageItem extends BaseItem {
45361
45380
  apply(op) {
45362
45381
  switch (op.class) {
45363
45382
  case "Transformation":
45364
- this.transformation.apply(op);
45383
+ super.apply(op);
45365
45384
  break;
45366
45385
  case "LinkTo":
45367
45386
  this.linkTo.apply(op);
@@ -45789,7 +45808,7 @@ class Drawing extends BaseItem {
45789
45808
  this.updateMbr();
45790
45809
  break;
45791
45810
  case "Transformation":
45792
- this.transformation.apply(op);
45811
+ super.apply(op);
45793
45812
  break;
45794
45813
  case "LinkTo":
45795
45814
  this.linkTo.apply(op);
@@ -45952,7 +45971,7 @@ class Group extends BaseItem {
45952
45971
  }
45953
45972
  break;
45954
45973
  case "Transformation":
45955
- this.transformation.apply(op);
45974
+ super.apply(op);
45956
45975
  break;
45957
45976
  default:
45958
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;
@@ -21695,7 +21695,10 @@ class BaseItem extends Mbr {
21695
21695
  if (this.parent === "Board" || !this.parent || !this.board?.items) {
21696
21696
  return this.getMbr();
21697
21697
  }
21698
- const worldMatrix = this.getWorldMatrix();
21698
+ const container = this.board.items.getById(this.parent);
21699
+ if (!container)
21700
+ return this.getMbr();
21701
+ const worldMatrix = container.getWorldMatrix();
21699
21702
  const local = this.getMbr();
21700
21703
  const corners = [
21701
21704
  new Point(local.left, local.top),
@@ -21983,6 +21986,7 @@ class RichText extends BaseItem {
21983
21986
  _onLimitReached = () => {};
21984
21987
  shrinkWidth = false;
21985
21988
  prevMbr = null;
21989
+ worldMatrixGetter;
21986
21990
  rtCounter = 0;
21987
21991
  constructor(board, container, id = "", transformation = new Transformation(id, board.events), linkTo, placeholderText = conf.i18n?.t("board.textPlaceholder"), isInShape = false, autoSize = false, insideOf, initialTextStyles = conf.DEFAULT_TEXT_STYLES) {
21988
21992
  super(board, id);
@@ -22155,8 +22159,22 @@ class RichText extends BaseItem {
22155
22159
  const container = this.getTransformedContainer();
22156
22160
  const containerWidth = container.getWidth();
22157
22161
  const containerHeight = container.getHeight();
22158
- const optimal = findOptimalMaxWidthForTextAutoSize(nodes, containerWidth, containerHeight, containerWidth);
22159
- 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;
22160
22178
  }
22161
22179
  applyAutoSizeScale(textScale, blockNodes) {
22162
22180
  const nodes = blockNodes ? blockNodes : this.getBlockNodes();
@@ -22297,7 +22315,7 @@ class RichText extends BaseItem {
22297
22315
  apply(op) {
22298
22316
  switch (op.class) {
22299
22317
  case "Transformation":
22300
- this.transformation.apply(op);
22318
+ super.apply(op);
22301
22319
  break;
22302
22320
  case "LinkTo":
22303
22321
  this.linkTo.apply(op);
@@ -36339,7 +36357,7 @@ class AINode extends BaseItem {
36339
36357
  this.text.apply(op);
36340
36358
  break;
36341
36359
  case "Transformation":
36342
- this.text.transformation.apply(op);
36360
+ super.apply(op);
36343
36361
  break;
36344
36362
  case "LinkTo":
36345
36363
  this.linkTo.apply(op);
@@ -39844,7 +39862,7 @@ class Shape extends BaseItem {
39844
39862
  this.text.apply(op);
39845
39863
  break;
39846
39864
  case "Transformation":
39847
- this.transformation.apply(op);
39865
+ super.apply(op);
39848
39866
  break;
39849
39867
  case "LinkTo":
39850
39868
  this.linkTo.apply(op);
@@ -40269,6 +40287,7 @@ class Sticker extends BaseItem {
40269
40287
  this.linkTo = new LinkTo(this.id, this.board.events);
40270
40288
  this.transformation = new Transformation(this.id, this.board.events);
40271
40289
  this.text = new RichText(board, this.textContainer, this.id, this.transformation, this.linkTo, " ", false, true, this.itemType);
40290
+ this.text.worldMatrixGetter = () => this.getWorldMatrix();
40272
40291
  this.transformation.subject.subscribe((_subject, op) => {
40273
40292
  this.transformPath();
40274
40293
  if (op.method === "applyMatrix") {
@@ -40372,7 +40391,7 @@ class Sticker extends BaseItem {
40372
40391
  this.text.apply(op);
40373
40392
  break;
40374
40393
  case "Transformation":
40375
- this.transformation.apply(op);
40394
+ super.apply(op);
40376
40395
  break;
40377
40396
  case "LinkTo":
40378
40397
  this.linkTo.apply(op);
@@ -41620,7 +41639,7 @@ class VideoItem extends BaseItem {
41620
41639
  apply(op) {
41621
41640
  switch (op.class) {
41622
41641
  case "Transformation":
41623
- this.transformation.apply(op);
41642
+ super.apply(op);
41624
41643
  break;
41625
41644
  case "LinkTo":
41626
41645
  this.linkTo.apply(op);
@@ -42096,7 +42115,7 @@ class AudioItem extends BaseItem {
42096
42115
  apply(op) {
42097
42116
  switch (op.class) {
42098
42117
  case "Transformation":
42099
- this.transformation.apply(op);
42118
+ super.apply(op);
42100
42119
  break;
42101
42120
  case "LinkTo":
42102
42121
  this.linkTo.apply(op);
@@ -42290,7 +42309,7 @@ class Placeholder extends BaseItem {
42290
42309
  this.updateMbr();
42291
42310
  break;
42292
42311
  case "Transformation":
42293
- this.transformation.apply(op);
42312
+ super.apply(op);
42294
42313
  break;
42295
42314
  default:
42296
42315
  return;
@@ -42717,7 +42736,7 @@ class ImageItem extends BaseItem {
42717
42736
  apply(op) {
42718
42737
  switch (op.class) {
42719
42738
  case "Transformation":
42720
- this.transformation.apply(op);
42739
+ super.apply(op);
42721
42740
  break;
42722
42741
  case "LinkTo":
42723
42742
  this.linkTo.apply(op);
@@ -43145,7 +43164,7 @@ class Drawing extends BaseItem {
43145
43164
  this.updateMbr();
43146
43165
  break;
43147
43166
  case "Transformation":
43148
- this.transformation.apply(op);
43167
+ super.apply(op);
43149
43168
  break;
43150
43169
  case "LinkTo":
43151
43170
  this.linkTo.apply(op);
@@ -43308,7 +43327,7 @@ class Group extends BaseItem {
43308
43327
  }
43309
43328
  break;
43310
43329
  case "Transformation":
43311
- this.transformation.apply(op);
43330
+ super.apply(op);
43312
43331
  break;
43313
43332
  default:
43314
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;
@@ -21688,7 +21688,10 @@ class BaseItem extends Mbr {
21688
21688
  if (this.parent === "Board" || !this.parent || !this.board?.items) {
21689
21689
  return this.getMbr();
21690
21690
  }
21691
- const worldMatrix = this.getWorldMatrix();
21691
+ const container = this.board.items.getById(this.parent);
21692
+ if (!container)
21693
+ return this.getMbr();
21694
+ const worldMatrix = container.getWorldMatrix();
21692
21695
  const local = this.getMbr();
21693
21696
  const corners = [
21694
21697
  new Point(local.left, local.top),
@@ -21976,6 +21979,7 @@ class RichText extends BaseItem {
21976
21979
  _onLimitReached = () => {};
21977
21980
  shrinkWidth = false;
21978
21981
  prevMbr = null;
21982
+ worldMatrixGetter;
21979
21983
  rtCounter = 0;
21980
21984
  constructor(board, container, id = "", transformation = new Transformation(id, board.events), linkTo, placeholderText = conf.i18n?.t("board.textPlaceholder"), isInShape = false, autoSize = false, insideOf, initialTextStyles = conf.DEFAULT_TEXT_STYLES) {
21981
21985
  super(board, id);
@@ -22148,8 +22152,22 @@ class RichText extends BaseItem {
22148
22152
  const container = this.getTransformedContainer();
22149
22153
  const containerWidth = container.getWidth();
22150
22154
  const containerHeight = container.getHeight();
22151
- const optimal = findOptimalMaxWidthForTextAutoSize(nodes, containerWidth, containerHeight, containerWidth);
22152
- 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;
22153
22171
  }
22154
22172
  applyAutoSizeScale(textScale, blockNodes) {
22155
22173
  const nodes = blockNodes ? blockNodes : this.getBlockNodes();
@@ -22290,7 +22308,7 @@ class RichText extends BaseItem {
22290
22308
  apply(op) {
22291
22309
  switch (op.class) {
22292
22310
  case "Transformation":
22293
- this.transformation.apply(op);
22311
+ super.apply(op);
22294
22312
  break;
22295
22313
  case "LinkTo":
22296
22314
  this.linkTo.apply(op);
@@ -36332,7 +36350,7 @@ class AINode extends BaseItem {
36332
36350
  this.text.apply(op);
36333
36351
  break;
36334
36352
  case "Transformation":
36335
- this.text.transformation.apply(op);
36353
+ super.apply(op);
36336
36354
  break;
36337
36355
  case "LinkTo":
36338
36356
  this.linkTo.apply(op);
@@ -39837,7 +39855,7 @@ class Shape extends BaseItem {
39837
39855
  this.text.apply(op);
39838
39856
  break;
39839
39857
  case "Transformation":
39840
- this.transformation.apply(op);
39858
+ super.apply(op);
39841
39859
  break;
39842
39860
  case "LinkTo":
39843
39861
  this.linkTo.apply(op);
@@ -40262,6 +40280,7 @@ class Sticker extends BaseItem {
40262
40280
  this.linkTo = new LinkTo(this.id, this.board.events);
40263
40281
  this.transformation = new Transformation(this.id, this.board.events);
40264
40282
  this.text = new RichText(board, this.textContainer, this.id, this.transformation, this.linkTo, " ", false, true, this.itemType);
40283
+ this.text.worldMatrixGetter = () => this.getWorldMatrix();
40265
40284
  this.transformation.subject.subscribe((_subject, op) => {
40266
40285
  this.transformPath();
40267
40286
  if (op.method === "applyMatrix") {
@@ -40365,7 +40384,7 @@ class Sticker extends BaseItem {
40365
40384
  this.text.apply(op);
40366
40385
  break;
40367
40386
  case "Transformation":
40368
- this.transformation.apply(op);
40387
+ super.apply(op);
40369
40388
  break;
40370
40389
  case "LinkTo":
40371
40390
  this.linkTo.apply(op);
@@ -41613,7 +41632,7 @@ class VideoItem extends BaseItem {
41613
41632
  apply(op) {
41614
41633
  switch (op.class) {
41615
41634
  case "Transformation":
41616
- this.transformation.apply(op);
41635
+ super.apply(op);
41617
41636
  break;
41618
41637
  case "LinkTo":
41619
41638
  this.linkTo.apply(op);
@@ -42089,7 +42108,7 @@ class AudioItem extends BaseItem {
42089
42108
  apply(op) {
42090
42109
  switch (op.class) {
42091
42110
  case "Transformation":
42092
- this.transformation.apply(op);
42111
+ super.apply(op);
42093
42112
  break;
42094
42113
  case "LinkTo":
42095
42114
  this.linkTo.apply(op);
@@ -42283,7 +42302,7 @@ class Placeholder extends BaseItem {
42283
42302
  this.updateMbr();
42284
42303
  break;
42285
42304
  case "Transformation":
42286
- this.transformation.apply(op);
42305
+ super.apply(op);
42287
42306
  break;
42288
42307
  default:
42289
42308
  return;
@@ -42710,7 +42729,7 @@ class ImageItem extends BaseItem {
42710
42729
  apply(op) {
42711
42730
  switch (op.class) {
42712
42731
  case "Transformation":
42713
- this.transformation.apply(op);
42732
+ super.apply(op);
42714
42733
  break;
42715
42734
  case "LinkTo":
42716
42735
  this.linkTo.apply(op);
@@ -43138,7 +43157,7 @@ class Drawing extends BaseItem {
43138
43157
  this.updateMbr();
43139
43158
  break;
43140
43159
  case "Transformation":
43141
- this.transformation.apply(op);
43160
+ super.apply(op);
43142
43161
  break;
43143
43162
  case "LinkTo":
43144
43163
  this.linkTo.apply(op);
@@ -43301,7 +43320,7 @@ class Group extends BaseItem {
43301
43320
  }
43302
43321
  break;
43303
43322
  case "Transformation":
43304
- this.transformation.apply(op);
43323
+ super.apply(op);
43305
43324
  break;
43306
43325
  default:
43307
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;
@@ -24155,7 +24155,10 @@ class BaseItem extends Mbr {
24155
24155
  if (this.parent === "Board" || !this.parent || !this.board?.items) {
24156
24156
  return this.getMbr();
24157
24157
  }
24158
- const worldMatrix = this.getWorldMatrix();
24158
+ const container = this.board.items.getById(this.parent);
24159
+ if (!container)
24160
+ return this.getMbr();
24161
+ const worldMatrix = container.getWorldMatrix();
24159
24162
  const local = this.getMbr();
24160
24163
  const corners = [
24161
24164
  new Point(local.left, local.top),
@@ -24443,6 +24446,7 @@ class RichText extends BaseItem {
24443
24446
  _onLimitReached = () => {};
24444
24447
  shrinkWidth = false;
24445
24448
  prevMbr = null;
24449
+ worldMatrixGetter;
24446
24450
  rtCounter = 0;
24447
24451
  constructor(board, container, id = "", transformation = new Transformation(id, board.events), linkTo, placeholderText = conf.i18n?.t("board.textPlaceholder"), isInShape = false, autoSize = false, insideOf, initialTextStyles = conf.DEFAULT_TEXT_STYLES) {
24448
24452
  super(board, id);
@@ -24615,8 +24619,22 @@ class RichText extends BaseItem {
24615
24619
  const container = this.getTransformedContainer();
24616
24620
  const containerWidth = container.getWidth();
24617
24621
  const containerHeight = container.getHeight();
24618
- const optimal = findOptimalMaxWidthForTextAutoSize(nodes, containerWidth, containerHeight, containerWidth);
24619
- 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;
24620
24638
  }
24621
24639
  applyAutoSizeScale(textScale, blockNodes) {
24622
24640
  const nodes = blockNodes ? blockNodes : this.getBlockNodes();
@@ -24757,7 +24775,7 @@ class RichText extends BaseItem {
24757
24775
  apply(op) {
24758
24776
  switch (op.class) {
24759
24777
  case "Transformation":
24760
- this.transformation.apply(op);
24778
+ super.apply(op);
24761
24779
  break;
24762
24780
  case "LinkTo":
24763
24781
  this.linkTo.apply(op);
@@ -38800,7 +38818,7 @@ class AINode extends BaseItem {
38800
38818
  this.text.apply(op);
38801
38819
  break;
38802
38820
  case "Transformation":
38803
- this.text.transformation.apply(op);
38821
+ super.apply(op);
38804
38822
  break;
38805
38823
  case "LinkTo":
38806
38824
  this.linkTo.apply(op);
@@ -42305,7 +42323,7 @@ class Shape extends BaseItem {
42305
42323
  this.text.apply(op);
42306
42324
  break;
42307
42325
  case "Transformation":
42308
- this.transformation.apply(op);
42326
+ super.apply(op);
42309
42327
  break;
42310
42328
  case "LinkTo":
42311
42329
  this.linkTo.apply(op);
@@ -42730,6 +42748,7 @@ class Sticker extends BaseItem {
42730
42748
  this.linkTo = new LinkTo(this.id, this.board.events);
42731
42749
  this.transformation = new Transformation(this.id, this.board.events);
42732
42750
  this.text = new RichText(board, this.textContainer, this.id, this.transformation, this.linkTo, " ", false, true, this.itemType);
42751
+ this.text.worldMatrixGetter = () => this.getWorldMatrix();
42733
42752
  this.transformation.subject.subscribe((_subject, op) => {
42734
42753
  this.transformPath();
42735
42754
  if (op.method === "applyMatrix") {
@@ -42833,7 +42852,7 @@ class Sticker extends BaseItem {
42833
42852
  this.text.apply(op);
42834
42853
  break;
42835
42854
  case "Transformation":
42836
- this.transformation.apply(op);
42855
+ super.apply(op);
42837
42856
  break;
42838
42857
  case "LinkTo":
42839
42858
  this.linkTo.apply(op);
@@ -44081,7 +44100,7 @@ class VideoItem extends BaseItem {
44081
44100
  apply(op) {
44082
44101
  switch (op.class) {
44083
44102
  case "Transformation":
44084
- this.transformation.apply(op);
44103
+ super.apply(op);
44085
44104
  break;
44086
44105
  case "LinkTo":
44087
44106
  this.linkTo.apply(op);
@@ -44557,7 +44576,7 @@ class AudioItem extends BaseItem {
44557
44576
  apply(op) {
44558
44577
  switch (op.class) {
44559
44578
  case "Transformation":
44560
- this.transformation.apply(op);
44579
+ super.apply(op);
44561
44580
  break;
44562
44581
  case "LinkTo":
44563
44582
  this.linkTo.apply(op);
@@ -44751,7 +44770,7 @@ class Placeholder extends BaseItem {
44751
44770
  this.updateMbr();
44752
44771
  break;
44753
44772
  case "Transformation":
44754
- this.transformation.apply(op);
44773
+ super.apply(op);
44755
44774
  break;
44756
44775
  default:
44757
44776
  return;
@@ -45178,7 +45197,7 @@ class ImageItem extends BaseItem {
45178
45197
  apply(op) {
45179
45198
  switch (op.class) {
45180
45199
  case "Transformation":
45181
- this.transformation.apply(op);
45200
+ super.apply(op);
45182
45201
  break;
45183
45202
  case "LinkTo":
45184
45203
  this.linkTo.apply(op);
@@ -45606,7 +45625,7 @@ class Drawing extends BaseItem {
45606
45625
  this.updateMbr();
45607
45626
  break;
45608
45627
  case "Transformation":
45609
- this.transformation.apply(op);
45628
+ super.apply(op);
45610
45629
  break;
45611
45630
  case "LinkTo":
45612
45631
  this.linkTo.apply(op);
@@ -45769,7 +45788,7 @@ class Group extends BaseItem {
45769
45788
  }
45770
45789
  break;
45771
45790
  case "Transformation":
45772
- this.transformation.apply(op);
45791
+ super.apply(op);
45773
45792
  break;
45774
45793
  default:
45775
45794
  return;
@@ -6,7 +6,7 @@ import { SelectionContext } from "../../Selection";
6
6
  import { DefaultTextStyles } from "../../Settings";
7
7
  import { Subject } from "../../Subject";
8
8
  import { BaseRange, BaseSelection, Descendant, Operation as SlateOp } from "slate";
9
- import { ItemType, Mbr, Point, RichTextData, Transformation } from "..";
9
+ import { ItemType, Matrix, Mbr, Point, RichTextData, Transformation } from "..";
10
10
  import { HorisontalAlignment, VerticalAlignment } from "../Alignment";
11
11
  import { DrawingContext } from "../DrawingContext";
12
12
  import { LinkTo } from "../LinkTo/LinkTo";
@@ -52,6 +52,7 @@ export declare class RichText extends BaseItem {
52
52
  private _onLimitReached;
53
53
  private shrinkWidth;
54
54
  prevMbr: Mbr | null;
55
+ worldMatrixGetter?: () => Matrix;
55
56
  rtCounter: number;
56
57
  constructor(board: Board, container: Mbr, id?: string, transformation?: Transformation, linkTo?: LinkTo, placeholderText?: string, isInShape?: boolean, autoSize?: boolean, insideOf?: ItemType | undefined, initialTextStyles?: DefaultTextStyles);
57
58
  isClosed(): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "microboard-temp",
3
- "version": "0.11.0",
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",