microboard-temp 0.11.0 → 0.11.1

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.
@@ -21866,7 +21866,11 @@ 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
+ }
21873
+ const containerWorldMatrix = container.getWorldMatrix();
21870
21874
  const local = this.getMbr();
21871
21875
  const corners = [
21872
21876
  new Point(local.left, local.top),
@@ -21875,7 +21879,7 @@ class BaseItem extends Mbr {
21875
21879
  new Point(local.left, local.bottom)
21876
21880
  ];
21877
21881
  for (const c of corners)
21878
- worldMatrix.apply(c);
21882
+ containerWorldMatrix.apply(c);
21879
21883
  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));
21880
21884
  }
21881
21885
  applyAddChildren(childIds) {
@@ -22154,6 +22158,7 @@ class RichText extends BaseItem {
22154
22158
  _onLimitReached = () => {};
22155
22159
  shrinkWidth = false;
22156
22160
  prevMbr = null;
22161
+ worldMatrixGetter;
22157
22162
  rtCounter = 0;
22158
22163
  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
22164
  super(board, id);
@@ -22323,7 +22328,7 @@ class RichText extends BaseItem {
22323
22328
  };
22324
22329
  calcAutoSize(blockNodes) {
22325
22330
  const nodes = blockNodes ? blockNodes : this.getBlockNodes();
22326
- const container = this.getTransformedContainer();
22331
+ const container = this.getLayoutContainer();
22327
22332
  const containerWidth = container.getWidth();
22328
22333
  const containerHeight = container.getHeight();
22329
22334
  const optimal = findOptimalMaxWidthForTextAutoSize(nodes, containerWidth, containerHeight, containerWidth);
@@ -22331,7 +22336,7 @@ class RichText extends BaseItem {
22331
22336
  }
22332
22337
  applyAutoSizeScale(textScale, blockNodes) {
22333
22338
  const nodes = blockNodes ? blockNodes : this.getBlockNodes();
22334
- const container = this.getTransformedContainer();
22339
+ const container = this.getLayoutContainer();
22335
22340
  const containerWidth = container.getWidth();
22336
22341
  const containerHeight = container.getHeight();
22337
22342
  this.layoutNodes = getBlockNodes(nodes, containerWidth / textScale);
@@ -22453,6 +22458,13 @@ class RichText extends BaseItem {
22453
22458
  }
22454
22459
  return this.container.getTransformed(this.transformation.toMatrix());
22455
22460
  }
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
+ }
22456
22468
  emitWithoutApplying = (op) => {
22457
22469
  if (this.board.events) {
22458
22470
  this.board.events.emit(op);
@@ -36419,6 +36431,7 @@ class AINode extends BaseItem {
36419
36431
  this.subject.publish(this);
36420
36432
  });
36421
36433
  this.text.insideOf = "AINode";
36434
+ this.text.worldMatrixGetter = () => this.getWorldMatrix();
36422
36435
  this.transformPath();
36423
36436
  }
36424
36437
  transformPath() {
@@ -36510,7 +36523,7 @@ class AINode extends BaseItem {
36510
36523
  this.text.apply(op);
36511
36524
  break;
36512
36525
  case "Transformation":
36513
- this.text.transformation.apply(op);
36526
+ super.apply(op);
36514
36527
  break;
36515
36528
  case "LinkTo":
36516
36529
  this.linkTo.apply(op);
@@ -40440,6 +40453,7 @@ class Sticker extends BaseItem {
40440
40453
  this.linkTo = new LinkTo(this.id, this.board.events);
40441
40454
  this.transformation = new Transformation(this.id, this.board.events);
40442
40455
  this.text = new RichText(board, this.textContainer, this.id, this.transformation, this.linkTo, " ", false, true, this.itemType);
40456
+ this.text.worldMatrixGetter = () => this.getWorldMatrix();
40443
40457
  this.transformation.subject.subscribe((_subject, op) => {
40444
40458
  this.transformPath();
40445
40459
  if (op.method === "applyMatrix") {
@@ -40543,7 +40557,7 @@ class Sticker extends BaseItem {
40543
40557
  this.text.apply(op);
40544
40558
  break;
40545
40559
  case "Transformation":
40546
- this.transformation.apply(op);
40560
+ super.apply(op);
40547
40561
  break;
40548
40562
  case "LinkTo":
40549
40563
  this.linkTo.apply(op);
package/dist/cjs/index.js CHANGED
@@ -21866,7 +21866,11 @@ 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
+ }
21873
+ const containerWorldMatrix = container.getWorldMatrix();
21870
21874
  const local = this.getMbr();
21871
21875
  const corners = [
21872
21876
  new Point(local.left, local.top),
@@ -21875,7 +21879,7 @@ class BaseItem extends Mbr {
21875
21879
  new Point(local.left, local.bottom)
21876
21880
  ];
21877
21881
  for (const c of corners)
21878
- worldMatrix.apply(c);
21882
+ containerWorldMatrix.apply(c);
21879
21883
  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));
21880
21884
  }
21881
21885
  applyAddChildren(childIds) {
@@ -22154,6 +22158,7 @@ class RichText extends BaseItem {
22154
22158
  _onLimitReached = () => {};
22155
22159
  shrinkWidth = false;
22156
22160
  prevMbr = null;
22161
+ worldMatrixGetter;
22157
22162
  rtCounter = 0;
22158
22163
  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
22164
  super(board, id);
@@ -22323,7 +22328,7 @@ class RichText extends BaseItem {
22323
22328
  };
22324
22329
  calcAutoSize(blockNodes) {
22325
22330
  const nodes = blockNodes ? blockNodes : this.getBlockNodes();
22326
- const container = this.getTransformedContainer();
22331
+ const container = this.getLayoutContainer();
22327
22332
  const containerWidth = container.getWidth();
22328
22333
  const containerHeight = container.getHeight();
22329
22334
  const optimal = findOptimalMaxWidthForTextAutoSize(nodes, containerWidth, containerHeight, containerWidth);
@@ -22331,7 +22336,7 @@ class RichText extends BaseItem {
22331
22336
  }
22332
22337
  applyAutoSizeScale(textScale, blockNodes) {
22333
22338
  const nodes = blockNodes ? blockNodes : this.getBlockNodes();
22334
- const container = this.getTransformedContainer();
22339
+ const container = this.getLayoutContainer();
22335
22340
  const containerWidth = container.getWidth();
22336
22341
  const containerHeight = container.getHeight();
22337
22342
  this.layoutNodes = getBlockNodes(nodes, containerWidth / textScale);
@@ -22453,6 +22458,13 @@ class RichText extends BaseItem {
22453
22458
  }
22454
22459
  return this.container.getTransformed(this.transformation.toMatrix());
22455
22460
  }
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
+ }
22456
22468
  emitWithoutApplying = (op) => {
22457
22469
  if (this.board.events) {
22458
22470
  this.board.events.emit(op);
@@ -36419,6 +36431,7 @@ class AINode extends BaseItem {
36419
36431
  this.subject.publish(this);
36420
36432
  });
36421
36433
  this.text.insideOf = "AINode";
36434
+ this.text.worldMatrixGetter = () => this.getWorldMatrix();
36422
36435
  this.transformPath();
36423
36436
  }
36424
36437
  transformPath() {
@@ -36510,7 +36523,7 @@ class AINode extends BaseItem {
36510
36523
  this.text.apply(op);
36511
36524
  break;
36512
36525
  case "Transformation":
36513
- this.text.transformation.apply(op);
36526
+ super.apply(op);
36514
36527
  break;
36515
36528
  case "LinkTo":
36516
36529
  this.linkTo.apply(op);
@@ -40440,6 +40453,7 @@ class Sticker extends BaseItem {
40440
40453
  this.linkTo = new LinkTo(this.id, this.board.events);
40441
40454
  this.transformation = new Transformation(this.id, this.board.events);
40442
40455
  this.text = new RichText(board, this.textContainer, this.id, this.transformation, this.linkTo, " ", false, true, this.itemType);
40456
+ this.text.worldMatrixGetter = () => this.getWorldMatrix();
40443
40457
  this.transformation.subject.subscribe((_subject, op) => {
40444
40458
  this.transformPath();
40445
40459
  if (op.method === "applyMatrix") {
@@ -40543,7 +40557,7 @@ class Sticker extends BaseItem {
40543
40557
  this.text.apply(op);
40544
40558
  break;
40545
40559
  case "Transformation":
40546
- this.transformation.apply(op);
40560
+ super.apply(op);
40547
40561
  break;
40548
40562
  case "LinkTo":
40549
40563
  this.linkTo.apply(op);
package/dist/cjs/node.js CHANGED
@@ -24338,7 +24338,11 @@ 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
+ }
24345
+ const containerWorldMatrix = container.getWorldMatrix();
24342
24346
  const local = this.getMbr();
24343
24347
  const corners = [
24344
24348
  new Point(local.left, local.top),
@@ -24347,7 +24351,7 @@ class BaseItem extends Mbr {
24347
24351
  new Point(local.left, local.bottom)
24348
24352
  ];
24349
24353
  for (const c of corners)
24350
- worldMatrix.apply(c);
24354
+ containerWorldMatrix.apply(c);
24351
24355
  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));
24352
24356
  }
24353
24357
  applyAddChildren(childIds) {
@@ -24626,6 +24630,7 @@ class RichText extends BaseItem {
24626
24630
  _onLimitReached = () => {};
24627
24631
  shrinkWidth = false;
24628
24632
  prevMbr = null;
24633
+ worldMatrixGetter;
24629
24634
  rtCounter = 0;
24630
24635
  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
24636
  super(board, id);
@@ -24795,7 +24800,7 @@ class RichText extends BaseItem {
24795
24800
  };
24796
24801
  calcAutoSize(blockNodes) {
24797
24802
  const nodes = blockNodes ? blockNodes : this.getBlockNodes();
24798
- const container = this.getTransformedContainer();
24803
+ const container = this.getLayoutContainer();
24799
24804
  const containerWidth = container.getWidth();
24800
24805
  const containerHeight = container.getHeight();
24801
24806
  const optimal = findOptimalMaxWidthForTextAutoSize(nodes, containerWidth, containerHeight, containerWidth);
@@ -24803,7 +24808,7 @@ class RichText extends BaseItem {
24803
24808
  }
24804
24809
  applyAutoSizeScale(textScale, blockNodes) {
24805
24810
  const nodes = blockNodes ? blockNodes : this.getBlockNodes();
24806
- const container = this.getTransformedContainer();
24811
+ const container = this.getLayoutContainer();
24807
24812
  const containerWidth = container.getWidth();
24808
24813
  const containerHeight = container.getHeight();
24809
24814
  this.layoutNodes = getBlockNodes(nodes, containerWidth / textScale);
@@ -24925,6 +24930,13 @@ class RichText extends BaseItem {
24925
24930
  }
24926
24931
  return this.container.getTransformed(this.transformation.toMatrix());
24927
24932
  }
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
+ }
24928
24940
  emitWithoutApplying = (op) => {
24929
24941
  if (this.board.events) {
24930
24942
  this.board.events.emit(op);
@@ -38892,6 +38904,7 @@ class AINode extends BaseItem {
38892
38904
  this.subject.publish(this);
38893
38905
  });
38894
38906
  this.text.insideOf = "AINode";
38907
+ this.text.worldMatrixGetter = () => this.getWorldMatrix();
38895
38908
  this.transformPath();
38896
38909
  }
38897
38910
  transformPath() {
@@ -38983,7 +38996,7 @@ class AINode extends BaseItem {
38983
38996
  this.text.apply(op);
38984
38997
  break;
38985
38998
  case "Transformation":
38986
- this.text.transformation.apply(op);
38999
+ super.apply(op);
38987
39000
  break;
38988
39001
  case "LinkTo":
38989
39002
  this.linkTo.apply(op);
@@ -42913,6 +42926,7 @@ class Sticker extends BaseItem {
42913
42926
  this.linkTo = new LinkTo(this.id, this.board.events);
42914
42927
  this.transformation = new Transformation(this.id, this.board.events);
42915
42928
  this.text = new RichText(board, this.textContainer, this.id, this.transformation, this.linkTo, " ", false, true, this.itemType);
42929
+ this.text.worldMatrixGetter = () => this.getWorldMatrix();
42916
42930
  this.transformation.subject.subscribe((_subject, op) => {
42917
42931
  this.transformPath();
42918
42932
  if (op.method === "applyMatrix") {
@@ -43016,7 +43030,7 @@ class Sticker extends BaseItem {
43016
43030
  this.text.apply(op);
43017
43031
  break;
43018
43032
  case "Transformation":
43019
- this.transformation.apply(op);
43033
+ super.apply(op);
43020
43034
  break;
43021
43035
  case "LinkTo":
43022
43036
  this.linkTo.apply(op);
@@ -21695,7 +21695,11 @@ 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
+ }
21702
+ const containerWorldMatrix = container.getWorldMatrix();
21699
21703
  const local = this.getMbr();
21700
21704
  const corners = [
21701
21705
  new Point(local.left, local.top),
@@ -21704,7 +21708,7 @@ class BaseItem extends Mbr {
21704
21708
  new Point(local.left, local.bottom)
21705
21709
  ];
21706
21710
  for (const c of corners)
21707
- worldMatrix.apply(c);
21711
+ containerWorldMatrix.apply(c);
21708
21712
  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));
21709
21713
  }
21710
21714
  applyAddChildren(childIds) {
@@ -21983,6 +21987,7 @@ class RichText extends BaseItem {
21983
21987
  _onLimitReached = () => {};
21984
21988
  shrinkWidth = false;
21985
21989
  prevMbr = null;
21990
+ worldMatrixGetter;
21986
21991
  rtCounter = 0;
21987
21992
  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
21993
  super(board, id);
@@ -22152,7 +22157,7 @@ class RichText extends BaseItem {
22152
22157
  };
22153
22158
  calcAutoSize(blockNodes) {
22154
22159
  const nodes = blockNodes ? blockNodes : this.getBlockNodes();
22155
- const container = this.getTransformedContainer();
22160
+ const container = this.getLayoutContainer();
22156
22161
  const containerWidth = container.getWidth();
22157
22162
  const containerHeight = container.getHeight();
22158
22163
  const optimal = findOptimalMaxWidthForTextAutoSize(nodes, containerWidth, containerHeight, containerWidth);
@@ -22160,7 +22165,7 @@ class RichText extends BaseItem {
22160
22165
  }
22161
22166
  applyAutoSizeScale(textScale, blockNodes) {
22162
22167
  const nodes = blockNodes ? blockNodes : this.getBlockNodes();
22163
- const container = this.getTransformedContainer();
22168
+ const container = this.getLayoutContainer();
22164
22169
  const containerWidth = container.getWidth();
22165
22170
  const containerHeight = container.getHeight();
22166
22171
  this.layoutNodes = getBlockNodes(nodes, containerWidth / textScale);
@@ -22282,6 +22287,13 @@ class RichText extends BaseItem {
22282
22287
  }
22283
22288
  return this.container.getTransformed(this.transformation.toMatrix());
22284
22289
  }
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
+ }
22285
22297
  emitWithoutApplying = (op) => {
22286
22298
  if (this.board.events) {
22287
22299
  this.board.events.emit(op);
@@ -36248,6 +36260,7 @@ class AINode extends BaseItem {
36248
36260
  this.subject.publish(this);
36249
36261
  });
36250
36262
  this.text.insideOf = "AINode";
36263
+ this.text.worldMatrixGetter = () => this.getWorldMatrix();
36251
36264
  this.transformPath();
36252
36265
  }
36253
36266
  transformPath() {
@@ -36339,7 +36352,7 @@ class AINode extends BaseItem {
36339
36352
  this.text.apply(op);
36340
36353
  break;
36341
36354
  case "Transformation":
36342
- this.text.transformation.apply(op);
36355
+ super.apply(op);
36343
36356
  break;
36344
36357
  case "LinkTo":
36345
36358
  this.linkTo.apply(op);
@@ -40269,6 +40282,7 @@ class Sticker extends BaseItem {
40269
40282
  this.linkTo = new LinkTo(this.id, this.board.events);
40270
40283
  this.transformation = new Transformation(this.id, this.board.events);
40271
40284
  this.text = new RichText(board, this.textContainer, this.id, this.transformation, this.linkTo, " ", false, true, this.itemType);
40285
+ this.text.worldMatrixGetter = () => this.getWorldMatrix();
40272
40286
  this.transformation.subject.subscribe((_subject, op) => {
40273
40287
  this.transformPath();
40274
40288
  if (op.method === "applyMatrix") {
@@ -40372,7 +40386,7 @@ class Sticker extends BaseItem {
40372
40386
  this.text.apply(op);
40373
40387
  break;
40374
40388
  case "Transformation":
40375
- this.transformation.apply(op);
40389
+ super.apply(op);
40376
40390
  break;
40377
40391
  case "LinkTo":
40378
40392
  this.linkTo.apply(op);
package/dist/esm/index.js CHANGED
@@ -21688,7 +21688,11 @@ 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
+ }
21695
+ const containerWorldMatrix = container.getWorldMatrix();
21692
21696
  const local = this.getMbr();
21693
21697
  const corners = [
21694
21698
  new Point(local.left, local.top),
@@ -21697,7 +21701,7 @@ class BaseItem extends Mbr {
21697
21701
  new Point(local.left, local.bottom)
21698
21702
  ];
21699
21703
  for (const c of corners)
21700
- worldMatrix.apply(c);
21704
+ containerWorldMatrix.apply(c);
21701
21705
  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));
21702
21706
  }
21703
21707
  applyAddChildren(childIds) {
@@ -21976,6 +21980,7 @@ class RichText extends BaseItem {
21976
21980
  _onLimitReached = () => {};
21977
21981
  shrinkWidth = false;
21978
21982
  prevMbr = null;
21983
+ worldMatrixGetter;
21979
21984
  rtCounter = 0;
21980
21985
  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
21986
  super(board, id);
@@ -22145,7 +22150,7 @@ class RichText extends BaseItem {
22145
22150
  };
22146
22151
  calcAutoSize(blockNodes) {
22147
22152
  const nodes = blockNodes ? blockNodes : this.getBlockNodes();
22148
- const container = this.getTransformedContainer();
22153
+ const container = this.getLayoutContainer();
22149
22154
  const containerWidth = container.getWidth();
22150
22155
  const containerHeight = container.getHeight();
22151
22156
  const optimal = findOptimalMaxWidthForTextAutoSize(nodes, containerWidth, containerHeight, containerWidth);
@@ -22153,7 +22158,7 @@ class RichText extends BaseItem {
22153
22158
  }
22154
22159
  applyAutoSizeScale(textScale, blockNodes) {
22155
22160
  const nodes = blockNodes ? blockNodes : this.getBlockNodes();
22156
- const container = this.getTransformedContainer();
22161
+ const container = this.getLayoutContainer();
22157
22162
  const containerWidth = container.getWidth();
22158
22163
  const containerHeight = container.getHeight();
22159
22164
  this.layoutNodes = getBlockNodes(nodes, containerWidth / textScale);
@@ -22275,6 +22280,13 @@ class RichText extends BaseItem {
22275
22280
  }
22276
22281
  return this.container.getTransformed(this.transformation.toMatrix());
22277
22282
  }
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
+ }
22278
22290
  emitWithoutApplying = (op) => {
22279
22291
  if (this.board.events) {
22280
22292
  this.board.events.emit(op);
@@ -36241,6 +36253,7 @@ class AINode extends BaseItem {
36241
36253
  this.subject.publish(this);
36242
36254
  });
36243
36255
  this.text.insideOf = "AINode";
36256
+ this.text.worldMatrixGetter = () => this.getWorldMatrix();
36244
36257
  this.transformPath();
36245
36258
  }
36246
36259
  transformPath() {
@@ -36332,7 +36345,7 @@ class AINode extends BaseItem {
36332
36345
  this.text.apply(op);
36333
36346
  break;
36334
36347
  case "Transformation":
36335
- this.text.transformation.apply(op);
36348
+ super.apply(op);
36336
36349
  break;
36337
36350
  case "LinkTo":
36338
36351
  this.linkTo.apply(op);
@@ -40262,6 +40275,7 @@ class Sticker extends BaseItem {
40262
40275
  this.linkTo = new LinkTo(this.id, this.board.events);
40263
40276
  this.transformation = new Transformation(this.id, this.board.events);
40264
40277
  this.text = new RichText(board, this.textContainer, this.id, this.transformation, this.linkTo, " ", false, true, this.itemType);
40278
+ this.text.worldMatrixGetter = () => this.getWorldMatrix();
40265
40279
  this.transformation.subject.subscribe((_subject, op) => {
40266
40280
  this.transformPath();
40267
40281
  if (op.method === "applyMatrix") {
@@ -40365,7 +40379,7 @@ class Sticker extends BaseItem {
40365
40379
  this.text.apply(op);
40366
40380
  break;
40367
40381
  case "Transformation":
40368
- this.transformation.apply(op);
40382
+ super.apply(op);
40369
40383
  break;
40370
40384
  case "LinkTo":
40371
40385
  this.linkTo.apply(op);
package/dist/esm/node.js CHANGED
@@ -24155,7 +24155,11 @@ 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
+ }
24162
+ const containerWorldMatrix = container.getWorldMatrix();
24159
24163
  const local = this.getMbr();
24160
24164
  const corners = [
24161
24165
  new Point(local.left, local.top),
@@ -24164,7 +24168,7 @@ class BaseItem extends Mbr {
24164
24168
  new Point(local.left, local.bottom)
24165
24169
  ];
24166
24170
  for (const c of corners)
24167
- worldMatrix.apply(c);
24171
+ containerWorldMatrix.apply(c);
24168
24172
  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));
24169
24173
  }
24170
24174
  applyAddChildren(childIds) {
@@ -24443,6 +24447,7 @@ class RichText extends BaseItem {
24443
24447
  _onLimitReached = () => {};
24444
24448
  shrinkWidth = false;
24445
24449
  prevMbr = null;
24450
+ worldMatrixGetter;
24446
24451
  rtCounter = 0;
24447
24452
  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
24453
  super(board, id);
@@ -24612,7 +24617,7 @@ class RichText extends BaseItem {
24612
24617
  };
24613
24618
  calcAutoSize(blockNodes) {
24614
24619
  const nodes = blockNodes ? blockNodes : this.getBlockNodes();
24615
- const container = this.getTransformedContainer();
24620
+ const container = this.getLayoutContainer();
24616
24621
  const containerWidth = container.getWidth();
24617
24622
  const containerHeight = container.getHeight();
24618
24623
  const optimal = findOptimalMaxWidthForTextAutoSize(nodes, containerWidth, containerHeight, containerWidth);
@@ -24620,7 +24625,7 @@ class RichText extends BaseItem {
24620
24625
  }
24621
24626
  applyAutoSizeScale(textScale, blockNodes) {
24622
24627
  const nodes = blockNodes ? blockNodes : this.getBlockNodes();
24623
- const container = this.getTransformedContainer();
24628
+ const container = this.getLayoutContainer();
24624
24629
  const containerWidth = container.getWidth();
24625
24630
  const containerHeight = container.getHeight();
24626
24631
  this.layoutNodes = getBlockNodes(nodes, containerWidth / textScale);
@@ -24742,6 +24747,13 @@ class RichText extends BaseItem {
24742
24747
  }
24743
24748
  return this.container.getTransformed(this.transformation.toMatrix());
24744
24749
  }
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
+ }
24745
24757
  emitWithoutApplying = (op) => {
24746
24758
  if (this.board.events) {
24747
24759
  this.board.events.emit(op);
@@ -38709,6 +38721,7 @@ class AINode extends BaseItem {
38709
38721
  this.subject.publish(this);
38710
38722
  });
38711
38723
  this.text.insideOf = "AINode";
38724
+ this.text.worldMatrixGetter = () => this.getWorldMatrix();
38712
38725
  this.transformPath();
38713
38726
  }
38714
38727
  transformPath() {
@@ -38800,7 +38813,7 @@ class AINode extends BaseItem {
38800
38813
  this.text.apply(op);
38801
38814
  break;
38802
38815
  case "Transformation":
38803
- this.text.transformation.apply(op);
38816
+ super.apply(op);
38804
38817
  break;
38805
38818
  case "LinkTo":
38806
38819
  this.linkTo.apply(op);
@@ -42730,6 +42743,7 @@ class Sticker extends BaseItem {
42730
42743
  this.linkTo = new LinkTo(this.id, this.board.events);
42731
42744
  this.transformation = new Transformation(this.id, this.board.events);
42732
42745
  this.text = new RichText(board, this.textContainer, this.id, this.transformation, this.linkTo, " ", false, true, this.itemType);
42746
+ this.text.worldMatrixGetter = () => this.getWorldMatrix();
42733
42747
  this.transformation.subject.subscribe((_subject, op) => {
42734
42748
  this.transformPath();
42735
42749
  if (op.method === "applyMatrix") {
@@ -42833,7 +42847,7 @@ class Sticker extends BaseItem {
42833
42847
  this.text.apply(op);
42834
42848
  break;
42835
42849
  case "Transformation":
42836
- this.transformation.apply(op);
42850
+ super.apply(op);
42837
42851
  break;
42838
42852
  case "LinkTo":
42839
42853
  this.linkTo.apply(op);
@@ -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,8 @@ 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
+ worldMatrixGetter?: () => Matrix;
55
57
  rtCounter: number;
56
58
  constructor(board: Board, container: Mbr, id?: string, transformation?: Transformation, linkTo?: LinkTo, placeholderText?: string, isInShape?: boolean, autoSize?: boolean, insideOf?: ItemType | undefined, initialTextStyles?: DefaultTextStyles);
57
59
  isClosed(): boolean;
@@ -94,6 +96,13 @@ export declare class RichText extends BaseItem {
94
96
  * Get the container that would be used to align the CanvasDocument.
95
97
  */
96
98
  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;
97
106
  emitWithoutApplying: (op: RichTextOperation) => void;
98
107
  emit: (op: RichTextOperation) => void;
99
108
  apply(op: Operation): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "microboard-temp",
3
- "version": "0.11.0",
3
+ "version": "0.11.1",
4
4
  "description": "A flexible interactive whiteboard library",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",