Is there any way to make DOM action via use_node_ref
? or alternatively, how to do document.query_selector()
in Rust using yew?
use web_sys::HtmlInputElement;
use yew::{
function_component, functional::*, html,
NodeRef, Html
};
#[function_component(UseRef)]
pub fn ref_hook() -> Html {
let input_ref = use_node_ref();
let all_editables = input_ref.query_selector("[contenteditable]")
web_sys::console::(all_editables)
html! {
<div>
<input ref={input_ref} type="number" />
</div>
}
}
Goal: I have a rich text editor app. And I have a minified html in form of string like this <h1> this is title</h1><p>hello world</>
and I need to get the DOM and change the innerHTML
to set it to this value.
Goal2: I will also need to update the innerHtml
as the user write things in the contenteditable
elements. Fore example when the user type @john smith
I will make a create an <a>
element with href
the have the link to John smith
's profile.