Skip to content
Snippets Groups Projects
Commit 1a5307e4 authored by chris's avatar chris
Browse files

add Todo plus cleanup

parent f03c48b3
No related branches found
No related tags found
1 merge request!68add Todo plus cleanup
...@@ -48,7 +48,7 @@ export default ({ node, view, pos }) => { ...@@ -48,7 +48,7 @@ export default ({ node, view, pos }) => {
} }
} }
); );
// noteView.focus(); noteView.focus();
context.updateView({ [pos]: noteView }); context.updateView({ [pos]: noteView });
}, []); }, []);
......
...@@ -9,7 +9,7 @@ export default class Note extends Tools { ...@@ -9,7 +9,7 @@ export default class Note extends Tools {
get run() { get run() {
return (state, dispatch) => { return (state, dispatch) => {
const footnote = state.config.schema.nodes.footnote.create(); const footnote = state.config.schema.nodes.footnote.create(null, "");
dispatch(state.tr.replaceSelectionWith(footnote)); dispatch(state.tr.replaceSelectionWith(footnote));
}; };
} }
......
...@@ -7,6 +7,8 @@ import NoteEditor from "./NoteEditor"; ...@@ -7,6 +7,8 @@ import NoteEditor from "./NoteEditor";
export default () => { export default () => {
const { view: { main } } = useContext(WaxContext); const { view: { main } } = useContext(WaxContext);
const [notes, setNotes] = useState([]); const [notes, setNotes] = useState([]);
//TODO Set notes to watch if actual content has changed
const [notesContent, setNotesContent] = useState([]);
useEffect( useEffect(
() => { () => {
setNotes(updateNotes(main)); setNotes(updateNotes(main));
...@@ -17,12 +19,19 @@ export default () => { ...@@ -17,12 +19,19 @@ export default () => {
const noteComponent = useMemo( const noteComponent = useMemo(
() => <NoteEditor notes={notes} view={main} />, () => <NoteEditor notes={notes} view={main} />,
[notes] [notes.length]
); );
return <div>{noteComponent}</div>; return <div>{noteComponent}</div>;
}; };
const updateNotes = view => { const updateNotes = view => {
if (view) { if (view) {
console.log(
DocumentHelpers.findChildrenByType(
view.state.doc,
view.state.schema.nodes.footnote,
true
)
);
return DocumentHelpers.findChildrenByType( return DocumentHelpers.findChildrenByType(
view.state.doc, view.state.doc,
view.state.schema.nodes.footnote, view.state.schema.nodes.footnote,
......
...@@ -2,11 +2,6 @@ import React, { useMemo } from "react"; ...@@ -2,11 +2,6 @@ import React, { useMemo } from "react";
import Editor from "./Editor"; import Editor from "./Editor";
export default ({ notes, view }) => { export default ({ notes, view }) => {
// const EditorComponent = useMemo(
// () => <Editor node={note.node} pos={note.pos} view={view} />,
// [notes]
// );
return ( return (
<div> <div>
{notes.map(note => ( {notes.map(note => (
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment