Skip to content
Snippets Groups Projects
Commit 36e631cb authored by chris's avatar chris
Browse files

comment deco plugin

parent 7698c4b1
No related branches found
No related tags found
2 merge requests!548Merge yjs with standard comments,!545Overlapping comments
......@@ -4,7 +4,7 @@ import RightArea from './components/RightArea';
import commentMark from './schema/commentMark';
import CommentPlugin from './plugins/CommentPlugin';
// import CopyPasteCommentPlugin from './plugins/CopyPasteCommentPlugin';
import { AnnotationPlugin } from './plugins/AnnotationPlugin';
import { CommentDecorationPlugin } from './plugins/CommentDecorationPlugin';
import './comments.css';
export default class CommentsService extends Service {
......@@ -46,8 +46,8 @@ export default class CommentsService extends Service {
};
this.app.PmPlugins.add(
'AnnotationPlugin',
AnnotationPlugin('AnnotationPlugin', options),
'CommentDecorationPlugin',
CommentDecorationPlugin('commentDecorationPlugin', options),
);
const createOverlay = this.container.get('CreateOverlay');
......
......@@ -6,7 +6,7 @@ import styled from 'styled-components';
import { WaxContext } from 'wax-prosemirror-core';
import { override } from '@pubsweet/ui-toolkit';
import CommentBox from './ui/comments/CommentBox';
import { AnnotationPluginKey } from '../plugins/AnnotationPlugin';
import { CommentDecorationPluginKey } from '../plugins/CommentDecorationPlugin';
const ConnectedCommentStyled = styled.div`
margin-left: ${props => (props.active ? `${-20}px` : `${50}px`)};
......@@ -78,7 +78,7 @@ export default ({ comment, top, commentId, recalculateTops, users }) => {
comment.data.conversation.push(obj);
dispatch(
state.tr.setMeta(AnnotationPluginKey, {
state.tr.setMeta(CommentDecorationPluginKey, {
type: 'updateComment',
id: activeComment.id,
data: comment.data,
......@@ -107,7 +107,7 @@ export default ({ comment, top, commentId, recalculateTops, users }) => {
const onClickResolve = () => {
dispatch(
state.tr.setMeta(AnnotationPluginKey, {
state.tr.setMeta(CommentDecorationPluginKey, {
type: 'deleteComment',
id: activeComment.id,
}),
......
......@@ -2,7 +2,7 @@
import React, { useLayoutEffect, useContext } from 'react';
import { WaxContext } from 'wax-prosemirror-core';
import CommentBubble from './CommentBubble';
import { AnnotationPluginKey } from '../../../plugins/AnnotationPlugin';
import { CommentDecorationPluginKey } from '../../../plugins/CommentDecorationPlugin';
const CommentBubbleComponent = ({ setPosition, position, group }) => {
const {
......@@ -30,7 +30,7 @@ const CommentBubbleComponent = ({ setPosition, position, group }) => {
const { selection } = state;
dispatch(
state.tr.setMeta(AnnotationPluginKey, {
state.tr.setMeta(CommentDecorationPluginKey, {
type: 'addComment',
from: selection.from,
to: selection.to,
......
......@@ -4,10 +4,12 @@ import CommentState from './CommentState';
let contentSize = 0;
let allCommentsCount = 0;
export const AnnotationPluginKey = new PluginKey('annotationPlugin');
export const AnnotationPlugin = (name, options) => {
export const CommentDecorationPluginKey = new PluginKey(
'commentDecorationPlugin',
);
export const CommentDecorationPlugin = (name, options) => {
return new Plugin({
key: AnnotationPluginKey,
key: CommentDecorationPluginKey,
state: {
init() {
return new CommentState({
......
......@@ -2,7 +2,7 @@
import { v4 as uuidv4 } from 'uuid';
import { Decoration, DecorationSet } from 'prosemirror-view';
import CommentDecoration from './CommentDecoration';
import { AnnotationPluginKey } from './AnnotationPlugin';
import { CommentDecorationPluginKey } from './CommentDecorationPlugin';
const randomId = () => {
return uuidv4();
......@@ -88,7 +88,7 @@ export default class CommentState {
}
apply(transaction, state) {
const action = transaction.getMeta(AnnotationPluginKey);
const action = transaction.getMeta(CommentDecorationPluginKey);
if (action && action.type) {
if (action.type === 'addComment') {
this.addComment(action);
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment