@anu3ev/fabric-image-editor 0.5.7 → 0.5.9
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 +295 -247
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -1593,21 +1593,21 @@ class ct {
|
|
|
1593
1593
|
const A = b.getElement();
|
|
1594
1594
|
let j = "";
|
|
1595
1595
|
if (A instanceof HTMLImageElement ? j = A.src : A instanceof HTMLCanvasElement && (j = A.toDataURL()), y > wt || I > Mt) {
|
|
1596
|
-
const
|
|
1596
|
+
const w = yield this.resizeImageToBoundaries(j, "max"), T = URL.createObjectURL(w);
|
|
1597
1597
|
this._createdBlobUrls.push(T), b = yield zt.fromURL(T, { crossOrigin: "anonymous" });
|
|
1598
1598
|
} else if (y < _t || I < Rt) {
|
|
1599
|
-
const
|
|
1599
|
+
const w = yield this.resizeImageToBoundaries(j, "min"), T = URL.createObjectURL(w);
|
|
1600
1600
|
this._createdBlobUrls.push(T), b = yield zt.fromURL(T, { crossOrigin: "anonymous" });
|
|
1601
1601
|
}
|
|
1602
1602
|
}
|
|
1603
1603
|
if (b.set("id", `${b.type}-${G()}`), b.set("format", f), s === "scale-montage")
|
|
1604
1604
|
this.editor.canvasManager.scaleMontageAreaToImage({ object: b, withoutSave: !0 });
|
|
1605
1605
|
else {
|
|
1606
|
-
const { width: A, height: j } = c,
|
|
1607
|
-
s === "image-contain" &&
|
|
1606
|
+
const { width: A, height: j } = c, w = this.calculateScaleFactor({ imageObject: b, scaleType: s });
|
|
1607
|
+
s === "image-contain" && w < 1 ? d.fitObject({ object: b, type: "contain", withoutSave: !0 }) : s === "image-cover" && (I > A || y > j) && d.fitObject({ object: b, type: "cover", withoutSave: !0 });
|
|
1608
1608
|
}
|
|
1609
1609
|
r.add(b), r.centerObject(b), a || r.setActiveObject(b), r.renderAll(), l.resumeHistory(), o || l.saveState();
|
|
1610
|
-
const
|
|
1610
|
+
const M = {
|
|
1611
1611
|
image: b,
|
|
1612
1612
|
format: f,
|
|
1613
1613
|
contentType: g,
|
|
@@ -1618,7 +1618,7 @@ class ct {
|
|
|
1618
1618
|
isBackground: i,
|
|
1619
1619
|
withoutSelection: a
|
|
1620
1620
|
};
|
|
1621
|
-
return r.fire("editor:image-imported",
|
|
1621
|
+
return r.fire("editor:image-imported", M), M;
|
|
1622
1622
|
} catch (v) {
|
|
1623
1623
|
return u.emitError({
|
|
1624
1624
|
origin: "ImageManager",
|
|
@@ -1728,28 +1728,28 @@ class ct {
|
|
|
1728
1728
|
};
|
|
1729
1729
|
return i.fire("editor:canvas-exported", S), S;
|
|
1730
1730
|
}
|
|
1731
|
-
const
|
|
1731
|
+
const M = yield createImageBitmap(y), A = yield r.post(
|
|
1732
1732
|
"toDataURL",
|
|
1733
|
-
{ format: u, quality: 1, bitmap:
|
|
1734
|
-
[
|
|
1733
|
+
{ format: u, quality: 1, bitmap: M },
|
|
1734
|
+
[M]
|
|
1735
1735
|
);
|
|
1736
1736
|
if (d) {
|
|
1737
|
-
const C = p * 0.264583, x = m * 0.264583,
|
|
1737
|
+
const C = p * 0.264583, x = m * 0.264583, W = (yield this.editor.moduleLoader.loadModule("jspdf")).jsPDF, Y = new W({
|
|
1738
1738
|
orientation: C > x ? "landscape" : "portrait",
|
|
1739
1739
|
unit: "mm",
|
|
1740
1740
|
format: [C, x]
|
|
1741
1741
|
});
|
|
1742
|
-
if (
|
|
1743
|
-
const
|
|
1744
|
-
image:
|
|
1742
|
+
if (Y.addImage(String(A), "JPG", 0, 0, C, x), o) {
|
|
1743
|
+
const P = {
|
|
1744
|
+
image: Y.output("datauristring"),
|
|
1745
1745
|
format: "pdf",
|
|
1746
1746
|
contentType: "application/pdf",
|
|
1747
1747
|
fileName: e
|
|
1748
1748
|
};
|
|
1749
|
-
return i.fire("editor:canvas-exported",
|
|
1749
|
+
return i.fire("editor:canvas-exported", P), P;
|
|
1750
1750
|
}
|
|
1751
|
-
const
|
|
1752
|
-
image: new File([
|
|
1751
|
+
const H = Y.output("blob"), L = {
|
|
1752
|
+
image: new File([H], e, { type: "application/pdf" }),
|
|
1753
1753
|
format: "pdf",
|
|
1754
1754
|
contentType: "application/pdf",
|
|
1755
1755
|
fileName: e
|
|
@@ -2621,7 +2621,7 @@ class Js {
|
|
|
2621
2621
|
_calculateEmptySpaceRatio(t) {
|
|
2622
2622
|
const { canvas: e, montageArea: s } = this.editor, o = e.viewportTransform, n = e.getWidth(), i = e.getHeight(), a = s.left - s.width / 2, r = s.left + s.width / 2, c = s.top - s.height / 2, d = s.top + s.height / 2, l = -o[4] / t, u = (-o[4] + n) / t, g = -o[5] / t, f = (-o[5] + i) / t, p = l < a, m = u > r, v = g < c, b = f > d;
|
|
2623
2623
|
if (!(p || m || v || b)) return 0;
|
|
2624
|
-
const y = Math.max(0, a - l),
|
|
2624
|
+
const y = Math.max(0, a - l), M = Math.max(0, u - r), A = Math.max(0, c - g), j = Math.max(0, f - d), w = Math.max(y, M), T = Math.max(A, j), S = w / n, C = T / i;
|
|
2625
2625
|
return Math.max(S, C);
|
|
2626
2626
|
}
|
|
2627
2627
|
/**
|
|
@@ -2638,8 +2638,8 @@ class Js {
|
|
|
2638
2638
|
const { canvas: i, montageArea: a } = this.editor, r = i.viewportTransform, c = i.getWidth(), d = i.getHeight(), l = t.x - r[4], u = t.y - r[5], g = Math.abs(o), f = e - s;
|
|
2639
2639
|
if (Math.abs(f) / g <= 0.1)
|
|
2640
2640
|
return { x: l, y: u };
|
|
2641
|
-
const m = c / 2, v = d / 2, b = a.left, I = a.top, y = m - b * s,
|
|
2642
|
-
return { x, y:
|
|
2641
|
+
const m = c / 2, v = d / 2, b = a.left, I = a.top, y = m - b * s, M = v - I * s, A = (y - r[4]) / (e - s), j = (M - r[5]) / (e - s), w = A * g, T = j * g, S = w * n, C = T * n, x = Math.abs(S) > Math.abs(l) ? l : S, W = Math.abs(C) > Math.abs(u) ? u : C;
|
|
2642
|
+
return { x, y: W };
|
|
2643
2643
|
}
|
|
2644
2644
|
/**
|
|
2645
2645
|
* Применяет плавное центрирование viewport при приближении к defaultZoom.
|
|
@@ -2911,8 +2911,9 @@ class Ot {
|
|
|
2911
2911
|
endColor: s,
|
|
2912
2912
|
startPosition: o,
|
|
2913
2913
|
endPosition: n,
|
|
2914
|
-
|
|
2915
|
-
|
|
2914
|
+
colorStops: i,
|
|
2915
|
+
customData: a = {},
|
|
2916
|
+
withoutSave: r = !1
|
|
2916
2917
|
}) {
|
|
2917
2918
|
this.setGradientBackground({
|
|
2918
2919
|
gradient: {
|
|
@@ -2921,10 +2922,11 @@ class Ot {
|
|
|
2921
2922
|
startColor: e,
|
|
2922
2923
|
endColor: s,
|
|
2923
2924
|
startPosition: o,
|
|
2924
|
-
endPosition: n
|
|
2925
|
+
endPosition: n,
|
|
2926
|
+
colorStops: i
|
|
2925
2927
|
},
|
|
2926
|
-
customData:
|
|
2927
|
-
withoutSave:
|
|
2928
|
+
customData: a,
|
|
2929
|
+
withoutSave: r
|
|
2928
2930
|
});
|
|
2929
2931
|
}
|
|
2930
2932
|
/**
|
|
@@ -2939,8 +2941,9 @@ class Ot {
|
|
|
2939
2941
|
endColor: n,
|
|
2940
2942
|
startPosition: i,
|
|
2941
2943
|
endPosition: a,
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
+
colorStops: r,
|
|
2945
|
+
customData: c = {},
|
|
2946
|
+
withoutSave: d = !1
|
|
2944
2947
|
}) {
|
|
2945
2948
|
this.setGradientBackground({
|
|
2946
2949
|
gradient: {
|
|
@@ -2951,10 +2954,11 @@ class Ot {
|
|
|
2951
2954
|
startColor: o,
|
|
2952
2955
|
endColor: n,
|
|
2953
2956
|
startPosition: i,
|
|
2954
|
-
endPosition: a
|
|
2957
|
+
endPosition: a,
|
|
2958
|
+
colorStops: r
|
|
2955
2959
|
},
|
|
2956
|
-
customData:
|
|
2957
|
-
withoutSave:
|
|
2960
|
+
customData: c,
|
|
2961
|
+
withoutSave: d
|
|
2958
2962
|
});
|
|
2959
2963
|
}
|
|
2960
2964
|
/**
|
|
@@ -3095,37 +3099,45 @@ class Ot {
|
|
|
3095
3099
|
startColor: e,
|
|
3096
3100
|
endColor: s,
|
|
3097
3101
|
startPosition: o = 0,
|
|
3098
|
-
endPosition: n = 100
|
|
3099
|
-
|
|
3102
|
+
endPosition: n = 100,
|
|
3103
|
+
colorStops: i
|
|
3104
|
+
} = t;
|
|
3105
|
+
let a;
|
|
3106
|
+
if (i && i.length > 0 ? a = i.map((u) => ({
|
|
3107
|
+
offset: u.offset / 100,
|
|
3108
|
+
color: u.color
|
|
3109
|
+
})) : e && s ? a = [
|
|
3100
3110
|
{ offset: o / 100, color: e },
|
|
3101
3111
|
{ offset: n / 100, color: s }
|
|
3102
|
-
]
|
|
3103
|
-
|
|
3104
|
-
|
|
3112
|
+
] : a = [
|
|
3113
|
+
{ offset: 0, color: "#000000" },
|
|
3114
|
+
{ offset: 1, color: "#ffffff" }
|
|
3115
|
+
], t.type === "linear") {
|
|
3116
|
+
const u = t.angle * Math.PI / 180, g = Ot._angleToCoords(u);
|
|
3105
3117
|
return new ze({
|
|
3106
3118
|
type: "linear",
|
|
3107
3119
|
gradientUnits: "percentage",
|
|
3108
|
-
coords:
|
|
3109
|
-
colorStops:
|
|
3120
|
+
coords: g,
|
|
3121
|
+
colorStops: a
|
|
3110
3122
|
});
|
|
3111
3123
|
}
|
|
3112
3124
|
const {
|
|
3113
|
-
centerX:
|
|
3114
|
-
centerY:
|
|
3115
|
-
radius:
|
|
3116
|
-
} = t,
|
|
3117
|
-
x1:
|
|
3118
|
-
y1:
|
|
3119
|
-
x2:
|
|
3120
|
-
y2:
|
|
3125
|
+
centerX: r = 50,
|
|
3126
|
+
centerY: c = 50,
|
|
3127
|
+
radius: d = 50
|
|
3128
|
+
} = t, l = {
|
|
3129
|
+
x1: r / 100,
|
|
3130
|
+
y1: c / 100,
|
|
3131
|
+
x2: r / 100,
|
|
3132
|
+
y2: c / 100,
|
|
3121
3133
|
r1: 0,
|
|
3122
|
-
r2:
|
|
3134
|
+
r2: d / 100
|
|
3123
3135
|
};
|
|
3124
3136
|
return new ze({
|
|
3125
3137
|
type: "radial",
|
|
3126
3138
|
gradientUnits: "percentage",
|
|
3127
|
-
coords:
|
|
3128
|
-
colorStops:
|
|
3139
|
+
coords: l,
|
|
3140
|
+
colorStops: a
|
|
3129
3141
|
});
|
|
3130
3142
|
}
|
|
3131
3143
|
/**
|
|
@@ -4407,32 +4419,22 @@ const io = () => {
|
|
|
4407
4419
|
if (!(t <= 0))
|
|
4408
4420
|
return h != null ? h : "#000000";
|
|
4409
4421
|
}, Ke = ({ width: h = 0 }) => h ? Math.max(0, h) : 0, ie = ({ value: h }) => typeof h == "string" ? h.toLocaleUpperCase() : "", st = 0.01;
|
|
4410
|
-
class
|
|
4422
|
+
class z {
|
|
4411
4423
|
constructor({ editor: t }) {
|
|
4412
4424
|
var e;
|
|
4413
4425
|
this._handleTextEditingEntered = () => {
|
|
4414
4426
|
this.isTextEditingActive = !0;
|
|
4415
|
-
}, this._handleTextChanged = (s) => {
|
|
4416
|
-
const { target: o } = s;
|
|
4417
|
-
if (!Z._isTextbox(o)) return;
|
|
4418
|
-
const { text: n = "", uppercase: i } = o, a = !!i, r = n.toLocaleLowerCase();
|
|
4419
|
-
if (a) {
|
|
4420
|
-
const d = ie({ value: r });
|
|
4421
|
-
d !== n && o.set({ text: d }), o.textCaseRaw = r;
|
|
4422
|
-
} else
|
|
4423
|
-
o.textCaseRaw = n;
|
|
4424
|
-
Z._roundTextboxDimensions({ textbox: o }) && (o.setCoords(), o.dirty = !0);
|
|
4425
4427
|
}, this._handleTextEditingExited = (s) => {
|
|
4426
4428
|
var r, c;
|
|
4427
4429
|
const { target: o } = s;
|
|
4428
|
-
if (!
|
|
4430
|
+
if (!z._isTextbox(o)) return;
|
|
4429
4431
|
const n = (r = o.text) != null ? r : "";
|
|
4430
4432
|
if (!!o.uppercase) {
|
|
4431
4433
|
const d = (c = o.textCaseRaw) != null ? c : n.toLocaleLowerCase();
|
|
4432
4434
|
o.textCaseRaw = d;
|
|
4433
4435
|
} else
|
|
4434
4436
|
o.textCaseRaw = n;
|
|
4435
|
-
|
|
4437
|
+
z._roundTextboxDimensions({ textbox: o }) && (o.setCoords(), o.dirty = !0, this.canvas.requestRenderAll()), o.locked || o.set({
|
|
4436
4438
|
lockMovementX: !1,
|
|
4437
4439
|
lockMovementY: !1
|
|
4438
4440
|
}), setTimeout(() => {
|
|
@@ -4441,7 +4443,7 @@ class Z {
|
|
|
4441
4443
|
}, this._handleObjectScaling = (s) => {
|
|
4442
4444
|
var X, It, Wt, mt, Ht, Ct, Ae, je, Ie, Ce, Te, Ee, Oe;
|
|
4443
4445
|
const { target: o, transform: n } = s;
|
|
4444
|
-
if (o instanceof k || !
|
|
4446
|
+
if (o instanceof k || !z._isTextbox(o) || !n) return;
|
|
4445
4447
|
o.isScaling = !0;
|
|
4446
4448
|
const i = this._ensureScalingState(o), {
|
|
4447
4449
|
baseWidth: a,
|
|
@@ -4450,30 +4452,30 @@ class Z {
|
|
|
4450
4452
|
basePadding: d,
|
|
4451
4453
|
baseRadii: l,
|
|
4452
4454
|
baseStyles: u
|
|
4453
|
-
} = i, g = typeof ((X = n.original) == null ? void 0 : X.width) == "number" ? n.original.width : void 0, f = typeof ((It = n.original) == null ? void 0 : It.left) == "number" ? n.original.left : void 0, p = g != null ? g : a, m = f != null ? f : r, v = (Wt = n.corner) != null ? Wt : "", b = (mt = n.action) != null ? mt : "", I = ["ml", "mr"].includes(v) || b === "scaleX", y = ["mt", "mb"].includes(v) || b === "scaleY",
|
|
4454
|
-
if (!I && !y && !
|
|
4455
|
-
const j = Math.abs((Ct = (Ht = o.scaleX) != null ? Ht : n.scaleX) != null ? Ct : 1) || 1,
|
|
4455
|
+
} = i, g = typeof ((X = n.original) == null ? void 0 : X.width) == "number" ? n.original.width : void 0, f = typeof ((It = n.original) == null ? void 0 : It.left) == "number" ? n.original.left : void 0, p = g != null ? g : a, m = f != null ? f : r, v = (Wt = n.corner) != null ? Wt : "", b = (mt = n.action) != null ? mt : "", I = ["ml", "mr"].includes(v) || b === "scaleX", y = ["mt", "mb"].includes(v) || b === "scaleY", M = ["tl", "tr", "bl", "br"].includes(v) || b === "scale", A = M || y;
|
|
4456
|
+
if (!I && !y && !M) return;
|
|
4457
|
+
const j = Math.abs((Ct = (Ht = o.scaleX) != null ? Ht : n.scaleX) != null ? Ct : 1) || 1, w = Math.abs((je = (Ae = o.scaleY) != null ? Ae : n.scaleY) != null ? je : 1) || 1, T = Math.max(1, p * j), S = Math.max(1, Math.round(T)), C = Math.max(1, c * w), {
|
|
4456
4458
|
paddingTop: x = 0,
|
|
4457
|
-
paddingRight:
|
|
4458
|
-
paddingBottom:
|
|
4459
|
-
paddingLeft:
|
|
4459
|
+
paddingRight: W = 0,
|
|
4460
|
+
paddingBottom: Y = 0,
|
|
4461
|
+
paddingLeft: H = 0,
|
|
4460
4462
|
radiusTopLeft: V = 0,
|
|
4461
4463
|
radiusTopRight: L = 0,
|
|
4462
4464
|
radiusBottomRight: D = 0,
|
|
4463
|
-
radiusBottomLeft:
|
|
4464
|
-
fontSize:
|
|
4465
|
-
width:
|
|
4465
|
+
radiusBottomLeft: P = 0,
|
|
4466
|
+
fontSize: Z,
|
|
4467
|
+
width: U,
|
|
4466
4468
|
originX: K = "left"
|
|
4467
|
-
} = o, $ =
|
|
4468
|
-
top: Math.max(0, d.top *
|
|
4469
|
-
right: Math.max(0, d.right *
|
|
4470
|
-
bottom: Math.max(0, d.bottom *
|
|
4471
|
-
left: Math.max(0, d.left *
|
|
4469
|
+
} = o, $ = M || y, q = M || y, F = $ ? {
|
|
4470
|
+
top: Math.max(0, d.top * w),
|
|
4471
|
+
right: Math.max(0, d.right * w),
|
|
4472
|
+
bottom: Math.max(0, d.bottom * w),
|
|
4473
|
+
left: Math.max(0, d.left * w)
|
|
4472
4474
|
} : d, Q = q ? {
|
|
4473
|
-
topLeft: Math.max(0, l.topLeft *
|
|
4474
|
-
topRight: Math.max(0, l.topRight *
|
|
4475
|
-
bottomRight: Math.max(0, l.bottomRight *
|
|
4476
|
-
bottomLeft: Math.max(0, l.bottomLeft *
|
|
4475
|
+
topLeft: Math.max(0, l.topLeft * w),
|
|
4476
|
+
topRight: Math.max(0, l.topRight * w),
|
|
4477
|
+
bottomRight: Math.max(0, l.bottomRight * w),
|
|
4478
|
+
bottomLeft: Math.max(0, l.bottomLeft * w)
|
|
4477
4479
|
} : l, St = Object.keys(u).length > 0;
|
|
4478
4480
|
let et;
|
|
4479
4481
|
if (A && St) {
|
|
@@ -4484,11 +4486,11 @@ class Z {
|
|
|
4484
4486
|
Object.entries(Le).forEach(([cs, Zt]) => {
|
|
4485
4487
|
if (!Zt) return;
|
|
4486
4488
|
const De = _({}, Zt);
|
|
4487
|
-
typeof Zt.fontSize == "number" && (De.fontSize = Math.max(1, Zt.fontSize *
|
|
4489
|
+
typeof Zt.fontSize == "number" && (De.fontSize = Math.max(1, Zt.fontSize * w)), oe[cs] = De;
|
|
4488
4490
|
}), Object.keys(oe).length && (se[rs] = oe);
|
|
4489
4491
|
}), Object.keys(se).length && (et = se);
|
|
4490
4492
|
}
|
|
4491
|
-
const lt = (Ce = (Ie = n.originX) != null ? Ie : K) != null ? Ce : "left", pt = m + p, At = m + p / 2, ht =
|
|
4493
|
+
const lt = (Ce = (Ie = n.originX) != null ? Ie : K) != null ? Ce : "left", pt = m + p, At = m + p / 2, ht = U != null ? U : p, jt = S !== ht, Ft = Math.abs(C - (Z != null ? Z : c)) > st, Nt = Math.abs(F.top - x) > st || Math.abs(F.right - W) > st || Math.abs(F.bottom - Y) > st || Math.abs(F.left - H) > st, xt = Math.abs(Q.topLeft - V) > st || Math.abs(Q.topRight - L) > st || Math.abs(Q.bottomRight - D) > st || Math.abs(Q.bottomLeft - P) > st;
|
|
4492
4494
|
if (!jt && !Ft && !Nt && !xt) {
|
|
4493
4495
|
o.set({ scaleX: 1, scaleY: 1 }), n.scaleX = 1, n.scaleY = 1;
|
|
4494
4496
|
return;
|
|
@@ -4496,10 +4498,10 @@ class Z {
|
|
|
4496
4498
|
et && (o.styles = et), o.set({
|
|
4497
4499
|
width: S,
|
|
4498
4500
|
fontSize: A ? C : c,
|
|
4499
|
-
paddingTop:
|
|
4500
|
-
paddingRight:
|
|
4501
|
-
paddingBottom:
|
|
4502
|
-
paddingLeft:
|
|
4501
|
+
paddingTop: F.top,
|
|
4502
|
+
paddingRight: F.right,
|
|
4503
|
+
paddingBottom: F.bottom,
|
|
4504
|
+
paddingLeft: F.left,
|
|
4503
4505
|
radiusTopLeft: Q.topLeft,
|
|
4504
4506
|
radiusTopRight: Q.topRight,
|
|
4505
4507
|
radiusBottomRight: Q.bottomRight,
|
|
@@ -4507,17 +4509,17 @@ class Z {
|
|
|
4507
4509
|
scaleX: 1,
|
|
4508
4510
|
scaleY: 1
|
|
4509
4511
|
});
|
|
4510
|
-
const Bt =
|
|
4512
|
+
const Bt = z._roundTextboxDimensions({ textbox: o });
|
|
4511
4513
|
Bt && (o.dirty = !0);
|
|
4512
4514
|
const ut = (Te = o.width) != null ? Te : S, kt = ut !== ht;
|
|
4513
4515
|
let gt = m;
|
|
4514
|
-
kt && (I ||
|
|
4516
|
+
kt && (I || M) && (lt === "right" ? gt = pt - ut : lt === "center" && (gt = At - ut / 2)), o.set({ left: gt }), i.baseLeft = gt, n.scaleX = 1, n.scaleY = 1;
|
|
4515
4517
|
const { original: it } = n;
|
|
4516
4518
|
it && (it.scaleX = 1, it.scaleY = 1, it.width = ut, it.height = o.height, it.left = gt), o.setCoords(), this.canvas.requestRenderAll(), i.baseWidth = ut, i.baseFontSize = (Ee = o.fontSize) != null ? Ee : C, i.baseStyles = JSON.parse(JSON.stringify((Oe = o.styles) != null ? Oe : {})), i.basePadding = {
|
|
4517
|
-
top:
|
|
4518
|
-
right:
|
|
4519
|
-
bottom:
|
|
4520
|
-
left:
|
|
4519
|
+
top: F.top,
|
|
4520
|
+
right: F.right,
|
|
4521
|
+
bottom: F.bottom,
|
|
4522
|
+
left: F.left
|
|
4521
4523
|
}, i.baseRadii = {
|
|
4522
4524
|
topLeft: Q.topLeft,
|
|
4523
4525
|
topRight: Q.topRight,
|
|
@@ -4528,38 +4530,38 @@ class Z {
|
|
|
4528
4530
|
var b, I, y;
|
|
4529
4531
|
const { target: o } = s;
|
|
4530
4532
|
if (o instanceof k) {
|
|
4531
|
-
const
|
|
4532
|
-
if (!
|
|
4533
|
-
const { scaleX: j = 1, scaleY:
|
|
4534
|
-
if (Math.abs(j - 1) < st && Math.abs(
|
|
4535
|
-
this.canvas.discardActiveObject(),
|
|
4536
|
-
var C, x,
|
|
4537
|
-
if (
|
|
4538
|
-
const
|
|
4539
|
-
paddingTop:
|
|
4540
|
-
paddingRight:
|
|
4533
|
+
const M = o.getObjects();
|
|
4534
|
+
if (!M.some((S) => z._isTextbox(S))) return;
|
|
4535
|
+
const { scaleX: j = 1, scaleY: w = 1 } = o;
|
|
4536
|
+
if (Math.abs(j - 1) < st && Math.abs(w - 1) < st) return;
|
|
4537
|
+
this.canvas.discardActiveObject(), M.forEach((S) => {
|
|
4538
|
+
var C, x, W, Y;
|
|
4539
|
+
if (z._isTextbox(S)) {
|
|
4540
|
+
const H = (C = S.scaleX) != null ? C : 1, V = (x = S.scaleY) != null ? x : 1, L = ((W = S.fontSize) != null ? W : 16) * V, D = ((Y = S.width) != null ? Y : 0) * H, P = V, {
|
|
4541
|
+
paddingTop: Z = 0,
|
|
4542
|
+
paddingRight: U = 0,
|
|
4541
4543
|
paddingBottom: K = 0,
|
|
4542
4544
|
paddingLeft: $ = 0,
|
|
4543
4545
|
radiusTopLeft: q = 0,
|
|
4544
|
-
radiusTopRight:
|
|
4546
|
+
radiusTopRight: F = 0,
|
|
4545
4547
|
radiusBottomRight: Q = 0,
|
|
4546
4548
|
radiusBottomLeft: St = 0,
|
|
4547
4549
|
styles: et
|
|
4548
4550
|
} = S, lt = {
|
|
4549
|
-
paddingTop: Math.max(0,
|
|
4550
|
-
paddingRight: Math.max(0,
|
|
4551
|
-
paddingBottom: Math.max(0, K *
|
|
4552
|
-
paddingLeft: Math.max(0, $ *
|
|
4551
|
+
paddingTop: Math.max(0, Z * P),
|
|
4552
|
+
paddingRight: Math.max(0, U * P),
|
|
4553
|
+
paddingBottom: Math.max(0, K * P),
|
|
4554
|
+
paddingLeft: Math.max(0, $ * P)
|
|
4553
4555
|
}, pt = {
|
|
4554
|
-
radiusTopLeft: Math.max(0, q *
|
|
4555
|
-
radiusTopRight: Math.max(0,
|
|
4556
|
-
radiusBottomRight: Math.max(0, Q *
|
|
4557
|
-
radiusBottomLeft: Math.max(0, St *
|
|
4556
|
+
radiusTopLeft: Math.max(0, q * P),
|
|
4557
|
+
radiusTopRight: Math.max(0, F * P),
|
|
4558
|
+
radiusBottomRight: Math.max(0, Q * P),
|
|
4559
|
+
radiusBottomLeft: Math.max(0, St * P)
|
|
4558
4560
|
};
|
|
4559
4561
|
let At = et;
|
|
4560
4562
|
et && Object.keys(et).length > 0 && (At = JSON.parse(JSON.stringify(et)), Object.values(At).forEach((ht) => {
|
|
4561
4563
|
Object.values(ht).forEach((jt) => {
|
|
4562
|
-
typeof jt.fontSize == "number" && (jt.fontSize = Math.max(1, jt.fontSize *
|
|
4564
|
+
typeof jt.fontSize == "number" && (jt.fontSize = Math.max(1, jt.fontSize * P));
|
|
4563
4565
|
});
|
|
4564
4566
|
})), S.set(yt(_(_({
|
|
4565
4567
|
fontSize: L,
|
|
@@ -4568,17 +4570,17 @@ class Z {
|
|
|
4568
4570
|
scaleY: 1
|
|
4569
4571
|
}, lt), pt), {
|
|
4570
4572
|
styles: At
|
|
4571
|
-
})),
|
|
4573
|
+
})), z._roundTextboxDimensions({ textbox: S });
|
|
4572
4574
|
}
|
|
4573
4575
|
S.setCoords();
|
|
4574
4576
|
});
|
|
4575
|
-
const T = new k(
|
|
4577
|
+
const T = new k(M, {
|
|
4576
4578
|
canvas: this.canvas
|
|
4577
4579
|
});
|
|
4578
4580
|
this.canvas.setActiveObject(T), this.canvas.requestRenderAll();
|
|
4579
4581
|
return;
|
|
4580
4582
|
}
|
|
4581
|
-
if (!
|
|
4583
|
+
if (!z._isTextbox(o)) return;
|
|
4582
4584
|
o.isScaling = !1;
|
|
4583
4585
|
const n = this.scalingState.get(o);
|
|
4584
4586
|
if (this.scalingState.delete(o), !(n != null && n.hasWidthChange)) return;
|
|
@@ -4613,8 +4615,8 @@ class Z {
|
|
|
4613
4615
|
* @param options — настройки текста
|
|
4614
4616
|
* @param flags — флаги поведения
|
|
4615
4617
|
*/
|
|
4616
|
-
addText(
|
|
4617
|
-
var
|
|
4618
|
+
addText(W = {}, { withoutSelection: S = !1, withoutSave: C = !1, withoutAdding: x = !1 } = {}) {
|
|
4619
|
+
var Y = W, {
|
|
4618
4620
|
id: t = `text-${G()}`,
|
|
4619
4621
|
text: e = "Новый текст",
|
|
4620
4622
|
fontFamily: s,
|
|
@@ -4635,11 +4637,11 @@ class Z {
|
|
|
4635
4637
|
paddingRight: b = 0,
|
|
4636
4638
|
paddingBottom: I = 0,
|
|
4637
4639
|
paddingLeft: y = 0,
|
|
4638
|
-
radiusTopLeft:
|
|
4640
|
+
radiusTopLeft: M = 0,
|
|
4639
4641
|
radiusTopRight: A = 0,
|
|
4640
4642
|
radiusBottomRight: j = 0,
|
|
4641
|
-
radiusBottomLeft:
|
|
4642
|
-
} =
|
|
4643
|
+
radiusBottomLeft: w = 0
|
|
4644
|
+
} = Y, T = vt(Y, [
|
|
4643
4645
|
"id",
|
|
4644
4646
|
"text",
|
|
4645
4647
|
"fontFamily",
|
|
@@ -4666,12 +4668,12 @@ class Z {
|
|
|
4666
4668
|
"radiusBottomLeft"
|
|
4667
4669
|
]);
|
|
4668
4670
|
var $;
|
|
4669
|
-
const { historyManager:
|
|
4670
|
-
|
|
4671
|
-
const L = s != null ? s : this._getDefaultFontFamily(), D = Ke({ width: g }),
|
|
4671
|
+
const { historyManager: H } = this.editor, { canvas: V } = this;
|
|
4672
|
+
H.suspendHistory();
|
|
4673
|
+
const L = s != null ? s : this._getDefaultFontFamily(), D = Ke({ width: g }), P = Xe({
|
|
4672
4674
|
strokeColor: u,
|
|
4673
4675
|
width: D
|
|
4674
|
-
}),
|
|
4676
|
+
}), Z = _({
|
|
4675
4677
|
id: t,
|
|
4676
4678
|
fontFamily: L,
|
|
4677
4679
|
fontSize: o,
|
|
@@ -4682,7 +4684,7 @@ class Z {
|
|
|
4682
4684
|
linethrough: c,
|
|
4683
4685
|
textAlign: d,
|
|
4684
4686
|
fill: l,
|
|
4685
|
-
stroke:
|
|
4687
|
+
stroke: P,
|
|
4686
4688
|
strokeWidth: D,
|
|
4687
4689
|
strokeUniform: !0,
|
|
4688
4690
|
opacity: f,
|
|
@@ -4692,25 +4694,25 @@ class Z {
|
|
|
4692
4694
|
paddingRight: b,
|
|
4693
4695
|
paddingBottom: I,
|
|
4694
4696
|
paddingLeft: y,
|
|
4695
|
-
radiusTopLeft:
|
|
4697
|
+
radiusTopLeft: M,
|
|
4696
4698
|
radiusTopRight: A,
|
|
4697
4699
|
radiusBottomRight: j,
|
|
4698
|
-
radiusBottomLeft:
|
|
4699
|
-
}, T),
|
|
4700
|
-
if (
|
|
4701
|
-
const q = ie({ value:
|
|
4702
|
-
q !==
|
|
4703
|
-
}
|
|
4704
|
-
return
|
|
4705
|
-
textbox:
|
|
4706
|
-
options: yt(_({},
|
|
4700
|
+
radiusBottomLeft: w
|
|
4701
|
+
}, T), U = new ee(e, Z);
|
|
4702
|
+
if (U.textCaseRaw = ($ = U.text) != null ? $ : "", r) {
|
|
4703
|
+
const q = ie({ value: U.textCaseRaw });
|
|
4704
|
+
q !== U.text && U.set({ text: q });
|
|
4705
|
+
}
|
|
4706
|
+
return z._roundTextboxDimensions({ textbox: U }) && (U.dirty = !0), T.left === void 0 && T.top === void 0 && V.centerObject(U), x || V.add(U), S || V.setActiveObject(U), V.requestRenderAll(), H.resumeHistory(), C || H.saveState(), V.fire("editor:text-added", {
|
|
4707
|
+
textbox: U,
|
|
4708
|
+
options: yt(_({}, Z), {
|
|
4707
4709
|
text: e,
|
|
4708
4710
|
bold: n,
|
|
4709
4711
|
italic: i,
|
|
4710
4712
|
strikethrough: c,
|
|
4711
4713
|
align: d,
|
|
4712
4714
|
color: l,
|
|
4713
|
-
strokeColor:
|
|
4715
|
+
strokeColor: P,
|
|
4714
4716
|
strokeWidth: D
|
|
4715
4717
|
}),
|
|
4716
4718
|
flags: {
|
|
@@ -4718,7 +4720,7 @@ class Z {
|
|
|
4718
4720
|
withoutSave: !!C,
|
|
4719
4721
|
withoutAdding: !!x
|
|
4720
4722
|
}
|
|
4721
|
-
}),
|
|
4723
|
+
}), U;
|
|
4722
4724
|
}
|
|
4723
4725
|
/**
|
|
4724
4726
|
* Обновляет текстовый объект.
|
|
@@ -4734,7 +4736,7 @@ class Z {
|
|
|
4734
4736
|
if (!n) return null;
|
|
4735
4737
|
const { historyManager: i } = this.editor, { canvas: a } = this;
|
|
4736
4738
|
i.suspendHistory();
|
|
4737
|
-
const r =
|
|
4739
|
+
const r = z._getSnapshot(n), Nt = e, {
|
|
4738
4740
|
text: c,
|
|
4739
4741
|
fontFamily: d,
|
|
4740
4742
|
fontSize: l,
|
|
@@ -4747,17 +4749,17 @@ class Z {
|
|
|
4747
4749
|
color: b,
|
|
4748
4750
|
strokeColor: I,
|
|
4749
4751
|
strokeWidth: y,
|
|
4750
|
-
opacity:
|
|
4752
|
+
opacity: M,
|
|
4751
4753
|
backgroundColor: A,
|
|
4752
4754
|
backgroundOpacity: j,
|
|
4753
|
-
paddingTop:
|
|
4755
|
+
paddingTop: w,
|
|
4754
4756
|
paddingRight: T,
|
|
4755
4757
|
paddingBottom: S,
|
|
4756
4758
|
paddingLeft: C,
|
|
4757
4759
|
radiusTopLeft: x,
|
|
4758
|
-
radiusTopRight:
|
|
4759
|
-
radiusBottomRight:
|
|
4760
|
-
radiusBottomLeft:
|
|
4760
|
+
radiusTopRight: W,
|
|
4761
|
+
radiusBottomRight: Y,
|
|
4762
|
+
radiusBottomLeft: H
|
|
4761
4763
|
} = Nt, V = vt(Nt, [
|
|
4762
4764
|
"text",
|
|
4763
4765
|
"fontFamily",
|
|
@@ -4782,23 +4784,23 @@ class Z {
|
|
|
4782
4784
|
"radiusTopRight",
|
|
4783
4785
|
"radiusBottomRight",
|
|
4784
4786
|
"radiusBottomLeft"
|
|
4785
|
-
]), L = _({}, V), D = ao({ textbox: n }),
|
|
4786
|
-
if (d !== void 0 && (
|
|
4787
|
+
]), L = _({}, V), D = ao({ textbox: n }), P = D ? z._expandRangeToFullLines({ textbox: n, range: D }) : null, Z = {}, U = {}, K = {}, $ = co({ textbox: n, range: D }), q = !D || $, F = !D;
|
|
4788
|
+
if (d !== void 0 && (P && (U.fontFamily = d), q && (L.fontFamily = d, F && (K.fontFamily = d))), l !== void 0 && (P && (U.fontSize = l), q && (L.fontSize = l, F && (K.fontSize = l))), u !== void 0) {
|
|
4787
4789
|
const X = u ? "bold" : "normal";
|
|
4788
|
-
D && (
|
|
4790
|
+
D && (Z.fontWeight = X), q && (L.fontWeight = X, F && (K.fontWeight = X));
|
|
4789
4791
|
}
|
|
4790
4792
|
if (g !== void 0) {
|
|
4791
4793
|
const X = g ? "italic" : "normal";
|
|
4792
|
-
D && (
|
|
4794
|
+
D && (Z.fontStyle = X), q && (L.fontStyle = X, F && (K.fontStyle = X));
|
|
4793
4795
|
}
|
|
4794
|
-
if (f !== void 0 && (D && (
|
|
4796
|
+
if (f !== void 0 && (D && (Z.underline = f), q && (L.underline = f, F && (K.underline = f))), m !== void 0 && (D && (Z.linethrough = m), q && (L.linethrough = m, F && (K.linethrough = m))), v !== void 0 && (L.textAlign = v), b !== void 0 && (D && (Z.fill = b), q && (L.fill = b, F && (K.fill = b))), I !== void 0 || y !== void 0) {
|
|
4795
4797
|
const X = D ? Ve({ textbox: n, range: D, property: "strokeWidth" }) : void 0, It = D ? Ve({ textbox: n, range: D, property: "stroke" }) : void 0, Wt = (Bt = (xt = y != null ? y : X) != null ? xt : n.strokeWidth) != null ? Bt : 0, mt = Ke({ width: Wt }), Ht = (kt = (ut = I != null ? I : It) != null ? ut : n.stroke) != null ? kt : void 0, Ct = Xe({
|
|
4796
4798
|
strokeColor: Ht,
|
|
4797
4799
|
width: mt
|
|
4798
4800
|
});
|
|
4799
|
-
D && (
|
|
4801
|
+
D && (Z.stroke = Ct, Z.strokeWidth = mt), q && (L.stroke = Ct, L.strokeWidth = mt, F && (K.stroke = Ct, K.strokeWidth = mt));
|
|
4800
4802
|
}
|
|
4801
|
-
|
|
4803
|
+
M !== void 0 && (L.opacity = M), A !== void 0 && (L.backgroundColor = A), j !== void 0 && (L.backgroundOpacity = j), w !== void 0 && (L.paddingTop = w), T !== void 0 && (L.paddingRight = T), S !== void 0 && (L.paddingBottom = S), C !== void 0 && (L.paddingLeft = C), x !== void 0 && (L.radiusTopLeft = x), W !== void 0 && (L.radiusTopRight = W), Y !== void 0 && (L.radiusBottomRight = Y), H !== void 0 && (L.radiusBottomLeft = H);
|
|
4802
4804
|
const Q = (it = n.textCaseRaw) != null ? it : (gt = n.text) != null ? gt : "", St = !!n.uppercase, et = c !== void 0, lt = et ? c != null ? c : "" : Q, pt = p != null ? p : St;
|
|
4803
4805
|
if (et || pt !== St) {
|
|
4804
4806
|
const X = pt ? ie({ value: lt }) : lt;
|
|
@@ -4807,14 +4809,14 @@ class Z {
|
|
|
4807
4809
|
n.uppercase = pt, n.set(L);
|
|
4808
4810
|
let ht = !1;
|
|
4809
4811
|
if (D) {
|
|
4810
|
-
const X = ne({ textbox: n, styles:
|
|
4812
|
+
const X = ne({ textbox: n, styles: Z, range: D }), It = P ? ne({ textbox: n, styles: U, range: P }) : !1;
|
|
4811
4813
|
ht = X || It;
|
|
4812
4814
|
} else if (Object.keys(K).length) {
|
|
4813
4815
|
const X = ro({ textbox: n });
|
|
4814
4816
|
X && (ht = ne({ textbox: n, styles: K, range: X }));
|
|
4815
4817
|
}
|
|
4816
|
-
ht && (n.dirty = !0), (A !== void 0 || j !== void 0 ||
|
|
4817
|
-
const Ft =
|
|
4818
|
+
ht && (n.dirty = !0), (A !== void 0 || j !== void 0 || w !== void 0 || T !== void 0 || S !== void 0 || C !== void 0 || x !== void 0 || W !== void 0 || Y !== void 0 || H !== void 0) && (n.dirty = !0), z._roundTextboxDimensions({ textbox: n }) && (n.dirty = !0), n.setCoords(), o || a.requestRenderAll(), i.resumeHistory(), s || i.saveState();
|
|
4819
|
+
const Ft = z._getSnapshot(n);
|
|
4818
4820
|
return a.fire("editor:text-updated", {
|
|
4819
4821
|
textbox: n,
|
|
4820
4822
|
target: t,
|
|
@@ -4827,7 +4829,7 @@ class Z {
|
|
|
4827
4829
|
before: r,
|
|
4828
4830
|
after: Ft,
|
|
4829
4831
|
selectionRange: D != null ? D : void 0,
|
|
4830
|
-
selectionStyles: D && Object.keys(
|
|
4832
|
+
selectionStyles: D && Object.keys(Z).length ? Z : void 0
|
|
4831
4833
|
}), n;
|
|
4832
4834
|
}
|
|
4833
4835
|
/**
|
|
@@ -4835,7 +4837,7 @@ class Z {
|
|
|
4835
4837
|
*/
|
|
4836
4838
|
destroy() {
|
|
4837
4839
|
const { canvas: t } = this;
|
|
4838
|
-
t.off("object:scaling", this._handleObjectScaling), t.off("object:modified", this._handleObjectModified), t.off("text:editing:exited", this._handleTextEditingExited), t.off("text:editing:entered", this._handleTextEditingEntered), t.off("text:changed",
|
|
4840
|
+
t.off("object:scaling", this._handleObjectScaling), t.off("object:resizing", z._handleObjectResizing), t.off("object:modified", this._handleObjectModified), t.off("text:editing:exited", this._handleTextEditingExited), t.off("text:editing:entered", this._handleTextEditingEntered), t.off("text:changed", z._handleTextChanged);
|
|
4839
4841
|
}
|
|
4840
4842
|
/**
|
|
4841
4843
|
* Возвращает активный текст или ищет по id.
|
|
@@ -4845,10 +4847,10 @@ class Z {
|
|
|
4845
4847
|
const { canvas: e } = this;
|
|
4846
4848
|
if (!t) {
|
|
4847
4849
|
const s = e.getActiveObject();
|
|
4848
|
-
return
|
|
4850
|
+
return z._isTextbox(s) ? s : null;
|
|
4849
4851
|
}
|
|
4850
4852
|
if (typeof t == "string") {
|
|
4851
|
-
const s = e.getObjects().find((o) =>
|
|
4853
|
+
const s = e.getObjects().find((o) => z._isTextbox(o) && o.id === t);
|
|
4852
4854
|
return s != null ? s : null;
|
|
4853
4855
|
}
|
|
4854
4856
|
return null;
|
|
@@ -4864,12 +4866,53 @@ class Z {
|
|
|
4864
4866
|
*/
|
|
4865
4867
|
_bindEvents() {
|
|
4866
4868
|
const { canvas: t } = this;
|
|
4867
|
-
t.on("object:scaling", this._handleObjectScaling), t.on("object:modified", this._handleObjectModified), t.on("text:editing:entered", this._handleTextEditingEntered), t.on("text:editing:exited", this._handleTextEditingExited), t.on("text:changed",
|
|
4869
|
+
t.on("object:scaling", this._handleObjectScaling), t.on("object:resizing", z._handleObjectResizing), t.on("object:modified", this._handleObjectModified), t.on("text:editing:entered", this._handleTextEditingEntered), t.on("text:editing:exited", this._handleTextEditingExited), t.on("text:changed", z._handleTextChanged);
|
|
4870
|
+
}
|
|
4871
|
+
/**
|
|
4872
|
+
* Реагирует на изменение текста в режиме редактирования: синхронизирует textCaseRaw и uppercase.
|
|
4873
|
+
*/
|
|
4874
|
+
static _handleTextChanged(t) {
|
|
4875
|
+
const { target: e } = t;
|
|
4876
|
+
if (!z._isTextbox(e)) return;
|
|
4877
|
+
const { text: s = "", uppercase: o } = e, n = !!o, i = s.toLocaleLowerCase();
|
|
4878
|
+
if (n) {
|
|
4879
|
+
const r = ie({ value: i });
|
|
4880
|
+
r !== s && e.set({ text: r }), e.textCaseRaw = i;
|
|
4881
|
+
} else
|
|
4882
|
+
e.textCaseRaw = s;
|
|
4883
|
+
z._roundTextboxDimensions({ textbox: e }) && (e.setCoords(), e.dirty = !0);
|
|
4884
|
+
}
|
|
4885
|
+
/**
|
|
4886
|
+
* Обрабатывает изменение ширины текстового объекта (resizing).
|
|
4887
|
+
* Корректирует ширину, вычитая паддинги, так как Fabric при изменении ширины
|
|
4888
|
+
* устанавливает значение, включающее визуальные отступы.
|
|
4889
|
+
* Также корректирует позицию при ресайзе слева, чтобы компенсировать смещение.
|
|
4890
|
+
*/
|
|
4891
|
+
static _handleObjectResizing(t) {
|
|
4892
|
+
var l, u, g, f, p, m;
|
|
4893
|
+
const { target: e, transform: s } = t;
|
|
4894
|
+
if (!z._isTextbox(e)) return;
|
|
4895
|
+
const {
|
|
4896
|
+
paddingLeft: o = 0,
|
|
4897
|
+
paddingRight: n = 0
|
|
4898
|
+
} = e, i = o + n;
|
|
4899
|
+
if (i === 0) return;
|
|
4900
|
+
const a = (l = e.width) != null ? l : 0, r = Math.max(0, a - i);
|
|
4901
|
+
if (a === r) return;
|
|
4902
|
+
e.set({ width: r });
|
|
4903
|
+
const c = (u = e.width) != null ? u : 0, d = a - c;
|
|
4904
|
+
if (d !== 0 && s && s.corner === "ml") {
|
|
4905
|
+
const b = ((g = e.angle) != null ? g : 0) * Math.PI / 180, I = Math.cos(b), y = Math.sin(b), M = (f = e.scaleX) != null ? f : 1, A = d * M;
|
|
4906
|
+
e.set({
|
|
4907
|
+
left: ((p = e.left) != null ? p : 0) + A * I,
|
|
4908
|
+
top: ((m = e.top) != null ? m : 0) + A * y
|
|
4909
|
+
});
|
|
4910
|
+
}
|
|
4868
4911
|
}
|
|
4869
4912
|
/**
|
|
4870
4913
|
* Возвращает диапазоны символов для каждой строки текста без учёта символов переноса.
|
|
4871
4914
|
*/
|
|
4872
|
-
_getLineRanges({ textbox: t }) {
|
|
4915
|
+
static _getLineRanges({ textbox: t }) {
|
|
4873
4916
|
var n;
|
|
4874
4917
|
const e = (n = t.text) != null ? n : "";
|
|
4875
4918
|
if (!e.length) return [];
|
|
@@ -4884,11 +4927,11 @@ class Z {
|
|
|
4884
4927
|
/**
|
|
4885
4928
|
* Расширяет выделение до полных строк, которые оно пересекает.
|
|
4886
4929
|
*/
|
|
4887
|
-
_expandRangeToFullLines({
|
|
4930
|
+
static _expandRangeToFullLines({
|
|
4888
4931
|
textbox: t,
|
|
4889
4932
|
range: e
|
|
4890
4933
|
}) {
|
|
4891
|
-
const s =
|
|
4934
|
+
const s = z._getLineRanges({ textbox: t });
|
|
4892
4935
|
if (!s.length) return e;
|
|
4893
4936
|
let { start: o } = e, { end: n } = e;
|
|
4894
4937
|
return s.forEach(({ start: i, end: a }) => {
|
|
@@ -4950,10 +4993,10 @@ class Z {
|
|
|
4950
4993
|
static _roundTextboxDimensions({
|
|
4951
4994
|
textbox: t
|
|
4952
4995
|
}) {
|
|
4953
|
-
const { width: e, height: s, calcTextWidth: o, calcTextHeight: n } = t, i = typeof o == "function" ? o.call(t) : void 0, a = typeof n == "function" ? n.call(t) : void 0, r =
|
|
4996
|
+
const { width: e, height: s, calcTextWidth: o, calcTextHeight: n } = t, i = typeof o == "function" ? o.call(t) : void 0, a = typeof n == "function" ? n.call(t) : void 0, r = z._resolveDimension({
|
|
4954
4997
|
rawValue: e,
|
|
4955
4998
|
calculatedValue: i
|
|
4956
|
-
}), c =
|
|
4999
|
+
}), c = z._resolveDimension({
|
|
4957
5000
|
rawValue: s,
|
|
4958
5001
|
calculatedValue: a
|
|
4959
5002
|
}), d = Number.isFinite(r) ? Math.round(r) : null, l = Number.isFinite(c) ? Math.round(c) : null, u = {};
|
|
@@ -4964,11 +5007,11 @@ class Z {
|
|
|
4964
5007
|
*/
|
|
4965
5008
|
static _getSnapshot(t) {
|
|
4966
5009
|
const e = ({
|
|
4967
|
-
snapshot:
|
|
4968
|
-
entries:
|
|
5010
|
+
snapshot: Z,
|
|
5011
|
+
entries: U
|
|
4969
5012
|
}) => {
|
|
4970
|
-
Object.entries(
|
|
4971
|
-
$ != null && (
|
|
5013
|
+
Object.entries(U).forEach(([K, $]) => {
|
|
5014
|
+
$ != null && (Z[K] = $);
|
|
4972
5015
|
});
|
|
4973
5016
|
}, {
|
|
4974
5017
|
id: s,
|
|
@@ -4989,27 +5032,27 @@ class Z {
|
|
|
4989
5032
|
backgroundColor: b,
|
|
4990
5033
|
backgroundOpacity: I,
|
|
4991
5034
|
paddingTop: y,
|
|
4992
|
-
paddingRight:
|
|
5035
|
+
paddingRight: M,
|
|
4993
5036
|
paddingBottom: A,
|
|
4994
5037
|
paddingLeft: j,
|
|
4995
|
-
radiusTopLeft:
|
|
5038
|
+
radiusTopLeft: w,
|
|
4996
5039
|
radiusTopRight: T,
|
|
4997
5040
|
radiusBottomRight: S,
|
|
4998
5041
|
radiusBottomLeft: C,
|
|
4999
5042
|
left: x,
|
|
5000
|
-
top:
|
|
5001
|
-
width:
|
|
5002
|
-
height:
|
|
5043
|
+
top: W,
|
|
5044
|
+
width: Y,
|
|
5045
|
+
height: H,
|
|
5003
5046
|
angle: V,
|
|
5004
5047
|
scaleX: L,
|
|
5005
5048
|
scaleY: D
|
|
5006
|
-
} = t,
|
|
5049
|
+
} = t, P = {
|
|
5007
5050
|
id: s,
|
|
5008
5051
|
uppercase: !!i,
|
|
5009
5052
|
textAlign: g
|
|
5010
5053
|
};
|
|
5011
5054
|
return e({
|
|
5012
|
-
snapshot:
|
|
5055
|
+
snapshot: P,
|
|
5013
5056
|
entries: {
|
|
5014
5057
|
text: o,
|
|
5015
5058
|
textCaseRaw: n,
|
|
@@ -5026,22 +5069,22 @@ class Z {
|
|
|
5026
5069
|
backgroundColor: b,
|
|
5027
5070
|
backgroundOpacity: I,
|
|
5028
5071
|
paddingTop: y,
|
|
5029
|
-
paddingRight:
|
|
5072
|
+
paddingRight: M,
|
|
5030
5073
|
paddingBottom: A,
|
|
5031
5074
|
paddingLeft: j,
|
|
5032
|
-
radiusTopLeft:
|
|
5075
|
+
radiusTopLeft: w,
|
|
5033
5076
|
radiusTopRight: T,
|
|
5034
5077
|
radiusBottomRight: S,
|
|
5035
5078
|
radiusBottomLeft: C,
|
|
5036
5079
|
left: x,
|
|
5037
|
-
top:
|
|
5038
|
-
width:
|
|
5039
|
-
height:
|
|
5080
|
+
top: W,
|
|
5081
|
+
width: Y,
|
|
5082
|
+
height: H,
|
|
5040
5083
|
angle: V,
|
|
5041
5084
|
scaleX: L,
|
|
5042
5085
|
scaleY: D
|
|
5043
5086
|
}
|
|
5044
|
-
}),
|
|
5087
|
+
}), P;
|
|
5045
5088
|
}
|
|
5046
5089
|
/**
|
|
5047
5090
|
* Возвращает первый доступный шрифт или дефолтный Arial.
|
|
@@ -5154,32 +5197,37 @@ const ot = ({
|
|
|
5154
5197
|
y2: s
|
|
5155
5198
|
}) => (Math.atan2(s - t, e - h) * 180 / Math.PI + 360) % 360, fo = (h) => {
|
|
5156
5199
|
if (!h || typeof h != "object") return null;
|
|
5157
|
-
const { type: t, coords: e, colorStops: s } = h, o = Array.isArray(s) ? s : [], n = o[0], i = o[o.length - 1], a = typeof (n == null ? void 0 : n.color) == "string" ? n.color : void 0, r = typeof (i == null ? void 0 : i.color) == "string" ? i.color : a, c = typeof (n == null ? void 0 : n.offset) == "number" ? n.offset * 100 : void 0, d = typeof (i == null ? void 0 : i.offset) == "number" ? i.offset * 100 : void 0
|
|
5200
|
+
const { type: t, coords: e, colorStops: s } = h, o = Array.isArray(s) ? s : [], n = o[0], i = o[o.length - 1], a = typeof (n == null ? void 0 : n.color) == "string" ? n.color : void 0, r = typeof (i == null ? void 0 : i.color) == "string" ? i.color : a, c = typeof (n == null ? void 0 : n.offset) == "number" ? n.offset * 100 : void 0, d = typeof (i == null ? void 0 : i.offset) == "number" ? i.offset * 100 : void 0, l = o.map((u) => ({
|
|
5201
|
+
color: typeof u.color == "string" ? u.color : "#000000",
|
|
5202
|
+
offset: typeof u.offset == "number" ? u.offset * 100 : 0
|
|
5203
|
+
}));
|
|
5158
5204
|
if (!a || !r || !e) return null;
|
|
5159
5205
|
if (t === "linear") {
|
|
5160
|
-
const { x1:
|
|
5161
|
-
if (typeof
|
|
5206
|
+
const { x1: u, y1: g, x2: f, y2: p } = e;
|
|
5207
|
+
if (typeof u == "number" && typeof g == "number" && typeof f == "number" && typeof p == "number")
|
|
5162
5208
|
return {
|
|
5163
5209
|
type: "linear",
|
|
5164
|
-
angle: go({ x1:
|
|
5210
|
+
angle: go({ x1: u, y1: g, x2: f, y2: p }),
|
|
5165
5211
|
startColor: a,
|
|
5166
5212
|
endColor: r,
|
|
5167
5213
|
startPosition: c,
|
|
5168
|
-
endPosition: d
|
|
5214
|
+
endPosition: d,
|
|
5215
|
+
colorStops: l
|
|
5169
5216
|
};
|
|
5170
5217
|
}
|
|
5171
5218
|
if (t === "radial") {
|
|
5172
|
-
const { x1:
|
|
5173
|
-
if (typeof
|
|
5219
|
+
const { x1: u, y1: g, r2: f } = e;
|
|
5220
|
+
if (typeof u == "number" && typeof g == "number" && typeof f == "number")
|
|
5174
5221
|
return {
|
|
5175
5222
|
type: "radial",
|
|
5176
|
-
centerX:
|
|
5177
|
-
centerY:
|
|
5178
|
-
radius:
|
|
5223
|
+
centerX: u * 100,
|
|
5224
|
+
centerY: g * 100,
|
|
5225
|
+
radius: f * 100,
|
|
5179
5226
|
startColor: a,
|
|
5180
5227
|
endColor: r,
|
|
5181
5228
|
startPosition: c,
|
|
5182
|
-
endPosition: d
|
|
5229
|
+
endPosition: d,
|
|
5230
|
+
colorStops: l
|
|
5183
5231
|
};
|
|
5184
5232
|
}
|
|
5185
5233
|
return null;
|
|
@@ -5211,8 +5259,8 @@ class R {
|
|
|
5211
5259
|
code: bt.TEMPLATE_MANAGER.NO_OBJECTS_SELECTED,
|
|
5212
5260
|
message: "Нет объектов для сериализации шаблона"
|
|
5213
5261
|
}), null;
|
|
5214
|
-
const f = R._getBounds(i), p = R._getMontageSize({ montageArea: i, bounds: f }), m = p.width, v = p.height, b = g.map((
|
|
5215
|
-
object:
|
|
5262
|
+
const f = R._getBounds(i), p = R._getMontageSize({ montageArea: i, bounds: f }), m = p.width, v = p.height, b = g.map((M) => R._serializeObject({
|
|
5263
|
+
object: M,
|
|
5216
5264
|
bounds: f,
|
|
5217
5265
|
baseWidth: m,
|
|
5218
5266
|
baseHeight: v,
|
|
@@ -5274,13 +5322,13 @@ class R {
|
|
|
5274
5322
|
code: bt.TEMPLATE_MANAGER.INVALID_TEMPLATE,
|
|
5275
5323
|
message: "Не удалось создать объекты шаблона"
|
|
5276
5324
|
}), null;
|
|
5277
|
-
const { backgroundObject: y, contentObjects:
|
|
5325
|
+
const { backgroundObject: y, contentObjects: M } = R._extractBackgroundObject(I);
|
|
5278
5326
|
y && (b = yield R._applyBackgroundFromObject({
|
|
5279
5327
|
backgroundObject: y,
|
|
5280
5328
|
backgroundManager: r,
|
|
5281
5329
|
errorManager: a
|
|
5282
5330
|
}));
|
|
5283
|
-
const A =
|
|
5331
|
+
const A = M.map((j) => (R._applyTextOverrides({ object: j, data: e }), R._transformObject({
|
|
5284
5332
|
object: j,
|
|
5285
5333
|
scale: p,
|
|
5286
5334
|
bounds: u,
|
|
@@ -5377,8 +5425,8 @@ class R {
|
|
|
5377
5425
|
naturalHeight: 0,
|
|
5378
5426
|
width: 0,
|
|
5379
5427
|
height: 0
|
|
5380
|
-
}, f = ot({ value: d || u || r.width, fallback: 0 }), p = ot({ value: l || g || r.height, fallback: 0 }), m = ot({ value: o, fallback: f }), v = ot({ value: n, fallback: p }), b = ot({ value: i, fallback: r.scaleX || 1 }), I = ot({ value: a, fallback: r.scaleY || 1 }), y = m * b,
|
|
5381
|
-
f > 0 && (
|
|
5428
|
+
}, f = ot({ value: d || u || r.width, fallback: 0 }), p = ot({ value: l || g || r.height, fallback: 0 }), m = ot({ value: o, fallback: f }), v = ot({ value: n, fallback: p }), b = ot({ value: i, fallback: r.scaleX || 1 }), I = ot({ value: a, fallback: r.scaleY || 1 }), y = m * b, M = v * I, A = f ? y / f : null, j = p ? M / p : null, w = {};
|
|
5429
|
+
f > 0 && (w.width = f), p > 0 && (w.height = p), A && A > 0 && (w.scaleX = A), j && j > 0 && (w.scaleY = j), r.set(w);
|
|
5382
5430
|
}
|
|
5383
5431
|
/**
|
|
5384
5432
|
* Проверяет, содержит ли сериализованный объект инлайн SVG.
|
|
@@ -5853,56 +5901,56 @@ const po = 5, os = "#3D8BF4", pe = 1, Qt = 1, Qe = ({
|
|
|
5853
5901
|
...c.map((y) => ({ bounds: y, isActive: !1 })),
|
|
5854
5902
|
{ bounds: h, isActive: !0 }
|
|
5855
5903
|
];
|
|
5856
|
-
d.sort((y,
|
|
5904
|
+
d.sort((y, M) => y.bounds.top - M.bounds.top);
|
|
5857
5905
|
const l = d.findIndex((y) => y.isActive);
|
|
5858
5906
|
if (l === -1)
|
|
5859
5907
|
return { delta: 0, guide: null };
|
|
5860
5908
|
const u = d[l - 1], g = d[l - 2], f = d[l + 1], p = d[l + 2], m = [], v = i - n;
|
|
5861
5909
|
if (u && g) {
|
|
5862
|
-
const { bounds: y } = u, { bounds:
|
|
5863
|
-
if (
|
|
5910
|
+
const { bounds: y } = u, { bounds: M } = g, A = y.top - M.bottom, j = n - y.bottom, w = Math.abs(j - A);
|
|
5911
|
+
if (w <= e) {
|
|
5864
5912
|
const T = A - j, S = n + T, C = {
|
|
5865
5913
|
type: "vertical",
|
|
5866
5914
|
axis: o,
|
|
5867
|
-
refStart:
|
|
5915
|
+
refStart: M.bottom,
|
|
5868
5916
|
refEnd: y.top,
|
|
5869
5917
|
activeStart: y.bottom,
|
|
5870
5918
|
activeEnd: S,
|
|
5871
5919
|
distance: A
|
|
5872
5920
|
};
|
|
5873
|
-
m.push({ delta: T, guide: C, diff:
|
|
5921
|
+
m.push({ delta: T, guide: C, diff: w });
|
|
5874
5922
|
}
|
|
5875
5923
|
}
|
|
5876
5924
|
if (f && p) {
|
|
5877
|
-
const { bounds: y } = f, { bounds:
|
|
5878
|
-
if (
|
|
5925
|
+
const { bounds: y } = f, { bounds: M } = p, A = M.top - y.bottom, j = y.top - i, w = Math.abs(j - A);
|
|
5926
|
+
if (w <= e) {
|
|
5879
5927
|
const T = j - A, S = i + T, C = {
|
|
5880
5928
|
type: "vertical",
|
|
5881
5929
|
axis: o,
|
|
5882
5930
|
refStart: y.bottom,
|
|
5883
|
-
refEnd:
|
|
5931
|
+
refEnd: M.top,
|
|
5884
5932
|
activeStart: S,
|
|
5885
5933
|
activeEnd: y.top,
|
|
5886
5934
|
distance: A
|
|
5887
5935
|
};
|
|
5888
|
-
m.push({ delta: T, guide: C, diff:
|
|
5936
|
+
m.push({ delta: T, guide: C, diff: w });
|
|
5889
5937
|
}
|
|
5890
5938
|
}
|
|
5891
5939
|
if (u && f) {
|
|
5892
|
-
const { bounds: y } = u, { bounds:
|
|
5940
|
+
const { bounds: y } = u, { bounds: M } = f, j = M.top - y.bottom - v;
|
|
5893
5941
|
if (j >= 0) {
|
|
5894
|
-
const
|
|
5895
|
-
if (
|
|
5896
|
-
const
|
|
5942
|
+
const w = j / 2, T = n - y.bottom, S = M.top - i, C = Math.abs(T - w), x = Math.abs(S - w), W = Math.max(C, x);
|
|
5943
|
+
if (W <= e) {
|
|
5944
|
+
const Y = w - T, H = i + Y, V = {
|
|
5897
5945
|
type: "vertical",
|
|
5898
5946
|
axis: o,
|
|
5899
5947
|
refStart: y.bottom,
|
|
5900
|
-
refEnd: y.bottom +
|
|
5901
|
-
activeStart:
|
|
5902
|
-
activeEnd:
|
|
5903
|
-
distance:
|
|
5948
|
+
refEnd: y.bottom + w,
|
|
5949
|
+
activeStart: H,
|
|
5950
|
+
activeEnd: H + w,
|
|
5951
|
+
distance: w
|
|
5904
5952
|
};
|
|
5905
|
-
m.push({ delta:
|
|
5953
|
+
m.push({ delta: Y, guide: V, diff: W });
|
|
5906
5954
|
}
|
|
5907
5955
|
}
|
|
5908
5956
|
}
|
|
@@ -5915,7 +5963,7 @@ const po = 5, os = "#3D8BF4", pe = 1, Qt = 1, Qe = ({
|
|
|
5915
5963
|
});
|
|
5916
5964
|
if (m.push(...b), !m.length)
|
|
5917
5965
|
return { delta: 0, guide: null };
|
|
5918
|
-
const I = m.reduce((y,
|
|
5966
|
+
const I = m.reduce((y, M) => M.diff < y.diff ? M : y, m[0]);
|
|
5919
5967
|
return {
|
|
5920
5968
|
delta: I.delta,
|
|
5921
5969
|
guide: I.guide
|
|
@@ -5939,56 +5987,56 @@ const po = 5, os = "#3D8BF4", pe = 1, Qt = 1, Qe = ({
|
|
|
5939
5987
|
...c.map((y) => ({ bounds: y, isActive: !1 })),
|
|
5940
5988
|
{ bounds: h, isActive: !0 }
|
|
5941
5989
|
];
|
|
5942
|
-
d.sort((y,
|
|
5990
|
+
d.sort((y, M) => y.bounds.left - M.bounds.left);
|
|
5943
5991
|
const l = d.findIndex((y) => y.isActive);
|
|
5944
5992
|
if (l === -1)
|
|
5945
5993
|
return { delta: 0, guide: null };
|
|
5946
5994
|
const u = d[l - 1], g = d[l - 2], f = d[l + 1], p = d[l + 2], m = [], v = i - n;
|
|
5947
5995
|
if (u && g) {
|
|
5948
|
-
const { bounds: y } = u, { bounds:
|
|
5949
|
-
if (
|
|
5996
|
+
const { bounds: y } = u, { bounds: M } = g, A = y.left - M.right, j = n - y.right, w = Math.abs(j - A);
|
|
5997
|
+
if (w <= e) {
|
|
5950
5998
|
const T = A - j, S = n + T, C = {
|
|
5951
5999
|
type: "horizontal",
|
|
5952
6000
|
axis: o,
|
|
5953
|
-
refStart:
|
|
6001
|
+
refStart: M.right,
|
|
5954
6002
|
refEnd: y.left,
|
|
5955
6003
|
activeStart: y.right,
|
|
5956
6004
|
activeEnd: S,
|
|
5957
6005
|
distance: A
|
|
5958
6006
|
};
|
|
5959
|
-
m.push({ delta: T, guide: C, diff:
|
|
6007
|
+
m.push({ delta: T, guide: C, diff: w });
|
|
5960
6008
|
}
|
|
5961
6009
|
}
|
|
5962
6010
|
if (f && p) {
|
|
5963
|
-
const { bounds: y } = f, { bounds:
|
|
5964
|
-
if (
|
|
6011
|
+
const { bounds: y } = f, { bounds: M } = p, A = M.left - y.right, j = y.left - i, w = Math.abs(j - A);
|
|
6012
|
+
if (w <= e) {
|
|
5965
6013
|
const T = j - A, S = i + T, C = {
|
|
5966
6014
|
type: "horizontal",
|
|
5967
6015
|
axis: o,
|
|
5968
6016
|
refStart: y.right,
|
|
5969
|
-
refEnd:
|
|
6017
|
+
refEnd: M.left,
|
|
5970
6018
|
activeStart: S,
|
|
5971
6019
|
activeEnd: y.left,
|
|
5972
6020
|
distance: A
|
|
5973
6021
|
};
|
|
5974
|
-
m.push({ delta: T, guide: C, diff:
|
|
6022
|
+
m.push({ delta: T, guide: C, diff: w });
|
|
5975
6023
|
}
|
|
5976
6024
|
}
|
|
5977
6025
|
if (u && f) {
|
|
5978
|
-
const { bounds: y } = u, { bounds:
|
|
6026
|
+
const { bounds: y } = u, { bounds: M } = f, j = M.left - y.right - v;
|
|
5979
6027
|
if (j >= 0) {
|
|
5980
|
-
const
|
|
5981
|
-
if (
|
|
5982
|
-
const
|
|
6028
|
+
const w = j / 2, T = n - y.right, S = M.left - i, C = Math.abs(T - w), x = Math.abs(S - w), W = Math.max(C, x);
|
|
6029
|
+
if (W <= e) {
|
|
6030
|
+
const Y = w - T, H = i + Y, V = {
|
|
5983
6031
|
type: "horizontal",
|
|
5984
6032
|
axis: o,
|
|
5985
6033
|
refStart: y.right,
|
|
5986
|
-
refEnd: y.right +
|
|
5987
|
-
activeStart:
|
|
5988
|
-
activeEnd:
|
|
5989
|
-
distance:
|
|
6034
|
+
refEnd: y.right + w,
|
|
6035
|
+
activeStart: H,
|
|
6036
|
+
activeEnd: H + w,
|
|
6037
|
+
distance: w
|
|
5990
6038
|
};
|
|
5991
|
-
m.push({ delta:
|
|
6039
|
+
m.push({ delta: Y, guide: V, diff: W });
|
|
5992
6040
|
}
|
|
5993
6041
|
}
|
|
5994
6042
|
}
|
|
@@ -6001,7 +6049,7 @@ const po = 5, os = "#3D8BF4", pe = 1, Qt = 1, Qe = ({
|
|
|
6001
6049
|
});
|
|
6002
6050
|
if (m.push(...b), !m.length)
|
|
6003
6051
|
return { delta: 0, guide: null };
|
|
6004
|
-
const I = m.reduce((y,
|
|
6052
|
+
const I = m.reduce((y, M) => M.diff < y.diff ? M : y, m[0]);
|
|
6005
6053
|
return {
|
|
6006
6054
|
delta: I.delta,
|
|
6007
6055
|
guide: I.guide
|
|
@@ -6055,17 +6103,17 @@ const po = 5, os = "#3D8BF4", pe = 1, Qt = 1, Qe = ({
|
|
|
6055
6103
|
offsetAlongAxis: g = 0,
|
|
6056
6104
|
offsetPerpendicular: f = 0
|
|
6057
6105
|
}) => {
|
|
6058
|
-
const p = i || 1, m = 12 / p, v = l / p, b = u / p, I = (s + o) / 2 + g, y = t === "vertical" ? e + f : I,
|
|
6106
|
+
const p = i || 1, m = 12 / p, v = l / p, b = u / p, I = (s + o) / 2 + g, y = t === "vertical" ? e + f : I, M = t === "vertical" ? I : e + f;
|
|
6059
6107
|
h.save(), h.setLineDash([]), h.fillStyle = a, h.strokeStyle = a, h.lineWidth = d / p, h.font = `${m}px ${c}`, h.textAlign = "center", h.textBaseline = "middle";
|
|
6060
|
-
const j = h.measureText(n).width + v * 2,
|
|
6108
|
+
const j = h.measureText(n).width + v * 2, w = m + v * 2, T = y - j / 2, S = M - w / 2;
|
|
6061
6109
|
h.beginPath(), Mo({
|
|
6062
6110
|
context: h,
|
|
6063
6111
|
x: T,
|
|
6064
6112
|
y: S,
|
|
6065
6113
|
width: j,
|
|
6066
|
-
height:
|
|
6114
|
+
height: w,
|
|
6067
6115
|
radius: b
|
|
6068
|
-
}), h.fill(), h.fillStyle = r, h.fillText(n, y,
|
|
6116
|
+
}), h.fill(), h.fillStyle = r, h.fillText(n, y, M), h.restore();
|
|
6069
6117
|
}, wo = ({
|
|
6070
6118
|
context: h,
|
|
6071
6119
|
guide: t,
|
|
@@ -6593,19 +6641,19 @@ class Lt {
|
|
|
6593
6641
|
}), o;
|
|
6594
6642
|
}
|
|
6595
6643
|
if (!s) return o;
|
|
6596
|
-
const I = n < d, y = i > l,
|
|
6644
|
+
const I = n < d, y = i > l, M = Math.min(n, d), A = Math.max(n, d), j = A - M;
|
|
6597
6645
|
j > 0 && !I && o.push({
|
|
6598
6646
|
type: "horizontal",
|
|
6599
6647
|
axis: b,
|
|
6600
|
-
start:
|
|
6648
|
+
start: M,
|
|
6601
6649
|
end: A,
|
|
6602
6650
|
distance: j
|
|
6603
6651
|
});
|
|
6604
|
-
const
|
|
6652
|
+
const w = Math.min(i, l), T = Math.max(i, l), S = T - w;
|
|
6605
6653
|
return S > 0 && !y && o.push({
|
|
6606
6654
|
type: "horizontal",
|
|
6607
6655
|
axis: b,
|
|
6608
|
-
start:
|
|
6656
|
+
start: w,
|
|
6609
6657
|
end: T,
|
|
6610
6658
|
distance: S
|
|
6611
6659
|
}), o;
|
|
@@ -6654,19 +6702,19 @@ class Lt {
|
|
|
6654
6702
|
}), o;
|
|
6655
6703
|
}
|
|
6656
6704
|
if (!s) return o;
|
|
6657
|
-
const I = n < d, y = i > l,
|
|
6705
|
+
const I = n < d, y = i > l, M = Math.min(n, d), A = Math.max(n, d), j = A - M;
|
|
6658
6706
|
j > 0 && !I && o.push({
|
|
6659
6707
|
type: "vertical",
|
|
6660
6708
|
axis: b,
|
|
6661
|
-
start:
|
|
6709
|
+
start: M,
|
|
6662
6710
|
end: A,
|
|
6663
6711
|
distance: j
|
|
6664
6712
|
});
|
|
6665
|
-
const
|
|
6713
|
+
const w = Math.min(i, l), T = Math.max(i, l), S = T - w;
|
|
6666
6714
|
return S > 0 && !y && o.push({
|
|
6667
6715
|
type: "vertical",
|
|
6668
6716
|
axis: b,
|
|
6669
|
-
start:
|
|
6717
|
+
start: w,
|
|
6670
6718
|
end: T,
|
|
6671
6719
|
distance: S
|
|
6672
6720
|
}), o;
|
|
@@ -6764,7 +6812,7 @@ class Se {
|
|
|
6764
6812
|
showRotationAngle: d,
|
|
6765
6813
|
_onReadyCallback: l
|
|
6766
6814
|
} = this.options;
|
|
6767
|
-
if (J.apply(), this.canvas = new vs(this.containerId, this.options), this.moduleLoader = new As(), this.workerManager = new Is(), this.errorManager = new Yt({ editor: this }), this.historyManager = new Jt({ editor: this }), this.toolbar = new Ys({ editor: this }), this.transformManager = new qs({ editor: this }), this.zoomManager = new Js({ editor: this }), this.canvasManager = new Qs({ editor: this }), this.imageManager = new ct({ editor: this }), this.layerManager = new $t({ editor: this }), this.shapeManager = new to({ editor: this }), this.interactionBlocker = new $s({ editor: this }), this.backgroundManager = new Ot({ editor: this }), this.clipboardManager = new eo({ editor: this }), this.objectLockManager = new te({ editor: this }), this.groupingManager = new so({ editor: this }), this.selectionManager = new oo({ editor: this }), this.deletionManager = new we({ editor: this }), this.panConstraintManager = new no({ editor: this }), this.snappingManager = new jo({ editor: this }), this.measurementManager = new Lt({ editor: this }), this.fontManager = new fe((u = this.options.fonts) != null ? u : []), this.textManager = new
|
|
6815
|
+
if (J.apply(), this.canvas = new vs(this.containerId, this.options), this.moduleLoader = new As(), this.workerManager = new Is(), this.errorManager = new Yt({ editor: this }), this.historyManager = new Jt({ editor: this }), this.toolbar = new Ys({ editor: this }), this.transformManager = new qs({ editor: this }), this.zoomManager = new Js({ editor: this }), this.canvasManager = new Qs({ editor: this }), this.imageManager = new ct({ editor: this }), this.layerManager = new $t({ editor: this }), this.shapeManager = new to({ editor: this }), this.interactionBlocker = new $s({ editor: this }), this.backgroundManager = new Ot({ editor: this }), this.clipboardManager = new eo({ editor: this }), this.objectLockManager = new te({ editor: this }), this.groupingManager = new so({ editor: this }), this.selectionManager = new oo({ editor: this }), this.deletionManager = new we({ editor: this }), this.panConstraintManager = new no({ editor: this }), this.snappingManager = new jo({ editor: this }), this.measurementManager = new Lt({ editor: this }), this.fontManager = new fe((u = this.options.fonts) != null ? u : []), this.textManager = new z({ editor: this }), this.templateManager = new R({ editor: this }), d && (this.angleIndicator = new Me({ editor: this })), this._createMontageArea(), this._createClippingArea(), this.listeners = new Ut({ editor: this, options: this.options }), this.canvasManager.setEditorContainerWidth(t), this.canvasManager.setEditorContainerHeight(e), this.canvasManager.setCanvasWrapperWidth(s), this.canvasManager.setCanvasWrapperHeight(o), this.canvasManager.setCanvasCSSWidth(n), this.canvasManager.setCanvasCSSHeight(i), this.canvasManager.updateCanvas(), this.zoomManager.calculateAndApplyDefaultZoom(), yield this.fontManager.loadFonts(), a != null && a.source) {
|
|
6768
6816
|
const {
|
|
6769
6817
|
source: g,
|
|
6770
6818
|
scale: f = `image-${c}`,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anu3ev/fabric-image-editor",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.9",
|
|
4
4
|
"description": "JavaScript image editor built on FabricJS, allowing you to create instances with an integrated montage area and providing an API to modify and manage state.",
|
|
5
5
|
"module": "dist/main.js",
|
|
6
6
|
"files": [
|