/// Insert an image at the current caret position.
///
/// Return a reference to the inserted image element.
Insert an image at the current caret position.
Return a reference to the inserted image element.
Insert an image at the current caret position . Return a reference to the inserted image element .
pub fn insert_image(&mut self, src: &str, alt: &str, cls: &str) -> HtmlElement {
        debug!("[compose_area] insert_image ({})", &alt);
        // NOTE: Ideally we'd create an image node here and would then use
        //       `insert_node`. But unfortunately that will not modify the undo
        //       stack of the browser (see https://stackoverflow.com/a/15895618).
        //       Thus, we need to resort to an ugly `execCommand` with a HTML
        //       string. Furthermore, we need to create a random ID in order
        //       to be able to find the image again in the DOM.
        let img_id = format!("__$$compose_area_img_{}", self.get_counter());
        let html = format!(
            "<img id=\"{}\" src=\"{}\" alt=\"{}\" class=\"{}\">",
            img_id,
            src.replace('"', ""),
            alt.replace('"', ""),
            cls.replace('"', ""),
        );
        self.insert_html(&html);
        self.document
            .get_element_by_id(&img_id)
            .expect("Could not find inserted image node")
            .dyn_into::<HtmlElement>()
            .expect("Could not cast image element into HtmlElement")
    }
pub fn insert_image ( & mut self , src : & str , alt : & str , cls : & str ) -> HtmlElement { debug ! ( " " alt ) ; // NOTE: Ideally we'd create an image node here and would then use //       `insert_node`. But unfortunately that will not modify the undo //       stack of the browser (see https://stackoverflow.com/a/15895618). //       Thus, we need to resort to an ugly `execCommand` with a HTML //       string. Furthermore, we need to create a random ID in order //       to be able to find the image again in the DOM. let img_id = format ! ( " " self get_counter ( ) ) ; let html = format ! ( " \" \" \" \" \" \" \" \" " img_id src replace ( '"' " " ) alt replace ( '"' " " ) cls replace ( '"' " " ) ) ; self . insert_html ( & html ) ; self . document . get_element_by_id ( & img_id ) . expect ( " " ) . dyn_into :: < HtmlElement > ( ) . expect ( " " ) }
Insert an image at the current caret position.
Insert an image at the current caret position .
&mut self
src
&str
alt
&str
cls
&str