@haklex/rich-renderer-codeblock 0.0.92 → 0.0.94
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/icons.mjs +4 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +94 -8
- package/dist/{language-DEZONKsW.js → language-kyYjCKCv.js} +16 -16
- package/dist/rich-renderer-codeblock.css +1 -1
- package/dist/static.d.ts +4 -1
- package/dist/static.d.ts.map +1 -1
- package/dist/static.mjs +18 -2
- package/package.json +5 -5
- package/dist/CodeBlockRenderer-CJOZSBIy.js +0 -132
- package/dist/CodeBlockRenderer.d.ts +0 -5
- package/dist/CodeBlockRenderer.d.ts.map +0 -1
package/dist/icons.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useMemo } from "react";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { p as getMaterialIconSvg } from "./language-kyYjCKCv.js";
|
|
4
|
+
import { q, L, h } from "./language-kyYjCKCv.js";
|
|
5
5
|
const EXT_TO_ICON = {
|
|
6
6
|
ts: "typescript",
|
|
7
7
|
tsx: "react-ts",
|
|
@@ -84,8 +84,8 @@ const FileIcon = ({ filename, size = 16, className, fallback = "F" }) => {
|
|
|
84
84
|
};
|
|
85
85
|
export {
|
|
86
86
|
FileIcon,
|
|
87
|
-
|
|
88
|
-
|
|
87
|
+
q as LANG_TO_ICON,
|
|
88
|
+
L as LanguageIcon,
|
|
89
89
|
getMaterialIconSvg,
|
|
90
90
|
h as hasLanguageIcon
|
|
91
91
|
};
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA"}
|
package/dist/index.mjs
CHANGED
|
@@ -4,15 +4,101 @@ import { Compartment, Prec, EditorState, EditorSelection } from "@codemirror/sta
|
|
|
4
4
|
import { EditorView, keymap, lineNumbers } from "@codemirror/view";
|
|
5
5
|
import { isOnFirstLine, isOnLastLine, getThemeExtensions, loadLanguageExtension } from "@haklex/cm-editor";
|
|
6
6
|
import { useVariant, useColorScheme } from "@haklex/rich-editor";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { normalizeLanguage } from "./constants.mjs";
|
|
11
|
-
import { Combobox, ComboboxInput, ComboboxContent, ComboboxEmpty, ComboboxList, ComboboxItem } from "@haklex/rich-editor-ui";
|
|
12
|
-
import { bundledLanguagesInfo } from "shiki/bundle/web";
|
|
7
|
+
import { useState, useRef, useEffect, useCallback, useMemo } from "react";
|
|
8
|
+
import { Check, Copy, ChevronDown } from "lucide-react";
|
|
9
|
+
import { normalizeLanguage, getLanguageDisplayName, languageToColorMap } from "./constants.mjs";
|
|
13
10
|
import "@iconify/utils";
|
|
14
11
|
import "@iconify-json/material-icon-theme";
|
|
15
|
-
import {
|
|
12
|
+
import { c as card, s as semanticClassNames, l as lang, h as hasLanguageIcon, L as LanguageIcon, a as copyButton, b as bodyBackgroundStatic, d as bodyBackground, e as expandWrap, f as expandButton, g as scroll, i as scrollCollapsed, j as langInput, k as lined, m as linedWithNumbers, n as body, o as bodyReadonly } from "./language-kyYjCKCv.js";
|
|
13
|
+
import { Combobox, ComboboxInput, ComboboxContent, ComboboxEmpty, ComboboxList, ComboboxItem } from "@haklex/rich-editor-ui";
|
|
14
|
+
import { bundledLanguagesInfo } from "shiki/bundle/web";
|
|
15
|
+
import { CodeBlockRenderer } from "./static.mjs";
|
|
16
|
+
const CopyIcon = /* @__PURE__ */ jsx(Copy, { size: 16 });
|
|
17
|
+
const CheckIcon = /* @__PURE__ */ jsx(Check, { size: 16 });
|
|
18
|
+
const ExpandIcon = /* @__PURE__ */ jsx(ChevronDown, { size: 14 });
|
|
19
|
+
function CodeBlockCard({
|
|
20
|
+
code,
|
|
21
|
+
language,
|
|
22
|
+
collapsible = true,
|
|
23
|
+
langSlot,
|
|
24
|
+
children,
|
|
25
|
+
static: staticMode = false
|
|
26
|
+
}) {
|
|
27
|
+
const normalizedLanguage = normalizeLanguage(language);
|
|
28
|
+
const [copied, setCopied] = useState(false);
|
|
29
|
+
const copyTimerRef = useRef(void 0);
|
|
30
|
+
const [isCollapsed, setIsCollapsed] = useState(true);
|
|
31
|
+
const [isOverflow, setIsOverflow] = useState(false);
|
|
32
|
+
const scrollRef = useRef(null);
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
if (!collapsible) {
|
|
35
|
+
setIsOverflow(false);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const el = scrollRef.current;
|
|
39
|
+
if (!el) return;
|
|
40
|
+
const check = () => {
|
|
41
|
+
const halfVh = window.innerHeight / 2;
|
|
42
|
+
setIsOverflow(el.scrollHeight >= halfVh);
|
|
43
|
+
};
|
|
44
|
+
const raf = requestAnimationFrame(check);
|
|
45
|
+
return () => cancelAnimationFrame(raf);
|
|
46
|
+
}, [code, collapsible]);
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
return () => clearTimeout(copyTimerRef.current);
|
|
49
|
+
}, []);
|
|
50
|
+
const handleCopy = useCallback(() => {
|
|
51
|
+
navigator.clipboard.writeText(code).then(() => {
|
|
52
|
+
setCopied(true);
|
|
53
|
+
clearTimeout(copyTimerRef.current);
|
|
54
|
+
copyTimerRef.current = setTimeout(() => setCopied(false), 2e3);
|
|
55
|
+
}).catch(() => {
|
|
56
|
+
});
|
|
57
|
+
}, [code]);
|
|
58
|
+
const languageLabel = getLanguageDisplayName(normalizedLanguage);
|
|
59
|
+
const accent = languageToColorMap[normalizedLanguage] || "#737373";
|
|
60
|
+
const cardStyle = useMemo(() => ({ "--rr-code-accent": accent }), [accent]);
|
|
61
|
+
const scrollClassName = [
|
|
62
|
+
scroll,
|
|
63
|
+
semanticClassNames.scroll,
|
|
64
|
+
collapsible && isCollapsed && isOverflow && scrollCollapsed,
|
|
65
|
+
collapsible && isCollapsed && isOverflow && semanticClassNames.scrollCollapsed
|
|
66
|
+
].filter(Boolean).join(" ");
|
|
67
|
+
return /* @__PURE__ */ jsxs("div", { className: `${card} ${semanticClassNames.card}`, style: cardStyle, children: [
|
|
68
|
+
langSlot ?? (normalizedLanguage !== "text" && /* @__PURE__ */ jsx("div", { "aria-hidden": true, className: `${lang} ${semanticClassNames.lang}`, children: hasLanguageIcon(normalizedLanguage) ? /* @__PURE__ */ jsx(LanguageIcon, { language: normalizedLanguage, size: 14 }) : /* @__PURE__ */ jsx("span", { children: languageLabel }) })),
|
|
69
|
+
/* @__PURE__ */ jsx(
|
|
70
|
+
"button",
|
|
71
|
+
{
|
|
72
|
+
"aria-label": copied ? "Copied" : "Copy code",
|
|
73
|
+
className: `${copyButton} ${semanticClassNames.copyButton}`,
|
|
74
|
+
type: "button",
|
|
75
|
+
onClick: handleCopy,
|
|
76
|
+
children: copied ? CheckIcon : CopyIcon
|
|
77
|
+
}
|
|
78
|
+
),
|
|
79
|
+
/* @__PURE__ */ jsxs(
|
|
80
|
+
"div",
|
|
81
|
+
{
|
|
82
|
+
className: `${staticMode ? bodyBackgroundStatic : bodyBackground} ${semanticClassNames.bodyBackground}`,
|
|
83
|
+
children: [
|
|
84
|
+
/* @__PURE__ */ jsx("div", { className: scrollClassName, ref: scrollRef, children }),
|
|
85
|
+
collapsible && isOverflow && isCollapsed && /* @__PURE__ */ jsx("div", { className: `${expandWrap} ${semanticClassNames.expandWrap}`, children: /* @__PURE__ */ jsxs(
|
|
86
|
+
"button",
|
|
87
|
+
{
|
|
88
|
+
className: `${expandButton} ${semanticClassNames.expandButton}`,
|
|
89
|
+
type: "button",
|
|
90
|
+
onClick: () => setIsCollapsed(false),
|
|
91
|
+
children: [
|
|
92
|
+
ExpandIcon,
|
|
93
|
+
/* @__PURE__ */ jsx("span", { children: "展开" })
|
|
94
|
+
]
|
|
95
|
+
}
|
|
96
|
+
) })
|
|
97
|
+
]
|
|
98
|
+
}
|
|
99
|
+
)
|
|
100
|
+
] });
|
|
101
|
+
}
|
|
16
102
|
const languageItems = bundledLanguagesInfo.map((info) => ({
|
|
17
103
|
id: info.id,
|
|
18
104
|
name: info.name
|
|
@@ -274,5 +360,5 @@ const CodeBlockEditRenderer = ({
|
|
|
274
360
|
};
|
|
275
361
|
export {
|
|
276
362
|
CodeBlockEditRenderer,
|
|
277
|
-
|
|
363
|
+
CodeBlockRenderer
|
|
278
364
|
};
|
|
@@ -134,23 +134,23 @@ const LanguageIcon = ({
|
|
|
134
134
|
);
|
|
135
135
|
};
|
|
136
136
|
export {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
137
|
+
LanguageIcon as L,
|
|
138
|
+
copyButton as a,
|
|
139
|
+
bodyBackgroundStatic as b,
|
|
140
|
+
card as c,
|
|
141
|
+
bodyBackground as d,
|
|
142
|
+
expandWrap as e,
|
|
143
|
+
expandButton as f,
|
|
144
|
+
scroll as g,
|
|
145
145
|
hasLanguageIcon as h,
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
146
|
+
scrollCollapsed as i,
|
|
147
|
+
langInput as j,
|
|
148
|
+
lined as k,
|
|
149
149
|
lang as l,
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
150
|
+
linedWithNumbers as m,
|
|
151
|
+
body as n,
|
|
152
|
+
bodyReadonly as o,
|
|
153
|
+
getMaterialIconSvg as p,
|
|
154
|
+
LANG_TO_ICON as q,
|
|
155
155
|
semanticClassNames as s
|
|
156
156
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
:root{--rc-text: #000;--rc-text-secondary: #27272a;--rc-text-tertiary: #71717a;--rc-text-quaternary: #a1a1aa;--rc-bg: #ffffff;--rc-bg-secondary: #fafafa;--rc-bg-tertiary: #f4f4f5;--rc-fill: #e8e8ec;--rc-fill-secondary: #eeeeef;--rc-fill-tertiary: #f4f4f6;--rc-fill-quaternary: #f9f9fa;--rc-border: #f4f4f5;--rc-accent: #2563eb;--rc-accent-light: #2563eb20;--rc-link: #2563eb;--rc-code-text: #3f3f46;--rc-code-bg: #f4f4f5;--rc-hr-border: #e4e4e7;--rc-quote-border: #2563eb;--rc-quote-bg: #eff6ff;--rc-alert-info: #006bb7;--rc-alert-warning: #cc5500;--rc-alert-tip: #11cc00;--rc-alert-caution: #cc0011;--rc-alert-important: #5500cc;--rc-max-width: 700px;--rc-shadow-top-bar: 0 8px 30px rgba(0, 0, 0, .12), 0 2px 8px rgba(0, 0, 0, .06);--rc-shadow-modal: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -4px rgba(0,0,0,.1);--rc-shadow-menu: 0 1px 4px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.08);--rc-space-xs: 4px;--rc-space-sm: 8px;--rc-space-md: 16px;--rc-space-lg: 24px;--rc-space-xl: 32px;--rc-font-family-sans: "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, Helvetica, "noto sans sc", "hiragino sans gb", -apple-system, system-ui, sans-serif, Apple Color Emoji, Segoe UI Emoji, Not Color Emoji;--rc-font-family-serif: "Noto Serif CJK SC", "Source Han Serif SC", "Source Han Serif", "source-han-serif-sc", "Songti SC", STSong, "华文宋体", serif;--rc-font-mono: "SF Mono", SFMono-Regular, ui-monospace, "DejaVu Sans Mono", Menlo, Consolas, monospace;--rc-font-size-2xs: .625em;--rc-font-size-xs: .75em;--rc-font-size-sm: .8125em;--rc-font-size-md: .875em;--rc-font-size-lg: 1.25em;--rc-font-size-base: 16px;--rc-font-size-small: 14px;--rc-line-height: 1.7;--rc-line-height-tight: 1.4;--rc-font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, Helvetica, "noto sans sc", "hiragino sans gb", -apple-system, system-ui, sans-serif, Apple Color Emoji, Segoe UI Emoji, Not Color Emoji;--rc-radius-sm: 4px;--rc-radius-md: 8px;--rc-radius-lg: 12px}:root.dark{--rc-text: #fafafa;--rc-text-secondary: #a1a1aa;--rc-text-tertiary: #71717a;--rc-text-quaternary: #52525b;--rc-bg: #09090b;--rc-bg-secondary: #18181b;--rc-bg-tertiary: #27272a;--rc-fill: #2a2a2f;--rc-fill-secondary: #222226;--rc-fill-tertiary: #1b1b1f;--rc-fill-quaternary: #131316;--rc-border: #27272a;--rc-accent: #60a5fa;--rc-accent-light: #60a5fa20;--rc-link: #60a5fa;--rc-code-text: #e4e4e7;--rc-code-bg: #27272a;--rc-hr-border: #27272a;--rc-quote-border: #60a5fa;--rc-quote-bg: #1e3a5f;--rc-alert-info: #7db9e5;--rc-alert-warning: #da864a;--rc-alert-tip: #54da48;--rc-alert-caution: #e16973;--rc-alert-important: #9966e0;--rc-max-width: 700px;--rc-shadow-top-bar: 0 8px 30px rgba(0, 0, 0, .45), 0 2px 8px rgba(0, 0, 0, .3);--rc-shadow-modal: 0 10px 15px -3px rgba(0,0,0,.4), 0 4px 6px -4px rgba(0,0,0,.35);--rc-shadow-menu: 0 1px 4px rgba(0,0,0,.25), 0 4px 16px rgba(0,0,0,.4);--rc-space-xs: 4px;--rc-space-sm: 8px;--rc-space-md: 16px;--rc-space-lg: 24px;--rc-space-xl: 32px;--rc-font-family-sans: "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, Helvetica, "noto sans sc", "hiragino sans gb", -apple-system, system-ui, sans-serif, Apple Color Emoji, Segoe UI Emoji, Not Color Emoji;--rc-font-family-serif: "Noto Serif CJK SC", "Source Han Serif SC", "Source Han Serif", "source-han-serif-sc", "Songti SC", STSong, "华文宋体", serif;--rc-font-mono: "SF Mono", SFMono-Regular, ui-monospace, "DejaVu Sans Mono", Menlo, Consolas, monospace;--rc-font-size-2xs: .625em;--rc-font-size-xs: .75em;--rc-font-size-sm: .8125em;--rc-font-size-md: .875em;--rc-font-size-lg: 1.25em;--rc-font-size-base: 16px;--rc-font-size-small: 14px;--rc-line-height: 1.7;--rc-line-height-tight: 1.4;--rc-font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, Helvetica, "noto sans sc", "hiragino sans gb", -apple-system, system-ui, sans-serif, Apple Color Emoji, Segoe UI Emoji, Not Color Emoji;--rc-radius-sm: 4px;--rc-radius-md: 8px;--rc-radius-lg: 12px}.axx50{--rc-text: #000;--rc-text-secondary: #27272a;--rc-text-tertiary: #71717a;--rc-text-quaternary: #a1a1aa;--rc-bg: #ffffff;--rc-bg-secondary: #fafafa;--rc-bg-tertiary: #f4f4f5;--rc-fill: #e8e8ec;--rc-fill-secondary: #eeeeef;--rc-fill-tertiary: #f4f4f6;--rc-fill-quaternary: #f9f9fa;--rc-border: #f4f4f5;--rc-accent: #2563eb;--rc-accent-light: #2563eb20;--rc-link: #2563eb;--rc-code-text: #3f3f46;--rc-code-bg: #f4f4f5;--rc-hr-border: #e4e4e7;--rc-quote-border: #2563eb;--rc-quote-bg: #eff6ff;--rc-alert-info: #006bb7;--rc-alert-warning: #cc5500;--rc-alert-tip: #11cc00;--rc-alert-caution: #cc0011;--rc-alert-important: #5500cc;--rc-max-width: 700px;--rc-shadow-top-bar: 0 8px 30px rgba(0, 0, 0, .12), 0 2px 8px rgba(0, 0, 0, .06);--rc-shadow-modal: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -4px rgba(0,0,0,.1);--rc-shadow-menu: 0 1px 4px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.08);--rc-space-xs: 4px;--rc-space-sm: 8px;--rc-space-md: 16px;--rc-space-lg: 24px;--rc-space-xl: 32px;--rc-font-family-sans: "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, Helvetica, "noto sans sc", "hiragino sans gb", -apple-system, system-ui, sans-serif, Apple Color Emoji, Segoe UI Emoji, Not Color Emoji;--rc-font-family-serif: "Noto Serif CJK SC", "Source Han Serif SC", "Source Han Serif", "source-han-serif-sc", "Songti SC", STSong, "华文宋体", serif;--rc-font-mono: "SF Mono", SFMono-Regular, ui-monospace, "DejaVu Sans Mono", Menlo, Consolas, monospace;--rc-font-size-2xs: .625em;--rc-font-size-xs: .75em;--rc-font-size-sm: .8125em;--rc-font-size-md: .875em;--rc-font-size-lg: 1.25em;--rc-font-size-base: 16px;--rc-font-size-small: 14px;--rc-line-height: 1.7;--rc-line-height-tight: 1.4;--rc-font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, Helvetica, "noto sans sc", "hiragino sans gb", -apple-system, system-ui, sans-serif, Apple Color Emoji, Segoe UI Emoji, Not Color Emoji;--rc-radius-sm: 4px;--rc-radius-md: 8px;--rc-radius-lg: 12px}.axx51{--rc-text: #000;--rc-text-secondary: #27272a;--rc-text-tertiary: #71717a;--rc-text-quaternary: #a1a1aa;--rc-bg: #ffffff;--rc-bg-secondary: #fafafa;--rc-bg-tertiary: #f4f4f5;--rc-fill: #e8e8ec;--rc-fill-secondary: #eeeeef;--rc-fill-tertiary: #f4f4f6;--rc-fill-quaternary: #f9f9fa;--rc-border: #f4f4f5;--rc-accent: #2563eb;--rc-accent-light: #2563eb20;--rc-link: #2563eb;--rc-code-text: #3f3f46;--rc-code-bg: #f4f4f5;--rc-hr-border: #e4e4e7;--rc-quote-border: #2563eb;--rc-quote-bg: #eff6ff;--rc-alert-info: #006bb7;--rc-alert-warning: #cc5500;--rc-alert-tip: #11cc00;--rc-alert-caution: #cc0011;--rc-alert-important: #5500cc;--rc-max-width: 700px;--rc-shadow-top-bar: 0 8px 30px rgba(0, 0, 0, .12), 0 2px 8px rgba(0, 0, 0, .06);--rc-shadow-modal: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -4px rgba(0,0,0,.1);--rc-shadow-menu: 0 1px 4px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.08);--rc-space-xs: 4px;--rc-space-sm: 8px;--rc-space-md: 16px;--rc-space-lg: 24px;--rc-space-xl: 32px;--rc-font-family-sans: "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, Helvetica, "noto sans sc", "hiragino sans gb", -apple-system, system-ui, sans-serif, Apple Color Emoji, Segoe UI Emoji, Not Color Emoji;--rc-font-family-serif: "Noto Serif CJK SC", "Source Han Serif SC", "Source Han Serif", "source-han-serif-sc", "Songti SC", STSong, "华文宋体", serif;--rc-font-mono: "SF Mono", SFMono-Regular, ui-monospace, "DejaVu Sans Mono", Menlo, Consolas, monospace;--rc-font-size-2xs: .625em;--rc-font-size-xs: .75em;--rc-font-size-sm: .8125em;--rc-font-size-md: .875em;--rc-font-size-lg: 1.25em;--rc-font-size-base: 16px;--rc-font-size-small: 14px;--rc-line-height: 1.8;--rc-line-height-tight: 1.4;--rc-font-family: "Noto Serif CJK SC", "Source Han Serif SC", "Source Han Serif", "source-han-serif-sc", "Songti SC", STSong, "华文宋体", serif;--rc-radius-sm: 4px;--rc-radius-md: 8px;--rc-radius-lg: 12px}.axx52{--rc-text: #000;--rc-text-secondary: #27272a;--rc-text-tertiary: #71717a;--rc-text-quaternary: #a1a1aa;--rc-bg: #ffffff;--rc-bg-secondary: #fafafa;--rc-bg-tertiary: #f4f4f5;--rc-fill: #e8e8ec;--rc-fill-secondary: #eeeeef;--rc-fill-tertiary: #f4f4f6;--rc-fill-quaternary: #f9f9fa;--rc-border: #f4f4f5;--rc-accent: #2563eb;--rc-accent-light: #2563eb20;--rc-link: #2563eb;--rc-code-text: #3f3f46;--rc-code-bg: #f4f4f5;--rc-hr-border: #e4e4e7;--rc-quote-border: #a1a1aa;--rc-quote-bg: #fafafa;--rc-alert-info: #006bb7;--rc-alert-warning: #cc5500;--rc-alert-tip: #11cc00;--rc-alert-caution: #cc0011;--rc-alert-important: #5500cc;--rc-max-width: none;--rc-shadow-top-bar: 0 8px 30px rgba(0, 0, 0, .12), 0 2px 8px rgba(0, 0, 0, .06);--rc-shadow-modal: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -4px rgba(0,0,0,.1);--rc-shadow-menu: 0 1px 4px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.08);--rc-space-xs: 2px;--rc-space-sm: 4px;--rc-space-md: 10px;--rc-space-lg: 16px;--rc-space-xl: 20px;--rc-font-family-sans: "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, Helvetica, "noto sans sc", "hiragino sans gb", -apple-system, system-ui, sans-serif, Apple Color Emoji, Segoe UI Emoji, Not Color Emoji;--rc-font-family-serif: "Noto Serif CJK SC", "Source Han Serif SC", "Source Han Serif", "source-han-serif-sc", "Songti SC", STSong, "华文宋体", serif;--rc-font-mono: "SF Mono", SFMono-Regular, ui-monospace, "DejaVu Sans Mono", Menlo, Consolas, monospace;--rc-font-size-2xs: .625em;--rc-font-size-xs: .75em;--rc-font-size-sm: .8125em;--rc-font-size-md: .875em;--rc-font-size-lg: 1.25em;--rc-font-size-base: 14px;--rc-font-size-small: 12px;--rc-line-height: 1.5;--rc-line-height-tight: 1.3;--rc-font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, Helvetica, "noto sans sc", "hiragino sans gb", -apple-system, system-ui, sans-serif, Apple Color Emoji, Segoe UI Emoji, Not Color Emoji;--rc-radius-sm: 3px;--rc-radius-md: 6px;--rc-radius-lg: 12px}.dark .axx50,[data-theme=dark] .axx50,.dark.axx50,[data-theme=dark].axx50,.dark .axx51,[data-theme=dark] .axx51,.dark.axx51,[data-theme=dark].axx51,.dark .axx52,[data-theme=dark] .axx52,.dark.axx52,[data-theme=dark].axx52{--rc-text: #fafafa;--rc-text-secondary: #a1a1aa;--rc-text-tertiary: #71717a;--rc-text-quaternary: #52525b;--rc-bg: #09090b;--rc-bg-secondary: #18181b;--rc-bg-tertiary: #27272a;--rc-fill: #2a2a2f;--rc-fill-secondary: #222226;--rc-fill-tertiary: #1b1b1f;--rc-fill-quaternary: #131316;--rc-border: #27272a;--rc-accent: #60a5fa;--rc-accent-light: #60a5fa20;--rc-link: #60a5fa;--rc-code-text: #e4e4e7;--rc-code-bg: #27272a;--rc-hr-border: #27272a;--rc-quote-border: #60a5fa;--rc-quote-bg: #1e3a5f;--rc-alert-info: #7db9e5;--rc-alert-warning: #da864a;--rc-alert-tip: #54da48;--rc-alert-caution: #e16973;--rc-alert-important: #9966e0;--rc-shadow-top-bar: 0 8px 30px rgba(0, 0, 0, .45), 0 2px 8px rgba(0, 0, 0, .3);--rc-shadow-modal: 0 10px 15px -3px rgba(0,0,0,.4), 0 4px 6px -4px rgba(0,0,0,.35);--rc-shadow-menu: 0 1px 4px rgba(0,0,0,.25), 0 4px 16px rgba(0,0,0,.4)}._1pn9r4q0{--rr-code-accent: #737373;position:relative;margin:1.5rem 0;border-radius:.5rem;overflow:hidden;font-size:var(--rc-font-size-md);font-family:var(--rc-font-mono)}._1pn9r4q1{appearance:none;border:none;background:transparent;color:inherit;font:inherit;padding:0;outline:none;width:8em;opacity:1}._1pn9r4q1::placeholder{opacity:.5}._1pn9r4q2{position:absolute;bottom:.75rem;right:.75rem;z-index:1;display:flex;align-items:center;gap:.375rem;font-size:var(--rc-font-size-md);opacity:.6;pointer-events:none}._1pn9r4q2:has(._1pn9r4q1){pointer-events:auto}._1pn9r4q3{display:inline-flex;flex-shrink:0}._1pn9r4q3 svg{width:100%;height:100%}._1pn9r4q4{appearance:none;position:absolute;right:.5rem;top:.5rem;z-index:3;display:flex;align-items:center;justify-content:center;padding:.375rem;border-radius:.375rem;border:1px solid color-mix(in srgb,var(--rr-code-accent) 5%,transparent);background:color-mix(in srgb,var(--rr-code-accent) 80%,transparent);color:#fff;cursor:pointer;opacity:0;transition:opacity .2s ease;backdrop-filter:blur(8px)}._1pn9r4q0:hover ._1pn9r4q4{opacity:1}._1pn9r4q5{position:relative;background:color-mix(in srgb,var(--rr-code-accent) 5%,transparent);padding:0}._1pn9r4q6{padding-block:12px}._1pn9r4q7{position:relative;width:100%;overflow:auto}._1pn9r4q8{max-height:50vh;overflow:hidden}._1pn9r4q9{position:relative;overflow:auto;background-color:transparent!important}._1pn9r4q9 .cm-editor{background:transparent;color:var(--rc-text);font-family:var(--rc-font-mono)}._1pn9r4q9 .cm-scroller{font-family:var(--rc-font-mono)!important;line-height:1.6}._1pn9r4q9 .cm-content{padding-top:0;padding-bottom:0;padding-left:1.25rem;padding-right:1.25rem;min-height:1.6em}._1pn9r4q9:has(.cm-gutters) .cm-content{padding-left:.5rem;padding-right:1.25rem}._1pn9r4q9 .cm-line{padding:0}._1pn9r4q9 .cm-gutters{border-right:none;padding-left:1.25rem}._1pn9r4q9 .cm-lineNumbers .cm-gutterElement{min-width:3em;text-align:right;padding-right:2em;color:color-mix(in srgb,var(--rc-text-secondary) 40%,transparent)!important}._1pn9r4q9>.shikicode.output{position:static!important;inset:auto!important}._1pn9r4qa>textarea.shikicode{display:none}._1pn9r4qb{position:absolute;bottom:0;left:0;right:0;display:flex;justify-content:center;padding:.5rem 0 .75rem;background:linear-gradient(to bottom,transparent 0%,var(--bg, var(--rc-bg-secondary)) 80%);pointer-events:none}._1pn9r4qc{appearance:none;border:none;background:none;cursor:pointer;display:flex;align-items:center;gap:.5rem;font-size:var(--rc-font-size-xs);color:inherit;opacity:.7;pointer-events:auto}._1pn9r4qc:hover{opacity:1}._1pn9r4q0 .shikicode.input,._1pn9r4q0 .shikicode.output,._1pn9r4q0 .shikicode.output code,._1pn9r4q0 .shikicode.output .line,._1pn9r4q0 .shikicode.output .line span{font-variant-ligatures:none;font-kerning:none}._1pn9r4q0 .shikicode.input,._1pn9r4q0 .shikicode.output,._1pn9r4q9 pre,._1pn9r4q9 code,._1pn9r4q9 .line,._1pn9r4q9 .line span{font-family:var(--rc-font-mono)!important}._1pn9r4q0 pre{margin:0!important;padding:0!important;border-radius:0;font-size:1em}._1pn9r4q0 pre code{display:flex;flex-direction:column;font-family:var(--rc-font-mono)!important}._1pn9r4q0 .shiki,._1pn9r4q0 code,._1pn9r4q0 pre{background:transparent!important}[data-theme=dark] ._1pn9r4q0 .shiki-themes,[data-theme=dark] ._1pn9r4q0 .shiki-themes span{color:var(--shiki-dark)!important;font-style:var(--shiki-dark-font-style)!important;font-weight:var(--shiki-dark-font-weight)!important;text-decoration:var(--shiki-dark-text-decoration)!important}._1pn9r4q9:has(.shikicode.input.line-numbers) .shikicode.output .line:before{background-color:transparent!important;color:color-mix(in srgb,var(--rc-text-secondary) 40%,transparent)!important;width:5em;padding-right:2em}._1pn9r4q9:not(:has(.shikicode.input.line-numbers)) .shikicode.output .line:before{display:none}._1pn9r4q0 .line{display:block;padding:0 1.25rem}._1pn9r4q0 .shikicode.input.line-numbers{padding-left:calc(5em + 1.25rem)}._1pn9r4q0 .shikicode.input:not(.line-numbers){padding-left:1.25rem}._1pn9r4q0 .line>span:last-child{margin-right:1.25rem}._1pn9r4q0 .line:after{content:" "}._1pn9r4q0 .highlighted,._1pn9r4q0 .diff{position:relative;overflow-wrap:break-word}._1pn9r4q0 .highlighted:before,._1pn9r4q0 .diff:before{content:"";position:absolute;left:0;top:0;height:100%;width:2px}._1pn9r4q0 .highlighted{background:color-mix(in srgb,var(--rr-code-accent) 20%,transparent)}._1pn9r4q0 .highlighted:before{background:var(--rr-code-accent)}._1pn9r4q0 .diff.add{background:#22c55e26}._1pn9r4q0 .diff.add:before{background:#22c55e}._1pn9r4q0 .diff.add:after{content:" +";position:absolute;left:0;color:#22c55e}._1pn9r4q0 .diff.remove{background:#ef444426}._1pn9r4q0 .diff.remove:before{background:#ef4444}._1pn9r4q0 .diff.remove:after{content:" -";position:absolute;left:0;color:#ef4444}._1pn9r4qd{counter-reset:shiki-line 0}._1pn9r4qd .line{counter-increment:shiki-line 1}._1pn9r4qd .line:before{content:counter(shiki-line);color:transparent;text-align:right;box-sizing:border-box;width:2em;display:inline-block;position:sticky;left:0}._1pn9r4qe .line:before{color:inherit;opacity:.4;width:5em;padding-right:2em}._1pn9r4q7 pre::-webkit-scrollbar-track{margin-left:1rem;margin-right:var(--sr-margin, 0)}._1pn9r4q7 pre::-webkit-scrollbar{background-color:transparent!important}._1pn9r4qf{font-family:var(--rc-font-mono);font-size:var(--rc-font-size-md);background-color:var(--rc-code-bg);border-radius:var(--rc-radius-md);overflow:hidden;margin:var(--rc-space-md) 0;border:1px solid var(--rc-border)}._1pn9r4qg{display:flex;align-items:center;justify-content:space-between;padding:var(--rc-space-sm) var(--rc-space-md);border-bottom:1px solid var(--rc-border);font-size:var(--rc-font-size-md);color:var(--rc-text-secondary);user-select:none}._1pn9r4qh{font-family:var(--rc-font-mono);font-size:.85em;text-transform:uppercase;letter-spacing:.05em}._1pn9r4qi{appearance:none;border:none;background:none;color:var(--rc-text-secondary);cursor:pointer;padding:var(--rc-space-xs) var(--rc-space-sm);border-radius:var(--rc-radius-sm);font-family:var(--rc-font-family);font-size:var(--rc-font-size-md);line-height:1;transition:color .15s ease,background-color .15s ease}.rich-code-block{font-family:var(--rc-font-mono);font-size:var(--rc-font-size-md);background-color:var(--rc-code-bg);border-radius:var(--rc-radius-md);overflow:hidden;margin:var(--rc-space-md) 0;border:1px solid var(--rc-border)}.rich-code-block pre{margin:0;padding:var(--rc-space-md);overflow-x:auto}.rich-code-block code{font-family:inherit;font-size:inherit;background:none;border:none;padding:0;color:inherit}.rich-code-block-header{display:flex;align-items:center;justify-content:space-between;padding:var(--rc-space-sm) var(--rc-space-md);border-bottom:1px solid var(--rc-border);font-size:var(--rc-font-size-md);color:var(--rc-text-secondary);user-select:none}.rich-code-block-lang{font-family:var(--rc-font-mono);font-size:.85em;text-transform:uppercase;letter-spacing:.05em}.rich-code-block-copy{appearance:none;border:none;background:none;color:var(--rc-text-secondary);cursor:pointer;padding:var(--rc-space-xs) var(--rc-space-sm);border-radius:var(--rc-radius-sm);font-family:var(--rc-font-family);font-size:var(--rc-font-size-md);line-height:1;transition:color .15s ease,background-color .15s ease}.rich-code-block-copy:hover{color:var(--rc-text);background-color:var(--rc-fill-secondary)}.rich-code-block-numbered pre{counter-reset:line}.rich-code-block-numbered .line{counter-increment:line}.rich-code-block-numbered .line:before{content:counter(line);display:inline-block;width:2.5em;margin-right:var(--rc-space-md);text-align:right;color:color-mix(in srgb,var(--rc-text-secondary) 40%,transparent)!important;opacity:.4;user-select:none;font-size:var(--rc-font-size-md)}
|
|
1
|
+
:root{--rc-text: #000;--rc-text-secondary: #262626;--rc-text-tertiary: #737373;--rc-text-quaternary: #a3a3a3;--rc-bg: #ffffff;--rc-bg-secondary: #fafafa;--rc-bg-tertiary: #f5f5f5;--rc-fill: #e8e8e8;--rc-fill-secondary: #eeeeee;--rc-fill-tertiary: #f5f5f5;--rc-fill-quaternary: #fafafa;--rc-border: #f5f5f5;--rc-accent: #2563eb;--rc-accent-light: #2563eb20;--rc-link: #2563eb;--rc-code-text: #404040;--rc-code-bg: #f5f5f5;--rc-hr-border: #e5e5e5;--rc-quote-border: #2563eb;--rc-quote-bg: #f5f5f5;--rc-alert-info: #006bb7;--rc-alert-warning: #cc5500;--rc-alert-tip: #11cc00;--rc-alert-caution: #cc0011;--rc-alert-important: #5500cc;--rc-max-width: 700px;--rc-shadow-top-bar: 0 8px 30px rgba(0, 0, 0, .12), 0 2px 8px rgba(0, 0, 0, .06);--rc-shadow-modal: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -4px rgba(0,0,0,.1);--rc-shadow-menu: 0 1px 4px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.08);--rc-space-xs: 4px;--rc-space-sm: 8px;--rc-space-md: 16px;--rc-space-lg: 24px;--rc-space-xl: 32px;--rc-font-family-sans: "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, Helvetica, "noto sans sc", "hiragino sans gb", -apple-system, system-ui, sans-serif, Apple Color Emoji, Segoe UI Emoji, Not Color Emoji;--rc-font-family-serif: "Noto Serif CJK SC", "Source Han Serif SC", "Source Han Serif", "source-han-serif-sc", "Songti SC", STSong, "华文宋体", serif;--rc-font-mono: "SF Mono", SFMono-Regular, ui-monospace, "DejaVu Sans Mono", Menlo, Consolas, monospace;--rc-font-size-2xs: .625em;--rc-font-size-xs: .75em;--rc-font-size-sm: .8125em;--rc-font-size-md: .875em;--rc-font-size-lg: 1.25em;--rc-font-size-base: 16px;--rc-font-size-small: 14px;--rc-line-height: 1.7;--rc-line-height-tight: 1.4;--rc-font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, Helvetica, "noto sans sc", "hiragino sans gb", -apple-system, system-ui, sans-serif, Apple Color Emoji, Segoe UI Emoji, Not Color Emoji;--rc-radius-sm: 4px;--rc-radius-md: 8px;--rc-radius-lg: 12px}:root.dark{--rc-text: #fafafa;--rc-text-secondary: #a3a3a3;--rc-text-tertiary: #737373;--rc-text-quaternary: #525252;--rc-bg: #0a0a0a;--rc-bg-secondary: #171717;--rc-bg-tertiary: #262626;--rc-fill: #2a2a2a;--rc-fill-secondary: #222222;--rc-fill-tertiary: #1a1a1a;--rc-fill-quaternary: #141414;--rc-border: #262626;--rc-accent: #60a5fa;--rc-accent-light: #60a5fa20;--rc-link: #60a5fa;--rc-code-text: #d4d4d4;--rc-code-bg: #262626;--rc-hr-border: #262626;--rc-quote-border: #60a5fa;--rc-quote-bg: #262626;--rc-alert-info: #7db9e5;--rc-alert-warning: #da864a;--rc-alert-tip: #54da48;--rc-alert-caution: #e16973;--rc-alert-important: #9966e0;--rc-max-width: 700px;--rc-shadow-top-bar: 0 8px 30px rgba(0, 0, 0, .45), 0 2px 8px rgba(0, 0, 0, .3);--rc-shadow-modal: 0 10px 15px -3px rgba(0,0,0,.4), 0 4px 6px -4px rgba(0,0,0,.35);--rc-shadow-menu: 0 1px 4px rgba(0,0,0,.25), 0 4px 16px rgba(0,0,0,.4);--rc-space-xs: 4px;--rc-space-sm: 8px;--rc-space-md: 16px;--rc-space-lg: 24px;--rc-space-xl: 32px;--rc-font-family-sans: "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, Helvetica, "noto sans sc", "hiragino sans gb", -apple-system, system-ui, sans-serif, Apple Color Emoji, Segoe UI Emoji, Not Color Emoji;--rc-font-family-serif: "Noto Serif CJK SC", "Source Han Serif SC", "Source Han Serif", "source-han-serif-sc", "Songti SC", STSong, "华文宋体", serif;--rc-font-mono: "SF Mono", SFMono-Regular, ui-monospace, "DejaVu Sans Mono", Menlo, Consolas, monospace;--rc-font-size-2xs: .625em;--rc-font-size-xs: .75em;--rc-font-size-sm: .8125em;--rc-font-size-md: .875em;--rc-font-size-lg: 1.25em;--rc-font-size-base: 16px;--rc-font-size-small: 14px;--rc-line-height: 1.7;--rc-line-height-tight: 1.4;--rc-font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, Helvetica, "noto sans sc", "hiragino sans gb", -apple-system, system-ui, sans-serif, Apple Color Emoji, Segoe UI Emoji, Not Color Emoji;--rc-radius-sm: 4px;--rc-radius-md: 8px;--rc-radius-lg: 12px}[data-theme=dark]{--rc-text: #fafafa;--rc-text-secondary: #a3a3a3;--rc-text-tertiary: #737373;--rc-text-quaternary: #525252;--rc-bg: #0a0a0a;--rc-bg-secondary: #171717;--rc-bg-tertiary: #262626;--rc-fill: #2a2a2a;--rc-fill-secondary: #222222;--rc-fill-tertiary: #1a1a1a;--rc-fill-quaternary: #141414;--rc-border: #262626;--rc-accent: #60a5fa;--rc-accent-light: #60a5fa20;--rc-link: #60a5fa;--rc-code-text: #d4d4d4;--rc-code-bg: #262626;--rc-hr-border: #262626;--rc-quote-border: #60a5fa;--rc-quote-bg: #262626;--rc-alert-info: #7db9e5;--rc-alert-warning: #da864a;--rc-alert-tip: #54da48;--rc-alert-caution: #e16973;--rc-alert-important: #9966e0;--rc-max-width: 700px;--rc-shadow-top-bar: 0 8px 30px rgba(0, 0, 0, .45), 0 2px 8px rgba(0, 0, 0, .3);--rc-shadow-modal: 0 10px 15px -3px rgba(0,0,0,.4), 0 4px 6px -4px rgba(0,0,0,.35);--rc-shadow-menu: 0 1px 4px rgba(0,0,0,.25), 0 4px 16px rgba(0,0,0,.4);--rc-space-xs: 4px;--rc-space-sm: 8px;--rc-space-md: 16px;--rc-space-lg: 24px;--rc-space-xl: 32px;--rc-font-family-sans: "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, Helvetica, "noto sans sc", "hiragino sans gb", -apple-system, system-ui, sans-serif, Apple Color Emoji, Segoe UI Emoji, Not Color Emoji;--rc-font-family-serif: "Noto Serif CJK SC", "Source Han Serif SC", "Source Han Serif", "source-han-serif-sc", "Songti SC", STSong, "华文宋体", serif;--rc-font-mono: "SF Mono", SFMono-Regular, ui-monospace, "DejaVu Sans Mono", Menlo, Consolas, monospace;--rc-font-size-2xs: .625em;--rc-font-size-xs: .75em;--rc-font-size-sm: .8125em;--rc-font-size-md: .875em;--rc-font-size-lg: 1.25em;--rc-font-size-base: 16px;--rc-font-size-small: 14px;--rc-line-height: 1.7;--rc-line-height-tight: 1.4;--rc-font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, Helvetica, "noto sans sc", "hiragino sans gb", -apple-system, system-ui, sans-serif, Apple Color Emoji, Segoe UI Emoji, Not Color Emoji;--rc-radius-sm: 4px;--rc-radius-md: 8px;--rc-radius-lg: 12px}.axx50{--rc-text: #000;--rc-text-secondary: #262626;--rc-text-tertiary: #737373;--rc-text-quaternary: #a3a3a3;--rc-bg: #ffffff;--rc-bg-secondary: #fafafa;--rc-bg-tertiary: #f5f5f5;--rc-fill: #e8e8e8;--rc-fill-secondary: #eeeeee;--rc-fill-tertiary: #f5f5f5;--rc-fill-quaternary: #fafafa;--rc-border: #f5f5f5;--rc-accent: #2563eb;--rc-accent-light: #2563eb20;--rc-link: #2563eb;--rc-code-text: #404040;--rc-code-bg: #f5f5f5;--rc-hr-border: #e5e5e5;--rc-quote-border: #2563eb;--rc-quote-bg: #f5f5f5;--rc-alert-info: #006bb7;--rc-alert-warning: #cc5500;--rc-alert-tip: #11cc00;--rc-alert-caution: #cc0011;--rc-alert-important: #5500cc;--rc-max-width: 700px;--rc-shadow-top-bar: 0 8px 30px rgba(0, 0, 0, .12), 0 2px 8px rgba(0, 0, 0, .06);--rc-shadow-modal: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -4px rgba(0,0,0,.1);--rc-shadow-menu: 0 1px 4px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.08);--rc-space-xs: 4px;--rc-space-sm: 8px;--rc-space-md: 16px;--rc-space-lg: 24px;--rc-space-xl: 32px;--rc-font-family-sans: "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, Helvetica, "noto sans sc", "hiragino sans gb", -apple-system, system-ui, sans-serif, Apple Color Emoji, Segoe UI Emoji, Not Color Emoji;--rc-font-family-serif: "Noto Serif CJK SC", "Source Han Serif SC", "Source Han Serif", "source-han-serif-sc", "Songti SC", STSong, "华文宋体", serif;--rc-font-mono: "SF Mono", SFMono-Regular, ui-monospace, "DejaVu Sans Mono", Menlo, Consolas, monospace;--rc-font-size-2xs: .625em;--rc-font-size-xs: .75em;--rc-font-size-sm: .8125em;--rc-font-size-md: .875em;--rc-font-size-lg: 1.25em;--rc-font-size-base: 16px;--rc-font-size-small: 14px;--rc-line-height: 1.7;--rc-line-height-tight: 1.4;--rc-font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, Helvetica, "noto sans sc", "hiragino sans gb", -apple-system, system-ui, sans-serif, Apple Color Emoji, Segoe UI Emoji, Not Color Emoji;--rc-radius-sm: 4px;--rc-radius-md: 8px;--rc-radius-lg: 12px}.axx51{--rc-text: #000;--rc-text-secondary: #262626;--rc-text-tertiary: #737373;--rc-text-quaternary: #a3a3a3;--rc-bg: #ffffff;--rc-bg-secondary: #fafafa;--rc-bg-tertiary: #f5f5f5;--rc-fill: #e8e8e8;--rc-fill-secondary: #eeeeee;--rc-fill-tertiary: #f5f5f5;--rc-fill-quaternary: #fafafa;--rc-border: #f5f5f5;--rc-accent: #2563eb;--rc-accent-light: #2563eb20;--rc-link: #2563eb;--rc-code-text: #404040;--rc-code-bg: #f5f5f5;--rc-hr-border: #e5e5e5;--rc-quote-border: #2563eb;--rc-quote-bg: #f5f5f5;--rc-alert-info: #006bb7;--rc-alert-warning: #cc5500;--rc-alert-tip: #11cc00;--rc-alert-caution: #cc0011;--rc-alert-important: #5500cc;--rc-max-width: 700px;--rc-shadow-top-bar: 0 8px 30px rgba(0, 0, 0, .12), 0 2px 8px rgba(0, 0, 0, .06);--rc-shadow-modal: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -4px rgba(0,0,0,.1);--rc-shadow-menu: 0 1px 4px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.08);--rc-space-xs: 4px;--rc-space-sm: 8px;--rc-space-md: 16px;--rc-space-lg: 24px;--rc-space-xl: 32px;--rc-font-family-sans: "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, Helvetica, "noto sans sc", "hiragino sans gb", -apple-system, system-ui, sans-serif, Apple Color Emoji, Segoe UI Emoji, Not Color Emoji;--rc-font-family-serif: "Noto Serif CJK SC", "Source Han Serif SC", "Source Han Serif", "source-han-serif-sc", "Songti SC", STSong, "华文宋体", serif;--rc-font-mono: "SF Mono", SFMono-Regular, ui-monospace, "DejaVu Sans Mono", Menlo, Consolas, monospace;--rc-font-size-2xs: .625em;--rc-font-size-xs: .75em;--rc-font-size-sm: .8125em;--rc-font-size-md: .875em;--rc-font-size-lg: 1.25em;--rc-font-size-base: 16px;--rc-font-size-small: 14px;--rc-line-height: 1.8;--rc-line-height-tight: 1.4;--rc-font-family: "Noto Serif CJK SC", "Source Han Serif SC", "Source Han Serif", "source-han-serif-sc", "Songti SC", STSong, "华文宋体", serif;--rc-radius-sm: 4px;--rc-radius-md: 8px;--rc-radius-lg: 12px}.axx52{--rc-text: #000;--rc-text-secondary: #262626;--rc-text-tertiary: #737373;--rc-text-quaternary: #a3a3a3;--rc-bg: #ffffff;--rc-bg-secondary: #fafafa;--rc-bg-tertiary: #f5f5f5;--rc-fill: #e8e8e8;--rc-fill-secondary: #eeeeee;--rc-fill-tertiary: #f5f5f5;--rc-fill-quaternary: #fafafa;--rc-border: #f5f5f5;--rc-accent: #2563eb;--rc-accent-light: #2563eb20;--rc-link: #2563eb;--rc-code-text: #404040;--rc-code-bg: #f5f5f5;--rc-hr-border: #e5e5e5;--rc-quote-border: #a3a3a3;--rc-quote-bg: #fafafa;--rc-alert-info: #006bb7;--rc-alert-warning: #cc5500;--rc-alert-tip: #11cc00;--rc-alert-caution: #cc0011;--rc-alert-important: #5500cc;--rc-max-width: none;--rc-shadow-top-bar: 0 8px 30px rgba(0, 0, 0, .12), 0 2px 8px rgba(0, 0, 0, .06);--rc-shadow-modal: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -4px rgba(0,0,0,.1);--rc-shadow-menu: 0 1px 4px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.08);--rc-space-xs: 2px;--rc-space-sm: 4px;--rc-space-md: 10px;--rc-space-lg: 16px;--rc-space-xl: 20px;--rc-font-family-sans: "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, Helvetica, "noto sans sc", "hiragino sans gb", -apple-system, system-ui, sans-serif, Apple Color Emoji, Segoe UI Emoji, Not Color Emoji;--rc-font-family-serif: "Noto Serif CJK SC", "Source Han Serif SC", "Source Han Serif", "source-han-serif-sc", "Songti SC", STSong, "华文宋体", serif;--rc-font-mono: "SF Mono", SFMono-Regular, ui-monospace, "DejaVu Sans Mono", Menlo, Consolas, monospace;--rc-font-size-2xs: .625em;--rc-font-size-xs: .75em;--rc-font-size-sm: .8125em;--rc-font-size-md: .875em;--rc-font-size-lg: 1.25em;--rc-font-size-base: 14px;--rc-font-size-small: 12px;--rc-line-height: 1.5;--rc-line-height-tight: 1.3;--rc-font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, Helvetica, "noto sans sc", "hiragino sans gb", -apple-system, system-ui, sans-serif, Apple Color Emoji, Segoe UI Emoji, Not Color Emoji;--rc-radius-sm: 3px;--rc-radius-md: 6px;--rc-radius-lg: 12px}.dark .axx50,[data-theme=dark] .axx50,.dark.axx50,[data-theme=dark].axx50,.dark .axx51,[data-theme=dark] .axx51,.dark.axx51,[data-theme=dark].axx51,.dark .axx52,[data-theme=dark] .axx52,.dark.axx52,[data-theme=dark].axx52{--rc-text: #fafafa;--rc-text-secondary: #a3a3a3;--rc-text-tertiary: #737373;--rc-text-quaternary: #525252;--rc-bg: #0a0a0a;--rc-bg-secondary: #171717;--rc-bg-tertiary: #262626;--rc-fill: #2a2a2a;--rc-fill-secondary: #222222;--rc-fill-tertiary: #1a1a1a;--rc-fill-quaternary: #141414;--rc-border: #262626;--rc-accent: #60a5fa;--rc-accent-light: #60a5fa20;--rc-link: #60a5fa;--rc-code-text: #d4d4d4;--rc-code-bg: #262626;--rc-hr-border: #262626;--rc-quote-border: #60a5fa;--rc-quote-bg: #262626;--rc-alert-info: #7db9e5;--rc-alert-warning: #da864a;--rc-alert-tip: #54da48;--rc-alert-caution: #e16973;--rc-alert-important: #9966e0;--rc-shadow-top-bar: 0 8px 30px rgba(0, 0, 0, .45), 0 2px 8px rgba(0, 0, 0, .3);--rc-shadow-modal: 0 10px 15px -3px rgba(0,0,0,.4), 0 4px 6px -4px rgba(0,0,0,.35);--rc-shadow-menu: 0 1px 4px rgba(0,0,0,.25), 0 4px 16px rgba(0,0,0,.4)}._1pn9r4q0{--rr-code-accent: #737373;position:relative;margin:1.5rem 0;border-radius:.5rem;overflow:hidden;font-size:var(--rc-font-size-md);font-family:var(--rc-font-mono)}._1pn9r4q1{appearance:none;border:none;background:transparent;color:inherit;font:inherit;padding:0;outline:none;width:8em;opacity:1}._1pn9r4q1::placeholder{opacity:.5}._1pn9r4q2{position:absolute;bottom:.75rem;right:.75rem;z-index:1;display:flex;align-items:center;gap:.375rem;font-size:var(--rc-font-size-md);opacity:.6;pointer-events:none}._1pn9r4q2:has(._1pn9r4q1){pointer-events:auto}._1pn9r4q3{display:inline-flex;flex-shrink:0}._1pn9r4q3 svg{width:100%;height:100%}._1pn9r4q4{appearance:none;position:absolute;right:.5rem;top:.5rem;z-index:3;display:flex;align-items:center;justify-content:center;padding:.375rem;border-radius:.375rem;border:1px solid color-mix(in srgb,var(--rr-code-accent) 5%,transparent);background:color-mix(in srgb,var(--rr-code-accent) 80%,transparent);color:#fff;cursor:pointer;opacity:0;transition:opacity .2s ease;backdrop-filter:blur(8px)}._1pn9r4q0:hover ._1pn9r4q4{opacity:1}._1pn9r4q5{position:relative;background:color-mix(in srgb,var(--rr-code-accent) 5%,transparent);padding:0}._1pn9r4q6{padding-block:12px}._1pn9r4q7{position:relative;width:100%;overflow:auto}._1pn9r4q8{max-height:50vh;overflow:hidden}._1pn9r4q9{position:relative;overflow:auto;background-color:transparent!important}._1pn9r4q9 .cm-editor{background:transparent;color:var(--rc-text);font-family:var(--rc-font-mono)}._1pn9r4q9 .cm-scroller{font-family:var(--rc-font-mono)!important;line-height:1.6}._1pn9r4q9 .cm-content{padding-top:0;padding-bottom:0;padding-left:1.25rem;padding-right:1.25rem;min-height:1.6em}._1pn9r4q9:has(.cm-gutters) .cm-content{padding-left:.5rem;padding-right:1.25rem}._1pn9r4q9 .cm-line{padding:0}._1pn9r4q9 .cm-gutters{border-right:none;padding-left:1.25rem}._1pn9r4q9 .cm-lineNumbers .cm-gutterElement{min-width:3em;text-align:right;padding-right:2em;color:color-mix(in srgb,var(--rc-text-secondary) 40%,transparent)!important}._1pn9r4q9>.shikicode.output{position:static!important;inset:auto!important}._1pn9r4qa>textarea.shikicode{display:none}._1pn9r4qb{position:absolute;bottom:0;left:0;right:0;display:flex;justify-content:center;padding:.5rem 0 .75rem;background:linear-gradient(to bottom,transparent 0%,var(--bg, var(--rc-bg-secondary)) 80%);pointer-events:none}._1pn9r4qc{appearance:none;border:none;background:none;cursor:pointer;display:flex;align-items:center;gap:.5rem;font-size:var(--rc-font-size-xs);color:inherit;opacity:.7;pointer-events:auto}._1pn9r4qc:hover{opacity:1}._1pn9r4q0 .shikicode.input,._1pn9r4q0 .shikicode.output,._1pn9r4q0 .shikicode.output code,._1pn9r4q0 .shikicode.output .line,._1pn9r4q0 .shikicode.output .line span{font-variant-ligatures:none;font-kerning:none}._1pn9r4q0 .shikicode.input,._1pn9r4q0 .shikicode.output,._1pn9r4q9 pre,._1pn9r4q9 code,._1pn9r4q9 .line,._1pn9r4q9 .line span{font-family:var(--rc-font-mono)!important}._1pn9r4q0 pre{margin:0!important;padding:0!important;border-radius:0;font-size:1em}._1pn9r4q0 pre code{display:flex;flex-direction:column;font-family:var(--rc-font-mono)!important}._1pn9r4q0 .shiki,._1pn9r4q0 code,._1pn9r4q0 pre{background:transparent!important}[data-theme=dark] ._1pn9r4q0 .shiki-themes,[data-theme=dark] ._1pn9r4q0 .shiki-themes span{color:var(--shiki-dark)!important;font-style:var(--shiki-dark-font-style)!important;font-weight:var(--shiki-dark-font-weight)!important;text-decoration:var(--shiki-dark-text-decoration)!important}._1pn9r4q9:has(.shikicode.input.line-numbers) .shikicode.output .line:before{background-color:transparent!important;color:color-mix(in srgb,var(--rc-text-secondary) 40%,transparent)!important;width:5em;padding-right:2em}._1pn9r4q9:not(:has(.shikicode.input.line-numbers)) .shikicode.output .line:before{display:none}._1pn9r4q0 .line{display:block;padding:0 1.25rem}._1pn9r4q0 .shikicode.input.line-numbers{padding-left:calc(5em + 1.25rem)}._1pn9r4q0 .shikicode.input:not(.line-numbers){padding-left:1.25rem}._1pn9r4q0 .line>span:last-child{margin-right:1.25rem}._1pn9r4q0 .line:after{content:" "}._1pn9r4q0 .highlighted,._1pn9r4q0 .diff{position:relative;overflow-wrap:break-word}._1pn9r4q0 .highlighted:before,._1pn9r4q0 .diff:before{content:"";position:absolute;left:0;top:0;height:100%;width:2px}._1pn9r4q0 .highlighted{background:color-mix(in srgb,var(--rr-code-accent) 20%,transparent)}._1pn9r4q0 .highlighted:before{background:var(--rr-code-accent)}._1pn9r4q0 .diff.add{background:#22c55e26}._1pn9r4q0 .diff.add:before{background:#22c55e}._1pn9r4q0 .diff.add:after{content:" +";position:absolute;left:0;color:#22c55e}._1pn9r4q0 .diff.remove{background:#ef444426}._1pn9r4q0 .diff.remove:before{background:#ef4444}._1pn9r4q0 .diff.remove:after{content:" -";position:absolute;left:0;color:#ef4444}._1pn9r4qd{counter-reset:shiki-line 0}._1pn9r4qd .line{counter-increment:shiki-line 1}._1pn9r4qd .line:before{content:counter(shiki-line);color:transparent;text-align:right;box-sizing:border-box;width:2em;display:inline-block;position:sticky;left:0}._1pn9r4qe .line:before{color:inherit;opacity:.4;width:5em;padding-right:2em}._1pn9r4q7 pre::-webkit-scrollbar-track{margin-left:1rem;margin-right:var(--sr-margin, 0)}._1pn9r4q7 pre::-webkit-scrollbar{background-color:transparent!important}._1pn9r4qf{font-family:var(--rc-font-mono);font-size:var(--rc-font-size-md);background-color:var(--rc-code-bg);border-radius:var(--rc-radius-md);overflow:hidden;margin:var(--rc-space-md) 0;border:1px solid var(--rc-border)}._1pn9r4qg{display:flex;align-items:center;justify-content:space-between;padding:var(--rc-space-sm) var(--rc-space-md);border-bottom:1px solid var(--rc-border);font-size:var(--rc-font-size-md);color:var(--rc-text-secondary);user-select:none}._1pn9r4qh{font-family:var(--rc-font-mono);font-size:.85em;text-transform:uppercase;letter-spacing:.05em}._1pn9r4qi{appearance:none;border:none;background:none;color:var(--rc-text-secondary);cursor:pointer;padding:var(--rc-space-xs) var(--rc-space-sm);border-radius:var(--rc-radius-sm);font-family:var(--rc-font-family);font-size:var(--rc-font-size-md);line-height:1;transition:color .15s ease,background-color .15s ease}.rich-code-block{font-family:var(--rc-font-mono);font-size:var(--rc-font-size-md);background-color:var(--rc-code-bg);border-radius:var(--rc-radius-md);overflow:hidden;margin:var(--rc-space-md) 0;border:1px solid var(--rc-border)}.rich-code-block pre{margin:0;padding:var(--rc-space-md);overflow-x:auto}.rich-code-block code{font-family:inherit;font-size:inherit;background:none;border:none;padding:0;color:inherit}.rich-code-block-header{display:flex;align-items:center;justify-content:space-between;padding:var(--rc-space-sm) var(--rc-space-md);border-bottom:1px solid var(--rc-border);font-size:var(--rc-font-size-md);color:var(--rc-text-secondary);user-select:none}.rich-code-block-lang{font-family:var(--rc-font-mono);font-size:.85em;text-transform:uppercase;letter-spacing:.05em}.rich-code-block-copy{appearance:none;border:none;background:none;color:var(--rc-text-secondary);cursor:pointer;padding:var(--rc-space-xs) var(--rc-space-sm);border-radius:var(--rc-radius-sm);font-family:var(--rc-font-family);font-size:var(--rc-font-size-md);line-height:1;transition:color .15s ease,background-color .15s ease}.rich-code-block-copy:hover{color:var(--rc-text);background-color:var(--rc-fill-secondary)}.rich-code-block-numbered pre{counter-reset:line}.rich-code-block-numbered .line{counter-increment:line}.rich-code-block-numbered .line:before{content:counter(line);display:inline-block;width:2.5em;margin-right:var(--rc-space-md);text-align:right;color:color-mix(in srgb,var(--rc-text-secondary) 40%,transparent)!important;opacity:.4;user-select:none;font-size:var(--rc-font-size-md)}
|
package/dist/static.d.ts
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { CodeBlockRendererProps } from '@haklex/rich-editor/renderers';
|
|
2
|
+
import { ComponentType } from 'react';
|
|
3
|
+
export declare const CodeBlockRenderer: ComponentType<CodeBlockRendererProps>;
|
|
4
|
+
export default CodeBlockRenderer;
|
|
2
5
|
//# sourceMappingURL=static.d.ts.map
|
package/dist/static.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"static.d.ts","sourceRoot":"","sources":["../src/static.
|
|
1
|
+
{"version":3,"file":"static.d.ts","sourceRoot":"","sources":["../src/static.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAA;AAC3E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAE1C,eAAO,MAAM,iBAAiB,EAAE,aAAa,CAAC,sBAAsB,CAYnE,CAAA;AAED,eAAe,iBAAiB,CAAA"}
|
package/dist/static.mjs
CHANGED
|
@@ -1,4 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { CodeBlock } from "@haklex/rich-editor-ui";
|
|
3
|
+
const CodeBlockRenderer = ({
|
|
4
|
+
code,
|
|
5
|
+
language,
|
|
6
|
+
showLineNumbers
|
|
7
|
+
}) => {
|
|
8
|
+
return /* @__PURE__ */ jsx(
|
|
9
|
+
CodeBlock,
|
|
10
|
+
{
|
|
11
|
+
code,
|
|
12
|
+
language,
|
|
13
|
+
showLineNumbers
|
|
14
|
+
}
|
|
15
|
+
);
|
|
16
|
+
};
|
|
2
17
|
export {
|
|
3
|
-
|
|
18
|
+
CodeBlockRenderer,
|
|
19
|
+
CodeBlockRenderer as default
|
|
4
20
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@haklex/rich-renderer-codeblock",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.94",
|
|
4
4
|
"description": "Code block renderer with Shiki syntax highlighting",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -44,10 +44,10 @@
|
|
|
44
44
|
"@iconify/utils": "^3.1.0",
|
|
45
45
|
"lucide-react": "^1.0.0",
|
|
46
46
|
"shiki": "^4.0.1",
|
|
47
|
-
"@haklex/cm-editor": "0.0.
|
|
48
|
-
"@haklex/rich-editor": "0.0.
|
|
49
|
-
"@haklex/rich-
|
|
50
|
-
"@haklex/rich-
|
|
47
|
+
"@haklex/cm-editor": "0.0.94",
|
|
48
|
+
"@haklex/rich-editor": "0.0.94",
|
|
49
|
+
"@haklex/rich-style-token": "0.0.94",
|
|
50
|
+
"@haklex/rich-editor-ui": "0.0.94"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@types/react": "^19.2.14",
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useState, useRef, useEffect, useCallback, useMemo } from "react";
|
|
3
|
-
import { Check, Copy, ChevronDown } from "lucide-react";
|
|
4
|
-
import { normalizeLanguage, getLanguageDisplayName, languageToColorMap } from "./constants.mjs";
|
|
5
|
-
import "@iconify/utils";
|
|
6
|
-
import "@iconify-json/material-icon-theme";
|
|
7
|
-
import { i as card, s as semanticClassNames, l as lang, h as hasLanguageIcon, a as LanguageIcon, j as copyButton, k as bodyBackgroundStatic, m as bodyBackground, n as expandWrap, o as expandButton, p as scroll, q as scrollCollapsed, c as lined, d as linedWithNumbers } from "./language-DEZONKsW.js";
|
|
8
|
-
import { getHighlighterWithLang, SHIKI_DUAL_THEMES } from "./shiki.mjs";
|
|
9
|
-
const CopyIcon = /* @__PURE__ */ jsx(Copy, { size: 16 });
|
|
10
|
-
const CheckIcon = /* @__PURE__ */ jsx(Check, { size: 16 });
|
|
11
|
-
const ExpandIcon = /* @__PURE__ */ jsx(ChevronDown, { size: 14 });
|
|
12
|
-
function CodeBlockCard({
|
|
13
|
-
code,
|
|
14
|
-
language,
|
|
15
|
-
collapsible = true,
|
|
16
|
-
langSlot,
|
|
17
|
-
children,
|
|
18
|
-
static: staticMode = false
|
|
19
|
-
}) {
|
|
20
|
-
const normalizedLanguage = normalizeLanguage(language);
|
|
21
|
-
const [copied, setCopied] = useState(false);
|
|
22
|
-
const copyTimerRef = useRef(void 0);
|
|
23
|
-
const [isCollapsed, setIsCollapsed] = useState(true);
|
|
24
|
-
const [isOverflow, setIsOverflow] = useState(false);
|
|
25
|
-
const scrollRef = useRef(null);
|
|
26
|
-
useEffect(() => {
|
|
27
|
-
if (!collapsible) {
|
|
28
|
-
setIsOverflow(false);
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
const el = scrollRef.current;
|
|
32
|
-
if (!el) return;
|
|
33
|
-
const check = () => {
|
|
34
|
-
const halfVh = window.innerHeight / 2;
|
|
35
|
-
setIsOverflow(el.scrollHeight >= halfVh);
|
|
36
|
-
};
|
|
37
|
-
const raf = requestAnimationFrame(check);
|
|
38
|
-
return () => cancelAnimationFrame(raf);
|
|
39
|
-
}, [code, collapsible]);
|
|
40
|
-
useEffect(() => {
|
|
41
|
-
return () => clearTimeout(copyTimerRef.current);
|
|
42
|
-
}, []);
|
|
43
|
-
const handleCopy = useCallback(() => {
|
|
44
|
-
navigator.clipboard.writeText(code).then(() => {
|
|
45
|
-
setCopied(true);
|
|
46
|
-
clearTimeout(copyTimerRef.current);
|
|
47
|
-
copyTimerRef.current = setTimeout(() => setCopied(false), 2e3);
|
|
48
|
-
}).catch(() => {
|
|
49
|
-
});
|
|
50
|
-
}, [code]);
|
|
51
|
-
const languageLabel = getLanguageDisplayName(normalizedLanguage);
|
|
52
|
-
const accent = languageToColorMap[normalizedLanguage] || "#737373";
|
|
53
|
-
const cardStyle = useMemo(() => ({ "--rr-code-accent": accent }), [accent]);
|
|
54
|
-
const scrollClassName = [
|
|
55
|
-
scroll,
|
|
56
|
-
semanticClassNames.scroll,
|
|
57
|
-
collapsible && isCollapsed && isOverflow && scrollCollapsed,
|
|
58
|
-
collapsible && isCollapsed && isOverflow && semanticClassNames.scrollCollapsed
|
|
59
|
-
].filter(Boolean).join(" ");
|
|
60
|
-
return /* @__PURE__ */ jsxs("div", { className: `${card} ${semanticClassNames.card}`, style: cardStyle, children: [
|
|
61
|
-
langSlot ?? (normalizedLanguage !== "text" && /* @__PURE__ */ jsx("div", { "aria-hidden": true, className: `${lang} ${semanticClassNames.lang}`, children: hasLanguageIcon(normalizedLanguage) ? /* @__PURE__ */ jsx(LanguageIcon, { language: normalizedLanguage, size: 14 }) : /* @__PURE__ */ jsx("span", { children: languageLabel }) })),
|
|
62
|
-
/* @__PURE__ */ jsx(
|
|
63
|
-
"button",
|
|
64
|
-
{
|
|
65
|
-
"aria-label": copied ? "Copied" : "Copy code",
|
|
66
|
-
className: `${copyButton} ${semanticClassNames.copyButton}`,
|
|
67
|
-
type: "button",
|
|
68
|
-
onClick: handleCopy,
|
|
69
|
-
children: copied ? CheckIcon : CopyIcon
|
|
70
|
-
}
|
|
71
|
-
),
|
|
72
|
-
/* @__PURE__ */ jsxs(
|
|
73
|
-
"div",
|
|
74
|
-
{
|
|
75
|
-
className: `${staticMode ? bodyBackgroundStatic : bodyBackground} ${semanticClassNames.bodyBackground}`,
|
|
76
|
-
children: [
|
|
77
|
-
/* @__PURE__ */ jsx("div", { className: scrollClassName, ref: scrollRef, children }),
|
|
78
|
-
collapsible && isOverflow && isCollapsed && /* @__PURE__ */ jsx("div", { className: `${expandWrap} ${semanticClassNames.expandWrap}`, children: /* @__PURE__ */ jsxs(
|
|
79
|
-
"button",
|
|
80
|
-
{
|
|
81
|
-
className: `${expandButton} ${semanticClassNames.expandButton}`,
|
|
82
|
-
type: "button",
|
|
83
|
-
onClick: () => setIsCollapsed(false),
|
|
84
|
-
children: [
|
|
85
|
-
ExpandIcon,
|
|
86
|
-
/* @__PURE__ */ jsx("span", { children: "展开" })
|
|
87
|
-
]
|
|
88
|
-
}
|
|
89
|
-
) })
|
|
90
|
-
]
|
|
91
|
-
}
|
|
92
|
-
)
|
|
93
|
-
] });
|
|
94
|
-
}
|
|
95
|
-
const CodeBlockRenderer = ({
|
|
96
|
-
code,
|
|
97
|
-
language,
|
|
98
|
-
showLineNumbers: showLineNumbersProp
|
|
99
|
-
}) => {
|
|
100
|
-
const showLineNumbers = showLineNumbersProp ?? false;
|
|
101
|
-
const normalizedLanguage = normalizeLanguage(language);
|
|
102
|
-
const [html, setHtml] = useState(null);
|
|
103
|
-
useEffect(() => {
|
|
104
|
-
let cancelled = false;
|
|
105
|
-
(async () => {
|
|
106
|
-
const highlighter = await getHighlighterWithLang(normalizedLanguage);
|
|
107
|
-
if (cancelled) return;
|
|
108
|
-
const loaded = highlighter.getLoadedLanguages();
|
|
109
|
-
const lang2 = loaded.includes(normalizedLanguage) ? normalizedLanguage : "text";
|
|
110
|
-
const result = highlighter.codeToHtml(code, {
|
|
111
|
-
lang: lang2,
|
|
112
|
-
themes: SHIKI_DUAL_THEMES
|
|
113
|
-
});
|
|
114
|
-
if (!cancelled) setHtml(result);
|
|
115
|
-
})();
|
|
116
|
-
return () => {
|
|
117
|
-
cancelled = true;
|
|
118
|
-
};
|
|
119
|
-
}, [code, normalizedLanguage]);
|
|
120
|
-
const fallbackLines = useMemo(() => code.split("\n"), [code]);
|
|
121
|
-
const linedClassName = [
|
|
122
|
-
showLineNumbers && lined,
|
|
123
|
-
showLineNumbers && semanticClassNames.lined,
|
|
124
|
-
showLineNumbers && linedWithNumbers,
|
|
125
|
-
showLineNumbers && semanticClassNames.linedWithNumbers
|
|
126
|
-
].filter(Boolean).join(" ");
|
|
127
|
-
return /* @__PURE__ */ jsx(CodeBlockCard, { static: true, code, language, children: html ? /* @__PURE__ */ jsx("div", { className: linedClassName, dangerouslySetInnerHTML: { __html: html } }) : /* @__PURE__ */ jsx("pre", { className: linedClassName, children: /* @__PURE__ */ jsx("code", { children: fallbackLines.map((line, i) => /* @__PURE__ */ jsx("span", { className: "line", children: line }, i)) }) }) });
|
|
128
|
-
};
|
|
129
|
-
export {
|
|
130
|
-
CodeBlockRenderer as C,
|
|
131
|
-
CodeBlockCard as a
|
|
132
|
-
};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { CodeBlockRendererProps } from '@haklex/rich-editor/renderers';
|
|
2
|
-
import { ComponentType } from 'react';
|
|
3
|
-
export declare const CodeBlockRenderer: ComponentType<CodeBlockRendererProps>;
|
|
4
|
-
export default CodeBlockRenderer;
|
|
5
|
-
//# sourceMappingURL=CodeBlockRenderer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CodeBlockRenderer.d.ts","sourceRoot":"","sources":["../src/CodeBlockRenderer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAQ3C,eAAO,MAAM,iBAAiB,EAAE,aAAa,CAAC,sBAAsB,CA2DnE,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|