microboard-temp 0.13.0 → 0.13.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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, scaleY);
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,25 @@ class RichText extends BaseItem {
22867
22876
  }
22868
22877
  const { ctx } = context;
22869
22878
  ctx.save();
22870
- 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);
22879
+ const cameraScale = context.getCameraScale();
22880
+ const extraScale = this.renderingScale ? this.renderingScale(cameraScale) : 1;
22881
+ let matrix;
22882
+ if (this.customTransformationMatrix) {
22883
+ matrix = this.customTransformationMatrix();
22884
+ } else {
22885
+ matrix = this.transformation.toMatrix();
22875
22886
  }
22887
+ const { translateX, translateY, scaleX, scaleY } = matrix;
22888
+ const scaledMatrix = new Matrix(translateX, translateY, scaleX * extraScale, scaleY * extraScale);
22889
+ context.matrix = scaledMatrix;
22890
+ context.applyChanges();
22891
+ ctx.translate(this.container.left, this.container.top);
22876
22892
  const shouldClip = this.insideOf === "Shape" || this.insideOf === "Sticker";
22877
22893
  if (shouldClip) {
22878
22894
  ctx.clip(this.clipPath.nativePath);
22879
22895
  }
22880
22896
  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);
22897
+ this.layoutNodes.render(ctx, autoSizeScale);
22884
22898
  ctx.restore();
22885
22899
  if (this.getLinkTo() && (this.insideOf === "RichText" || !this.insideOf)) {
22886
22900
  const { top, right } = this.getMbr();
@@ -23005,12 +23019,19 @@ class RichText extends BaseItem {
23005
23019
  return unsafe.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
23006
23020
  };
23007
23021
  const elements = this.editor.editor.children.map(renderNode);
23008
- const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
23009
23022
  const cameraScale = this.board.camera.getScale();
23010
23023
  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();
23024
+ let matrix;
23025
+ if (this.customTransformationMatrix) {
23026
+ matrix = this.customTransformationMatrix();
23027
+ } else {
23028
+ matrix = this.transformation.toMatrix();
23029
+ }
23030
+ const { translateX, translateY, scaleX, scaleY } = matrix;
23031
+ const scaledMatrix = new Matrix(translateX, translateY, scaleX * extraScale, scaleY * extraScale);
23032
+ const transform = `translate(${scaledMatrix.translateX + this.container.left * scaledMatrix.scaleX}px, ${scaledMatrix.translateY + this.container.top * scaledMatrix.scaleY}px) scale(${scaledMatrix.scaleX}, ${scaledMatrix.scaleY})`;
23033
+ const transformedWidth = this.getMbr().getWidth();
23034
+ const transformedHeight = this.getMbr().getHeight();
23014
23035
  const div = documentFactory.createElement("rich-text");
23015
23036
  div.id = this.getId();
23016
23037
  div.style.width = `${transformedWidth + 5}px`;
@@ -41046,9 +41067,8 @@ class Frame2 extends BaseItem {
41046
41067
  this.text = new RichText(board, this.textContainer, this.id, this.transformation, this.linkTo, this.name, true, false, "Frame", { ...conf.DEFAULT_TEXT_STYLES, fontColor: FRAME_TITLE_COLOR });
41047
41068
  this.text.setSelectionHorisontalAlignment("left");
41048
41069
  this.text.customTransformationMatrix = () => {
41049
- const { translateX, translateY, scaleX } = this.transformation.getMatrixData();
41050
- const scaleY = this.getMbr().getHeight() * 2 / 10;
41051
- return new Matrix(translateX, translateY, scaleX, scaleY);
41070
+ const matrix = this.transformation.toMatrix();
41071
+ return new Matrix(matrix.translateX, matrix.translateY, 1, 1);
41052
41072
  };
41053
41073
  this.text.renderingScale = (cameraScale) => {
41054
41074
  return Math.max(1, Math.min(5, 1 / 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, scaleY);
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,25 @@ class RichText extends BaseItem {
22867
22876
  }
22868
22877
  const { ctx } = context;
22869
22878
  ctx.save();
22870
- 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);
22879
+ const cameraScale = context.getCameraScale();
22880
+ const extraScale = this.renderingScale ? this.renderingScale(cameraScale) : 1;
22881
+ let matrix;
22882
+ if (this.customTransformationMatrix) {
22883
+ matrix = this.customTransformationMatrix();
22884
+ } else {
22885
+ matrix = this.transformation.toMatrix();
22875
22886
  }
22887
+ const { translateX, translateY, scaleX, scaleY } = matrix;
22888
+ const scaledMatrix = new Matrix(translateX, translateY, scaleX * extraScale, scaleY * extraScale);
22889
+ context.matrix = scaledMatrix;
22890
+ context.applyChanges();
22891
+ ctx.translate(this.container.left, this.container.top);
22876
22892
  const shouldClip = this.insideOf === "Shape" || this.insideOf === "Sticker";
22877
22893
  if (shouldClip) {
22878
22894
  ctx.clip(this.clipPath.nativePath);
22879
22895
  }
22880
22896
  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);
22897
+ this.layoutNodes.render(ctx, autoSizeScale);
22884
22898
  ctx.restore();
22885
22899
  if (this.getLinkTo() && (this.insideOf === "RichText" || !this.insideOf)) {
22886
22900
  const { top, right } = this.getMbr();
@@ -23005,12 +23019,19 @@ class RichText extends BaseItem {
23005
23019
  return unsafe.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
23006
23020
  };
23007
23021
  const elements = this.editor.editor.children.map(renderNode);
23008
- const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
23009
23022
  const cameraScale = this.board.camera.getScale();
23010
23023
  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();
23024
+ let matrix;
23025
+ if (this.customTransformationMatrix) {
23026
+ matrix = this.customTransformationMatrix();
23027
+ } else {
23028
+ matrix = this.transformation.toMatrix();
23029
+ }
23030
+ const { translateX, translateY, scaleX, scaleY } = matrix;
23031
+ const scaledMatrix = new Matrix(translateX, translateY, scaleX * extraScale, scaleY * extraScale);
23032
+ const transform = `translate(${scaledMatrix.translateX + this.container.left * scaledMatrix.scaleX}px, ${scaledMatrix.translateY + this.container.top * scaledMatrix.scaleY}px) scale(${scaledMatrix.scaleX}, ${scaledMatrix.scaleY})`;
23033
+ const transformedWidth = this.getMbr().getWidth();
23034
+ const transformedHeight = this.getMbr().getHeight();
23014
23035
  const div = documentFactory.createElement("rich-text");
23015
23036
  div.id = this.getId();
23016
23037
  div.style.width = `${transformedWidth + 5}px`;
@@ -41046,9 +41067,8 @@ class Frame2 extends BaseItem {
41046
41067
  this.text = new RichText(board, this.textContainer, this.id, this.transformation, this.linkTo, this.name, true, false, "Frame", { ...conf.DEFAULT_TEXT_STYLES, fontColor: FRAME_TITLE_COLOR });
41047
41068
  this.text.setSelectionHorisontalAlignment("left");
41048
41069
  this.text.customTransformationMatrix = () => {
41049
- const { translateX, translateY, scaleX } = this.transformation.getMatrixData();
41050
- const scaleY = this.getMbr().getHeight() * 2 / 10;
41051
- return new Matrix(translateX, translateY, scaleX, scaleY);
41070
+ const matrix = this.transformation.toMatrix();
41071
+ return new Matrix(matrix.translateX, matrix.translateY, 1, 1);
41052
41072
  };
41053
41073
  this.text.renderingScale = (cameraScale) => {
41054
41074
  return Math.max(1, Math.min(5, 1 / 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, scaleY);
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,25 @@ class RichText extends BaseItem {
25339
25348
  }
25340
25349
  const { ctx } = context;
25341
25350
  ctx.save();
25342
- 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);
25351
+ const cameraScale = context.getCameraScale();
25352
+ const extraScale = this.renderingScale ? this.renderingScale(cameraScale) : 1;
25353
+ let matrix;
25354
+ if (this.customTransformationMatrix) {
25355
+ matrix = this.customTransformationMatrix();
25356
+ } else {
25357
+ matrix = this.transformation.toMatrix();
25347
25358
  }
25359
+ const { translateX, translateY, scaleX, scaleY } = matrix;
25360
+ const scaledMatrix = new Matrix(translateX, translateY, scaleX * extraScale, scaleY * extraScale);
25361
+ context.matrix = scaledMatrix;
25362
+ context.applyChanges();
25363
+ ctx.translate(this.container.left, this.container.top);
25348
25364
  const shouldClip = this.insideOf === "Shape" || this.insideOf === "Sticker";
25349
25365
  if (shouldClip) {
25350
25366
  ctx.clip(this.clipPath.nativePath);
25351
25367
  }
25352
25368
  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);
25369
+ this.layoutNodes.render(ctx, autoSizeScale);
25356
25370
  ctx.restore();
25357
25371
  if (this.getLinkTo() && (this.insideOf === "RichText" || !this.insideOf)) {
25358
25372
  const { top, right } = this.getMbr();
@@ -25477,12 +25491,19 @@ class RichText extends BaseItem {
25477
25491
  return unsafe.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
25478
25492
  };
25479
25493
  const elements = this.editor.editor.children.map(renderNode);
25480
- const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
25481
25494
  const cameraScale = this.board.camera.getScale();
25482
25495
  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();
25496
+ let matrix;
25497
+ if (this.customTransformationMatrix) {
25498
+ matrix = this.customTransformationMatrix();
25499
+ } else {
25500
+ matrix = this.transformation.toMatrix();
25501
+ }
25502
+ const { translateX, translateY, scaleX, scaleY } = matrix;
25503
+ const scaledMatrix = new Matrix(translateX, translateY, scaleX * extraScale, scaleY * extraScale);
25504
+ const transform = `translate(${scaledMatrix.translateX + this.container.left * scaledMatrix.scaleX}px, ${scaledMatrix.translateY + this.container.top * scaledMatrix.scaleY}px) scale(${scaledMatrix.scaleX}, ${scaledMatrix.scaleY})`;
25505
+ const transformedWidth = this.getMbr().getWidth();
25506
+ const transformedHeight = this.getMbr().getHeight();
25486
25507
  const div = documentFactory.createElement("rich-text");
25487
25508
  div.id = this.getId();
25488
25509
  div.style.width = `${transformedWidth + 5}px`;
@@ -43519,9 +43540,8 @@ class Frame2 extends BaseItem {
43519
43540
  this.text = new RichText(board, this.textContainer, this.id, this.transformation, this.linkTo, this.name, true, false, "Frame", { ...conf.DEFAULT_TEXT_STYLES, fontColor: FRAME_TITLE_COLOR });
43520
43541
  this.text.setSelectionHorisontalAlignment("left");
43521
43542
  this.text.customTransformationMatrix = () => {
43522
- const { translateX, translateY, scaleX } = this.transformation.getMatrixData();
43523
- const scaleY = this.getMbr().getHeight() * 2 / 10;
43524
- return new Matrix(translateX, translateY, scaleX, scaleY);
43543
+ const matrix = this.transformation.toMatrix();
43544
+ return new Matrix(matrix.translateX, matrix.translateY, 1, 1);
43525
43545
  };
43526
43546
  this.text.renderingScale = (cameraScale) => {
43527
43547
  return Math.max(1, Math.min(5, 1 / 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, scaleY);
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,25 @@ class RichText extends BaseItem {
22696
22705
  }
22697
22706
  const { ctx } = context;
22698
22707
  ctx.save();
22699
- 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);
22708
+ const cameraScale = context.getCameraScale();
22709
+ const extraScale = this.renderingScale ? this.renderingScale(cameraScale) : 1;
22710
+ let matrix;
22711
+ if (this.customTransformationMatrix) {
22712
+ matrix = this.customTransformationMatrix();
22713
+ } else {
22714
+ matrix = this.transformation.toMatrix();
22704
22715
  }
22716
+ const { translateX, translateY, scaleX, scaleY } = matrix;
22717
+ const scaledMatrix = new Matrix(translateX, translateY, scaleX * extraScale, scaleY * extraScale);
22718
+ context.matrix = scaledMatrix;
22719
+ context.applyChanges();
22720
+ ctx.translate(this.container.left, this.container.top);
22705
22721
  const shouldClip = this.insideOf === "Shape" || this.insideOf === "Sticker";
22706
22722
  if (shouldClip) {
22707
22723
  ctx.clip(this.clipPath.nativePath);
22708
22724
  }
22709
22725
  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);
22726
+ this.layoutNodes.render(ctx, autoSizeScale);
22713
22727
  ctx.restore();
22714
22728
  if (this.getLinkTo() && (this.insideOf === "RichText" || !this.insideOf)) {
22715
22729
  const { top, right } = this.getMbr();
@@ -22834,12 +22848,19 @@ class RichText extends BaseItem {
22834
22848
  return unsafe.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
22835
22849
  };
22836
22850
  const elements = this.editor.editor.children.map(renderNode);
22837
- const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
22838
22851
  const cameraScale = this.board.camera.getScale();
22839
22852
  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();
22853
+ let matrix;
22854
+ if (this.customTransformationMatrix) {
22855
+ matrix = this.customTransformationMatrix();
22856
+ } else {
22857
+ matrix = this.transformation.toMatrix();
22858
+ }
22859
+ const { translateX, translateY, scaleX, scaleY } = matrix;
22860
+ const scaledMatrix = new Matrix(translateX, translateY, scaleX * extraScale, scaleY * extraScale);
22861
+ const transform = `translate(${scaledMatrix.translateX + this.container.left * scaledMatrix.scaleX}px, ${scaledMatrix.translateY + this.container.top * scaledMatrix.scaleY}px) scale(${scaledMatrix.scaleX}, ${scaledMatrix.scaleY})`;
22862
+ const transformedWidth = this.getMbr().getWidth();
22863
+ const transformedHeight = this.getMbr().getHeight();
22843
22864
  const div = documentFactory.createElement("rich-text");
22844
22865
  div.id = this.getId();
22845
22866
  div.style.width = `${transformedWidth + 5}px`;
@@ -40875,9 +40896,8 @@ class Frame2 extends BaseItem {
40875
40896
  this.text = new RichText(board, this.textContainer, this.id, this.transformation, this.linkTo, this.name, true, false, "Frame", { ...conf.DEFAULT_TEXT_STYLES, fontColor: FRAME_TITLE_COLOR });
40876
40897
  this.text.setSelectionHorisontalAlignment("left");
40877
40898
  this.text.customTransformationMatrix = () => {
40878
- const { translateX, translateY, scaleX } = this.transformation.getMatrixData();
40879
- const scaleY = this.getMbr().getHeight() * 2 / 10;
40880
- return new Matrix(translateX, translateY, scaleX, scaleY);
40899
+ const matrix = this.transformation.toMatrix();
40900
+ return new Matrix(matrix.translateX, matrix.translateY, 1, 1);
40881
40901
  };
40882
40902
  this.text.renderingScale = (cameraScale) => {
40883
40903
  return Math.max(1, Math.min(5, 1 / 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, scaleY);
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,25 @@ class RichText extends BaseItem {
22689
22698
  }
22690
22699
  const { ctx } = context;
22691
22700
  ctx.save();
22692
- 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);
22701
+ const cameraScale = context.getCameraScale();
22702
+ const extraScale = this.renderingScale ? this.renderingScale(cameraScale) : 1;
22703
+ let matrix;
22704
+ if (this.customTransformationMatrix) {
22705
+ matrix = this.customTransformationMatrix();
22706
+ } else {
22707
+ matrix = this.transformation.toMatrix();
22697
22708
  }
22709
+ const { translateX, translateY, scaleX, scaleY } = matrix;
22710
+ const scaledMatrix = new Matrix(translateX, translateY, scaleX * extraScale, scaleY * extraScale);
22711
+ context.matrix = scaledMatrix;
22712
+ context.applyChanges();
22713
+ ctx.translate(this.container.left, this.container.top);
22698
22714
  const shouldClip = this.insideOf === "Shape" || this.insideOf === "Sticker";
22699
22715
  if (shouldClip) {
22700
22716
  ctx.clip(this.clipPath.nativePath);
22701
22717
  }
22702
22718
  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);
22719
+ this.layoutNodes.render(ctx, autoSizeScale);
22706
22720
  ctx.restore();
22707
22721
  if (this.getLinkTo() && (this.insideOf === "RichText" || !this.insideOf)) {
22708
22722
  const { top, right } = this.getMbr();
@@ -22827,12 +22841,19 @@ class RichText extends BaseItem {
22827
22841
  return unsafe.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
22828
22842
  };
22829
22843
  const elements = this.editor.editor.children.map(renderNode);
22830
- const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
22831
22844
  const cameraScale = this.board.camera.getScale();
22832
22845
  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();
22846
+ let matrix;
22847
+ if (this.customTransformationMatrix) {
22848
+ matrix = this.customTransformationMatrix();
22849
+ } else {
22850
+ matrix = this.transformation.toMatrix();
22851
+ }
22852
+ const { translateX, translateY, scaleX, scaleY } = matrix;
22853
+ const scaledMatrix = new Matrix(translateX, translateY, scaleX * extraScale, scaleY * extraScale);
22854
+ const transform = `translate(${scaledMatrix.translateX + this.container.left * scaledMatrix.scaleX}px, ${scaledMatrix.translateY + this.container.top * scaledMatrix.scaleY}px) scale(${scaledMatrix.scaleX}, ${scaledMatrix.scaleY})`;
22855
+ const transformedWidth = this.getMbr().getWidth();
22856
+ const transformedHeight = this.getMbr().getHeight();
22836
22857
  const div = documentFactory.createElement("rich-text");
22837
22858
  div.id = this.getId();
22838
22859
  div.style.width = `${transformedWidth + 5}px`;
@@ -40868,9 +40889,8 @@ class Frame2 extends BaseItem {
40868
40889
  this.text = new RichText(board, this.textContainer, this.id, this.transformation, this.linkTo, this.name, true, false, "Frame", { ...conf.DEFAULT_TEXT_STYLES, fontColor: FRAME_TITLE_COLOR });
40869
40890
  this.text.setSelectionHorisontalAlignment("left");
40870
40891
  this.text.customTransformationMatrix = () => {
40871
- const { translateX, translateY, scaleX } = this.transformation.getMatrixData();
40872
- const scaleY = this.getMbr().getHeight() * 2 / 10;
40873
- return new Matrix(translateX, translateY, scaleX, scaleY);
40892
+ const matrix = this.transformation.toMatrix();
40893
+ return new Matrix(matrix.translateX, matrix.translateY, 1, 1);
40874
40894
  };
40875
40895
  this.text.renderingScale = (cameraScale) => {
40876
40896
  return Math.max(1, Math.min(5, 1 / 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, scaleY);
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,25 @@ class RichText extends BaseItem {
25156
25165
  }
25157
25166
  const { ctx } = context;
25158
25167
  ctx.save();
25159
- 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);
25168
+ const cameraScale = context.getCameraScale();
25169
+ const extraScale = this.renderingScale ? this.renderingScale(cameraScale) : 1;
25170
+ let matrix;
25171
+ if (this.customTransformationMatrix) {
25172
+ matrix = this.customTransformationMatrix();
25173
+ } else {
25174
+ matrix = this.transformation.toMatrix();
25164
25175
  }
25176
+ const { translateX, translateY, scaleX, scaleY } = matrix;
25177
+ const scaledMatrix = new Matrix(translateX, translateY, scaleX * extraScale, scaleY * extraScale);
25178
+ context.matrix = scaledMatrix;
25179
+ context.applyChanges();
25180
+ ctx.translate(this.container.left, this.container.top);
25165
25181
  const shouldClip = this.insideOf === "Shape" || this.insideOf === "Sticker";
25166
25182
  if (shouldClip) {
25167
25183
  ctx.clip(this.clipPath.nativePath);
25168
25184
  }
25169
25185
  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);
25186
+ this.layoutNodes.render(ctx, autoSizeScale);
25173
25187
  ctx.restore();
25174
25188
  if (this.getLinkTo() && (this.insideOf === "RichText" || !this.insideOf)) {
25175
25189
  const { top, right } = this.getMbr();
@@ -25294,12 +25308,19 @@ class RichText extends BaseItem {
25294
25308
  return unsafe.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
25295
25309
  };
25296
25310
  const elements = this.editor.editor.children.map(renderNode);
25297
- const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
25298
25311
  const cameraScale = this.board.camera.getScale();
25299
25312
  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();
25313
+ let matrix;
25314
+ if (this.customTransformationMatrix) {
25315
+ matrix = this.customTransformationMatrix();
25316
+ } else {
25317
+ matrix = this.transformation.toMatrix();
25318
+ }
25319
+ const { translateX, translateY, scaleX, scaleY } = matrix;
25320
+ const scaledMatrix = new Matrix(translateX, translateY, scaleX * extraScale, scaleY * extraScale);
25321
+ const transform = `translate(${scaledMatrix.translateX + this.container.left * scaledMatrix.scaleX}px, ${scaledMatrix.translateY + this.container.top * scaledMatrix.scaleY}px) scale(${scaledMatrix.scaleX}, ${scaledMatrix.scaleY})`;
25322
+ const transformedWidth = this.getMbr().getWidth();
25323
+ const transformedHeight = this.getMbr().getHeight();
25303
25324
  const div = documentFactory.createElement("rich-text");
25304
25325
  div.id = this.getId();
25305
25326
  div.style.width = `${transformedWidth + 5}px`;
@@ -43336,9 +43357,8 @@ class Frame2 extends BaseItem {
43336
43357
  this.text = new RichText(board, this.textContainer, this.id, this.transformation, this.linkTo, this.name, true, false, "Frame", { ...conf.DEFAULT_TEXT_STYLES, fontColor: FRAME_TITLE_COLOR });
43337
43358
  this.text.setSelectionHorisontalAlignment("left");
43338
43359
  this.text.customTransformationMatrix = () => {
43339
- const { translateX, translateY, scaleX } = this.transformation.getMatrixData();
43340
- const scaleY = this.getMbr().getHeight() * 2 / 10;
43341
- return new Matrix(translateX, translateY, scaleX, scaleY);
43360
+ const matrix = this.transformation.toMatrix();
43361
+ return new Matrix(matrix.translateX, matrix.translateY, 1, 1);
43342
43362
  };
43343
43363
  this.text.renderingScale = (cameraScale) => {
43344
43364
  return Math.max(1, Math.min(5, 1 / 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.2",
4
4
  "description": "A flexible interactive whiteboard library",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",