-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Style rich text editor newlines as line breaks, not paragraph breaks #10293
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
7f55f8c
Comment editor styling: line height, spacing, cursor width, style_fac…
alokedesai da55cff
Simplify styling
alokedesai 3c16f85
Refactor rich text styles for better readability and spacing
alokedesai 4ce889a
self review
alokedesai 9a03e9b
Move rich text block spacings into defaults
alokedesai ba7dcbd
Refine rich text markdown spacing
alokedesai 66dc008
self review
alokedesai 0828bec
Reduce the amount of padding
alokedesai 2fce233
update skills and fix merge conflicts
alokedesai 191fcc7
Cargo fmt
alokedesai 968b9c6
Fix tests
alokedesai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| use warp_core::ui::appearance::Appearance; | ||
| use warp_editor::render::model::{BlockSpacing, IndentableBlockSpacing, RichTextStyles}; | ||
| use warpui::elements::{Margin, Padding}; | ||
| use warpui::text_layout::DEFAULT_TOP_BOTTOM_RATIO; | ||
| use crate::notebooks::editor::{NOTEBOOK_BASELINE_RATIO, NOTEBOOK_LINE_HEIGHT_RATIO}; | ||
| use crate::settings::FontSettings; | ||
|
|
||
| pub trait RichTextStylesExt { | ||
| fn new_for_notebook(appearance: &Appearance, font_settings: &FontSettings) -> Self; | ||
|
|
||
| fn new_with_default_line_height(appearance: &Appearance, font_settings: &FontSettings) -> Self; | ||
| } | ||
|
|
||
| impl RichTextStylesExt for RichTextStyles { | ||
| fn new_for_notebook(appearance: &Appearance, font_settings: &FontSettings) -> Self { | ||
| super::rich_text_styles_internal(appearance, font_settings, NOTEBOOK_LINE_HEIGHT_RATIO, NOTEBOOK_BASELINE_RATIO) | ||
| } | ||
|
|
||
| fn new_with_default_line_height(appearance: &Appearance, font_settings: &FontSettings) -> Self { | ||
| // Bump the line height ratio slightly so soft-wrapped and hard-wrapped lines | ||
| // have consistent, comfortable spacing. | ||
| let line_height_ratio = appearance.line_height_ratio() + 0.15; | ||
| let compact_text_spacing = BlockSpacing { | ||
| margin: Margin::uniform(0.), | ||
| padding: Padding::uniform(0.), | ||
| }; | ||
| let compact_indentable = IndentableBlockSpacing::new(Margin::uniform(0.), 20.); | ||
| let mut styles = super::rich_text_styles_internal( | ||
| appearance, | ||
| font_settings, | ||
| line_height_ratio, | ||
| DEFAULT_TOP_BOTTOM_RATIO, | ||
| ); | ||
| styles.minimum_paragraph_height = None; | ||
| styles.cursor_width = 3.; | ||
| styles.show_placeholder_text_on_empty_block = true; | ||
| // Only compact text block spacings; keep the default code block spacing. | ||
| styles.block_spacings.text = compact_text_spacing; | ||
| styles.block_spacings.header = compact_text_spacing; | ||
| styles.block_spacings.task_list = compact_indentable.clone(); | ||
| styles.block_spacings.ordered_list = compact_indentable.clone(); | ||
| styles.block_spacings.unordered_list = compact_indentable; | ||
| styles | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This just reduces the padding of the comment editor, which looks much better now that we've reduced the padding of the editor
Before:
After: