@manuscripts/article-editor 3.4.1 → 3.4.2-LEAN-3894.0
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.
- package/dist/cjs/components/comments/CommentActions.js +11 -7
- package/dist/cjs/components/comments/CommentActions.js.map +1 -1
- package/dist/cjs/components/comments/CommentBody.js +10 -6
- package/dist/cjs/components/comments/CommentBody.js.map +1 -1
- package/dist/cjs/components/comments/CommentCard.js +165 -0
- package/dist/cjs/components/comments/CommentCard.js.map +1 -0
- package/dist/cjs/components/comments/CommentResolveButton.js +1 -1
- package/dist/cjs/components/comments/CommentThread.js +83 -89
- package/dist/cjs/components/comments/CommentThread.js.map +1 -1
- package/dist/cjs/components/comments/CommentsPanel.js +33 -10
- package/dist/cjs/components/comments/CommentsPanel.js.map +1 -1
- package/dist/cjs/components/comments/DeleteCommentConfirmation.js +74 -0
- package/dist/cjs/components/comments/DeleteCommentConfirmation.js.map +1 -0
- package/dist/cjs/components/comments/ReplyBox.js +121 -0
- package/dist/cjs/components/comments/ReplyBox.js.map +1 -0
- package/dist/cjs/lib/comments.js +26 -5
- package/dist/cjs/lib/comments.js.map +1 -1
- package/dist/es/components/comments/CommentActions.js +11 -7
- package/dist/es/components/comments/CommentActions.js.map +1 -1
- package/dist/es/components/comments/CommentBody.js +11 -7
- package/dist/es/components/comments/CommentBody.js.map +1 -1
- package/dist/es/components/comments/CommentCard.js +135 -0
- package/dist/es/components/comments/CommentCard.js.map +1 -0
- package/dist/es/components/comments/CommentResolveButton.js +1 -1
- package/dist/es/components/comments/CommentThread.js +86 -92
- package/dist/es/components/comments/CommentThread.js.map +1 -1
- package/dist/es/components/comments/CommentsPanel.js +35 -12
- package/dist/es/components/comments/CommentsPanel.js.map +1 -1
- package/dist/es/components/comments/DeleteCommentConfirmation.js +67 -0
- package/dist/es/components/comments/DeleteCommentConfirmation.js.map +1 -0
- package/dist/es/components/comments/ReplyBox.js +91 -0
- package/dist/es/components/comments/ReplyBox.js.map +1 -0
- package/dist/es/lib/comments.js +23 -3
- package/dist/es/lib/comments.js.map +1 -1
- package/dist/types/components/comments/CommentCard.d.ts +27 -0
- package/dist/types/components/comments/CommentThread.d.ts +3 -2
- package/dist/types/components/comments/DeleteCommentConfirmation.d.ts +19 -0
- package/dist/types/components/comments/ReplyBox.d.ts +18 -0
- package/dist/types/lib/comments.d.ts +4 -3
- package/package.json +2 -2
@@ -1,105 +1,99 @@
|
|
1
|
-
import {
|
2
|
-
import React, { forwardRef, useState } from 'react';
|
1
|
+
import { TextButton } from '@manuscripts/style-guide';
|
2
|
+
import React, { forwardRef, useEffect, useRef, useState } from 'react';
|
3
3
|
import styled from 'styled-components';
|
4
|
-
import {
|
5
|
-
import {
|
6
|
-
import {
|
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:
|
10
|
-
background-color: ${(props) => (props.isSelected ? '#
|
11
|
-
border: 1px solid
|
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
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
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
|
-
|
35
|
-
|
21
|
+
&:hover {
|
22
|
+
background-color: #fff;
|
23
|
+
|
24
|
+
.actions-icon {
|
25
|
+
visibility: visible;
|
26
|
+
}
|
36
27
|
}
|
37
28
|
`;
|
38
|
-
const
|
39
|
-
|
40
|
-
color: #
|
41
|
-
|
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
|
47
|
-
|
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 {
|
54
|
-
const
|
55
|
-
const
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
const
|
65
|
-
|
66
|
-
|
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);
|
38
|
+
const { thread, isSelected, onSelect, onSave, onDelete, insertCommentReply, } = props;
|
39
|
+
const { comment, isNew, replies } = thread;
|
40
|
+
const cardsRef = useRef(null);
|
41
|
+
const [showMore, setShowMore] = useState(false);
|
42
|
+
const [editingCommentId, setEditingCommentId] = useState(isNew ? comment.node.attrs.id : null);
|
43
|
+
useEffect(() => {
|
44
|
+
if (cardsRef.current) {
|
45
|
+
const contentHeight = cardsRef.current.scrollHeight;
|
46
|
+
setShowMore(contentHeight > 280);
|
47
|
+
}
|
48
|
+
}, [comment, replies]);
|
49
|
+
const handleSelect = () => {
|
50
|
+
if (!isSelected) {
|
51
|
+
onSelect();
|
84
52
|
}
|
85
53
|
};
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
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 })));
|
54
|
+
return (React.createElement(Container, { "data-cy": "comment", isSelected: isSelected, ref: ref, onClick: handleSelect },
|
55
|
+
React.createElement(CardsWrapper, { ref: cardsRef, isSelected: isSelected, showMore: showMore },
|
56
|
+
React.createElement(CommentCard, { comment: comment, isReply: false, numOfReplies: replies.length, isNew: isNew, isEndOfThread: !replies.length, editingCommentId: editingCommentId, setEditingCommentId: setEditingCommentId, onDelete: onDelete, onSave: onSave, onSelect: onSelect }),
|
57
|
+
replies.sort(commentsByTime).map((reply, index) => {
|
58
|
+
return (React.createElement("div", { key: reply.node.attrs.id },
|
59
|
+
index === 0 && React.createElement(SeparatorLine, null),
|
60
|
+
React.createElement(Indented, null,
|
61
|
+
index !== 0 && React.createElement(SeparatorLine, null),
|
62
|
+
React.createElement(CommentCard, { comment: reply, isReply: true, numOfReplies: 0, isNew: false, isEndOfThread: index === replies.length - 1, editingCommentId: editingCommentId, setEditingCommentId: setEditingCommentId, onDelete: onDelete, onSave: onSave, onSelect: onSelect }))));
|
63
|
+
})),
|
64
|
+
showMore && !isSelected && (React.createElement(React.Fragment, null,
|
65
|
+
React.createElement(SeparatorLine, null),
|
66
|
+
React.createElement(ButtonContainer, null,
|
67
|
+
React.createElement(ShowMore, { onClick: onSelect }, "Show more")))),
|
68
|
+
isSelected && editingCommentId === null && (React.createElement(ReplyBox, { insertCommentReply: insertCommentReply, commentID: comment.node.attrs.id }))));
|
104
69
|
});
|
70
|
+
const ButtonContainer = styled.div `
|
71
|
+
display: flex;
|
72
|
+
justify-content: center;
|
73
|
+
align-items: center;
|
74
|
+
`;
|
75
|
+
const ShowMore = styled(TextButton) `
|
76
|
+
cursor: pointer;
|
77
|
+
text-align: center;
|
78
|
+
margin-top: 6px;
|
79
|
+
color: #353535;
|
80
|
+
`;
|
81
|
+
const CardsWrapper = styled.div `
|
82
|
+
max-height: ${({ isSelected }) => (isSelected ? 'none' : '280px')};
|
83
|
+
position: relative;
|
84
|
+
${({ showMore, isSelected }) => showMore &&
|
85
|
+
!isSelected &&
|
86
|
+
`
|
87
|
+
overflow: hidden;
|
88
|
+
&:after {
|
89
|
+
content: '';
|
90
|
+
position: absolute;
|
91
|
+
bottom: 0;
|
92
|
+
left: 0;
|
93
|
+
right: 0;
|
94
|
+
height: 40px;
|
95
|
+
background: linear-gradient(to bottom, rgba(255, 255, 255, 0), rgba(255, 255, 255, 1));
|
96
|
+
}
|
97
|
+
`}
|
98
|
+
`;
|
105
99
|
//# sourceMappingURL=CommentThread.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"CommentThread.js","sourceRoot":"","sources":["../../../../src/components/comments/CommentThread.tsx"],"names":[],"mappings":"AAYA,OAAO,
|
1
|
+
{"version":3,"file":"CommentThread.js","sourceRoot":"","sources":["../../../../src/components/comments/CommentThread.tsx"],"names":[],"mappings":"AAYA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AACrD,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACtE,OAAO,MAAM,MAAM,mBAAmB,CAAA;AAEtC,OAAO,EAAE,cAAc,EAAU,MAAM,oBAAoB,CAAA;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAErC,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAA0B;;sBAEhC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;;IAEpE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,UAAU,IAAI,wBAAwB;;;;;;;kBAOzC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC;;;;;;;;;;CAUrE,CAAA;AACD,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,CAAA;;;;CAI/B,CAAA;AACD,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAA;;CAE1B,CAAA;AAWD,MAAM,CAAC,MAAM,aAAa,GAAG,UAAU,CACrC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;IACb,MAAM,EACJ,MAAM,EACN,UAAU,EACV,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,kBAAkB,GACnB,GAAG,KAAK,CAAA;IAET,MAAM,EAAE,OAAO,EAAE,KAAK,EA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,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 {
|
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 {
|
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
|
-
|
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,7 +98,6 @@ 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
|
};
|
79
103
|
const handleDelete = (id) => {
|
@@ -83,16 +107,15 @@ export const CommentsPanel = () => {
|
|
83
107
|
}
|
84
108
|
const tr = view.state.tr;
|
85
109
|
tr.delete(comment.pos, comment.pos + comment.node.nodeSize);
|
86
|
-
clearCommentSelection(tr);
|
87
110
|
view.dispatch(skipTracking(tr));
|
88
111
|
};
|
89
|
-
const isSelected = (
|
90
|
-
return
|
112
|
+
const isSelected = (thread) => {
|
113
|
+
return thread && selectedCommentKey === thread.comment.key;
|
91
114
|
};
|
92
115
|
if (!view) {
|
93
116
|
return null;
|
94
117
|
}
|
95
|
-
if (!
|
118
|
+
if (!threads.length) {
|
96
119
|
return React.createElement(CommentsPlaceholder, null);
|
97
120
|
}
|
98
121
|
return (React.createElement(React.Fragment, null,
|
@@ -100,8 +123,8 @@ export const CommentsPanel = () => {
|
|
100
123
|
React.createElement(CheckboxLabel, null,
|
101
124
|
React.createElement(CheckboxField, { name: 'show-resolved', checked: showResolved, onChange: (e) => setShowResolved(e.target.checked) }),
|
102
125
|
React.createElement(CheckboxLabelText, null, "See resolved"))),
|
103
|
-
|
126
|
+
threads
|
104
127
|
.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,
|
128
|
+
.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
129
|
};
|
107
130
|
//# 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,
|
1
|
+
{"version":3,"file":"CommentsPanel.js","sourceRoot":"","sources":["../../../../src/components/comments/CommentsPanel.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAGL,WAAW,EAEX,aAAa,EACb,mBAAmB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AQ,EAAE,YAAY,EACtB,kBAAkB,EAAE,kBAAkB,GACtC,CACH,CAAC,CACH,CACJ,CAAA;AACH,CAAC,CAAA"}
|
@@ -0,0 +1,67 @@
|
|
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 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
|
+
position: absolute;
|
42
|
+
top: -8px;
|
43
|
+
left: ${(props) => (props.isReply ? '-24px' : '-8px')};
|
44
|
+
right: -8px;
|
45
|
+
bottom: -16px;
|
46
|
+
opacity: 0.95;
|
47
|
+
display: flex;
|
48
|
+
align-items: center;
|
49
|
+
justify-content: center;
|
50
|
+
background: #fafafa;
|
51
|
+
z-index: 10;
|
52
|
+
`;
|
53
|
+
const Buttons = styled(ButtonGroup) `
|
54
|
+
& button:not(:last-of-type) {
|
55
|
+
margin-right: 4px;
|
56
|
+
}
|
57
|
+
`;
|
58
|
+
export const DeleteCommentConfirmation = ({ isReply, onCancel, onConfirm }) => {
|
59
|
+
return (React.createElement(DeleteConfirmation, { isReply: isReply },
|
60
|
+
React.createElement(MessageContainer, null,
|
61
|
+
React.createElement(AttentionOrangeIcon, null),
|
62
|
+
React.createElement(Message, null, "Delete this comment?")),
|
63
|
+
React.createElement(Buttons, null,
|
64
|
+
React.createElement(CancelButton, { onClick: onCancel }, "Cancel"),
|
65
|
+
React.createElement(DeleteButton, { onClick: onConfirm }, "Delete"))));
|
66
|
+
};
|
67
|
+
//# 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,MAAM,OAAO,CAAA;AACzB,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;;;UAGlD,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC;;;;;;;;;CAStD,CAAA;AAED,MAAM,OAAO,GAAG,MAAM,CAAC,WAAW,CAAC,CAAA;;;;CAIlC,CAAA;AAQD,MAAM,CAAC,MAAM,yBAAyB,GAElC,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,EAAE;IACvC,OAAO,CACL,oBAAC,kBAAkB,IAAC,OAAO,EAAE,OAAO;QAClC,oBAAC,gBAAgB;YACf,oBAAC,mBAAmB,OAAG;YACvB,oBAAC,OAAO,+BAA+B,CACtB;QACnB,oBAAC,OAAO;YACN,oBAAC,YAAY,IAAC,OAAO,EAAE,QAAQ,aAAuB;YACtD,oBAAC,YAAY,IAAC,OAAO,EAAE,SAAS,aAAuB,CAC/C,CACS,CACtB,CAAA;AACH,CAAC,CAAA"}
|
@@ -0,0 +1,91 @@
|
|
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 { 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
|
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AAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO;YACzC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;CAyB/C,CAAA;AAED,MAAM,OAAO,GAAG,MAAM,CAAC,WAAW,CAAC,CAAA;;;;MAI7B,cAAc;;;;;;CAMnB,CAAA"}
|
package/dist/es/lib/comments.js
CHANGED
@@ -1,3 +1,15 @@
|
|
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
|
9
|
-
return comments
|
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
|
-
|
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":"
|
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,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,YAAY,GAAG,CAC1B,QAAmB,EACnB,YAAqB,EACX,EAAE;IACZ,OAAO,QAAQ;SACZ,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,qBAAqB;SAChD,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACX,OAAO,EAAE,CAAC;QACV,KAAK,EAAE,YAAY,KAAK,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;QACvC,OAAO,EAAE,QAAQ,CAAC,MAAM,CACtB,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,gCAAgC;SACxF;KACF,CAAC,CAAC,CAAA;AACP,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;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAU,EAAE,CAAU,EAAE,EAAE;IACvD,MAAM,UAAU,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,IAAI,CAAC,CAAA;IACjE,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"}
|
@@ -0,0 +1,27 @@
|
|
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 { Comment, CommentAttrs } from '@manuscripts/body-editor';
|
13
|
+
import React from 'react';
|
14
|
+
interface CommentCardProps {
|
15
|
+
comment: Comment;
|
16
|
+
isReply: boolean;
|
17
|
+
numOfReplies: number;
|
18
|
+
isNew: boolean;
|
19
|
+
isEndOfThread: boolean;
|
20
|
+
editingCommentId: string | null;
|
21
|
+
setEditingCommentId: (id: string | null) => void;
|
22
|
+
onSave: (comment: CommentAttrs) => void;
|
23
|
+
onDelete: (id: string) => void;
|
24
|
+
onSelect: () => void;
|
25
|
+
}
|
26
|
+
export declare const CommentCard: React.FC<CommentCardProps>;
|
27
|
+
export {};
|
@@ -11,12 +11,13 @@
|
|
11
11
|
*/
|
12
12
|
import { CommentAttrs } from '@manuscripts/body-editor';
|
13
13
|
import React from 'react';
|
14
|
-
import {
|
14
|
+
import { Thread } from '../../lib/comments';
|
15
15
|
export interface CommentThreadProps {
|
16
|
-
|
16
|
+
thread: Thread;
|
17
17
|
isSelected: boolean;
|
18
18
|
onSelect: () => void;
|
19
19
|
onSave: (comment: CommentAttrs) => void;
|
20
20
|
onDelete: (id: string) => void;
|
21
|
+
insertCommentReply: (target: string, contents: string) => void;
|
21
22
|
}
|
22
23
|
export declare const CommentThread: React.ForwardRefExoticComponent<CommentThreadProps & React.RefAttributes<HTMLDivElement>>;
|