You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I added line numbers by creating a div on the left side of the code editor. Using a useEffect hook ensures that the line numbers increases as the height of the code editor increase. Let me know what you think.
I added line numbers by creating a div on the left side of the code editor. Using a useEffect hook ensures that the line numbers increases as the height of the code editor increase. Let me know what you think.
⚠️ But the very last active line doesn't get a <span class="code-line"> wrapper unless it has content, resulting in a weird editor experience; @jaywcjlove do you know if this is a bug or intended behaviour? Any quick workaround?
@jaywcjlove the line break just adds visual padding, the trailing newline that you can enter in the editor (and that gets no span.code-line wrapper and also no line number) lives inside the code element instead. Is there some known workaround for this or is this a bug?
@jaywcjlove thanks, I've already tried the rehype plugin but irrelevant of the implementation method, the last line (if just an empty newline) is still without a line number since it's not represented within the editor-preview (pre element) itself, only in the textarea:
This results in the following broken behaviour:
Screen.Recording.2024-09-13.at.11.42.19.mov
I'd expect the line number "5" to appear immediately when pressing enter, otherwise it's as if the cursor is outside the bounds of the editor, trailing in the void.
Reacted by Marko Klopets, Richard Willis and Chris Toxz
Activity
jaywcjlove commentedon Sep 3, 2021
@xsro It is more difficult to add line numbers, and there is no plan to add this feature before finding a better way.
marabesi commentedon Oct 30, 2021
Just came across this issue because I would like to support line numbers as well.
Will it be in the roadmap? Or should I try to find a replacement?
obonyojimmy commentedon Apr 5, 2022
Supporting this feature inclussion , probably aprop like
showInlineLineNumbersas an inspiration from https://www.npmjs.com/package/react-syntax-highlighterstephensanwo commentedon May 13, 2022
I added line numbers by creating a div on the left side of the code editor. Using a useEffect hook ensures that the line numbers increases as the height of the code editor increase. Let me know what you think.
shawnz42 commentedon Sep 12, 2022
Hi, from where to import CodeContainter and LineNumbers
Sumis34 commentedon Apr 19, 2023
Looks nice, would be nice to see a working example with the full code needed.
jonashex commentedon Apr 24, 2024
It would be really nice to have this feature :)
andreasvirkus commentedon Aug 5, 2024
Line numbers can be implemented with a few lines of CSS:
<span class="code-line">wrapper unless it has content, resulting in a weird editor experience; @jaywcjlove do you know if this is a bug or intended behaviour? Any quick workaround?Screen.Recording.2024-08-05.at.14.37.45.mov
jaywcjlove commentedon Aug 5, 2024
react-textarea-code-editor/core/src/Editor.tsx
Line 69 in c3d2efa
@xsro Line breaks are added to align with the Textarea.
andreasvirkus commentedon Sep 12, 2024
@jaywcjlove the line break just adds visual padding, the trailing newline that you can enter in the editor (and that gets no
span.code-linewrapper and also no line number) lives inside thecodeelement instead. Is there some known workaround for this or is this a bug?jaywcjlove commentedon Sep 12, 2024
@andreasvirkus Line numbers are not displayed by default. If needed, you can add them using the following method.
react-textarea-code-editor/core/src/index.tsx
Line 9 in c3d2efa
2024-09-12.21.45.49.mp4
andreasvirkus commentedon Sep 13, 2024
@jaywcjlove thanks, I've already tried the rehype plugin but irrelevant of the implementation method, the last line (if just an empty newline) is still without a line number since it's not represented within the
editor-preview(pre element) itself, only in the textarea:This results in the following broken behaviour:
Screen.Recording.2024-09-13.at.11.42.19.mov
I'd expect the line number "5" to appear immediately when pressing enter, otherwise it's as if the cursor is outside the bounds of the editor, trailing in the void.