Skip to content

Commit

Permalink
Fixed code highlighting bug
Browse files Browse the repository at this point in the history
  • Loading branch information
SahilDahekar committed Dec 16, 2024
1 parent dc7d0d3 commit 8c8c5ab
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions components/editor/CodeBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -275,20 +275,32 @@ export default function CodeBlock({
lineNumberStyle={(lineNumber: number) => {
const isHighlighted = highlightedLines && highlightedLines.includes(lineNumber);

return {
const styles = {
display: 'inline-block',
marginLeft: '16px',
paddingRight: '16px',
background: isHighlighted ? '#252f3f' : 'inherit',
backgroundColor: isHighlighted ? '#3e4d64' : '#252f3f',
color: isHighlighted ? '#A3ACAD' : '#8B9394'
};

return styles;
}}
wrapLines={true}
lineProps={(lineNumber: number) => {
const isHighlighted = highlightedLines && highlightedLines.includes(lineNumber);

const style: React.CSSProperties = {
paddingRight: '2rem'
};

if (isHighlighted) {
style.display = 'block';
style.width = '100%';
style.backgroundColor = '#3e4d64';
}

return {
className: `${isHighlighted ? 'bg-code-editor-dark-highlight block ml-10 w-full' : ''} pr-8`
style
};
}}
codeTagProps={{
Expand Down

0 comments on commit 8c8c5ab

Please sign in to comment.