From 871fa9a68b30bb120c4783b908451923c84a03a9 Mon Sep 17 00:00:00 2001 From: chris <kokosias@yahoo.gr> Date: Wed, 20 Mar 2024 11:25:12 +0200 Subject: [PATCH] resolve comment --- editors/demo/src/Editoria/config/config.js | 1 + wax-prosemirror-services/index.js | 6 +++++- .../src/CommentsService/CommentsService.js | 8 +++++++- .../CommentsService/components/ConnectedComment.js | 11 +++-------- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/editors/demo/src/Editoria/config/config.js b/editors/demo/src/Editoria/config/config.js index 31bc56977..35325a79d 100644 --- a/editors/demo/src/Editoria/config/config.js +++ b/editors/demo/src/Editoria/config/config.js @@ -27,6 +27,7 @@ import { BlockDropDownToolGroupService, AskAiContentService, // YjsService, + CommentDecoration, } from 'wax-prosemirror-services'; import { TablesService, tableEditing, columnResizing } from 'wax-table-service'; diff --git a/wax-prosemirror-services/index.js b/wax-prosemirror-services/index.js index 95b5a5596..32f70e7d1 100644 --- a/wax-prosemirror-services/index.js +++ b/wax-prosemirror-services/index.js @@ -36,6 +36,10 @@ ToolGroups */ export { default as DisplayTextToolGroupService } from './src/WaxToolGroups/DisplayTextToolGroupService/DisplayTextToolGroupService'; export { default as BlockDropDownToolGroupService } from './src/WaxToolGroups/BlockDropDownToolGroupService/BlockDropDownToolGroupService'; -/* Plugins */ +/* Plugins */ export { default as disallowPasteImagesPlugin } from './src/ImageService/plugins/disallowPasteImagesPlugin'; +export { + CommentDecorationPlugin, + CommentDecorationPluginKey, +} from './src/CommentsService/plugins/CommentDecorationPlugin'; diff --git a/wax-prosemirror-services/src/CommentsService/CommentsService.js b/wax-prosemirror-services/src/CommentsService/CommentsService.js index 826da5abe..1a732f086 100644 --- a/wax-prosemirror-services/src/CommentsService/CommentsService.js +++ b/wax-prosemirror-services/src/CommentsService/CommentsService.js @@ -40,7 +40,13 @@ export default class CommentsService extends Service { ...items, ]); commentsConfig.getComments(this.allCommentsFromStates); - + if (this.app.context.options.resolvedComment) { + this.allCommentsFromStates = this.allCommentsFromStates.filter( + comm => { + return comm.id !== this.app.context.options.resolvedComment; + }, + ); + } this.app.context.setOption({ comments: this.allCommentsFromStates }); }, }; diff --git a/wax-prosemirror-services/src/CommentsService/components/ConnectedComment.js b/wax-prosemirror-services/src/CommentsService/components/ConnectedComment.js index bf7ad252f..ee0ee2baa 100644 --- a/wax-prosemirror-services/src/CommentsService/components/ConnectedComment.js +++ b/wax-prosemirror-services/src/CommentsService/components/ConnectedComment.js @@ -106,21 +106,16 @@ export default ({ comment, top, commentId, recalculateTops, users }) => { }; const onClickResolve = () => { + context.setOption({ resolvedComment: activeComment.id }); dispatch( state.tr.setMeta(CommentDecorationPluginKey, { type: 'deleteComment', id: activeComment.id, }), ); - // recalculateTops(); + + dispatch(state.tr); activeView.focus(); - setTimeout(() => { - const newComments = comments.filter(comm => { - return comm.id !== activeComment.id; - }); - context.setOption({ comments: newComments }); - dispatch(state.tr); - }); }; const onTextAreaBlur = () => { -- GitLab