@snowcone-app/canvas 0.23.0 → 0.27.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/ERROR_CONTRACT.md +638 -0
- package/README.md +2 -1
- package/STYLING_CONTRACT.md +59 -8
- package/dist/{CanvasRenderer-6_HhR4-q.js → CanvasRenderer-yszzrDfo.js} +4 -4
- package/dist/{CanvasRenderer-6_HhR4-q.js.map → CanvasRenderer-yszzrDfo.js.map} +1 -1
- package/dist/{CanvasStateV1-DmZ1Qvvn.js → CanvasStateV1-BTbCD_xC.js} +3 -3
- package/dist/{CanvasStateV1-DmZ1Qvvn.js.map → CanvasStateV1-BTbCD_xC.js.map} +1 -1
- package/dist/{ContextualToolbars-BDEt9ND0.js → ContextualToolbars-BHjYsril.js} +6 -6
- package/dist/{ContextualToolbars-BDEt9ND0.js.map → ContextualToolbars-BHjYsril.js.map} +1 -1
- package/dist/{EditorCanvasImpl-Ckg7WO2j.js → EditorCanvasImpl-Ui8Ceb-h.js} +8 -8
- package/dist/{EditorCanvasImpl-Ckg7WO2j.js.map → EditorCanvasImpl-Ui8Ceb-h.js.map} +1 -1
- package/dist/{ExportManager-DoU4VK6h.js → ExportManager-BTcyj4cf.js} +2 -2
- package/dist/{ExportManager-DoU4VK6h.js.map → ExportManager-BTcyj4cf.js.map} +1 -1
- package/dist/{FontAnalyzer-CwIpgTGd.js → FontAnalyzer-EF3gLPr8.js} +30 -20
- package/dist/{FontAnalyzer-CwIpgTGd.js.map → FontAnalyzer-EF3gLPr8.js.map} +1 -1
- package/dist/{ImagePanel-BwqFDKvW.js → ImagePanel-CIk6z41z.js} +6 -6
- package/dist/{ImagePanel-BwqFDKvW.js.map → ImagePanel-CIk6z41z.js.map} +1 -1
- package/dist/{SnowconeCanvas-D1sLcIja.js → SnowconeCanvas-DuWALOAt.js} +10 -10
- package/dist/{SnowconeCanvas-D1sLcIja.js.map → SnowconeCanvas-DuWALOAt.js.map} +1 -1
- package/dist/{UnifiedFontService-CC3CSmH5.js → UnifiedFontService-CHVYDBDW.js} +869 -836
- package/dist/{UnifiedFontService-CC3CSmH5.js.map → UnifiedFontService-CHVYDBDW.js.map} +1 -1
- package/dist/advanced.mjs +14 -14
- package/dist/api/embed.d.ts +6 -2
- package/dist/components/editor/EditorLoadingOverlay.d.ts +12 -0
- package/dist/components/editor/EditorPlacements.d.ts +14 -0
- package/dist/components/editor/EditorPreview.d.ts +32 -8
- package/dist/components/editor/EditorRoot.d.ts +12 -0
- package/dist/components/editor/PreviewPrismOverlay.d.ts +23 -0
- package/dist/components/editor/RootInternals.d.ts +31 -0
- package/dist/components/editor/editorAudit.d.ts +66 -0
- package/dist/components/editor/index.d.ts +14 -0
- package/dist/components/editor/usePlacements.d.ts +14 -0
- package/dist/components/embed-realtime/context.d.ts +11 -2
- package/dist/components/embed-realtime/validateEmbed.d.ts +20 -1
- package/dist/contexts/EditorContext.d.ts +34 -0
- package/dist/core/HybridHistoryManager.d.ts +7 -0
- package/dist/core/elementGuards.d.ts +19 -0
- package/dist/{custom-icons-BW6hqmkL.js → custom-icons-CcLMyybv.js} +7 -7
- package/dist/{custom-icons-BW6hqmkL.js.map → custom-icons-CcLMyybv.js.map} +1 -1
- package/dist/design/design-builder.d.ts +41 -3
- package/dist/design/product-config.d.ts +10 -0
- package/dist/{design-builder-2VUjfmdt.js → design-builder-cZY958Rw.js} +109 -61
- package/dist/design-builder-cZY958Rw.js.map +1 -0
- package/dist/editorErrors-BhrZ_nwj.js +1219 -0
- package/dist/editorErrors-BhrZ_nwj.js.map +1 -0
- package/dist/embed-CJswRZte.js +1586 -0
- package/dist/embed-CJswRZte.js.map +1 -0
- package/dist/embed.mjs +42 -34
- package/dist/errors/editorError.d.ts +29 -1
- package/dist/{guards-8rkFAMBs.js → guards-DIX8aXWM.js} +2 -2
- package/dist/{guards-8rkFAMBs.js.map → guards-DIX8aXWM.js.map} +1 -1
- package/dist/hooks/elementPatch.d.ts +96 -0
- package/dist/hooks/useCommands.d.ts +20 -0
- package/dist/index.mjs +8 -8
- package/dist/internals.mjs +9 -9
- package/dist/style.css +1 -1
- package/dist/template-fields-BXl29sgh.js +716 -0
- package/dist/template-fields-BXl29sgh.js.map +1 -0
- package/dist/testing.mjs +4 -4
- package/dist/{usePieceGuideBundle-CbJJg66S.js → usePieceGuideBundle-DE21DQGZ.js} +2 -2
- package/dist/{usePieceGuideBundle-CbJJg66S.js.map → usePieceGuideBundle-DE21DQGZ.js.map} +1 -1
- package/dist/{validation-C9Fe9ahK.js → validation-DGXAQmUC.js} +11 -11
- package/dist/{validation-C9Fe9ahK.js.map → validation-DGXAQmUC.js.map} +1 -1
- package/example/package.json +1 -1
- package/llms.txt +3 -0
- package/package.json +7 -4
- package/dist/design-builder-2VUjfmdt.js.map +0 -1
- package/dist/editorErrors-B2mb1sVN.js +0 -1208
- package/dist/editorErrors-B2mb1sVN.js.map +0 -1
- package/dist/embed-DxsaqZJF.js +0 -1226
- package/dist/embed-DxsaqZJF.js.map +0 -1
- package/dist/template-fields-CQ6n2P4V.js +0 -548
- package/dist/template-fields-CQ6n2P4V.js.map +0 -1
|
@@ -1,1208 +0,0 @@
|
|
|
1
|
-
import { jsx as H } from "react/jsx-runtime";
|
|
2
|
-
import { useContext as X, useSyncExternalStore as rt, useCallback as a, createContext as Q, useRef as me, useState as E, useEffect as ve, useMemo as q } from "react";
|
|
3
|
-
import { y as Ve, N as it, ab as st, ac as ct, G as ke, ad as dt, ae as at, af as lt, ag as ut, ah as mt, c as $e, z as ft, ai as At, aj as pt, ak as ht, E as xt, L as Ne, I as yt, g as Et, S as St, al as bt, am as De } from "./FontAnalyzer-CwIpgTGd.js";
|
|
4
|
-
const We = Q(null), It = () => () => {
|
|
5
|
-
}, Le = () => 0;
|
|
6
|
-
function Jt() {
|
|
7
|
-
const t = X(We), e = rt(
|
|
8
|
-
t ? t.subscribe : It,
|
|
9
|
-
t ? t.getVersion : Le,
|
|
10
|
-
t ? t.getVersion : Le
|
|
11
|
-
);
|
|
12
|
-
return a(
|
|
13
|
-
(o) => !!(t && o && t.getBoundLayer(o)),
|
|
14
|
-
// `version` is the reactivity key: a registry change must mint a new
|
|
15
|
-
// callback so memoized consumers re-evaluate.
|
|
16
|
-
[t, e]
|
|
17
|
-
);
|
|
18
|
-
}
|
|
19
|
-
class wt extends Error {
|
|
20
|
-
constructor(e, o, n = {}) {
|
|
21
|
-
super(`[Editor] ${e}: ${o}`), this.name = "EditorError", this.code = e, this.data = { code: e, ...n };
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
function gt(t) {
|
|
25
|
-
return t instanceof Error && t.name === "EditorError" && "code" in t;
|
|
26
|
-
}
|
|
27
|
-
function Tt() {
|
|
28
|
-
var t;
|
|
29
|
-
return typeof Ve < "u" && ((t = Ve.env) == null ? void 0 : t.NODE_ENV) !== "production";
|
|
30
|
-
}
|
|
31
|
-
const Ae = $e("useCommandHistory");
|
|
32
|
-
function Pt(t, e, o, n) {
|
|
33
|
-
const d = me(new it(o)), l = X(We), i = a(
|
|
34
|
-
(s, A) => {
|
|
35
|
-
const y = s == null ? void 0 : s.name;
|
|
36
|
-
if (!l || !y) return;
|
|
37
|
-
const x = l.getBoundLayer(y);
|
|
38
|
-
if (x)
|
|
39
|
-
throw new wt(
|
|
40
|
-
"E_BOUND_LAYER_MUTATION",
|
|
41
|
-
`cannot ${A} layer "${y}" — a mounted <${x.part} layer={design.layer("${y}")}> is bound to it. Unmount that field first, or keep the layer and set its text through the field / its binding instead.`,
|
|
42
|
-
{ layer: y, part: x.part, operation: A, docSlug: "embed-mode" }
|
|
43
|
-
);
|
|
44
|
-
},
|
|
45
|
-
[l]
|
|
46
|
-
), [r, u] = E({
|
|
47
|
-
canUndo: !1,
|
|
48
|
-
canRedo: !1,
|
|
49
|
-
// Per-artboard state for the active artboard
|
|
50
|
-
canUndoActiveArtboard: !1,
|
|
51
|
-
canRedoActiveArtboard: !1
|
|
52
|
-
}), c = a(() => {
|
|
53
|
-
const s = d.current, A = o.getActiveArtboardId();
|
|
54
|
-
u({
|
|
55
|
-
canUndo: s.canUndo(),
|
|
56
|
-
canRedo: s.canRedo(),
|
|
57
|
-
// Per-artboard state - only check active artboard's history
|
|
58
|
-
canUndoActiveArtboard: A ? s.canUndoArtboard(A) : !1,
|
|
59
|
-
canRedoActiveArtboard: A ? s.canRedoArtboard(A) : !1
|
|
60
|
-
});
|
|
61
|
-
}, [o]), V = a(
|
|
62
|
-
(s, A) => {
|
|
63
|
-
s && s.name !== A.name && i(s, "rename");
|
|
64
|
-
const y = new st(
|
|
65
|
-
A.id,
|
|
66
|
-
s || null,
|
|
67
|
-
A,
|
|
68
|
-
(P) => {
|
|
69
|
-
e((k) => k.map((R) => R.id === P.id ? P : R));
|
|
70
|
-
}
|
|
71
|
-
), x = o.getArtboardIdForElement(A.id);
|
|
72
|
-
if (x)
|
|
73
|
-
d.current.executeOnArtboard(x, y);
|
|
74
|
-
else {
|
|
75
|
-
const P = o.getActiveArtboardId();
|
|
76
|
-
P && d.current.executeOnArtboard(P, y);
|
|
77
|
-
}
|
|
78
|
-
c();
|
|
79
|
-
},
|
|
80
|
-
[e, o, c, i]
|
|
81
|
-
), O = a(
|
|
82
|
-
(s, A, y, x) => {
|
|
83
|
-
const P = A || o.getActiveArtboardId();
|
|
84
|
-
if (!P) {
|
|
85
|
-
Ae.warn("No active artboard to add element to");
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
const k = new ct(
|
|
89
|
-
s,
|
|
90
|
-
(R) => {
|
|
91
|
-
const N = R;
|
|
92
|
-
e((v) => {
|
|
93
|
-
if (x) {
|
|
94
|
-
const U = v.findIndex((F) => F.id === x);
|
|
95
|
-
if (U !== -1) {
|
|
96
|
-
const F = [...v];
|
|
97
|
-
return F.splice(U, 0, N), F;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
if (y) {
|
|
101
|
-
const U = v.findIndex((F) => F.id === y);
|
|
102
|
-
if (U !== -1) {
|
|
103
|
-
const F = [...v];
|
|
104
|
-
return F.splice(U + 1, 0, N), F;
|
|
105
|
-
}
|
|
106
|
-
for (let F = 0; F < v.length; F++) {
|
|
107
|
-
const j = v[F];
|
|
108
|
-
if (j instanceof ke && j.children) {
|
|
109
|
-
const ne = j.children.findIndex((Y) => Y.id === y);
|
|
110
|
-
if (ne !== -1) {
|
|
111
|
-
const Y = j.clone();
|
|
112
|
-
Y.children.splice(ne + 1, 0, N);
|
|
113
|
-
const J = [...v];
|
|
114
|
-
return J[F] = Y, J;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
return [...v, N];
|
|
120
|
-
}), o.addElementToArtboard(R.id, P);
|
|
121
|
-
},
|
|
122
|
-
(R) => {
|
|
123
|
-
e((N) => N.filter((v) => v.id !== R)), o.removeElementFromArtboard(R);
|
|
124
|
-
}
|
|
125
|
-
);
|
|
126
|
-
d.current.executeOnArtboard(P, k), c();
|
|
127
|
-
},
|
|
128
|
-
[e, o, c]
|
|
129
|
-
), D = a(
|
|
130
|
-
(s) => {
|
|
131
|
-
i(s, "delete");
|
|
132
|
-
const A = o.getArtboardIdForElement(s.id);
|
|
133
|
-
if (!A) {
|
|
134
|
-
Ae.warn("Element not found in any artboard");
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
const y = new dt(
|
|
138
|
-
s,
|
|
139
|
-
(x) => {
|
|
140
|
-
e((P) => [...P, x]), o.addElementToArtboard(x.id, A);
|
|
141
|
-
},
|
|
142
|
-
(x) => {
|
|
143
|
-
e((P) => P.filter((k) => k.id !== x)), o.removeElementFromArtboard(x);
|
|
144
|
-
}
|
|
145
|
-
);
|
|
146
|
-
d.current.executeOnArtboard(A, y), c();
|
|
147
|
-
},
|
|
148
|
-
[e, o, c, i]
|
|
149
|
-
), w = a(
|
|
150
|
-
(s) => {
|
|
151
|
-
const A = new at(s, o);
|
|
152
|
-
d.current.executeGlobal(A), c(), n == null || n();
|
|
153
|
-
},
|
|
154
|
-
[o, c, n]
|
|
155
|
-
), L = a(
|
|
156
|
-
(s) => {
|
|
157
|
-
const A = new lt(s, o);
|
|
158
|
-
d.current.executeGlobal(A), c(), n == null || n();
|
|
159
|
-
},
|
|
160
|
-
[o, c, n]
|
|
161
|
-
), p = a(
|
|
162
|
-
(s, A, y) => {
|
|
163
|
-
const x = new ut(s, A, y, o);
|
|
164
|
-
d.current.executeGlobal(x), c(), n == null || n();
|
|
165
|
-
},
|
|
166
|
-
[o, c, n]
|
|
167
|
-
), f = a(
|
|
168
|
-
(s) => {
|
|
169
|
-
if (s.length === 0)
|
|
170
|
-
return;
|
|
171
|
-
const A = o.getActiveArtboardId();
|
|
172
|
-
if (!A) {
|
|
173
|
-
Ae.warn("No active artboard for batch execution");
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
176
|
-
const y = s.map((x) => new class extends Object {
|
|
177
|
-
execute() {
|
|
178
|
-
x.execute();
|
|
179
|
-
}
|
|
180
|
-
undo() {
|
|
181
|
-
x.undo();
|
|
182
|
-
}
|
|
183
|
-
}());
|
|
184
|
-
d.current.executeBatchOnArtboard(A, y), c();
|
|
185
|
-
},
|
|
186
|
-
[o, c]
|
|
187
|
-
), g = a(() => {
|
|
188
|
-
d.current.undo() && (c(), n == null || n());
|
|
189
|
-
}, [c, n]), z = a(() => {
|
|
190
|
-
d.current.redo() && (c(), n == null || n());
|
|
191
|
-
}, [c, n]), T = a(() => {
|
|
192
|
-
const s = o.getActiveArtboardId();
|
|
193
|
-
s && d.current.undoArtboard(s) && (c(), n == null || n());
|
|
194
|
-
}, [o, c, n]), b = a(() => {
|
|
195
|
-
const s = o.getActiveArtboardId();
|
|
196
|
-
s && d.current.redoArtboard(s) && (c(), n == null || n());
|
|
197
|
-
}, [o, c, n]), _ = a(() => {
|
|
198
|
-
d.current.clear(), c();
|
|
199
|
-
}, [c]), te = a(
|
|
200
|
-
(s) => {
|
|
201
|
-
d.current.clearArtboardHistory(s), c();
|
|
202
|
-
},
|
|
203
|
-
[c]
|
|
204
|
-
), B = me(null);
|
|
205
|
-
ve(() => {
|
|
206
|
-
const s = o.getActiveArtboardId();
|
|
207
|
-
s !== B.current && (B.current = s, c());
|
|
208
|
-
});
|
|
209
|
-
const $ = a(
|
|
210
|
-
(s, A, y) => {
|
|
211
|
-
const x = t.map((R) => R.id), P = o.getArtboardIdForElement(s);
|
|
212
|
-
if (!P) {
|
|
213
|
-
Ae.warn("Element not found in any artboard");
|
|
214
|
-
return;
|
|
215
|
-
}
|
|
216
|
-
const k = new mt(s, A, y, x, (R) => {
|
|
217
|
-
e((N) => {
|
|
218
|
-
const v = new Map(N.map((U) => [U.id, U]));
|
|
219
|
-
return R.map((U) => v.get(U)).filter(Boolean);
|
|
220
|
-
});
|
|
221
|
-
});
|
|
222
|
-
d.current.executeOnArtboard(P, k), c();
|
|
223
|
-
},
|
|
224
|
-
[t, e, o, c]
|
|
225
|
-
);
|
|
226
|
-
return {
|
|
227
|
-
// Element operations
|
|
228
|
-
executeElementUpdate: V,
|
|
229
|
-
executeAddElement: O,
|
|
230
|
-
executeRemoveElement: D,
|
|
231
|
-
executeReorderElement: $,
|
|
232
|
-
// Batch operations
|
|
233
|
-
executeCommandBatch: f,
|
|
234
|
-
// Artboard operations
|
|
235
|
-
executeCreateArtboard: w,
|
|
236
|
-
executeDeleteArtboard: L,
|
|
237
|
-
executeUpdateArtboard: p,
|
|
238
|
-
// Undo/redo (smart - considers last operation and active artboard)
|
|
239
|
-
undo: g,
|
|
240
|
-
redo: z,
|
|
241
|
-
// Undo/redo for active artboard only (element operations)
|
|
242
|
-
undoActiveArtboard: T,
|
|
243
|
-
redoActiveArtboard: b,
|
|
244
|
-
clearHistory: _,
|
|
245
|
-
clearArtboardHistory: te,
|
|
246
|
-
// State (smart - considers last operation)
|
|
247
|
-
canUndo: r.canUndo,
|
|
248
|
-
canRedo: r.canRedo,
|
|
249
|
-
// State for active artboard only
|
|
250
|
-
canUndoActiveArtboard: r.canUndoActiveArtboard,
|
|
251
|
-
canRedoActiveArtboard: r.canRedoActiveArtboard,
|
|
252
|
-
historyManager: d.current
|
|
253
|
-
};
|
|
254
|
-
}
|
|
255
|
-
function oe(t) {
|
|
256
|
-
return t && "fontSize" in t && "color" in t && "fontFamily" in t;
|
|
257
|
-
}
|
|
258
|
-
function Ct(t, e) {
|
|
259
|
-
const [o, n] = E(32), [d, l] = E("#333333"), [i, r] = E("Arial"), [u, c] = E("center");
|
|
260
|
-
ve(() => {
|
|
261
|
-
if (t && oe(t)) {
|
|
262
|
-
const p = t.transformType === "circle" && "getEffectiveFontSize" in t ? Math.round(t.getEffectiveFontSize()) : Math.round(t.fontSize), f = t.color, g = t.fontFamily, z = t.textAlign;
|
|
263
|
-
n((T) => T !== p ? p : T), l((T) => T !== f ? f : T), r((T) => T !== g ? g : T), c((T) => T !== z ? z : T);
|
|
264
|
-
}
|
|
265
|
-
}, [t]);
|
|
266
|
-
const V = a(
|
|
267
|
-
(p) => {
|
|
268
|
-
if (!t || !oe(t)) return;
|
|
269
|
-
const f = Math.max(At, Math.min(pt, o + p));
|
|
270
|
-
n(f);
|
|
271
|
-
const g = t.clone();
|
|
272
|
-
g.transformType === "circle" && "setEffectiveFontSize" in g ? g.setEffectiveFontSize(f) : g.setFontSize(f), e(g);
|
|
273
|
-
},
|
|
274
|
-
[t, o, e]
|
|
275
|
-
), O = a(
|
|
276
|
-
(p) => {
|
|
277
|
-
if (!t || !oe(t)) return;
|
|
278
|
-
n(p);
|
|
279
|
-
const f = t.clone();
|
|
280
|
-
f.transformType === "circle" && "setEffectiveFontSize" in f ? f.setEffectiveFontSize(p) : f.setFontSize(p), e(f);
|
|
281
|
-
},
|
|
282
|
-
[t, e]
|
|
283
|
-
), D = a(
|
|
284
|
-
(p) => {
|
|
285
|
-
if (!t || !oe(t)) return;
|
|
286
|
-
l(p);
|
|
287
|
-
const f = t.clone();
|
|
288
|
-
if (f.color = p, f.richText)
|
|
289
|
-
for (const g of f.richText.spans)
|
|
290
|
-
g.style.color = void 0;
|
|
291
|
-
e(f);
|
|
292
|
-
},
|
|
293
|
-
[t, e]
|
|
294
|
-
), w = a(
|
|
295
|
-
(p) => {
|
|
296
|
-
if (!t || !oe(t)) return;
|
|
297
|
-
const f = t.fontFamily;
|
|
298
|
-
f !== p && ft.clearCache(f), r(p);
|
|
299
|
-
const g = t.clone();
|
|
300
|
-
g.fontFamily = p, e(g);
|
|
301
|
-
},
|
|
302
|
-
[t, e]
|
|
303
|
-
), L = a(
|
|
304
|
-
(p) => {
|
|
305
|
-
if (!t || !oe(t)) return;
|
|
306
|
-
c(p);
|
|
307
|
-
const f = t.clone();
|
|
308
|
-
f.textAlign = p, e(f);
|
|
309
|
-
},
|
|
310
|
-
[t, e]
|
|
311
|
-
);
|
|
312
|
-
return {
|
|
313
|
-
// State
|
|
314
|
-
fontSize: o,
|
|
315
|
-
fontColor: d,
|
|
316
|
-
fontFamily: i,
|
|
317
|
-
textAlign: u,
|
|
318
|
-
// State setters (for UI only)
|
|
319
|
-
setFontSize: n,
|
|
320
|
-
setFontColor: l,
|
|
321
|
-
setFontFamily: r,
|
|
322
|
-
setTextAlign: c,
|
|
323
|
-
// Update functions (update element + UI)
|
|
324
|
-
updateFontSize: V,
|
|
325
|
-
setFontSizeValue: O,
|
|
326
|
-
updateFontColor: D,
|
|
327
|
-
updateFontFamily: w,
|
|
328
|
-
updateTextAlign: L
|
|
329
|
-
};
|
|
330
|
-
}
|
|
331
|
-
const Ze = "data-preserve-selection";
|
|
332
|
-
function Ft(t) {
|
|
333
|
-
if (!(t instanceof Element))
|
|
334
|
-
return !1;
|
|
335
|
-
let e = t;
|
|
336
|
-
const o = [];
|
|
337
|
-
for (; e; ) {
|
|
338
|
-
const n = e.id ? `#${e.id}` : "", d = e.className ? `.${String(e.className).split(" ").slice(0, 2).join(".")}` : "";
|
|
339
|
-
if (o.push(`${e.tagName.toLowerCase()}${n}${d}`), e.hasAttribute(Ze))
|
|
340
|
-
return !0;
|
|
341
|
-
const l = e.getAttribute("role");
|
|
342
|
-
if (l === "dialog" || l === "alertdialog" || l === "menu" || l === "listbox")
|
|
343
|
-
return !0;
|
|
344
|
-
const i = e.getAttribute("data-slot");
|
|
345
|
-
if (i && (i.includes("popover") || i.includes("dialog")) || e.hasAttribute("data-radix-popper-content-wrapper"))
|
|
346
|
-
return !0;
|
|
347
|
-
e = e.parentElement;
|
|
348
|
-
}
|
|
349
|
-
return !1;
|
|
350
|
-
}
|
|
351
|
-
const Kt = {
|
|
352
|
-
[Ze]: ""
|
|
353
|
-
};
|
|
354
|
-
function Rt(t) {
|
|
355
|
-
const e = Ge(t);
|
|
356
|
-
return e !== null && e < 0.5;
|
|
357
|
-
}
|
|
358
|
-
function Mt(t) {
|
|
359
|
-
const e = Ge(t);
|
|
360
|
-
return e !== null && e >= 0.5;
|
|
361
|
-
}
|
|
362
|
-
function Ge(t) {
|
|
363
|
-
const e = t.trim();
|
|
364
|
-
if (e.startsWith("#")) {
|
|
365
|
-
const n = e.slice(1);
|
|
366
|
-
let d, l, i;
|
|
367
|
-
if (n.length === 3)
|
|
368
|
-
d = parseInt(n[0] + n[0], 16), l = parseInt(n[1] + n[1], 16), i = parseInt(n[2] + n[2], 16);
|
|
369
|
-
else if (n.length === 6)
|
|
370
|
-
d = parseInt(n.slice(0, 2), 16), l = parseInt(n.slice(2, 4), 16), i = parseInt(n.slice(4, 6), 16);
|
|
371
|
-
else return null;
|
|
372
|
-
return Number.isNaN(d) || Number.isNaN(l) || Number.isNaN(i) ? null : Be(d, l, i);
|
|
373
|
-
}
|
|
374
|
-
const o = e.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);
|
|
375
|
-
return o ? Be(Number(o[1]), Number(o[2]), Number(o[3])) : null;
|
|
376
|
-
}
|
|
377
|
-
function Be(t, e, o) {
|
|
378
|
-
const n = (d) => {
|
|
379
|
-
const l = d / 255;
|
|
380
|
-
return l <= 0.03928 ? l / 12.92 : Math.pow((l + 0.055) / 1.055, 2.4);
|
|
381
|
-
};
|
|
382
|
-
return 0.2126 * n(t) + 0.7152 * n(e) + 0.0722 * n(o);
|
|
383
|
-
}
|
|
384
|
-
const vt = "#333333", zt = "#f4f4f5";
|
|
385
|
-
function Ot(t) {
|
|
386
|
-
return t && Rt(t) ? zt : vt;
|
|
387
|
-
}
|
|
388
|
-
const Xe = Q(null), Ut = 0.1, Ht = 4, _e = 0.25, Vt = ({
|
|
389
|
-
children: t,
|
|
390
|
-
artboardManager: e,
|
|
391
|
-
canvasRef: o,
|
|
392
|
-
viewPadding: n = 0.9
|
|
393
|
-
}) => {
|
|
394
|
-
const [d, l] = E(1), [i, r] = E({ x: 0, y: 0 }), [u, c] = E(!1), [V, O] = E(1), D = a(() => {
|
|
395
|
-
O(1), r({ x: 0, y: 0 });
|
|
396
|
-
}, []), w = a(() => {
|
|
397
|
-
l((z) => Math.min(z + _e, Ht));
|
|
398
|
-
}, []), L = a(() => {
|
|
399
|
-
l((z) => Math.max(z - _e, Ut));
|
|
400
|
-
}, []), p = a(() => {
|
|
401
|
-
const z = e.getActiveArtboard();
|
|
402
|
-
if (!z || !o.current) return;
|
|
403
|
-
let T = o.current.parentElement, b = 0, _ = 0;
|
|
404
|
-
for (; T && (b = T.clientWidth, _ = T.clientHeight, !(b > 0 && _ > 0)); )
|
|
405
|
-
T = T.parentElement;
|
|
406
|
-
if (!b || !_) return;
|
|
407
|
-
const te = Math.min(
|
|
408
|
-
b * n / z.width,
|
|
409
|
-
_ * n / z.height,
|
|
410
|
-
1
|
|
411
|
-
// Never zoom in beyond 100%
|
|
412
|
-
);
|
|
413
|
-
l(te), r({ x: 0, y: 0 });
|
|
414
|
-
}, [e, o, n]), f = a(() => {
|
|
415
|
-
l(1), r({ x: 0, y: 0 });
|
|
416
|
-
}, []), g = q(
|
|
417
|
-
() => ({
|
|
418
|
-
zoom: d,
|
|
419
|
-
panOffset: i,
|
|
420
|
-
isPanning: u,
|
|
421
|
-
zoomIn: w,
|
|
422
|
-
zoomOut: L,
|
|
423
|
-
zoomToFit: p,
|
|
424
|
-
resetView: f,
|
|
425
|
-
setZoom: l,
|
|
426
|
-
setPanOffset: r,
|
|
427
|
-
setIsPanning: c,
|
|
428
|
-
userZoom: V,
|
|
429
|
-
setUserZoom: O,
|
|
430
|
-
resetUserView: D
|
|
431
|
-
}),
|
|
432
|
-
[d, i, u, w, L, p, f, V, D]
|
|
433
|
-
);
|
|
434
|
-
return /* @__PURE__ */ H(Xe.Provider, { value: g, children: t });
|
|
435
|
-
};
|
|
436
|
-
function Nt() {
|
|
437
|
-
const t = X(Xe);
|
|
438
|
-
if (!t)
|
|
439
|
-
throw new Error("useViewportContext must be used within a ViewportProvider (or EditorProvider)");
|
|
440
|
-
return t;
|
|
441
|
-
}
|
|
442
|
-
const je = Q(null), Dt = ({ children: t }) => {
|
|
443
|
-
const [e, o] = E(null), [n, d] = E([]), [l, i] = E(null), [r, u] = E(null), [c, V] = E(!1), O = a((L) => {
|
|
444
|
-
o(L);
|
|
445
|
-
}, []), D = a((L) => {
|
|
446
|
-
i(L);
|
|
447
|
-
}, []), w = q(
|
|
448
|
-
() => ({
|
|
449
|
-
selectedId: e,
|
|
450
|
-
multiSelection: n,
|
|
451
|
-
activeChildElement: l,
|
|
452
|
-
hoveredElementId: r,
|
|
453
|
-
hideHandles: c,
|
|
454
|
-
setSelectedId: o,
|
|
455
|
-
setMultiSelection: d,
|
|
456
|
-
setHoveredElementId: u,
|
|
457
|
-
setHideHandles: V,
|
|
458
|
-
handleSelectionChange: O,
|
|
459
|
-
handleActiveChildChange: D
|
|
460
|
-
}),
|
|
461
|
-
[
|
|
462
|
-
e,
|
|
463
|
-
n,
|
|
464
|
-
l,
|
|
465
|
-
r,
|
|
466
|
-
c,
|
|
467
|
-
O,
|
|
468
|
-
D
|
|
469
|
-
]
|
|
470
|
-
);
|
|
471
|
-
return /* @__PURE__ */ H(je.Provider, { value: w, children: t });
|
|
472
|
-
};
|
|
473
|
-
function Lt() {
|
|
474
|
-
const t = X(je);
|
|
475
|
-
if (!t)
|
|
476
|
-
throw new Error("useSelectionContext must be used within a SelectionProvider (or EditorProvider)");
|
|
477
|
-
return t;
|
|
478
|
-
}
|
|
479
|
-
const Ye = Q(null), Bt = ({ children: t, value: e }) => {
|
|
480
|
-
const o = q(
|
|
481
|
-
() => ({
|
|
482
|
-
undo: e.undo,
|
|
483
|
-
redo: e.redo,
|
|
484
|
-
canUndo: e.canUndo,
|
|
485
|
-
canRedo: e.canRedo,
|
|
486
|
-
undoActiveArtboard: e.undoActiveArtboard,
|
|
487
|
-
redoActiveArtboard: e.redoActiveArtboard,
|
|
488
|
-
canUndoActiveArtboard: e.canUndoActiveArtboard,
|
|
489
|
-
canRedoActiveArtboard: e.canRedoActiveArtboard
|
|
490
|
-
}),
|
|
491
|
-
[
|
|
492
|
-
e.undo,
|
|
493
|
-
e.redo,
|
|
494
|
-
e.canUndo,
|
|
495
|
-
e.canRedo,
|
|
496
|
-
e.undoActiveArtboard,
|
|
497
|
-
e.redoActiveArtboard,
|
|
498
|
-
e.canUndoActiveArtboard,
|
|
499
|
-
e.canRedoActiveArtboard
|
|
500
|
-
]
|
|
501
|
-
);
|
|
502
|
-
return /* @__PURE__ */ H(Ye.Provider, { value: o, children: t });
|
|
503
|
-
};
|
|
504
|
-
function qt() {
|
|
505
|
-
const t = X(Ye);
|
|
506
|
-
if (!t)
|
|
507
|
-
throw new Error("useHistoryContext must be used within a HistoryProvider (or EditorProvider)");
|
|
508
|
-
return t;
|
|
509
|
-
}
|
|
510
|
-
const Je = Q(null), _t = ({ children: t }) => {
|
|
511
|
-
const [e, o] = E(null), [n, d] = E(!1), [l, i] = E(0), [r, u] = E(!1), [c, V] = E(!1), O = q(
|
|
512
|
-
() => ({
|
|
513
|
-
expandedPanelType: e,
|
|
514
|
-
setExpandedPanelType: o,
|
|
515
|
-
isToolbarMenuOpen: n,
|
|
516
|
-
setIsToolbarMenuOpen: d,
|
|
517
|
-
textSelectionVersion: l,
|
|
518
|
-
setTextSelectionVersion: i,
|
|
519
|
-
isCanvasReady: r,
|
|
520
|
-
setCanvasReady: u,
|
|
521
|
-
isRotating: c,
|
|
522
|
-
setIsRotating: V
|
|
523
|
-
}),
|
|
524
|
-
[e, n, l, r, c]
|
|
525
|
-
);
|
|
526
|
-
return /* @__PURE__ */ H(Je.Provider, { value: O, children: t });
|
|
527
|
-
};
|
|
528
|
-
function kt() {
|
|
529
|
-
const t = X(Je);
|
|
530
|
-
if (!t)
|
|
531
|
-
throw new Error("useToolStateContext must be used within a ToolStateProvider (or EditorProvider)");
|
|
532
|
-
return t;
|
|
533
|
-
}
|
|
534
|
-
const Ke = Q(null), $t = ({ children: t, value: e }) => {
|
|
535
|
-
const o = q(
|
|
536
|
-
() => ({
|
|
537
|
-
elements: e.elements,
|
|
538
|
-
elementStore: e.elementStore,
|
|
539
|
-
artboards: e.artboards,
|
|
540
|
-
artboardManager: e.artboardManager,
|
|
541
|
-
artboardVersion: e.artboardVersion,
|
|
542
|
-
setElements: e.setElements,
|
|
543
|
-
refreshArtboards: e.refreshArtboards,
|
|
544
|
-
getElementById: e.getElementById,
|
|
545
|
-
handleAddElement: e.handleAddElement,
|
|
546
|
-
handleElementUpdate: e.handleElementUpdate,
|
|
547
|
-
handleLoadWorkspace: e.handleLoadWorkspace,
|
|
548
|
-
handleCopyElements: e.handleCopyElements,
|
|
549
|
-
handlePasteElements: e.handlePasteElements,
|
|
550
|
-
fontSize: e.fontSize,
|
|
551
|
-
fontColor: e.fontColor,
|
|
552
|
-
fontFamily: e.fontFamily,
|
|
553
|
-
textAlign: e.textAlign,
|
|
554
|
-
updateFontSize: e.updateFontSize,
|
|
555
|
-
setFontSizeValue: e.setFontSizeValue,
|
|
556
|
-
updateFontColor: e.updateFontColor,
|
|
557
|
-
updateFontFamily: e.updateFontFamily,
|
|
558
|
-
updateTextAlign: e.updateTextAlign,
|
|
559
|
-
canvasRef: e.canvasRef,
|
|
560
|
-
canvasEditorRef: e.canvasEditorRef
|
|
561
|
-
}),
|
|
562
|
-
[
|
|
563
|
-
e.elements,
|
|
564
|
-
e.elementStore,
|
|
565
|
-
e.artboards,
|
|
566
|
-
e.artboardManager,
|
|
567
|
-
e.artboardVersion,
|
|
568
|
-
e.setElements,
|
|
569
|
-
e.refreshArtboards,
|
|
570
|
-
e.getElementById,
|
|
571
|
-
e.handleAddElement,
|
|
572
|
-
e.handleElementUpdate,
|
|
573
|
-
e.handleLoadWorkspace,
|
|
574
|
-
e.handleCopyElements,
|
|
575
|
-
e.handlePasteElements,
|
|
576
|
-
e.fontSize,
|
|
577
|
-
e.fontColor,
|
|
578
|
-
e.fontFamily,
|
|
579
|
-
e.textAlign,
|
|
580
|
-
e.updateFontSize,
|
|
581
|
-
e.setFontSizeValue,
|
|
582
|
-
e.updateFontColor,
|
|
583
|
-
e.updateFontFamily,
|
|
584
|
-
e.updateTextAlign,
|
|
585
|
-
e.canvasRef,
|
|
586
|
-
e.canvasEditorRef
|
|
587
|
-
]
|
|
588
|
-
);
|
|
589
|
-
return /* @__PURE__ */ H(Ke.Provider, { value: o, children: t });
|
|
590
|
-
};
|
|
591
|
-
function Qt() {
|
|
592
|
-
const t = X(Ke);
|
|
593
|
-
if (!t)
|
|
594
|
-
throw new Error("useElementsContext must be used within an ElementsProvider (or EditorProvider)");
|
|
595
|
-
return t;
|
|
596
|
-
}
|
|
597
|
-
const Me = Q(null), Wt = ({ children: t, value: e }) => {
|
|
598
|
-
const o = q(
|
|
599
|
-
() => ({
|
|
600
|
-
executeElementUpdate: e.executeElementUpdate,
|
|
601
|
-
executeAddElement: e.executeAddElement,
|
|
602
|
-
executeRemoveElement: e.executeRemoveElement,
|
|
603
|
-
executeReorderElement: e.executeReorderElement,
|
|
604
|
-
executeCreateArtboard: e.executeCreateArtboard,
|
|
605
|
-
executeDeleteArtboard: e.executeDeleteArtboard,
|
|
606
|
-
executeUpdateArtboard: e.executeUpdateArtboard,
|
|
607
|
-
executeCommandBatch: e.executeCommandBatch,
|
|
608
|
-
undo: e.undo,
|
|
609
|
-
redo: e.redo,
|
|
610
|
-
canUndo: e.canUndo,
|
|
611
|
-
canRedo: e.canRedo,
|
|
612
|
-
undoActiveArtboard: e.undoActiveArtboard,
|
|
613
|
-
redoActiveArtboard: e.redoActiveArtboard,
|
|
614
|
-
canUndoActiveArtboard: e.canUndoActiveArtboard,
|
|
615
|
-
canRedoActiveArtboard: e.canRedoActiveArtboard,
|
|
616
|
-
historyManager: e.historyManager
|
|
617
|
-
}),
|
|
618
|
-
[
|
|
619
|
-
e.executeElementUpdate,
|
|
620
|
-
e.executeAddElement,
|
|
621
|
-
e.executeRemoveElement,
|
|
622
|
-
e.executeReorderElement,
|
|
623
|
-
e.executeCreateArtboard,
|
|
624
|
-
e.executeDeleteArtboard,
|
|
625
|
-
e.executeUpdateArtboard,
|
|
626
|
-
e.executeCommandBatch,
|
|
627
|
-
e.undo,
|
|
628
|
-
e.redo,
|
|
629
|
-
e.canUndo,
|
|
630
|
-
e.canRedo,
|
|
631
|
-
e.undoActiveArtboard,
|
|
632
|
-
e.redoActiveArtboard,
|
|
633
|
-
e.canUndoActiveArtboard,
|
|
634
|
-
e.canRedoActiveArtboard,
|
|
635
|
-
e.historyManager
|
|
636
|
-
]
|
|
637
|
-
);
|
|
638
|
-
return /* @__PURE__ */ H(Me.Provider, { value: o, children: t });
|
|
639
|
-
};
|
|
640
|
-
function en() {
|
|
641
|
-
const t = X(Me);
|
|
642
|
-
if (!t)
|
|
643
|
-
throw new Error("useCommandContext must be used within a CommandProvider (or EditorProvider)");
|
|
644
|
-
return t;
|
|
645
|
-
}
|
|
646
|
-
const Zt = $e("EditorContext"), qe = Q(null), Qe = Q(null), tn = () => {
|
|
647
|
-
const t = X(Qe);
|
|
648
|
-
if (!t)
|
|
649
|
-
throw new Error("useEditorHandles must be used within EditorProvider");
|
|
650
|
-
return t;
|
|
651
|
-
}, Gt = ({ children: t, artboardManager: e, canvasRef: o, canvasEditorRef: n }) => {
|
|
652
|
-
const d = me(null), l = q(() => ({ get: () => d.current }), []), i = Nt(), r = Lt(), u = kt(), [c, V] = E(
|
|
653
|
-
() => e.getAllArtboards()
|
|
654
|
-
), [O, D] = E(0), [w, L] = E(
|
|
655
|
-
() => new Ne()
|
|
656
|
-
), p = q(() => w.toArray(), [w]), f = a((m) => {
|
|
657
|
-
L((h) => {
|
|
658
|
-
const I = h.toArray(), C = typeof m == "function" ? m(I) : m;
|
|
659
|
-
return C === I ? h : Ne.fromArray(C);
|
|
660
|
-
});
|
|
661
|
-
}, []), g = a(
|
|
662
|
-
(m) => w.get(m),
|
|
663
|
-
[w]
|
|
664
|
-
), [z, T] = E([]), b = r.selectedId ? w.get(r.selectedId) : void 0, _ = a(() => {
|
|
665
|
-
V([...e.getAllArtboards()]), D((m) => m + 1);
|
|
666
|
-
}, [e]), {
|
|
667
|
-
historyManager: te,
|
|
668
|
-
executeElementUpdate: B,
|
|
669
|
-
executeAddElement: $,
|
|
670
|
-
executeRemoveElement: s,
|
|
671
|
-
executeReorderElement: A,
|
|
672
|
-
executeCommandBatch: y,
|
|
673
|
-
executeCreateArtboard: x,
|
|
674
|
-
executeDeleteArtboard: P,
|
|
675
|
-
executeUpdateArtboard: k,
|
|
676
|
-
undo: R,
|
|
677
|
-
redo: N,
|
|
678
|
-
canUndo: v,
|
|
679
|
-
canRedo: U,
|
|
680
|
-
undoActiveArtboard: F,
|
|
681
|
-
redoActiveArtboard: j,
|
|
682
|
-
canUndoActiveArtboard: ne,
|
|
683
|
-
canRedoActiveArtboard: Y
|
|
684
|
-
} = Pt(
|
|
685
|
-
p,
|
|
686
|
-
f,
|
|
687
|
-
e,
|
|
688
|
-
_
|
|
689
|
-
), J = a(
|
|
690
|
-
(m) => {
|
|
691
|
-
const h = w.get(m.id);
|
|
692
|
-
B(h, m);
|
|
693
|
-
},
|
|
694
|
-
[w, B]
|
|
695
|
-
), et = a(
|
|
696
|
-
(m) => {
|
|
697
|
-
if (!b || !(b instanceof ke))
|
|
698
|
-
return;
|
|
699
|
-
const h = b.clone(), I = h.children.findIndex(
|
|
700
|
-
(C) => C.id === m.id
|
|
701
|
-
);
|
|
702
|
-
I >= 0 && (h.children[I] = m, J(h));
|
|
703
|
-
},
|
|
704
|
-
[b, J]
|
|
705
|
-
), tt = r.activeChildElement || b, nt = r.activeChildElement ? et : J, {
|
|
706
|
-
fontSize: pe,
|
|
707
|
-
fontColor: he,
|
|
708
|
-
fontFamily: xe,
|
|
709
|
-
textAlign: ye,
|
|
710
|
-
updateFontSize: Ee,
|
|
711
|
-
setFontSizeValue: Se,
|
|
712
|
-
updateFontColor: be,
|
|
713
|
-
updateFontFamily: Ie,
|
|
714
|
-
updateTextAlign: we
|
|
715
|
-
} = Ct(tt, nt), ge = a(
|
|
716
|
-
async (m, h) => {
|
|
717
|
-
var Oe;
|
|
718
|
-
const I = e.getActiveArtboardId();
|
|
719
|
-
if (!I) {
|
|
720
|
-
alert("Please create or select an artboard first");
|
|
721
|
-
return;
|
|
722
|
-
}
|
|
723
|
-
const C = `element-${Date.now()}`, S = e.getActiveArtboard(), ie = S ? S.x + S.width / 2 : window.innerWidth / 2, se = S ? S.y + S.height / 2 : window.innerHeight / 2, W = ((Oe = n.current) == null ? void 0 : Oe.getZoom()) || i.zoom || 1;
|
|
724
|
-
if (m === "image") {
|
|
725
|
-
const ue = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==", ee = 200 / W, K = h == null ? void 0 : h.src, G = new yt({
|
|
726
|
-
id: C,
|
|
727
|
-
x: ie,
|
|
728
|
-
y: se,
|
|
729
|
-
// Defer loading `src` until after the element is in the store so a
|
|
730
|
-
// synchronously-cached image can't fire onLoadCallback too early.
|
|
731
|
-
imageUrl: K ? "" : ue,
|
|
732
|
-
transformData: {
|
|
733
|
-
type: "image",
|
|
734
|
-
width: ee,
|
|
735
|
-
height: ee,
|
|
736
|
-
cropX: 0,
|
|
737
|
-
cropY: 0,
|
|
738
|
-
cropWidth: 1,
|
|
739
|
-
cropHeight: 1,
|
|
740
|
-
flipHorizontal: !1,
|
|
741
|
-
flipVertical: !1,
|
|
742
|
-
borderRadius: 0
|
|
743
|
-
}
|
|
744
|
-
});
|
|
745
|
-
K && (G.imageLoaded = !1, G.imageElement = null, G.isCropping = !1, G.imageUrl = K, G.preserveDimensions = !1, G.onLoadCallback = (M) => {
|
|
746
|
-
const Ue = M.transformData.width, He = M.transformData.height, Re = Math.min(ee / Ue, ee / He, 1);
|
|
747
|
-
Re < 1 && (M.transformData.width = Ue * Re, M.transformData.height = He * Re), M.transformData.cropX = 0, M.transformData.cropY = 0, M.transformData.cropWidth = 1, M.transformData.cropHeight = 1, B(G, M);
|
|
748
|
-
}), $(G, I), r.setSelectedId(G.id), K && G.loadImage(K);
|
|
749
|
-
return;
|
|
750
|
-
}
|
|
751
|
-
let ce;
|
|
752
|
-
const Z = {
|
|
753
|
-
text: "custom",
|
|
754
|
-
circle: "circle",
|
|
755
|
-
wave: "wave",
|
|
756
|
-
arch: "arch",
|
|
757
|
-
shape: "shape"
|
|
758
|
-
}[m] || "custom", ae = Et(Z);
|
|
759
|
-
if (!ae || !ae.Component)
|
|
760
|
-
return;
|
|
761
|
-
const le = e.getActiveArtboard(), ot = le ? Math.min(le.width, le.height) * 0.1 : 80, Fe = le ? le.width * 0.5 : 300;
|
|
762
|
-
if (m === "shape") {
|
|
763
|
-
const ue = (h == null ? void 0 : h.shapeType) ?? "rectangle";
|
|
764
|
-
let ee = 200 / W, K = 200 / W;
|
|
765
|
-
ue === "ellipse" ? (ee = 150 / W, K = 250 / W) : ue === "line" && (ee = 300 / W, K = 8 / W), ce = new St({
|
|
766
|
-
id: C,
|
|
767
|
-
x: ie,
|
|
768
|
-
y: se,
|
|
769
|
-
transformData: {
|
|
770
|
-
type: "shape",
|
|
771
|
-
shapeType: ue,
|
|
772
|
-
width: ee,
|
|
773
|
-
height: K,
|
|
774
|
-
fillColor: "#3b82f6",
|
|
775
|
-
fillOpacity: 1
|
|
776
|
-
}
|
|
777
|
-
});
|
|
778
|
-
} else
|
|
779
|
-
ce = new ae.Component({
|
|
780
|
-
id: C,
|
|
781
|
-
text: "New Text",
|
|
782
|
-
x: ie,
|
|
783
|
-
y: se,
|
|
784
|
-
fontSize: ot,
|
|
785
|
-
fontFamily: "Poppins",
|
|
786
|
-
color: Ot(S == null ? void 0 : S.backgroundColor),
|
|
787
|
-
transformData: Z === "arch" ? {
|
|
788
|
-
type: "arch",
|
|
789
|
-
width: Fe,
|
|
790
|
-
archHeight: bt.archHeight
|
|
791
|
-
} : Z === "wave" ? {
|
|
792
|
-
type: "wave",
|
|
793
|
-
width: Fe,
|
|
794
|
-
amplitude: De.amplitude,
|
|
795
|
-
frequency: De.frequency
|
|
796
|
-
} : Z === "circle" ? {
|
|
797
|
-
type: "circle",
|
|
798
|
-
radius: Fe / 2
|
|
799
|
-
} : void 0
|
|
800
|
-
});
|
|
801
|
-
e.addElementToArtboard(C, I), $(
|
|
802
|
-
ce,
|
|
803
|
-
I,
|
|
804
|
-
r.selectedId || void 0
|
|
805
|
-
), r.setSelectedId(C);
|
|
806
|
-
},
|
|
807
|
-
[e, $, B, r, i.zoom, n]
|
|
808
|
-
), Te = a(() => {
|
|
809
|
-
const m = [];
|
|
810
|
-
if (r.multiSelection.length > 0) {
|
|
811
|
-
const h = p.filter(
|
|
812
|
-
(I) => r.multiSelection.includes(I.id)
|
|
813
|
-
);
|
|
814
|
-
m.push(...h);
|
|
815
|
-
} else b && m.push(b);
|
|
816
|
-
if (m.length > 0) {
|
|
817
|
-
const h = m.map((I) => I.clone());
|
|
818
|
-
T(h);
|
|
819
|
-
}
|
|
820
|
-
}, [b, r.multiSelection, p]), Pe = a(() => {
|
|
821
|
-
if (z.length === 0) return;
|
|
822
|
-
const m = [], h = 30, I = 30;
|
|
823
|
-
z.forEach((C) => {
|
|
824
|
-
const S = w.get(C.id), ie = S ? S.x : C.x, se = S ? S.y : C.y, W = C.toJSON();
|
|
825
|
-
delete W.id;
|
|
826
|
-
const ce = C.constructor, de = new ce(W);
|
|
827
|
-
de.x = ie + h, de.y = se + I;
|
|
828
|
-
let Z = null;
|
|
829
|
-
if (S && (Z = e.getArtboardIdForElement(
|
|
830
|
-
S.id
|
|
831
|
-
)), Z || (Z = e.getActiveArtboardId()), !Z) {
|
|
832
|
-
Zt.warn("[handlePasteElements] No artboard found for pasting");
|
|
833
|
-
return;
|
|
834
|
-
}
|
|
835
|
-
const ae = S ? S.id : void 0;
|
|
836
|
-
$(de, Z, ae), m.push(de.id);
|
|
837
|
-
}), m.length === 1 ? r.handleSelectionChange(m[0]) : m.length > 1 && r.setMultiSelection(m);
|
|
838
|
-
}, [
|
|
839
|
-
z,
|
|
840
|
-
w,
|
|
841
|
-
e,
|
|
842
|
-
$,
|
|
843
|
-
r
|
|
844
|
-
]), fe = a(() => {
|
|
845
|
-
if (u.expandedPanelType === "crop" && (b == null ? void 0 : b.transformType) === "image") {
|
|
846
|
-
const m = b;
|
|
847
|
-
if (m.isCropping) {
|
|
848
|
-
const h = m.clone();
|
|
849
|
-
h.exitCropMode(), B(m, h);
|
|
850
|
-
}
|
|
851
|
-
}
|
|
852
|
-
u.setExpandedPanelType(null);
|
|
853
|
-
}, [
|
|
854
|
-
u.expandedPanelType,
|
|
855
|
-
u.setExpandedPanelType,
|
|
856
|
-
b,
|
|
857
|
-
B
|
|
858
|
-
]);
|
|
859
|
-
ve(() => {
|
|
860
|
-
const m = (h) => {
|
|
861
|
-
const I = h.target;
|
|
862
|
-
if (I.tagName === "CANVAS" || Ft(I))
|
|
863
|
-
return;
|
|
864
|
-
const S = document.activeElement;
|
|
865
|
-
if (S != null && S.hasAttribute("data-preserve-selection")) {
|
|
866
|
-
S.blur();
|
|
867
|
-
return;
|
|
868
|
-
}
|
|
869
|
-
if (u.expandedPanelType !== null) {
|
|
870
|
-
fe();
|
|
871
|
-
return;
|
|
872
|
-
}
|
|
873
|
-
r.selectedId !== null && r.setSelectedId(null), r.multiSelection.length > 0 && r.setMultiSelection([]);
|
|
874
|
-
};
|
|
875
|
-
return document.addEventListener("pointerdown", m), () => document.removeEventListener("pointerdown", m);
|
|
876
|
-
}, [u.expandedPanelType, fe, r]);
|
|
877
|
-
const Ce = a(
|
|
878
|
-
(m, h, I) => {
|
|
879
|
-
e.clear(), m.forEach((C) => {
|
|
880
|
-
e.createArtboard(C.toJSON());
|
|
881
|
-
}), I && e.setActiveArtboard(I), V([...e.getAllArtboards()]), D((C) => C + 1), f(h), r.setSelectedId(null);
|
|
882
|
-
},
|
|
883
|
-
[e, r, f]
|
|
884
|
-
), ze = q(() => ({
|
|
885
|
-
// From ViewportContext
|
|
886
|
-
zoom: i.zoom,
|
|
887
|
-
panOffset: i.panOffset,
|
|
888
|
-
isPanning: i.isPanning,
|
|
889
|
-
zoomIn: i.zoomIn,
|
|
890
|
-
zoomOut: i.zoomOut,
|
|
891
|
-
zoomToFit: i.zoomToFit,
|
|
892
|
-
resetView: i.resetView,
|
|
893
|
-
setZoom: i.setZoom,
|
|
894
|
-
setPanOffset: i.setPanOffset,
|
|
895
|
-
setIsPanning: i.setIsPanning,
|
|
896
|
-
// From SelectionContext
|
|
897
|
-
selectedId: r.selectedId,
|
|
898
|
-
multiSelection: r.multiSelection,
|
|
899
|
-
activeChildElement: r.activeChildElement,
|
|
900
|
-
hoveredElementId: r.hoveredElementId,
|
|
901
|
-
hideHandles: r.hideHandles,
|
|
902
|
-
setSelectedId: r.setSelectedId,
|
|
903
|
-
setMultiSelection: r.setMultiSelection,
|
|
904
|
-
setHoveredElementId: r.setHoveredElementId,
|
|
905
|
-
setHideHandles: r.setHideHandles,
|
|
906
|
-
handleSelectionChange: r.handleSelectionChange,
|
|
907
|
-
handleActiveChildChange: r.handleActiveChildChange,
|
|
908
|
-
// From ToolStateContext
|
|
909
|
-
expandedPanelType: u.expandedPanelType,
|
|
910
|
-
setExpandedPanelType: u.setExpandedPanelType,
|
|
911
|
-
isToolbarMenuOpen: u.isToolbarMenuOpen,
|
|
912
|
-
setIsToolbarMenuOpen: u.setIsToolbarMenuOpen,
|
|
913
|
-
textSelectionVersion: u.textSelectionVersion,
|
|
914
|
-
setTextSelectionVersion: u.setTextSelectionVersion,
|
|
915
|
-
isCanvasReady: u.isCanvasReady,
|
|
916
|
-
setCanvasReady: u.setCanvasReady,
|
|
917
|
-
isRotating: u.isRotating,
|
|
918
|
-
setIsRotating: u.setIsRotating,
|
|
919
|
-
// Cross-context handler
|
|
920
|
-
clearExpandedPanel: fe,
|
|
921
|
-
// Core state (element/artboard domain)
|
|
922
|
-
artboardManager: e,
|
|
923
|
-
artboards: c,
|
|
924
|
-
elements: p,
|
|
925
|
-
elementStore: w,
|
|
926
|
-
getElementById: g,
|
|
927
|
-
// Derived state (cross-context)
|
|
928
|
-
selectedElement: b,
|
|
929
|
-
// Refs
|
|
930
|
-
canvasRef: o,
|
|
931
|
-
canvasEditorRef: n,
|
|
932
|
-
// Element setters
|
|
933
|
-
setElements: f,
|
|
934
|
-
// Artboard version counter
|
|
935
|
-
artboardVersion: O,
|
|
936
|
-
// Handlers
|
|
937
|
-
refreshArtboards: _,
|
|
938
|
-
handleElementUpdate: J,
|
|
939
|
-
handleAddElement: ge,
|
|
940
|
-
handleLoadWorkspace: Ce,
|
|
941
|
-
handleCopyElements: Te,
|
|
942
|
-
handlePasteElements: Pe,
|
|
943
|
-
// Command history (undo/redo actions + execute functions)
|
|
944
|
-
historyManager: te,
|
|
945
|
-
executeElementUpdate: B,
|
|
946
|
-
executeAddElement: $,
|
|
947
|
-
executeRemoveElement: s,
|
|
948
|
-
executeReorderElement: A,
|
|
949
|
-
executeCommandBatch: y,
|
|
950
|
-
executeCreateArtboard: x,
|
|
951
|
-
executeDeleteArtboard: P,
|
|
952
|
-
executeUpdateArtboard: k,
|
|
953
|
-
undo: R,
|
|
954
|
-
redo: N,
|
|
955
|
-
canUndo: v,
|
|
956
|
-
canRedo: U,
|
|
957
|
-
undoActiveArtboard: F,
|
|
958
|
-
redoActiveArtboard: j,
|
|
959
|
-
canUndoActiveArtboard: ne,
|
|
960
|
-
canRedoActiveArtboard: Y,
|
|
961
|
-
// Element properties
|
|
962
|
-
fontSize: pe,
|
|
963
|
-
fontColor: he,
|
|
964
|
-
fontFamily: xe,
|
|
965
|
-
textAlign: ye,
|
|
966
|
-
updateFontSize: Ee,
|
|
967
|
-
setFontSizeValue: Se,
|
|
968
|
-
updateFontColor: be,
|
|
969
|
-
updateFontFamily: Ie,
|
|
970
|
-
updateTextAlign: we
|
|
971
|
-
}), [
|
|
972
|
-
// Viewport
|
|
973
|
-
i.zoom,
|
|
974
|
-
i.panOffset,
|
|
975
|
-
i.isPanning,
|
|
976
|
-
i.zoomIn,
|
|
977
|
-
i.zoomOut,
|
|
978
|
-
i.zoomToFit,
|
|
979
|
-
i.resetView,
|
|
980
|
-
i.setZoom,
|
|
981
|
-
i.setPanOffset,
|
|
982
|
-
i.setIsPanning,
|
|
983
|
-
// Selection
|
|
984
|
-
r.selectedId,
|
|
985
|
-
r.multiSelection,
|
|
986
|
-
r.activeChildElement,
|
|
987
|
-
r.hoveredElementId,
|
|
988
|
-
r.hideHandles,
|
|
989
|
-
r.setSelectedId,
|
|
990
|
-
r.setMultiSelection,
|
|
991
|
-
r.setHoveredElementId,
|
|
992
|
-
r.setHideHandles,
|
|
993
|
-
r.handleSelectionChange,
|
|
994
|
-
r.handleActiveChildChange,
|
|
995
|
-
// Tool state
|
|
996
|
-
u.expandedPanelType,
|
|
997
|
-
u.setExpandedPanelType,
|
|
998
|
-
u.isToolbarMenuOpen,
|
|
999
|
-
u.setIsToolbarMenuOpen,
|
|
1000
|
-
u.textSelectionVersion,
|
|
1001
|
-
u.setTextSelectionVersion,
|
|
1002
|
-
u.isCanvasReady,
|
|
1003
|
-
u.setCanvasReady,
|
|
1004
|
-
u.isRotating,
|
|
1005
|
-
u.setIsRotating,
|
|
1006
|
-
fe,
|
|
1007
|
-
// Element/artboard domain
|
|
1008
|
-
e,
|
|
1009
|
-
c,
|
|
1010
|
-
p,
|
|
1011
|
-
w,
|
|
1012
|
-
g,
|
|
1013
|
-
b,
|
|
1014
|
-
o,
|
|
1015
|
-
n,
|
|
1016
|
-
f,
|
|
1017
|
-
O,
|
|
1018
|
-
_,
|
|
1019
|
-
J,
|
|
1020
|
-
ge,
|
|
1021
|
-
Ce,
|
|
1022
|
-
Te,
|
|
1023
|
-
Pe,
|
|
1024
|
-
// Command history
|
|
1025
|
-
te,
|
|
1026
|
-
B,
|
|
1027
|
-
$,
|
|
1028
|
-
s,
|
|
1029
|
-
A,
|
|
1030
|
-
y,
|
|
1031
|
-
x,
|
|
1032
|
-
P,
|
|
1033
|
-
k,
|
|
1034
|
-
R,
|
|
1035
|
-
N,
|
|
1036
|
-
v,
|
|
1037
|
-
U,
|
|
1038
|
-
F,
|
|
1039
|
-
j,
|
|
1040
|
-
ne,
|
|
1041
|
-
Y,
|
|
1042
|
-
// Element properties
|
|
1043
|
-
pe,
|
|
1044
|
-
he,
|
|
1045
|
-
xe,
|
|
1046
|
-
ye,
|
|
1047
|
-
Ee,
|
|
1048
|
-
Se,
|
|
1049
|
-
be,
|
|
1050
|
-
Ie,
|
|
1051
|
-
we
|
|
1052
|
-
]);
|
|
1053
|
-
return d.current = ze, /* @__PURE__ */ H(Qe.Provider, { value: l, children: /* @__PURE__ */ H(
|
|
1054
|
-
Bt,
|
|
1055
|
-
{
|
|
1056
|
-
value: {
|
|
1057
|
-
undo: R,
|
|
1058
|
-
redo: N,
|
|
1059
|
-
canUndo: v,
|
|
1060
|
-
canRedo: U,
|
|
1061
|
-
undoActiveArtboard: F,
|
|
1062
|
-
redoActiveArtboard: j,
|
|
1063
|
-
canUndoActiveArtboard: ne,
|
|
1064
|
-
canRedoActiveArtboard: Y
|
|
1065
|
-
},
|
|
1066
|
-
children: /* @__PURE__ */ H(
|
|
1067
|
-
$t,
|
|
1068
|
-
{
|
|
1069
|
-
value: {
|
|
1070
|
-
elements: p,
|
|
1071
|
-
elementStore: w,
|
|
1072
|
-
artboards: c,
|
|
1073
|
-
artboardManager: e,
|
|
1074
|
-
artboardVersion: O,
|
|
1075
|
-
setElements: f,
|
|
1076
|
-
refreshArtboards: _,
|
|
1077
|
-
getElementById: g,
|
|
1078
|
-
handleAddElement: ge,
|
|
1079
|
-
handleElementUpdate: J,
|
|
1080
|
-
handleLoadWorkspace: Ce,
|
|
1081
|
-
handleCopyElements: Te,
|
|
1082
|
-
handlePasteElements: Pe,
|
|
1083
|
-
fontSize: pe,
|
|
1084
|
-
fontColor: he,
|
|
1085
|
-
fontFamily: xe,
|
|
1086
|
-
textAlign: ye,
|
|
1087
|
-
updateFontSize: Ee,
|
|
1088
|
-
setFontSizeValue: Se,
|
|
1089
|
-
updateFontColor: be,
|
|
1090
|
-
updateFontFamily: Ie,
|
|
1091
|
-
updateTextAlign: we,
|
|
1092
|
-
canvasRef: o,
|
|
1093
|
-
canvasEditorRef: n
|
|
1094
|
-
},
|
|
1095
|
-
children: /* @__PURE__ */ H(
|
|
1096
|
-
Wt,
|
|
1097
|
-
{
|
|
1098
|
-
value: {
|
|
1099
|
-
executeElementUpdate: B,
|
|
1100
|
-
executeAddElement: $,
|
|
1101
|
-
executeRemoveElement: s,
|
|
1102
|
-
executeReorderElement: A,
|
|
1103
|
-
executeCommandBatch: y,
|
|
1104
|
-
executeCreateArtboard: x,
|
|
1105
|
-
executeDeleteArtboard: P,
|
|
1106
|
-
executeUpdateArtboard: k,
|
|
1107
|
-
undo: R,
|
|
1108
|
-
redo: N,
|
|
1109
|
-
canUndo: v,
|
|
1110
|
-
canRedo: U,
|
|
1111
|
-
undoActiveArtboard: F,
|
|
1112
|
-
redoActiveArtboard: j,
|
|
1113
|
-
canUndoActiveArtboard: ne,
|
|
1114
|
-
canRedoActiveArtboard: Y,
|
|
1115
|
-
historyManager: te
|
|
1116
|
-
},
|
|
1117
|
-
children: /* @__PURE__ */ H(qe.Provider, { value: ze, children: t })
|
|
1118
|
-
}
|
|
1119
|
-
)
|
|
1120
|
-
}
|
|
1121
|
-
)
|
|
1122
|
-
}
|
|
1123
|
-
) });
|
|
1124
|
-
}, nn = ({
|
|
1125
|
-
children: t,
|
|
1126
|
-
initialArtboardConfig: e = {},
|
|
1127
|
-
viewPadding: o = 0.9
|
|
1128
|
-
}) => {
|
|
1129
|
-
const [n] = E(() => {
|
|
1130
|
-
const i = new xt(), r = {
|
|
1131
|
-
name: e.name || "Artboard 1",
|
|
1132
|
-
x: e.x ?? 0,
|
|
1133
|
-
y: e.y ?? 0,
|
|
1134
|
-
width: e.width ?? 1e3,
|
|
1135
|
-
height: e.height ?? 1e3,
|
|
1136
|
-
backgroundColor: e.backgroundColor || ht
|
|
1137
|
-
};
|
|
1138
|
-
return i.createArtboard(r), i;
|
|
1139
|
-
}), d = me(null), l = me(null);
|
|
1140
|
-
return /* @__PURE__ */ H(
|
|
1141
|
-
Vt,
|
|
1142
|
-
{
|
|
1143
|
-
artboardManager: n,
|
|
1144
|
-
canvasRef: d,
|
|
1145
|
-
viewPadding: o,
|
|
1146
|
-
children: /* @__PURE__ */ H(Dt, { children: /* @__PURE__ */ H(_t, { children: /* @__PURE__ */ H(
|
|
1147
|
-
Gt,
|
|
1148
|
-
{
|
|
1149
|
-
artboardManager: n,
|
|
1150
|
-
canvasRef: d,
|
|
1151
|
-
canvasEditorRef: l,
|
|
1152
|
-
children: t
|
|
1153
|
-
}
|
|
1154
|
-
) }) })
|
|
1155
|
-
}
|
|
1156
|
-
);
|
|
1157
|
-
}, on = () => {
|
|
1158
|
-
const t = X(qe);
|
|
1159
|
-
if (!t)
|
|
1160
|
-
throw new Error("useEditor must be used within EditorProvider");
|
|
1161
|
-
return t;
|
|
1162
|
-
}, re = [];
|
|
1163
|
-
function rn(t) {
|
|
1164
|
-
Tt() && re.push(t);
|
|
1165
|
-
}
|
|
1166
|
-
function sn() {
|
|
1167
|
-
return [...re];
|
|
1168
|
-
}
|
|
1169
|
-
function cn() {
|
|
1170
|
-
re.length = 0;
|
|
1171
|
-
}
|
|
1172
|
-
function dn() {
|
|
1173
|
-
if (re.length === 0) return;
|
|
1174
|
-
const t = re.map((e) => gt(e) ? `${e.code}: ${e.message}` : `${e.name}: ${e.message}`).join(`
|
|
1175
|
-
- `);
|
|
1176
|
-
throw re.length = 0, new Error(
|
|
1177
|
-
`expectNoEditorErrors: ${t.includes(`
|
|
1178
|
-
`) ? "errors were" : "an error was"} contained by <Editor.Root>'s boundary during this test:
|
|
1179
|
-
- ${t}
|
|
1180
|
-
A contained error renders an error card in prod — this composition is broken even if the test rendered "successfully".`
|
|
1181
|
-
);
|
|
1182
|
-
}
|
|
1183
|
-
export {
|
|
1184
|
-
We as B,
|
|
1185
|
-
nn as E,
|
|
1186
|
-
Ze as P,
|
|
1187
|
-
Nt as a,
|
|
1188
|
-
en as b,
|
|
1189
|
-
Qt as c,
|
|
1190
|
-
qt as d,
|
|
1191
|
-
Lt as e,
|
|
1192
|
-
kt as f,
|
|
1193
|
-
wt as g,
|
|
1194
|
-
Jt as h,
|
|
1195
|
-
gt as i,
|
|
1196
|
-
Tt as j,
|
|
1197
|
-
tn as k,
|
|
1198
|
-
dn as l,
|
|
1199
|
-
sn as m,
|
|
1200
|
-
cn as n,
|
|
1201
|
-
Rt as o,
|
|
1202
|
-
Kt as p,
|
|
1203
|
-
Mt as q,
|
|
1204
|
-
rn as r,
|
|
1205
|
-
Ft as s,
|
|
1206
|
-
on as u
|
|
1207
|
-
};
|
|
1208
|
-
//# sourceMappingURL=editorErrors-B2mb1sVN.js.map
|