Skip to content
Snippets Groups Projects
Commit 449d8102 authored by chris's avatar chris
Browse files

feat(layout): comment/track counter

parent eee57953
No related branches found
No related tags found
1 merge request!226Ui components
...@@ -186,6 +186,27 @@ const getNotes = main => { ...@@ -186,6 +186,27 @@ const getNotes = main => {
return notes; return notes;
}; };
const getCommentsTracks = main => {
const marks = DocumentHelpers.findInlineNodes(main.state.doc);
const commentsTracks = [];
marks.map(node => {
if (node.node.marks.length > 0) {
node.node.marks.filter(mark => {
if (
mark.type.name === 'comment' ||
mark.type.name === 'insertion' ||
mark.type.name === 'deletion' ||
mark.type.name === 'format_change'
) {
mark.pos = node.pos;
commentsTracks.push(mark);
}
});
}
});
return commentsTracks;
};
const LeftSideBar = ComponentPlugin('leftSideBar'); const LeftSideBar = ComponentPlugin('leftSideBar');
const MainMenuToolBar = ComponentPlugin('mainMenuToolBar'); const MainMenuToolBar = ComponentPlugin('mainMenuToolBar');
const NotesArea = ComponentPlugin('notesArea'); const NotesArea = ComponentPlugin('notesArea');
...@@ -215,8 +236,9 @@ const EditoriaLayout = ({ editor }) => { ...@@ -215,8 +236,9 @@ const EditoriaLayout = ({ editor }) => {
zIndex: '99999', zIndex: '99999',
}; };
} }
const notes = main && getNotes(main); const notes = main && getNotes(main);
const commentsTracks = main && getCommentsTracks(main).length;
console.log('comments', commentsTracks);
const areNotes = notes && !!notes.length && notes.length > 0; const areNotes = notes && !!notes.length && notes.length > 0;
const [hasNotes, setHasNotes] = useState(areNotes); const [hasNotes, setHasNotes] = useState(areNotes);
...@@ -258,7 +280,7 @@ const EditoriaLayout = ({ editor }) => { ...@@ -258,7 +280,7 @@ const EditoriaLayout = ({ editor }) => {
<CommentsContainer> <CommentsContainer>
<CommentTrackTools> <CommentTrackTools>
<span> <span>
58 COMMENTS AND SUGGESTIONS {commentsTracks} COMMENTS AND SUGGESTIONS
<CommentTrackToolBar /> <CommentTrackToolBar />
</span> </span>
</CommentTrackTools> </CommentTrackTools>
......
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