@snowcone-app/canvas 0.33.0 → 0.34.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-CLDFENZq.js → ContextualToolbars-BxnFwtTH.js} +4 -4
- package/dist/{ContextualToolbars-CLDFENZq.js.map → ContextualToolbars-BxnFwtTH.js.map} +1 -1
- package/dist/{EditorCanvasImpl-XP_t-tNl.js → EditorCanvasImpl-B9GjC1h6.js} +6 -6
- package/dist/{EditorCanvasImpl-XP_t-tNl.js.map → EditorCanvasImpl-B9GjC1h6.js.map} +1 -1
- package/dist/ImagePanel-Ih9e9cOQ.js +984 -0
- package/dist/ImagePanel-Ih9e9cOQ.js.map +1 -0
- package/dist/{SnowconeCanvas-wMLBZJ9z.js → SnowconeCanvas-B4Nhk7JQ.js} +7 -7
- package/dist/{SnowconeCanvas-wMLBZJ9z.js.map → SnowconeCanvas-B4Nhk7JQ.js.map} +1 -1
- package/dist/advanced.mjs +9 -9
- package/dist/components/ImageBrowserDrawer.d.ts +4 -1
- package/dist/contexts/CanvasServicesContext.d.ts +17 -1
- package/dist/{custom-icons-DTWtkJ9N.js → custom-icons-CblWjgt-.js} +2 -2
- package/dist/{custom-icons-DTWtkJ9N.js.map → custom-icons-CblWjgt-.js.map} +1 -1
- package/dist/{design-builder-BpbYUYtK.js → design-builder-D4izkvlb.js} +156 -152
- package/dist/{design-builder-BpbYUYtK.js.map → design-builder-D4izkvlb.js.map} +1 -1
- package/dist/{embed-VTcnrkRj.js → embed-CxSoTDTw.js} +6 -6
- package/dist/{embed-VTcnrkRj.js.map → embed-CxSoTDTw.js.map} +1 -1
- package/dist/embed.mjs +4 -4
- package/dist/index.mjs +7 -7
- package/dist/rendering/serialize-for-server.d.ts +14 -0
- package/dist/services/imageSearch.d.ts +24 -0
- package/dist/style.css +1 -1
- package/dist/{template-fields-D-2oLhCi.js → template-fields-ClO9mflO.js} +3 -3
- package/dist/{template-fields-D-2oLhCi.js.map → template-fields-ClO9mflO.js.map} +1 -1
- package/dist/testing.mjs +2 -2
- package/dist/{useCommands-DwnZHUg8.js → useCommands-Bj9QHZ35.js} +514 -496
- package/dist/{useCommands-DwnZHUg8.js.map → useCommands-Bj9QHZ35.js.map} +1 -1
- package/dist/{validation-CSa86fDE.js → validation-BU8STi7a.js} +8 -8
- package/dist/{validation-CSa86fDE.js.map → validation-BU8STi7a.js.map} +1 -1
- package/example/package.json +1 -1
- package/package.json +3 -3
- package/dist/ImagePanel-ntJBepby.js +0 -951
- package/dist/ImagePanel-ntJBepby.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as k } from "react/jsx-runtime";
|
|
2
2
|
import { useContext as Y, useSyncExternalStore as pe, useCallback as m, createContext as Q, useRef as pt, useState as b, useEffect as Dt, useMemo as q } from "react";
|
|
3
|
-
import { a0 as Ae, E as ot, U as ye, aq as ge, G as jt, ar as xe, as as be, at as we, au as Ee, av as Se, c as Zt, C as Re, aw as Ce, ax as Ie, ay as Te, W as Oe, _ as Wt, I as
|
|
3
|
+
import { a0 as Ae, E as ot, U as ye, aq as ge, G as jt, ar as xe, as as be, at as we, au as Ee, av as Se, c as Zt, C as Re, aw as Ce, ax as Ie, ay as Te, W as Oe, _ as Wt, I as Fe, g as ve, S as Pe, az as Ne, aA as Mt, y as ze, D as He, M as ke } from "./FontAnalyzer-BrKY6XYn.js";
|
|
4
4
|
const Jt = Q(null), Ue = () => () => {
|
|
5
5
|
}, Yt = () => 0;
|
|
6
6
|
function go() {
|
|
@@ -18,11 +18,11 @@ function go() {
|
|
|
18
18
|
}
|
|
19
19
|
const gt = Zt("useCommandHistory");
|
|
20
20
|
function Ve(e, t, o, n) {
|
|
21
|
-
const
|
|
21
|
+
const s = pt(new Ae(o)), i = Y(Jt), c = m(
|
|
22
22
|
(l, f) => {
|
|
23
23
|
const g = l == null ? void 0 : l.name;
|
|
24
|
-
if (!
|
|
25
|
-
const y =
|
|
24
|
+
if (!i || !g) return;
|
|
25
|
+
const y = i.getBoundLayer(g);
|
|
26
26
|
if (y)
|
|
27
27
|
throw new ot(
|
|
28
28
|
"E_BOUND_LAYER_MUTATION",
|
|
@@ -30,7 +30,7 @@ function Ve(e, t, o, n) {
|
|
|
30
30
|
{ layer: g, part: y.part, operation: f, docSlug: "embed-mode" }
|
|
31
31
|
);
|
|
32
32
|
},
|
|
33
|
-
[
|
|
33
|
+
[i]
|
|
34
34
|
), [r, d] = b({
|
|
35
35
|
canUndo: !1,
|
|
36
36
|
canRedo: !1,
|
|
@@ -38,7 +38,7 @@ function Ve(e, t, o, n) {
|
|
|
38
38
|
canUndoActiveArtboard: !1,
|
|
39
39
|
canRedoActiveArtboard: !1
|
|
40
40
|
}), a = m(() => {
|
|
41
|
-
const l =
|
|
41
|
+
const l = s.current, f = o.getActiveArtboardId();
|
|
42
42
|
d({
|
|
43
43
|
canUndo: l.canUndo(),
|
|
44
44
|
canRedo: l.canRedo(),
|
|
@@ -58,15 +58,15 @@ function Ve(e, t, o, n) {
|
|
|
58
58
|
}
|
|
59
59
|
), y = o.getArtboardIdForElement(f.id);
|
|
60
60
|
if (y)
|
|
61
|
-
|
|
61
|
+
s.current.executeOnArtboard(y, g);
|
|
62
62
|
else {
|
|
63
63
|
const C = o.getActiveArtboardId();
|
|
64
|
-
C &&
|
|
64
|
+
C && s.current.executeOnArtboard(C, g);
|
|
65
65
|
}
|
|
66
66
|
a();
|
|
67
67
|
},
|
|
68
68
|
[t, o, a, c]
|
|
69
|
-
),
|
|
69
|
+
), v = m(
|
|
70
70
|
(l, f, g, y) => {
|
|
71
71
|
const C = f || o.getActiveArtboardId();
|
|
72
72
|
if (!C) {
|
|
@@ -111,7 +111,7 @@ function Ve(e, t, o, n) {
|
|
|
111
111
|
t((U) => U.filter((N) => N.id !== P)), o.removeElementFromArtboard(P);
|
|
112
112
|
}
|
|
113
113
|
);
|
|
114
|
-
|
|
114
|
+
s.current.executeOnArtboard(C, $), a();
|
|
115
115
|
},
|
|
116
116
|
[t, o, a]
|
|
117
117
|
), V = m(
|
|
@@ -131,25 +131,25 @@ function Ve(e, t, o, n) {
|
|
|
131
131
|
t((C) => C.filter(($) => $.id !== y)), o.removeElementFromArtboard(y);
|
|
132
132
|
}
|
|
133
133
|
);
|
|
134
|
-
|
|
134
|
+
s.current.executeOnArtboard(f, g), a();
|
|
135
135
|
},
|
|
136
136
|
[t, o, a, c]
|
|
137
137
|
), E = m(
|
|
138
138
|
(l) => {
|
|
139
139
|
const f = new be(l, o);
|
|
140
|
-
|
|
140
|
+
s.current.executeGlobal(f), a(), n == null || n();
|
|
141
141
|
},
|
|
142
142
|
[o, a, n]
|
|
143
143
|
), D = m(
|
|
144
144
|
(l) => {
|
|
145
145
|
const f = new we(l, o);
|
|
146
|
-
|
|
146
|
+
s.current.executeGlobal(f), a(), n == null || n();
|
|
147
147
|
},
|
|
148
148
|
[o, a, n]
|
|
149
149
|
), p = m(
|
|
150
150
|
(l, f, g) => {
|
|
151
151
|
const y = new Ee(l, f, g, o);
|
|
152
|
-
|
|
152
|
+
s.current.executeGlobal(y), a(), n == null || n();
|
|
153
153
|
},
|
|
154
154
|
[o, a, n]
|
|
155
155
|
), h = m(
|
|
@@ -169,24 +169,24 @@ function Ve(e, t, o, n) {
|
|
|
169
169
|
y.undo();
|
|
170
170
|
}
|
|
171
171
|
}());
|
|
172
|
-
|
|
172
|
+
s.current.executeBatchOnArtboard(f, g), a();
|
|
173
173
|
},
|
|
174
174
|
[o, a]
|
|
175
175
|
), S = m(() => {
|
|
176
|
-
|
|
177
|
-
}, [a, n]),
|
|
178
|
-
|
|
176
|
+
s.current.undo() && (a(), n == null || n());
|
|
177
|
+
}, [a, n]), F = m(() => {
|
|
178
|
+
s.current.redo() && (a(), n == null || n());
|
|
179
179
|
}, [a, n]), R = m(() => {
|
|
180
180
|
const l = o.getActiveArtboardId();
|
|
181
|
-
l &&
|
|
181
|
+
l && s.current.undoArtboard(l) && (a(), n == null || n());
|
|
182
182
|
}, [o, a, n]), w = m(() => {
|
|
183
183
|
const l = o.getActiveArtboardId();
|
|
184
|
-
l &&
|
|
184
|
+
l && s.current.redoArtboard(l) && (a(), n == null || n());
|
|
185
185
|
}, [o, a, n]), L = m(() => {
|
|
186
|
-
|
|
186
|
+
s.current.clear(), a();
|
|
187
187
|
}, [a]), nt = m(
|
|
188
188
|
(l) => {
|
|
189
|
-
|
|
189
|
+
s.current.clearArtboardHistory(l), a();
|
|
190
190
|
},
|
|
191
191
|
[a]
|
|
192
192
|
), _ = pt(null);
|
|
@@ -207,14 +207,14 @@ function Ve(e, t, o, n) {
|
|
|
207
207
|
return P.map((H) => N.get(H)).filter(Boolean);
|
|
208
208
|
});
|
|
209
209
|
});
|
|
210
|
-
|
|
210
|
+
s.current.executeOnArtboard(C, $), a();
|
|
211
211
|
},
|
|
212
212
|
[e, t, o, a]
|
|
213
213
|
);
|
|
214
214
|
return {
|
|
215
215
|
// Element operations
|
|
216
216
|
executeElementUpdate: z,
|
|
217
|
-
executeAddElement:
|
|
217
|
+
executeAddElement: v,
|
|
218
218
|
executeRemoveElement: V,
|
|
219
219
|
executeReorderElement: M,
|
|
220
220
|
// Batch operations
|
|
@@ -225,7 +225,7 @@ function Ve(e, t, o, n) {
|
|
|
225
225
|
executeUpdateArtboard: p,
|
|
226
226
|
// Undo/redo (smart - considers last operation and active artboard)
|
|
227
227
|
undo: S,
|
|
228
|
-
redo:
|
|
228
|
+
redo: F,
|
|
229
229
|
// Undo/redo for active artboard only (element operations)
|
|
230
230
|
undoActiveArtboard: R,
|
|
231
231
|
redoActiveArtboard: w,
|
|
@@ -237,18 +237,18 @@ function Ve(e, t, o, n) {
|
|
|
237
237
|
// State for active artboard only
|
|
238
238
|
canUndoActiveArtboard: r.canUndoActiveArtboard,
|
|
239
239
|
canRedoActiveArtboard: r.canRedoActiveArtboard,
|
|
240
|
-
historyManager:
|
|
240
|
+
historyManager: s.current
|
|
241
241
|
};
|
|
242
242
|
}
|
|
243
243
|
function dt(e) {
|
|
244
244
|
return e && "fontSize" in e && "color" in e && "fontFamily" in e;
|
|
245
245
|
}
|
|
246
246
|
function De(e, t) {
|
|
247
|
-
const [o, n] = b(32), [
|
|
247
|
+
const [o, n] = b(32), [s, i] = b("#333333"), [c, r] = b("Arial"), [d, a] = b("center");
|
|
248
248
|
Dt(() => {
|
|
249
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,
|
|
251
|
-
n((R) => R !== p ? p : R),
|
|
250
|
+
const p = e.transformType === "circle" && "getEffectiveFontSize" in e ? Math.round(e.getEffectiveFontSize()) : Math.round(e.fontSize), h = e.color, S = e.fontFamily, F = e.textAlign;
|
|
251
|
+
n((R) => R !== p ? p : R), i((R) => R !== h ? h : R), r((R) => R !== S ? S : R), a((R) => R !== F ? F : R);
|
|
252
252
|
}
|
|
253
253
|
}, [e]);
|
|
254
254
|
const z = m(
|
|
@@ -260,7 +260,7 @@ function De(e, t) {
|
|
|
260
260
|
S.transformType === "circle" && "setEffectiveFontSize" in S ? S.setEffectiveFontSize(h) : S.setFontSize(h), t(S);
|
|
261
261
|
},
|
|
262
262
|
[e, o, t]
|
|
263
|
-
),
|
|
263
|
+
), v = m(
|
|
264
264
|
(p) => {
|
|
265
265
|
if (!e || !dt(e)) return;
|
|
266
266
|
n(p);
|
|
@@ -271,7 +271,7 @@ function De(e, t) {
|
|
|
271
271
|
), V = m(
|
|
272
272
|
(p) => {
|
|
273
273
|
if (!e || !dt(e)) return;
|
|
274
|
-
|
|
274
|
+
i(p);
|
|
275
275
|
const h = e.clone();
|
|
276
276
|
if (h.color = p, h.richText)
|
|
277
277
|
for (const S of h.richText.spans)
|
|
@@ -300,17 +300,17 @@ function De(e, t) {
|
|
|
300
300
|
return {
|
|
301
301
|
// State
|
|
302
302
|
fontSize: o,
|
|
303
|
-
fontColor:
|
|
303
|
+
fontColor: s,
|
|
304
304
|
fontFamily: c,
|
|
305
305
|
textAlign: d,
|
|
306
306
|
// State setters (for UI only)
|
|
307
307
|
setFontSize: n,
|
|
308
|
-
setFontColor:
|
|
308
|
+
setFontColor: i,
|
|
309
309
|
setFontFamily: r,
|
|
310
310
|
setTextAlign: a,
|
|
311
311
|
// Update functions (update element + UI)
|
|
312
312
|
updateFontSize: z,
|
|
313
|
-
setFontSizeValue:
|
|
313
|
+
setFontSizeValue: v,
|
|
314
314
|
updateFontColor: V,
|
|
315
315
|
updateFontFamily: E,
|
|
316
316
|
updateTextAlign: D
|
|
@@ -323,11 +323,11 @@ function _e(e) {
|
|
|
323
323
|
let t = e;
|
|
324
324
|
const o = [];
|
|
325
325
|
for (; t; ) {
|
|
326
|
-
const n = t.id ? `#${t.id}` : "",
|
|
327
|
-
if (o.push(`${t.tagName.toLowerCase()}${n}${
|
|
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
328
|
return !0;
|
|
329
|
-
const
|
|
330
|
-
if (
|
|
329
|
+
const i = t.getAttribute("role");
|
|
330
|
+
if (i === "dialog" || i === "alertdialog" || i === "menu" || i === "listbox")
|
|
331
331
|
return !0;
|
|
332
332
|
const c = t.getAttribute("data-slot");
|
|
333
333
|
if (c && (c.includes("popover") || c.includes("dialog")) || t.hasAttribute("data-radix-popper-content-wrapper"))
|
|
@@ -351,21 +351,21 @@ function Qt(e) {
|
|
|
351
351
|
const t = e.trim();
|
|
352
352
|
if (t.startsWith("#")) {
|
|
353
353
|
const n = t.slice(1);
|
|
354
|
-
let
|
|
354
|
+
let s, i, c;
|
|
355
355
|
if (n.length === 3)
|
|
356
|
-
|
|
356
|
+
s = parseInt(n[0] + n[0], 16), i = parseInt(n[1] + n[1], 16), c = parseInt(n[2] + n[2], 16);
|
|
357
357
|
else if (n.length === 6)
|
|
358
|
-
|
|
358
|
+
s = parseInt(n.slice(0, 2), 16), i = parseInt(n.slice(2, 4), 16), c = parseInt(n.slice(4, 6), 16);
|
|
359
359
|
else return null;
|
|
360
|
-
return Number.isNaN(
|
|
360
|
+
return Number.isNaN(s) || Number.isNaN(i) || Number.isNaN(c) ? null : Xt(s, i, c);
|
|
361
361
|
}
|
|
362
362
|
const o = t.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);
|
|
363
363
|
return o ? Xt(Number(o[1]), Number(o[2]), Number(o[3])) : null;
|
|
364
364
|
}
|
|
365
365
|
function Xt(e, t, o) {
|
|
366
|
-
const n = (
|
|
367
|
-
const
|
|
368
|
-
return
|
|
366
|
+
const n = (s) => {
|
|
367
|
+
const i = s / 255;
|
|
368
|
+
return i <= 0.03928 ? i / 12.92 : Math.pow((i + 0.055) / 1.055, 2.4);
|
|
369
369
|
};
|
|
370
370
|
return 0.2126 * n(e) + 0.7152 * n(t) + 0.0722 * n(o);
|
|
371
371
|
}
|
|
@@ -379,45 +379,45 @@ const te = Q(null), Me = 0.1, Ye = 4, Gt = 0.25, Xe = ({
|
|
|
379
379
|
canvasRef: o,
|
|
380
380
|
viewPadding: n = 0.9
|
|
381
381
|
}) => {
|
|
382
|
-
const [
|
|
383
|
-
|
|
382
|
+
const [s, i] = b(1), [c, r] = b({ x: 0, y: 0 }), [d, a] = b(!1), [z, v] = b(1), V = m(() => {
|
|
383
|
+
v(1), r({ x: 0, y: 0 });
|
|
384
384
|
}, []), E = m(() => {
|
|
385
|
-
|
|
385
|
+
i((F) => Math.min(F + Gt, Ye));
|
|
386
386
|
}, []), D = m(() => {
|
|
387
|
-
|
|
387
|
+
i((F) => Math.max(F - Gt, Me));
|
|
388
388
|
}, []), p = m(() => {
|
|
389
|
-
const
|
|
390
|
-
if (!
|
|
389
|
+
const F = t.getActiveArtboard();
|
|
390
|
+
if (!F || !o.current) return;
|
|
391
391
|
let R = o.current.parentElement, w = 0, L = 0;
|
|
392
392
|
for (; R && (w = R.clientWidth, L = R.clientHeight, !(w > 0 && L > 0)); )
|
|
393
393
|
R = R.parentElement;
|
|
394
394
|
if (!w || !L) return;
|
|
395
395
|
const nt = Math.min(
|
|
396
|
-
w * n /
|
|
397
|
-
L * n /
|
|
396
|
+
w * n / F.width,
|
|
397
|
+
L * n / F.height,
|
|
398
398
|
1
|
|
399
399
|
// Never zoom in beyond 100%
|
|
400
400
|
);
|
|
401
|
-
|
|
401
|
+
i(nt), r({ x: 0, y: 0 });
|
|
402
402
|
}, [t, o, n]), h = m(() => {
|
|
403
|
-
|
|
403
|
+
i(1), r({ x: 0, y: 0 });
|
|
404
404
|
}, []), S = q(
|
|
405
405
|
() => ({
|
|
406
|
-
zoom:
|
|
406
|
+
zoom: s,
|
|
407
407
|
panOffset: c,
|
|
408
408
|
isPanning: d,
|
|
409
409
|
zoomIn: E,
|
|
410
410
|
zoomOut: D,
|
|
411
411
|
zoomToFit: p,
|
|
412
412
|
resetView: h,
|
|
413
|
-
setZoom:
|
|
413
|
+
setZoom: i,
|
|
414
414
|
setPanOffset: r,
|
|
415
415
|
setIsPanning: a,
|
|
416
416
|
userZoom: z,
|
|
417
|
-
setUserZoom:
|
|
417
|
+
setUserZoom: v,
|
|
418
418
|
resetUserView: V
|
|
419
419
|
}),
|
|
420
|
-
[
|
|
420
|
+
[s, c, d, E, D, p, h, z, V]
|
|
421
421
|
);
|
|
422
422
|
return /* @__PURE__ */ k(te.Provider, { value: S, children: e });
|
|
423
423
|
};
|
|
@@ -428,7 +428,7 @@ function Ge() {
|
|
|
428
428
|
return e;
|
|
429
429
|
}
|
|
430
430
|
const ee = Q(null), Ke = ({ children: e }) => {
|
|
431
|
-
const [t, o] = b(null), [n,
|
|
431
|
+
const [t, o] = b(null), [n, s] = b([]), [i, c] = b(null), [r, d] = b(null), [a, z] = b(!1), v = m((D) => {
|
|
432
432
|
o(D);
|
|
433
433
|
}, []), V = m((D) => {
|
|
434
434
|
c(D);
|
|
@@ -436,23 +436,23 @@ const ee = Q(null), Ke = ({ children: e }) => {
|
|
|
436
436
|
() => ({
|
|
437
437
|
selectedId: t,
|
|
438
438
|
multiSelection: n,
|
|
439
|
-
activeChildElement:
|
|
439
|
+
activeChildElement: i,
|
|
440
440
|
hoveredElementId: r,
|
|
441
441
|
hideHandles: a,
|
|
442
442
|
setSelectedId: o,
|
|
443
|
-
setMultiSelection:
|
|
443
|
+
setMultiSelection: s,
|
|
444
444
|
setHoveredElementId: d,
|
|
445
445
|
setHideHandles: z,
|
|
446
|
-
handleSelectionChange:
|
|
446
|
+
handleSelectionChange: v,
|
|
447
447
|
handleActiveChildChange: V
|
|
448
448
|
}),
|
|
449
449
|
[
|
|
450
450
|
t,
|
|
451
451
|
n,
|
|
452
|
-
|
|
452
|
+
i,
|
|
453
453
|
r,
|
|
454
454
|
a,
|
|
455
|
-
|
|
455
|
+
v,
|
|
456
456
|
V
|
|
457
457
|
]
|
|
458
458
|
);
|
|
@@ -496,22 +496,22 @@ function wo() {
|
|
|
496
496
|
return e;
|
|
497
497
|
}
|
|
498
498
|
const ne = Q(null), Je = ({ children: e }) => {
|
|
499
|
-
const [t, o] = b(null), [n,
|
|
499
|
+
const [t, o] = b(null), [n, s] = b(!1), [i, c] = b(0), [r, d] = b(!1), [a, z] = b(!1), v = q(
|
|
500
500
|
() => ({
|
|
501
501
|
expandedPanelType: t,
|
|
502
502
|
setExpandedPanelType: o,
|
|
503
503
|
isToolbarMenuOpen: n,
|
|
504
|
-
setIsToolbarMenuOpen:
|
|
505
|
-
textSelectionVersion:
|
|
504
|
+
setIsToolbarMenuOpen: s,
|
|
505
|
+
textSelectionVersion: i,
|
|
506
506
|
setTextSelectionVersion: c,
|
|
507
507
|
isCanvasReady: r,
|
|
508
508
|
setCanvasReady: d,
|
|
509
509
|
isRotating: a,
|
|
510
510
|
setIsRotating: z
|
|
511
511
|
}),
|
|
512
|
-
[t, n,
|
|
512
|
+
[t, n, i, r, a]
|
|
513
513
|
);
|
|
514
|
-
return /* @__PURE__ */ k(ne.Provider, { value:
|
|
514
|
+
return /* @__PURE__ */ k(ne.Provider, { value: v, children: e });
|
|
515
515
|
};
|
|
516
516
|
function qe() {
|
|
517
517
|
const e = Y(ne);
|
|
@@ -637,9 +637,9 @@ const eo = Zt("EditorContext"), se = Q(null), ce = Q(null), Ro = () => {
|
|
|
637
637
|
throw new Error("useEditorHandles must be used within EditorProvider");
|
|
638
638
|
return e;
|
|
639
639
|
}, oo = ({ children: e, artboardManager: t, canvasRef: o, canvasEditorRef: n }) => {
|
|
640
|
-
const
|
|
640
|
+
const s = pt(null), i = q(() => ({ get: () => s.current }), []), c = Ge(), r = je(), d = qe(), [a, z] = b(
|
|
641
641
|
() => t.getAllArtboards()
|
|
642
|
-
), [
|
|
642
|
+
), [v, V] = b(0), [E, D] = b(
|
|
643
643
|
() => new Wt()
|
|
644
644
|
), p = q(() => E.toArray(), [E]), h = m((u) => {
|
|
645
645
|
D((A) => {
|
|
@@ -649,7 +649,7 @@ const eo = Zt("EditorContext"), se = Q(null), ce = Q(null), Ro = () => {
|
|
|
649
649
|
}, []), S = m(
|
|
650
650
|
(u) => E.get(u),
|
|
651
651
|
[E]
|
|
652
|
-
), [
|
|
652
|
+
), [F, R] = b([]), w = r.selectedId ? E.get(r.selectedId) : void 0, L = m(() => {
|
|
653
653
|
z([...t.getAllArtboards()]), V((u) => u + 1);
|
|
654
654
|
}, [t]), {
|
|
655
655
|
historyManager: nt,
|
|
@@ -712,7 +712,7 @@ const eo = Zt("EditorContext"), se = Q(null), ce = Q(null), Ro = () => {
|
|
|
712
712
|
);
|
|
713
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
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
|
|
715
|
+
const ft = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==", et = 200 / j, Z = x == null ? void 0 : x.src, W = new Fe({
|
|
716
716
|
id: T,
|
|
717
717
|
name: u.name,
|
|
718
718
|
x: mt,
|
|
@@ -745,7 +745,7 @@ const eo = Zt("EditorContext"), se = Q(null), ce = Q(null), Ro = () => {
|
|
|
745
745
|
wave: "wave",
|
|
746
746
|
arch: "arch",
|
|
747
747
|
shape: "shape"
|
|
748
|
-
}[A] || "custom", zt =
|
|
748
|
+
}[A] || "custom", zt = ve(at);
|
|
749
749
|
if (!zt || !zt.Component)
|
|
750
750
|
throw new Error(`[EditorContext] no transform registered for element type "${A}"`);
|
|
751
751
|
const ht = t.getActiveArtboard(), fe = ht ? Math.min(ht.width, ht.height) * 0.1 : 80, Ht = ht ? ht.width * 0.5 : 300;
|
|
@@ -797,12 +797,12 @@ const eo = Zt("EditorContext"), se = Q(null), ce = Q(null), Ro = () => {
|
|
|
797
797
|
), r.setSelectedId(T), { id: T, name: u.name ?? "" };
|
|
798
798
|
},
|
|
799
799
|
[t, M, _, r, c.zoom, n]
|
|
800
|
-
),
|
|
800
|
+
), Ft = m(
|
|
801
801
|
async (u, A) => {
|
|
802
802
|
await At({ ...A, type: u });
|
|
803
803
|
},
|
|
804
804
|
[At]
|
|
805
|
-
),
|
|
805
|
+
), vt = m(() => {
|
|
806
806
|
const u = [];
|
|
807
807
|
if (r.multiSelection.length > 0) {
|
|
808
808
|
const A = p.filter(
|
|
@@ -815,9 +815,9 @@ const eo = Zt("EditorContext"), se = Q(null), ce = Q(null), Ro = () => {
|
|
|
815
815
|
R(A);
|
|
816
816
|
}
|
|
817
817
|
}, [w, r.multiSelection, p]), Pt = m(() => {
|
|
818
|
-
if (
|
|
818
|
+
if (F.length === 0) return;
|
|
819
819
|
const u = [], A = 30, x = 30;
|
|
820
|
-
|
|
820
|
+
F.forEach((I) => {
|
|
821
821
|
const T = E.get(I.id), B = T ? T.x : I.x, mt = T ? T.y : I.y, st = I.toJSON();
|
|
822
822
|
delete st.id;
|
|
823
823
|
const j = I.constructor, tt = new j(st);
|
|
@@ -833,7 +833,7 @@ const eo = Zt("EditorContext"), se = Q(null), ce = Q(null), Ro = () => {
|
|
|
833
833
|
M(tt, ct, at), u.push(tt.id);
|
|
834
834
|
}), u.length === 1 ? r.handleSelectionChange(u[0]) : u.length > 1 && r.setMultiSelection(u);
|
|
835
835
|
}, [
|
|
836
|
-
|
|
836
|
+
F,
|
|
837
837
|
E,
|
|
838
838
|
t,
|
|
839
839
|
M,
|
|
@@ -929,16 +929,16 @@ const eo = Zt("EditorContext"), se = Q(null), ce = Q(null), Ro = () => {
|
|
|
929
929
|
// Element setters
|
|
930
930
|
setElements: h,
|
|
931
931
|
// Artboard version counter
|
|
932
|
-
artboardVersion:
|
|
932
|
+
artboardVersion: v,
|
|
933
933
|
// Handlers
|
|
934
934
|
refreshArtboards: L,
|
|
935
935
|
handleElementUpdate: K,
|
|
936
936
|
addElement: At,
|
|
937
|
-
handleAddElement:
|
|
937
|
+
handleAddElement: Ft,
|
|
938
938
|
handleLoadWorkspace: Nt,
|
|
939
|
-
handleCopyElements:
|
|
939
|
+
handleCopyElements: vt,
|
|
940
940
|
handlePasteElements: Pt,
|
|
941
|
-
hasClipboardContent:
|
|
941
|
+
hasClipboardContent: F.length > 0,
|
|
942
942
|
// Command history (undo/redo actions + execute functions)
|
|
943
943
|
historyManager: nt,
|
|
944
944
|
executeElementUpdate: _,
|
|
@@ -1013,15 +1013,15 @@ const eo = Zt("EditorContext"), se = Q(null), ce = Q(null), Ro = () => {
|
|
|
1013
1013
|
o,
|
|
1014
1014
|
n,
|
|
1015
1015
|
h,
|
|
1016
|
-
|
|
1016
|
+
v,
|
|
1017
1017
|
L,
|
|
1018
1018
|
K,
|
|
1019
1019
|
At,
|
|
1020
|
-
vt,
|
|
1021
|
-
Nt,
|
|
1022
1020
|
Ft,
|
|
1021
|
+
Nt,
|
|
1022
|
+
vt,
|
|
1023
1023
|
Pt,
|
|
1024
|
-
|
|
1024
|
+
F,
|
|
1025
1025
|
// Command history
|
|
1026
1026
|
nt,
|
|
1027
1027
|
_,
|
|
@@ -1051,7 +1051,7 @@ const eo = Zt("EditorContext"), se = Q(null), ce = Q(null), Ro = () => {
|
|
|
1051
1051
|
Tt,
|
|
1052
1052
|
Ot
|
|
1053
1053
|
]);
|
|
1054
|
-
return
|
|
1054
|
+
return s.current = _t, /* @__PURE__ */ k(ce.Provider, { value: i, children: /* @__PURE__ */ k(
|
|
1055
1055
|
Ze,
|
|
1056
1056
|
{
|
|
1057
1057
|
value: {
|
|
@@ -1072,14 +1072,14 @@ const eo = Zt("EditorContext"), se = Q(null), ce = Q(null), Ro = () => {
|
|
|
1072
1072
|
elementStore: E,
|
|
1073
1073
|
artboards: a,
|
|
1074
1074
|
artboardManager: t,
|
|
1075
|
-
artboardVersion:
|
|
1075
|
+
artboardVersion: v,
|
|
1076
1076
|
setElements: h,
|
|
1077
1077
|
refreshArtboards: L,
|
|
1078
1078
|
getElementById: S,
|
|
1079
|
-
handleAddElement:
|
|
1079
|
+
handleAddElement: Ft,
|
|
1080
1080
|
handleElementUpdate: K,
|
|
1081
1081
|
handleLoadWorkspace: Nt,
|
|
1082
|
-
handleCopyElements:
|
|
1082
|
+
handleCopyElements: vt,
|
|
1083
1083
|
handlePasteElements: Pt,
|
|
1084
1084
|
fontSize: bt,
|
|
1085
1085
|
fontColor: wt,
|
|
@@ -1137,19 +1137,19 @@ const eo = Zt("EditorContext"), se = Q(null), ce = Q(null), Ro = () => {
|
|
|
1137
1137
|
backgroundColor: t.backgroundColor || Te
|
|
1138
1138
|
};
|
|
1139
1139
|
return c.createArtboard(r), c;
|
|
1140
|
-
}),
|
|
1140
|
+
}), s = pt(null), i = pt(null);
|
|
1141
1141
|
return /* @__PURE__ */ k(
|
|
1142
1142
|
Xe,
|
|
1143
1143
|
{
|
|
1144
1144
|
artboardManager: n,
|
|
1145
|
-
canvasRef:
|
|
1145
|
+
canvasRef: s,
|
|
1146
1146
|
viewPadding: o,
|
|
1147
1147
|
children: /* @__PURE__ */ k(Ke, { children: /* @__PURE__ */ k(Je, { children: /* @__PURE__ */ k(
|
|
1148
1148
|
oo,
|
|
1149
1149
|
{
|
|
1150
1150
|
artboardManager: n,
|
|
1151
|
-
canvasRef:
|
|
1152
|
-
canvasEditorRef:
|
|
1151
|
+
canvasRef: s,
|
|
1152
|
+
canvasEditorRef: i,
|
|
1153
1153
|
children: e
|
|
1154
1154
|
}
|
|
1155
1155
|
) }) })
|
|
@@ -1167,10 +1167,10 @@ function To(e) {
|
|
|
1167
1167
|
function Oo() {
|
|
1168
1168
|
return [...ut];
|
|
1169
1169
|
}
|
|
1170
|
-
function
|
|
1170
|
+
function Fo() {
|
|
1171
1171
|
ut.length = 0;
|
|
1172
1172
|
}
|
|
1173
|
-
function
|
|
1173
|
+
function vo() {
|
|
1174
1174
|
if (ut.length === 0) return;
|
|
1175
1175
|
const e = ut.map((t) => ze(t) ? `${t.code}: ${t.message}` : `${t.name}: ${t.message}`).join(`
|
|
1176
1176
|
- `);
|
|
@@ -1196,16 +1196,16 @@ function ae(e) {
|
|
|
1196
1196
|
};
|
|
1197
1197
|
}
|
|
1198
1198
|
function ro(e) {
|
|
1199
|
-
var n;
|
|
1199
|
+
var n, s;
|
|
1200
1200
|
const t = (n = e.artboards) != null && n.length ? e.artboards : [{ name: "Front", width: 800, height: 800 }], o = t.map(() => []);
|
|
1201
1201
|
for (const i of e.elements || []) {
|
|
1202
|
-
const
|
|
1203
|
-
o[
|
|
1202
|
+
const c = i == null ? void 0 : i.artboard, r = typeof c == "string" ? t.findIndex((d) => (d.name || "Front") === c) : -1;
|
|
1203
|
+
o[r >= 0 ? r : 0].push(io(i));
|
|
1204
1204
|
}
|
|
1205
1205
|
return {
|
|
1206
1206
|
schemaVersion: no,
|
|
1207
|
-
artboards: t.map((i,
|
|
1208
|
-
id: `artboard-${
|
|
1207
|
+
artboards: t.map((i, c) => ({
|
|
1208
|
+
id: `artboard-${c + 1}`,
|
|
1209
1209
|
name: i.name || "Front",
|
|
1210
1210
|
x: 0,
|
|
1211
1211
|
y: 0,
|
|
@@ -1217,10 +1217,14 @@ function ro(e) {
|
|
|
1217
1217
|
// explicitly-set artboard backgrounds from every realtime mockup while
|
|
1218
1218
|
// the editor kept showing them (WYSIWYG drift).
|
|
1219
1219
|
exportBackground: i.exportBackground ?? !1,
|
|
1220
|
-
elements: o[
|
|
1220
|
+
elements: o[c],
|
|
1221
1221
|
distressTexture: i.distressTexture,
|
|
1222
1222
|
imageMask: i.imageMask
|
|
1223
|
-
}))
|
|
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 } : {}
|
|
1224
1228
|
};
|
|
1225
1229
|
}
|
|
1226
1230
|
function io(e) {
|
|
@@ -1235,18 +1239,18 @@ function io(e) {
|
|
|
1235
1239
|
}
|
|
1236
1240
|
function so(e) {
|
|
1237
1241
|
var a;
|
|
1238
|
-
const t = e.transformData || {}, o = e.masks && e.masks.length > 0, n = t.width || 0,
|
|
1242
|
+
const t = e.transformData || {}, o = e.masks && e.masks.length > 0, n = t.width || 0, s = t.height || 0, i = o ? n : n * (t.cropWidth ?? 1), c = o ? s : s * (t.cropHeight ?? 1), r = {
|
|
1239
1243
|
id: e.id,
|
|
1240
1244
|
type: "image",
|
|
1241
1245
|
x: e.x || 0,
|
|
1242
1246
|
y: e.y || 0,
|
|
1243
|
-
width:
|
|
1247
|
+
width: i,
|
|
1244
1248
|
height: c,
|
|
1245
1249
|
rotation: e.rotation || 0,
|
|
1246
1250
|
imageUrl: e.imageUrl,
|
|
1247
1251
|
imageAspectRatio: e.imageAspectRatio
|
|
1248
1252
|
};
|
|
1249
|
-
return !o && (t.cropX !== 0 || t.cropY !== 0 || t.cropWidth !== 1 || t.cropHeight !== 1) && (r.cropX = t.cropX, r.cropY = t.cropY, r.cropWidth = t.cropWidth, r.cropHeight = t.cropHeight, r.needsCropPixelConversion = !0), t.flipHorizontal && (r.flipHorizontal = t.flipHorizontal), t.flipVertical && (r.flipVertical = t.flipVertical), t.borderRadius && (r.borderRadius = t.borderRadius), ke(t.adjustments) || (r.adjustments = { ...t.adjustments }), e.opacity !== void 0 && (r.opacity = e.opacity), e.distressEffect && (r.distressEffect = e.distressEffect), ((a = e.masks) == null ? void 0 : a.length) > 0 && (r.masks = e.masks), e.blendMode && (r.blendMode = e.blendMode), e.knockoutParts && (r.knockoutParts = e.knockoutParts), e.stroke && (r.stroke = e.stroke), ae(r);
|
|
1253
|
+
return !o && (t.cropX !== 0 || t.cropY !== 0 || t.cropWidth !== 1 || t.cropHeight !== 1) && (r.cropX = t.cropX, r.cropY = t.cropY, r.cropWidth = t.cropWidth, r.cropHeight = t.cropHeight, r.needsCropPixelConversion = !0), t.flipHorizontal && (r.flipHorizontal = t.flipHorizontal), t.flipVertical && (r.flipVertical = t.flipVertical), t.borderRadius && (r.borderRadius = t.borderRadius), e.shadow && (r.shadow = e.shadow), ke(t.adjustments) || (r.adjustments = { ...t.adjustments }), e.opacity !== void 0 && (r.opacity = e.opacity), e.distressEffect && (r.distressEffect = e.distressEffect), ((a = e.masks) == null ? void 0 : a.length) > 0 && (r.masks = e.masks), e.blendMode && (r.blendMode = e.blendMode), e.knockoutParts && (r.knockoutParts = e.knockoutParts), e.stroke && (r.stroke = e.stroke), ae(r);
|
|
1250
1254
|
}
|
|
1251
1255
|
const Kt = "center", de = Symbol.for("snowcone.canvas.layerToken");
|
|
1252
1256
|
function Po(e) {
|
|
@@ -1279,8 +1283,8 @@ function mo(e) {
|
|
|
1279
1283
|
function ho(e) {
|
|
1280
1284
|
return e === "top-left" || e === "top" || e === "top-right" ? "top" : e === "bottom-left" || e === "bottom" || e === "bottom-right" ? "bottom" : "middle";
|
|
1281
1285
|
}
|
|
1282
|
-
function Ut(e, t, o, n,
|
|
1283
|
-
const c = mo(e), r = ho(e), d = c === "left" ? t / 2 +
|
|
1286
|
+
function Ut(e, t, o, n, s, i) {
|
|
1287
|
+
const c = mo(e), r = ho(e), d = c === "left" ? t / 2 + i : c === "right" ? n - t / 2 - i : n / 2, a = r === "top" ? o / 2 + i : r === "bottom" ? s - o / 2 - i : s / 2;
|
|
1284
1288
|
return { x: d, y: a };
|
|
1285
1289
|
}
|
|
1286
1290
|
function fo(e, t, o) {
|
|
@@ -1296,14 +1300,14 @@ function fo(e, t, o) {
|
|
|
1296
1300
|
cropHeight: 1
|
|
1297
1301
|
};
|
|
1298
1302
|
}
|
|
1299
|
-
const
|
|
1303
|
+
const s = t / e, i = o / s;
|
|
1300
1304
|
return {
|
|
1301
1305
|
width: t,
|
|
1302
|
-
height:
|
|
1306
|
+
height: s,
|
|
1303
1307
|
cropX: 0,
|
|
1304
|
-
cropY: (1 -
|
|
1308
|
+
cropY: (1 - i) / 2,
|
|
1305
1309
|
cropWidth: 1,
|
|
1306
|
-
cropHeight:
|
|
1310
|
+
cropHeight: i
|
|
1307
1311
|
};
|
|
1308
1312
|
}
|
|
1309
1313
|
class lt {
|
|
@@ -1311,21 +1315,21 @@ class lt {
|
|
|
1311
1315
|
if (this.els = [], this.colorRoles = /* @__PURE__ */ new Map(), this.idCounter = 0, !(t.width > 0) || !(t.height > 0))
|
|
1312
1316
|
throw new Error("design(): artboard width and height must be positive numbers");
|
|
1313
1317
|
for (const [o, n] of Object.entries(t.colors ?? {})) {
|
|
1314
|
-
const
|
|
1315
|
-
if (
|
|
1318
|
+
const s = uo(n);
|
|
1319
|
+
if (s === null)
|
|
1316
1320
|
throw new ot(
|
|
1317
1321
|
"E_COLOR_ROLE_INVALID",
|
|
1318
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).`,
|
|
1319
1323
|
{ roleName: o, value: n, docSlug: "embed-mode" }
|
|
1320
1324
|
);
|
|
1321
|
-
const
|
|
1322
|
-
if (
|
|
1325
|
+
const i = [...this.colorRoles.entries()].find(([, c]) => c === s);
|
|
1326
|
+
if (i)
|
|
1323
1327
|
throw new ot(
|
|
1324
1328
|
"E_COLOR_ROLE_COLLISION",
|
|
1325
|
-
`color roles "${
|
|
1326
|
-
{ roles: [
|
|
1329
|
+
`color roles "${i[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: [i[0], o], value: s, docSlug: "embed-mode" }
|
|
1327
1331
|
);
|
|
1328
|
-
this.colorRoles.set(o,
|
|
1332
|
+
this.colorRoles.set(o, s);
|
|
1329
1333
|
}
|
|
1330
1334
|
this.current = {
|
|
1331
1335
|
name: t.name || "Front",
|
|
@@ -1351,10 +1355,10 @@ class lt {
|
|
|
1351
1355
|
* emit all pages and `TemplateField.artboard` can scope fields per page.
|
|
1352
1356
|
*/
|
|
1353
1357
|
static fromState(t, o = {}) {
|
|
1354
|
-
const n = t.artboards.find((
|
|
1358
|
+
const n = t.artboards.find((i) => i.name === t.activeArtboard) ?? t.artboards[0];
|
|
1355
1359
|
if (!n)
|
|
1356
1360
|
throw new Error("DesignBuilder.fromState(): state has no artboards");
|
|
1357
|
-
const
|
|
1361
|
+
const s = new lt({
|
|
1358
1362
|
name: n.name,
|
|
1359
1363
|
width: n.width,
|
|
1360
1364
|
height: n.height,
|
|
@@ -1362,14 +1366,14 @@ class lt {
|
|
|
1362
1366
|
role: n.role
|
|
1363
1367
|
});
|
|
1364
1368
|
if (o.artboards === "all") {
|
|
1365
|
-
|
|
1366
|
-
for (const
|
|
1367
|
-
|
|
1368
|
-
return
|
|
1369
|
+
s.allArtboards = t.artboards.map((i) => ({ ...i }));
|
|
1370
|
+
for (const i of t.elements)
|
|
1371
|
+
s.els.push(i.artboard ? { ...i } : { ...i, artboard: n.name });
|
|
1372
|
+
return s;
|
|
1369
1373
|
}
|
|
1370
|
-
for (const
|
|
1371
|
-
|
|
1372
|
-
return
|
|
1374
|
+
for (const i of t.elements)
|
|
1375
|
+
i.artboard && i.artboard !== n.name || s.els.push({ ...i });
|
|
1376
|
+
return s;
|
|
1373
1377
|
}
|
|
1374
1378
|
nextId(t) {
|
|
1375
1379
|
return `${t}-${++this.idCounter}`;
|
|
@@ -1430,11 +1434,11 @@ class lt {
|
|
|
1430
1434
|
}, this.allArtboards.push(lt.snapshotArtboard(this.current)), this;
|
|
1431
1435
|
}
|
|
1432
1436
|
background(t, o = {}) {
|
|
1433
|
-
const { width: n, height:
|
|
1434
|
-
let
|
|
1437
|
+
const { width: n, height: s } = this.current;
|
|
1438
|
+
let i;
|
|
1435
1439
|
if (o.aspectRatio && o.aspectRatio > 0) {
|
|
1436
|
-
const r = fo(o.aspectRatio, n,
|
|
1437
|
-
|
|
1440
|
+
const r = fo(o.aspectRatio, n, s);
|
|
1441
|
+
i = {
|
|
1438
1442
|
type: "image",
|
|
1439
1443
|
width: r.width,
|
|
1440
1444
|
height: r.height,
|
|
@@ -1447,10 +1451,10 @@ class lt {
|
|
|
1447
1451
|
borderRadius: 0
|
|
1448
1452
|
};
|
|
1449
1453
|
} else
|
|
1450
|
-
|
|
1454
|
+
i = {
|
|
1451
1455
|
type: "image",
|
|
1452
1456
|
width: n,
|
|
1453
|
-
height:
|
|
1457
|
+
height: s,
|
|
1454
1458
|
cropX: 0,
|
|
1455
1459
|
cropY: 0,
|
|
1456
1460
|
cropWidth: 1,
|
|
@@ -1463,18 +1467,18 @@ class lt {
|
|
|
1463
1467
|
id: this.nextId("bg"),
|
|
1464
1468
|
transformType: "image",
|
|
1465
1469
|
x: n / 2,
|
|
1466
|
-
y:
|
|
1470
|
+
y: s / 2,
|
|
1467
1471
|
rotation: 0,
|
|
1468
1472
|
opacity: o.opacity ?? 1,
|
|
1469
1473
|
imageUrl: t,
|
|
1470
1474
|
imageAspectRatio: o.aspectRatio,
|
|
1471
|
-
transformData:
|
|
1475
|
+
transformData: i,
|
|
1472
1476
|
name: o.name ?? "Background"
|
|
1473
1477
|
};
|
|
1474
1478
|
return this.els.unshift(c), this;
|
|
1475
1479
|
}
|
|
1476
1480
|
image(t, o = {}) {
|
|
1477
|
-
const { width: n, height:
|
|
1481
|
+
const { width: n, height: s } = this.current, i = o.width ?? Math.round(n / 3), c = o.height ?? (o.aspectRatio ? Math.round(i / o.aspectRatio) : i), { x: r, y: d } = Ut(o.anchor ?? Kt, i, c, n, s, o.padding ?? 0), a = {
|
|
1478
1482
|
id: this.nextId("img"),
|
|
1479
1483
|
transformType: "image",
|
|
1480
1484
|
x: r,
|
|
@@ -1485,7 +1489,7 @@ class lt {
|
|
|
1485
1489
|
imageAspectRatio: o.aspectRatio,
|
|
1486
1490
|
transformData: {
|
|
1487
1491
|
type: "image",
|
|
1488
|
-
width:
|
|
1492
|
+
width: i,
|
|
1489
1493
|
height: c,
|
|
1490
1494
|
cropX: 0,
|
|
1491
1495
|
cropY: 0,
|
|
@@ -1500,14 +1504,14 @@ class lt {
|
|
|
1500
1504
|
return this.els.push(a), this;
|
|
1501
1505
|
}
|
|
1502
1506
|
text(t, o = {}) {
|
|
1503
|
-
const { width: n, height:
|
|
1507
|
+
const { width: n, height: s } = this.current, i = o.fontSize ?? Math.round(this.current.height / 12), { x: c, y: r } = Ut(o.anchor ?? "top", 0, i, n, s, o.padding ?? Math.round(s / 20)), d = {
|
|
1504
1508
|
id: this.nextId("text"),
|
|
1505
1509
|
transformType: "custom",
|
|
1506
1510
|
x: c,
|
|
1507
1511
|
y: r,
|
|
1508
1512
|
rotation: o.rotation ?? 0,
|
|
1509
1513
|
text: t,
|
|
1510
|
-
fontSize:
|
|
1514
|
+
fontSize: i,
|
|
1511
1515
|
fontFamily: o.fontFamily ?? "Anton",
|
|
1512
1516
|
color: xt(o.color) ?? "#ffffff",
|
|
1513
1517
|
textAlign: o.textAlign ?? "center",
|
|
@@ -1532,13 +1536,13 @@ class lt {
|
|
|
1532
1536
|
* is not bindable (shape/group/path).
|
|
1533
1537
|
*/
|
|
1534
1538
|
layer(t) {
|
|
1535
|
-
const o = this.els.find((
|
|
1539
|
+
const o = this.els.find((s) => s.name === t);
|
|
1536
1540
|
if (!o) {
|
|
1537
|
-
const
|
|
1541
|
+
const s = this.layerNamesOfKind("text"), i = this.layerNamesOfKind("image");
|
|
1538
1542
|
throw new ot(
|
|
1539
1543
|
"E_LAYER_NOT_FOUND",
|
|
1540
|
-
`no layer "${t}" in this design. Text layers: ${JSON.stringify(
|
|
1541
|
-
{ layerName: t, validNames: [...
|
|
1544
|
+
`no layer "${t}" in this design. Text layers: ${JSON.stringify(s)}; image layers: ${JSON.stringify(i)}. Fix the name, or add the layer first — e.g. design(…).text('…', { name: '${t}' }).`,
|
|
1545
|
+
{ layerName: t, validNames: [...s, ...i], textNames: s, imageNames: i, docSlug: "embed-mode" }
|
|
1542
1546
|
);
|
|
1543
1547
|
}
|
|
1544
1548
|
const n = Vt(o);
|
|
@@ -1579,7 +1583,7 @@ class lt {
|
|
|
1579
1583
|
}
|
|
1580
1584
|
/** An anchored vector shape. */
|
|
1581
1585
|
shape(t, o = {}) {
|
|
1582
|
-
const { width: n, height:
|
|
1586
|
+
const { width: n, height: s } = this.current, i = o.size ?? Math.round(n / 6), c = typeof i == "number" ? i : i.width, r = typeof i == "number" ? i : i.height, { x: d, y: a } = Ut(o.anchor ?? Kt, c, r, n, s, o.padding ?? 0), z = {
|
|
1583
1587
|
type: "shape",
|
|
1584
1588
|
shapeType: t,
|
|
1585
1589
|
width: c,
|
|
@@ -1588,7 +1592,7 @@ class lt {
|
|
|
1588
1592
|
fillOpacity: o.opacity ?? 1,
|
|
1589
1593
|
...o.points !== void 0 ? { points: o.points } : {},
|
|
1590
1594
|
...o.sides !== void 0 ? { sides: o.sides } : {}
|
|
1591
|
-
},
|
|
1595
|
+
}, v = {
|
|
1592
1596
|
id: this.nextId("shape"),
|
|
1593
1597
|
transformType: "shape",
|
|
1594
1598
|
x: d,
|
|
@@ -1597,7 +1601,7 @@ class lt {
|
|
|
1597
1601
|
transformData: z,
|
|
1598
1602
|
...o.name ? { name: o.name } : {}
|
|
1599
1603
|
};
|
|
1600
|
-
return this.els.push(
|
|
1604
|
+
return this.els.push(v), this;
|
|
1601
1605
|
}
|
|
1602
1606
|
/** The composed elements, in render order (background first). Editor shape. */
|
|
1603
1607
|
get elements() {
|
|
@@ -1659,14 +1663,14 @@ export {
|
|
|
1659
1663
|
go as k,
|
|
1660
1664
|
zo as l,
|
|
1661
1665
|
Ro as m,
|
|
1662
|
-
|
|
1666
|
+
vo as n,
|
|
1663
1667
|
Oo as o,
|
|
1664
1668
|
xo as p,
|
|
1665
|
-
|
|
1669
|
+
Fo as q,
|
|
1666
1670
|
To as r,
|
|
1667
1671
|
ro as s,
|
|
1668
1672
|
Le as t,
|
|
1669
1673
|
Io as u,
|
|
1670
1674
|
bo as v
|
|
1671
1675
|
};
|
|
1672
|
-
//# sourceMappingURL=design-builder-
|
|
1676
|
+
//# sourceMappingURL=design-builder-D4izkvlb.js.map
|