diff --git a/Cargo.lock b/Cargo.lock index c70d09a..41dd5d1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -940,7 +940,7 @@ checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "rust-web-markdown" version = "0.1.0" -source = "git+https://github.com/rambip/rust-web-markdown/#716310fd582b3e72516b7a72db8fa493f9b12070" +source = "git+https://github.com/rambip/rust-web-markdown/#c2aae3239bad20cc716b78d08d7cb60926c76a44" dependencies = [ "katex", "lazy_static", diff --git a/src/lib.rs b/src/lib.rs index 91823c9..b33dfe3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,6 @@ use rust_web_markdown::{ render_markdown, ElementAttributes, HtmlElement, MarkdownProps, Context, - CowStr, MouseEvent + CowStr, }; use core::ops::Range; @@ -13,7 +13,7 @@ use yew::prelude::{ function_component, html, AttrValue, Callback, Html, Properties, UseStateHandle, }; -use web_sys::window; +use web_sys::{window, MouseEvent}; use std::collections::HashMap; @@ -39,6 +39,8 @@ impl<'a> Context<'a, 'static> for &'a Props { type Setter = UseStateHandle; + type MouseEvent = MouseEvent; + fn props(self) -> MarkdownProps<'a, 'static, Self> { let Props { render_links, @@ -82,11 +84,6 @@ impl<'a> Context<'a, 'static> for &'a Props { let classes: Vec<_> = attributes.classes.iter().map(|x| x.to_string()).collect(); let on_click = attributes.on_click; - let inside = match attributes.inner_html { - Some(i) => Html::from_html_unchecked(i.to_string().into()), - None => inside - }; - match e { HtmlElement::Div => { html! {
{inside}
} @@ -158,6 +155,18 @@ impl<'a> Context<'a, 'static> for &'a Props { } } + fn el_span_with_inner_html(self, inner_html: String, attributes: ElementAttributes>) -> Self::View { + let style = attributes.style.map(|x| x.to_string()); + let classes: Vec<_> = attributes.classes.iter().map(|x| x.to_string()).collect(); + let onclick = attributes.on_click; + + html! { + + {Html::from_html_unchecked(inner_html.into())} + + } + } + fn el_hr(self, attributes: ElementAttributes>) -> Self::View { let style = attributes.style.map(|x| x.to_string()); let classes: Vec<_> = attributes.classes.iter().map(|x| x.to_string()).collect();