Skip to content

Commit

Permalink
🐛 fix: code panel scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
rdmclin2 committed Feb 11, 2024
1 parent 8bce246 commit 80a20b7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
4 changes: 4 additions & 0 deletions src/Markdown/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@ export const useStyles = createStyles(({ css, cx, token, prefixCls }) => {
border-radius: ${token.borderRadius}px;
`,
),
highlighter: css`
max-height: 400px;
overflow: scroll;
`,
header: cx(
`${prefix}-header`,
css`
Expand Down
10 changes: 2 additions & 8 deletions src/Markdown/wrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,7 @@ const HighlightWrapper = memo((props: HighlightWrapperProps) => {

const highlightBlock = useMemo(() => {
return (
<Highlight
language={lang?.toLowerCase()}
copyable={false}
showLanguage={false}
type="block"
style={{ maxHeight: 400, overflowY: 'scroll' }}
>
<Highlight language={lang?.toLowerCase()} copyable={false} showLanguage={false} type="block">
{children}
</Highlight>
);
Expand Down Expand Up @@ -87,7 +81,7 @@ const HighlightWrapper = memo((props: HighlightWrapperProps) => {
/>
<CopyButton className={styles.copy} content={children} />
</Flexbox>
{expand ? highlightBlock : null}
<div className={styles.highlighter}>{expand ? highlightBlock : null}</div>
</div>
);
});
Expand Down
5 changes: 3 additions & 2 deletions src/ProBuilder/components/Code/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,14 @@ export const CodePanel: FC<CodePanelProps> = memo((props) => {
{/* 右侧按钮区域 */}
</Flexbox>
</Flexbox>
<Flexbox className={styles.code} style={{ height: `calc(100% - ${HEADER_HEIGHT}px)` }}>
<Flexbox className={styles.code}>
<Highlight
theme={isDarkMode ? 'dark' : 'light'}
lineNumber
language="tsx"
onCopy={onCopy}
style={{ height: '100%' }}
showLanguage={false}
style={{ height: '100%', overflow: 'auto' }}
>
{configCode}
</Highlight>
Expand Down
2 changes: 1 addition & 1 deletion src/ProBuilder/components/Code/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const useStyles = createStyles(({ token, stylish, css }) => {
`,
code: css`
background: ${token.colorFillQuaternary};
overflow: scroll;
height: 100%;
`,
};
});

0 comments on commit 80a20b7

Please sign in to comment.