microboard-temp 0.13.0 → 0.13.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.
@@ -22506,10 +22506,17 @@ class RichText extends BaseItem {
22506
22506
  return this.shrinkWidth;
22507
22507
  }
22508
22508
  getTransformedContainer() {
22509
+ const cameraScale = this.board.camera.getScale();
22510
+ const extraScale = this.renderingScale ? this.renderingScale(cameraScale) : 1;
22511
+ let matrix;
22509
22512
  if (this.customTransformationMatrix) {
22510
- return this.container.getTransformed(this.customTransformationMatrix());
22513
+ matrix = this.customTransformationMatrix();
22514
+ } else {
22515
+ matrix = this.transformation.toMatrix();
22511
22516
  }
22512
- return this.container.getTransformed(this.transformation.toMatrix());
22517
+ const { translateX, translateY, scaleX, scaleY } = matrix;
22518
+ const scaledMatrix = new Matrix(translateX, translateY, scaleX * extraScale, scaleY * extraScale);
22519
+ return this.container.getTransformed(scaledMatrix);
22513
22520
  }
22514
22521
  emitWithoutApplying = (op) => {
22515
22522
  if (this.board.events) {
@@ -22850,7 +22857,9 @@ class RichText extends BaseItem {
22850
22857
  this.insideOf = data.insideOf;
22851
22858
  if (typeof document !== "undefined") {
22852
22859
  document.fonts.ready.then(() => {
22853
- this.updateElement();
22860
+ this.layoutNodes = getBlockNodes(this.getBlockNodes(), this.shrinkWidth ? Infinity : this.getMaxWidth() || 0, this.shrinkWidth, this.insideOf === "Frame");
22861
+ this.alignInRectangle(this.getTransformedContainer(), this.editor.verticalAlignment);
22862
+ this.transformCanvas();
22854
22863
  });
22855
22864
  }
22856
22865
  this.subject.publish(this);
@@ -22867,20 +22876,17 @@ class RichText extends BaseItem {
22867
22876
  }
22868
22877
  const { ctx } = context;
22869
22878
  ctx.save();
22879
+ const cameraScale = context.getCameraScale();
22880
+ const extraScale = this.renderingScale ? this.renderingScale(cameraScale) : 1;
22870
22881
  ctx.translate(this.left, this.top);
22871
- const shouldScale = !this.isInShape && !this.autoSize;
22872
- if (shouldScale) {
22873
- const { scaleX, scaleY } = this.transformation.getMatrixData();
22874
- ctx.scale(scaleX, scaleY);
22875
- }
22882
+ const { scaleX, scaleY } = this.transformation.getMatrixData();
22883
+ ctx.scale(scaleX * extraScale, scaleY * extraScale);
22876
22884
  const shouldClip = this.insideOf === "Shape" || this.insideOf === "Sticker";
22877
22885
  if (shouldClip) {
22878
22886
  ctx.clip(this.clipPath.nativePath);
22879
22887
  }
22880
22888
  const autoSizeScale = this.autoSize ? this.autoSizeScale : undefined;
22881
- const cameraScale = context.getCameraScale();
22882
- const extraScale = this.renderingScale ? this.renderingScale(cameraScale) : 1;
22883
- this.layoutNodes.render(ctx, autoSizeScale ? autoSizeScale * extraScale : extraScale);
22889
+ this.layoutNodes.render(ctx, autoSizeScale);
22884
22890
  ctx.restore();
22885
22891
  if (this.getLinkTo() && (this.insideOf === "RichText" || !this.insideOf)) {
22886
22892
  const { top, right } = this.getMbr();
@@ -23005,12 +23011,12 @@ class RichText extends BaseItem {
23005
23011
  return unsafe.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
23006
23012
  };
23007
23013
  const elements = this.editor.editor.children.map(renderNode);
23008
- const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
23009
23014
  const cameraScale = this.board.camera.getScale();
23010
23015
  const extraScale = this.renderingScale ? this.renderingScale(cameraScale) : 1;
23011
- const transform = `translate(${translateX}px, ${translateY}px) scale(${scaleX * extraScale}, ${scaleY * extraScale})`;
23012
- const transformedWidth = this.getTransformedContainer().getWidth();
23013
- const transformedHeight = this.getTransformedContainer().getHeight();
23016
+ const { scaleX, scaleY } = this.transformation.getMatrixData();
23017
+ const transform = `translate(${this.left}px, ${this.top}px) scale(${scaleX * extraScale}, ${scaleY * extraScale})`;
23018
+ const transformedWidth = this.getMbr().getWidth();
23019
+ const transformedHeight = this.getMbr().getHeight();
23014
23020
  const div = documentFactory.createElement("rich-text");
23015
23021
  div.id = this.getId();
23016
23022
  div.style.width = `${transformedWidth + 5}px`;
@@ -41047,7 +41053,7 @@ class Frame2 extends BaseItem {
41047
41053
  this.text.setSelectionHorisontalAlignment("left");
41048
41054
  this.text.customTransformationMatrix = () => {
41049
41055
  const { translateX, translateY, scaleX } = this.transformation.getMatrixData();
41050
- const scaleY = this.getMbr().getHeight() * 2 / 10;
41056
+ const scaleY = this.text.layoutNodes.height * scaleX / 10;
41051
41057
  return new Matrix(translateX, translateY, scaleX, scaleY);
41052
41058
  };
41053
41059
  this.text.renderingScale = (cameraScale) => {
package/dist/cjs/index.js CHANGED
@@ -22506,10 +22506,17 @@ class RichText extends BaseItem {
22506
22506
  return this.shrinkWidth;
22507
22507
  }
22508
22508
  getTransformedContainer() {
22509
+ const cameraScale = this.board.camera.getScale();
22510
+ const extraScale = this.renderingScale ? this.renderingScale(cameraScale) : 1;
22511
+ let matrix;
22509
22512
  if (this.customTransformationMatrix) {
22510
- return this.container.getTransformed(this.customTransformationMatrix());
22513
+ matrix = this.customTransformationMatrix();
22514
+ } else {
22515
+ matrix = this.transformation.toMatrix();
22511
22516
  }
22512
- return this.container.getTransformed(this.transformation.toMatrix());
22517
+ const { translateX, translateY, scaleX, scaleY } = matrix;
22518
+ const scaledMatrix = new Matrix(translateX, translateY, scaleX * extraScale, scaleY * extraScale);
22519
+ return this.container.getTransformed(scaledMatrix);
22513
22520
  }
22514
22521
  emitWithoutApplying = (op) => {
22515
22522
  if (this.board.events) {
@@ -22850,7 +22857,9 @@ class RichText extends BaseItem {
22850
22857
  this.insideOf = data.insideOf;
22851
22858
  if (typeof document !== "undefined") {
22852
22859
  document.fonts.ready.then(() => {
22853
- this.updateElement();
22860
+ this.layoutNodes = getBlockNodes(this.getBlockNodes(), this.shrinkWidth ? Infinity : this.getMaxWidth() || 0, this.shrinkWidth, this.insideOf === "Frame");
22861
+ this.alignInRectangle(this.getTransformedContainer(), this.editor.verticalAlignment);
22862
+ this.transformCanvas();
22854
22863
  });
22855
22864
  }
22856
22865
  this.subject.publish(this);
@@ -22867,20 +22876,17 @@ class RichText extends BaseItem {
22867
22876
  }
22868
22877
  const { ctx } = context;
22869
22878
  ctx.save();
22879
+ const cameraScale = context.getCameraScale();
22880
+ const extraScale = this.renderingScale ? this.renderingScale(cameraScale) : 1;
22870
22881
  ctx.translate(this.left, this.top);
22871
- const shouldScale = !this.isInShape && !this.autoSize;
22872
- if (shouldScale) {
22873
- const { scaleX, scaleY } = this.transformation.getMatrixData();
22874
- ctx.scale(scaleX, scaleY);
22875
- }
22882
+ const { scaleX, scaleY } = this.transformation.getMatrixData();
22883
+ ctx.scale(scaleX * extraScale, scaleY * extraScale);
22876
22884
  const shouldClip = this.insideOf === "Shape" || this.insideOf === "Sticker";
22877
22885
  if (shouldClip) {
22878
22886
  ctx.clip(this.clipPath.nativePath);
22879
22887
  }
22880
22888
  const autoSizeScale = this.autoSize ? this.autoSizeScale : undefined;
22881
- const cameraScale = context.getCameraScale();
22882
- const extraScale = this.renderingScale ? this.renderingScale(cameraScale) : 1;
22883
- this.layoutNodes.render(ctx, autoSizeScale ? autoSizeScale * extraScale : extraScale);
22889
+ this.layoutNodes.render(ctx, autoSizeScale);
22884
22890
  ctx.restore();
22885
22891
  if (this.getLinkTo() && (this.insideOf === "RichText" || !this.insideOf)) {
22886
22892
  const { top, right } = this.getMbr();
@@ -23005,12 +23011,12 @@ class RichText extends BaseItem {
23005
23011
  return unsafe.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
23006
23012
  };
23007
23013
  const elements = this.editor.editor.children.map(renderNode);
23008
- const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
23009
23014
  const cameraScale = this.board.camera.getScale();
23010
23015
  const extraScale = this.renderingScale ? this.renderingScale(cameraScale) : 1;
23011
- const transform = `translate(${translateX}px, ${translateY}px) scale(${scaleX * extraScale}, ${scaleY * extraScale})`;
23012
- const transformedWidth = this.getTransformedContainer().getWidth();
23013
- const transformedHeight = this.getTransformedContainer().getHeight();
23016
+ const { scaleX, scaleY } = this.transformation.getMatrixData();
23017
+ const transform = `translate(${this.left}px, ${this.top}px) scale(${scaleX * extraScale}, ${scaleY * extraScale})`;
23018
+ const transformedWidth = this.getMbr().getWidth();
23019
+ const transformedHeight = this.getMbr().getHeight();
23014
23020
  const div = documentFactory.createElement("rich-text");
23015
23021
  div.id = this.getId();
23016
23022
  div.style.width = `${transformedWidth + 5}px`;
@@ -41047,7 +41053,7 @@ class Frame2 extends BaseItem {
41047
41053
  this.text.setSelectionHorisontalAlignment("left");
41048
41054
  this.text.customTransformationMatrix = () => {
41049
41055
  const { translateX, translateY, scaleX } = this.transformation.getMatrixData();
41050
- const scaleY = this.getMbr().getHeight() * 2 / 10;
41056
+ const scaleY = this.text.layoutNodes.height * scaleX / 10;
41051
41057
  return new Matrix(translateX, translateY, scaleX, scaleY);
41052
41058
  };
41053
41059
  this.text.renderingScale = (cameraScale) => {
package/dist/cjs/node.js CHANGED
@@ -24978,10 +24978,17 @@ class RichText extends BaseItem {
24978
24978
  return this.shrinkWidth;
24979
24979
  }
24980
24980
  getTransformedContainer() {
24981
+ const cameraScale = this.board.camera.getScale();
24982
+ const extraScale = this.renderingScale ? this.renderingScale(cameraScale) : 1;
24983
+ let matrix;
24981
24984
  if (this.customTransformationMatrix) {
24982
- return this.container.getTransformed(this.customTransformationMatrix());
24985
+ matrix = this.customTransformationMatrix();
24986
+ } else {
24987
+ matrix = this.transformation.toMatrix();
24983
24988
  }
24984
- return this.container.getTransformed(this.transformation.toMatrix());
24989
+ const { translateX, translateY, scaleX, scaleY } = matrix;
24990
+ const scaledMatrix = new Matrix(translateX, translateY, scaleX * extraScale, scaleY * extraScale);
24991
+ return this.container.getTransformed(scaledMatrix);
24985
24992
  }
24986
24993
  emitWithoutApplying = (op) => {
24987
24994
  if (this.board.events) {
@@ -25322,7 +25329,9 @@ class RichText extends BaseItem {
25322
25329
  this.insideOf = data.insideOf;
25323
25330
  if (typeof document !== "undefined") {
25324
25331
  document.fonts.ready.then(() => {
25325
- this.updateElement();
25332
+ this.layoutNodes = getBlockNodes(this.getBlockNodes(), this.shrinkWidth ? Infinity : this.getMaxWidth() || 0, this.shrinkWidth, this.insideOf === "Frame");
25333
+ this.alignInRectangle(this.getTransformedContainer(), this.editor.verticalAlignment);
25334
+ this.transformCanvas();
25326
25335
  });
25327
25336
  }
25328
25337
  this.subject.publish(this);
@@ -25339,20 +25348,17 @@ class RichText extends BaseItem {
25339
25348
  }
25340
25349
  const { ctx } = context;
25341
25350
  ctx.save();
25351
+ const cameraScale = context.getCameraScale();
25352
+ const extraScale = this.renderingScale ? this.renderingScale(cameraScale) : 1;
25342
25353
  ctx.translate(this.left, this.top);
25343
- const shouldScale = !this.isInShape && !this.autoSize;
25344
- if (shouldScale) {
25345
- const { scaleX, scaleY } = this.transformation.getMatrixData();
25346
- ctx.scale(scaleX, scaleY);
25347
- }
25354
+ const { scaleX, scaleY } = this.transformation.getMatrixData();
25355
+ ctx.scale(scaleX * extraScale, scaleY * extraScale);
25348
25356
  const shouldClip = this.insideOf === "Shape" || this.insideOf === "Sticker";
25349
25357
  if (shouldClip) {
25350
25358
  ctx.clip(this.clipPath.nativePath);
25351
25359
  }
25352
25360
  const autoSizeScale = this.autoSize ? this.autoSizeScale : undefined;
25353
- const cameraScale = context.getCameraScale();
25354
- const extraScale = this.renderingScale ? this.renderingScale(cameraScale) : 1;
25355
- this.layoutNodes.render(ctx, autoSizeScale ? autoSizeScale * extraScale : extraScale);
25361
+ this.layoutNodes.render(ctx, autoSizeScale);
25356
25362
  ctx.restore();
25357
25363
  if (this.getLinkTo() && (this.insideOf === "RichText" || !this.insideOf)) {
25358
25364
  const { top, right } = this.getMbr();
@@ -25477,12 +25483,12 @@ class RichText extends BaseItem {
25477
25483
  return unsafe.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
25478
25484
  };
25479
25485
  const elements = this.editor.editor.children.map(renderNode);
25480
- const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
25481
25486
  const cameraScale = this.board.camera.getScale();
25482
25487
  const extraScale = this.renderingScale ? this.renderingScale(cameraScale) : 1;
25483
- const transform = `translate(${translateX}px, ${translateY}px) scale(${scaleX * extraScale}, ${scaleY * extraScale})`;
25484
- const transformedWidth = this.getTransformedContainer().getWidth();
25485
- const transformedHeight = this.getTransformedContainer().getHeight();
25488
+ const { scaleX, scaleY } = this.transformation.getMatrixData();
25489
+ const transform = `translate(${this.left}px, ${this.top}px) scale(${scaleX * extraScale}, ${scaleY * extraScale})`;
25490
+ const transformedWidth = this.getMbr().getWidth();
25491
+ const transformedHeight = this.getMbr().getHeight();
25486
25492
  const div = documentFactory.createElement("rich-text");
25487
25493
  div.id = this.getId();
25488
25494
  div.style.width = `${transformedWidth + 5}px`;
@@ -43520,7 +43526,7 @@ class Frame2 extends BaseItem {
43520
43526
  this.text.setSelectionHorisontalAlignment("left");
43521
43527
  this.text.customTransformationMatrix = () => {
43522
43528
  const { translateX, translateY, scaleX } = this.transformation.getMatrixData();
43523
- const scaleY = this.getMbr().getHeight() * 2 / 10;
43529
+ const scaleY = this.text.layoutNodes.height * scaleX / 10;
43524
43530
  return new Matrix(translateX, translateY, scaleX, scaleY);
43525
43531
  };
43526
43532
  this.text.renderingScale = (cameraScale) => {
@@ -22335,10 +22335,17 @@ class RichText extends BaseItem {
22335
22335
  return this.shrinkWidth;
22336
22336
  }
22337
22337
  getTransformedContainer() {
22338
+ const cameraScale = this.board.camera.getScale();
22339
+ const extraScale = this.renderingScale ? this.renderingScale(cameraScale) : 1;
22340
+ let matrix;
22338
22341
  if (this.customTransformationMatrix) {
22339
- return this.container.getTransformed(this.customTransformationMatrix());
22342
+ matrix = this.customTransformationMatrix();
22343
+ } else {
22344
+ matrix = this.transformation.toMatrix();
22340
22345
  }
22341
- return this.container.getTransformed(this.transformation.toMatrix());
22346
+ const { translateX, translateY, scaleX, scaleY } = matrix;
22347
+ const scaledMatrix = new Matrix(translateX, translateY, scaleX * extraScale, scaleY * extraScale);
22348
+ return this.container.getTransformed(scaledMatrix);
22342
22349
  }
22343
22350
  emitWithoutApplying = (op) => {
22344
22351
  if (this.board.events) {
@@ -22679,7 +22686,9 @@ class RichText extends BaseItem {
22679
22686
  this.insideOf = data.insideOf;
22680
22687
  if (typeof document !== "undefined") {
22681
22688
  document.fonts.ready.then(() => {
22682
- this.updateElement();
22689
+ this.layoutNodes = getBlockNodes(this.getBlockNodes(), this.shrinkWidth ? Infinity : this.getMaxWidth() || 0, this.shrinkWidth, this.insideOf === "Frame");
22690
+ this.alignInRectangle(this.getTransformedContainer(), this.editor.verticalAlignment);
22691
+ this.transformCanvas();
22683
22692
  });
22684
22693
  }
22685
22694
  this.subject.publish(this);
@@ -22696,20 +22705,17 @@ class RichText extends BaseItem {
22696
22705
  }
22697
22706
  const { ctx } = context;
22698
22707
  ctx.save();
22708
+ const cameraScale = context.getCameraScale();
22709
+ const extraScale = this.renderingScale ? this.renderingScale(cameraScale) : 1;
22699
22710
  ctx.translate(this.left, this.top);
22700
- const shouldScale = !this.isInShape && !this.autoSize;
22701
- if (shouldScale) {
22702
- const { scaleX, scaleY } = this.transformation.getMatrixData();
22703
- ctx.scale(scaleX, scaleY);
22704
- }
22711
+ const { scaleX, scaleY } = this.transformation.getMatrixData();
22712
+ ctx.scale(scaleX * extraScale, scaleY * extraScale);
22705
22713
  const shouldClip = this.insideOf === "Shape" || this.insideOf === "Sticker";
22706
22714
  if (shouldClip) {
22707
22715
  ctx.clip(this.clipPath.nativePath);
22708
22716
  }
22709
22717
  const autoSizeScale = this.autoSize ? this.autoSizeScale : undefined;
22710
- const cameraScale = context.getCameraScale();
22711
- const extraScale = this.renderingScale ? this.renderingScale(cameraScale) : 1;
22712
- this.layoutNodes.render(ctx, autoSizeScale ? autoSizeScale * extraScale : extraScale);
22718
+ this.layoutNodes.render(ctx, autoSizeScale);
22713
22719
  ctx.restore();
22714
22720
  if (this.getLinkTo() && (this.insideOf === "RichText" || !this.insideOf)) {
22715
22721
  const { top, right } = this.getMbr();
@@ -22834,12 +22840,12 @@ class RichText extends BaseItem {
22834
22840
  return unsafe.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
22835
22841
  };
22836
22842
  const elements = this.editor.editor.children.map(renderNode);
22837
- const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
22838
22843
  const cameraScale = this.board.camera.getScale();
22839
22844
  const extraScale = this.renderingScale ? this.renderingScale(cameraScale) : 1;
22840
- const transform = `translate(${translateX}px, ${translateY}px) scale(${scaleX * extraScale}, ${scaleY * extraScale})`;
22841
- const transformedWidth = this.getTransformedContainer().getWidth();
22842
- const transformedHeight = this.getTransformedContainer().getHeight();
22845
+ const { scaleX, scaleY } = this.transformation.getMatrixData();
22846
+ const transform = `translate(${this.left}px, ${this.top}px) scale(${scaleX * extraScale}, ${scaleY * extraScale})`;
22847
+ const transformedWidth = this.getMbr().getWidth();
22848
+ const transformedHeight = this.getMbr().getHeight();
22843
22849
  const div = documentFactory.createElement("rich-text");
22844
22850
  div.id = this.getId();
22845
22851
  div.style.width = `${transformedWidth + 5}px`;
@@ -40876,7 +40882,7 @@ class Frame2 extends BaseItem {
40876
40882
  this.text.setSelectionHorisontalAlignment("left");
40877
40883
  this.text.customTransformationMatrix = () => {
40878
40884
  const { translateX, translateY, scaleX } = this.transformation.getMatrixData();
40879
- const scaleY = this.getMbr().getHeight() * 2 / 10;
40885
+ const scaleY = this.text.layoutNodes.height * scaleX / 10;
40880
40886
  return new Matrix(translateX, translateY, scaleX, scaleY);
40881
40887
  };
40882
40888
  this.text.renderingScale = (cameraScale) => {
package/dist/esm/index.js CHANGED
@@ -22328,10 +22328,17 @@ class RichText extends BaseItem {
22328
22328
  return this.shrinkWidth;
22329
22329
  }
22330
22330
  getTransformedContainer() {
22331
+ const cameraScale = this.board.camera.getScale();
22332
+ const extraScale = this.renderingScale ? this.renderingScale(cameraScale) : 1;
22333
+ let matrix;
22331
22334
  if (this.customTransformationMatrix) {
22332
- return this.container.getTransformed(this.customTransformationMatrix());
22335
+ matrix = this.customTransformationMatrix();
22336
+ } else {
22337
+ matrix = this.transformation.toMatrix();
22333
22338
  }
22334
- return this.container.getTransformed(this.transformation.toMatrix());
22339
+ const { translateX, translateY, scaleX, scaleY } = matrix;
22340
+ const scaledMatrix = new Matrix(translateX, translateY, scaleX * extraScale, scaleY * extraScale);
22341
+ return this.container.getTransformed(scaledMatrix);
22335
22342
  }
22336
22343
  emitWithoutApplying = (op) => {
22337
22344
  if (this.board.events) {
@@ -22672,7 +22679,9 @@ class RichText extends BaseItem {
22672
22679
  this.insideOf = data.insideOf;
22673
22680
  if (typeof document !== "undefined") {
22674
22681
  document.fonts.ready.then(() => {
22675
- this.updateElement();
22682
+ this.layoutNodes = getBlockNodes(this.getBlockNodes(), this.shrinkWidth ? Infinity : this.getMaxWidth() || 0, this.shrinkWidth, this.insideOf === "Frame");
22683
+ this.alignInRectangle(this.getTransformedContainer(), this.editor.verticalAlignment);
22684
+ this.transformCanvas();
22676
22685
  });
22677
22686
  }
22678
22687
  this.subject.publish(this);
@@ -22689,20 +22698,17 @@ class RichText extends BaseItem {
22689
22698
  }
22690
22699
  const { ctx } = context;
22691
22700
  ctx.save();
22701
+ const cameraScale = context.getCameraScale();
22702
+ const extraScale = this.renderingScale ? this.renderingScale(cameraScale) : 1;
22692
22703
  ctx.translate(this.left, this.top);
22693
- const shouldScale = !this.isInShape && !this.autoSize;
22694
- if (shouldScale) {
22695
- const { scaleX, scaleY } = this.transformation.getMatrixData();
22696
- ctx.scale(scaleX, scaleY);
22697
- }
22704
+ const { scaleX, scaleY } = this.transformation.getMatrixData();
22705
+ ctx.scale(scaleX * extraScale, scaleY * extraScale);
22698
22706
  const shouldClip = this.insideOf === "Shape" || this.insideOf === "Sticker";
22699
22707
  if (shouldClip) {
22700
22708
  ctx.clip(this.clipPath.nativePath);
22701
22709
  }
22702
22710
  const autoSizeScale = this.autoSize ? this.autoSizeScale : undefined;
22703
- const cameraScale = context.getCameraScale();
22704
- const extraScale = this.renderingScale ? this.renderingScale(cameraScale) : 1;
22705
- this.layoutNodes.render(ctx, autoSizeScale ? autoSizeScale * extraScale : extraScale);
22711
+ this.layoutNodes.render(ctx, autoSizeScale);
22706
22712
  ctx.restore();
22707
22713
  if (this.getLinkTo() && (this.insideOf === "RichText" || !this.insideOf)) {
22708
22714
  const { top, right } = this.getMbr();
@@ -22827,12 +22833,12 @@ class RichText extends BaseItem {
22827
22833
  return unsafe.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
22828
22834
  };
22829
22835
  const elements = this.editor.editor.children.map(renderNode);
22830
- const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
22831
22836
  const cameraScale = this.board.camera.getScale();
22832
22837
  const extraScale = this.renderingScale ? this.renderingScale(cameraScale) : 1;
22833
- const transform = `translate(${translateX}px, ${translateY}px) scale(${scaleX * extraScale}, ${scaleY * extraScale})`;
22834
- const transformedWidth = this.getTransformedContainer().getWidth();
22835
- const transformedHeight = this.getTransformedContainer().getHeight();
22838
+ const { scaleX, scaleY } = this.transformation.getMatrixData();
22839
+ const transform = `translate(${this.left}px, ${this.top}px) scale(${scaleX * extraScale}, ${scaleY * extraScale})`;
22840
+ const transformedWidth = this.getMbr().getWidth();
22841
+ const transformedHeight = this.getMbr().getHeight();
22836
22842
  const div = documentFactory.createElement("rich-text");
22837
22843
  div.id = this.getId();
22838
22844
  div.style.width = `${transformedWidth + 5}px`;
@@ -40869,7 +40875,7 @@ class Frame2 extends BaseItem {
40869
40875
  this.text.setSelectionHorisontalAlignment("left");
40870
40876
  this.text.customTransformationMatrix = () => {
40871
40877
  const { translateX, translateY, scaleX } = this.transformation.getMatrixData();
40872
- const scaleY = this.getMbr().getHeight() * 2 / 10;
40878
+ const scaleY = this.text.layoutNodes.height * scaleX / 10;
40873
40879
  return new Matrix(translateX, translateY, scaleX, scaleY);
40874
40880
  };
40875
40881
  this.text.renderingScale = (cameraScale) => {
package/dist/esm/node.js CHANGED
@@ -24795,10 +24795,17 @@ class RichText extends BaseItem {
24795
24795
  return this.shrinkWidth;
24796
24796
  }
24797
24797
  getTransformedContainer() {
24798
+ const cameraScale = this.board.camera.getScale();
24799
+ const extraScale = this.renderingScale ? this.renderingScale(cameraScale) : 1;
24800
+ let matrix;
24798
24801
  if (this.customTransformationMatrix) {
24799
- return this.container.getTransformed(this.customTransformationMatrix());
24802
+ matrix = this.customTransformationMatrix();
24803
+ } else {
24804
+ matrix = this.transformation.toMatrix();
24800
24805
  }
24801
- return this.container.getTransformed(this.transformation.toMatrix());
24806
+ const { translateX, translateY, scaleX, scaleY } = matrix;
24807
+ const scaledMatrix = new Matrix(translateX, translateY, scaleX * extraScale, scaleY * extraScale);
24808
+ return this.container.getTransformed(scaledMatrix);
24802
24809
  }
24803
24810
  emitWithoutApplying = (op) => {
24804
24811
  if (this.board.events) {
@@ -25139,7 +25146,9 @@ class RichText extends BaseItem {
25139
25146
  this.insideOf = data.insideOf;
25140
25147
  if (typeof document !== "undefined") {
25141
25148
  document.fonts.ready.then(() => {
25142
- this.updateElement();
25149
+ this.layoutNodes = getBlockNodes(this.getBlockNodes(), this.shrinkWidth ? Infinity : this.getMaxWidth() || 0, this.shrinkWidth, this.insideOf === "Frame");
25150
+ this.alignInRectangle(this.getTransformedContainer(), this.editor.verticalAlignment);
25151
+ this.transformCanvas();
25143
25152
  });
25144
25153
  }
25145
25154
  this.subject.publish(this);
@@ -25156,20 +25165,17 @@ class RichText extends BaseItem {
25156
25165
  }
25157
25166
  const { ctx } = context;
25158
25167
  ctx.save();
25168
+ const cameraScale = context.getCameraScale();
25169
+ const extraScale = this.renderingScale ? this.renderingScale(cameraScale) : 1;
25159
25170
  ctx.translate(this.left, this.top);
25160
- const shouldScale = !this.isInShape && !this.autoSize;
25161
- if (shouldScale) {
25162
- const { scaleX, scaleY } = this.transformation.getMatrixData();
25163
- ctx.scale(scaleX, scaleY);
25164
- }
25171
+ const { scaleX, scaleY } = this.transformation.getMatrixData();
25172
+ ctx.scale(scaleX * extraScale, scaleY * extraScale);
25165
25173
  const shouldClip = this.insideOf === "Shape" || this.insideOf === "Sticker";
25166
25174
  if (shouldClip) {
25167
25175
  ctx.clip(this.clipPath.nativePath);
25168
25176
  }
25169
25177
  const autoSizeScale = this.autoSize ? this.autoSizeScale : undefined;
25170
- const cameraScale = context.getCameraScale();
25171
- const extraScale = this.renderingScale ? this.renderingScale(cameraScale) : 1;
25172
- this.layoutNodes.render(ctx, autoSizeScale ? autoSizeScale * extraScale : extraScale);
25178
+ this.layoutNodes.render(ctx, autoSizeScale);
25173
25179
  ctx.restore();
25174
25180
  if (this.getLinkTo() && (this.insideOf === "RichText" || !this.insideOf)) {
25175
25181
  const { top, right } = this.getMbr();
@@ -25294,12 +25300,12 @@ class RichText extends BaseItem {
25294
25300
  return unsafe.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
25295
25301
  };
25296
25302
  const elements = this.editor.editor.children.map(renderNode);
25297
- const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
25298
25303
  const cameraScale = this.board.camera.getScale();
25299
25304
  const extraScale = this.renderingScale ? this.renderingScale(cameraScale) : 1;
25300
- const transform = `translate(${translateX}px, ${translateY}px) scale(${scaleX * extraScale}, ${scaleY * extraScale})`;
25301
- const transformedWidth = this.getTransformedContainer().getWidth();
25302
- const transformedHeight = this.getTransformedContainer().getHeight();
25305
+ const { scaleX, scaleY } = this.transformation.getMatrixData();
25306
+ const transform = `translate(${this.left}px, ${this.top}px) scale(${scaleX * extraScale}, ${scaleY * extraScale})`;
25307
+ const transformedWidth = this.getMbr().getWidth();
25308
+ const transformedHeight = this.getMbr().getHeight();
25303
25309
  const div = documentFactory.createElement("rich-text");
25304
25310
  div.id = this.getId();
25305
25311
  div.style.width = `${transformedWidth + 5}px`;
@@ -43337,7 +43343,7 @@ class Frame2 extends BaseItem {
43337
43343
  this.text.setSelectionHorisontalAlignment("left");
43338
43344
  this.text.customTransformationMatrix = () => {
43339
43345
  const { translateX, translateY, scaleX } = this.transformation.getMatrixData();
43340
- const scaleY = this.getMbr().getHeight() * 2 / 10;
43346
+ const scaleY = this.text.layoutNodes.height * scaleX / 10;
43341
43347
  return new Matrix(translateX, translateY, scaleX, scaleY);
43342
43348
  };
43343
43349
  this.text.renderingScale = (cameraScale) => {
@@ -10,6 +10,7 @@ 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";
13
+ import { LayoutBlockNodes } from "./CanvasText/LayoutBlockNodes";
13
14
  import { BlockNode, BlockType } from "./Editor/BlockNode";
14
15
  import { TextStyle } from "./Editor/TextNode";
15
16
  import { EditorContainer } from "./EditorContainer";
@@ -37,7 +38,7 @@ export declare class RichText extends BaseItem {
37
38
  readonly editorEditor: import("slate").EditorInterface;
38
39
  private isContainerSet;
39
40
  isRenderEnabled: boolean;
40
- private layoutNodes;
41
+ layoutNodes: LayoutBlockNodes;
41
42
  private clipPath;
42
43
  private updateRequired;
43
44
  private autoSizeScale;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "microboard-temp",
3
- "version": "0.13.0",
3
+ "version": "0.13.1",
4
4
  "description": "A flexible interactive whiteboard library",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",