Skip to content

Commit

Permalink
save attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
aliscie committed Mar 23, 2023
1 parent d405a42 commit 7ae4699
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions editor/src/handle_mutation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ pub fn handle_mutation(
}
}
"attributes" => {
log!("change attr"); // TODO save attributes
if let Some(element) = current_element.parent_element() {
// log!(element.get_attribute("class"));
if let Ok(id) = Uuid::parse_str(element.id().as_ref()).map(Id::from) {
Expand Down
3 changes: 2 additions & 1 deletion editor/src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ pub fn on_slash_input(
tree_id: element_tree.id,
parent_id: *parent_id.unwrap_or(&current_element),
children: adjacency.get(&i.id).cloned(),
prev_element_id: Some(current_element),
// TODO fix this prev_element_id: Some(current_element),
prev_element_id: None,
}));
}
return Some((id, changes));
Expand Down
12 changes: 10 additions & 2 deletions frontend/src/editor_components/table/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use editor::plugins::Position;
use shared::id::Id;
use shared::schema::{EditorChange, EditorElement};
use wasm_bindgen::UnwrapThrowExt;
use web_sys::{window, HtmlInputElement, HtmlTableCellElement, MouseEvent};
use web_sys::{window, HtmlInputElement, HtmlTableCellElement, MouseEvent, HtmlElement};
use yew::prelude::*;
use yew::{function_component, html};
use yew_hooks::prelude::*;
Expand Down Expand Up @@ -48,10 +48,18 @@ pub fn Table(props: &Props) -> Html {
let on_column_contextmenu = {
let global_state = global_state.clone();
Callback::from(move |mouse_event: MouseEvent| {
let curr :HtmlElement = mouse_event.target_unchecked_into();

let element = html! {
<ContextProvider<GlobalEditorState> context = {global_state.clone()}>
<ContextMenu items={vec![
html!{<a>{"add formula"}</a>},
html!{<a
onclick={
Callback::from(move |e: MouseEvent| {
curr.set_attribute("formula", "1+1").unwrap_throw();
})
}
>{"add formula"}</a>},
html!{<a>{"add filter"}</a>},]} event = {mouse_event.clone()}/ >
</ContextProvider<GlobalEditorState>>
};
Expand Down

0 comments on commit 7ae4699

Please sign in to comment.