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

remove selection if focus is lost from note

parent aba2ee8b
No related branches found
No related tags found
1 merge request!258Editoria fixes
...@@ -50,7 +50,7 @@ export default ({ comment, top, commentId, recalculateTops }) => { ...@@ -50,7 +50,7 @@ export default ({ comment, top, commentId, recalculateTops }) => {
const commentPlugin = app.PmPlugins.get('commentPlugin'); const commentPlugin = app.PmPlugins.get('commentPlugin');
const activeComment = commentPlugin.getState(activeView.state).comment; const activeComment = commentPlugin.getState(activeView.state).comment;
console.log(activeComment);
useEffect(() => { useEffect(() => {
setIsActive(false); setIsActive(false);
recalculateTops(); recalculateTops();
...@@ -121,6 +121,7 @@ export default ({ comment, top, commentId, recalculateTops }) => { ...@@ -121,6 +121,7 @@ export default ({ comment, top, commentId, recalculateTops }) => {
}); });
// if (allCommentsWithSameId.length > 1); // if (allCommentsWithSameId.length > 1);
// maxPos += last(allCommentsWithSameId).node.nodeSize; // maxPos += last(allCommentsWithSameId).node.nodeSize;
recalculateTops();
dispatch(state.tr.removeMark(minPos, maxPos, commentMark)); dispatch(state.tr.removeMark(minPos, maxPos, commentMark));
activeView.focus(); activeView.focus();
}; };
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
import React, { useEffect, useRef, useContext, useMemo } from 'react'; import React, { useEffect, useRef, useContext, useMemo } from 'react';
import { filter } from 'lodash'; import { filter } from 'lodash';
import { EditorView } from 'prosemirror-view'; import { EditorView } from 'prosemirror-view';
import { EditorState } from 'prosemirror-state'; import { EditorState, TextSelection } from 'prosemirror-state';
import { StepMap } from 'prosemirror-transform'; import { StepMap } from 'prosemirror-transform';
import { baseKeymap } from 'prosemirror-commands'; import { baseKeymap } from 'prosemirror-commands';
import { keymap } from 'prosemirror-keymap'; import { keymap } from 'prosemirror-keymap';
...@@ -37,6 +37,14 @@ export default ({ node, view }) => { ...@@ -37,6 +37,14 @@ export default ({ node, view }) => {
// This is the magic part // This is the magic part
dispatchTransaction, dispatchTransaction,
handleDOMEvents: { handleDOMEvents: {
blur: () => {
context.view[noteId].dispatch(
context.view[noteId].state.tr.setSelection(
new TextSelection(context.view[noteId].state.tr.doc.resolve(0)),
),
);
},
mousedown: () => { mousedown: () => {
context.updateView({}, noteId); context.updateView({}, noteId);
clickInNote = true; clickInNote = true;
......
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