Move document() from plume_front::editor to plume_front

This commit is contained in:
Kitaiti Makoto 2021-02-12 18:12:32 +09:00
parent 5d38c3ad70
commit de1c3f3245
2 changed files with 9 additions and 9 deletions

View File

@ -1,12 +1,12 @@
use crate::CATALOG; use crate::{document, CATALOG};
use js_sys::{encode_uri_component, Date, RegExp}; use js_sys::{encode_uri_component, Date, RegExp};
use serde_derive::{Deserialize, Serialize}; use serde_derive::{Deserialize, Serialize};
use std::{convert::TryInto, sync::Mutex}; use std::{convert::TryInto, sync::Mutex};
use wasm_bindgen::{prelude::*, JsCast, JsValue}; use wasm_bindgen::{prelude::*, JsCast, JsValue};
use web_sys::{ use web_sys::{
console, window, ClipboardEvent, Document, Element, Event, FocusEvent, HtmlAnchorElement, console, window, ClipboardEvent, Element, Event, FocusEvent, HtmlAnchorElement, HtmlDocument,
HtmlDocument, HtmlElement, HtmlFormElement, HtmlInputElement, HtmlSelectElement, HtmlElement, HtmlFormElement, HtmlInputElement, HtmlSelectElement, HtmlTextAreaElement,
HtmlTextAreaElement, KeyboardEvent, MouseEvent, Node, KeyboardEvent, MouseEvent, Node,
}; };
macro_rules! mv { macro_rules! mv {
@ -18,10 +18,6 @@ macro_rules! mv {
} }
} }
fn document() -> Document {
window().unwrap().document().unwrap()
}
fn get_elt_value(id: &'static str) -> String { fn get_elt_value(id: &'static str) -> String {
let elt = document().get_element_by_id(id).unwrap(); let elt = document().get_element_by_id(id).unwrap();
let inp: Option<&HtmlInputElement> = elt.dyn_ref(); let inp: Option<&HtmlInputElement> = elt.dyn_ref();

View File

@ -7,7 +7,7 @@ extern crate gettext_macros;
extern crate lazy_static; extern crate lazy_static;
use wasm_bindgen::{prelude::*, JsCast}; use wasm_bindgen::{prelude::*, JsCast};
use web_sys::{console, window, Element, Event, HtmlInputElement, TouchEvent}; use web_sys::{console, window, Document, Element, Event, HtmlInputElement, TouchEvent};
init_i18n!( init_i18n!(
"plume-front", "plume-front",
@ -163,3 +163,7 @@ fn search() {
normalize_query.forget(); normalize_query.forget();
} }
} }
fn document() -> Document {
window().unwrap().document().unwrap()
}