From 046d11527e4066e6e1dd82b46dc4b5f7ddf8aff0 Mon Sep 17 00:00:00 2001
From: chris <kokosias@yahoo.gr>
Date: Wed, 28 Feb 2024 16:59:48 +0200
Subject: [PATCH] get comments list to config

---
 editors/demo/src/Editoria/config/config.js                 | 7 +++++++
 .../src/CommentsService/CommentsService.js                 | 4 +++-
 .../src/CommentsService/plugins/AnnotationState.js         | 1 -
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/editors/demo/src/Editoria/config/config.js b/editors/demo/src/Editoria/config/config.js
index a3d88270d..ccb479884 100644
--- a/editors/demo/src/Editoria/config/config.js
+++ b/editors/demo/src/Editoria/config/config.js
@@ -64,6 +64,10 @@ const updateTitle = debounce(title => {
   console.log(title);
 }, 100);
 
+const getComments = debounce(comments => {
+  console.log(comments);
+}, 100);
+
 const saveTags = tags => {
   // console.log(tags);
 };
@@ -159,9 +163,12 @@ export default {
     ),
   ],
   ImageService: { showAlt: true },
+
   CommentsService: {
     showTitle: true,
+    getComments,
   },
+
   CustomTagService: {
     tags: [
       { label: 'custom-tag-label-1', tagType: 'inline' },
diff --git a/wax-prosemirror-services/src/CommentsService/CommentsService.js b/wax-prosemirror-services/src/CommentsService/CommentsService.js
index e58bf9a11..5a6454014 100644
--- a/wax-prosemirror-services/src/CommentsService/CommentsService.js
+++ b/wax-prosemirror-services/src/CommentsService/CommentsService.js
@@ -11,6 +11,8 @@ const PLUGIN_KEY = 'commentPlugin';
 
 export default class CommentsService extends Service {
   boot() {
+    const commentsConfig = this.app.config.get('config.CommentsService');
+    console.log(commentsConfig);
     this.app.PmPlugins.add(PLUGIN_KEY, CommentPlugin(PLUGIN_KEY));
     this.app.PmPlugins.add(
       'copyPasteCommentPlugin',
@@ -19,7 +21,7 @@ export default class CommentsService extends Service {
 
     const options = {
       styles: {},
-      onSelectionChange: items => console.log(items),
+      onSelectionChange: items => commentsConfig.getComments(items),
       onAnnotationListChange: () => true,
       document: '',
       field: 'annotations',
diff --git a/wax-prosemirror-services/src/CommentsService/plugins/AnnotationState.js b/wax-prosemirror-services/src/CommentsService/plugins/AnnotationState.js
index 2d2cae12b..5632de31b 100644
--- a/wax-prosemirror-services/src/CommentsService/plugins/AnnotationState.js
+++ b/wax-prosemirror-services/src/CommentsService/plugins/AnnotationState.js
@@ -154,7 +154,6 @@ export default class AnnotationState {
     }
     // manually map annotation positions
     this.options.map.forEach((annotation, _) => {
-      console.log(this.decorations);
       if ('from' in annotation && 'to' in annotation) {
         annotation.from = transaction.mapping.map(annotation.from);
         annotation.to = transaction.mapping.map(annotation.to);
-- 
GitLab