From 564ba2de3d543db201b11cc5f5f03aa3ece3e6af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BC=8A=E6=AC=A7?= Date: Fri, 25 Oct 2024 11:06:38 +0800 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Rename=20models.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/components/Cargo.toml | 4 ++-- .../components/src/data/canvas/charts/mod.rs | 2 +- packages/components/src/data/canvas/mod.rs | 4 ++-- packages/components/src/data/paragraph/mod.rs | 4 ++++ .../input => data/paragraph}/rich/html/mod.rs | 0 .../src/data/paragraph/rich/markdown/mod.rs | 20 ++++++++++++++++ .../paragraph/rich/mediawiki}/mod.rs | 0 .../input => data/paragraph}/rich/mod.rs | 4 ++-- .../src/form/input/markdown_input.rs | 23 ------------------- packages/components/src/form/input/mod.rs | 18 +++++---------- .../src/form/input/password_input.rs | 23 ------------------- .../src/form/input/{char_input.rs => rich.rs} | 4 ++-- .../src/form/input/rich/mediawiki/mod.rs | 0 .../src/form/input/{text_input.rs => text.rs} | 0 .../{text_area_input.rs => text_area.rs} | 0 .../form/picker/{color_picker.rs => color.rs} | 0 .../form/picker/{date_picker.rs => date.rs} | 0 .../{date_time_picker.rs => date_time.rs} | 0 packages/components/src/form/picker/mod.rs | 16 ++++++------- .../form/picker/{time_picker.rs => time.rs} | 0 20 files changed, 47 insertions(+), 75 deletions(-) rename packages/components/src/{form/input => data/paragraph}/rich/html/mod.rs (100%) create mode 100644 packages/components/src/data/paragraph/rich/markdown/mod.rs rename packages/components/src/{form/input/rich/markdown => data/paragraph/rich/mediawiki}/mod.rs (100%) rename packages/components/src/{form/input => data/paragraph}/rich/mod.rs (86%) delete mode 100644 packages/components/src/form/input/markdown_input.rs delete mode 100644 packages/components/src/form/input/password_input.rs rename packages/components/src/form/input/{char_input.rs => rich.rs} (84%) delete mode 100644 packages/components/src/form/input/rich/mediawiki/mod.rs rename packages/components/src/form/input/{text_input.rs => text.rs} (100%) rename packages/components/src/form/input/{text_area_input.rs => text_area.rs} (100%) rename packages/components/src/form/picker/{color_picker.rs => color.rs} (100%) rename packages/components/src/form/picker/{date_picker.rs => date.rs} (100%) rename packages/components/src/form/picker/{date_time_picker.rs => date_time.rs} (100%) rename packages/components/src/form/picker/{time_picker.rs => time.rs} (100%) diff --git a/packages/components/Cargo.toml b/packages/components/Cargo.toml index 3aaf4bf..2b7fd5c 100644 --- a/packages/components/Cargo.toml +++ b/packages/components/Cargo.toml @@ -30,7 +30,7 @@ yew = { workspace = true } yew-router = { workspace = true } html5ever = { version = "^0.29", optional = true } -comrak = { version = "^0.29", optional = true } +markdown = { version = "1.0.0-alpha.21", optional = true } parse-wiki-text-2 = { version = "^0.2", optional = true } egui = { version = "^0.29", optional = true } @@ -56,7 +56,7 @@ form-input-rich = [ "form-input-rich-mediawiki", ] form-input-rich-html = ["dep:html5ever"] -form-input-rich-markdown = ["dep:comrak"] +form-input-rich-markdown = ["dep:markdown"] form-input-rich-mediawiki = ["dep:parse-wiki-text-2"] data-canvas = ["data-canvas-charts", "data-canvas-scene"] diff --git a/packages/components/src/data/canvas/charts/mod.rs b/packages/components/src/data/canvas/charts/mod.rs index baa3d4a..8c834a0 100644 --- a/packages/components/src/data/canvas/charts/mod.rs +++ b/packages/components/src/data/canvas/charts/mod.rs @@ -1,2 +1,2 @@ // https://echarts.apache.org/ -// https://egui.rs/ +// https://github.com/emilk/egui_plot/ diff --git a/packages/components/src/data/canvas/mod.rs b/packages/components/src/data/canvas/mod.rs index 1a9f6dc..4508a63 100644 --- a/packages/components/src/data/canvas/mod.rs +++ b/packages/components/src/data/canvas/mod.rs @@ -1,4 +1,4 @@ -#[cfg(features = "data-canvas-charts")] +#[cfg(feature = "data-canvas-charts")] pub mod charts; -#[cfg(features = "data-canvas-scene")] +#[cfg(feature = "data-canvas-scene")] pub mod scene; diff --git a/packages/components/src/data/paragraph/mod.rs b/packages/components/src/data/paragraph/mod.rs index 598b6dd..d3eb478 100644 --- a/packages/components/src/data/paragraph/mod.rs +++ b/packages/components/src/data/paragraph/mod.rs @@ -1,6 +1,8 @@ mod affix; mod badge; mod chip; + +mod rich; mod typography; mod avatar; @@ -10,6 +12,8 @@ mod image; pub use affix::Affix; pub use badge::Badge; pub use chip::Chip; + +pub use rich::Rich; pub use typography::Typography; pub use avatar::Avatar; diff --git a/packages/components/src/form/input/rich/html/mod.rs b/packages/components/src/data/paragraph/rich/html/mod.rs similarity index 100% rename from packages/components/src/form/input/rich/html/mod.rs rename to packages/components/src/data/paragraph/rich/html/mod.rs diff --git a/packages/components/src/data/paragraph/rich/markdown/mod.rs b/packages/components/src/data/paragraph/rich/markdown/mod.rs new file mode 100644 index 0000000..d126ea2 --- /dev/null +++ b/packages/components/src/data/paragraph/rich/markdown/mod.rs @@ -0,0 +1,20 @@ +#[cfg(test)] +mod test { + #[test] + fn test() { + use markdown::{to_mdast, ParseOptions}; + + let input = r#" +```rust;ignored +fn main() { + println!("Hello, world!"); +} +``` + + + +{a + b} // inline code + "#; + println!("{:?}", to_mdast(input, &ParseOptions::mdx()).unwrap()); + } +} diff --git a/packages/components/src/form/input/rich/markdown/mod.rs b/packages/components/src/data/paragraph/rich/mediawiki/mod.rs similarity index 100% rename from packages/components/src/form/input/rich/markdown/mod.rs rename to packages/components/src/data/paragraph/rich/mediawiki/mod.rs diff --git a/packages/components/src/form/input/rich/mod.rs b/packages/components/src/data/paragraph/rich/mod.rs similarity index 86% rename from packages/components/src/form/input/rich/mod.rs rename to packages/components/src/data/paragraph/rich/mod.rs index ff50b1b..f412909 100644 --- a/packages/components/src/form/input/rich/mod.rs +++ b/packages/components/src/data/paragraph/rich/mod.rs @@ -9,13 +9,13 @@ use stylist::yew::styled_component; use yew::prelude::*; #[derive(Properties, Debug, PartialEq)] -pub struct RichTextInputProps { +pub struct RichProps { #[prop_or_default] pub children: Children, } #[styled_component] -pub fn RichTextInput(props: &RichTextInputProps) -> Html { +pub fn Rich(props: &RichProps) -> Html { html! {
Html { - html! { -
- {props.children.clone()} -
- } -} diff --git a/packages/components/src/form/input/mod.rs b/packages/components/src/form/input/mod.rs index b09d093..e26ce0b 100644 --- a/packages/components/src/form/input/mod.rs +++ b/packages/components/src/form/input/mod.rs @@ -1,13 +1,7 @@ -pub mod rich; +mod rich; +mod text; +mod text_area; -mod char_input; -mod markdown_input; -mod password_input; -mod text_area_input; -mod text_input; - -pub use char_input::CharInput; -pub use markdown_input::MarkdownInput; -pub use password_input::PasswordInput; -pub use text_area_input::TextAreaInput; -pub use text_input::TextInput; +pub use rich::RichInput; +pub use text::TextInput; +pub use text_area::TextAreaInput; diff --git a/packages/components/src/form/input/password_input.rs b/packages/components/src/form/input/password_input.rs deleted file mode 100644 index ca7f512..0000000 --- a/packages/components/src/form/input/password_input.rs +++ /dev/null @@ -1,23 +0,0 @@ -use stylist::yew::styled_component; -use yew::prelude::*; - -#[derive(Properties, Debug, PartialEq)] -pub struct PasswordInputProps { - #[prop_or_default] - pub children: Children, -} - -#[styled_component] -pub fn PasswordInput(props: &PasswordInputProps) -> Html { - html! { -
- {props.children.clone()} -
- } -} diff --git a/packages/components/src/form/input/char_input.rs b/packages/components/src/form/input/rich.rs similarity index 84% rename from packages/components/src/form/input/char_input.rs rename to packages/components/src/form/input/rich.rs index 2c72b00..0966faa 100644 --- a/packages/components/src/form/input/char_input.rs +++ b/packages/components/src/form/input/rich.rs @@ -2,13 +2,13 @@ use stylist::yew::styled_component; use yew::prelude::*; #[derive(Properties, Debug, PartialEq)] -pub struct CharInputProps { +pub struct RichInputProps { #[prop_or_default] pub children: Children, } #[styled_component] -pub fn CharInput(props: &CharInputProps) -> Html { +pub fn RichInput(props: &RichInputProps) -> Html { html! {