@haklex/rich-renderer-linkcard 0.0.47 → 0.0.48

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.
@@ -1212,18 +1212,28 @@ const LinkCardRenderer = (props) => {
1212
1212
  source: explicitSource,
1213
1213
  id: explicitId,
1214
1214
  className,
1215
- plugins: plugins$1 = plugins,
1215
+ plugins: extraPlugins,
1216
1216
  fetchContext: fetchContextProp
1217
1217
  } = props;
1218
1218
  const contextValue = useLinkCardFetchContext();
1219
1219
  const fetchContext = fetchContextProp ?? contextValue;
1220
+ const mergedPlugins = useMemo(() => {
1221
+ if (!extraPlugins || extraPlugins.length === 0) return plugins;
1222
+ const map = new Map(plugins.map((p) => [p.name, p]));
1223
+ for (const plugin of extraPlugins) {
1224
+ map.set(plugin.name, plugin);
1225
+ }
1226
+ return [...map.values()].sort(
1227
+ (a, b) => (b.priority ?? 0) - (a.priority ?? 0)
1228
+ );
1229
+ }, [extraPlugins]);
1220
1230
  const pluginMap2 = useMemo(
1221
- () => new Map(plugins$1.map((plugin) => [plugin.name, plugin])),
1222
- [plugins$1]
1231
+ () => new Map(mergedPlugins.map((plugin) => [plugin.name, plugin])),
1232
+ [mergedPlugins]
1223
1233
  );
1224
1234
  const urlMatch = useUrlMatcher(
1225
1235
  !explicitSource || !explicitId ? url : void 0,
1226
- plugins$1
1236
+ mergedPlugins
1227
1237
  );
1228
1238
  const source = explicitSource || urlMatch?.plugin.name;
1229
1239
  const id = explicitId || urlMatch?.match.id;
@@ -5,6 +5,9 @@ export interface EnhancedLinkCardProps extends LinkCardRendererProps {
5
5
  source?: string;
6
6
  id?: string;
7
7
  className?: string;
8
+ /**
9
+ * 额外插件,与内置插件合并(同名覆盖内置,按 priority 排序)
10
+ */
8
11
  plugins?: PluginRegistry;
9
12
  fetchContext?: LinkCardFetchContext;
10
13
  }
@@ -1 +1 @@
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;AAS1C,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,CA2KjE,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;AAS1C,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;;OAEG;IACH,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB,YAAY,CAAC,EAAE,oBAAoB,CAAA;CACpC;AA6BD,eAAO,MAAM,gBAAgB,EAAE,aAAa,CAAC,qBAAqB,CAsLjE,CAAA"}
package/dist/index.mjs CHANGED
@@ -7,8 +7,8 @@ import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext
7
7
  import { $getNodeByKey, $createTextNode, $createParagraphNode, $insertNodes, $createNodeSelection, $setSelection, PASTE_COMMAND, $getSelection, $isRangeSelection, $isParagraphNode, COMMAND_PRIORITY_LOW } from "lexical";
8
8
  import { Link, ExternalLink, RemoveFormatting, Unlink, CreditCard } from "lucide-react";
9
9
  import { useState, useRef, useEffect, useCallback, createElement, useMemo } from "react";
10
- import { A as editWrapper, B as semanticClassNames, C as editPanel, D as editUrlRow, E as editLinkIcon, F as editInput, G as editActions, H as editActionButton, I as editActionButtonEnd, r as matchUrl } from "./LinkCardRenderer-BXL61dFZ.js";
11
- import { L, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, s, t, u, v, w, x, y, z } from "./LinkCardRenderer-BXL61dFZ.js";
10
+ import { A as editWrapper, B as semanticClassNames, C as editPanel, D as editUrlRow, E as editLinkIcon, F as editInput, G as editActions, H as editActionButton, I as editActionButtonEnd, r as matchUrl } from "./LinkCardRenderer-C1BWulCW.js";
11
+ import { L, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, s, t, u, v, w, x, y, z } from "./LinkCardRenderer-C1BWulCW.js";
12
12
  import { $isLinkCardNode, LinkCardNode, createRendererDecoration, LinkCardRenderer } from "@haklex/rich-editor";
13
13
  import { Popover, PopoverTrigger, PopoverPanel } from "@haklex/rich-editor-ui";
14
14
  function LinkCardEditDecorator({
package/dist/static.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { L, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z } from "./LinkCardRenderer-BXL61dFZ.js";
1
+ import { L, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z } from "./LinkCardRenderer-C1BWulCW.js";
2
2
  export {
3
3
  L as LanguageToColorMap,
4
4
  a as LinkCardFetchProvider,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haklex/rich-renderer-linkcard",
3
- "version": "0.0.47",
3
+ "version": "0.0.48",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -21,9 +21,9 @@
21
21
  "dependencies": {
22
22
  "lucide-react": "^0.575.0",
23
23
  "react-intersection-observer": "^10.0.3",
24
- "@haklex/rich-editor": "0.0.47",
25
- "@haklex/rich-editor-ui": "0.0.47",
26
- "@haklex/rich-style-token": "0.0.47"
24
+ "@haklex/rich-editor": "0.0.48",
25
+ "@haklex/rich-editor-ui": "0.0.48",
26
+ "@haklex/rich-style-token": "0.0.48"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@lexical/link": "^0.41.0",