@manuscripts/article-editor 3.2.19-LEAN-3894.0 → 3.2.19
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 +7 -11
- package/dist/cjs/components/comments/CommentActions.js.map +1 -1
- package/dist/cjs/components/comments/CommentResolveButton.js +1 -1
- package/dist/cjs/components/comments/CommentThread.js +89 -77
- package/dist/cjs/components/comments/CommentThread.js.map +1 -1
- package/dist/cjs/components/comments/CommentsPanel.js +10 -33
- package/dist/cjs/components/comments/CommentsPanel.js.map +1 -1
- package/dist/cjs/lib/comments.js +5 -26
- package/dist/cjs/lib/comments.js.map +1 -1
- package/dist/es/components/comments/CommentActions.js +7 -11
- package/dist/es/components/comments/CommentActions.js.map +1 -1
- package/dist/es/components/comments/CommentResolveButton.js +1 -1
- package/dist/es/components/comments/CommentThread.js +92 -80
- package/dist/es/components/comments/CommentThread.js.map +1 -1
- package/dist/es/components/comments/CommentsPanel.js +12 -35
- package/dist/es/components/comments/CommentsPanel.js.map +1 -1
- package/dist/es/lib/comments.js +3 -23
- package/dist/es/lib/comments.js.map +1 -1
- package/dist/types/components/comments/CommentThread.d.ts +2 -3
- package/dist/types/lib/comments.d.ts +3 -4
- package/package.json +4 -4
- package/dist/cjs/components/comments/CommentCard.js +0 -162
- package/dist/cjs/components/comments/CommentCard.js.map +0 -1
- package/dist/cjs/components/comments/DeleteCommentConfirmation.js +0 -69
- package/dist/cjs/components/comments/DeleteCommentConfirmation.js.map +0 -1
- package/dist/cjs/components/comments/ReplyBox.js +0 -118
- package/dist/cjs/components/comments/ReplyBox.js.map +0 -1
- package/dist/es/components/comments/CommentCard.js +0 -132
- package/dist/es/components/comments/CommentCard.js.map +0 -1
- package/dist/es/components/comments/DeleteCommentConfirmation.js +0 -62
- package/dist/es/components/comments/DeleteCommentConfirmation.js.map +0 -1
- package/dist/es/components/comments/ReplyBox.js +0 -88
- package/dist/es/components/comments/ReplyBox.js.map +0 -1
- package/dist/types/components/comments/CommentCard.d.ts +0 -25
- package/dist/types/components/comments/DeleteCommentConfirmation.d.ts +0 -18
- package/dist/types/components/comments/ReplyBox.d.ts +0 -18
@@ -1,93 +1,105 @@
|
|
1
|
-
import {
|
2
|
-
import React, { forwardRef,
|
1
|
+
import { AvatarIcon, RelativeDate, SystemUserAvatarIcon, usePermissions, } from '@manuscripts/style-guide';
|
2
|
+
import React, { forwardRef, useState } from 'react';
|
3
3
|
import styled from 'styled-components';
|
4
|
-
import {
|
5
|
-
import {
|
6
|
-
import {
|
4
|
+
import { buildAuthorName, getAuthorID } from '../../lib/comments';
|
5
|
+
import { useStore } from '../../store';
|
6
|
+
import { CommentActions } from './CommentActions';
|
7
|
+
import { CommentBody } from './CommentBody';
|
7
8
|
const Container = styled.div `
|
8
|
-
padding:
|
9
|
-
background-color: ${(props) => (props.isSelected ? '#
|
10
|
-
border: 1px solid #
|
11
|
-
|
12
|
-
border-radius: 4px;
|
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;
|
13
13
|
margin-bottom: 16px;
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
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%;
|
23
33
|
|
24
|
-
|
25
|
-
|
26
|
-
}
|
34
|
+
svg {
|
35
|
+
padding-right: 10px;
|
27
36
|
}
|
28
37
|
`;
|
29
|
-
const
|
30
|
-
|
31
|
-
|
32
|
-
|
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;
|
33
45
|
`;
|
34
|
-
const
|
35
|
-
|
46
|
+
const Timestamp = styled(RelativeDate) `
|
47
|
+
font-size: 12px;
|
48
|
+
line-height: 16px;
|
49
|
+
font-weight: 400;
|
50
|
+
color: #6e6e6e;
|
36
51
|
`;
|
37
52
|
export const CommentThread = forwardRef((props, ref) => {
|
38
|
-
const {
|
39
|
-
const
|
40
|
-
const
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
53
|
+
const { tree, isSelected, onSelect, onSave, onDelete } = props;
|
54
|
+
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);
|
46
84
|
}
|
47
|
-
}
|
85
|
+
};
|
86
|
+
const handleToggleResolve = () => {
|
87
|
+
onSave({
|
88
|
+
...tree.comment.node.attrs,
|
89
|
+
resolved: !tree.comment.node.attrs.resolved,
|
90
|
+
});
|
91
|
+
};
|
48
92
|
return (React.createElement(Container, { "data-cy": "comment", isSelected: isSelected, ref: ref },
|
49
|
-
React.createElement(
|
50
|
-
React.createElement(
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
React.createElement(
|
55
|
-
|
56
|
-
|
57
|
-
})),
|
58
|
-
|
59
|
-
|
60
|
-
React.createElement(ButtonContainer, null,
|
61
|
-
React.createElement(ShowMore, { onClick: onSelect }, "Show more")))),
|
62
|
-
isSelected && !isNew && (React.createElement(ReplyBox, { insertCommentReply: insertCommentReply, commentID: comment.node.attrs.id }))));
|
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 })));
|
63
104
|
});
|
64
|
-
const ButtonContainer = styled.div `
|
65
|
-
display: flex;
|
66
|
-
justify-content: center;
|
67
|
-
align-items: center;
|
68
|
-
`;
|
69
|
-
const ShowMore = styled(TextButton) `
|
70
|
-
cursor: pointer;
|
71
|
-
text-align: center;
|
72
|
-
margin-top: 6px;
|
73
|
-
color: #353535;
|
74
|
-
`;
|
75
|
-
const CardsWrapper = styled.div `
|
76
|
-
max-height: ${({ isSelected }) => (isSelected ? 'none' : '280px')};
|
77
|
-
position: relative;
|
78
|
-
${({ showMore, isSelected }) => showMore &&
|
79
|
-
!isSelected &&
|
80
|
-
`
|
81
|
-
overflow: hidden;
|
82
|
-
&:after {
|
83
|
-
content: '';
|
84
|
-
position: absolute;
|
85
|
-
bottom: 0;
|
86
|
-
left: 0;
|
87
|
-
right: 0;
|
88
|
-
height: 40px;
|
89
|
-
background: linear-gradient(to bottom, rgba(255, 255, 255, 0), rgba(255, 255, 255, 1));
|
90
|
-
}
|
91
|
-
`}
|
92
|
-
`;
|
93
105
|
//# 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,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,W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AAC,WAAW,IACV,OAAO,EAAE,IAAI,CAAC,OAAO,EACrB,SAAS,EAAE,IAAI,CAAC,KAAK,IAAI,SAAS,EAClC,MAAM,EAAE,UAAU,EAClB,QAAQ,EAAE,YAAY,EACtB,QAAQ,EAAE,QAAQ,GAClB,CACQ,CACb,CAAA;AACH,CAAC,CACF,CAAA"}
|
@@ -9,16 +9,13 @@
|
|
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 { commentsKey, isNodeComment, setCommentSelection, } from '@manuscripts/body-editor';
|
13
|
-
import { buildContribution } from '@manuscripts/json-schema';
|
12
|
+
import { clearCommentSelection, commentsKey, isNodeComment, setCommentSelection, } from '@manuscripts/body-editor';
|
14
13
|
import { CheckboxField, CheckboxLabel } from '@manuscripts/style-guide';
|
15
14
|
import { skipTracking } from '@manuscripts/track-changes-plugin';
|
16
|
-
import { generateNodeID, schema } from '@manuscripts/transform';
|
17
15
|
import { NodeSelection, TextSelection } from 'prosemirror-state';
|
18
|
-
import { findChildrenByType } from 'prosemirror-utils';
|
19
16
|
import React, { useCallback, useMemo, useState } from 'react';
|
20
17
|
import styled from 'styled-components';
|
21
|
-
import {
|
18
|
+
import { buildCommentTrees } from '../../lib/comments';
|
22
19
|
import { useStore } from '../../store';
|
23
20
|
import { CommentsPlaceholder } from './CommentsPlaceholder';
|
24
21
|
import { CommentThread } from './CommentThread';
|
@@ -37,17 +34,14 @@ const scrollIntoView = (element) => {
|
|
37
34
|
}
|
38
35
|
};
|
39
36
|
export const CommentsPanel = () => {
|
40
|
-
const [{ view, newCommentID, selectedCommentKey
|
37
|
+
const [{ view, newCommentID, selectedCommentKey }] = useStore((state) => ({
|
41
38
|
view: state.view,
|
42
|
-
doc: state.doc,
|
43
39
|
newCommentID: state.newCommentID,
|
44
40
|
selectedCommentKey: state.selectedCommentKey,
|
45
|
-
user: state.user,
|
46
41
|
}));
|
47
42
|
const [showResolved, setShowResolved] = useState(true);
|
48
|
-
const comments = useMemo(() => view?.state ? commentsKey.getState(view.state)?.comments : undefined, [view?.state
|
49
|
-
);
|
50
|
-
const threads = useMemo(() => (comments ? buildThreads([...comments.values()], newCommentID) : []), [comments, newCommentID]);
|
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]);
|
51
45
|
const selectedRef = useCallback((e) => {
|
52
46
|
if (e) {
|
53
47
|
scrollIntoView(e);
|
@@ -72,25 +66,6 @@ export const CommentsPanel = () => {
|
|
72
66
|
view.focus();
|
73
67
|
view.dispatch(tr);
|
74
68
|
};
|
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
|
-
};
|
94
69
|
const handleSave = (attrs) => {
|
95
70
|
const comment = comments?.get(attrs.id);
|
96
71
|
if (!comment || !view) {
|
@@ -98,6 +73,7 @@ export const CommentsPanel = () => {
|
|
98
73
|
}
|
99
74
|
const tr = view.state.tr;
|
100
75
|
tr.setNodeMarkup(comment.pos, undefined, attrs);
|
76
|
+
clearCommentSelection(tr);
|
101
77
|
view.dispatch(skipTracking(tr));
|
102
78
|
};
|
103
79
|
const handleDelete = (id) => {
|
@@ -107,15 +83,16 @@ export const CommentsPanel = () => {
|
|
107
83
|
}
|
108
84
|
const tr = view.state.tr;
|
109
85
|
tr.delete(comment.pos, comment.pos + comment.node.nodeSize);
|
86
|
+
clearCommentSelection(tr);
|
110
87
|
view.dispatch(skipTracking(tr));
|
111
88
|
};
|
112
|
-
const isSelected = (
|
113
|
-
return
|
89
|
+
const isSelected = (tree) => {
|
90
|
+
return tree && selectedCommentKey === tree.comment.key;
|
114
91
|
};
|
115
92
|
if (!view) {
|
116
93
|
return null;
|
117
94
|
}
|
118
|
-
if (!
|
95
|
+
if (!trees.length) {
|
119
96
|
return React.createElement(CommentsPlaceholder, null);
|
120
97
|
}
|
121
98
|
return (React.createElement(React.Fragment, null,
|
@@ -123,8 +100,8 @@ export const CommentsPanel = () => {
|
|
123
100
|
React.createElement(CheckboxLabel, null,
|
124
101
|
React.createElement(CheckboxField, { name: 'show-resolved', checked: showResolved, onChange: (e) => setShowResolved(e.target.checked) }),
|
125
102
|
React.createElement(CheckboxLabelText, null, "See resolved"))),
|
126
|
-
|
103
|
+
trees
|
127
104
|
.filter((c) => showResolved || !c.comment.node.attrs.resolved)
|
128
|
-
.map((c, i, a) => (React.createElement(CommentThread, { key: c.comment.node.attrs.id, ref: isSelected(c) && !isSelected(a[i - 1]) ? selectedRef : null,
|
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 })))));
|
129
106
|
};
|
130
107
|
//# 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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C,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,EAChE,IAAI,EAAE,CAAC,EACP,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,GACtB,CACH,CAAC,CACH,CACJ,CAAA;AACH,CAAC,CAAA"}
|
package/dist/es/lib/comments.js
CHANGED
@@ -1,15 +1,3 @@
|
|
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';
|
13
1
|
export const getAuthorID = (comment) => {
|
14
2
|
const contributions = comment.node.attrs.contributions;
|
15
3
|
if (!contributions?.length) {
|
@@ -17,14 +5,11 @@ export const getAuthorID = (comment) => {
|
|
17
5
|
}
|
18
6
|
return contributions[0].profileID;
|
19
7
|
};
|
20
|
-
export const
|
21
|
-
return comments
|
22
|
-
.filter((c) => !isReply(c)) // Filter out replies
|
23
|
-
.map((c) => ({
|
8
|
+
export const buildCommentTrees = (comments, newCommentID) => {
|
9
|
+
return comments.map((c) => ({
|
24
10
|
comment: c,
|
25
11
|
isNew: newCommentID === c.node.attrs.id,
|
26
|
-
|
27
|
-
),
|
12
|
+
children: [],
|
28
13
|
}));
|
29
14
|
};
|
30
15
|
export const buildAuthorName = (user) => {
|
@@ -35,9 +20,4 @@ export const buildAuthorName = (user) => {
|
|
35
20
|
.filter(Boolean)
|
36
21
|
.join(' ');
|
37
22
|
};
|
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
|
-
};
|
43
23
|
//# 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":"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"}
|
@@ -11,13 +11,12 @@
|
|
11
11
|
*/
|
12
12
|
import { CommentAttrs } from '@manuscripts/body-editor';
|
13
13
|
import React from 'react';
|
14
|
-
import {
|
14
|
+
import { CommentTree } from '../../lib/comments';
|
15
15
|
export interface CommentThreadProps {
|
16
|
-
|
16
|
+
tree: CommentTree;
|
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;
|
22
21
|
}
|
23
22
|
export declare const CommentThread: React.ForwardRefExoticComponent<CommentThreadProps & React.RefAttributes<HTMLDivElement>>;
|
@@ -11,12 +11,11 @@
|
|
11
11
|
*/
|
12
12
|
import { Comment } from '@manuscripts/body-editor';
|
13
13
|
import { UserProfile } from '@manuscripts/json-schema';
|
14
|
-
export type
|
14
|
+
export type CommentTree = {
|
15
15
|
comment: Comment;
|
16
16
|
isNew: boolean;
|
17
|
-
|
17
|
+
children: CommentTree[];
|
18
18
|
};
|
19
19
|
export declare const getAuthorID: (comment: Comment) => string | undefined;
|
20
|
-
export declare const
|
20
|
+
export declare const buildCommentTrees: (comments: Comment[], newCommentID?: string) => CommentTree[];
|
21
21
|
export declare const buildAuthorName: (user: UserProfile | undefined) => string;
|
22
|
-
export declare const commentsByTime: (a: Comment, b: Comment) => number;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@manuscripts/article-editor",
|
3
|
-
"version": "3.2.19
|
3
|
+
"version": "3.2.19",
|
4
4
|
"license": "CPAL-1.0",
|
5
5
|
"description": "React components for editing and viewing manuscripts",
|
6
6
|
"repository": "github:Atypon-OpenSource/manuscripts-article-editor",
|
@@ -35,12 +35,12 @@
|
|
35
35
|
"@fontsource/lato": "^4.5.10",
|
36
36
|
"@fontsource/pt-sans": "^4.5.11",
|
37
37
|
"@fontsource/pt-serif": "^4.5.11",
|
38
|
-
"@manuscripts/body-editor": "2.2.20
|
38
|
+
"@manuscripts/body-editor": "2.2.20",
|
39
39
|
"@manuscripts/json-schema": "2.2.11",
|
40
40
|
"@manuscripts/library": "1.3.11",
|
41
41
|
"@manuscripts/style-guide": "2.0.21",
|
42
42
|
"@manuscripts/track-changes-plugin": "1.7.23",
|
43
|
-
"@manuscripts/transform": "3.0.
|
43
|
+
"@manuscripts/transform": "3.0.5",
|
44
44
|
"@popperjs/core": "^2.11.8",
|
45
45
|
"@reach/tabs": "^0.18.0",
|
46
46
|
"@types/use-sync-external-store": "^0.0.6",
|
@@ -108,4 +108,4 @@
|
|
108
108
|
"resolutions": {
|
109
109
|
"@types/react": "^18.3.1"
|
110
110
|
}
|
111
|
-
}
|
111
|
+
}
|
@@ -1,162 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
-
if (k2 === undefined) k2 = k;
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
-
}
|
8
|
-
Object.defineProperty(o, k2, desc);
|
9
|
-
}) : (function(o, m, k, k2) {
|
10
|
-
if (k2 === undefined) k2 = k;
|
11
|
-
o[k2] = m[k];
|
12
|
-
}));
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
-
}) : function(o, v) {
|
16
|
-
o["default"] = v;
|
17
|
-
});
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
19
|
-
if (mod && mod.__esModule) return mod;
|
20
|
-
var result = {};
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
22
|
-
__setModuleDefault(result, mod);
|
23
|
-
return result;
|
24
|
-
};
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
27
|
-
};
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
29
|
-
exports.CommentCard = void 0;
|
30
|
-
const style_guide_1 = require("@manuscripts/style-guide");
|
31
|
-
const react_1 = __importStar(require("react"));
|
32
|
-
const styled_components_1 = __importDefault(require("styled-components"));
|
33
|
-
const comments_1 = require("../../lib/comments");
|
34
|
-
const store_1 = require("../../store");
|
35
|
-
const CommentActions_1 = require("./CommentActions");
|
36
|
-
const CommentBody_1 = require("./CommentBody");
|
37
|
-
const DeleteCommentConfirmation_1 = require("./DeleteCommentConfirmation");
|
38
|
-
const CommentHeader = styled_components_1.default.div `
|
39
|
-
display: flex;
|
40
|
-
justify-content: space-between;
|
41
|
-
margin-bottom: 8px;
|
42
|
-
`;
|
43
|
-
const CommentMetadata = styled_components_1.default.div `
|
44
|
-
display: flex;
|
45
|
-
align-items: center;
|
46
|
-
padding-right: 8px;
|
47
|
-
`;
|
48
|
-
const CommentAuthor = styled_components_1.default.div `
|
49
|
-
display: flex;
|
50
|
-
color: #353535;
|
51
|
-
font-weight: 400;
|
52
|
-
max-width: 200px;
|
53
|
-
white-space: nowrap;
|
54
|
-
overflow: hidden;
|
55
|
-
text-overflow: ellipsis;
|
56
|
-
width: 100%;
|
57
|
-
|
58
|
-
svg {
|
59
|
-
padding-right: 10px;
|
60
|
-
}
|
61
|
-
`;
|
62
|
-
const CommentTarget = styled_components_1.default.div `
|
63
|
-
font-size: 14px;
|
64
|
-
color: #353535;
|
65
|
-
background-color: #ffeebf;
|
66
|
-
padding: 4px 8px;
|
67
|
-
margin-top: 16px;
|
68
|
-
margin-bottom: 16px;
|
69
|
-
`;
|
70
|
-
const Timestamp = (0, styled_components_1.default)(style_guide_1.RelativeDate) `
|
71
|
-
font-size: 12px;
|
72
|
-
line-height: 16px;
|
73
|
-
font-weight: 400;
|
74
|
-
color: #6e6e6e;
|
75
|
-
white-space: nowrap;
|
76
|
-
padding-right: 8px;
|
77
|
-
`;
|
78
|
-
const RepliesCount = styled_components_1.default.div `
|
79
|
-
border-radius: 50%;
|
80
|
-
width: 20px;
|
81
|
-
height: 12px;
|
82
|
-
color: #ffffff;
|
83
|
-
background-color: #1a9bc7;
|
84
|
-
text-align: center;
|
85
|
-
font-size: 9px;
|
86
|
-
`;
|
87
|
-
const Card = styled_components_1.default.div `
|
88
|
-
position: relative;
|
89
|
-
`;
|
90
|
-
const CommentCard = ({ comment, isReply, numOfReplies, isNew, isEndOfThread, onSave, onDelete, onSelect, }) => {
|
91
|
-
const can = (0, style_guide_1.usePermissions)();
|
92
|
-
const [{ user, collaboratorsById }] = (0, store_1.useStore)((state) => ({
|
93
|
-
user: state.user,
|
94
|
-
collaboratorsById: state.collaboratorsById,
|
95
|
-
}));
|
96
|
-
const authorID = (0, comments_1.getAuthorID)(comment);
|
97
|
-
const authorName = authorID
|
98
|
-
? (0, comments_1.buildAuthorName)(collaboratorsById.get(authorID))
|
99
|
-
: '';
|
100
|
-
const timestamp = comment.node.attrs.contributions?.[0].timestamp;
|
101
|
-
const isOwn = authorID === user._id;
|
102
|
-
const isResolveEnabled = isOwn
|
103
|
-
? can.resolveOwnComment
|
104
|
-
: can.resolveOthersComment;
|
105
|
-
const isActionsEnabled = isOwn
|
106
|
-
? can.handleOwnComments
|
107
|
-
: can.handleOthersComments;
|
108
|
-
const [isEditing, setEditing] = (0, react_1.useState)(isNew);
|
109
|
-
const [showDeleteConfirmation, setShowDeleteConfirmation] = (0, react_1.useState)(false);
|
110
|
-
const handleEdit = () => {
|
111
|
-
setEditing(true);
|
112
|
-
onSelect();
|
113
|
-
};
|
114
|
-
const handleSave = (contents) => {
|
115
|
-
onSave({
|
116
|
-
...comment.node.attrs,
|
117
|
-
contents,
|
118
|
-
});
|
119
|
-
setEditing(false);
|
120
|
-
};
|
121
|
-
const handleCancel = () => {
|
122
|
-
setEditing(false);
|
123
|
-
if (isNew) {
|
124
|
-
onDelete(comment.node.attrs.id);
|
125
|
-
}
|
126
|
-
};
|
127
|
-
const handleToggleResolve = () => {
|
128
|
-
onSave({
|
129
|
-
...comment.node.attrs,
|
130
|
-
resolved: !comment.node.attrs.resolved,
|
131
|
-
});
|
132
|
-
};
|
133
|
-
const handleDelete = () => {
|
134
|
-
setShowDeleteConfirmation(true);
|
135
|
-
};
|
136
|
-
const confirmDelete = () => {
|
137
|
-
onDelete(comment.node.attrs.id);
|
138
|
-
setShowDeleteConfirmation(false);
|
139
|
-
};
|
140
|
-
const cancelDelete = () => {
|
141
|
-
setShowDeleteConfirmation(false);
|
142
|
-
};
|
143
|
-
return (react_1.default.createElement(Card, null,
|
144
|
-
react_1.default.createElement(CommentHeader, { "data-cy": "comment-header" },
|
145
|
-
react_1.default.createElement(CommentMetadata, null,
|
146
|
-
react_1.default.createElement(CommentAuthor, null, authorName ? (react_1.default.createElement(react_1.default.Fragment, null,
|
147
|
-
react_1.default.createElement(style_guide_1.AvatarIcon, { width: 20, height: 20 }),
|
148
|
-
react_1.default.createElement(CommentAuthor, null, authorName))) : (!isReply && (react_1.default.createElement(react_1.default.Fragment, null,
|
149
|
-
react_1.default.createElement(style_guide_1.SystemUserAvatarIcon, { width: 20, height: 20 }),
|
150
|
-
react_1.default.createElement(CommentAuthor, null, "System"))))),
|
151
|
-
timestamp && react_1.default.createElement(Timestamp, { date: timestamp * 1000 }),
|
152
|
-
numOfReplies !== 0 && react_1.default.createElement(RepliesCount, null,
|
153
|
-
" ",
|
154
|
-
numOfReplies,
|
155
|
-
" ")),
|
156
|
-
react_1.default.createElement(CommentActions_1.CommentActions, { comment: comment, isResolveEnabled: isResolveEnabled && !isReply, isActionsEnabled: isActionsEnabled && isEndOfThread, onDelete: handleDelete, onEdit: handleEdit, toggleResolve: handleToggleResolve })),
|
157
|
-
comment.node.attrs.originalText && (react_1.default.createElement(CommentTarget, null, comment.node.attrs.originalText)),
|
158
|
-
react_1.default.createElement(CommentBody_1.CommentBody, { comment: comment, isEditing: isNew || isEditing, onSave: handleSave, onCancel: handleCancel, onSelect: onSelect }),
|
159
|
-
showDeleteConfirmation && (react_1.default.createElement(DeleteCommentConfirmation_1.DeleteCommentConfirmation, { onCancel: cancelDelete, onConfirm: confirmDelete }))));
|
160
|
-
};
|
161
|
-
exports.CommentCard = CommentCard;
|
162
|
-
//# sourceMappingURL=CommentCard.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"CommentCard.js","sourceRoot":"","sources":["../../../../src/components/comments/CommentCard.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,0DAKiC;AACjC,+CAAuC;AACvC,0EAAsC;AAEtC,iDAAiE;AACjE,uCAAsC;AACtC,qDAAiD;AACjD,+CAA2C;AAC3C,2EAAuE;AAEvE,MAAM,aAAa,GAAG,2BAAM,CAAC,GAAG,CAAA;;;;CAI/B,CAAA;AAED,MAAM,eAAe,GAAG,2BAAM,CAAC,GAAG,CAAA;;;;CAIjC,CAAA;AAED,MAAM,aAAa,GAAG,2BAAM,CAAC,GAAG,CAAA;;;;;;;;;;;;;CAa/B,CAAA;AACD,MAAM,aAAa,GAAG,2BAAM,CAAC,GAAG,CAAA;;;;;;;CAO/B,CAAA;AAED,MAAM,SAAS,GAAG,IAAA,2BAAM,EAAC,0BAAY,CAAC,CAAA;;;;;;;CAOrC,CAAA;AACD,MAAM,YAAY,GAAG,2BAAM,CAAC,GAAG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