diff --git a/src/frontend/components/editor.rs b/src/frontend/components/editor.rs new file mode 100644 index 0000000..7d468a2 --- /dev/null +++ b/src/frontend/components/editor.rs @@ -0,0 +1,42 @@ +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/mod.rs b/src/frontend/mod.rs index cb9d0b7..995713f 100644 --- a/src/frontend/mod.rs +++ b/src/frontend/mod.rs @@ -15,7 +15,7 @@ pub fn hydrate() { use crate::frontend::app::App; console_error_panic_hook::set_once(); leptos::mount_to_body(App); - + // set theme // https://daisyui.com/docs/themes/ let document = web_sys::window().unwrap().document().unwrap(); diff --git a/src/frontend/pages/article/create.rs b/src/frontend/pages/article/create.rs index 213bfda..9c409e3 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 2399843..ad8e636 100644 --- a/src/frontend/pages/article/edit.rs +++ b/src/frontend/pages/article/edit.rs @@ -2,8 +2,10 @@ use crate::{ common::{ApiConflict, ArticleView, EditArticleForm}, frontend::{ app::GlobalState, - components::article_nav::{ActiveTab, ArticleNav}, - markdown::render_markdown, + components::{ + article_nav::{ActiveTab, ArticleNav}, + editor::EditorView, + }, pages::article_resource, }, }; @@ -27,7 +29,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(); @@ -46,15 +48,13 @@ pub fn EditArticle() -> impl IntoView { .dispatch(conflict_id); } - let textarea = create_node_ref:: - -
-
- - Markdown - - " formatting is supported" -
+ + +
impl IntoView { view! {

Most recently edited Articles

-
().id(); - let is_local_only = val == "only-local"; - set_only_local.update(|p| *p = is_local_only); - }> +
() + .id(); + let is_local_only = val == "only-local"; + set_only_local.update(|p| *p = is_local_only); + } + >