@anu3ev/fabric-image-editor 0.7.8 → 0.7.10
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 +689 -689
- package/package.json +1 -1
- package/readme.md +1 -2
package/dist/main.js
CHANGED
|
@@ -252,87 +252,87 @@ var M = class {
|
|
|
252
252
|
}, N = "#2B2D33", P = "#3D8BF4", F = "#FFFFFF";
|
|
253
253
|
//#endregion
|
|
254
254
|
//#region src/editor/customized-controls/renderers.ts
|
|
255
|
-
function
|
|
255
|
+
function ee(e, t, n, r, i) {
|
|
256
256
|
e.save(), e.translate(t, n), e.rotate(C.degreesToRadians(i.angle)), e.fillStyle = F, e.strokeStyle = P, e.lineWidth = 1, e.beginPath(), e.roundRect(-12 / 2, -12 / 2, 12, 12, 2), e.fill(), e.stroke(), e.restore();
|
|
257
257
|
}
|
|
258
|
-
function
|
|
258
|
+
function te(e, t, n, r, i) {
|
|
259
259
|
e.save(), e.translate(t, n), e.rotate(C.degreesToRadians(i.angle)), e.fillStyle = F, e.strokeStyle = P, e.lineWidth = 1, e.beginPath(), e.roundRect(-8 / 2, -20 / 2, 8, 20, 100), e.fill(), e.stroke(), e.restore();
|
|
260
260
|
}
|
|
261
|
-
function
|
|
261
|
+
function I(e, t, n, r, i) {
|
|
262
262
|
e.save(), e.translate(t, n), e.rotate(C.degreesToRadians(i.angle)), e.fillStyle = F, e.strokeStyle = P, e.lineWidth = 1, e.beginPath(), e.roundRect(-20 / 2, -8 / 2, 20, 8, 100), e.fill(), e.stroke(), e.restore();
|
|
263
263
|
}
|
|
264
|
-
var
|
|
265
|
-
|
|
266
|
-
function
|
|
267
|
-
e.save(), e.translate(t, n), e.rotate(C.degreesToRadians(i.angle)), e.fillStyle = N, e.beginPath(), e.arc(0, 0, 16, 0, 2 * Math.PI), e.fill(), e.drawImage(
|
|
264
|
+
var ne = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTE4Ljc1IDQuMzc1djMuNzVhLjYyNS42MjUgMCAwIDEtLjYyNS42MjVoLTMuNzVhLjYyNS42MjUgMCAwIDEgMC0xLjI1aDIuMTRsLTIuMDc3LTEuOTAzLS4wMi0uMDE5YTYuMjUgNi4yNSAwIDEgMC0uMTMgOC45NjcuNjI2LjYyNiAwIDAgMSAuODYuOTA5QTcuNDU2IDcuNDU2IDAgMCAxIDEwIDE3LjVoLS4xMDNhNy41IDcuNSAwIDEgMSA1LjM5Ni0xMi44MTJMMTcuNSA2LjcwM1Y0LjM3NWEuNjI1LjYyNSAwIDAgMSAxLjI1IDBaIi8+PC9zdmc+", re = new Image();
|
|
265
|
+
re.src = ne;
|
|
266
|
+
function L(e, t, n, r, i) {
|
|
267
|
+
e.save(), e.translate(t, n), e.rotate(C.degreesToRadians(i.angle)), e.fillStyle = N, e.beginPath(), e.arc(0, 0, 16, 0, 2 * Math.PI), e.fill(), e.drawImage(re, -16 / 2, -16 / 2, 16, 16), e.restore();
|
|
268
268
|
}
|
|
269
269
|
//#endregion
|
|
270
270
|
//#region src/editor/customized-controls/default-controls.ts
|
|
271
|
-
var
|
|
271
|
+
var ie = {
|
|
272
272
|
tl: {
|
|
273
|
-
render:
|
|
273
|
+
render: ee,
|
|
274
274
|
sizeX: 12,
|
|
275
275
|
sizeY: 12,
|
|
276
276
|
offsetX: 0,
|
|
277
277
|
offsetY: 0
|
|
278
278
|
},
|
|
279
279
|
tr: {
|
|
280
|
-
render:
|
|
280
|
+
render: ee,
|
|
281
281
|
sizeX: 12,
|
|
282
282
|
sizeY: 12,
|
|
283
283
|
offsetX: 0,
|
|
284
284
|
offsetY: 0
|
|
285
285
|
},
|
|
286
286
|
bl: {
|
|
287
|
-
render:
|
|
287
|
+
render: ee,
|
|
288
288
|
sizeX: 12,
|
|
289
289
|
sizeY: 12,
|
|
290
290
|
offsetX: 0,
|
|
291
291
|
offsetY: 0
|
|
292
292
|
},
|
|
293
293
|
br: {
|
|
294
|
-
render:
|
|
294
|
+
render: ee,
|
|
295
295
|
sizeX: 12,
|
|
296
296
|
sizeY: 12,
|
|
297
297
|
offsetX: 0,
|
|
298
298
|
offsetY: 0
|
|
299
299
|
},
|
|
300
300
|
ml: {
|
|
301
|
-
render:
|
|
301
|
+
render: te,
|
|
302
302
|
sizeX: 8,
|
|
303
303
|
sizeY: 20,
|
|
304
304
|
offsetX: 0,
|
|
305
305
|
offsetY: 0
|
|
306
306
|
},
|
|
307
307
|
mr: {
|
|
308
|
-
render:
|
|
308
|
+
render: te,
|
|
309
309
|
sizeX: 8,
|
|
310
310
|
sizeY: 20,
|
|
311
311
|
offsetX: 0,
|
|
312
312
|
offsetY: 0
|
|
313
313
|
},
|
|
314
314
|
mt: {
|
|
315
|
-
render:
|
|
315
|
+
render: I,
|
|
316
316
|
sizeX: 20,
|
|
317
317
|
sizeY: 8,
|
|
318
318
|
offsetX: 0,
|
|
319
319
|
offsetY: 0
|
|
320
320
|
},
|
|
321
321
|
mb: {
|
|
322
|
-
render:
|
|
322
|
+
render: I,
|
|
323
323
|
sizeX: 20,
|
|
324
324
|
sizeY: 8,
|
|
325
325
|
offsetX: 0,
|
|
326
326
|
offsetY: 0
|
|
327
327
|
},
|
|
328
328
|
mtr: {
|
|
329
|
-
render:
|
|
329
|
+
render: L,
|
|
330
330
|
sizeX: 32,
|
|
331
331
|
sizeY: 32,
|
|
332
332
|
offsetX: 0,
|
|
333
333
|
offsetY: -32
|
|
334
334
|
}
|
|
335
|
-
},
|
|
335
|
+
}, R = class t {
|
|
336
336
|
static wrapWidthControl(e) {
|
|
337
337
|
if (!e?.actionHandler) return;
|
|
338
338
|
let t = e.actionHandler;
|
|
@@ -342,7 +342,7 @@ var re = {
|
|
|
342
342
|
};
|
|
343
343
|
}
|
|
344
344
|
static applyControlOverrides(e) {
|
|
345
|
-
Object.entries(
|
|
345
|
+
Object.entries(ie).forEach(([t, n]) => {
|
|
346
346
|
let r = e[t];
|
|
347
347
|
r && (Object.assign(r, n), t === "mtr" && (r.cursorStyle = "grab", r.mouseDownHandler = (e, t, n, r) => {
|
|
348
348
|
let i = t?.target;
|
|
@@ -432,7 +432,7 @@ var re = {
|
|
|
432
432
|
mr: !0
|
|
433
433
|
});
|
|
434
434
|
}
|
|
435
|
-
},
|
|
435
|
+
}, ae = class e {
|
|
436
436
|
static {
|
|
437
437
|
this.registeredFontKeys = /* @__PURE__ */ new Set();
|
|
438
438
|
}
|
|
@@ -585,7 +585,7 @@ var re = {
|
|
|
585
585
|
};
|
|
586
586
|
return Object.entries(e).filter(([, e]) => e != null && `${e}`.length > 0).map(([e, n]) => `${t[e] ?? e}: ${n};`);
|
|
587
587
|
}
|
|
588
|
-
},
|
|
588
|
+
}, z = {
|
|
589
589
|
style: {
|
|
590
590
|
position: "absolute",
|
|
591
591
|
display: "none",
|
|
@@ -687,7 +687,7 @@ var re = {
|
|
|
687
687
|
e.layerManager.sendBackwards();
|
|
688
688
|
}
|
|
689
689
|
}
|
|
690
|
-
},
|
|
690
|
+
}, oe = class {
|
|
691
691
|
constructor({ editor: e }) {
|
|
692
692
|
this.currentTarget = null, this.currentLocked = !1, this.isTransforming = !1, this.isTemporarilyHidden = !1, this.editor = e, this.canvas = e.canvas, this.options = e.options, this._initToolbar();
|
|
693
693
|
}
|
|
@@ -695,22 +695,22 @@ var re = {
|
|
|
695
695
|
if (!this.options.showToolbar) return;
|
|
696
696
|
let e = this.options.toolbar || {};
|
|
697
697
|
this.config = {
|
|
698
|
-
...
|
|
698
|
+
...z,
|
|
699
699
|
...e,
|
|
700
700
|
style: {
|
|
701
|
-
...
|
|
701
|
+
...z.style,
|
|
702
702
|
...e.style || {}
|
|
703
703
|
},
|
|
704
704
|
btnStyle: {
|
|
705
|
-
...
|
|
705
|
+
...z.btnStyle,
|
|
706
706
|
...e.btnStyle || {}
|
|
707
707
|
},
|
|
708
708
|
icons: {
|
|
709
|
-
...
|
|
709
|
+
...z.icons,
|
|
710
710
|
...e.icons || {}
|
|
711
711
|
},
|
|
712
712
|
handlers: {
|
|
713
|
-
...
|
|
713
|
+
...z.handlers,
|
|
714
714
|
...e.handlers || {}
|
|
715
715
|
}
|
|
716
716
|
}, this.currentTarget = null, this.currentLocked = !1, this.isTransforming = !1, this.isTemporarilyHidden = !1, this._onMouseDown = this._handleMouseDown.bind(this), this._onObjectMoving = this._startTransform.bind(this), this._onObjectScaling = this._startTransform.bind(this), this._onObjectRotating = this._startTransform.bind(this), this._onMouseUp = this._endTransform.bind(this), this._onObjectModified = this._endTransform.bind(this), this._onSelectionChange = this._updateToolbar.bind(this), this._onSelectionClear = () => {
|
|
@@ -788,7 +788,7 @@ var re = {
|
|
|
788
788
|
destroy() {
|
|
789
789
|
this.el.removeEventListener("mouseover", this._onBtnOver), this.el.removeEventListener("mouseout", this._onBtnOut), this.canvas.off("mouse:down", this._onMouseDown), this.canvas.off("object:moving", this._onObjectMoving), this.canvas.off("object:scaling", this._onObjectScaling), this.canvas.off("object:rotating", this._onObjectRotating), this.canvas.off("mouse:up", this._onMouseUp), this.canvas.off("object:modified", this._onObjectModified), this.canvas.off("selection:created", this._onSelectionChange), this.canvas.off("selection:updated", this._onSelectionChange), this.canvas.off("after:render", this._onSelectionChange), this.canvas.off("selection:cleared", this._onSelectionClear), this.el.remove();
|
|
790
790
|
}
|
|
791
|
-
},
|
|
791
|
+
}, B = {
|
|
792
792
|
position: "absolute",
|
|
793
793
|
display: "none",
|
|
794
794
|
background: "#2B2D33",
|
|
@@ -802,12 +802,12 @@ var re = {
|
|
|
802
802
|
"pointer-events": "none",
|
|
803
803
|
"white-space": "nowrap",
|
|
804
804
|
"box-shadow": "0 2px 8px rgba(0, 0, 0, 0.2)"
|
|
805
|
-
},
|
|
805
|
+
}, se = "fabric-editor-angle-indicator", ce = class e {
|
|
806
806
|
constructor({ editor: e }) {
|
|
807
807
|
this.isActive = !1, this.currentAngle = 0, this.editor = e, this.canvas = e.canvas, this.options = e.options, this._createDOM(), this._bindEvents();
|
|
808
808
|
}
|
|
809
809
|
_createDOM() {
|
|
810
|
-
this.el = document.createElement("div"), this.el.className =
|
|
810
|
+
this.el = document.createElement("div"), this.el.className = se, Object.entries(B).forEach(([e, t]) => {
|
|
811
811
|
this.el.style.setProperty(e, t);
|
|
812
812
|
}), this.canvas.wrapperEl.appendChild(this.el);
|
|
813
813
|
}
|
|
@@ -852,10 +852,10 @@ var re = {
|
|
|
852
852
|
destroy() {
|
|
853
853
|
this.canvas && (this.canvas.off("object:rotating", this._onObjectRotating), this.canvas.off("mouse:up", this._onMouseUp), this.canvas.off("object:modified", this._onObjectModified), this.canvas.off("selection:cleared", this._onSelectionCleared)), this.el?.parentNode && this.el.parentNode.removeChild(this.el), this.el = null, this.editor = null, this.canvas = null, this.options = null;
|
|
854
854
|
}
|
|
855
|
-
},
|
|
855
|
+
}, le = /* @__PURE__ */ "id.backgroundId.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.shapeTextAutoExpand.shapeAlignHorizontal.shapeAlignVertical.shapePaddingTop.shapePaddingRight.shapePaddingBottom.shapePaddingLeft.shapeFill.shapeStroke.shapeStrokeWidth.shapeStrokeDashArray.shapeOpacity.shapeRounding.shapeNodeType".split(".");
|
|
856
856
|
//#endregion
|
|
857
857
|
//#region src/editor/history-manager/diff-normalization.ts
|
|
858
|
-
function
|
|
858
|
+
function V({ state: e }) {
|
|
859
859
|
return JSON.parse(JSON.stringify(e));
|
|
860
860
|
}
|
|
861
861
|
function H({ value: e }) {
|
|
@@ -925,7 +925,7 @@ function ge({ prevState: e, nextState: t }) {
|
|
|
925
925
|
o !== c || s !== l || (t.width = n, t.height = r);
|
|
926
926
|
}
|
|
927
927
|
function _e({ prevState: e, nextState: t }) {
|
|
928
|
-
let n =
|
|
928
|
+
let n = V({ state: e }), r = V({ state: t });
|
|
929
929
|
return he({ objects: n.objects }), he({ objects: r.objects }), ge({
|
|
930
930
|
prevState: n,
|
|
931
931
|
nextState: r
|
|
@@ -1122,7 +1122,7 @@ var Me = class {
|
|
|
1122
1122
|
}
|
|
1123
1123
|
_serializeCanvasState() {
|
|
1124
1124
|
let { canvas: e } = this;
|
|
1125
|
-
return e.toDatalessObject([...
|
|
1125
|
+
return e.toDatalessObject([...le]);
|
|
1126
1126
|
}
|
|
1127
1127
|
_handlePendingSaveTimeout() {
|
|
1128
1128
|
this._pendingSaveTimeoutId !== null && (this._pendingSaveTimeoutId = null, this._pendingSaveReason = null, this.saveState());
|
|
@@ -1197,7 +1197,7 @@ var Me = class {
|
|
|
1197
1197
|
e && (this._pendingSaveTimeoutId !== null && this._pendingSaveReason === e.reason && this._clearPendingSave(), e.reason === "text-edit" && this._deactivateTextEditing(), this._saveSerializedState({ currentStateObj: e.state }));
|
|
1198
1198
|
let t = je({
|
|
1199
1199
|
canvas: this.canvas,
|
|
1200
|
-
callback: () => this.canvas.toDatalessObject([...
|
|
1200
|
+
callback: () => this.canvas.toDatalessObject([...le])
|
|
1201
1201
|
});
|
|
1202
1202
|
console.timeEnd("saveState"), this._saveSerializedState({ currentStateObj: t });
|
|
1203
1203
|
} finally {
|
|
@@ -3400,38 +3400,38 @@ var Xe = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
|
|
|
3400
3400
|
left: .2
|
|
3401
3401
|
}
|
|
3402
3402
|
}
|
|
3403
|
-
], ot = "circle", st = "center", ct = {};
|
|
3403
|
+
], ot = "circle", st = "center", ct = "middle", lt = {};
|
|
3404
3404
|
for (let e = 0; e < at.length; e += 1) {
|
|
3405
3405
|
let t = at[e];
|
|
3406
|
-
|
|
3406
|
+
lt[t.key] = t;
|
|
3407
3407
|
}
|
|
3408
|
-
var
|
|
3409
|
-
function
|
|
3408
|
+
var ut = lt, dt = ({ presetKey: e }) => ut[e] ?? null, ft = ({ preset: e, rounding: t }) => (typeof t == "number" ? t : 0) <= 0 || e.type === "rect" ? e.key : e.roundedVariant ?? e.key;
|
|
3409
|
+
function pt({ value: e, size: t }) {
|
|
3410
3410
|
let n = Number.isFinite(e) ? Math.min(Math.max(e, 0), tt) : 0;
|
|
3411
3411
|
return (Number.isFinite(t) && t > 0 ? t : 0) * n;
|
|
3412
3412
|
}
|
|
3413
|
-
var
|
|
3413
|
+
var mt = ({ preset: e, width: t, height: n }) => {
|
|
3414
3414
|
let r = e.internalTextInset ?? {};
|
|
3415
3415
|
return {
|
|
3416
|
-
top:
|
|
3416
|
+
top: pt({
|
|
3417
3417
|
value: r.top ?? et.top,
|
|
3418
3418
|
size: n
|
|
3419
3419
|
}),
|
|
3420
|
-
right:
|
|
3420
|
+
right: pt({
|
|
3421
3421
|
value: r.right ?? et.right,
|
|
3422
3422
|
size: t
|
|
3423
3423
|
}),
|
|
3424
|
-
bottom:
|
|
3424
|
+
bottom: pt({
|
|
3425
3425
|
value: r.bottom ?? et.bottom,
|
|
3426
3426
|
size: n
|
|
3427
3427
|
}),
|
|
3428
|
-
left:
|
|
3428
|
+
left: pt({
|
|
3429
3429
|
value: r.left ?? et.left,
|
|
3430
3430
|
size: t
|
|
3431
3431
|
})
|
|
3432
3432
|
};
|
|
3433
3433
|
};
|
|
3434
|
-
function
|
|
3434
|
+
function ht({ path: e }) {
|
|
3435
3435
|
let t = e.match(/[a-zA-Z]/g) ?? [], n = new Set([
|
|
3436
3436
|
"M",
|
|
3437
3437
|
"L",
|
|
@@ -3445,24 +3445,24 @@ function mt({ path: e }) {
|
|
|
3445
3445
|
}
|
|
3446
3446
|
return t.length > 0;
|
|
3447
3447
|
}
|
|
3448
|
-
var
|
|
3448
|
+
var gt = ({ preset: e }) => e.type === "rect" || e.type === "triangle" || e.type === "polygon" || e.type === "polyline" ? !0 : e.type === "ellipse" || e.type === "svg" ? !1 : ht({ path: e.path }), _t = 1, vt = 1e-4;
|
|
3449
3449
|
function K({ value: e }) {
|
|
3450
3450
|
return Number(e.toFixed(4));
|
|
3451
3451
|
}
|
|
3452
|
-
function
|
|
3452
|
+
function yt({ rounding: e }) {
|
|
3453
3453
|
return Math.max(0, e ?? 0) > 0;
|
|
3454
3454
|
}
|
|
3455
|
-
function
|
|
3455
|
+
function bt({ width: e, height: t, strokeWidth: n }) {
|
|
3456
3456
|
let r = Math.max(0, n ?? 0);
|
|
3457
3457
|
return {
|
|
3458
|
-
width: Math.max(
|
|
3459
|
-
height: Math.max(
|
|
3458
|
+
width: Math.max(_t, e - r),
|
|
3459
|
+
height: Math.max(_t, t - r)
|
|
3460
3460
|
};
|
|
3461
3461
|
}
|
|
3462
|
-
function
|
|
3463
|
-
let a =
|
|
3464
|
-
width: Math.max(
|
|
3465
|
-
height: Math.max(
|
|
3462
|
+
function xt({ shape: e, width: t, height: n, rounding: r, strokeWidth: i }) {
|
|
3463
|
+
let a = bt({
|
|
3464
|
+
width: Math.max(_t, t),
|
|
3465
|
+
height: Math.max(_t, n),
|
|
3466
3466
|
strokeWidth: i
|
|
3467
3467
|
});
|
|
3468
3468
|
if (e instanceof g) {
|
|
@@ -3481,7 +3481,7 @@ function bt({ shape: e, width: t, height: n, rounding: r, strokeWidth: i }) {
|
|
|
3481
3481
|
}), e.setCoords();
|
|
3482
3482
|
return;
|
|
3483
3483
|
}
|
|
3484
|
-
let { width: o =
|
|
3484
|
+
let { width: o = _t, height: s = _t } = e, c = Math.max(_t, o), l = Math.max(_t, s);
|
|
3485
3485
|
e.set({
|
|
3486
3486
|
scaleX: a.width / c,
|
|
3487
3487
|
scaleY: a.height / l,
|
|
@@ -3491,11 +3491,11 @@ function bt({ shape: e, width: t, height: n, rounding: r, strokeWidth: i }) {
|
|
|
3491
3491
|
originY: "center"
|
|
3492
3492
|
}), e.setCoords();
|
|
3493
3493
|
}
|
|
3494
|
-
function
|
|
3494
|
+
function St({ shape: e, style: t }) {
|
|
3495
3495
|
let { fill: n, stroke: r, strokeWidth: i, strokeDashArray: a, opacity: o } = t;
|
|
3496
3496
|
if (e instanceof l) {
|
|
3497
3497
|
let n = e.getObjects();
|
|
3498
|
-
for (let e = 0; e < n.length; e += 1)
|
|
3498
|
+
for (let e = 0; e < n.length; e += 1) St({
|
|
3499
3499
|
shape: n[e],
|
|
3500
3500
|
style: t
|
|
3501
3501
|
});
|
|
@@ -3509,7 +3509,7 @@ function xt({ shape: e, style: t }) {
|
|
|
3509
3509
|
};
|
|
3510
3510
|
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();
|
|
3511
3511
|
}
|
|
3512
|
-
function
|
|
3512
|
+
function Ct({ points: e, closed: t }) {
|
|
3513
3513
|
if (e.length === 0) return "";
|
|
3514
3514
|
let n = `M ${K({ value: e[0].x })} ${K({ value: e[0].y })}`;
|
|
3515
3515
|
for (let t = 1; t < e.length; t += 1) {
|
|
@@ -3518,7 +3518,7 @@ function St({ points: e, closed: t }) {
|
|
|
3518
3518
|
}
|
|
3519
3519
|
return t && (n += " Z"), n;
|
|
3520
3520
|
}
|
|
3521
|
-
function
|
|
3521
|
+
function wt({ previous: e, current: t, next: n, radius: r }) {
|
|
3522
3522
|
let i = {
|
|
3523
3523
|
x: e.x - t.x,
|
|
3524
3524
|
y: e.y - t.y
|
|
@@ -3526,7 +3526,7 @@ function Ct({ previous: e, current: t, next: n, radius: r }) {
|
|
|
3526
3526
|
x: n.x - t.x,
|
|
3527
3527
|
y: n.y - t.y
|
|
3528
3528
|
}, o = Math.hypot(i.x, i.y), s = Math.hypot(a.x, a.y);
|
|
3529
|
-
if (o <=
|
|
3529
|
+
if (o <= vt || s <= vt) return {
|
|
3530
3530
|
start: {
|
|
3531
3531
|
x: K({ value: t.x }),
|
|
3532
3532
|
y: K({ value: t.y })
|
|
@@ -3548,7 +3548,7 @@ function Ct({ previous: e, current: t, next: n, radius: r }) {
|
|
|
3548
3548
|
}
|
|
3549
3549
|
};
|
|
3550
3550
|
}
|
|
3551
|
-
function
|
|
3551
|
+
function Tt({ points: e, radius: t, closed: n }) {
|
|
3552
3552
|
let r = e.length;
|
|
3553
3553
|
if (r === 0) return "";
|
|
3554
3554
|
if (!n && r === 1) {
|
|
@@ -3556,7 +3556,7 @@ function wt({ points: e, radius: t, closed: n }) {
|
|
|
3556
3556
|
return `M ${K({ value: t.x })} ${K({ value: t.y })}`;
|
|
3557
3557
|
}
|
|
3558
3558
|
let i = Math.max(0, t);
|
|
3559
|
-
if (i <= 0) return
|
|
3559
|
+
if (i <= 0) return Ct({
|
|
3560
3560
|
points: e,
|
|
3561
3561
|
closed: n
|
|
3562
3562
|
});
|
|
@@ -3564,7 +3564,7 @@ function wt({ points: e, radius: t, closed: n }) {
|
|
|
3564
3564
|
let t = [];
|
|
3565
3565
|
for (let n = 0; n < r; n += 1) {
|
|
3566
3566
|
let a = n === 0 ? r - 1 : n - 1, o = n === r - 1 ? 0 : n + 1;
|
|
3567
|
-
t.push(
|
|
3567
|
+
t.push(wt({
|
|
3568
3568
|
previous: e[a],
|
|
3569
3569
|
current: e[n],
|
|
3570
3570
|
next: e[o],
|
|
@@ -3578,13 +3578,13 @@ function wt({ points: e, radius: t, closed: n }) {
|
|
|
3578
3578
|
}
|
|
3579
3579
|
return a += " Z", a;
|
|
3580
3580
|
}
|
|
3581
|
-
if (r === 2) return
|
|
3581
|
+
if (r === 2) return Ct({
|
|
3582
3582
|
points: e,
|
|
3583
3583
|
closed: !1
|
|
3584
3584
|
});
|
|
3585
3585
|
let a = `M ${K({ value: e[0].x })} ${K({ value: e[0].y })}`;
|
|
3586
3586
|
for (let t = 1; t < r - 1; t += 1) {
|
|
3587
|
-
let n =
|
|
3587
|
+
let n = wt({
|
|
3588
3588
|
previous: e[t - 1],
|
|
3589
3589
|
current: e[t],
|
|
3590
3590
|
next: e[t + 1],
|
|
@@ -3595,8 +3595,8 @@ function wt({ points: e, radius: t, closed: n }) {
|
|
|
3595
3595
|
let o = e[r - 1];
|
|
3596
3596
|
return a += ` L ${K({ value: o.x })} ${K({ value: o.y })}`, a;
|
|
3597
3597
|
}
|
|
3598
|
-
function
|
|
3599
|
-
return new d(
|
|
3598
|
+
function Et({ points: e, rounding: t, closed: n }) {
|
|
3599
|
+
return new d(Tt({
|
|
3600
3600
|
points: e,
|
|
3601
3601
|
radius: t,
|
|
3602
3602
|
closed: n
|
|
@@ -3607,8 +3607,8 @@ function Tt({ points: e, rounding: t, closed: n }) {
|
|
|
3607
3607
|
top: 0
|
|
3608
3608
|
});
|
|
3609
3609
|
}
|
|
3610
|
-
function
|
|
3611
|
-
return
|
|
3610
|
+
function Dt({ rounding: e }) {
|
|
3611
|
+
return yt({ rounding: e }) ? Et({
|
|
3612
3612
|
points: [
|
|
3613
3613
|
{
|
|
3614
3614
|
x: 50,
|
|
@@ -3634,7 +3634,7 @@ function Et({ rounding: e }) {
|
|
|
3634
3634
|
top: 0
|
|
3635
3635
|
});
|
|
3636
3636
|
}
|
|
3637
|
-
function
|
|
3637
|
+
function Ot({ path: e }) {
|
|
3638
3638
|
return new d(e, {
|
|
3639
3639
|
originX: "center",
|
|
3640
3640
|
originY: "center",
|
|
@@ -3642,8 +3642,8 @@ function Dt({ path: e }) {
|
|
|
3642
3642
|
top: 0
|
|
3643
3643
|
});
|
|
3644
3644
|
}
|
|
3645
|
-
function
|
|
3646
|
-
let n =
|
|
3645
|
+
function kt({ path: e, rounding: t }) {
|
|
3646
|
+
let n = Ot({ path: e }).path ?? [], r = C.makePathSimpler(n), i = [], a = !1;
|
|
3647
3647
|
for (let e = 0; e < r.length; e += 1) {
|
|
3648
3648
|
let t = r[e];
|
|
3649
3649
|
if (!t) return null;
|
|
@@ -3663,19 +3663,19 @@ function Ot({ path: e, rounding: t }) {
|
|
|
3663
3663
|
}
|
|
3664
3664
|
return null;
|
|
3665
3665
|
}
|
|
3666
|
-
return i.length < 2 || a && i.length < 3 ? null :
|
|
3666
|
+
return i.length < 2 || a && i.length < 3 ? null : Et({
|
|
3667
3667
|
points: i,
|
|
3668
3668
|
rounding: t,
|
|
3669
3669
|
closed: a
|
|
3670
3670
|
});
|
|
3671
3671
|
}
|
|
3672
|
-
function
|
|
3673
|
-
return
|
|
3672
|
+
function At({ path: e, rounding: t }) {
|
|
3673
|
+
return yt({ rounding: t }) && kt({
|
|
3674
3674
|
path: e,
|
|
3675
3675
|
rounding: Math.max(0, t ?? 0)
|
|
3676
|
-
}) ||
|
|
3676
|
+
}) || Ot({ path: e });
|
|
3677
3677
|
}
|
|
3678
|
-
function
|
|
3678
|
+
function jt({ points: e, type: t, rounding: n }) {
|
|
3679
3679
|
let r = e.length > 0 ? e : [
|
|
3680
3680
|
{
|
|
3681
3681
|
x: 0,
|
|
@@ -3690,13 +3690,13 @@ function At({ points: e, type: t, rounding: n }) {
|
|
|
3690
3690
|
y: 100
|
|
3691
3691
|
}
|
|
3692
3692
|
], i = Math.max(0, n ?? 0);
|
|
3693
|
-
if (
|
|
3694
|
-
if (t === "polygon" && r.length >= 3) return
|
|
3693
|
+
if (yt({ rounding: n })) {
|
|
3694
|
+
if (t === "polygon" && r.length >= 3) return Et({
|
|
3695
3695
|
points: r,
|
|
3696
3696
|
rounding: i,
|
|
3697
3697
|
closed: !0
|
|
3698
3698
|
});
|
|
3699
|
-
if (t === "polyline" && r.length >= 2) return
|
|
3699
|
+
if (t === "polyline" && r.length >= 2) return Et({
|
|
3700
3700
|
points: r,
|
|
3701
3701
|
rounding: i,
|
|
3702
3702
|
closed: !1
|
|
@@ -3709,7 +3709,7 @@ function At({ points: e, type: t, rounding: n }) {
|
|
|
3709
3709
|
top: 0
|
|
3710
3710
|
});
|
|
3711
3711
|
}
|
|
3712
|
-
async function
|
|
3712
|
+
async function Mt({ svg: e }) {
|
|
3713
3713
|
let t = await x(e), n = C.groupSVGElements(t.objects, t.options);
|
|
3714
3714
|
return n.set({
|
|
3715
3715
|
originX: "center",
|
|
@@ -3718,7 +3718,7 @@ async function jt({ svg: e }) {
|
|
|
3718
3718
|
top: 0
|
|
3719
3719
|
}), n.setCoords(), n;
|
|
3720
3720
|
}
|
|
3721
|
-
async function
|
|
3721
|
+
async function Nt({ preset: e, rounding: t }) {
|
|
3722
3722
|
switch (e.type) {
|
|
3723
3723
|
case "rect": return new g({
|
|
3724
3724
|
width: 100,
|
|
@@ -3736,22 +3736,22 @@ async function Mt({ preset: e, rounding: t }) {
|
|
|
3736
3736
|
left: 0,
|
|
3737
3737
|
top: 0
|
|
3738
3738
|
});
|
|
3739
|
-
case "triangle": return
|
|
3740
|
-
case "polygon": return
|
|
3739
|
+
case "triangle": return Dt({ rounding: t });
|
|
3740
|
+
case "polygon": return jt({
|
|
3741
3741
|
points: e.points,
|
|
3742
3742
|
type: "polygon",
|
|
3743
3743
|
rounding: t
|
|
3744
3744
|
});
|
|
3745
|
-
case "polyline": return
|
|
3745
|
+
case "polyline": return jt({
|
|
3746
3746
|
points: e.points,
|
|
3747
3747
|
type: "polyline",
|
|
3748
3748
|
rounding: t
|
|
3749
3749
|
});
|
|
3750
|
-
case "path": return
|
|
3750
|
+
case "path": return At({
|
|
3751
3751
|
path: e.path,
|
|
3752
3752
|
rounding: t
|
|
3753
3753
|
});
|
|
3754
|
-
case "svg": return
|
|
3754
|
+
case "svg": return Mt({ svg: e.svg });
|
|
3755
3755
|
default: return new g({
|
|
3756
3756
|
width: 100,
|
|
3757
3757
|
height: 100,
|
|
@@ -3762,15 +3762,15 @@ async function Mt({ preset: e, rounding: t }) {
|
|
|
3762
3762
|
});
|
|
3763
3763
|
}
|
|
3764
3764
|
}
|
|
3765
|
-
async function
|
|
3766
|
-
let a = await
|
|
3765
|
+
async function Pt({ preset: e, width: t, height: n, style: r, rounding: i }) {
|
|
3766
|
+
let a = await Nt({
|
|
3767
3767
|
preset: e,
|
|
3768
3768
|
rounding: i
|
|
3769
3769
|
});
|
|
3770
|
-
return
|
|
3770
|
+
return St({
|
|
3771
3771
|
shape: a,
|
|
3772
3772
|
style: r
|
|
3773
|
-
}),
|
|
3773
|
+
}), xt({
|
|
3774
3774
|
shape: a,
|
|
3775
3775
|
width: t,
|
|
3776
3776
|
height: n,
|
|
@@ -3786,23 +3786,15 @@ async function Nt({ preset: e, width: t, height: n, style: r, rounding: i }) {
|
|
|
3786
3786
|
}
|
|
3787
3787
|
//#endregion
|
|
3788
3788
|
//#region src/editor/shape-manager/layout/shape-padding.ts
|
|
3789
|
-
function
|
|
3789
|
+
function Ft({ value: e }) {
|
|
3790
3790
|
return Number.isFinite(e) ? Math.max(0, e ?? 0) : 0;
|
|
3791
3791
|
}
|
|
3792
|
-
function
|
|
3792
|
+
function It({ value: e }) {
|
|
3793
3793
|
return Number.isFinite(e) ? Math.max(0, Math.floor(e ?? 0)) : 0;
|
|
3794
3794
|
}
|
|
3795
|
-
function
|
|
3795
|
+
function Lt({ stroke: e, strokeWidth: t }) {
|
|
3796
3796
|
return e == null ? !1 : Math.max(0, t ?? 0) > 0;
|
|
3797
3797
|
}
|
|
3798
|
-
function Lt({ padding: e }) {
|
|
3799
|
-
return {
|
|
3800
|
-
top: Pt({ value: e?.top }),
|
|
3801
|
-
right: Pt({ value: e?.right }),
|
|
3802
|
-
bottom: Pt({ value: e?.bottom }),
|
|
3803
|
-
left: Pt({ value: e?.left })
|
|
3804
|
-
};
|
|
3805
|
-
}
|
|
3806
3798
|
function Rt({ padding: e }) {
|
|
3807
3799
|
return {
|
|
3808
3800
|
top: Ft({ value: e?.top }),
|
|
@@ -3811,8 +3803,16 @@ function Rt({ padding: e }) {
|
|
|
3811
3803
|
left: Ft({ value: e?.left })
|
|
3812
3804
|
};
|
|
3813
3805
|
}
|
|
3814
|
-
function zt({
|
|
3815
|
-
|
|
3806
|
+
function zt({ padding: e }) {
|
|
3807
|
+
return {
|
|
3808
|
+
top: It({ value: e?.top }),
|
|
3809
|
+
right: It({ value: e?.right }),
|
|
3810
|
+
bottom: It({ value: e?.bottom }),
|
|
3811
|
+
left: It({ value: e?.left })
|
|
3812
|
+
};
|
|
3813
|
+
}
|
|
3814
|
+
function Bt({ stroke: e, strokeWidth: t }) {
|
|
3815
|
+
if (!Lt({
|
|
3816
3816
|
stroke: e,
|
|
3817
3817
|
strokeWidth: t
|
|
3818
3818
|
})) return {
|
|
@@ -3829,16 +3829,16 @@ function zt({ stroke: e, strokeWidth: t }) {
|
|
|
3829
3829
|
left: n
|
|
3830
3830
|
};
|
|
3831
3831
|
}
|
|
3832
|
-
function
|
|
3833
|
-
return t ?
|
|
3832
|
+
function Vt({ base: e, override: t }) {
|
|
3833
|
+
return t ? zt({ padding: {
|
|
3834
3834
|
top: t.top ?? e.top,
|
|
3835
3835
|
right: t.right ?? e.right,
|
|
3836
3836
|
bottom: t.bottom ?? e.bottom,
|
|
3837
3837
|
left: t.left ?? e.left
|
|
3838
3838
|
} }) : e;
|
|
3839
3839
|
}
|
|
3840
|
-
function
|
|
3841
|
-
let n =
|
|
3840
|
+
function Ht({ base: e, addition: t }) {
|
|
3841
|
+
let n = Rt({ padding: e }), r = Rt({ padding: t });
|
|
3842
3842
|
return {
|
|
3843
3843
|
top: n.top + r.top,
|
|
3844
3844
|
right: n.right + r.right,
|
|
@@ -3846,16 +3846,16 @@ function Vt({ base: e, addition: t }) {
|
|
|
3846
3846
|
left: n.left + r.left
|
|
3847
3847
|
};
|
|
3848
3848
|
}
|
|
3849
|
-
function
|
|
3850
|
-
return
|
|
3849
|
+
function Ut({ baseInset: e, stroke: t, strokeWidth: n }) {
|
|
3850
|
+
return Ht({
|
|
3851
3851
|
base: e,
|
|
3852
|
-
addition:
|
|
3852
|
+
addition: Bt({
|
|
3853
3853
|
stroke: t,
|
|
3854
3854
|
strokeWidth: n
|
|
3855
3855
|
})
|
|
3856
3856
|
});
|
|
3857
3857
|
}
|
|
3858
|
-
function
|
|
3858
|
+
function Wt({ padding: e }) {
|
|
3859
3859
|
if (!e) return {};
|
|
3860
3860
|
let t = {}, n = Object.keys(e);
|
|
3861
3861
|
for (let r = 0; r < n.length; r += 1) {
|
|
@@ -3866,17 +3866,17 @@ function Ut({ padding: e }) {
|
|
|
3866
3866
|
}
|
|
3867
3867
|
//#endregion
|
|
3868
3868
|
//#region src/editor/shape-manager/layout/shape-layout-padding.ts
|
|
3869
|
-
var
|
|
3870
|
-
function
|
|
3869
|
+
var Gt = .5, Kt = 12;
|
|
3870
|
+
function qt({ width: e, padding: t }) {
|
|
3871
3871
|
let n = Math.max(0, t.left), r = Math.max(0, t.right);
|
|
3872
3872
|
return Math.max(1, e - n - r);
|
|
3873
3873
|
}
|
|
3874
|
-
function
|
|
3874
|
+
function Jt({ text: e }) {
|
|
3875
3875
|
return (e.text ?? "").trim().length > 0;
|
|
3876
3876
|
}
|
|
3877
|
-
function
|
|
3877
|
+
function Yt({ start: e, end: t, maxTotalPadding: n, startChanged: r, endChanged: i }) {
|
|
3878
3878
|
let a = Math.max(0, e), o = Math.max(0, t), s = Math.max(0, n);
|
|
3879
|
-
if (a + o <= s +
|
|
3879
|
+
if (a + o <= s + Gt) return {
|
|
3880
3880
|
start: a,
|
|
3881
3881
|
end: o
|
|
3882
3882
|
};
|
|
@@ -3905,8 +3905,8 @@ function Jt({ start: e, end: t, maxTotalPadding: n, startChanged: r, endChanged:
|
|
|
3905
3905
|
end: o * l
|
|
3906
3906
|
};
|
|
3907
3907
|
}
|
|
3908
|
-
function
|
|
3909
|
-
let s = Math.max(0, n), c = Math.max(0, r), l = Math.max(0, i - s - c), u =
|
|
3908
|
+
function Xt({ start: e, end: t, insetStart: n, insetEnd: r, maxTotalPadding: i, startChanged: a, endChanged: o }) {
|
|
3909
|
+
let s = Math.max(0, n), c = Math.max(0, r), l = Math.max(0, i - s - c), u = Yt({
|
|
3910
3910
|
start: Math.max(0, e),
|
|
3911
3911
|
end: Math.max(0, t),
|
|
3912
3912
|
maxTotalPadding: l,
|
|
@@ -3920,23 +3920,23 @@ function Yt({ start: e, end: t, insetStart: n, insetEnd: r, maxTotalPadding: i,
|
|
|
3920
3920
|
appliedUserPaddingEnd: f
|
|
3921
3921
|
};
|
|
3922
3922
|
}
|
|
3923
|
-
function
|
|
3923
|
+
function Zt({ text: e, minFrameWidth: t, maxFrameWidth: n, frameHeight: r, measureTextboxHeightForFrame: i }) {
|
|
3924
3924
|
let a = Math.max(1, t), o = Math.max(a, n), s = Math.max(1, r);
|
|
3925
|
-
if (!
|
|
3925
|
+
if (!Jt({ text: e }) || i({
|
|
3926
3926
|
text: e,
|
|
3927
3927
|
frameWidth: a
|
|
3928
|
-
}) <= s +
|
|
3928
|
+
}) <= s + Gt) return a;
|
|
3929
3929
|
if (i({
|
|
3930
3930
|
text: e,
|
|
3931
3931
|
frameWidth: o
|
|
3932
|
-
}) > s +
|
|
3932
|
+
}) > s + Gt) return o;
|
|
3933
3933
|
let c = a, l = o;
|
|
3934
|
-
for (let t = 0; t <
|
|
3934
|
+
for (let t = 0; t < Kt; t += 1) {
|
|
3935
3935
|
let t = (c + l) / 2;
|
|
3936
3936
|
if (i({
|
|
3937
3937
|
text: e,
|
|
3938
3938
|
frameWidth: t
|
|
3939
|
-
}) <= s +
|
|
3939
|
+
}) <= s + Gt) {
|
|
3940
3940
|
l = t;
|
|
3941
3941
|
continue;
|
|
3942
3942
|
}
|
|
@@ -3944,16 +3944,16 @@ function Xt({ text: e, minFrameWidth: t, maxFrameWidth: n, frameHeight: r, measu
|
|
|
3944
3944
|
}
|
|
3945
3945
|
return l;
|
|
3946
3946
|
}
|
|
3947
|
-
function
|
|
3948
|
-
let l = Math.max(1, t), u = Math.max(1, n), d =
|
|
3949
|
-
a || (m =
|
|
3947
|
+
function Qt({ text: e, width: t, height: n, padding: r, internalShapeTextInset: i, expandShapeHeightToFitText: a, changedPadding: o, measureTextboxHeightForFrame: s, resolveMinimumTextFrameWidth: c }) {
|
|
3948
|
+
let l = Math.max(1, t), u = Math.max(1, n), d = Jt({ text: e }) ? c({ text: e }) : 1, f = i.top + i.bottom, p = Math.max(1, u - f), m = d;
|
|
3949
|
+
a || (m = Zt({
|
|
3950
3950
|
text: e,
|
|
3951
3951
|
minFrameWidth: d,
|
|
3952
3952
|
maxFrameWidth: l,
|
|
3953
3953
|
frameHeight: p,
|
|
3954
3954
|
measureTextboxHeightForFrame: s
|
|
3955
3955
|
}));
|
|
3956
|
-
let h = m + i.left + i.right, g = Math.max(0, l - m), _ =
|
|
3956
|
+
let h = m + i.left + i.right, g = Math.max(0, l - m), _ = Xt({
|
|
3957
3957
|
start: r.left,
|
|
3958
3958
|
end: r.right,
|
|
3959
3959
|
insetStart: i.left,
|
|
@@ -3974,8 +3974,8 @@ function Zt({ text: e, width: t, height: n, padding: r, internalShapeTextInset:
|
|
|
3974
3974
|
requiredWidth: h
|
|
3975
3975
|
};
|
|
3976
3976
|
}
|
|
3977
|
-
function
|
|
3978
|
-
let a = Math.max(0, Math.max(1, n) - Math.max(1, r)), o =
|
|
3977
|
+
function $t({ padding: e, internalShapeTextInset: t, height: n, textHeight: r, changedPadding: i }) {
|
|
3978
|
+
let a = Math.max(0, Math.max(1, n) - Math.max(1, r)), o = Xt({
|
|
3979
3979
|
start: e.top,
|
|
3980
3980
|
end: e.bottom,
|
|
3981
3981
|
insetStart: t.top,
|
|
@@ -3995,8 +3995,8 @@ function Qt({ padding: e, internalShapeTextInset: t, height: n, textHeight: r, c
|
|
|
3995
3995
|
}
|
|
3996
3996
|
};
|
|
3997
3997
|
}
|
|
3998
|
-
function
|
|
3999
|
-
let l = Math.max(1, t), u = Math.max(1, n), d =
|
|
3998
|
+
function en({ text: e, width: t, height: n, padding: r, internalShapeTextInset: i, expandShapeHeightToFitText: a, changedPadding: o, measureTextboxHeightForFrame: s, resolveMinimumTextFrameWidth: c }) {
|
|
3999
|
+
let l = Math.max(1, t), u = Math.max(1, n), d = Rt({ padding: r }), f = Rt({ padding: i }), p = Qt({
|
|
4000
4000
|
text: e,
|
|
4001
4001
|
width: l,
|
|
4002
4002
|
height: u,
|
|
@@ -4006,7 +4006,7 @@ function $t({ text: e, width: t, height: n, padding: r, internalShapeTextInset:
|
|
|
4006
4006
|
changedPadding: o,
|
|
4007
4007
|
measureTextboxHeightForFrame: s,
|
|
4008
4008
|
resolveMinimumTextFrameWidth: c
|
|
4009
|
-
}), m =
|
|
4009
|
+
}), m = qt({
|
|
4010
4010
|
width: l,
|
|
4011
4011
|
padding: {
|
|
4012
4012
|
top: 0,
|
|
@@ -4014,10 +4014,10 @@ function $t({ text: e, width: t, height: n, padding: r, internalShapeTextInset:
|
|
|
4014
4014
|
bottom: 0,
|
|
4015
4015
|
left: p.appliedPadding.left
|
|
4016
4016
|
}
|
|
4017
|
-
}), h =
|
|
4017
|
+
}), h = Jt({ text: e }) ? s({
|
|
4018
4018
|
text: e,
|
|
4019
4019
|
frameWidth: m
|
|
4020
|
-
}) : 1, g = f.top + f.bottom, _ = a ? Math.max(u, h + g) : u, v =
|
|
4020
|
+
}) : 1, g = f.top + f.bottom, _ = a ? Math.max(u, h + g) : u, v = $t({
|
|
4021
4021
|
padding: d,
|
|
4022
4022
|
internalShapeTextInset: f,
|
|
4023
4023
|
height: _,
|
|
@@ -4043,8 +4043,8 @@ function $t({ text: e, width: t, height: n, padding: r, internalShapeTextInset:
|
|
|
4043
4043
|
}
|
|
4044
4044
|
//#endregion
|
|
4045
4045
|
//#region src/editor/shape-manager/layout/shape-layout.ts
|
|
4046
|
-
var q = 1,
|
|
4047
|
-
let d =
|
|
4046
|
+
var q = 1, tn = .5, nn = 8, rn = ({ group: e, shape: t, text: n, width: r, height: i, alignH: a, alignV: o, padding: s, internalShapeTextInset: c, expandShapeHeightToFitText: l = !0, changedPadding: u }) => {
|
|
4047
|
+
let d = zt({ padding: s }), f = Rt({ padding: c }), p = Math.max(q, e.shapeManualBaseWidth ?? r), m = Math.max(q, e.shapeManualBaseHeight ?? i), h = Math.max(q, i), g = Math.max(q, r), _ = en({
|
|
4048
4048
|
text: n,
|
|
4049
4049
|
width: g,
|
|
4050
4050
|
height: h,
|
|
@@ -4052,13 +4052,13 @@ var q = 1, en = .5, tn = 8, nn = ({ group: e, shape: t, text: n, width: r, heigh
|
|
|
4052
4052
|
internalShapeTextInset: f,
|
|
4053
4053
|
expandShapeHeightToFitText: l,
|
|
4054
4054
|
changedPadding: u,
|
|
4055
|
-
measureTextboxHeightForFrame:
|
|
4056
|
-
resolveMinimumTextFrameWidth:
|
|
4055
|
+
measureTextboxHeightForFrame: pn,
|
|
4056
|
+
resolveMinimumTextFrameWidth: mn
|
|
4057
4057
|
});
|
|
4058
|
-
for (let e = 0; e <
|
|
4058
|
+
for (let e = 0; e < nn; e += 1) {
|
|
4059
4059
|
let e = Math.max(g, _.requiredWidth);
|
|
4060
|
-
if (e <= g +
|
|
4061
|
-
g = e, _ =
|
|
4060
|
+
if (e <= g + tn) break;
|
|
4061
|
+
g = e, _ = en({
|
|
4062
4062
|
text: n,
|
|
4063
4063
|
width: g,
|
|
4064
4064
|
height: h,
|
|
@@ -4066,19 +4066,19 @@ var q = 1, en = .5, tn = 8, nn = ({ group: e, shape: t, text: n, width: r, heigh
|
|
|
4066
4066
|
internalShapeTextInset: f,
|
|
4067
4067
|
expandShapeHeightToFitText: l,
|
|
4068
4068
|
changedPadding: u,
|
|
4069
|
-
measureTextboxHeightForFrame:
|
|
4070
|
-
resolveMinimumTextFrameWidth:
|
|
4069
|
+
measureTextboxHeightForFrame: pn,
|
|
4070
|
+
resolveMinimumTextFrameWidth: mn
|
|
4071
4071
|
});
|
|
4072
4072
|
}
|
|
4073
4073
|
let { appliedPadding: v, appliedUserPadding: y, requiredHeight: b } = _, x = Math.max(q, b);
|
|
4074
|
-
|
|
4074
|
+
xt({
|
|
4075
4075
|
shape: t,
|
|
4076
4076
|
width: g,
|
|
4077
4077
|
height: x,
|
|
4078
4078
|
rounding: e.shapeRounding,
|
|
4079
4079
|
strokeWidth: e.shapeStrokeWidth
|
|
4080
4080
|
});
|
|
4081
|
-
let { frame: S, splitByGrapheme: C, textTop: w } =
|
|
4081
|
+
let { frame: S, splitByGrapheme: C, textTop: w } = sn({
|
|
4082
4082
|
text: n,
|
|
4083
4083
|
width: g,
|
|
4084
4084
|
height: x,
|
|
@@ -4107,45 +4107,45 @@ var q = 1, en = .5, tn = 8, nn = ({ group: e, shape: t, text: n, width: r, heigh
|
|
|
4107
4107
|
scaleX: 1,
|
|
4108
4108
|
scaleY: 1
|
|
4109
4109
|
}), e.set("dirty", !0), e.setCoords();
|
|
4110
|
-
},
|
|
4110
|
+
}, an = ({ text: e, currentWidth: t, minimumWidth: n, padding: r, montageAreaWidth: i }) => {
|
|
4111
4111
|
let a = Math.max(q, t), o = Math.max(q, n);
|
|
4112
|
-
if (!
|
|
4113
|
-
let s = Number.isFinite(i) && i > 0 ? Math.max(q, i) : Math.max(a, o), c =
|
|
4112
|
+
if (!ln({ text: e })) return o;
|
|
4113
|
+
let s = Number.isFinite(i) && i > 0 ? Math.max(q, i) : Math.max(a, o), c = Rt({ padding: r }), l = Math.max(o, s), u = qt({
|
|
4114
4114
|
width: l,
|
|
4115
4115
|
padding: c
|
|
4116
|
-
}), d = l, f =
|
|
4116
|
+
}), d = l, f = fn({
|
|
4117
4117
|
text: e,
|
|
4118
4118
|
frameWidth: u
|
|
4119
4119
|
});
|
|
4120
4120
|
if (f.hasWrappedLines) return d;
|
|
4121
4121
|
let p = Math.max(q, f.longestLineWidth), m = Math.max(q, p + c.left + c.right), h = Math.min(d, Math.max(o, m));
|
|
4122
|
-
for (let t = 0; t <
|
|
4123
|
-
let t =
|
|
4122
|
+
for (let t = 0; t < nn; t += 1) {
|
|
4123
|
+
let t = qt({
|
|
4124
4124
|
width: h,
|
|
4125
4125
|
padding: c
|
|
4126
|
-
}), n =
|
|
4126
|
+
}), n = fn({
|
|
4127
4127
|
text: e,
|
|
4128
4128
|
frameWidth: t
|
|
4129
|
-
}), r = t >= p -
|
|
4129
|
+
}), r = t >= p - tn;
|
|
4130
4130
|
if (!n.hasWrappedLines && r) return h;
|
|
4131
|
-
if (h >= d -
|
|
4131
|
+
if (h >= d - tn) return d;
|
|
4132
4132
|
let i = n.hasWrappedLines ? Math.max(m + 1, h + 1) : p;
|
|
4133
4133
|
h = Math.min(d, Math.max(h + 1, n.hasWrappedLines ? i : m));
|
|
4134
4134
|
}
|
|
4135
4135
|
return h;
|
|
4136
|
-
},
|
|
4137
|
-
if (!
|
|
4138
|
-
let n =
|
|
4139
|
-
return
|
|
4140
|
-
},
|
|
4141
|
-
let a =
|
|
4136
|
+
}, on = ({ text: e, padding: t }) => {
|
|
4137
|
+
if (!ln({ text: e })) return q;
|
|
4138
|
+
let n = Rt({ padding: t });
|
|
4139
|
+
return mn({ text: e }) + n.left + n.right;
|
|
4140
|
+
}, sn = ({ text: e, width: t, height: n, alignV: r, padding: i }) => {
|
|
4141
|
+
let a = un({
|
|
4142
4142
|
width: Math.max(q, t),
|
|
4143
4143
|
height: Math.max(q, n),
|
|
4144
|
-
padding:
|
|
4145
|
-
}), o =
|
|
4144
|
+
padding: Rt({ padding: i })
|
|
4145
|
+
}), o = _n({
|
|
4146
4146
|
text: e,
|
|
4147
4147
|
frameWidth: a.width
|
|
4148
|
-
}), s =
|
|
4148
|
+
}), s = pn({
|
|
4149
4149
|
text: e,
|
|
4150
4150
|
frameWidth: a.width,
|
|
4151
4151
|
splitByGrapheme: o
|
|
@@ -4153,29 +4153,29 @@ var q = 1, en = .5, tn = 8, nn = ({ group: e, shape: t, text: n, width: r, heigh
|
|
|
4153
4153
|
return {
|
|
4154
4154
|
frame: a,
|
|
4155
4155
|
splitByGrapheme: o,
|
|
4156
|
-
textTop:
|
|
4156
|
+
textTop: gn({
|
|
4157
4157
|
alignV: r,
|
|
4158
4158
|
frameHeight: a.height,
|
|
4159
4159
|
frameTop: a.top,
|
|
4160
4160
|
textHeight: s
|
|
4161
4161
|
})
|
|
4162
4162
|
};
|
|
4163
|
-
},
|
|
4163
|
+
}, cn = ({ text: e, width: t, height: n, padding: r }) => {
|
|
4164
4164
|
let i = Math.max(q, n);
|
|
4165
|
-
if (!
|
|
4166
|
-
let a = Math.max(q, t), o =
|
|
4165
|
+
if (!ln({ text: e })) return i;
|
|
4166
|
+
let a = Math.max(q, t), o = Rt({ padding: r }), s = pn({
|
|
4167
4167
|
text: e,
|
|
4168
|
-
frameWidth:
|
|
4168
|
+
frameWidth: qt({
|
|
4169
4169
|
width: a,
|
|
4170
4170
|
padding: o
|
|
4171
4171
|
})
|
|
4172
4172
|
});
|
|
4173
4173
|
return Math.max(i, s + o.top + o.bottom);
|
|
4174
4174
|
};
|
|
4175
|
-
function
|
|
4175
|
+
function ln({ text: e }) {
|
|
4176
4176
|
return (e.text ?? "").trim().length > 0;
|
|
4177
4177
|
}
|
|
4178
|
-
function
|
|
4178
|
+
function un({ width: e, height: t, padding: n }) {
|
|
4179
4179
|
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);
|
|
4180
4180
|
return {
|
|
4181
4181
|
left: -e / 2 + r,
|
|
@@ -4184,7 +4184,7 @@ function ln({ width: e, height: t, padding: n }) {
|
|
|
4184
4184
|
height: Math.max(q, t - a - o)
|
|
4185
4185
|
};
|
|
4186
4186
|
}
|
|
4187
|
-
function
|
|
4187
|
+
function dn({ text: e }) {
|
|
4188
4188
|
let { height: t } = e;
|
|
4189
4189
|
if (typeof t == "number" && Number.isFinite(t)) return t;
|
|
4190
4190
|
if (typeof e.calcTextHeight == "function") {
|
|
@@ -4193,18 +4193,18 @@ function un({ text: e }) {
|
|
|
4193
4193
|
}
|
|
4194
4194
|
return q;
|
|
4195
4195
|
}
|
|
4196
|
-
function
|
|
4197
|
-
let n =
|
|
4196
|
+
function fn({ text: e, frameWidth: t }) {
|
|
4197
|
+
let n = yn({ text: e }), r = _n({
|
|
4198
4198
|
text: e,
|
|
4199
4199
|
frameWidth: t
|
|
4200
|
-
}), i =
|
|
4200
|
+
}), i = Sn({ text: e });
|
|
4201
4201
|
e.set({
|
|
4202
4202
|
autoExpand: !1,
|
|
4203
4203
|
width: Math.max(q, t),
|
|
4204
4204
|
splitByGrapheme: r
|
|
4205
4205
|
}), e.initDimensions();
|
|
4206
|
-
let a =
|
|
4207
|
-
return
|
|
4206
|
+
let a = bn({ text: e }) > n, o = Math.ceil(vn({ text: e }));
|
|
4207
|
+
return Cn({
|
|
4208
4208
|
text: e,
|
|
4209
4209
|
state: i
|
|
4210
4210
|
}), {
|
|
@@ -4212,8 +4212,8 @@ function dn({ text: e, frameWidth: t }) {
|
|
|
4212
4212
|
longestLineWidth: o
|
|
4213
4213
|
};
|
|
4214
4214
|
}
|
|
4215
|
-
function
|
|
4216
|
-
let r =
|
|
4215
|
+
function pn({ text: e, frameWidth: t, splitByGrapheme: n }) {
|
|
4216
|
+
let r = Sn({ text: e }), i = n ?? _n({
|
|
4217
4217
|
text: e,
|
|
4218
4218
|
frameWidth: t
|
|
4219
4219
|
});
|
|
@@ -4222,71 +4222,71 @@ function fn({ text: e, frameWidth: t, splitByGrapheme: n }) {
|
|
|
4222
4222
|
width: Math.max(q, t),
|
|
4223
4223
|
splitByGrapheme: i
|
|
4224
4224
|
}), e.initDimensions();
|
|
4225
|
-
let a =
|
|
4226
|
-
return
|
|
4225
|
+
let a = dn({ text: e });
|
|
4226
|
+
return Cn({
|
|
4227
4227
|
text: e,
|
|
4228
4228
|
state: r
|
|
4229
4229
|
}), a;
|
|
4230
4230
|
}
|
|
4231
|
-
function
|
|
4232
|
-
let t =
|
|
4231
|
+
function mn({ text: e }) {
|
|
4232
|
+
let t = hn({
|
|
4233
4233
|
text: e,
|
|
4234
4234
|
frameWidth: q,
|
|
4235
4235
|
splitByGrapheme: !0
|
|
4236
4236
|
});
|
|
4237
4237
|
return Math.max(q, t);
|
|
4238
4238
|
}
|
|
4239
|
-
function
|
|
4240
|
-
let r =
|
|
4239
|
+
function hn({ text: e, frameWidth: t, splitByGrapheme: n }) {
|
|
4240
|
+
let r = Sn({ text: e });
|
|
4241
4241
|
e.set({
|
|
4242
4242
|
autoExpand: !1,
|
|
4243
4243
|
width: Math.max(q, t),
|
|
4244
4244
|
splitByGrapheme: n
|
|
4245
4245
|
}), e.initDimensions();
|
|
4246
|
-
let i =
|
|
4247
|
-
return
|
|
4246
|
+
let i = vn({ text: e });
|
|
4247
|
+
return Cn({
|
|
4248
4248
|
text: e,
|
|
4249
4249
|
state: r
|
|
4250
4250
|
}), i;
|
|
4251
4251
|
}
|
|
4252
|
-
function
|
|
4252
|
+
function gn({ alignV: e, frameHeight: t, frameTop: n, textHeight: r }) {
|
|
4253
4253
|
let i = Math.max(0, t - r);
|
|
4254
4254
|
return e === "top" ? n : e === "bottom" ? n + i : n + i / 2;
|
|
4255
4255
|
}
|
|
4256
|
-
function
|
|
4257
|
-
let n = Math.max(q, t), r =
|
|
4256
|
+
function _n({ text: e, frameWidth: t }) {
|
|
4257
|
+
let n = Math.max(q, t), r = Sn({ text: e });
|
|
4258
4258
|
e.set({
|
|
4259
4259
|
autoExpand: !1,
|
|
4260
4260
|
width: n,
|
|
4261
4261
|
splitByGrapheme: !1
|
|
4262
4262
|
}), e.initDimensions();
|
|
4263
|
-
let i =
|
|
4264
|
-
return
|
|
4263
|
+
let i = wn({ text: e }) > n + tn;
|
|
4264
|
+
return Cn({
|
|
4265
4265
|
text: e,
|
|
4266
4266
|
state: r
|
|
4267
4267
|
}), i;
|
|
4268
4268
|
}
|
|
4269
|
-
function
|
|
4270
|
-
let t =
|
|
4271
|
-
if (t > 0) return
|
|
4269
|
+
function vn({ text: e }) {
|
|
4270
|
+
let t = bn({ text: e });
|
|
4271
|
+
if (t > 0) return xn({
|
|
4272
4272
|
text: e,
|
|
4273
4273
|
lineCount: t
|
|
4274
4274
|
});
|
|
4275
4275
|
let n = e.text ?? "";
|
|
4276
|
-
return
|
|
4276
|
+
return xn({
|
|
4277
4277
|
text: e,
|
|
4278
4278
|
lineCount: Math.max(n.split("\n").length, 1)
|
|
4279
4279
|
});
|
|
4280
4280
|
}
|
|
4281
|
-
function
|
|
4281
|
+
function yn({ text: e }) {
|
|
4282
4282
|
let t = e.text ?? "";
|
|
4283
4283
|
return Math.max(t.split("\n").length, 1);
|
|
4284
4284
|
}
|
|
4285
|
-
function
|
|
4285
|
+
function bn({ text: e }) {
|
|
4286
4286
|
let t = e;
|
|
4287
4287
|
return Array.isArray(t.textLines) ? t.textLines.length : 0;
|
|
4288
4288
|
}
|
|
4289
|
-
function
|
|
4289
|
+
function xn({ text: e, lineCount: t }) {
|
|
4290
4290
|
let n = q;
|
|
4291
4291
|
for (let r = 0; r < t; r += 1) {
|
|
4292
4292
|
let t = e.getLineWidth(r);
|
|
@@ -4294,7 +4294,7 @@ function bn({ text: e, lineCount: t }) {
|
|
|
4294
4294
|
}
|
|
4295
4295
|
return n;
|
|
4296
4296
|
}
|
|
4297
|
-
function
|
|
4297
|
+
function Sn({ text: e }) {
|
|
4298
4298
|
let { autoExpand: t, splitByGrapheme: n, width: r } = e;
|
|
4299
4299
|
return {
|
|
4300
4300
|
autoExpand: t,
|
|
@@ -4302,23 +4302,23 @@ function xn({ text: e }) {
|
|
|
4302
4302
|
width: typeof r == "number" ? r : void 0
|
|
4303
4303
|
};
|
|
4304
4304
|
}
|
|
4305
|
-
function
|
|
4305
|
+
function Cn({ text: e, state: t }) {
|
|
4306
4306
|
let { autoExpand: n, splitByGrapheme: r, width: i } = t, a = {};
|
|
4307
4307
|
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());
|
|
4308
4308
|
}
|
|
4309
|
-
function
|
|
4309
|
+
function wn({ text: e }) {
|
|
4310
4310
|
let { dynamicMinWidth: t } = e;
|
|
4311
4311
|
return typeof t == "number" && Number.isFinite(t) ? t : 0;
|
|
4312
4312
|
}
|
|
4313
4313
|
//#endregion
|
|
4314
4314
|
//#region src/editor/shape-manager/shape-runtime.ts
|
|
4315
|
-
var
|
|
4315
|
+
var Tn = ({ group: e }) => {
|
|
4316
4316
|
let t = e;
|
|
4317
4317
|
typeof t.setInteractive == "function" && t.setInteractive(!0), t.set({
|
|
4318
4318
|
interactive: !0,
|
|
4319
4319
|
subTargetCheck: !0
|
|
4320
4320
|
});
|
|
4321
|
-
},
|
|
4321
|
+
}, En = ({ text: e }) => {
|
|
4322
4322
|
let t = !!(e.locked || e.group?.locked);
|
|
4323
4323
|
e.set({
|
|
4324
4324
|
hasBorders: !1,
|
|
@@ -4331,7 +4331,7 @@ var wn = ({ group: e }) => {
|
|
|
4331
4331
|
autoExpand: !1,
|
|
4332
4332
|
shapeNodeType: "text"
|
|
4333
4333
|
}), e.setCoords();
|
|
4334
|
-
},
|
|
4334
|
+
}, Dn = ({ group: e }) => {
|
|
4335
4335
|
let { layoutManager: t } = e;
|
|
4336
4336
|
if (!t || typeof t.unsubscribeTargets != "function") return;
|
|
4337
4337
|
let n = e.getObjects();
|
|
@@ -4339,7 +4339,7 @@ var wn = ({ group: e }) => {
|
|
|
4339
4339
|
target: e,
|
|
4340
4340
|
targets: n
|
|
4341
4341
|
});
|
|
4342
|
-
},
|
|
4342
|
+
}, On = ({ group: e }) => {
|
|
4343
4343
|
let t = e.getObjects();
|
|
4344
4344
|
for (let e = 0; e < t.length; e += 1) {
|
|
4345
4345
|
let n = t[e];
|
|
@@ -4350,23 +4350,23 @@ var wn = ({ group: e }) => {
|
|
|
4350
4350
|
if (n instanceof _) return n;
|
|
4351
4351
|
}
|
|
4352
4352
|
return null;
|
|
4353
|
-
},
|
|
4353
|
+
}, kn = [
|
|
4354
4354
|
"tl",
|
|
4355
4355
|
"tr",
|
|
4356
4356
|
"bl",
|
|
4357
4357
|
"br"
|
|
4358
|
-
],
|
|
4358
|
+
], An = ({ transform: e }) => {
|
|
4359
4359
|
let { originX: t, originY: n } = e;
|
|
4360
4360
|
return (t === "center" || t === .5) && (n === "center" || n === .5);
|
|
4361
|
-
},
|
|
4361
|
+
}, jn = ({ transform: e, x: t, y: n }) => {
|
|
4362
4362
|
let r = e, { target: i } = r, { scaleX: a = 1, scaleY: o = 1 } = i, s = b.getLocalPoint(r, r.originX, r.originY, t, n), c = Math.sign(s.x || r.signX || 1), l = Math.sign(s.y || r.signY || 1);
|
|
4363
4363
|
r.signX === void 0 && (r.signX = c), r.signY === void 0 && (r.signY = l);
|
|
4364
4364
|
let u = i._getTransformedDimensions(), d = Math.abs(s.x * a / u.x), f = Math.abs(s.y * o / u.y);
|
|
4365
|
-
|
|
4365
|
+
An({ transform: r }) && (d *= 2, f *= 2);
|
|
4366
4366
|
let p = !i.lockScalingX && (!i.lockScalingFlip || r.signX === c), m = !i.lockScalingY && (!i.lockScalingFlip || r.signY === l);
|
|
4367
4367
|
return p && i.set("scaleX", d), m && i.set("scaleY", f), a !== i.scaleX || o !== i.scaleY;
|
|
4368
|
-
},
|
|
4369
|
-
let e = b.wrapWithFireEvent("scaling", b.wrapWithFixedAnchor((e, t, n, r) =>
|
|
4368
|
+
}, Mn = () => {
|
|
4369
|
+
let e = b.wrapWithFireEvent("scaling", b.wrapWithFixedAnchor((e, t, n, r) => jn({
|
|
4370
4370
|
transform: t,
|
|
4371
4371
|
x: n,
|
|
4372
4372
|
y: r
|
|
@@ -4382,31 +4382,31 @@ var wn = ({ group: e }) => {
|
|
|
4382
4382
|
a.uniformScaling = s;
|
|
4383
4383
|
}
|
|
4384
4384
|
};
|
|
4385
|
-
},
|
|
4385
|
+
}, Nn = ({ control: e }) => {
|
|
4386
4386
|
let t = new r({
|
|
4387
4387
|
...e,
|
|
4388
|
-
actionHandler:
|
|
4388
|
+
actionHandler: Mn()
|
|
4389
4389
|
});
|
|
4390
4390
|
return t.shapeFreeScaleCornerControl = !0, t;
|
|
4391
|
-
},
|
|
4391
|
+
}, Pn = ({ group: e }) => {
|
|
4392
4392
|
let t = { ...e.controls };
|
|
4393
|
-
|
|
4393
|
+
kn.forEach((n) => {
|
|
4394
4394
|
let r = e.controls[n];
|
|
4395
|
-
r && (r.shapeFreeScaleCornerControl || (t[n] =
|
|
4395
|
+
r && (r.shapeFreeScaleCornerControl || (t[n] = Nn({ control: r })));
|
|
4396
4396
|
}), e.controls = t;
|
|
4397
|
-
},
|
|
4398
|
-
function
|
|
4397
|
+
}, Fn = "shape-group";
|
|
4398
|
+
function In() {
|
|
4399
4399
|
return { performLayout() {} };
|
|
4400
4400
|
}
|
|
4401
|
-
function
|
|
4401
|
+
function Ln({ layoutManager: e }) {
|
|
4402
4402
|
let t = y.getClass("layoutManager");
|
|
4403
4403
|
if (!e) return new t();
|
|
4404
4404
|
let { strategy: n, type: r } = e, i = y.getClass(r);
|
|
4405
4405
|
return n ? new i(new (y.getClass(n))()) : new i();
|
|
4406
4406
|
}
|
|
4407
|
-
var
|
|
4407
|
+
var Rn = class e extends l {
|
|
4408
4408
|
static {
|
|
4409
|
-
this.type =
|
|
4409
|
+
this.type = Fn;
|
|
4410
4410
|
}
|
|
4411
4411
|
constructor(e = [], t = {}) {
|
|
4412
4412
|
let { layoutManager: n, objectCaching: r, centeredScaling: i, lockScalingFlip: a, ...o } = t;
|
|
@@ -4422,24 +4422,24 @@ var Ln = class e extends l {
|
|
|
4422
4422
|
this.set({
|
|
4423
4423
|
objectCaching: !1,
|
|
4424
4424
|
shapeComposite: !0
|
|
4425
|
-
}), this.shapeTextAutoExpand === void 0 && (this.shapeTextAutoExpand = !0);
|
|
4426
|
-
let e =
|
|
4425
|
+
}), this.shapeTextAutoExpand === void 0 && (this.shapeTextAutoExpand = !0), this.shapeAlignHorizontal === void 0 && (this.shapeAlignHorizontal = st), this.shapeAlignVertical === void 0 && (this.shapeAlignVertical = ct);
|
|
4426
|
+
let e = zt({ padding: {
|
|
4427
4427
|
top: this.shapePaddingTop,
|
|
4428
4428
|
right: this.shapePaddingRight,
|
|
4429
4429
|
bottom: this.shapePaddingBottom,
|
|
4430
4430
|
left: this.shapePaddingLeft
|
|
4431
4431
|
} });
|
|
4432
|
-
this.shapePaddingTop = e.top, this.shapePaddingRight = e.right, this.shapePaddingBottom = e.bottom, this.shapePaddingLeft = e.left, this._syncRoundability(),
|
|
4433
|
-
let t =
|
|
4434
|
-
t &&
|
|
4432
|
+
this.shapePaddingTop = e.top, this.shapePaddingRight = e.right, this.shapePaddingBottom = e.bottom, this.shapePaddingLeft = e.left, this._syncRoundability(), Tn({ group: this }), Pn({ group: this });
|
|
4433
|
+
let t = On({ group: this });
|
|
4434
|
+
t && En({ text: t }), Dn({ group: this }), this.setCoords();
|
|
4435
4435
|
}
|
|
4436
4436
|
static async fromObject({ type: t, objects: n = [], layoutManager: r, ...i }, a) {
|
|
4437
4437
|
let [o, s] = await Promise.all([C.enlivenObjects(n, a), C.enlivenObjectEnlivables(i, a)]), c = new e(o, {
|
|
4438
4438
|
...i,
|
|
4439
4439
|
...s,
|
|
4440
|
-
layoutManager:
|
|
4440
|
+
layoutManager: In()
|
|
4441
4441
|
});
|
|
4442
|
-
return c.layoutManager =
|
|
4442
|
+
return c.layoutManager = Ln({ layoutManager: r }), c.layoutManager.subscribeTargets({
|
|
4443
4443
|
type: "initialization",
|
|
4444
4444
|
target: c,
|
|
4445
4445
|
targets: c.getObjects()
|
|
@@ -4449,12 +4449,12 @@ var Ln = class e extends l {
|
|
|
4449
4449
|
if (typeof this.shapeCanRound == "boolean") return;
|
|
4450
4450
|
let e = this.shapePresetKey;
|
|
4451
4451
|
if (!e) return;
|
|
4452
|
-
let t =
|
|
4453
|
-
t && (this.shapeCanRound =
|
|
4452
|
+
let t = dt({ presetKey: e });
|
|
4453
|
+
t && (this.shapeCanRound = gt({ preset: t }));
|
|
4454
4454
|
}
|
|
4455
|
-
},
|
|
4456
|
-
y?.setClass && y.setClass(
|
|
4457
|
-
}, J = (e) => e instanceof
|
|
4455
|
+
}, zn = () => {
|
|
4456
|
+
y?.setClass && y.setClass(Rn, Fn);
|
|
4457
|
+
}, J = (e) => e instanceof Rn || e instanceof l && e.shapeComposite === !0, Bn = ({ target: e, subTargets: t = [] }) => {
|
|
4458
4458
|
if (J(e)) return e;
|
|
4459
4459
|
if (e?.group && J(e.group)) return e.group;
|
|
4460
4460
|
for (let e = 0; e < t.length; e += 1) {
|
|
@@ -4464,7 +4464,7 @@ var Ln = class e extends l {
|
|
|
4464
4464
|
if (r && J(r)) return r;
|
|
4465
4465
|
}
|
|
4466
4466
|
return null;
|
|
4467
|
-
},
|
|
4467
|
+
}, Vn = ({ group: e }) => {
|
|
4468
4468
|
let t = e.getObjects();
|
|
4469
4469
|
for (let e = 0; e < t.length; e += 1) {
|
|
4470
4470
|
let n = t[e];
|
|
@@ -4475,7 +4475,7 @@ var Ln = class e extends l {
|
|
|
4475
4475
|
if (!(n instanceof _)) return n;
|
|
4476
4476
|
}
|
|
4477
4477
|
return null;
|
|
4478
|
-
},
|
|
4478
|
+
}, Hn = ({ group: e }) => {
|
|
4479
4479
|
let t = e.getObjects();
|
|
4480
4480
|
for (let e = 0; e < t.length; e += 1) {
|
|
4481
4481
|
let n = t[e];
|
|
@@ -4487,16 +4487,16 @@ var Ln = class e extends l {
|
|
|
4487
4487
|
}
|
|
4488
4488
|
return null;
|
|
4489
4489
|
}, Y = ({ group: e }) => ({
|
|
4490
|
-
shape:
|
|
4491
|
-
text:
|
|
4492
|
-
}),
|
|
4493
|
-
|
|
4494
|
-
},
|
|
4490
|
+
shape: Vn({ group: e }),
|
|
4491
|
+
text: Hn({ group: e })
|
|
4492
|
+
}), Un = ({ group: e }) => {
|
|
4493
|
+
Tn({ group: e });
|
|
4494
|
+
}, Wn = ({ transform: e, key: t }) => {
|
|
4495
4495
|
let n = e?.original;
|
|
4496
4496
|
if (!n || typeof n != "object") return null;
|
|
4497
4497
|
let r = n[t];
|
|
4498
4498
|
return typeof r != "number" || !Number.isFinite(r) ? null : r;
|
|
4499
|
-
},
|
|
4499
|
+
}, Gn = ({ value: e }) => e === "left" || e === "center" || e === "right" || typeof e == "number" && Number.isFinite(e) ? e : null, Kn = ({ value: e }) => e === "top" || e === "center" || e === "bottom" || typeof e == "number" && Number.isFinite(e) ? e : null, qn = ({ transform: e }) => {
|
|
4500
4500
|
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;
|
|
4501
4501
|
return {
|
|
4502
4502
|
canScaleWidth: o,
|
|
@@ -4504,37 +4504,37 @@ var Ln = class e extends l {
|
|
|
4504
4504
|
isCornerScaleAction: r,
|
|
4505
4505
|
isVerticalOnlyScale: s && !o
|
|
4506
4506
|
};
|
|
4507
|
-
},
|
|
4507
|
+
}, Jn = ({ event: e, group: t, transform: n, canvas: r }) => {
|
|
4508
4508
|
if (!e) return null;
|
|
4509
4509
|
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;
|
|
4510
4510
|
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;
|
|
4511
|
-
},
|
|
4511
|
+
}, Yn = ({ group: e, originX: t, originY: n }) => {
|
|
4512
4512
|
if (t === null || n === null) return null;
|
|
4513
4513
|
let r = e, i = typeof r.getRelativeCenterPoint == "function" ? r.getRelativeCenterPoint() : e.getCenterPoint();
|
|
4514
4514
|
return typeof r.translateToOriginPoint == "function" ? r.translateToOriginPoint(i, t, n) : i;
|
|
4515
|
-
},
|
|
4515
|
+
}, Xn = ({ state: e, transform: t }) => {
|
|
4516
4516
|
if (!t || e.startTransformOriginX === null && e.startTransformOriginY === null) return !1;
|
|
4517
|
-
let n =
|
|
4517
|
+
let n = Gn({ value: t.originX }), r = Kn({ value: t.originY });
|
|
4518
4518
|
return n !== e.startTransformOriginX || r !== e.startTransformOriginY;
|
|
4519
|
-
},
|
|
4519
|
+
}, Zn = ({ state: e, transform: t }) => !t || !e.startTransformCorner ? !1 : t.corner !== e.startTransformCorner;
|
|
4520
4520
|
//#endregion
|
|
4521
4521
|
//#region src/editor/shape-manager/scaling/shape-scaling-preview.ts
|
|
4522
|
-
function
|
|
4522
|
+
function Qn({ size: e, scale: t, strokeWidth: n, minSize: r, scaleEpsilon: i }) {
|
|
4523
4523
|
let a = Math.max(i, Math.abs(t) || 1), o = Math.max(0, n);
|
|
4524
4524
|
return o <= 0 ? Math.max(r, e / a) : Math.max(r, e / a + o - o / a);
|
|
4525
4525
|
}
|
|
4526
|
-
function
|
|
4526
|
+
function $n({ group: e, shape: t, width: n, height: r, scaleX: i, scaleY: a, minSize: o, scaleEpsilon: s }) {
|
|
4527
4527
|
let c = Math.max(0, e.shapeStrokeWidth ?? 0);
|
|
4528
|
-
|
|
4528
|
+
xt({
|
|
4529
4529
|
shape: t,
|
|
4530
|
-
width:
|
|
4530
|
+
width: Qn({
|
|
4531
4531
|
size: n,
|
|
4532
4532
|
scale: i,
|
|
4533
4533
|
strokeWidth: c,
|
|
4534
4534
|
minSize: o,
|
|
4535
4535
|
scaleEpsilon: s
|
|
4536
4536
|
}),
|
|
4537
|
-
height:
|
|
4537
|
+
height: Qn({
|
|
4538
4538
|
size: r,
|
|
4539
4539
|
scale: a,
|
|
4540
4540
|
strokeWidth: c,
|
|
@@ -4545,8 +4545,8 @@ function Qn({ group: e, shape: t, width: n, height: r, scaleX: i, scaleY: a, min
|
|
|
4545
4545
|
strokeWidth: c
|
|
4546
4546
|
});
|
|
4547
4547
|
}
|
|
4548
|
-
function
|
|
4549
|
-
let l = Math.max(c, Math.abs(o) || 1), u = Math.max(c, Math.abs(s) || 1), d = i ?? "center", { frame: f, splitByGrapheme: p, textTop: m } =
|
|
4548
|
+
function er({ text: e, width: t, height: n, padding: r, alignH: i, alignV: a, scaleX: o, scaleY: s, scaleEpsilon: c }) {
|
|
4549
|
+
let l = Math.max(c, Math.abs(o) || 1), u = Math.max(c, Math.abs(s) || 1), d = i ?? "center", { frame: f, splitByGrapheme: p, textTop: m } = sn({
|
|
4550
4550
|
text: e,
|
|
4551
4551
|
width: t,
|
|
4552
4552
|
height: n,
|
|
@@ -4566,13 +4566,13 @@ function $n({ text: e, width: t, height: n, padding: r, alignH: i, alignV: a, sc
|
|
|
4566
4566
|
scaleY: 1 / u
|
|
4567
4567
|
}), e.initDimensions(), e.setCoords();
|
|
4568
4568
|
}
|
|
4569
|
-
var
|
|
4569
|
+
var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH: o, alignV: s, scaleX: c, scaleY: l, minSize: u, scaleEpsilon: d }) => {
|
|
4570
4570
|
let f = Math.max(d, Math.abs(c) || 1), p = Math.max(d, Math.abs(l) || 1);
|
|
4571
4571
|
e.set({
|
|
4572
4572
|
width: r / f,
|
|
4573
4573
|
height: i / p,
|
|
4574
4574
|
dirty: !0
|
|
4575
|
-
}),
|
|
4575
|
+
}), $n({
|
|
4576
4576
|
group: e,
|
|
4577
4577
|
shape: t,
|
|
4578
4578
|
width: r,
|
|
@@ -4581,7 +4581,7 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4581
4581
|
scaleY: l,
|
|
4582
4582
|
minSize: u,
|
|
4583
4583
|
scaleEpsilon: d
|
|
4584
|
-
}),
|
|
4584
|
+
}), er({
|
|
4585
4585
|
text: n,
|
|
4586
4586
|
width: r,
|
|
4587
4587
|
height: i,
|
|
@@ -4592,7 +4592,7 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4592
4592
|
scaleY: l,
|
|
4593
4593
|
scaleEpsilon: d
|
|
4594
4594
|
});
|
|
4595
|
-
}, X = 1, Z = 1e-4,
|
|
4595
|
+
}, X = 1, Z = 1e-4, nr = .5, rr = class e {
|
|
4596
4596
|
constructor({ canvas: t }) {
|
|
4597
4597
|
this.handleObjectScaling = (t) => {
|
|
4598
4598
|
let { target: n, transform: r } = t;
|
|
@@ -4608,7 +4608,7 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4608
4608
|
text: o,
|
|
4609
4609
|
constraintPadding: c,
|
|
4610
4610
|
transform: r
|
|
4611
|
-
}), { isCornerScaleAction: u } =
|
|
4611
|
+
}), { isCornerScaleAction: u } = qn({ transform: r }), d = !!(t.e && "shiftKey" in t.e && t.e.shiftKey);
|
|
4612
4612
|
l.isProportionalScaling = u && d;
|
|
4613
4613
|
let f = i.left ?? 0, p = i.top ?? 0, m = !!i.flipX, h = !!i.flipY, g = i.shapeAlignHorizontal ?? "center", _ = i.shapeAlignVertical ?? "middle", v = this._resolveScalingDecision({
|
|
4614
4614
|
group: i,
|
|
@@ -4623,7 +4623,7 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4623
4623
|
shouldHandleAsNoop: v.shouldHandleAsNoop,
|
|
4624
4624
|
scaleX: v.appliedScaleX,
|
|
4625
4625
|
scaleY: v.appliedScaleY
|
|
4626
|
-
}),
|
|
4626
|
+
}), tr({
|
|
4627
4627
|
group: i,
|
|
4628
4628
|
shape: a,
|
|
4629
4629
|
text: o,
|
|
@@ -4654,7 +4654,7 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4654
4654
|
if (!n) return;
|
|
4655
4655
|
let { target: r } = n;
|
|
4656
4656
|
if (!J(r)) return;
|
|
4657
|
-
let { canScaleHeight: i, canScaleWidth: a } =
|
|
4657
|
+
let { canScaleHeight: i, canScaleWidth: a } = qn({ transform: n });
|
|
4658
4658
|
if (!a && !i) return;
|
|
4659
4659
|
let o = r, s = this.scalingState.get(o);
|
|
4660
4660
|
if (!s || s.isProportionalScaling) return;
|
|
@@ -4669,7 +4669,7 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4669
4669
|
group: o,
|
|
4670
4670
|
axis: "x"
|
|
4671
4671
|
})) {
|
|
4672
|
-
let e =
|
|
4672
|
+
let e = on({
|
|
4673
4673
|
text: l,
|
|
4674
4674
|
padding: d
|
|
4675
4675
|
}), t = Math.max(X / s.startWidth, e / s.startWidth);
|
|
@@ -4703,7 +4703,7 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4703
4703
|
shouldHandleAsNoop: !1,
|
|
4704
4704
|
scaleX: _,
|
|
4705
4705
|
scaleY: v
|
|
4706
|
-
}),
|
|
4706
|
+
}), tr({
|
|
4707
4707
|
group: o,
|
|
4708
4708
|
shape: c,
|
|
4709
4709
|
text: l,
|
|
@@ -4750,7 +4750,7 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4750
4750
|
this.scalingState.delete(r);
|
|
4751
4751
|
return;
|
|
4752
4752
|
}
|
|
4753
|
-
let p = r.shapeAlignHorizontal ?? "center", m = r.shapeAlignVertical ?? "middle", h = e._resolveScalingConstraintPadding({ group: r }), g = t.transform ?
|
|
4753
|
+
let p = r.shapeAlignHorizontal ?? "center", m = r.shapeAlignVertical ?? "middle", h = e._resolveScalingConstraintPadding({ group: r }), g = t.transform ? qn({ transform: t.transform }) : null, _ = i?.canScaleWidth ?? g?.canScaleWidth ?? Math.abs(a - 1) > Z, v = i?.canScaleHeight ?? g?.canScaleHeight ?? Math.abs(o - 1) > Z, y = on({
|
|
4754
4754
|
text: f,
|
|
4755
4755
|
padding: h
|
|
4756
4756
|
}), b = i?.lastAllowedScaleX ?? a, x = i?.lastAllowedScaleY ?? o;
|
|
@@ -4773,7 +4773,7 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4773
4773
|
state: i
|
|
4774
4774
|
}) && (x = Math.max(X / c, e / c));
|
|
4775
4775
|
}
|
|
4776
|
-
let S = _ ? Math.max(X, s * b) : s, C = v ? Math.max(X, c * x) : u, w = Math.abs(S - s) >
|
|
4776
|
+
let S = _ ? Math.max(X, s * b) : s, C = v ? Math.max(X, c * x) : u, w = Math.abs(S - s) > nr, T = Math.abs(C - c) > nr, E = w || T, D = S, O = C;
|
|
4777
4777
|
if (!E && i) {
|
|
4778
4778
|
this._restoreShapeStateWithoutResize({
|
|
4779
4779
|
group: r,
|
|
@@ -4802,7 +4802,7 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4802
4802
|
});
|
|
4803
4803
|
r.shapeManualBaseWidth = k.width, r.shapeManualBaseHeight = k.height;
|
|
4804
4804
|
let A = i?.baseRounding ?? Math.max(0, r.shapeRounding ?? 0);
|
|
4805
|
-
r.shapeRounding = Math.max(0, A * Math.min(b, x)),
|
|
4805
|
+
r.shapeRounding = Math.max(0, A * Math.min(b, x)), rn({
|
|
4806
4806
|
group: r,
|
|
4807
4807
|
shape: d,
|
|
4808
4808
|
text: f,
|
|
@@ -4829,10 +4829,10 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4829
4829
|
}, this.canvas = t, this.scalingState = /* @__PURE__ */ new WeakMap();
|
|
4830
4830
|
}
|
|
4831
4831
|
_resolveScalingDecision({ group: e, text: t, constraintPadding: n, state: r, transform: i }) {
|
|
4832
|
-
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 =
|
|
4832
|
+
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 = Xn({
|
|
4833
4833
|
state: r,
|
|
4834
4834
|
transform: i
|
|
4835
|
-
}), d =
|
|
4835
|
+
}), d = Zn({
|
|
4836
4836
|
state: r,
|
|
4837
4837
|
transform: i
|
|
4838
4838
|
});
|
|
@@ -4864,7 +4864,7 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4864
4864
|
};
|
|
4865
4865
|
}
|
|
4866
4866
|
_resolveScalingConstraintState({ text: e, constraintPadding: t, state: n, transform: r, scaleX: i, scaleY: a }) {
|
|
4867
|
-
let { startHeight: o, startWidth: s, cannotScaleDownAtStart: c, crossedOppositeCorner: l, isProportionalScaling: u, lastAllowedScaleX: d, lastAllowedScaleY: f, startScaleY: p } = n, m = Math.max(X, s * i), h = Math.max(X, o * a), g = i < d - Z, _ = a < f - Z, v = a < p - Z, { canScaleHeight: y, canScaleWidth: b, isVerticalOnlyScale: x } =
|
|
4867
|
+
let { startHeight: o, startWidth: s, cannotScaleDownAtStart: c, crossedOppositeCorner: l, isProportionalScaling: u, lastAllowedScaleX: d, lastAllowedScaleY: f, startScaleY: p } = n, m = Math.max(X, s * i), h = Math.max(X, o * a), g = i < d - Z, _ = a < f - Z, v = a < p - Z, { canScaleHeight: y, canScaleWidth: b, isVerticalOnlyScale: x } = qn({ transform: r }), S = b && g ? on({
|
|
4868
4868
|
text: e,
|
|
4869
4869
|
padding: t
|
|
4870
4870
|
}) : null, C = y && _ ? this._resolveMinimumTextFitHeight({
|
|
@@ -4883,7 +4883,7 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4883
4883
|
};
|
|
4884
4884
|
}
|
|
4885
4885
|
_resolvePreviewDimensions({ text: e, constraintPadding: t, state: n, appliedScaleX: r, appliedScaleY: i, minimumHeight: a }) {
|
|
4886
|
-
let o = n.canScaleWidth ? Math.max(X, n.startWidth * r) : n.startWidth, s = n.canScaleHeight ? Math.max(X, n.startHeight * i) : n.startManualBaseHeight, c = a ??
|
|
4886
|
+
let o = n.canScaleWidth ? Math.max(X, n.startWidth * r) : n.startWidth, s = n.canScaleHeight ? Math.max(X, n.startHeight * i) : n.startManualBaseHeight, c = a ?? cn({
|
|
4887
4887
|
text: e,
|
|
4888
4888
|
width: o,
|
|
4889
4889
|
height: s,
|
|
@@ -4916,7 +4916,7 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4916
4916
|
if (!r) return !1;
|
|
4917
4917
|
let { transform: i } = e;
|
|
4918
4918
|
if (!i) return !1;
|
|
4919
|
-
let { canScaleWidth: a } =
|
|
4919
|
+
let { canScaleWidth: a } = qn({ transform: i });
|
|
4920
4920
|
if (!a || !this._hasPointerReachedScaleOrigin({
|
|
4921
4921
|
event: e,
|
|
4922
4922
|
group: t,
|
|
@@ -4929,7 +4929,7 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4929
4929
|
if (!r) return !1;
|
|
4930
4930
|
let { transform: i } = e;
|
|
4931
4931
|
if (!i) return !1;
|
|
4932
|
-
let { canScaleHeight: a } =
|
|
4932
|
+
let { canScaleHeight: a } = qn({ transform: i });
|
|
4933
4933
|
if (!a || !this._hasPointerReachedScaleOrigin({
|
|
4934
4934
|
event: e,
|
|
4935
4935
|
group: t,
|
|
@@ -4943,7 +4943,7 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4943
4943
|
if (!r) return !1;
|
|
4944
4944
|
let i = r, a = n === "x" ? i.signX : i.signY;
|
|
4945
4945
|
if (typeof a != "number" || !Number.isFinite(a)) return !1;
|
|
4946
|
-
let o =
|
|
4946
|
+
let o = Jn({
|
|
4947
4947
|
event: e.e,
|
|
4948
4948
|
group: t,
|
|
4949
4949
|
transform: r,
|
|
@@ -4960,19 +4960,19 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4960
4960
|
let a = this._resolveScalingStartDimensions({
|
|
4961
4961
|
group: e,
|
|
4962
4962
|
transform: r
|
|
4963
|
-
}), o =
|
|
4963
|
+
}), o = Wn({
|
|
4964
4964
|
transform: r,
|
|
4965
4965
|
key: "scaleX"
|
|
4966
|
-
}), s =
|
|
4966
|
+
}), s = Wn({
|
|
4967
4967
|
transform: r,
|
|
4968
4968
|
key: "scaleY"
|
|
4969
|
-
}), c =
|
|
4969
|
+
}), c = Wn({
|
|
4970
4970
|
transform: r,
|
|
4971
4971
|
key: "left"
|
|
4972
|
-
}), l =
|
|
4972
|
+
}), l = Wn({
|
|
4973
4973
|
transform: r,
|
|
4974
4974
|
key: "top"
|
|
4975
|
-
}), 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 =
|
|
4975
|
+
}), 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 = Gn({ value: r?.original?.originX ?? r?.originX }), h = Kn({ value: r?.original?.originY ?? r?.originY }), g = typeof r?.corner == "string" ? r.corner : null, _ = Yn({
|
|
4976
4976
|
group: e,
|
|
4977
4977
|
originX: m,
|
|
4978
4978
|
originY: h
|
|
@@ -5015,7 +5015,7 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5015
5015
|
return i;
|
|
5016
5016
|
}
|
|
5017
5017
|
_resolveMinimumTextFitHeight({ text: e, width: t, padding: n }) {
|
|
5018
|
-
return
|
|
5018
|
+
return cn({
|
|
5019
5019
|
text: e,
|
|
5020
5020
|
width: t,
|
|
5021
5021
|
height: X,
|
|
@@ -5023,7 +5023,7 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5023
5023
|
});
|
|
5024
5024
|
}
|
|
5025
5025
|
static _resolveUserPadding({ group: e }) {
|
|
5026
|
-
return
|
|
5026
|
+
return zt({ padding: {
|
|
5027
5027
|
top: e.shapePaddingTop,
|
|
5028
5028
|
right: e.shapePaddingRight,
|
|
5029
5029
|
bottom: e.shapePaddingBottom,
|
|
@@ -5031,9 +5031,9 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5031
5031
|
} });
|
|
5032
5032
|
}
|
|
5033
5033
|
static _resolveInternalShapeTextInset({ group: e, width: t, height: n }) {
|
|
5034
|
-
let r = e.shapePresetKey ?? "", i = r ?
|
|
5035
|
-
return
|
|
5036
|
-
baseInset: i ?
|
|
5034
|
+
let r = e.shapePresetKey ?? "", i = r ? dt({ presetKey: r }) : null;
|
|
5035
|
+
return Ut({
|
|
5036
|
+
baseInset: i ? mt({
|
|
5037
5037
|
preset: i,
|
|
5038
5038
|
width: t,
|
|
5039
5039
|
height: n
|
|
@@ -5044,7 +5044,7 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5044
5044
|
}
|
|
5045
5045
|
static _resolveEffectivePadding({ group: t }) {
|
|
5046
5046
|
let n = Math.max(X, t.shapeBaseWidth ?? t.width ?? t.shapeManualBaseWidth ?? X), r = Math.max(X, t.shapeBaseHeight ?? t.height ?? t.shapeManualBaseHeight ?? X), i = e._resolveUserPadding({ group: t });
|
|
5047
|
-
return
|
|
5047
|
+
return Ht({
|
|
5048
5048
|
base: e._resolveInternalShapeTextInset({
|
|
5049
5049
|
group: t,
|
|
5050
5050
|
width: n,
|
|
@@ -5071,7 +5071,7 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5071
5071
|
}
|
|
5072
5072
|
_restoreShapeStateWithoutResize({ group: t, shape: n, text: r, state: i, startWidth: a, startHeight: o, alignH: s, alignV: c, userPadding: l }) {
|
|
5073
5073
|
let u = Math.max(X, t.shapeBaseWidth ?? t.width ?? a), d = Math.max(X, t.shapeBaseHeight ?? t.height ?? o);
|
|
5074
|
-
|
|
5074
|
+
rn({
|
|
5075
5075
|
group: t,
|
|
5076
5076
|
shape: n,
|
|
5077
5077
|
text: r,
|
|
@@ -5099,7 +5099,7 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5099
5099
|
}
|
|
5100
5100
|
_restoreGroupTransformOnly({ group: e, shape: t, text: n, state: r }) {
|
|
5101
5101
|
let i = Math.max(X, e.shapeBaseWidth ?? e.width ?? r.startWidth), a = Math.max(X, e.shapeBaseHeight ?? e.height ?? r.startHeight);
|
|
5102
|
-
t && (
|
|
5102
|
+
t && (xt({
|
|
5103
5103
|
shape: t,
|
|
5104
5104
|
width: i,
|
|
5105
5105
|
height: a,
|
|
@@ -5123,7 +5123,7 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5123
5123
|
});
|
|
5124
5124
|
}
|
|
5125
5125
|
_resolveScalingStartDimensions({ group: e, transform: t }) {
|
|
5126
|
-
let { canScaleWidth: n, canScaleHeight: r } =
|
|
5126
|
+
let { canScaleWidth: n, canScaleHeight: r } = qn({ transform: t }), i = Math.max(X, e.shapeBaseWidth ?? e.width ?? e.shapeManualBaseWidth ?? X), a = Math.max(X, e.shapeBaseHeight ?? e.height ?? e.shapeManualBaseHeight ?? X);
|
|
5127
5127
|
return {
|
|
5128
5128
|
startWidth: i,
|
|
5129
5129
|
startHeight: a,
|
|
@@ -5142,10 +5142,10 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5142
5142
|
height: s
|
|
5143
5143
|
};
|
|
5144
5144
|
}
|
|
5145
|
-
},
|
|
5145
|
+
}, ir = class {
|
|
5146
5146
|
constructor({ canvas: e }) {
|
|
5147
5147
|
this.handleMouseDown = (e) => {
|
|
5148
|
-
let { target: t, e: n, subTargets: r = [] } = e, i =
|
|
5148
|
+
let { target: t, e: n, subTargets: r = [] } = e, i = Bn({
|
|
5149
5149
|
target: t,
|
|
5150
5150
|
subTargets: r
|
|
5151
5151
|
});
|
|
@@ -5155,7 +5155,7 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5155
5155
|
let o = this.canvas.getActiveObject(), s = o === i;
|
|
5156
5156
|
if (!(o === a && a.isEditing)) {
|
|
5157
5157
|
if (!s) {
|
|
5158
|
-
a.isEditing ||
|
|
5158
|
+
a.isEditing || En({ text: a });
|
|
5159
5159
|
return;
|
|
5160
5160
|
}
|
|
5161
5161
|
n instanceof MouseEvent && (n.detail < 2 || this.enterTextEditing({ group: i }));
|
|
@@ -5175,14 +5175,14 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5175
5175
|
J(r) && (this._restoreTextEditingInteractionMode({
|
|
5176
5176
|
group: r,
|
|
5177
5177
|
text: n
|
|
5178
|
-
}),
|
|
5178
|
+
}), En({ text: n }), this.canvas.getActiveObject() === n && this.canvas.setActiveObject(r), this.canvas.requestRenderAll());
|
|
5179
5179
|
}, this.canvas = e, this.editingInteractionState = /* @__PURE__ */ new WeakMap();
|
|
5180
5180
|
}
|
|
5181
5181
|
enterTextEditing({ group: e }) {
|
|
5182
5182
|
let { text: t } = Y({ group: e });
|
|
5183
5183
|
if (t) {
|
|
5184
5184
|
if (e.locked || t.locked) {
|
|
5185
|
-
|
|
5185
|
+
En({ text: t }), this.canvas.requestRenderAll();
|
|
5186
5186
|
return;
|
|
5187
5187
|
}
|
|
5188
5188
|
this._enterTextEditingInteractionMode({
|
|
@@ -5232,7 +5232,7 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5232
5232
|
lockMovementY: n.textLockMovementY
|
|
5233
5233
|
}), this.editingInteractionState.delete(e), e.setCoords(), t.setCoords());
|
|
5234
5234
|
}
|
|
5235
|
-
},
|
|
5235
|
+
}, ar = "#B0B5BF", or = 0, sr = 1, cr = class {
|
|
5236
5236
|
constructor({ editor: e }) {
|
|
5237
5237
|
this._handleObjectScaling = (e) => {
|
|
5238
5238
|
this.scalingController.handleObjectScaling(e);
|
|
@@ -5269,12 +5269,12 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5269
5269
|
textNode: r,
|
|
5270
5270
|
textStyle: n
|
|
5271
5271
|
});
|
|
5272
|
-
}, this.editor = e,
|
|
5272
|
+
}, this.editor = e, zn(), this.scalingController = new rr({ canvas: e.canvas }), this.editingController = new ir({ canvas: e.canvas }), this.editingPlacements = /* @__PURE__ */ new WeakMap(), this.internalTextUpdates = /* @__PURE__ */ new WeakSet(), this._bindEvents();
|
|
5273
5273
|
}
|
|
5274
5274
|
async add({ presetKey: e = ot, options: t = {} } = {}) {
|
|
5275
|
-
let n =
|
|
5275
|
+
let n = dt({ presetKey: e });
|
|
5276
5276
|
if (!n) return null;
|
|
5277
|
-
let { width: r, height: i, shapeTextAutoExpand: a, left: o, top: s, originX: c, originY: l, text: u, textStyle: d, alignH: f, alignV: p, textPadding: m, rounding: h, withoutAdding: g, withoutSelection: _, withoutSave: v, id: y } = t, b =
|
|
5277
|
+
let { width: r, height: i, shapeTextAutoExpand: a, left: o, top: s, originX: c, originY: l, text: u, textStyle: d, alignH: f, alignV: p, textPadding: m, rounding: h, withoutAdding: g, withoutSelection: _, withoutSave: v, id: y } = t, b = dt({ presetKey: ft({
|
|
5278
5278
|
preset: n,
|
|
5279
5279
|
rounding: h
|
|
5280
5280
|
}) }) ?? n, x = Math.max(1, r ?? b.width), S = Math.max(1, i ?? b.height), C = a !== !1, w = this._resolveHorizontalAlign({
|
|
@@ -5283,18 +5283,18 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5283
5283
|
}), T = p ?? "middle", E = this._resolveShapeStyle({
|
|
5284
5284
|
options: t,
|
|
5285
5285
|
fallback: null
|
|
5286
|
-
}), O =
|
|
5287
|
-
baseInset:
|
|
5286
|
+
}), O = zt({ padding: m }), k = Ut({
|
|
5287
|
+
baseInset: mt({
|
|
5288
5288
|
preset: b,
|
|
5289
5289
|
width: x,
|
|
5290
5290
|
height: S
|
|
5291
5291
|
}),
|
|
5292
5292
|
stroke: E.stroke,
|
|
5293
5293
|
strokeWidth: E.strokeWidth
|
|
5294
|
-
}), A =
|
|
5294
|
+
}), A = Ht({
|
|
5295
5295
|
base: k,
|
|
5296
5296
|
addition: O
|
|
5297
|
-
}), j =
|
|
5297
|
+
}), j = Wt({ padding: m }), M = this._createTextNode({
|
|
5298
5298
|
text: u,
|
|
5299
5299
|
textStyle: d,
|
|
5300
5300
|
width: x,
|
|
@@ -5306,7 +5306,7 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5306
5306
|
manualWidth: x,
|
|
5307
5307
|
shapeTextAutoExpandEnabled: C,
|
|
5308
5308
|
padding: A
|
|
5309
|
-
}), P = await
|
|
5309
|
+
}), P = await Pt({
|
|
5310
5310
|
preset: b,
|
|
5311
5311
|
width: N,
|
|
5312
5312
|
height: S,
|
|
@@ -5315,7 +5315,7 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5315
5315
|
}), F = this._createShapeGroup({
|
|
5316
5316
|
id: y ?? `shape-${D()}`,
|
|
5317
5317
|
presetKey: b.key,
|
|
5318
|
-
presetCanRound:
|
|
5318
|
+
presetCanRound: gt({ preset: b }),
|
|
5319
5319
|
shape: P,
|
|
5320
5320
|
text: M,
|
|
5321
5321
|
width: N,
|
|
@@ -5358,7 +5358,7 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5358
5358
|
async update({ target: e, presetKey: t, options: n = {} } = {}) {
|
|
5359
5359
|
let r = this._resolveShapeGroup({ target: e });
|
|
5360
5360
|
if (!r) return null;
|
|
5361
|
-
let i =
|
|
5361
|
+
let i = dt({ presetKey: t ?? r.shapePresetKey ?? "circle" });
|
|
5362
5362
|
if (!i) return null;
|
|
5363
5363
|
let { left: a, top: o, originX: s, originY: c, width: l, height: u, shapeTextAutoExpand: d, text: f, textStyle: p, alignH: m, alignV: h, textPadding: g, rounding: _, withoutSelection: v, withoutSave: y } = n, b = this.editor.canvasManager.resolveObjectPlacement({
|
|
5364
5364
|
object: r,
|
|
@@ -5366,31 +5366,31 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5366
5366
|
top: o,
|
|
5367
5367
|
originX: s,
|
|
5368
5368
|
originY: c
|
|
5369
|
-
}), x = this._resolveCurrentDimensions({ group: r }), S = Math.max(1, u ?? x.height), C = this._isShapeTextAutoExpandEnabled({ group: r }), w = d === void 0 ? C : d !== !1, T = _ ?? r.shapeRounding ?? 0, E =
|
|
5369
|
+
}), x = this._resolveCurrentDimensions({ group: r }), S = Math.max(1, u ?? x.height), C = this._isShapeTextAutoExpandEnabled({ group: r }), w = d === void 0 ? C : d !== !1, T = _ ?? r.shapeRounding ?? 0, E = dt({ presetKey: ft({
|
|
5370
5370
|
preset: i,
|
|
5371
5371
|
rounding: T
|
|
5372
|
-
}) }) ?? i, D = m ?? r.shapeAlignHorizontal ?? "center", O = h ?? r.shapeAlignVertical ?? "middle", k = this._resolveGroupUserPadding({ group: r }), A =
|
|
5372
|
+
}) }) ?? i, D = m ?? r.shapeAlignHorizontal ?? "center", O = h ?? r.shapeAlignVertical ?? "middle", k = this._resolveGroupUserPadding({ group: r }), A = Wt({ padding: g }), j = Vt({
|
|
5373
5373
|
base: k,
|
|
5374
5374
|
override: g
|
|
5375
5375
|
}), M = this._resolveShapeStyle({
|
|
5376
5376
|
options: n,
|
|
5377
5377
|
fallback: r
|
|
5378
|
-
}), N =
|
|
5379
|
-
baseInset:
|
|
5378
|
+
}), N = Ut({
|
|
5379
|
+
baseInset: mt({
|
|
5380
5380
|
preset: E,
|
|
5381
5381
|
width: x.width,
|
|
5382
5382
|
height: S
|
|
5383
5383
|
}),
|
|
5384
5384
|
stroke: M.stroke,
|
|
5385
5385
|
strokeWidth: M.strokeWidth
|
|
5386
|
-
}), P =
|
|
5386
|
+
}), P = Ht({
|
|
5387
5387
|
base: N,
|
|
5388
5388
|
addition: j
|
|
5389
5389
|
}), F = Math.max(1, r.shapeManualBaseWidth ?? x.width);
|
|
5390
5390
|
l !== void 0 && (F = Math.max(1, l)), l === void 0 && C && !w && (F = Math.max(1, x.width));
|
|
5391
|
-
let
|
|
5392
|
-
if (!
|
|
5393
|
-
let
|
|
5391
|
+
let ee = Math.max(1, u ?? r.shapeManualBaseHeight ?? S), { shape: te, text: I } = Y({ group: r });
|
|
5392
|
+
if (!te || !I) return null;
|
|
5393
|
+
let ne = {
|
|
5394
5394
|
angle: 0,
|
|
5395
5395
|
skewX: 0,
|
|
5396
5396
|
skewY: 0,
|
|
@@ -5403,46 +5403,46 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5403
5403
|
top: 0,
|
|
5404
5404
|
originX: "left",
|
|
5405
5405
|
originY: "top"
|
|
5406
|
-
},
|
|
5407
|
-
text:
|
|
5408
|
-
textStyle: this._resolveCurrentTextStyle({ textNode:
|
|
5409
|
-
width: Math.max(1,
|
|
5406
|
+
}, re = this._createTextNode({
|
|
5407
|
+
text: I.textCaseRaw ?? I.text ?? "",
|
|
5408
|
+
textStyle: this._resolveCurrentTextStyle({ textNode: I }),
|
|
5409
|
+
width: Math.max(1, I.width ?? x.width),
|
|
5410
5410
|
align: D
|
|
5411
5411
|
});
|
|
5412
|
-
|
|
5413
|
-
textNode:
|
|
5412
|
+
re.set(ne), this._applyTextUpdates({
|
|
5413
|
+
textNode: re,
|
|
5414
5414
|
text: f,
|
|
5415
5415
|
textStyle: p,
|
|
5416
5416
|
align: D
|
|
5417
5417
|
});
|
|
5418
|
-
let
|
|
5419
|
-
text:
|
|
5418
|
+
let L = l === void 0 && u === void 0 && t === void 0 && d === void 0 && _ === void 0 && f === void 0 && !this._hasShapeTextSizeAffectingStyleChanges({ textStyle: p }), ie = g !== void 0 && L, R = L ? x.width : this._resolveShapeLayoutWidth({
|
|
5419
|
+
text: re,
|
|
5420
5420
|
currentWidth: x.width,
|
|
5421
5421
|
manualWidth: F,
|
|
5422
5422
|
shapeTextAutoExpandEnabled: w,
|
|
5423
5423
|
padding: P
|
|
5424
|
-
}),
|
|
5424
|
+
}), ae = await Pt({
|
|
5425
5425
|
preset: E,
|
|
5426
|
-
width:
|
|
5426
|
+
width: R,
|
|
5427
5427
|
height: S,
|
|
5428
5428
|
style: M,
|
|
5429
5429
|
rounding: T
|
|
5430
|
-
}),
|
|
5431
|
-
if (
|
|
5432
|
-
let
|
|
5433
|
-
this._detachShapeGroupAutoLayout({ group: r }),
|
|
5434
|
-
textNode:
|
|
5430
|
+
}), z = r.getObjects().indexOf(te);
|
|
5431
|
+
if (z < 0) return null;
|
|
5432
|
+
let oe = () => {
|
|
5433
|
+
this._detachShapeGroupAutoLayout({ group: r }), I.set(ne), this._applyTextUpdates({
|
|
5434
|
+
textNode: I,
|
|
5435
5435
|
text: f,
|
|
5436
5436
|
textStyle: p,
|
|
5437
5437
|
align: D
|
|
5438
|
-
}), r.remove(
|
|
5438
|
+
}), r.remove(te), r.insertAt(z, ae), this._applyShapeGroupMetadata({
|
|
5439
5439
|
group: r,
|
|
5440
5440
|
presetKey: E.key,
|
|
5441
|
-
presetCanRound:
|
|
5442
|
-
width:
|
|
5441
|
+
presetCanRound: gt({ preset: E }),
|
|
5442
|
+
width: R,
|
|
5443
5443
|
height: S,
|
|
5444
5444
|
manualWidth: F,
|
|
5445
|
-
manualHeight:
|
|
5445
|
+
manualHeight: ee,
|
|
5446
5446
|
shapeTextAutoExpand: w,
|
|
5447
5447
|
alignH: D,
|
|
5448
5448
|
alignV: O,
|
|
@@ -5451,22 +5451,22 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5451
5451
|
rounding: T
|
|
5452
5452
|
}), this._applyCurrentLayout({
|
|
5453
5453
|
group: r,
|
|
5454
|
-
shape:
|
|
5455
|
-
text:
|
|
5454
|
+
shape: ae,
|
|
5455
|
+
text: I,
|
|
5456
5456
|
placement: b,
|
|
5457
|
-
width:
|
|
5457
|
+
width: R,
|
|
5458
5458
|
height: S,
|
|
5459
5459
|
alignH: D,
|
|
5460
5460
|
alignV: O,
|
|
5461
5461
|
internalShapeTextInset: N,
|
|
5462
|
-
expandShapeHeightToFitText: !
|
|
5462
|
+
expandShapeHeightToFitText: !ie,
|
|
5463
5463
|
changedPadding: A
|
|
5464
|
-
}),
|
|
5464
|
+
}), I.isEditing && this.editingPlacements.set(r, b);
|
|
5465
5465
|
};
|
|
5466
|
-
if (!this._isOnCanvas({ object: r })) return
|
|
5466
|
+
if (!this._isOnCanvas({ object: r })) return oe(), r;
|
|
5467
5467
|
this._beginMutation();
|
|
5468
5468
|
try {
|
|
5469
|
-
|
|
5469
|
+
oe(), !I.isEditing && !v && this.editor.canvas.setActiveObject(r), this.editor.canvas.requestRenderAll();
|
|
5470
5470
|
} finally {
|
|
5471
5471
|
this._endMutation({ withoutSave: y });
|
|
5472
5472
|
}
|
|
@@ -5490,7 +5490,7 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5490
5490
|
if (!i) return null;
|
|
5491
5491
|
this._beginMutation();
|
|
5492
5492
|
try {
|
|
5493
|
-
|
|
5493
|
+
St({
|
|
5494
5494
|
shape: i,
|
|
5495
5495
|
style: { fill: t }
|
|
5496
5496
|
}), r.shapeFill = t, r.setCoords(), this.editor.canvas.requestRenderAll();
|
|
@@ -5506,7 +5506,7 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5506
5506
|
if (!o) return null;
|
|
5507
5507
|
this._beginMutation();
|
|
5508
5508
|
try {
|
|
5509
|
-
if (
|
|
5509
|
+
if (St({
|
|
5510
5510
|
shape: o,
|
|
5511
5511
|
style: {
|
|
5512
5512
|
stroke: t,
|
|
@@ -5536,7 +5536,7 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5536
5536
|
if (!i) return null;
|
|
5537
5537
|
this._beginMutation();
|
|
5538
5538
|
try {
|
|
5539
|
-
|
|
5539
|
+
St({
|
|
5540
5540
|
shape: i,
|
|
5541
5541
|
style: { opacity: t }
|
|
5542
5542
|
}), a && (a.set({ opacity: t }), a.setCoords()), r.shapeOpacity = t, r.setCoords(), this.editor.canvas.requestRenderAll();
|
|
@@ -5629,7 +5629,7 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5629
5629
|
e.on("object:scaling", this._handleObjectScaling), e.on("object:modified", this._handleObjectModified), e.on("mouse:move", this._handleMouseMove), e.on("mouse:down", this._handleMouseDown), e.on("text:editing:entered", this._handleTextEditingEntered), e.on("text:editing:exited", this._handleTextEditingExited), e.on("text:changed", this._handleTextChanged), e.on("editor:before:text-updated", this._handleBeforeTextUpdated);
|
|
5630
5630
|
}
|
|
5631
5631
|
_createShapeGroup({ id: e, presetKey: t, presetCanRound: n, shape: r, text: i, width: a, height: o, manualWidth: s, manualHeight: c, shapeTextAutoExpand: l, alignH: u, alignV: d, padding: f, internalShapeTextInset: p, changedPadding: m, style: h, rounding: g }) {
|
|
5632
|
-
let _ = new
|
|
5632
|
+
let _ = new Rn([r, i], {
|
|
5633
5633
|
id: e,
|
|
5634
5634
|
originX: "center",
|
|
5635
5635
|
originY: "center",
|
|
@@ -5653,7 +5653,7 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5653
5653
|
padding: f,
|
|
5654
5654
|
style: h,
|
|
5655
5655
|
rounding: g
|
|
5656
|
-
}), _.rehydrateRuntimeState(),
|
|
5656
|
+
}), _.rehydrateRuntimeState(), Un({ group: _ }), En({ text: i }), rn({
|
|
5657
5657
|
group: _,
|
|
5658
5658
|
shape: r,
|
|
5659
5659
|
text: i,
|
|
@@ -5711,7 +5711,7 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5711
5711
|
return s.set({
|
|
5712
5712
|
shapeNodeType: "text",
|
|
5713
5713
|
splitByGrapheme: !1
|
|
5714
|
-
}),
|
|
5714
|
+
}), En({ text: s }), s;
|
|
5715
5715
|
}
|
|
5716
5716
|
_applyTextUpdates({ textNode: e, text: t, textStyle: n, align: r }) {
|
|
5717
5717
|
let i = {};
|
|
@@ -5740,7 +5740,7 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5740
5740
|
_resolveCurrentTextStyle({ textNode: e }) {
|
|
5741
5741
|
let { backgroundColor: t, backgroundOpacity: n, fill: r, fontFamily: i, fontSize: a, fontStyle: o, fontWeight: s, lineFontDefaults: c, linethrough: l, opacity: u, paddingBottom: d, paddingLeft: f, paddingRight: p, paddingTop: m, radiusBottomLeft: h, radiusBottomRight: g, radiusTopLeft: _, radiusTopRight: v, stroke: y, strokeWidth: b, styles: x, textAlign: S, underline: C, uppercase: w } = e;
|
|
5742
5742
|
return {
|
|
5743
|
-
align:
|
|
5743
|
+
align: this._resolveShapeTextHorizontalAlign({
|
|
5744
5744
|
group: e.group,
|
|
5745
5745
|
textStyle: { align: S }
|
|
5746
5746
|
}),
|
|
@@ -5783,7 +5783,7 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5783
5783
|
};
|
|
5784
5784
|
}
|
|
5785
5785
|
_resolveGroupUserPadding({ group: e }) {
|
|
5786
|
-
return
|
|
5786
|
+
return zt({ padding: {
|
|
5787
5787
|
top: e.shapePaddingTop,
|
|
5788
5788
|
right: e.shapePaddingRight,
|
|
5789
5789
|
bottom: e.shapePaddingBottom,
|
|
@@ -5791,9 +5791,9 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5791
5791
|
} });
|
|
5792
5792
|
}
|
|
5793
5793
|
_resolveGroupInternalShapeTextInset({ group: e, width: t, height: n }) {
|
|
5794
|
-
let r =
|
|
5795
|
-
return
|
|
5796
|
-
baseInset: r ?
|
|
5794
|
+
let r = dt({ presetKey: e.shapePresetKey ?? "circle" });
|
|
5795
|
+
return Ut({
|
|
5796
|
+
baseInset: r ? mt({
|
|
5797
5797
|
preset: r,
|
|
5798
5798
|
width: t,
|
|
5799
5799
|
height: n
|
|
@@ -5813,7 +5813,7 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5813
5813
|
}
|
|
5814
5814
|
_resolveAutoExpandShapeWidth({ text: e, currentWidth: t, minimumWidth: n, padding: r }) {
|
|
5815
5815
|
let i = this._resolveMontageAreaWidth();
|
|
5816
|
-
return i ?
|
|
5816
|
+
return i ? an({
|
|
5817
5817
|
text: e,
|
|
5818
5818
|
currentWidth: t,
|
|
5819
5819
|
minimumWidth: n,
|
|
@@ -5831,7 +5831,7 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5831
5831
|
}
|
|
5832
5832
|
_resolveShapeTextHorizontalAlign({ group: e, textStyle: t }) {
|
|
5833
5833
|
let n = t?.align;
|
|
5834
|
-
return n === "left" || n === "center" || n === "right" ? n : e.shapeAlignHorizontal ?? "center";
|
|
5834
|
+
return n === "left" || n === "center" || n === "right" || n === "justify" ? n : e.shapeAlignHorizontal ?? "center";
|
|
5835
5835
|
}
|
|
5836
5836
|
_applyCurrentLayout({ group: e, shape: t, text: n, placement: r, width: i, height: a, alignH: o, alignV: s, internalShapeTextInset: c, expandShapeHeightToFitText: l = !0, changedPadding: u }) {
|
|
5837
5837
|
let d = this._resolveCurrentDimensions({ group: e }), f = this._resolveManualDimensions({ group: e }), p = this._resolveGroupUserPadding({ group: e }), m = d.width;
|
|
@@ -5840,7 +5840,7 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5840
5840
|
currentWidth: d.width,
|
|
5841
5841
|
manualWidth: f.width,
|
|
5842
5842
|
shapeTextAutoExpandEnabled: this._isShapeTextAutoExpandEnabled({ group: e }),
|
|
5843
|
-
padding:
|
|
5843
|
+
padding: Ht({
|
|
5844
5844
|
base: c ?? this._resolveGroupInternalShapeTextInset({
|
|
5845
5845
|
group: e,
|
|
5846
5846
|
width: m,
|
|
@@ -5854,7 +5854,7 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5854
5854
|
width: m,
|
|
5855
5855
|
height: h
|
|
5856
5856
|
}), _ = r ?? this.editor.canvasManager.getObjectPlacement({ object: e });
|
|
5857
|
-
|
|
5857
|
+
rn({
|
|
5858
5858
|
group: e,
|
|
5859
5859
|
shape: t,
|
|
5860
5860
|
text: n,
|
|
@@ -5894,12 +5894,12 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5894
5894
|
return this.editingPlacements.get(e) || this.editor.canvasManager.getObjectPlacement({ object: e });
|
|
5895
5895
|
}
|
|
5896
5896
|
_detachShapeGroupAutoLayout({ group: e }) {
|
|
5897
|
-
|
|
5897
|
+
Dn({ group: e });
|
|
5898
5898
|
}
|
|
5899
5899
|
_resolveHorizontalAlign({ explicitAlign: e, textStyle: t }) {
|
|
5900
5900
|
if (e) return e;
|
|
5901
5901
|
let n = t?.align;
|
|
5902
|
-
return n === "left" || n === "center" || n === "right" ? n : st;
|
|
5902
|
+
return n === "left" || n === "center" || n === "right" || n === "justify" ? n : st;
|
|
5903
5903
|
}
|
|
5904
5904
|
_hasShapeTextSizeAffectingStyleChanges({ textStyle: e }) {
|
|
5905
5905
|
if (!e) return !1;
|
|
@@ -5913,11 +5913,11 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5913
5913
|
_resolveShapeStyle({ options: e, fallback: t }) {
|
|
5914
5914
|
let { fill: n, stroke: r, strokeWidth: i, strokeDashArray: a, opacity: o } = e, s = a === void 0 ? t?.shapeStrokeDashArray : a;
|
|
5915
5915
|
return {
|
|
5916
|
-
fill: n ?? t?.shapeFill ??
|
|
5916
|
+
fill: n ?? t?.shapeFill ?? ar,
|
|
5917
5917
|
stroke: r ?? t?.shapeStroke ?? null,
|
|
5918
|
-
strokeWidth: i ?? t?.shapeStrokeWidth ??
|
|
5918
|
+
strokeWidth: i ?? t?.shapeStrokeWidth ?? or,
|
|
5919
5919
|
strokeDashArray: s ?? null,
|
|
5920
|
-
opacity: o ?? t?.shapeOpacity ??
|
|
5920
|
+
opacity: o ?? t?.shapeOpacity ?? sr
|
|
5921
5921
|
};
|
|
5922
5922
|
}
|
|
5923
5923
|
_beginMutation() {
|
|
@@ -5953,7 +5953,7 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5953
5953
|
}
|
|
5954
5954
|
return null;
|
|
5955
5955
|
}
|
|
5956
|
-
},
|
|
5956
|
+
}, lr = class {
|
|
5957
5957
|
constructor({ editor: e }) {
|
|
5958
5958
|
this.editor = e, this.clipboard = null;
|
|
5959
5959
|
}
|
|
@@ -6209,12 +6209,12 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6209
6209
|
}), !1;
|
|
6210
6210
|
}
|
|
6211
6211
|
}
|
|
6212
|
-
},
|
|
6212
|
+
}, ur = class t {
|
|
6213
6213
|
constructor({ editor: e }) {
|
|
6214
6214
|
this.editor = e;
|
|
6215
6215
|
}
|
|
6216
6216
|
lockObject({ object: e, skipInnerObjects: n, withoutSave: r } = {}) {
|
|
6217
|
-
let { canvas: i, historyManager: a } = this.editor, o = e || i.getActiveObject(), s =
|
|
6217
|
+
let { canvas: i, historyManager: a } = this.editor, o = e || i.getActiveObject(), s = Bn({ target: o }) ?? o;
|
|
6218
6218
|
if (!s || s.locked) return;
|
|
6219
6219
|
let c = {
|
|
6220
6220
|
lockMovementX: !0,
|
|
@@ -6236,7 +6236,7 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6236
6236
|
});
|
|
6237
6237
|
}
|
|
6238
6238
|
unlockObject({ object: e, withoutSave: n } = {}) {
|
|
6239
|
-
let { canvas: r, historyManager: i } = this.editor, a = e || r.getActiveObject(), o =
|
|
6239
|
+
let { canvas: r, historyManager: i } = this.editor, a = e || r.getActiveObject(), o = Bn({ target: a }) ?? a;
|
|
6240
6240
|
if (!o) return;
|
|
6241
6241
|
let s = {
|
|
6242
6242
|
lockMovementX: !1,
|
|
@@ -6274,7 +6274,7 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6274
6274
|
!(n instanceof _) || !n.isEditing || n.exitEditing();
|
|
6275
6275
|
}
|
|
6276
6276
|
}
|
|
6277
|
-
},
|
|
6277
|
+
}, dr = class {
|
|
6278
6278
|
constructor({ editor: e }) {
|
|
6279
6279
|
this.editor = e;
|
|
6280
6280
|
}
|
|
@@ -6340,7 +6340,7 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6340
6340
|
i.resumeHistory(), n || i.saveState();
|
|
6341
6341
|
}
|
|
6342
6342
|
}
|
|
6343
|
-
},
|
|
6343
|
+
}, fr = class t {
|
|
6344
6344
|
constructor({ editor: e }) {
|
|
6345
6345
|
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();
|
|
6346
6346
|
}
|
|
@@ -6534,7 +6534,7 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6534
6534
|
let { options: e } = this.editor, { selectionKey: t } = e;
|
|
6535
6535
|
return t === void 0 ? ["ctrlKey", "metaKey"] : t;
|
|
6536
6536
|
}
|
|
6537
|
-
},
|
|
6537
|
+
}, pr = class e {
|
|
6538
6538
|
constructor({ editor: e }) {
|
|
6539
6539
|
this.editor = e;
|
|
6540
6540
|
}
|
|
@@ -6574,7 +6574,7 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6574
6574
|
};
|
|
6575
6575
|
return i.fire("editor:objects-deleted", l), l;
|
|
6576
6576
|
}
|
|
6577
|
-
},
|
|
6577
|
+
}, mr = {
|
|
6578
6578
|
IMAGE_MANAGER: {
|
|
6579
6579
|
INVALID_CONTENT_TYPE: "INVALID_CONTENT_TYPE",
|
|
6580
6580
|
INVALID_SOURCE_TYPE: "INVALID_SOURCE_TYPE",
|
|
@@ -6612,7 +6612,7 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6612
6612
|
INVALID_TARGET: "TEMPLATE_INVALID_TARGET",
|
|
6613
6613
|
APPLY_FAILED: "TEMPLATE_APPLY_FAILED"
|
|
6614
6614
|
}
|
|
6615
|
-
},
|
|
6615
|
+
}, hr = class e {
|
|
6616
6616
|
constructor({ editor: e }) {
|
|
6617
6617
|
this._buffer = [], this.editor = e;
|
|
6618
6618
|
}
|
|
@@ -6670,9 +6670,9 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6670
6670
|
}), this.editor.canvas.fire("editor:warning", s);
|
|
6671
6671
|
}
|
|
6672
6672
|
static isValidErrorCode(e) {
|
|
6673
|
-
return e ? Object.values(
|
|
6673
|
+
return e ? Object.values(mr).some((t) => Object.values(t).includes(e)) : !1;
|
|
6674
6674
|
}
|
|
6675
|
-
},
|
|
6675
|
+
}, gr = class {
|
|
6676
6676
|
constructor({ editor: e }) {
|
|
6677
6677
|
this.currentBounds = null, this.editor = e;
|
|
6678
6678
|
}
|
|
@@ -6721,32 +6721,32 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6721
6721
|
updateBounds() {
|
|
6722
6722
|
this.currentBounds = this.calculatePanBounds();
|
|
6723
6723
|
}
|
|
6724
|
-
},
|
|
6724
|
+
}, _r = ({ textbox: e }) => {
|
|
6725
6725
|
if (!e.isEditing) return null;
|
|
6726
6726
|
let t = e.selectionStart ?? 0, n = e.selectionEnd ?? t;
|
|
6727
6727
|
return t === n ? null : {
|
|
6728
6728
|
start: Math.min(t, n),
|
|
6729
6729
|
end: Math.max(t, n)
|
|
6730
6730
|
};
|
|
6731
|
-
},
|
|
6731
|
+
}, vr = ({ textbox: e }) => {
|
|
6732
6732
|
let t = e.text?.length ?? 0;
|
|
6733
6733
|
return t <= 0 ? null : {
|
|
6734
6734
|
start: 0,
|
|
6735
6735
|
end: t
|
|
6736
6736
|
};
|
|
6737
|
-
},
|
|
6737
|
+
}, yr = ({ textbox: e, range: t }) => {
|
|
6738
6738
|
if (!t) return !1;
|
|
6739
6739
|
let n = e.text?.length ?? 0;
|
|
6740
6740
|
return n <= 0 ? !1 : t.start <= 0 && t.end >= n;
|
|
6741
|
-
},
|
|
6741
|
+
}, br = ({ textbox: e, styles: t, range: n }) => {
|
|
6742
6742
|
if (!t || !Object.keys(t).length) return !1;
|
|
6743
6743
|
let { start: r, end: i } = n;
|
|
6744
6744
|
return i <= r ? !1 : (e.setSelectionStyles(t, r, i), !0);
|
|
6745
|
-
},
|
|
6745
|
+
}, xr = ({ textbox: e, range: t, property: n }) => {
|
|
6746
6746
|
if (!t) return;
|
|
6747
6747
|
let r = e.getSelectionStyles(t.start, t.end, !0);
|
|
6748
6748
|
if (r.length) return r[0]?.[n];
|
|
6749
|
-
},
|
|
6749
|
+
}, Sr = ({ strokeColor: e, width: t }) => t <= 0 ? null : e ?? "#000000", Cr = ({ width: e = 0 }) => e ? Math.max(0, e) : 0, wr = ({ value: e }) => typeof e == "string" ? e.toLocaleUpperCase() : "", Tr = ({ value: e, min: t, max: n }) => Math.min(Math.max(e, t), n), Er = class e extends _ {
|
|
6750
6750
|
static {
|
|
6751
6751
|
this.type = "background-textbox";
|
|
6752
6752
|
}
|
|
@@ -6871,7 +6871,7 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6871
6871
|
this._removeShadow(e);
|
|
6872
6872
|
}
|
|
6873
6873
|
_getDecorationColorAt(e, t) {
|
|
6874
|
-
let n = this.getValueOfPropertyAt(e, t, "strokeWidth"), r =
|
|
6874
|
+
let n = this.getValueOfPropertyAt(e, t, "strokeWidth"), r = Cr({ width: typeof n == "number" && Number.isFinite(n) ? n : 0 }), i = this.getValueOfPropertyAt(e, t, "stroke"), a = i == null ? null : Sr({
|
|
6875
6875
|
strokeColor: i,
|
|
6876
6876
|
width: r
|
|
6877
6877
|
});
|
|
@@ -6887,22 +6887,22 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6887
6887
|
_getCornerRadii({ width: e, height: t }) {
|
|
6888
6888
|
let n = e / 2, r = t / 2, i = Math.min(n, r);
|
|
6889
6889
|
return {
|
|
6890
|
-
bottomLeft:
|
|
6890
|
+
bottomLeft: Tr({
|
|
6891
6891
|
value: this.radiusBottomLeft ?? 0,
|
|
6892
6892
|
min: 0,
|
|
6893
6893
|
max: i
|
|
6894
6894
|
}),
|
|
6895
|
-
bottomRight:
|
|
6895
|
+
bottomRight: Tr({
|
|
6896
6896
|
value: this.radiusBottomRight ?? 0,
|
|
6897
6897
|
min: 0,
|
|
6898
6898
|
max: i
|
|
6899
6899
|
}),
|
|
6900
|
-
topLeft:
|
|
6900
|
+
topLeft: Tr({
|
|
6901
6901
|
value: this.radiusTopLeft ?? 0,
|
|
6902
6902
|
min: 0,
|
|
6903
6903
|
max: i
|
|
6904
6904
|
}),
|
|
6905
|
-
topRight:
|
|
6905
|
+
topRight: Tr({
|
|
6906
6906
|
value: this.radiusTopRight ?? 0,
|
|
6907
6907
|
min: 0,
|
|
6908
6908
|
max: i
|
|
@@ -6920,7 +6920,7 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6920
6920
|
_getEffectiveBackgroundFill() {
|
|
6921
6921
|
let e = this.backgroundColor;
|
|
6922
6922
|
if (!e) return null;
|
|
6923
|
-
let t =
|
|
6923
|
+
let t = Tr({
|
|
6924
6924
|
value: this.backgroundOpacity ?? 1,
|
|
6925
6925
|
min: 0,
|
|
6926
6926
|
max: 1
|
|
@@ -6928,7 +6928,7 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6928
6928
|
try {
|
|
6929
6929
|
r = new n(e);
|
|
6930
6930
|
} catch (t) {
|
|
6931
|
-
return
|
|
6931
|
+
return hr.emitError({
|
|
6932
6932
|
origin: "BackgroundTextbox",
|
|
6933
6933
|
method: "_getEffectiveBackgroundFill",
|
|
6934
6934
|
code: "INVALID_COLOR_VALUE",
|
|
@@ -6942,19 +6942,19 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6942
6942
|
return r.setAlpha(t), r.toRgba();
|
|
6943
6943
|
}
|
|
6944
6944
|
static _renderRoundedRect({ ctx: e, height: t, left: n, radii: r, top: i, width: a }) {
|
|
6945
|
-
let o = n + a, s = i + t, { topLeft: c, topRight: l, bottomRight: u, bottomLeft: d } = r, f =
|
|
6945
|
+
let o = n + a, s = i + t, { topLeft: c, topRight: l, bottomRight: u, bottomLeft: d } = r, f = Tr({
|
|
6946
6946
|
value: c,
|
|
6947
6947
|
min: 0,
|
|
6948
6948
|
max: a
|
|
6949
|
-
}), p =
|
|
6949
|
+
}), p = Tr({
|
|
6950
6950
|
value: l,
|
|
6951
6951
|
min: 0,
|
|
6952
6952
|
max: a
|
|
6953
|
-
}), m =
|
|
6953
|
+
}), m = Tr({
|
|
6954
6954
|
value: u,
|
|
6955
6955
|
min: 0,
|
|
6956
6956
|
max: a
|
|
6957
|
-
}), h =
|
|
6957
|
+
}), h = Tr({
|
|
6958
6958
|
value: d,
|
|
6959
6959
|
min: 0,
|
|
6960
6960
|
max: a
|
|
@@ -6965,9 +6965,9 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6965
6965
|
let { width: e = 0, height: t = 0 } = this, n = Math.round(e), r = Math.round(t);
|
|
6966
6966
|
n !== e && (this.width = Math.max(0, n)), r !== t && (this.height = Math.max(0, r));
|
|
6967
6967
|
}
|
|
6968
|
-
},
|
|
6969
|
-
y?.setClass && y.setClass(
|
|
6970
|
-
},
|
|
6968
|
+
}, Dr = () => {
|
|
6969
|
+
y?.setClass && y.setClass(Er, "background-textbox");
|
|
6970
|
+
}, Or = .01, kr = ({ textbox: e, lineIndices: t, updates: n }) => {
|
|
6971
6971
|
if (!t.length) return !1;
|
|
6972
6972
|
let { fontFamily: r, fontSize: i, fill: a, stroke: o } = n;
|
|
6973
6973
|
if (!(r !== void 0 || i !== void 0 || a !== void 0 || o !== void 0)) return !1;
|
|
@@ -6979,7 +6979,7 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6979
6979
|
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);
|
|
6980
6980
|
}
|
|
6981
6981
|
return l && (e.lineFontDefaults = c), l;
|
|
6982
|
-
},
|
|
6982
|
+
}, Ar = ({ lineText: e, lineStyles: t, lineDefaults: n }) => {
|
|
6983
6983
|
let r = e.length;
|
|
6984
6984
|
if (r === 0) return {
|
|
6985
6985
|
lineStyles: t,
|
|
@@ -7011,7 +7011,7 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7011
7011
|
lineStyles: l,
|
|
7012
7012
|
changed: u
|
|
7013
7013
|
};
|
|
7014
|
-
},
|
|
7014
|
+
}, jr = ({ lineFontDefaults: e }) => {
|
|
7015
7015
|
if (!e) return;
|
|
7016
7016
|
let t = {};
|
|
7017
7017
|
for (let n in e) {
|
|
@@ -7022,7 +7022,7 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7022
7022
|
i && (t[r] = { ...i });
|
|
7023
7023
|
}
|
|
7024
7024
|
return t;
|
|
7025
|
-
},
|
|
7025
|
+
}, Mr = ({ lineFontDefaults: e, scale: t }) => {
|
|
7026
7026
|
if (!e || !Number.isFinite(t) || Math.abs(t - 1) < .01) return;
|
|
7027
7027
|
let n = {}, r = !1, i = !1;
|
|
7028
7028
|
for (let a in e) {
|
|
@@ -7039,20 +7039,20 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7039
7039
|
n[o] = c, r = !0;
|
|
7040
7040
|
}
|
|
7041
7041
|
if (!(!r || !i)) return n;
|
|
7042
|
-
},
|
|
7042
|
+
}, Nr = ({ textbox: e, text: t }) => {
|
|
7043
7043
|
let { textLines: n } = e, r = Array.isArray(n) && n.length > 0 ? n.length : Math.max(t.split("\n").length, 1), i = 0;
|
|
7044
7044
|
for (let t = 0; t < r; t += 1) {
|
|
7045
7045
|
let n = e.getLineWidth(t);
|
|
7046
7046
|
n > i && (i = n);
|
|
7047
7047
|
}
|
|
7048
7048
|
return i;
|
|
7049
|
-
},
|
|
7049
|
+
}, Pr = ({ textbox: e, montageLeft: t, montageRight: n }) => {
|
|
7050
7050
|
e.setCoords();
|
|
7051
7051
|
let r = e.getBoundingRect(!1, !0), i = r.left ?? 0, a = i + (r.width ?? 0), o = n - t;
|
|
7052
7052
|
if (o > 0 && (r.width ?? 0) >= o - .01) return !1;
|
|
7053
7053
|
let s = 0;
|
|
7054
7054
|
return i < t ? s = t - i : a > n && (s = n - a), Math.abs(s) <= .01 ? !1 : (e.set({ left: (e.left ?? 0) + s }), !0);
|
|
7055
|
-
},
|
|
7055
|
+
}, Fr = ({ rawValue: e, calculatedValue: t }) => typeof e == "number" ? e : typeof t == "number" ? t : 0, Ir = ({ stylesList: e }) => {
|
|
7056
7056
|
let t = e.length;
|
|
7057
7057
|
if (!t) return !1;
|
|
7058
7058
|
for (let n = 0; n < t; n += 1) {
|
|
@@ -7062,16 +7062,16 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7062
7062
|
if (r !== void 0 || i !== void 0 || a !== void 0 || o !== void 0 || s !== void 0 || c !== void 0) return !0;
|
|
7063
7063
|
}
|
|
7064
7064
|
return !1;
|
|
7065
|
-
},
|
|
7066
|
-
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 =
|
|
7065
|
+
}, Lr = ({ textbox: e }) => {
|
|
7066
|
+
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 = Fr({
|
|
7067
7067
|
rawValue: t,
|
|
7068
7068
|
calculatedValue: a
|
|
7069
|
-
}), c =
|
|
7069
|
+
}), c = Fr({
|
|
7070
7070
|
rawValue: n,
|
|
7071
7071
|
calculatedValue: o
|
|
7072
7072
|
}), l = Number.isFinite(s) ? Math.round(s) : null, u = Number.isFinite(c) ? Math.round(c) : null, d = {};
|
|
7073
7073
|
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;
|
|
7074
|
-
},
|
|
7074
|
+
}, Rr = ({ textbox: e }) => {
|
|
7075
7075
|
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;
|
|
7076
7076
|
return {
|
|
7077
7077
|
width: t,
|
|
@@ -7089,9 +7089,9 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7089
7089
|
bottomLeft: f
|
|
7090
7090
|
},
|
|
7091
7091
|
styles: JSON.parse(JSON.stringify(r)),
|
|
7092
|
-
lineFontDefaults:
|
|
7092
|
+
lineFontDefaults: jr({ lineFontDefaults: i })
|
|
7093
7093
|
};
|
|
7094
|
-
},
|
|
7094
|
+
}, zr = ({ base: e }) => {
|
|
7095
7095
|
let t = 1 / Math.max(1, e.width), n = [e.fontSize];
|
|
7096
7096
|
Object.values(e.styles).forEach((e) => {
|
|
7097
7097
|
Object.values(e).forEach((e) => {
|
|
@@ -7108,7 +7108,7 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7108
7108
|
fontScale: r,
|
|
7109
7109
|
proportionalScale: Math.max(t, r)
|
|
7110
7110
|
};
|
|
7111
|
-
},
|
|
7111
|
+
}, Br = ({ textbox: e, canvasManager: t, base: n, widthScale: r, heightScale: i, placement: a, shouldScaleFontSize: o, shouldScalePadding: s, shouldScaleRadii: c, shouldDisableAutoExpandOnHorizontalChange: l = !1, shouldRoundDimensions: u = !0 }) => {
|
|
7112
7112
|
let { width: d, fontSize: f, padding: p, radii: m, styles: h, lineFontDefaults: g } = n, _ = Math.max(1, d * r), v = u ? Math.max(1, Math.round(_)) : _, y = Math.max(Math.min(8, f), f * i), b = Object.keys(h).length > 0, x;
|
|
7113
7113
|
if (o && b) {
|
|
7114
7114
|
let e = {};
|
|
@@ -7127,7 +7127,7 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7127
7127
|
}), Object.keys(e).length && (x = e);
|
|
7128
7128
|
}
|
|
7129
7129
|
let S;
|
|
7130
|
-
o && (S =
|
|
7130
|
+
o && (S = Mr({
|
|
7131
7131
|
lineFontDefaults: g,
|
|
7132
7132
|
scale: i
|
|
7133
7133
|
}));
|
|
@@ -7141,7 +7141,7 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7141
7141
|
topRight: Math.max(0, m.topRight * i),
|
|
7142
7142
|
bottomRight: Math.max(0, m.bottomRight * i),
|
|
7143
7143
|
bottomLeft: Math.max(0, m.bottomLeft * i)
|
|
7144
|
-
} : m, T = e.width ?? d, E = Math.abs(v - T) >
|
|
7144
|
+
} : m, T = e.width ?? d, E = Math.abs(v - T) > Or;
|
|
7145
7145
|
l && E && (e.autoExpand = !1), x && (e.styles = x), S && (e.lineFontDefaults = S), e.set({
|
|
7146
7146
|
width: v,
|
|
7147
7147
|
fontSize: o ? y : f,
|
|
@@ -7163,7 +7163,7 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7163
7163
|
} finally {
|
|
7164
7164
|
e.shouldRoundDimensionsOnInit = D;
|
|
7165
7165
|
}
|
|
7166
|
-
let O = u ?
|
|
7166
|
+
let O = u ? Lr({ textbox: e }) : !1;
|
|
7167
7167
|
return O && (e.dirty = !0), t.applyObjectPlacement({
|
|
7168
7168
|
object: e,
|
|
7169
7169
|
placement: a
|
|
@@ -7171,18 +7171,18 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7171
7171
|
appliedWidth: e.width ?? v,
|
|
7172
7172
|
dimensionsRounded: O
|
|
7173
7173
|
};
|
|
7174
|
-
},
|
|
7174
|
+
}, Vr = ({ transform: e }) => {
|
|
7175
7175
|
let { corner: t = "", action: n = "" } = e;
|
|
7176
7176
|
return {
|
|
7177
7177
|
isCornerHandle: t === "tl" || t === "tr" || t === "bl" || t === "br" || n === "scale",
|
|
7178
7178
|
isHorizontalHandle: t === "ml" || t === "mr" || n === "scaleX",
|
|
7179
7179
|
isVerticalHandle: t === "mt" || t === "mb" || n === "scaleY"
|
|
7180
7180
|
};
|
|
7181
|
-
},
|
|
7181
|
+
}, Hr = ({ textbox: e, transform: t, appliedWidth: n }) => {
|
|
7182
7182
|
t.scaleX = 1, t.scaleY = 1;
|
|
7183
7183
|
let { original: r } = t;
|
|
7184
7184
|
r && (r.scaleX = 1, r.scaleY = 1, r.width = n, r.height = e.height, r.left = e.left, r.top = e.top);
|
|
7185
|
-
},
|
|
7185
|
+
}, Ur = ({ textbox: e, transform: t, scenePoint: n }) => {
|
|
7186
7186
|
let { x: r, y: i } = e._getTransformedDimensions();
|
|
7187
7187
|
if (r <= 0 || i <= 0) return null;
|
|
7188
7188
|
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);
|
|
@@ -7192,27 +7192,27 @@ var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7192
7192
|
stepScaleX: l,
|
|
7193
7193
|
stepScaleY: u
|
|
7194
7194
|
};
|
|
7195
|
-
},
|
|
7196
|
-
function
|
|
7195
|
+
}, Wr = 1e-4;
|
|
7196
|
+
function Gr(e) {
|
|
7197
7197
|
return !!e && e instanceof _;
|
|
7198
7198
|
}
|
|
7199
|
-
function
|
|
7200
|
-
if (!
|
|
7199
|
+
function Kr(e) {
|
|
7200
|
+
if (!Gr(e)) return !1;
|
|
7201
7201
|
let t = e.group;
|
|
7202
7202
|
return e.shapeNodeType === "text" && t?.shapeComposite === !0;
|
|
7203
7203
|
}
|
|
7204
|
-
var
|
|
7204
|
+
var qr = class {
|
|
7205
7205
|
constructor({ canvas: t, canvasManager: n, persistScaledTextbox: r }) {
|
|
7206
7206
|
this.handleMouseMove = (e) => {
|
|
7207
7207
|
let t = this.canvas._currentTransform;
|
|
7208
7208
|
if (!t) return;
|
|
7209
7209
|
let { target: n } = t;
|
|
7210
|
-
if (!
|
|
7210
|
+
if (!Gr(n) || Kr(n)) return;
|
|
7211
7211
|
let r = this.scalingState.get(n);
|
|
7212
7212
|
if (!r || !e.e) return;
|
|
7213
|
-
let { isCornerHandle: i, isHorizontalHandle: a, isVerticalHandle: o } =
|
|
7213
|
+
let { isCornerHandle: i, isHorizontalHandle: a, isVerticalHandle: o } = Vr({ transform: t });
|
|
7214
7214
|
if (!a && !o && !i) return;
|
|
7215
|
-
let s =
|
|
7215
|
+
let s = Ur({
|
|
7216
7216
|
textbox: n,
|
|
7217
7217
|
transform: t,
|
|
7218
7218
|
scenePoint: this.canvas.getScenePoint(e.e)
|
|
@@ -7235,20 +7235,20 @@ var Kr = class {
|
|
|
7235
7235
|
}, j = r.lastAllowedScaleX, M = r.lastAllowedScaleY;
|
|
7236
7236
|
if (i) {
|
|
7237
7237
|
let e = Math.max(r.minimumProportionalScale, r.lastAllowedScaleX * Math.sqrt(u * d)), t = c || l ? r.minimumProportionalScale : e;
|
|
7238
|
-
if (Math.abs(t - r.lastAllowedScaleX) <=
|
|
7238
|
+
if (Math.abs(t - r.lastAllowedScaleX) <= Wr) return;
|
|
7239
7239
|
j = t, M = t;
|
|
7240
7240
|
} else {
|
|
7241
7241
|
if (a) {
|
|
7242
7242
|
let e = r.lastAllowedScaleX * u, t = c ? r.minimumWidthScale : Math.max(r.minimumWidthScale, e);
|
|
7243
|
-
Math.abs(t - r.lastAllowedScaleX) >
|
|
7243
|
+
Math.abs(t - r.lastAllowedScaleX) > Wr && (j = t);
|
|
7244
7244
|
}
|
|
7245
7245
|
if (o) {
|
|
7246
7246
|
let e = r.lastAllowedScaleY * d, t = l ? r.minimumFontScale : Math.max(r.minimumFontScale, e);
|
|
7247
|
-
Math.abs(t - r.lastAllowedScaleY) >
|
|
7247
|
+
Math.abs(t - r.lastAllowedScaleY) > Wr && (M = t);
|
|
7248
7248
|
}
|
|
7249
|
-
if (Math.abs(j - r.lastAllowedScaleX) <=
|
|
7249
|
+
if (Math.abs(j - r.lastAllowedScaleX) <= Wr && Math.abs(M - r.lastAllowedScaleY) <= Wr) return;
|
|
7250
7250
|
}
|
|
7251
|
-
let { appliedWidth: N, dimensionsRounded: P } =
|
|
7251
|
+
let { appliedWidth: N, dimensionsRounded: P } = Br({
|
|
7252
7252
|
textbox: n,
|
|
7253
7253
|
canvasManager: this.canvasManager,
|
|
7254
7254
|
base: r.startBase,
|
|
@@ -7261,7 +7261,7 @@ var Kr = class {
|
|
|
7261
7261
|
shouldDisableAutoExpandOnHorizontalChange: a,
|
|
7262
7262
|
shouldRoundDimensions: !i
|
|
7263
7263
|
});
|
|
7264
|
-
|
|
7264
|
+
Hr({
|
|
7265
7265
|
textbox: n,
|
|
7266
7266
|
transform: t,
|
|
7267
7267
|
appliedWidth: N
|
|
@@ -7282,27 +7282,27 @@ var Kr = class {
|
|
|
7282
7282
|
}), this.canvas.requestRenderAll();
|
|
7283
7283
|
}, this.handleObjectScaling = (t) => {
|
|
7284
7284
|
let { target: n, transform: r } = t;
|
|
7285
|
-
if (n instanceof e || !
|
|
7285
|
+
if (n instanceof e || !Gr(n) || Kr(n) || !r) return;
|
|
7286
7286
|
n.isScaling = !0;
|
|
7287
7287
|
let i = this._ensureScalingState({
|
|
7288
7288
|
textbox: n,
|
|
7289
7289
|
transform: r
|
|
7290
|
-
}), { startBase: a } = i, { width: o, fontSize: s } = a, { isCornerHandle: c, isHorizontalHandle: l, isVerticalHandle: u } =
|
|
7290
|
+
}), { startBase: a } = i, { width: o, fontSize: s } = a, { isCornerHandle: c, isHorizontalHandle: l, isVerticalHandle: u } = Vr({ transform: r }), d = r.corner ?? "", f = c || u;
|
|
7291
7291
|
if (!l && !u && !c) return;
|
|
7292
7292
|
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({
|
|
7293
7293
|
object: n,
|
|
7294
7294
|
originX: _,
|
|
7295
7295
|
originY: v
|
|
7296
|
-
}), { paddingTop: b = 0, paddingRight: x = 0, paddingBottom: S = 0, paddingLeft: C = 0, radiusTopLeft: w = 0, radiusTopRight: T = 0, radiusBottomRight: E = 0, radiusBottomLeft: D = 0, fontSize: O, width: k } = n, A = c || u, j = c || u, M = k ?? o, N = i.lastAllowedScaleX, P = i.lastAllowedScaleY, F = y,
|
|
7296
|
+
}), { paddingTop: b = 0, paddingRight: x = 0, paddingBottom: S = 0, paddingLeft: C = 0, radiusTopLeft: w = 0, radiusTopRight: T = 0, radiusBottomRight: E = 0, radiusBottomLeft: D = 0, fontSize: O, width: k } = n, A = c || u, j = c || u, M = k ?? o, N = i.lastAllowedScaleX, P = i.lastAllowedScaleY, F = y, ee = !0;
|
|
7297
7297
|
if (c) {
|
|
7298
7298
|
let e = Math.sqrt(h * g), t = i.lastAllowedScaleX * e, n = p < 0 || m < 0, r = _ !== i.startTransformOriginX || v !== i.startTransformOriginY, a = d !== i.startTransformCorner;
|
|
7299
|
-
if (n || r || a) N = i.lastAllowedScaleX, P = i.lastAllowedScaleY, F = i.lastAllowedPlacement,
|
|
7299
|
+
if (n || r || a) N = i.lastAllowedScaleX, P = i.lastAllowedScaleY, F = i.lastAllowedPlacement, ee = !1;
|
|
7300
7300
|
else {
|
|
7301
7301
|
let e = Math.max(i.minimumProportionalScale, t);
|
|
7302
7302
|
N = e, P = e;
|
|
7303
7303
|
}
|
|
7304
7304
|
} else l && (N = Math.max(i.minimumWidthScale, i.lastAllowedScaleX * h)), u && (P = Math.max(i.minimumFontScale, i.lastAllowedScaleY * g));
|
|
7305
|
-
let { appliedWidth:
|
|
7305
|
+
let { appliedWidth: te, dimensionsRounded: I } = Br({
|
|
7306
7306
|
textbox: n,
|
|
7307
7307
|
canvasManager: this.canvasManager,
|
|
7308
7308
|
base: a,
|
|
@@ -7315,14 +7315,14 @@ var Kr = class {
|
|
|
7315
7315
|
shouldDisableAutoExpandOnHorizontalChange: l,
|
|
7316
7316
|
shouldRoundDimensions: !c
|
|
7317
7317
|
});
|
|
7318
|
-
|
|
7318
|
+
Hr({
|
|
7319
7319
|
textbox: n,
|
|
7320
7320
|
transform: r,
|
|
7321
|
-
appliedWidth:
|
|
7322
|
-
}), this.canvas.requestRenderAll(),
|
|
7321
|
+
appliedWidth: te
|
|
7322
|
+
}), this.canvas.requestRenderAll(), ee && this._updateScalingStateAfterLiveCommit({
|
|
7323
7323
|
textbox: n,
|
|
7324
7324
|
state: i,
|
|
7325
|
-
appliedWidth:
|
|
7325
|
+
appliedWidth: te,
|
|
7326
7326
|
previousFontSize: O ?? s,
|
|
7327
7327
|
previousPadding: {
|
|
7328
7328
|
top: b,
|
|
@@ -7337,7 +7337,7 @@ var Kr = class {
|
|
|
7337
7337
|
bottomLeft: D
|
|
7338
7338
|
},
|
|
7339
7339
|
previousWidth: M,
|
|
7340
|
-
dimensionsRounded:
|
|
7340
|
+
dimensionsRounded: I,
|
|
7341
7341
|
isCornerHandle: c,
|
|
7342
7342
|
isHorizontalHandle: l,
|
|
7343
7343
|
isVerticalHandle: u,
|
|
@@ -7348,7 +7348,7 @@ var Kr = class {
|
|
|
7348
7348
|
let { target: n } = t;
|
|
7349
7349
|
if (n instanceof e) {
|
|
7350
7350
|
let t = n.getObjects();
|
|
7351
|
-
if (!t.some((e) =>
|
|
7351
|
+
if (!t.some((e) => Gr(e))) return;
|
|
7352
7352
|
let { scaleX: r = 1, scaleY: i = 1 } = n;
|
|
7353
7353
|
if (Math.abs(r - 1) < .01 && Math.abs(i - 1) < .01) return;
|
|
7354
7354
|
this.canvas.discardActiveObject(), t.forEach((e) => {
|
|
@@ -7358,7 +7358,7 @@ var Kr = class {
|
|
|
7358
7358
|
this.canvas.setActiveObject(a), this.canvas.requestRenderAll();
|
|
7359
7359
|
return;
|
|
7360
7360
|
}
|
|
7361
|
-
if (!
|
|
7361
|
+
if (!Gr(n) || Kr(n)) return;
|
|
7362
7362
|
n.isScaling = !1;
|
|
7363
7363
|
let r = this.scalingState.get(n);
|
|
7364
7364
|
if (this.scalingState.delete(n), !r?.hasScalingChange) return;
|
|
@@ -7383,11 +7383,11 @@ var Kr = class {
|
|
|
7383
7383
|
}, this.canvas = t, this.canvasManager = n, this.persistScaledTextbox = r, this.scalingState = /* @__PURE__ */ new WeakMap();
|
|
7384
7384
|
}
|
|
7385
7385
|
commitStandaloneTextScale({ target: e, shouldDisableAutoExpandOnHorizontalChange: t = !1 }) {
|
|
7386
|
-
if (!
|
|
7386
|
+
if (!Gr(e) || Kr(e)) return !1;
|
|
7387
7387
|
let n = Math.abs(e.scaleX ?? 1) || 1, r = Math.abs(e.scaleY ?? 1) || 1;
|
|
7388
7388
|
if (!(Math.abs(n - 1) > .01 || Math.abs(r - 1) > .01)) return !1;
|
|
7389
|
-
let i =
|
|
7390
|
-
return
|
|
7389
|
+
let i = Rr({ textbox: e }), a = this.canvasManager.getObjectPlacement({ object: e });
|
|
7390
|
+
return Br({
|
|
7391
7391
|
textbox: e,
|
|
7392
7392
|
canvasManager: this.canvasManager,
|
|
7393
7393
|
base: i,
|
|
@@ -7403,7 +7403,7 @@ var Kr = class {
|
|
|
7403
7403
|
_ensureScalingState({ textbox: e, transform: t }) {
|
|
7404
7404
|
let n = this.scalingState.get(e);
|
|
7405
7405
|
if (!n) {
|
|
7406
|
-
let r =
|
|
7406
|
+
let r = Rr({ textbox: e }), i = zr({ base: r }), a = t.original?.originX ?? t.originX ?? e.originX ?? "center", o = t.original?.originY ?? t.originY ?? e.originY ?? "center";
|
|
7407
7407
|
n = {
|
|
7408
7408
|
startBase: r,
|
|
7409
7409
|
startTransformCorner: typeof t.corner == "string" ? t.corner : null,
|
|
@@ -7435,7 +7435,7 @@ var Kr = class {
|
|
|
7435
7435
|
topRight: e.radiusTopRight ?? 0,
|
|
7436
7436
|
bottomRight: e.radiusBottomRight ?? 0,
|
|
7437
7437
|
bottomLeft: e.radiusBottomLeft ?? 0
|
|
7438
|
-
}, v = Math.abs(n - o) >
|
|
7438
|
+
}, v = Math.abs(n - o) > Or, y = Math.abs(h - r) > Or, 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;
|
|
7439
7439
|
if (c) {
|
|
7440
7440
|
let e = h / Math.max(1, m);
|
|
7441
7441
|
S = e, C = e;
|
|
@@ -7456,7 +7456,7 @@ var Kr = class {
|
|
|
7456
7456
|
originY: a
|
|
7457
7457
|
});
|
|
7458
7458
|
}
|
|
7459
|
-
},
|
|
7459
|
+
}, Jr = ({ textbox: e }) => {
|
|
7460
7460
|
let t = e.text ?? "";
|
|
7461
7461
|
if (!t.length) return [];
|
|
7462
7462
|
let n = t.split("\n"), r = [], i = 0;
|
|
@@ -7468,7 +7468,7 @@ var Kr = class {
|
|
|
7468
7468
|
});
|
|
7469
7469
|
}
|
|
7470
7470
|
return r;
|
|
7471
|
-
},
|
|
7471
|
+
}, Yr = ({ range: e, text: t }) => {
|
|
7472
7472
|
if (!e) return null;
|
|
7473
7473
|
let n = t.length;
|
|
7474
7474
|
if (n <= 0) return null;
|
|
@@ -7477,8 +7477,8 @@ var Kr = class {
|
|
|
7477
7477
|
start: l,
|
|
7478
7478
|
end: u
|
|
7479
7479
|
};
|
|
7480
|
-
},
|
|
7481
|
-
let n =
|
|
7480
|
+
}, Xr = ({ textbox: e, range: t }) => {
|
|
7481
|
+
let n = Jr({ textbox: e });
|
|
7482
7482
|
if (!n.length) return t;
|
|
7483
7483
|
let { start: r } = t, { end: i } = t;
|
|
7484
7484
|
for (let e = 0; e < n.length; e += 1) {
|
|
@@ -7491,7 +7491,7 @@ var Kr = class {
|
|
|
7491
7491
|
start: r,
|
|
7492
7492
|
end: i
|
|
7493
7493
|
};
|
|
7494
|
-
},
|
|
7494
|
+
}, Zr = ({ textbox: e, range: t }) => {
|
|
7495
7495
|
let n = e.text ?? "";
|
|
7496
7496
|
if (!n.length) return [];
|
|
7497
7497
|
let { start: r, end: i } = t, a = n.split("\n"), o = [], s = 0;
|
|
@@ -7500,7 +7500,7 @@ var Kr = class {
|
|
|
7500
7500
|
i > n && r < c && o.push(e), s = c + 1;
|
|
7501
7501
|
}
|
|
7502
7502
|
return o;
|
|
7503
|
-
},
|
|
7503
|
+
}, Qr = ({ textbox: e, range: t }) => {
|
|
7504
7504
|
let n = e.text ?? "";
|
|
7505
7505
|
if (!n.length) return [];
|
|
7506
7506
|
let { start: r, end: i } = t, a = n.split("\n"), o = [], s = 0;
|
|
@@ -7509,20 +7509,20 @@ var Kr = class {
|
|
|
7509
7509
|
r <= n && i >= c && o.push(e), s = c + 1;
|
|
7510
7510
|
}
|
|
7511
7511
|
return o;
|
|
7512
|
-
},
|
|
7512
|
+
}, $r = ({ previous: e, next: t }) => {
|
|
7513
7513
|
let n = Math.min(e.length, t.length);
|
|
7514
7514
|
for (let r = 0; r < n; r += 1) if (e[r] !== t[r]) return r;
|
|
7515
7515
|
return n;
|
|
7516
|
-
},
|
|
7516
|
+
}, ei = ({ text: e, charIndex: t }) => {
|
|
7517
7517
|
let n = Math.max(0, Math.min(t, e.length)), r = 0;
|
|
7518
7518
|
for (let t = 0; t < n; t += 1) e[t] === "\n" && (r += 1);
|
|
7519
7519
|
return r;
|
|
7520
|
-
},
|
|
7520
|
+
}, ti = ({ text: e, lineIndex: t }) => {
|
|
7521
7521
|
if (t <= 0) return 0;
|
|
7522
7522
|
let n = 0;
|
|
7523
7523
|
for (let r = 0; r < e.length; r += 1) if (e[r] === "\n" && (n += 1, n === t)) return r + 1;
|
|
7524
7524
|
return e.length;
|
|
7525
|
-
},
|
|
7525
|
+
}, ni = class e {
|
|
7526
7526
|
constructor({ editor: t }) {
|
|
7527
7527
|
this._handleTextEditingEntered = (t) => {
|
|
7528
7528
|
this.isTextEditingActive = !0;
|
|
@@ -7535,7 +7535,7 @@ var Kr = class {
|
|
|
7535
7535
|
if (!e._isTextbox(n) || this.lineDefaultsSyncing.has(n)) return;
|
|
7536
7536
|
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 });
|
|
7537
7537
|
if (s) {
|
|
7538
|
-
let e =
|
|
7538
|
+
let e = wr({ value: l });
|
|
7539
7539
|
e !== i && n.set({ text: e }), n.textCaseRaw = l;
|
|
7540
7540
|
} else n.textCaseRaw = i;
|
|
7541
7541
|
if (!r && o === void 0 && (n.autoExpand = !0), r) {
|
|
@@ -7553,7 +7553,7 @@ var Kr = class {
|
|
|
7553
7553
|
let r = e._isShapeOwnedTextbox(n);
|
|
7554
7554
|
this.editingPlacementState?.delete(n);
|
|
7555
7555
|
let i = n.text ?? "";
|
|
7556
|
-
n.uppercase ? n.textCaseRaw = n.textCaseRaw ?? i.toLocaleLowerCase() : n.textCaseRaw = i, r || (
|
|
7556
|
+
n.uppercase ? n.textCaseRaw = n.textCaseRaw ?? i.toLocaleLowerCase() : n.textCaseRaw = i, r || (Lr({ textbox: n }) && (n.setCoords(), n.dirty = !0, this.canvas.requestRenderAll()), n.locked || n.set({
|
|
7557
7557
|
lockMovementX: !1,
|
|
7558
7558
|
lockMovementY: !1
|
|
7559
7559
|
}));
|
|
@@ -7580,7 +7580,7 @@ var Kr = class {
|
|
|
7580
7580
|
transform: r,
|
|
7581
7581
|
event: i ?? null
|
|
7582
7582
|
});
|
|
7583
|
-
}, this.editor = t, this.canvas = t.canvas, this.fonts = t.options.fonts ?? [], this.scalingController = new
|
|
7583
|
+
}, this.editor = t, this.canvas = t.canvas, this.fonts = t.options.fonts ?? [], this.scalingController = new qr({
|
|
7584
7584
|
canvas: t.canvas,
|
|
7585
7585
|
canvasManager: t.canvasManager,
|
|
7586
7586
|
persistScaledTextbox: ({ target: e, style: t }) => {
|
|
@@ -7589,15 +7589,15 @@ var Kr = class {
|
|
|
7589
7589
|
style: t
|
|
7590
7590
|
});
|
|
7591
7591
|
}
|
|
7592
|
-
}), this.editingPlacementState = /* @__PURE__ */ new WeakMap(), this.lineDefaultsSyncing = /* @__PURE__ */ new WeakSet(), this.isTextEditingActive = !1, this._bindEvents(),
|
|
7592
|
+
}), this.editingPlacementState = /* @__PURE__ */ new WeakMap(), this.lineDefaultsSyncing = /* @__PURE__ */ new WeakSet(), this.isTextEditingActive = !1, this._bindEvents(), Dr();
|
|
7593
7593
|
}
|
|
7594
7594
|
addText({ id: t = `text-${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 } = {}) {
|
|
7595
7595
|
let { canvasManager: j, historyManager: M } = this.editor, { canvas: N } = this;
|
|
7596
7596
|
M.suspendHistory();
|
|
7597
|
-
let P = i ?? this._getDefaultFontFamily(), F =
|
|
7597
|
+
let P = i ?? this._getDefaultFontFamily(), F = Cr({ width: m }), ee = Sr({
|
|
7598
7598
|
strokeColor: p,
|
|
7599
7599
|
width: F
|
|
7600
|
-
}),
|
|
7600
|
+
}), te = {
|
|
7601
7601
|
id: t,
|
|
7602
7602
|
fontFamily: P,
|
|
7603
7603
|
fontSize: a,
|
|
@@ -7608,7 +7608,7 @@ var Kr = class {
|
|
|
7608
7608
|
linethrough: u,
|
|
7609
7609
|
textAlign: d,
|
|
7610
7610
|
fill: f,
|
|
7611
|
-
stroke:
|
|
7611
|
+
stroke: ee,
|
|
7612
7612
|
strokeWidth: F,
|
|
7613
7613
|
strokeUniform: !0,
|
|
7614
7614
|
opacity: h,
|
|
@@ -7623,40 +7623,40 @@ var Kr = class {
|
|
|
7623
7623
|
radiusBottomRight: w,
|
|
7624
7624
|
radiusBottomLeft: T,
|
|
7625
7625
|
...E
|
|
7626
|
-
},
|
|
7627
|
-
|
|
7628
|
-
let
|
|
7629
|
-
if (
|
|
7630
|
-
let e =
|
|
7631
|
-
e !==
|
|
7632
|
-
}
|
|
7633
|
-
|
|
7634
|
-
let
|
|
7635
|
-
|
|
7636
|
-
object:
|
|
7626
|
+
}, I = new Er(n, te), ne = r !== !1;
|
|
7627
|
+
I.autoExpand = ne;
|
|
7628
|
+
let re = E.left !== void 0 || E.top !== void 0;
|
|
7629
|
+
if (I.textCaseRaw = I.text ?? "", l) {
|
|
7630
|
+
let e = wr({ value: I.textCaseRaw });
|
|
7631
|
+
e !== I.text && I.set({ text: e });
|
|
7632
|
+
}
|
|
7633
|
+
Lr({ textbox: I }) && (I.dirty = !0);
|
|
7634
|
+
let L;
|
|
7635
|
+
re && (L = j.resolveObjectPlacement({
|
|
7636
|
+
object: I,
|
|
7637
7637
|
left: E.left,
|
|
7638
7638
|
top: E.top,
|
|
7639
7639
|
originX: E.originX,
|
|
7640
7640
|
originY: E.originY,
|
|
7641
7641
|
fallbackPoint: j.getMontageAreaSceneCenter()
|
|
7642
7642
|
}));
|
|
7643
|
-
let
|
|
7644
|
-
return (
|
|
7645
|
-
textbox:
|
|
7646
|
-
placement:
|
|
7647
|
-
shouldAutoExpand:
|
|
7648
|
-
clampToMontage:
|
|
7649
|
-
}),
|
|
7650
|
-
textbox:
|
|
7643
|
+
let ie = ne && e._hasWrappedLinesBeyondExplicitBreaks(I);
|
|
7644
|
+
return (re || ie) && this._normalizeTextboxAfterContentChange({
|
|
7645
|
+
textbox: I,
|
|
7646
|
+
placement: L,
|
|
7647
|
+
shouldAutoExpand: ie,
|
|
7648
|
+
clampToMontage: re
|
|
7649
|
+
}), L || j.centerObjectToMontageArea({ object: I }), A || N.add(I), O || N.setActiveObject(I), N.requestRenderAll(), M.resumeHistory(), k || M.saveState(), N.fire("editor:text-added", {
|
|
7650
|
+
textbox: I,
|
|
7651
7651
|
options: {
|
|
7652
|
-
...
|
|
7652
|
+
...te,
|
|
7653
7653
|
text: n,
|
|
7654
7654
|
bold: o,
|
|
7655
7655
|
italic: s,
|
|
7656
7656
|
strikethrough: u,
|
|
7657
7657
|
align: d,
|
|
7658
7658
|
color: f,
|
|
7659
|
-
strokeColor:
|
|
7659
|
+
strokeColor: ee,
|
|
7660
7660
|
strokeWidth: F
|
|
7661
7661
|
},
|
|
7662
7662
|
flags: {
|
|
@@ -7664,127 +7664,127 @@ var Kr = class {
|
|
|
7664
7664
|
withoutSave: !!k,
|
|
7665
7665
|
withoutAdding: !!A
|
|
7666
7666
|
}
|
|
7667
|
-
}),
|
|
7667
|
+
}), I;
|
|
7668
7668
|
}
|
|
7669
7669
|
updateText({ target: t, style: n = {}, withoutSave: r, skipRender: i, selectionRange: a } = {}) {
|
|
7670
7670
|
let o = this._resolveTextObject(t);
|
|
7671
7671
|
if (!o) return null;
|
|
7672
7672
|
let { text: s = "" } = o, { historyManager: c } = this.editor, { canvasManager: l } = this.editor, { canvas: u } = this;
|
|
7673
7673
|
c.suspendHistory();
|
|
7674
|
-
let d = e._getSnapshot(o), { text: f, autoExpand: p, fontFamily: m, fontSize: h, bold: g, italic: _, underline: v, uppercase: y, strikethrough: b, align: x, color: S, strokeColor: C, strokeWidth: w, opacity: T, backgroundColor: E, backgroundOpacity: D, paddingTop: O, paddingRight: k, paddingBottom: A, paddingLeft: j, radiusTopLeft: M, radiusTopRight: N, radiusBottomRight: P, radiusBottomLeft: F, left:
|
|
7674
|
+
let d = e._getSnapshot(o), { text: f, autoExpand: p, fontFamily: m, fontSize: h, bold: g, italic: _, underline: v, uppercase: y, strikethrough: b, align: x, color: S, strokeColor: C, strokeWidth: w, opacity: T, backgroundColor: E, backgroundOpacity: D, paddingTop: O, paddingRight: k, paddingBottom: A, paddingLeft: j, radiusTopLeft: M, radiusTopRight: N, radiusBottomRight: P, radiusBottomLeft: F, left: ee, top: te, originX: I, originY: ne, ...re } = n, L = { ...re }, ie = l.resolveObjectPlacement({
|
|
7675
7675
|
object: o,
|
|
7676
|
-
left:
|
|
7677
|
-
top:
|
|
7678
|
-
originX:
|
|
7679
|
-
originY:
|
|
7680
|
-
}),
|
|
7676
|
+
left: ee,
|
|
7677
|
+
top: te,
|
|
7678
|
+
originX: I,
|
|
7679
|
+
originY: ne
|
|
7680
|
+
}), R = a === void 0 ? _r({ textbox: o }) : Yr({
|
|
7681
7681
|
text: s,
|
|
7682
7682
|
range: a
|
|
7683
|
-
}),
|
|
7683
|
+
}), ae = R ? Xr({
|
|
7684
7684
|
textbox: o,
|
|
7685
|
-
range:
|
|
7686
|
-
}) : null,
|
|
7685
|
+
range: R
|
|
7686
|
+
}) : null, z = {}, oe = {}, B = {}, se, ce, le = yr({
|
|
7687
7687
|
textbox: o,
|
|
7688
|
-
range:
|
|
7689
|
-
}),
|
|
7690
|
-
if (m !== void 0 && (
|
|
7688
|
+
range: R
|
|
7689
|
+
}), V = !R || le, H = !R;
|
|
7690
|
+
if (m !== void 0 && (ae && (oe.fontFamily = m), V && (L.fontFamily = m, H && (B.fontFamily = m))), h !== void 0 && (ae && (oe.fontSize = h), V && (L.fontSize = h, H && (B.fontSize = h))), g !== void 0) {
|
|
7691
7691
|
let e = g ? "bold" : "normal";
|
|
7692
|
-
|
|
7692
|
+
R && (z.fontWeight = e), V && (L.fontWeight = e, H && (B.fontWeight = e));
|
|
7693
7693
|
}
|
|
7694
7694
|
if (_ !== void 0) {
|
|
7695
7695
|
let e = _ ? "italic" : "normal";
|
|
7696
|
-
|
|
7696
|
+
R && (z.fontStyle = e), V && (L.fontStyle = e, H && (B.fontStyle = e));
|
|
7697
7697
|
}
|
|
7698
|
-
if (v !== void 0 && (
|
|
7699
|
-
let e =
|
|
7698
|
+
if (v !== void 0 && (R && (z.underline = v), V && (L.underline = v, H && (B.underline = v))), b !== void 0 && (R && (z.linethrough = b), V && (L.linethrough = b, H && (B.linethrough = b))), x !== void 0 && (L.textAlign = x), S !== void 0 && (R && (z.fill = S), V && (L.fill = S, H && (B.fill = S))), C !== void 0 || w !== void 0) {
|
|
7699
|
+
let e = R ? xr({
|
|
7700
7700
|
textbox: o,
|
|
7701
|
-
range:
|
|
7701
|
+
range: R,
|
|
7702
7702
|
property: "strokeWidth"
|
|
7703
|
-
}) : void 0, t =
|
|
7703
|
+
}) : void 0, t = R ? xr({
|
|
7704
7704
|
textbox: o,
|
|
7705
|
-
range:
|
|
7705
|
+
range: R,
|
|
7706
7706
|
property: "stroke"
|
|
7707
7707
|
}) : void 0;
|
|
7708
|
-
|
|
7708
|
+
ce = Cr({ width: w ?? e ?? o.strokeWidth ?? 0 }), se = Sr({
|
|
7709
7709
|
strokeColor: C ?? t ?? o.stroke ?? void 0,
|
|
7710
|
-
width:
|
|
7711
|
-
}),
|
|
7710
|
+
width: ce
|
|
7711
|
+
}), R && (z.stroke = se, z.strokeWidth = ce), V && (L.stroke = se, L.strokeWidth = ce, H && (B.stroke = se, B.strokeWidth = ce));
|
|
7712
7712
|
}
|
|
7713
|
-
T !== void 0 && (
|
|
7713
|
+
T !== void 0 && (L.opacity = T), E !== void 0 && (L.backgroundColor = E), D !== void 0 && (L.backgroundOpacity = D), O !== void 0 && (L.paddingTop = O), k !== void 0 && (L.paddingRight = k), A !== void 0 && (L.paddingBottom = A), j !== void 0 && (L.paddingLeft = j), M !== void 0 && (L.radiusTopLeft = M), N !== void 0 && (L.radiusTopRight = N), P !== void 0 && (L.radiusBottomRight = P), F !== void 0 && (L.radiusBottomLeft = F);
|
|
7714
7714
|
let ue = o.textCaseRaw ?? s, de = !!o.uppercase, fe = f !== void 0, pe = fe ? f ?? "" : ue, me = y ?? de, he = me !== de;
|
|
7715
|
-
fe || he ? (
|
|
7715
|
+
fe || he ? (L.text = me ? wr({ value: pe }) : pe, o.textCaseRaw = pe) : o.textCaseRaw === void 0 && (o.textCaseRaw = ue), o.uppercase = me, o.set(L);
|
|
7716
7716
|
let ge = !1;
|
|
7717
|
-
if (
|
|
7718
|
-
let e =
|
|
7717
|
+
if (R) {
|
|
7718
|
+
let e = br({
|
|
7719
7719
|
textbox: o,
|
|
7720
|
-
styles:
|
|
7721
|
-
range:
|
|
7722
|
-
}), t =
|
|
7720
|
+
styles: z,
|
|
7721
|
+
range: R
|
|
7722
|
+
}), t = ae ? br({
|
|
7723
7723
|
textbox: o,
|
|
7724
|
-
styles:
|
|
7725
|
-
range:
|
|
7724
|
+
styles: oe,
|
|
7725
|
+
range: ae
|
|
7726
7726
|
}) : !1;
|
|
7727
7727
|
ge = e || t;
|
|
7728
|
-
} else if (Object.keys(
|
|
7729
|
-
let e =
|
|
7730
|
-
e && (ge =
|
|
7728
|
+
} else if (Object.keys(B).length) {
|
|
7729
|
+
let e = vr({ textbox: o });
|
|
7730
|
+
e && (ge = br({
|
|
7731
7731
|
textbox: o,
|
|
7732
|
-
styles:
|
|
7732
|
+
styles: B,
|
|
7733
7733
|
range: e
|
|
7734
7734
|
}));
|
|
7735
7735
|
}
|
|
7736
|
-
let _e = ge &&
|
|
7737
|
-
|
|
7738
|
-
|
|
7739
|
-
|
|
7736
|
+
let _e = ge && Ir({ stylesList: [
|
|
7737
|
+
z,
|
|
7738
|
+
oe,
|
|
7739
|
+
B
|
|
7740
7740
|
] });
|
|
7741
|
-
if (ge && (o.dirty = !0),
|
|
7742
|
-
let e =
|
|
7741
|
+
if (ge && (o.dirty = !0), ae && (m !== void 0 || h !== void 0)) {
|
|
7742
|
+
let e = Zr({
|
|
7743
7743
|
textbox: o,
|
|
7744
|
-
range:
|
|
7744
|
+
range: ae
|
|
7745
7745
|
}), t = {};
|
|
7746
|
-
m !== void 0 && (t.fontFamily = m), h !== void 0 && (t.fontSize = h),
|
|
7746
|
+
m !== void 0 && (t.fontFamily = m), h !== void 0 && (t.fontSize = h), kr({
|
|
7747
7747
|
textbox: o,
|
|
7748
7748
|
lineIndices: e,
|
|
7749
7749
|
updates: t
|
|
7750
7750
|
});
|
|
7751
7751
|
}
|
|
7752
|
-
if (
|
|
7753
|
-
let e =
|
|
7752
|
+
if (R && (S !== void 0 || C !== void 0 || w !== void 0)) {
|
|
7753
|
+
let e = Qr({
|
|
7754
7754
|
textbox: o,
|
|
7755
|
-
range:
|
|
7755
|
+
range: R
|
|
7756
7756
|
}), t = {};
|
|
7757
|
-
S !== void 0 && (t.fill = S), (C !== void 0 || w !== void 0) && (
|
|
7757
|
+
S !== void 0 && (t.fill = S), (C !== void 0 || w !== void 0) && (se === null && (t.stroke = null), se != null && (t.stroke = se)), kr({
|
|
7758
7758
|
textbox: o,
|
|
7759
7759
|
lineIndices: e,
|
|
7760
7760
|
updates: t
|
|
7761
7761
|
});
|
|
7762
7762
|
}
|
|
7763
7763
|
_e && (o.initDimensions(), o.dirty = !0), (E !== void 0 || D !== void 0 || O !== void 0 || k !== void 0 || A !== void 0 || j !== void 0 || M !== void 0 || N !== void 0 || P !== void 0 || F !== void 0) && (o.dirty = !0);
|
|
7764
|
-
let ve =
|
|
7765
|
-
|
|
7766
|
-
|
|
7767
|
-
|
|
7768
|
-
|
|
7769
|
-
] }), { autoExpand: ye } = o, be = p !== void 0, xe = Object.prototype.hasOwnProperty.call(
|
|
7764
|
+
let ve = Ir({ stylesList: [
|
|
7765
|
+
L,
|
|
7766
|
+
z,
|
|
7767
|
+
oe,
|
|
7768
|
+
B
|
|
7769
|
+
] }), { autoExpand: ye } = o, be = p !== void 0, xe = Object.prototype.hasOwnProperty.call(L, "width"), Se = (p ?? ye) !== !1;
|
|
7770
7770
|
be ? o.autoExpand = p !== !1 : ye === void 0 && (o.autoExpand = !0);
|
|
7771
7771
|
let Ce = Se && !xe && (fe || he || ve);
|
|
7772
7772
|
this._normalizeTextboxAfterContentChange({
|
|
7773
7773
|
textbox: o,
|
|
7774
|
-
placement:
|
|
7774
|
+
placement: ie,
|
|
7775
7775
|
shouldAutoExpand: Ce
|
|
7776
7776
|
}), o.setCoords();
|
|
7777
7777
|
let we = {
|
|
7778
7778
|
withoutSave: !!r,
|
|
7779
7779
|
skipRender: !!i
|
|
7780
|
-
}, Te = !!
|
|
7780
|
+
}, Te = !!R && Object.keys(z).length > 0, Ee = {
|
|
7781
7781
|
textbox: o,
|
|
7782
7782
|
target: t,
|
|
7783
7783
|
style: n,
|
|
7784
7784
|
options: we,
|
|
7785
|
-
updates:
|
|
7786
|
-
selectionRange:
|
|
7787
|
-
selectionStyles: Te ?
|
|
7785
|
+
updates: L,
|
|
7786
|
+
selectionRange: R ?? void 0,
|
|
7787
|
+
selectionStyles: Te ? z : void 0
|
|
7788
7788
|
};
|
|
7789
7789
|
u.fire("editor:before:text-updated", Ee), i || u.requestRenderAll();
|
|
7790
7790
|
let De = e._getSnapshot(o);
|
|
@@ -7843,7 +7843,7 @@ var Kr = class {
|
|
|
7843
7843
|
clampToMontage: r
|
|
7844
7844
|
}));
|
|
7845
7845
|
let a = !1;
|
|
7846
|
-
i || (a =
|
|
7846
|
+
i || (a = Lr({ textbox: e }));
|
|
7847
7847
|
let o = !1;
|
|
7848
7848
|
return !i && t && (this.editor.canvasManager.applyObjectPlacement({
|
|
7849
7849
|
object: e,
|
|
@@ -7857,15 +7857,15 @@ var Kr = class {
|
|
|
7857
7857
|
_syncLineFontDefaultsOnTextChanged({ textbox: e }) {
|
|
7858
7858
|
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;
|
|
7859
7859
|
if (h !== 0 && n && Object.keys(n).length) {
|
|
7860
|
-
let e =
|
|
7860
|
+
let e = $r({
|
|
7861
7861
|
previous: d,
|
|
7862
7862
|
next: u
|
|
7863
|
-
}), t =
|
|
7863
|
+
}), t = ei({
|
|
7864
7864
|
text: d,
|
|
7865
7865
|
charIndex: e
|
|
7866
7866
|
});
|
|
7867
7867
|
if (h > 0) {
|
|
7868
|
-
let r =
|
|
7868
|
+
let r = ti({
|
|
7869
7869
|
text: d,
|
|
7870
7870
|
lineIndex: t
|
|
7871
7871
|
}), i = t + 1;
|
|
@@ -7906,7 +7906,7 @@ var Kr = class {
|
|
|
7906
7906
|
let t = p[e] ?? "", n = g ? g[e] : void 0;
|
|
7907
7907
|
if (n && (T = n), t.length !== 0) {
|
|
7908
7908
|
if (n) {
|
|
7909
|
-
let r =
|
|
7909
|
+
let r = Ar({
|
|
7910
7910
|
lineText: t,
|
|
7911
7911
|
lineStyles: S ? S[e] : void 0,
|
|
7912
7912
|
lineDefaults: n
|
|
@@ -7946,16 +7946,16 @@ var Kr = class {
|
|
|
7946
7946
|
if (!Number.isFinite(f) || f <= 0) return !1;
|
|
7947
7947
|
let p = a.split("\n").length, m = !1;
|
|
7948
7948
|
Math.abs((e.width ?? 0) - f) > .01 && (e.set({ width: f }), m = !0), e.initDimensions();
|
|
7949
|
-
let { textLines: h } = e, g = Array.isArray(h) && h.length > p, _ = Math.ceil(
|
|
7949
|
+
let { textLines: h } = e, g = Array.isArray(h) && h.length > p, _ = Math.ceil(Nr({
|
|
7950
7950
|
textbox: e,
|
|
7951
7951
|
text: a
|
|
7952
7952
|
})), v = Math.min(e.minWidth ?? 1, f), y = Math.min(f, Math.max(_, v));
|
|
7953
|
-
g && (y = f), Math.abs((e.width ?? 0) - y) > .01 && (e.set({ width: y }), e.initDimensions(), m = !0),
|
|
7953
|
+
g && (y = f), Math.abs((e.width ?? 0) - y) > .01 && (e.set({ width: y }), e.initDimensions(), m = !0), Lr({ textbox: e }) && (m = !0), t && r.applyObjectPlacement({
|
|
7954
7954
|
object: e,
|
|
7955
7955
|
placement: t
|
|
7956
7956
|
});
|
|
7957
7957
|
let b = !1;
|
|
7958
|
-
return n && (b =
|
|
7958
|
+
return n && (b = Pr({
|
|
7959
7959
|
textbox: e,
|
|
7960
7960
|
montageLeft: o,
|
|
7961
7961
|
montageRight: o + s
|
|
@@ -8013,7 +8013,7 @@ var Kr = class {
|
|
|
8013
8013
|
_getDefaultFontFamily() {
|
|
8014
8014
|
return this.fonts[0]?.family ?? "Arial";
|
|
8015
8015
|
}
|
|
8016
|
-
},
|
|
8016
|
+
}, ri = ({ x1: e, y1: t, x2: n, y2: r }) => (Math.atan2(r - t, n - e) * 180 / Math.PI + 360) % 360, ii = (e) => {
|
|
8017
8017
|
if (!e || typeof e != "object") return null;
|
|
8018
8018
|
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) => ({
|
|
8019
8019
|
color: typeof e.color == "string" ? e.color : "#000000",
|
|
@@ -8024,7 +8024,7 @@ var Kr = class {
|
|
|
8024
8024
|
let { x1: e, y1: t, x2: r, y2: i } = n;
|
|
8025
8025
|
if (typeof e == "number" && typeof t == "number" && typeof r == "number" && typeof i == "number") return {
|
|
8026
8026
|
type: "linear",
|
|
8027
|
-
angle:
|
|
8027
|
+
angle: ri({
|
|
8028
8028
|
x1: e,
|
|
8029
8029
|
y1: t,
|
|
8030
8030
|
x2: r,
|
|
@@ -8052,7 +8052,7 @@ var Kr = class {
|
|
|
8052
8052
|
};
|
|
8053
8053
|
}
|
|
8054
8054
|
return null;
|
|
8055
|
-
},
|
|
8055
|
+
}, ai = "_templateAnchorX", oi = "_templateAnchorY", si = class t {
|
|
8056
8056
|
constructor({ editor: e }) {
|
|
8057
8057
|
this.editor = e;
|
|
8058
8058
|
}
|
|
@@ -8061,7 +8061,7 @@ var Kr = class {
|
|
|
8061
8061
|
if (!p.length) return s.emitWarning({
|
|
8062
8062
|
origin: "TemplateManager",
|
|
8063
8063
|
method: "serializeSelection",
|
|
8064
|
-
code:
|
|
8064
|
+
code: mr.TEMPLATE_MANAGER.NO_OBJECTS_SELECTED,
|
|
8065
8065
|
message: "Нет объектов для сериализации шаблона"
|
|
8066
8066
|
}), null;
|
|
8067
8067
|
let m = t._getBounds(o), h = t._getMontageSize({
|
|
@@ -8090,14 +8090,14 @@ var Kr = class {
|
|
|
8090
8090
|
if (!s?.length) return a.emitWarning({
|
|
8091
8091
|
origin: "TemplateManager",
|
|
8092
8092
|
method: "applyTemplate",
|
|
8093
|
-
code:
|
|
8093
|
+
code: mr.TEMPLATE_MANAGER.INVALID_TEMPLATE,
|
|
8094
8094
|
message: "Шаблон не содержит объектов"
|
|
8095
8095
|
}), null;
|
|
8096
8096
|
let u = t._getBounds(r);
|
|
8097
8097
|
if (!u) return a.emitWarning({
|
|
8098
8098
|
origin: "TemplateManager",
|
|
8099
8099
|
method: "applyTemplate",
|
|
8100
|
-
code:
|
|
8100
|
+
code: mr.TEMPLATE_MANAGER.INVALID_TARGET,
|
|
8101
8101
|
message: "Не удалось определить границы монтажной области"
|
|
8102
8102
|
}), null;
|
|
8103
8103
|
let d = t._getMontageSize({
|
|
@@ -8116,7 +8116,7 @@ var Kr = class {
|
|
|
8116
8116
|
if (!r.length) return a.emitWarning({
|
|
8117
8117
|
origin: "TemplateManager",
|
|
8118
8118
|
method: "applyTemplate",
|
|
8119
|
-
code:
|
|
8119
|
+
code: mr.TEMPLATE_MANAGER.INVALID_TEMPLATE,
|
|
8120
8120
|
message: "Не удалось создать объекты шаблона"
|
|
8121
8121
|
}), null;
|
|
8122
8122
|
let { backgroundObject: i, contentObjects: c } = t._extractBackgroundObject(r);
|
|
@@ -8151,7 +8151,7 @@ var Kr = class {
|
|
|
8151
8151
|
return a.emitError({
|
|
8152
8152
|
origin: "TemplateManager",
|
|
8153
8153
|
method: "applyTemplate",
|
|
8154
|
-
code:
|
|
8154
|
+
code: mr.TEMPLATE_MANAGER.APPLY_FAILED,
|
|
8155
8155
|
message: "Ошибка применения шаблона",
|
|
8156
8156
|
data: {
|
|
8157
8157
|
templateId: l,
|
|
@@ -8305,8 +8305,8 @@ var Kr = class {
|
|
|
8305
8305
|
baseHeight: a,
|
|
8306
8306
|
scale: n,
|
|
8307
8307
|
useRelativePositions: o,
|
|
8308
|
-
anchorX: t._resolveAnchor(s,
|
|
8309
|
-
anchorY: t._resolveAnchor(s,
|
|
8308
|
+
anchorX: t._resolveAnchor(s, ai),
|
|
8309
|
+
anchorY: t._resolveAnchor(s, oi)
|
|
8310
8310
|
})
|
|
8311
8311
|
}), h = f * n, g = p * n, _ = e.originX ?? "center", v = e.originY ?? "center";
|
|
8312
8312
|
e.set({
|
|
@@ -8320,7 +8320,7 @@ var Kr = class {
|
|
|
8320
8320
|
originX: _,
|
|
8321
8321
|
originY: v
|
|
8322
8322
|
}
|
|
8323
|
-
}), delete s[
|
|
8323
|
+
}), delete s[ai], delete s[oi];
|
|
8324
8324
|
}
|
|
8325
8325
|
static _getPositioningBounds({ bounds: e, baseWidth: n, baseHeight: r, scale: i, useRelativePositions: a, anchorX: o, anchorY: s }) {
|
|
8326
8326
|
if (!a) return e;
|
|
@@ -8384,7 +8384,7 @@ var Kr = class {
|
|
|
8384
8384
|
});
|
|
8385
8385
|
if (!i || !s || !o) return;
|
|
8386
8386
|
e.setCoords();
|
|
8387
|
-
let c = e, l = t._resolveAnchor(c,
|
|
8387
|
+
let c = e, l = t._resolveAnchor(c, ai), 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;
|
|
8388
8388
|
e.set("width", i), e.initDimensions();
|
|
8389
8389
|
let g = t._getLongestLineWidth({
|
|
8390
8390
|
textbox: e,
|
|
@@ -8403,7 +8403,7 @@ var Kr = class {
|
|
|
8403
8403
|
return i;
|
|
8404
8404
|
}
|
|
8405
8405
|
_serializeObject({ object: e, bounds: n, baseWidth: r, baseHeight: i }) {
|
|
8406
|
-
let a = e.toDatalessObject([...
|
|
8406
|
+
let a = e.toDatalessObject([...le]);
|
|
8407
8407
|
if (t._isSvgObject(e)) {
|
|
8408
8408
|
let n = t._extractSvgMarkup(e);
|
|
8409
8409
|
n && (a.svgMarkup = n, delete a.objects, delete a.path);
|
|
@@ -8413,10 +8413,10 @@ var Kr = class {
|
|
|
8413
8413
|
x: (p.left - o) / d,
|
|
8414
8414
|
y: (p.top - s) / f
|
|
8415
8415
|
}, h = (u.left - o) / d, g = (u.top - s) / f, _ = h + u.width / d, v = g + u.height / f;
|
|
8416
|
-
return a[
|
|
8416
|
+
return a[ai] = t._detectAnchor({
|
|
8417
8417
|
start: h,
|
|
8418
8418
|
end: _
|
|
8419
|
-
}), a[
|
|
8419
|
+
}), a[oi] = t._detectAnchor({
|
|
8420
8420
|
start: g,
|
|
8421
8421
|
end: v
|
|
8422
8422
|
}), a.left = m.x, a.top = m.y, a;
|
|
@@ -8441,7 +8441,7 @@ var Kr = class {
|
|
|
8441
8441
|
withoutSave: !0
|
|
8442
8442
|
}), !0;
|
|
8443
8443
|
if (a === "gradient") {
|
|
8444
|
-
let e =
|
|
8444
|
+
let e = ii(r);
|
|
8445
8445
|
if (e) return n.setGradientBackground({
|
|
8446
8446
|
gradient: e,
|
|
8447
8447
|
customData: o,
|
|
@@ -8462,7 +8462,7 @@ var Kr = class {
|
|
|
8462
8462
|
r.emitWarning({
|
|
8463
8463
|
origin: "TemplateManager",
|
|
8464
8464
|
method: "applyTemplate",
|
|
8465
|
-
code:
|
|
8465
|
+
code: mr.TEMPLATE_MANAGER.APPLY_FAILED,
|
|
8466
8466
|
message: "Не удалось применить фон из шаблона",
|
|
8467
8467
|
data: e
|
|
8468
8468
|
});
|
|
@@ -8498,29 +8498,29 @@ var Kr = class {
|
|
|
8498
8498
|
enlivenObjectEnlivables(e) {
|
|
8499
8499
|
return C.enlivenObjectEnlivables(e);
|
|
8500
8500
|
}
|
|
8501
|
-
},
|
|
8502
|
-
let n =
|
|
8501
|
+
}, ci = "#3D8BF4", li = .5, ui = ({ distance: e }) => Number.isFinite(e) ? Math.round(Math.max(0, e)) : 0, di = ({ firstDistance: e, secondDistance: t }) => {
|
|
8502
|
+
let n = ui({ distance: e }), r = ui({ distance: t });
|
|
8503
8503
|
return {
|
|
8504
8504
|
firstDisplayDistance: n,
|
|
8505
8505
|
secondDisplayDistance: r,
|
|
8506
8506
|
displayDistanceDiff: Math.abs(n - r),
|
|
8507
8507
|
commonDisplayDistance: Math.max(n, r)
|
|
8508
8508
|
};
|
|
8509
|
-
},
|
|
8509
|
+
}, fi = ({ firstStart: e, firstEnd: t, secondStart: n, secondEnd: r }) => Math.min(t, r) - Math.max(e, n), pi = ({ step: e }) => {
|
|
8510
8510
|
let t = Math.abs(e).toString(), n = t.indexOf(".");
|
|
8511
8511
|
return n === -1 ? 0 : t.slice(n + 1).length;
|
|
8512
|
-
},
|
|
8512
|
+
}, mi = ({ value: e, step: t }) => {
|
|
8513
8513
|
if (t === 0) return e;
|
|
8514
|
-
let n =
|
|
8514
|
+
let n = pi({ step: t }), r = Math.round(e / t) * t;
|
|
8515
8515
|
return Number(r.toFixed(n));
|
|
8516
|
-
},
|
|
8516
|
+
}, hi = ({ value: e, step: t }) => {
|
|
8517
8517
|
if (t === 0) return !0;
|
|
8518
|
-
let n =
|
|
8518
|
+
let n = mi({
|
|
8519
8519
|
value: e,
|
|
8520
8520
|
step: t
|
|
8521
|
-
}), r = 10 ** -(
|
|
8521
|
+
}), r = 10 ** -(pi({ step: t }) + 4);
|
|
8522
8522
|
return Math.abs(n - e) <= r;
|
|
8523
|
-
},
|
|
8523
|
+
}, gi = ({ bounds: e, axis: t }) => {
|
|
8524
8524
|
let { left: n = 0, right: r = 0, top: i = 0, bottom: a = 0 } = e;
|
|
8525
8525
|
return t === "vertical" ? {
|
|
8526
8526
|
start: i,
|
|
@@ -8529,7 +8529,7 @@ var Kr = class {
|
|
|
8529
8529
|
start: n,
|
|
8530
8530
|
end: r
|
|
8531
8531
|
};
|
|
8532
|
-
},
|
|
8532
|
+
}, _i = ({ items: e, axis: t }) => {
|
|
8533
8533
|
for (let n = 1; n < e.length; n += 1) {
|
|
8534
8534
|
let r = e[n], { bounds: i } = r, a = i[t], o = n - 1;
|
|
8535
8535
|
for (; o >= 0;) {
|
|
@@ -8539,10 +8539,10 @@ var Kr = class {
|
|
|
8539
8539
|
}
|
|
8540
8540
|
e[o + 1] = r;
|
|
8541
8541
|
}
|
|
8542
|
-
},
|
|
8542
|
+
}, vi = ({ items: e, index: t, axis: n, direction: r }) => {
|
|
8543
8543
|
let i = e[t];
|
|
8544
8544
|
if (!i) return null;
|
|
8545
|
-
let { bounds: a } = i, { start: o, end: s } =
|
|
8545
|
+
let { bounds: a } = i, { start: o, end: s } = gi({
|
|
8546
8546
|
bounds: a,
|
|
8547
8547
|
axis: n
|
|
8548
8548
|
});
|
|
@@ -8550,7 +8550,7 @@ var Kr = class {
|
|
|
8550
8550
|
for (let r = t - 1; r >= 0; --r) {
|
|
8551
8551
|
let t = e[r];
|
|
8552
8552
|
if (!t) continue;
|
|
8553
|
-
let { bounds: i } = t, { end: a } =
|
|
8553
|
+
let { bounds: i } = t, { end: a } = gi({
|
|
8554
8554
|
bounds: i,
|
|
8555
8555
|
axis: n
|
|
8556
8556
|
});
|
|
@@ -8561,26 +8561,26 @@ var Kr = class {
|
|
|
8561
8561
|
for (let r = t + 1; r < e.length; r += 1) {
|
|
8562
8562
|
let t = e[r];
|
|
8563
8563
|
if (!t) continue;
|
|
8564
|
-
let { bounds: i } = t, { start: a } =
|
|
8564
|
+
let { bounds: i } = t, { start: a } = gi({
|
|
8565
8565
|
bounds: i,
|
|
8566
8566
|
axis: n
|
|
8567
8567
|
});
|
|
8568
8568
|
if (a - s >= 0) return r;
|
|
8569
8569
|
}
|
|
8570
8570
|
return null;
|
|
8571
|
-
},
|
|
8571
|
+
}, yi = ({ items: e }) => {
|
|
8572
8572
|
for (let t = 0; t < e.length; t += 1) {
|
|
8573
8573
|
let { isActive: n } = e[t];
|
|
8574
8574
|
if (n) return t;
|
|
8575
8575
|
}
|
|
8576
8576
|
return -1;
|
|
8577
|
-
},
|
|
8577
|
+
}, bi = ({ patternAxis: e, activeRangeStart: t, activeRangeEnd: n, tolerance: r = 0 }) => {
|
|
8578
8578
|
let i = Math.min(t, n), a = Math.max(t, n);
|
|
8579
8579
|
return e >= i - r && e <= a + r;
|
|
8580
|
-
},
|
|
8580
|
+
}, xi = ({ patternStart: e, patternEnd: t, activeStart: n, activeEnd: r }) => t <= n ? "before" : e >= r ? "after" : null, Si = ({ baseOption: e, candidateOption: t }) => {
|
|
8581
8581
|
let { delta: n, guide: { distance: r } } = e, { delta: i, guide: { distance: a } } = t;
|
|
8582
8582
|
return n === i && r === a;
|
|
8583
|
-
},
|
|
8583
|
+
}, Ci = ({ options: e }) => {
|
|
8584
8584
|
let t = e[0];
|
|
8585
8585
|
for (let n = 1; n < e.length; n += 1) {
|
|
8586
8586
|
let r = e[n];
|
|
@@ -8591,11 +8591,11 @@ var Kr = class {
|
|
|
8591
8591
|
r.diff === t.diff && Math.abs(r.delta) < Math.abs(t.delta) && (t = r);
|
|
8592
8592
|
}
|
|
8593
8593
|
return t;
|
|
8594
|
-
},
|
|
8594
|
+
}, wi = ({ currentOption: e, nextOption: t }) => {
|
|
8595
8595
|
if (!e) return !0;
|
|
8596
8596
|
let { contextDistance: n, diff: r, delta: i } = e, { contextDistance: a, diff: o, delta: s } = t;
|
|
8597
8597
|
return a < n ? !0 : a > n ? !1 : o < r ? !0 : o > r ? !1 : Math.abs(s) < Math.abs(i);
|
|
8598
|
-
},
|
|
8598
|
+
}, Ti = ({ options: e }) => {
|
|
8599
8599
|
let t = [], n = null, r = null;
|
|
8600
8600
|
for (let i of e) {
|
|
8601
8601
|
let { kind: e, side: a } = i;
|
|
@@ -8603,18 +8603,18 @@ var Kr = class {
|
|
|
8603
8603
|
t.push(i);
|
|
8604
8604
|
continue;
|
|
8605
8605
|
}
|
|
8606
|
-
a === "before" &&
|
|
8606
|
+
a === "before" && wi({
|
|
8607
8607
|
currentOption: n,
|
|
8608
8608
|
nextOption: i
|
|
8609
|
-
}) && (n = i), a === "after" &&
|
|
8609
|
+
}) && (n = i), a === "after" && wi({
|
|
8610
8610
|
currentOption: r,
|
|
8611
8611
|
nextOption: i
|
|
8612
8612
|
}) && (r = i);
|
|
8613
8613
|
}
|
|
8614
8614
|
return n && t.push(n), r && t.push(r), t;
|
|
8615
|
-
},
|
|
8615
|
+
}, Ei = ({ options: e, side: t, baseOption: n }) => {
|
|
8616
8616
|
let r = null;
|
|
8617
|
-
for (let i of e) if (i.side === t &&
|
|
8617
|
+
for (let i of e) if (i.side === t && Si({
|
|
8618
8618
|
baseOption: n,
|
|
8619
8619
|
candidateOption: i
|
|
8620
8620
|
})) {
|
|
@@ -8625,63 +8625,63 @@ var Kr = class {
|
|
|
8625
8625
|
!r || i.diff !== r.diff || Math.abs(i.delta) < Math.abs(r.delta) && (r = i);
|
|
8626
8626
|
}
|
|
8627
8627
|
return r;
|
|
8628
|
-
},
|
|
8628
|
+
}, Di = ({ option: e }) => {
|
|
8629
8629
|
let { side: t, kind: n, guide: { distance: r } } = e;
|
|
8630
8630
|
return {
|
|
8631
8631
|
side: t,
|
|
8632
8632
|
kind: n,
|
|
8633
8633
|
distance: r
|
|
8634
8634
|
};
|
|
8635
|
-
},
|
|
8635
|
+
}, Oi = ({ option: e, context: t }) => {
|
|
8636
8636
|
let { side: n, kind: r, distance: i } = t, { side: a, kind: o, guide: { distance: s } } = e;
|
|
8637
8637
|
return n !== a || r !== o ? !1 : Math.abs(s - i) <= 1;
|
|
8638
|
-
},
|
|
8638
|
+
}, ki = ({ options: e, context: t }) => {
|
|
8639
8639
|
if (!t) return null;
|
|
8640
|
-
for (let n of e) if (
|
|
8640
|
+
for (let n of e) if (Oi({
|
|
8641
8641
|
option: n,
|
|
8642
8642
|
context: t
|
|
8643
8643
|
})) return n;
|
|
8644
8644
|
return null;
|
|
8645
|
-
},
|
|
8646
|
-
let i =
|
|
8645
|
+
}, Ai = ({ options: e, bestOption: t, previousContext: n, switchDistance: r = 0 }) => {
|
|
8646
|
+
let i = ki({
|
|
8647
8647
|
options: e,
|
|
8648
8648
|
context: n
|
|
8649
8649
|
});
|
|
8650
8650
|
if (!i) return t;
|
|
8651
8651
|
let a = Math.max(0, r);
|
|
8652
8652
|
return a === 0 || Math.abs(t.delta - i.delta) >= a ? t : i;
|
|
8653
|
-
},
|
|
8653
|
+
}, ji = ({ guides: e, seenGuideKeys: t, guide: n }) => {
|
|
8654
8654
|
let { type: r, axis: i, refStart: a, refEnd: o, activeStart: s, activeEnd: c, distance: l } = n, u = `${r}:${i}:${a}:${o}:${s}:${c}:${l}`;
|
|
8655
8655
|
t.has(u) || (t.add(u), e.push(n));
|
|
8656
|
-
},
|
|
8656
|
+
}, Mi = ({ options: e, previousContext: t = null, switchDistance: n = 0 }) => {
|
|
8657
8657
|
if (!e.length) return {
|
|
8658
8658
|
delta: 0,
|
|
8659
8659
|
guides: [],
|
|
8660
8660
|
context: null
|
|
8661
8661
|
};
|
|
8662
|
-
let r =
|
|
8662
|
+
let r = Ti({ options: e }), i = [];
|
|
8663
8663
|
for (let e of r) e.kind === "reference" && i.push(e);
|
|
8664
|
-
let a = i.length > 0, o = a ? i : r, s =
|
|
8664
|
+
let a = i.length > 0, o = a ? i : r, s = Ai({
|
|
8665
8665
|
options: o,
|
|
8666
|
-
bestOption:
|
|
8666
|
+
bestOption: Ci({ options: o }),
|
|
8667
8667
|
previousContext: t,
|
|
8668
8668
|
switchDistance: n
|
|
8669
|
-
}), c =
|
|
8669
|
+
}), c = Ei({
|
|
8670
8670
|
options: o,
|
|
8671
8671
|
side: "before",
|
|
8672
8672
|
baseOption: s
|
|
8673
|
-
}), l =
|
|
8673
|
+
}), l = Ei({
|
|
8674
8674
|
options: o,
|
|
8675
8675
|
side: "after",
|
|
8676
8676
|
baseOption: s
|
|
8677
|
-
}), u =
|
|
8677
|
+
}), u = Ei({
|
|
8678
8678
|
options: a ? r : o,
|
|
8679
8679
|
side: "center",
|
|
8680
8680
|
baseOption: s
|
|
8681
8681
|
}), d = [];
|
|
8682
8682
|
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);
|
|
8683
8683
|
let f = [], p = /* @__PURE__ */ new Set();
|
|
8684
|
-
for (let e of d)
|
|
8684
|
+
for (let e of d) ji({
|
|
8685
8685
|
guides: f,
|
|
8686
8686
|
seenGuideKeys: p,
|
|
8687
8687
|
guide: e.guide
|
|
@@ -8689,15 +8689,15 @@ var Kr = class {
|
|
|
8689
8689
|
return {
|
|
8690
8690
|
delta: s.delta,
|
|
8691
8691
|
guides: f,
|
|
8692
|
-
context:
|
|
8692
|
+
context: Di({ option: s })
|
|
8693
8693
|
};
|
|
8694
|
-
},
|
|
8695
|
-
let s = n - (e - r), c =
|
|
8694
|
+
}, Ni = ({ activeStart: e, activeEnd: t, targetGap: n, beforeEdge: r, afterEdge: i, threshold: a, step: o }) => {
|
|
8695
|
+
let s = n - (e - r), c = mi({
|
|
8696
8696
|
value: s,
|
|
8697
8697
|
step: o
|
|
8698
8698
|
}), l = Math.max(1, Math.ceil(a / Math.max(o, 1))), u = null;
|
|
8699
8699
|
for (let d = -l; d <= l; d += 1) {
|
|
8700
|
-
let l = c + d * o, f = e + l, p = t + l, m = f - r, h = i - p, { displayDistanceDiff: g, commonDisplayDistance: _ } =
|
|
8700
|
+
let l = c + d * o, f = e + l, p = t + l, m = f - r, h = i - p, { displayDistanceDiff: g, commonDisplayDistance: _ } = di({
|
|
8701
8701
|
firstDistance: m,
|
|
8702
8702
|
secondDistance: h
|
|
8703
8703
|
});
|
|
@@ -8712,13 +8712,13 @@ var Kr = class {
|
|
|
8712
8712
|
});
|
|
8713
8713
|
}
|
|
8714
8714
|
return u;
|
|
8715
|
-
},
|
|
8716
|
-
let { secondDisplayDistance: n, displayDistanceDiff: r } =
|
|
8715
|
+
}, Pi = ({ currentGap: e, referenceGap: t }) => {
|
|
8716
|
+
let { secondDisplayDistance: n, displayDistanceDiff: r } = di({
|
|
8717
8717
|
firstDistance: e,
|
|
8718
8718
|
secondDistance: t
|
|
8719
8719
|
});
|
|
8720
8720
|
return r > 1 ? null : n;
|
|
8721
|
-
},
|
|
8721
|
+
}, Fi = ({ anchors: e, positions: t, threshold: n }) => {
|
|
8722
8722
|
let r = 0, i = n + 1, a = null;
|
|
8723
8723
|
for (let o of t) for (let t of e) {
|
|
8724
8724
|
let e = Math.abs(t - o);
|
|
@@ -8728,8 +8728,8 @@ var Kr = class {
|
|
|
8728
8728
|
delta: r,
|
|
8729
8729
|
guidePosition: a
|
|
8730
8730
|
};
|
|
8731
|
-
},
|
|
8732
|
-
let { left: r, right: i, centerX: a, top: o, bottom: s, centerY: c } = e, l =
|
|
8731
|
+
}, Ii = ({ activeBounds: e, threshold: t, anchors: n }) => {
|
|
8732
|
+
let { left: r, right: i, centerX: a, top: o, bottom: s, centerY: c } = e, l = Fi({
|
|
8733
8733
|
anchors: n.vertical,
|
|
8734
8734
|
positions: [
|
|
8735
8735
|
r,
|
|
@@ -8737,7 +8737,7 @@ var Kr = class {
|
|
|
8737
8737
|
i
|
|
8738
8738
|
],
|
|
8739
8739
|
threshold: t
|
|
8740
|
-
}), u =
|
|
8740
|
+
}), u = Fi({
|
|
8741
8741
|
anchors: n.horizontal,
|
|
8742
8742
|
positions: [
|
|
8743
8743
|
o,
|
|
@@ -8757,11 +8757,11 @@ var Kr = class {
|
|
|
8757
8757
|
deltaY: u.delta,
|
|
8758
8758
|
guides: d
|
|
8759
8759
|
};
|
|
8760
|
-
},
|
|
8760
|
+
}, Li = ({ activeBounds: e, candidates: t, threshold: n, patterns: r, previousContext: i = null, switchDistance: a = 0 }) => {
|
|
8761
8761
|
let { centerX: o, top: s, bottom: c, left: l, right: u } = e, d = [];
|
|
8762
8762
|
for (let e of t) {
|
|
8763
8763
|
let { left: t, right: n } = e;
|
|
8764
|
-
|
|
8764
|
+
fi({
|
|
8765
8765
|
firstStart: t,
|
|
8766
8766
|
firstEnd: n,
|
|
8767
8767
|
secondStart: l,
|
|
@@ -8781,22 +8781,22 @@ var Kr = class {
|
|
|
8781
8781
|
f.push({
|
|
8782
8782
|
bounds: e,
|
|
8783
8783
|
isActive: !0
|
|
8784
|
-
}),
|
|
8784
|
+
}), _i({
|
|
8785
8785
|
items: f,
|
|
8786
8786
|
axis: "top"
|
|
8787
8787
|
});
|
|
8788
|
-
let p =
|
|
8788
|
+
let p = yi({ items: f });
|
|
8789
8789
|
if (p === -1) return {
|
|
8790
8790
|
delta: 0,
|
|
8791
8791
|
guides: [],
|
|
8792
8792
|
context: null
|
|
8793
8793
|
};
|
|
8794
|
-
let m = [], h = c - s, g =
|
|
8794
|
+
let m = [], h = c - s, g = vi({
|
|
8795
8795
|
items: f,
|
|
8796
8796
|
index: p,
|
|
8797
8797
|
axis: "vertical",
|
|
8798
8798
|
direction: "prev"
|
|
8799
|
-
}), _ =
|
|
8799
|
+
}), _ = vi({
|
|
8800
8800
|
items: f,
|
|
8801
8801
|
index: p,
|
|
8802
8802
|
axis: "vertical",
|
|
@@ -8805,19 +8805,19 @@ var Kr = class {
|
|
|
8805
8805
|
if (v && y) {
|
|
8806
8806
|
let { bounds: e } = v, { bounds: t } = y, { bottom: r } = e, { top: i } = t, a = i - r - h;
|
|
8807
8807
|
if (a >= 0) {
|
|
8808
|
-
let e =
|
|
8808
|
+
let e = mi({
|
|
8809
8809
|
value: a / 2,
|
|
8810
8810
|
step: 1
|
|
8811
8811
|
}), t = s - r, l = i - c, u = Math.abs(t - e), d = Math.abs(l - e);
|
|
8812
8812
|
if (Math.max(u, d) <= n) {
|
|
8813
|
-
let t =
|
|
8813
|
+
let t = Ni({
|
|
8814
8814
|
activeStart: s,
|
|
8815
8815
|
activeEnd: c,
|
|
8816
8816
|
targetGap: e,
|
|
8817
8817
|
beforeEdge: r,
|
|
8818
8818
|
afterEdge: i,
|
|
8819
8819
|
threshold: n,
|
|
8820
|
-
step:
|
|
8820
|
+
step: li
|
|
8821
8821
|
});
|
|
8822
8822
|
if (t) {
|
|
8823
8823
|
let { delta: e, distance: n, diff: i, activeStart: a, activeEnd: s } = t, c = {
|
|
@@ -8854,16 +8854,16 @@ var Kr = class {
|
|
|
8854
8854
|
}
|
|
8855
8855
|
for (let e of r) {
|
|
8856
8856
|
let { axis: t, start: r, end: i, distance: a } = e;
|
|
8857
|
-
if (!
|
|
8857
|
+
if (!hi({
|
|
8858
8858
|
value: a,
|
|
8859
8859
|
step: .5
|
|
8860
|
-
}) || !
|
|
8860
|
+
}) || !bi({
|
|
8861
8861
|
patternAxis: t,
|
|
8862
8862
|
activeRangeStart: l,
|
|
8863
8863
|
activeRangeEnd: u,
|
|
8864
8864
|
tolerance: n
|
|
8865
8865
|
})) continue;
|
|
8866
|
-
let d =
|
|
8866
|
+
let d = xi({
|
|
8867
8867
|
patternStart: r,
|
|
8868
8868
|
patternEnd: i,
|
|
8869
8869
|
activeStart: s,
|
|
@@ -8871,12 +8871,12 @@ var Kr = class {
|
|
|
8871
8871
|
});
|
|
8872
8872
|
if (d) {
|
|
8873
8873
|
if (b !== null && S && d === "before" && Math.abs(b - a) <= n) {
|
|
8874
|
-
let e =
|
|
8874
|
+
let e = mi({
|
|
8875
8875
|
value: a - b,
|
|
8876
8876
|
step: 1
|
|
8877
8877
|
}), t = s + e, { bottom: c } = S, l = t - c, u = Math.abs(l - a);
|
|
8878
8878
|
if (u > n) continue;
|
|
8879
|
-
let d =
|
|
8879
|
+
let d = Pi({
|
|
8880
8880
|
currentGap: l,
|
|
8881
8881
|
referenceGap: a
|
|
8882
8882
|
});
|
|
@@ -8900,12 +8900,12 @@ var Kr = class {
|
|
|
8900
8900
|
});
|
|
8901
8901
|
}
|
|
8902
8902
|
if (x !== null && C && d === "after" && Math.abs(x - a) <= n) {
|
|
8903
|
-
let e =
|
|
8903
|
+
let e = mi({
|
|
8904
8904
|
value: x - a,
|
|
8905
8905
|
step: 1
|
|
8906
8906
|
}), t = c + e, { top: s } = C, l = s - t, u = Math.abs(l - a);
|
|
8907
8907
|
if (u > n) continue;
|
|
8908
|
-
let d =
|
|
8908
|
+
let d = Pi({
|
|
8909
8909
|
currentGap: l,
|
|
8910
8910
|
referenceGap: a
|
|
8911
8911
|
});
|
|
@@ -8930,16 +8930,16 @@ var Kr = class {
|
|
|
8930
8930
|
}
|
|
8931
8931
|
}
|
|
8932
8932
|
}
|
|
8933
|
-
return
|
|
8933
|
+
return Mi({
|
|
8934
8934
|
options: m,
|
|
8935
8935
|
previousContext: i,
|
|
8936
8936
|
switchDistance: a
|
|
8937
8937
|
});
|
|
8938
|
-
},
|
|
8938
|
+
}, Ri = ({ activeBounds: e, candidates: t, threshold: n, patterns: r, previousContext: i = null, switchDistance: a = 0 }) => {
|
|
8939
8939
|
let { centerY: o, left: s, right: c, top: l, bottom: u } = e, d = [];
|
|
8940
8940
|
for (let e of t) {
|
|
8941
8941
|
let { top: t, bottom: n } = e;
|
|
8942
|
-
|
|
8942
|
+
fi({
|
|
8943
8943
|
firstStart: t,
|
|
8944
8944
|
firstEnd: n,
|
|
8945
8945
|
secondStart: l,
|
|
@@ -8959,22 +8959,22 @@ var Kr = class {
|
|
|
8959
8959
|
f.push({
|
|
8960
8960
|
bounds: e,
|
|
8961
8961
|
isActive: !0
|
|
8962
|
-
}),
|
|
8962
|
+
}), _i({
|
|
8963
8963
|
items: f,
|
|
8964
8964
|
axis: "left"
|
|
8965
8965
|
});
|
|
8966
|
-
let p =
|
|
8966
|
+
let p = yi({ items: f });
|
|
8967
8967
|
if (p === -1) return {
|
|
8968
8968
|
delta: 0,
|
|
8969
8969
|
guides: [],
|
|
8970
8970
|
context: null
|
|
8971
8971
|
};
|
|
8972
|
-
let m = [], h = c - s, g =
|
|
8972
|
+
let m = [], h = c - s, g = vi({
|
|
8973
8973
|
items: f,
|
|
8974
8974
|
index: p,
|
|
8975
8975
|
axis: "horizontal",
|
|
8976
8976
|
direction: "prev"
|
|
8977
|
-
}), _ =
|
|
8977
|
+
}), _ = vi({
|
|
8978
8978
|
items: f,
|
|
8979
8979
|
index: p,
|
|
8980
8980
|
axis: "horizontal",
|
|
@@ -8983,19 +8983,19 @@ var Kr = class {
|
|
|
8983
8983
|
if (v && y) {
|
|
8984
8984
|
let { bounds: e } = v, { bounds: t } = y, { right: r } = e, { left: i } = t, a = i - r - h;
|
|
8985
8985
|
if (a >= 0) {
|
|
8986
|
-
let e =
|
|
8986
|
+
let e = mi({
|
|
8987
8987
|
value: a / 2,
|
|
8988
8988
|
step: 1
|
|
8989
8989
|
}), t = s - r, l = i - c, u = Math.abs(t - e), d = Math.abs(l - e);
|
|
8990
8990
|
if (Math.max(u, d) <= n) {
|
|
8991
|
-
let t =
|
|
8991
|
+
let t = Ni({
|
|
8992
8992
|
activeStart: s,
|
|
8993
8993
|
activeEnd: c,
|
|
8994
8994
|
targetGap: e,
|
|
8995
8995
|
beforeEdge: r,
|
|
8996
8996
|
afterEdge: i,
|
|
8997
8997
|
threshold: n,
|
|
8998
|
-
step:
|
|
8998
|
+
step: li
|
|
8999
8999
|
});
|
|
9000
9000
|
if (t) {
|
|
9001
9001
|
let { delta: e, distance: n, diff: i, activeStart: a, activeEnd: s } = t, c = {
|
|
@@ -9032,16 +9032,16 @@ var Kr = class {
|
|
|
9032
9032
|
}
|
|
9033
9033
|
for (let e of r) {
|
|
9034
9034
|
let { axis: t, start: r, end: i, distance: a } = e;
|
|
9035
|
-
if (!
|
|
9035
|
+
if (!hi({
|
|
9036
9036
|
value: a,
|
|
9037
9037
|
step: .5
|
|
9038
|
-
}) || !
|
|
9038
|
+
}) || !bi({
|
|
9039
9039
|
patternAxis: t,
|
|
9040
9040
|
activeRangeStart: l,
|
|
9041
9041
|
activeRangeEnd: u,
|
|
9042
9042
|
tolerance: n
|
|
9043
9043
|
})) continue;
|
|
9044
|
-
let d =
|
|
9044
|
+
let d = xi({
|
|
9045
9045
|
patternStart: r,
|
|
9046
9046
|
patternEnd: i,
|
|
9047
9047
|
activeStart: s,
|
|
@@ -9049,12 +9049,12 @@ var Kr = class {
|
|
|
9049
9049
|
});
|
|
9050
9050
|
if (d) {
|
|
9051
9051
|
if (b !== null && S && d === "before" && Math.abs(b - a) <= n) {
|
|
9052
|
-
let e =
|
|
9052
|
+
let e = mi({
|
|
9053
9053
|
value: a - b,
|
|
9054
9054
|
step: 1
|
|
9055
9055
|
}), t = s + e, { right: c } = S, l = t - c, u = Math.abs(l - a);
|
|
9056
9056
|
if (u > n) continue;
|
|
9057
|
-
let d =
|
|
9057
|
+
let d = Pi({
|
|
9058
9058
|
currentGap: l,
|
|
9059
9059
|
referenceGap: a
|
|
9060
9060
|
});
|
|
@@ -9078,12 +9078,12 @@ var Kr = class {
|
|
|
9078
9078
|
});
|
|
9079
9079
|
}
|
|
9080
9080
|
if (x !== null && C && d === "after" && Math.abs(x - a) <= n) {
|
|
9081
|
-
let e =
|
|
9081
|
+
let e = mi({
|
|
9082
9082
|
value: x - a,
|
|
9083
9083
|
step: 1
|
|
9084
9084
|
}), t = c + e, { left: s } = C, l = s - t, u = Math.abs(l - a);
|
|
9085
9085
|
if (u > n) continue;
|
|
9086
|
-
let d =
|
|
9086
|
+
let d = Pi({
|
|
9087
9087
|
currentGap: l,
|
|
9088
9088
|
referenceGap: a
|
|
9089
9089
|
});
|
|
@@ -9108,20 +9108,20 @@ var Kr = class {
|
|
|
9108
9108
|
}
|
|
9109
9109
|
}
|
|
9110
9110
|
}
|
|
9111
|
-
return
|
|
9111
|
+
return Mi({
|
|
9112
9112
|
options: m,
|
|
9113
9113
|
previousContext: i,
|
|
9114
9114
|
switchDistance: a
|
|
9115
9115
|
});
|
|
9116
|
-
},
|
|
9117
|
-
let { vertical: o = null, horizontal: s = null } = i ?? {}, c =
|
|
9116
|
+
}, zi = ({ activeBounds: e, candidates: t, threshold: n, spacingPatterns: r, previousContexts: i, switchDistance: a = 0 }) => {
|
|
9117
|
+
let { vertical: o = null, horizontal: s = null } = i ?? {}, c = Li({
|
|
9118
9118
|
activeBounds: e,
|
|
9119
9119
|
candidates: t,
|
|
9120
9120
|
threshold: n,
|
|
9121
9121
|
patterns: r.vertical,
|
|
9122
9122
|
previousContext: o,
|
|
9123
9123
|
switchDistance: a
|
|
9124
|
-
}), l =
|
|
9124
|
+
}), l = Ri({
|
|
9125
9125
|
activeBounds: e,
|
|
9126
9126
|
candidates: t,
|
|
9127
9127
|
threshold: n,
|
|
@@ -9140,14 +9140,14 @@ var Kr = class {
|
|
|
9140
9140
|
horizontal: l.context
|
|
9141
9141
|
}
|
|
9142
9142
|
};
|
|
9143
|
-
},
|
|
9143
|
+
}, Bi = ({ context: e, x: t, y: n, width: r, height: i, radius: a }) => {
|
|
9144
9144
|
let o = Math.min(a, r / 2, i / 2);
|
|
9145
9145
|
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();
|
|
9146
|
-
},
|
|
9146
|
+
}, Vi = ({ 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 }) => {
|
|
9147
9147
|
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;
|
|
9148
9148
|
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";
|
|
9149
9149
|
let S = e.measureText(a).width + _ * 2, C = g + _ * 2, w = b - S / 2, T = x - C / 2;
|
|
9150
|
-
e.beginPath(),
|
|
9150
|
+
e.beginPath(), Bi({
|
|
9151
9151
|
context: e,
|
|
9152
9152
|
x: w,
|
|
9153
9153
|
y: T,
|
|
@@ -9155,11 +9155,11 @@ var Kr = class {
|
|
|
9155
9155
|
height: C,
|
|
9156
9156
|
radius: v
|
|
9157
9157
|
}), e.fill(), e.fillStyle = c, e.fillText(a, b, x), e.restore();
|
|
9158
|
-
},
|
|
9159
|
-
let { type: r, axis: i, refStart: a, refEnd: o, activeStart: s, activeEnd: c, distance: l } = t, u =
|
|
9158
|
+
}, Hi = ({ context: e, guide: t, zoom: n }) => {
|
|
9159
|
+
let { type: r, axis: i, refStart: a, refEnd: o, activeStart: s, activeEnd: c, distance: l } = t, u = ui({ distance: l }).toString();
|
|
9160
9160
|
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();
|
|
9161
|
-
let d =
|
|
9162
|
-
|
|
9161
|
+
let d = ci;
|
|
9162
|
+
Vi({
|
|
9163
9163
|
context: e,
|
|
9164
9164
|
type: r,
|
|
9165
9165
|
axis: i,
|
|
@@ -9169,7 +9169,7 @@ var Kr = class {
|
|
|
9169
9169
|
zoom: n,
|
|
9170
9170
|
color: d,
|
|
9171
9171
|
lineWidth: 1
|
|
9172
|
-
}),
|
|
9172
|
+
}), Vi({
|
|
9173
9173
|
context: e,
|
|
9174
9174
|
type: r,
|
|
9175
9175
|
axis: i,
|
|
@@ -9180,10 +9180,10 @@ var Kr = class {
|
|
|
9180
9180
|
color: d,
|
|
9181
9181
|
lineWidth: 1
|
|
9182
9182
|
});
|
|
9183
|
-
},
|
|
9183
|
+
}, Ui = ({ anchors: e, bounds: t }) => {
|
|
9184
9184
|
let { left: n, right: r, centerX: i, top: a, bottom: o, centerY: s } = t;
|
|
9185
9185
|
e.vertical.push(n, i, r), e.horizontal.push(a, s, o);
|
|
9186
|
-
},
|
|
9186
|
+
}, Wi = ({ bounds: e, type: t, primaryStart: n, primaryEnd: r }) => {
|
|
9187
9187
|
let i = [], a = n === "top" ? "left" : "top", o = r === "bottom" ? "right" : "bottom", s = [...e].sort((e, t) => e[n] - t[n]);
|
|
9188
9188
|
for (let e = 0; e < s.length; e += 1) {
|
|
9189
9189
|
let c = s[e], l = null, u = Infinity;
|
|
@@ -9204,35 +9204,35 @@ var Kr = class {
|
|
|
9204
9204
|
});
|
|
9205
9205
|
}
|
|
9206
9206
|
return i;
|
|
9207
|
-
},
|
|
9208
|
-
vertical:
|
|
9207
|
+
}, Gi = ({ bounds: e }) => ({
|
|
9208
|
+
vertical: Wi({
|
|
9209
9209
|
bounds: e,
|
|
9210
9210
|
axis: "centerX",
|
|
9211
9211
|
type: "vertical",
|
|
9212
9212
|
primaryStart: "top",
|
|
9213
9213
|
primaryEnd: "bottom"
|
|
9214
9214
|
}),
|
|
9215
|
-
horizontal:
|
|
9215
|
+
horizontal: Wi({
|
|
9216
9216
|
bounds: e,
|
|
9217
9217
|
axis: "centerY",
|
|
9218
9218
|
type: "horizontal",
|
|
9219
9219
|
primaryStart: "left",
|
|
9220
9220
|
primaryEnd: "right"
|
|
9221
9221
|
})
|
|
9222
|
-
}),
|
|
9222
|
+
}), Ki = [
|
|
9223
9223
|
"montage-area",
|
|
9224
9224
|
"background",
|
|
9225
9225
|
"interaction-blocker"
|
|
9226
|
-
],
|
|
9226
|
+
], qi = ({ activeObject: t }) => {
|
|
9227
9227
|
let n = /* @__PURE__ */ new Set();
|
|
9228
9228
|
return t ? (n.add(t), t instanceof e && t.getObjects().forEach((e) => n.add(e)), n) : n;
|
|
9229
|
-
},
|
|
9229
|
+
}, Ji = ({ object: e, excluded: t, ignoredIds: n = Ki }) => {
|
|
9230
9230
|
if (t.has(e)) return !0;
|
|
9231
9231
|
let { visible: r = !0 } = e;
|
|
9232
9232
|
if (!r) return !0;
|
|
9233
9233
|
let { id: i } = e;
|
|
9234
9234
|
return !!(i && n.includes(i));
|
|
9235
|
-
},
|
|
9235
|
+
}, Yi = class e {
|
|
9236
9236
|
constructor({ editor: e }) {
|
|
9237
9237
|
this.anchors = {
|
|
9238
9238
|
vertical: [],
|
|
@@ -9285,7 +9285,7 @@ var Kr = class {
|
|
|
9285
9285
|
this._clearSpacingContexts(), this._clearGuides();
|
|
9286
9286
|
return;
|
|
9287
9287
|
}
|
|
9288
|
-
let { canvas: o } = this, s = o.getZoom() || 1, c = 5 / s, { deltaX: l, deltaY: u } =
|
|
9288
|
+
let { canvas: o } = this, s = o.getZoom() || 1, c = 5 / s, { deltaX: l, deltaY: u } = Ii({
|
|
9289
9289
|
activeBounds: a,
|
|
9290
9290
|
threshold: c,
|
|
9291
9291
|
anchors: this.anchors
|
|
@@ -9297,7 +9297,7 @@ var Kr = class {
|
|
|
9297
9297
|
top: t + u
|
|
9298
9298
|
}), n.setCoords(), a = W({ object: n }) ?? a;
|
|
9299
9299
|
}
|
|
9300
|
-
let d = this._resolveCurrentTargetBounds({ activeObject: n }), f = this.spacingContexts.vertical || this.spacingContexts.horizontal ? 10 / s : c, p =
|
|
9300
|
+
let d = this._resolveCurrentTargetBounds({ activeObject: n }), f = this.spacingContexts.vertical || this.spacingContexts.horizontal ? 10 / s : c, p = zi({
|
|
9301
9301
|
activeBounds: a,
|
|
9302
9302
|
candidates: d,
|
|
9303
9303
|
threshold: f,
|
|
@@ -9318,11 +9318,11 @@ var Kr = class {
|
|
|
9318
9318
|
target: n,
|
|
9319
9319
|
transform: i
|
|
9320
9320
|
});
|
|
9321
|
-
let h = W({ object: n }) ?? a, g =
|
|
9321
|
+
let h = W({ object: n }) ?? a, g = Ii({
|
|
9322
9322
|
activeBounds: h,
|
|
9323
9323
|
threshold: c,
|
|
9324
9324
|
anchors: this.anchors
|
|
9325
|
-
}), _ =
|
|
9325
|
+
}), _ = zi({
|
|
9326
9326
|
activeBounds: h,
|
|
9327
9327
|
candidates: d,
|
|
9328
9328
|
threshold: c,
|
|
@@ -9553,9 +9553,9 @@ var Kr = class {
|
|
|
9553
9553
|
let { canvas: e, guideBounds: t } = this, n = e.getSelectionContext();
|
|
9554
9554
|
if (!n) return;
|
|
9555
9555
|
let { left: r, right: i, top: a, bottom: o } = t ?? this._calculateViewportBounds(), { viewportTransform: s } = e, c = e.getZoom() || 1;
|
|
9556
|
-
n.save(), Array.isArray(s) && n.transform(...s), n.lineWidth = 1 / c, n.strokeStyle =
|
|
9556
|
+
n.save(), Array.isArray(s) && n.transform(...s), n.lineWidth = 1 / c, n.strokeStyle = ci, n.setLineDash([4, 4]);
|
|
9557
9557
|
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();
|
|
9558
|
-
for (let e of this.activeSpacingGuides)
|
|
9558
|
+
for (let e of this.activeSpacingGuides) Hi({
|
|
9559
9559
|
context: n,
|
|
9560
9560
|
guide: e,
|
|
9561
9561
|
zoom: c
|
|
@@ -9766,14 +9766,14 @@ var Kr = class {
|
|
|
9766
9766
|
}, r = [];
|
|
9767
9767
|
for (let e of t) {
|
|
9768
9768
|
let t = W({ object: e });
|
|
9769
|
-
t && (
|
|
9769
|
+
t && (Ui({
|
|
9770
9770
|
anchors: n,
|
|
9771
9771
|
bounds: t
|
|
9772
9772
|
}), r.push(t));
|
|
9773
9773
|
}
|
|
9774
9774
|
let { montageArea: i } = this.editor, a = W({ object: i });
|
|
9775
9775
|
if (a) {
|
|
9776
|
-
|
|
9776
|
+
Ui({
|
|
9777
9777
|
anchors: n,
|
|
9778
9778
|
bounds: a
|
|
9779
9779
|
});
|
|
@@ -9785,12 +9785,12 @@ var Kr = class {
|
|
|
9785
9785
|
bottom: i
|
|
9786
9786
|
};
|
|
9787
9787
|
} else this.guideBounds = this._calculateViewportBounds();
|
|
9788
|
-
this.anchors = n, this.spacingPatterns =
|
|
9788
|
+
this.anchors = n, this.spacingPatterns = Gi({ bounds: r }), this.cachedTargetBounds = r;
|
|
9789
9789
|
}
|
|
9790
9790
|
_collectTargets({ activeObject: e }) {
|
|
9791
|
-
let t =
|
|
9791
|
+
let t = qi({ activeObject: e }), n = [];
|
|
9792
9792
|
return this.canvas.forEachObject((e) => {
|
|
9793
|
-
|
|
9793
|
+
Ji({
|
|
9794
9794
|
object: e,
|
|
9795
9795
|
excluded: t
|
|
9796
9796
|
}) || n.push(e);
|
|
@@ -9813,7 +9813,7 @@ var Kr = class {
|
|
|
9813
9813
|
bottom: (r - s) / a
|
|
9814
9814
|
};
|
|
9815
9815
|
}
|
|
9816
|
-
},
|
|
9816
|
+
}, Xi = "#3D8BF4", Zi = class e {
|
|
9817
9817
|
constructor({ editor: e }) {
|
|
9818
9818
|
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();
|
|
9819
9819
|
}
|
|
@@ -9906,8 +9906,8 @@ var Kr = class {
|
|
|
9906
9906
|
this.isTargetMontageArea = l, this.activeGuides = d, this._hideToolbar(), n.requestRenderAll();
|
|
9907
9907
|
}
|
|
9908
9908
|
static _resolveTarget({ event: e, activeObject: t }) {
|
|
9909
|
-
let { target: n } = e, r =
|
|
9910
|
-
return n && !
|
|
9909
|
+
let { target: n } = e, r = qi({ activeObject: t });
|
|
9910
|
+
return n && !Ji({
|
|
9911
9911
|
object: n,
|
|
9912
9912
|
excluded: r
|
|
9913
9913
|
}) ? n : null;
|
|
@@ -10024,18 +10024,18 @@ var Kr = class {
|
|
|
10024
10024
|
let { canvas: e } = this, t = e.getSelectionContext();
|
|
10025
10025
|
if (!t) return;
|
|
10026
10026
|
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;
|
|
10027
|
-
t.save(), Array.isArray(n) && t.transform(...n), t.lineWidth = 1 / r, t.strokeStyle =
|
|
10027
|
+
t.save(), Array.isArray(n) && t.transform(...n), t.lineWidth = 1 / r, t.strokeStyle = Xi, t.setLineDash([]);
|
|
10028
10028
|
for (let e of this.activeGuides) {
|
|
10029
10029
|
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;
|
|
10030
|
-
t.beginPath(), n === "vertical" ? (t.moveTo(i, a), t.lineTo(i, c)) : (t.moveTo(a, i), t.lineTo(c, i)), t.stroke(),
|
|
10030
|
+
t.beginPath(), n === "vertical" ? (t.moveTo(i, a), t.lineTo(i, c)) : (t.moveTo(a, i), t.lineTo(c, i)), t.stroke(), Vi({
|
|
10031
10031
|
context: t,
|
|
10032
10032
|
type: n,
|
|
10033
10033
|
axis: i,
|
|
10034
10034
|
start: a,
|
|
10035
10035
|
end: c,
|
|
10036
|
-
text:
|
|
10036
|
+
text: ui({ distance: l }).toString(),
|
|
10037
10037
|
zoom: r,
|
|
10038
|
-
color:
|
|
10038
|
+
color: Xi,
|
|
10039
10039
|
lineWidth: 1,
|
|
10040
10040
|
offsetAlongAxis: d,
|
|
10041
10041
|
offsetPerpendicular: 0
|
|
@@ -10053,13 +10053,13 @@ var Kr = class {
|
|
|
10053
10053
|
let { toolbar: e } = this.editor;
|
|
10054
10054
|
e?.showAfterTemporary?.(), this.isToolbarHidden = !1;
|
|
10055
10055
|
}
|
|
10056
|
-
},
|
|
10056
|
+
}, Qi = class e {
|
|
10057
10057
|
constructor(e, t) {
|
|
10058
10058
|
this.options = t, this.containerId = e, this.editorId = `${e}-${D()}`, this.init();
|
|
10059
10059
|
}
|
|
10060
10060
|
async init() {
|
|
10061
10061
|
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;
|
|
10062
|
-
if (
|
|
10062
|
+
if (R.apply(), this.canvas = new t(this.containerId, this.options), this.moduleLoader = new A(), this.workerManager = new M(), this.errorManager = new hr({ editor: this }), this.historyManager = new Me({ editor: this }), this.toolbar = new oe({ editor: this }), this.transformManager = new Ue({ editor: this }), this.zoomManager = new We({ editor: this }), this.canvasManager = new He({ editor: this }), this.imageManager = new Re({ editor: this }), this.layerManager = new $e({ editor: this }), this.shapeManager = new cr({ editor: this }), this.interactionBlocker = new Ze({ editor: this }), this.backgroundManager = new Qe({ editor: this }), this.clipboardManager = new lr({ editor: this }), this.objectLockManager = new ur({ editor: this }), this.groupingManager = new dr({ editor: this }), this.selectionManager = new fr({ editor: this }), this.deletionManager = new pr({ editor: this }), this.panConstraintManager = new gr({ editor: this }), this.snappingManager = new Yi({ editor: this }), this.measurementManager = new Zi({ editor: this }), this.fontManager = new ae(this.options.fonts ?? []), this.textManager = new ni({ editor: this }), this.templateManager = new si({ editor: this }), u && (this.angleIndicator = new ce({ editor: this })), this._createMontageArea(), this._createClippingArea(), this.interactionBlocker.ensureOverlay(), this.listeners = new k({
|
|
10063
10063
|
editor: this,
|
|
10064
10064
|
options: this.options
|
|
10065
10065
|
}), 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) {
|
|
@@ -10167,7 +10167,7 @@ var Kr = class {
|
|
|
10167
10167
|
"U+A640-A69F",
|
|
10168
10168
|
"U+FE2E-FE2F",
|
|
10169
10169
|
"U+2116"
|
|
10170
|
-
].join(", "),
|
|
10170
|
+
].join(", "), $i = {
|
|
10171
10171
|
preserveObjectStacking: !0,
|
|
10172
10172
|
controlsAboveOverlay: !0,
|
|
10173
10173
|
centeredRotation: !0,
|
|
@@ -11021,20 +11021,20 @@ var Kr = class {
|
|
|
11021
11021
|
};
|
|
11022
11022
|
//#endregion
|
|
11023
11023
|
//#region src/main.ts
|
|
11024
|
-
function
|
|
11024
|
+
function ea(e, t = {}) {
|
|
11025
11025
|
let n = {
|
|
11026
|
-
|
|
11026
|
+
...$i,
|
|
11027
11027
|
...t
|
|
11028
11028
|
}, r = document.getElementById(e);
|
|
11029
11029
|
if (!r) return Promise.reject(/* @__PURE__ */ Error(`Контейнер с ID "${e}" не найден.`));
|
|
11030
11030
|
let i = document.createElement("canvas");
|
|
11031
11031
|
return i.id = `${e}-canvas`, r.appendChild(i), n.editorContainer = r, new Promise((t) => {
|
|
11032
11032
|
n._onReadyCallback = t;
|
|
11033
|
-
let r = new
|
|
11033
|
+
let r = new Qi(i.id, n);
|
|
11034
11034
|
window[e] = r;
|
|
11035
11035
|
});
|
|
11036
11036
|
}
|
|
11037
11037
|
//#endregion
|
|
11038
|
-
export {
|
|
11038
|
+
export { ea as default };
|
|
11039
11039
|
|
|
11040
11040
|
//# sourceMappingURL=main.js.map
|