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

Set activeViewId into context

parent c9046309
No related branches found
No related tags found
1 merge request!76Comment discussion
......@@ -52,7 +52,12 @@ export default props => {
const state = view.state.apply(tr);
view.updateState(state);
context.updateView({ main: view });
context.updateView({
main: view,
activeViewId: context.activeViewId,
activeView: view
});
props.onChange(state.doc.content);
};
......
......@@ -3,6 +3,7 @@ import React, { useContext, useState } from "react";
export const WaxContext = React.createContext({
view: {},
activeView: {},
activeViewId: null,
app: null,
updateView: null,
updateActiveView: null
......@@ -13,15 +14,21 @@ export default props => {
app: props.app,
view: props.view || {},
activeView: props.activeView || {},
activeViewId: props.activeViewId || {},
updateView: view => {
setContext({
...context,
view: Object.assign(context.view, view),
activeView: view.main || view
activeView: view.main || view,
activeViewId: view.activeViewId
});
},
updateActiveView: view => {
setContext({ ...context, activeView: view });
setContext({
...context,
activeView: view.activeView,
activeViewId: view.activeViewId
});
}
});
......
......@@ -48,9 +48,13 @@ export default ({ node, view }) => {
outerTr.step(steps[j].map(offsetMap));
}
//Set everytime the active view into context
context.updateActiveView(context.view[noteId]);
if (outerTr.docChanged) view.dispatch(outerTr);
//Set everytime the active view into context
context.updateActiveView({
activeView: context.view[noteId],
activeViewId: noteId
});
}
},
handleDOMEvents: {
......@@ -68,8 +72,12 @@ export default ({ node, view }) => {
context.updateView({ [noteId]: noteView });
if (context.view[noteId]) {
context.view[noteId].focus();
//Set everytime the active view into context
context.updateActiveView(context.view[noteId]);
context.updateActiveView({
activeView: context.view[noteId],
activeViewId: noteId
});
}
}, []);
......
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