@fileverse-dev/ddoc 2.1.4-patch-20 → 2.1.4-patch-21
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/index.es.js
CHANGED
@@ -140175,71 +140175,86 @@ else {
|
|
140175
140175
|
}
|
140176
140176
|
const rF = ({
|
140177
140177
|
link: t,
|
140178
|
-
metadataProxyUrl: e
|
140178
|
+
metadataProxyUrl: e,
|
140179
|
+
hoverEvent: n
|
140179
140180
|
}) => {
|
140180
|
-
const [
|
140181
|
-
|
140182
|
-
|
140183
|
-
|
140184
|
-
|
140185
|
-
|
140186
|
-
|
140187
|
-
(async () => {
|
140181
|
+
const [r, i] = Pe(null), [a, s] = Pe(!1), o = Ge(/* @__PURE__ */ new Map()), l = async (c) => {
|
140182
|
+
if (c) {
|
140183
|
+
if (o.current.has(c)) {
|
140184
|
+
i(o.current.get(c)), s(!1);
|
140185
|
+
return;
|
140186
|
+
}
|
140187
|
+
s(!0);
|
140188
140188
|
try {
|
140189
|
-
|
140190
|
-
|
140191
|
-
|
140192
|
-
|
140193
|
-
|
140194
|
-
|
140195
|
-
|
140196
|
-
|
140197
|
-
link: t
|
140189
|
+
const u = await fetch(
|
140190
|
+
`${e}/${encodeURIComponent(c)}`
|
140191
|
+
), { metadata: f } = await u.json(), d = {
|
140192
|
+
title: f.title,
|
140193
|
+
description: f.description,
|
140194
|
+
image: f.image,
|
140195
|
+
favicon: f.favicon,
|
140196
|
+
link: c
|
140198
140197
|
};
|
140199
|
-
|
140200
|
-
|
140201
|
-
|
140202
|
-
}
|
140203
|
-
|
140198
|
+
o.current.set(c, d), i(d);
|
140199
|
+
} catch (u) {
|
140200
|
+
console.error("Error fetching link preview:", u), i(null);
|
140201
|
+
} finally {
|
140202
|
+
s(!1);
|
140204
140203
|
}
|
140205
|
-
}
|
140206
|
-
}
|
140207
|
-
|
140204
|
+
}
|
140205
|
+
};
|
140206
|
+
return ze(() => {
|
140207
|
+
t && l(t);
|
140208
|
+
}, [t]), ze(() => {
|
140209
|
+
const c = (u) => {
|
140210
|
+
u.detail ? o.current.has(t) ? (i(o.current.get(t)), s(!1)) : l(t) : i(null);
|
140211
|
+
};
|
140212
|
+
return n.addEventListener(
|
140213
|
+
"hoverStateChange",
|
140214
|
+
c
|
140215
|
+
), () => {
|
140216
|
+
n.removeEventListener(
|
140217
|
+
"hoverStateChange",
|
140218
|
+
c
|
140219
|
+
);
|
140220
|
+
};
|
140221
|
+
}, [n, t]), /* @__PURE__ */ A.jsx("div", { className: "w-[250px] border color-border-default shadow-elevation-3 rounded p-3 flex flex-col gap-2 justify-center hover-link-popup color-bg-default", children: a ? /* @__PURE__ */ A.jsx("p", { className: "text-helper-text-sm color-text-secondary", children: "Loading preview..." }) : r ? /* @__PURE__ */ A.jsxs(A.Fragment, { children: [
|
140222
|
+
r.image && /* @__PURE__ */ A.jsx(
|
140208
140223
|
"img",
|
140209
140224
|
{
|
140210
|
-
src:
|
140225
|
+
src: r.image,
|
140211
140226
|
className: "w-[225px] h-[125px] object-contain rounded",
|
140212
140227
|
alt: "Preview",
|
140213
|
-
onError: (
|
140214
|
-
|
140228
|
+
onError: (c) => {
|
140229
|
+
c.currentTarget.style.display = "none";
|
140215
140230
|
}
|
140216
140231
|
}
|
140217
140232
|
),
|
140218
140233
|
/* @__PURE__ */ A.jsxs("div", { className: "flex flex-col gap-2", children: [
|
140219
|
-
(
|
140220
|
-
|
140221
|
-
|
140234
|
+
(r.title || r.description) && /* @__PURE__ */ A.jsxs("div", { className: "flex flex-col gap-[2px]", children: [
|
140235
|
+
r.title && /* @__PURE__ */ A.jsx("p", { className: "text-heading-xsm w-full truncate color-text-default select-text", children: r.title }),
|
140236
|
+
r.description && /* @__PURE__ */ A.jsx("p", { className: "text-helper-text-sm color-text-secondary w-full truncate select-text", children: r.description })
|
140222
140237
|
] }),
|
140223
140238
|
/* @__PURE__ */ A.jsxs("div", { className: "flex gap-2", children: [
|
140224
|
-
|
140239
|
+
r.favicon && /* @__PURE__ */ A.jsx(
|
140225
140240
|
"img",
|
140226
140241
|
{
|
140227
|
-
src:
|
140242
|
+
src: r.favicon,
|
140228
140243
|
className: "w-[18px] aspect-square rounded",
|
140229
140244
|
alt: "Favicon",
|
140230
|
-
onError: (
|
140231
|
-
|
140245
|
+
onError: (c) => {
|
140246
|
+
c.currentTarget.style.display = "none";
|
140232
140247
|
}
|
140233
140248
|
}
|
140234
140249
|
),
|
140235
|
-
|
140250
|
+
r.link && /* @__PURE__ */ A.jsx(
|
140236
140251
|
"a",
|
140237
140252
|
{
|
140238
|
-
href:
|
140253
|
+
href: r.link,
|
140239
140254
|
target: "_blank",
|
140240
140255
|
rel: "noopener noreferrer",
|
140241
140256
|
className: "text-helper-text-sm color-text-link w-full truncate hover:underline hover:cursor-pointer",
|
140242
|
-
children:
|
140257
|
+
children: r.link
|
140243
140258
|
}
|
140244
140259
|
)
|
140245
140260
|
] })
|
@@ -140252,28 +140267,32 @@ const rF = ({
|
|
140252
140267
|
return [];
|
140253
140268
|
const t = new Cn("link-preview");
|
140254
140269
|
let e = null, n = null, r = null, i = null;
|
140270
|
+
const a = new EventTarget();
|
140255
140271
|
return [
|
140256
140272
|
new hn({
|
140257
140273
|
key: t,
|
140258
140274
|
props: {
|
140259
140275
|
handleDOMEvents: {
|
140260
|
-
mouseover: (
|
140261
|
-
const
|
140262
|
-
if (
|
140263
|
-
const
|
140264
|
-
if (!
|
140265
|
-
e || (e = document.createElement("div"), e.className = "hover-link-popup", e.style.position = "absolute", e.style.zIndex = "999", document.body.appendChild(e)), r ===
|
140276
|
+
mouseover: (s, o) => {
|
140277
|
+
const c = o.target.closest("a");
|
140278
|
+
if (c) {
|
140279
|
+
const u = c.getAttribute("href");
|
140280
|
+
if (!u) return !1;
|
140281
|
+
e || (e = document.createElement("div"), e.className = "hover-link-popup", e.style.position = "absolute", e.style.zIndex = "999", document.body.appendChild(e)), r === c && setTimeout(() => {
|
140266
140282
|
if (e)
|
140267
|
-
return e.style.display = "block",
|
140268
|
-
|
140269
|
-
|
140270
|
-
|
140283
|
+
return e.style.display = "block", a.dispatchEvent(
|
140284
|
+
new CustomEvent("hoverStateChange", { detail: !0 })
|
140285
|
+
), !1;
|
140286
|
+
}, 600), r = c;
|
140287
|
+
const f = c.getBoundingClientRect();
|
140288
|
+
e.style.left = `${f.left}px`, e.style.top = `${f.bottom + 5}px`, setTimeout(() => {
|
140271
140289
|
e && (e.style.display = "block", n || (n = P8(e))), n && n.render(
|
140272
140290
|
/* @__PURE__ */ A.jsx(
|
140273
140291
|
rF,
|
140274
140292
|
{
|
140275
|
-
link:
|
140276
|
-
metadataProxyUrl: this.options.metadataProxyUrl
|
140293
|
+
link: u,
|
140294
|
+
metadataProxyUrl: this.options.metadataProxyUrl,
|
140295
|
+
hoverEvent: a
|
140277
140296
|
}
|
140278
140297
|
)
|
140279
140298
|
);
|
@@ -140281,28 +140300,33 @@ const rF = ({
|
|
140281
140300
|
}
|
140282
140301
|
return !1;
|
140283
140302
|
},
|
140284
|
-
mouseout: (
|
140285
|
-
const
|
140303
|
+
mouseout: (s, o) => {
|
140304
|
+
const l = o.relatedTarget;
|
140286
140305
|
return i && clearTimeout(i), i = setTimeout(() => {
|
140287
|
-
e && !e.contains(
|
140288
|
-
|
140306
|
+
e && !e.contains(l) && !(l != null && l.closest(".hover-link-popup")) && (e.style.display = "none", a.dispatchEvent(
|
140307
|
+
new CustomEvent("hoverStateChange", { detail: !1 })
|
140308
|
+
));
|
140309
|
+
}, 100), !1;
|
140289
140310
|
},
|
140290
|
-
touchstart: (
|
140291
|
-
const
|
140292
|
-
if (
|
140293
|
-
const
|
140294
|
-
if (!
|
140295
|
-
e || (e = document.createElement("div"), e.className = "hover-link-popup", e.style.position = "absolute", e.style.zIndex = "999", document.body.appendChild(e)), r =
|
140296
|
-
const
|
140297
|
-
e.style.left = `${
|
140311
|
+
touchstart: (s, o) => {
|
140312
|
+
const c = o.target.closest("a");
|
140313
|
+
if (c) {
|
140314
|
+
const u = c.getAttribute("href");
|
140315
|
+
if (!u) return !1;
|
140316
|
+
e || (e = document.createElement("div"), e.className = "hover-link-popup", e.style.position = "absolute", e.style.zIndex = "999", document.body.appendChild(e)), r = c;
|
140317
|
+
const f = c.getBoundingClientRect();
|
140318
|
+
e.style.left = `${f.left}px`, e.style.top = `${f.bottom + 5}px`, setTimeout(() => {
|
140298
140319
|
e && (e.style.display = "block", n || (n = P8(e)), n.render(
|
140299
140320
|
/* @__PURE__ */ A.jsx(
|
140300
140321
|
rF,
|
140301
140322
|
{
|
140302
|
-
link:
|
140303
|
-
metadataProxyUrl: this.options.metadataProxyUrl
|
140323
|
+
link: u,
|
140324
|
+
metadataProxyUrl: this.options.metadataProxyUrl,
|
140325
|
+
hoverEvent: a
|
140304
140326
|
}
|
140305
140327
|
)
|
140328
|
+
), a.dispatchEvent(
|
140329
|
+
new CustomEvent("hoverStateChange", { detail: !0 })
|
140306
140330
|
));
|
140307
140331
|
}, 600);
|
140308
140332
|
}
|
@@ -5,7 +5,8 @@ export interface LinkPreviewData {
|
|
5
5
|
favicon: string;
|
6
6
|
link: string;
|
7
7
|
}
|
8
|
-
export declare const LinkPreviewCard: ({ link, metadataProxyUrl, }: {
|
8
|
+
export declare const LinkPreviewCard: ({ link, metadataProxyUrl, hoverEvent, }: {
|
9
9
|
link: string;
|
10
10
|
metadataProxyUrl: string;
|
11
|
+
hoverEvent: EventTarget;
|
11
12
|
}) => import("react/jsx-runtime").JSX.Element;
|