@haklex/rich-renderer-linkcard 0.1.0 → 0.2.0
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/LinkCardRenderer-DqaMJub3.js +1330 -0
- package/dist/index.mjs +262 -292
- package/dist/rich-renderer-linkcard.css +2 -1
- package/dist/static.mjs +2 -29
- package/package.json +15 -15
- package/dist/LinkCardRenderer-CiJESZKI.js +0 -1309
package/dist/index.mjs
CHANGED
|
@@ -1,302 +1,272 @@
|
|
|
1
|
-
|
|
2
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
-
import { jsxs, jsx } from "react/jsx-runtime";
|
|
1
|
+
import { A as fetchJsonWithContext, C as githubIssuePlugin, D as LanguageToColorMap, E as leetcodePlugin, M as arxivPlugin, O as camelcaseKeys, S as githubPrPlugin, T as githubCommitPlugin, _ as tmdbPlugin, a as editInput, b as bangumiPlugin, c as editUrlRow, d as matchUrl, f as useUrlMatcher, g as createMxSpacePlugin, h as plugins, i as useLinkCardFetchContext, j as generateColor, k as fetchGitHubApi, l as editWrapper, m as pluginMap, n as LinkCardSkeleton, o as editLinkIcon, p as getPluginByName, r as LinkCardFetchProvider, s as editPanel, t as LinkCardRenderer, u as semanticClassNames, v as qqMusicPlugin, w as githubDiscussionPlugin, x as githubRepoPlugin, y as neteaseMusicPlugin } from "./LinkCardRenderer-DqaMJub3.js";
|
|
5
2
|
import { $createLinkNode, $isLinkNode } from "@lexical/link";
|
|
6
3
|
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
7
|
-
import { $
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
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-CiJESZKI.js";
|
|
4
|
+
import { $createNodeSelection, $createParagraphNode, $createTextNode, $getNodeByKey, $getSelection, $insertNodes, $isParagraphNode, $isRangeSelection, $setSelection, COMMAND_PRIORITY_LOW, PASTE_COMMAND } from "lexical";
|
|
5
|
+
import { CreditCard, ExternalLink, Link, RemoveFormatting, Unlink } from "lucide-react";
|
|
6
|
+
import { createElement, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
8
|
import { $isLinkCardNode, LinkCardNode } from "@haklex/rich-editor/nodes";
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
9
|
+
import { LinkCardRenderer as LinkCardRenderer$1, createRendererDecoration } from "@haklex/rich-editor/renderers";
|
|
10
|
+
import { ActionBar, ActionButton, Popover, PopoverPanel, PopoverTrigger } from "@haklex/rich-editor-ui";
|
|
11
|
+
//#region src/LinkCardEditDecorator.tsx
|
|
15
12
|
function LinkCardEditDecorator({ nodeKey, payload, children }) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
)
|
|
132
|
-
] }),
|
|
133
|
-
/* @__PURE__ */ jsxs(ActionBar, { children: [
|
|
134
|
-
/* @__PURE__ */ jsxs(ActionButton, { onClick: handleOpen, children: [
|
|
135
|
-
/* @__PURE__ */ jsx(ExternalLink, { size: 14 }),
|
|
136
|
-
"Open"
|
|
137
|
-
] }),
|
|
138
|
-
/* @__PURE__ */ jsxs(ActionButton, { onClick: handleConvertToLink, children: [
|
|
139
|
-
/* @__PURE__ */ jsx(RemoveFormatting, { size: 14 }),
|
|
140
|
-
"To Link"
|
|
141
|
-
] }),
|
|
142
|
-
/* @__PURE__ */ jsxs(ActionButton, { danger: true, onClick: handleDelete, children: [
|
|
143
|
-
/* @__PURE__ */ jsx(Unlink, { size: 14 }),
|
|
144
|
-
"Remove"
|
|
145
|
-
] })
|
|
146
|
-
] })
|
|
147
|
-
]
|
|
148
|
-
}
|
|
149
|
-
)
|
|
150
|
-
]
|
|
151
|
-
}
|
|
152
|
-
);
|
|
13
|
+
const [editor] = useLexicalComposerContext();
|
|
14
|
+
const editable = editor.isEditable();
|
|
15
|
+
const [open, setOpen] = useState(() => !payload.url);
|
|
16
|
+
const [url, setUrl] = useState(payload.url);
|
|
17
|
+
const inputRef = useRef(null);
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
setUrl(payload.url);
|
|
20
|
+
}, [payload.url]);
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
if (open) requestAnimationFrame(() => {
|
|
23
|
+
inputRef.current?.focus();
|
|
24
|
+
inputRef.current?.select();
|
|
25
|
+
});
|
|
26
|
+
}, [open]);
|
|
27
|
+
const commitUrl = useCallback(() => {
|
|
28
|
+
const trimmed = url.trim();
|
|
29
|
+
if (!trimmed) return;
|
|
30
|
+
editor.update(() => {
|
|
31
|
+
const node = $getNodeByKey(nodeKey);
|
|
32
|
+
if ($isLinkCardNode(node) && node.getUrl() !== trimmed) node.setUrl(trimmed);
|
|
33
|
+
});
|
|
34
|
+
}, [
|
|
35
|
+
editor,
|
|
36
|
+
nodeKey,
|
|
37
|
+
url
|
|
38
|
+
]);
|
|
39
|
+
const handleDelete = useCallback(() => {
|
|
40
|
+
editor.update(() => {
|
|
41
|
+
const node = $getNodeByKey(nodeKey);
|
|
42
|
+
if (node) node.remove();
|
|
43
|
+
});
|
|
44
|
+
setOpen(false);
|
|
45
|
+
}, [editor, nodeKey]);
|
|
46
|
+
const handleConvertToLink = useCallback(() => {
|
|
47
|
+
editor.update(() => {
|
|
48
|
+
const node = $getNodeByKey(nodeKey);
|
|
49
|
+
if (!$isLinkCardNode(node)) return;
|
|
50
|
+
const nodeUrl = node.getUrl();
|
|
51
|
+
const { title } = payload;
|
|
52
|
+
const linkNode = $createLinkNode(nodeUrl);
|
|
53
|
+
linkNode.append($createTextNode(title || nodeUrl));
|
|
54
|
+
const paragraph = $createParagraphNode();
|
|
55
|
+
paragraph.append(linkNode);
|
|
56
|
+
node.replace(paragraph);
|
|
57
|
+
paragraph.selectEnd();
|
|
58
|
+
});
|
|
59
|
+
setOpen(false);
|
|
60
|
+
}, [
|
|
61
|
+
editor,
|
|
62
|
+
nodeKey,
|
|
63
|
+
payload
|
|
64
|
+
]);
|
|
65
|
+
const handleKeyDown = useCallback((e) => {
|
|
66
|
+
if (e.key === "Enter") {
|
|
67
|
+
e.preventDefault();
|
|
68
|
+
commitUrl();
|
|
69
|
+
} else if (e.key === "Escape") {
|
|
70
|
+
e.preventDefault();
|
|
71
|
+
setUrl(payload.url);
|
|
72
|
+
}
|
|
73
|
+
}, [commitUrl, payload.url]);
|
|
74
|
+
const handleOpen = useCallback(() => {
|
|
75
|
+
window.open(payload.url, "_blank", "noopener,noreferrer");
|
|
76
|
+
}, [payload.url]);
|
|
77
|
+
if (!editable) return children;
|
|
78
|
+
return /* @__PURE__ */ jsxs(Popover, {
|
|
79
|
+
open,
|
|
80
|
+
onOpenChange: (nextOpen) => {
|
|
81
|
+
setOpen(nextOpen);
|
|
82
|
+
if (!nextOpen) setUrl(payload.url);
|
|
83
|
+
},
|
|
84
|
+
children: [/* @__PURE__ */ jsx(PopoverTrigger, {
|
|
85
|
+
openOnHover: true,
|
|
86
|
+
closeDelay: 300,
|
|
87
|
+
delay: 200,
|
|
88
|
+
nativeButton: false,
|
|
89
|
+
render: /* @__PURE__ */ jsx("span", { className: `${editWrapper} ${semanticClassNames.editWrapper}` }),
|
|
90
|
+
children
|
|
91
|
+
}), /* @__PURE__ */ jsxs(PopoverPanel, {
|
|
92
|
+
className: `${editPanel} ${semanticClassNames.editPanel}`,
|
|
93
|
+
side: "bottom",
|
|
94
|
+
sideOffset: 8,
|
|
95
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
96
|
+
className: `${editUrlRow} ${semanticClassNames.editUrlRow}`,
|
|
97
|
+
children: [/* @__PURE__ */ jsx(Link, {
|
|
98
|
+
className: `${editLinkIcon} ${semanticClassNames.editLinkIcon}`,
|
|
99
|
+
size: 16
|
|
100
|
+
}), /* @__PURE__ */ jsx("input", {
|
|
101
|
+
className: `${editInput} ${semanticClassNames.editInput}`,
|
|
102
|
+
placeholder: "https://...",
|
|
103
|
+
ref: inputRef,
|
|
104
|
+
type: "url",
|
|
105
|
+
value: url,
|
|
106
|
+
onBlur: commitUrl,
|
|
107
|
+
onChange: (e) => setUrl(e.target.value),
|
|
108
|
+
onKeyDown: handleKeyDown
|
|
109
|
+
})]
|
|
110
|
+
}), /* @__PURE__ */ jsxs(ActionBar, { children: [
|
|
111
|
+
/* @__PURE__ */ jsxs(ActionButton, {
|
|
112
|
+
onClick: handleOpen,
|
|
113
|
+
children: [/* @__PURE__ */ jsx(ExternalLink, { size: 14 }), "Open"]
|
|
114
|
+
}),
|
|
115
|
+
/* @__PURE__ */ jsxs(ActionButton, {
|
|
116
|
+
onClick: handleConvertToLink,
|
|
117
|
+
children: [/* @__PURE__ */ jsx(RemoveFormatting, { size: 14 }), "To Link"]
|
|
118
|
+
}),
|
|
119
|
+
/* @__PURE__ */ jsxs(ActionButton, {
|
|
120
|
+
danger: true,
|
|
121
|
+
onClick: handleDelete,
|
|
122
|
+
children: [/* @__PURE__ */ jsx(Unlink, { size: 14 }), "Remove"]
|
|
123
|
+
})
|
|
124
|
+
] })]
|
|
125
|
+
})]
|
|
126
|
+
});
|
|
153
127
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
128
|
+
//#endregion
|
|
129
|
+
//#region \0@oxc-project+runtime@0.127.0/helpers/typeof.js
|
|
130
|
+
function _typeof(o) {
|
|
131
|
+
"@babel/helpers - typeof";
|
|
132
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
133
|
+
return typeof o;
|
|
134
|
+
} : function(o) {
|
|
135
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
136
|
+
}, _typeof(o);
|
|
137
|
+
}
|
|
138
|
+
//#endregion
|
|
139
|
+
//#region \0@oxc-project+runtime@0.127.0/helpers/toPrimitive.js
|
|
140
|
+
function toPrimitive(t, r) {
|
|
141
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
142
|
+
var e = t[Symbol.toPrimitive];
|
|
143
|
+
if (void 0 !== e) {
|
|
144
|
+
var i = e.call(t, r || "default");
|
|
145
|
+
if ("object" != _typeof(i)) return i;
|
|
146
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
147
|
+
}
|
|
148
|
+
return ("string" === r ? String : Number)(t);
|
|
149
|
+
}
|
|
150
|
+
//#endregion
|
|
151
|
+
//#region \0@oxc-project+runtime@0.127.0/helpers/toPropertyKey.js
|
|
152
|
+
function toPropertyKey(t) {
|
|
153
|
+
var i = toPrimitive(t, "string");
|
|
154
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
155
|
+
}
|
|
156
|
+
//#endregion
|
|
157
|
+
//#region \0@oxc-project+runtime@0.127.0/helpers/defineProperty.js
|
|
158
|
+
function _defineProperty(e, r, t) {
|
|
159
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
160
|
+
value: t,
|
|
161
|
+
enumerable: !0,
|
|
162
|
+
configurable: !0,
|
|
163
|
+
writable: !0
|
|
164
|
+
}) : e[r] = t, e;
|
|
165
|
+
}
|
|
166
|
+
//#endregion
|
|
167
|
+
//#region src/LinkCardEditNode.ts
|
|
168
|
+
var LinkCardEditNode = class LinkCardEditNode extends LinkCardNode {
|
|
169
|
+
static clone(node) {
|
|
170
|
+
return new LinkCardEditNode({
|
|
171
|
+
url: node.__url,
|
|
172
|
+
title: node.__title,
|
|
173
|
+
description: node.__description,
|
|
174
|
+
favicon: node.__favicon,
|
|
175
|
+
image: node.__image
|
|
176
|
+
}, node.__key);
|
|
177
|
+
}
|
|
178
|
+
static importJSON(serializedNode) {
|
|
179
|
+
return new LinkCardEditNode({
|
|
180
|
+
url: serializedNode.url,
|
|
181
|
+
title: serializedNode.title,
|
|
182
|
+
description: serializedNode.description,
|
|
183
|
+
favicon: serializedNode.favicon,
|
|
184
|
+
image: serializedNode.image
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
decorate(_editor, _config) {
|
|
188
|
+
const payload = {
|
|
189
|
+
url: this.__url,
|
|
190
|
+
title: this.__title,
|
|
191
|
+
description: this.__description,
|
|
192
|
+
favicon: this.__favicon,
|
|
193
|
+
image: this.__image
|
|
194
|
+
};
|
|
195
|
+
const rendererEl = createRendererDecoration("LinkCard", LinkCardRenderer$1, payload);
|
|
196
|
+
return createElement(LinkCardEditDecorator, {
|
|
197
|
+
nodeKey: this.__key,
|
|
198
|
+
payload,
|
|
199
|
+
children: rendererEl
|
|
200
|
+
});
|
|
201
|
+
}
|
|
191
202
|
};
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
]);
|
|
206
|
-
|
|
203
|
+
_defineProperty(LinkCardEditNode, "commandItems", [{
|
|
204
|
+
title: "Link Card",
|
|
205
|
+
icon: createElement(Link, { size: 20 }),
|
|
206
|
+
description: "Link preview card",
|
|
207
|
+
keywords: [
|
|
208
|
+
"link",
|
|
209
|
+
"card",
|
|
210
|
+
"bookmark",
|
|
211
|
+
"embed"
|
|
212
|
+
],
|
|
213
|
+
section: "MEDIA",
|
|
214
|
+
onSelect: (editor) => {
|
|
215
|
+
editor.update(() => {
|
|
216
|
+
$insertNodes([$createLinkCardEditNode({ url: "" })]);
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
}]);
|
|
207
220
|
function $createLinkCardEditNode(payload) {
|
|
208
|
-
|
|
221
|
+
return new LinkCardEditNode(payload);
|
|
209
222
|
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
"To Card"
|
|
236
|
-
] });
|
|
223
|
+
var linkCardEditNodes = [LinkCardEditNode];
|
|
224
|
+
//#endregion
|
|
225
|
+
//#region src/ConvertToLinkCardAction.tsx
|
|
226
|
+
function ConvertToLinkCardAction({ url, linkKey, pluginRegistry, className }) {
|
|
227
|
+
const [editor] = useLexicalComposerContext();
|
|
228
|
+
if (!useMemo(() => matchUrl(url, pluginRegistry), [url, pluginRegistry])) return null;
|
|
229
|
+
const handleConvert = () => {
|
|
230
|
+
editor.update(() => {
|
|
231
|
+
const linkNode = $getNodeByKey(linkKey);
|
|
232
|
+
if (!linkNode || !$isLinkNode(linkNode)) return;
|
|
233
|
+
const topElement = linkNode.getTopLevelElement();
|
|
234
|
+
if (!topElement) return;
|
|
235
|
+
const linkCardNode = $createLinkCardEditNode({ url });
|
|
236
|
+
topElement.replace(linkCardNode);
|
|
237
|
+
const nodeSelection = $createNodeSelection();
|
|
238
|
+
nodeSelection.add(linkCardNode.getKey());
|
|
239
|
+
$setSelection(nodeSelection);
|
|
240
|
+
});
|
|
241
|
+
};
|
|
242
|
+
return /* @__PURE__ */ jsxs("button", {
|
|
243
|
+
className,
|
|
244
|
+
type: "button",
|
|
245
|
+
onClick: handleConvert,
|
|
246
|
+
children: [/* @__PURE__ */ jsx(CreditCard, { size: 14 }), "To Card"]
|
|
247
|
+
});
|
|
237
248
|
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
}) {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
url: text
|
|
260
|
-
});
|
|
261
|
-
topElement.replace(linkCardNode);
|
|
262
|
-
return true;
|
|
263
|
-
},
|
|
264
|
-
COMMAND_PRIORITY_LOW
|
|
265
|
-
);
|
|
266
|
-
}, [editor, pluginRegistry]);
|
|
267
|
-
return null;
|
|
249
|
+
//#endregion
|
|
250
|
+
//#region src/PasteLinkCardPlugin.tsx
|
|
251
|
+
function PasteLinkCardPlugin({ pluginRegistry }) {
|
|
252
|
+
const [editor] = useLexicalComposerContext();
|
|
253
|
+
useEffect(() => {
|
|
254
|
+
return editor.registerCommand(PASTE_COMMAND, (event) => {
|
|
255
|
+
const text = event.clipboardData?.getData("text/plain")?.trim();
|
|
256
|
+
if (!text) return false;
|
|
257
|
+
if (!matchUrl(text, pluginRegistry)) return false;
|
|
258
|
+
const selection = $getSelection();
|
|
259
|
+
if (!$isRangeSelection(selection)) return false;
|
|
260
|
+
const topElement = selection.anchor.getNode().getTopLevelElement();
|
|
261
|
+
if (!topElement || !$isParagraphNode(topElement)) return false;
|
|
262
|
+
if (topElement.getTextContent().trim().length > 0) return false;
|
|
263
|
+
event.preventDefault();
|
|
264
|
+
const linkCardNode = $createLinkCardEditNode({ url: text });
|
|
265
|
+
topElement.replace(linkCardNode);
|
|
266
|
+
return true;
|
|
267
|
+
}, COMMAND_PRIORITY_LOW);
|
|
268
|
+
}, [editor, pluginRegistry]);
|
|
269
|
+
return null;
|
|
268
270
|
}
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
ConvertToLinkCardAction,
|
|
272
|
-
L as LanguageToColorMap,
|
|
273
|
-
LinkCardEditDecorator,
|
|
274
|
-
LinkCardEditNode,
|
|
275
|
-
a as LinkCardFetchProvider,
|
|
276
|
-
b as LinkCardRenderer,
|
|
277
|
-
c as LinkCardSkeleton,
|
|
278
|
-
PasteLinkCardPlugin,
|
|
279
|
-
d as arxivPlugin,
|
|
280
|
-
e as bangumiPlugin,
|
|
281
|
-
f as camelcaseKeys,
|
|
282
|
-
g as createMxSpacePlugin,
|
|
283
|
-
h as fetchGitHubApi,
|
|
284
|
-
i as fetchJsonWithContext,
|
|
285
|
-
j as generateColor,
|
|
286
|
-
k as getPluginByName,
|
|
287
|
-
l as githubCommitPlugin,
|
|
288
|
-
m as githubDiscussionPlugin,
|
|
289
|
-
n as githubIssuePlugin,
|
|
290
|
-
o as githubPrPlugin,
|
|
291
|
-
p as githubRepoPlugin,
|
|
292
|
-
q as leetcodePlugin,
|
|
293
|
-
linkCardEditNodes,
|
|
294
|
-
matchUrl,
|
|
295
|
-
s as neteaseMusicPlugin,
|
|
296
|
-
t as pluginMap,
|
|
297
|
-
u as plugins,
|
|
298
|
-
v as qqMusicPlugin,
|
|
299
|
-
w as tmdbPlugin,
|
|
300
|
-
x as useLinkCardFetchContext,
|
|
301
|
-
y as useUrlMatcher
|
|
302
|
-
};
|
|
271
|
+
//#endregion
|
|
272
|
+
export { $createLinkCardEditNode, ConvertToLinkCardAction, LanguageToColorMap, LinkCardEditDecorator, LinkCardEditNode, LinkCardFetchProvider, LinkCardRenderer, LinkCardSkeleton, PasteLinkCardPlugin, arxivPlugin, bangumiPlugin, camelcaseKeys, createMxSpacePlugin, fetchGitHubApi, fetchJsonWithContext, generateColor, getPluginByName, githubCommitPlugin, githubDiscussionPlugin, githubIssuePlugin, githubPrPlugin, githubRepoPlugin, leetcodePlugin, linkCardEditNodes, matchUrl, neteaseMusicPlugin, pluginMap, plugins, qqMusicPlugin, tmdbPlugin, useLinkCardFetchContext, useUrlMatcher };
|