@manuscripts/article-editor 3.4.7 → 3.4.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/cjs/components/comments/CommentActions.js +11 -7
  2. package/dist/cjs/components/comments/CommentActions.js.map +1 -1
  3. package/dist/cjs/components/comments/CommentBody.js +11 -7
  4. package/dist/cjs/components/comments/CommentBody.js.map +1 -1
  5. package/dist/cjs/components/comments/CommentCard.js +163 -0
  6. package/dist/cjs/components/comments/CommentCard.js.map +1 -0
  7. package/dist/cjs/components/comments/CommentResolveButton.js +1 -1
  8. package/dist/cjs/components/comments/CommentThread.js +88 -88
  9. package/dist/cjs/components/comments/CommentThread.js.map +1 -1
  10. package/dist/cjs/components/comments/CommentsPanel.js +45 -10
  11. package/dist/cjs/components/comments/CommentsPanel.js.map +1 -1
  12. package/dist/cjs/components/comments/DeleteCommentConfirmation.js +115 -0
  13. package/dist/cjs/components/comments/DeleteCommentConfirmation.js.map +1 -0
  14. package/dist/cjs/components/comments/ReplyBox.js +121 -0
  15. package/dist/cjs/components/comments/ReplyBox.js.map +1 -0
  16. package/dist/cjs/lib/comments.js +26 -5
  17. package/dist/cjs/lib/comments.js.map +1 -1
  18. package/dist/es/components/comments/CommentActions.js +11 -7
  19. package/dist/es/components/comments/CommentActions.js.map +1 -1
  20. package/dist/es/components/comments/CommentBody.js +12 -8
  21. package/dist/es/components/comments/CommentBody.js.map +1 -1
  22. package/dist/es/components/comments/CommentCard.js +133 -0
  23. package/dist/es/components/comments/CommentCard.js.map +1 -0
  24. package/dist/es/components/comments/CommentResolveButton.js +1 -1
  25. package/dist/es/components/comments/CommentThread.js +91 -91
  26. package/dist/es/components/comments/CommentThread.js.map +1 -1
  27. package/dist/es/components/comments/CommentsPanel.js +47 -12
  28. package/dist/es/components/comments/CommentsPanel.js.map +1 -1
  29. package/dist/es/components/comments/DeleteCommentConfirmation.js +85 -0
  30. package/dist/es/components/comments/DeleteCommentConfirmation.js.map +1 -0
  31. package/dist/es/components/comments/ReplyBox.js +91 -0
  32. package/dist/es/components/comments/ReplyBox.js.map +1 -0
  33. package/dist/es/lib/comments.js +23 -3
  34. package/dist/es/lib/comments.js.map +1 -1
  35. package/dist/types/components/comments/CommentBody.d.ts +0 -1
  36. package/dist/types/components/comments/CommentCard.d.ts +26 -0
  37. package/dist/types/components/comments/CommentThread.d.ts +3 -2
  38. package/dist/types/components/comments/DeleteCommentConfirmation.d.ts +19 -0
  39. package/dist/types/components/comments/ReplyBox.d.ts +18 -0
  40. package/dist/types/lib/comments.d.ts +4 -3
  41. package/package.json +1 -1
@@ -1,105 +1,105 @@
1
- import { AvatarIcon, RelativeDate, SystemUserAvatarIcon, usePermissions, } from '@manuscripts/style-guide';
2
- import React, { forwardRef, useState } from 'react';
1
+ import { TextButton, usePermissions } from '@manuscripts/style-guide';
2
+ import React, { forwardRef, useEffect, useRef, useState } from 'react';
3
3
  import styled from 'styled-components';
4
- import { buildAuthorName, getAuthorID } from '../../lib/comments';
5
- import { useStore } from '../../store';
6
- import { CommentActions } from './CommentActions';
7
- import { CommentBody } from './CommentBody';
4
+ import { commentsByTime } from '../../lib/comments';
5
+ import { CommentCard } from './CommentCard';
6
+ import { ReplyBox } from './ReplyBox';
8
7
  const Container = styled.div `
9
- padding: 16px;
10
- background-color: ${(props) => (props.isSelected ? '#f2fbfc' : '#ffffff')};
11
- border: 1px solid ${(props) => (props.isSelected ? '#bce7f6' : '#e2e2e2')};
12
- border-left-width: 4px;
8
+ padding: 8px;
9
+ background-color: ${(props) => (props.isSelected ? '#fff' : '#fafafa')};
10
+ border: 1px solid #c9c9c9;
11
+ ${(props) => props.isSelected && 'border-left-width: 4px'};
12
+ border-radius: 4px;
13
13
  margin-bottom: 16px;
14
- `;
15
- const CommentHeader = styled.div `
16
- display: flex;
17
- margin-bottom: 16px;
18
- `;
19
- const CommentMetadata = styled.div `
20
- flex: 1;
21
- padding-left: 8px;
22
- padding-right: 8px;
23
- `;
24
- const CommentAuthor = styled.div `
25
- display: flex;
26
- color: #353535;
27
- font-weight: 400;
28
- max-width: 200px;
29
- white-space: nowrap;
30
- overflow: hidden;
31
- text-overflow: ellipsis;
32
- width: 100%;
14
+ margin-left: 12px;
15
+ margin-right: 12px;
16
+ cursor: pointer;
17
+ .actions-icon {
18
+ visibility: ${(props) => (props.isSelected ? 'visible' : 'hidden')};
19
+ }
33
20
 
34
- svg {
35
- padding-right: 10px;
21
+ &:hover {
22
+ background-color: #fff;
23
+
24
+ .actions-icon {
25
+ visibility: visible;
26
+ }
36
27
  }
37
28
  `;
38
- const CommentTarget = styled.div `
39
- font-size: 14px;
40
- color: #353535;
41
- background-color: #ffeebf;
42
- padding: 4px 8px;
43
- margin-top: 16px;
44
- margin-bottom: 16px;
29
+ const SeparatorLine = styled.div `
30
+ margin-bottom: 8px;
31
+ background-color: #c9c9c9;
32
+ height: 1px;
45
33
  `;
46
- const Timestamp = styled(RelativeDate) `
47
- font-size: 12px;
48
- line-height: 16px;
49
- font-weight: 400;
50
- color: #6e6e6e;
34
+ const Indented = styled.div `
35
+ padding-left: 16px;
51
36
  `;
52
37
  export const CommentThread = forwardRef((props, ref) => {
53
- const { tree, isSelected, onSelect, onSave, onDelete } = props;
38
+ const { thread, isSelected, onSelect, onSave, onDelete, insertCommentReply, } = props;
54
39
  const can = usePermissions();
55
- const [{ user, collaboratorsById }] = useStore((state) => ({
56
- user: state.user,
57
- collaboratorsById: state.collaboratorsById,
58
- }));
59
- const authorID = getAuthorID(tree.comment);
60
- const authorName = authorID
61
- ? buildAuthorName(collaboratorsById.get(authorID))
62
- : '';
63
- const timestamp = tree.comment.node.attrs.contributions?.[0].timestamp;
64
- const isOwn = authorID === user._id;
65
- const isResolveEnabled = isOwn
66
- ? can.resolveOwnComment
67
- : can.resolveOthersComment;
68
- const isActionsEnabled = isOwn
69
- ? can.handleOwnComments
70
- : can.handleOthersComments;
71
- const [isEditing, setEditing] = useState(tree.isNew);
72
- const handleEdit = () => setEditing(true);
73
- const handleSave = (contents) => {
74
- onSave({
75
- ...tree.comment.node.attrs,
76
- contents,
77
- });
78
- setEditing(false);
79
- };
80
- const handleCancel = () => {
81
- setEditing(false);
82
- if (tree.isNew) {
83
- onDelete(tree.comment.node.attrs.id);
40
+ const { comment, isNew, replies } = thread;
41
+ const cardsRef = useRef(null);
42
+ const [showMore, setShowMore] = useState(false);
43
+ const [editingCommentId, setEditingCommentId] = useState(isNew ? comment.node.attrs.id : null);
44
+ useEffect(() => {
45
+ if (!isSelected) {
46
+ setEditingCommentId(null);
47
+ }
48
+ }, [isSelected]);
49
+ useEffect(() => {
50
+ if (cardsRef.current) {
51
+ const contentHeight = cardsRef.current.scrollHeight;
52
+ setShowMore(contentHeight > 280);
53
+ }
54
+ }, [comment, replies]);
55
+ const handleSelect = () => {
56
+ if (!isSelected) {
57
+ onSelect();
84
58
  }
85
59
  };
86
- const handleToggleResolve = () => {
87
- onSave({
88
- ...tree.comment.node.attrs,
89
- resolved: !tree.comment.node.attrs.resolved,
90
- });
91
- };
92
- return (React.createElement(Container, { "data-cy": "comment", isSelected: isSelected, ref: ref },
93
- React.createElement(CommentHeader, { "data-cy": "comment-header" },
94
- React.createElement(CommentMetadata, null,
95
- React.createElement(CommentAuthor, null, authorName ? (React.createElement(React.Fragment, null,
96
- React.createElement(AvatarIcon, { width: 20, height: 20 }),
97
- React.createElement(CommentAuthor, null, authorName))) : (React.createElement(React.Fragment, null,
98
- React.createElement(SystemUserAvatarIcon, { width: 20, height: 20 }),
99
- React.createElement(CommentAuthor, null, "System")))),
100
- timestamp && React.createElement(Timestamp, { date: timestamp * 1000 })),
101
- React.createElement(CommentActions, { comment: tree.comment, isResolveEnabled: isResolveEnabled, isActionsEnabled: isActionsEnabled, onDelete: () => onDelete(tree.comment.node.attrs.id), onEdit: handleEdit, toggleResolve: handleToggleResolve })),
102
- tree.comment.node.attrs.originalText && (React.createElement(CommentTarget, null, tree.comment.node.attrs.originalText)),
103
- React.createElement(CommentBody, { comment: tree.comment, isEditing: tree.isNew || isEditing, onSave: handleSave, onCancel: handleCancel, onSelect: onSelect })));
60
+ return (React.createElement(Container, { "data-cy": "comment", isSelected: isSelected, ref: ref, onClick: handleSelect },
61
+ React.createElement(CardsWrapper, { ref: cardsRef, isSelected: isSelected, showMore: showMore },
62
+ React.createElement(CommentCard, { comment: comment, isReply: false, numOfReplies: replies.length, isNew: isNew, isEndOfThread: !replies.length, editingCommentId: editingCommentId, setEditingCommentId: setEditingCommentId, onDelete: onDelete, onSave: onSave }),
63
+ replies.sort(commentsByTime).map((reply, index) => {
64
+ return (React.createElement("div", { key: reply.node.attrs.id },
65
+ index === 0 && React.createElement(SeparatorLine, null),
66
+ React.createElement(Indented, null,
67
+ index !== 0 && React.createElement(SeparatorLine, null),
68
+ React.createElement(CommentCard, { comment: reply, isReply: true, numOfReplies: 0, isNew: false, isEndOfThread: index === replies.length - 1, editingCommentId: editingCommentId, setEditingCommentId: setEditingCommentId, onDelete: onDelete, onSave: onSave }))));
69
+ })),
70
+ showMore && !isSelected && (React.createElement(React.Fragment, null,
71
+ React.createElement(SeparatorLine, null),
72
+ React.createElement(ButtonContainer, null,
73
+ React.createElement(ShowMore, { onClick: onSelect }, "Show more")))),
74
+ can.createComment && isSelected && editingCommentId === null && (React.createElement(ReplyBox, { insertCommentReply: insertCommentReply, commentID: comment.node.attrs.id }))));
104
75
  });
76
+ const ButtonContainer = styled.div `
77
+ display: flex;
78
+ justify-content: center;
79
+ align-items: center;
80
+ `;
81
+ const ShowMore = styled(TextButton) `
82
+ cursor: pointer;
83
+ text-align: center;
84
+ margin-top: 6px;
85
+ color: #353535;
86
+ `;
87
+ const CardsWrapper = styled.div `
88
+ max-height: ${({ isSelected }) => (isSelected ? 'none' : '280px')};
89
+ position: relative;
90
+ ${({ showMore, isSelected }) => showMore &&
91
+ !isSelected &&
92
+ `
93
+ overflow: hidden;
94
+ &:after {
95
+ content: '';
96
+ position: absolute;
97
+ bottom: 0;
98
+ left: 0;
99
+ right: 0;
100
+ height: 40px;
101
+ background: linear-gradient(to bottom, rgba(255, 255, 255, 0), rgba(255, 255, 255, 1));
102
+ }
103
+ `}
104
+ `;
105
105
  //# sourceMappingURL=CommentThread.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CommentThread.js","sourceRoot":"","sources":["../../../../src/components/comments/CommentThread.tsx"],"names":[],"mappings":"AAYA,OAAO,EACL,UAAU,EACV,YAAY,EACZ,oBAAoB,EACpB,cAAc,GACf,MAAM,0BAA0B,CAAA;AACjC,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACnD,OAAO,MAAM,MAAM,mBAAmB,CAAA;AAEtC,OAAO,EAAE,eAAe,EAAe,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAC9E,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAE3C,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAA0B;;sBAEhC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC;sBACrD,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC;;;CAG1E,CAAA;AAED,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,CAAA;;;CAG/B,CAAA;AAED,MAAM,eAAe,GAAG,MAAM,CAAC,GAAG,CAAA;;;;CAIjC,CAAA;AAED,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;;;;;;;CAa/B,CAAA;AAED,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;CAO/B,CAAA;AAED,MAAM,SAAS,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CAAC,EAC3C,gBAAgB,EAAE,gBAAgB,EAClC,mBAAmB,EAAE,mBAAmB,EACxC,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,GACd,CACO,CACP,CACP,CAAA;YACH,CAAC,CAAC,CACW;QAEd,QAAQ,IAAI,CAAC,UAAU,IAAI,CAC1B;YACE,oBAAC,aAAa,OAAG;YACjB,oBAAC,eAAe;gBACd,oBAAC,QAAQ,IAAC,OAAO,EAAE,QAAQ,gBAAsB,CACjC,CACjB,CACJ;QACA,GAAG,CAAC,aAAa,IAAI,UAAU,IAAI,gBAAgB,KAAK,IAAI,IAAI,CAC/D,oBAAC,QAAQ,IACP,kBAAkB,EAAE,kBAAkB,EACtC,SAAS,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,GAChC,CACH,CACS,CACb,CAAA;AACH,CAAC,CACF,CAAA;AAED,MAAM,eAAe,GAAG,MAAM,CAAC,GAAG,CAAA;;;;CAIjC,CAAA;AAED,MAAM,QAAQ,GAAG,MAAM,CAAC,UAAU,CAAC,CAAA;;;;;CAKlC,CAAA;AAED,MAAM,YAAY,GAAG,MAAM,CAAC,GAAG,CAG7B;gBACc,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC;;IAE/D,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,EAAE,CAC7B,QAAQ;IACR,CAAC,UAAU;IACX;;;;;;;;;;;GAWD;CACF,CAAA"}
@@ -9,13 +9,16 @@
9
9
  *
10
10
  * All portions of the code written by Atypon Systems LLC are Copyright (c) 2019 Atypon Systems LLC. All Rights Reserved.
11
11
  */
12
- import { clearCommentSelection, commentsKey, isNodeComment, setCommentSelection, } from '@manuscripts/body-editor';
12
+ import { commentsKey, isNodeComment, setCommentSelection, } from '@manuscripts/body-editor';
13
+ import { buildContribution } from '@manuscripts/json-schema';
13
14
  import { CheckboxField, CheckboxLabel } from '@manuscripts/style-guide';
14
15
  import { skipTracking } from '@manuscripts/track-changes-plugin';
16
+ import { generateNodeID, schema } from '@manuscripts/transform';
15
17
  import { NodeSelection, TextSelection } from 'prosemirror-state';
18
+ import { findChildrenByType } from 'prosemirror-utils';
16
19
  import React, { useCallback, useMemo, useState } from 'react';
17
20
  import styled from 'styled-components';
18
- import { buildCommentTrees } from '../../lib/comments';
21
+ import { buildThreads } from '../../lib/comments';
19
22
  import { useStore } from '../../store';
20
23
  import { CommentsPlaceholder } from './CommentsPlaceholder';
21
24
  import { CommentThread } from './CommentThread';
@@ -34,14 +37,17 @@ const scrollIntoView = (element) => {
34
37
  }
35
38
  };
36
39
  export const CommentsPanel = () => {
37
- const [{ view, newCommentID, selectedCommentKey }] = useStore((state) => ({
40
+ const [{ view, newCommentID, selectedCommentKey, user, doc }] = useStore((state) => ({
38
41
  view: state.view,
42
+ doc: state.doc,
39
43
  newCommentID: state.newCommentID,
40
44
  selectedCommentKey: state.selectedCommentKey,
45
+ user: state.user,
41
46
  }));
42
47
  const [showResolved, setShowResolved] = useState(true);
43
- const comments = useMemo(() => view?.state ? commentsKey.getState(view.state)?.comments : undefined, [view?.state]);
44
- const trees = useMemo(() => comments ? buildCommentTrees([...comments.values()], newCommentID) : [], [comments, newCommentID]);
48
+ const comments = useMemo(() => view?.state ? commentsKey.getState(view.state)?.comments : undefined, [view?.state, doc] // eslint-disable-line react-hooks/exhaustive-deps
49
+ );
50
+ const threads = useMemo(() => (comments ? buildThreads([...comments.values()], newCommentID) : []), [comments, newCommentID]);
45
51
  const selectedRef = useCallback((e) => {
46
52
  if (e) {
47
53
  scrollIntoView(e);
@@ -66,6 +72,25 @@ export const CommentsPanel = () => {
66
72
  view.focus();
67
73
  view.dispatch(tr);
68
74
  };
75
+ const insertCommentReply = (target, contents) => {
76
+ if (!view) {
77
+ return;
78
+ }
79
+ const attrs = {
80
+ id: generateNodeID(schema.nodes.comment),
81
+ contents,
82
+ target,
83
+ contributions: [buildContribution(user._id)],
84
+ resolved: false,
85
+ };
86
+ const comment = view.state.schema.nodes.comment.create(attrs);
87
+ const comments = findChildrenByType(view.state.doc, view.state.schema.nodes.comments)[0];
88
+ if (comments) {
89
+ const pos = comments.pos + 1;
90
+ const tr = view.state.tr.insert(pos, comment);
91
+ view.dispatch(skipTracking(tr));
92
+ }
93
+ };
69
94
  const handleSave = (attrs) => {
70
95
  const comment = comments?.get(attrs.id);
71
96
  if (!comment || !view) {
@@ -73,9 +98,19 @@ export const CommentsPanel = () => {
73
98
  }
74
99
  const tr = view.state.tr;
75
100
  tr.setNodeMarkup(comment.pos, undefined, attrs);
76
- clearCommentSelection(tr);
77
101
  view.dispatch(skipTracking(tr));
78
102
  };
103
+ const deleteHighlightMarkers = (id, tr) => {
104
+ const nodes = findChildrenByType(doc, schema.nodes.highlight_marker);
105
+ // Sort nodes in reverse order by position to ensure deletions do not affect the positions of subsequent nodes
106
+ nodes.sort((a, b) => b.pos - a.pos);
107
+ nodes.forEach(({ node, pos }) => {
108
+ const attrs = node.attrs;
109
+ if (attrs.id === id) {
110
+ tr.delete(pos, pos + node.nodeSize);
111
+ }
112
+ });
113
+ };
79
114
  const handleDelete = (id) => {
80
115
  const comment = comments?.get(id);
81
116
  if (!comment || !view) {
@@ -83,16 +118,16 @@ export const CommentsPanel = () => {
83
118
  }
84
119
  const tr = view.state.tr;
85
120
  tr.delete(comment.pos, comment.pos + comment.node.nodeSize);
86
- clearCommentSelection(tr);
121
+ deleteHighlightMarkers(id, tr);
87
122
  view.dispatch(skipTracking(tr));
88
123
  };
89
- const isSelected = (tree) => {
90
- return tree && selectedCommentKey === tree.comment.key;
124
+ const isSelected = (thread) => {
125
+ return thread && selectedCommentKey === thread.comment.key;
91
126
  };
92
127
  if (!view) {
93
128
  return null;
94
129
  }
95
- if (!trees.length) {
130
+ if (!threads.length) {
96
131
  return React.createElement(CommentsPlaceholder, null);
97
132
  }
98
133
  return (React.createElement(React.Fragment, null,
@@ -100,8 +135,8 @@ export const CommentsPanel = () => {
100
135
  React.createElement(CheckboxLabel, null,
101
136
  React.createElement(CheckboxField, { name: 'show-resolved', checked: showResolved, onChange: (e) => setShowResolved(e.target.checked) }),
102
137
  React.createElement(CheckboxLabelText, null, "See resolved"))),
103
- trees
138
+ threads
104
139
  .filter((c) => showResolved || !c.comment.node.attrs.resolved)
105
- .map((c, i, a) => (React.createElement(CommentThread, { key: c.comment.node.attrs.id, ref: isSelected(c) && !isSelected(a[i - 1]) ? selectedRef : null, tree: c, isSelected: isSelected(c), onSelect: () => setSelectedComment(c.comment), onSave: handleSave, onDelete: handleDelete })))));
140
+ .map((c, i, a) => (React.createElement(CommentThread, { key: c.comment.node.attrs.id, ref: isSelected(c) && !isSelected(a[i - 1]) ? selectedRef : null, thread: c, isSelected: isSelected(c), onSelect: () => setSelectedComment(c.comment), onSave: handleSave, onDelete: handleDelete, insertCommentReply: insertCommentReply })))));
106
141
  };
107
142
  //# sourceMappingURL=CommentsPanel.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CommentsPanel.js","sourceRoot":"","sources":["../../../../src/components/comments/CommentsPanel.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EACL,qBAAqB,EAGrB,WAAW,EAEX,aAAa,EACb,mBAAmB,GACpB,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAA;AAChE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAChE,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAC7D,OAAO,MAAM,MAAM,mBAAmB,CAAA;AAEtC,OAAO,EAAE,iBAAiB,EAAe,MAAM,oBAAoB,CAAA;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAA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AAE,CAAC,YAAY,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;aAC7D,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAChB,oBAAC,aAAa,IACZ,GAAG,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,EAC5B,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,EAChE,MAAM,EAAE,CAAC,EACT,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,EACzB,QAAQ,EAAE,GAAG,EAAE,CAAC,kBAAkB,CAAC,CAAC,CAAC,OAAO,CAAC,EAC7C,MAAM,EAAE,UAAU,EAClB,QAAQ,EAAE,YAAY,EACtB,kBAAkB,EAAE,kBAAkB,GACtC,CACH,CAAC,CACH,CACJ,CAAA;AACH,CAAC,CAAA"}
@@ -0,0 +1,85 @@
1
+ /*!
2
+ * The contents of this file are subject to the Common Public Attribution License Version 1.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://mpapp-public.gitlab.io/manuscripts-frontend/LICENSE. The License is based on the Mozilla Public License Version 1.1 but Sections 14 and 15 have been added to cover use of software over a computer network and provide for limited attribution for the Original Developer. In addition, Exhibit A has been modified to be consistent with Exhibit B.
3
+ *
4
+ * Software distributed under the License is distributed on an “AS IS” basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License.
5
+ *
6
+ * The Original Code is manuscripts-frontend.
7
+ *
8
+ * The Original Developer is the Initial Developer. The Initial Developer of the Original Code is Atypon Systems LLC.
9
+ *
10
+ * All portions of the code written by Atypon Systems LLC are Copyright (c) 2024 Atypon Systems LLC. All Rights Reserved.
11
+ */
12
+ import { AttentionOrangeIcon, ButtonGroup, PrimaryButton, SecondaryButton, } from '@manuscripts/style-guide';
13
+ import React, { useEffect, useRef } from 'react';
14
+ import styled from 'styled-components';
15
+ const MessageContainer = styled.div `
16
+ display: flex;
17
+ align-items: center;
18
+ flex-grow: 1;
19
+
20
+ svg {
21
+ padding-left: 14px;
22
+ }
23
+ `;
24
+ const CancelButton = styled(SecondaryButton) `
25
+ padding: 4px ${(props) => props.theme.grid.unit * 3}px;
26
+ font-size: 14px;
27
+ `;
28
+ const DeleteButton = styled(PrimaryButton) `
29
+ padding: 4px ${(props) => props.theme.grid.unit * 3}px;
30
+ margin-right: 16px;
31
+ font-size: 14px;
32
+ `;
33
+ const Message = styled.div `
34
+ font-weight: 700;
35
+ color: #000;
36
+ font-size: 14px;
37
+ line-height: 16px;
38
+ margin: 0 8px;
39
+ `;
40
+ const DeleteConfirmation = styled.div `
41
+ border-top: 1px solid #e2e2e2;
42
+ border-bottom: 1px solid #e2e2e2;
43
+ box-shadow: 0px 4px 9px 0px rgba(0, 0, 0, 0.3);
44
+ position: absolute;
45
+ top: -9px;
46
+ left: ${(props) => (props.isReply ? '-24px' : '-8px')};
47
+ right: -8px;
48
+ bottom: -9px;
49
+ opacity: 0.95;
50
+ display: flex;
51
+ align-items: center;
52
+ justify-content: center;
53
+ background: #fafafa;
54
+ z-index: 10;
55
+ `;
56
+ const Buttons = styled(ButtonGroup) `
57
+ & button:not(:last-of-type) {
58
+ margin-right: 4px;
59
+ }
60
+ `;
61
+ export const DeleteCommentConfirmation = ({ isReply, onCancel, onConfirm }) => {
62
+ const deleteConfirmationRef = useRef(null);
63
+ useEffect(() => {
64
+ const handleClickOutside = (e) => {
65
+ if (e.target &&
66
+ deleteConfirmationRef.current &&
67
+ !deleteConfirmationRef.current.contains(e.target) &&
68
+ !e.target.closest('.delete-button')) {
69
+ onCancel();
70
+ }
71
+ };
72
+ document.addEventListener('click', handleClickOutside);
73
+ return () => {
74
+ document.removeEventListener('click', handleClickOutside);
75
+ };
76
+ }, []); // eslint-disable-line react-hooks/exhaustive-deps
77
+ return (React.createElement(DeleteConfirmation, { isReply: isReply, ref: deleteConfirmationRef },
78
+ React.createElement(MessageContainer, null,
79
+ React.createElement(AttentionOrangeIcon, null),
80
+ React.createElement(Message, null, "Delete this comment?")),
81
+ React.createElement(Buttons, null,
82
+ React.createElement(CancelButton, { onClick: onCancel }, "Cancel"),
83
+ React.createElement(DeleteButton, { onClick: onConfirm }, "Delete"))));
84
+ };
85
+ //# sourceMappingURL=DeleteCommentConfirmation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DeleteCommentConfirmation.js","sourceRoot":"","sources":["../../../../src/components/comments/DeleteCommentConfirmation.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EACL,mBAAmB,EACnB,WAAW,EACX,aAAa,EACb,eAAe,GAChB,MAAM,0BAA0B,CAAA;AACjC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAChD,OAAO,MAAM,MAAM,mBAAmB,CAAA;AAEtC,MAAM,gBAAgB,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;;CAQlC,CAAA;AAED,MAAM,YAAY,GAAG,MAAM,CAAC,eAAe,CAAC,CAAA;iBAC3B,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC;;CAEpD,CAAA;AACD,MAAM,YAAY,GAAG,MAAM,CAAC,aAAa,CAAC,CAAA;iBACzB,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC;;;CAGpD,CAAA;AACD,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;CAMzB,CAAA;AAED,MAAM,kBAAkB,GAAG,MAAM,CAAC,GAAG,CAAuB;;;;;;UAMlD,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,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2
+ * The contents of this file are subject to the Common Public Attribution License Version 1.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://mpapp-public.gitlab.io/manuscripts-frontend/LICENSE. The License is based on the Mozilla Public License Version 1.1 but Sections 14 and 15 have been added to cover use of software over a computer network and provide for limited attribution for the Original Developer. In addition, Exhibit A has been modified to be consistent with Exhibit B.
3
+ *
4
+ * Software distributed under the License is distributed on an “AS IS” basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License.
5
+ *
6
+ * The Original Code is manuscripts-frontend.
7
+ *
8
+ * The Original Developer is the Initial Developer. The Initial Developer of the Original Code is Atypon Systems LLC.
9
+ *
10
+ * All portions of the code written by Atypon Systems LLC are Copyright (c) 2024 Atypon Systems LLC. All Rights Reserved.
11
+ */
12
+ import { ButtonGroup, PrimaryButton, TertiaryButton, } from '@manuscripts/style-guide';
13
+ import React, { useMemo, useRef, useState } from 'react';
14
+ import styled from 'styled-components';
15
+ export const ReplyBox = ({ insertCommentReply, commentID, }) => {
16
+ const [isTextBoxFocused, setIsTextBoxFocused] = useState(false);
17
+ const [value, setValue] = useState('');
18
+ const replyRef = useRef(null);
19
+ const handleFocus = () => setIsTextBoxFocused(true);
20
+ const reply = () => {
21
+ if (replyRef.current) {
22
+ insertCommentReply(commentID, replyRef.current.value);
23
+ setValue('');
24
+ replyRef.current.value = '';
25
+ replyRef.current.style.height = '30px'; // Reset the height
26
+ }
27
+ };
28
+ const handleCancel = () => {
29
+ setIsTextBoxFocused(false);
30
+ setValue('');
31
+ if (replyRef.current) {
32
+ replyRef.current.value = '';
33
+ replyRef.current.style.height = '30px'; // Reset the height
34
+ }
35
+ };
36
+ const disableSaveButton = useMemo(() => !value.length, [value]);
37
+ const onTextChange = (e) => {
38
+ setValue(e.target.value);
39
+ if (replyRef.current) {
40
+ replyRef.current.style.height = '30px'; // Reset the height
41
+ replyRef.current.style.height = `${Math.min(replyRef.current.scrollHeight, 55)}px`; // Set the height based on content
42
+ }
43
+ };
44
+ return (React.createElement(React.Fragment, null,
45
+ React.createElement(TextBox, { "data-cy": "reply", placeholder: "Reply...", ref: replyRef, onChange: onTextChange, onFocus: handleFocus }),
46
+ isTextBoxFocused && (React.createElement(Actions, { "data-cy": "reply-actions" },
47
+ React.createElement(TertiaryButton, { onClick: handleCancel }, "Cancel"),
48
+ React.createElement(PrimaryButton, { onClick: reply, disabled: disableSaveButton }, "Reply")))));
49
+ };
50
+ const TextBox = styled.textarea `
51
+ cursor: text;
52
+ font-family: ${(props) => props.theme.font.family.sans};
53
+ color: ${(props) => props.theme.colors.text.primary};
54
+ margin: ${(props) => props.theme.grid.unit * 2}px 0;
55
+ resize: none;
56
+
57
+ width: 100%;
58
+
59
+ height: 30px;
60
+ max-height: 55px;
61
+
62
+ outline: 0;
63
+ border: 1px solid #e2e2e2;
64
+ border-radius: 6px;
65
+
66
+ &:focus {
67
+ background: #f2fbfc;
68
+ border: 1px solid #bce7f6;
69
+ border-radius: 6px;
70
+ }
71
+
72
+ box-sizing: border-box;
73
+ padding: 3px 16px 3px 16px;
74
+ font-style: normal;
75
+ font-weight: 400;
76
+ font-size: 14px;
77
+ line-height: 24px;
78
+ overflow: hidden;
79
+ `;
80
+ const Actions = styled(ButtonGroup) `
81
+ & button:not(:last-of-type) {
82
+ margin-right: 4px;
83
+ }
84
+ & ${TertiaryButton} {
85
+ &:hover {
86
+ background-color: inherit !important;
87
+ border-color: transparent !important;
88
+ }
89
+ }
90
+ `;
91
+ //# sourceMappingURL=ReplyBox.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReplyBox.js","sourceRoot":"","sources":["../../../../src/components/comments/ReplyBox.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EACL,WAAW,EACX,aAAa,EACb,cAAc,GACf,MAAM,0BAA0B,CAAA;AACjC,OAAO,KAAK,EAAE,EAAe,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;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@@
1
+ /*!
2
+ * The contents of this file are subject to the Common Public Attribution License Version 1.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://mpapp-public.gitlab.io/manuscripts-frontend/LICENSE. The License is based on the Mozilla Public License Version 1.1 but Sections 14 and 15 have been added to cover use of software over a computer network and provide for limited attribution for the Original Developer. In addition, Exhibit A has been modified to be consistent with Exhibit B.
3
+ *
4
+ * Software distributed under the License is distributed on an “AS IS” basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License.
5
+ *
6
+ * The Original Code is manuscripts-frontend.
7
+ *
8
+ * The Original Developer is the Initial Developer. The Initial Developer of the Original Code is Atypon Systems LLC.
9
+ *
10
+ * All portions of the code written by Atypon Systems LLC are Copyright (c) 2024 Atypon Systems LLC. All Rights Reserved.
11
+ */
12
+ import { isReply } from '@manuscripts/body-editor';
1
13
  export const getAuthorID = (comment) => {
2
14
  const contributions = comment.node.attrs.contributions;
3
15
  if (!contributions?.length) {
@@ -5,11 +17,14 @@ export const getAuthorID = (comment) => {
5
17
  }
6
18
  return contributions[0].profileID;
7
19
  };
8
- export const buildCommentTrees = (comments, newCommentID) => {
9
- return comments.map((c) => ({
20
+ export const buildThreads = (comments, newCommentID) => {
21
+ return comments
22
+ .filter((c) => !isReply(c)) // Filter out replies
23
+ .map((c) => ({
10
24
  comment: c,
11
25
  isNew: newCommentID === c.node.attrs.id,
12
- children: [],
26
+ replies: comments.filter((reply) => reply.node.attrs.target === c.node.attrs.id // Find replies for each comment
27
+ ),
13
28
  }));
14
29
  };
15
30
  export const buildAuthorName = (user) => {
@@ -20,4 +35,9 @@ export const buildAuthorName = (user) => {
20
35
  .filter(Boolean)
21
36
  .join(' ');
22
37
  };
38
+ export const commentsByTime = (a, b) => {
39
+ const aTimestamp = a.node.attrs.contributions?.[0].timestamp || 0;
40
+ const bTimestamp = b.node.attrs.contributions?.[0].timestamp || 0;
41
+ return aTimestamp - bTimestamp;
42
+ };
23
43
  //# sourceMappingURL=comments.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"comments.js","sourceRoot":"","sources":["../../../src/lib/comments.ts"],"names":[],"mappings":"AAoBA,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,OAAgB,EAAE,EAAE;IAC9C,MAAM,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAA;IACtD,IAAI,CAAC,aAAa,EAAE,MAAM,EAAE;QAC1B,OAAO,SAAS,CAAA;KACjB;IACD,OAAO,aAAa,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;AACnC,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,QAAmB,EACnB,YAAqB,EACN,EAAE;IACjB,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAC1B,OAAO,EAAE,CAAC;QACV,KAAK,EAAE,YAAY,KAAK,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;QACvC,QAAQ,EAAE,EAAE;KACb,CAAC,CAAC,CAAA;AACL,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,IAA6B,EAAE,EAAE;IAC/D,IAAI,CAAC,IAAI,EAAE;QACT,OAAO,EAAE,CAAA;KACV;IACD,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC;SACjE,MAAM,CAAC,OAAO,CAAC;SACf,IAAI,CAAC,GAAG,CAAC,CAAA;AACd,CAAC,CAAA"}
1
+ {"version":3,"file":"comments.js","sourceRoot":"","sources":["../../../src/lib/comments.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAW,OAAO,EAAE,MAAM,0BAA0B,CAAA;AAS3D,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,OAAgB,EAAE,EAAE;IAC9C,MAAM,aAAa,GAAG,OAAO,CAAC,I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E,MAAM,UAAU,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,IAAI,CAAC,CAAA;IACjE,OAAO,UAAU,GAAG,UAAU,CAAA;AAChC,CAAC,CAAA"}
@@ -16,6 +16,5 @@ export interface CommentBodyProps {
16
16
  isEditing: boolean;
17
17
  onSave: (content: string) => void;
18
18
  onCancel: () => void;
19
- onSelect: () => void;
20
19
  }
21
20
  export declare const CommentBody: React.FC<CommentBodyProps>;