Skip to content

feat(CodeBlock): improvements in code block#949

Open
d3m1d0v wants to merge 3 commits intomainfrom
codeblock-linewrapping
Open

feat(CodeBlock): improvements in code block#949
d3m1d0v wants to merge 3 commits intomainfrom
codeblock-linewrapping

Conversation

@d3m1d0v
Copy link
Member

@d3m1d0v d3m1d0v commented Feb 10, 2026

Changes in CodeBlock:

  • Text wrapping is disabled by default.
  • Floating toolbar for code block has been redesigned:
    • Move PlainText to first position in the language select list.
    • Replace the "line numbers" checkbox with a toggle button
    • Add a copy button
    • Change the remove button theme to danger
  • Add button to the floating toolbar to toggle text wrapping - it will only affect the current code block and only during current editing session for current user

Toolbar:

  • add danger theme to single button

Also added a new example story where you can configure a code block.

image

@gravity-ui
Copy link

gravity-ui bot commented Feb 10, 2026

Storybook Deployed

@gravity-ui
Copy link

gravity-ui bot commented Feb 10, 2026

🎭 Playwright Report

@makhnatkin
Copy link
Collaborator

@d3m1d0v I suggest using negative margin for the first element and padding for the container

.yfm-line-number {
    margin-left: -2rem;
}
.hljs > div {
    padding-left: 2rem
}
Screenshot 2026-02-10 at 16 18 34 Screenshot 2026-02-10 at 16 18 44

@d3m1d0v d3m1d0v force-pushed the codeblock-linewrapping branch 2 times, most recently from 7b31530 to 46e48ed Compare February 12, 2026 17:11
@d3m1d0v d3m1d0v force-pushed the codeblock-linewrapping branch from 46e48ed to 62cb200 Compare February 12, 2026 19:12
@d3m1d0v d3m1d0v changed the title feat(CodeBlock): add line wrapping to codeblock [wip] feat(CodeBlock): add line wrapping to codeblock Feb 12, 2026
@d3m1d0v d3m1d0v marked this pull request as ready for review February 12, 2026 19:47
@d3m1d0v d3m1d0v requested a review from makhnatkin as a code owner February 12, 2026 19:47
@d3m1d0v d3m1d0v changed the title feat(CodeBlock): add line wrapping to codeblock feat(CodeBlock): improvements in code block Feb 13, 2026

export type YfmTableDnDDemoProps = {
lineWrapping: 'disabled' | 'enabled';
lineNumbers: 'disabled' | 'enabled' | 'by-default';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion, by-default looks unconventional as an enum value. Maybe rename it to default or auto?

this.contentDOM = document.createElement('div');

const hasLineWrapping = hasLineWrappingDecoration(decorations);
if (this._opts.lineNumbers?.enabled && hasLineWrapping) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m not fully sure why hasLineWrapping is needed here, and why it isn’t needed in update() for _applyLineNumbersResult:

if (this._opts.lineNumbers?.enabled) {
            this._applyLineNumbersResult = applyLineNumbers(
...

Could you clarify the reasoning?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants