@snowcone-app/canvas 0.44.1 → 0.45.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/{ContextualToolbars-rCZo-KCm.js → ContextualToolbars-5tHC6s0Y.js} +4 -4
- package/dist/{ContextualToolbars-rCZo-KCm.js.map → ContextualToolbars-5tHC6s0Y.js.map} +1 -1
- package/dist/{EditorCanvasImpl-VkjeyOGd.js → EditorCanvasImpl-B4VBKRBA.js} +6 -6
- package/dist/{EditorCanvasImpl-VkjeyOGd.js.map → EditorCanvasImpl-B4VBKRBA.js.map} +1 -1
- package/dist/{ImagePanel-DhOWKvIN.js → ImagePanel-bW3yr6Ac.js} +264 -259
- package/dist/{ImagePanel-DhOWKvIN.js.map → ImagePanel-bW3yr6Ac.js.map} +1 -1
- package/dist/{SnowconeCanvas-COXpmwkS.js → SnowconeCanvas-crxPwbib.js} +441 -439
- package/dist/SnowconeCanvas-crxPwbib.js.map +1 -0
- package/dist/advanced.mjs +9 -9
- package/dist/components/embed/SnowconeCanvas.d.ts +6 -0
- package/dist/components/embed/kernel.d.ts +2 -0
- package/dist/{custom-icons-C4bzABm2.js → custom-icons-DQRp8GhF.js} +2 -2
- package/dist/{custom-icons-C4bzABm2.js.map → custom-icons-DQRp8GhF.js.map} +1 -1
- package/dist/{design-builder-DCHVrEFV.js → design-builder-sH53Og6j.js} +598 -589
- package/dist/design-builder-sH53Og6j.js.map +1 -0
- package/dist/{embed-CamnTsuT.js → embed-CYWbpvu_.js} +6 -6
- package/dist/{embed-CamnTsuT.js.map → embed-CYWbpvu_.js.map} +1 -1
- package/dist/embed.mjs +4 -4
- package/dist/index.mjs +7 -7
- package/dist/{template-fields-CK7Uvvc8.js → template-fields-BaQG0CJY.js} +3 -3
- package/dist/{template-fields-CK7Uvvc8.js.map → template-fields-BaQG0CJY.js.map} +1 -1
- package/dist/testing.mjs +2 -2
- package/dist/{useCommands-BrkGKdXr.js → useCommands-F-b_SwW-.js} +3 -3
- package/dist/{useCommands-BrkGKdXr.js.map → useCommands-F-b_SwW-.js.map} +1 -1
- package/dist/{validation-jgr2OtXC.js → validation-hn5ZX8Po.js} +9 -8
- package/dist/{validation-jgr2OtXC.js.map → validation-hn5ZX8Po.js.map} +1 -1
- package/example/package.json +1 -1
- package/package.json +3 -3
- package/dist/SnowconeCanvas-COXpmwkS.js.map +0 -1
- package/dist/design-builder-DCHVrEFV.js.map +0 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { jsx as V } from "react/jsx-runtime";
|
|
2
|
-
import { useContext as G, useSyncExternalStore as
|
|
3
|
-
import { H as
|
|
4
|
-
import { g as
|
|
5
|
-
const
|
|
6
|
-
},
|
|
7
|
-
function
|
|
8
|
-
const e = G(
|
|
9
|
-
e ? e.subscribe :
|
|
10
|
-
e ? e.getVersion :
|
|
11
|
-
e ? e.getVersion :
|
|
2
|
+
import { useContext as G, useSyncExternalStore as Re, useCallback as h, createContext as q, useRef as At, useState as S, useEffect as Bt, useMemo as J } from "react";
|
|
3
|
+
import { H as Ie, t as et, U as Te, B as Ce, G as Qt, R as Fe, D as ve, J as Pe, K as Ne, M as Oe, c as te, z as ze, N as Ue, O as He, I as _t, Q as ke, e as De, E as Xt, q as Le, S as Ve, V as Gt, X as _e, Y as Kt, Z as $e, _ as Be, $ as Me, a0 as We, a1 as Ye, i as Xe } from "./FontAnalyzer-Ds3Wdba7.js";
|
|
4
|
+
import { g as ee, a as oe } from "./placement-tSiIVhrL.js";
|
|
5
|
+
const ne = q(null), Ge = () => () => {
|
|
6
|
+
}, Zt = () => 0;
|
|
7
|
+
function Ho() {
|
|
8
|
+
const e = G(ne), t = Re(
|
|
9
|
+
e ? e.subscribe : Ge,
|
|
10
|
+
e ? e.getVersion : Zt,
|
|
11
|
+
e ? e.getVersion : Zt
|
|
12
12
|
);
|
|
13
13
|
return h(
|
|
14
14
|
(o) => !!(e && o && e.getBoundLayer(o)),
|
|
@@ -17,152 +17,152 @@ function Uo() {
|
|
|
17
17
|
[e, t]
|
|
18
18
|
);
|
|
19
19
|
}
|
|
20
|
-
const
|
|
21
|
-
function
|
|
22
|
-
const i =
|
|
23
|
-
(
|
|
24
|
-
const
|
|
25
|
-
if (!r || !
|
|
26
|
-
const A = r.getBoundLayer(
|
|
20
|
+
const bt = te("useCommandHistory");
|
|
21
|
+
function Ke(e, t, o, n) {
|
|
22
|
+
const i = At(new Ie(o)), r = G(ne), a = h(
|
|
23
|
+
(u, g) => {
|
|
24
|
+
const b = u == null ? void 0 : u.name;
|
|
25
|
+
if (!r || !b) return;
|
|
26
|
+
const A = r.getBoundLayer(b);
|
|
27
27
|
if (A)
|
|
28
|
-
throw new
|
|
28
|
+
throw new et(
|
|
29
29
|
"E_BOUND_LAYER_MUTATION",
|
|
30
|
-
`cannot ${
|
|
31
|
-
{ layer:
|
|
30
|
+
`cannot ${g} layer "${b}" — a mounted <${A.part} layer={design.layer("${b}")}> is bound to it. Unmount that field first, or keep the layer and set its text through the field / its binding instead.`,
|
|
31
|
+
{ layer: b, part: A.part, operation: g, docSlug: "embed-mode" }
|
|
32
32
|
);
|
|
33
33
|
},
|
|
34
34
|
[r]
|
|
35
|
-
), [s, c] =
|
|
35
|
+
), [s, c] = S({
|
|
36
36
|
canUndo: !1,
|
|
37
37
|
canRedo: !1,
|
|
38
38
|
// Per-artboard state for the active artboard
|
|
39
39
|
canUndoActiveArtboard: !1,
|
|
40
40
|
canRedoActiveArtboard: !1
|
|
41
41
|
}), d = h(() => {
|
|
42
|
-
const
|
|
42
|
+
const u = i.current, g = o.getActiveArtboardId();
|
|
43
43
|
c({
|
|
44
|
-
canUndo:
|
|
45
|
-
canRedo:
|
|
44
|
+
canUndo: u.canUndo(),
|
|
45
|
+
canRedo: u.canRedo(),
|
|
46
46
|
// Per-artboard state - only check active artboard's history
|
|
47
|
-
canUndoActiveArtboard:
|
|
48
|
-
canRedoActiveArtboard:
|
|
47
|
+
canUndoActiveArtboard: g ? u.canUndoArtboard(g) : !1,
|
|
48
|
+
canRedoActiveArtboard: g ? u.canRedoArtboard(g) : !1
|
|
49
49
|
});
|
|
50
|
-
}, [o]),
|
|
51
|
-
(
|
|
52
|
-
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
(
|
|
58
|
-
t((Y) => Y.map((z) => z.id ===
|
|
50
|
+
}, [o]), R = h(
|
|
51
|
+
(u, g) => {
|
|
52
|
+
u && u.name !== g.name && a(u, "rename");
|
|
53
|
+
const b = new Te(
|
|
54
|
+
g.id,
|
|
55
|
+
u || null,
|
|
56
|
+
g,
|
|
57
|
+
(F) => {
|
|
58
|
+
t((Y) => Y.map((z) => z.id === F.id ? F : z));
|
|
59
59
|
}
|
|
60
|
-
), A = o.getArtboardIdForElement(
|
|
60
|
+
), A = o.getArtboardIdForElement(g.id);
|
|
61
61
|
if (A)
|
|
62
|
-
i.current.executeOnArtboard(A,
|
|
62
|
+
i.current.executeOnArtboard(A, b);
|
|
63
63
|
else {
|
|
64
|
-
const
|
|
65
|
-
|
|
64
|
+
const F = o.getActiveArtboardId();
|
|
65
|
+
F && i.current.executeOnArtboard(F, b);
|
|
66
66
|
}
|
|
67
67
|
d();
|
|
68
68
|
},
|
|
69
69
|
[t, o, d, a]
|
|
70
70
|
), N = h(
|
|
71
|
-
(
|
|
72
|
-
const
|
|
73
|
-
if (!
|
|
74
|
-
|
|
71
|
+
(u, g, b, A) => {
|
|
72
|
+
const F = g || o.getActiveArtboardId();
|
|
73
|
+
if (!F) {
|
|
74
|
+
bt.warn("No active artboard to add element to");
|
|
75
75
|
return;
|
|
76
76
|
}
|
|
77
|
-
const Y = new
|
|
78
|
-
|
|
77
|
+
const Y = new Ce(
|
|
78
|
+
u,
|
|
79
79
|
(z) => {
|
|
80
|
-
const
|
|
80
|
+
const _ = z;
|
|
81
81
|
t((U) => {
|
|
82
82
|
if (A) {
|
|
83
83
|
const L = U.findIndex((P) => P.id === A);
|
|
84
84
|
if (L !== -1) {
|
|
85
85
|
const P = [...U];
|
|
86
|
-
return P.splice(L, 0,
|
|
86
|
+
return P.splice(L, 0, _), P;
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
|
-
if (
|
|
90
|
-
const L = U.findIndex((P) => P.id ===
|
|
89
|
+
if (b) {
|
|
90
|
+
const L = U.findIndex((P) => P.id === b);
|
|
91
91
|
if (L !== -1) {
|
|
92
92
|
const P = [...U];
|
|
93
|
-
return P.splice(L + 1, 0,
|
|
93
|
+
return P.splice(L + 1, 0, _), P;
|
|
94
94
|
}
|
|
95
95
|
for (let P = 0; P < U.length; P++) {
|
|
96
96
|
const K = U[P];
|
|
97
|
-
if (K instanceof
|
|
98
|
-
const
|
|
99
|
-
if (
|
|
97
|
+
if (K instanceof Qt && K.children) {
|
|
98
|
+
const nt = K.children.findIndex((Z) => Z.id === b);
|
|
99
|
+
if (nt !== -1) {
|
|
100
100
|
const Z = K.clone();
|
|
101
|
-
Z.children.splice(
|
|
102
|
-
const
|
|
103
|
-
return
|
|
101
|
+
Z.children.splice(nt + 1, 0, _);
|
|
102
|
+
const $ = [...U];
|
|
103
|
+
return $[P] = Z, $;
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
|
-
return [...U,
|
|
109
|
-
}), o.addElementToArtboard(z.id,
|
|
108
|
+
return [...U, _];
|
|
109
|
+
}), o.addElementToArtboard(z.id, F);
|
|
110
110
|
},
|
|
111
111
|
(z) => {
|
|
112
|
-
t((
|
|
112
|
+
t((_) => _.filter((U) => U.id !== z)), o.removeElementFromArtboard(z);
|
|
113
113
|
}
|
|
114
114
|
);
|
|
115
|
-
i.current.executeOnArtboard(
|
|
115
|
+
i.current.executeOnArtboard(F, Y), d();
|
|
116
116
|
},
|
|
117
117
|
[t, o, d]
|
|
118
118
|
), k = h(
|
|
119
|
-
(
|
|
120
|
-
a(
|
|
121
|
-
const
|
|
122
|
-
if (!
|
|
123
|
-
|
|
119
|
+
(u) => {
|
|
120
|
+
a(u, "delete");
|
|
121
|
+
const g = o.getArtboardIdForElement(u.id);
|
|
122
|
+
if (!g) {
|
|
123
|
+
bt.warn("Element not found in any artboard");
|
|
124
124
|
return;
|
|
125
125
|
}
|
|
126
|
-
const
|
|
127
|
-
|
|
126
|
+
const b = new Fe(
|
|
127
|
+
u,
|
|
128
128
|
(A) => {
|
|
129
|
-
t((
|
|
129
|
+
t((F) => [...F, A]), o.addElementToArtboard(A.id, g);
|
|
130
130
|
},
|
|
131
131
|
(A) => {
|
|
132
|
-
t((
|
|
132
|
+
t((F) => F.filter((Y) => Y.id !== A)), o.removeElementFromArtboard(A);
|
|
133
133
|
}
|
|
134
134
|
);
|
|
135
|
-
i.current.executeOnArtboard(
|
|
135
|
+
i.current.executeOnArtboard(g, b), d();
|
|
136
136
|
},
|
|
137
137
|
[t, o, d, a]
|
|
138
|
-
),
|
|
139
|
-
(
|
|
140
|
-
const
|
|
141
|
-
i.current.executeGlobal(
|
|
138
|
+
), x = h(
|
|
139
|
+
(u) => {
|
|
140
|
+
const g = new ve(u, o);
|
|
141
|
+
i.current.executeGlobal(g), d(), n == null || n();
|
|
142
142
|
},
|
|
143
143
|
[o, d, n]
|
|
144
144
|
), D = h(
|
|
145
|
-
(
|
|
146
|
-
const
|
|
147
|
-
i.current.executeGlobal(
|
|
145
|
+
(u) => {
|
|
146
|
+
const g = new Pe(u, o);
|
|
147
|
+
i.current.executeGlobal(g), d(), n == null || n();
|
|
148
148
|
},
|
|
149
149
|
[o, d, n]
|
|
150
|
-
),
|
|
151
|
-
(
|
|
152
|
-
const A = new
|
|
150
|
+
), p = h(
|
|
151
|
+
(u, g, b) => {
|
|
152
|
+
const A = new Ne(u, g, b, o);
|
|
153
153
|
i.current.executeGlobal(A), d(), n == null || n();
|
|
154
154
|
},
|
|
155
155
|
[o, d, n]
|
|
156
156
|
), m = h(
|
|
157
|
-
(
|
|
158
|
-
if (
|
|
157
|
+
(u) => {
|
|
158
|
+
if (u.length === 0)
|
|
159
159
|
return;
|
|
160
|
-
const
|
|
161
|
-
if (!
|
|
162
|
-
|
|
160
|
+
const g = o.getActiveArtboardId();
|
|
161
|
+
if (!g) {
|
|
162
|
+
bt.warn("No active artboard for batch execution");
|
|
163
163
|
return;
|
|
164
164
|
}
|
|
165
|
-
const
|
|
165
|
+
const b = u.map((A) => new class extends Object {
|
|
166
166
|
execute() {
|
|
167
167
|
A.execute();
|
|
168
168
|
}
|
|
@@ -170,68 +170,68 @@ function Ge(e, t, o, n) {
|
|
|
170
170
|
A.undo();
|
|
171
171
|
}
|
|
172
172
|
}());
|
|
173
|
-
i.current.executeBatchOnArtboard(
|
|
173
|
+
i.current.executeBatchOnArtboard(g, b), d();
|
|
174
174
|
},
|
|
175
175
|
[o, d]
|
|
176
|
-
),
|
|
176
|
+
), w = h(() => {
|
|
177
177
|
i.current.undo() && (d(), n == null || n());
|
|
178
|
-
}, [d, n]), I = h(() => {
|
|
179
|
-
i.current.redo() && (d(), n == null || n());
|
|
180
178
|
}, [d, n]), T = h(() => {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
179
|
+
i.current.redo() && (d(), n == null || n());
|
|
180
|
+
}, [d, n]), C = h(() => {
|
|
181
|
+
const u = o.getActiveArtboardId();
|
|
182
|
+
u && i.current.undoArtboard(u) && (d(), n == null || n());
|
|
183
|
+
}, [o, d, n]), I = h(() => {
|
|
184
|
+
const u = o.getActiveArtboardId();
|
|
185
|
+
u && i.current.redoArtboard(u) && (d(), n == null || n());
|
|
186
186
|
}, [o, d, n]), M = h(() => {
|
|
187
187
|
i.current.clear(), d();
|
|
188
|
-
}, [d]),
|
|
189
|
-
(
|
|
190
|
-
i.current.clearArtboardHistory(
|
|
188
|
+
}, [d]), ot = h(
|
|
189
|
+
(u) => {
|
|
190
|
+
i.current.clearArtboardHistory(u), d();
|
|
191
191
|
},
|
|
192
192
|
[d]
|
|
193
|
-
),
|
|
194
|
-
|
|
195
|
-
const
|
|
196
|
-
|
|
193
|
+
), ht = At(null);
|
|
194
|
+
Bt(() => {
|
|
195
|
+
const u = o.getActiveArtboardId();
|
|
196
|
+
u !== ht.current && (ht.current = u, d());
|
|
197
197
|
});
|
|
198
198
|
const W = h(
|
|
199
|
-
(
|
|
200
|
-
const A = e.map((z) => z.id),
|
|
201
|
-
if (!
|
|
202
|
-
|
|
199
|
+
(u, g, b) => {
|
|
200
|
+
const A = e.map((z) => z.id), F = o.getArtboardIdForElement(u);
|
|
201
|
+
if (!F) {
|
|
202
|
+
bt.warn("Element not found in any artboard");
|
|
203
203
|
return;
|
|
204
204
|
}
|
|
205
|
-
const Y = new
|
|
206
|
-
t((
|
|
207
|
-
const U = new Map(
|
|
205
|
+
const Y = new Oe(u, g, b, A, (z) => {
|
|
206
|
+
t((_) => {
|
|
207
|
+
const U = new Map(_.map((L) => [L.id, L]));
|
|
208
208
|
return z.map((L) => U.get(L)).filter(Boolean);
|
|
209
209
|
});
|
|
210
210
|
});
|
|
211
|
-
i.current.executeOnArtboard(
|
|
211
|
+
i.current.executeOnArtboard(F, Y), d();
|
|
212
212
|
},
|
|
213
213
|
[e, t, o, d]
|
|
214
214
|
);
|
|
215
215
|
return {
|
|
216
216
|
// Element operations
|
|
217
|
-
executeElementUpdate:
|
|
217
|
+
executeElementUpdate: R,
|
|
218
218
|
executeAddElement: N,
|
|
219
219
|
executeRemoveElement: k,
|
|
220
220
|
executeReorderElement: W,
|
|
221
221
|
// Batch operations
|
|
222
222
|
executeCommandBatch: m,
|
|
223
223
|
// Artboard operations
|
|
224
|
-
executeCreateArtboard:
|
|
224
|
+
executeCreateArtboard: x,
|
|
225
225
|
executeDeleteArtboard: D,
|
|
226
|
-
executeUpdateArtboard:
|
|
226
|
+
executeUpdateArtboard: p,
|
|
227
227
|
// Undo/redo (smart - considers last operation and active artboard)
|
|
228
|
-
undo:
|
|
229
|
-
redo:
|
|
228
|
+
undo: w,
|
|
229
|
+
redo: T,
|
|
230
230
|
// Undo/redo for active artboard only (element operations)
|
|
231
|
-
undoActiveArtboard:
|
|
232
|
-
redoActiveArtboard:
|
|
231
|
+
undoActiveArtboard: C,
|
|
232
|
+
redoActiveArtboard: I,
|
|
233
233
|
clearHistory: M,
|
|
234
|
-
clearArtboardHistory:
|
|
234
|
+
clearArtboardHistory: ot,
|
|
235
235
|
// State (smart - considers last operation)
|
|
236
236
|
canUndo: s.canUndo,
|
|
237
237
|
canRedo: s.canRedo,
|
|
@@ -244,57 +244,57 @@ function Ge(e, t, o, n) {
|
|
|
244
244
|
function dt(e) {
|
|
245
245
|
return e && "fontSize" in e && "color" in e && "fontFamily" in e;
|
|
246
246
|
}
|
|
247
|
-
function
|
|
248
|
-
const [o, n] =
|
|
249
|
-
|
|
247
|
+
function Ze(e, t) {
|
|
248
|
+
const [o, n] = S(32), [i, r] = S("#333333"), [a, s] = S("Arial"), [c, d] = S("center");
|
|
249
|
+
Bt(() => {
|
|
250
250
|
if (e && dt(e)) {
|
|
251
|
-
const
|
|
252
|
-
n((
|
|
251
|
+
const p = e.transformType === "circle" && "getEffectiveFontSize" in e ? Math.round(e.getEffectiveFontSize()) : Math.round(e.fontSize), m = e.color, w = e.fontFamily, T = e.textAlign;
|
|
252
|
+
n((C) => C !== p ? p : C), r((C) => C !== m ? m : C), s((C) => C !== w ? w : C), d((C) => C !== T ? T : C);
|
|
253
253
|
}
|
|
254
254
|
}, [e]);
|
|
255
|
-
const
|
|
256
|
-
(
|
|
255
|
+
const R = h(
|
|
256
|
+
(p) => {
|
|
257
257
|
if (!e || !dt(e)) return;
|
|
258
|
-
const m = Math.max(
|
|
258
|
+
const m = Math.max(Ue, Math.min(He, o + p));
|
|
259
259
|
n(m);
|
|
260
|
-
const
|
|
261
|
-
|
|
260
|
+
const w = e.clone();
|
|
261
|
+
w.transformType === "circle" && "setEffectiveFontSize" in w ? w.setEffectiveFontSize(m) : w.setFontSize(m), t(w);
|
|
262
262
|
},
|
|
263
263
|
[e, o, t]
|
|
264
264
|
), N = h(
|
|
265
|
-
(
|
|
265
|
+
(p) => {
|
|
266
266
|
if (!e || !dt(e)) return;
|
|
267
|
-
n(
|
|
267
|
+
n(p);
|
|
268
268
|
const m = e.clone();
|
|
269
|
-
m.transformType === "circle" && "setEffectiveFontSize" in m ? m.setEffectiveFontSize(
|
|
269
|
+
m.transformType === "circle" && "setEffectiveFontSize" in m ? m.setEffectiveFontSize(p) : m.setFontSize(p), t(m);
|
|
270
270
|
},
|
|
271
271
|
[e, t]
|
|
272
272
|
), k = h(
|
|
273
|
-
(
|
|
273
|
+
(p) => {
|
|
274
274
|
if (!e || !dt(e)) return;
|
|
275
|
-
r(
|
|
275
|
+
r(p);
|
|
276
276
|
const m = e.clone();
|
|
277
|
-
if (m.color =
|
|
278
|
-
for (const
|
|
279
|
-
|
|
277
|
+
if (m.color = p, m.richText)
|
|
278
|
+
for (const w of m.richText.spans)
|
|
279
|
+
w.style.color = void 0;
|
|
280
280
|
t(m);
|
|
281
281
|
},
|
|
282
282
|
[e, t]
|
|
283
|
-
),
|
|
284
|
-
(
|
|
283
|
+
), x = h(
|
|
284
|
+
(p) => {
|
|
285
285
|
if (!e || !dt(e)) return;
|
|
286
286
|
const m = e.fontFamily;
|
|
287
|
-
m !==
|
|
288
|
-
const
|
|
289
|
-
|
|
287
|
+
m !== p && ze.clearCache(m), s(p);
|
|
288
|
+
const w = e.clone();
|
|
289
|
+
w.fontFamily = p, t(w);
|
|
290
290
|
},
|
|
291
291
|
[e, t]
|
|
292
292
|
), D = h(
|
|
293
|
-
(
|
|
293
|
+
(p) => {
|
|
294
294
|
if (!e || !dt(e)) return;
|
|
295
|
-
d(
|
|
295
|
+
d(p);
|
|
296
296
|
const m = e.clone();
|
|
297
|
-
m.textAlign =
|
|
297
|
+
m.textAlign = p, t(m);
|
|
298
298
|
},
|
|
299
299
|
[e, t]
|
|
300
300
|
);
|
|
@@ -310,22 +310,22 @@ function Ke(e, t) {
|
|
|
310
310
|
setFontFamily: s,
|
|
311
311
|
setTextAlign: d,
|
|
312
312
|
// Update functions (update element + UI)
|
|
313
|
-
updateFontSize:
|
|
313
|
+
updateFontSize: R,
|
|
314
314
|
setFontSizeValue: N,
|
|
315
315
|
updateFontColor: k,
|
|
316
|
-
updateFontFamily:
|
|
316
|
+
updateFontFamily: x,
|
|
317
317
|
updateTextAlign: D
|
|
318
318
|
};
|
|
319
319
|
}
|
|
320
|
-
const
|
|
321
|
-
function
|
|
320
|
+
const re = "data-preserve-selection";
|
|
321
|
+
function je(e) {
|
|
322
322
|
if (!(e instanceof Element))
|
|
323
323
|
return !1;
|
|
324
324
|
let t = e;
|
|
325
325
|
const o = [];
|
|
326
326
|
for (; t; ) {
|
|
327
327
|
const n = t.id ? `#${t.id}` : "", i = t.className ? `.${String(t.className).split(" ").slice(0, 2).join(".")}` : "";
|
|
328
|
-
if (o.push(`${t.tagName.toLowerCase()}${n}${i}`), t.hasAttribute(
|
|
328
|
+
if (o.push(`${t.tagName.toLowerCase()}${n}${i}`), t.hasAttribute(re))
|
|
329
329
|
return !0;
|
|
330
330
|
const r = t.getAttribute("role");
|
|
331
331
|
if (r === "dialog" || r === "alertdialog" || r === "menu" || r === "listbox")
|
|
@@ -337,18 +337,18 @@ function Ze(e) {
|
|
|
337
337
|
}
|
|
338
338
|
return !1;
|
|
339
339
|
}
|
|
340
|
-
const
|
|
341
|
-
[
|
|
340
|
+
const ko = {
|
|
341
|
+
[re]: ""
|
|
342
342
|
};
|
|
343
|
-
function
|
|
344
|
-
const t =
|
|
343
|
+
function Je(e) {
|
|
344
|
+
const t = ie(e);
|
|
345
345
|
return t !== null && t < 0.5;
|
|
346
346
|
}
|
|
347
|
-
function
|
|
348
|
-
const t =
|
|
347
|
+
function Do(e) {
|
|
348
|
+
const t = ie(e);
|
|
349
349
|
return t !== null && t >= 0.5;
|
|
350
350
|
}
|
|
351
|
-
function
|
|
351
|
+
function ie(e) {
|
|
352
352
|
const t = e.trim();
|
|
353
353
|
if (t.startsWith("#")) {
|
|
354
354
|
const n = t.slice(1);
|
|
@@ -358,29 +358,29 @@ function re(e) {
|
|
|
358
358
|
else if (n.length === 6)
|
|
359
359
|
i = parseInt(n.slice(0, 2), 16), r = parseInt(n.slice(2, 4), 16), a = parseInt(n.slice(4, 6), 16);
|
|
360
360
|
else return null;
|
|
361
|
-
return Number.isNaN(i) || Number.isNaN(r) || Number.isNaN(a) ? null :
|
|
361
|
+
return Number.isNaN(i) || Number.isNaN(r) || Number.isNaN(a) ? null : jt(i, r, a);
|
|
362
362
|
}
|
|
363
363
|
const o = t.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);
|
|
364
|
-
return o ?
|
|
364
|
+
return o ? jt(Number(o[1]), Number(o[2]), Number(o[3])) : null;
|
|
365
365
|
}
|
|
366
|
-
function
|
|
366
|
+
function jt(e, t, o) {
|
|
367
367
|
const n = (i) => {
|
|
368
368
|
const r = i / 255;
|
|
369
369
|
return r <= 0.03928 ? r / 12.92 : Math.pow((r + 0.055) / 1.055, 2.4);
|
|
370
370
|
};
|
|
371
371
|
return 0.2126 * n(e) + 0.7152 * n(t) + 0.0722 * n(o);
|
|
372
372
|
}
|
|
373
|
-
const
|
|
374
|
-
function
|
|
375
|
-
return e &&
|
|
373
|
+
const qe = "#333333", Qe = "#f4f4f5";
|
|
374
|
+
function to(e) {
|
|
375
|
+
return e && Je(e) ? Qe : qe;
|
|
376
376
|
}
|
|
377
|
-
const
|
|
377
|
+
const eo = {
|
|
378
378
|
timeout: 3e4,
|
|
379
379
|
retries: 1,
|
|
380
380
|
retryDelay: 1e3,
|
|
381
381
|
validateUrl: !0
|
|
382
382
|
};
|
|
383
|
-
function
|
|
383
|
+
function oo(e) {
|
|
384
384
|
try {
|
|
385
385
|
const t = new URL(e);
|
|
386
386
|
return ["http:", "https:", "data:", "blob:"].includes(t.protocol);
|
|
@@ -388,9 +388,9 @@ function eo(e) {
|
|
|
388
388
|
return !1;
|
|
389
389
|
}
|
|
390
390
|
}
|
|
391
|
-
async function
|
|
392
|
-
const o = { ...
|
|
393
|
-
if (o.validateUrl && !
|
|
391
|
+
async function se(e, t = {}) {
|
|
392
|
+
const o = { ...eo, ...t };
|
|
393
|
+
if (o.validateUrl && !oo(e))
|
|
394
394
|
return {
|
|
395
395
|
success: !1,
|
|
396
396
|
error: new Error(`Invalid image URL: ${e}`)
|
|
@@ -398,16 +398,16 @@ async function ie(e, t = {}) {
|
|
|
398
398
|
let n;
|
|
399
399
|
for (let i = 0; i <= o.retries; i++)
|
|
400
400
|
try {
|
|
401
|
-
return await
|
|
401
|
+
return await no(e, o.timeout);
|
|
402
402
|
} catch (r) {
|
|
403
|
-
n = r instanceof Error ? r : new Error(String(r)), i < o.retries && await
|
|
403
|
+
n = r instanceof Error ? r : new Error(String(r)), i < o.retries && await ro(o.retryDelay);
|
|
404
404
|
}
|
|
405
405
|
return {
|
|
406
406
|
success: !1,
|
|
407
407
|
error: n || new Error("Failed to load image after retries")
|
|
408
408
|
};
|
|
409
409
|
}
|
|
410
|
-
function
|
|
410
|
+
function no(e, t) {
|
|
411
411
|
return new Promise((o) => {
|
|
412
412
|
const n = new Image();
|
|
413
413
|
n.crossOrigin = "anonymous";
|
|
@@ -417,13 +417,13 @@ function oo(e, t) {
|
|
|
417
417
|
}, s = () => {
|
|
418
418
|
if (r) return;
|
|
419
419
|
r = !0, a();
|
|
420
|
-
const d = n.naturalWidth || n.width,
|
|
420
|
+
const d = n.naturalWidth || n.width, R = n.naturalHeight || n.height;
|
|
421
421
|
o({
|
|
422
422
|
success: !0,
|
|
423
423
|
element: n,
|
|
424
424
|
width: d,
|
|
425
|
-
height:
|
|
426
|
-
aspectRatio:
|
|
425
|
+
height: R,
|
|
426
|
+
aspectRatio: R > 0 ? d / R : 1
|
|
427
427
|
});
|
|
428
428
|
}, c = (d) => {
|
|
429
429
|
r || (r = !0, a(), o({
|
|
@@ -438,9 +438,9 @@ function oo(e, t) {
|
|
|
438
438
|
}, t), n.src = e;
|
|
439
439
|
});
|
|
440
440
|
}
|
|
441
|
-
async function
|
|
442
|
-
var k,
|
|
443
|
-
const i = await
|
|
441
|
+
async function Lo(e, t, o = {}, n = {}) {
|
|
442
|
+
var k, x, D, p, m, w, T;
|
|
443
|
+
const i = await se(e, n);
|
|
444
444
|
if (!i.success || !i.width || !i.height)
|
|
445
445
|
return {
|
|
446
446
|
success: !1,
|
|
@@ -450,7 +450,7 @@ async function Do(e, t, o = {}, n = {}) {
|
|
|
450
450
|
width: t.artboard.width,
|
|
451
451
|
height: t.artboard.height,
|
|
452
452
|
scale: t.scale,
|
|
453
|
-
align:
|
|
453
|
+
align: ee(t.alignment),
|
|
454
454
|
offsetX: t.offsetX,
|
|
455
455
|
offsetY: t.offsetY,
|
|
456
456
|
scaleMode: t.scaleMode,
|
|
@@ -458,16 +458,16 @@ async function Do(e, t, o = {}, n = {}) {
|
|
|
458
458
|
marginRight: t.marginRight,
|
|
459
459
|
marginBottom: t.marginBottom,
|
|
460
460
|
marginLeft: t.marginLeft
|
|
461
|
-
}, a =
|
|
461
|
+
}, a = oe(
|
|
462
462
|
{ width: i.width, height: i.height },
|
|
463
463
|
r
|
|
464
|
-
), s = t.artboard.x + a.x, c = t.artboard.y + a.y, d = s + a.width / 2,
|
|
464
|
+
), s = t.artboard.x + a.x, c = t.artboard.y + a.y, d = s + a.width / 2, R = c + a.height / 2;
|
|
465
465
|
return {
|
|
466
466
|
success: !0,
|
|
467
|
-
element: new
|
|
467
|
+
element: new _t({
|
|
468
468
|
...o,
|
|
469
469
|
x: d,
|
|
470
|
-
y:
|
|
470
|
+
y: R,
|
|
471
471
|
imageUrl: e,
|
|
472
472
|
imageAspectRatio: i.aspectRatio,
|
|
473
473
|
preserveDimensions: !0,
|
|
@@ -477,26 +477,26 @@ async function Do(e, t, o = {}, n = {}) {
|
|
|
477
477
|
width: a.width,
|
|
478
478
|
height: a.height,
|
|
479
479
|
cropX: ((k = o.transformData) == null ? void 0 : k.cropX) ?? 0,
|
|
480
|
-
cropY: ((
|
|
480
|
+
cropY: ((x = o.transformData) == null ? void 0 : x.cropY) ?? 0,
|
|
481
481
|
cropWidth: ((D = o.transformData) == null ? void 0 : D.cropWidth) ?? 1,
|
|
482
|
-
cropHeight: ((
|
|
482
|
+
cropHeight: ((p = o.transformData) == null ? void 0 : p.cropHeight) ?? 1,
|
|
483
483
|
flipHorizontal: ((m = o.transformData) == null ? void 0 : m.flipHorizontal) ?? !1,
|
|
484
|
-
flipVertical: ((
|
|
485
|
-
borderRadius: ((
|
|
484
|
+
flipVertical: ((w = o.transformData) == null ? void 0 : w.flipVertical) ?? !1,
|
|
485
|
+
borderRadius: ((T = o.transformData) == null ? void 0 : T.borderRadius) ?? 0
|
|
486
486
|
}
|
|
487
487
|
}),
|
|
488
488
|
placement: {
|
|
489
489
|
artworkSize: { width: i.width, height: i.height },
|
|
490
490
|
finalSize: { width: a.width, height: a.height },
|
|
491
|
-
position: { x: d, y:
|
|
491
|
+
position: { x: d, y: R },
|
|
492
492
|
scale: a.scale
|
|
493
493
|
}
|
|
494
494
|
};
|
|
495
495
|
}
|
|
496
|
-
function
|
|
496
|
+
function ro(e) {
|
|
497
497
|
return new Promise((t) => setTimeout(t, e));
|
|
498
498
|
}
|
|
499
|
-
function
|
|
499
|
+
function Vo(e) {
|
|
500
500
|
if (e != null && e.scaleMode)
|
|
501
501
|
return {
|
|
502
502
|
scaleMode: e.scaleMode,
|
|
@@ -507,21 +507,21 @@ function Lo(e) {
|
|
|
507
507
|
align: e.fitAlign
|
|
508
508
|
};
|
|
509
509
|
}
|
|
510
|
-
function
|
|
510
|
+
function ae(e) {
|
|
511
511
|
var t;
|
|
512
512
|
return ((t = e == null ? void 0 : e.imageFit) == null ? void 0 : t.scaleMode) === "contain";
|
|
513
513
|
}
|
|
514
|
-
function
|
|
515
|
-
if (!
|
|
514
|
+
function io(e, t) {
|
|
515
|
+
if (!ae(e)) return null;
|
|
516
516
|
if (!(t.width > 0) || !(t.height > 0))
|
|
517
517
|
throw new Error(
|
|
518
518
|
`E_NEW_IMAGE_SIZE: a new picture of ${t.width}x${t.height} cannot be placed on a ${e.width}x${e.height} area; pass the picture's natural size (loadImageFromURL).`
|
|
519
519
|
);
|
|
520
|
-
const o = e.imageFit, n =
|
|
520
|
+
const o = e.imageFit, n = oe(t, {
|
|
521
521
|
width: e.width,
|
|
522
522
|
height: e.height,
|
|
523
523
|
scaleMode: "contain",
|
|
524
|
-
align:
|
|
524
|
+
align: ee(o.align),
|
|
525
525
|
marginTop: o.marginTop,
|
|
526
526
|
marginRight: o.marginRight,
|
|
527
527
|
marginBottom: o.marginBottom,
|
|
@@ -534,71 +534,71 @@ function ro(e, t) {
|
|
|
534
534
|
height: n.height
|
|
535
535
|
};
|
|
536
536
|
}
|
|
537
|
-
async function
|
|
538
|
-
if (!
|
|
539
|
-
const o = await
|
|
540
|
-
return !o.success || !o.width || !o.height ? null :
|
|
537
|
+
async function so(e, t) {
|
|
538
|
+
if (!ae(e)) return null;
|
|
539
|
+
const o = await se(t, { validateUrl: !1 });
|
|
540
|
+
return !o.success || !o.width || !o.height ? null : io(e, { width: o.width, height: o.height });
|
|
541
541
|
}
|
|
542
|
-
const
|
|
542
|
+
const ce = q(null), ao = 0.1, co = 4, Jt = 0.25, lo = ({
|
|
543
543
|
children: e,
|
|
544
544
|
artboardManager: t,
|
|
545
545
|
canvasRef: o,
|
|
546
546
|
viewPadding: n = 0.9
|
|
547
547
|
}) => {
|
|
548
|
-
const [i, r] =
|
|
548
|
+
const [i, r] = S(1), [a, s] = S({ x: 0, y: 0 }), [c, d] = S(!1), [R, N] = S(1), k = h(() => {
|
|
549
549
|
N(1), s({ x: 0, y: 0 });
|
|
550
|
-
}, []),
|
|
551
|
-
r((
|
|
550
|
+
}, []), x = h(() => {
|
|
551
|
+
r((T) => Math.min(T + Jt, co));
|
|
552
552
|
}, []), D = h(() => {
|
|
553
|
-
r((
|
|
554
|
-
}, []),
|
|
555
|
-
const
|
|
556
|
-
if (!
|
|
557
|
-
let
|
|
558
|
-
for (;
|
|
559
|
-
|
|
560
|
-
if (!
|
|
561
|
-
const
|
|
562
|
-
|
|
563
|
-
M * n /
|
|
553
|
+
r((T) => Math.max(T - Jt, ao));
|
|
554
|
+
}, []), p = h(() => {
|
|
555
|
+
const T = t.getActiveArtboard();
|
|
556
|
+
if (!T || !o.current) return;
|
|
557
|
+
let C = o.current.parentElement, I = 0, M = 0;
|
|
558
|
+
for (; C && (I = C.clientWidth, M = C.clientHeight, !(I > 0 && M > 0)); )
|
|
559
|
+
C = C.parentElement;
|
|
560
|
+
if (!I || !M) return;
|
|
561
|
+
const ot = Math.min(
|
|
562
|
+
I * n / T.width,
|
|
563
|
+
M * n / T.height,
|
|
564
564
|
1
|
|
565
565
|
// Never zoom in beyond 100%
|
|
566
566
|
);
|
|
567
|
-
r(
|
|
567
|
+
r(ot), s({ x: 0, y: 0 });
|
|
568
568
|
}, [t, o, n]), m = h(() => {
|
|
569
569
|
r(1), s({ x: 0, y: 0 });
|
|
570
|
-
}, []),
|
|
570
|
+
}, []), w = J(
|
|
571
571
|
() => ({
|
|
572
572
|
zoom: i,
|
|
573
573
|
panOffset: a,
|
|
574
574
|
isPanning: c,
|
|
575
|
-
zoomIn:
|
|
575
|
+
zoomIn: x,
|
|
576
576
|
zoomOut: D,
|
|
577
|
-
zoomToFit:
|
|
577
|
+
zoomToFit: p,
|
|
578
578
|
resetView: m,
|
|
579
579
|
setZoom: r,
|
|
580
580
|
setPanOffset: s,
|
|
581
581
|
setIsPanning: d,
|
|
582
|
-
userZoom:
|
|
582
|
+
userZoom: R,
|
|
583
583
|
setUserZoom: N,
|
|
584
584
|
resetUserView: k
|
|
585
585
|
}),
|
|
586
|
-
[i, a, c,
|
|
586
|
+
[i, a, c, x, D, p, m, R, k]
|
|
587
587
|
);
|
|
588
|
-
return /* @__PURE__ */ V(
|
|
588
|
+
return /* @__PURE__ */ V(ce.Provider, { value: w, children: e });
|
|
589
589
|
};
|
|
590
|
-
function
|
|
591
|
-
const e = G(
|
|
590
|
+
function uo() {
|
|
591
|
+
const e = G(ce);
|
|
592
592
|
if (!e)
|
|
593
593
|
throw new Error("useViewportContext must be used within a ViewportProvider (or EditorProvider)");
|
|
594
594
|
return e;
|
|
595
595
|
}
|
|
596
|
-
const
|
|
597
|
-
const [t, o] =
|
|
596
|
+
const de = q(null), ho = ({ children: e }) => {
|
|
597
|
+
const [t, o] = S(null), [n, i] = S([]), [r, a] = S(null), [s, c] = S(null), [d, R] = S(!1), N = h((D) => {
|
|
598
598
|
o(D);
|
|
599
599
|
}, []), k = h((D) => {
|
|
600
600
|
a(D);
|
|
601
|
-
}, []),
|
|
601
|
+
}, []), x = J(
|
|
602
602
|
() => ({
|
|
603
603
|
selectedId: t,
|
|
604
604
|
multiSelection: n,
|
|
@@ -608,7 +608,7 @@ const ce = Q(null), uo = ({ children: e }) => {
|
|
|
608
608
|
setSelectedId: o,
|
|
609
609
|
setMultiSelection: i,
|
|
610
610
|
setHoveredElementId: c,
|
|
611
|
-
setHideHandles:
|
|
611
|
+
setHideHandles: R,
|
|
612
612
|
handleSelectionChange: N,
|
|
613
613
|
handleActiveChildChange: k
|
|
614
614
|
}),
|
|
@@ -622,16 +622,16 @@ const ce = Q(null), uo = ({ children: e }) => {
|
|
|
622
622
|
k
|
|
623
623
|
]
|
|
624
624
|
);
|
|
625
|
-
return /* @__PURE__ */ V(
|
|
625
|
+
return /* @__PURE__ */ V(de.Provider, { value: x, children: e });
|
|
626
626
|
};
|
|
627
|
-
function
|
|
628
|
-
const e = G(
|
|
627
|
+
function mo() {
|
|
628
|
+
const e = G(de);
|
|
629
629
|
if (!e)
|
|
630
630
|
throw new Error("useSelectionContext must be used within a SelectionProvider (or EditorProvider)");
|
|
631
631
|
return e;
|
|
632
632
|
}
|
|
633
|
-
const
|
|
634
|
-
const o =
|
|
633
|
+
const le = q(null), fo = ({ children: e, value: t }) => {
|
|
634
|
+
const o = J(
|
|
635
635
|
() => ({
|
|
636
636
|
undo: t.undo,
|
|
637
637
|
redo: t.redo,
|
|
@@ -653,16 +653,16 @@ const de = Q(null), mo = ({ children: e, value: t }) => {
|
|
|
653
653
|
t.canRedoActiveArtboard
|
|
654
654
|
]
|
|
655
655
|
);
|
|
656
|
-
return /* @__PURE__ */ V(
|
|
656
|
+
return /* @__PURE__ */ V(le.Provider, { value: o, children: e });
|
|
657
657
|
};
|
|
658
|
-
function
|
|
659
|
-
const e = G(
|
|
658
|
+
function _o() {
|
|
659
|
+
const e = G(le);
|
|
660
660
|
if (!e)
|
|
661
661
|
throw new Error("useHistoryContext must be used within a HistoryProvider (or EditorProvider)");
|
|
662
662
|
return e;
|
|
663
663
|
}
|
|
664
|
-
const
|
|
665
|
-
const [t, o] =
|
|
664
|
+
const ue = q(null), po = ({ children: e }) => {
|
|
665
|
+
const [t, o] = S(null), [n, i] = S(!1), [r, a] = S(0), [s, c] = S(!1), [d, R] = S(!1), N = J(
|
|
666
666
|
() => ({
|
|
667
667
|
expandedPanelType: t,
|
|
668
668
|
setExpandedPanelType: o,
|
|
@@ -673,20 +673,20 @@ const le = Q(null), fo = ({ children: e }) => {
|
|
|
673
673
|
isCanvasReady: s,
|
|
674
674
|
setCanvasReady: c,
|
|
675
675
|
isRotating: d,
|
|
676
|
-
setIsRotating:
|
|
676
|
+
setIsRotating: R
|
|
677
677
|
}),
|
|
678
678
|
[t, n, r, s, d]
|
|
679
679
|
);
|
|
680
|
-
return /* @__PURE__ */ V(
|
|
680
|
+
return /* @__PURE__ */ V(ue.Provider, { value: N, children: e });
|
|
681
681
|
};
|
|
682
|
-
function
|
|
683
|
-
const e = G(
|
|
682
|
+
function go() {
|
|
683
|
+
const e = G(ue);
|
|
684
684
|
if (!e)
|
|
685
685
|
throw new Error("useToolStateContext must be used within a ToolStateProvider (or EditorProvider)");
|
|
686
686
|
return e;
|
|
687
687
|
}
|
|
688
|
-
const
|
|
689
|
-
const o =
|
|
688
|
+
const he = q(null), Ao = ({ children: e, value: t }) => {
|
|
689
|
+
const o = J(
|
|
690
690
|
() => ({
|
|
691
691
|
elements: t.elements,
|
|
692
692
|
elementStore: t.elementStore,
|
|
@@ -740,16 +740,16 @@ const ue = Q(null), go = ({ children: e, value: t }) => {
|
|
|
740
740
|
t.canvasEditorRef
|
|
741
741
|
]
|
|
742
742
|
);
|
|
743
|
-
return /* @__PURE__ */ V(
|
|
743
|
+
return /* @__PURE__ */ V(he.Provider, { value: o, children: e });
|
|
744
744
|
};
|
|
745
|
-
function
|
|
746
|
-
const e = G(
|
|
745
|
+
function $o() {
|
|
746
|
+
const e = G(he);
|
|
747
747
|
if (!e)
|
|
748
748
|
throw new Error("useElementsContext must be used within an ElementsProvider (or EditorProvider)");
|
|
749
749
|
return e;
|
|
750
750
|
}
|
|
751
|
-
const
|
|
752
|
-
const o =
|
|
751
|
+
const me = q(null), yo = ({ children: e, value: t }) => {
|
|
752
|
+
const o = J(
|
|
753
753
|
() => ({
|
|
754
754
|
executeElementUpdate: t.executeElementUpdate,
|
|
755
755
|
executeAddElement: t.executeAddElement,
|
|
@@ -789,120 +789,129 @@ const he = Q(null), Ao = ({ children: e, value: t }) => {
|
|
|
789
789
|
t.historyManager
|
|
790
790
|
]
|
|
791
791
|
);
|
|
792
|
-
return /* @__PURE__ */ V(
|
|
792
|
+
return /* @__PURE__ */ V(me.Provider, { value: o, children: e });
|
|
793
793
|
};
|
|
794
|
-
function
|
|
795
|
-
const e = G(
|
|
794
|
+
function Bo() {
|
|
795
|
+
const e = G(me);
|
|
796
796
|
if (!e)
|
|
797
797
|
throw new Error("useCommandContext must be used within a CommandProvider (or EditorProvider)");
|
|
798
798
|
return e;
|
|
799
799
|
}
|
|
800
|
-
const
|
|
801
|
-
const e = G(
|
|
800
|
+
const xo = te("EditorContext"), fe = q(null), pe = q(null), Mo = () => {
|
|
801
|
+
const e = G(pe);
|
|
802
802
|
if (!e)
|
|
803
803
|
throw new Error("useEditorHandles must be used within EditorProvider");
|
|
804
804
|
return e;
|
|
805
|
-
},
|
|
806
|
-
const i =
|
|
805
|
+
}, wo = ({ children: e, artboardManager: t, canvasRef: o, canvasEditorRef: n }) => {
|
|
806
|
+
const i = At(null), r = J(() => ({ get: () => i.current }), []), a = uo(), s = mo(), c = go(), [d, R] = S(
|
|
807
807
|
() => t.getAllArtboards()
|
|
808
|
-
), [N, k] =
|
|
809
|
-
() => new
|
|
810
|
-
),
|
|
811
|
-
D((
|
|
812
|
-
const
|
|
813
|
-
return
|
|
808
|
+
), [N, k] = S(0), [x, D] = S(
|
|
809
|
+
() => new Xt()
|
|
810
|
+
), p = J(() => x.toArray(), [x]), m = h((l) => {
|
|
811
|
+
D((f) => {
|
|
812
|
+
const y = f.toArray(), E = typeof l == "function" ? l(y) : l;
|
|
813
|
+
return E === y ? f : Xt.fromArray(E);
|
|
814
814
|
});
|
|
815
|
-
}, []),
|
|
816
|
-
(
|
|
817
|
-
[
|
|
818
|
-
), [
|
|
819
|
-
|
|
815
|
+
}, []), w = h(
|
|
816
|
+
(l) => x.get(l),
|
|
817
|
+
[x]
|
|
818
|
+
), [T, C] = S([]), I = s.selectedId ? x.get(s.selectedId) : void 0, M = h(() => {
|
|
819
|
+
R([...t.getAllArtboards()]), k((l) => l + 1);
|
|
820
820
|
}, [t]), {
|
|
821
|
-
historyManager:
|
|
822
|
-
executeElementUpdate:
|
|
821
|
+
historyManager: ot,
|
|
822
|
+
executeElementUpdate: ht,
|
|
823
823
|
executeAddElement: W,
|
|
824
|
-
executeRemoveElement:
|
|
825
|
-
executeReorderElement:
|
|
826
|
-
executeCommandBatch:
|
|
824
|
+
executeRemoveElement: u,
|
|
825
|
+
executeReorderElement: g,
|
|
826
|
+
executeCommandBatch: b,
|
|
827
827
|
executeCreateArtboard: A,
|
|
828
|
-
executeDeleteArtboard:
|
|
828
|
+
executeDeleteArtboard: F,
|
|
829
829
|
executeUpdateArtboard: Y,
|
|
830
830
|
undo: z,
|
|
831
|
-
redo:
|
|
831
|
+
redo: _,
|
|
832
832
|
canUndo: U,
|
|
833
833
|
canRedo: L,
|
|
834
834
|
undoActiveArtboard: P,
|
|
835
835
|
redoActiveArtboard: K,
|
|
836
|
-
canUndoActiveArtboard:
|
|
836
|
+
canUndoActiveArtboard: nt,
|
|
837
837
|
canRedoActiveArtboard: Z
|
|
838
|
-
} =
|
|
839
|
-
|
|
838
|
+
} = Ke(
|
|
839
|
+
p,
|
|
840
840
|
m,
|
|
841
841
|
t,
|
|
842
842
|
M
|
|
843
|
-
),
|
|
844
|
-
(
|
|
845
|
-
|
|
846
|
-
|
|
843
|
+
), $ = h(
|
|
844
|
+
(l, f) => {
|
|
845
|
+
if (f && t.isPlaceholder(f.id)) {
|
|
846
|
+
const y = l == null ? void 0 : l.text, E = f.text;
|
|
847
|
+
typeof E == "string" && y !== E && t.unmarkPlaceholder(f.id);
|
|
848
|
+
}
|
|
849
|
+
return ht(l, f);
|
|
847
850
|
},
|
|
848
|
-
[
|
|
849
|
-
),
|
|
850
|
-
(
|
|
851
|
-
|
|
851
|
+
[t, ht]
|
|
852
|
+
), it = h(
|
|
853
|
+
(l) => {
|
|
854
|
+
const f = x.get(l.id);
|
|
855
|
+
$(f, l);
|
|
856
|
+
},
|
|
857
|
+
[x, $]
|
|
858
|
+
), we = h(
|
|
859
|
+
(l) => {
|
|
860
|
+
if (!I || !(I instanceof Qt))
|
|
852
861
|
return;
|
|
853
|
-
const
|
|
854
|
-
(
|
|
862
|
+
const f = I.clone(), y = f.children.findIndex(
|
|
863
|
+
(E) => E.id === l.id
|
|
855
864
|
);
|
|
856
|
-
|
|
865
|
+
y >= 0 && (f.children[y] = l, it(f));
|
|
857
866
|
},
|
|
858
|
-
[
|
|
859
|
-
),
|
|
860
|
-
fontSize:
|
|
861
|
-
fontColor:
|
|
862
|
-
fontFamily:
|
|
863
|
-
textAlign:
|
|
864
|
-
updateFontSize:
|
|
865
|
-
setFontSizeValue:
|
|
866
|
-
updateFontColor:
|
|
867
|
-
updateFontFamily:
|
|
868
|
-
updateTextAlign:
|
|
869
|
-
} =
|
|
870
|
-
async (
|
|
871
|
-
var
|
|
872
|
-
const
|
|
873
|
-
if (!
|
|
874
|
-
throw new
|
|
867
|
+
[I, it]
|
|
868
|
+
), be = s.activeChildElement || I, Ee = s.activeChildElement ? we : it, {
|
|
869
|
+
fontSize: St,
|
|
870
|
+
fontColor: Rt,
|
|
871
|
+
fontFamily: It,
|
|
872
|
+
textAlign: Tt,
|
|
873
|
+
updateFontSize: Ct,
|
|
874
|
+
setFontSizeValue: Ft,
|
|
875
|
+
updateFontColor: vt,
|
|
876
|
+
updateFontFamily: Pt,
|
|
877
|
+
updateTextAlign: Nt
|
|
878
|
+
} = Ze(be, Ee), yt = h(
|
|
879
|
+
async (l) => {
|
|
880
|
+
var Wt;
|
|
881
|
+
const f = l.type, y = l, E = t.getActiveArtboardId();
|
|
882
|
+
if (!E)
|
|
883
|
+
throw new et(
|
|
875
884
|
"E_NO_ACTIVE_ARTBOARD",
|
|
876
|
-
`addElement({ type: "${
|
|
877
|
-
{ type:
|
|
885
|
+
`addElement({ type: "${f}" }) needs an active artboard and none exists. <Editor.Root> seeds one automatically; with a raw EditorProvider create one first (executeCreateArtboard) or select one (artboardManager.setActiveArtboard).`,
|
|
886
|
+
{ type: f, docSlug: "embed-mode" }
|
|
878
887
|
);
|
|
879
|
-
const v = `element-${Date.now()}`, O = t.getActiveArtboard(),
|
|
880
|
-
if (
|
|
881
|
-
const
|
|
882
|
-
if (
|
|
883
|
-
const H = new
|
|
888
|
+
const v = `element-${Date.now()}`, O = t.getActiveArtboard(), mt = O ? O.x + O.width / 2 : window.innerWidth / 2, st = O ? O.y + O.height / 2 : window.innerHeight / 2, j = ((Wt = n.current) == null ? void 0 : Wt.getZoom()) || a.zoom || 1;
|
|
889
|
+
if (f === "image") {
|
|
890
|
+
const pt = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==", tt = 200 / j, B = y == null ? void 0 : y.src, gt = B ? await so(O, B) : null;
|
|
891
|
+
if (gt) {
|
|
892
|
+
const H = new _t({
|
|
884
893
|
id: v,
|
|
885
|
-
name:
|
|
886
|
-
x:
|
|
887
|
-
y:
|
|
894
|
+
name: l.name,
|
|
895
|
+
x: gt.x,
|
|
896
|
+
y: gt.y,
|
|
888
897
|
imageUrl: "",
|
|
889
898
|
preserveDimensions: !0,
|
|
890
|
-
transformData: { type: "image", width:
|
|
899
|
+
transformData: { type: "image", width: gt.width, height: gt.height }
|
|
891
900
|
});
|
|
892
|
-
return H.imageUrl = B, H.onLoadCallback = (
|
|
901
|
+
return H.imageUrl = B, H.onLoadCallback = (wt) => $(H, wt), W(H, E), s.setSelectedId(H.id), H.loadImage(B), { id: H.id, name: l.name ?? "" };
|
|
893
902
|
}
|
|
894
|
-
const X = new
|
|
903
|
+
const X = new _t({
|
|
895
904
|
id: v,
|
|
896
|
-
name:
|
|
897
|
-
x:
|
|
905
|
+
name: l.name,
|
|
906
|
+
x: mt,
|
|
898
907
|
y: st,
|
|
899
908
|
// Defer loading `src` until after the element is in the store so a
|
|
900
909
|
// synchronously-cached image can't fire onLoadCallback too early.
|
|
901
|
-
imageUrl: B ? "" :
|
|
910
|
+
imageUrl: B ? "" : pt,
|
|
902
911
|
transformData: {
|
|
903
912
|
type: "image",
|
|
904
|
-
width:
|
|
905
|
-
height:
|
|
913
|
+
width: tt,
|
|
914
|
+
height: tt,
|
|
906
915
|
cropX: 0,
|
|
907
916
|
cropY: 0,
|
|
908
917
|
cropWidth: 1,
|
|
@@ -913,130 +922,130 @@ const yo = Qt("EditorContext"), me = Q(null), fe = Q(null), Bo = () => {
|
|
|
913
922
|
}
|
|
914
923
|
});
|
|
915
924
|
return B && (X.imageLoaded = !1, X.imageElement = null, X.isCropping = !1, X.imageUrl = B, X.preserveDimensions = !1, X.onLoadCallback = (H) => {
|
|
916
|
-
const
|
|
917
|
-
|
|
918
|
-
}), W(X,
|
|
925
|
+
const wt = H.transformData.width, Yt = H.transformData.height, Lt = Math.min(tt / wt, tt / Yt, 1);
|
|
926
|
+
Lt < 1 && (H.transformData.width = wt * Lt, H.transformData.height = Yt * Lt), H.transformData.cropX = 0, H.transformData.cropY = 0, H.transformData.cropWidth = 1, H.transformData.cropHeight = 1, $(X, H);
|
|
927
|
+
}), W(X, E), s.setSelectedId(X.id), B && X.loadImage(B), { id: X.id, name: l.name ?? "" };
|
|
919
928
|
}
|
|
920
|
-
let
|
|
929
|
+
let Q;
|
|
921
930
|
const ct = {
|
|
922
931
|
text: "custom",
|
|
923
932
|
circle: "circle",
|
|
924
933
|
wave: "wave",
|
|
925
934
|
arch: "arch",
|
|
926
935
|
shape: "shape"
|
|
927
|
-
}[
|
|
928
|
-
if (!
|
|
929
|
-
throw new Error(`[EditorContext] no transform registered for element type "${
|
|
930
|
-
const
|
|
931
|
-
if (
|
|
932
|
-
const
|
|
933
|
-
let
|
|
934
|
-
|
|
936
|
+
}[f] || "custom", kt = Le(ct);
|
|
937
|
+
if (!kt || !kt.Component)
|
|
938
|
+
throw new Error(`[EditorContext] no transform registered for element type "${f}"`);
|
|
939
|
+
const ft = t.getActiveArtboard(), Se = ft ? Math.min(ft.width, ft.height) * 0.1 : 80, Dt = ft ? ft.width * 0.5 : 300;
|
|
940
|
+
if (f === "shape") {
|
|
941
|
+
const pt = (y == null ? void 0 : y.shapeType) ?? "rectangle";
|
|
942
|
+
let tt = 200 / j, B = 200 / j;
|
|
943
|
+
pt === "ellipse" ? (tt = 150 / j, B = 250 / j) : pt === "line" && (tt = 300 / j, B = 8 / j), Q = new Ve({
|
|
935
944
|
id: v,
|
|
936
|
-
name:
|
|
937
|
-
x:
|
|
945
|
+
name: l.name,
|
|
946
|
+
x: mt,
|
|
938
947
|
y: st,
|
|
939
948
|
transformData: {
|
|
940
949
|
type: "shape",
|
|
941
|
-
shapeType:
|
|
942
|
-
width:
|
|
950
|
+
shapeType: pt,
|
|
951
|
+
width: tt,
|
|
943
952
|
height: B,
|
|
944
953
|
// an engraved area has one ink: black, which the laser cuts
|
|
945
|
-
fillColor: O != null && O.engrave ?
|
|
954
|
+
fillColor: O != null && O.engrave ? Gt : "#3b82f6",
|
|
946
955
|
fillOpacity: 1
|
|
947
956
|
}
|
|
948
957
|
});
|
|
949
958
|
} else
|
|
950
|
-
|
|
959
|
+
Q = new kt.Component({
|
|
951
960
|
id: v,
|
|
952
|
-
name:
|
|
961
|
+
name: l.name,
|
|
953
962
|
text: "New Text",
|
|
954
|
-
x:
|
|
963
|
+
x: mt,
|
|
955
964
|
y: st,
|
|
956
|
-
fontSize:
|
|
965
|
+
fontSize: Se,
|
|
957
966
|
fontFamily: "Poppins",
|
|
958
|
-
color: O != null && O.engrave ?
|
|
967
|
+
color: O != null && O.engrave ? Gt : to(O == null ? void 0 : O.backgroundColor),
|
|
959
968
|
transformData: ct === "arch" ? {
|
|
960
969
|
type: "arch",
|
|
961
|
-
width:
|
|
962
|
-
archHeight:
|
|
970
|
+
width: Dt,
|
|
971
|
+
archHeight: _e.archHeight
|
|
963
972
|
} : ct === "wave" ? {
|
|
964
973
|
type: "wave",
|
|
965
|
-
width:
|
|
966
|
-
amplitude:
|
|
967
|
-
frequency:
|
|
974
|
+
width: Dt,
|
|
975
|
+
amplitude: Kt.amplitude,
|
|
976
|
+
frequency: Kt.frequency
|
|
968
977
|
} : ct === "circle" ? {
|
|
969
978
|
type: "circle",
|
|
970
|
-
radius:
|
|
979
|
+
radius: Dt / 2
|
|
971
980
|
} : void 0
|
|
972
981
|
});
|
|
973
|
-
return t.addElementToArtboard(v,
|
|
974
|
-
|
|
975
|
-
|
|
982
|
+
return t.addElementToArtboard(v, E), W(
|
|
983
|
+
Q,
|
|
984
|
+
E,
|
|
976
985
|
s.selectedId || void 0
|
|
977
|
-
), s.setSelectedId(v), { id: v, name:
|
|
986
|
+
), s.setSelectedId(v), { id: v, name: l.name ?? "" };
|
|
978
987
|
},
|
|
979
|
-
[t, W,
|
|
980
|
-
),
|
|
981
|
-
async (
|
|
982
|
-
await
|
|
988
|
+
[t, W, $, s, a.zoom, n]
|
|
989
|
+
), Ot = h(
|
|
990
|
+
async (l, f) => {
|
|
991
|
+
await yt({ ...f, type: l });
|
|
983
992
|
},
|
|
984
|
-
[
|
|
985
|
-
),
|
|
986
|
-
const
|
|
993
|
+
[yt]
|
|
994
|
+
), zt = h(() => {
|
|
995
|
+
const l = [];
|
|
987
996
|
if (s.multiSelection.length > 0) {
|
|
988
|
-
const
|
|
989
|
-
(
|
|
997
|
+
const f = p.filter(
|
|
998
|
+
(y) => s.multiSelection.includes(y.id)
|
|
990
999
|
);
|
|
991
|
-
|
|
992
|
-
} else
|
|
993
|
-
if (
|
|
994
|
-
const
|
|
995
|
-
|
|
1000
|
+
l.push(...f);
|
|
1001
|
+
} else I && l.push(I);
|
|
1002
|
+
if (l.length > 0) {
|
|
1003
|
+
const f = l.map((y) => y.clone());
|
|
1004
|
+
C(f);
|
|
996
1005
|
}
|
|
997
|
-
}, [
|
|
998
|
-
if (
|
|
999
|
-
const
|
|
1000
|
-
|
|
1001
|
-
const v =
|
|
1006
|
+
}, [I, s.multiSelection, p]), Ut = h(() => {
|
|
1007
|
+
if (T.length === 0) return;
|
|
1008
|
+
const l = [], f = 30, y = 30;
|
|
1009
|
+
T.forEach((E) => {
|
|
1010
|
+
const v = x.get(E.id), O = v ? v.x : E.x, mt = v ? v.y : E.y, st = E.toJSON();
|
|
1002
1011
|
delete st.id;
|
|
1003
|
-
const
|
|
1004
|
-
|
|
1012
|
+
const j = E.constructor, Q = new j(st);
|
|
1013
|
+
Q.x = O + f, Q.y = mt + y;
|
|
1005
1014
|
let at = null;
|
|
1006
1015
|
if (v && (at = t.getArtboardIdForElement(
|
|
1007
1016
|
v.id
|
|
1008
1017
|
)), at || (at = t.getActiveArtboardId()), !at) {
|
|
1009
|
-
|
|
1018
|
+
xo.warn("[handlePasteElements] No artboard found for pasting");
|
|
1010
1019
|
return;
|
|
1011
1020
|
}
|
|
1012
1021
|
const ct = v ? v.id : void 0;
|
|
1013
|
-
W(
|
|
1014
|
-
}),
|
|
1022
|
+
W(Q, at, ct), l.push(Q.id);
|
|
1023
|
+
}), l.length === 1 ? s.handleSelectionChange(l[0]) : l.length > 1 && s.setMultiSelection(l);
|
|
1015
1024
|
}, [
|
|
1016
|
-
|
|
1017
|
-
|
|
1025
|
+
T,
|
|
1026
|
+
x,
|
|
1018
1027
|
t,
|
|
1019
1028
|
W,
|
|
1020
1029
|
s
|
|
1021
|
-
]),
|
|
1022
|
-
if (c.expandedPanelType === "crop" && (
|
|
1023
|
-
const
|
|
1024
|
-
if (
|
|
1025
|
-
const
|
|
1026
|
-
|
|
1030
|
+
]), xt = h(() => {
|
|
1031
|
+
if (c.expandedPanelType === "crop" && (I == null ? void 0 : I.transformType) === "image") {
|
|
1032
|
+
const l = I;
|
|
1033
|
+
if (l.isCropping) {
|
|
1034
|
+
const f = l.clone();
|
|
1035
|
+
f.exitCropMode(), $(l, f);
|
|
1027
1036
|
}
|
|
1028
1037
|
}
|
|
1029
1038
|
c.setExpandedPanelType(null);
|
|
1030
1039
|
}, [
|
|
1031
1040
|
c.expandedPanelType,
|
|
1032
1041
|
c.setExpandedPanelType,
|
|
1033
|
-
|
|
1034
|
-
|
|
1042
|
+
I,
|
|
1043
|
+
$
|
|
1035
1044
|
]);
|
|
1036
|
-
|
|
1037
|
-
const
|
|
1038
|
-
const
|
|
1039
|
-
if (
|
|
1045
|
+
Bt(() => {
|
|
1046
|
+
const l = (f) => {
|
|
1047
|
+
const y = f.target;
|
|
1048
|
+
if (y.tagName === "CANVAS" || je(y))
|
|
1040
1049
|
return;
|
|
1041
1050
|
const v = document.activeElement;
|
|
1042
1051
|
if (v != null && v.hasAttribute("data-preserve-selection")) {
|
|
@@ -1044,21 +1053,21 @@ const yo = Qt("EditorContext"), me = Q(null), fe = Q(null), Bo = () => {
|
|
|
1044
1053
|
return;
|
|
1045
1054
|
}
|
|
1046
1055
|
if (c.expandedPanelType !== null) {
|
|
1047
|
-
|
|
1056
|
+
xt();
|
|
1048
1057
|
return;
|
|
1049
1058
|
}
|
|
1050
1059
|
s.selectedId !== null && s.setSelectedId(null), s.multiSelection.length > 0 && s.setMultiSelection([]);
|
|
1051
1060
|
};
|
|
1052
|
-
return document.addEventListener("pointerdown",
|
|
1053
|
-
}, [c.expandedPanelType,
|
|
1054
|
-
const
|
|
1055
|
-
(
|
|
1056
|
-
t.clear(),
|
|
1057
|
-
t.createArtboard(
|
|
1058
|
-
}),
|
|
1061
|
+
return document.addEventListener("pointerdown", l), () => document.removeEventListener("pointerdown", l);
|
|
1062
|
+
}, [c.expandedPanelType, xt, s]);
|
|
1063
|
+
const Ht = h(
|
|
1064
|
+
(l, f, y) => {
|
|
1065
|
+
t.clear(), l.forEach((E) => {
|
|
1066
|
+
t.createArtboard(E.toJSON());
|
|
1067
|
+
}), y && t.setActiveArtboard(y), R([...t.getAllArtboards()]), k((E) => E + 1), m(f), s.setSelectedId(null);
|
|
1059
1068
|
},
|
|
1060
1069
|
[t, s, m]
|
|
1061
|
-
),
|
|
1070
|
+
), Mt = J(() => ({
|
|
1062
1071
|
// From ViewportContext
|
|
1063
1072
|
zoom: a.zoom,
|
|
1064
1073
|
panOffset: a.panOffset,
|
|
@@ -1094,15 +1103,15 @@ const yo = Qt("EditorContext"), me = Q(null), fe = Q(null), Bo = () => {
|
|
|
1094
1103
|
isRotating: c.isRotating,
|
|
1095
1104
|
setIsRotating: c.setIsRotating,
|
|
1096
1105
|
// Cross-context handler
|
|
1097
|
-
clearExpandedPanel:
|
|
1106
|
+
clearExpandedPanel: xt,
|
|
1098
1107
|
// Core state (element/artboard domain)
|
|
1099
1108
|
artboardManager: t,
|
|
1100
1109
|
artboards: d,
|
|
1101
|
-
elements:
|
|
1102
|
-
elementStore:
|
|
1103
|
-
getElementById:
|
|
1110
|
+
elements: p,
|
|
1111
|
+
elementStore: x,
|
|
1112
|
+
getElementById: w,
|
|
1104
1113
|
// Derived state (cross-context)
|
|
1105
|
-
selectedElement:
|
|
1114
|
+
selectedElement: I,
|
|
1106
1115
|
// Refs
|
|
1107
1116
|
canvasRef: o,
|
|
1108
1117
|
canvasEditorRef: n,
|
|
@@ -1112,41 +1121,41 @@ const yo = Qt("EditorContext"), me = Q(null), fe = Q(null), Bo = () => {
|
|
|
1112
1121
|
artboardVersion: N,
|
|
1113
1122
|
// Handlers
|
|
1114
1123
|
refreshArtboards: M,
|
|
1115
|
-
handleElementUpdate:
|
|
1116
|
-
addElement:
|
|
1117
|
-
handleAddElement:
|
|
1118
|
-
handleLoadWorkspace:
|
|
1119
|
-
handleCopyElements:
|
|
1120
|
-
handlePasteElements:
|
|
1121
|
-
hasClipboardContent:
|
|
1124
|
+
handleElementUpdate: it,
|
|
1125
|
+
addElement: yt,
|
|
1126
|
+
handleAddElement: Ot,
|
|
1127
|
+
handleLoadWorkspace: Ht,
|
|
1128
|
+
handleCopyElements: zt,
|
|
1129
|
+
handlePasteElements: Ut,
|
|
1130
|
+
hasClipboardContent: T.length > 0,
|
|
1122
1131
|
// Command history (undo/redo actions + execute functions)
|
|
1123
|
-
historyManager:
|
|
1124
|
-
executeElementUpdate:
|
|
1132
|
+
historyManager: ot,
|
|
1133
|
+
executeElementUpdate: $,
|
|
1125
1134
|
executeAddElement: W,
|
|
1126
|
-
executeRemoveElement:
|
|
1127
|
-
executeReorderElement:
|
|
1128
|
-
executeCommandBatch:
|
|
1135
|
+
executeRemoveElement: u,
|
|
1136
|
+
executeReorderElement: g,
|
|
1137
|
+
executeCommandBatch: b,
|
|
1129
1138
|
executeCreateArtboard: A,
|
|
1130
|
-
executeDeleteArtboard:
|
|
1139
|
+
executeDeleteArtboard: F,
|
|
1131
1140
|
executeUpdateArtboard: Y,
|
|
1132
1141
|
undo: z,
|
|
1133
|
-
redo:
|
|
1142
|
+
redo: _,
|
|
1134
1143
|
canUndo: U,
|
|
1135
1144
|
canRedo: L,
|
|
1136
1145
|
undoActiveArtboard: P,
|
|
1137
1146
|
redoActiveArtboard: K,
|
|
1138
|
-
canUndoActiveArtboard:
|
|
1147
|
+
canUndoActiveArtboard: nt,
|
|
1139
1148
|
canRedoActiveArtboard: Z,
|
|
1140
1149
|
// Element properties
|
|
1141
|
-
fontSize:
|
|
1142
|
-
fontColor:
|
|
1143
|
-
fontFamily:
|
|
1144
|
-
textAlign:
|
|
1145
|
-
updateFontSize:
|
|
1146
|
-
setFontSizeValue:
|
|
1147
|
-
updateFontColor:
|
|
1148
|
-
updateFontFamily:
|
|
1149
|
-
updateTextAlign:
|
|
1150
|
+
fontSize: St,
|
|
1151
|
+
fontColor: Rt,
|
|
1152
|
+
fontFamily: It,
|
|
1153
|
+
textAlign: Tt,
|
|
1154
|
+
updateFontSize: Ct,
|
|
1155
|
+
setFontSizeValue: Ft,
|
|
1156
|
+
updateFontColor: vt,
|
|
1157
|
+
updateFontFamily: Pt,
|
|
1158
|
+
updateTextAlign: Nt
|
|
1150
1159
|
}), [
|
|
1151
1160
|
// Viewport
|
|
1152
1161
|
a.zoom,
|
|
@@ -1182,46 +1191,45 @@ const yo = Qt("EditorContext"), me = Q(null), fe = Q(null), Bo = () => {
|
|
|
1182
1191
|
c.setCanvasReady,
|
|
1183
1192
|
c.isRotating,
|
|
1184
1193
|
c.setIsRotating,
|
|
1185
|
-
|
|
1194
|
+
xt,
|
|
1186
1195
|
// Element/artboard domain
|
|
1187
1196
|
t,
|
|
1188
1197
|
d,
|
|
1189
|
-
|
|
1190
|
-
y,
|
|
1198
|
+
p,
|
|
1191
1199
|
x,
|
|
1192
|
-
|
|
1200
|
+
w,
|
|
1201
|
+
I,
|
|
1193
1202
|
o,
|
|
1194
1203
|
n,
|
|
1195
1204
|
m,
|
|
1196
1205
|
N,
|
|
1197
1206
|
M,
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
Nt,
|
|
1201
|
-
Ut,
|
|
1207
|
+
it,
|
|
1208
|
+
yt,
|
|
1202
1209
|
Ot,
|
|
1210
|
+
Ht,
|
|
1203
1211
|
zt,
|
|
1204
|
-
|
|
1212
|
+
Ut,
|
|
1213
|
+
T,
|
|
1205
1214
|
// Command history
|
|
1206
|
-
|
|
1207
|
-
|
|
1215
|
+
ot,
|
|
1216
|
+
$,
|
|
1208
1217
|
W,
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1218
|
+
u,
|
|
1219
|
+
g,
|
|
1220
|
+
b,
|
|
1212
1221
|
A,
|
|
1213
|
-
|
|
1222
|
+
F,
|
|
1214
1223
|
Y,
|
|
1215
1224
|
z,
|
|
1216
|
-
|
|
1225
|
+
_,
|
|
1217
1226
|
U,
|
|
1218
1227
|
L,
|
|
1219
1228
|
P,
|
|
1220
1229
|
K,
|
|
1221
|
-
|
|
1230
|
+
nt,
|
|
1222
1231
|
Z,
|
|
1223
1232
|
// Element properties
|
|
1224
|
-
Et,
|
|
1225
1233
|
St,
|
|
1226
1234
|
Rt,
|
|
1227
1235
|
It,
|
|
@@ -1229,103 +1237,104 @@ const yo = Qt("EditorContext"), me = Q(null), fe = Q(null), Bo = () => {
|
|
|
1229
1237
|
Ct,
|
|
1230
1238
|
Ft,
|
|
1231
1239
|
vt,
|
|
1232
|
-
Pt
|
|
1240
|
+
Pt,
|
|
1241
|
+
Nt
|
|
1233
1242
|
]);
|
|
1234
|
-
return i.current =
|
|
1235
|
-
|
|
1243
|
+
return i.current = Mt, /* @__PURE__ */ V(pe.Provider, { value: r, children: /* @__PURE__ */ V(
|
|
1244
|
+
fo,
|
|
1236
1245
|
{
|
|
1237
1246
|
value: {
|
|
1238
1247
|
undo: z,
|
|
1239
|
-
redo:
|
|
1248
|
+
redo: _,
|
|
1240
1249
|
canUndo: U,
|
|
1241
1250
|
canRedo: L,
|
|
1242
1251
|
undoActiveArtboard: P,
|
|
1243
1252
|
redoActiveArtboard: K,
|
|
1244
|
-
canUndoActiveArtboard:
|
|
1253
|
+
canUndoActiveArtboard: nt,
|
|
1245
1254
|
canRedoActiveArtboard: Z
|
|
1246
1255
|
},
|
|
1247
1256
|
children: /* @__PURE__ */ V(
|
|
1248
|
-
|
|
1257
|
+
Ao,
|
|
1249
1258
|
{
|
|
1250
1259
|
value: {
|
|
1251
|
-
elements:
|
|
1252
|
-
elementStore:
|
|
1260
|
+
elements: p,
|
|
1261
|
+
elementStore: x,
|
|
1253
1262
|
artboards: d,
|
|
1254
1263
|
artboardManager: t,
|
|
1255
1264
|
artboardVersion: N,
|
|
1256
1265
|
setElements: m,
|
|
1257
1266
|
refreshArtboards: M,
|
|
1258
|
-
getElementById:
|
|
1259
|
-
handleAddElement:
|
|
1260
|
-
handleElementUpdate:
|
|
1261
|
-
handleLoadWorkspace:
|
|
1262
|
-
handleCopyElements:
|
|
1263
|
-
handlePasteElements:
|
|
1264
|
-
fontSize:
|
|
1265
|
-
fontColor:
|
|
1266
|
-
fontFamily:
|
|
1267
|
-
textAlign:
|
|
1268
|
-
updateFontSize:
|
|
1269
|
-
setFontSizeValue:
|
|
1270
|
-
updateFontColor:
|
|
1271
|
-
updateFontFamily:
|
|
1272
|
-
updateTextAlign:
|
|
1267
|
+
getElementById: w,
|
|
1268
|
+
handleAddElement: Ot,
|
|
1269
|
+
handleElementUpdate: it,
|
|
1270
|
+
handleLoadWorkspace: Ht,
|
|
1271
|
+
handleCopyElements: zt,
|
|
1272
|
+
handlePasteElements: Ut,
|
|
1273
|
+
fontSize: St,
|
|
1274
|
+
fontColor: Rt,
|
|
1275
|
+
fontFamily: It,
|
|
1276
|
+
textAlign: Tt,
|
|
1277
|
+
updateFontSize: Ct,
|
|
1278
|
+
setFontSizeValue: Ft,
|
|
1279
|
+
updateFontColor: vt,
|
|
1280
|
+
updateFontFamily: Pt,
|
|
1281
|
+
updateTextAlign: Nt,
|
|
1273
1282
|
canvasRef: o,
|
|
1274
1283
|
canvasEditorRef: n
|
|
1275
1284
|
},
|
|
1276
1285
|
children: /* @__PURE__ */ V(
|
|
1277
|
-
|
|
1286
|
+
yo,
|
|
1278
1287
|
{
|
|
1279
1288
|
value: {
|
|
1280
|
-
executeElementUpdate:
|
|
1289
|
+
executeElementUpdate: $,
|
|
1281
1290
|
executeAddElement: W,
|
|
1282
|
-
executeRemoveElement:
|
|
1283
|
-
executeReorderElement:
|
|
1284
|
-
executeCommandBatch:
|
|
1291
|
+
executeRemoveElement: u,
|
|
1292
|
+
executeReorderElement: g,
|
|
1293
|
+
executeCommandBatch: b,
|
|
1285
1294
|
executeCreateArtboard: A,
|
|
1286
|
-
executeDeleteArtboard:
|
|
1295
|
+
executeDeleteArtboard: F,
|
|
1287
1296
|
executeUpdateArtboard: Y,
|
|
1288
1297
|
undo: z,
|
|
1289
|
-
redo:
|
|
1298
|
+
redo: _,
|
|
1290
1299
|
canUndo: U,
|
|
1291
1300
|
canRedo: L,
|
|
1292
1301
|
undoActiveArtboard: P,
|
|
1293
1302
|
redoActiveArtboard: K,
|
|
1294
|
-
canUndoActiveArtboard:
|
|
1303
|
+
canUndoActiveArtboard: nt,
|
|
1295
1304
|
canRedoActiveArtboard: Z,
|
|
1296
|
-
historyManager:
|
|
1305
|
+
historyManager: ot
|
|
1297
1306
|
},
|
|
1298
|
-
children: /* @__PURE__ */ V(
|
|
1307
|
+
children: /* @__PURE__ */ V(fe.Provider, { value: Mt, children: e })
|
|
1299
1308
|
}
|
|
1300
1309
|
)
|
|
1301
1310
|
}
|
|
1302
1311
|
)
|
|
1303
1312
|
}
|
|
1304
1313
|
) });
|
|
1305
|
-
},
|
|
1314
|
+
}, Wo = ({
|
|
1306
1315
|
children: e,
|
|
1307
1316
|
initialArtboardConfig: t = {},
|
|
1308
1317
|
viewPadding: o = 0.9
|
|
1309
1318
|
}) => {
|
|
1310
|
-
const [n] =
|
|
1311
|
-
const a = new
|
|
1319
|
+
const [n] = S(() => {
|
|
1320
|
+
const a = new De(), s = {
|
|
1312
1321
|
name: t.name || "Artboard 1",
|
|
1313
1322
|
x: t.x ?? 0,
|
|
1314
1323
|
y: t.y ?? 0,
|
|
1315
1324
|
width: t.width ?? 1e3,
|
|
1316
1325
|
height: t.height ?? 1e3,
|
|
1317
|
-
backgroundColor: t.backgroundColor ||
|
|
1326
|
+
backgroundColor: t.backgroundColor || ke
|
|
1318
1327
|
};
|
|
1319
1328
|
return a.createArtboard(s), a;
|
|
1320
|
-
}), i =
|
|
1329
|
+
}), i = At(null), r = At(null);
|
|
1321
1330
|
return /* @__PURE__ */ V(
|
|
1322
|
-
|
|
1331
|
+
lo,
|
|
1323
1332
|
{
|
|
1324
1333
|
artboardManager: n,
|
|
1325
1334
|
canvasRef: i,
|
|
1326
1335
|
viewPadding: o,
|
|
1327
|
-
children: /* @__PURE__ */ V(
|
|
1328
|
-
|
|
1336
|
+
children: /* @__PURE__ */ V(ho, { children: /* @__PURE__ */ V(po, { children: /* @__PURE__ */ V(
|
|
1337
|
+
wo,
|
|
1329
1338
|
{
|
|
1330
1339
|
artboardManager: n,
|
|
1331
1340
|
canvasRef: i,
|
|
@@ -1335,24 +1344,24 @@ const yo = Qt("EditorContext"), me = Q(null), fe = Q(null), Bo = () => {
|
|
|
1335
1344
|
) }) })
|
|
1336
1345
|
}
|
|
1337
1346
|
);
|
|
1338
|
-
},
|
|
1339
|
-
const e = G(
|
|
1347
|
+
}, Yo = () => {
|
|
1348
|
+
const e = G(fe);
|
|
1340
1349
|
if (!e)
|
|
1341
1350
|
throw new Error("useEditor must be used within EditorProvider");
|
|
1342
1351
|
return e;
|
|
1343
1352
|
}, ut = [];
|
|
1344
|
-
function
|
|
1345
|
-
|
|
1353
|
+
function Xo(e) {
|
|
1354
|
+
Be() && ut.push(e);
|
|
1346
1355
|
}
|
|
1347
|
-
function
|
|
1356
|
+
function Go() {
|
|
1348
1357
|
return [...ut];
|
|
1349
1358
|
}
|
|
1350
|
-
function
|
|
1359
|
+
function Ko() {
|
|
1351
1360
|
ut.length = 0;
|
|
1352
1361
|
}
|
|
1353
|
-
function
|
|
1362
|
+
function Zo() {
|
|
1354
1363
|
if (ut.length === 0) return;
|
|
1355
|
-
const e = ut.map((t) =>
|
|
1364
|
+
const e = ut.map((t) => $e(t) ? `${t.code}: ${t.message}` : `${t.name}: ${t.message}`).join(`
|
|
1356
1365
|
- `);
|
|
1357
1366
|
throw ut.length = 0, new Error(
|
|
1358
1367
|
`expectNoEditorErrors: ${e.includes(`
|
|
@@ -1361,36 +1370,36 @@ function Ko() {
|
|
|
1361
1370
|
A contained error renders an error card in prod — this composition is broken even if the test rendered "successfully".`
|
|
1362
1371
|
);
|
|
1363
1372
|
}
|
|
1364
|
-
const
|
|
1365
|
-
function
|
|
1373
|
+
const bo = 1;
|
|
1374
|
+
function rt(e) {
|
|
1366
1375
|
return typeof e == "number" && Number.isFinite(e) ? Math.round(e * 100) / 100 : e;
|
|
1367
1376
|
}
|
|
1368
|
-
function
|
|
1377
|
+
function ge(e) {
|
|
1369
1378
|
return {
|
|
1370
1379
|
...e,
|
|
1371
|
-
...e.x !== void 0 && { x:
|
|
1372
|
-
...e.y !== void 0 && { y:
|
|
1373
|
-
...e.width !== void 0 && { width:
|
|
1374
|
-
...e.height !== void 0 && { height:
|
|
1375
|
-
...e.rotation !== void 0 && { rotation:
|
|
1380
|
+
...e.x !== void 0 && { x: rt(e.x) },
|
|
1381
|
+
...e.y !== void 0 && { y: rt(e.y) },
|
|
1382
|
+
...e.width !== void 0 && { width: rt(e.width) },
|
|
1383
|
+
...e.height !== void 0 && { height: rt(e.height) },
|
|
1384
|
+
...e.rotation !== void 0 && { rotation: rt(e.rotation) }
|
|
1376
1385
|
};
|
|
1377
1386
|
}
|
|
1378
|
-
function
|
|
1387
|
+
function Eo(e) {
|
|
1379
1388
|
var n, i;
|
|
1380
1389
|
const t = (n = e.artboards) != null && n.length ? e.artboards : [{ name: "Front", width: 800, height: 800 }], o = t.map(() => []);
|
|
1381
1390
|
for (const r of e.elements || []) {
|
|
1382
1391
|
const a = r == null ? void 0 : r.artboard, s = typeof a == "string" ? t.findIndex((c) => (c.name || "Front") === a) : -1;
|
|
1383
|
-
(r == null ? void 0 : r.visible) !== !1 && o[s >= 0 ? s : 0].push(
|
|
1392
|
+
(r == null ? void 0 : r.visible) !== !1 && o[s >= 0 ? s : 0].push(Ae(r));
|
|
1384
1393
|
}
|
|
1385
1394
|
return {
|
|
1386
|
-
schemaVersion:
|
|
1395
|
+
schemaVersion: bo,
|
|
1387
1396
|
artboards: t.map((r, a) => ({
|
|
1388
1397
|
id: `artboard-${a + 1}`,
|
|
1389
1398
|
name: r.name || "Front",
|
|
1390
1399
|
x: 0,
|
|
1391
1400
|
y: 0,
|
|
1392
|
-
width:
|
|
1393
|
-
height:
|
|
1401
|
+
width: rt(r.width || 800),
|
|
1402
|
+
height: rt(r.height || 800),
|
|
1394
1403
|
backgroundColor: r.backgroundColor || "transparent",
|
|
1395
1404
|
// Pass the artboard's flag through — the server worker only paints the
|
|
1396
1405
|
// background when this is true. Hardcoding `false` here silently dropped
|
|
@@ -1407,19 +1416,19 @@ function bo(e) {
|
|
|
1407
1416
|
...(i = e.customFonts) != null && i.length ? { customFonts: e.customFonts } : {}
|
|
1408
1417
|
};
|
|
1409
1418
|
}
|
|
1410
|
-
function
|
|
1419
|
+
function Ae(e) {
|
|
1411
1420
|
const t = e.type || e.transformType;
|
|
1412
1421
|
if (t === "image")
|
|
1413
|
-
return
|
|
1422
|
+
return So(e);
|
|
1414
1423
|
const { artboard: o, ...n } = e;
|
|
1415
|
-
return t === "group" && Array.isArray(e.children) && (n.children = e.children.filter((i) => i && i.visible !== !1).map(
|
|
1424
|
+
return t === "group" && Array.isArray(e.children) && (n.children = e.children.filter((i) => i && i.visible !== !1).map(Ae)), ge({
|
|
1416
1425
|
...n,
|
|
1417
1426
|
type: t
|
|
1418
1427
|
});
|
|
1419
1428
|
}
|
|
1420
|
-
function
|
|
1429
|
+
function So(e) {
|
|
1421
1430
|
var d;
|
|
1422
|
-
const t = e.transformData || {}, o =
|
|
1431
|
+
const t = e.transformData || {}, o = Me(e), n = We(t, o), i = t.width || 0, r = t.height || 0, a = i * n.cropWidth, s = r * n.cropHeight, c = {
|
|
1423
1432
|
id: e.id,
|
|
1424
1433
|
type: "image",
|
|
1425
1434
|
x: e.x || 0,
|
|
@@ -1430,44 +1439,44 @@ function Eo(e) {
|
|
|
1430
1439
|
imageUrl: e.imageUrl,
|
|
1431
1440
|
imageAspectRatio: e.imageAspectRatio
|
|
1432
1441
|
};
|
|
1433
|
-
return
|
|
1442
|
+
return Ye(n) || (c.cropX = n.cropX, c.cropY = n.cropY, c.cropWidth = n.cropWidth, c.cropHeight = n.cropHeight, c.needsCropPixelConversion = !0), t.flipHorizontal && (c.flipHorizontal = t.flipHorizontal), t.flipVertical && (c.flipVertical = t.flipVertical), t.borderRadius && (c.borderRadius = t.borderRadius), e.shadow && (c.shadow = e.shadow), Xe(t.adjustments) || (c.adjustments = { ...t.adjustments }), e.opacity !== void 0 && (c.opacity = e.opacity), e.distressEffect && (c.distressEffect = e.distressEffect), ((d = e.masks) == null ? void 0 : d.length) > 0 && (c.masks = e.masks), e.blendMode && (c.blendMode = e.blendMode), e.knockoutParts && (c.knockoutParts = e.knockoutParts), e.stroke && (c.stroke = e.stroke), ge(c);
|
|
1434
1443
|
}
|
|
1435
|
-
const
|
|
1436
|
-
function
|
|
1437
|
-
return typeof e == "object" && e !== null && e[
|
|
1444
|
+
const qt = "center", ye = Symbol.for("snowcone.canvas.layerToken");
|
|
1445
|
+
function jo(e) {
|
|
1446
|
+
return typeof e == "object" && e !== null && e[ye] === !0 && typeof e.name == "string" && (e.kind === "text" || e.kind === "image");
|
|
1438
1447
|
}
|
|
1439
|
-
function
|
|
1440
|
-
return Object.freeze({ kind: e, name: t, [
|
|
1448
|
+
function Ro(e, t) {
|
|
1449
|
+
return Object.freeze({ kind: e, name: t, [ye]: !0 });
|
|
1441
1450
|
}
|
|
1442
|
-
const
|
|
1443
|
-
function
|
|
1444
|
-
return typeof e == "object" && e !== null && e[
|
|
1451
|
+
const xe = Symbol.for("snowcone.canvas.colorToken");
|
|
1452
|
+
function Io(e) {
|
|
1453
|
+
return typeof e == "object" && e !== null && e[xe] === !0 && typeof e.name == "string" && typeof e.value == "string";
|
|
1445
1454
|
}
|
|
1446
|
-
function
|
|
1447
|
-
return Object.freeze({ name: e, value: t, [
|
|
1455
|
+
function To(e, t) {
|
|
1456
|
+
return Object.freeze({ name: e, value: t, [xe]: !0 });
|
|
1448
1457
|
}
|
|
1449
|
-
function
|
|
1458
|
+
function Co(e) {
|
|
1450
1459
|
let t = e.trim().toUpperCase();
|
|
1451
1460
|
return /^#[0-9A-F]{3}$/.test(t) && (t = "#" + t[1] + t[1] + t[2] + t[2] + t[3] + t[3]), /^#[0-9A-F]{6}$/.test(t) ? t : null;
|
|
1452
1461
|
}
|
|
1453
|
-
function
|
|
1454
|
-
return
|
|
1462
|
+
function Et(e) {
|
|
1463
|
+
return Io(e) ? e.value : e;
|
|
1455
1464
|
}
|
|
1456
|
-
function
|
|
1465
|
+
function $t(e) {
|
|
1457
1466
|
const t = e.transformType;
|
|
1458
1467
|
return t === "image" ? "image" : t === "shape" || t === "group" || t === "path" ? null : "text";
|
|
1459
1468
|
}
|
|
1460
|
-
function
|
|
1469
|
+
function Fo(e) {
|
|
1461
1470
|
return e === "top-left" || e === "left" || e === "bottom-left" ? "left" : e === "top-right" || e === "right" || e === "bottom-right" ? "right" : "center";
|
|
1462
1471
|
}
|
|
1463
|
-
function
|
|
1472
|
+
function vo(e) {
|
|
1464
1473
|
return e === "top-left" || e === "top" || e === "top-right" ? "top" : e === "bottom-left" || e === "bottom" || e === "bottom-right" ? "bottom" : "middle";
|
|
1465
1474
|
}
|
|
1466
|
-
function
|
|
1467
|
-
const a =
|
|
1475
|
+
function Vt(e, t, o, n, i, r) {
|
|
1476
|
+
const a = Fo(e), s = vo(e), c = a === "left" ? t / 2 + r : a === "right" ? n - t / 2 - r : n / 2, d = s === "top" ? o / 2 + r : s === "bottom" ? i - o / 2 - r : i / 2;
|
|
1468
1477
|
return { x: c, y: d };
|
|
1469
1478
|
}
|
|
1470
|
-
function
|
|
1479
|
+
function Po(e, t, o) {
|
|
1471
1480
|
const n = t / o;
|
|
1472
1481
|
if (e >= n) {
|
|
1473
1482
|
const a = o * e, s = t / a;
|
|
@@ -1495,16 +1504,16 @@ class lt {
|
|
|
1495
1504
|
if (this.els = [], this.colorRoles = /* @__PURE__ */ new Map(), this.idCounter = 0, !(t.width > 0) || !(t.height > 0))
|
|
1496
1505
|
throw new Error("design(): artboard width and height must be positive numbers");
|
|
1497
1506
|
for (const [o, n] of Object.entries(t.colors ?? {})) {
|
|
1498
|
-
const i =
|
|
1507
|
+
const i = Co(n);
|
|
1499
1508
|
if (i === null)
|
|
1500
|
-
throw new
|
|
1509
|
+
throw new et(
|
|
1501
1510
|
"E_COLOR_ROLE_INVALID",
|
|
1502
1511
|
`color role "${o}" is ${JSON.stringify(n)} — roles must be #RGB/#RRGGBB hex (useColorBinding matches by normalized hex value; other syntaxes can't bind).`,
|
|
1503
1512
|
{ roleName: o, value: n, docSlug: "embed-mode" }
|
|
1504
1513
|
);
|
|
1505
1514
|
const r = [...this.colorRoles.entries()].find(([, a]) => a === i);
|
|
1506
1515
|
if (r)
|
|
1507
|
-
throw new
|
|
1516
|
+
throw new et(
|
|
1508
1517
|
"E_COLOR_ROLE_COLLISION",
|
|
1509
1518
|
`color roles "${r[0]}" and "${o}" both normalize to ${i}. useColorBinding matches elements by VALUE, so colliding roles would repaint each other's elements — give every role a distinct hex.`,
|
|
1510
1519
|
{ roles: [r[0], o], value: i, docSlug: "embed-mode" }
|
|
@@ -1515,7 +1524,7 @@ class lt {
|
|
|
1515
1524
|
name: t.name || "Front",
|
|
1516
1525
|
width: t.width,
|
|
1517
1526
|
height: t.height,
|
|
1518
|
-
backgroundColor:
|
|
1527
|
+
backgroundColor: Et(t.backgroundColor),
|
|
1519
1528
|
role: t.role
|
|
1520
1529
|
}, this.activeName = this.current.name;
|
|
1521
1530
|
}
|
|
@@ -1598,7 +1607,7 @@ class lt {
|
|
|
1598
1607
|
if (!(o.width > 0) || !(o.height > 0))
|
|
1599
1608
|
throw new Error("design().artboard(): width and height must be positive numbers");
|
|
1600
1609
|
if (this.allArtboards || (this.allArtboards = [lt.snapshotArtboard(this.current)]), this.allArtboards.some((n) => n.name === t))
|
|
1601
|
-
throw new
|
|
1610
|
+
throw new et(
|
|
1602
1611
|
"E_DUPLICATE_ARTBOARD",
|
|
1603
1612
|
`the design already has an artboard "${t}" — artboard names are placement labels and must be unique. Existing: ${JSON.stringify(this.allArtboards.map((n) => n.name))}.`,
|
|
1604
1613
|
{ artboardName: t, validNames: this.allArtboards.map((n) => n.name), docSlug: "embed-mode" }
|
|
@@ -1609,7 +1618,7 @@ class lt {
|
|
|
1609
1618
|
name: t,
|
|
1610
1619
|
width: o.width,
|
|
1611
1620
|
height: o.height,
|
|
1612
|
-
backgroundColor:
|
|
1621
|
+
backgroundColor: Et(o.backgroundColor),
|
|
1613
1622
|
role: o.role
|
|
1614
1623
|
}, this.allArtboards.push(lt.snapshotArtboard(this.current)), this;
|
|
1615
1624
|
}
|
|
@@ -1617,7 +1626,7 @@ class lt {
|
|
|
1617
1626
|
const { width: n, height: i } = this.current;
|
|
1618
1627
|
let r;
|
|
1619
1628
|
if (o.aspectRatio && o.aspectRatio > 0) {
|
|
1620
|
-
const s =
|
|
1629
|
+
const s = Po(o.aspectRatio, n, i);
|
|
1621
1630
|
r = {
|
|
1622
1631
|
type: "image",
|
|
1623
1632
|
width: s.width,
|
|
@@ -1658,7 +1667,7 @@ class lt {
|
|
|
1658
1667
|
return this.els.unshift(a), this;
|
|
1659
1668
|
}
|
|
1660
1669
|
image(t, o = {}) {
|
|
1661
|
-
const { width: n, height: i } = this.current, r = o.width ?? Math.round(n / 3), a = o.height ?? (o.aspectRatio ? Math.round(r / o.aspectRatio) : r), { x: s, y: c } =
|
|
1670
|
+
const { width: n, height: i } = this.current, r = o.width ?? Math.round(n / 3), a = o.height ?? (o.aspectRatio ? Math.round(r / o.aspectRatio) : r), { x: s, y: c } = Vt(o.anchor ?? qt, r, a, n, i, o.padding ?? 0), d = {
|
|
1662
1671
|
id: this.nextId("img"),
|
|
1663
1672
|
transformType: "image",
|
|
1664
1673
|
x: s,
|
|
@@ -1684,7 +1693,7 @@ class lt {
|
|
|
1684
1693
|
return this.els.push(d), this;
|
|
1685
1694
|
}
|
|
1686
1695
|
text(t, o = {}) {
|
|
1687
|
-
const { width: n, height: i } = this.current, r = o.fontSize ?? Math.round(this.current.height / 12), { x: a, y: s } =
|
|
1696
|
+
const { width: n, height: i } = this.current, r = o.fontSize ?? Math.round(this.current.height / 12), { x: a, y: s } = Vt(o.anchor ?? "top", 0, r, n, i, o.padding ?? Math.round(i / 20)), c = {
|
|
1688
1697
|
id: this.nextId("text"),
|
|
1689
1698
|
transformType: "custom",
|
|
1690
1699
|
x: a,
|
|
@@ -1693,7 +1702,7 @@ class lt {
|
|
|
1693
1702
|
text: t,
|
|
1694
1703
|
fontSize: r,
|
|
1695
1704
|
fontFamily: o.fontFamily ?? "Anton",
|
|
1696
|
-
color:
|
|
1705
|
+
color: Et(o.color) ?? "#ffffff",
|
|
1697
1706
|
textAlign: o.textAlign ?? "center",
|
|
1698
1707
|
bold: o.bold ?? !1,
|
|
1699
1708
|
italic: o.italic ?? !1,
|
|
@@ -1719,20 +1728,20 @@ class lt {
|
|
|
1719
1728
|
const o = this.els.find((i) => i.name === t);
|
|
1720
1729
|
if (!o) {
|
|
1721
1730
|
const i = this.layerNamesOfKind("text"), r = this.layerNamesOfKind("image");
|
|
1722
|
-
throw new
|
|
1731
|
+
throw new et(
|
|
1723
1732
|
"E_LAYER_NOT_FOUND",
|
|
1724
1733
|
`no layer "${t}" in this design. Text layers: ${JSON.stringify(i)}; image layers: ${JSON.stringify(r)}. Fix the name, or add the layer first — e.g. design(…).text('…', { name: '${t}' }).`,
|
|
1725
1734
|
{ layerName: t, validNames: [...i, ...r], textNames: i, imageNames: r, docSlug: "embed-mode" }
|
|
1726
1735
|
);
|
|
1727
1736
|
}
|
|
1728
|
-
const n =
|
|
1737
|
+
const n = $t(o);
|
|
1729
1738
|
if (!n)
|
|
1730
|
-
throw new
|
|
1739
|
+
throw new et(
|
|
1731
1740
|
"E_LAYER_WRONG_KIND",
|
|
1732
1741
|
`layer "${t}" is a ${o.transformType} element — only text and image layers are bindable. Bindable layers: ${JSON.stringify([...this.layerNamesOfKind("text"), ...this.layerNamesOfKind("image")])}.`,
|
|
1733
1742
|
{ layerName: t, actualType: o.transformType, docSlug: "embed-mode" }
|
|
1734
1743
|
);
|
|
1735
|
-
return
|
|
1744
|
+
return Ro(n, t);
|
|
1736
1745
|
}
|
|
1737
1746
|
/**
|
|
1738
1747
|
* Mint a {@link ColorToken} for a declared color role. Compile time: `name`
|
|
@@ -1750,25 +1759,25 @@ class lt {
|
|
|
1750
1759
|
color(t) {
|
|
1751
1760
|
const o = this.colorRoles.get(t);
|
|
1752
1761
|
if (o === void 0)
|
|
1753
|
-
throw new
|
|
1762
|
+
throw new et(
|
|
1754
1763
|
"E_COLOR_ROLE_NOT_FOUND",
|
|
1755
1764
|
`no color role "${t}" in this design. Declared roles: ${JSON.stringify([...this.colorRoles.keys()])}. Declare roles up front — design({ …, colors: { ${t}: '#FF2D8A' } }).`,
|
|
1756
1765
|
{ roleName: t, validNames: [...this.colorRoles.keys()], docSlug: "embed-mode" }
|
|
1757
1766
|
);
|
|
1758
|
-
return
|
|
1767
|
+
return To(t, o);
|
|
1759
1768
|
}
|
|
1760
1769
|
/** Names of bindable layers of one kind, in stack order. @internal */
|
|
1761
1770
|
layerNamesOfKind(t) {
|
|
1762
|
-
return this.els.filter((o) =>
|
|
1771
|
+
return this.els.filter((o) => $t(o) === t).map((o) => o.name).filter((o) => !!o);
|
|
1763
1772
|
}
|
|
1764
1773
|
/** An anchored vector shape. */
|
|
1765
1774
|
shape(t, o = {}) {
|
|
1766
|
-
const { width: n, height: i } = this.current, r = o.size ?? Math.round(n / 6), a = typeof r == "number" ? r : r.width, s = typeof r == "number" ? r : r.height, { x: c, y: d } =
|
|
1775
|
+
const { width: n, height: i } = this.current, r = o.size ?? Math.round(n / 6), a = typeof r == "number" ? r : r.width, s = typeof r == "number" ? r : r.height, { x: c, y: d } = Vt(o.anchor ?? qt, a, s, n, i, o.padding ?? 0), R = {
|
|
1767
1776
|
type: "shape",
|
|
1768
1777
|
shapeType: t,
|
|
1769
1778
|
width: a,
|
|
1770
1779
|
height: s,
|
|
1771
|
-
fillColor:
|
|
1780
|
+
fillColor: Et(o.fill) ?? "#000000",
|
|
1772
1781
|
fillOpacity: o.opacity ?? 1,
|
|
1773
1782
|
...o.points !== void 0 ? { points: o.points } : {},
|
|
1774
1783
|
...o.sides !== void 0 ? { sides: o.sides } : {}
|
|
@@ -1778,7 +1787,7 @@ class lt {
|
|
|
1778
1787
|
x: c,
|
|
1779
1788
|
y: d,
|
|
1780
1789
|
rotation: o.rotation ?? 0,
|
|
1781
|
-
transformData:
|
|
1790
|
+
transformData: R,
|
|
1782
1791
|
...o.name ? { name: o.name } : {}
|
|
1783
1792
|
};
|
|
1784
1793
|
return this.els.push(N), this;
|
|
@@ -1815,47 +1824,47 @@ class lt {
|
|
|
1815
1824
|
/** Server-render payload for `RenderSession.renderState(placement, …)`.
|
|
1816
1825
|
* Equivalent to `serializeStateForServer(design.toJSON())`. */
|
|
1817
1826
|
toServerRequest() {
|
|
1818
|
-
return
|
|
1827
|
+
return Eo(this.toJSON());
|
|
1819
1828
|
}
|
|
1820
1829
|
}
|
|
1821
|
-
function
|
|
1830
|
+
function Jo(e) {
|
|
1822
1831
|
return new lt(e);
|
|
1823
1832
|
}
|
|
1824
|
-
function
|
|
1825
|
-
return
|
|
1833
|
+
function qo(e) {
|
|
1834
|
+
return $t(e);
|
|
1826
1835
|
}
|
|
1827
1836
|
export {
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1837
|
+
Do as A,
|
|
1838
|
+
ne as B,
|
|
1839
|
+
bo as C,
|
|
1831
1840
|
lt as D,
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1841
|
+
Wo as E,
|
|
1842
|
+
re as P,
|
|
1843
|
+
Bo as a,
|
|
1844
|
+
Yo as b,
|
|
1845
|
+
mo as c,
|
|
1846
|
+
ae as d,
|
|
1847
|
+
uo as e,
|
|
1848
|
+
Jo as f,
|
|
1849
|
+
Zo as g,
|
|
1850
|
+
Go as h,
|
|
1851
|
+
Vo as i,
|
|
1852
|
+
Lo as j,
|
|
1853
|
+
qo as k,
|
|
1854
|
+
se as l,
|
|
1855
|
+
jo as m,
|
|
1856
|
+
Io as n,
|
|
1857
|
+
ko as o,
|
|
1858
|
+
so as p,
|
|
1859
|
+
je as q,
|
|
1860
|
+
Ko as r,
|
|
1861
|
+
Eo as s,
|
|
1862
|
+
_o as t,
|
|
1863
|
+
$o as u,
|
|
1864
|
+
go as v,
|
|
1865
|
+
Xo as w,
|
|
1866
|
+
Ho as x,
|
|
1867
|
+
Mo as y,
|
|
1868
|
+
Je as z
|
|
1860
1869
|
};
|
|
1861
|
-
//# sourceMappingURL=design-builder-
|
|
1870
|
+
//# sourceMappingURL=design-builder-sH53Og6j.js.map
|