From 4f5e6240cce3faba233fc909f770f42594b5e41b Mon Sep 17 00:00:00 2001 From: chris <kokosias@yahoo.gr> Date: Thu, 21 Jan 2021 22:16:55 +0200 Subject: [PATCH] workaround for setting active view in notes --- .../src/components/findAndReplace/FindComponent.js | 1 - .../src/components/findAndReplace/helpers.js | 1 - wax-prosemirror-services/src/NoteService/Editor.js | 6 ++++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/wax-prosemirror-components/src/components/findAndReplace/FindComponent.js b/wax-prosemirror-components/src/components/findAndReplace/FindComponent.js index b78c59d64..42cc4ea10 100644 --- a/wax-prosemirror-components/src/components/findAndReplace/FindComponent.js +++ b/wax-prosemirror-components/src/components/findAndReplace/FindComponent.js @@ -177,7 +177,6 @@ const FindComponent = ({ close, expand, setPreviousSearcValue }) => { ); const resultsFrom = helpers.getResultsFrom(results); const notesIds = helpers.getNotesIds(view.main); - const found = helpers.getClosestMatch( lastSelection.from, resultsFrom[lastActiveViewId], diff --git a/wax-prosemirror-components/src/components/findAndReplace/helpers.js b/wax-prosemirror-components/src/components/findAndReplace/helpers.js index 451ffa1d7..2bc31ee51 100644 --- a/wax-prosemirror-components/src/components/findAndReplace/helpers.js +++ b/wax-prosemirror-components/src/components/findAndReplace/helpers.js @@ -120,7 +120,6 @@ const getClosestMatch = (selectionFrom, results, greater = true) => { }; const moveToMatch = (view, lastActiveViewId, results, position) => { - console.log(lastActiveViewId, results, position); const selectionFrom = new TextSelection( view[lastActiveViewId].state.doc.resolve( results[lastActiveViewId][position].from, diff --git a/wax-prosemirror-services/src/NoteService/Editor.js b/wax-prosemirror-services/src/NoteService/Editor.js index 77276a22b..79d3f2766 100644 --- a/wax-prosemirror-services/src/NoteService/Editor.js +++ b/wax-prosemirror-services/src/NoteService/Editor.js @@ -18,7 +18,7 @@ export default ({ node, view }) => { const context = useContext(WaxContext); const noteId = node.attrs.id; let noteView; - + let clickInNote = false; // eslint-disable-next-line react/destructuring-assignment const isEditable = context.view.main.props.editable(editable => { return editable; @@ -38,7 +38,7 @@ export default ({ node, view }) => { handleDOMEvents: { mousedown: () => { context.updateView({}, noteId); - + clickInNote = true; // Kludge to prevent issues due to the fact that the whole // footnote is node-selected (and thus DOM-selected) when // the parent editor is focused. @@ -92,6 +92,8 @@ export default ({ node, view }) => { // TODO Remove timeout and use state to check if noteView has changed setTimeout(() => { + if (clickInNote) context.updateView({}, noteId); + clickInNote = false; if (noteView.state.selection.from !== noteView.state.selection.to) context.updateView({}, noteId); }, 20); -- GitLab