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