Skip to content

Commit

Permalink
refactor: exports
Browse files Browse the repository at this point in the history
  • Loading branch information
geofmureithi committed Feb 25, 2024
1 parent a5975fd commit d246701
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 27 deletions.
13 changes: 2 additions & 11 deletions edita/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,15 @@
mod commands;
mod editor;
mod heading;
mod image;
mod nodes;
mod paragraph;

mod state;
mod text;

pub use edita_core as core;

pub use crate::commands::bold::MakeBold;
pub use crate::editor::EditorExt;
pub use crate::heading::HeaderBlock;
pub use crate::image::Image;
pub use crate::image::ImageBlock;
pub use crate::nodes::Node;
pub use crate::paragraph::Paragraph;
pub use crate::paragraph::ParagraphBlock;
pub use crate::nodes::*;
pub use crate::state::EditorState;
pub use crate::text::{BoldBlock, InlineCodeBlock, ItalicBlock, TextNodeBlock};

// # Blocks
//
Expand Down
10 changes: 5 additions & 5 deletions edita/src/heading.rs → edita/src/nodes/heading.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ use web_sys::Element;
use crate::{nodes::EditorNode, state::EditorState};

#[derive(Clone, Serialize, Debug)]
pub struct Heading {
pub struct Header {
text: String,
level: u8,
}

impl Default for Heading {
impl Default for Header {
fn default() -> Self {
Self {
text: String::default(),
Expand All @@ -21,7 +21,7 @@ impl Default for Heading {
}
}

impl crate::nodes::Node for Heading {
impl crate::nodes::Node for Header {
fn render(&self) -> Dom {
html! { <h1 data-ph="Heading">{self.text.clone()}</h1> }
}
Expand Down Expand Up @@ -60,7 +60,7 @@ impl Block for HeaderBlock {
_ => 0, // Default level, or you could handle this case differently
};

EditorNode::Heading(Heading { text, level })
EditorNode::Heading(Header { text, level })
} else {
unreachable!("No such header")
}
Expand All @@ -69,6 +69,6 @@ impl Block for HeaderBlock {

impl Command<EditorState> for HeaderBlock {
fn execute(&self, state: &mut EditorState) {
state.add_node(Heading::default())
state.add_node(Header::default())
}
}
File renamed without changes.
37 changes: 26 additions & 11 deletions edita/src/nodes/mod.rs
Original file line number Diff line number Diff line change
@@ -1,25 +1,40 @@
pub mod block_quote;
mod block_quote;
mod bullet_list;
pub mod list_item;
mod heading;
mod image;
mod list_item;
mod ordered_list;
mod paragraph;
mod task_item;
mod task_list;

mod text;
use hirola::{dom::Dom, prelude::*};
use serde::Serialize;

use crate::{
nodes::block_quote::BlockQuote,
editor::HtmlNode,
heading::Heading,
use crate::{editor::HtmlNode, nodes::block_quote::BlockQuote};

pub use self::{
bullet_list::BulletList,
heading::Header,
image::Image,
list_item::ListItem,
ordered_list::OrderedList,
paragraph::Paragraph,
task_item::TaskItem,
task_list::TaskList,
text::{Bold, InlineCode, Italic, TextNode},
};

use self::{
bullet_list::BulletList, list_item::ListItem, ordered_list::OrderedList, task_item::TaskItem,
task_list::TaskList,
pub use self::{
bullet_list::BulletListBlock,
heading::HeaderBlock,
image::ImageBlock,
list_item::ListItemBlock,
ordered_list::OrderedListBlock,
paragraph::ParagraphBlock,
task_item::TaskItemBlock,
task_list::TaskListBlock,
text::{BoldBlock, InlineCodeBlock, ItalicBlock, TextNodeBlock},
};

pub trait Node {
Expand All @@ -32,7 +47,7 @@ pub enum EditorNode {
Paragraph(Paragraph),
Text(TextNode),
Bold(Bold),
Heading(Heading),
Heading(Header),
Italic(Italic),
InlineCode(InlineCode),
Image(Image),
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit d246701

Please sign in to comment.