返回 presentation-ai
code-block-node-static.tsx
根目录 / src / components / plate / ui / code-block-node-static.tsx
1 import { type TCodeBlockElement } from "platejs";
2 import {
3 SlateElement,
4 SlateLeaf,
5 type SlateElementProps,
6 type SlateLeafProps,
7 } from "platejs/static";
8
9 export function CodeBlockElementStatic(
10 props: SlateElementProps<TCodeBlockElement>,
11 ) {
12 return (
13 <SlateElement
14 className="py-1 [.hljs-addition]:**:bg-[#f0fff4] [.hljs-addition]:**:text-[#22863a] [.hljs-attr,.hljs-attribute,.hljs-literal,.hljs-meta,.hljs-number,.hljs-operator,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-id,.hljs-variable]:**:text-[#005cc5] [.hljs-built_in,.hljs-symbol]:**:text-[#e36209] [.hljs-bullet]:**:text-[#735c0f] [.hljs-comment,.hljs-code,.hljs-formula]:**:text-[#6a737d] [.hljs-deletion]:**:bg-[#ffeef0] [.hljs-deletion]:**:text-[#b31d28] [.hljs-emphasis]:**:italic [.hljs-keyword,.hljs-doctag,.hljs-template-tag,.hljs-template-variable,.hljs-type,.hljs-variable.language]:**:text-[#d73a49] [.hljs-name,.hljs-quote,.hljs-selector-tag,.hljs-selector-pseudo]:**:text-[#22863a] [.hljs-regexp,.hljs-string,.hljs-meta_.hljs-string]:**:text-[#032f62] [.hljs-section]:**:font-bold [.hljs-section]:**:text-[#005cc5] [.hljs-strong]:**:font-bold [.hljs-title,.hljs-title.class,.hljs-title.class_.inherited,.hljs-title.function]:**:text-[#6f42c1]"
15 {...props}
16 >
17 <div className="relative rounded-md bg-muted/50">
18 <pre className="overflow-x-auto p-8 pr-4 font-mono text-sm leading-[normal] [tab-size:2] print:break-inside-avoid">
19 <code>{props.children}</code>
20 </pre>
21 </div>
22 </SlateElement>
23 );
24 }
25
26 export function CodeLineElementStatic(props: SlateElementProps) {
27 return <SlateElement {...props} />;
28 }
29
30 export function CodeSyntaxLeafStatic(props: SlateLeafProps) {
31 const tokenClassName = props.leaf.className as string;
32
33 return <SlateLeaf className={tokenClassName} {...props} />;
34 }
35
35 lines Plain Text