@haklex/rich-renderer-linkcard 0.0.4 → 0.0.5

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.
@@ -1 +1 @@
1
- {"version":3,"file":"LinkCardEditDecorator.d.ts","sourceRoot":"","sources":["../src/LinkCardEditDecorator.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAK/E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAGzC,UAAU,0BAA0B;IAClC,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,mBAAmB,CAAA;IAC5B,QAAQ,EAAE,YAAY,CAAA;CACvB;AAED,wBAAgB,qBAAqB,CAAC,EACpC,OAAO,EACP,OAAO,EACP,QAAQ,GACT,EAAE,0BAA0B,2CAoH5B"}
1
+ {"version":3,"file":"LinkCardEditDecorator.d.ts","sourceRoot":"","sources":["../src/LinkCardEditDecorator.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAK/E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAKzC,UAAU,0BAA0B;IAClC,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,mBAAmB,CAAA;IAC5B,QAAQ,EAAE,YAAY,CAAA;CACvB;AAED,wBAAgB,qBAAqB,CAAC,EACpC,OAAO,EACP,OAAO,EACP,QAAQ,GACT,EAAE,0BAA0B,2CA+H5B"}
@@ -1 +1 @@
1
- {"version":3,"file":"LinkCardRenderer.d.ts","sourceRoot":"","sources":["../src/LinkCardRenderer.tsx"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAA;AAErB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAEhE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAO1C,OAAO,KAAK,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAEnE,MAAM,WAAW,qBAAsB,SAAQ,qBAAqB;IAClE,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB,YAAY,CAAC,EAAE,oBAAoB,CAAA;CACpC;AAgBD,eAAO,MAAM,gBAAgB,EAAE,aAAa,CAAC,qBAAqB,CAqJjE,CAAA"}
1
+ {"version":3,"file":"LinkCardRenderer.d.ts","sourceRoot":"","sources":["../src/LinkCardRenderer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAEhE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAQ1C,OAAO,KAAK,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAEnE,MAAM,WAAW,qBAAsB,SAAQ,qBAAqB;IAClE,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB,YAAY,CAAC,EAAE,oBAAoB,CAAA;CACpC;AA6BD,eAAO,MAAM,gBAAgB,EAAE,aAAa,CAAC,qBAAqB,CA6KjE,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"LinkCardSkeleton.d.ts","sourceRoot":"","sources":["../src/LinkCardSkeleton.tsx"],"names":[],"mappings":"AAEA,wBAAgB,gBAAgB,CAAC,EAC/B,MAAM,EACN,SAAS,GACV,EAAE;IACD,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,2CAsBA"}
1
+ {"version":3,"file":"LinkCardSkeleton.d.ts","sourceRoot":"","sources":["../src/LinkCardSkeleton.tsx"],"names":[],"mappings":"AAGA,wBAAgB,gBAAgB,CAAC,EAC/B,MAAM,EACN,SAAS,GACV,EAAE;IACD,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,2CAwCA"}
package/dist/index.mjs CHANGED
@@ -28,14 +28,14 @@ const arxivPlugin = {
28
28
  const parser = new DOMParser();
29
29
  const xmlDoc = parser.parseFromString(text, "application/xml");
30
30
  const entry = xmlDoc.getElementsByTagName("entry")[0];
31
- const title = entry.getElementsByTagName("title")[0].textContent;
31
+ const title2 = entry.getElementsByTagName("title")[0].textContent;
32
32
  const authors = entry.getElementsByTagName("author");
33
33
  const authorNames = Array.from(authors).map(
34
34
  (author) => author.getElementsByTagName("name")[0].textContent
35
35
  );
36
36
  return {
37
37
  title: /* @__PURE__ */ jsxs("span", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
38
- /* @__PURE__ */ jsx("span", { style: { flex: 1 }, children: title }),
38
+ /* @__PURE__ */ jsx("span", { style: { flex: 1 }, children: title2 }),
39
39
  /* @__PURE__ */ jsx("span", { style: { flexShrink: 0 }, children: /* @__PURE__ */ jsx(
40
40
  "span",
41
41
  {
@@ -627,14 +627,14 @@ const bangumiPlugin = {
627
627
  const json = await fetch(`/api/bangumi/${type}/${realId}`).then(
628
628
  (r) => r.json()
629
629
  );
630
- let title = "";
630
+ let title2 = "";
631
631
  let originalTitle = "";
632
632
  if (type === "subject") {
633
633
  if (json.name_cn && json.name_cn !== json.name && json.name_cn !== "") {
634
- title = json.name_cn;
634
+ title2 = json.name_cn;
635
635
  originalTitle = json.name;
636
636
  } else {
637
- title = json.name;
637
+ title2 = json.name;
638
638
  originalTitle = json.name;
639
639
  }
640
640
  } else if (type === "character" || type === "person") {
@@ -642,7 +642,7 @@ const bangumiPlugin = {
642
642
  infobox.forEach(
643
643
  (item) => {
644
644
  if (item.key === "简体中文名") {
645
- title = typeof item.value === "string" ? item.value : item.value[0].v;
645
+ title2 = typeof item.value === "string" ? item.value : item.value[0].v;
646
646
  } else if (item.key === "别名") {
647
647
  const aliases = item.value;
648
648
  aliases.forEach((alias) => {
@@ -673,8 +673,8 @@ const bangumiPlugin = {
673
673
  gap: "8px"
674
674
  },
675
675
  children: [
676
- /* @__PURE__ */ jsx("span", { children: title }),
677
- title !== originalTitle && /* @__PURE__ */ jsxs("span", { style: { fontSize: "0.875rem", opacity: 0.7 }, children: [
676
+ /* @__PURE__ */ jsx("span", { children: title2 }),
677
+ title2 !== originalTitle && /* @__PURE__ */ jsxs("span", { style: { fontSize: "0.875rem", opacity: 0.7 }, children: [
678
678
  "(",
679
679
  originalTitle,
680
680
  ")"
@@ -710,7 +710,7 @@ const bangumiPlugin = {
710
710
  ),
711
711
  desc: /* @__PURE__ */ jsx("span", { style: { overflow: "visible", whiteSpace: "pre-wrap" }, children: json.summary }),
712
712
  image: json.images.grid,
713
- color: generateColor(title),
713
+ color: generateColor(title2),
714
714
  classNames: {
715
715
  image: type === "subject" ? "link-card__image--poster-md" : "link-card__image--poster-sm",
716
716
  cardRoot: "link-card--reversed"
@@ -877,7 +877,7 @@ const tmdbPlugin = {
877
877
  const json = await fetch(
878
878
  `/api/tmdb/${type}/${realId}?language=${userLanguage}`
879
879
  ).then((r) => r.json());
880
- const title = type === "tv" ? json.name : json.title;
880
+ const title2 = type === "tv" ? json.name : json.title;
881
881
  const originalTitle = type === "tv" ? json.original_name : json.original_title;
882
882
  return {
883
883
  title: /* @__PURE__ */ jsxs(
@@ -890,8 +890,8 @@ const tmdbPlugin = {
890
890
  gap: "8px"
891
891
  },
892
892
  children: [
893
- /* @__PURE__ */ jsx("span", { children: title }),
894
- title !== originalTitle && /* @__PURE__ */ jsxs("span", { style: { fontSize: "0.875rem", opacity: 0.7 }, children: [
893
+ /* @__PURE__ */ jsx("span", { children: title2 }),
894
+ title2 !== originalTitle && /* @__PURE__ */ jsxs("span", { style: { fontSize: "0.875rem", opacity: 0.7 }, children: [
895
895
  "(",
896
896
  originalTitle,
897
897
  ")"
@@ -919,7 +919,7 @@ const tmdbPlugin = {
919
919
  ),
920
920
  desc: /* @__PURE__ */ jsx("span", { style: { overflow: "visible", whiteSpace: "pre-wrap" }, children: json.overview }),
921
921
  image: `https://image.tmdb.org/t/p/w500${json.poster_path}`,
922
- color: generateColor(title || originalTitle || id),
922
+ color: generateColor(title2 || originalTitle || id),
923
923
  classNames: {
924
924
  image: "link-card__image--poster",
925
925
  cardRoot: "link-card--reversed"
@@ -1027,6 +1027,31 @@ function useUrlMatcher(url, pluginRegistry = plugins) {
1027
1027
  return null;
1028
1028
  }, [url, pluginRegistry]);
1029
1029
  }
1030
+ var semanticClassNames = { card: "link-card", cardShortDesc: "link-card--short-desc", cardSkeleton: "link-card--skeleton", cardError: "link-card--error", bg: "link-card__bg", image: "link-card__image", icon: "link-card__icon", content: "link-card__content", title: "link-card__title", titleText: "link-card__title-text", external: "link-card__external", desc: "link-card__desc", desc2: "link-card__desc-2", editWrapper: "rich-link-card-edit-wrapper", editPanel: "rich-link-card-edit-panel", editUrlRow: "rich-link-card-edit-url-row", editLinkIcon: "rich-link-card-edit-link-icon", editInput: "rich-link-card-edit-input", editActions: "rich-link-card-edit-actions", editActionButton: "rich-link-card-edit-action-btn", editActionButtonEnd: "rich-link-card-edit-action-btn--end" };
1031
+ var card = "_13weebv0";
1032
+ var cardShortDesc = "_13weebv1";
1033
+ var bg = "_13weebv2";
1034
+ var image = "_13weebv3";
1035
+ var icon = "_13weebv7";
1036
+ var content = "_13weebv8";
1037
+ var title = "_13weebv9";
1038
+ var titleText = "_13weebva";
1039
+ var external = "_13weebvb";
1040
+ var desc = "_13weebvc";
1041
+ var desc2 = "_13weebvd";
1042
+ var cardSkeleton = "_13weebvl";
1043
+ var cardError = "_13weebvn";
1044
+ var editWrapper = "_13weebvo";
1045
+ var editPanel = "_13weebvp";
1046
+ var editUrlRow = "_13weebvq";
1047
+ var editLinkIcon = "_13weebvr";
1048
+ var editInput = "_13weebvt";
1049
+ var editActions = "_13weebvu";
1050
+ var editActionButton = "_13weebvv";
1051
+ var editActionButtonEnd = "_13weebvw";
1052
+ var typeCardModifier = { media: "_13weebvi", github: "_13weebvj", academic: "_13weebvk", wide: "_13weebvg", full: "_13weebvh" };
1053
+ var semanticTypeClassNames = { media: "link-card--media", github: "link-card--github", academic: "link-card--academic", wide: "link-card--wide", full: "link-card--full" };
1054
+ var semanticClassToStyle = { "link-card--short-desc": "_13weebv1", "link-card--skeleton": "_13weebvl", "link-card--error": "_13weebvn", "link-card--reversed": "_13weebvf", "link-card--wide": "_13weebvg", "link-card--full": "_13weebvh", "link-card--media": "_13weebvi", "link-card--github": "_13weebvj", "link-card--academic": "_13weebvk", "link-card__image--poster": "_13weebv4", "link-card__image--poster-md": "_13weebv5", "link-card__image--poster-sm": "_13weebv6" };
1030
1055
  function LinkCardEditDecorator({
1031
1056
  nodeKey,
1032
1057
  payload,
@@ -1096,7 +1121,12 @@ function LinkCardEditDecorator({
1096
1121
  delay: 200,
1097
1122
  closeDelay: 300,
1098
1123
  openOnHover: true,
1099
- render: /* @__PURE__ */ jsx("span", { className: "rich-link-card-edit-wrapper" }),
1124
+ render: /* @__PURE__ */ jsx(
1125
+ "span",
1126
+ {
1127
+ className: `${editWrapper} ${semanticClassNames.editWrapper}`
1128
+ }
1129
+ ),
1100
1130
  children
1101
1131
  }
1102
1132
  ),
@@ -1105,50 +1135,68 @@ function LinkCardEditDecorator({
1105
1135
  {
1106
1136
  side: "bottom",
1107
1137
  sideOffset: 8,
1108
- className: "rich-link-card-edit-panel",
1138
+ className: `${editPanel} ${semanticClassNames.editPanel}`,
1109
1139
  children: [
1110
- /* @__PURE__ */ jsxs("div", { className: "rich-link-card-edit-url-row", children: [
1111
- /* @__PURE__ */ jsx(Link, { className: "rich-link-card-edit-link-icon", size: 16 }),
1112
- /* @__PURE__ */ jsx(
1113
- "input",
1114
- {
1115
- ref: inputRef,
1116
- className: "rich-link-card-edit-input",
1117
- type: "url",
1118
- value: url,
1119
- onChange: (e) => setUrl(e.target.value),
1120
- onBlur: commitUrl,
1121
- onKeyDown: handleKeyDown,
1122
- placeholder: "https://..."
1123
- }
1124
- )
1125
- ] }),
1126
- /* @__PURE__ */ jsxs("div", { className: "rich-link-card-edit-actions", children: [
1127
- /* @__PURE__ */ jsxs(
1128
- "button",
1129
- {
1130
- className: "rich-link-card-edit-action-btn",
1131
- type: "button",
1132
- onClick: handleOpen,
1133
- children: [
1134
- /* @__PURE__ */ jsx(ExternalLink, { size: 14 }),
1135
- "Open"
1136
- ]
1137
- }
1138
- ),
1139
- /* @__PURE__ */ jsxs(
1140
- "button",
1141
- {
1142
- className: "rich-link-card-edit-action-btn rich-link-card-edit-action-btn--end",
1143
- type: "button",
1144
- onClick: handleDelete,
1145
- children: [
1146
- /* @__PURE__ */ jsx(Unlink, { size: 14 }),
1147
- "Remove"
1148
- ]
1149
- }
1150
- )
1151
- ] })
1140
+ /* @__PURE__ */ jsxs(
1141
+ "div",
1142
+ {
1143
+ className: `${editUrlRow} ${semanticClassNames.editUrlRow}`,
1144
+ children: [
1145
+ /* @__PURE__ */ jsx(
1146
+ Link,
1147
+ {
1148
+ className: `${editLinkIcon} ${semanticClassNames.editLinkIcon}`,
1149
+ size: 16
1150
+ }
1151
+ ),
1152
+ /* @__PURE__ */ jsx(
1153
+ "input",
1154
+ {
1155
+ ref: inputRef,
1156
+ className: `${editInput} ${semanticClassNames.editInput}`,
1157
+ type: "url",
1158
+ value: url,
1159
+ onChange: (e) => setUrl(e.target.value),
1160
+ onBlur: commitUrl,
1161
+ onKeyDown: handleKeyDown,
1162
+ placeholder: "https://..."
1163
+ }
1164
+ )
1165
+ ]
1166
+ }
1167
+ ),
1168
+ /* @__PURE__ */ jsxs(
1169
+ "div",
1170
+ {
1171
+ className: `${editActions} ${semanticClassNames.editActions}`,
1172
+ children: [
1173
+ /* @__PURE__ */ jsxs(
1174
+ "button",
1175
+ {
1176
+ className: `${editActionButton} ${semanticClassNames.editActionButton}`,
1177
+ type: "button",
1178
+ onClick: handleOpen,
1179
+ children: [
1180
+ /* @__PURE__ */ jsx(ExternalLink, { size: 14 }),
1181
+ "Open"
1182
+ ]
1183
+ }
1184
+ ),
1185
+ /* @__PURE__ */ jsxs(
1186
+ "button",
1187
+ {
1188
+ className: `${editActionButton} ${semanticClassNames.editActionButton} ${editActionButtonEnd} ${semanticClassNames.editActionButtonEnd}`,
1189
+ type: "button",
1190
+ onClick: handleDelete,
1191
+ children: [
1192
+ /* @__PURE__ */ jsx(Unlink, { size: 14 }),
1193
+ "Remove"
1194
+ ]
1195
+ }
1196
+ )
1197
+ ]
1198
+ }
1199
+ )
1152
1200
  ]
1153
1201
  }
1154
1202
  )
@@ -1247,35 +1295,67 @@ function LinkCardSkeleton({
1247
1295
  className
1248
1296
  }) {
1249
1297
  const plugin = source ? pluginMap.get(source) : void 0;
1250
- const typeClass = plugin?.typeClass ? `link-card--${plugin.typeClass}` : "";
1298
+ const typeClass = plugin?.typeClass;
1299
+ const typeStyleClass = typeClass ? typeCardModifier[typeClass] : "";
1300
+ const typeSemanticClass = typeClass ? semanticTypeClassNames[typeClass] : "";
1251
1301
  return /* @__PURE__ */ jsxs(
1252
1302
  "span",
1253
1303
  {
1254
1304
  "data-hide-print": true,
1255
1305
  "data-source": source || void 0,
1256
- className: ["link-card", "link-card--skeleton", typeClass, className].filter(Boolean).join(" "),
1306
+ className: [
1307
+ card,
1308
+ semanticClassNames.card,
1309
+ cardSkeleton,
1310
+ semanticClassNames.cardSkeleton,
1311
+ typeStyleClass,
1312
+ typeSemanticClass,
1313
+ className
1314
+ ].filter(Boolean).join(" "),
1257
1315
  children: [
1258
- /* @__PURE__ */ jsx("span", { className: "link-card__image" }),
1259
- /* @__PURE__ */ jsxs("span", { className: "link-card__content", children: [
1260
- /* @__PURE__ */ jsx("span", { className: "link-card__title", children: /* @__PURE__ */ jsx("span", { className: "link-card__title-text" }) }),
1261
- /* @__PURE__ */ jsx("span", { className: "link-card__desc" }),
1262
- /* @__PURE__ */ jsx("span", { className: "link-card__desc link-card__desc-2" })
1263
- ] })
1316
+ /* @__PURE__ */ jsx("span", { className: `${image} ${semanticClassNames.image}` }),
1317
+ /* @__PURE__ */ jsxs(
1318
+ "span",
1319
+ {
1320
+ className: `${content} ${semanticClassNames.content}`,
1321
+ children: [
1322
+ /* @__PURE__ */ jsx("span", { className: `${title} ${semanticClassNames.title}`, children: /* @__PURE__ */ jsx(
1323
+ "span",
1324
+ {
1325
+ className: `${titleText} ${semanticClassNames.titleText}`
1326
+ }
1327
+ ) }),
1328
+ /* @__PURE__ */ jsx("span", { className: `${desc} ${semanticClassNames.desc}` }),
1329
+ /* @__PURE__ */ jsx(
1330
+ "span",
1331
+ {
1332
+ className: `${desc} ${semanticClassNames.desc} ${desc2} ${semanticClassNames.desc2}`
1333
+ }
1334
+ )
1335
+ ]
1336
+ }
1337
+ )
1264
1338
  ]
1265
1339
  }
1266
1340
  );
1267
1341
  }
1268
1342
  function FallbackIcon({ favicon }) {
1269
1343
  const [faviconFailed, setFaviconFailed] = useState(false);
1270
- return /* @__PURE__ */ jsx("span", { className: "link-card__icon", children: favicon && !faviconFailed ? /* @__PURE__ */ jsx("img", { src: favicon, alt: "", onError: () => setFaviconFailed(true) }) : /* @__PURE__ */ jsx(Globe, { "aria-hidden": "true" }) });
1344
+ return /* @__PURE__ */ jsx("span", { className: `${icon} ${semanticClassNames.icon}`, children: favicon && !faviconFailed ? /* @__PURE__ */ jsx("img", { src: favicon, alt: "", onError: () => setFaviconFailed(true) }) : /* @__PURE__ */ jsx(Globe, { "aria-hidden": "true" }) });
1345
+ }
1346
+ function mapSemanticClasses(classNames) {
1347
+ if (!classNames) return "";
1348
+ return classNames.split(/\s+/).filter(Boolean).map(
1349
+ (cls) => semanticClassToStyle[cls] ? `${semanticClassToStyle[cls]} ${cls}` : cls
1350
+ ).join(" ");
1271
1351
  }
1272
1352
  const LinkCardRenderer = (props) => {
1273
1353
  const {
1274
1354
  url,
1275
- title,
1355
+ title: title$1,
1276
1356
  description,
1277
1357
  favicon,
1278
- image,
1358
+ image: image$1,
1279
1359
  source: explicitSource,
1280
1360
  id: explicitId,
1281
1361
  className,
@@ -1303,12 +1383,16 @@ const LinkCardRenderer = (props) => {
1303
1383
  enabled: useDynamicFetch,
1304
1384
  context: fetchContext
1305
1385
  });
1306
- const typeClass = selectedPlugin?.typeClass ? `link-card--${selectedPlugin.typeClass}` : "";
1307
- const finalTitle = cardInfo?.title || title || url;
1386
+ const typeClass = selectedPlugin?.typeClass;
1387
+ const typeStyleClass = typeClass ? typeCardModifier[typeClass] : "";
1388
+ const typeSemanticClass = typeClass ? semanticTypeClassNames[typeClass] : "";
1389
+ const finalTitle = cardInfo?.title || title$1 || url;
1308
1390
  const finalDesc = cardInfo?.desc || description;
1309
- const finalImage = cardInfo?.image || image;
1391
+ const finalImage = cardInfo?.image || image$1;
1310
1392
  const finalColor = cardInfo?.color;
1311
1393
  const classNames = cardInfo?.classNames || {};
1394
+ const mappedCardRootClass = mapSemanticClasses(classNames.cardRoot);
1395
+ const mappedImageClass = mapSemanticClasses(classNames.image);
1312
1396
  const [shortDesc, setShortDesc] = useState(false);
1313
1397
  const descRef = useRef(null);
1314
1398
  useLayoutEffect(() => {
@@ -1346,14 +1430,19 @@ const LinkCardRenderer = (props) => {
1346
1430
  "data-hide-print": true,
1347
1431
  ref: useDynamicFetch ? ref : void 0,
1348
1432
  className: [
1349
- "link-card",
1350
- typeClass,
1351
- shortDesc && "link-card--short-desc",
1352
- useDynamicFetch && (loading || isError) && "link-card--skeleton",
1353
- useDynamicFetch && isError && "link-card--error",
1433
+ card,
1434
+ semanticClassNames.card,
1435
+ typeStyleClass,
1436
+ typeSemanticClass,
1437
+ shortDesc && cardShortDesc,
1438
+ shortDesc && semanticClassNames.cardShortDesc,
1439
+ useDynamicFetch && (loading || isError) && cardSkeleton,
1440
+ useDynamicFetch && (loading || isError) && semanticClassNames.cardSkeleton,
1441
+ useDynamicFetch && isError && cardError,
1442
+ useDynamicFetch && isError && semanticClassNames.cardError,
1354
1443
  "not-prose",
1355
1444
  className,
1356
- classNames.cardRoot
1445
+ mappedCardRootClass
1357
1446
  ].filter(Boolean).join(" "),
1358
1447
  "data-source": source || void 0,
1359
1448
  href: useDynamicFetch ? fullUrl : url,
@@ -1366,7 +1455,7 @@ const LinkCardRenderer = (props) => {
1366
1455
  finalColor && /* @__PURE__ */ jsx(
1367
1456
  "div",
1368
1457
  {
1369
- className: "link-card__bg",
1458
+ className: `${bg} ${semanticClassNames.bg}`,
1370
1459
  style: {
1371
1460
  backgroundColor: finalColor,
1372
1461
  opacity: 0.04
@@ -1376,27 +1465,50 @@ const LinkCardRenderer = (props) => {
1376
1465
  hasImage || showImagePlaceholder ? /* @__PURE__ */ jsx(
1377
1466
  "span",
1378
1467
  {
1379
- className: ["link-card__image", classNames.image].filter(Boolean).join(" "),
1468
+ className: [
1469
+ image,
1470
+ semanticClassNames.image,
1471
+ mappedImageClass
1472
+ ].filter(Boolean).join(" "),
1380
1473
  "data-image": finalImage || "",
1381
1474
  style: {
1382
1475
  backgroundImage: finalImage ? `url(${finalImage})` : void 0
1383
1476
  }
1384
1477
  }
1385
1478
  ) : /* @__PURE__ */ jsx(FallbackIcon, { favicon }),
1386
- /* @__PURE__ */ jsxs("span", { className: "link-card__content", children: [
1387
- /* @__PURE__ */ jsxs("span", { className: "link-card__title", children: [
1388
- /* @__PURE__ */ jsx("span", { className: "link-card__title-text", children: finalTitle }),
1389
- /* @__PURE__ */ jsx(
1390
- ExternalLink,
1391
- {
1392
- className: "link-card__external",
1393
- "aria-hidden": "true",
1394
- focusable: false
1395
- }
1396
- )
1397
- ] }),
1398
- finalDesc && /* @__PURE__ */ jsx("span", { ref: descRef, className: "link-card__desc", children: finalDesc })
1399
- ] })
1479
+ /* @__PURE__ */ jsxs(
1480
+ "span",
1481
+ {
1482
+ className: `${content} ${semanticClassNames.content}`,
1483
+ children: [
1484
+ /* @__PURE__ */ jsxs("span", { className: `${title} ${semanticClassNames.title}`, children: [
1485
+ /* @__PURE__ */ jsx(
1486
+ "span",
1487
+ {
1488
+ className: `${titleText} ${semanticClassNames.titleText}`,
1489
+ children: finalTitle
1490
+ }
1491
+ ),
1492
+ /* @__PURE__ */ jsx(
1493
+ ExternalLink,
1494
+ {
1495
+ className: `${external} ${semanticClassNames.external}`,
1496
+ "aria-hidden": "true",
1497
+ focusable: false
1498
+ }
1499
+ )
1500
+ ] }),
1501
+ finalDesc && /* @__PURE__ */ jsx(
1502
+ "span",
1503
+ {
1504
+ ref: descRef,
1505
+ className: `${desc} ${semanticClassNames.desc}`,
1506
+ children: finalDesc
1507
+ }
1508
+ )
1509
+ ]
1510
+ }
1511
+ )
1400
1512
  ]
1401
1513
  }
1402
1514
  );
@@ -1,4 +1,4 @@
1
- @keyframes _13weebv0 {
1
+ @keyframes _13weebvm {
2
2
  0%, 100% {
3
3
  opacity: 1;
4
4
  }
@@ -6,7 +6,7 @@
6
6
  opacity: 0.5;
7
7
  }
8
8
  }
9
- .link-card {
9
+ ._13weebv0 {
10
10
  position: relative;
11
11
  display: flex;
12
12
  box-sizing: border-box;
@@ -28,26 +28,26 @@
28
28
  backdrop-filter: blur(12px) saturate(150%);
29
29
  transition: border-color 0.2s, background-color 0.2s;
30
30
  }
31
- .link-card:hover {
31
+ ._13weebv0:hover {
32
32
  border-color: var(--rc-border);
33
33
  background-color: var(--rc-bg-secondary);
34
34
  }
35
- .link-card--short-desc {
35
+ ._13weebv1 {
36
36
  align-items: center;
37
37
  }
38
- .link-card * {
38
+ ._13weebv0 * {
39
39
  font-style: normal !important;
40
40
  }
41
- .link-card span {
41
+ ._13weebv0 span {
42
42
  border-bottom: 0 !important;
43
43
  }
44
- .link-card__bg {
44
+ ._13weebv2 {
45
45
  position: absolute;
46
46
  inset: 0;
47
47
  z-index: 0;
48
48
  pointer-events: none;
49
49
  }
50
- .link-card__image {
50
+ ._13weebv3 {
51
51
  position: relative;
52
52
  flex-shrink: 0;
53
53
  width: 2.5rem;
@@ -59,7 +59,26 @@
59
59
  background-color: var(--rc-bg-secondary);
60
60
  z-index: 1;
61
61
  }
62
- .link-card__icon {
62
+ ._13weebv4 {
63
+ width: 6.25rem !important;
64
+ height: auto !important;
65
+ min-height: 8.75rem;
66
+ aspect-ratio: 2 / 3;
67
+ align-self: stretch;
68
+ }
69
+ ._13weebv5 {
70
+ width: 3.5rem !important;
71
+ height: 5rem !important;
72
+ aspect-ratio: auto;
73
+ align-self: flex-start;
74
+ }
75
+ ._13weebv6 {
76
+ width: 3.5rem !important;
77
+ height: 3.5rem !important;
78
+ aspect-ratio: auto;
79
+ align-self: flex-start;
80
+ }
81
+ ._13weebv7 {
63
82
  flex-shrink: 0;
64
83
  display: flex;
65
84
  align-items: center;
@@ -70,29 +89,29 @@
70
89
  background-color: var(--rc-bg-secondary);
71
90
  z-index: 1;
72
91
  }
73
- .link-card__icon img {
92
+ ._13weebv7 img {
74
93
  width: 1.25rem;
75
94
  height: 1.25rem;
76
95
  border-radius: 0.25rem;
77
96
  }
78
- .link-card__icon svg {
97
+ ._13weebv7 svg {
79
98
  width: 1.25rem;
80
99
  height: 1.25rem;
81
100
  color: var(--rc-text-secondary);
82
101
  }
83
- .link-card__content {
102
+ ._13weebv8 {
84
103
  flex: 1;
85
104
  min-width: 0;
86
105
  position: relative;
87
106
  z-index: 1;
88
107
  }
89
- .link-card__title {
108
+ ._13weebv9 {
90
109
  display: flex;
91
110
  align-items: center;
92
111
  gap: 0.5rem;
93
112
  line-height: 1.25rem;
94
113
  }
95
- .link-card__title-text {
114
+ ._13weebva {
96
115
  flex: 1;
97
116
  min-width: 0;
98
117
  display: -webkit-box;
@@ -104,7 +123,7 @@
104
123
  font-weight: 600;
105
124
  line-height: 1.25rem;
106
125
  }
107
- .link-card__external {
126
+ ._13weebvb {
108
127
  flex-shrink: 0;
109
128
  margin-left: auto;
110
129
  width: 0.875rem;
@@ -113,10 +132,10 @@
113
132
  opacity: 0;
114
133
  transition: opacity 0.2s;
115
134
  }
116
- .link-card:hover .link-card__external {
135
+ ._13weebv0:hover ._13weebvb {
117
136
  opacity: 1;
118
137
  }
119
- .link-card__desc {
138
+ ._13weebvc {
120
139
  display: -webkit-box;
121
140
  -webkit-box-orient: vertical;
122
141
  -webkit-line-clamp: 2;
@@ -128,7 +147,7 @@
128
147
  color: var(--rc-text-secondary);
129
148
  min-width: 0;
130
149
  }
131
- .link-card__favicon {
150
+ ._13weebve {
132
151
  flex-shrink: 0;
133
152
  width: 1rem;
134
153
  height: 1rem;
@@ -136,122 +155,103 @@
136
155
  vertical-align: middle;
137
156
  margin-right: 0.375rem;
138
157
  }
139
- .link-card__image--poster {
140
- width: 6.25rem !important;
141
- height: auto !important;
142
- min-height: 8.75rem;
143
- aspect-ratio: 2 / 3;
144
- align-self: stretch;
145
- }
146
- .link-card__image--poster-md {
147
- width: 3.5rem !important;
148
- height: 5rem !important;
149
- aspect-ratio: auto;
150
- align-self: flex-start;
151
- }
152
- .link-card__image--poster-sm {
153
- width: 3.5rem !important;
154
- height: 3.5rem !important;
155
- aspect-ratio: auto;
156
- align-self: flex-start;
157
- }
158
- .link-card--reversed {
158
+ ._13weebvf {
159
159
  width: 100% !important;
160
160
  height: auto !important;
161
161
  padding: 0;
162
162
  }
163
- .link-card--reversed .link-card__image {
163
+ ._13weebvf ._13weebv3 {
164
164
  border-radius: 0;
165
165
  }
166
- .link-card--reversed .link-card__image::after {
166
+ ._13weebvf ._13weebv3::after {
167
167
  content: '';
168
168
  position: absolute;
169
169
  inset: 0;
170
170
  background: linear-gradient(to right, transparent 60%, var(--rc-bg-secondary));
171
171
  pointer-events: none;
172
172
  }
173
- .link-card--reversed .link-card__content {
173
+ ._13weebvf ._13weebv8 {
174
174
  padding: 1rem;
175
175
  display: flex;
176
176
  flex-direction: column;
177
177
  justify-content: center;
178
178
  }
179
- .link-card--wide {
179
+ ._13weebvg {
180
180
  width: 100%;
181
181
  max-width: 40rem;
182
182
  }
183
- .link-card--full {
183
+ ._13weebvh {
184
184
  width: 100%;
185
185
  }
186
- .link-card--media {
186
+ ._13weebvi {
187
187
  width: 100%;
188
188
  }
189
- .link-card--media .link-card__desc {
189
+ ._13weebvi ._13weebvc {
190
190
  -webkit-line-clamp: 4;
191
191
  }
192
- .link-card--github {
192
+ ._13weebvj {
193
193
  width: 36rem;
194
194
  }
195
- .link-card--academic {
195
+ ._13weebvk {
196
196
  width: 38rem;
197
197
  }
198
- .link-card--academic .link-card__desc {
198
+ ._13weebvk ._13weebvc {
199
199
  -webkit-line-clamp: 3;
200
200
  }
201
- .link-card[data-source='gh-repo'] {
201
+ ._13weebv0[data-source='gh-repo'] {
202
202
  height: 6.25rem;
203
203
  }
204
- .link-card[data-source='gh-commit'], .link-card[data-source='gh-pr'], .link-card[data-source='gh-issue'], .link-card[data-source='gh-discussion'] {
204
+ ._13weebv0[data-source='gh-commit'], ._13weebv0[data-source='gh-pr'], ._13weebv0[data-source='gh-issue'], ._13weebv0[data-source='gh-discussion'] {
205
205
  height: 5rem;
206
206
  }
207
- .link-card[data-source='leetcode'] {
207
+ ._13weebv0[data-source='leetcode'] {
208
208
  height: 5.25rem;
209
209
  }
210
- .link-card[data-source='arxiv'] {
210
+ ._13weebv0[data-source='arxiv'] {
211
211
  height: 6rem;
212
212
  }
213
- .link-card[data-source='netease-music-song'], .link-card[data-source='qq-music-song'] {
213
+ ._13weebv0[data-source='netease-music-song'], ._13weebv0[data-source='qq-music-song'] {
214
214
  height: 5.75rem;
215
215
  }
216
- .link-card--skeleton {
216
+ ._13weebvl {
217
217
  animation-play-state: paused;
218
218
  }
219
- .link-card--skeleton .link-card__title-text {
219
+ ._13weebvl ._13weebva {
220
220
  width: 8rem;
221
221
  height: 1.25rem;
222
222
  border-radius: 0.375rem;
223
223
  background-color: var(--rc-border);
224
224
  }
225
- .link-card--skeleton .link-card__desc {
225
+ ._13weebvl ._13weebvc {
226
226
  width: 100%;
227
227
  margin-top: 0.5rem;
228
228
  height: 0.875rem;
229
229
  border-radius: 0.375rem;
230
230
  background-color: var(--rc-border);
231
231
  }
232
- .link-card--skeleton .link-card__desc-2 {
232
+ ._13weebvl ._13weebvd {
233
233
  width: 80%;
234
234
  }
235
- .link-card--skeleton .link-card__image {
235
+ ._13weebvl ._13weebv3 {
236
236
  background-color: var(--rc-border);
237
237
  }
238
- .link-card--skeleton .link-card__title-text, .link-card--skeleton .link-card__desc, .link-card--skeleton .link-card__image {
239
- animation: _13weebv0 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
238
+ ._13weebvl ._13weebva, ._13weebvl ._13weebvc, ._13weebvl ._13weebv3 {
239
+ animation: _13weebvm 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
240
240
  }
241
- .link-card--skeleton.link-card--error {
241
+ ._13weebvl._13weebvn {
242
242
  background-color: color-mix(in srgb, var(--rc-alert-caution) 12%, transparent) !important;
243
243
  }
244
- .link-card--skeleton.link-card--error .link-card__title-text, .link-card--skeleton.link-card--error .link-card__desc, .link-card--skeleton.link-card--error .link-card__image {
244
+ ._13weebvl._13weebvn ._13weebva, ._13weebvl._13weebvn ._13weebvc, ._13weebvl._13weebvn ._13weebv3 {
245
245
  background-color: color-mix(in srgb, var(--rc-alert-caution) 47%, transparent);
246
246
  color: transparent;
247
247
  }
248
- .link-card--skeleton.link-card--error .link-card__image {
248
+ ._13weebvl._13weebvn ._13weebv3 {
249
249
  background-image: none !important;
250
250
  }
251
- .rich-link-card-edit-wrapper {
251
+ ._13weebvo {
252
252
  display: inline;
253
253
  }
254
- .rich-link-card-edit-panel {
254
+ ._13weebvp {
255
255
  display: flex;
256
256
  flex-direction: column;
257
257
  gap: 8px;
@@ -262,7 +262,7 @@
262
262
  border-color: var(--rc-border);
263
263
  color: var(--rc-text);
264
264
  }
265
- .rich-link-card-edit-url-row {
265
+ ._13weebvq {
266
266
  display: flex;
267
267
  align-items: center;
268
268
  gap: 8px;
@@ -271,11 +271,11 @@
271
271
  border-radius: var(--rc-radius-md);
272
272
  min-width: 0;
273
273
  }
274
- .rich-link-card-edit-link-icon {
274
+ ._13weebvr {
275
275
  flex-shrink: 0;
276
276
  color: var(--rc-text-secondary);
277
277
  }
278
- .rich-link-card-edit-url-text {
278
+ ._13weebvs {
279
279
  flex: 1;
280
280
  color: var(--rc-text);
281
281
  font-family: var(--rc-font-mono);
@@ -285,7 +285,7 @@
285
285
  white-space: nowrap;
286
286
  min-width: 0;
287
287
  }
288
- .rich-link-card-edit-input {
288
+ ._13weebvt {
289
289
  flex: 1;
290
290
  appearance: none;
291
291
  border: none;
@@ -297,12 +297,12 @@
297
297
  outline: none;
298
298
  min-width: 0;
299
299
  }
300
- .rich-link-card-edit-actions {
300
+ ._13weebvu {
301
301
  display: flex;
302
302
  align-items: center;
303
303
  gap: 4px;
304
304
  }
305
- .rich-link-card-edit-action-btn {
305
+ ._13weebvv {
306
306
  display: inline-flex;
307
307
  align-items: center;
308
308
  gap: 6px;
@@ -318,14 +318,14 @@
318
318
  transition: color 0.15s ease, background-color 0.15s ease;
319
319
  white-space: nowrap;
320
320
  }
321
- .rich-link-card-edit-action-btn:hover {
321
+ ._13weebvv:hover {
322
322
  background-color: var(--rc-bg-secondary);
323
323
  }
324
- .rich-link-card-edit-action-btn--end {
324
+ ._13weebvw {
325
325
  margin-left: auto;
326
326
  }
327
327
  @media (max-width: 640px) {
328
- .link-card--github {
328
+ ._13weebvj {
329
329
  width: 100%;
330
330
  }
331
331
  }
@@ -1,2 +1,82 @@
1
- export {};
1
+ export declare const semanticClassNames: {
2
+ readonly card: "link-card";
3
+ readonly cardShortDesc: "link-card--short-desc";
4
+ readonly cardSkeleton: "link-card--skeleton";
5
+ readonly cardError: "link-card--error";
6
+ readonly cardReversed: "link-card--reversed";
7
+ readonly cardWide: "link-card--wide";
8
+ readonly cardFull: "link-card--full";
9
+ readonly cardMedia: "link-card--media";
10
+ readonly cardGithub: "link-card--github";
11
+ readonly cardAcademic: "link-card--academic";
12
+ readonly bg: "link-card__bg";
13
+ readonly image: "link-card__image";
14
+ readonly imagePoster: "link-card__image--poster";
15
+ readonly imagePosterMd: "link-card__image--poster-md";
16
+ readonly imagePosterSm: "link-card__image--poster-sm";
17
+ readonly icon: "link-card__icon";
18
+ readonly content: "link-card__content";
19
+ readonly title: "link-card__title";
20
+ readonly titleText: "link-card__title-text";
21
+ readonly external: "link-card__external";
22
+ readonly desc: "link-card__desc";
23
+ readonly desc2: "link-card__desc-2";
24
+ readonly favicon: "link-card__favicon";
25
+ readonly editWrapper: "rich-link-card-edit-wrapper";
26
+ readonly editPanel: "rich-link-card-edit-panel";
27
+ readonly editUrlRow: "rich-link-card-edit-url-row";
28
+ readonly editLinkIcon: "rich-link-card-edit-link-icon";
29
+ readonly editUrlText: "rich-link-card-edit-url-text";
30
+ readonly editInput: "rich-link-card-edit-input";
31
+ readonly editActions: "rich-link-card-edit-actions";
32
+ readonly editActionButton: "rich-link-card-edit-action-btn";
33
+ readonly editActionButtonEnd: "rich-link-card-edit-action-btn--end";
34
+ };
35
+ export declare const card: string;
36
+ export declare const cardShortDesc: string;
37
+ export declare const bg: string;
38
+ export declare const image: string;
39
+ export declare const imagePoster: string;
40
+ export declare const imagePosterMd: string;
41
+ export declare const imagePosterSm: string;
42
+ export declare const icon: string;
43
+ export declare const content: string;
44
+ export declare const title: string;
45
+ export declare const titleText: string;
46
+ export declare const external: string;
47
+ export declare const desc: string;
48
+ export declare const desc2: string;
49
+ export declare const favicon: string;
50
+ export declare const cardReversed: string;
51
+ export declare const cardWide: string;
52
+ export declare const cardFull: string;
53
+ export declare const cardMedia: string;
54
+ export declare const cardGithub: string;
55
+ export declare const cardAcademic: string;
56
+ export declare const cardSkeleton: string;
57
+ export declare const cardError: string;
58
+ export declare const editWrapper: string;
59
+ export declare const editPanel: string;
60
+ export declare const editUrlRow: string;
61
+ export declare const editLinkIcon: string;
62
+ export declare const editUrlText: string;
63
+ export declare const editInput: string;
64
+ export declare const editActions: string;
65
+ export declare const editActionButton: string;
66
+ export declare const editActionButtonEnd: string;
67
+ export declare const typeCardModifier: {
68
+ readonly media: string;
69
+ readonly github: string;
70
+ readonly academic: string;
71
+ readonly wide: string;
72
+ readonly full: string;
73
+ };
74
+ export declare const semanticTypeClassNames: {
75
+ readonly media: "link-card--media";
76
+ readonly github: "link-card--github";
77
+ readonly academic: "link-card--academic";
78
+ readonly wide: "link-card--wide";
79
+ readonly full: "link-card--full";
80
+ };
81
+ export declare const semanticClassToStyle: Record<string, string>;
2
82
  //# sourceMappingURL=styles.css.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"styles.css.d.ts","sourceRoot":"","sources":["../src/styles.css.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"styles.css.d.ts","sourceRoot":"","sources":["../src/styles.css.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiCrB,CAAA;AAEV,eAAO,MAAM,IAAI,QA2Bf,CAAA;AAEF,eAAO,MAAM,aAAa,QAExB,CAAA;AAKF,eAAO,MAAM,EAAE,QAKb,CAAA;AAEF,eAAO,MAAM,KAAK,QAWhB,CAAA;AAEF,eAAO,MAAM,WAAW,QAMtB,CAAA;AAEF,eAAO,MAAM,aAAa,QAKxB,CAAA;AAEF,eAAO,MAAM,aAAa,QAKxB,CAAA;AAEF,eAAO,MAAM,IAAI,QAUf,CAAA;AAcF,eAAO,MAAM,OAAO,QAKlB,CAAA;AAEF,eAAO,MAAM,KAAK,QAKhB,CAAA;AAEF,eAAO,MAAM,SAAS,QAWpB,CAAA;AAEF,eAAO,MAAM,QAAQ,QAanB,CAAA;AAEF,eAAO,MAAM,IAAI,QAWf,CAAA;AAEF,eAAO,MAAM,KAAK,QAAY,CAAA;AAE9B,eAAO,MAAM,OAAO,QAOlB,CAAA;AAEF,eAAO,MAAM,YAAY,QAIvB,CAAA;AAmBF,eAAO,MAAM,QAAQ,QAA8C,CAAA;AACnE,eAAO,MAAM,QAAQ,QAA2B,CAAA;AAChD,eAAO,MAAM,SAAS,QAA2B,CAAA;AAGjD,eAAO,MAAM,UAAU,QAGrB,CAAA;AAEF,eAAO,MAAM,YAAY,QAA4B,CAAA;AAerD,eAAO,MAAM,YAAY,QAA0C,CAAA;AAmCnE,eAAO,MAAM,SAAS,QAAY,CAAA;AAmBlC,eAAO,MAAM,WAAW,QAEtB,CAAA;AAEF,eAAO,MAAM,SAAS,QAUpB,CAAA;AAEF,eAAO,MAAM,UAAU,QAQrB,CAAA;AAEF,eAAO,MAAM,YAAY,QAGvB,CAAA;AAEF,eAAO,MAAM,WAAW,QAStB,CAAA;AAEF,eAAO,MAAM,SAAS,QAWpB,CAAA;AAEF,eAAO,MAAM,WAAW,QAItB,CAAA;AAEF,eAAO,MAAM,gBAAgB,QAoB3B,CAAA;AAEF,eAAO,MAAM,mBAAmB,QAE9B,CAAA;AAEF,eAAO,MAAM,gBAAgB;;;;;;CAMnB,CAAA;AAEV,eAAO,MAAM,sBAAsB;;;;;;CAMzB,CAAA;AAEV,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAavD,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haklex/rich-renderer-linkcard",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -17,9 +17,9 @@
17
17
  "dependencies": {
18
18
  "lucide-react": "^0.574.0",
19
19
  "react-intersection-observer": "^9.15.1",
20
- "@haklex/rich-editor-ui": "0.0.4",
21
- "@haklex/rich-style-token": "0.0.4",
22
- "@haklex/rich-editor": "0.0.4"
20
+ "@haklex/rich-editor": "0.0.5",
21
+ "@haklex/rich-editor-ui": "0.0.5",
22
+ "@haklex/rich-style-token": "0.0.5"
23
23
  },
24
24
  "devDependencies": {
25
25
  "@lexical/react": "^0.39.0",