diff --git a/wax-prosemirror-core/src/ioc-react.js b/wax-prosemirror-core/src/ioc-react.js index a0e111577e2174d27dd944a4c2c74021fa92dc97..ce78895e44a9262fb013cf2f49b31302c998b544 100644 --- a/wax-prosemirror-core/src/ioc-react.js +++ b/wax-prosemirror-core/src/ioc-react.js @@ -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 }); } }); diff --git a/wax-prosemirror-services/src/NoteService/Editor.js b/wax-prosemirror-services/src/NoteService/Editor.js index ca891d29e885687c53d5d517919be99b31647d7f..4f7e86e14565f993fbb123909a583af955824131 100644 --- a/wax-prosemirror-services/src/NoteService/Editor.js +++ b/wax-prosemirror-services/src/NoteService/Editor.js @@ -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 = () => {