Skip to content

Style rich text editor newlines as line breaks, not paragraph breaks#10293

Merged
alokedesai merged 11 commits into
masterfrom
aloke/code_review_comment_styling
May 22, 2026
Merged

Style rich text editor newlines as line breaks, not paragraph breaks#10293
alokedesai merged 11 commits into
masterfrom
aloke/code_review_comment_styling

Conversation

@alokedesai
Copy link
Copy Markdown
Member

@alokedesai alokedesai commented May 6, 2026

Description

The rich text editor would treat each newline as a paragraph break instead of line break, causing the user-visible line height to look unusually large.

This PR changes the styling of the rich text editor to more closely mimic a normal markdown editor instead of an editor like Notion.

Specifically:

  1. I changed the margin of text blocks to be 0px. There's now no difference in padding between hard-wrapped and soft-wrapped lines.
  2. I reduced the padding of some of the other block styles (including headers)
  3. I removed the post_process notebook step that strips newlines. This processing step was just wrong, the filesystem should be the source of truth. Removing newlines can change how a document reads, for ex: foo\n\n\nbar is different from foo\nbar.

I considered fixing this deeper in the stack by not creating a new paragraph block when a user creates a newline after an existing paragraph block. That ended up being a much more complicated change than I intended, so opted for this now given priorities. Happy to keep on investigating that if you feel strongly we should go down that approach.

Testing

I did a bunch of monkey testing with AI-generated markdown. See screenshots and looms below

Left is before, right is after:
image

Loom
https://www.loom.com/share/7d90d47720314eaa9aba7040935b8d51?from_recorder=1&focus_title=1

…tory

- Add RichTextStylesExt trait with new_with_default_line_height for comment editors
- Add IndentableBlockSpacing::new() and BlockSpacings::uniform() constructors
- Add style_factory field to RichTextEditorConfig/RichTextEditorView
- Consolidate style_factory with initial styles in comment_editor
- Compact text block spacings, 3px cursor width, remove minimum_paragraph_height

Co-Authored-By: Oz <oz-agent@warp.dev>
@cla-bot cla-bot Bot added the cla-signed label May 6, 2026
@oz-for-oss
Copy link
Copy Markdown
Contributor

oz-for-oss Bot commented May 6, 2026

@alokedesai

I'm starting a first review of this pull request.

You can view the conversation on Warp.

I completed the review and no human review was requested for this pull request.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

Copy link
Copy Markdown
Member Author

alokedesai commented May 6, 2026

Copy link
Copy Markdown
Contributor

@oz-for-oss oz-for-oss Bot left a comment

Choose a reason for hiding this comment

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

Overview

This PR adds custom rich text styling for code review comment editors, wires a style factory through RichTextEditorView so styles rebuild correctly after appearance/font changes, and adds related editor keybindings.

Concerns

  • No blocking correctness or security concerns found.
  • Two comment typos were introduced in touched code.

Verdict

Found: 0 critical, 0 important, 2 suggestions

Approve with nits

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

Comment thread app/src/notebooks/editor/view.rs Outdated
Comment thread app/src/notebooks/editor/view.rs Outdated
@alokedesai alokedesai changed the title Comment editor styling: line height, spacing, cursor width, style_factory Treat rich text editor newlines as line breaks, not paragraph breaks May 19, 2026
@alokedesai alokedesai requested a review from bnavetta May 20, 2026 21:00
Container::new(footer_row)
.with_vertical_padding(8.)
.with_horizontal_padding(8.)
.with_vertical_padding(4.)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This just reduces the padding of the comment editor, which looks much better now that we've reduced the padding of the editor

Before:

Image

After:

Image

use warpui::elements::ListIndentLevel;

const NOTEBOOK_LINE_HEIGHT_RATIO: f32 = 1.6;
const NOTEBOOK_LINE_HEIGHT_RATIO: f32 = 1.5;
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Bumped this down just a tad to overall reduce the size of any given line


pub const TEXT_SPACING: BlockSpacing = BlockSpacing {
margin: Margin::uniform(4.).with_right(16.),
margin: Margin::uniform(0.).with_right(16.),
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is the key change. By setting the margin to 0px, we just use line height.

The downside is there may be slightly less margin between different a non-text block and a text block but I've bashed this pretty extensively and I don't see any visual issues.

margin: Margin::uniform(4.)
.with_top(12.)
.with_bottom(12.)
.with_top(4.)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I reduce this, the header spacing was way too big (I think the post_process step was obscuring this because we'd often remove newlines between a header and the actual text)

@alokedesai alokedesai changed the title Treat rich text editor newlines as line breaks, not paragraph breaks Style rich text editor newlines as line breaks, not paragraph breaks May 21, 2026
Copy link
Copy Markdown
Contributor

@bnavetta bnavetta left a comment

Choose a reason for hiding this comment

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

I considered fixing this deeper in the stack by not creating a new paragraph block when a user creates a newline after an existing paragraph block. That ended up being a much more complicated change than I intended, so opted for this now given priorities. Happy to keep on investigating that if you feel strongly we should go down that approach.

I think the approach here, rather than conditionally folding paragraphs together, is safest. There are a ton of assumptions in the editor around newline handling

@alokedesai alokedesai merged commit 885c540 into master May 22, 2026
26 checks passed
@alokedesai alokedesai deleted the aloke/code_review_comment_styling branch May 22, 2026 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants