diff --git a/editors/demo/src/Editoria/config/config.js b/editors/demo/src/Editoria/config/config.js index 50a91f81372522ed4cc8bf93082105b89ea401c7..7a274eb97c412a70fd8b986451da68ec18041228 100644 --- a/editors/demo/src/Editoria/config/config.js +++ b/editors/demo/src/Editoria/config/config.js @@ -61,13 +61,17 @@ async function DummyPromise(userInput) { } const updateTitle = debounce(title => { - console.log(title); + // console.log(title); }, 100); const getComments = debounce(comments => { - // console.log(comments); + console.log(comments); }, 2000); +const setComments = (comments = []) => { + return comments; +}; + const saveTags = tags => { // console.log(tags); }; @@ -167,6 +171,7 @@ export default { CommentsService: { showTitle: true, getComments, + setComments, }, CustomTagService: { diff --git a/wax-prosemirror-services/src/CommentsService/CommentsService.js b/wax-prosemirror-services/src/CommentsService/CommentsService.js index dedf6d5bf6acafd2469242774c724b0d3c189b9f..f787157ce9479e8c052c57024e3012a1cf370433 100644 --- a/wax-prosemirror-services/src/CommentsService/CommentsService.js +++ b/wax-prosemirror-services/src/CommentsService/CommentsService.js @@ -24,6 +24,15 @@ export default class CommentsService extends Service { const options = { styles: {}, + existingComments: () => { + const map = new Map(); + if (commentsConfig.setComments().length > 0) { + commentsConfig.setComments().forEach(value => { + map.set(value.id, value); + }); + } + return map; + }, onSelectionChange: items => { this.allCommentsFromStates = this.allCommentsFromStates.filter( comm => diff --git a/wax-prosemirror-services/src/CommentsService/components/ConnectedComment.js b/wax-prosemirror-services/src/CommentsService/components/ConnectedComment.js index 92e95ca40064a199c0c46de0b57c8d634593ecf4..82175d04314252188c0b75b0cb122642a5ea614a 100644 --- a/wax-prosemirror-services/src/CommentsService/components/ConnectedComment.js +++ b/wax-prosemirror-services/src/CommentsService/components/ConnectedComment.js @@ -2,9 +2,8 @@ /* eslint react/prop-types: 0 */ import React, { useContext, useMemo, useState, useEffect } from 'react'; import { TextSelection } from 'prosemirror-state'; -import { last, maxBy, minBy } from 'lodash'; import styled from 'styled-components'; -import { WaxContext, DocumentHelpers, Commands } from 'wax-prosemirror-core'; +import { WaxContext } from 'wax-prosemirror-core'; import { override } from '@pubsweet/ui-toolkit'; import CommentBox from './ui/comments/CommentBox'; import { AnnotationPluginKey } from '../plugins/AnnotationPlugin'; diff --git a/wax-prosemirror-services/src/CommentsService/plugins/AnnotationPlugin.js b/wax-prosemirror-services/src/CommentsService/plugins/AnnotationPlugin.js index f5212ec8b28219da207c6242c2ff74137a9a0e74..27fdb670ec0d92e1c5c0dc109fe0831561b7b6fd 100644 --- a/wax-prosemirror-services/src/CommentsService/plugins/AnnotationPlugin.js +++ b/wax-prosemirror-services/src/CommentsService/plugins/AnnotationPlugin.js @@ -12,7 +12,7 @@ export const AnnotationPlugin = (name, options) => { init() { return new AnnotationState({ styles: options.styles, - map: new Map(), + map: options.existingComments(), instance: options.instance, onAnnotationListChange: options.onAnnotationListChange, onSelectionChange: options.onSelectionChange,