pub struct RenderContext { /* private fields */ }Expand description
What BlockNode::render needs besides the node: the text style, code
highlighter and Markdown extensions.
Implementations§
Source§impl RenderContext
impl RenderContext
Sourcepub fn new(style: TextViewStyle) -> Self
pub fn new(style: TextViewStyle) -> Self
Creates a local rendering context without reading application globals.
The host supplies body typography through its container or
with_body_font_size.
Sourcepub fn with_code_block_highlighter<F>(self, highlighter: F) -> Self
pub fn with_code_block_highlighter<F>(self, highlighter: F) -> Self
Replaces code highlighting for this context only.
Sourcepub fn with_image_source<F>(self, resolver: F) -> Self
pub fn with_image_source<F>(self, resolver: F) -> Self
Resolves document image URIs. The host owns resource access policy.
Sourcepub fn on_link_click<F>(self, handler: F) -> Self
pub fn on_link_click<F>(self, handler: F) -> Self
Handles link activation. Without a handler, links use App::open_url.
Sourcepub fn with_link_reference(
self,
identifier: impl Into<SharedString>,
link: LinkMark,
) -> Self
pub fn with_link_reference( self, identifier: impl Into<SharedString>, link: LinkMark, ) -> Self
Registers a reference-link definition from the host’s document. Supply definitions for the entire document, including virtualized blocks.
Sourcepub fn from_app(cx: &App) -> Self
pub fn from_app(cx: &App) -> Self
The context TextView would start from: the global TextViewDefaults
style and code-block highlighter when set, else the theme’s style.
Sourcepub fn with_style(self, style: TextViewStyle) -> Self
pub fn with_style(self, style: TextViewStyle) -> Self
Replaces the text style.
Sourcepub fn with_markdown_extensions(
self,
extensions: Arc<MarkdownExtensions>,
) -> Self
pub fn with_markdown_extensions( self, extensions: Arc<MarkdownExtensions>, ) -> Self
Sets the Markdown extensions that render custom nodes.
Sourcepub fn with_body_font_size(self, size: Pixels) -> Self
pub fn with_body_font_size(self, size: Pixels) -> Self
Sets the font size body text inherits, which the block gaps and heading sizes are relative to.
Sourcepub fn style(&self) -> &TextViewStyle
pub fn style(&self) -> &TextViewStyle
The text style blocks render with.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for RenderContext
impl !UnwindSafe for RenderContext
impl Freeze for RenderContext
impl Send for RenderContext
impl Sync for RenderContext
impl Unpin for RenderContext
impl UnsafeUnpin for RenderContext
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
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> ⓘ
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> ⓘ
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