@anu3ev/fabric-image-editor 0.8.1 → 0.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js +825 -785
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -2453,9 +2453,9 @@ var wt = class {
|
|
|
2453
2453
|
f && (this.editor.montageArea = f, n.placeMontageAreaAtCanonicalScenePosition(), p = f.width !== l || f.height !== u, m = s !== t.getWidth() || c !== t.getHeight());
|
|
2454
2454
|
let h = t.getObjects().find((e) => e.id === "background");
|
|
2455
2455
|
h ? i.backgroundObject = h : i.removeBackground({ withoutSave: !0 });
|
|
2456
|
-
let { textManager: g } = this.editor;
|
|
2457
|
-
|
|
2458
|
-
g.commitStandaloneTextScale({ target: e });
|
|
2456
|
+
let { textManager: g, shapeManager: _ } = this.editor;
|
|
2457
|
+
t.getObjects().forEach((e) => {
|
|
2458
|
+
g.commitStandaloneTextScale({ target: e }), _.commitRehydratedShapeLayout({ target: e });
|
|
2459
2459
|
}), f && (r.ensureOverlay(), m ? n.updateCanvas() : p ? (a.calculateAndApplyDefaultZoom(), n.refreshMontageDerivedState()) : (a.updateDefaultZoom(), n.centerViewportToMontageArea(), n.refreshMontageDerivedState(), o.updateBounds())), t.renderAll(), t.fire("editor:history-state-loaded", {
|
|
2460
2460
|
fullState: e,
|
|
2461
2461
|
currentIndex: this.currentIndex,
|
|
@@ -2527,7 +2527,7 @@ var wt = class {
|
|
|
2527
2527
|
}
|
|
2528
2528
|
}
|
|
2529
2529
|
}
|
|
2530
|
-
}, Tt = .1, Et = 4096, Dt = 4096, Ot = "application/image-editor:", kt = /* @__PURE__ */ "customData.backgroundType.format.contentType.width.height.originX.originY.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.shapeReplaceBoxWidth.shapeReplaceBoxHeight.shapeTextAutoExpand.shapeAlignHorizontal.shapeAlignVertical.shapePaddingTop.shapePaddingRight.shapePaddingBottom.shapePaddingLeft.shapeFill.shapeStroke.shapeStrokeWidth.shapeStrokeDashArray.shapeOpacity.shapeRounding.shapeNodeType".split("."), At = class e {
|
|
2530
|
+
}, Tt = .1, Et = 4096, Dt = 4096, Ot = "application/image-editor:", kt = /* @__PURE__ */ "id.customData.backgroundType.format.contentType.width.height.originX.originY.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.shapeReplaceBoxWidth.shapeReplaceBoxHeight.shapeTextAutoExpand.shapeAlignHorizontal.shapeAlignVertical.shapePaddingTop.shapePaddingRight.shapePaddingBottom.shapePaddingLeft.shapeFill.shapeStroke.shapeStrokeWidth.shapeStrokeDashArray.shapeOpacity.shapeRounding.shapeNodeType".split("."), At = class e {
|
|
2531
2531
|
constructor({ editor: e }) {
|
|
2532
2532
|
this.editor = e, this.options = e.options, this._createdBlobUrls = [], this.acceptContentTypes = this.editor.options.acceptContentTypes, this.acceptFormats = this.getAllowedFormatsFromContentTypes();
|
|
2533
2533
|
}
|
|
@@ -4013,24 +4013,259 @@ var Wt = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
|
|
|
4013
4013
|
e.sendObjectBackwards(t.obj);
|
|
4014
4014
|
});
|
|
4015
4015
|
}
|
|
4016
|
-
}, Jt =
|
|
4016
|
+
}, Jt = .01, Yt = ({ textbox: e, lineIndices: t, updates: n }) => {
|
|
4017
|
+
if (!t.length) return !1;
|
|
4018
|
+
let { fontFamily: r, fontSize: i, fill: a, stroke: o } = n;
|
|
4019
|
+
if (!(r !== void 0 || i !== void 0 || a !== void 0 || o !== void 0)) return !1;
|
|
4020
|
+
let { lineFontDefaults: s } = e, c = s ?? {}, l = !1, u = !1;
|
|
4021
|
+
for (let e = 0; e < t.length; e += 1) {
|
|
4022
|
+
let n = t[e];
|
|
4023
|
+
if (!Number.isFinite(n)) continue;
|
|
4024
|
+
let d = u ? c[n] : s?.[n], f = d ? { ...d } : {}, p = !1;
|
|
4025
|
+
r !== void 0 && d?.fontFamily !== r && (f.fontFamily = r, p = !0), i !== void 0 && d?.fontSize !== i && (f.fontSize = i, p = !0), a !== void 0 && d?.fill !== a && (f.fill = a, p = !0), o !== void 0 && (o === null && d?.stroke !== void 0 && (delete f.stroke, p = !0), o !== null && d?.stroke !== o && (f.stroke = o, p = !0)), p && (u ||= (c = { ...c }, !0), c[n] = f, l = !0);
|
|
4026
|
+
}
|
|
4027
|
+
return l && (e.lineFontDefaults = c), l;
|
|
4028
|
+
}, Xt = ({ lineText: e, lineStyles: t, lineDefaults: n }) => {
|
|
4029
|
+
let r = e.length;
|
|
4030
|
+
if (r === 0) return {
|
|
4031
|
+
lineStyles: t,
|
|
4032
|
+
changed: !1
|
|
4033
|
+
};
|
|
4034
|
+
let { fontFamily: i, fontSize: a, fill: o, stroke: s } = n;
|
|
4035
|
+
if (!(i !== void 0 || a !== void 0 || o !== void 0 || s !== void 0)) return {
|
|
4036
|
+
lineStyles: t,
|
|
4037
|
+
changed: !1
|
|
4038
|
+
};
|
|
4039
|
+
let c = {};
|
|
4040
|
+
i !== void 0 && (c.fontFamily = i), a !== void 0 && (c.fontSize = a), o !== void 0 && (c.fill = o), s !== void 0 && (c.stroke = s);
|
|
4041
|
+
let l = t, u = !1, d = !1;
|
|
4042
|
+
if (t) for (let e in t) {
|
|
4043
|
+
if (!Object.prototype.hasOwnProperty.call(t, e)) continue;
|
|
4044
|
+
let n = Number(e);
|
|
4045
|
+
Number.isInteger(n) && n >= 0 && n < r || (d ||= (l = { ...t }, !0), l && Object.prototype.hasOwnProperty.call(l, e) && delete l[e], u = !0);
|
|
4046
|
+
}
|
|
4047
|
+
for (let e = 0; e < r; e += 1) {
|
|
4048
|
+
let n = l ?? t, r = n ? n[e] : void 0;
|
|
4049
|
+
if (!r) {
|
|
4050
|
+
l || (l = {}, d = !0), d ||= (l = { ...l }, !0), l[e] = { ...c }, u = !0;
|
|
4051
|
+
continue;
|
|
4052
|
+
}
|
|
4053
|
+
let f = null;
|
|
4054
|
+
i !== void 0 && r.fontFamily === void 0 && (f = { ...r }, f.fontFamily = i), a !== void 0 && r.fontSize === void 0 && (f ||= { ...r }, f.fontSize = a), o !== void 0 && r.fill === void 0 && (f ||= { ...r }, f.fill = o), s !== void 0 && r.stroke === void 0 && (f ||= { ...r }, f.stroke = s), f && (l || (l = {}, d = !0), d ||= (l = { ...l }, !0), l[e] = f, u = !0);
|
|
4055
|
+
}
|
|
4056
|
+
return {
|
|
4057
|
+
lineStyles: l,
|
|
4058
|
+
changed: u
|
|
4059
|
+
};
|
|
4060
|
+
}, Zt = ({ lineFontDefaults: e }) => {
|
|
4061
|
+
if (!e) return;
|
|
4062
|
+
let t = {};
|
|
4063
|
+
for (let n in e) {
|
|
4064
|
+
if (!Object.prototype.hasOwnProperty.call(e, n)) continue;
|
|
4065
|
+
let r = Number(n);
|
|
4066
|
+
if (!Number.isFinite(r)) continue;
|
|
4067
|
+
let i = e[r];
|
|
4068
|
+
i && (t[r] = { ...i });
|
|
4069
|
+
}
|
|
4070
|
+
return t;
|
|
4071
|
+
}, Qt = ({ lineFontDefaults: e, scale: t }) => {
|
|
4072
|
+
if (!e || !Number.isFinite(t) || Math.abs(t - 1) < .01) return;
|
|
4073
|
+
let n = {}, r = !1, i = !1;
|
|
4074
|
+
for (let a in e) {
|
|
4075
|
+
if (!Object.prototype.hasOwnProperty.call(e, a)) continue;
|
|
4076
|
+
let o = Number(a);
|
|
4077
|
+
if (!Number.isFinite(o)) continue;
|
|
4078
|
+
let s = e[o];
|
|
4079
|
+
if (!s) continue;
|
|
4080
|
+
let c = { ...s };
|
|
4081
|
+
if (typeof s.fontSize == "number") {
|
|
4082
|
+
let e = Math.min(8, s.fontSize);
|
|
4083
|
+
c.fontSize = Math.max(e, s.fontSize * t), i = !0;
|
|
4084
|
+
}
|
|
4085
|
+
n[o] = c, r = !0;
|
|
4086
|
+
}
|
|
4087
|
+
if (!(!r || !i)) return n;
|
|
4088
|
+
}, $t = ({ textbox: e, text: t }) => {
|
|
4089
|
+
let { textLines: n } = e, r = Array.isArray(n) && n.length > 0 ? n.length : Math.max(t.split("\n").length, 1), i = 0;
|
|
4090
|
+
for (let t = 0; t < r; t += 1) {
|
|
4091
|
+
let n = e.getLineWidth(t);
|
|
4092
|
+
n > i && (i = n);
|
|
4093
|
+
}
|
|
4094
|
+
return i;
|
|
4095
|
+
}, en = ({ origin: e, size: t }) => e === "left" || e === "top" || e === "start" || e === 0 ? 0 : e === "right" || e === "bottom" || e === "end" || e === 1 ? t : t / 2, tn = ({ textbox: e, originX: t = e.originX ?? "center", originY: n = e.originY ?? "center" }) => {
|
|
4096
|
+
let r = e.width ?? e.calcTextWidth() ?? 0, i = e.height ?? e.calcTextHeight() ?? 0, a = e.paddingTop ?? 0, o = e.paddingRight ?? 0, s = e.paddingBottom ?? 0, c = e.paddingLeft ?? 0, l = -r / 2 + (c - o) / 2, u = -i / 2 + (a - s) / 2, d = new p(l + en({
|
|
4097
|
+
origin: t,
|
|
4098
|
+
size: r
|
|
4099
|
+
}), u + en({
|
|
4100
|
+
origin: n,
|
|
4101
|
+
size: i
|
|
4102
|
+
})), f = e.getPointByOrigin("center", "center"), m = e, h = typeof m.calcTransformMatrix == "function" ? m.calcTransformMatrix() : null, g = Array.isArray(h) ? new p(d.x * h[0] + d.y * h[2] + f.x, d.x * h[1] + d.y * h[3] + f.y) : new p(f.x + d.x, f.y + d.y);
|
|
4103
|
+
return {
|
|
4104
|
+
left: g.x,
|
|
4105
|
+
top: g.y,
|
|
4106
|
+
originX: t,
|
|
4107
|
+
originY: n
|
|
4108
|
+
};
|
|
4109
|
+
}, nn = ({ textbox: e, montageLeft: t, montageRight: n }) => {
|
|
4110
|
+
e.setCoords();
|
|
4111
|
+
let r = e.getBoundingRect(!1, !0), i = r.left ?? 0, a = i + (r.width ?? 0), o = n - t;
|
|
4112
|
+
if (o > 0 && (r.width ?? 0) >= o - .01) return !1;
|
|
4113
|
+
let s = 0;
|
|
4114
|
+
return i < t ? s = t - i : a > n && (s = n - a), Math.abs(s) <= .01 ? !1 : (e.set({ left: (e.left ?? 0) + s }), !0);
|
|
4115
|
+
}, rn = ({ rawValue: e, calculatedValue: t }) => typeof e == "number" ? e : typeof t == "number" ? t : 0, an = ({ stylesList: e }) => {
|
|
4116
|
+
let t = e.length;
|
|
4117
|
+
if (!t) return !1;
|
|
4118
|
+
for (let n = 0; n < t; n += 1) {
|
|
4119
|
+
let t = e[n];
|
|
4120
|
+
if (!t) continue;
|
|
4121
|
+
let { fontFamily: r, fontSize: i, fontWeight: a, fontStyle: o, lineHeight: s, charSpacing: c } = t;
|
|
4122
|
+
if (r !== void 0 || i !== void 0 || a !== void 0 || o !== void 0 || s !== void 0 || c !== void 0) return !0;
|
|
4123
|
+
}
|
|
4124
|
+
return !1;
|
|
4125
|
+
}, on = ({ textbox: e }) => {
|
|
4126
|
+
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 = rn({
|
|
4127
|
+
rawValue: t,
|
|
4128
|
+
calculatedValue: a
|
|
4129
|
+
}), c = rn({
|
|
4130
|
+
rawValue: n,
|
|
4131
|
+
calculatedValue: o
|
|
4132
|
+
}), l = Number.isFinite(s) ? Math.round(s) : null, u = Number.isFinite(c) ? Math.round(c) : null, d = {};
|
|
4133
|
+
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;
|
|
4134
|
+
}, sn = ({ textbox: e }) => {
|
|
4135
|
+
let t = e.width ?? e.calcTextWidth(), n = e.fontSize ?? 16, { styles: r = {} } = e, { lineFontDefaults: i } = e, { paddingTop: a = 0, paddingRight: o = 0, paddingBottom: s = 0, paddingLeft: c = 0 } = e, { radiusTopLeft: l = 0, radiusTopRight: u = 0, radiusBottomRight: d = 0, radiusBottomLeft: f = 0 } = e;
|
|
4136
|
+
return {
|
|
4137
|
+
width: t,
|
|
4138
|
+
fontSize: n,
|
|
4139
|
+
padding: {
|
|
4140
|
+
top: a,
|
|
4141
|
+
right: o,
|
|
4142
|
+
bottom: s,
|
|
4143
|
+
left: c
|
|
4144
|
+
},
|
|
4145
|
+
radii: {
|
|
4146
|
+
topLeft: l,
|
|
4147
|
+
topRight: u,
|
|
4148
|
+
bottomRight: d,
|
|
4149
|
+
bottomLeft: f
|
|
4150
|
+
},
|
|
4151
|
+
styles: JSON.parse(JSON.stringify(r)),
|
|
4152
|
+
lineFontDefaults: Zt({ lineFontDefaults: i })
|
|
4153
|
+
};
|
|
4154
|
+
}, cn = ({ base: e }) => {
|
|
4155
|
+
let t = 1 / Math.max(1, e.width), n = [e.fontSize];
|
|
4156
|
+
Object.values(e.styles).forEach((e) => {
|
|
4157
|
+
Object.values(e).forEach((e) => {
|
|
4158
|
+
let { fontSize: t } = e;
|
|
4159
|
+
typeof t != "number" || !Number.isFinite(t) || t <= 0 || n.push(t);
|
|
4160
|
+
});
|
|
4161
|
+
}), Object.values(e.lineFontDefaults ?? {}).forEach((e) => {
|
|
4162
|
+
let { fontSize: t } = e;
|
|
4163
|
+
typeof t != "number" || !Number.isFinite(t) || t <= 0 || n.push(t);
|
|
4164
|
+
});
|
|
4165
|
+
let r = n.reduce((e, t) => Math.max(e, Math.min(8, t) / t), 0);
|
|
4166
|
+
return {
|
|
4167
|
+
widthScale: t,
|
|
4168
|
+
fontScale: r,
|
|
4169
|
+
proportionalScale: Math.max(t, r)
|
|
4170
|
+
};
|
|
4171
|
+
}, ln = ({ textbox: e, base: t, scale: n, shouldScaleFontSize: r = !0, shouldScalePadding: i = !0, shouldScaleRadii: a = !0 }) => {
|
|
4172
|
+
let { fontSize: o, padding: s, radii: c, styles: l, lineFontDefaults: u } = t, d = Math.max(Math.min(8, o), o * n), f = Object.keys(l).length > 0, p;
|
|
4173
|
+
if (r && f) {
|
|
4174
|
+
let e = {};
|
|
4175
|
+
Object.entries(l).forEach(([t, r]) => {
|
|
4176
|
+
if (!r) return;
|
|
4177
|
+
let i = {};
|
|
4178
|
+
Object.entries(r).forEach(([e, t]) => {
|
|
4179
|
+
if (!t) return;
|
|
4180
|
+
let r = { ...t };
|
|
4181
|
+
if (typeof t.fontSize == "number") {
|
|
4182
|
+
let e = Math.min(8, t.fontSize);
|
|
4183
|
+
r.fontSize = Math.max(e, t.fontSize * n);
|
|
4184
|
+
}
|
|
4185
|
+
i[e] = r;
|
|
4186
|
+
}), Object.keys(i).length && (e[t] = i);
|
|
4187
|
+
}), Object.keys(e).length && (p = e);
|
|
4188
|
+
}
|
|
4189
|
+
let m;
|
|
4190
|
+
r && (m = Qt({
|
|
4191
|
+
lineFontDefaults: u,
|
|
4192
|
+
scale: n
|
|
4193
|
+
}));
|
|
4194
|
+
let h = i ? {
|
|
4195
|
+
top: Math.max(0, s.top * n),
|
|
4196
|
+
right: Math.max(0, s.right * n),
|
|
4197
|
+
bottom: Math.max(0, s.bottom * n),
|
|
4198
|
+
left: Math.max(0, s.left * n)
|
|
4199
|
+
} : s, g = a ? {
|
|
4200
|
+
topLeft: Math.max(0, c.topLeft * n),
|
|
4201
|
+
topRight: Math.max(0, c.topRight * n),
|
|
4202
|
+
bottomRight: Math.max(0, c.bottomRight * n),
|
|
4203
|
+
bottomLeft: Math.max(0, c.bottomLeft * n)
|
|
4204
|
+
} : c;
|
|
4205
|
+
p && (e.styles = p), m && (e.lineFontDefaults = m), e.set({
|
|
4206
|
+
fontSize: r ? d : o,
|
|
4207
|
+
paddingTop: h.top,
|
|
4208
|
+
paddingRight: h.right,
|
|
4209
|
+
paddingBottom: h.bottom,
|
|
4210
|
+
paddingLeft: h.left,
|
|
4211
|
+
radiusTopLeft: g.topLeft,
|
|
4212
|
+
radiusTopRight: g.topRight,
|
|
4213
|
+
radiusBottomRight: g.bottomRight,
|
|
4214
|
+
radiusBottomLeft: g.bottomLeft
|
|
4215
|
+
});
|
|
4216
|
+
}, un = ({ textbox: e, canvasManager: t, base: n, widthScale: r, heightScale: i, placement: a, anchorPlacement: o, shouldScaleFontSize: s, shouldScalePadding: c, shouldScaleRadii: l, shouldDisableAutoExpandOnHorizontalChange: u = !1, shouldRoundDimensions: d = !0 }) => {
|
|
4217
|
+
let { width: f } = n, m = Math.max(1, f * r), h = d ? Math.max(1, Math.round(m)) : m, g = e.width ?? f, _ = Math.abs(h - g) > Jt;
|
|
4218
|
+
u && _ && (e.autoExpand = !1), ln({
|
|
4219
|
+
textbox: e,
|
|
4220
|
+
base: n,
|
|
4221
|
+
scale: i,
|
|
4222
|
+
shouldScaleFontSize: s,
|
|
4223
|
+
shouldScalePadding: c,
|
|
4224
|
+
shouldScaleRadii: l
|
|
4225
|
+
}), e.set({
|
|
4226
|
+
width: h,
|
|
4227
|
+
scaleX: 1,
|
|
4228
|
+
scaleY: 1
|
|
4229
|
+
});
|
|
4230
|
+
let v = e.shouldRoundDimensionsOnInit;
|
|
4231
|
+
e.shouldRoundDimensionsOnInit = d;
|
|
4232
|
+
try {
|
|
4233
|
+
e.initDimensions();
|
|
4234
|
+
} finally {
|
|
4235
|
+
e.shouldRoundDimensionsOnInit = v;
|
|
4236
|
+
}
|
|
4237
|
+
let y = d ? on({ textbox: e }) : !1;
|
|
4238
|
+
return y && (e.dirty = !0), o ? (e.set({
|
|
4239
|
+
originX: a.originX,
|
|
4240
|
+
originY: a.originY
|
|
4241
|
+
}), e.setPositionByOrigin(new p(o.left, o.top), o.originX, o.originY), e.setCoords(), {
|
|
4242
|
+
appliedWidth: e.width ?? h,
|
|
4243
|
+
dimensionsRounded: y
|
|
4244
|
+
}) : (t.applyObjectPlacement({
|
|
4245
|
+
object: e,
|
|
4246
|
+
placement: a
|
|
4247
|
+
}), e.setCoords(), {
|
|
4248
|
+
appliedWidth: e.width ?? h,
|
|
4249
|
+
dimensionsRounded: y
|
|
4250
|
+
});
|
|
4251
|
+
}, dn = 1, fn = 1e-4;
|
|
4017
4252
|
function J({ value: e }) {
|
|
4018
4253
|
return Number(e.toFixed(4));
|
|
4019
4254
|
}
|
|
4020
|
-
function
|
|
4255
|
+
function pn({ rounding: e }) {
|
|
4021
4256
|
return B({ rounding: e }) > 0;
|
|
4022
4257
|
}
|
|
4023
|
-
function
|
|
4258
|
+
function mn({ width: e, height: t, strokeWidth: n }) {
|
|
4024
4259
|
let r = Math.max(0, n ?? 0);
|
|
4025
4260
|
return {
|
|
4026
|
-
width: Math.max(
|
|
4027
|
-
height: Math.max(
|
|
4261
|
+
width: Math.max(dn, e - r),
|
|
4262
|
+
height: Math.max(dn, t - r)
|
|
4028
4263
|
};
|
|
4029
4264
|
}
|
|
4030
|
-
function
|
|
4031
|
-
let a =
|
|
4032
|
-
width: Math.max(
|
|
4033
|
-
height: Math.max(
|
|
4265
|
+
function hn({ shape: e, width: t, height: n, rounding: r, strokeWidth: i }) {
|
|
4266
|
+
let a = mn({
|
|
4267
|
+
width: Math.max(dn, t),
|
|
4268
|
+
height: Math.max(dn, n),
|
|
4034
4269
|
strokeWidth: i
|
|
4035
4270
|
});
|
|
4036
4271
|
if (e instanceof g) {
|
|
@@ -4049,7 +4284,7 @@ function Qt({ shape: e, width: t, height: n, rounding: r, strokeWidth: i }) {
|
|
|
4049
4284
|
}), e.setCoords();
|
|
4050
4285
|
return;
|
|
4051
4286
|
}
|
|
4052
|
-
let { width: o =
|
|
4287
|
+
let { width: o = dn, height: s = dn } = e, c = Math.max(dn, o), l = Math.max(dn, s);
|
|
4053
4288
|
e.set({
|
|
4054
4289
|
scaleX: a.width / c,
|
|
4055
4290
|
scaleY: a.height / l,
|
|
@@ -4059,11 +4294,11 @@ function Qt({ shape: e, width: t, height: n, rounding: r, strokeWidth: i }) {
|
|
|
4059
4294
|
originY: "center"
|
|
4060
4295
|
}), e.setCoords();
|
|
4061
4296
|
}
|
|
4062
|
-
function
|
|
4297
|
+
function gn({ shape: e, style: t }) {
|
|
4063
4298
|
let { fill: n, stroke: r, strokeWidth: i, strokeDashArray: a, opacity: o } = t;
|
|
4064
4299
|
if (e instanceof l) {
|
|
4065
4300
|
let n = e.getObjects();
|
|
4066
|
-
for (let e = 0; e < n.length; e += 1)
|
|
4301
|
+
for (let e = 0; e < n.length; e += 1) gn({
|
|
4067
4302
|
shape: n[e],
|
|
4068
4303
|
style: t
|
|
4069
4304
|
});
|
|
@@ -4077,7 +4312,7 @@ function $t({ shape: e, style: t }) {
|
|
|
4077
4312
|
};
|
|
4078
4313
|
n !== void 0 && (s.fill = n), r !== void 0 && (s.stroke = r), i !== void 0 && (s.strokeWidth = i), a !== void 0 && (s.strokeDashArray = a), o !== void 0 && (s.opacity = o), e.set(s), e.setCoords();
|
|
4079
4314
|
}
|
|
4080
|
-
function
|
|
4315
|
+
function _n({ points: e, closed: t }) {
|
|
4081
4316
|
if (e.length === 0) return "";
|
|
4082
4317
|
let n = `M ${J({ value: e[0].x })} ${J({ value: e[0].y })}`;
|
|
4083
4318
|
for (let t = 1; t < e.length; t += 1) {
|
|
@@ -4086,7 +4321,7 @@ function en({ points: e, closed: t }) {
|
|
|
4086
4321
|
}
|
|
4087
4322
|
return t && (n += " Z"), n;
|
|
4088
4323
|
}
|
|
4089
|
-
function
|
|
4324
|
+
function vn({ previous: e, current: t, next: n, roundingRatio: r }) {
|
|
4090
4325
|
let i = {
|
|
4091
4326
|
x: e.x - t.x,
|
|
4092
4327
|
y: e.y - t.y
|
|
@@ -4094,7 +4329,7 @@ function tn({ previous: e, current: t, next: n, roundingRatio: r }) {
|
|
|
4094
4329
|
x: n.x - t.x,
|
|
4095
4330
|
y: n.y - t.y
|
|
4096
4331
|
}, o = Math.hypot(i.x, i.y), s = Math.hypot(a.x, a.y);
|
|
4097
|
-
if (o <=
|
|
4332
|
+
if (o <= fn || s <= fn) return {
|
|
4098
4333
|
start: {
|
|
4099
4334
|
x: J({ value: t.x }),
|
|
4100
4335
|
y: J({ value: t.y })
|
|
@@ -4116,14 +4351,14 @@ function tn({ previous: e, current: t, next: n, roundingRatio: r }) {
|
|
|
4116
4351
|
}
|
|
4117
4352
|
};
|
|
4118
4353
|
}
|
|
4119
|
-
function
|
|
4354
|
+
function yn({ points: e, roundingRatio: t, closed: n }) {
|
|
4120
4355
|
let r = e.length;
|
|
4121
4356
|
if (r === 0) return "";
|
|
4122
4357
|
if (!n && r === 1) {
|
|
4123
4358
|
let t = e[0];
|
|
4124
4359
|
return `M ${J({ value: t.x })} ${J({ value: t.y })}`;
|
|
4125
4360
|
}
|
|
4126
|
-
if (t <= 0) return
|
|
4361
|
+
if (t <= 0) return _n({
|
|
4127
4362
|
points: e,
|
|
4128
4363
|
closed: n
|
|
4129
4364
|
});
|
|
@@ -4131,7 +4366,7 @@ function nn({ points: e, roundingRatio: t, closed: n }) {
|
|
|
4131
4366
|
let n = [];
|
|
4132
4367
|
for (let i = 0; i < r; i += 1) {
|
|
4133
4368
|
let a = i === 0 ? r - 1 : i - 1, o = i === r - 1 ? 0 : i + 1;
|
|
4134
|
-
n.push(
|
|
4369
|
+
n.push(vn({
|
|
4135
4370
|
previous: e[a],
|
|
4136
4371
|
current: e[i],
|
|
4137
4372
|
next: e[o],
|
|
@@ -4145,13 +4380,13 @@ function nn({ points: e, roundingRatio: t, closed: n }) {
|
|
|
4145
4380
|
}
|
|
4146
4381
|
return a += " Z", a;
|
|
4147
4382
|
}
|
|
4148
|
-
if (r === 2) return
|
|
4383
|
+
if (r === 2) return _n({
|
|
4149
4384
|
points: e,
|
|
4150
4385
|
closed: !1
|
|
4151
4386
|
});
|
|
4152
4387
|
let i = `M ${J({ value: e[0].x })} ${J({ value: e[0].y })}`;
|
|
4153
4388
|
for (let n = 1; n < r - 1; n += 1) {
|
|
4154
|
-
let r =
|
|
4389
|
+
let r = vn({
|
|
4155
4390
|
previous: e[n - 1],
|
|
4156
4391
|
current: e[n],
|
|
4157
4392
|
next: e[n + 1],
|
|
@@ -4162,8 +4397,8 @@ function nn({ points: e, roundingRatio: t, closed: n }) {
|
|
|
4162
4397
|
let a = e[r - 1];
|
|
4163
4398
|
return i += ` L ${J({ value: a.x })} ${J({ value: a.y })}`, i;
|
|
4164
4399
|
}
|
|
4165
|
-
function
|
|
4166
|
-
return new d(
|
|
4400
|
+
function bn({ points: e, rounding: t, closed: n }) {
|
|
4401
|
+
return new d(yn({
|
|
4167
4402
|
points: e,
|
|
4168
4403
|
roundingRatio: V({ rounding: t }),
|
|
4169
4404
|
closed: n
|
|
@@ -4174,8 +4409,8 @@ function rn({ points: e, rounding: t, closed: n }) {
|
|
|
4174
4409
|
top: 0
|
|
4175
4410
|
});
|
|
4176
4411
|
}
|
|
4177
|
-
function
|
|
4178
|
-
return
|
|
4412
|
+
function xn({ rounding: e }) {
|
|
4413
|
+
return pn({ rounding: e }) ? bn({
|
|
4179
4414
|
points: [
|
|
4180
4415
|
{
|
|
4181
4416
|
x: 50,
|
|
@@ -4201,7 +4436,7 @@ function an({ rounding: e }) {
|
|
|
4201
4436
|
top: 0
|
|
4202
4437
|
});
|
|
4203
4438
|
}
|
|
4204
|
-
function
|
|
4439
|
+
function Sn({ path: e }) {
|
|
4205
4440
|
return new d(e, {
|
|
4206
4441
|
originX: "center",
|
|
4207
4442
|
originY: "center",
|
|
@@ -4209,8 +4444,8 @@ function on({ path: e }) {
|
|
|
4209
4444
|
top: 0
|
|
4210
4445
|
});
|
|
4211
4446
|
}
|
|
4212
|
-
function
|
|
4213
|
-
let n =
|
|
4447
|
+
function Cn({ path: e, rounding: t }) {
|
|
4448
|
+
let n = Sn({ path: e }).path ?? [], r = C.makePathSimpler(n), i = [], a = !1;
|
|
4214
4449
|
for (let e = 0; e < r.length; e += 1) {
|
|
4215
4450
|
let t = r[e];
|
|
4216
4451
|
if (!t) return null;
|
|
@@ -4230,19 +4465,19 @@ function sn({ path: e, rounding: t }) {
|
|
|
4230
4465
|
}
|
|
4231
4466
|
return null;
|
|
4232
4467
|
}
|
|
4233
|
-
return i.length < 2 || a && i.length < 3 ? null :
|
|
4468
|
+
return i.length < 2 || a && i.length < 3 ? null : bn({
|
|
4234
4469
|
points: i,
|
|
4235
4470
|
rounding: t,
|
|
4236
4471
|
closed: a
|
|
4237
4472
|
});
|
|
4238
4473
|
}
|
|
4239
|
-
function
|
|
4240
|
-
return
|
|
4474
|
+
function wn({ path: e, rounding: t }) {
|
|
4475
|
+
return pn({ rounding: t }) && Cn({
|
|
4241
4476
|
path: e,
|
|
4242
4477
|
rounding: B({ rounding: t })
|
|
4243
|
-
}) ||
|
|
4478
|
+
}) || Sn({ path: e });
|
|
4244
4479
|
}
|
|
4245
|
-
function
|
|
4480
|
+
function Tn({ points: e, type: t, rounding: n }) {
|
|
4246
4481
|
let r = e.length > 0 ? e : [
|
|
4247
4482
|
{
|
|
4248
4483
|
x: 0,
|
|
@@ -4258,12 +4493,12 @@ function ln({ points: e, type: t, rounding: n }) {
|
|
|
4258
4493
|
}
|
|
4259
4494
|
], i = B({ rounding: n });
|
|
4260
4495
|
if (i > 0) {
|
|
4261
|
-
if (t === "polygon" && r.length >= 3) return
|
|
4496
|
+
if (t === "polygon" && r.length >= 3) return bn({
|
|
4262
4497
|
points: r,
|
|
4263
4498
|
rounding: i,
|
|
4264
4499
|
closed: !0
|
|
4265
4500
|
});
|
|
4266
|
-
if (t === "polyline" && r.length >= 2) return
|
|
4501
|
+
if (t === "polyline" && r.length >= 2) return bn({
|
|
4267
4502
|
points: r,
|
|
4268
4503
|
rounding: i,
|
|
4269
4504
|
closed: !1
|
|
@@ -4276,7 +4511,7 @@ function ln({ points: e, type: t, rounding: n }) {
|
|
|
4276
4511
|
top: 0
|
|
4277
4512
|
});
|
|
4278
4513
|
}
|
|
4279
|
-
async function
|
|
4514
|
+
async function En({ svg: e }) {
|
|
4280
4515
|
let t = await x(e), n = C.groupSVGElements(t.objects, t.options);
|
|
4281
4516
|
return n.set({
|
|
4282
4517
|
originX: "center",
|
|
@@ -4285,7 +4520,7 @@ async function un({ svg: e }) {
|
|
|
4285
4520
|
top: 0
|
|
4286
4521
|
}), n.setCoords(), n;
|
|
4287
4522
|
}
|
|
4288
|
-
async function
|
|
4523
|
+
async function Dn({ preset: e, rounding: t }) {
|
|
4289
4524
|
switch (e.type) {
|
|
4290
4525
|
case "rect": return new g({
|
|
4291
4526
|
width: 100,
|
|
@@ -4303,22 +4538,22 @@ async function dn({ preset: e, rounding: t }) {
|
|
|
4303
4538
|
left: 0,
|
|
4304
4539
|
top: 0
|
|
4305
4540
|
});
|
|
4306
|
-
case "triangle": return
|
|
4307
|
-
case "polygon": return
|
|
4541
|
+
case "triangle": return xn({ rounding: t });
|
|
4542
|
+
case "polygon": return Tn({
|
|
4308
4543
|
points: e.points,
|
|
4309
4544
|
type: "polygon",
|
|
4310
4545
|
rounding: t
|
|
4311
4546
|
});
|
|
4312
|
-
case "polyline": return
|
|
4547
|
+
case "polyline": return Tn({
|
|
4313
4548
|
points: e.points,
|
|
4314
4549
|
type: "polyline",
|
|
4315
4550
|
rounding: t
|
|
4316
4551
|
});
|
|
4317
|
-
case "path": return
|
|
4552
|
+
case "path": return wn({
|
|
4318
4553
|
path: e.path,
|
|
4319
4554
|
rounding: t
|
|
4320
4555
|
});
|
|
4321
|
-
case "svg": return
|
|
4556
|
+
case "svg": return En({ svg: e.svg });
|
|
4322
4557
|
default: return new g({
|
|
4323
4558
|
width: 100,
|
|
4324
4559
|
height: 100,
|
|
@@ -4329,21 +4564,22 @@ async function dn({ preset: e, rounding: t }) {
|
|
|
4329
4564
|
});
|
|
4330
4565
|
}
|
|
4331
4566
|
}
|
|
4332
|
-
async function
|
|
4333
|
-
let a = await
|
|
4567
|
+
async function On({ preset: e, width: t, height: n, style: r, rounding: i }) {
|
|
4568
|
+
let a = await Dn({
|
|
4334
4569
|
preset: e,
|
|
4335
4570
|
rounding: i
|
|
4336
4571
|
});
|
|
4337
|
-
return
|
|
4572
|
+
return gn({
|
|
4338
4573
|
shape: a,
|
|
4339
4574
|
style: r
|
|
4340
|
-
}),
|
|
4575
|
+
}), hn({
|
|
4341
4576
|
shape: a,
|
|
4342
4577
|
width: t,
|
|
4343
4578
|
height: n,
|
|
4344
4579
|
rounding: i,
|
|
4345
4580
|
strokeWidth: r.strokeWidth
|
|
4346
4581
|
}), a.set({
|
|
4582
|
+
id: `${a.type}-${D()}`,
|
|
4347
4583
|
selectable: !1,
|
|
4348
4584
|
evented: !1,
|
|
4349
4585
|
hasControls: !1,
|
|
@@ -4353,17 +4589,17 @@ async function fn({ preset: e, width: t, height: n, style: r, rounding: i }) {
|
|
|
4353
4589
|
}
|
|
4354
4590
|
//#endregion
|
|
4355
4591
|
//#region src/editor/shape-manager/layout/shape-layout-padding.ts
|
|
4356
|
-
var
|
|
4357
|
-
function
|
|
4592
|
+
var kn = .5, An = 12;
|
|
4593
|
+
function jn({ width: e, padding: t }) {
|
|
4358
4594
|
let n = Math.max(0, t.left), r = Math.max(0, t.right);
|
|
4359
4595
|
return Math.max(1, e - n - r);
|
|
4360
4596
|
}
|
|
4361
|
-
function
|
|
4597
|
+
function Mn({ text: e }) {
|
|
4362
4598
|
return (e.text ?? "").trim().length > 0;
|
|
4363
4599
|
}
|
|
4364
|
-
function
|
|
4600
|
+
function Nn({ start: e, end: t, maxTotalPadding: n, startChanged: r, endChanged: i }) {
|
|
4365
4601
|
let a = Math.max(0, e), o = Math.max(0, t), s = Math.max(0, n);
|
|
4366
|
-
if (a + o <= s +
|
|
4602
|
+
if (a + o <= s + kn) return {
|
|
4367
4603
|
start: a,
|
|
4368
4604
|
end: o
|
|
4369
4605
|
};
|
|
@@ -4392,8 +4628,8 @@ function _n({ start: e, end: t, maxTotalPadding: n, startChanged: r, endChanged:
|
|
|
4392
4628
|
end: o * l
|
|
4393
4629
|
};
|
|
4394
4630
|
}
|
|
4395
|
-
function
|
|
4396
|
-
let s = Math.max(0, n), c = Math.max(0, r), l = Math.max(0, i - s - c), u =
|
|
4631
|
+
function Pn({ start: e, end: t, insetStart: n, insetEnd: r, maxTotalPadding: i, startChanged: a, endChanged: o }) {
|
|
4632
|
+
let s = Math.max(0, n), c = Math.max(0, r), l = Math.max(0, i - s - c), u = Nn({
|
|
4397
4633
|
start: Math.max(0, e),
|
|
4398
4634
|
end: Math.max(0, t),
|
|
4399
4635
|
maxTotalPadding: l,
|
|
@@ -4407,23 +4643,23 @@ function vn({ start: e, end: t, insetStart: n, insetEnd: r, maxTotalPadding: i,
|
|
|
4407
4643
|
appliedUserPaddingEnd: f
|
|
4408
4644
|
};
|
|
4409
4645
|
}
|
|
4410
|
-
function
|
|
4646
|
+
function Fn({ text: e, minFrameWidth: t, maxFrameWidth: n, frameHeight: r, measureTextboxHeightForFrame: i }) {
|
|
4411
4647
|
let a = Math.max(1, t), o = Math.max(a, n), s = Math.max(1, r);
|
|
4412
|
-
if (!
|
|
4648
|
+
if (!Mn({ text: e }) || i({
|
|
4413
4649
|
text: e,
|
|
4414
4650
|
frameWidth: a
|
|
4415
|
-
}) <= s +
|
|
4651
|
+
}) <= s + kn) return a;
|
|
4416
4652
|
if (i({
|
|
4417
4653
|
text: e,
|
|
4418
4654
|
frameWidth: o
|
|
4419
|
-
}) > s +
|
|
4655
|
+
}) > s + kn) return o;
|
|
4420
4656
|
let c = a, l = o;
|
|
4421
|
-
for (let t = 0; t <
|
|
4657
|
+
for (let t = 0; t < An; t += 1) {
|
|
4422
4658
|
let t = (c + l) / 2;
|
|
4423
4659
|
if (i({
|
|
4424
4660
|
text: e,
|
|
4425
4661
|
frameWidth: t
|
|
4426
|
-
}) <= s +
|
|
4662
|
+
}) <= s + kn) {
|
|
4427
4663
|
l = t;
|
|
4428
4664
|
continue;
|
|
4429
4665
|
}
|
|
@@ -4431,16 +4667,16 @@ function yn({ text: e, minFrameWidth: t, maxFrameWidth: n, frameHeight: r, measu
|
|
|
4431
4667
|
}
|
|
4432
4668
|
return l;
|
|
4433
4669
|
}
|
|
4434
|
-
function
|
|
4435
|
-
let l = Math.max(1, t), u = Math.max(1, n), d =
|
|
4436
|
-
a || (m =
|
|
4670
|
+
function In({ text: e, width: t, height: n, padding: r, internalShapeTextInset: i, expandShapeHeightToFitText: a, changedPadding: o, measureTextboxHeightForFrame: s, resolveMinimumTextFrameWidth: c }) {
|
|
4671
|
+
let l = Math.max(1, t), u = Math.max(1, n), d = Mn({ text: e }) ? c({ text: e }) : 1, f = i.top + i.bottom, p = Math.max(1, u - f), m = d;
|
|
4672
|
+
a || (m = Fn({
|
|
4437
4673
|
text: e,
|
|
4438
4674
|
minFrameWidth: d,
|
|
4439
4675
|
maxFrameWidth: l,
|
|
4440
4676
|
frameHeight: p,
|
|
4441
4677
|
measureTextboxHeightForFrame: s
|
|
4442
4678
|
}));
|
|
4443
|
-
let h = m + i.left + i.right, g = Math.max(0, l - m), _ =
|
|
4679
|
+
let h = m + i.left + i.right, g = Math.max(0, l - m), _ = Pn({
|
|
4444
4680
|
start: r.left,
|
|
4445
4681
|
end: r.right,
|
|
4446
4682
|
insetStart: i.left,
|
|
@@ -4461,8 +4697,8 @@ function bn({ text: e, width: t, height: n, padding: r, internalShapeTextInset:
|
|
|
4461
4697
|
requiredWidth: h
|
|
4462
4698
|
};
|
|
4463
4699
|
}
|
|
4464
|
-
function
|
|
4465
|
-
let a = Math.max(0, Math.max(1, n) - Math.max(1, r)), o =
|
|
4700
|
+
function Ln({ padding: e, internalShapeTextInset: t, height: n, textHeight: r, changedPadding: i }) {
|
|
4701
|
+
let a = Math.max(0, Math.max(1, n) - Math.max(1, r)), o = Pn({
|
|
4466
4702
|
start: e.top,
|
|
4467
4703
|
end: e.bottom,
|
|
4468
4704
|
insetStart: t.top,
|
|
@@ -4482,8 +4718,8 @@ function xn({ padding: e, internalShapeTextInset: t, height: n, textHeight: r, c
|
|
|
4482
4718
|
}
|
|
4483
4719
|
};
|
|
4484
4720
|
}
|
|
4485
|
-
function
|
|
4486
|
-
let l = Math.max(1, t), u = Math.max(1, n), d = K({ padding: r }), f = K({ padding: i }), p =
|
|
4721
|
+
function Rn({ text: e, width: t, height: n, padding: r, internalShapeTextInset: i, expandShapeHeightToFitText: a, changedPadding: o, measureTextboxHeightForFrame: s, resolveMinimumTextFrameWidth: c }) {
|
|
4722
|
+
let l = Math.max(1, t), u = Math.max(1, n), d = K({ padding: r }), f = K({ padding: i }), p = In({
|
|
4487
4723
|
text: e,
|
|
4488
4724
|
width: l,
|
|
4489
4725
|
height: u,
|
|
@@ -4493,7 +4729,7 @@ function Sn({ text: e, width: t, height: n, padding: r, internalShapeTextInset:
|
|
|
4493
4729
|
changedPadding: o,
|
|
4494
4730
|
measureTextboxHeightForFrame: s,
|
|
4495
4731
|
resolveMinimumTextFrameWidth: c
|
|
4496
|
-
}), m =
|
|
4732
|
+
}), m = jn({
|
|
4497
4733
|
width: l,
|
|
4498
4734
|
padding: {
|
|
4499
4735
|
top: 0,
|
|
@@ -4501,10 +4737,10 @@ function Sn({ text: e, width: t, height: n, padding: r, internalShapeTextInset:
|
|
|
4501
4737
|
bottom: 0,
|
|
4502
4738
|
left: p.appliedPadding.left
|
|
4503
4739
|
}
|
|
4504
|
-
}), h =
|
|
4740
|
+
}), h = Mn({ text: e }) ? s({
|
|
4505
4741
|
text: e,
|
|
4506
4742
|
frameWidth: m
|
|
4507
|
-
}) : 1, g = f.top + f.bottom, _ = a ? Math.max(u, h + g) : u, v =
|
|
4743
|
+
}) : 1, g = f.top + f.bottom, _ = a ? Math.max(u, h + g) : u, v = Ln({
|
|
4508
4744
|
padding: d,
|
|
4509
4745
|
internalShapeTextInset: f,
|
|
4510
4746
|
height: _,
|
|
@@ -4530,9 +4766,9 @@ function Sn({ text: e, width: t, height: n, padding: r, internalShapeTextInset:
|
|
|
4530
4766
|
}
|
|
4531
4767
|
//#endregion
|
|
4532
4768
|
//#region src/editor/shape-manager/layout/shape-layout.ts
|
|
4533
|
-
var Y = 1,
|
|
4534
|
-
function
|
|
4535
|
-
let { frame: o, splitByGrapheme: s, textTop: c } =
|
|
4769
|
+
var Y = 1, zn = .5, Bn = 8, Vn = 20, Hn = 16;
|
|
4770
|
+
function Un({ text: e, alignV: t, width: n, height: r, appliedPadding: i, appliedUserPadding: a }) {
|
|
4771
|
+
let { frame: o, splitByGrapheme: s, textTop: c } = Xn({
|
|
4536
4772
|
text: e,
|
|
4537
4773
|
width: n,
|
|
4538
4774
|
height: r,
|
|
@@ -4549,8 +4785,8 @@ function Dn({ text: e, alignV: t, width: n, height: r, appliedPadding: i, applie
|
|
|
4549
4785
|
textTop: c
|
|
4550
4786
|
};
|
|
4551
4787
|
}
|
|
4552
|
-
var
|
|
4553
|
-
let { width: f, height: p, appliedPadding: m, appliedUserPadding: h } = s ?
|
|
4788
|
+
var Wn = ({ text: e, width: t, height: n, alignV: r, padding: i, internalShapeTextInset: a, resolveInternalShapeTextInset: o, preserveAspectRatio: s, shapeTextAutoExpandEnabled: c, montageAreaWidth: l, expandShapeHeightToFitText: u = !0, changedPadding: d }) => {
|
|
4789
|
+
let { width: f, height: p, appliedPadding: m, appliedUserPadding: h } = s ? qn({
|
|
4554
4790
|
text: e,
|
|
4555
4791
|
width: t,
|
|
4556
4792
|
height: n,
|
|
@@ -4561,7 +4797,7 @@ var On = ({ text: e, width: t, height: n, alignV: r, padding: i, internalShapeTe
|
|
|
4561
4797
|
montageAreaWidth: l,
|
|
4562
4798
|
expandShapeHeightToFitText: u,
|
|
4563
4799
|
changedPadding: d
|
|
4564
|
-
}) :
|
|
4800
|
+
}) : nr({
|
|
4565
4801
|
text: e,
|
|
4566
4802
|
width: t,
|
|
4567
4803
|
height: n,
|
|
@@ -4571,7 +4807,7 @@ var On = ({ text: e, width: t, height: n, alignV: r, padding: i, internalShapeTe
|
|
|
4571
4807
|
expandShapeHeightToFitText: u,
|
|
4572
4808
|
changedPadding: d
|
|
4573
4809
|
});
|
|
4574
|
-
return
|
|
4810
|
+
return Un({
|
|
4575
4811
|
text: e,
|
|
4576
4812
|
alignV: r,
|
|
4577
4813
|
width: f,
|
|
@@ -4579,13 +4815,13 @@ var On = ({ text: e, width: t, height: n, alignV: r, padding: i, internalShapeTe
|
|
|
4579
4815
|
appliedPadding: m,
|
|
4580
4816
|
appliedUserPadding: h
|
|
4581
4817
|
});
|
|
4582
|
-
},
|
|
4583
|
-
let l = Se({ padding: i }), u = K({ padding: a }), d = Math.max(Y, t), f = Math.max(Y, n), p =
|
|
4818
|
+
}, Gn = ({ text: e, width: t, height: n, alignV: r, padding: i, internalShapeTextInset: a, resolveInternalShapeTextInset: o, expandShapeHeightToFitText: s = !0, changedPadding: c }) => {
|
|
4819
|
+
let l = Se({ padding: i }), u = K({ padding: a }), d = Math.max(Y, t), f = Math.max(Y, n), p = Rn({
|
|
4584
4820
|
text: e,
|
|
4585
4821
|
width: d,
|
|
4586
4822
|
height: f,
|
|
4587
4823
|
padding: l,
|
|
4588
|
-
internalShapeTextInset:
|
|
4824
|
+
internalShapeTextInset: tr({
|
|
4589
4825
|
width: d,
|
|
4590
4826
|
height: f,
|
|
4591
4827
|
internalShapeTextInset: u,
|
|
@@ -4593,18 +4829,18 @@ var On = ({ text: e, width: t, height: n, alignV: r, padding: i, internalShapeTe
|
|
|
4593
4829
|
}),
|
|
4594
4830
|
expandShapeHeightToFitText: s,
|
|
4595
4831
|
changedPadding: c,
|
|
4596
|
-
measureTextboxHeightForFrame:
|
|
4597
|
-
resolveMinimumTextFrameWidth:
|
|
4832
|
+
measureTextboxHeightForFrame: cr,
|
|
4833
|
+
resolveMinimumTextFrameWidth: lr
|
|
4598
4834
|
});
|
|
4599
|
-
for (let t = 0; t <
|
|
4835
|
+
for (let t = 0; t < Bn; t += 1) {
|
|
4600
4836
|
let t = Math.max(f, p.requiredHeight);
|
|
4601
|
-
if (t <= f +
|
|
4602
|
-
f = t, p =
|
|
4837
|
+
if (t <= f + zn) break;
|
|
4838
|
+
f = t, p = Rn({
|
|
4603
4839
|
text: e,
|
|
4604
4840
|
width: d,
|
|
4605
4841
|
height: f,
|
|
4606
4842
|
padding: l,
|
|
4607
|
-
internalShapeTextInset:
|
|
4843
|
+
internalShapeTextInset: tr({
|
|
4608
4844
|
width: d,
|
|
4609
4845
|
height: f,
|
|
4610
4846
|
internalShapeTextInset: u,
|
|
@@ -4612,11 +4848,11 @@ var On = ({ text: e, width: t, height: n, alignV: r, padding: i, internalShapeTe
|
|
|
4612
4848
|
}),
|
|
4613
4849
|
expandShapeHeightToFitText: s,
|
|
4614
4850
|
changedPadding: c,
|
|
4615
|
-
measureTextboxHeightForFrame:
|
|
4616
|
-
resolveMinimumTextFrameWidth:
|
|
4851
|
+
measureTextboxHeightForFrame: cr,
|
|
4852
|
+
resolveMinimumTextFrameWidth: lr
|
|
4617
4853
|
});
|
|
4618
4854
|
}
|
|
4619
|
-
return
|
|
4855
|
+
return Un({
|
|
4620
4856
|
text: e,
|
|
4621
4857
|
alignV: r,
|
|
4622
4858
|
width: d,
|
|
@@ -4624,8 +4860,8 @@ var On = ({ text: e, width: t, height: n, alignV: r, padding: i, internalShapeTe
|
|
|
4624
4860
|
appliedPadding: p.appliedPadding,
|
|
4625
4861
|
appliedUserPadding: p.appliedUserPadding
|
|
4626
4862
|
});
|
|
4627
|
-
},
|
|
4628
|
-
let h = Math.max(Y, e.shapeManualBaseWidth ?? r), g = Math.max(Y, e.shapeManualBaseHeight ?? i), { width: _, height: v, appliedUserPadding: y, frame: b, splitByGrapheme: x, textTop: S } =
|
|
4863
|
+
}, Kn = ({ group: e, shape: t, text: n, width: r, height: i, alignH: a, alignV: o, padding: s, internalShapeTextInset: c, resolveInternalShapeTextInset: l, preserveAspectRatio: u, shapeTextAutoExpandEnabled: d, montageAreaWidth: f, expandShapeHeightToFitText: p = !0, changedPadding: m }) => {
|
|
4864
|
+
let h = Math.max(Y, e.shapeManualBaseWidth ?? r), g = Math.max(Y, e.shapeManualBaseHeight ?? i), { width: _, height: v, appliedUserPadding: y, frame: b, splitByGrapheme: x, textTop: S } = Wn({
|
|
4629
4865
|
text: n,
|
|
4630
4866
|
width: r,
|
|
4631
4867
|
height: i,
|
|
@@ -4639,7 +4875,7 @@ var On = ({ text: e, width: t, height: n, alignV: r, padding: i, internalShapeTe
|
|
|
4639
4875
|
expandShapeHeightToFitText: p,
|
|
4640
4876
|
changedPadding: m
|
|
4641
4877
|
});
|
|
4642
|
-
|
|
4878
|
+
hn({
|
|
4643
4879
|
shape: t,
|
|
4644
4880
|
width: _,
|
|
4645
4881
|
height: v,
|
|
@@ -4668,9 +4904,9 @@ var On = ({ text: e, width: t, height: n, alignV: r, padding: i, internalShapeTe
|
|
|
4668
4904
|
scaleY: 1
|
|
4669
4905
|
}), e.set("dirty", !0), e.setCoords();
|
|
4670
4906
|
};
|
|
4671
|
-
function
|
|
4907
|
+
function qn({ text: e, width: t, height: n, padding: r, internalShapeTextInset: i, resolveInternalShapeTextInset: a, shapeTextAutoExpandEnabled: o = !0, montageAreaWidth: s, expandShapeHeightToFitText: c = !0, changedPadding: l }) {
|
|
4672
4908
|
let u = Math.max(Y, t), d = Math.max(Y, n), f = Number.isFinite(s) && (s ?? 0) > 0 ? Math.max(Y, s ?? Y) : null;
|
|
4673
|
-
if (!
|
|
4909
|
+
if (!Qn({ text: e })) return nr({
|
|
4674
4910
|
text: e,
|
|
4675
4911
|
width: u,
|
|
4676
4912
|
height: d,
|
|
@@ -4681,7 +4917,7 @@ function jn({ text: e, width: t, height: n, padding: r, internalShapeTextInset:
|
|
|
4681
4917
|
changedPadding: l
|
|
4682
4918
|
});
|
|
4683
4919
|
let p = d / u, m = ({ width: t }) => {
|
|
4684
|
-
let n = Math.max(Y, t * p), o =
|
|
4920
|
+
let n = Math.max(Y, t * p), o = nr({
|
|
4685
4921
|
text: e,
|
|
4686
4922
|
width: t,
|
|
4687
4923
|
height: n,
|
|
@@ -4693,13 +4929,13 @@ function jn({ text: e, width: t, height: n, padding: r, internalShapeTextInset:
|
|
|
4693
4929
|
});
|
|
4694
4930
|
return {
|
|
4695
4931
|
candidateHeight: n,
|
|
4696
|
-
frameWidth:
|
|
4932
|
+
frameWidth: jn({
|
|
4697
4933
|
width: t,
|
|
4698
4934
|
padding: o.appliedPadding
|
|
4699
4935
|
}),
|
|
4700
4936
|
layoutResolution: o
|
|
4701
4937
|
};
|
|
4702
|
-
}, h = ({ candidateWidth: e, candidateHeight: t, layoutResolution: n }) => !(n.width > e +
|
|
4938
|
+
}, h = ({ candidateWidth: e, candidateHeight: t, layoutResolution: n }) => !(n.width > e + zn || n.height > t + zn);
|
|
4703
4939
|
if (!o) {
|
|
4704
4940
|
let e = ({ width: e }) => {
|
|
4705
4941
|
let { candidateHeight: t, layoutResolution: n } = m({ width: e });
|
|
@@ -4709,11 +4945,11 @@ function jn({ text: e, width: t, height: n, padding: r, internalShapeTextInset:
|
|
|
4709
4945
|
layoutResolution: n
|
|
4710
4946
|
});
|
|
4711
4947
|
}, t = f ? Math.max(u, f) : u;
|
|
4712
|
-
e({ width: t }) || (t =
|
|
4948
|
+
e({ width: t }) || (t = rr({
|
|
4713
4949
|
minimumWidth: t,
|
|
4714
4950
|
isWidthValid: e
|
|
4715
4951
|
}));
|
|
4716
|
-
let { layoutResolution: n } = m({ width:
|
|
4952
|
+
let { layoutResolution: n } = m({ width: ir({
|
|
4717
4953
|
minimumWidth: u,
|
|
4718
4954
|
maximumWidth: t,
|
|
4719
4955
|
isWidthValid: e
|
|
@@ -4726,19 +4962,19 @@ function jn({ text: e, width: t, height: n, padding: r, internalShapeTextInset:
|
|
|
4726
4962
|
candidateWidth: t,
|
|
4727
4963
|
candidateHeight: r,
|
|
4728
4964
|
layoutResolution: a
|
|
4729
|
-
}) || n !== void 0 && i < n -
|
|
4965
|
+
}) || n !== void 0 && i < n - zn ? !1 : !sr({
|
|
4730
4966
|
text: e,
|
|
4731
4967
|
frameWidth: i
|
|
4732
4968
|
}).hasWrappedLines;
|
|
4733
|
-
}, _ = f ? Math.max(u, f) :
|
|
4969
|
+
}, _ = f ? Math.max(u, f) : rr({
|
|
4734
4970
|
minimumWidth: u,
|
|
4735
4971
|
isWidthValid: ({ width: e }) => g({ width: e })
|
|
4736
|
-
}), v = m({ width: _ }), y =
|
|
4972
|
+
}), v = m({ width: _ }), y = sr({
|
|
4737
4973
|
text: e,
|
|
4738
4974
|
frameWidth: v.frameWidth
|
|
4739
4975
|
});
|
|
4740
4976
|
if (y.hasWrappedLines) return v.layoutResolution;
|
|
4741
|
-
let b = Math.max(Y, y.longestLineWidth), { layoutResolution: x } = m({ width:
|
|
4977
|
+
let b = Math.max(Y, y.longestLineWidth), { layoutResolution: x } = m({ width: ir({
|
|
4742
4978
|
minimumWidth: u,
|
|
4743
4979
|
maximumWidth: _,
|
|
4744
4980
|
isWidthValid: ({ width: e }) => g({
|
|
@@ -4748,67 +4984,67 @@ function jn({ text: e, width: t, height: n, padding: r, internalShapeTextInset:
|
|
|
4748
4984
|
}) });
|
|
4749
4985
|
return x;
|
|
4750
4986
|
}
|
|
4751
|
-
var
|
|
4987
|
+
var Jn = ({ text: e, currentWidth: t, minimumWidth: n, padding: r, montageAreaWidth: i, resolvePaddingForWidth: a }) => {
|
|
4752
4988
|
let o = Math.max(Y, t), s = Math.max(Y, n);
|
|
4753
|
-
if (!
|
|
4754
|
-
let c = Math.max(s, Number.isFinite(i) && i > 0 ? Math.max(Y, i) : Math.max(o, s)), l =
|
|
4989
|
+
if (!Qn({ text: e })) return s;
|
|
4990
|
+
let c = Math.max(s, Number.isFinite(i) && i > 0 ? Math.max(Y, i) : Math.max(o, s)), l = jn({
|
|
4755
4991
|
width: c,
|
|
4756
|
-
padding:
|
|
4992
|
+
padding: $n({
|
|
4757
4993
|
width: c,
|
|
4758
4994
|
padding: r,
|
|
4759
4995
|
resolvePaddingForWidth: a
|
|
4760
4996
|
})
|
|
4761
|
-
}), u = c, d =
|
|
4997
|
+
}), u = c, d = sr({
|
|
4762
4998
|
text: e,
|
|
4763
4999
|
frameWidth: l
|
|
4764
5000
|
});
|
|
4765
5001
|
if (d.hasWrappedLines) return u;
|
|
4766
5002
|
let f = Math.max(Y, d.longestLineWidth);
|
|
4767
|
-
return
|
|
5003
|
+
return ir({
|
|
4768
5004
|
minimumWidth: s,
|
|
4769
5005
|
maximumWidth: u,
|
|
4770
5006
|
isWidthValid: ({ width: t }) => {
|
|
4771
|
-
let n =
|
|
5007
|
+
let n = jn({
|
|
4772
5008
|
width: t,
|
|
4773
|
-
padding:
|
|
5009
|
+
padding: $n({
|
|
4774
5010
|
width: t,
|
|
4775
5011
|
padding: r,
|
|
4776
5012
|
resolvePaddingForWidth: a
|
|
4777
5013
|
})
|
|
4778
5014
|
});
|
|
4779
|
-
return n < f -
|
|
5015
|
+
return n < f - zn ? !1 : !sr({
|
|
4780
5016
|
text: e,
|
|
4781
5017
|
frameWidth: n
|
|
4782
5018
|
}).hasWrappedLines;
|
|
4783
5019
|
}
|
|
4784
5020
|
});
|
|
4785
|
-
},
|
|
4786
|
-
if (!
|
|
4787
|
-
let r =
|
|
5021
|
+
}, Yn = ({ text: e, padding: t, resolvePaddingForWidth: n }) => {
|
|
5022
|
+
if (!Qn({ text: e })) return Y;
|
|
5023
|
+
let r = lr({ text: e }), i = Math.max(Y, r), a = ({ width: e }) => jn({
|
|
4788
5024
|
width: e,
|
|
4789
|
-
padding:
|
|
5025
|
+
padding: $n({
|
|
4790
5026
|
width: e,
|
|
4791
5027
|
padding: t,
|
|
4792
5028
|
resolvePaddingForWidth: n
|
|
4793
5029
|
})
|
|
4794
|
-
}) >= r -
|
|
4795
|
-
return
|
|
5030
|
+
}) >= r - zn;
|
|
5031
|
+
return ir({
|
|
4796
5032
|
minimumWidth: i,
|
|
4797
|
-
maximumWidth:
|
|
5033
|
+
maximumWidth: rr({
|
|
4798
5034
|
minimumWidth: i,
|
|
4799
5035
|
isWidthValid: a
|
|
4800
5036
|
}),
|
|
4801
5037
|
isWidthValid: a
|
|
4802
5038
|
});
|
|
4803
|
-
},
|
|
4804
|
-
let a =
|
|
5039
|
+
}, Xn = ({ text: e, width: t, height: n, alignV: r, padding: i }) => {
|
|
5040
|
+
let a = ar({
|
|
4805
5041
|
width: Math.max(Y, t),
|
|
4806
5042
|
height: Math.max(Y, n),
|
|
4807
5043
|
padding: K({ padding: i })
|
|
4808
|
-
}), o =
|
|
5044
|
+
}), o = fr({
|
|
4809
5045
|
text: e,
|
|
4810
5046
|
frameWidth: a.width
|
|
4811
|
-
}), s =
|
|
5047
|
+
}), s = cr({
|
|
4812
5048
|
text: e,
|
|
4813
5049
|
frameWidth: a.width,
|
|
4814
5050
|
splitByGrapheme: o
|
|
@@ -4816,60 +5052,60 @@ var Mn = ({ text: e, currentWidth: t, minimumWidth: n, padding: r, montageAreaWi
|
|
|
4816
5052
|
return {
|
|
4817
5053
|
frame: a,
|
|
4818
5054
|
splitByGrapheme: o,
|
|
4819
|
-
textTop:
|
|
5055
|
+
textTop: dr({
|
|
4820
5056
|
alignV: r,
|
|
4821
5057
|
frameHeight: a.height,
|
|
4822
5058
|
frameTop: a.top,
|
|
4823
5059
|
textHeight: s
|
|
4824
5060
|
})
|
|
4825
5061
|
};
|
|
4826
|
-
},
|
|
5062
|
+
}, Zn = ({ text: e, width: t, height: n, padding: r, resolvePaddingForSize: i }) => {
|
|
4827
5063
|
let a = Math.max(Y, n);
|
|
4828
|
-
if (!
|
|
5064
|
+
if (!Qn({ text: e })) return a;
|
|
4829
5065
|
let o = Math.max(Y, t), s = a;
|
|
4830
|
-
for (let t = 0; t <
|
|
4831
|
-
let t =
|
|
5066
|
+
for (let t = 0; t < Bn; t += 1) {
|
|
5067
|
+
let t = er({
|
|
4832
5068
|
width: o,
|
|
4833
5069
|
height: s,
|
|
4834
5070
|
padding: r,
|
|
4835
5071
|
resolvePaddingForSize: i
|
|
4836
|
-
}), n =
|
|
5072
|
+
}), n = cr({
|
|
4837
5073
|
text: e,
|
|
4838
|
-
frameWidth:
|
|
5074
|
+
frameWidth: jn({
|
|
4839
5075
|
width: o,
|
|
4840
5076
|
padding: t
|
|
4841
5077
|
})
|
|
4842
5078
|
}), c = Math.max(a, n + t.top + t.bottom);
|
|
4843
|
-
if (c <= s +
|
|
5079
|
+
if (c <= s + zn) return c;
|
|
4844
5080
|
s = c;
|
|
4845
5081
|
}
|
|
4846
5082
|
return s;
|
|
4847
5083
|
};
|
|
4848
|
-
function
|
|
5084
|
+
function Qn({ text: e }) {
|
|
4849
5085
|
return (e.text ?? "").trim().length > 0;
|
|
4850
5086
|
}
|
|
4851
|
-
function
|
|
5087
|
+
function $n({ width: e, padding: t, resolvePaddingForWidth: n }) {
|
|
4852
5088
|
return K(n ? { padding: n({ width: Math.max(Y, e) }) } : { padding: t });
|
|
4853
5089
|
}
|
|
4854
|
-
function
|
|
5090
|
+
function er({ width: e, height: t, padding: n, resolvePaddingForSize: r }) {
|
|
4855
5091
|
return K(r ? { padding: r({
|
|
4856
5092
|
width: Math.max(Y, e),
|
|
4857
5093
|
height: Math.max(Y, t)
|
|
4858
5094
|
}) } : { padding: n });
|
|
4859
5095
|
}
|
|
4860
|
-
function
|
|
5096
|
+
function tr({ width: e, height: t, internalShapeTextInset: n, resolveInternalShapeTextInset: r }) {
|
|
4861
5097
|
return K(r ? { padding: r({
|
|
4862
5098
|
width: Math.max(Y, e),
|
|
4863
5099
|
height: Math.max(Y, t)
|
|
4864
5100
|
}) } : { padding: n });
|
|
4865
5101
|
}
|
|
4866
|
-
function
|
|
4867
|
-
let c = Se({ padding: r }), l = K({ padding: i }), u = Math.max(Y, t), d = Math.max(Y, n), f =
|
|
5102
|
+
function nr({ text: e, width: t, height: n, padding: r, internalShapeTextInset: i, resolveInternalShapeTextInset: a, expandShapeHeightToFitText: o = !0, changedPadding: s }) {
|
|
5103
|
+
let c = Se({ padding: r }), l = K({ padding: i }), u = Math.max(Y, t), d = Math.max(Y, n), f = Rn({
|
|
4868
5104
|
text: e,
|
|
4869
5105
|
width: u,
|
|
4870
5106
|
height: d,
|
|
4871
5107
|
padding: c,
|
|
4872
|
-
internalShapeTextInset:
|
|
5108
|
+
internalShapeTextInset: tr({
|
|
4873
5109
|
width: u,
|
|
4874
5110
|
height: d,
|
|
4875
5111
|
internalShapeTextInset: l,
|
|
@@ -4877,18 +5113,18 @@ function Bn({ text: e, width: t, height: n, padding: r, internalShapeTextInset:
|
|
|
4877
5113
|
}),
|
|
4878
5114
|
expandShapeHeightToFitText: o,
|
|
4879
5115
|
changedPadding: s,
|
|
4880
|
-
measureTextboxHeightForFrame:
|
|
4881
|
-
resolveMinimumTextFrameWidth:
|
|
5116
|
+
measureTextboxHeightForFrame: cr,
|
|
5117
|
+
resolveMinimumTextFrameWidth: lr
|
|
4882
5118
|
});
|
|
4883
|
-
for (let t = 0; t <
|
|
5119
|
+
for (let t = 0; t < Bn; t += 1) {
|
|
4884
5120
|
let t = Math.max(u, f.requiredWidth), n = Math.max(d, f.requiredHeight);
|
|
4885
|
-
if (t <= u +
|
|
4886
|
-
u = t, d = n, f =
|
|
5121
|
+
if (t <= u + zn && n <= d + zn) break;
|
|
5122
|
+
u = t, d = n, f = Rn({
|
|
4887
5123
|
text: e,
|
|
4888
5124
|
width: u,
|
|
4889
5125
|
height: d,
|
|
4890
5126
|
padding: c,
|
|
4891
|
-
internalShapeTextInset:
|
|
5127
|
+
internalShapeTextInset: tr({
|
|
4892
5128
|
width: u,
|
|
4893
5129
|
height: d,
|
|
4894
5130
|
internalShapeTextInset: l,
|
|
@@ -4896,8 +5132,8 @@ function Bn({ text: e, width: t, height: n, padding: r, internalShapeTextInset:
|
|
|
4896
5132
|
}),
|
|
4897
5133
|
expandShapeHeightToFitText: o,
|
|
4898
5134
|
changedPadding: s,
|
|
4899
|
-
measureTextboxHeightForFrame:
|
|
4900
|
-
resolveMinimumTextFrameWidth:
|
|
5135
|
+
measureTextboxHeightForFrame: cr,
|
|
5136
|
+
resolveMinimumTextFrameWidth: lr
|
|
4901
5137
|
});
|
|
4902
5138
|
}
|
|
4903
5139
|
return {
|
|
@@ -4907,17 +5143,17 @@ function Bn({ text: e, width: t, height: n, padding: r, internalShapeTextInset:
|
|
|
4907
5143
|
appliedUserPadding: f.appliedUserPadding
|
|
4908
5144
|
};
|
|
4909
5145
|
}
|
|
4910
|
-
function
|
|
5146
|
+
function rr({ minimumWidth: e, isWidthValid: t }) {
|
|
4911
5147
|
let n = Math.max(Y, e);
|
|
4912
5148
|
if (t({ width: n })) return n;
|
|
4913
|
-
for (let e = 0; e <
|
|
5149
|
+
for (let e = 0; e < Hn; e += 1) if (n = Math.max(n + 1, n * 2), t({ width: n })) return n;
|
|
4914
5150
|
return n;
|
|
4915
5151
|
}
|
|
4916
|
-
function
|
|
5152
|
+
function ir({ minimumWidth: e, maximumWidth: t, isWidthValid: n }) {
|
|
4917
5153
|
let r = Math.max(Y, e), i = Math.max(r, t);
|
|
4918
5154
|
if (n({ width: r })) return r;
|
|
4919
5155
|
if (!n({ width: i })) return i;
|
|
4920
|
-
for (let e = 0; e <
|
|
5156
|
+
for (let e = 0; e < Vn && !(i - r <= zn); e += 1) {
|
|
4921
5157
|
let e = r + (i - r) / 2;
|
|
4922
5158
|
if (n({ width: e })) {
|
|
4923
5159
|
i = e;
|
|
@@ -4927,7 +5163,7 @@ function Hn({ minimumWidth: e, maximumWidth: t, isWidthValid: n }) {
|
|
|
4927
5163
|
}
|
|
4928
5164
|
return i;
|
|
4929
5165
|
}
|
|
4930
|
-
function
|
|
5166
|
+
function ar({ width: e, height: t, padding: n }) {
|
|
4931
5167
|
let r = Math.max(0, n.left), i = Math.max(0, n.right), a = Math.max(0, n.top), o = Math.max(0, n.bottom);
|
|
4932
5168
|
return {
|
|
4933
5169
|
left: -e / 2 + r,
|
|
@@ -4936,7 +5172,7 @@ function Un({ width: e, height: t, padding: n }) {
|
|
|
4936
5172
|
height: Math.max(Y, t - a - o)
|
|
4937
5173
|
};
|
|
4938
5174
|
}
|
|
4939
|
-
function
|
|
5175
|
+
function or({ text: e }) {
|
|
4940
5176
|
let { height: t } = e;
|
|
4941
5177
|
if (typeof t == "number" && Number.isFinite(t)) return t;
|
|
4942
5178
|
if (typeof e.calcTextHeight == "function") {
|
|
@@ -4945,18 +5181,18 @@ function Wn({ text: e }) {
|
|
|
4945
5181
|
}
|
|
4946
5182
|
return Y;
|
|
4947
5183
|
}
|
|
4948
|
-
function
|
|
4949
|
-
let n =
|
|
5184
|
+
function sr({ text: e, frameWidth: t }) {
|
|
5185
|
+
let n = mr({ text: e }), r = fr({
|
|
4950
5186
|
text: e,
|
|
4951
5187
|
frameWidth: t
|
|
4952
|
-
}), i =
|
|
5188
|
+
}), i = _r({ text: e });
|
|
4953
5189
|
e.set({
|
|
4954
5190
|
autoExpand: !1,
|
|
4955
5191
|
width: Math.max(Y, t),
|
|
4956
5192
|
splitByGrapheme: r
|
|
4957
5193
|
}), e.initDimensions();
|
|
4958
|
-
let a =
|
|
4959
|
-
return
|
|
5194
|
+
let a = hr({ text: e }) > n, o = Math.ceil(pr({ text: e }));
|
|
5195
|
+
return vr({
|
|
4960
5196
|
text: e,
|
|
4961
5197
|
state: i
|
|
4962
5198
|
}), {
|
|
@@ -4964,8 +5200,8 @@ function Gn({ text: e, frameWidth: t }) {
|
|
|
4964
5200
|
longestLineWidth: o
|
|
4965
5201
|
};
|
|
4966
5202
|
}
|
|
4967
|
-
function
|
|
4968
|
-
let r =
|
|
5203
|
+
function cr({ text: e, frameWidth: t, splitByGrapheme: n }) {
|
|
5204
|
+
let r = _r({ text: e }), i = n ?? fr({
|
|
4969
5205
|
text: e,
|
|
4970
5206
|
frameWidth: t
|
|
4971
5207
|
});
|
|
@@ -4974,71 +5210,71 @@ function Kn({ text: e, frameWidth: t, splitByGrapheme: n }) {
|
|
|
4974
5210
|
width: Math.max(Y, t),
|
|
4975
5211
|
splitByGrapheme: i
|
|
4976
5212
|
}), e.initDimensions();
|
|
4977
|
-
let a =
|
|
4978
|
-
return
|
|
5213
|
+
let a = or({ text: e });
|
|
5214
|
+
return vr({
|
|
4979
5215
|
text: e,
|
|
4980
5216
|
state: r
|
|
4981
5217
|
}), a;
|
|
4982
5218
|
}
|
|
4983
|
-
function
|
|
4984
|
-
let t =
|
|
5219
|
+
function lr({ text: e }) {
|
|
5220
|
+
let t = ur({
|
|
4985
5221
|
text: e,
|
|
4986
5222
|
frameWidth: Y,
|
|
4987
5223
|
splitByGrapheme: !0
|
|
4988
5224
|
});
|
|
4989
5225
|
return Math.max(Y, t);
|
|
4990
5226
|
}
|
|
4991
|
-
function
|
|
4992
|
-
let r =
|
|
5227
|
+
function ur({ text: e, frameWidth: t, splitByGrapheme: n }) {
|
|
5228
|
+
let r = _r({ text: e });
|
|
4993
5229
|
e.set({
|
|
4994
5230
|
autoExpand: !1,
|
|
4995
5231
|
width: Math.max(Y, t),
|
|
4996
5232
|
splitByGrapheme: n
|
|
4997
5233
|
}), e.initDimensions();
|
|
4998
|
-
let i =
|
|
4999
|
-
return
|
|
5234
|
+
let i = pr({ text: e });
|
|
5235
|
+
return vr({
|
|
5000
5236
|
text: e,
|
|
5001
5237
|
state: r
|
|
5002
5238
|
}), i;
|
|
5003
5239
|
}
|
|
5004
|
-
function
|
|
5240
|
+
function dr({ alignV: e, frameHeight: t, frameTop: n, textHeight: r }) {
|
|
5005
5241
|
let i = Math.max(0, t - r);
|
|
5006
5242
|
return e === "top" ? n : e === "bottom" ? n + i : n + i / 2;
|
|
5007
5243
|
}
|
|
5008
|
-
function
|
|
5009
|
-
let n = Math.max(Y, t), r =
|
|
5244
|
+
function fr({ text: e, frameWidth: t }) {
|
|
5245
|
+
let n = Math.max(Y, t), r = _r({ text: e });
|
|
5010
5246
|
e.set({
|
|
5011
5247
|
autoExpand: !1,
|
|
5012
5248
|
width: n,
|
|
5013
5249
|
splitByGrapheme: !1
|
|
5014
5250
|
}), e.initDimensions();
|
|
5015
|
-
let i =
|
|
5016
|
-
return
|
|
5251
|
+
let i = yr({ text: e }) > n + zn;
|
|
5252
|
+
return vr({
|
|
5017
5253
|
text: e,
|
|
5018
5254
|
state: r
|
|
5019
5255
|
}), i;
|
|
5020
5256
|
}
|
|
5021
|
-
function
|
|
5022
|
-
let t =
|
|
5023
|
-
if (t > 0) return
|
|
5257
|
+
function pr({ text: e }) {
|
|
5258
|
+
let t = hr({ text: e });
|
|
5259
|
+
if (t > 0) return gr({
|
|
5024
5260
|
text: e,
|
|
5025
5261
|
lineCount: t
|
|
5026
5262
|
});
|
|
5027
5263
|
let n = e.text ?? "";
|
|
5028
|
-
return
|
|
5264
|
+
return gr({
|
|
5029
5265
|
text: e,
|
|
5030
5266
|
lineCount: Math.max(n.split("\n").length, 1)
|
|
5031
5267
|
});
|
|
5032
5268
|
}
|
|
5033
|
-
function
|
|
5269
|
+
function mr({ text: e }) {
|
|
5034
5270
|
let t = e.text ?? "";
|
|
5035
5271
|
return Math.max(t.split("\n").length, 1);
|
|
5036
5272
|
}
|
|
5037
|
-
function
|
|
5273
|
+
function hr({ text: e }) {
|
|
5038
5274
|
let t = e;
|
|
5039
5275
|
return Array.isArray(t.textLines) ? t.textLines.length : 0;
|
|
5040
5276
|
}
|
|
5041
|
-
function
|
|
5277
|
+
function gr({ text: e, lineCount: t }) {
|
|
5042
5278
|
let n = Y;
|
|
5043
5279
|
for (let r = 0; r < t; r += 1) {
|
|
5044
5280
|
let t = e.getLineWidth(r);
|
|
@@ -5046,7 +5282,7 @@ function er({ text: e, lineCount: t }) {
|
|
|
5046
5282
|
}
|
|
5047
5283
|
return n;
|
|
5048
5284
|
}
|
|
5049
|
-
function
|
|
5285
|
+
function _r({ text: e }) {
|
|
5050
5286
|
let { autoExpand: t, splitByGrapheme: n, width: r } = e;
|
|
5051
5287
|
return {
|
|
5052
5288
|
autoExpand: t,
|
|
@@ -5054,22 +5290,22 @@ function tr({ text: e }) {
|
|
|
5054
5290
|
width: typeof r == "number" ? r : void 0
|
|
5055
5291
|
};
|
|
5056
5292
|
}
|
|
5057
|
-
function
|
|
5293
|
+
function vr({ text: e, state: t }) {
|
|
5058
5294
|
let { autoExpand: n, splitByGrapheme: r, width: i } = t, a = {};
|
|
5059
5295
|
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());
|
|
5060
5296
|
}
|
|
5061
|
-
function
|
|
5297
|
+
function yr({ text: e }) {
|
|
5062
5298
|
let { dynamicMinWidth: t } = e;
|
|
5063
5299
|
return typeof t == "number" && Number.isFinite(t) ? t : 0;
|
|
5064
5300
|
}
|
|
5065
5301
|
//#endregion
|
|
5066
5302
|
//#region src/editor/shape-manager/scaling/shape-scaling-transform.ts
|
|
5067
|
-
var
|
|
5303
|
+
var br = ({ transform: e, key: t }) => {
|
|
5068
5304
|
let n = e?.original;
|
|
5069
5305
|
if (!n || typeof n != "object") return null;
|
|
5070
5306
|
let r = n[t];
|
|
5071
5307
|
return typeof r != "number" || !Number.isFinite(r) ? null : r;
|
|
5072
|
-
},
|
|
5308
|
+
}, xr = ({ value: e }) => e === "left" || e === "center" || e === "right" || typeof e == "number" && Number.isFinite(e) ? e : null, Sr = ({ value: e }) => e === "top" || e === "center" || e === "bottom" || typeof e == "number" && Number.isFinite(e) ? e : null, Cr = ({ transform: e }) => {
|
|
5073
5309
|
let t = e?.action ?? "", n = typeof e?.corner == "string" ? e.corner : "", r = n === "tl" || n === "tr" || n === "bl" || n === "br", i = t === "scaleX" || n === "ml" || n === "mr", a = t === "scaleY" || n === "mt" || n === "mb", o = i || r, s = a || r;
|
|
5074
5310
|
return {
|
|
5075
5311
|
canScaleWidth: o,
|
|
@@ -5077,37 +5313,37 @@ var ir = ({ transform: e, key: t }) => {
|
|
|
5077
5313
|
isCornerScaleAction: r,
|
|
5078
5314
|
isVerticalOnlyScale: s && !o
|
|
5079
5315
|
};
|
|
5080
|
-
},
|
|
5316
|
+
}, wr = ({ event: e, group: t, transform: n, canvas: r }) => {
|
|
5081
5317
|
if (!e) return null;
|
|
5082
5318
|
let i = t.canvas ?? r, a = i.getScenePoint(e), o = t.getRelativeCenterPoint(), s = t.translateToGivenOrigin(o, "center", "center", n.originX, n.originY), c = t.angle ?? 0, l = (c === 0 ? a : a.rotate(-c * Math.PI / 180, o)).subtract(s), u = t.controls[n.corner], d = i.getZoom() || 1, f = (t.padding ?? 0) / d;
|
|
5083
5319
|
return l.x >= f && (l.x -= f), l.x <= -f && (l.x += f), l.y >= f && (l.y -= f), l.y <= -f && (l.y += f), l.x -= u?.offsetX ?? 0, l.y -= u?.offsetY ?? 0, l;
|
|
5084
|
-
},
|
|
5320
|
+
}, Tr = ({ group: e, originX: t, originY: n }) => {
|
|
5085
5321
|
if (t === null || n === null) return null;
|
|
5086
5322
|
let r = e, i = typeof r.getRelativeCenterPoint == "function" ? r.getRelativeCenterPoint() : e.getCenterPoint();
|
|
5087
5323
|
return typeof r.translateToOriginPoint == "function" ? r.translateToOriginPoint(i, t, n) : i;
|
|
5088
|
-
},
|
|
5324
|
+
}, Er = ({ state: e, transform: t }) => {
|
|
5089
5325
|
if (!t || e.startTransformOriginX === null && e.startTransformOriginY === null) return !1;
|
|
5090
|
-
let n =
|
|
5326
|
+
let n = xr({ value: t.originX }), r = Sr({ value: t.originY });
|
|
5091
5327
|
return n !== e.startTransformOriginX || r !== e.startTransformOriginY;
|
|
5092
|
-
},
|
|
5328
|
+
}, Dr = ({ state: e, transform: t }) => !t || !e.startTransformCorner ? !1 : t.corner !== e.startTransformCorner;
|
|
5093
5329
|
//#endregion
|
|
5094
5330
|
//#region src/editor/shape-manager/scaling/shape-scaling-preview.ts
|
|
5095
|
-
function
|
|
5331
|
+
function Or({ size: e, scale: t, strokeWidth: n, minSize: r, scaleEpsilon: i }) {
|
|
5096
5332
|
let a = Math.max(i, Math.abs(t) || 1), o = Math.max(0, n);
|
|
5097
5333
|
return o <= 0 ? Math.max(r, e / a) : Math.max(r, e / a + o - o / a);
|
|
5098
5334
|
}
|
|
5099
|
-
function
|
|
5335
|
+
function kr({ group: e, shape: t, width: n, height: r, scaleX: i, scaleY: a, minSize: o, scaleEpsilon: s }) {
|
|
5100
5336
|
let c = Math.max(0, e.shapeStrokeWidth ?? 0);
|
|
5101
|
-
|
|
5337
|
+
hn({
|
|
5102
5338
|
shape: t,
|
|
5103
|
-
width:
|
|
5339
|
+
width: Or({
|
|
5104
5340
|
size: n,
|
|
5105
5341
|
scale: i,
|
|
5106
5342
|
strokeWidth: c,
|
|
5107
5343
|
minSize: o,
|
|
5108
5344
|
scaleEpsilon: s
|
|
5109
5345
|
}),
|
|
5110
|
-
height:
|
|
5346
|
+
height: Or({
|
|
5111
5347
|
size: r,
|
|
5112
5348
|
scale: a,
|
|
5113
5349
|
strokeWidth: c,
|
|
@@ -5118,7 +5354,7 @@ function pr({ group: e, shape: t, width: n, height: r, scaleX: i, scaleY: a, min
|
|
|
5118
5354
|
strokeWidth: c
|
|
5119
5355
|
});
|
|
5120
5356
|
}
|
|
5121
|
-
function
|
|
5357
|
+
function Ar({ text: e, layout: t, alignH: n, scaleX: r, scaleY: i, scaleEpsilon: a }) {
|
|
5122
5358
|
let o = Math.max(a, Math.abs(r) || 1), s = Math.max(a, Math.abs(i) || 1), c = n ?? "center";
|
|
5123
5359
|
e.set({
|
|
5124
5360
|
autoExpand: !1,
|
|
@@ -5133,13 +5369,13 @@ function mr({ text: e, layout: t, alignH: n, scaleX: r, scaleY: i, scaleEpsilon:
|
|
|
5133
5369
|
scaleY: 1 / s
|
|
5134
5370
|
}), e.initDimensions(), e.setCoords();
|
|
5135
5371
|
}
|
|
5136
|
-
var
|
|
5372
|
+
var jr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY: o, minSize: s, scaleEpsilon: c }) => {
|
|
5137
5373
|
let l = Math.max(c, Math.abs(a) || 1), u = Math.max(c, Math.abs(o) || 1);
|
|
5138
5374
|
e.set({
|
|
5139
5375
|
width: r.width / l,
|
|
5140
5376
|
height: r.height / u,
|
|
5141
5377
|
dirty: !0
|
|
5142
|
-
}),
|
|
5378
|
+
}), kr({
|
|
5143
5379
|
group: e,
|
|
5144
5380
|
shape: t,
|
|
5145
5381
|
width: r.width,
|
|
@@ -5148,7 +5384,7 @@ var hr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY
|
|
|
5148
5384
|
scaleY: o,
|
|
5149
5385
|
minSize: s,
|
|
5150
5386
|
scaleEpsilon: c
|
|
5151
|
-
}),
|
|
5387
|
+
}), Ar({
|
|
5152
5388
|
text: n,
|
|
5153
5389
|
layout: r,
|
|
5154
5390
|
alignH: i,
|
|
@@ -5156,7 +5392,7 @@ var hr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY
|
|
|
5156
5392
|
scaleY: o,
|
|
5157
5393
|
scaleEpsilon: c
|
|
5158
5394
|
});
|
|
5159
|
-
}, X = 1, Z = 1e-4,
|
|
5395
|
+
}, X = 1, Z = 1e-4, Mr = .5, Nr = class e {
|
|
5160
5396
|
constructor({ canvas: t }) {
|
|
5161
5397
|
this.handleObjectScaling = (t) => {
|
|
5162
5398
|
let { target: n, transform: r } = t;
|
|
@@ -5172,7 +5408,7 @@ var hr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY
|
|
|
5172
5408
|
text: o,
|
|
5173
5409
|
constraintPadding: s,
|
|
5174
5410
|
transform: r
|
|
5175
|
-
}), { isCornerScaleAction: l } =
|
|
5411
|
+
}), { isCornerScaleAction: l } = Cr({ transform: r }), u = !!(t.e && "shiftKey" in t.e && t.e.shiftKey);
|
|
5176
5412
|
c.isProportionalScaling = l && u;
|
|
5177
5413
|
let d = i.left ?? 0, f = i.top ?? 0, p = !!i.flipX, m = !!i.flipY, h = i.shapeAlignHorizontal ?? "center", g = this._resolveScalingDecision({
|
|
5178
5414
|
group: i,
|
|
@@ -5194,7 +5430,7 @@ var hr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY
|
|
|
5194
5430
|
shouldHandleAsNoop: g.shouldHandleAsNoop,
|
|
5195
5431
|
scaleX: g.appliedScaleX,
|
|
5196
5432
|
scaleY: g.appliedScaleY
|
|
5197
|
-
}),
|
|
5433
|
+
}), jr({
|
|
5198
5434
|
group: i,
|
|
5199
5435
|
shape: a,
|
|
5200
5436
|
text: o,
|
|
@@ -5222,7 +5458,7 @@ var hr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY
|
|
|
5222
5458
|
if (!n) return;
|
|
5223
5459
|
let { target: r } = n;
|
|
5224
5460
|
if (!q(r)) return;
|
|
5225
|
-
let { canScaleHeight: i, canScaleWidth: a } =
|
|
5461
|
+
let { canScaleHeight: i, canScaleWidth: a } = Cr({ transform: n });
|
|
5226
5462
|
if (!a && !i) return;
|
|
5227
5463
|
let o = r, s = this.scalingState.get(o);
|
|
5228
5464
|
if (!s || s.isProportionalScaling) return;
|
|
@@ -5237,7 +5473,7 @@ var hr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY
|
|
|
5237
5473
|
group: o,
|
|
5238
5474
|
axis: "x"
|
|
5239
5475
|
})) {
|
|
5240
|
-
let t =
|
|
5476
|
+
let t = Yn({
|
|
5241
5477
|
text: l,
|
|
5242
5478
|
padding: u,
|
|
5243
5479
|
resolvePaddingForWidth: ({ width: t }) => e._resolveScalingConstraintPadding({
|
|
@@ -5285,7 +5521,7 @@ var hr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY
|
|
|
5285
5521
|
shouldHandleAsNoop: !1,
|
|
5286
5522
|
scaleX: h,
|
|
5287
5523
|
scaleY: g
|
|
5288
|
-
}),
|
|
5524
|
+
}), jr({
|
|
5289
5525
|
group: o,
|
|
5290
5526
|
shape: c,
|
|
5291
5527
|
text: l,
|
|
@@ -5329,7 +5565,7 @@ var hr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY
|
|
|
5329
5565
|
this.scalingState.delete(r);
|
|
5330
5566
|
return;
|
|
5331
5567
|
}
|
|
5332
|
-
let p = r.shapeAlignHorizontal ?? "center", m = r.shapeAlignVertical ?? "middle", h = e._resolveScalingConstraintPadding({ group: r }), g = t.transform ?
|
|
5568
|
+
let p = r.shapeAlignHorizontal ?? "center", m = r.shapeAlignVertical ?? "middle", h = e._resolveScalingConstraintPadding({ group: r }), g = t.transform ? Cr({ transform: t.transform }) : null, _ = i?.canScaleWidth ?? g?.canScaleWidth ?? Math.abs(a - 1) > Z, v = i?.canScaleHeight ?? g?.canScaleHeight ?? Math.abs(o - 1) > Z, y = i?.lastAllowedScaleX ?? a, b = i?.lastAllowedScaleY ?? o, x = Yn({
|
|
5333
5569
|
text: f,
|
|
5334
5570
|
padding: h,
|
|
5335
5571
|
resolvePaddingForWidth: ({ width: t }) => e._resolveScalingConstraintPadding({
|
|
@@ -5358,7 +5594,7 @@ var hr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY
|
|
|
5358
5594
|
state: i
|
|
5359
5595
|
}) && (b = Math.max(X / c, e / c));
|
|
5360
5596
|
}
|
|
5361
|
-
let S = _ ? Math.max(X, s * y) : s, C = v ? Math.max(X, c * b) : u, w = Math.abs(S - s) >
|
|
5597
|
+
let S = _ ? Math.max(X, s * y) : s, C = v ? Math.max(X, c * b) : u, w = Math.abs(S - s) > Mr, T = Math.abs(C - c) > Mr, E = w || T, D = S, O = C;
|
|
5362
5598
|
if (!E && i) {
|
|
5363
5599
|
this._restoreShapeStateWithoutResize({
|
|
5364
5600
|
group: r,
|
|
@@ -5391,7 +5627,7 @@ var hr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY
|
|
|
5391
5627
|
width: D,
|
|
5392
5628
|
height: O
|
|
5393
5629
|
});
|
|
5394
|
-
|
|
5630
|
+
Kn({
|
|
5395
5631
|
group: r,
|
|
5396
5632
|
shape: d,
|
|
5397
5633
|
text: f,
|
|
@@ -5420,10 +5656,10 @@ var hr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY
|
|
|
5420
5656
|
}, this.canvas = t, this.scalingState = /* @__PURE__ */ new WeakMap();
|
|
5421
5657
|
}
|
|
5422
5658
|
_resolveScalingDecision({ group: e, text: t, constraintPadding: n, state: r, transform: i }) {
|
|
5423
|
-
let a = e.scaleX ?? 1, o = e.scaleY ?? 1, s = Math.abs(a) || 1, c = Math.abs(o) || 1, l = a < 0 || o < 0, u =
|
|
5659
|
+
let a = e.scaleX ?? 1, o = e.scaleY ?? 1, s = Math.abs(a) || 1, c = Math.abs(o) || 1, l = a < 0 || o < 0, u = Er({
|
|
5424
5660
|
state: r,
|
|
5425
5661
|
transform: i
|
|
5426
|
-
}), d =
|
|
5662
|
+
}), d = Dr({
|
|
5427
5663
|
state: r,
|
|
5428
5664
|
transform: i
|
|
5429
5665
|
});
|
|
@@ -5457,7 +5693,7 @@ var hr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY
|
|
|
5457
5693
|
};
|
|
5458
5694
|
}
|
|
5459
5695
|
_resolveScalingConstraintState({ group: t, text: n, constraintPadding: r, state: i, transform: a, scaleX: o, scaleY: s }) {
|
|
5460
|
-
let { startHeight: c, startWidth: l, cannotScaleDownAtStart: u, crossedOppositeCorner: d, isProportionalScaling: f, lastAllowedScaleX: p, lastAllowedScaleY: m, startScaleY: h } = i, g = Math.max(X, l * o), _ = Math.max(X, c * s), v = o < p - Z, y = s < m - Z, b = s < h - Z, { canScaleHeight: x, canScaleWidth: S, isVerticalOnlyScale: C } =
|
|
5696
|
+
let { startHeight: c, startWidth: l, cannotScaleDownAtStart: u, crossedOppositeCorner: d, isProportionalScaling: f, lastAllowedScaleX: p, lastAllowedScaleY: m, startScaleY: h } = i, g = Math.max(X, l * o), _ = Math.max(X, c * s), v = o < p - Z, y = s < m - Z, b = s < h - Z, { canScaleHeight: x, canScaleWidth: S, isVerticalOnlyScale: C } = Cr({ transform: a }), w = S && v ? Yn({
|
|
5461
5697
|
text: n,
|
|
5462
5698
|
padding: r,
|
|
5463
5699
|
resolvePaddingForWidth: ({ width: n }) => e._resolveScalingConstraintPadding({
|
|
@@ -5482,7 +5718,7 @@ var hr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY
|
|
|
5482
5718
|
};
|
|
5483
5719
|
}
|
|
5484
5720
|
_resolvePreviewDimensions({ group: t, text: n, constraintPadding: r, state: i, appliedScaleX: a, appliedScaleY: o, minimumHeight: s }) {
|
|
5485
|
-
let c = i.canScaleWidth ? Math.max(X, i.startWidth * a) : i.startWidth, l = i.canScaleHeight ? Math.max(X, i.startHeight * o) : i.startManualBaseHeight, u = s ??
|
|
5721
|
+
let c = i.canScaleWidth ? Math.max(X, i.startWidth * a) : i.startWidth, l = i.canScaleHeight ? Math.max(X, i.startHeight * o) : i.startManualBaseHeight, u = s ?? Zn({
|
|
5486
5722
|
text: n,
|
|
5487
5723
|
width: c,
|
|
5488
5724
|
height: l,
|
|
@@ -5500,7 +5736,7 @@ var hr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY
|
|
|
5500
5736
|
}
|
|
5501
5737
|
_resolvePreviewLayout({ group: t, text: n, state: r, appliedScaleX: i, appliedScaleY: a, minimumHeight: o }) {
|
|
5502
5738
|
let s = r.canScaleWidth ? Math.max(X, r.startWidth * i) : r.startWidth, c = r.canScaleHeight ? Math.max(X, r.startHeight * a) : r.startManualBaseHeight;
|
|
5503
|
-
return
|
|
5739
|
+
return Gn({
|
|
5504
5740
|
text: n,
|
|
5505
5741
|
width: s,
|
|
5506
5742
|
height: o == null ? c : Math.max(c, o),
|
|
@@ -5535,7 +5771,7 @@ var hr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY
|
|
|
5535
5771
|
if (!r) return !1;
|
|
5536
5772
|
let { transform: i } = e;
|
|
5537
5773
|
if (!i) return !1;
|
|
5538
|
-
let { canScaleWidth: a } =
|
|
5774
|
+
let { canScaleWidth: a } = Cr({ transform: i });
|
|
5539
5775
|
if (!a || !this._hasPointerReachedScaleOrigin({
|
|
5540
5776
|
event: e,
|
|
5541
5777
|
group: t,
|
|
@@ -5548,7 +5784,7 @@ var hr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY
|
|
|
5548
5784
|
if (!r) return !1;
|
|
5549
5785
|
let { transform: i } = e;
|
|
5550
5786
|
if (!i) return !1;
|
|
5551
|
-
let { canScaleHeight: a } =
|
|
5787
|
+
let { canScaleHeight: a } = Cr({ transform: i });
|
|
5552
5788
|
if (!a || !this._hasPointerReachedScaleOrigin({
|
|
5553
5789
|
event: e,
|
|
5554
5790
|
group: t,
|
|
@@ -5562,7 +5798,7 @@ var hr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY
|
|
|
5562
5798
|
if (!r) return !1;
|
|
5563
5799
|
let i = r, a = n === "x" ? i.signX : i.signY;
|
|
5564
5800
|
if (typeof a != "number" || !Number.isFinite(a)) return !1;
|
|
5565
|
-
let o =
|
|
5801
|
+
let o = wr({
|
|
5566
5802
|
event: e.e,
|
|
5567
5803
|
group: t,
|
|
5568
5804
|
transform: r,
|
|
@@ -5579,19 +5815,19 @@ var hr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY
|
|
|
5579
5815
|
let a = this._resolveScalingStartDimensions({
|
|
5580
5816
|
group: e,
|
|
5581
5817
|
transform: r
|
|
5582
|
-
}), o =
|
|
5818
|
+
}), o = br({
|
|
5583
5819
|
transform: r,
|
|
5584
5820
|
key: "scaleX"
|
|
5585
|
-
}), s =
|
|
5821
|
+
}), s = br({
|
|
5586
5822
|
transform: r,
|
|
5587
5823
|
key: "scaleY"
|
|
5588
|
-
}), c =
|
|
5824
|
+
}), c = br({
|
|
5589
5825
|
transform: r,
|
|
5590
5826
|
key: "left"
|
|
5591
|
-
}), l =
|
|
5827
|
+
}), l = br({
|
|
5592
5828
|
transform: r,
|
|
5593
5829
|
key: "top"
|
|
5594
|
-
}), u = Math.abs(o ?? e.scaleX ?? 1) || 1, d = Math.abs(s ?? e.scaleY ?? 1) || 1, f = c ?? e.left ?? 0, p = l ?? e.top ?? 0, m =
|
|
5830
|
+
}), u = Math.abs(o ?? e.scaleX ?? 1) || 1, d = Math.abs(s ?? e.scaleY ?? 1) || 1, f = c ?? e.left ?? 0, p = l ?? e.top ?? 0, m = xr({ value: r?.original?.originX ?? r?.originX }), h = Sr({ value: r?.original?.originY ?? r?.originY }), g = typeof r?.corner == "string" ? r.corner : null, _ = Tr({
|
|
5595
5831
|
group: e,
|
|
5596
5832
|
originX: m,
|
|
5597
5833
|
originY: h
|
|
@@ -5634,7 +5870,7 @@ var hr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY
|
|
|
5634
5870
|
return i;
|
|
5635
5871
|
}
|
|
5636
5872
|
_resolveMinimumTextFitHeight({ group: t, text: n, width: r, padding: i }) {
|
|
5637
|
-
return
|
|
5873
|
+
return Zn({
|
|
5638
5874
|
text: n,
|
|
5639
5875
|
width: r,
|
|
5640
5876
|
height: X,
|
|
@@ -5688,7 +5924,7 @@ var hr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY
|
|
|
5688
5924
|
width: u,
|
|
5689
5925
|
height: d
|
|
5690
5926
|
});
|
|
5691
|
-
|
|
5927
|
+
Kn({
|
|
5692
5928
|
group: t,
|
|
5693
5929
|
shape: n,
|
|
5694
5930
|
text: r,
|
|
@@ -5717,7 +5953,7 @@ var hr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY
|
|
|
5717
5953
|
}
|
|
5718
5954
|
_restoreGroupTransformOnly({ group: e, shape: t, text: n, state: r }) {
|
|
5719
5955
|
let i = Math.max(X, e.shapeBaseWidth ?? e.width ?? r.startWidth), a = Math.max(X, e.shapeBaseHeight ?? e.height ?? r.startHeight);
|
|
5720
|
-
t && (
|
|
5956
|
+
t && (hn({
|
|
5721
5957
|
shape: t,
|
|
5722
5958
|
width: i,
|
|
5723
5959
|
height: a,
|
|
@@ -5741,7 +5977,7 @@ var hr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY
|
|
|
5741
5977
|
});
|
|
5742
5978
|
}
|
|
5743
5979
|
_resolveScalingStartDimensions({ group: e, transform: t }) {
|
|
5744
|
-
let { canScaleWidth: n, canScaleHeight: r } =
|
|
5980
|
+
let { canScaleWidth: n, canScaleHeight: r } = Cr({ transform: t }), i = Math.max(X, e.shapeBaseWidth ?? e.width ?? e.shapeManualBaseWidth ?? X), a = Math.max(X, e.shapeBaseHeight ?? e.height ?? e.shapeManualBaseHeight ?? X);
|
|
5745
5981
|
return {
|
|
5746
5982
|
startWidth: i,
|
|
5747
5983
|
startHeight: a,
|
|
@@ -5760,7 +5996,7 @@ var hr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY
|
|
|
5760
5996
|
height: s
|
|
5761
5997
|
};
|
|
5762
5998
|
}
|
|
5763
|
-
},
|
|
5999
|
+
}, Pr = class {
|
|
5764
6000
|
constructor({ canvas: e }) {
|
|
5765
6001
|
this.handleMouseDown = (e) => {
|
|
5766
6002
|
let { target: t, e: n, subTargets: r = [] } = e, i = Ue({
|
|
@@ -5884,7 +6120,7 @@ var hr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY
|
|
|
5884
6120
|
let t = this.canvas;
|
|
5885
6121
|
t.findTarget = e.findTarget, this.editingTargetResolverState = void 0;
|
|
5886
6122
|
}
|
|
5887
|
-
},
|
|
6123
|
+
}, Fr = class e {
|
|
5888
6124
|
constructor({ canvas: e }) {
|
|
5889
6125
|
this.canvas = e, this.textEditingSnapshots = /* @__PURE__ */ new WeakMap(), this.pendingTextUpdates = /* @__PURE__ */ new WeakMap(), this.resizeStartSnapshots = /* @__PURE__ */ new Map(), this.pendingResizeUpdates = /* @__PURE__ */ new WeakMap();
|
|
5890
6126
|
}
|
|
@@ -6080,7 +6316,7 @@ var hr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY
|
|
|
6080
6316
|
}
|
|
6081
6317
|
}), I;
|
|
6082
6318
|
}
|
|
6083
|
-
},
|
|
6319
|
+
}, Ir = "#B4B7BD", Lr = 0, Rr = 1, zr = class {
|
|
6084
6320
|
constructor({ editor: e }) {
|
|
6085
6321
|
this._handleObjectScaling = (e) => {
|
|
6086
6322
|
let t = e.target && q(e.target) ? e.target : null;
|
|
@@ -6145,7 +6381,7 @@ var hr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY
|
|
|
6145
6381
|
if (!(t instanceof _)) return;
|
|
6146
6382
|
let n = t;
|
|
6147
6383
|
this.lifecycleController.finishTextUpdate({ textNode: n });
|
|
6148
|
-
}, this.editor = e, He(), this.scalingController = new
|
|
6384
|
+
}, this.editor = e, He(), this.scalingController = new Nr({ canvas: e.canvas }), this.editingController = new Pr({ canvas: e.canvas }), this.editingPlacements = /* @__PURE__ */ new WeakMap(), this.lifecycleController = new Fr({ canvas: e.canvas }), this.internalTextUpdates = /* @__PURE__ */ new WeakSet(), this._bindEvents();
|
|
6149
6385
|
}
|
|
6150
6386
|
async add({ presetKey: e = ce, options: t = {} } = {}) {
|
|
6151
6387
|
let n = pe({ presetKey: e });
|
|
@@ -6243,7 +6479,7 @@ var hr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY
|
|
|
6243
6479
|
addition: k
|
|
6244
6480
|
})
|
|
6245
6481
|
}));
|
|
6246
|
-
let I = await
|
|
6482
|
+
let I = await On({
|
|
6247
6483
|
preset: m,
|
|
6248
6484
|
width: F,
|
|
6249
6485
|
height: x,
|
|
@@ -6373,7 +6609,7 @@ var hr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY
|
|
|
6373
6609
|
let be = U({
|
|
6374
6610
|
width: _e,
|
|
6375
6611
|
height: ye
|
|
6376
|
-
}), xe = await
|
|
6612
|
+
}), xe = await On({
|
|
6377
6613
|
preset: A,
|
|
6378
6614
|
width: _e,
|
|
6379
6615
|
height: ye,
|
|
@@ -6473,7 +6709,7 @@ var hr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY
|
|
|
6473
6709
|
});
|
|
6474
6710
|
this._beginMutation();
|
|
6475
6711
|
try {
|
|
6476
|
-
|
|
6712
|
+
gn({
|
|
6477
6713
|
shape: i,
|
|
6478
6714
|
style: { fill: t }
|
|
6479
6715
|
}), r.shapeFill = t, r.setCoords(), this.lifecycleController.fireBefore({ lifecycle: a }), this.editor.canvas.requestRenderAll();
|
|
@@ -6495,7 +6731,7 @@ var hr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY
|
|
|
6495
6731
|
});
|
|
6496
6732
|
this._beginMutation();
|
|
6497
6733
|
try {
|
|
6498
|
-
if (
|
|
6734
|
+
if (gn({
|
|
6499
6735
|
shape: o,
|
|
6500
6736
|
style: {
|
|
6501
6737
|
stroke: t,
|
|
@@ -6531,7 +6767,7 @@ var hr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY
|
|
|
6531
6767
|
});
|
|
6532
6768
|
this._beginMutation();
|
|
6533
6769
|
try {
|
|
6534
|
-
|
|
6770
|
+
gn({
|
|
6535
6771
|
shape: a,
|
|
6536
6772
|
style: { opacity: t }
|
|
6537
6773
|
}), n && o && (o.set({ opacity: t }), o.setCoords()), i.shapeOpacity = t, i.setCoords(), this.lifecycleController.fireBefore({ lifecycle: s }), this.editor.canvas.requestRenderAll();
|
|
@@ -6625,6 +6861,37 @@ var hr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY
|
|
|
6625
6861
|
}
|
|
6626
6862
|
});
|
|
6627
6863
|
}
|
|
6864
|
+
commitRehydratedShapeLayout({ target: e, textScale: t = 1 }) {
|
|
6865
|
+
let n = this._resolveShapeGroup({ target: e });
|
|
6866
|
+
if (!n) return !1;
|
|
6867
|
+
let { shape: r, text: i } = Ke({ group: n });
|
|
6868
|
+
if (!r || !i) return !1;
|
|
6869
|
+
let a = this.editor.canvasManager.getObjectPlacement({ object: n }), { shapeAlignHorizontal: o = le, shapeAlignVertical: s = ue, shapeBaseWidth: c, shapeBaseHeight: l, shapeManualBaseWidth: u, shapeManualBaseHeight: d, shapeReplaceBoxWidth: f, shapeReplaceBoxHeight: p, shapePaddingTop: m = 0, shapePaddingRight: h = 0, shapePaddingBottom: g = 0, shapePaddingLeft: _ = 0, width: v, height: y } = n, b = Math.abs(n.scaleX ?? 1) || 1, x = Math.abs(n.scaleY ?? 1) || 1, S = Number.isFinite(t) && t > 0 ? t : 1, C = Math.max(1, c ?? v ?? 1), w = Math.max(1, l ?? y ?? 1), T = {
|
|
6870
|
+
width: Math.max(1, C * b),
|
|
6871
|
+
height: Math.max(1, w * x)
|
|
6872
|
+
}, E = {
|
|
6873
|
+
width: Math.max(1, (u ?? C) * b),
|
|
6874
|
+
height: Math.max(1, (d ?? w) * x)
|
|
6875
|
+
}, D = {
|
|
6876
|
+
width: Math.max(1, (f ?? C) * b),
|
|
6877
|
+
height: Math.max(1, (p ?? w) * x)
|
|
6878
|
+
};
|
|
6879
|
+
return Math.abs(S - 1) > 1e-4 && (ln({
|
|
6880
|
+
textbox: i,
|
|
6881
|
+
base: sn({ textbox: i }),
|
|
6882
|
+
scale: S
|
|
6883
|
+
}), n.shapePaddingTop = Math.max(0, m * S), n.shapePaddingRight = Math.max(0, h * S), n.shapePaddingBottom = Math.max(0, g * S), n.shapePaddingLeft = Math.max(0, _ * S)), this._detachShapeGroupAutoLayout({ group: n }), n.shapeManualBaseWidth = E.width, n.shapeManualBaseHeight = E.height, this._applyCurrentLayout({
|
|
6884
|
+
group: n,
|
|
6885
|
+
shape: r,
|
|
6886
|
+
text: i,
|
|
6887
|
+
placement: a,
|
|
6888
|
+
width: T.width,
|
|
6889
|
+
height: T.height,
|
|
6890
|
+
alignH: o,
|
|
6891
|
+
alignV: s,
|
|
6892
|
+
minimumReplaceBox: D
|
|
6893
|
+
}), !0;
|
|
6894
|
+
}
|
|
6628
6895
|
destroy() {
|
|
6629
6896
|
let { canvas: e } = this.editor;
|
|
6630
6897
|
e.off("object:scaling", this._handleObjectScaling), e.off("object:modified", this._handleObjectModified), e.off("mouse:move", this._handleMouseMove), e.off("mouse:down", this._handleMouseDown), e.off("mouse:up", this._handleMouseUp), e.off("text:editing:entered", this._handleTextEditingEntered), e.off("text:editing:exited", this._handleTextEditingExited), e.off("text:changed", this._handleTextChanged), e.off("editor:before:text-updated", this._handleBeforeTextUpdated), e.off("editor:text-updated", this._handleTextUpdated);
|
|
@@ -6657,7 +6924,7 @@ var hr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY
|
|
|
6657
6924
|
padding: h,
|
|
6658
6925
|
style: y,
|
|
6659
6926
|
rounding: b
|
|
6660
|
-
}), x.rehydrateRuntimeState(), qe({ group: x }), ke({ text: i }),
|
|
6927
|
+
}), x.rehydrateRuntimeState(), qe({ group: x }), ke({ text: i }), Kn({
|
|
6661
6928
|
group: x,
|
|
6662
6929
|
shape: r,
|
|
6663
6930
|
text: i,
|
|
@@ -6832,7 +7099,7 @@ var hr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY
|
|
|
6832
7099
|
}
|
|
6833
7100
|
_resolveAutoExpandShapeWidth({ text: e, currentWidth: t, minimumWidth: n, padding: r, resolvePaddingForWidth: i }) {
|
|
6834
7101
|
let a = this._resolveMontageAreaWidth();
|
|
6835
|
-
return a ?
|
|
7102
|
+
return a ? Jn({
|
|
6836
7103
|
text: e,
|
|
6837
7104
|
currentWidth: t,
|
|
6838
7105
|
minimumWidth: n,
|
|
@@ -6888,7 +7155,7 @@ var hr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY
|
|
|
6888
7155
|
width: y,
|
|
6889
7156
|
height: b
|
|
6890
7157
|
}), S = r ?? this.editor.canvasManager.getObjectPlacement({ object: e }), C = u ? this._resolveMontageAreaWidth() : void 0;
|
|
6891
|
-
|
|
7158
|
+
Kn({
|
|
6892
7159
|
group: e,
|
|
6893
7160
|
shape: t,
|
|
6894
7161
|
text: n,
|
|
@@ -6951,11 +7218,11 @@ var hr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY
|
|
|
6951
7218
|
_resolveShapeStyle({ options: e, fallback: t }) {
|
|
6952
7219
|
let { fill: n, stroke: r, strokeWidth: i, strokeDashArray: a, opacity: o } = e, s = a === void 0 ? t?.shapeStrokeDashArray : a;
|
|
6953
7220
|
return {
|
|
6954
|
-
fill: n ?? t?.shapeFill ??
|
|
7221
|
+
fill: n ?? t?.shapeFill ?? Ir,
|
|
6955
7222
|
stroke: r ?? t?.shapeStroke ?? null,
|
|
6956
|
-
strokeWidth: i ?? t?.shapeStrokeWidth ??
|
|
7223
|
+
strokeWidth: i ?? t?.shapeStrokeWidth ?? Lr,
|
|
6957
7224
|
strokeDashArray: s ?? null,
|
|
6958
|
-
opacity: o ?? t?.shapeOpacity ??
|
|
7225
|
+
opacity: o ?? t?.shapeOpacity ?? Rr
|
|
6959
7226
|
};
|
|
6960
7227
|
}
|
|
6961
7228
|
_collectShapeGroupsFromTarget({ target: t, subTargets: n = [] }) {
|
|
@@ -7011,7 +7278,7 @@ var hr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY
|
|
|
7011
7278
|
}
|
|
7012
7279
|
return null;
|
|
7013
7280
|
}
|
|
7014
|
-
},
|
|
7281
|
+
}, Br = class {
|
|
7015
7282
|
constructor({ editor: e }) {
|
|
7016
7283
|
this.editor = e, this.clipboard = null;
|
|
7017
7284
|
}
|
|
@@ -7031,7 +7298,7 @@ var hr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY
|
|
|
7031
7298
|
let { canvas: t, errorManager: n } = this.editor;
|
|
7032
7299
|
try {
|
|
7033
7300
|
let n = await e.clone(kt);
|
|
7034
|
-
this.
|
|
7301
|
+
this._materializeCloneGeometry({ clonedObject: n }), this.clipboard = n, t.fire("editor:object-copied", { object: n });
|
|
7035
7302
|
} catch (e) {
|
|
7036
7303
|
n.emitError({
|
|
7037
7304
|
origin: "ClipboardManager",
|
|
@@ -7104,17 +7371,25 @@ var hr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY
|
|
|
7104
7371
|
}
|
|
7105
7372
|
n.add(t), n.setActiveObject(t), n.requestRenderAll();
|
|
7106
7373
|
}
|
|
7107
|
-
|
|
7108
|
-
let {
|
|
7109
|
-
if (
|
|
7110
|
-
|
|
7111
|
-
|
|
7112
|
-
|
|
7113
|
-
|
|
7114
|
-
return;
|
|
7115
|
-
}
|
|
7116
|
-
n.commitStandaloneTextScale({ target: t });
|
|
7374
|
+
_materializeCloneGeometry({ clonedObject: t }) {
|
|
7375
|
+
let { shapeManager: n, textManager: r } = this.editor;
|
|
7376
|
+
if (t instanceof e) {
|
|
7377
|
+
t.forEachObject((e) => {
|
|
7378
|
+
r.commitStandaloneTextScale({ target: e }), n.commitRehydratedShapeLayout({ target: e });
|
|
7379
|
+
}), t.setCoords();
|
|
7380
|
+
return;
|
|
7117
7381
|
}
|
|
7382
|
+
r.commitStandaloneTextScale({ target: t }), n.commitRehydratedShapeLayout({ target: t });
|
|
7383
|
+
}
|
|
7384
|
+
_materializeCloneIdentity({ clonedObject: t, enableEvented: n = !0 }) {
|
|
7385
|
+
t.set({ id: `${t.type}-${D()}` }), n && t.set({ evented: !0 });
|
|
7386
|
+
let r = t instanceof e;
|
|
7387
|
+
(r || t instanceof l) && t.getObjects().forEach((e) => {
|
|
7388
|
+
this._materializeCloneIdentity({
|
|
7389
|
+
clonedObject: e,
|
|
7390
|
+
enableEvented: r
|
|
7391
|
+
});
|
|
7392
|
+
});
|
|
7118
7393
|
}
|
|
7119
7394
|
async _handleImageImport(e) {
|
|
7120
7395
|
let { canvas: t, errorManager: n } = this.editor, r = !1, i = !1, a = null, o = null, s = new Promise((e, t) => {
|
|
@@ -7162,24 +7437,17 @@ var hr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY
|
|
|
7162
7437
|
object: i
|
|
7163
7438
|
});
|
|
7164
7439
|
}
|
|
7165
|
-
async copyPaste(
|
|
7166
|
-
let { canvas:
|
|
7167
|
-
if (!
|
|
7440
|
+
async copyPaste(e) {
|
|
7441
|
+
let { canvas: t } = this.editor, n = e || t.getActiveObject();
|
|
7442
|
+
if (!n || n.locked) return !1;
|
|
7168
7443
|
try {
|
|
7169
|
-
let
|
|
7170
|
-
return
|
|
7171
|
-
e.
|
|
7172
|
-
|
|
7173
|
-
|
|
7174
|
-
|
|
7175
|
-
|
|
7176
|
-
id: `${t.type}-${D()}`,
|
|
7177
|
-
left: t.left + 10,
|
|
7178
|
-
top: t.top + 10,
|
|
7179
|
-
evented: !0
|
|
7180
|
-
}), this._rehydrateStandaloneTextOnClone({ clonedObject: t }), this._addClonedObjectToCanvas(t), n.fire("editor:object-duplicated", {
|
|
7181
|
-
targetObject: r,
|
|
7182
|
-
clonedObject: t
|
|
7444
|
+
let e = await n.clone(kt);
|
|
7445
|
+
return this._materializeCloneIdentity({ clonedObject: e }), e.set({
|
|
7446
|
+
left: e.left + 10,
|
|
7447
|
+
top: e.top + 10
|
|
7448
|
+
}), this._materializeCloneGeometry({ clonedObject: e }), this._addClonedObjectToCanvas(e), t.fire("editor:object-duplicated", {
|
|
7449
|
+
targetObject: n,
|
|
7450
|
+
clonedObject: e
|
|
7183
7451
|
}), !0;
|
|
7184
7452
|
} catch (e) {
|
|
7185
7453
|
let { errorManager: t } = this.editor;
|
|
@@ -7237,24 +7505,17 @@ var hr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY
|
|
|
7237
7505
|
this.paste();
|
|
7238
7506
|
}
|
|
7239
7507
|
async paste() {
|
|
7240
|
-
let { canvas:
|
|
7508
|
+
let { canvas: e } = this.editor;
|
|
7241
7509
|
if (!this.clipboard) return !1;
|
|
7242
7510
|
try {
|
|
7243
|
-
let
|
|
7244
|
-
return
|
|
7245
|
-
|
|
7246
|
-
|
|
7247
|
-
|
|
7248
|
-
});
|
|
7249
|
-
}), n.set({
|
|
7250
|
-
id: `${n.type}-${D()}`,
|
|
7251
|
-
left: n.left + 10,
|
|
7252
|
-
top: n.top + 10,
|
|
7253
|
-
evented: !0
|
|
7254
|
-
}), this._rehydrateStandaloneTextOnClone({ clonedObject: n }), this._addClonedObjectToCanvas(n), t.fire("editor:object-pasted", {
|
|
7511
|
+
let t = await this.clipboard.clone(kt);
|
|
7512
|
+
return e.discardActiveObject(), this._materializeCloneIdentity({ clonedObject: t }), t.set({
|
|
7513
|
+
left: t.left + 10,
|
|
7514
|
+
top: t.top + 10
|
|
7515
|
+
}), this._materializeCloneGeometry({ clonedObject: t }), this._addClonedObjectToCanvas(t), e.fire("editor:object-pasted", {
|
|
7255
7516
|
fromInternalClipboard: !0,
|
|
7256
7517
|
clipboardObject: this.clipboard,
|
|
7257
|
-
object:
|
|
7518
|
+
object: t
|
|
7258
7519
|
}), !0;
|
|
7259
7520
|
} catch (e) {
|
|
7260
7521
|
let { errorManager: t } = this.editor;
|
|
@@ -7267,7 +7528,7 @@ var hr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY
|
|
|
7267
7528
|
}), !1;
|
|
7268
7529
|
}
|
|
7269
7530
|
}
|
|
7270
|
-
},
|
|
7531
|
+
}, Vr = class t {
|
|
7271
7532
|
constructor({ editor: e }) {
|
|
7272
7533
|
this.editor = e;
|
|
7273
7534
|
}
|
|
@@ -7332,7 +7593,7 @@ var hr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY
|
|
|
7332
7593
|
!(n instanceof _) || !n.isEditing || n.exitEditing();
|
|
7333
7594
|
}
|
|
7334
7595
|
}
|
|
7335
|
-
},
|
|
7596
|
+
}, Hr = class {
|
|
7336
7597
|
constructor({ editor: e }) {
|
|
7337
7598
|
this.editor = e;
|
|
7338
7599
|
}
|
|
@@ -7398,7 +7659,7 @@ var hr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY
|
|
|
7398
7659
|
i.resumeHistory(), n || i.saveState();
|
|
7399
7660
|
}
|
|
7400
7661
|
}
|
|
7401
|
-
},
|
|
7662
|
+
}, Ur = class t {
|
|
7402
7663
|
constructor({ editor: e }) {
|
|
7403
7664
|
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();
|
|
7404
7665
|
}
|
|
@@ -7592,7 +7853,7 @@ var hr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY
|
|
|
7592
7853
|
let { options: e } = this.editor, { selectionKey: t } = e;
|
|
7593
7854
|
return t === void 0 ? ["ctrlKey", "metaKey"] : t;
|
|
7594
7855
|
}
|
|
7595
|
-
},
|
|
7856
|
+
}, Wr = class e {
|
|
7596
7857
|
constructor({ editor: e }) {
|
|
7597
7858
|
this.editor = e;
|
|
7598
7859
|
}
|
|
@@ -7632,7 +7893,7 @@ var hr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY
|
|
|
7632
7893
|
};
|
|
7633
7894
|
return i.fire("editor:objects-deleted", l), l;
|
|
7634
7895
|
}
|
|
7635
|
-
},
|
|
7896
|
+
}, Gr = {
|
|
7636
7897
|
IMAGE_MANAGER: {
|
|
7637
7898
|
INVALID_CONTENT_TYPE: "INVALID_CONTENT_TYPE",
|
|
7638
7899
|
INVALID_SOURCE_TYPE: "INVALID_SOURCE_TYPE",
|
|
@@ -7670,7 +7931,7 @@ var hr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY
|
|
|
7670
7931
|
INVALID_TARGET: "TEMPLATE_INVALID_TARGET",
|
|
7671
7932
|
APPLY_FAILED: "TEMPLATE_APPLY_FAILED"
|
|
7672
7933
|
}
|
|
7673
|
-
},
|
|
7934
|
+
}, Kr = class e {
|
|
7674
7935
|
constructor({ editor: e }) {
|
|
7675
7936
|
this._buffer = [], this.editor = e;
|
|
7676
7937
|
}
|
|
@@ -7728,9 +7989,9 @@ var hr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY
|
|
|
7728
7989
|
}), this.editor.canvas.fire("editor:warning", s);
|
|
7729
7990
|
}
|
|
7730
7991
|
static isValidErrorCode(e) {
|
|
7731
|
-
return e ? Object.values(
|
|
7992
|
+
return e ? Object.values(Gr).some((t) => Object.values(t).includes(e)) : !1;
|
|
7732
7993
|
}
|
|
7733
|
-
},
|
|
7994
|
+
}, qr = class {
|
|
7734
7995
|
constructor({ editor: e }) {
|
|
7735
7996
|
this.currentBounds = null, this.editor = e;
|
|
7736
7997
|
}
|
|
@@ -7779,32 +8040,32 @@ var hr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY
|
|
|
7779
8040
|
updateBounds() {
|
|
7780
8041
|
this.currentBounds = this.calculatePanBounds();
|
|
7781
8042
|
}
|
|
7782
|
-
},
|
|
8043
|
+
}, Jr = ({ textbox: e }) => {
|
|
7783
8044
|
if (!e.isEditing) return null;
|
|
7784
8045
|
let t = e.selectionStart ?? 0, n = e.selectionEnd ?? t;
|
|
7785
8046
|
return t === n ? null : {
|
|
7786
8047
|
start: Math.min(t, n),
|
|
7787
8048
|
end: Math.max(t, n)
|
|
7788
8049
|
};
|
|
7789
|
-
},
|
|
8050
|
+
}, Yr = ({ textbox: e }) => {
|
|
7790
8051
|
let t = e.text?.length ?? 0;
|
|
7791
8052
|
return t <= 0 ? null : {
|
|
7792
8053
|
start: 0,
|
|
7793
8054
|
end: t
|
|
7794
8055
|
};
|
|
7795
|
-
},
|
|
8056
|
+
}, Xr = ({ textbox: e, range: t }) => {
|
|
7796
8057
|
if (!t) return !1;
|
|
7797
8058
|
let n = e.text?.length ?? 0;
|
|
7798
8059
|
return n <= 0 ? !1 : t.start <= 0 && t.end >= n;
|
|
7799
|
-
},
|
|
8060
|
+
}, Zr = ({ textbox: e, styles: t, range: n }) => {
|
|
7800
8061
|
if (!t || !Object.keys(t).length) return !1;
|
|
7801
8062
|
let { start: r, end: i } = n;
|
|
7802
8063
|
return i <= r ? !1 : (e.setSelectionStyles(t, r, i), !0);
|
|
7803
|
-
},
|
|
8064
|
+
}, Qr = ({ textbox: e, range: t, property: n }) => {
|
|
7804
8065
|
if (!t) return;
|
|
7805
8066
|
let r = e.getSelectionStyles(t.start, t.end, !0);
|
|
7806
8067
|
if (r.length) return r[0]?.[n];
|
|
7807
|
-
},
|
|
8068
|
+
}, $r = ({ strokeColor: e, width: t }) => t <= 0 ? null : e ?? "#000000", ei = ({ width: e = 0 }) => e ? Math.max(0, e) : 0, ti = ({ value: e }) => typeof e == "string" ? e.toLocaleUpperCase() : "", ni = ({ value: e, min: t, max: n }) => Math.min(Math.max(e, t), n), ri = class e extends _ {
|
|
7808
8069
|
static {
|
|
7809
8070
|
this.type = "background-textbox";
|
|
7810
8071
|
}
|
|
@@ -7938,7 +8199,7 @@ var hr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY
|
|
|
7938
8199
|
this._removeShadow(e);
|
|
7939
8200
|
}
|
|
7940
8201
|
_getDecorationColorAt(e, t) {
|
|
7941
|
-
let n = this.getValueOfPropertyAt(e, t, "strokeWidth"), r =
|
|
8202
|
+
let n = this.getValueOfPropertyAt(e, t, "strokeWidth"), r = ei({ width: typeof n == "number" && Number.isFinite(n) ? n : 0 }), i = this.getValueOfPropertyAt(e, t, "stroke"), a = i == null ? null : $r({
|
|
7942
8203
|
strokeColor: i,
|
|
7943
8204
|
width: r
|
|
7944
8205
|
});
|
|
@@ -7954,22 +8215,22 @@ var hr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY
|
|
|
7954
8215
|
_getCornerRadii({ width: e, height: t }) {
|
|
7955
8216
|
let n = e / 2, r = t / 2, i = Math.min(n, r);
|
|
7956
8217
|
return {
|
|
7957
|
-
bottomLeft:
|
|
8218
|
+
bottomLeft: ni({
|
|
7958
8219
|
value: this.radiusBottomLeft ?? 0,
|
|
7959
8220
|
min: 0,
|
|
7960
8221
|
max: i
|
|
7961
8222
|
}),
|
|
7962
|
-
bottomRight:
|
|
8223
|
+
bottomRight: ni({
|
|
7963
8224
|
value: this.radiusBottomRight ?? 0,
|
|
7964
8225
|
min: 0,
|
|
7965
8226
|
max: i
|
|
7966
8227
|
}),
|
|
7967
|
-
topLeft:
|
|
8228
|
+
topLeft: ni({
|
|
7968
8229
|
value: this.radiusTopLeft ?? 0,
|
|
7969
8230
|
min: 0,
|
|
7970
8231
|
max: i
|
|
7971
8232
|
}),
|
|
7972
|
-
topRight:
|
|
8233
|
+
topRight: ni({
|
|
7973
8234
|
value: this.radiusTopRight ?? 0,
|
|
7974
8235
|
min: 0,
|
|
7975
8236
|
max: i
|
|
@@ -7987,7 +8248,7 @@ var hr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY
|
|
|
7987
8248
|
_getEffectiveBackgroundFill() {
|
|
7988
8249
|
let e = this.backgroundColor;
|
|
7989
8250
|
if (!e) return null;
|
|
7990
|
-
let t =
|
|
8251
|
+
let t = ni({
|
|
7991
8252
|
value: this.backgroundOpacity ?? 1,
|
|
7992
8253
|
min: 0,
|
|
7993
8254
|
max: 1
|
|
@@ -7995,7 +8256,7 @@ var hr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY
|
|
|
7995
8256
|
try {
|
|
7996
8257
|
r = new n(e);
|
|
7997
8258
|
} catch (t) {
|
|
7998
|
-
return
|
|
8259
|
+
return Kr.emitError({
|
|
7999
8260
|
origin: "BackgroundTextbox",
|
|
8000
8261
|
method: "_getEffectiveBackgroundFill",
|
|
8001
8262
|
code: "INVALID_COLOR_VALUE",
|
|
@@ -8009,19 +8270,19 @@ var hr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY
|
|
|
8009
8270
|
return r.setAlpha(t), r.toRgba();
|
|
8010
8271
|
}
|
|
8011
8272
|
static _renderRoundedRect({ ctx: e, height: t, left: n, radii: r, top: i, width: a }) {
|
|
8012
|
-
let o = n + a, s = i + t, { topLeft: c, topRight: l, bottomRight: u, bottomLeft: d } = r, f =
|
|
8273
|
+
let o = n + a, s = i + t, { topLeft: c, topRight: l, bottomRight: u, bottomLeft: d } = r, f = ni({
|
|
8013
8274
|
value: c,
|
|
8014
8275
|
min: 0,
|
|
8015
8276
|
max: a
|
|
8016
|
-
}), p =
|
|
8277
|
+
}), p = ni({
|
|
8017
8278
|
value: l,
|
|
8018
8279
|
min: 0,
|
|
8019
8280
|
max: a
|
|
8020
|
-
}), m =
|
|
8281
|
+
}), m = ni({
|
|
8021
8282
|
value: u,
|
|
8022
8283
|
min: 0,
|
|
8023
8284
|
max: a
|
|
8024
|
-
}), h =
|
|
8285
|
+
}), h = ni({
|
|
8025
8286
|
value: d,
|
|
8026
8287
|
min: 0,
|
|
8027
8288
|
max: a
|
|
@@ -8032,244 +8293,20 @@ var hr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY
|
|
|
8032
8293
|
let { width: e = 0, height: t = 0 } = this, n = Math.round(e), r = Math.round(t);
|
|
8033
8294
|
n !== e && (this.width = Math.max(0, n)), r !== t && (this.height = Math.max(0, r));
|
|
8034
8295
|
}
|
|
8035
|
-
},
|
|
8036
|
-
y?.setClass && y.setClass(
|
|
8037
|
-
},
|
|
8038
|
-
if (!t.length) return !1;
|
|
8039
|
-
let { fontFamily: r, fontSize: i, fill: a, stroke: o } = n;
|
|
8040
|
-
if (!(r !== void 0 || i !== void 0 || a !== void 0 || o !== void 0)) return !1;
|
|
8041
|
-
let { lineFontDefaults: s } = e, c = s ?? {}, l = !1, u = !1;
|
|
8042
|
-
for (let e = 0; e < t.length; e += 1) {
|
|
8043
|
-
let n = t[e];
|
|
8044
|
-
if (!Number.isFinite(n)) continue;
|
|
8045
|
-
let d = u ? c[n] : s?.[n], f = d ? { ...d } : {}, p = !1;
|
|
8046
|
-
r !== void 0 && d?.fontFamily !== r && (f.fontFamily = r, p = !0), i !== void 0 && d?.fontSize !== i && (f.fontSize = i, p = !0), a !== void 0 && d?.fill !== a && (f.fill = a, p = !0), o !== void 0 && (o === null && d?.stroke !== void 0 && (delete f.stroke, p = !0), o !== null && d?.stroke !== o && (f.stroke = o, p = !0)), p && (u ||= (c = { ...c }, !0), c[n] = f, l = !0);
|
|
8047
|
-
}
|
|
8048
|
-
return l && (e.lineFontDefaults = c), l;
|
|
8049
|
-
}, Gr = ({ lineText: e, lineStyles: t, lineDefaults: n }) => {
|
|
8050
|
-
let r = e.length;
|
|
8051
|
-
if (r === 0) return {
|
|
8052
|
-
lineStyles: t,
|
|
8053
|
-
changed: !1
|
|
8054
|
-
};
|
|
8055
|
-
let { fontFamily: i, fontSize: a, fill: o, stroke: s } = n;
|
|
8056
|
-
if (!(i !== void 0 || a !== void 0 || o !== void 0 || s !== void 0)) return {
|
|
8057
|
-
lineStyles: t,
|
|
8058
|
-
changed: !1
|
|
8059
|
-
};
|
|
8060
|
-
let c = {};
|
|
8061
|
-
i !== void 0 && (c.fontFamily = i), a !== void 0 && (c.fontSize = a), o !== void 0 && (c.fill = o), s !== void 0 && (c.stroke = s);
|
|
8062
|
-
let l = t, u = !1, d = !1;
|
|
8063
|
-
if (t) for (let e in t) {
|
|
8064
|
-
if (!Object.prototype.hasOwnProperty.call(t, e)) continue;
|
|
8065
|
-
let n = Number(e);
|
|
8066
|
-
Number.isInteger(n) && n >= 0 && n < r || (d ||= (l = { ...t }, !0), l && Object.prototype.hasOwnProperty.call(l, e) && delete l[e], u = !0);
|
|
8067
|
-
}
|
|
8068
|
-
for (let e = 0; e < r; e += 1) {
|
|
8069
|
-
let n = l ?? t, r = n ? n[e] : void 0;
|
|
8070
|
-
if (!r) {
|
|
8071
|
-
l || (l = {}, d = !0), d ||= (l = { ...l }, !0), l[e] = { ...c }, u = !0;
|
|
8072
|
-
continue;
|
|
8073
|
-
}
|
|
8074
|
-
let f = null;
|
|
8075
|
-
i !== void 0 && r.fontFamily === void 0 && (f = { ...r }, f.fontFamily = i), a !== void 0 && r.fontSize === void 0 && (f ||= { ...r }, f.fontSize = a), o !== void 0 && r.fill === void 0 && (f ||= { ...r }, f.fill = o), s !== void 0 && r.stroke === void 0 && (f ||= { ...r }, f.stroke = s), f && (l || (l = {}, d = !0), d ||= (l = { ...l }, !0), l[e] = f, u = !0);
|
|
8076
|
-
}
|
|
8077
|
-
return {
|
|
8078
|
-
lineStyles: l,
|
|
8079
|
-
changed: u
|
|
8080
|
-
};
|
|
8081
|
-
}, Kr = ({ lineFontDefaults: e }) => {
|
|
8082
|
-
if (!e) return;
|
|
8083
|
-
let t = {};
|
|
8084
|
-
for (let n in e) {
|
|
8085
|
-
if (!Object.prototype.hasOwnProperty.call(e, n)) continue;
|
|
8086
|
-
let r = Number(n);
|
|
8087
|
-
if (!Number.isFinite(r)) continue;
|
|
8088
|
-
let i = e[r];
|
|
8089
|
-
i && (t[r] = { ...i });
|
|
8090
|
-
}
|
|
8091
|
-
return t;
|
|
8092
|
-
}, qr = ({ lineFontDefaults: e, scale: t }) => {
|
|
8093
|
-
if (!e || !Number.isFinite(t) || Math.abs(t - 1) < .01) return;
|
|
8094
|
-
let n = {}, r = !1, i = !1;
|
|
8095
|
-
for (let a in e) {
|
|
8096
|
-
if (!Object.prototype.hasOwnProperty.call(e, a)) continue;
|
|
8097
|
-
let o = Number(a);
|
|
8098
|
-
if (!Number.isFinite(o)) continue;
|
|
8099
|
-
let s = e[o];
|
|
8100
|
-
if (!s) continue;
|
|
8101
|
-
let c = { ...s };
|
|
8102
|
-
if (typeof s.fontSize == "number") {
|
|
8103
|
-
let e = Math.min(8, s.fontSize);
|
|
8104
|
-
c.fontSize = Math.max(e, s.fontSize * t), i = !0;
|
|
8105
|
-
}
|
|
8106
|
-
n[o] = c, r = !0;
|
|
8107
|
-
}
|
|
8108
|
-
if (!(!r || !i)) return n;
|
|
8109
|
-
}, Jr = ({ textbox: e, text: t }) => {
|
|
8110
|
-
let { textLines: n } = e, r = Array.isArray(n) && n.length > 0 ? n.length : Math.max(t.split("\n").length, 1), i = 0;
|
|
8111
|
-
for (let t = 0; t < r; t += 1) {
|
|
8112
|
-
let n = e.getLineWidth(t);
|
|
8113
|
-
n > i && (i = n);
|
|
8114
|
-
}
|
|
8115
|
-
return i;
|
|
8116
|
-
}, Yr = ({ origin: e, size: t }) => e === "left" || e === "top" || e === "start" || e === 0 ? 0 : e === "right" || e === "bottom" || e === "end" || e === 1 ? t : t / 2, Xr = ({ textbox: e, originX: t = e.originX ?? "center", originY: n = e.originY ?? "center" }) => {
|
|
8117
|
-
let r = e.width ?? e.calcTextWidth() ?? 0, i = e.height ?? e.calcTextHeight() ?? 0, a = e.paddingTop ?? 0, o = e.paddingRight ?? 0, s = e.paddingBottom ?? 0, c = e.paddingLeft ?? 0, l = -r / 2 + (c - o) / 2, u = -i / 2 + (a - s) / 2, d = new p(l + Yr({
|
|
8118
|
-
origin: t,
|
|
8119
|
-
size: r
|
|
8120
|
-
}), u + Yr({
|
|
8121
|
-
origin: n,
|
|
8122
|
-
size: i
|
|
8123
|
-
})), f = e.getPointByOrigin("center", "center"), m = e, h = typeof m.calcTransformMatrix == "function" ? m.calcTransformMatrix() : null, g = Array.isArray(h) ? new p(d.x * h[0] + d.y * h[2] + f.x, d.x * h[1] + d.y * h[3] + f.y) : new p(f.x + d.x, f.y + d.y);
|
|
8124
|
-
return {
|
|
8125
|
-
left: g.x,
|
|
8126
|
-
top: g.y,
|
|
8127
|
-
originX: t,
|
|
8128
|
-
originY: n
|
|
8129
|
-
};
|
|
8130
|
-
}, Zr = ({ textbox: e, montageLeft: t, montageRight: n }) => {
|
|
8131
|
-
e.setCoords();
|
|
8132
|
-
let r = e.getBoundingRect(!1, !0), i = r.left ?? 0, a = i + (r.width ?? 0), o = n - t;
|
|
8133
|
-
if (o > 0 && (r.width ?? 0) >= o - .01) return !1;
|
|
8134
|
-
let s = 0;
|
|
8135
|
-
return i < t ? s = t - i : a > n && (s = n - a), Math.abs(s) <= .01 ? !1 : (e.set({ left: (e.left ?? 0) + s }), !0);
|
|
8136
|
-
}, Qr = ({ rawValue: e, calculatedValue: t }) => typeof e == "number" ? e : typeof t == "number" ? t : 0, $r = ({ stylesList: e }) => {
|
|
8137
|
-
let t = e.length;
|
|
8138
|
-
if (!t) return !1;
|
|
8139
|
-
for (let n = 0; n < t; n += 1) {
|
|
8140
|
-
let t = e[n];
|
|
8141
|
-
if (!t) continue;
|
|
8142
|
-
let { fontFamily: r, fontSize: i, fontWeight: a, fontStyle: o, lineHeight: s, charSpacing: c } = t;
|
|
8143
|
-
if (r !== void 0 || i !== void 0 || a !== void 0 || o !== void 0 || s !== void 0 || c !== void 0) return !0;
|
|
8144
|
-
}
|
|
8145
|
-
return !1;
|
|
8146
|
-
}, ei = ({ textbox: e }) => {
|
|
8147
|
-
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 = Qr({
|
|
8148
|
-
rawValue: t,
|
|
8149
|
-
calculatedValue: a
|
|
8150
|
-
}), c = Qr({
|
|
8151
|
-
rawValue: n,
|
|
8152
|
-
calculatedValue: o
|
|
8153
|
-
}), l = Number.isFinite(s) ? Math.round(s) : null, u = Number.isFinite(c) ? Math.round(c) : null, d = {};
|
|
8154
|
-
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;
|
|
8155
|
-
}, ti = ({ textbox: e }) => {
|
|
8156
|
-
let t = e.width ?? e.calcTextWidth(), n = e.fontSize ?? 16, { styles: r = {} } = e, { lineFontDefaults: i } = e, { paddingTop: a = 0, paddingRight: o = 0, paddingBottom: s = 0, paddingLeft: c = 0 } = e, { radiusTopLeft: l = 0, radiusTopRight: u = 0, radiusBottomRight: d = 0, radiusBottomLeft: f = 0 } = e;
|
|
8157
|
-
return {
|
|
8158
|
-
width: t,
|
|
8159
|
-
fontSize: n,
|
|
8160
|
-
padding: {
|
|
8161
|
-
top: a,
|
|
8162
|
-
right: o,
|
|
8163
|
-
bottom: s,
|
|
8164
|
-
left: c
|
|
8165
|
-
},
|
|
8166
|
-
radii: {
|
|
8167
|
-
topLeft: l,
|
|
8168
|
-
topRight: u,
|
|
8169
|
-
bottomRight: d,
|
|
8170
|
-
bottomLeft: f
|
|
8171
|
-
},
|
|
8172
|
-
styles: JSON.parse(JSON.stringify(r)),
|
|
8173
|
-
lineFontDefaults: Kr({ lineFontDefaults: i })
|
|
8174
|
-
};
|
|
8175
|
-
}, ni = ({ base: e }) => {
|
|
8176
|
-
let t = 1 / Math.max(1, e.width), n = [e.fontSize];
|
|
8177
|
-
Object.values(e.styles).forEach((e) => {
|
|
8178
|
-
Object.values(e).forEach((e) => {
|
|
8179
|
-
let { fontSize: t } = e;
|
|
8180
|
-
typeof t != "number" || !Number.isFinite(t) || t <= 0 || n.push(t);
|
|
8181
|
-
});
|
|
8182
|
-
}), Object.values(e.lineFontDefaults ?? {}).forEach((e) => {
|
|
8183
|
-
let { fontSize: t } = e;
|
|
8184
|
-
typeof t != "number" || !Number.isFinite(t) || t <= 0 || n.push(t);
|
|
8185
|
-
});
|
|
8186
|
-
let r = n.reduce((e, t) => Math.max(e, Math.min(8, t) / t), 0);
|
|
8187
|
-
return {
|
|
8188
|
-
widthScale: t,
|
|
8189
|
-
fontScale: r,
|
|
8190
|
-
proportionalScale: Math.max(t, r)
|
|
8191
|
-
};
|
|
8192
|
-
}, ri = ({ textbox: e, canvasManager: t, base: n, widthScale: r, heightScale: i, placement: a, anchorPlacement: o, shouldScaleFontSize: s, shouldScalePadding: c, shouldScaleRadii: l, shouldDisableAutoExpandOnHorizontalChange: u = !1, shouldRoundDimensions: d = !0 }) => {
|
|
8193
|
-
let { width: f, fontSize: m, padding: h, radii: g, styles: _, lineFontDefaults: v } = n, y = Math.max(1, f * r), b = d ? Math.max(1, Math.round(y)) : y, x = Math.max(Math.min(8, m), m * i), S = Object.keys(_).length > 0, C;
|
|
8194
|
-
if (s && S) {
|
|
8195
|
-
let e = {};
|
|
8196
|
-
Object.entries(_).forEach(([t, n]) => {
|
|
8197
|
-
if (!n) return;
|
|
8198
|
-
let r = {};
|
|
8199
|
-
Object.entries(n).forEach(([e, t]) => {
|
|
8200
|
-
if (!t) return;
|
|
8201
|
-
let n = { ...t };
|
|
8202
|
-
if (typeof t.fontSize == "number") {
|
|
8203
|
-
let e = Math.min(8, t.fontSize);
|
|
8204
|
-
n.fontSize = Math.max(e, t.fontSize * i);
|
|
8205
|
-
}
|
|
8206
|
-
r[e] = n;
|
|
8207
|
-
}), Object.keys(r).length && (e[t] = r);
|
|
8208
|
-
}), Object.keys(e).length && (C = e);
|
|
8209
|
-
}
|
|
8210
|
-
let w;
|
|
8211
|
-
s && (w = qr({
|
|
8212
|
-
lineFontDefaults: v,
|
|
8213
|
-
scale: i
|
|
8214
|
-
}));
|
|
8215
|
-
let T = c ? {
|
|
8216
|
-
top: Math.max(0, h.top * i),
|
|
8217
|
-
right: Math.max(0, h.right * i),
|
|
8218
|
-
bottom: Math.max(0, h.bottom * i),
|
|
8219
|
-
left: Math.max(0, h.left * i)
|
|
8220
|
-
} : h, E = l ? {
|
|
8221
|
-
topLeft: Math.max(0, g.topLeft * i),
|
|
8222
|
-
topRight: Math.max(0, g.topRight * i),
|
|
8223
|
-
bottomRight: Math.max(0, g.bottomRight * i),
|
|
8224
|
-
bottomLeft: Math.max(0, g.bottomLeft * i)
|
|
8225
|
-
} : g, D = e.width ?? f, O = Math.abs(b - D) > Ur;
|
|
8226
|
-
u && O && (e.autoExpand = !1), C && (e.styles = C), w && (e.lineFontDefaults = w), e.set({
|
|
8227
|
-
width: b,
|
|
8228
|
-
fontSize: s ? x : m,
|
|
8229
|
-
paddingTop: T.top,
|
|
8230
|
-
paddingRight: T.right,
|
|
8231
|
-
paddingBottom: T.bottom,
|
|
8232
|
-
paddingLeft: T.left,
|
|
8233
|
-
radiusTopLeft: E.topLeft,
|
|
8234
|
-
radiusTopRight: E.topRight,
|
|
8235
|
-
radiusBottomRight: E.bottomRight,
|
|
8236
|
-
radiusBottomLeft: E.bottomLeft,
|
|
8237
|
-
scaleX: 1,
|
|
8238
|
-
scaleY: 1
|
|
8239
|
-
});
|
|
8240
|
-
let k = e.shouldRoundDimensionsOnInit;
|
|
8241
|
-
e.shouldRoundDimensionsOnInit = d;
|
|
8242
|
-
try {
|
|
8243
|
-
e.initDimensions();
|
|
8244
|
-
} finally {
|
|
8245
|
-
e.shouldRoundDimensionsOnInit = k;
|
|
8246
|
-
}
|
|
8247
|
-
let A = d ? ei({ textbox: e }) : !1;
|
|
8248
|
-
return A && (e.dirty = !0), o ? (e.set({
|
|
8249
|
-
originX: a.originX,
|
|
8250
|
-
originY: a.originY
|
|
8251
|
-
}), e.setPositionByOrigin(new p(o.left, o.top), o.originX, o.originY), e.setCoords(), {
|
|
8252
|
-
appliedWidth: e.width ?? b,
|
|
8253
|
-
dimensionsRounded: A
|
|
8254
|
-
}) : (t.applyObjectPlacement({
|
|
8255
|
-
object: e,
|
|
8256
|
-
placement: a
|
|
8257
|
-
}), e.setCoords(), {
|
|
8258
|
-
appliedWidth: e.width ?? b,
|
|
8259
|
-
dimensionsRounded: A
|
|
8260
|
-
});
|
|
8261
|
-
}, ii = ({ transform: e }) => {
|
|
8296
|
+
}, ii = () => {
|
|
8297
|
+
y?.setClass && y.setClass(ri, "background-textbox");
|
|
8298
|
+
}, ai = ({ transform: e }) => {
|
|
8262
8299
|
let { corner: t = "", action: n = "" } = e;
|
|
8263
8300
|
return {
|
|
8264
8301
|
isCornerHandle: t === "tl" || t === "tr" || t === "bl" || t === "br" || n === "scale",
|
|
8265
8302
|
isHorizontalHandle: t === "ml" || t === "mr" || n === "scaleX",
|
|
8266
8303
|
isVerticalHandle: t === "mt" || t === "mb" || n === "scaleY"
|
|
8267
8304
|
};
|
|
8268
|
-
},
|
|
8305
|
+
}, oi = ({ textbox: e, transform: t, appliedWidth: n }) => {
|
|
8269
8306
|
t.scaleX = 1, t.scaleY = 1;
|
|
8270
8307
|
let { original: r } = t;
|
|
8271
8308
|
r && (r.scaleX = 1, r.scaleY = 1, r.width = n, r.height = e.height, r.left = e.left, r.top = e.top);
|
|
8272
|
-
},
|
|
8309
|
+
}, si = ({ textbox: e, transform: t, scenePoint: n }) => {
|
|
8273
8310
|
let { x: r, y: i } = e._getTransformedDimensions();
|
|
8274
8311
|
if (r <= 0 || i <= 0) return null;
|
|
8275
8312
|
let a = b.getLocalPoint(t, t.originX, t.originY, n.x, n.y), o = t, s = typeof o.signX == "number" && a.x * o.signX <= 0, c = typeof o.signY == "number" && a.y * o.signY <= 0, l = Math.abs(a.x / r), u = Math.abs(a.y / i);
|
|
@@ -8279,27 +8316,27 @@ var hr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY
|
|
|
8279
8316
|
stepScaleX: l,
|
|
8280
8317
|
stepScaleY: u
|
|
8281
8318
|
};
|
|
8282
|
-
},
|
|
8283
|
-
function
|
|
8319
|
+
}, ci = 1e-4;
|
|
8320
|
+
function li(e) {
|
|
8284
8321
|
return !!e && e instanceof _;
|
|
8285
8322
|
}
|
|
8286
|
-
function
|
|
8287
|
-
if (!
|
|
8323
|
+
function ui(e) {
|
|
8324
|
+
if (!li(e)) return !1;
|
|
8288
8325
|
let t = e.group;
|
|
8289
8326
|
return e.shapeNodeType === "text" && t?.shapeComposite === !0;
|
|
8290
8327
|
}
|
|
8291
|
-
var
|
|
8328
|
+
var di = class {
|
|
8292
8329
|
constructor({ canvas: t, canvasManager: n, persistScaledTextbox: r }) {
|
|
8293
8330
|
this.handleMouseMove = (e) => {
|
|
8294
8331
|
let t = this.canvas._currentTransform;
|
|
8295
8332
|
if (!t) return;
|
|
8296
8333
|
let { target: n } = t;
|
|
8297
|
-
if (!
|
|
8334
|
+
if (!li(n) || ui(n)) return;
|
|
8298
8335
|
let r = this.scalingState.get(n);
|
|
8299
8336
|
if (!r || !e.e) return;
|
|
8300
|
-
let { isCornerHandle: i, isHorizontalHandle: a, isVerticalHandle: o } =
|
|
8337
|
+
let { isCornerHandle: i, isHorizontalHandle: a, isVerticalHandle: o } = ai({ transform: t });
|
|
8301
8338
|
if (!a && !o && !i) return;
|
|
8302
|
-
let s =
|
|
8339
|
+
let s = si({
|
|
8303
8340
|
textbox: n,
|
|
8304
8341
|
transform: t,
|
|
8305
8342
|
scenePoint: this.canvas.getScenePoint(e.e)
|
|
@@ -8322,20 +8359,20 @@ var ui = class {
|
|
|
8322
8359
|
}, j = r.lastAllowedScaleX, M = r.lastAllowedScaleY;
|
|
8323
8360
|
if (i) {
|
|
8324
8361
|
let e = Math.max(r.minimumProportionalScale, r.lastAllowedScaleX * Math.sqrt(u * d)), t = c || l ? r.minimumProportionalScale : e;
|
|
8325
|
-
if (Math.abs(t - r.lastAllowedScaleX) <=
|
|
8362
|
+
if (Math.abs(t - r.lastAllowedScaleX) <= ci) return;
|
|
8326
8363
|
j = t, M = t;
|
|
8327
8364
|
} else {
|
|
8328
8365
|
if (a) {
|
|
8329
8366
|
let e = r.lastAllowedScaleX * u, t = c ? r.minimumWidthScale : Math.max(r.minimumWidthScale, e);
|
|
8330
|
-
Math.abs(t - r.lastAllowedScaleX) >
|
|
8367
|
+
Math.abs(t - r.lastAllowedScaleX) > ci && (j = t);
|
|
8331
8368
|
}
|
|
8332
8369
|
if (o) {
|
|
8333
8370
|
let e = r.lastAllowedScaleY * d, t = l ? r.minimumFontScale : Math.max(r.minimumFontScale, e);
|
|
8334
|
-
Math.abs(t - r.lastAllowedScaleY) >
|
|
8371
|
+
Math.abs(t - r.lastAllowedScaleY) > ci && (M = t);
|
|
8335
8372
|
}
|
|
8336
|
-
if (Math.abs(j - r.lastAllowedScaleX) <=
|
|
8373
|
+
if (Math.abs(j - r.lastAllowedScaleX) <= ci && Math.abs(M - r.lastAllowedScaleY) <= ci) return;
|
|
8337
8374
|
}
|
|
8338
|
-
let { appliedWidth: N, dimensionsRounded: P } =
|
|
8375
|
+
let { appliedWidth: N, dimensionsRounded: P } = un({
|
|
8339
8376
|
textbox: n,
|
|
8340
8377
|
canvasManager: this.canvasManager,
|
|
8341
8378
|
base: r.startBase,
|
|
@@ -8349,7 +8386,7 @@ var ui = class {
|
|
|
8349
8386
|
shouldDisableAutoExpandOnHorizontalChange: a,
|
|
8350
8387
|
shouldRoundDimensions: !i
|
|
8351
8388
|
});
|
|
8352
|
-
|
|
8389
|
+
oi({
|
|
8353
8390
|
textbox: n,
|
|
8354
8391
|
transform: t,
|
|
8355
8392
|
appliedWidth: N
|
|
@@ -8370,12 +8407,12 @@ var ui = class {
|
|
|
8370
8407
|
}), this.canvas.requestRenderAll();
|
|
8371
8408
|
}, this.handleObjectScaling = (t) => {
|
|
8372
8409
|
let { target: n, transform: r } = t;
|
|
8373
|
-
if (n instanceof e || !
|
|
8410
|
+
if (n instanceof e || !li(n) || ui(n) || !r) return;
|
|
8374
8411
|
n.isScaling = !0;
|
|
8375
8412
|
let i = this._ensureScalingState({
|
|
8376
8413
|
textbox: n,
|
|
8377
8414
|
transform: r
|
|
8378
|
-
}), { startBase: a } = i, { width: o, fontSize: s } = a, { isCornerHandle: c, isHorizontalHandle: l, isVerticalHandle: u } =
|
|
8415
|
+
}), { startBase: a } = i, { width: o, fontSize: s } = a, { isCornerHandle: c, isHorizontalHandle: l, isVerticalHandle: u } = ai({ transform: r }), d = r.corner ?? "", f = c || u;
|
|
8379
8416
|
if (!l && !u && !c) return;
|
|
8380
8417
|
let p = n.scaleX ?? r.scaleX ?? 1, m = n.scaleY ?? r.scaleY ?? 1, h = Math.abs(p) || 1, g = Math.abs(m) || 1, _ = r.originX ?? n.originX ?? "center", v = r.originY ?? n.originY ?? "center", y = this.canvasManager.getObjectPlacement({
|
|
8381
8418
|
object: n,
|
|
@@ -8390,7 +8427,7 @@ var ui = class {
|
|
|
8390
8427
|
N = e, P = e;
|
|
8391
8428
|
}
|
|
8392
8429
|
} else l && (N = Math.max(i.minimumWidthScale, i.lastAllowedScaleX * h)), u && (P = Math.max(i.minimumFontScale, i.lastAllowedScaleY * g));
|
|
8393
|
-
let { appliedWidth: ee, dimensionsRounded: te } =
|
|
8430
|
+
let { appliedWidth: ee, dimensionsRounded: te } = un({
|
|
8394
8431
|
textbox: n,
|
|
8395
8432
|
canvasManager: this.canvasManager,
|
|
8396
8433
|
base: a,
|
|
@@ -8404,7 +8441,7 @@ var ui = class {
|
|
|
8404
8441
|
shouldDisableAutoExpandOnHorizontalChange: l,
|
|
8405
8442
|
shouldRoundDimensions: !c
|
|
8406
8443
|
});
|
|
8407
|
-
|
|
8444
|
+
oi({
|
|
8408
8445
|
textbox: n,
|
|
8409
8446
|
transform: r,
|
|
8410
8447
|
appliedWidth: ee
|
|
@@ -8437,7 +8474,7 @@ var ui = class {
|
|
|
8437
8474
|
let { target: n } = t;
|
|
8438
8475
|
if (n instanceof e) {
|
|
8439
8476
|
let t = n.getObjects();
|
|
8440
|
-
if (!t.some((e) =>
|
|
8477
|
+
if (!t.some((e) => li(e))) return;
|
|
8441
8478
|
let { scaleX: r = 1, scaleY: i = 1 } = n;
|
|
8442
8479
|
if (Math.abs(r - 1) < .01 && Math.abs(i - 1) < .01) return;
|
|
8443
8480
|
this.canvas.discardActiveObject(), t.forEach((e) => {
|
|
@@ -8447,7 +8484,7 @@ var ui = class {
|
|
|
8447
8484
|
this.canvas.setActiveObject(a), this.canvas.requestRenderAll();
|
|
8448
8485
|
return;
|
|
8449
8486
|
}
|
|
8450
|
-
if (!
|
|
8487
|
+
if (!li(n) || ui(n)) return;
|
|
8451
8488
|
n.isScaling = !1;
|
|
8452
8489
|
let r = this.scalingState.get(n);
|
|
8453
8490
|
if (this.scalingState.delete(n), !r?.hasScalingChange) return;
|
|
@@ -8472,11 +8509,11 @@ var ui = class {
|
|
|
8472
8509
|
}, this.canvas = t, this.canvasManager = n, this.persistScaledTextbox = r, this.scalingState = /* @__PURE__ */ new WeakMap();
|
|
8473
8510
|
}
|
|
8474
8511
|
commitStandaloneTextScale({ target: e, shouldDisableAutoExpandOnHorizontalChange: t = !1 }) {
|
|
8475
|
-
if (!
|
|
8512
|
+
if (!li(e) || ui(e)) return !1;
|
|
8476
8513
|
let n = Math.abs(e.scaleX ?? 1) || 1, r = Math.abs(e.scaleY ?? 1) || 1;
|
|
8477
8514
|
if (!(Math.abs(n - 1) > .01 || Math.abs(r - 1) > .01)) return !1;
|
|
8478
|
-
let i =
|
|
8479
|
-
return
|
|
8515
|
+
let i = sn({ textbox: e }), a = this.canvasManager.getObjectPlacement({ object: e });
|
|
8516
|
+
return un({
|
|
8480
8517
|
textbox: e,
|
|
8481
8518
|
canvasManager: this.canvasManager,
|
|
8482
8519
|
base: i,
|
|
@@ -8492,7 +8529,7 @@ var ui = class {
|
|
|
8492
8529
|
_ensureScalingState({ textbox: e, transform: t }) {
|
|
8493
8530
|
let n = this.scalingState.get(e);
|
|
8494
8531
|
if (!n) {
|
|
8495
|
-
let r =
|
|
8532
|
+
let r = sn({ textbox: e }), i = this.canvasManager.getObjectPlacement({ object: e }), a = cn({ base: r }), o = t.original?.originX ?? t.originX ?? e.originX ?? "center", s = t.original?.originY ?? t.originY ?? e.originY ?? "center";
|
|
8496
8533
|
n = {
|
|
8497
8534
|
startBase: r,
|
|
8498
8535
|
startObjectPlacement: i,
|
|
@@ -8525,7 +8562,7 @@ var ui = class {
|
|
|
8525
8562
|
topRight: e.radiusTopRight ?? 0,
|
|
8526
8563
|
bottomRight: e.radiusBottomRight ?? 0,
|
|
8527
8564
|
bottomLeft: e.radiusBottomLeft ?? 0
|
|
8528
|
-
}, v = Math.abs(n - o) >
|
|
8565
|
+
}, v = Math.abs(n - o) > Jt, y = Math.abs(h - r) > Jt, b = Math.abs(g.top - i.top) > .01 || Math.abs(g.right - i.right) > .01 || Math.abs(g.bottom - i.bottom) > .01 || Math.abs(g.left - i.left) > .01, x = Math.abs(_.topLeft - a.topLeft) > .01 || Math.abs(_.topRight - a.topRight) > .01 || Math.abs(_.bottomRight - a.bottomRight) > .01 || Math.abs(_.bottomLeft - a.bottomLeft) > .01, S = t.lastAllowedScaleX, C = t.lastAllowedScaleY;
|
|
8529
8566
|
if (c) {
|
|
8530
8567
|
let e = h / Math.max(1, m);
|
|
8531
8568
|
S = e, C = e;
|
|
@@ -8546,7 +8583,7 @@ var ui = class {
|
|
|
8546
8583
|
originY: a
|
|
8547
8584
|
});
|
|
8548
8585
|
}
|
|
8549
|
-
},
|
|
8586
|
+
}, fi = ({ textbox: e }) => {
|
|
8550
8587
|
let t = e.text ?? "";
|
|
8551
8588
|
if (!t.length) return [];
|
|
8552
8589
|
let n = t.split("\n"), r = [], i = 0;
|
|
@@ -8558,7 +8595,7 @@ var ui = class {
|
|
|
8558
8595
|
});
|
|
8559
8596
|
}
|
|
8560
8597
|
return r;
|
|
8561
|
-
},
|
|
8598
|
+
}, pi = ({ range: e, text: t }) => {
|
|
8562
8599
|
if (!e) return null;
|
|
8563
8600
|
let n = t.length;
|
|
8564
8601
|
if (n <= 0) return null;
|
|
@@ -8567,8 +8604,8 @@ var ui = class {
|
|
|
8567
8604
|
start: l,
|
|
8568
8605
|
end: u
|
|
8569
8606
|
};
|
|
8570
|
-
},
|
|
8571
|
-
let n =
|
|
8607
|
+
}, mi = ({ textbox: e, range: t }) => {
|
|
8608
|
+
let n = fi({ textbox: e });
|
|
8572
8609
|
if (!n.length) return t;
|
|
8573
8610
|
let { start: r } = t, { end: i } = t;
|
|
8574
8611
|
for (let e = 0; e < n.length; e += 1) {
|
|
@@ -8581,7 +8618,7 @@ var ui = class {
|
|
|
8581
8618
|
start: r,
|
|
8582
8619
|
end: i
|
|
8583
8620
|
};
|
|
8584
|
-
},
|
|
8621
|
+
}, hi = ({ textbox: e, range: t }) => {
|
|
8585
8622
|
let n = e.text ?? "";
|
|
8586
8623
|
if (!n.length) return [];
|
|
8587
8624
|
let { start: r, end: i } = t, a = n.split("\n"), o = [], s = 0;
|
|
@@ -8590,7 +8627,7 @@ var ui = class {
|
|
|
8590
8627
|
i > n && r < c && o.push(e), s = c + 1;
|
|
8591
8628
|
}
|
|
8592
8629
|
return o;
|
|
8593
|
-
},
|
|
8630
|
+
}, gi = ({ textbox: e, range: t }) => {
|
|
8594
8631
|
let n = e.text ?? "";
|
|
8595
8632
|
if (!n.length) return [];
|
|
8596
8633
|
let { start: r, end: i } = t, a = n.split("\n"), o = [], s = 0;
|
|
@@ -8599,20 +8636,20 @@ var ui = class {
|
|
|
8599
8636
|
r <= n && i >= c && o.push(e), s = c + 1;
|
|
8600
8637
|
}
|
|
8601
8638
|
return o;
|
|
8602
|
-
},
|
|
8639
|
+
}, _i = ({ previous: e, next: t }) => {
|
|
8603
8640
|
let n = Math.min(e.length, t.length);
|
|
8604
8641
|
for (let r = 0; r < n; r += 1) if (e[r] !== t[r]) return r;
|
|
8605
8642
|
return n;
|
|
8606
|
-
},
|
|
8643
|
+
}, vi = ({ text: e, charIndex: t }) => {
|
|
8607
8644
|
let n = Math.max(0, Math.min(t, e.length)), r = 0;
|
|
8608
8645
|
for (let t = 0; t < n; t += 1) e[t] === "\n" && (r += 1);
|
|
8609
8646
|
return r;
|
|
8610
|
-
},
|
|
8647
|
+
}, yi = ({ text: e, lineIndex: t }) => {
|
|
8611
8648
|
if (t <= 0) return 0;
|
|
8612
8649
|
let n = 0;
|
|
8613
8650
|
for (let r = 0; r < e.length; r += 1) if (e[r] === "\n" && (n += 1, n === t)) return r + 1;
|
|
8614
8651
|
return e.length;
|
|
8615
|
-
},
|
|
8652
|
+
}, bi = class e {
|
|
8616
8653
|
constructor({ editor: t }) {
|
|
8617
8654
|
this._handleTextEditingEntered = (t) => {
|
|
8618
8655
|
this.isTextEditingActive = !0;
|
|
@@ -8625,7 +8662,7 @@ var ui = class {
|
|
|
8625
8662
|
if (!e._isTextbox(n) || this.lineDefaultsSyncing.has(n)) return;
|
|
8626
8663
|
let r = e._isShapeOwnedTextbox(n), { text: i = "", uppercase: a, autoExpand: o } = n, s = !!a, c = o !== !1, l = i.toLocaleLowerCase(), u = r ? null : this.editingPlacementState?.get(n) ?? this.editor.canvasManager.getObjectPlacement({ object: n });
|
|
8627
8664
|
if (s) {
|
|
8628
|
-
let e =
|
|
8665
|
+
let e = ti({ value: l });
|
|
8629
8666
|
e !== i && n.set({ text: e }), n.textCaseRaw = l;
|
|
8630
8667
|
} else n.textCaseRaw = i;
|
|
8631
8668
|
if (!r && o === void 0 && (n.autoExpand = !0), r) {
|
|
@@ -8643,7 +8680,7 @@ var ui = class {
|
|
|
8643
8680
|
let r = e._isShapeOwnedTextbox(n);
|
|
8644
8681
|
this.editingPlacementState?.delete(n);
|
|
8645
8682
|
let i = n.text ?? "";
|
|
8646
|
-
n.uppercase ? n.textCaseRaw = n.textCaseRaw ?? i.toLocaleLowerCase() : n.textCaseRaw = i, r || (
|
|
8683
|
+
n.uppercase ? n.textCaseRaw = n.textCaseRaw ?? i.toLocaleLowerCase() : n.textCaseRaw = i, r || (on({ textbox: n }) && (n.setCoords(), n.dirty = !0, this.canvas.requestRenderAll()), n.locked || n.set({
|
|
8647
8684
|
lockMovementX: !1,
|
|
8648
8685
|
lockMovementY: !1
|
|
8649
8686
|
}));
|
|
@@ -8670,7 +8707,7 @@ var ui = class {
|
|
|
8670
8707
|
transform: r,
|
|
8671
8708
|
event: i ?? null
|
|
8672
8709
|
});
|
|
8673
|
-
}, this.editor = t, this.canvas = t.canvas, this.fonts = t.options.fonts ?? [], this.scalingController = new
|
|
8710
|
+
}, this.editor = t, this.canvas = t.canvas, this.fonts = t.options.fonts ?? [], this.scalingController = new di({
|
|
8674
8711
|
canvas: t.canvas,
|
|
8675
8712
|
canvasManager: t.canvasManager,
|
|
8676
8713
|
persistScaledTextbox: ({ target: e, style: t }) => {
|
|
@@ -8679,12 +8716,12 @@ var ui = class {
|
|
|
8679
8716
|
style: t
|
|
8680
8717
|
});
|
|
8681
8718
|
}
|
|
8682
|
-
}), this.editingPlacementState = /* @__PURE__ */ new WeakMap(), this.lineDefaultsSyncing = /* @__PURE__ */ new WeakSet(), this.isTextEditingActive = !1, this._bindEvents(),
|
|
8719
|
+
}), this.editingPlacementState = /* @__PURE__ */ new WeakMap(), this.lineDefaultsSyncing = /* @__PURE__ */ new WeakSet(), this.isTextEditingActive = !1, this._bindEvents(), ii();
|
|
8683
8720
|
}
|
|
8684
|
-
addText({ id: t = `
|
|
8721
|
+
addText({ id: t = `background-textbox-${D()}`, text: n = "Новый текст", autoExpand: r = !0, fontFamily: i, fontSize: a = 48, bold: o = !1, italic: s = !1, underline: c = !1, uppercase: l = !1, strikethrough: u = !1, align: d = "left", color: f = "#000000", strokeColor: p, strokeWidth: m = 0, opacity: h = 1, backgroundColor: g, backgroundOpacity: _ = 1, paddingTop: v = 0, paddingRight: y = 0, paddingBottom: b = 0, paddingLeft: x = 0, radiusTopLeft: S = 0, radiusTopRight: C = 0, radiusBottomRight: w = 0, radiusBottomLeft: T = 0, ...E } = {}, { withoutSelection: O = !1, withoutSave: k = !1, withoutAdding: A = !1, emitLifecycleEvents: j = !0 } = {}) {
|
|
8685
8722
|
let { canvasManager: M, historyManager: N } = this.editor, { canvas: P } = this;
|
|
8686
8723
|
N.suspendHistory();
|
|
8687
|
-
let F = i ?? this._getDefaultFontFamily(), I =
|
|
8724
|
+
let F = i ?? this._getDefaultFontFamily(), I = ei({ width: m }), ee = $r({
|
|
8688
8725
|
strokeColor: p,
|
|
8689
8726
|
width: I
|
|
8690
8727
|
}), te = {
|
|
@@ -8713,14 +8750,14 @@ var ui = class {
|
|
|
8713
8750
|
radiusBottomRight: w,
|
|
8714
8751
|
radiusBottomLeft: T,
|
|
8715
8752
|
...E
|
|
8716
|
-
}, L = new
|
|
8753
|
+
}, L = new ri(n, te), ne = r !== !1;
|
|
8717
8754
|
L.autoExpand = ne;
|
|
8718
8755
|
let re = E.left !== void 0 || E.top !== void 0;
|
|
8719
8756
|
if (L.textCaseRaw = L.text ?? "", l) {
|
|
8720
|
-
let e =
|
|
8757
|
+
let e = ti({ value: L.textCaseRaw });
|
|
8721
8758
|
e !== L.text && L.set({ text: e });
|
|
8722
8759
|
}
|
|
8723
|
-
|
|
8760
|
+
on({ textbox: L }) && (L.dirty = !0);
|
|
8724
8761
|
let R;
|
|
8725
8762
|
re && (R = M.resolveObjectPlacement({
|
|
8726
8763
|
object: L,
|
|
@@ -8767,13 +8804,13 @@ var ui = class {
|
|
|
8767
8804
|
top: te,
|
|
8768
8805
|
originX: L,
|
|
8769
8806
|
originY: ne
|
|
8770
|
-
}), z = a === void 0 ?
|
|
8807
|
+
}), z = a === void 0 ? Jr({ textbox: s }) : pi({
|
|
8771
8808
|
text: c,
|
|
8772
8809
|
range: a
|
|
8773
|
-
}), B = z ?
|
|
8810
|
+
}), B = z ? mi({
|
|
8774
8811
|
textbox: s,
|
|
8775
8812
|
range: z
|
|
8776
|
-
}) : null, V = {}, H = {}, U = {}, ae, oe, W =
|
|
8813
|
+
}) : null, V = {}, H = {}, U = {}, ae, oe, W = Xr({
|
|
8777
8814
|
textbox: s,
|
|
8778
8815
|
range: z
|
|
8779
8816
|
}), se = !z || W, G = !z;
|
|
@@ -8786,24 +8823,24 @@ var ui = class {
|
|
|
8786
8823
|
z && (V.fontStyle = e), se && (R.fontStyle = e, G && (U.fontStyle = e));
|
|
8787
8824
|
}
|
|
8788
8825
|
if (y !== void 0 && (z && (V.underline = y), se && (R.underline = y, G && (U.underline = y))), x !== void 0 && (z && (V.linethrough = x), se && (R.linethrough = x, G && (U.linethrough = x))), S !== void 0 && (R.textAlign = S), C !== void 0 && (z && (V.fill = C), se && (R.fill = C, G && (U.fill = C))), w !== void 0 || T !== void 0) {
|
|
8789
|
-
let e = z ?
|
|
8826
|
+
let e = z ? Qr({
|
|
8790
8827
|
textbox: s,
|
|
8791
8828
|
range: z,
|
|
8792
8829
|
property: "strokeWidth"
|
|
8793
|
-
}) : void 0, t = z ?
|
|
8830
|
+
}) : void 0, t = z ? Qr({
|
|
8794
8831
|
textbox: s,
|
|
8795
8832
|
range: z,
|
|
8796
8833
|
property: "stroke"
|
|
8797
8834
|
}) : void 0;
|
|
8798
|
-
oe =
|
|
8835
|
+
oe = ei({ width: T ?? e ?? s.strokeWidth ?? 0 }), ae = $r({
|
|
8799
8836
|
strokeColor: w ?? t ?? s.stroke ?? void 0,
|
|
8800
8837
|
width: oe
|
|
8801
8838
|
}), z && (V.stroke = ae, V.strokeWidth = oe), se && (R.stroke = ae, R.strokeWidth = oe, G && (U.stroke = ae, U.strokeWidth = oe));
|
|
8802
8839
|
}
|
|
8803
8840
|
E !== void 0 && (R.opacity = E), D !== void 0 && (R.backgroundColor = D), O !== void 0 && (R.backgroundOpacity = O), k !== void 0 && (R.paddingTop = k), A !== void 0 && (R.paddingRight = A), j !== void 0 && (R.paddingBottom = j), M !== void 0 && (R.paddingLeft = M), N !== void 0 && (R.radiusTopLeft = N), P !== void 0 && (R.radiusTopRight = P), F !== void 0 && (R.radiusBottomRight = F), I !== void 0 && (R.radiusBottomLeft = I);
|
|
8804
8841
|
let ce = s.textCaseRaw ?? c, le = !!s.uppercase, ue = p !== void 0, de = ue ? p ?? "" : ce, fe = b ?? le, pe = fe !== le;
|
|
8805
|
-
ue || pe ? (R.text = fe ?
|
|
8806
|
-
let me =
|
|
8842
|
+
ue || pe ? (R.text = fe ? ti({ value: de }) : de, s.textCaseRaw = de) : s.textCaseRaw === void 0 && (s.textCaseRaw = ce);
|
|
8843
|
+
let me = an({ stylesList: [
|
|
8807
8844
|
R,
|
|
8808
8845
|
V,
|
|
8809
8846
|
H,
|
|
@@ -8819,53 +8856,53 @@ var ui = class {
|
|
|
8819
8856
|
j,
|
|
8820
8857
|
M
|
|
8821
8858
|
], _e = he.some((e) => e !== void 0), ve = ge.some((e) => e !== void 0), ye = Object.prototype.hasOwnProperty.call(R, "width"), be = ve && !_e && !ue && !pe && !me && !ye, xe = null;
|
|
8822
|
-
be && (xe =
|
|
8859
|
+
be && (xe = tn({
|
|
8823
8860
|
textbox: s,
|
|
8824
8861
|
originX: ie.originX,
|
|
8825
8862
|
originY: ie.originY
|
|
8826
8863
|
})), s.uppercase = fe, s.set(R);
|
|
8827
8864
|
let K = !1;
|
|
8828
8865
|
if (z) {
|
|
8829
|
-
let e =
|
|
8866
|
+
let e = Zr({
|
|
8830
8867
|
textbox: s,
|
|
8831
8868
|
styles: V,
|
|
8832
8869
|
range: z
|
|
8833
|
-
}), t = B ?
|
|
8870
|
+
}), t = B ? Zr({
|
|
8834
8871
|
textbox: s,
|
|
8835
8872
|
styles: H,
|
|
8836
8873
|
range: B
|
|
8837
8874
|
}) : !1;
|
|
8838
8875
|
K = e || t;
|
|
8839
8876
|
} else if (Object.keys(U).length) {
|
|
8840
|
-
let e =
|
|
8841
|
-
e && (K =
|
|
8877
|
+
let e = Yr({ textbox: s });
|
|
8878
|
+
e && (K = Zr({
|
|
8842
8879
|
textbox: s,
|
|
8843
8880
|
styles: U,
|
|
8844
8881
|
range: e
|
|
8845
8882
|
}));
|
|
8846
8883
|
}
|
|
8847
|
-
let Se = K &&
|
|
8884
|
+
let Se = K && an({ stylesList: [
|
|
8848
8885
|
V,
|
|
8849
8886
|
H,
|
|
8850
8887
|
U
|
|
8851
8888
|
] });
|
|
8852
8889
|
if (K && (s.dirty = !0), B && (h !== void 0 || g !== void 0)) {
|
|
8853
|
-
let e =
|
|
8890
|
+
let e = hi({
|
|
8854
8891
|
textbox: s,
|
|
8855
8892
|
range: B
|
|
8856
8893
|
}), t = {};
|
|
8857
|
-
h !== void 0 && (t.fontFamily = h), g !== void 0 && (t.fontSize = g),
|
|
8894
|
+
h !== void 0 && (t.fontFamily = h), g !== void 0 && (t.fontSize = g), Yt({
|
|
8858
8895
|
textbox: s,
|
|
8859
8896
|
lineIndices: e,
|
|
8860
8897
|
updates: t
|
|
8861
8898
|
});
|
|
8862
8899
|
}
|
|
8863
8900
|
if (z && (C !== void 0 || w !== void 0 || T !== void 0)) {
|
|
8864
|
-
let e =
|
|
8901
|
+
let e = gi({
|
|
8865
8902
|
textbox: s,
|
|
8866
8903
|
range: z
|
|
8867
8904
|
}), t = {};
|
|
8868
|
-
C !== void 0 && (t.fill = C), (w !== void 0 || T !== void 0) && (ae === null && (t.stroke = null), ae != null && (t.stroke = ae)),
|
|
8905
|
+
C !== void 0 && (t.fill = C), (w !== void 0 || T !== void 0) && (ae === null && (t.stroke = null), ae != null && (t.stroke = ae)), Yt({
|
|
8869
8906
|
textbox: s,
|
|
8870
8907
|
lineIndices: e,
|
|
8871
8908
|
updates: t
|
|
@@ -8971,7 +9008,7 @@ var ui = class {
|
|
|
8971
9008
|
clampToMontage: r
|
|
8972
9009
|
}));
|
|
8973
9010
|
let a = !1;
|
|
8974
|
-
i || (a =
|
|
9011
|
+
i || (a = on({ textbox: e }));
|
|
8975
9012
|
let o = !1;
|
|
8976
9013
|
return !i && t && (this.editor.canvasManager.applyObjectPlacement({
|
|
8977
9014
|
object: e,
|
|
@@ -8979,7 +9016,7 @@ var ui = class {
|
|
|
8979
9016
|
}), o = !0), (i || a) && (e.dirty = !0), (i || a || o) && e.setCoords(), i || a;
|
|
8980
9017
|
}
|
|
8981
9018
|
_restoreTextboxContentPlacement({ textbox: e, contentPlacement: t }) {
|
|
8982
|
-
let n =
|
|
9019
|
+
let n = tn({
|
|
8983
9020
|
textbox: e,
|
|
8984
9021
|
originX: t.originX,
|
|
8985
9022
|
originY: t.originY
|
|
@@ -8999,15 +9036,15 @@ var ui = class {
|
|
|
8999
9036
|
_syncLineFontDefaultsOnTextChanged({ textbox: e }) {
|
|
9000
9037
|
let { text: t = "", lineFontDefaults: n, styles: r, fontFamily: i, fontSize: a, fill: o, stroke: s, selectionStart: c, isEditing: l } = e, u = t, d = e.__lineDefaultsPrevText ?? u, f = d.split("\n"), p = u.split("\n"), m = f.length, h = p.length - m, g = n, _ = !1, v = !1, y = typeof o == "string" ? o : void 0, b = typeof s == "string" ? s : void 0;
|
|
9001
9038
|
if (h !== 0 && n && Object.keys(n).length) {
|
|
9002
|
-
let e =
|
|
9039
|
+
let e = _i({
|
|
9003
9040
|
previous: d,
|
|
9004
9041
|
next: u
|
|
9005
|
-
}), t =
|
|
9042
|
+
}), t = vi({
|
|
9006
9043
|
text: d,
|
|
9007
9044
|
charIndex: e
|
|
9008
9045
|
});
|
|
9009
9046
|
if (h > 0) {
|
|
9010
|
-
let r =
|
|
9047
|
+
let r = yi({
|
|
9011
9048
|
text: d,
|
|
9012
9049
|
lineIndex: t
|
|
9013
9050
|
}), i = t + 1;
|
|
@@ -9048,7 +9085,7 @@ var ui = class {
|
|
|
9048
9085
|
let t = p[e] ?? "", n = g ? g[e] : void 0;
|
|
9049
9086
|
if (n && (T = n), t.length !== 0) {
|
|
9050
9087
|
if (n) {
|
|
9051
|
-
let r =
|
|
9088
|
+
let r = Xt({
|
|
9052
9089
|
lineText: t,
|
|
9053
9090
|
lineStyles: S ? S[e] : void 0,
|
|
9054
9091
|
lineDefaults: n
|
|
@@ -9088,16 +9125,16 @@ var ui = class {
|
|
|
9088
9125
|
if (!Number.isFinite(f) || f <= 0) return !1;
|
|
9089
9126
|
let p = a.split("\n").length, m = !1;
|
|
9090
9127
|
Math.abs((e.width ?? 0) - f) > .01 && (e.set({ width: f }), m = !0), e.initDimensions();
|
|
9091
|
-
let { textLines: h } = e, g = Array.isArray(h) && h.length > p, _ = Math.ceil(
|
|
9128
|
+
let { textLines: h } = e, g = Array.isArray(h) && h.length > p, _ = Math.ceil($t({
|
|
9092
9129
|
textbox: e,
|
|
9093
9130
|
text: a
|
|
9094
9131
|
})), v = Math.min(e.minWidth ?? 1, f), y = Math.min(f, Math.max(_, v));
|
|
9095
|
-
g && (y = f), Math.abs((e.width ?? 0) - y) > .01 && (e.set({ width: y }), e.initDimensions(), m = !0),
|
|
9132
|
+
g && (y = f), Math.abs((e.width ?? 0) - y) > .01 && (e.set({ width: y }), e.initDimensions(), m = !0), on({ textbox: e }) && (m = !0), t && r.applyObjectPlacement({
|
|
9096
9133
|
object: e,
|
|
9097
9134
|
placement: t
|
|
9098
9135
|
});
|
|
9099
9136
|
let b = !1;
|
|
9100
|
-
return n && (b =
|
|
9137
|
+
return n && (b = nn({
|
|
9101
9138
|
textbox: e,
|
|
9102
9139
|
montageLeft: o,
|
|
9103
9140
|
montageRight: o + s
|
|
@@ -9155,7 +9192,7 @@ var ui = class {
|
|
|
9155
9192
|
_getDefaultFontFamily() {
|
|
9156
9193
|
return this.fonts[0]?.family ?? "Arial";
|
|
9157
9194
|
}
|
|
9158
|
-
},
|
|
9195
|
+
}, xi = ({ x1: e, y1: t, x2: n, y2: r }) => (Math.atan2(r - t, n - e) * 180 / Math.PI + 360) % 360, Si = (e) => {
|
|
9159
9196
|
if (!e || typeof e != "object") return null;
|
|
9160
9197
|
let { type: t, coords: n, colorStops: r } = e, i = Array.isArray(r) ? r : [], a = i[0], o = i[i.length - 1], s = typeof a?.color == "string" ? a.color : void 0, c = typeof o?.color == "string" ? o.color : s, l = typeof a?.offset == "number" ? a.offset * 100 : void 0, u = typeof o?.offset == "number" ? o.offset * 100 : void 0, d = i.map((e) => ({
|
|
9161
9198
|
color: typeof e.color == "string" ? e.color : "#000000",
|
|
@@ -9166,7 +9203,7 @@ var ui = class {
|
|
|
9166
9203
|
let { x1: e, y1: t, x2: r, y2: i } = n;
|
|
9167
9204
|
if (typeof e == "number" && typeof t == "number" && typeof r == "number" && typeof i == "number") return {
|
|
9168
9205
|
type: "linear",
|
|
9169
|
-
angle:
|
|
9206
|
+
angle: xi({
|
|
9170
9207
|
x1: e,
|
|
9171
9208
|
y1: t,
|
|
9172
9209
|
x2: r,
|
|
@@ -9194,7 +9231,7 @@ var ui = class {
|
|
|
9194
9231
|
};
|
|
9195
9232
|
}
|
|
9196
9233
|
return null;
|
|
9197
|
-
},
|
|
9234
|
+
}, Ci = "_templateAnchorX", wi = "_templateAnchorY", Ti = class t {
|
|
9198
9235
|
constructor({ editor: e }) {
|
|
9199
9236
|
this.editor = e;
|
|
9200
9237
|
}
|
|
@@ -9203,7 +9240,7 @@ var ui = class {
|
|
|
9203
9240
|
if (!p.length) return s.emitWarning({
|
|
9204
9241
|
origin: "TemplateManager",
|
|
9205
9242
|
method: "serializeSelection",
|
|
9206
|
-
code:
|
|
9243
|
+
code: Gr.TEMPLATE_MANAGER.NO_OBJECTS_SELECTED,
|
|
9207
9244
|
message: "Нет объектов для сериализации шаблона"
|
|
9208
9245
|
}), null;
|
|
9209
9246
|
let m = t._getBounds(o), h = t._getMontageSize({
|
|
@@ -9228,80 +9265,83 @@ var ui = class {
|
|
|
9228
9265
|
};
|
|
9229
9266
|
}
|
|
9230
9267
|
async applyTemplate({ template: e }) {
|
|
9231
|
-
let { canvas: n, montageArea: r, historyManager: i, errorManager: a, backgroundManager: o } = this.editor, { objects:
|
|
9232
|
-
if (!
|
|
9268
|
+
let { canvas: n, montageArea: r, historyManager: i, errorManager: a, backgroundManager: o, shapeManager: s, textManager: c } = this.editor, { objects: l, meta: u, id: d } = e ?? {};
|
|
9269
|
+
if (!l?.length) return a.emitWarning({
|
|
9233
9270
|
origin: "TemplateManager",
|
|
9234
9271
|
method: "applyTemplate",
|
|
9235
|
-
code:
|
|
9272
|
+
code: Gr.TEMPLATE_MANAGER.INVALID_TEMPLATE,
|
|
9236
9273
|
message: "Шаблон не содержит объектов"
|
|
9237
9274
|
}), null;
|
|
9238
|
-
let
|
|
9239
|
-
if (!
|
|
9275
|
+
let f = t._getBounds(r);
|
|
9276
|
+
if (!f) return a.emitWarning({
|
|
9240
9277
|
origin: "TemplateManager",
|
|
9241
9278
|
method: "applyTemplate",
|
|
9242
|
-
code:
|
|
9279
|
+
code: Gr.TEMPLATE_MANAGER.INVALID_TARGET,
|
|
9243
9280
|
message: "Не удалось определить границы монтажной области"
|
|
9244
9281
|
}), null;
|
|
9245
|
-
let
|
|
9282
|
+
let p = t._getMontageSize({
|
|
9246
9283
|
montageArea: r,
|
|
9247
|
-
bounds:
|
|
9248
|
-
}),
|
|
9249
|
-
meta:
|
|
9250
|
-
fallback:
|
|
9251
|
-
}),
|
|
9252
|
-
meta:
|
|
9253
|
-
target:
|
|
9254
|
-
}),
|
|
9284
|
+
bounds: f
|
|
9285
|
+
}), m = t._normalizeMeta({
|
|
9286
|
+
meta: u,
|
|
9287
|
+
fallback: p
|
|
9288
|
+
}), h = t._calculateScale({
|
|
9289
|
+
meta: m,
|
|
9290
|
+
target: p
|
|
9291
|
+
}), g = !!m.positionsNormalized, _ = !1, v = !1;
|
|
9255
9292
|
i.suspendHistory();
|
|
9256
9293
|
try {
|
|
9257
|
-
let r = await t._enlivenObjects(
|
|
9294
|
+
let r = await t._enlivenObjects(l);
|
|
9258
9295
|
if (!r.length) return a.emitWarning({
|
|
9259
9296
|
origin: "TemplateManager",
|
|
9260
9297
|
method: "applyTemplate",
|
|
9261
|
-
code:
|
|
9298
|
+
code: Gr.TEMPLATE_MANAGER.INVALID_TEMPLATE,
|
|
9262
9299
|
message: "Не удалось создать объекты шаблона"
|
|
9263
9300
|
}), null;
|
|
9264
|
-
let { backgroundObject: i, contentObjects:
|
|
9265
|
-
i && (
|
|
9301
|
+
let { backgroundObject: i, contentObjects: u } = t._extractBackgroundObject(r);
|
|
9302
|
+
i && (v = await t._applyBackgroundFromObject({
|
|
9266
9303
|
backgroundObject: i,
|
|
9267
9304
|
backgroundManager: o,
|
|
9268
9305
|
errorManager: a
|
|
9269
9306
|
}));
|
|
9270
|
-
let
|
|
9307
|
+
let d = u.map((e) => (this._adaptTextboxWidth({
|
|
9271
9308
|
object: e,
|
|
9272
|
-
baseWidth:
|
|
9309
|
+
baseWidth: m.baseWidth
|
|
9273
9310
|
}), this._transformObject({
|
|
9274
9311
|
object: e,
|
|
9275
|
-
scale:
|
|
9276
|
-
bounds:
|
|
9277
|
-
baseWidth:
|
|
9278
|
-
baseHeight:
|
|
9279
|
-
useRelativePositions:
|
|
9280
|
-
}),
|
|
9312
|
+
scale: h,
|
|
9313
|
+
bounds: f,
|
|
9314
|
+
baseWidth: m.baseWidth,
|
|
9315
|
+
baseHeight: m.baseHeight,
|
|
9316
|
+
useRelativePositions: g
|
|
9317
|
+
}), c.commitStandaloneTextScale({ target: e }), s.commitRehydratedShapeLayout({
|
|
9318
|
+
target: e,
|
|
9319
|
+
textScale: h
|
|
9320
|
+
}), Vt({ object: e }), e.set({
|
|
9281
9321
|
id: `${e.type}-${D()}`,
|
|
9282
9322
|
evented: !0
|
|
9283
9323
|
}), n.add(e), e));
|
|
9284
|
-
return !
|
|
9324
|
+
return !d.length && !v ? null : (_ = d.length > 0 || v, d.length && t._activateObjects({
|
|
9285
9325
|
canvas: n,
|
|
9286
|
-
objects:
|
|
9326
|
+
objects: d
|
|
9287
9327
|
}), n.requestRenderAll(), n.fire("editor:template-applied", {
|
|
9288
9328
|
template: e,
|
|
9289
|
-
objects:
|
|
9290
|
-
bounds:
|
|
9291
|
-
}),
|
|
9329
|
+
objects: d,
|
|
9330
|
+
bounds: f
|
|
9331
|
+
}), d);
|
|
9292
9332
|
} catch (e) {
|
|
9293
9333
|
return a.emitError({
|
|
9294
9334
|
origin: "TemplateManager",
|
|
9295
9335
|
method: "applyTemplate",
|
|
9296
|
-
code:
|
|
9336
|
+
code: Gr.TEMPLATE_MANAGER.APPLY_FAILED,
|
|
9297
9337
|
message: "Ошибка применения шаблона",
|
|
9298
9338
|
data: {
|
|
9299
|
-
templateId:
|
|
9339
|
+
templateId: d,
|
|
9300
9340
|
error: e
|
|
9301
9341
|
}
|
|
9302
9342
|
}), null;
|
|
9303
9343
|
} finally {
|
|
9304
|
-
i.resumeHistory(),
|
|
9344
|
+
i.resumeHistory(), _ && i.saveState();
|
|
9305
9345
|
}
|
|
9306
9346
|
}
|
|
9307
9347
|
static _collectObjects(t) {
|
|
@@ -9447,8 +9487,8 @@ var ui = class {
|
|
|
9447
9487
|
baseHeight: a,
|
|
9448
9488
|
scale: n,
|
|
9449
9489
|
useRelativePositions: o,
|
|
9450
|
-
anchorX: t._resolveAnchor(s,
|
|
9451
|
-
anchorY: t._resolveAnchor(s,
|
|
9490
|
+
anchorX: t._resolveAnchor(s, Ci),
|
|
9491
|
+
anchorY: t._resolveAnchor(s, wi)
|
|
9452
9492
|
})
|
|
9453
9493
|
}), h = f * n, g = p * n, _ = e.originX ?? "center", v = e.originY ?? "center";
|
|
9454
9494
|
e.set({
|
|
@@ -9462,7 +9502,7 @@ var ui = class {
|
|
|
9462
9502
|
originX: _,
|
|
9463
9503
|
originY: v
|
|
9464
9504
|
}
|
|
9465
|
-
}), delete s[
|
|
9505
|
+
}), delete s[Ci], delete s[wi];
|
|
9466
9506
|
}
|
|
9467
9507
|
static _getPositioningBounds({ bounds: e, baseWidth: n, baseHeight: r, scale: i, useRelativePositions: a, anchorX: o, anchorY: s }) {
|
|
9468
9508
|
if (!a) return e;
|
|
@@ -9526,7 +9566,7 @@ var ui = class {
|
|
|
9526
9566
|
});
|
|
9527
9567
|
if (!i || !s || !o) return;
|
|
9528
9568
|
e.setCoords();
|
|
9529
|
-
let c = e, l = t._resolveAnchor(c,
|
|
9569
|
+
let c = e, l = t._resolveAnchor(c, Ci), u = typeof c.left == "number" ? c.left : null, d = e.originX ?? "center", f = e.originY ?? "center", p = e.getPointByOrigin(d, f), m = e.getBoundingRect(!1, !0), h = m.left + m.width;
|
|
9530
9570
|
e.set("width", i), e.initDimensions();
|
|
9531
9571
|
let g = t._getLongestLineWidth({
|
|
9532
9572
|
textbox: e,
|
|
@@ -9555,10 +9595,10 @@ var ui = class {
|
|
|
9555
9595
|
x: (p.left - o) / d,
|
|
9556
9596
|
y: (p.top - s) / f
|
|
9557
9597
|
}, h = (u.left - o) / d, g = (u.top - s) / f, _ = h + u.width / d, v = g + u.height / f;
|
|
9558
|
-
return a[
|
|
9598
|
+
return a[Ci] = t._detectAnchor({
|
|
9559
9599
|
start: h,
|
|
9560
9600
|
end: _
|
|
9561
|
-
}), a[
|
|
9601
|
+
}), a[wi] = t._detectAnchor({
|
|
9562
9602
|
start: g,
|
|
9563
9603
|
end: v
|
|
9564
9604
|
}), a.left = m.x, a.top = m.y, a;
|
|
@@ -9583,7 +9623,7 @@ var ui = class {
|
|
|
9583
9623
|
withoutSave: !0
|
|
9584
9624
|
}), !0;
|
|
9585
9625
|
if (a === "gradient") {
|
|
9586
|
-
let e =
|
|
9626
|
+
let e = Si(r);
|
|
9587
9627
|
if (e) return n.setGradientBackground({
|
|
9588
9628
|
gradient: e,
|
|
9589
9629
|
customData: o,
|
|
@@ -9604,7 +9644,7 @@ var ui = class {
|
|
|
9604
9644
|
r.emitWarning({
|
|
9605
9645
|
origin: "TemplateManager",
|
|
9606
9646
|
method: "applyTemplate",
|
|
9607
|
-
code:
|
|
9647
|
+
code: Gr.TEMPLATE_MANAGER.APPLY_FAILED,
|
|
9608
9648
|
message: "Не удалось применить фон из шаблона",
|
|
9609
9649
|
data: e
|
|
9610
9650
|
});
|
|
@@ -9640,29 +9680,29 @@ var ui = class {
|
|
|
9640
9680
|
enlivenObjectEnlivables(e) {
|
|
9641
9681
|
return C.enlivenObjectEnlivables(e);
|
|
9642
9682
|
}
|
|
9643
|
-
},
|
|
9644
|
-
let n =
|
|
9683
|
+
}, Ei = "#3D8BF4", Di = .5, Oi = ({ distance: e }) => Number.isFinite(e) ? Math.round(Math.max(0, e)) : 0, ki = ({ firstDistance: e, secondDistance: t }) => {
|
|
9684
|
+
let n = Oi({ distance: e }), r = Oi({ distance: t });
|
|
9645
9685
|
return {
|
|
9646
9686
|
firstDisplayDistance: n,
|
|
9647
9687
|
secondDisplayDistance: r,
|
|
9648
9688
|
displayDistanceDiff: Math.abs(n - r),
|
|
9649
9689
|
commonDisplayDistance: Math.max(n, r)
|
|
9650
9690
|
};
|
|
9651
|
-
},
|
|
9691
|
+
}, Ai = ({ firstStart: e, firstEnd: t, secondStart: n, secondEnd: r }) => Math.min(t, r) - Math.max(e, n), ji = ({ step: e }) => {
|
|
9652
9692
|
let t = Math.abs(e).toString(), n = t.indexOf(".");
|
|
9653
9693
|
return n === -1 ? 0 : t.slice(n + 1).length;
|
|
9654
|
-
},
|
|
9694
|
+
}, Mi = ({ value: e, step: t }) => {
|
|
9655
9695
|
if (t === 0) return e;
|
|
9656
|
-
let n =
|
|
9696
|
+
let n = ji({ step: t }), r = Math.round(e / t) * t;
|
|
9657
9697
|
return Number(r.toFixed(n));
|
|
9658
|
-
},
|
|
9698
|
+
}, Ni = ({ value: e, step: t }) => {
|
|
9659
9699
|
if (t === 0) return !0;
|
|
9660
|
-
let n =
|
|
9700
|
+
let n = Mi({
|
|
9661
9701
|
value: e,
|
|
9662
9702
|
step: t
|
|
9663
|
-
}), r = 10 ** -(
|
|
9703
|
+
}), r = 10 ** -(ji({ step: t }) + 4);
|
|
9664
9704
|
return Math.abs(n - e) <= r;
|
|
9665
|
-
},
|
|
9705
|
+
}, Pi = ({ bounds: e, axis: t }) => {
|
|
9666
9706
|
let { left: n = 0, right: r = 0, top: i = 0, bottom: a = 0 } = e;
|
|
9667
9707
|
return t === "vertical" ? {
|
|
9668
9708
|
start: i,
|
|
@@ -9671,7 +9711,7 @@ var ui = class {
|
|
|
9671
9711
|
start: n,
|
|
9672
9712
|
end: r
|
|
9673
9713
|
};
|
|
9674
|
-
},
|
|
9714
|
+
}, Fi = ({ items: e, axis: t }) => {
|
|
9675
9715
|
for (let n = 1; n < e.length; n += 1) {
|
|
9676
9716
|
let r = e[n], { bounds: i } = r, a = i[t], o = n - 1;
|
|
9677
9717
|
for (; o >= 0;) {
|
|
@@ -9681,10 +9721,10 @@ var ui = class {
|
|
|
9681
9721
|
}
|
|
9682
9722
|
e[o + 1] = r;
|
|
9683
9723
|
}
|
|
9684
|
-
},
|
|
9724
|
+
}, Ii = ({ items: e, index: t, axis: n, direction: r }) => {
|
|
9685
9725
|
let i = e[t];
|
|
9686
9726
|
if (!i) return null;
|
|
9687
|
-
let { bounds: a } = i, { start: o, end: s } =
|
|
9727
|
+
let { bounds: a } = i, { start: o, end: s } = Pi({
|
|
9688
9728
|
bounds: a,
|
|
9689
9729
|
axis: n
|
|
9690
9730
|
});
|
|
@@ -9692,7 +9732,7 @@ var ui = class {
|
|
|
9692
9732
|
for (let r = t - 1; r >= 0; --r) {
|
|
9693
9733
|
let t = e[r];
|
|
9694
9734
|
if (!t) continue;
|
|
9695
|
-
let { bounds: i } = t, { end: a } =
|
|
9735
|
+
let { bounds: i } = t, { end: a } = Pi({
|
|
9696
9736
|
bounds: i,
|
|
9697
9737
|
axis: n
|
|
9698
9738
|
});
|
|
@@ -9703,26 +9743,26 @@ var ui = class {
|
|
|
9703
9743
|
for (let r = t + 1; r < e.length; r += 1) {
|
|
9704
9744
|
let t = e[r];
|
|
9705
9745
|
if (!t) continue;
|
|
9706
|
-
let { bounds: i } = t, { start: a } =
|
|
9746
|
+
let { bounds: i } = t, { start: a } = Pi({
|
|
9707
9747
|
bounds: i,
|
|
9708
9748
|
axis: n
|
|
9709
9749
|
});
|
|
9710
9750
|
if (a - s >= 0) return r;
|
|
9711
9751
|
}
|
|
9712
9752
|
return null;
|
|
9713
|
-
},
|
|
9753
|
+
}, Li = ({ items: e }) => {
|
|
9714
9754
|
for (let t = 0; t < e.length; t += 1) {
|
|
9715
9755
|
let { isActive: n } = e[t];
|
|
9716
9756
|
if (n) return t;
|
|
9717
9757
|
}
|
|
9718
9758
|
return -1;
|
|
9719
|
-
},
|
|
9759
|
+
}, Ri = ({ patternAxis: e, activeRangeStart: t, activeRangeEnd: n, tolerance: r = 0 }) => {
|
|
9720
9760
|
let i = Math.min(t, n), a = Math.max(t, n);
|
|
9721
9761
|
return e >= i - r && e <= a + r;
|
|
9722
|
-
},
|
|
9762
|
+
}, zi = ({ patternStart: e, patternEnd: t, activeStart: n, activeEnd: r }) => t <= n ? "before" : e >= r ? "after" : null, Bi = ({ baseOption: e, candidateOption: t }) => {
|
|
9723
9763
|
let { delta: n, guide: { distance: r } } = e, { delta: i, guide: { distance: a } } = t;
|
|
9724
9764
|
return n === i && r === a;
|
|
9725
|
-
},
|
|
9765
|
+
}, Vi = ({ options: e }) => {
|
|
9726
9766
|
let t = e[0];
|
|
9727
9767
|
for (let n = 1; n < e.length; n += 1) {
|
|
9728
9768
|
let r = e[n];
|
|
@@ -9733,11 +9773,11 @@ var ui = class {
|
|
|
9733
9773
|
r.diff === t.diff && Math.abs(r.delta) < Math.abs(t.delta) && (t = r);
|
|
9734
9774
|
}
|
|
9735
9775
|
return t;
|
|
9736
|
-
},
|
|
9776
|
+
}, Hi = ({ currentOption: e, nextOption: t }) => {
|
|
9737
9777
|
if (!e) return !0;
|
|
9738
9778
|
let { contextDistance: n, diff: r, delta: i } = e, { contextDistance: a, diff: o, delta: s } = t;
|
|
9739
9779
|
return a < n ? !0 : a > n ? !1 : o < r ? !0 : o > r ? !1 : Math.abs(s) < Math.abs(i);
|
|
9740
|
-
},
|
|
9780
|
+
}, Ui = ({ options: e }) => {
|
|
9741
9781
|
let t = [], n = null, r = null;
|
|
9742
9782
|
for (let i of e) {
|
|
9743
9783
|
let { kind: e, side: a } = i;
|
|
@@ -9745,18 +9785,18 @@ var ui = class {
|
|
|
9745
9785
|
t.push(i);
|
|
9746
9786
|
continue;
|
|
9747
9787
|
}
|
|
9748
|
-
a === "before" &&
|
|
9788
|
+
a === "before" && Hi({
|
|
9749
9789
|
currentOption: n,
|
|
9750
9790
|
nextOption: i
|
|
9751
|
-
}) && (n = i), a === "after" &&
|
|
9791
|
+
}) && (n = i), a === "after" && Hi({
|
|
9752
9792
|
currentOption: r,
|
|
9753
9793
|
nextOption: i
|
|
9754
9794
|
}) && (r = i);
|
|
9755
9795
|
}
|
|
9756
9796
|
return n && t.push(n), r && t.push(r), t;
|
|
9757
|
-
},
|
|
9797
|
+
}, Wi = ({ options: e, side: t, baseOption: n }) => {
|
|
9758
9798
|
let r = null;
|
|
9759
|
-
for (let i of e) if (i.side === t &&
|
|
9799
|
+
for (let i of e) if (i.side === t && Bi({
|
|
9760
9800
|
baseOption: n,
|
|
9761
9801
|
candidateOption: i
|
|
9762
9802
|
})) {
|
|
@@ -9767,63 +9807,63 @@ var ui = class {
|
|
|
9767
9807
|
!r || i.diff !== r.diff || Math.abs(i.delta) < Math.abs(r.delta) && (r = i);
|
|
9768
9808
|
}
|
|
9769
9809
|
return r;
|
|
9770
|
-
},
|
|
9810
|
+
}, Gi = ({ option: e }) => {
|
|
9771
9811
|
let { side: t, kind: n, guide: { distance: r } } = e;
|
|
9772
9812
|
return {
|
|
9773
9813
|
side: t,
|
|
9774
9814
|
kind: n,
|
|
9775
9815
|
distance: r
|
|
9776
9816
|
};
|
|
9777
|
-
},
|
|
9817
|
+
}, Ki = ({ option: e, context: t }) => {
|
|
9778
9818
|
let { side: n, kind: r, distance: i } = t, { side: a, kind: o, guide: { distance: s } } = e;
|
|
9779
9819
|
return n !== a || r !== o ? !1 : Math.abs(s - i) <= 1;
|
|
9780
|
-
},
|
|
9820
|
+
}, qi = ({ options: e, context: t }) => {
|
|
9781
9821
|
if (!t) return null;
|
|
9782
|
-
for (let n of e) if (
|
|
9822
|
+
for (let n of e) if (Ki({
|
|
9783
9823
|
option: n,
|
|
9784
9824
|
context: t
|
|
9785
9825
|
})) return n;
|
|
9786
9826
|
return null;
|
|
9787
|
-
},
|
|
9788
|
-
let i =
|
|
9827
|
+
}, Ji = ({ options: e, bestOption: t, previousContext: n, switchDistance: r = 0 }) => {
|
|
9828
|
+
let i = qi({
|
|
9789
9829
|
options: e,
|
|
9790
9830
|
context: n
|
|
9791
9831
|
});
|
|
9792
9832
|
if (!i) return t;
|
|
9793
9833
|
let a = Math.max(0, r);
|
|
9794
9834
|
return a === 0 || Math.abs(t.delta - i.delta) >= a ? t : i;
|
|
9795
|
-
},
|
|
9835
|
+
}, Yi = ({ guides: e, seenGuideKeys: t, guide: n }) => {
|
|
9796
9836
|
let { type: r, axis: i, refStart: a, refEnd: o, activeStart: s, activeEnd: c, distance: l } = n, u = `${r}:${i}:${a}:${o}:${s}:${c}:${l}`;
|
|
9797
9837
|
t.has(u) || (t.add(u), e.push(n));
|
|
9798
|
-
},
|
|
9838
|
+
}, Xi = ({ options: e, previousContext: t = null, switchDistance: n = 0 }) => {
|
|
9799
9839
|
if (!e.length) return {
|
|
9800
9840
|
delta: 0,
|
|
9801
9841
|
guides: [],
|
|
9802
9842
|
context: null
|
|
9803
9843
|
};
|
|
9804
|
-
let r =
|
|
9844
|
+
let r = Ui({ options: e }), i = [];
|
|
9805
9845
|
for (let e of r) e.kind === "reference" && i.push(e);
|
|
9806
|
-
let a = i.length > 0, o = a ? i : r, s =
|
|
9846
|
+
let a = i.length > 0, o = a ? i : r, s = Ji({
|
|
9807
9847
|
options: o,
|
|
9808
|
-
bestOption:
|
|
9848
|
+
bestOption: Vi({ options: o }),
|
|
9809
9849
|
previousContext: t,
|
|
9810
9850
|
switchDistance: n
|
|
9811
|
-
}), c =
|
|
9851
|
+
}), c = Wi({
|
|
9812
9852
|
options: o,
|
|
9813
9853
|
side: "before",
|
|
9814
9854
|
baseOption: s
|
|
9815
|
-
}), l =
|
|
9855
|
+
}), l = Wi({
|
|
9816
9856
|
options: o,
|
|
9817
9857
|
side: "after",
|
|
9818
9858
|
baseOption: s
|
|
9819
|
-
}), u =
|
|
9859
|
+
}), u = Wi({
|
|
9820
9860
|
options: a ? r : o,
|
|
9821
9861
|
side: "center",
|
|
9822
9862
|
baseOption: s
|
|
9823
9863
|
}), d = [];
|
|
9824
9864
|
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);
|
|
9825
9865
|
let f = [], p = /* @__PURE__ */ new Set();
|
|
9826
|
-
for (let e of d)
|
|
9866
|
+
for (let e of d) Yi({
|
|
9827
9867
|
guides: f,
|
|
9828
9868
|
seenGuideKeys: p,
|
|
9829
9869
|
guide: e.guide
|
|
@@ -9831,15 +9871,15 @@ var ui = class {
|
|
|
9831
9871
|
return {
|
|
9832
9872
|
delta: s.delta,
|
|
9833
9873
|
guides: f,
|
|
9834
|
-
context:
|
|
9874
|
+
context: Gi({ option: s })
|
|
9835
9875
|
};
|
|
9836
|
-
},
|
|
9837
|
-
let s = n - (e - r), c =
|
|
9876
|
+
}, Zi = ({ activeStart: e, activeEnd: t, targetGap: n, beforeEdge: r, afterEdge: i, threshold: a, step: o }) => {
|
|
9877
|
+
let s = n - (e - r), c = Mi({
|
|
9838
9878
|
value: s,
|
|
9839
9879
|
step: o
|
|
9840
9880
|
}), l = Math.max(1, Math.ceil(a / Math.max(o, 1))), u = null;
|
|
9841
9881
|
for (let d = -l; d <= l; d += 1) {
|
|
9842
|
-
let l = c + d * o, f = e + l, p = t + l, m = f - r, h = i - p, { displayDistanceDiff: g, commonDisplayDistance: _ } =
|
|
9882
|
+
let l = c + d * o, f = e + l, p = t + l, m = f - r, h = i - p, { displayDistanceDiff: g, commonDisplayDistance: _ } = ki({
|
|
9843
9883
|
firstDistance: m,
|
|
9844
9884
|
secondDistance: h
|
|
9845
9885
|
});
|
|
@@ -9854,13 +9894,13 @@ var ui = class {
|
|
|
9854
9894
|
});
|
|
9855
9895
|
}
|
|
9856
9896
|
return u;
|
|
9857
|
-
},
|
|
9858
|
-
let { secondDisplayDistance: n, displayDistanceDiff: r } =
|
|
9897
|
+
}, Qi = ({ currentGap: e, referenceGap: t }) => {
|
|
9898
|
+
let { secondDisplayDistance: n, displayDistanceDiff: r } = ki({
|
|
9859
9899
|
firstDistance: e,
|
|
9860
9900
|
secondDistance: t
|
|
9861
9901
|
});
|
|
9862
9902
|
return r > 1 ? null : n;
|
|
9863
|
-
},
|
|
9903
|
+
}, $i = ({ anchors: e, positions: t, threshold: n }) => {
|
|
9864
9904
|
let r = 0, i = n + 1, a = null;
|
|
9865
9905
|
for (let o of t) for (let t of e) {
|
|
9866
9906
|
let e = Math.abs(t - o);
|
|
@@ -9870,8 +9910,8 @@ var ui = class {
|
|
|
9870
9910
|
delta: r,
|
|
9871
9911
|
guidePosition: a
|
|
9872
9912
|
};
|
|
9873
|
-
},
|
|
9874
|
-
let { left: r, right: i, centerX: a, top: o, bottom: s, centerY: c } = e, l =
|
|
9913
|
+
}, ea = ({ activeBounds: e, threshold: t, anchors: n }) => {
|
|
9914
|
+
let { left: r, right: i, centerX: a, top: o, bottom: s, centerY: c } = e, l = $i({
|
|
9875
9915
|
anchors: n.vertical,
|
|
9876
9916
|
positions: [
|
|
9877
9917
|
r,
|
|
@@ -9879,7 +9919,7 @@ var ui = class {
|
|
|
9879
9919
|
i
|
|
9880
9920
|
],
|
|
9881
9921
|
threshold: t
|
|
9882
|
-
}), u =
|
|
9922
|
+
}), u = $i({
|
|
9883
9923
|
anchors: n.horizontal,
|
|
9884
9924
|
positions: [
|
|
9885
9925
|
o,
|
|
@@ -9899,11 +9939,11 @@ var ui = class {
|
|
|
9899
9939
|
deltaY: u.delta,
|
|
9900
9940
|
guides: d
|
|
9901
9941
|
};
|
|
9902
|
-
},
|
|
9942
|
+
}, ta = ({ activeBounds: e, candidates: t, threshold: n, patterns: r, previousContext: i = null, switchDistance: a = 0 }) => {
|
|
9903
9943
|
let { centerX: o, top: s, bottom: c, left: l, right: u } = e, d = [];
|
|
9904
9944
|
for (let e of t) {
|
|
9905
9945
|
let { left: t, right: n } = e;
|
|
9906
|
-
|
|
9946
|
+
Ai({
|
|
9907
9947
|
firstStart: t,
|
|
9908
9948
|
firstEnd: n,
|
|
9909
9949
|
secondStart: l,
|
|
@@ -9923,22 +9963,22 @@ var ui = class {
|
|
|
9923
9963
|
f.push({
|
|
9924
9964
|
bounds: e,
|
|
9925
9965
|
isActive: !0
|
|
9926
|
-
}),
|
|
9966
|
+
}), Fi({
|
|
9927
9967
|
items: f,
|
|
9928
9968
|
axis: "top"
|
|
9929
9969
|
});
|
|
9930
|
-
let p =
|
|
9970
|
+
let p = Li({ items: f });
|
|
9931
9971
|
if (p === -1) return {
|
|
9932
9972
|
delta: 0,
|
|
9933
9973
|
guides: [],
|
|
9934
9974
|
context: null
|
|
9935
9975
|
};
|
|
9936
|
-
let m = [], h = c - s, g =
|
|
9976
|
+
let m = [], h = c - s, g = Ii({
|
|
9937
9977
|
items: f,
|
|
9938
9978
|
index: p,
|
|
9939
9979
|
axis: "vertical",
|
|
9940
9980
|
direction: "prev"
|
|
9941
|
-
}), _ =
|
|
9981
|
+
}), _ = Ii({
|
|
9942
9982
|
items: f,
|
|
9943
9983
|
index: p,
|
|
9944
9984
|
axis: "vertical",
|
|
@@ -9947,19 +9987,19 @@ var ui = class {
|
|
|
9947
9987
|
if (v && y) {
|
|
9948
9988
|
let { bounds: e } = v, { bounds: t } = y, { bottom: r } = e, { top: i } = t, a = i - r - h;
|
|
9949
9989
|
if (a >= 0) {
|
|
9950
|
-
let e =
|
|
9990
|
+
let e = Mi({
|
|
9951
9991
|
value: a / 2,
|
|
9952
9992
|
step: 1
|
|
9953
9993
|
}), t = s - r, l = i - c, u = Math.abs(t - e), d = Math.abs(l - e);
|
|
9954
9994
|
if (Math.max(u, d) <= n) {
|
|
9955
|
-
let t =
|
|
9995
|
+
let t = Zi({
|
|
9956
9996
|
activeStart: s,
|
|
9957
9997
|
activeEnd: c,
|
|
9958
9998
|
targetGap: e,
|
|
9959
9999
|
beforeEdge: r,
|
|
9960
10000
|
afterEdge: i,
|
|
9961
10001
|
threshold: n,
|
|
9962
|
-
step:
|
|
10002
|
+
step: Di
|
|
9963
10003
|
});
|
|
9964
10004
|
if (t) {
|
|
9965
10005
|
let { delta: e, distance: n, diff: i, activeStart: a, activeEnd: s } = t, c = {
|
|
@@ -9996,16 +10036,16 @@ var ui = class {
|
|
|
9996
10036
|
}
|
|
9997
10037
|
for (let e of r) {
|
|
9998
10038
|
let { axis: t, start: r, end: i, distance: a } = e;
|
|
9999
|
-
if (!
|
|
10039
|
+
if (!Ni({
|
|
10000
10040
|
value: a,
|
|
10001
10041
|
step: .5
|
|
10002
|
-
}) || !
|
|
10042
|
+
}) || !Ri({
|
|
10003
10043
|
patternAxis: t,
|
|
10004
10044
|
activeRangeStart: l,
|
|
10005
10045
|
activeRangeEnd: u,
|
|
10006
10046
|
tolerance: n
|
|
10007
10047
|
})) continue;
|
|
10008
|
-
let d =
|
|
10048
|
+
let d = zi({
|
|
10009
10049
|
patternStart: r,
|
|
10010
10050
|
patternEnd: i,
|
|
10011
10051
|
activeStart: s,
|
|
@@ -10013,12 +10053,12 @@ var ui = class {
|
|
|
10013
10053
|
});
|
|
10014
10054
|
if (d) {
|
|
10015
10055
|
if (b !== null && S && d === "before" && Math.abs(b - a) <= n) {
|
|
10016
|
-
let e =
|
|
10056
|
+
let e = Mi({
|
|
10017
10057
|
value: a - b,
|
|
10018
10058
|
step: 1
|
|
10019
10059
|
}), t = s + e, { bottom: c } = S, l = t - c, u = Math.abs(l - a);
|
|
10020
10060
|
if (u > n) continue;
|
|
10021
|
-
let d =
|
|
10061
|
+
let d = Qi({
|
|
10022
10062
|
currentGap: l,
|
|
10023
10063
|
referenceGap: a
|
|
10024
10064
|
});
|
|
@@ -10042,12 +10082,12 @@ var ui = class {
|
|
|
10042
10082
|
});
|
|
10043
10083
|
}
|
|
10044
10084
|
if (x !== null && C && d === "after" && Math.abs(x - a) <= n) {
|
|
10045
|
-
let e =
|
|
10085
|
+
let e = Mi({
|
|
10046
10086
|
value: x - a,
|
|
10047
10087
|
step: 1
|
|
10048
10088
|
}), t = c + e, { top: s } = C, l = s - t, u = Math.abs(l - a);
|
|
10049
10089
|
if (u > n) continue;
|
|
10050
|
-
let d =
|
|
10090
|
+
let d = Qi({
|
|
10051
10091
|
currentGap: l,
|
|
10052
10092
|
referenceGap: a
|
|
10053
10093
|
});
|
|
@@ -10072,16 +10112,16 @@ var ui = class {
|
|
|
10072
10112
|
}
|
|
10073
10113
|
}
|
|
10074
10114
|
}
|
|
10075
|
-
return
|
|
10115
|
+
return Xi({
|
|
10076
10116
|
options: m,
|
|
10077
10117
|
previousContext: i,
|
|
10078
10118
|
switchDistance: a
|
|
10079
10119
|
});
|
|
10080
|
-
},
|
|
10120
|
+
}, na = ({ activeBounds: e, candidates: t, threshold: n, patterns: r, previousContext: i = null, switchDistance: a = 0 }) => {
|
|
10081
10121
|
let { centerY: o, left: s, right: c, top: l, bottom: u } = e, d = [];
|
|
10082
10122
|
for (let e of t) {
|
|
10083
10123
|
let { top: t, bottom: n } = e;
|
|
10084
|
-
|
|
10124
|
+
Ai({
|
|
10085
10125
|
firstStart: t,
|
|
10086
10126
|
firstEnd: n,
|
|
10087
10127
|
secondStart: l,
|
|
@@ -10101,22 +10141,22 @@ var ui = class {
|
|
|
10101
10141
|
f.push({
|
|
10102
10142
|
bounds: e,
|
|
10103
10143
|
isActive: !0
|
|
10104
|
-
}),
|
|
10144
|
+
}), Fi({
|
|
10105
10145
|
items: f,
|
|
10106
10146
|
axis: "left"
|
|
10107
10147
|
});
|
|
10108
|
-
let p =
|
|
10148
|
+
let p = Li({ items: f });
|
|
10109
10149
|
if (p === -1) return {
|
|
10110
10150
|
delta: 0,
|
|
10111
10151
|
guides: [],
|
|
10112
10152
|
context: null
|
|
10113
10153
|
};
|
|
10114
|
-
let m = [], h = c - s, g =
|
|
10154
|
+
let m = [], h = c - s, g = Ii({
|
|
10115
10155
|
items: f,
|
|
10116
10156
|
index: p,
|
|
10117
10157
|
axis: "horizontal",
|
|
10118
10158
|
direction: "prev"
|
|
10119
|
-
}), _ =
|
|
10159
|
+
}), _ = Ii({
|
|
10120
10160
|
items: f,
|
|
10121
10161
|
index: p,
|
|
10122
10162
|
axis: "horizontal",
|
|
@@ -10125,19 +10165,19 @@ var ui = class {
|
|
|
10125
10165
|
if (v && y) {
|
|
10126
10166
|
let { bounds: e } = v, { bounds: t } = y, { right: r } = e, { left: i } = t, a = i - r - h;
|
|
10127
10167
|
if (a >= 0) {
|
|
10128
|
-
let e =
|
|
10168
|
+
let e = Mi({
|
|
10129
10169
|
value: a / 2,
|
|
10130
10170
|
step: 1
|
|
10131
10171
|
}), t = s - r, l = i - c, u = Math.abs(t - e), d = Math.abs(l - e);
|
|
10132
10172
|
if (Math.max(u, d) <= n) {
|
|
10133
|
-
let t =
|
|
10173
|
+
let t = Zi({
|
|
10134
10174
|
activeStart: s,
|
|
10135
10175
|
activeEnd: c,
|
|
10136
10176
|
targetGap: e,
|
|
10137
10177
|
beforeEdge: r,
|
|
10138
10178
|
afterEdge: i,
|
|
10139
10179
|
threshold: n,
|
|
10140
|
-
step:
|
|
10180
|
+
step: Di
|
|
10141
10181
|
});
|
|
10142
10182
|
if (t) {
|
|
10143
10183
|
let { delta: e, distance: n, diff: i, activeStart: a, activeEnd: s } = t, c = {
|
|
@@ -10174,16 +10214,16 @@ var ui = class {
|
|
|
10174
10214
|
}
|
|
10175
10215
|
for (let e of r) {
|
|
10176
10216
|
let { axis: t, start: r, end: i, distance: a } = e;
|
|
10177
|
-
if (!
|
|
10217
|
+
if (!Ni({
|
|
10178
10218
|
value: a,
|
|
10179
10219
|
step: .5
|
|
10180
|
-
}) || !
|
|
10220
|
+
}) || !Ri({
|
|
10181
10221
|
patternAxis: t,
|
|
10182
10222
|
activeRangeStart: l,
|
|
10183
10223
|
activeRangeEnd: u,
|
|
10184
10224
|
tolerance: n
|
|
10185
10225
|
})) continue;
|
|
10186
|
-
let d =
|
|
10226
|
+
let d = zi({
|
|
10187
10227
|
patternStart: r,
|
|
10188
10228
|
patternEnd: i,
|
|
10189
10229
|
activeStart: s,
|
|
@@ -10191,12 +10231,12 @@ var ui = class {
|
|
|
10191
10231
|
});
|
|
10192
10232
|
if (d) {
|
|
10193
10233
|
if (b !== null && S && d === "before" && Math.abs(b - a) <= n) {
|
|
10194
|
-
let e =
|
|
10234
|
+
let e = Mi({
|
|
10195
10235
|
value: a - b,
|
|
10196
10236
|
step: 1
|
|
10197
10237
|
}), t = s + e, { right: c } = S, l = t - c, u = Math.abs(l - a);
|
|
10198
10238
|
if (u > n) continue;
|
|
10199
|
-
let d =
|
|
10239
|
+
let d = Qi({
|
|
10200
10240
|
currentGap: l,
|
|
10201
10241
|
referenceGap: a
|
|
10202
10242
|
});
|
|
@@ -10220,12 +10260,12 @@ var ui = class {
|
|
|
10220
10260
|
});
|
|
10221
10261
|
}
|
|
10222
10262
|
if (x !== null && C && d === "after" && Math.abs(x - a) <= n) {
|
|
10223
|
-
let e =
|
|
10263
|
+
let e = Mi({
|
|
10224
10264
|
value: x - a,
|
|
10225
10265
|
step: 1
|
|
10226
10266
|
}), t = c + e, { left: s } = C, l = s - t, u = Math.abs(l - a);
|
|
10227
10267
|
if (u > n) continue;
|
|
10228
|
-
let d =
|
|
10268
|
+
let d = Qi({
|
|
10229
10269
|
currentGap: l,
|
|
10230
10270
|
referenceGap: a
|
|
10231
10271
|
});
|
|
@@ -10250,20 +10290,20 @@ var ui = class {
|
|
|
10250
10290
|
}
|
|
10251
10291
|
}
|
|
10252
10292
|
}
|
|
10253
|
-
return
|
|
10293
|
+
return Xi({
|
|
10254
10294
|
options: m,
|
|
10255
10295
|
previousContext: i,
|
|
10256
10296
|
switchDistance: a
|
|
10257
10297
|
});
|
|
10258
|
-
},
|
|
10259
|
-
let { vertical: o = null, horizontal: s = null } = i ?? {}, c =
|
|
10298
|
+
}, ra = ({ activeBounds: e, candidates: t, threshold: n, spacingPatterns: r, previousContexts: i, switchDistance: a = 0 }) => {
|
|
10299
|
+
let { vertical: o = null, horizontal: s = null } = i ?? {}, c = ta({
|
|
10260
10300
|
activeBounds: e,
|
|
10261
10301
|
candidates: t,
|
|
10262
10302
|
threshold: n,
|
|
10263
10303
|
patterns: r.vertical,
|
|
10264
10304
|
previousContext: o,
|
|
10265
10305
|
switchDistance: a
|
|
10266
|
-
}), l =
|
|
10306
|
+
}), l = na({
|
|
10267
10307
|
activeBounds: e,
|
|
10268
10308
|
candidates: t,
|
|
10269
10309
|
threshold: n,
|
|
@@ -10282,14 +10322,14 @@ var ui = class {
|
|
|
10282
10322
|
horizontal: l.context
|
|
10283
10323
|
}
|
|
10284
10324
|
};
|
|
10285
|
-
},
|
|
10325
|
+
}, ia = ({ context: e, x: t, y: n, width: r, height: i, radius: a }) => {
|
|
10286
10326
|
let o = Math.min(a, r / 2, i / 2);
|
|
10287
10327
|
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();
|
|
10288
|
-
},
|
|
10328
|
+
}, aa = ({ 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 }) => {
|
|
10289
10329
|
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;
|
|
10290
10330
|
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";
|
|
10291
10331
|
let S = e.measureText(a).width + _ * 2, C = g + _ * 2, w = b - S / 2, T = x - C / 2;
|
|
10292
|
-
e.beginPath(),
|
|
10332
|
+
e.beginPath(), ia({
|
|
10293
10333
|
context: e,
|
|
10294
10334
|
x: w,
|
|
10295
10335
|
y: T,
|
|
@@ -10297,11 +10337,11 @@ var ui = class {
|
|
|
10297
10337
|
height: C,
|
|
10298
10338
|
radius: v
|
|
10299
10339
|
}), e.fill(), e.fillStyle = c, e.fillText(a, b, x), e.restore();
|
|
10300
|
-
},
|
|
10301
|
-
let { type: r, axis: i, refStart: a, refEnd: o, activeStart: s, activeEnd: c, distance: l } = t, u =
|
|
10340
|
+
}, oa = ({ context: e, guide: t, zoom: n }) => {
|
|
10341
|
+
let { type: r, axis: i, refStart: a, refEnd: o, activeStart: s, activeEnd: c, distance: l } = t, u = Oi({ distance: l }).toString();
|
|
10302
10342
|
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();
|
|
10303
|
-
let d =
|
|
10304
|
-
|
|
10343
|
+
let d = Ei;
|
|
10344
|
+
aa({
|
|
10305
10345
|
context: e,
|
|
10306
10346
|
type: r,
|
|
10307
10347
|
axis: i,
|
|
@@ -10311,7 +10351,7 @@ var ui = class {
|
|
|
10311
10351
|
zoom: n,
|
|
10312
10352
|
color: d,
|
|
10313
10353
|
lineWidth: 1
|
|
10314
|
-
}),
|
|
10354
|
+
}), aa({
|
|
10315
10355
|
context: e,
|
|
10316
10356
|
type: r,
|
|
10317
10357
|
axis: i,
|
|
@@ -10322,10 +10362,10 @@ var ui = class {
|
|
|
10322
10362
|
color: d,
|
|
10323
10363
|
lineWidth: 1
|
|
10324
10364
|
});
|
|
10325
|
-
},
|
|
10365
|
+
}, sa = ({ anchors: e, bounds: t }) => {
|
|
10326
10366
|
let { left: n, right: r, centerX: i, top: a, bottom: o, centerY: s } = t;
|
|
10327
10367
|
e.vertical.push(n, i, r), e.horizontal.push(a, s, o);
|
|
10328
|
-
},
|
|
10368
|
+
}, ca = ({ bounds: e, type: t, primaryStart: n, primaryEnd: r }) => {
|
|
10329
10369
|
let i = [], a = n === "top" ? "left" : "top", o = r === "bottom" ? "right" : "bottom", s = [...e].sort((e, t) => e[n] - t[n]);
|
|
10330
10370
|
for (let e = 0; e < s.length; e += 1) {
|
|
10331
10371
|
let c = s[e], l = null, u = Infinity;
|
|
@@ -10346,35 +10386,35 @@ var ui = class {
|
|
|
10346
10386
|
});
|
|
10347
10387
|
}
|
|
10348
10388
|
return i;
|
|
10349
|
-
},
|
|
10350
|
-
vertical:
|
|
10389
|
+
}, la = ({ bounds: e }) => ({
|
|
10390
|
+
vertical: ca({
|
|
10351
10391
|
bounds: e,
|
|
10352
10392
|
axis: "centerX",
|
|
10353
10393
|
type: "vertical",
|
|
10354
10394
|
primaryStart: "top",
|
|
10355
10395
|
primaryEnd: "bottom"
|
|
10356
10396
|
}),
|
|
10357
|
-
horizontal:
|
|
10397
|
+
horizontal: ca({
|
|
10358
10398
|
bounds: e,
|
|
10359
10399
|
axis: "centerY",
|
|
10360
10400
|
type: "horizontal",
|
|
10361
10401
|
primaryStart: "left",
|
|
10362
10402
|
primaryEnd: "right"
|
|
10363
10403
|
})
|
|
10364
|
-
}),
|
|
10404
|
+
}), ua = [
|
|
10365
10405
|
"montage-area",
|
|
10366
10406
|
"background",
|
|
10367
10407
|
"interaction-blocker"
|
|
10368
|
-
],
|
|
10408
|
+
], da = ({ activeObject: t }) => {
|
|
10369
10409
|
let n = /* @__PURE__ */ new Set();
|
|
10370
10410
|
return t ? (n.add(t), t instanceof e && t.getObjects().forEach((e) => n.add(e)), n) : n;
|
|
10371
|
-
},
|
|
10411
|
+
}, fa = ({ object: e, excluded: t, ignoredIds: n = ua }) => {
|
|
10372
10412
|
if (t.has(e)) return !0;
|
|
10373
10413
|
let { visible: r = !0 } = e;
|
|
10374
10414
|
if (!r) return !0;
|
|
10375
10415
|
let { id: i } = e;
|
|
10376
10416
|
return !!(i && n.includes(i));
|
|
10377
|
-
},
|
|
10417
|
+
}, pa = class e {
|
|
10378
10418
|
constructor({ editor: e }) {
|
|
10379
10419
|
this.anchors = {
|
|
10380
10420
|
vertical: [],
|
|
@@ -10427,7 +10467,7 @@ var ui = class {
|
|
|
10427
10467
|
this._clearSpacingContexts(), this._clearGuides();
|
|
10428
10468
|
return;
|
|
10429
10469
|
}
|
|
10430
|
-
let { canvas: o } = this, s = o.getZoom() || 1, c = 5 / s, { deltaX: l, deltaY: u } =
|
|
10470
|
+
let { canvas: o } = this, s = o.getZoom() || 1, c = 5 / s, { deltaX: l, deltaY: u } = ea({
|
|
10431
10471
|
activeBounds: a,
|
|
10432
10472
|
threshold: c,
|
|
10433
10473
|
anchors: this.anchors
|
|
@@ -10439,7 +10479,7 @@ var ui = class {
|
|
|
10439
10479
|
top: t + u
|
|
10440
10480
|
}), n.setCoords(), a = Ht({ object: n }) ?? a;
|
|
10441
10481
|
}
|
|
10442
|
-
let d = this._resolveCurrentTargetBounds({ activeObject: n }), f = this.spacingContexts.vertical || this.spacingContexts.horizontal ? 10 / s : c, p =
|
|
10482
|
+
let d = this._resolveCurrentTargetBounds({ activeObject: n }), f = this.spacingContexts.vertical || this.spacingContexts.horizontal ? 10 / s : c, p = ra({
|
|
10443
10483
|
activeBounds: a,
|
|
10444
10484
|
candidates: d,
|
|
10445
10485
|
threshold: f,
|
|
@@ -10460,11 +10500,11 @@ var ui = class {
|
|
|
10460
10500
|
target: n,
|
|
10461
10501
|
transform: i
|
|
10462
10502
|
});
|
|
10463
|
-
let h = Ht({ object: n }) ?? a, g =
|
|
10503
|
+
let h = Ht({ object: n }) ?? a, g = ea({
|
|
10464
10504
|
activeBounds: h,
|
|
10465
10505
|
threshold: c,
|
|
10466
10506
|
anchors: this.anchors
|
|
10467
|
-
}), _ =
|
|
10507
|
+
}), _ = ra({
|
|
10468
10508
|
activeBounds: h,
|
|
10469
10509
|
candidates: d,
|
|
10470
10510
|
threshold: c,
|
|
@@ -10695,9 +10735,9 @@ var ui = class {
|
|
|
10695
10735
|
let { canvas: e, guideBounds: t } = this, n = e.getSelectionContext();
|
|
10696
10736
|
if (!n) return;
|
|
10697
10737
|
let { left: r, right: i, top: a, bottom: o } = t ?? this._calculateViewportBounds(), { viewportTransform: s } = e, c = e.getZoom() || 1;
|
|
10698
|
-
n.save(), Array.isArray(s) && n.transform(...s), n.lineWidth = 1 / c, n.strokeStyle =
|
|
10738
|
+
n.save(), Array.isArray(s) && n.transform(...s), n.lineWidth = 1 / c, n.strokeStyle = Ei, n.setLineDash([4, 4]);
|
|
10699
10739
|
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();
|
|
10700
|
-
for (let e of this.activeSpacingGuides)
|
|
10740
|
+
for (let e of this.activeSpacingGuides) oa({
|
|
10701
10741
|
context: n,
|
|
10702
10742
|
guide: e,
|
|
10703
10743
|
zoom: c
|
|
@@ -10908,14 +10948,14 @@ var ui = class {
|
|
|
10908
10948
|
}, r = [];
|
|
10909
10949
|
for (let e of t) {
|
|
10910
10950
|
let t = Ht({ object: e });
|
|
10911
|
-
t && (
|
|
10951
|
+
t && (sa({
|
|
10912
10952
|
anchors: n,
|
|
10913
10953
|
bounds: t
|
|
10914
10954
|
}), r.push(t));
|
|
10915
10955
|
}
|
|
10916
10956
|
let { montageArea: i } = this.editor, a = Ht({ object: i });
|
|
10917
10957
|
if (a) {
|
|
10918
|
-
|
|
10958
|
+
sa({
|
|
10919
10959
|
anchors: n,
|
|
10920
10960
|
bounds: a
|
|
10921
10961
|
});
|
|
@@ -10927,12 +10967,12 @@ var ui = class {
|
|
|
10927
10967
|
bottom: i
|
|
10928
10968
|
};
|
|
10929
10969
|
} else this.guideBounds = this._calculateViewportBounds();
|
|
10930
|
-
this.anchors = n, this.spacingPatterns =
|
|
10970
|
+
this.anchors = n, this.spacingPatterns = la({ bounds: r }), this.cachedTargetBounds = r;
|
|
10931
10971
|
}
|
|
10932
10972
|
_collectTargets({ activeObject: e }) {
|
|
10933
|
-
let t =
|
|
10973
|
+
let t = da({ activeObject: e }), n = [];
|
|
10934
10974
|
return this.canvas.forEachObject((e) => {
|
|
10935
|
-
|
|
10975
|
+
fa({
|
|
10936
10976
|
object: e,
|
|
10937
10977
|
excluded: t
|
|
10938
10978
|
}) || n.push(e);
|
|
@@ -10955,7 +10995,7 @@ var ui = class {
|
|
|
10955
10995
|
bottom: (r - s) / a
|
|
10956
10996
|
};
|
|
10957
10997
|
}
|
|
10958
|
-
},
|
|
10998
|
+
}, ma = "#3D8BF4", ha = class e {
|
|
10959
10999
|
constructor({ editor: e }) {
|
|
10960
11000
|
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();
|
|
10961
11001
|
}
|
|
@@ -11048,8 +11088,8 @@ var ui = class {
|
|
|
11048
11088
|
this.isTargetMontageArea = l, this.activeGuides = d, this._hideToolbar(), n.requestRenderAll();
|
|
11049
11089
|
}
|
|
11050
11090
|
static _resolveTarget({ event: e, activeObject: t }) {
|
|
11051
|
-
let { target: n } = e, r =
|
|
11052
|
-
return n && !
|
|
11091
|
+
let { target: n } = e, r = da({ activeObject: t });
|
|
11092
|
+
return n && !fa({
|
|
11053
11093
|
object: n,
|
|
11054
11094
|
excluded: r
|
|
11055
11095
|
}) ? n : null;
|
|
@@ -11166,18 +11206,18 @@ var ui = class {
|
|
|
11166
11206
|
let { canvas: e } = this, t = e.getSelectionContext();
|
|
11167
11207
|
if (!t) return;
|
|
11168
11208
|
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;
|
|
11169
|
-
t.save(), Array.isArray(n) && t.transform(...n), t.lineWidth = 1 / r, t.strokeStyle =
|
|
11209
|
+
t.save(), Array.isArray(n) && t.transform(...n), t.lineWidth = 1 / r, t.strokeStyle = ma, t.setLineDash([]);
|
|
11170
11210
|
for (let e of this.activeGuides) {
|
|
11171
11211
|
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;
|
|
11172
|
-
t.beginPath(), n === "vertical" ? (t.moveTo(i, a), t.lineTo(i, c)) : (t.moveTo(a, i), t.lineTo(c, i)), t.stroke(),
|
|
11212
|
+
t.beginPath(), n === "vertical" ? (t.moveTo(i, a), t.lineTo(i, c)) : (t.moveTo(a, i), t.lineTo(c, i)), t.stroke(), aa({
|
|
11173
11213
|
context: t,
|
|
11174
11214
|
type: n,
|
|
11175
11215
|
axis: i,
|
|
11176
11216
|
start: a,
|
|
11177
11217
|
end: c,
|
|
11178
|
-
text:
|
|
11218
|
+
text: Oi({ distance: l }).toString(),
|
|
11179
11219
|
zoom: r,
|
|
11180
|
-
color:
|
|
11220
|
+
color: ma,
|
|
11181
11221
|
lineWidth: 1,
|
|
11182
11222
|
offsetAlongAxis: d,
|
|
11183
11223
|
offsetPerpendicular: 0
|
|
@@ -11195,13 +11235,13 @@ var ui = class {
|
|
|
11195
11235
|
let { toolbar: e } = this.editor;
|
|
11196
11236
|
e?.showAfterTemporary?.(), this.isToolbarHidden = !1;
|
|
11197
11237
|
}
|
|
11198
|
-
},
|
|
11238
|
+
}, ga = class e {
|
|
11199
11239
|
constructor(e, t) {
|
|
11200
11240
|
this.options = t, this.containerId = e, this.editorId = `${e}-${D()}`, this.init();
|
|
11201
11241
|
}
|
|
11202
11242
|
async init() {
|
|
11203
11243
|
let { editorContainerWidth: e, editorContainerHeight: n, canvasWrapperWidth: r, canvasWrapperHeight: i, canvasCSSWidth: a, canvasCSSHeight: o, initialImage: s, initialState: c, scaleType: l, showRotationAngle: u, _onReadyCallback: d } = this.options;
|
|
11204
|
-
if (ie.apply(), this.canvas = new t(this.containerId, this.options), this.moduleLoader = new A(), this.workerManager = new M(), this.errorManager = new
|
|
11244
|
+
if (ie.apply(), this.canvas = new t(this.containerId, this.options), this.moduleLoader = new A(), this.workerManager = new M(), this.errorManager = new Kr({ editor: this }), this.historyManager = new wt({ editor: this }), this.toolbar = new Ye({ editor: this }), this.transformManager = new Ft({ editor: this }), this.zoomManager = new It({ editor: this }), this.canvasManager = new Pt({ editor: this }), this.imageManager = new At({ editor: this }), this.layerManager = new qt({ editor: this }), this.shapeManager = new zr({ editor: this }), this.interactionBlocker = new Gt({ editor: this }), this.backgroundManager = new Kt({ editor: this }), this.clipboardManager = new Br({ editor: this }), this.objectLockManager = new Vr({ editor: this }), this.groupingManager = new Hr({ editor: this }), this.selectionManager = new Ur({ editor: this }), this.deletionManager = new Wr({ editor: this }), this.panConstraintManager = new qr({ editor: this }), this.snappingManager = new pa({ editor: this }), this.measurementManager = new ha({ editor: this }), this.fontManager = new z(this.options.fonts ?? []), this.textManager = new bi({ editor: this }), this.templateManager = new Ti({ editor: this }), u && (this.angleIndicator = new Qe({ editor: this })), this._createMontageArea(), this._createClippingArea(), this.interactionBlocker.ensureOverlay(), this.listeners = new k({
|
|
11205
11245
|
editor: this,
|
|
11206
11246
|
options: this.options
|
|
11207
11247
|
}), this.canvasManager.setEditorContainerWidth(e), this.canvasManager.setEditorContainerHeight(n), this.canvasManager.setCanvasWrapperWidth(r), this.canvasManager.setCanvasWrapperHeight(i), this.canvasManager.setCanvasCSSWidth(a), this.canvasManager.setCanvasCSSHeight(o), this.canvasManager.updateCanvas(), this.zoomManager.calculateAndApplyDefaultZoom(), await this.fontManager.loadFonts(), c) {
|
|
@@ -11309,7 +11349,7 @@ var ui = class {
|
|
|
11309
11349
|
"U+A640-A69F",
|
|
11310
11350
|
"U+FE2E-FE2F",
|
|
11311
11351
|
"U+2116"
|
|
11312
|
-
].join(", "),
|
|
11352
|
+
].join(", "), _a = {
|
|
11313
11353
|
preserveObjectStacking: !0,
|
|
11314
11354
|
controlsAboveOverlay: !0,
|
|
11315
11355
|
centeredRotation: !0,
|
|
@@ -12163,20 +12203,20 @@ var ui = class {
|
|
|
12163
12203
|
};
|
|
12164
12204
|
//#endregion
|
|
12165
12205
|
//#region src/main.ts
|
|
12166
|
-
function
|
|
12206
|
+
function va(e, t = {}) {
|
|
12167
12207
|
let n = {
|
|
12168
|
-
...
|
|
12208
|
+
..._a,
|
|
12169
12209
|
...t
|
|
12170
12210
|
}, r = document.getElementById(e);
|
|
12171
12211
|
if (!r) return Promise.reject(/* @__PURE__ */ Error(`Контейнер с ID "${e}" не найден.`));
|
|
12172
12212
|
let i = document.createElement("canvas");
|
|
12173
12213
|
return i.id = `${e}-canvas`, r.appendChild(i), n.editorContainer = r, new Promise((t) => {
|
|
12174
12214
|
n._onReadyCallback = t;
|
|
12175
|
-
let r = new
|
|
12215
|
+
let r = new ga(i.id, n);
|
|
12176
12216
|
window[e] = r;
|
|
12177
12217
|
});
|
|
12178
12218
|
}
|
|
12179
12219
|
//#endregion
|
|
12180
|
-
export {
|
|
12220
|
+
export { va as default };
|
|
12181
12221
|
|
|
12182
12222
|
//# sourceMappingURL=main.js.map
|