From f44a94d68d080b2781af85d95798d230aa863254 Mon Sep 17 00:00:00 2001 From: chris <kokosias@yahoo.gr> Date: Sun, 21 Apr 2024 14:44:20 +0300 Subject: [PATCH] fix yjs position from config --- editors/demo/src/Editoria/config/config.js | 68 +++++++++++++++++++ .../CommentsService/components/RightArea.js | 2 +- .../CommentsService/plugins/CommentState.js | 28 ++++---- 3 files changed, 82 insertions(+), 16 deletions(-) diff --git a/editors/demo/src/Editoria/config/config.js b/editors/demo/src/Editoria/config/config.js index 636a4101b..e643d4530 100644 --- a/editors/demo/src/Editoria/config/config.js +++ b/editors/demo/src/Editoria/config/config.js @@ -119,6 +119,74 @@ const setComments = ( }, endHeight: 266.3579406738281, }, + { + id: 'b8d907d4-1859-49a9-abcd-13788d497758', + from: { + type: { + client: 2887320119, + clock: 150, + }, + tname: null, + item: { + client: 2887320119, + clock: 185, + }, + assoc: 0, + }, + to: { + type: { + client: 2887320119, + clock: 150, + }, + tname: null, + item: { + client: 2887320119, + clock: 195, + }, + assoc: 0, + }, + data: { + yjsFrom: { + type: { + client: 2887320119, + clock: 150, + }, + tname: null, + item: { + client: 2887320119, + clock: 185, + }, + assoc: 0, + }, + yjsTo: { + type: { + client: 2887320119, + clock: 150, + }, + tname: null, + item: { + client: 2887320119, + clock: 195, + }, + assoc: 0, + }, + pmFrom: 164, + pmTo: 174, + type: 'comment', + conversation: [ + { + content: 'dfgdfgd', + displayName: 'admin', + userId: 'b3cfc28e-0f2e-45b5-b505-e66783d4f946', + timestamp: 1713699155995, + }, + ], + title: 'dgfdgf', + group: 'main', + viewId: 'main', + }, + endHeight: 406.734375, + }, ], ) => { return comments; diff --git a/wax-prosemirror-services/src/CommentsService/components/RightArea.js b/wax-prosemirror-services/src/CommentsService/components/RightArea.js index 81907dd0b..d62b3c771 100644 --- a/wax-prosemirror-services/src/CommentsService/components/RightArea.js +++ b/wax-prosemirror-services/src/CommentsService/components/RightArea.js @@ -287,7 +287,7 @@ const updateMarks = (views, comments) => { groupedMarkNodes.notes = groupedMarkNodes.notes.concat(newComments.notes); return { - main: sortBy(groupedMarkNodes.main, ['from']), + main: sortBy(groupedMarkNodes.main, ['data.pmFrom']), notes: groupedMarkNodes.notes, }; } diff --git a/wax-prosemirror-services/src/CommentsService/plugins/CommentState.js b/wax-prosemirror-services/src/CommentsService/plugins/CommentState.js index 5697fcaf2..314d202ac 100644 --- a/wax-prosemirror-services/src/CommentsService/plugins/CommentState.js +++ b/wax-prosemirror-services/src/CommentsService/plugins/CommentState.js @@ -61,22 +61,20 @@ export default class CommentState { if (ystate?.binding) { const { doc, type, binding } = ystate; - + console.log(this.allCommentsList()); this.allCommentsList().forEach((annotation, id) => { - if (typeof annotation.data.yjsFrom === 'number') { - annotation.data.yjsFrom = absolutePositionToRelativePosition( - annotation.data.yjsFrom, - type, - binding.mapping, - ); - } - if (typeof annotation.data.yjsTo === 'number') { - annotation.data.yjsTo = absolutePositionToRelativePosition( - annotation.data.yjsTo, - type, - binding.mapping, - ); - } + annotation.data.yjsFrom = absolutePositionToRelativePosition( + annotation.data.pmFrom, + type, + binding.mapping, + ); + + annotation.data.yjsTo = absolutePositionToRelativePosition( + annotation.data.pmTo, + type, + binding.mapping, + ); + const from = relativePositionToAbsolutePosition( doc, type, -- GitLab