eddyter 1.4.15 → 1.4.16
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/{CommentBubblePlugin-VCZgBJUi.js → CommentBubblePlugin-DZQW1ibY.js} +1 -1
- package/dist/{LazySignatureCanvas-RMigH9yY.js → LazySignatureCanvas-FKl1mD-T.js} +1 -1
- package/dist/assets/style.css +1 -1
- package/dist/components/NotePanelView/NotePanelView.d.ts +2 -1
- package/dist/{generateDocxThumbnail-fv5LNJIq.js → generateDocxThumbnail-DJlPLsdY.js} +1 -1
- package/dist/{generatePdfThumbnail-C0rDYo5e.js → generatePdfThumbnail-CfDAh39b.js} +1 -1
- package/dist/{generateXlsxThumbnail-C_vobxPD.js → generateXlsxThumbnail-cRIT4Jyf.js} +1 -1
- package/dist/{html2pdf.bundle.min-CFWvTTWI.js → html2pdf.bundle.min-BW3dolOS.js} +1 -1
- package/dist/{index-D5W6pnOr.js → index-BDDjWwK4.js} +8698 -8372
- package/dist/{index-Dhc1wcFH.js → index-BEepnYCf.js} +34 -33
- package/dist/index-BmfQcIrc.js +1429 -0
- package/dist/{index-o_C9Vw0n.js → index-BydXFu_2.js} +1 -1
- package/dist/{index-MXcGtHZr.js → index-W6_ogglw.js} +11 -11
- package/dist/{index-DKRhyxUF.js → index-gjz4wieB.js} +11 -11
- package/dist/index.js +1 -1
- package/dist/nodes/NotePanelNode.d.ts +7 -2
- package/dist/utils/notePanelExport.d.ts +11 -0
- package/dist/utils/notePanelPaste.d.ts +7 -0
- package/package.json +1 -1
- package/dist/index-Ct2Ouofi.js +0 -1613
|
@@ -0,0 +1,1429 @@
|
|
|
1
|
+
import { jsx as e, jsxs as h, Fragment as Kt } from "react/jsx-runtime";
|
|
2
|
+
import { I as Me } from "./ImageResizer-BVwxL4Eh.js";
|
|
3
|
+
import { CodeNode as Le } from "@lexical/code";
|
|
4
|
+
import { LinkNode as Ae } from "@lexical/link";
|
|
5
|
+
import { AutoFocusPlugin as De } from "@lexical/react/LexicalAutoFocusPlugin";
|
|
6
|
+
import { useCollaborationContext as ze } from "@lexical/react/LexicalCollaborationContext";
|
|
7
|
+
import { useLexicalComposerContext as $e } from "@lexical/react/LexicalComposerContext";
|
|
8
|
+
import { ContentEditable as We } from "@lexical/react/LexicalContentEditable";
|
|
9
|
+
import { LexicalErrorBoundary as Oe } from "@lexical/react/LexicalErrorBoundary";
|
|
10
|
+
import { HistoryPlugin as Te } from "@lexical/react/LexicalHistoryPlugin";
|
|
11
|
+
import { LexicalNestedComposer as _e } from "@lexical/react/LexicalNestedComposer";
|
|
12
|
+
import { OnChangePlugin as je } from "@lexical/react/LexicalOnChangePlugin";
|
|
13
|
+
import { RichTextPlugin as He } from "@lexical/react/LexicalRichTextPlugin";
|
|
14
|
+
import { useLexicalEditable as Fe } from "@lexical/react/useLexicalEditable";
|
|
15
|
+
import { useLexicalNodeSelection as Ye } from "@lexical/react/useLexicalNodeSelection";
|
|
16
|
+
import { mergeRegister as Xe } from "@lexical/utils";
|
|
17
|
+
import { $getRoot as qt, $isNodeSelection as st, $getSelection as tt, $isParagraphNode as _t, $setSelection as pt, $isRangeSelection as Be, SELECTION_CHANGE_COMMAND as Ue, COMMAND_PRIORITY_LOW as et, CLICK_COMMAND as Ge, DRAGSTART_COMMAND as Ke, KEY_DELETE_COMMAND as qe, KEY_BACKSPACE_COMMAND as Ve, KEY_ENTER_COMMAND as Je, KEY_ESCAPE_COMMAND as Qe, $getNodeByKey as rt, RootNode as Ze, TextNode as tr, LineBreakNode as er, ParagraphNode as rr, createCommand as or } from "lexical";
|
|
18
|
+
import { useState as C, useEffect as B, useRef as X, useMemo as Vt, useCallback as R, useLayoutEffect as Jt, Suspense as ir } from "react";
|
|
19
|
+
import { c as Rt, o as oe, p as ie, q as ne, r as ce, s as ae, t as de, B as Qt, v as Pt, w as k, I as nr, S as cr, x as ar, y as V, z as dr, G as sr, H as lr, W as ur, b as mr, A as gr, d as hr, e as fr, J as pr, L as br, K as wr, M as xr, N as yr, X as Cr, O as vr, P as Nr, Q as Rr, R as kr, U as Ir } from "./index-BDDjWwK4.js";
|
|
20
|
+
const se = Rt("Crop", [
|
|
21
|
+
["path", { d: "M6 2v14a2 2 0 0 0 2 2h14", key: "ron5a4" }],
|
|
22
|
+
["path", { d: "M18 22V8a2 2 0 0 0-2-2H2", key: "7s9ehn" }]
|
|
23
|
+
]);
|
|
24
|
+
const Er = Rt("Link2", [
|
|
25
|
+
["path", { d: "M9 17H7A5 5 0 0 1 7 7h2", key: "8i5ue5" }],
|
|
26
|
+
["path", { d: "M15 7h2a5 5 0 1 1 0 10h-2", key: "1b9ql8" }],
|
|
27
|
+
["line", { x1: "8", x2: "16", y1: "12", y2: "12", key: "1jonct" }]
|
|
28
|
+
]);
|
|
29
|
+
const Zt = Rt("RectangleHorizontal", [
|
|
30
|
+
["rect", { width: "20", height: "12", x: "2", y: "6", rx: "2", key: "9lu3g6" }]
|
|
31
|
+
]);
|
|
32
|
+
const te = Rt("RectangleVertical", [
|
|
33
|
+
["rect", { width: "12", height: "20", x: "6", y: "2", rx: "2", key: "1oxtiu" }]
|
|
34
|
+
]);
|
|
35
|
+
const Pr = Rt("RotateCcw", [
|
|
36
|
+
["path", { d: "M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8", key: "1357e3" }],
|
|
37
|
+
["path", { d: "M3 3v5h5", key: "1xhq8a" }]
|
|
38
|
+
]), Sr = ({
|
|
39
|
+
open: o,
|
|
40
|
+
onOpenChange: c,
|
|
41
|
+
oldImageUrl: s,
|
|
42
|
+
newImageUrl: f,
|
|
43
|
+
onReplace: y,
|
|
44
|
+
onCancel: N
|
|
45
|
+
}) => /* @__PURE__ */ e(oe, { open: o, onOpenChange: c, children: /* @__PURE__ */ h(ie, { className: "sm:max-w-[800px] max-h-[90vh] overflow-y-auto", children: [
|
|
46
|
+
/* @__PURE__ */ h(ne, { children: [
|
|
47
|
+
/* @__PURE__ */ h(ce, { className: "flex items-center gap-2 text-xl", children: [
|
|
48
|
+
/* @__PURE__ */ e("span", { className: "text-2xl", children: "🔄" }),
|
|
49
|
+
"Compare Images"
|
|
50
|
+
] }),
|
|
51
|
+
/* @__PURE__ */ e(ae, { className: "text-sm pt-1", children: "Choose whether to replace the original image with the refined version." })
|
|
52
|
+
] }),
|
|
53
|
+
/* @__PURE__ */ h("div", { className: "space-y-4 py-4", children: [
|
|
54
|
+
/* @__PURE__ */ e("div", { className: "grid grid-cols-2 gap-4", children: /* @__PURE__ */ h("div", { className: "space-y-2", children: [
|
|
55
|
+
/* @__PURE__ */ h("div", { className: "flex items-center justify-between", children: [
|
|
56
|
+
/* @__PURE__ */ e("span", { className: "text-sm font-semibold text-gray-700 dark:text-gray-300", children: "Refined Image" }),
|
|
57
|
+
/* @__PURE__ */ e("span", { className: "text-xs px-2 py-1 rounded-full bg-blue-100 dark:bg-blue-950/30 text-blue-600 dark:text-blue-400", children: "New" })
|
|
58
|
+
] }),
|
|
59
|
+
/* @__PURE__ */ e("div", { className: "relative aspect-square rounded-lg overflow-hidden bg-gray-100 dark:bg-gray-800 border-2 border-blue-500 dark:border-blue-600", children: /* @__PURE__ */ e(
|
|
60
|
+
"img",
|
|
61
|
+
{
|
|
62
|
+
src: f,
|
|
63
|
+
alt: "Refined",
|
|
64
|
+
className: "w-full h-full object-contain"
|
|
65
|
+
}
|
|
66
|
+
) })
|
|
67
|
+
] }) }),
|
|
68
|
+
/* @__PURE__ */ e("div", { className: "p-3 rounded-lg bg-blue-50 dark:bg-blue-950/20 border border-blue-200 dark:border-blue-800", children: /* @__PURE__ */ h("p", { className: "text-sm text-blue-800 dark:text-blue-200", children: [
|
|
69
|
+
/* @__PURE__ */ e("span", { className: "font-semibold", children: "Note:" }),
|
|
70
|
+
' Clicking "Replace" will update the image in your document. This action cannot be undone.'
|
|
71
|
+
] }) })
|
|
72
|
+
] }),
|
|
73
|
+
/* @__PURE__ */ h(de, { className: "gap-2", children: [
|
|
74
|
+
/* @__PURE__ */ e(
|
|
75
|
+
Qt,
|
|
76
|
+
{
|
|
77
|
+
variant: "outline",
|
|
78
|
+
onClick: N,
|
|
79
|
+
children: "Keep Original"
|
|
80
|
+
}
|
|
81
|
+
),
|
|
82
|
+
/* @__PURE__ */ h(
|
|
83
|
+
Qt,
|
|
84
|
+
{
|
|
85
|
+
onClick: y,
|
|
86
|
+
className: "bg-blue-500 hover:bg-blue-600 text-white",
|
|
87
|
+
children: [
|
|
88
|
+
/* @__PURE__ */ e("span", { className: "mr-2", children: "✓" }),
|
|
89
|
+
"Replace Image"
|
|
90
|
+
]
|
|
91
|
+
}
|
|
92
|
+
)
|
|
93
|
+
] })
|
|
94
|
+
] }) });
|
|
95
|
+
function Mr({
|
|
96
|
+
caption: o
|
|
97
|
+
}) {
|
|
98
|
+
const [c, s] = C(""), [f, y] = C("");
|
|
99
|
+
return B(() => ((() => {
|
|
100
|
+
const E = o.getEditorState().read(() => qt().getTextContent()).split(" • ");
|
|
101
|
+
s(E[0] || ""), y(E[1] || "");
|
|
102
|
+
})(), o.registerUpdateListener(({ editorState: $ }) => {
|
|
103
|
+
const M = $.read(() => qt().getTextContent()).split(" • ");
|
|
104
|
+
s(M[0] || ""), y(M[1] || "");
|
|
105
|
+
})), [o]), /* @__PURE__ */ e("div", { className: "signature-caption-container", children: /* @__PURE__ */ h("div", { className: "signature-caption-info", children: [
|
|
106
|
+
c && /* @__PURE__ */ e("span", { className: "signature-user-name", children: c }),
|
|
107
|
+
c && f && /* @__PURE__ */ e("span", { className: "signature-separator" }),
|
|
108
|
+
f && /* @__PURE__ */ e("span", { className: "signature-timestamp", children: f }),
|
|
109
|
+
!c && !f && /* @__PURE__ */ e("span", { children: "Signature" })
|
|
110
|
+
] }) });
|
|
111
|
+
}
|
|
112
|
+
const Lr = "/transform-image/";
|
|
113
|
+
function lt(o) {
|
|
114
|
+
if (!Pt || o.startsWith("data:") || o.toLowerCase().endsWith(".svg")) return !1;
|
|
115
|
+
try {
|
|
116
|
+
const c = new URL(o).origin, s = new URL(Pt).origin;
|
|
117
|
+
return c === s;
|
|
118
|
+
} catch {
|
|
119
|
+
return !1;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
function le(o) {
|
|
123
|
+
if (!lt(o)) return null;
|
|
124
|
+
try {
|
|
125
|
+
const s = new URL(o).pathname.replace(/^\//, ""), f = "transform-image/";
|
|
126
|
+
return s.startsWith(f) ? s.slice(f.length) || null : s || null;
|
|
127
|
+
} catch {
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
function Ar(o, c) {
|
|
132
|
+
if (!lt(o)) return o;
|
|
133
|
+
const s = le(o);
|
|
134
|
+
if (!s) return o;
|
|
135
|
+
const f = `${c.x},${c.y},${c.width},${c.height}`;
|
|
136
|
+
return `${Pt.replace(/\/$/, "")}${Lr}${s}?crop=${f}`;
|
|
137
|
+
}
|
|
138
|
+
function ee(o) {
|
|
139
|
+
if (!lt(o)) return o;
|
|
140
|
+
try {
|
|
141
|
+
const c = new URL(o);
|
|
142
|
+
return c.searchParams.delete("crop"), c.toString();
|
|
143
|
+
} catch {
|
|
144
|
+
return o;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
function vt(o) {
|
|
148
|
+
if (!lt(o)) return ee(o);
|
|
149
|
+
const c = le(o);
|
|
150
|
+
return c ? `${Pt.replace(/\/$/, "")}/${c}` : ee(o);
|
|
151
|
+
}
|
|
152
|
+
function Dr({
|
|
153
|
+
open: o,
|
|
154
|
+
onOpenChange: c,
|
|
155
|
+
src: s,
|
|
156
|
+
altText: f,
|
|
157
|
+
width: y,
|
|
158
|
+
height: N,
|
|
159
|
+
onCropApply: $
|
|
160
|
+
}) {
|
|
161
|
+
const [E, M] = C("freeform"), [ot, W] = C(s), [w, I] = C(!1), x = X(null), J = X(null), [i, D] = C({ x: 0, y: 0, width: 0, height: 0 }), [v, L] = C({ x: 0, y: 0, width: 0, height: 0 }), it = X(null), ut = Vt(() => typeof y == "number" && typeof N == "number" && N > 0 ? y / N : i.width > 0 && i.height > 0 ? i.width / i.height : null, [i.height, i.width, N, y]), bt = Vt(() => {
|
|
162
|
+
switch (E) {
|
|
163
|
+
case "original":
|
|
164
|
+
return ut;
|
|
165
|
+
case "1:1":
|
|
166
|
+
return 1;
|
|
167
|
+
case "4:3":
|
|
168
|
+
return 4 / 3;
|
|
169
|
+
case "16:9":
|
|
170
|
+
return 16 / 9;
|
|
171
|
+
case "3:4":
|
|
172
|
+
return 3 / 4;
|
|
173
|
+
case "9:16":
|
|
174
|
+
return 9 / 16;
|
|
175
|
+
default:
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
178
|
+
}, [ut, E]), d = 24, z = R(
|
|
179
|
+
(n) => {
|
|
180
|
+
let { x: g, y: p, width: u, height: b } = n;
|
|
181
|
+
const j = i.width, mt = i.height;
|
|
182
|
+
return g = Math.max(0, Math.min(g, j - d)), p = Math.max(0, Math.min(p, mt - d)), u = Math.max(d, Math.min(u, j - g)), b = Math.max(d, Math.min(b, mt - p)), { x: g, y: p, width: u, height: b };
|
|
183
|
+
},
|
|
184
|
+
[i.height, i.width]
|
|
185
|
+
), wt = R(
|
|
186
|
+
(n) => {
|
|
187
|
+
if (i.width <= 0 || i.height <= 0) return;
|
|
188
|
+
if (n == null) {
|
|
189
|
+
L({
|
|
190
|
+
x: 0,
|
|
191
|
+
y: 0,
|
|
192
|
+
width: i.width,
|
|
193
|
+
height: i.height
|
|
194
|
+
});
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
const g = i.width * 0.9, p = i.height * 0.9;
|
|
198
|
+
let u = g, b = u / n;
|
|
199
|
+
b > p && (b = p, u = b * n), L(
|
|
200
|
+
z({
|
|
201
|
+
x: (i.width - u) / 2,
|
|
202
|
+
y: (i.height - b) / 2,
|
|
203
|
+
width: u,
|
|
204
|
+
height: b
|
|
205
|
+
})
|
|
206
|
+
);
|
|
207
|
+
},
|
|
208
|
+
[i.height, i.width, z]
|
|
209
|
+
), nt = R(() => {
|
|
210
|
+
const n = x.current, g = J.current;
|
|
211
|
+
if (!n || !g) return;
|
|
212
|
+
let p = 0, u = 0, b = g;
|
|
213
|
+
for (; b && b !== n; )
|
|
214
|
+
p += b.offsetLeft, u += b.offsetTop, b = b.offsetParent;
|
|
215
|
+
D({
|
|
216
|
+
x: p,
|
|
217
|
+
y: u,
|
|
218
|
+
width: g.offsetWidth,
|
|
219
|
+
height: g.offsetHeight
|
|
220
|
+
});
|
|
221
|
+
}, []), U = R(
|
|
222
|
+
(n) => {
|
|
223
|
+
i.width <= 0 || i.height <= 0 || (n.preventDefault(), n.stopPropagation(), n.target.setPointerCapture?.(n.pointerId), it.current = {
|
|
224
|
+
mode: "move",
|
|
225
|
+
startX: n.clientX,
|
|
226
|
+
startY: n.clientY,
|
|
227
|
+
initialRect: { ...v }
|
|
228
|
+
});
|
|
229
|
+
},
|
|
230
|
+
[i.height, i.width, v]
|
|
231
|
+
), xt = R(
|
|
232
|
+
(n, g) => {
|
|
233
|
+
i.width <= 0 || i.height <= 0 || (n.preventDefault(), n.stopPropagation(), n.target.setPointerCapture?.(n.pointerId), it.current = {
|
|
234
|
+
mode: g,
|
|
235
|
+
startX: n.clientX,
|
|
236
|
+
startY: n.clientY,
|
|
237
|
+
initialRect: { ...v }
|
|
238
|
+
});
|
|
239
|
+
},
|
|
240
|
+
[i.height, i.width, v]
|
|
241
|
+
), St = R(async () => {
|
|
242
|
+
if (i.width <= 0 || i.height <= 0) {
|
|
243
|
+
c(!1);
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
const n = J.current;
|
|
247
|
+
if (!n || !n.naturalWidth || !n.naturalHeight) {
|
|
248
|
+
k.error("Could not read image dimensions");
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
const g = n.naturalWidth / i.width, p = n.naturalHeight / i.height, u = {
|
|
252
|
+
x: Math.max(0, Math.round(v.x * g)),
|
|
253
|
+
y: Math.max(0, Math.round(v.y * p)),
|
|
254
|
+
width: Math.max(1, Math.round(v.width * g)),
|
|
255
|
+
height: Math.max(1, Math.round(v.height * p)),
|
|
256
|
+
naturalWidth: n.naturalWidth,
|
|
257
|
+
naturalHeight: n.naturalHeight
|
|
258
|
+
};
|
|
259
|
+
u.width = Math.min(u.width, n.naturalWidth - u.x), u.height = Math.min(u.height, n.naturalHeight - u.y), c(!1), Promise.resolve($(u));
|
|
260
|
+
}, [i, v, $, c]);
|
|
261
|
+
return B(() => {
|
|
262
|
+
o && (D({ x: 0, y: 0, width: 0, height: 0 }), L({ x: 0, y: 0, width: 0, height: 0 }), I(!1), W(vt(s)));
|
|
263
|
+
}, [o, s]), B(() => {
|
|
264
|
+
if (!o) return;
|
|
265
|
+
const n = x.current;
|
|
266
|
+
if (!n) return;
|
|
267
|
+
const g = new ResizeObserver(() => {
|
|
268
|
+
nt();
|
|
269
|
+
});
|
|
270
|
+
g.observe(n);
|
|
271
|
+
const p = J.current;
|
|
272
|
+
p && g.observe(p);
|
|
273
|
+
const u = () => nt();
|
|
274
|
+
return window.addEventListener("resize", u), () => {
|
|
275
|
+
g.disconnect(), window.removeEventListener("resize", u);
|
|
276
|
+
};
|
|
277
|
+
}, [o, nt]), B(() => {
|
|
278
|
+
if (!o) return;
|
|
279
|
+
const n = (p) => {
|
|
280
|
+
const u = it.current;
|
|
281
|
+
if (!u) return;
|
|
282
|
+
p.preventDefault();
|
|
283
|
+
const b = p.clientX - u.startX, j = p.clientY - u.startY, mt = i.width, gt = i.height, Q = bt ?? null, { x: G, y: ct, width: O, height: K } = u.initialRect;
|
|
284
|
+
if (u.mode === "move") {
|
|
285
|
+
const ht = Math.max(0, mt - O), kt = Math.max(0, gt - K);
|
|
286
|
+
L(
|
|
287
|
+
z({
|
|
288
|
+
x: Math.max(0, Math.min(ht, G + b)),
|
|
289
|
+
y: Math.max(0, Math.min(kt, ct + j)),
|
|
290
|
+
width: O,
|
|
291
|
+
height: K
|
|
292
|
+
})
|
|
293
|
+
);
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
const S = u.mode;
|
|
297
|
+
let T = G, Z = ct, H = O, F = K;
|
|
298
|
+
S.includes("e") && (H = O + b), S.includes("w") && (T = G + b, H = O - b), S.includes("s") && (F = K + j), S.includes("n") && (Z = ct + j, F = K - j), Q != null && Q > 0 && (S === "e" || S === "w" ? (F = H / Q, S.includes("n") && (Z = ct + K - F)) : S === "n" || S === "s" ? (H = F * Q, S.includes("w") && (T = G + O - H)) : (F = H / Q, S.includes("n") && (Z = ct + K - F), S.includes("w") && (T = G + O - H))), L(z({ x: T, y: Z, width: H, height: F }));
|
|
299
|
+
}, g = () => {
|
|
300
|
+
it.current = null;
|
|
301
|
+
};
|
|
302
|
+
return window.addEventListener("pointermove", n), window.addEventListener("pointerup", g), () => {
|
|
303
|
+
window.removeEventListener("pointermove", n), window.removeEventListener("pointerup", g);
|
|
304
|
+
};
|
|
305
|
+
}, [
|
|
306
|
+
o,
|
|
307
|
+
i.width,
|
|
308
|
+
i.height,
|
|
309
|
+
bt,
|
|
310
|
+
z
|
|
311
|
+
]), B(() => {
|
|
312
|
+
o && wt(bt);
|
|
313
|
+
}, [o, bt, i, wt]), /* @__PURE__ */ e(oe, { open: o, onOpenChange: c, children: /* @__PURE__ */ e(
|
|
314
|
+
ie,
|
|
315
|
+
{
|
|
316
|
+
className: "sm:cteditor-max-w-[860px] cteditor-max-w-[calc(100%-2rem)] cteditor-rounded-xl cteditor-overflow-hidden cteditor-p-0",
|
|
317
|
+
onClick: (n) => n.stopPropagation(),
|
|
318
|
+
onPointerDown: (n) => n.stopPropagation(),
|
|
319
|
+
children: /* @__PURE__ */ h("div", { className: "cteditor-grid md:cteditor-grid-cols-[1.4fr_320px]", children: [
|
|
320
|
+
/* @__PURE__ */ e("div", { className: "cteditor-bg-muted/20 cteditor-p-4 md:cteditor-p-6", children: /* @__PURE__ */ h(
|
|
321
|
+
"div",
|
|
322
|
+
{
|
|
323
|
+
ref: x,
|
|
324
|
+
className: "cteditor-relative cteditor-min-h-[340px] cteditor-rounded-lg cteditor-bg-black/70 cteditor-flex cteditor-items-center cteditor-justify-center cteditor-select-none cteditor-touch-none",
|
|
325
|
+
children: [
|
|
326
|
+
/* @__PURE__ */ e("div", { className: "cteditor-overflow-hidden cteditor-rounded-lg cteditor-flex cteditor-items-center cteditor-justify-center cteditor-w-full", children: w ? /* @__PURE__ */ e("div", { className: "cteditor-text-sm cteditor-text-muted-foreground", children: "Failed to load image preview" }) : /* @__PURE__ */ e(
|
|
327
|
+
"img",
|
|
328
|
+
{
|
|
329
|
+
ref: J,
|
|
330
|
+
src: ot,
|
|
331
|
+
alt: f || "Crop preview",
|
|
332
|
+
className: "cteditor-max-w-full cteditor-max-h-[460px] cteditor-w-auto cteditor-h-auto cteditor-select-none cteditor-block",
|
|
333
|
+
draggable: !1,
|
|
334
|
+
onLoad: () => {
|
|
335
|
+
I(!1), nt();
|
|
336
|
+
},
|
|
337
|
+
onError: () => {
|
|
338
|
+
I(!0);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
) }),
|
|
342
|
+
i.width > 0 && i.height > 0 && !w && /* @__PURE__ */ h(
|
|
343
|
+
"div",
|
|
344
|
+
{
|
|
345
|
+
className: "cteditor-absolute cteditor-border-2 cteditor-border-blue-500 cteditor-cursor-move cteditor-select-none",
|
|
346
|
+
style: {
|
|
347
|
+
left: i.x + v.x,
|
|
348
|
+
top: i.y + v.y,
|
|
349
|
+
width: v.width,
|
|
350
|
+
height: v.height
|
|
351
|
+
},
|
|
352
|
+
children: [
|
|
353
|
+
/* @__PURE__ */ e(
|
|
354
|
+
"div",
|
|
355
|
+
{
|
|
356
|
+
className: "cteditor-absolute cteditor-inset-0 cteditor-grid cteditor-grid-cols-3 cteditor-grid-rows-3 cteditor-pointer-events-none",
|
|
357
|
+
"aria-hidden": !0,
|
|
358
|
+
children: Array.from({ length: 9 }).map((n, g) => /* @__PURE__ */ e(
|
|
359
|
+
"div",
|
|
360
|
+
{
|
|
361
|
+
className: "cteditor-border cteditor-border-white/30"
|
|
362
|
+
},
|
|
363
|
+
g
|
|
364
|
+
))
|
|
365
|
+
}
|
|
366
|
+
),
|
|
367
|
+
/* @__PURE__ */ e(
|
|
368
|
+
"div",
|
|
369
|
+
{
|
|
370
|
+
className: "cteditor-absolute cteditor-inset-0 cteditor-pointer-events-auto",
|
|
371
|
+
onPointerDown: U,
|
|
372
|
+
"aria-label": "Move crop area"
|
|
373
|
+
}
|
|
374
|
+
),
|
|
375
|
+
[
|
|
376
|
+
["n", "cteditor-top-0 cteditor-left-1/2 cteditor--translate-x-1/2 cteditor--translate-y-1/2", "cteditor-cursor-n-resize", "cteditor-w-8 cteditor-h-2"],
|
|
377
|
+
["s", "cteditor-bottom-0 cteditor-left-1/2 cteditor--translate-x-1/2 cteditor-translate-y-1/2", "cteditor-cursor-s-resize", "cteditor-w-8 cteditor-h-2"],
|
|
378
|
+
["e", "cteditor-right-0 cteditor-top-1/2 cteditor-translate-x-1/2 cteditor--translate-y-1/2", "cteditor-cursor-e-resize", "cteditor-w-2 cteditor-h-8"],
|
|
379
|
+
["w", "cteditor-left-0 cteditor-top-1/2 cteditor--translate-x-1/2 cteditor--translate-y-1/2", "cteditor-cursor-w-resize", "cteditor-w-2 cteditor-h-8"],
|
|
380
|
+
["nw", "cteditor-left-0 cteditor-top-0 cteditor--translate-x-1/2 cteditor--translate-y-1/2", "cteditor-cursor-nw-resize", "cteditor-size-4"],
|
|
381
|
+
["ne", "cteditor-right-0 cteditor-top-0 cteditor-translate-x-1/2 cteditor--translate-y-1/2", "cteditor-cursor-ne-resize", "cteditor-size-4"],
|
|
382
|
+
["sw", "cteditor-left-0 cteditor-bottom-0 cteditor--translate-x-1/2 cteditor-translate-y-1/2", "cteditor-cursor-sw-resize", "cteditor-size-4"],
|
|
383
|
+
["se", "cteditor-right-0 cteditor-bottom-0 cteditor-translate-x-1/2 cteditor-translate-y-1/2", "cteditor-cursor-se-resize", "cteditor-size-4"]
|
|
384
|
+
].map(([n, g, p, u]) => /* @__PURE__ */ e(
|
|
385
|
+
"div",
|
|
386
|
+
{
|
|
387
|
+
className: `cteditor-absolute cteditor-border-2 cteditor-border-white cteditor-bg-blue-500 cteditor-rounded-sm cteditor-pointer-events-auto cteditor-shadow ${g} ${p} ${u}`,
|
|
388
|
+
onPointerDown: (b) => xt(b, n),
|
|
389
|
+
"aria-label": `Resize ${n}`
|
|
390
|
+
},
|
|
391
|
+
n
|
|
392
|
+
))
|
|
393
|
+
]
|
|
394
|
+
}
|
|
395
|
+
)
|
|
396
|
+
]
|
|
397
|
+
}
|
|
398
|
+
) }),
|
|
399
|
+
/* @__PURE__ */ h("div", { className: "cteditor-p-4 md:cteditor-p-5 cteditor-border-l cteditor-border-border cteditor-bg-background", children: [
|
|
400
|
+
/* @__PURE__ */ h(ne, { className: "cteditor-mb-4 cteditor-space-y-1", children: [
|
|
401
|
+
/* @__PURE__ */ e(ce, { children: "Crop" }),
|
|
402
|
+
/* @__PURE__ */ e(ae, { children: "Choose an aspect ratio and adjust the crop area, then click Apply." })
|
|
403
|
+
] }),
|
|
404
|
+
/* @__PURE__ */ h("div", { className: "cteditor-space-y-4", children: [
|
|
405
|
+
/* @__PURE__ */ h("div", { children: [
|
|
406
|
+
/* @__PURE__ */ e("p", { className: "cteditor-text-sm cteditor-font-medium cteditor-mb-2", children: "Aspect ratio" }),
|
|
407
|
+
/* @__PURE__ */ e("div", { className: "cteditor-grid cteditor-grid-cols-3 cteditor-gap-2", children: [
|
|
408
|
+
{ id: "freeform", label: "Freeform", icon: se },
|
|
409
|
+
{ id: "original", label: "Original", icon: nr },
|
|
410
|
+
{ id: "1:1", label: "1:1", icon: cr },
|
|
411
|
+
{ id: "4:3", label: "4:3", icon: Zt },
|
|
412
|
+
{ id: "16:9", label: "16:9", icon: Zt },
|
|
413
|
+
{ id: "3:4", label: "3:4", icon: te },
|
|
414
|
+
{ id: "9:16", label: "9:16", icon: te }
|
|
415
|
+
].map((n) => {
|
|
416
|
+
const g = n.icon, p = E === n.id;
|
|
417
|
+
return /* @__PURE__ */ h(
|
|
418
|
+
"button",
|
|
419
|
+
{
|
|
420
|
+
type: "button",
|
|
421
|
+
onClick: () => {
|
|
422
|
+
M(n.id);
|
|
423
|
+
},
|
|
424
|
+
className: `cteditor-h-20 cteditor-rounded-md cteditor-border cteditor-text-sm cteditor-transition-colors cteditor-flex cteditor-flex-col cteditor-items-center cteditor-justify-center cteditor-gap-1.5 ${p ? "cteditor-border-primary cteditor-bg-primary/10 cteditor-text-primary" : "cteditor-border-border hover:cteditor-bg-accent"}`,
|
|
425
|
+
children: [
|
|
426
|
+
/* @__PURE__ */ e(g, { className: "cteditor-w-4 cteditor-h-4" }),
|
|
427
|
+
/* @__PURE__ */ e("span", { children: n.label })
|
|
428
|
+
]
|
|
429
|
+
},
|
|
430
|
+
n.id
|
|
431
|
+
);
|
|
432
|
+
}) })
|
|
433
|
+
] }),
|
|
434
|
+
/* @__PURE__ */ h("div", { className: "cteditor-rounded-md cteditor-border cteditor-border-border cteditor-p-3 cteditor-bg-muted/20 cteditor-space-y-2", children: [
|
|
435
|
+
/* @__PURE__ */ h("div", { children: [
|
|
436
|
+
/* @__PURE__ */ e("p", { className: "cteditor-text-xs cteditor-text-muted-foreground cteditor-mb-0.5", children: "Crop size" }),
|
|
437
|
+
/* @__PURE__ */ h("p", { className: "cteditor-text-sm cteditor-font-medium", children: [
|
|
438
|
+
Math.round(v.width),
|
|
439
|
+
" × ",
|
|
440
|
+
Math.round(v.height),
|
|
441
|
+
" px"
|
|
442
|
+
] })
|
|
443
|
+
] }),
|
|
444
|
+
/* @__PURE__ */ h("div", { children: [
|
|
445
|
+
/* @__PURE__ */ e("p", { className: "cteditor-text-xs cteditor-text-muted-foreground cteditor-mb-0.5", children: "Aspect ratio" }),
|
|
446
|
+
/* @__PURE__ */ e("p", { className: "cteditor-text-sm", children: E === "freeform" ? "Free" : E === "original" ? "Original" : E })
|
|
447
|
+
] })
|
|
448
|
+
] })
|
|
449
|
+
] }),
|
|
450
|
+
/* @__PURE__ */ h(de, { className: "cteditor-gap-2 cteditor-mt-4", children: [
|
|
451
|
+
/* @__PURE__ */ e(
|
|
452
|
+
"button",
|
|
453
|
+
{
|
|
454
|
+
type: "button",
|
|
455
|
+
onClick: () => {
|
|
456
|
+
M("freeform"), wt(null);
|
|
457
|
+
},
|
|
458
|
+
className: "cteditor-px-3 cteditor-py-2 cteditor-text-sm cteditor-rounded-md cteditor-bg-background cteditor-border cteditor-border-border cteditor-text-foreground hover:cteditor-bg-accent cteditor-transition-colors",
|
|
459
|
+
children: "Reset"
|
|
460
|
+
}
|
|
461
|
+
),
|
|
462
|
+
/* @__PURE__ */ e(
|
|
463
|
+
"button",
|
|
464
|
+
{
|
|
465
|
+
type: "button",
|
|
466
|
+
onClick: () => c(!1),
|
|
467
|
+
className: "cteditor-px-3 cteditor-py-2 cteditor-text-sm cteditor-rounded-md cteditor-bg-background cteditor-border cteditor-border-border cteditor-text-foreground hover:cteditor-bg-accent cteditor-transition-colors",
|
|
468
|
+
children: "Cancel"
|
|
469
|
+
}
|
|
470
|
+
),
|
|
471
|
+
/* @__PURE__ */ e(
|
|
472
|
+
"button",
|
|
473
|
+
{
|
|
474
|
+
type: "button",
|
|
475
|
+
onClick: St,
|
|
476
|
+
className: "cteditor-px-3 cteditor-py-2 cteditor-text-sm cteditor-rounded-md cteditor-bg-primary cteditor-text-primary-foreground hover:cteditor-bg-primary/90 cteditor-transition-colors",
|
|
477
|
+
children: "Apply"
|
|
478
|
+
}
|
|
479
|
+
)
|
|
480
|
+
] })
|
|
481
|
+
] })
|
|
482
|
+
] })
|
|
483
|
+
}
|
|
484
|
+
) });
|
|
485
|
+
}
|
|
486
|
+
const Nt = /* @__PURE__ */ new Set(), re = or("RIGHT_CLICK_IMAGE_COMMAND");
|
|
487
|
+
function zr(o) {
|
|
488
|
+
if (!Nt.has(o))
|
|
489
|
+
throw new Promise((c) => {
|
|
490
|
+
const s = new Image();
|
|
491
|
+
s.src = o, s.onload = () => {
|
|
492
|
+
Nt.add(o), c(null);
|
|
493
|
+
}, s.onerror = () => {
|
|
494
|
+
Nt.add(o);
|
|
495
|
+
};
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
function $r({
|
|
499
|
+
altText: o,
|
|
500
|
+
className: c,
|
|
501
|
+
imageRef: s,
|
|
502
|
+
src: f,
|
|
503
|
+
width: y,
|
|
504
|
+
height: N,
|
|
505
|
+
maxWidth: $,
|
|
506
|
+
onError: E,
|
|
507
|
+
onLoad: M
|
|
508
|
+
}) {
|
|
509
|
+
zr(f);
|
|
510
|
+
const ot = typeof y == "number", W = typeof N == "number", w = ot && W, I = ot ? y : "auto", x = W ? N : "auto";
|
|
511
|
+
return /* @__PURE__ */ e(
|
|
512
|
+
"img",
|
|
513
|
+
{
|
|
514
|
+
className: c || void 0,
|
|
515
|
+
src: f,
|
|
516
|
+
alt: o,
|
|
517
|
+
ref: s,
|
|
518
|
+
style: w ? {
|
|
519
|
+
width: I,
|
|
520
|
+
height: "auto",
|
|
521
|
+
aspectRatio: `${I} / ${x}`,
|
|
522
|
+
maxWidth: "100%"
|
|
523
|
+
} : ot ? {
|
|
524
|
+
// Only width known (e.g. bogus height stripped from source HTML):
|
|
525
|
+
// fix the width and let the browser compute height naturally.
|
|
526
|
+
width: I,
|
|
527
|
+
height: "auto",
|
|
528
|
+
maxWidth: "100%"
|
|
529
|
+
} : W ? {
|
|
530
|
+
// Only height known: fix height, let browser compute width.
|
|
531
|
+
width: "auto",
|
|
532
|
+
height: x,
|
|
533
|
+
maxWidth: "100%"
|
|
534
|
+
} : {
|
|
535
|
+
// No dimensions specified - use original image size.
|
|
536
|
+
height: "auto"
|
|
537
|
+
},
|
|
538
|
+
onError: E,
|
|
539
|
+
onLoad: M,
|
|
540
|
+
draggable: "false"
|
|
541
|
+
}
|
|
542
|
+
);
|
|
543
|
+
}
|
|
544
|
+
function Wr() {
|
|
545
|
+
return /* @__PURE__ */ e(
|
|
546
|
+
"img",
|
|
547
|
+
{
|
|
548
|
+
src: "",
|
|
549
|
+
style: {
|
|
550
|
+
height: 200,
|
|
551
|
+
opacity: 0.2,
|
|
552
|
+
width: 200
|
|
553
|
+
},
|
|
554
|
+
draggable: "false"
|
|
555
|
+
}
|
|
556
|
+
);
|
|
557
|
+
}
|
|
558
|
+
function Or(o, c = 12e3) {
|
|
559
|
+
return new Promise((s, f) => {
|
|
560
|
+
const y = new Image();
|
|
561
|
+
let N = !1;
|
|
562
|
+
const $ = window.setTimeout(() => {
|
|
563
|
+
N || (N = !0, f(new Error("Image load timeout")));
|
|
564
|
+
}, c);
|
|
565
|
+
y.onload = () => {
|
|
566
|
+
N || (N = !0, window.clearTimeout($), s());
|
|
567
|
+
}, y.onerror = () => {
|
|
568
|
+
N || (N = !0, window.clearTimeout($), f(new Error("Image failed to load")));
|
|
569
|
+
}, y.src = o;
|
|
570
|
+
});
|
|
571
|
+
}
|
|
572
|
+
function io({
|
|
573
|
+
src: o,
|
|
574
|
+
altText: c,
|
|
575
|
+
nodeKey: s,
|
|
576
|
+
width: f,
|
|
577
|
+
height: y,
|
|
578
|
+
maxWidth: N,
|
|
579
|
+
resizable: $,
|
|
580
|
+
showCaption: E,
|
|
581
|
+
caption: M,
|
|
582
|
+
captionsEnabled: ot,
|
|
583
|
+
originalPrompt: W,
|
|
584
|
+
position: w = "none",
|
|
585
|
+
linkUrl: I
|
|
586
|
+
}) {
|
|
587
|
+
const x = X(null), J = X(null), [i, D, v] = Ye(s), [L, it] = C(!1), ut = X(!1), { isCollabActive: bt } = ze(), [d] = $e(), [z, wt] = C(null), nt = X(null), [U, xt] = C(!1), St = Fe(), [n, g] = C(!1), [p, u] = C(""), [b, j] = C(!1), [mt, gt] = C(!1), [Q, G] = C(""), [ct, O] = C(""), [K, S] = C(!1), T = X(null), [Z, H] = C(0), [F, ht] = C(!1), kt = X(null), [ue, yt] = C(null), [Mt, Ct] = C(!1), [jt, Ht] = C(!1), at = X(null), It = ar()?.apiKey, Lt = Z > 0 && Z < 350;
|
|
588
|
+
Jt(() => {
|
|
589
|
+
if (!i || !st(z) || U) {
|
|
590
|
+
yt(null);
|
|
591
|
+
return;
|
|
592
|
+
}
|
|
593
|
+
const t = kt.current, r = d.getRootElement(), a = t?.parentElement;
|
|
594
|
+
if (!t || !r || !a) {
|
|
595
|
+
yt(null);
|
|
596
|
+
return;
|
|
597
|
+
}
|
|
598
|
+
const l = r.getBoundingClientRect(), m = a.getBoundingClientRect(), P = t.getBoundingClientRect(), A = 8, _ = P.width;
|
|
599
|
+
if (_ <= 0) {
|
|
600
|
+
yt(null);
|
|
601
|
+
return;
|
|
602
|
+
}
|
|
603
|
+
if (Lt) {
|
|
604
|
+
const dt = m.left + m.width / 2 - _ / 2, Y = Math.max(l.left + A, Math.min(dt, l.right - A - _));
|
|
605
|
+
yt({
|
|
606
|
+
left: Y - m.left,
|
|
607
|
+
bottom: 0,
|
|
608
|
+
right: "auto",
|
|
609
|
+
transform: "translateY(100%) translateY(4px)"
|
|
610
|
+
});
|
|
611
|
+
} else {
|
|
612
|
+
const dt = m.right - A - _, Y = Math.max(l.left + A, Math.min(dt, l.right - A - _));
|
|
613
|
+
yt({
|
|
614
|
+
left: Y - m.left,
|
|
615
|
+
top: A,
|
|
616
|
+
right: "auto"
|
|
617
|
+
});
|
|
618
|
+
}
|
|
619
|
+
}, [i, z, U, Lt, d, Z]), B(() => {
|
|
620
|
+
if (x.current) {
|
|
621
|
+
const t = () => {
|
|
622
|
+
ut.current || x.current && H(x.current.offsetWidth);
|
|
623
|
+
};
|
|
624
|
+
t();
|
|
625
|
+
const r = new ResizeObserver(t);
|
|
626
|
+
return r.observe(x.current), () => r.disconnect();
|
|
627
|
+
}
|
|
628
|
+
}, [f, y, i]), Jt(() => {
|
|
629
|
+
if ((w === "left" || w === "right") && typeof f == "number" && x.current) {
|
|
630
|
+
const t = x.current.closest(".editor-image"), r = t?.parentElement, a = d.getRootElement(), l = a ? a.getBoundingClientRect().width : f + 32, m = `${Math.min(f + 32, l)}px`;
|
|
631
|
+
return t && (t.style.removeProperty("display"), t.style.setProperty("max-width", m, "important")), r && r.style.setProperty("max-width", m, "important"), () => {
|
|
632
|
+
t && (t.style.removeProperty("max-width"), t.style.removeProperty("display")), r && r.style.removeProperty("max-width");
|
|
633
|
+
};
|
|
634
|
+
}
|
|
635
|
+
}, [w, f, d]);
|
|
636
|
+
const At = R(
|
|
637
|
+
(t) => {
|
|
638
|
+
const r = tt();
|
|
639
|
+
return i && st(r) && (t.preventDefault(), d.update(() => {
|
|
640
|
+
r.getNodes().forEach((l) => {
|
|
641
|
+
if (V(l)) {
|
|
642
|
+
const m = l.getParent();
|
|
643
|
+
l.remove(), m && _t(m) && m.getChildrenSize() === 0 && m.setFormat("left");
|
|
644
|
+
}
|
|
645
|
+
});
|
|
646
|
+
})), !1;
|
|
647
|
+
},
|
|
648
|
+
[d, i]
|
|
649
|
+
), Ft = R(
|
|
650
|
+
(t) => {
|
|
651
|
+
const r = tt(), a = J.current;
|
|
652
|
+
if (i && st(r) && r.getNodes().length === 1) {
|
|
653
|
+
if (E)
|
|
654
|
+
return pt(null), t.preventDefault(), M.focus(), !0;
|
|
655
|
+
if (a !== null && a !== document.activeElement)
|
|
656
|
+
return t.preventDefault(), a.focus(), !0;
|
|
657
|
+
}
|
|
658
|
+
return !1;
|
|
659
|
+
},
|
|
660
|
+
[M, i, E]
|
|
661
|
+
), Yt = R(
|
|
662
|
+
(t) => nt.current === M || J.current === t.target ? (pt(null), d.update(() => {
|
|
663
|
+
D(!0);
|
|
664
|
+
const r = d.getRootElement();
|
|
665
|
+
r !== null && r.focus();
|
|
666
|
+
}), !0) : !1,
|
|
667
|
+
[M, d, D]
|
|
668
|
+
), Dt = R(
|
|
669
|
+
(t) => {
|
|
670
|
+
const r = t;
|
|
671
|
+
if (L)
|
|
672
|
+
return !0;
|
|
673
|
+
const a = r.target;
|
|
674
|
+
if (a.closest("button") && x.current && a.closest(".editor-image") === x.current.closest(".editor-image"))
|
|
675
|
+
return !0;
|
|
676
|
+
const l = a === x.current;
|
|
677
|
+
let m = !1;
|
|
678
|
+
if (!l && x.current) {
|
|
679
|
+
const P = x.current.getBoundingClientRect();
|
|
680
|
+
m = r.clientX >= P.left && r.clientX <= P.right && r.clientY >= P.top && r.clientY <= P.bottom;
|
|
681
|
+
}
|
|
682
|
+
return l || m ? (r.shiftKey ? D(!i) : (v(), D(!0)), !0) : !1;
|
|
683
|
+
},
|
|
684
|
+
[L, i, D, v]
|
|
685
|
+
), zt = R(
|
|
686
|
+
(t) => {
|
|
687
|
+
d.getEditorState().read(() => {
|
|
688
|
+
const r = tt();
|
|
689
|
+
t.target.tagName === "IMG" && Be(r) && r.getNodes().length === 1 && d.dispatchCommand(
|
|
690
|
+
re,
|
|
691
|
+
t
|
|
692
|
+
);
|
|
693
|
+
});
|
|
694
|
+
},
|
|
695
|
+
[d]
|
|
696
|
+
);
|
|
697
|
+
B(() => {
|
|
698
|
+
let t = !0;
|
|
699
|
+
const r = d.getRootElement(), a = Xe(
|
|
700
|
+
d.registerUpdateListener(({ editorState: l }) => {
|
|
701
|
+
t && wt(l.read(() => tt()));
|
|
702
|
+
}),
|
|
703
|
+
d.registerCommand(
|
|
704
|
+
Ue,
|
|
705
|
+
(l, m) => (nt.current = m, !1),
|
|
706
|
+
et
|
|
707
|
+
),
|
|
708
|
+
d.registerCommand(
|
|
709
|
+
Ge,
|
|
710
|
+
Dt,
|
|
711
|
+
et
|
|
712
|
+
),
|
|
713
|
+
d.registerCommand(
|
|
714
|
+
re,
|
|
715
|
+
Dt,
|
|
716
|
+
et
|
|
717
|
+
),
|
|
718
|
+
d.registerCommand(
|
|
719
|
+
Ke,
|
|
720
|
+
(l) => l.target === x.current ? (l.preventDefault(), !0) : !1,
|
|
721
|
+
et
|
|
722
|
+
),
|
|
723
|
+
d.registerCommand(
|
|
724
|
+
qe,
|
|
725
|
+
At,
|
|
726
|
+
et
|
|
727
|
+
),
|
|
728
|
+
d.registerCommand(
|
|
729
|
+
Ve,
|
|
730
|
+
At,
|
|
731
|
+
et
|
|
732
|
+
),
|
|
733
|
+
d.registerCommand(Je, Ft, et),
|
|
734
|
+
d.registerCommand(
|
|
735
|
+
Qe,
|
|
736
|
+
Yt,
|
|
737
|
+
et
|
|
738
|
+
)
|
|
739
|
+
);
|
|
740
|
+
return r?.addEventListener("contextmenu", zt), () => {
|
|
741
|
+
t = !1, a(), r?.removeEventListener("contextmenu", zt);
|
|
742
|
+
};
|
|
743
|
+
}, [
|
|
744
|
+
v,
|
|
745
|
+
d,
|
|
746
|
+
L,
|
|
747
|
+
i,
|
|
748
|
+
s,
|
|
749
|
+
At,
|
|
750
|
+
Ft,
|
|
751
|
+
Yt,
|
|
752
|
+
Dt,
|
|
753
|
+
zt,
|
|
754
|
+
D
|
|
755
|
+
]);
|
|
756
|
+
const me = () => {
|
|
757
|
+
d.update(() => {
|
|
758
|
+
const t = rt(s);
|
|
759
|
+
V(t) && t.setShowCaption(!0);
|
|
760
|
+
});
|
|
761
|
+
}, ge = (t, r) => {
|
|
762
|
+
ut.current = !1, setTimeout(() => {
|
|
763
|
+
it(!1);
|
|
764
|
+
}, 200), d.update(() => {
|
|
765
|
+
const a = rt(s);
|
|
766
|
+
V(a) && a.setWidthAndHeight(t, r);
|
|
767
|
+
});
|
|
768
|
+
}, he = () => {
|
|
769
|
+
ut.current = !0, it(!0);
|
|
770
|
+
}, fe = (t) => {
|
|
771
|
+
if (t.preventDefault(), t.stopPropagation(), o.startsWith("data:")) {
|
|
772
|
+
const r = window.open("", "_blank");
|
|
773
|
+
r && (r.document.write(`
|
|
774
|
+
<!DOCTYPE html>
|
|
775
|
+
<html>
|
|
776
|
+
<head>
|
|
777
|
+
<title>${c || "Image"}</title>
|
|
778
|
+
<style>
|
|
779
|
+
body {
|
|
780
|
+
margin: 0;
|
|
781
|
+
display: flex;
|
|
782
|
+
justify-content: center;
|
|
783
|
+
align-items: center;
|
|
784
|
+
min-height: 100vh;
|
|
785
|
+
background-color: #1a1a1a;
|
|
786
|
+
}
|
|
787
|
+
img {
|
|
788
|
+
max-width: 100%;
|
|
789
|
+
max-height: 100vh;
|
|
790
|
+
object-fit: contain;
|
|
791
|
+
}
|
|
792
|
+
</style>
|
|
793
|
+
</head>
|
|
794
|
+
<body>
|
|
795
|
+
<img src="${o}" alt="${c || "Image"}" />
|
|
796
|
+
</body>
|
|
797
|
+
</html>
|
|
798
|
+
`), r.document.close());
|
|
799
|
+
} else
|
|
800
|
+
window.open(o, "_blank");
|
|
801
|
+
}, pe = (t) => {
|
|
802
|
+
t.preventDefault(), t.stopPropagation(), d.update(() => {
|
|
803
|
+
const r = rt(s);
|
|
804
|
+
if (V(r)) {
|
|
805
|
+
const a = r.getParent();
|
|
806
|
+
r.remove(), a && _t(a) && a.getChildrenSize() === 0 && a.setFormat("left");
|
|
807
|
+
}
|
|
808
|
+
});
|
|
809
|
+
}, ft = (t, r) => {
|
|
810
|
+
t.preventDefault(), t.stopPropagation(), d.update(() => {
|
|
811
|
+
const a = rt(s);
|
|
812
|
+
if (V(a)) {
|
|
813
|
+
a.setPosition(r);
|
|
814
|
+
const l = a.getParent();
|
|
815
|
+
l && _t(l) && (r === "left" ? l.setFormat("left") : r === "right" ? l.setFormat("right") : l.setFormat(""));
|
|
816
|
+
}
|
|
817
|
+
});
|
|
818
|
+
}, be = (t) => {
|
|
819
|
+
t.preventDefault(), t.stopPropagation(), g(!n);
|
|
820
|
+
}, we = R((t) => {
|
|
821
|
+
t.preventDefault(), t.stopPropagation(), ht(!0);
|
|
822
|
+
}, []), xe = R(
|
|
823
|
+
(t) => {
|
|
824
|
+
t.preventDefault(), t.stopPropagation();
|
|
825
|
+
const r = vt(o);
|
|
826
|
+
if (!(lt(o) && o !== r) && !(typeof f == "number" || typeof y == "number"))
|
|
827
|
+
return;
|
|
828
|
+
d.update(
|
|
829
|
+
() => {
|
|
830
|
+
const P = rt(s);
|
|
831
|
+
if (!V(P)) return;
|
|
832
|
+
P.setSrc(r), P.setWidthAndHeight("inherit", "inherit");
|
|
833
|
+
const A = tt();
|
|
834
|
+
A && pt(A.clone());
|
|
835
|
+
},
|
|
836
|
+
{ tag: "image-reset" }
|
|
837
|
+
);
|
|
838
|
+
const m = x.current;
|
|
839
|
+
m && requestAnimationFrame(() => {
|
|
840
|
+
m.src = r, m.style.removeProperty("width"), m.style.removeProperty("height");
|
|
841
|
+
}), k.success("Image reset to original size and crop");
|
|
842
|
+
},
|
|
843
|
+
[d, s, o, f, y]
|
|
844
|
+
), ye = R(
|
|
845
|
+
async (t) => {
|
|
846
|
+
let r = o;
|
|
847
|
+
if (lt(o))
|
|
848
|
+
r = vt(o);
|
|
849
|
+
else {
|
|
850
|
+
if (!It) {
|
|
851
|
+
k.error("API key is required to upload and crop external images.");
|
|
852
|
+
return;
|
|
853
|
+
}
|
|
854
|
+
const l = k.loading("Uploading image…");
|
|
855
|
+
try {
|
|
856
|
+
r = (await dr.post(
|
|
857
|
+
sr.project.fileUploadFromUrl,
|
|
858
|
+
{ url: o, prefix: "uploads" },
|
|
859
|
+
{ headers: { "x-api-key": It } }
|
|
860
|
+
)).data.fileUrl, k.dismiss(l);
|
|
861
|
+
} catch {
|
|
862
|
+
k.dismiss(l), k.error("Failed to upload image. Try again.");
|
|
863
|
+
return;
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
const a = Ar(r, t);
|
|
867
|
+
if (a === r) {
|
|
868
|
+
k.error("Cropping is only supported for images hosted on the CDN.");
|
|
869
|
+
return;
|
|
870
|
+
}
|
|
871
|
+
Ct(!0), at.current = a;
|
|
872
|
+
try {
|
|
873
|
+
await Or(a), Nt.add(a), d.update(() => {
|
|
874
|
+
const l = rt(s);
|
|
875
|
+
if (!V(l)) return;
|
|
876
|
+
l.setSrc(a), l.setWidthAndHeight(t.width, t.height);
|
|
877
|
+
const m = tt();
|
|
878
|
+
m && pt(m.clone());
|
|
879
|
+
}), k.success("Image cropped");
|
|
880
|
+
} catch {
|
|
881
|
+
at.current = null, Ct(!1), k.error("Crop failed to load. Showing original image.");
|
|
882
|
+
}
|
|
883
|
+
},
|
|
884
|
+
[d, s, o, It]
|
|
885
|
+
), Ce = R(() => {
|
|
886
|
+
I && !i && (T.current = setTimeout(() => {
|
|
887
|
+
S(!0);
|
|
888
|
+
}, 300));
|
|
889
|
+
}, [I, i]), ve = R(() => {
|
|
890
|
+
T.current && (clearTimeout(T.current), T.current = null), S(!1);
|
|
891
|
+
}, []), Xt = R((t) => {
|
|
892
|
+
t.preventDefault(), t.stopPropagation(), I && window.open(I, "_blank", "noopener,noreferrer");
|
|
893
|
+
}, [I]);
|
|
894
|
+
B(() => () => {
|
|
895
|
+
T.current && clearTimeout(T.current);
|
|
896
|
+
}, []), B(() => {
|
|
897
|
+
i || ht(!1);
|
|
898
|
+
}, [i]), B(() => {
|
|
899
|
+
xt(!1), Ht(!1);
|
|
900
|
+
}, [o]);
|
|
901
|
+
const Bt = async () => {
|
|
902
|
+
if (!p.trim() || b) return;
|
|
903
|
+
j(!0);
|
|
904
|
+
const t = k.loading("Refining image...", {
|
|
905
|
+
description: "This may take 10-30 seconds. Please wait."
|
|
906
|
+
});
|
|
907
|
+
try {
|
|
908
|
+
let r = p.trim();
|
|
909
|
+
const l = p.trim().replace(/^(add|also add|include|with|and)\s+(some|a|an)\s+/gi, "").replace(/^(add|also add|include|with|and)\s+/gi, "").trim(), m = (Y) => {
|
|
910
|
+
const Ot = Y.toLowerCase();
|
|
911
|
+
return [
|
|
912
|
+
"article",
|
|
913
|
+
"write",
|
|
914
|
+
"blog",
|
|
915
|
+
"post",
|
|
916
|
+
"essay",
|
|
917
|
+
"content",
|
|
918
|
+
"generate an article",
|
|
919
|
+
"create an article",
|
|
920
|
+
"write about",
|
|
921
|
+
"and add some pictures",
|
|
922
|
+
"with pictures",
|
|
923
|
+
"with images",
|
|
924
|
+
"add some images",
|
|
925
|
+
"include images",
|
|
926
|
+
"include pictures"
|
|
927
|
+
].some((Et) => Ot.includes(Et));
|
|
928
|
+
};
|
|
929
|
+
let P = "";
|
|
930
|
+
if (W && W.trim()) {
|
|
931
|
+
const Y = W.trim();
|
|
932
|
+
m(Y) && c && c !== "Generated image" && c.trim() ? P = c.trim() : P = Y;
|
|
933
|
+
} else c && c !== "Generated image" && c.trim() && (P = c.trim());
|
|
934
|
+
P ? r = `${P} with ${l}` : r = l;
|
|
935
|
+
const A = await fetch(`${Rr}/agent/stream`, {
|
|
936
|
+
method: "POST",
|
|
937
|
+
headers: { "Content-Type": "application/json" },
|
|
938
|
+
body: JSON.stringify({
|
|
939
|
+
type: "general",
|
|
940
|
+
query: `Generate Image: ${r}`,
|
|
941
|
+
model: "openai",
|
|
942
|
+
api_key: It || ""
|
|
943
|
+
})
|
|
944
|
+
});
|
|
945
|
+
if (!A.ok)
|
|
946
|
+
throw new Error(`Image service error: ${A.status}`);
|
|
947
|
+
const _ = A.body?.getReader(), Wt = new TextDecoder();
|
|
948
|
+
if (!_) throw new Error("Stream reader not available");
|
|
949
|
+
let dt = null;
|
|
950
|
+
t: for (; ; ) {
|
|
951
|
+
const { done: Y, value: Ot } = await _.read();
|
|
952
|
+
if (Y) break;
|
|
953
|
+
const Gt = Wt.decode(Ot, { stream: !0 }).split(`
|
|
954
|
+
`);
|
|
955
|
+
for (const Et of Gt) {
|
|
956
|
+
if (!Et.startsWith("data: ")) continue;
|
|
957
|
+
const Tt = Et.slice(6).trim();
|
|
958
|
+
if (!(!Tt || Tt === "[DONE]"))
|
|
959
|
+
try {
|
|
960
|
+
const q = JSON.parse(Tt);
|
|
961
|
+
if (q.type === "image_ready") {
|
|
962
|
+
dt = q.url, _.cancel();
|
|
963
|
+
break t;
|
|
964
|
+
} else {
|
|
965
|
+
if (q.type === "image_failed")
|
|
966
|
+
throw _.cancel(), new Error(q.error || "Image generation failed");
|
|
967
|
+
if (q.type === "error")
|
|
968
|
+
throw _.cancel(), new Error(q.message || "Image generation failed");
|
|
969
|
+
}
|
|
970
|
+
} catch (q) {
|
|
971
|
+
if (q instanceof SyntaxError) continue;
|
|
972
|
+
throw q;
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
if (!dt)
|
|
977
|
+
throw new Error("Failed to generate image - no image received");
|
|
978
|
+
k.dismiss(t), k.success("Image refined successfully!", {
|
|
979
|
+
description: "Compare the images and choose which to keep."
|
|
980
|
+
}), G(dt), O(r), gt(!0), u(""), g(!1);
|
|
981
|
+
} catch (r) {
|
|
982
|
+
if (k.dismiss(t), r instanceof kr) {
|
|
983
|
+
const a = r.code === "API_KEYS_DISABLED" ? "API Keys Disabled" : "API Key Required";
|
|
984
|
+
k.error(a, {
|
|
985
|
+
description: r.message,
|
|
986
|
+
duration: 8e3
|
|
987
|
+
});
|
|
988
|
+
} else r instanceof Ir ? k.error("Credits Issue", {
|
|
989
|
+
description: r.message,
|
|
990
|
+
duration: 8e3
|
|
991
|
+
}) : k.error("Failed to refine image", {
|
|
992
|
+
description: r instanceof Error ? r.message : "Unknown error. Please try again."
|
|
993
|
+
});
|
|
994
|
+
} finally {
|
|
995
|
+
j(!1);
|
|
996
|
+
}
|
|
997
|
+
}, Ne = () => {
|
|
998
|
+
d.update(() => {
|
|
999
|
+
const t = rt(s);
|
|
1000
|
+
if (V(t)) {
|
|
1001
|
+
t.setSrc(Q), t.setOriginalPrompt(ct);
|
|
1002
|
+
const r = tt();
|
|
1003
|
+
r && pt(r.clone());
|
|
1004
|
+
}
|
|
1005
|
+
}), gt(!1), G(""), O(""), k.success("Image replaced successfully!", {
|
|
1006
|
+
description: "The image has been updated with the refined version."
|
|
1007
|
+
});
|
|
1008
|
+
}, Re = () => {
|
|
1009
|
+
gt(!1), G(""), O("");
|
|
1010
|
+
}, ke = i && st(z) && !L, Ut = (i || L) && St, $t = vt(o), Ie = R(() => {
|
|
1011
|
+
at.current && o === at.current && (Nt.add(o), at.current = null, Ct(!1));
|
|
1012
|
+
}, [o]), Ee = R(() => {
|
|
1013
|
+
if (!jt && lt(o) && o !== $t) {
|
|
1014
|
+
Ht(!0), xt(!1), Ct(!1), at.current = null, d.update(() => {
|
|
1015
|
+
const r = rt(s);
|
|
1016
|
+
if (!V(r)) return;
|
|
1017
|
+
r.setSrc($t);
|
|
1018
|
+
const a = tt();
|
|
1019
|
+
a && pt(a.clone());
|
|
1020
|
+
}), k.error("Cropped image failed. Showing original image instead.");
|
|
1021
|
+
return;
|
|
1022
|
+
}
|
|
1023
|
+
Ct(!1), at.current = null, xt(!0);
|
|
1024
|
+
}, [jt, o, $t, d, s]), Pe = () => w === "left" || w === "right" ? {
|
|
1025
|
+
position: "relative",
|
|
1026
|
+
display: "block",
|
|
1027
|
+
width: "100%"
|
|
1028
|
+
// Fill the floated container
|
|
1029
|
+
} : w === "full" ? {
|
|
1030
|
+
position: "relative",
|
|
1031
|
+
display: "block",
|
|
1032
|
+
width: "fit-content",
|
|
1033
|
+
margin: "0 auto"
|
|
1034
|
+
} : w === "inline-left" ? {
|
|
1035
|
+
position: "relative",
|
|
1036
|
+
display: "block",
|
|
1037
|
+
width: "fit-content",
|
|
1038
|
+
marginRight: "auto"
|
|
1039
|
+
} : w === "inline-center" ? {
|
|
1040
|
+
position: "relative",
|
|
1041
|
+
display: "block",
|
|
1042
|
+
width: "fit-content",
|
|
1043
|
+
margin: "0 auto"
|
|
1044
|
+
} : w === "inline-right" ? {
|
|
1045
|
+
position: "relative",
|
|
1046
|
+
display: "block",
|
|
1047
|
+
width: "fit-content",
|
|
1048
|
+
marginLeft: "auto"
|
|
1049
|
+
} : {
|
|
1050
|
+
position: "relative",
|
|
1051
|
+
display: "inline-block"
|
|
1052
|
+
}, Se = R(
|
|
1053
|
+
(t) => {
|
|
1054
|
+
if (L || t.target.closest("button"))
|
|
1055
|
+
return;
|
|
1056
|
+
const a = t.target === x.current;
|
|
1057
|
+
let l = !1;
|
|
1058
|
+
if (!a && x.current) {
|
|
1059
|
+
const m = x.current.getBoundingClientRect();
|
|
1060
|
+
l = t.clientX >= m.left && t.clientX <= m.right && t.clientY >= m.top && t.clientY <= m.bottom;
|
|
1061
|
+
}
|
|
1062
|
+
!a && !l || (t.stopPropagation(), t.shiftKey ? D(!i) : (v(), D(!0)));
|
|
1063
|
+
},
|
|
1064
|
+
[L, i, D, v]
|
|
1065
|
+
);
|
|
1066
|
+
return /* @__PURE__ */ e(ir, { fallback: null, children: /* @__PURE__ */ h(Kt, { children: [
|
|
1067
|
+
/* @__PURE__ */ h(
|
|
1068
|
+
"div",
|
|
1069
|
+
{
|
|
1070
|
+
draggable: ke,
|
|
1071
|
+
style: Pe(),
|
|
1072
|
+
onClick: Se,
|
|
1073
|
+
onMouseEnter: Ce,
|
|
1074
|
+
onMouseLeave: ve,
|
|
1075
|
+
children: [
|
|
1076
|
+
U ? /* @__PURE__ */ e(Wr, {}) : /* @__PURE__ */ e(
|
|
1077
|
+
$r,
|
|
1078
|
+
{
|
|
1079
|
+
className: Ut ? `focused ${st(z) ? "draggable" : ""}` : I ? "cteditor-cursor-pointer" : null,
|
|
1080
|
+
src: o,
|
|
1081
|
+
altText: c,
|
|
1082
|
+
imageRef: x,
|
|
1083
|
+
width: f,
|
|
1084
|
+
height: y,
|
|
1085
|
+
maxWidth: N,
|
|
1086
|
+
onLoad: Ie,
|
|
1087
|
+
onError: Ee
|
|
1088
|
+
}
|
|
1089
|
+
),
|
|
1090
|
+
Mt && !U && /* @__PURE__ */ h("div", { className: "cteditor-absolute cteditor-inset-0 cteditor-flex cteditor-flex-col cteditor-items-center cteditor-justify-center cteditor-rounded-lg cteditor-bg-background/50 cteditor-backdrop-blur-[1px] cteditor-pointer-events-none", children: [
|
|
1091
|
+
/* @__PURE__ */ e(lr, { className: "cteditor-w-10 cteditor-h-10 cteditor-text-foreground cteditor-animate-spin cteditor-mb-2", "aria-hidden": !0 }),
|
|
1092
|
+
/* @__PURE__ */ e("span", { className: "cteditor-text-sm cteditor-font-medium cteditor-text-foreground", children: "Applying crop..." })
|
|
1093
|
+
] }),
|
|
1094
|
+
K && I && !i && /* @__PURE__ */ h(
|
|
1095
|
+
"div",
|
|
1096
|
+
{
|
|
1097
|
+
className: "cteditor-absolute cteditor-bottom-2 cteditor-left-2 cteditor-right-2 cteditor-bg-background cteditor-rounded-lg cteditor-shadow-lg cteditor-border cteditor-border-border cteditor-p-2 cteditor-flex cteditor-items-center cteditor-gap-2",
|
|
1098
|
+
style: { zIndex: 10 },
|
|
1099
|
+
children: [
|
|
1100
|
+
/* @__PURE__ */ e(Er, { className: "cteditor-w-4 cteditor-h-4 cteditor-text-muted-foreground cteditor-flex-shrink-0" }),
|
|
1101
|
+
/* @__PURE__ */ e("span", { className: "cteditor-text-sm cteditor-text-foreground cteditor-truncate cteditor-flex-1", children: I }),
|
|
1102
|
+
/* @__PURE__ */ e(
|
|
1103
|
+
"button",
|
|
1104
|
+
{
|
|
1105
|
+
type: "button",
|
|
1106
|
+
onClick: Xt,
|
|
1107
|
+
className: "cteditor-px-2 cteditor-py-1.5 cteditor-text-xs cteditor-rounded cteditor-bg-primary cteditor-text-primary-foreground hover:cteditor-bg-primary/90 cteditor-transition-colors cteditor-flex-shrink-0",
|
|
1108
|
+
children: "Open"
|
|
1109
|
+
}
|
|
1110
|
+
)
|
|
1111
|
+
]
|
|
1112
|
+
}
|
|
1113
|
+
),
|
|
1114
|
+
i && st(z) && !U && !Mt && /* @__PURE__ */ h(
|
|
1115
|
+
"div",
|
|
1116
|
+
{
|
|
1117
|
+
ref: kt,
|
|
1118
|
+
className: "cteditor-absolute cteditor-flex cteditor-gap-1 z-10 cteditor-text-foreground",
|
|
1119
|
+
style: ue ?? (Lt ? { left: "50%", transform: "translateX(-50%) translateY(100%) translateY(4px)", bottom: 0 } : { top: 8, right: 8 }),
|
|
1120
|
+
children: [
|
|
1121
|
+
/* @__PURE__ */ h("div", { className: "cteditor-flex cteditor-items-center cteditor-gap-0.5 cteditor-bg-accent cteditor-border cteditor-border-foreground/10 cteditor-rounded-md cteditor-shadow-md cteditor-p-0.5", children: [
|
|
1122
|
+
/* @__PURE__ */ e(
|
|
1123
|
+
"button",
|
|
1124
|
+
{
|
|
1125
|
+
type: "button",
|
|
1126
|
+
onClick: (t) => ft(t, "left"),
|
|
1127
|
+
className: ` cteditor-size-6 cteditor-flex cteditor-items-center cteditor-justify-center cteditor-rounded hover:cteditor-bg-foreground/10 cteditor-transition-colors ${w === "left" ? "cteditor-bg-foreground/10" : ""}`,
|
|
1128
|
+
"aria-label": "Wrap text left",
|
|
1129
|
+
title: "Wrap text left",
|
|
1130
|
+
children: /* @__PURE__ */ e(ur, {})
|
|
1131
|
+
}
|
|
1132
|
+
),
|
|
1133
|
+
/* @__PURE__ */ e(
|
|
1134
|
+
"button",
|
|
1135
|
+
{
|
|
1136
|
+
type: "button",
|
|
1137
|
+
onClick: (t) => ft(t, "right"),
|
|
1138
|
+
className: ` cteditor-size-6 cteditor-flex cteditor-items-center cteditor-justify-center cteditor-rounded hover:cteditor-bg-foreground/10 cteditor-transition-colors ${w === "right" ? "cteditor-bg-foreground/10" : ""}`,
|
|
1139
|
+
"aria-label": "Wrap text right",
|
|
1140
|
+
title: "Wrap text right",
|
|
1141
|
+
children: /* @__PURE__ */ e(mr, {})
|
|
1142
|
+
}
|
|
1143
|
+
),
|
|
1144
|
+
/* @__PURE__ */ e("div", { className: "cteditor-w-px cteditor-h-5 cteditor-bg-foreground/10 cteditor-mx-0.5" }),
|
|
1145
|
+
/* @__PURE__ */ e(
|
|
1146
|
+
"button",
|
|
1147
|
+
{
|
|
1148
|
+
type: "button",
|
|
1149
|
+
onClick: (t) => ft(t, "inline-left"),
|
|
1150
|
+
className: `cteditor-size-6 cteditor-flex cteditor-items-center cteditor-justify-center cteditor-rounded hover:cteditor-bg-foreground/10 cteditor-transition-colors ${w === "inline-left" ? "cteditor-bg-foreground/10" : ""}`,
|
|
1151
|
+
"aria-label": "Align left",
|
|
1152
|
+
title: "Align left (no text wrap)",
|
|
1153
|
+
children: /* @__PURE__ */ e(gr, {})
|
|
1154
|
+
}
|
|
1155
|
+
),
|
|
1156
|
+
/* @__PURE__ */ e(
|
|
1157
|
+
"button",
|
|
1158
|
+
{
|
|
1159
|
+
type: "button",
|
|
1160
|
+
onClick: (t) => ft(t, "inline-center"),
|
|
1161
|
+
className: `cteditor-size-6 cteditor-flex cteditor-items-center cteditor-justify-center cteditor-rounded hover:cteditor-bg-foreground/10 cteditor-transition-colors ${w === "inline-center" || w === "full" ? "cteditor-bg-foreground/10" : ""}`,
|
|
1162
|
+
"aria-label": "Align center",
|
|
1163
|
+
title: "Align center (no text wrap)",
|
|
1164
|
+
children: /* @__PURE__ */ e(hr, {})
|
|
1165
|
+
}
|
|
1166
|
+
),
|
|
1167
|
+
/* @__PURE__ */ e(
|
|
1168
|
+
"button",
|
|
1169
|
+
{
|
|
1170
|
+
type: "button",
|
|
1171
|
+
onClick: (t) => ft(t, "inline-right"),
|
|
1172
|
+
className: `cteditor-size-6 cteditor-flex cteditor-items-center cteditor-justify-center cteditor-rounded hover:cteditor-bg-foreground/10 cteditor-transition-colors ${w === "inline-right" ? "cteditor-bg-foreground/10" : ""}`,
|
|
1173
|
+
"aria-label": "Align right",
|
|
1174
|
+
title: "Align right (no text wrap)",
|
|
1175
|
+
children: /* @__PURE__ */ e(fr, {})
|
|
1176
|
+
}
|
|
1177
|
+
),
|
|
1178
|
+
/* @__PURE__ */ e("div", { className: "cteditor-w-px cteditor-h-5 cteditor-bg-foreground/10 cteditor-mx-0.5" }),
|
|
1179
|
+
/* @__PURE__ */ e(
|
|
1180
|
+
"button",
|
|
1181
|
+
{
|
|
1182
|
+
type: "button",
|
|
1183
|
+
onClick: (t) => ft(t, "none"),
|
|
1184
|
+
className: `cteditor-size-6 cteditor-flex cteditor-items-center cteditor-justify-center cteditor-rounded hover:cteditor-bg-foreground/10 cteditor-transition-colors ${w === "none" ? "cteditor-bg-foreground/10" : ""}`,
|
|
1185
|
+
"aria-label": "Inline",
|
|
1186
|
+
title: "Inline with text",
|
|
1187
|
+
children: /* @__PURE__ */ e(pr, { className: "cteditor-w-4 cteditor-h-4 cteditor-text-foreground" })
|
|
1188
|
+
}
|
|
1189
|
+
),
|
|
1190
|
+
/* @__PURE__ */ e("div", { className: "cteditor-w-px cteditor-h-5 cteditor-bg-foreground/10 cteditor-mx-0.5" }),
|
|
1191
|
+
!o.startsWith("data:") && !o.toLowerCase().endsWith(".svg") && /* @__PURE__ */ h(Kt, { children: [
|
|
1192
|
+
/* @__PURE__ */ e(
|
|
1193
|
+
"button",
|
|
1194
|
+
{
|
|
1195
|
+
type: "button",
|
|
1196
|
+
onClick: we,
|
|
1197
|
+
className: "cteditor-size-6 cteditor-flex cteditor-items-center cteditor-justify-center cteditor-rounded hover:cteditor-bg-foreground/10 cteditor-transition-colors",
|
|
1198
|
+
"aria-label": "Crop image",
|
|
1199
|
+
title: "Crop image",
|
|
1200
|
+
children: /* @__PURE__ */ e(se, { className: "cteditor-w-4 cteditor-h-4 cteditor-text-foreground" })
|
|
1201
|
+
}
|
|
1202
|
+
),
|
|
1203
|
+
(vt(o) !== o || typeof f == "number" || typeof y == "number") && /* @__PURE__ */ e(
|
|
1204
|
+
"button",
|
|
1205
|
+
{
|
|
1206
|
+
type: "button",
|
|
1207
|
+
onClick: xe,
|
|
1208
|
+
className: "cteditor-size-6 cteditor-flex cteditor-items-center cteditor-justify-center cteditor-rounded hover:cteditor-bg-foreground/10 cteditor-transition-colors",
|
|
1209
|
+
"aria-label": "Reset image to original size and crop",
|
|
1210
|
+
title: "Reset to original size and crop",
|
|
1211
|
+
children: /* @__PURE__ */ e(Pr, { className: "cteditor-w-4 cteditor-h-4 cteditor-text-foreground" })
|
|
1212
|
+
}
|
|
1213
|
+
)
|
|
1214
|
+
] })
|
|
1215
|
+
] }),
|
|
1216
|
+
I && /* @__PURE__ */ e(
|
|
1217
|
+
"button",
|
|
1218
|
+
{
|
|
1219
|
+
type: "button",
|
|
1220
|
+
onClick: Xt,
|
|
1221
|
+
className: " cteditor-size-6 cteditor-flex cteditor-items-center cteditor-justify-center cteditor-rounded-md cteditor-bg-accent hover:cteditor-bg-accent/95 cteditor-transition-colors cteditor-shadow-md cteditor-border cteditor-border-foreground/20",
|
|
1222
|
+
"aria-label": "Visit link",
|
|
1223
|
+
title: `Visit: ${I}`,
|
|
1224
|
+
children: /* @__PURE__ */ e(br, {})
|
|
1225
|
+
}
|
|
1226
|
+
),
|
|
1227
|
+
W && /* @__PURE__ */ e(
|
|
1228
|
+
"button",
|
|
1229
|
+
{
|
|
1230
|
+
type: "button",
|
|
1231
|
+
onClick: (t) => {
|
|
1232
|
+
t.stopPropagation(), be(t);
|
|
1233
|
+
},
|
|
1234
|
+
className: " cteditor-size-8 cteditor-flex cteditor-items-center cteditor-justify-center cteditor-rounded-md cteditor-bg-accent hover:cteditor-bg-accent/90 cteditor-transition-colors cteditor-shadow-md cteditor-border cteditor-border-foreground/20",
|
|
1235
|
+
"aria-label": "Refine image",
|
|
1236
|
+
title: "Refine image",
|
|
1237
|
+
children: /* @__PURE__ */ e(wr, { className: "cteditor-w-4 cteditor-h-4 cteditor-text-foreground" })
|
|
1238
|
+
}
|
|
1239
|
+
),
|
|
1240
|
+
/* @__PURE__ */ e(
|
|
1241
|
+
"button",
|
|
1242
|
+
{
|
|
1243
|
+
type: "button",
|
|
1244
|
+
onClick: (t) => {
|
|
1245
|
+
t.stopPropagation(), fe(t);
|
|
1246
|
+
},
|
|
1247
|
+
className: " cteditor-size-8 cteditor-flex cteditor-items-center cteditor-justify-center cteditor-rounded-md cteditor-bg-accent hover:cteditor-bg-accent/90 cteditor-transition-colors cteditor-shadow-md cteditor-border cteditor-border-foreground/20",
|
|
1248
|
+
"aria-label": "Open image in new tab",
|
|
1249
|
+
title: "Open in new tab",
|
|
1250
|
+
children: /* @__PURE__ */ e(xr, {})
|
|
1251
|
+
}
|
|
1252
|
+
),
|
|
1253
|
+
/* @__PURE__ */ e(
|
|
1254
|
+
"button",
|
|
1255
|
+
{
|
|
1256
|
+
type: "button",
|
|
1257
|
+
onClick: (t) => {
|
|
1258
|
+
t.stopPropagation(), pe(t);
|
|
1259
|
+
},
|
|
1260
|
+
className: " cteditor-size-8 cteditor-flex cteditor-items-center cteditor-justify-center cteditor-rounded-md cteditor-bg-accent hover:cteditor-bg-destructive hover:cteditor-text-destructive-foreground cteditor-transition-colors cteditor-shadow-md cteditor-border cteditor-border-foreground/20",
|
|
1261
|
+
"aria-label": "Delete image",
|
|
1262
|
+
title: "Delete image",
|
|
1263
|
+
children: /* @__PURE__ */ e(yr, {})
|
|
1264
|
+
}
|
|
1265
|
+
)
|
|
1266
|
+
]
|
|
1267
|
+
}
|
|
1268
|
+
),
|
|
1269
|
+
n && i && !U && W && /* @__PURE__ */ e(
|
|
1270
|
+
"div",
|
|
1271
|
+
{
|
|
1272
|
+
className: "cteditor-absolute cteditor-bottom-2 cteditor-left-2 cteditor-right-2 cteditor-bg-background/85 cteditor-rounded-lg cteditor-shadow-xl cteditor-border cteditor-border-foreground/20 cteditor-p-3 cteditor-backdrop-blur-lg md:cteditor-min-w-80",
|
|
1273
|
+
style: { zIndex: 10 },
|
|
1274
|
+
onClick: (t) => t.stopPropagation(),
|
|
1275
|
+
onKeyDown: (t) => t.stopPropagation(),
|
|
1276
|
+
onKeyUp: (t) => t.stopPropagation(),
|
|
1277
|
+
children: /* @__PURE__ */ h("div", { className: "cteditor-flex cteditor-flex-col cteditor-gap-2", children: [
|
|
1278
|
+
/* @__PURE__ */ e("label", { className: "cteditor-text-xs cteditor-font-medium cteditor-text-foreground", children: "What else do you want in this scene?" }),
|
|
1279
|
+
/* @__PURE__ */ e(
|
|
1280
|
+
"input",
|
|
1281
|
+
{
|
|
1282
|
+
type: "text",
|
|
1283
|
+
value: p,
|
|
1284
|
+
onChange: (t) => u(t.target.value),
|
|
1285
|
+
onKeyDown: (t) => {
|
|
1286
|
+
t.stopPropagation(), t.key === "Enter" && p.trim() && !b && Bt(), t.key === "Escape" && (g(!1), u(""));
|
|
1287
|
+
},
|
|
1288
|
+
onKeyUp: (t) => {
|
|
1289
|
+
t.stopPropagation();
|
|
1290
|
+
},
|
|
1291
|
+
onClick: (t) => {
|
|
1292
|
+
t.stopPropagation();
|
|
1293
|
+
},
|
|
1294
|
+
placeholder: "e.g., flying birds, golden sunset, stormy clouds...",
|
|
1295
|
+
className: "cteditor-w-full cteditor-px-3 cteditor-py-2 cteditor-text-sm cteditor-border cteditor-border-foreground/10 focus:cteditor-border-foreground cteditor-rounded-md cteditor-bg-background cteditor-text-foreground ",
|
|
1296
|
+
disabled: b,
|
|
1297
|
+
autoFocus: !0
|
|
1298
|
+
}
|
|
1299
|
+
),
|
|
1300
|
+
/* @__PURE__ */ h("div", { className: "cteditor-flex cteditor-gap-2 cteditor-justify-end", children: [
|
|
1301
|
+
/* @__PURE__ */ e(
|
|
1302
|
+
"button",
|
|
1303
|
+
{
|
|
1304
|
+
type: "button",
|
|
1305
|
+
onClick: (t) => {
|
|
1306
|
+
t.stopPropagation(), Bt();
|
|
1307
|
+
},
|
|
1308
|
+
disabled: b || !p.trim(),
|
|
1309
|
+
className: " cteditor-px-5 cteditor-py-2 cteditor-text-sm cteditor-rounded-md cteditor-bg-foreground cteditor-text-background hover:cteditor-bg-foreground/95 disabled:cteditor-opacity-50 disabled:cteditor-cursor-not-allowed cteditor-transition-colors focus:cteditor-outline-none focus:cteditor-ring-2 focus:cteditor-ring-background",
|
|
1310
|
+
children: b ? /* @__PURE__ */ h("span", { className: "cteditor-flex cteditor-items-center cteditor-justify-center cteditor-gap-2", children: [
|
|
1311
|
+
/* @__PURE__ */ e("span", { className: "cteditor-inline-block cteditor-w-4 cteditor-h-4 cteditor-border-2 cteditor-border-t-transparent cteditor-rounded-full cteditor-animate-spin" }),
|
|
1312
|
+
"Refining..."
|
|
1313
|
+
] }) : "Refine Image"
|
|
1314
|
+
}
|
|
1315
|
+
),
|
|
1316
|
+
/* @__PURE__ */ e(
|
|
1317
|
+
"button",
|
|
1318
|
+
{
|
|
1319
|
+
type: "button",
|
|
1320
|
+
onClick: (t) => {
|
|
1321
|
+
t.stopPropagation(), g(!1), u("");
|
|
1322
|
+
},
|
|
1323
|
+
disabled: b,
|
|
1324
|
+
className: "cteditor-size-9 cteditor-flex cteditor-items-center cteditor-justify-center cteditor-text-sm cteditor-rounded-md cteditor-bg-background cteditor-border cteditor-border-border cteditor-text-foreground hover:cteditor-bg-accent disabled:cteditor-opacity-50 disabled:cteditor-cursor-not-allowed cteditor-transition-colors",
|
|
1325
|
+
children: /* @__PURE__ */ e(Cr, { size: 16 })
|
|
1326
|
+
}
|
|
1327
|
+
)
|
|
1328
|
+
] })
|
|
1329
|
+
] })
|
|
1330
|
+
}
|
|
1331
|
+
),
|
|
1332
|
+
$ && st(z) && Ut && !Mt && /* @__PURE__ */ e(
|
|
1333
|
+
Me,
|
|
1334
|
+
{
|
|
1335
|
+
showCaption: E,
|
|
1336
|
+
setShowCaption: me,
|
|
1337
|
+
editor: d,
|
|
1338
|
+
buttonRef: J,
|
|
1339
|
+
imageRef: x,
|
|
1340
|
+
maxWidth: N,
|
|
1341
|
+
onResizeStart: he,
|
|
1342
|
+
onResizeEnd: ge,
|
|
1343
|
+
captionsEnabled: !U && ot
|
|
1344
|
+
}
|
|
1345
|
+
)
|
|
1346
|
+
]
|
|
1347
|
+
}
|
|
1348
|
+
),
|
|
1349
|
+
E && (c.startsWith("Signature by") ? /* @__PURE__ */ e(Mr, { caption: M }) : /* @__PURE__ */ e(
|
|
1350
|
+
"div",
|
|
1351
|
+
{
|
|
1352
|
+
className: "image-caption-container",
|
|
1353
|
+
style: {
|
|
1354
|
+
width: typeof f == "number" ? `${f}px` : "100%",
|
|
1355
|
+
maxWidth: "100%",
|
|
1356
|
+
// Match the image's alignment
|
|
1357
|
+
...w === "inline-center" || w === "full" ? { margin: "0 auto" } : w === "inline-right" ? { marginLeft: "auto" } : w === "left" ? { float: "left", clear: "left" } : w === "right" ? { float: "right", clear: "right" } : {}
|
|
1358
|
+
},
|
|
1359
|
+
children: /* @__PURE__ */ h(
|
|
1360
|
+
_e,
|
|
1361
|
+
{
|
|
1362
|
+
initialEditor: M,
|
|
1363
|
+
initialNodes: [
|
|
1364
|
+
Ze,
|
|
1365
|
+
tr,
|
|
1366
|
+
er,
|
|
1367
|
+
rr,
|
|
1368
|
+
Ae,
|
|
1369
|
+
Le
|
|
1370
|
+
],
|
|
1371
|
+
children: [
|
|
1372
|
+
/* @__PURE__ */ e(De, {}),
|
|
1373
|
+
/* @__PURE__ */ e(
|
|
1374
|
+
He,
|
|
1375
|
+
{
|
|
1376
|
+
contentEditable: /* @__PURE__ */ e(
|
|
1377
|
+
We,
|
|
1378
|
+
{
|
|
1379
|
+
"aria-placeholder": "Enter a caption...",
|
|
1380
|
+
placeholder: () => /* @__PURE__ */ e("span", { className: "cteditor-text-xs cteditor-absolute cteditor-left-2 cteditor-top-[7px]", children: "Enter a caption..." }),
|
|
1381
|
+
className: " cteditor-outline-none !cteditor-shadow-none cteditor-bg-foreground/10 cteditor-border !cteditor-border-foreground/15 cteditor-py-1 cteditor-px-2 cteditor-rounded-sm cteditor-text-xs cteditor-relative"
|
|
1382
|
+
}
|
|
1383
|
+
),
|
|
1384
|
+
ErrorBoundary: Oe
|
|
1385
|
+
}
|
|
1386
|
+
),
|
|
1387
|
+
/* @__PURE__ */ e(
|
|
1388
|
+
je,
|
|
1389
|
+
{
|
|
1390
|
+
onChange: () => {
|
|
1391
|
+
}
|
|
1392
|
+
}
|
|
1393
|
+
),
|
|
1394
|
+
/* @__PURE__ */ e(Te, {}),
|
|
1395
|
+
/* @__PURE__ */ e(vr, { namespace: Nr.namespace })
|
|
1396
|
+
]
|
|
1397
|
+
}
|
|
1398
|
+
)
|
|
1399
|
+
}
|
|
1400
|
+
)),
|
|
1401
|
+
/* @__PURE__ */ e(
|
|
1402
|
+
Dr,
|
|
1403
|
+
{
|
|
1404
|
+
open: F,
|
|
1405
|
+
onOpenChange: ht,
|
|
1406
|
+
src: o,
|
|
1407
|
+
altText: c,
|
|
1408
|
+
width: f,
|
|
1409
|
+
height: y,
|
|
1410
|
+
onCropApply: ye
|
|
1411
|
+
}
|
|
1412
|
+
),
|
|
1413
|
+
/* @__PURE__ */ e(
|
|
1414
|
+
Sr,
|
|
1415
|
+
{
|
|
1416
|
+
open: mt,
|
|
1417
|
+
onOpenChange: gt,
|
|
1418
|
+
oldImageUrl: o,
|
|
1419
|
+
newImageUrl: Q,
|
|
1420
|
+
onReplace: Ne,
|
|
1421
|
+
onCancel: Re
|
|
1422
|
+
}
|
|
1423
|
+
)
|
|
1424
|
+
] }) });
|
|
1425
|
+
}
|
|
1426
|
+
export {
|
|
1427
|
+
re as RIGHT_CLICK_IMAGE_COMMAND,
|
|
1428
|
+
io as default
|
|
1429
|
+
};
|