diff --git a/.gitignore b/.gitignore index 84e096f..04eb975 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ /target /.cargo /.vscode -/edita/dist/ - +/examples/simple/dist/ +Cargo.lock \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock deleted file mode 100644 index f053db8..0000000 --- a/Cargo.lock +++ /dev/null @@ -1,601 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "autocfg" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" - -[[package]] -name = "bumpalo" -version = "3.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "console_error_panic_hook" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc" -dependencies = [ - "cfg-if", - "wasm-bindgen", -] - -[[package]] -name = "discard" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0" - -[[package]] -name = "edita-core" -version = "0.1.0" - -[[package]] -name = "edita-hirola" -version = "0.1.0" -dependencies = [ - "console_error_panic_hook", - "edita-core", - "hirola", - "js-sys", - "log", - "serde", - "serde_json", - "wasm-bindgen", - "wasm-logger", - "web-sys", -] - -[[package]] -name = "futures-channel" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" -dependencies = [ - "futures-core", -] - -[[package]] -name = "futures-core" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" - -[[package]] -name = "futures-macro" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.48", -] - -[[package]] -name = "futures-signals" -version = "0.3.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b175f2f6600dd81d92d20cf10872b03ea9df6b2513ca7f672341260dacb1ab2" -dependencies = [ - "discard", - "futures-channel", - "futures-core", - "futures-util", - "gensym", - "log", - "pin-project", - "serde", -] - -[[package]] -name = "futures-task" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" - -[[package]] -name = "futures-util" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" -dependencies = [ - "futures-core", - "futures-macro", - "futures-task", - "pin-project-lite", - "pin-utils", - "slab", -] - -[[package]] -name = "gensym" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "913dce4c5f06c2ea40fc178c06f777ac89fc6b1383e90c254fafb1abe4ba3c82" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.48", - "uuid", -] - -[[package]] -name = "getrandom" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" -dependencies = [ - "cfg-if", - "libc", - "wasi", -] - -[[package]] -name = "heck" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" - -[[package]] -name = "hirola" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1958dc5e0572bd2d7b80975404ffb35142a063b383ce36fb11e0d4e0bfebca24" -dependencies = [ - "hirola-core", - "hirola-dom", - "hirola-macros", -] - -[[package]] -name = "hirola-core" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "402909cc0a1a8893046f68ce51eccb0ce0dccf6c3f0d680af0814f98ded30b33" -dependencies = [ - "futures-signals", - "futures-util", -] - -[[package]] -name = "hirola-dom" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c0ec8073c6407e5aa7d2fd9297a8f784463a62724060a03da0f457ae41b262e" -dependencies = [ - "discard", - "hirola-core", - "hirola-macros", - "log", - "matchit", - "strum", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", -] - -[[package]] -name = "hirola-macros" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "690305c148bf67b553bcf14f2b386c9ed00f745db29fed440d1fdfb18e63cb84" -dependencies = [ - "heck", - "paste", - "proc-macro-error", - "proc-macro-hack", - "proc-macro2", - "quote", - "rstml", - "syn 2.0.48", -] - -[[package]] -name = "itoa" -version = "1.0.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" - -[[package]] -name = "js-sys" -version = "0.3.66" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cee9c64da59eae3b50095c18d3e74f8b73c0b86d2792824ff01bbce68ba229ca" -dependencies = [ - "wasm-bindgen", -] - -[[package]] -name = "libc" -version = "0.2.151" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4" - -[[package]] -name = "log" -version = "0.4.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" - -[[package]] -name = "matchit" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" - -[[package]] -name = "once_cell" -version = "1.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" - -[[package]] -name = "paste" -version = "1.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" - -[[package]] -name = "pin-project" -version = "1.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fda4ed1c6c173e3fc7a83629421152e01d7b1f9b7f65fb301e490e8cfc656422" -dependencies = [ - "pin-project-internal", -] - -[[package]] -name = "pin-project-internal" -version = "1.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.48", -] - -[[package]] -name = "pin-project-lite" -version = "0.2.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" - -[[package]] -name = "pin-utils" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" - -[[package]] -name = "proc-macro-error" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" -dependencies = [ - "proc-macro-error-attr", - "proc-macro2", - "quote", - "syn 1.0.109", - "version_check", -] - -[[package]] -name = "proc-macro-error-attr" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" -dependencies = [ - "proc-macro2", - "quote", - "version_check", -] - -[[package]] -name = "proc-macro-hack" -version = "0.5.20+deprecated" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068" - -[[package]] -name = "proc-macro2" -version = "1.0.75" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "907a61bd0f64c2f29cd1cf1dc34d05176426a3f504a78010f08416ddb7b13708" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "proc-macro2-diagnostics" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.48", - "version_check", - "yansi", -] - -[[package]] -name = "quote" -version = "1.0.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "rstml" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe542870b8f59dd45ad11d382e5339c9a1047cde059be136a7016095bbdefa77" -dependencies = [ - "proc-macro2", - "proc-macro2-diagnostics", - "quote", - "syn 2.0.48", - "syn_derive", - "thiserror", -] - -[[package]] -name = "rustversion" -version = "1.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" - -[[package]] -name = "ryu" -version = "1.0.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" - -[[package]] -name = "serde" -version = "1.0.194" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b114498256798c94a0689e1a15fec6005dee8ac1f41de56404b67afc2a4b773" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.194" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3385e45322e8f9931410f01b3031ec534c3947d0e94c18049af4d9f9907d4e0" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.48", -] - -[[package]] -name = "serde_json" -version = "1.0.111" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "176e46fa42316f18edd598015a5166857fc835ec732f5215eac6b7bdbf0a84f4" -dependencies = [ - "itoa", - "ryu", - "serde", -] - -[[package]] -name = "slab" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" -dependencies = [ - "autocfg", -] - -[[package]] -name = "strum" -version = "0.25.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" -dependencies = [ - "strum_macros", -] - -[[package]] -name = "strum_macros" -version = "0.25.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23dc1fa9ac9c169a78ba62f0b841814b7abae11bdd047b9c58f893439e309ea0" -dependencies = [ - "heck", - "proc-macro2", - "quote", - "rustversion", - "syn 2.0.48", -] - -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "unicode-ident", -] - -[[package]] -name = "syn" -version = "2.0.48" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "syn_derive" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1329189c02ff984e9736652b1631330da25eaa6bc639089ed4915d25446cbe7b" -dependencies = [ - "proc-macro-error", - "proc-macro2", - "quote", - "syn 2.0.48", -] - -[[package]] -name = "thiserror" -version = "1.0.56" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad" -dependencies = [ - "thiserror-impl", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.56" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.48", -] - -[[package]] -name = "unicode-ident" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" - -[[package]] -name = "uuid" -version = "1.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e395fcf16a7a3d8127ec99782007af141946b4795001f876d54fb0d55978560" -dependencies = [ - "getrandom", -] - -[[package]] -name = "version_check" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" - -[[package]] -name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - -[[package]] -name = "wasm-bindgen" -version = "0.2.89" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ed0d4f68a3015cc185aff4db9506a015f4b96f95303897bfa23f846db54064e" -dependencies = [ - "cfg-if", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.89" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b56f625e64f3a1084ded111c4d5f477df9f8c92df113852fa5a374dbda78826" -dependencies = [ - "bumpalo", - "log", - "once_cell", - "proc-macro2", - "quote", - "syn 2.0.48", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-futures" -version = "0.4.39" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac36a15a220124ac510204aec1c3e5db8a22ab06fd6706d881dc6149f8ed9a12" -dependencies = [ - "cfg-if", - "js-sys", - "wasm-bindgen", - "web-sys", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.89" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0162dbf37223cd2afce98f3d0785506dcb8d266223983e4b5b525859e6e182b2" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.89" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.48", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.89" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ab9b36309365056cd639da3134bf87fa8f3d86008abf99e612384a6eecd459f" - -[[package]] -name = "wasm-logger" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "074649a66bb306c8f2068c9016395fa65d8e08d2affcbf95acf3c24c3ab19718" -dependencies = [ - "log", - "wasm-bindgen", - "web-sys", -] - -[[package]] -name = "web-sys" -version = "0.3.66" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50c24a44ec86bb68fbecd1b3efed7e85ea5621b39b35ef2766b66cd984f8010f" -dependencies = [ - "js-sys", - "wasm-bindgen", -] - -[[package]] -name = "yansi" -version = "1.0.0-rc.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1367295b8f788d371ce2dbc842c7b709c73ee1364d30351dd300ec2203b12377" diff --git a/Cargo.toml b/Cargo.toml index b68407e..c959577 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,3 +1,3 @@ [workspace] -members = ["edita-core", "edita"] +members = ["edita-core", "edita", "examples/simple"] resolver = "2" diff --git a/edita-core/Cargo.toml b/edita-core/Cargo.toml index 554d7d1..eb06c4e 100644 --- a/edita-core/Cargo.toml +++ b/edita-core/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "edita-core" -version = "0.1.0" +version = "0.2.0" edition = "2021" authors = ["Geoffrey Mureithi "] description = "edita-core is a core rust library for building headless block editors" diff --git a/edita/Cargo.toml b/edita/Cargo.toml index 22768c3..101f06e 100644 --- a/edita/Cargo.toml +++ b/edita/Cargo.toml @@ -1,6 +1,6 @@ [package] -name = "edita-hirola" -version = "0.1.0" +name = "edita" +version = "0.2.0" edition = "2021" authors = ["Geoffrey Mureithi "] description = "edita is a simple block html-based editor built with rust" @@ -18,23 +18,8 @@ crate-type = ["cdylib", "rlib"] [dependencies] hirola = "0.4" -console_error_panic_hook = "0.1.7" -web-sys = { version = "0.3", features = [ - "MutationObserver", - "MutationObserverInit", - "MutationRecord", - "CharacterData", - "Selection", - "Range", - "CssFontFaceRule", - "CssStyleDeclaration", - "NodeList", - "HtmlImageElement", -] } +web-sys = { version = "0.3" } js-sys = "0.3" wasm-bindgen = "0.2" serde = { version = "1", features = ["derive"] } -serde_json = "1" -edita-core = { path = "../edita-core", version = "0.1.0" } -log = "0.4.6" -wasm-logger = "0.2.0" +edita-core = { path = "../edita-core", version = "0.2.0" } diff --git a/edita/src/heading.rs b/edita/src/heading.rs index d9cbba2..72de3c9 100644 --- a/edita/src/heading.rs +++ b/edita/src/heading.rs @@ -69,6 +69,6 @@ impl Block for HeaderBlock { impl Command for HeaderBlock { fn execute(&self, state: &mut EditorState) { - state.add_node(Box::::default()) + state.add_node(Heading::default()) } } diff --git a/edita/src/lib.rs b/edita/src/lib.rs index 3461f72..c5c72dd 100644 --- a/edita/src/lib.rs +++ b/edita/src/lib.rs @@ -7,6 +7,8 @@ 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; diff --git a/edita/src/nodes/task_list.rs b/edita/src/nodes/task_list.rs index 676ccf7..d7e433f 100644 --- a/edita/src/nodes/task_list.rs +++ b/edita/src/nodes/task_list.rs @@ -7,10 +7,7 @@ use web_sys::{Element, Node}; use crate::{nodes::EditorNode, EditorState}; -use super::{ - list_item::{ListItem, ListItemBlock}, - task_item::{TaskItem, TaskItemBlock}, -}; +use super::task_item::{TaskItem, TaskItemBlock}; pub struct TaskListBlock; @@ -37,7 +34,7 @@ impl Block for TaskListBlock { EditorNode::TaskList(TaskList { list: Object::entries(&node.child_nodes()) .into_iter() - .map(|item| TaskItem::parse(&TaskItemBlock, editor, item.dyn_ref().unwrap())) + .map(|item| TaskItemBlock::parse(&TaskItemBlock, editor, item.dyn_ref().unwrap())) .map(|node| match node { EditorNode::TaskItem(item) => Some(item), _ => None, diff --git a/edita/src/paragraph.rs b/edita/src/paragraph.rs index 355d3e6..af920cb 100644 --- a/edita/src/paragraph.rs +++ b/edita/src/paragraph.rs @@ -63,6 +63,6 @@ impl Block for ParagraphBlock { impl Command for ParagraphBlock { fn execute(&self, state: &mut EditorState) { - state.add_node(Box::::default()) + state.add_node(Paragraph::default()) } } diff --git a/edita/src/state.rs b/edita/src/state.rs index 248ba8f..c3ff0d2 100644 --- a/edita/src/state.rs +++ b/edita/src/state.rs @@ -1,3 +1,4 @@ +use edita_core::Command; use hirola::{ dom::node_ref::NodeRef, prelude::{Callback, GenericNode}, @@ -26,7 +27,7 @@ impl EditorState { notify: Mutable::new(()), } } - pub fn add_node(&self, node: Box) { + pub fn add_node(&self, node: N) { self.node.get().append_render(node.render()); } @@ -34,9 +35,14 @@ impl EditorState { &self.node } + pub fn execute>(&self, cmd: C) { + cmd.execute(&mut self.clone()) + } + pub fn notify(&self) { self.notify.replace(()) } + } impl Callback for EditorState {} diff --git a/examples/simple/Cargo.toml b/examples/simple/Cargo.toml new file mode 100644 index 0000000..b81d748 --- /dev/null +++ b/examples/simple/Cargo.toml @@ -0,0 +1,28 @@ +[package] +name = "simple" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +hirola = "0.4" +edita = { path = "../../edita" } +console_error_panic_hook = "0.1.7" +log = "0.4.6" +wasm-logger = "0.2.0" +wasm-bindgen = "0.2" +js-sys = "0.3" +serde_json = "1" +web-sys = { version = "0.3", features = [ + "MutationObserver", + "MutationObserverInit", + "MutationRecord", + "CharacterData", + "Selection", + "Range", + "CssFontFaceRule", + "CssStyleDeclaration", + "NodeList", + "HtmlImageElement", +] } \ No newline at end of file diff --git a/edita/Trunk.toml b/examples/simple/Trunk.toml similarity index 100% rename from edita/Trunk.toml rename to examples/simple/Trunk.toml diff --git a/edita/index.html b/examples/simple/index.html similarity index 100% rename from edita/index.html rename to examples/simple/index.html diff --git a/edita/src/main.rs b/examples/simple/src/main.rs similarity index 72% rename from edita/src/main.rs rename to examples/simple/src/main.rs index 8e0aaa2..1775e60 100644 --- a/edita/src/main.rs +++ b/examples/simple/src/main.rs @@ -1,13 +1,6 @@ -mod commands; -mod editor; -mod heading; -mod image; -mod nodes; -mod paragraph; -mod state; -mod text; - -use edita_core::Command; +use edita::core::Command; +use edita::core::*; +use edita::*; use hirola::dom::node_ref::NodeRef; use hirola::dom::*; use hirola::prelude::*; @@ -15,17 +8,6 @@ use hirola::signal::SignalExt; use wasm_bindgen::closure::Closure; use wasm_bindgen::JsCast; -use crate::commands::bold::MakeBold; -use crate::editor::EditorExt; -use crate::heading::HeaderBlock; -use crate::image::Image; -use crate::image::ImageBlock; -use crate::blocks::Node; -use crate::paragraph::Paragraph; -use crate::paragraph::ParagraphBlock; -use crate::state::EditorState; -use crate::text::{BoldBlock, InlineCodeBlock, ItalicBlock, TextNodeBlock}; - fn main() { wasm_logger::init(wasm_logger::Config::default()); console_error_panic_hook::set_once(); @@ -38,7 +20,7 @@ fn app() -> Dom { let notifier = state.clone(); - let mut editor = edita_core::Editor::new(state.clone()); + let mut editor = Editor::new(state.clone()); editor.add_block(HeaderBlock); editor.add_block(ParagraphBlock); editor.add_block(TextNodeBlock); @@ -76,11 +58,9 @@ fn app() -> Dom {

"A simple Editor"