@snowcone-app/canvas 0.28.0 → 0.29.0
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/{CanvasRenderer-B_3GISlW.js → CanvasRenderer-_lFoIoz5.js} +1083 -1071
- package/dist/CanvasRenderer-_lFoIoz5.js.map +1 -0
- package/dist/{CanvasStateV1-kL09wsAn.js → CanvasStateV1-BMxr6xb8.js} +7 -4
- package/dist/{CanvasStateV1-kL09wsAn.js.map → CanvasStateV1-BMxr6xb8.js.map} +1 -1
- package/dist/{ContextualToolbars-C69oYLdw.js → ContextualToolbars-0jWvnQgp.js} +1718 -1656
- package/dist/ContextualToolbars-0jWvnQgp.js.map +1 -0
- package/dist/{EditorCanvasImpl-CrI9C_xM.js → EditorCanvasImpl-BNz8TPFs.js} +8 -8
- package/dist/{EditorCanvasImpl-CrI9C_xM.js.map → EditorCanvasImpl-BNz8TPFs.js.map} +1 -1
- package/dist/{ExportManager-J2xK86uq.js → ExportManager-B8Td7uR5.js} +1043 -964
- package/dist/ExportManager-B8Td7uR5.js.map +1 -0
- package/dist/{FontAnalyzer-PE6nysqE.js → FontAnalyzer-D4Sg-P6_.js} +1234 -1172
- package/dist/FontAnalyzer-D4Sg-P6_.js.map +1 -0
- package/dist/{ImagePanel-CmQCxBGm.js → ImagePanel-CN2Bu3hf.js} +6 -6
- package/dist/{ImagePanel-CmQCxBGm.js.map → ImagePanel-CN2Bu3hf.js.map} +1 -1
- package/dist/{SnowconeCanvas-CQiFVR0X.js → SnowconeCanvas-CR_LdRFP.js} +27 -27
- package/dist/{SnowconeCanvas-CQiFVR0X.js.map → SnowconeCanvas-CR_LdRFP.js.map} +1 -1
- package/dist/{UnifiedFontService-BJzoqfBF.js → UnifiedFontService-CgYnYTj7.js} +7 -7
- package/dist/{UnifiedFontService-BJzoqfBF.js.map → UnifiedFontService-CgYnYTj7.js.map} +1 -1
- package/dist/advanced.mjs +14 -14
- package/dist/components/toolbars/SecondaryPanels.d.ts +11 -0
- package/dist/core/TextElement.d.ts +13 -0
- package/dist/core/TextMetrics.d.ts +17 -3
- package/dist/core/rich-text-layout.d.ts +2 -0
- package/dist/core/text-spacing.d.ts +74 -0
- package/dist/{custom-icons-BWiUGqD6.js → custom-icons-B5TRC1Ed.js} +2 -2
- package/dist/{custom-icons-BWiUGqD6.js.map → custom-icons-B5TRC1Ed.js.map} +1 -1
- package/dist/{design-builder-bquxIHct.js → design-builder-COj0zkxu.js} +2 -2
- package/dist/{design-builder-bquxIHct.js.map → design-builder-COj0zkxu.js.map} +1 -1
- package/dist/{editorErrors-8uDRMhow.js → editorErrors-CCvoKj_P.js} +2 -2
- package/dist/{editorErrors-8uDRMhow.js.map → editorErrors-CCvoKj_P.js.map} +1 -1
- package/dist/{embed-L3oRIgsj.js → embed-BTRtoktw.js} +10 -10
- package/dist/{embed-L3oRIgsj.js.map → embed-BTRtoktw.js.map} +1 -1
- package/dist/embed.mjs +6 -6
- package/dist/{guards-BlbhM5MX.js → guards-uQtEQJbs.js} +2 -2
- package/dist/{guards-BlbhM5MX.js.map → guards-uQtEQJbs.js.map} +1 -1
- package/dist/hooks/useTextToolbar.d.ts +8 -0
- package/dist/index.mjs +8 -8
- package/dist/internals.mjs +5 -5
- package/dist/rendering/renderer-types.d.ts +4 -0
- package/dist/rendering/rich-text-renderer.d.ts +4 -0
- package/dist/rendering/text-renderer.d.ts +4 -1
- package/dist/state/CanvasStateV1.d.ts +3 -0
- package/dist/{template-fields-ai7vnW8g.js → template-fields-BLRp84Ny.js} +6 -6
- package/dist/{template-fields-ai7vnW8g.js.map → template-fields-BLRp84Ny.js.map} +1 -1
- package/dist/testing.mjs +4 -4
- package/dist/types/index.d.ts +26 -0
- package/dist/{usePieceGuideBundle-CMe5br2a.js → usePieceGuideBundle-CTQszfKA.js} +2 -2
- package/dist/{usePieceGuideBundle-CMe5br2a.js.map → usePieceGuideBundle-CTQszfKA.js.map} +1 -1
- package/dist/utils/featureApplied.d.ts +6 -0
- package/dist/{validation-B8kIYutI.js → validation-eCebhplp.js} +1940 -1935
- package/dist/validation-eCebhplp.js.map +1 -0
- package/dist/workers/export-worker.bundle.string.d.ts +1 -1
- package/example/package.json +1 -1
- package/package.json +1 -1
- package/dist/CanvasRenderer-B_3GISlW.js.map +0 -1
- package/dist/ContextualToolbars-C69oYLdw.js.map +0 -1
- package/dist/ExportManager-J2xK86uq.js.map +0 -1
- package/dist/FontAnalyzer-PE6nysqE.js.map +0 -1
- package/dist/validation-B8kIYutI.js.map +0 -1
|
@@ -1,122 +1,122 @@
|
|
|
1
|
-
function
|
|
1
|
+
function se(r) {
|
|
2
2
|
return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r;
|
|
3
3
|
}
|
|
4
|
-
var
|
|
4
|
+
var Ht = { exports: {} }, O = Ht.exports = {}, X, Y;
|
|
5
5
|
function xt() {
|
|
6
6
|
throw new Error("setTimeout has not been defined");
|
|
7
7
|
}
|
|
8
|
-
function
|
|
8
|
+
function St() {
|
|
9
9
|
throw new Error("clearTimeout has not been defined");
|
|
10
10
|
}
|
|
11
11
|
(function() {
|
|
12
12
|
try {
|
|
13
|
-
typeof setTimeout == "function" ?
|
|
13
|
+
typeof setTimeout == "function" ? X = setTimeout : X = xt;
|
|
14
14
|
} catch {
|
|
15
|
-
|
|
15
|
+
X = xt;
|
|
16
16
|
}
|
|
17
17
|
try {
|
|
18
|
-
typeof clearTimeout == "function" ?
|
|
18
|
+
typeof clearTimeout == "function" ? Y = clearTimeout : Y = St;
|
|
19
19
|
} catch {
|
|
20
|
-
|
|
20
|
+
Y = St;
|
|
21
21
|
}
|
|
22
22
|
})();
|
|
23
|
-
function
|
|
24
|
-
if (
|
|
23
|
+
function Pt(r) {
|
|
24
|
+
if (X === setTimeout)
|
|
25
25
|
return setTimeout(r, 0);
|
|
26
|
-
if ((
|
|
27
|
-
return
|
|
26
|
+
if ((X === xt || !X) && setTimeout)
|
|
27
|
+
return X = setTimeout, setTimeout(r, 0);
|
|
28
28
|
try {
|
|
29
|
-
return
|
|
29
|
+
return X(r, 0);
|
|
30
30
|
} catch {
|
|
31
31
|
try {
|
|
32
|
-
return
|
|
32
|
+
return X.call(null, r, 0);
|
|
33
33
|
} catch {
|
|
34
|
-
return
|
|
34
|
+
return X.call(this, r, 0);
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
function
|
|
39
|
-
if (
|
|
38
|
+
function oe(r) {
|
|
39
|
+
if (Y === clearTimeout)
|
|
40
40
|
return clearTimeout(r);
|
|
41
|
-
if ((
|
|
42
|
-
return
|
|
41
|
+
if ((Y === St || !Y) && clearTimeout)
|
|
42
|
+
return Y = clearTimeout, clearTimeout(r);
|
|
43
43
|
try {
|
|
44
|
-
return
|
|
44
|
+
return Y(r);
|
|
45
45
|
} catch {
|
|
46
46
|
try {
|
|
47
|
-
return
|
|
47
|
+
return Y.call(null, r);
|
|
48
48
|
} catch {
|
|
49
|
-
return
|
|
49
|
+
return Y.call(this, r);
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
-
var
|
|
54
|
-
function
|
|
55
|
-
!K || !V || (K = !1, V.length ?
|
|
53
|
+
var _ = [], K = !1, V, dt = -1;
|
|
54
|
+
function re() {
|
|
55
|
+
!K || !V || (K = !1, V.length ? _ = V.concat(_) : dt = -1, _.length && Lt());
|
|
56
56
|
}
|
|
57
|
-
function
|
|
57
|
+
function Lt() {
|
|
58
58
|
if (!K) {
|
|
59
|
-
var r =
|
|
59
|
+
var r = Pt(re);
|
|
60
60
|
K = !0;
|
|
61
|
-
for (var t =
|
|
62
|
-
for (V =
|
|
61
|
+
for (var t = _.length; t; ) {
|
|
62
|
+
for (V = _, _ = []; ++dt < t; )
|
|
63
63
|
V && V[dt].run();
|
|
64
|
-
dt = -1, t =
|
|
64
|
+
dt = -1, t = _.length;
|
|
65
65
|
}
|
|
66
|
-
V = null, K = !1,
|
|
66
|
+
V = null, K = !1, oe(r);
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
|
-
|
|
69
|
+
O.nextTick = function(r) {
|
|
70
70
|
var t = new Array(arguments.length - 1);
|
|
71
71
|
if (arguments.length > 1)
|
|
72
72
|
for (var e = 1; e < arguments.length; e++)
|
|
73
73
|
t[e - 1] = arguments[e];
|
|
74
|
-
|
|
74
|
+
_.push(new Wt(r, t)), _.length === 1 && !K && Pt(Lt);
|
|
75
75
|
};
|
|
76
|
-
function
|
|
76
|
+
function Wt(r, t) {
|
|
77
77
|
this.fun = r, this.array = t;
|
|
78
78
|
}
|
|
79
|
-
|
|
79
|
+
Wt.prototype.run = function() {
|
|
80
80
|
this.fun.apply(null, this.array);
|
|
81
81
|
};
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
function
|
|
82
|
+
O.title = "browser";
|
|
83
|
+
O.browser = !0;
|
|
84
|
+
O.env = {};
|
|
85
|
+
O.argv = [];
|
|
86
|
+
O.version = "";
|
|
87
|
+
O.versions = {};
|
|
88
|
+
function N() {
|
|
89
89
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
90
|
+
O.on = N;
|
|
91
|
+
O.addListener = N;
|
|
92
|
+
O.once = N;
|
|
93
|
+
O.off = N;
|
|
94
|
+
O.removeListener = N;
|
|
95
|
+
O.removeAllListeners = N;
|
|
96
|
+
O.emit = N;
|
|
97
|
+
O.prependListener = N;
|
|
98
|
+
O.prependOnceListener = N;
|
|
99
|
+
O.listeners = function(r) {
|
|
100
100
|
return [];
|
|
101
101
|
};
|
|
102
|
-
|
|
102
|
+
O.binding = function(r) {
|
|
103
103
|
throw new Error("process.binding is not supported");
|
|
104
104
|
};
|
|
105
|
-
|
|
105
|
+
O.cwd = function() {
|
|
106
106
|
return "/";
|
|
107
107
|
};
|
|
108
|
-
|
|
108
|
+
O.chdir = function(r) {
|
|
109
109
|
throw new Error("process.chdir is not supported");
|
|
110
110
|
};
|
|
111
|
-
|
|
111
|
+
O.umask = function() {
|
|
112
112
|
return 0;
|
|
113
113
|
};
|
|
114
|
-
var
|
|
115
|
-
const
|
|
116
|
-
let
|
|
114
|
+
var ne = Ht.exports;
|
|
115
|
+
const It = /* @__PURE__ */ se(ne);
|
|
116
|
+
let kt = 1;
|
|
117
117
|
class nt {
|
|
118
118
|
constructor(t = {}) {
|
|
119
|
-
this.transformType = "artboard", this.id = t.id || `artboard-${
|
|
119
|
+
this.transformType = "artboard", this.id = t.id || `artboard-${kt++}`, this.name = t.name || `Artboard ${kt}`, this.x = t.x !== void 0 ? t.x : 0, this.y = t.y !== void 0 ? t.y : 0, this.width = t.width || 1920, this.height = t.height || 1080, this.backgroundColor = t.backgroundColor || "#ffffff", t.backgroundType ? this.backgroundType = t.backgroundType : t.backgroundColor === "transparent" ? this.backgroundType = "transparent" : t.backgroundTexture ? this.backgroundType = "texture" : this.backgroundType = "color", this.backgroundTexture = t.backgroundTexture, this.exportBackground = t.exportBackground ?? !1, this.clipShape = t.clipShape, this.previewBackgroundColor = t.previewBackgroundColor, this.role = t.role, this.distressTexture = t.distressTexture ? { ...t.distressTexture } : void 0, this.imageMask = t.imageMask ? { ...t.imageMask } : void 0, this.elementIds = new Set(t.elementIds || []);
|
|
120
120
|
}
|
|
121
121
|
/**
|
|
122
122
|
* Get bounding box of the artboard
|
|
@@ -191,8 +191,8 @@ class nt {
|
|
|
191
191
|
* Test if a point hits the artboard border (for selection)
|
|
192
192
|
* Returns true if point is near the border (within tolerance)
|
|
193
193
|
*/
|
|
194
|
-
hitTestBorder(t, e,
|
|
195
|
-
const s = t >= this.x -
|
|
194
|
+
hitTestBorder(t, e, i = 5) {
|
|
195
|
+
const s = t >= this.x - i && t <= this.x + this.width + i, o = e >= this.y - i && e <= this.y + this.height + i, a = Math.abs(t - this.x) <= i && o, n = Math.abs(t - (this.x + this.width)) <= i && o, h = Math.abs(e - this.y) <= i && s, l = Math.abs(e - (this.y + this.height)) <= i && s;
|
|
196
196
|
return a || n || h || l;
|
|
197
197
|
}
|
|
198
198
|
/**
|
|
@@ -274,7 +274,7 @@ class nt {
|
|
|
274
274
|
this.x = t, this.y = e;
|
|
275
275
|
}
|
|
276
276
|
}
|
|
277
|
-
class
|
|
277
|
+
class ti {
|
|
278
278
|
constructor() {
|
|
279
279
|
this.artboards = /* @__PURE__ */ new Map(), this.elementToArtboard = /* @__PURE__ */ new Map(), this.activeArtboardId = null;
|
|
280
280
|
}
|
|
@@ -301,14 +301,14 @@ class qe {
|
|
|
301
301
|
const e = this.artboards.get(t);
|
|
302
302
|
if (!e)
|
|
303
303
|
return [];
|
|
304
|
-
const
|
|
305
|
-
if (
|
|
304
|
+
const i = e.getElementIds();
|
|
305
|
+
if (i.forEach((s) => {
|
|
306
306
|
this.elementToArtboard.delete(s);
|
|
307
307
|
}), this.artboards.delete(t), this.activeArtboardId === t) {
|
|
308
308
|
const s = Array.from(this.artboards.keys());
|
|
309
309
|
this.activeArtboardId = s.length > 0 ? s[0] : null;
|
|
310
310
|
}
|
|
311
|
-
return
|
|
311
|
+
return i;
|
|
312
312
|
}
|
|
313
313
|
/**
|
|
314
314
|
* Get an artboard by ID
|
|
@@ -350,15 +350,15 @@ class qe {
|
|
|
350
350
|
* Add an element to an artboard
|
|
351
351
|
*/
|
|
352
352
|
addElementToArtboard(t, e) {
|
|
353
|
-
const
|
|
354
|
-
if (!
|
|
353
|
+
const i = this.artboards.get(e);
|
|
354
|
+
if (!i)
|
|
355
355
|
return !1;
|
|
356
356
|
const s = this.elementToArtboard.get(t);
|
|
357
357
|
if (s) {
|
|
358
|
-
const
|
|
359
|
-
|
|
358
|
+
const o = this.artboards.get(s);
|
|
359
|
+
o == null || o.removeElementId(t);
|
|
360
360
|
}
|
|
361
|
-
return
|
|
361
|
+
return i.addElementId(t), this.elementToArtboard.set(t, e), !0;
|
|
362
362
|
}
|
|
363
363
|
/**
|
|
364
364
|
* Remove an element from its artboard
|
|
@@ -366,8 +366,8 @@ class qe {
|
|
|
366
366
|
removeElementFromArtboard(t) {
|
|
367
367
|
const e = this.elementToArtboard.get(t);
|
|
368
368
|
if (e) {
|
|
369
|
-
const
|
|
370
|
-
|
|
369
|
+
const i = this.artboards.get(e);
|
|
370
|
+
i == null || i.removeElementId(t), this.elementToArtboard.delete(t);
|
|
371
371
|
}
|
|
372
372
|
}
|
|
373
373
|
/**
|
|
@@ -395,8 +395,8 @@ class qe {
|
|
|
395
395
|
* Find artboard at a point (for selection)
|
|
396
396
|
*/
|
|
397
397
|
findArtboardAtPoint(t, e) {
|
|
398
|
-
const
|
|
399
|
-
for (const s of
|
|
398
|
+
const i = Array.from(this.artboards.values()).reverse();
|
|
399
|
+
for (const s of i)
|
|
400
400
|
if (s.containsPoint(t, e))
|
|
401
401
|
return s;
|
|
402
402
|
return null;
|
|
@@ -404,11 +404,11 @@ class qe {
|
|
|
404
404
|
/**
|
|
405
405
|
* Find artboard border at point (for resize handles)
|
|
406
406
|
*/
|
|
407
|
-
findArtboardBorderAtPoint(t, e,
|
|
407
|
+
findArtboardBorderAtPoint(t, e, i = 5) {
|
|
408
408
|
const s = Array.from(this.artboards.values()).reverse();
|
|
409
|
-
for (const
|
|
410
|
-
if (
|
|
411
|
-
return
|
|
409
|
+
for (const o of s)
|
|
410
|
+
if (o.hitTestBorder(t, e, i))
|
|
411
|
+
return o;
|
|
412
412
|
return null;
|
|
413
413
|
}
|
|
414
414
|
/**
|
|
@@ -421,8 +421,8 @@ class qe {
|
|
|
421
421
|
* Update artboard properties
|
|
422
422
|
*/
|
|
423
423
|
updateArtboard(t, e) {
|
|
424
|
-
const
|
|
425
|
-
return
|
|
424
|
+
const i = this.artboards.get(t);
|
|
425
|
+
return i ? (i.updateProperties(e), !0) : !1;
|
|
426
426
|
}
|
|
427
427
|
/**
|
|
428
428
|
* Rename an artboard
|
|
@@ -447,10 +447,10 @@ class qe {
|
|
|
447
447
|
* Preserves Map insertion order by rebuilding the internal Map.
|
|
448
448
|
*/
|
|
449
449
|
reorderArtboards(t, e) {
|
|
450
|
-
const
|
|
451
|
-
if (t < 0 || t >=
|
|
452
|
-
const [s] =
|
|
453
|
-
|
|
450
|
+
const i = Array.from(this.artboards.entries());
|
|
451
|
+
if (t < 0 || t >= i.length || e < 0 || e >= i.length || t === e) return;
|
|
452
|
+
const [s] = i.splice(t, 1);
|
|
453
|
+
i.splice(e, 0, s), this.artboards = new Map(i);
|
|
454
454
|
}
|
|
455
455
|
/**
|
|
456
456
|
* Clear all artboards
|
|
@@ -472,9 +472,9 @@ class qe {
|
|
|
472
472
|
*/
|
|
473
473
|
fromJSON(t) {
|
|
474
474
|
this.clear(), t.artboards.forEach((e) => {
|
|
475
|
-
const
|
|
476
|
-
this.artboards.set(
|
|
477
|
-
this.elementToArtboard.set(s,
|
|
475
|
+
const i = nt.fromJSON(e);
|
|
476
|
+
this.artboards.set(i.id, i), i.getElementIds().forEach((s) => {
|
|
477
|
+
this.elementToArtboard.set(s, i.id);
|
|
478
478
|
});
|
|
479
479
|
}), this.activeArtboardId = t.activeArtboardId;
|
|
480
480
|
}
|
|
@@ -483,16 +483,16 @@ class qe {
|
|
|
483
483
|
* Ensures all elements have valid artboard assignments
|
|
484
484
|
*/
|
|
485
485
|
validateMappings(t) {
|
|
486
|
-
const e = new Set(t.map((
|
|
487
|
-
for (const [
|
|
488
|
-
e.has(
|
|
489
|
-
for (const
|
|
490
|
-
const s =
|
|
491
|
-
|
|
486
|
+
const e = new Set(t.map((i) => i.id));
|
|
487
|
+
for (const [i, s] of this.elementToArtboard.entries())
|
|
488
|
+
e.has(i) || this.removeElementFromArtboard(i);
|
|
489
|
+
for (const i of this.artboards.values()) {
|
|
490
|
+
const s = i.getElementIds().filter((o) => e.has(o));
|
|
491
|
+
i.clearElementIds(), s.forEach((o) => i.addElementId(o));
|
|
492
492
|
}
|
|
493
493
|
}
|
|
494
494
|
}
|
|
495
|
-
const
|
|
495
|
+
const I = {
|
|
496
496
|
/**
|
|
497
497
|
* Forward transform (local → world, for rendering)
|
|
498
498
|
* Converts degrees to radians with the canvas convention (negative = clockwise)
|
|
@@ -521,7 +521,7 @@ const D = {
|
|
|
521
521
|
return t > 180 && (t -= 360), t;
|
|
522
522
|
}
|
|
523
523
|
};
|
|
524
|
-
let
|
|
524
|
+
let ae = 1;
|
|
525
525
|
class Q {
|
|
526
526
|
/** Whether this element clips content below it (derived from blendMode === 'clip') */
|
|
527
527
|
get isClipping() {
|
|
@@ -531,7 +531,7 @@ class Q {
|
|
|
531
531
|
t ? (this.blendMode = "clip", this.knockoutParts || (this.knockoutParts = { fill: !0, scope: "group" })) : this.blendMode === "clip" && (this.blendMode = "normal");
|
|
532
532
|
}
|
|
533
533
|
constructor(t = {}) {
|
|
534
|
-
this.id = t.id || `element-${
|
|
534
|
+
this.id = t.id || `element-${ae++}`, this.x = t.x !== void 0 ? t.x : 100, this.y = t.y !== void 0 ? t.y : 100, this.rotation = t.rotation !== void 0 ? t.rotation : 0, this.opacity = t.opacity !== void 0 ? t.opacity : 1, this.transformType = t.transformType || "custom", this.transformData = t.transformData || {}, this.blendMode = t.blendMode, this.knockoutParts = t.knockoutParts, this.stroke = t.stroke, this.masks = t.masks, this.distressEffect = t.distressEffect, t.isClipping && !t.blendMode && (this.blendMode = "clip", this.knockoutParts || (this.knockoutParts = { fill: !0, scope: "group" })), this.name = t.name, this.visible = t.visible !== void 0 ? t.visible : !0, this.locked = t.locked !== void 0 ? t.locked : !1;
|
|
535
535
|
}
|
|
536
536
|
/**
|
|
537
537
|
* Get visual bounding box (tight fit around actual rendered content)
|
|
@@ -554,15 +554,15 @@ class Q {
|
|
|
554
554
|
* Uses visual bounding box for better user experience
|
|
555
555
|
*/
|
|
556
556
|
hitTest(t, e) {
|
|
557
|
-
const
|
|
558
|
-
return d >=
|
|
557
|
+
const i = this.getVisualBoundingBox(), s = this.getRotationAnchor(), o = I.toRadiansInverse(this.rotation), a = Math.cos(o), n = Math.sin(o), h = t - s.x, l = e - s.y, c = h * a - l * n, g = h * n + l * a, d = s.x + c, f = s.y + g;
|
|
558
|
+
return d >= i.x && d <= i.x + i.width && f >= i.y && f <= i.y + i.height;
|
|
559
559
|
}
|
|
560
560
|
/**
|
|
561
561
|
* Apply canvas transform (translate, rotate)
|
|
562
562
|
* Common implementation for all elements
|
|
563
563
|
*/
|
|
564
564
|
applyCanvasTransform(t) {
|
|
565
|
-
t.translate(this.x, this.y), t.rotate(
|
|
565
|
+
t.translate(this.x, this.y), t.rotate(I.toRadians(this.rotation));
|
|
566
566
|
}
|
|
567
567
|
/**
|
|
568
568
|
* Serialize to JSON
|
|
@@ -647,7 +647,7 @@ class Q {
|
|
|
647
647
|
};
|
|
648
648
|
}
|
|
649
649
|
}
|
|
650
|
-
class
|
|
650
|
+
class P {
|
|
651
651
|
/**
|
|
652
652
|
* Create a transform helper for an element
|
|
653
653
|
* @param element - Element with x, y, rotation properties
|
|
@@ -665,10 +665,10 @@ class R {
|
|
|
665
665
|
* @returns Point in local coordinates
|
|
666
666
|
*/
|
|
667
667
|
worldToLocal(t, e) {
|
|
668
|
-
const
|
|
668
|
+
const i = this.element.rotation * Math.PI / 180, s = Math.cos(i), o = Math.sin(i), a = t - this.element.x, n = e - this.element.y;
|
|
669
669
|
return {
|
|
670
|
-
x: a * s - n *
|
|
671
|
-
y: a *
|
|
670
|
+
x: a * s - n * o,
|
|
671
|
+
y: a * o + n * s
|
|
672
672
|
};
|
|
673
673
|
}
|
|
674
674
|
/**
|
|
@@ -681,7 +681,7 @@ class R {
|
|
|
681
681
|
* @returns Point in world coordinates
|
|
682
682
|
*/
|
|
683
683
|
localToWorld(t, e) {
|
|
684
|
-
const
|
|
684
|
+
const i = -this.element.rotation * Math.PI / 180, s = Math.cos(i), o = Math.sin(i), a = t * s - e * o, n = t * o + e * s;
|
|
685
685
|
return {
|
|
686
686
|
x: this.element.x + a,
|
|
687
687
|
y: this.element.y + n
|
|
@@ -697,10 +697,10 @@ class R {
|
|
|
697
697
|
* @returns Delta in local space
|
|
698
698
|
*/
|
|
699
699
|
worldDeltaToLocal(t, e) {
|
|
700
|
-
const
|
|
700
|
+
const i = this.element.rotation * Math.PI / 180, s = Math.cos(i), o = Math.sin(i);
|
|
701
701
|
return {
|
|
702
|
-
dx: t * s - e *
|
|
703
|
-
dy: t *
|
|
702
|
+
dx: t * s - e * o,
|
|
703
|
+
dy: t * o + e * s
|
|
704
704
|
};
|
|
705
705
|
}
|
|
706
706
|
/**
|
|
@@ -712,10 +712,10 @@ class R {
|
|
|
712
712
|
* @returns Delta in world space
|
|
713
713
|
*/
|
|
714
714
|
localDeltaToWorld(t, e) {
|
|
715
|
-
const
|
|
715
|
+
const i = -this.element.rotation * Math.PI / 180, s = Math.cos(i), o = Math.sin(i);
|
|
716
716
|
return {
|
|
717
|
-
dx: t * s - e *
|
|
718
|
-
dy: t *
|
|
717
|
+
dx: t * s - e * o,
|
|
718
|
+
dy: t * o + e * s
|
|
719
719
|
};
|
|
720
720
|
}
|
|
721
721
|
/**
|
|
@@ -729,10 +729,10 @@ class R {
|
|
|
729
729
|
* @param angleDegrees - Rotation angle in degrees (positive = clockwise in UI)
|
|
730
730
|
* @returns Rotated point in world space
|
|
731
731
|
*/
|
|
732
|
-
static rotatePointAroundAnchor(t, e,
|
|
733
|
-
const a = -
|
|
732
|
+
static rotatePointAroundAnchor(t, e, i, s, o) {
|
|
733
|
+
const a = -o * Math.PI / 180, n = Math.cos(a), h = Math.sin(a), l = t - i, c = e - s, g = l * n - c * h, d = l * h + c * n;
|
|
734
734
|
return {
|
|
735
|
-
x:
|
|
735
|
+
x: i + g,
|
|
736
736
|
y: s + d
|
|
737
737
|
};
|
|
738
738
|
}
|
|
@@ -788,10 +788,10 @@ class R {
|
|
|
788
788
|
* @returns Transform instance for the snapshot
|
|
789
789
|
*/
|
|
790
790
|
static fromSnapshot(t) {
|
|
791
|
-
return new
|
|
791
|
+
return new P(t);
|
|
792
792
|
}
|
|
793
793
|
}
|
|
794
|
-
const
|
|
794
|
+
const he = [
|
|
795
795
|
// Bold/Display Fonts - Perfect for statements and headlines (49 fonts)
|
|
796
796
|
{
|
|
797
797
|
name: "Bebas Neue",
|
|
@@ -2267,10 +2267,10 @@ const re = [
|
|
|
2267
2267
|
description: "Humanist monospace"
|
|
2268
2268
|
}
|
|
2269
2269
|
];
|
|
2270
|
-
function
|
|
2271
|
-
return
|
|
2270
|
+
function le() {
|
|
2271
|
+
return he.map((r) => r.name);
|
|
2272
2272
|
}
|
|
2273
|
-
const
|
|
2273
|
+
const ei = {
|
|
2274
2274
|
system: "System Fonts",
|
|
2275
2275
|
display: "Bold & Display",
|
|
2276
2276
|
"sans-serif": "Sans Serif",
|
|
@@ -2282,99 +2282,99 @@ const je = {
|
|
|
2282
2282
|
decorative: "Decorative & Unique",
|
|
2283
2283
|
monospace: "Monospace"
|
|
2284
2284
|
};
|
|
2285
|
-
function
|
|
2285
|
+
function zt(r) {
|
|
2286
2286
|
if (typeof window > "u" || typeof document > "u")
|
|
2287
2287
|
return "oklch(0% 0 0)";
|
|
2288
2288
|
const t = r || document.documentElement;
|
|
2289
2289
|
return getComputedStyle(t).getPropertyValue("--accent").trim() || "oklch(0% 0 0)";
|
|
2290
2290
|
}
|
|
2291
|
-
function
|
|
2291
|
+
function ce(r) {
|
|
2292
2292
|
return typeof window > "u" || typeof document > "u" ? "light" : document.documentElement.getAttribute("data-theme") || "light";
|
|
2293
2293
|
}
|
|
2294
|
-
function
|
|
2295
|
-
return
|
|
2294
|
+
function Xt() {
|
|
2295
|
+
return ce().includes("dark") ? "#60a5fa" : "#3b82f6";
|
|
2296
2296
|
}
|
|
2297
|
-
function
|
|
2297
|
+
function ii(r) {
|
|
2298
2298
|
if (typeof window > "u" || typeof document > "u")
|
|
2299
2299
|
return "#FF0000";
|
|
2300
2300
|
const t = r || document.documentElement;
|
|
2301
2301
|
return getComputedStyle(t).getPropertyValue("--color-spacing-indicator").trim() || "#FF0000";
|
|
2302
2302
|
}
|
|
2303
|
-
function
|
|
2304
|
-
const e =
|
|
2303
|
+
function si(r = 0.1, t) {
|
|
2304
|
+
const e = zt(t);
|
|
2305
2305
|
if (e.startsWith("oklch("))
|
|
2306
2306
|
return `${e.slice(0, -1)} / ${r})`;
|
|
2307
2307
|
if (e.startsWith("#")) {
|
|
2308
|
-
const
|
|
2309
|
-
return `rgba(${s}, ${
|
|
2308
|
+
const i = e.replace("#", ""), s = parseInt(i.substring(0, 2), 16), o = parseInt(i.substring(2, 4), 16), a = parseInt(i.substring(4, 6), 16);
|
|
2309
|
+
return `rgba(${s}, ${o}, ${a}, ${r})`;
|
|
2310
2310
|
}
|
|
2311
2311
|
return e;
|
|
2312
2312
|
}
|
|
2313
|
-
function
|
|
2313
|
+
function oi(r) {
|
|
2314
2314
|
if (typeof window > "u" || typeof document > "u")
|
|
2315
2315
|
return "oklch(0% 0 0 / 0.45)";
|
|
2316
2316
|
const t = r || document.documentElement;
|
|
2317
2317
|
return getComputedStyle(t).getPropertyValue("--color-text-selection").trim() || "oklch(0% 0 0 / 0.45)";
|
|
2318
2318
|
}
|
|
2319
|
-
function
|
|
2319
|
+
function ri(r) {
|
|
2320
2320
|
if (typeof window > "u" || typeof document > "u")
|
|
2321
2321
|
return "#b5f747";
|
|
2322
2322
|
const t = r || document.documentElement;
|
|
2323
2323
|
return getComputedStyle(t).getPropertyValue("--color-accent-hover").trim() || "#b5f747";
|
|
2324
2324
|
}
|
|
2325
|
-
function
|
|
2325
|
+
function de(r) {
|
|
2326
2326
|
if (typeof window > "u" || typeof document > "u")
|
|
2327
2327
|
return "oklch(0.2103 0.0059 285.89)";
|
|
2328
2328
|
const t = r || document.documentElement;
|
|
2329
2329
|
return getComputedStyle(t).getPropertyValue("--foreground").trim() || "oklch(0.2103 0.0059 285.89)";
|
|
2330
2330
|
}
|
|
2331
|
-
function
|
|
2331
|
+
function ni(r) {
|
|
2332
2332
|
if (typeof window > "u" || typeof document > "u")
|
|
2333
2333
|
return "oklch(0.9607 0 0)";
|
|
2334
2334
|
const t = r || document.documentElement;
|
|
2335
2335
|
return getComputedStyle(t).getPropertyValue("--background").trim() || "oklch(0.9607 0 0)";
|
|
2336
2336
|
}
|
|
2337
|
-
function
|
|
2338
|
-
const t =
|
|
2337
|
+
function ai(r) {
|
|
2338
|
+
const t = de(r);
|
|
2339
2339
|
return t.startsWith("oklch(") ? `${t.slice(0, -1)} / 0.2)` : "rgba(0,0,0,0.2)";
|
|
2340
2340
|
}
|
|
2341
|
-
function
|
|
2341
|
+
function hi(r) {
|
|
2342
2342
|
if (typeof window > "u" || typeof document > "u")
|
|
2343
2343
|
return "oklch(0% 0 0 / 0.2)";
|
|
2344
2344
|
const t = document.documentElement;
|
|
2345
2345
|
return getComputedStyle(t).getPropertyValue("--divider").trim() || "oklch(0% 0 0 / 0.2)";
|
|
2346
2346
|
}
|
|
2347
|
-
function
|
|
2347
|
+
function li(r) {
|
|
2348
2348
|
if (typeof window > "u" || typeof document > "u")
|
|
2349
2349
|
return "oklch(0% 0 0 / 0.5)";
|
|
2350
2350
|
const t = document.documentElement, e = getComputedStyle(t).getPropertyValue("--foreground").trim();
|
|
2351
2351
|
return e.startsWith("oklch(") ? `${e.slice(0, -1)} / 0.5)` : e || "oklch(0% 0 0 / 0.5)";
|
|
2352
2352
|
}
|
|
2353
|
-
function
|
|
2353
|
+
function ci(r) {
|
|
2354
2354
|
if (typeof window > "u" || typeof document > "u")
|
|
2355
2355
|
return "#b5f747";
|
|
2356
2356
|
const t = document.documentElement;
|
|
2357
2357
|
return getComputedStyle(t).getPropertyValue("--color-accent-hover-border").trim() || "#b5f747";
|
|
2358
2358
|
}
|
|
2359
|
-
function
|
|
2359
|
+
function di(r) {
|
|
2360
2360
|
if (typeof window > "u" || typeof document > "u")
|
|
2361
2361
|
return "oklch(0.2103 0.0059 285.89)";
|
|
2362
2362
|
const t = document.documentElement;
|
|
2363
2363
|
return getComputedStyle(t).getPropertyValue("--foreground").trim() || "oklch(0.2103 0.0059 285.89)";
|
|
2364
2364
|
}
|
|
2365
|
-
function
|
|
2365
|
+
function gi(r) {
|
|
2366
2366
|
if (typeof window > "u" || typeof document > "u")
|
|
2367
2367
|
return "oklch(1 0 0)";
|
|
2368
2368
|
const t = document.documentElement;
|
|
2369
2369
|
return getComputedStyle(t).getPropertyValue("--background").trim() || "oklch(1 0 0)";
|
|
2370
2370
|
}
|
|
2371
|
-
function
|
|
2371
|
+
function fi(r) {
|
|
2372
2372
|
if (typeof window > "u" || typeof document > "u")
|
|
2373
2373
|
return "oklch(0.2103 0.0059 285.89 / 0.5)";
|
|
2374
2374
|
const t = document.documentElement, e = getComputedStyle(t).getPropertyValue("--foreground").trim();
|
|
2375
2375
|
return e.startsWith("oklch(") ? `${e.slice(0, -1)} / 0.5)` : e || "oklch(0.2103 0.0059 285.89 / 0.5)";
|
|
2376
2376
|
}
|
|
2377
|
-
const
|
|
2377
|
+
const ui = 1, mi = "#ffffff", ge = 20, pi = 6, yi = 24, fe = 16, ue = 36, me = 24, wi = 4, bi = "#FFFFFF", xi = 2, Si = 0.1, Ci = le(), Ti = [8, 10, 12, 14, 16, 18, 20, 24, 28, 32, 36, 48, 64, 72, 96, 128], j = 0, Yt = 1.2, _t = 50, pe = 8, ye = 999, we = /* @__PURE__ */ new Set([
|
|
2378
2378
|
"Arial",
|
|
2379
2379
|
"Arial Black",
|
|
2380
2380
|
"Verdana",
|
|
@@ -2395,12 +2395,12 @@ const lo = 1, co = "#ffffff", le = 20, go = 6, fo = 24, ce = 16, de = 36, ge = 2
|
|
|
2395
2395
|
"Monaco",
|
|
2396
2396
|
"Consolas",
|
|
2397
2397
|
"Courier"
|
|
2398
|
-
]),
|
|
2399
|
-
var
|
|
2400
|
-
class
|
|
2398
|
+
]), be = 0.3;
|
|
2399
|
+
var xe = /* @__PURE__ */ ((r) => (r[r.DEBUG = 0] = "DEBUG", r[r.INFO = 1] = "INFO", r[r.WARN = 2] = "WARN", r[r.ERROR = 3] = "ERROR", r[r.NONE = 4] = "NONE", r))(xe || {});
|
|
2400
|
+
class Se {
|
|
2401
2401
|
constructor() {
|
|
2402
2402
|
var t;
|
|
2403
|
-
this.level = 0, this.enabled = typeof
|
|
2403
|
+
this.level = 0, this.enabled = typeof It < "u" && ((t = It.env) == null ? void 0 : t.NODE_ENV) !== "production";
|
|
2404
2404
|
}
|
|
2405
2405
|
// Only enabled in development by default
|
|
2406
2406
|
/**
|
|
@@ -2454,10 +2454,10 @@ class we {
|
|
|
2454
2454
|
* Create a scoped logger with a prefix for a specific module
|
|
2455
2455
|
*/
|
|
2456
2456
|
scope(t) {
|
|
2457
|
-
return new
|
|
2457
|
+
return new Ce(this, t);
|
|
2458
2458
|
}
|
|
2459
2459
|
}
|
|
2460
|
-
class
|
|
2460
|
+
class Ce {
|
|
2461
2461
|
constructor(t, e) {
|
|
2462
2462
|
this.logger = t, this.scopeName = e;
|
|
2463
2463
|
}
|
|
@@ -2474,18 +2474,18 @@ class xe {
|
|
|
2474
2474
|
this.logger.error(`[${this.scopeName}] ${t}`, ...e);
|
|
2475
2475
|
}
|
|
2476
2476
|
}
|
|
2477
|
-
const
|
|
2478
|
-
function
|
|
2479
|
-
return
|
|
2480
|
-
|
|
2477
|
+
const Te = new Se(), mt = (r) => Te.scope(r), ve = mt("ImageLoadEvents"), Ct = /* @__PURE__ */ new Set();
|
|
2478
|
+
function vi(r) {
|
|
2479
|
+
return Ct.add(r), () => {
|
|
2480
|
+
Ct.delete(r);
|
|
2481
2481
|
};
|
|
2482
2482
|
}
|
|
2483
2483
|
function et(r) {
|
|
2484
|
-
|
|
2484
|
+
Ct.forEach((t) => {
|
|
2485
2485
|
try {
|
|
2486
2486
|
t(r);
|
|
2487
2487
|
} catch (e) {
|
|
2488
|
-
|
|
2488
|
+
ve.error("Listener error:", e);
|
|
2489
2489
|
}
|
|
2490
2490
|
});
|
|
2491
2491
|
}
|
|
@@ -2511,18 +2511,18 @@ class J {
|
|
|
2511
2511
|
const e = this.cache.get(t);
|
|
2512
2512
|
if (e)
|
|
2513
2513
|
return e.refCount++, e.image;
|
|
2514
|
-
const
|
|
2515
|
-
|
|
2514
|
+
const i = new Image();
|
|
2515
|
+
i.crossOrigin = "anonymous";
|
|
2516
2516
|
const s = {
|
|
2517
|
-
image:
|
|
2517
|
+
image: i,
|
|
2518
2518
|
refCount: 1,
|
|
2519
2519
|
loaded: !1
|
|
2520
2520
|
};
|
|
2521
|
-
return
|
|
2521
|
+
return i.onload = () => {
|
|
2522
2522
|
s.loaded = !0;
|
|
2523
|
-
},
|
|
2523
|
+
}, i.onerror = () => {
|
|
2524
2524
|
s.loaded = !0;
|
|
2525
|
-
}, this.cache.set(t, s), (!t.includes(":") || /^https?:\/\/|^data:|^blob:/.test(t)) && (
|
|
2525
|
+
}, this.cache.set(t, s), (!t.includes(":") || /^https?:\/\/|^data:|^blob:/.test(t)) && (i.src = t), i;
|
|
2526
2526
|
}
|
|
2527
2527
|
/**
|
|
2528
2528
|
* Release a reference to a cached image.
|
|
@@ -2571,20 +2571,20 @@ class J {
|
|
|
2571
2571
|
this.cache.clear();
|
|
2572
2572
|
}
|
|
2573
2573
|
}
|
|
2574
|
-
const
|
|
2575
|
-
function
|
|
2574
|
+
const it = mt("ImageElement"), Et = 3e4, Ot = 3, Fe = 1e3;
|
|
2575
|
+
function x(r) {
|
|
2576
2576
|
return r.transformData;
|
|
2577
2577
|
}
|
|
2578
2578
|
class pt extends Q {
|
|
2579
2579
|
// Track URL acquired from ImageCache for release on destroy
|
|
2580
2580
|
constructor(t = {}) {
|
|
2581
|
-
var e,
|
|
2581
|
+
var e, i, s, o, a, n, h, l, c, g;
|
|
2582
2582
|
super(t), this.svgBlobUrl = null, this.loadTimeoutId = null, this.retryAttempt = 0, this.cachedImageUrl = null, this.transformType = "image", this.transformData = {
|
|
2583
2583
|
type: "image",
|
|
2584
2584
|
width: ((e = t.transformData) == null ? void 0 : e.width) || 200,
|
|
2585
|
-
height: ((
|
|
2585
|
+
height: ((i = t.transformData) == null ? void 0 : i.height) || 200,
|
|
2586
2586
|
cropX: ((s = t.transformData) == null ? void 0 : s.cropX) ?? 0,
|
|
2587
|
-
cropY: ((
|
|
2587
|
+
cropY: ((o = t.transformData) == null ? void 0 : o.cropY) ?? 0,
|
|
2588
2588
|
cropWidth: ((a = t.transformData) == null ? void 0 : a.cropWidth) ?? 1,
|
|
2589
2589
|
cropHeight: ((n = t.transformData) == null ? void 0 : n.cropHeight) ?? 1,
|
|
2590
2590
|
flipHorizontal: ((h = t.transformData) == null ? void 0 : h.flipHorizontal) ?? !1,
|
|
@@ -2617,42 +2617,42 @@ class pt extends Q {
|
|
|
2617
2617
|
attemptLoadRegularImage(t) {
|
|
2618
2618
|
var h;
|
|
2619
2619
|
this.clearLoadTimeout(), this.releaseImageCache();
|
|
2620
|
-
const
|
|
2620
|
+
const i = J.getInstance().acquire(t);
|
|
2621
2621
|
this.cachedImageUrl = t;
|
|
2622
2622
|
let s = !1;
|
|
2623
|
-
const
|
|
2623
|
+
const o = () => {
|
|
2624
2624
|
s = !0, this.clearLoadTimeout();
|
|
2625
2625
|
};
|
|
2626
|
-
if (
|
|
2627
|
-
|
|
2626
|
+
if (i.complete && i.naturalWidth > 0) {
|
|
2627
|
+
o(), this.imageElement = i, this.imageLoaded = !0, this.imageLoadState = "loaded", this.imageLoadError = null, this.imageAspectRatio = i.naturalWidth / i.naturalHeight, this.preserveDimensions || (this.transformData.height = this.transformData.width / this.imageAspectRatio), this.onLoadCallback && this.onLoadCallback(this.clone()), et(this.id);
|
|
2628
2628
|
return;
|
|
2629
2629
|
}
|
|
2630
|
-
const a =
|
|
2631
|
-
|
|
2632
|
-
s || (
|
|
2633
|
-
},
|
|
2630
|
+
const a = i.onload, n = i.onerror;
|
|
2631
|
+
i.onload = (l) => {
|
|
2632
|
+
s || (o(), this.imageElement = i, this.imageLoaded = !0, this.imageLoadState = "loaded", this.imageLoadError = null, this.imageAspectRatio = i.naturalWidth / i.naturalHeight, this.preserveDimensions || (this.transformData.height = this.transformData.width / this.imageAspectRatio), this.onLoadCallback && this.onLoadCallback(this.clone()), et(this.id), a && a !== i.onload && a(l));
|
|
2633
|
+
}, i.onerror = (l) => {
|
|
2634
2634
|
if (s) return;
|
|
2635
|
-
|
|
2635
|
+
o();
|
|
2636
2636
|
const c = new Error(`Failed to load image: ${t}`);
|
|
2637
|
-
this.handleLoadFailure(t, c), n && n !==
|
|
2637
|
+
this.handleLoadFailure(t, c), n && n !== i.onerror && n(l);
|
|
2638
2638
|
}, this.loadTimeoutId = setTimeout(() => {
|
|
2639
2639
|
if (s) return;
|
|
2640
|
-
|
|
2641
|
-
const l = new Error(`Image load timed out after ${
|
|
2640
|
+
o(), i.src = "";
|
|
2641
|
+
const l = new Error(`Image load timed out after ${Et}ms: ${t}`);
|
|
2642
2642
|
this.handleLoadFailure(t, l);
|
|
2643
|
-
},
|
|
2643
|
+
}, Et), (!i.src || i.src !== t) && (i.src = t), !s && i.complete && i.naturalWidth > 0 && ((h = i.onload) == null || h.call(i, new Event("load")));
|
|
2644
2644
|
}
|
|
2645
2645
|
/**
|
|
2646
2646
|
* Handle a load failure - either retry with backoff or set error state.
|
|
2647
2647
|
*/
|
|
2648
2648
|
handleLoadFailure(t, e) {
|
|
2649
|
-
if (this.retryAttempt++, this.retryAttempt <
|
|
2650
|
-
const
|
|
2651
|
-
|
|
2649
|
+
if (this.retryAttempt++, this.retryAttempt < Ot) {
|
|
2650
|
+
const i = Fe * Math.pow(2, this.retryAttempt - 1);
|
|
2651
|
+
it.warn(`Image load attempt ${this.retryAttempt} failed, retrying in ${i}ms:`, t), this.imageLoadState = "retrying", this.imageLoadError = e, et(this.id), this.loadTimeoutId = setTimeout(() => {
|
|
2652
2652
|
this.attemptLoadRegularImage(t);
|
|
2653
|
-
},
|
|
2653
|
+
}, i);
|
|
2654
2654
|
} else
|
|
2655
|
-
|
|
2655
|
+
it.error(`Image load failed after ${Ot} attempts:`, t), this.imageLoaded = !1, this.imageLoadState = "error", this.imageLoadError = e, et(this.id);
|
|
2656
2656
|
}
|
|
2657
2657
|
/**
|
|
2658
2658
|
* Clear any pending load timeout
|
|
@@ -2672,7 +2672,7 @@ class pt extends Q {
|
|
|
2672
2672
|
* Resets retry count and starts fresh.
|
|
2673
2673
|
*/
|
|
2674
2674
|
retryImageLoad() {
|
|
2675
|
-
this.imageUrl && (
|
|
2675
|
+
this.imageUrl && (it.info("Manual retry triggered for image:", this.imageUrl), this.clearLoadTimeout(), this.imageLoaded = !1, this.imageElement = null, this.isSvg ? (this.imageLoadState = "loading", this.imageLoadError = null, this.loadSvgAsHighDpi(this.imageUrl)) : this.loadRegularImage(this.imageUrl));
|
|
2676
2676
|
}
|
|
2677
2677
|
/**
|
|
2678
2678
|
* Revoke any existing SVG blob URL to prevent memory leaks
|
|
@@ -2691,10 +2691,10 @@ class pt extends Q {
|
|
|
2691
2691
|
e.crossOrigin = "anonymous", e.onload = () => {
|
|
2692
2692
|
const s = document.createElement("canvas");
|
|
2693
2693
|
s.width = e.width * 4, s.height = e.height * 4;
|
|
2694
|
-
const
|
|
2695
|
-
|
|
2694
|
+
const o = s.getContext("2d");
|
|
2695
|
+
o.scale(4, 4), o.drawImage(e, 0, 0), s.toBlob((a) => {
|
|
2696
2696
|
if (!a) {
|
|
2697
|
-
|
|
2697
|
+
it.error("Failed to convert SVG to blob"), this.imageLoaded = !1;
|
|
2698
2698
|
return;
|
|
2699
2699
|
}
|
|
2700
2700
|
this.svgBlobUrl = URL.createObjectURL(a), this.imageElement = new Image(), this.imageElement.crossOrigin = "anonymous", this.imageElement.onload = () => {
|
|
@@ -2702,7 +2702,7 @@ class pt extends Q {
|
|
|
2702
2702
|
}, this.imageElement.src = this.svgBlobUrl;
|
|
2703
2703
|
}, "image/png");
|
|
2704
2704
|
}, e.onerror = () => {
|
|
2705
|
-
|
|
2705
|
+
it.error("Failed to load SVG:", t), this.imageLoaded = !1;
|
|
2706
2706
|
}, e.src = t;
|
|
2707
2707
|
}
|
|
2708
2708
|
/**
|
|
@@ -2713,10 +2713,10 @@ class pt extends Q {
|
|
|
2713
2713
|
getBoundingBox() {
|
|
2714
2714
|
if (this.isCropping) {
|
|
2715
2715
|
const t = this.transformData.width * this.transformData.cropWidth, e = this.transformData.height * this.transformData.cropHeight;
|
|
2716
|
-
let
|
|
2717
|
-
const
|
|
2718
|
-
|
|
2719
|
-
const n = Math.cos(
|
|
2716
|
+
let i = this.transformData.width / 2 - (this.transformData.cropX * this.transformData.width + t / 2), s = this.transformData.height / 2 - (this.transformData.cropY * this.transformData.height + e / 2);
|
|
2717
|
+
const o = this.transformData.flipHorizontal ? -1 : 1, a = this.transformData.flipVertical ? -1 : 1;
|
|
2718
|
+
i *= o, s *= a;
|
|
2719
|
+
const n = Math.cos(I.toRadians(this.rotation)), h = Math.sin(I.toRadians(this.rotation)), l = i * n - s * h, c = i * h + s * n, g = this.x + l, d = this.y + c;
|
|
2720
2720
|
return {
|
|
2721
2721
|
x: g - this.transformData.width / 2,
|
|
2722
2722
|
y: d - this.transformData.height / 2,
|
|
@@ -2754,10 +2754,10 @@ class pt extends Q {
|
|
|
2754
2754
|
getRotationAnchor() {
|
|
2755
2755
|
if (this.isCropping) {
|
|
2756
2756
|
const t = this.transformData.width * this.transformData.cropWidth, e = this.transformData.height * this.transformData.cropHeight;
|
|
2757
|
-
let
|
|
2758
|
-
const
|
|
2759
|
-
|
|
2760
|
-
const n = Math.cos(
|
|
2757
|
+
let i = this.transformData.width / 2 - (this.transformData.cropX * this.transformData.width + t / 2), s = this.transformData.height / 2 - (this.transformData.cropY * this.transformData.height + e / 2);
|
|
2758
|
+
const o = this.transformData.flipHorizontal ? -1 : 1, a = this.transformData.flipVertical ? -1 : 1;
|
|
2759
|
+
i *= o, s *= a;
|
|
2760
|
+
const n = Math.cos(I.toRadians(this.rotation)), h = Math.sin(I.toRadians(this.rotation)), l = i * n - s * h, c = i * h + s * n;
|
|
2761
2761
|
return {
|
|
2762
2762
|
x: this.x + l,
|
|
2763
2763
|
y: this.y + c
|
|
@@ -2772,26 +2772,26 @@ class pt extends Q {
|
|
|
2772
2772
|
* Hit test for image - checks if point is inside the visible (cropped) area
|
|
2773
2773
|
*/
|
|
2774
2774
|
hitTest(t, e) {
|
|
2775
|
-
const
|
|
2775
|
+
const i = this.worldToLocal(t, e);
|
|
2776
2776
|
if (this.isCropping) {
|
|
2777
|
-
const s = this.transformData.width * this.transformData.cropWidth,
|
|
2778
|
-
return
|
|
2777
|
+
const s = this.transformData.width * this.transformData.cropWidth, o = this.transformData.height * this.transformData.cropHeight, a = this.transformData.width / 2 - (this.transformData.cropX * this.transformData.width + s / 2), n = this.transformData.height / 2 - (this.transformData.cropY * this.transformData.height + o / 2), h = this.transformData.width / 2, l = this.transformData.height / 2;
|
|
2778
|
+
return i.x >= a - h && i.x <= a + h && i.y >= n - l && i.y <= n + l;
|
|
2779
2779
|
} else {
|
|
2780
|
-
const s = this.transformData.width * this.transformData.cropWidth,
|
|
2781
|
-
return
|
|
2780
|
+
const s = this.transformData.width * this.transformData.cropWidth, o = this.transformData.height * this.transformData.cropHeight, a = s / 2, n = o / 2;
|
|
2781
|
+
return i.x >= -a && i.x <= a && i.y >= -n && i.y <= n;
|
|
2782
2782
|
}
|
|
2783
2783
|
}
|
|
2784
2784
|
/**
|
|
2785
2785
|
* Render the image
|
|
2786
2786
|
*/
|
|
2787
|
-
render(t, e = !1,
|
|
2787
|
+
render(t, e = !1, i = !1) {
|
|
2788
2788
|
if (!this.imageLoaded || !this.imageElement) {
|
|
2789
2789
|
this.renderPlaceholder(t);
|
|
2790
2790
|
return;
|
|
2791
2791
|
}
|
|
2792
|
-
t.save(), this.opacity !== void 0 && this.opacity !== 1 && (t.globalAlpha = this.opacity), t.translate(this.x, this.y), t.rotate(
|
|
2793
|
-
const s = this.transformData.flipHorizontal ? -1 : 1,
|
|
2794
|
-
if (t.scale(s,
|
|
2792
|
+
t.save(), this.opacity !== void 0 && this.opacity !== 1 && (t.globalAlpha = this.opacity), t.translate(this.x, this.y), t.rotate(I.toRadians(this.rotation));
|
|
2793
|
+
const s = this.transformData.flipHorizontal ? -1 : 1, o = this.transformData.flipVertical ? -1 : 1;
|
|
2794
|
+
if (t.scale(s, o), this.isCropping) {
|
|
2795
2795
|
const a = this.transformData.width * this.transformData.cropWidth, n = this.transformData.height * this.transformData.cropHeight, h = this.transformData.width / 2 - (this.transformData.cropX * this.transformData.width + a / 2), l = this.transformData.height / 2 - (this.transformData.cropY * this.transformData.height + n / 2), c = h - this.transformData.width / 2, g = l - this.transformData.height / 2, d = this.transformData.borderRadius || 0;
|
|
2796
2796
|
if (d > 0) {
|
|
2797
2797
|
t.save();
|
|
@@ -2851,55 +2851,55 @@ class pt extends Q {
|
|
|
2851
2851
|
* Shows different visuals for loading, retrying, error, and no-image states.
|
|
2852
2852
|
*/
|
|
2853
2853
|
renderPlaceholder(t) {
|
|
2854
|
-
t.save(), t.translate(this.x, this.y), t.rotate(
|
|
2855
|
-
const e = this.transformData.width * this.transformData.cropWidth,
|
|
2854
|
+
t.save(), t.translate(this.x, this.y), t.rotate(I.toRadians(this.rotation));
|
|
2855
|
+
const e = this.transformData.width * this.transformData.cropWidth, i = this.transformData.height * this.transformData.cropHeight, s = -e / 2, o = -i / 2;
|
|
2856
2856
|
let a, n, h;
|
|
2857
|
-
this.imageLoadState === "error" ? (a = "#f0e0e0", n = "#993333", h = "Image failed to load") : this.imageLoadState === "retrying" ? (a = "#e0e0e0", n = "#666", h = "Retrying...") : this.imageLoadState === "loading" ? (a = "#e0e0e0", n = "#666", h = "Loading...") : (a = "#e0e0e0", n = "#666", h = this.imageUrl ? "Loading..." : "No image"), t.fillStyle = a, t.fillRect(s,
|
|
2857
|
+
this.imageLoadState === "error" ? (a = "#f0e0e0", n = "#993333", h = "Image failed to load") : this.imageLoadState === "retrying" ? (a = "#e0e0e0", n = "#666", h = "Retrying...") : this.imageLoadState === "loading" ? (a = "#e0e0e0", n = "#666", h = "Loading...") : (a = "#e0e0e0", n = "#666", h = this.imageUrl ? "Loading..." : "No image"), t.fillStyle = a, t.fillRect(s, o, e, i), t.fillStyle = n, t.font = "14px system-ui, -apple-system, sans-serif", t.textAlign = "center", t.textBaseline = "middle", t.fillText(h, 0, 0), t.restore();
|
|
2858
2858
|
}
|
|
2859
2859
|
/**
|
|
2860
2860
|
* Handle resize - maintain aspect ratio
|
|
2861
2861
|
* @returns {boolean} true if resize was applied
|
|
2862
2862
|
*/
|
|
2863
|
-
resize(t, e,
|
|
2864
|
-
let
|
|
2865
|
-
this.isCropping ? (
|
|
2866
|
-
const n = (
|
|
2863
|
+
resize(t, e, i, s) {
|
|
2864
|
+
let o, a;
|
|
2865
|
+
this.isCropping ? (o = e / x(s).width, a = i / x(s).height) : (o = e / (s.width ?? 1), a = i / (s.height ?? 1));
|
|
2866
|
+
const n = (o + a) / 2;
|
|
2867
2867
|
let h = t;
|
|
2868
2868
|
this.isCropping && (h = this.remapAnchorForFlips(t, s));
|
|
2869
2869
|
let l = n;
|
|
2870
2870
|
if (this.isCropping) {
|
|
2871
|
-
const
|
|
2872
|
-
n <
|
|
2871
|
+
const B = this.transformData.width / x(s).width;
|
|
2872
|
+
n < B && (l = this.calculateMinScaleForCropBounds(
|
|
2873
2873
|
h,
|
|
2874
2874
|
s,
|
|
2875
2875
|
n,
|
|
2876
|
-
|
|
2876
|
+
B
|
|
2877
2877
|
));
|
|
2878
2878
|
}
|
|
2879
|
-
this.transformData.width =
|
|
2879
|
+
this.transformData.width = x(s).width * l, this.transformData.height = this.transformData.width / this.imageAspectRatio, this.rotation = s.rotation;
|
|
2880
2880
|
let c, g;
|
|
2881
2881
|
if (this.isCropping) {
|
|
2882
|
-
const
|
|
2883
|
-
c = s.x -
|
|
2882
|
+
const B = (x(s).cropX + x(s).cropWidth / 2) * x(s).width - x(s).width / 2, A = (x(s).cropY + x(s).cropHeight / 2) * x(s).height - x(s).height / 2, k = B, R = A, E = P.fromSnapshot(s).localDeltaToWorld(k, R), W = E.dx, z = E.dy;
|
|
2883
|
+
c = s.x - W, g = s.y - z;
|
|
2884
2884
|
} else {
|
|
2885
|
-
const
|
|
2886
|
-
c = s.x -
|
|
2885
|
+
const B = (x(s).cropX + x(s).cropWidth / 2) * x(s).width - x(s).width / 2, A = (x(s).cropY + x(s).cropHeight / 2) * x(s).height - x(s).height / 2, k = B, R = A, E = P.fromSnapshot(s).localDeltaToWorld(k, R), W = E.dx, z = E.dy;
|
|
2886
|
+
c = s.x - W, g = s.y - z;
|
|
2887
2887
|
}
|
|
2888
2888
|
let d, f, u = 0, m = 0;
|
|
2889
|
-
h === "top-left" ? (u =
|
|
2890
|
-
const y =
|
|
2891
|
-
d = c +
|
|
2892
|
-
let
|
|
2893
|
-
h === "top-left" ? (
|
|
2894
|
-
const
|
|
2889
|
+
h === "top-left" ? (u = x(s).width / 2, m = x(s).height / 2) : h === "top-right" ? (u = -x(s).width / 2, m = x(s).height / 2) : h === "bottom-left" ? (u = x(s).width / 2, m = -x(s).height / 2) : h === "bottom-right" ? (u = -x(s).width / 2, m = -x(s).height / 2) : h === "middle-left" ? (u = x(s).width / 2, m = 0) : h === "middle-right" ? (u = -x(s).width / 2, m = 0) : h === "middle-top" ? (u = 0, m = x(s).height / 2) : h === "middle-bottom" && (u = 0, m = -x(s).height / 2);
|
|
2890
|
+
const y = P.fromSnapshot(s).localDeltaToWorld(u, m), w = y.dx, S = y.dy;
|
|
2891
|
+
d = c + w, f = g + S;
|
|
2892
|
+
let b = 0, T = 0;
|
|
2893
|
+
h === "top-left" ? (b = this.transformData.width / 2, T = this.transformData.height / 2) : h === "top-right" ? (b = -this.transformData.width / 2, T = this.transformData.height / 2) : h === "bottom-left" ? (b = this.transformData.width / 2, T = -this.transformData.height / 2) : h === "bottom-right" ? (b = -this.transformData.width / 2, T = -this.transformData.height / 2) : h === "middle-left" ? (b = this.transformData.width / 2, T = 0) : h === "middle-right" ? (b = -this.transformData.width / 2, T = 0) : h === "middle-top" ? (b = 0, T = this.transformData.height / 2) : h === "middle-bottom" && (b = 0, T = -this.transformData.height / 2);
|
|
2894
|
+
const M = new P(this).localDeltaToWorld(b, T), F = M.dx, v = M.dy, D = d - F, U = f - v;
|
|
2895
2895
|
if (this.isCropping) {
|
|
2896
|
-
const
|
|
2897
|
-
this.x =
|
|
2898
|
-
const
|
|
2899
|
-
this.transformData.cropX =
|
|
2896
|
+
const B = s.x, A = s.y, k = x(s).cropWidth * x(s).width, R = x(s).cropHeight * x(s).height;
|
|
2897
|
+
this.x = B, this.y = A;
|
|
2898
|
+
const H = k / this.transformData.width, E = R / this.transformData.height, W = B - D, z = A - U, Dt = new P(this).worldDeltaToLocal(W, z), Zt = Dt.dx, Kt = Dt.dy, Qt = this.transformData.width / 2 + Zt, te = this.transformData.height / 2 + Kt, ee = Qt / this.transformData.width - H / 2, ie = te / this.transformData.height - E / 2;
|
|
2899
|
+
this.transformData.cropX = ee, this.transformData.cropY = ie, this.transformData.cropWidth = H, this.transformData.cropHeight = E;
|
|
2900
2900
|
} else {
|
|
2901
|
-
const
|
|
2902
|
-
this.x =
|
|
2901
|
+
const B = (this.transformData.cropX + this.transformData.cropWidth / 2) * this.transformData.width - this.transformData.width / 2, A = (this.transformData.cropY + this.transformData.cropHeight / 2) * this.transformData.height - this.transformData.height / 2, k = B, R = A, E = new P(this).localDeltaToWorld(k, R), W = E.dx, z = E.dy;
|
|
2902
|
+
this.x = D + W, this.y = U + z;
|
|
2903
2903
|
}
|
|
2904
2904
|
return !0;
|
|
2905
2905
|
}
|
|
@@ -2945,7 +2945,7 @@ class pt extends Q {
|
|
|
2945
2945
|
getCropBoxWorldCorners() {
|
|
2946
2946
|
const t = this.getCropBoxBounds();
|
|
2947
2947
|
if (!t) return null;
|
|
2948
|
-
const e = Math.cos(
|
|
2948
|
+
const e = Math.cos(I.toRadians(this.rotation)), i = Math.sin(I.toRadians(this.rotation));
|
|
2949
2949
|
return [
|
|
2950
2950
|
{ x: t.x, y: t.y },
|
|
2951
2951
|
// top-left
|
|
@@ -2955,9 +2955,9 @@ class pt extends Q {
|
|
|
2955
2955
|
// bottom-left
|
|
2956
2956
|
{ x: t.x + t.width, y: t.y + t.height }
|
|
2957
2957
|
// bottom-right
|
|
2958
|
-
].map((
|
|
2959
|
-
x: this.x +
|
|
2960
|
-
y: this.y +
|
|
2958
|
+
].map((o) => ({
|
|
2959
|
+
x: this.x + o.x * e - o.y * i,
|
|
2960
|
+
y: this.y + o.x * i + o.y * e
|
|
2961
2961
|
}));
|
|
2962
2962
|
}
|
|
2963
2963
|
/**
|
|
@@ -2965,8 +2965,8 @@ class pt extends Q {
|
|
|
2965
2965
|
* Local coordinates are relative to this.x, this.y (the center of the visible area)
|
|
2966
2966
|
*/
|
|
2967
2967
|
worldToLocal(t, e) {
|
|
2968
|
-
const
|
|
2969
|
-
let n =
|
|
2968
|
+
const i = t - this.x, s = e - this.y, o = Math.cos(I.toRadiansInverse(this.rotation)), a = Math.sin(I.toRadiansInverse(this.rotation));
|
|
2969
|
+
let n = i * o - s * a, h = i * a + s * o;
|
|
2970
2970
|
const l = this.transformData.flipHorizontal ? -1 : 1, c = this.transformData.flipVertical ? -1 : 1;
|
|
2971
2971
|
return n *= l, h *= c, {
|
|
2972
2972
|
x: n,
|
|
@@ -2979,9 +2979,9 @@ class pt extends Q {
|
|
|
2979
2979
|
* Canvas transformations are applied in reverse: scale -> rotate -> translate
|
|
2980
2980
|
*/
|
|
2981
2981
|
localToWorld(t, e) {
|
|
2982
|
-
const
|
|
2983
|
-
let
|
|
2984
|
-
const n = Math.cos(
|
|
2982
|
+
const i = this.transformData.flipHorizontal ? -1 : 1, s = this.transformData.flipVertical ? -1 : 1;
|
|
2983
|
+
let o = t * i, a = e * s;
|
|
2984
|
+
const n = Math.cos(I.toRadians(this.rotation)), h = Math.sin(I.toRadians(this.rotation)), l = o * n - a * h, c = o * h + a * n;
|
|
2985
2985
|
return {
|
|
2986
2986
|
x: this.x + l,
|
|
2987
2987
|
y: this.y + c
|
|
@@ -2994,18 +2994,18 @@ class pt extends Q {
|
|
|
2994
2994
|
* @param worldY - Y coordinate in world space
|
|
2995
2995
|
* @param zoom - Current zoom level (used to scale hit areas for consistent interaction)
|
|
2996
2996
|
*/
|
|
2997
|
-
hitTestCropHandle(t, e,
|
|
2997
|
+
hitTestCropHandle(t, e, i = 1) {
|
|
2998
2998
|
if (!this.isCropping) return null;
|
|
2999
2999
|
const s = this.getCropBoxBounds();
|
|
3000
3000
|
if (!s) return null;
|
|
3001
|
-
const
|
|
3001
|
+
const o = this.worldToLocal(t, e), a = 1 / i, n = fe * a, h = ue * a, l = me * a, c = [
|
|
3002
3002
|
{ x: s.x, y: s.y, anchor: "top-left" },
|
|
3003
3003
|
{ x: s.x + s.width, y: s.y, anchor: "top-right" },
|
|
3004
3004
|
{ x: s.x, y: s.y + s.height, anchor: "bottom-left" },
|
|
3005
3005
|
{ x: s.x + s.width, y: s.y + s.height, anchor: "bottom-right" }
|
|
3006
3006
|
];
|
|
3007
3007
|
for (const d of c) {
|
|
3008
|
-
const f =
|
|
3008
|
+
const f = o.x - d.x, u = o.y - d.y;
|
|
3009
3009
|
if (Math.sqrt(f * f + u * u) <= n) {
|
|
3010
3010
|
const p = this.localToWorld(d.x, d.y);
|
|
3011
3011
|
return { type: "corner", anchor: d.anchor, worldX: p.x, worldY: p.y };
|
|
@@ -3018,7 +3018,7 @@ class pt extends Q {
|
|
|
3018
3018
|
{ x: s.x + s.width, y: s.y + s.height / 2, anchor: "right", orientation: "vertical" }
|
|
3019
3019
|
];
|
|
3020
3020
|
for (const d of g) {
|
|
3021
|
-
const f =
|
|
3021
|
+
const f = o.x - d.x, u = o.y - d.y;
|
|
3022
3022
|
let m, p;
|
|
3023
3023
|
if (d.orientation === "horizontal" ? (m = h / 2, p = l / 2) : (m = l / 2, p = h / 2), Math.abs(f) <= m && Math.abs(u) <= p) {
|
|
3024
3024
|
const y = this.localToWorld(d.x, d.y);
|
|
@@ -3033,10 +3033,10 @@ class pt extends Q {
|
|
|
3033
3033
|
*/
|
|
3034
3034
|
hitTestCropBox(t, e) {
|
|
3035
3035
|
if (!this.isCropping) return !1;
|
|
3036
|
-
const
|
|
3037
|
-
if (!
|
|
3036
|
+
const i = this.getCropBoxBounds();
|
|
3037
|
+
if (!i) return !1;
|
|
3038
3038
|
const s = this.worldToLocal(t, e);
|
|
3039
|
-
return s.x >=
|
|
3039
|
+
return s.x >= i.x && s.x <= i.x + i.width && s.y >= i.y && s.y <= i.y + i.height;
|
|
3040
3040
|
}
|
|
3041
3041
|
/**
|
|
3042
3042
|
* Update crop box (normalized 0-1 coordinates)
|
|
@@ -3046,42 +3046,42 @@ class pt extends Q {
|
|
|
3046
3046
|
* @param {number} cropHeight - Normalized height (0-1)
|
|
3047
3047
|
* @param {boolean} adjustPosition - Whether to adjust this.x, this.y to keep visual position stable (default: false)
|
|
3048
3048
|
*/
|
|
3049
|
-
updateCrop(t, e,
|
|
3050
|
-
let n = Math.max(0.1, Math.min(1,
|
|
3049
|
+
updateCrop(t, e, i, s, o = !1) {
|
|
3050
|
+
let n = Math.max(0.1, Math.min(1, i)), h = Math.max(0.1, Math.min(1, s)), l = Math.max(0, Math.min(1 - n, t)), c = Math.max(0, Math.min(1 - h, e));
|
|
3051
3051
|
l + n > 1 && (n = 1 - l), c + h > 1 && (h = 1 - c);
|
|
3052
3052
|
let g = 0, d = 0;
|
|
3053
|
-
if (
|
|
3054
|
-
const f = this.transformData.cropX * this.transformData.width + this.transformData.cropWidth * this.transformData.width / 2, u = this.transformData.cropY * this.transformData.height + this.transformData.cropHeight * this.transformData.height / 2, m = l * this.transformData.width + n * this.transformData.width / 2, p = c * this.transformData.height + h * this.transformData.height / 2, y = m - f,
|
|
3055
|
-
g = y *
|
|
3053
|
+
if (o) {
|
|
3054
|
+
const f = this.transformData.cropX * this.transformData.width + this.transformData.cropWidth * this.transformData.width / 2, u = this.transformData.cropY * this.transformData.height + this.transformData.cropHeight * this.transformData.height / 2, m = l * this.transformData.width + n * this.transformData.width / 2, p = c * this.transformData.height + h * this.transformData.height / 2, y = m - f, w = p - u, S = Math.cos(I.toRadians(this.rotation)), b = Math.sin(I.toRadians(this.rotation));
|
|
3055
|
+
g = y * S - w * b, d = y * b + w * S;
|
|
3056
3056
|
}
|
|
3057
|
-
this.transformData.cropX = l, this.transformData.cropY = c, this.transformData.cropWidth = n, this.transformData.cropHeight = h,
|
|
3057
|
+
this.transformData.cropX = l, this.transformData.cropY = c, this.transformData.cropWidth = n, this.transformData.cropHeight = h, o && (this.x += g, this.y += d);
|
|
3058
3058
|
}
|
|
3059
3059
|
/**
|
|
3060
3060
|
* Get the local position of the corner opposite to the given anchor
|
|
3061
3061
|
* Corners are relative to frame center
|
|
3062
3062
|
*/
|
|
3063
|
-
getOppositeCornerLocalPosition(t, e,
|
|
3064
|
-
const s = e / 2,
|
|
3063
|
+
getOppositeCornerLocalPosition(t, e, i) {
|
|
3064
|
+
const s = e / 2, o = i / 2;
|
|
3065
3065
|
return {
|
|
3066
|
-
"top-left": { x: s, y:
|
|
3066
|
+
"top-left": { x: s, y: o },
|
|
3067
3067
|
// Opposite is bottom-right
|
|
3068
|
-
"top-right": { x: -s, y:
|
|
3068
|
+
"top-right": { x: -s, y: o },
|
|
3069
3069
|
// Opposite is bottom-left
|
|
3070
|
-
"bottom-left": { x: s, y: -
|
|
3070
|
+
"bottom-left": { x: s, y: -o },
|
|
3071
3071
|
// Opposite is top-right
|
|
3072
|
-
"bottom-right": { x: -s, y: -
|
|
3072
|
+
"bottom-right": { x: -s, y: -o },
|
|
3073
3073
|
// Opposite is top-left
|
|
3074
|
-
top: { x: 0, y:
|
|
3074
|
+
top: { x: 0, y: o },
|
|
3075
3075
|
// Opposite is bottom edge
|
|
3076
|
-
bottom: { x: 0, y: -
|
|
3076
|
+
bottom: { x: 0, y: -o },
|
|
3077
3077
|
// Opposite is top edge
|
|
3078
3078
|
left: { x: s, y: 0 },
|
|
3079
3079
|
// Opposite is right edge
|
|
3080
3080
|
right: { x: -s, y: 0 },
|
|
3081
3081
|
// Opposite is left edge
|
|
3082
|
-
"middle-top": { x: 0, y:
|
|
3082
|
+
"middle-top": { x: 0, y: o },
|
|
3083
3083
|
// Opposite is bottom edge
|
|
3084
|
-
"middle-bottom": { x: 0, y: -
|
|
3084
|
+
"middle-bottom": { x: 0, y: -o },
|
|
3085
3085
|
// Opposite is top edge
|
|
3086
3086
|
"middle-left": { x: s, y: 0 },
|
|
3087
3087
|
// Opposite is right edge
|
|
@@ -3094,7 +3094,7 @@ class pt extends Q {
|
|
|
3094
3094
|
* In crop mode, this.x/y is the crop center, not the frame center
|
|
3095
3095
|
*/
|
|
3096
3096
|
calculateFrameCenterFromCropCenter(t) {
|
|
3097
|
-
const e =
|
|
3097
|
+
const e = x(t).width * x(t).cropWidth, i = x(t).height * x(t).cropHeight, s = x(t).width / 2 - (x(t).cropX * x(t).width + e / 2), o = x(t).height / 2 - (x(t).cropY * x(t).height + i / 2), n = new P(t).localDeltaToWorld(s, o);
|
|
3098
3098
|
return {
|
|
3099
3099
|
x: t.x + n.dx,
|
|
3100
3100
|
y: t.y + n.dy
|
|
@@ -3104,11 +3104,11 @@ class pt extends Q {
|
|
|
3104
3104
|
* Get the position of the fixed corner (opposite of anchor) in world coordinates
|
|
3105
3105
|
*/
|
|
3106
3106
|
getFixedCornerWorldPosition(t, e) {
|
|
3107
|
-
const
|
|
3107
|
+
const i = this.getOppositeCornerLocalPosition(
|
|
3108
3108
|
t,
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
), s = this.calculateFrameCenterFromCropCenter(e), a = new
|
|
3109
|
+
x(e).width,
|
|
3110
|
+
x(e).height
|
|
3111
|
+
), s = this.calculateFrameCenterFromCropCenter(e), a = new P(e).localDeltaToWorld(i.x, i.y);
|
|
3112
3112
|
return {
|
|
3113
3113
|
x: s.x + a.dx,
|
|
3114
3114
|
y: s.y + a.dy
|
|
@@ -3118,12 +3118,12 @@ class pt extends Q {
|
|
|
3118
3118
|
* Calculate where the frame center would be after resize
|
|
3119
3119
|
* The opposite corner from the anchor stays fixed in world space
|
|
3120
3120
|
*/
|
|
3121
|
-
calculateFrameCenterAfterResize(t, e,
|
|
3122
|
-
const s = this.getFixedCornerWorldPosition(e,
|
|
3121
|
+
calculateFrameCenterAfterResize(t, e, i) {
|
|
3122
|
+
const s = this.getFixedCornerWorldPosition(e, i), o = x(i).width * t, a = o / this.imageAspectRatio, n = this.getOppositeCornerLocalPosition(e, o, a), l = new P({
|
|
3123
3123
|
x: 0,
|
|
3124
3124
|
// Will calculate frame center
|
|
3125
3125
|
y: 0,
|
|
3126
|
-
rotation:
|
|
3126
|
+
rotation: i.rotation
|
|
3127
3127
|
}).localDeltaToWorld(n.x, n.y);
|
|
3128
3128
|
return {
|
|
3129
3129
|
x: s.x - l.dx,
|
|
@@ -3135,19 +3135,19 @@ class pt extends Q {
|
|
|
3135
3135
|
* This is the core geometric calculation that determines where the crop zone
|
|
3136
3136
|
* would be positioned within the frame after resize.
|
|
3137
3137
|
*/
|
|
3138
|
-
calculateCropStateAtScale(t, e,
|
|
3139
|
-
const s =
|
|
3140
|
-
x:
|
|
3138
|
+
calculateCropStateAtScale(t, e, i) {
|
|
3139
|
+
const s = x(i).width * t, o = s / this.imageAspectRatio, a = x(i).cropWidth * x(i).width, n = x(i).cropHeight * x(i).height, h = a / s, l = n / o, c = this.calculateFrameCenterAfterResize(t, e, i), g = {
|
|
3140
|
+
x: i.x,
|
|
3141
3141
|
// In crop mode, this.x/y is the crop center
|
|
3142
|
-
y:
|
|
3143
|
-
}, d = g.x - c.x, f = g.y - c.y, m = new
|
|
3142
|
+
y: i.y
|
|
3143
|
+
}, d = g.x - c.x, f = g.y - c.y, m = new P({
|
|
3144
3144
|
x: c.x,
|
|
3145
3145
|
y: c.y,
|
|
3146
|
-
rotation:
|
|
3147
|
-
}).worldDeltaToLocal(d, f), p = s / 2 + m.dx, y =
|
|
3146
|
+
rotation: i.rotation
|
|
3147
|
+
}).worldDeltaToLocal(d, f), p = s / 2 + m.dx, y = o / 2 + m.dy, w = p / s - h / 2, S = y / o - l / 2;
|
|
3148
3148
|
return {
|
|
3149
|
-
cropX:
|
|
3150
|
-
cropY:
|
|
3149
|
+
cropX: w,
|
|
3150
|
+
cropY: S,
|
|
3151
3151
|
cropWidth: h,
|
|
3152
3152
|
cropHeight: l
|
|
3153
3153
|
};
|
|
@@ -3155,21 +3155,21 @@ class pt extends Q {
|
|
|
3155
3155
|
/**
|
|
3156
3156
|
* Check if a given scale keeps crop within frame bounds
|
|
3157
3157
|
*/
|
|
3158
|
-
isScaleValidForCropBounds(t, e,
|
|
3159
|
-
const
|
|
3160
|
-
if (
|
|
3158
|
+
isScaleValidForCropBounds(t, e, i) {
|
|
3159
|
+
const o = this.calculateCropStateAtScale(t, e, i);
|
|
3160
|
+
if (o.cropWidth > 1 + 1e-4 || o.cropHeight > 1 + 1e-4)
|
|
3161
3161
|
return !1;
|
|
3162
|
-
const a =
|
|
3162
|
+
const a = o.cropX, n = o.cropX + o.cropWidth, h = o.cropY, l = o.cropY + o.cropHeight;
|
|
3163
3163
|
return a >= -1e-4 && h >= -1e-4 && n <= 1 + 1e-4 && l <= 1 + 1e-4;
|
|
3164
3164
|
}
|
|
3165
3165
|
/**
|
|
3166
3166
|
* Calculate minimum scale that keeps crop within frame bounds
|
|
3167
3167
|
* Uses binary search to find the largest scale >= proposedScale that satisfies constraints
|
|
3168
3168
|
*/
|
|
3169
|
-
calculateMinScaleForCropBounds(t, e,
|
|
3170
|
-
if (this.isScaleValidForCropBounds(
|
|
3171
|
-
return
|
|
3172
|
-
let n =
|
|
3169
|
+
calculateMinScaleForCropBounds(t, e, i, s) {
|
|
3170
|
+
if (this.isScaleValidForCropBounds(i, t, e))
|
|
3171
|
+
return i;
|
|
3172
|
+
let n = i, h = s;
|
|
3173
3173
|
for (let l = 0; l < 20; l++) {
|
|
3174
3174
|
const c = (n + h) / 2;
|
|
3175
3175
|
if (this.isScaleValidForCropBounds(c, t, e) ? h = c : n = c, Math.abs(h - n) < 1e-4)
|
|
@@ -3181,15 +3181,15 @@ class pt extends Q {
|
|
|
3181
3181
|
* Remap anchor to account for flips
|
|
3182
3182
|
*/
|
|
3183
3183
|
remapAnchorForFlips(t, e) {
|
|
3184
|
-
let
|
|
3185
|
-
const s =
|
|
3186
|
-
return s && (
|
|
3184
|
+
let i = t;
|
|
3185
|
+
const s = x(e).flipHorizontal, o = x(e).flipVertical;
|
|
3186
|
+
return s && (i.includes("left") ? i = i.replace("left", "right") : i.includes("right") && (i = i.replace("right", "left"))), o && (i.includes("top") ? i = i.replace("top", "bottom") : i.includes("bottom") && (i = i.replace("bottom", "top"))), i;
|
|
3187
3187
|
}
|
|
3188
3188
|
/**
|
|
3189
3189
|
* Clone this element
|
|
3190
3190
|
*/
|
|
3191
3191
|
clone() {
|
|
3192
|
-
const t = this.toJSON(), { imageUrl: e, ...
|
|
3192
|
+
const t = this.toJSON(), { imageUrl: e, ...i } = t, s = new pt(i);
|
|
3193
3193
|
return s.imageUrl = this.imageUrl, s.imageElement = this.imageElement, s.imageLoaded = this.imageLoaded, s.imageAspectRatio = this.imageAspectRatio, s.isCropping = this.isCropping, s.onLoadCallback = this.onLoadCallback, s.isSvg = this.isSvg, s.imageLoadState = this.imageLoadState, s.imageLoadError = this.imageLoadError, s.preserveDimensions = this.preserveDimensions, s;
|
|
3194
3194
|
}
|
|
3195
3195
|
/**
|
|
@@ -3224,29 +3224,29 @@ class pt extends Q {
|
|
|
3224
3224
|
this.clearLoadTimeout(), this.releaseImageCache(), this.revokeSvgBlobUrl(), this.imageElement = null, this.onLoadCallback = null, this.imageLoadError = null;
|
|
3225
3225
|
}
|
|
3226
3226
|
}
|
|
3227
|
-
const
|
|
3228
|
-
let
|
|
3229
|
-
function
|
|
3227
|
+
const Nt = /* @__PURE__ */ new Map();
|
|
3228
|
+
let Tt = null;
|
|
3229
|
+
function Ut(r) {
|
|
3230
3230
|
return new Error(
|
|
3231
3231
|
`[paint-registry] no painter registered for ${r}. Element painting requires the rendering engine: import 'src/rendering/element-painters.js' (every paint driver — CanvasRenderer, ExportManager, ElementPreviewRenderer — does this; a direct element.render() call in a test must import it too).`
|
|
3232
3232
|
);
|
|
3233
3233
|
}
|
|
3234
|
-
function
|
|
3235
|
-
|
|
3234
|
+
function Fi(r, t) {
|
|
3235
|
+
Nt.set(r, t);
|
|
3236
3236
|
}
|
|
3237
3237
|
function gt(r) {
|
|
3238
|
-
const t =
|
|
3239
|
-
if (!t) throw
|
|
3238
|
+
const t = Nt.get(r);
|
|
3239
|
+
if (!t) throw Ut(`text transform "${r}"`);
|
|
3240
3240
|
return t;
|
|
3241
3241
|
}
|
|
3242
|
-
function
|
|
3243
|
-
|
|
3242
|
+
function Ai(r) {
|
|
3243
|
+
Tt = r;
|
|
3244
3244
|
}
|
|
3245
|
-
function
|
|
3246
|
-
if (!
|
|
3247
|
-
return
|
|
3245
|
+
function Ae() {
|
|
3246
|
+
if (!Tt) throw Ut("group clipping");
|
|
3247
|
+
return Tt;
|
|
3248
3248
|
}
|
|
3249
|
-
class
|
|
3249
|
+
class L {
|
|
3250
3250
|
constructor(t = []) {
|
|
3251
3251
|
this.spans = t.length > 0 ? t.map((e) => ({ ...e, style: { ...e.style } })) : [{ text: "", style: {} }], this.normalize();
|
|
3252
3252
|
}
|
|
@@ -3254,7 +3254,7 @@ class P {
|
|
|
3254
3254
|
* Create RichText from plain text string (no special formatting)
|
|
3255
3255
|
*/
|
|
3256
3256
|
static fromPlainText(t, e = {}) {
|
|
3257
|
-
return new
|
|
3257
|
+
return new L([{ text: t, style: e }]);
|
|
3258
3258
|
}
|
|
3259
3259
|
/**
|
|
3260
3260
|
* Get the full text content (all spans concatenated)
|
|
@@ -3277,10 +3277,10 @@ class P {
|
|
|
3277
3277
|
if (this.spans.length === 0) return {};
|
|
3278
3278
|
if (t < 0) return this.spans[0].style;
|
|
3279
3279
|
let e = 0;
|
|
3280
|
-
for (const
|
|
3281
|
-
if (t < e +
|
|
3282
|
-
return
|
|
3283
|
-
e +=
|
|
3280
|
+
for (const i of this.spans) {
|
|
3281
|
+
if (t < e + i.text.length)
|
|
3282
|
+
return i.style;
|
|
3283
|
+
e += i.text.length;
|
|
3284
3284
|
}
|
|
3285
3285
|
return this.spans[this.spans.length - 1].style;
|
|
3286
3286
|
}
|
|
@@ -3290,19 +3290,19 @@ class P {
|
|
|
3290
3290
|
* @param end End index (exclusive)
|
|
3291
3291
|
* @param style Style to apply (merged with existing styles)
|
|
3292
3292
|
*/
|
|
3293
|
-
applyStyle(t, e,
|
|
3293
|
+
applyStyle(t, e, i) {
|
|
3294
3294
|
if (t >= e || t < 0 || e > this.getLength())
|
|
3295
3295
|
return;
|
|
3296
3296
|
const s = [];
|
|
3297
|
-
let
|
|
3297
|
+
let o = 0;
|
|
3298
3298
|
for (const a of this.spans) {
|
|
3299
|
-
const n =
|
|
3299
|
+
const n = o, h = o + a.text.length;
|
|
3300
3300
|
if (h <= t) {
|
|
3301
|
-
s.push(a),
|
|
3301
|
+
s.push(a), o = h;
|
|
3302
3302
|
continue;
|
|
3303
3303
|
}
|
|
3304
3304
|
if (n >= e) {
|
|
3305
|
-
s.push(a),
|
|
3305
|
+
s.push(a), o = h;
|
|
3306
3306
|
continue;
|
|
3307
3307
|
}
|
|
3308
3308
|
const l = Math.max(t, n), c = Math.min(e, h);
|
|
@@ -3311,11 +3311,11 @@ class P {
|
|
|
3311
3311
|
style: a.style
|
|
3312
3312
|
}), s.push({
|
|
3313
3313
|
text: a.text.substring(l - n, c - n),
|
|
3314
|
-
style: { ...a.style, ...
|
|
3314
|
+
style: { ...a.style, ...i }
|
|
3315
3315
|
}), c < h && s.push({
|
|
3316
3316
|
text: a.text.substring(c - n),
|
|
3317
3317
|
style: a.style
|
|
3318
|
-
}),
|
|
3318
|
+
}), o = h;
|
|
3319
3319
|
}
|
|
3320
3320
|
this.spans = s, this.normalize();
|
|
3321
3321
|
}
|
|
@@ -3325,26 +3325,26 @@ class P {
|
|
|
3325
3325
|
* @param text Text to insert
|
|
3326
3326
|
* @param style Style for the inserted text
|
|
3327
3327
|
*/
|
|
3328
|
-
insert(t, e,
|
|
3328
|
+
insert(t, e, i) {
|
|
3329
3329
|
if (e.length === 0) return;
|
|
3330
3330
|
const s = [];
|
|
3331
|
-
let
|
|
3331
|
+
let o = 0;
|
|
3332
3332
|
for (const a of this.spans) {
|
|
3333
|
-
const n =
|
|
3334
|
-
if (t <= n && s.length === 0 && s.push({ text: e, style:
|
|
3333
|
+
const n = o, h = o + a.text.length;
|
|
3334
|
+
if (t <= n && s.length === 0 && s.push({ text: e, style: i }), t > n && t <= h) {
|
|
3335
3335
|
const l = t - n;
|
|
3336
3336
|
s.push({
|
|
3337
3337
|
text: a.text.substring(0, l),
|
|
3338
3338
|
style: a.style
|
|
3339
|
-
}), s.push({ text: e, style:
|
|
3339
|
+
}), s.push({ text: e, style: i }), s.push({
|
|
3340
3340
|
text: a.text.substring(l),
|
|
3341
3341
|
style: a.style
|
|
3342
|
-
}),
|
|
3342
|
+
}), o = h;
|
|
3343
3343
|
continue;
|
|
3344
3344
|
}
|
|
3345
|
-
s.push(a),
|
|
3345
|
+
s.push(a), o = h;
|
|
3346
3346
|
}
|
|
3347
|
-
t >= this.getLength() && !s.some((a) => a.text === e) && s.push({ text: e, style:
|
|
3347
|
+
t >= this.getLength() && !s.some((a) => a.text === e) && s.push({ text: e, style: i }), this.spans = s, this.normalize();
|
|
3348
3348
|
}
|
|
3349
3349
|
/**
|
|
3350
3350
|
* Delete text in a character range
|
|
@@ -3352,19 +3352,19 @@ class P {
|
|
|
3352
3352
|
* @param end End index (exclusive)
|
|
3353
3353
|
*/
|
|
3354
3354
|
delete(t, e) {
|
|
3355
|
-
const
|
|
3356
|
-
if (t = Math.max(0, Math.min(t,
|
|
3355
|
+
const i = this.getLength();
|
|
3356
|
+
if (t = Math.max(0, Math.min(t, i)), e = Math.max(0, Math.min(e, i)), t >= e)
|
|
3357
3357
|
return;
|
|
3358
3358
|
const s = [];
|
|
3359
|
-
let
|
|
3359
|
+
let o = 0;
|
|
3360
3360
|
for (const a of this.spans) {
|
|
3361
|
-
const n =
|
|
3361
|
+
const n = o, h = o + a.text.length;
|
|
3362
3362
|
if (h <= t) {
|
|
3363
|
-
s.push(a),
|
|
3363
|
+
s.push(a), o = h;
|
|
3364
3364
|
continue;
|
|
3365
3365
|
}
|
|
3366
3366
|
if (n >= e) {
|
|
3367
|
-
s.push(a),
|
|
3367
|
+
s.push(a), o = h;
|
|
3368
3368
|
continue;
|
|
3369
3369
|
}
|
|
3370
3370
|
const l = Math.max(t, n), c = Math.min(e, h);
|
|
@@ -3374,7 +3374,7 @@ class P {
|
|
|
3374
3374
|
}), c < h && s.push({
|
|
3375
3375
|
text: a.text.substring(c - n),
|
|
3376
3376
|
style: a.style
|
|
3377
|
-
}),
|
|
3377
|
+
}), o = h;
|
|
3378
3378
|
}
|
|
3379
3379
|
this.spans = s.length > 0 ? s : [{ text: "", style: {} }], this.normalize();
|
|
3380
3380
|
}
|
|
@@ -3385,15 +3385,15 @@ class P {
|
|
|
3385
3385
|
* This prevents fragmentation and improves performance
|
|
3386
3386
|
*/
|
|
3387
3387
|
normalize() {
|
|
3388
|
-
if (this.spans = this.spans.filter((
|
|
3388
|
+
if (this.spans = this.spans.filter((i) => i.text !== ""), this.spans.length === 0) {
|
|
3389
3389
|
this.spans = [{ text: "", style: {} }];
|
|
3390
3390
|
return;
|
|
3391
3391
|
}
|
|
3392
3392
|
if (this.spans.length <= 1) return;
|
|
3393
3393
|
const t = [];
|
|
3394
3394
|
let e = this.spans[0];
|
|
3395
|
-
for (let
|
|
3396
|
-
const s = this.spans[
|
|
3395
|
+
for (let i = 1; i < this.spans.length; i++) {
|
|
3396
|
+
const s = this.spans[i];
|
|
3397
3397
|
this.stylesEqual(e.style, s.style) ? e = {
|
|
3398
3398
|
text: e.text + s.text,
|
|
3399
3399
|
style: e.style
|
|
@@ -3405,13 +3405,13 @@ class P {
|
|
|
3405
3405
|
* Check if two styles are equal
|
|
3406
3406
|
*/
|
|
3407
3407
|
stylesEqual(t, e) {
|
|
3408
|
-
return t.color === e.color && t.fontFamily === e.fontFamily && t.fontSize === e.fontSize && t.bold === e.bold && t.italic === e.italic && t.underline === e.underline && t.strikethrough === e.strikethrough;
|
|
3408
|
+
return t.color === e.color && t.fontFamily === e.fontFamily && t.fontSize === e.fontSize && t.bold === e.bold && t.italic === e.italic && t.underline === e.underline && t.strikethrough === e.strikethrough && t.letterSpacing === e.letterSpacing;
|
|
3409
3409
|
}
|
|
3410
3410
|
/**
|
|
3411
3411
|
* Clone this RichText instance
|
|
3412
3412
|
*/
|
|
3413
3413
|
clone() {
|
|
3414
|
-
return new
|
|
3414
|
+
return new L(
|
|
3415
3415
|
this.spans.map((t) => ({
|
|
3416
3416
|
text: t.text,
|
|
3417
3417
|
style: { ...t.style }
|
|
@@ -3439,74 +3439,74 @@ class P {
|
|
|
3439
3439
|
* Deserialize from JSON
|
|
3440
3440
|
*/
|
|
3441
3441
|
static fromJSON(t) {
|
|
3442
|
-
return new
|
|
3442
|
+
return new L(t.spans);
|
|
3443
3443
|
}
|
|
3444
3444
|
}
|
|
3445
|
-
function
|
|
3445
|
+
function Mi(r) {
|
|
3446
3446
|
return r.type === "custom";
|
|
3447
3447
|
}
|
|
3448
|
-
function
|
|
3448
|
+
function Di(r) {
|
|
3449
3449
|
return r.type === "circle";
|
|
3450
3450
|
}
|
|
3451
|
-
function
|
|
3451
|
+
function Ii(r) {
|
|
3452
3452
|
return r.type === "arch";
|
|
3453
3453
|
}
|
|
3454
|
-
function
|
|
3454
|
+
function ki(r) {
|
|
3455
3455
|
return r.type === "wave";
|
|
3456
3456
|
}
|
|
3457
|
-
function
|
|
3457
|
+
function Ei(r) {
|
|
3458
3458
|
return r.type === "flag";
|
|
3459
3459
|
}
|
|
3460
|
-
function
|
|
3460
|
+
function Oi(r) {
|
|
3461
3461
|
return r.type === "image";
|
|
3462
3462
|
}
|
|
3463
|
-
function
|
|
3463
|
+
function Bi(r) {
|
|
3464
3464
|
return r.type === "group";
|
|
3465
3465
|
}
|
|
3466
|
-
function
|
|
3466
|
+
function Ri(r) {
|
|
3467
3467
|
return r.transformType !== "image" && r.transformType !== "group";
|
|
3468
3468
|
}
|
|
3469
|
-
function
|
|
3469
|
+
function Hi(r) {
|
|
3470
3470
|
return r.transformType === "image";
|
|
3471
3471
|
}
|
|
3472
|
-
function
|
|
3472
|
+
function Pi(r) {
|
|
3473
3473
|
return r.transformType === "custom";
|
|
3474
3474
|
}
|
|
3475
|
-
function
|
|
3475
|
+
function Li(r) {
|
|
3476
3476
|
return r.transformType === "circle";
|
|
3477
3477
|
}
|
|
3478
|
-
function
|
|
3478
|
+
function Wi(r) {
|
|
3479
3479
|
return r.transformType === "group";
|
|
3480
3480
|
}
|
|
3481
|
-
function
|
|
3481
|
+
function zi(r) {
|
|
3482
3482
|
return r.transformType === "shape";
|
|
3483
3483
|
}
|
|
3484
|
-
function
|
|
3484
|
+
function Xi(r) {
|
|
3485
3485
|
return r.transformType === "path";
|
|
3486
3486
|
}
|
|
3487
|
-
function
|
|
3487
|
+
function Yi(r) {
|
|
3488
3488
|
return r.type === "shape";
|
|
3489
3489
|
}
|
|
3490
|
-
function
|
|
3490
|
+
function _i(r) {
|
|
3491
3491
|
return r.type === "path";
|
|
3492
3492
|
}
|
|
3493
|
-
function
|
|
3493
|
+
function Ni(r) {
|
|
3494
3494
|
var t;
|
|
3495
3495
|
return ((t = r.stroke) == null ? void 0 : t.enabled) === !0;
|
|
3496
3496
|
}
|
|
3497
|
-
function
|
|
3497
|
+
function Ui(r) {
|
|
3498
3498
|
return Array.isArray(r.masks) && r.masks.length > 0;
|
|
3499
3499
|
}
|
|
3500
|
-
function
|
|
3500
|
+
function Gi(r) {
|
|
3501
3501
|
return r.blendMode === "knockout" || r.blendMode === "clip";
|
|
3502
3502
|
}
|
|
3503
|
-
function
|
|
3503
|
+
function $i(r) {
|
|
3504
3504
|
var t;
|
|
3505
3505
|
return ((t = r.distressEffect) == null ? void 0 : t.enabled) === !0;
|
|
3506
3506
|
}
|
|
3507
3507
|
class q extends Q {
|
|
3508
3508
|
constructor(t = {}) {
|
|
3509
|
-
super(t), this.transformType = t.transformType || "custom", this.fontSize = t.fontSize || 72, this.fontFamily = t.fontFamily || "Arial", this.color = t.color || "#333333", this.bold = t.bold !== void 0 ? t.bold : !1, this.italic = t.italic !== void 0 ? t.italic : !1, this.underline = t.underline !== void 0 ? t.underline : !1, this.strikethrough = t.strikethrough !== void 0 ? t.strikethrough : !1, this.textAlign = t.textAlign || "center", t.richText ? (t.richText instanceof
|
|
3509
|
+
super(t), this.transformType = t.transformType || "custom", this.fontSize = t.fontSize || 72, this.fontFamily = t.fontFamily || "Arial", this.color = t.color || "#333333", this.bold = t.bold !== void 0 ? t.bold : !1, this.italic = t.italic !== void 0 ? t.italic : !1, this.underline = t.underline !== void 0 ? t.underline : !1, this.strikethrough = t.strikethrough !== void 0 ? t.strikethrough : !1, this.textAlign = t.textAlign || "center", this.letterSpacing = t.letterSpacing, this.lineHeight = t.lineHeight, t.richText ? (t.richText instanceof L ? this.richText = t.richText : this.richText = L.fromJSON(t.richText), this.text = this.richText.getText()) : t.text !== void 0 ? (this.text = t.text, this.richText = L.fromPlainText(t.text, {})) : (this.text = "Text", this.richText = L.fromPlainText("Text", {})), this.glyphOverrides = t.glyphOverrides, this.openTypeFeatures = t.openTypeFeatures;
|
|
3510
3510
|
}
|
|
3511
3511
|
/**
|
|
3512
3512
|
* Get bounding box in world coordinates
|
|
@@ -3524,7 +3524,7 @@ class q extends Q {
|
|
|
3524
3524
|
* statically imports the paint pipeline. Selection and hover visuals are
|
|
3525
3525
|
* handled by SelectionRenderer and HoverRenderer.
|
|
3526
3526
|
*/
|
|
3527
|
-
render(t, e = !1,
|
|
3527
|
+
render(t, e = !1, i = !1) {
|
|
3528
3528
|
const s = t.globalAlpha;
|
|
3529
3529
|
this.opacity !== void 0 && this.opacity !== 1 && (t.globalAlpha = this.opacity), gt(this.transformType)(t, this.toJSON()), t.globalAlpha = s;
|
|
3530
3530
|
}
|
|
@@ -3547,6 +3547,8 @@ class q extends Q {
|
|
|
3547
3547
|
underline: this.underline,
|
|
3548
3548
|
strikethrough: this.strikethrough,
|
|
3549
3549
|
// Typography properties (only include if defined)
|
|
3550
|
+
...this.letterSpacing !== void 0 && { letterSpacing: this.letterSpacing },
|
|
3551
|
+
...this.lineHeight !== void 0 && { lineHeight: this.lineHeight },
|
|
3550
3552
|
...this.openTypeFeatures && { openTypeFeatures: { ...this.openTypeFeatures } },
|
|
3551
3553
|
...this.glyphOverrides && { glyphOverrides: this.glyphOverrides.map((e) => ({ ...e })) }
|
|
3552
3554
|
};
|
|
@@ -3563,7 +3565,7 @@ class q extends Q {
|
|
|
3563
3565
|
* @param newText - Plain text to set (resets to element defaults)
|
|
3564
3566
|
*/
|
|
3565
3567
|
setText(t) {
|
|
3566
|
-
this.text = t, this.richText =
|
|
3568
|
+
this.text = t, this.richText = L.fromPlainText(t, {});
|
|
3567
3569
|
}
|
|
3568
3570
|
/**
|
|
3569
3571
|
* Get the plain text content
|
|
@@ -3576,7 +3578,7 @@ class q extends Q {
|
|
|
3576
3578
|
* Get the rich text object
|
|
3577
3579
|
*/
|
|
3578
3580
|
getRichText() {
|
|
3579
|
-
return this.richText || (this.richText =
|
|
3581
|
+
return this.richText || (this.richText = L.fromPlainText(this.text, {})), this.richText;
|
|
3580
3582
|
}
|
|
3581
3583
|
/**
|
|
3582
3584
|
* Set the rich text object
|
|
@@ -3595,21 +3597,22 @@ class q extends Q {
|
|
|
3595
3597
|
bold: this.bold,
|
|
3596
3598
|
italic: this.italic,
|
|
3597
3599
|
underline: this.underline,
|
|
3598
|
-
strikethrough: this.strikethrough
|
|
3600
|
+
strikethrough: this.strikethrough,
|
|
3601
|
+
...this.letterSpacing !== void 0 && { letterSpacing: this.letterSpacing }
|
|
3599
3602
|
};
|
|
3600
3603
|
}
|
|
3601
3604
|
/**
|
|
3602
3605
|
* Apply character-level formatting to a text range
|
|
3603
3606
|
*/
|
|
3604
|
-
applyFormatting(t, e,
|
|
3607
|
+
applyFormatting(t, e, i) {
|
|
3605
3608
|
const s = this.getRichText();
|
|
3606
|
-
s.applyStyle(t, e,
|
|
3609
|
+
s.applyStyle(t, e, i), this.text = s.getText();
|
|
3607
3610
|
}
|
|
3608
3611
|
/**
|
|
3609
3612
|
* Update font size
|
|
3610
3613
|
*/
|
|
3611
3614
|
setFontSize(t) {
|
|
3612
|
-
this.fontSize = Math.max(
|
|
3615
|
+
this.fontSize = Math.max(pe, Math.min(ye, t));
|
|
3613
3616
|
}
|
|
3614
3617
|
/**
|
|
3615
3618
|
* Update color
|
|
@@ -3618,8 +3621,8 @@ class q extends Q {
|
|
|
3618
3621
|
setColor(t) {
|
|
3619
3622
|
const e = this.color;
|
|
3620
3623
|
if (this.color = t, this.richText)
|
|
3621
|
-
for (let
|
|
3622
|
-
const s = this.richText.spans[
|
|
3624
|
+
for (let i = 0; i < this.richText.spans.length; i++) {
|
|
3625
|
+
const s = this.richText.spans[i];
|
|
3623
3626
|
(s.style.color === void 0 || s.style.color === e) && (s.style.color = t);
|
|
3624
3627
|
}
|
|
3625
3628
|
}
|
|
@@ -3627,7 +3630,7 @@ class q extends Q {
|
|
|
3627
3630
|
* Handle resize transform
|
|
3628
3631
|
* Must be implemented by subclasses
|
|
3629
3632
|
*/
|
|
3630
|
-
resize(t, e,
|
|
3633
|
+
resize(t, e, i, s) {
|
|
3631
3634
|
throw new Error("resize() must be implemented by subclass");
|
|
3632
3635
|
}
|
|
3633
3636
|
/**
|
|
@@ -3643,8 +3646,50 @@ class q extends Q {
|
|
|
3643
3646
|
};
|
|
3644
3647
|
}
|
|
3645
3648
|
}
|
|
3649
|
+
function Me(r) {
|
|
3650
|
+
return Array.from(r).length;
|
|
3651
|
+
}
|
|
3652
|
+
function yt(r, t, e) {
|
|
3653
|
+
return e ? r + e * Me(t) : r;
|
|
3654
|
+
}
|
|
3655
|
+
function De(r, t, e) {
|
|
3656
|
+
const i = Array.from(t), s = [0];
|
|
3657
|
+
let o = "";
|
|
3658
|
+
for (let a = 0; a < i.length; a++)
|
|
3659
|
+
o += i[a], s.push(r.measureText(o).width + e * (a + 1));
|
|
3660
|
+
return s;
|
|
3661
|
+
}
|
|
3662
|
+
function Ie(r, t, e) {
|
|
3663
|
+
switch (r.textAlign) {
|
|
3664
|
+
case "center":
|
|
3665
|
+
return t - e / 2;
|
|
3666
|
+
case "right":
|
|
3667
|
+
case "end":
|
|
3668
|
+
return t - e;
|
|
3669
|
+
default:
|
|
3670
|
+
return t;
|
|
3671
|
+
}
|
|
3672
|
+
}
|
|
3673
|
+
function Gt(r, t, e, i, s, o) {
|
|
3674
|
+
if (!o || e.length === 0) {
|
|
3675
|
+
t[r](e, i, s);
|
|
3676
|
+
return;
|
|
3677
|
+
}
|
|
3678
|
+
const a = De(t, e, o), n = a[a.length - 1], h = Ie(t, i, n), l = t.textAlign;
|
|
3679
|
+
t.textAlign = "left";
|
|
3680
|
+
const c = Array.from(e);
|
|
3681
|
+
for (let g = 0; g < c.length; g++)
|
|
3682
|
+
t[r](c[g], h + a[g], s);
|
|
3683
|
+
t.textAlign = l;
|
|
3684
|
+
}
|
|
3685
|
+
function Vi(r, t, e, i, s) {
|
|
3686
|
+
Gt("fillText", r, t, e, i, s);
|
|
3687
|
+
}
|
|
3688
|
+
function Ji(r, t, e, i, s) {
|
|
3689
|
+
Gt("strokeText", r, t, e, i, s);
|
|
3690
|
+
}
|
|
3646
3691
|
let ht = null;
|
|
3647
|
-
function
|
|
3692
|
+
function wt() {
|
|
3648
3693
|
if (!ht)
|
|
3649
3694
|
if (typeof document < "u")
|
|
3650
3695
|
ht = document.createElement("canvas");
|
|
@@ -3654,123 +3699,125 @@ function yt() {
|
|
|
3654
3699
|
throw new Error("No canvas available for text measurement");
|
|
3655
3700
|
return ht;
|
|
3656
3701
|
}
|
|
3657
|
-
function at(r, t, e = !1,
|
|
3702
|
+
function at(r, t, e = !1, i = !1) {
|
|
3658
3703
|
const s = [];
|
|
3659
|
-
return
|
|
3704
|
+
return i && s.push("italic"), e && s.push("bold"), s.push(`${r}px`), s.push(t), s.join(" ");
|
|
3660
3705
|
}
|
|
3661
|
-
function
|
|
3662
|
-
const
|
|
3663
|
-
|
|
3706
|
+
function Ft(r, t, e, i, s = !1, o = !1, a, n = !1, h) {
|
|
3707
|
+
const c = wt().getContext("2d");
|
|
3708
|
+
c.font = at(e, i, s, o);
|
|
3709
|
+
const g = (h == null ? void 0 : h.letterSpacing) ?? 0, d = (A) => yt(c.measureText(A).width, A, g);
|
|
3710
|
+
if (r.trim().length === 0)
|
|
3664
3711
|
return [r];
|
|
3665
3712
|
if (r.includes(`
|
|
3666
3713
|
`)) {
|
|
3667
|
-
const
|
|
3714
|
+
const A = r.split(`
|
|
3668
3715
|
`), k = [];
|
|
3669
|
-
for (let
|
|
3670
|
-
const
|
|
3671
|
-
k.push(...
|
|
3716
|
+
for (let R = 0; R < A.length; R++) {
|
|
3717
|
+
const H = A[R], E = Ft(H, t, e, i, s, o, void 0, n, h);
|
|
3718
|
+
k.push(...E);
|
|
3672
3719
|
}
|
|
3673
3720
|
return k;
|
|
3674
3721
|
}
|
|
3675
|
-
const
|
|
3722
|
+
const f = r.match(/^\s*/), u = r.match(/\s*$/), m = f ? f[0] : "", p = u ? u[0] : "", w = r.substring(m.length, r.length - p.length).split(" ");
|
|
3676
3723
|
if (a !== void 0 && a > 0) {
|
|
3677
3724
|
if (a === 1)
|
|
3678
|
-
return [
|
|
3679
|
-
const
|
|
3680
|
-
for (let
|
|
3681
|
-
const
|
|
3682
|
-
|
|
3725
|
+
return [m + w.join(" ") + p];
|
|
3726
|
+
const A = [], k = Math.ceil(w.length / a);
|
|
3727
|
+
for (let R = 0; R < w.length; R += k) {
|
|
3728
|
+
const H = w.slice(R, R + k);
|
|
3729
|
+
A.push(H.join(" "));
|
|
3683
3730
|
}
|
|
3684
|
-
return
|
|
3685
|
-
}
|
|
3686
|
-
const
|
|
3687
|
-
if (
|
|
3688
|
-
return [
|
|
3689
|
-
const
|
|
3690
|
-
let
|
|
3691
|
-
const
|
|
3692
|
-
for (let
|
|
3693
|
-
const k =
|
|
3694
|
-
if (
|
|
3695
|
-
|
|
3696
|
-
const
|
|
3697
|
-
let
|
|
3698
|
-
for (const
|
|
3699
|
-
const
|
|
3700
|
-
|
|
3731
|
+
return A.length > 0 && (A[0] = m + A[0], A[A.length - 1] = A[A.length - 1] + p), A;
|
|
3732
|
+
}
|
|
3733
|
+
const S = w.join(" "), b = m + S + p, T = d(b), C = t < 200, F = n ? 0 : Math.max(20, t * (n ? 0 : C ? 0.08 : 0.05));
|
|
3734
|
+
if (T <= t + F)
|
|
3735
|
+
return [b];
|
|
3736
|
+
const v = [];
|
|
3737
|
+
let D = "";
|
|
3738
|
+
const B = n ? 0 : Math.max(15, t * (n ? 0 : C ? 0.05 : 0.03));
|
|
3739
|
+
for (let A = 0; A < w.length; A++) {
|
|
3740
|
+
const k = w[A];
|
|
3741
|
+
if (d(k) > t + B) {
|
|
3742
|
+
D.length > 0 && (v.push(D), D = "");
|
|
3743
|
+
const H = Array.from(k);
|
|
3744
|
+
let E = "";
|
|
3745
|
+
for (const W of H) {
|
|
3746
|
+
const z = E + W;
|
|
3747
|
+
d(z) > t + B && E.length > 0 ? (v.push(E), E = W) : E = z;
|
|
3701
3748
|
}
|
|
3702
|
-
|
|
3749
|
+
D = E;
|
|
3703
3750
|
} else {
|
|
3704
|
-
const
|
|
3705
|
-
|
|
3751
|
+
const H = D.length > 0 ? D + " " + k : k;
|
|
3752
|
+
d(H) > t + B && D.length > 0 ? (v.push(D), D = k) : D = H;
|
|
3706
3753
|
}
|
|
3707
3754
|
}
|
|
3708
|
-
if (
|
|
3709
|
-
if (
|
|
3710
|
-
const
|
|
3711
|
-
|
|
3755
|
+
if (D.length > 0 && v.push(D), v.length > 0) {
|
|
3756
|
+
if (m.length > 0) {
|
|
3757
|
+
const A = m + v[0];
|
|
3758
|
+
d(A) > t + B ? v.unshift(m) : v[0] = A;
|
|
3712
3759
|
}
|
|
3713
|
-
if (
|
|
3714
|
-
const
|
|
3715
|
-
|
|
3760
|
+
if (p.length > 0) {
|
|
3761
|
+
const A = v.length - 1, k = v[A] + p;
|
|
3762
|
+
d(k) > t + B ? v.push(p) : v[A] = k;
|
|
3716
3763
|
}
|
|
3717
3764
|
}
|
|
3718
|
-
return
|
|
3765
|
+
return v;
|
|
3719
3766
|
}
|
|
3720
|
-
function
|
|
3721
|
-
const
|
|
3722
|
-
return
|
|
3767
|
+
function Bt(r, t, e, i = !1, s = !1, o = 0) {
|
|
3768
|
+
const n = wt().getContext("2d");
|
|
3769
|
+
return n.font = at(t, e, i, s), yt(n.measureText(r).width, r, o);
|
|
3723
3770
|
}
|
|
3724
|
-
function
|
|
3725
|
-
const
|
|
3726
|
-
|
|
3727
|
-
const n =
|
|
3771
|
+
function vt(r, t, e = !1, i = !1) {
|
|
3772
|
+
const o = wt().getContext("2d");
|
|
3773
|
+
o.font = at(r, t, e, i);
|
|
3774
|
+
const n = o.measureText("ÁÉÍgjpqy"), h = n.actualBoundingBoxAscent || r * 0.8, l = n.actualBoundingBoxDescent || r * 0.2, c = h + l;
|
|
3728
3775
|
return { ascent: h, descent: l, height: c };
|
|
3729
3776
|
}
|
|
3730
|
-
function
|
|
3731
|
-
const h =
|
|
3732
|
-
`),
|
|
3733
|
-
isParagraphStart: !
|
|
3734
|
-
isParagraphEnd: !
|
|
3735
|
-
})),
|
|
3736
|
-
|
|
3737
|
-
let f = 0;
|
|
3738
|
-
const u = Tt(e, o, s, i);
|
|
3777
|
+
function Rt(r, t, e, i, s = !1, o = !1, a, n = !1, h) {
|
|
3778
|
+
const l = (h == null ? void 0 : h.letterSpacing) ?? 0, c = Ft(r, t, e, i, s, o, a, n, h), g = r.includes(`
|
|
3779
|
+
`), d = c.map((b, T) => ({
|
|
3780
|
+
isParagraphStart: !g && T === 0,
|
|
3781
|
+
isParagraphEnd: !g && T === c.length - 1
|
|
3782
|
+
})), u = wt().getContext("2d");
|
|
3783
|
+
u.font = at(e, i, s, o);
|
|
3739
3784
|
let m = 0;
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
|
|
3785
|
+
const p = vt(e, i, s, o);
|
|
3786
|
+
let y = 0;
|
|
3787
|
+
c.forEach((b, T) => {
|
|
3788
|
+
const C = d[T].isParagraphStart, M = d[T].isParagraphEnd;
|
|
3789
|
+
let F = b;
|
|
3790
|
+
if (!C) {
|
|
3791
|
+
const v = b.match(/^ +/), D = v ? v[0].length : 0;
|
|
3792
|
+
D > 0 && (F = F.substring(D));
|
|
3746
3793
|
}
|
|
3747
|
-
if (!
|
|
3748
|
-
const
|
|
3749
|
-
|
|
3794
|
+
if (!M) {
|
|
3795
|
+
const v = F.match(/ +$/), D = v ? v[0].length : 0;
|
|
3796
|
+
D > 0 && (F = F.substring(0, F.length - D));
|
|
3750
3797
|
}
|
|
3751
|
-
if (
|
|
3752
|
-
const
|
|
3753
|
-
|
|
3798
|
+
if (y++, F.length > 0) {
|
|
3799
|
+
const v = yt(u.measureText(F).width, F, l);
|
|
3800
|
+
m = Math.max(m, v);
|
|
3754
3801
|
}
|
|
3755
3802
|
});
|
|
3756
|
-
let
|
|
3757
|
-
const
|
|
3758
|
-
if (
|
|
3759
|
-
|
|
3760
|
-
else if (
|
|
3761
|
-
|
|
3803
|
+
let w;
|
|
3804
|
+
const S = (h == null ? void 0 : h.lineHeight) ?? Yt;
|
|
3805
|
+
if (y === 1)
|
|
3806
|
+
w = p.height;
|
|
3807
|
+
else if (y === 0)
|
|
3808
|
+
w = 0;
|
|
3762
3809
|
else {
|
|
3763
|
-
const
|
|
3764
|
-
|
|
3810
|
+
const b = e * S;
|
|
3811
|
+
w = (y - 1) * b + p.height;
|
|
3765
3812
|
}
|
|
3766
3813
|
return {
|
|
3767
|
-
width:
|
|
3768
|
-
height:
|
|
3769
|
-
lines:
|
|
3814
|
+
width: m,
|
|
3815
|
+
height: w,
|
|
3816
|
+
lines: c
|
|
3770
3817
|
};
|
|
3771
3818
|
}
|
|
3772
3819
|
let lt = null;
|
|
3773
|
-
function
|
|
3820
|
+
function ke() {
|
|
3774
3821
|
if (!lt)
|
|
3775
3822
|
if (typeof OffscreenCanvas < "u")
|
|
3776
3823
|
lt = new OffscreenCanvas(1, 1).getContext("2d");
|
|
@@ -3780,19 +3827,19 @@ function ve() {
|
|
|
3780
3827
|
throw new Error("No canvas context available");
|
|
3781
3828
|
return lt;
|
|
3782
3829
|
}
|
|
3783
|
-
function
|
|
3784
|
-
const
|
|
3785
|
-
const
|
|
3786
|
-
return
|
|
3787
|
-
}, a = (p, y) => p.fontSize === y.fontSize && p.fontFamily === y.fontFamily && p.color === y.color && p.bold === y.bold && p.italic === y.italic && p.underline === y.underline && p.strikethrough === y.strikethrough, n = [];
|
|
3830
|
+
function Ee(r, t, e) {
|
|
3831
|
+
const i = ke(), s = [], o = (p, y) => {
|
|
3832
|
+
const w = y.fontSize || e.fontSize, S = y.fontFamily || e.fontFamily, b = y.bold !== void 0 ? y.bold : e.bold || !1, T = y.italic !== void 0 ? y.italic : e.italic || !1, C = y.letterSpacing !== void 0 ? y.letterSpacing : e.letterSpacing ?? 0;
|
|
3833
|
+
return i.font = at(w, S, b, T), yt(i.measureText(p).width, p, C);
|
|
3834
|
+
}, a = (p, y) => p.fontSize === y.fontSize && p.fontFamily === y.fontFamily && p.color === y.color && p.bold === y.bold && p.italic === y.italic && p.underline === y.underline && p.strikethrough === y.strikethrough && p.letterSpacing === y.letterSpacing, n = [];
|
|
3788
3835
|
r.forEach((p) => {
|
|
3789
3836
|
n.length > 0 && a(n[n.length - 1].style, p.style) ? n[n.length - 1].text += p.text : n.push({ text: p.text, style: p.style });
|
|
3790
3837
|
});
|
|
3791
3838
|
let h = "";
|
|
3792
3839
|
const l = [];
|
|
3793
3840
|
n.forEach((p, y) => {
|
|
3794
|
-
for (let
|
|
3795
|
-
h += p.text[
|
|
3841
|
+
for (let w = 0; w < p.text.length; w++)
|
|
3842
|
+
h += p.text[w], l.push(y);
|
|
3796
3843
|
});
|
|
3797
3844
|
const c = [];
|
|
3798
3845
|
let g = "", d = 0;
|
|
@@ -3806,79 +3853,79 @@ function Fe(r, t, e) {
|
|
|
3806
3853
|
f.length > 0 && (s.push(f), f = [], u = 0);
|
|
3807
3854
|
};
|
|
3808
3855
|
return c.forEach((p, y) => {
|
|
3809
|
-
const
|
|
3810
|
-
let
|
|
3811
|
-
for (let
|
|
3812
|
-
const
|
|
3813
|
-
|
|
3856
|
+
const w = [];
|
|
3857
|
+
let S = l[p.startIdx], b = "";
|
|
3858
|
+
for (let C = p.startIdx; C <= p.endIdx; C++) {
|
|
3859
|
+
const M = l[C];
|
|
3860
|
+
M !== S ? (w.push({ text: b, style: n[S].style }), b = h[C], S = M) : b += h[C];
|
|
3814
3861
|
}
|
|
3815
|
-
|
|
3816
|
-
const
|
|
3862
|
+
b.length > 0 && w.push({ text: b, style: n[S].style });
|
|
3863
|
+
const T = w.reduce((C, M) => C + o(M.text, M.style), 0);
|
|
3817
3864
|
if (p.text === " ") {
|
|
3818
3865
|
if (f.length > 0) {
|
|
3819
|
-
const
|
|
3820
|
-
a(
|
|
3866
|
+
const C = f[f.length - 1];
|
|
3867
|
+
a(C.style, w[0].style) ? C.text += " " : f.push({ text: " ", style: w[0].style });
|
|
3821
3868
|
} else
|
|
3822
|
-
f.push({ text: " ", style:
|
|
3823
|
-
u +=
|
|
3824
|
-
} else if (
|
|
3869
|
+
f.push({ text: " ", style: w[0].style });
|
|
3870
|
+
u += T;
|
|
3871
|
+
} else if (T > t) {
|
|
3825
3872
|
f.length > 0 && m();
|
|
3826
|
-
for (const
|
|
3827
|
-
const
|
|
3873
|
+
for (const C of w) {
|
|
3874
|
+
const M = Array.from(C.text);
|
|
3828
3875
|
let F = "";
|
|
3829
|
-
for (const
|
|
3830
|
-
const
|
|
3831
|
-
if (u +
|
|
3876
|
+
for (const v of M) {
|
|
3877
|
+
const D = o(v, C.style);
|
|
3878
|
+
if (u + D > t && u > 0) {
|
|
3832
3879
|
if (F.length > 0) {
|
|
3833
3880
|
if (f.length > 0) {
|
|
3834
|
-
const
|
|
3835
|
-
a(
|
|
3881
|
+
const U = f[f.length - 1];
|
|
3882
|
+
a(U.style, C.style) ? U.text += F : f.push({ text: F, style: C.style });
|
|
3836
3883
|
} else
|
|
3837
|
-
f.push({ text: F, style:
|
|
3884
|
+
f.push({ text: F, style: C.style });
|
|
3838
3885
|
F = "";
|
|
3839
3886
|
}
|
|
3840
3887
|
m();
|
|
3841
3888
|
}
|
|
3842
|
-
F +=
|
|
3889
|
+
F += v, u += D;
|
|
3843
3890
|
}
|
|
3844
3891
|
if (F.length > 0)
|
|
3845
3892
|
if (f.length > 0) {
|
|
3846
|
-
const
|
|
3847
|
-
a(
|
|
3893
|
+
const v = f[f.length - 1];
|
|
3894
|
+
a(v.style, C.style) ? v.text += F : f.push({ text: F, style: C.style });
|
|
3848
3895
|
} else
|
|
3849
|
-
f.push({ text: F, style:
|
|
3896
|
+
f.push({ text: F, style: C.style });
|
|
3850
3897
|
}
|
|
3851
3898
|
} else
|
|
3852
|
-
u +
|
|
3899
|
+
u + T > t && f.length > 0 && m(), w.forEach((C) => {
|
|
3853
3900
|
if (f.length > 0) {
|
|
3854
|
-
const
|
|
3855
|
-
a(
|
|
3901
|
+
const M = f[f.length - 1];
|
|
3902
|
+
a(M.style, C.style) ? M.text += C.text : f.push({ ...C });
|
|
3856
3903
|
} else
|
|
3857
|
-
f.push({ ...
|
|
3858
|
-
}), u +=
|
|
3904
|
+
f.push({ ...C });
|
|
3905
|
+
}), u += T;
|
|
3859
3906
|
}), m(), s.length === 0 && s.push([]), s;
|
|
3860
3907
|
}
|
|
3861
|
-
function
|
|
3908
|
+
function Oe(r) {
|
|
3862
3909
|
const t = [];
|
|
3863
3910
|
let e = [];
|
|
3864
|
-
return r.spans.forEach((
|
|
3865
|
-
const s =
|
|
3911
|
+
return r.spans.forEach((i) => {
|
|
3912
|
+
const s = i.text.split(`
|
|
3866
3913
|
`);
|
|
3867
|
-
s.forEach((
|
|
3868
|
-
|
|
3914
|
+
s.forEach((o, a) => {
|
|
3915
|
+
o.length > 0 && e.push({ text: o, style: i.style }), a < s.length - 1 && (t.push(e), e = []);
|
|
3869
3916
|
});
|
|
3870
3917
|
}), e.length > 0 && t.push(e), t.length === 0 && t.push([]), t;
|
|
3871
3918
|
}
|
|
3872
3919
|
function st(r) {
|
|
3873
3920
|
return typeof r.width == "number" ? r.width : void 0;
|
|
3874
3921
|
}
|
|
3875
|
-
function
|
|
3922
|
+
function $t(r, t) {
|
|
3876
3923
|
r.width = t;
|
|
3877
3924
|
}
|
|
3878
|
-
function
|
|
3879
|
-
const
|
|
3925
|
+
function Be(r, t, e) {
|
|
3926
|
+
const i = e.transformData, s = st(i), o = s !== void 0 ? s : e.width ?? 0, a = t / o, n = e.fontSize ?? r.fontSize, h = n * a;
|
|
3880
3927
|
let l;
|
|
3881
|
-
if (h < 16 ? l = Math.round(h) : l = Math.round(h * 2) / 2, r.setFontSize(l), e.richText && e.richText instanceof
|
|
3928
|
+
if (h < 16 ? l = Math.round(h) : l = Math.round(h * 2) / 2, r.setFontSize(l), e.richText && e.richText instanceof L && typeof r.setRichText == "function") {
|
|
3882
3929
|
const f = e.richText.clone();
|
|
3883
3930
|
for (const u of f.spans)
|
|
3884
3931
|
if (u.style.fontSize !== void 0) {
|
|
@@ -3890,36 +3937,36 @@ function Ae(r, t, e) {
|
|
|
3890
3937
|
const c = r.transformData;
|
|
3891
3938
|
if (st(c) !== void 0 && s !== void 0) {
|
|
3892
3939
|
const d = n > 0 ? l / n : a, f = s * d;
|
|
3893
|
-
|
|
3940
|
+
$t(c, Math.max(20, Math.ceil(f)));
|
|
3894
3941
|
}
|
|
3895
3942
|
}
|
|
3896
|
-
function
|
|
3943
|
+
function Re(r, t, e, i) {
|
|
3897
3944
|
if (t !== "middle-left" && t !== "middle-right")
|
|
3898
3945
|
return;
|
|
3899
|
-
r.fontSize =
|
|
3946
|
+
r.fontSize = i.fontSize ?? r.fontSize;
|
|
3900
3947
|
const s = r.transformData;
|
|
3901
3948
|
if (st(s) !== void 0) {
|
|
3902
|
-
|
|
3903
|
-
const a =
|
|
3904
|
-
t === "middle-left" ? (r.x =
|
|
3949
|
+
$t(s, Math.max(_t, e));
|
|
3950
|
+
const a = I.toRadiansInverse(r.rotation), n = Math.cos(a), h = Math.sin(a), l = i.transformData, g = st(l) ?? i.width ?? 0, f = (st(s) ?? 0) - g;
|
|
3951
|
+
t === "middle-left" ? (r.x = i.x - f / 2 * n, r.y = i.y - f / 2 * h) : t === "middle-right" && (r.x = i.x + f / 2 * n, r.y = i.y + f / 2 * h);
|
|
3905
3952
|
}
|
|
3906
3953
|
}
|
|
3907
|
-
function
|
|
3908
|
-
const
|
|
3909
|
-
|
|
3954
|
+
function Vt(r, t, e, i, s) {
|
|
3955
|
+
const o = t.includes("top") || t.includes("bottom"), a = t.includes("middle");
|
|
3956
|
+
o ? Be(r, e, s) : a && Re(r, t, e, s);
|
|
3910
3957
|
}
|
|
3911
|
-
class
|
|
3958
|
+
class He extends q {
|
|
3912
3959
|
// Temporary property used during resize operations only
|
|
3913
3960
|
constructor(t = {}) {
|
|
3914
3961
|
super(t), this.transformType = "custom";
|
|
3915
|
-
const e = t.transformData,
|
|
3916
|
-
|
|
3917
|
-
|
|
3962
|
+
const e = t.transformData, i = (e == null ? void 0 : e.width) !== void 0 ? e.width : Math.max(
|
|
3963
|
+
_t,
|
|
3964
|
+
Bt(this.text, this.fontSize, this.fontFamily, this.bold, this.italic, this.letterSpacing ?? 0) + j * 2
|
|
3918
3965
|
);
|
|
3919
3966
|
this.transformData = {
|
|
3920
3967
|
type: "custom",
|
|
3921
3968
|
controlPoints: (e == null ? void 0 : e.controlPoints) ?? [],
|
|
3922
|
-
width:
|
|
3969
|
+
width: i
|
|
3923
3970
|
};
|
|
3924
3971
|
}
|
|
3925
3972
|
/**
|
|
@@ -3927,30 +3974,31 @@ class Ie extends q {
|
|
|
3927
3974
|
* Returns the total height based on the tallest font in each line
|
|
3928
3975
|
*/
|
|
3929
3976
|
calculateRichTextHeight() {
|
|
3930
|
-
const t = this.getRichText(), e = this.transformData.width - j * 2,
|
|
3931
|
-
if (
|
|
3932
|
-
|
|
3977
|
+
const t = this.getRichText(), e = this.transformData.width - j * 2, i = Oe(t), s = [];
|
|
3978
|
+
if (i.forEach((h) => {
|
|
3979
|
+
Ee(h, e, {
|
|
3933
3980
|
fontSize: this.fontSize,
|
|
3934
3981
|
fontFamily: this.fontFamily,
|
|
3935
3982
|
bold: this.bold,
|
|
3936
|
-
italic: this.italic
|
|
3983
|
+
italic: this.italic,
|
|
3984
|
+
letterSpacing: this.letterSpacing
|
|
3937
3985
|
}).forEach((c) => {
|
|
3938
3986
|
s.push(c);
|
|
3939
3987
|
});
|
|
3940
3988
|
}), s.length === 0)
|
|
3941
3989
|
return 0;
|
|
3942
|
-
let
|
|
3990
|
+
let o = 0, a = 0;
|
|
3943
3991
|
s.forEach((h) => {
|
|
3944
3992
|
h.forEach((l) => {
|
|
3945
|
-
const c = l.style.fontSize !== void 0 ? l.style.fontSize : this.fontSize, g = l.style.fontFamily !== void 0 ? l.style.fontFamily : this.fontFamily, d = l.style.bold !== void 0 ? l.style.bold : this.bold, f = l.style.italic !== void 0 ? l.style.italic : this.italic, u =
|
|
3946
|
-
|
|
3993
|
+
const c = l.style.fontSize !== void 0 ? l.style.fontSize : this.fontSize, g = l.style.fontFamily !== void 0 ? l.style.fontFamily : this.fontFamily, d = l.style.bold !== void 0 ? l.style.bold : this.bold, f = l.style.italic !== void 0 ? l.style.italic : this.italic, u = vt(c, g, d, f);
|
|
3994
|
+
o = Math.max(o, u.height), a = Math.max(a, u.ascent);
|
|
3947
3995
|
});
|
|
3948
3996
|
});
|
|
3949
|
-
const n = this.fontSize *
|
|
3997
|
+
const n = this.fontSize * (this.lineHeight ?? Yt);
|
|
3950
3998
|
if (s.length === 1)
|
|
3951
|
-
return
|
|
3999
|
+
return o;
|
|
3952
4000
|
{
|
|
3953
|
-
const h =
|
|
4001
|
+
const h = vt(this.fontSize, this.fontFamily, this.bold, this.italic), l = (s.length - 1) * n + h.height, c = Math.max(0, a - h.ascent), g = Math.max(0, o - a - (h.height - h.ascent));
|
|
3954
4002
|
return l + c + g;
|
|
3955
4003
|
}
|
|
3956
4004
|
}
|
|
@@ -3972,7 +4020,7 @@ class Ie extends q {
|
|
|
3972
4020
|
getBoundingBox() {
|
|
3973
4021
|
const t = this.transformData.width - j * 2;
|
|
3974
4022
|
let e;
|
|
3975
|
-
return this.hasPerCharacterFormatting() ? e = this.calculateRichTextHeight() : e =
|
|
4023
|
+
return this.hasPerCharacterFormatting() ? e = this.calculateRichTextHeight() : e = Rt(
|
|
3976
4024
|
this.text,
|
|
3977
4025
|
t,
|
|
3978
4026
|
this.fontSize,
|
|
@@ -3980,8 +4028,9 @@ class Ie extends q {
|
|
|
3980
4028
|
this.bold,
|
|
3981
4029
|
this.italic,
|
|
3982
4030
|
this._lockedLineCount,
|
|
3983
|
-
!0
|
|
4031
|
+
!0,
|
|
3984
4032
|
// strict: wrap exactly at maxWidth
|
|
4033
|
+
{ letterSpacing: this.letterSpacing, lineHeight: this.lineHeight }
|
|
3985
4034
|
).height, {
|
|
3986
4035
|
x: this.x - this.transformData.width / 2,
|
|
3987
4036
|
y: this.y - e / 2,
|
|
@@ -3998,7 +4047,7 @@ class Ie extends q {
|
|
|
3998
4047
|
getVisualBoundingBox() {
|
|
3999
4048
|
const t = this.transformData.width - j * 2;
|
|
4000
4049
|
let e;
|
|
4001
|
-
this.hasPerCharacterFormatting() ? e = this.calculateRichTextHeight() : e =
|
|
4050
|
+
this.hasPerCharacterFormatting() ? e = this.calculateRichTextHeight() : e = Rt(
|
|
4002
4051
|
this.text,
|
|
4003
4052
|
t,
|
|
4004
4053
|
this.fontSize,
|
|
@@ -4006,14 +4055,15 @@ class Ie extends q {
|
|
|
4006
4055
|
this.bold,
|
|
4007
4056
|
this.italic,
|
|
4008
4057
|
this._lockedLineCount,
|
|
4009
|
-
!0
|
|
4058
|
+
!0,
|
|
4010
4059
|
// strict: wrap exactly at maxWidth
|
|
4060
|
+
{ letterSpacing: this.letterSpacing, lineHeight: this.lineHeight }
|
|
4011
4061
|
).height;
|
|
4012
|
-
const
|
|
4062
|
+
const i = this.transformData.width;
|
|
4013
4063
|
return {
|
|
4014
|
-
x: this.x -
|
|
4064
|
+
x: this.x - i / 2,
|
|
4015
4065
|
y: this.y - e / 2,
|
|
4016
|
-
width:
|
|
4066
|
+
width: i,
|
|
4017
4067
|
height: e
|
|
4018
4068
|
};
|
|
4019
4069
|
}
|
|
@@ -4033,10 +4083,10 @@ class Ie extends q {
|
|
|
4033
4083
|
* (x, y) is the center of the element, we rotate around this center point
|
|
4034
4084
|
* Now uses shared rendering function that works in both main thread and worker
|
|
4035
4085
|
*/
|
|
4036
|
-
render(t, e = !1,
|
|
4086
|
+
render(t, e = !1, i = !1) {
|
|
4037
4087
|
var n;
|
|
4038
|
-
const s = this.opacity ?? 1,
|
|
4039
|
-
if (s < 1 &&
|
|
4088
|
+
const s = this.opacity ?? 1, o = !!((n = this.stroke) != null && n.enabled);
|
|
4089
|
+
if (s < 1 && o) {
|
|
4040
4090
|
this.renderWithOffscreen(t, s);
|
|
4041
4091
|
return;
|
|
4042
4092
|
}
|
|
@@ -4049,7 +4099,7 @@ class Ie extends q {
|
|
|
4049
4099
|
*/
|
|
4050
4100
|
renderWithOffscreen(t, e) {
|
|
4051
4101
|
var d;
|
|
4052
|
-
const s = (((d = this.stroke) == null ? void 0 : d.width) || 0) + 20,
|
|
4102
|
+
const s = (((d = this.stroke) == null ? void 0 : d.width) || 0) + 20, o = this.getVisualBoundingBox(), a = Math.ceil(o.width + s * 2), n = Math.ceil(o.height + s * 2), h = document.createElement("canvas");
|
|
4053
4103
|
h.width = a, h.height = n;
|
|
4054
4104
|
const l = h.getContext("2d");
|
|
4055
4105
|
if (!l) {
|
|
@@ -4057,24 +4107,33 @@ class Ie extends q {
|
|
|
4057
4107
|
t.globalAlpha = e, gt("custom")(t, this.toJSON()), t.globalAlpha = f;
|
|
4058
4108
|
return;
|
|
4059
4109
|
}
|
|
4060
|
-
const c =
|
|
4110
|
+
const c = o.x + o.width / 2, g = o.y + o.height / 2;
|
|
4061
4111
|
l.translate(a / 2 - c, n / 2 - g), gt("custom")(l, this.toJSON()), t.save(), t.globalAlpha = e, t.drawImage(h, c - a / 2, g - n / 2), t.restore();
|
|
4062
4112
|
}
|
|
4063
4113
|
/**
|
|
4064
4114
|
* Override getTransformStartData to capture initial line count
|
|
4065
4115
|
*/
|
|
4066
4116
|
getTransformStartData() {
|
|
4067
|
-
const t = super.getTransformStartData(), e = this.transformData.width - j * 2,
|
|
4068
|
-
|
|
4117
|
+
const t = super.getTransformStartData(), e = this.transformData.width - j * 2, i = Ft(this.text, e, this.fontSize, this.fontFamily, this.bold, this.italic, void 0, !1, {
|
|
4118
|
+
letterSpacing: this.letterSpacing
|
|
4119
|
+
});
|
|
4120
|
+
return t.lineCount = i.length, t;
|
|
4069
4121
|
}
|
|
4070
4122
|
/**
|
|
4071
4123
|
* Handle resize using standard resize logic
|
|
4072
4124
|
* Corner handles: uniform scale (fontSize and width both change) - line count locked
|
|
4073
4125
|
* Side handles: only width changes - text re-wraps naturally
|
|
4074
4126
|
*/
|
|
4075
|
-
resize(t, e,
|
|
4076
|
-
if (t === "top-left" || t === "top-right" || t === "bottom-left" || t === "bottom-right" || (this._lockedLineCount = void 0),
|
|
4077
|
-
const n =
|
|
4127
|
+
resize(t, e, i, s) {
|
|
4128
|
+
if (t === "top-left" || t === "top-right" || t === "bottom-left" || t === "bottom-right" || (this._lockedLineCount = void 0), Vt(this, t, e, i, s), this._lockedLineCount !== void 0 && this._lockedLineCount > 0) {
|
|
4129
|
+
const n = Bt(
|
|
4130
|
+
this.text,
|
|
4131
|
+
this.fontSize,
|
|
4132
|
+
this.fontFamily,
|
|
4133
|
+
this.bold,
|
|
4134
|
+
this.italic,
|
|
4135
|
+
this.letterSpacing ?? 0
|
|
4136
|
+
) / this._lockedLineCount + j * 2;
|
|
4078
4137
|
this.transformData.width < n && (this.transformData.width = Math.ceil(n));
|
|
4079
4138
|
}
|
|
4080
4139
|
}
|
|
@@ -4119,32 +4178,32 @@ class Ie extends q {
|
|
|
4119
4178
|
};
|
|
4120
4179
|
}
|
|
4121
4180
|
}
|
|
4122
|
-
function
|
|
4123
|
-
const s =
|
|
4181
|
+
function Pe(r, t, e, i) {
|
|
4182
|
+
const s = I.toRadians(i), o = Math.cos(s), a = Math.sin(s);
|
|
4124
4183
|
let n = 0, h = 0;
|
|
4125
4184
|
e === "top-left" ? (n = r.width, h = r.height) : e === "top-right" ? (n = 0, h = r.height) : e === "bottom-left" ? (n = r.width, h = 0) : e === "bottom-right" && (n = 0, h = 0);
|
|
4126
|
-
const l = r.x + (n *
|
|
4185
|
+
const l = r.x + (n * o - h * a), c = r.y + (n * a + h * o);
|
|
4127
4186
|
let g = 0, d = 0;
|
|
4128
4187
|
e === "top-left" ? (g = t.width, d = t.height) : e === "top-right" ? (g = 0, d = t.height) : e === "bottom-left" ? (g = t.width, d = 0) : e === "bottom-right" && (g = 0, d = 0);
|
|
4129
|
-
const f = l - (g *
|
|
4188
|
+
const f = l - (g * o - d * a), u = c - (g * a + d * o);
|
|
4130
4189
|
return { x: f, y: u };
|
|
4131
4190
|
}
|
|
4132
|
-
function
|
|
4133
|
-
const s = r.width / 2,
|
|
4191
|
+
function qi(r, t, e, i = 1) {
|
|
4192
|
+
const s = r.width / 2, o = r.height + ge / i, a = r.x + s, n = r.y + o, h = I.toRadians(t), l = Math.cos(h), c = Math.sin(h), g = a - e.x, d = n - e.y, f = g * l - d * c, u = g * c + d * l;
|
|
4134
4193
|
return {
|
|
4135
4194
|
x: e.x + f,
|
|
4136
4195
|
y: e.y + u
|
|
4137
4196
|
};
|
|
4138
4197
|
}
|
|
4139
|
-
function
|
|
4140
|
-
const
|
|
4141
|
-
const d = r.x + c, f = r.y + g, u = d - e.x, m = f - e.y, p = u * s - m *
|
|
4198
|
+
function ji(r, t, e) {
|
|
4199
|
+
const i = I.toRadians(t), s = Math.cos(i), o = Math.sin(i), a = (c, g) => {
|
|
4200
|
+
const d = r.x + c, f = r.y + g, u = d - e.x, m = f - e.y, p = u * s - m * o, y = u * o + m * s;
|
|
4142
4201
|
return {
|
|
4143
4202
|
x: e.x + p,
|
|
4144
4203
|
y: e.y + y
|
|
4145
4204
|
};
|
|
4146
4205
|
}, { width: n, height: h } = r, l = (c, g, d, f) => {
|
|
4147
|
-
const u = a(d, f), m =
|
|
4206
|
+
const u = a(d, f), m = Le(
|
|
4148
4207
|
u.x,
|
|
4149
4208
|
u.y,
|
|
4150
4209
|
e.x,
|
|
@@ -4173,35 +4232,35 @@ function Uo(r, t, e) {
|
|
|
4173
4232
|
l("edge", "middle-bottom", n / 2, h)
|
|
4174
4233
|
];
|
|
4175
4234
|
}
|
|
4176
|
-
function
|
|
4177
|
-
const
|
|
4178
|
-
return
|
|
4235
|
+
function Zi(r, t, e, i, s) {
|
|
4236
|
+
const o = r - e, a = t - i;
|
|
4237
|
+
return o * o + a * a <= s * s;
|
|
4179
4238
|
}
|
|
4180
|
-
function
|
|
4181
|
-
const s =
|
|
4239
|
+
function Ki(r, t, e, i) {
|
|
4240
|
+
const s = I.toRadiansInverse(i), o = Math.cos(s), a = Math.sin(s), n = r - e.x, h = t - e.y, l = n * o - h * a, c = n * a + h * o;
|
|
4182
4241
|
return l >= 0 && l <= e.width && c >= 0 && c <= e.height;
|
|
4183
4242
|
}
|
|
4184
|
-
function tt(r, t, e = "Arial",
|
|
4185
|
-
const a = document.createElement("canvas").getContext("2d"), n =
|
|
4243
|
+
function tt(r, t, e = "Arial", i = !1, s = !1) {
|
|
4244
|
+
const a = document.createElement("canvas").getContext("2d"), n = i ? "bold" : "normal", h = s ? "italic" : "normal";
|
|
4186
4245
|
return a.font = `${h} ${n} ${t}px ${e}`, a.measureText(r).width;
|
|
4187
4246
|
}
|
|
4188
|
-
function
|
|
4247
|
+
function Qi(r) {
|
|
4189
4248
|
return {
|
|
4190
4249
|
x: r.x + r.width / 2,
|
|
4191
4250
|
y: r.y + r.height / 2
|
|
4192
4251
|
};
|
|
4193
4252
|
}
|
|
4194
|
-
function
|
|
4195
|
-
return Math.atan2(
|
|
4253
|
+
function ts(r, t, e, i) {
|
|
4254
|
+
return Math.atan2(i - t, e - r);
|
|
4196
4255
|
}
|
|
4197
|
-
function
|
|
4256
|
+
function es(r, t, e) {
|
|
4198
4257
|
return Math.abs(r - t) <= e;
|
|
4199
4258
|
}
|
|
4200
|
-
function
|
|
4201
|
-
const n = r - e, h = t -
|
|
4259
|
+
function Le(r, t, e, i, s, o = 0, a = "") {
|
|
4260
|
+
const n = r - e, h = t - i;
|
|
4202
4261
|
let l = Math.atan2(h, n) * (180 / Math.PI);
|
|
4203
4262
|
if (l = (l % 360 + 360) % 360, s === "corner") {
|
|
4204
|
-
if (Math.abs(
|
|
4263
|
+
if (Math.abs(o) < 0.1) {
|
|
4205
4264
|
if (a === "top-left" || a === "bottom-right")
|
|
4206
4265
|
return "nwse-resize";
|
|
4207
4266
|
if (a === "top-right" || a === "bottom-left")
|
|
@@ -4214,17 +4273,17 @@ function Ee(r, t, e, o, s, i = 0, a = "") {
|
|
|
4214
4273
|
return c >= 45 && c < 135 ? "ns-resize" : "ew-resize";
|
|
4215
4274
|
}
|
|
4216
4275
|
}
|
|
4217
|
-
function
|
|
4276
|
+
function We(r) {
|
|
4218
4277
|
if (!r.getTransform)
|
|
4219
4278
|
return 1;
|
|
4220
4279
|
const t = r.getTransform();
|
|
4221
4280
|
return Math.sqrt(t.a * t.a + t.b * t.b);
|
|
4222
4281
|
}
|
|
4223
|
-
function
|
|
4224
|
-
const
|
|
4225
|
-
r.lineWidth =
|
|
4282
|
+
function is(r, t, e = []) {
|
|
4283
|
+
const i = We(r);
|
|
4284
|
+
r.lineWidth = i > 0 ? t / i : t, e.length > 0 && r.setLineDash(i > 0 ? e.map((s) => s / i) : e);
|
|
4226
4285
|
}
|
|
4227
|
-
class
|
|
4286
|
+
class ze extends q {
|
|
4228
4287
|
constructor(t = {}) {
|
|
4229
4288
|
super(t), this.transformType = "circle";
|
|
4230
4289
|
const e = t.transformData;
|
|
@@ -4254,12 +4313,12 @@ class Be extends q {
|
|
|
4254
4313
|
* For circular text, calculate the arc bounds where text actually appears
|
|
4255
4314
|
*/
|
|
4256
4315
|
getVisualBoundingBox() {
|
|
4257
|
-
const t = this.transformData.radius * this.transformData.scale, e = this.fontSize * this.transformData.scale, s = tt(this.text, e, this.fontFamily, this.bold, this.italic) / t,
|
|
4316
|
+
const t = this.transformData.radius * this.transformData.scale, e = this.fontSize * this.transformData.scale, s = tt(this.text, e, this.fontFamily, this.bold, this.italic) / t, o = -Math.PI / 2 - s / 2, a = -Math.PI / 2 + s / 2, n = t > e / 2 ? t - e / 2 : t * 0.1, h = t + e / 2;
|
|
4258
4317
|
let l = 1 / 0, c = -1 / 0, g = 1 / 0, d = -1 / 0;
|
|
4259
4318
|
const f = 10;
|
|
4260
4319
|
for (let u = 0; u <= f; u++) {
|
|
4261
|
-
const m =
|
|
4262
|
-
l = Math.min(l, p,
|
|
4320
|
+
const m = o + (a - o) * (u / f), p = this.x + Math.cos(m) * n, y = this.y + Math.sin(m) * n, w = this.x + Math.cos(m) * h, S = this.y + Math.sin(m) * h;
|
|
4321
|
+
l = Math.min(l, p, w), c = Math.max(c, p, w), g = Math.min(g, y, S), d = Math.max(d, y, S);
|
|
4263
4322
|
}
|
|
4264
4323
|
return {
|
|
4265
4324
|
x: l,
|
|
@@ -4277,15 +4336,15 @@ class Be extends q {
|
|
|
4277
4336
|
* Handle resize
|
|
4278
4337
|
* For circle, we maintain uniform scale and keep scale on the transform
|
|
4279
4338
|
*/
|
|
4280
|
-
resize(t, e,
|
|
4281
|
-
const
|
|
4339
|
+
resize(t, e, i, s) {
|
|
4340
|
+
const o = s.transformData, a = (e + i) / 2, n = (s.width + s.height) / 2, h = a / n, l = o.scale * h, c = Math.max(0.1, Math.min(10, l));
|
|
4282
4341
|
this.transformData.scale = c;
|
|
4283
|
-
const g = this.getBoundingBox(), d =
|
|
4342
|
+
const g = this.getBoundingBox(), d = Pe(
|
|
4284
4343
|
{
|
|
4285
|
-
x: s.x -
|
|
4286
|
-
y: s.y -
|
|
4287
|
-
width:
|
|
4288
|
-
height:
|
|
4344
|
+
x: s.x - o.radius * o.scale,
|
|
4345
|
+
y: s.y - o.radius * o.scale,
|
|
4346
|
+
width: o.radius * 2 * o.scale,
|
|
4347
|
+
height: o.radius * 2 * o.scale
|
|
4289
4348
|
},
|
|
4290
4349
|
{ width: g.width, height: g.height },
|
|
4291
4350
|
t,
|
|
@@ -4354,7 +4413,7 @@ class Be extends q {
|
|
|
4354
4413
|
};
|
|
4355
4414
|
}
|
|
4356
4415
|
}
|
|
4357
|
-
class
|
|
4416
|
+
class Xe extends q {
|
|
4358
4417
|
constructor(t = {}) {
|
|
4359
4418
|
super(t), this.transformType = "arch";
|
|
4360
4419
|
const e = t.transformData;
|
|
@@ -4365,19 +4424,19 @@ class Re extends q {
|
|
|
4365
4424
|
};
|
|
4366
4425
|
}
|
|
4367
4426
|
getBoundingBox() {
|
|
4368
|
-
const t = Math.abs(this.transformData.archHeight), e = this.fontSize * (1.2 + t),
|
|
4427
|
+
const t = Math.abs(this.transformData.archHeight), e = this.fontSize * (1.2 + t), i = this.transformData.archHeight > 0 ? -e : 0;
|
|
4369
4428
|
return {
|
|
4370
4429
|
x: this.x - this.transformData.width / 2,
|
|
4371
|
-
y: this.y +
|
|
4430
|
+
y: this.y + i,
|
|
4372
4431
|
width: this.transformData.width,
|
|
4373
4432
|
height: e
|
|
4374
4433
|
};
|
|
4375
4434
|
}
|
|
4376
4435
|
getVisualBoundingBox() {
|
|
4377
|
-
const t = this.text.split(""), e = t.map((u) => tt(u, this.fontSize, this.fontFamily)),
|
|
4378
|
-
let h = 1 / 0, l = -1 / 0, c = 1 / 0, g = -1 / 0, d = -
|
|
4436
|
+
const t = this.text.split(""), e = t.map((u) => tt(u, this.fontSize, this.fontFamily)), i = e.reduce((u, m) => u + m, 0), s = this.transformData.width / 2, o = 0.3, n = this.fontSize / 2;
|
|
4437
|
+
let h = 1 / 0, l = -1 / 0, c = 1 / 0, g = -1 / 0, d = -i / 2;
|
|
4379
4438
|
t.forEach((u, m) => {
|
|
4380
|
-
const p = e[m], y = d + p / 2,
|
|
4439
|
+
const p = e[m], y = d + p / 2, w = y / s, S = (Math.pow(w, 2) - 1) * this.transformData.archHeight * this.fontSize, b = 2 * w * this.transformData.archHeight;
|
|
4381
4440
|
[
|
|
4382
4441
|
{ x: -p / 2, y: -n },
|
|
4383
4442
|
// top-left
|
|
@@ -4387,9 +4446,9 @@ class Re extends q {
|
|
|
4387
4446
|
// bottom-left
|
|
4388
4447
|
{ x: p / 2, y: n }
|
|
4389
4448
|
// bottom-right
|
|
4390
|
-
].forEach((
|
|
4391
|
-
const
|
|
4392
|
-
h = Math.min(h,
|
|
4449
|
+
].forEach((C) => {
|
|
4450
|
+
const M = C.x, F = C.y + b * o * C.x, v = y + M, D = S + F;
|
|
4451
|
+
h = Math.min(h, v), l = Math.max(l, v), c = Math.min(c, D), g = Math.max(g, D);
|
|
4393
4452
|
}), d += p;
|
|
4394
4453
|
});
|
|
4395
4454
|
const f = 2;
|
|
@@ -4400,9 +4459,9 @@ class Re extends q {
|
|
|
4400
4459
|
height: g - c
|
|
4401
4460
|
};
|
|
4402
4461
|
}
|
|
4403
|
-
resize(t, e,
|
|
4404
|
-
const
|
|
4405
|
-
if (
|
|
4462
|
+
resize(t, e, i, s) {
|
|
4463
|
+
const o = t.includes("top") || t.includes("bottom"), a = t.includes("middle"), n = s.transformData;
|
|
4464
|
+
if (o) {
|
|
4406
4465
|
const h = e / s.width, l = s.fontSize * h;
|
|
4407
4466
|
this.setFontSize(l);
|
|
4408
4467
|
const c = n.width * h;
|
|
@@ -4447,7 +4506,7 @@ class Re extends q {
|
|
|
4447
4506
|
};
|
|
4448
4507
|
}
|
|
4449
4508
|
}
|
|
4450
|
-
const
|
|
4509
|
+
const ot = {
|
|
4451
4510
|
amplitude: 0.2,
|
|
4452
4511
|
// 20% - subtle wave effect
|
|
4453
4512
|
frequency: 1.2,
|
|
@@ -4459,22 +4518,22 @@ const it = {
|
|
|
4459
4518
|
frequency: 2,
|
|
4460
4519
|
// Standard flag frequency
|
|
4461
4520
|
width: 200
|
|
4462
|
-
},
|
|
4521
|
+
}, Ye = {
|
|
4463
4522
|
archHeight: 0.5
|
|
4464
|
-
},
|
|
4523
|
+
}, _e = {
|
|
4465
4524
|
leanAmount: 0
|
|
4466
|
-
},
|
|
4525
|
+
}, Ne = {
|
|
4467
4526
|
ascendAngle: -15
|
|
4468
4527
|
};
|
|
4469
|
-
class
|
|
4528
|
+
class Ue extends q {
|
|
4470
4529
|
constructor(t = {}) {
|
|
4471
4530
|
super(t), this.transformType = "wave";
|
|
4472
4531
|
const e = t.transformData;
|
|
4473
4532
|
this.transformData = {
|
|
4474
4533
|
type: "wave",
|
|
4475
|
-
amplitude: (e == null ? void 0 : e.amplitude) ??
|
|
4476
|
-
frequency: (e == null ? void 0 : e.frequency) ??
|
|
4477
|
-
width: (e == null ? void 0 : e.width) ??
|
|
4534
|
+
amplitude: (e == null ? void 0 : e.amplitude) ?? ot.amplitude,
|
|
4535
|
+
frequency: (e == null ? void 0 : e.frequency) ?? ot.frequency,
|
|
4536
|
+
width: (e == null ? void 0 : e.width) ?? ot.width
|
|
4478
4537
|
};
|
|
4479
4538
|
}
|
|
4480
4539
|
getBoundingBox() {
|
|
@@ -4487,22 +4546,22 @@ class We extends q {
|
|
|
4487
4546
|
};
|
|
4488
4547
|
}
|
|
4489
4548
|
getVisualBoundingBox() {
|
|
4490
|
-
const t = this.text.split(""), e = t.map((d) => tt(d, this.fontSize, this.fontFamily)),
|
|
4491
|
-
let a = 1 / 0, n = -1 / 0, h = 1 / 0, l = -1 / 0, c = -
|
|
4549
|
+
const t = this.text.split(""), e = t.map((d) => tt(d, this.fontSize, this.fontFamily)), i = e.reduce((d, f) => d + f, 0), o = this.fontSize / 2;
|
|
4550
|
+
let a = 1 / 0, n = -1 / 0, h = 1 / 0, l = -1 / 0, c = -i / 2;
|
|
4492
4551
|
t.forEach((d, f) => {
|
|
4493
|
-
const u = e[f], m = c + u / 2, p = m / (this.transformData.width / 2), y = this.transformData.amplitude * this.fontSize * Math.sin(this.transformData.frequency * Math.PI * p),
|
|
4552
|
+
const u = e[f], m = c + u / 2, p = m / (this.transformData.width / 2), y = this.transformData.amplitude * this.fontSize * Math.sin(this.transformData.frequency * Math.PI * p), w = this.transformData.amplitude * this.transformData.frequency * Math.PI * Math.cos(this.transformData.frequency * Math.PI * p);
|
|
4494
4553
|
[
|
|
4495
|
-
{ x: -u / 2, y: -
|
|
4554
|
+
{ x: -u / 2, y: -o },
|
|
4496
4555
|
// top-left
|
|
4497
|
-
{ x: u / 2, y: -
|
|
4556
|
+
{ x: u / 2, y: -o },
|
|
4498
4557
|
// top-right
|
|
4499
|
-
{ x: -u / 2, y:
|
|
4558
|
+
{ x: -u / 2, y: o },
|
|
4500
4559
|
// bottom-left
|
|
4501
|
-
{ x: u / 2, y:
|
|
4560
|
+
{ x: u / 2, y: o }
|
|
4502
4561
|
// bottom-right
|
|
4503
|
-
].forEach((
|
|
4504
|
-
const
|
|
4505
|
-
a = Math.min(a,
|
|
4562
|
+
].forEach((b) => {
|
|
4563
|
+
const T = b.x, C = b.y + w * be * b.x, M = m + T, F = y + C;
|
|
4564
|
+
a = Math.min(a, M), n = Math.max(n, M), h = Math.min(h, F), l = Math.max(l, F);
|
|
4506
4565
|
}), c += u;
|
|
4507
4566
|
});
|
|
4508
4567
|
const g = 2;
|
|
@@ -4513,8 +4572,8 @@ class We extends q {
|
|
|
4513
4572
|
height: l - h
|
|
4514
4573
|
};
|
|
4515
4574
|
}
|
|
4516
|
-
resize(t, e,
|
|
4517
|
-
|
|
4575
|
+
resize(t, e, i, s) {
|
|
4576
|
+
Vt(this, t, e, i, s);
|
|
4518
4577
|
}
|
|
4519
4578
|
getEnabledAnchors() {
|
|
4520
4579
|
return ["top-left", "top-right", "bottom-left", "bottom-right"];
|
|
@@ -4535,7 +4594,7 @@ class We extends q {
|
|
|
4535
4594
|
};
|
|
4536
4595
|
}
|
|
4537
4596
|
}
|
|
4538
|
-
class
|
|
4597
|
+
class Ge extends q {
|
|
4539
4598
|
constructor(t = {}) {
|
|
4540
4599
|
super(t), this.transformType = "flag";
|
|
4541
4600
|
const e = t.transformData;
|
|
@@ -4556,10 +4615,10 @@ class ze extends q {
|
|
|
4556
4615
|
};
|
|
4557
4616
|
}
|
|
4558
4617
|
getVisualBoundingBox() {
|
|
4559
|
-
const t = this.text.split(""), e = t.map((f) => tt(f, this.fontSize, this.fontFamily)),
|
|
4560
|
-
let n = 1 / 0, h = -1 / 0, l = 1 / 0, c = -1 / 0, g = -
|
|
4618
|
+
const t = this.text.split(""), e = t.map((f) => tt(f, this.fontSize, this.fontFamily)), i = e.reduce((f, u) => f + u, 0), s = 0.3, a = this.fontSize / 2;
|
|
4619
|
+
let n = 1 / 0, h = -1 / 0, l = 1 / 0, c = -1 / 0, g = -i / 2;
|
|
4561
4620
|
t.forEach((f, u) => {
|
|
4562
|
-
const m = e[u], p = g + m / 2, y = p / (this.transformData.width / 2),
|
|
4621
|
+
const m = e[u], p = g + m / 2, y = p / (this.transformData.width / 2), w = Math.abs(y), S = this.transformData.amplitude * w, b = S * this.fontSize * Math.sin(this.transformData.frequency * Math.PI * y), T = S * this.transformData.frequency * Math.PI * Math.cos(this.transformData.frequency * Math.PI * y), C = this.transformData.amplitude * Math.sign(y) * Math.sin(this.transformData.frequency * Math.PI * y), M = T + C;
|
|
4563
4622
|
[
|
|
4564
4623
|
{ x: -m / 2, y: -a },
|
|
4565
4624
|
// top-left
|
|
@@ -4569,9 +4628,9 @@ class ze extends q {
|
|
|
4569
4628
|
// bottom-left
|
|
4570
4629
|
{ x: m / 2, y: a }
|
|
4571
4630
|
// bottom-right
|
|
4572
|
-
].forEach((
|
|
4573
|
-
const
|
|
4574
|
-
n = Math.min(n,
|
|
4631
|
+
].forEach((v) => {
|
|
4632
|
+
const D = v.x, U = v.y + M * s * v.x, B = p + D, A = b + U;
|
|
4633
|
+
n = Math.min(n, B), h = Math.max(h, B), l = Math.min(l, A), c = Math.max(c, A);
|
|
4575
4634
|
}), g += m;
|
|
4576
4635
|
});
|
|
4577
4636
|
const d = 2;
|
|
@@ -4582,9 +4641,9 @@ class ze extends q {
|
|
|
4582
4641
|
height: c - l
|
|
4583
4642
|
};
|
|
4584
4643
|
}
|
|
4585
|
-
resize(t, e,
|
|
4586
|
-
const
|
|
4587
|
-
if (
|
|
4644
|
+
resize(t, e, i, s) {
|
|
4645
|
+
const o = t.includes("top") || t.includes("bottom"), a = t.includes("middle"), n = s.transformData;
|
|
4646
|
+
if (o) {
|
|
4588
4647
|
const h = e / s.width, l = s.fontSize * h;
|
|
4589
4648
|
this.setFontSize(l);
|
|
4590
4649
|
const c = n.width * h;
|
|
@@ -4631,7 +4690,7 @@ class ze extends q {
|
|
|
4631
4690
|
};
|
|
4632
4691
|
}
|
|
4633
4692
|
}
|
|
4634
|
-
class
|
|
4693
|
+
class $e extends q {
|
|
4635
4694
|
constructor(t = {}) {
|
|
4636
4695
|
super(t), this.transformType = "lean";
|
|
4637
4696
|
const e = t.transformData;
|
|
@@ -4651,19 +4710,19 @@ class Xe extends q {
|
|
|
4651
4710
|
};
|
|
4652
4711
|
}
|
|
4653
4712
|
getVisualBoundingBox() {
|
|
4654
|
-
const e = tt(this.text, this.fontSize, this.fontFamily),
|
|
4655
|
-
{ x: -e / 2, y: -
|
|
4713
|
+
const e = tt(this.text, this.fontSize, this.fontFamily), i = this.fontSize * 1.2, s = -this.transformData.leanAmount * Math.PI / 4, o = Math.tan(s), a = [
|
|
4714
|
+
{ x: -e / 2, y: -i / 2 },
|
|
4656
4715
|
// top-left
|
|
4657
|
-
{ x: e / 2, y: -
|
|
4716
|
+
{ x: e / 2, y: -i / 2 },
|
|
4658
4717
|
// top-right
|
|
4659
|
-
{ x: -e / 2, y:
|
|
4718
|
+
{ x: -e / 2, y: i / 2 },
|
|
4660
4719
|
// bottom-left
|
|
4661
|
-
{ x: e / 2, y:
|
|
4720
|
+
{ x: e / 2, y: i / 2 }
|
|
4662
4721
|
// bottom-right
|
|
4663
4722
|
];
|
|
4664
4723
|
let n = 1 / 0, h = -1 / 0, l = 1 / 0, c = -1 / 0;
|
|
4665
4724
|
a.forEach((d) => {
|
|
4666
|
-
const f = d.x +
|
|
4725
|
+
const f = d.x + o * d.y, u = d.y;
|
|
4667
4726
|
n = Math.min(n, f), h = Math.max(h, f), l = Math.min(l, u), c = Math.max(c, u);
|
|
4668
4727
|
});
|
|
4669
4728
|
const g = 2;
|
|
@@ -4674,9 +4733,9 @@ class Xe extends q {
|
|
|
4674
4733
|
height: c - l
|
|
4675
4734
|
};
|
|
4676
4735
|
}
|
|
4677
|
-
resize(t, e,
|
|
4678
|
-
const
|
|
4679
|
-
if (
|
|
4736
|
+
resize(t, e, i, s) {
|
|
4737
|
+
const o = t.includes("top") || t.includes("bottom"), a = t.includes("middle"), n = s.transformData;
|
|
4738
|
+
if (o) {
|
|
4680
4739
|
const h = e / s.width, l = s.fontSize * h;
|
|
4681
4740
|
this.setFontSize(l);
|
|
4682
4741
|
const c = n.width * h;
|
|
@@ -4721,7 +4780,7 @@ class Xe extends q {
|
|
|
4721
4780
|
};
|
|
4722
4781
|
}
|
|
4723
4782
|
}
|
|
4724
|
-
class
|
|
4783
|
+
class Ve extends q {
|
|
4725
4784
|
constructor(t = {}) {
|
|
4726
4785
|
super(t), this.transformType = "ascend";
|
|
4727
4786
|
const e = t.transformData;
|
|
@@ -4732,19 +4791,19 @@ class Ye extends q {
|
|
|
4732
4791
|
};
|
|
4733
4792
|
}
|
|
4734
4793
|
getBoundingBox() {
|
|
4735
|
-
const t = this.transformData.ascendAngle * Math.PI / 180, e = this.transformData.width,
|
|
4794
|
+
const t = this.transformData.ascendAngle * Math.PI / 180, e = this.transformData.width, i = e * Math.tan(t), s = Math.abs(i) + this.fontSize * 1.2, o = i > 0 ? -s : 0;
|
|
4736
4795
|
return {
|
|
4737
4796
|
x: this.x - e / 2,
|
|
4738
|
-
y: this.y +
|
|
4797
|
+
y: this.y + o,
|
|
4739
4798
|
width: e,
|
|
4740
4799
|
height: s
|
|
4741
4800
|
};
|
|
4742
4801
|
}
|
|
4743
4802
|
getVisualBoundingBox() {
|
|
4744
|
-
const t = this.text.split(""), e = t.map((m) => tt(m, this.fontSize, this.fontFamily)),
|
|
4745
|
-
let l = 1 / 0, c = -1 / 0, g = 1 / 0, d = -1 / 0, f = -
|
|
4803
|
+
const t = this.text.split(""), e = t.map((m) => tt(m, this.fontSize, this.fontFamily)), i = e.reduce((m, p) => m + p, 0), s = this.transformData.ascendAngle * Math.PI / 180, o = Math.tan(s), a = 1, h = this.fontSize / 2;
|
|
4804
|
+
let l = 1 / 0, c = -1 / 0, g = 1 / 0, d = -1 / 0, f = -i / 2;
|
|
4746
4805
|
t.forEach((m, p) => {
|
|
4747
|
-
const y = e[p],
|
|
4806
|
+
const y = e[p], w = f + y / 2, S = w * o;
|
|
4748
4807
|
[
|
|
4749
4808
|
{ x: -y / 2, y: -h },
|
|
4750
4809
|
// top-left
|
|
@@ -4754,9 +4813,9 @@ class Ye extends q {
|
|
|
4754
4813
|
// bottom-left
|
|
4755
4814
|
{ x: y / 2, y: h }
|
|
4756
4815
|
// bottom-right
|
|
4757
|
-
].forEach((
|
|
4758
|
-
const
|
|
4759
|
-
l = Math.min(l, F), c = Math.max(c, F), g = Math.min(g,
|
|
4816
|
+
].forEach((T) => {
|
|
4817
|
+
const C = T.x, M = T.y + o * a * T.x, F = w + C, v = S + M;
|
|
4818
|
+
l = Math.min(l, F), c = Math.max(c, F), g = Math.min(g, v), d = Math.max(d, v);
|
|
4760
4819
|
}), f += y;
|
|
4761
4820
|
});
|
|
4762
4821
|
const u = 2;
|
|
@@ -4767,9 +4826,9 @@ class Ye extends q {
|
|
|
4767
4826
|
height: d - g
|
|
4768
4827
|
};
|
|
4769
4828
|
}
|
|
4770
|
-
resize(t, e,
|
|
4771
|
-
const
|
|
4772
|
-
if (
|
|
4829
|
+
resize(t, e, i, s) {
|
|
4830
|
+
const o = t.includes("top") || t.includes("bottom"), a = t.includes("middle"), n = s.transformData;
|
|
4831
|
+
if (o) {
|
|
4773
4832
|
const h = e / s.width, l = s.fontSize * h;
|
|
4774
4833
|
this.setFontSize(l);
|
|
4775
4834
|
const c = n.width * h;
|
|
@@ -4814,16 +4873,16 @@ class Ye extends q {
|
|
|
4814
4873
|
};
|
|
4815
4874
|
}
|
|
4816
4875
|
}
|
|
4817
|
-
class
|
|
4876
|
+
class At extends Q {
|
|
4818
4877
|
constructor(t = {}) {
|
|
4819
|
-
var
|
|
4878
|
+
var i, s, o, a, n, h, l, c, g, d, f;
|
|
4820
4879
|
super(t), this.transformType = "shape";
|
|
4821
4880
|
const e = "rectangle";
|
|
4822
4881
|
this.transformData = {
|
|
4823
4882
|
type: "shape",
|
|
4824
|
-
shapeType: ((
|
|
4883
|
+
shapeType: ((i = t.transformData) == null ? void 0 : i.shapeType) || e,
|
|
4825
4884
|
width: ((s = t.transformData) == null ? void 0 : s.width) || 200,
|
|
4826
|
-
height: ((
|
|
4885
|
+
height: ((o = t.transformData) == null ? void 0 : o.height) || 200,
|
|
4827
4886
|
borderRadius: ((a = t.transformData) == null ? void 0 : a.borderRadius) ?? 3,
|
|
4828
4887
|
// Default 3% radius (~6px on 200x200 shape, matches hover border)
|
|
4829
4888
|
radiusX: (n = t.transformData) == null ? void 0 : n.radiusX,
|
|
@@ -4831,7 +4890,7 @@ class Ft extends Q {
|
|
|
4831
4890
|
sides: ((l = t.transformData) == null ? void 0 : l.sides) ?? 5,
|
|
4832
4891
|
points: ((c = t.transformData) == null ? void 0 : c.points) ?? 5,
|
|
4833
4892
|
innerRadius: ((g = t.transformData) == null ? void 0 : g.innerRadius) ?? 0.4,
|
|
4834
|
-
fillColor: ((d = t.transformData) == null ? void 0 : d.fillColor) ||
|
|
4893
|
+
fillColor: ((d = t.transformData) == null ? void 0 : d.fillColor) || Xt(),
|
|
4835
4894
|
fillOpacity: ((f = t.transformData) == null ? void 0 : f.fillOpacity) ?? 1
|
|
4836
4895
|
};
|
|
4837
4896
|
}
|
|
@@ -4864,9 +4923,9 @@ class Ft extends Q {
|
|
|
4864
4923
|
* `getBoundingBox()`. The chrome aligns with the *fill* edge.
|
|
4865
4924
|
*/
|
|
4866
4925
|
getVisualBoundingBox() {
|
|
4867
|
-
const { shapeType: t, width: e, height:
|
|
4926
|
+
const { shapeType: t, width: e, height: i } = this.transformData;
|
|
4868
4927
|
if (t === "circle") {
|
|
4869
|
-
const s = Math.min(e,
|
|
4928
|
+
const s = Math.min(e, i) / 2;
|
|
4870
4929
|
return {
|
|
4871
4930
|
x: this.x - s,
|
|
4872
4931
|
y: this.y - s,
|
|
@@ -4875,25 +4934,25 @@ class Ft extends Q {
|
|
|
4875
4934
|
};
|
|
4876
4935
|
}
|
|
4877
4936
|
if (t === "polygon" || t === "star") {
|
|
4878
|
-
const s = Math.min(e,
|
|
4879
|
-
let
|
|
4937
|
+
const s = Math.min(e, i) / 2;
|
|
4938
|
+
let o = 1 / 0, a = 1 / 0, n = -1 / 0, h = -1 / 0;
|
|
4880
4939
|
if (t === "polygon") {
|
|
4881
4940
|
const l = this.transformData.sides || 5;
|
|
4882
4941
|
for (let c = 0; c < l; c++) {
|
|
4883
4942
|
const g = c * 2 * Math.PI / l - Math.PI / 2, d = s * Math.cos(g), f = s * Math.sin(g);
|
|
4884
|
-
d <
|
|
4943
|
+
d < o && (o = d), d > n && (n = d), f < a && (a = f), f > h && (h = f);
|
|
4885
4944
|
}
|
|
4886
4945
|
} else {
|
|
4887
4946
|
const l = this.transformData.points || 5, c = s, g = c * (this.transformData.innerRadius ?? 0.4);
|
|
4888
4947
|
for (let d = 0; d < l * 2; d++) {
|
|
4889
4948
|
const f = d * Math.PI / l - Math.PI / 2, u = d % 2 === 0 ? c : g, m = u * Math.cos(f), p = u * Math.sin(f);
|
|
4890
|
-
m <
|
|
4949
|
+
m < o && (o = m), m > n && (n = m), p < a && (a = p), p > h && (h = p);
|
|
4891
4950
|
}
|
|
4892
4951
|
}
|
|
4893
4952
|
return {
|
|
4894
|
-
x: this.x +
|
|
4953
|
+
x: this.x + o,
|
|
4895
4954
|
y: this.y + a,
|
|
4896
|
-
width: n -
|
|
4955
|
+
width: n - o,
|
|
4897
4956
|
height: h - a
|
|
4898
4957
|
};
|
|
4899
4958
|
}
|
|
@@ -4908,16 +4967,16 @@ class Ft extends Q {
|
|
|
4908
4967
|
/**
|
|
4909
4968
|
* Render the shape
|
|
4910
4969
|
*/
|
|
4911
|
-
render(t, e = !1,
|
|
4970
|
+
render(t, e = !1, i = !1) {
|
|
4912
4971
|
var n;
|
|
4913
|
-
const s = this.opacity ?? 1,
|
|
4914
|
-
if (s < 1 &&
|
|
4972
|
+
const s = this.opacity ?? 1, o = !!((n = this.stroke) != null && n.enabled);
|
|
4973
|
+
if (s < 1 && o) {
|
|
4915
4974
|
this.renderWithOffscreen(t, s);
|
|
4916
4975
|
return;
|
|
4917
4976
|
}
|
|
4918
|
-
t.save(), t.translate(this.x, this.y), t.rotate(
|
|
4977
|
+
t.save(), t.translate(this.x, this.y), t.rotate(I.toRadians(this.rotation)), t.fillStyle = this.transformData.fillColor || "#3b82f6";
|
|
4919
4978
|
const a = this.transformData.fillOpacity ?? 1;
|
|
4920
|
-
t.globalAlpha = s * a, this.renderShape(t), t.restore(),
|
|
4979
|
+
t.globalAlpha = s * a, this.renderShape(t), t.restore(), o && this.renderStroke(t, s);
|
|
4921
4980
|
}
|
|
4922
4981
|
/**
|
|
4923
4982
|
* Render fill+stroke to a temporary canvas at full opacity, then composite
|
|
@@ -4925,7 +4984,7 @@ class Ft extends Q {
|
|
|
4925
4984
|
*/
|
|
4926
4985
|
renderWithOffscreen(t, e) {
|
|
4927
4986
|
var f;
|
|
4928
|
-
const { width:
|
|
4987
|
+
const { width: i, height: s } = this.transformData, a = (((f = this.stroke) == null ? void 0 : f.width) || 2) + 2, n = Math.ceil(i + a * 2), h = Math.ceil(s + a * 2), l = document.createElement("canvas");
|
|
4929
4988
|
l.width = n, l.height = h;
|
|
4930
4989
|
const c = l.getContext("2d");
|
|
4931
4990
|
if (!c) {
|
|
@@ -4936,103 +4995,103 @@ class Ft extends Q {
|
|
|
4936
4995
|
const g = this.transformData.fillOpacity ?? 1;
|
|
4937
4996
|
c.globalAlpha = g, c.beginPath(), this.traceShapePath(c), c.fill(), c.restore(), c.save(), c.translate(n / 2, h / 2);
|
|
4938
4997
|
const d = this.stroke;
|
|
4939
|
-
c.strokeStyle = d.color || "#000000", c.lineWidth = d.width || 2, c.lineCap = d.lineCap || "round", c.lineJoin = d.lineJoin || "round", c.globalAlpha = d.opacity ?? 1, d.dashArray && d.dashArray.length > 0 && c.setLineDash(d.dashArray), c.beginPath(), this.traceShapePath(c), c.stroke(), c.restore(), t.save(), t.translate(this.x, this.y), t.rotate(
|
|
4998
|
+
c.strokeStyle = d.color || "#000000", c.lineWidth = d.width || 2, c.lineCap = d.lineCap || "round", c.lineJoin = d.lineJoin || "round", c.globalAlpha = d.opacity ?? 1, d.dashArray && d.dashArray.length > 0 && c.setLineDash(d.dashArray), c.beginPath(), this.traceShapePath(c), c.stroke(), c.restore(), t.save(), t.translate(this.x, this.y), t.rotate(I.toRadians(this.rotation)), t.globalAlpha = e, t.drawImage(l, -n / 2, -h / 2), t.restore();
|
|
4940
4999
|
}
|
|
4941
5000
|
/**
|
|
4942
5001
|
* Direct render (no offscreen) — used as fallback
|
|
4943
5002
|
*/
|
|
4944
5003
|
renderDirect(t, e) {
|
|
4945
|
-
var
|
|
4946
|
-
t.save(), t.translate(this.x, this.y), t.rotate(
|
|
5004
|
+
var i;
|
|
5005
|
+
t.save(), t.translate(this.x, this.y), t.rotate(I.toRadians(this.rotation)), t.fillStyle = this.transformData.fillColor || "#3b82f6", t.globalAlpha = e * (this.transformData.fillOpacity ?? 1), this.renderShape(t), t.restore(), (i = this.stroke) != null && i.enabled && this.renderStroke(t, e);
|
|
4947
5006
|
}
|
|
4948
5007
|
/**
|
|
4949
5008
|
* Trace the shape path without filling or stroking — used by offscreen render
|
|
4950
5009
|
*/
|
|
4951
5010
|
traceShapePath(t) {
|
|
4952
|
-
const { shapeType: e, width:
|
|
5011
|
+
const { shapeType: e, width: i, height: s } = this.transformData;
|
|
4953
5012
|
switch (e) {
|
|
4954
5013
|
case "rectangle": {
|
|
4955
|
-
const
|
|
4956
|
-
if (
|
|
4957
|
-
const h = Math.min(
|
|
4958
|
-
t.roundRect(a, n,
|
|
5014
|
+
const o = this.transformData.borderRadius || 0, a = -i / 2, n = -s / 2;
|
|
5015
|
+
if (o > 0) {
|
|
5016
|
+
const h = Math.min(o / 100 * Math.min(i, s), i / 2, s / 2);
|
|
5017
|
+
t.roundRect(a, n, i, s, h);
|
|
4959
5018
|
} else
|
|
4960
|
-
t.rect(a, n,
|
|
5019
|
+
t.rect(a, n, i, s);
|
|
4961
5020
|
break;
|
|
4962
5021
|
}
|
|
4963
5022
|
case "circle": {
|
|
4964
|
-
const
|
|
4965
|
-
t.arc(0, 0,
|
|
5023
|
+
const o = Math.min(i, s) / 2;
|
|
5024
|
+
t.arc(0, 0, o, 0, Math.PI * 2);
|
|
4966
5025
|
break;
|
|
4967
5026
|
}
|
|
4968
5027
|
case "ellipse":
|
|
4969
|
-
t.ellipse(0, 0,
|
|
5028
|
+
t.ellipse(0, 0, i / 2, s / 2, 0, 0, Math.PI * 2);
|
|
4970
5029
|
break;
|
|
4971
5030
|
case "triangle": {
|
|
4972
|
-
const
|
|
4973
|
-
t.moveTo(0, -a), t.lineTo(
|
|
5031
|
+
const o = i / 2, a = s / 2;
|
|
5032
|
+
t.moveTo(0, -a), t.lineTo(o, a), t.lineTo(-o, a), t.closePath();
|
|
4974
5033
|
break;
|
|
4975
5034
|
}
|
|
4976
5035
|
case "polygon": {
|
|
4977
|
-
const
|
|
4978
|
-
for (let n = 0; n <
|
|
4979
|
-
const h = n * 2 * Math.PI /
|
|
5036
|
+
const o = this.transformData.sides || 5, a = Math.min(i, s) / 2;
|
|
5037
|
+
for (let n = 0; n < o; n++) {
|
|
5038
|
+
const h = n * 2 * Math.PI / o - Math.PI / 2, l = a * Math.cos(h), c = a * Math.sin(h);
|
|
4980
5039
|
n === 0 ? t.moveTo(l, c) : t.lineTo(l, c);
|
|
4981
5040
|
}
|
|
4982
5041
|
t.closePath();
|
|
4983
5042
|
break;
|
|
4984
5043
|
}
|
|
4985
5044
|
case "star": {
|
|
4986
|
-
const
|
|
4987
|
-
for (let h = 0; h <
|
|
4988
|
-
const l = h * Math.PI /
|
|
5045
|
+
const o = this.transformData.points || 5, a = Math.min(i, s) / 2, n = a * (this.transformData.innerRadius || 0.4);
|
|
5046
|
+
for (let h = 0; h < o * 2; h++) {
|
|
5047
|
+
const l = h * Math.PI / o - Math.PI / 2, c = h % 2 === 0 ? a : n, g = c * Math.cos(l), d = c * Math.sin(l);
|
|
4989
5048
|
h === 0 ? t.moveTo(g, d) : t.lineTo(g, d);
|
|
4990
5049
|
}
|
|
4991
5050
|
t.closePath();
|
|
4992
5051
|
break;
|
|
4993
5052
|
}
|
|
4994
5053
|
case "line": {
|
|
4995
|
-
const
|
|
4996
|
-
t.rect(-
|
|
5054
|
+
const o = i / 2, a = s / 2;
|
|
5055
|
+
t.rect(-o, -a, i, s);
|
|
4997
5056
|
break;
|
|
4998
5057
|
}
|
|
4999
5058
|
default:
|
|
5000
|
-
t.rect(-
|
|
5059
|
+
t.rect(-i / 2, -s / 2, i, s);
|
|
5001
5060
|
}
|
|
5002
5061
|
}
|
|
5003
5062
|
/**
|
|
5004
5063
|
* Render the stroke for this shape element
|
|
5005
5064
|
*/
|
|
5006
5065
|
renderStroke(t, e) {
|
|
5007
|
-
t.save(), t.translate(this.x, this.y), t.rotate(
|
|
5008
|
-
const
|
|
5009
|
-
t.strokeStyle =
|
|
5010
|
-
const { shapeType: s, width:
|
|
5066
|
+
t.save(), t.translate(this.x, this.y), t.rotate(I.toRadians(this.rotation));
|
|
5067
|
+
const i = this.stroke;
|
|
5068
|
+
t.strokeStyle = i.color || "#000000", t.lineWidth = i.width || 2, t.lineCap = i.lineCap || "round", t.lineJoin = i.lineJoin || "round", t.globalAlpha = e * (i.opacity ?? 1), i.dashArray && i.dashArray.length > 0 && t.setLineDash(i.dashArray);
|
|
5069
|
+
const { shapeType: s, width: o, height: a } = this.transformData;
|
|
5011
5070
|
switch (t.beginPath(), s) {
|
|
5012
5071
|
case "rectangle": {
|
|
5013
|
-
const n = this.transformData.borderRadius || 0, h = -
|
|
5072
|
+
const n = this.transformData.borderRadius || 0, h = -o / 2, l = -a / 2;
|
|
5014
5073
|
if (n > 0) {
|
|
5015
|
-
const c = Math.min(n / 100 * Math.min(
|
|
5016
|
-
t.roundRect(h, l,
|
|
5074
|
+
const c = Math.min(n / 100 * Math.min(o, a), o / 2, a / 2);
|
|
5075
|
+
t.roundRect(h, l, o, a, c);
|
|
5017
5076
|
} else
|
|
5018
|
-
t.rect(h, l,
|
|
5077
|
+
t.rect(h, l, o, a);
|
|
5019
5078
|
break;
|
|
5020
5079
|
}
|
|
5021
5080
|
case "circle": {
|
|
5022
|
-
const n = Math.min(
|
|
5081
|
+
const n = Math.min(o, a) / 2;
|
|
5023
5082
|
t.arc(0, 0, n, 0, Math.PI * 2);
|
|
5024
5083
|
break;
|
|
5025
5084
|
}
|
|
5026
5085
|
case "ellipse":
|
|
5027
|
-
t.ellipse(0, 0,
|
|
5086
|
+
t.ellipse(0, 0, o / 2, a / 2, 0, 0, Math.PI * 2);
|
|
5028
5087
|
break;
|
|
5029
5088
|
case "triangle": {
|
|
5030
|
-
const n =
|
|
5089
|
+
const n = o / 2, h = a / 2;
|
|
5031
5090
|
t.moveTo(0, -h), t.lineTo(n, h), t.lineTo(-n, h), t.closePath();
|
|
5032
5091
|
break;
|
|
5033
5092
|
}
|
|
5034
5093
|
case "polygon": {
|
|
5035
|
-
const n = this.transformData.sides || 5, h = Math.min(
|
|
5094
|
+
const n = this.transformData.sides || 5, h = Math.min(o, a) / 2;
|
|
5036
5095
|
for (let l = 0; l < n; l++) {
|
|
5037
5096
|
const c = l * 2 * Math.PI / n - Math.PI / 2, g = h * Math.cos(c), d = h * Math.sin(c);
|
|
5038
5097
|
l === 0 ? t.moveTo(g, d) : t.lineTo(g, d);
|
|
@@ -5041,7 +5100,7 @@ class Ft extends Q {
|
|
|
5041
5100
|
break;
|
|
5042
5101
|
}
|
|
5043
5102
|
case "star": {
|
|
5044
|
-
const n = this.transformData.points || 5, h = Math.min(
|
|
5103
|
+
const n = this.transformData.points || 5, h = Math.min(o, a) / 2, l = h * (this.transformData.innerRadius || 0.4);
|
|
5045
5104
|
for (let c = 0; c < n * 2; c++) {
|
|
5046
5105
|
const g = c * Math.PI / n - Math.PI / 2, d = c % 2 === 0 ? h : l, f = d * Math.cos(g), u = d * Math.sin(g);
|
|
5047
5106
|
c === 0 ? t.moveTo(f, u) : t.lineTo(f, u);
|
|
@@ -5050,12 +5109,12 @@ class Ft extends Q {
|
|
|
5050
5109
|
break;
|
|
5051
5110
|
}
|
|
5052
5111
|
case "line": {
|
|
5053
|
-
const n =
|
|
5054
|
-
t.rect(-n, -h,
|
|
5112
|
+
const n = o / 2, h = a / 2;
|
|
5113
|
+
t.rect(-n, -h, o, a);
|
|
5055
5114
|
break;
|
|
5056
5115
|
}
|
|
5057
5116
|
default:
|
|
5058
|
-
t.rect(-
|
|
5117
|
+
t.rect(-o / 2, -a / 2, o, a);
|
|
5059
5118
|
}
|
|
5060
5119
|
t.stroke(), t.restore();
|
|
5061
5120
|
}
|
|
@@ -5063,45 +5122,45 @@ class Ft extends Q {
|
|
|
5063
5122
|
* Render the specific shape based on shapeType
|
|
5064
5123
|
*/
|
|
5065
5124
|
renderShape(t) {
|
|
5066
|
-
const { shapeType: e, width:
|
|
5125
|
+
const { shapeType: e, width: i, height: s } = this.transformData;
|
|
5067
5126
|
switch (t.beginPath(), e) {
|
|
5068
5127
|
case "rectangle":
|
|
5069
|
-
this.renderRectangle(t,
|
|
5128
|
+
this.renderRectangle(t, i, s);
|
|
5070
5129
|
break;
|
|
5071
5130
|
case "circle":
|
|
5072
|
-
this.renderCircle(t, Math.min(
|
|
5131
|
+
this.renderCircle(t, Math.min(i, s) / 2);
|
|
5073
5132
|
break;
|
|
5074
5133
|
case "ellipse":
|
|
5075
|
-
this.renderEllipse(t,
|
|
5134
|
+
this.renderEllipse(t, i / 2, s / 2);
|
|
5076
5135
|
break;
|
|
5077
5136
|
case "triangle":
|
|
5078
|
-
this.renderTriangle(t,
|
|
5137
|
+
this.renderTriangle(t, i, s);
|
|
5079
5138
|
break;
|
|
5080
5139
|
case "polygon":
|
|
5081
|
-
this.renderPolygon(t, Math.min(
|
|
5140
|
+
this.renderPolygon(t, Math.min(i, s) / 2);
|
|
5082
5141
|
break;
|
|
5083
5142
|
case "star":
|
|
5084
|
-
this.renderStar(t, Math.min(
|
|
5143
|
+
this.renderStar(t, Math.min(i, s) / 2);
|
|
5085
5144
|
break;
|
|
5086
5145
|
case "line":
|
|
5087
|
-
this.renderLine(t,
|
|
5146
|
+
this.renderLine(t, i, s);
|
|
5088
5147
|
return;
|
|
5089
5148
|
// Line uses stroke, not fill
|
|
5090
5149
|
default:
|
|
5091
|
-
this.renderRectangle(t,
|
|
5150
|
+
this.renderRectangle(t, i, s);
|
|
5092
5151
|
}
|
|
5093
5152
|
t.fill();
|
|
5094
5153
|
}
|
|
5095
5154
|
/**
|
|
5096
5155
|
* Render a rectangle (with optional border radius)
|
|
5097
5156
|
*/
|
|
5098
|
-
renderRectangle(t, e,
|
|
5099
|
-
const s = this.transformData.borderRadius || 0,
|
|
5157
|
+
renderRectangle(t, e, i) {
|
|
5158
|
+
const s = this.transformData.borderRadius || 0, o = -e / 2, a = -i / 2;
|
|
5100
5159
|
if (s > 0) {
|
|
5101
|
-
const n = Math.min(s / 100 * Math.min(e,
|
|
5102
|
-
t.roundRect(
|
|
5160
|
+
const n = Math.min(s / 100 * Math.min(e, i), e / 2, i / 2);
|
|
5161
|
+
t.roundRect(o, a, e, i, n);
|
|
5103
5162
|
} else
|
|
5104
|
-
t.rect(
|
|
5163
|
+
t.rect(o, a, e, i);
|
|
5105
5164
|
}
|
|
5106
5165
|
/**
|
|
5107
5166
|
* Render a circle
|
|
@@ -5112,23 +5171,23 @@ class Ft extends Q {
|
|
|
5112
5171
|
/**
|
|
5113
5172
|
* Render an ellipse
|
|
5114
5173
|
*/
|
|
5115
|
-
renderEllipse(t, e,
|
|
5116
|
-
t.ellipse(0, 0, e,
|
|
5174
|
+
renderEllipse(t, e, i) {
|
|
5175
|
+
t.ellipse(0, 0, e, i, 0, 0, Math.PI * 2);
|
|
5117
5176
|
}
|
|
5118
5177
|
/**
|
|
5119
5178
|
* Render a triangle (isosceles, pointing up)
|
|
5120
5179
|
*/
|
|
5121
|
-
renderTriangle(t, e,
|
|
5122
|
-
const s = e / 2,
|
|
5123
|
-
t.moveTo(0, -
|
|
5180
|
+
renderTriangle(t, e, i) {
|
|
5181
|
+
const s = e / 2, o = i / 2;
|
|
5182
|
+
t.moveTo(0, -o), t.lineTo(s, o), t.lineTo(-s, o), t.closePath();
|
|
5124
5183
|
}
|
|
5125
5184
|
/**
|
|
5126
5185
|
* Render a regular polygon
|
|
5127
5186
|
*/
|
|
5128
5187
|
renderPolygon(t, e) {
|
|
5129
|
-
const
|
|
5130
|
-
for (let a = 0; a <=
|
|
5131
|
-
const n =
|
|
5188
|
+
const i = Math.max(3, Math.min(20, this.transformData.sides || 5)), s = Math.PI * 2 / i, o = -Math.PI / 2;
|
|
5189
|
+
for (let a = 0; a <= i; a++) {
|
|
5190
|
+
const n = o + s * a, h = Math.cos(n) * e, l = Math.sin(n) * e;
|
|
5132
5191
|
a === 0 ? t.moveTo(h, l) : t.lineTo(h, l);
|
|
5133
5192
|
}
|
|
5134
5193
|
t.closePath();
|
|
@@ -5137,9 +5196,9 @@ class Ft extends Q {
|
|
|
5137
5196
|
* Render a star
|
|
5138
5197
|
*/
|
|
5139
5198
|
renderStar(t, e) {
|
|
5140
|
-
const
|
|
5141
|
-
for (let h = 0; h <
|
|
5142
|
-
const l = n + a * h, c = h % 2 === 0 ? e :
|
|
5199
|
+
const i = Math.max(3, Math.min(20, this.transformData.points || 5)), s = Math.max(0.1, Math.min(0.9, this.transformData.innerRadius || 0.4)), o = e * s, a = Math.PI / i, n = -Math.PI / 2;
|
|
5200
|
+
for (let h = 0; h < i * 2; h++) {
|
|
5201
|
+
const l = n + a * h, c = h % 2 === 0 ? e : o, g = Math.cos(l) * c, d = Math.sin(l) * c;
|
|
5143
5202
|
h === 0 ? t.moveTo(g, d) : t.lineTo(g, d);
|
|
5144
5203
|
}
|
|
5145
5204
|
t.closePath();
|
|
@@ -5147,19 +5206,19 @@ class Ft extends Q {
|
|
|
5147
5206
|
/**
|
|
5148
5207
|
* Render a line
|
|
5149
5208
|
*/
|
|
5150
|
-
renderLine(t, e,
|
|
5151
|
-
const s = e / 2,
|
|
5152
|
-
t.moveTo(-s, 0), t.lineTo(s, 0), t.strokeStyle = this.transformData.fillColor || "#3b82f6", t.lineWidth =
|
|
5209
|
+
renderLine(t, e, i) {
|
|
5210
|
+
const s = e / 2, o = i;
|
|
5211
|
+
t.moveTo(-s, 0), t.lineTo(s, 0), t.strokeStyle = this.transformData.fillColor || "#3b82f6", t.lineWidth = o, t.lineCap = "round", t.stroke();
|
|
5153
5212
|
}
|
|
5154
5213
|
/**
|
|
5155
5214
|
* Handle resize - maintain aspect ratio for circles, free resize for others
|
|
5156
5215
|
*/
|
|
5157
|
-
resize(t, e,
|
|
5158
|
-
const { shapeType:
|
|
5159
|
-
if (
|
|
5160
|
-
const c = Math.max(e / s.transformData.width,
|
|
5216
|
+
resize(t, e, i, s) {
|
|
5217
|
+
const { shapeType: o } = this.transformData;
|
|
5218
|
+
if (o === "circle" || o === "polygon" || o === "star") {
|
|
5219
|
+
const c = Math.max(e / s.transformData.width, i / s.transformData.height);
|
|
5161
5220
|
this.transformData.width = s.transformData.width * c, this.transformData.height = s.transformData.height * c;
|
|
5162
|
-
} else
|
|
5221
|
+
} else o === "line" ? (this.transformData.width = e, this.transformData.height = s.transformData.height) : (this.transformData.width = e, this.transformData.height = i);
|
|
5163
5222
|
this.rotation = s.rotation;
|
|
5164
5223
|
const a = this.getFixedCorner(t, s), n = this.getOppositeAnchor(t), h = this.getBoundingBox(), l = this.getCornerOffset(n, h);
|
|
5165
5224
|
return this.x = a.x - l.x, this.y = a.y - l.y, !0;
|
|
@@ -5187,77 +5246,77 @@ class Ft extends Q {
|
|
|
5187
5246
|
* Get the position of the fixed corner (opposite of dragged anchor)
|
|
5188
5247
|
*/
|
|
5189
5248
|
getFixedCorner(t, e) {
|
|
5190
|
-
const
|
|
5249
|
+
const i = {
|
|
5191
5250
|
x: e.x - e.transformData.width / 2,
|
|
5192
5251
|
y: e.y - e.transformData.height / 2,
|
|
5193
5252
|
width: e.transformData.width,
|
|
5194
5253
|
height: e.transformData.height
|
|
5195
5254
|
};
|
|
5196
|
-
let s,
|
|
5255
|
+
let s, o;
|
|
5197
5256
|
switch (t) {
|
|
5198
5257
|
case "top-left":
|
|
5199
|
-
s =
|
|
5258
|
+
s = i.x + i.width, o = i.y + i.height;
|
|
5200
5259
|
break;
|
|
5201
5260
|
case "top-right":
|
|
5202
|
-
s =
|
|
5261
|
+
s = i.x, o = i.y + i.height;
|
|
5203
5262
|
break;
|
|
5204
5263
|
case "bottom-left":
|
|
5205
|
-
s =
|
|
5264
|
+
s = i.x + i.width, o = i.y;
|
|
5206
5265
|
break;
|
|
5207
5266
|
case "bottom-right":
|
|
5208
|
-
s =
|
|
5267
|
+
s = i.x, o = i.y;
|
|
5209
5268
|
break;
|
|
5210
5269
|
case "middle-left":
|
|
5211
|
-
s =
|
|
5270
|
+
s = i.x + i.width, o = i.y + i.height / 2;
|
|
5212
5271
|
break;
|
|
5213
5272
|
case "middle-right":
|
|
5214
|
-
s =
|
|
5273
|
+
s = i.x, o = i.y + i.height / 2;
|
|
5215
5274
|
break;
|
|
5216
5275
|
case "middle-top":
|
|
5217
|
-
s =
|
|
5276
|
+
s = i.x + i.width / 2, o = i.y + i.height;
|
|
5218
5277
|
break;
|
|
5219
5278
|
case "middle-bottom":
|
|
5220
|
-
s =
|
|
5279
|
+
s = i.x + i.width / 2, o = i.y;
|
|
5221
5280
|
break;
|
|
5222
5281
|
default:
|
|
5223
|
-
s =
|
|
5282
|
+
s = i.x + i.width / 2, o = i.y + i.height / 2;
|
|
5224
5283
|
}
|
|
5225
|
-
return { x: s, y:
|
|
5284
|
+
return { x: s, y: o };
|
|
5226
5285
|
}
|
|
5227
5286
|
/**
|
|
5228
5287
|
* Get the offset of a corner from the center
|
|
5229
5288
|
*/
|
|
5230
5289
|
getCornerOffset(t, e) {
|
|
5231
|
-
let
|
|
5290
|
+
let i, s;
|
|
5232
5291
|
switch (t) {
|
|
5233
5292
|
case "top-left":
|
|
5234
|
-
|
|
5293
|
+
i = -e.width / 2, s = -e.height / 2;
|
|
5235
5294
|
break;
|
|
5236
5295
|
case "top-right":
|
|
5237
|
-
|
|
5296
|
+
i = e.width / 2, s = -e.height / 2;
|
|
5238
5297
|
break;
|
|
5239
5298
|
case "bottom-left":
|
|
5240
|
-
|
|
5299
|
+
i = -e.width / 2, s = e.height / 2;
|
|
5241
5300
|
break;
|
|
5242
5301
|
case "bottom-right":
|
|
5243
|
-
|
|
5302
|
+
i = e.width / 2, s = e.height / 2;
|
|
5244
5303
|
break;
|
|
5245
5304
|
case "middle-left":
|
|
5246
|
-
|
|
5305
|
+
i = -e.width / 2, s = 0;
|
|
5247
5306
|
break;
|
|
5248
5307
|
case "middle-right":
|
|
5249
|
-
|
|
5308
|
+
i = e.width / 2, s = 0;
|
|
5250
5309
|
break;
|
|
5251
5310
|
case "middle-top":
|
|
5252
|
-
|
|
5311
|
+
i = 0, s = -e.height / 2;
|
|
5253
5312
|
break;
|
|
5254
5313
|
case "middle-bottom":
|
|
5255
|
-
|
|
5314
|
+
i = 0, s = e.height / 2;
|
|
5256
5315
|
break;
|
|
5257
5316
|
default:
|
|
5258
|
-
|
|
5317
|
+
i = 0, s = 0;
|
|
5259
5318
|
}
|
|
5260
|
-
return { x:
|
|
5319
|
+
return { x: i, y: s };
|
|
5261
5320
|
}
|
|
5262
5321
|
/**
|
|
5263
5322
|
* Get enabled anchors - all 8 anchors for most shapes, only corners for circles/polygons
|
|
@@ -5279,7 +5338,7 @@ class Ft extends Q {
|
|
|
5279
5338
|
* Clone this element
|
|
5280
5339
|
*/
|
|
5281
5340
|
clone() {
|
|
5282
|
-
return new
|
|
5341
|
+
return new At(this.toJSON());
|
|
5283
5342
|
}
|
|
5284
5343
|
/**
|
|
5285
5344
|
* Serialize to JSON
|
|
@@ -5303,15 +5362,15 @@ class Ft extends Q {
|
|
|
5303
5362
|
}
|
|
5304
5363
|
class Mt extends Q {
|
|
5305
5364
|
constructor(t = {}) {
|
|
5306
|
-
var e,
|
|
5365
|
+
var e, i, s, o, a, n, h, l, c, g;
|
|
5307
5366
|
super(t), this.transformType = "path", this.transformData = {
|
|
5308
5367
|
type: "path",
|
|
5309
5368
|
points: ((e = t.transformData) == null ? void 0 : e.points) || [],
|
|
5310
|
-
closed: ((
|
|
5369
|
+
closed: ((i = t.transformData) == null ? void 0 : i.closed) ?? !1,
|
|
5311
5370
|
width: ((s = t.transformData) == null ? void 0 : s.width) || 200,
|
|
5312
|
-
height: ((
|
|
5371
|
+
height: ((o = t.transformData) == null ? void 0 : o.height) || 200,
|
|
5313
5372
|
fillEnabled: ((a = t.transformData) == null ? void 0 : a.fillEnabled) ?? !1,
|
|
5314
|
-
fillColor: ((n = t.transformData) == null ? void 0 : n.fillColor) ||
|
|
5373
|
+
fillColor: ((n = t.transformData) == null ? void 0 : n.fillColor) || Xt(),
|
|
5315
5374
|
fillOpacity: ((h = t.transformData) == null ? void 0 : h.fillOpacity) ?? 1,
|
|
5316
5375
|
strokeEnabled: ((l = t.transformData) == null ? void 0 : l.strokeEnabled) ?? !0,
|
|
5317
5376
|
strokeColor: ((c = t.transformData) == null ? void 0 : c.strokeColor) || "#000000",
|
|
@@ -5357,11 +5416,11 @@ class Mt extends Q {
|
|
|
5357
5416
|
* @param p3 End point
|
|
5358
5417
|
* @param t Parameter from 0 to 1
|
|
5359
5418
|
*/
|
|
5360
|
-
bezierPoint(t, e,
|
|
5361
|
-
const a = 1 -
|
|
5419
|
+
bezierPoint(t, e, i, s, o) {
|
|
5420
|
+
const a = 1 - o, n = a * a, h = n * a, l = o * o, c = l * o;
|
|
5362
5421
|
return {
|
|
5363
|
-
x: h * t.x + 3 * n *
|
|
5364
|
-
y: h * t.y + 3 * n *
|
|
5422
|
+
x: h * t.x + 3 * n * o * e.x + 3 * a * l * i.x + c * s.x,
|
|
5423
|
+
y: h * t.y + 3 * n * o * e.y + 3 * a * l * i.y + c * s.y
|
|
5365
5424
|
};
|
|
5366
5425
|
}
|
|
5367
5426
|
/**
|
|
@@ -5373,33 +5432,33 @@ class Mt extends Q {
|
|
|
5373
5432
|
const { points: t } = this.transformData;
|
|
5374
5433
|
if (t.length === 0)
|
|
5375
5434
|
return { x: 0, y: 0, width: 0, height: 0 };
|
|
5376
|
-
let e = 1 / 0,
|
|
5435
|
+
let e = 1 / 0, i = 1 / 0, s = -1 / 0, o = -1 / 0;
|
|
5377
5436
|
for (let d = 0; d < t.length; d++) {
|
|
5378
5437
|
const f = t[d], u = t[(d + 1) % t.length];
|
|
5379
5438
|
if (d === t.length - 1 && !this.transformData.closed) {
|
|
5380
|
-
e = Math.min(e, f.x),
|
|
5439
|
+
e = Math.min(e, f.x), i = Math.min(i, f.y), s = Math.max(s, f.x), o = Math.max(o, f.y);
|
|
5381
5440
|
break;
|
|
5382
5441
|
}
|
|
5383
|
-
if (e = Math.min(e, f.x),
|
|
5442
|
+
if (e = Math.min(e, f.x), i = Math.min(i, f.y), s = Math.max(s, f.x), o = Math.max(o, f.y), f.handleOut || u.handleIn) {
|
|
5384
5443
|
const p = { x: f.x, y: f.y }, y = {
|
|
5385
5444
|
x: f.x + (((h = f.handleOut) == null ? void 0 : h.x) || 0),
|
|
5386
5445
|
y: f.y + (((l = f.handleOut) == null ? void 0 : l.y) || 0)
|
|
5387
|
-
},
|
|
5446
|
+
}, w = {
|
|
5388
5447
|
x: u.x + (((c = u.handleIn) == null ? void 0 : c.x) || 0),
|
|
5389
5448
|
y: u.y + (((g = u.handleIn) == null ? void 0 : g.y) || 0)
|
|
5390
|
-
},
|
|
5391
|
-
for (let
|
|
5392
|
-
const
|
|
5393
|
-
e = Math.min(e,
|
|
5449
|
+
}, S = { x: u.x, y: u.y }, b = 20;
|
|
5450
|
+
for (let T = 0; T <= b; T++) {
|
|
5451
|
+
const C = T / b, M = this.bezierPoint(p, y, w, S, C);
|
|
5452
|
+
e = Math.min(e, M.x), i = Math.min(i, M.y), s = Math.max(s, M.x), o = Math.max(o, M.y);
|
|
5394
5453
|
}
|
|
5395
5454
|
}
|
|
5396
5455
|
}
|
|
5397
5456
|
const a = this.transformData.strokeEnabled ? this.transformData.strokeWidth || 2 : 0, n = a / 2;
|
|
5398
5457
|
return {
|
|
5399
5458
|
x: e - n,
|
|
5400
|
-
y:
|
|
5459
|
+
y: i - n,
|
|
5401
5460
|
width: s - e + a,
|
|
5402
|
-
height:
|
|
5461
|
+
height: o - i + a
|
|
5403
5462
|
};
|
|
5404
5463
|
}
|
|
5405
5464
|
/**
|
|
@@ -5412,56 +5471,56 @@ class Mt extends Q {
|
|
|
5412
5471
|
/**
|
|
5413
5472
|
* Render the path
|
|
5414
5473
|
*/
|
|
5415
|
-
render(t, e = !1,
|
|
5416
|
-
const { points: s, closed:
|
|
5474
|
+
render(t, e = !1, i = !1) {
|
|
5475
|
+
const { points: s, closed: o, fillEnabled: a, fillColor: n, fillOpacity: h, strokeEnabled: l, strokeColor: c, strokeWidth: g } = this.transformData;
|
|
5417
5476
|
if (s.length === 0)
|
|
5418
5477
|
return;
|
|
5419
|
-
t.save(), t.translate(this.x, this.y), t.rotate(
|
|
5478
|
+
t.save(), t.translate(this.x, this.y), t.rotate(I.toRadians(this.rotation));
|
|
5420
5479
|
const d = this.calculatePathBounds(), f = d.x + d.width / 2, u = d.y + d.height / 2;
|
|
5421
|
-
t.translate(-f, -u), t.beginPath(), this.renderPath(t), a &&
|
|
5480
|
+
t.translate(-f, -u), t.beginPath(), this.renderPath(t), a && o && n && (t.fillStyle = n, t.globalAlpha = h ?? 1, t.fill()), l && c && g && (t.strokeStyle = c, t.lineWidth = g, t.lineCap = "round", t.lineJoin = "round", t.globalAlpha = 1, t.stroke()), t.restore();
|
|
5422
5481
|
}
|
|
5423
5482
|
/**
|
|
5424
5483
|
* Render the path using Canvas API bezier curves
|
|
5425
5484
|
*/
|
|
5426
5485
|
renderPath(t) {
|
|
5427
|
-
var
|
|
5428
|
-
const { points: e, closed:
|
|
5486
|
+
var o, a, n, h;
|
|
5487
|
+
const { points: e, closed: i } = this.transformData;
|
|
5429
5488
|
if (e.length === 0) return;
|
|
5430
5489
|
const s = e[0];
|
|
5431
5490
|
t.moveTo(s.x, s.y);
|
|
5432
5491
|
for (let l = 0; l < e.length; l++) {
|
|
5433
5492
|
const c = e[l], g = e[(l + 1) % e.length];
|
|
5434
|
-
if (l === e.length - 1 && !
|
|
5493
|
+
if (l === e.length - 1 && !i)
|
|
5435
5494
|
break;
|
|
5436
5495
|
if (c.handleOut || g.handleIn) {
|
|
5437
|
-
const f = c.x + (((
|
|
5496
|
+
const f = c.x + (((o = c.handleOut) == null ? void 0 : o.x) || 0), u = c.y + (((a = c.handleOut) == null ? void 0 : a.y) || 0), m = g.x + (((n = g.handleIn) == null ? void 0 : n.x) || 0), p = g.y + (((h = g.handleIn) == null ? void 0 : h.y) || 0);
|
|
5438
5497
|
t.bezierCurveTo(f, u, m, p, g.x, g.y);
|
|
5439
5498
|
} else
|
|
5440
5499
|
t.lineTo(g.x, g.y);
|
|
5441
5500
|
}
|
|
5442
|
-
|
|
5501
|
+
i && t.closePath();
|
|
5443
5502
|
}
|
|
5444
5503
|
/**
|
|
5445
5504
|
* Handle resize - scale all points relative to center
|
|
5446
5505
|
*/
|
|
5447
|
-
resize(t, e,
|
|
5448
|
-
const
|
|
5449
|
-
if (
|
|
5506
|
+
resize(t, e, i, s) {
|
|
5507
|
+
const o = s.transformData.width, a = s.transformData.height;
|
|
5508
|
+
if (o === 0 || a === 0)
|
|
5450
5509
|
return !1;
|
|
5451
|
-
const n = e /
|
|
5510
|
+
const n = e / o, h = i / a, l = s.transformData.points;
|
|
5452
5511
|
let c = 1 / 0, g = 1 / 0, d = -1 / 0, f = -1 / 0;
|
|
5453
|
-
for (const
|
|
5454
|
-
c = Math.min(c,
|
|
5512
|
+
for (const b of l)
|
|
5513
|
+
c = Math.min(c, b.x), g = Math.min(g, b.y), d = Math.max(d, b.x), f = Math.max(f, b.y);
|
|
5455
5514
|
const u = (c + d) / 2, m = (g + f) / 2;
|
|
5456
|
-
this.transformData.points = l.map((
|
|
5457
|
-
...
|
|
5458
|
-
x: u + (
|
|
5459
|
-
y: m + (
|
|
5460
|
-
handleIn:
|
|
5461
|
-
handleOut:
|
|
5462
|
-
})), this.transformData.width = e, this.transformData.height =
|
|
5463
|
-
const p = this.getFixedCorner(t, s), y = this.getOppositeAnchor(t),
|
|
5464
|
-
return this.x = p.x -
|
|
5515
|
+
this.transformData.points = l.map((b) => ({
|
|
5516
|
+
...b,
|
|
5517
|
+
x: u + (b.x - u) * n,
|
|
5518
|
+
y: m + (b.y - m) * h,
|
|
5519
|
+
handleIn: b.handleIn ? { x: b.handleIn.x * n, y: b.handleIn.y * h } : void 0,
|
|
5520
|
+
handleOut: b.handleOut ? { x: b.handleOut.x * n, y: b.handleOut.y * h } : void 0
|
|
5521
|
+
})), this.transformData.width = e, this.transformData.height = i, this.rotation = s.rotation;
|
|
5522
|
+
const p = this.getFixedCorner(t, s), y = this.getOppositeAnchor(t), w = this.getBoundingBox(), S = this.getCornerOffset(y, w);
|
|
5523
|
+
return this.x = p.x - S.x, this.y = p.y - S.y, !0;
|
|
5465
5524
|
}
|
|
5466
5525
|
/**
|
|
5467
5526
|
* Get the opposite anchor (the one that should stay fixed during resize)
|
|
@@ -5486,77 +5545,77 @@ class Mt extends Q {
|
|
|
5486
5545
|
* Get the position of the fixed corner (opposite of dragged anchor)
|
|
5487
5546
|
*/
|
|
5488
5547
|
getFixedCorner(t, e) {
|
|
5489
|
-
const
|
|
5548
|
+
const i = {
|
|
5490
5549
|
x: e.x - e.transformData.width / 2,
|
|
5491
5550
|
y: e.y - e.transformData.height / 2,
|
|
5492
5551
|
width: e.transformData.width,
|
|
5493
5552
|
height: e.transformData.height
|
|
5494
5553
|
};
|
|
5495
|
-
let s,
|
|
5554
|
+
let s, o;
|
|
5496
5555
|
switch (t) {
|
|
5497
5556
|
case "top-left":
|
|
5498
|
-
s =
|
|
5557
|
+
s = i.x + i.width, o = i.y + i.height;
|
|
5499
5558
|
break;
|
|
5500
5559
|
case "top-right":
|
|
5501
|
-
s =
|
|
5560
|
+
s = i.x, o = i.y + i.height;
|
|
5502
5561
|
break;
|
|
5503
5562
|
case "bottom-left":
|
|
5504
|
-
s =
|
|
5563
|
+
s = i.x + i.width, o = i.y;
|
|
5505
5564
|
break;
|
|
5506
5565
|
case "bottom-right":
|
|
5507
|
-
s =
|
|
5566
|
+
s = i.x, o = i.y;
|
|
5508
5567
|
break;
|
|
5509
5568
|
case "middle-left":
|
|
5510
|
-
s =
|
|
5569
|
+
s = i.x + i.width, o = i.y + i.height / 2;
|
|
5511
5570
|
break;
|
|
5512
5571
|
case "middle-right":
|
|
5513
|
-
s =
|
|
5572
|
+
s = i.x, o = i.y + i.height / 2;
|
|
5514
5573
|
break;
|
|
5515
5574
|
case "middle-top":
|
|
5516
|
-
s =
|
|
5575
|
+
s = i.x + i.width / 2, o = i.y + i.height;
|
|
5517
5576
|
break;
|
|
5518
5577
|
case "middle-bottom":
|
|
5519
|
-
s =
|
|
5578
|
+
s = i.x + i.width / 2, o = i.y;
|
|
5520
5579
|
break;
|
|
5521
5580
|
default:
|
|
5522
|
-
s =
|
|
5581
|
+
s = i.x + i.width / 2, o = i.y + i.height / 2;
|
|
5523
5582
|
}
|
|
5524
|
-
return { x: s, y:
|
|
5583
|
+
return { x: s, y: o };
|
|
5525
5584
|
}
|
|
5526
5585
|
/**
|
|
5527
5586
|
* Get the offset of a corner from the center
|
|
5528
5587
|
*/
|
|
5529
5588
|
getCornerOffset(t, e) {
|
|
5530
|
-
let
|
|
5589
|
+
let i, s;
|
|
5531
5590
|
switch (t) {
|
|
5532
5591
|
case "top-left":
|
|
5533
|
-
|
|
5592
|
+
i = -e.width / 2, s = -e.height / 2;
|
|
5534
5593
|
break;
|
|
5535
5594
|
case "top-right":
|
|
5536
|
-
|
|
5595
|
+
i = e.width / 2, s = -e.height / 2;
|
|
5537
5596
|
break;
|
|
5538
5597
|
case "bottom-left":
|
|
5539
|
-
|
|
5598
|
+
i = -e.width / 2, s = e.height / 2;
|
|
5540
5599
|
break;
|
|
5541
5600
|
case "bottom-right":
|
|
5542
|
-
|
|
5601
|
+
i = e.width / 2, s = e.height / 2;
|
|
5543
5602
|
break;
|
|
5544
5603
|
case "middle-left":
|
|
5545
|
-
|
|
5604
|
+
i = -e.width / 2, s = 0;
|
|
5546
5605
|
break;
|
|
5547
5606
|
case "middle-right":
|
|
5548
|
-
|
|
5607
|
+
i = e.width / 2, s = 0;
|
|
5549
5608
|
break;
|
|
5550
5609
|
case "middle-top":
|
|
5551
|
-
|
|
5610
|
+
i = 0, s = -e.height / 2;
|
|
5552
5611
|
break;
|
|
5553
5612
|
case "middle-bottom":
|
|
5554
|
-
|
|
5613
|
+
i = 0, s = e.height / 2;
|
|
5555
5614
|
break;
|
|
5556
5615
|
default:
|
|
5557
|
-
|
|
5616
|
+
i = 0, s = 0;
|
|
5558
5617
|
}
|
|
5559
|
-
return { x:
|
|
5618
|
+
return { x: i, y: s };
|
|
5560
5619
|
}
|
|
5561
5620
|
/**
|
|
5562
5621
|
* Get enabled anchors - all 8 anchors for free resize
|
|
@@ -5607,7 +5666,7 @@ class Mt extends Q {
|
|
|
5607
5666
|
};
|
|
5608
5667
|
}
|
|
5609
5668
|
}
|
|
5610
|
-
const
|
|
5669
|
+
const Je = {
|
|
5611
5670
|
circle: [
|
|
5612
5671
|
{
|
|
5613
5672
|
key: "reverse",
|
|
@@ -5620,7 +5679,7 @@ const _e = {
|
|
|
5620
5679
|
{
|
|
5621
5680
|
key: "archHeight",
|
|
5622
5681
|
label: "Arch Height",
|
|
5623
|
-
defaultInternalValue:
|
|
5682
|
+
defaultInternalValue: Ye.archHeight,
|
|
5624
5683
|
// Slider 0-100 maps to internal -1 to 1
|
|
5625
5684
|
toSlider: (r) => (r + 1) / 2 * 100,
|
|
5626
5685
|
fromSlider: (r) => r / 100 * 2 - 1,
|
|
@@ -5631,7 +5690,7 @@ const _e = {
|
|
|
5631
5690
|
{
|
|
5632
5691
|
key: "amplitude",
|
|
5633
5692
|
label: "Wave Amplitude",
|
|
5634
|
-
defaultInternalValue:
|
|
5693
|
+
defaultInternalValue: ot.amplitude,
|
|
5635
5694
|
// Slider 0-100 maps to internal -0.5 to 0.5 (-50% to +50%)
|
|
5636
5695
|
toSlider: (r) => (r + 0.5) * 100,
|
|
5637
5696
|
fromSlider: (r) => r / 100 - 0.5,
|
|
@@ -5640,7 +5699,7 @@ const _e = {
|
|
|
5640
5699
|
{
|
|
5641
5700
|
key: "frequency",
|
|
5642
5701
|
label: "Wave Frequency",
|
|
5643
|
-
defaultInternalValue:
|
|
5702
|
+
defaultInternalValue: ot.frequency,
|
|
5644
5703
|
step: 5,
|
|
5645
5704
|
// 5% steps for smoother control
|
|
5646
5705
|
// Slider 0-100 maps to internal 1 to 5
|
|
@@ -5673,7 +5732,7 @@ const _e = {
|
|
|
5673
5732
|
{
|
|
5674
5733
|
key: "leanAmount",
|
|
5675
5734
|
label: "Lean Amount",
|
|
5676
|
-
defaultInternalValue:
|
|
5735
|
+
defaultInternalValue: _e.leanAmount,
|
|
5677
5736
|
// Slider 0-100 maps to internal -0.5 to 0.5
|
|
5678
5737
|
// Display as -100% to 100%
|
|
5679
5738
|
toSlider: (r) => (r + 0.5) * 100,
|
|
@@ -5685,7 +5744,7 @@ const _e = {
|
|
|
5685
5744
|
{
|
|
5686
5745
|
key: "ascendAngle",
|
|
5687
5746
|
label: "Ascend Amount",
|
|
5688
|
-
defaultInternalValue:
|
|
5747
|
+
defaultInternalValue: Ne.ascendAngle,
|
|
5689
5748
|
// Slider 0-100 maps to internal angle +30° to -30°
|
|
5690
5749
|
// Display: slider 0 = -100% (down), slider 50 = 0%, slider 100 = +100% (up)
|
|
5691
5750
|
toSlider: (r) => (30 - r) / 60 * 100,
|
|
@@ -5761,18 +5820,18 @@ const _e = {
|
|
|
5761
5820
|
toDisplay: (r) => `${(r * 100).toFixed(0)}%`
|
|
5762
5821
|
}
|
|
5763
5822
|
]
|
|
5764
|
-
},
|
|
5765
|
-
{ id: "custom", label: "CUSTOM", Component:
|
|
5823
|
+
}, Jt = [
|
|
5824
|
+
{ id: "custom", label: "CUSTOM", Component: He },
|
|
5766
5825
|
// NOTE: distort transform is not yet implemented. Removed from registry
|
|
5767
5826
|
// to prevent it from appearing in UI that iterates over registered transforms.
|
|
5768
5827
|
// Re-add with a valid Component when implementation is ready.
|
|
5769
|
-
{ id: "circle", label: "CIRCLE", Component:
|
|
5770
|
-
{ id: "lean", label: "LEAN", Component:
|
|
5771
|
-
{ id: "arch", label: "ARCH", Component:
|
|
5772
|
-
{ id: "ascend", label: "ASCEND", Component:
|
|
5773
|
-
{ id: "wave", label: "WAVE", Component:
|
|
5774
|
-
{ id: "flag", label: "FLAG", Component:
|
|
5775
|
-
{ id: "shape", label: "SHAPE", Component:
|
|
5828
|
+
{ id: "circle", label: "CIRCLE", Component: ze },
|
|
5829
|
+
{ id: "lean", label: "LEAN", Component: $e },
|
|
5830
|
+
{ id: "arch", label: "ARCH", Component: Xe },
|
|
5831
|
+
{ id: "ascend", label: "ASCEND", Component: Ve },
|
|
5832
|
+
{ id: "wave", label: "WAVE", Component: Ue },
|
|
5833
|
+
{ id: "flag", label: "FLAG", Component: Ge },
|
|
5834
|
+
{ id: "shape", label: "SHAPE", Component: At },
|
|
5776
5835
|
{ id: "path", label: "PATH", Component: Mt },
|
|
5777
5836
|
{ id: "image", label: "IMAGE", Component: pt },
|
|
5778
5837
|
// Use a getter to break circular dependency: GroupElement imports getTransformById
|
|
@@ -5781,9 +5840,9 @@ const _e = {
|
|
|
5781
5840
|
{ id: "group", label: "GROUP", get Component() {
|
|
5782
5841
|
return ut;
|
|
5783
5842
|
} }
|
|
5784
|
-
],
|
|
5785
|
-
function
|
|
5786
|
-
if (
|
|
5843
|
+
], qt = new Set(Jt.map((r) => r.id)), ft = /* @__PURE__ */ new Map();
|
|
5844
|
+
function ss(r, t) {
|
|
5845
|
+
if (qt.has(r))
|
|
5787
5846
|
throw new Error(
|
|
5788
5847
|
`Cannot register transform type "${r}": conflicts with built-in type`
|
|
5789
5848
|
);
|
|
@@ -5793,25 +5852,25 @@ function Zo(r, t) {
|
|
|
5793
5852
|
);
|
|
5794
5853
|
ft.set(r, t);
|
|
5795
5854
|
}
|
|
5796
|
-
function
|
|
5797
|
-
if (
|
|
5855
|
+
function os(r) {
|
|
5856
|
+
if (qt.has(r))
|
|
5798
5857
|
throw new Error(
|
|
5799
5858
|
`Cannot unregister transform type "${r}": built-in types cannot be removed`
|
|
5800
5859
|
);
|
|
5801
5860
|
return ft.delete(r);
|
|
5802
5861
|
}
|
|
5803
|
-
function
|
|
5804
|
-
const t =
|
|
5862
|
+
function qe(r) {
|
|
5863
|
+
const t = Jt.find((e) => e.id === r);
|
|
5805
5864
|
return t || ft.get(r);
|
|
5806
5865
|
}
|
|
5807
|
-
function
|
|
5808
|
-
return
|
|
5866
|
+
function rs(r) {
|
|
5867
|
+
return Je[r] || [];
|
|
5809
5868
|
}
|
|
5810
5869
|
class ut extends Q {
|
|
5811
5870
|
constructor(t = {}) {
|
|
5812
5871
|
super(t), this.isGroup = !0, this._baseBBoxWidth = 0, this._baseBBoxHeight = 0, this._rotationCenterX = 0, this._rotationCenterY = 0, this.transformType = "group";
|
|
5813
5872
|
const e = t.children || [];
|
|
5814
|
-
this.children = e.map((
|
|
5873
|
+
this.children = e.map((i) => i instanceof Q ? i : this._reconstructChildFromJSON(i)), this.transformData = {
|
|
5815
5874
|
type: "group"
|
|
5816
5875
|
}, this.children.length > 0 && this.updateBoundsFromChildren(!0);
|
|
5817
5876
|
}
|
|
@@ -5822,10 +5881,10 @@ class ut extends Q {
|
|
|
5822
5881
|
*/
|
|
5823
5882
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- JSON deserialization: config comes from toJSON() and constructors accept Partial<Config> with varying signatures
|
|
5824
5883
|
_reconstructChildFromJSON(t) {
|
|
5825
|
-
const e = t.transformType || t.type,
|
|
5826
|
-
if (!
|
|
5884
|
+
const e = t.transformType || t.type, i = qe(e);
|
|
5885
|
+
if (!i || !i.Component)
|
|
5827
5886
|
throw new Error(`Unknown transform type: ${e}`);
|
|
5828
|
-
return new
|
|
5887
|
+
return new i.Component(t);
|
|
5829
5888
|
}
|
|
5830
5889
|
/**
|
|
5831
5890
|
* Calculate group bounds from all children
|
|
@@ -5834,16 +5893,16 @@ class ut extends Q {
|
|
|
5834
5893
|
getBoundingBox() {
|
|
5835
5894
|
if (this.children.length === 0)
|
|
5836
5895
|
return { x: this.x - 50, y: this.y - 50, width: 100, height: 100 };
|
|
5837
|
-
let t = 1 / 0, e = 1 / 0,
|
|
5838
|
-
return this.children.forEach((
|
|
5839
|
-
const a =
|
|
5840
|
-
this._getRotatedCorners(
|
|
5841
|
-
t = Math.min(t, h.x), e = Math.min(e, h.y),
|
|
5896
|
+
let t = 1 / 0, e = 1 / 0, i = -1 / 0, s = -1 / 0;
|
|
5897
|
+
return this.children.forEach((o) => {
|
|
5898
|
+
const a = o.getVisualBoundingBox();
|
|
5899
|
+
this._getRotatedCorners(o, a).forEach((h) => {
|
|
5900
|
+
t = Math.min(t, h.x), e = Math.min(e, h.y), i = Math.max(i, h.x), s = Math.max(s, h.y);
|
|
5842
5901
|
});
|
|
5843
5902
|
}), {
|
|
5844
5903
|
x: t,
|
|
5845
5904
|
y: e,
|
|
5846
|
-
width:
|
|
5905
|
+
width: i - t,
|
|
5847
5906
|
height: s - e
|
|
5848
5907
|
};
|
|
5849
5908
|
}
|
|
@@ -5868,13 +5927,13 @@ class ut extends Q {
|
|
|
5868
5927
|
* Get the four corners of an element's bounding box in world space
|
|
5869
5928
|
*/
|
|
5870
5929
|
_getRotatedCorners(t, e) {
|
|
5871
|
-
const
|
|
5930
|
+
const i = new P(t), s = e.x + e.width / 2, o = e.y + e.height / 2, a = s - t.x, n = o - t.y;
|
|
5872
5931
|
return [
|
|
5873
5932
|
{ localX: a - e.width / 2, localY: n - e.height / 2 },
|
|
5874
5933
|
{ localX: a + e.width / 2, localY: n - e.height / 2 },
|
|
5875
5934
|
{ localX: a - e.width / 2, localY: n + e.height / 2 },
|
|
5876
5935
|
{ localX: a + e.width / 2, localY: n + e.height / 2 }
|
|
5877
|
-
].map((l) =>
|
|
5936
|
+
].map((l) => i.localToWorld(l.localX, l.localY));
|
|
5878
5937
|
}
|
|
5879
5938
|
/**
|
|
5880
5939
|
* Update group center and size from children
|
|
@@ -5883,8 +5942,8 @@ class ut extends Q {
|
|
|
5883
5942
|
updateBoundsFromChildren(t = !1) {
|
|
5884
5943
|
const e = this.getBoundingBox();
|
|
5885
5944
|
if (this.x = e.x + e.width / 2, this.y = e.y + e.height / 2, t || this._baseBBoxWidth === 0 || this._baseBBoxHeight === 0) {
|
|
5886
|
-
const
|
|
5887
|
-
this._baseBBoxWidth =
|
|
5945
|
+
const i = this._calculateInitialDimensions();
|
|
5946
|
+
this._baseBBoxWidth = i.width, this._baseBBoxHeight = i.height, this._rotationCenterX = this.x, this._rotationCenterY = this.y;
|
|
5888
5947
|
}
|
|
5889
5948
|
}
|
|
5890
5949
|
/**
|
|
@@ -5907,21 +5966,21 @@ class ut extends Q {
|
|
|
5907
5966
|
* Render the group with clipping support
|
|
5908
5967
|
* Elements with isClipping=true clip all elements below them in the group
|
|
5909
5968
|
*/
|
|
5910
|
-
render(t, e = !1,
|
|
5969
|
+
render(t, e = !1, i = !1) {
|
|
5911
5970
|
const s = this.children.filter((a) => a.visible !== !1);
|
|
5912
|
-
s.some((a) => a.isClipping) ?
|
|
5971
|
+
s.some((a) => a.isClipping) ? Ae()(t, s) : s.forEach((a) => {
|
|
5913
5972
|
a.render(t, !1);
|
|
5914
|
-
}), e ? this._renderGroupOutline(t, 1) :
|
|
5973
|
+
}), e ? this._renderGroupOutline(t, 1) : i && this._renderGroupOutline(t, 0.3);
|
|
5915
5974
|
}
|
|
5916
5975
|
/**
|
|
5917
5976
|
* Render dashed outline around group
|
|
5918
5977
|
* Uses an oriented bounding box that doesn't change size during rotation
|
|
5919
5978
|
*/
|
|
5920
5979
|
_renderGroupOutline(t, e = 1) {
|
|
5921
|
-
const
|
|
5922
|
-
t.save(), t.globalAlpha = e, t.strokeStyle =
|
|
5923
|
-
const s = this._rotationCenterX || this.x,
|
|
5924
|
-
this.rotation !== 0 && (t.translate(s,
|
|
5980
|
+
const i = this.getOrientedBoundingBox();
|
|
5981
|
+
t.save(), t.globalAlpha = e, t.strokeStyle = zt(), t.lineWidth = 2, t.setLineDash([5, 5]);
|
|
5982
|
+
const s = this._rotationCenterX || this.x, o = this._rotationCenterY || this.y;
|
|
5983
|
+
this.rotation !== 0 && (t.translate(s, o), t.rotate(-this.rotation * Math.PI / 180), t.translate(-s, -o)), t.strokeRect(i.x, i.y, i.width, i.height), t.setLineDash([]), t.restore();
|
|
5925
5984
|
}
|
|
5926
5985
|
/**
|
|
5927
5986
|
* Get oriented bounding box (uses cached base dimensions for stability during rotation)
|
|
@@ -5938,12 +5997,12 @@ class ut extends Q {
|
|
|
5938
5997
|
if (this._baseBBoxWidth > 0 && this._baseBBoxHeight > 0)
|
|
5939
5998
|
t = this._baseBBoxWidth, e = this._baseBBoxHeight;
|
|
5940
5999
|
else {
|
|
5941
|
-
const
|
|
5942
|
-
t =
|
|
6000
|
+
const o = this.getBoundingBox();
|
|
6001
|
+
t = o.width, e = o.height, this._baseBBoxWidth = t, this._baseBBoxHeight = e;
|
|
5943
6002
|
}
|
|
5944
|
-
const
|
|
6003
|
+
const i = this._rotationCenterX || this.x, s = this._rotationCenterY || this.y;
|
|
5945
6004
|
return {
|
|
5946
|
-
x:
|
|
6005
|
+
x: i - t / 2,
|
|
5947
6006
|
y: s - e / 2,
|
|
5948
6007
|
width: t,
|
|
5949
6008
|
height: e
|
|
@@ -5953,8 +6012,8 @@ class ut extends Q {
|
|
|
5953
6012
|
* Move the group (moves all children)
|
|
5954
6013
|
*/
|
|
5955
6014
|
move(t, e) {
|
|
5956
|
-
this.x += t, this.y += e, this._rotationCenterX += t, this._rotationCenterY += e, this.children.forEach((
|
|
5957
|
-
|
|
6015
|
+
this.x += t, this.y += e, this._rotationCenterX += t, this._rotationCenterY += e, this.children.forEach((i) => {
|
|
6016
|
+
i.move(t, e);
|
|
5958
6017
|
});
|
|
5959
6018
|
}
|
|
5960
6019
|
/**
|
|
@@ -5963,20 +6022,20 @@ class ut extends Q {
|
|
|
5963
6022
|
setRotation(t) {
|
|
5964
6023
|
const e = t - this.rotation;
|
|
5965
6024
|
this.rotation = t;
|
|
5966
|
-
const
|
|
5967
|
-
this.children.forEach((
|
|
5968
|
-
const a =
|
|
5969
|
-
|
|
5970
|
-
}), this.x =
|
|
6025
|
+
const i = this._rotationCenterX || this.x, s = this._rotationCenterY || this.y;
|
|
6026
|
+
this.children.forEach((o) => {
|
|
6027
|
+
const a = P.rotatePointAroundAnchor(o.x, o.y, i, s, e);
|
|
6028
|
+
o.x = a.x, o.y = a.y, o.setRotation(o.rotation + e);
|
|
6029
|
+
}), this.x = i, this.y = s;
|
|
5971
6030
|
}
|
|
5972
6031
|
/**
|
|
5973
6032
|
* Resize the group (scales all children proportionally)
|
|
5974
6033
|
* Uses the same fixed-corner approach as multi-selection resize
|
|
5975
6034
|
*/
|
|
5976
|
-
resize(t, e,
|
|
6035
|
+
resize(t, e, i, s) {
|
|
5977
6036
|
if (!s.childrenStartData || !s.width || !s.height)
|
|
5978
6037
|
return;
|
|
5979
|
-
const
|
|
6038
|
+
const o = e / s.width, a = i / s.height, n = (o + a) / 2;
|
|
5980
6039
|
let h, l;
|
|
5981
6040
|
switch (t) {
|
|
5982
6041
|
case "top-left":
|
|
@@ -5995,17 +6054,17 @@ class ut extends Q {
|
|
|
5995
6054
|
h = 0, l = 0;
|
|
5996
6055
|
}
|
|
5997
6056
|
const c = -s.rotation * Math.PI / 180, g = Math.cos(c), d = Math.sin(c), f = s.x + (h * g - l * d), u = s.y + (h * d + l * g);
|
|
5998
|
-
this.children.forEach((y,
|
|
5999
|
-
const
|
|
6000
|
-
if (y.x =
|
|
6001
|
-
const F =
|
|
6002
|
-
y.transformData.width =
|
|
6057
|
+
this.children.forEach((y, w) => {
|
|
6058
|
+
const S = s.childrenStartData[w], b = S.x - f, T = S.y - u, C = f + b * n, M = u + T * n;
|
|
6059
|
+
if (y.x = C, y.y = M, y instanceof pt) {
|
|
6060
|
+
const F = S.transformData, v = F.width * n, D = F.height * n;
|
|
6061
|
+
y.transformData.width = v, y.transformData.height = D;
|
|
6003
6062
|
} else if (y instanceof ut) {
|
|
6004
|
-
const F = (
|
|
6005
|
-
y.resize(t, F,
|
|
6063
|
+
const F = (S.width ?? 0) * n, v = (S.height ?? 0) * n;
|
|
6064
|
+
y.resize(t, F, v, S);
|
|
6006
6065
|
} else {
|
|
6007
|
-
const F = (
|
|
6008
|
-
y.resize(t, F,
|
|
6066
|
+
const F = (S.width ?? 0) * n, v = (S.height ?? 0) * n;
|
|
6067
|
+
y.resize(t, F, v, S);
|
|
6009
6068
|
}
|
|
6010
6069
|
}), this._baseBBoxWidth = s.width * n, this._baseBBoxHeight = s.height * n;
|
|
6011
6070
|
const m = s.x - f, p = s.y - u;
|
|
@@ -6016,16 +6075,16 @@ class ut extends Q {
|
|
|
6016
6075
|
* Use cached base dimensions instead of axis-aligned bbox for consistency with visual border
|
|
6017
6076
|
*/
|
|
6018
6077
|
getTransformStartData() {
|
|
6019
|
-
const t = this._baseBBoxWidth > 0 ? this._baseBBoxWidth : this.getBoundingBox().width, e = this._baseBBoxHeight > 0 ? this._baseBBoxHeight : this.getBoundingBox().height,
|
|
6078
|
+
const t = this._baseBBoxWidth > 0 ? this._baseBBoxWidth : this.getBoundingBox().width, e = this._baseBBoxHeight > 0 ? this._baseBBoxHeight : this.getBoundingBox().height, i = this._rotationCenterX || this.x, s = this._rotationCenterY || this.y;
|
|
6020
6079
|
return {
|
|
6021
6080
|
id: this.id,
|
|
6022
|
-
x:
|
|
6081
|
+
x: i,
|
|
6023
6082
|
y: s,
|
|
6024
6083
|
width: t,
|
|
6025
6084
|
height: e,
|
|
6026
6085
|
rotation: this.rotation,
|
|
6027
6086
|
transformData: this.transformData,
|
|
6028
|
-
childrenStartData: this.children.map((
|
|
6087
|
+
childrenStartData: this.children.map((o) => o.getTransformStartData())
|
|
6029
6088
|
};
|
|
6030
6089
|
}
|
|
6031
6090
|
/**
|
|
@@ -6033,11 +6092,11 @@ class ut extends Q {
|
|
|
6033
6092
|
* This allows clicking anywhere within the selection border to drag the group
|
|
6034
6093
|
*/
|
|
6035
6094
|
hitTest(t, e) {
|
|
6036
|
-
const
|
|
6095
|
+
const i = this.getOrientedBoundingBox(), s = this._rotationCenterX || this.x, o = this._rotationCenterY || this.y;
|
|
6037
6096
|
if (this.rotation === 0)
|
|
6038
|
-
return t >=
|
|
6039
|
-
const a = this.rotation * Math.PI / 180, n = Math.cos(a), h = Math.sin(a), l = t - s, c = e -
|
|
6040
|
-
return g >=
|
|
6097
|
+
return t >= i.x && t <= i.x + i.width && e >= i.y && e <= i.y + i.height;
|
|
6098
|
+
const a = this.rotation * Math.PI / 180, n = Math.cos(a), h = Math.sin(a), l = t - s, c = e - o, g = s + (l * n - c * h), d = o + (l * h + c * n);
|
|
6099
|
+
return g >= i.x && g <= i.x + i.width && d >= i.y && d <= i.y + i.height;
|
|
6041
6100
|
}
|
|
6042
6101
|
/**
|
|
6043
6102
|
* Only corner handles for groups (uniform scale)
|
|
@@ -6062,7 +6121,7 @@ class ut extends Q {
|
|
|
6062
6121
|
* Clone the group (deep copy with children)
|
|
6063
6122
|
*/
|
|
6064
6123
|
clone() {
|
|
6065
|
-
const t = this.children.map((
|
|
6124
|
+
const t = this.children.map((i) => i.clone()), e = new ut({
|
|
6066
6125
|
id: this.id,
|
|
6067
6126
|
x: this.x,
|
|
6068
6127
|
y: this.y,
|
|
@@ -6073,9 +6132,9 @@ class ut extends Q {
|
|
|
6073
6132
|
return e._baseBBoxWidth = this._baseBBoxWidth, e._baseBBoxHeight = this._baseBBoxHeight, e._rotationCenterX = this._rotationCenterX, e._rotationCenterY = this._rotationCenterY, e.opacity = this.opacity, e.name = this.name, e.visible = this.visible, e.locked = this.locked, this.blendMode && (e.blendMode = this.blendMode), this.knockoutParts && (e.knockoutParts = { ...this.knockoutParts }), this.stroke && (e.stroke = {
|
|
6074
6133
|
...this.stroke,
|
|
6075
6134
|
...this.stroke.dashArray && { dashArray: [...this.stroke.dashArray] }
|
|
6076
|
-
}), this.masks && (e.masks = this.masks.map((
|
|
6077
|
-
...
|
|
6078
|
-
maskElement: structuredClone(
|
|
6135
|
+
}), this.masks && (e.masks = this.masks.map((i) => ({
|
|
6136
|
+
...i,
|
|
6137
|
+
maskElement: structuredClone(i.maskElement)
|
|
6079
6138
|
}))), this.distressEffect && (e.distressEffect = { ...this.distressEffect }), e;
|
|
6080
6139
|
}
|
|
6081
6140
|
/**
|
|
@@ -6088,7 +6147,7 @@ class ut extends Q {
|
|
|
6088
6147
|
* Remove a child from the group
|
|
6089
6148
|
*/
|
|
6090
6149
|
removeChild(t) {
|
|
6091
|
-
const e = this.children.findIndex((
|
|
6150
|
+
const e = this.children.findIndex((i) => i.id === t);
|
|
6092
6151
|
return e >= 0 ? (this.children.splice(e, 1), this.updateBoundsFromChildren(!0), !0) : !1;
|
|
6093
6152
|
}
|
|
6094
6153
|
/**
|
|
@@ -6102,8 +6161,8 @@ class ut extends Q {
|
|
|
6102
6161
|
* Returns the child element or null if no child was hit
|
|
6103
6162
|
*/
|
|
6104
6163
|
hitTestChild(t, e) {
|
|
6105
|
-
for (let
|
|
6106
|
-
const s = this.children[
|
|
6164
|
+
for (let i = this.children.length - 1; i >= 0; i--) {
|
|
6165
|
+
const s = this.children[i];
|
|
6107
6166
|
if (s.hitTest(t, e))
|
|
6108
6167
|
return s;
|
|
6109
6168
|
}
|
|
@@ -6142,15 +6201,15 @@ class Z {
|
|
|
6142
6201
|
/** O(n) lookup by name. Returns the first element with the given name, or undefined. */
|
|
6143
6202
|
getByName(t) {
|
|
6144
6203
|
for (const e of this.order) {
|
|
6145
|
-
const
|
|
6146
|
-
if (
|
|
6204
|
+
const i = this.byId.get(e);
|
|
6205
|
+
if (i && i.name === t) return i;
|
|
6147
6206
|
}
|
|
6148
6207
|
}
|
|
6149
6208
|
/** O(n) lookup by name. Returns all elements with the given name in render order. */
|
|
6150
6209
|
getAllByName(t) {
|
|
6151
6210
|
const e = [];
|
|
6152
|
-
for (const
|
|
6153
|
-
const s = this.byId.get(
|
|
6211
|
+
for (const i of this.order) {
|
|
6212
|
+
const s = this.byId.get(i);
|
|
6154
6213
|
s && s.name === t && e.push(s);
|
|
6155
6214
|
}
|
|
6156
6215
|
return e;
|
|
@@ -6169,13 +6228,13 @@ class Z {
|
|
|
6169
6228
|
*/
|
|
6170
6229
|
updateById(t, e) {
|
|
6171
6230
|
if (!this.byId.has(t)) return this;
|
|
6172
|
-
const
|
|
6231
|
+
const i = this.clone();
|
|
6173
6232
|
if (t !== e.id) {
|
|
6174
|
-
|
|
6175
|
-
const s =
|
|
6176
|
-
s !== -1 && (
|
|
6233
|
+
i.byId.delete(t);
|
|
6234
|
+
const s = i.order.indexOf(t);
|
|
6235
|
+
s !== -1 && (i.order[s] = e.id);
|
|
6177
6236
|
}
|
|
6178
|
-
return
|
|
6237
|
+
return i.byId.set(e.id, e), i;
|
|
6179
6238
|
}
|
|
6180
6239
|
/** Add an element at the end of the render order. */
|
|
6181
6240
|
add(t) {
|
|
@@ -6184,21 +6243,21 @@ class Z {
|
|
|
6184
6243
|
}
|
|
6185
6244
|
/** Insert an element after a specific element ID. */
|
|
6186
6245
|
insertAfter(t, e) {
|
|
6187
|
-
const
|
|
6188
|
-
|
|
6189
|
-
const s =
|
|
6190
|
-
return s !== -1 ?
|
|
6246
|
+
const i = this.clone();
|
|
6247
|
+
i.byId.set(t.id, t);
|
|
6248
|
+
const s = i.order.indexOf(e);
|
|
6249
|
+
return s !== -1 ? i.order.splice(s + 1, 0, t.id) : i.order.push(t.id), i;
|
|
6191
6250
|
}
|
|
6192
6251
|
/** Remove an element by ID. */
|
|
6193
6252
|
remove(t) {
|
|
6194
6253
|
if (!this.byId.has(t)) return this;
|
|
6195
6254
|
const e = this.clone();
|
|
6196
|
-
return e.byId.delete(t), e.order = e.order.filter((
|
|
6255
|
+
return e.byId.delete(t), e.order = e.order.filter((i) => i !== t), e;
|
|
6197
6256
|
}
|
|
6198
6257
|
/** Reorder element to a new index in the render order. */
|
|
6199
6258
|
reorder(t, e) {
|
|
6200
|
-
const
|
|
6201
|
-
return
|
|
6259
|
+
const i = this.clone();
|
|
6260
|
+
return i.order = i.order.filter((s) => s !== t), i.order.splice(e, 0, t), i;
|
|
6202
6261
|
}
|
|
6203
6262
|
/**
|
|
6204
6263
|
* Apply a batch update: replace elements whose IDs match.
|
|
@@ -6230,7 +6289,7 @@ class Z {
|
|
|
6230
6289
|
*/
|
|
6231
6290
|
setOrder(t) {
|
|
6232
6291
|
const e = this.clone();
|
|
6233
|
-
return e.order = t.filter((
|
|
6292
|
+
return e.order = t.filter((i) => e.byId.has(i)), e;
|
|
6234
6293
|
}
|
|
6235
6294
|
// ---------------------------------------------------------------------------
|
|
6236
6295
|
// Conversion helpers
|
|
@@ -6252,7 +6311,7 @@ class Z {
|
|
|
6252
6311
|
return t.byId = new Map(this.byId), t.order = [...this.order], t;
|
|
6253
6312
|
}
|
|
6254
6313
|
}
|
|
6255
|
-
class
|
|
6314
|
+
class $ {
|
|
6256
6315
|
/**
|
|
6257
6316
|
* Execute the command
|
|
6258
6317
|
*/
|
|
@@ -6266,9 +6325,9 @@ class U {
|
|
|
6266
6325
|
throw new Error("Command.undo() must be implemented");
|
|
6267
6326
|
}
|
|
6268
6327
|
}
|
|
6269
|
-
class
|
|
6270
|
-
constructor(t, e,
|
|
6271
|
-
super(), this.elementId = t, this.oldElement = e ? e.clone() : null, this.newElement =
|
|
6328
|
+
class ns extends $ {
|
|
6329
|
+
constructor(t, e, i, s) {
|
|
6330
|
+
super(), this.elementId = t, this.oldElement = e ? e.clone() : null, this.newElement = i ? i.clone() : null, this.onUpdate = s;
|
|
6272
6331
|
}
|
|
6273
6332
|
execute() {
|
|
6274
6333
|
this.newElement && this.onUpdate(this.newElement);
|
|
@@ -6277,9 +6336,9 @@ class ts extends U {
|
|
|
6277
6336
|
this.oldElement && this.onUpdate(this.oldElement);
|
|
6278
6337
|
}
|
|
6279
6338
|
}
|
|
6280
|
-
class
|
|
6281
|
-
constructor(t, e,
|
|
6282
|
-
super(), this.element = t.clone(), this.onAdd = e, this.onRemove =
|
|
6339
|
+
class as extends $ {
|
|
6340
|
+
constructor(t, e, i) {
|
|
6341
|
+
super(), this.element = t.clone(), this.onAdd = e, this.onRemove = i;
|
|
6283
6342
|
}
|
|
6284
6343
|
execute() {
|
|
6285
6344
|
this.onAdd(this.element);
|
|
@@ -6288,9 +6347,9 @@ class es extends U {
|
|
|
6288
6347
|
this.onRemove(this.element.id);
|
|
6289
6348
|
}
|
|
6290
6349
|
}
|
|
6291
|
-
class
|
|
6292
|
-
constructor(t, e,
|
|
6293
|
-
super(), this.element = t.clone(), this.onAdd = e, this.onRemove =
|
|
6350
|
+
class hs extends $ {
|
|
6351
|
+
constructor(t, e, i) {
|
|
6352
|
+
super(), this.element = t.clone(), this.onAdd = e, this.onRemove = i;
|
|
6294
6353
|
}
|
|
6295
6354
|
execute() {
|
|
6296
6355
|
this.onRemove(this.element.id);
|
|
@@ -6299,7 +6358,7 @@ class os extends U {
|
|
|
6299
6358
|
this.onAdd(this.element);
|
|
6300
6359
|
}
|
|
6301
6360
|
}
|
|
6302
|
-
class
|
|
6361
|
+
class je extends $ {
|
|
6303
6362
|
constructor(t) {
|
|
6304
6363
|
super(), this.commands = t;
|
|
6305
6364
|
}
|
|
@@ -6331,7 +6390,7 @@ class ct {
|
|
|
6331
6390
|
executeBatch(t) {
|
|
6332
6391
|
if (t.length === 0)
|
|
6333
6392
|
return;
|
|
6334
|
-
const e = new
|
|
6393
|
+
const e = new je(t);
|
|
6335
6394
|
this.execute(e);
|
|
6336
6395
|
}
|
|
6337
6396
|
/**
|
|
@@ -6376,7 +6435,7 @@ class ct {
|
|
|
6376
6435
|
};
|
|
6377
6436
|
}
|
|
6378
6437
|
}
|
|
6379
|
-
class
|
|
6438
|
+
class ls extends $ {
|
|
6380
6439
|
constructor(t, e) {
|
|
6381
6440
|
super(), this.artboard = t.clone(), this.artboardManager = e;
|
|
6382
6441
|
}
|
|
@@ -6396,7 +6455,7 @@ class ss extends U {
|
|
|
6396
6455
|
this.artboardManager.deleteArtboard(this.artboard.id);
|
|
6397
6456
|
}
|
|
6398
6457
|
}
|
|
6399
|
-
class
|
|
6458
|
+
class cs extends $ {
|
|
6400
6459
|
constructor(t, e) {
|
|
6401
6460
|
super(), this.artboard = t.clone(), this.artboardManager = e, this.elementsOnArtboard = t.getElementIds();
|
|
6402
6461
|
}
|
|
@@ -6419,9 +6478,9 @@ class is extends U {
|
|
|
6419
6478
|
});
|
|
6420
6479
|
}
|
|
6421
6480
|
}
|
|
6422
|
-
class
|
|
6423
|
-
constructor(t, e,
|
|
6424
|
-
super(), this.artboardId = t, this.oldProperties = { ...e }, this.newProperties = { ...
|
|
6481
|
+
class ds extends $ {
|
|
6482
|
+
constructor(t, e, i, s) {
|
|
6483
|
+
super(), this.artboardId = t, this.oldProperties = { ...e }, this.newProperties = { ...i }, this.artboardManager = s;
|
|
6425
6484
|
}
|
|
6426
6485
|
execute() {
|
|
6427
6486
|
this.artboardManager.updateArtboard(this.artboardId, this.newProperties);
|
|
@@ -6430,17 +6489,17 @@ class rs extends U {
|
|
|
6430
6489
|
this.artboardManager.updateArtboard(this.artboardId, this.oldProperties);
|
|
6431
6490
|
}
|
|
6432
6491
|
}
|
|
6433
|
-
class
|
|
6434
|
-
constructor(t, e,
|
|
6435
|
-
super(), this.draggedId = t, this.targetId = e, this.position =
|
|
6492
|
+
class gs extends $ {
|
|
6493
|
+
constructor(t, e, i, s, o) {
|
|
6494
|
+
super(), this.draggedId = t, this.targetId = e, this.position = i, this.oldOrder = [...s], this.onReorder = o, this.newOrder = this.calculateNewOrder();
|
|
6436
6495
|
}
|
|
6437
6496
|
calculateNewOrder() {
|
|
6438
6497
|
const t = [...this.oldOrder], e = t.indexOf(this.draggedId);
|
|
6439
6498
|
if (e === -1) return t;
|
|
6440
6499
|
t.splice(e, 1);
|
|
6441
|
-
const
|
|
6442
|
-
if (
|
|
6443
|
-
const s = this.position === "before" ?
|
|
6500
|
+
const i = t.indexOf(this.targetId);
|
|
6501
|
+
if (i === -1) return t;
|
|
6502
|
+
const s = this.position === "before" ? i : i + 1;
|
|
6444
6503
|
return t.splice(s, 0, this.draggedId), t;
|
|
6445
6504
|
}
|
|
6446
6505
|
execute() {
|
|
@@ -6450,8 +6509,8 @@ class ns extends U {
|
|
|
6450
6509
|
this.onReorder(this.oldOrder);
|
|
6451
6510
|
}
|
|
6452
6511
|
}
|
|
6453
|
-
const
|
|
6454
|
-
class
|
|
6512
|
+
const Ze = mt("HybridHistoryManager");
|
|
6513
|
+
class fs {
|
|
6455
6514
|
constructor(t, e = 50) {
|
|
6456
6515
|
this.commandExecutedCallbacks = [], this.globalHistory = new ct(e), this.artboardHistories = /* @__PURE__ */ new Map(), this.lastOperation = null, this.artboardManager = t, this.maxHistorySize = e;
|
|
6457
6516
|
}
|
|
@@ -6468,12 +6527,12 @@ class as {
|
|
|
6468
6527
|
/**
|
|
6469
6528
|
* Notify all callbacks that a command was executed
|
|
6470
6529
|
*/
|
|
6471
|
-
notifyCommandExecuted(t, e,
|
|
6530
|
+
notifyCommandExecuted(t, e, i) {
|
|
6472
6531
|
for (const s of this.commandExecutedCallbacks)
|
|
6473
6532
|
try {
|
|
6474
|
-
s(t, e,
|
|
6475
|
-
} catch (
|
|
6476
|
-
|
|
6533
|
+
s(t, e, i);
|
|
6534
|
+
} catch (o) {
|
|
6535
|
+
Ze.error("Error in command executed callback:", o);
|
|
6477
6536
|
}
|
|
6478
6537
|
}
|
|
6479
6538
|
/**
|
|
@@ -6506,21 +6565,21 @@ class as {
|
|
|
6506
6565
|
executeBatchOnArtboard(t, e) {
|
|
6507
6566
|
if (e.length === 0)
|
|
6508
6567
|
return;
|
|
6509
|
-
let
|
|
6510
|
-
|
|
6568
|
+
let i = this.artboardHistories.get(t);
|
|
6569
|
+
i || (i = new ct(this.maxHistorySize), this.artboardHistories.set(t, i)), i.executeBatch(e), this.lastOperation = {
|
|
6511
6570
|
type: "artboard",
|
|
6512
6571
|
artboardId: t,
|
|
6513
6572
|
timestamp: Date.now()
|
|
6514
6573
|
};
|
|
6515
|
-
const s =
|
|
6574
|
+
const s = i.history[i.currentIndex];
|
|
6516
6575
|
this.notifyCommandExecuted(s, "artboard", t);
|
|
6517
6576
|
}
|
|
6518
6577
|
/**
|
|
6519
6578
|
* Execute a command on a specific artboard
|
|
6520
6579
|
*/
|
|
6521
6580
|
executeOnArtboard(t, e) {
|
|
6522
|
-
let
|
|
6523
|
-
|
|
6581
|
+
let i = this.artboardHistories.get(t);
|
|
6582
|
+
i || (i = new ct(this.maxHistorySize), this.artboardHistories.set(t, i)), i.execute(e), this.lastOperation = {
|
|
6524
6583
|
type: "artboard",
|
|
6525
6584
|
artboardId: t,
|
|
6526
6585
|
timestamp: Date.now()
|
|
@@ -6583,8 +6642,8 @@ class as {
|
|
|
6583
6642
|
const e = this.artboardHistories.get(t);
|
|
6584
6643
|
if (!e)
|
|
6585
6644
|
return !1;
|
|
6586
|
-
const
|
|
6587
|
-
return
|
|
6645
|
+
const i = e.undo();
|
|
6646
|
+
return i && this.updateLastOperation("artboard", t), i;
|
|
6588
6647
|
}
|
|
6589
6648
|
/**
|
|
6590
6649
|
* Redo artboard operation
|
|
@@ -6593,8 +6652,8 @@ class as {
|
|
|
6593
6652
|
const e = this.artboardHistories.get(t);
|
|
6594
6653
|
if (!e)
|
|
6595
6654
|
return !1;
|
|
6596
|
-
const
|
|
6597
|
-
return
|
|
6655
|
+
const i = e.redo();
|
|
6656
|
+
return i && this.updateLastOperation("artboard", t), i;
|
|
6598
6657
|
}
|
|
6599
6658
|
/**
|
|
6600
6659
|
* Check if global undo is available
|
|
@@ -6679,12 +6738,12 @@ class as {
|
|
|
6679
6738
|
*/
|
|
6680
6739
|
getState() {
|
|
6681
6740
|
const t = this.globalHistory.getState(), e = /* @__PURE__ */ new Map();
|
|
6682
|
-
return this.artboardHistories.forEach((
|
|
6683
|
-
const
|
|
6741
|
+
return this.artboardHistories.forEach((i, s) => {
|
|
6742
|
+
const o = i.getState();
|
|
6684
6743
|
e.set(s, {
|
|
6685
|
-
canUndo:
|
|
6686
|
-
canRedo:
|
|
6687
|
-
historySize:
|
|
6744
|
+
canUndo: o.canUndo,
|
|
6745
|
+
canRedo: o.canRedo,
|
|
6746
|
+
historySize: o.historySize
|
|
6688
6747
|
});
|
|
6689
6748
|
}), {
|
|
6690
6749
|
global: {
|
|
@@ -6745,12 +6804,12 @@ class as {
|
|
|
6745
6804
|
return this.canRedoGlobal() ? "Redo artboard operation" : "Nothing to redo";
|
|
6746
6805
|
}
|
|
6747
6806
|
}
|
|
6748
|
-
const
|
|
6749
|
-
let
|
|
6750
|
-
async function
|
|
6751
|
-
return
|
|
6807
|
+
const G = mt("FontAnalyzer");
|
|
6808
|
+
let bt = null;
|
|
6809
|
+
async function Ke() {
|
|
6810
|
+
return bt || (bt = await import("./browser-module-DFvKXBUE.js")), bt;
|
|
6752
6811
|
}
|
|
6753
|
-
class
|
|
6812
|
+
class Qe {
|
|
6754
6813
|
constructor() {
|
|
6755
6814
|
this.fontCache = /* @__PURE__ */ new Map(), this.failedFonts = /* @__PURE__ */ new Set(), this.CACHE_DURATION = 1e3 * 60 * 30, this.MAX_CACHE_SIZE = 5;
|
|
6756
6815
|
}
|
|
@@ -6762,15 +6821,15 @@ class Ve {
|
|
|
6762
6821
|
evictOldestFont() {
|
|
6763
6822
|
if (this.fontCache.size <= this.MAX_CACHE_SIZE) return;
|
|
6764
6823
|
let t = null, e = Date.now();
|
|
6765
|
-
this.fontCache.forEach((
|
|
6766
|
-
|
|
6824
|
+
this.fontCache.forEach((i, s) => {
|
|
6825
|
+
i.timestamp < e && (e = i.timestamp, t = s);
|
|
6767
6826
|
}), t && this.fontCache.delete(t);
|
|
6768
6827
|
}
|
|
6769
6828
|
/**
|
|
6770
6829
|
* Check if a font is a system font
|
|
6771
6830
|
*/
|
|
6772
6831
|
isSystemFont(t) {
|
|
6773
|
-
return
|
|
6832
|
+
return we.has(t);
|
|
6774
6833
|
}
|
|
6775
6834
|
/**
|
|
6776
6835
|
* Get Google Fonts API URL for a specific font family
|
|
@@ -6783,9 +6842,9 @@ class Ve {
|
|
|
6783
6842
|
*/
|
|
6784
6843
|
async extractFontFileUrl(t, e = 400) {
|
|
6785
6844
|
try {
|
|
6786
|
-
const
|
|
6845
|
+
const i = this.getGoogleFontUrl(t, e), o = await (await fetch(i)).text(), a = /@font-face\s*{([^}]*)}/g, n = Array.from(o.matchAll(a));
|
|
6787
6846
|
if (n.length === 0)
|
|
6788
|
-
return
|
|
6847
|
+
return G.warn("No @font-face found in CSS"), null;
|
|
6789
6848
|
let h = null, l = -1;
|
|
6790
6849
|
for (let c = 0; c < n.length; c++) {
|
|
6791
6850
|
const g = n[c][1], d = g.match(/url\((https:\/\/fonts\.gstatic\.com\/[^)]+)\)/), f = g.includes("unicode-range"), u = g.match(/unicode-range:\s*([^;]+);/);
|
|
@@ -6794,9 +6853,9 @@ class Ve {
|
|
|
6794
6853
|
let p = 0;
|
|
6795
6854
|
f ? u && (p = (u[1].match(/U\+/g) || []).length) : p = 1e3, p > l && (l = p, h = m);
|
|
6796
6855
|
}
|
|
6797
|
-
return h || (
|
|
6798
|
-
} catch (
|
|
6799
|
-
return
|
|
6856
|
+
return h || (G.warn("No font URL found in CSS for", t), null);
|
|
6857
|
+
} catch (i) {
|
|
6858
|
+
return G.error("Error extracting font file URL:", i), null;
|
|
6800
6859
|
}
|
|
6801
6860
|
}
|
|
6802
6861
|
/**
|
|
@@ -6805,27 +6864,27 @@ class Ve {
|
|
|
6805
6864
|
async loadFont(t, e = 400) {
|
|
6806
6865
|
if (this.isSystemFont(t))
|
|
6807
6866
|
return null;
|
|
6808
|
-
const
|
|
6809
|
-
if (this.failedFonts.has(
|
|
6867
|
+
const i = `${t}-${e}`;
|
|
6868
|
+
if (this.failedFonts.has(i))
|
|
6810
6869
|
return null;
|
|
6811
|
-
const s = this.fontCache.get(
|
|
6870
|
+
const s = this.fontCache.get(i);
|
|
6812
6871
|
if (s && Date.now() - s.timestamp < this.CACHE_DURATION)
|
|
6813
6872
|
return s.timestamp = Date.now(), s.font;
|
|
6814
6873
|
try {
|
|
6815
|
-
const
|
|
6816
|
-
if (!
|
|
6817
|
-
return this.failedFonts.add(
|
|
6818
|
-
const a = await fetch(
|
|
6874
|
+
const o = await this.extractFontFileUrl(t, e);
|
|
6875
|
+
if (!o)
|
|
6876
|
+
return this.failedFonts.add(i), null;
|
|
6877
|
+
const a = await fetch(o);
|
|
6819
6878
|
if (!a.ok)
|
|
6820
|
-
return
|
|
6821
|
-
const n = await a.arrayBuffer(), h = new Uint8Array(n), c = (await
|
|
6822
|
-
return this.fontCache.set(
|
|
6879
|
+
return G.error(`Font fetch failed: ${a.status} ${a.statusText}`), this.failedFonts.add(i), null;
|
|
6880
|
+
const n = await a.arrayBuffer(), h = new Uint8Array(n), c = (await Ke()).create(h), g = "fonts" in c ? c.fonts[0] : c;
|
|
6881
|
+
return this.fontCache.set(i, {
|
|
6823
6882
|
font: g,
|
|
6824
|
-
url:
|
|
6883
|
+
url: o,
|
|
6825
6884
|
timestamp: Date.now()
|
|
6826
6885
|
}), this.evictOldestFont(), g;
|
|
6827
|
-
} catch (
|
|
6828
|
-
return
|
|
6886
|
+
} catch (o) {
|
|
6887
|
+
return G.error(`Error loading font ${t}:`, o), this.failedFonts.add(i), null;
|
|
6829
6888
|
}
|
|
6830
6889
|
}
|
|
6831
6890
|
/**
|
|
@@ -6833,7 +6892,7 @@ class Ve {
|
|
|
6833
6892
|
* Returns null if font is not cached - font should be pre-loaded before rendering
|
|
6834
6893
|
*/
|
|
6835
6894
|
getFontSync(t, e = 400) {
|
|
6836
|
-
const
|
|
6895
|
+
const i = `${t}-${e}`, s = this.fontCache.get(i);
|
|
6837
6896
|
return s && Date.now() - s.timestamp < this.CACHE_DURATION ? (s.timestamp = Date.now(), s.font) : null;
|
|
6838
6897
|
}
|
|
6839
6898
|
/**
|
|
@@ -6842,22 +6901,22 @@ class Ve {
|
|
|
6842
6901
|
*/
|
|
6843
6902
|
clearCache(t, e) {
|
|
6844
6903
|
if (t) {
|
|
6845
|
-
const
|
|
6846
|
-
this.fontCache.delete(
|
|
6904
|
+
const i = `${t}-${e || 400}`;
|
|
6905
|
+
this.fontCache.delete(i), this.failedFonts.delete(i);
|
|
6847
6906
|
} else
|
|
6848
6907
|
this.fontCache.clear(), this.failedFonts.clear();
|
|
6849
6908
|
}
|
|
6850
6909
|
/**
|
|
6851
6910
|
* Get all glyphs in a font (for browsing)
|
|
6852
6911
|
*/
|
|
6853
|
-
async getAllGlyphs(t, e = 400,
|
|
6912
|
+
async getAllGlyphs(t, e = 400, i = 1500) {
|
|
6854
6913
|
var n, h;
|
|
6855
6914
|
if (this.isSystemFont(t))
|
|
6856
6915
|
return [];
|
|
6857
6916
|
const s = await this.loadFont(t, e);
|
|
6858
6917
|
if (!s)
|
|
6859
6918
|
return [];
|
|
6860
|
-
const
|
|
6919
|
+
const o = [], a = Math.min(s.numGlyphs, i);
|
|
6861
6920
|
for (let l = 0; l < a; l++)
|
|
6862
6921
|
try {
|
|
6863
6922
|
const c = s.getGlyph(l);
|
|
@@ -6885,7 +6944,7 @@ class Ve {
|
|
|
6885
6944
|
const m = c.name.toLowerCase();
|
|
6886
6945
|
if (m.includes("swash") || m.includes("cswh") ? u = "swash" : c.name.match(/\.(alt|ss\d+|cv\d+|salt|ornament)/) || c.name.match(/_\d+$/) ? u = "stylistic" : m.match(/liga|dlig/) && (u = "ligature"), u === "default")
|
|
6887
6946
|
continue;
|
|
6888
|
-
d && d.length > 0 &&
|
|
6947
|
+
d && d.length > 0 && o.push({
|
|
6889
6948
|
glyphIndex: c.id,
|
|
6890
6949
|
unicode: d,
|
|
6891
6950
|
name: f,
|
|
@@ -6894,21 +6953,21 @@ class Ve {
|
|
|
6894
6953
|
});
|
|
6895
6954
|
} catch {
|
|
6896
6955
|
}
|
|
6897
|
-
return
|
|
6956
|
+
return o;
|
|
6898
6957
|
}
|
|
6899
6958
|
/**
|
|
6900
6959
|
* Get glyph alternates for a specific character
|
|
6901
6960
|
*/
|
|
6902
|
-
async getGlyphAlternates(t, e,
|
|
6961
|
+
async getGlyphAlternates(t, e, i = 400) {
|
|
6903
6962
|
var l, c, g, d;
|
|
6904
|
-
const s = await this.loadFont(t,
|
|
6963
|
+
const s = await this.loadFont(t, i);
|
|
6905
6964
|
if (!s)
|
|
6906
6965
|
return [];
|
|
6907
|
-
const
|
|
6966
|
+
const o = [], a = e.codePointAt(0);
|
|
6908
6967
|
if (a === void 0)
|
|
6909
6968
|
return [];
|
|
6910
6969
|
const n = s.glyphForCodePoint(a);
|
|
6911
|
-
n &&
|
|
6970
|
+
n && o.push({
|
|
6912
6971
|
glyphIndex: n.id,
|
|
6913
6972
|
unicode: e,
|
|
6914
6973
|
name: n.name || "Default",
|
|
@@ -6926,22 +6985,22 @@ class Ve {
|
|
|
6926
6985
|
new RegExp(`^${h}\\.(swash|alt|ss\\d+|salt|ornament)`, "i"),
|
|
6927
6986
|
new RegExp(`^${h}_\\d+$`, "i"),
|
|
6928
6987
|
new RegExp(`^${h}\\.\\d+$`, "i")
|
|
6929
|
-
].some((
|
|
6988
|
+
].some((w) => w.test(m.name)) && m.id !== n.id) {
|
|
6930
6989
|
f++;
|
|
6931
|
-
let
|
|
6990
|
+
let w = m.name;
|
|
6932
6991
|
if (m.name.includes(".swash"))
|
|
6933
|
-
|
|
6992
|
+
w = `${e} Swash`;
|
|
6934
6993
|
else if (m.name.match(/\.alt(\d+)?/)) {
|
|
6935
|
-
const
|
|
6936
|
-
|
|
6994
|
+
const S = ((l = m.name.match(/\.alt(\d+)/)) == null ? void 0 : l[1]) || "";
|
|
6995
|
+
w = `${e} Alternate${S ? " " + S : ""}`;
|
|
6937
6996
|
} else if (m.name.match(/\.ss(\d+)/)) {
|
|
6938
|
-
const
|
|
6939
|
-
|
|
6997
|
+
const S = (c = m.name.match(/\.ss(\d+)/)) == null ? void 0 : c[1];
|
|
6998
|
+
w = `${e} Stylistic Set ${S}`;
|
|
6940
6999
|
}
|
|
6941
|
-
|
|
7000
|
+
o.push({
|
|
6942
7001
|
glyphIndex: m.id,
|
|
6943
7002
|
unicode: e,
|
|
6944
|
-
name:
|
|
7003
|
+
name: w,
|
|
6945
7004
|
category: "stylistic",
|
|
6946
7005
|
previewDataUrl: this.generateGlyphPreview(s, m.id, 80)
|
|
6947
7006
|
});
|
|
@@ -6959,35 +7018,35 @@ class Ve {
|
|
|
6959
7018
|
const y = (d = (g = f.lookupList) == null ? void 0 : g.lookups) == null ? void 0 : d[p];
|
|
6960
7019
|
if (y) {
|
|
6961
7020
|
if (y.lookupType === 1)
|
|
6962
|
-
for (const
|
|
6963
|
-
const
|
|
6964
|
-
if (!
|
|
6965
|
-
if (this.getCoverageIndex(
|
|
6966
|
-
const
|
|
6967
|
-
|
|
6968
|
-
glyphIndex:
|
|
7021
|
+
for (const w of y.subtables || []) {
|
|
7022
|
+
const S = w.coverage;
|
|
7023
|
+
if (!S) continue;
|
|
7024
|
+
if (this.getCoverageIndex(S, n.id) !== -1) {
|
|
7025
|
+
const T = this.getSubstituteGlyph(w, n.id);
|
|
7026
|
+
T !== null && o.push({
|
|
7027
|
+
glyphIndex: T,
|
|
6969
7028
|
unicode: e,
|
|
6970
7029
|
name: `${e} (${m})`,
|
|
6971
7030
|
category: this.categorizeFeature(m),
|
|
6972
|
-
previewDataUrl: this.generateGlyphPreview(s,
|
|
7031
|
+
previewDataUrl: this.generateGlyphPreview(s, T, 80)
|
|
6973
7032
|
});
|
|
6974
7033
|
}
|
|
6975
7034
|
}
|
|
6976
7035
|
else if (y.lookupType === 3)
|
|
6977
|
-
for (const
|
|
6978
|
-
const
|
|
6979
|
-
if (!
|
|
6980
|
-
const
|
|
6981
|
-
if (
|
|
6982
|
-
const
|
|
6983
|
-
if (
|
|
6984
|
-
for (const
|
|
6985
|
-
|
|
6986
|
-
glyphIndex:
|
|
7036
|
+
for (const w of y.subtables || []) {
|
|
7037
|
+
const S = w.coverage;
|
|
7038
|
+
if (!S) continue;
|
|
7039
|
+
const b = this.getCoverageIndex(S, n.id), T = w;
|
|
7040
|
+
if (b !== -1 && T.alternateSets) {
|
|
7041
|
+
const C = T.alternateSets[b];
|
|
7042
|
+
if (C)
|
|
7043
|
+
for (const M of C)
|
|
7044
|
+
o.push({
|
|
7045
|
+
glyphIndex: M,
|
|
6987
7046
|
unicode: e,
|
|
6988
7047
|
name: `${e} (${m} alt)`,
|
|
6989
7048
|
category: this.categorizeFeature(m),
|
|
6990
|
-
previewDataUrl: this.generateGlyphPreview(s,
|
|
7049
|
+
previewDataUrl: this.generateGlyphPreview(s, M, 80)
|
|
6991
7050
|
});
|
|
6992
7051
|
}
|
|
6993
7052
|
}
|
|
@@ -6995,61 +7054,61 @@ class Ve {
|
|
|
6995
7054
|
}
|
|
6996
7055
|
}
|
|
6997
7056
|
}
|
|
6998
|
-
return
|
|
7057
|
+
return o;
|
|
6999
7058
|
}
|
|
7000
7059
|
/**
|
|
7001
7060
|
* Get available OpenType features for a font
|
|
7002
7061
|
*/
|
|
7003
7062
|
async getAvailableFeatures(t, e = 400) {
|
|
7004
|
-
const
|
|
7005
|
-
if (!
|
|
7006
|
-
return
|
|
7063
|
+
const i = await this.loadFont(t, e);
|
|
7064
|
+
if (!i)
|
|
7065
|
+
return G.warn(`Font ${t} failed to load`), [];
|
|
7007
7066
|
try {
|
|
7008
7067
|
const s = [];
|
|
7009
|
-
if (
|
|
7010
|
-
const
|
|
7011
|
-
for (const a of
|
|
7012
|
-
a.tag &&
|
|
7013
|
-
s.push(...Array.from(
|
|
7068
|
+
if (i.GSUB && i.GSUB.featureList) {
|
|
7069
|
+
const o = /* @__PURE__ */ new Set();
|
|
7070
|
+
for (const a of i.GSUB.featureList)
|
|
7071
|
+
a.tag && o.add(a.tag);
|
|
7072
|
+
s.push(...Array.from(o));
|
|
7014
7073
|
}
|
|
7015
|
-
if (
|
|
7016
|
-
const
|
|
7017
|
-
for (const a of
|
|
7018
|
-
a.tag &&
|
|
7019
|
-
s.push(...Array.from(
|
|
7074
|
+
if (i.GPOS && i.GPOS.featureList) {
|
|
7075
|
+
const o = /* @__PURE__ */ new Set();
|
|
7076
|
+
for (const a of i.GPOS.featureList)
|
|
7077
|
+
a.tag && o.add(a.tag);
|
|
7078
|
+
s.push(...Array.from(o));
|
|
7020
7079
|
}
|
|
7021
7080
|
return s;
|
|
7022
7081
|
} catch (s) {
|
|
7023
|
-
return
|
|
7082
|
+
return G.error(`Error getting features for ${t}:`, s), [];
|
|
7024
7083
|
}
|
|
7025
7084
|
}
|
|
7026
7085
|
/**
|
|
7027
7086
|
* Generate a preview image for a glyph
|
|
7028
7087
|
*/
|
|
7029
|
-
generateGlyphPreview(t, e,
|
|
7088
|
+
generateGlyphPreview(t, e, i = 80) {
|
|
7030
7089
|
const s = document.createElement("canvas");
|
|
7031
|
-
s.width =
|
|
7032
|
-
const
|
|
7033
|
-
if (!
|
|
7090
|
+
s.width = i, s.height = i;
|
|
7091
|
+
const o = s.getContext("2d");
|
|
7092
|
+
if (!o)
|
|
7034
7093
|
return "";
|
|
7035
7094
|
try {
|
|
7036
7095
|
const a = t.getGlyph(e);
|
|
7037
7096
|
if (!a)
|
|
7038
7097
|
return "";
|
|
7039
|
-
|
|
7098
|
+
o.clearRect(0, 0, i, i);
|
|
7040
7099
|
const n = a.bbox;
|
|
7041
7100
|
if (!n)
|
|
7042
7101
|
return "";
|
|
7043
7102
|
const h = n.maxX - n.minX, l = n.maxY - n.minY;
|
|
7044
7103
|
if (h === 0 || l === 0)
|
|
7045
7104
|
return "";
|
|
7046
|
-
const g = Math.min(
|
|
7105
|
+
const g = Math.min(i / h, i / l) * 0.6, d = (n.minX + n.maxX) / 2, f = (n.minY + n.maxY) / 2, u = i / 2, m = i / 2, p = a.path.toSVG();
|
|
7047
7106
|
if (!p)
|
|
7048
7107
|
return "";
|
|
7049
7108
|
const y = new Path2D(p);
|
|
7050
|
-
return
|
|
7109
|
+
return o.save(), o.translate(u, m), o.scale(g, -g), o.translate(-d, -f), o.fillStyle = "#000000", o.fill(y), o.restore(), s.toDataURL("image/png");
|
|
7051
7110
|
} catch (a) {
|
|
7052
|
-
return
|
|
7111
|
+
return G.error("Error generating glyph preview:", a), "";
|
|
7053
7112
|
}
|
|
7054
7113
|
}
|
|
7055
7114
|
/**
|
|
@@ -7109,11 +7168,11 @@ class Ve {
|
|
|
7109
7168
|
if (t.format === 1 && t.glyphs)
|
|
7110
7169
|
return t.glyphs.indexOf(e);
|
|
7111
7170
|
if (t.format === 2 && t.ranges) {
|
|
7112
|
-
const
|
|
7113
|
-
for (let s = 0; s <
|
|
7114
|
-
const
|
|
7115
|
-
if (e >=
|
|
7116
|
-
return
|
|
7171
|
+
const i = t.ranges;
|
|
7172
|
+
for (let s = 0; s < i.length; s++) {
|
|
7173
|
+
const o = i[s];
|
|
7174
|
+
if (e >= o.start && e <= o.end)
|
|
7175
|
+
return o.index + (e - o.start);
|
|
7117
7176
|
}
|
|
7118
7177
|
}
|
|
7119
7178
|
return -1;
|
|
@@ -7126,9 +7185,9 @@ class Ve {
|
|
|
7126
7185
|
if (t.substFormat === 1 && typeof t.deltaGlyphId == "number")
|
|
7127
7186
|
return e + t.deltaGlyphId;
|
|
7128
7187
|
if (t.substFormat === 2 && t.substitute) {
|
|
7129
|
-
const
|
|
7130
|
-
if (
|
|
7131
|
-
return s[
|
|
7188
|
+
const i = this.getCoverageIndex(t.coverage, e), s = t.substitute;
|
|
7189
|
+
if (i !== -1 && s[i] !== void 0)
|
|
7190
|
+
return s[i];
|
|
7132
7191
|
}
|
|
7133
7192
|
return null;
|
|
7134
7193
|
}
|
|
@@ -7136,14 +7195,14 @@ class Ve {
|
|
|
7136
7195
|
* Get the count of alternate glyphs in a font (fast - no preview generation)
|
|
7137
7196
|
*/
|
|
7138
7197
|
async getAlternateGlyphCount(t, e = 400) {
|
|
7139
|
-
const
|
|
7140
|
-
if (!
|
|
7198
|
+
const i = await this.loadFont(t, e);
|
|
7199
|
+
if (!i)
|
|
7141
7200
|
return 0;
|
|
7142
7201
|
let s = 0;
|
|
7143
|
-
const
|
|
7144
|
-
for (let a = 0; a <
|
|
7202
|
+
const o = Math.min(i.numGlyphs, 1500);
|
|
7203
|
+
for (let a = 0; a < o; a++)
|
|
7145
7204
|
try {
|
|
7146
|
-
const n =
|
|
7205
|
+
const n = i.getGlyph(a);
|
|
7147
7206
|
if (!n || !n.name || n.name === ".notdef" || n.name.startsWith(".null"))
|
|
7148
7207
|
continue;
|
|
7149
7208
|
const h = n.codePoints || [];
|
|
@@ -7169,123 +7228,126 @@ class Ve {
|
|
|
7169
7228
|
};
|
|
7170
7229
|
}
|
|
7171
7230
|
}
|
|
7172
|
-
const
|
|
7231
|
+
const us = new Qe();
|
|
7173
7232
|
export {
|
|
7174
|
-
|
|
7233
|
+
Te as $,
|
|
7175
7234
|
nt as A,
|
|
7176
7235
|
Q as B,
|
|
7177
|
-
|
|
7178
|
-
|
|
7179
|
-
|
|
7180
|
-
|
|
7236
|
+
he as C,
|
|
7237
|
+
Xe as D,
|
|
7238
|
+
ti as E,
|
|
7239
|
+
Ti as F,
|
|
7181
7240
|
ut as G,
|
|
7182
|
-
|
|
7241
|
+
Ve as H,
|
|
7183
7242
|
pt as I,
|
|
7184
|
-
|
|
7185
|
-
|
|
7243
|
+
ze as J,
|
|
7244
|
+
He as K,
|
|
7186
7245
|
Z as L,
|
|
7187
|
-
|
|
7188
|
-
|
|
7189
|
-
|
|
7246
|
+
Ge as M,
|
|
7247
|
+
fs as N,
|
|
7248
|
+
$e as O,
|
|
7190
7249
|
Mt as P,
|
|
7191
|
-
|
|
7192
|
-
|
|
7193
|
-
|
|
7250
|
+
xe as Q,
|
|
7251
|
+
L as R,
|
|
7252
|
+
At as S,
|
|
7194
7253
|
q as T,
|
|
7195
|
-
|
|
7196
|
-
|
|
7197
|
-
|
|
7198
|
-
|
|
7199
|
-
|
|
7200
|
-
|
|
7201
|
-
|
|
7202
|
-
|
|
7203
|
-
|
|
7204
|
-
|
|
7254
|
+
ns as U,
|
|
7255
|
+
Pe as V,
|
|
7256
|
+
Ue as W,
|
|
7257
|
+
ji as X,
|
|
7258
|
+
qi as Y,
|
|
7259
|
+
Zi as Z,
|
|
7260
|
+
Ki as _,
|
|
7261
|
+
Ui as a,
|
|
7262
|
+
_e as a$,
|
|
7263
|
+
Oe as a0,
|
|
7264
|
+
Ee as a1,
|
|
7205
7265
|
at as a2,
|
|
7206
|
-
|
|
7207
|
-
|
|
7208
|
-
|
|
7209
|
-
|
|
7210
|
-
|
|
7211
|
-
|
|
7212
|
-
|
|
7213
|
-
|
|
7214
|
-
|
|
7215
|
-
|
|
7216
|
-
|
|
7217
|
-
|
|
7218
|
-
|
|
7219
|
-
|
|
7220
|
-
|
|
7221
|
-
|
|
7222
|
-
|
|
7223
|
-
|
|
7224
|
-
|
|
7225
|
-
|
|
7226
|
-
|
|
7227
|
-
|
|
7228
|
-
|
|
7229
|
-
|
|
7230
|
-
|
|
7231
|
-
|
|
7232
|
-
|
|
7233
|
-
|
|
7234
|
-
|
|
7235
|
-
|
|
7236
|
-
|
|
7237
|
-
|
|
7238
|
-
|
|
7239
|
-
|
|
7240
|
-
|
|
7241
|
-
|
|
7242
|
-
|
|
7243
|
-
|
|
7244
|
-
|
|
7245
|
-
|
|
7246
|
-
|
|
7247
|
-
|
|
7248
|
-
|
|
7249
|
-
|
|
7250
|
-
|
|
7251
|
-
|
|
7252
|
-
|
|
7253
|
-
|
|
7254
|
-
|
|
7255
|
-
|
|
7256
|
-
|
|
7257
|
-
|
|
7258
|
-
|
|
7259
|
-
|
|
7260
|
-
|
|
7261
|
-
|
|
7262
|
-
|
|
7263
|
-
|
|
7264
|
-
|
|
7265
|
-
|
|
7266
|
+
Bt as a3,
|
|
7267
|
+
vt as a4,
|
|
7268
|
+
Rt as a5,
|
|
7269
|
+
Yt as a6,
|
|
7270
|
+
Ji as a7,
|
|
7271
|
+
j as a8,
|
|
7272
|
+
yt as a9,
|
|
7273
|
+
is as aA,
|
|
7274
|
+
ge as aB,
|
|
7275
|
+
si as aC,
|
|
7276
|
+
ci as aD,
|
|
7277
|
+
ts as aE,
|
|
7278
|
+
fe as aF,
|
|
7279
|
+
Qi as aG,
|
|
7280
|
+
Le as aH,
|
|
7281
|
+
es as aI,
|
|
7282
|
+
wi as aJ,
|
|
7283
|
+
hi as aK,
|
|
7284
|
+
li as aL,
|
|
7285
|
+
ai as aM,
|
|
7286
|
+
de as aN,
|
|
7287
|
+
ni as aO,
|
|
7288
|
+
ri as aP,
|
|
7289
|
+
ii as aQ,
|
|
7290
|
+
xi as aR,
|
|
7291
|
+
bi as aS,
|
|
7292
|
+
oi as aT,
|
|
7293
|
+
pi as aU,
|
|
7294
|
+
yi as aV,
|
|
7295
|
+
ui as aW,
|
|
7296
|
+
ei as aX,
|
|
7297
|
+
Jt as aY,
|
|
7298
|
+
rs as aZ,
|
|
7299
|
+
Ci as a_,
|
|
7300
|
+
Vi as aa,
|
|
7301
|
+
be as ab,
|
|
7302
|
+
Fi as ac,
|
|
7303
|
+
Ai as ad,
|
|
7304
|
+
J as ae,
|
|
7305
|
+
as as af,
|
|
7306
|
+
hs as ag,
|
|
7307
|
+
ls as ah,
|
|
7308
|
+
cs as ai,
|
|
7309
|
+
ds as aj,
|
|
7310
|
+
gs as ak,
|
|
7311
|
+
pe as al,
|
|
7312
|
+
ye as am,
|
|
7313
|
+
mi as an,
|
|
7314
|
+
Ye as ao,
|
|
7315
|
+
ot as ap,
|
|
7316
|
+
vi as aq,
|
|
7317
|
+
Ft as ar,
|
|
7318
|
+
Xt as as,
|
|
7319
|
+
di as at,
|
|
7320
|
+
zt as au,
|
|
7321
|
+
gi as av,
|
|
7322
|
+
fi as aw,
|
|
7323
|
+
I as ax,
|
|
7324
|
+
P as ay,
|
|
7325
|
+
Si as az,
|
|
7326
|
+
Ni as b,
|
|
7327
|
+
rt as b0,
|
|
7266
7328
|
mt as c,
|
|
7267
|
-
|
|
7268
|
-
|
|
7269
|
-
|
|
7270
|
-
|
|
7271
|
-
|
|
7272
|
-
|
|
7273
|
-
|
|
7274
|
-
|
|
7275
|
-
|
|
7276
|
-
|
|
7277
|
-
|
|
7278
|
-
|
|
7279
|
-
|
|
7280
|
-
|
|
7281
|
-
|
|
7282
|
-
|
|
7283
|
-
|
|
7284
|
-
|
|
7285
|
-
|
|
7286
|
-
|
|
7287
|
-
|
|
7288
|
-
|
|
7289
|
-
|
|
7329
|
+
Li as d,
|
|
7330
|
+
Di as e,
|
|
7331
|
+
Pi as f,
|
|
7332
|
+
qe as g,
|
|
7333
|
+
$i as h,
|
|
7334
|
+
Ii as i,
|
|
7335
|
+
Mi as j,
|
|
7336
|
+
Ei as k,
|
|
7337
|
+
Wi as l,
|
|
7338
|
+
Bi as m,
|
|
7339
|
+
Hi as n,
|
|
7340
|
+
Oi as o,
|
|
7341
|
+
Gi as p,
|
|
7342
|
+
Xi as q,
|
|
7343
|
+
ss as r,
|
|
7344
|
+
_i as s,
|
|
7345
|
+
zi as t,
|
|
7346
|
+
os as u,
|
|
7347
|
+
Yi as v,
|
|
7348
|
+
Ri as w,
|
|
7349
|
+
ki as x,
|
|
7350
|
+
It as y,
|
|
7351
|
+
us as z
|
|
7290
7352
|
};
|
|
7291
|
-
//# sourceMappingURL=FontAnalyzer-
|
|
7353
|
+
//# sourceMappingURL=FontAnalyzer-D4Sg-P6_.js.map
|