@anu3ev/fabric-image-editor 0.7.13 → 0.7.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js +659 -551
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -4330,45 +4330,124 @@ function en({ text: e, width: t, height: n, padding: r, internalShapeTextInset:
|
|
|
4330
4330
|
}
|
|
4331
4331
|
//#endregion
|
|
4332
4332
|
//#region src/editor/shape-manager/layout/shape-layout.ts
|
|
4333
|
-
var q = 1, tn = .5, nn = 8, rn = 20, an = 16
|
|
4334
|
-
|
|
4333
|
+
var q = 1, tn = .5, nn = 8, rn = 20, an = 16;
|
|
4334
|
+
function on({ text: e, alignV: t, width: n, height: r, appliedPadding: i, appliedUserPadding: a }) {
|
|
4335
|
+
let { frame: o, splitByGrapheme: s, textTop: c } = pn({
|
|
4336
|
+
text: e,
|
|
4337
|
+
width: n,
|
|
4338
|
+
height: r,
|
|
4339
|
+
alignV: t,
|
|
4340
|
+
padding: i
|
|
4341
|
+
});
|
|
4342
|
+
return {
|
|
4343
|
+
width: n,
|
|
4344
|
+
height: r,
|
|
4345
|
+
appliedPadding: i,
|
|
4346
|
+
appliedUserPadding: a,
|
|
4347
|
+
frame: o,
|
|
4348
|
+
splitByGrapheme: s,
|
|
4349
|
+
textTop: c
|
|
4350
|
+
};
|
|
4351
|
+
}
|
|
4352
|
+
var sn = ({ text: e, width: t, height: n, alignV: r, padding: i, internalShapeTextInset: a, resolveInternalShapeTextInset: o, preserveAspectRatio: s, shapeTextAutoExpandEnabled: c, montageAreaWidth: l, expandShapeHeightToFitText: u = !0, changedPadding: d }) => {
|
|
4353
|
+
let { width: f, height: p, appliedPadding: m, appliedUserPadding: h } = s ? un({
|
|
4354
|
+
text: e,
|
|
4355
|
+
width: t,
|
|
4356
|
+
height: n,
|
|
4357
|
+
padding: i,
|
|
4358
|
+
internalShapeTextInset: a,
|
|
4359
|
+
resolveInternalShapeTextInset: o,
|
|
4360
|
+
shapeTextAutoExpandEnabled: c,
|
|
4361
|
+
montageAreaWidth: l,
|
|
4362
|
+
expandShapeHeightToFitText: u,
|
|
4363
|
+
changedPadding: d
|
|
4364
|
+
}) : yn({
|
|
4365
|
+
text: e,
|
|
4366
|
+
width: t,
|
|
4367
|
+
height: n,
|
|
4368
|
+
padding: i,
|
|
4369
|
+
internalShapeTextInset: a,
|
|
4370
|
+
resolveInternalShapeTextInset: o,
|
|
4371
|
+
expandShapeHeightToFitText: u,
|
|
4372
|
+
changedPadding: d
|
|
4373
|
+
});
|
|
4374
|
+
return on({
|
|
4375
|
+
text: e,
|
|
4376
|
+
alignV: r,
|
|
4377
|
+
width: f,
|
|
4378
|
+
height: p,
|
|
4379
|
+
appliedPadding: m,
|
|
4380
|
+
appliedUserPadding: h
|
|
4381
|
+
});
|
|
4382
|
+
}, cn = ({ text: e, width: t, height: n, alignV: r, padding: i, internalShapeTextInset: a, resolveInternalShapeTextInset: o, expandShapeHeightToFitText: s = !0, changedPadding: c }) => {
|
|
4383
|
+
let l = zt({ padding: i }), u = Rt({ padding: a }), d = Math.max(q, t), f = Math.max(q, n), p = en({
|
|
4384
|
+
text: e,
|
|
4385
|
+
width: d,
|
|
4386
|
+
height: f,
|
|
4387
|
+
padding: l,
|
|
4388
|
+
internalShapeTextInset: vn({
|
|
4389
|
+
width: d,
|
|
4390
|
+
height: f,
|
|
4391
|
+
internalShapeTextInset: u,
|
|
4392
|
+
resolveInternalShapeTextInset: o
|
|
4393
|
+
}),
|
|
4394
|
+
expandShapeHeightToFitText: s,
|
|
4395
|
+
changedPadding: c,
|
|
4396
|
+
measureTextboxHeightForFrame: Tn,
|
|
4397
|
+
resolveMinimumTextFrameWidth: En
|
|
4398
|
+
});
|
|
4399
|
+
for (let t = 0; t < nn; t += 1) {
|
|
4400
|
+
let t = Math.max(f, p.requiredHeight);
|
|
4401
|
+
if (t <= f + tn) break;
|
|
4402
|
+
f = t, p = en({
|
|
4403
|
+
text: e,
|
|
4404
|
+
width: d,
|
|
4405
|
+
height: f,
|
|
4406
|
+
padding: l,
|
|
4407
|
+
internalShapeTextInset: vn({
|
|
4408
|
+
width: d,
|
|
4409
|
+
height: f,
|
|
4410
|
+
internalShapeTextInset: u,
|
|
4411
|
+
resolveInternalShapeTextInset: o
|
|
4412
|
+
}),
|
|
4413
|
+
expandShapeHeightToFitText: s,
|
|
4414
|
+
changedPadding: c,
|
|
4415
|
+
measureTextboxHeightForFrame: Tn,
|
|
4416
|
+
resolveMinimumTextFrameWidth: En
|
|
4417
|
+
});
|
|
4418
|
+
}
|
|
4419
|
+
return on({
|
|
4420
|
+
text: e,
|
|
4421
|
+
alignV: r,
|
|
4422
|
+
width: d,
|
|
4423
|
+
height: f,
|
|
4424
|
+
appliedPadding: p.appliedPadding,
|
|
4425
|
+
appliedUserPadding: p.appliedUserPadding
|
|
4426
|
+
});
|
|
4427
|
+
}, ln = ({ group: e, shape: t, text: n, width: r, height: i, alignH: a, alignV: o, padding: s, internalShapeTextInset: c, resolveInternalShapeTextInset: l, preserveAspectRatio: u, shapeTextAutoExpandEnabled: d, montageAreaWidth: f, expandShapeHeightToFitText: p = !0, changedPadding: m }) => {
|
|
4428
|
+
let h = Math.max(q, e.shapeManualBaseWidth ?? r), g = Math.max(q, e.shapeManualBaseHeight ?? i), { width: _, height: v, appliedUserPadding: y, frame: b, splitByGrapheme: x, textTop: S } = sn({
|
|
4335
4429
|
text: n,
|
|
4336
4430
|
width: r,
|
|
4337
4431
|
height: i,
|
|
4432
|
+
alignV: o,
|
|
4338
4433
|
padding: s,
|
|
4339
4434
|
internalShapeTextInset: c,
|
|
4340
4435
|
resolveInternalShapeTextInset: l,
|
|
4341
|
-
|
|
4436
|
+
preserveAspectRatio: u,
|
|
4437
|
+
shapeTextAutoExpandEnabled: d ?? e.shapeTextAutoExpand !== !1,
|
|
4342
4438
|
montageAreaWidth: f,
|
|
4343
4439
|
expandShapeHeightToFitText: p,
|
|
4344
4440
|
changedPadding: m
|
|
4345
|
-
}) : gn({
|
|
4346
|
-
text: n,
|
|
4347
|
-
width: r,
|
|
4348
|
-
height: i,
|
|
4349
|
-
padding: s,
|
|
4350
|
-
internalShapeTextInset: c,
|
|
4351
|
-
resolveInternalShapeTextInset: l,
|
|
4352
|
-
expandShapeHeightToFitText: p,
|
|
4353
|
-
changedPadding: m
|
|
4354
4441
|
});
|
|
4355
4442
|
xt({
|
|
4356
4443
|
shape: t,
|
|
4357
|
-
width:
|
|
4358
|
-
height:
|
|
4444
|
+
width: _,
|
|
4445
|
+
height: v,
|
|
4359
4446
|
rounding: e.shapeRounding,
|
|
4360
4447
|
strokeWidth: e.shapeStrokeWidth
|
|
4361
|
-
})
|
|
4362
|
-
let { frame: S, splitByGrapheme: C, textTop: w } = un({
|
|
4363
|
-
text: n,
|
|
4364
|
-
width: v,
|
|
4365
|
-
height: y,
|
|
4366
|
-
alignV: o,
|
|
4367
|
-
padding: b
|
|
4368
|
-
});
|
|
4369
|
-
n.set({
|
|
4448
|
+
}), n.set({
|
|
4370
4449
|
autoExpand: !1,
|
|
4371
|
-
width:
|
|
4450
|
+
width: b.width,
|
|
4372
4451
|
textAlign: a,
|
|
4373
4452
|
scaleX: 1,
|
|
4374
4453
|
scaleY: 1,
|
|
@@ -4377,21 +4456,21 @@ var q = 1, tn = .5, nn = 8, rn = 20, an = 16, on = ({ group: e, shape: t, text:
|
|
|
4377
4456
|
skewY: 0,
|
|
4378
4457
|
flipX: !1,
|
|
4379
4458
|
flipY: !1,
|
|
4380
|
-
left:
|
|
4381
|
-
top:
|
|
4459
|
+
left: b.left,
|
|
4460
|
+
top: S,
|
|
4382
4461
|
originX: "left",
|
|
4383
4462
|
originY: "top",
|
|
4384
|
-
splitByGrapheme:
|
|
4385
|
-
}), n.initDimensions(), n.setCoords(), t.setCoords(), e.shapeBaseWidth =
|
|
4386
|
-
width:
|
|
4387
|
-
height:
|
|
4463
|
+
splitByGrapheme: x
|
|
4464
|
+
}), n.initDimensions(), n.setCoords(), t.setCoords(), e.shapeBaseWidth = _, e.shapeBaseHeight = v, e.shapeManualBaseWidth = h, e.shapeManualBaseHeight = g, e.shapePaddingTop = y.top, e.shapePaddingRight = y.right, e.shapePaddingBottom = y.bottom, e.shapePaddingLeft = y.left, e.shapeAlignHorizontal = a, e.shapeAlignVertical = o, e.set({
|
|
4465
|
+
width: _,
|
|
4466
|
+
height: v,
|
|
4388
4467
|
scaleX: 1,
|
|
4389
4468
|
scaleY: 1
|
|
4390
4469
|
}), e.set("dirty", !0), e.setCoords();
|
|
4391
4470
|
};
|
|
4392
|
-
function
|
|
4471
|
+
function un({ text: e, width: t, height: n, padding: r, internalShapeTextInset: i, resolveInternalShapeTextInset: a, shapeTextAutoExpandEnabled: o = !0, montageAreaWidth: s, expandShapeHeightToFitText: c = !0, changedPadding: l }) {
|
|
4393
4472
|
let u = Math.max(q, t), d = Math.max(q, n), f = Number.isFinite(s) && (s ?? 0) > 0 ? Math.max(q, s ?? q) : null;
|
|
4394
|
-
if (!
|
|
4473
|
+
if (!hn({ text: e })) return yn({
|
|
4395
4474
|
text: e,
|
|
4396
4475
|
width: u,
|
|
4397
4476
|
height: d,
|
|
@@ -4402,7 +4481,7 @@ function sn({ text: e, width: t, height: n, padding: r, internalShapeTextInset:
|
|
|
4402
4481
|
changedPadding: l
|
|
4403
4482
|
});
|
|
4404
4483
|
let p = d / u, m = ({ width: t }) => {
|
|
4405
|
-
let n = Math.max(q, t * p), o =
|
|
4484
|
+
let n = Math.max(q, t * p), o = yn({
|
|
4406
4485
|
text: e,
|
|
4407
4486
|
width: t,
|
|
4408
4487
|
height: n,
|
|
@@ -4430,11 +4509,11 @@ function sn({ text: e, width: t, height: n, padding: r, internalShapeTextInset:
|
|
|
4430
4509
|
layoutResolution: n
|
|
4431
4510
|
});
|
|
4432
4511
|
}, t = f ? Math.max(u, f) : u;
|
|
4433
|
-
e({ width: t }) || (t =
|
|
4512
|
+
e({ width: t }) || (t = bn({
|
|
4434
4513
|
minimumWidth: t,
|
|
4435
4514
|
isWidthValid: e
|
|
4436
4515
|
}));
|
|
4437
|
-
let { layoutResolution: n } = m({ width:
|
|
4516
|
+
let { layoutResolution: n } = m({ width: xn({
|
|
4438
4517
|
minimumWidth: u,
|
|
4439
4518
|
maximumWidth: t,
|
|
4440
4519
|
isWidthValid: e
|
|
@@ -4447,19 +4526,19 @@ function sn({ text: e, width: t, height: n, padding: r, internalShapeTextInset:
|
|
|
4447
4526
|
candidateWidth: t,
|
|
4448
4527
|
candidateHeight: r,
|
|
4449
4528
|
layoutResolution: a
|
|
4450
|
-
}) || n !== void 0 && i < n - tn ? !1 : !
|
|
4529
|
+
}) || n !== void 0 && i < n - tn ? !1 : !wn({
|
|
4451
4530
|
text: e,
|
|
4452
4531
|
frameWidth: i
|
|
4453
4532
|
}).hasWrappedLines;
|
|
4454
|
-
}, _ = f ? Math.max(u, f) :
|
|
4533
|
+
}, _ = f ? Math.max(u, f) : bn({
|
|
4455
4534
|
minimumWidth: u,
|
|
4456
4535
|
isWidthValid: ({ width: e }) => g({ width: e })
|
|
4457
|
-
}), v = m({ width: _ }), y =
|
|
4536
|
+
}), v = m({ width: _ }), y = wn({
|
|
4458
4537
|
text: e,
|
|
4459
4538
|
frameWidth: v.frameWidth
|
|
4460
4539
|
});
|
|
4461
4540
|
if (y.hasWrappedLines) return v.layoutResolution;
|
|
4462
|
-
let b = Math.max(q, y.longestLineWidth), { layoutResolution: x } = m({ width:
|
|
4541
|
+
let b = Math.max(q, y.longestLineWidth), { layoutResolution: x } = m({ width: xn({
|
|
4463
4542
|
minimumWidth: u,
|
|
4464
4543
|
maximumWidth: _,
|
|
4465
4544
|
isWidthValid: ({ width: e }) => g({
|
|
@@ -4469,67 +4548,67 @@ function sn({ text: e, width: t, height: n, padding: r, internalShapeTextInset:
|
|
|
4469
4548
|
}) });
|
|
4470
4549
|
return x;
|
|
4471
4550
|
}
|
|
4472
|
-
var
|
|
4551
|
+
var dn = ({ text: e, currentWidth: t, minimumWidth: n, padding: r, montageAreaWidth: i, resolvePaddingForWidth: a }) => {
|
|
4473
4552
|
let o = Math.max(q, t), s = Math.max(q, n);
|
|
4474
|
-
if (!
|
|
4553
|
+
if (!hn({ text: e })) return s;
|
|
4475
4554
|
let c = Math.max(s, Number.isFinite(i) && i > 0 ? Math.max(q, i) : Math.max(o, s)), l = qt({
|
|
4476
4555
|
width: c,
|
|
4477
|
-
padding:
|
|
4556
|
+
padding: gn({
|
|
4478
4557
|
width: c,
|
|
4479
4558
|
padding: r,
|
|
4480
4559
|
resolvePaddingForWidth: a
|
|
4481
4560
|
})
|
|
4482
|
-
}), u = c, d =
|
|
4561
|
+
}), u = c, d = wn({
|
|
4483
4562
|
text: e,
|
|
4484
4563
|
frameWidth: l
|
|
4485
4564
|
});
|
|
4486
4565
|
if (d.hasWrappedLines) return u;
|
|
4487
4566
|
let f = Math.max(q, d.longestLineWidth);
|
|
4488
|
-
return
|
|
4567
|
+
return xn({
|
|
4489
4568
|
minimumWidth: s,
|
|
4490
4569
|
maximumWidth: u,
|
|
4491
4570
|
isWidthValid: ({ width: t }) => {
|
|
4492
4571
|
let n = qt({
|
|
4493
4572
|
width: t,
|
|
4494
|
-
padding:
|
|
4573
|
+
padding: gn({
|
|
4495
4574
|
width: t,
|
|
4496
4575
|
padding: r,
|
|
4497
4576
|
resolvePaddingForWidth: a
|
|
4498
4577
|
})
|
|
4499
4578
|
});
|
|
4500
|
-
return n < f - tn ? !1 : !
|
|
4579
|
+
return n < f - tn ? !1 : !wn({
|
|
4501
4580
|
text: e,
|
|
4502
4581
|
frameWidth: n
|
|
4503
4582
|
}).hasWrappedLines;
|
|
4504
4583
|
}
|
|
4505
4584
|
});
|
|
4506
|
-
},
|
|
4507
|
-
if (!
|
|
4508
|
-
let r =
|
|
4585
|
+
}, fn = ({ text: e, padding: t, resolvePaddingForWidth: n }) => {
|
|
4586
|
+
if (!hn({ text: e })) return q;
|
|
4587
|
+
let r = En({ text: e }), i = Math.max(q, r), a = ({ width: e }) => qt({
|
|
4509
4588
|
width: e,
|
|
4510
|
-
padding:
|
|
4589
|
+
padding: gn({
|
|
4511
4590
|
width: e,
|
|
4512
4591
|
padding: t,
|
|
4513
4592
|
resolvePaddingForWidth: n
|
|
4514
4593
|
})
|
|
4515
4594
|
}) >= r - tn;
|
|
4516
|
-
return
|
|
4595
|
+
return xn({
|
|
4517
4596
|
minimumWidth: i,
|
|
4518
|
-
maximumWidth:
|
|
4597
|
+
maximumWidth: bn({
|
|
4519
4598
|
minimumWidth: i,
|
|
4520
4599
|
isWidthValid: a
|
|
4521
4600
|
}),
|
|
4522
4601
|
isWidthValid: a
|
|
4523
4602
|
});
|
|
4524
|
-
},
|
|
4525
|
-
let a =
|
|
4603
|
+
}, pn = ({ text: e, width: t, height: n, alignV: r, padding: i }) => {
|
|
4604
|
+
let a = Sn({
|
|
4526
4605
|
width: Math.max(q, t),
|
|
4527
4606
|
height: Math.max(q, n),
|
|
4528
4607
|
padding: Rt({ padding: i })
|
|
4529
|
-
}), o =
|
|
4608
|
+
}), o = kn({
|
|
4530
4609
|
text: e,
|
|
4531
4610
|
frameWidth: a.width
|
|
4532
|
-
}), s =
|
|
4611
|
+
}), s = Tn({
|
|
4533
4612
|
text: e,
|
|
4534
4613
|
frameWidth: a.width,
|
|
4535
4614
|
splitByGrapheme: o
|
|
@@ -4537,24 +4616,24 @@ var cn = ({ text: e, currentWidth: t, minimumWidth: n, padding: r, montageAreaWi
|
|
|
4537
4616
|
return {
|
|
4538
4617
|
frame: a,
|
|
4539
4618
|
splitByGrapheme: o,
|
|
4540
|
-
textTop:
|
|
4619
|
+
textTop: On({
|
|
4541
4620
|
alignV: r,
|
|
4542
4621
|
frameHeight: a.height,
|
|
4543
4622
|
frameTop: a.top,
|
|
4544
4623
|
textHeight: s
|
|
4545
4624
|
})
|
|
4546
4625
|
};
|
|
4547
|
-
},
|
|
4626
|
+
}, mn = ({ text: e, width: t, height: n, padding: r, resolvePaddingForSize: i }) => {
|
|
4548
4627
|
let a = Math.max(q, n);
|
|
4549
|
-
if (!
|
|
4628
|
+
if (!hn({ text: e })) return a;
|
|
4550
4629
|
let o = Math.max(q, t), s = a;
|
|
4551
4630
|
for (let t = 0; t < nn; t += 1) {
|
|
4552
|
-
let t =
|
|
4631
|
+
let t = _n({
|
|
4553
4632
|
width: o,
|
|
4554
4633
|
height: s,
|
|
4555
4634
|
padding: r,
|
|
4556
4635
|
resolvePaddingForSize: i
|
|
4557
|
-
}), n =
|
|
4636
|
+
}), n = Tn({
|
|
4558
4637
|
text: e,
|
|
4559
4638
|
frameWidth: qt({
|
|
4560
4639
|
width: o,
|
|
@@ -4566,31 +4645,31 @@ var cn = ({ text: e, currentWidth: t, minimumWidth: n, padding: r, montageAreaWi
|
|
|
4566
4645
|
}
|
|
4567
4646
|
return s;
|
|
4568
4647
|
};
|
|
4569
|
-
function
|
|
4648
|
+
function hn({ text: e }) {
|
|
4570
4649
|
return (e.text ?? "").trim().length > 0;
|
|
4571
4650
|
}
|
|
4572
|
-
function
|
|
4651
|
+
function gn({ width: e, padding: t, resolvePaddingForWidth: n }) {
|
|
4573
4652
|
return Rt(n ? { padding: n({ width: Math.max(q, e) }) } : { padding: t });
|
|
4574
4653
|
}
|
|
4575
|
-
function
|
|
4654
|
+
function _n({ width: e, height: t, padding: n, resolvePaddingForSize: r }) {
|
|
4576
4655
|
return Rt(r ? { padding: r({
|
|
4577
4656
|
width: Math.max(q, e),
|
|
4578
4657
|
height: Math.max(q, t)
|
|
4579
4658
|
}) } : { padding: n });
|
|
4580
4659
|
}
|
|
4581
|
-
function
|
|
4660
|
+
function vn({ width: e, height: t, internalShapeTextInset: n, resolveInternalShapeTextInset: r }) {
|
|
4582
4661
|
return Rt(r ? { padding: r({
|
|
4583
4662
|
width: Math.max(q, e),
|
|
4584
4663
|
height: Math.max(q, t)
|
|
4585
4664
|
}) } : { padding: n });
|
|
4586
4665
|
}
|
|
4587
|
-
function
|
|
4666
|
+
function yn({ text: e, width: t, height: n, padding: r, internalShapeTextInset: i, resolveInternalShapeTextInset: a, expandShapeHeightToFitText: o = !0, changedPadding: s }) {
|
|
4588
4667
|
let c = zt({ padding: r }), l = Rt({ padding: i }), u = Math.max(q, t), d = Math.max(q, n), f = en({
|
|
4589
4668
|
text: e,
|
|
4590
4669
|
width: u,
|
|
4591
4670
|
height: d,
|
|
4592
4671
|
padding: c,
|
|
4593
|
-
internalShapeTextInset:
|
|
4672
|
+
internalShapeTextInset: vn({
|
|
4594
4673
|
width: u,
|
|
4595
4674
|
height: d,
|
|
4596
4675
|
internalShapeTextInset: l,
|
|
@@ -4598,8 +4677,8 @@ function gn({ text: e, width: t, height: n, padding: r, internalShapeTextInset:
|
|
|
4598
4677
|
}),
|
|
4599
4678
|
expandShapeHeightToFitText: o,
|
|
4600
4679
|
changedPadding: s,
|
|
4601
|
-
measureTextboxHeightForFrame:
|
|
4602
|
-
resolveMinimumTextFrameWidth:
|
|
4680
|
+
measureTextboxHeightForFrame: Tn,
|
|
4681
|
+
resolveMinimumTextFrameWidth: En
|
|
4603
4682
|
});
|
|
4604
4683
|
for (let t = 0; t < nn; t += 1) {
|
|
4605
4684
|
let t = Math.max(u, f.requiredWidth), n = Math.max(d, f.requiredHeight);
|
|
@@ -4609,7 +4688,7 @@ function gn({ text: e, width: t, height: n, padding: r, internalShapeTextInset:
|
|
|
4609
4688
|
width: u,
|
|
4610
4689
|
height: d,
|
|
4611
4690
|
padding: c,
|
|
4612
|
-
internalShapeTextInset:
|
|
4691
|
+
internalShapeTextInset: vn({
|
|
4613
4692
|
width: u,
|
|
4614
4693
|
height: d,
|
|
4615
4694
|
internalShapeTextInset: l,
|
|
@@ -4617,8 +4696,8 @@ function gn({ text: e, width: t, height: n, padding: r, internalShapeTextInset:
|
|
|
4617
4696
|
}),
|
|
4618
4697
|
expandShapeHeightToFitText: o,
|
|
4619
4698
|
changedPadding: s,
|
|
4620
|
-
measureTextboxHeightForFrame:
|
|
4621
|
-
resolveMinimumTextFrameWidth:
|
|
4699
|
+
measureTextboxHeightForFrame: Tn,
|
|
4700
|
+
resolveMinimumTextFrameWidth: En
|
|
4622
4701
|
});
|
|
4623
4702
|
}
|
|
4624
4703
|
return {
|
|
@@ -4628,13 +4707,13 @@ function gn({ text: e, width: t, height: n, padding: r, internalShapeTextInset:
|
|
|
4628
4707
|
appliedUserPadding: f.appliedUserPadding
|
|
4629
4708
|
};
|
|
4630
4709
|
}
|
|
4631
|
-
function
|
|
4710
|
+
function bn({ minimumWidth: e, isWidthValid: t }) {
|
|
4632
4711
|
let n = Math.max(q, e);
|
|
4633
4712
|
if (t({ width: n })) return n;
|
|
4634
4713
|
for (let e = 0; e < an; e += 1) if (n = Math.max(n + 1, n * 2), t({ width: n })) return n;
|
|
4635
4714
|
return n;
|
|
4636
4715
|
}
|
|
4637
|
-
function
|
|
4716
|
+
function xn({ minimumWidth: e, maximumWidth: t, isWidthValid: n }) {
|
|
4638
4717
|
let r = Math.max(q, e), i = Math.max(r, t);
|
|
4639
4718
|
if (n({ width: r })) return r;
|
|
4640
4719
|
if (!n({ width: i })) return i;
|
|
@@ -4648,7 +4727,7 @@ function vn({ minimumWidth: e, maximumWidth: t, isWidthValid: n }) {
|
|
|
4648
4727
|
}
|
|
4649
4728
|
return i;
|
|
4650
4729
|
}
|
|
4651
|
-
function
|
|
4730
|
+
function Sn({ width: e, height: t, padding: n }) {
|
|
4652
4731
|
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);
|
|
4653
4732
|
return {
|
|
4654
4733
|
left: -e / 2 + r,
|
|
@@ -4657,7 +4736,7 @@ function yn({ width: e, height: t, padding: n }) {
|
|
|
4657
4736
|
height: Math.max(q, t - a - o)
|
|
4658
4737
|
};
|
|
4659
4738
|
}
|
|
4660
|
-
function
|
|
4739
|
+
function Cn({ text: e }) {
|
|
4661
4740
|
let { height: t } = e;
|
|
4662
4741
|
if (typeof t == "number" && Number.isFinite(t)) return t;
|
|
4663
4742
|
if (typeof e.calcTextHeight == "function") {
|
|
@@ -4666,18 +4745,18 @@ function bn({ text: e }) {
|
|
|
4666
4745
|
}
|
|
4667
4746
|
return q;
|
|
4668
4747
|
}
|
|
4669
|
-
function
|
|
4670
|
-
let n =
|
|
4748
|
+
function wn({ text: e, frameWidth: t }) {
|
|
4749
|
+
let n = jn({ text: e }), r = kn({
|
|
4671
4750
|
text: e,
|
|
4672
4751
|
frameWidth: t
|
|
4673
|
-
}), i =
|
|
4752
|
+
}), i = Pn({ text: e });
|
|
4674
4753
|
e.set({
|
|
4675
4754
|
autoExpand: !1,
|
|
4676
4755
|
width: Math.max(q, t),
|
|
4677
4756
|
splitByGrapheme: r
|
|
4678
4757
|
}), e.initDimensions();
|
|
4679
|
-
let a =
|
|
4680
|
-
return
|
|
4758
|
+
let a = Mn({ text: e }) > n, o = Math.ceil(An({ text: e }));
|
|
4759
|
+
return Fn({
|
|
4681
4760
|
text: e,
|
|
4682
4761
|
state: i
|
|
4683
4762
|
}), {
|
|
@@ -4685,8 +4764,8 @@ function xn({ text: e, frameWidth: t }) {
|
|
|
4685
4764
|
longestLineWidth: o
|
|
4686
4765
|
};
|
|
4687
4766
|
}
|
|
4688
|
-
function
|
|
4689
|
-
let r =
|
|
4767
|
+
function Tn({ text: e, frameWidth: t, splitByGrapheme: n }) {
|
|
4768
|
+
let r = Pn({ text: e }), i = n ?? kn({
|
|
4690
4769
|
text: e,
|
|
4691
4770
|
frameWidth: t
|
|
4692
4771
|
});
|
|
@@ -4695,71 +4774,71 @@ function Sn({ text: e, frameWidth: t, splitByGrapheme: n }) {
|
|
|
4695
4774
|
width: Math.max(q, t),
|
|
4696
4775
|
splitByGrapheme: i
|
|
4697
4776
|
}), e.initDimensions();
|
|
4698
|
-
let a =
|
|
4699
|
-
return
|
|
4777
|
+
let a = Cn({ text: e });
|
|
4778
|
+
return Fn({
|
|
4700
4779
|
text: e,
|
|
4701
4780
|
state: r
|
|
4702
4781
|
}), a;
|
|
4703
4782
|
}
|
|
4704
|
-
function
|
|
4705
|
-
let t =
|
|
4783
|
+
function En({ text: e }) {
|
|
4784
|
+
let t = Dn({
|
|
4706
4785
|
text: e,
|
|
4707
4786
|
frameWidth: q,
|
|
4708
4787
|
splitByGrapheme: !0
|
|
4709
4788
|
});
|
|
4710
4789
|
return Math.max(q, t);
|
|
4711
4790
|
}
|
|
4712
|
-
function
|
|
4713
|
-
let r =
|
|
4791
|
+
function Dn({ text: e, frameWidth: t, splitByGrapheme: n }) {
|
|
4792
|
+
let r = Pn({ text: e });
|
|
4714
4793
|
e.set({
|
|
4715
4794
|
autoExpand: !1,
|
|
4716
4795
|
width: Math.max(q, t),
|
|
4717
4796
|
splitByGrapheme: n
|
|
4718
4797
|
}), e.initDimensions();
|
|
4719
|
-
let i =
|
|
4720
|
-
return
|
|
4798
|
+
let i = An({ text: e });
|
|
4799
|
+
return Fn({
|
|
4721
4800
|
text: e,
|
|
4722
4801
|
state: r
|
|
4723
4802
|
}), i;
|
|
4724
4803
|
}
|
|
4725
|
-
function
|
|
4804
|
+
function On({ alignV: e, frameHeight: t, frameTop: n, textHeight: r }) {
|
|
4726
4805
|
let i = Math.max(0, t - r);
|
|
4727
4806
|
return e === "top" ? n : e === "bottom" ? n + i : n + i / 2;
|
|
4728
4807
|
}
|
|
4729
|
-
function
|
|
4730
|
-
let n = Math.max(q, t), r =
|
|
4808
|
+
function kn({ text: e, frameWidth: t }) {
|
|
4809
|
+
let n = Math.max(q, t), r = Pn({ text: e });
|
|
4731
4810
|
e.set({
|
|
4732
4811
|
autoExpand: !1,
|
|
4733
4812
|
width: n,
|
|
4734
4813
|
splitByGrapheme: !1
|
|
4735
4814
|
}), e.initDimensions();
|
|
4736
|
-
let i =
|
|
4737
|
-
return
|
|
4815
|
+
let i = In({ text: e }) > n + tn;
|
|
4816
|
+
return Fn({
|
|
4738
4817
|
text: e,
|
|
4739
4818
|
state: r
|
|
4740
4819
|
}), i;
|
|
4741
4820
|
}
|
|
4742
|
-
function
|
|
4743
|
-
let t =
|
|
4744
|
-
if (t > 0) return
|
|
4821
|
+
function An({ text: e }) {
|
|
4822
|
+
let t = Mn({ text: e });
|
|
4823
|
+
if (t > 0) return Nn({
|
|
4745
4824
|
text: e,
|
|
4746
4825
|
lineCount: t
|
|
4747
4826
|
});
|
|
4748
4827
|
let n = e.text ?? "";
|
|
4749
|
-
return
|
|
4828
|
+
return Nn({
|
|
4750
4829
|
text: e,
|
|
4751
4830
|
lineCount: Math.max(n.split("\n").length, 1)
|
|
4752
4831
|
});
|
|
4753
4832
|
}
|
|
4754
|
-
function
|
|
4833
|
+
function jn({ text: e }) {
|
|
4755
4834
|
let t = e.text ?? "";
|
|
4756
4835
|
return Math.max(t.split("\n").length, 1);
|
|
4757
4836
|
}
|
|
4758
|
-
function
|
|
4837
|
+
function Mn({ text: e }) {
|
|
4759
4838
|
let t = e;
|
|
4760
4839
|
return Array.isArray(t.textLines) ? t.textLines.length : 0;
|
|
4761
4840
|
}
|
|
4762
|
-
function
|
|
4841
|
+
function Nn({ text: e, lineCount: t }) {
|
|
4763
4842
|
let n = q;
|
|
4764
4843
|
for (let r = 0; r < t; r += 1) {
|
|
4765
4844
|
let t = e.getLineWidth(r);
|
|
@@ -4767,7 +4846,7 @@ function An({ text: e, lineCount: t }) {
|
|
|
4767
4846
|
}
|
|
4768
4847
|
return n;
|
|
4769
4848
|
}
|
|
4770
|
-
function
|
|
4849
|
+
function Pn({ text: e }) {
|
|
4771
4850
|
let { autoExpand: t, splitByGrapheme: n, width: r } = e;
|
|
4772
4851
|
return {
|
|
4773
4852
|
autoExpand: t,
|
|
@@ -4775,23 +4854,23 @@ function jn({ text: e }) {
|
|
|
4775
4854
|
width: typeof r == "number" ? r : void 0
|
|
4776
4855
|
};
|
|
4777
4856
|
}
|
|
4778
|
-
function
|
|
4857
|
+
function Fn({ text: e, state: t }) {
|
|
4779
4858
|
let { autoExpand: n, splitByGrapheme: r, width: i } = t, a = {};
|
|
4780
4859
|
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());
|
|
4781
4860
|
}
|
|
4782
|
-
function
|
|
4861
|
+
function In({ text: e }) {
|
|
4783
4862
|
let { dynamicMinWidth: t } = e;
|
|
4784
4863
|
return typeof t == "number" && Number.isFinite(t) ? t : 0;
|
|
4785
4864
|
}
|
|
4786
4865
|
//#endregion
|
|
4787
4866
|
//#region src/editor/shape-manager/shape-runtime.ts
|
|
4788
|
-
var
|
|
4867
|
+
var Ln = ({ group: e }) => {
|
|
4789
4868
|
let t = e;
|
|
4790
4869
|
typeof t.setInteractive == "function" && t.setInteractive(!0), t.set({
|
|
4791
4870
|
interactive: !0,
|
|
4792
4871
|
subTargetCheck: !0
|
|
4793
4872
|
});
|
|
4794
|
-
},
|
|
4873
|
+
}, Rn = ({ text: e }) => {
|
|
4795
4874
|
let t = !!(e.locked || e.group?.locked);
|
|
4796
4875
|
e.set({
|
|
4797
4876
|
hasBorders: !1,
|
|
@@ -4804,7 +4883,7 @@ var Pn = ({ group: e }) => {
|
|
|
4804
4883
|
autoExpand: !1,
|
|
4805
4884
|
shapeNodeType: "text"
|
|
4806
4885
|
}), e.setCoords();
|
|
4807
|
-
},
|
|
4886
|
+
}, zn = ({ group: e }) => {
|
|
4808
4887
|
let { layoutManager: t } = e;
|
|
4809
4888
|
if (!t || typeof t.unsubscribeTargets != "function") return;
|
|
4810
4889
|
let n = e.getObjects();
|
|
@@ -4812,7 +4891,7 @@ var Pn = ({ group: e }) => {
|
|
|
4812
4891
|
target: e,
|
|
4813
4892
|
targets: n
|
|
4814
4893
|
});
|
|
4815
|
-
},
|
|
4894
|
+
}, Bn = ({ group: e }) => {
|
|
4816
4895
|
let t = e.getObjects();
|
|
4817
4896
|
for (let e = 0; e < t.length; e += 1) {
|
|
4818
4897
|
let n = t[e];
|
|
@@ -4823,23 +4902,23 @@ var Pn = ({ group: e }) => {
|
|
|
4823
4902
|
if (n instanceof _) return n;
|
|
4824
4903
|
}
|
|
4825
4904
|
return null;
|
|
4826
|
-
},
|
|
4905
|
+
}, Vn = [
|
|
4827
4906
|
"tl",
|
|
4828
4907
|
"tr",
|
|
4829
4908
|
"bl",
|
|
4830
4909
|
"br"
|
|
4831
|
-
],
|
|
4910
|
+
], Hn = ({ transform: e }) => {
|
|
4832
4911
|
let { originX: t, originY: n } = e;
|
|
4833
4912
|
return (t === "center" || t === .5) && (n === "center" || n === .5);
|
|
4834
|
-
},
|
|
4913
|
+
}, Un = ({ transform: e, x: t, y: n }) => {
|
|
4835
4914
|
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);
|
|
4836
4915
|
r.signX === void 0 && (r.signX = c), r.signY === void 0 && (r.signY = l);
|
|
4837
4916
|
let u = i._getTransformedDimensions(), d = Math.abs(s.x * a / u.x), f = Math.abs(s.y * o / u.y);
|
|
4838
|
-
|
|
4917
|
+
Hn({ transform: r }) && (d *= 2, f *= 2);
|
|
4839
4918
|
let p = !i.lockScalingX && (!i.lockScalingFlip || r.signX === c), m = !i.lockScalingY && (!i.lockScalingFlip || r.signY === l);
|
|
4840
4919
|
return p && i.set("scaleX", d), m && i.set("scaleY", f), a !== i.scaleX || o !== i.scaleY;
|
|
4841
|
-
},
|
|
4842
|
-
let e = b.wrapWithFireEvent("scaling", b.wrapWithFixedAnchor((e, t, n, r) =>
|
|
4920
|
+
}, Wn = () => {
|
|
4921
|
+
let e = b.wrapWithFireEvent("scaling", b.wrapWithFixedAnchor((e, t, n, r) => Un({
|
|
4843
4922
|
transform: t,
|
|
4844
4923
|
x: n,
|
|
4845
4924
|
y: r
|
|
@@ -4855,31 +4934,31 @@ var Pn = ({ group: e }) => {
|
|
|
4855
4934
|
a.uniformScaling = s;
|
|
4856
4935
|
}
|
|
4857
4936
|
};
|
|
4858
|
-
},
|
|
4937
|
+
}, Gn = ({ control: e }) => {
|
|
4859
4938
|
let t = new r({
|
|
4860
4939
|
...e,
|
|
4861
|
-
actionHandler:
|
|
4940
|
+
actionHandler: Wn()
|
|
4862
4941
|
});
|
|
4863
4942
|
return t.shapeFreeScaleCornerControl = !0, t;
|
|
4864
|
-
},
|
|
4943
|
+
}, Kn = ({ group: e }) => {
|
|
4865
4944
|
let t = { ...e.controls };
|
|
4866
|
-
|
|
4945
|
+
Vn.forEach((n) => {
|
|
4867
4946
|
let r = e.controls[n];
|
|
4868
|
-
r && (r.shapeFreeScaleCornerControl || (t[n] =
|
|
4947
|
+
r && (r.shapeFreeScaleCornerControl || (t[n] = Gn({ control: r })));
|
|
4869
4948
|
}), e.controls = t;
|
|
4870
|
-
},
|
|
4871
|
-
function
|
|
4949
|
+
}, qn = "shape-group";
|
|
4950
|
+
function Jn() {
|
|
4872
4951
|
return { performLayout() {} };
|
|
4873
4952
|
}
|
|
4874
|
-
function
|
|
4953
|
+
function Yn({ layoutManager: e }) {
|
|
4875
4954
|
let t = y.getClass("layoutManager");
|
|
4876
4955
|
if (!e) return new t();
|
|
4877
4956
|
let { strategy: n, type: r } = e, i = y.getClass(r);
|
|
4878
4957
|
return n ? new i(new (y.getClass(n))()) : new i();
|
|
4879
4958
|
}
|
|
4880
|
-
var
|
|
4959
|
+
var Xn = class e extends l {
|
|
4881
4960
|
static {
|
|
4882
|
-
this.type =
|
|
4961
|
+
this.type = qn;
|
|
4883
4962
|
}
|
|
4884
4963
|
constructor(e = [], t = {}) {
|
|
4885
4964
|
let { layoutManager: n, objectCaching: r, centeredScaling: i, lockScalingFlip: a, ...o } = t;
|
|
@@ -4902,17 +4981,17 @@ var qn = class e extends l {
|
|
|
4902
4981
|
bottom: this.shapePaddingBottom,
|
|
4903
4982
|
left: this.shapePaddingLeft
|
|
4904
4983
|
} });
|
|
4905
|
-
this.shapePaddingTop = e.top, this.shapePaddingRight = e.right, this.shapePaddingBottom = e.bottom, this.shapePaddingLeft = e.left, this._syncRoundability(),
|
|
4906
|
-
let t =
|
|
4907
|
-
t &&
|
|
4984
|
+
this.shapePaddingTop = e.top, this.shapePaddingRight = e.right, this.shapePaddingBottom = e.bottom, this.shapePaddingLeft = e.left, this._syncRoundability(), Ln({ group: this }), Kn({ group: this });
|
|
4985
|
+
let t = Bn({ group: this });
|
|
4986
|
+
t && Rn({ text: t }), zn({ group: this }), this.setCoords();
|
|
4908
4987
|
}
|
|
4909
4988
|
static async fromObject({ type: t, objects: n = [], layoutManager: r, ...i }, a) {
|
|
4910
4989
|
let [o, s] = await Promise.all([C.enlivenObjects(n, a), C.enlivenObjectEnlivables(i, a)]), c = new e(o, {
|
|
4911
4990
|
...i,
|
|
4912
4991
|
...s,
|
|
4913
|
-
layoutManager:
|
|
4992
|
+
layoutManager: Jn()
|
|
4914
4993
|
});
|
|
4915
|
-
return c.layoutManager =
|
|
4994
|
+
return c.layoutManager = Yn({ layoutManager: r }), c.layoutManager.subscribeTargets({
|
|
4916
4995
|
type: "initialization",
|
|
4917
4996
|
target: c,
|
|
4918
4997
|
targets: c.getObjects()
|
|
@@ -4925,9 +5004,9 @@ var qn = class e extends l {
|
|
|
4925
5004
|
let t = dt({ presetKey: e });
|
|
4926
5005
|
t && (this.shapeCanRound = gt({ preset: t }));
|
|
4927
5006
|
}
|
|
4928
|
-
},
|
|
4929
|
-
y?.setClass && y.setClass(
|
|
4930
|
-
}, J = (e) => e instanceof
|
|
5007
|
+
}, Zn = () => {
|
|
5008
|
+
y?.setClass && y.setClass(Xn, qn);
|
|
5009
|
+
}, J = (e) => e instanceof Xn || e instanceof l && e.shapeComposite === !0, Qn = ({ target: e, subTargets: t = [] }) => {
|
|
4931
5010
|
if (J(e)) return e;
|
|
4932
5011
|
if (e?.group && J(e.group)) return e.group;
|
|
4933
5012
|
for (let e = 0; e < t.length; e += 1) {
|
|
@@ -4937,7 +5016,7 @@ var qn = class e extends l {
|
|
|
4937
5016
|
if (r && J(r)) return r;
|
|
4938
5017
|
}
|
|
4939
5018
|
return null;
|
|
4940
|
-
},
|
|
5019
|
+
}, $n = ({ group: e }) => {
|
|
4941
5020
|
let t = e.getObjects();
|
|
4942
5021
|
for (let e = 0; e < t.length; e += 1) {
|
|
4943
5022
|
let n = t[e];
|
|
@@ -4948,7 +5027,7 @@ var qn = class e extends l {
|
|
|
4948
5027
|
if (!(n instanceof _)) return n;
|
|
4949
5028
|
}
|
|
4950
5029
|
return null;
|
|
4951
|
-
},
|
|
5030
|
+
}, er = ({ group: e }) => {
|
|
4952
5031
|
let t = e.getObjects();
|
|
4953
5032
|
for (let e = 0; e < t.length; e += 1) {
|
|
4954
5033
|
let n = t[e];
|
|
@@ -4960,16 +5039,16 @@ var qn = class e extends l {
|
|
|
4960
5039
|
}
|
|
4961
5040
|
return null;
|
|
4962
5041
|
}, Y = ({ group: e }) => ({
|
|
4963
|
-
shape:
|
|
4964
|
-
text:
|
|
4965
|
-
}),
|
|
4966
|
-
|
|
4967
|
-
},
|
|
5042
|
+
shape: $n({ group: e }),
|
|
5043
|
+
text: er({ group: e })
|
|
5044
|
+
}), tr = ({ group: e }) => {
|
|
5045
|
+
Ln({ group: e });
|
|
5046
|
+
}, nr = ({ transform: e, key: t }) => {
|
|
4968
5047
|
let n = e?.original;
|
|
4969
5048
|
if (!n || typeof n != "object") return null;
|
|
4970
5049
|
let r = n[t];
|
|
4971
5050
|
return typeof r != "number" || !Number.isFinite(r) ? null : r;
|
|
4972
|
-
},
|
|
5051
|
+
}, rr = ({ value: e }) => e === "left" || e === "center" || e === "right" || typeof e == "number" && Number.isFinite(e) ? e : null, ir = ({ value: e }) => e === "top" || e === "center" || e === "bottom" || typeof e == "number" && Number.isFinite(e) ? e : null, ar = ({ transform: e }) => {
|
|
4973
5052
|
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;
|
|
4974
5053
|
return {
|
|
4975
5054
|
canScaleWidth: o,
|
|
@@ -4977,37 +5056,37 @@ var qn = class e extends l {
|
|
|
4977
5056
|
isCornerScaleAction: r,
|
|
4978
5057
|
isVerticalOnlyScale: s && !o
|
|
4979
5058
|
};
|
|
4980
|
-
},
|
|
5059
|
+
}, or = ({ event: e, group: t, transform: n, canvas: r }) => {
|
|
4981
5060
|
if (!e) return null;
|
|
4982
5061
|
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;
|
|
4983
5062
|
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;
|
|
4984
|
-
},
|
|
5063
|
+
}, sr = ({ group: e, originX: t, originY: n }) => {
|
|
4985
5064
|
if (t === null || n === null) return null;
|
|
4986
5065
|
let r = e, i = typeof r.getRelativeCenterPoint == "function" ? r.getRelativeCenterPoint() : e.getCenterPoint();
|
|
4987
5066
|
return typeof r.translateToOriginPoint == "function" ? r.translateToOriginPoint(i, t, n) : i;
|
|
4988
|
-
},
|
|
5067
|
+
}, cr = ({ state: e, transform: t }) => {
|
|
4989
5068
|
if (!t || e.startTransformOriginX === null && e.startTransformOriginY === null) return !1;
|
|
4990
|
-
let n =
|
|
5069
|
+
let n = rr({ value: t.originX }), r = ir({ value: t.originY });
|
|
4991
5070
|
return n !== e.startTransformOriginX || r !== e.startTransformOriginY;
|
|
4992
|
-
},
|
|
5071
|
+
}, lr = ({ state: e, transform: t }) => !t || !e.startTransformCorner ? !1 : t.corner !== e.startTransformCorner;
|
|
4993
5072
|
//#endregion
|
|
4994
5073
|
//#region src/editor/shape-manager/scaling/shape-scaling-preview.ts
|
|
4995
|
-
function
|
|
5074
|
+
function ur({ size: e, scale: t, strokeWidth: n, minSize: r, scaleEpsilon: i }) {
|
|
4996
5075
|
let a = Math.max(i, Math.abs(t) || 1), o = Math.max(0, n);
|
|
4997
5076
|
return o <= 0 ? Math.max(r, e / a) : Math.max(r, e / a + o - o / a);
|
|
4998
5077
|
}
|
|
4999
|
-
function
|
|
5078
|
+
function dr({ group: e, shape: t, width: n, height: r, scaleX: i, scaleY: a, minSize: o, scaleEpsilon: s }) {
|
|
5000
5079
|
let c = Math.max(0, e.shapeStrokeWidth ?? 0);
|
|
5001
5080
|
xt({
|
|
5002
5081
|
shape: t,
|
|
5003
|
-
width:
|
|
5082
|
+
width: ur({
|
|
5004
5083
|
size: n,
|
|
5005
5084
|
scale: i,
|
|
5006
5085
|
strokeWidth: c,
|
|
5007
5086
|
minSize: o,
|
|
5008
5087
|
scaleEpsilon: s
|
|
5009
5088
|
}),
|
|
5010
|
-
height:
|
|
5089
|
+
height: ur({
|
|
5011
5090
|
size: r,
|
|
5012
5091
|
scale: a,
|
|
5013
5092
|
strokeWidth: c,
|
|
@@ -5018,54 +5097,45 @@ function cr({ group: e, shape: t, width: n, height: r, scaleX: i, scaleY: a, min
|
|
|
5018
5097
|
strokeWidth: c
|
|
5019
5098
|
});
|
|
5020
5099
|
}
|
|
5021
|
-
function
|
|
5022
|
-
let
|
|
5023
|
-
text: e,
|
|
5024
|
-
width: t,
|
|
5025
|
-
height: n,
|
|
5026
|
-
alignV: a ?? "middle",
|
|
5027
|
-
padding: r
|
|
5028
|
-
});
|
|
5100
|
+
function fr({ text: e, layout: t, alignH: n, scaleX: r, scaleY: i, scaleEpsilon: a }) {
|
|
5101
|
+
let o = Math.max(a, Math.abs(r) || 1), s = Math.max(a, Math.abs(i) || 1), c = n ?? "center";
|
|
5029
5102
|
e.set({
|
|
5030
5103
|
autoExpand: !1,
|
|
5031
|
-
textAlign:
|
|
5032
|
-
width:
|
|
5033
|
-
splitByGrapheme:
|
|
5034
|
-
left:
|
|
5035
|
-
top:
|
|
5104
|
+
textAlign: c,
|
|
5105
|
+
width: t.frame.width,
|
|
5106
|
+
splitByGrapheme: t.splitByGrapheme,
|
|
5107
|
+
left: t.frame.left / o,
|
|
5108
|
+
top: t.textTop / s,
|
|
5036
5109
|
originX: "left",
|
|
5037
5110
|
originY: "top",
|
|
5038
|
-
scaleX: 1 /
|
|
5039
|
-
scaleY: 1 /
|
|
5111
|
+
scaleX: 1 / o,
|
|
5112
|
+
scaleY: 1 / s
|
|
5040
5113
|
}), e.initDimensions(), e.setCoords();
|
|
5041
5114
|
}
|
|
5042
|
-
var
|
|
5043
|
-
let
|
|
5115
|
+
var pr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY: o, minSize: s, scaleEpsilon: c }) => {
|
|
5116
|
+
let l = Math.max(c, Math.abs(a) || 1), u = Math.max(c, Math.abs(o) || 1);
|
|
5044
5117
|
e.set({
|
|
5045
|
-
width: r /
|
|
5046
|
-
height:
|
|
5118
|
+
width: r.width / l,
|
|
5119
|
+
height: r.height / u,
|
|
5047
5120
|
dirty: !0
|
|
5048
|
-
}),
|
|
5121
|
+
}), dr({
|
|
5049
5122
|
group: e,
|
|
5050
5123
|
shape: t,
|
|
5051
|
-
width: r,
|
|
5052
|
-
height:
|
|
5053
|
-
scaleX:
|
|
5054
|
-
scaleY:
|
|
5055
|
-
minSize:
|
|
5056
|
-
scaleEpsilon:
|
|
5057
|
-
}),
|
|
5124
|
+
width: r.width,
|
|
5125
|
+
height: r.height,
|
|
5126
|
+
scaleX: a,
|
|
5127
|
+
scaleY: o,
|
|
5128
|
+
minSize: s,
|
|
5129
|
+
scaleEpsilon: c
|
|
5130
|
+
}), fr({
|
|
5058
5131
|
text: n,
|
|
5059
|
-
|
|
5060
|
-
|
|
5061
|
-
|
|
5062
|
-
|
|
5063
|
-
|
|
5064
|
-
scaleX: c,
|
|
5065
|
-
scaleY: l,
|
|
5066
|
-
scaleEpsilon: d
|
|
5132
|
+
layout: r,
|
|
5133
|
+
alignH: i,
|
|
5134
|
+
scaleX: a,
|
|
5135
|
+
scaleY: o,
|
|
5136
|
+
scaleEpsilon: c
|
|
5067
5137
|
});
|
|
5068
|
-
}, X = 1, Z = 1e-4,
|
|
5138
|
+
}, X = 1, Z = 1e-4, mr = .5, hr = class e {
|
|
5069
5139
|
constructor({ canvas: t }) {
|
|
5070
5140
|
this.handleObjectScaling = (t) => {
|
|
5071
5141
|
let { target: n, transform: r } = t;
|
|
@@ -5081,42 +5151,42 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5081
5151
|
text: o,
|
|
5082
5152
|
constraintPadding: s,
|
|
5083
5153
|
transform: r
|
|
5084
|
-
}), { isCornerScaleAction: l } =
|
|
5154
|
+
}), { isCornerScaleAction: l } = ar({ transform: r }), u = !!(t.e && "shiftKey" in t.e && t.e.shiftKey);
|
|
5085
5155
|
c.isProportionalScaling = l && u;
|
|
5086
|
-
let d = i.left ?? 0, f = i.top ?? 0, p = !!i.flipX, m = !!i.flipY, h = i.shapeAlignHorizontal ?? "center", g =
|
|
5156
|
+
let d = i.left ?? 0, f = i.top ?? 0, p = !!i.flipX, m = !!i.flipY, h = i.shapeAlignHorizontal ?? "center", g = this._resolveScalingDecision({
|
|
5087
5157
|
group: i,
|
|
5088
5158
|
text: o,
|
|
5089
5159
|
constraintPadding: s,
|
|
5090
5160
|
state: c,
|
|
5091
5161
|
transform: r
|
|
5092
|
-
}),
|
|
5162
|
+
}), _ = this._resolvePreviewLayout({
|
|
5093
5163
|
group: i,
|
|
5094
|
-
|
|
5095
|
-
|
|
5096
|
-
|
|
5097
|
-
|
|
5164
|
+
text: o,
|
|
5165
|
+
state: c,
|
|
5166
|
+
appliedScaleX: g.appliedScaleX,
|
|
5167
|
+
appliedScaleY: g.appliedScaleY,
|
|
5168
|
+
minimumHeight: g.previewHeight
|
|
5169
|
+
}), v = Math.abs(i.scaleX ?? 1) || 1, y = Math.abs(i.scaleY ?? 1) || 1;
|
|
5170
|
+
(g.shouldHandleAsNoop || g.shouldRestoreLastAllowedTransform || Math.abs(g.appliedScaleX - v) > Z || Math.abs(g.appliedScaleY - y) > Z) && this._applyResolvedScalingState({
|
|
5098
5171
|
group: i,
|
|
5099
5172
|
state: c,
|
|
5100
|
-
shouldHandleAsNoop:
|
|
5101
|
-
scaleX:
|
|
5102
|
-
scaleY:
|
|
5103
|
-
}),
|
|
5173
|
+
shouldHandleAsNoop: g.shouldHandleAsNoop,
|
|
5174
|
+
scaleX: g.appliedScaleX,
|
|
5175
|
+
scaleY: g.appliedScaleY
|
|
5176
|
+
}), pr({
|
|
5104
5177
|
group: i,
|
|
5105
5178
|
shape: a,
|
|
5106
5179
|
text: o,
|
|
5107
|
-
|
|
5108
|
-
height: _.previewHeight,
|
|
5109
|
-
padding: v,
|
|
5180
|
+
layout: _,
|
|
5110
5181
|
alignH: h,
|
|
5111
|
-
|
|
5112
|
-
|
|
5113
|
-
scaleY: _.appliedScaleY,
|
|
5182
|
+
scaleX: g.appliedScaleX,
|
|
5183
|
+
scaleY: g.appliedScaleY,
|
|
5114
5184
|
minSize: X,
|
|
5115
5185
|
scaleEpsilon: Z
|
|
5116
5186
|
}), this._restoreScalingAnchorPosition({
|
|
5117
5187
|
group: i,
|
|
5118
5188
|
state: c
|
|
5119
|
-
}), !
|
|
5189
|
+
}), !g.shouldHandleAsNoop && !g.shouldRestoreLastAllowedTransform && this._storeLastAllowedTransform({
|
|
5120
5190
|
group: i,
|
|
5121
5191
|
state: c,
|
|
5122
5192
|
scaleX: i.scaleX ?? 1,
|
|
@@ -5131,77 +5201,77 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5131
5201
|
if (!n) return;
|
|
5132
5202
|
let { target: r } = n;
|
|
5133
5203
|
if (!J(r)) return;
|
|
5134
|
-
let { canScaleHeight: i, canScaleWidth: a } =
|
|
5204
|
+
let { canScaleHeight: i, canScaleWidth: a } = ar({ transform: n });
|
|
5135
5205
|
if (!a && !i) return;
|
|
5136
5206
|
let o = r, s = this.scalingState.get(o);
|
|
5137
5207
|
if (!s || s.isProportionalScaling) return;
|
|
5138
5208
|
let { shape: c, text: l } = Y({ group: o });
|
|
5139
5209
|
if (!c || !l) return;
|
|
5140
|
-
let u = e._resolveScalingConstraintPadding({ group: o }), d = o.shapeAlignHorizontal ?? "center", f =
|
|
5210
|
+
let u = e._resolveScalingConstraintPadding({ group: o }), d = o.shapeAlignHorizontal ?? "center", f = Math.abs(o.scaleX ?? s.lastAllowedScaleX ?? 1) || 1, p = Math.abs(o.scaleY ?? s.lastAllowedScaleY ?? 1) || 1, m = {
|
|
5141
5211
|
...t,
|
|
5142
5212
|
transform: n
|
|
5143
|
-
},
|
|
5213
|
+
}, h = f, g = p, _ = null, v = !1, y = !1;
|
|
5144
5214
|
if (a && this._hasPointerReachedScaleOrigin({
|
|
5145
|
-
event:
|
|
5215
|
+
event: m,
|
|
5146
5216
|
group: o,
|
|
5147
5217
|
axis: "x"
|
|
5148
5218
|
})) {
|
|
5149
|
-
let t =
|
|
5219
|
+
let t = fn({
|
|
5150
5220
|
text: l,
|
|
5151
5221
|
padding: u,
|
|
5152
5222
|
resolvePaddingForWidth: ({ width: t }) => e._resolveScalingConstraintPadding({
|
|
5153
5223
|
group: o,
|
|
5154
5224
|
width: t,
|
|
5155
|
-
height: Math.max(X, s.startHeight *
|
|
5225
|
+
height: Math.max(X, s.startHeight * g)
|
|
5156
5226
|
})
|
|
5157
5227
|
}), n = Math.max(X / s.startWidth, t / s.startWidth);
|
|
5158
|
-
s.lastAllowedScaleX > n + Z && (
|
|
5228
|
+
s.lastAllowedScaleX > n + Z && (h = n, v = !0, y = !0);
|
|
5159
5229
|
}
|
|
5160
5230
|
if (i && this._hasPointerReachedScaleOrigin({
|
|
5161
|
-
event:
|
|
5231
|
+
event: m,
|
|
5162
5232
|
group: o,
|
|
5163
5233
|
axis: "y"
|
|
5164
5234
|
})) {
|
|
5165
|
-
|
|
5235
|
+
_ = this._resolveMinimumTextFitHeight({
|
|
5166
5236
|
group: o,
|
|
5167
5237
|
text: l,
|
|
5168
|
-
width: Math.max(X, s.startWidth *
|
|
5238
|
+
width: Math.max(X, s.startWidth * h),
|
|
5169
5239
|
padding: u
|
|
5170
5240
|
});
|
|
5171
|
-
let e = Math.max(X / s.startHeight,
|
|
5172
|
-
s.lastAllowedScaleY > e + Z && (
|
|
5241
|
+
let e = Math.max(X / s.startHeight, _ / s.startHeight);
|
|
5242
|
+
s.lastAllowedScaleY > e + Z && (g = e, y = !0);
|
|
5173
5243
|
}
|
|
5174
|
-
if (!
|
|
5175
|
-
let
|
|
5244
|
+
if (!y) return;
|
|
5245
|
+
let b = this._resolvePreviewDimensions({
|
|
5176
5246
|
group: o,
|
|
5177
5247
|
text: l,
|
|
5178
5248
|
constraintPadding: u,
|
|
5179
5249
|
state: s,
|
|
5180
|
-
appliedScaleX:
|
|
5181
|
-
appliedScaleY:
|
|
5182
|
-
minimumHeight:
|
|
5183
|
-
}),
|
|
5250
|
+
appliedScaleX: h,
|
|
5251
|
+
appliedScaleY: g,
|
|
5252
|
+
minimumHeight: v ? null : _
|
|
5253
|
+
}), x = this._resolvePreviewLayout({
|
|
5184
5254
|
group: o,
|
|
5185
|
-
|
|
5186
|
-
|
|
5255
|
+
text: l,
|
|
5256
|
+
state: s,
|
|
5257
|
+
appliedScaleX: h,
|
|
5258
|
+
appliedScaleY: g,
|
|
5259
|
+
minimumHeight: b.previewHeight
|
|
5187
5260
|
});
|
|
5188
5261
|
this._applyResolvedScalingState({
|
|
5189
5262
|
group: o,
|
|
5190
5263
|
state: s,
|
|
5191
5264
|
shouldHandleAsNoop: !1,
|
|
5192
|
-
scaleX:
|
|
5193
|
-
scaleY:
|
|
5194
|
-
}),
|
|
5265
|
+
scaleX: h,
|
|
5266
|
+
scaleY: g
|
|
5267
|
+
}), pr({
|
|
5195
5268
|
group: o,
|
|
5196
5269
|
shape: c,
|
|
5197
5270
|
text: l,
|
|
5198
|
-
|
|
5199
|
-
height: x.previewHeight,
|
|
5200
|
-
padding: S,
|
|
5271
|
+
layout: x,
|
|
5201
5272
|
alignH: d,
|
|
5202
|
-
|
|
5203
|
-
|
|
5204
|
-
scaleY: _,
|
|
5273
|
+
scaleX: h,
|
|
5274
|
+
scaleY: g,
|
|
5205
5275
|
minSize: X,
|
|
5206
5276
|
scaleEpsilon: Z
|
|
5207
5277
|
}), this._restoreScalingAnchorPosition({
|
|
@@ -5210,8 +5280,8 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5210
5280
|
}), this._storeLastAllowedTransform({
|
|
5211
5281
|
group: o,
|
|
5212
5282
|
state: s,
|
|
5213
|
-
scaleX:
|
|
5214
|
-
scaleY:
|
|
5283
|
+
scaleX: h,
|
|
5284
|
+
scaleY: g,
|
|
5215
5285
|
currentLeft: s.lastAllowedLeft,
|
|
5216
5286
|
currentTop: s.lastAllowedTop,
|
|
5217
5287
|
currentFlipX: s.lastAllowedFlipX,
|
|
@@ -5238,7 +5308,7 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5238
5308
|
this.scalingState.delete(r);
|
|
5239
5309
|
return;
|
|
5240
5310
|
}
|
|
5241
|
-
let p = r.shapeAlignHorizontal ?? "center", m = r.shapeAlignVertical ?? "middle", h = e._resolveScalingConstraintPadding({ group: r }), g = t.transform ?
|
|
5311
|
+
let p = r.shapeAlignHorizontal ?? "center", m = r.shapeAlignVertical ?? "middle", h = e._resolveScalingConstraintPadding({ group: r }), g = t.transform ? ar({ transform: t.transform }) : null, _ = i?.canScaleWidth ?? g?.canScaleWidth ?? Math.abs(a - 1) > Z, v = i?.canScaleHeight ?? g?.canScaleHeight ?? Math.abs(o - 1) > Z, y = i?.lastAllowedScaleX ?? a, b = i?.lastAllowedScaleY ?? o, x = fn({
|
|
5242
5312
|
text: f,
|
|
5243
5313
|
padding: h,
|
|
5244
5314
|
resolvePaddingForWidth: ({ width: t }) => e._resolveScalingConstraintPadding({
|
|
@@ -5267,7 +5337,7 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5267
5337
|
state: i
|
|
5268
5338
|
}) && (b = Math.max(X / c, e / c));
|
|
5269
5339
|
}
|
|
5270
|
-
let S = _ ? Math.max(X, s * y) : s, C = v ? Math.max(X, c * b) : u, w = Math.abs(S - s) >
|
|
5340
|
+
let S = _ ? Math.max(X, s * y) : s, C = v ? Math.max(X, c * b) : u, w = Math.abs(S - s) > mr, T = Math.abs(C - c) > mr, E = w || T, D = S, O = C;
|
|
5271
5341
|
if (!E && i) {
|
|
5272
5342
|
this._restoreShapeStateWithoutResize({
|
|
5273
5343
|
group: r,
|
|
@@ -5302,7 +5372,7 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5302
5372
|
width: D,
|
|
5303
5373
|
height: O
|
|
5304
5374
|
});
|
|
5305
|
-
|
|
5375
|
+
ln({
|
|
5306
5376
|
group: r,
|
|
5307
5377
|
shape: d,
|
|
5308
5378
|
text: f,
|
|
@@ -5331,10 +5401,10 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5331
5401
|
}, this.canvas = t, this.scalingState = /* @__PURE__ */ new WeakMap();
|
|
5332
5402
|
}
|
|
5333
5403
|
_resolveScalingDecision({ group: e, text: t, constraintPadding: n, state: r, transform: i }) {
|
|
5334
|
-
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 =
|
|
5404
|
+
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 = cr({
|
|
5335
5405
|
state: r,
|
|
5336
5406
|
transform: i
|
|
5337
|
-
}), d =
|
|
5407
|
+
}), d = lr({
|
|
5338
5408
|
state: r,
|
|
5339
5409
|
transform: i
|
|
5340
5410
|
});
|
|
@@ -5368,7 +5438,7 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5368
5438
|
};
|
|
5369
5439
|
}
|
|
5370
5440
|
_resolveScalingConstraintState({ group: t, text: n, constraintPadding: r, state: i, transform: a, scaleX: o, scaleY: s }) {
|
|
5371
|
-
let { startHeight: c, startWidth: l, cannotScaleDownAtStart: u, crossedOppositeCorner: d, isProportionalScaling: f, lastAllowedScaleX: p, lastAllowedScaleY: m, startScaleY: h } = i, g = Math.max(X, l * o), _ = Math.max(X, c * s), v = o < p - Z, y = s < m - Z, b = s < h - Z, { canScaleHeight: x, canScaleWidth: S, isVerticalOnlyScale: C } =
|
|
5441
|
+
let { startHeight: c, startWidth: l, cannotScaleDownAtStart: u, crossedOppositeCorner: d, isProportionalScaling: f, lastAllowedScaleX: p, lastAllowedScaleY: m, startScaleY: h } = i, g = Math.max(X, l * o), _ = Math.max(X, c * s), v = o < p - Z, y = s < m - Z, b = s < h - Z, { canScaleHeight: x, canScaleWidth: S, isVerticalOnlyScale: C } = ar({ transform: a }), w = S && v ? fn({
|
|
5372
5442
|
text: n,
|
|
5373
5443
|
padding: r,
|
|
5374
5444
|
resolvePaddingForWidth: ({ width: n }) => e._resolveScalingConstraintPadding({
|
|
@@ -5393,7 +5463,7 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5393
5463
|
};
|
|
5394
5464
|
}
|
|
5395
5465
|
_resolvePreviewDimensions({ group: t, text: n, constraintPadding: r, state: i, appliedScaleX: a, appliedScaleY: o, minimumHeight: s }) {
|
|
5396
|
-
let c = i.canScaleWidth ? Math.max(X, i.startWidth * a) : i.startWidth, l = i.canScaleHeight ? Math.max(X, i.startHeight * o) : i.startManualBaseHeight, u = s ??
|
|
5466
|
+
let c = i.canScaleWidth ? Math.max(X, i.startWidth * a) : i.startWidth, l = i.canScaleHeight ? Math.max(X, i.startHeight * o) : i.startManualBaseHeight, u = s ?? mn({
|
|
5397
5467
|
text: n,
|
|
5398
5468
|
width: c,
|
|
5399
5469
|
height: l,
|
|
@@ -5409,6 +5479,21 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5409
5479
|
previewHeight: Math.max(l, u)
|
|
5410
5480
|
};
|
|
5411
5481
|
}
|
|
5482
|
+
_resolvePreviewLayout({ group: t, text: n, state: r, appliedScaleX: i, appliedScaleY: a, minimumHeight: o }) {
|
|
5483
|
+
let s = r.canScaleWidth ? Math.max(X, r.startWidth * i) : r.startWidth, c = r.canScaleHeight ? Math.max(X, r.startHeight * a) : r.startManualBaseHeight;
|
|
5484
|
+
return cn({
|
|
5485
|
+
text: n,
|
|
5486
|
+
width: s,
|
|
5487
|
+
height: o == null ? c : Math.max(c, o),
|
|
5488
|
+
alignV: t.shapeAlignVertical ?? "middle",
|
|
5489
|
+
padding: e._resolveUserPadding({ group: t }),
|
|
5490
|
+
resolveInternalShapeTextInset: ({ width: n, height: r }) => e._resolveInternalShapeTextInset({
|
|
5491
|
+
group: t,
|
|
5492
|
+
width: n,
|
|
5493
|
+
height: r
|
|
5494
|
+
})
|
|
5495
|
+
});
|
|
5496
|
+
}
|
|
5412
5497
|
_applyResolvedScalingState({ group: e, state: t, shouldHandleAsNoop: n, scaleX: r, scaleY: i }) {
|
|
5413
5498
|
t.blockedScaleAttempt = n, e.shapeScalingNoopTransform = n;
|
|
5414
5499
|
let a = n ? t.startScaleX : r, o = n ? t.startScaleY : i, s = n ? t.startLeft : t.lastAllowedLeft, c = n ? t.startTop : t.lastAllowedTop;
|
|
@@ -5431,7 +5516,7 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5431
5516
|
if (!r) return !1;
|
|
5432
5517
|
let { transform: i } = e;
|
|
5433
5518
|
if (!i) return !1;
|
|
5434
|
-
let { canScaleWidth: a } =
|
|
5519
|
+
let { canScaleWidth: a } = ar({ transform: i });
|
|
5435
5520
|
if (!a || !this._hasPointerReachedScaleOrigin({
|
|
5436
5521
|
event: e,
|
|
5437
5522
|
group: t,
|
|
@@ -5444,7 +5529,7 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5444
5529
|
if (!r) return !1;
|
|
5445
5530
|
let { transform: i } = e;
|
|
5446
5531
|
if (!i) return !1;
|
|
5447
|
-
let { canScaleHeight: a } =
|
|
5532
|
+
let { canScaleHeight: a } = ar({ transform: i });
|
|
5448
5533
|
if (!a || !this._hasPointerReachedScaleOrigin({
|
|
5449
5534
|
event: e,
|
|
5450
5535
|
group: t,
|
|
@@ -5458,7 +5543,7 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5458
5543
|
if (!r) return !1;
|
|
5459
5544
|
let i = r, a = n === "x" ? i.signX : i.signY;
|
|
5460
5545
|
if (typeof a != "number" || !Number.isFinite(a)) return !1;
|
|
5461
|
-
let o =
|
|
5546
|
+
let o = or({
|
|
5462
5547
|
event: e.e,
|
|
5463
5548
|
group: t,
|
|
5464
5549
|
transform: r,
|
|
@@ -5475,19 +5560,19 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5475
5560
|
let a = this._resolveScalingStartDimensions({
|
|
5476
5561
|
group: e,
|
|
5477
5562
|
transform: r
|
|
5478
|
-
}), o =
|
|
5563
|
+
}), o = nr({
|
|
5479
5564
|
transform: r,
|
|
5480
5565
|
key: "scaleX"
|
|
5481
|
-
}), s =
|
|
5566
|
+
}), s = nr({
|
|
5482
5567
|
transform: r,
|
|
5483
5568
|
key: "scaleY"
|
|
5484
|
-
}), c =
|
|
5569
|
+
}), c = nr({
|
|
5485
5570
|
transform: r,
|
|
5486
5571
|
key: "left"
|
|
5487
|
-
}), l =
|
|
5572
|
+
}), l = nr({
|
|
5488
5573
|
transform: r,
|
|
5489
5574
|
key: "top"
|
|
5490
|
-
}), 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 =
|
|
5575
|
+
}), 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 = rr({ value: r?.original?.originX ?? r?.originX }), h = ir({ value: r?.original?.originY ?? r?.originY }), g = typeof r?.corner == "string" ? r.corner : null, _ = sr({
|
|
5491
5576
|
group: e,
|
|
5492
5577
|
originX: m,
|
|
5493
5578
|
originY: h
|
|
@@ -5531,7 +5616,7 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5531
5616
|
return i;
|
|
5532
5617
|
}
|
|
5533
5618
|
_resolveMinimumTextFitHeight({ group: t, text: n, width: r, padding: i }) {
|
|
5534
|
-
return
|
|
5619
|
+
return mn({
|
|
5535
5620
|
text: n,
|
|
5536
5621
|
width: r,
|
|
5537
5622
|
height: X,
|
|
@@ -5563,17 +5648,6 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5563
5648
|
strokeWidth: e.shapeStrokeWidth
|
|
5564
5649
|
});
|
|
5565
5650
|
}
|
|
5566
|
-
static _resolveEffectivePadding({ group: t, width: n, height: r }) {
|
|
5567
|
-
let i = Math.max(X, n ?? t.shapeBaseWidth ?? t.width ?? t.shapeManualBaseWidth ?? X), a = Math.max(X, r ?? t.shapeBaseHeight ?? t.height ?? t.shapeManualBaseHeight ?? X), o = e._resolveUserPadding({ group: t });
|
|
5568
|
-
return Ht({
|
|
5569
|
-
base: e._resolveInternalShapeTextInset({
|
|
5570
|
-
group: t,
|
|
5571
|
-
width: i,
|
|
5572
|
-
height: a
|
|
5573
|
-
}),
|
|
5574
|
-
addition: o
|
|
5575
|
-
});
|
|
5576
|
-
}
|
|
5577
5651
|
static _resolveScalingConstraintPadding({ group: t, width: n, height: r }) {
|
|
5578
5652
|
let i = Math.max(X, n ?? t.shapeBaseWidth ?? t.width ?? t.shapeManualBaseWidth ?? X), a = Math.max(X, r ?? t.shapeBaseHeight ?? t.height ?? t.shapeManualBaseHeight ?? X);
|
|
5579
5653
|
return e._resolveInternalShapeTextInset({
|
|
@@ -5592,7 +5666,7 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5592
5666
|
}
|
|
5593
5667
|
_restoreShapeStateWithoutResize({ group: t, shape: n, text: r, state: i, startWidth: a, startHeight: o, alignH: s, alignV: c, userPadding: l }) {
|
|
5594
5668
|
let u = Math.max(X, t.shapeBaseWidth ?? t.width ?? a), d = Math.max(X, t.shapeBaseHeight ?? t.height ?? o);
|
|
5595
|
-
|
|
5669
|
+
ln({
|
|
5596
5670
|
group: t,
|
|
5597
5671
|
shape: n,
|
|
5598
5672
|
text: r,
|
|
@@ -5649,7 +5723,7 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5649
5723
|
});
|
|
5650
5724
|
}
|
|
5651
5725
|
_resolveScalingStartDimensions({ group: e, transform: t }) {
|
|
5652
|
-
let { canScaleWidth: n, canScaleHeight: r } =
|
|
5726
|
+
let { canScaleWidth: n, canScaleHeight: r } = ar({ transform: t }), i = Math.max(X, e.shapeBaseWidth ?? e.width ?? e.shapeManualBaseWidth ?? X), a = Math.max(X, e.shapeBaseHeight ?? e.height ?? e.shapeManualBaseHeight ?? X);
|
|
5653
5727
|
return {
|
|
5654
5728
|
startWidth: i,
|
|
5655
5729
|
startHeight: a,
|
|
@@ -5668,10 +5742,10 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5668
5742
|
height: s
|
|
5669
5743
|
};
|
|
5670
5744
|
}
|
|
5671
|
-
},
|
|
5745
|
+
}, gr = class {
|
|
5672
5746
|
constructor({ canvas: e }) {
|
|
5673
5747
|
this.handleMouseDown = (e) => {
|
|
5674
|
-
let { target: t, e: n, subTargets: r = [] } = e, i =
|
|
5748
|
+
let { target: t, e: n, subTargets: r = [] } = e, i = Qn({
|
|
5675
5749
|
target: t,
|
|
5676
5750
|
subTargets: r
|
|
5677
5751
|
});
|
|
@@ -5681,7 +5755,7 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5681
5755
|
let o = this.canvas.getActiveObject(), s = o === i;
|
|
5682
5756
|
if (!(o === a && a.isEditing)) {
|
|
5683
5757
|
if (!s) {
|
|
5684
|
-
a.isEditing ||
|
|
5758
|
+
a.isEditing || Rn({ text: a });
|
|
5685
5759
|
return;
|
|
5686
5760
|
}
|
|
5687
5761
|
n instanceof MouseEvent && (n.detail < 2 || this.enterTextEditing({ group: i }));
|
|
@@ -5701,14 +5775,14 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5701
5775
|
J(r) && (this._restoreTextEditingInteractionMode({
|
|
5702
5776
|
group: r,
|
|
5703
5777
|
text: n
|
|
5704
|
-
}),
|
|
5705
|
-
}, this.canvas = e, this.editingInteractionState = /* @__PURE__ */ new WeakMap();
|
|
5778
|
+
}), Rn({ text: n }), this.canvas.getActiveObject() === n && this.canvas.setActiveObject(r), this.canvas.requestRenderAll());
|
|
5779
|
+
}, this.canvas = e, this.editingInteractionState = /* @__PURE__ */ new WeakMap(), this.editingTargetResolverState = void 0;
|
|
5706
5780
|
}
|
|
5707
5781
|
enterTextEditing({ group: e }) {
|
|
5708
5782
|
let { text: t } = Y({ group: e });
|
|
5709
5783
|
if (t) {
|
|
5710
5784
|
if (e.locked || t.locked) {
|
|
5711
|
-
|
|
5785
|
+
Rn({ text: t }), this.canvas.requestRenderAll();
|
|
5712
5786
|
return;
|
|
5713
5787
|
}
|
|
5714
5788
|
this._enterTextEditingInteractionMode({
|
|
@@ -5742,6 +5816,9 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5742
5816
|
}), t.set({
|
|
5743
5817
|
lockMovementX: !0,
|
|
5744
5818
|
lockMovementY: !0
|
|
5819
|
+
}), this._installEditingTargetResolver({
|
|
5820
|
+
group: e,
|
|
5821
|
+
text: t
|
|
5745
5822
|
}), e.setCoords(), t.setCoords();
|
|
5746
5823
|
}
|
|
5747
5824
|
_restoreTextEditingInteractionMode({ group: e, text: t }) {
|
|
@@ -5756,9 +5833,40 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5756
5833
|
}), t.set({
|
|
5757
5834
|
lockMovementX: n.textLockMovementX,
|
|
5758
5835
|
lockMovementY: n.textLockMovementY
|
|
5759
|
-
}), this.editingInteractionState.delete(e), e.setCoords(), t.setCoords());
|
|
5836
|
+
}), this._restoreEditingTargetResolver(), this.editingInteractionState.delete(e), e.setCoords(), t.setCoords());
|
|
5837
|
+
}
|
|
5838
|
+
_installEditingTargetResolver({ group: e, text: t }) {
|
|
5839
|
+
let n = this.editingTargetResolverState;
|
|
5840
|
+
if (n?.group === e && n.text === t) return;
|
|
5841
|
+
this._restoreEditingTargetResolver();
|
|
5842
|
+
let r = this.canvas, i = r.findTarget.bind(r);
|
|
5843
|
+
r.findTarget = (n) => {
|
|
5844
|
+
let r = i(n);
|
|
5845
|
+
if (this.canvas.getActiveObject() !== t || !t.isEditing || r.target === t || Qn({
|
|
5846
|
+
target: r.target,
|
|
5847
|
+
subTargets: r.subTargets
|
|
5848
|
+
}) !== e) return r;
|
|
5849
|
+
let a = r.subTargets.includes(t) ? r.subTargets : [t, ...r.subTargets];
|
|
5850
|
+
return {
|
|
5851
|
+
...r,
|
|
5852
|
+
target: t,
|
|
5853
|
+
currentTarget: t,
|
|
5854
|
+
subTargets: a,
|
|
5855
|
+
currentSubTargets: a
|
|
5856
|
+
};
|
|
5857
|
+
}, this.editingTargetResolverState = {
|
|
5858
|
+
group: e,
|
|
5859
|
+
text: t,
|
|
5860
|
+
findTarget: i
|
|
5861
|
+
};
|
|
5862
|
+
}
|
|
5863
|
+
_restoreEditingTargetResolver() {
|
|
5864
|
+
let e = this.editingTargetResolverState;
|
|
5865
|
+
if (!e) return;
|
|
5866
|
+
let t = this.canvas;
|
|
5867
|
+
t.findTarget = e.findTarget, this.editingTargetResolverState = void 0;
|
|
5760
5868
|
}
|
|
5761
|
-
},
|
|
5869
|
+
}, _r = class e {
|
|
5762
5870
|
constructor({ canvas: e }) {
|
|
5763
5871
|
this.canvas = e, this.textEditingSnapshots = /* @__PURE__ */ new WeakMap(), this.pendingTextUpdates = /* @__PURE__ */ new WeakMap(), this.resizeStartSnapshots = /* @__PURE__ */ new Map(), this.pendingResizeUpdates = /* @__PURE__ */ new WeakMap();
|
|
5764
5872
|
}
|
|
@@ -5954,7 +6062,7 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5954
6062
|
}
|
|
5955
6063
|
}), I;
|
|
5956
6064
|
}
|
|
5957
|
-
},
|
|
6065
|
+
}, vr = "#B4B7BD", yr = 0, br = 1, xr = class {
|
|
5958
6066
|
constructor({ editor: e }) {
|
|
5959
6067
|
this._handleObjectScaling = (e) => {
|
|
5960
6068
|
let t = e.target && J(e.target) ? e.target : null;
|
|
@@ -6019,7 +6127,7 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6019
6127
|
if (!(t instanceof _)) return;
|
|
6020
6128
|
let n = t;
|
|
6021
6129
|
this.lifecycleController.finishTextUpdate({ textNode: n });
|
|
6022
|
-
}, this.editor = e,
|
|
6130
|
+
}, this.editor = e, Zn(), this.scalingController = new hr({ canvas: e.canvas }), this.editingController = new gr({ canvas: e.canvas }), this.editingPlacements = /* @__PURE__ */ new WeakMap(), this.lifecycleController = new _r({ canvas: e.canvas }), this.internalTextUpdates = /* @__PURE__ */ new WeakSet(), this._bindEvents();
|
|
6023
6131
|
}
|
|
6024
6132
|
async add({ presetKey: e = ot, options: t = {} } = {}) {
|
|
6025
6133
|
let n = dt({ presetKey: e });
|
|
@@ -6484,7 +6592,7 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6484
6592
|
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("mouse:up", this._handleMouseUp), 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), e.on("editor:text-updated", this._handleTextUpdated);
|
|
6485
6593
|
}
|
|
6486
6594
|
_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, resolveInternalShapeTextInset: m, changedPadding: h, style: g, rounding: _ }) {
|
|
6487
|
-
let v = new
|
|
6595
|
+
let v = new Xn([r, i], {
|
|
6488
6596
|
originX: "center",
|
|
6489
6597
|
originY: "center",
|
|
6490
6598
|
left: 0,
|
|
@@ -6507,7 +6615,7 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6507
6615
|
padding: f,
|
|
6508
6616
|
style: g,
|
|
6509
6617
|
rounding: _
|
|
6510
|
-
}), v.rehydrateRuntimeState(),
|
|
6618
|
+
}), v.rehydrateRuntimeState(), tr({ group: v }), Rn({ text: i }), ln({
|
|
6511
6619
|
group: v,
|
|
6512
6620
|
shape: r,
|
|
6513
6621
|
text: i,
|
|
@@ -6570,7 +6678,7 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6570
6678
|
return s.set({
|
|
6571
6679
|
shapeNodeType: "text",
|
|
6572
6680
|
splitByGrapheme: !1
|
|
6573
|
-
}),
|
|
6681
|
+
}), Rn({ text: s }), s;
|
|
6574
6682
|
}
|
|
6575
6683
|
_applyTextUpdates({ textNode: e, text: t, textStyle: n, align: r }) {
|
|
6576
6684
|
let i = {};
|
|
@@ -6680,7 +6788,7 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6680
6788
|
}
|
|
6681
6789
|
_resolveAutoExpandShapeWidth({ text: e, currentWidth: t, minimumWidth: n, padding: r, resolvePaddingForWidth: i }) {
|
|
6682
6790
|
let a = this._resolveMontageAreaWidth();
|
|
6683
|
-
return a ?
|
|
6791
|
+
return a ? dn({
|
|
6684
6792
|
text: e,
|
|
6685
6793
|
currentWidth: t,
|
|
6686
6794
|
minimumWidth: n,
|
|
@@ -6736,7 +6844,7 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6736
6844
|
width: y,
|
|
6737
6845
|
height: b
|
|
6738
6846
|
}), S = r ?? this.editor.canvasManager.getObjectPlacement({ object: e }), C = u ? this._resolveMontageAreaWidth() : void 0;
|
|
6739
|
-
|
|
6847
|
+
ln({
|
|
6740
6848
|
group: e,
|
|
6741
6849
|
shape: t,
|
|
6742
6850
|
text: n,
|
|
@@ -6780,7 +6888,7 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6780
6888
|
return this.editingPlacements.get(e) || this.editor.canvasManager.getObjectPlacement({ object: e });
|
|
6781
6889
|
}
|
|
6782
6890
|
_detachShapeGroupAutoLayout({ group: e }) {
|
|
6783
|
-
|
|
6891
|
+
zn({ group: e });
|
|
6784
6892
|
}
|
|
6785
6893
|
_resolveHorizontalAlign({ explicitAlign: e, textStyle: t }) {
|
|
6786
6894
|
if (e) return e;
|
|
@@ -6799,11 +6907,11 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6799
6907
|
_resolveShapeStyle({ options: e, fallback: t }) {
|
|
6800
6908
|
let { fill: n, stroke: r, strokeWidth: i, strokeDashArray: a, opacity: o } = e, s = a === void 0 ? t?.shapeStrokeDashArray : a;
|
|
6801
6909
|
return {
|
|
6802
|
-
fill: n ?? t?.shapeFill ??
|
|
6910
|
+
fill: n ?? t?.shapeFill ?? vr,
|
|
6803
6911
|
stroke: r ?? t?.shapeStroke ?? null,
|
|
6804
|
-
strokeWidth: i ?? t?.shapeStrokeWidth ??
|
|
6912
|
+
strokeWidth: i ?? t?.shapeStrokeWidth ?? yr,
|
|
6805
6913
|
strokeDashArray: s ?? null,
|
|
6806
|
-
opacity: o ?? t?.shapeOpacity ??
|
|
6914
|
+
opacity: o ?? t?.shapeOpacity ?? br
|
|
6807
6915
|
};
|
|
6808
6916
|
}
|
|
6809
6917
|
_collectShapeGroupsFromTarget({ target: t, subTargets: n = [] }) {
|
|
@@ -6859,7 +6967,7 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6859
6967
|
}
|
|
6860
6968
|
return null;
|
|
6861
6969
|
}
|
|
6862
|
-
},
|
|
6970
|
+
}, Sr = class {
|
|
6863
6971
|
constructor({ editor: e }) {
|
|
6864
6972
|
this.editor = e, this.clipboard = null;
|
|
6865
6973
|
}
|
|
@@ -7115,12 +7223,12 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7115
7223
|
}), !1;
|
|
7116
7224
|
}
|
|
7117
7225
|
}
|
|
7118
|
-
},
|
|
7226
|
+
}, Cr = class t {
|
|
7119
7227
|
constructor({ editor: e }) {
|
|
7120
7228
|
this.editor = e;
|
|
7121
7229
|
}
|
|
7122
7230
|
lockObject({ object: e, skipInnerObjects: n, withoutSave: r } = {}) {
|
|
7123
|
-
let { canvas: i, historyManager: a } = this.editor, o = e || i.getActiveObject(), s =
|
|
7231
|
+
let { canvas: i, historyManager: a } = this.editor, o = e || i.getActiveObject(), s = Qn({ target: o }) ?? o;
|
|
7124
7232
|
if (!s || s.locked) return;
|
|
7125
7233
|
let c = {
|
|
7126
7234
|
lockMovementX: !0,
|
|
@@ -7142,7 +7250,7 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7142
7250
|
});
|
|
7143
7251
|
}
|
|
7144
7252
|
unlockObject({ object: e, withoutSave: n } = {}) {
|
|
7145
|
-
let { canvas: r, historyManager: i } = this.editor, a = e || r.getActiveObject(), o =
|
|
7253
|
+
let { canvas: r, historyManager: i } = this.editor, a = e || r.getActiveObject(), o = Qn({ target: a }) ?? a;
|
|
7146
7254
|
if (!o) return;
|
|
7147
7255
|
let s = {
|
|
7148
7256
|
lockMovementX: !1,
|
|
@@ -7180,7 +7288,7 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7180
7288
|
!(n instanceof _) || !n.isEditing || n.exitEditing();
|
|
7181
7289
|
}
|
|
7182
7290
|
}
|
|
7183
|
-
},
|
|
7291
|
+
}, wr = class {
|
|
7184
7292
|
constructor({ editor: e }) {
|
|
7185
7293
|
this.editor = e;
|
|
7186
7294
|
}
|
|
@@ -7246,7 +7354,7 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7246
7354
|
i.resumeHistory(), n || i.saveState();
|
|
7247
7355
|
}
|
|
7248
7356
|
}
|
|
7249
|
-
},
|
|
7357
|
+
}, Tr = class t {
|
|
7250
7358
|
constructor({ editor: e }) {
|
|
7251
7359
|
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();
|
|
7252
7360
|
}
|
|
@@ -7440,7 +7548,7 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7440
7548
|
let { options: e } = this.editor, { selectionKey: t } = e;
|
|
7441
7549
|
return t === void 0 ? ["ctrlKey", "metaKey"] : t;
|
|
7442
7550
|
}
|
|
7443
|
-
},
|
|
7551
|
+
}, Er = class e {
|
|
7444
7552
|
constructor({ editor: e }) {
|
|
7445
7553
|
this.editor = e;
|
|
7446
7554
|
}
|
|
@@ -7480,7 +7588,7 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7480
7588
|
};
|
|
7481
7589
|
return i.fire("editor:objects-deleted", l), l;
|
|
7482
7590
|
}
|
|
7483
|
-
},
|
|
7591
|
+
}, Dr = {
|
|
7484
7592
|
IMAGE_MANAGER: {
|
|
7485
7593
|
INVALID_CONTENT_TYPE: "INVALID_CONTENT_TYPE",
|
|
7486
7594
|
INVALID_SOURCE_TYPE: "INVALID_SOURCE_TYPE",
|
|
@@ -7518,7 +7626,7 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7518
7626
|
INVALID_TARGET: "TEMPLATE_INVALID_TARGET",
|
|
7519
7627
|
APPLY_FAILED: "TEMPLATE_APPLY_FAILED"
|
|
7520
7628
|
}
|
|
7521
|
-
},
|
|
7629
|
+
}, Or = class e {
|
|
7522
7630
|
constructor({ editor: e }) {
|
|
7523
7631
|
this._buffer = [], this.editor = e;
|
|
7524
7632
|
}
|
|
@@ -7576,9 +7684,9 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7576
7684
|
}), this.editor.canvas.fire("editor:warning", s);
|
|
7577
7685
|
}
|
|
7578
7686
|
static isValidErrorCode(e) {
|
|
7579
|
-
return e ? Object.values(
|
|
7687
|
+
return e ? Object.values(Dr).some((t) => Object.values(t).includes(e)) : !1;
|
|
7580
7688
|
}
|
|
7581
|
-
},
|
|
7689
|
+
}, kr = class {
|
|
7582
7690
|
constructor({ editor: e }) {
|
|
7583
7691
|
this.currentBounds = null, this.editor = e;
|
|
7584
7692
|
}
|
|
@@ -7627,32 +7735,32 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7627
7735
|
updateBounds() {
|
|
7628
7736
|
this.currentBounds = this.calculatePanBounds();
|
|
7629
7737
|
}
|
|
7630
|
-
},
|
|
7738
|
+
}, Ar = ({ textbox: e }) => {
|
|
7631
7739
|
if (!e.isEditing) return null;
|
|
7632
7740
|
let t = e.selectionStart ?? 0, n = e.selectionEnd ?? t;
|
|
7633
7741
|
return t === n ? null : {
|
|
7634
7742
|
start: Math.min(t, n),
|
|
7635
7743
|
end: Math.max(t, n)
|
|
7636
7744
|
};
|
|
7637
|
-
},
|
|
7745
|
+
}, jr = ({ textbox: e }) => {
|
|
7638
7746
|
let t = e.text?.length ?? 0;
|
|
7639
7747
|
return t <= 0 ? null : {
|
|
7640
7748
|
start: 0,
|
|
7641
7749
|
end: t
|
|
7642
7750
|
};
|
|
7643
|
-
},
|
|
7751
|
+
}, Mr = ({ textbox: e, range: t }) => {
|
|
7644
7752
|
if (!t) return !1;
|
|
7645
7753
|
let n = e.text?.length ?? 0;
|
|
7646
7754
|
return n <= 0 ? !1 : t.start <= 0 && t.end >= n;
|
|
7647
|
-
},
|
|
7755
|
+
}, Nr = ({ textbox: e, styles: t, range: n }) => {
|
|
7648
7756
|
if (!t || !Object.keys(t).length) return !1;
|
|
7649
7757
|
let { start: r, end: i } = n;
|
|
7650
7758
|
return i <= r ? !1 : (e.setSelectionStyles(t, r, i), !0);
|
|
7651
|
-
},
|
|
7759
|
+
}, Pr = ({ textbox: e, range: t, property: n }) => {
|
|
7652
7760
|
if (!t) return;
|
|
7653
7761
|
let r = e.getSelectionStyles(t.start, t.end, !0);
|
|
7654
7762
|
if (r.length) return r[0]?.[n];
|
|
7655
|
-
},
|
|
7763
|
+
}, Fr = ({ strokeColor: e, width: t }) => t <= 0 ? null : e ?? "#000000", Ir = ({ width: e = 0 }) => e ? Math.max(0, e) : 0, Lr = ({ value: e }) => typeof e == "string" ? e.toLocaleUpperCase() : "", Rr = ({ value: e, min: t, max: n }) => Math.min(Math.max(e, t), n), zr = class e extends _ {
|
|
7656
7764
|
static {
|
|
7657
7765
|
this.type = "background-textbox";
|
|
7658
7766
|
}
|
|
@@ -7786,7 +7894,7 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7786
7894
|
this._removeShadow(e);
|
|
7787
7895
|
}
|
|
7788
7896
|
_getDecorationColorAt(e, t) {
|
|
7789
|
-
let n = this.getValueOfPropertyAt(e, t, "strokeWidth"), r =
|
|
7897
|
+
let n = this.getValueOfPropertyAt(e, t, "strokeWidth"), r = Ir({ width: typeof n == "number" && Number.isFinite(n) ? n : 0 }), i = this.getValueOfPropertyAt(e, t, "stroke"), a = i == null ? null : Fr({
|
|
7790
7898
|
strokeColor: i,
|
|
7791
7899
|
width: r
|
|
7792
7900
|
});
|
|
@@ -7802,22 +7910,22 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7802
7910
|
_getCornerRadii({ width: e, height: t }) {
|
|
7803
7911
|
let n = e / 2, r = t / 2, i = Math.min(n, r);
|
|
7804
7912
|
return {
|
|
7805
|
-
bottomLeft:
|
|
7913
|
+
bottomLeft: Rr({
|
|
7806
7914
|
value: this.radiusBottomLeft ?? 0,
|
|
7807
7915
|
min: 0,
|
|
7808
7916
|
max: i
|
|
7809
7917
|
}),
|
|
7810
|
-
bottomRight:
|
|
7918
|
+
bottomRight: Rr({
|
|
7811
7919
|
value: this.radiusBottomRight ?? 0,
|
|
7812
7920
|
min: 0,
|
|
7813
7921
|
max: i
|
|
7814
7922
|
}),
|
|
7815
|
-
topLeft:
|
|
7923
|
+
topLeft: Rr({
|
|
7816
7924
|
value: this.radiusTopLeft ?? 0,
|
|
7817
7925
|
min: 0,
|
|
7818
7926
|
max: i
|
|
7819
7927
|
}),
|
|
7820
|
-
topRight:
|
|
7928
|
+
topRight: Rr({
|
|
7821
7929
|
value: this.radiusTopRight ?? 0,
|
|
7822
7930
|
min: 0,
|
|
7823
7931
|
max: i
|
|
@@ -7835,7 +7943,7 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7835
7943
|
_getEffectiveBackgroundFill() {
|
|
7836
7944
|
let e = this.backgroundColor;
|
|
7837
7945
|
if (!e) return null;
|
|
7838
|
-
let t =
|
|
7946
|
+
let t = Rr({
|
|
7839
7947
|
value: this.backgroundOpacity ?? 1,
|
|
7840
7948
|
min: 0,
|
|
7841
7949
|
max: 1
|
|
@@ -7843,7 +7951,7 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7843
7951
|
try {
|
|
7844
7952
|
r = new n(e);
|
|
7845
7953
|
} catch (t) {
|
|
7846
|
-
return
|
|
7954
|
+
return Or.emitError({
|
|
7847
7955
|
origin: "BackgroundTextbox",
|
|
7848
7956
|
method: "_getEffectiveBackgroundFill",
|
|
7849
7957
|
code: "INVALID_COLOR_VALUE",
|
|
@@ -7857,19 +7965,19 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7857
7965
|
return r.setAlpha(t), r.toRgba();
|
|
7858
7966
|
}
|
|
7859
7967
|
static _renderRoundedRect({ ctx: e, height: t, left: n, radii: r, top: i, width: a }) {
|
|
7860
|
-
let o = n + a, s = i + t, { topLeft: c, topRight: l, bottomRight: u, bottomLeft: d } = r, f =
|
|
7968
|
+
let o = n + a, s = i + t, { topLeft: c, topRight: l, bottomRight: u, bottomLeft: d } = r, f = Rr({
|
|
7861
7969
|
value: c,
|
|
7862
7970
|
min: 0,
|
|
7863
7971
|
max: a
|
|
7864
|
-
}), p =
|
|
7972
|
+
}), p = Rr({
|
|
7865
7973
|
value: l,
|
|
7866
7974
|
min: 0,
|
|
7867
7975
|
max: a
|
|
7868
|
-
}), m =
|
|
7976
|
+
}), m = Rr({
|
|
7869
7977
|
value: u,
|
|
7870
7978
|
min: 0,
|
|
7871
7979
|
max: a
|
|
7872
|
-
}), h =
|
|
7980
|
+
}), h = Rr({
|
|
7873
7981
|
value: d,
|
|
7874
7982
|
min: 0,
|
|
7875
7983
|
max: a
|
|
@@ -7880,9 +7988,9 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7880
7988
|
let { width: e = 0, height: t = 0 } = this, n = Math.round(e), r = Math.round(t);
|
|
7881
7989
|
n !== e && (this.width = Math.max(0, n)), r !== t && (this.height = Math.max(0, r));
|
|
7882
7990
|
}
|
|
7883
|
-
},
|
|
7884
|
-
y?.setClass && y.setClass(
|
|
7885
|
-
},
|
|
7991
|
+
}, Br = () => {
|
|
7992
|
+
y?.setClass && y.setClass(zr, "background-textbox");
|
|
7993
|
+
}, Vr = .01, Hr = ({ textbox: e, lineIndices: t, updates: n }) => {
|
|
7886
7994
|
if (!t.length) return !1;
|
|
7887
7995
|
let { fontFamily: r, fontSize: i, fill: a, stroke: o } = n;
|
|
7888
7996
|
if (!(r !== void 0 || i !== void 0 || a !== void 0 || o !== void 0)) return !1;
|
|
@@ -7894,7 +8002,7 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7894
8002
|
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);
|
|
7895
8003
|
}
|
|
7896
8004
|
return l && (e.lineFontDefaults = c), l;
|
|
7897
|
-
},
|
|
8005
|
+
}, Ur = ({ lineText: e, lineStyles: t, lineDefaults: n }) => {
|
|
7898
8006
|
let r = e.length;
|
|
7899
8007
|
if (r === 0) return {
|
|
7900
8008
|
lineStyles: t,
|
|
@@ -7926,7 +8034,7 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7926
8034
|
lineStyles: l,
|
|
7927
8035
|
changed: u
|
|
7928
8036
|
};
|
|
7929
|
-
},
|
|
8037
|
+
}, Wr = ({ lineFontDefaults: e }) => {
|
|
7930
8038
|
if (!e) return;
|
|
7931
8039
|
let t = {};
|
|
7932
8040
|
for (let n in e) {
|
|
@@ -7937,7 +8045,7 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7937
8045
|
i && (t[r] = { ...i });
|
|
7938
8046
|
}
|
|
7939
8047
|
return t;
|
|
7940
|
-
},
|
|
8048
|
+
}, Gr = ({ lineFontDefaults: e, scale: t }) => {
|
|
7941
8049
|
if (!e || !Number.isFinite(t) || Math.abs(t - 1) < .01) return;
|
|
7942
8050
|
let n = {}, r = !1, i = !1;
|
|
7943
8051
|
for (let a in e) {
|
|
@@ -7954,18 +8062,18 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7954
8062
|
n[o] = c, r = !0;
|
|
7955
8063
|
}
|
|
7956
8064
|
if (!(!r || !i)) return n;
|
|
7957
|
-
},
|
|
8065
|
+
}, Kr = ({ textbox: e, text: t }) => {
|
|
7958
8066
|
let { textLines: n } = e, r = Array.isArray(n) && n.length > 0 ? n.length : Math.max(t.split("\n").length, 1), i = 0;
|
|
7959
8067
|
for (let t = 0; t < r; t += 1) {
|
|
7960
8068
|
let n = e.getLineWidth(t);
|
|
7961
8069
|
n > i && (i = n);
|
|
7962
8070
|
}
|
|
7963
8071
|
return i;
|
|
7964
|
-
},
|
|
7965
|
-
let r = e.width ?? e.calcTextWidth() ?? 0, i = e.height ?? e.calcTextHeight() ?? 0, a = e.paddingTop ?? 0, o = e.paddingRight ?? 0, s = e.paddingBottom ?? 0, c = e.paddingLeft ?? 0, l = -r / 2 + (c - o) / 2, u = -i / 2 + (a - s) / 2, d = new p(l +
|
|
8072
|
+
}, qr = ({ origin: e, size: t }) => e === "left" || e === "top" || e === "start" || e === 0 ? 0 : e === "right" || e === "bottom" || e === "end" || e === 1 ? t : t / 2, Jr = ({ textbox: e, originX: t = e.originX ?? "center", originY: n = e.originY ?? "center" }) => {
|
|
8073
|
+
let r = e.width ?? e.calcTextWidth() ?? 0, i = e.height ?? e.calcTextHeight() ?? 0, a = e.paddingTop ?? 0, o = e.paddingRight ?? 0, s = e.paddingBottom ?? 0, c = e.paddingLeft ?? 0, l = -r / 2 + (c - o) / 2, u = -i / 2 + (a - s) / 2, d = new p(l + qr({
|
|
7966
8074
|
origin: t,
|
|
7967
8075
|
size: r
|
|
7968
|
-
}), u +
|
|
8076
|
+
}), u + qr({
|
|
7969
8077
|
origin: n,
|
|
7970
8078
|
size: i
|
|
7971
8079
|
})), f = e.getPointByOrigin("center", "center"), m = e, h = typeof m.calcTransformMatrix == "function" ? m.calcTransformMatrix() : null, g = Array.isArray(h) ? new p(d.x * h[0] + d.y * h[2] + f.x, d.x * h[1] + d.y * h[3] + f.y) : new p(f.x + d.x, f.y + d.y);
|
|
@@ -7975,13 +8083,13 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7975
8083
|
originX: t,
|
|
7976
8084
|
originY: n
|
|
7977
8085
|
};
|
|
7978
|
-
},
|
|
8086
|
+
}, Yr = ({ textbox: e, montageLeft: t, montageRight: n }) => {
|
|
7979
8087
|
e.setCoords();
|
|
7980
8088
|
let r = e.getBoundingRect(!1, !0), i = r.left ?? 0, a = i + (r.width ?? 0), o = n - t;
|
|
7981
8089
|
if (o > 0 && (r.width ?? 0) >= o - .01) return !1;
|
|
7982
8090
|
let s = 0;
|
|
7983
8091
|
return i < t ? s = t - i : a > n && (s = n - a), Math.abs(s) <= .01 ? !1 : (e.set({ left: (e.left ?? 0) + s }), !0);
|
|
7984
|
-
},
|
|
8092
|
+
}, Xr = ({ rawValue: e, calculatedValue: t }) => typeof e == "number" ? e : typeof t == "number" ? t : 0, Zr = ({ stylesList: e }) => {
|
|
7985
8093
|
let t = e.length;
|
|
7986
8094
|
if (!t) return !1;
|
|
7987
8095
|
for (let n = 0; n < t; n += 1) {
|
|
@@ -7991,16 +8099,16 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7991
8099
|
if (r !== void 0 || i !== void 0 || a !== void 0 || o !== void 0 || s !== void 0 || c !== void 0) return !0;
|
|
7992
8100
|
}
|
|
7993
8101
|
return !1;
|
|
7994
|
-
},
|
|
7995
|
-
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 =
|
|
8102
|
+
}, Qr = ({ textbox: e }) => {
|
|
8103
|
+
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 = Xr({
|
|
7996
8104
|
rawValue: t,
|
|
7997
8105
|
calculatedValue: a
|
|
7998
|
-
}), c =
|
|
8106
|
+
}), c = Xr({
|
|
7999
8107
|
rawValue: n,
|
|
8000
8108
|
calculatedValue: o
|
|
8001
8109
|
}), l = Number.isFinite(s) ? Math.round(s) : null, u = Number.isFinite(c) ? Math.round(c) : null, d = {};
|
|
8002
8110
|
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;
|
|
8003
|
-
},
|
|
8111
|
+
}, $r = ({ textbox: e }) => {
|
|
8004
8112
|
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;
|
|
8005
8113
|
return {
|
|
8006
8114
|
width: t,
|
|
@@ -8018,9 +8126,9 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
8018
8126
|
bottomLeft: f
|
|
8019
8127
|
},
|
|
8020
8128
|
styles: JSON.parse(JSON.stringify(r)),
|
|
8021
|
-
lineFontDefaults:
|
|
8129
|
+
lineFontDefaults: Wr({ lineFontDefaults: i })
|
|
8022
8130
|
};
|
|
8023
|
-
},
|
|
8131
|
+
}, ei = ({ base: e }) => {
|
|
8024
8132
|
let t = 1 / Math.max(1, e.width), n = [e.fontSize];
|
|
8025
8133
|
Object.values(e.styles).forEach((e) => {
|
|
8026
8134
|
Object.values(e).forEach((e) => {
|
|
@@ -8037,7 +8145,7 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
8037
8145
|
fontScale: r,
|
|
8038
8146
|
proportionalScale: Math.max(t, r)
|
|
8039
8147
|
};
|
|
8040
|
-
},
|
|
8148
|
+
}, ti = ({ textbox: e, canvasManager: t, base: n, widthScale: r, heightScale: i, placement: a, anchorPlacement: o, shouldScaleFontSize: s, shouldScalePadding: c, shouldScaleRadii: l, shouldDisableAutoExpandOnHorizontalChange: u = !1, shouldRoundDimensions: d = !0 }) => {
|
|
8041
8149
|
let { width: f, fontSize: m, padding: h, radii: g, styles: _, lineFontDefaults: v } = n, y = Math.max(1, f * r), b = d ? Math.max(1, Math.round(y)) : y, x = Math.max(Math.min(8, m), m * i), S = Object.keys(_).length > 0, C;
|
|
8042
8150
|
if (s && S) {
|
|
8043
8151
|
let e = {};
|
|
@@ -8056,7 +8164,7 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
8056
8164
|
}), Object.keys(e).length && (C = e);
|
|
8057
8165
|
}
|
|
8058
8166
|
let w;
|
|
8059
|
-
s && (w =
|
|
8167
|
+
s && (w = Gr({
|
|
8060
8168
|
lineFontDefaults: v,
|
|
8061
8169
|
scale: i
|
|
8062
8170
|
}));
|
|
@@ -8070,7 +8178,7 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
8070
8178
|
topRight: Math.max(0, g.topRight * i),
|
|
8071
8179
|
bottomRight: Math.max(0, g.bottomRight * i),
|
|
8072
8180
|
bottomLeft: Math.max(0, g.bottomLeft * i)
|
|
8073
|
-
} : g, D = e.width ?? f, O = Math.abs(b - D) >
|
|
8181
|
+
} : g, D = e.width ?? f, O = Math.abs(b - D) > Vr;
|
|
8074
8182
|
u && O && (e.autoExpand = !1), C && (e.styles = C), w && (e.lineFontDefaults = w), e.set({
|
|
8075
8183
|
width: b,
|
|
8076
8184
|
fontSize: s ? x : m,
|
|
@@ -8092,7 +8200,7 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
8092
8200
|
} finally {
|
|
8093
8201
|
e.shouldRoundDimensionsOnInit = k;
|
|
8094
8202
|
}
|
|
8095
|
-
let A = d ?
|
|
8203
|
+
let A = d ? Qr({ textbox: e }) : !1;
|
|
8096
8204
|
return A && (e.dirty = !0), o ? (e.set({
|
|
8097
8205
|
originX: a.originX,
|
|
8098
8206
|
originY: a.originY
|
|
@@ -8106,18 +8214,18 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
8106
8214
|
appliedWidth: e.width ?? b,
|
|
8107
8215
|
dimensionsRounded: A
|
|
8108
8216
|
});
|
|
8109
|
-
},
|
|
8217
|
+
}, ni = ({ transform: e }) => {
|
|
8110
8218
|
let { corner: t = "", action: n = "" } = e;
|
|
8111
8219
|
return {
|
|
8112
8220
|
isCornerHandle: t === "tl" || t === "tr" || t === "bl" || t === "br" || n === "scale",
|
|
8113
8221
|
isHorizontalHandle: t === "ml" || t === "mr" || n === "scaleX",
|
|
8114
8222
|
isVerticalHandle: t === "mt" || t === "mb" || n === "scaleY"
|
|
8115
8223
|
};
|
|
8116
|
-
},
|
|
8224
|
+
}, ri = ({ textbox: e, transform: t, appliedWidth: n }) => {
|
|
8117
8225
|
t.scaleX = 1, t.scaleY = 1;
|
|
8118
8226
|
let { original: r } = t;
|
|
8119
8227
|
r && (r.scaleX = 1, r.scaleY = 1, r.width = n, r.height = e.height, r.left = e.left, r.top = e.top);
|
|
8120
|
-
},
|
|
8228
|
+
}, ii = ({ textbox: e, transform: t, scenePoint: n }) => {
|
|
8121
8229
|
let { x: r, y: i } = e._getTransformedDimensions();
|
|
8122
8230
|
if (r <= 0 || i <= 0) return null;
|
|
8123
8231
|
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);
|
|
@@ -8127,27 +8235,27 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
8127
8235
|
stepScaleX: l,
|
|
8128
8236
|
stepScaleY: u
|
|
8129
8237
|
};
|
|
8130
|
-
},
|
|
8131
|
-
function
|
|
8238
|
+
}, ai = 1e-4;
|
|
8239
|
+
function oi(e) {
|
|
8132
8240
|
return !!e && e instanceof _;
|
|
8133
8241
|
}
|
|
8134
|
-
function
|
|
8135
|
-
if (!
|
|
8242
|
+
function si(e) {
|
|
8243
|
+
if (!oi(e)) return !1;
|
|
8136
8244
|
let t = e.group;
|
|
8137
8245
|
return e.shapeNodeType === "text" && t?.shapeComposite === !0;
|
|
8138
8246
|
}
|
|
8139
|
-
var
|
|
8247
|
+
var ci = class {
|
|
8140
8248
|
constructor({ canvas: t, canvasManager: n, persistScaledTextbox: r }) {
|
|
8141
8249
|
this.handleMouseMove = (e) => {
|
|
8142
8250
|
let t = this.canvas._currentTransform;
|
|
8143
8251
|
if (!t) return;
|
|
8144
8252
|
let { target: n } = t;
|
|
8145
|
-
if (!
|
|
8253
|
+
if (!oi(n) || si(n)) return;
|
|
8146
8254
|
let r = this.scalingState.get(n);
|
|
8147
8255
|
if (!r || !e.e) return;
|
|
8148
|
-
let { isCornerHandle: i, isHorizontalHandle: a, isVerticalHandle: o } =
|
|
8256
|
+
let { isCornerHandle: i, isHorizontalHandle: a, isVerticalHandle: o } = ni({ transform: t });
|
|
8149
8257
|
if (!a && !o && !i) return;
|
|
8150
|
-
let s =
|
|
8258
|
+
let s = ii({
|
|
8151
8259
|
textbox: n,
|
|
8152
8260
|
transform: t,
|
|
8153
8261
|
scenePoint: this.canvas.getScenePoint(e.e)
|
|
@@ -8170,20 +8278,20 @@ var ai = class {
|
|
|
8170
8278
|
}, j = r.lastAllowedScaleX, M = r.lastAllowedScaleY;
|
|
8171
8279
|
if (i) {
|
|
8172
8280
|
let e = Math.max(r.minimumProportionalScale, r.lastAllowedScaleX * Math.sqrt(u * d)), t = c || l ? r.minimumProportionalScale : e;
|
|
8173
|
-
if (Math.abs(t - r.lastAllowedScaleX) <=
|
|
8281
|
+
if (Math.abs(t - r.lastAllowedScaleX) <= ai) return;
|
|
8174
8282
|
j = t, M = t;
|
|
8175
8283
|
} else {
|
|
8176
8284
|
if (a) {
|
|
8177
8285
|
let e = r.lastAllowedScaleX * u, t = c ? r.minimumWidthScale : Math.max(r.minimumWidthScale, e);
|
|
8178
|
-
Math.abs(t - r.lastAllowedScaleX) >
|
|
8286
|
+
Math.abs(t - r.lastAllowedScaleX) > ai && (j = t);
|
|
8179
8287
|
}
|
|
8180
8288
|
if (o) {
|
|
8181
8289
|
let e = r.lastAllowedScaleY * d, t = l ? r.minimumFontScale : Math.max(r.minimumFontScale, e);
|
|
8182
|
-
Math.abs(t - r.lastAllowedScaleY) >
|
|
8290
|
+
Math.abs(t - r.lastAllowedScaleY) > ai && (M = t);
|
|
8183
8291
|
}
|
|
8184
|
-
if (Math.abs(j - r.lastAllowedScaleX) <=
|
|
8292
|
+
if (Math.abs(j - r.lastAllowedScaleX) <= ai && Math.abs(M - r.lastAllowedScaleY) <= ai) return;
|
|
8185
8293
|
}
|
|
8186
|
-
let { appliedWidth: N, dimensionsRounded: P } =
|
|
8294
|
+
let { appliedWidth: N, dimensionsRounded: P } = ti({
|
|
8187
8295
|
textbox: n,
|
|
8188
8296
|
canvasManager: this.canvasManager,
|
|
8189
8297
|
base: r.startBase,
|
|
@@ -8197,7 +8305,7 @@ var ai = class {
|
|
|
8197
8305
|
shouldDisableAutoExpandOnHorizontalChange: a,
|
|
8198
8306
|
shouldRoundDimensions: !i
|
|
8199
8307
|
});
|
|
8200
|
-
|
|
8308
|
+
ri({
|
|
8201
8309
|
textbox: n,
|
|
8202
8310
|
transform: t,
|
|
8203
8311
|
appliedWidth: N
|
|
@@ -8218,12 +8326,12 @@ var ai = class {
|
|
|
8218
8326
|
}), this.canvas.requestRenderAll();
|
|
8219
8327
|
}, this.handleObjectScaling = (t) => {
|
|
8220
8328
|
let { target: n, transform: r } = t;
|
|
8221
|
-
if (n instanceof e || !
|
|
8329
|
+
if (n instanceof e || !oi(n) || si(n) || !r) return;
|
|
8222
8330
|
n.isScaling = !0;
|
|
8223
8331
|
let i = this._ensureScalingState({
|
|
8224
8332
|
textbox: n,
|
|
8225
8333
|
transform: r
|
|
8226
|
-
}), { startBase: a } = i, { width: o, fontSize: s } = a, { isCornerHandle: c, isHorizontalHandle: l, isVerticalHandle: u } =
|
|
8334
|
+
}), { startBase: a } = i, { width: o, fontSize: s } = a, { isCornerHandle: c, isHorizontalHandle: l, isVerticalHandle: u } = ni({ transform: r }), d = r.corner ?? "", f = c || u;
|
|
8227
8335
|
if (!l && !u && !c) return;
|
|
8228
8336
|
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({
|
|
8229
8337
|
object: n,
|
|
@@ -8238,7 +8346,7 @@ var ai = class {
|
|
|
8238
8346
|
N = e, P = e;
|
|
8239
8347
|
}
|
|
8240
8348
|
} else l && (N = Math.max(i.minimumWidthScale, i.lastAllowedScaleX * h)), u && (P = Math.max(i.minimumFontScale, i.lastAllowedScaleY * g));
|
|
8241
|
-
let { appliedWidth: L, dimensionsRounded: ee } =
|
|
8349
|
+
let { appliedWidth: L, dimensionsRounded: ee } = ti({
|
|
8242
8350
|
textbox: n,
|
|
8243
8351
|
canvasManager: this.canvasManager,
|
|
8244
8352
|
base: a,
|
|
@@ -8252,7 +8360,7 @@ var ai = class {
|
|
|
8252
8360
|
shouldDisableAutoExpandOnHorizontalChange: l,
|
|
8253
8361
|
shouldRoundDimensions: !c
|
|
8254
8362
|
});
|
|
8255
|
-
|
|
8363
|
+
ri({
|
|
8256
8364
|
textbox: n,
|
|
8257
8365
|
transform: r,
|
|
8258
8366
|
appliedWidth: L
|
|
@@ -8285,7 +8393,7 @@ var ai = class {
|
|
|
8285
8393
|
let { target: n } = t;
|
|
8286
8394
|
if (n instanceof e) {
|
|
8287
8395
|
let t = n.getObjects();
|
|
8288
|
-
if (!t.some((e) =>
|
|
8396
|
+
if (!t.some((e) => oi(e))) return;
|
|
8289
8397
|
let { scaleX: r = 1, scaleY: i = 1 } = n;
|
|
8290
8398
|
if (Math.abs(r - 1) < .01 && Math.abs(i - 1) < .01) return;
|
|
8291
8399
|
this.canvas.discardActiveObject(), t.forEach((e) => {
|
|
@@ -8295,7 +8403,7 @@ var ai = class {
|
|
|
8295
8403
|
this.canvas.setActiveObject(a), this.canvas.requestRenderAll();
|
|
8296
8404
|
return;
|
|
8297
8405
|
}
|
|
8298
|
-
if (!
|
|
8406
|
+
if (!oi(n) || si(n)) return;
|
|
8299
8407
|
n.isScaling = !1;
|
|
8300
8408
|
let r = this.scalingState.get(n);
|
|
8301
8409
|
if (this.scalingState.delete(n), !r?.hasScalingChange) return;
|
|
@@ -8320,11 +8428,11 @@ var ai = class {
|
|
|
8320
8428
|
}, this.canvas = t, this.canvasManager = n, this.persistScaledTextbox = r, this.scalingState = /* @__PURE__ */ new WeakMap();
|
|
8321
8429
|
}
|
|
8322
8430
|
commitStandaloneTextScale({ target: e, shouldDisableAutoExpandOnHorizontalChange: t = !1 }) {
|
|
8323
|
-
if (!
|
|
8431
|
+
if (!oi(e) || si(e)) return !1;
|
|
8324
8432
|
let n = Math.abs(e.scaleX ?? 1) || 1, r = Math.abs(e.scaleY ?? 1) || 1;
|
|
8325
8433
|
if (!(Math.abs(n - 1) > .01 || Math.abs(r - 1) > .01)) return !1;
|
|
8326
|
-
let i =
|
|
8327
|
-
return
|
|
8434
|
+
let i = $r({ textbox: e }), a = this.canvasManager.getObjectPlacement({ object: e });
|
|
8435
|
+
return ti({
|
|
8328
8436
|
textbox: e,
|
|
8329
8437
|
canvasManager: this.canvasManager,
|
|
8330
8438
|
base: i,
|
|
@@ -8340,7 +8448,7 @@ var ai = class {
|
|
|
8340
8448
|
_ensureScalingState({ textbox: e, transform: t }) {
|
|
8341
8449
|
let n = this.scalingState.get(e);
|
|
8342
8450
|
if (!n) {
|
|
8343
|
-
let r =
|
|
8451
|
+
let r = $r({ textbox: e }), i = this.canvasManager.getObjectPlacement({ object: e }), a = ei({ base: r }), o = t.original?.originX ?? t.originX ?? e.originX ?? "center", s = t.original?.originY ?? t.originY ?? e.originY ?? "center";
|
|
8344
8452
|
n = {
|
|
8345
8453
|
startBase: r,
|
|
8346
8454
|
startObjectPlacement: i,
|
|
@@ -8373,7 +8481,7 @@ var ai = class {
|
|
|
8373
8481
|
topRight: e.radiusTopRight ?? 0,
|
|
8374
8482
|
bottomRight: e.radiusBottomRight ?? 0,
|
|
8375
8483
|
bottomLeft: e.radiusBottomLeft ?? 0
|
|
8376
|
-
}, v = Math.abs(n - o) >
|
|
8484
|
+
}, v = Math.abs(n - o) > Vr, y = Math.abs(h - r) > Vr, 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;
|
|
8377
8485
|
if (c) {
|
|
8378
8486
|
let e = h / Math.max(1, m);
|
|
8379
8487
|
S = e, C = e;
|
|
@@ -8394,7 +8502,7 @@ var ai = class {
|
|
|
8394
8502
|
originY: a
|
|
8395
8503
|
});
|
|
8396
8504
|
}
|
|
8397
|
-
},
|
|
8505
|
+
}, li = ({ textbox: e }) => {
|
|
8398
8506
|
let t = e.text ?? "";
|
|
8399
8507
|
if (!t.length) return [];
|
|
8400
8508
|
let n = t.split("\n"), r = [], i = 0;
|
|
@@ -8406,7 +8514,7 @@ var ai = class {
|
|
|
8406
8514
|
});
|
|
8407
8515
|
}
|
|
8408
8516
|
return r;
|
|
8409
|
-
},
|
|
8517
|
+
}, ui = ({ range: e, text: t }) => {
|
|
8410
8518
|
if (!e) return null;
|
|
8411
8519
|
let n = t.length;
|
|
8412
8520
|
if (n <= 0) return null;
|
|
@@ -8415,8 +8523,8 @@ var ai = class {
|
|
|
8415
8523
|
start: l,
|
|
8416
8524
|
end: u
|
|
8417
8525
|
};
|
|
8418
|
-
},
|
|
8419
|
-
let n =
|
|
8526
|
+
}, di = ({ textbox: e, range: t }) => {
|
|
8527
|
+
let n = li({ textbox: e });
|
|
8420
8528
|
if (!n.length) return t;
|
|
8421
8529
|
let { start: r } = t, { end: i } = t;
|
|
8422
8530
|
for (let e = 0; e < n.length; e += 1) {
|
|
@@ -8429,7 +8537,7 @@ var ai = class {
|
|
|
8429
8537
|
start: r,
|
|
8430
8538
|
end: i
|
|
8431
8539
|
};
|
|
8432
|
-
},
|
|
8540
|
+
}, fi = ({ textbox: e, range: t }) => {
|
|
8433
8541
|
let n = e.text ?? "";
|
|
8434
8542
|
if (!n.length) return [];
|
|
8435
8543
|
let { start: r, end: i } = t, a = n.split("\n"), o = [], s = 0;
|
|
@@ -8438,7 +8546,7 @@ var ai = class {
|
|
|
8438
8546
|
i > n && r < c && o.push(e), s = c + 1;
|
|
8439
8547
|
}
|
|
8440
8548
|
return o;
|
|
8441
|
-
},
|
|
8549
|
+
}, pi = ({ textbox: e, range: t }) => {
|
|
8442
8550
|
let n = e.text ?? "";
|
|
8443
8551
|
if (!n.length) return [];
|
|
8444
8552
|
let { start: r, end: i } = t, a = n.split("\n"), o = [], s = 0;
|
|
@@ -8447,20 +8555,20 @@ var ai = class {
|
|
|
8447
8555
|
r <= n && i >= c && o.push(e), s = c + 1;
|
|
8448
8556
|
}
|
|
8449
8557
|
return o;
|
|
8450
|
-
},
|
|
8558
|
+
}, mi = ({ previous: e, next: t }) => {
|
|
8451
8559
|
let n = Math.min(e.length, t.length);
|
|
8452
8560
|
for (let r = 0; r < n; r += 1) if (e[r] !== t[r]) return r;
|
|
8453
8561
|
return n;
|
|
8454
|
-
},
|
|
8562
|
+
}, hi = ({ text: e, charIndex: t }) => {
|
|
8455
8563
|
let n = Math.max(0, Math.min(t, e.length)), r = 0;
|
|
8456
8564
|
for (let t = 0; t < n; t += 1) e[t] === "\n" && (r += 1);
|
|
8457
8565
|
return r;
|
|
8458
|
-
},
|
|
8566
|
+
}, gi = ({ text: e, lineIndex: t }) => {
|
|
8459
8567
|
if (t <= 0) return 0;
|
|
8460
8568
|
let n = 0;
|
|
8461
8569
|
for (let r = 0; r < e.length; r += 1) if (e[r] === "\n" && (n += 1, n === t)) return r + 1;
|
|
8462
8570
|
return e.length;
|
|
8463
|
-
},
|
|
8571
|
+
}, _i = class e {
|
|
8464
8572
|
constructor({ editor: t }) {
|
|
8465
8573
|
this._handleTextEditingEntered = (t) => {
|
|
8466
8574
|
this.isTextEditingActive = !0;
|
|
@@ -8473,7 +8581,7 @@ var ai = class {
|
|
|
8473
8581
|
if (!e._isTextbox(n) || this.lineDefaultsSyncing.has(n)) return;
|
|
8474
8582
|
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 });
|
|
8475
8583
|
if (s) {
|
|
8476
|
-
let e =
|
|
8584
|
+
let e = Lr({ value: l });
|
|
8477
8585
|
e !== i && n.set({ text: e }), n.textCaseRaw = l;
|
|
8478
8586
|
} else n.textCaseRaw = i;
|
|
8479
8587
|
if (!r && o === void 0 && (n.autoExpand = !0), r) {
|
|
@@ -8491,7 +8599,7 @@ var ai = class {
|
|
|
8491
8599
|
let r = e._isShapeOwnedTextbox(n);
|
|
8492
8600
|
this.editingPlacementState?.delete(n);
|
|
8493
8601
|
let i = n.text ?? "";
|
|
8494
|
-
n.uppercase ? n.textCaseRaw = n.textCaseRaw ?? i.toLocaleLowerCase() : n.textCaseRaw = i, r || (
|
|
8602
|
+
n.uppercase ? n.textCaseRaw = n.textCaseRaw ?? i.toLocaleLowerCase() : n.textCaseRaw = i, r || (Qr({ textbox: n }) && (n.setCoords(), n.dirty = !0, this.canvas.requestRenderAll()), n.locked || n.set({
|
|
8495
8603
|
lockMovementX: !1,
|
|
8496
8604
|
lockMovementY: !1
|
|
8497
8605
|
}));
|
|
@@ -8518,7 +8626,7 @@ var ai = class {
|
|
|
8518
8626
|
transform: r,
|
|
8519
8627
|
event: i ?? null
|
|
8520
8628
|
});
|
|
8521
|
-
}, this.editor = t, this.canvas = t.canvas, this.fonts = t.options.fonts ?? [], this.scalingController = new
|
|
8629
|
+
}, this.editor = t, this.canvas = t.canvas, this.fonts = t.options.fonts ?? [], this.scalingController = new ci({
|
|
8522
8630
|
canvas: t.canvas,
|
|
8523
8631
|
canvasManager: t.canvasManager,
|
|
8524
8632
|
persistScaledTextbox: ({ target: e, style: t }) => {
|
|
@@ -8527,12 +8635,12 @@ var ai = class {
|
|
|
8527
8635
|
style: t
|
|
8528
8636
|
});
|
|
8529
8637
|
}
|
|
8530
|
-
}), this.editingPlacementState = /* @__PURE__ */ new WeakMap(), this.lineDefaultsSyncing = /* @__PURE__ */ new WeakSet(), this.isTextEditingActive = !1, this._bindEvents(),
|
|
8638
|
+
}), this.editingPlacementState = /* @__PURE__ */ new WeakMap(), this.lineDefaultsSyncing = /* @__PURE__ */ new WeakSet(), this.isTextEditingActive = !1, this._bindEvents(), Br();
|
|
8531
8639
|
}
|
|
8532
8640
|
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, emitLifecycleEvents: j = !0 } = {}) {
|
|
8533
8641
|
let { canvasManager: M, historyManager: N } = this.editor, { canvas: P } = this;
|
|
8534
8642
|
N.suspendHistory();
|
|
8535
|
-
let F = i ?? this._getDefaultFontFamily(), I =
|
|
8643
|
+
let F = i ?? this._getDefaultFontFamily(), I = Ir({ width: m }), L = Fr({
|
|
8536
8644
|
strokeColor: p,
|
|
8537
8645
|
width: I
|
|
8538
8646
|
}), ee = {
|
|
@@ -8561,14 +8669,14 @@ var ai = class {
|
|
|
8561
8669
|
radiusBottomRight: w,
|
|
8562
8670
|
radiusBottomLeft: T,
|
|
8563
8671
|
...E
|
|
8564
|
-
}, R = new
|
|
8672
|
+
}, R = new zr(n, ee), te = r !== !1;
|
|
8565
8673
|
R.autoExpand = te;
|
|
8566
8674
|
let ne = E.left !== void 0 || E.top !== void 0;
|
|
8567
8675
|
if (R.textCaseRaw = R.text ?? "", l) {
|
|
8568
|
-
let e =
|
|
8676
|
+
let e = Lr({ value: R.textCaseRaw });
|
|
8569
8677
|
e !== R.text && R.set({ text: e });
|
|
8570
8678
|
}
|
|
8571
|
-
|
|
8679
|
+
Qr({ textbox: R }) && (R.dirty = !0);
|
|
8572
8680
|
let z;
|
|
8573
8681
|
ne && (z = M.resolveObjectPlacement({
|
|
8574
8682
|
object: R,
|
|
@@ -8615,13 +8723,13 @@ var ai = class {
|
|
|
8615
8723
|
top: ee,
|
|
8616
8724
|
originX: R,
|
|
8617
8725
|
originY: te
|
|
8618
|
-
}), B = a === void 0 ?
|
|
8726
|
+
}), B = a === void 0 ? Ar({ textbox: s }) : ui({
|
|
8619
8727
|
text: c,
|
|
8620
8728
|
range: a
|
|
8621
|
-
}), V = B ?
|
|
8729
|
+
}), V = B ? di({
|
|
8622
8730
|
textbox: s,
|
|
8623
8731
|
range: B
|
|
8624
|
-
}) : null, H = {}, ie = {}, U = {}, ae, oe, se =
|
|
8732
|
+
}) : null, H = {}, ie = {}, U = {}, ae, oe, se = Mr({
|
|
8625
8733
|
textbox: s,
|
|
8626
8734
|
range: B
|
|
8627
8735
|
}), ce = !B || se, le = !B;
|
|
@@ -8634,24 +8742,24 @@ var ai = class {
|
|
|
8634
8742
|
B && (H.fontStyle = e), ce && (z.fontStyle = e, le && (U.fontStyle = e));
|
|
8635
8743
|
}
|
|
8636
8744
|
if (y !== void 0 && (B && (H.underline = y), ce && (z.underline = y, le && (U.underline = y))), x !== void 0 && (B && (H.linethrough = x), ce && (z.linethrough = x, le && (U.linethrough = x))), S !== void 0 && (z.textAlign = S), C !== void 0 && (B && (H.fill = C), ce && (z.fill = C, le && (U.fill = C))), w !== void 0 || T !== void 0) {
|
|
8637
|
-
let e = B ?
|
|
8745
|
+
let e = B ? Pr({
|
|
8638
8746
|
textbox: s,
|
|
8639
8747
|
range: B,
|
|
8640
8748
|
property: "strokeWidth"
|
|
8641
|
-
}) : void 0, t = B ?
|
|
8749
|
+
}) : void 0, t = B ? Pr({
|
|
8642
8750
|
textbox: s,
|
|
8643
8751
|
range: B,
|
|
8644
8752
|
property: "stroke"
|
|
8645
8753
|
}) : void 0;
|
|
8646
|
-
oe =
|
|
8754
|
+
oe = Ir({ width: T ?? e ?? s.strokeWidth ?? 0 }), ae = Fr({
|
|
8647
8755
|
strokeColor: w ?? t ?? s.stroke ?? void 0,
|
|
8648
8756
|
width: oe
|
|
8649
8757
|
}), B && (H.stroke = ae, H.strokeWidth = oe), ce && (z.stroke = ae, z.strokeWidth = oe, le && (U.stroke = ae, U.strokeWidth = oe));
|
|
8650
8758
|
}
|
|
8651
8759
|
E !== void 0 && (z.opacity = E), D !== void 0 && (z.backgroundColor = D), O !== void 0 && (z.backgroundOpacity = O), k !== void 0 && (z.paddingTop = k), A !== void 0 && (z.paddingRight = A), j !== void 0 && (z.paddingBottom = j), M !== void 0 && (z.paddingLeft = M), N !== void 0 && (z.radiusTopLeft = N), P !== void 0 && (z.radiusTopRight = P), F !== void 0 && (z.radiusBottomRight = F), I !== void 0 && (z.radiusBottomLeft = I);
|
|
8652
8760
|
let ue = s.textCaseRaw ?? c, de = !!s.uppercase, fe = p !== void 0, pe = fe ? p ?? "" : ue, me = b ?? de, he = me !== de;
|
|
8653
|
-
fe || he ? (z.text = me ?
|
|
8654
|
-
let ge =
|
|
8761
|
+
fe || he ? (z.text = me ? Lr({ value: pe }) : pe, s.textCaseRaw = pe) : s.textCaseRaw === void 0 && (s.textCaseRaw = ue);
|
|
8762
|
+
let ge = Zr({ stylesList: [
|
|
8655
8763
|
z,
|
|
8656
8764
|
H,
|
|
8657
8765
|
ie,
|
|
@@ -8667,53 +8775,53 @@ var ai = class {
|
|
|
8667
8775
|
j,
|
|
8668
8776
|
M
|
|
8669
8777
|
], ye = _e.some((e) => e !== void 0), be = ve.some((e) => e !== void 0), xe = Object.prototype.hasOwnProperty.call(z, "width"), Se = be && !ye && !fe && !he && !ge && !xe, Ce = null;
|
|
8670
|
-
Se && (Ce =
|
|
8778
|
+
Se && (Ce = Jr({
|
|
8671
8779
|
textbox: s,
|
|
8672
8780
|
originX: re.originX,
|
|
8673
8781
|
originY: re.originY
|
|
8674
8782
|
})), s.uppercase = me, s.set(z);
|
|
8675
8783
|
let we = !1;
|
|
8676
8784
|
if (B) {
|
|
8677
|
-
let e =
|
|
8785
|
+
let e = Nr({
|
|
8678
8786
|
textbox: s,
|
|
8679
8787
|
styles: H,
|
|
8680
8788
|
range: B
|
|
8681
|
-
}), t = V ?
|
|
8789
|
+
}), t = V ? Nr({
|
|
8682
8790
|
textbox: s,
|
|
8683
8791
|
styles: ie,
|
|
8684
8792
|
range: V
|
|
8685
8793
|
}) : !1;
|
|
8686
8794
|
we = e || t;
|
|
8687
8795
|
} else if (Object.keys(U).length) {
|
|
8688
|
-
let e =
|
|
8689
|
-
e && (we =
|
|
8796
|
+
let e = jr({ textbox: s });
|
|
8797
|
+
e && (we = Nr({
|
|
8690
8798
|
textbox: s,
|
|
8691
8799
|
styles: U,
|
|
8692
8800
|
range: e
|
|
8693
8801
|
}));
|
|
8694
8802
|
}
|
|
8695
|
-
let Te = we &&
|
|
8803
|
+
let Te = we && Zr({ stylesList: [
|
|
8696
8804
|
H,
|
|
8697
8805
|
ie,
|
|
8698
8806
|
U
|
|
8699
8807
|
] });
|
|
8700
8808
|
if (we && (s.dirty = !0), V && (h !== void 0 || g !== void 0)) {
|
|
8701
|
-
let e =
|
|
8809
|
+
let e = fi({
|
|
8702
8810
|
textbox: s,
|
|
8703
8811
|
range: V
|
|
8704
8812
|
}), t = {};
|
|
8705
|
-
h !== void 0 && (t.fontFamily = h), g !== void 0 && (t.fontSize = g),
|
|
8813
|
+
h !== void 0 && (t.fontFamily = h), g !== void 0 && (t.fontSize = g), Hr({
|
|
8706
8814
|
textbox: s,
|
|
8707
8815
|
lineIndices: e,
|
|
8708
8816
|
updates: t
|
|
8709
8817
|
});
|
|
8710
8818
|
}
|
|
8711
8819
|
if (B && (C !== void 0 || w !== void 0 || T !== void 0)) {
|
|
8712
|
-
let e =
|
|
8820
|
+
let e = pi({
|
|
8713
8821
|
textbox: s,
|
|
8714
8822
|
range: B
|
|
8715
8823
|
}), t = {};
|
|
8716
|
-
C !== void 0 && (t.fill = C), (w !== void 0 || T !== void 0) && (ae === null && (t.stroke = null), ae != null && (t.stroke = ae)),
|
|
8824
|
+
C !== void 0 && (t.fill = C), (w !== void 0 || T !== void 0) && (ae === null && (t.stroke = null), ae != null && (t.stroke = ae)), Hr({
|
|
8717
8825
|
textbox: s,
|
|
8718
8826
|
lineIndices: e,
|
|
8719
8827
|
updates: t
|
|
@@ -8808,7 +8916,7 @@ var ai = class {
|
|
|
8808
8916
|
clampToMontage: r
|
|
8809
8917
|
}));
|
|
8810
8918
|
let a = !1;
|
|
8811
|
-
i || (a =
|
|
8919
|
+
i || (a = Qr({ textbox: e }));
|
|
8812
8920
|
let o = !1;
|
|
8813
8921
|
return !i && t && (this.editor.canvasManager.applyObjectPlacement({
|
|
8814
8922
|
object: e,
|
|
@@ -8816,7 +8924,7 @@ var ai = class {
|
|
|
8816
8924
|
}), o = !0), (i || a) && (e.dirty = !0), (i || a || o) && e.setCoords(), i || a;
|
|
8817
8925
|
}
|
|
8818
8926
|
_restoreTextboxContentPlacement({ textbox: e, contentPlacement: t }) {
|
|
8819
|
-
let n =
|
|
8927
|
+
let n = Jr({
|
|
8820
8928
|
textbox: e,
|
|
8821
8929
|
originX: t.originX,
|
|
8822
8930
|
originY: t.originY
|
|
@@ -8836,15 +8944,15 @@ var ai = class {
|
|
|
8836
8944
|
_syncLineFontDefaultsOnTextChanged({ textbox: e }) {
|
|
8837
8945
|
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;
|
|
8838
8946
|
if (h !== 0 && n && Object.keys(n).length) {
|
|
8839
|
-
let e =
|
|
8947
|
+
let e = mi({
|
|
8840
8948
|
previous: d,
|
|
8841
8949
|
next: u
|
|
8842
|
-
}), t =
|
|
8950
|
+
}), t = hi({
|
|
8843
8951
|
text: d,
|
|
8844
8952
|
charIndex: e
|
|
8845
8953
|
});
|
|
8846
8954
|
if (h > 0) {
|
|
8847
|
-
let r =
|
|
8955
|
+
let r = gi({
|
|
8848
8956
|
text: d,
|
|
8849
8957
|
lineIndex: t
|
|
8850
8958
|
}), i = t + 1;
|
|
@@ -8885,7 +8993,7 @@ var ai = class {
|
|
|
8885
8993
|
let t = p[e] ?? "", n = g ? g[e] : void 0;
|
|
8886
8994
|
if (n && (T = n), t.length !== 0) {
|
|
8887
8995
|
if (n) {
|
|
8888
|
-
let r =
|
|
8996
|
+
let r = Ur({
|
|
8889
8997
|
lineText: t,
|
|
8890
8998
|
lineStyles: S ? S[e] : void 0,
|
|
8891
8999
|
lineDefaults: n
|
|
@@ -8925,16 +9033,16 @@ var ai = class {
|
|
|
8925
9033
|
if (!Number.isFinite(f) || f <= 0) return !1;
|
|
8926
9034
|
let p = a.split("\n").length, m = !1;
|
|
8927
9035
|
Math.abs((e.width ?? 0) - f) > .01 && (e.set({ width: f }), m = !0), e.initDimensions();
|
|
8928
|
-
let { textLines: h } = e, g = Array.isArray(h) && h.length > p, _ = Math.ceil(
|
|
9036
|
+
let { textLines: h } = e, g = Array.isArray(h) && h.length > p, _ = Math.ceil(Kr({
|
|
8929
9037
|
textbox: e,
|
|
8930
9038
|
text: a
|
|
8931
9039
|
})), v = Math.min(e.minWidth ?? 1, f), y = Math.min(f, Math.max(_, v));
|
|
8932
|
-
g && (y = f), Math.abs((e.width ?? 0) - y) > .01 && (e.set({ width: y }), e.initDimensions(), m = !0),
|
|
9040
|
+
g && (y = f), Math.abs((e.width ?? 0) - y) > .01 && (e.set({ width: y }), e.initDimensions(), m = !0), Qr({ textbox: e }) && (m = !0), t && r.applyObjectPlacement({
|
|
8933
9041
|
object: e,
|
|
8934
9042
|
placement: t
|
|
8935
9043
|
});
|
|
8936
9044
|
let b = !1;
|
|
8937
|
-
return n && (b =
|
|
9045
|
+
return n && (b = Yr({
|
|
8938
9046
|
textbox: e,
|
|
8939
9047
|
montageLeft: o,
|
|
8940
9048
|
montageRight: o + s
|
|
@@ -8992,7 +9100,7 @@ var ai = class {
|
|
|
8992
9100
|
_getDefaultFontFamily() {
|
|
8993
9101
|
return this.fonts[0]?.family ?? "Arial";
|
|
8994
9102
|
}
|
|
8995
|
-
},
|
|
9103
|
+
}, vi = ({ x1: e, y1: t, x2: n, y2: r }) => (Math.atan2(r - t, n - e) * 180 / Math.PI + 360) % 360, yi = (e) => {
|
|
8996
9104
|
if (!e || typeof e != "object") return null;
|
|
8997
9105
|
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) => ({
|
|
8998
9106
|
color: typeof e.color == "string" ? e.color : "#000000",
|
|
@@ -9003,7 +9111,7 @@ var ai = class {
|
|
|
9003
9111
|
let { x1: e, y1: t, x2: r, y2: i } = n;
|
|
9004
9112
|
if (typeof e == "number" && typeof t == "number" && typeof r == "number" && typeof i == "number") return {
|
|
9005
9113
|
type: "linear",
|
|
9006
|
-
angle:
|
|
9114
|
+
angle: vi({
|
|
9007
9115
|
x1: e,
|
|
9008
9116
|
y1: t,
|
|
9009
9117
|
x2: r,
|
|
@@ -9031,7 +9139,7 @@ var ai = class {
|
|
|
9031
9139
|
};
|
|
9032
9140
|
}
|
|
9033
9141
|
return null;
|
|
9034
|
-
},
|
|
9142
|
+
}, bi = "_templateAnchorX", xi = "_templateAnchorY", Si = class t {
|
|
9035
9143
|
constructor({ editor: e }) {
|
|
9036
9144
|
this.editor = e;
|
|
9037
9145
|
}
|
|
@@ -9040,7 +9148,7 @@ var ai = class {
|
|
|
9040
9148
|
if (!p.length) return s.emitWarning({
|
|
9041
9149
|
origin: "TemplateManager",
|
|
9042
9150
|
method: "serializeSelection",
|
|
9043
|
-
code:
|
|
9151
|
+
code: Dr.TEMPLATE_MANAGER.NO_OBJECTS_SELECTED,
|
|
9044
9152
|
message: "Нет объектов для сериализации шаблона"
|
|
9045
9153
|
}), null;
|
|
9046
9154
|
let m = t._getBounds(o), h = t._getMontageSize({
|
|
@@ -9069,14 +9177,14 @@ var ai = class {
|
|
|
9069
9177
|
if (!s?.length) return a.emitWarning({
|
|
9070
9178
|
origin: "TemplateManager",
|
|
9071
9179
|
method: "applyTemplate",
|
|
9072
|
-
code:
|
|
9180
|
+
code: Dr.TEMPLATE_MANAGER.INVALID_TEMPLATE,
|
|
9073
9181
|
message: "Шаблон не содержит объектов"
|
|
9074
9182
|
}), null;
|
|
9075
9183
|
let u = t._getBounds(r);
|
|
9076
9184
|
if (!u) return a.emitWarning({
|
|
9077
9185
|
origin: "TemplateManager",
|
|
9078
9186
|
method: "applyTemplate",
|
|
9079
|
-
code:
|
|
9187
|
+
code: Dr.TEMPLATE_MANAGER.INVALID_TARGET,
|
|
9080
9188
|
message: "Не удалось определить границы монтажной области"
|
|
9081
9189
|
}), null;
|
|
9082
9190
|
let d = t._getMontageSize({
|
|
@@ -9095,7 +9203,7 @@ var ai = class {
|
|
|
9095
9203
|
if (!r.length) return a.emitWarning({
|
|
9096
9204
|
origin: "TemplateManager",
|
|
9097
9205
|
method: "applyTemplate",
|
|
9098
|
-
code:
|
|
9206
|
+
code: Dr.TEMPLATE_MANAGER.INVALID_TEMPLATE,
|
|
9099
9207
|
message: "Не удалось создать объекты шаблона"
|
|
9100
9208
|
}), null;
|
|
9101
9209
|
let { backgroundObject: i, contentObjects: c } = t._extractBackgroundObject(r);
|
|
@@ -9130,7 +9238,7 @@ var ai = class {
|
|
|
9130
9238
|
return a.emitError({
|
|
9131
9239
|
origin: "TemplateManager",
|
|
9132
9240
|
method: "applyTemplate",
|
|
9133
|
-
code:
|
|
9241
|
+
code: Dr.TEMPLATE_MANAGER.APPLY_FAILED,
|
|
9134
9242
|
message: "Ошибка применения шаблона",
|
|
9135
9243
|
data: {
|
|
9136
9244
|
templateId: l,
|
|
@@ -9284,8 +9392,8 @@ var ai = class {
|
|
|
9284
9392
|
baseHeight: a,
|
|
9285
9393
|
scale: n,
|
|
9286
9394
|
useRelativePositions: o,
|
|
9287
|
-
anchorX: t._resolveAnchor(s,
|
|
9288
|
-
anchorY: t._resolveAnchor(s,
|
|
9395
|
+
anchorX: t._resolveAnchor(s, bi),
|
|
9396
|
+
anchorY: t._resolveAnchor(s, xi)
|
|
9289
9397
|
})
|
|
9290
9398
|
}), h = f * n, g = p * n, _ = e.originX ?? "center", v = e.originY ?? "center";
|
|
9291
9399
|
e.set({
|
|
@@ -9299,7 +9407,7 @@ var ai = class {
|
|
|
9299
9407
|
originX: _,
|
|
9300
9408
|
originY: v
|
|
9301
9409
|
}
|
|
9302
|
-
}), delete s[
|
|
9410
|
+
}), delete s[bi], delete s[xi];
|
|
9303
9411
|
}
|
|
9304
9412
|
static _getPositioningBounds({ bounds: e, baseWidth: n, baseHeight: r, scale: i, useRelativePositions: a, anchorX: o, anchorY: s }) {
|
|
9305
9413
|
if (!a) return e;
|
|
@@ -9363,7 +9471,7 @@ var ai = class {
|
|
|
9363
9471
|
});
|
|
9364
9472
|
if (!i || !s || !o) return;
|
|
9365
9473
|
e.setCoords();
|
|
9366
|
-
let c = e, l = t._resolveAnchor(c,
|
|
9474
|
+
let c = e, l = t._resolveAnchor(c, bi), 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;
|
|
9367
9475
|
e.set("width", i), e.initDimensions();
|
|
9368
9476
|
let g = t._getLongestLineWidth({
|
|
9369
9477
|
textbox: e,
|
|
@@ -9392,10 +9500,10 @@ var ai = class {
|
|
|
9392
9500
|
x: (p.left - o) / d,
|
|
9393
9501
|
y: (p.top - s) / f
|
|
9394
9502
|
}, h = (u.left - o) / d, g = (u.top - s) / f, _ = h + u.width / d, v = g + u.height / f;
|
|
9395
|
-
return a[
|
|
9503
|
+
return a[bi] = t._detectAnchor({
|
|
9396
9504
|
start: h,
|
|
9397
9505
|
end: _
|
|
9398
|
-
}), a[
|
|
9506
|
+
}), a[xi] = t._detectAnchor({
|
|
9399
9507
|
start: g,
|
|
9400
9508
|
end: v
|
|
9401
9509
|
}), a.left = m.x, a.top = m.y, a;
|
|
@@ -9420,7 +9528,7 @@ var ai = class {
|
|
|
9420
9528
|
withoutSave: !0
|
|
9421
9529
|
}), !0;
|
|
9422
9530
|
if (a === "gradient") {
|
|
9423
|
-
let e =
|
|
9531
|
+
let e = yi(r);
|
|
9424
9532
|
if (e) return n.setGradientBackground({
|
|
9425
9533
|
gradient: e,
|
|
9426
9534
|
customData: o,
|
|
@@ -9441,7 +9549,7 @@ var ai = class {
|
|
|
9441
9549
|
r.emitWarning({
|
|
9442
9550
|
origin: "TemplateManager",
|
|
9443
9551
|
method: "applyTemplate",
|
|
9444
|
-
code:
|
|
9552
|
+
code: Dr.TEMPLATE_MANAGER.APPLY_FAILED,
|
|
9445
9553
|
message: "Не удалось применить фон из шаблона",
|
|
9446
9554
|
data: e
|
|
9447
9555
|
});
|
|
@@ -9477,29 +9585,29 @@ var ai = class {
|
|
|
9477
9585
|
enlivenObjectEnlivables(e) {
|
|
9478
9586
|
return C.enlivenObjectEnlivables(e);
|
|
9479
9587
|
}
|
|
9480
|
-
},
|
|
9481
|
-
let n =
|
|
9588
|
+
}, Ci = "#3D8BF4", wi = .5, Ti = ({ distance: e }) => Number.isFinite(e) ? Math.round(Math.max(0, e)) : 0, Ei = ({ firstDistance: e, secondDistance: t }) => {
|
|
9589
|
+
let n = Ti({ distance: e }), r = Ti({ distance: t });
|
|
9482
9590
|
return {
|
|
9483
9591
|
firstDisplayDistance: n,
|
|
9484
9592
|
secondDisplayDistance: r,
|
|
9485
9593
|
displayDistanceDiff: Math.abs(n - r),
|
|
9486
9594
|
commonDisplayDistance: Math.max(n, r)
|
|
9487
9595
|
};
|
|
9488
|
-
},
|
|
9596
|
+
}, Di = ({ firstStart: e, firstEnd: t, secondStart: n, secondEnd: r }) => Math.min(t, r) - Math.max(e, n), Oi = ({ step: e }) => {
|
|
9489
9597
|
let t = Math.abs(e).toString(), n = t.indexOf(".");
|
|
9490
9598
|
return n === -1 ? 0 : t.slice(n + 1).length;
|
|
9491
|
-
},
|
|
9599
|
+
}, ki = ({ value: e, step: t }) => {
|
|
9492
9600
|
if (t === 0) return e;
|
|
9493
|
-
let n =
|
|
9601
|
+
let n = Oi({ step: t }), r = Math.round(e / t) * t;
|
|
9494
9602
|
return Number(r.toFixed(n));
|
|
9495
|
-
},
|
|
9603
|
+
}, Ai = ({ value: e, step: t }) => {
|
|
9496
9604
|
if (t === 0) return !0;
|
|
9497
|
-
let n =
|
|
9605
|
+
let n = ki({
|
|
9498
9606
|
value: e,
|
|
9499
9607
|
step: t
|
|
9500
|
-
}), r = 10 ** -(
|
|
9608
|
+
}), r = 10 ** -(Oi({ step: t }) + 4);
|
|
9501
9609
|
return Math.abs(n - e) <= r;
|
|
9502
|
-
},
|
|
9610
|
+
}, ji = ({ bounds: e, axis: t }) => {
|
|
9503
9611
|
let { left: n = 0, right: r = 0, top: i = 0, bottom: a = 0 } = e;
|
|
9504
9612
|
return t === "vertical" ? {
|
|
9505
9613
|
start: i,
|
|
@@ -9508,7 +9616,7 @@ var ai = class {
|
|
|
9508
9616
|
start: n,
|
|
9509
9617
|
end: r
|
|
9510
9618
|
};
|
|
9511
|
-
},
|
|
9619
|
+
}, Mi = ({ items: e, axis: t }) => {
|
|
9512
9620
|
for (let n = 1; n < e.length; n += 1) {
|
|
9513
9621
|
let r = e[n], { bounds: i } = r, a = i[t], o = n - 1;
|
|
9514
9622
|
for (; o >= 0;) {
|
|
@@ -9518,10 +9626,10 @@ var ai = class {
|
|
|
9518
9626
|
}
|
|
9519
9627
|
e[o + 1] = r;
|
|
9520
9628
|
}
|
|
9521
|
-
},
|
|
9629
|
+
}, Ni = ({ items: e, index: t, axis: n, direction: r }) => {
|
|
9522
9630
|
let i = e[t];
|
|
9523
9631
|
if (!i) return null;
|
|
9524
|
-
let { bounds: a } = i, { start: o, end: s } =
|
|
9632
|
+
let { bounds: a } = i, { start: o, end: s } = ji({
|
|
9525
9633
|
bounds: a,
|
|
9526
9634
|
axis: n
|
|
9527
9635
|
});
|
|
@@ -9529,7 +9637,7 @@ var ai = class {
|
|
|
9529
9637
|
for (let r = t - 1; r >= 0; --r) {
|
|
9530
9638
|
let t = e[r];
|
|
9531
9639
|
if (!t) continue;
|
|
9532
|
-
let { bounds: i } = t, { end: a } =
|
|
9640
|
+
let { bounds: i } = t, { end: a } = ji({
|
|
9533
9641
|
bounds: i,
|
|
9534
9642
|
axis: n
|
|
9535
9643
|
});
|
|
@@ -9540,26 +9648,26 @@ var ai = class {
|
|
|
9540
9648
|
for (let r = t + 1; r < e.length; r += 1) {
|
|
9541
9649
|
let t = e[r];
|
|
9542
9650
|
if (!t) continue;
|
|
9543
|
-
let { bounds: i } = t, { start: a } =
|
|
9651
|
+
let { bounds: i } = t, { start: a } = ji({
|
|
9544
9652
|
bounds: i,
|
|
9545
9653
|
axis: n
|
|
9546
9654
|
});
|
|
9547
9655
|
if (a - s >= 0) return r;
|
|
9548
9656
|
}
|
|
9549
9657
|
return null;
|
|
9550
|
-
},
|
|
9658
|
+
}, Pi = ({ items: e }) => {
|
|
9551
9659
|
for (let t = 0; t < e.length; t += 1) {
|
|
9552
9660
|
let { isActive: n } = e[t];
|
|
9553
9661
|
if (n) return t;
|
|
9554
9662
|
}
|
|
9555
9663
|
return -1;
|
|
9556
|
-
},
|
|
9664
|
+
}, Fi = ({ patternAxis: e, activeRangeStart: t, activeRangeEnd: n, tolerance: r = 0 }) => {
|
|
9557
9665
|
let i = Math.min(t, n), a = Math.max(t, n);
|
|
9558
9666
|
return e >= i - r && e <= a + r;
|
|
9559
|
-
},
|
|
9667
|
+
}, Ii = ({ patternStart: e, patternEnd: t, activeStart: n, activeEnd: r }) => t <= n ? "before" : e >= r ? "after" : null, Li = ({ baseOption: e, candidateOption: t }) => {
|
|
9560
9668
|
let { delta: n, guide: { distance: r } } = e, { delta: i, guide: { distance: a } } = t;
|
|
9561
9669
|
return n === i && r === a;
|
|
9562
|
-
},
|
|
9670
|
+
}, Ri = ({ options: e }) => {
|
|
9563
9671
|
let t = e[0];
|
|
9564
9672
|
for (let n = 1; n < e.length; n += 1) {
|
|
9565
9673
|
let r = e[n];
|
|
@@ -9570,11 +9678,11 @@ var ai = class {
|
|
|
9570
9678
|
r.diff === t.diff && Math.abs(r.delta) < Math.abs(t.delta) && (t = r);
|
|
9571
9679
|
}
|
|
9572
9680
|
return t;
|
|
9573
|
-
},
|
|
9681
|
+
}, zi = ({ currentOption: e, nextOption: t }) => {
|
|
9574
9682
|
if (!e) return !0;
|
|
9575
9683
|
let { contextDistance: n, diff: r, delta: i } = e, { contextDistance: a, diff: o, delta: s } = t;
|
|
9576
9684
|
return a < n ? !0 : a > n ? !1 : o < r ? !0 : o > r ? !1 : Math.abs(s) < Math.abs(i);
|
|
9577
|
-
},
|
|
9685
|
+
}, Bi = ({ options: e }) => {
|
|
9578
9686
|
let t = [], n = null, r = null;
|
|
9579
9687
|
for (let i of e) {
|
|
9580
9688
|
let { kind: e, side: a } = i;
|
|
@@ -9582,18 +9690,18 @@ var ai = class {
|
|
|
9582
9690
|
t.push(i);
|
|
9583
9691
|
continue;
|
|
9584
9692
|
}
|
|
9585
|
-
a === "before" &&
|
|
9693
|
+
a === "before" && zi({
|
|
9586
9694
|
currentOption: n,
|
|
9587
9695
|
nextOption: i
|
|
9588
|
-
}) && (n = i), a === "after" &&
|
|
9696
|
+
}) && (n = i), a === "after" && zi({
|
|
9589
9697
|
currentOption: r,
|
|
9590
9698
|
nextOption: i
|
|
9591
9699
|
}) && (r = i);
|
|
9592
9700
|
}
|
|
9593
9701
|
return n && t.push(n), r && t.push(r), t;
|
|
9594
|
-
},
|
|
9702
|
+
}, Vi = ({ options: e, side: t, baseOption: n }) => {
|
|
9595
9703
|
let r = null;
|
|
9596
|
-
for (let i of e) if (i.side === t &&
|
|
9704
|
+
for (let i of e) if (i.side === t && Li({
|
|
9597
9705
|
baseOption: n,
|
|
9598
9706
|
candidateOption: i
|
|
9599
9707
|
})) {
|
|
@@ -9604,63 +9712,63 @@ var ai = class {
|
|
|
9604
9712
|
!r || i.diff !== r.diff || Math.abs(i.delta) < Math.abs(r.delta) && (r = i);
|
|
9605
9713
|
}
|
|
9606
9714
|
return r;
|
|
9607
|
-
},
|
|
9715
|
+
}, Hi = ({ option: e }) => {
|
|
9608
9716
|
let { side: t, kind: n, guide: { distance: r } } = e;
|
|
9609
9717
|
return {
|
|
9610
9718
|
side: t,
|
|
9611
9719
|
kind: n,
|
|
9612
9720
|
distance: r
|
|
9613
9721
|
};
|
|
9614
|
-
},
|
|
9722
|
+
}, Ui = ({ option: e, context: t }) => {
|
|
9615
9723
|
let { side: n, kind: r, distance: i } = t, { side: a, kind: o, guide: { distance: s } } = e;
|
|
9616
9724
|
return n !== a || r !== o ? !1 : Math.abs(s - i) <= 1;
|
|
9617
|
-
},
|
|
9725
|
+
}, Wi = ({ options: e, context: t }) => {
|
|
9618
9726
|
if (!t) return null;
|
|
9619
|
-
for (let n of e) if (
|
|
9727
|
+
for (let n of e) if (Ui({
|
|
9620
9728
|
option: n,
|
|
9621
9729
|
context: t
|
|
9622
9730
|
})) return n;
|
|
9623
9731
|
return null;
|
|
9624
|
-
},
|
|
9625
|
-
let i =
|
|
9732
|
+
}, Gi = ({ options: e, bestOption: t, previousContext: n, switchDistance: r = 0 }) => {
|
|
9733
|
+
let i = Wi({
|
|
9626
9734
|
options: e,
|
|
9627
9735
|
context: n
|
|
9628
9736
|
});
|
|
9629
9737
|
if (!i) return t;
|
|
9630
9738
|
let a = Math.max(0, r);
|
|
9631
9739
|
return a === 0 || Math.abs(t.delta - i.delta) >= a ? t : i;
|
|
9632
|
-
},
|
|
9740
|
+
}, Ki = ({ guides: e, seenGuideKeys: t, guide: n }) => {
|
|
9633
9741
|
let { type: r, axis: i, refStart: a, refEnd: o, activeStart: s, activeEnd: c, distance: l } = n, u = `${r}:${i}:${a}:${o}:${s}:${c}:${l}`;
|
|
9634
9742
|
t.has(u) || (t.add(u), e.push(n));
|
|
9635
|
-
},
|
|
9743
|
+
}, qi = ({ options: e, previousContext: t = null, switchDistance: n = 0 }) => {
|
|
9636
9744
|
if (!e.length) return {
|
|
9637
9745
|
delta: 0,
|
|
9638
9746
|
guides: [],
|
|
9639
9747
|
context: null
|
|
9640
9748
|
};
|
|
9641
|
-
let r =
|
|
9749
|
+
let r = Bi({ options: e }), i = [];
|
|
9642
9750
|
for (let e of r) e.kind === "reference" && i.push(e);
|
|
9643
|
-
let a = i.length > 0, o = a ? i : r, s =
|
|
9751
|
+
let a = i.length > 0, o = a ? i : r, s = Gi({
|
|
9644
9752
|
options: o,
|
|
9645
|
-
bestOption:
|
|
9753
|
+
bestOption: Ri({ options: o }),
|
|
9646
9754
|
previousContext: t,
|
|
9647
9755
|
switchDistance: n
|
|
9648
|
-
}), c =
|
|
9756
|
+
}), c = Vi({
|
|
9649
9757
|
options: o,
|
|
9650
9758
|
side: "before",
|
|
9651
9759
|
baseOption: s
|
|
9652
|
-
}), l =
|
|
9760
|
+
}), l = Vi({
|
|
9653
9761
|
options: o,
|
|
9654
9762
|
side: "after",
|
|
9655
9763
|
baseOption: s
|
|
9656
|
-
}), u =
|
|
9764
|
+
}), u = Vi({
|
|
9657
9765
|
options: a ? r : o,
|
|
9658
9766
|
side: "center",
|
|
9659
9767
|
baseOption: s
|
|
9660
9768
|
}), d = [];
|
|
9661
9769
|
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);
|
|
9662
9770
|
let f = [], p = /* @__PURE__ */ new Set();
|
|
9663
|
-
for (let e of d)
|
|
9771
|
+
for (let e of d) Ki({
|
|
9664
9772
|
guides: f,
|
|
9665
9773
|
seenGuideKeys: p,
|
|
9666
9774
|
guide: e.guide
|
|
@@ -9668,15 +9776,15 @@ var ai = class {
|
|
|
9668
9776
|
return {
|
|
9669
9777
|
delta: s.delta,
|
|
9670
9778
|
guides: f,
|
|
9671
|
-
context:
|
|
9779
|
+
context: Hi({ option: s })
|
|
9672
9780
|
};
|
|
9673
|
-
},
|
|
9674
|
-
let s = n - (e - r), c =
|
|
9781
|
+
}, Ji = ({ activeStart: e, activeEnd: t, targetGap: n, beforeEdge: r, afterEdge: i, threshold: a, step: o }) => {
|
|
9782
|
+
let s = n - (e - r), c = ki({
|
|
9675
9783
|
value: s,
|
|
9676
9784
|
step: o
|
|
9677
9785
|
}), l = Math.max(1, Math.ceil(a / Math.max(o, 1))), u = null;
|
|
9678
9786
|
for (let d = -l; d <= l; d += 1) {
|
|
9679
|
-
let l = c + d * o, f = e + l, p = t + l, m = f - r, h = i - p, { displayDistanceDiff: g, commonDisplayDistance: _ } =
|
|
9787
|
+
let l = c + d * o, f = e + l, p = t + l, m = f - r, h = i - p, { displayDistanceDiff: g, commonDisplayDistance: _ } = Ei({
|
|
9680
9788
|
firstDistance: m,
|
|
9681
9789
|
secondDistance: h
|
|
9682
9790
|
});
|
|
@@ -9691,13 +9799,13 @@ var ai = class {
|
|
|
9691
9799
|
});
|
|
9692
9800
|
}
|
|
9693
9801
|
return u;
|
|
9694
|
-
},
|
|
9695
|
-
let { secondDisplayDistance: n, displayDistanceDiff: r } =
|
|
9802
|
+
}, Yi = ({ currentGap: e, referenceGap: t }) => {
|
|
9803
|
+
let { secondDisplayDistance: n, displayDistanceDiff: r } = Ei({
|
|
9696
9804
|
firstDistance: e,
|
|
9697
9805
|
secondDistance: t
|
|
9698
9806
|
});
|
|
9699
9807
|
return r > 1 ? null : n;
|
|
9700
|
-
},
|
|
9808
|
+
}, Xi = ({ anchors: e, positions: t, threshold: n }) => {
|
|
9701
9809
|
let r = 0, i = n + 1, a = null;
|
|
9702
9810
|
for (let o of t) for (let t of e) {
|
|
9703
9811
|
let e = Math.abs(t - o);
|
|
@@ -9707,8 +9815,8 @@ var ai = class {
|
|
|
9707
9815
|
delta: r,
|
|
9708
9816
|
guidePosition: a
|
|
9709
9817
|
};
|
|
9710
|
-
},
|
|
9711
|
-
let { left: r, right: i, centerX: a, top: o, bottom: s, centerY: c } = e, l =
|
|
9818
|
+
}, Zi = ({ activeBounds: e, threshold: t, anchors: n }) => {
|
|
9819
|
+
let { left: r, right: i, centerX: a, top: o, bottom: s, centerY: c } = e, l = Xi({
|
|
9712
9820
|
anchors: n.vertical,
|
|
9713
9821
|
positions: [
|
|
9714
9822
|
r,
|
|
@@ -9716,7 +9824,7 @@ var ai = class {
|
|
|
9716
9824
|
i
|
|
9717
9825
|
],
|
|
9718
9826
|
threshold: t
|
|
9719
|
-
}), u =
|
|
9827
|
+
}), u = Xi({
|
|
9720
9828
|
anchors: n.horizontal,
|
|
9721
9829
|
positions: [
|
|
9722
9830
|
o,
|
|
@@ -9736,11 +9844,11 @@ var ai = class {
|
|
|
9736
9844
|
deltaY: u.delta,
|
|
9737
9845
|
guides: d
|
|
9738
9846
|
};
|
|
9739
|
-
},
|
|
9847
|
+
}, Qi = ({ activeBounds: e, candidates: t, threshold: n, patterns: r, previousContext: i = null, switchDistance: a = 0 }) => {
|
|
9740
9848
|
let { centerX: o, top: s, bottom: c, left: l, right: u } = e, d = [];
|
|
9741
9849
|
for (let e of t) {
|
|
9742
9850
|
let { left: t, right: n } = e;
|
|
9743
|
-
|
|
9851
|
+
Di({
|
|
9744
9852
|
firstStart: t,
|
|
9745
9853
|
firstEnd: n,
|
|
9746
9854
|
secondStart: l,
|
|
@@ -9760,22 +9868,22 @@ var ai = class {
|
|
|
9760
9868
|
f.push({
|
|
9761
9869
|
bounds: e,
|
|
9762
9870
|
isActive: !0
|
|
9763
|
-
}),
|
|
9871
|
+
}), Mi({
|
|
9764
9872
|
items: f,
|
|
9765
9873
|
axis: "top"
|
|
9766
9874
|
});
|
|
9767
|
-
let p =
|
|
9875
|
+
let p = Pi({ items: f });
|
|
9768
9876
|
if (p === -1) return {
|
|
9769
9877
|
delta: 0,
|
|
9770
9878
|
guides: [],
|
|
9771
9879
|
context: null
|
|
9772
9880
|
};
|
|
9773
|
-
let m = [], h = c - s, g =
|
|
9881
|
+
let m = [], h = c - s, g = Ni({
|
|
9774
9882
|
items: f,
|
|
9775
9883
|
index: p,
|
|
9776
9884
|
axis: "vertical",
|
|
9777
9885
|
direction: "prev"
|
|
9778
|
-
}), _ =
|
|
9886
|
+
}), _ = Ni({
|
|
9779
9887
|
items: f,
|
|
9780
9888
|
index: p,
|
|
9781
9889
|
axis: "vertical",
|
|
@@ -9784,19 +9892,19 @@ var ai = class {
|
|
|
9784
9892
|
if (v && y) {
|
|
9785
9893
|
let { bounds: e } = v, { bounds: t } = y, { bottom: r } = e, { top: i } = t, a = i - r - h;
|
|
9786
9894
|
if (a >= 0) {
|
|
9787
|
-
let e =
|
|
9895
|
+
let e = ki({
|
|
9788
9896
|
value: a / 2,
|
|
9789
9897
|
step: 1
|
|
9790
9898
|
}), t = s - r, l = i - c, u = Math.abs(t - e), d = Math.abs(l - e);
|
|
9791
9899
|
if (Math.max(u, d) <= n) {
|
|
9792
|
-
let t =
|
|
9900
|
+
let t = Ji({
|
|
9793
9901
|
activeStart: s,
|
|
9794
9902
|
activeEnd: c,
|
|
9795
9903
|
targetGap: e,
|
|
9796
9904
|
beforeEdge: r,
|
|
9797
9905
|
afterEdge: i,
|
|
9798
9906
|
threshold: n,
|
|
9799
|
-
step:
|
|
9907
|
+
step: wi
|
|
9800
9908
|
});
|
|
9801
9909
|
if (t) {
|
|
9802
9910
|
let { delta: e, distance: n, diff: i, activeStart: a, activeEnd: s } = t, c = {
|
|
@@ -9833,16 +9941,16 @@ var ai = class {
|
|
|
9833
9941
|
}
|
|
9834
9942
|
for (let e of r) {
|
|
9835
9943
|
let { axis: t, start: r, end: i, distance: a } = e;
|
|
9836
|
-
if (!
|
|
9944
|
+
if (!Ai({
|
|
9837
9945
|
value: a,
|
|
9838
9946
|
step: .5
|
|
9839
|
-
}) || !
|
|
9947
|
+
}) || !Fi({
|
|
9840
9948
|
patternAxis: t,
|
|
9841
9949
|
activeRangeStart: l,
|
|
9842
9950
|
activeRangeEnd: u,
|
|
9843
9951
|
tolerance: n
|
|
9844
9952
|
})) continue;
|
|
9845
|
-
let d =
|
|
9953
|
+
let d = Ii({
|
|
9846
9954
|
patternStart: r,
|
|
9847
9955
|
patternEnd: i,
|
|
9848
9956
|
activeStart: s,
|
|
@@ -9850,12 +9958,12 @@ var ai = class {
|
|
|
9850
9958
|
});
|
|
9851
9959
|
if (d) {
|
|
9852
9960
|
if (b !== null && S && d === "before" && Math.abs(b - a) <= n) {
|
|
9853
|
-
let e =
|
|
9961
|
+
let e = ki({
|
|
9854
9962
|
value: a - b,
|
|
9855
9963
|
step: 1
|
|
9856
9964
|
}), t = s + e, { bottom: c } = S, l = t - c, u = Math.abs(l - a);
|
|
9857
9965
|
if (u > n) continue;
|
|
9858
|
-
let d =
|
|
9966
|
+
let d = Yi({
|
|
9859
9967
|
currentGap: l,
|
|
9860
9968
|
referenceGap: a
|
|
9861
9969
|
});
|
|
@@ -9879,12 +9987,12 @@ var ai = class {
|
|
|
9879
9987
|
});
|
|
9880
9988
|
}
|
|
9881
9989
|
if (x !== null && C && d === "after" && Math.abs(x - a) <= n) {
|
|
9882
|
-
let e =
|
|
9990
|
+
let e = ki({
|
|
9883
9991
|
value: x - a,
|
|
9884
9992
|
step: 1
|
|
9885
9993
|
}), t = c + e, { top: s } = C, l = s - t, u = Math.abs(l - a);
|
|
9886
9994
|
if (u > n) continue;
|
|
9887
|
-
let d =
|
|
9995
|
+
let d = Yi({
|
|
9888
9996
|
currentGap: l,
|
|
9889
9997
|
referenceGap: a
|
|
9890
9998
|
});
|
|
@@ -9909,16 +10017,16 @@ var ai = class {
|
|
|
9909
10017
|
}
|
|
9910
10018
|
}
|
|
9911
10019
|
}
|
|
9912
|
-
return
|
|
10020
|
+
return qi({
|
|
9913
10021
|
options: m,
|
|
9914
10022
|
previousContext: i,
|
|
9915
10023
|
switchDistance: a
|
|
9916
10024
|
});
|
|
9917
|
-
},
|
|
10025
|
+
}, $i = ({ activeBounds: e, candidates: t, threshold: n, patterns: r, previousContext: i = null, switchDistance: a = 0 }) => {
|
|
9918
10026
|
let { centerY: o, left: s, right: c, top: l, bottom: u } = e, d = [];
|
|
9919
10027
|
for (let e of t) {
|
|
9920
10028
|
let { top: t, bottom: n } = e;
|
|
9921
|
-
|
|
10029
|
+
Di({
|
|
9922
10030
|
firstStart: t,
|
|
9923
10031
|
firstEnd: n,
|
|
9924
10032
|
secondStart: l,
|
|
@@ -9938,22 +10046,22 @@ var ai = class {
|
|
|
9938
10046
|
f.push({
|
|
9939
10047
|
bounds: e,
|
|
9940
10048
|
isActive: !0
|
|
9941
|
-
}),
|
|
10049
|
+
}), Mi({
|
|
9942
10050
|
items: f,
|
|
9943
10051
|
axis: "left"
|
|
9944
10052
|
});
|
|
9945
|
-
let p =
|
|
10053
|
+
let p = Pi({ items: f });
|
|
9946
10054
|
if (p === -1) return {
|
|
9947
10055
|
delta: 0,
|
|
9948
10056
|
guides: [],
|
|
9949
10057
|
context: null
|
|
9950
10058
|
};
|
|
9951
|
-
let m = [], h = c - s, g =
|
|
10059
|
+
let m = [], h = c - s, g = Ni({
|
|
9952
10060
|
items: f,
|
|
9953
10061
|
index: p,
|
|
9954
10062
|
axis: "horizontal",
|
|
9955
10063
|
direction: "prev"
|
|
9956
|
-
}), _ =
|
|
10064
|
+
}), _ = Ni({
|
|
9957
10065
|
items: f,
|
|
9958
10066
|
index: p,
|
|
9959
10067
|
axis: "horizontal",
|
|
@@ -9962,19 +10070,19 @@ var ai = class {
|
|
|
9962
10070
|
if (v && y) {
|
|
9963
10071
|
let { bounds: e } = v, { bounds: t } = y, { right: r } = e, { left: i } = t, a = i - r - h;
|
|
9964
10072
|
if (a >= 0) {
|
|
9965
|
-
let e =
|
|
10073
|
+
let e = ki({
|
|
9966
10074
|
value: a / 2,
|
|
9967
10075
|
step: 1
|
|
9968
10076
|
}), t = s - r, l = i - c, u = Math.abs(t - e), d = Math.abs(l - e);
|
|
9969
10077
|
if (Math.max(u, d) <= n) {
|
|
9970
|
-
let t =
|
|
10078
|
+
let t = Ji({
|
|
9971
10079
|
activeStart: s,
|
|
9972
10080
|
activeEnd: c,
|
|
9973
10081
|
targetGap: e,
|
|
9974
10082
|
beforeEdge: r,
|
|
9975
10083
|
afterEdge: i,
|
|
9976
10084
|
threshold: n,
|
|
9977
|
-
step:
|
|
10085
|
+
step: wi
|
|
9978
10086
|
});
|
|
9979
10087
|
if (t) {
|
|
9980
10088
|
let { delta: e, distance: n, diff: i, activeStart: a, activeEnd: s } = t, c = {
|
|
@@ -10011,16 +10119,16 @@ var ai = class {
|
|
|
10011
10119
|
}
|
|
10012
10120
|
for (let e of r) {
|
|
10013
10121
|
let { axis: t, start: r, end: i, distance: a } = e;
|
|
10014
|
-
if (!
|
|
10122
|
+
if (!Ai({
|
|
10015
10123
|
value: a,
|
|
10016
10124
|
step: .5
|
|
10017
|
-
}) || !
|
|
10125
|
+
}) || !Fi({
|
|
10018
10126
|
patternAxis: t,
|
|
10019
10127
|
activeRangeStart: l,
|
|
10020
10128
|
activeRangeEnd: u,
|
|
10021
10129
|
tolerance: n
|
|
10022
10130
|
})) continue;
|
|
10023
|
-
let d =
|
|
10131
|
+
let d = Ii({
|
|
10024
10132
|
patternStart: r,
|
|
10025
10133
|
patternEnd: i,
|
|
10026
10134
|
activeStart: s,
|
|
@@ -10028,12 +10136,12 @@ var ai = class {
|
|
|
10028
10136
|
});
|
|
10029
10137
|
if (d) {
|
|
10030
10138
|
if (b !== null && S && d === "before" && Math.abs(b - a) <= n) {
|
|
10031
|
-
let e =
|
|
10139
|
+
let e = ki({
|
|
10032
10140
|
value: a - b,
|
|
10033
10141
|
step: 1
|
|
10034
10142
|
}), t = s + e, { right: c } = S, l = t - c, u = Math.abs(l - a);
|
|
10035
10143
|
if (u > n) continue;
|
|
10036
|
-
let d =
|
|
10144
|
+
let d = Yi({
|
|
10037
10145
|
currentGap: l,
|
|
10038
10146
|
referenceGap: a
|
|
10039
10147
|
});
|
|
@@ -10057,12 +10165,12 @@ var ai = class {
|
|
|
10057
10165
|
});
|
|
10058
10166
|
}
|
|
10059
10167
|
if (x !== null && C && d === "after" && Math.abs(x - a) <= n) {
|
|
10060
|
-
let e =
|
|
10168
|
+
let e = ki({
|
|
10061
10169
|
value: x - a,
|
|
10062
10170
|
step: 1
|
|
10063
10171
|
}), t = c + e, { left: s } = C, l = s - t, u = Math.abs(l - a);
|
|
10064
10172
|
if (u > n) continue;
|
|
10065
|
-
let d =
|
|
10173
|
+
let d = Yi({
|
|
10066
10174
|
currentGap: l,
|
|
10067
10175
|
referenceGap: a
|
|
10068
10176
|
});
|
|
@@ -10087,20 +10195,20 @@ var ai = class {
|
|
|
10087
10195
|
}
|
|
10088
10196
|
}
|
|
10089
10197
|
}
|
|
10090
|
-
return
|
|
10198
|
+
return qi({
|
|
10091
10199
|
options: m,
|
|
10092
10200
|
previousContext: i,
|
|
10093
10201
|
switchDistance: a
|
|
10094
10202
|
});
|
|
10095
|
-
},
|
|
10096
|
-
let { vertical: o = null, horizontal: s = null } = i ?? {}, c =
|
|
10203
|
+
}, ea = ({ activeBounds: e, candidates: t, threshold: n, spacingPatterns: r, previousContexts: i, switchDistance: a = 0 }) => {
|
|
10204
|
+
let { vertical: o = null, horizontal: s = null } = i ?? {}, c = Qi({
|
|
10097
10205
|
activeBounds: e,
|
|
10098
10206
|
candidates: t,
|
|
10099
10207
|
threshold: n,
|
|
10100
10208
|
patterns: r.vertical,
|
|
10101
10209
|
previousContext: o,
|
|
10102
10210
|
switchDistance: a
|
|
10103
|
-
}), l =
|
|
10211
|
+
}), l = $i({
|
|
10104
10212
|
activeBounds: e,
|
|
10105
10213
|
candidates: t,
|
|
10106
10214
|
threshold: n,
|
|
@@ -10119,14 +10227,14 @@ var ai = class {
|
|
|
10119
10227
|
horizontal: l.context
|
|
10120
10228
|
}
|
|
10121
10229
|
};
|
|
10122
|
-
},
|
|
10230
|
+
}, ta = ({ context: e, x: t, y: n, width: r, height: i, radius: a }) => {
|
|
10123
10231
|
let o = Math.min(a, r / 2, i / 2);
|
|
10124
10232
|
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();
|
|
10125
|
-
},
|
|
10233
|
+
}, na = ({ 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 }) => {
|
|
10126
10234
|
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;
|
|
10127
10235
|
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";
|
|
10128
10236
|
let S = e.measureText(a).width + _ * 2, C = g + _ * 2, w = b - S / 2, T = x - C / 2;
|
|
10129
|
-
e.beginPath(),
|
|
10237
|
+
e.beginPath(), ta({
|
|
10130
10238
|
context: e,
|
|
10131
10239
|
x: w,
|
|
10132
10240
|
y: T,
|
|
@@ -10134,11 +10242,11 @@ var ai = class {
|
|
|
10134
10242
|
height: C,
|
|
10135
10243
|
radius: v
|
|
10136
10244
|
}), e.fill(), e.fillStyle = c, e.fillText(a, b, x), e.restore();
|
|
10137
|
-
},
|
|
10138
|
-
let { type: r, axis: i, refStart: a, refEnd: o, activeStart: s, activeEnd: c, distance: l } = t, u =
|
|
10245
|
+
}, ra = ({ context: e, guide: t, zoom: n }) => {
|
|
10246
|
+
let { type: r, axis: i, refStart: a, refEnd: o, activeStart: s, activeEnd: c, distance: l } = t, u = Ti({ distance: l }).toString();
|
|
10139
10247
|
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();
|
|
10140
|
-
let d =
|
|
10141
|
-
|
|
10248
|
+
let d = Ci;
|
|
10249
|
+
na({
|
|
10142
10250
|
context: e,
|
|
10143
10251
|
type: r,
|
|
10144
10252
|
axis: i,
|
|
@@ -10148,7 +10256,7 @@ var ai = class {
|
|
|
10148
10256
|
zoom: n,
|
|
10149
10257
|
color: d,
|
|
10150
10258
|
lineWidth: 1
|
|
10151
|
-
}),
|
|
10259
|
+
}), na({
|
|
10152
10260
|
context: e,
|
|
10153
10261
|
type: r,
|
|
10154
10262
|
axis: i,
|
|
@@ -10159,10 +10267,10 @@ var ai = class {
|
|
|
10159
10267
|
color: d,
|
|
10160
10268
|
lineWidth: 1
|
|
10161
10269
|
});
|
|
10162
|
-
},
|
|
10270
|
+
}, ia = ({ anchors: e, bounds: t }) => {
|
|
10163
10271
|
let { left: n, right: r, centerX: i, top: a, bottom: o, centerY: s } = t;
|
|
10164
10272
|
e.vertical.push(n, i, r), e.horizontal.push(a, s, o);
|
|
10165
|
-
},
|
|
10273
|
+
}, aa = ({ bounds: e, type: t, primaryStart: n, primaryEnd: r }) => {
|
|
10166
10274
|
let i = [], a = n === "top" ? "left" : "top", o = r === "bottom" ? "right" : "bottom", s = [...e].sort((e, t) => e[n] - t[n]);
|
|
10167
10275
|
for (let e = 0; e < s.length; e += 1) {
|
|
10168
10276
|
let c = s[e], l = null, u = Infinity;
|
|
@@ -10183,35 +10291,35 @@ var ai = class {
|
|
|
10183
10291
|
});
|
|
10184
10292
|
}
|
|
10185
10293
|
return i;
|
|
10186
|
-
},
|
|
10187
|
-
vertical:
|
|
10294
|
+
}, oa = ({ bounds: e }) => ({
|
|
10295
|
+
vertical: aa({
|
|
10188
10296
|
bounds: e,
|
|
10189
10297
|
axis: "centerX",
|
|
10190
10298
|
type: "vertical",
|
|
10191
10299
|
primaryStart: "top",
|
|
10192
10300
|
primaryEnd: "bottom"
|
|
10193
10301
|
}),
|
|
10194
|
-
horizontal:
|
|
10302
|
+
horizontal: aa({
|
|
10195
10303
|
bounds: e,
|
|
10196
10304
|
axis: "centerY",
|
|
10197
10305
|
type: "horizontal",
|
|
10198
10306
|
primaryStart: "left",
|
|
10199
10307
|
primaryEnd: "right"
|
|
10200
10308
|
})
|
|
10201
|
-
}),
|
|
10309
|
+
}), sa = [
|
|
10202
10310
|
"montage-area",
|
|
10203
10311
|
"background",
|
|
10204
10312
|
"interaction-blocker"
|
|
10205
|
-
],
|
|
10313
|
+
], ca = ({ activeObject: t }) => {
|
|
10206
10314
|
let n = /* @__PURE__ */ new Set();
|
|
10207
10315
|
return t ? (n.add(t), t instanceof e && t.getObjects().forEach((e) => n.add(e)), n) : n;
|
|
10208
|
-
},
|
|
10316
|
+
}, la = ({ object: e, excluded: t, ignoredIds: n = sa }) => {
|
|
10209
10317
|
if (t.has(e)) return !0;
|
|
10210
10318
|
let { visible: r = !0 } = e;
|
|
10211
10319
|
if (!r) return !0;
|
|
10212
10320
|
let { id: i } = e;
|
|
10213
10321
|
return !!(i && n.includes(i));
|
|
10214
|
-
},
|
|
10322
|
+
}, ua = class e {
|
|
10215
10323
|
constructor({ editor: e }) {
|
|
10216
10324
|
this.anchors = {
|
|
10217
10325
|
vertical: [],
|
|
@@ -10264,7 +10372,7 @@ var ai = class {
|
|
|
10264
10372
|
this._clearSpacingContexts(), this._clearGuides();
|
|
10265
10373
|
return;
|
|
10266
10374
|
}
|
|
10267
|
-
let { canvas: o } = this, s = o.getZoom() || 1, c = 5 / s, { deltaX: l, deltaY: u } =
|
|
10375
|
+
let { canvas: o } = this, s = o.getZoom() || 1, c = 5 / s, { deltaX: l, deltaY: u } = Zi({
|
|
10268
10376
|
activeBounds: a,
|
|
10269
10377
|
threshold: c,
|
|
10270
10378
|
anchors: this.anchors
|
|
@@ -10276,7 +10384,7 @@ var ai = class {
|
|
|
10276
10384
|
top: t + u
|
|
10277
10385
|
}), n.setCoords(), a = Ye({ object: n }) ?? a;
|
|
10278
10386
|
}
|
|
10279
|
-
let d = this._resolveCurrentTargetBounds({ activeObject: n }), f = this.spacingContexts.vertical || this.spacingContexts.horizontal ? 10 / s : c, p =
|
|
10387
|
+
let d = this._resolveCurrentTargetBounds({ activeObject: n }), f = this.spacingContexts.vertical || this.spacingContexts.horizontal ? 10 / s : c, p = ea({
|
|
10280
10388
|
activeBounds: a,
|
|
10281
10389
|
candidates: d,
|
|
10282
10390
|
threshold: f,
|
|
@@ -10297,11 +10405,11 @@ var ai = class {
|
|
|
10297
10405
|
target: n,
|
|
10298
10406
|
transform: i
|
|
10299
10407
|
});
|
|
10300
|
-
let h = Ye({ object: n }) ?? a, g =
|
|
10408
|
+
let h = Ye({ object: n }) ?? a, g = Zi({
|
|
10301
10409
|
activeBounds: h,
|
|
10302
10410
|
threshold: c,
|
|
10303
10411
|
anchors: this.anchors
|
|
10304
|
-
}), _ =
|
|
10412
|
+
}), _ = ea({
|
|
10305
10413
|
activeBounds: h,
|
|
10306
10414
|
candidates: d,
|
|
10307
10415
|
threshold: c,
|
|
@@ -10532,9 +10640,9 @@ var ai = class {
|
|
|
10532
10640
|
let { canvas: e, guideBounds: t } = this, n = e.getSelectionContext();
|
|
10533
10641
|
if (!n) return;
|
|
10534
10642
|
let { left: r, right: i, top: a, bottom: o } = t ?? this._calculateViewportBounds(), { viewportTransform: s } = e, c = e.getZoom() || 1;
|
|
10535
|
-
n.save(), Array.isArray(s) && n.transform(...s), n.lineWidth = 1 / c, n.strokeStyle =
|
|
10643
|
+
n.save(), Array.isArray(s) && n.transform(...s), n.lineWidth = 1 / c, n.strokeStyle = Ci, n.setLineDash([4, 4]);
|
|
10536
10644
|
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();
|
|
10537
|
-
for (let e of this.activeSpacingGuides)
|
|
10645
|
+
for (let e of this.activeSpacingGuides) ra({
|
|
10538
10646
|
context: n,
|
|
10539
10647
|
guide: e,
|
|
10540
10648
|
zoom: c
|
|
@@ -10745,14 +10853,14 @@ var ai = class {
|
|
|
10745
10853
|
}, r = [];
|
|
10746
10854
|
for (let e of t) {
|
|
10747
10855
|
let t = Ye({ object: e });
|
|
10748
|
-
t && (
|
|
10856
|
+
t && (ia({
|
|
10749
10857
|
anchors: n,
|
|
10750
10858
|
bounds: t
|
|
10751
10859
|
}), r.push(t));
|
|
10752
10860
|
}
|
|
10753
10861
|
let { montageArea: i } = this.editor, a = Ye({ object: i });
|
|
10754
10862
|
if (a) {
|
|
10755
|
-
|
|
10863
|
+
ia({
|
|
10756
10864
|
anchors: n,
|
|
10757
10865
|
bounds: a
|
|
10758
10866
|
});
|
|
@@ -10764,12 +10872,12 @@ var ai = class {
|
|
|
10764
10872
|
bottom: i
|
|
10765
10873
|
};
|
|
10766
10874
|
} else this.guideBounds = this._calculateViewportBounds();
|
|
10767
|
-
this.anchors = n, this.spacingPatterns =
|
|
10875
|
+
this.anchors = n, this.spacingPatterns = oa({ bounds: r }), this.cachedTargetBounds = r;
|
|
10768
10876
|
}
|
|
10769
10877
|
_collectTargets({ activeObject: e }) {
|
|
10770
|
-
let t =
|
|
10878
|
+
let t = ca({ activeObject: e }), n = [];
|
|
10771
10879
|
return this.canvas.forEachObject((e) => {
|
|
10772
|
-
|
|
10880
|
+
la({
|
|
10773
10881
|
object: e,
|
|
10774
10882
|
excluded: t
|
|
10775
10883
|
}) || n.push(e);
|
|
@@ -10792,7 +10900,7 @@ var ai = class {
|
|
|
10792
10900
|
bottom: (r - s) / a
|
|
10793
10901
|
};
|
|
10794
10902
|
}
|
|
10795
|
-
},
|
|
10903
|
+
}, da = "#3D8BF4", fa = class e {
|
|
10796
10904
|
constructor({ editor: e }) {
|
|
10797
10905
|
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();
|
|
10798
10906
|
}
|
|
@@ -10885,8 +10993,8 @@ var ai = class {
|
|
|
10885
10993
|
this.isTargetMontageArea = l, this.activeGuides = d, this._hideToolbar(), n.requestRenderAll();
|
|
10886
10994
|
}
|
|
10887
10995
|
static _resolveTarget({ event: e, activeObject: t }) {
|
|
10888
|
-
let { target: n } = e, r =
|
|
10889
|
-
return n && !
|
|
10996
|
+
let { target: n } = e, r = ca({ activeObject: t });
|
|
10997
|
+
return n && !la({
|
|
10890
10998
|
object: n,
|
|
10891
10999
|
excluded: r
|
|
10892
11000
|
}) ? n : null;
|
|
@@ -11003,18 +11111,18 @@ var ai = class {
|
|
|
11003
11111
|
let { canvas: e } = this, t = e.getSelectionContext();
|
|
11004
11112
|
if (!t) return;
|
|
11005
11113
|
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;
|
|
11006
|
-
t.save(), Array.isArray(n) && t.transform(...n), t.lineWidth = 1 / r, t.strokeStyle =
|
|
11114
|
+
t.save(), Array.isArray(n) && t.transform(...n), t.lineWidth = 1 / r, t.strokeStyle = da, t.setLineDash([]);
|
|
11007
11115
|
for (let e of this.activeGuides) {
|
|
11008
11116
|
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;
|
|
11009
|
-
t.beginPath(), n === "vertical" ? (t.moveTo(i, a), t.lineTo(i, c)) : (t.moveTo(a, i), t.lineTo(c, i)), t.stroke(),
|
|
11117
|
+
t.beginPath(), n === "vertical" ? (t.moveTo(i, a), t.lineTo(i, c)) : (t.moveTo(a, i), t.lineTo(c, i)), t.stroke(), na({
|
|
11010
11118
|
context: t,
|
|
11011
11119
|
type: n,
|
|
11012
11120
|
axis: i,
|
|
11013
11121
|
start: a,
|
|
11014
11122
|
end: c,
|
|
11015
|
-
text:
|
|
11123
|
+
text: Ti({ distance: l }).toString(),
|
|
11016
11124
|
zoom: r,
|
|
11017
|
-
color:
|
|
11125
|
+
color: da,
|
|
11018
11126
|
lineWidth: 1,
|
|
11019
11127
|
offsetAlongAxis: d,
|
|
11020
11128
|
offsetPerpendicular: 0
|
|
@@ -11032,13 +11140,13 @@ var ai = class {
|
|
|
11032
11140
|
let { toolbar: e } = this.editor;
|
|
11033
11141
|
e?.showAfterTemporary?.(), this.isToolbarHidden = !1;
|
|
11034
11142
|
}
|
|
11035
|
-
},
|
|
11143
|
+
}, pa = class e {
|
|
11036
11144
|
constructor(e, t) {
|
|
11037
11145
|
this.options = t, this.containerId = e, this.editorId = `${e}-${D()}`, this.init();
|
|
11038
11146
|
}
|
|
11039
11147
|
async init() {
|
|
11040
11148
|
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;
|
|
11041
|
-
if (re.apply(), this.canvas = new t(this.containerId, this.options), this.moduleLoader = new A(), this.workerManager = new M(), this.errorManager = new
|
|
11149
|
+
if (re.apply(), this.canvas = new t(this.containerId, this.options), this.moduleLoader = new A(), this.workerManager = new M(), this.errorManager = new Or({ editor: this }), this.historyManager = new je({ editor: this }), this.toolbar = new H({ editor: this }), this.transformManager = new He({ editor: this }), this.zoomManager = new Ue({ editor: this }), this.canvasManager = new Ve({ editor: this }), this.imageManager = new Le({ editor: this }), this.layerManager = new et({ editor: this }), this.shapeManager = new xr({ editor: this }), this.interactionBlocker = new Qe({ editor: this }), this.backgroundManager = new $e({ editor: this }), this.clipboardManager = new Sr({ editor: this }), this.objectLockManager = new Cr({ editor: this }), this.groupingManager = new wr({ editor: this }), this.selectionManager = new Tr({ editor: this }), this.deletionManager = new Er({ editor: this }), this.panConstraintManager = new kr({ editor: this }), this.snappingManager = new ua({ editor: this }), this.measurementManager = new fa({ editor: this }), this.fontManager = new B(this.options.fonts ?? []), this.textManager = new _i({ editor: this }), this.templateManager = new Si({ editor: this }), u && (this.angleIndicator = new ae({ editor: this })), this._createMontageArea(), this._createClippingArea(), this.interactionBlocker.ensureOverlay(), this.listeners = new k({
|
|
11042
11150
|
editor: this,
|
|
11043
11151
|
options: this.options
|
|
11044
11152
|
}), 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) {
|
|
@@ -11146,7 +11254,7 @@ var ai = class {
|
|
|
11146
11254
|
"U+A640-A69F",
|
|
11147
11255
|
"U+FE2E-FE2F",
|
|
11148
11256
|
"U+2116"
|
|
11149
|
-
].join(", "),
|
|
11257
|
+
].join(", "), ma = {
|
|
11150
11258
|
preserveObjectStacking: !0,
|
|
11151
11259
|
controlsAboveOverlay: !0,
|
|
11152
11260
|
centeredRotation: !0,
|
|
@@ -12000,20 +12108,20 @@ var ai = class {
|
|
|
12000
12108
|
};
|
|
12001
12109
|
//#endregion
|
|
12002
12110
|
//#region src/main.ts
|
|
12003
|
-
function
|
|
12111
|
+
function ha(e, t = {}) {
|
|
12004
12112
|
let n = {
|
|
12005
|
-
...
|
|
12113
|
+
...ma,
|
|
12006
12114
|
...t
|
|
12007
12115
|
}, r = document.getElementById(e);
|
|
12008
12116
|
if (!r) return Promise.reject(/* @__PURE__ */ Error(`Контейнер с ID "${e}" не найден.`));
|
|
12009
12117
|
let i = document.createElement("canvas");
|
|
12010
12118
|
return i.id = `${e}-canvas`, r.appendChild(i), n.editorContainer = r, new Promise((t) => {
|
|
12011
12119
|
n._onReadyCallback = t;
|
|
12012
|
-
let r = new
|
|
12120
|
+
let r = new pa(i.id, n);
|
|
12013
12121
|
window[e] = r;
|
|
12014
12122
|
});
|
|
12015
12123
|
}
|
|
12016
12124
|
//#endregion
|
|
12017
|
-
export {
|
|
12125
|
+
export { ha as default };
|
|
12018
12126
|
|
|
12019
12127
|
//# sourceMappingURL=main.js.map
|