From 52e13827bc12104044c5554a06dc1288c0a538e0 Mon Sep 17 00:00:00 2001 From: chris <kokosias@yahoo.gr> Date: Mon, 30 Mar 2020 20:31:08 +0300 Subject: [PATCH] set into WaxContext the active view --- wax-prosemirror-core/src/ioc-react.js | 7 ++++++- wax-prosemirror-services/src/NoteService/Editor.js | 8 +++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/wax-prosemirror-core/src/ioc-react.js b/wax-prosemirror-core/src/ioc-react.js index a0e111577..ce78895e4 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 ca891d29e..4f7e86e14 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 = () => { -- GitLab