diff --git a/wax-prosemirror-services/src/CommentsService/plugins/CommentState.js b/wax-prosemirror-services/src/CommentsService/plugins/CommentState.js index 5637ce6e05af36c99630ea31bf3403798ede61f4..8d78ee54e19ca7f97b9296d315ce448c24b82415 100644 --- a/wax-prosemirror-services/src/CommentsService/plugins/CommentState.js +++ b/wax-prosemirror-services/src/CommentsService/plugins/CommentState.js @@ -203,11 +203,6 @@ export default class CommentState { const ystate = ySyncPluginKey.getState(state); - this.decorations = this.decorations.map( - transaction.mapping, - transaction.doc, - ); - if (ystate?.isChangeOrigin) { this.updateCommentPostions(ystate); this.createDecorations(state); @@ -215,6 +210,20 @@ export default class CommentState { return this; } + this.decorations = this.decorations.map( + transaction.mapping, + transaction.doc, + ); + + map.forEach((annotation, _) => { + if ('from' in annotation && 'to' in annotation) { + annotation.data.pmFrom = transaction.mapping.map( + annotation.data.pmFrom, + ); + annotation.data.pmTo = transaction.mapping.map(annotation.data.pmTo); + } + }); + if (ystate?.binding && ystate?.binding.mapping) { this.updateCommentPostions(ystate); this.createDecorations(state);