Context

Trait Context 

Source
pub trait Context<'a, 'callback>: Copy + 'a
where 'callback: 'a,
{ type View: Clone + 'callback; type Handler<T: 'callback>: 'callback; type MouseEvent: 'static;
Show 25 methods // Required methods fn props(self) -> MarkdownProps; fn set_frontmatter(&mut self, frontmatter: String); fn render_links( self, link: LinkDescription<Self::View>, ) -> Result<Self::View, String>; fn call_handler<T>(callback: &Self::Handler<T>, input: T); fn make_md_handler( self, position: Range<usize>, stop_propagation: bool, ) -> Self::Handler<Self::MouseEvent>; fn el_with_attributes( self, e: HtmlElement, inside: Self::View, attributes: ElementAttributes<Self::Handler<Self::MouseEvent>>, ) -> Self::View; fn el_span_with_inner_html( self, inner_html: String, attributes: ElementAttributes<Self::Handler<Self::MouseEvent>>, ) -> Self::View; fn el_hr( self, attributes: ElementAttributes<Self::Handler<Self::MouseEvent>>, ) -> Self::View; fn el_br(self) -> Self::View; fn el_fragment(self, children: Vec<Self::View>) -> Self::View; fn el_a(self, children: Self::View, href: String) -> Self::View; fn el_img(self, src: String, alt: String) -> Self::View; fn el_text(self, text: CowStr<'a>) -> Self::View; fn el_input_checkbox( self, checked: bool, attributes: ElementAttributes<Self::Handler<Self::MouseEvent>>, ) -> Self::View; fn mount_dynamic_link( self, rel: &str, href: &str, integrity: &str, crossorigin: &str, ); fn has_custom_component(self, name: &str) -> bool; fn render_custom_component( self, name: &str, input: MdComponentProps<Self::View>, ) -> Result<Self::View, ComponentCreationError>; fn has_custom_links(self) -> bool; // Provided methods fn el(self, e: HtmlElement, inside: Self::View) -> Self::View { ... } fn el_empty(self) -> Self::View { ... } fn render_tasklist_marker( self, m: bool, position: Range<usize>, ) -> Self::View { ... } fn render_rule(self, range: Range<usize>) -> Self::View { ... } fn render_code(self, s: CowStr<'a>, range: Range<usize>) -> Self::View { ... } fn render_text(self, s: CowStr<'a>, range: Range<usize>) -> Self::View { ... } fn render_link( self, link: LinkDescription<Self::View>, ) -> Result<Self::View, String> { ... }
}

Required Associated Types§

Source

type View: Clone + 'callback

Source

type Handler<T: 'callback>: 'callback

Source

type MouseEvent: 'static

Required Methods§

Source

fn props(self) -> MarkdownProps

get all the properties from the context

Source

fn set_frontmatter(&mut self, frontmatter: String)

write the frontmatter (or metadata) string present at the top of the markdown source

Source

fn call_handler<T>(callback: &Self::Handler<T>, input: T)

calls a callback with the given input

Source

fn make_md_handler( self, position: Range<usize>, stop_propagation: bool, ) -> Self::Handler<Self::MouseEvent>

creates a callback that will fire when the user clicks on markdown

Source

fn el_with_attributes( self, e: HtmlElement, inside: Self::View, attributes: ElementAttributes<Self::Handler<Self::MouseEvent>>, ) -> Self::View

creates a html element attributes contains the html attributes for this element

Source

fn el_span_with_inner_html( self, inner_html: String, attributes: ElementAttributes<Self::Handler<Self::MouseEvent>>, ) -> Self::View

renders raw html, inside a span

Source

fn el_hr( self, attributes: ElementAttributes<Self::Handler<Self::MouseEvent>>, ) -> Self::View

renders a hr element, with attributes

Source

fn el_br(self) -> Self::View

renders a br element

Source

fn el_fragment(self, children: Vec<Self::View>) -> Self::View

takes a vector of views and return a view

Source

fn el_a(self, children: Self::View, href: String) -> Self::View

renders a link

Source

fn el_img(self, src: String, alt: String) -> Self::View

renders an image

Source

fn el_text(self, text: CowStr<'a>) -> Self::View

renders raw text

Source

fn el_input_checkbox( self, checked: bool, attributes: ElementAttributes<Self::Handler<Self::MouseEvent>>, ) -> Self::View

add a styleshit to the markdown component

Source

fn has_custom_component(self, name: &str) -> bool

Source

fn render_custom_component( self, name: &str, input: MdComponentProps<Self::View>, ) -> Result<Self::View, ComponentCreationError>

Provided Methods§

Source

fn el(self, e: HtmlElement, inside: Self::View) -> Self::View

creates a html element, with default attributes

Source

fn el_empty(self) -> Self::View

renders an empty view

Source

fn render_tasklist_marker(self, m: bool, position: Range<usize>) -> Self::View

Source

fn render_rule(self, range: Range<usize>) -> Self::View

Source

fn render_code(self, s: CowStr<'a>, range: Range<usize>) -> Self::View

Source

fn render_text(self, s: CowStr<'a>, range: Range<usize>) -> Self::View

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<'src> Context<'src, 'static> for MdContext