@snowcone-app/canvas 0.40.22 → 0.40.23
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-BmLEU_Zb.js → CanvasRenderer-JcBrIZ6I.js} +454 -452
- package/dist/{CanvasRenderer-BmLEU_Zb.js.map → CanvasRenderer-JcBrIZ6I.js.map} +1 -1
- package/dist/{CanvasStateV1-DnpfA376.js → CanvasStateV1-BJ5-75NN.js} +3 -3
- package/dist/{CanvasStateV1-DnpfA376.js.map → CanvasStateV1-BJ5-75NN.js.map} +1 -1
- package/dist/{ContextualToolbars-DSJykxdc.js → ContextualToolbars-wmbHxn5a.js} +2058 -1991
- package/dist/{ContextualToolbars-DSJykxdc.js.map → ContextualToolbars-wmbHxn5a.js.map} +1 -1
- package/dist/{EditorCanvasImpl-t5MD0lMB.js → EditorCanvasImpl-CI_mLBGt.js} +8 -8
- package/dist/{EditorCanvasImpl-t5MD0lMB.js.map → EditorCanvasImpl-CI_mLBGt.js.map} +1 -1
- package/dist/{ExportManager-CnUTZrbv.js → ExportManager-CHlByUYV.js} +856 -839
- package/dist/ExportManager-CHlByUYV.js.map +1 -0
- package/dist/{FontAnalyzer-Bjtl4XTH.js → FontAnalyzer-Bj2KrX80.js} +1592 -1530
- package/dist/FontAnalyzer-Bj2KrX80.js.map +1 -0
- package/dist/{ImagePanel-AWQgzuXz.js → ImagePanel-0ZwDDaCy.js} +6 -6
- package/dist/{ImagePanel-AWQgzuXz.js.map → ImagePanel-0ZwDDaCy.js.map} +1 -1
- package/dist/{SnowconeCanvas-BWv3Sd5P.js → SnowconeCanvas-0w0-l9tm.js} +10 -10
- package/dist/{SnowconeCanvas-BWv3Sd5P.js.map → SnowconeCanvas-0w0-l9tm.js.map} +1 -1
- package/dist/advanced.mjs +39 -39
- package/dist/components/toolbars/SecondaryPanels.d.ts +3 -0
- package/dist/core/ImageElement.d.ts +20 -0
- package/dist/core/TextMetrics.d.ts +14 -2
- package/dist/core/masked-crop.d.ts +57 -0
- package/dist/{custom-icons-Bn8_I4kt.js → custom-icons-up58ZbC9.js} +2 -2
- package/dist/{custom-icons-Bn8_I4kt.js.map → custom-icons-up58ZbC9.js.map} +1 -1
- package/dist/{design-builder-B3v5OAQo.js → design-builder-DUEwCUmA.js} +396 -396
- package/dist/{design-builder-B3v5OAQo.js.map → design-builder-DUEwCUmA.js.map} +1 -1
- package/dist/{embed-D6-jVZMw.js → embed-VKMR6QO1.js} +10 -10
- package/dist/{embed-D6-jVZMw.js.map → embed-VKMR6QO1.js.map} +1 -1
- package/dist/embed.mjs +7 -7
- package/dist/{export-worker.bundle.string-DXciOLDt.js → export-worker.bundle.string-C6Zm9Wt-.js} +146 -27
- package/dist/{export-worker.bundle.string-DXciOLDt.js.map → export-worker.bundle.string-C6Zm9Wt-.js.map} +1 -1
- package/dist/{guards-B_Q3pewr.js → guards-CQeF53PN.js} +2 -2
- package/dist/{guards-B_Q3pewr.js.map → guards-CQeF53PN.js.map} +1 -1
- package/dist/index.mjs +9 -9
- package/dist/internals.mjs +6 -6
- package/dist/rendering/MaskRenderer.d.ts +13 -0
- package/dist/{template-fields-B4sJfQjP.js → template-fields-tobyHoMe.js} +5 -5
- package/dist/{template-fields-B4sJfQjP.js.map → template-fields-tobyHoMe.js.map} +1 -1
- package/dist/testing.mjs +3 -3
- package/dist/types/index.d.ts +10 -0
- package/dist/{useCommands-CZHeVauL.js → useCommands-Cm3mDB-l.js} +225 -225
- package/dist/{useCommands-CZHeVauL.js.map → useCommands-Cm3mDB-l.js.map} +1 -1
- package/dist/{usePieceGuideBundle-DsCv7HKy.js → usePieceGuideBundle-BTnUn33k.js} +2 -2
- package/dist/{usePieceGuideBundle-DsCv7HKy.js.map → usePieceGuideBundle-BTnUn33k.js.map} +1 -1
- package/dist/{validation-D9catdeB.js → validation-D4zxugNJ.js} +11 -11
- package/dist/{validation-D9catdeB.js.map → validation-D4zxugNJ.js.map} +1 -1
- package/dist/workers/export-worker.bundle.string.d.ts +1 -1
- package/example/package.json +1 -1
- package/package.json +1 -1
- package/dist/ExportManager-CnUTZrbv.js.map +0 -1
- package/dist/FontAnalyzer-Bjtl4XTH.js.map +0 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsx as k } from "react/jsx-runtime";
|
|
2
|
-
import { useContext as Y, useSyncExternalStore as
|
|
3
|
-
import { H as
|
|
4
|
-
const Jt = Q(null),
|
|
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
5
|
}, Yt = () => 0;
|
|
6
|
-
function
|
|
7
|
-
const e = Y(Jt), t =
|
|
8
|
-
e ? e.subscribe :
|
|
6
|
+
function wo() {
|
|
7
|
+
const e = Y(Jt), t = Ae(
|
|
8
|
+
e ? e.subscribe : Le,
|
|
9
9
|
e ? e.getVersion : Yt,
|
|
10
10
|
e ? e.getVersion : Yt
|
|
11
11
|
);
|
|
@@ -17,12 +17,12 @@ function go() {
|
|
|
17
17
|
);
|
|
18
18
|
}
|
|
19
19
|
const gt = Zt("useCommandHistory");
|
|
20
|
-
function
|
|
21
|
-
const s = pt(new
|
|
20
|
+
function $e(e, t, o, n) {
|
|
21
|
+
const s = pt(new ye(o)), r = 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 (!r || !g) return;
|
|
25
|
+
const y = r.getBoundLayer(g);
|
|
26
26
|
if (y)
|
|
27
27
|
throw new ot(
|
|
28
28
|
"E_BOUND_LAYER_MUTATION",
|
|
@@ -30,16 +30,16 @@ function Ve(e, t, o, n) {
|
|
|
30
30
|
{ layer: g, part: y.part, operation: f, docSlug: "embed-mode" }
|
|
31
31
|
);
|
|
32
32
|
},
|
|
33
|
-
[
|
|
34
|
-
), [
|
|
33
|
+
[r]
|
|
34
|
+
), [i, a] = b({
|
|
35
35
|
canUndo: !1,
|
|
36
36
|
canRedo: !1,
|
|
37
37
|
// Per-artboard state for the active artboard
|
|
38
38
|
canUndoActiveArtboard: !1,
|
|
39
39
|
canRedoActiveArtboard: !1
|
|
40
|
-
}),
|
|
40
|
+
}), d = m(() => {
|
|
41
41
|
const l = s.current, f = o.getActiveArtboardId();
|
|
42
|
-
|
|
42
|
+
a({
|
|
43
43
|
canUndo: l.canUndo(),
|
|
44
44
|
canRedo: l.canRedo(),
|
|
45
45
|
// Per-artboard state - only check active artboard's history
|
|
@@ -49,31 +49,31 @@ function Ve(e, t, o, n) {
|
|
|
49
49
|
}, [o]), z = m(
|
|
50
50
|
(l, f) => {
|
|
51
51
|
l && l.name !== f.name && c(l, "rename");
|
|
52
|
-
const g = new
|
|
52
|
+
const g = new ge(
|
|
53
53
|
f.id,
|
|
54
54
|
l || null,
|
|
55
55
|
f,
|
|
56
|
-
(
|
|
57
|
-
t(($) => $.map((P) => P.id ===
|
|
56
|
+
(I) => {
|
|
57
|
+
t(($) => $.map((P) => P.id === I.id ? I : P));
|
|
58
58
|
}
|
|
59
59
|
), y = o.getArtboardIdForElement(f.id);
|
|
60
60
|
if (y)
|
|
61
61
|
s.current.executeOnArtboard(y, g);
|
|
62
62
|
else {
|
|
63
|
-
const
|
|
64
|
-
|
|
63
|
+
const I = o.getActiveArtboardId();
|
|
64
|
+
I && s.current.executeOnArtboard(I, g);
|
|
65
65
|
}
|
|
66
|
-
|
|
66
|
+
d();
|
|
67
67
|
},
|
|
68
|
-
[t, o,
|
|
69
|
-
),
|
|
68
|
+
[t, o, d, c]
|
|
69
|
+
), F = m(
|
|
70
70
|
(l, f, g, y) => {
|
|
71
|
-
const
|
|
72
|
-
if (!
|
|
71
|
+
const I = f || o.getActiveArtboardId();
|
|
72
|
+
if (!I) {
|
|
73
73
|
gt.warn("No active artboard to add element to");
|
|
74
74
|
return;
|
|
75
75
|
}
|
|
76
|
-
const $ = new
|
|
76
|
+
const $ = new xe(
|
|
77
77
|
l,
|
|
78
78
|
(P) => {
|
|
79
79
|
const U = P;
|
|
@@ -105,15 +105,15 @@ function Ve(e, t, o, n) {
|
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
return [...N, U];
|
|
108
|
-
}), o.addElementToArtboard(P.id,
|
|
108
|
+
}), o.addElementToArtboard(P.id, I);
|
|
109
109
|
},
|
|
110
110
|
(P) => {
|
|
111
111
|
t((U) => U.filter((N) => N.id !== P)), o.removeElementFromArtboard(P);
|
|
112
112
|
}
|
|
113
113
|
);
|
|
114
|
-
s.current.executeOnArtboard(
|
|
114
|
+
s.current.executeOnArtboard(I, $), d();
|
|
115
115
|
},
|
|
116
|
-
[t, o,
|
|
116
|
+
[t, o, d]
|
|
117
117
|
), V = m(
|
|
118
118
|
(l) => {
|
|
119
119
|
c(l, "delete");
|
|
@@ -122,36 +122,36 @@ function Ve(e, t, o, n) {
|
|
|
122
122
|
gt.warn("Element not found in any artboard");
|
|
123
123
|
return;
|
|
124
124
|
}
|
|
125
|
-
const g = new
|
|
125
|
+
const g = new be(
|
|
126
126
|
l,
|
|
127
127
|
(y) => {
|
|
128
|
-
t((
|
|
128
|
+
t((I) => [...I, y]), o.addElementToArtboard(y.id, f);
|
|
129
129
|
},
|
|
130
130
|
(y) => {
|
|
131
|
-
t((
|
|
131
|
+
t((I) => I.filter(($) => $.id !== y)), o.removeElementFromArtboard(y);
|
|
132
132
|
}
|
|
133
133
|
);
|
|
134
|
-
s.current.executeOnArtboard(f, g),
|
|
134
|
+
s.current.executeOnArtboard(f, g), d();
|
|
135
135
|
},
|
|
136
|
-
[t, o,
|
|
136
|
+
[t, o, d, c]
|
|
137
137
|
), E = m(
|
|
138
138
|
(l) => {
|
|
139
|
-
const f = new
|
|
140
|
-
s.current.executeGlobal(f),
|
|
139
|
+
const f = new we(l, o);
|
|
140
|
+
s.current.executeGlobal(f), d(), n == null || n();
|
|
141
141
|
},
|
|
142
|
-
[o,
|
|
142
|
+
[o, d, n]
|
|
143
143
|
), D = m(
|
|
144
144
|
(l) => {
|
|
145
|
-
const f = new
|
|
146
|
-
s.current.executeGlobal(f),
|
|
145
|
+
const f = new Ee(l, o);
|
|
146
|
+
s.current.executeGlobal(f), d(), n == null || n();
|
|
147
147
|
},
|
|
148
|
-
[o,
|
|
148
|
+
[o, d, n]
|
|
149
149
|
), p = m(
|
|
150
150
|
(l, f, g) => {
|
|
151
|
-
const y = new
|
|
152
|
-
s.current.executeGlobal(y),
|
|
151
|
+
const y = new Se(l, f, g, o);
|
|
152
|
+
s.current.executeGlobal(y), d(), n == null || n();
|
|
153
153
|
},
|
|
154
|
-
[o,
|
|
154
|
+
[o, d, n]
|
|
155
155
|
), h = m(
|
|
156
156
|
(l) => {
|
|
157
157
|
if (l.length === 0)
|
|
@@ -169,52 +169,52 @@ function Ve(e, t, o, n) {
|
|
|
169
169
|
y.undo();
|
|
170
170
|
}
|
|
171
171
|
}());
|
|
172
|
-
s.current.executeBatchOnArtboard(f, g),
|
|
172
|
+
s.current.executeBatchOnArtboard(f, g), d();
|
|
173
173
|
},
|
|
174
|
-
[o,
|
|
174
|
+
[o, d]
|
|
175
175
|
), S = m(() => {
|
|
176
|
-
s.current.undo() && (
|
|
177
|
-
}, [
|
|
178
|
-
s.current.redo() && (
|
|
179
|
-
}, [
|
|
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
180
|
const l = o.getActiveArtboardId();
|
|
181
|
-
l && s.current.undoArtboard(l) && (
|
|
182
|
-
}, [o,
|
|
181
|
+
l && s.current.undoArtboard(l) && (d(), n == null || n());
|
|
182
|
+
}, [o, d, n]), w = m(() => {
|
|
183
183
|
const l = o.getActiveArtboardId();
|
|
184
|
-
l && s.current.redoArtboard(l) && (
|
|
185
|
-
}, [o,
|
|
186
|
-
s.current.clear(),
|
|
187
|
-
}, [
|
|
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
188
|
(l) => {
|
|
189
|
-
s.current.clearArtboardHistory(l),
|
|
189
|
+
s.current.clearArtboardHistory(l), d();
|
|
190
190
|
},
|
|
191
|
-
[
|
|
191
|
+
[d]
|
|
192
192
|
), _ = pt(null);
|
|
193
193
|
Dt(() => {
|
|
194
194
|
const l = o.getActiveArtboardId();
|
|
195
|
-
l !== _.current && (_.current = l,
|
|
195
|
+
l !== _.current && (_.current = l, d());
|
|
196
196
|
});
|
|
197
197
|
const M = m(
|
|
198
198
|
(l, f, g) => {
|
|
199
|
-
const y = e.map((P) => P.id),
|
|
200
|
-
if (!
|
|
199
|
+
const y = e.map((P) => P.id), I = o.getArtboardIdForElement(l);
|
|
200
|
+
if (!I) {
|
|
201
201
|
gt.warn("Element not found in any artboard");
|
|
202
202
|
return;
|
|
203
203
|
}
|
|
204
|
-
const $ = new
|
|
204
|
+
const $ = new Re(l, f, g, y, (P) => {
|
|
205
205
|
t((U) => {
|
|
206
206
|
const N = new Map(U.map((H) => [H.id, H]));
|
|
207
207
|
return P.map((H) => N.get(H)).filter(Boolean);
|
|
208
208
|
});
|
|
209
209
|
});
|
|
210
|
-
s.current.executeOnArtboard(
|
|
210
|
+
s.current.executeOnArtboard(I, $), d();
|
|
211
211
|
},
|
|
212
|
-
[e, t, o,
|
|
212
|
+
[e, t, o, d]
|
|
213
213
|
);
|
|
214
214
|
return {
|
|
215
215
|
// Element operations
|
|
216
216
|
executeElementUpdate: z,
|
|
217
|
-
executeAddElement:
|
|
217
|
+
executeAddElement: F,
|
|
218
218
|
executeRemoveElement: V,
|
|
219
219
|
executeReorderElement: M,
|
|
220
220
|
// Batch operations
|
|
@@ -225,42 +225,42 @@ 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: v,
|
|
229
229
|
// Undo/redo for active artboard only (element operations)
|
|
230
230
|
undoActiveArtboard: R,
|
|
231
231
|
redoActiveArtboard: w,
|
|
232
232
|
clearHistory: L,
|
|
233
233
|
clearArtboardHistory: nt,
|
|
234
234
|
// State (smart - considers last operation)
|
|
235
|
-
canUndo:
|
|
236
|
-
canRedo:
|
|
235
|
+
canUndo: i.canUndo,
|
|
236
|
+
canRedo: i.canRedo,
|
|
237
237
|
// State for active artboard only
|
|
238
|
-
canUndoActiveArtboard:
|
|
239
|
-
canRedoActiveArtboard:
|
|
238
|
+
canUndoActiveArtboard: i.canUndoActiveArtboard,
|
|
239
|
+
canRedoActiveArtboard: i.canRedoActiveArtboard,
|
|
240
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
|
-
function
|
|
247
|
-
const [o, n] = b(32), [s,
|
|
246
|
+
function Be(e, t) {
|
|
247
|
+
const [o, n] = b(32), [s, r] = b("#333333"), [c, i] = b("Arial"), [a, d] = 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, 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
252
|
}
|
|
253
253
|
}, [e]);
|
|
254
254
|
const z = m(
|
|
255
255
|
(p) => {
|
|
256
256
|
if (!e || !dt(e)) return;
|
|
257
|
-
const h = Math.max(Ce, Math.min(
|
|
257
|
+
const h = Math.max(Ce, Math.min(Te, o + p));
|
|
258
258
|
n(h);
|
|
259
259
|
const S = e.clone();
|
|
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
|
+
), F = 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
|
+
r(p);
|
|
275
275
|
const h = e.clone();
|
|
276
276
|
if (h.color = p, h.richText)
|
|
277
277
|
for (const S of h.richText.spans)
|
|
@@ -283,7 +283,7 @@ function De(e, t) {
|
|
|
283
283
|
(p) => {
|
|
284
284
|
if (!e || !dt(e)) return;
|
|
285
285
|
const h = e.fontFamily;
|
|
286
|
-
h !== p &&
|
|
286
|
+
h !== p && Ie.clearCache(h), i(p);
|
|
287
287
|
const S = e.clone();
|
|
288
288
|
S.fontFamily = p, t(S);
|
|
289
289
|
},
|
|
@@ -291,7 +291,7 @@ function De(e, t) {
|
|
|
291
291
|
), D = m(
|
|
292
292
|
(p) => {
|
|
293
293
|
if (!e || !dt(e)) return;
|
|
294
|
-
|
|
294
|
+
d(p);
|
|
295
295
|
const h = e.clone();
|
|
296
296
|
h.textAlign = p, t(h);
|
|
297
297
|
},
|
|
@@ -302,22 +302,22 @@ function De(e, t) {
|
|
|
302
302
|
fontSize: o,
|
|
303
303
|
fontColor: s,
|
|
304
304
|
fontFamily: c,
|
|
305
|
-
textAlign:
|
|
305
|
+
textAlign: a,
|
|
306
306
|
// State setters (for UI only)
|
|
307
307
|
setFontSize: n,
|
|
308
|
-
setFontColor:
|
|
309
|
-
setFontFamily:
|
|
310
|
-
setTextAlign:
|
|
308
|
+
setFontColor: r,
|
|
309
|
+
setFontFamily: i,
|
|
310
|
+
setTextAlign: d,
|
|
311
311
|
// Update functions (update element + UI)
|
|
312
312
|
updateFontSize: z,
|
|
313
|
-
setFontSizeValue:
|
|
313
|
+
setFontSizeValue: F,
|
|
314
314
|
updateFontColor: V,
|
|
315
315
|
updateFontFamily: E,
|
|
316
316
|
updateTextAlign: D
|
|
317
317
|
};
|
|
318
318
|
}
|
|
319
319
|
const qt = "data-preserve-selection";
|
|
320
|
-
function
|
|
320
|
+
function We(e) {
|
|
321
321
|
if (!(e instanceof Element))
|
|
322
322
|
return !1;
|
|
323
323
|
let t = e;
|
|
@@ -326,8 +326,8 @@ function _e(e) {
|
|
|
326
326
|
const n = t.id ? `#${t.id}` : "", s = t.className ? `.${String(t.className).split(" ").slice(0, 2).join(".")}` : "";
|
|
327
327
|
if (o.push(`${t.tagName.toLowerCase()}${n}${s}`), t.hasAttribute(qt))
|
|
328
328
|
return !0;
|
|
329
|
-
const
|
|
330
|
-
if (
|
|
329
|
+
const r = t.getAttribute("role");
|
|
330
|
+
if (r === "dialog" || r === "alertdialog" || r === "menu" || r === "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"))
|
|
@@ -336,14 +336,14 @@ function _e(e) {
|
|
|
336
336
|
}
|
|
337
337
|
return !1;
|
|
338
338
|
}
|
|
339
|
-
const
|
|
339
|
+
const Eo = {
|
|
340
340
|
[qt]: ""
|
|
341
341
|
};
|
|
342
|
-
function
|
|
342
|
+
function Me(e) {
|
|
343
343
|
const t = Qt(e);
|
|
344
344
|
return t !== null && t < 0.5;
|
|
345
345
|
}
|
|
346
|
-
function
|
|
346
|
+
function So(e) {
|
|
347
347
|
const t = Qt(e);
|
|
348
348
|
return t !== null && t >= 0.5;
|
|
349
349
|
}
|
|
@@ -351,84 +351,84 @@ function Qt(e) {
|
|
|
351
351
|
const t = e.trim();
|
|
352
352
|
if (t.startsWith("#")) {
|
|
353
353
|
const n = t.slice(1);
|
|
354
|
-
let s,
|
|
354
|
+
let s, r, c;
|
|
355
355
|
if (n.length === 3)
|
|
356
|
-
s = parseInt(n[0] + n[0], 16),
|
|
356
|
+
s = parseInt(n[0] + n[0], 16), r = parseInt(n[1] + n[1], 16), c = parseInt(n[2] + n[2], 16);
|
|
357
357
|
else if (n.length === 6)
|
|
358
|
-
s = parseInt(n.slice(0, 2), 16),
|
|
358
|
+
s = parseInt(n.slice(0, 2), 16), r = parseInt(n.slice(2, 4), 16), c = parseInt(n.slice(4, 6), 16);
|
|
359
359
|
else return null;
|
|
360
|
-
return Number.isNaN(s) || Number.isNaN(
|
|
360
|
+
return Number.isNaN(s) || Number.isNaN(r) || Number.isNaN(c) ? null : Xt(s, r, 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
366
|
const n = (s) => {
|
|
367
|
-
const
|
|
368
|
-
return
|
|
367
|
+
const r = s / 255;
|
|
368
|
+
return r <= 0.03928 ? r / 12.92 : Math.pow((r + 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
|
}
|
|
372
|
-
const
|
|
373
|
-
function
|
|
374
|
-
return e &&
|
|
372
|
+
const Ye = "#333333", Xe = "#f4f4f5";
|
|
373
|
+
function Ke(e) {
|
|
374
|
+
return e && Me(e) ? Xe : Ye;
|
|
375
375
|
}
|
|
376
|
-
const te = Q(null),
|
|
376
|
+
const te = Q(null), Ge = 0.1, je = 4, Kt = 0.25, Ze = ({
|
|
377
377
|
children: e,
|
|
378
378
|
artboardManager: t,
|
|
379
379
|
canvasRef: o,
|
|
380
380
|
viewPadding: n = 0.9
|
|
381
381
|
}) => {
|
|
382
|
-
const [s,
|
|
383
|
-
|
|
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
384
|
}, []), E = m(() => {
|
|
385
|
-
|
|
385
|
+
r((v) => Math.min(v + Kt, je));
|
|
386
386
|
}, []), D = m(() => {
|
|
387
|
-
|
|
387
|
+
r((v) => Math.max(v - Kt, Ge));
|
|
388
388
|
}, []), p = m(() => {
|
|
389
|
-
const
|
|
390
|
-
if (!
|
|
389
|
+
const v = t.getActiveArtboard();
|
|
390
|
+
if (!v || !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 / v.width,
|
|
397
|
+
L * n / v.height,
|
|
398
398
|
1
|
|
399
399
|
// Never zoom in beyond 100%
|
|
400
400
|
);
|
|
401
|
-
|
|
401
|
+
r(nt), i({ x: 0, y: 0 });
|
|
402
402
|
}, [t, o, n]), h = m(() => {
|
|
403
|
-
|
|
403
|
+
r(1), i({ x: 0, y: 0 });
|
|
404
404
|
}, []), S = q(
|
|
405
405
|
() => ({
|
|
406
406
|
zoom: s,
|
|
407
407
|
panOffset: c,
|
|
408
|
-
isPanning:
|
|
408
|
+
isPanning: a,
|
|
409
409
|
zoomIn: E,
|
|
410
410
|
zoomOut: D,
|
|
411
411
|
zoomToFit: p,
|
|
412
412
|
resetView: h,
|
|
413
|
-
setZoom:
|
|
414
|
-
setPanOffset:
|
|
415
|
-
setIsPanning:
|
|
413
|
+
setZoom: r,
|
|
414
|
+
setPanOffset: i,
|
|
415
|
+
setIsPanning: d,
|
|
416
416
|
userZoom: z,
|
|
417
|
-
setUserZoom:
|
|
417
|
+
setUserZoom: F,
|
|
418
418
|
resetUserView: V
|
|
419
419
|
}),
|
|
420
|
-
[s, c,
|
|
420
|
+
[s, c, a, E, D, p, h, z, V]
|
|
421
421
|
);
|
|
422
422
|
return /* @__PURE__ */ k(te.Provider, { value: S, children: e });
|
|
423
423
|
};
|
|
424
|
-
function
|
|
424
|
+
function Je() {
|
|
425
425
|
const e = Y(te);
|
|
426
426
|
if (!e)
|
|
427
427
|
throw new Error("useViewportContext must be used within a ViewportProvider (or EditorProvider)");
|
|
428
428
|
return e;
|
|
429
429
|
}
|
|
430
|
-
const ee = Q(null),
|
|
431
|
-
const [t, o] = b(null), [n, s] = b([]), [
|
|
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
432
|
o(D);
|
|
433
433
|
}, []), V = m((D) => {
|
|
434
434
|
c(D);
|
|
@@ -436,35 +436,35 @@ const ee = Q(null), Ge = ({ children: e }) => {
|
|
|
436
436
|
() => ({
|
|
437
437
|
selectedId: t,
|
|
438
438
|
multiSelection: n,
|
|
439
|
-
activeChildElement:
|
|
440
|
-
hoveredElementId:
|
|
441
|
-
hideHandles:
|
|
439
|
+
activeChildElement: r,
|
|
440
|
+
hoveredElementId: i,
|
|
441
|
+
hideHandles: d,
|
|
442
442
|
setSelectedId: o,
|
|
443
443
|
setMultiSelection: s,
|
|
444
|
-
setHoveredElementId:
|
|
444
|
+
setHoveredElementId: a,
|
|
445
445
|
setHideHandles: z,
|
|
446
|
-
handleSelectionChange:
|
|
446
|
+
handleSelectionChange: F,
|
|
447
447
|
handleActiveChildChange: V
|
|
448
448
|
}),
|
|
449
449
|
[
|
|
450
450
|
t,
|
|
451
451
|
n,
|
|
452
|
-
i,
|
|
453
452
|
r,
|
|
454
|
-
|
|
455
|
-
|
|
453
|
+
i,
|
|
454
|
+
d,
|
|
455
|
+
F,
|
|
456
456
|
V
|
|
457
457
|
]
|
|
458
458
|
);
|
|
459
459
|
return /* @__PURE__ */ k(ee.Provider, { value: E, children: e });
|
|
460
460
|
};
|
|
461
|
-
function
|
|
461
|
+
function Qe() {
|
|
462
462
|
const e = Y(ee);
|
|
463
463
|
if (!e)
|
|
464
464
|
throw new Error("useSelectionContext must be used within a SelectionProvider (or EditorProvider)");
|
|
465
465
|
return e;
|
|
466
466
|
}
|
|
467
|
-
const oe = Q(null),
|
|
467
|
+
const oe = Q(null), to = ({ children: e, value: t }) => {
|
|
468
468
|
const o = q(
|
|
469
469
|
() => ({
|
|
470
470
|
undo: t.undo,
|
|
@@ -489,37 +489,37 @@ const oe = Q(null), Ze = ({ children: e, value: t }) => {
|
|
|
489
489
|
);
|
|
490
490
|
return /* @__PURE__ */ k(oe.Provider, { value: o, children: e });
|
|
491
491
|
};
|
|
492
|
-
function
|
|
492
|
+
function Ro() {
|
|
493
493
|
const e = Y(oe);
|
|
494
494
|
if (!e)
|
|
495
495
|
throw new Error("useHistoryContext must be used within a HistoryProvider (or EditorProvider)");
|
|
496
496
|
return e;
|
|
497
497
|
}
|
|
498
|
-
const ne = Q(null),
|
|
499
|
-
const [t, o] = b(null), [n, s] = b(!1), [
|
|
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
500
|
() => ({
|
|
501
501
|
expandedPanelType: t,
|
|
502
502
|
setExpandedPanelType: o,
|
|
503
503
|
isToolbarMenuOpen: n,
|
|
504
504
|
setIsToolbarMenuOpen: s,
|
|
505
|
-
textSelectionVersion:
|
|
505
|
+
textSelectionVersion: r,
|
|
506
506
|
setTextSelectionVersion: c,
|
|
507
|
-
isCanvasReady:
|
|
508
|
-
setCanvasReady:
|
|
509
|
-
isRotating:
|
|
507
|
+
isCanvasReady: i,
|
|
508
|
+
setCanvasReady: a,
|
|
509
|
+
isRotating: d,
|
|
510
510
|
setIsRotating: z
|
|
511
511
|
}),
|
|
512
|
-
[t, n,
|
|
512
|
+
[t, n, r, i, d]
|
|
513
513
|
);
|
|
514
|
-
return /* @__PURE__ */ k(ne.Provider, { value:
|
|
514
|
+
return /* @__PURE__ */ k(ne.Provider, { value: F, children: e });
|
|
515
515
|
};
|
|
516
|
-
function
|
|
516
|
+
function oo() {
|
|
517
517
|
const e = Y(ne);
|
|
518
518
|
if (!e)
|
|
519
519
|
throw new Error("useToolStateContext must be used within a ToolStateProvider (or EditorProvider)");
|
|
520
520
|
return e;
|
|
521
521
|
}
|
|
522
|
-
const re = Q(null),
|
|
522
|
+
const re = Q(null), no = ({ children: e, value: t }) => {
|
|
523
523
|
const o = q(
|
|
524
524
|
() => ({
|
|
525
525
|
elements: t.elements,
|
|
@@ -576,13 +576,13 @@ const re = Q(null), Qe = ({ children: e, value: t }) => {
|
|
|
576
576
|
);
|
|
577
577
|
return /* @__PURE__ */ k(re.Provider, { value: o, children: e });
|
|
578
578
|
};
|
|
579
|
-
function
|
|
579
|
+
function Io() {
|
|
580
580
|
const e = Y(re);
|
|
581
581
|
if (!e)
|
|
582
582
|
throw new Error("useElementsContext must be used within an ElementsProvider (or EditorProvider)");
|
|
583
583
|
return e;
|
|
584
584
|
}
|
|
585
|
-
const ie = Q(null),
|
|
585
|
+
const ie = Q(null), ro = ({ children: e, value: t }) => {
|
|
586
586
|
const o = q(
|
|
587
587
|
() => ({
|
|
588
588
|
executeElementUpdate: t.executeElementUpdate,
|
|
@@ -625,31 +625,31 @@ const ie = Q(null), to = ({ children: e, value: t }) => {
|
|
|
625
625
|
);
|
|
626
626
|
return /* @__PURE__ */ k(ie.Provider, { value: o, children: e });
|
|
627
627
|
};
|
|
628
|
-
function
|
|
628
|
+
function Co() {
|
|
629
629
|
const e = Y(ie);
|
|
630
630
|
if (!e)
|
|
631
631
|
throw new Error("useCommandContext must be used within a CommandProvider (or EditorProvider)");
|
|
632
632
|
return e;
|
|
633
633
|
}
|
|
634
|
-
const
|
|
634
|
+
const io = Zt("EditorContext"), se = Q(null), ce = Q(null), To = () => {
|
|
635
635
|
const e = Y(ce);
|
|
636
636
|
if (!e)
|
|
637
637
|
throw new Error("useEditorHandles must be used within EditorProvider");
|
|
638
638
|
return e;
|
|
639
|
-
},
|
|
640
|
-
const s = pt(null),
|
|
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
641
|
() => t.getAllArtboards()
|
|
642
|
-
), [
|
|
642
|
+
), [F, V] = b(0), [E, D] = b(
|
|
643
643
|
() => new Wt()
|
|
644
644
|
), p = q(() => E.toArray(), [E]), h = m((u) => {
|
|
645
645
|
D((A) => {
|
|
646
|
-
const x = A.toArray(),
|
|
647
|
-
return
|
|
646
|
+
const x = A.toArray(), C = typeof u == "function" ? u(x) : u;
|
|
647
|
+
return C === x ? A : Wt.fromArray(C);
|
|
648
648
|
});
|
|
649
649
|
}, []), S = m(
|
|
650
650
|
(u) => E.get(u),
|
|
651
651
|
[E]
|
|
652
|
-
), [
|
|
652
|
+
), [v, R] = b([]), w = i.selectedId ? E.get(i.selectedId) : void 0, L = m(() => {
|
|
653
653
|
z([...t.getAllArtboards()]), V((u) => u + 1);
|
|
654
654
|
}, [t]), {
|
|
655
655
|
historyManager: nt,
|
|
@@ -659,7 +659,7 @@ const eo = Zt("EditorContext"), se = Q(null), ce = Q(null), Ro = () => {
|
|
|
659
659
|
executeReorderElement: f,
|
|
660
660
|
executeCommandBatch: g,
|
|
661
661
|
executeCreateArtboard: y,
|
|
662
|
-
executeDeleteArtboard:
|
|
662
|
+
executeDeleteArtboard: I,
|
|
663
663
|
executeUpdateArtboard: $,
|
|
664
664
|
undo: P,
|
|
665
665
|
redo: U,
|
|
@@ -669,7 +669,7 @@ const eo = Zt("EditorContext"), se = Q(null), ce = Q(null), Ro = () => {
|
|
|
669
669
|
redoActiveArtboard: X,
|
|
670
670
|
canUndoActiveArtboard: rt,
|
|
671
671
|
canRedoActiveArtboard: K
|
|
672
|
-
} =
|
|
672
|
+
} = $e(
|
|
673
673
|
p,
|
|
674
674
|
h,
|
|
675
675
|
t,
|
|
@@ -680,31 +680,31 @@ const eo = Zt("EditorContext"), se = Q(null), ce = Q(null), Ro = () => {
|
|
|
680
680
|
_(A, u);
|
|
681
681
|
},
|
|
682
682
|
[E, _]
|
|
683
|
-
),
|
|
683
|
+
), me = m(
|
|
684
684
|
(u) => {
|
|
685
685
|
if (!w || !(w instanceof jt))
|
|
686
686
|
return;
|
|
687
687
|
const A = w.clone(), x = A.children.findIndex(
|
|
688
|
-
(
|
|
688
|
+
(C) => C.id === u.id
|
|
689
689
|
);
|
|
690
690
|
x >= 0 && (A.children[x] = u, G(A));
|
|
691
691
|
},
|
|
692
692
|
[w, G]
|
|
693
|
-
),
|
|
693
|
+
), he = i.activeChildElement || w, fe = i.activeChildElement ? me : G, {
|
|
694
694
|
fontSize: bt,
|
|
695
695
|
fontColor: wt,
|
|
696
696
|
fontFamily: Et,
|
|
697
697
|
textAlign: St,
|
|
698
698
|
updateFontSize: Rt,
|
|
699
|
-
setFontSizeValue:
|
|
700
|
-
updateFontColor:
|
|
699
|
+
setFontSizeValue: It,
|
|
700
|
+
updateFontColor: Ct,
|
|
701
701
|
updateFontFamily: Tt,
|
|
702
702
|
updateTextAlign: Ot
|
|
703
|
-
} =
|
|
703
|
+
} = Be(he, fe), At = m(
|
|
704
704
|
async (u) => {
|
|
705
705
|
var Lt;
|
|
706
|
-
const A = u.type, x = u,
|
|
707
|
-
if (!
|
|
706
|
+
const A = u.type, x = u, C = t.getActiveArtboardId();
|
|
707
|
+
if (!C)
|
|
708
708
|
throw new ot(
|
|
709
709
|
"E_NO_ACTIVE_ARTBOARD",
|
|
710
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).`,
|
|
@@ -736,7 +736,7 @@ const eo = Zt("EditorContext"), se = Q(null), ce = Q(null), Ro = () => {
|
|
|
736
736
|
return Z && (W.imageLoaded = !1, W.imageElement = null, W.isCropping = !1, W.imageUrl = Z, W.preserveDimensions = !1, W.onLoadCallback = (J) => {
|
|
737
737
|
const $t = J.transformData.width, Bt = J.transformData.height, kt = Math.min(et / $t, et / Bt, 1);
|
|
738
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,
|
|
739
|
+
}), M(W, C), i.setSelectedId(W.id), Z && W.loadImage(Z), { id: W.id, name: u.name ?? "" };
|
|
740
740
|
}
|
|
741
741
|
let tt;
|
|
742
742
|
const at = {
|
|
@@ -745,14 +745,14 @@ 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 = Pe(at);
|
|
749
749
|
if (!zt || !zt.Component)
|
|
750
750
|
throw new Error(`[EditorContext] no transform registered for element type "${A}"`);
|
|
751
|
-
const ht = t.getActiveArtboard(),
|
|
751
|
+
const ht = t.getActiveArtboard(), pe = ht ? Math.min(ht.width, ht.height) * 0.1 : 80, Ht = ht ? ht.width * 0.5 : 300;
|
|
752
752
|
if (A === "shape") {
|
|
753
753
|
const ft = (x == null ? void 0 : x.shapeType) ?? "rectangle";
|
|
754
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
|
|
755
|
+
ft === "ellipse" ? (et = 150 / j, Z = 250 / j) : ft === "line" && (et = 300 / j, Z = 8 / j), tt = new Ne({
|
|
756
756
|
id: T,
|
|
757
757
|
name: u.name,
|
|
758
758
|
x: mt,
|
|
@@ -773,13 +773,13 @@ const eo = Zt("EditorContext"), se = Q(null), ce = Q(null), Ro = () => {
|
|
|
773
773
|
text: "New Text",
|
|
774
774
|
x: mt,
|
|
775
775
|
y: st,
|
|
776
|
-
fontSize:
|
|
776
|
+
fontSize: pe,
|
|
777
777
|
fontFamily: "Poppins",
|
|
778
|
-
color:
|
|
778
|
+
color: Ke(B == null ? void 0 : B.backgroundColor),
|
|
779
779
|
transformData: at === "arch" ? {
|
|
780
780
|
type: "arch",
|
|
781
781
|
width: Ht,
|
|
782
|
-
archHeight:
|
|
782
|
+
archHeight: ze.archHeight
|
|
783
783
|
} : at === "wave" ? {
|
|
784
784
|
type: "wave",
|
|
785
785
|
width: Ht,
|
|
@@ -790,23 +790,23 @@ const eo = Zt("EditorContext"), se = Q(null), ce = Q(null), Ro = () => {
|
|
|
790
790
|
radius: Ht / 2
|
|
791
791
|
} : void 0
|
|
792
792
|
});
|
|
793
|
-
return t.addElementToArtboard(T,
|
|
793
|
+
return t.addElementToArtboard(T, C), M(
|
|
794
794
|
tt,
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
),
|
|
795
|
+
C,
|
|
796
|
+
i.selectedId || void 0
|
|
797
|
+
), i.setSelectedId(T), { id: T, name: u.name ?? "" };
|
|
798
798
|
},
|
|
799
|
-
[t, M, _,
|
|
800
|
-
),
|
|
799
|
+
[t, M, _, i, c.zoom, n]
|
|
800
|
+
), vt = m(
|
|
801
801
|
async (u, A) => {
|
|
802
802
|
await At({ ...A, type: u });
|
|
803
803
|
},
|
|
804
804
|
[At]
|
|
805
|
-
),
|
|
805
|
+
), Ft = m(() => {
|
|
806
806
|
const u = [];
|
|
807
|
-
if (
|
|
807
|
+
if (i.multiSelection.length > 0) {
|
|
808
808
|
const A = p.filter(
|
|
809
|
-
(x) =>
|
|
809
|
+
(x) => i.multiSelection.includes(x.id)
|
|
810
810
|
);
|
|
811
811
|
u.push(...A);
|
|
812
812
|
} else w && u.push(w);
|
|
@@ -814,70 +814,70 @@ const eo = Zt("EditorContext"), se = Q(null), ce = Q(null), Ro = () => {
|
|
|
814
814
|
const A = u.map((x) => x.clone());
|
|
815
815
|
R(A);
|
|
816
816
|
}
|
|
817
|
-
}, [w,
|
|
818
|
-
if (
|
|
817
|
+
}, [w, i.multiSelection, p]), Pt = m(() => {
|
|
818
|
+
if (v.length === 0) return;
|
|
819
819
|
const u = [], A = 30, x = 30;
|
|
820
|
-
|
|
821
|
-
const T = E.get(
|
|
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
822
|
delete st.id;
|
|
823
|
-
const j =
|
|
823
|
+
const j = C.constructor, tt = new j(st);
|
|
824
824
|
tt.x = B + A, tt.y = mt + x;
|
|
825
825
|
let ct = null;
|
|
826
826
|
if (T && (ct = t.getArtboardIdForElement(
|
|
827
827
|
T.id
|
|
828
828
|
)), ct || (ct = t.getActiveArtboardId()), !ct) {
|
|
829
|
-
|
|
829
|
+
io.warn("[handlePasteElements] No artboard found for pasting");
|
|
830
830
|
return;
|
|
831
831
|
}
|
|
832
832
|
const at = T ? T.id : void 0;
|
|
833
833
|
M(tt, ct, at), u.push(tt.id);
|
|
834
|
-
}), u.length === 1 ?
|
|
834
|
+
}), u.length === 1 ? i.handleSelectionChange(u[0]) : u.length > 1 && i.setMultiSelection(u);
|
|
835
835
|
}, [
|
|
836
|
-
|
|
836
|
+
v,
|
|
837
837
|
E,
|
|
838
838
|
t,
|
|
839
839
|
M,
|
|
840
|
-
|
|
840
|
+
i
|
|
841
841
|
]), yt = m(() => {
|
|
842
|
-
if (
|
|
842
|
+
if (a.expandedPanelType === "crop" && (w == null ? void 0 : w.transformType) === "image") {
|
|
843
843
|
const u = w;
|
|
844
844
|
if (u.isCropping) {
|
|
845
845
|
const A = u.clone();
|
|
846
846
|
A.exitCropMode(), _(u, A);
|
|
847
847
|
}
|
|
848
848
|
}
|
|
849
|
-
|
|
849
|
+
a.setExpandedPanelType(null);
|
|
850
850
|
}, [
|
|
851
|
-
|
|
852
|
-
|
|
851
|
+
a.expandedPanelType,
|
|
852
|
+
a.setExpandedPanelType,
|
|
853
853
|
w,
|
|
854
854
|
_
|
|
855
855
|
]);
|
|
856
856
|
Dt(() => {
|
|
857
857
|
const u = (A) => {
|
|
858
858
|
const x = A.target;
|
|
859
|
-
if (x.tagName === "CANVAS" ||
|
|
859
|
+
if (x.tagName === "CANVAS" || We(x))
|
|
860
860
|
return;
|
|
861
861
|
const T = document.activeElement;
|
|
862
862
|
if (T != null && T.hasAttribute("data-preserve-selection")) {
|
|
863
863
|
T.blur();
|
|
864
864
|
return;
|
|
865
865
|
}
|
|
866
|
-
if (
|
|
866
|
+
if (a.expandedPanelType !== null) {
|
|
867
867
|
yt();
|
|
868
868
|
return;
|
|
869
869
|
}
|
|
870
|
-
|
|
870
|
+
i.selectedId !== null && i.setSelectedId(null), i.multiSelection.length > 0 && i.setMultiSelection([]);
|
|
871
871
|
};
|
|
872
872
|
return document.addEventListener("pointerdown", u), () => document.removeEventListener("pointerdown", u);
|
|
873
|
-
}, [
|
|
873
|
+
}, [a.expandedPanelType, yt, i]);
|
|
874
874
|
const Nt = m(
|
|
875
875
|
(u, A, x) => {
|
|
876
|
-
t.clear(), u.forEach((
|
|
877
|
-
t.createArtboard(
|
|
878
|
-
}), x && t.setActiveArtboard(x), z([...t.getAllArtboards()]), V((
|
|
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
879
|
},
|
|
880
|
-
[t,
|
|
880
|
+
[t, i, h]
|
|
881
881
|
), _t = q(() => ({
|
|
882
882
|
// From ViewportContext
|
|
883
883
|
zoom: c.zoom,
|
|
@@ -891,33 +891,33 @@ const eo = Zt("EditorContext"), se = Q(null), ce = Q(null), Ro = () => {
|
|
|
891
891
|
setPanOffset: c.setPanOffset,
|
|
892
892
|
setIsPanning: c.setIsPanning,
|
|
893
893
|
// From SelectionContext
|
|
894
|
-
selectedId:
|
|
895
|
-
multiSelection:
|
|
896
|
-
activeChildElement:
|
|
897
|
-
hoveredElementId:
|
|
898
|
-
hideHandles:
|
|
899
|
-
setSelectedId:
|
|
900
|
-
setMultiSelection:
|
|
901
|
-
setHoveredElementId:
|
|
902
|
-
setHideHandles:
|
|
903
|
-
handleSelectionChange:
|
|
904
|
-
handleActiveChildChange:
|
|
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
905
|
// From ToolStateContext
|
|
906
|
-
expandedPanelType:
|
|
907
|
-
setExpandedPanelType:
|
|
908
|
-
isToolbarMenuOpen:
|
|
909
|
-
setIsToolbarMenuOpen:
|
|
910
|
-
textSelectionVersion:
|
|
911
|
-
setTextSelectionVersion:
|
|
912
|
-
isCanvasReady:
|
|
913
|
-
setCanvasReady:
|
|
914
|
-
isRotating:
|
|
915
|
-
setIsRotating:
|
|
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
916
|
// Cross-context handler
|
|
917
917
|
clearExpandedPanel: yt,
|
|
918
918
|
// Core state (element/artboard domain)
|
|
919
919
|
artboardManager: t,
|
|
920
|
-
artboards:
|
|
920
|
+
artboards: d,
|
|
921
921
|
elements: p,
|
|
922
922
|
elementStore: E,
|
|
923
923
|
getElementById: S,
|
|
@@ -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: F,
|
|
933
933
|
// Handlers
|
|
934
934
|
refreshArtboards: L,
|
|
935
935
|
handleElementUpdate: G,
|
|
936
936
|
addElement: At,
|
|
937
|
-
handleAddElement:
|
|
937
|
+
handleAddElement: vt,
|
|
938
938
|
handleLoadWorkspace: Nt,
|
|
939
|
-
handleCopyElements:
|
|
939
|
+
handleCopyElements: Ft,
|
|
940
940
|
handlePasteElements: Pt,
|
|
941
|
-
hasClipboardContent:
|
|
941
|
+
hasClipboardContent: v.length > 0,
|
|
942
942
|
// Command history (undo/redo actions + execute functions)
|
|
943
943
|
historyManager: nt,
|
|
944
944
|
executeElementUpdate: _,
|
|
@@ -947,7 +947,7 @@ const eo = Zt("EditorContext"), se = Q(null), ce = Q(null), Ro = () => {
|
|
|
947
947
|
executeReorderElement: f,
|
|
948
948
|
executeCommandBatch: g,
|
|
949
949
|
executeCreateArtboard: y,
|
|
950
|
-
executeDeleteArtboard:
|
|
950
|
+
executeDeleteArtboard: I,
|
|
951
951
|
executeUpdateArtboard: $,
|
|
952
952
|
undo: P,
|
|
953
953
|
redo: U,
|
|
@@ -963,8 +963,8 @@ const eo = Zt("EditorContext"), se = Q(null), ce = Q(null), Ro = () => {
|
|
|
963
963
|
fontFamily: Et,
|
|
964
964
|
textAlign: St,
|
|
965
965
|
updateFontSize: Rt,
|
|
966
|
-
setFontSizeValue:
|
|
967
|
-
updateFontColor:
|
|
966
|
+
setFontSizeValue: It,
|
|
967
|
+
updateFontColor: Ct,
|
|
968
968
|
updateFontFamily: Tt,
|
|
969
969
|
updateTextAlign: Ot
|
|
970
970
|
}), [
|
|
@@ -980,32 +980,32 @@ const eo = Zt("EditorContext"), se = Q(null), ce = Q(null), Ro = () => {
|
|
|
980
980
|
c.setPanOffset,
|
|
981
981
|
c.setIsPanning,
|
|
982
982
|
// Selection
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
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
994
|
// Tool state
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
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
1005
|
yt,
|
|
1006
1006
|
// Element/artboard domain
|
|
1007
1007
|
t,
|
|
1008
|
-
|
|
1008
|
+
d,
|
|
1009
1009
|
p,
|
|
1010
1010
|
E,
|
|
1011
1011
|
S,
|
|
@@ -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
|
+
F,
|
|
1017
1017
|
L,
|
|
1018
1018
|
G,
|
|
1019
1019
|
At,
|
|
1020
|
-
Ft,
|
|
1021
|
-
Nt,
|
|
1022
1020
|
vt,
|
|
1021
|
+
Nt,
|
|
1022
|
+
Ft,
|
|
1023
1023
|
Pt,
|
|
1024
|
-
|
|
1024
|
+
v,
|
|
1025
1025
|
// Command history
|
|
1026
1026
|
nt,
|
|
1027
1027
|
_,
|
|
@@ -1030,7 +1030,7 @@ const eo = Zt("EditorContext"), se = Q(null), ce = Q(null), Ro = () => {
|
|
|
1030
1030
|
f,
|
|
1031
1031
|
g,
|
|
1032
1032
|
y,
|
|
1033
|
-
|
|
1033
|
+
I,
|
|
1034
1034
|
$,
|
|
1035
1035
|
P,
|
|
1036
1036
|
U,
|
|
@@ -1046,13 +1046,13 @@ const eo = Zt("EditorContext"), se = Q(null), ce = Q(null), Ro = () => {
|
|
|
1046
1046
|
Et,
|
|
1047
1047
|
St,
|
|
1048
1048
|
Rt,
|
|
1049
|
-
Ct,
|
|
1050
1049
|
It,
|
|
1050
|
+
Ct,
|
|
1051
1051
|
Tt,
|
|
1052
1052
|
Ot
|
|
1053
1053
|
]);
|
|
1054
|
-
return s.current = _t, /* @__PURE__ */ k(ce.Provider, { value:
|
|
1055
|
-
|
|
1054
|
+
return s.current = _t, /* @__PURE__ */ k(ce.Provider, { value: r, children: /* @__PURE__ */ k(
|
|
1055
|
+
to,
|
|
1056
1056
|
{
|
|
1057
1057
|
value: {
|
|
1058
1058
|
undo: P,
|
|
@@ -1065,36 +1065,36 @@ const eo = Zt("EditorContext"), se = Q(null), ce = Q(null), Ro = () => {
|
|
|
1065
1065
|
canRedoActiveArtboard: K
|
|
1066
1066
|
},
|
|
1067
1067
|
children: /* @__PURE__ */ k(
|
|
1068
|
-
|
|
1068
|
+
no,
|
|
1069
1069
|
{
|
|
1070
1070
|
value: {
|
|
1071
1071
|
elements: p,
|
|
1072
1072
|
elementStore: E,
|
|
1073
|
-
artboards:
|
|
1073
|
+
artboards: d,
|
|
1074
1074
|
artboardManager: t,
|
|
1075
|
-
artboardVersion:
|
|
1075
|
+
artboardVersion: F,
|
|
1076
1076
|
setElements: h,
|
|
1077
1077
|
refreshArtboards: L,
|
|
1078
1078
|
getElementById: S,
|
|
1079
|
-
handleAddElement:
|
|
1079
|
+
handleAddElement: vt,
|
|
1080
1080
|
handleElementUpdate: G,
|
|
1081
1081
|
handleLoadWorkspace: Nt,
|
|
1082
|
-
handleCopyElements:
|
|
1082
|
+
handleCopyElements: Ft,
|
|
1083
1083
|
handlePasteElements: Pt,
|
|
1084
1084
|
fontSize: bt,
|
|
1085
1085
|
fontColor: wt,
|
|
1086
1086
|
fontFamily: Et,
|
|
1087
1087
|
textAlign: St,
|
|
1088
1088
|
updateFontSize: Rt,
|
|
1089
|
-
setFontSizeValue:
|
|
1090
|
-
updateFontColor:
|
|
1089
|
+
setFontSizeValue: It,
|
|
1090
|
+
updateFontColor: Ct,
|
|
1091
1091
|
updateFontFamily: Tt,
|
|
1092
1092
|
updateTextAlign: Ot,
|
|
1093
1093
|
canvasRef: o,
|
|
1094
1094
|
canvasEditorRef: n
|
|
1095
1095
|
},
|
|
1096
1096
|
children: /* @__PURE__ */ k(
|
|
1097
|
-
|
|
1097
|
+
ro,
|
|
1098
1098
|
{
|
|
1099
1099
|
value: {
|
|
1100
1100
|
executeElementUpdate: _,
|
|
@@ -1103,7 +1103,7 @@ const eo = Zt("EditorContext"), se = Q(null), ce = Q(null), Ro = () => {
|
|
|
1103
1103
|
executeReorderElement: f,
|
|
1104
1104
|
executeCommandBatch: g,
|
|
1105
1105
|
executeCreateArtboard: y,
|
|
1106
|
-
executeDeleteArtboard:
|
|
1106
|
+
executeDeleteArtboard: I,
|
|
1107
1107
|
executeUpdateArtboard: $,
|
|
1108
1108
|
undo: P,
|
|
1109
1109
|
redo: U,
|
|
@@ -1122,57 +1122,57 @@ const eo = Zt("EditorContext"), se = Q(null), ce = Q(null), Ro = () => {
|
|
|
1122
1122
|
)
|
|
1123
1123
|
}
|
|
1124
1124
|
) });
|
|
1125
|
-
},
|
|
1125
|
+
}, Oo = ({
|
|
1126
1126
|
children: e,
|
|
1127
1127
|
initialArtboardConfig: t = {},
|
|
1128
1128
|
viewPadding: o = 0.9
|
|
1129
1129
|
}) => {
|
|
1130
1130
|
const [n] = b(() => {
|
|
1131
|
-
const c = new
|
|
1131
|
+
const c = new ve(), i = {
|
|
1132
1132
|
name: t.name || "Artboard 1",
|
|
1133
1133
|
x: t.x ?? 0,
|
|
1134
1134
|
y: t.y ?? 0,
|
|
1135
1135
|
width: t.width ?? 1e3,
|
|
1136
1136
|
height: t.height ?? 1e3,
|
|
1137
|
-
backgroundColor: t.backgroundColor ||
|
|
1137
|
+
backgroundColor: t.backgroundColor || Oe
|
|
1138
1138
|
};
|
|
1139
|
-
return c.createArtboard(
|
|
1140
|
-
}), s = pt(null),
|
|
1139
|
+
return c.createArtboard(i), c;
|
|
1140
|
+
}), s = pt(null), r = pt(null);
|
|
1141
1141
|
return /* @__PURE__ */ k(
|
|
1142
|
-
|
|
1142
|
+
Ze,
|
|
1143
1143
|
{
|
|
1144
1144
|
artboardManager: n,
|
|
1145
1145
|
canvasRef: s,
|
|
1146
1146
|
viewPadding: o,
|
|
1147
|
-
children: /* @__PURE__ */ k(
|
|
1148
|
-
|
|
1147
|
+
children: /* @__PURE__ */ k(qe, { children: /* @__PURE__ */ k(eo, { children: /* @__PURE__ */ k(
|
|
1148
|
+
so,
|
|
1149
1149
|
{
|
|
1150
1150
|
artboardManager: n,
|
|
1151
1151
|
canvasRef: s,
|
|
1152
|
-
canvasEditorRef:
|
|
1152
|
+
canvasEditorRef: r,
|
|
1153
1153
|
children: e
|
|
1154
1154
|
}
|
|
1155
1155
|
) }) })
|
|
1156
1156
|
}
|
|
1157
1157
|
);
|
|
1158
|
-
},
|
|
1158
|
+
}, vo = () => {
|
|
1159
1159
|
const e = Y(se);
|
|
1160
1160
|
if (!e)
|
|
1161
1161
|
throw new Error("useEditor must be used within EditorProvider");
|
|
1162
1162
|
return e;
|
|
1163
1163
|
}, ut = [];
|
|
1164
|
-
function
|
|
1165
|
-
|
|
1164
|
+
function Fo(e) {
|
|
1165
|
+
ke() && ut.push(e);
|
|
1166
1166
|
}
|
|
1167
|
-
function
|
|
1167
|
+
function Po() {
|
|
1168
1168
|
return [...ut];
|
|
1169
1169
|
}
|
|
1170
|
-
function
|
|
1170
|
+
function No() {
|
|
1171
1171
|
ut.length = 0;
|
|
1172
1172
|
}
|
|
1173
|
-
function
|
|
1173
|
+
function zo() {
|
|
1174
1174
|
if (ut.length === 0) return;
|
|
1175
|
-
const e = ut.map((t) =>
|
|
1175
|
+
const e = ut.map((t) => He(t) ? `${t.code}: ${t.message}` : `${t.name}: ${t.message}`).join(`
|
|
1176
1176
|
- `);
|
|
1177
1177
|
throw ut.length = 0, new Error(
|
|
1178
1178
|
`expectNoEditorErrors: ${e.includes(`
|
|
@@ -1181,7 +1181,7 @@ function vo() {
|
|
|
1181
1181
|
A contained error renders an error card in prod — this composition is broken even if the test rendered "successfully".`
|
|
1182
1182
|
);
|
|
1183
1183
|
}
|
|
1184
|
-
const
|
|
1184
|
+
const co = 1;
|
|
1185
1185
|
function it(e) {
|
|
1186
1186
|
return typeof e == "number" && Number.isFinite(e) ? Math.round(e * 100) / 100 : e;
|
|
1187
1187
|
}
|
|
@@ -1195,31 +1195,31 @@ function ae(e) {
|
|
|
1195
1195
|
...e.rotation !== void 0 && { rotation: it(e.rotation) }
|
|
1196
1196
|
};
|
|
1197
1197
|
}
|
|
1198
|
-
function
|
|
1198
|
+
function ao(e) {
|
|
1199
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
|
-
for (const
|
|
1202
|
-
const c =
|
|
1203
|
-
o[
|
|
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
1204
|
}
|
|
1205
1205
|
return {
|
|
1206
|
-
schemaVersion:
|
|
1207
|
-
artboards: t.map((
|
|
1206
|
+
schemaVersion: co,
|
|
1207
|
+
artboards: t.map((r, c) => ({
|
|
1208
1208
|
id: `artboard-${c + 1}`,
|
|
1209
|
-
name:
|
|
1209
|
+
name: r.name || "Front",
|
|
1210
1210
|
x: 0,
|
|
1211
1211
|
y: 0,
|
|
1212
|
-
width: it(
|
|
1213
|
-
height: it(
|
|
1214
|
-
backgroundColor:
|
|
1212
|
+
width: it(r.width || 800),
|
|
1213
|
+
height: it(r.height || 800),
|
|
1214
|
+
backgroundColor: r.backgroundColor || "transparent",
|
|
1215
1215
|
// Pass the artboard's flag through — the server worker only paints the
|
|
1216
1216
|
// background when this is true. Hardcoding `false` here silently dropped
|
|
1217
1217
|
// explicitly-set artboard backgrounds from every realtime mockup while
|
|
1218
1218
|
// the editor kept showing them (WYSIWYG drift).
|
|
1219
|
-
exportBackground:
|
|
1219
|
+
exportBackground: r.exportBackground ?? !1,
|
|
1220
1220
|
elements: o[c],
|
|
1221
|
-
distressTexture:
|
|
1222
|
-
imageMask:
|
|
1221
|
+
distressTexture: r.distressTexture,
|
|
1222
|
+
imageMask: r.imageMask
|
|
1223
1223
|
})),
|
|
1224
1224
|
// Custom (brand) font dependencies ride the wire so the server worker can
|
|
1225
1225
|
// load them — without this, server renders of custom-font designs fall
|
|
@@ -1227,87 +1227,87 @@ function ro(e) {
|
|
|
1227
1227
|
...(s = e.customFonts) != null && s.length ? { customFonts: e.customFonts } : {}
|
|
1228
1228
|
};
|
|
1229
1229
|
}
|
|
1230
|
-
function
|
|
1230
|
+
function de(e) {
|
|
1231
1231
|
const t = e.type || e.transformType;
|
|
1232
1232
|
if (t === "image")
|
|
1233
|
-
return
|
|
1233
|
+
return lo(e);
|
|
1234
1234
|
const { artboard: o, ...n } = e;
|
|
1235
|
-
return ae({
|
|
1235
|
+
return t === "group" && Array.isArray(e.children) && (n.children = e.children.filter((s) => s && s.visible !== !1).map(de)), ae({
|
|
1236
1236
|
...n,
|
|
1237
1237
|
type: t
|
|
1238
1238
|
});
|
|
1239
1239
|
}
|
|
1240
|
-
function
|
|
1241
|
-
var
|
|
1242
|
-
const t = e.transformData || {}, o = e
|
|
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
1243
|
id: e.id,
|
|
1244
1244
|
type: "image",
|
|
1245
1245
|
x: e.x || 0,
|
|
1246
1246
|
y: e.y || 0,
|
|
1247
|
-
width:
|
|
1248
|
-
height:
|
|
1247
|
+
width: c,
|
|
1248
|
+
height: i,
|
|
1249
1249
|
rotation: e.rotation || 0,
|
|
1250
1250
|
imageUrl: e.imageUrl,
|
|
1251
1251
|
imageAspectRatio: e.imageAspectRatio
|
|
1252
1252
|
};
|
|
1253
|
-
return
|
|
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
1254
|
}
|
|
1255
|
-
const Gt = "center",
|
|
1256
|
-
function
|
|
1257
|
-
return typeof e == "object" && e !== null && e[
|
|
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
1258
|
}
|
|
1259
|
-
function
|
|
1260
|
-
return Object.freeze({ kind: e, name: t, [
|
|
1259
|
+
function uo(e, t) {
|
|
1260
|
+
return Object.freeze({ kind: e, name: t, [le]: !0 });
|
|
1261
1261
|
}
|
|
1262
|
-
const
|
|
1263
|
-
function
|
|
1264
|
-
return typeof e == "object" && e !== null && e[
|
|
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
1265
|
}
|
|
1266
|
-
function
|
|
1267
|
-
return Object.freeze({ name: e, value: t, [
|
|
1266
|
+
function ho(e, t) {
|
|
1267
|
+
return Object.freeze({ name: e, value: t, [ue]: !0 });
|
|
1268
1268
|
}
|
|
1269
|
-
function
|
|
1269
|
+
function fo(e) {
|
|
1270
1270
|
let t = e.trim().toUpperCase();
|
|
1271
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
1272
|
}
|
|
1273
1273
|
function xt(e) {
|
|
1274
|
-
return
|
|
1274
|
+
return mo(e) ? e.value : e;
|
|
1275
1275
|
}
|
|
1276
1276
|
function Vt(e) {
|
|
1277
1277
|
const t = e.transformType;
|
|
1278
1278
|
return t === "image" ? "image" : t === "shape" || t === "group" || t === "path" ? null : "text";
|
|
1279
1279
|
}
|
|
1280
|
-
function
|
|
1280
|
+
function po(e) {
|
|
1281
1281
|
return e === "top-left" || e === "left" || e === "bottom-left" ? "left" : e === "top-right" || e === "right" || e === "bottom-right" ? "right" : "center";
|
|
1282
1282
|
}
|
|
1283
|
-
function
|
|
1283
|
+
function Ao(e) {
|
|
1284
1284
|
return e === "top-left" || e === "top" || e === "top-right" ? "top" : e === "bottom-left" || e === "bottom" || e === "bottom-right" ? "bottom" : "middle";
|
|
1285
1285
|
}
|
|
1286
|
-
function Ut(e, t, o, n, s,
|
|
1287
|
-
const c =
|
|
1288
|
-
return { x:
|
|
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
1289
|
}
|
|
1290
|
-
function
|
|
1290
|
+
function yo(e, t, o) {
|
|
1291
1291
|
const n = t / o;
|
|
1292
1292
|
if (e >= n) {
|
|
1293
|
-
const c = o * e,
|
|
1293
|
+
const c = o * e, i = t / c;
|
|
1294
1294
|
return {
|
|
1295
1295
|
width: c,
|
|
1296
1296
|
height: o,
|
|
1297
|
-
cropX: (1 -
|
|
1297
|
+
cropX: (1 - i) / 2,
|
|
1298
1298
|
cropY: 0,
|
|
1299
|
-
cropWidth:
|
|
1299
|
+
cropWidth: i,
|
|
1300
1300
|
cropHeight: 1
|
|
1301
1301
|
};
|
|
1302
1302
|
}
|
|
1303
|
-
const s = t / e,
|
|
1303
|
+
const s = t / e, r = o / s;
|
|
1304
1304
|
return {
|
|
1305
1305
|
width: t,
|
|
1306
1306
|
height: s,
|
|
1307
1307
|
cropX: 0,
|
|
1308
|
-
cropY: (1 -
|
|
1308
|
+
cropY: (1 - r) / 2,
|
|
1309
1309
|
cropWidth: 1,
|
|
1310
|
-
cropHeight:
|
|
1310
|
+
cropHeight: r
|
|
1311
1311
|
};
|
|
1312
1312
|
}
|
|
1313
1313
|
class lt {
|
|
@@ -1315,19 +1315,19 @@ class lt {
|
|
|
1315
1315
|
if (this.els = [], this.colorRoles = /* @__PURE__ */ new Map(), this.idCounter = 0, !(t.width > 0) || !(t.height > 0))
|
|
1316
1316
|
throw new Error("design(): artboard width and height must be positive numbers");
|
|
1317
1317
|
for (const [o, n] of Object.entries(t.colors ?? {})) {
|
|
1318
|
-
const s =
|
|
1318
|
+
const s = fo(n);
|
|
1319
1319
|
if (s === null)
|
|
1320
1320
|
throw new ot(
|
|
1321
1321
|
"E_COLOR_ROLE_INVALID",
|
|
1322
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
1323
|
{ roleName: o, value: n, docSlug: "embed-mode" }
|
|
1324
1324
|
);
|
|
1325
|
-
const
|
|
1326
|
-
if (
|
|
1325
|
+
const r = [...this.colorRoles.entries()].find(([, c]) => c === s);
|
|
1326
|
+
if (r)
|
|
1327
1327
|
throw new ot(
|
|
1328
1328
|
"E_COLOR_ROLE_COLLISION",
|
|
1329
|
-
`color roles "${
|
|
1330
|
-
{ roles: [
|
|
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
1331
|
);
|
|
1332
1332
|
this.colorRoles.set(o, s);
|
|
1333
1333
|
}
|
|
@@ -1355,7 +1355,7 @@ class lt {
|
|
|
1355
1355
|
* emit all pages and `TemplateField.artboard` can scope fields per page.
|
|
1356
1356
|
*/
|
|
1357
1357
|
static fromState(t, o = {}) {
|
|
1358
|
-
const n = t.artboards.find((
|
|
1358
|
+
const n = t.artboards.find((r) => r.name === t.activeArtboard) ?? t.artboards[0];
|
|
1359
1359
|
if (!n)
|
|
1360
1360
|
throw new Error("DesignBuilder.fromState(): state has no artboards");
|
|
1361
1361
|
const s = new lt({
|
|
@@ -1366,13 +1366,13 @@ class lt {
|
|
|
1366
1366
|
role: n.role
|
|
1367
1367
|
});
|
|
1368
1368
|
if (o.artboards === "all") {
|
|
1369
|
-
s.allArtboards = t.artboards.map((
|
|
1370
|
-
for (const
|
|
1371
|
-
s.els.push(
|
|
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
1372
|
return s;
|
|
1373
1373
|
}
|
|
1374
|
-
for (const
|
|
1375
|
-
|
|
1374
|
+
for (const r of t.elements)
|
|
1375
|
+
r.artboard && r.artboard !== n.name || s.els.push({ ...r });
|
|
1376
1376
|
return s;
|
|
1377
1377
|
}
|
|
1378
1378
|
nextId(t) {
|
|
@@ -1435,23 +1435,23 @@ class lt {
|
|
|
1435
1435
|
}
|
|
1436
1436
|
background(t, o = {}) {
|
|
1437
1437
|
const { width: n, height: s } = this.current;
|
|
1438
|
-
let
|
|
1438
|
+
let r;
|
|
1439
1439
|
if (o.aspectRatio && o.aspectRatio > 0) {
|
|
1440
|
-
const
|
|
1441
|
-
|
|
1440
|
+
const i = yo(o.aspectRatio, n, s);
|
|
1441
|
+
r = {
|
|
1442
1442
|
type: "image",
|
|
1443
|
-
width:
|
|
1444
|
-
height:
|
|
1445
|
-
cropX:
|
|
1446
|
-
cropY:
|
|
1447
|
-
cropWidth:
|
|
1448
|
-
cropHeight:
|
|
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
1449
|
flipHorizontal: !1,
|
|
1450
1450
|
flipVertical: !1,
|
|
1451
1451
|
borderRadius: 0
|
|
1452
1452
|
};
|
|
1453
1453
|
} else
|
|
1454
|
-
|
|
1454
|
+
r = {
|
|
1455
1455
|
type: "image",
|
|
1456
1456
|
width: n,
|
|
1457
1457
|
height: s,
|
|
@@ -1472,24 +1472,24 @@ class lt {
|
|
|
1472
1472
|
opacity: o.opacity ?? 1,
|
|
1473
1473
|
imageUrl: t,
|
|
1474
1474
|
imageAspectRatio: o.aspectRatio,
|
|
1475
|
-
transformData:
|
|
1475
|
+
transformData: r,
|
|
1476
1476
|
name: o.name ?? "Background"
|
|
1477
1477
|
};
|
|
1478
1478
|
return this.els.unshift(c), this;
|
|
1479
1479
|
}
|
|
1480
1480
|
image(t, o = {}) {
|
|
1481
|
-
const { width: n, height: s } = this.current,
|
|
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
1482
|
id: this.nextId("img"),
|
|
1483
1483
|
transformType: "image",
|
|
1484
|
-
x:
|
|
1485
|
-
y:
|
|
1484
|
+
x: i,
|
|
1485
|
+
y: a,
|
|
1486
1486
|
rotation: o.rotation ?? 0,
|
|
1487
1487
|
opacity: o.opacity ?? 1,
|
|
1488
1488
|
imageUrl: t,
|
|
1489
1489
|
imageAspectRatio: o.aspectRatio,
|
|
1490
1490
|
transformData: {
|
|
1491
1491
|
type: "image",
|
|
1492
|
-
width:
|
|
1492
|
+
width: r,
|
|
1493
1493
|
height: c,
|
|
1494
1494
|
cropX: 0,
|
|
1495
1495
|
cropY: 0,
|
|
@@ -1501,17 +1501,17 @@ class lt {
|
|
|
1501
1501
|
},
|
|
1502
1502
|
...o.name ? { name: o.name } : {}
|
|
1503
1503
|
};
|
|
1504
|
-
return this.els.push(
|
|
1504
|
+
return this.els.push(d), this;
|
|
1505
1505
|
}
|
|
1506
1506
|
text(t, o = {}) {
|
|
1507
|
-
const { width: n, height: s } = this.current,
|
|
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
1508
|
id: this.nextId("text"),
|
|
1509
1509
|
transformType: "custom",
|
|
1510
1510
|
x: c,
|
|
1511
|
-
y:
|
|
1511
|
+
y: i,
|
|
1512
1512
|
rotation: o.rotation ?? 0,
|
|
1513
1513
|
text: t,
|
|
1514
|
-
fontSize:
|
|
1514
|
+
fontSize: r,
|
|
1515
1515
|
fontFamily: o.fontFamily ?? "Anton",
|
|
1516
1516
|
color: xt(o.color) ?? "#ffffff",
|
|
1517
1517
|
textAlign: o.textAlign ?? "center",
|
|
@@ -1520,7 +1520,7 @@ class lt {
|
|
|
1520
1520
|
transformData: { type: "custom" },
|
|
1521
1521
|
...o.name ? { name: o.name } : {}
|
|
1522
1522
|
};
|
|
1523
|
-
return this.els.push(
|
|
1523
|
+
return this.els.push(a), this;
|
|
1524
1524
|
}
|
|
1525
1525
|
/**
|
|
1526
1526
|
* Mint a {@link LayerToken} for a named layer — the only currency
|
|
@@ -1538,11 +1538,11 @@ class lt {
|
|
|
1538
1538
|
layer(t) {
|
|
1539
1539
|
const o = this.els.find((s) => s.name === t);
|
|
1540
1540
|
if (!o) {
|
|
1541
|
-
const s = this.layerNamesOfKind("text"),
|
|
1541
|
+
const s = this.layerNamesOfKind("text"), r = this.layerNamesOfKind("image");
|
|
1542
1542
|
throw new ot(
|
|
1543
1543
|
"E_LAYER_NOT_FOUND",
|
|
1544
|
-
`no layer "${t}" in this design. Text layers: ${JSON.stringify(s)}; image layers: ${JSON.stringify(
|
|
1545
|
-
{ layerName: t, validNames: [...s, ...
|
|
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
1546
|
);
|
|
1547
1547
|
}
|
|
1548
1548
|
const n = Vt(o);
|
|
@@ -1552,7 +1552,7 @@ class lt {
|
|
|
1552
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
1553
|
{ layerName: t, actualType: o.transformType, docSlug: "embed-mode" }
|
|
1554
1554
|
);
|
|
1555
|
-
return
|
|
1555
|
+
return uo(n, t);
|
|
1556
1556
|
}
|
|
1557
1557
|
/**
|
|
1558
1558
|
* Mint a {@link ColorToken} for a declared color role. Compile time: `name`
|
|
@@ -1575,7 +1575,7 @@ class lt {
|
|
|
1575
1575
|
`no color role "${t}" in this design. Declared roles: ${JSON.stringify([...this.colorRoles.keys()])}. Declare roles up front — design({ …, colors: { ${t}: '#FF2D8A' } }).`,
|
|
1576
1576
|
{ roleName: t, validNames: [...this.colorRoles.keys()], docSlug: "embed-mode" }
|
|
1577
1577
|
);
|
|
1578
|
-
return
|
|
1578
|
+
return ho(t, o);
|
|
1579
1579
|
}
|
|
1580
1580
|
/** Names of bindable layers of one kind, in stack order. @internal */
|
|
1581
1581
|
layerNamesOfKind(t) {
|
|
@@ -1583,25 +1583,25 @@ class lt {
|
|
|
1583
1583
|
}
|
|
1584
1584
|
/** An anchored vector shape. */
|
|
1585
1585
|
shape(t, o = {}) {
|
|
1586
|
-
const { width: n, height: s } = this.current,
|
|
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
1587
|
type: "shape",
|
|
1588
1588
|
shapeType: t,
|
|
1589
1589
|
width: c,
|
|
1590
|
-
height:
|
|
1590
|
+
height: i,
|
|
1591
1591
|
fillColor: xt(o.fill) ?? "#000000",
|
|
1592
1592
|
fillOpacity: o.opacity ?? 1,
|
|
1593
1593
|
...o.points !== void 0 ? { points: o.points } : {},
|
|
1594
1594
|
...o.sides !== void 0 ? { sides: o.sides } : {}
|
|
1595
|
-
},
|
|
1595
|
+
}, F = {
|
|
1596
1596
|
id: this.nextId("shape"),
|
|
1597
1597
|
transformType: "shape",
|
|
1598
|
-
x:
|
|
1599
|
-
y:
|
|
1598
|
+
x: a,
|
|
1599
|
+
y: d,
|
|
1600
1600
|
rotation: o.rotation ?? 0,
|
|
1601
1601
|
transformData: z,
|
|
1602
1602
|
...o.name ? { name: o.name } : {}
|
|
1603
1603
|
};
|
|
1604
|
-
return this.els.push(
|
|
1604
|
+
return this.els.push(F), this;
|
|
1605
1605
|
}
|
|
1606
1606
|
/** The composed elements, in render order (background first). Editor shape. */
|
|
1607
1607
|
get elements() {
|
|
@@ -1635,42 +1635,42 @@ class lt {
|
|
|
1635
1635
|
/** Server-render payload for `RenderSession.renderState(placement, …)`.
|
|
1636
1636
|
* Equivalent to `serializeStateForServer(design.toJSON())`. */
|
|
1637
1637
|
toServerRequest() {
|
|
1638
|
-
return
|
|
1638
|
+
return ao(this.toJSON());
|
|
1639
1639
|
}
|
|
1640
1640
|
}
|
|
1641
|
-
function
|
|
1641
|
+
function ko(e) {
|
|
1642
1642
|
return new lt(e);
|
|
1643
1643
|
}
|
|
1644
|
-
function
|
|
1644
|
+
function Uo(e) {
|
|
1645
1645
|
return Vt(e);
|
|
1646
1646
|
}
|
|
1647
1647
|
export {
|
|
1648
1648
|
Jt as B,
|
|
1649
|
-
|
|
1649
|
+
co as C,
|
|
1650
1650
|
lt as D,
|
|
1651
|
-
|
|
1651
|
+
Oo as E,
|
|
1652
1652
|
qt as P,
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
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
1675
|
};
|
|
1676
|
-
//# sourceMappingURL=design-builder-
|
|
1676
|
+
//# sourceMappingURL=design-builder-DUEwCUmA.js.map
|