@snowcone-app/canvas 0.41.4 → 0.41.5
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-JcBrIZ6I.js → CanvasRenderer-3M-52sAd.js} +4 -4
- package/dist/{CanvasRenderer-JcBrIZ6I.js.map → CanvasRenderer-3M-52sAd.js.map} +1 -1
- package/dist/{CanvasStateV1-BJ5-75NN.js → CanvasStateV1-C9tFMK5q.js} +3 -3
- package/dist/{CanvasStateV1-BJ5-75NN.js.map → CanvasStateV1-C9tFMK5q.js.map} +1 -1
- package/dist/{ContextualToolbars-wmbHxn5a.js → ContextualToolbars-B2LTNu7r.js} +358 -358
- package/dist/{ContextualToolbars-wmbHxn5a.js.map → ContextualToolbars-B2LTNu7r.js.map} +1 -1
- package/dist/{EditorCanvasImpl-CSDnCIpN.js → EditorCanvasImpl-CKqnla_y.js} +26 -26
- package/dist/EditorCanvasImpl-CKqnla_y.js.map +1 -0
- package/dist/{ExportManager-CHlByUYV.js → ExportManager-9_RjQEv0.js} +2 -2
- package/dist/{ExportManager-CHlByUYV.js.map → ExportManager-9_RjQEv0.js.map} +1 -1
- package/dist/{FontAnalyzer-Bj2KrX80.js → FontAnalyzer-Ch1jgTq7.js} +88 -68
- package/dist/FontAnalyzer-Ch1jgTq7.js.map +1 -0
- package/dist/ImagePanel-DY9Ve3X7.js +1016 -0
- package/dist/{ImagePanel-0ZwDDaCy.js.map → ImagePanel-DY9Ve3X7.js.map} +1 -1
- package/dist/SnowconeCanvas-BSFMazgl.js +1098 -0
- package/dist/SnowconeCanvas-BSFMazgl.js.map +1 -0
- package/dist/advanced.mjs +44 -44
- package/dist/api/stable.d.ts +1 -1
- package/dist/components/embed/SnowconeCanvas.d.ts +15 -0
- package/dist/components/embed/kernel.d.ts +3 -1
- package/dist/core/ArtboardElement.d.ts +2 -0
- package/dist/core/ArtboardManager.d.ts +11 -0
- package/dist/{custom-icons-up58ZbC9.js → custom-icons-D_XezOul.js} +2 -2
- package/dist/{custom-icons-up58ZbC9.js.map → custom-icons-D_XezOul.js.map} +1 -1
- package/dist/design-builder-BFM94eA9.js +1859 -0
- package/dist/design-builder-BFM94eA9.js.map +1 -0
- package/dist/{embed-GXevsHX5.js → embed-KG_YnRHA.js} +10 -10
- package/dist/{embed-GXevsHX5.js.map → embed-KG_YnRHA.js.map} +1 -1
- package/dist/embed.mjs +12 -12
- package/dist/{guards-CQeF53PN.js → guards-D_mw4DgS.js} +2 -2
- package/dist/{guards-CQeF53PN.js.map → guards-D_mw4DgS.js.map} +1 -1
- package/dist/index.mjs +9 -9
- package/dist/internals.mjs +6 -6
- package/dist/{placement-D31o3YYC.js → placement-tSiIVhrL.js} +3 -3
- package/dist/{placement-D31o3YYC.js.map → placement-tSiIVhrL.js.map} +1 -1
- package/dist/placement.mjs +2 -2
- package/dist/{template-fields-tobyHoMe.js → template-fields-C0qoE_ZH.js} +32 -32
- package/dist/{template-fields-tobyHoMe.js.map → template-fields-C0qoE_ZH.js.map} +1 -1
- package/dist/testing.mjs +3 -3
- package/dist/{useCommands-Cm3mDB-l.js → useCommands-DSapP-w1.js} +7 -7
- package/dist/{useCommands-Cm3mDB-l.js.map → useCommands-DSapP-w1.js.map} +1 -1
- package/dist/{usePieceGuideBundle-BTnUn33k.js → usePieceGuideBundle-oBykb3X8.js} +2 -2
- package/dist/{usePieceGuideBundle-BTnUn33k.js.map → usePieceGuideBundle-oBykb3X8.js.map} +1 -1
- package/dist/utils/newImagePlacement.d.ts +56 -0
- package/dist/{validation-D4zxugNJ.js → validation-D6zVSeTh.js} +307 -307
- package/dist/{validation-D4zxugNJ.js.map → validation-D6zVSeTh.js.map} +1 -1
- package/dist/vendor/ui/primitives/badge.d.ts +1 -1
- package/dist/vendor/ui/primitives/link.d.ts +1 -1
- package/dist/vendor/ui/primitives/spinner.d.ts +1 -1
- package/example/package.json +1 -1
- package/package.json +1 -1
- package/dist/EditorCanvasImpl-CSDnCIpN.js.map +0 -1
- package/dist/FontAnalyzer-Bj2KrX80.js.map +0 -1
- package/dist/ImagePanel-0ZwDDaCy.js +0 -984
- package/dist/SnowconeCanvas-BZk7PRpk.js +0 -1215
- package/dist/SnowconeCanvas-BZk7PRpk.js.map +0 -1
- package/dist/design-builder-DUEwCUmA.js +0 -1676
- package/dist/design-builder-DUEwCUmA.js.map +0 -1
|
@@ -1,1676 +0,0 @@
|
|
|
1
|
-
import { jsx as k } from "react/jsx-runtime";
|
|
2
|
-
import { useContext as Y, useSyncExternalStore as Ae, useCallback as m, createContext as Q, useRef as pt, useState as b, useEffect as Dt, useMemo as q } from "react";
|
|
3
|
-
import { H as ye, t as ot, U as ge, B as xe, G as jt, R as be, D as we, J as Ee, K as Se, M as Re, c as Zt, z as Ie, N as Ce, O as Te, Q as Oe, e as ve, E as Wt, I as Fe, q as Pe, S as Ne, V as ze, X as Mt, Y as He, Z as ke, _ as Ue, $ as Ve, a0 as De, i as _e } from "./FontAnalyzer-Bj2KrX80.js";
|
|
4
|
-
const Jt = Q(null), Le = () => () => {
|
|
5
|
-
}, Yt = () => 0;
|
|
6
|
-
function wo() {
|
|
7
|
-
const e = Y(Jt), t = Ae(
|
|
8
|
-
e ? e.subscribe : Le,
|
|
9
|
-
e ? e.getVersion : Yt,
|
|
10
|
-
e ? e.getVersion : Yt
|
|
11
|
-
);
|
|
12
|
-
return m(
|
|
13
|
-
(o) => !!(e && o && e.getBoundLayer(o)),
|
|
14
|
-
// `version` is the reactivity key: a registry change must mint a new
|
|
15
|
-
// callback so memoized consumers re-evaluate.
|
|
16
|
-
[e, t]
|
|
17
|
-
);
|
|
18
|
-
}
|
|
19
|
-
const gt = Zt("useCommandHistory");
|
|
20
|
-
function $e(e, t, o, n) {
|
|
21
|
-
const s = pt(new ye(o)), r = Y(Jt), c = m(
|
|
22
|
-
(l, f) => {
|
|
23
|
-
const g = l == null ? void 0 : l.name;
|
|
24
|
-
if (!r || !g) return;
|
|
25
|
-
const y = r.getBoundLayer(g);
|
|
26
|
-
if (y)
|
|
27
|
-
throw new ot(
|
|
28
|
-
"E_BOUND_LAYER_MUTATION",
|
|
29
|
-
`cannot ${f} layer "${g}" — a mounted <${y.part} layer={design.layer("${g}")}> is bound to it. Unmount that field first, or keep the layer and set its text through the field / its binding instead.`,
|
|
30
|
-
{ layer: g, part: y.part, operation: f, docSlug: "embed-mode" }
|
|
31
|
-
);
|
|
32
|
-
},
|
|
33
|
-
[r]
|
|
34
|
-
), [i, a] = b({
|
|
35
|
-
canUndo: !1,
|
|
36
|
-
canRedo: !1,
|
|
37
|
-
// Per-artboard state for the active artboard
|
|
38
|
-
canUndoActiveArtboard: !1,
|
|
39
|
-
canRedoActiveArtboard: !1
|
|
40
|
-
}), d = m(() => {
|
|
41
|
-
const l = s.current, f = o.getActiveArtboardId();
|
|
42
|
-
a({
|
|
43
|
-
canUndo: l.canUndo(),
|
|
44
|
-
canRedo: l.canRedo(),
|
|
45
|
-
// Per-artboard state - only check active artboard's history
|
|
46
|
-
canUndoActiveArtboard: f ? l.canUndoArtboard(f) : !1,
|
|
47
|
-
canRedoActiveArtboard: f ? l.canRedoArtboard(f) : !1
|
|
48
|
-
});
|
|
49
|
-
}, [o]), z = m(
|
|
50
|
-
(l, f) => {
|
|
51
|
-
l && l.name !== f.name && c(l, "rename");
|
|
52
|
-
const g = new ge(
|
|
53
|
-
f.id,
|
|
54
|
-
l || null,
|
|
55
|
-
f,
|
|
56
|
-
(I) => {
|
|
57
|
-
t(($) => $.map((P) => P.id === I.id ? I : P));
|
|
58
|
-
}
|
|
59
|
-
), y = o.getArtboardIdForElement(f.id);
|
|
60
|
-
if (y)
|
|
61
|
-
s.current.executeOnArtboard(y, g);
|
|
62
|
-
else {
|
|
63
|
-
const I = o.getActiveArtboardId();
|
|
64
|
-
I && s.current.executeOnArtboard(I, g);
|
|
65
|
-
}
|
|
66
|
-
d();
|
|
67
|
-
},
|
|
68
|
-
[t, o, d, c]
|
|
69
|
-
), F = m(
|
|
70
|
-
(l, f, g, y) => {
|
|
71
|
-
const I = f || o.getActiveArtboardId();
|
|
72
|
-
if (!I) {
|
|
73
|
-
gt.warn("No active artboard to add element to");
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
const $ = new xe(
|
|
77
|
-
l,
|
|
78
|
-
(P) => {
|
|
79
|
-
const U = P;
|
|
80
|
-
t((N) => {
|
|
81
|
-
if (y) {
|
|
82
|
-
const H = N.findIndex((O) => O.id === y);
|
|
83
|
-
if (H !== -1) {
|
|
84
|
-
const O = [...N];
|
|
85
|
-
return O.splice(H, 0, U), O;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
if (g) {
|
|
89
|
-
const H = N.findIndex((O) => O.id === g);
|
|
90
|
-
if (H !== -1) {
|
|
91
|
-
const O = [...N];
|
|
92
|
-
return O.splice(H + 1, 0, U), O;
|
|
93
|
-
}
|
|
94
|
-
for (let O = 0; O < N.length; O++) {
|
|
95
|
-
const X = N[O];
|
|
96
|
-
if (X instanceof jt && X.children) {
|
|
97
|
-
const rt = X.children.findIndex((K) => K.id === g);
|
|
98
|
-
if (rt !== -1) {
|
|
99
|
-
const K = X.clone();
|
|
100
|
-
K.children.splice(rt + 1, 0, U);
|
|
101
|
-
const G = [...N];
|
|
102
|
-
return G[O] = K, G;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
return [...N, U];
|
|
108
|
-
}), o.addElementToArtboard(P.id, I);
|
|
109
|
-
},
|
|
110
|
-
(P) => {
|
|
111
|
-
t((U) => U.filter((N) => N.id !== P)), o.removeElementFromArtboard(P);
|
|
112
|
-
}
|
|
113
|
-
);
|
|
114
|
-
s.current.executeOnArtboard(I, $), d();
|
|
115
|
-
},
|
|
116
|
-
[t, o, d]
|
|
117
|
-
), V = m(
|
|
118
|
-
(l) => {
|
|
119
|
-
c(l, "delete");
|
|
120
|
-
const f = o.getArtboardIdForElement(l.id);
|
|
121
|
-
if (!f) {
|
|
122
|
-
gt.warn("Element not found in any artboard");
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
const g = new be(
|
|
126
|
-
l,
|
|
127
|
-
(y) => {
|
|
128
|
-
t((I) => [...I, y]), o.addElementToArtboard(y.id, f);
|
|
129
|
-
},
|
|
130
|
-
(y) => {
|
|
131
|
-
t((I) => I.filter(($) => $.id !== y)), o.removeElementFromArtboard(y);
|
|
132
|
-
}
|
|
133
|
-
);
|
|
134
|
-
s.current.executeOnArtboard(f, g), d();
|
|
135
|
-
},
|
|
136
|
-
[t, o, d, c]
|
|
137
|
-
), E = m(
|
|
138
|
-
(l) => {
|
|
139
|
-
const f = new we(l, o);
|
|
140
|
-
s.current.executeGlobal(f), d(), n == null || n();
|
|
141
|
-
},
|
|
142
|
-
[o, d, n]
|
|
143
|
-
), D = m(
|
|
144
|
-
(l) => {
|
|
145
|
-
const f = new Ee(l, o);
|
|
146
|
-
s.current.executeGlobal(f), d(), n == null || n();
|
|
147
|
-
},
|
|
148
|
-
[o, d, n]
|
|
149
|
-
), p = m(
|
|
150
|
-
(l, f, g) => {
|
|
151
|
-
const y = new Se(l, f, g, o);
|
|
152
|
-
s.current.executeGlobal(y), d(), n == null || n();
|
|
153
|
-
},
|
|
154
|
-
[o, d, n]
|
|
155
|
-
), h = m(
|
|
156
|
-
(l) => {
|
|
157
|
-
if (l.length === 0)
|
|
158
|
-
return;
|
|
159
|
-
const f = o.getActiveArtboardId();
|
|
160
|
-
if (!f) {
|
|
161
|
-
gt.warn("No active artboard for batch execution");
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
const g = l.map((y) => new class extends Object {
|
|
165
|
-
execute() {
|
|
166
|
-
y.execute();
|
|
167
|
-
}
|
|
168
|
-
undo() {
|
|
169
|
-
y.undo();
|
|
170
|
-
}
|
|
171
|
-
}());
|
|
172
|
-
s.current.executeBatchOnArtboard(f, g), d();
|
|
173
|
-
},
|
|
174
|
-
[o, d]
|
|
175
|
-
), S = m(() => {
|
|
176
|
-
s.current.undo() && (d(), n == null || n());
|
|
177
|
-
}, [d, n]), v = m(() => {
|
|
178
|
-
s.current.redo() && (d(), n == null || n());
|
|
179
|
-
}, [d, n]), R = m(() => {
|
|
180
|
-
const l = o.getActiveArtboardId();
|
|
181
|
-
l && s.current.undoArtboard(l) && (d(), n == null || n());
|
|
182
|
-
}, [o, d, n]), w = m(() => {
|
|
183
|
-
const l = o.getActiveArtboardId();
|
|
184
|
-
l && s.current.redoArtboard(l) && (d(), n == null || n());
|
|
185
|
-
}, [o, d, n]), L = m(() => {
|
|
186
|
-
s.current.clear(), d();
|
|
187
|
-
}, [d]), nt = m(
|
|
188
|
-
(l) => {
|
|
189
|
-
s.current.clearArtboardHistory(l), d();
|
|
190
|
-
},
|
|
191
|
-
[d]
|
|
192
|
-
), _ = pt(null);
|
|
193
|
-
Dt(() => {
|
|
194
|
-
const l = o.getActiveArtboardId();
|
|
195
|
-
l !== _.current && (_.current = l, d());
|
|
196
|
-
});
|
|
197
|
-
const M = m(
|
|
198
|
-
(l, f, g) => {
|
|
199
|
-
const y = e.map((P) => P.id), I = o.getArtboardIdForElement(l);
|
|
200
|
-
if (!I) {
|
|
201
|
-
gt.warn("Element not found in any artboard");
|
|
202
|
-
return;
|
|
203
|
-
}
|
|
204
|
-
const $ = new Re(l, f, g, y, (P) => {
|
|
205
|
-
t((U) => {
|
|
206
|
-
const N = new Map(U.map((H) => [H.id, H]));
|
|
207
|
-
return P.map((H) => N.get(H)).filter(Boolean);
|
|
208
|
-
});
|
|
209
|
-
});
|
|
210
|
-
s.current.executeOnArtboard(I, $), d();
|
|
211
|
-
},
|
|
212
|
-
[e, t, o, d]
|
|
213
|
-
);
|
|
214
|
-
return {
|
|
215
|
-
// Element operations
|
|
216
|
-
executeElementUpdate: z,
|
|
217
|
-
executeAddElement: F,
|
|
218
|
-
executeRemoveElement: V,
|
|
219
|
-
executeReorderElement: M,
|
|
220
|
-
// Batch operations
|
|
221
|
-
executeCommandBatch: h,
|
|
222
|
-
// Artboard operations
|
|
223
|
-
executeCreateArtboard: E,
|
|
224
|
-
executeDeleteArtboard: D,
|
|
225
|
-
executeUpdateArtboard: p,
|
|
226
|
-
// Undo/redo (smart - considers last operation and active artboard)
|
|
227
|
-
undo: S,
|
|
228
|
-
redo: v,
|
|
229
|
-
// Undo/redo for active artboard only (element operations)
|
|
230
|
-
undoActiveArtboard: R,
|
|
231
|
-
redoActiveArtboard: w,
|
|
232
|
-
clearHistory: L,
|
|
233
|
-
clearArtboardHistory: nt,
|
|
234
|
-
// State (smart - considers last operation)
|
|
235
|
-
canUndo: i.canUndo,
|
|
236
|
-
canRedo: i.canRedo,
|
|
237
|
-
// State for active artboard only
|
|
238
|
-
canUndoActiveArtboard: i.canUndoActiveArtboard,
|
|
239
|
-
canRedoActiveArtboard: i.canRedoActiveArtboard,
|
|
240
|
-
historyManager: s.current
|
|
241
|
-
};
|
|
242
|
-
}
|
|
243
|
-
function dt(e) {
|
|
244
|
-
return e && "fontSize" in e && "color" in e && "fontFamily" in e;
|
|
245
|
-
}
|
|
246
|
-
function Be(e, t) {
|
|
247
|
-
const [o, n] = b(32), [s, r] = b("#333333"), [c, i] = b("Arial"), [a, d] = b("center");
|
|
248
|
-
Dt(() => {
|
|
249
|
-
if (e && dt(e)) {
|
|
250
|
-
const p = e.transformType === "circle" && "getEffectiveFontSize" in e ? Math.round(e.getEffectiveFontSize()) : Math.round(e.fontSize), h = e.color, S = e.fontFamily, v = e.textAlign;
|
|
251
|
-
n((R) => R !== p ? p : R), r((R) => R !== h ? h : R), i((R) => R !== S ? S : R), d((R) => R !== v ? v : R);
|
|
252
|
-
}
|
|
253
|
-
}, [e]);
|
|
254
|
-
const z = m(
|
|
255
|
-
(p) => {
|
|
256
|
-
if (!e || !dt(e)) return;
|
|
257
|
-
const h = Math.max(Ce, Math.min(Te, o + p));
|
|
258
|
-
n(h);
|
|
259
|
-
const S = e.clone();
|
|
260
|
-
S.transformType === "circle" && "setEffectiveFontSize" in S ? S.setEffectiveFontSize(h) : S.setFontSize(h), t(S);
|
|
261
|
-
},
|
|
262
|
-
[e, o, t]
|
|
263
|
-
), F = m(
|
|
264
|
-
(p) => {
|
|
265
|
-
if (!e || !dt(e)) return;
|
|
266
|
-
n(p);
|
|
267
|
-
const h = e.clone();
|
|
268
|
-
h.transformType === "circle" && "setEffectiveFontSize" in h ? h.setEffectiveFontSize(p) : h.setFontSize(p), t(h);
|
|
269
|
-
},
|
|
270
|
-
[e, t]
|
|
271
|
-
), V = m(
|
|
272
|
-
(p) => {
|
|
273
|
-
if (!e || !dt(e)) return;
|
|
274
|
-
r(p);
|
|
275
|
-
const h = e.clone();
|
|
276
|
-
if (h.color = p, h.richText)
|
|
277
|
-
for (const S of h.richText.spans)
|
|
278
|
-
S.style.color = void 0;
|
|
279
|
-
t(h);
|
|
280
|
-
},
|
|
281
|
-
[e, t]
|
|
282
|
-
), E = m(
|
|
283
|
-
(p) => {
|
|
284
|
-
if (!e || !dt(e)) return;
|
|
285
|
-
const h = e.fontFamily;
|
|
286
|
-
h !== p && Ie.clearCache(h), i(p);
|
|
287
|
-
const S = e.clone();
|
|
288
|
-
S.fontFamily = p, t(S);
|
|
289
|
-
},
|
|
290
|
-
[e, t]
|
|
291
|
-
), D = m(
|
|
292
|
-
(p) => {
|
|
293
|
-
if (!e || !dt(e)) return;
|
|
294
|
-
d(p);
|
|
295
|
-
const h = e.clone();
|
|
296
|
-
h.textAlign = p, t(h);
|
|
297
|
-
},
|
|
298
|
-
[e, t]
|
|
299
|
-
);
|
|
300
|
-
return {
|
|
301
|
-
// State
|
|
302
|
-
fontSize: o,
|
|
303
|
-
fontColor: s,
|
|
304
|
-
fontFamily: c,
|
|
305
|
-
textAlign: a,
|
|
306
|
-
// State setters (for UI only)
|
|
307
|
-
setFontSize: n,
|
|
308
|
-
setFontColor: r,
|
|
309
|
-
setFontFamily: i,
|
|
310
|
-
setTextAlign: d,
|
|
311
|
-
// Update functions (update element + UI)
|
|
312
|
-
updateFontSize: z,
|
|
313
|
-
setFontSizeValue: F,
|
|
314
|
-
updateFontColor: V,
|
|
315
|
-
updateFontFamily: E,
|
|
316
|
-
updateTextAlign: D
|
|
317
|
-
};
|
|
318
|
-
}
|
|
319
|
-
const qt = "data-preserve-selection";
|
|
320
|
-
function We(e) {
|
|
321
|
-
if (!(e instanceof Element))
|
|
322
|
-
return !1;
|
|
323
|
-
let t = e;
|
|
324
|
-
const o = [];
|
|
325
|
-
for (; t; ) {
|
|
326
|
-
const n = t.id ? `#${t.id}` : "", s = t.className ? `.${String(t.className).split(" ").slice(0, 2).join(".")}` : "";
|
|
327
|
-
if (o.push(`${t.tagName.toLowerCase()}${n}${s}`), t.hasAttribute(qt))
|
|
328
|
-
return !0;
|
|
329
|
-
const r = t.getAttribute("role");
|
|
330
|
-
if (r === "dialog" || r === "alertdialog" || r === "menu" || r === "listbox")
|
|
331
|
-
return !0;
|
|
332
|
-
const c = t.getAttribute("data-slot");
|
|
333
|
-
if (c && (c.includes("popover") || c.includes("dialog")) || t.hasAttribute("data-radix-popper-content-wrapper"))
|
|
334
|
-
return !0;
|
|
335
|
-
t = t.parentElement;
|
|
336
|
-
}
|
|
337
|
-
return !1;
|
|
338
|
-
}
|
|
339
|
-
const Eo = {
|
|
340
|
-
[qt]: ""
|
|
341
|
-
};
|
|
342
|
-
function Me(e) {
|
|
343
|
-
const t = Qt(e);
|
|
344
|
-
return t !== null && t < 0.5;
|
|
345
|
-
}
|
|
346
|
-
function So(e) {
|
|
347
|
-
const t = Qt(e);
|
|
348
|
-
return t !== null && t >= 0.5;
|
|
349
|
-
}
|
|
350
|
-
function Qt(e) {
|
|
351
|
-
const t = e.trim();
|
|
352
|
-
if (t.startsWith("#")) {
|
|
353
|
-
const n = t.slice(1);
|
|
354
|
-
let s, r, c;
|
|
355
|
-
if (n.length === 3)
|
|
356
|
-
s = parseInt(n[0] + n[0], 16), r = parseInt(n[1] + n[1], 16), c = parseInt(n[2] + n[2], 16);
|
|
357
|
-
else if (n.length === 6)
|
|
358
|
-
s = parseInt(n.slice(0, 2), 16), r = parseInt(n.slice(2, 4), 16), c = parseInt(n.slice(4, 6), 16);
|
|
359
|
-
else return null;
|
|
360
|
-
return Number.isNaN(s) || Number.isNaN(r) || Number.isNaN(c) ? null : Xt(s, r, c);
|
|
361
|
-
}
|
|
362
|
-
const o = t.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);
|
|
363
|
-
return o ? Xt(Number(o[1]), Number(o[2]), Number(o[3])) : null;
|
|
364
|
-
}
|
|
365
|
-
function Xt(e, t, o) {
|
|
366
|
-
const n = (s) => {
|
|
367
|
-
const r = s / 255;
|
|
368
|
-
return r <= 0.03928 ? r / 12.92 : Math.pow((r + 0.055) / 1.055, 2.4);
|
|
369
|
-
};
|
|
370
|
-
return 0.2126 * n(e) + 0.7152 * n(t) + 0.0722 * n(o);
|
|
371
|
-
}
|
|
372
|
-
const Ye = "#333333", Xe = "#f4f4f5";
|
|
373
|
-
function Ke(e) {
|
|
374
|
-
return e && Me(e) ? Xe : Ye;
|
|
375
|
-
}
|
|
376
|
-
const te = Q(null), Ge = 0.1, je = 4, Kt = 0.25, Ze = ({
|
|
377
|
-
children: e,
|
|
378
|
-
artboardManager: t,
|
|
379
|
-
canvasRef: o,
|
|
380
|
-
viewPadding: n = 0.9
|
|
381
|
-
}) => {
|
|
382
|
-
const [s, r] = b(1), [c, i] = b({ x: 0, y: 0 }), [a, d] = b(!1), [z, F] = b(1), V = m(() => {
|
|
383
|
-
F(1), i({ x: 0, y: 0 });
|
|
384
|
-
}, []), E = m(() => {
|
|
385
|
-
r((v) => Math.min(v + Kt, je));
|
|
386
|
-
}, []), D = m(() => {
|
|
387
|
-
r((v) => Math.max(v - Kt, Ge));
|
|
388
|
-
}, []), p = m(() => {
|
|
389
|
-
const v = t.getActiveArtboard();
|
|
390
|
-
if (!v || !o.current) return;
|
|
391
|
-
let R = o.current.parentElement, w = 0, L = 0;
|
|
392
|
-
for (; R && (w = R.clientWidth, L = R.clientHeight, !(w > 0 && L > 0)); )
|
|
393
|
-
R = R.parentElement;
|
|
394
|
-
if (!w || !L) return;
|
|
395
|
-
const nt = Math.min(
|
|
396
|
-
w * n / v.width,
|
|
397
|
-
L * n / v.height,
|
|
398
|
-
1
|
|
399
|
-
// Never zoom in beyond 100%
|
|
400
|
-
);
|
|
401
|
-
r(nt), i({ x: 0, y: 0 });
|
|
402
|
-
}, [t, o, n]), h = m(() => {
|
|
403
|
-
r(1), i({ x: 0, y: 0 });
|
|
404
|
-
}, []), S = q(
|
|
405
|
-
() => ({
|
|
406
|
-
zoom: s,
|
|
407
|
-
panOffset: c,
|
|
408
|
-
isPanning: a,
|
|
409
|
-
zoomIn: E,
|
|
410
|
-
zoomOut: D,
|
|
411
|
-
zoomToFit: p,
|
|
412
|
-
resetView: h,
|
|
413
|
-
setZoom: r,
|
|
414
|
-
setPanOffset: i,
|
|
415
|
-
setIsPanning: d,
|
|
416
|
-
userZoom: z,
|
|
417
|
-
setUserZoom: F,
|
|
418
|
-
resetUserView: V
|
|
419
|
-
}),
|
|
420
|
-
[s, c, a, E, D, p, h, z, V]
|
|
421
|
-
);
|
|
422
|
-
return /* @__PURE__ */ k(te.Provider, { value: S, children: e });
|
|
423
|
-
};
|
|
424
|
-
function Je() {
|
|
425
|
-
const e = Y(te);
|
|
426
|
-
if (!e)
|
|
427
|
-
throw new Error("useViewportContext must be used within a ViewportProvider (or EditorProvider)");
|
|
428
|
-
return e;
|
|
429
|
-
}
|
|
430
|
-
const ee = Q(null), qe = ({ children: e }) => {
|
|
431
|
-
const [t, o] = b(null), [n, s] = b([]), [r, c] = b(null), [i, a] = b(null), [d, z] = b(!1), F = m((D) => {
|
|
432
|
-
o(D);
|
|
433
|
-
}, []), V = m((D) => {
|
|
434
|
-
c(D);
|
|
435
|
-
}, []), E = q(
|
|
436
|
-
() => ({
|
|
437
|
-
selectedId: t,
|
|
438
|
-
multiSelection: n,
|
|
439
|
-
activeChildElement: r,
|
|
440
|
-
hoveredElementId: i,
|
|
441
|
-
hideHandles: d,
|
|
442
|
-
setSelectedId: o,
|
|
443
|
-
setMultiSelection: s,
|
|
444
|
-
setHoveredElementId: a,
|
|
445
|
-
setHideHandles: z,
|
|
446
|
-
handleSelectionChange: F,
|
|
447
|
-
handleActiveChildChange: V
|
|
448
|
-
}),
|
|
449
|
-
[
|
|
450
|
-
t,
|
|
451
|
-
n,
|
|
452
|
-
r,
|
|
453
|
-
i,
|
|
454
|
-
d,
|
|
455
|
-
F,
|
|
456
|
-
V
|
|
457
|
-
]
|
|
458
|
-
);
|
|
459
|
-
return /* @__PURE__ */ k(ee.Provider, { value: E, children: e });
|
|
460
|
-
};
|
|
461
|
-
function Qe() {
|
|
462
|
-
const e = Y(ee);
|
|
463
|
-
if (!e)
|
|
464
|
-
throw new Error("useSelectionContext must be used within a SelectionProvider (or EditorProvider)");
|
|
465
|
-
return e;
|
|
466
|
-
}
|
|
467
|
-
const oe = Q(null), to = ({ children: e, value: t }) => {
|
|
468
|
-
const o = q(
|
|
469
|
-
() => ({
|
|
470
|
-
undo: t.undo,
|
|
471
|
-
redo: t.redo,
|
|
472
|
-
canUndo: t.canUndo,
|
|
473
|
-
canRedo: t.canRedo,
|
|
474
|
-
undoActiveArtboard: t.undoActiveArtboard,
|
|
475
|
-
redoActiveArtboard: t.redoActiveArtboard,
|
|
476
|
-
canUndoActiveArtboard: t.canUndoActiveArtboard,
|
|
477
|
-
canRedoActiveArtboard: t.canRedoActiveArtboard
|
|
478
|
-
}),
|
|
479
|
-
[
|
|
480
|
-
t.undo,
|
|
481
|
-
t.redo,
|
|
482
|
-
t.canUndo,
|
|
483
|
-
t.canRedo,
|
|
484
|
-
t.undoActiveArtboard,
|
|
485
|
-
t.redoActiveArtboard,
|
|
486
|
-
t.canUndoActiveArtboard,
|
|
487
|
-
t.canRedoActiveArtboard
|
|
488
|
-
]
|
|
489
|
-
);
|
|
490
|
-
return /* @__PURE__ */ k(oe.Provider, { value: o, children: e });
|
|
491
|
-
};
|
|
492
|
-
function Ro() {
|
|
493
|
-
const e = Y(oe);
|
|
494
|
-
if (!e)
|
|
495
|
-
throw new Error("useHistoryContext must be used within a HistoryProvider (or EditorProvider)");
|
|
496
|
-
return e;
|
|
497
|
-
}
|
|
498
|
-
const ne = Q(null), eo = ({ children: e }) => {
|
|
499
|
-
const [t, o] = b(null), [n, s] = b(!1), [r, c] = b(0), [i, a] = b(!1), [d, z] = b(!1), F = q(
|
|
500
|
-
() => ({
|
|
501
|
-
expandedPanelType: t,
|
|
502
|
-
setExpandedPanelType: o,
|
|
503
|
-
isToolbarMenuOpen: n,
|
|
504
|
-
setIsToolbarMenuOpen: s,
|
|
505
|
-
textSelectionVersion: r,
|
|
506
|
-
setTextSelectionVersion: c,
|
|
507
|
-
isCanvasReady: i,
|
|
508
|
-
setCanvasReady: a,
|
|
509
|
-
isRotating: d,
|
|
510
|
-
setIsRotating: z
|
|
511
|
-
}),
|
|
512
|
-
[t, n, r, i, d]
|
|
513
|
-
);
|
|
514
|
-
return /* @__PURE__ */ k(ne.Provider, { value: F, children: e });
|
|
515
|
-
};
|
|
516
|
-
function oo() {
|
|
517
|
-
const e = Y(ne);
|
|
518
|
-
if (!e)
|
|
519
|
-
throw new Error("useToolStateContext must be used within a ToolStateProvider (or EditorProvider)");
|
|
520
|
-
return e;
|
|
521
|
-
}
|
|
522
|
-
const re = Q(null), no = ({ children: e, value: t }) => {
|
|
523
|
-
const o = q(
|
|
524
|
-
() => ({
|
|
525
|
-
elements: t.elements,
|
|
526
|
-
elementStore: t.elementStore,
|
|
527
|
-
artboards: t.artboards,
|
|
528
|
-
artboardManager: t.artboardManager,
|
|
529
|
-
artboardVersion: t.artboardVersion,
|
|
530
|
-
setElements: t.setElements,
|
|
531
|
-
refreshArtboards: t.refreshArtboards,
|
|
532
|
-
getElementById: t.getElementById,
|
|
533
|
-
handleAddElement: t.handleAddElement,
|
|
534
|
-
handleElementUpdate: t.handleElementUpdate,
|
|
535
|
-
handleLoadWorkspace: t.handleLoadWorkspace,
|
|
536
|
-
handleCopyElements: t.handleCopyElements,
|
|
537
|
-
handlePasteElements: t.handlePasteElements,
|
|
538
|
-
fontSize: t.fontSize,
|
|
539
|
-
fontColor: t.fontColor,
|
|
540
|
-
fontFamily: t.fontFamily,
|
|
541
|
-
textAlign: t.textAlign,
|
|
542
|
-
updateFontSize: t.updateFontSize,
|
|
543
|
-
setFontSizeValue: t.setFontSizeValue,
|
|
544
|
-
updateFontColor: t.updateFontColor,
|
|
545
|
-
updateFontFamily: t.updateFontFamily,
|
|
546
|
-
updateTextAlign: t.updateTextAlign,
|
|
547
|
-
canvasRef: t.canvasRef,
|
|
548
|
-
canvasEditorRef: t.canvasEditorRef
|
|
549
|
-
}),
|
|
550
|
-
[
|
|
551
|
-
t.elements,
|
|
552
|
-
t.elementStore,
|
|
553
|
-
t.artboards,
|
|
554
|
-
t.artboardManager,
|
|
555
|
-
t.artboardVersion,
|
|
556
|
-
t.setElements,
|
|
557
|
-
t.refreshArtboards,
|
|
558
|
-
t.getElementById,
|
|
559
|
-
t.handleAddElement,
|
|
560
|
-
t.handleElementUpdate,
|
|
561
|
-
t.handleLoadWorkspace,
|
|
562
|
-
t.handleCopyElements,
|
|
563
|
-
t.handlePasteElements,
|
|
564
|
-
t.fontSize,
|
|
565
|
-
t.fontColor,
|
|
566
|
-
t.fontFamily,
|
|
567
|
-
t.textAlign,
|
|
568
|
-
t.updateFontSize,
|
|
569
|
-
t.setFontSizeValue,
|
|
570
|
-
t.updateFontColor,
|
|
571
|
-
t.updateFontFamily,
|
|
572
|
-
t.updateTextAlign,
|
|
573
|
-
t.canvasRef,
|
|
574
|
-
t.canvasEditorRef
|
|
575
|
-
]
|
|
576
|
-
);
|
|
577
|
-
return /* @__PURE__ */ k(re.Provider, { value: o, children: e });
|
|
578
|
-
};
|
|
579
|
-
function Io() {
|
|
580
|
-
const e = Y(re);
|
|
581
|
-
if (!e)
|
|
582
|
-
throw new Error("useElementsContext must be used within an ElementsProvider (or EditorProvider)");
|
|
583
|
-
return e;
|
|
584
|
-
}
|
|
585
|
-
const ie = Q(null), ro = ({ children: e, value: t }) => {
|
|
586
|
-
const o = q(
|
|
587
|
-
() => ({
|
|
588
|
-
executeElementUpdate: t.executeElementUpdate,
|
|
589
|
-
executeAddElement: t.executeAddElement,
|
|
590
|
-
executeRemoveElement: t.executeRemoveElement,
|
|
591
|
-
executeReorderElement: t.executeReorderElement,
|
|
592
|
-
executeCreateArtboard: t.executeCreateArtboard,
|
|
593
|
-
executeDeleteArtboard: t.executeDeleteArtboard,
|
|
594
|
-
executeUpdateArtboard: t.executeUpdateArtboard,
|
|
595
|
-
executeCommandBatch: t.executeCommandBatch,
|
|
596
|
-
undo: t.undo,
|
|
597
|
-
redo: t.redo,
|
|
598
|
-
canUndo: t.canUndo,
|
|
599
|
-
canRedo: t.canRedo,
|
|
600
|
-
undoActiveArtboard: t.undoActiveArtboard,
|
|
601
|
-
redoActiveArtboard: t.redoActiveArtboard,
|
|
602
|
-
canUndoActiveArtboard: t.canUndoActiveArtboard,
|
|
603
|
-
canRedoActiveArtboard: t.canRedoActiveArtboard,
|
|
604
|
-
historyManager: t.historyManager
|
|
605
|
-
}),
|
|
606
|
-
[
|
|
607
|
-
t.executeElementUpdate,
|
|
608
|
-
t.executeAddElement,
|
|
609
|
-
t.executeRemoveElement,
|
|
610
|
-
t.executeReorderElement,
|
|
611
|
-
t.executeCreateArtboard,
|
|
612
|
-
t.executeDeleteArtboard,
|
|
613
|
-
t.executeUpdateArtboard,
|
|
614
|
-
t.executeCommandBatch,
|
|
615
|
-
t.undo,
|
|
616
|
-
t.redo,
|
|
617
|
-
t.canUndo,
|
|
618
|
-
t.canRedo,
|
|
619
|
-
t.undoActiveArtboard,
|
|
620
|
-
t.redoActiveArtboard,
|
|
621
|
-
t.canUndoActiveArtboard,
|
|
622
|
-
t.canRedoActiveArtboard,
|
|
623
|
-
t.historyManager
|
|
624
|
-
]
|
|
625
|
-
);
|
|
626
|
-
return /* @__PURE__ */ k(ie.Provider, { value: o, children: e });
|
|
627
|
-
};
|
|
628
|
-
function Co() {
|
|
629
|
-
const e = Y(ie);
|
|
630
|
-
if (!e)
|
|
631
|
-
throw new Error("useCommandContext must be used within a CommandProvider (or EditorProvider)");
|
|
632
|
-
return e;
|
|
633
|
-
}
|
|
634
|
-
const io = Zt("EditorContext"), se = Q(null), ce = Q(null), To = () => {
|
|
635
|
-
const e = Y(ce);
|
|
636
|
-
if (!e)
|
|
637
|
-
throw new Error("useEditorHandles must be used within EditorProvider");
|
|
638
|
-
return e;
|
|
639
|
-
}, so = ({ children: e, artboardManager: t, canvasRef: o, canvasEditorRef: n }) => {
|
|
640
|
-
const s = pt(null), r = q(() => ({ get: () => s.current }), []), c = Je(), i = Qe(), a = oo(), [d, z] = b(
|
|
641
|
-
() => t.getAllArtboards()
|
|
642
|
-
), [F, V] = b(0), [E, D] = b(
|
|
643
|
-
() => new Wt()
|
|
644
|
-
), p = q(() => E.toArray(), [E]), h = m((u) => {
|
|
645
|
-
D((A) => {
|
|
646
|
-
const x = A.toArray(), C = typeof u == "function" ? u(x) : u;
|
|
647
|
-
return C === x ? A : Wt.fromArray(C);
|
|
648
|
-
});
|
|
649
|
-
}, []), S = m(
|
|
650
|
-
(u) => E.get(u),
|
|
651
|
-
[E]
|
|
652
|
-
), [v, R] = b([]), w = i.selectedId ? E.get(i.selectedId) : void 0, L = m(() => {
|
|
653
|
-
z([...t.getAllArtboards()]), V((u) => u + 1);
|
|
654
|
-
}, [t]), {
|
|
655
|
-
historyManager: nt,
|
|
656
|
-
executeElementUpdate: _,
|
|
657
|
-
executeAddElement: M,
|
|
658
|
-
executeRemoveElement: l,
|
|
659
|
-
executeReorderElement: f,
|
|
660
|
-
executeCommandBatch: g,
|
|
661
|
-
executeCreateArtboard: y,
|
|
662
|
-
executeDeleteArtboard: I,
|
|
663
|
-
executeUpdateArtboard: $,
|
|
664
|
-
undo: P,
|
|
665
|
-
redo: U,
|
|
666
|
-
canUndo: N,
|
|
667
|
-
canRedo: H,
|
|
668
|
-
undoActiveArtboard: O,
|
|
669
|
-
redoActiveArtboard: X,
|
|
670
|
-
canUndoActiveArtboard: rt,
|
|
671
|
-
canRedoActiveArtboard: K
|
|
672
|
-
} = $e(
|
|
673
|
-
p,
|
|
674
|
-
h,
|
|
675
|
-
t,
|
|
676
|
-
L
|
|
677
|
-
), G = m(
|
|
678
|
-
(u) => {
|
|
679
|
-
const A = E.get(u.id);
|
|
680
|
-
_(A, u);
|
|
681
|
-
},
|
|
682
|
-
[E, _]
|
|
683
|
-
), me = m(
|
|
684
|
-
(u) => {
|
|
685
|
-
if (!w || !(w instanceof jt))
|
|
686
|
-
return;
|
|
687
|
-
const A = w.clone(), x = A.children.findIndex(
|
|
688
|
-
(C) => C.id === u.id
|
|
689
|
-
);
|
|
690
|
-
x >= 0 && (A.children[x] = u, G(A));
|
|
691
|
-
},
|
|
692
|
-
[w, G]
|
|
693
|
-
), he = i.activeChildElement || w, fe = i.activeChildElement ? me : G, {
|
|
694
|
-
fontSize: bt,
|
|
695
|
-
fontColor: wt,
|
|
696
|
-
fontFamily: Et,
|
|
697
|
-
textAlign: St,
|
|
698
|
-
updateFontSize: Rt,
|
|
699
|
-
setFontSizeValue: It,
|
|
700
|
-
updateFontColor: Ct,
|
|
701
|
-
updateFontFamily: Tt,
|
|
702
|
-
updateTextAlign: Ot
|
|
703
|
-
} = Be(he, fe), At = m(
|
|
704
|
-
async (u) => {
|
|
705
|
-
var Lt;
|
|
706
|
-
const A = u.type, x = u, C = t.getActiveArtboardId();
|
|
707
|
-
if (!C)
|
|
708
|
-
throw new ot(
|
|
709
|
-
"E_NO_ACTIVE_ARTBOARD",
|
|
710
|
-
`addElement({ type: "${A}" }) 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).`,
|
|
711
|
-
{ type: A, docSlug: "embed-mode" }
|
|
712
|
-
);
|
|
713
|
-
const T = `element-${Date.now()}`, B = t.getActiveArtboard(), mt = B ? B.x + B.width / 2 : window.innerWidth / 2, st = B ? B.y + B.height / 2 : window.innerHeight / 2, j = ((Lt = n.current) == null ? void 0 : Lt.getZoom()) || c.zoom || 1;
|
|
714
|
-
if (A === "image") {
|
|
715
|
-
const ft = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==", et = 200 / j, Z = x == null ? void 0 : x.src, W = new Fe({
|
|
716
|
-
id: T,
|
|
717
|
-
name: u.name,
|
|
718
|
-
x: mt,
|
|
719
|
-
y: st,
|
|
720
|
-
// Defer loading `src` until after the element is in the store so a
|
|
721
|
-
// synchronously-cached image can't fire onLoadCallback too early.
|
|
722
|
-
imageUrl: Z ? "" : ft,
|
|
723
|
-
transformData: {
|
|
724
|
-
type: "image",
|
|
725
|
-
width: et,
|
|
726
|
-
height: et,
|
|
727
|
-
cropX: 0,
|
|
728
|
-
cropY: 0,
|
|
729
|
-
cropWidth: 1,
|
|
730
|
-
cropHeight: 1,
|
|
731
|
-
flipHorizontal: !1,
|
|
732
|
-
flipVertical: !1,
|
|
733
|
-
borderRadius: 0
|
|
734
|
-
}
|
|
735
|
-
});
|
|
736
|
-
return Z && (W.imageLoaded = !1, W.imageElement = null, W.isCropping = !1, W.imageUrl = Z, W.preserveDimensions = !1, W.onLoadCallback = (J) => {
|
|
737
|
-
const $t = J.transformData.width, Bt = J.transformData.height, kt = Math.min(et / $t, et / Bt, 1);
|
|
738
|
-
kt < 1 && (J.transformData.width = $t * kt, J.transformData.height = Bt * kt), J.transformData.cropX = 0, J.transformData.cropY = 0, J.transformData.cropWidth = 1, J.transformData.cropHeight = 1, _(W, J);
|
|
739
|
-
}), M(W, C), i.setSelectedId(W.id), Z && W.loadImage(Z), { id: W.id, name: u.name ?? "" };
|
|
740
|
-
}
|
|
741
|
-
let tt;
|
|
742
|
-
const at = {
|
|
743
|
-
text: "custom",
|
|
744
|
-
circle: "circle",
|
|
745
|
-
wave: "wave",
|
|
746
|
-
arch: "arch",
|
|
747
|
-
shape: "shape"
|
|
748
|
-
}[A] || "custom", zt = Pe(at);
|
|
749
|
-
if (!zt || !zt.Component)
|
|
750
|
-
throw new Error(`[EditorContext] no transform registered for element type "${A}"`);
|
|
751
|
-
const ht = t.getActiveArtboard(), pe = ht ? Math.min(ht.width, ht.height) * 0.1 : 80, Ht = ht ? ht.width * 0.5 : 300;
|
|
752
|
-
if (A === "shape") {
|
|
753
|
-
const ft = (x == null ? void 0 : x.shapeType) ?? "rectangle";
|
|
754
|
-
let et = 200 / j, Z = 200 / j;
|
|
755
|
-
ft === "ellipse" ? (et = 150 / j, Z = 250 / j) : ft === "line" && (et = 300 / j, Z = 8 / j), tt = new Ne({
|
|
756
|
-
id: T,
|
|
757
|
-
name: u.name,
|
|
758
|
-
x: mt,
|
|
759
|
-
y: st,
|
|
760
|
-
transformData: {
|
|
761
|
-
type: "shape",
|
|
762
|
-
shapeType: ft,
|
|
763
|
-
width: et,
|
|
764
|
-
height: Z,
|
|
765
|
-
fillColor: "#3b82f6",
|
|
766
|
-
fillOpacity: 1
|
|
767
|
-
}
|
|
768
|
-
});
|
|
769
|
-
} else
|
|
770
|
-
tt = new zt.Component({
|
|
771
|
-
id: T,
|
|
772
|
-
name: u.name,
|
|
773
|
-
text: "New Text",
|
|
774
|
-
x: mt,
|
|
775
|
-
y: st,
|
|
776
|
-
fontSize: pe,
|
|
777
|
-
fontFamily: "Poppins",
|
|
778
|
-
color: Ke(B == null ? void 0 : B.backgroundColor),
|
|
779
|
-
transformData: at === "arch" ? {
|
|
780
|
-
type: "arch",
|
|
781
|
-
width: Ht,
|
|
782
|
-
archHeight: ze.archHeight
|
|
783
|
-
} : at === "wave" ? {
|
|
784
|
-
type: "wave",
|
|
785
|
-
width: Ht,
|
|
786
|
-
amplitude: Mt.amplitude,
|
|
787
|
-
frequency: Mt.frequency
|
|
788
|
-
} : at === "circle" ? {
|
|
789
|
-
type: "circle",
|
|
790
|
-
radius: Ht / 2
|
|
791
|
-
} : void 0
|
|
792
|
-
});
|
|
793
|
-
return t.addElementToArtboard(T, C), M(
|
|
794
|
-
tt,
|
|
795
|
-
C,
|
|
796
|
-
i.selectedId || void 0
|
|
797
|
-
), i.setSelectedId(T), { id: T, name: u.name ?? "" };
|
|
798
|
-
},
|
|
799
|
-
[t, M, _, i, c.zoom, n]
|
|
800
|
-
), vt = m(
|
|
801
|
-
async (u, A) => {
|
|
802
|
-
await At({ ...A, type: u });
|
|
803
|
-
},
|
|
804
|
-
[At]
|
|
805
|
-
), Ft = m(() => {
|
|
806
|
-
const u = [];
|
|
807
|
-
if (i.multiSelection.length > 0) {
|
|
808
|
-
const A = p.filter(
|
|
809
|
-
(x) => i.multiSelection.includes(x.id)
|
|
810
|
-
);
|
|
811
|
-
u.push(...A);
|
|
812
|
-
} else w && u.push(w);
|
|
813
|
-
if (u.length > 0) {
|
|
814
|
-
const A = u.map((x) => x.clone());
|
|
815
|
-
R(A);
|
|
816
|
-
}
|
|
817
|
-
}, [w, i.multiSelection, p]), Pt = m(() => {
|
|
818
|
-
if (v.length === 0) return;
|
|
819
|
-
const u = [], A = 30, x = 30;
|
|
820
|
-
v.forEach((C) => {
|
|
821
|
-
const T = E.get(C.id), B = T ? T.x : C.x, mt = T ? T.y : C.y, st = C.toJSON();
|
|
822
|
-
delete st.id;
|
|
823
|
-
const j = C.constructor, tt = new j(st);
|
|
824
|
-
tt.x = B + A, tt.y = mt + x;
|
|
825
|
-
let ct = null;
|
|
826
|
-
if (T && (ct = t.getArtboardIdForElement(
|
|
827
|
-
T.id
|
|
828
|
-
)), ct || (ct = t.getActiveArtboardId()), !ct) {
|
|
829
|
-
io.warn("[handlePasteElements] No artboard found for pasting");
|
|
830
|
-
return;
|
|
831
|
-
}
|
|
832
|
-
const at = T ? T.id : void 0;
|
|
833
|
-
M(tt, ct, at), u.push(tt.id);
|
|
834
|
-
}), u.length === 1 ? i.handleSelectionChange(u[0]) : u.length > 1 && i.setMultiSelection(u);
|
|
835
|
-
}, [
|
|
836
|
-
v,
|
|
837
|
-
E,
|
|
838
|
-
t,
|
|
839
|
-
M,
|
|
840
|
-
i
|
|
841
|
-
]), yt = m(() => {
|
|
842
|
-
if (a.expandedPanelType === "crop" && (w == null ? void 0 : w.transformType) === "image") {
|
|
843
|
-
const u = w;
|
|
844
|
-
if (u.isCropping) {
|
|
845
|
-
const A = u.clone();
|
|
846
|
-
A.exitCropMode(), _(u, A);
|
|
847
|
-
}
|
|
848
|
-
}
|
|
849
|
-
a.setExpandedPanelType(null);
|
|
850
|
-
}, [
|
|
851
|
-
a.expandedPanelType,
|
|
852
|
-
a.setExpandedPanelType,
|
|
853
|
-
w,
|
|
854
|
-
_
|
|
855
|
-
]);
|
|
856
|
-
Dt(() => {
|
|
857
|
-
const u = (A) => {
|
|
858
|
-
const x = A.target;
|
|
859
|
-
if (x.tagName === "CANVAS" || We(x))
|
|
860
|
-
return;
|
|
861
|
-
const T = document.activeElement;
|
|
862
|
-
if (T != null && T.hasAttribute("data-preserve-selection")) {
|
|
863
|
-
T.blur();
|
|
864
|
-
return;
|
|
865
|
-
}
|
|
866
|
-
if (a.expandedPanelType !== null) {
|
|
867
|
-
yt();
|
|
868
|
-
return;
|
|
869
|
-
}
|
|
870
|
-
i.selectedId !== null && i.setSelectedId(null), i.multiSelection.length > 0 && i.setMultiSelection([]);
|
|
871
|
-
};
|
|
872
|
-
return document.addEventListener("pointerdown", u), () => document.removeEventListener("pointerdown", u);
|
|
873
|
-
}, [a.expandedPanelType, yt, i]);
|
|
874
|
-
const Nt = m(
|
|
875
|
-
(u, A, x) => {
|
|
876
|
-
t.clear(), u.forEach((C) => {
|
|
877
|
-
t.createArtboard(C.toJSON());
|
|
878
|
-
}), x && t.setActiveArtboard(x), z([...t.getAllArtboards()]), V((C) => C + 1), h(A), i.setSelectedId(null);
|
|
879
|
-
},
|
|
880
|
-
[t, i, h]
|
|
881
|
-
), _t = q(() => ({
|
|
882
|
-
// From ViewportContext
|
|
883
|
-
zoom: c.zoom,
|
|
884
|
-
panOffset: c.panOffset,
|
|
885
|
-
isPanning: c.isPanning,
|
|
886
|
-
zoomIn: c.zoomIn,
|
|
887
|
-
zoomOut: c.zoomOut,
|
|
888
|
-
zoomToFit: c.zoomToFit,
|
|
889
|
-
resetView: c.resetView,
|
|
890
|
-
setZoom: c.setZoom,
|
|
891
|
-
setPanOffset: c.setPanOffset,
|
|
892
|
-
setIsPanning: c.setIsPanning,
|
|
893
|
-
// From SelectionContext
|
|
894
|
-
selectedId: i.selectedId,
|
|
895
|
-
multiSelection: i.multiSelection,
|
|
896
|
-
activeChildElement: i.activeChildElement,
|
|
897
|
-
hoveredElementId: i.hoveredElementId,
|
|
898
|
-
hideHandles: i.hideHandles,
|
|
899
|
-
setSelectedId: i.setSelectedId,
|
|
900
|
-
setMultiSelection: i.setMultiSelection,
|
|
901
|
-
setHoveredElementId: i.setHoveredElementId,
|
|
902
|
-
setHideHandles: i.setHideHandles,
|
|
903
|
-
handleSelectionChange: i.handleSelectionChange,
|
|
904
|
-
handleActiveChildChange: i.handleActiveChildChange,
|
|
905
|
-
// From ToolStateContext
|
|
906
|
-
expandedPanelType: a.expandedPanelType,
|
|
907
|
-
setExpandedPanelType: a.setExpandedPanelType,
|
|
908
|
-
isToolbarMenuOpen: a.isToolbarMenuOpen,
|
|
909
|
-
setIsToolbarMenuOpen: a.setIsToolbarMenuOpen,
|
|
910
|
-
textSelectionVersion: a.textSelectionVersion,
|
|
911
|
-
setTextSelectionVersion: a.setTextSelectionVersion,
|
|
912
|
-
isCanvasReady: a.isCanvasReady,
|
|
913
|
-
setCanvasReady: a.setCanvasReady,
|
|
914
|
-
isRotating: a.isRotating,
|
|
915
|
-
setIsRotating: a.setIsRotating,
|
|
916
|
-
// Cross-context handler
|
|
917
|
-
clearExpandedPanel: yt,
|
|
918
|
-
// Core state (element/artboard domain)
|
|
919
|
-
artboardManager: t,
|
|
920
|
-
artboards: d,
|
|
921
|
-
elements: p,
|
|
922
|
-
elementStore: E,
|
|
923
|
-
getElementById: S,
|
|
924
|
-
// Derived state (cross-context)
|
|
925
|
-
selectedElement: w,
|
|
926
|
-
// Refs
|
|
927
|
-
canvasRef: o,
|
|
928
|
-
canvasEditorRef: n,
|
|
929
|
-
// Element setters
|
|
930
|
-
setElements: h,
|
|
931
|
-
// Artboard version counter
|
|
932
|
-
artboardVersion: F,
|
|
933
|
-
// Handlers
|
|
934
|
-
refreshArtboards: L,
|
|
935
|
-
handleElementUpdate: G,
|
|
936
|
-
addElement: At,
|
|
937
|
-
handleAddElement: vt,
|
|
938
|
-
handleLoadWorkspace: Nt,
|
|
939
|
-
handleCopyElements: Ft,
|
|
940
|
-
handlePasteElements: Pt,
|
|
941
|
-
hasClipboardContent: v.length > 0,
|
|
942
|
-
// Command history (undo/redo actions + execute functions)
|
|
943
|
-
historyManager: nt,
|
|
944
|
-
executeElementUpdate: _,
|
|
945
|
-
executeAddElement: M,
|
|
946
|
-
executeRemoveElement: l,
|
|
947
|
-
executeReorderElement: f,
|
|
948
|
-
executeCommandBatch: g,
|
|
949
|
-
executeCreateArtboard: y,
|
|
950
|
-
executeDeleteArtboard: I,
|
|
951
|
-
executeUpdateArtboard: $,
|
|
952
|
-
undo: P,
|
|
953
|
-
redo: U,
|
|
954
|
-
canUndo: N,
|
|
955
|
-
canRedo: H,
|
|
956
|
-
undoActiveArtboard: O,
|
|
957
|
-
redoActiveArtboard: X,
|
|
958
|
-
canUndoActiveArtboard: rt,
|
|
959
|
-
canRedoActiveArtboard: K,
|
|
960
|
-
// Element properties
|
|
961
|
-
fontSize: bt,
|
|
962
|
-
fontColor: wt,
|
|
963
|
-
fontFamily: Et,
|
|
964
|
-
textAlign: St,
|
|
965
|
-
updateFontSize: Rt,
|
|
966
|
-
setFontSizeValue: It,
|
|
967
|
-
updateFontColor: Ct,
|
|
968
|
-
updateFontFamily: Tt,
|
|
969
|
-
updateTextAlign: Ot
|
|
970
|
-
}), [
|
|
971
|
-
// Viewport
|
|
972
|
-
c.zoom,
|
|
973
|
-
c.panOffset,
|
|
974
|
-
c.isPanning,
|
|
975
|
-
c.zoomIn,
|
|
976
|
-
c.zoomOut,
|
|
977
|
-
c.zoomToFit,
|
|
978
|
-
c.resetView,
|
|
979
|
-
c.setZoom,
|
|
980
|
-
c.setPanOffset,
|
|
981
|
-
c.setIsPanning,
|
|
982
|
-
// Selection
|
|
983
|
-
i.selectedId,
|
|
984
|
-
i.multiSelection,
|
|
985
|
-
i.activeChildElement,
|
|
986
|
-
i.hoveredElementId,
|
|
987
|
-
i.hideHandles,
|
|
988
|
-
i.setSelectedId,
|
|
989
|
-
i.setMultiSelection,
|
|
990
|
-
i.setHoveredElementId,
|
|
991
|
-
i.setHideHandles,
|
|
992
|
-
i.handleSelectionChange,
|
|
993
|
-
i.handleActiveChildChange,
|
|
994
|
-
// Tool state
|
|
995
|
-
a.expandedPanelType,
|
|
996
|
-
a.setExpandedPanelType,
|
|
997
|
-
a.isToolbarMenuOpen,
|
|
998
|
-
a.setIsToolbarMenuOpen,
|
|
999
|
-
a.textSelectionVersion,
|
|
1000
|
-
a.setTextSelectionVersion,
|
|
1001
|
-
a.isCanvasReady,
|
|
1002
|
-
a.setCanvasReady,
|
|
1003
|
-
a.isRotating,
|
|
1004
|
-
a.setIsRotating,
|
|
1005
|
-
yt,
|
|
1006
|
-
// Element/artboard domain
|
|
1007
|
-
t,
|
|
1008
|
-
d,
|
|
1009
|
-
p,
|
|
1010
|
-
E,
|
|
1011
|
-
S,
|
|
1012
|
-
w,
|
|
1013
|
-
o,
|
|
1014
|
-
n,
|
|
1015
|
-
h,
|
|
1016
|
-
F,
|
|
1017
|
-
L,
|
|
1018
|
-
G,
|
|
1019
|
-
At,
|
|
1020
|
-
vt,
|
|
1021
|
-
Nt,
|
|
1022
|
-
Ft,
|
|
1023
|
-
Pt,
|
|
1024
|
-
v,
|
|
1025
|
-
// Command history
|
|
1026
|
-
nt,
|
|
1027
|
-
_,
|
|
1028
|
-
M,
|
|
1029
|
-
l,
|
|
1030
|
-
f,
|
|
1031
|
-
g,
|
|
1032
|
-
y,
|
|
1033
|
-
I,
|
|
1034
|
-
$,
|
|
1035
|
-
P,
|
|
1036
|
-
U,
|
|
1037
|
-
N,
|
|
1038
|
-
H,
|
|
1039
|
-
O,
|
|
1040
|
-
X,
|
|
1041
|
-
rt,
|
|
1042
|
-
K,
|
|
1043
|
-
// Element properties
|
|
1044
|
-
bt,
|
|
1045
|
-
wt,
|
|
1046
|
-
Et,
|
|
1047
|
-
St,
|
|
1048
|
-
Rt,
|
|
1049
|
-
It,
|
|
1050
|
-
Ct,
|
|
1051
|
-
Tt,
|
|
1052
|
-
Ot
|
|
1053
|
-
]);
|
|
1054
|
-
return s.current = _t, /* @__PURE__ */ k(ce.Provider, { value: r, children: /* @__PURE__ */ k(
|
|
1055
|
-
to,
|
|
1056
|
-
{
|
|
1057
|
-
value: {
|
|
1058
|
-
undo: P,
|
|
1059
|
-
redo: U,
|
|
1060
|
-
canUndo: N,
|
|
1061
|
-
canRedo: H,
|
|
1062
|
-
undoActiveArtboard: O,
|
|
1063
|
-
redoActiveArtboard: X,
|
|
1064
|
-
canUndoActiveArtboard: rt,
|
|
1065
|
-
canRedoActiveArtboard: K
|
|
1066
|
-
},
|
|
1067
|
-
children: /* @__PURE__ */ k(
|
|
1068
|
-
no,
|
|
1069
|
-
{
|
|
1070
|
-
value: {
|
|
1071
|
-
elements: p,
|
|
1072
|
-
elementStore: E,
|
|
1073
|
-
artboards: d,
|
|
1074
|
-
artboardManager: t,
|
|
1075
|
-
artboardVersion: F,
|
|
1076
|
-
setElements: h,
|
|
1077
|
-
refreshArtboards: L,
|
|
1078
|
-
getElementById: S,
|
|
1079
|
-
handleAddElement: vt,
|
|
1080
|
-
handleElementUpdate: G,
|
|
1081
|
-
handleLoadWorkspace: Nt,
|
|
1082
|
-
handleCopyElements: Ft,
|
|
1083
|
-
handlePasteElements: Pt,
|
|
1084
|
-
fontSize: bt,
|
|
1085
|
-
fontColor: wt,
|
|
1086
|
-
fontFamily: Et,
|
|
1087
|
-
textAlign: St,
|
|
1088
|
-
updateFontSize: Rt,
|
|
1089
|
-
setFontSizeValue: It,
|
|
1090
|
-
updateFontColor: Ct,
|
|
1091
|
-
updateFontFamily: Tt,
|
|
1092
|
-
updateTextAlign: Ot,
|
|
1093
|
-
canvasRef: o,
|
|
1094
|
-
canvasEditorRef: n
|
|
1095
|
-
},
|
|
1096
|
-
children: /* @__PURE__ */ k(
|
|
1097
|
-
ro,
|
|
1098
|
-
{
|
|
1099
|
-
value: {
|
|
1100
|
-
executeElementUpdate: _,
|
|
1101
|
-
executeAddElement: M,
|
|
1102
|
-
executeRemoveElement: l,
|
|
1103
|
-
executeReorderElement: f,
|
|
1104
|
-
executeCommandBatch: g,
|
|
1105
|
-
executeCreateArtboard: y,
|
|
1106
|
-
executeDeleteArtboard: I,
|
|
1107
|
-
executeUpdateArtboard: $,
|
|
1108
|
-
undo: P,
|
|
1109
|
-
redo: U,
|
|
1110
|
-
canUndo: N,
|
|
1111
|
-
canRedo: H,
|
|
1112
|
-
undoActiveArtboard: O,
|
|
1113
|
-
redoActiveArtboard: X,
|
|
1114
|
-
canUndoActiveArtboard: rt,
|
|
1115
|
-
canRedoActiveArtboard: K,
|
|
1116
|
-
historyManager: nt
|
|
1117
|
-
},
|
|
1118
|
-
children: /* @__PURE__ */ k(se.Provider, { value: _t, children: e })
|
|
1119
|
-
}
|
|
1120
|
-
)
|
|
1121
|
-
}
|
|
1122
|
-
)
|
|
1123
|
-
}
|
|
1124
|
-
) });
|
|
1125
|
-
}, Oo = ({
|
|
1126
|
-
children: e,
|
|
1127
|
-
initialArtboardConfig: t = {},
|
|
1128
|
-
viewPadding: o = 0.9
|
|
1129
|
-
}) => {
|
|
1130
|
-
const [n] = b(() => {
|
|
1131
|
-
const c = new ve(), i = {
|
|
1132
|
-
name: t.name || "Artboard 1",
|
|
1133
|
-
x: t.x ?? 0,
|
|
1134
|
-
y: t.y ?? 0,
|
|
1135
|
-
width: t.width ?? 1e3,
|
|
1136
|
-
height: t.height ?? 1e3,
|
|
1137
|
-
backgroundColor: t.backgroundColor || Oe
|
|
1138
|
-
};
|
|
1139
|
-
return c.createArtboard(i), c;
|
|
1140
|
-
}), s = pt(null), r = pt(null);
|
|
1141
|
-
return /* @__PURE__ */ k(
|
|
1142
|
-
Ze,
|
|
1143
|
-
{
|
|
1144
|
-
artboardManager: n,
|
|
1145
|
-
canvasRef: s,
|
|
1146
|
-
viewPadding: o,
|
|
1147
|
-
children: /* @__PURE__ */ k(qe, { children: /* @__PURE__ */ k(eo, { children: /* @__PURE__ */ k(
|
|
1148
|
-
so,
|
|
1149
|
-
{
|
|
1150
|
-
artboardManager: n,
|
|
1151
|
-
canvasRef: s,
|
|
1152
|
-
canvasEditorRef: r,
|
|
1153
|
-
children: e
|
|
1154
|
-
}
|
|
1155
|
-
) }) })
|
|
1156
|
-
}
|
|
1157
|
-
);
|
|
1158
|
-
}, vo = () => {
|
|
1159
|
-
const e = Y(se);
|
|
1160
|
-
if (!e)
|
|
1161
|
-
throw new Error("useEditor must be used within EditorProvider");
|
|
1162
|
-
return e;
|
|
1163
|
-
}, ut = [];
|
|
1164
|
-
function Fo(e) {
|
|
1165
|
-
ke() && ut.push(e);
|
|
1166
|
-
}
|
|
1167
|
-
function Po() {
|
|
1168
|
-
return [...ut];
|
|
1169
|
-
}
|
|
1170
|
-
function No() {
|
|
1171
|
-
ut.length = 0;
|
|
1172
|
-
}
|
|
1173
|
-
function zo() {
|
|
1174
|
-
if (ut.length === 0) return;
|
|
1175
|
-
const e = ut.map((t) => He(t) ? `${t.code}: ${t.message}` : `${t.name}: ${t.message}`).join(`
|
|
1176
|
-
- `);
|
|
1177
|
-
throw ut.length = 0, new Error(
|
|
1178
|
-
`expectNoEditorErrors: ${e.includes(`
|
|
1179
|
-
`) ? "errors were" : "an error was"} contained by <Editor.Root>'s boundary during this test:
|
|
1180
|
-
- ${e}
|
|
1181
|
-
A contained error renders an error card in prod — this composition is broken even if the test rendered "successfully".`
|
|
1182
|
-
);
|
|
1183
|
-
}
|
|
1184
|
-
const co = 1;
|
|
1185
|
-
function it(e) {
|
|
1186
|
-
return typeof e == "number" && Number.isFinite(e) ? Math.round(e * 100) / 100 : e;
|
|
1187
|
-
}
|
|
1188
|
-
function ae(e) {
|
|
1189
|
-
return {
|
|
1190
|
-
...e,
|
|
1191
|
-
...e.x !== void 0 && { x: it(e.x) },
|
|
1192
|
-
...e.y !== void 0 && { y: it(e.y) },
|
|
1193
|
-
...e.width !== void 0 && { width: it(e.width) },
|
|
1194
|
-
...e.height !== void 0 && { height: it(e.height) },
|
|
1195
|
-
...e.rotation !== void 0 && { rotation: it(e.rotation) }
|
|
1196
|
-
};
|
|
1197
|
-
}
|
|
1198
|
-
function ao(e) {
|
|
1199
|
-
var n, s;
|
|
1200
|
-
const t = (n = e.artboards) != null && n.length ? e.artboards : [{ name: "Front", width: 800, height: 800 }], o = t.map(() => []);
|
|
1201
|
-
for (const r of e.elements || []) {
|
|
1202
|
-
const c = r == null ? void 0 : r.artboard, i = typeof c == "string" ? t.findIndex((a) => (a.name || "Front") === c) : -1;
|
|
1203
|
-
(r == null ? void 0 : r.visible) !== !1 && o[i >= 0 ? i : 0].push(de(r));
|
|
1204
|
-
}
|
|
1205
|
-
return {
|
|
1206
|
-
schemaVersion: co,
|
|
1207
|
-
artboards: t.map((r, c) => ({
|
|
1208
|
-
id: `artboard-${c + 1}`,
|
|
1209
|
-
name: r.name || "Front",
|
|
1210
|
-
x: 0,
|
|
1211
|
-
y: 0,
|
|
1212
|
-
width: it(r.width || 800),
|
|
1213
|
-
height: it(r.height || 800),
|
|
1214
|
-
backgroundColor: r.backgroundColor || "transparent",
|
|
1215
|
-
// Pass the artboard's flag through — the server worker only paints the
|
|
1216
|
-
// background when this is true. Hardcoding `false` here silently dropped
|
|
1217
|
-
// explicitly-set artboard backgrounds from every realtime mockup while
|
|
1218
|
-
// the editor kept showing them (WYSIWYG drift).
|
|
1219
|
-
exportBackground: r.exportBackground ?? !1,
|
|
1220
|
-
elements: o[c],
|
|
1221
|
-
distressTexture: r.distressTexture,
|
|
1222
|
-
imageMask: r.imageMask
|
|
1223
|
-
})),
|
|
1224
|
-
// Custom (brand) font dependencies ride the wire so the server worker can
|
|
1225
|
-
// load them — without this, server renders of custom-font designs fall
|
|
1226
|
-
// back to the wrong family even when the bundle supports custom fonts.
|
|
1227
|
-
...(s = e.customFonts) != null && s.length ? { customFonts: e.customFonts } : {}
|
|
1228
|
-
};
|
|
1229
|
-
}
|
|
1230
|
-
function de(e) {
|
|
1231
|
-
const t = e.type || e.transformType;
|
|
1232
|
-
if (t === "image")
|
|
1233
|
-
return lo(e);
|
|
1234
|
-
const { artboard: o, ...n } = e;
|
|
1235
|
-
return t === "group" && Array.isArray(e.children) && (n.children = e.children.filter((s) => s && s.visible !== !1).map(de)), ae({
|
|
1236
|
-
...n,
|
|
1237
|
-
type: t
|
|
1238
|
-
});
|
|
1239
|
-
}
|
|
1240
|
-
function lo(e) {
|
|
1241
|
-
var d;
|
|
1242
|
-
const t = e.transformData || {}, o = Ue(e), n = Ve(t, o), s = t.width || 0, r = t.height || 0, c = s * n.cropWidth, i = r * n.cropHeight, a = {
|
|
1243
|
-
id: e.id,
|
|
1244
|
-
type: "image",
|
|
1245
|
-
x: e.x || 0,
|
|
1246
|
-
y: e.y || 0,
|
|
1247
|
-
width: c,
|
|
1248
|
-
height: i,
|
|
1249
|
-
rotation: e.rotation || 0,
|
|
1250
|
-
imageUrl: e.imageUrl,
|
|
1251
|
-
imageAspectRatio: e.imageAspectRatio
|
|
1252
|
-
};
|
|
1253
|
-
return De(n) || (a.cropX = n.cropX, a.cropY = n.cropY, a.cropWidth = n.cropWidth, a.cropHeight = n.cropHeight, a.needsCropPixelConversion = !0), t.flipHorizontal && (a.flipHorizontal = t.flipHorizontal), t.flipVertical && (a.flipVertical = t.flipVertical), t.borderRadius && (a.borderRadius = t.borderRadius), e.shadow && (a.shadow = e.shadow), _e(t.adjustments) || (a.adjustments = { ...t.adjustments }), e.opacity !== void 0 && (a.opacity = e.opacity), e.distressEffect && (a.distressEffect = e.distressEffect), ((d = e.masks) == null ? void 0 : d.length) > 0 && (a.masks = e.masks), e.blendMode && (a.blendMode = e.blendMode), e.knockoutParts && (a.knockoutParts = e.knockoutParts), e.stroke && (a.stroke = e.stroke), ae(a);
|
|
1254
|
-
}
|
|
1255
|
-
const Gt = "center", le = Symbol.for("snowcone.canvas.layerToken");
|
|
1256
|
-
function Ho(e) {
|
|
1257
|
-
return typeof e == "object" && e !== null && e[le] === !0 && typeof e.name == "string" && (e.kind === "text" || e.kind === "image");
|
|
1258
|
-
}
|
|
1259
|
-
function uo(e, t) {
|
|
1260
|
-
return Object.freeze({ kind: e, name: t, [le]: !0 });
|
|
1261
|
-
}
|
|
1262
|
-
const ue = Symbol.for("snowcone.canvas.colorToken");
|
|
1263
|
-
function mo(e) {
|
|
1264
|
-
return typeof e == "object" && e !== null && e[ue] === !0 && typeof e.name == "string" && typeof e.value == "string";
|
|
1265
|
-
}
|
|
1266
|
-
function ho(e, t) {
|
|
1267
|
-
return Object.freeze({ name: e, value: t, [ue]: !0 });
|
|
1268
|
-
}
|
|
1269
|
-
function fo(e) {
|
|
1270
|
-
let t = e.trim().toUpperCase();
|
|
1271
|
-
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;
|
|
1272
|
-
}
|
|
1273
|
-
function xt(e) {
|
|
1274
|
-
return mo(e) ? e.value : e;
|
|
1275
|
-
}
|
|
1276
|
-
function Vt(e) {
|
|
1277
|
-
const t = e.transformType;
|
|
1278
|
-
return t === "image" ? "image" : t === "shape" || t === "group" || t === "path" ? null : "text";
|
|
1279
|
-
}
|
|
1280
|
-
function po(e) {
|
|
1281
|
-
return e === "top-left" || e === "left" || e === "bottom-left" ? "left" : e === "top-right" || e === "right" || e === "bottom-right" ? "right" : "center";
|
|
1282
|
-
}
|
|
1283
|
-
function Ao(e) {
|
|
1284
|
-
return e === "top-left" || e === "top" || e === "top-right" ? "top" : e === "bottom-left" || e === "bottom" || e === "bottom-right" ? "bottom" : "middle";
|
|
1285
|
-
}
|
|
1286
|
-
function Ut(e, t, o, n, s, r) {
|
|
1287
|
-
const c = po(e), i = Ao(e), a = c === "left" ? t / 2 + r : c === "right" ? n - t / 2 - r : n / 2, d = i === "top" ? o / 2 + r : i === "bottom" ? s - o / 2 - r : s / 2;
|
|
1288
|
-
return { x: a, y: d };
|
|
1289
|
-
}
|
|
1290
|
-
function yo(e, t, o) {
|
|
1291
|
-
const n = t / o;
|
|
1292
|
-
if (e >= n) {
|
|
1293
|
-
const c = o * e, i = t / c;
|
|
1294
|
-
return {
|
|
1295
|
-
width: c,
|
|
1296
|
-
height: o,
|
|
1297
|
-
cropX: (1 - i) / 2,
|
|
1298
|
-
cropY: 0,
|
|
1299
|
-
cropWidth: i,
|
|
1300
|
-
cropHeight: 1
|
|
1301
|
-
};
|
|
1302
|
-
}
|
|
1303
|
-
const s = t / e, r = o / s;
|
|
1304
|
-
return {
|
|
1305
|
-
width: t,
|
|
1306
|
-
height: s,
|
|
1307
|
-
cropX: 0,
|
|
1308
|
-
cropY: (1 - r) / 2,
|
|
1309
|
-
cropWidth: 1,
|
|
1310
|
-
cropHeight: r
|
|
1311
|
-
};
|
|
1312
|
-
}
|
|
1313
|
-
class lt {
|
|
1314
|
-
constructor(t) {
|
|
1315
|
-
if (this.els = [], this.colorRoles = /* @__PURE__ */ new Map(), this.idCounter = 0, !(t.width > 0) || !(t.height > 0))
|
|
1316
|
-
throw new Error("design(): artboard width and height must be positive numbers");
|
|
1317
|
-
for (const [o, n] of Object.entries(t.colors ?? {})) {
|
|
1318
|
-
const s = fo(n);
|
|
1319
|
-
if (s === null)
|
|
1320
|
-
throw new ot(
|
|
1321
|
-
"E_COLOR_ROLE_INVALID",
|
|
1322
|
-
`color role "${o}" is ${JSON.stringify(n)} — roles must be #RGB/#RRGGBB hex (useColorBinding matches by normalized hex value; other syntaxes can't bind).`,
|
|
1323
|
-
{ roleName: o, value: n, docSlug: "embed-mode" }
|
|
1324
|
-
);
|
|
1325
|
-
const r = [...this.colorRoles.entries()].find(([, c]) => c === s);
|
|
1326
|
-
if (r)
|
|
1327
|
-
throw new ot(
|
|
1328
|
-
"E_COLOR_ROLE_COLLISION",
|
|
1329
|
-
`color roles "${r[0]}" and "${o}" both normalize to ${s}. useColorBinding matches elements by VALUE, so colliding roles would repaint each other's elements — give every role a distinct hex.`,
|
|
1330
|
-
{ roles: [r[0], o], value: s, docSlug: "embed-mode" }
|
|
1331
|
-
);
|
|
1332
|
-
this.colorRoles.set(o, s);
|
|
1333
|
-
}
|
|
1334
|
-
this.current = {
|
|
1335
|
-
name: t.name || "Front",
|
|
1336
|
-
width: t.width,
|
|
1337
|
-
height: t.height,
|
|
1338
|
-
backgroundColor: xt(t.backgroundColor),
|
|
1339
|
-
role: t.role
|
|
1340
|
-
}, this.activeName = this.current.name;
|
|
1341
|
-
}
|
|
1342
|
-
/**
|
|
1343
|
-
* Seed a builder from a previously saved canvas state — the editor shape
|
|
1344
|
-
* `<SnowconeCanvas onChange>` emits (and `toJSON()` produces).
|
|
1345
|
-
*
|
|
1346
|
-
* This is how a saved editable template re-enters the turnkey embed path:
|
|
1347
|
-
* load the template's state JSON, lift it back into a `DesignBuilder`, and
|
|
1348
|
-
* hand it to `<RealtimeEmbed design={…}>`. By default the active artboard
|
|
1349
|
-
* becomes the builder's artboard; elements tagged for other artboards are
|
|
1350
|
-
* skipped (untagged elements are assumed to belong to the active one).
|
|
1351
|
-
*
|
|
1352
|
-
* Pass `{ artboards: 'all' }` to load a multi-page template (ADR-0086)
|
|
1353
|
-
* whole: every artboard (with its pacing `role`) and every element are
|
|
1354
|
-
* kept, membership tags preserved, so `toJSON()` / `toServerRequest()`
|
|
1355
|
-
* emit all pages and `TemplateField.artboard` can scope fields per page.
|
|
1356
|
-
*/
|
|
1357
|
-
static fromState(t, o = {}) {
|
|
1358
|
-
const n = t.artboards.find((r) => r.name === t.activeArtboard) ?? t.artboards[0];
|
|
1359
|
-
if (!n)
|
|
1360
|
-
throw new Error("DesignBuilder.fromState(): state has no artboards");
|
|
1361
|
-
const s = new lt({
|
|
1362
|
-
name: n.name,
|
|
1363
|
-
width: n.width,
|
|
1364
|
-
height: n.height,
|
|
1365
|
-
backgroundColor: n.backgroundColor,
|
|
1366
|
-
role: n.role
|
|
1367
|
-
});
|
|
1368
|
-
if (o.artboards === "all") {
|
|
1369
|
-
s.allArtboards = t.artboards.map((r) => ({ ...r }));
|
|
1370
|
-
for (const r of t.elements)
|
|
1371
|
-
s.els.push(r.artboard ? { ...r } : { ...r, artboard: n.name });
|
|
1372
|
-
return s;
|
|
1373
|
-
}
|
|
1374
|
-
for (const r of t.elements)
|
|
1375
|
-
r.artboard && r.artboard !== n.name || s.els.push({ ...r });
|
|
1376
|
-
return s;
|
|
1377
|
-
}
|
|
1378
|
-
nextId(t) {
|
|
1379
|
-
return `${t}-${++this.idCounter}`;
|
|
1380
|
-
}
|
|
1381
|
-
/** A wire-shape snapshot of an authoring artboard, applying the same
|
|
1382
|
-
* background-export rule everywhere (a design background is part of the
|
|
1383
|
-
* design — exports and server renders paint it). */
|
|
1384
|
-
static snapshotArtboard(t) {
|
|
1385
|
-
return {
|
|
1386
|
-
name: t.name,
|
|
1387
|
-
width: t.width,
|
|
1388
|
-
height: t.height,
|
|
1389
|
-
...t.backgroundColor ? {
|
|
1390
|
-
backgroundColor: t.backgroundColor,
|
|
1391
|
-
exportBackground: t.backgroundColor !== "transparent"
|
|
1392
|
-
} : {},
|
|
1393
|
-
...t.role ? { role: t.role } : {}
|
|
1394
|
-
};
|
|
1395
|
-
}
|
|
1396
|
-
/**
|
|
1397
|
-
* Open a NEW artboard (placement) and make it the authoring context: layer
|
|
1398
|
-
* calls after this target the new artboard — anchor math uses its
|
|
1399
|
-
* dimensions, and the elements carry its membership tag (the public
|
|
1400
|
-
* `artboard` field, PR #482). The FIRST artboard (from `design({ name })`)
|
|
1401
|
-
* remains the initially-active placement when the design mounts; switch at
|
|
1402
|
-
* runtime with `usePlacements()` / `<Editor.Placements/>` (ADR-0088).
|
|
1403
|
-
*
|
|
1404
|
-
* `label` must be the product's placement label (case-sensitive) — the same
|
|
1405
|
-
* artboard-name-is-placement-label rule as `design({ name })`.
|
|
1406
|
-
*
|
|
1407
|
-
* ```ts
|
|
1408
|
-
* const seed = design({ name: 'Front', width: 1480, height: 2328 })
|
|
1409
|
-
* .text('YOUR NAME', { anchor: 'top', name: 'headline' })
|
|
1410
|
-
* .artboard('Back', { width: 1480, height: 2328 })
|
|
1411
|
-
* .text('EST. 2026', { anchor: 'center', name: 'backline' });
|
|
1412
|
-
* ```
|
|
1413
|
-
*
|
|
1414
|
-
* @throws EditorError `E_DUPLICATE_ARTBOARD` — the design already has an
|
|
1415
|
-
* artboard with this label.
|
|
1416
|
-
*/
|
|
1417
|
-
artboard(t, o) {
|
|
1418
|
-
if (!(o.width > 0) || !(o.height > 0))
|
|
1419
|
-
throw new Error("design().artboard(): width and height must be positive numbers");
|
|
1420
|
-
if (this.allArtboards || (this.allArtboards = [lt.snapshotArtboard(this.current)]), this.allArtboards.some((n) => n.name === t))
|
|
1421
|
-
throw new ot(
|
|
1422
|
-
"E_DUPLICATE_ARTBOARD",
|
|
1423
|
-
`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))}.`,
|
|
1424
|
-
{ artboardName: t, validNames: this.allArtboards.map((n) => n.name), docSlug: "embed-mode" }
|
|
1425
|
-
);
|
|
1426
|
-
for (const n of this.els)
|
|
1427
|
-
n.artboard || (n.artboard = this.current.name);
|
|
1428
|
-
return this.current = {
|
|
1429
|
-
name: t,
|
|
1430
|
-
width: o.width,
|
|
1431
|
-
height: o.height,
|
|
1432
|
-
backgroundColor: xt(o.backgroundColor),
|
|
1433
|
-
role: o.role
|
|
1434
|
-
}, this.allArtboards.push(lt.snapshotArtboard(this.current)), this;
|
|
1435
|
-
}
|
|
1436
|
-
background(t, o = {}) {
|
|
1437
|
-
const { width: n, height: s } = this.current;
|
|
1438
|
-
let r;
|
|
1439
|
-
if (o.aspectRatio && o.aspectRatio > 0) {
|
|
1440
|
-
const i = yo(o.aspectRatio, n, s);
|
|
1441
|
-
r = {
|
|
1442
|
-
type: "image",
|
|
1443
|
-
width: i.width,
|
|
1444
|
-
height: i.height,
|
|
1445
|
-
cropX: i.cropX,
|
|
1446
|
-
cropY: i.cropY,
|
|
1447
|
-
cropWidth: i.cropWidth,
|
|
1448
|
-
cropHeight: i.cropHeight,
|
|
1449
|
-
flipHorizontal: !1,
|
|
1450
|
-
flipVertical: !1,
|
|
1451
|
-
borderRadius: 0
|
|
1452
|
-
};
|
|
1453
|
-
} else
|
|
1454
|
-
r = {
|
|
1455
|
-
type: "image",
|
|
1456
|
-
width: n,
|
|
1457
|
-
height: s,
|
|
1458
|
-
cropX: 0,
|
|
1459
|
-
cropY: 0,
|
|
1460
|
-
cropWidth: 1,
|
|
1461
|
-
cropHeight: 1,
|
|
1462
|
-
flipHorizontal: !1,
|
|
1463
|
-
flipVertical: !1,
|
|
1464
|
-
borderRadius: 0
|
|
1465
|
-
};
|
|
1466
|
-
const c = {
|
|
1467
|
-
id: this.nextId("bg"),
|
|
1468
|
-
transformType: "image",
|
|
1469
|
-
x: n / 2,
|
|
1470
|
-
y: s / 2,
|
|
1471
|
-
rotation: 0,
|
|
1472
|
-
opacity: o.opacity ?? 1,
|
|
1473
|
-
imageUrl: t,
|
|
1474
|
-
imageAspectRatio: o.aspectRatio,
|
|
1475
|
-
transformData: r,
|
|
1476
|
-
name: o.name ?? "Background"
|
|
1477
|
-
};
|
|
1478
|
-
return this.els.unshift(c), this;
|
|
1479
|
-
}
|
|
1480
|
-
image(t, o = {}) {
|
|
1481
|
-
const { width: n, height: s } = this.current, r = o.width ?? Math.round(n / 3), c = o.height ?? (o.aspectRatio ? Math.round(r / o.aspectRatio) : r), { x: i, y: a } = Ut(o.anchor ?? Gt, r, c, n, s, o.padding ?? 0), d = {
|
|
1482
|
-
id: this.nextId("img"),
|
|
1483
|
-
transformType: "image",
|
|
1484
|
-
x: i,
|
|
1485
|
-
y: a,
|
|
1486
|
-
rotation: o.rotation ?? 0,
|
|
1487
|
-
opacity: o.opacity ?? 1,
|
|
1488
|
-
imageUrl: t,
|
|
1489
|
-
imageAspectRatio: o.aspectRatio,
|
|
1490
|
-
transformData: {
|
|
1491
|
-
type: "image",
|
|
1492
|
-
width: r,
|
|
1493
|
-
height: c,
|
|
1494
|
-
cropX: 0,
|
|
1495
|
-
cropY: 0,
|
|
1496
|
-
cropWidth: 1,
|
|
1497
|
-
cropHeight: 1,
|
|
1498
|
-
flipHorizontal: !1,
|
|
1499
|
-
flipVertical: !1,
|
|
1500
|
-
borderRadius: 0
|
|
1501
|
-
},
|
|
1502
|
-
...o.name ? { name: o.name } : {}
|
|
1503
|
-
};
|
|
1504
|
-
return this.els.push(d), this;
|
|
1505
|
-
}
|
|
1506
|
-
text(t, o = {}) {
|
|
1507
|
-
const { width: n, height: s } = this.current, r = o.fontSize ?? Math.round(this.current.height / 12), { x: c, y: i } = Ut(o.anchor ?? "top", 0, r, n, s, o.padding ?? Math.round(s / 20)), a = {
|
|
1508
|
-
id: this.nextId("text"),
|
|
1509
|
-
transformType: "custom",
|
|
1510
|
-
x: c,
|
|
1511
|
-
y: i,
|
|
1512
|
-
rotation: o.rotation ?? 0,
|
|
1513
|
-
text: t,
|
|
1514
|
-
fontSize: r,
|
|
1515
|
-
fontFamily: o.fontFamily ?? "Anton",
|
|
1516
|
-
color: xt(o.color) ?? "#ffffff",
|
|
1517
|
-
textAlign: o.textAlign ?? "center",
|
|
1518
|
-
bold: o.bold ?? !1,
|
|
1519
|
-
italic: o.italic ?? !1,
|
|
1520
|
-
transformData: { type: "custom" },
|
|
1521
|
-
...o.name ? { name: o.name } : {}
|
|
1522
|
-
};
|
|
1523
|
-
return this.els.push(a), this;
|
|
1524
|
-
}
|
|
1525
|
-
/**
|
|
1526
|
-
* Mint a {@link LayerToken} for a named layer — the only currency
|
|
1527
|
-
* `Editor.TextField` accepts (ADR-0085 §1). Compile time: `name` is
|
|
1528
|
-
* constrained to this design's declared layer names, kind inferred from
|
|
1529
|
-
* which per-kind union it falls in. Runtime: validated EAGERLY against the
|
|
1530
|
-
* built elements (nearest the mistake), so CMS/JSON-loaded designs get the
|
|
1531
|
-
* same protection with `string` typing.
|
|
1532
|
-
*
|
|
1533
|
-
* @throws EditorError `E_LAYER_NOT_FOUND` — no layer with this name; lists
|
|
1534
|
-
* the valid names per kind.
|
|
1535
|
-
* @throws EditorError `E_LAYER_WRONG_KIND` — the name matches a layer that
|
|
1536
|
-
* is not bindable (shape/group/path).
|
|
1537
|
-
*/
|
|
1538
|
-
layer(t) {
|
|
1539
|
-
const o = this.els.find((s) => s.name === t);
|
|
1540
|
-
if (!o) {
|
|
1541
|
-
const s = this.layerNamesOfKind("text"), r = this.layerNamesOfKind("image");
|
|
1542
|
-
throw new ot(
|
|
1543
|
-
"E_LAYER_NOT_FOUND",
|
|
1544
|
-
`no layer "${t}" in this design. Text layers: ${JSON.stringify(s)}; image layers: ${JSON.stringify(r)}. Fix the name, or add the layer first — e.g. design(…).text('…', { name: '${t}' }).`,
|
|
1545
|
-
{ layerName: t, validNames: [...s, ...r], textNames: s, imageNames: r, docSlug: "embed-mode" }
|
|
1546
|
-
);
|
|
1547
|
-
}
|
|
1548
|
-
const n = Vt(o);
|
|
1549
|
-
if (!n)
|
|
1550
|
-
throw new ot(
|
|
1551
|
-
"E_LAYER_WRONG_KIND",
|
|
1552
|
-
`layer "${t}" is a ${o.transformType} element — only text and image layers are bindable. Bindable layers: ${JSON.stringify([...this.layerNamesOfKind("text"), ...this.layerNamesOfKind("image")])}.`,
|
|
1553
|
-
{ layerName: t, actualType: o.transformType, docSlug: "embed-mode" }
|
|
1554
|
-
);
|
|
1555
|
-
return uo(n, t);
|
|
1556
|
-
}
|
|
1557
|
-
/**
|
|
1558
|
-
* Mint a {@link ColorToken} for a declared color role. Compile time: `name`
|
|
1559
|
-
* is constrained to the roles declared in `design({ colors })`. Runtime:
|
|
1560
|
-
* validated against the declared roles (CMS/JSON-built designs degrade to
|
|
1561
|
-
* `string` typing and rely on this throw).
|
|
1562
|
-
*
|
|
1563
|
-
* Use the token wherever the design paints the role (`fill`, `color`) AND
|
|
1564
|
-
* as the `useColorBinding` argument — one source of truth, no hand-synced
|
|
1565
|
-
* hex pairs.
|
|
1566
|
-
*
|
|
1567
|
-
* @throws EditorError `E_COLOR_ROLE_NOT_FOUND` — no role with this name;
|
|
1568
|
-
* lists the declared roles.
|
|
1569
|
-
*/
|
|
1570
|
-
color(t) {
|
|
1571
|
-
const o = this.colorRoles.get(t);
|
|
1572
|
-
if (o === void 0)
|
|
1573
|
-
throw new ot(
|
|
1574
|
-
"E_COLOR_ROLE_NOT_FOUND",
|
|
1575
|
-
`no color role "${t}" in this design. Declared roles: ${JSON.stringify([...this.colorRoles.keys()])}. Declare roles up front — design({ …, colors: { ${t}: '#FF2D8A' } }).`,
|
|
1576
|
-
{ roleName: t, validNames: [...this.colorRoles.keys()], docSlug: "embed-mode" }
|
|
1577
|
-
);
|
|
1578
|
-
return ho(t, o);
|
|
1579
|
-
}
|
|
1580
|
-
/** Names of bindable layers of one kind, in stack order. @internal */
|
|
1581
|
-
layerNamesOfKind(t) {
|
|
1582
|
-
return this.els.filter((o) => Vt(o) === t).map((o) => o.name).filter((o) => !!o);
|
|
1583
|
-
}
|
|
1584
|
-
/** An anchored vector shape. */
|
|
1585
|
-
shape(t, o = {}) {
|
|
1586
|
-
const { width: n, height: s } = this.current, r = o.size ?? Math.round(n / 6), c = typeof r == "number" ? r : r.width, i = typeof r == "number" ? r : r.height, { x: a, y: d } = Ut(o.anchor ?? Gt, c, i, n, s, o.padding ?? 0), z = {
|
|
1587
|
-
type: "shape",
|
|
1588
|
-
shapeType: t,
|
|
1589
|
-
width: c,
|
|
1590
|
-
height: i,
|
|
1591
|
-
fillColor: xt(o.fill) ?? "#000000",
|
|
1592
|
-
fillOpacity: o.opacity ?? 1,
|
|
1593
|
-
...o.points !== void 0 ? { points: o.points } : {},
|
|
1594
|
-
...o.sides !== void 0 ? { sides: o.sides } : {}
|
|
1595
|
-
}, F = {
|
|
1596
|
-
id: this.nextId("shape"),
|
|
1597
|
-
transformType: "shape",
|
|
1598
|
-
x: a,
|
|
1599
|
-
y: d,
|
|
1600
|
-
rotation: o.rotation ?? 0,
|
|
1601
|
-
transformData: z,
|
|
1602
|
-
...o.name ? { name: o.name } : {}
|
|
1603
|
-
};
|
|
1604
|
-
return this.els.push(F), this;
|
|
1605
|
-
}
|
|
1606
|
-
/** The composed elements, in render order (background first). Editor shape. */
|
|
1607
|
-
get elements() {
|
|
1608
|
-
return this.els.map((t) => ({ ...t }));
|
|
1609
|
-
}
|
|
1610
|
-
/** Editor-shape canvas state for `<SnowconeCanvas initialElements=… />` and
|
|
1611
|
-
* `serializeStateForServer`. `activeArtboard` is the artboard name. A
|
|
1612
|
-
* builder loaded with `fromState(…, { artboards: 'all' })` emits every
|
|
1613
|
-
* page (artboard `role`s and element membership tags included). */
|
|
1614
|
-
toJSON() {
|
|
1615
|
-
return this.allArtboards ? {
|
|
1616
|
-
// Elements added via builder methods since the last context switch are
|
|
1617
|
-
// untagged — they belong to the CURRENT authoring artboard; stamp them
|
|
1618
|
-
// so the multi-artboard state groups them correctly.
|
|
1619
|
-
elements: this.els.map(
|
|
1620
|
-
(t) => t.artboard ? { ...t } : { ...t, artboard: this.current.name }
|
|
1621
|
-
),
|
|
1622
|
-
artboards: this.allArtboards.map((t) => ({ ...t })),
|
|
1623
|
-
// The initially-active placement (first artboard / saved state's
|
|
1624
|
-
// active) — NOT the last `.artboard()` authoring context.
|
|
1625
|
-
activeArtboard: this.activeName
|
|
1626
|
-
} : {
|
|
1627
|
-
elements: this.elements,
|
|
1628
|
-
// A background set on a design is part of the design: flag it renderable
|
|
1629
|
-
// so exports and server renders paint it, matching the editor (the
|
|
1630
|
-
// export worker skips it without `exportBackground`) — see snapshotArtboard.
|
|
1631
|
-
artboards: [lt.snapshotArtboard(this.current)],
|
|
1632
|
-
activeArtboard: this.current.name
|
|
1633
|
-
};
|
|
1634
|
-
}
|
|
1635
|
-
/** Server-render payload for `RenderSession.renderState(placement, …)`.
|
|
1636
|
-
* Equivalent to `serializeStateForServer(design.toJSON())`. */
|
|
1637
|
-
toServerRequest() {
|
|
1638
|
-
return ao(this.toJSON());
|
|
1639
|
-
}
|
|
1640
|
-
}
|
|
1641
|
-
function ko(e) {
|
|
1642
|
-
return new lt(e);
|
|
1643
|
-
}
|
|
1644
|
-
function Uo(e) {
|
|
1645
|
-
return Vt(e);
|
|
1646
|
-
}
|
|
1647
|
-
export {
|
|
1648
|
-
Jt as B,
|
|
1649
|
-
co as C,
|
|
1650
|
-
lt as D,
|
|
1651
|
-
Oo as E,
|
|
1652
|
-
qt as P,
|
|
1653
|
-
Co as a,
|
|
1654
|
-
vo as b,
|
|
1655
|
-
Qe as c,
|
|
1656
|
-
Je as d,
|
|
1657
|
-
ko as e,
|
|
1658
|
-
zo as f,
|
|
1659
|
-
Po as g,
|
|
1660
|
-
mo as h,
|
|
1661
|
-
Ho as i,
|
|
1662
|
-
We as j,
|
|
1663
|
-
Ro as k,
|
|
1664
|
-
Uo as l,
|
|
1665
|
-
oo as m,
|
|
1666
|
-
Fo as n,
|
|
1667
|
-
wo as o,
|
|
1668
|
-
Eo as p,
|
|
1669
|
-
To as q,
|
|
1670
|
-
No as r,
|
|
1671
|
-
ao as s,
|
|
1672
|
-
Me as t,
|
|
1673
|
-
Io as u,
|
|
1674
|
-
So as v
|
|
1675
|
-
};
|
|
1676
|
-
//# sourceMappingURL=design-builder-DUEwCUmA.js.map
|