diff --git a/editors/demo/src/Editoria/config/config.js b/editors/demo/src/Editoria/config/config.js index c8c829d265d8ed42d1c8509b4ce58198b508fcc3..d4adf4c89b5c65738527320ab2a780e56d9cc92d 100644 --- a/editors/demo/src/Editoria/config/config.js +++ b/editors/demo/src/Editoria/config/config.js @@ -306,7 +306,7 @@ export default { // eslint-disable-next-line no-restricted-globals connectionUrl: 'ws://localhost:5010', // connectionUrl: 'ws://0.tcp.ap.ngrok.io:17607', - docIdentifier: 'prosemirror-rweedxefe5dc', + docIdentifier: 'prosemirror-rweedxrefe5dc', YjsType: 'prosemirror', }, diff --git a/wax-prosemirror-services/src/CommentsService/plugins/CommentState.js b/wax-prosemirror-services/src/CommentsService/plugins/CommentState.js index 8d78ee54e19ca7f97b9296d315ce448c24b82415..969ed679c8c73f547599acc35a3e7beaabf612b7 100644 --- a/wax-prosemirror-services/src/CommentsService/plugins/CommentState.js +++ b/wax-prosemirror-services/src/CommentsService/plugins/CommentState.js @@ -69,21 +69,17 @@ export default class CommentState { if (ystate?.binding) { const { doc, type, binding } = ystate; this.allCommentsList().forEach((annotation, id) => { - if (typeof annotation.data.yjsFrom !== 'object') { - annotation.data.yjsFrom = absolutePositionToRelativePosition( - annotation.data.pmFrom, - type, - binding.mapping, - ); - } + annotation.data.yjsFrom = absolutePositionToRelativePosition( + annotation.data.pmFrom, + type, + binding.mapping, + ); - if (typeof annotation.data.yjsTo !== 'object') { - annotation.data.yjsTo = absolutePositionToRelativePosition( - annotation.data.pmTo, - type, - binding.mapping, - ); - } + annotation.data.yjsTo = absolutePositionToRelativePosition( + annotation.data.pmTo, + type, + binding.mapping, + ); const from = relativePositionToAbsolutePosition( doc, @@ -198,13 +194,14 @@ export default class CommentState { if (action.type === 'createDecorations') { this.createDecorations(state); } + // this.createDecorations(state); return this; } const ystate = ySyncPluginKey.getState(state); if (ystate?.isChangeOrigin) { - this.updateCommentPostions(ystate); + // this.updateCommentPostions(ystate); this.createDecorations(state); return this; @@ -226,17 +223,13 @@ export default class CommentState { if (ystate?.binding && ystate?.binding.mapping) { this.updateCommentPostions(ystate); - this.createDecorations(state); return this; // eslint-disable-next-line no-else-return } else { - // Not YJS - map.forEach((annotation, _) => { + this.options.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); + annotation.from = transaction.mapping.map(annotation.from); + annotation.to = transaction.mapping.map(annotation.to); } }); this.createDecorations(state);