diff --git a/src/frontend/components/editor.rs b/src/frontend/components/editor.rs new file mode 100644 index 0000000..ceb3a2f --- /dev/null +++ b/src/frontend/components/editor.rs @@ -0,0 +1,38 @@ +use crate::frontend::markdown::render_markdown; +use html::Textarea; +use leptos::*; + +#[component] +pub fn EditorView( + // this param gives a false warning about being unused, ignore that + #[allow(unused)] + textarea_ref: NodeRef + + +
+
+
+ + Markdown + + " formatting is supported" +
+ } +} diff --git a/src/frontend/components/mod.rs b/src/frontend/components/mod.rs index 0dd12c8..fa9f556 100644 --- a/src/frontend/components/mod.rs +++ b/src/frontend/components/mod.rs @@ -1,4 +1,5 @@ pub mod article_nav; pub mod credentials; +pub mod editor; pub mod instance_follow_button; pub mod nav; diff --git a/src/frontend/pages/article/create.rs b/src/frontend/pages/article/create.rs index 213bfda..3fac577 100644 --- a/src/frontend/pages/article/create.rs +++ b/src/frontend/pages/article/create.rs @@ -1,6 +1,6 @@ use crate::{ common::CreateArticleForm, - frontend::{app::GlobalState, markdown::render_markdown}, + frontend::{app::GlobalState, components::editor::EditorView}, }; use html::Textarea; use leptos::*; @@ -10,15 +10,13 @@ use leptos_use::{use_textarea_autosize, UseTextareaAutosizeReturn}; #[component] pub fn CreateArticle() -> impl IntoView { let (title, set_title) = create_signal(String::new()); - let textarea = create_node_ref:: - - -
-
-
- - Markdown - - " formatting is supported" -
+ + {move || { create_error .get() diff --git a/src/frontend/pages/article/edit.rs b/src/frontend/pages/article/edit.rs index 3dd19f7..ba91809 100644 --- a/src/frontend/pages/article/edit.rs +++ b/src/frontend/pages/article/edit.rs @@ -3,8 +3,7 @@ use crate::{ frontend::{ app::GlobalState, article_title, - components::article_nav::ArticleNav, - markdown::render_markdown, + components::{article_nav::ArticleNav, editor::EditorView}, pages::article_resource, }, }; @@ -28,7 +27,7 @@ pub fn EditArticle() -> impl IntoView { let (edit_response, set_edit_response) = create_signal(EditResponse::None); let (edit_error, set_edit_error) = create_signal(None::); - let conflict_id = move || use_params_map().get().get("conflict_id").cloned(); + let conflict_id = move || use_params_map().get_untracked().get("conflict_id").cloned(); if let Some(conflict_id) = conflict_id() { create_action(move |conflict_id: &String| { let conflict_id: i32 = conflict_id.parse().unwrap(); @@ -47,15 +46,13 @@ pub fn EditArticle() -> impl IntoView { .dispatch(conflict_id); } - let textarea = create_node_ref:: - - -
-
-
- - Markdown - - " formatting is supported" -
+ +