microboard-temp 0.13.7 → 0.13.9

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.
@@ -22208,7 +22208,6 @@ class RichText extends BaseItem {
22208
22208
  autoSizeScale = 1;
22209
22209
  containerMaxWidth;
22210
22210
  linkTo;
22211
- localArea;
22212
22211
  maxHeight;
22213
22212
  selection;
22214
22213
  transformationRenderBlock = undefined;
@@ -22230,7 +22229,6 @@ class RichText extends BaseItem {
22230
22229
  this.autoSize = autoSize;
22231
22230
  this.insideOf = insideOf;
22232
22231
  this.initialTextStyles = initialTextStyles;
22233
- this.localArea = container.copy();
22234
22232
  counter = counter + 1;
22235
22233
  this.rtCounter = counter;
22236
22234
  this.linkTo = linkTo || new LinkTo(this.id, this.board.events);
@@ -22383,7 +22381,7 @@ class RichText extends BaseItem {
22383
22381
  this.layoutNodes.width = this.containerMaxWidth;
22384
22382
  }
22385
22383
  }
22386
- this.alignInRectangle(this.localArea, this.editor.verticalAlignment);
22384
+ this.alignInRectangle(this.getTransformedContainer(), this.editor.verticalAlignment);
22387
22385
  this.transformCanvas();
22388
22386
  this.subject.publish(this);
22389
22387
  this.updateRequired = false;
@@ -22463,7 +22461,7 @@ class RichText extends BaseItem {
22463
22461
  this.right = transformed.right;
22464
22462
  this.bottom = transformed.bottom;
22465
22463
  } else {
22466
- this.alignInRectangle(this.localArea, this.editor.verticalAlignment);
22464
+ this.alignInRectangle(this.getTransformedContainer(), this.editor.verticalAlignment);
22467
22465
  }
22468
22466
  this.setClipPath();
22469
22467
  if (!this.isInShape && !this.autoSize) {
@@ -22491,16 +22489,16 @@ class RichText extends BaseItem {
22491
22489
  }
22492
22490
  }
22493
22491
  setClipPath() {
22494
- const width = this.localArea.getWidth();
22495
- const height = this.localArea.getHeight();
22492
+ const container = this.getTransformedContainer();
22493
+ const width = container.getWidth();
22494
+ const height = container.getHeight();
22496
22495
  this.clipPath = new conf.path2DFactory;
22497
22496
  this.clipPath.rect(0, 0, width, height);
22498
22497
  }
22499
22498
  setContainer(container) {
22500
22499
  this.isContainerSet = true;
22501
- this.localArea = container.copy();
22502
22500
  this.container = container;
22503
- this.updateElement();
22501
+ this.alignInRectangle(this.getTransformedContainer(), this.editor.verticalAlignment);
22504
22502
  }
22505
22503
  applyMaxWidth(maxWidth) {
22506
22504
  const shouldNotShrink = this.insideOf !== "RichText" && this.insideOf !== "AINode" && this.containerMaxWidth && this.shrinkWidth;
@@ -22523,8 +22521,8 @@ class RichText extends BaseItem {
22523
22521
  matrix = this.transformation.toMatrix();
22524
22522
  }
22525
22523
  const { translateX, translateY, scaleX, scaleY } = matrix;
22526
- const scaledMatrix = new Matrix(translateX, translateY, scaleX * extraScale, scaleY * extraScale);
22527
- return this.localArea.getTransformed(scaledMatrix);
22524
+ const scaledMatrix = new Matrix(translateX, translateY, scaleX, scaleY);
22525
+ return this.container.getTransformed(scaledMatrix);
22528
22526
  }
22529
22527
  emitWithoutApplying = (op) => {
22530
22528
  if (this.board.events) {
@@ -22866,7 +22864,7 @@ class RichText extends BaseItem {
22866
22864
  if (typeof document !== "undefined") {
22867
22865
  document.fonts.ready.then(() => {
22868
22866
  this.layoutNodes = getBlockNodes(this.getBlockNodes(), this.shrinkWidth ? Infinity : this.getMaxWidth() || 0, this.shrinkWidth, this.insideOf === "Frame");
22869
- this.alignInRectangle(this.localArea, this.editor.verticalAlignment);
22867
+ this.alignInRectangle(this.getTransformedContainer(), this.editor.verticalAlignment);
22870
22868
  this.transformCanvas();
22871
22869
  });
22872
22870
  }
@@ -22896,7 +22894,7 @@ class RichText extends BaseItem {
22896
22894
  const scaledMatrix = new Matrix(translateX, translateY, scaleX * extraScale, scaleY * extraScale);
22897
22895
  context.matrix = scaledMatrix;
22898
22896
  context.applyChanges();
22899
- ctx.translate(this.left, this.top);
22897
+ ctx.translate(this.container.left, this.container.top);
22900
22898
  const shouldClip = this.insideOf === "Shape" || this.insideOf === "Sticker";
22901
22899
  if (shouldClip) {
22902
22900
  ctx.clip(this.clipPath.nativePath);
@@ -23037,7 +23035,7 @@ class RichText extends BaseItem {
23037
23035
  }
23038
23036
  const { translateX, translateY, scaleX, scaleY } = matrix;
23039
23037
  const scaledMatrix = new Matrix(translateX, translateY, scaleX * extraScale, scaleY * extraScale);
23040
- const transform = `translate(${scaledMatrix.translateX + this.left * scaledMatrix.scaleX}px, ${scaledMatrix.translateY + this.top * scaledMatrix.scaleY}px) scale(${scaledMatrix.scaleX}, ${scaledMatrix.scaleY})`;
23038
+ const transform = `translate(${scaledMatrix.translateX + this.container.left * scaledMatrix.scaleX}px, ${scaledMatrix.translateY + this.container.top * scaledMatrix.scaleY}px) scale(${scaledMatrix.scaleX}, ${scaledMatrix.scaleY})`;
23041
23039
  const transformedWidth = this.getMbr().getWidth();
23042
23040
  const transformedHeight = this.getMbr().getHeight();
23043
23041
  const div = documentFactory.createElement("rich-text");
@@ -23133,19 +23131,6 @@ class RichText extends BaseItem {
23133
23131
  getPrevMbr() {
23134
23132
  return this.prevMbr;
23135
23133
  }
23136
- getMbr() {
23137
- const cameraScale = this.board.camera.getScale();
23138
- const extraScale = this.renderingScale ? this.renderingScale(cameraScale) : 1;
23139
- let matrix;
23140
- if (this.customTransformationMatrix) {
23141
- matrix = this.customTransformationMatrix();
23142
- } else {
23143
- matrix = this.transformation.toMatrix();
23144
- }
23145
- const { translateX, translateY, scaleX, scaleY } = matrix;
23146
- const scaledMatrix = new Matrix(translateX, translateY, scaleX * extraScale, scaleY * extraScale);
23147
- return new Mbr(this.left, this.top, this.right, this.bottom).getTransformed(scaledMatrix);
23148
- }
23149
23134
  }
23150
23135
 
23151
23136
  // src/Items/Mbr/updateRects.ts
@@ -41045,8 +41030,8 @@ class DefaultFrameData {
41045
41030
 
41046
41031
  // src/Items/Frame/Frame.ts
41047
41032
  var defaultFrameData = new DefaultFrameData;
41048
- var HEADING_TOP_OFFSET = -45;
41049
- var HEADING_BOTTOM_OFFSET = -12;
41033
+ var HEADING_TOP_OFFSET = -33;
41034
+ var HEADING_BOTTOM_OFFSET = -5;
41050
41035
 
41051
41036
  class Frame2 extends BaseItem {
41052
41037
  getItemById;
@@ -41062,7 +41047,7 @@ class Frame2 extends BaseItem {
41062
41047
  parent = "Board";
41063
41048
  transformation;
41064
41049
  subject = new Subject;
41065
- textContainer;
41050
+ textContainer = new Mbr;
41066
41051
  path;
41067
41052
  children = [];
41068
41053
  mbr = new Mbr;
@@ -41083,12 +41068,13 @@ class Frame2 extends BaseItem {
41083
41068
  this.borderOpacity = borderOpacity;
41084
41069
  this.borderStyle = borderStyle;
41085
41070
  this.borderWidth = borderWidth;
41086
- this.textContainer = Frames[this.shapeType].textBounds.copy();
41087
- this.textContainer.top = HEADING_TOP_OFFSET;
41088
- this.textContainer.bottom = HEADING_BOTTOM_OFFSET;
41089
41071
  this.path = Frames[this.shapeType].path.copy();
41090
41072
  this.transformation = new Transformation(this.id, board.events);
41091
41073
  this.linkTo = new LinkTo(this.id, board.events);
41074
+ const textBounds = Frames[this.shapeType].textBounds.copy();
41075
+ textBounds.top = HEADING_TOP_OFFSET;
41076
+ textBounds.bottom = HEADING_BOTTOM_OFFSET;
41077
+ this.textContainer = textBounds;
41092
41078
  this.text = new RichText(board, this.textContainer, this.id, this.transformation, this.linkTo, this.name, true, false, "Frame", { ...conf.DEFAULT_TEXT_STYLES, fontSize: 18, fontColor: FRAME_TITLE_COLOR });
41093
41079
  this.text.editor.verticalAlignment = "bottom";
41094
41080
  this.text.setSelectionHorisontalAlignment("left");
@@ -41123,11 +41109,17 @@ class Frame2 extends BaseItem {
41123
41109
  }
41124
41110
  initPath() {
41125
41111
  this.path = Frames[this.shapeType].path.copy();
41126
- this.textContainer = Frames[this.shapeType].textBounds.copy();
41127
- this.textContainer.top = HEADING_TOP_OFFSET;
41128
- this.textContainer.bottom = HEADING_BOTTOM_OFFSET;
41129
- this.text.setContainer(this.textContainer.copy());
41130
- this.text.updateElement();
41112
+ this.updateTextContainer();
41113
+ }
41114
+ updateTextContainer() {
41115
+ const textBounds = Frames[this.shapeType].textBounds.copy();
41116
+ textBounds.top = HEADING_TOP_OFFSET;
41117
+ textBounds.bottom = HEADING_BOTTOM_OFFSET;
41118
+ this.textContainer = textBounds;
41119
+ if (this.text) {
41120
+ this.text.setContainer(this.textContainer.copy());
41121
+ this.text.updateElement();
41122
+ }
41131
41123
  }
41132
41124
  getPaths() {
41133
41125
  return this.path;
@@ -41270,9 +41262,7 @@ class Frame2 extends BaseItem {
41270
41262
  }
41271
41263
  if (data.text) {
41272
41264
  this.text.deserialize(data.text);
41273
- this.textContainer.top = HEADING_TOP_OFFSET;
41274
- this.textContainer.bottom = HEADING_BOTTOM_OFFSET;
41275
- this.text.setContainer(this.textContainer.copy());
41265
+ this.updateTextContainer();
41276
41266
  }
41277
41267
  this.canChangeRatio = data.canChangeRatio ?? this.canChangeRatio;
41278
41268
  this.subject.publish(this);
@@ -41288,15 +41278,13 @@ class Frame2 extends BaseItem {
41288
41278
  }
41289
41279
  transformPath(saveProportions = false) {
41290
41280
  this.path = Frames[this.shapeType].path.copy();
41291
- this.textContainer = Frames[this.shapeType].textBounds.copy();
41281
+ this.updateTextContainer();
41292
41282
  if (saveProportions) {
41293
41283
  const newMatrix = this.getSavedProportionsMatrix();
41294
41284
  this.path.transform(newMatrix);
41295
- this.textContainer.transform(newMatrix);
41296
41285
  this.transformation.applyScaleTo(newMatrix.scaleX, newMatrix.scaleY);
41297
41286
  } else {
41298
41287
  this.path.transform(this.transformation.toMatrix());
41299
- this.textContainer.transform(this.transformation.toMatrix());
41300
41288
  }
41301
41289
  this.path.setBackgroundOpacity(this.backgroundOpacity);
41302
41290
  this.path.setBorderWidth(this.borderWidth);
package/dist/cjs/index.js CHANGED
@@ -22208,7 +22208,6 @@ class RichText extends BaseItem {
22208
22208
  autoSizeScale = 1;
22209
22209
  containerMaxWidth;
22210
22210
  linkTo;
22211
- localArea;
22212
22211
  maxHeight;
22213
22212
  selection;
22214
22213
  transformationRenderBlock = undefined;
@@ -22230,7 +22229,6 @@ class RichText extends BaseItem {
22230
22229
  this.autoSize = autoSize;
22231
22230
  this.insideOf = insideOf;
22232
22231
  this.initialTextStyles = initialTextStyles;
22233
- this.localArea = container.copy();
22234
22232
  counter = counter + 1;
22235
22233
  this.rtCounter = counter;
22236
22234
  this.linkTo = linkTo || new LinkTo(this.id, this.board.events);
@@ -22383,7 +22381,7 @@ class RichText extends BaseItem {
22383
22381
  this.layoutNodes.width = this.containerMaxWidth;
22384
22382
  }
22385
22383
  }
22386
- this.alignInRectangle(this.localArea, this.editor.verticalAlignment);
22384
+ this.alignInRectangle(this.getTransformedContainer(), this.editor.verticalAlignment);
22387
22385
  this.transformCanvas();
22388
22386
  this.subject.publish(this);
22389
22387
  this.updateRequired = false;
@@ -22463,7 +22461,7 @@ class RichText extends BaseItem {
22463
22461
  this.right = transformed.right;
22464
22462
  this.bottom = transformed.bottom;
22465
22463
  } else {
22466
- this.alignInRectangle(this.localArea, this.editor.verticalAlignment);
22464
+ this.alignInRectangle(this.getTransformedContainer(), this.editor.verticalAlignment);
22467
22465
  }
22468
22466
  this.setClipPath();
22469
22467
  if (!this.isInShape && !this.autoSize) {
@@ -22491,16 +22489,16 @@ class RichText extends BaseItem {
22491
22489
  }
22492
22490
  }
22493
22491
  setClipPath() {
22494
- const width = this.localArea.getWidth();
22495
- const height = this.localArea.getHeight();
22492
+ const container = this.getTransformedContainer();
22493
+ const width = container.getWidth();
22494
+ const height = container.getHeight();
22496
22495
  this.clipPath = new conf.path2DFactory;
22497
22496
  this.clipPath.rect(0, 0, width, height);
22498
22497
  }
22499
22498
  setContainer(container) {
22500
22499
  this.isContainerSet = true;
22501
- this.localArea = container.copy();
22502
22500
  this.container = container;
22503
- this.updateElement();
22501
+ this.alignInRectangle(this.getTransformedContainer(), this.editor.verticalAlignment);
22504
22502
  }
22505
22503
  applyMaxWidth(maxWidth) {
22506
22504
  const shouldNotShrink = this.insideOf !== "RichText" && this.insideOf !== "AINode" && this.containerMaxWidth && this.shrinkWidth;
@@ -22523,8 +22521,8 @@ class RichText extends BaseItem {
22523
22521
  matrix = this.transformation.toMatrix();
22524
22522
  }
22525
22523
  const { translateX, translateY, scaleX, scaleY } = matrix;
22526
- const scaledMatrix = new Matrix(translateX, translateY, scaleX * extraScale, scaleY * extraScale);
22527
- return this.localArea.getTransformed(scaledMatrix);
22524
+ const scaledMatrix = new Matrix(translateX, translateY, scaleX, scaleY);
22525
+ return this.container.getTransformed(scaledMatrix);
22528
22526
  }
22529
22527
  emitWithoutApplying = (op) => {
22530
22528
  if (this.board.events) {
@@ -22866,7 +22864,7 @@ class RichText extends BaseItem {
22866
22864
  if (typeof document !== "undefined") {
22867
22865
  document.fonts.ready.then(() => {
22868
22866
  this.layoutNodes = getBlockNodes(this.getBlockNodes(), this.shrinkWidth ? Infinity : this.getMaxWidth() || 0, this.shrinkWidth, this.insideOf === "Frame");
22869
- this.alignInRectangle(this.localArea, this.editor.verticalAlignment);
22867
+ this.alignInRectangle(this.getTransformedContainer(), this.editor.verticalAlignment);
22870
22868
  this.transformCanvas();
22871
22869
  });
22872
22870
  }
@@ -22896,7 +22894,7 @@ class RichText extends BaseItem {
22896
22894
  const scaledMatrix = new Matrix(translateX, translateY, scaleX * extraScale, scaleY * extraScale);
22897
22895
  context.matrix = scaledMatrix;
22898
22896
  context.applyChanges();
22899
- ctx.translate(this.left, this.top);
22897
+ ctx.translate(this.container.left, this.container.top);
22900
22898
  const shouldClip = this.insideOf === "Shape" || this.insideOf === "Sticker";
22901
22899
  if (shouldClip) {
22902
22900
  ctx.clip(this.clipPath.nativePath);
@@ -23037,7 +23035,7 @@ class RichText extends BaseItem {
23037
23035
  }
23038
23036
  const { translateX, translateY, scaleX, scaleY } = matrix;
23039
23037
  const scaledMatrix = new Matrix(translateX, translateY, scaleX * extraScale, scaleY * extraScale);
23040
- const transform = `translate(${scaledMatrix.translateX + this.left * scaledMatrix.scaleX}px, ${scaledMatrix.translateY + this.top * scaledMatrix.scaleY}px) scale(${scaledMatrix.scaleX}, ${scaledMatrix.scaleY})`;
23038
+ const transform = `translate(${scaledMatrix.translateX + this.container.left * scaledMatrix.scaleX}px, ${scaledMatrix.translateY + this.container.top * scaledMatrix.scaleY}px) scale(${scaledMatrix.scaleX}, ${scaledMatrix.scaleY})`;
23041
23039
  const transformedWidth = this.getMbr().getWidth();
23042
23040
  const transformedHeight = this.getMbr().getHeight();
23043
23041
  const div = documentFactory.createElement("rich-text");
@@ -23133,19 +23131,6 @@ class RichText extends BaseItem {
23133
23131
  getPrevMbr() {
23134
23132
  return this.prevMbr;
23135
23133
  }
23136
- getMbr() {
23137
- const cameraScale = this.board.camera.getScale();
23138
- const extraScale = this.renderingScale ? this.renderingScale(cameraScale) : 1;
23139
- let matrix;
23140
- if (this.customTransformationMatrix) {
23141
- matrix = this.customTransformationMatrix();
23142
- } else {
23143
- matrix = this.transformation.toMatrix();
23144
- }
23145
- const { translateX, translateY, scaleX, scaleY } = matrix;
23146
- const scaledMatrix = new Matrix(translateX, translateY, scaleX * extraScale, scaleY * extraScale);
23147
- return new Mbr(this.left, this.top, this.right, this.bottom).getTransformed(scaledMatrix);
23148
- }
23149
23134
  }
23150
23135
 
23151
23136
  // src/Items/Mbr/updateRects.ts
@@ -41045,8 +41030,8 @@ class DefaultFrameData {
41045
41030
 
41046
41031
  // src/Items/Frame/Frame.ts
41047
41032
  var defaultFrameData = new DefaultFrameData;
41048
- var HEADING_TOP_OFFSET = -45;
41049
- var HEADING_BOTTOM_OFFSET = -12;
41033
+ var HEADING_TOP_OFFSET = -33;
41034
+ var HEADING_BOTTOM_OFFSET = -5;
41050
41035
 
41051
41036
  class Frame2 extends BaseItem {
41052
41037
  getItemById;
@@ -41062,7 +41047,7 @@ class Frame2 extends BaseItem {
41062
41047
  parent = "Board";
41063
41048
  transformation;
41064
41049
  subject = new Subject;
41065
- textContainer;
41050
+ textContainer = new Mbr;
41066
41051
  path;
41067
41052
  children = [];
41068
41053
  mbr = new Mbr;
@@ -41083,12 +41068,13 @@ class Frame2 extends BaseItem {
41083
41068
  this.borderOpacity = borderOpacity;
41084
41069
  this.borderStyle = borderStyle;
41085
41070
  this.borderWidth = borderWidth;
41086
- this.textContainer = Frames[this.shapeType].textBounds.copy();
41087
- this.textContainer.top = HEADING_TOP_OFFSET;
41088
- this.textContainer.bottom = HEADING_BOTTOM_OFFSET;
41089
41071
  this.path = Frames[this.shapeType].path.copy();
41090
41072
  this.transformation = new Transformation(this.id, board.events);
41091
41073
  this.linkTo = new LinkTo(this.id, board.events);
41074
+ const textBounds = Frames[this.shapeType].textBounds.copy();
41075
+ textBounds.top = HEADING_TOP_OFFSET;
41076
+ textBounds.bottom = HEADING_BOTTOM_OFFSET;
41077
+ this.textContainer = textBounds;
41092
41078
  this.text = new RichText(board, this.textContainer, this.id, this.transformation, this.linkTo, this.name, true, false, "Frame", { ...conf.DEFAULT_TEXT_STYLES, fontSize: 18, fontColor: FRAME_TITLE_COLOR });
41093
41079
  this.text.editor.verticalAlignment = "bottom";
41094
41080
  this.text.setSelectionHorisontalAlignment("left");
@@ -41123,11 +41109,17 @@ class Frame2 extends BaseItem {
41123
41109
  }
41124
41110
  initPath() {
41125
41111
  this.path = Frames[this.shapeType].path.copy();
41126
- this.textContainer = Frames[this.shapeType].textBounds.copy();
41127
- this.textContainer.top = HEADING_TOP_OFFSET;
41128
- this.textContainer.bottom = HEADING_BOTTOM_OFFSET;
41129
- this.text.setContainer(this.textContainer.copy());
41130
- this.text.updateElement();
41112
+ this.updateTextContainer();
41113
+ }
41114
+ updateTextContainer() {
41115
+ const textBounds = Frames[this.shapeType].textBounds.copy();
41116
+ textBounds.top = HEADING_TOP_OFFSET;
41117
+ textBounds.bottom = HEADING_BOTTOM_OFFSET;
41118
+ this.textContainer = textBounds;
41119
+ if (this.text) {
41120
+ this.text.setContainer(this.textContainer.copy());
41121
+ this.text.updateElement();
41122
+ }
41131
41123
  }
41132
41124
  getPaths() {
41133
41125
  return this.path;
@@ -41270,9 +41262,7 @@ class Frame2 extends BaseItem {
41270
41262
  }
41271
41263
  if (data.text) {
41272
41264
  this.text.deserialize(data.text);
41273
- this.textContainer.top = HEADING_TOP_OFFSET;
41274
- this.textContainer.bottom = HEADING_BOTTOM_OFFSET;
41275
- this.text.setContainer(this.textContainer.copy());
41265
+ this.updateTextContainer();
41276
41266
  }
41277
41267
  this.canChangeRatio = data.canChangeRatio ?? this.canChangeRatio;
41278
41268
  this.subject.publish(this);
@@ -41288,15 +41278,13 @@ class Frame2 extends BaseItem {
41288
41278
  }
41289
41279
  transformPath(saveProportions = false) {
41290
41280
  this.path = Frames[this.shapeType].path.copy();
41291
- this.textContainer = Frames[this.shapeType].textBounds.copy();
41281
+ this.updateTextContainer();
41292
41282
  if (saveProportions) {
41293
41283
  const newMatrix = this.getSavedProportionsMatrix();
41294
41284
  this.path.transform(newMatrix);
41295
- this.textContainer.transform(newMatrix);
41296
41285
  this.transformation.applyScaleTo(newMatrix.scaleX, newMatrix.scaleY);
41297
41286
  } else {
41298
41287
  this.path.transform(this.transformation.toMatrix());
41299
- this.textContainer.transform(this.transformation.toMatrix());
41300
41288
  }
41301
41289
  this.path.setBackgroundOpacity(this.backgroundOpacity);
41302
41290
  this.path.setBorderWidth(this.borderWidth);
package/dist/cjs/node.js CHANGED
@@ -24680,7 +24680,6 @@ class RichText extends BaseItem {
24680
24680
  autoSizeScale = 1;
24681
24681
  containerMaxWidth;
24682
24682
  linkTo;
24683
- localArea;
24684
24683
  maxHeight;
24685
24684
  selection;
24686
24685
  transformationRenderBlock = undefined;
@@ -24702,7 +24701,6 @@ class RichText extends BaseItem {
24702
24701
  this.autoSize = autoSize;
24703
24702
  this.insideOf = insideOf;
24704
24703
  this.initialTextStyles = initialTextStyles;
24705
- this.localArea = container.copy();
24706
24704
  counter = counter + 1;
24707
24705
  this.rtCounter = counter;
24708
24706
  this.linkTo = linkTo || new LinkTo(this.id, this.board.events);
@@ -24855,7 +24853,7 @@ class RichText extends BaseItem {
24855
24853
  this.layoutNodes.width = this.containerMaxWidth;
24856
24854
  }
24857
24855
  }
24858
- this.alignInRectangle(this.localArea, this.editor.verticalAlignment);
24856
+ this.alignInRectangle(this.getTransformedContainer(), this.editor.verticalAlignment);
24859
24857
  this.transformCanvas();
24860
24858
  this.subject.publish(this);
24861
24859
  this.updateRequired = false;
@@ -24935,7 +24933,7 @@ class RichText extends BaseItem {
24935
24933
  this.right = transformed.right;
24936
24934
  this.bottom = transformed.bottom;
24937
24935
  } else {
24938
- this.alignInRectangle(this.localArea, this.editor.verticalAlignment);
24936
+ this.alignInRectangle(this.getTransformedContainer(), this.editor.verticalAlignment);
24939
24937
  }
24940
24938
  this.setClipPath();
24941
24939
  if (!this.isInShape && !this.autoSize) {
@@ -24963,16 +24961,16 @@ class RichText extends BaseItem {
24963
24961
  }
24964
24962
  }
24965
24963
  setClipPath() {
24966
- const width = this.localArea.getWidth();
24967
- const height = this.localArea.getHeight();
24964
+ const container = this.getTransformedContainer();
24965
+ const width = container.getWidth();
24966
+ const height = container.getHeight();
24968
24967
  this.clipPath = new conf.path2DFactory;
24969
24968
  this.clipPath.rect(0, 0, width, height);
24970
24969
  }
24971
24970
  setContainer(container) {
24972
24971
  this.isContainerSet = true;
24973
- this.localArea = container.copy();
24974
24972
  this.container = container;
24975
- this.updateElement();
24973
+ this.alignInRectangle(this.getTransformedContainer(), this.editor.verticalAlignment);
24976
24974
  }
24977
24975
  applyMaxWidth(maxWidth) {
24978
24976
  const shouldNotShrink = this.insideOf !== "RichText" && this.insideOf !== "AINode" && this.containerMaxWidth && this.shrinkWidth;
@@ -24995,8 +24993,8 @@ class RichText extends BaseItem {
24995
24993
  matrix = this.transformation.toMatrix();
24996
24994
  }
24997
24995
  const { translateX, translateY, scaleX, scaleY } = matrix;
24998
- const scaledMatrix = new Matrix(translateX, translateY, scaleX * extraScale, scaleY * extraScale);
24999
- return this.localArea.getTransformed(scaledMatrix);
24996
+ const scaledMatrix = new Matrix(translateX, translateY, scaleX, scaleY);
24997
+ return this.container.getTransformed(scaledMatrix);
25000
24998
  }
25001
24999
  emitWithoutApplying = (op) => {
25002
25000
  if (this.board.events) {
@@ -25338,7 +25336,7 @@ class RichText extends BaseItem {
25338
25336
  if (typeof document !== "undefined") {
25339
25337
  document.fonts.ready.then(() => {
25340
25338
  this.layoutNodes = getBlockNodes(this.getBlockNodes(), this.shrinkWidth ? Infinity : this.getMaxWidth() || 0, this.shrinkWidth, this.insideOf === "Frame");
25341
- this.alignInRectangle(this.localArea, this.editor.verticalAlignment);
25339
+ this.alignInRectangle(this.getTransformedContainer(), this.editor.verticalAlignment);
25342
25340
  this.transformCanvas();
25343
25341
  });
25344
25342
  }
@@ -25368,7 +25366,7 @@ class RichText extends BaseItem {
25368
25366
  const scaledMatrix = new Matrix(translateX, translateY, scaleX * extraScale, scaleY * extraScale);
25369
25367
  context.matrix = scaledMatrix;
25370
25368
  context.applyChanges();
25371
- ctx.translate(this.left, this.top);
25369
+ ctx.translate(this.container.left, this.container.top);
25372
25370
  const shouldClip = this.insideOf === "Shape" || this.insideOf === "Sticker";
25373
25371
  if (shouldClip) {
25374
25372
  ctx.clip(this.clipPath.nativePath);
@@ -25509,7 +25507,7 @@ class RichText extends BaseItem {
25509
25507
  }
25510
25508
  const { translateX, translateY, scaleX, scaleY } = matrix;
25511
25509
  const scaledMatrix = new Matrix(translateX, translateY, scaleX * extraScale, scaleY * extraScale);
25512
- const transform = `translate(${scaledMatrix.translateX + this.left * scaledMatrix.scaleX}px, ${scaledMatrix.translateY + this.top * scaledMatrix.scaleY}px) scale(${scaledMatrix.scaleX}, ${scaledMatrix.scaleY})`;
25510
+ const transform = `translate(${scaledMatrix.translateX + this.container.left * scaledMatrix.scaleX}px, ${scaledMatrix.translateY + this.container.top * scaledMatrix.scaleY}px) scale(${scaledMatrix.scaleX}, ${scaledMatrix.scaleY})`;
25513
25511
  const transformedWidth = this.getMbr().getWidth();
25514
25512
  const transformedHeight = this.getMbr().getHeight();
25515
25513
  const div = documentFactory.createElement("rich-text");
@@ -25605,19 +25603,6 @@ class RichText extends BaseItem {
25605
25603
  getPrevMbr() {
25606
25604
  return this.prevMbr;
25607
25605
  }
25608
- getMbr() {
25609
- const cameraScale = this.board.camera.getScale();
25610
- const extraScale = this.renderingScale ? this.renderingScale(cameraScale) : 1;
25611
- let matrix;
25612
- if (this.customTransformationMatrix) {
25613
- matrix = this.customTransformationMatrix();
25614
- } else {
25615
- matrix = this.transformation.toMatrix();
25616
- }
25617
- const { translateX, translateY, scaleX, scaleY } = matrix;
25618
- const scaledMatrix = new Matrix(translateX, translateY, scaleX * extraScale, scaleY * extraScale);
25619
- return new Mbr(this.left, this.top, this.right, this.bottom).getTransformed(scaledMatrix);
25620
- }
25621
25606
  }
25622
25607
 
25623
25608
  // src/Items/Mbr/updateRects.ts
@@ -43518,8 +43503,8 @@ class DefaultFrameData {
43518
43503
 
43519
43504
  // src/Items/Frame/Frame.ts
43520
43505
  var defaultFrameData = new DefaultFrameData;
43521
- var HEADING_TOP_OFFSET = -45;
43522
- var HEADING_BOTTOM_OFFSET = -12;
43506
+ var HEADING_TOP_OFFSET = -33;
43507
+ var HEADING_BOTTOM_OFFSET = -5;
43523
43508
 
43524
43509
  class Frame2 extends BaseItem {
43525
43510
  getItemById;
@@ -43535,7 +43520,7 @@ class Frame2 extends BaseItem {
43535
43520
  parent = "Board";
43536
43521
  transformation;
43537
43522
  subject = new Subject;
43538
- textContainer;
43523
+ textContainer = new Mbr;
43539
43524
  path;
43540
43525
  children = [];
43541
43526
  mbr = new Mbr;
@@ -43556,12 +43541,13 @@ class Frame2 extends BaseItem {
43556
43541
  this.borderOpacity = borderOpacity;
43557
43542
  this.borderStyle = borderStyle;
43558
43543
  this.borderWidth = borderWidth;
43559
- this.textContainer = Frames[this.shapeType].textBounds.copy();
43560
- this.textContainer.top = HEADING_TOP_OFFSET;
43561
- this.textContainer.bottom = HEADING_BOTTOM_OFFSET;
43562
43544
  this.path = Frames[this.shapeType].path.copy();
43563
43545
  this.transformation = new Transformation(this.id, board.events);
43564
43546
  this.linkTo = new LinkTo(this.id, board.events);
43547
+ const textBounds = Frames[this.shapeType].textBounds.copy();
43548
+ textBounds.top = HEADING_TOP_OFFSET;
43549
+ textBounds.bottom = HEADING_BOTTOM_OFFSET;
43550
+ this.textContainer = textBounds;
43565
43551
  this.text = new RichText(board, this.textContainer, this.id, this.transformation, this.linkTo, this.name, true, false, "Frame", { ...conf.DEFAULT_TEXT_STYLES, fontSize: 18, fontColor: FRAME_TITLE_COLOR });
43566
43552
  this.text.editor.verticalAlignment = "bottom";
43567
43553
  this.text.setSelectionHorisontalAlignment("left");
@@ -43596,11 +43582,17 @@ class Frame2 extends BaseItem {
43596
43582
  }
43597
43583
  initPath() {
43598
43584
  this.path = Frames[this.shapeType].path.copy();
43599
- this.textContainer = Frames[this.shapeType].textBounds.copy();
43600
- this.textContainer.top = HEADING_TOP_OFFSET;
43601
- this.textContainer.bottom = HEADING_BOTTOM_OFFSET;
43602
- this.text.setContainer(this.textContainer.copy());
43603
- this.text.updateElement();
43585
+ this.updateTextContainer();
43586
+ }
43587
+ updateTextContainer() {
43588
+ const textBounds = Frames[this.shapeType].textBounds.copy();
43589
+ textBounds.top = HEADING_TOP_OFFSET;
43590
+ textBounds.bottom = HEADING_BOTTOM_OFFSET;
43591
+ this.textContainer = textBounds;
43592
+ if (this.text) {
43593
+ this.text.setContainer(this.textContainer.copy());
43594
+ this.text.updateElement();
43595
+ }
43604
43596
  }
43605
43597
  getPaths() {
43606
43598
  return this.path;
@@ -43743,9 +43735,7 @@ class Frame2 extends BaseItem {
43743
43735
  }
43744
43736
  if (data.text) {
43745
43737
  this.text.deserialize(data.text);
43746
- this.textContainer.top = HEADING_TOP_OFFSET;
43747
- this.textContainer.bottom = HEADING_BOTTOM_OFFSET;
43748
- this.text.setContainer(this.textContainer.copy());
43738
+ this.updateTextContainer();
43749
43739
  }
43750
43740
  this.canChangeRatio = data.canChangeRatio ?? this.canChangeRatio;
43751
43741
  this.subject.publish(this);
@@ -43761,15 +43751,13 @@ class Frame2 extends BaseItem {
43761
43751
  }
43762
43752
  transformPath(saveProportions = false) {
43763
43753
  this.path = Frames[this.shapeType].path.copy();
43764
- this.textContainer = Frames[this.shapeType].textBounds.copy();
43754
+ this.updateTextContainer();
43765
43755
  if (saveProportions) {
43766
43756
  const newMatrix = this.getSavedProportionsMatrix();
43767
43757
  this.path.transform(newMatrix);
43768
- this.textContainer.transform(newMatrix);
43769
43758
  this.transformation.applyScaleTo(newMatrix.scaleX, newMatrix.scaleY);
43770
43759
  } else {
43771
43760
  this.path.transform(this.transformation.toMatrix());
43772
- this.textContainer.transform(this.transformation.toMatrix());
43773
43761
  }
43774
43762
  this.path.setBackgroundOpacity(this.backgroundOpacity);
43775
43763
  this.path.setBorderWidth(this.borderWidth);
@@ -22037,7 +22037,6 @@ class RichText extends BaseItem {
22037
22037
  autoSizeScale = 1;
22038
22038
  containerMaxWidth;
22039
22039
  linkTo;
22040
- localArea;
22041
22040
  maxHeight;
22042
22041
  selection;
22043
22042
  transformationRenderBlock = undefined;
@@ -22059,7 +22058,6 @@ class RichText extends BaseItem {
22059
22058
  this.autoSize = autoSize;
22060
22059
  this.insideOf = insideOf;
22061
22060
  this.initialTextStyles = initialTextStyles;
22062
- this.localArea = container.copy();
22063
22061
  counter = counter + 1;
22064
22062
  this.rtCounter = counter;
22065
22063
  this.linkTo = linkTo || new LinkTo(this.id, this.board.events);
@@ -22212,7 +22210,7 @@ class RichText extends BaseItem {
22212
22210
  this.layoutNodes.width = this.containerMaxWidth;
22213
22211
  }
22214
22212
  }
22215
- this.alignInRectangle(this.localArea, this.editor.verticalAlignment);
22213
+ this.alignInRectangle(this.getTransformedContainer(), this.editor.verticalAlignment);
22216
22214
  this.transformCanvas();
22217
22215
  this.subject.publish(this);
22218
22216
  this.updateRequired = false;
@@ -22292,7 +22290,7 @@ class RichText extends BaseItem {
22292
22290
  this.right = transformed.right;
22293
22291
  this.bottom = transformed.bottom;
22294
22292
  } else {
22295
- this.alignInRectangle(this.localArea, this.editor.verticalAlignment);
22293
+ this.alignInRectangle(this.getTransformedContainer(), this.editor.verticalAlignment);
22296
22294
  }
22297
22295
  this.setClipPath();
22298
22296
  if (!this.isInShape && !this.autoSize) {
@@ -22320,16 +22318,16 @@ class RichText extends BaseItem {
22320
22318
  }
22321
22319
  }
22322
22320
  setClipPath() {
22323
- const width = this.localArea.getWidth();
22324
- const height = this.localArea.getHeight();
22321
+ const container = this.getTransformedContainer();
22322
+ const width = container.getWidth();
22323
+ const height = container.getHeight();
22325
22324
  this.clipPath = new conf.path2DFactory;
22326
22325
  this.clipPath.rect(0, 0, width, height);
22327
22326
  }
22328
22327
  setContainer(container) {
22329
22328
  this.isContainerSet = true;
22330
- this.localArea = container.copy();
22331
22329
  this.container = container;
22332
- this.updateElement();
22330
+ this.alignInRectangle(this.getTransformedContainer(), this.editor.verticalAlignment);
22333
22331
  }
22334
22332
  applyMaxWidth(maxWidth) {
22335
22333
  const shouldNotShrink = this.insideOf !== "RichText" && this.insideOf !== "AINode" && this.containerMaxWidth && this.shrinkWidth;
@@ -22352,8 +22350,8 @@ class RichText extends BaseItem {
22352
22350
  matrix = this.transformation.toMatrix();
22353
22351
  }
22354
22352
  const { translateX, translateY, scaleX, scaleY } = matrix;
22355
- const scaledMatrix = new Matrix(translateX, translateY, scaleX * extraScale, scaleY * extraScale);
22356
- return this.localArea.getTransformed(scaledMatrix);
22353
+ const scaledMatrix = new Matrix(translateX, translateY, scaleX, scaleY);
22354
+ return this.container.getTransformed(scaledMatrix);
22357
22355
  }
22358
22356
  emitWithoutApplying = (op) => {
22359
22357
  if (this.board.events) {
@@ -22695,7 +22693,7 @@ class RichText extends BaseItem {
22695
22693
  if (typeof document !== "undefined") {
22696
22694
  document.fonts.ready.then(() => {
22697
22695
  this.layoutNodes = getBlockNodes(this.getBlockNodes(), this.shrinkWidth ? Infinity : this.getMaxWidth() || 0, this.shrinkWidth, this.insideOf === "Frame");
22698
- this.alignInRectangle(this.localArea, this.editor.verticalAlignment);
22696
+ this.alignInRectangle(this.getTransformedContainer(), this.editor.verticalAlignment);
22699
22697
  this.transformCanvas();
22700
22698
  });
22701
22699
  }
@@ -22725,7 +22723,7 @@ class RichText extends BaseItem {
22725
22723
  const scaledMatrix = new Matrix(translateX, translateY, scaleX * extraScale, scaleY * extraScale);
22726
22724
  context.matrix = scaledMatrix;
22727
22725
  context.applyChanges();
22728
- ctx.translate(this.left, this.top);
22726
+ ctx.translate(this.container.left, this.container.top);
22729
22727
  const shouldClip = this.insideOf === "Shape" || this.insideOf === "Sticker";
22730
22728
  if (shouldClip) {
22731
22729
  ctx.clip(this.clipPath.nativePath);
@@ -22866,7 +22864,7 @@ class RichText extends BaseItem {
22866
22864
  }
22867
22865
  const { translateX, translateY, scaleX, scaleY } = matrix;
22868
22866
  const scaledMatrix = new Matrix(translateX, translateY, scaleX * extraScale, scaleY * extraScale);
22869
- const transform = `translate(${scaledMatrix.translateX + this.left * scaledMatrix.scaleX}px, ${scaledMatrix.translateY + this.top * scaledMatrix.scaleY}px) scale(${scaledMatrix.scaleX}, ${scaledMatrix.scaleY})`;
22867
+ const transform = `translate(${scaledMatrix.translateX + this.container.left * scaledMatrix.scaleX}px, ${scaledMatrix.translateY + this.container.top * scaledMatrix.scaleY}px) scale(${scaledMatrix.scaleX}, ${scaledMatrix.scaleY})`;
22870
22868
  const transformedWidth = this.getMbr().getWidth();
22871
22869
  const transformedHeight = this.getMbr().getHeight();
22872
22870
  const div = documentFactory.createElement("rich-text");
@@ -22962,19 +22960,6 @@ class RichText extends BaseItem {
22962
22960
  getPrevMbr() {
22963
22961
  return this.prevMbr;
22964
22962
  }
22965
- getMbr() {
22966
- const cameraScale = this.board.camera.getScale();
22967
- const extraScale = this.renderingScale ? this.renderingScale(cameraScale) : 1;
22968
- let matrix;
22969
- if (this.customTransformationMatrix) {
22970
- matrix = this.customTransformationMatrix();
22971
- } else {
22972
- matrix = this.transformation.toMatrix();
22973
- }
22974
- const { translateX, translateY, scaleX, scaleY } = matrix;
22975
- const scaledMatrix = new Matrix(translateX, translateY, scaleX * extraScale, scaleY * extraScale);
22976
- return new Mbr(this.left, this.top, this.right, this.bottom).getTransformed(scaledMatrix);
22977
- }
22978
22963
  }
22979
22964
 
22980
22965
  // src/Items/Mbr/updateRects.ts
@@ -40874,8 +40859,8 @@ class DefaultFrameData {
40874
40859
 
40875
40860
  // src/Items/Frame/Frame.ts
40876
40861
  var defaultFrameData = new DefaultFrameData;
40877
- var HEADING_TOP_OFFSET = -45;
40878
- var HEADING_BOTTOM_OFFSET = -12;
40862
+ var HEADING_TOP_OFFSET = -33;
40863
+ var HEADING_BOTTOM_OFFSET = -5;
40879
40864
 
40880
40865
  class Frame2 extends BaseItem {
40881
40866
  getItemById;
@@ -40891,7 +40876,7 @@ class Frame2 extends BaseItem {
40891
40876
  parent = "Board";
40892
40877
  transformation;
40893
40878
  subject = new Subject;
40894
- textContainer;
40879
+ textContainer = new Mbr;
40895
40880
  path;
40896
40881
  children = [];
40897
40882
  mbr = new Mbr;
@@ -40912,12 +40897,13 @@ class Frame2 extends BaseItem {
40912
40897
  this.borderOpacity = borderOpacity;
40913
40898
  this.borderStyle = borderStyle;
40914
40899
  this.borderWidth = borderWidth;
40915
- this.textContainer = Frames[this.shapeType].textBounds.copy();
40916
- this.textContainer.top = HEADING_TOP_OFFSET;
40917
- this.textContainer.bottom = HEADING_BOTTOM_OFFSET;
40918
40900
  this.path = Frames[this.shapeType].path.copy();
40919
40901
  this.transformation = new Transformation(this.id, board.events);
40920
40902
  this.linkTo = new LinkTo(this.id, board.events);
40903
+ const textBounds = Frames[this.shapeType].textBounds.copy();
40904
+ textBounds.top = HEADING_TOP_OFFSET;
40905
+ textBounds.bottom = HEADING_BOTTOM_OFFSET;
40906
+ this.textContainer = textBounds;
40921
40907
  this.text = new RichText(board, this.textContainer, this.id, this.transformation, this.linkTo, this.name, true, false, "Frame", { ...conf.DEFAULT_TEXT_STYLES, fontSize: 18, fontColor: FRAME_TITLE_COLOR });
40922
40908
  this.text.editor.verticalAlignment = "bottom";
40923
40909
  this.text.setSelectionHorisontalAlignment("left");
@@ -40952,11 +40938,17 @@ class Frame2 extends BaseItem {
40952
40938
  }
40953
40939
  initPath() {
40954
40940
  this.path = Frames[this.shapeType].path.copy();
40955
- this.textContainer = Frames[this.shapeType].textBounds.copy();
40956
- this.textContainer.top = HEADING_TOP_OFFSET;
40957
- this.textContainer.bottom = HEADING_BOTTOM_OFFSET;
40958
- this.text.setContainer(this.textContainer.copy());
40959
- this.text.updateElement();
40941
+ this.updateTextContainer();
40942
+ }
40943
+ updateTextContainer() {
40944
+ const textBounds = Frames[this.shapeType].textBounds.copy();
40945
+ textBounds.top = HEADING_TOP_OFFSET;
40946
+ textBounds.bottom = HEADING_BOTTOM_OFFSET;
40947
+ this.textContainer = textBounds;
40948
+ if (this.text) {
40949
+ this.text.setContainer(this.textContainer.copy());
40950
+ this.text.updateElement();
40951
+ }
40960
40952
  }
40961
40953
  getPaths() {
40962
40954
  return this.path;
@@ -41099,9 +41091,7 @@ class Frame2 extends BaseItem {
41099
41091
  }
41100
41092
  if (data.text) {
41101
41093
  this.text.deserialize(data.text);
41102
- this.textContainer.top = HEADING_TOP_OFFSET;
41103
- this.textContainer.bottom = HEADING_BOTTOM_OFFSET;
41104
- this.text.setContainer(this.textContainer.copy());
41094
+ this.updateTextContainer();
41105
41095
  }
41106
41096
  this.canChangeRatio = data.canChangeRatio ?? this.canChangeRatio;
41107
41097
  this.subject.publish(this);
@@ -41117,15 +41107,13 @@ class Frame2 extends BaseItem {
41117
41107
  }
41118
41108
  transformPath(saveProportions = false) {
41119
41109
  this.path = Frames[this.shapeType].path.copy();
41120
- this.textContainer = Frames[this.shapeType].textBounds.copy();
41110
+ this.updateTextContainer();
41121
41111
  if (saveProportions) {
41122
41112
  const newMatrix = this.getSavedProportionsMatrix();
41123
41113
  this.path.transform(newMatrix);
41124
- this.textContainer.transform(newMatrix);
41125
41114
  this.transformation.applyScaleTo(newMatrix.scaleX, newMatrix.scaleY);
41126
41115
  } else {
41127
41116
  this.path.transform(this.transformation.toMatrix());
41128
- this.textContainer.transform(this.transformation.toMatrix());
41129
41117
  }
41130
41118
  this.path.setBackgroundOpacity(this.backgroundOpacity);
41131
41119
  this.path.setBorderWidth(this.borderWidth);
package/dist/esm/index.js CHANGED
@@ -22030,7 +22030,6 @@ class RichText extends BaseItem {
22030
22030
  autoSizeScale = 1;
22031
22031
  containerMaxWidth;
22032
22032
  linkTo;
22033
- localArea;
22034
22033
  maxHeight;
22035
22034
  selection;
22036
22035
  transformationRenderBlock = undefined;
@@ -22052,7 +22051,6 @@ class RichText extends BaseItem {
22052
22051
  this.autoSize = autoSize;
22053
22052
  this.insideOf = insideOf;
22054
22053
  this.initialTextStyles = initialTextStyles;
22055
- this.localArea = container.copy();
22056
22054
  counter = counter + 1;
22057
22055
  this.rtCounter = counter;
22058
22056
  this.linkTo = linkTo || new LinkTo(this.id, this.board.events);
@@ -22205,7 +22203,7 @@ class RichText extends BaseItem {
22205
22203
  this.layoutNodes.width = this.containerMaxWidth;
22206
22204
  }
22207
22205
  }
22208
- this.alignInRectangle(this.localArea, this.editor.verticalAlignment);
22206
+ this.alignInRectangle(this.getTransformedContainer(), this.editor.verticalAlignment);
22209
22207
  this.transformCanvas();
22210
22208
  this.subject.publish(this);
22211
22209
  this.updateRequired = false;
@@ -22285,7 +22283,7 @@ class RichText extends BaseItem {
22285
22283
  this.right = transformed.right;
22286
22284
  this.bottom = transformed.bottom;
22287
22285
  } else {
22288
- this.alignInRectangle(this.localArea, this.editor.verticalAlignment);
22286
+ this.alignInRectangle(this.getTransformedContainer(), this.editor.verticalAlignment);
22289
22287
  }
22290
22288
  this.setClipPath();
22291
22289
  if (!this.isInShape && !this.autoSize) {
@@ -22313,16 +22311,16 @@ class RichText extends BaseItem {
22313
22311
  }
22314
22312
  }
22315
22313
  setClipPath() {
22316
- const width = this.localArea.getWidth();
22317
- const height = this.localArea.getHeight();
22314
+ const container = this.getTransformedContainer();
22315
+ const width = container.getWidth();
22316
+ const height = container.getHeight();
22318
22317
  this.clipPath = new conf.path2DFactory;
22319
22318
  this.clipPath.rect(0, 0, width, height);
22320
22319
  }
22321
22320
  setContainer(container) {
22322
22321
  this.isContainerSet = true;
22323
- this.localArea = container.copy();
22324
22322
  this.container = container;
22325
- this.updateElement();
22323
+ this.alignInRectangle(this.getTransformedContainer(), this.editor.verticalAlignment);
22326
22324
  }
22327
22325
  applyMaxWidth(maxWidth) {
22328
22326
  const shouldNotShrink = this.insideOf !== "RichText" && this.insideOf !== "AINode" && this.containerMaxWidth && this.shrinkWidth;
@@ -22345,8 +22343,8 @@ class RichText extends BaseItem {
22345
22343
  matrix = this.transformation.toMatrix();
22346
22344
  }
22347
22345
  const { translateX, translateY, scaleX, scaleY } = matrix;
22348
- const scaledMatrix = new Matrix(translateX, translateY, scaleX * extraScale, scaleY * extraScale);
22349
- return this.localArea.getTransformed(scaledMatrix);
22346
+ const scaledMatrix = new Matrix(translateX, translateY, scaleX, scaleY);
22347
+ return this.container.getTransformed(scaledMatrix);
22350
22348
  }
22351
22349
  emitWithoutApplying = (op) => {
22352
22350
  if (this.board.events) {
@@ -22688,7 +22686,7 @@ class RichText extends BaseItem {
22688
22686
  if (typeof document !== "undefined") {
22689
22687
  document.fonts.ready.then(() => {
22690
22688
  this.layoutNodes = getBlockNodes(this.getBlockNodes(), this.shrinkWidth ? Infinity : this.getMaxWidth() || 0, this.shrinkWidth, this.insideOf === "Frame");
22691
- this.alignInRectangle(this.localArea, this.editor.verticalAlignment);
22689
+ this.alignInRectangle(this.getTransformedContainer(), this.editor.verticalAlignment);
22692
22690
  this.transformCanvas();
22693
22691
  });
22694
22692
  }
@@ -22718,7 +22716,7 @@ class RichText extends BaseItem {
22718
22716
  const scaledMatrix = new Matrix(translateX, translateY, scaleX * extraScale, scaleY * extraScale);
22719
22717
  context.matrix = scaledMatrix;
22720
22718
  context.applyChanges();
22721
- ctx.translate(this.left, this.top);
22719
+ ctx.translate(this.container.left, this.container.top);
22722
22720
  const shouldClip = this.insideOf === "Shape" || this.insideOf === "Sticker";
22723
22721
  if (shouldClip) {
22724
22722
  ctx.clip(this.clipPath.nativePath);
@@ -22859,7 +22857,7 @@ class RichText extends BaseItem {
22859
22857
  }
22860
22858
  const { translateX, translateY, scaleX, scaleY } = matrix;
22861
22859
  const scaledMatrix = new Matrix(translateX, translateY, scaleX * extraScale, scaleY * extraScale);
22862
- const transform = `translate(${scaledMatrix.translateX + this.left * scaledMatrix.scaleX}px, ${scaledMatrix.translateY + this.top * scaledMatrix.scaleY}px) scale(${scaledMatrix.scaleX}, ${scaledMatrix.scaleY})`;
22860
+ const transform = `translate(${scaledMatrix.translateX + this.container.left * scaledMatrix.scaleX}px, ${scaledMatrix.translateY + this.container.top * scaledMatrix.scaleY}px) scale(${scaledMatrix.scaleX}, ${scaledMatrix.scaleY})`;
22863
22861
  const transformedWidth = this.getMbr().getWidth();
22864
22862
  const transformedHeight = this.getMbr().getHeight();
22865
22863
  const div = documentFactory.createElement("rich-text");
@@ -22955,19 +22953,6 @@ class RichText extends BaseItem {
22955
22953
  getPrevMbr() {
22956
22954
  return this.prevMbr;
22957
22955
  }
22958
- getMbr() {
22959
- const cameraScale = this.board.camera.getScale();
22960
- const extraScale = this.renderingScale ? this.renderingScale(cameraScale) : 1;
22961
- let matrix;
22962
- if (this.customTransformationMatrix) {
22963
- matrix = this.customTransformationMatrix();
22964
- } else {
22965
- matrix = this.transformation.toMatrix();
22966
- }
22967
- const { translateX, translateY, scaleX, scaleY } = matrix;
22968
- const scaledMatrix = new Matrix(translateX, translateY, scaleX * extraScale, scaleY * extraScale);
22969
- return new Mbr(this.left, this.top, this.right, this.bottom).getTransformed(scaledMatrix);
22970
- }
22971
22956
  }
22972
22957
 
22973
22958
  // src/Items/Mbr/updateRects.ts
@@ -40867,8 +40852,8 @@ class DefaultFrameData {
40867
40852
 
40868
40853
  // src/Items/Frame/Frame.ts
40869
40854
  var defaultFrameData = new DefaultFrameData;
40870
- var HEADING_TOP_OFFSET = -45;
40871
- var HEADING_BOTTOM_OFFSET = -12;
40855
+ var HEADING_TOP_OFFSET = -33;
40856
+ var HEADING_BOTTOM_OFFSET = -5;
40872
40857
 
40873
40858
  class Frame2 extends BaseItem {
40874
40859
  getItemById;
@@ -40884,7 +40869,7 @@ class Frame2 extends BaseItem {
40884
40869
  parent = "Board";
40885
40870
  transformation;
40886
40871
  subject = new Subject;
40887
- textContainer;
40872
+ textContainer = new Mbr;
40888
40873
  path;
40889
40874
  children = [];
40890
40875
  mbr = new Mbr;
@@ -40905,12 +40890,13 @@ class Frame2 extends BaseItem {
40905
40890
  this.borderOpacity = borderOpacity;
40906
40891
  this.borderStyle = borderStyle;
40907
40892
  this.borderWidth = borderWidth;
40908
- this.textContainer = Frames[this.shapeType].textBounds.copy();
40909
- this.textContainer.top = HEADING_TOP_OFFSET;
40910
- this.textContainer.bottom = HEADING_BOTTOM_OFFSET;
40911
40893
  this.path = Frames[this.shapeType].path.copy();
40912
40894
  this.transformation = new Transformation(this.id, board.events);
40913
40895
  this.linkTo = new LinkTo(this.id, board.events);
40896
+ const textBounds = Frames[this.shapeType].textBounds.copy();
40897
+ textBounds.top = HEADING_TOP_OFFSET;
40898
+ textBounds.bottom = HEADING_BOTTOM_OFFSET;
40899
+ this.textContainer = textBounds;
40914
40900
  this.text = new RichText(board, this.textContainer, this.id, this.transformation, this.linkTo, this.name, true, false, "Frame", { ...conf.DEFAULT_TEXT_STYLES, fontSize: 18, fontColor: FRAME_TITLE_COLOR });
40915
40901
  this.text.editor.verticalAlignment = "bottom";
40916
40902
  this.text.setSelectionHorisontalAlignment("left");
@@ -40945,11 +40931,17 @@ class Frame2 extends BaseItem {
40945
40931
  }
40946
40932
  initPath() {
40947
40933
  this.path = Frames[this.shapeType].path.copy();
40948
- this.textContainer = Frames[this.shapeType].textBounds.copy();
40949
- this.textContainer.top = HEADING_TOP_OFFSET;
40950
- this.textContainer.bottom = HEADING_BOTTOM_OFFSET;
40951
- this.text.setContainer(this.textContainer.copy());
40952
- this.text.updateElement();
40934
+ this.updateTextContainer();
40935
+ }
40936
+ updateTextContainer() {
40937
+ const textBounds = Frames[this.shapeType].textBounds.copy();
40938
+ textBounds.top = HEADING_TOP_OFFSET;
40939
+ textBounds.bottom = HEADING_BOTTOM_OFFSET;
40940
+ this.textContainer = textBounds;
40941
+ if (this.text) {
40942
+ this.text.setContainer(this.textContainer.copy());
40943
+ this.text.updateElement();
40944
+ }
40953
40945
  }
40954
40946
  getPaths() {
40955
40947
  return this.path;
@@ -41092,9 +41084,7 @@ class Frame2 extends BaseItem {
41092
41084
  }
41093
41085
  if (data.text) {
41094
41086
  this.text.deserialize(data.text);
41095
- this.textContainer.top = HEADING_TOP_OFFSET;
41096
- this.textContainer.bottom = HEADING_BOTTOM_OFFSET;
41097
- this.text.setContainer(this.textContainer.copy());
41087
+ this.updateTextContainer();
41098
41088
  }
41099
41089
  this.canChangeRatio = data.canChangeRatio ?? this.canChangeRatio;
41100
41090
  this.subject.publish(this);
@@ -41110,15 +41100,13 @@ class Frame2 extends BaseItem {
41110
41100
  }
41111
41101
  transformPath(saveProportions = false) {
41112
41102
  this.path = Frames[this.shapeType].path.copy();
41113
- this.textContainer = Frames[this.shapeType].textBounds.copy();
41103
+ this.updateTextContainer();
41114
41104
  if (saveProportions) {
41115
41105
  const newMatrix = this.getSavedProportionsMatrix();
41116
41106
  this.path.transform(newMatrix);
41117
- this.textContainer.transform(newMatrix);
41118
41107
  this.transformation.applyScaleTo(newMatrix.scaleX, newMatrix.scaleY);
41119
41108
  } else {
41120
41109
  this.path.transform(this.transformation.toMatrix());
41121
- this.textContainer.transform(this.transformation.toMatrix());
41122
41110
  }
41123
41111
  this.path.setBackgroundOpacity(this.backgroundOpacity);
41124
41112
  this.path.setBorderWidth(this.borderWidth);
package/dist/esm/node.js CHANGED
@@ -24497,7 +24497,6 @@ class RichText extends BaseItem {
24497
24497
  autoSizeScale = 1;
24498
24498
  containerMaxWidth;
24499
24499
  linkTo;
24500
- localArea;
24501
24500
  maxHeight;
24502
24501
  selection;
24503
24502
  transformationRenderBlock = undefined;
@@ -24519,7 +24518,6 @@ class RichText extends BaseItem {
24519
24518
  this.autoSize = autoSize;
24520
24519
  this.insideOf = insideOf;
24521
24520
  this.initialTextStyles = initialTextStyles;
24522
- this.localArea = container.copy();
24523
24521
  counter = counter + 1;
24524
24522
  this.rtCounter = counter;
24525
24523
  this.linkTo = linkTo || new LinkTo(this.id, this.board.events);
@@ -24672,7 +24670,7 @@ class RichText extends BaseItem {
24672
24670
  this.layoutNodes.width = this.containerMaxWidth;
24673
24671
  }
24674
24672
  }
24675
- this.alignInRectangle(this.localArea, this.editor.verticalAlignment);
24673
+ this.alignInRectangle(this.getTransformedContainer(), this.editor.verticalAlignment);
24676
24674
  this.transformCanvas();
24677
24675
  this.subject.publish(this);
24678
24676
  this.updateRequired = false;
@@ -24752,7 +24750,7 @@ class RichText extends BaseItem {
24752
24750
  this.right = transformed.right;
24753
24751
  this.bottom = transformed.bottom;
24754
24752
  } else {
24755
- this.alignInRectangle(this.localArea, this.editor.verticalAlignment);
24753
+ this.alignInRectangle(this.getTransformedContainer(), this.editor.verticalAlignment);
24756
24754
  }
24757
24755
  this.setClipPath();
24758
24756
  if (!this.isInShape && !this.autoSize) {
@@ -24780,16 +24778,16 @@ class RichText extends BaseItem {
24780
24778
  }
24781
24779
  }
24782
24780
  setClipPath() {
24783
- const width = this.localArea.getWidth();
24784
- const height = this.localArea.getHeight();
24781
+ const container = this.getTransformedContainer();
24782
+ const width = container.getWidth();
24783
+ const height = container.getHeight();
24785
24784
  this.clipPath = new conf.path2DFactory;
24786
24785
  this.clipPath.rect(0, 0, width, height);
24787
24786
  }
24788
24787
  setContainer(container) {
24789
24788
  this.isContainerSet = true;
24790
- this.localArea = container.copy();
24791
24789
  this.container = container;
24792
- this.updateElement();
24790
+ this.alignInRectangle(this.getTransformedContainer(), this.editor.verticalAlignment);
24793
24791
  }
24794
24792
  applyMaxWidth(maxWidth) {
24795
24793
  const shouldNotShrink = this.insideOf !== "RichText" && this.insideOf !== "AINode" && this.containerMaxWidth && this.shrinkWidth;
@@ -24812,8 +24810,8 @@ class RichText extends BaseItem {
24812
24810
  matrix = this.transformation.toMatrix();
24813
24811
  }
24814
24812
  const { translateX, translateY, scaleX, scaleY } = matrix;
24815
- const scaledMatrix = new Matrix(translateX, translateY, scaleX * extraScale, scaleY * extraScale);
24816
- return this.localArea.getTransformed(scaledMatrix);
24813
+ const scaledMatrix = new Matrix(translateX, translateY, scaleX, scaleY);
24814
+ return this.container.getTransformed(scaledMatrix);
24817
24815
  }
24818
24816
  emitWithoutApplying = (op) => {
24819
24817
  if (this.board.events) {
@@ -25155,7 +25153,7 @@ class RichText extends BaseItem {
25155
25153
  if (typeof document !== "undefined") {
25156
25154
  document.fonts.ready.then(() => {
25157
25155
  this.layoutNodes = getBlockNodes(this.getBlockNodes(), this.shrinkWidth ? Infinity : this.getMaxWidth() || 0, this.shrinkWidth, this.insideOf === "Frame");
25158
- this.alignInRectangle(this.localArea, this.editor.verticalAlignment);
25156
+ this.alignInRectangle(this.getTransformedContainer(), this.editor.verticalAlignment);
25159
25157
  this.transformCanvas();
25160
25158
  });
25161
25159
  }
@@ -25185,7 +25183,7 @@ class RichText extends BaseItem {
25185
25183
  const scaledMatrix = new Matrix(translateX, translateY, scaleX * extraScale, scaleY * extraScale);
25186
25184
  context.matrix = scaledMatrix;
25187
25185
  context.applyChanges();
25188
- ctx.translate(this.left, this.top);
25186
+ ctx.translate(this.container.left, this.container.top);
25189
25187
  const shouldClip = this.insideOf === "Shape" || this.insideOf === "Sticker";
25190
25188
  if (shouldClip) {
25191
25189
  ctx.clip(this.clipPath.nativePath);
@@ -25326,7 +25324,7 @@ class RichText extends BaseItem {
25326
25324
  }
25327
25325
  const { translateX, translateY, scaleX, scaleY } = matrix;
25328
25326
  const scaledMatrix = new Matrix(translateX, translateY, scaleX * extraScale, scaleY * extraScale);
25329
- const transform = `translate(${scaledMatrix.translateX + this.left * scaledMatrix.scaleX}px, ${scaledMatrix.translateY + this.top * scaledMatrix.scaleY}px) scale(${scaledMatrix.scaleX}, ${scaledMatrix.scaleY})`;
25327
+ const transform = `translate(${scaledMatrix.translateX + this.container.left * scaledMatrix.scaleX}px, ${scaledMatrix.translateY + this.container.top * scaledMatrix.scaleY}px) scale(${scaledMatrix.scaleX}, ${scaledMatrix.scaleY})`;
25330
25328
  const transformedWidth = this.getMbr().getWidth();
25331
25329
  const transformedHeight = this.getMbr().getHeight();
25332
25330
  const div = documentFactory.createElement("rich-text");
@@ -25422,19 +25420,6 @@ class RichText extends BaseItem {
25422
25420
  getPrevMbr() {
25423
25421
  return this.prevMbr;
25424
25422
  }
25425
- getMbr() {
25426
- const cameraScale = this.board.camera.getScale();
25427
- const extraScale = this.renderingScale ? this.renderingScale(cameraScale) : 1;
25428
- let matrix;
25429
- if (this.customTransformationMatrix) {
25430
- matrix = this.customTransformationMatrix();
25431
- } else {
25432
- matrix = this.transformation.toMatrix();
25433
- }
25434
- const { translateX, translateY, scaleX, scaleY } = matrix;
25435
- const scaledMatrix = new Matrix(translateX, translateY, scaleX * extraScale, scaleY * extraScale);
25436
- return new Mbr(this.left, this.top, this.right, this.bottom).getTransformed(scaledMatrix);
25437
- }
25438
25423
  }
25439
25424
 
25440
25425
  // src/Items/Mbr/updateRects.ts
@@ -43335,8 +43320,8 @@ class DefaultFrameData {
43335
43320
 
43336
43321
  // src/Items/Frame/Frame.ts
43337
43322
  var defaultFrameData = new DefaultFrameData;
43338
- var HEADING_TOP_OFFSET = -45;
43339
- var HEADING_BOTTOM_OFFSET = -12;
43323
+ var HEADING_TOP_OFFSET = -33;
43324
+ var HEADING_BOTTOM_OFFSET = -5;
43340
43325
 
43341
43326
  class Frame2 extends BaseItem {
43342
43327
  getItemById;
@@ -43352,7 +43337,7 @@ class Frame2 extends BaseItem {
43352
43337
  parent = "Board";
43353
43338
  transformation;
43354
43339
  subject = new Subject;
43355
- textContainer;
43340
+ textContainer = new Mbr;
43356
43341
  path;
43357
43342
  children = [];
43358
43343
  mbr = new Mbr;
@@ -43373,12 +43358,13 @@ class Frame2 extends BaseItem {
43373
43358
  this.borderOpacity = borderOpacity;
43374
43359
  this.borderStyle = borderStyle;
43375
43360
  this.borderWidth = borderWidth;
43376
- this.textContainer = Frames[this.shapeType].textBounds.copy();
43377
- this.textContainer.top = HEADING_TOP_OFFSET;
43378
- this.textContainer.bottom = HEADING_BOTTOM_OFFSET;
43379
43361
  this.path = Frames[this.shapeType].path.copy();
43380
43362
  this.transformation = new Transformation(this.id, board.events);
43381
43363
  this.linkTo = new LinkTo(this.id, board.events);
43364
+ const textBounds = Frames[this.shapeType].textBounds.copy();
43365
+ textBounds.top = HEADING_TOP_OFFSET;
43366
+ textBounds.bottom = HEADING_BOTTOM_OFFSET;
43367
+ this.textContainer = textBounds;
43382
43368
  this.text = new RichText(board, this.textContainer, this.id, this.transformation, this.linkTo, this.name, true, false, "Frame", { ...conf.DEFAULT_TEXT_STYLES, fontSize: 18, fontColor: FRAME_TITLE_COLOR });
43383
43369
  this.text.editor.verticalAlignment = "bottom";
43384
43370
  this.text.setSelectionHorisontalAlignment("left");
@@ -43413,11 +43399,17 @@ class Frame2 extends BaseItem {
43413
43399
  }
43414
43400
  initPath() {
43415
43401
  this.path = Frames[this.shapeType].path.copy();
43416
- this.textContainer = Frames[this.shapeType].textBounds.copy();
43417
- this.textContainer.top = HEADING_TOP_OFFSET;
43418
- this.textContainer.bottom = HEADING_BOTTOM_OFFSET;
43419
- this.text.setContainer(this.textContainer.copy());
43420
- this.text.updateElement();
43402
+ this.updateTextContainer();
43403
+ }
43404
+ updateTextContainer() {
43405
+ const textBounds = Frames[this.shapeType].textBounds.copy();
43406
+ textBounds.top = HEADING_TOP_OFFSET;
43407
+ textBounds.bottom = HEADING_BOTTOM_OFFSET;
43408
+ this.textContainer = textBounds;
43409
+ if (this.text) {
43410
+ this.text.setContainer(this.textContainer.copy());
43411
+ this.text.updateElement();
43412
+ }
43421
43413
  }
43422
43414
  getPaths() {
43423
43415
  return this.path;
@@ -43560,9 +43552,7 @@ class Frame2 extends BaseItem {
43560
43552
  }
43561
43553
  if (data.text) {
43562
43554
  this.text.deserialize(data.text);
43563
- this.textContainer.top = HEADING_TOP_OFFSET;
43564
- this.textContainer.bottom = HEADING_BOTTOM_OFFSET;
43565
- this.text.setContainer(this.textContainer.copy());
43555
+ this.updateTextContainer();
43566
43556
  }
43567
43557
  this.canChangeRatio = data.canChangeRatio ?? this.canChangeRatio;
43568
43558
  this.subject.publish(this);
@@ -43578,15 +43568,13 @@ class Frame2 extends BaseItem {
43578
43568
  }
43579
43569
  transformPath(saveProportions = false) {
43580
43570
  this.path = Frames[this.shapeType].path.copy();
43581
- this.textContainer = Frames[this.shapeType].textBounds.copy();
43571
+ this.updateTextContainer();
43582
43572
  if (saveProportions) {
43583
43573
  const newMatrix = this.getSavedProportionsMatrix();
43584
43574
  this.path.transform(newMatrix);
43585
- this.textContainer.transform(newMatrix);
43586
43575
  this.transformation.applyScaleTo(newMatrix.scaleX, newMatrix.scaleY);
43587
43576
  } else {
43588
43577
  this.path.transform(this.transformation.toMatrix());
43589
- this.textContainer.transform(this.transformation.toMatrix());
43590
43578
  }
43591
43579
  this.path.setBackgroundOpacity(this.backgroundOpacity);
43592
43580
  this.path.setBorderWidth(this.borderWidth);
@@ -52,6 +52,7 @@ export declare class Frame extends BaseItem {
52
52
  * false - if outside of the frame
53
53
  */
54
54
  private initPath;
55
+ private updateTextContainer;
55
56
  getPaths(): Path | Paths;
56
57
  getPath(): Path | Paths;
57
58
  copyPaths(): Path | Paths;
@@ -44,7 +44,6 @@ export declare class RichText extends BaseItem {
44
44
  private autoSizeScale;
45
45
  private containerMaxWidth?;
46
46
  readonly linkTo: LinkTo;
47
- private localArea;
48
47
  maxHeight: number;
49
48
  private selection?;
50
49
  transformationRenderBlock?: boolean;
@@ -154,5 +153,4 @@ export declare class RichText extends BaseItem {
154
153
  getRichText(): RichText;
155
154
  getLinkTo(): string | undefined;
156
155
  getPrevMbr(): Mbr | null;
157
- getMbr(): Mbr;
158
156
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "microboard-temp",
3
- "version": "0.13.7",
3
+ "version": "0.13.9",
4
4
  "description": "A flexible interactive whiteboard library",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",