@haklex/rich-renderer-linkcard 0.0.60 → 0.0.61
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/LinkCardEditDecorator.d.ts.map +1 -1
- package/dist/LinkCardEditNode.d.ts +2 -2
- package/dist/LinkCardEditNode.d.ts.map +1 -1
- package/dist/{LinkCardRenderer-DMH3krCw.js → LinkCardRenderer-Dap643Is.js} +6 -4
- package/dist/LinkCardRenderer.d.ts.map +1 -1
- package/dist/index.mjs +11 -7
- package/dist/static.mjs +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LinkCardEditDecorator.d.ts","sourceRoot":"","sources":["../src/LinkCardEditDecorator.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"LinkCardEditDecorator.d.ts","sourceRoot":"","sources":["../src/LinkCardEditDecorator.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAO9D,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,2CA4J5B"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { LinkCardNode, LinkCardNodePayload, SerializedLinkCardNode,
|
|
1
|
+
import { LinkCardNode, LinkCardNodePayload, SerializedLinkCardNode, CommandItemConfig } from '@haklex/rich-editor';
|
|
2
2
|
import { EditorConfig, Klass, LexicalEditor, LexicalNode } from 'lexical';
|
|
3
3
|
import { ReactElement } from 'react';
|
|
4
4
|
export declare class LinkCardEditNode extends LinkCardNode {
|
|
5
|
-
static
|
|
5
|
+
static commandItems: CommandItemConfig[];
|
|
6
6
|
static clone(node: LinkCardEditNode): LinkCardEditNode;
|
|
7
7
|
static importJSON(serializedNode: SerializedLinkCardNode): LinkCardEditNode;
|
|
8
8
|
decorate(_editor: LexicalEditor, _config: EditorConfig): ReactElement;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LinkCardEditNode.d.ts","sourceRoot":"","sources":["../src/LinkCardEditNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,YAAY,EACZ,KAAK,mBAAmB,EAExB,KAAK,sBAAsB,EAC3B,KAAK,
|
|
1
|
+
{"version":3,"file":"LinkCardEditNode.d.ts","sourceRoot":"","sources":["../src/LinkCardEditNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,YAAY,EACZ,KAAK,mBAAmB,EAExB,KAAK,sBAAsB,EAC3B,KAAK,iBAAiB,EACvB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAG9E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAKzC,qBAAa,gBAAiB,SAAQ,YAAY;IAChD,MAAM,CAAC,YAAY,EAAE,iBAAiB,EAAE,CAavC;IAED,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,gBAAgB,GAAG,gBAAgB;IAatD,MAAM,CAAC,UAAU,CAAC,cAAc,EAAE,sBAAsB,GAAG,gBAAgB;IAU3E,QAAQ,CAAC,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,YAAY,GAAG,YAAY;CAmBtE;AAED,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,mBAAmB,GAC3B,gBAAgB,CAElB;AAED,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,CAAsB,CAAA"}
|
|
@@ -1207,7 +1207,8 @@ const LinkCardRenderer = (props) => {
|
|
|
1207
1207
|
const typeClass = selectedPlugin?.typeClass;
|
|
1208
1208
|
const typeStyleClass = typeClass ? typeCardModifier[typeClass] : "";
|
|
1209
1209
|
const typeSemanticClass = typeClass ? semanticTypeClassNames[typeClass] : "";
|
|
1210
|
-
const
|
|
1210
|
+
const isErrorState = useDynamicFetch && isError;
|
|
1211
|
+
const finalTitle = cardInfo?.title || title$1 || (isErrorState ? "" : url);
|
|
1211
1212
|
const finalDesc = cardInfo?.desc || description;
|
|
1212
1213
|
const finalImage = cardInfo?.image || image$1;
|
|
1213
1214
|
const finalColor = cardInfo?.color;
|
|
@@ -1244,7 +1245,8 @@ const LinkCardRenderer = (props) => {
|
|
|
1244
1245
|
);
|
|
1245
1246
|
}
|
|
1246
1247
|
const hasImage = !!finalImage;
|
|
1247
|
-
const showImagePlaceholder =
|
|
1248
|
+
const showImagePlaceholder = isErrorState && !hasImage;
|
|
1249
|
+
const shouldCenterContent = !finalDesc || shortDesc;
|
|
1248
1250
|
return /* @__PURE__ */ jsxs(
|
|
1249
1251
|
"a",
|
|
1250
1252
|
{
|
|
@@ -1255,8 +1257,8 @@ const LinkCardRenderer = (props) => {
|
|
|
1255
1257
|
semanticClassNames.card,
|
|
1256
1258
|
typeStyleClass,
|
|
1257
1259
|
typeSemanticClass,
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
+
shouldCenterContent && cardShortDesc,
|
|
1261
|
+
shouldCenterContent && semanticClassNames.cardShortDesc,
|
|
1260
1262
|
useDynamicFetch && (loading || isError) && cardSkeleton,
|
|
1261
1263
|
useDynamicFetch && (loading || isError) && semanticClassNames.cardSkeleton,
|
|
1262
1264
|
useDynamicFetch && isError && cardError,
|
|
@@ -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;;OAEG;IACH,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB,YAAY,CAAC,EAAE,oBAAoB,CAAA;CACpC;AA6BD,eAAO,MAAM,gBAAgB,EAAE,aAAa,CAAC,qBAAqB,
|
|
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,CAwLjE,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 { z as editWrapper, A as semanticClassNames, B as editPanel, C as editUrlRow, D as editLinkIcon, E as editInput, F as editActions, G as editActionButton, H as editActionButtonEnd, r as matchUrl } from "./LinkCardRenderer-
|
|
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 } from "./LinkCardRenderer-
|
|
10
|
+
import { z as editWrapper, A as semanticClassNames, B as editPanel, C as editUrlRow, D as editLinkIcon, E as editInput, F as editActions, G as editActionButton, H as editActionButtonEnd, r as matchUrl } from "./LinkCardRenderer-Dap643Is.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 } from "./LinkCardRenderer-Dap643Is.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({
|
|
@@ -18,16 +18,20 @@ function LinkCardEditDecorator({
|
|
|
18
18
|
}) {
|
|
19
19
|
const [editor] = useLexicalComposerContext();
|
|
20
20
|
const editable = editor.isEditable();
|
|
21
|
-
const [open, setOpen] = useState(
|
|
21
|
+
const [open, setOpen] = useState(() => !payload.url);
|
|
22
22
|
const [url, setUrl] = useState(payload.url);
|
|
23
23
|
const inputRef = useRef(null);
|
|
24
24
|
useEffect(() => {
|
|
25
25
|
setUrl(payload.url);
|
|
26
26
|
}, [payload.url]);
|
|
27
27
|
useEffect(() => {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
if (open) {
|
|
29
|
+
requestAnimationFrame(() => {
|
|
30
|
+
inputRef.current?.focus();
|
|
31
|
+
inputRef.current?.select();
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}, [open]);
|
|
31
35
|
const commitUrl = useCallback(() => {
|
|
32
36
|
const trimmed = url.trim();
|
|
33
37
|
if (!trimmed) return;
|
|
@@ -233,7 +237,7 @@ const _LinkCardEditNode = class _LinkCardEditNode extends LinkCardNode {
|
|
|
233
237
|
});
|
|
234
238
|
}
|
|
235
239
|
};
|
|
236
|
-
__publicField(_LinkCardEditNode, "
|
|
240
|
+
__publicField(_LinkCardEditNode, "commandItems", [
|
|
237
241
|
{
|
|
238
242
|
title: "Link Card",
|
|
239
243
|
icon: createElement(Link, { size: 20 }),
|
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 } from "./LinkCardRenderer-
|
|
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 } from "./LinkCardRenderer-Dap643Is.js";
|
|
2
2
|
export {
|
|
3
3
|
L as LanguageToColorMap,
|
|
4
4
|
a as LinkCardFetchProvider,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@haklex/rich-renderer-linkcard",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.61",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"lucide-react": "^0.577.0",
|
|
30
30
|
"react-intersection-observer": "^10.0.3",
|
|
31
|
-
"@haklex/rich-editor
|
|
32
|
-
"@haklex/rich-editor": "0.0.
|
|
33
|
-
"@haklex/rich-style-token": "0.0.
|
|
31
|
+
"@haklex/rich-editor": "0.0.61",
|
|
32
|
+
"@haklex/rich-editor-ui": "0.0.61",
|
|
33
|
+
"@haklex/rich-style-token": "0.0.61"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@lexical/link": "^0.41.0",
|