fix: allow rich text to wrap properly
This commit is contained in:
@@ -114,7 +114,6 @@ enum ContentBlock {
|
||||
},
|
||||
Empty,
|
||||
Table {
|
||||
row_count: usize,
|
||||
col_count: usize,
|
||||
cells: Vec<RichTextContent>,
|
||||
},
|
||||
@@ -598,7 +597,6 @@ impl MarkdownText {
|
||||
|
||||
// the table consists of only the header row
|
||||
self.blocks.push(ContentBlock::Table {
|
||||
row_count,
|
||||
col_count,
|
||||
cells: cell_blocks,
|
||||
});
|
||||
@@ -690,21 +688,19 @@ impl gpui::Render for MarkdownText {
|
||||
.child(content.clone()),
|
||||
|
||||
| ContentBlock::Table {
|
||||
row_count,
|
||||
col_count,
|
||||
cells,
|
||||
col_count, cells, ..
|
||||
} => div().flex().w_full().child(
|
||||
div()
|
||||
.w_full()
|
||||
.min_w_0()
|
||||
.grid()
|
||||
.grid_cols(*col_count as u16)
|
||||
.grid_rows(*row_count as u16)
|
||||
.h_40()
|
||||
.border_l_1()
|
||||
.border_t_1()
|
||||
.border_color(theme.colors.border_muted)
|
||||
.children(cells.iter().map(|cell_content| {
|
||||
div()
|
||||
.min_w_0()
|
||||
.p_1()
|
||||
.border_r_1()
|
||||
.border_b_1()
|
||||
|
||||
@@ -177,20 +177,23 @@ impl gpui::RenderOnce for RichText {
|
||||
let styled_text =
|
||||
gpui::StyledText::new(content).with_highlights(highlights.into_iter().cloned());
|
||||
if links.is_empty() {
|
||||
styled_text.into_any_element()
|
||||
div().min_w_0().whitespace_normal().child(styled_text)
|
||||
} else {
|
||||
let on_click = self.on_click.as_ref().map(Rc::clone);
|
||||
let all_links = Rc::clone(&self.content.links);
|
||||
let link_i_offset = *link_i_offset;
|
||||
|
||||
gpui::InteractiveText::new(i, styled_text)
|
||||
.on_click(links.clone(), move |i, window, cx| {
|
||||
if let Some(f) = &on_click {
|
||||
let link = all_links[i + link_i_offset].clone();
|
||||
f(&RichTextClickTarget::Link(link), window, cx);
|
||||
}
|
||||
})
|
||||
.into_any_element()
|
||||
div().min_w_0().whitespace_normal().child(
|
||||
gpui::InteractiveText::new(i, styled_text).on_click(
|
||||
links.clone(),
|
||||
move |i, window, cx| {
|
||||
if let Some(f) = &on_click {
|
||||
let link = all_links[i + link_i_offset].clone();
|
||||
f(&RichTextClickTarget::Link(link), window, cx);
|
||||
}
|
||||
},
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
| RichTextElement::Image { src, description } => todo!(),
|
||||
@@ -200,6 +203,10 @@ impl gpui::RenderOnce for RichText {
|
||||
.flex()
|
||||
.flex_row()
|
||||
.flex_wrap()
|
||||
.items_start()
|
||||
.w_full()
|
||||
.min_w_0()
|
||||
.whitespace_normal()
|
||||
.text_color(theme.colors.text)
|
||||
.children(children)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user