eddyter 1.4.12 → 1.4.13
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/README.md +3 -2
- package/dist/CommentBubblePlugin-DDCERFQO.js +29 -0
- package/dist/{LazyCodeMirror-CcceEUqu.js → LazyCodeMirror-C1bW4mVF.js} +941 -1484
- package/dist/{LazySignatureCanvas-Cck44R9l.js → LazySignatureCanvas-D5P1189T.js} +21 -38
- package/dist/Provider/EditorProvider.d.ts +2 -0
- package/dist/api/auth.d.ts +4 -0
- package/dist/assets/style.css +1 -1
- package/dist/{babel-CCPWkrf4.js → babel-B9hn44Wo.js} +726 -1302
- package/dist/components/ColorPicker/LazyHexColorPicker.d.ts +2 -0
- package/dist/components/CommentToggle/CommentToggle.d.ts +2 -2
- package/dist/components/ConfigurableEditorWithAuth.d.ts +2 -2
- package/dist/components/EmojiPickerWidget/LazyEmojiPicker.d.ts +4 -0
- package/dist/components/LockedFeature/FeatureLockCard.d.ts +22 -0
- package/dist/components/LockedFeature/FeatureLockTooltipContent.d.ts +12 -0
- package/dist/components/LockedFeature/LockedFeature.d.ts +6 -1
- package/dist/components/LockedFeature/lockedFeatureMetadata.d.ts +7 -0
- package/dist/components/Toolbar/styles.d.ts +5 -5
- package/dist/components/ui/tooltip.d.ts +2 -1
- package/dist/{estree-CxUPh9wa.js → estree-CocPn_Md.js} +529 -917
- package/dist/{generateDocxThumbnail-DGj_L73_.js → generateDocxThumbnail-BVFpoKUP.js} +762 -1118
- package/dist/{generatePdfThumbnail-D1ui86rp.js → generatePdfThumbnail-Pvt57kGy.js} +13 -19
- package/dist/{generateXlsxThumbnail-CbJOr-_6.js → generateXlsxThumbnail-DRggrLYK.js} +3322 -3508
- package/dist/{html-CmniStvG.js → html-CxCicOef.js} +350 -589
- package/dist/{html2canvas.esm-C2wu93Kq.js → html2canvas.esm-BD_Vwvv8.js} +139 -204
- package/dist/{html2pdf.bundle.min-CN_w9Sxu.js → html2pdf.bundle.min-DElEIEzd.js} +3405 -5221
- package/dist/{index-DiSjJC3k.js → index-C9Dld3-L.js} +13 -13
- package/dist/{index-CuwrKBfY.js → index-Cojy1w7r.js} +194 -217
- package/dist/index-D11sRTul.js +147 -0
- package/dist/{index-Dh0oRk6u.js → index-DFEFJp4J.js} +37294 -41489
- package/dist/index-D_izLqTY.js +552 -0
- package/dist/{index-hrDzgkRb.js → index-ZBDns08-.js} +81 -80
- package/dist/index-rm00T8b9.js +166 -0
- package/dist/index.js +2 -2
- package/dist/{markdown-B0mEGGfQ.js → markdown-BUjgWFLu.js} +578 -1015
- package/dist/{objectWithoutPropertiesLoose-DO0w4vQT.js → objectWithoutPropertiesLoose-DiWPeE4c.js} +6 -10
- package/dist/pages/ConfigurableEditor/ConfigurableEditor.d.ts +1 -1
- package/dist/plugins/LocalStoragePlugin.d.ts +0 -2
- package/dist/{postcss-B0bxXf7u.js → postcss-CGIcwj_g.js} +615 -1065
- package/dist/{standalone-DmuJV5rn.js → standalone-C0qguT38.js} +350 -596
- package/dist/{typescript-DZlC_9M8.js → typescript-BM7wk6k-.js} +1114 -1806
- package/package.json +8 -1
|
@@ -0,0 +1,552 @@
|
|
|
1
|
+
import { jsx as o, jsxs as j, Fragment as re } from "react/jsx-runtime";
|
|
2
|
+
import { $insertDataTransferForRichText as se } from "@lexical/clipboard";
|
|
3
|
+
import { useLexicalComposerContext as ee } from "@lexical/react/LexicalComposerContext";
|
|
4
|
+
import { mergeRegister as ce, $wrapNodeInElement as J } from "@lexical/utils";
|
|
5
|
+
import { $isTableCellNode as ae } from "@lexical/table";
|
|
6
|
+
import { $getNodeByKey as T, $createNodeSelection as G, $setSelection as H, $getSelection as S, $isNodeSelection as te, SELECTION_CHANGE_COMMAND as de, COMMAND_PRIORITY_LOW as ne, KEY_ENTER_COMMAND as le, $createParagraphNode as W, $isRootOrShadowRoot as V, PASTE_COMMAND as ue, $isRangeSelection as U, COMMAND_PRIORITY_CRITICAL as me } from "lexical";
|
|
7
|
+
import { useState as M, useEffect as E, useCallback as _, useRef as Q } from "react";
|
|
8
|
+
import { c as fe, E as k, L as pe, a as N, I as ge, C as he, W as be, b as ye, A as xe, d as Ee, e as Ce, f as ve, T as Ne, $ as Z } from "./index-DFEFJp4J.js";
|
|
9
|
+
import { createPortal as ke } from "react-dom";
|
|
10
|
+
const Ae = fe("Copy", [
|
|
11
|
+
["rect", { width: "14", height: "14", x: "8", y: "8", rx: "2", ry: "2", key: "17jyea" }],
|
|
12
|
+
["path", { d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2", key: "zix9uf" }]
|
|
13
|
+
]), K = "cteditor-flex cteditor-items-center cteditor-gap-0.5 cteditor-bg-background/80 cteditor-rounded-md cteditor-shadow-md cteditor-border cteditor-border-border cteditor-p-0.5", w = "cteditor-size-6 cteditor-flex cteditor-items-center cteditor-justify-center cteditor-rounded hover:cteditor-bg-accent cteditor-transition-colors cteditor-text-foreground", P = "cteditor-bg-accent", Y = "cteditor-size-8 cteditor-flex cteditor-items-center cteditor-justify-center cteditor-rounded-md cteditor-bg-background/80 cteditor-shadow-md cteditor-border cteditor-border-border hover:cteditor-bg-accent cteditor-transition-colors cteditor-text-foreground";
|
|
14
|
+
function we({
|
|
15
|
+
editor: c,
|
|
16
|
+
anchorElem: y,
|
|
17
|
+
nodeKey: n,
|
|
18
|
+
url: f,
|
|
19
|
+
onClose: u
|
|
20
|
+
}) {
|
|
21
|
+
const a = Q(null), d = Q(), [g, i] = M(
|
|
22
|
+
"embed"
|
|
23
|
+
), [A, t] = M(
|
|
24
|
+
"left"
|
|
25
|
+
), [p, m] = M("none"), [r, l] = M(!1), h = _(() => {
|
|
26
|
+
const e = a.current;
|
|
27
|
+
if (!e) return;
|
|
28
|
+
const R = c.getRootElement()?.querySelector(
|
|
29
|
+
`[data-lexical-node-key="${n}"]`
|
|
30
|
+
);
|
|
31
|
+
if (R) {
|
|
32
|
+
const v = R.getBoundingClientRect(), I = e.getBoundingClientRect(), X = y.getBoundingClientRect(), oe = v.left + v.width / 2, ie = I.width / 2;
|
|
33
|
+
let F = v.top - I.height - 15, O = oe - ie;
|
|
34
|
+
O < 10 && (O = 10), O + I.width > window.innerWidth - 10 && (O = window.innerWidth - I.width - 10), F < 10 && (F = v.bottom + 15), F -= X.top, O -= X.left, e.style.opacity = "1", e.style.transform = `translate(${O}px, ${F}px)`, r || (e.style.display = "flex", e.style.visibility = "visible", e.style.zIndex = "9999", l(!0));
|
|
35
|
+
} else
|
|
36
|
+
e.style.opacity = "0", e.style.visibility = "hidden";
|
|
37
|
+
}, [c, n, y, r]), x = _(() => {
|
|
38
|
+
const e = () => {
|
|
39
|
+
h(), d.current = requestAnimationFrame(e);
|
|
40
|
+
};
|
|
41
|
+
d.current = requestAnimationFrame(e);
|
|
42
|
+
}, [h]), L = _(() => {
|
|
43
|
+
d.current && (cancelAnimationFrame(d.current), d.current = void 0);
|
|
44
|
+
}, []);
|
|
45
|
+
E(() => (x(), () => {
|
|
46
|
+
L();
|
|
47
|
+
}), [x, L]), E(() => {
|
|
48
|
+
const e = a.current;
|
|
49
|
+
if (e) {
|
|
50
|
+
const s = setTimeout(() => {
|
|
51
|
+
e.style.display = "flex", e.style.opacity = "1", e.style.visibility = "visible", e.style.zIndex = "9999", l(!0);
|
|
52
|
+
}, 100);
|
|
53
|
+
return () => clearTimeout(s);
|
|
54
|
+
}
|
|
55
|
+
}, []), E(() => {
|
|
56
|
+
const e = (s) => {
|
|
57
|
+
const R = s, { nodeKey: v } = R.detail;
|
|
58
|
+
v === n && l(!0);
|
|
59
|
+
};
|
|
60
|
+
return document.addEventListener("embedNodeSelected", e), () => {
|
|
61
|
+
document.removeEventListener(
|
|
62
|
+
"embedNodeSelected",
|
|
63
|
+
e
|
|
64
|
+
);
|
|
65
|
+
};
|
|
66
|
+
}, [n]), E(() => {
|
|
67
|
+
c.getEditorState().read(() => {
|
|
68
|
+
const e = T(n);
|
|
69
|
+
e instanceof k && (typeof e.getDisplayType == "function" && i(e.getDisplayType()), typeof e.getAlignment == "function" && t(e.getAlignment()), typeof e.getPosition == "function" && m(e.getPosition()));
|
|
70
|
+
});
|
|
71
|
+
}, [c, n]);
|
|
72
|
+
const C = (e) => {
|
|
73
|
+
i(e), c.update(() => {
|
|
74
|
+
const s = T(n);
|
|
75
|
+
s instanceof k && typeof s.setDisplayType == "function" && s.setDisplayType(e);
|
|
76
|
+
});
|
|
77
|
+
}, $ = (e) => {
|
|
78
|
+
t(e), c.update(() => {
|
|
79
|
+
const s = T(n);
|
|
80
|
+
s instanceof k && typeof s.setAlignment == "function" && s.setAlignment(e);
|
|
81
|
+
});
|
|
82
|
+
}, q = (e) => {
|
|
83
|
+
m(e), c.update(() => {
|
|
84
|
+
const s = T(n);
|
|
85
|
+
s instanceof k && typeof s.setPosition == "function" && s.setPosition(e);
|
|
86
|
+
});
|
|
87
|
+
}, z = (e) => {
|
|
88
|
+
e.stopPropagation(), window.open(f, "_blank");
|
|
89
|
+
}, D = (e) => {
|
|
90
|
+
e.stopPropagation(), c.update(() => {
|
|
91
|
+
const s = T(n);
|
|
92
|
+
s && s.remove();
|
|
93
|
+
}), u();
|
|
94
|
+
}, b = (e) => {
|
|
95
|
+
e.stopPropagation(), navigator.clipboard.writeText(f).then(() => {
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
return E(() => {
|
|
99
|
+
const e = (s) => {
|
|
100
|
+
a.current && !a.current.contains(s.target) && (s.target.closest("[data-embed-type]") || u());
|
|
101
|
+
};
|
|
102
|
+
return r && setTimeout(() => {
|
|
103
|
+
document.addEventListener("mousedown", e);
|
|
104
|
+
}, 100), () => {
|
|
105
|
+
document.removeEventListener("mousedown", e);
|
|
106
|
+
};
|
|
107
|
+
}, [u, r]), /* @__PURE__ */ j(
|
|
108
|
+
"div",
|
|
109
|
+
{
|
|
110
|
+
className: "floating-embed-menu cteditor-flex cteditor-gap-1 cteditor-z-10",
|
|
111
|
+
ref: a,
|
|
112
|
+
onClick: (e) => {
|
|
113
|
+
e.stopPropagation();
|
|
114
|
+
},
|
|
115
|
+
style: {
|
|
116
|
+
position: "absolute",
|
|
117
|
+
top: 0,
|
|
118
|
+
left: 0,
|
|
119
|
+
opacity: 0,
|
|
120
|
+
visibility: "hidden",
|
|
121
|
+
zIndex: 9999,
|
|
122
|
+
transition: "opacity 0.15s ease-in-out"
|
|
123
|
+
},
|
|
124
|
+
children: [
|
|
125
|
+
/* @__PURE__ */ j("div", { className: K, children: [
|
|
126
|
+
/* @__PURE__ */ o(
|
|
127
|
+
"button",
|
|
128
|
+
{
|
|
129
|
+
type: "button",
|
|
130
|
+
className: N(
|
|
131
|
+
w,
|
|
132
|
+
g === "url" && P
|
|
133
|
+
),
|
|
134
|
+
onClick: (e) => {
|
|
135
|
+
e.stopPropagation(), C("url");
|
|
136
|
+
},
|
|
137
|
+
title: "Link",
|
|
138
|
+
children: /* @__PURE__ */ o(pe, {})
|
|
139
|
+
}
|
|
140
|
+
),
|
|
141
|
+
/* @__PURE__ */ o(
|
|
142
|
+
"button",
|
|
143
|
+
{
|
|
144
|
+
type: "button",
|
|
145
|
+
className: N(
|
|
146
|
+
w,
|
|
147
|
+
g === "card" && P
|
|
148
|
+
),
|
|
149
|
+
onClick: (e) => {
|
|
150
|
+
e.stopPropagation(), C("card");
|
|
151
|
+
},
|
|
152
|
+
title: "Card",
|
|
153
|
+
children: /* @__PURE__ */ o(ge, { className: "cteditor-size-3.5" })
|
|
154
|
+
}
|
|
155
|
+
),
|
|
156
|
+
/* @__PURE__ */ o(
|
|
157
|
+
"button",
|
|
158
|
+
{
|
|
159
|
+
type: "button",
|
|
160
|
+
className: N(
|
|
161
|
+
w,
|
|
162
|
+
g === "embed" && P
|
|
163
|
+
),
|
|
164
|
+
onClick: (e) => {
|
|
165
|
+
e.stopPropagation(), C("embed");
|
|
166
|
+
},
|
|
167
|
+
title: "Embed",
|
|
168
|
+
children: /* @__PURE__ */ o(he, {})
|
|
169
|
+
}
|
|
170
|
+
)
|
|
171
|
+
] }),
|
|
172
|
+
/* @__PURE__ */ o("div", { className: "cteditor-w-px cteditor-h-6 cteditor-bg-border cteditor-flex-shrink-0" }),
|
|
173
|
+
/* @__PURE__ */ j("div", { className: K, children: [
|
|
174
|
+
/* @__PURE__ */ o(
|
|
175
|
+
"button",
|
|
176
|
+
{
|
|
177
|
+
type: "button",
|
|
178
|
+
className: N(
|
|
179
|
+
w,
|
|
180
|
+
p === "left" && P
|
|
181
|
+
),
|
|
182
|
+
onClick: (e) => {
|
|
183
|
+
e.stopPropagation(), q(p === "left" ? "none" : "left");
|
|
184
|
+
},
|
|
185
|
+
title: "Wrap text left (text beside card)",
|
|
186
|
+
children: /* @__PURE__ */ o(be, {})
|
|
187
|
+
}
|
|
188
|
+
),
|
|
189
|
+
/* @__PURE__ */ o(
|
|
190
|
+
"button",
|
|
191
|
+
{
|
|
192
|
+
type: "button",
|
|
193
|
+
className: N(
|
|
194
|
+
w,
|
|
195
|
+
p === "right" && P
|
|
196
|
+
),
|
|
197
|
+
onClick: (e) => {
|
|
198
|
+
e.stopPropagation(), q(p === "right" ? "none" : "right");
|
|
199
|
+
},
|
|
200
|
+
title: "Wrap text right (text beside card)",
|
|
201
|
+
children: /* @__PURE__ */ o(ye, {})
|
|
202
|
+
}
|
|
203
|
+
)
|
|
204
|
+
] }),
|
|
205
|
+
/* @__PURE__ */ o("div", { className: "cteditor-w-px cteditor-h-6 cteditor-bg-border cteditor-flex-shrink-0" }),
|
|
206
|
+
/* @__PURE__ */ j("div", { className: K, children: [
|
|
207
|
+
/* @__PURE__ */ o(
|
|
208
|
+
"button",
|
|
209
|
+
{
|
|
210
|
+
type: "button",
|
|
211
|
+
className: N(
|
|
212
|
+
w,
|
|
213
|
+
A === "left" && P
|
|
214
|
+
),
|
|
215
|
+
onClick: (e) => {
|
|
216
|
+
e.stopPropagation(), $("left");
|
|
217
|
+
},
|
|
218
|
+
title: "Align left",
|
|
219
|
+
children: /* @__PURE__ */ o(xe, {})
|
|
220
|
+
}
|
|
221
|
+
),
|
|
222
|
+
/* @__PURE__ */ o(
|
|
223
|
+
"button",
|
|
224
|
+
{
|
|
225
|
+
type: "button",
|
|
226
|
+
className: N(
|
|
227
|
+
w,
|
|
228
|
+
A === "center" && P
|
|
229
|
+
),
|
|
230
|
+
onClick: (e) => {
|
|
231
|
+
e.stopPropagation(), $("center");
|
|
232
|
+
},
|
|
233
|
+
title: "Align center",
|
|
234
|
+
children: /* @__PURE__ */ o(Ee, {})
|
|
235
|
+
}
|
|
236
|
+
),
|
|
237
|
+
/* @__PURE__ */ o(
|
|
238
|
+
"button",
|
|
239
|
+
{
|
|
240
|
+
type: "button",
|
|
241
|
+
className: N(
|
|
242
|
+
w,
|
|
243
|
+
A === "right" && P
|
|
244
|
+
),
|
|
245
|
+
onClick: (e) => {
|
|
246
|
+
e.stopPropagation(), $("right");
|
|
247
|
+
},
|
|
248
|
+
title: "Align right",
|
|
249
|
+
children: /* @__PURE__ */ o(Ce, {})
|
|
250
|
+
}
|
|
251
|
+
)
|
|
252
|
+
] }),
|
|
253
|
+
/* @__PURE__ */ o("div", { className: "cteditor-w-px cteditor-h-6 cteditor-bg-border cteditor-flex-shrink-0" }),
|
|
254
|
+
/* @__PURE__ */ o(
|
|
255
|
+
"button",
|
|
256
|
+
{
|
|
257
|
+
type: "button",
|
|
258
|
+
className: Y,
|
|
259
|
+
onClick: z,
|
|
260
|
+
title: "Open in new tab",
|
|
261
|
+
children: /* @__PURE__ */ o(ve, { className: "cteditor-size-4" })
|
|
262
|
+
}
|
|
263
|
+
),
|
|
264
|
+
/* @__PURE__ */ o(
|
|
265
|
+
"button",
|
|
266
|
+
{
|
|
267
|
+
type: "button",
|
|
268
|
+
className: N(
|
|
269
|
+
Y,
|
|
270
|
+
"hover:cteditor-bg-destructive hover:cteditor-text-destructive-foreground"
|
|
271
|
+
),
|
|
272
|
+
onClick: D,
|
|
273
|
+
title: "Remove",
|
|
274
|
+
children: /* @__PURE__ */ o(Ne, { className: "cteditor-size-4" })
|
|
275
|
+
}
|
|
276
|
+
),
|
|
277
|
+
/* @__PURE__ */ o(
|
|
278
|
+
"button",
|
|
279
|
+
{
|
|
280
|
+
type: "button",
|
|
281
|
+
className: Y,
|
|
282
|
+
onClick: b,
|
|
283
|
+
title: "Copy",
|
|
284
|
+
children: /* @__PURE__ */ o(Ae, { className: "cteditor-size-4" })
|
|
285
|
+
}
|
|
286
|
+
)
|
|
287
|
+
]
|
|
288
|
+
}
|
|
289
|
+
);
|
|
290
|
+
}
|
|
291
|
+
function Pe(c, y) {
|
|
292
|
+
const [n, f] = M(null), [u, a] = M(""), d = (t) => t.includes("youtube.com") || t.includes("youtu.be") || t.includes("loom.com") || t.includes("vimeo.com") || t.includes("supercut.video") || t.includes("jam.dev") || t.includes("figma.com");
|
|
293
|
+
E(() => {
|
|
294
|
+
const t = (p) => {
|
|
295
|
+
const m = p, { nodeKey: r, url: l } = m.detail;
|
|
296
|
+
r && l && d(l) && (f(r), a(l));
|
|
297
|
+
};
|
|
298
|
+
return document.addEventListener("embedNodeSelected", t), () => {
|
|
299
|
+
document.removeEventListener(
|
|
300
|
+
"embedNodeSelected",
|
|
301
|
+
t
|
|
302
|
+
);
|
|
303
|
+
};
|
|
304
|
+
}, []);
|
|
305
|
+
const g = _(
|
|
306
|
+
(t) => {
|
|
307
|
+
if (!t) return;
|
|
308
|
+
const p = t.closest("[data-lexical-node-key]");
|
|
309
|
+
if (!p) return;
|
|
310
|
+
const m = p.getAttribute("data-lexical-node-key");
|
|
311
|
+
m && c.update(() => {
|
|
312
|
+
const r = T(m);
|
|
313
|
+
if (r instanceof k) {
|
|
314
|
+
const l = typeof r.getURL == "function" ? r.getURL() : r.__url;
|
|
315
|
+
if (d(l)) {
|
|
316
|
+
const h = G();
|
|
317
|
+
h.add(m), H(h), f(m), a(l);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
});
|
|
321
|
+
},
|
|
322
|
+
[c]
|
|
323
|
+
), i = _(() => {
|
|
324
|
+
c.getEditorState().read(() => {
|
|
325
|
+
const t = S();
|
|
326
|
+
if (te(t)) {
|
|
327
|
+
const m = t.getNodes()[0];
|
|
328
|
+
if (m instanceof k) {
|
|
329
|
+
const r = typeof m.getURL == "function" ? m.getURL() : m.__url;
|
|
330
|
+
if (d(r)) {
|
|
331
|
+
f(m.getKey()), a(r);
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
f(null);
|
|
337
|
+
});
|
|
338
|
+
}, [c]);
|
|
339
|
+
E(() => {
|
|
340
|
+
const t = c.getRootElement();
|
|
341
|
+
if (!t) return;
|
|
342
|
+
const p = (m) => {
|
|
343
|
+
const r = m.target, l = r.closest(
|
|
344
|
+
'[data-embed-type="youtube"], [data-embed-type="loom"], [data-embed-type="vimeo"], [data-embed-type="figma"]'
|
|
345
|
+
);
|
|
346
|
+
if (l) {
|
|
347
|
+
const h = l.getAttribute("data-lexical-node-key");
|
|
348
|
+
if (h) {
|
|
349
|
+
c.update(() => {
|
|
350
|
+
const x = T(h);
|
|
351
|
+
if (x instanceof k) {
|
|
352
|
+
const L = typeof x.getURL == "function" ? x.getURL() : x.__url, C = G();
|
|
353
|
+
C.add(h), H(C), f(h), a(L);
|
|
354
|
+
}
|
|
355
|
+
});
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
g(r);
|
|
360
|
+
};
|
|
361
|
+
return t.addEventListener("mousedown", p), () => {
|
|
362
|
+
t.removeEventListener("mousedown", p);
|
|
363
|
+
};
|
|
364
|
+
}, [c, g]), E(() => ce(
|
|
365
|
+
c.registerUpdateListener(() => {
|
|
366
|
+
i();
|
|
367
|
+
}),
|
|
368
|
+
c.registerCommand(
|
|
369
|
+
de,
|
|
370
|
+
() => (i(), !1),
|
|
371
|
+
ne
|
|
372
|
+
)
|
|
373
|
+
), [c, i]);
|
|
374
|
+
const A = _(() => {
|
|
375
|
+
f(null);
|
|
376
|
+
}, []);
|
|
377
|
+
return n ? ke(
|
|
378
|
+
/* @__PURE__ */ o(
|
|
379
|
+
we,
|
|
380
|
+
{
|
|
381
|
+
editor: c,
|
|
382
|
+
anchorElem: y,
|
|
383
|
+
nodeKey: n,
|
|
384
|
+
url: u,
|
|
385
|
+
onClose: A
|
|
386
|
+
}
|
|
387
|
+
),
|
|
388
|
+
y
|
|
389
|
+
) : null;
|
|
390
|
+
}
|
|
391
|
+
function Te({
|
|
392
|
+
anchorElem: c
|
|
393
|
+
}) {
|
|
394
|
+
const [y] = ee(), n = c ?? (typeof document < "u" ? document.body : null);
|
|
395
|
+
return n ? Pe(y, n) : null;
|
|
396
|
+
}
|
|
397
|
+
const Re = [
|
|
398
|
+
"youtube.com",
|
|
399
|
+
"youtu.be",
|
|
400
|
+
"vimeo.com",
|
|
401
|
+
"loom.com",
|
|
402
|
+
"supercut.video",
|
|
403
|
+
"jam.dev"
|
|
404
|
+
];
|
|
405
|
+
function Se(c, y) {
|
|
406
|
+
try {
|
|
407
|
+
const u = new DOMParser().parseFromString(c, "text/html").body, a = (u.textContent || "").trim().replace(/\s+/g, " "), d = y.trim().replace(/\s+/g, " ");
|
|
408
|
+
return a && a !== d || !!u.querySelector(
|
|
409
|
+
"img,iframe,video,table,blockquote,figure,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code"
|
|
410
|
+
) ? !1 : u.querySelectorAll("a[href]").length === 1 ? !0 : a === d;
|
|
411
|
+
} catch {
|
|
412
|
+
return !1;
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
const qe = ({
|
|
416
|
+
floatingAnchorElem: c
|
|
417
|
+
}) => {
|
|
418
|
+
const y = c ?? (typeof document < "u" ? document.body : void 0), [n] = ee();
|
|
419
|
+
return E(() => {
|
|
420
|
+
const f = n.getRootElement();
|
|
421
|
+
if (!f) return;
|
|
422
|
+
const u = (a) => {
|
|
423
|
+
const d = a.target;
|
|
424
|
+
if (d.closest('a[download], a[href*=".mp4"], a[href*=".webm"], a[href*=".ogg"], a[href*=".pdf"], a[href*=".doc"], a[href*=".docx"], a[href*=".xls"], a[href*=".xlsx"], a[href*=".ppt"], a[href*=".pptx"], a[href*=".zip"], a[href*=".rar"], a[href*=".txt"], a[href*=".csv"], a[href*=".json"], a[href*=".png"], a[href*=".jpg"], a[href*=".jpeg"], a[href*=".gif"], a[href*=".webp"], a[href*=".svg"]')) return;
|
|
425
|
+
const i = d.closest("[data-lexical-node-key]");
|
|
426
|
+
if (!i || !(i.querySelector("iframe") || i.querySelector("video") || i.getAttribute("data-embed-type"))) return;
|
|
427
|
+
const t = i.getAttribute("data-lexical-node-key");
|
|
428
|
+
if (!t) return;
|
|
429
|
+
a.preventDefault(), a.stopPropagation();
|
|
430
|
+
const p = i.getBoundingClientRect();
|
|
431
|
+
n.update(() => {
|
|
432
|
+
const m = T(t);
|
|
433
|
+
if (m instanceof k) {
|
|
434
|
+
const r = m.__url, l = G();
|
|
435
|
+
l.add(t), H(l);
|
|
436
|
+
const h = new CustomEvent("embedNodeSelected", {
|
|
437
|
+
detail: {
|
|
438
|
+
nodeKey: t,
|
|
439
|
+
url: r,
|
|
440
|
+
rect: p
|
|
441
|
+
},
|
|
442
|
+
bubbles: !0
|
|
443
|
+
});
|
|
444
|
+
document.dispatchEvent(h);
|
|
445
|
+
}
|
|
446
|
+
});
|
|
447
|
+
};
|
|
448
|
+
return f.addEventListener("click", u, !0), () => {
|
|
449
|
+
f.removeEventListener("click", u, !0);
|
|
450
|
+
};
|
|
451
|
+
}, [n]), E(() => n.registerCommand(
|
|
452
|
+
le,
|
|
453
|
+
(f) => {
|
|
454
|
+
const u = S();
|
|
455
|
+
if (!u || !te(u)) return !1;
|
|
456
|
+
const a = u.getNodes();
|
|
457
|
+
if (a.length !== 1) return !1;
|
|
458
|
+
const d = a[0];
|
|
459
|
+
if (!(d instanceof k)) return !1;
|
|
460
|
+
f.preventDefault();
|
|
461
|
+
const g = W(), i = d.getParent();
|
|
462
|
+
return i && V(i) ? d.insertAfter(g) : i ? i.insertAfter(g) : d.insertAfter(g), g.selectStart(), !0;
|
|
463
|
+
},
|
|
464
|
+
ne
|
|
465
|
+
), [n]), E(() => n.registerCommand(
|
|
466
|
+
ue,
|
|
467
|
+
(f) => {
|
|
468
|
+
const u = f.clipboardData;
|
|
469
|
+
if (!u) return !1;
|
|
470
|
+
const a = S();
|
|
471
|
+
if (!U(a)) return !1;
|
|
472
|
+
const d = u.getData("application/x-lexical-editor");
|
|
473
|
+
if (d)
|
|
474
|
+
try {
|
|
475
|
+
const l = JSON.parse(d);
|
|
476
|
+
if (l && Array.isArray(l.nodes) && l.nodes.length > 0)
|
|
477
|
+
return f.preventDefault(), n.update(
|
|
478
|
+
() => {
|
|
479
|
+
const h = S();
|
|
480
|
+
U(h) && se(u, h, n);
|
|
481
|
+
},
|
|
482
|
+
{ tag: "paste" }
|
|
483
|
+
), !0;
|
|
484
|
+
} catch {
|
|
485
|
+
}
|
|
486
|
+
const g = u.getData("text/html");
|
|
487
|
+
if (g && g.includes("data-lexical-embed-node"))
|
|
488
|
+
try {
|
|
489
|
+
const h = new DOMParser().parseFromString(g, "text/html"), x = h.querySelectorAll('[data-lexical-embed-node="1"]');
|
|
490
|
+
if (x.length > 0) {
|
|
491
|
+
const L = (h.body.textContent || "").trim();
|
|
492
|
+
let C = "";
|
|
493
|
+
x.forEach((z) => {
|
|
494
|
+
C += z.textContent || "";
|
|
495
|
+
});
|
|
496
|
+
const $ = L.replace(C, "").trim(), q = !!h.body.querySelector(
|
|
497
|
+
"p,h1,h2,h3,h4,h5,h6,ul,ol,li,blockquote,table,pre"
|
|
498
|
+
);
|
|
499
|
+
if ($.length === 0 && !q)
|
|
500
|
+
return f.preventDefault(), n.update(
|
|
501
|
+
() => {
|
|
502
|
+
const z = S();
|
|
503
|
+
if (!U(z)) return;
|
|
504
|
+
const D = [];
|
|
505
|
+
x.forEach((b) => {
|
|
506
|
+
const B = b.getAttribute("data-embed-url"), e = b.getAttribute("data-embed-display-type") || "embed", s = b.getAttribute("data-embed-alignment") || "left", R = b.getAttribute("data-embed-position") || "none", v = Number(b.getAttribute("data-embed-width")) || 560, I = Number(b.getAttribute("data-embed-height")) || 315;
|
|
507
|
+
B && D.push(
|
|
508
|
+
Z(
|
|
509
|
+
B,
|
|
510
|
+
e,
|
|
511
|
+
s,
|
|
512
|
+
v,
|
|
513
|
+
I,
|
|
514
|
+
R
|
|
515
|
+
)
|
|
516
|
+
);
|
|
517
|
+
}), D.length > 0 && D.forEach((b, B) => {
|
|
518
|
+
const e = S();
|
|
519
|
+
if (U(e) && (e.insertNodes([b]), V(b.getParentOrThrow()) && J(b, W).selectEnd(), B < D.length - 1)) {
|
|
520
|
+
const s = S();
|
|
521
|
+
U(s) && s.insertParagraph();
|
|
522
|
+
}
|
|
523
|
+
});
|
|
524
|
+
},
|
|
525
|
+
{ tag: "paste" }
|
|
526
|
+
), !0;
|
|
527
|
+
}
|
|
528
|
+
} catch {
|
|
529
|
+
}
|
|
530
|
+
const i = u.getData("text/plain").trim();
|
|
531
|
+
if (!i.match(/^https?:\/\//) || g && !Se(g, i))
|
|
532
|
+
return !1;
|
|
533
|
+
const A = a.anchor.getNode();
|
|
534
|
+
let t = !1, p = A;
|
|
535
|
+
for (; p; ) {
|
|
536
|
+
if (ae(p)) {
|
|
537
|
+
t = !0;
|
|
538
|
+
break;
|
|
539
|
+
}
|
|
540
|
+
p = p.getParent();
|
|
541
|
+
}
|
|
542
|
+
if (t)
|
|
543
|
+
return a.insertText(i), !0;
|
|
544
|
+
const m = Re.some((l) => i.includes(l)), r = Z(i);
|
|
545
|
+
return m ? r.setDisplayType("embed") : i.match(/\.(pdf|docx?|xlsx?|pptx?|zip|rar|txt)$/) || i.includes("figma.com") ? r.setDisplayType("card") : r.setDisplayType("url"), a.insertNodes([r]), V(r.getParentOrThrow()) && J(r, W).selectEnd(), !0;
|
|
546
|
+
},
|
|
547
|
+
me
|
|
548
|
+
), [n]), /* @__PURE__ */ o(re, { children: /* @__PURE__ */ o(Te, { anchorElem: y }) });
|
|
549
|
+
};
|
|
550
|
+
export {
|
|
551
|
+
qe as default
|
|
552
|
+
};
|