Skip to content
Snippets Groups Projects
Commit 52e13827 authored by chris's avatar chris
Browse files

set into WaxContext the active view

parent 559b80cb
No related branches found
No related tags found
1 merge request!76Comment discussion
......@@ -3,15 +3,20 @@ import React, { useContext, useState } from "react";
export const WaxContext = React.createContext({
view: {},
app: null,
updateView: null
updateView: null,
updateActiveView: null
});
export default props => {
const [context, setContext] = useState({
app: props.app,
view: props.view || {},
activeView: props.activeView || {},
updateView: view => {
setContext({ ...context, view: Object.assign(context.view, view) });
},
updateActiveView: view => {
setContext({ ...context, activeView: view });
}
});
......
......@@ -57,6 +57,8 @@ export default ({ node, view }) => {
// footnote is node-selected (and thus DOM-selected) when
// the parent editor is focused.
if (noteView.hasFocus()) noteView.focus();
//Set everytime the active view into context
context.updateActiveView(context.view[noteId]);
}
}
}
......@@ -64,7 +66,11 @@ export default ({ node, view }) => {
//Set Each note into Wax's Context
context.updateView({ [noteId]: noteView });
if (context.view[noteId]) context.view[noteId].focus();
if (context.view[noteId]) {
context.view[noteId].focus();
//Set everytime the active view into context
context.updateActiveView(context.view[noteId]);
}
}, []);
const createKeyBindings = () => {
......
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