#[non_exhaustive]pub enum BlockNode {
Show 13 variants
Root {
children: Vec<BlockNode>,
span: Option<Span>,
},
Paragraph(Paragraph),
Heading {
level: u8,
children: Paragraph,
span: Option<Span>,
},
Blockquote {
children: Vec<BlockNode>,
span: Option<Span>,
},
List {
children: Vec<BlockNode>,
ordered: bool,
start: Option<u32>,
span: Option<Span>,
},
ListItem {
children: Vec<BlockNode>,
spread: bool,
checked: Option<bool>,
span: Option<Span>,
},
CodeBlock(CodeBlock),
Custom {
node: MarkdownNode,
state: BlockState,
},
Table(Table),
Break {
html: bool,
span: Option<Span>,
},
HorizontalRule {
span: Option<Span>,
},
Definition {
identifier: SharedString,
url: SharedString,
title: Option<SharedString>,
span: Option<Span>,
},
Unknown,
}Expand description
The block-level nodes.
This is the document tree TextView renders. Together with
editor_host it is also the hand-over type for
external editors: they build the tree, render it with
BlockNode::render and read geometry back per leaf.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Root
Something like a Div container in HTML.
Paragraph(Paragraph)
Heading
Blockquote
List
Fields
ListItem
Fields
CodeBlock(CodeBlock)
Custom
A custom Markdown node produced by MarkdownExtensions.
Table(Table)
Break
HorizontalRule
Definition
Use for to_markdown get raw definition
Unknown
Implementations§
Source§impl BlockNode
impl BlockNode
Sourcepub fn render_with_id(
&self,
id: impl Into<ElementId>,
flow: FlowPosition,
render_context: &RenderContext,
window: &mut Window,
cx: &mut App,
) -> AnyElement
pub fn render_with_id( &self, id: impl Into<ElementId>, flow: FlowPosition, render_context: &RenderContext, window: &mut Window, cx: &mut App, ) -> AnyElement
Renders under a stable host-owned identity. Use a domain ID, not a list position, when inserting, reordering or virtualizing blocks. Identity scopes GPUI element state independently of the leaf keys used for geometry.
Sourcepub fn render(
&self,
ix: usize,
flow: FlowPosition,
cx: &RenderContext,
window: &mut Window,
app: &mut App,
) -> AnyElement
pub fn render( &self, ix: usize, flow: FlowPosition, cx: &RenderContext, window: &mut Window, app: &mut App, ) -> AnyElement
Renders the block as TextView does. ix identifies the block among
its siblings (element ids derive from it).
Trait Implementations§
impl StructuralPartialEq for BlockNode
Auto Trait Implementations§
impl !Freeze for BlockNode
impl !RefUnwindSafe for BlockNode
impl !UnwindSafe for BlockNode
impl Send for BlockNode
impl Sync for BlockNode
impl Unpin for BlockNode
impl UnsafeUnpin for BlockNode
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more