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

revert comments implementation

parent 69059b79
No related branches found
No related tags found
1 merge request!160add track change plugin through service
...@@ -92,16 +92,22 @@ export default ({ comment, activeView, user, active }) => { ...@@ -92,16 +92,22 @@ export default ({ comment, activeView, user, active }) => {
const resolveComment = event => { const resolveComment = event => {
if (event) event.stopPropagation(); if (event) event.stopPropagation();
let maxPos = comment.pos;
let minPos = comment.pos;
const actualComment = DocumentHelpers.findMarkPosition( allCommentsWithSameId.forEach(singleComment => {
activeView.state, const markPosition = DocumentHelpers.findMarkPosition(
allCommentsWithSameId[0].pos, state,
'comment', singleComment.pos,
); 'comment',
);
if (markPosition.from < minPos) minPos = markPosition.from;
if (markPosition.to > maxPos) maxPos = markPosition.to;
});
dispatch( if (allCommentsWithSameId.length > 1)
state.tr.removeMark(actualComment.from, actualComment.to, commentMark), maxPos += last(allCommentsWithSameId).node.nodeSize;
); dispatch(state.tr.removeMark(minPos, maxPos, commentMark));
activeView.focus(); activeView.focus();
}; };
......
...@@ -22,13 +22,37 @@ const getComment = state => { ...@@ -22,13 +22,37 @@ const getComment = state => {
} }
if (commentOnSelection) { if (commentOnSelection) {
const actualComment = DocumentHelpers.findMarkPosition( const commentNodes = DocumentHelpers.findChildrenByMark(
state, state.doc,
commentOnSelection.from, commentMark,
'comment', true,
); );
return actualComment;
const allCommentsWithSameId = [];
commentNodes.map(node => {
node.node.marks.filter(mark => {
if (
mark.type.name === 'comment' &&
commentOnSelection.attrs.id === mark.attrs.id
) {
allCommentsWithSameId.push(node);
}
});
});
if (allCommentsWithSameId.length > 1) {
const minPos = minBy(allCommentsWithSameId, 'pos');
const maxPos = maxBy(allCommentsWithSameId, 'pos');
return {
from: minPos.pos,
to: maxPos.pos + last(allCommentsWithSameId).node.nodeSize,
attrs: commentOnSelection.attrs,
contained: commentOnSelection.contained,
};
}
} }
return commentOnSelection;
}; };
export default props => { export default props => {
......
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