From 8f98e4874863651193eb8b8467f2b224a87ac206 Mon Sep 17 00:00:00 2001
From: chris <kokosias@yahoo.gr>
Date: Mon, 30 Mar 2020 12:18:44 +0300
Subject: [PATCH] find inline comments in the whole document

---
 .../src/components/comments/CommentBox.js     | 19 ++++++++++++++++---
 .../components/comments/CommentComponent.js   |  6 +++++-
 .../src/layouts/EditoriaLayout.js             |  2 +-
 .../src/document/DocumentHelpers.js           |  7 ++++++-
 4 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/wax-prosemirror-components/src/components/comments/CommentBox.js b/wax-prosemirror-components/src/components/comments/CommentBox.js
index 1a9d277b7..32e0042cb 100644
--- a/wax-prosemirror-components/src/components/comments/CommentBox.js
+++ b/wax-prosemirror-components/src/components/comments/CommentBox.js
@@ -1,5 +1,18 @@
 import React, { useEffect, useRef, useContext } from "react";
+import styled from "styled-components";
 
-export default ({ node, view }) => {
-  useEffect(() => {}, []);
-};
+// export default ({ node, view }) => {
+//   useEffect(() => {}, []);
+// };
+
+const CommentBoxStyled = styled.div`
+  height: 50px;
+  width: 50px;
+  display: flex;
+  flex-direction: column;
+  margin-top: 10px;
+  background: black;
+`;
+
+const CommentBox = () => <CommentBoxStyled />;
+export default CommentBox;
diff --git a/wax-prosemirror-components/src/components/comments/CommentComponent.js b/wax-prosemirror-components/src/components/comments/CommentComponent.js
index 84fb9e2ae..fc821ab55 100644
--- a/wax-prosemirror-components/src/components/comments/CommentComponent.js
+++ b/wax-prosemirror-components/src/components/comments/CommentComponent.js
@@ -30,7 +30,11 @@ export default () => {
 
 const updateComments = view => {
   if (view) {
-    // TODO find comments
+    return DocumentHelpers.findChildrenByMark(
+      view.state.doc,
+      view.state.schema.marks.comment,
+      true
+    );
   }
   return [];
 };
diff --git a/wax-prosemirror-layouts/src/layouts/EditoriaLayout.js b/wax-prosemirror-layouts/src/layouts/EditoriaLayout.js
index bba95b426..1a8b9931e 100644
--- a/wax-prosemirror-layouts/src/layouts/EditoriaLayout.js
+++ b/wax-prosemirror-layouts/src/layouts/EditoriaLayout.js
@@ -171,7 +171,7 @@ const NotesContainer = styled.div`
 
 const CommentsContainer = styled.div`
   display: flex;
-  flex-direction: row;
+  flex-direction: column;
   width: 35%;
   height: 100%;
 `;
diff --git a/wax-prosemirror-utilities/src/document/DocumentHelpers.js b/wax-prosemirror-utilities/src/document/DocumentHelpers.js
index 36fedfeb1..62af5f2b1 100644
--- a/wax-prosemirror-utilities/src/document/DocumentHelpers.js
+++ b/wax-prosemirror-utilities/src/document/DocumentHelpers.js
@@ -55,9 +55,14 @@ const findInlineNodes = (node, descend) => {
   return findChildren(node, child => child.isInline, descend);
 };
 
+const findChildrenByMark = (node, markType, descend) => {
+  return findChildren(node, child => markType.isInSet(child.marks), descend);
+};
+
 export default {
   findMark,
   findBlockNodes,
   findChildrenByType,
-  findInlineNodes
+  findInlineNodes,
+  findChildrenByMark
 };
-- 
GitLab