@anu3ev/fabric-image-editor 0.7.13 → 0.7.14
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 +623 -549
- 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
|
-
}),
|
|
5778
|
+
}), Rn({ text: n }), this.canvas.getActiveObject() === n && this.canvas.setActiveObject(r), this.canvas.requestRenderAll());
|
|
5705
5779
|
}, this.canvas = e, this.editingInteractionState = /* @__PURE__ */ new WeakMap();
|
|
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({
|
|
@@ -5758,7 +5832,7 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5758
5832
|
lockMovementY: n.textLockMovementY
|
|
5759
5833
|
}), this.editingInteractionState.delete(e), e.setCoords(), t.setCoords());
|
|
5760
5834
|
}
|
|
5761
|
-
},
|
|
5835
|
+
}, _r = class e {
|
|
5762
5836
|
constructor({ canvas: e }) {
|
|
5763
5837
|
this.canvas = e, this.textEditingSnapshots = /* @__PURE__ */ new WeakMap(), this.pendingTextUpdates = /* @__PURE__ */ new WeakMap(), this.resizeStartSnapshots = /* @__PURE__ */ new Map(), this.pendingResizeUpdates = /* @__PURE__ */ new WeakMap();
|
|
5764
5838
|
}
|
|
@@ -5954,7 +6028,7 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5954
6028
|
}
|
|
5955
6029
|
}), I;
|
|
5956
6030
|
}
|
|
5957
|
-
},
|
|
6031
|
+
}, vr = "#B4B7BD", yr = 0, br = 1, xr = class {
|
|
5958
6032
|
constructor({ editor: e }) {
|
|
5959
6033
|
this._handleObjectScaling = (e) => {
|
|
5960
6034
|
let t = e.target && J(e.target) ? e.target : null;
|
|
@@ -6019,7 +6093,7 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6019
6093
|
if (!(t instanceof _)) return;
|
|
6020
6094
|
let n = t;
|
|
6021
6095
|
this.lifecycleController.finishTextUpdate({ textNode: n });
|
|
6022
|
-
}, this.editor = e,
|
|
6096
|
+
}, 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
6097
|
}
|
|
6024
6098
|
async add({ presetKey: e = ot, options: t = {} } = {}) {
|
|
6025
6099
|
let n = dt({ presetKey: e });
|
|
@@ -6484,7 +6558,7 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6484
6558
|
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
6559
|
}
|
|
6486
6560
|
_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
|
|
6561
|
+
let v = new Xn([r, i], {
|
|
6488
6562
|
originX: "center",
|
|
6489
6563
|
originY: "center",
|
|
6490
6564
|
left: 0,
|
|
@@ -6507,7 +6581,7 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6507
6581
|
padding: f,
|
|
6508
6582
|
style: g,
|
|
6509
6583
|
rounding: _
|
|
6510
|
-
}), v.rehydrateRuntimeState(),
|
|
6584
|
+
}), v.rehydrateRuntimeState(), tr({ group: v }), Rn({ text: i }), ln({
|
|
6511
6585
|
group: v,
|
|
6512
6586
|
shape: r,
|
|
6513
6587
|
text: i,
|
|
@@ -6570,7 +6644,7 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6570
6644
|
return s.set({
|
|
6571
6645
|
shapeNodeType: "text",
|
|
6572
6646
|
splitByGrapheme: !1
|
|
6573
|
-
}),
|
|
6647
|
+
}), Rn({ text: s }), s;
|
|
6574
6648
|
}
|
|
6575
6649
|
_applyTextUpdates({ textNode: e, text: t, textStyle: n, align: r }) {
|
|
6576
6650
|
let i = {};
|
|
@@ -6680,7 +6754,7 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6680
6754
|
}
|
|
6681
6755
|
_resolveAutoExpandShapeWidth({ text: e, currentWidth: t, minimumWidth: n, padding: r, resolvePaddingForWidth: i }) {
|
|
6682
6756
|
let a = this._resolveMontageAreaWidth();
|
|
6683
|
-
return a ?
|
|
6757
|
+
return a ? dn({
|
|
6684
6758
|
text: e,
|
|
6685
6759
|
currentWidth: t,
|
|
6686
6760
|
minimumWidth: n,
|
|
@@ -6736,7 +6810,7 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6736
6810
|
width: y,
|
|
6737
6811
|
height: b
|
|
6738
6812
|
}), S = r ?? this.editor.canvasManager.getObjectPlacement({ object: e }), C = u ? this._resolveMontageAreaWidth() : void 0;
|
|
6739
|
-
|
|
6813
|
+
ln({
|
|
6740
6814
|
group: e,
|
|
6741
6815
|
shape: t,
|
|
6742
6816
|
text: n,
|
|
@@ -6780,7 +6854,7 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6780
6854
|
return this.editingPlacements.get(e) || this.editor.canvasManager.getObjectPlacement({ object: e });
|
|
6781
6855
|
}
|
|
6782
6856
|
_detachShapeGroupAutoLayout({ group: e }) {
|
|
6783
|
-
|
|
6857
|
+
zn({ group: e });
|
|
6784
6858
|
}
|
|
6785
6859
|
_resolveHorizontalAlign({ explicitAlign: e, textStyle: t }) {
|
|
6786
6860
|
if (e) return e;
|
|
@@ -6799,11 +6873,11 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6799
6873
|
_resolveShapeStyle({ options: e, fallback: t }) {
|
|
6800
6874
|
let { fill: n, stroke: r, strokeWidth: i, strokeDashArray: a, opacity: o } = e, s = a === void 0 ? t?.shapeStrokeDashArray : a;
|
|
6801
6875
|
return {
|
|
6802
|
-
fill: n ?? t?.shapeFill ??
|
|
6876
|
+
fill: n ?? t?.shapeFill ?? vr,
|
|
6803
6877
|
stroke: r ?? t?.shapeStroke ?? null,
|
|
6804
|
-
strokeWidth: i ?? t?.shapeStrokeWidth ??
|
|
6878
|
+
strokeWidth: i ?? t?.shapeStrokeWidth ?? yr,
|
|
6805
6879
|
strokeDashArray: s ?? null,
|
|
6806
|
-
opacity: o ?? t?.shapeOpacity ??
|
|
6880
|
+
opacity: o ?? t?.shapeOpacity ?? br
|
|
6807
6881
|
};
|
|
6808
6882
|
}
|
|
6809
6883
|
_collectShapeGroupsFromTarget({ target: t, subTargets: n = [] }) {
|
|
@@ -6859,7 +6933,7 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6859
6933
|
}
|
|
6860
6934
|
return null;
|
|
6861
6935
|
}
|
|
6862
|
-
},
|
|
6936
|
+
}, Sr = class {
|
|
6863
6937
|
constructor({ editor: e }) {
|
|
6864
6938
|
this.editor = e, this.clipboard = null;
|
|
6865
6939
|
}
|
|
@@ -7115,12 +7189,12 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7115
7189
|
}), !1;
|
|
7116
7190
|
}
|
|
7117
7191
|
}
|
|
7118
|
-
},
|
|
7192
|
+
}, Cr = class t {
|
|
7119
7193
|
constructor({ editor: e }) {
|
|
7120
7194
|
this.editor = e;
|
|
7121
7195
|
}
|
|
7122
7196
|
lockObject({ object: e, skipInnerObjects: n, withoutSave: r } = {}) {
|
|
7123
|
-
let { canvas: i, historyManager: a } = this.editor, o = e || i.getActiveObject(), s =
|
|
7197
|
+
let { canvas: i, historyManager: a } = this.editor, o = e || i.getActiveObject(), s = Qn({ target: o }) ?? o;
|
|
7124
7198
|
if (!s || s.locked) return;
|
|
7125
7199
|
let c = {
|
|
7126
7200
|
lockMovementX: !0,
|
|
@@ -7142,7 +7216,7 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7142
7216
|
});
|
|
7143
7217
|
}
|
|
7144
7218
|
unlockObject({ object: e, withoutSave: n } = {}) {
|
|
7145
|
-
let { canvas: r, historyManager: i } = this.editor, a = e || r.getActiveObject(), o =
|
|
7219
|
+
let { canvas: r, historyManager: i } = this.editor, a = e || r.getActiveObject(), o = Qn({ target: a }) ?? a;
|
|
7146
7220
|
if (!o) return;
|
|
7147
7221
|
let s = {
|
|
7148
7222
|
lockMovementX: !1,
|
|
@@ -7180,7 +7254,7 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7180
7254
|
!(n instanceof _) || !n.isEditing || n.exitEditing();
|
|
7181
7255
|
}
|
|
7182
7256
|
}
|
|
7183
|
-
},
|
|
7257
|
+
}, wr = class {
|
|
7184
7258
|
constructor({ editor: e }) {
|
|
7185
7259
|
this.editor = e;
|
|
7186
7260
|
}
|
|
@@ -7246,7 +7320,7 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7246
7320
|
i.resumeHistory(), n || i.saveState();
|
|
7247
7321
|
}
|
|
7248
7322
|
}
|
|
7249
|
-
},
|
|
7323
|
+
}, Tr = class t {
|
|
7250
7324
|
constructor({ editor: e }) {
|
|
7251
7325
|
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
7326
|
}
|
|
@@ -7440,7 +7514,7 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7440
7514
|
let { options: e } = this.editor, { selectionKey: t } = e;
|
|
7441
7515
|
return t === void 0 ? ["ctrlKey", "metaKey"] : t;
|
|
7442
7516
|
}
|
|
7443
|
-
},
|
|
7517
|
+
}, Er = class e {
|
|
7444
7518
|
constructor({ editor: e }) {
|
|
7445
7519
|
this.editor = e;
|
|
7446
7520
|
}
|
|
@@ -7480,7 +7554,7 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7480
7554
|
};
|
|
7481
7555
|
return i.fire("editor:objects-deleted", l), l;
|
|
7482
7556
|
}
|
|
7483
|
-
},
|
|
7557
|
+
}, Dr = {
|
|
7484
7558
|
IMAGE_MANAGER: {
|
|
7485
7559
|
INVALID_CONTENT_TYPE: "INVALID_CONTENT_TYPE",
|
|
7486
7560
|
INVALID_SOURCE_TYPE: "INVALID_SOURCE_TYPE",
|
|
@@ -7518,7 +7592,7 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7518
7592
|
INVALID_TARGET: "TEMPLATE_INVALID_TARGET",
|
|
7519
7593
|
APPLY_FAILED: "TEMPLATE_APPLY_FAILED"
|
|
7520
7594
|
}
|
|
7521
|
-
},
|
|
7595
|
+
}, Or = class e {
|
|
7522
7596
|
constructor({ editor: e }) {
|
|
7523
7597
|
this._buffer = [], this.editor = e;
|
|
7524
7598
|
}
|
|
@@ -7576,9 +7650,9 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7576
7650
|
}), this.editor.canvas.fire("editor:warning", s);
|
|
7577
7651
|
}
|
|
7578
7652
|
static isValidErrorCode(e) {
|
|
7579
|
-
return e ? Object.values(
|
|
7653
|
+
return e ? Object.values(Dr).some((t) => Object.values(t).includes(e)) : !1;
|
|
7580
7654
|
}
|
|
7581
|
-
},
|
|
7655
|
+
}, kr = class {
|
|
7582
7656
|
constructor({ editor: e }) {
|
|
7583
7657
|
this.currentBounds = null, this.editor = e;
|
|
7584
7658
|
}
|
|
@@ -7627,32 +7701,32 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7627
7701
|
updateBounds() {
|
|
7628
7702
|
this.currentBounds = this.calculatePanBounds();
|
|
7629
7703
|
}
|
|
7630
|
-
},
|
|
7704
|
+
}, Ar = ({ textbox: e }) => {
|
|
7631
7705
|
if (!e.isEditing) return null;
|
|
7632
7706
|
let t = e.selectionStart ?? 0, n = e.selectionEnd ?? t;
|
|
7633
7707
|
return t === n ? null : {
|
|
7634
7708
|
start: Math.min(t, n),
|
|
7635
7709
|
end: Math.max(t, n)
|
|
7636
7710
|
};
|
|
7637
|
-
},
|
|
7711
|
+
}, jr = ({ textbox: e }) => {
|
|
7638
7712
|
let t = e.text?.length ?? 0;
|
|
7639
7713
|
return t <= 0 ? null : {
|
|
7640
7714
|
start: 0,
|
|
7641
7715
|
end: t
|
|
7642
7716
|
};
|
|
7643
|
-
},
|
|
7717
|
+
}, Mr = ({ textbox: e, range: t }) => {
|
|
7644
7718
|
if (!t) return !1;
|
|
7645
7719
|
let n = e.text?.length ?? 0;
|
|
7646
7720
|
return n <= 0 ? !1 : t.start <= 0 && t.end >= n;
|
|
7647
|
-
},
|
|
7721
|
+
}, Nr = ({ textbox: e, styles: t, range: n }) => {
|
|
7648
7722
|
if (!t || !Object.keys(t).length) return !1;
|
|
7649
7723
|
let { start: r, end: i } = n;
|
|
7650
7724
|
return i <= r ? !1 : (e.setSelectionStyles(t, r, i), !0);
|
|
7651
|
-
},
|
|
7725
|
+
}, Pr = ({ textbox: e, range: t, property: n }) => {
|
|
7652
7726
|
if (!t) return;
|
|
7653
7727
|
let r = e.getSelectionStyles(t.start, t.end, !0);
|
|
7654
7728
|
if (r.length) return r[0]?.[n];
|
|
7655
|
-
},
|
|
7729
|
+
}, 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
7730
|
static {
|
|
7657
7731
|
this.type = "background-textbox";
|
|
7658
7732
|
}
|
|
@@ -7786,7 +7860,7 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7786
7860
|
this._removeShadow(e);
|
|
7787
7861
|
}
|
|
7788
7862
|
_getDecorationColorAt(e, t) {
|
|
7789
|
-
let n = this.getValueOfPropertyAt(e, t, "strokeWidth"), r =
|
|
7863
|
+
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
7864
|
strokeColor: i,
|
|
7791
7865
|
width: r
|
|
7792
7866
|
});
|
|
@@ -7802,22 +7876,22 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7802
7876
|
_getCornerRadii({ width: e, height: t }) {
|
|
7803
7877
|
let n = e / 2, r = t / 2, i = Math.min(n, r);
|
|
7804
7878
|
return {
|
|
7805
|
-
bottomLeft:
|
|
7879
|
+
bottomLeft: Rr({
|
|
7806
7880
|
value: this.radiusBottomLeft ?? 0,
|
|
7807
7881
|
min: 0,
|
|
7808
7882
|
max: i
|
|
7809
7883
|
}),
|
|
7810
|
-
bottomRight:
|
|
7884
|
+
bottomRight: Rr({
|
|
7811
7885
|
value: this.radiusBottomRight ?? 0,
|
|
7812
7886
|
min: 0,
|
|
7813
7887
|
max: i
|
|
7814
7888
|
}),
|
|
7815
|
-
topLeft:
|
|
7889
|
+
topLeft: Rr({
|
|
7816
7890
|
value: this.radiusTopLeft ?? 0,
|
|
7817
7891
|
min: 0,
|
|
7818
7892
|
max: i
|
|
7819
7893
|
}),
|
|
7820
|
-
topRight:
|
|
7894
|
+
topRight: Rr({
|
|
7821
7895
|
value: this.radiusTopRight ?? 0,
|
|
7822
7896
|
min: 0,
|
|
7823
7897
|
max: i
|
|
@@ -7835,7 +7909,7 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7835
7909
|
_getEffectiveBackgroundFill() {
|
|
7836
7910
|
let e = this.backgroundColor;
|
|
7837
7911
|
if (!e) return null;
|
|
7838
|
-
let t =
|
|
7912
|
+
let t = Rr({
|
|
7839
7913
|
value: this.backgroundOpacity ?? 1,
|
|
7840
7914
|
min: 0,
|
|
7841
7915
|
max: 1
|
|
@@ -7843,7 +7917,7 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7843
7917
|
try {
|
|
7844
7918
|
r = new n(e);
|
|
7845
7919
|
} catch (t) {
|
|
7846
|
-
return
|
|
7920
|
+
return Or.emitError({
|
|
7847
7921
|
origin: "BackgroundTextbox",
|
|
7848
7922
|
method: "_getEffectiveBackgroundFill",
|
|
7849
7923
|
code: "INVALID_COLOR_VALUE",
|
|
@@ -7857,19 +7931,19 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7857
7931
|
return r.setAlpha(t), r.toRgba();
|
|
7858
7932
|
}
|
|
7859
7933
|
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 =
|
|
7934
|
+
let o = n + a, s = i + t, { topLeft: c, topRight: l, bottomRight: u, bottomLeft: d } = r, f = Rr({
|
|
7861
7935
|
value: c,
|
|
7862
7936
|
min: 0,
|
|
7863
7937
|
max: a
|
|
7864
|
-
}), p =
|
|
7938
|
+
}), p = Rr({
|
|
7865
7939
|
value: l,
|
|
7866
7940
|
min: 0,
|
|
7867
7941
|
max: a
|
|
7868
|
-
}), m =
|
|
7942
|
+
}), m = Rr({
|
|
7869
7943
|
value: u,
|
|
7870
7944
|
min: 0,
|
|
7871
7945
|
max: a
|
|
7872
|
-
}), h =
|
|
7946
|
+
}), h = Rr({
|
|
7873
7947
|
value: d,
|
|
7874
7948
|
min: 0,
|
|
7875
7949
|
max: a
|
|
@@ -7880,9 +7954,9 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7880
7954
|
let { width: e = 0, height: t = 0 } = this, n = Math.round(e), r = Math.round(t);
|
|
7881
7955
|
n !== e && (this.width = Math.max(0, n)), r !== t && (this.height = Math.max(0, r));
|
|
7882
7956
|
}
|
|
7883
|
-
},
|
|
7884
|
-
y?.setClass && y.setClass(
|
|
7885
|
-
},
|
|
7957
|
+
}, Br = () => {
|
|
7958
|
+
y?.setClass && y.setClass(zr, "background-textbox");
|
|
7959
|
+
}, Vr = .01, Hr = ({ textbox: e, lineIndices: t, updates: n }) => {
|
|
7886
7960
|
if (!t.length) return !1;
|
|
7887
7961
|
let { fontFamily: r, fontSize: i, fill: a, stroke: o } = n;
|
|
7888
7962
|
if (!(r !== void 0 || i !== void 0 || a !== void 0 || o !== void 0)) return !1;
|
|
@@ -7894,7 +7968,7 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7894
7968
|
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
7969
|
}
|
|
7896
7970
|
return l && (e.lineFontDefaults = c), l;
|
|
7897
|
-
},
|
|
7971
|
+
}, Ur = ({ lineText: e, lineStyles: t, lineDefaults: n }) => {
|
|
7898
7972
|
let r = e.length;
|
|
7899
7973
|
if (r === 0) return {
|
|
7900
7974
|
lineStyles: t,
|
|
@@ -7926,7 +8000,7 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7926
8000
|
lineStyles: l,
|
|
7927
8001
|
changed: u
|
|
7928
8002
|
};
|
|
7929
|
-
},
|
|
8003
|
+
}, Wr = ({ lineFontDefaults: e }) => {
|
|
7930
8004
|
if (!e) return;
|
|
7931
8005
|
let t = {};
|
|
7932
8006
|
for (let n in e) {
|
|
@@ -7937,7 +8011,7 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7937
8011
|
i && (t[r] = { ...i });
|
|
7938
8012
|
}
|
|
7939
8013
|
return t;
|
|
7940
|
-
},
|
|
8014
|
+
}, Gr = ({ lineFontDefaults: e, scale: t }) => {
|
|
7941
8015
|
if (!e || !Number.isFinite(t) || Math.abs(t - 1) < .01) return;
|
|
7942
8016
|
let n = {}, r = !1, i = !1;
|
|
7943
8017
|
for (let a in e) {
|
|
@@ -7954,18 +8028,18 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7954
8028
|
n[o] = c, r = !0;
|
|
7955
8029
|
}
|
|
7956
8030
|
if (!(!r || !i)) return n;
|
|
7957
|
-
},
|
|
8031
|
+
}, Kr = ({ textbox: e, text: t }) => {
|
|
7958
8032
|
let { textLines: n } = e, r = Array.isArray(n) && n.length > 0 ? n.length : Math.max(t.split("\n").length, 1), i = 0;
|
|
7959
8033
|
for (let t = 0; t < r; t += 1) {
|
|
7960
8034
|
let n = e.getLineWidth(t);
|
|
7961
8035
|
n > i && (i = n);
|
|
7962
8036
|
}
|
|
7963
8037
|
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 +
|
|
8038
|
+
}, 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" }) => {
|
|
8039
|
+
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
8040
|
origin: t,
|
|
7967
8041
|
size: r
|
|
7968
|
-
}), u +
|
|
8042
|
+
}), u + qr({
|
|
7969
8043
|
origin: n,
|
|
7970
8044
|
size: i
|
|
7971
8045
|
})), 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 +8049,13 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7975
8049
|
originX: t,
|
|
7976
8050
|
originY: n
|
|
7977
8051
|
};
|
|
7978
|
-
},
|
|
8052
|
+
}, Yr = ({ textbox: e, montageLeft: t, montageRight: n }) => {
|
|
7979
8053
|
e.setCoords();
|
|
7980
8054
|
let r = e.getBoundingRect(!1, !0), i = r.left ?? 0, a = i + (r.width ?? 0), o = n - t;
|
|
7981
8055
|
if (o > 0 && (r.width ?? 0) >= o - .01) return !1;
|
|
7982
8056
|
let s = 0;
|
|
7983
8057
|
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
|
-
},
|
|
8058
|
+
}, Xr = ({ rawValue: e, calculatedValue: t }) => typeof e == "number" ? e : typeof t == "number" ? t : 0, Zr = ({ stylesList: e }) => {
|
|
7985
8059
|
let t = e.length;
|
|
7986
8060
|
if (!t) return !1;
|
|
7987
8061
|
for (let n = 0; n < t; n += 1) {
|
|
@@ -7991,16 +8065,16 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7991
8065
|
if (r !== void 0 || i !== void 0 || a !== void 0 || o !== void 0 || s !== void 0 || c !== void 0) return !0;
|
|
7992
8066
|
}
|
|
7993
8067
|
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 =
|
|
8068
|
+
}, Qr = ({ textbox: e }) => {
|
|
8069
|
+
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
8070
|
rawValue: t,
|
|
7997
8071
|
calculatedValue: a
|
|
7998
|
-
}), c =
|
|
8072
|
+
}), c = Xr({
|
|
7999
8073
|
rawValue: n,
|
|
8000
8074
|
calculatedValue: o
|
|
8001
8075
|
}), l = Number.isFinite(s) ? Math.round(s) : null, u = Number.isFinite(c) ? Math.round(c) : null, d = {};
|
|
8002
8076
|
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
|
-
},
|
|
8077
|
+
}, $r = ({ textbox: e }) => {
|
|
8004
8078
|
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
8079
|
return {
|
|
8006
8080
|
width: t,
|
|
@@ -8018,9 +8092,9 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
8018
8092
|
bottomLeft: f
|
|
8019
8093
|
},
|
|
8020
8094
|
styles: JSON.parse(JSON.stringify(r)),
|
|
8021
|
-
lineFontDefaults:
|
|
8095
|
+
lineFontDefaults: Wr({ lineFontDefaults: i })
|
|
8022
8096
|
};
|
|
8023
|
-
},
|
|
8097
|
+
}, ei = ({ base: e }) => {
|
|
8024
8098
|
let t = 1 / Math.max(1, e.width), n = [e.fontSize];
|
|
8025
8099
|
Object.values(e.styles).forEach((e) => {
|
|
8026
8100
|
Object.values(e).forEach((e) => {
|
|
@@ -8037,7 +8111,7 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
8037
8111
|
fontScale: r,
|
|
8038
8112
|
proportionalScale: Math.max(t, r)
|
|
8039
8113
|
};
|
|
8040
|
-
},
|
|
8114
|
+
}, 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
8115
|
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
8116
|
if (s && S) {
|
|
8043
8117
|
let e = {};
|
|
@@ -8056,7 +8130,7 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
8056
8130
|
}), Object.keys(e).length && (C = e);
|
|
8057
8131
|
}
|
|
8058
8132
|
let w;
|
|
8059
|
-
s && (w =
|
|
8133
|
+
s && (w = Gr({
|
|
8060
8134
|
lineFontDefaults: v,
|
|
8061
8135
|
scale: i
|
|
8062
8136
|
}));
|
|
@@ -8070,7 +8144,7 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
8070
8144
|
topRight: Math.max(0, g.topRight * i),
|
|
8071
8145
|
bottomRight: Math.max(0, g.bottomRight * i),
|
|
8072
8146
|
bottomLeft: Math.max(0, g.bottomLeft * i)
|
|
8073
|
-
} : g, D = e.width ?? f, O = Math.abs(b - D) >
|
|
8147
|
+
} : g, D = e.width ?? f, O = Math.abs(b - D) > Vr;
|
|
8074
8148
|
u && O && (e.autoExpand = !1), C && (e.styles = C), w && (e.lineFontDefaults = w), e.set({
|
|
8075
8149
|
width: b,
|
|
8076
8150
|
fontSize: s ? x : m,
|
|
@@ -8092,7 +8166,7 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
8092
8166
|
} finally {
|
|
8093
8167
|
e.shouldRoundDimensionsOnInit = k;
|
|
8094
8168
|
}
|
|
8095
|
-
let A = d ?
|
|
8169
|
+
let A = d ? Qr({ textbox: e }) : !1;
|
|
8096
8170
|
return A && (e.dirty = !0), o ? (e.set({
|
|
8097
8171
|
originX: a.originX,
|
|
8098
8172
|
originY: a.originY
|
|
@@ -8106,18 +8180,18 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
8106
8180
|
appliedWidth: e.width ?? b,
|
|
8107
8181
|
dimensionsRounded: A
|
|
8108
8182
|
});
|
|
8109
|
-
},
|
|
8183
|
+
}, ni = ({ transform: e }) => {
|
|
8110
8184
|
let { corner: t = "", action: n = "" } = e;
|
|
8111
8185
|
return {
|
|
8112
8186
|
isCornerHandle: t === "tl" || t === "tr" || t === "bl" || t === "br" || n === "scale",
|
|
8113
8187
|
isHorizontalHandle: t === "ml" || t === "mr" || n === "scaleX",
|
|
8114
8188
|
isVerticalHandle: t === "mt" || t === "mb" || n === "scaleY"
|
|
8115
8189
|
};
|
|
8116
|
-
},
|
|
8190
|
+
}, ri = ({ textbox: e, transform: t, appliedWidth: n }) => {
|
|
8117
8191
|
t.scaleX = 1, t.scaleY = 1;
|
|
8118
8192
|
let { original: r } = t;
|
|
8119
8193
|
r && (r.scaleX = 1, r.scaleY = 1, r.width = n, r.height = e.height, r.left = e.left, r.top = e.top);
|
|
8120
|
-
},
|
|
8194
|
+
}, ii = ({ textbox: e, transform: t, scenePoint: n }) => {
|
|
8121
8195
|
let { x: r, y: i } = e._getTransformedDimensions();
|
|
8122
8196
|
if (r <= 0 || i <= 0) return null;
|
|
8123
8197
|
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 +8201,27 @@ var ur = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
8127
8201
|
stepScaleX: l,
|
|
8128
8202
|
stepScaleY: u
|
|
8129
8203
|
};
|
|
8130
|
-
},
|
|
8131
|
-
function
|
|
8204
|
+
}, ai = 1e-4;
|
|
8205
|
+
function oi(e) {
|
|
8132
8206
|
return !!e && e instanceof _;
|
|
8133
8207
|
}
|
|
8134
|
-
function
|
|
8135
|
-
if (!
|
|
8208
|
+
function si(e) {
|
|
8209
|
+
if (!oi(e)) return !1;
|
|
8136
8210
|
let t = e.group;
|
|
8137
8211
|
return e.shapeNodeType === "text" && t?.shapeComposite === !0;
|
|
8138
8212
|
}
|
|
8139
|
-
var
|
|
8213
|
+
var ci = class {
|
|
8140
8214
|
constructor({ canvas: t, canvasManager: n, persistScaledTextbox: r }) {
|
|
8141
8215
|
this.handleMouseMove = (e) => {
|
|
8142
8216
|
let t = this.canvas._currentTransform;
|
|
8143
8217
|
if (!t) return;
|
|
8144
8218
|
let { target: n } = t;
|
|
8145
|
-
if (!
|
|
8219
|
+
if (!oi(n) || si(n)) return;
|
|
8146
8220
|
let r = this.scalingState.get(n);
|
|
8147
8221
|
if (!r || !e.e) return;
|
|
8148
|
-
let { isCornerHandle: i, isHorizontalHandle: a, isVerticalHandle: o } =
|
|
8222
|
+
let { isCornerHandle: i, isHorizontalHandle: a, isVerticalHandle: o } = ni({ transform: t });
|
|
8149
8223
|
if (!a && !o && !i) return;
|
|
8150
|
-
let s =
|
|
8224
|
+
let s = ii({
|
|
8151
8225
|
textbox: n,
|
|
8152
8226
|
transform: t,
|
|
8153
8227
|
scenePoint: this.canvas.getScenePoint(e.e)
|
|
@@ -8170,20 +8244,20 @@ var ai = class {
|
|
|
8170
8244
|
}, j = r.lastAllowedScaleX, M = r.lastAllowedScaleY;
|
|
8171
8245
|
if (i) {
|
|
8172
8246
|
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) <=
|
|
8247
|
+
if (Math.abs(t - r.lastAllowedScaleX) <= ai) return;
|
|
8174
8248
|
j = t, M = t;
|
|
8175
8249
|
} else {
|
|
8176
8250
|
if (a) {
|
|
8177
8251
|
let e = r.lastAllowedScaleX * u, t = c ? r.minimumWidthScale : Math.max(r.minimumWidthScale, e);
|
|
8178
|
-
Math.abs(t - r.lastAllowedScaleX) >
|
|
8252
|
+
Math.abs(t - r.lastAllowedScaleX) > ai && (j = t);
|
|
8179
8253
|
}
|
|
8180
8254
|
if (o) {
|
|
8181
8255
|
let e = r.lastAllowedScaleY * d, t = l ? r.minimumFontScale : Math.max(r.minimumFontScale, e);
|
|
8182
|
-
Math.abs(t - r.lastAllowedScaleY) >
|
|
8256
|
+
Math.abs(t - r.lastAllowedScaleY) > ai && (M = t);
|
|
8183
8257
|
}
|
|
8184
|
-
if (Math.abs(j - r.lastAllowedScaleX) <=
|
|
8258
|
+
if (Math.abs(j - r.lastAllowedScaleX) <= ai && Math.abs(M - r.lastAllowedScaleY) <= ai) return;
|
|
8185
8259
|
}
|
|
8186
|
-
let { appliedWidth: N, dimensionsRounded: P } =
|
|
8260
|
+
let { appliedWidth: N, dimensionsRounded: P } = ti({
|
|
8187
8261
|
textbox: n,
|
|
8188
8262
|
canvasManager: this.canvasManager,
|
|
8189
8263
|
base: r.startBase,
|
|
@@ -8197,7 +8271,7 @@ var ai = class {
|
|
|
8197
8271
|
shouldDisableAutoExpandOnHorizontalChange: a,
|
|
8198
8272
|
shouldRoundDimensions: !i
|
|
8199
8273
|
});
|
|
8200
|
-
|
|
8274
|
+
ri({
|
|
8201
8275
|
textbox: n,
|
|
8202
8276
|
transform: t,
|
|
8203
8277
|
appliedWidth: N
|
|
@@ -8218,12 +8292,12 @@ var ai = class {
|
|
|
8218
8292
|
}), this.canvas.requestRenderAll();
|
|
8219
8293
|
}, this.handleObjectScaling = (t) => {
|
|
8220
8294
|
let { target: n, transform: r } = t;
|
|
8221
|
-
if (n instanceof e || !
|
|
8295
|
+
if (n instanceof e || !oi(n) || si(n) || !r) return;
|
|
8222
8296
|
n.isScaling = !0;
|
|
8223
8297
|
let i = this._ensureScalingState({
|
|
8224
8298
|
textbox: n,
|
|
8225
8299
|
transform: r
|
|
8226
|
-
}), { startBase: a } = i, { width: o, fontSize: s } = a, { isCornerHandle: c, isHorizontalHandle: l, isVerticalHandle: u } =
|
|
8300
|
+
}), { startBase: a } = i, { width: o, fontSize: s } = a, { isCornerHandle: c, isHorizontalHandle: l, isVerticalHandle: u } = ni({ transform: r }), d = r.corner ?? "", f = c || u;
|
|
8227
8301
|
if (!l && !u && !c) return;
|
|
8228
8302
|
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
8303
|
object: n,
|
|
@@ -8238,7 +8312,7 @@ var ai = class {
|
|
|
8238
8312
|
N = e, P = e;
|
|
8239
8313
|
}
|
|
8240
8314
|
} 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 } =
|
|
8315
|
+
let { appliedWidth: L, dimensionsRounded: ee } = ti({
|
|
8242
8316
|
textbox: n,
|
|
8243
8317
|
canvasManager: this.canvasManager,
|
|
8244
8318
|
base: a,
|
|
@@ -8252,7 +8326,7 @@ var ai = class {
|
|
|
8252
8326
|
shouldDisableAutoExpandOnHorizontalChange: l,
|
|
8253
8327
|
shouldRoundDimensions: !c
|
|
8254
8328
|
});
|
|
8255
|
-
|
|
8329
|
+
ri({
|
|
8256
8330
|
textbox: n,
|
|
8257
8331
|
transform: r,
|
|
8258
8332
|
appliedWidth: L
|
|
@@ -8285,7 +8359,7 @@ var ai = class {
|
|
|
8285
8359
|
let { target: n } = t;
|
|
8286
8360
|
if (n instanceof e) {
|
|
8287
8361
|
let t = n.getObjects();
|
|
8288
|
-
if (!t.some((e) =>
|
|
8362
|
+
if (!t.some((e) => oi(e))) return;
|
|
8289
8363
|
let { scaleX: r = 1, scaleY: i = 1 } = n;
|
|
8290
8364
|
if (Math.abs(r - 1) < .01 && Math.abs(i - 1) < .01) return;
|
|
8291
8365
|
this.canvas.discardActiveObject(), t.forEach((e) => {
|
|
@@ -8295,7 +8369,7 @@ var ai = class {
|
|
|
8295
8369
|
this.canvas.setActiveObject(a), this.canvas.requestRenderAll();
|
|
8296
8370
|
return;
|
|
8297
8371
|
}
|
|
8298
|
-
if (!
|
|
8372
|
+
if (!oi(n) || si(n)) return;
|
|
8299
8373
|
n.isScaling = !1;
|
|
8300
8374
|
let r = this.scalingState.get(n);
|
|
8301
8375
|
if (this.scalingState.delete(n), !r?.hasScalingChange) return;
|
|
@@ -8320,11 +8394,11 @@ var ai = class {
|
|
|
8320
8394
|
}, this.canvas = t, this.canvasManager = n, this.persistScaledTextbox = r, this.scalingState = /* @__PURE__ */ new WeakMap();
|
|
8321
8395
|
}
|
|
8322
8396
|
commitStandaloneTextScale({ target: e, shouldDisableAutoExpandOnHorizontalChange: t = !1 }) {
|
|
8323
|
-
if (!
|
|
8397
|
+
if (!oi(e) || si(e)) return !1;
|
|
8324
8398
|
let n = Math.abs(e.scaleX ?? 1) || 1, r = Math.abs(e.scaleY ?? 1) || 1;
|
|
8325
8399
|
if (!(Math.abs(n - 1) > .01 || Math.abs(r - 1) > .01)) return !1;
|
|
8326
|
-
let i =
|
|
8327
|
-
return
|
|
8400
|
+
let i = $r({ textbox: e }), a = this.canvasManager.getObjectPlacement({ object: e });
|
|
8401
|
+
return ti({
|
|
8328
8402
|
textbox: e,
|
|
8329
8403
|
canvasManager: this.canvasManager,
|
|
8330
8404
|
base: i,
|
|
@@ -8340,7 +8414,7 @@ var ai = class {
|
|
|
8340
8414
|
_ensureScalingState({ textbox: e, transform: t }) {
|
|
8341
8415
|
let n = this.scalingState.get(e);
|
|
8342
8416
|
if (!n) {
|
|
8343
|
-
let r =
|
|
8417
|
+
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
8418
|
n = {
|
|
8345
8419
|
startBase: r,
|
|
8346
8420
|
startObjectPlacement: i,
|
|
@@ -8373,7 +8447,7 @@ var ai = class {
|
|
|
8373
8447
|
topRight: e.radiusTopRight ?? 0,
|
|
8374
8448
|
bottomRight: e.radiusBottomRight ?? 0,
|
|
8375
8449
|
bottomLeft: e.radiusBottomLeft ?? 0
|
|
8376
|
-
}, v = Math.abs(n - o) >
|
|
8450
|
+
}, 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
8451
|
if (c) {
|
|
8378
8452
|
let e = h / Math.max(1, m);
|
|
8379
8453
|
S = e, C = e;
|
|
@@ -8394,7 +8468,7 @@ var ai = class {
|
|
|
8394
8468
|
originY: a
|
|
8395
8469
|
});
|
|
8396
8470
|
}
|
|
8397
|
-
},
|
|
8471
|
+
}, li = ({ textbox: e }) => {
|
|
8398
8472
|
let t = e.text ?? "";
|
|
8399
8473
|
if (!t.length) return [];
|
|
8400
8474
|
let n = t.split("\n"), r = [], i = 0;
|
|
@@ -8406,7 +8480,7 @@ var ai = class {
|
|
|
8406
8480
|
});
|
|
8407
8481
|
}
|
|
8408
8482
|
return r;
|
|
8409
|
-
},
|
|
8483
|
+
}, ui = ({ range: e, text: t }) => {
|
|
8410
8484
|
if (!e) return null;
|
|
8411
8485
|
let n = t.length;
|
|
8412
8486
|
if (n <= 0) return null;
|
|
@@ -8415,8 +8489,8 @@ var ai = class {
|
|
|
8415
8489
|
start: l,
|
|
8416
8490
|
end: u
|
|
8417
8491
|
};
|
|
8418
|
-
},
|
|
8419
|
-
let n =
|
|
8492
|
+
}, di = ({ textbox: e, range: t }) => {
|
|
8493
|
+
let n = li({ textbox: e });
|
|
8420
8494
|
if (!n.length) return t;
|
|
8421
8495
|
let { start: r } = t, { end: i } = t;
|
|
8422
8496
|
for (let e = 0; e < n.length; e += 1) {
|
|
@@ -8429,7 +8503,7 @@ var ai = class {
|
|
|
8429
8503
|
start: r,
|
|
8430
8504
|
end: i
|
|
8431
8505
|
};
|
|
8432
|
-
},
|
|
8506
|
+
}, fi = ({ textbox: e, range: t }) => {
|
|
8433
8507
|
let n = e.text ?? "";
|
|
8434
8508
|
if (!n.length) return [];
|
|
8435
8509
|
let { start: r, end: i } = t, a = n.split("\n"), o = [], s = 0;
|
|
@@ -8438,7 +8512,7 @@ var ai = class {
|
|
|
8438
8512
|
i > n && r < c && o.push(e), s = c + 1;
|
|
8439
8513
|
}
|
|
8440
8514
|
return o;
|
|
8441
|
-
},
|
|
8515
|
+
}, pi = ({ textbox: e, range: t }) => {
|
|
8442
8516
|
let n = e.text ?? "";
|
|
8443
8517
|
if (!n.length) return [];
|
|
8444
8518
|
let { start: r, end: i } = t, a = n.split("\n"), o = [], s = 0;
|
|
@@ -8447,20 +8521,20 @@ var ai = class {
|
|
|
8447
8521
|
r <= n && i >= c && o.push(e), s = c + 1;
|
|
8448
8522
|
}
|
|
8449
8523
|
return o;
|
|
8450
|
-
},
|
|
8524
|
+
}, mi = ({ previous: e, next: t }) => {
|
|
8451
8525
|
let n = Math.min(e.length, t.length);
|
|
8452
8526
|
for (let r = 0; r < n; r += 1) if (e[r] !== t[r]) return r;
|
|
8453
8527
|
return n;
|
|
8454
|
-
},
|
|
8528
|
+
}, hi = ({ text: e, charIndex: t }) => {
|
|
8455
8529
|
let n = Math.max(0, Math.min(t, e.length)), r = 0;
|
|
8456
8530
|
for (let t = 0; t < n; t += 1) e[t] === "\n" && (r += 1);
|
|
8457
8531
|
return r;
|
|
8458
|
-
},
|
|
8532
|
+
}, gi = ({ text: e, lineIndex: t }) => {
|
|
8459
8533
|
if (t <= 0) return 0;
|
|
8460
8534
|
let n = 0;
|
|
8461
8535
|
for (let r = 0; r < e.length; r += 1) if (e[r] === "\n" && (n += 1, n === t)) return r + 1;
|
|
8462
8536
|
return e.length;
|
|
8463
|
-
},
|
|
8537
|
+
}, _i = class e {
|
|
8464
8538
|
constructor({ editor: t }) {
|
|
8465
8539
|
this._handleTextEditingEntered = (t) => {
|
|
8466
8540
|
this.isTextEditingActive = !0;
|
|
@@ -8473,7 +8547,7 @@ var ai = class {
|
|
|
8473
8547
|
if (!e._isTextbox(n) || this.lineDefaultsSyncing.has(n)) return;
|
|
8474
8548
|
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
8549
|
if (s) {
|
|
8476
|
-
let e =
|
|
8550
|
+
let e = Lr({ value: l });
|
|
8477
8551
|
e !== i && n.set({ text: e }), n.textCaseRaw = l;
|
|
8478
8552
|
} else n.textCaseRaw = i;
|
|
8479
8553
|
if (!r && o === void 0 && (n.autoExpand = !0), r) {
|
|
@@ -8491,7 +8565,7 @@ var ai = class {
|
|
|
8491
8565
|
let r = e._isShapeOwnedTextbox(n);
|
|
8492
8566
|
this.editingPlacementState?.delete(n);
|
|
8493
8567
|
let i = n.text ?? "";
|
|
8494
|
-
n.uppercase ? n.textCaseRaw = n.textCaseRaw ?? i.toLocaleLowerCase() : n.textCaseRaw = i, r || (
|
|
8568
|
+
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
8569
|
lockMovementX: !1,
|
|
8496
8570
|
lockMovementY: !1
|
|
8497
8571
|
}));
|
|
@@ -8518,7 +8592,7 @@ var ai = class {
|
|
|
8518
8592
|
transform: r,
|
|
8519
8593
|
event: i ?? null
|
|
8520
8594
|
});
|
|
8521
|
-
}, this.editor = t, this.canvas = t.canvas, this.fonts = t.options.fonts ?? [], this.scalingController = new
|
|
8595
|
+
}, this.editor = t, this.canvas = t.canvas, this.fonts = t.options.fonts ?? [], this.scalingController = new ci({
|
|
8522
8596
|
canvas: t.canvas,
|
|
8523
8597
|
canvasManager: t.canvasManager,
|
|
8524
8598
|
persistScaledTextbox: ({ target: e, style: t }) => {
|
|
@@ -8527,12 +8601,12 @@ var ai = class {
|
|
|
8527
8601
|
style: t
|
|
8528
8602
|
});
|
|
8529
8603
|
}
|
|
8530
|
-
}), this.editingPlacementState = /* @__PURE__ */ new WeakMap(), this.lineDefaultsSyncing = /* @__PURE__ */ new WeakSet(), this.isTextEditingActive = !1, this._bindEvents(),
|
|
8604
|
+
}), this.editingPlacementState = /* @__PURE__ */ new WeakMap(), this.lineDefaultsSyncing = /* @__PURE__ */ new WeakSet(), this.isTextEditingActive = !1, this._bindEvents(), Br();
|
|
8531
8605
|
}
|
|
8532
8606
|
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
8607
|
let { canvasManager: M, historyManager: N } = this.editor, { canvas: P } = this;
|
|
8534
8608
|
N.suspendHistory();
|
|
8535
|
-
let F = i ?? this._getDefaultFontFamily(), I =
|
|
8609
|
+
let F = i ?? this._getDefaultFontFamily(), I = Ir({ width: m }), L = Fr({
|
|
8536
8610
|
strokeColor: p,
|
|
8537
8611
|
width: I
|
|
8538
8612
|
}), ee = {
|
|
@@ -8561,14 +8635,14 @@ var ai = class {
|
|
|
8561
8635
|
radiusBottomRight: w,
|
|
8562
8636
|
radiusBottomLeft: T,
|
|
8563
8637
|
...E
|
|
8564
|
-
}, R = new
|
|
8638
|
+
}, R = new zr(n, ee), te = r !== !1;
|
|
8565
8639
|
R.autoExpand = te;
|
|
8566
8640
|
let ne = E.left !== void 0 || E.top !== void 0;
|
|
8567
8641
|
if (R.textCaseRaw = R.text ?? "", l) {
|
|
8568
|
-
let e =
|
|
8642
|
+
let e = Lr({ value: R.textCaseRaw });
|
|
8569
8643
|
e !== R.text && R.set({ text: e });
|
|
8570
8644
|
}
|
|
8571
|
-
|
|
8645
|
+
Qr({ textbox: R }) && (R.dirty = !0);
|
|
8572
8646
|
let z;
|
|
8573
8647
|
ne && (z = M.resolveObjectPlacement({
|
|
8574
8648
|
object: R,
|
|
@@ -8615,13 +8689,13 @@ var ai = class {
|
|
|
8615
8689
|
top: ee,
|
|
8616
8690
|
originX: R,
|
|
8617
8691
|
originY: te
|
|
8618
|
-
}), B = a === void 0 ?
|
|
8692
|
+
}), B = a === void 0 ? Ar({ textbox: s }) : ui({
|
|
8619
8693
|
text: c,
|
|
8620
8694
|
range: a
|
|
8621
|
-
}), V = B ?
|
|
8695
|
+
}), V = B ? di({
|
|
8622
8696
|
textbox: s,
|
|
8623
8697
|
range: B
|
|
8624
|
-
}) : null, H = {}, ie = {}, U = {}, ae, oe, se =
|
|
8698
|
+
}) : null, H = {}, ie = {}, U = {}, ae, oe, se = Mr({
|
|
8625
8699
|
textbox: s,
|
|
8626
8700
|
range: B
|
|
8627
8701
|
}), ce = !B || se, le = !B;
|
|
@@ -8634,24 +8708,24 @@ var ai = class {
|
|
|
8634
8708
|
B && (H.fontStyle = e), ce && (z.fontStyle = e, le && (U.fontStyle = e));
|
|
8635
8709
|
}
|
|
8636
8710
|
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 ?
|
|
8711
|
+
let e = B ? Pr({
|
|
8638
8712
|
textbox: s,
|
|
8639
8713
|
range: B,
|
|
8640
8714
|
property: "strokeWidth"
|
|
8641
|
-
}) : void 0, t = B ?
|
|
8715
|
+
}) : void 0, t = B ? Pr({
|
|
8642
8716
|
textbox: s,
|
|
8643
8717
|
range: B,
|
|
8644
8718
|
property: "stroke"
|
|
8645
8719
|
}) : void 0;
|
|
8646
|
-
oe =
|
|
8720
|
+
oe = Ir({ width: T ?? e ?? s.strokeWidth ?? 0 }), ae = Fr({
|
|
8647
8721
|
strokeColor: w ?? t ?? s.stroke ?? void 0,
|
|
8648
8722
|
width: oe
|
|
8649
8723
|
}), B && (H.stroke = ae, H.strokeWidth = oe), ce && (z.stroke = ae, z.strokeWidth = oe, le && (U.stroke = ae, U.strokeWidth = oe));
|
|
8650
8724
|
}
|
|
8651
8725
|
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
8726
|
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 =
|
|
8727
|
+
fe || he ? (z.text = me ? Lr({ value: pe }) : pe, s.textCaseRaw = pe) : s.textCaseRaw === void 0 && (s.textCaseRaw = ue);
|
|
8728
|
+
let ge = Zr({ stylesList: [
|
|
8655
8729
|
z,
|
|
8656
8730
|
H,
|
|
8657
8731
|
ie,
|
|
@@ -8667,53 +8741,53 @@ var ai = class {
|
|
|
8667
8741
|
j,
|
|
8668
8742
|
M
|
|
8669
8743
|
], 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 =
|
|
8744
|
+
Se && (Ce = Jr({
|
|
8671
8745
|
textbox: s,
|
|
8672
8746
|
originX: re.originX,
|
|
8673
8747
|
originY: re.originY
|
|
8674
8748
|
})), s.uppercase = me, s.set(z);
|
|
8675
8749
|
let we = !1;
|
|
8676
8750
|
if (B) {
|
|
8677
|
-
let e =
|
|
8751
|
+
let e = Nr({
|
|
8678
8752
|
textbox: s,
|
|
8679
8753
|
styles: H,
|
|
8680
8754
|
range: B
|
|
8681
|
-
}), t = V ?
|
|
8755
|
+
}), t = V ? Nr({
|
|
8682
8756
|
textbox: s,
|
|
8683
8757
|
styles: ie,
|
|
8684
8758
|
range: V
|
|
8685
8759
|
}) : !1;
|
|
8686
8760
|
we = e || t;
|
|
8687
8761
|
} else if (Object.keys(U).length) {
|
|
8688
|
-
let e =
|
|
8689
|
-
e && (we =
|
|
8762
|
+
let e = jr({ textbox: s });
|
|
8763
|
+
e && (we = Nr({
|
|
8690
8764
|
textbox: s,
|
|
8691
8765
|
styles: U,
|
|
8692
8766
|
range: e
|
|
8693
8767
|
}));
|
|
8694
8768
|
}
|
|
8695
|
-
let Te = we &&
|
|
8769
|
+
let Te = we && Zr({ stylesList: [
|
|
8696
8770
|
H,
|
|
8697
8771
|
ie,
|
|
8698
8772
|
U
|
|
8699
8773
|
] });
|
|
8700
8774
|
if (we && (s.dirty = !0), V && (h !== void 0 || g !== void 0)) {
|
|
8701
|
-
let e =
|
|
8775
|
+
let e = fi({
|
|
8702
8776
|
textbox: s,
|
|
8703
8777
|
range: V
|
|
8704
8778
|
}), t = {};
|
|
8705
|
-
h !== void 0 && (t.fontFamily = h), g !== void 0 && (t.fontSize = g),
|
|
8779
|
+
h !== void 0 && (t.fontFamily = h), g !== void 0 && (t.fontSize = g), Hr({
|
|
8706
8780
|
textbox: s,
|
|
8707
8781
|
lineIndices: e,
|
|
8708
8782
|
updates: t
|
|
8709
8783
|
});
|
|
8710
8784
|
}
|
|
8711
8785
|
if (B && (C !== void 0 || w !== void 0 || T !== void 0)) {
|
|
8712
|
-
let e =
|
|
8786
|
+
let e = pi({
|
|
8713
8787
|
textbox: s,
|
|
8714
8788
|
range: B
|
|
8715
8789
|
}), t = {};
|
|
8716
|
-
C !== void 0 && (t.fill = C), (w !== void 0 || T !== void 0) && (ae === null && (t.stroke = null), ae != null && (t.stroke = ae)),
|
|
8790
|
+
C !== void 0 && (t.fill = C), (w !== void 0 || T !== void 0) && (ae === null && (t.stroke = null), ae != null && (t.stroke = ae)), Hr({
|
|
8717
8791
|
textbox: s,
|
|
8718
8792
|
lineIndices: e,
|
|
8719
8793
|
updates: t
|
|
@@ -8808,7 +8882,7 @@ var ai = class {
|
|
|
8808
8882
|
clampToMontage: r
|
|
8809
8883
|
}));
|
|
8810
8884
|
let a = !1;
|
|
8811
|
-
i || (a =
|
|
8885
|
+
i || (a = Qr({ textbox: e }));
|
|
8812
8886
|
let o = !1;
|
|
8813
8887
|
return !i && t && (this.editor.canvasManager.applyObjectPlacement({
|
|
8814
8888
|
object: e,
|
|
@@ -8816,7 +8890,7 @@ var ai = class {
|
|
|
8816
8890
|
}), o = !0), (i || a) && (e.dirty = !0), (i || a || o) && e.setCoords(), i || a;
|
|
8817
8891
|
}
|
|
8818
8892
|
_restoreTextboxContentPlacement({ textbox: e, contentPlacement: t }) {
|
|
8819
|
-
let n =
|
|
8893
|
+
let n = Jr({
|
|
8820
8894
|
textbox: e,
|
|
8821
8895
|
originX: t.originX,
|
|
8822
8896
|
originY: t.originY
|
|
@@ -8836,15 +8910,15 @@ var ai = class {
|
|
|
8836
8910
|
_syncLineFontDefaultsOnTextChanged({ textbox: e }) {
|
|
8837
8911
|
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
8912
|
if (h !== 0 && n && Object.keys(n).length) {
|
|
8839
|
-
let e =
|
|
8913
|
+
let e = mi({
|
|
8840
8914
|
previous: d,
|
|
8841
8915
|
next: u
|
|
8842
|
-
}), t =
|
|
8916
|
+
}), t = hi({
|
|
8843
8917
|
text: d,
|
|
8844
8918
|
charIndex: e
|
|
8845
8919
|
});
|
|
8846
8920
|
if (h > 0) {
|
|
8847
|
-
let r =
|
|
8921
|
+
let r = gi({
|
|
8848
8922
|
text: d,
|
|
8849
8923
|
lineIndex: t
|
|
8850
8924
|
}), i = t + 1;
|
|
@@ -8885,7 +8959,7 @@ var ai = class {
|
|
|
8885
8959
|
let t = p[e] ?? "", n = g ? g[e] : void 0;
|
|
8886
8960
|
if (n && (T = n), t.length !== 0) {
|
|
8887
8961
|
if (n) {
|
|
8888
|
-
let r =
|
|
8962
|
+
let r = Ur({
|
|
8889
8963
|
lineText: t,
|
|
8890
8964
|
lineStyles: S ? S[e] : void 0,
|
|
8891
8965
|
lineDefaults: n
|
|
@@ -8925,16 +8999,16 @@ var ai = class {
|
|
|
8925
8999
|
if (!Number.isFinite(f) || f <= 0) return !1;
|
|
8926
9000
|
let p = a.split("\n").length, m = !1;
|
|
8927
9001
|
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(
|
|
9002
|
+
let { textLines: h } = e, g = Array.isArray(h) && h.length > p, _ = Math.ceil(Kr({
|
|
8929
9003
|
textbox: e,
|
|
8930
9004
|
text: a
|
|
8931
9005
|
})), 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),
|
|
9006
|
+
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
9007
|
object: e,
|
|
8934
9008
|
placement: t
|
|
8935
9009
|
});
|
|
8936
9010
|
let b = !1;
|
|
8937
|
-
return n && (b =
|
|
9011
|
+
return n && (b = Yr({
|
|
8938
9012
|
textbox: e,
|
|
8939
9013
|
montageLeft: o,
|
|
8940
9014
|
montageRight: o + s
|
|
@@ -8992,7 +9066,7 @@ var ai = class {
|
|
|
8992
9066
|
_getDefaultFontFamily() {
|
|
8993
9067
|
return this.fonts[0]?.family ?? "Arial";
|
|
8994
9068
|
}
|
|
8995
|
-
},
|
|
9069
|
+
}, vi = ({ x1: e, y1: t, x2: n, y2: r }) => (Math.atan2(r - t, n - e) * 180 / Math.PI + 360) % 360, yi = (e) => {
|
|
8996
9070
|
if (!e || typeof e != "object") return null;
|
|
8997
9071
|
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
9072
|
color: typeof e.color == "string" ? e.color : "#000000",
|
|
@@ -9003,7 +9077,7 @@ var ai = class {
|
|
|
9003
9077
|
let { x1: e, y1: t, x2: r, y2: i } = n;
|
|
9004
9078
|
if (typeof e == "number" && typeof t == "number" && typeof r == "number" && typeof i == "number") return {
|
|
9005
9079
|
type: "linear",
|
|
9006
|
-
angle:
|
|
9080
|
+
angle: vi({
|
|
9007
9081
|
x1: e,
|
|
9008
9082
|
y1: t,
|
|
9009
9083
|
x2: r,
|
|
@@ -9031,7 +9105,7 @@ var ai = class {
|
|
|
9031
9105
|
};
|
|
9032
9106
|
}
|
|
9033
9107
|
return null;
|
|
9034
|
-
},
|
|
9108
|
+
}, bi = "_templateAnchorX", xi = "_templateAnchorY", Si = class t {
|
|
9035
9109
|
constructor({ editor: e }) {
|
|
9036
9110
|
this.editor = e;
|
|
9037
9111
|
}
|
|
@@ -9040,7 +9114,7 @@ var ai = class {
|
|
|
9040
9114
|
if (!p.length) return s.emitWarning({
|
|
9041
9115
|
origin: "TemplateManager",
|
|
9042
9116
|
method: "serializeSelection",
|
|
9043
|
-
code:
|
|
9117
|
+
code: Dr.TEMPLATE_MANAGER.NO_OBJECTS_SELECTED,
|
|
9044
9118
|
message: "Нет объектов для сериализации шаблона"
|
|
9045
9119
|
}), null;
|
|
9046
9120
|
let m = t._getBounds(o), h = t._getMontageSize({
|
|
@@ -9069,14 +9143,14 @@ var ai = class {
|
|
|
9069
9143
|
if (!s?.length) return a.emitWarning({
|
|
9070
9144
|
origin: "TemplateManager",
|
|
9071
9145
|
method: "applyTemplate",
|
|
9072
|
-
code:
|
|
9146
|
+
code: Dr.TEMPLATE_MANAGER.INVALID_TEMPLATE,
|
|
9073
9147
|
message: "Шаблон не содержит объектов"
|
|
9074
9148
|
}), null;
|
|
9075
9149
|
let u = t._getBounds(r);
|
|
9076
9150
|
if (!u) return a.emitWarning({
|
|
9077
9151
|
origin: "TemplateManager",
|
|
9078
9152
|
method: "applyTemplate",
|
|
9079
|
-
code:
|
|
9153
|
+
code: Dr.TEMPLATE_MANAGER.INVALID_TARGET,
|
|
9080
9154
|
message: "Не удалось определить границы монтажной области"
|
|
9081
9155
|
}), null;
|
|
9082
9156
|
let d = t._getMontageSize({
|
|
@@ -9095,7 +9169,7 @@ var ai = class {
|
|
|
9095
9169
|
if (!r.length) return a.emitWarning({
|
|
9096
9170
|
origin: "TemplateManager",
|
|
9097
9171
|
method: "applyTemplate",
|
|
9098
|
-
code:
|
|
9172
|
+
code: Dr.TEMPLATE_MANAGER.INVALID_TEMPLATE,
|
|
9099
9173
|
message: "Не удалось создать объекты шаблона"
|
|
9100
9174
|
}), null;
|
|
9101
9175
|
let { backgroundObject: i, contentObjects: c } = t._extractBackgroundObject(r);
|
|
@@ -9130,7 +9204,7 @@ var ai = class {
|
|
|
9130
9204
|
return a.emitError({
|
|
9131
9205
|
origin: "TemplateManager",
|
|
9132
9206
|
method: "applyTemplate",
|
|
9133
|
-
code:
|
|
9207
|
+
code: Dr.TEMPLATE_MANAGER.APPLY_FAILED,
|
|
9134
9208
|
message: "Ошибка применения шаблона",
|
|
9135
9209
|
data: {
|
|
9136
9210
|
templateId: l,
|
|
@@ -9284,8 +9358,8 @@ var ai = class {
|
|
|
9284
9358
|
baseHeight: a,
|
|
9285
9359
|
scale: n,
|
|
9286
9360
|
useRelativePositions: o,
|
|
9287
|
-
anchorX: t._resolveAnchor(s,
|
|
9288
|
-
anchorY: t._resolveAnchor(s,
|
|
9361
|
+
anchorX: t._resolveAnchor(s, bi),
|
|
9362
|
+
anchorY: t._resolveAnchor(s, xi)
|
|
9289
9363
|
})
|
|
9290
9364
|
}), h = f * n, g = p * n, _ = e.originX ?? "center", v = e.originY ?? "center";
|
|
9291
9365
|
e.set({
|
|
@@ -9299,7 +9373,7 @@ var ai = class {
|
|
|
9299
9373
|
originX: _,
|
|
9300
9374
|
originY: v
|
|
9301
9375
|
}
|
|
9302
|
-
}), delete s[
|
|
9376
|
+
}), delete s[bi], delete s[xi];
|
|
9303
9377
|
}
|
|
9304
9378
|
static _getPositioningBounds({ bounds: e, baseWidth: n, baseHeight: r, scale: i, useRelativePositions: a, anchorX: o, anchorY: s }) {
|
|
9305
9379
|
if (!a) return e;
|
|
@@ -9363,7 +9437,7 @@ var ai = class {
|
|
|
9363
9437
|
});
|
|
9364
9438
|
if (!i || !s || !o) return;
|
|
9365
9439
|
e.setCoords();
|
|
9366
|
-
let c = e, l = t._resolveAnchor(c,
|
|
9440
|
+
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
9441
|
e.set("width", i), e.initDimensions();
|
|
9368
9442
|
let g = t._getLongestLineWidth({
|
|
9369
9443
|
textbox: e,
|
|
@@ -9392,10 +9466,10 @@ var ai = class {
|
|
|
9392
9466
|
x: (p.left - o) / d,
|
|
9393
9467
|
y: (p.top - s) / f
|
|
9394
9468
|
}, h = (u.left - o) / d, g = (u.top - s) / f, _ = h + u.width / d, v = g + u.height / f;
|
|
9395
|
-
return a[
|
|
9469
|
+
return a[bi] = t._detectAnchor({
|
|
9396
9470
|
start: h,
|
|
9397
9471
|
end: _
|
|
9398
|
-
}), a[
|
|
9472
|
+
}), a[xi] = t._detectAnchor({
|
|
9399
9473
|
start: g,
|
|
9400
9474
|
end: v
|
|
9401
9475
|
}), a.left = m.x, a.top = m.y, a;
|
|
@@ -9420,7 +9494,7 @@ var ai = class {
|
|
|
9420
9494
|
withoutSave: !0
|
|
9421
9495
|
}), !0;
|
|
9422
9496
|
if (a === "gradient") {
|
|
9423
|
-
let e =
|
|
9497
|
+
let e = yi(r);
|
|
9424
9498
|
if (e) return n.setGradientBackground({
|
|
9425
9499
|
gradient: e,
|
|
9426
9500
|
customData: o,
|
|
@@ -9441,7 +9515,7 @@ var ai = class {
|
|
|
9441
9515
|
r.emitWarning({
|
|
9442
9516
|
origin: "TemplateManager",
|
|
9443
9517
|
method: "applyTemplate",
|
|
9444
|
-
code:
|
|
9518
|
+
code: Dr.TEMPLATE_MANAGER.APPLY_FAILED,
|
|
9445
9519
|
message: "Не удалось применить фон из шаблона",
|
|
9446
9520
|
data: e
|
|
9447
9521
|
});
|
|
@@ -9477,29 +9551,29 @@ var ai = class {
|
|
|
9477
9551
|
enlivenObjectEnlivables(e) {
|
|
9478
9552
|
return C.enlivenObjectEnlivables(e);
|
|
9479
9553
|
}
|
|
9480
|
-
},
|
|
9481
|
-
let n =
|
|
9554
|
+
}, Ci = "#3D8BF4", wi = .5, Ti = ({ distance: e }) => Number.isFinite(e) ? Math.round(Math.max(0, e)) : 0, Ei = ({ firstDistance: e, secondDistance: t }) => {
|
|
9555
|
+
let n = Ti({ distance: e }), r = Ti({ distance: t });
|
|
9482
9556
|
return {
|
|
9483
9557
|
firstDisplayDistance: n,
|
|
9484
9558
|
secondDisplayDistance: r,
|
|
9485
9559
|
displayDistanceDiff: Math.abs(n - r),
|
|
9486
9560
|
commonDisplayDistance: Math.max(n, r)
|
|
9487
9561
|
};
|
|
9488
|
-
},
|
|
9562
|
+
}, Di = ({ firstStart: e, firstEnd: t, secondStart: n, secondEnd: r }) => Math.min(t, r) - Math.max(e, n), Oi = ({ step: e }) => {
|
|
9489
9563
|
let t = Math.abs(e).toString(), n = t.indexOf(".");
|
|
9490
9564
|
return n === -1 ? 0 : t.slice(n + 1).length;
|
|
9491
|
-
},
|
|
9565
|
+
}, ki = ({ value: e, step: t }) => {
|
|
9492
9566
|
if (t === 0) return e;
|
|
9493
|
-
let n =
|
|
9567
|
+
let n = Oi({ step: t }), r = Math.round(e / t) * t;
|
|
9494
9568
|
return Number(r.toFixed(n));
|
|
9495
|
-
},
|
|
9569
|
+
}, Ai = ({ value: e, step: t }) => {
|
|
9496
9570
|
if (t === 0) return !0;
|
|
9497
|
-
let n =
|
|
9571
|
+
let n = ki({
|
|
9498
9572
|
value: e,
|
|
9499
9573
|
step: t
|
|
9500
|
-
}), r = 10 ** -(
|
|
9574
|
+
}), r = 10 ** -(Oi({ step: t }) + 4);
|
|
9501
9575
|
return Math.abs(n - e) <= r;
|
|
9502
|
-
},
|
|
9576
|
+
}, ji = ({ bounds: e, axis: t }) => {
|
|
9503
9577
|
let { left: n = 0, right: r = 0, top: i = 0, bottom: a = 0 } = e;
|
|
9504
9578
|
return t === "vertical" ? {
|
|
9505
9579
|
start: i,
|
|
@@ -9508,7 +9582,7 @@ var ai = class {
|
|
|
9508
9582
|
start: n,
|
|
9509
9583
|
end: r
|
|
9510
9584
|
};
|
|
9511
|
-
},
|
|
9585
|
+
}, Mi = ({ items: e, axis: t }) => {
|
|
9512
9586
|
for (let n = 1; n < e.length; n += 1) {
|
|
9513
9587
|
let r = e[n], { bounds: i } = r, a = i[t], o = n - 1;
|
|
9514
9588
|
for (; o >= 0;) {
|
|
@@ -9518,10 +9592,10 @@ var ai = class {
|
|
|
9518
9592
|
}
|
|
9519
9593
|
e[o + 1] = r;
|
|
9520
9594
|
}
|
|
9521
|
-
},
|
|
9595
|
+
}, Ni = ({ items: e, index: t, axis: n, direction: r }) => {
|
|
9522
9596
|
let i = e[t];
|
|
9523
9597
|
if (!i) return null;
|
|
9524
|
-
let { bounds: a } = i, { start: o, end: s } =
|
|
9598
|
+
let { bounds: a } = i, { start: o, end: s } = ji({
|
|
9525
9599
|
bounds: a,
|
|
9526
9600
|
axis: n
|
|
9527
9601
|
});
|
|
@@ -9529,7 +9603,7 @@ var ai = class {
|
|
|
9529
9603
|
for (let r = t - 1; r >= 0; --r) {
|
|
9530
9604
|
let t = e[r];
|
|
9531
9605
|
if (!t) continue;
|
|
9532
|
-
let { bounds: i } = t, { end: a } =
|
|
9606
|
+
let { bounds: i } = t, { end: a } = ji({
|
|
9533
9607
|
bounds: i,
|
|
9534
9608
|
axis: n
|
|
9535
9609
|
});
|
|
@@ -9540,26 +9614,26 @@ var ai = class {
|
|
|
9540
9614
|
for (let r = t + 1; r < e.length; r += 1) {
|
|
9541
9615
|
let t = e[r];
|
|
9542
9616
|
if (!t) continue;
|
|
9543
|
-
let { bounds: i } = t, { start: a } =
|
|
9617
|
+
let { bounds: i } = t, { start: a } = ji({
|
|
9544
9618
|
bounds: i,
|
|
9545
9619
|
axis: n
|
|
9546
9620
|
});
|
|
9547
9621
|
if (a - s >= 0) return r;
|
|
9548
9622
|
}
|
|
9549
9623
|
return null;
|
|
9550
|
-
},
|
|
9624
|
+
}, Pi = ({ items: e }) => {
|
|
9551
9625
|
for (let t = 0; t < e.length; t += 1) {
|
|
9552
9626
|
let { isActive: n } = e[t];
|
|
9553
9627
|
if (n) return t;
|
|
9554
9628
|
}
|
|
9555
9629
|
return -1;
|
|
9556
|
-
},
|
|
9630
|
+
}, Fi = ({ patternAxis: e, activeRangeStart: t, activeRangeEnd: n, tolerance: r = 0 }) => {
|
|
9557
9631
|
let i = Math.min(t, n), a = Math.max(t, n);
|
|
9558
9632
|
return e >= i - r && e <= a + r;
|
|
9559
|
-
},
|
|
9633
|
+
}, Ii = ({ patternStart: e, patternEnd: t, activeStart: n, activeEnd: r }) => t <= n ? "before" : e >= r ? "after" : null, Li = ({ baseOption: e, candidateOption: t }) => {
|
|
9560
9634
|
let { delta: n, guide: { distance: r } } = e, { delta: i, guide: { distance: a } } = t;
|
|
9561
9635
|
return n === i && r === a;
|
|
9562
|
-
},
|
|
9636
|
+
}, Ri = ({ options: e }) => {
|
|
9563
9637
|
let t = e[0];
|
|
9564
9638
|
for (let n = 1; n < e.length; n += 1) {
|
|
9565
9639
|
let r = e[n];
|
|
@@ -9570,11 +9644,11 @@ var ai = class {
|
|
|
9570
9644
|
r.diff === t.diff && Math.abs(r.delta) < Math.abs(t.delta) && (t = r);
|
|
9571
9645
|
}
|
|
9572
9646
|
return t;
|
|
9573
|
-
},
|
|
9647
|
+
}, zi = ({ currentOption: e, nextOption: t }) => {
|
|
9574
9648
|
if (!e) return !0;
|
|
9575
9649
|
let { contextDistance: n, diff: r, delta: i } = e, { contextDistance: a, diff: o, delta: s } = t;
|
|
9576
9650
|
return a < n ? !0 : a > n ? !1 : o < r ? !0 : o > r ? !1 : Math.abs(s) < Math.abs(i);
|
|
9577
|
-
},
|
|
9651
|
+
}, Bi = ({ options: e }) => {
|
|
9578
9652
|
let t = [], n = null, r = null;
|
|
9579
9653
|
for (let i of e) {
|
|
9580
9654
|
let { kind: e, side: a } = i;
|
|
@@ -9582,18 +9656,18 @@ var ai = class {
|
|
|
9582
9656
|
t.push(i);
|
|
9583
9657
|
continue;
|
|
9584
9658
|
}
|
|
9585
|
-
a === "before" &&
|
|
9659
|
+
a === "before" && zi({
|
|
9586
9660
|
currentOption: n,
|
|
9587
9661
|
nextOption: i
|
|
9588
|
-
}) && (n = i), a === "after" &&
|
|
9662
|
+
}) && (n = i), a === "after" && zi({
|
|
9589
9663
|
currentOption: r,
|
|
9590
9664
|
nextOption: i
|
|
9591
9665
|
}) && (r = i);
|
|
9592
9666
|
}
|
|
9593
9667
|
return n && t.push(n), r && t.push(r), t;
|
|
9594
|
-
},
|
|
9668
|
+
}, Vi = ({ options: e, side: t, baseOption: n }) => {
|
|
9595
9669
|
let r = null;
|
|
9596
|
-
for (let i of e) if (i.side === t &&
|
|
9670
|
+
for (let i of e) if (i.side === t && Li({
|
|
9597
9671
|
baseOption: n,
|
|
9598
9672
|
candidateOption: i
|
|
9599
9673
|
})) {
|
|
@@ -9604,63 +9678,63 @@ var ai = class {
|
|
|
9604
9678
|
!r || i.diff !== r.diff || Math.abs(i.delta) < Math.abs(r.delta) && (r = i);
|
|
9605
9679
|
}
|
|
9606
9680
|
return r;
|
|
9607
|
-
},
|
|
9681
|
+
}, Hi = ({ option: e }) => {
|
|
9608
9682
|
let { side: t, kind: n, guide: { distance: r } } = e;
|
|
9609
9683
|
return {
|
|
9610
9684
|
side: t,
|
|
9611
9685
|
kind: n,
|
|
9612
9686
|
distance: r
|
|
9613
9687
|
};
|
|
9614
|
-
},
|
|
9688
|
+
}, Ui = ({ option: e, context: t }) => {
|
|
9615
9689
|
let { side: n, kind: r, distance: i } = t, { side: a, kind: o, guide: { distance: s } } = e;
|
|
9616
9690
|
return n !== a || r !== o ? !1 : Math.abs(s - i) <= 1;
|
|
9617
|
-
},
|
|
9691
|
+
}, Wi = ({ options: e, context: t }) => {
|
|
9618
9692
|
if (!t) return null;
|
|
9619
|
-
for (let n of e) if (
|
|
9693
|
+
for (let n of e) if (Ui({
|
|
9620
9694
|
option: n,
|
|
9621
9695
|
context: t
|
|
9622
9696
|
})) return n;
|
|
9623
9697
|
return null;
|
|
9624
|
-
},
|
|
9625
|
-
let i =
|
|
9698
|
+
}, Gi = ({ options: e, bestOption: t, previousContext: n, switchDistance: r = 0 }) => {
|
|
9699
|
+
let i = Wi({
|
|
9626
9700
|
options: e,
|
|
9627
9701
|
context: n
|
|
9628
9702
|
});
|
|
9629
9703
|
if (!i) return t;
|
|
9630
9704
|
let a = Math.max(0, r);
|
|
9631
9705
|
return a === 0 || Math.abs(t.delta - i.delta) >= a ? t : i;
|
|
9632
|
-
},
|
|
9706
|
+
}, Ki = ({ guides: e, seenGuideKeys: t, guide: n }) => {
|
|
9633
9707
|
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
9708
|
t.has(u) || (t.add(u), e.push(n));
|
|
9635
|
-
},
|
|
9709
|
+
}, qi = ({ options: e, previousContext: t = null, switchDistance: n = 0 }) => {
|
|
9636
9710
|
if (!e.length) return {
|
|
9637
9711
|
delta: 0,
|
|
9638
9712
|
guides: [],
|
|
9639
9713
|
context: null
|
|
9640
9714
|
};
|
|
9641
|
-
let r =
|
|
9715
|
+
let r = Bi({ options: e }), i = [];
|
|
9642
9716
|
for (let e of r) e.kind === "reference" && i.push(e);
|
|
9643
|
-
let a = i.length > 0, o = a ? i : r, s =
|
|
9717
|
+
let a = i.length > 0, o = a ? i : r, s = Gi({
|
|
9644
9718
|
options: o,
|
|
9645
|
-
bestOption:
|
|
9719
|
+
bestOption: Ri({ options: o }),
|
|
9646
9720
|
previousContext: t,
|
|
9647
9721
|
switchDistance: n
|
|
9648
|
-
}), c =
|
|
9722
|
+
}), c = Vi({
|
|
9649
9723
|
options: o,
|
|
9650
9724
|
side: "before",
|
|
9651
9725
|
baseOption: s
|
|
9652
|
-
}), l =
|
|
9726
|
+
}), l = Vi({
|
|
9653
9727
|
options: o,
|
|
9654
9728
|
side: "after",
|
|
9655
9729
|
baseOption: s
|
|
9656
|
-
}), u =
|
|
9730
|
+
}), u = Vi({
|
|
9657
9731
|
options: a ? r : o,
|
|
9658
9732
|
side: "center",
|
|
9659
9733
|
baseOption: s
|
|
9660
9734
|
}), d = [];
|
|
9661
9735
|
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
9736
|
let f = [], p = /* @__PURE__ */ new Set();
|
|
9663
|
-
for (let e of d)
|
|
9737
|
+
for (let e of d) Ki({
|
|
9664
9738
|
guides: f,
|
|
9665
9739
|
seenGuideKeys: p,
|
|
9666
9740
|
guide: e.guide
|
|
@@ -9668,15 +9742,15 @@ var ai = class {
|
|
|
9668
9742
|
return {
|
|
9669
9743
|
delta: s.delta,
|
|
9670
9744
|
guides: f,
|
|
9671
|
-
context:
|
|
9745
|
+
context: Hi({ option: s })
|
|
9672
9746
|
};
|
|
9673
|
-
},
|
|
9674
|
-
let s = n - (e - r), c =
|
|
9747
|
+
}, Ji = ({ activeStart: e, activeEnd: t, targetGap: n, beforeEdge: r, afterEdge: i, threshold: a, step: o }) => {
|
|
9748
|
+
let s = n - (e - r), c = ki({
|
|
9675
9749
|
value: s,
|
|
9676
9750
|
step: o
|
|
9677
9751
|
}), l = Math.max(1, Math.ceil(a / Math.max(o, 1))), u = null;
|
|
9678
9752
|
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: _ } =
|
|
9753
|
+
let l = c + d * o, f = e + l, p = t + l, m = f - r, h = i - p, { displayDistanceDiff: g, commonDisplayDistance: _ } = Ei({
|
|
9680
9754
|
firstDistance: m,
|
|
9681
9755
|
secondDistance: h
|
|
9682
9756
|
});
|
|
@@ -9691,13 +9765,13 @@ var ai = class {
|
|
|
9691
9765
|
});
|
|
9692
9766
|
}
|
|
9693
9767
|
return u;
|
|
9694
|
-
},
|
|
9695
|
-
let { secondDisplayDistance: n, displayDistanceDiff: r } =
|
|
9768
|
+
}, Yi = ({ currentGap: e, referenceGap: t }) => {
|
|
9769
|
+
let { secondDisplayDistance: n, displayDistanceDiff: r } = Ei({
|
|
9696
9770
|
firstDistance: e,
|
|
9697
9771
|
secondDistance: t
|
|
9698
9772
|
});
|
|
9699
9773
|
return r > 1 ? null : n;
|
|
9700
|
-
},
|
|
9774
|
+
}, Xi = ({ anchors: e, positions: t, threshold: n }) => {
|
|
9701
9775
|
let r = 0, i = n + 1, a = null;
|
|
9702
9776
|
for (let o of t) for (let t of e) {
|
|
9703
9777
|
let e = Math.abs(t - o);
|
|
@@ -9707,8 +9781,8 @@ var ai = class {
|
|
|
9707
9781
|
delta: r,
|
|
9708
9782
|
guidePosition: a
|
|
9709
9783
|
};
|
|
9710
|
-
},
|
|
9711
|
-
let { left: r, right: i, centerX: a, top: o, bottom: s, centerY: c } = e, l =
|
|
9784
|
+
}, Zi = ({ activeBounds: e, threshold: t, anchors: n }) => {
|
|
9785
|
+
let { left: r, right: i, centerX: a, top: o, bottom: s, centerY: c } = e, l = Xi({
|
|
9712
9786
|
anchors: n.vertical,
|
|
9713
9787
|
positions: [
|
|
9714
9788
|
r,
|
|
@@ -9716,7 +9790,7 @@ var ai = class {
|
|
|
9716
9790
|
i
|
|
9717
9791
|
],
|
|
9718
9792
|
threshold: t
|
|
9719
|
-
}), u =
|
|
9793
|
+
}), u = Xi({
|
|
9720
9794
|
anchors: n.horizontal,
|
|
9721
9795
|
positions: [
|
|
9722
9796
|
o,
|
|
@@ -9736,11 +9810,11 @@ var ai = class {
|
|
|
9736
9810
|
deltaY: u.delta,
|
|
9737
9811
|
guides: d
|
|
9738
9812
|
};
|
|
9739
|
-
},
|
|
9813
|
+
}, Qi = ({ activeBounds: e, candidates: t, threshold: n, patterns: r, previousContext: i = null, switchDistance: a = 0 }) => {
|
|
9740
9814
|
let { centerX: o, top: s, bottom: c, left: l, right: u } = e, d = [];
|
|
9741
9815
|
for (let e of t) {
|
|
9742
9816
|
let { left: t, right: n } = e;
|
|
9743
|
-
|
|
9817
|
+
Di({
|
|
9744
9818
|
firstStart: t,
|
|
9745
9819
|
firstEnd: n,
|
|
9746
9820
|
secondStart: l,
|
|
@@ -9760,22 +9834,22 @@ var ai = class {
|
|
|
9760
9834
|
f.push({
|
|
9761
9835
|
bounds: e,
|
|
9762
9836
|
isActive: !0
|
|
9763
|
-
}),
|
|
9837
|
+
}), Mi({
|
|
9764
9838
|
items: f,
|
|
9765
9839
|
axis: "top"
|
|
9766
9840
|
});
|
|
9767
|
-
let p =
|
|
9841
|
+
let p = Pi({ items: f });
|
|
9768
9842
|
if (p === -1) return {
|
|
9769
9843
|
delta: 0,
|
|
9770
9844
|
guides: [],
|
|
9771
9845
|
context: null
|
|
9772
9846
|
};
|
|
9773
|
-
let m = [], h = c - s, g =
|
|
9847
|
+
let m = [], h = c - s, g = Ni({
|
|
9774
9848
|
items: f,
|
|
9775
9849
|
index: p,
|
|
9776
9850
|
axis: "vertical",
|
|
9777
9851
|
direction: "prev"
|
|
9778
|
-
}), _ =
|
|
9852
|
+
}), _ = Ni({
|
|
9779
9853
|
items: f,
|
|
9780
9854
|
index: p,
|
|
9781
9855
|
axis: "vertical",
|
|
@@ -9784,19 +9858,19 @@ var ai = class {
|
|
|
9784
9858
|
if (v && y) {
|
|
9785
9859
|
let { bounds: e } = v, { bounds: t } = y, { bottom: r } = e, { top: i } = t, a = i - r - h;
|
|
9786
9860
|
if (a >= 0) {
|
|
9787
|
-
let e =
|
|
9861
|
+
let e = ki({
|
|
9788
9862
|
value: a / 2,
|
|
9789
9863
|
step: 1
|
|
9790
9864
|
}), t = s - r, l = i - c, u = Math.abs(t - e), d = Math.abs(l - e);
|
|
9791
9865
|
if (Math.max(u, d) <= n) {
|
|
9792
|
-
let t =
|
|
9866
|
+
let t = Ji({
|
|
9793
9867
|
activeStart: s,
|
|
9794
9868
|
activeEnd: c,
|
|
9795
9869
|
targetGap: e,
|
|
9796
9870
|
beforeEdge: r,
|
|
9797
9871
|
afterEdge: i,
|
|
9798
9872
|
threshold: n,
|
|
9799
|
-
step:
|
|
9873
|
+
step: wi
|
|
9800
9874
|
});
|
|
9801
9875
|
if (t) {
|
|
9802
9876
|
let { delta: e, distance: n, diff: i, activeStart: a, activeEnd: s } = t, c = {
|
|
@@ -9833,16 +9907,16 @@ var ai = class {
|
|
|
9833
9907
|
}
|
|
9834
9908
|
for (let e of r) {
|
|
9835
9909
|
let { axis: t, start: r, end: i, distance: a } = e;
|
|
9836
|
-
if (!
|
|
9910
|
+
if (!Ai({
|
|
9837
9911
|
value: a,
|
|
9838
9912
|
step: .5
|
|
9839
|
-
}) || !
|
|
9913
|
+
}) || !Fi({
|
|
9840
9914
|
patternAxis: t,
|
|
9841
9915
|
activeRangeStart: l,
|
|
9842
9916
|
activeRangeEnd: u,
|
|
9843
9917
|
tolerance: n
|
|
9844
9918
|
})) continue;
|
|
9845
|
-
let d =
|
|
9919
|
+
let d = Ii({
|
|
9846
9920
|
patternStart: r,
|
|
9847
9921
|
patternEnd: i,
|
|
9848
9922
|
activeStart: s,
|
|
@@ -9850,12 +9924,12 @@ var ai = class {
|
|
|
9850
9924
|
});
|
|
9851
9925
|
if (d) {
|
|
9852
9926
|
if (b !== null && S && d === "before" && Math.abs(b - a) <= n) {
|
|
9853
|
-
let e =
|
|
9927
|
+
let e = ki({
|
|
9854
9928
|
value: a - b,
|
|
9855
9929
|
step: 1
|
|
9856
9930
|
}), t = s + e, { bottom: c } = S, l = t - c, u = Math.abs(l - a);
|
|
9857
9931
|
if (u > n) continue;
|
|
9858
|
-
let d =
|
|
9932
|
+
let d = Yi({
|
|
9859
9933
|
currentGap: l,
|
|
9860
9934
|
referenceGap: a
|
|
9861
9935
|
});
|
|
@@ -9879,12 +9953,12 @@ var ai = class {
|
|
|
9879
9953
|
});
|
|
9880
9954
|
}
|
|
9881
9955
|
if (x !== null && C && d === "after" && Math.abs(x - a) <= n) {
|
|
9882
|
-
let e =
|
|
9956
|
+
let e = ki({
|
|
9883
9957
|
value: x - a,
|
|
9884
9958
|
step: 1
|
|
9885
9959
|
}), t = c + e, { top: s } = C, l = s - t, u = Math.abs(l - a);
|
|
9886
9960
|
if (u > n) continue;
|
|
9887
|
-
let d =
|
|
9961
|
+
let d = Yi({
|
|
9888
9962
|
currentGap: l,
|
|
9889
9963
|
referenceGap: a
|
|
9890
9964
|
});
|
|
@@ -9909,16 +9983,16 @@ var ai = class {
|
|
|
9909
9983
|
}
|
|
9910
9984
|
}
|
|
9911
9985
|
}
|
|
9912
|
-
return
|
|
9986
|
+
return qi({
|
|
9913
9987
|
options: m,
|
|
9914
9988
|
previousContext: i,
|
|
9915
9989
|
switchDistance: a
|
|
9916
9990
|
});
|
|
9917
|
-
},
|
|
9991
|
+
}, $i = ({ activeBounds: e, candidates: t, threshold: n, patterns: r, previousContext: i = null, switchDistance: a = 0 }) => {
|
|
9918
9992
|
let { centerY: o, left: s, right: c, top: l, bottom: u } = e, d = [];
|
|
9919
9993
|
for (let e of t) {
|
|
9920
9994
|
let { top: t, bottom: n } = e;
|
|
9921
|
-
|
|
9995
|
+
Di({
|
|
9922
9996
|
firstStart: t,
|
|
9923
9997
|
firstEnd: n,
|
|
9924
9998
|
secondStart: l,
|
|
@@ -9938,22 +10012,22 @@ var ai = class {
|
|
|
9938
10012
|
f.push({
|
|
9939
10013
|
bounds: e,
|
|
9940
10014
|
isActive: !0
|
|
9941
|
-
}),
|
|
10015
|
+
}), Mi({
|
|
9942
10016
|
items: f,
|
|
9943
10017
|
axis: "left"
|
|
9944
10018
|
});
|
|
9945
|
-
let p =
|
|
10019
|
+
let p = Pi({ items: f });
|
|
9946
10020
|
if (p === -1) return {
|
|
9947
10021
|
delta: 0,
|
|
9948
10022
|
guides: [],
|
|
9949
10023
|
context: null
|
|
9950
10024
|
};
|
|
9951
|
-
let m = [], h = c - s, g =
|
|
10025
|
+
let m = [], h = c - s, g = Ni({
|
|
9952
10026
|
items: f,
|
|
9953
10027
|
index: p,
|
|
9954
10028
|
axis: "horizontal",
|
|
9955
10029
|
direction: "prev"
|
|
9956
|
-
}), _ =
|
|
10030
|
+
}), _ = Ni({
|
|
9957
10031
|
items: f,
|
|
9958
10032
|
index: p,
|
|
9959
10033
|
axis: "horizontal",
|
|
@@ -9962,19 +10036,19 @@ var ai = class {
|
|
|
9962
10036
|
if (v && y) {
|
|
9963
10037
|
let { bounds: e } = v, { bounds: t } = y, { right: r } = e, { left: i } = t, a = i - r - h;
|
|
9964
10038
|
if (a >= 0) {
|
|
9965
|
-
let e =
|
|
10039
|
+
let e = ki({
|
|
9966
10040
|
value: a / 2,
|
|
9967
10041
|
step: 1
|
|
9968
10042
|
}), t = s - r, l = i - c, u = Math.abs(t - e), d = Math.abs(l - e);
|
|
9969
10043
|
if (Math.max(u, d) <= n) {
|
|
9970
|
-
let t =
|
|
10044
|
+
let t = Ji({
|
|
9971
10045
|
activeStart: s,
|
|
9972
10046
|
activeEnd: c,
|
|
9973
10047
|
targetGap: e,
|
|
9974
10048
|
beforeEdge: r,
|
|
9975
10049
|
afterEdge: i,
|
|
9976
10050
|
threshold: n,
|
|
9977
|
-
step:
|
|
10051
|
+
step: wi
|
|
9978
10052
|
});
|
|
9979
10053
|
if (t) {
|
|
9980
10054
|
let { delta: e, distance: n, diff: i, activeStart: a, activeEnd: s } = t, c = {
|
|
@@ -10011,16 +10085,16 @@ var ai = class {
|
|
|
10011
10085
|
}
|
|
10012
10086
|
for (let e of r) {
|
|
10013
10087
|
let { axis: t, start: r, end: i, distance: a } = e;
|
|
10014
|
-
if (!
|
|
10088
|
+
if (!Ai({
|
|
10015
10089
|
value: a,
|
|
10016
10090
|
step: .5
|
|
10017
|
-
}) || !
|
|
10091
|
+
}) || !Fi({
|
|
10018
10092
|
patternAxis: t,
|
|
10019
10093
|
activeRangeStart: l,
|
|
10020
10094
|
activeRangeEnd: u,
|
|
10021
10095
|
tolerance: n
|
|
10022
10096
|
})) continue;
|
|
10023
|
-
let d =
|
|
10097
|
+
let d = Ii({
|
|
10024
10098
|
patternStart: r,
|
|
10025
10099
|
patternEnd: i,
|
|
10026
10100
|
activeStart: s,
|
|
@@ -10028,12 +10102,12 @@ var ai = class {
|
|
|
10028
10102
|
});
|
|
10029
10103
|
if (d) {
|
|
10030
10104
|
if (b !== null && S && d === "before" && Math.abs(b - a) <= n) {
|
|
10031
|
-
let e =
|
|
10105
|
+
let e = ki({
|
|
10032
10106
|
value: a - b,
|
|
10033
10107
|
step: 1
|
|
10034
10108
|
}), t = s + e, { right: c } = S, l = t - c, u = Math.abs(l - a);
|
|
10035
10109
|
if (u > n) continue;
|
|
10036
|
-
let d =
|
|
10110
|
+
let d = Yi({
|
|
10037
10111
|
currentGap: l,
|
|
10038
10112
|
referenceGap: a
|
|
10039
10113
|
});
|
|
@@ -10057,12 +10131,12 @@ var ai = class {
|
|
|
10057
10131
|
});
|
|
10058
10132
|
}
|
|
10059
10133
|
if (x !== null && C && d === "after" && Math.abs(x - a) <= n) {
|
|
10060
|
-
let e =
|
|
10134
|
+
let e = ki({
|
|
10061
10135
|
value: x - a,
|
|
10062
10136
|
step: 1
|
|
10063
10137
|
}), t = c + e, { left: s } = C, l = s - t, u = Math.abs(l - a);
|
|
10064
10138
|
if (u > n) continue;
|
|
10065
|
-
let d =
|
|
10139
|
+
let d = Yi({
|
|
10066
10140
|
currentGap: l,
|
|
10067
10141
|
referenceGap: a
|
|
10068
10142
|
});
|
|
@@ -10087,20 +10161,20 @@ var ai = class {
|
|
|
10087
10161
|
}
|
|
10088
10162
|
}
|
|
10089
10163
|
}
|
|
10090
|
-
return
|
|
10164
|
+
return qi({
|
|
10091
10165
|
options: m,
|
|
10092
10166
|
previousContext: i,
|
|
10093
10167
|
switchDistance: a
|
|
10094
10168
|
});
|
|
10095
|
-
},
|
|
10096
|
-
let { vertical: o = null, horizontal: s = null } = i ?? {}, c =
|
|
10169
|
+
}, ea = ({ activeBounds: e, candidates: t, threshold: n, spacingPatterns: r, previousContexts: i, switchDistance: a = 0 }) => {
|
|
10170
|
+
let { vertical: o = null, horizontal: s = null } = i ?? {}, c = Qi({
|
|
10097
10171
|
activeBounds: e,
|
|
10098
10172
|
candidates: t,
|
|
10099
10173
|
threshold: n,
|
|
10100
10174
|
patterns: r.vertical,
|
|
10101
10175
|
previousContext: o,
|
|
10102
10176
|
switchDistance: a
|
|
10103
|
-
}), l =
|
|
10177
|
+
}), l = $i({
|
|
10104
10178
|
activeBounds: e,
|
|
10105
10179
|
candidates: t,
|
|
10106
10180
|
threshold: n,
|
|
@@ -10119,14 +10193,14 @@ var ai = class {
|
|
|
10119
10193
|
horizontal: l.context
|
|
10120
10194
|
}
|
|
10121
10195
|
};
|
|
10122
|
-
},
|
|
10196
|
+
}, ta = ({ context: e, x: t, y: n, width: r, height: i, radius: a }) => {
|
|
10123
10197
|
let o = Math.min(a, r / 2, i / 2);
|
|
10124
10198
|
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
|
-
},
|
|
10199
|
+
}, 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
10200
|
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
10201
|
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
10202
|
let S = e.measureText(a).width + _ * 2, C = g + _ * 2, w = b - S / 2, T = x - C / 2;
|
|
10129
|
-
e.beginPath(),
|
|
10203
|
+
e.beginPath(), ta({
|
|
10130
10204
|
context: e,
|
|
10131
10205
|
x: w,
|
|
10132
10206
|
y: T,
|
|
@@ -10134,11 +10208,11 @@ var ai = class {
|
|
|
10134
10208
|
height: C,
|
|
10135
10209
|
radius: v
|
|
10136
10210
|
}), 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 =
|
|
10211
|
+
}, ra = ({ context: e, guide: t, zoom: n }) => {
|
|
10212
|
+
let { type: r, axis: i, refStart: a, refEnd: o, activeStart: s, activeEnd: c, distance: l } = t, u = Ti({ distance: l }).toString();
|
|
10139
10213
|
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
|
-
|
|
10214
|
+
let d = Ci;
|
|
10215
|
+
na({
|
|
10142
10216
|
context: e,
|
|
10143
10217
|
type: r,
|
|
10144
10218
|
axis: i,
|
|
@@ -10148,7 +10222,7 @@ var ai = class {
|
|
|
10148
10222
|
zoom: n,
|
|
10149
10223
|
color: d,
|
|
10150
10224
|
lineWidth: 1
|
|
10151
|
-
}),
|
|
10225
|
+
}), na({
|
|
10152
10226
|
context: e,
|
|
10153
10227
|
type: r,
|
|
10154
10228
|
axis: i,
|
|
@@ -10159,10 +10233,10 @@ var ai = class {
|
|
|
10159
10233
|
color: d,
|
|
10160
10234
|
lineWidth: 1
|
|
10161
10235
|
});
|
|
10162
|
-
},
|
|
10236
|
+
}, ia = ({ anchors: e, bounds: t }) => {
|
|
10163
10237
|
let { left: n, right: r, centerX: i, top: a, bottom: o, centerY: s } = t;
|
|
10164
10238
|
e.vertical.push(n, i, r), e.horizontal.push(a, s, o);
|
|
10165
|
-
},
|
|
10239
|
+
}, aa = ({ bounds: e, type: t, primaryStart: n, primaryEnd: r }) => {
|
|
10166
10240
|
let i = [], a = n === "top" ? "left" : "top", o = r === "bottom" ? "right" : "bottom", s = [...e].sort((e, t) => e[n] - t[n]);
|
|
10167
10241
|
for (let e = 0; e < s.length; e += 1) {
|
|
10168
10242
|
let c = s[e], l = null, u = Infinity;
|
|
@@ -10183,35 +10257,35 @@ var ai = class {
|
|
|
10183
10257
|
});
|
|
10184
10258
|
}
|
|
10185
10259
|
return i;
|
|
10186
|
-
},
|
|
10187
|
-
vertical:
|
|
10260
|
+
}, oa = ({ bounds: e }) => ({
|
|
10261
|
+
vertical: aa({
|
|
10188
10262
|
bounds: e,
|
|
10189
10263
|
axis: "centerX",
|
|
10190
10264
|
type: "vertical",
|
|
10191
10265
|
primaryStart: "top",
|
|
10192
10266
|
primaryEnd: "bottom"
|
|
10193
10267
|
}),
|
|
10194
|
-
horizontal:
|
|
10268
|
+
horizontal: aa({
|
|
10195
10269
|
bounds: e,
|
|
10196
10270
|
axis: "centerY",
|
|
10197
10271
|
type: "horizontal",
|
|
10198
10272
|
primaryStart: "left",
|
|
10199
10273
|
primaryEnd: "right"
|
|
10200
10274
|
})
|
|
10201
|
-
}),
|
|
10275
|
+
}), sa = [
|
|
10202
10276
|
"montage-area",
|
|
10203
10277
|
"background",
|
|
10204
10278
|
"interaction-blocker"
|
|
10205
|
-
],
|
|
10279
|
+
], ca = ({ activeObject: t }) => {
|
|
10206
10280
|
let n = /* @__PURE__ */ new Set();
|
|
10207
10281
|
return t ? (n.add(t), t instanceof e && t.getObjects().forEach((e) => n.add(e)), n) : n;
|
|
10208
|
-
},
|
|
10282
|
+
}, la = ({ object: e, excluded: t, ignoredIds: n = sa }) => {
|
|
10209
10283
|
if (t.has(e)) return !0;
|
|
10210
10284
|
let { visible: r = !0 } = e;
|
|
10211
10285
|
if (!r) return !0;
|
|
10212
10286
|
let { id: i } = e;
|
|
10213
10287
|
return !!(i && n.includes(i));
|
|
10214
|
-
},
|
|
10288
|
+
}, ua = class e {
|
|
10215
10289
|
constructor({ editor: e }) {
|
|
10216
10290
|
this.anchors = {
|
|
10217
10291
|
vertical: [],
|
|
@@ -10264,7 +10338,7 @@ var ai = class {
|
|
|
10264
10338
|
this._clearSpacingContexts(), this._clearGuides();
|
|
10265
10339
|
return;
|
|
10266
10340
|
}
|
|
10267
|
-
let { canvas: o } = this, s = o.getZoom() || 1, c = 5 / s, { deltaX: l, deltaY: u } =
|
|
10341
|
+
let { canvas: o } = this, s = o.getZoom() || 1, c = 5 / s, { deltaX: l, deltaY: u } = Zi({
|
|
10268
10342
|
activeBounds: a,
|
|
10269
10343
|
threshold: c,
|
|
10270
10344
|
anchors: this.anchors
|
|
@@ -10276,7 +10350,7 @@ var ai = class {
|
|
|
10276
10350
|
top: t + u
|
|
10277
10351
|
}), n.setCoords(), a = Ye({ object: n }) ?? a;
|
|
10278
10352
|
}
|
|
10279
|
-
let d = this._resolveCurrentTargetBounds({ activeObject: n }), f = this.spacingContexts.vertical || this.spacingContexts.horizontal ? 10 / s : c, p =
|
|
10353
|
+
let d = this._resolveCurrentTargetBounds({ activeObject: n }), f = this.spacingContexts.vertical || this.spacingContexts.horizontal ? 10 / s : c, p = ea({
|
|
10280
10354
|
activeBounds: a,
|
|
10281
10355
|
candidates: d,
|
|
10282
10356
|
threshold: f,
|
|
@@ -10297,11 +10371,11 @@ var ai = class {
|
|
|
10297
10371
|
target: n,
|
|
10298
10372
|
transform: i
|
|
10299
10373
|
});
|
|
10300
|
-
let h = Ye({ object: n }) ?? a, g =
|
|
10374
|
+
let h = Ye({ object: n }) ?? a, g = Zi({
|
|
10301
10375
|
activeBounds: h,
|
|
10302
10376
|
threshold: c,
|
|
10303
10377
|
anchors: this.anchors
|
|
10304
|
-
}), _ =
|
|
10378
|
+
}), _ = ea({
|
|
10305
10379
|
activeBounds: h,
|
|
10306
10380
|
candidates: d,
|
|
10307
10381
|
threshold: c,
|
|
@@ -10532,9 +10606,9 @@ var ai = class {
|
|
|
10532
10606
|
let { canvas: e, guideBounds: t } = this, n = e.getSelectionContext();
|
|
10533
10607
|
if (!n) return;
|
|
10534
10608
|
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 =
|
|
10609
|
+
n.save(), Array.isArray(s) && n.transform(...s), n.lineWidth = 1 / c, n.strokeStyle = Ci, n.setLineDash([4, 4]);
|
|
10536
10610
|
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)
|
|
10611
|
+
for (let e of this.activeSpacingGuides) ra({
|
|
10538
10612
|
context: n,
|
|
10539
10613
|
guide: e,
|
|
10540
10614
|
zoom: c
|
|
@@ -10745,14 +10819,14 @@ var ai = class {
|
|
|
10745
10819
|
}, r = [];
|
|
10746
10820
|
for (let e of t) {
|
|
10747
10821
|
let t = Ye({ object: e });
|
|
10748
|
-
t && (
|
|
10822
|
+
t && (ia({
|
|
10749
10823
|
anchors: n,
|
|
10750
10824
|
bounds: t
|
|
10751
10825
|
}), r.push(t));
|
|
10752
10826
|
}
|
|
10753
10827
|
let { montageArea: i } = this.editor, a = Ye({ object: i });
|
|
10754
10828
|
if (a) {
|
|
10755
|
-
|
|
10829
|
+
ia({
|
|
10756
10830
|
anchors: n,
|
|
10757
10831
|
bounds: a
|
|
10758
10832
|
});
|
|
@@ -10764,12 +10838,12 @@ var ai = class {
|
|
|
10764
10838
|
bottom: i
|
|
10765
10839
|
};
|
|
10766
10840
|
} else this.guideBounds = this._calculateViewportBounds();
|
|
10767
|
-
this.anchors = n, this.spacingPatterns =
|
|
10841
|
+
this.anchors = n, this.spacingPatterns = oa({ bounds: r }), this.cachedTargetBounds = r;
|
|
10768
10842
|
}
|
|
10769
10843
|
_collectTargets({ activeObject: e }) {
|
|
10770
|
-
let t =
|
|
10844
|
+
let t = ca({ activeObject: e }), n = [];
|
|
10771
10845
|
return this.canvas.forEachObject((e) => {
|
|
10772
|
-
|
|
10846
|
+
la({
|
|
10773
10847
|
object: e,
|
|
10774
10848
|
excluded: t
|
|
10775
10849
|
}) || n.push(e);
|
|
@@ -10792,7 +10866,7 @@ var ai = class {
|
|
|
10792
10866
|
bottom: (r - s) / a
|
|
10793
10867
|
};
|
|
10794
10868
|
}
|
|
10795
|
-
},
|
|
10869
|
+
}, da = "#3D8BF4", fa = class e {
|
|
10796
10870
|
constructor({ editor: e }) {
|
|
10797
10871
|
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
10872
|
}
|
|
@@ -10885,8 +10959,8 @@ var ai = class {
|
|
|
10885
10959
|
this.isTargetMontageArea = l, this.activeGuides = d, this._hideToolbar(), n.requestRenderAll();
|
|
10886
10960
|
}
|
|
10887
10961
|
static _resolveTarget({ event: e, activeObject: t }) {
|
|
10888
|
-
let { target: n } = e, r =
|
|
10889
|
-
return n && !
|
|
10962
|
+
let { target: n } = e, r = ca({ activeObject: t });
|
|
10963
|
+
return n && !la({
|
|
10890
10964
|
object: n,
|
|
10891
10965
|
excluded: r
|
|
10892
10966
|
}) ? n : null;
|
|
@@ -11003,18 +11077,18 @@ var ai = class {
|
|
|
11003
11077
|
let { canvas: e } = this, t = e.getSelectionContext();
|
|
11004
11078
|
if (!t) return;
|
|
11005
11079
|
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 =
|
|
11080
|
+
t.save(), Array.isArray(n) && t.transform(...n), t.lineWidth = 1 / r, t.strokeStyle = da, t.setLineDash([]);
|
|
11007
11081
|
for (let e of this.activeGuides) {
|
|
11008
11082
|
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(),
|
|
11083
|
+
t.beginPath(), n === "vertical" ? (t.moveTo(i, a), t.lineTo(i, c)) : (t.moveTo(a, i), t.lineTo(c, i)), t.stroke(), na({
|
|
11010
11084
|
context: t,
|
|
11011
11085
|
type: n,
|
|
11012
11086
|
axis: i,
|
|
11013
11087
|
start: a,
|
|
11014
11088
|
end: c,
|
|
11015
|
-
text:
|
|
11089
|
+
text: Ti({ distance: l }).toString(),
|
|
11016
11090
|
zoom: r,
|
|
11017
|
-
color:
|
|
11091
|
+
color: da,
|
|
11018
11092
|
lineWidth: 1,
|
|
11019
11093
|
offsetAlongAxis: d,
|
|
11020
11094
|
offsetPerpendicular: 0
|
|
@@ -11032,13 +11106,13 @@ var ai = class {
|
|
|
11032
11106
|
let { toolbar: e } = this.editor;
|
|
11033
11107
|
e?.showAfterTemporary?.(), this.isToolbarHidden = !1;
|
|
11034
11108
|
}
|
|
11035
|
-
},
|
|
11109
|
+
}, pa = class e {
|
|
11036
11110
|
constructor(e, t) {
|
|
11037
11111
|
this.options = t, this.containerId = e, this.editorId = `${e}-${D()}`, this.init();
|
|
11038
11112
|
}
|
|
11039
11113
|
async init() {
|
|
11040
11114
|
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
|
|
11115
|
+
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
11116
|
editor: this,
|
|
11043
11117
|
options: this.options
|
|
11044
11118
|
}), 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 +11220,7 @@ var ai = class {
|
|
|
11146
11220
|
"U+A640-A69F",
|
|
11147
11221
|
"U+FE2E-FE2F",
|
|
11148
11222
|
"U+2116"
|
|
11149
|
-
].join(", "),
|
|
11223
|
+
].join(", "), ma = {
|
|
11150
11224
|
preserveObjectStacking: !0,
|
|
11151
11225
|
controlsAboveOverlay: !0,
|
|
11152
11226
|
centeredRotation: !0,
|
|
@@ -12000,20 +12074,20 @@ var ai = class {
|
|
|
12000
12074
|
};
|
|
12001
12075
|
//#endregion
|
|
12002
12076
|
//#region src/main.ts
|
|
12003
|
-
function
|
|
12077
|
+
function ha(e, t = {}) {
|
|
12004
12078
|
let n = {
|
|
12005
|
-
...
|
|
12079
|
+
...ma,
|
|
12006
12080
|
...t
|
|
12007
12081
|
}, r = document.getElementById(e);
|
|
12008
12082
|
if (!r) return Promise.reject(/* @__PURE__ */ Error(`Контейнер с ID "${e}" не найден.`));
|
|
12009
12083
|
let i = document.createElement("canvas");
|
|
12010
12084
|
return i.id = `${e}-canvas`, r.appendChild(i), n.editorContainer = r, new Promise((t) => {
|
|
12011
12085
|
n._onReadyCallback = t;
|
|
12012
|
-
let r = new
|
|
12086
|
+
let r = new pa(i.id, n);
|
|
12013
12087
|
window[e] = r;
|
|
12014
12088
|
});
|
|
12015
12089
|
}
|
|
12016
12090
|
//#endregion
|
|
12017
|
-
export {
|
|
12091
|
+
export { ha as default };
|
|
12018
12092
|
|
|
12019
12093
|
//# sourceMappingURL=main.js.map
|