@anu3ev/fabric-image-editor 0.6.14 → 0.6.15
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.
- package/dist/main.js +928 -755
- package/dist/stats.html +1 -1
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -243,7 +243,7 @@ function N(e) {
|
|
|
243
243
|
}
|
|
244
244
|
//#endregion
|
|
245
245
|
//#region src/editor/worker-manager/index.ts
|
|
246
|
-
var
|
|
246
|
+
var ee = class {
|
|
247
247
|
constructor(e) {
|
|
248
248
|
e ? this.worker = new Worker(e, { type: "module" }) : this.worker = new N(), this._callbacks = /* @__PURE__ */ new Map(), this.worker.onmessage = this._handleMessage.bind(this);
|
|
249
249
|
}
|
|
@@ -271,26 +271,26 @@ var P = class {
|
|
|
271
271
|
terminate() {
|
|
272
272
|
this.worker.terminate();
|
|
273
273
|
}
|
|
274
|
-
},
|
|
274
|
+
}, P = "#2B2D33", F = "#3D8BF4", I = "#FFFFFF";
|
|
275
275
|
//#endregion
|
|
276
276
|
//#region src/editor/customized-controls/renderers.ts
|
|
277
277
|
function L(e, t, n, r, i) {
|
|
278
|
-
e.save(), e.translate(t, n), e.rotate(C.degreesToRadians(i.angle)), e.fillStyle = I, e.strokeStyle =
|
|
278
|
+
e.save(), e.translate(t, n), e.rotate(C.degreesToRadians(i.angle)), e.fillStyle = I, e.strokeStyle = F, e.lineWidth = 1, e.beginPath(), e.roundRect(-12 / 2, -12 / 2, 12, 12, 2), e.fill(), e.stroke(), e.restore();
|
|
279
279
|
}
|
|
280
280
|
function te(e, t, n, r, i) {
|
|
281
|
-
e.save(), e.translate(t, n), e.rotate(C.degreesToRadians(i.angle)), e.fillStyle = I, e.strokeStyle =
|
|
281
|
+
e.save(), e.translate(t, n), e.rotate(C.degreesToRadians(i.angle)), e.fillStyle = I, e.strokeStyle = F, e.lineWidth = 1, e.beginPath(), e.roundRect(-8 / 2, -20 / 2, 8, 20, 100), e.fill(), e.stroke(), e.restore();
|
|
282
282
|
}
|
|
283
283
|
function R(e, t, n, r, i) {
|
|
284
|
-
e.save(), e.translate(t, n), e.rotate(C.degreesToRadians(i.angle)), e.fillStyle = I, e.strokeStyle =
|
|
284
|
+
e.save(), e.translate(t, n), e.rotate(C.degreesToRadians(i.angle)), e.fillStyle = I, e.strokeStyle = F, e.lineWidth = 1, e.beginPath(), e.roundRect(-20 / 2, -8 / 2, 20, 8, 100), e.fill(), e.stroke(), e.restore();
|
|
285
285
|
}
|
|
286
286
|
var z = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTE4Ljc1IDQuMzc1djMuNzVhLjYyNS42MjUgMCAwIDEtLjYyNS42MjVoLTMuNzVhLjYyNS42MjUgMCAwIDEgMC0xLjI1aDIuMTRsLTIuMDc3LTEuOTAzLS4wMi0uMDE5YTYuMjUgNi4yNSAwIDEgMC0uMTMgOC45NjcuNjI2LjYyNiAwIDAgMSAuODYuOTA5QTcuNDU2IDcuNDU2IDAgMCAxIDEwIDE3LjVoLS4xMDNhNy41IDcuNSAwIDEgMSA1LjM5Ni0xMi44MTJMMTcuNSA2LjcwM1Y0LjM3NWEuNjI1LjYyNSAwIDAgMSAxLjI1IDBaIi8+PC9zdmc+", ne = new Image();
|
|
287
287
|
ne.src = z;
|
|
288
|
-
function
|
|
289
|
-
e.save(), e.translate(t, n), e.rotate(C.degreesToRadians(i.angle)), e.fillStyle =
|
|
288
|
+
function B(e, t, n, r, i) {
|
|
289
|
+
e.save(), e.translate(t, n), e.rotate(C.degreesToRadians(i.angle)), e.fillStyle = P, e.beginPath(), e.arc(0, 0, 16, 0, 2 * Math.PI), e.fill(), e.drawImage(ne, -16 / 2, -16 / 2, 16, 16), e.restore();
|
|
290
290
|
}
|
|
291
291
|
//#endregion
|
|
292
292
|
//#region src/editor/customized-controls/default-controls.ts
|
|
293
|
-
var
|
|
293
|
+
var re = {
|
|
294
294
|
tl: {
|
|
295
295
|
render: L,
|
|
296
296
|
sizeX: 12,
|
|
@@ -348,13 +348,13 @@ var ie = {
|
|
|
348
348
|
offsetY: 0
|
|
349
349
|
},
|
|
350
350
|
mtr: {
|
|
351
|
-
render:
|
|
351
|
+
render: B,
|
|
352
352
|
sizeX: 32,
|
|
353
353
|
sizeY: 32,
|
|
354
354
|
offsetX: 0,
|
|
355
355
|
offsetY: -32
|
|
356
356
|
}
|
|
357
|
-
},
|
|
357
|
+
}, V = class t {
|
|
358
358
|
static wrapWidthControl(e) {
|
|
359
359
|
if (!(e != null && e.actionHandler)) return;
|
|
360
360
|
let t = e.actionHandler;
|
|
@@ -364,7 +364,7 @@ var ie = {
|
|
|
364
364
|
};
|
|
365
365
|
}
|
|
366
366
|
static applyControlOverrides(e) {
|
|
367
|
-
Object.entries(
|
|
367
|
+
Object.entries(re).forEach(([t, n]) => {
|
|
368
368
|
let r = e[t];
|
|
369
369
|
r && (Object.assign(r, n), t === "mtr" && (r.cursorStyle = "grab", r.mouseDownHandler = (e, t, n, r) => {
|
|
370
370
|
var i;
|
|
@@ -457,7 +457,7 @@ var ie = {
|
|
|
457
457
|
mr: !0
|
|
458
458
|
});
|
|
459
459
|
}
|
|
460
|
-
},
|
|
460
|
+
}, ie, ae = class e {
|
|
461
461
|
constructor(e = []) {
|
|
462
462
|
this.fonts = e;
|
|
463
463
|
}
|
|
@@ -608,7 +608,7 @@ var ie = {
|
|
|
608
608
|
});
|
|
609
609
|
}
|
|
610
610
|
};
|
|
611
|
-
|
|
611
|
+
ie = ae, ie.registeredFontKeys = /* @__PURE__ */ new Set(), ie.descriptorDefaults = {
|
|
612
612
|
style: "normal",
|
|
613
613
|
weight: "normal",
|
|
614
614
|
stretch: "normal",
|
|
@@ -619,7 +619,7 @@ ae = oe, ae.registeredFontKeys = /* @__PURE__ */ new Set(), ae.descriptorDefault
|
|
|
619
619
|
};
|
|
620
620
|
//#endregion
|
|
621
621
|
//#region src/editor/ui/toolbar-manager/default-config.ts
|
|
622
|
-
var
|
|
622
|
+
var oe = {
|
|
623
623
|
style: {
|
|
624
624
|
position: "absolute",
|
|
625
625
|
display: "none",
|
|
@@ -729,36 +729,36 @@ var se = {
|
|
|
729
729
|
};
|
|
730
730
|
//#endregion
|
|
731
731
|
//#region \0@oxc-project+runtime@0.120.0/helpers/typeof.js
|
|
732
|
-
function
|
|
732
|
+
function H(e) {
|
|
733
733
|
"@babel/helpers - typeof";
|
|
734
|
-
return
|
|
734
|
+
return H = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e) {
|
|
735
735
|
return typeof e;
|
|
736
736
|
} : function(e) {
|
|
737
737
|
return e && typeof Symbol == "function" && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
|
|
738
|
-
},
|
|
738
|
+
}, H(e);
|
|
739
739
|
}
|
|
740
740
|
//#endregion
|
|
741
741
|
//#region \0@oxc-project+runtime@0.120.0/helpers/toPrimitive.js
|
|
742
|
-
function
|
|
743
|
-
if (
|
|
742
|
+
function se(e, t) {
|
|
743
|
+
if (H(e) != "object" || !e) return e;
|
|
744
744
|
var n = e[Symbol.toPrimitive];
|
|
745
745
|
if (n !== void 0) {
|
|
746
746
|
var r = n.call(e, t || "default");
|
|
747
|
-
if (
|
|
747
|
+
if (H(r) != "object") return r;
|
|
748
748
|
throw TypeError("@@toPrimitive must return a primitive value.");
|
|
749
749
|
}
|
|
750
750
|
return (t === "string" ? String : Number)(e);
|
|
751
751
|
}
|
|
752
752
|
//#endregion
|
|
753
753
|
//#region \0@oxc-project+runtime@0.120.0/helpers/toPropertyKey.js
|
|
754
|
-
function
|
|
755
|
-
var t =
|
|
756
|
-
return
|
|
754
|
+
function ce(e) {
|
|
755
|
+
var t = se(e, "string");
|
|
756
|
+
return H(t) == "symbol" ? t : t + "";
|
|
757
757
|
}
|
|
758
758
|
//#endregion
|
|
759
759
|
//#region \0@oxc-project+runtime@0.120.0/helpers/defineProperty.js
|
|
760
|
-
function
|
|
761
|
-
return (t =
|
|
760
|
+
function le(e, t, n) {
|
|
761
|
+
return (t = ce(t)) in e ? Object.defineProperty(e, t, {
|
|
762
762
|
value: n,
|
|
763
763
|
enumerable: !0,
|
|
764
764
|
configurable: !0,
|
|
@@ -767,7 +767,7 @@ function ue(e, t, n) {
|
|
|
767
767
|
}
|
|
768
768
|
//#endregion
|
|
769
769
|
//#region \0@oxc-project+runtime@0.120.0/helpers/objectSpread2.js
|
|
770
|
-
function
|
|
770
|
+
function ue(e, t) {
|
|
771
771
|
var n = Object.keys(e);
|
|
772
772
|
if (Object.getOwnPropertySymbols) {
|
|
773
773
|
var r = Object.getOwnPropertySymbols(e);
|
|
@@ -777,12 +777,12 @@ function de(e, t) {
|
|
|
777
777
|
}
|
|
778
778
|
return n;
|
|
779
779
|
}
|
|
780
|
-
function
|
|
780
|
+
function U(e) {
|
|
781
781
|
for (var t = 1; t < arguments.length; t++) {
|
|
782
782
|
var n = arguments[t] == null ? {} : arguments[t];
|
|
783
|
-
t % 2 ?
|
|
784
|
-
|
|
785
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n)) :
|
|
783
|
+
t % 2 ? ue(Object(n), !0).forEach(function(t) {
|
|
784
|
+
le(e, t, n[t]);
|
|
785
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n)) : ue(Object(n)).forEach(function(t) {
|
|
786
786
|
Object.defineProperty(e, t, Object.getOwnPropertyDescriptor(n, t));
|
|
787
787
|
});
|
|
788
788
|
}
|
|
@@ -790,18 +790,18 @@ function H(e) {
|
|
|
790
790
|
}
|
|
791
791
|
//#endregion
|
|
792
792
|
//#region src/editor/ui/toolbar-manager/index.ts
|
|
793
|
-
var
|
|
793
|
+
var W = class {
|
|
794
794
|
constructor({ editor: e }) {
|
|
795
795
|
this.currentTarget = null, this.currentLocked = !1, this.isTransforming = !1, this.isTemporarilyHidden = !1, this.editor = e, this.canvas = e.canvas, this.options = e.options, this._initToolbar();
|
|
796
796
|
}
|
|
797
797
|
_initToolbar() {
|
|
798
798
|
if (!this.options.showToolbar) return;
|
|
799
799
|
let e = this.options.toolbar || {};
|
|
800
|
-
this.config =
|
|
801
|
-
style:
|
|
802
|
-
btnStyle:
|
|
803
|
-
icons:
|
|
804
|
-
handlers:
|
|
800
|
+
this.config = U(U(U({}, oe), e), {}, {
|
|
801
|
+
style: U(U({}, oe.style), e.style || {}),
|
|
802
|
+
btnStyle: U(U({}, oe.btnStyle), e.btnStyle || {}),
|
|
803
|
+
icons: U(U({}, oe.icons), e.icons || {}),
|
|
804
|
+
handlers: U(U({}, oe.handlers), e.handlers || {})
|
|
805
805
|
}), this.currentTarget = null, this.currentLocked = !1, this.isTransforming = !1, this.isTemporarilyHidden = !1, this._onMouseDown = this._handleMouseDown.bind(this), this._onObjectMoving = this._startTransform.bind(this), this._onObjectScaling = this._startTransform.bind(this), this._onObjectRotating = this._startTransform.bind(this), this._onMouseUp = this._endTransform.bind(this), this._onObjectModified = this._endTransform.bind(this), this._onSelectionChange = this._updateToolbar.bind(this), this._onSelectionClear = () => {
|
|
806
806
|
this.el.style.display = "none";
|
|
807
807
|
}, this._createDOM(), this._bindEvents();
|
|
@@ -881,7 +881,7 @@ var U = class {
|
|
|
881
881
|
destroy() {
|
|
882
882
|
this.el.removeEventListener("mouseover", this._onBtnOver), this.el.removeEventListener("mouseout", this._onBtnOut), this.canvas.off("mouse:down", this._onMouseDown), this.canvas.off("object:moving", this._onObjectMoving), this.canvas.off("object:scaling", this._onObjectScaling), this.canvas.off("object:rotating", this._onObjectRotating), this.canvas.off("mouse:up", this._onMouseUp), this.canvas.off("object:modified", this._onObjectModified), this.canvas.off("selection:created", this._onSelectionChange), this.canvas.off("selection:updated", this._onSelectionChange), this.canvas.off("after:render", this._onSelectionChange), this.canvas.off("selection:cleared", this._onSelectionClear), this.el.remove();
|
|
883
883
|
}
|
|
884
|
-
},
|
|
884
|
+
}, de = {
|
|
885
885
|
position: "absolute",
|
|
886
886
|
display: "none",
|
|
887
887
|
background: "#2B2D33",
|
|
@@ -900,7 +900,7 @@ var U = class {
|
|
|
900
900
|
this.isActive = !1, this.currentAngle = 0, this.editor = e, this.canvas = e.canvas, this.options = e.options, this._createDOM(), this._bindEvents();
|
|
901
901
|
}
|
|
902
902
|
_createDOM() {
|
|
903
|
-
this.el = document.createElement("div"), this.el.className = fe, Object.entries(
|
|
903
|
+
this.el = document.createElement("div"), this.el.className = fe, Object.entries(de).forEach(([e, t]) => {
|
|
904
904
|
this.el.style.setProperty(e, t);
|
|
905
905
|
}), this.canvas.wrapperEl.appendChild(this.el);
|
|
906
906
|
}
|
|
@@ -946,7 +946,7 @@ var U = class {
|
|
|
946
946
|
var e;
|
|
947
947
|
this.canvas && (this.canvas.off("object:rotating", this._onObjectRotating), this.canvas.off("mouse:up", this._onMouseUp), this.canvas.off("object:modified", this._onObjectModified), this.canvas.off("selection:cleared", this._onSelectionCleared)), (e = this.el) != null && e.parentNode && this.el.parentNode.removeChild(this.el), this.el = null, this.editor = null, this.canvas = null, this.options = null;
|
|
948
948
|
}
|
|
949
|
-
}, me = /* @__PURE__ */ "id.backgroundId.customData.backgroundType.format.contentType.width.height.locked.editable.evented.selectable.lockMovementX.lockMovementY.lockRotation.lockScalingX.lockScalingY.lockSkewingX.lockSkewingY.styles.lineFontDefaults.textCaseRaw.uppercase.autoExpand.linethrough.underline.fontStyle.fontWeight.backgroundOpacity.paddingTop.paddingRight.paddingBottom.paddingLeft.radiusTopLeft.radiusTopRight.radiusBottomRight.radiusBottomLeft.shapeComposite.shapePresetKey.shapeBaseWidth.shapeBaseHeight.shapeManualBaseWidth.shapeManualBaseHeight.shapeAlignHorizontal.shapeAlignVertical.shapePaddingTop.shapePaddingRight.shapePaddingBottom.shapePaddingLeft.shapeFill.shapeStroke.shapeStrokeWidth.shapeStrokeDashArray.shapeOpacity.shapeRounding.shapeNodeType".split(".");
|
|
949
|
+
}, me = /* @__PURE__ */ "id.backgroundId.customData.backgroundType.format.contentType.width.height.locked.editable.evented.selectable.lockMovementX.lockMovementY.lockRotation.lockScalingX.lockScalingY.lockSkewingX.lockSkewingY.styles.lineFontDefaults.textCaseRaw.uppercase.autoExpand.linethrough.underline.fontStyle.fontWeight.backgroundOpacity.paddingTop.paddingRight.paddingBottom.paddingLeft.radiusTopLeft.radiusTopRight.radiusBottomRight.radiusBottomLeft.shapeComposite.shapePresetKey.shapeBaseWidth.shapeBaseHeight.shapeManualBaseWidth.shapeManualBaseHeight.shapeTextAutoExpand.shapeAlignHorizontal.shapeAlignVertical.shapePaddingTop.shapePaddingRight.shapePaddingBottom.shapePaddingLeft.shapeFill.shapeStroke.shapeStrokeWidth.shapeStrokeDashArray.shapeOpacity.shapeRounding.shapeNodeType".split(".");
|
|
950
950
|
//#endregion
|
|
951
951
|
//#region src/editor/history-manager/diff-normalization.ts
|
|
952
952
|
function he({ state: e }) {
|
|
@@ -1438,7 +1438,7 @@ var Ue = class {
|
|
|
1438
1438
|
}
|
|
1439
1439
|
})();
|
|
1440
1440
|
}
|
|
1441
|
-
}, We = .1, Ge = 4096, Ke = 4096, qe = "application/image-editor:", Je = /* @__PURE__ */ "customData.backgroundType.format.contentType.width.height.locked.editable.evented.selectable.lockMovementX.lockMovementY.lockRotation.lockScalingX.lockScalingY.lockSkewingX.lockSkewingY.styles.lineFontDefaults.textCaseRaw.uppercase.autoExpand.linethrough.underline.fontStyle.fontWeight.backgroundOpacity.paddingTop.paddingRight.paddingBottom.paddingLeft.radiusTopLeft.radiusTopRight.radiusBottomRight.radiusBottomLeft.shapeComposite.shapePresetKey.shapeBaseWidth.shapeBaseHeight.shapeManualBaseWidth.shapeManualBaseHeight.shapeAlignHorizontal.shapeAlignVertical.shapePaddingTop.shapePaddingRight.shapePaddingBottom.shapePaddingLeft.shapeFill.shapeStroke.shapeStrokeWidth.shapeStrokeDashArray.shapeOpacity.shapeRounding.shapeNodeType".split("."), Ye = class e {
|
|
1441
|
+
}, We = .1, Ge = 4096, Ke = 4096, qe = "application/image-editor:", Je = /* @__PURE__ */ "customData.backgroundType.format.contentType.width.height.locked.editable.evented.selectable.lockMovementX.lockMovementY.lockRotation.lockScalingX.lockScalingY.lockSkewingX.lockSkewingY.styles.lineFontDefaults.textCaseRaw.uppercase.autoExpand.linethrough.underline.fontStyle.fontWeight.backgroundOpacity.paddingTop.paddingRight.paddingBottom.paddingLeft.radiusTopLeft.radiusTopRight.radiusBottomRight.radiusBottomLeft.shapeComposite.shapePresetKey.shapeBaseWidth.shapeBaseHeight.shapeManualBaseWidth.shapeManualBaseHeight.shapeTextAutoExpand.shapeAlignHorizontal.shapeAlignVertical.shapePaddingTop.shapePaddingRight.shapePaddingBottom.shapePaddingLeft.shapeFill.shapeStroke.shapeStrokeWidth.shapeStrokeDashArray.shapeOpacity.shapeRounding.shapeNodeType".split("."), Ye = class e {
|
|
1442
1442
|
constructor({ editor: e }) {
|
|
1443
1443
|
this.editor = e, this.options = e.options, this._createdBlobUrls = [], this.acceptContentTypes = this.editor.options.acceptContentTypes, this.acceptFormats = this.getAllowedFormatsFromContentTypes();
|
|
1444
1444
|
}
|
|
@@ -2531,7 +2531,7 @@ var pt = ({ canvas: e, options: t = {}, flags: n = {} }) => {
|
|
|
2531
2531
|
let { id: r = `rect-${D()}`, left: i, top: a, width: o = 100, height: s = 100, fill: c = "blue" } = t, l = ut(t, dt);
|
|
2532
2532
|
return ft({
|
|
2533
2533
|
canvas: e,
|
|
2534
|
-
object: new g(
|
|
2534
|
+
object: new g(U({
|
|
2535
2535
|
id: r,
|
|
2536
2536
|
left: i,
|
|
2537
2537
|
top: a,
|
|
@@ -3967,10 +3967,10 @@ function Qt() {
|
|
|
3967
3967
|
//#region src/editor/shape-manager/shape-layout.ts
|
|
3968
3968
|
var J = 1, $t = .5, en = 12, tn = 12, nn = .45, rn = 8, an = 8, on = ({ group: e, shape: t, text: n, width: r, height: i, alignH: a, alignV: o, padding: s }) => {
|
|
3969
3969
|
var c, l;
|
|
3970
|
-
let u =
|
|
3970
|
+
let u = pn({ padding: s }), d = Math.max(J, (c = e.shapeManualBaseWidth) == null ? r : c), f = Math.max(J, (l = e.shapeManualBaseHeight) == null ? i : l), p = cn({
|
|
3971
3971
|
text: n,
|
|
3972
3972
|
padding: u
|
|
3973
|
-
}), m = Math.max(J, r, p), h =
|
|
3973
|
+
}), m = Math.max(J, r, p), h = un({
|
|
3974
3974
|
text: n,
|
|
3975
3975
|
width: m,
|
|
3976
3976
|
height: i,
|
|
@@ -3983,7 +3983,7 @@ var J = 1, $t = .5, en = 12, tn = 12, nn = .45, rn = 8, an = 8, on = ({ group: e
|
|
|
3983
3983
|
rounding: e.shapeRounding,
|
|
3984
3984
|
strokeWidth: e.shapeStrokeWidth
|
|
3985
3985
|
});
|
|
3986
|
-
let { frame: _, splitByGrapheme: v, textTop: y } =
|
|
3986
|
+
let { frame: _, splitByGrapheme: v, textTop: y } = ln({
|
|
3987
3987
|
text: n,
|
|
3988
3988
|
width: m,
|
|
3989
3989
|
height: g,
|
|
@@ -4012,22 +4012,56 @@ var J = 1, $t = .5, en = 12, tn = 12, nn = .45, rn = 8, an = 8, on = ({ group: e
|
|
|
4012
4012
|
scaleX: 1,
|
|
4013
4013
|
scaleY: 1
|
|
4014
4014
|
}), e.set("dirty", !0), e.setCoords();
|
|
4015
|
-
}, sn = ({ text: e,
|
|
4016
|
-
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
|
|
4015
|
+
}, sn = ({ text: e, currentWidth: t, minimumWidth: n, padding: r, strokeWidth: i, montageAreaWidth: a }) => {
|
|
4016
|
+
let o = Math.max(J, t), s = Math.max(J, n);
|
|
4017
|
+
if (!mn({ text: e })) return s;
|
|
4018
|
+
let c = Number.isFinite(a) && a > 0 ? Math.max(J, a) : Math.max(o, s), l = Math.max(0, i == null ? 0 : i), u = Math.max(s, c);
|
|
4019
|
+
if (l >= u) return Math.max(o, s);
|
|
4020
|
+
let d = pn({ padding: r }), f = u, p = yn({
|
|
4021
|
+
text: e,
|
|
4022
|
+
frameWidth: _n({
|
|
4023
|
+
width: f,
|
|
4024
|
+
padding: d
|
|
4025
|
+
})
|
|
4026
|
+
});
|
|
4027
|
+
if (p.hasWrappedLines) return f;
|
|
4028
|
+
let m = Math.max(J, p.longestLineWidth), h = Math.min(f, Math.max(s, dn({
|
|
4029
|
+
frameWidth: m,
|
|
4030
|
+
padding: d
|
|
4031
|
+
})));
|
|
4032
|
+
for (let t = 0; t < rn; t += 1) {
|
|
4033
|
+
let t = _n({
|
|
4034
|
+
width: h,
|
|
4035
|
+
padding: d
|
|
4036
|
+
}), n = yn({
|
|
4037
|
+
text: e,
|
|
4038
|
+
frameWidth: t
|
|
4039
|
+
}), r = t >= m - $t;
|
|
4040
|
+
if (!n.hasWrappedLines && r) return h;
|
|
4041
|
+
if (h >= f - $t) return f;
|
|
4042
|
+
let i = n.hasWrappedLines ? Math.max(m + 1, t + 1) : m;
|
|
4043
|
+
h = Math.min(f, Math.max(h + 1, dn({
|
|
4044
|
+
frameWidth: i,
|
|
4045
|
+
padding: d
|
|
4046
|
+
})));
|
|
4047
|
+
}
|
|
4048
|
+
return h;
|
|
4049
|
+
}, cn = ({ text: e, padding: t }) => {
|
|
4050
|
+
if (!mn({ text: e })) return J;
|
|
4051
|
+
let n = pn({ padding: t });
|
|
4052
|
+
return dn({
|
|
4053
|
+
frameWidth: xn({ text: e }),
|
|
4020
4054
|
padding: n
|
|
4021
4055
|
});
|
|
4022
|
-
},
|
|
4023
|
-
let a =
|
|
4056
|
+
}, ln = ({ text: e, width: t, height: n, alignV: r, padding: i }) => {
|
|
4057
|
+
let a = gn({
|
|
4024
4058
|
width: Math.max(J, t),
|
|
4025
4059
|
height: Math.max(J, n),
|
|
4026
|
-
padding:
|
|
4027
|
-
}), o =
|
|
4060
|
+
padding: pn({ padding: i })
|
|
4061
|
+
}), o = Tn({
|
|
4028
4062
|
text: e,
|
|
4029
4063
|
frameWidth: a.width
|
|
4030
|
-
}), s =
|
|
4064
|
+
}), s = bn({
|
|
4031
4065
|
text: e,
|
|
4032
4066
|
frameWidth: a.width,
|
|
4033
4067
|
splitByGrapheme: o
|
|
@@ -4035,23 +4069,23 @@ var J = 1, $t = .5, en = 12, tn = 12, nn = .45, rn = 8, an = 8, on = ({ group: e
|
|
|
4035
4069
|
return {
|
|
4036
4070
|
frame: a,
|
|
4037
4071
|
splitByGrapheme: o,
|
|
4038
|
-
textTop:
|
|
4072
|
+
textTop: Cn({
|
|
4039
4073
|
alignV: r,
|
|
4040
4074
|
frameHeight: a.height,
|
|
4041
4075
|
frameTop: a.top,
|
|
4042
4076
|
textHeight: s
|
|
4043
4077
|
})
|
|
4044
4078
|
};
|
|
4045
|
-
},
|
|
4079
|
+
}, un = ({ text: e, width: t, height: n, padding: r }) => {
|
|
4046
4080
|
let i = Math.max(J, n);
|
|
4047
|
-
if (!
|
|
4048
|
-
let a = Math.max(J, t), o =
|
|
4081
|
+
if (!mn({ text: e })) return i;
|
|
4082
|
+
let a = Math.max(J, t), o = pn({ padding: r }), s = i;
|
|
4049
4083
|
for (let t = 0; t < an; t += 1) {
|
|
4050
|
-
let t =
|
|
4084
|
+
let t = gn({
|
|
4051
4085
|
width: a,
|
|
4052
4086
|
height: s,
|
|
4053
4087
|
padding: o
|
|
4054
|
-
}), n =
|
|
4088
|
+
}), n = bn({
|
|
4055
4089
|
text: e,
|
|
4056
4090
|
frameWidth: t.width
|
|
4057
4091
|
});
|
|
@@ -4061,10 +4095,10 @@ var J = 1, $t = .5, en = 12, tn = 12, nn = .45, rn = 8, an = 8, on = ({ group: e
|
|
|
4061
4095
|
}
|
|
4062
4096
|
return s;
|
|
4063
4097
|
};
|
|
4064
|
-
function
|
|
4098
|
+
function dn({ frameWidth: e, padding: t }) {
|
|
4065
4099
|
let n = Math.max(J, e), r = n;
|
|
4066
4100
|
for (let e = 0; e < rn; e += 1) {
|
|
4067
|
-
let e =
|
|
4101
|
+
let e = _n({
|
|
4068
4102
|
width: r,
|
|
4069
4103
|
padding: t
|
|
4070
4104
|
});
|
|
@@ -4074,38 +4108,38 @@ function un({ frameWidth: e, padding: t }) {
|
|
|
4074
4108
|
}
|
|
4075
4109
|
return r;
|
|
4076
4110
|
}
|
|
4077
|
-
function
|
|
4111
|
+
function fn({ left: e, top: t, canvasCenter: n }) {
|
|
4078
4112
|
return typeof e == "number" && typeof t == "number" ? new p(e, t) : n;
|
|
4079
4113
|
}
|
|
4080
|
-
function
|
|
4114
|
+
function pn({ padding: e }) {
|
|
4081
4115
|
return {
|
|
4082
|
-
top:
|
|
4083
|
-
right:
|
|
4084
|
-
bottom:
|
|
4085
|
-
left:
|
|
4116
|
+
top: hn({ value: e.top }),
|
|
4117
|
+
right: hn({ value: e.right }),
|
|
4118
|
+
bottom: hn({ value: e.bottom }),
|
|
4119
|
+
left: hn({ value: e.left })
|
|
4086
4120
|
};
|
|
4087
4121
|
}
|
|
4088
|
-
function
|
|
4122
|
+
function mn({ text: e }) {
|
|
4089
4123
|
var t;
|
|
4090
4124
|
return ((t = e.text) == null ? "" : t).trim().length > 0;
|
|
4091
4125
|
}
|
|
4092
|
-
function
|
|
4126
|
+
function hn({ value: e }) {
|
|
4093
4127
|
return Math.min(Math.max(e, 0), nn);
|
|
4094
4128
|
}
|
|
4095
|
-
function
|
|
4096
|
-
let r =
|
|
4129
|
+
function gn({ width: e, height: t, padding: n }) {
|
|
4130
|
+
let r = wn({
|
|
4097
4131
|
size: e,
|
|
4098
4132
|
ratio: n.left,
|
|
4099
4133
|
axis: "horizontal"
|
|
4100
|
-
}), i =
|
|
4134
|
+
}), i = wn({
|
|
4101
4135
|
size: e,
|
|
4102
4136
|
ratio: n.right,
|
|
4103
4137
|
axis: "horizontal"
|
|
4104
|
-
}), a =
|
|
4138
|
+
}), a = wn({
|
|
4105
4139
|
size: t,
|
|
4106
4140
|
ratio: n.top,
|
|
4107
4141
|
axis: "vertical"
|
|
4108
|
-
}), o =
|
|
4142
|
+
}), o = wn({
|
|
4109
4143
|
size: t,
|
|
4110
4144
|
ratio: n.bottom,
|
|
4111
4145
|
axis: "vertical"
|
|
@@ -4117,19 +4151,19 @@ function hn({ width: e, height: t, padding: n }) {
|
|
|
4117
4151
|
height: Math.max(J, t - a - o)
|
|
4118
4152
|
};
|
|
4119
4153
|
}
|
|
4120
|
-
function
|
|
4121
|
-
let n =
|
|
4154
|
+
function _n({ width: e, padding: t }) {
|
|
4155
|
+
let n = wn({
|
|
4122
4156
|
size: e,
|
|
4123
4157
|
ratio: t.left,
|
|
4124
4158
|
axis: "horizontal"
|
|
4125
|
-
}), r =
|
|
4159
|
+
}), r = wn({
|
|
4126
4160
|
size: e,
|
|
4127
4161
|
ratio: t.right,
|
|
4128
4162
|
axis: "horizontal"
|
|
4129
4163
|
});
|
|
4130
4164
|
return Math.max(J, e - n - r);
|
|
4131
4165
|
}
|
|
4132
|
-
function
|
|
4166
|
+
function vn({ text: e }) {
|
|
4133
4167
|
let { height: t } = e;
|
|
4134
4168
|
if (typeof t == "number" && Number.isFinite(t)) return t;
|
|
4135
4169
|
if (typeof e.calcTextHeight == "function") {
|
|
@@ -4138,8 +4172,27 @@ function _n({ text: e }) {
|
|
|
4138
4172
|
}
|
|
4139
4173
|
return J;
|
|
4140
4174
|
}
|
|
4141
|
-
function
|
|
4142
|
-
let
|
|
4175
|
+
function yn({ text: e, frameWidth: t }) {
|
|
4176
|
+
let n = Dn({ text: e }), r = Tn({
|
|
4177
|
+
text: e,
|
|
4178
|
+
frameWidth: t
|
|
4179
|
+
}), i = An({ text: e });
|
|
4180
|
+
e.set({
|
|
4181
|
+
autoExpand: !1,
|
|
4182
|
+
width: Math.max(J, t),
|
|
4183
|
+
splitByGrapheme: r
|
|
4184
|
+
}), e.initDimensions();
|
|
4185
|
+
let a = On({ text: e }) > n, o = Math.ceil(En({ text: e }));
|
|
4186
|
+
return jn({
|
|
4187
|
+
text: e,
|
|
4188
|
+
state: i
|
|
4189
|
+
}), {
|
|
4190
|
+
hasWrappedLines: a,
|
|
4191
|
+
longestLineWidth: o
|
|
4192
|
+
};
|
|
4193
|
+
}
|
|
4194
|
+
function bn({ text: e, frameWidth: t, splitByGrapheme: n }) {
|
|
4195
|
+
let r = An({ text: e }), i = n == null ? Tn({
|
|
4143
4196
|
text: e,
|
|
4144
4197
|
frameWidth: t
|
|
4145
4198
|
}) : n;
|
|
@@ -4148,68 +4201,77 @@ function vn({ text: e, frameWidth: t, splitByGrapheme: n }) {
|
|
|
4148
4201
|
width: Math.max(J, t),
|
|
4149
4202
|
splitByGrapheme: i
|
|
4150
4203
|
}), e.initDimensions();
|
|
4151
|
-
let a =
|
|
4152
|
-
return
|
|
4204
|
+
let a = vn({ text: e });
|
|
4205
|
+
return jn({
|
|
4153
4206
|
text: e,
|
|
4154
4207
|
state: r
|
|
4155
4208
|
}), a;
|
|
4156
4209
|
}
|
|
4157
|
-
function
|
|
4158
|
-
let t =
|
|
4210
|
+
function xn({ text: e }) {
|
|
4211
|
+
let t = Sn({
|
|
4159
4212
|
text: e,
|
|
4160
4213
|
frameWidth: J,
|
|
4161
4214
|
splitByGrapheme: !0
|
|
4162
4215
|
});
|
|
4163
4216
|
return Math.max(J, t);
|
|
4164
4217
|
}
|
|
4165
|
-
function
|
|
4166
|
-
let r =
|
|
4218
|
+
function Sn({ text: e, frameWidth: t, splitByGrapheme: n }) {
|
|
4219
|
+
let r = An({ text: e });
|
|
4167
4220
|
e.set({
|
|
4168
4221
|
autoExpand: !1,
|
|
4169
4222
|
width: Math.max(J, t),
|
|
4170
4223
|
splitByGrapheme: n
|
|
4171
4224
|
}), e.initDimensions();
|
|
4172
|
-
let i =
|
|
4173
|
-
return
|
|
4225
|
+
let i = En({ text: e });
|
|
4226
|
+
return jn({
|
|
4174
4227
|
text: e,
|
|
4175
4228
|
state: r
|
|
4176
4229
|
}), i;
|
|
4177
4230
|
}
|
|
4178
|
-
function
|
|
4231
|
+
function Cn({ alignV: e, frameHeight: t, frameTop: n, textHeight: r }) {
|
|
4179
4232
|
let i = Math.max(0, t - r);
|
|
4180
4233
|
return e === "top" ? n : e === "bottom" ? n + i : n + i / 2;
|
|
4181
4234
|
}
|
|
4182
|
-
function
|
|
4235
|
+
function wn({ size: e, ratio: t, axis: n }) {
|
|
4183
4236
|
let r = n === "horizontal" ? en : tn, i = e * t;
|
|
4184
4237
|
return Math.max(0, Math.min(i, r));
|
|
4185
4238
|
}
|
|
4186
|
-
function
|
|
4187
|
-
let n = Math.max(J, t), r =
|
|
4239
|
+
function Tn({ text: e, frameWidth: t }) {
|
|
4240
|
+
let n = Math.max(J, t), r = An({ text: e });
|
|
4188
4241
|
e.set({
|
|
4189
4242
|
autoExpand: !1,
|
|
4190
4243
|
width: n,
|
|
4191
4244
|
splitByGrapheme: !1
|
|
4192
4245
|
}), e.initDimensions();
|
|
4193
|
-
let i =
|
|
4194
|
-
return
|
|
4246
|
+
let i = Mn({ text: e }) > n + $t;
|
|
4247
|
+
return jn({
|
|
4195
4248
|
text: e,
|
|
4196
4249
|
state: r
|
|
4197
4250
|
}), i;
|
|
4198
4251
|
}
|
|
4199
|
-
function
|
|
4252
|
+
function En({ text: e }) {
|
|
4200
4253
|
var t;
|
|
4201
|
-
let n = e;
|
|
4202
|
-
if (
|
|
4254
|
+
let n = On({ text: e });
|
|
4255
|
+
if (n > 0) return kn({
|
|
4203
4256
|
text: e,
|
|
4204
|
-
lineCount: n
|
|
4257
|
+
lineCount: n
|
|
4205
4258
|
});
|
|
4206
|
-
let r = (t =
|
|
4207
|
-
return
|
|
4259
|
+
let r = (t = e.text) == null ? "" : t;
|
|
4260
|
+
return kn({
|
|
4208
4261
|
text: e,
|
|
4209
4262
|
lineCount: Math.max(r.split("\n").length, 1)
|
|
4210
4263
|
});
|
|
4211
4264
|
}
|
|
4212
|
-
function
|
|
4265
|
+
function Dn({ text: e }) {
|
|
4266
|
+
var t;
|
|
4267
|
+
let n = (t = e.text) == null ? "" : t;
|
|
4268
|
+
return Math.max(n.split("\n").length, 1);
|
|
4269
|
+
}
|
|
4270
|
+
function On({ text: e }) {
|
|
4271
|
+
let t = e;
|
|
4272
|
+
return Array.isArray(t.textLines) ? t.textLines.length : 0;
|
|
4273
|
+
}
|
|
4274
|
+
function kn({ text: e, lineCount: t }) {
|
|
4213
4275
|
let n = J;
|
|
4214
4276
|
for (let r = 0; r < t; r += 1) {
|
|
4215
4277
|
let t = e.getLineWidth(r);
|
|
@@ -4217,7 +4279,7 @@ function Tn({ text: e, lineCount: t }) {
|
|
|
4217
4279
|
}
|
|
4218
4280
|
return n;
|
|
4219
4281
|
}
|
|
4220
|
-
function
|
|
4282
|
+
function An({ text: e }) {
|
|
4221
4283
|
let { autoExpand: t, splitByGrapheme: n, width: r } = e;
|
|
4222
4284
|
return {
|
|
4223
4285
|
autoExpand: t,
|
|
@@ -4225,32 +4287,33 @@ function En({ text: e }) {
|
|
|
4225
4287
|
width: typeof r == "number" ? r : void 0
|
|
4226
4288
|
};
|
|
4227
4289
|
}
|
|
4228
|
-
function
|
|
4290
|
+
function jn({ text: e, state: t }) {
|
|
4229
4291
|
let { autoExpand: n, splitByGrapheme: r, width: i } = t, a = {};
|
|
4230
4292
|
n !== void 0 && (a.autoExpand = n), r !== void 0 && (a.splitByGrapheme = r), typeof i == "number" && (a.width = i), Object.keys(a).length > 0 && (e.set(a), e.initDimensions());
|
|
4231
4293
|
}
|
|
4232
|
-
function
|
|
4294
|
+
function Mn({ text: e }) {
|
|
4233
4295
|
let { dynamicMinWidth: t } = e;
|
|
4234
4296
|
return typeof t == "number" && Number.isFinite(t) ? t : 0;
|
|
4235
4297
|
}
|
|
4236
4298
|
//#endregion
|
|
4237
4299
|
//#region src/editor/shape-manager/shape-runtime.ts
|
|
4238
|
-
var
|
|
4300
|
+
var Nn = ({ group: e }) => {
|
|
4239
4301
|
let t = e;
|
|
4240
4302
|
typeof t.setInteractive == "function" && t.setInteractive(!0), t.set({
|
|
4241
4303
|
interactive: !0,
|
|
4242
4304
|
subTargetCheck: !0
|
|
4243
4305
|
});
|
|
4244
|
-
},
|
|
4306
|
+
}, Pn = ({ text: e }) => {
|
|
4245
4307
|
e.set({
|
|
4246
4308
|
hasBorders: !1,
|
|
4247
4309
|
hasControls: !1,
|
|
4248
4310
|
evented: !1,
|
|
4249
4311
|
selectable: !1,
|
|
4250
4312
|
editable: !0,
|
|
4313
|
+
autoExpand: !1,
|
|
4251
4314
|
shapeNodeType: "text"
|
|
4252
4315
|
}), e.setCoords();
|
|
4253
|
-
},
|
|
4316
|
+
}, Fn = ({ group: e }) => {
|
|
4254
4317
|
let { layoutManager: t } = e;
|
|
4255
4318
|
if (!t || typeof t.unsubscribeTargets != "function") return;
|
|
4256
4319
|
let n = e.getObjects();
|
|
@@ -4258,7 +4321,7 @@ var kn = ({ group: e }) => {
|
|
|
4258
4321
|
target: e,
|
|
4259
4322
|
targets: n
|
|
4260
4323
|
});
|
|
4261
|
-
},
|
|
4324
|
+
}, In = ({ group: e }) => {
|
|
4262
4325
|
let t = e.getObjects();
|
|
4263
4326
|
for (let e = 0; e < t.length; e += 1) {
|
|
4264
4327
|
let n = t[e];
|
|
@@ -4269,23 +4332,23 @@ var kn = ({ group: e }) => {
|
|
|
4269
4332
|
if (n instanceof _) return n;
|
|
4270
4333
|
}
|
|
4271
4334
|
return null;
|
|
4272
|
-
},
|
|
4335
|
+
}, Ln = [
|
|
4273
4336
|
"tl",
|
|
4274
4337
|
"tr",
|
|
4275
4338
|
"bl",
|
|
4276
4339
|
"br"
|
|
4277
|
-
],
|
|
4340
|
+
], Rn = ({ transform: e }) => {
|
|
4278
4341
|
let { originX: t, originY: n } = e;
|
|
4279
4342
|
return (t === "center" || t === .5) && (n === "center" || n === .5);
|
|
4280
|
-
},
|
|
4343
|
+
}, zn = ({ transform: e, x: t, y: n }) => {
|
|
4281
4344
|
let r = e, { target: i } = r, { scaleX: a = 1, scaleY: o = 1 } = i, s = b.getLocalPoint(r, r.originX, r.originY, t, n), c = Math.sign(s.x || r.signX || 1), l = Math.sign(s.y || r.signY || 1);
|
|
4282
4345
|
r.signX === void 0 && (r.signX = c), r.signY === void 0 && (r.signY = l);
|
|
4283
4346
|
let u = i._getTransformedDimensions(), d = Math.abs(s.x * a / u.x), f = Math.abs(s.y * o / u.y);
|
|
4284
|
-
|
|
4347
|
+
Rn({ transform: r }) && (d *= 2, f *= 2);
|
|
4285
4348
|
let p = !i.lockScalingX && (!i.lockScalingFlip || r.signX === c), m = !i.lockScalingY && (!i.lockScalingFlip || r.signY === l);
|
|
4286
4349
|
return p && i.set("scaleX", d), m && i.set("scaleY", f), a !== i.scaleX || o !== i.scaleY;
|
|
4287
|
-
},
|
|
4288
|
-
let e = b.wrapWithFireEvent("scaling", b.wrapWithFixedAnchor((e, t, n, r) =>
|
|
4350
|
+
}, Bn = () => {
|
|
4351
|
+
let e = b.wrapWithFireEvent("scaling", b.wrapWithFixedAnchor((e, t, n, r) => zn({
|
|
4289
4352
|
transform: t,
|
|
4290
4353
|
x: n,
|
|
4291
4354
|
y: r
|
|
@@ -4301,38 +4364,38 @@ var kn = ({ group: e }) => {
|
|
|
4301
4364
|
a.uniformScaling = s;
|
|
4302
4365
|
}
|
|
4303
4366
|
};
|
|
4304
|
-
},
|
|
4305
|
-
let t = new r(
|
|
4367
|
+
}, Vn = ({ control: e }) => {
|
|
4368
|
+
let t = new r(U(U({}, e), {}, { actionHandler: Bn() }));
|
|
4306
4369
|
return t.shapeFreeScaleCornerControl = !0, t;
|
|
4307
|
-
},
|
|
4308
|
-
let t =
|
|
4309
|
-
|
|
4370
|
+
}, Hn = ({ group: e }) => {
|
|
4371
|
+
let t = U({}, e.controls);
|
|
4372
|
+
Ln.forEach((n) => {
|
|
4310
4373
|
let r = e.controls[n];
|
|
4311
|
-
r && (r.shapeFreeScaleCornerControl || (t[n] =
|
|
4374
|
+
r && (r.shapeFreeScaleCornerControl || (t[n] = Vn({ control: r })));
|
|
4312
4375
|
}), e.controls = t;
|
|
4313
|
-
},
|
|
4376
|
+
}, Un = [
|
|
4314
4377
|
"layoutManager",
|
|
4315
4378
|
"objectCaching",
|
|
4316
4379
|
"centeredScaling",
|
|
4317
4380
|
"lockScalingFlip"
|
|
4318
|
-
],
|
|
4381
|
+
], Wn = [
|
|
4319
4382
|
"type",
|
|
4320
4383
|
"objects",
|
|
4321
4384
|
"layoutManager"
|
|
4322
|
-
],
|
|
4323
|
-
function
|
|
4385
|
+
], Gn, Kn = "shape-group";
|
|
4386
|
+
function qn() {
|
|
4324
4387
|
return { performLayout() {} };
|
|
4325
4388
|
}
|
|
4326
|
-
function
|
|
4389
|
+
function Jn({ layoutManager: e }) {
|
|
4327
4390
|
let t = y.getClass("layoutManager");
|
|
4328
4391
|
if (!e) return new t();
|
|
4329
4392
|
let { strategy: n, type: r } = e, i = y.getClass(r);
|
|
4330
4393
|
return n ? new i(new (y.getClass(n))()) : new i();
|
|
4331
4394
|
}
|
|
4332
|
-
var
|
|
4395
|
+
var Yn = class e extends l {
|
|
4333
4396
|
constructor(e = [], t = {}) {
|
|
4334
|
-
let { layoutManager: n, objectCaching: r, centeredScaling: i, lockScalingFlip: a } = t, o = ut(t,
|
|
4335
|
-
super(e,
|
|
4397
|
+
let { layoutManager: n, objectCaching: r, centeredScaling: i, lockScalingFlip: a } = t, o = ut(t, Un);
|
|
4398
|
+
super(e, U(U({}, o), {}, {
|
|
4336
4399
|
layoutManager: n,
|
|
4337
4400
|
objectCaching: r == null ? !1 : r,
|
|
4338
4401
|
centeredScaling: i == null ? !1 : i,
|
|
@@ -4343,14 +4406,14 @@ var Gn = class e extends l {
|
|
|
4343
4406
|
this.set({
|
|
4344
4407
|
objectCaching: !1,
|
|
4345
4408
|
shapeComposite: !0
|
|
4346
|
-
}), this._syncRoundability(),
|
|
4347
|
-
let e =
|
|
4348
|
-
e &&
|
|
4409
|
+
}), this.shapeTextAutoExpand === void 0 && (this.shapeTextAutoExpand = !0), this._syncRoundability(), Nn({ group: this }), Hn({ group: this });
|
|
4410
|
+
let e = In({ group: this });
|
|
4411
|
+
e && Pn({ text: e }), Fn({ group: this }), this.setCoords();
|
|
4349
4412
|
}
|
|
4350
4413
|
static fromObject(t, n) {
|
|
4351
4414
|
return k(function* () {
|
|
4352
|
-
let { type: r, objects: i = [], layoutManager: a } = t, o = ut(t,
|
|
4353
|
-
return l.layoutManager =
|
|
4415
|
+
let { type: r, objects: i = [], layoutManager: a } = t, o = ut(t, Wn), [s, c] = yield Promise.all([C.enlivenObjects(i, n), C.enlivenObjectEnlivables(o, n)]), l = new e(s, U(U(U({}, o), c), {}, { layoutManager: qn() }));
|
|
4416
|
+
return l.layoutManager = Jn({ layoutManager: a }), l.layoutManager.subscribeTargets({
|
|
4354
4417
|
type: "initialization",
|
|
4355
4418
|
target: l,
|
|
4356
4419
|
targets: l.getObjects()
|
|
@@ -4365,10 +4428,10 @@ var Gn = class e extends l {
|
|
|
4365
4428
|
t && (this.shapeCanRound = At({ preset: t }));
|
|
4366
4429
|
}
|
|
4367
4430
|
};
|
|
4368
|
-
|
|
4369
|
-
var
|
|
4370
|
-
y != null && y.setClass && y.setClass(
|
|
4371
|
-
}, Y = (e) => e instanceof
|
|
4431
|
+
Gn = Yn, Gn.type = Kn;
|
|
4432
|
+
var Xn = () => {
|
|
4433
|
+
y != null && y.setClass && y.setClass(Yn, Kn);
|
|
4434
|
+
}, Y = (e) => e instanceof Yn || e instanceof l && e.shapeComposite === !0, Zn = ({ target: e, subTargets: t = [] }) => {
|
|
4372
4435
|
if (Y(e)) return e;
|
|
4373
4436
|
if (e != null && e.group && Y(e.group)) return e.group;
|
|
4374
4437
|
for (let e = 0; e < t.length; e += 1) {
|
|
@@ -4378,7 +4441,7 @@ var Kn = () => {
|
|
|
4378
4441
|
if (r && Y(r)) return r;
|
|
4379
4442
|
}
|
|
4380
4443
|
return null;
|
|
4381
|
-
},
|
|
4444
|
+
}, Qn = ({ group: e }) => {
|
|
4382
4445
|
let t = e.getObjects();
|
|
4383
4446
|
for (let e = 0; e < t.length; e += 1) {
|
|
4384
4447
|
let n = t[e];
|
|
@@ -4389,7 +4452,7 @@ var Kn = () => {
|
|
|
4389
4452
|
if (!(n instanceof _)) return n;
|
|
4390
4453
|
}
|
|
4391
4454
|
return null;
|
|
4392
|
-
},
|
|
4455
|
+
}, $n = ({ group: e }) => {
|
|
4393
4456
|
let t = e.getObjects();
|
|
4394
4457
|
for (let e = 0; e < t.length; e += 1) {
|
|
4395
4458
|
let n = t[e];
|
|
@@ -4400,17 +4463,17 @@ var Kn = () => {
|
|
|
4400
4463
|
if (n instanceof _) return n;
|
|
4401
4464
|
}
|
|
4402
4465
|
return null;
|
|
4403
|
-
},
|
|
4404
|
-
shape:
|
|
4405
|
-
text:
|
|
4406
|
-
}),
|
|
4407
|
-
|
|
4408
|
-
},
|
|
4466
|
+
}, er = ({ group: e }) => ({
|
|
4467
|
+
shape: Qn({ group: e }),
|
|
4468
|
+
text: $n({ group: e })
|
|
4469
|
+
}), tr = ({ group: e }) => {
|
|
4470
|
+
Nn({ group: e });
|
|
4471
|
+
}, nr = ({ transform: e, key: t }) => {
|
|
4409
4472
|
let n = e == null ? void 0 : e.original;
|
|
4410
4473
|
if (!n || typeof n != "object") return null;
|
|
4411
4474
|
let r = n[t];
|
|
4412
4475
|
return typeof r != "number" || !Number.isFinite(r) ? null : r;
|
|
4413
|
-
},
|
|
4476
|
+
}, rr = ({ value: e }) => e === "left" || e === "center" || e === "right" || typeof e == "number" && Number.isFinite(e) ? e : null, ir = ({ value: e }) => e === "top" || e === "center" || e === "bottom" || typeof e == "number" && Number.isFinite(e) ? e : null, ar = ({ transform: e }) => {
|
|
4414
4477
|
var t;
|
|
4415
4478
|
let n = (t = e == null ? void 0 : e.action) == null ? "" : t, r = typeof (e == null ? void 0 : e.corner) == "string" ? e.corner : "", i = r === "tl" || r === "tr" || r === "bl" || r === "br", a = n === "scaleX" || r === "ml" || r === "mr", o = n === "scaleY" || r === "mt" || r === "mb", s = a || i, c = o || i;
|
|
4416
4479
|
return {
|
|
@@ -4419,39 +4482,39 @@ var Kn = () => {
|
|
|
4419
4482
|
isCornerScaleAction: i,
|
|
4420
4483
|
isVerticalOnlyScale: c && !s
|
|
4421
4484
|
};
|
|
4422
|
-
},
|
|
4485
|
+
}, or = ({ event: e, group: t, transform: n, canvas: r }) => {
|
|
4423
4486
|
var i, a, o, s, c;
|
|
4424
4487
|
if (!e) return null;
|
|
4425
4488
|
let l = (i = t.canvas) == null ? r : i, u = l.getScenePoint(e), d = t.getRelativeCenterPoint(), f = t.translateToGivenOrigin(d, "center", "center", n.originX, n.originY), p = (a = t.angle) == null ? 0 : a, m = (p === 0 ? u : u.rotate(-p * Math.PI / 180, d)).subtract(f), h = t.controls[n.corner], g = l.getZoom() || 1, _ = ((o = t.padding) == null ? 0 : o) / g;
|
|
4426
4489
|
return m.x >= _ && (m.x -= _), m.x <= -_ && (m.x += _), m.y >= _ && (m.y -= _), m.y <= -_ && (m.y += _), m.x -= (s = h == null ? void 0 : h.offsetX) == null ? 0 : s, m.y -= (c = h == null ? void 0 : h.offsetY) == null ? 0 : c, m;
|
|
4427
|
-
},
|
|
4490
|
+
}, sr = ({ group: e, originX: t, originY: n }) => {
|
|
4428
4491
|
if (t === null || n === null) return null;
|
|
4429
4492
|
let r = e, i = typeof r.getRelativeCenterPoint == "function" ? r.getRelativeCenterPoint() : e.getCenterPoint();
|
|
4430
4493
|
return typeof r.translateToOriginPoint == "function" ? r.translateToOriginPoint(i, t, n) : i;
|
|
4431
|
-
},
|
|
4494
|
+
}, cr = ({ state: e, transform: t }) => {
|
|
4432
4495
|
if (!t || e.startTransformOriginX === null && e.startTransformOriginY === null) return !1;
|
|
4433
|
-
let n =
|
|
4496
|
+
let n = rr({ value: t.originX }), r = ir({ value: t.originY });
|
|
4434
4497
|
return n !== e.startTransformOriginX || r !== e.startTransformOriginY;
|
|
4435
|
-
},
|
|
4498
|
+
}, lr = ({ state: e, transform: t }) => !t || !e.startTransformCorner ? !1 : t.corner !== e.startTransformCorner;
|
|
4436
4499
|
//#endregion
|
|
4437
4500
|
//#region src/editor/shape-manager/scaling/shape-scaling-preview.ts
|
|
4438
|
-
function
|
|
4501
|
+
function ur({ size: e, scale: t, strokeWidth: n, minSize: r, scaleEpsilon: i }) {
|
|
4439
4502
|
let a = Math.max(i, Math.abs(t) || 1), o = Math.max(0, n);
|
|
4440
4503
|
return o <= 0 ? Math.max(r, e / a) : Math.max(r, e / a + o - o / a);
|
|
4441
4504
|
}
|
|
4442
|
-
function
|
|
4505
|
+
function dr({ group: e, shape: t, width: n, height: r, scaleX: i, scaleY: a, minSize: o, scaleEpsilon: s }) {
|
|
4443
4506
|
var c;
|
|
4444
4507
|
let l = Math.max(0, (c = e.shapeStrokeWidth) == null ? 0 : c);
|
|
4445
4508
|
Pt({
|
|
4446
4509
|
shape: t,
|
|
4447
|
-
width:
|
|
4510
|
+
width: ur({
|
|
4448
4511
|
size: n,
|
|
4449
4512
|
scale: i,
|
|
4450
4513
|
strokeWidth: l,
|
|
4451
4514
|
minSize: o,
|
|
4452
4515
|
scaleEpsilon: s
|
|
4453
4516
|
}),
|
|
4454
|
-
height:
|
|
4517
|
+
height: ur({
|
|
4455
4518
|
size: r,
|
|
4456
4519
|
scale: a,
|
|
4457
4520
|
strokeWidth: l,
|
|
@@ -4462,8 +4525,8 @@ function sr({ group: e, shape: t, width: n, height: r, scaleX: i, scaleY: a, min
|
|
|
4462
4525
|
strokeWidth: l
|
|
4463
4526
|
});
|
|
4464
4527
|
}
|
|
4465
|
-
function
|
|
4466
|
-
let l = Math.max(c, Math.abs(o) || 1), u = Math.max(c, Math.abs(s) || 1), d = i == null ? Ct : i, { frame: f, splitByGrapheme: p, textTop: m } =
|
|
4528
|
+
function fr({ text: e, width: t, height: n, padding: r, alignH: i, alignV: a, scaleX: o, scaleY: s, scaleEpsilon: c }) {
|
|
4529
|
+
let l = Math.max(c, Math.abs(o) || 1), u = Math.max(c, Math.abs(s) || 1), d = i == null ? Ct : i, { frame: f, splitByGrapheme: p, textTop: m } = ln({
|
|
4467
4530
|
text: e,
|
|
4468
4531
|
width: t,
|
|
4469
4532
|
height: n,
|
|
@@ -4483,13 +4546,13 @@ function cr({ text: e, width: t, height: n, padding: r, alignH: i, alignV: a, sc
|
|
|
4483
4546
|
scaleY: 1 / u
|
|
4484
4547
|
}), e.initDimensions(), e.setCoords();
|
|
4485
4548
|
}
|
|
4486
|
-
var
|
|
4549
|
+
var pr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH: o, alignV: s, scaleX: c, scaleY: l, minSize: u, scaleEpsilon: d }) => {
|
|
4487
4550
|
let f = Math.max(d, Math.abs(c) || 1), p = Math.max(d, Math.abs(l) || 1);
|
|
4488
4551
|
e.set({
|
|
4489
4552
|
width: r / f,
|
|
4490
4553
|
height: i / p,
|
|
4491
4554
|
dirty: !0
|
|
4492
|
-
}),
|
|
4555
|
+
}), dr({
|
|
4493
4556
|
group: e,
|
|
4494
4557
|
shape: t,
|
|
4495
4558
|
width: r,
|
|
@@ -4498,7 +4561,7 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4498
4561
|
scaleY: l,
|
|
4499
4562
|
minSize: u,
|
|
4500
4563
|
scaleEpsilon: d
|
|
4501
|
-
}),
|
|
4564
|
+
}), fr({
|
|
4502
4565
|
text: n,
|
|
4503
4566
|
width: r,
|
|
4504
4567
|
height: i,
|
|
@@ -4509,13 +4572,13 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4509
4572
|
scaleY: l,
|
|
4510
4573
|
scaleEpsilon: d
|
|
4511
4574
|
});
|
|
4512
|
-
}, X = 1, Z = 1e-4,
|
|
4575
|
+
}, X = 1, Z = 1e-4, mr = .5, hr = class e {
|
|
4513
4576
|
constructor({ canvas: t }) {
|
|
4514
4577
|
this.handleObjectScaling = (t) => {
|
|
4515
4578
|
var n, r, i, a, o, s;
|
|
4516
4579
|
let { target: c, transform: l } = t;
|
|
4517
4580
|
if (!Y(c)) return;
|
|
4518
|
-
let u = c, { shape: d, text: f } =
|
|
4581
|
+
let u = c, { shape: d, text: f } = er({ group: u });
|
|
4519
4582
|
if (!d || !f) return;
|
|
4520
4583
|
u.set({
|
|
4521
4584
|
lockScalingFlip: !0,
|
|
@@ -4526,7 +4589,7 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4526
4589
|
text: f,
|
|
4527
4590
|
padding: p,
|
|
4528
4591
|
transform: l
|
|
4529
|
-
}), { isCornerScaleAction: h } =
|
|
4592
|
+
}), { isCornerScaleAction: h } = ar({ transform: l }), g = !!(t.e && "shiftKey" in t.e && t.e.shiftKey);
|
|
4530
4593
|
m.isProportionalScaling = h && g;
|
|
4531
4594
|
let _ = (n = u.left) == null ? 0 : n, v = (r = u.top) == null ? 0 : r, y = !!u.flipX, b = !!u.flipY, x = (i = u.shapeAlignHorizontal) == null ? Ct : i, S = (a = u.shapeAlignVertical) == null ? wt : a, C = this._resolveScalingDecision({
|
|
4532
4595
|
group: u,
|
|
@@ -4541,7 +4604,7 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4541
4604
|
shouldHandleAsNoop: C.shouldHandleAsNoop,
|
|
4542
4605
|
scaleX: C.appliedScaleX,
|
|
4543
4606
|
scaleY: C.appliedScaleY
|
|
4544
|
-
}),
|
|
4607
|
+
}), pr({
|
|
4545
4608
|
group: u,
|
|
4546
4609
|
shape: d,
|
|
4547
4610
|
text: f,
|
|
@@ -4577,22 +4640,22 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4577
4640
|
if (!c) return;
|
|
4578
4641
|
let { target: l } = c;
|
|
4579
4642
|
if (!Y(l)) return;
|
|
4580
|
-
let { canScaleHeight: u, canScaleWidth: d } =
|
|
4643
|
+
let { canScaleHeight: u, canScaleWidth: d } = ar({ transform: c });
|
|
4581
4644
|
if (!d && !u) return;
|
|
4582
4645
|
let f = l, p = this.scalingState.get(f);
|
|
4583
4646
|
if (!p || p.isProportionalScaling) return;
|
|
4584
|
-
let { shape: m, text: h } =
|
|
4647
|
+
let { shape: m, text: h } = er({ group: f });
|
|
4585
4648
|
if (!m || !h) return;
|
|
4586
|
-
let g = e._resolvePadding({ group: f }), _ = (n = f.shapeAlignHorizontal) == null ? Ct : n, v = (r = f.shapeAlignVertical) == null ? wt : r, y = Math.abs((i = (a = f.scaleX) == null ? p.lastAllowedScaleX : a) == null ? 1 : i) || 1, b = Math.abs((o = (s = f.scaleY) == null ? p.lastAllowedScaleY : s) == null ? 1 : o) || 1, x =
|
|
4649
|
+
let g = e._resolvePadding({ group: f }), _ = (n = f.shapeAlignHorizontal) == null ? Ct : n, v = (r = f.shapeAlignVertical) == null ? wt : r, y = Math.abs((i = (a = f.scaleX) == null ? p.lastAllowedScaleX : a) == null ? 1 : i) || 1, b = Math.abs((o = (s = f.scaleY) == null ? p.lastAllowedScaleY : s) == null ? 1 : o) || 1, x = U(U({}, t), {}, { transform: c }), S = y, C = b, w = null, T = !1, E = !1;
|
|
4587
4650
|
if (d && this._hasPointerReachedScaleOrigin({
|
|
4588
4651
|
event: x,
|
|
4589
4652
|
group: f,
|
|
4590
4653
|
axis: "x"
|
|
4591
4654
|
})) {
|
|
4592
|
-
let e =
|
|
4655
|
+
let e = cn({
|
|
4593
4656
|
text: h,
|
|
4594
4657
|
padding: g
|
|
4595
|
-
}), t = Math.max(X / p.
|
|
4658
|
+
}), t = Math.max(X / p.startWidth, e / p.startWidth);
|
|
4596
4659
|
p.lastAllowedScaleX > t + Z && (S = t, T = !0, E = !0);
|
|
4597
4660
|
}
|
|
4598
4661
|
if (u && this._hasPointerReachedScaleOrigin({
|
|
@@ -4602,10 +4665,10 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4602
4665
|
})) {
|
|
4603
4666
|
w = this._resolveMinimumTextFitHeight({
|
|
4604
4667
|
text: h,
|
|
4605
|
-
width: Math.max(X, p.
|
|
4668
|
+
width: Math.max(X, p.startWidth * S),
|
|
4606
4669
|
padding: g
|
|
4607
4670
|
});
|
|
4608
|
-
let e = Math.max(X / p.
|
|
4671
|
+
let e = Math.max(X / p.startHeight, w / p.startHeight);
|
|
4609
4672
|
p.lastAllowedScaleY > e + Z && (C = e, E = !0);
|
|
4610
4673
|
}
|
|
4611
4674
|
if (!E) return;
|
|
@@ -4623,7 +4686,7 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4623
4686
|
shouldHandleAsNoop: !1,
|
|
4624
4687
|
scaleX: S,
|
|
4625
4688
|
scaleY: C
|
|
4626
|
-
}),
|
|
4689
|
+
}), pr({
|
|
4627
4690
|
group: f,
|
|
4628
4691
|
shape: m,
|
|
4629
4692
|
text: h,
|
|
@@ -4650,97 +4713,106 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4650
4713
|
currentFlipY: p.lastAllowedFlipY
|
|
4651
4714
|
}), this.canvas.requestRenderAll();
|
|
4652
4715
|
}, this.handleObjectModified = (t) => {
|
|
4653
|
-
var n, r, i, a, o, s, c, l, u, d, f, p, m, h, g, _;
|
|
4654
|
-
let { target:
|
|
4655
|
-
if (!Y(
|
|
4656
|
-
let
|
|
4657
|
-
if (!(Math.abs(
|
|
4658
|
-
let
|
|
4659
|
-
if (
|
|
4660
|
-
let { shape: e, text: t } =
|
|
4716
|
+
var n, r, i, a, o, s, c, l, u, d, f, p, m, h, g, _, v, y, b, x, S, C, w, T;
|
|
4717
|
+
let { target: E } = t;
|
|
4718
|
+
if (!Y(E)) return;
|
|
4719
|
+
let D = E, O = this.scalingState.get(D), k = Math.abs((n = D.scaleX) == null ? 1 : n) || 1, A = Math.abs((r = D.scaleY) == null ? 1 : r) || 1;
|
|
4720
|
+
if (!(Math.abs(k - 1) > Z || Math.abs(A - 1) > Z) && !O) return;
|
|
4721
|
+
let j = (i = O == null ? void 0 : O.startWidth) == null ? Math.max(X, (a = (o = (s = D.shapeBaseWidth) == null ? D.width : s) == null ? D.shapeManualBaseWidth : o) == null ? X : a) : i, M = (c = O == null ? void 0 : O.startHeight) == null ? Math.max(X, (l = (u = (d = D.shapeBaseHeight) == null ? D.height : d) == null ? D.shapeManualBaseHeight : u) == null ? X : l) : c, N = (f = O == null ? void 0 : O.startManualBaseWidth) == null ? Math.max(X, (p = D.shapeManualBaseWidth) == null ? j : p) : f, ee = (m = O == null ? void 0 : O.startManualBaseHeight) == null ? Math.max(X, (h = D.shapeManualBaseHeight) == null ? M : h) : m;
|
|
4722
|
+
if (O != null && O.blockedScaleAttempt && O) {
|
|
4723
|
+
let { shape: e, text: t } = er({ group: D });
|
|
4661
4724
|
this._restoreGroupTransformOnly({
|
|
4662
|
-
group:
|
|
4725
|
+
group: D,
|
|
4663
4726
|
shape: e,
|
|
4664
4727
|
text: t,
|
|
4665
|
-
state:
|
|
4666
|
-
}),
|
|
4728
|
+
state: O
|
|
4729
|
+
}), D.shapeScalingNoopTransform = !1, this.scalingState.delete(D), this.canvas.requestRenderAll();
|
|
4667
4730
|
return;
|
|
4668
4731
|
}
|
|
4669
|
-
let { shape:
|
|
4670
|
-
if (!
|
|
4671
|
-
this.scalingState.delete(
|
|
4732
|
+
let { shape: P, text: F } = er({ group: D });
|
|
4733
|
+
if (!P || !F) {
|
|
4734
|
+
this.scalingState.delete(D);
|
|
4672
4735
|
return;
|
|
4673
4736
|
}
|
|
4674
|
-
let
|
|
4675
|
-
text:
|
|
4676
|
-
padding:
|
|
4677
|
-
}),
|
|
4678
|
-
if (!(
|
|
4737
|
+
let I = (g = D.shapeAlignHorizontal) == null ? Ct : g, L = (_ = D.shapeAlignVertical) == null ? wt : _, te = e._resolvePadding({ group: D }), R = t.transform ? ar({ transform: t.transform }) : null, z = (v = (y = O == null ? void 0 : O.canScaleWidth) == null ? R == null ? void 0 : R.canScaleWidth : y) == null ? Math.abs(k - 1) > Z : v, ne = (b = (x = O == null ? void 0 : O.canScaleHeight) == null ? R == null ? void 0 : R.canScaleHeight : x) == null ? Math.abs(A - 1) > Z : b, B = cn({
|
|
4738
|
+
text: F,
|
|
4739
|
+
padding: te
|
|
4740
|
+
}), re = (S = O == null ? void 0 : O.lastAllowedScaleX) == null ? k : S, V = (C = O == null ? void 0 : O.lastAllowedScaleY) == null ? A : C;
|
|
4741
|
+
if (!(O != null && O.isProportionalScaling)) {
|
|
4679
4742
|
this._shouldClampWidthToMinimum({
|
|
4680
4743
|
event: t,
|
|
4681
|
-
group:
|
|
4682
|
-
minimumWidth:
|
|
4683
|
-
state:
|
|
4684
|
-
}) && (
|
|
4744
|
+
group: D,
|
|
4745
|
+
minimumWidth: B,
|
|
4746
|
+
state: O
|
|
4747
|
+
}) && (re = Math.max(X / j, B / j));
|
|
4685
4748
|
let e = this._resolveMinimumTextFitHeight({
|
|
4686
|
-
text:
|
|
4687
|
-
width: Math.max(X,
|
|
4688
|
-
padding:
|
|
4749
|
+
text: F,
|
|
4750
|
+
width: Math.max(X, j * re),
|
|
4751
|
+
padding: te
|
|
4689
4752
|
});
|
|
4690
4753
|
this._shouldClampHeightToMinimum({
|
|
4691
4754
|
event: t,
|
|
4692
|
-
group:
|
|
4755
|
+
group: D,
|
|
4693
4756
|
minimumHeight: e,
|
|
4694
|
-
state:
|
|
4695
|
-
}) && (
|
|
4757
|
+
state: O
|
|
4758
|
+
}) && (V = Math.max(X / M, e / M));
|
|
4696
4759
|
}
|
|
4697
|
-
let
|
|
4698
|
-
if (!
|
|
4760
|
+
let ie = z ? Math.max(X, j * re) : j, ae = ne ? Math.max(X, M * V) : ee, oe = Math.abs(ie - j) > mr, H = Math.abs(ae - M) > mr, se = oe || H, ce = ie, le = ae;
|
|
4761
|
+
if (!se && O) {
|
|
4699
4762
|
this._restoreShapeStateWithoutResize({
|
|
4700
|
-
group:
|
|
4701
|
-
shape:
|
|
4702
|
-
text:
|
|
4703
|
-
state:
|
|
4704
|
-
|
|
4705
|
-
|
|
4706
|
-
alignH:
|
|
4707
|
-
alignV:
|
|
4708
|
-
padding:
|
|
4709
|
-
}), this.scalingState.delete(
|
|
4763
|
+
group: D,
|
|
4764
|
+
shape: P,
|
|
4765
|
+
text: F,
|
|
4766
|
+
state: O,
|
|
4767
|
+
startWidth: j,
|
|
4768
|
+
startHeight: M,
|
|
4769
|
+
alignH: I,
|
|
4770
|
+
alignV: L,
|
|
4771
|
+
padding: te
|
|
4772
|
+
}), this.scalingState.delete(D), this.canvas.requestRenderAll();
|
|
4710
4773
|
return;
|
|
4711
4774
|
}
|
|
4712
|
-
|
|
4713
|
-
left:
|
|
4714
|
-
top:
|
|
4715
|
-
})
|
|
4716
|
-
let
|
|
4717
|
-
|
|
4718
|
-
|
|
4719
|
-
|
|
4720
|
-
|
|
4721
|
-
|
|
4722
|
-
|
|
4723
|
-
|
|
4724
|
-
|
|
4725
|
-
|
|
4726
|
-
|
|
4775
|
+
O && D.set({
|
|
4776
|
+
left: O.lastAllowedLeft,
|
|
4777
|
+
top: O.lastAllowedTop
|
|
4778
|
+
});
|
|
4779
|
+
let ue = this._resolveNextManualBaseDimensionsAfterScaling({
|
|
4780
|
+
startManualBaseWidth: N,
|
|
4781
|
+
startManualBaseHeight: ee,
|
|
4782
|
+
canScaleWidth: z,
|
|
4783
|
+
canScaleHeight: ne,
|
|
4784
|
+
finalWidth: ce,
|
|
4785
|
+
finalHeight: le
|
|
4786
|
+
});
|
|
4787
|
+
D.shapeManualBaseWidth = ue.width, D.shapeManualBaseHeight = ue.height;
|
|
4788
|
+
let U = (w = O == null ? void 0 : O.baseRounding) == null ? Math.max(0, (T = D.shapeRounding) == null ? 0 : T) : w;
|
|
4789
|
+
D.shapeRounding = Math.max(0, U * Math.min(re, V)), on({
|
|
4790
|
+
group: D,
|
|
4791
|
+
shape: P,
|
|
4792
|
+
text: F,
|
|
4793
|
+
width: ce,
|
|
4794
|
+
height: le,
|
|
4795
|
+
alignH: I,
|
|
4796
|
+
alignV: L,
|
|
4797
|
+
padding: te
|
|
4798
|
+
}), F.set({
|
|
4727
4799
|
scaleX: 1,
|
|
4728
4800
|
scaleY: 1
|
|
4729
|
-
}),
|
|
4801
|
+
}), D.set({
|
|
4730
4802
|
scaleX: 1,
|
|
4731
4803
|
scaleY: 1
|
|
4732
|
-
}),
|
|
4733
|
-
group:
|
|
4734
|
-
state:
|
|
4735
|
-
}),
|
|
4804
|
+
}), O && this._restoreScalingAnchorPosition({
|
|
4805
|
+
group: D,
|
|
4806
|
+
state: O
|
|
4807
|
+
}), D.setCoords(), F.setCoords(), P.setCoords(), this.scalingState.delete(D), D.shapeScalingNoopTransform = !1, this.canvas.requestRenderAll();
|
|
4736
4808
|
}, this.canvas = t, this.scalingState = /* @__PURE__ */ new WeakMap();
|
|
4737
4809
|
}
|
|
4738
4810
|
_resolveScalingDecision({ group: e, text: t, padding: n, state: r, transform: i }) {
|
|
4739
4811
|
var a, o, s, c, l, u;
|
|
4740
|
-
let d = (a = e.scaleX) == null ? 1 : a, f = (o = e.scaleY) == null ? 1 : o, p = Math.abs(d) || 1, m = Math.abs(f) || 1, h = d < 0 || f < 0, g =
|
|
4812
|
+
let d = (a = e.scaleX) == null ? 1 : a, f = (o = e.scaleY) == null ? 1 : o, p = Math.abs(d) || 1, m = Math.abs(f) || 1, h = d < 0 || f < 0, g = cr({
|
|
4741
4813
|
state: r,
|
|
4742
4814
|
transform: i
|
|
4743
|
-
}), _ =
|
|
4815
|
+
}), _ = lr({
|
|
4744
4816
|
state: r,
|
|
4745
4817
|
transform: i
|
|
4746
4818
|
});
|
|
@@ -4772,7 +4844,7 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4772
4844
|
};
|
|
4773
4845
|
}
|
|
4774
4846
|
_resolveScalingConstraintState({ text: e, padding: t, state: n, transform: r, scaleX: i, scaleY: a }) {
|
|
4775
|
-
let {
|
|
4847
|
+
let { startHeight: o, startWidth: s, cannotScaleDownAtStart: c, crossedOppositeCorner: l, isProportionalScaling: u, lastAllowedScaleX: d, lastAllowedScaleY: f, startScaleY: p } = n, m = Math.max(X, s * i), h = Math.max(X, o * a), g = i < d - Z, _ = a < f - Z, v = a < p - Z, { canScaleHeight: y, canScaleWidth: b, isVerticalOnlyScale: x } = ar({ transform: r }), S = b && g ? cn({
|
|
4776
4848
|
text: e,
|
|
4777
4849
|
padding: t
|
|
4778
4850
|
}) : null, C = y && _ ? this._resolveMinimumTextFitHeight({
|
|
@@ -4791,7 +4863,7 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4791
4863
|
};
|
|
4792
4864
|
}
|
|
4793
4865
|
_resolvePreviewDimensions({ text: e, padding: t, state: n, appliedScaleX: r, appliedScaleY: i, minimumHeight: a }) {
|
|
4794
|
-
let o = Math.max(X, n.
|
|
4866
|
+
let o = n.canScaleWidth ? Math.max(X, n.startWidth * r) : n.startWidth, s = n.canScaleHeight ? Math.max(X, n.startHeight * i) : n.startManualBaseHeight, c = a == null ? un({
|
|
4795
4867
|
text: e,
|
|
4796
4868
|
width: o,
|
|
4797
4869
|
height: s,
|
|
@@ -4825,26 +4897,26 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4825
4897
|
if (!r) return !1;
|
|
4826
4898
|
let { transform: i } = e;
|
|
4827
4899
|
if (!i) return !1;
|
|
4828
|
-
let { canScaleWidth: a } =
|
|
4900
|
+
let { canScaleWidth: a } = ar({ transform: i });
|
|
4829
4901
|
if (!a || !this._hasPointerReachedScaleOrigin({
|
|
4830
4902
|
event: e,
|
|
4831
4903
|
group: t,
|
|
4832
4904
|
axis: "x"
|
|
4833
4905
|
})) return !1;
|
|
4834
|
-
let o = Math.max(X / r.
|
|
4906
|
+
let o = Math.max(X / r.startWidth, n / r.startWidth);
|
|
4835
4907
|
return r.lastAllowedScaleX > o + Z;
|
|
4836
4908
|
}
|
|
4837
4909
|
_shouldClampHeightToMinimum({ event: e, group: t, minimumHeight: n, state: r }) {
|
|
4838
4910
|
if (!r) return !1;
|
|
4839
4911
|
let { transform: i } = e;
|
|
4840
4912
|
if (!i) return !1;
|
|
4841
|
-
let { canScaleHeight: a } =
|
|
4913
|
+
let { canScaleHeight: a } = ar({ transform: i });
|
|
4842
4914
|
if (!a || !this._hasPointerReachedScaleOrigin({
|
|
4843
4915
|
event: e,
|
|
4844
4916
|
group: t,
|
|
4845
4917
|
axis: "y"
|
|
4846
4918
|
})) return !1;
|
|
4847
|
-
let o = Math.max(X / r.
|
|
4919
|
+
let o = Math.max(X / r.startHeight, n / r.startHeight);
|
|
4848
4920
|
return r.lastAllowedScaleY > o + Z;
|
|
4849
4921
|
}
|
|
4850
4922
|
_hasPointerReachedScaleOrigin({ event: e, group: t, axis: n }) {
|
|
@@ -4852,7 +4924,7 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4852
4924
|
if (!r) return !1;
|
|
4853
4925
|
let i = r, a = n === "x" ? i.signX : i.signY;
|
|
4854
4926
|
if (typeof a != "number" || !Number.isFinite(a)) return !1;
|
|
4855
|
-
let o =
|
|
4927
|
+
let o = or({
|
|
4856
4928
|
event: e.e,
|
|
4857
4929
|
group: t,
|
|
4858
4930
|
transform: r,
|
|
@@ -4866,59 +4938,66 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4866
4938
|
_ensureScalingState({ group: e, text: t, padding: n, transform: r }) {
|
|
4867
4939
|
let i = this.scalingState.get(e);
|
|
4868
4940
|
if (!i) {
|
|
4869
|
-
var a, o, s, c, l, u, d, f, p, m, h
|
|
4870
|
-
let
|
|
4941
|
+
var a, o, s, c, l, u, d, f, p, m, h;
|
|
4942
|
+
let g = this._resolveScalingStartDimensions({
|
|
4943
|
+
group: e,
|
|
4944
|
+
transform: r
|
|
4945
|
+
}), _ = nr({
|
|
4871
4946
|
transform: r,
|
|
4872
4947
|
key: "scaleX"
|
|
4873
|
-
}),
|
|
4948
|
+
}), v = nr({
|
|
4874
4949
|
transform: r,
|
|
4875
4950
|
key: "scaleY"
|
|
4876
|
-
}),
|
|
4951
|
+
}), y = nr({
|
|
4877
4952
|
transform: r,
|
|
4878
4953
|
key: "left"
|
|
4879
|
-
}),
|
|
4954
|
+
}), b = nr({
|
|
4880
4955
|
transform: r,
|
|
4881
4956
|
key: "top"
|
|
4882
|
-
}),
|
|
4957
|
+
}), x = Math.abs((a = _ == null ? e.scaleX : _) == null ? 1 : a) || 1, S = Math.abs((o = v == null ? e.scaleY : v) == null ? 1 : o) || 1, C = (s = y == null ? e.left : y) == null ? 0 : s, w = (c = b == null ? e.top : b) == null ? 0 : c, T = rr({ value: (l = r == null || (u = r.original) == null ? void 0 : u.originX) == null ? r == null ? void 0 : r.originX : l }), E = ir({ value: (d = r == null || (f = r.original) == null ? void 0 : f.originY) == null ? r == null ? void 0 : r.originY : d }), D = typeof (r == null ? void 0 : r.corner) == "string" ? r.corner : null, O = sr({
|
|
4883
4958
|
group: e,
|
|
4884
|
-
originX:
|
|
4885
|
-
originY:
|
|
4886
|
-
}),
|
|
4959
|
+
originX: T,
|
|
4960
|
+
originY: E
|
|
4961
|
+
}), k = this._resolveMinimumTextFitHeight({
|
|
4887
4962
|
text: t,
|
|
4888
|
-
width:
|
|
4963
|
+
width: g.startWidth,
|
|
4889
4964
|
padding: n
|
|
4890
4965
|
});
|
|
4891
4966
|
i = {
|
|
4892
|
-
|
|
4893
|
-
|
|
4894
|
-
|
|
4895
|
-
|
|
4967
|
+
startWidth: g.startWidth,
|
|
4968
|
+
startHeight: g.startHeight,
|
|
4969
|
+
startManualBaseWidth: g.startManualBaseWidth,
|
|
4970
|
+
startManualBaseHeight: g.startManualBaseHeight,
|
|
4971
|
+
canScaleWidth: g.canScaleWidth,
|
|
4972
|
+
canScaleHeight: g.canScaleHeight,
|
|
4973
|
+
baseRounding: Math.max(0, (p = e.shapeRounding) == null ? 0 : p),
|
|
4974
|
+
cannotScaleDownAtStart: k >= g.startHeight - Z,
|
|
4896
4975
|
isProportionalScaling: !1,
|
|
4897
4976
|
blockedScaleAttempt: !1,
|
|
4898
|
-
startLeft:
|
|
4899
|
-
startTop:
|
|
4900
|
-
startScaleX:
|
|
4901
|
-
startScaleY:
|
|
4902
|
-
startTransformOriginX:
|
|
4903
|
-
startTransformOriginY:
|
|
4904
|
-
startTransformCorner:
|
|
4905
|
-
scalingAnchorX: (
|
|
4906
|
-
scalingAnchorY: (
|
|
4907
|
-
scalingAnchorOriginX:
|
|
4908
|
-
scalingAnchorOriginY:
|
|
4977
|
+
startLeft: C,
|
|
4978
|
+
startTop: w,
|
|
4979
|
+
startScaleX: x,
|
|
4980
|
+
startScaleY: S,
|
|
4981
|
+
startTransformOriginX: T,
|
|
4982
|
+
startTransformOriginY: E,
|
|
4983
|
+
startTransformCorner: D,
|
|
4984
|
+
scalingAnchorX: (m = O == null ? void 0 : O.x) == null ? null : m,
|
|
4985
|
+
scalingAnchorY: (h = O == null ? void 0 : O.y) == null ? null : h,
|
|
4986
|
+
scalingAnchorOriginX: T,
|
|
4987
|
+
scalingAnchorOriginY: E,
|
|
4909
4988
|
crossedOppositeCorner: !1,
|
|
4910
4989
|
lastAllowedFlipX: !!e.flipX,
|
|
4911
4990
|
lastAllowedFlipY: !!e.flipY,
|
|
4912
|
-
lastAllowedScaleX:
|
|
4913
|
-
lastAllowedScaleY:
|
|
4914
|
-
lastAllowedLeft:
|
|
4915
|
-
lastAllowedTop:
|
|
4991
|
+
lastAllowedScaleX: x,
|
|
4992
|
+
lastAllowedScaleY: S,
|
|
4993
|
+
lastAllowedLeft: C,
|
|
4994
|
+
lastAllowedTop: w
|
|
4916
4995
|
}, this.scalingState.set(e, i);
|
|
4917
4996
|
}
|
|
4918
4997
|
return i;
|
|
4919
4998
|
}
|
|
4920
4999
|
_resolveMinimumTextFitHeight({ text: e, width: t, padding: n }) {
|
|
4921
|
-
return
|
|
5000
|
+
return un({
|
|
4922
5001
|
text: e,
|
|
4923
5002
|
width: t,
|
|
4924
5003
|
height: X,
|
|
@@ -4942,7 +5021,7 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4942
5021
|
}
|
|
4943
5022
|
e.setPositionByOrigin(new p(n, r), i, a), e.setCoords();
|
|
4944
5023
|
}
|
|
4945
|
-
_restoreShapeStateWithoutResize({ group: e, shape: t, text: n, state: r,
|
|
5024
|
+
_restoreShapeStateWithoutResize({ group: e, shape: t, text: n, state: r, startWidth: i, startHeight: a, alignH: o, alignV: s, padding: c }) {
|
|
4946
5025
|
var l, u, d, f;
|
|
4947
5026
|
on({
|
|
4948
5027
|
group: e,
|
|
@@ -4967,7 +5046,7 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4967
5046
|
}
|
|
4968
5047
|
_restoreGroupTransformOnly({ group: e, shape: t, text: n, state: r }) {
|
|
4969
5048
|
var i, a, o, s;
|
|
4970
|
-
let c = Math.max(X, (i = (a = e.shapeBaseWidth) == null ? e.width : a) == null ? r.
|
|
5049
|
+
let c = Math.max(X, (i = (a = e.shapeBaseWidth) == null ? e.width : a) == null ? r.startWidth : i), l = Math.max(X, (o = (s = e.shapeBaseHeight) == null ? e.height : s) == null ? r.startHeight : o);
|
|
4971
5050
|
t && (Pt({
|
|
4972
5051
|
shape: t,
|
|
4973
5052
|
width: c,
|
|
@@ -4991,20 +5070,41 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4991
5070
|
state: r
|
|
4992
5071
|
});
|
|
4993
5072
|
}
|
|
4994
|
-
|
|
5073
|
+
_resolveScalingStartDimensions({ group: e, transform: t }) {
|
|
5074
|
+
var n, r, i, a, o, s, c, l;
|
|
5075
|
+
let { canScaleWidth: u, canScaleHeight: d } = ar({ transform: t }), f = Math.max(X, (n = (r = (i = e.shapeBaseWidth) == null ? e.width : i) == null ? e.shapeManualBaseWidth : r) == null ? X : n), p = Math.max(X, (a = (o = (s = e.shapeBaseHeight) == null ? e.height : s) == null ? e.shapeManualBaseHeight : o) == null ? X : a);
|
|
5076
|
+
return {
|
|
5077
|
+
startWidth: f,
|
|
5078
|
+
startHeight: p,
|
|
5079
|
+
startManualBaseWidth: Math.max(X, (c = e.shapeManualBaseWidth) == null ? f : c),
|
|
5080
|
+
startManualBaseHeight: Math.max(X, (l = e.shapeManualBaseHeight) == null ? p : l),
|
|
5081
|
+
canScaleWidth: u,
|
|
5082
|
+
canScaleHeight: d
|
|
5083
|
+
};
|
|
5084
|
+
}
|
|
5085
|
+
_resolveNextManualBaseDimensionsAfterScaling({ startManualBaseWidth: e, startManualBaseHeight: t, canScaleWidth: n, canScaleHeight: r, finalWidth: i, finalHeight: a }) {
|
|
5086
|
+
let o = e;
|
|
5087
|
+
n && (o = i);
|
|
5088
|
+
let s = t;
|
|
5089
|
+
return r && (s = a), {
|
|
5090
|
+
width: o,
|
|
5091
|
+
height: s
|
|
5092
|
+
};
|
|
5093
|
+
}
|
|
5094
|
+
}, gr = class {
|
|
4995
5095
|
constructor({ canvas: e }) {
|
|
4996
5096
|
this.handleMouseDown = (e) => {
|
|
4997
|
-
let { target: t, e: n, subTargets: r = [] } = e, i =
|
|
5097
|
+
let { target: t, e: n, subTargets: r = [] } = e, i = Zn({
|
|
4998
5098
|
target: t,
|
|
4999
5099
|
subTargets: r
|
|
5000
5100
|
});
|
|
5001
5101
|
if (!i) return;
|
|
5002
|
-
let { text: a } =
|
|
5102
|
+
let { text: a } = er({ group: i });
|
|
5003
5103
|
if (!a) return;
|
|
5004
5104
|
let o = this.canvas.getActiveObject(), s = o === i;
|
|
5005
5105
|
if (!(o === a && a.isEditing)) {
|
|
5006
5106
|
if (!s) {
|
|
5007
|
-
a.isEditing ||
|
|
5107
|
+
a.isEditing || Pn({ text: a });
|
|
5008
5108
|
return;
|
|
5009
5109
|
}
|
|
5010
5110
|
n instanceof MouseEvent && (n.detail < 2 || this.enterTextEditing({ group: i }));
|
|
@@ -5024,11 +5124,11 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5024
5124
|
Y(r) && (this._restoreTextEditingInteractionMode({
|
|
5025
5125
|
group: r,
|
|
5026
5126
|
text: n
|
|
5027
|
-
}),
|
|
5127
|
+
}), Pn({ text: n }), this.canvas.getActiveObject() === n && this.canvas.setActiveObject(r), this.canvas.requestRenderAll());
|
|
5028
5128
|
}, this.canvas = e, this.editingInteractionState = /* @__PURE__ */ new WeakMap();
|
|
5029
5129
|
}
|
|
5030
5130
|
enterTextEditing({ group: e }) {
|
|
5031
|
-
let { text: t } =
|
|
5131
|
+
let { text: t } = er({ group: e });
|
|
5032
5132
|
t && (this._enterTextEditingInteractionMode({
|
|
5033
5133
|
group: e,
|
|
5034
5134
|
text: t
|
|
@@ -5039,6 +5139,20 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5039
5139
|
lockMovementY: !0
|
|
5040
5140
|
}), this.canvas.setActiveObject(t), t.isEditing || (t.enterEditing(), t.selectAll()), this.canvas.requestRenderAll());
|
|
5041
5141
|
}
|
|
5142
|
+
resolveGroupInteractionState({ group: e }) {
|
|
5143
|
+
let t = this.editingInteractionState.get(e);
|
|
5144
|
+
return t ? {
|
|
5145
|
+
selectable: t.groupSelectable,
|
|
5146
|
+
evented: t.groupEvented,
|
|
5147
|
+
lockMovementX: t.groupLockMovementX,
|
|
5148
|
+
lockMovementY: t.groupLockMovementY
|
|
5149
|
+
} : {
|
|
5150
|
+
selectable: e.selectable !== !1,
|
|
5151
|
+
evented: e.evented !== !1,
|
|
5152
|
+
lockMovementX: !!e.lockMovementX,
|
|
5153
|
+
lockMovementY: !!e.lockMovementY
|
|
5154
|
+
};
|
|
5155
|
+
}
|
|
5042
5156
|
_enterTextEditingInteractionMode({ group: e, text: t }) {
|
|
5043
5157
|
this.editingInteractionState.has(e) || this.editingInteractionState.set(e, {
|
|
5044
5158
|
groupSelectable: e.selectable !== !1,
|
|
@@ -5075,7 +5189,7 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5075
5189
|
lockMovementY: n.textLockMovementY
|
|
5076
5190
|
}), this.editingInteractionState.delete(e), e.setCoords(), t.setCoords());
|
|
5077
5191
|
}
|
|
5078
|
-
},
|
|
5192
|
+
}, _r = "#B0B5BF", vr = 0, yr = 1, br = class {
|
|
5079
5193
|
constructor({ editor: e }) {
|
|
5080
5194
|
this._handleObjectScaling = (e) => {
|
|
5081
5195
|
this.scalingController.handleObjectScaling(e);
|
|
@@ -5119,7 +5233,7 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5119
5233
|
textNode: r,
|
|
5120
5234
|
textStyle: n
|
|
5121
5235
|
});
|
|
5122
|
-
}, this.editor = e,
|
|
5236
|
+
}, this.editor = e, Xn(), this.scalingController = new hr({ canvas: e.canvas }), this.editingController = new gr({ canvas: e.canvas }), this.editingCenters = /* @__PURE__ */ new WeakMap(), this.internalTextUpdates = /* @__PURE__ */ new WeakSet(), this._bindEvents();
|
|
5123
5237
|
}
|
|
5124
5238
|
add() {
|
|
5125
5239
|
var e = this;
|
|
@@ -5127,56 +5241,66 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5127
5241
|
var r;
|
|
5128
5242
|
let i = Dt({ presetKey: t });
|
|
5129
5243
|
if (!i) return null;
|
|
5130
|
-
let { width: a, height: o,
|
|
5244
|
+
let { width: a, height: o, shapeTextAutoExpand: s, left: c, top: l, text: u, textStyle: d, alignH: f, alignV: p, textPadding: m, rounding: h, withoutAdding: g, withoutSelection: _, withoutSave: v, id: y } = n, b = (r = Dt({ presetKey: Ot({
|
|
5131
5245
|
preset: i,
|
|
5132
|
-
rounding:
|
|
5133
|
-
}) })) == null ? i : r,
|
|
5134
|
-
explicitAlign:
|
|
5135
|
-
textStyle:
|
|
5136
|
-
}),
|
|
5137
|
-
preset:
|
|
5138
|
-
overridePadding:
|
|
5139
|
-
}),
|
|
5246
|
+
rounding: h
|
|
5247
|
+
}) })) == null ? i : r, x = Math.max(1, a == null ? b.width : a), S = Math.max(1, o == null ? b.height : o), C = s !== !1, w = e._resolveHorizontalAlign({
|
|
5248
|
+
explicitAlign: f,
|
|
5249
|
+
textStyle: d
|
|
5250
|
+
}), T = p == null ? wt : p, E = kt({
|
|
5251
|
+
preset: b,
|
|
5252
|
+
overridePadding: m
|
|
5253
|
+
}), O = e._resolveShapeStyle({
|
|
5140
5254
|
options: n,
|
|
5141
5255
|
fallback: null
|
|
5142
|
-
}),
|
|
5143
|
-
|
|
5144
|
-
|
|
5145
|
-
|
|
5146
|
-
|
|
5147
|
-
|
|
5148
|
-
}),
|
|
5149
|
-
text:
|
|
5150
|
-
|
|
5151
|
-
|
|
5152
|
-
|
|
5153
|
-
|
|
5154
|
-
|
|
5155
|
-
|
|
5156
|
-
|
|
5157
|
-
|
|
5158
|
-
|
|
5159
|
-
|
|
5160
|
-
|
|
5161
|
-
|
|
5162
|
-
|
|
5163
|
-
|
|
5164
|
-
|
|
5165
|
-
|
|
5166
|
-
|
|
5167
|
-
|
|
5168
|
-
|
|
5169
|
-
|
|
5256
|
+
}), k = e._createTextNode({
|
|
5257
|
+
text: u,
|
|
5258
|
+
textStyle: d,
|
|
5259
|
+
width: x,
|
|
5260
|
+
align: w,
|
|
5261
|
+
opacity: O.opacity
|
|
5262
|
+
}), A = e._resolveShapeLayoutWidth({
|
|
5263
|
+
text: k,
|
|
5264
|
+
currentWidth: x,
|
|
5265
|
+
manualWidth: x,
|
|
5266
|
+
shapeTextAutoExpandEnabled: C,
|
|
5267
|
+
padding: E,
|
|
5268
|
+
strokeWidth: O.strokeWidth
|
|
5269
|
+
}), j = yield Ft({
|
|
5270
|
+
preset: b,
|
|
5271
|
+
width: A,
|
|
5272
|
+
height: S,
|
|
5273
|
+
style: O,
|
|
5274
|
+
rounding: h
|
|
5275
|
+
}), M = e._createShapeGroup({
|
|
5276
|
+
id: y == null ? `shape-${D()}` : y,
|
|
5277
|
+
presetKey: b.key,
|
|
5278
|
+
presetCanRound: At({ preset: b }),
|
|
5279
|
+
shape: j,
|
|
5280
|
+
text: k,
|
|
5281
|
+
width: A,
|
|
5282
|
+
height: S,
|
|
5283
|
+
manualWidth: x,
|
|
5284
|
+
manualHeight: S,
|
|
5285
|
+
shapeTextAutoExpand: C,
|
|
5286
|
+
alignH: w,
|
|
5287
|
+
alignV: T,
|
|
5288
|
+
padding: E,
|
|
5289
|
+
style: O,
|
|
5290
|
+
rounding: h
|
|
5291
|
+
}), N = fn({
|
|
5292
|
+
left: c,
|
|
5293
|
+
top: l,
|
|
5170
5294
|
canvasCenter: e.editor.canvas.getCenterPoint()
|
|
5171
5295
|
});
|
|
5172
|
-
if (
|
|
5296
|
+
if (M.setPositionByOrigin(N, "center", "center"), M.setCoords(), g) return M;
|
|
5173
5297
|
e._beginMutation();
|
|
5174
5298
|
try {
|
|
5175
|
-
e.editor.canvas.add(
|
|
5299
|
+
e.editor.canvas.add(M), _ || e.editor.canvas.setActiveObject(M), e.editor.canvas.requestRenderAll();
|
|
5176
5300
|
} finally {
|
|
5177
|
-
e._endMutation({ withoutSave:
|
|
5301
|
+
e._endMutation({ withoutSave: v });
|
|
5178
5302
|
}
|
|
5179
|
-
return
|
|
5303
|
+
return M;
|
|
5180
5304
|
}).apply(this, arguments);
|
|
5181
5305
|
}
|
|
5182
5306
|
update() {
|
|
@@ -5187,23 +5311,25 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5187
5311
|
if (!d) return null;
|
|
5188
5312
|
let f = Dt({ presetKey: (i = n == null ? d.shapePresetKey : n) == null ? St : i });
|
|
5189
5313
|
if (!f) return null;
|
|
5190
|
-
let { width: p, height: m,
|
|
5314
|
+
let { width: p, height: m, shapeTextAutoExpand: h, text: g, textStyle: _, alignH: v, alignV: y, textPadding: b, rounding: x, withoutSelection: S, withoutSave: C } = r, w = e._resolveCurrentDimensions({ group: d }), T = Math.max(1, m == null ? w.height : m), E = e._isShapeTextAutoExpandEnabled({ group: d }), O = h === void 0 ? E : h !== !1, k = (a = x == null ? d.shapeRounding : x) == null ? 0 : a, A = (o = Dt({ presetKey: Ot({
|
|
5191
5315
|
preset: f,
|
|
5192
|
-
rounding:
|
|
5193
|
-
}) })) == null ? f : o,
|
|
5194
|
-
preset:
|
|
5195
|
-
overridePadding:
|
|
5196
|
-
}),
|
|
5316
|
+
rounding: k
|
|
5317
|
+
}) })) == null ? f : o, j = (s = v == null ? d.shapeAlignHorizontal : v) == null ? Ct : s, M = (c = y == null ? d.shapeAlignVertical : y) == null ? wt : c, N = e._resolveGroupPadding({ group: d }), ee = kt({
|
|
5318
|
+
preset: A,
|
|
5319
|
+
overridePadding: b == null ? N : b
|
|
5320
|
+
}), P = e._resolveShapeStyle({
|
|
5197
5321
|
options: r,
|
|
5198
5322
|
fallback: d
|
|
5199
|
-
}),
|
|
5200
|
-
|
|
5201
|
-
let
|
|
5323
|
+
}), F = Math.max(1, (l = d.shapeManualBaseWidth) == null ? w.width : l);
|
|
5324
|
+
p !== void 0 && (F = Math.max(1, p)), p === void 0 && E && !O && (F = Math.max(1, w.width));
|
|
5325
|
+
let I = Math.max(1, (u = m == null ? d.shapeManualBaseHeight : m) == null ? T : u), L = e.editingController.resolveGroupInteractionState({ group: d }), te = d.getCenterPoint(), { id: R, angle: z = 0, customData: ne, flipX: B = !1, flipY: re = !1, lockRotation: V = !1, lockScalingX: ie = !1, lockScalingY: ae = !1, lockSkewingX: oe = !1, lockSkewingY: H = !1, locked: se = !1 } = d, { selectable: ce, evented: le, lockMovementX: ue, lockMovementY: U } = L, { text: W } = er({ group: d });
|
|
5326
|
+
if (!W) return null;
|
|
5327
|
+
let de = d.removeAll(), fe = e._findTextNode({
|
|
5202
5328
|
objects: de,
|
|
5203
|
-
fallback:
|
|
5329
|
+
fallback: W
|
|
5204
5330
|
});
|
|
5205
|
-
if (!
|
|
5206
|
-
|
|
5331
|
+
if (!fe) return null;
|
|
5332
|
+
fe.set({
|
|
5207
5333
|
angle: 0,
|
|
5208
5334
|
skewX: 0,
|
|
5209
5335
|
skewY: 0,
|
|
@@ -5217,56 +5343,64 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5217
5343
|
originX: "left",
|
|
5218
5344
|
originY: "top"
|
|
5219
5345
|
}), e._applyTextUpdates({
|
|
5220
|
-
textNode:
|
|
5221
|
-
text:
|
|
5222
|
-
textStyle:
|
|
5223
|
-
align:
|
|
5346
|
+
textNode: fe,
|
|
5347
|
+
text: g,
|
|
5348
|
+
textStyle: _,
|
|
5349
|
+
align: j
|
|
5224
5350
|
});
|
|
5225
|
-
let
|
|
5226
|
-
|
|
5227
|
-
|
|
5351
|
+
let pe = e._resolveShapeLayoutWidth({
|
|
5352
|
+
text: fe,
|
|
5353
|
+
currentWidth: w.width,
|
|
5354
|
+
manualWidth: F,
|
|
5355
|
+
shapeTextAutoExpandEnabled: O,
|
|
5356
|
+
padding: ee,
|
|
5357
|
+
strokeWidth: P.strokeWidth
|
|
5358
|
+
}), me = yield Ft({
|
|
5359
|
+
preset: A,
|
|
5360
|
+
width: pe,
|
|
5228
5361
|
height: T,
|
|
5229
|
-
style:
|
|
5230
|
-
rounding:
|
|
5231
|
-
}),
|
|
5232
|
-
id:
|
|
5233
|
-
presetKey:
|
|
5234
|
-
presetCanRound: At({ preset:
|
|
5235
|
-
shape:
|
|
5236
|
-
text:
|
|
5237
|
-
width:
|
|
5362
|
+
style: P,
|
|
5363
|
+
rounding: k
|
|
5364
|
+
}), he = e._createShapeGroup({
|
|
5365
|
+
id: R == null ? `shape-${D()}` : R,
|
|
5366
|
+
presetKey: A.key,
|
|
5367
|
+
presetCanRound: At({ preset: A }),
|
|
5368
|
+
shape: me,
|
|
5369
|
+
text: fe,
|
|
5370
|
+
width: pe,
|
|
5238
5371
|
height: T,
|
|
5239
|
-
manualWidth:
|
|
5240
|
-
manualHeight:
|
|
5241
|
-
|
|
5242
|
-
|
|
5243
|
-
|
|
5244
|
-
|
|
5245
|
-
|
|
5372
|
+
manualWidth: F,
|
|
5373
|
+
manualHeight: I,
|
|
5374
|
+
shapeTextAutoExpand: O,
|
|
5375
|
+
alignH: j,
|
|
5376
|
+
alignV: M,
|
|
5377
|
+
padding: ee,
|
|
5378
|
+
style: P,
|
|
5379
|
+
rounding: k
|
|
5246
5380
|
});
|
|
5247
|
-
if (
|
|
5248
|
-
angle:
|
|
5249
|
-
customData:
|
|
5250
|
-
evented:
|
|
5251
|
-
flipX:
|
|
5252
|
-
flipY:
|
|
5253
|
-
lockMovementX:
|
|
5254
|
-
lockMovementY:
|
|
5255
|
-
lockRotation:
|
|
5256
|
-
lockScalingX:
|
|
5257
|
-
lockScalingY:
|
|
5258
|
-
lockSkewingX:
|
|
5259
|
-
lockSkewingY:
|
|
5260
|
-
locked:
|
|
5261
|
-
selectable:
|
|
5262
|
-
}),
|
|
5381
|
+
if (he.set({
|
|
5382
|
+
angle: z,
|
|
5383
|
+
customData: ne,
|
|
5384
|
+
evented: le,
|
|
5385
|
+
flipX: B,
|
|
5386
|
+
flipY: re,
|
|
5387
|
+
lockMovementX: ue,
|
|
5388
|
+
lockMovementY: U,
|
|
5389
|
+
lockRotation: V,
|
|
5390
|
+
lockScalingX: ie,
|
|
5391
|
+
lockScalingY: ae,
|
|
5392
|
+
lockSkewingX: oe,
|
|
5393
|
+
lockSkewingY: H,
|
|
5394
|
+
locked: se,
|
|
5395
|
+
selectable: ce
|
|
5396
|
+
}), he.setPositionByOrigin(te, "center", "center"), he.setCoords(), !e._isOnCanvas({ object: d })) return he;
|
|
5263
5397
|
e._beginMutation();
|
|
5264
5398
|
try {
|
|
5265
|
-
e.editor.canvas.remove(d), e.editor.canvas.add(
|
|
5399
|
+
e.editor.canvas.remove(d), e.editor.canvas.add(he), S || e.editor.canvas.setActiveObject(he), e.editor.canvas.requestRenderAll();
|
|
5266
5400
|
} finally {
|
|
5267
|
-
e._endMutation({ withoutSave:
|
|
5401
|
+
e._endMutation({ withoutSave: C });
|
|
5268
5402
|
}
|
|
5269
|
-
return
|
|
5403
|
+
return he;
|
|
5270
5404
|
}).apply(this, arguments);
|
|
5271
5405
|
}
|
|
5272
5406
|
remove({ target: e, withoutSave: t } = {}) {
|
|
@@ -5283,7 +5417,7 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5283
5417
|
setFill({ target: e, fill: t, withoutSave: n }) {
|
|
5284
5418
|
let r = this._resolveShapeGroup({ target: e });
|
|
5285
5419
|
if (!r) return null;
|
|
5286
|
-
let { shape: i } =
|
|
5420
|
+
let { shape: i } = er({ group: r });
|
|
5287
5421
|
if (!i) return null;
|
|
5288
5422
|
this._beginMutation();
|
|
5289
5423
|
try {
|
|
@@ -5299,7 +5433,7 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5299
5433
|
setStroke({ target: e, stroke: t, strokeWidth: n, dash: r, withoutSave: i }) {
|
|
5300
5434
|
let a = this._resolveShapeGroup({ target: e });
|
|
5301
5435
|
if (!a) return null;
|
|
5302
|
-
let { shape: o, text: s } =
|
|
5436
|
+
let { shape: o, text: s } = er({ group: a });
|
|
5303
5437
|
if (!o) return null;
|
|
5304
5438
|
this._beginMutation();
|
|
5305
5439
|
try {
|
|
@@ -5323,7 +5457,7 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5323
5457
|
setOpacity({ target: e, opacity: t, withoutSave: n }) {
|
|
5324
5458
|
let r = this._resolveShapeGroup({ target: e });
|
|
5325
5459
|
if (!r) return null;
|
|
5326
|
-
let { shape: i, text: a } =
|
|
5460
|
+
let { shape: i, text: a } = er({ group: r });
|
|
5327
5461
|
if (!i) return null;
|
|
5328
5462
|
this._beginMutation();
|
|
5329
5463
|
try {
|
|
@@ -5339,13 +5473,13 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5339
5473
|
getTextNode({ target: e } = {}) {
|
|
5340
5474
|
let t = this._resolveShapeGroup({ target: e });
|
|
5341
5475
|
if (!t) return null;
|
|
5342
|
-
let { text: n } =
|
|
5476
|
+
let { text: n } = er({ group: t });
|
|
5343
5477
|
return n || null;
|
|
5344
5478
|
}
|
|
5345
5479
|
updateTextStyle({ target: e, style: t = {}, withoutSave: n } = {}) {
|
|
5346
5480
|
let r = this._resolveShapeGroup({ target: e });
|
|
5347
5481
|
if (!r) return null;
|
|
5348
|
-
let { shape: i, text: a } =
|
|
5482
|
+
let { shape: i, text: a } = er({ group: r });
|
|
5349
5483
|
if (!i || !a) return null;
|
|
5350
5484
|
if (!(Object.keys(t).length > 0)) return r;
|
|
5351
5485
|
let o = this._resolveManualDimensions({ group: r }), s = r.getCenterPoint(), c = this._resolveShapeTextHorizontalAlign({
|
|
@@ -5366,7 +5500,6 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5366
5500
|
x: s.x,
|
|
5367
5501
|
y: s.y
|
|
5368
5502
|
},
|
|
5369
|
-
width: o.width,
|
|
5370
5503
|
height: o.height,
|
|
5371
5504
|
alignH: c
|
|
5372
5505
|
}), this.editor.canvas.requestRenderAll();
|
|
@@ -5379,7 +5512,7 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5379
5512
|
var i, a;
|
|
5380
5513
|
let o = this._resolveShapeGroup({ target: e });
|
|
5381
5514
|
if (!o) return null;
|
|
5382
|
-
let { shape: s, text: c } =
|
|
5515
|
+
let { shape: s, text: c } = er({ group: o });
|
|
5383
5516
|
if (!s || !c) return null;
|
|
5384
5517
|
let l = this._resolveCurrentDimensions({ group: o }), u = (i = t == null ? o.shapeAlignHorizontal : t) == null ? Ct : i, d = (a = n == null ? o.shapeAlignVertical : n) == null ? wt : a, f = this._resolveGroupPadding({ group: o });
|
|
5385
5518
|
this._beginMutation();
|
|
@@ -5429,9 +5562,9 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5429
5562
|
let { canvas: e } = this.editor;
|
|
5430
5563
|
e.on("object:scaling", this._handleObjectScaling), e.on("object:modified", this._handleObjectModified), e.on("mouse:move", this._handleMouseMove), e.on("mouse:down", this._handleMouseDown), e.on("text:editing:entered", this._handleTextEditingEntered), e.on("text:editing:exited", this._handleTextEditingExited), e.on("text:changed", this._handleTextChanged), e.on("editor:before:text-updated", this._handleBeforeTextUpdated);
|
|
5431
5564
|
}
|
|
5432
|
-
_createShapeGroup({ id: e, presetKey: t, presetCanRound: n, shape: r, text: i, width: a, height: o, manualWidth: s, manualHeight: c,
|
|
5433
|
-
var
|
|
5434
|
-
let
|
|
5565
|
+
_createShapeGroup({ id: e, presetKey: t, presetCanRound: n, shape: r, text: i, width: a, height: o, manualWidth: s, manualHeight: c, shapeTextAutoExpand: l, alignH: u, alignV: d, padding: f, style: p, rounding: m }) {
|
|
5566
|
+
var h;
|
|
5567
|
+
let g = new Yn([r, i], {
|
|
5435
5568
|
id: e,
|
|
5436
5569
|
originX: "center",
|
|
5437
5570
|
originY: "center",
|
|
@@ -5440,41 +5573,42 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5440
5573
|
lockScalingFlip: !0,
|
|
5441
5574
|
centeredScaling: !1,
|
|
5442
5575
|
objectCaching: !1
|
|
5443
|
-
}),
|
|
5444
|
-
return
|
|
5576
|
+
}), _ = p.strokeDashArray ? p.strokeDashArray.slice() : (h = p.strokeDashArray) == null ? null : h;
|
|
5577
|
+
return g.set({
|
|
5445
5578
|
shapeComposite: !0,
|
|
5446
5579
|
shapePresetKey: t,
|
|
5447
5580
|
shapeBaseWidth: a,
|
|
5448
5581
|
shapeBaseHeight: o,
|
|
5449
5582
|
shapeManualBaseWidth: Math.max(1, s == null ? a : s),
|
|
5450
5583
|
shapeManualBaseHeight: Math.max(1, c == null ? o : c),
|
|
5451
|
-
|
|
5452
|
-
|
|
5453
|
-
|
|
5454
|
-
|
|
5455
|
-
|
|
5456
|
-
|
|
5457
|
-
|
|
5458
|
-
|
|
5459
|
-
|
|
5460
|
-
|
|
5461
|
-
|
|
5462
|
-
|
|
5584
|
+
shapeTextAutoExpand: l,
|
|
5585
|
+
shapeAlignHorizontal: u,
|
|
5586
|
+
shapeAlignVertical: d,
|
|
5587
|
+
shapePaddingTop: f.top,
|
|
5588
|
+
shapePaddingRight: f.right,
|
|
5589
|
+
shapePaddingBottom: f.bottom,
|
|
5590
|
+
shapePaddingLeft: f.left,
|
|
5591
|
+
shapeFill: p.fill,
|
|
5592
|
+
shapeStroke: p.stroke,
|
|
5593
|
+
shapeStrokeWidth: p.strokeWidth,
|
|
5594
|
+
shapeStrokeDashArray: _,
|
|
5595
|
+
shapeOpacity: p.opacity,
|
|
5596
|
+
shapeRounding: Math.max(0, m == null ? 0 : m),
|
|
5463
5597
|
shapeCanRound: n
|
|
5464
|
-
}),
|
|
5465
|
-
group:
|
|
5598
|
+
}), g.rehydrateRuntimeState(), tr({ group: g }), Pn({ text: i }), on({
|
|
5599
|
+
group: g,
|
|
5466
5600
|
shape: r,
|
|
5467
5601
|
text: i,
|
|
5468
5602
|
width: a,
|
|
5469
5603
|
height: o,
|
|
5470
|
-
alignH:
|
|
5471
|
-
alignV:
|
|
5472
|
-
padding:
|
|
5473
|
-
}), this._detachShapeGroupAutoLayout({ group:
|
|
5604
|
+
alignH: u,
|
|
5605
|
+
alignV: d,
|
|
5606
|
+
padding: f
|
|
5607
|
+
}), this._detachShapeGroupAutoLayout({ group: g }), g;
|
|
5474
5608
|
}
|
|
5475
5609
|
_createTextNode({ text: e, textStyle: t, width: n, align: r, opacity: i }) {
|
|
5476
5610
|
var a;
|
|
5477
|
-
let o = t == null ? {} : t, s =
|
|
5611
|
+
let o = t == null ? {} : t, s = U(U({}, o), {}, {
|
|
5478
5612
|
text: (a = e == null ? o.text : e) == null ? "" : a,
|
|
5479
5613
|
align: r,
|
|
5480
5614
|
autoExpand: !1,
|
|
@@ -5492,7 +5626,7 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5492
5626
|
return c.set({
|
|
5493
5627
|
shapeNodeType: "text",
|
|
5494
5628
|
splitByGrapheme: !1
|
|
5495
|
-
}),
|
|
5629
|
+
}), Pn({ text: c }), c;
|
|
5496
5630
|
}
|
|
5497
5631
|
_applyTextUpdates({ textNode: e, text: t, textStyle: n, align: r }) {
|
|
5498
5632
|
let i = {};
|
|
@@ -5541,6 +5675,37 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5541
5675
|
left: (i = e.shapePaddingLeft) == null ? .2 : i
|
|
5542
5676
|
};
|
|
5543
5677
|
}
|
|
5678
|
+
_isShapeTextAutoExpandEnabled({ group: e }) {
|
|
5679
|
+
return e.shapeTextAutoExpand !== !1;
|
|
5680
|
+
}
|
|
5681
|
+
_resolveMontageAreaWidth() {
|
|
5682
|
+
var e;
|
|
5683
|
+
let { montageArea: t } = this.editor;
|
|
5684
|
+
if (!t) return null;
|
|
5685
|
+
t.setCoords();
|
|
5686
|
+
let n = (e = t.getBoundingRect().width) == null ? 0 : e;
|
|
5687
|
+
return !Number.isFinite(n) || n <= 0 ? null : n;
|
|
5688
|
+
}
|
|
5689
|
+
_resolveAutoExpandShapeWidth({ text: e, currentWidth: t, minimumWidth: n, padding: r, strokeWidth: i }) {
|
|
5690
|
+
let a = this._resolveMontageAreaWidth();
|
|
5691
|
+
return a ? sn({
|
|
5692
|
+
text: e,
|
|
5693
|
+
currentWidth: t,
|
|
5694
|
+
minimumWidth: n,
|
|
5695
|
+
padding: r,
|
|
5696
|
+
strokeWidth: i,
|
|
5697
|
+
montageAreaWidth: a
|
|
5698
|
+
}) : Math.max(1, t, n);
|
|
5699
|
+
}
|
|
5700
|
+
_resolveShapeLayoutWidth({ text: e, currentWidth: t, manualWidth: n, shapeTextAutoExpandEnabled: r, padding: i, strokeWidth: a }) {
|
|
5701
|
+
return r ? this._resolveAutoExpandShapeWidth({
|
|
5702
|
+
text: e,
|
|
5703
|
+
currentWidth: t,
|
|
5704
|
+
minimumWidth: n,
|
|
5705
|
+
padding: i,
|
|
5706
|
+
strokeWidth: a
|
|
5707
|
+
}) : Math.max(1, n);
|
|
5708
|
+
}
|
|
5544
5709
|
_resolveShapeTextHorizontalAlign({ group: e, textStyle: t }) {
|
|
5545
5710
|
var n;
|
|
5546
5711
|
let r = t == null ? void 0 : t.align;
|
|
@@ -5548,28 +5713,37 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5548
5713
|
}
|
|
5549
5714
|
_applyCurrentLayout({ group: e, shape: t, text: n, center: r, width: i, height: a, alignH: o, alignV: s }) {
|
|
5550
5715
|
var c, l;
|
|
5551
|
-
let u = this._resolveCurrentDimensions({ group: e }), d =
|
|
5552
|
-
|
|
5553
|
-
|
|
5716
|
+
let u = this._resolveCurrentDimensions({ group: e }), d = this._resolveManualDimensions({ group: e }), f = this._resolveGroupPadding({ group: e }), p = u.width;
|
|
5717
|
+
p = i === void 0 ? this._resolveShapeLayoutWidth({
|
|
5718
|
+
text: n,
|
|
5719
|
+
currentWidth: u.width,
|
|
5720
|
+
manualWidth: d.width,
|
|
5721
|
+
shapeTextAutoExpandEnabled: this._isShapeTextAutoExpandEnabled({ group: e }),
|
|
5722
|
+
padding: f,
|
|
5723
|
+
strokeWidth: e.shapeStrokeWidth
|
|
5724
|
+
}) : Math.max(1, i);
|
|
5725
|
+
let m = Math.max(1, a == null ? u.height : a), h = e.getCenterPoint(), g = r == null ? {
|
|
5726
|
+
x: h.x,
|
|
5727
|
+
y: h.y
|
|
5554
5728
|
} : r;
|
|
5555
5729
|
on({
|
|
5556
5730
|
group: e,
|
|
5557
5731
|
shape: t,
|
|
5558
5732
|
text: n,
|
|
5559
|
-
width:
|
|
5560
|
-
height:
|
|
5733
|
+
width: p,
|
|
5734
|
+
height: m,
|
|
5561
5735
|
alignH: (c = o == null ? e.shapeAlignHorizontal : o) == null ? Ct : c,
|
|
5562
5736
|
alignV: (l = s == null ? e.shapeAlignVertical : s) == null ? wt : l,
|
|
5563
|
-
padding:
|
|
5737
|
+
padding: f
|
|
5564
5738
|
}), e.set({
|
|
5565
|
-
left:
|
|
5566
|
-
top:
|
|
5739
|
+
left: g.x,
|
|
5740
|
+
top: g.y
|
|
5567
5741
|
}), e.setCoords();
|
|
5568
5742
|
}
|
|
5569
5743
|
_syncShapeTextLayoutAfterTextMutation({ textNode: e, textStyle: t }) {
|
|
5570
5744
|
let { group: n } = e;
|
|
5571
5745
|
if (!Y(n)) return !1;
|
|
5572
|
-
let { shape: r, text: i } =
|
|
5746
|
+
let { shape: r, text: i } = er({ group: n });
|
|
5573
5747
|
if (!r || !i) return !1;
|
|
5574
5748
|
this._detachShapeGroupAutoLayout({ group: n });
|
|
5575
5749
|
let a = this._resolveEditingCenter({ group: n }), o = this._resolveManualDimensions({ group: n }), s = this._resolveShapeTextHorizontalAlign({
|
|
@@ -5581,7 +5755,6 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5581
5755
|
shape: r,
|
|
5582
5756
|
text: i,
|
|
5583
5757
|
center: a,
|
|
5584
|
-
width: o.width,
|
|
5585
5758
|
height: o.height,
|
|
5586
5759
|
alignH: s
|
|
5587
5760
|
}), !0;
|
|
@@ -5596,7 +5769,7 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5596
5769
|
};
|
|
5597
5770
|
}
|
|
5598
5771
|
_detachShapeGroupAutoLayout({ group: e }) {
|
|
5599
|
-
|
|
5772
|
+
Fn({ group: e });
|
|
5600
5773
|
}
|
|
5601
5774
|
_resolveHorizontalAlign({ explicitAlign: e, textStyle: t }) {
|
|
5602
5775
|
if (e) return e;
|
|
@@ -5607,11 +5780,11 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5607
5780
|
var n, r, i, a;
|
|
5608
5781
|
let { fill: o, stroke: s, strokeWidth: c, strokeDashArray: l, opacity: u } = e, d = l === void 0 ? t == null ? void 0 : t.shapeStrokeDashArray : l;
|
|
5609
5782
|
return {
|
|
5610
|
-
fill: (n = o == null ? t == null ? void 0 : t.shapeFill : o) == null ?
|
|
5783
|
+
fill: (n = o == null ? t == null ? void 0 : t.shapeFill : o) == null ? _r : n,
|
|
5611
5784
|
stroke: (r = s == null ? t == null ? void 0 : t.shapeStroke : s) == null ? null : r,
|
|
5612
|
-
strokeWidth: (i = c == null ? t == null ? void 0 : t.shapeStrokeWidth : c) == null ?
|
|
5785
|
+
strokeWidth: (i = c == null ? t == null ? void 0 : t.shapeStrokeWidth : c) == null ? vr : i,
|
|
5613
5786
|
strokeDashArray: d == null ? null : d,
|
|
5614
|
-
opacity: (a = u == null ? t == null ? void 0 : t.shapeOpacity : u) == null ?
|
|
5787
|
+
opacity: (a = u == null ? t == null ? void 0 : t.shapeOpacity : u) == null ? yr : a
|
|
5615
5788
|
};
|
|
5616
5789
|
}
|
|
5617
5790
|
_findTextNode({ objects: e, fallback: t }) {
|
|
@@ -5654,7 +5827,7 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5654
5827
|
}
|
|
5655
5828
|
return null;
|
|
5656
5829
|
}
|
|
5657
|
-
},
|
|
5830
|
+
}, xr = class {
|
|
5658
5831
|
constructor({ editor: e }) {
|
|
5659
5832
|
this.editor = e, this.clipboard = null;
|
|
5660
5833
|
}
|
|
@@ -5800,7 +5973,7 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5800
5973
|
var n = this;
|
|
5801
5974
|
return k(function* () {
|
|
5802
5975
|
var r;
|
|
5803
|
-
let i =
|
|
5976
|
+
let i = U(U({ source: e }, t), {}, { fromClipboard: !0 }), a = yield n.editor.imageManager.importImage(i), o = a == null ? void 0 : a.image, s = (r = a == null ? void 0 : a.source) == null ? e : r;
|
|
5804
5977
|
o && n.editor.canvas.fire("editor:object-pasted", {
|
|
5805
5978
|
imageSource: s,
|
|
5806
5979
|
fromInternalClipboard: !1,
|
|
@@ -5923,7 +6096,7 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5923
6096
|
}
|
|
5924
6097
|
})();
|
|
5925
6098
|
}
|
|
5926
|
-
},
|
|
6099
|
+
}, Sr = class t {
|
|
5927
6100
|
constructor({ editor: e }) {
|
|
5928
6101
|
this.editor = e;
|
|
5929
6102
|
}
|
|
@@ -5973,7 +6146,7 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5973
6146
|
static _isGroupOrSelection(t) {
|
|
5974
6147
|
return t instanceof e || t instanceof l;
|
|
5975
6148
|
}
|
|
5976
|
-
},
|
|
6149
|
+
}, Cr = class {
|
|
5977
6150
|
constructor({ editor: e }) {
|
|
5978
6151
|
this.editor = e;
|
|
5979
6152
|
}
|
|
@@ -6039,7 +6212,7 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6039
6212
|
i.resumeHistory(), n || i.saveState();
|
|
6040
6213
|
}
|
|
6041
6214
|
}
|
|
6042
|
-
},
|
|
6215
|
+
}, wr = class t {
|
|
6043
6216
|
constructor({ editor: e }) {
|
|
6044
6217
|
this.lastSelection = [], this.isCtrlSelectionBoxActive = !1, this.isSelectionMergeInProgress = !1, this.editor = e, this.selectionKey = this._resolveSelectionKey(), this.handleTextEditingEnteredBound = this._handleTextEditingEntered.bind(this), this.handleTextEditingExitedBound = this._handleTextEditingExited.bind(this), this.handleLockedSelectionBound = this._filterLockedSelection.bind(this), this.handleSelectionMergeBound = this._handleSelectionMerge.bind(this), this.handleSelectionChangeBound = this._handleSelectionChange.bind(this), this.handleSelectionClearedBound = this._handleSelectionCleared.bind(this), this.handleSelectionBoxStartBound = this._handleSelectionBoxStart.bind(this), this.handleSelectionBoxEndBound = this._handleSelectionBoxEnd.bind(this), this._applySelectionKey({ selectionKey: this.selectionKey }), this._bindEvents();
|
|
6045
6218
|
}
|
|
@@ -6233,7 +6406,7 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6233
6406
|
let { options: e } = this.editor, { selectionKey: t } = e;
|
|
6234
6407
|
return t === void 0 ? ["ctrlKey", "metaKey"] : t;
|
|
6235
6408
|
}
|
|
6236
|
-
},
|
|
6409
|
+
}, Tr = class e {
|
|
6237
6410
|
constructor({ editor: e }) {
|
|
6238
6411
|
this.editor = e;
|
|
6239
6412
|
}
|
|
@@ -6272,7 +6445,7 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6272
6445
|
};
|
|
6273
6446
|
return i.fire("editor:objects-deleted", c), c;
|
|
6274
6447
|
}
|
|
6275
|
-
},
|
|
6448
|
+
}, Er = {
|
|
6276
6449
|
IMAGE_MANAGER: {
|
|
6277
6450
|
INVALID_CONTENT_TYPE: "INVALID_CONTENT_TYPE",
|
|
6278
6451
|
INVALID_SOURCE_TYPE: "INVALID_SOURCE_TYPE",
|
|
@@ -6310,7 +6483,7 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6310
6483
|
INVALID_TARGET: "TEMPLATE_INVALID_TARGET",
|
|
6311
6484
|
APPLY_FAILED: "TEMPLATE_APPLY_FAILED"
|
|
6312
6485
|
}
|
|
6313
|
-
},
|
|
6486
|
+
}, Dr = class e {
|
|
6314
6487
|
constructor({ editor: e }) {
|
|
6315
6488
|
this._buffer = [], this.editor = e;
|
|
6316
6489
|
}
|
|
@@ -6339,7 +6512,7 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6339
6512
|
message: o,
|
|
6340
6513
|
data: i
|
|
6341
6514
|
};
|
|
6342
|
-
this._buffer.push(
|
|
6515
|
+
this._buffer.push(U({ type: "editor:error" }, s)), this.editor.canvas.fire("editor:error", s);
|
|
6343
6516
|
}
|
|
6344
6517
|
emitWarning({ origin: t = "ImageEditor", method: n = "Unknown Method", code: r, message: i, data: a }) {
|
|
6345
6518
|
if (!e.isValidErrorCode(r)) {
|
|
@@ -6359,12 +6532,12 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6359
6532
|
message: o,
|
|
6360
6533
|
data: a
|
|
6361
6534
|
};
|
|
6362
|
-
this._buffer.push(
|
|
6535
|
+
this._buffer.push(U({ type: "editor:warning" }, s)), this.editor.canvas.fire("editor:warning", s);
|
|
6363
6536
|
}
|
|
6364
6537
|
static isValidErrorCode(e) {
|
|
6365
|
-
return e ? Object.values(
|
|
6538
|
+
return e ? Object.values(Er).some((t) => Object.values(t).includes(e)) : !1;
|
|
6366
6539
|
}
|
|
6367
|
-
},
|
|
6540
|
+
}, Or = class {
|
|
6368
6541
|
constructor({ editor: e }) {
|
|
6369
6542
|
this.currentBounds = null, this.editor = e;
|
|
6370
6543
|
}
|
|
@@ -6414,7 +6587,7 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6414
6587
|
updateBounds() {
|
|
6415
6588
|
this.currentBounds = this.calculatePanBounds();
|
|
6416
6589
|
}
|
|
6417
|
-
},
|
|
6590
|
+
}, kr = ({ textbox: e }) => {
|
|
6418
6591
|
var t, n;
|
|
6419
6592
|
if (!e.isEditing) return null;
|
|
6420
6593
|
let r = (t = e.selectionStart) == null ? 0 : t, i = (n = e.selectionEnd) == null ? r : n;
|
|
@@ -6422,28 +6595,28 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6422
6595
|
start: Math.min(r, i),
|
|
6423
6596
|
end: Math.max(r, i)
|
|
6424
6597
|
};
|
|
6425
|
-
},
|
|
6598
|
+
}, Ar = ({ textbox: e }) => {
|
|
6426
6599
|
var t, n;
|
|
6427
6600
|
let r = (t = (n = e.text) == null ? void 0 : n.length) == null ? 0 : t;
|
|
6428
6601
|
return r <= 0 ? null : {
|
|
6429
6602
|
start: 0,
|
|
6430
6603
|
end: r
|
|
6431
6604
|
};
|
|
6432
|
-
},
|
|
6605
|
+
}, jr = ({ textbox: e, range: t }) => {
|
|
6433
6606
|
var n, r;
|
|
6434
6607
|
if (!t) return !1;
|
|
6435
6608
|
let i = (n = (r = e.text) == null ? void 0 : r.length) == null ? 0 : n;
|
|
6436
6609
|
return i <= 0 ? !1 : t.start <= 0 && t.end >= i;
|
|
6437
|
-
},
|
|
6610
|
+
}, Mr = ({ textbox: e, styles: t, range: n }) => {
|
|
6438
6611
|
if (!t || !Object.keys(t).length) return !1;
|
|
6439
6612
|
let { start: r, end: i } = n;
|
|
6440
6613
|
return i <= r ? !1 : (e.setSelectionStyles(t, r, i), !0);
|
|
6441
|
-
},
|
|
6614
|
+
}, Nr = ({ textbox: e, range: t, property: n }) => {
|
|
6442
6615
|
var r;
|
|
6443
6616
|
if (!t) return;
|
|
6444
6617
|
let i = e.getSelectionStyles(t.start, t.end, !0);
|
|
6445
6618
|
if (i.length) return (r = i[0]) == null ? void 0 : r[n];
|
|
6446
|
-
},
|
|
6619
|
+
}, Pr = ({ strokeColor: e, width: t }) => t <= 0 ? null : e == null ? "#000000" : e, Fr = ({ width: e = 0 }) => e ? Math.max(0, e) : 0, Ir = ({ value: e }) => typeof e == "string" ? e.toLocaleUpperCase() : "", Lr, Rr = ({ value: e, min: t, max: n }) => Math.min(Math.max(e, t), n), zr = class e extends _ {
|
|
6447
6620
|
constructor(e, t = {}) {
|
|
6448
6621
|
var n, r, i, a, o, s, c, l, u, d;
|
|
6449
6622
|
super(e, t), this.backgroundOpacity = (n = t.backgroundOpacity) == null ? 1 : n, this.lineFontDefaults = (r = t.lineFontDefaults) == null ? void 0 : r, this.paddingTop = (i = t.paddingTop) == null ? 0 : i, this.paddingRight = (a = t.paddingRight) == null ? 0 : a, this.paddingBottom = (o = t.paddingBottom) == null ? 0 : o, this.paddingLeft = (s = t.paddingLeft) == null ? 0 : s, this.radiusTopLeft = (c = t.radiusTopLeft) == null ? 0 : c, this.radiusTopRight = (l = t.radiusTopRight) == null ? 0 : l, this.radiusBottomRight = (u = t.radiusBottomRight) == null ? 0 : u, this.radiusBottomLeft = (d = t.radiusBottomLeft) == null ? 0 : d, this._roundDimensions();
|
|
@@ -6465,13 +6638,13 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6465
6638
|
}
|
|
6466
6639
|
_getTransformedDimensions(e = {}) {
|
|
6467
6640
|
let { width: t, height: n } = this._getBackgroundDimensions();
|
|
6468
|
-
return super._getTransformedDimensions(
|
|
6641
|
+
return super._getTransformedDimensions(U(U({}, e), {}, {
|
|
6469
6642
|
width: t,
|
|
6470
6643
|
height: n
|
|
6471
6644
|
}));
|
|
6472
6645
|
}
|
|
6473
6646
|
toObject(e = []) {
|
|
6474
|
-
return
|
|
6647
|
+
return U(U({}, super.toObject(e)), {}, {
|
|
6475
6648
|
backgroundOpacity: this.backgroundOpacity,
|
|
6476
6649
|
lineFontDefaults: this.lineFontDefaults,
|
|
6477
6650
|
paddingTop: this.paddingTop,
|
|
@@ -6533,7 +6706,7 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6533
6706
|
this._removeShadow(e);
|
|
6534
6707
|
}
|
|
6535
6708
|
_getDecorationColorAt(e, t) {
|
|
6536
|
-
let n = this.getValueOfPropertyAt(e, t, "strokeWidth"), r =
|
|
6709
|
+
let n = this.getValueOfPropertyAt(e, t, "strokeWidth"), r = Fr({ width: typeof n == "number" && Number.isFinite(n) ? n : 0 }), i = this.getValueOfPropertyAt(e, t, "stroke"), a = i == null ? null : Pr({
|
|
6537
6710
|
strokeColor: i,
|
|
6538
6711
|
width: r
|
|
6539
6712
|
});
|
|
@@ -6553,22 +6726,22 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6553
6726
|
var n, r, i, a;
|
|
6554
6727
|
let o = e / 2, s = t / 2, c = Math.min(o, s);
|
|
6555
6728
|
return {
|
|
6556
|
-
bottomLeft:
|
|
6729
|
+
bottomLeft: Rr({
|
|
6557
6730
|
value: (n = this.radiusBottomLeft) == null ? 0 : n,
|
|
6558
6731
|
min: 0,
|
|
6559
6732
|
max: c
|
|
6560
6733
|
}),
|
|
6561
|
-
bottomRight:
|
|
6734
|
+
bottomRight: Rr({
|
|
6562
6735
|
value: (r = this.radiusBottomRight) == null ? 0 : r,
|
|
6563
6736
|
min: 0,
|
|
6564
6737
|
max: c
|
|
6565
6738
|
}),
|
|
6566
|
-
topLeft:
|
|
6739
|
+
topLeft: Rr({
|
|
6567
6740
|
value: (i = this.radiusTopLeft) == null ? 0 : i,
|
|
6568
6741
|
min: 0,
|
|
6569
6742
|
max: c
|
|
6570
6743
|
}),
|
|
6571
|
-
topRight:
|
|
6744
|
+
topRight: Rr({
|
|
6572
6745
|
value: (a = this.radiusTopRight) == null ? 0 : a,
|
|
6573
6746
|
min: 0,
|
|
6574
6747
|
max: c
|
|
@@ -6588,7 +6761,7 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6588
6761
|
var e;
|
|
6589
6762
|
let t = this.backgroundColor;
|
|
6590
6763
|
if (!t) return null;
|
|
6591
|
-
let r =
|
|
6764
|
+
let r = Rr({
|
|
6592
6765
|
value: (e = this.backgroundOpacity) == null ? 1 : e,
|
|
6593
6766
|
min: 0,
|
|
6594
6767
|
max: 1
|
|
@@ -6596,7 +6769,7 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6596
6769
|
try {
|
|
6597
6770
|
i = new n(t);
|
|
6598
6771
|
} catch (e) {
|
|
6599
|
-
return
|
|
6772
|
+
return Dr.emitError({
|
|
6600
6773
|
origin: "BackgroundTextbox",
|
|
6601
6774
|
method: "_getEffectiveBackgroundFill",
|
|
6602
6775
|
code: "INVALID_COLOR_VALUE",
|
|
@@ -6610,19 +6783,19 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6610
6783
|
return i.setAlpha(r), i.toRgba();
|
|
6611
6784
|
}
|
|
6612
6785
|
static _renderRoundedRect({ ctx: e, height: t, left: n, radii: r, top: i, width: a }) {
|
|
6613
|
-
let o = n + a, s = i + t, { topLeft: c, topRight: l, bottomRight: u, bottomLeft: d } = r, f =
|
|
6786
|
+
let o = n + a, s = i + t, { topLeft: c, topRight: l, bottomRight: u, bottomLeft: d } = r, f = Rr({
|
|
6614
6787
|
value: c,
|
|
6615
6788
|
min: 0,
|
|
6616
6789
|
max: a
|
|
6617
|
-
}), p =
|
|
6790
|
+
}), p = Rr({
|
|
6618
6791
|
value: l,
|
|
6619
6792
|
min: 0,
|
|
6620
6793
|
max: a
|
|
6621
|
-
}), m =
|
|
6794
|
+
}), m = Rr({
|
|
6622
6795
|
value: u,
|
|
6623
6796
|
min: 0,
|
|
6624
6797
|
max: a
|
|
6625
|
-
}), h =
|
|
6798
|
+
}), h = Rr({
|
|
6626
6799
|
value: d,
|
|
6627
6800
|
min: 0,
|
|
6628
6801
|
max: a
|
|
@@ -6634,7 +6807,7 @@ var lr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6634
6807
|
n !== e && (this.width = Math.max(0, n)), r !== t && (this.height = Math.max(0, r));
|
|
6635
6808
|
}
|
|
6636
6809
|
};
|
|
6637
|
-
|
|
6810
|
+
Lr = zr, Lr.type = "background-textbox", Lr.cacheProperties = [
|
|
6638
6811
|
...Array.isArray(_.cacheProperties) ? _.cacheProperties : [],
|
|
6639
6812
|
"backgroundColor",
|
|
6640
6813
|
"backgroundOpacity",
|
|
@@ -6647,7 +6820,7 @@ Nr = Fr, Nr.type = "background-textbox", Nr.cacheProperties = [
|
|
|
6647
6820
|
"radiusTopRight",
|
|
6648
6821
|
"radiusBottomRight",
|
|
6649
6822
|
"radiusBottomLeft"
|
|
6650
|
-
],
|
|
6823
|
+
], Lr.stateProperties = [
|
|
6651
6824
|
...Array.isArray(_.stateProperties) ? _.stateProperties : [],
|
|
6652
6825
|
"backgroundColor",
|
|
6653
6826
|
"backgroundOpacity",
|
|
@@ -6661,9 +6834,9 @@ Nr = Fr, Nr.type = "background-textbox", Nr.cacheProperties = [
|
|
|
6661
6834
|
"radiusBottomRight",
|
|
6662
6835
|
"radiusBottomLeft"
|
|
6663
6836
|
];
|
|
6664
|
-
var
|
|
6665
|
-
y != null && y.setClass && y.setClass(
|
|
6666
|
-
},
|
|
6837
|
+
var Br = () => {
|
|
6838
|
+
y != null && y.setClass && y.setClass(zr, "background-textbox");
|
|
6839
|
+
}, Vr = .01, Hr = ({ textbox: e, lineIndices: t, updates: n }) => {
|
|
6667
6840
|
if (!t.length) return !1;
|
|
6668
6841
|
let { fontFamily: r, fontSize: i, fill: a, stroke: o } = n;
|
|
6669
6842
|
if (!(r !== void 0 || i !== void 0 || a !== void 0 || o !== void 0)) return !1;
|
|
@@ -6671,11 +6844,11 @@ var Ir = () => {
|
|
|
6671
6844
|
for (let e = 0; e < t.length; e += 1) {
|
|
6672
6845
|
let n = t[e];
|
|
6673
6846
|
if (!Number.isFinite(n)) continue;
|
|
6674
|
-
let d = u ? c[n] : s == null ? void 0 : s[n], f = d ?
|
|
6675
|
-
r !== void 0 && (d == null ? void 0 : d.fontFamily) !== r && (f.fontFamily = r, p = !0), i !== void 0 && (d == null ? void 0 : d.fontSize) !== i && (f.fontSize = i, p = !0), a !== void 0 && (d == null ? void 0 : d.fill) !== a && (f.fill = a, p = !0), o !== void 0 && (o === null && (d == null ? void 0 : d.stroke) !== void 0 && (delete f.stroke, p = !0), o !== null && (d == null ? void 0 : d.stroke) !== o && (f.stroke = o, p = !0)), p && (u || (c =
|
|
6847
|
+
let d = u ? c[n] : s == null ? void 0 : s[n], f = d ? U({}, d) : {}, p = !1;
|
|
6848
|
+
r !== void 0 && (d == null ? void 0 : d.fontFamily) !== r && (f.fontFamily = r, p = !0), i !== void 0 && (d == null ? void 0 : d.fontSize) !== i && (f.fontSize = i, p = !0), a !== void 0 && (d == null ? void 0 : d.fill) !== a && (f.fill = a, p = !0), o !== void 0 && (o === null && (d == null ? void 0 : d.stroke) !== void 0 && (delete f.stroke, p = !0), o !== null && (d == null ? void 0 : d.stroke) !== o && (f.stroke = o, p = !0)), p && (u || (c = U({}, c), u = !0), c[n] = f, l = !0);
|
|
6676
6849
|
}
|
|
6677
6850
|
return l && (e.lineFontDefaults = c), l;
|
|
6678
|
-
},
|
|
6851
|
+
}, Ur = ({ lineText: e, lineStyles: t, lineDefaults: n }) => {
|
|
6679
6852
|
let r = e.length;
|
|
6680
6853
|
if (r === 0) return {
|
|
6681
6854
|
lineStyles: t,
|
|
@@ -6692,23 +6865,23 @@ var Ir = () => {
|
|
|
6692
6865
|
if (t) for (let e in t) {
|
|
6693
6866
|
if (!Object.prototype.hasOwnProperty.call(t, e)) continue;
|
|
6694
6867
|
let n = Number(e);
|
|
6695
|
-
Number.isInteger(n) && n >= 0 && n < r || (d || (l =
|
|
6868
|
+
Number.isInteger(n) && n >= 0 && n < r || (d || (l = U({}, t), d = !0), l && Object.prototype.hasOwnProperty.call(l, e) && delete l[e], u = !0);
|
|
6696
6869
|
}
|
|
6697
6870
|
for (let e = 0; e < r; e += 1) {
|
|
6698
6871
|
var f;
|
|
6699
6872
|
let n = (f = l) == null ? t : f, r = n ? n[e] : void 0;
|
|
6700
6873
|
if (!r) {
|
|
6701
|
-
l || (l = {}, d = !0), d || (l =
|
|
6874
|
+
l || (l = {}, d = !0), d || (l = U({}, l), d = !0), l[e] = U({}, c), u = !0;
|
|
6702
6875
|
continue;
|
|
6703
6876
|
}
|
|
6704
6877
|
let p = null;
|
|
6705
|
-
i !== void 0 && r.fontFamily === void 0 && (p =
|
|
6878
|
+
i !== void 0 && r.fontFamily === void 0 && (p = U({}, r), p.fontFamily = i), a !== void 0 && r.fontSize === void 0 && (p || (p = U({}, r)), p.fontSize = a), o !== void 0 && r.fill === void 0 && (p || (p = U({}, r)), p.fill = o), s !== void 0 && r.stroke === void 0 && (p || (p = U({}, r)), p.stroke = s), p && (l || (l = {}, d = !0), d || (l = U({}, l), d = !0), l[e] = p, u = !0);
|
|
6706
6879
|
}
|
|
6707
6880
|
return {
|
|
6708
6881
|
lineStyles: l,
|
|
6709
6882
|
changed: u
|
|
6710
6883
|
};
|
|
6711
|
-
},
|
|
6884
|
+
}, Wr = ({ lineFontDefaults: e }) => {
|
|
6712
6885
|
if (!e) return;
|
|
6713
6886
|
let t = {};
|
|
6714
6887
|
for (let n in e) {
|
|
@@ -6716,10 +6889,10 @@ var Ir = () => {
|
|
|
6716
6889
|
let r = Number(n);
|
|
6717
6890
|
if (!Number.isFinite(r)) continue;
|
|
6718
6891
|
let i = e[r];
|
|
6719
|
-
i && (t[r] =
|
|
6892
|
+
i && (t[r] = U({}, i));
|
|
6720
6893
|
}
|
|
6721
6894
|
return t;
|
|
6722
|
-
},
|
|
6895
|
+
}, Gr = ({ lineFontDefaults: e, scale: t }) => {
|
|
6723
6896
|
if (!e || !Number.isFinite(t) || Math.abs(t - 1) < .01) return;
|
|
6724
6897
|
let n = {}, r = !1, i = !1;
|
|
6725
6898
|
for (let a in e) {
|
|
@@ -6728,11 +6901,11 @@ var Ir = () => {
|
|
|
6728
6901
|
if (!Number.isFinite(o)) continue;
|
|
6729
6902
|
let s = e[o];
|
|
6730
6903
|
if (!s) continue;
|
|
6731
|
-
let c =
|
|
6904
|
+
let c = U({}, s);
|
|
6732
6905
|
typeof s.fontSize == "number" && (c.fontSize = Math.max(1, s.fontSize * t), i = !0), n[o] = c, r = !0;
|
|
6733
6906
|
}
|
|
6734
6907
|
if (!(!r || !i)) return n;
|
|
6735
|
-
},
|
|
6908
|
+
}, Kr = ({ textbox: e }) => {
|
|
6736
6909
|
var t;
|
|
6737
6910
|
let n = (t = e.text) == null ? "" : t;
|
|
6738
6911
|
if (!n.length) return [];
|
|
@@ -6746,7 +6919,7 @@ var Ir = () => {
|
|
|
6746
6919
|
});
|
|
6747
6920
|
}
|
|
6748
6921
|
return i;
|
|
6749
|
-
},
|
|
6922
|
+
}, qr = ({ range: e, text: t }) => {
|
|
6750
6923
|
if (!e) return null;
|
|
6751
6924
|
let n = t.length;
|
|
6752
6925
|
if (n <= 0) return null;
|
|
@@ -6755,8 +6928,8 @@ var Ir = () => {
|
|
|
6755
6928
|
start: l,
|
|
6756
6929
|
end: u
|
|
6757
6930
|
};
|
|
6758
|
-
},
|
|
6759
|
-
let n =
|
|
6931
|
+
}, Jr = ({ textbox: e, range: t }) => {
|
|
6932
|
+
let n = Kr({ textbox: e });
|
|
6760
6933
|
if (!n.length) return t;
|
|
6761
6934
|
let { start: r } = t, { end: i } = t;
|
|
6762
6935
|
for (let e = 0; e < n.length; e += 1) {
|
|
@@ -6769,7 +6942,7 @@ var Ir = () => {
|
|
|
6769
6942
|
start: r,
|
|
6770
6943
|
end: i
|
|
6771
6944
|
};
|
|
6772
|
-
},
|
|
6945
|
+
}, Yr = ({ textbox: e, range: t }) => {
|
|
6773
6946
|
var n;
|
|
6774
6947
|
let r = (n = e.text) == null ? "" : n;
|
|
6775
6948
|
if (!r.length) return [];
|
|
@@ -6780,7 +6953,7 @@ var Ir = () => {
|
|
|
6780
6953
|
a > n && i < r && s.push(e), c = r + 1;
|
|
6781
6954
|
}
|
|
6782
6955
|
return s;
|
|
6783
|
-
},
|
|
6956
|
+
}, Xr = ({ textbox: e, range: t }) => {
|
|
6784
6957
|
var n;
|
|
6785
6958
|
let r = (n = e.text) == null ? "" : n;
|
|
6786
6959
|
if (!r.length) return [];
|
|
@@ -6791,34 +6964,34 @@ var Ir = () => {
|
|
|
6791
6964
|
i <= n && a >= r && s.push(e), c = r + 1;
|
|
6792
6965
|
}
|
|
6793
6966
|
return s;
|
|
6794
|
-
},
|
|
6967
|
+
}, Zr = ({ previous: e, next: t }) => {
|
|
6795
6968
|
let n = Math.min(e.length, t.length);
|
|
6796
6969
|
for (let r = 0; r < n; r += 1) if (e[r] !== t[r]) return r;
|
|
6797
6970
|
return n;
|
|
6798
|
-
},
|
|
6971
|
+
}, Qr = ({ text: e, charIndex: t }) => {
|
|
6799
6972
|
let n = Math.max(0, Math.min(t, e.length)), r = 0;
|
|
6800
6973
|
for (let t = 0; t < n; t += 1) e[t] === "\n" && (r += 1);
|
|
6801
6974
|
return r;
|
|
6802
|
-
},
|
|
6975
|
+
}, $r = ({ text: e, lineIndex: t }) => {
|
|
6803
6976
|
if (t <= 0) return 0;
|
|
6804
6977
|
let n = 0;
|
|
6805
6978
|
for (let r = 0; r < e.length; r += 1) if (e[r] === "\n" && (n += 1, n === t)) return r + 1;
|
|
6806
6979
|
return e.length;
|
|
6807
|
-
},
|
|
6980
|
+
}, ei = ({ textbox: e, text: t }) => {
|
|
6808
6981
|
let { textLines: n } = e, r = Array.isArray(n) && n.length > 0 ? n.length : Math.max(t.split("\n").length, 1), i = 0;
|
|
6809
6982
|
for (let t = 0; t < r; t += 1) {
|
|
6810
6983
|
let n = e.getLineWidth(t);
|
|
6811
6984
|
n > i && (i = n);
|
|
6812
6985
|
}
|
|
6813
6986
|
return i;
|
|
6814
|
-
},
|
|
6987
|
+
}, ti = ({ textbox: e, montageLeft: t, montageRight: n }) => {
|
|
6815
6988
|
var r, i, a, o;
|
|
6816
6989
|
e.setCoords();
|
|
6817
6990
|
let s = e.getBoundingRect(!1, !0), c = (r = s.left) == null ? 0 : r, l = c + ((i = s.width) == null ? 0 : i), u = n - t;
|
|
6818
6991
|
if (u > 0 && ((a = s.width) == null ? 0 : a) >= u - .01) return !1;
|
|
6819
6992
|
let d = 0;
|
|
6820
6993
|
return c < t ? d = t - c : l > n && (d = n - l), Math.abs(d) <= .01 ? !1 : (e.set({ left: ((o = e.left) == null ? 0 : o) + d }), !0);
|
|
6821
|
-
},
|
|
6994
|
+
}, ni = ({ rawValue: e, calculatedValue: t }) => typeof e == "number" ? e : typeof t == "number" ? t : 0, ri = ({ stylesList: e }) => {
|
|
6822
6995
|
let t = e.length;
|
|
6823
6996
|
if (!t) return !1;
|
|
6824
6997
|
for (let n = 0; n < t; n += 1) {
|
|
@@ -6828,16 +7001,16 @@ var Ir = () => {
|
|
|
6828
7001
|
if (r !== void 0 || i !== void 0 || a !== void 0 || o !== void 0 || s !== void 0 || c !== void 0) return !0;
|
|
6829
7002
|
}
|
|
6830
7003
|
return !1;
|
|
6831
|
-
},
|
|
6832
|
-
let { width: t, height: n, calcTextWidth: r, calcTextHeight: i } = e, a = typeof r == "function" ? r.call(e) : void 0, o = typeof i == "function" ? i.call(e) : void 0, s =
|
|
7004
|
+
}, ii = ({ textbox: e }) => {
|
|
7005
|
+
let { width: t, height: n, calcTextWidth: r, calcTextHeight: i } = e, a = typeof r == "function" ? r.call(e) : void 0, o = typeof i == "function" ? i.call(e) : void 0, s = ni({
|
|
6833
7006
|
rawValue: t,
|
|
6834
7007
|
calculatedValue: a
|
|
6835
|
-
}), c =
|
|
7008
|
+
}), c = ni({
|
|
6836
7009
|
rawValue: n,
|
|
6837
7010
|
calculatedValue: o
|
|
6838
7011
|
}), l = Number.isFinite(s) ? Math.round(s) : null, u = Number.isFinite(c) ? Math.round(c) : null, d = {};
|
|
6839
7012
|
return l !== null && l !== s && (d.width = Math.max(0, l)), u !== null && u !== c && (d.height = Math.max(0, u)), Object.keys(d).length ? (e.set(d), !0) : !1;
|
|
6840
|
-
},
|
|
7013
|
+
}, ai = [
|
|
6841
7014
|
"id",
|
|
6842
7015
|
"text",
|
|
6843
7016
|
"autoExpand",
|
|
@@ -6863,7 +7036,7 @@ var Ir = () => {
|
|
|
6863
7036
|
"radiusTopRight",
|
|
6864
7037
|
"radiusBottomRight",
|
|
6865
7038
|
"radiusBottomLeft"
|
|
6866
|
-
],
|
|
7039
|
+
], oi = [
|
|
6867
7040
|
"text",
|
|
6868
7041
|
"autoExpand",
|
|
6869
7042
|
"fontFamily",
|
|
@@ -6888,7 +7061,7 @@ var Ir = () => {
|
|
|
6888
7061
|
"radiusTopRight",
|
|
6889
7062
|
"radiusBottomRight",
|
|
6890
7063
|
"radiusBottomLeft"
|
|
6891
|
-
],
|
|
7064
|
+
], si = class t {
|
|
6892
7065
|
constructor({ editor: n }) {
|
|
6893
7066
|
var r;
|
|
6894
7067
|
this._handleTextEditingEntered = (e) => {
|
|
@@ -6909,14 +7082,14 @@ var Ir = () => {
|
|
|
6909
7082
|
if (!t._isTextbox(n) || this.lineDefaultsSyncing.has(n)) return;
|
|
6910
7083
|
let { text: r = "", uppercase: i, autoExpand: a } = n, o = !!i, s = a !== !1, c = r.toLocaleLowerCase();
|
|
6911
7084
|
if (o) {
|
|
6912
|
-
let e =
|
|
7085
|
+
let e = Ir({ value: c });
|
|
6913
7086
|
e !== r && n.set({ text: e }), n.textCaseRaw = c;
|
|
6914
7087
|
} else n.textCaseRaw = r;
|
|
6915
7088
|
a === void 0 && (n.autoExpand = !0);
|
|
6916
7089
|
let l = !1;
|
|
6917
7090
|
s && (l = this._autoExpandTextboxWidth(n));
|
|
6918
7091
|
let u = !1;
|
|
6919
|
-
l || (u =
|
|
7092
|
+
l || (u = ii({ textbox: n })), (l || u) && (n.setCoords(), n.dirty = !0), this._syncLineFontDefaultsOnTextChanged({ textbox: n });
|
|
6920
7093
|
}, this._handleTextEditingExited = (e) => {
|
|
6921
7094
|
var n, r;
|
|
6922
7095
|
let { target: i } = e;
|
|
@@ -6927,7 +7100,7 @@ var Ir = () => {
|
|
|
6927
7100
|
var o;
|
|
6928
7101
|
i.textCaseRaw = (o = i.textCaseRaw) == null ? a.toLocaleLowerCase() : o;
|
|
6929
7102
|
} else i.textCaseRaw = a;
|
|
6930
|
-
|
|
7103
|
+
ii({ textbox: i }) && (i.setCoords(), i.dirty = !0, this.canvas.requestRenderAll()), i.locked || i.set({
|
|
6931
7104
|
lockMovementX: !1,
|
|
6932
7105
|
lockMovementY: !1
|
|
6933
7106
|
});
|
|
@@ -6959,42 +7132,42 @@ var Ir = () => {
|
|
|
6959
7132
|
let { target: g, transform: _ } = n;
|
|
6960
7133
|
if (g instanceof e || !t._isTextbox(g) || !_) return;
|
|
6961
7134
|
g.isScaling = !0;
|
|
6962
|
-
let v = this._ensureScalingState(g), { baseWidth: y, baseLeft: b, baseFontSize: x, basePadding: S, baseRadii: C, baseStyles: w, baseLineFontDefaults: T } = v, E = typeof ((r = _.original) == null ? void 0 : r.width) == "number" ? _.original.width : void 0, D = typeof ((i = _.original) == null ? void 0 : i.left) == "number" ? _.original.left : void 0, O = E == null ? y : E, k = D == null ? b : D, A = (a = _.corner) == null ? "" : a, j = (o = _.action) == null ? "" : o, M = ["ml", "mr"].includes(A) || j === "scaleX", N = ["mt", "mb"].includes(A) || j === "scaleY",
|
|
7135
|
+
let v = this._ensureScalingState(g), { baseWidth: y, baseLeft: b, baseFontSize: x, basePadding: S, baseRadii: C, baseStyles: w, baseLineFontDefaults: T } = v, E = typeof ((r = _.original) == null ? void 0 : r.width) == "number" ? _.original.width : void 0, D = typeof ((i = _.original) == null ? void 0 : i.left) == "number" ? _.original.left : void 0, O = E == null ? y : E, k = D == null ? b : D, A = (a = _.corner) == null ? "" : a, j = (o = _.action) == null ? "" : o, M = ["ml", "mr"].includes(A) || j === "scaleX", N = ["mt", "mb"].includes(A) || j === "scaleY", ee = [
|
|
6963
7136
|
"tl",
|
|
6964
7137
|
"tr",
|
|
6965
7138
|
"bl",
|
|
6966
7139
|
"br"
|
|
6967
|
-
].includes(A) || j === "scale",
|
|
6968
|
-
if (!M && !N && !
|
|
6969
|
-
let
|
|
7140
|
+
].includes(A) || j === "scale", P = ee || N;
|
|
7141
|
+
if (!M && !N && !ee) return;
|
|
7142
|
+
let F = Math.abs((s = (c = g.scaleX) == null ? _.scaleX : c) == null ? 1 : s) || 1, I = Math.abs((l = (u = g.scaleY) == null ? _.scaleY : u) == null ? 1 : l) || 1, L = Math.max(1, O * F), te = Math.max(1, Math.round(L)), R = Math.max(1, x * I), { paddingTop: z = 0, paddingRight: ne = 0, paddingBottom: B = 0, paddingLeft: re = 0, radiusTopLeft: V = 0, radiusTopRight: ie = 0, radiusBottomRight: ae = 0, radiusBottomLeft: oe = 0, fontSize: H, width: se, originX: ce = "left" } = g, le = ee || N, ue = ee || N, W = le ? {
|
|
6970
7143
|
top: Math.max(0, S.top * I),
|
|
6971
7144
|
right: Math.max(0, S.right * I),
|
|
6972
7145
|
bottom: Math.max(0, S.bottom * I),
|
|
6973
7146
|
left: Math.max(0, S.left * I)
|
|
6974
|
-
} : S,
|
|
7147
|
+
} : S, de = ue ? {
|
|
6975
7148
|
topLeft: Math.max(0, C.topLeft * I),
|
|
6976
7149
|
topRight: Math.max(0, C.topRight * I),
|
|
6977
7150
|
bottomRight: Math.max(0, C.bottomRight * I),
|
|
6978
7151
|
bottomLeft: Math.max(0, C.bottomLeft * I)
|
|
6979
7152
|
} : C, fe = Object.keys(w).length > 0, pe;
|
|
6980
|
-
if (
|
|
7153
|
+
if (P && fe) {
|
|
6981
7154
|
let e = {};
|
|
6982
7155
|
Object.entries(w).forEach(([t, n]) => {
|
|
6983
7156
|
if (!n) return;
|
|
6984
7157
|
let r = {};
|
|
6985
7158
|
Object.entries(n).forEach(([e, t]) => {
|
|
6986
7159
|
if (!t) return;
|
|
6987
|
-
let n =
|
|
7160
|
+
let n = U({}, t);
|
|
6988
7161
|
typeof t.fontSize == "number" && (n.fontSize = Math.max(1, t.fontSize * I)), r[e] = n;
|
|
6989
7162
|
}), Object.keys(r).length && (e[t] = r);
|
|
6990
7163
|
}), Object.keys(e).length && (pe = e);
|
|
6991
7164
|
}
|
|
6992
7165
|
let me;
|
|
6993
|
-
|
|
7166
|
+
P && (me = Gr({
|
|
6994
7167
|
lineFontDefaults: T,
|
|
6995
7168
|
scale: I
|
|
6996
7169
|
}));
|
|
6997
|
-
let he = (d = (f = _.originX) == null ?
|
|
7170
|
+
let he = (d = (f = _.originX) == null ? ce : f) == null ? "left" : d, ge = k + O, _e = k + O / 2, ve = se == null ? O : se, ye = te !== ve, be = Math.abs(R - (H == null ? x : H)) > Vr, xe = Math.abs(W.top - z) > .01 || Math.abs(W.right - ne) > .01 || Math.abs(W.bottom - B) > .01 || Math.abs(W.left - re) > .01, Se = Math.abs(de.topLeft - V) > .01 || Math.abs(de.topRight - ie) > .01 || Math.abs(de.bottomRight - ae) > .01 || Math.abs(de.bottomLeft - oe) > .01;
|
|
6998
7171
|
if (!ye && !be && !xe && !Se) {
|
|
6999
7172
|
g.set({
|
|
7000
7173
|
scaleX: 1,
|
|
@@ -7004,33 +7177,33 @@ var Ir = () => {
|
|
|
7004
7177
|
}
|
|
7005
7178
|
pe && (g.styles = pe), me && (g.lineFontDefaults = me), g.set({
|
|
7006
7179
|
width: te,
|
|
7007
|
-
fontSize:
|
|
7008
|
-
paddingTop:
|
|
7009
|
-
paddingRight:
|
|
7010
|
-
paddingBottom:
|
|
7011
|
-
paddingLeft:
|
|
7012
|
-
radiusTopLeft:
|
|
7013
|
-
radiusTopRight:
|
|
7014
|
-
radiusBottomRight:
|
|
7015
|
-
radiusBottomLeft:
|
|
7180
|
+
fontSize: P ? R : x,
|
|
7181
|
+
paddingTop: W.top,
|
|
7182
|
+
paddingRight: W.right,
|
|
7183
|
+
paddingBottom: W.bottom,
|
|
7184
|
+
paddingLeft: W.left,
|
|
7185
|
+
radiusTopLeft: de.topLeft,
|
|
7186
|
+
radiusTopRight: de.topRight,
|
|
7187
|
+
radiusBottomRight: de.bottomRight,
|
|
7188
|
+
radiusBottomLeft: de.bottomLeft,
|
|
7016
7189
|
scaleX: 1,
|
|
7017
7190
|
scaleY: 1
|
|
7018
7191
|
});
|
|
7019
|
-
let Ce =
|
|
7192
|
+
let Ce = ii({ textbox: g });
|
|
7020
7193
|
Ce && (g.dirty = !0);
|
|
7021
7194
|
let we = (p = g.width) == null ? te : p, Te = we !== ve, Ee = k;
|
|
7022
|
-
Te && (M ||
|
|
7195
|
+
Te && (M || ee) && (he === "right" ? Ee = ge - we : he === "center" && (Ee = _e - we / 2)), g.set({ left: Ee }), v.baseLeft = Ee, _.scaleX = 1, _.scaleY = 1;
|
|
7023
7196
|
let { original: De } = _;
|
|
7024
|
-
De && (De.scaleX = 1, De.scaleY = 1, De.width = we, De.height = g.height, De.left = Ee), g.setCoords(), this.canvas.requestRenderAll(), v.baseWidth = we, v.baseFontSize = (m = g.fontSize) == null ? R : m, v.baseStyles = JSON.parse(JSON.stringify((h = g.styles) == null ? {} : h)), v.baseLineFontDefaults =
|
|
7025
|
-
top:
|
|
7026
|
-
right:
|
|
7027
|
-
bottom:
|
|
7028
|
-
left:
|
|
7197
|
+
De && (De.scaleX = 1, De.scaleY = 1, De.width = we, De.height = g.height, De.left = Ee), g.setCoords(), this.canvas.requestRenderAll(), v.baseWidth = we, v.baseFontSize = (m = g.fontSize) == null ? R : m, v.baseStyles = JSON.parse(JSON.stringify((h = g.styles) == null ? {} : h)), v.baseLineFontDefaults = Wr({ lineFontDefaults: g.lineFontDefaults }), v.basePadding = {
|
|
7198
|
+
top: W.top,
|
|
7199
|
+
right: W.right,
|
|
7200
|
+
bottom: W.bottom,
|
|
7201
|
+
left: W.left
|
|
7029
7202
|
}, v.baseRadii = {
|
|
7030
|
-
topLeft:
|
|
7031
|
-
topRight:
|
|
7032
|
-
bottomRight:
|
|
7033
|
-
bottomLeft:
|
|
7203
|
+
topLeft: de.topLeft,
|
|
7204
|
+
topRight: de.topRight,
|
|
7205
|
+
bottomRight: de.bottomRight,
|
|
7206
|
+
bottomLeft: de.bottomLeft
|
|
7034
7207
|
}, v.hasWidthChange = Te || be || xe || Se || Ce;
|
|
7035
7208
|
}, this._handleObjectModified = (n) => {
|
|
7036
7209
|
var r, i, a;
|
|
@@ -7059,16 +7232,16 @@ var Ir = () => {
|
|
|
7059
7232
|
typeof e.fontSize == "number" && (e.fontSize = Math.max(1, e.fontSize * l));
|
|
7060
7233
|
});
|
|
7061
7234
|
}));
|
|
7062
|
-
let S =
|
|
7235
|
+
let S = Gr({
|
|
7063
7236
|
lineFontDefaults: e.lineFontDefaults,
|
|
7064
7237
|
scale: l
|
|
7065
|
-
}), C =
|
|
7238
|
+
}), C = U(U(U({
|
|
7066
7239
|
fontSize: s,
|
|
7067
7240
|
width: c,
|
|
7068
7241
|
scaleX: 1,
|
|
7069
7242
|
scaleY: 1
|
|
7070
7243
|
}, y), b), {}, { styles: x });
|
|
7071
|
-
S && (C.lineFontDefaults = S), e.set(C),
|
|
7244
|
+
S && (C.lineFontDefaults = S), e.set(C), ii({ textbox: e });
|
|
7072
7245
|
}
|
|
7073
7246
|
e.setCoords();
|
|
7074
7247
|
});
|
|
@@ -7098,18 +7271,18 @@ var Ir = () => {
|
|
|
7098
7271
|
scaleX: 1,
|
|
7099
7272
|
scaleY: 1
|
|
7100
7273
|
}), o.setCoords();
|
|
7101
|
-
}, this.editor = n, this.canvas = n.canvas, this.fonts = (r = n.options.fonts) == null ? [] : r, this.scalingState = /* @__PURE__ */ new WeakMap(), this.editingAnchorState = /* @__PURE__ */ new WeakMap(), this.lineDefaultsSyncing = /* @__PURE__ */ new WeakSet(), this.isTextEditingActive = !1, this._bindEvents(),
|
|
7274
|
+
}, this.editor = n, this.canvas = n.canvas, this.fonts = (r = n.options.fonts) == null ? [] : r, this.scalingState = /* @__PURE__ */ new WeakMap(), this.editingAnchorState = /* @__PURE__ */ new WeakMap(), this.lineDefaultsSyncing = /* @__PURE__ */ new WeakSet(), this.isTextEditingActive = !1, this._bindEvents(), Br();
|
|
7102
7275
|
}
|
|
7103
7276
|
addText(e = {}, { withoutSelection: t = !1, withoutSave: n = !1, withoutAdding: r = !1 } = {}) {
|
|
7104
7277
|
var i;
|
|
7105
|
-
let { id: a = `text-${D()}`, text: o = "Новый текст", autoExpand: s = !0, fontFamily: c, fontSize: l = 48, bold: u = !1, italic: d = !1, underline: f = !1, uppercase: p = !1, strikethrough: m = !1, align: h = "left", color: g = "#000000", strokeColor: _, strokeWidth: v = 0, opacity: y = 1, backgroundColor: b, backgroundOpacity: x = 1, paddingTop: S = 0, paddingRight: C = 0, paddingBottom: w = 0, paddingLeft: T = 0, radiusTopLeft: E = 0, radiusTopRight: O = 0, radiusBottomRight: k = 0, radiusBottomLeft: A = 0 } = e, j = ut(e,
|
|
7278
|
+
let { id: a = `text-${D()}`, text: o = "Новый текст", autoExpand: s = !0, fontFamily: c, fontSize: l = 48, bold: u = !1, italic: d = !1, underline: f = !1, uppercase: p = !1, strikethrough: m = !1, align: h = "left", color: g = "#000000", strokeColor: _, strokeWidth: v = 0, opacity: y = 1, backgroundColor: b, backgroundOpacity: x = 1, paddingTop: S = 0, paddingRight: C = 0, paddingBottom: w = 0, paddingLeft: T = 0, radiusTopLeft: E = 0, radiusTopRight: O = 0, radiusBottomRight: k = 0, radiusBottomLeft: A = 0 } = e, j = ut(e, ai), { historyManager: M } = this.editor, { canvas: N } = this;
|
|
7106
7279
|
M.suspendHistory();
|
|
7107
|
-
let
|
|
7280
|
+
let ee = c == null ? this._getDefaultFontFamily() : c, P = Fr({ width: v }), F = Pr({
|
|
7108
7281
|
strokeColor: _,
|
|
7109
|
-
width:
|
|
7110
|
-
}), I =
|
|
7282
|
+
width: P
|
|
7283
|
+
}), I = U({
|
|
7111
7284
|
id: a,
|
|
7112
|
-
fontFamily:
|
|
7285
|
+
fontFamily: ee,
|
|
7113
7286
|
fontSize: l,
|
|
7114
7287
|
fontWeight: u ? "bold" : "normal",
|
|
7115
7288
|
fontStyle: d ? "italic" : "normal",
|
|
@@ -7118,8 +7291,8 @@ var Ir = () => {
|
|
|
7118
7291
|
linethrough: m,
|
|
7119
7292
|
textAlign: h,
|
|
7120
7293
|
fill: g,
|
|
7121
|
-
stroke:
|
|
7122
|
-
strokeWidth:
|
|
7294
|
+
stroke: F,
|
|
7295
|
+
strokeWidth: P,
|
|
7123
7296
|
strokeUniform: !0,
|
|
7124
7297
|
opacity: y,
|
|
7125
7298
|
backgroundColor: b,
|
|
@@ -7132,22 +7305,22 @@ var Ir = () => {
|
|
|
7132
7305
|
radiusTopRight: O,
|
|
7133
7306
|
radiusBottomRight: k,
|
|
7134
7307
|
radiusBottomLeft: A
|
|
7135
|
-
}, j), L = new
|
|
7308
|
+
}, j), L = new zr(o, I);
|
|
7136
7309
|
if (L.autoExpand = s !== !1, L.textCaseRaw = (i = L.text) == null ? "" : i, p) {
|
|
7137
|
-
let e =
|
|
7310
|
+
let e = Ir({ value: L.textCaseRaw });
|
|
7138
7311
|
e !== L.text && L.set({ text: e });
|
|
7139
7312
|
}
|
|
7140
|
-
return
|
|
7313
|
+
return ii({ textbox: L }) && (L.dirty = !0), j.left === void 0 && j.top === void 0 && N.centerObject(L), r || N.add(L), t || N.setActiveObject(L), N.requestRenderAll(), M.resumeHistory(), n || M.saveState(), N.fire("editor:text-added", {
|
|
7141
7314
|
textbox: L,
|
|
7142
|
-
options:
|
|
7315
|
+
options: U(U({}, I), {}, {
|
|
7143
7316
|
text: o,
|
|
7144
7317
|
bold: u,
|
|
7145
7318
|
italic: d,
|
|
7146
7319
|
strikethrough: m,
|
|
7147
7320
|
align: h,
|
|
7148
7321
|
color: g,
|
|
7149
|
-
strokeColor:
|
|
7150
|
-
strokeWidth:
|
|
7322
|
+
strokeColor: F,
|
|
7323
|
+
strokeWidth: P
|
|
7151
7324
|
}),
|
|
7152
7325
|
flags: {
|
|
7153
7326
|
withoutSelection: !!t,
|
|
@@ -7166,116 +7339,116 @@ var Ir = () => {
|
|
|
7166
7339
|
originY: p,
|
|
7167
7340
|
x: m.x,
|
|
7168
7341
|
y: m.y
|
|
7169
|
-
}, { text: g, autoExpand: _, fontFamily: v, fontSize: y, bold: b, italic: x, underline: S, uppercase: C, strikethrough: w, align: T, color: E, strokeColor: D, strokeWidth: O, opacity: k, backgroundColor: A, backgroundOpacity: j, paddingTop: M, paddingRight: N, paddingBottom:
|
|
7342
|
+
}, { text: g, autoExpand: _, fontFamily: v, fontSize: y, bold: b, italic: x, underline: S, uppercase: C, strikethrough: w, align: T, color: E, strokeColor: D, strokeWidth: O, opacity: k, backgroundColor: A, backgroundOpacity: j, paddingTop: M, paddingRight: N, paddingBottom: ee, paddingLeft: P, radiusTopLeft: F, radiusTopRight: I, radiusBottomRight: L, radiusBottomLeft: te } = n, R = U({}, ut(n, oi)), z = a === void 0 ? kr({ textbox: c }) : qr({
|
|
7170
7343
|
text: l,
|
|
7171
7344
|
range: a
|
|
7172
|
-
}), ne = z ?
|
|
7345
|
+
}), ne = z ? Jr({
|
|
7173
7346
|
textbox: c,
|
|
7174
7347
|
range: z
|
|
7175
|
-
}) : null,
|
|
7348
|
+
}) : null, B = {}, re = {}, V = {}, ie, ae, oe = jr({
|
|
7176
7349
|
textbox: c,
|
|
7177
7350
|
range: z
|
|
7178
|
-
}),
|
|
7179
|
-
if (v !== void 0 && (ne && (
|
|
7351
|
+
}), H = !z || oe, se = !z;
|
|
7352
|
+
if (v !== void 0 && (ne && (re.fontFamily = v), H && (R.fontFamily = v, se && (V.fontFamily = v))), y !== void 0 && (ne && (re.fontSize = y), H && (R.fontSize = y, se && (V.fontSize = y))), b !== void 0) {
|
|
7180
7353
|
let e = b ? "bold" : "normal";
|
|
7181
|
-
z && (
|
|
7354
|
+
z && (B.fontWeight = e), H && (R.fontWeight = e, se && (V.fontWeight = e));
|
|
7182
7355
|
}
|
|
7183
7356
|
if (x !== void 0) {
|
|
7184
7357
|
let e = x ? "italic" : "normal";
|
|
7185
|
-
z && (
|
|
7358
|
+
z && (B.fontStyle = e), H && (R.fontStyle = e, se && (V.fontStyle = e));
|
|
7186
7359
|
}
|
|
7187
|
-
if (S !== void 0 && (z && (
|
|
7188
|
-
var le, ue,
|
|
7189
|
-
let e = z ?
|
|
7360
|
+
if (S !== void 0 && (z && (B.underline = S), H && (R.underline = S, se && (V.underline = S))), w !== void 0 && (z && (B.linethrough = w), H && (R.linethrough = w, se && (V.linethrough = w))), T !== void 0 && (R.textAlign = T), E !== void 0 && (z && (B.fill = E), H && (R.fill = E, se && (V.fill = E))), D !== void 0 || O !== void 0) {
|
|
7361
|
+
var ce, le, ue, W;
|
|
7362
|
+
let e = z ? Nr({
|
|
7190
7363
|
textbox: c,
|
|
7191
7364
|
range: z,
|
|
7192
7365
|
property: "strokeWidth"
|
|
7193
|
-
}) : void 0, t = z ?
|
|
7366
|
+
}) : void 0, t = z ? Nr({
|
|
7194
7367
|
textbox: c,
|
|
7195
7368
|
range: z,
|
|
7196
7369
|
property: "stroke"
|
|
7197
7370
|
}) : void 0;
|
|
7198
|
-
|
|
7199
|
-
strokeColor: (
|
|
7200
|
-
width:
|
|
7201
|
-
}), z && (
|
|
7202
|
-
}
|
|
7203
|
-
k !== void 0 && (R.opacity = k), A !== void 0 && (R.backgroundColor = A), j !== void 0 && (R.backgroundOpacity = j), M !== void 0 && (R.paddingTop = M), N !== void 0 && (R.paddingRight = N),
|
|
7204
|
-
let
|
|
7205
|
-
pe || ge ? (R.text = he ?
|
|
7371
|
+
ae = Fr({ width: (ce = (le = O == null ? e : O) == null ? c.strokeWidth : le) == null ? 0 : ce }), ie = Pr({
|
|
7372
|
+
strokeColor: (ue = (W = D == null ? t : D) == null ? c.stroke : W) == null ? void 0 : ue,
|
|
7373
|
+
width: ae
|
|
7374
|
+
}), z && (B.stroke = ie, B.strokeWidth = ae), H && (R.stroke = ie, R.strokeWidth = ae, se && (V.stroke = ie, V.strokeWidth = ae));
|
|
7375
|
+
}
|
|
7376
|
+
k !== void 0 && (R.opacity = k), A !== void 0 && (R.backgroundColor = A), j !== void 0 && (R.backgroundOpacity = j), M !== void 0 && (R.paddingTop = M), N !== void 0 && (R.paddingRight = N), ee !== void 0 && (R.paddingBottom = ee), P !== void 0 && (R.paddingLeft = P), F !== void 0 && (R.radiusTopLeft = F), I !== void 0 && (R.radiusTopRight = I), L !== void 0 && (R.radiusBottomRight = L), te !== void 0 && (R.radiusBottomLeft = te);
|
|
7377
|
+
let de = (s = c.textCaseRaw) == null ? l : s, fe = !!c.uppercase, pe = g !== void 0, me = pe ? g == null ? "" : g : de, he = C == null ? fe : C, ge = he !== fe;
|
|
7378
|
+
pe || ge ? (R.text = he ? Ir({ value: me }) : me, c.textCaseRaw = me) : c.textCaseRaw === void 0 && (c.textCaseRaw = de), c.uppercase = he, c.set(R);
|
|
7206
7379
|
let _e = !1;
|
|
7207
7380
|
if (z) {
|
|
7208
|
-
let e =
|
|
7381
|
+
let e = Mr({
|
|
7209
7382
|
textbox: c,
|
|
7210
|
-
styles:
|
|
7383
|
+
styles: B,
|
|
7211
7384
|
range: z
|
|
7212
|
-
}), t = ne ?
|
|
7385
|
+
}), t = ne ? Mr({
|
|
7213
7386
|
textbox: c,
|
|
7214
|
-
styles:
|
|
7387
|
+
styles: re,
|
|
7215
7388
|
range: ne
|
|
7216
7389
|
}) : !1;
|
|
7217
7390
|
_e = e || t;
|
|
7218
|
-
} else if (Object.keys(
|
|
7219
|
-
let e =
|
|
7220
|
-
e && (_e =
|
|
7391
|
+
} else if (Object.keys(V).length) {
|
|
7392
|
+
let e = Ar({ textbox: c });
|
|
7393
|
+
e && (_e = Mr({
|
|
7221
7394
|
textbox: c,
|
|
7222
|
-
styles:
|
|
7395
|
+
styles: V,
|
|
7223
7396
|
range: e
|
|
7224
7397
|
}));
|
|
7225
7398
|
}
|
|
7226
|
-
let ve = _e &&
|
|
7399
|
+
let ve = _e && ri({ stylesList: [
|
|
7400
|
+
B,
|
|
7227
7401
|
re,
|
|
7228
|
-
|
|
7229
|
-
B
|
|
7402
|
+
V
|
|
7230
7403
|
] });
|
|
7231
7404
|
if (_e && (c.dirty = !0), ne && (v !== void 0 || y !== void 0)) {
|
|
7232
|
-
let e =
|
|
7405
|
+
let e = Yr({
|
|
7233
7406
|
textbox: c,
|
|
7234
7407
|
range: ne
|
|
7235
7408
|
}), t = {};
|
|
7236
|
-
v !== void 0 && (t.fontFamily = v), y !== void 0 && (t.fontSize = y),
|
|
7409
|
+
v !== void 0 && (t.fontFamily = v), y !== void 0 && (t.fontSize = y), Hr({
|
|
7237
7410
|
textbox: c,
|
|
7238
7411
|
lineIndices: e,
|
|
7239
7412
|
updates: t
|
|
7240
7413
|
});
|
|
7241
7414
|
}
|
|
7242
7415
|
if (z && (E !== void 0 || D !== void 0 || O !== void 0)) {
|
|
7243
|
-
let e =
|
|
7416
|
+
let e = Xr({
|
|
7244
7417
|
textbox: c,
|
|
7245
7418
|
range: z
|
|
7246
7419
|
}), t = {};
|
|
7247
|
-
E !== void 0 && (t.fill = E), (D !== void 0 || O !== void 0) && (
|
|
7420
|
+
E !== void 0 && (t.fill = E), (D !== void 0 || O !== void 0) && (ie === null && (t.stroke = null), ie != null && (t.stroke = ie)), Hr({
|
|
7248
7421
|
textbox: c,
|
|
7249
7422
|
lineIndices: e,
|
|
7250
7423
|
updates: t
|
|
7251
7424
|
});
|
|
7252
7425
|
}
|
|
7253
|
-
ve && (c.initDimensions(), c.dirty = !0), (A !== void 0 || j !== void 0 || M !== void 0 || N !== void 0 ||
|
|
7254
|
-
let ye =
|
|
7426
|
+
ve && (c.initDimensions(), c.dirty = !0), (A !== void 0 || j !== void 0 || M !== void 0 || N !== void 0 || ee !== void 0 || P !== void 0 || F !== void 0 || I !== void 0 || L !== void 0 || te !== void 0) && (c.dirty = !0);
|
|
7427
|
+
let ye = ri({ stylesList: [
|
|
7255
7428
|
R,
|
|
7429
|
+
B,
|
|
7256
7430
|
re,
|
|
7257
|
-
|
|
7258
|
-
B
|
|
7431
|
+
V
|
|
7259
7432
|
] }), { autoExpand: be } = c, xe = _ !== void 0, Se = (_ == null ? be : _) !== !1;
|
|
7260
7433
|
xe ? c.autoExpand = _ !== !1 : be === void 0 && (c.autoExpand = !0);
|
|
7261
7434
|
let Ce = Object.prototype.hasOwnProperty.call(R, "width"), we = Se && !Ce && (pe || ge || ye), Te = !1;
|
|
7262
|
-
we && (Te = this._autoExpandTextboxWidth(c, { anchor: h }), Te && (c.dirty = !0)), !Te &&
|
|
7435
|
+
we && (Te = this._autoExpandTextboxWidth(c, { anchor: h }), Te && (c.dirty = !0)), !Te && ii({ textbox: c }) && (c.dirty = !0), c.setCoords();
|
|
7263
7436
|
let Ee = {
|
|
7264
7437
|
withoutSave: !!r,
|
|
7265
7438
|
skipRender: !!i
|
|
7266
|
-
}, De = !!z && Object.keys(
|
|
7439
|
+
}, De = !!z && Object.keys(B).length > 0, Oe = {
|
|
7267
7440
|
textbox: c,
|
|
7268
7441
|
target: e,
|
|
7269
7442
|
style: n,
|
|
7270
7443
|
options: Ee,
|
|
7271
7444
|
updates: R,
|
|
7272
7445
|
selectionRange: z == null ? void 0 : z,
|
|
7273
|
-
selectionStyles: De ?
|
|
7446
|
+
selectionStyles: De ? B : void 0
|
|
7274
7447
|
};
|
|
7275
7448
|
d.fire("editor:before:text-updated", Oe), i || d.requestRenderAll();
|
|
7276
7449
|
let ke = t._getSnapshot(c);
|
|
7277
7450
|
u.resumeHistory(), r || u.saveState();
|
|
7278
|
-
let Ae =
|
|
7451
|
+
let Ae = U(U({}, Oe), {}, {
|
|
7279
7452
|
before: f,
|
|
7280
7453
|
after: ke
|
|
7281
7454
|
});
|
|
@@ -7312,15 +7485,15 @@ var Ir = () => {
|
|
|
7312
7485
|
var t;
|
|
7313
7486
|
let { text: n = "", lineFontDefaults: r, styles: i, fontFamily: a, fontSize: o, fill: s, stroke: c, selectionStart: l, isEditing: u } = e, d = n, f = (t = e.__lineDefaultsPrevText) == null ? d : t, p = f.split("\n"), m = d.split("\n"), h = p.length, g = m.length - h, _ = r, v = !1, y = !1, b = typeof s == "string" ? s : void 0, x = typeof c == "string" ? c : void 0;
|
|
7314
7487
|
if (g !== 0 && r && Object.keys(r).length) {
|
|
7315
|
-
let e =
|
|
7488
|
+
let e = Zr({
|
|
7316
7489
|
previous: f,
|
|
7317
7490
|
next: d
|
|
7318
|
-
}), t =
|
|
7491
|
+
}), t = Qr({
|
|
7319
7492
|
text: f,
|
|
7320
7493
|
charIndex: e
|
|
7321
7494
|
});
|
|
7322
7495
|
if (g > 0) {
|
|
7323
|
-
let n =
|
|
7496
|
+
let n = $r({
|
|
7324
7497
|
text: f,
|
|
7325
7498
|
lineIndex: t
|
|
7326
7499
|
}), i = t + 1;
|
|
@@ -7333,7 +7506,7 @@ var Ir = () => {
|
|
|
7333
7506
|
let n = r[t];
|
|
7334
7507
|
if (!n) continue;
|
|
7335
7508
|
let o = t >= i ? t + g : t;
|
|
7336
|
-
a[o] =
|
|
7509
|
+
a[o] = U({}, n);
|
|
7337
7510
|
}
|
|
7338
7511
|
_ = a, v = !0, y = !0;
|
|
7339
7512
|
}
|
|
@@ -7349,7 +7522,7 @@ var Ir = () => {
|
|
|
7349
7522
|
let t = Number(e);
|
|
7350
7523
|
if (!Number.isFinite(t)) continue;
|
|
7351
7524
|
let n = r[t];
|
|
7352
|
-
n && (t < i && (o[t] =
|
|
7525
|
+
n && (t < i && (o[t] = U({}, n)), t > a && (o[t + g] = U({}, n)));
|
|
7353
7526
|
}
|
|
7354
7527
|
_ = o, v = !0, y = !0;
|
|
7355
7528
|
}
|
|
@@ -7365,21 +7538,21 @@ var Ir = () => {
|
|
|
7365
7538
|
let t = (k = m[e]) == null ? "" : k, n = _ ? _[e] : void 0;
|
|
7366
7539
|
if (n && (D = n), t.length !== 0) {
|
|
7367
7540
|
if (n) {
|
|
7368
|
-
let r =
|
|
7541
|
+
let r = Ur({
|
|
7369
7542
|
lineText: t,
|
|
7370
7543
|
lineStyles: w ? w[e] : void 0,
|
|
7371
7544
|
lineDefaults: n
|
|
7372
7545
|
});
|
|
7373
|
-
r.changed && (w || (w = {}, E = !0), E || (w =
|
|
7546
|
+
r.changed && (w || (w = {}, E = !0), E || (w = U({}, w), E = !0), r.lineStyles && (w[e] = r.lineStyles), !r.lineStyles && w[e] && delete w[e], T = !0);
|
|
7374
7547
|
}
|
|
7375
7548
|
continue;
|
|
7376
7549
|
}
|
|
7377
7550
|
let r = n == null ? D : n, i = {};
|
|
7378
|
-
(r == null ? void 0 : r.fontFamily) === void 0 ? a !== void 0 && (i.fontFamily = a) : i.fontFamily = r.fontFamily, (r == null ? void 0 : r.fontSize) === void 0 ? o !== void 0 && (i.fontSize = o) : i.fontSize = r.fontSize, (r == null ? void 0 : r.fill) === void 0 ? b !== void 0 && (i.fill = b) : i.fill = r.fill, (r == null ? void 0 : r.stroke) === void 0 ? x !== void 0 && (i.stroke = x) : i.stroke = r.stroke, !n && Object.keys(i).length && (_ || (_ = {}, y = !0), y || (_ =
|
|
7551
|
+
(r == null ? void 0 : r.fontFamily) === void 0 ? a !== void 0 && (i.fontFamily = a) : i.fontFamily = r.fontFamily, (r == null ? void 0 : r.fontSize) === void 0 ? o !== void 0 && (i.fontSize = o) : i.fontSize = r.fontSize, (r == null ? void 0 : r.fill) === void 0 ? b !== void 0 && (i.fill = b) : i.fill = r.fill, (r == null ? void 0 : r.stroke) === void 0 ? x !== void 0 && (i.stroke = x) : i.stroke = r.stroke, !n && Object.keys(i).length && (_ || (_ = {}, y = !0), y || (_ = U({}, _), y = !0), _[e] = i, v = !0, D = i), n && (D = n), C !== null && C === e && (O = i);
|
|
7379
7552
|
let s = {};
|
|
7380
7553
|
i.fontFamily !== void 0 && (s.fontFamily = i.fontFamily), i.fontSize !== void 0 && (s.fontSize = i.fontSize), i.fill !== void 0 && (s.fill = i.fill), i.stroke !== void 0 && (s.stroke = i.stroke);
|
|
7381
7554
|
let c = Object.keys(s).length > 0;
|
|
7382
|
-
(c || w && w[e]) && (w || (w = {}, E = !0), E || (w =
|
|
7555
|
+
(c || w && w[e]) && (w || (w = {}, E = !0), E || (w = U({}, w), E = !0), c && (w[e] = { 0: s }), !c && w[e] && delete w[e], T = !0);
|
|
7383
7556
|
}
|
|
7384
7557
|
if (v && _ && (e.lineFontDefaults = _), T && (e.styles = w, e.dirty = !0), O && typeof l == "number") {
|
|
7385
7558
|
let t = {};
|
|
@@ -7407,17 +7580,17 @@ var Ir = () => {
|
|
|
7407
7580
|
if (!Number.isFinite(E) || E <= 0) return !1;
|
|
7408
7581
|
let D = _.split("\n").length, O = !1;
|
|
7409
7582
|
Math.abs(((u = e.width) == null ? 0 : u) - E) > .01 && (e.set({ width: E }), O = !0), e.initDimensions();
|
|
7410
|
-
let { textLines: k } = e, A = Array.isArray(k) && k.length > D, j = Math.ceil(
|
|
7583
|
+
let { textLines: k } = e, A = Array.isArray(k) && k.length > D, j = Math.ceil(ei({
|
|
7411
7584
|
textbox: e,
|
|
7412
7585
|
text: _
|
|
7413
7586
|
})), M = Math.min((d = e.minWidth) == null ? 1 : d, E), N = Math.min(E, Math.max(j, M));
|
|
7414
|
-
A && (N = E), Math.abs(((f = e.width) == null ? 0 : f) - N) > .01 && (e.set({ width: N }), e.initDimensions(), O = !0),
|
|
7415
|
-
let
|
|
7587
|
+
A && (N = E), Math.abs(((f = e.width) == null ? 0 : f) - N) > .01 && (e.set({ width: N }), e.initDimensions(), O = !0), ii({ textbox: e }) && (O = !0), b && (e.setPositionByOrigin(new p(b.x, b.y), "center", x), O = !0);
|
|
7588
|
+
let ee = ti({
|
|
7416
7589
|
textbox: e,
|
|
7417
7590
|
montageLeft: (m = v.left) == null ? 0 : m,
|
|
7418
7591
|
montageRight: ((h = v.left) == null ? 0 : h) + y
|
|
7419
7592
|
});
|
|
7420
|
-
return O ||
|
|
7593
|
+
return O || ee;
|
|
7421
7594
|
}
|
|
7422
7595
|
_ensureEditingAnchorState() {
|
|
7423
7596
|
return this.editingAnchorState || (this.editingAnchorState = /* @__PURE__ */ new WeakMap()), this.editingAnchorState;
|
|
@@ -7444,7 +7617,7 @@ var Ir = () => {
|
|
|
7444
7617
|
bottomLeft: _
|
|
7445
7618
|
},
|
|
7446
7619
|
baseStyles: JSON.parse(JSON.stringify(c)),
|
|
7447
|
-
baseLineFontDefaults:
|
|
7620
|
+
baseLineFontDefaults: Wr({ lineFontDefaults: l }),
|
|
7448
7621
|
hasWidthChange: !1
|
|
7449
7622
|
}, this.scalingState.set(e, t);
|
|
7450
7623
|
}
|
|
@@ -7455,13 +7628,13 @@ var Ir = () => {
|
|
|
7455
7628
|
Object.entries(t).forEach(([t, n]) => {
|
|
7456
7629
|
n != null && (e[t] = n);
|
|
7457
7630
|
});
|
|
7458
|
-
}, { id: n, text: r, textCaseRaw: i, uppercase: a, autoExpand: o, fontFamily: s, fontSize: c, fontWeight: l, fontStyle: u, underline: d, linethrough: f, textAlign: p, fill: m, stroke: h, strokeWidth: g, opacity: _, backgroundColor: v, backgroundOpacity: y, paddingTop: b, paddingRight: x, paddingBottom: S, paddingLeft: C, radiusTopLeft: w, radiusTopRight: T, radiusBottomRight: E, radiusBottomLeft: D, left: O, top: k, width: A, height: j, angle: M, scaleX: N, scaleY:
|
|
7631
|
+
}, { id: n, text: r, textCaseRaw: i, uppercase: a, autoExpand: o, fontFamily: s, fontSize: c, fontWeight: l, fontStyle: u, underline: d, linethrough: f, textAlign: p, fill: m, stroke: h, strokeWidth: g, opacity: _, backgroundColor: v, backgroundOpacity: y, paddingTop: b, paddingRight: x, paddingBottom: S, paddingLeft: C, radiusTopLeft: w, radiusTopRight: T, radiusBottomRight: E, radiusBottomLeft: D, left: O, top: k, width: A, height: j, angle: M, scaleX: N, scaleY: ee } = e, P = {
|
|
7459
7632
|
id: n,
|
|
7460
7633
|
uppercase: !!a,
|
|
7461
7634
|
textAlign: p
|
|
7462
7635
|
};
|
|
7463
7636
|
return t({
|
|
7464
|
-
snapshot:
|
|
7637
|
+
snapshot: P,
|
|
7465
7638
|
entries: {
|
|
7466
7639
|
text: r,
|
|
7467
7640
|
textCaseRaw: i,
|
|
@@ -7492,15 +7665,15 @@ var Ir = () => {
|
|
|
7492
7665
|
height: j,
|
|
7493
7666
|
angle: M,
|
|
7494
7667
|
scaleX: N,
|
|
7495
|
-
scaleY:
|
|
7668
|
+
scaleY: ee
|
|
7496
7669
|
}
|
|
7497
|
-
}),
|
|
7670
|
+
}), P;
|
|
7498
7671
|
}
|
|
7499
7672
|
_getDefaultFontFamily() {
|
|
7500
7673
|
var e, t;
|
|
7501
7674
|
return (e = (t = this.fonts[0]) == null ? void 0 : t.family) == null ? "Arial" : e;
|
|
7502
7675
|
}
|
|
7503
|
-
},
|
|
7676
|
+
}, ci = ({ x1: e, y1: t, x2: n, y2: r }) => (Math.atan2(r - t, n - e) * 180 / Math.PI + 360) % 360, li = (e) => {
|
|
7504
7677
|
if (!e || typeof e != "object") return null;
|
|
7505
7678
|
let { type: t, coords: n, colorStops: r } = e, i = Array.isArray(r) ? r : [], a = i[0], o = i[i.length - 1], s = typeof (a == null ? void 0 : a.color) == "string" ? a.color : void 0, c = typeof (o == null ? void 0 : o.color) == "string" ? o.color : s, l = typeof (a == null ? void 0 : a.offset) == "number" ? a.offset * 100 : void 0, u = typeof (o == null ? void 0 : o.offset) == "number" ? o.offset * 100 : void 0, d = i.map((e) => ({
|
|
7506
7679
|
color: typeof e.color == "string" ? e.color : "#000000",
|
|
@@ -7511,7 +7684,7 @@ var Ir = () => {
|
|
|
7511
7684
|
let { x1: e, y1: t, x2: r, y2: i } = n;
|
|
7512
7685
|
if (typeof e == "number" && typeof t == "number" && typeof r == "number" && typeof i == "number") return {
|
|
7513
7686
|
type: "linear",
|
|
7514
|
-
angle:
|
|
7687
|
+
angle: ci({
|
|
7515
7688
|
x1: e,
|
|
7516
7689
|
y1: t,
|
|
7517
7690
|
x2: r,
|
|
@@ -7539,7 +7712,7 @@ var Ir = () => {
|
|
|
7539
7712
|
};
|
|
7540
7713
|
}
|
|
7541
7714
|
return null;
|
|
7542
|
-
},
|
|
7715
|
+
}, ui = ["baseWidth", "baseHeight"], di = "_templateCenterX", fi = "_templateCenterY", pi = "_templateAnchorX", mi = "_templateAnchorY", hi = class t {
|
|
7543
7716
|
constructor({ editor: e }) {
|
|
7544
7717
|
this.editor = e;
|
|
7545
7718
|
}
|
|
@@ -7548,7 +7721,7 @@ var Ir = () => {
|
|
|
7548
7721
|
if (!p.length) return s.emitWarning({
|
|
7549
7722
|
origin: "TemplateManager",
|
|
7550
7723
|
method: "serializeSelection",
|
|
7551
|
-
code:
|
|
7724
|
+
code: Er.TEMPLATE_MANAGER.NO_OBJECTS_SELECTED,
|
|
7552
7725
|
message: "Нет объектов для сериализации шаблона"
|
|
7553
7726
|
}), null;
|
|
7554
7727
|
let m = t._getBounds(o), h = t._getMontageSize({
|
|
@@ -7560,7 +7733,7 @@ var Ir = () => {
|
|
|
7560
7733
|
baseWidth: g,
|
|
7561
7734
|
baseHeight: _,
|
|
7562
7735
|
montageArea: o == null ? null : o
|
|
7563
|
-
})), y =
|
|
7736
|
+
})), y = U(U({}, r), {}, {
|
|
7564
7737
|
baseWidth: g,
|
|
7565
7738
|
baseHeight: _,
|
|
7566
7739
|
positionsNormalized: !0,
|
|
@@ -7579,14 +7752,14 @@ var Ir = () => {
|
|
|
7579
7752
|
if (!(c != null && c.length)) return o.emitWarning({
|
|
7580
7753
|
origin: "TemplateManager",
|
|
7581
7754
|
method: "applyTemplate",
|
|
7582
|
-
code:
|
|
7755
|
+
code: Er.TEMPLATE_MANAGER.INVALID_TEMPLATE,
|
|
7583
7756
|
message: "Шаблон не содержит объектов"
|
|
7584
7757
|
}), null;
|
|
7585
7758
|
let d = t._getBounds(i);
|
|
7586
7759
|
if (!d) return o.emitWarning({
|
|
7587
7760
|
origin: "TemplateManager",
|
|
7588
7761
|
method: "applyTemplate",
|
|
7589
|
-
code:
|
|
7762
|
+
code: Er.TEMPLATE_MANAGER.INVALID_TARGET,
|
|
7590
7763
|
message: "Не удалось определить границы монтажной области"
|
|
7591
7764
|
}), null;
|
|
7592
7765
|
let f = t._getMontageSize({
|
|
@@ -7605,7 +7778,7 @@ var Ir = () => {
|
|
|
7605
7778
|
if (!a.length) return o.emitWarning({
|
|
7606
7779
|
origin: "TemplateManager",
|
|
7607
7780
|
method: "applyTemplate",
|
|
7608
|
-
code:
|
|
7781
|
+
code: Er.TEMPLATE_MANAGER.INVALID_TEMPLATE,
|
|
7609
7782
|
message: "Не удалось создать объекты шаблона"
|
|
7610
7783
|
}), null;
|
|
7611
7784
|
let { backgroundObject: l, contentObjects: u } = t._extractBackgroundObject(a);
|
|
@@ -7642,7 +7815,7 @@ var Ir = () => {
|
|
|
7642
7815
|
return o.emitError({
|
|
7643
7816
|
origin: "TemplateManager",
|
|
7644
7817
|
method: "applyTemplate",
|
|
7645
|
-
code:
|
|
7818
|
+
code: Er.TEMPLATE_MANAGER.APPLY_FAILED,
|
|
7646
7819
|
message: "Ошибка применения шаблона",
|
|
7647
7820
|
data: {
|
|
7648
7821
|
templateId: u,
|
|
@@ -7758,7 +7931,7 @@ var Ir = () => {
|
|
|
7758
7931
|
})();
|
|
7759
7932
|
}
|
|
7760
7933
|
static _prepareSerializableProps(e) {
|
|
7761
|
-
let t =
|
|
7934
|
+
let t = U({}, e);
|
|
7762
7935
|
return delete t.svgMarkup, delete t.objects, delete t.path, delete t.paths, delete t.type, delete t.version, t;
|
|
7763
7936
|
}
|
|
7764
7937
|
static _isSvgObject(e) {
|
|
@@ -7792,8 +7965,8 @@ var Ir = () => {
|
|
|
7792
7965
|
baseHeight: o,
|
|
7793
7966
|
useRelativePositions: c,
|
|
7794
7967
|
centerKeys: {
|
|
7795
|
-
x:
|
|
7796
|
-
y:
|
|
7968
|
+
x: di,
|
|
7969
|
+
y: fi
|
|
7797
7970
|
}
|
|
7798
7971
|
}), { scaleX: f, scaleY: p } = e, m = G({
|
|
7799
7972
|
value: f,
|
|
@@ -7810,8 +7983,8 @@ var Ir = () => {
|
|
|
7810
7983
|
baseHeight: o,
|
|
7811
7984
|
scale: n,
|
|
7812
7985
|
useRelativePositions: c,
|
|
7813
|
-
anchorX: t._resolveAnchor(l,
|
|
7814
|
-
anchorY: t._resolveAnchor(l,
|
|
7986
|
+
anchorX: t._resolveAnchor(l, pi),
|
|
7987
|
+
anchorY: t._resolveAnchor(l, mi)
|
|
7815
7988
|
}),
|
|
7816
7989
|
targetSize: i,
|
|
7817
7990
|
montageArea: s
|
|
@@ -7819,7 +7992,7 @@ var Ir = () => {
|
|
|
7819
7992
|
e.set({
|
|
7820
7993
|
scaleX: _,
|
|
7821
7994
|
scaleY: v
|
|
7822
|
-
}), e.setPositionByOrigin(g, "center", "center"), e.setCoords(), delete l[
|
|
7995
|
+
}), e.setPositionByOrigin(g, "center", "center"), e.setCoords(), delete l[di], delete l[fi], delete l[pi], delete l[mi];
|
|
7823
7996
|
}
|
|
7824
7997
|
static _getPositioningBounds({ bounds: e, baseWidth: n, baseHeight: r, scale: i, useRelativePositions: a, anchorX: o, anchorY: s }) {
|
|
7825
7998
|
if (!a) return e;
|
|
@@ -7847,8 +8020,8 @@ var Ir = () => {
|
|
|
7847
8020
|
return Math.abs(u) <= .1 ? "center" : u < 0 ? "start" : "end";
|
|
7848
8021
|
}
|
|
7849
8022
|
static _normalizeMeta({ meta: e, fallback: t }) {
|
|
7850
|
-
let { width: n, height: r } = t, i = e || {}, { baseWidth: a = n, baseHeight: o = r } = i, s = ut(i,
|
|
7851
|
-
return
|
|
8023
|
+
let { width: n, height: r } = t, i = e || {}, { baseWidth: a = n, baseHeight: o = r } = i, s = ut(i, ui);
|
|
8024
|
+
return U({
|
|
7852
8025
|
baseWidth: a,
|
|
7853
8026
|
baseHeight: o
|
|
7854
8027
|
}, s);
|
|
@@ -7895,7 +8068,7 @@ var Ir = () => {
|
|
|
7895
8068
|
}), g = h * p, v = d * p, y = f * p, b = g + v + y + m;
|
|
7896
8069
|
if (!a || !h || !l) return;
|
|
7897
8070
|
e.setCoords();
|
|
7898
|
-
let x = e, S = x[
|
|
8071
|
+
let x = e, S = x[di], C = typeof S == "number" ? S : null, w = t._resolveAnchor(x, pi), T = b / l, E = C === null ? null : C - T / 2, D = C === null ? null : C + T / 2, O = e.getCenterPoint();
|
|
7899
8072
|
e.set("width", a), e.initDimensions();
|
|
7900
8073
|
let k = t._getLongestLineWidth({
|
|
7901
8074
|
textbox: e,
|
|
@@ -7903,7 +8076,7 @@ var Ir = () => {
|
|
|
7903
8076
|
}), A = k > h ? k + 1 : h;
|
|
7904
8077
|
e.set("width", A), e.initDimensions(), e.setPositionByOrigin(O, "center", "center"), e.setCoords();
|
|
7905
8078
|
let j = (A * p + v + y + m) / l, M = C;
|
|
7906
|
-
w === "start" && E !== null ? M = Math.max(0, E) + j / 2 : w === "end" && D !== null && (M = Math.min(1, D) - j / 2), typeof M == "number" && (x[
|
|
8079
|
+
w === "start" && E !== null ? M = Math.max(0, E) + j / 2 : w === "end" && D !== null && (M = Math.min(1, D) - j / 2), typeof M == "number" && (x[di] = M);
|
|
7907
8080
|
}
|
|
7908
8081
|
static _getLongestLineWidth({ textbox: e, text: t }) {
|
|
7909
8082
|
let { textLines: n } = e, r = Array.isArray(n) && n.length > 0 ? n.length : Math.max(t.split("\n").length, 1), i = 0;
|
|
@@ -7931,11 +8104,11 @@ var Ir = () => {
|
|
|
7931
8104
|
y: (t.y - c) / p
|
|
7932
8105
|
};
|
|
7933
8106
|
})() : m, g = (d.left - s) / f, _ = (d.top - c) / p, v = g + d.width / f, y = _ + d.height / p;
|
|
7934
|
-
return o[
|
|
8107
|
+
return o[di] = h.x, o[fi] = h.y, o[pi] = t._detectAnchor({
|
|
7935
8108
|
center: h.x,
|
|
7936
8109
|
start: g,
|
|
7937
8110
|
end: v
|
|
7938
|
-
}), o[
|
|
8111
|
+
}), o[mi] = t._detectAnchor({
|
|
7939
8112
|
center: h.y,
|
|
7940
8113
|
start: _,
|
|
7941
8114
|
end: y
|
|
@@ -7962,7 +8135,7 @@ var Ir = () => {
|
|
|
7962
8135
|
withoutSave: !0
|
|
7963
8136
|
}), !0;
|
|
7964
8137
|
if (a === "gradient") {
|
|
7965
|
-
let e =
|
|
8138
|
+
let e = li(r);
|
|
7966
8139
|
if (e) return n.setGradientBackground({
|
|
7967
8140
|
gradient: e,
|
|
7968
8141
|
customData: o,
|
|
@@ -7983,7 +8156,7 @@ var Ir = () => {
|
|
|
7983
8156
|
r.emitWarning({
|
|
7984
8157
|
origin: "TemplateManager",
|
|
7985
8158
|
method: "applyTemplate",
|
|
7986
|
-
code:
|
|
8159
|
+
code: Er.TEMPLATE_MANAGER.APPLY_FAILED,
|
|
7987
8160
|
message: "Не удалось применить фон из шаблона",
|
|
7988
8161
|
data: e
|
|
7989
8162
|
});
|
|
@@ -8006,7 +8179,7 @@ var Ir = () => {
|
|
|
8006
8179
|
};
|
|
8007
8180
|
}
|
|
8008
8181
|
static _cloneCustomData(e) {
|
|
8009
|
-
if (!(!e || typeof e != "object")) return
|
|
8182
|
+
if (!(!e || typeof e != "object")) return U({}, e);
|
|
8010
8183
|
}
|
|
8011
8184
|
static _getImageSource(e) {
|
|
8012
8185
|
let t = e;
|
|
@@ -8024,29 +8197,29 @@ var Ir = () => {
|
|
|
8024
8197
|
enlivenObjectEnlivables(e) {
|
|
8025
8198
|
return C.enlivenObjectEnlivables(e);
|
|
8026
8199
|
}
|
|
8027
|
-
},
|
|
8028
|
-
let n =
|
|
8200
|
+
}, gi = "#3D8BF4", _i = .5, vi = ({ distance: e }) => Number.isFinite(e) ? Math.round(Math.max(0, e)) : 0, yi = ({ firstDistance: e, secondDistance: t }) => {
|
|
8201
|
+
let n = vi({ distance: e }), r = vi({ distance: t });
|
|
8029
8202
|
return {
|
|
8030
8203
|
firstDisplayDistance: n,
|
|
8031
8204
|
secondDisplayDistance: r,
|
|
8032
8205
|
displayDistanceDiff: Math.abs(n - r),
|
|
8033
8206
|
commonDisplayDistance: Math.max(n, r)
|
|
8034
8207
|
};
|
|
8035
|
-
},
|
|
8208
|
+
}, bi = ({ firstStart: e, firstEnd: t, secondStart: n, secondEnd: r }) => Math.min(t, r) - Math.max(e, n), xi = ({ step: e }) => {
|
|
8036
8209
|
let t = Math.abs(e).toString(), n = t.indexOf(".");
|
|
8037
8210
|
return n === -1 ? 0 : t.slice(n + 1).length;
|
|
8038
|
-
},
|
|
8211
|
+
}, Si = ({ value: e, step: t }) => {
|
|
8039
8212
|
if (t === 0) return e;
|
|
8040
|
-
let n =
|
|
8213
|
+
let n = xi({ step: t }), r = Math.round(e / t) * t;
|
|
8041
8214
|
return Number(r.toFixed(n));
|
|
8042
|
-
},
|
|
8215
|
+
}, Ci = ({ value: e, step: t }) => {
|
|
8043
8216
|
if (t === 0) return !0;
|
|
8044
|
-
let n =
|
|
8217
|
+
let n = Si({
|
|
8045
8218
|
value: e,
|
|
8046
8219
|
step: t
|
|
8047
|
-
}), r =
|
|
8220
|
+
}), r = xi({ step: t }), i = Math.pow(10, -(r + 4));
|
|
8048
8221
|
return Math.abs(n - e) <= i;
|
|
8049
|
-
},
|
|
8222
|
+
}, wi = ({ bounds: e, axis: t }) => {
|
|
8050
8223
|
let { left: n = 0, right: r = 0, top: i = 0, bottom: a = 0 } = e;
|
|
8051
8224
|
return t === "vertical" ? {
|
|
8052
8225
|
start: i,
|
|
@@ -8055,7 +8228,7 @@ var Ir = () => {
|
|
|
8055
8228
|
start: n,
|
|
8056
8229
|
end: r
|
|
8057
8230
|
};
|
|
8058
|
-
},
|
|
8231
|
+
}, Ti = ({ items: e, axis: t }) => {
|
|
8059
8232
|
for (let n = 1; n < e.length; n += 1) {
|
|
8060
8233
|
let r = e[n], { bounds: i } = r, a = i[t], o = n - 1;
|
|
8061
8234
|
for (; o >= 0;) {
|
|
@@ -8065,10 +8238,10 @@ var Ir = () => {
|
|
|
8065
8238
|
}
|
|
8066
8239
|
e[o + 1] = r;
|
|
8067
8240
|
}
|
|
8068
|
-
},
|
|
8241
|
+
}, Ei = ({ items: e, index: t, axis: n, direction: r }) => {
|
|
8069
8242
|
let i = e[t];
|
|
8070
8243
|
if (!i) return null;
|
|
8071
|
-
let { bounds: a } = i, { start: o, end: s } =
|
|
8244
|
+
let { bounds: a } = i, { start: o, end: s } = wi({
|
|
8072
8245
|
bounds: a,
|
|
8073
8246
|
axis: n
|
|
8074
8247
|
});
|
|
@@ -8076,7 +8249,7 @@ var Ir = () => {
|
|
|
8076
8249
|
for (let r = t - 1; r >= 0; --r) {
|
|
8077
8250
|
let t = e[r];
|
|
8078
8251
|
if (!t) continue;
|
|
8079
|
-
let { bounds: i } = t, { end: a } =
|
|
8252
|
+
let { bounds: i } = t, { end: a } = wi({
|
|
8080
8253
|
bounds: i,
|
|
8081
8254
|
axis: n
|
|
8082
8255
|
});
|
|
@@ -8087,26 +8260,26 @@ var Ir = () => {
|
|
|
8087
8260
|
for (let r = t + 1; r < e.length; r += 1) {
|
|
8088
8261
|
let t = e[r];
|
|
8089
8262
|
if (!t) continue;
|
|
8090
|
-
let { bounds: i } = t, { start: a } =
|
|
8263
|
+
let { bounds: i } = t, { start: a } = wi({
|
|
8091
8264
|
bounds: i,
|
|
8092
8265
|
axis: n
|
|
8093
8266
|
});
|
|
8094
8267
|
if (a - s >= 0) return r;
|
|
8095
8268
|
}
|
|
8096
8269
|
return null;
|
|
8097
|
-
},
|
|
8270
|
+
}, Di = ({ items: e }) => {
|
|
8098
8271
|
for (let t = 0; t < e.length; t += 1) {
|
|
8099
8272
|
let { isActive: n } = e[t];
|
|
8100
8273
|
if (n) return t;
|
|
8101
8274
|
}
|
|
8102
8275
|
return -1;
|
|
8103
|
-
},
|
|
8276
|
+
}, Oi = ({ patternAxis: e, activeRangeStart: t, activeRangeEnd: n, tolerance: r = 0 }) => {
|
|
8104
8277
|
let i = Math.min(t, n), a = Math.max(t, n);
|
|
8105
8278
|
return e >= i - r && e <= a + r;
|
|
8106
|
-
},
|
|
8279
|
+
}, ki = ({ patternStart: e, patternEnd: t, activeStart: n, activeEnd: r }) => t <= n ? "before" : e >= r ? "after" : null, Ai = ({ baseOption: e, candidateOption: t }) => {
|
|
8107
8280
|
let { delta: n, guide: { distance: r } } = e, { delta: i, guide: { distance: a } } = t;
|
|
8108
8281
|
return n === i && r === a;
|
|
8109
|
-
},
|
|
8282
|
+
}, ji = ({ options: e }) => {
|
|
8110
8283
|
let t = e[0];
|
|
8111
8284
|
for (let n = 1; n < e.length; n += 1) {
|
|
8112
8285
|
let r = e[n];
|
|
@@ -8117,11 +8290,11 @@ var Ir = () => {
|
|
|
8117
8290
|
r.diff === t.diff && Math.abs(r.delta) < Math.abs(t.delta) && (t = r);
|
|
8118
8291
|
}
|
|
8119
8292
|
return t;
|
|
8120
|
-
},
|
|
8293
|
+
}, Mi = ({ currentOption: e, nextOption: t }) => {
|
|
8121
8294
|
if (!e) return !0;
|
|
8122
8295
|
let { contextDistance: n, diff: r, delta: i } = e, { contextDistance: a, diff: o, delta: s } = t;
|
|
8123
8296
|
return a < n ? !0 : a > n ? !1 : o < r ? !0 : o > r ? !1 : Math.abs(s) < Math.abs(i);
|
|
8124
|
-
},
|
|
8297
|
+
}, Ni = ({ options: e }) => {
|
|
8125
8298
|
let t = [], n = null, r = null;
|
|
8126
8299
|
for (let i of e) {
|
|
8127
8300
|
let { kind: e, side: a } = i;
|
|
@@ -8129,18 +8302,18 @@ var Ir = () => {
|
|
|
8129
8302
|
t.push(i);
|
|
8130
8303
|
continue;
|
|
8131
8304
|
}
|
|
8132
|
-
a === "before" &&
|
|
8305
|
+
a === "before" && Mi({
|
|
8133
8306
|
currentOption: n,
|
|
8134
8307
|
nextOption: i
|
|
8135
|
-
}) && (n = i), a === "after" &&
|
|
8308
|
+
}) && (n = i), a === "after" && Mi({
|
|
8136
8309
|
currentOption: r,
|
|
8137
8310
|
nextOption: i
|
|
8138
8311
|
}) && (r = i);
|
|
8139
8312
|
}
|
|
8140
8313
|
return n && t.push(n), r && t.push(r), t;
|
|
8141
|
-
},
|
|
8314
|
+
}, Pi = ({ options: e, side: t, baseOption: n }) => {
|
|
8142
8315
|
let r = null;
|
|
8143
|
-
for (let i of e) if (i.side === t &&
|
|
8316
|
+
for (let i of e) if (i.side === t && Ai({
|
|
8144
8317
|
baseOption: n,
|
|
8145
8318
|
candidateOption: i
|
|
8146
8319
|
})) {
|
|
@@ -8151,63 +8324,63 @@ var Ir = () => {
|
|
|
8151
8324
|
!r || i.diff !== r.diff || Math.abs(i.delta) < Math.abs(r.delta) && (r = i);
|
|
8152
8325
|
}
|
|
8153
8326
|
return r;
|
|
8154
|
-
},
|
|
8327
|
+
}, Fi = ({ option: e }) => {
|
|
8155
8328
|
let { side: t, kind: n, guide: { distance: r } } = e;
|
|
8156
8329
|
return {
|
|
8157
8330
|
side: t,
|
|
8158
8331
|
kind: n,
|
|
8159
8332
|
distance: r
|
|
8160
8333
|
};
|
|
8161
|
-
},
|
|
8334
|
+
}, Ii = ({ option: e, context: t }) => {
|
|
8162
8335
|
let { side: n, kind: r, distance: i } = t, { side: a, kind: o, guide: { distance: s } } = e;
|
|
8163
8336
|
return n !== a || r !== o ? !1 : Math.abs(s - i) <= 1;
|
|
8164
|
-
},
|
|
8337
|
+
}, Li = ({ options: e, context: t }) => {
|
|
8165
8338
|
if (!t) return null;
|
|
8166
|
-
for (let n of e) if (
|
|
8339
|
+
for (let n of e) if (Ii({
|
|
8167
8340
|
option: n,
|
|
8168
8341
|
context: t
|
|
8169
8342
|
})) return n;
|
|
8170
8343
|
return null;
|
|
8171
|
-
},
|
|
8172
|
-
let i =
|
|
8344
|
+
}, Ri = ({ options: e, bestOption: t, previousContext: n, switchDistance: r = 0 }) => {
|
|
8345
|
+
let i = Li({
|
|
8173
8346
|
options: e,
|
|
8174
8347
|
context: n
|
|
8175
8348
|
});
|
|
8176
8349
|
if (!i) return t;
|
|
8177
8350
|
let a = Math.max(0, r);
|
|
8178
8351
|
return a === 0 || Math.abs(t.delta - i.delta) >= a ? t : i;
|
|
8179
|
-
},
|
|
8352
|
+
}, zi = ({ guides: e, seenGuideKeys: t, guide: n }) => {
|
|
8180
8353
|
let { type: r, axis: i, refStart: a, refEnd: o, activeStart: s, activeEnd: c, distance: l } = n, u = `${r}:${i}:${a}:${o}:${s}:${c}:${l}`;
|
|
8181
8354
|
t.has(u) || (t.add(u), e.push(n));
|
|
8182
|
-
},
|
|
8355
|
+
}, Bi = ({ options: e, previousContext: t = null, switchDistance: n = 0 }) => {
|
|
8183
8356
|
if (!e.length) return {
|
|
8184
8357
|
delta: 0,
|
|
8185
8358
|
guides: [],
|
|
8186
8359
|
context: null
|
|
8187
8360
|
};
|
|
8188
|
-
let r =
|
|
8361
|
+
let r = Ni({ options: e }), i = [];
|
|
8189
8362
|
for (let e of r) e.kind === "reference" && i.push(e);
|
|
8190
|
-
let a = i.length > 0, o = a ? i : r, s =
|
|
8363
|
+
let a = i.length > 0, o = a ? i : r, s = Ri({
|
|
8191
8364
|
options: o,
|
|
8192
|
-
bestOption:
|
|
8365
|
+
bestOption: ji({ options: o }),
|
|
8193
8366
|
previousContext: t,
|
|
8194
8367
|
switchDistance: n
|
|
8195
|
-
}), c =
|
|
8368
|
+
}), c = Pi({
|
|
8196
8369
|
options: o,
|
|
8197
8370
|
side: "before",
|
|
8198
8371
|
baseOption: s
|
|
8199
|
-
}), l =
|
|
8372
|
+
}), l = Pi({
|
|
8200
8373
|
options: o,
|
|
8201
8374
|
side: "after",
|
|
8202
8375
|
baseOption: s
|
|
8203
|
-
}), u =
|
|
8376
|
+
}), u = Pi({
|
|
8204
8377
|
options: a ? r : o,
|
|
8205
8378
|
side: "center",
|
|
8206
8379
|
baseOption: s
|
|
8207
8380
|
}), d = [];
|
|
8208
8381
|
c && l ? d.push(c, l) : (d.push(s), s.side === "before" && l && d.push(l), s.side === "after" && c && d.push(c), s.side === "center" && (c && !l && d.push(c), l && !c && d.push(l)), a && s.side === "before" && !l && u && d.push(u), a && s.side === "after" && !c && u && d.push(u)), !d.length && u && d.push(u);
|
|
8209
8382
|
let f = [], p = /* @__PURE__ */ new Set();
|
|
8210
|
-
for (let e of d)
|
|
8383
|
+
for (let e of d) zi({
|
|
8211
8384
|
guides: f,
|
|
8212
8385
|
seenGuideKeys: p,
|
|
8213
8386
|
guide: e.guide
|
|
@@ -8215,15 +8388,15 @@ var Ir = () => {
|
|
|
8215
8388
|
return {
|
|
8216
8389
|
delta: s.delta,
|
|
8217
8390
|
guides: f,
|
|
8218
|
-
context:
|
|
8391
|
+
context: Fi({ option: s })
|
|
8219
8392
|
};
|
|
8220
|
-
},
|
|
8221
|
-
let s = n - (e - r), c =
|
|
8393
|
+
}, Vi = ({ activeStart: e, activeEnd: t, targetGap: n, beforeEdge: r, afterEdge: i, threshold: a, step: o }) => {
|
|
8394
|
+
let s = n - (e - r), c = Si({
|
|
8222
8395
|
value: s,
|
|
8223
8396
|
step: o
|
|
8224
8397
|
}), l = Math.max(1, Math.ceil(a / Math.max(o, 1))), u = null;
|
|
8225
8398
|
for (let d = -l; d <= l; d += 1) {
|
|
8226
|
-
let l = c + d * o, f = e + l, p = t + l, m = f - r, h = i - p, { displayDistanceDiff: g, commonDisplayDistance: _ } =
|
|
8399
|
+
let l = c + d * o, f = e + l, p = t + l, m = f - r, h = i - p, { displayDistanceDiff: g, commonDisplayDistance: _ } = yi({
|
|
8227
8400
|
firstDistance: m,
|
|
8228
8401
|
secondDistance: h
|
|
8229
8402
|
});
|
|
@@ -8238,13 +8411,13 @@ var Ir = () => {
|
|
|
8238
8411
|
});
|
|
8239
8412
|
}
|
|
8240
8413
|
return u;
|
|
8241
|
-
},
|
|
8242
|
-
let { secondDisplayDistance: n, displayDistanceDiff: r } =
|
|
8414
|
+
}, Hi = ({ currentGap: e, referenceGap: t }) => {
|
|
8415
|
+
let { secondDisplayDistance: n, displayDistanceDiff: r } = yi({
|
|
8243
8416
|
firstDistance: e,
|
|
8244
8417
|
secondDistance: t
|
|
8245
8418
|
});
|
|
8246
8419
|
return r > 1 ? null : n;
|
|
8247
|
-
},
|
|
8420
|
+
}, Ui = ({ anchors: e, positions: t, threshold: n }) => {
|
|
8248
8421
|
let r = 0, i = n + 1, a = null;
|
|
8249
8422
|
for (let o of t) for (let t of e) {
|
|
8250
8423
|
let e = Math.abs(t - o);
|
|
@@ -8254,8 +8427,8 @@ var Ir = () => {
|
|
|
8254
8427
|
delta: r,
|
|
8255
8428
|
guidePosition: a
|
|
8256
8429
|
};
|
|
8257
|
-
},
|
|
8258
|
-
let { left: r, right: i, centerX: a, top: o, bottom: s, centerY: c } = e, l =
|
|
8430
|
+
}, Wi = ({ activeBounds: e, threshold: t, anchors: n }) => {
|
|
8431
|
+
let { left: r, right: i, centerX: a, top: o, bottom: s, centerY: c } = e, l = Ui({
|
|
8259
8432
|
anchors: n.vertical,
|
|
8260
8433
|
positions: [
|
|
8261
8434
|
r,
|
|
@@ -8263,7 +8436,7 @@ var Ir = () => {
|
|
|
8263
8436
|
i
|
|
8264
8437
|
],
|
|
8265
8438
|
threshold: t
|
|
8266
|
-
}), u =
|
|
8439
|
+
}), u = Ui({
|
|
8267
8440
|
anchors: n.horizontal,
|
|
8268
8441
|
positions: [
|
|
8269
8442
|
o,
|
|
@@ -8283,11 +8456,11 @@ var Ir = () => {
|
|
|
8283
8456
|
deltaY: u.delta,
|
|
8284
8457
|
guides: d
|
|
8285
8458
|
};
|
|
8286
|
-
},
|
|
8459
|
+
}, Gi = ({ activeBounds: e, candidates: t, threshold: n, patterns: r, previousContext: i = null, switchDistance: a = 0 }) => {
|
|
8287
8460
|
let { centerX: o, top: s, bottom: c, left: l, right: u } = e, d = [];
|
|
8288
8461
|
for (let e of t) {
|
|
8289
8462
|
let { left: t, right: n } = e;
|
|
8290
|
-
|
|
8463
|
+
bi({
|
|
8291
8464
|
firstStart: t,
|
|
8292
8465
|
firstEnd: n,
|
|
8293
8466
|
secondStart: l,
|
|
@@ -8307,22 +8480,22 @@ var Ir = () => {
|
|
|
8307
8480
|
f.push({
|
|
8308
8481
|
bounds: e,
|
|
8309
8482
|
isActive: !0
|
|
8310
|
-
}),
|
|
8483
|
+
}), Ti({
|
|
8311
8484
|
items: f,
|
|
8312
8485
|
axis: "top"
|
|
8313
8486
|
});
|
|
8314
|
-
let p =
|
|
8487
|
+
let p = Di({ items: f });
|
|
8315
8488
|
if (p === -1) return {
|
|
8316
8489
|
delta: 0,
|
|
8317
8490
|
guides: [],
|
|
8318
8491
|
context: null
|
|
8319
8492
|
};
|
|
8320
|
-
let m = [], h = c - s, g =
|
|
8493
|
+
let m = [], h = c - s, g = Ei({
|
|
8321
8494
|
items: f,
|
|
8322
8495
|
index: p,
|
|
8323
8496
|
axis: "vertical",
|
|
8324
8497
|
direction: "prev"
|
|
8325
|
-
}), _ =
|
|
8498
|
+
}), _ = Ei({
|
|
8326
8499
|
items: f,
|
|
8327
8500
|
index: p,
|
|
8328
8501
|
axis: "vertical",
|
|
@@ -8331,19 +8504,19 @@ var Ir = () => {
|
|
|
8331
8504
|
if (v && y) {
|
|
8332
8505
|
let { bounds: e } = v, { bounds: t } = y, { bottom: r } = e, { top: i } = t, a = i - r - h;
|
|
8333
8506
|
if (a >= 0) {
|
|
8334
|
-
let e =
|
|
8507
|
+
let e = Si({
|
|
8335
8508
|
value: a / 2,
|
|
8336
8509
|
step: 1
|
|
8337
8510
|
}), t = s - r, l = i - c, u = Math.abs(t - e), d = Math.abs(l - e);
|
|
8338
8511
|
if (Math.max(u, d) <= n) {
|
|
8339
|
-
let t =
|
|
8512
|
+
let t = Vi({
|
|
8340
8513
|
activeStart: s,
|
|
8341
8514
|
activeEnd: c,
|
|
8342
8515
|
targetGap: e,
|
|
8343
8516
|
beforeEdge: r,
|
|
8344
8517
|
afterEdge: i,
|
|
8345
8518
|
threshold: n,
|
|
8346
|
-
step:
|
|
8519
|
+
step: _i
|
|
8347
8520
|
});
|
|
8348
8521
|
if (t) {
|
|
8349
8522
|
let { delta: e, distance: n, diff: i, activeStart: a, activeEnd: s } = t, c = {
|
|
@@ -8380,16 +8553,16 @@ var Ir = () => {
|
|
|
8380
8553
|
}
|
|
8381
8554
|
for (let e of r) {
|
|
8382
8555
|
let { axis: t, start: r, end: i, distance: a } = e;
|
|
8383
|
-
if (!
|
|
8556
|
+
if (!Ci({
|
|
8384
8557
|
value: a,
|
|
8385
8558
|
step: .5
|
|
8386
|
-
}) || !
|
|
8559
|
+
}) || !Oi({
|
|
8387
8560
|
patternAxis: t,
|
|
8388
8561
|
activeRangeStart: l,
|
|
8389
8562
|
activeRangeEnd: u,
|
|
8390
8563
|
tolerance: n
|
|
8391
8564
|
})) continue;
|
|
8392
|
-
let d =
|
|
8565
|
+
let d = ki({
|
|
8393
8566
|
patternStart: r,
|
|
8394
8567
|
patternEnd: i,
|
|
8395
8568
|
activeStart: s,
|
|
@@ -8397,12 +8570,12 @@ var Ir = () => {
|
|
|
8397
8570
|
});
|
|
8398
8571
|
if (d) {
|
|
8399
8572
|
if (b !== null && S && d === "before" && Math.abs(b - a) <= n) {
|
|
8400
|
-
let e =
|
|
8573
|
+
let e = Si({
|
|
8401
8574
|
value: a - b,
|
|
8402
8575
|
step: 1
|
|
8403
8576
|
}), t = s + e, { bottom: c } = S, l = t - c, u = Math.abs(l - a);
|
|
8404
8577
|
if (u > n) continue;
|
|
8405
|
-
let d =
|
|
8578
|
+
let d = Hi({
|
|
8406
8579
|
currentGap: l,
|
|
8407
8580
|
referenceGap: a
|
|
8408
8581
|
});
|
|
@@ -8426,12 +8599,12 @@ var Ir = () => {
|
|
|
8426
8599
|
});
|
|
8427
8600
|
}
|
|
8428
8601
|
if (x !== null && C && d === "after" && Math.abs(x - a) <= n) {
|
|
8429
|
-
let e =
|
|
8602
|
+
let e = Si({
|
|
8430
8603
|
value: x - a,
|
|
8431
8604
|
step: 1
|
|
8432
8605
|
}), t = c + e, { top: s } = C, l = s - t, u = Math.abs(l - a);
|
|
8433
8606
|
if (u > n) continue;
|
|
8434
|
-
let d =
|
|
8607
|
+
let d = Hi({
|
|
8435
8608
|
currentGap: l,
|
|
8436
8609
|
referenceGap: a
|
|
8437
8610
|
});
|
|
@@ -8456,16 +8629,16 @@ var Ir = () => {
|
|
|
8456
8629
|
}
|
|
8457
8630
|
}
|
|
8458
8631
|
}
|
|
8459
|
-
return
|
|
8632
|
+
return Bi({
|
|
8460
8633
|
options: m,
|
|
8461
8634
|
previousContext: i,
|
|
8462
8635
|
switchDistance: a
|
|
8463
8636
|
});
|
|
8464
|
-
},
|
|
8637
|
+
}, Ki = ({ activeBounds: e, candidates: t, threshold: n, patterns: r, previousContext: i = null, switchDistance: a = 0 }) => {
|
|
8465
8638
|
let { centerY: o, left: s, right: c, top: l, bottom: u } = e, d = [];
|
|
8466
8639
|
for (let e of t) {
|
|
8467
8640
|
let { top: t, bottom: n } = e;
|
|
8468
|
-
|
|
8641
|
+
bi({
|
|
8469
8642
|
firstStart: t,
|
|
8470
8643
|
firstEnd: n,
|
|
8471
8644
|
secondStart: l,
|
|
@@ -8485,22 +8658,22 @@ var Ir = () => {
|
|
|
8485
8658
|
f.push({
|
|
8486
8659
|
bounds: e,
|
|
8487
8660
|
isActive: !0
|
|
8488
|
-
}),
|
|
8661
|
+
}), Ti({
|
|
8489
8662
|
items: f,
|
|
8490
8663
|
axis: "left"
|
|
8491
8664
|
});
|
|
8492
|
-
let p =
|
|
8665
|
+
let p = Di({ items: f });
|
|
8493
8666
|
if (p === -1) return {
|
|
8494
8667
|
delta: 0,
|
|
8495
8668
|
guides: [],
|
|
8496
8669
|
context: null
|
|
8497
8670
|
};
|
|
8498
|
-
let m = [], h = c - s, g =
|
|
8671
|
+
let m = [], h = c - s, g = Ei({
|
|
8499
8672
|
items: f,
|
|
8500
8673
|
index: p,
|
|
8501
8674
|
axis: "horizontal",
|
|
8502
8675
|
direction: "prev"
|
|
8503
|
-
}), _ =
|
|
8676
|
+
}), _ = Ei({
|
|
8504
8677
|
items: f,
|
|
8505
8678
|
index: p,
|
|
8506
8679
|
axis: "horizontal",
|
|
@@ -8509,19 +8682,19 @@ var Ir = () => {
|
|
|
8509
8682
|
if (v && y) {
|
|
8510
8683
|
let { bounds: e } = v, { bounds: t } = y, { right: r } = e, { left: i } = t, a = i - r - h;
|
|
8511
8684
|
if (a >= 0) {
|
|
8512
|
-
let e =
|
|
8685
|
+
let e = Si({
|
|
8513
8686
|
value: a / 2,
|
|
8514
8687
|
step: 1
|
|
8515
8688
|
}), t = s - r, l = i - c, u = Math.abs(t - e), d = Math.abs(l - e);
|
|
8516
8689
|
if (Math.max(u, d) <= n) {
|
|
8517
|
-
let t =
|
|
8690
|
+
let t = Vi({
|
|
8518
8691
|
activeStart: s,
|
|
8519
8692
|
activeEnd: c,
|
|
8520
8693
|
targetGap: e,
|
|
8521
8694
|
beforeEdge: r,
|
|
8522
8695
|
afterEdge: i,
|
|
8523
8696
|
threshold: n,
|
|
8524
|
-
step:
|
|
8697
|
+
step: _i
|
|
8525
8698
|
});
|
|
8526
8699
|
if (t) {
|
|
8527
8700
|
let { delta: e, distance: n, diff: i, activeStart: a, activeEnd: s } = t, c = {
|
|
@@ -8558,16 +8731,16 @@ var Ir = () => {
|
|
|
8558
8731
|
}
|
|
8559
8732
|
for (let e of r) {
|
|
8560
8733
|
let { axis: t, start: r, end: i, distance: a } = e;
|
|
8561
|
-
if (!
|
|
8734
|
+
if (!Ci({
|
|
8562
8735
|
value: a,
|
|
8563
8736
|
step: .5
|
|
8564
|
-
}) || !
|
|
8737
|
+
}) || !Oi({
|
|
8565
8738
|
patternAxis: t,
|
|
8566
8739
|
activeRangeStart: l,
|
|
8567
8740
|
activeRangeEnd: u,
|
|
8568
8741
|
tolerance: n
|
|
8569
8742
|
})) continue;
|
|
8570
|
-
let d =
|
|
8743
|
+
let d = ki({
|
|
8571
8744
|
patternStart: r,
|
|
8572
8745
|
patternEnd: i,
|
|
8573
8746
|
activeStart: s,
|
|
@@ -8575,12 +8748,12 @@ var Ir = () => {
|
|
|
8575
8748
|
});
|
|
8576
8749
|
if (d) {
|
|
8577
8750
|
if (b !== null && S && d === "before" && Math.abs(b - a) <= n) {
|
|
8578
|
-
let e =
|
|
8751
|
+
let e = Si({
|
|
8579
8752
|
value: a - b,
|
|
8580
8753
|
step: 1
|
|
8581
8754
|
}), t = s + e, { right: c } = S, l = t - c, u = Math.abs(l - a);
|
|
8582
8755
|
if (u > n) continue;
|
|
8583
|
-
let d =
|
|
8756
|
+
let d = Hi({
|
|
8584
8757
|
currentGap: l,
|
|
8585
8758
|
referenceGap: a
|
|
8586
8759
|
});
|
|
@@ -8604,12 +8777,12 @@ var Ir = () => {
|
|
|
8604
8777
|
});
|
|
8605
8778
|
}
|
|
8606
8779
|
if (x !== null && C && d === "after" && Math.abs(x - a) <= n) {
|
|
8607
|
-
let e =
|
|
8780
|
+
let e = Si({
|
|
8608
8781
|
value: x - a,
|
|
8609
8782
|
step: 1
|
|
8610
8783
|
}), t = c + e, { left: s } = C, l = s - t, u = Math.abs(l - a);
|
|
8611
8784
|
if (u > n) continue;
|
|
8612
|
-
let d =
|
|
8785
|
+
let d = Hi({
|
|
8613
8786
|
currentGap: l,
|
|
8614
8787
|
referenceGap: a
|
|
8615
8788
|
});
|
|
@@ -8634,20 +8807,20 @@ var Ir = () => {
|
|
|
8634
8807
|
}
|
|
8635
8808
|
}
|
|
8636
8809
|
}
|
|
8637
|
-
return
|
|
8810
|
+
return Bi({
|
|
8638
8811
|
options: m,
|
|
8639
8812
|
previousContext: i,
|
|
8640
8813
|
switchDistance: a
|
|
8641
8814
|
});
|
|
8642
|
-
},
|
|
8643
|
-
let { vertical: o = null, horizontal: s = null } = i == null ? {} : i, c =
|
|
8815
|
+
}, qi = ({ activeBounds: e, candidates: t, threshold: n, spacingPatterns: r, previousContexts: i, switchDistance: a = 0 }) => {
|
|
8816
|
+
let { vertical: o = null, horizontal: s = null } = i == null ? {} : i, c = Gi({
|
|
8644
8817
|
activeBounds: e,
|
|
8645
8818
|
candidates: t,
|
|
8646
8819
|
threshold: n,
|
|
8647
8820
|
patterns: r.vertical,
|
|
8648
8821
|
previousContext: o,
|
|
8649
8822
|
switchDistance: a
|
|
8650
|
-
}), l =
|
|
8823
|
+
}), l = Ki({
|
|
8651
8824
|
activeBounds: e,
|
|
8652
8825
|
candidates: t,
|
|
8653
8826
|
threshold: n,
|
|
@@ -8666,14 +8839,14 @@ var Ir = () => {
|
|
|
8666
8839
|
horizontal: l.context
|
|
8667
8840
|
}
|
|
8668
8841
|
};
|
|
8669
|
-
},
|
|
8842
|
+
}, Ji = ({ context: e, x: t, y: n, width: r, height: i, radius: a }) => {
|
|
8670
8843
|
let o = Math.min(a, r / 2, i / 2);
|
|
8671
8844
|
e.moveTo(t + o, n), e.lineTo(t + r - o, n), e.quadraticCurveTo(t + r, n, t + r, n + o), e.lineTo(t + r, n + i - o), e.quadraticCurveTo(t + r, n + i, t + r - o, n + i), e.lineTo(t + o, n + i), e.quadraticCurveTo(t, n + i, t, n + i - o), e.lineTo(t, n + o), e.quadraticCurveTo(t, n, t + o, n), e.closePath();
|
|
8672
|
-
},
|
|
8845
|
+
}, Yi = ({ context: e, type: t, axis: n, start: r, end: i, text: a, zoom: o, color: s, textColor: c = "#ffffff", fontFamily: l = "sans-serif", lineWidth: u = 1, padding: d = 4, radius: f = 4, offsetAlongAxis: p = 0, offsetPerpendicular: m = 0 }) => {
|
|
8673
8846
|
let h = o || 1, g = 12 / h, _ = d / h, v = f / h, y = (r + i) / 2 + p, b = t === "vertical" ? n + m : y, x = t === "vertical" ? y : n + m;
|
|
8674
8847
|
e.save(), e.setLineDash([]), e.fillStyle = s, e.strokeStyle = s, e.lineWidth = u / h, e.font = `${g}px ${l}`, e.textAlign = "center", e.textBaseline = "middle";
|
|
8675
8848
|
let S = e.measureText(a).width + _ * 2, C = g + _ * 2, w = b - S / 2, T = x - C / 2;
|
|
8676
|
-
e.beginPath(),
|
|
8849
|
+
e.beginPath(), Ji({
|
|
8677
8850
|
context: e,
|
|
8678
8851
|
x: w,
|
|
8679
8852
|
y: T,
|
|
@@ -8681,11 +8854,11 @@ var Ir = () => {
|
|
|
8681
8854
|
height: C,
|
|
8682
8855
|
radius: v
|
|
8683
8856
|
}), e.fill(), e.fillStyle = c, e.fillText(a, b, x), e.restore();
|
|
8684
|
-
},
|
|
8685
|
-
let { type: r, axis: i, refStart: a, refEnd: o, activeStart: s, activeEnd: c, distance: l } = t, u =
|
|
8857
|
+
}, Xi = ({ context: e, guide: t, zoom: n }) => {
|
|
8858
|
+
let { type: r, axis: i, refStart: a, refEnd: o, activeStart: s, activeEnd: c, distance: l } = t, u = vi({ distance: l }).toString();
|
|
8686
8859
|
e.beginPath(), r === "vertical" ? (e.moveTo(i, a), e.lineTo(i, o), e.moveTo(i, s), e.lineTo(i, c)) : (e.moveTo(a, i), e.lineTo(o, i), e.moveTo(s, i), e.lineTo(c, i)), e.stroke();
|
|
8687
|
-
let d =
|
|
8688
|
-
|
|
8860
|
+
let d = gi;
|
|
8861
|
+
Yi({
|
|
8689
8862
|
context: e,
|
|
8690
8863
|
type: r,
|
|
8691
8864
|
axis: i,
|
|
@@ -8695,7 +8868,7 @@ var Ir = () => {
|
|
|
8695
8868
|
zoom: n,
|
|
8696
8869
|
color: d,
|
|
8697
8870
|
lineWidth: 1
|
|
8698
|
-
}),
|
|
8871
|
+
}), Yi({
|
|
8699
8872
|
context: e,
|
|
8700
8873
|
type: r,
|
|
8701
8874
|
axis: i,
|
|
@@ -8706,10 +8879,10 @@ var Ir = () => {
|
|
|
8706
8879
|
color: d,
|
|
8707
8880
|
lineWidth: 1
|
|
8708
8881
|
});
|
|
8709
|
-
},
|
|
8882
|
+
}, Zi = ({ anchors: e, bounds: t }) => {
|
|
8710
8883
|
let { left: n, right: r, centerX: i, top: a, bottom: o, centerY: s } = t;
|
|
8711
8884
|
e.vertical.push(n, i, r), e.horizontal.push(a, s, o);
|
|
8712
|
-
},
|
|
8885
|
+
}, Qi = ({ bounds: e, type: t, primaryStart: n, primaryEnd: r }) => {
|
|
8713
8886
|
let i = [], a = n === "top" ? "left" : "top", o = r === "bottom" ? "right" : "bottom", s = [...e].sort((e, t) => e[n] - t[n]);
|
|
8714
8887
|
for (let e = 0; e < s.length; e += 1) {
|
|
8715
8888
|
let c = s[e], l = null, u = Infinity;
|
|
@@ -8730,35 +8903,35 @@ var Ir = () => {
|
|
|
8730
8903
|
});
|
|
8731
8904
|
}
|
|
8732
8905
|
return i;
|
|
8733
|
-
},
|
|
8734
|
-
vertical:
|
|
8906
|
+
}, $i = ({ bounds: e }) => ({
|
|
8907
|
+
vertical: Qi({
|
|
8735
8908
|
bounds: e,
|
|
8736
8909
|
axis: "centerX",
|
|
8737
8910
|
type: "vertical",
|
|
8738
8911
|
primaryStart: "top",
|
|
8739
8912
|
primaryEnd: "bottom"
|
|
8740
8913
|
}),
|
|
8741
|
-
horizontal:
|
|
8914
|
+
horizontal: Qi({
|
|
8742
8915
|
bounds: e,
|
|
8743
8916
|
axis: "centerY",
|
|
8744
8917
|
type: "horizontal",
|
|
8745
8918
|
primaryStart: "left",
|
|
8746
8919
|
primaryEnd: "right"
|
|
8747
8920
|
})
|
|
8748
|
-
}),
|
|
8921
|
+
}), ea = [
|
|
8749
8922
|
"montage-area",
|
|
8750
8923
|
"background",
|
|
8751
8924
|
"interaction-blocker"
|
|
8752
|
-
],
|
|
8925
|
+
], ta = ({ activeObject: t }) => {
|
|
8753
8926
|
let n = /* @__PURE__ */ new Set();
|
|
8754
8927
|
return t ? (n.add(t), t instanceof e && t.getObjects().forEach((e) => n.add(e)), n) : n;
|
|
8755
|
-
},
|
|
8928
|
+
}, na = ({ object: e, excluded: t, ignoredIds: n = ea }) => {
|
|
8756
8929
|
if (t.has(e)) return !0;
|
|
8757
8930
|
let { visible: r = !0 } = e;
|
|
8758
8931
|
if (!r) return !0;
|
|
8759
8932
|
let { id: i } = e;
|
|
8760
8933
|
return !!(i && n.includes(i));
|
|
8761
|
-
},
|
|
8934
|
+
}, ra = class e {
|
|
8762
8935
|
constructor({ editor: e }) {
|
|
8763
8936
|
this.anchors = {
|
|
8764
8937
|
vertical: [],
|
|
@@ -8812,7 +8985,7 @@ var Ir = () => {
|
|
|
8812
8985
|
this._clearSpacingContexts(), this._clearGuides();
|
|
8813
8986
|
return;
|
|
8814
8987
|
}
|
|
8815
|
-
let { canvas: s } = this, c = s.getZoom() || 1, l = 5 / c, { deltaX: u, deltaY: d } =
|
|
8988
|
+
let { canvas: s } = this, c = s.getZoom() || 1, l = 5 / c, { deltaX: u, deltaY: d } = Wi({
|
|
8816
8989
|
activeBounds: o,
|
|
8817
8990
|
threshold: l,
|
|
8818
8991
|
anchors: this.anchors
|
|
@@ -8825,7 +8998,7 @@ var Ir = () => {
|
|
|
8825
8998
|
top: t + d
|
|
8826
8999
|
}), r.setCoords(), o = (f = ct({ object: r })) == null ? o : f;
|
|
8827
9000
|
}
|
|
8828
|
-
let p = this._resolveCurrentTargetBounds({ activeObject: r }), m = this.spacingContexts.vertical || this.spacingContexts.horizontal ? 10 / c : l, h =
|
|
9001
|
+
let p = this._resolveCurrentTargetBounds({ activeObject: r }), m = this.spacingContexts.vertical || this.spacingContexts.horizontal ? 10 / c : l, h = qi({
|
|
8829
9002
|
activeBounds: o,
|
|
8830
9003
|
candidates: p,
|
|
8831
9004
|
threshold: m,
|
|
@@ -8847,11 +9020,11 @@ var Ir = () => {
|
|
|
8847
9020
|
target: r,
|
|
8848
9021
|
transform: a
|
|
8849
9022
|
});
|
|
8850
|
-
let v = (n = ct({ object: r })) == null ? o : n, y =
|
|
9023
|
+
let v = (n = ct({ object: r })) == null ? o : n, y = Wi({
|
|
8851
9024
|
activeBounds: v,
|
|
8852
9025
|
threshold: l,
|
|
8853
9026
|
anchors: this.anchors
|
|
8854
|
-
}), b =
|
|
9027
|
+
}), b = qi({
|
|
8855
9028
|
activeBounds: v,
|
|
8856
9029
|
candidates: p,
|
|
8857
9030
|
threshold: l,
|
|
@@ -9067,9 +9240,9 @@ var Ir = () => {
|
|
|
9067
9240
|
let { canvas: e, guideBounds: t } = this, n = e.getSelectionContext();
|
|
9068
9241
|
if (!n) return;
|
|
9069
9242
|
let { left: r, right: i, top: a, bottom: o } = t == null ? this._calculateViewportBounds() : t, { viewportTransform: s } = e, c = e.getZoom() || 1;
|
|
9070
|
-
n.save(), Array.isArray(s) && n.transform(...s), n.lineWidth = 1 / c, n.strokeStyle =
|
|
9243
|
+
n.save(), Array.isArray(s) && n.transform(...s), n.lineWidth = 1 / c, n.strokeStyle = gi, n.setLineDash([4, 4]);
|
|
9071
9244
|
for (let e of this.activeGuides) n.beginPath(), e.type === "vertical" ? (n.moveTo(e.position, a), n.lineTo(e.position, o)) : (n.moveTo(r, e.position), n.lineTo(i, e.position)), n.stroke();
|
|
9072
|
-
for (let e of this.activeSpacingGuides)
|
|
9245
|
+
for (let e of this.activeSpacingGuides) Xi({
|
|
9073
9246
|
context: n,
|
|
9074
9247
|
guide: e,
|
|
9075
9248
|
zoom: c
|
|
@@ -9277,14 +9450,14 @@ var Ir = () => {
|
|
|
9277
9450
|
}, r = [];
|
|
9278
9451
|
for (let e of t) {
|
|
9279
9452
|
let t = ct({ object: e });
|
|
9280
|
-
t && (
|
|
9453
|
+
t && (Zi({
|
|
9281
9454
|
anchors: n,
|
|
9282
9455
|
bounds: t
|
|
9283
9456
|
}), r.push(t));
|
|
9284
9457
|
}
|
|
9285
9458
|
let { montageArea: i } = this.editor, a = ct({ object: i });
|
|
9286
9459
|
if (a) {
|
|
9287
|
-
|
|
9460
|
+
Zi({
|
|
9288
9461
|
anchors: n,
|
|
9289
9462
|
bounds: a
|
|
9290
9463
|
});
|
|
@@ -9296,12 +9469,12 @@ var Ir = () => {
|
|
|
9296
9469
|
bottom: i
|
|
9297
9470
|
};
|
|
9298
9471
|
} else this.guideBounds = this._calculateViewportBounds();
|
|
9299
|
-
this.anchors = n, this.spacingPatterns =
|
|
9472
|
+
this.anchors = n, this.spacingPatterns = $i({ bounds: r }), this.cachedTargetBounds = r;
|
|
9300
9473
|
}
|
|
9301
9474
|
_collectTargets({ activeObject: e }) {
|
|
9302
|
-
let t =
|
|
9475
|
+
let t = ta({ activeObject: e }), n = [];
|
|
9303
9476
|
return this.canvas.forEachObject((e) => {
|
|
9304
|
-
|
|
9477
|
+
na({
|
|
9305
9478
|
object: e,
|
|
9306
9479
|
excluded: t
|
|
9307
9480
|
}) || n.push(e);
|
|
@@ -9324,7 +9497,7 @@ var Ir = () => {
|
|
|
9324
9497
|
bottom: (r - s) / a
|
|
9325
9498
|
};
|
|
9326
9499
|
}
|
|
9327
|
-
},
|
|
9500
|
+
}, ia = "#3D8BF4", aa = class e {
|
|
9328
9501
|
constructor({ editor: e }) {
|
|
9329
9502
|
this.activeGuides = [], this.isAltPressed = !1, this.pendingEvent = null, this.frameRequest = null, this.isToolbarHidden = !1, this.isTargetMontageArea = !1, this.lastMouseEvent = null, this.editor = e, this.canvas = e.canvas, this._onMouseMove = this._handleMouseMove.bind(this), this._onBeforeRender = this._handleBeforeRender.bind(this), this._onAfterRender = this._handleAfterRender.bind(this), this._onSelectionCleared = this._handleSelectionCleared.bind(this), this._onKeyDown = this._handleKeyDown.bind(this), this._onKeyUp = this._handleKeyUp.bind(this), this._onWindowBlur = this._handleWindowBlur.bind(this), this._bindEvents();
|
|
9330
9503
|
}
|
|
@@ -9417,8 +9590,8 @@ var Ir = () => {
|
|
|
9417
9590
|
this.isTargetMontageArea = l, this.activeGuides = d, this._hideToolbar(), n.requestRenderAll();
|
|
9418
9591
|
}
|
|
9419
9592
|
static _resolveTarget({ event: e, activeObject: t }) {
|
|
9420
|
-
let { target: n } = e, r =
|
|
9421
|
-
return n && !
|
|
9593
|
+
let { target: n } = e, r = ta({ activeObject: t });
|
|
9594
|
+
return n && !na({
|
|
9422
9595
|
object: n,
|
|
9423
9596
|
excluded: r
|
|
9424
9597
|
}) ? n : null;
|
|
@@ -9535,18 +9708,18 @@ var Ir = () => {
|
|
|
9535
9708
|
let { canvas: e } = this, t = e.getSelectionContext();
|
|
9536
9709
|
if (!t) return;
|
|
9537
9710
|
let { viewportTransform: n } = e, r = e.getZoom() || 1, i = this.activeGuides.some((e) => e.type === "vertical"), a = this.activeGuides.some((e) => e.type === "horizontal"), o = i && a && !this.isTargetMontageArea, s = o ? 12 / r : 0;
|
|
9538
|
-
t.save(), Array.isArray(n) && t.transform(...n), t.lineWidth = 1 / r, t.strokeStyle =
|
|
9711
|
+
t.save(), Array.isArray(n) && t.transform(...n), t.lineWidth = 1 / r, t.strokeStyle = ia, t.setLineDash([]);
|
|
9539
9712
|
for (let e of this.activeGuides) {
|
|
9540
9713
|
let { type: n, axis: i, start: a, end: c, distance: l } = e, u = Math.abs(c - a), d = o ? (a <= c ? -1 : 1) * (u / 2 + s) : 0;
|
|
9541
|
-
t.beginPath(), n === "vertical" ? (t.moveTo(i, a), t.lineTo(i, c)) : (t.moveTo(a, i), t.lineTo(c, i)), t.stroke(),
|
|
9714
|
+
t.beginPath(), n === "vertical" ? (t.moveTo(i, a), t.lineTo(i, c)) : (t.moveTo(a, i), t.lineTo(c, i)), t.stroke(), Yi({
|
|
9542
9715
|
context: t,
|
|
9543
9716
|
type: n,
|
|
9544
9717
|
axis: i,
|
|
9545
9718
|
start: a,
|
|
9546
9719
|
end: c,
|
|
9547
|
-
text:
|
|
9720
|
+
text: vi({ distance: l }).toString(),
|
|
9548
9721
|
zoom: r,
|
|
9549
|
-
color:
|
|
9722
|
+
color: ia,
|
|
9550
9723
|
lineWidth: 1,
|
|
9551
9724
|
offsetAlongAxis: d,
|
|
9552
9725
|
offsetPerpendicular: 0
|
|
@@ -9566,15 +9739,15 @@ var Ir = () => {
|
|
|
9566
9739
|
let { toolbar: t } = this.editor;
|
|
9567
9740
|
t == null || (e = t.showAfterTemporary) == null || e.call(t), this.isToolbarHidden = !1;
|
|
9568
9741
|
}
|
|
9569
|
-
},
|
|
9742
|
+
}, oa = [
|
|
9570
9743
|
"source",
|
|
9571
9744
|
"scale",
|
|
9572
9745
|
"withoutSave"
|
|
9573
|
-
],
|
|
9746
|
+
], sa = [
|
|
9574
9747
|
"source",
|
|
9575
9748
|
"scale",
|
|
9576
9749
|
"withoutSave"
|
|
9577
|
-
],
|
|
9750
|
+
], ca = class e {
|
|
9578
9751
|
constructor(e, t) {
|
|
9579
9752
|
this.options = t, this.containerId = e, this.editorId = `${e}-${D()}`, this.init();
|
|
9580
9753
|
}
|
|
@@ -9583,7 +9756,7 @@ var Ir = () => {
|
|
|
9583
9756
|
return k(function* () {
|
|
9584
9757
|
var n;
|
|
9585
9758
|
let { editorContainerWidth: r, editorContainerHeight: i, canvasWrapperWidth: a, canvasWrapperHeight: o, canvasCSSWidth: s, canvasCSSHeight: c, initialImage: l, initialState: u, scaleType: d, showRotationAngle: f, _onReadyCallback: p } = e.options;
|
|
9586
|
-
if (
|
|
9759
|
+
if (V.apply(), e.canvas = new t(e.containerId, e.options), e.moduleLoader = new M(), e.workerManager = new ee(), e.errorManager = new Dr({ editor: e }), e.historyManager = new Ue({ editor: e }), e.toolbar = new W({ editor: e }), e.transformManager = new tt({ editor: e }), e.zoomManager = new nt({ editor: e }), e.canvasManager = new et({ editor: e }), e.imageManager = new Ye({ editor: e }), e.layerManager = new gt({ editor: e }), e.shapeManager = new br({ editor: e }), e.interactionBlocker = new mt({ editor: e }), e.backgroundManager = new ht({ editor: e }), e.clipboardManager = new xr({ editor: e }), e.objectLockManager = new Sr({ editor: e }), e.groupingManager = new Cr({ editor: e }), e.selectionManager = new wr({ editor: e }), e.deletionManager = new Tr({ editor: e }), e.panConstraintManager = new Or({ editor: e }), e.snappingManager = new ra({ editor: e }), e.measurementManager = new aa({ editor: e }), e.fontManager = new ae((n = e.options.fonts) == null ? [] : n), e.textManager = new si({ editor: e }), e.templateManager = new hi({ editor: e }), f && (e.angleIndicator = new pe({ editor: e })), e._createMontageArea(), e._createClippingArea(), e.listeners = new j({
|
|
9587
9760
|
editor: e,
|
|
9588
9761
|
options: e.options
|
|
9589
9762
|
}), e.canvasManager.setEditorContainerWidth(r), e.canvasManager.setEditorContainerHeight(i), e.canvasManager.setCanvasWrapperWidth(a), e.canvasManager.setCanvasWrapperHeight(o), e.canvasManager.setCanvasCSSWidth(s), e.canvasManager.setCanvasCSSHeight(c), e.canvasManager.updateCanvas(), e.zoomManager.calculateAndApplyDefaultZoom(), yield e.fontManager.loadFonts(), u) {
|
|
@@ -9593,8 +9766,8 @@ var Ir = () => {
|
|
|
9593
9766
|
yield e.historyManager.loadStateFromFullState(t);
|
|
9594
9767
|
} catch (t) {
|
|
9595
9768
|
if (l != null && l.source) {
|
|
9596
|
-
let { source: t, scale: n = `image-${d}`, withoutSave: r = !0 } = l, i = ut(l,
|
|
9597
|
-
yield e.imageManager.importImage(
|
|
9769
|
+
let { source: t, scale: n = `image-${d}`, withoutSave: r = !0 } = l, i = ut(l, oa);
|
|
9770
|
+
yield e.imageManager.importImage(U({
|
|
9598
9771
|
source: t,
|
|
9599
9772
|
scale: n,
|
|
9600
9773
|
withoutSave: r
|
|
@@ -9611,8 +9784,8 @@ var Ir = () => {
|
|
|
9611
9784
|
e.historyManager.resumeHistory();
|
|
9612
9785
|
}
|
|
9613
9786
|
} else if (l != null && l.source) {
|
|
9614
|
-
let { source: t, scale: n = `image-${d}`, withoutSave: r = !0 } = l, i = ut(l,
|
|
9615
|
-
yield e.imageManager.importImage(
|
|
9787
|
+
let { source: t, scale: n = `image-${d}`, withoutSave: r = !0 } = l, i = ut(l, sa);
|
|
9788
|
+
yield e.imageManager.importImage(U({
|
|
9616
9789
|
source: t,
|
|
9617
9790
|
scale: n,
|
|
9618
9791
|
withoutSave: r
|
|
@@ -9689,7 +9862,7 @@ var Ir = () => {
|
|
|
9689
9862
|
"U+A640-A69F",
|
|
9690
9863
|
"U+FE2E-FE2F",
|
|
9691
9864
|
"U+2116"
|
|
9692
|
-
].join(", "),
|
|
9865
|
+
].join(", "), la = {
|
|
9693
9866
|
preserveObjectStacking: !0,
|
|
9694
9867
|
controlsAboveOverlay: !0,
|
|
9695
9868
|
centeredRotation: !0,
|
|
@@ -10563,17 +10736,17 @@ var Ir = () => {
|
|
|
10563
10736
|
};
|
|
10564
10737
|
//#endregion
|
|
10565
10738
|
//#region src/main.ts
|
|
10566
|
-
function
|
|
10567
|
-
let n =
|
|
10739
|
+
function ua(e, t = {}) {
|
|
10740
|
+
let n = U(U({}, la), t), r = document.getElementById(e);
|
|
10568
10741
|
if (!r) return Promise.reject(/* @__PURE__ */ Error(`Контейнер с ID "${e}" не найден.`));
|
|
10569
10742
|
let i = document.createElement("canvas");
|
|
10570
10743
|
return i.id = `${e}-canvas`, r.appendChild(i), n.editorContainer = r, new Promise((t) => {
|
|
10571
10744
|
n._onReadyCallback = t;
|
|
10572
|
-
let r = new
|
|
10745
|
+
let r = new ca(i.id, n);
|
|
10573
10746
|
window[e] = r;
|
|
10574
10747
|
});
|
|
10575
10748
|
}
|
|
10576
10749
|
//#endregion
|
|
10577
|
-
export {
|
|
10750
|
+
export { ua as default };
|
|
10578
10751
|
|
|
10579
10752
|
//# sourceMappingURL=main.js.map
|