Skip to content

Commit 4f166d4

Browse files
committed
wip
1 parent 29f9deb commit 4f166d4

5 files changed

Lines changed: 109 additions & 43 deletions

File tree

srcs/leptos_app/src/components/app.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,24 @@ pub fn App() -> impl IntoView {
2222
let (items, set_items) = signal(vec![
2323
Item {
2424
id: 1,
25-
x: 30,
26-
y: 90,
27-
w: 30,
28-
h: 30,
29-
editor: "".to_string(),
30-
schema: Some("".to_string()),
31-
shared: Some("".to_string()),
32-
},
33-
Item {
34-
id: 2,
35-
x: 30,
36-
y: 30,
25+
x: 800,
26+
y: -400,
3727
w: 30,
3828
h: 30,
3929
editor: "".to_string(),
4030
schema: Some("".to_string()),
4131
shared: Some("".to_string()),
4232
},
33+
// Item {
34+
// id: 2,
35+
// x: 30,
36+
// y: 30,
37+
// w: 30,
38+
// h: 30,
39+
// editor: "".to_string(),
40+
// schema: Some("".to_string()),
41+
// shared: Some("".to_string()),
42+
// },
4343
]);
4444

4545
view! {

srcs/leptos_app/src/components/container.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use crate::lib::{
1313
};
1414

1515
use super::app::Item;
16+
use super::editor::Editor;
1617

1718
#[component]
1819
pub fn Container(props: Item) -> impl IntoView {
@@ -111,8 +112,9 @@ pub fn Container(props: Item) -> impl IntoView {
111112
node_ref=node_ref
112113
>
113114
<div class="pointer-events-none">
114-
<div class="pointer-events-auto h-7" contenteditable=move || format!("{}", selected())>
115-
</div>
115+
<Editor></Editor>
116+
// <div class="pointer-events-auto h-7" contenteditable=move || format!("{}", selected())>
117+
// </div>
116118
</div>
117119
// <ErrorBoundary fallback=|| view! { <RenderFallback {...props} /> }>
118120
// // <Render initialValue={schema()} {...renderProps} />
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
use leptos::prelude::*;
2+
3+
#[component]
4+
pub fn Editor(
5+
value: String,
6+
decorate: bool,
7+
readonly: bool,
8+
render_element: bool,
9+
render_leaf: bool,
10+
// #[prop(default = "currentColor")] color: &'static str,
11+
#[prop(optional)] placeholder: &'static str,
12+
#[prop(optional)] style: &'static str,
13+
#[prop(optional)] on_value_changed: &'static str,
14+
#[prop(optional)] on_key_down: &'static str,
15+
children: ChildrenFn,
16+
) -> impl IntoView {
17+
view! {
18+
<div contenteditable=true>test</div>
19+
}
20+
}
21+
22+
// style={{
23+
// padding: '4px',
24+
// 'background-color': 'white',
25+
// 'border-radius': '4px',
26+
// 'padding-bottom': '12px',
27+
// 'pointer-events': 'auto',
28+
// }}
29+
// onKeyDown={(event: KeyboardEvent) => {
30+
// for (const hotkey in HOTKEYS) {
31+
// if (isHotkey(hotkey, event)) {
32+
// event.preventDefault();
33+
// const mark = HOTKEYS[hotkey as keyof typeof HOTKEYS];
34+
// toggleMark(editor, mark);
35+
// }
36+
// }
37+
// }}

srcs/leptos_app/src/components/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ pub mod app;
22
mod background;
33
mod container;
44
mod controls;
5+
mod editor;
56
mod icon;
67
mod viewport;

srcs/slate_leptos/src/lib.rs

Lines changed: 55 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,63 @@
1-
use leptos::logging;
2-
use wasm_bindgen::prelude::*;
1+
use leptos::prelude::*;
32

4-
#[wasm_bindgen(module = "/slate.js")]
5-
extern "C" {
6-
fn createEditor() -> String;
3+
#[component]
4+
pub fn Editable() -> impl IntoView {
5+
view! {
6+
<div contenteditable=true
7+
on:beforeinput=|_| {}
8+
on:input=|_| {}
9+
on:blur=|_| {}
10+
on:click=|_| {}
11+
on:compositionend=|_| {}
12+
on:compositionupdate=|_| {}
13+
on:compositionstart=|_| {}
14+
on:copy=|_| {}
15+
on:cut=|_| {}
16+
on:dragover=|_| {}
17+
on:dragstart=|_| {}
18+
on:drop=|_| {}
19+
on:dragend=|_| {}
20+
on:focus=|_| {}
21+
on:keydown=|_| {}
22+
on:paste=|_| {}
23+
>test</div>
24+
}
25+
}
726

8-
// type MyClass;
27+
// use leptos::logging;
28+
// use wasm_bindgen::prelude::*;
929

10-
// #[wasm_bindgen(constructor)]
11-
// fn new() -> MyClass;
30+
// #[wasm_bindgen(module = "/slate.js")]
31+
// extern "C" {
32+
// fn createEditor() -> String;
1233

13-
// #[wasm_bindgen(method, getter)]
14-
// fn number(this: &MyClass) -> u32;
15-
// #[wasm_bindgen(method, setter)]
16-
// fn set_number(this: &MyClass, number: u32) -> MyClass;
17-
// #[wasm_bindgen(method)]
18-
// fn render(this: &MyClass) -> String;
19-
}
34+
// // type MyClass;
2035

21-
// // lifted from the `console_log` example
22-
// #[wasm_bindgen]
23-
// extern "C" {
24-
// #[wasm_bindgen(js_namespace = console)]
25-
// fn log(s: &str);
36+
// // #[wasm_bindgen(constructor)]
37+
// // fn new() -> MyClass;
38+
39+
// // #[wasm_bindgen(method, getter)]
40+
// // fn number(this: &MyClass) -> u32;
41+
// // #[wasm_bindgen(method, setter)]
42+
// // fn set_number(this: &MyClass, number: u32) -> MyClass;
43+
// // #[wasm_bindgen(method)]
44+
// // fn render(this: &MyClass) -> String;
2645
// }
2746

28-
#[wasm_bindgen(start)]
29-
pub fn create_editor() {
30-
logging::log!("{:?}", createEditor());
31-
// log(&format!("Hello from {}!", name())); // should output "Hello from Rust!"
47+
// // // lifted from the `console_log` example
48+
// // #[wasm_bindgen]
49+
// // extern "C" {
50+
// // #[wasm_bindgen(js_namespace = console)]
51+
// // fn log(s: &str);
52+
// // }
3253

33-
// let x = MyClass::new();
34-
// assert_eq!(x.number(), 42);
35-
// x.set_number(10);
36-
// log(&x.render());
37-
}
54+
// #[wasm_bindgen(start)]
55+
// pub fn create_editor() {
56+
// logging::log!("{:?}", createEditor());
57+
// // log(&format!("Hello from {}!", name())); // should output "Hello from Rust!"
58+
59+
// // let x = MyClass::new();
60+
// // assert_eq!(x.number(), 42);
61+
// // x.set_number(10);
62+
// // log(&x.render());
63+
// }

0 commit comments

Comments
 (0)