@8btc/whiteboard 0.0.20-alpha.16 → 0.0.20-alpha.18

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.
Files changed (2) hide show
  1. package/dist/index.js +22 -14
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -335,7 +335,6 @@ vi = new WeakMap(), de = new WeakMap(), Cs = new WeakMap(), Ss = new WeakMap(),
335
335
  */
336
336
  Zf = function() {
337
337
  b(this, de).on("transformstart", b(this, Cs)), b(this, de).on("transform", b(this, Ss)), b(this, de).on("transformend", b(this, ks)), b(this, de).on("dragstart", b(this, Es)), b(this, de).on("dragmove", b(this, Ts)), b(this, de).on("dragend", b(this, Ms)), b(this, de).on("pointerdblclick", (e) => {
338
- console.log("Transformer double clicked", e);
339
338
  const t = b(this, de).nodes();
340
339
  if (t.length === 1) {
341
340
  const r = t[0];
@@ -18401,17 +18400,27 @@ class US extends nr {
18401
18400
  });
18402
18401
  L(this, xr, async () => {
18403
18402
  const t = this.htmlEditorElement.getBoundingClientRect();
18404
- if (!(t.width === 0 || t.height === 0))
18405
- return VS(this.htmlEditorElement, {
18406
- width: t.width,
18407
- height: t.height,
18408
- pixelRatio: 3
18409
- }).then((r) => {
18410
- const i = this.element.getClientRect();
18411
- this.element.image(r), this.element.width(i.width), this.element.height(i.height);
18412
- }).catch((r) => {
18413
- console.error("Failed to render text to canvas:", r);
18414
- });
18403
+ if (t.width === 0 || t.height === 0)
18404
+ return;
18405
+ this.htmlElement.style.opacity = "1", this.element.opacity(0);
18406
+ const r = t.width / (this.core.getState().viewport.scale / this.config.scaleWhenCreate), i = t.height / (this.core.getState().viewport.scale / this.config.scaleWhenCreate);
18407
+ return VS(this.htmlEditorElement, {
18408
+ width: r,
18409
+ height: i,
18410
+ pixelRatio: 2,
18411
+ canvasWidth: r * 2,
18412
+ canvasHeight: i * 2
18413
+ }).then((o) => {
18414
+ this.element.image(o), this.element.width(
18415
+ t.width / this.core.getState().viewport.scale
18416
+ ), this.element.height(
18417
+ t.height / this.core.getState().viewport.scale
18418
+ );
18419
+ }).catch((o) => {
18420
+ console.error("Failed to render text to canvas:", o);
18421
+ }).finally(() => {
18422
+ this.htmlElement.style.opacity = "0", this.element.opacity(1);
18423
+ });
18415
18424
  });
18416
18425
  W(this, "detachEditor", () => {
18417
18426
  this.editor && (this.htmlElement.id = "", this.htmlEditorElement.innerHTML = this.editor.getHTML(), this.config.$_htmlContent = this.editor.getHTML(), this.editor.commands.blur(), this.htmlElement.style.pointerEvents = "none", this.element.listening(!0), this.core.isEditingText = !1, this.core._unregisterTextEditor(), window.removeEventListener("keydown", b(this, Mi)), window.removeEventListener("click", b(this, Ai)), this.editor.destroy(), this.editor = void 0, b(this, xr).call(this).then(() => {
@@ -18420,7 +18429,7 @@ class US extends nr {
18420
18429
  });
18421
18430
  L(this, yn, () => {
18422
18431
  const t = this.element.getClientRect();
18423
- this.htmlElement.style.left = `${t.x}px`, this.htmlElement.style.top = `${t.y}px`, this.config.lockX ? this.htmlEditorElement.style.width = `${t.width / this.config.htmlScale * this.config.scaleWhenCreate / this.core.getState().viewport.scale}px` : this.htmlEditorElement.style.width = "auto", this.htmlEditorElement.style.transform = `scale(${this.config.htmlScale})`;
18432
+ this.htmlElement.style.left = `${t.x}px`, this.htmlElement.style.top = `${t.y}px`, this.config.lockX ? this.htmlEditorElement.style.width = `${this.element.width() / this.config.htmlScale * this.config.scaleWhenCreate}px` : this.htmlEditorElement.style.width = "max-content", this.htmlEditorElement.style.transform = `scale(${this.config.htmlScale})`;
18424
18433
  });
18425
18434
  L(this, Ds, () => {
18426
18435
  this.resizeObserver = new ResizeObserver((t) => {
@@ -18506,7 +18515,6 @@ Xm = function() {
18506
18515
  t.width(t.width() * t.scaleX()), t.height(t.height() * t.scaleY()), this.config.htmlScale = this.config.htmlScale * t.scaleX(), t.setAttr("htmlScale", this.config.htmlScale), t.scale({ x: 1, y: 1 }), b(this, yn).call(this);
18507
18516
  }), t.on("transformend", (r) => {
18508
18517
  this.syncConfigFromElement(), this.core._rebuildStateAfterNodeChange(this, !0), b(this, xr).call(this).then(() => {
18509
- this.htmlElement.style.transition = "opacity 0.1s", this.element.opacity(1), this.htmlElement.style.opacity = "0";
18510
18518
  });
18511
18519
  }), t.on("dragmove", () => {
18512
18520
  b(this, yn).call(this);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@8btc/whiteboard",
3
3
  "private": false,
4
- "version": "0.0.20-alpha.16",
4
+ "version": "0.0.20-alpha.18",
5
5
  "type": "module",
6
6
  "main": "./dist/index.umd.js",
7
7
  "module": "./dist/index.js",