@anu3ev/fabric-image-editor 0.8.23 → 0.8.25

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/main.js +36 -25
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -7254,7 +7254,7 @@ var Si = class {
7254
7254
  }, this._handleTextChanged = (e) => {
7255
7255
  if (!(e.target instanceof v)) return;
7256
7256
  let t = e.target;
7257
- U(t.group) && this.runtime.syncShapeTextLayoutAfterTextMutation({ textNode: t }) && this.runtime.editor.canvas.requestRenderAll();
7257
+ U(t.group) && (this.runtime.editor.textManager.syncLineStylesWithText({ textbox: t }), this.runtime.syncShapeTextLayoutAfterTextMutation({ textNode: t }) && this.runtime.editor.canvas.requestRenderAll());
7258
7258
  }, this._handleBeforeTextUpdated = (e) => {
7259
7259
  let { textbox: t, style: n } = e;
7260
7260
  if (!(t instanceof v)) return;
@@ -10785,11 +10785,14 @@ var pa = {
10785
10785
  });
10786
10786
  }
10787
10787
  _applyPostStyleLayout({ textbox: e, placement: t, style: n, styleMaps: r, contentUpdate: i, contentPlacement: a, syncLineStylesWithText: o }) {
10788
- let s = e.text ?? "", c = this._hasBackgroundStyleUpdate({ style: n }), l = this._resolveShouldAutoExpand({
10788
+ let s = e.text ?? "", c = this._hasBackgroundStyleUpdate({ style: n }), l = this._shouldRefreshDimensions({
10789
+ contentUpdate: i,
10790
+ styleMaps: r
10791
+ }), u = this._resolveShouldAutoExpand({
10789
10792
  textbox: e,
10790
10793
  style: n,
10791
10794
  styleMaps: r,
10792
- contentUpdate: i
10795
+ shouldRefreshDimensions: l
10793
10796
  });
10794
10797
  c && (e.dirty = !0), this._applyAutoExpandPreference({
10795
10798
  textbox: e,
@@ -10802,7 +10805,8 @@ var pa = {
10802
10805
  }), this.runtime.normalizeTextboxAfterContentChange({
10803
10806
  textbox: e,
10804
10807
  placement: t,
10805
- shouldAutoExpand: l
10808
+ shouldAutoExpand: u,
10809
+ shouldRefreshDimensions: l
10806
10810
  }), a && this.runtime.restoreTextboxContentPlacement({
10807
10811
  textbox: e,
10808
10812
  contentPlacement: a
@@ -10822,14 +10826,16 @@ var pa = {
10822
10826
  e.radiusBottomLeft
10823
10827
  ].some((e) => e !== void 0);
10824
10828
  }
10825
- _resolveShouldAutoExpand({ textbox: e, style: t, styleMaps: n, contentUpdate: r }) {
10826
- let i = t.autoExpand ?? e.autoExpand, a = aa({ stylesList: [
10827
- n.updates,
10828
- n.selectionStyles,
10829
- n.lineSelectionStyles,
10830
- n.wholeTextStyles
10829
+ _resolveShouldAutoExpand({ textbox: e, style: t, styleMaps: n, shouldRefreshDimensions: r }) {
10830
+ return (t.autoExpand ?? e.autoExpand) !== !1 && !Object.prototype.hasOwnProperty.call(n.updates, "width") && r;
10831
+ }
10832
+ _shouldRefreshDimensions({ contentUpdate: e, styleMaps: t }) {
10833
+ return e.hasTextUpdate || e.uppercaseChanged || aa({ stylesList: [
10834
+ t.updates,
10835
+ t.selectionStyles,
10836
+ t.lineSelectionStyles,
10837
+ t.wholeTextStyles
10831
10838
  ] });
10832
- return i !== !1 && !Object.prototype.hasOwnProperty.call(n.updates, "width") && (r.hasTextUpdate || r.uppercaseChanged || a);
10833
10839
  }
10834
10840
  _applyAutoExpandPreference({ textbox: e, autoExpand: t }) {
10835
10841
  if (t !== void 0) {
@@ -11173,14 +11179,15 @@ var Wa = class {
11173
11179
  e !== i && n.set({ text: e }), n.textCaseRaw = l;
11174
11180
  } else n.textCaseRaw = i;
11175
11181
  if (!r && o === void 0 && (n.autoExpand = !0), r) {
11176
- this._syncLineStylesWithText({ textbox: n });
11182
+ this.syncLineStylesWithText({ textbox: n });
11177
11183
  return;
11178
11184
  }
11179
- this._normalizeTextboxAfterContentChange({
11185
+ this.syncLineStylesWithText({ textbox: n }), this._normalizeTextboxAfterContentChange({
11180
11186
  textbox: n,
11181
11187
  placement: u,
11182
- shouldAutoExpand: c
11183
- }), this._syncLineStylesWithText({ textbox: n });
11188
+ shouldAutoExpand: c,
11189
+ shouldRefreshDimensions: !0
11190
+ });
11184
11191
  }, this._handleTextEditingExited = (t) => {
11185
11192
  let { target: n } = t;
11186
11193
  if (!e._isTextbox(n)) return;
@@ -11230,7 +11237,7 @@ var Wa = class {
11230
11237
  resolveTextObject: (e) => this._resolveTextObject(e),
11231
11238
  normalizeTextboxAfterContentChange: (e) => this._normalizeTextboxAfterContentChange(e),
11232
11239
  restoreTextboxContentPlacement: (e) => this._restoreTextboxContentPlacement(e),
11233
- syncLineStylesWithText: (e) => this._syncLineStylesWithText(e),
11240
+ syncLineStylesWithText: (e) => this.syncLineStylesWithText(e),
11234
11241
  getSnapshot: (t) => e._getSnapshot(t)
11235
11242
  } }), this.editingPlacementState = /* @__PURE__ */ new WeakMap(), this.isTextEditingActive = !1, this._bindEvents(), Ia();
11236
11243
  }
@@ -11371,19 +11378,23 @@ var Wa = class {
11371
11378
  let n = t.split("\n").length, { textLines: r } = e;
11372
11379
  return Array.isArray(r) && r.length > n;
11373
11380
  }
11374
- _normalizeTextboxAfterContentChange({ textbox: e, placement: t, shouldAutoExpand: n, clampToMontage: r = !0 }) {
11375
- let i = !1;
11376
- n && (i = this._autoExpandTextboxWidth(e, {
11381
+ _normalizeTextboxAfterContentChange({ textbox: e, placement: t, shouldAutoExpand: n, clampToMontage: r = !0, shouldRefreshDimensions: i = !1 }) {
11382
+ let a = !1;
11383
+ n && (a = this._autoExpandTextboxWidth(e, {
11377
11384
  placement: t ?? void 0,
11378
11385
  clampToMontage: r
11379
11386
  }));
11380
- let a = !1;
11381
- i || (a = oa({ textbox: e }));
11382
- let o = !1;
11383
- return !i && t && (this.editor.canvasManager.applyObjectPlacement({
11387
+ let o = !1, s = !1;
11388
+ if (!a && i) {
11389
+ let t = e.width ?? 0, n = e.height ?? 0;
11390
+ e.initDimensions(), o = Math.abs((e.width ?? 0) - t) > .01 || Math.abs((e.height ?? 0) - n) > .01;
11391
+ }
11392
+ a || (s = oa({ textbox: e }));
11393
+ let c = !1;
11394
+ return !a && t && (this.editor.canvasManager.applyObjectPlacement({
11384
11395
  object: e,
11385
11396
  placement: t
11386
- }), o = !0), (i || a) && (e.dirty = !0), (i || a || o) && e.setCoords(), i || a;
11397
+ }), c = !0), (a || o || s) && (e.dirty = !0), (a || o || s || c) && e.setCoords(), a || o || s;
11387
11398
  }
11388
11399
  _restoreTextboxContentPlacement({ textbox: e, contentPlacement: t }) {
11389
11400
  let n = na({
@@ -11403,7 +11414,7 @@ var Wa = class {
11403
11414
  let { canvas: e } = this;
11404
11415
  e.on("object:scaling", this.scalingController.handleObjectScaling), e.on("object:resizing", this._handleObjectResizing), e.on("object:modified", this.scalingController.handleObjectModified), e.on("mouse:move", this.scalingController.handleMouseMove), e.on("text:editing:entered", this._handleTextEditingEntered), e.on("text:editing:exited", this._handleTextEditingExited), e.on("text:changed", this._handleTextChanged);
11405
11416
  }
11406
- _syncLineStylesWithText({ textbox: e, previousText: t, currentText: n }) {
11417
+ syncLineStylesWithText({ textbox: e, previousText: t, currentText: n }) {
11407
11418
  let r = n ?? e.text ?? "", i = Xi({
11408
11419
  textbox: e,
11409
11420
  previousText: t ?? e.__lineDefaultsPrevText ?? r,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anu3ev/fabric-image-editor",
3
- "version": "0.8.23",
3
+ "version": "0.8.25",
4
4
  "description": "TypeScript image editor library built on FabricJS, allowing you to create instances with an integrated montage area and providing an API to modify and manage state.",
5
5
  "module": "dist/main.js",
6
6
  "files": [