@snowcone-app/canvas 0.28.0 → 0.30.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 +13 -0
- package/dist/{CanvasRenderer-B_3GISlW.js → CanvasRenderer-BEf0hXeF.js} +1083 -1071
- package/dist/CanvasRenderer-BEf0hXeF.js.map +1 -0
- package/dist/{CanvasStateV1-kL09wsAn.js → CanvasStateV1-BDSyYo4A.js} +872 -844
- package/dist/{CanvasStateV1-kL09wsAn.js.map → CanvasStateV1-BDSyYo4A.js.map} +1 -1
- package/dist/ContextualToolbars-C3D_6sep.js +5960 -0
- package/dist/ContextualToolbars-C3D_6sep.js.map +1 -0
- package/dist/{EditorCanvasImpl-CrI9C_xM.js → EditorCanvasImpl-DXeBz2CX.js} +8 -8
- package/dist/{EditorCanvasImpl-CrI9C_xM.js.map → EditorCanvasImpl-DXeBz2CX.js.map} +1 -1
- package/dist/{ExportManager-J2xK86uq.js → ExportManager-DUdis6se.js} +1307 -970
- package/dist/ExportManager-DUdis6se.js.map +1 -0
- package/dist/{FontAnalyzer-PE6nysqE.js → FontAnalyzer-DKG5JK0x.js} +1419 -1342
- package/dist/FontAnalyzer-DKG5JK0x.js.map +1 -0
- package/dist/{ImagePanel-CmQCxBGm.js → ImagePanel-CBgGqmVV.js} +53 -53
- package/dist/{ImagePanel-CmQCxBGm.js.map → ImagePanel-CBgGqmVV.js.map} +1 -1
- package/dist/SnowconeCanvas-BWPBngvI.js +1192 -0
- package/dist/SnowconeCanvas-BWPBngvI.js.map +1 -0
- package/dist/{UnifiedFontService-BJzoqfBF.js → UnifiedFontService-Co9tQ59z.js} +869 -826
- package/dist/UnifiedFontService-Co9tQ59z.js.map +1 -0
- package/dist/advanced.mjs +14 -14
- package/dist/api/embed.d.ts +2 -0
- package/dist/api/stable.d.ts +2 -0
- package/dist/components/CanvasContextMenu.d.ts +15 -0
- package/dist/components/CanvasEditor/hooks/useCanvasInteraction.d.ts +27 -0
- package/dist/components/CanvasEditor.d.ts +8 -0
- package/dist/components/embed/SnowconeCanvas.d.ts +13 -0
- package/dist/components/embed/kernel.d.ts +8 -0
- package/dist/components/toolbars/SecondaryPanels.d.ts +11 -0
- package/dist/components/ui/icons.d.ts +2 -0
- package/dist/contexts/CanvasServicesContext.d.ts +17 -0
- package/dist/contexts/EditorContext.d.ts +7 -0
- package/dist/core/TextElement.d.ts +13 -0
- package/dist/core/TextMetrics.d.ts +17 -3
- package/dist/core/rich-text-layout.d.ts +2 -0
- package/dist/core/text-spacing.d.ts +74 -0
- package/dist/{custom-icons-BWiUGqD6.js → custom-icons-BIaRovwG.js} +2 -2
- package/dist/{custom-icons-BWiUGqD6.js.map → custom-icons-BIaRovwG.js.map} +1 -1
- package/dist/{design-builder-bquxIHct.js → design-builder-JYLO_Hyi.js} +2 -2
- package/dist/{design-builder-bquxIHct.js.map → design-builder-JYLO_Hyi.js.map} +1 -1
- package/dist/{editorErrors-8uDRMhow.js → editorErrors-WzaNxU1Y.js} +181 -194
- package/dist/editorErrors-WzaNxU1Y.js.map +1 -0
- package/dist/{embed-L3oRIgsj.js → embed-Csez1hui.js} +113 -112
- package/dist/{embed-L3oRIgsj.js.map → embed-Csez1hui.js.map} +1 -1
- package/dist/embed.mjs +51 -45
- package/dist/embed.mjs.map +1 -1
- package/dist/errors/editorError.d.ts +8 -0
- package/dist/{guards-BlbhM5MX.js → guards-BSoX73yg.js} +2 -2
- package/dist/{guards-BlbhM5MX.js.map → guards-BSoX73yg.js.map} +1 -1
- package/dist/hooks/useKeyboardShortcuts.d.ts +15 -2
- package/dist/hooks/useLayers.d.ts +2 -0
- package/dist/hooks/useTextToolbar.d.ts +8 -0
- package/dist/index.mjs +42 -37
- package/dist/index.mjs.map +1 -1
- package/dist/internals.mjs +47 -47
- package/dist/rendering/renderer-types.d.ts +4 -0
- package/dist/rendering/rich-text-renderer.d.ts +4 -0
- package/dist/rendering/text-renderer.d.ts +4 -1
- package/dist/state/CanvasStateV1.d.ts +34 -3
- package/dist/state/index.d.ts +2 -2
- package/dist/{template-fields-ai7vnW8g.js → template-fields-DYPW7bVU.js} +40 -40
- package/dist/{template-fields-ai7vnW8g.js.map → template-fields-DYPW7bVU.js.map} +1 -1
- package/dist/testing.mjs +13 -13
- package/dist/types/index.d.ts +26 -0
- package/dist/{usePieceGuideBundle-CMe5br2a.js → usePieceGuideBundle-CRLY2iQa.js} +2 -2
- package/dist/{usePieceGuideBundle-CMe5br2a.js.map → usePieceGuideBundle-CRLY2iQa.js.map} +1 -1
- package/dist/utils/custom-fonts.d.ts +99 -0
- package/dist/utils/featureApplied.d.ts +6 -0
- package/dist/validation-BGEl9rrE.js +8686 -0
- package/dist/validation-BGEl9rrE.js.map +1 -0
- package/dist/workers/export-protocol.d.ts +13 -0
- package/dist/workers/export-worker.bundle.string.d.ts +1 -1
- package/example/package.json +1 -1
- package/package.json +1 -1
- package/dist/CanvasRenderer-B_3GISlW.js.map +0 -1
- package/dist/ContextualToolbars-C69oYLdw.js +0 -5771
- package/dist/ContextualToolbars-C69oYLdw.js.map +0 -1
- package/dist/ExportManager-J2xK86uq.js.map +0 -1
- package/dist/FontAnalyzer-PE6nysqE.js.map +0 -1
- package/dist/SnowconeCanvas-CQiFVR0X.js +0 -1173
- package/dist/SnowconeCanvas-CQiFVR0X.js.map +0 -1
- package/dist/UnifiedFontService-BJzoqfBF.js.map +0 -1
- package/dist/editorErrors-8uDRMhow.js.map +0 -1
- package/dist/validation-B8kIYutI.js +0 -8397
- package/dist/validation-B8kIYutI.js.map +0 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { jsx as H } from "react/jsx-runtime";
|
|
2
|
-
import { useContext as G, useSyncExternalStore as
|
|
3
|
-
import {
|
|
4
|
-
const Ge = Q(null),
|
|
5
|
-
},
|
|
2
|
+
import { useContext as G, useSyncExternalStore as st, useCallback as l, createContext as Q, useRef as me, useState as b, useEffect as Oe, useMemo as q } from "react";
|
|
3
|
+
import { V as ct, E as $e, U as dt, ai as at, G as We, aj as lt, ak as ut, al as mt, am as ft, an as At, c as Ze, C as pt, ao as ht, ap as xt, aq as yt, K as Et, O as De, I as bt, g as St, S as wt, ar as It, as as Le, y as gt, D as Tt } from "./FontAnalyzer-DKG5JK0x.js";
|
|
4
|
+
const Ge = Q(null), Ct = () => () => {
|
|
5
|
+
}, _e = () => 0;
|
|
6
6
|
function Kt() {
|
|
7
|
-
const t = G(Ge), e =
|
|
8
|
-
t ? t.subscribe :
|
|
9
|
-
t ? t.getVersion :
|
|
10
|
-
t ? t.getVersion :
|
|
7
|
+
const t = G(Ge), e = st(
|
|
8
|
+
t ? t.subscribe : Ct,
|
|
9
|
+
t ? t.getVersion : _e,
|
|
10
|
+
t ? t.getVersion : _e
|
|
11
11
|
);
|
|
12
12
|
return l(
|
|
13
13
|
(o) => !!(t && o && t.getBoundLayer(o)),
|
|
@@ -16,27 +16,15 @@ function Kt() {
|
|
|
16
16
|
[t, e]
|
|
17
17
|
);
|
|
18
18
|
}
|
|
19
|
-
class Xe 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 Ct(t) {
|
|
25
|
-
return t instanceof Error && t.name === "EditorError" && "code" in t;
|
|
26
|
-
}
|
|
27
|
-
function Rt() {
|
|
28
|
-
var t;
|
|
29
|
-
return typeof De < "u" && ((t = De.env) == null ? void 0 : t.NODE_ENV) !== "production";
|
|
30
|
-
}
|
|
31
19
|
const pe = Ze("useCommandHistory");
|
|
32
|
-
function
|
|
33
|
-
const a = me(new
|
|
20
|
+
function Rt(t, e, o, n) {
|
|
21
|
+
const a = me(new ct(o)), u = G(Ge), i = l(
|
|
34
22
|
(s, A) => {
|
|
35
23
|
const y = s == null ? void 0 : s.name;
|
|
36
24
|
if (!u || !y) return;
|
|
37
25
|
const x = u.getBoundLayer(y);
|
|
38
26
|
if (x)
|
|
39
|
-
throw new
|
|
27
|
+
throw new $e(
|
|
40
28
|
"E_BOUND_LAYER_MUTATION",
|
|
41
29
|
`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
30
|
{ layer: y, part: x.part, operation: A, docSlug: "embed-mode" }
|
|
@@ -61,12 +49,12 @@ function Pt(t, e, o, n) {
|
|
|
61
49
|
}, [o]), V = l(
|
|
62
50
|
(s, A) => {
|
|
63
51
|
s && s.name !== A.name && i(s, "rename");
|
|
64
|
-
const y = new
|
|
52
|
+
const y = new dt(
|
|
65
53
|
A.id,
|
|
66
54
|
s || null,
|
|
67
55
|
A,
|
|
68
56
|
(T) => {
|
|
69
|
-
e((
|
|
57
|
+
e((k) => k.map((v) => v.id === T.id ? T : v));
|
|
70
58
|
}
|
|
71
59
|
), x = o.getArtboardIdForElement(A.id);
|
|
72
60
|
if (x)
|
|
@@ -85,45 +73,45 @@ function Pt(t, e, o, n) {
|
|
|
85
73
|
pe.warn("No active artboard to add element to");
|
|
86
74
|
return;
|
|
87
75
|
}
|
|
88
|
-
const
|
|
76
|
+
const k = new at(
|
|
89
77
|
s,
|
|
90
|
-
(
|
|
91
|
-
const N =
|
|
92
|
-
e((
|
|
78
|
+
(v) => {
|
|
79
|
+
const N = v;
|
|
80
|
+
e((z) => {
|
|
93
81
|
if (x) {
|
|
94
|
-
const U =
|
|
82
|
+
const U = z.findIndex((P) => P.id === x);
|
|
95
83
|
if (U !== -1) {
|
|
96
|
-
const P = [...
|
|
84
|
+
const P = [...z];
|
|
97
85
|
return P.splice(U, 0, N), P;
|
|
98
86
|
}
|
|
99
87
|
}
|
|
100
88
|
if (y) {
|
|
101
|
-
const U =
|
|
89
|
+
const U = z.findIndex((P) => P.id === y);
|
|
102
90
|
if (U !== -1) {
|
|
103
|
-
const P = [...
|
|
91
|
+
const P = [...z];
|
|
104
92
|
return P.splice(U + 1, 0, N), P;
|
|
105
93
|
}
|
|
106
|
-
for (let P = 0; P <
|
|
107
|
-
const X =
|
|
94
|
+
for (let P = 0; P < z.length; P++) {
|
|
95
|
+
const X = z[P];
|
|
108
96
|
if (X instanceof We && X.children) {
|
|
109
97
|
const oe = X.children.findIndex((j) => j.id === y);
|
|
110
98
|
if (oe !== -1) {
|
|
111
99
|
const j = X.clone();
|
|
112
100
|
j.children.splice(oe + 1, 0, N);
|
|
113
|
-
const Y = [...
|
|
101
|
+
const Y = [...z];
|
|
114
102
|
return Y[P] = j, Y;
|
|
115
103
|
}
|
|
116
104
|
}
|
|
117
105
|
}
|
|
118
106
|
}
|
|
119
|
-
return [...
|
|
120
|
-
}), o.addElementToArtboard(
|
|
107
|
+
return [...z, N];
|
|
108
|
+
}), o.addElementToArtboard(v.id, T);
|
|
121
109
|
},
|
|
122
|
-
(
|
|
123
|
-
e((N) => N.filter((
|
|
110
|
+
(v) => {
|
|
111
|
+
e((N) => N.filter((z) => z.id !== v)), o.removeElementFromArtboard(v);
|
|
124
112
|
}
|
|
125
113
|
);
|
|
126
|
-
a.current.executeOnArtboard(T,
|
|
114
|
+
a.current.executeOnArtboard(T, k), c();
|
|
127
115
|
},
|
|
128
116
|
[e, o, c]
|
|
129
117
|
), D = l(
|
|
@@ -134,13 +122,13 @@ function Pt(t, e, o, n) {
|
|
|
134
122
|
pe.warn("Element not found in any artboard");
|
|
135
123
|
return;
|
|
136
124
|
}
|
|
137
|
-
const y = new
|
|
125
|
+
const y = new lt(
|
|
138
126
|
s,
|
|
139
127
|
(x) => {
|
|
140
128
|
e((T) => [...T, x]), o.addElementToArtboard(x.id, A);
|
|
141
129
|
},
|
|
142
130
|
(x) => {
|
|
143
|
-
e((T) => T.filter((
|
|
131
|
+
e((T) => T.filter((k) => k.id !== x)), o.removeElementFromArtboard(x);
|
|
144
132
|
}
|
|
145
133
|
);
|
|
146
134
|
a.current.executeOnArtboard(A, y), c();
|
|
@@ -148,19 +136,19 @@ function Pt(t, e, o, n) {
|
|
|
148
136
|
[e, o, c, i]
|
|
149
137
|
), w = l(
|
|
150
138
|
(s) => {
|
|
151
|
-
const A = new
|
|
139
|
+
const A = new ut(s, o);
|
|
152
140
|
a.current.executeGlobal(A), c(), n == null || n();
|
|
153
141
|
},
|
|
154
142
|
[o, c, n]
|
|
155
143
|
), L = l(
|
|
156
144
|
(s) => {
|
|
157
|
-
const A = new
|
|
145
|
+
const A = new mt(s, o);
|
|
158
146
|
a.current.executeGlobal(A), c(), n == null || n();
|
|
159
147
|
},
|
|
160
148
|
[o, c, n]
|
|
161
149
|
), p = l(
|
|
162
150
|
(s, A, y) => {
|
|
163
|
-
const x = new
|
|
151
|
+
const x = new ft(s, A, y, o);
|
|
164
152
|
a.current.executeGlobal(x), c(), n == null || n();
|
|
165
153
|
},
|
|
166
154
|
[o, c, n]
|
|
@@ -186,7 +174,7 @@ function Pt(t, e, o, n) {
|
|
|
186
174
|
[o, c]
|
|
187
175
|
), I = l(() => {
|
|
188
176
|
a.current.undo() && (c(), n == null || n());
|
|
189
|
-
}, [c, n]),
|
|
177
|
+
}, [c, n]), F = l(() => {
|
|
190
178
|
a.current.redo() && (c(), n == null || n());
|
|
191
179
|
}, [c, n]), g = l(() => {
|
|
192
180
|
const s = o.getActiveArtboardId();
|
|
@@ -208,18 +196,18 @@ function Pt(t, e, o, n) {
|
|
|
208
196
|
});
|
|
209
197
|
const Z = l(
|
|
210
198
|
(s, A, y) => {
|
|
211
|
-
const x = t.map((
|
|
199
|
+
const x = t.map((v) => v.id), T = o.getArtboardIdForElement(s);
|
|
212
200
|
if (!T) {
|
|
213
201
|
pe.warn("Element not found in any artboard");
|
|
214
202
|
return;
|
|
215
203
|
}
|
|
216
|
-
const
|
|
204
|
+
const k = new At(s, A, y, x, (v) => {
|
|
217
205
|
e((N) => {
|
|
218
|
-
const
|
|
219
|
-
return
|
|
206
|
+
const z = new Map(N.map((U) => [U.id, U]));
|
|
207
|
+
return v.map((U) => z.get(U)).filter(Boolean);
|
|
220
208
|
});
|
|
221
209
|
});
|
|
222
|
-
a.current.executeOnArtboard(T,
|
|
210
|
+
a.current.executeOnArtboard(T, k), c();
|
|
223
211
|
},
|
|
224
212
|
[t, e, o, c]
|
|
225
213
|
);
|
|
@@ -237,7 +225,7 @@ function Pt(t, e, o, n) {
|
|
|
237
225
|
executeUpdateArtboard: p,
|
|
238
226
|
// Undo/redo (smart - considers last operation and active artboard)
|
|
239
227
|
undo: I,
|
|
240
|
-
redo:
|
|
228
|
+
redo: F,
|
|
241
229
|
// Undo/redo for active artboard only (element operations)
|
|
242
230
|
undoActiveArtboard: g,
|
|
243
231
|
redoActiveArtboard: S,
|
|
@@ -255,18 +243,18 @@ function Pt(t, e, o, n) {
|
|
|
255
243
|
function ce(t) {
|
|
256
244
|
return t && "fontSize" in t && "color" in t && "fontFamily" in t;
|
|
257
245
|
}
|
|
258
|
-
function
|
|
246
|
+
function Pt(t, e) {
|
|
259
247
|
const [o, n] = b(32), [a, u] = b("#333333"), [i, r] = b("Arial"), [m, c] = b("center");
|
|
260
248
|
Oe(() => {
|
|
261
249
|
if (t && ce(t)) {
|
|
262
|
-
const p = t.transformType === "circle" && "getEffectiveFontSize" in t ? Math.round(t.getEffectiveFontSize()) : Math.round(t.fontSize), f = t.color, I = t.fontFamily,
|
|
263
|
-
n((g) => g !== p ? p : g), u((g) => g !== f ? f : g), r((g) => g !== I ? I : g), c((g) => g !==
|
|
250
|
+
const p = t.transformType === "circle" && "getEffectiveFontSize" in t ? Math.round(t.getEffectiveFontSize()) : Math.round(t.fontSize), f = t.color, I = t.fontFamily, F = t.textAlign;
|
|
251
|
+
n((g) => g !== p ? p : g), u((g) => g !== f ? f : g), r((g) => g !== I ? I : g), c((g) => g !== F ? F : g);
|
|
264
252
|
}
|
|
265
253
|
}, [t]);
|
|
266
254
|
const V = l(
|
|
267
255
|
(p) => {
|
|
268
256
|
if (!t || !ce(t)) return;
|
|
269
|
-
const f = Math.max(
|
|
257
|
+
const f = Math.max(ht, Math.min(xt, o + p));
|
|
270
258
|
n(f);
|
|
271
259
|
const I = t.clone();
|
|
272
260
|
I.transformType === "circle" && "setEffectiveFontSize" in I ? I.setEffectiveFontSize(f) : I.setFontSize(f), e(I);
|
|
@@ -295,7 +283,7 @@ function Ft(t, e) {
|
|
|
295
283
|
(p) => {
|
|
296
284
|
if (!t || !ce(t)) return;
|
|
297
285
|
const f = t.fontFamily;
|
|
298
|
-
f !== p &&
|
|
286
|
+
f !== p && pt.clearCache(f), r(p);
|
|
299
287
|
const I = t.clone();
|
|
300
288
|
I.fontFamily = p, e(I);
|
|
301
289
|
},
|
|
@@ -328,15 +316,15 @@ function Ft(t, e) {
|
|
|
328
316
|
updateTextAlign: L
|
|
329
317
|
};
|
|
330
318
|
}
|
|
331
|
-
const
|
|
332
|
-
function
|
|
319
|
+
const Xe = "data-preserve-selection";
|
|
320
|
+
function Ft(t) {
|
|
333
321
|
if (!(t instanceof Element))
|
|
334
322
|
return !1;
|
|
335
323
|
let e = t;
|
|
336
324
|
const o = [];
|
|
337
325
|
for (; e; ) {
|
|
338
326
|
const n = e.id ? `#${e.id}` : "", a = e.className ? `.${String(e.className).split(" ").slice(0, 2).join(".")}` : "";
|
|
339
|
-
if (o.push(`${e.tagName.toLowerCase()}${n}${a}`), e.hasAttribute(
|
|
327
|
+
if (o.push(`${e.tagName.toLowerCase()}${n}${a}`), e.hasAttribute(Xe))
|
|
340
328
|
return !0;
|
|
341
329
|
const u = e.getAttribute("role");
|
|
342
330
|
if (u === "dialog" || u === "alertdialog" || u === "menu" || u === "listbox")
|
|
@@ -348,18 +336,18 @@ function vt(t) {
|
|
|
348
336
|
}
|
|
349
337
|
return !1;
|
|
350
338
|
}
|
|
351
|
-
const
|
|
352
|
-
[
|
|
339
|
+
const Mt = {
|
|
340
|
+
[Xe]: ""
|
|
353
341
|
};
|
|
354
|
-
function
|
|
355
|
-
const e =
|
|
342
|
+
function vt(t) {
|
|
343
|
+
const e = je(t);
|
|
356
344
|
return e !== null && e < 0.5;
|
|
357
345
|
}
|
|
358
|
-
function
|
|
359
|
-
const e =
|
|
346
|
+
function qt(t) {
|
|
347
|
+
const e = je(t);
|
|
360
348
|
return e !== null && e >= 0.5;
|
|
361
349
|
}
|
|
362
|
-
function
|
|
350
|
+
function je(t) {
|
|
363
351
|
const e = t.trim();
|
|
364
352
|
if (e.startsWith("#")) {
|
|
365
353
|
const n = e.slice(1);
|
|
@@ -369,23 +357,23 @@ function Ye(t) {
|
|
|
369
357
|
else if (n.length === 6)
|
|
370
358
|
a = parseInt(n.slice(0, 2), 16), u = parseInt(n.slice(2, 4), 16), i = parseInt(n.slice(4, 6), 16);
|
|
371
359
|
else return null;
|
|
372
|
-
return Number.isNaN(a) || Number.isNaN(u) || Number.isNaN(i) ? null :
|
|
360
|
+
return Number.isNaN(a) || Number.isNaN(u) || Number.isNaN(i) ? null : Be(a, u, i);
|
|
373
361
|
}
|
|
374
362
|
const o = e.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);
|
|
375
|
-
return o ?
|
|
363
|
+
return o ? Be(Number(o[1]), Number(o[2]), Number(o[3])) : null;
|
|
376
364
|
}
|
|
377
|
-
function
|
|
365
|
+
function Be(t, e, o) {
|
|
378
366
|
const n = (a) => {
|
|
379
367
|
const u = a / 255;
|
|
380
368
|
return u <= 0.03928 ? u / 12.92 : Math.pow((u + 0.055) / 1.055, 2.4);
|
|
381
369
|
};
|
|
382
370
|
return 0.2126 * n(t) + 0.7152 * n(e) + 0.0722 * n(o);
|
|
383
371
|
}
|
|
384
|
-
const
|
|
385
|
-
function
|
|
386
|
-
return t &&
|
|
372
|
+
const zt = "#333333", Ot = "#f4f4f5";
|
|
373
|
+
function Ut(t) {
|
|
374
|
+
return t && vt(t) ? Ot : zt;
|
|
387
375
|
}
|
|
388
|
-
const
|
|
376
|
+
const Ye = Q(null), Ht = 0.1, Vt = 4, ke = 0.25, Nt = ({
|
|
389
377
|
children: t,
|
|
390
378
|
artboardManager: e,
|
|
391
379
|
canvasRef: o,
|
|
@@ -394,19 +382,19 @@ const Je = Q(null), Vt = 0.1, Nt = 4, ke = 0.25, Dt = ({
|
|
|
394
382
|
const [a, u] = b(1), [i, r] = b({ x: 0, y: 0 }), [m, c] = b(!1), [V, O] = b(1), D = l(() => {
|
|
395
383
|
O(1), r({ x: 0, y: 0 });
|
|
396
384
|
}, []), w = l(() => {
|
|
397
|
-
u((
|
|
385
|
+
u((F) => Math.min(F + ke, Vt));
|
|
398
386
|
}, []), L = l(() => {
|
|
399
|
-
u((
|
|
387
|
+
u((F) => Math.max(F - ke, Ht));
|
|
400
388
|
}, []), p = l(() => {
|
|
401
|
-
const
|
|
402
|
-
if (!
|
|
389
|
+
const F = e.getActiveArtboard();
|
|
390
|
+
if (!F || !o.current) return;
|
|
403
391
|
let g = o.current.parentElement, S = 0, B = 0;
|
|
404
392
|
for (; g && (S = g.clientWidth, B = g.clientHeight, !(S > 0 && B > 0)); )
|
|
405
393
|
g = g.parentElement;
|
|
406
394
|
if (!S || !B) return;
|
|
407
395
|
const ne = Math.min(
|
|
408
|
-
S * n /
|
|
409
|
-
B * n /
|
|
396
|
+
S * n / F.width,
|
|
397
|
+
B * n / F.height,
|
|
410
398
|
1
|
|
411
399
|
// Never zoom in beyond 100%
|
|
412
400
|
);
|
|
@@ -431,15 +419,15 @@ const Je = Q(null), Vt = 0.1, Nt = 4, ke = 0.25, Dt = ({
|
|
|
431
419
|
}),
|
|
432
420
|
[a, i, m, w, L, p, f, V, D]
|
|
433
421
|
);
|
|
434
|
-
return /* @__PURE__ */ H(
|
|
422
|
+
return /* @__PURE__ */ H(Ye.Provider, { value: I, children: t });
|
|
435
423
|
};
|
|
436
|
-
function
|
|
437
|
-
const t = G(
|
|
424
|
+
function Dt() {
|
|
425
|
+
const t = G(Ye);
|
|
438
426
|
if (!t)
|
|
439
427
|
throw new Error("useViewportContext must be used within a ViewportProvider (or EditorProvider)");
|
|
440
428
|
return t;
|
|
441
429
|
}
|
|
442
|
-
const
|
|
430
|
+
const Je = Q(null), Lt = ({ children: t }) => {
|
|
443
431
|
const [e, o] = b(null), [n, a] = b([]), [u, i] = b(null), [r, m] = b(null), [c, V] = b(!1), O = l((L) => {
|
|
444
432
|
o(L);
|
|
445
433
|
}, []), D = l((L) => {
|
|
@@ -468,15 +456,15 @@ const Me = Q(null), _t = ({ children: t }) => {
|
|
|
468
456
|
D
|
|
469
457
|
]
|
|
470
458
|
);
|
|
471
|
-
return /* @__PURE__ */ H(
|
|
459
|
+
return /* @__PURE__ */ H(Je.Provider, { value: w, children: t });
|
|
472
460
|
};
|
|
473
|
-
function
|
|
474
|
-
const t = G(
|
|
461
|
+
function _t() {
|
|
462
|
+
const t = G(Je);
|
|
475
463
|
if (!t)
|
|
476
464
|
throw new Error("useSelectionContext must be used within a SelectionProvider (or EditorProvider)");
|
|
477
465
|
return t;
|
|
478
466
|
}
|
|
479
|
-
const Ke = Q(null),
|
|
467
|
+
const Ke = Q(null), Bt = ({ children: t, value: e }) => {
|
|
480
468
|
const o = q(
|
|
481
469
|
() => ({
|
|
482
470
|
undo: e.undo,
|
|
@@ -501,13 +489,13 @@ const Ke = Q(null), $t = ({ children: t, value: e }) => {
|
|
|
501
489
|
);
|
|
502
490
|
return /* @__PURE__ */ H(Ke.Provider, { value: o, children: t });
|
|
503
491
|
};
|
|
504
|
-
function
|
|
492
|
+
function Qt() {
|
|
505
493
|
const t = G(Ke);
|
|
506
494
|
if (!t)
|
|
507
495
|
throw new Error("useHistoryContext must be used within a HistoryProvider (or EditorProvider)");
|
|
508
496
|
return t;
|
|
509
497
|
}
|
|
510
|
-
const
|
|
498
|
+
const Me = Q(null), kt = ({ children: t }) => {
|
|
511
499
|
const [e, o] = b(null), [n, a] = b(!1), [u, i] = b(0), [r, m] = b(!1), [c, V] = b(!1), O = q(
|
|
512
500
|
() => ({
|
|
513
501
|
expandedPanelType: e,
|
|
@@ -523,15 +511,15 @@ const qe = Q(null), kt = ({ children: t }) => {
|
|
|
523
511
|
}),
|
|
524
512
|
[e, n, u, r, c]
|
|
525
513
|
);
|
|
526
|
-
return /* @__PURE__ */ H(
|
|
514
|
+
return /* @__PURE__ */ H(Me.Provider, { value: O, children: t });
|
|
527
515
|
};
|
|
528
|
-
function
|
|
529
|
-
const t = G(
|
|
516
|
+
function $t() {
|
|
517
|
+
const t = G(Me);
|
|
530
518
|
if (!t)
|
|
531
519
|
throw new Error("useToolStateContext must be used within a ToolStateProvider (or EditorProvider)");
|
|
532
520
|
return t;
|
|
533
521
|
}
|
|
534
|
-
const
|
|
522
|
+
const qe = Q(null), Wt = ({ children: t, value: e }) => {
|
|
535
523
|
const o = q(
|
|
536
524
|
() => ({
|
|
537
525
|
elements: e.elements,
|
|
@@ -586,15 +574,15 @@ const Qe = Q(null), Zt = ({ children: t, value: e }) => {
|
|
|
586
574
|
e.canvasEditorRef
|
|
587
575
|
]
|
|
588
576
|
);
|
|
589
|
-
return /* @__PURE__ */ H(
|
|
577
|
+
return /* @__PURE__ */ H(qe.Provider, { value: o, children: t });
|
|
590
578
|
};
|
|
591
|
-
function
|
|
592
|
-
const t = G(
|
|
579
|
+
function en() {
|
|
580
|
+
const t = G(qe);
|
|
593
581
|
if (!t)
|
|
594
582
|
throw new Error("useElementsContext must be used within an ElementsProvider (or EditorProvider)");
|
|
595
583
|
return t;
|
|
596
584
|
}
|
|
597
|
-
const
|
|
585
|
+
const Qe = Q(null), Zt = ({ children: t, value: e }) => {
|
|
598
586
|
const o = q(
|
|
599
587
|
() => ({
|
|
600
588
|
executeElementUpdate: e.executeElementUpdate,
|
|
@@ -635,33 +623,33 @@ const et = Q(null), Gt = ({ children: t, value: e }) => {
|
|
|
635
623
|
e.historyManager
|
|
636
624
|
]
|
|
637
625
|
);
|
|
638
|
-
return /* @__PURE__ */ H(
|
|
626
|
+
return /* @__PURE__ */ H(Qe.Provider, { value: o, children: t });
|
|
639
627
|
};
|
|
640
|
-
function
|
|
641
|
-
const t = G(
|
|
628
|
+
function tn() {
|
|
629
|
+
const t = G(Qe);
|
|
642
630
|
if (!t)
|
|
643
631
|
throw new Error("useCommandContext must be used within a CommandProvider (or EditorProvider)");
|
|
644
632
|
return t;
|
|
645
633
|
}
|
|
646
|
-
const
|
|
647
|
-
const t = G(
|
|
634
|
+
const Gt = Ze("EditorContext"), et = Q(null), tt = Q(null), nn = () => {
|
|
635
|
+
const t = G(tt);
|
|
648
636
|
if (!t)
|
|
649
637
|
throw new Error("useEditorHandles must be used within EditorProvider");
|
|
650
638
|
return t;
|
|
651
|
-
},
|
|
652
|
-
const a = me(null), u = q(() => ({ get: () => a.current }), []), i =
|
|
639
|
+
}, Xt = ({ children: t, artboardManager: e, canvasRef: o, canvasEditorRef: n }) => {
|
|
640
|
+
const a = me(null), u = q(() => ({ get: () => a.current }), []), i = Dt(), r = _t(), m = $t(), [c, V] = b(
|
|
653
641
|
() => e.getAllArtboards()
|
|
654
642
|
), [O, D] = b(0), [w, L] = b(
|
|
655
|
-
() => new
|
|
643
|
+
() => new De()
|
|
656
644
|
), p = q(() => w.toArray(), [w]), f = l((d) => {
|
|
657
645
|
L((h) => {
|
|
658
646
|
const E = h.toArray(), C = typeof d == "function" ? d(E) : d;
|
|
659
|
-
return C === E ? h :
|
|
647
|
+
return C === E ? h : De.fromArray(C);
|
|
660
648
|
});
|
|
661
649
|
}, []), I = l(
|
|
662
650
|
(d) => w.get(d),
|
|
663
651
|
[w]
|
|
664
|
-
), [
|
|
652
|
+
), [F, g] = b([]), S = r.selectedId ? w.get(r.selectedId) : void 0, B = l(() => {
|
|
665
653
|
V([...e.getAllArtboards()]), D((d) => d + 1);
|
|
666
654
|
}, [e]), {
|
|
667
655
|
historyManager: ne,
|
|
@@ -672,16 +660,16 @@ const Xt = Ze("EditorContext"), tt = Q(null), nt = Q(null), on = () => {
|
|
|
672
660
|
executeCommandBatch: y,
|
|
673
661
|
executeCreateArtboard: x,
|
|
674
662
|
executeDeleteArtboard: T,
|
|
675
|
-
executeUpdateArtboard:
|
|
676
|
-
undo:
|
|
663
|
+
executeUpdateArtboard: k,
|
|
664
|
+
undo: v,
|
|
677
665
|
redo: N,
|
|
678
|
-
canUndo:
|
|
666
|
+
canUndo: z,
|
|
679
667
|
canRedo: U,
|
|
680
668
|
undoActiveArtboard: P,
|
|
681
669
|
redoActiveArtboard: X,
|
|
682
670
|
canUndoActiveArtboard: oe,
|
|
683
671
|
canRedoActiveArtboard: j
|
|
684
|
-
} =
|
|
672
|
+
} = Rt(
|
|
685
673
|
p,
|
|
686
674
|
f,
|
|
687
675
|
e,
|
|
@@ -692,7 +680,7 @@ const Xt = Ze("EditorContext"), tt = Q(null), nt = Q(null), on = () => {
|
|
|
692
680
|
_(h, d);
|
|
693
681
|
},
|
|
694
682
|
[w, _]
|
|
695
|
-
),
|
|
683
|
+
), nt = l(
|
|
696
684
|
(d) => {
|
|
697
685
|
if (!S || !(S instanceof We))
|
|
698
686
|
return;
|
|
@@ -702,7 +690,7 @@ const Xt = Ze("EditorContext"), tt = Q(null), nt = Q(null), on = () => {
|
|
|
702
690
|
E >= 0 && (h.children[E] = d, Y(h));
|
|
703
691
|
},
|
|
704
692
|
[S, Y]
|
|
705
|
-
),
|
|
693
|
+
), ot = r.activeChildElement || S, rt = r.activeChildElement ? nt : Y, {
|
|
706
694
|
fontSize: he,
|
|
707
695
|
fontColor: xe,
|
|
708
696
|
fontFamily: ye,
|
|
@@ -712,26 +700,26 @@ const Xt = Ze("EditorContext"), tt = Q(null), nt = Q(null), on = () => {
|
|
|
712
700
|
updateFontColor: we,
|
|
713
701
|
updateFontFamily: Ie,
|
|
714
702
|
updateTextAlign: ge
|
|
715
|
-
} =
|
|
703
|
+
} = Pt(ot, rt), fe = l(
|
|
716
704
|
async (d) => {
|
|
717
705
|
var He;
|
|
718
706
|
const h = d.type, E = d, C = e.getActiveArtboardId();
|
|
719
707
|
if (!C)
|
|
720
|
-
throw new
|
|
708
|
+
throw new $e(
|
|
721
709
|
"E_NO_ACTIVE_ARTBOARD",
|
|
722
710
|
`addElement({ type: "${h}" }) 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).`,
|
|
723
711
|
{ type: h, docSlug: "embed-mode" }
|
|
724
712
|
);
|
|
725
|
-
const R = `element-${Date.now()}`,
|
|
713
|
+
const R = `element-${Date.now()}`, $ = e.getActiveArtboard(), ae = $ ? $.x + $.width / 2 : window.innerWidth / 2, re = $ ? $.y + $.height / 2 : window.innerHeight / 2, J = ((He = n.current) == null ? void 0 : He.getZoom()) || i.zoom || 1;
|
|
726
714
|
if (h === "image") {
|
|
727
|
-
const ue = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==", te = 200 / J,
|
|
715
|
+
const ue = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==", te = 200 / J, K = E == null ? void 0 : E.src, W = new bt({
|
|
728
716
|
id: R,
|
|
729
717
|
name: d.name,
|
|
730
718
|
x: ae,
|
|
731
719
|
y: re,
|
|
732
720
|
// Defer loading `src` until after the element is in the store so a
|
|
733
721
|
// synchronously-cached image can't fire onLoadCallback too early.
|
|
734
|
-
imageUrl:
|
|
722
|
+
imageUrl: K ? "" : ue,
|
|
735
723
|
transformData: {
|
|
736
724
|
type: "image",
|
|
737
725
|
width: te,
|
|
@@ -745,10 +733,10 @@ const Xt = Ze("EditorContext"), tt = Q(null), nt = Q(null), on = () => {
|
|
|
745
733
|
borderRadius: 0
|
|
746
734
|
}
|
|
747
735
|
});
|
|
748
|
-
return
|
|
749
|
-
const Ve =
|
|
750
|
-
ze < 1 && (
|
|
751
|
-
}), Z(W, C), r.setSelectedId(W.id),
|
|
736
|
+
return K && (W.imageLoaded = !1, W.imageElement = null, W.isCropping = !1, W.imageUrl = K, W.preserveDimensions = !1, W.onLoadCallback = (M) => {
|
|
737
|
+
const Ve = M.transformData.width, Ne = M.transformData.height, ze = Math.min(te / Ve, te / Ne, 1);
|
|
738
|
+
ze < 1 && (M.transformData.width = Ve * ze, M.transformData.height = Ne * ze), M.transformData.cropX = 0, M.transformData.cropY = 0, M.transformData.cropWidth = 1, M.transformData.cropHeight = 1, _(W, M);
|
|
739
|
+
}), Z(W, C), r.setSelectedId(W.id), K && W.loadImage(K), { id: W.id, name: d.name ?? "" };
|
|
752
740
|
}
|
|
753
741
|
let ee;
|
|
754
742
|
const se = {
|
|
@@ -757,14 +745,14 @@ const Xt = Ze("EditorContext"), tt = Q(null), nt = Q(null), on = () => {
|
|
|
757
745
|
wave: "wave",
|
|
758
746
|
arch: "arch",
|
|
759
747
|
shape: "shape"
|
|
760
|
-
}[h] || "custom", Fe =
|
|
748
|
+
}[h] || "custom", Fe = St(se);
|
|
761
749
|
if (!Fe || !Fe.Component)
|
|
762
750
|
throw new Error(`[EditorContext] no transform registered for element type "${h}"`);
|
|
763
|
-
const le = e.getActiveArtboard(),
|
|
751
|
+
const le = e.getActiveArtboard(), it = le ? Math.min(le.width, le.height) * 0.1 : 80, ve = le ? le.width * 0.5 : 300;
|
|
764
752
|
if (h === "shape") {
|
|
765
753
|
const ue = (E == null ? void 0 : E.shapeType) ?? "rectangle";
|
|
766
|
-
let te = 200 / J,
|
|
767
|
-
ue === "ellipse" ? (te = 150 / J,
|
|
754
|
+
let te = 200 / J, K = 200 / J;
|
|
755
|
+
ue === "ellipse" ? (te = 150 / J, K = 250 / J) : ue === "line" && (te = 300 / J, K = 8 / J), ee = new wt({
|
|
768
756
|
id: R,
|
|
769
757
|
name: d.name,
|
|
770
758
|
x: ae,
|
|
@@ -773,7 +761,7 @@ const Xt = Ze("EditorContext"), tt = Q(null), nt = Q(null), on = () => {
|
|
|
773
761
|
type: "shape",
|
|
774
762
|
shapeType: ue,
|
|
775
763
|
width: te,
|
|
776
|
-
height:
|
|
764
|
+
height: K,
|
|
777
765
|
fillColor: "#3b82f6",
|
|
778
766
|
fillOpacity: 1
|
|
779
767
|
}
|
|
@@ -785,18 +773,18 @@ const Xt = Ze("EditorContext"), tt = Q(null), nt = Q(null), on = () => {
|
|
|
785
773
|
text: "New Text",
|
|
786
774
|
x: ae,
|
|
787
775
|
y: re,
|
|
788
|
-
fontSize:
|
|
776
|
+
fontSize: it,
|
|
789
777
|
fontFamily: "Poppins",
|
|
790
|
-
color:
|
|
778
|
+
color: Ut($ == null ? void 0 : $.backgroundColor),
|
|
791
779
|
transformData: se === "arch" ? {
|
|
792
780
|
type: "arch",
|
|
793
781
|
width: ve,
|
|
794
|
-
archHeight:
|
|
782
|
+
archHeight: It.archHeight
|
|
795
783
|
} : se === "wave" ? {
|
|
796
784
|
type: "wave",
|
|
797
785
|
width: ve,
|
|
798
|
-
amplitude:
|
|
799
|
-
frequency:
|
|
786
|
+
amplitude: Le.amplitude,
|
|
787
|
+
frequency: Le.frequency
|
|
800
788
|
} : se === "circle" ? {
|
|
801
789
|
type: "circle",
|
|
802
790
|
radius: ve / 2
|
|
@@ -827,25 +815,25 @@ const Xt = Ze("EditorContext"), tt = Q(null), nt = Q(null), on = () => {
|
|
|
827
815
|
g(h);
|
|
828
816
|
}
|
|
829
817
|
}, [S, r.multiSelection, p]), Re = l(() => {
|
|
830
|
-
if (
|
|
818
|
+
if (F.length === 0) return;
|
|
831
819
|
const d = [], h = 30, E = 30;
|
|
832
|
-
|
|
833
|
-
const R = w.get(C.id),
|
|
820
|
+
F.forEach((C) => {
|
|
821
|
+
const R = w.get(C.id), $ = R ? R.x : C.x, ae = R ? R.y : C.y, re = C.toJSON();
|
|
834
822
|
delete re.id;
|
|
835
823
|
const J = C.constructor, ee = new J(re);
|
|
836
|
-
ee.x =
|
|
824
|
+
ee.x = $ + h, ee.y = ae + E;
|
|
837
825
|
let ie = null;
|
|
838
826
|
if (R && (ie = e.getArtboardIdForElement(
|
|
839
827
|
R.id
|
|
840
828
|
)), ie || (ie = e.getActiveArtboardId()), !ie) {
|
|
841
|
-
|
|
829
|
+
Gt.warn("[handlePasteElements] No artboard found for pasting");
|
|
842
830
|
return;
|
|
843
831
|
}
|
|
844
832
|
const se = R ? R.id : void 0;
|
|
845
833
|
Z(ee, ie, se), d.push(ee.id);
|
|
846
834
|
}), d.length === 1 ? r.handleSelectionChange(d[0]) : d.length > 1 && r.setMultiSelection(d);
|
|
847
835
|
}, [
|
|
848
|
-
|
|
836
|
+
F,
|
|
849
837
|
w,
|
|
850
838
|
e,
|
|
851
839
|
Z,
|
|
@@ -868,7 +856,7 @@ const Xt = Ze("EditorContext"), tt = Q(null), nt = Q(null), on = () => {
|
|
|
868
856
|
Oe(() => {
|
|
869
857
|
const d = (h) => {
|
|
870
858
|
const E = h.target;
|
|
871
|
-
if (E.tagName === "CANVAS" ||
|
|
859
|
+
if (E.tagName === "CANVAS" || Ft(E))
|
|
872
860
|
return;
|
|
873
861
|
const R = document.activeElement;
|
|
874
862
|
if (R != null && R.hasAttribute("data-preserve-selection")) {
|
|
@@ -950,6 +938,7 @@ const Xt = Ze("EditorContext"), tt = Q(null), nt = Q(null), on = () => {
|
|
|
950
938
|
handleLoadWorkspace: Pe,
|
|
951
939
|
handleCopyElements: Ce,
|
|
952
940
|
handlePasteElements: Re,
|
|
941
|
+
hasClipboardContent: F.length > 0,
|
|
953
942
|
// Command history (undo/redo actions + execute functions)
|
|
954
943
|
historyManager: ne,
|
|
955
944
|
executeElementUpdate: _,
|
|
@@ -959,10 +948,10 @@ const Xt = Ze("EditorContext"), tt = Q(null), nt = Q(null), on = () => {
|
|
|
959
948
|
executeCommandBatch: y,
|
|
960
949
|
executeCreateArtboard: x,
|
|
961
950
|
executeDeleteArtboard: T,
|
|
962
|
-
executeUpdateArtboard:
|
|
963
|
-
undo:
|
|
951
|
+
executeUpdateArtboard: k,
|
|
952
|
+
undo: v,
|
|
964
953
|
redo: N,
|
|
965
|
-
canUndo:
|
|
954
|
+
canUndo: z,
|
|
966
955
|
canRedo: U,
|
|
967
956
|
undoActiveArtboard: P,
|
|
968
957
|
redoActiveArtboard: X,
|
|
@@ -1032,6 +1021,7 @@ const Xt = Ze("EditorContext"), tt = Q(null), nt = Q(null), on = () => {
|
|
|
1032
1021
|
Pe,
|
|
1033
1022
|
Ce,
|
|
1034
1023
|
Re,
|
|
1024
|
+
F,
|
|
1035
1025
|
// Command history
|
|
1036
1026
|
ne,
|
|
1037
1027
|
_,
|
|
@@ -1041,10 +1031,10 @@ const Xt = Ze("EditorContext"), tt = Q(null), nt = Q(null), on = () => {
|
|
|
1041
1031
|
y,
|
|
1042
1032
|
x,
|
|
1043
1033
|
T,
|
|
1044
|
-
|
|
1045
|
-
F,
|
|
1046
|
-
N,
|
|
1034
|
+
k,
|
|
1047
1035
|
v,
|
|
1036
|
+
N,
|
|
1037
|
+
z,
|
|
1048
1038
|
U,
|
|
1049
1039
|
P,
|
|
1050
1040
|
X,
|
|
@@ -1061,13 +1051,13 @@ const Xt = Ze("EditorContext"), tt = Q(null), nt = Q(null), on = () => {
|
|
|
1061
1051
|
Ie,
|
|
1062
1052
|
ge
|
|
1063
1053
|
]);
|
|
1064
|
-
return a.current = Ue, /* @__PURE__ */ H(
|
|
1065
|
-
|
|
1054
|
+
return a.current = Ue, /* @__PURE__ */ H(tt.Provider, { value: u, children: /* @__PURE__ */ H(
|
|
1055
|
+
Bt,
|
|
1066
1056
|
{
|
|
1067
1057
|
value: {
|
|
1068
|
-
undo:
|
|
1058
|
+
undo: v,
|
|
1069
1059
|
redo: N,
|
|
1070
|
-
canUndo:
|
|
1060
|
+
canUndo: z,
|
|
1071
1061
|
canRedo: U,
|
|
1072
1062
|
undoActiveArtboard: P,
|
|
1073
1063
|
redoActiveArtboard: X,
|
|
@@ -1075,7 +1065,7 @@ const Xt = Ze("EditorContext"), tt = Q(null), nt = Q(null), on = () => {
|
|
|
1075
1065
|
canRedoActiveArtboard: j
|
|
1076
1066
|
},
|
|
1077
1067
|
children: /* @__PURE__ */ H(
|
|
1078
|
-
|
|
1068
|
+
Wt,
|
|
1079
1069
|
{
|
|
1080
1070
|
value: {
|
|
1081
1071
|
elements: p,
|
|
@@ -1104,7 +1094,7 @@ const Xt = Ze("EditorContext"), tt = Q(null), nt = Q(null), on = () => {
|
|
|
1104
1094
|
canvasEditorRef: n
|
|
1105
1095
|
},
|
|
1106
1096
|
children: /* @__PURE__ */ H(
|
|
1107
|
-
|
|
1097
|
+
Zt,
|
|
1108
1098
|
{
|
|
1109
1099
|
value: {
|
|
1110
1100
|
executeElementUpdate: _,
|
|
@@ -1114,10 +1104,10 @@ const Xt = Ze("EditorContext"), tt = Q(null), nt = Q(null), on = () => {
|
|
|
1114
1104
|
executeCommandBatch: y,
|
|
1115
1105
|
executeCreateArtboard: x,
|
|
1116
1106
|
executeDeleteArtboard: T,
|
|
1117
|
-
executeUpdateArtboard:
|
|
1118
|
-
undo:
|
|
1107
|
+
executeUpdateArtboard: k,
|
|
1108
|
+
undo: v,
|
|
1119
1109
|
redo: N,
|
|
1120
|
-
canUndo:
|
|
1110
|
+
canUndo: z,
|
|
1121
1111
|
canRedo: U,
|
|
1122
1112
|
undoActiveArtboard: P,
|
|
1123
1113
|
redoActiveArtboard: X,
|
|
@@ -1125,37 +1115,37 @@ const Xt = Ze("EditorContext"), tt = Q(null), nt = Q(null), on = () => {
|
|
|
1125
1115
|
canRedoActiveArtboard: j,
|
|
1126
1116
|
historyManager: ne
|
|
1127
1117
|
},
|
|
1128
|
-
children: /* @__PURE__ */ H(
|
|
1118
|
+
children: /* @__PURE__ */ H(et.Provider, { value: Ue, children: t })
|
|
1129
1119
|
}
|
|
1130
1120
|
)
|
|
1131
1121
|
}
|
|
1132
1122
|
)
|
|
1133
1123
|
}
|
|
1134
1124
|
) });
|
|
1135
|
-
},
|
|
1125
|
+
}, on = ({
|
|
1136
1126
|
children: t,
|
|
1137
1127
|
initialArtboardConfig: e = {},
|
|
1138
1128
|
viewPadding: o = 0.9
|
|
1139
1129
|
}) => {
|
|
1140
1130
|
const [n] = b(() => {
|
|
1141
|
-
const i = new
|
|
1131
|
+
const i = new Et(), r = {
|
|
1142
1132
|
name: e.name || "Artboard 1",
|
|
1143
1133
|
x: e.x ?? 0,
|
|
1144
1134
|
y: e.y ?? 0,
|
|
1145
1135
|
width: e.width ?? 1e3,
|
|
1146
1136
|
height: e.height ?? 1e3,
|
|
1147
|
-
backgroundColor: e.backgroundColor ||
|
|
1137
|
+
backgroundColor: e.backgroundColor || yt
|
|
1148
1138
|
};
|
|
1149
1139
|
return i.createArtboard(r), i;
|
|
1150
1140
|
}), a = me(null), u = me(null);
|
|
1151
1141
|
return /* @__PURE__ */ H(
|
|
1152
|
-
|
|
1142
|
+
Nt,
|
|
1153
1143
|
{
|
|
1154
1144
|
artboardManager: n,
|
|
1155
1145
|
canvasRef: a,
|
|
1156
1146
|
viewPadding: o,
|
|
1157
|
-
children: /* @__PURE__ */ H(
|
|
1158
|
-
|
|
1147
|
+
children: /* @__PURE__ */ H(Lt, { children: /* @__PURE__ */ H(kt, { children: /* @__PURE__ */ H(
|
|
1148
|
+
Xt,
|
|
1159
1149
|
{
|
|
1160
1150
|
artboardManager: n,
|
|
1161
1151
|
canvasRef: a,
|
|
@@ -1165,24 +1155,24 @@ const Xt = Ze("EditorContext"), tt = Q(null), nt = Q(null), on = () => {
|
|
|
1165
1155
|
) }) })
|
|
1166
1156
|
}
|
|
1167
1157
|
);
|
|
1168
|
-
},
|
|
1169
|
-
const t = G(
|
|
1158
|
+
}, rn = () => {
|
|
1159
|
+
const t = G(et);
|
|
1170
1160
|
if (!t)
|
|
1171
1161
|
throw new Error("useEditor must be used within EditorProvider");
|
|
1172
1162
|
return t;
|
|
1173
1163
|
}, de = [];
|
|
1174
|
-
function
|
|
1175
|
-
|
|
1164
|
+
function sn(t) {
|
|
1165
|
+
Tt() && de.push(t);
|
|
1176
1166
|
}
|
|
1177
|
-
function
|
|
1167
|
+
function cn() {
|
|
1178
1168
|
return [...de];
|
|
1179
1169
|
}
|
|
1180
|
-
function
|
|
1170
|
+
function dn() {
|
|
1181
1171
|
de.length = 0;
|
|
1182
1172
|
}
|
|
1183
|
-
function
|
|
1173
|
+
function an() {
|
|
1184
1174
|
if (de.length === 0) return;
|
|
1185
|
-
const t = de.map((e) =>
|
|
1175
|
+
const t = de.map((e) => gt(e) ? `${e.code}: ${e.message}` : `${e.name}: ${e.message}`).join(`
|
|
1186
1176
|
- `);
|
|
1187
1177
|
throw de.length = 0, new Error(
|
|
1188
1178
|
`expectNoEditorErrors: ${t.includes(`
|
|
@@ -1193,27 +1183,24 @@ A contained error renders an error card in prod — this composition is broken e
|
|
|
1193
1183
|
}
|
|
1194
1184
|
export {
|
|
1195
1185
|
Ge as B,
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
cn as r,
|
|
1216
|
-
vt as s,
|
|
1217
|
-
sn as u
|
|
1186
|
+
on as E,
|
|
1187
|
+
Xe as P,
|
|
1188
|
+
Dt as a,
|
|
1189
|
+
tn as b,
|
|
1190
|
+
en as c,
|
|
1191
|
+
Qt as d,
|
|
1192
|
+
_t as e,
|
|
1193
|
+
$t as f,
|
|
1194
|
+
Kt as g,
|
|
1195
|
+
nn as h,
|
|
1196
|
+
an as i,
|
|
1197
|
+
cn as j,
|
|
1198
|
+
dn as k,
|
|
1199
|
+
vt as l,
|
|
1200
|
+
qt as m,
|
|
1201
|
+
Mt as p,
|
|
1202
|
+
sn as r,
|
|
1203
|
+
Ft as s,
|
|
1204
|
+
rn as u
|
|
1218
1205
|
};
|
|
1219
|
-
//# sourceMappingURL=editorErrors-
|
|
1206
|
+
//# sourceMappingURL=editorErrors-WzaNxU1Y.js.map
|