-
Notifications
You must be signed in to change notification settings - Fork 1.4k
feat: add line numbers and horizontal scroll to code blocks #704
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -108,12 +108,27 @@ function CodeBlock({ | |||||||||
| style={_oneDark} | ||||||||||
| language={language || "text"} | ||||||||||
| PreTag="div" | ||||||||||
| showLineNumbers={code.split("\n").length > 1} | ||||||||||
| wrapLines={true} | ||||||||||
|
Comment on lines
+111
to
+112
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time! |
||||||||||
| lineNumberStyle={{ | ||||||||||
| minWidth: "2.5em", | ||||||||||
| paddingRight: "1em", | ||||||||||
| color: "#636d83", | ||||||||||
| userSelect: "none", | ||||||||||
| textAlign: "right", | ||||||||||
| }} | ||||||||||
|
Comment on lines
+113
to
+119
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The five properties declared in |
||||||||||
| customStyle={{ | ||||||||||
| margin: 0, | ||||||||||
| borderRadius: 0, | ||||||||||
| fontSize: "13px", | ||||||||||
| padding: "12px", | ||||||||||
| background: "transparent", | ||||||||||
| overflowX: "auto", | ||||||||||
| }} | ||||||||||
| codeTagProps={{ | ||||||||||
| style: { | ||||||||||
| whiteSpace: "pre", | ||||||||||
| }, | ||||||||||
| }} | ||||||||||
| > | ||||||||||
| {code} | ||||||||||
|
|
||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
overflow: hiddenmasked byoverflow-x: autoSetting
overflow-x: autoimmediately afteroverflow: hiddensilently changes the computed value tooverflow-x: auto; overflow-y: hidden. Theoverflow: hiddenwas placed here to clip children to theborder-radius: 6pxbox (a common CSS idiom). The intent of this PR — scrolling the code area — is already fully satisfied by theoverflow-x: autorule on the inner pre/div selector on line 2969. Because the inner element contains its own overflow, the outer.chat-code-blocknever actually overflows, making this outeroverflow-x: autoredundant. Consider removing the new line here and keepingoverflow: hiddenintact to preserve the clear original intent.