Skip to content

Commit 18c8727

Browse files
committed
feat(PrismCode): react renderer * 5
1 parent 2434bd4 commit 18c8727

File tree

1 file changed

+34
-25
lines changed

1 file changed

+34
-25
lines changed

src/components/content/PrismCode/PrismCode.tsx

Lines changed: 34 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -94,35 +94,44 @@ function PrismCode(props: CubePrismCodeProps, ref) {
9494
return (
9595
<PreElement ref={ref} {...otherProps}>
9696
<Highlight prism={Prism} code={code} language={grammarLang as any}>
97-
{({ className, tokens, getLineProps, getTokenProps }) => (
97+
{({ className, style, tokens, getLineProps, getTokenProps }) => (
9898
<code
9999
data-element="Code"
100100
className={`${className}${isDiff ? ' diff-highlight' : ''}`}
101+
style={{ ...style, color: undefined, backgroundColor: undefined }}
101102
>
102-
{tokens.map((line, i) => (
103-
<span
104-
key={i}
105-
{...getLineProps({ line, key: i })}
106-
style={undefined}
107-
>
108-
{line.map((token, key) => {
109-
const props = getTokenProps({ token, key });
110-
111-
return (
112-
<span
113-
key={key}
114-
{...props}
115-
style={{
116-
...props.style,
117-
color: undefined,
118-
backgroundColor: undefined,
119-
}}
120-
/>
121-
);
122-
})}
123-
{'\n'}
124-
</span>
125-
))}
103+
{tokens.map((line, i) => {
104+
const props = getLineProps({ line, key: i });
105+
106+
return (
107+
<span
108+
key={i}
109+
{...props}
110+
style={{
111+
...props.style,
112+
color: undefined,
113+
backgroundColor: undefined,
114+
}}
115+
>
116+
{line.map((token, key) => {
117+
const props = getTokenProps({ token, key });
118+
119+
return (
120+
<span
121+
key={key}
122+
{...props}
123+
style={{
124+
...props.style,
125+
color: undefined,
126+
backgroundColor: undefined,
127+
}}
128+
/>
129+
);
130+
})}
131+
{'\n'}
132+
</span>
133+
);
134+
})}
126135
</code>
127136
)}
128137
</Highlight>

0 commit comments

Comments
 (0)