@haklex/rich-ext-embed 0.1.1 → 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.
@@ -1,599 +0,0 @@
1
- var __defProp = Object.defineProperty;
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 { DecoratorNode, $getNodeByKey } from "lexical";
5
- import { createContext, use, lazy, useState, useMemo, useEffect, Suspense, Component, createElement, useRef, useCallback } from "react";
6
- import { jsx, jsxs } from "react/jsx-runtime";
7
- import { useColorScheme } from "@haklex/rich-editor";
8
- import { SiGithub } from "@icons-pack/react-simple-icons";
9
- import { ActionBar, ActionButton } from "@haklex/rich-editor-ui";
10
- import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
11
- import { ExternalLink, Trash2 } from "lucide-react";
12
- var semanticClassNames$1 = { wrapper: "rich-embed-link-wrapper", embed: "rich-embed", badge: "rich-embed__badge", dot: "rich-embed__dot", divider: "rich-embed__divider", input: "rich-embed__input" };
13
- var semanticEmbedModifierClass = { generic: "rich-embed--generic", tweet: "rich-embed--tweet", youtube: "rich-embed--youtube", codesandbox: "rich-embed--codesandbox", bilibili: "rich-embed--bilibili", "github-file": "rich-embed--github-file", "github-gist": "rich-embed--github-gist", thinking: "rich-embed--thinking" };
14
- var wrapper = "_1qucygc1";
15
- var embed = "_1qucygc2";
16
- var embedType = { generic: "_1qucygc3", tweet: "_1qucygc4", youtube: "_1qucygc5", codesandbox: "_1qucygc6", bilibili: "_1qucygc7", "github-file": "_1qucygc8", "github-gist": "_1qucygc9", thinking: "_1qucygca" };
17
- var badge = "_1qucygcb";
18
- var dot = "_1qucygcc";
19
- var divider = "_1qucygcd";
20
- var input = "_1qucygce";
21
- const EmbedRendererCtx = createContext({});
22
- const EmbedRendererProvider = EmbedRendererCtx.Provider;
23
- function useEmbedRenderers() {
24
- return use(EmbedRendererCtx);
25
- }
26
- var semanticClassNames = { ratioContainer: "embed-static-ratio-container", ratioInner: "embed-static-ratio-inner", iframe: "embed-static-iframe", gist: "embed-static-gist", gistIframe: "embed-static-gist__iframe", sourceLink: "embed-static-source-link", githubFile: "embed-static-github-file", githubFileCode: "embed-static-github-file__code", githubFileCodeLong: "embed-static-github-file__code--long", githubFileLine: "embed-static-github-file__line", githubFileLineNum: "embed-static-github-file__line-num", shiki: "embed-static-shiki", fallback: "embed-static-fallback", fallbackBadge: "embed-static-fallback__badge", fallbackDot: "embed-static-fallback__dot", fallbackLink: "embed-static-fallback__link", tweet: "embed-static-tweet", loading: "embed-static-loading" };
27
- var semanticFallbackModifierClass = { generic: "embed-static-fallback--generic", tweet: "embed-static-fallback--tweet", youtube: "embed-static-fallback--youtube", codesandbox: "embed-static-fallback--codesandbox", bilibili: "embed-static-fallback--bilibili", "github-file": "embed-static-fallback--github-file", "github-gist": "embed-static-fallback--github-gist", thinking: "embed-static-fallback--thinking" };
28
- var ratioContainer = "_1xclnej1";
29
- var ratioInner = "_1xclnej2";
30
- var iframe = "_1xclnej3";
31
- var gist = "_1xclnej4";
32
- var gistIframe = "_1xclnej5";
33
- var sourceLink = "_1xclnej6";
34
- var githubFile = "_1xclnej7";
35
- var githubFileCode = "_1xclnej8";
36
- var githubFileCodeLong = "_1xclnej9";
37
- var githubFileLine = "_1xclneja";
38
- var githubFileLineNum = "_1xclnejb";
39
- var shiki = "_1xclnejc";
40
- var fallback = "_1xclnejd";
41
- var fallbackType = { generic: "_1xclneje", tweet: "_1xclnejf", youtube: "_1xclnejg", codesandbox: "_1xclnejh", bilibili: "_1xclneji", "github-file": "_1xclnejj", "github-gist": "_1xclnejk", thinking: "_1xclnejl" };
42
- var fallbackBadge = "_1xclnejm";
43
- var fallbackDot = "_1xclnejn";
44
- var fallbackLink = "_1xclnejo";
45
- var tweet = "_1xclnejp";
46
- var loading = "_1xclnejq";
47
- const extToLang = {
48
- ".js": "javascript",
49
- ".ts": "typescript",
50
- ".mjs": "javascript",
51
- ".cjs": "javascript",
52
- ".mts": "typescript",
53
- ".cts": "typescript",
54
- ".jsx": "jsx",
55
- ".tsx": "tsx",
56
- ".md": "markdown",
57
- ".css": "css",
58
- ".scss": "scss",
59
- ".html": "html",
60
- ".json": "json",
61
- ".yml": "yaml",
62
- ".yaml": "yaml",
63
- ".toml": "toml",
64
- ".xml": "xml",
65
- ".sh": "bash",
66
- ".bash": "bash",
67
- ".zsh": "bash",
68
- ".go": "go",
69
- ".py": "python",
70
- ".rb": "ruby",
71
- ".java": "java",
72
- ".c": "c",
73
- ".cpp": "cpp",
74
- ".cs": "csharp",
75
- ".rs": "rust",
76
- ".swift": "swift",
77
- ".kt": "kotlin",
78
- ".lua": "lua",
79
- ".sql": "sql",
80
- ".graphql": "graphql",
81
- ".scala": "scala",
82
- ".dart": "dart",
83
- ".vue": "vue",
84
- ".h": "c",
85
- ".hpp": "cpp",
86
- ".m": "objectivec",
87
- ".ex": "elixir",
88
- ".r": "r"
89
- };
90
- function getLangFromPath(path) {
91
- const dot2 = path.lastIndexOf(".");
92
- if (dot2 === -1) return "text";
93
- return extToLang[path.slice(dot2).toLowerCase()] || "text";
94
- }
95
- const shikiPromise = import("shiki/bundle/web").catch(() => null);
96
- const typeLabels$1 = {
97
- "tweet": "X / Twitter",
98
- "youtube": "YouTube",
99
- "codesandbox": "CodeSandbox",
100
- "bilibili": "Bilibili",
101
- "github-file": "GitHub File",
102
- "github-gist": "GitHub Gist",
103
- "thinking": "Thinking"
104
- };
105
- const LazyTweet = lazy(() => import("react-tweet").then((mod) => ({ default: mod.IsolatedTweet })));
106
- class EmbedErrorBoundary extends Component {
107
- constructor() {
108
- super(...arguments);
109
- __publicField(this, "state", { hasError: false });
110
- }
111
- static getDerivedStateFromError() {
112
- return { hasError: true };
113
- }
114
- render() {
115
- return this.state.hasError ? this.props.fallback : this.props.children;
116
- }
117
- }
118
- function GitHubSvg() {
119
- return /* @__PURE__ */ jsx(SiGithub, { size: 16 });
120
- }
121
- function FixedRatioContainer({
122
- children,
123
- ratio = 58
124
- }) {
125
- return /* @__PURE__ */ jsx("div", { className: `${ratioContainer} ${semanticClassNames.ratioContainer}`, children: /* @__PURE__ */ jsx(
126
- "div",
127
- {
128
- className: `${ratioInner} ${semanticClassNames.ratioInner}`,
129
- style: { paddingBottom: `${ratio}%` },
130
- children
131
- }
132
- ) });
133
- }
134
- function FallbackLink({ url, type }) {
135
- const label = type ? typeLabels$1[type] : "Embed";
136
- const cssModifier = type || "generic";
137
- const fallbackTypeClass = fallbackType[cssModifier];
138
- const semanticModifierClass = semanticFallbackModifierClass[cssModifier];
139
- return /* @__PURE__ */ jsxs(
140
- "div",
141
- {
142
- className: `${fallback} ${fallbackTypeClass} ${semanticClassNames.fallback} ${semanticModifierClass}`.trim(),
143
- children: [
144
- /* @__PURE__ */ jsxs("span", { className: `${fallbackBadge} ${semanticClassNames.fallbackBadge}`, children: [
145
- /* @__PURE__ */ jsx("span", { className: `${fallbackDot} ${semanticClassNames.fallbackDot}` }),
146
- label
147
- ] }),
148
- /* @__PURE__ */ jsx(
149
- "a",
150
- {
151
- className: `${fallbackLink} ${semanticClassNames.fallbackLink}`,
152
- href: url,
153
- rel: "noreferrer",
154
- target: "_blank",
155
- children: url
156
- }
157
- )
158
- ]
159
- }
160
- );
161
- }
162
- function TweetRenderer({ url }) {
163
- const colorScheme = useColorScheme();
164
- let parsedUrl;
165
- try {
166
- parsedUrl = new URL(url);
167
- } catch {
168
- return /* @__PURE__ */ jsx(FallbackLink, { type: "tweet", url });
169
- }
170
- const id = parsedUrl.pathname.split("/").pop();
171
- if (!id) return /* @__PURE__ */ jsx(FallbackLink, { type: "tweet", url });
172
- const fallback2 = /* @__PURE__ */ jsx(FallbackLink, { type: "tweet", url });
173
- return /* @__PURE__ */ jsx(EmbedErrorBoundary, { fallback: fallback2, children: /* @__PURE__ */ jsx("div", { className: `${tweet} ${semanticClassNames.tweet}`, children: /* @__PURE__ */ jsx(
174
- Suspense,
175
- {
176
- fallback: /* @__PURE__ */ jsx("div", { className: `${loading} ${semanticClassNames.loading}`, children: "Loading tweet..." }),
177
- children: /* @__PURE__ */ jsx(
178
- LazyTweet,
179
- {
180
- id,
181
- style: { width: "100%" },
182
- theme: colorScheme === "dark" ? "dark" : "light"
183
- }
184
- )
185
- }
186
- ) }) });
187
- }
188
- function GithubFileEmbed({ url, href }) {
189
- const colorScheme = useColorScheme();
190
- const shikiTheme = colorScheme === "dark" ? "github-dark" : "github-light";
191
- const split = url.pathname.split("/");
192
- const [, owner, repo, , ...rest] = split;
193
- const ref = rest[0];
194
- const path = ref ? rest.slice(1).join("/") : rest.join("/");
195
- const matchResult = url.hash.match(/L\d+/g);
196
- let startLine = 0;
197
- let endLine;
198
- if (matchResult) {
199
- if (matchResult.length === 1) {
200
- startLine = Number.parseInt(matchResult[0].slice(1)) - 1;
201
- endLine = startLine + 1;
202
- } else {
203
- startLine = Number.parseInt(matchResult[0].slice(1)) - 1;
204
- endLine = Number.parseInt(matchResult[1].slice(1));
205
- }
206
- }
207
- const [content, setContent] = useState(null);
208
- const [highlightedHtml, setHighlightedHtml] = useState(null);
209
- const [loading$1, setLoading] = useState(true);
210
- const [error, setError] = useState(false);
211
- const lang = useMemo(() => getLangFromPath(path), [path]);
212
- useEffect(() => {
213
- let cancelled = false;
214
- setContent(null);
215
- setHighlightedHtml(null);
216
- setLoading(true);
217
- setError(false);
218
- const fetchPromise = fetch(
219
- `https://cdn.jsdelivr.net/gh/${owner}/${repo}${ref ? `@${ref}` : ""}/${path}`
220
- ).then((res) => {
221
- if (!res.ok) throw new Error(`HTTP ${res.status}`);
222
- return res.text();
223
- });
224
- Promise.all([fetchPromise, shikiPromise]).then(([text, shikiMod]) => {
225
- if (cancelled) return;
226
- setContent(text);
227
- const lines2 = text.split("\n");
228
- const end2 = endLine ?? lines2.length;
229
- const displayCode = lines2.slice(startLine, end2).join("\n");
230
- if (!shikiMod) {
231
- setLoading(false);
232
- return;
233
- }
234
- shikiMod.codeToHtml(displayCode, {
235
- lang,
236
- theme: shikiTheme
237
- }).then((html) => {
238
- if (!cancelled) {
239
- setHighlightedHtml(html);
240
- setLoading(false);
241
- }
242
- }).catch(() => {
243
- if (!cancelled) setLoading(false);
244
- });
245
- }).catch(() => {
246
- if (!cancelled) {
247
- setError(true);
248
- setLoading(false);
249
- }
250
- });
251
- return () => {
252
- cancelled = true;
253
- };
254
- }, [owner, repo, ref, path, lang, startLine, endLine, shikiTheme]);
255
- if (loading$1) {
256
- return /* @__PURE__ */ jsx("div", { className: `${loading} ${semanticClassNames.loading}`, children: "Loading GitHub File Preview..." });
257
- }
258
- if (error || content === null) {
259
- return /* @__PURE__ */ jsx(FallbackLink, { type: "github-file", url: href });
260
- }
261
- const lines = content.split("\n");
262
- const end = endLine ?? lines.length;
263
- const isLong = end - startLine > 20;
264
- return /* @__PURE__ */ jsxs("div", { className: `${githubFile} ${semanticClassNames.githubFile}`, children: [
265
- /* @__PURE__ */ jsx(
266
- "div",
267
- {
268
- className: `${githubFileCode} ${semanticClassNames.githubFileCode} ${isLong ? `${githubFileCodeLong} ${semanticClassNames.githubFileCodeLong}` : ""}`.trim(),
269
- children: highlightedHtml ? /* @__PURE__ */ jsx(
270
- "div",
271
- {
272
- className: `${shiki} ${semanticClassNames.shiki}`,
273
- dangerouslySetInnerHTML: { __html: highlightedHtml },
274
- style: { "--start-line": startLine }
275
- }
276
- ) : /* @__PURE__ */ jsx("pre", { children: /* @__PURE__ */ jsx("code", { children: lines.slice(startLine, end).map((line, i) => /* @__PURE__ */ jsxs(
277
- "span",
278
- {
279
- className: `${githubFileLine} ${semanticClassNames.githubFileLine}`,
280
- children: [
281
- /* @__PURE__ */ jsx(
282
- "span",
283
- {
284
- className: `${githubFileLineNum} ${semanticClassNames.githubFileLineNum}`,
285
- children: startLine + i + 1
286
- }
287
- ),
288
- line,
289
- "\n"
290
- ]
291
- },
292
- i
293
- )) }) })
294
- }
295
- ),
296
- /* @__PURE__ */ jsxs(
297
- "a",
298
- {
299
- className: `${sourceLink} ${semanticClassNames.sourceLink}`,
300
- href,
301
- rel: "noreferrer",
302
- target: "_blank",
303
- children: [
304
- /* @__PURE__ */ jsx(GitHubSvg, {}),
305
- /* @__PURE__ */ jsx("span", { children: href })
306
- ]
307
- }
308
- )
309
- ] });
310
- }
311
- function EmbedStaticRenderer({ type, url }) {
312
- const customRenderers = useEmbedRenderers();
313
- if (!url) return null;
314
- if (type && customRenderers[type]) {
315
- const Custom = customRenderers[type];
316
- return /* @__PURE__ */ jsx(Custom, { type, url });
317
- }
318
- let parsedUrl;
319
- try {
320
- parsedUrl = new URL(url);
321
- } catch {
322
- return /* @__PURE__ */ jsx(FallbackLink, { type, url });
323
- }
324
- switch (type) {
325
- case "tweet": {
326
- return /* @__PURE__ */ jsx(TweetRenderer, { url });
327
- }
328
- case "youtube": {
329
- const id = parsedUrl.searchParams.get("v");
330
- if (!id) return /* @__PURE__ */ jsx(FallbackLink, { type, url });
331
- return /* @__PURE__ */ jsx(FixedRatioContainer, { children: /* @__PURE__ */ jsx(
332
- "iframe",
333
- {
334
- allowFullScreen: true,
335
- allow: "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",
336
- className: `${iframe} ${semanticClassNames.iframe}`,
337
- src: `https://www.youtube.com/embed/${id}`,
338
- title: "YouTube video player"
339
- }
340
- ) });
341
- }
342
- case "bilibili": {
343
- const id = parsedUrl.pathname.split("/")[2];
344
- if (!id) return /* @__PURE__ */ jsx(FallbackLink, { type, url });
345
- return /* @__PURE__ */ jsx(FixedRatioContainer, { children: /* @__PURE__ */ jsx(
346
- "iframe",
347
- {
348
- allowFullScreen: true,
349
- className: `${iframe} ${semanticClassNames.iframe}`,
350
- scrolling: "no",
351
- src: `//player.bilibili.com/player.html?bvid=${id}&autoplay=0`
352
- }
353
- ) });
354
- }
355
- case "codesandbox": {
356
- const path = parsedUrl.pathname.slice(2);
357
- return /* @__PURE__ */ jsx(FixedRatioContainer, { children: /* @__PURE__ */ jsx(
358
- "iframe",
359
- {
360
- className: `${iframe} ${semanticClassNames.iframe}`,
361
- src: `https://codesandbox.io/embed/${path}?fontsize=14&hidenavigation=1&theme=dark${parsedUrl.search}`
362
- }
363
- ) });
364
- }
365
- case "github-gist": {
366
- const [, owner, id] = parsedUrl.pathname.split("/");
367
- if (!owner || !id) return /* @__PURE__ */ jsx(FallbackLink, { type, url });
368
- return /* @__PURE__ */ jsxs("div", { className: `${gist} ${semanticClassNames.gist}`, children: [
369
- /* @__PURE__ */ jsx(
370
- "iframe",
371
- {
372
- className: `${gistIframe} ${semanticClassNames.gistIframe}`,
373
- src: `https://gist.github.com/${owner}/${id}.pibb`
374
- }
375
- ),
376
- /* @__PURE__ */ jsxs(
377
- "a",
378
- {
379
- className: `${sourceLink} ${semanticClassNames.sourceLink}`,
380
- href: url,
381
- rel: "noreferrer",
382
- target: "_blank",
383
- children: [
384
- /* @__PURE__ */ jsx(GitHubSvg, {}),
385
- /* @__PURE__ */ jsx("span", { children: url })
386
- ]
387
- }
388
- )
389
- ] });
390
- }
391
- case "github-file": {
392
- return /* @__PURE__ */ jsx(GithubFileEmbed, { href: url, url: parsedUrl });
393
- }
394
- default: {
395
- return /* @__PURE__ */ jsx(FallbackLink, { type, url });
396
- }
397
- }
398
- }
399
- class EmbedNode extends DecoratorNode {
400
- constructor(url, source, key) {
401
- super(key);
402
- __publicField(this, "__url");
403
- __publicField(this, "__source");
404
- this.__url = url;
405
- this.__source = source;
406
- }
407
- static getType() {
408
- return "embed";
409
- }
410
- static clone(node) {
411
- return new EmbedNode(node.__url, node.__source, node.__key);
412
- }
413
- createDOM(_config) {
414
- const div = document.createElement("div");
415
- div.className = `${wrapper} ${semanticClassNames$1.wrapper}`;
416
- return div;
417
- }
418
- updateDOM() {
419
- return false;
420
- }
421
- isInline() {
422
- return false;
423
- }
424
- static importJSON(serializedNode) {
425
- return $createEmbedNode(serializedNode.url, serializedNode.source);
426
- }
427
- exportJSON() {
428
- return {
429
- ...super.exportJSON(),
430
- type: "embed",
431
- url: this.__url,
432
- source: this.__source,
433
- version: 1
434
- };
435
- }
436
- getUrl() {
437
- return this.getLatest().__url;
438
- }
439
- setUrl(url) {
440
- const writable = this.getWritable();
441
- writable.__url = url;
442
- }
443
- getSource() {
444
- return this.getLatest().__source;
445
- }
446
- setSource(source) {
447
- const writable = this.getWritable();
448
- writable.__source = source;
449
- }
450
- decorate(_editor, _config) {
451
- return createElement(EmbedStaticRenderer, {
452
- type: this.__source,
453
- url: this.__url
454
- });
455
- }
456
- }
457
- function $createEmbedNode(url, source) {
458
- return new EmbedNode(url, source);
459
- }
460
- function $isEmbedNode(node) {
461
- return node instanceof EmbedNode;
462
- }
463
- const isTweetUrl = (url) => (url.hostname === "twitter.com" || url.hostname === "x.com") && url.pathname.startsWith("/");
464
- const isYoutubeUrl = (url) => url.hostname === "www.youtube.com" && url.pathname.startsWith("/watch");
465
- const isCodesandboxUrl = (url) => url.hostname === "codesandbox.io" && url.pathname.split("/").length === 3;
466
- const isBilibiliVideoUrl = (url) => url.hostname.includes("bilibili.com") && url.pathname.startsWith("/video/BV");
467
- const isGithubFilePreviewUrl = (url) => {
468
- const [, , , type] = url.pathname.split("/");
469
- return url.hostname === "github.com" && type === "blob";
470
- };
471
- const isGistUrl = (url) => url.hostname === "gist.github.com";
472
- function createSelfThinkingMatcher(hostnames) {
473
- return (url) => hostnames.includes(url.hostname) && url.pathname.startsWith("/thinking/");
474
- }
475
- function matchEmbedUrl(url, selfThinkingMatcher) {
476
- if (isTweetUrl(url)) return "tweet";
477
- if (isYoutubeUrl(url)) return "youtube";
478
- if (isCodesandboxUrl(url)) return "codesandbox";
479
- if (isBilibiliVideoUrl(url)) return "bilibili";
480
- if (isGithubFilePreviewUrl(url)) return "github-file";
481
- if (isGistUrl(url)) return "github-gist";
482
- if (selfThinkingMatcher?.(url)) return "thinking";
483
- return null;
484
- }
485
- const typeLabels = {
486
- "tweet": "X / Twitter",
487
- "youtube": "YouTube",
488
- "codesandbox": "CodeSandbox",
489
- "bilibili": "Bilibili",
490
- "github-file": "GitHub File",
491
- "github-gist": "GitHub Gist",
492
- "thinking": "Thinking"
493
- };
494
- function EmbedLinkRenderer({ type, url, nodeKey }) {
495
- const [editor] = useLexicalComposerContext();
496
- const [editUrl, setEditUrl] = useState(url);
497
- const inputRef = useRef(null);
498
- useEffect(() => {
499
- setEditUrl(url);
500
- }, [url]);
501
- useEffect(() => {
502
- if (!url) {
503
- inputRef.current?.focus();
504
- }
505
- }, [url]);
506
- const commitUrl = useCallback(() => {
507
- const trimmed = editUrl.trim();
508
- if (!trimmed) return;
509
- editor.update(() => {
510
- const node = $getNodeByKey(nodeKey);
511
- if (!node || !("setUrl" in node)) return;
512
- const n = node;
513
- const currentUrl = n.getUrl?.();
514
- if (currentUrl !== trimmed) {
515
- n.setUrl(trimmed);
516
- }
517
- if (n.setSource) {
518
- try {
519
- n.setSource(matchEmbedUrl(new URL(trimmed)));
520
- } catch {
521
- }
522
- }
523
- });
524
- }, [editor, nodeKey, editUrl]);
525
- const handleKeyDown = useCallback(
526
- (e) => {
527
- if (e.key === "Enter") {
528
- e.preventDefault();
529
- commitUrl();
530
- inputRef.current?.blur();
531
- } else if (e.key === "Escape") {
532
- e.preventDefault();
533
- setEditUrl(url);
534
- inputRef.current?.blur();
535
- }
536
- },
537
- [commitUrl, url]
538
- );
539
- const handleDelete = useCallback(() => {
540
- editor.update(() => {
541
- const node = $getNodeByKey(nodeKey);
542
- if (node) node.remove();
543
- });
544
- }, [editor, nodeKey]);
545
- const handleOpen = useCallback(() => {
546
- if (url) window.open(url, "_blank", "noopener,noreferrer");
547
- }, [url]);
548
- const label = type ? typeLabels[type] : "Embed";
549
- const cssModifier = type || "generic";
550
- const embedModifierClass = embedType[cssModifier];
551
- const semanticModifierClass = semanticEmbedModifierClass[cssModifier];
552
- return /* @__PURE__ */ jsxs(
553
- "div",
554
- {
555
- className: `${embed} ${embedModifierClass} ${semanticClassNames$1.embed} ${semanticModifierClass}`.trim(),
556
- children: [
557
- /* @__PURE__ */ jsxs("span", { className: `${badge} ${semanticClassNames$1.badge}`, children: [
558
- /* @__PURE__ */ jsx("span", { className: `${dot} ${semanticClassNames$1.dot}` }),
559
- label
560
- ] }),
561
- /* @__PURE__ */ jsx("span", { className: `${divider} ${semanticClassNames$1.divider}` }),
562
- /* @__PURE__ */ jsx(
563
- "input",
564
- {
565
- className: `${input} ${semanticClassNames$1.input}`,
566
- placeholder: "https://...",
567
- ref: inputRef,
568
- type: "url",
569
- value: editUrl,
570
- onBlur: commitUrl,
571
- onChange: (e) => setEditUrl(e.target.value),
572
- onKeyDown: handleKeyDown
573
- }
574
- ),
575
- /* @__PURE__ */ jsxs(ActionBar, { children: [
576
- /* @__PURE__ */ jsx(ActionButton, { icon: true, disabled: !url, size: "md", title: "Open in new tab", onClick: handleOpen, children: /* @__PURE__ */ jsx(ExternalLink, {}) }),
577
- /* @__PURE__ */ jsx(ActionButton, { danger: true, icon: true, size: "md", title: "Delete", onClick: handleDelete, children: /* @__PURE__ */ jsx(Trash2, {}) })
578
- ] })
579
- ]
580
- }
581
- );
582
- }
583
- export {
584
- $createEmbedNode as $,
585
- EmbedNode as E,
586
- EmbedLinkRenderer as a,
587
- $isEmbedNode as b,
588
- createSelfThinkingMatcher as c,
589
- EmbedRendererProvider as d,
590
- EmbedStaticRenderer as e,
591
- isCodesandboxUrl as f,
592
- isGistUrl as g,
593
- isGithubFilePreviewUrl as h,
594
- isBilibiliVideoUrl as i,
595
- isTweetUrl as j,
596
- isYoutubeUrl as k,
597
- matchEmbedUrl as m,
598
- useEmbedRenderers as u
599
- };