
This pull request introduces a new `markdown` crate which is capable of parsing and rendering a Markdown source. One of the key additions is that it enables text selection within a `Markdown` view. Eventually, this will replace `RichText` but for now the goal is to use it in the assistant revamped assistant in the spirit of making progress. <img width="711" alt="image" src="https://github.com/zed-industries/zed/assets/482957/b56c777b-e57c-42f9-95c1-3ada22f63a69"> Note that this pull request doesn't yet use the new markdown renderer in `assistant2`. This is because we need to modify the assistant before slotting in the new renderer and I wanted to merge this independently of those changes. Release Notes: - N/A --------- Co-authored-by: Nathan Sobo <nathan@zed.dev> Co-authored-by: Conrad <conrad@zed.dev> Co-authored-by: Alp <akeles@umd.edu> Co-authored-by: Zachiah Sawyer <zachiah@proton.me>
64 lines
1.9 KiB
Rust
64 lines
1.9 KiB
Rust
use gpui::{prelude::*, AnyElement};
|
|
use smallvec::SmallVec;
|
|
use ui::prelude::*;
|
|
|
|
#[derive(IntoElement)]
|
|
pub struct ExtensionCard {
|
|
overridden_by_dev_extension: bool,
|
|
children: SmallVec<[AnyElement; 2]>,
|
|
}
|
|
|
|
impl ExtensionCard {
|
|
pub fn new() -> Self {
|
|
Self {
|
|
overridden_by_dev_extension: false,
|
|
children: SmallVec::new(),
|
|
}
|
|
}
|
|
|
|
pub fn overridden_by_dev_extension(mut self, overridden: bool) -> Self {
|
|
self.overridden_by_dev_extension = overridden;
|
|
self
|
|
}
|
|
}
|
|
|
|
impl ParentElement for ExtensionCard {
|
|
fn extend(&mut self, elements: impl IntoIterator<Item = AnyElement>) {
|
|
self.children.extend(elements)
|
|
}
|
|
}
|
|
|
|
impl RenderOnce for ExtensionCard {
|
|
fn render(self, cx: &mut WindowContext) -> impl IntoElement {
|
|
div().w_full().child(
|
|
v_flex()
|
|
.w_full()
|
|
.h(rems(7.))
|
|
.p_3()
|
|
.mt_4()
|
|
.gap_2()
|
|
.bg(cx.theme().colors().elevated_surface_background)
|
|
.border_1()
|
|
.border_color(cx.theme().colors().border)
|
|
.rounded_md()
|
|
.children(self.children)
|
|
.when(self.overridden_by_dev_extension, |card| {
|
|
card.child(
|
|
h_flex()
|
|
.absolute()
|
|
.top_0()
|
|
.left_0()
|
|
.occlude()
|
|
.size_full()
|
|
.items_center()
|
|
.justify_center()
|
|
.bg(theme::color_alpha(
|
|
cx.theme().colors().elevated_surface_background,
|
|
0.8,
|
|
))
|
|
.child(Label::new("Overridden by dev extension.")),
|
|
)
|
|
}),
|
|
)
|
|
}
|
|
}
|