From 21b1bde8387ec79a305b12df0c7099ec2dac104c Mon Sep 17 00:00:00 2001 From: chris <kokosias@yahoo.gr> Date: Thu, 18 Apr 2024 18:34:18 +0300 Subject: [PATCH] remove comment from surface Yjs --- editors/demo/src/Editoria/Editoria.js | 2 +- editors/demo/src/Editoria/config/config.js | 14 +++++++------- .../src/CommentsService/components/RightArea.js | 17 +++++++++++++++-- .../src/CommentsService/plugins/CommentState.js | 1 + 4 files changed, 24 insertions(+), 10 deletions(-) diff --git a/editors/demo/src/Editoria/Editoria.js b/editors/demo/src/Editoria/Editoria.js index 8837b278e..3e85568ea 100644 --- a/editors/demo/src/Editoria/Editoria.js +++ b/editors/demo/src/Editoria/Editoria.js @@ -55,7 +55,7 @@ const Editoria = () => { autoFocus placeholder="Type Something..." fileUpload={file => renderImage(file)} - value={demo} + // value={demo} // readonly layout={layout} // onChange={debounce(source => { diff --git a/editors/demo/src/Editoria/config/config.js b/editors/demo/src/Editoria/config/config.js index bfde4d975..fcabb1309 100644 --- a/editors/demo/src/Editoria/config/config.js +++ b/editors/demo/src/Editoria/config/config.js @@ -77,8 +77,8 @@ const setComments = ( to: 10, data: { type: 'comment', - yjsTo: 10, yjsFrom: 5, + yjsTo: 10, conversation: [ { content: '1111', @@ -231,11 +231,11 @@ export default { ], updateTags: saveTags, }, - // YjsService: { - // // eslint-disable-next-line no-restricted-globals - // connectionUrl: 'ws://localhost:4000', - // docIdentifier: 'prosemirror-demo', - // }, + YjsService: { + // eslint-disable-next-line no-restricted-globals + connectionUrl: 'ws://localhost:4000', + docIdentifier: 'prosemirror-demo', + }, AskAiContentService: { AskAiContentTransformation: DummyPromise, @@ -243,7 +243,7 @@ export default { }, services: [ - // new YjsService(), + new YjsService(), new BlockDropDownToolGroupService(), new AskAiContentService(), new CustomTagService(), diff --git a/wax-prosemirror-services/src/CommentsService/components/RightArea.js b/wax-prosemirror-services/src/CommentsService/components/RightArea.js index 923525246..2c2eec555 100644 --- a/wax-prosemirror-services/src/CommentsService/components/RightArea.js +++ b/wax-prosemirror-services/src/CommentsService/components/RightArea.js @@ -14,7 +14,7 @@ export default ({ area, users }) => { pmViews: { main }, app, activeView, - options: { comments }, + options: { comments, commentsMap }, } = context; const commentPlugin = app.PmPlugins.get('commentPlugin'); @@ -80,7 +80,7 @@ export default ({ area, users }) => { markNodeEl.getBoundingClientRect().top - WaxSurface.top + parseInt(WaxSurfaceMarginTop.slice(0, -2), 10); - } else { + } else if (!isFirstRun) { // comment is deleted from editing surface context.setOption({ resolvedComment: id }); context.setOption({ @@ -96,6 +96,19 @@ export default ({ area, users }) => { id, }), ); + + if (context.app.config.get('config.YjsService')) { + commentsMap.observe(() => { + const transaction = context.pmViews.main.state.tr.setMeta( + CommentDecorationPluginKey, + { + type: 'createDecorations', + }, + ); + + context.pmViews.main.dispatch(transaction); + }); + } }); } } else { diff --git a/wax-prosemirror-services/src/CommentsService/plugins/CommentState.js b/wax-prosemirror-services/src/CommentsService/plugins/CommentState.js index 790cc86f8..02ce2d3f1 100644 --- a/wax-prosemirror-services/src/CommentsService/plugins/CommentState.js +++ b/wax-prosemirror-services/src/CommentsService/plugins/CommentState.js @@ -155,6 +155,7 @@ export default class CommentState { ); const annotation = this.options.map.get(id); + annotation.from = newFrom; annotation.to = newTo; -- GitLab