Skip to content

Commit

Permalink
fix: codeWrap code element instead (#1671)
Browse files Browse the repository at this point in the history
  • Loading branch information
JounQin authored Dec 16, 2024
1 parent ed1a3d1 commit 10e77df
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
8 changes: 6 additions & 2 deletions e2e/tests/plugin-shiki.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,17 @@ test.describe('plugin shiki test', async () => {
expect(shikiDoms.length).toBe(4);

const firstShikiDom = shikiDoms[0];
expect(await firstShikiDom.$eval('pre', node => node.style.overflowX)).toBe(
'auto',
);

expect(
await firstShikiDom.$eval('pre', node => node.style.whiteSpace),
await firstShikiDom.$eval('code', node => node.style.whiteSpace),
).toBe('pre');

await firstShikiDom.$eval('button', btn => btn.click());
expect(
await firstShikiDom.$eval('pre', node => node.style.whiteSpace),
await firstShikiDom.$eval('code', node => node.style.whiteSpace),
).toBe('pre-wrap');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,10 @@ export function Code(props: CodeProps) {
case 'shiki':
default:
return (
<pre
{...props}
style={{
whiteSpace: codeWrap ? 'pre-wrap' : 'pre',
overflowX: 'auto',
}}
>
<code>{props.children}</code>
<pre {...props} style={{ overflowX: 'auto' }}>
<code style={{ whiteSpace: codeWrap ? 'pre-wrap' : 'pre' }}>
{props.children}
</code>
</pre>
);
}
Expand Down

0 comments on commit 10e77df

Please sign in to comment.