@manuscripts/style-guide 1.12.17-LEAN-3720.0 → 1.13.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/EditorHeader/EditorHeader.js +210 -0
- package/dist/cjs/components/EditorHeader/ProceedView.js +195 -0
- package/dist/cjs/components/RelativeDate.js +16 -4
- package/dist/cjs/index.js +1 -2
- package/dist/es/components/EditorHeader/EditorHeader.js +180 -0
- package/dist/es/components/EditorHeader/ProceedView.js +165 -0
- package/dist/es/components/RelativeDate.js +16 -4
- package/dist/es/index.js +1 -2
- package/dist/types/components/EditorHeader/EditorHeader.d.ts +68 -0
- package/dist/types/components/EditorHeader/ProceedView.d.ts +22 -0
- package/dist/types/components/RelativeDate.d.ts +4 -3
- package/dist/types/index.d.ts +1 -2
- package/package.json +1 -1
- package/dist/cjs/components/Comments/CommentActions.js +0 -98
- package/dist/cjs/components/Comments/CommentBody.js +0 -160
- package/dist/cjs/components/Comments/CommentTarget.js +0 -55
- package/dist/cjs/components/Comments/CommentUser.js +0 -76
- package/dist/cjs/components/Comments/CommentWrapper.js +0 -118
- package/dist/cjs/components/Comments/ResolveButton.js +0 -66
- package/dist/cjs/components/Comments/index.js +0 -21
- package/dist/cjs/components/ManuscriptNoteList.js +0 -210
- package/dist/es/components/Comments/CommentActions.js +0 -68
- package/dist/es/components/Comments/CommentBody.js +0 -131
- package/dist/es/components/Comments/CommentTarget.js +0 -29
- package/dist/es/components/Comments/CommentUser.js +0 -69
- package/dist/es/components/Comments/CommentWrapper.js +0 -88
- package/dist/es/components/Comments/ResolveButton.js +0 -59
- package/dist/es/components/Comments/index.js +0 -5
- package/dist/es/components/ManuscriptNoteList.js +0 -181
- package/dist/types/components/Comments/CommentActions.d.ts +0 -28
- package/dist/types/components/Comments/CommentBody.d.ts +0 -39
- package/dist/types/components/Comments/CommentTarget.d.ts +0 -21
- package/dist/types/components/Comments/CommentUser.d.ts +0 -23
- package/dist/types/components/Comments/CommentWrapper.d.ts +0 -26
- package/dist/types/components/Comments/ResolveButton.d.ts +0 -21
- package/dist/types/components/Comments/index.d.ts +0 -5
- package/dist/types/components/ManuscriptNoteList.d.ts +0 -45
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* © 2020 Atypon Systems LLC
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import { Field, Form, Formik } from 'formik';
|
|
17
|
-
import React, { useEffect } from 'react';
|
|
18
|
-
import styled from 'styled-components';
|
|
19
|
-
import { ButtonGroup, PrimaryButton, SecondaryButton } from '../Button';
|
|
20
|
-
import { FormError } from '../Form';
|
|
21
|
-
import { CommentReplyIcon } from '../icons';
|
|
22
|
-
import { Tooltip } from '../Tooltip';
|
|
23
|
-
export const CommentBody = React.memo(({ comment, saveComment, deleteComment, isReply, isNew, handleCreateReply, setIsEditing, scrollIntoHighlight, onFocusOut, isEditing, isProdNote, }) => {
|
|
24
|
-
useEffect(() => {
|
|
25
|
-
if (isNew) {
|
|
26
|
-
setIsEditing(true);
|
|
27
|
-
}
|
|
28
|
-
}, [isNew, setIsEditing]);
|
|
29
|
-
const cancelEditing = () => {
|
|
30
|
-
setIsEditing(false);
|
|
31
|
-
if (isNew) {
|
|
32
|
-
deleteComment(comment._id);
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
return (React.createElement(React.Fragment, null, isEditing ? (React.createElement(Formik, { initialValues: comment, onSubmit: (values, actions) => {
|
|
36
|
-
actions.setSubmitting(true);
|
|
37
|
-
saveComment(values);
|
|
38
|
-
setIsEditing(false);
|
|
39
|
-
} }, ({ errors, values, setFieldValue }) => (React.createElement(Form, null,
|
|
40
|
-
errors.contents && React.createElement(FormError, null, errors.contents),
|
|
41
|
-
React.createElement(Field, { name: 'contents' }, (props) => (React.createElement(CommentContent, null,
|
|
42
|
-
React.createElement(StyledCommentField, { id: comment._id, autoFocus: isEditing, value: values.contents, onChange: (event) => setFieldValue(props.field.name, event.target.value), onBlur: (event) => onFocusOut &&
|
|
43
|
-
onFocusOut(comment._id, event.target.value), placeholder: !isReply ? 'Comment...' : 'Reply...' })))),
|
|
44
|
-
React.createElement(EditingCommentFooter, null,
|
|
45
|
-
React.createElement(Actions, null,
|
|
46
|
-
React.createElement(SecondaryButton, { onClick: cancelEditing }, "Cancel"),
|
|
47
|
-
React.createElement(PrimaryButton, { disabled: !values.contents.replace(/<[^>]+>/g, '').length ||
|
|
48
|
-
(!isNew &&
|
|
49
|
-
(comment.contents === values.contents ||
|
|
50
|
-
!values.contents.replace(/<[^>]+>/g, '').length)), type: "submit" }, "Save"))))))) : (React.createElement("div", null,
|
|
51
|
-
React.createElement(CommentContent, { onClick: () => scrollIntoHighlight && scrollIntoHighlight(comment) },
|
|
52
|
-
React.createElement(StyledCommentViewer, { "data-cy": "note-text" }, comment.contents)),
|
|
53
|
-
!isReply && (React.createElement(CommentFooter, null,
|
|
54
|
-
React.createElement("span", null,
|
|
55
|
-
React.createElement(ActionButton, { hidden: !isProdNote, "data-tooltip-id": `reply-${comment._id}`, onClick: () => handleCreateReply(comment._id), "aria-label": 'reply', className: "reply-button note-actions" },
|
|
56
|
-
React.createElement(CommentReplyIcon, null))),
|
|
57
|
-
React.createElement(Tooltip, { id: `reply-${comment._id}`, place: "bottom" }, "Reply")))))));
|
|
58
|
-
});
|
|
59
|
-
const CommentFooter = styled.div `
|
|
60
|
-
margin-bottom: ${(props) => props.theme.grid.unit * 2}px;
|
|
61
|
-
padding: ${(props) => props.theme.grid.unit * 2}px
|
|
62
|
-
${(props) => props.theme.grid.unit * 2}px 0;
|
|
63
|
-
display: flex;
|
|
64
|
-
justify-content: flex-end;
|
|
65
|
-
height: ${(props) => props.theme.grid.unit * 6}px;
|
|
66
|
-
`;
|
|
67
|
-
const EditingCommentFooter = styled(CommentFooter) `
|
|
68
|
-
justify-content: flex-end;
|
|
69
|
-
padding: ${(props) => props.theme.grid.unit * 2}px
|
|
70
|
-
${(props) => props.theme.grid.unit * 4}px 0;
|
|
71
|
-
`;
|
|
72
|
-
const ActionButton = styled.button `
|
|
73
|
-
border: none;
|
|
74
|
-
background: none;
|
|
75
|
-
cursor: pointer;
|
|
76
|
-
&:not([disabled]):hover {
|
|
77
|
-
path {
|
|
78
|
-
stroke: ${(props) => props.theme.colors.brand.medium};
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
`;
|
|
82
|
-
const CommentContent = styled.div `
|
|
83
|
-
cursor: pointer;
|
|
84
|
-
padding: 0 ${(props) => props.theme.grid.unit * 4}px;
|
|
85
|
-
`;
|
|
86
|
-
const StyledCommentField = styled.textarea `
|
|
87
|
-
cursor: text;
|
|
88
|
-
font-family: ${(props) => props.theme.font.family.sans};
|
|
89
|
-
color: ${(props) => props.theme.colors.text.primary};
|
|
90
|
-
margin: ${(props) => props.theme.grid.unit * 2}px 0;
|
|
91
|
-
resize: none;
|
|
92
|
-
|
|
93
|
-
width: 100%;
|
|
94
|
-
outline: 0;
|
|
95
|
-
border: 1px solid #e2e2e2;
|
|
96
|
-
border-radius: 6px;
|
|
97
|
-
|
|
98
|
-
&:focus {
|
|
99
|
-
background: #f2fbfc;
|
|
100
|
-
border: 1px solid #bce7f6;
|
|
101
|
-
border-radius: 6px;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
.empty-node::before {
|
|
105
|
-
position: absolute;
|
|
106
|
-
color: #c9c9c9;
|
|
107
|
-
cursor: text;
|
|
108
|
-
pointer-events: none;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
box-sizing: border-box;
|
|
112
|
-
padding: 3px 16px 3px 16px;
|
|
113
|
-
font-style: normal;
|
|
114
|
-
font-weight: normal;
|
|
115
|
-
font-size: 14px;
|
|
116
|
-
line-height: 24px;
|
|
117
|
-
`;
|
|
118
|
-
const StyledCommentViewer = styled.div `
|
|
119
|
-
flex: 1;
|
|
120
|
-
|
|
121
|
-
font-family: ${(props) => props.theme.font.family.sans};
|
|
122
|
-
line-height: 1.06;
|
|
123
|
-
letter-spacing: -0.2px;
|
|
124
|
-
color: ${(props) => props.theme.colors.text.primary};
|
|
125
|
-
margin: ${(props) => props.theme.grid.unit * 2}px 0;
|
|
126
|
-
`;
|
|
127
|
-
const Actions = styled(ButtonGroup) `
|
|
128
|
-
& button:not(:last-of-type) {
|
|
129
|
-
margin-right: 4px;
|
|
130
|
-
}
|
|
131
|
-
`;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* © 2020 Atypon Systems LLC
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import React, { useEffect } from 'react';
|
|
17
|
-
export const CommentTarget = React.memo(({ isSelected, children }) => {
|
|
18
|
-
const threadRef = React.createRef();
|
|
19
|
-
useEffect(() => {
|
|
20
|
-
if (threadRef.current && isSelected) {
|
|
21
|
-
threadRef.current.scrollIntoView({
|
|
22
|
-
behavior: 'smooth',
|
|
23
|
-
block: 'start',
|
|
24
|
-
inline: 'nearest',
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
return (React.createElement("div", { "data-cy": "comment-target", ref: threadRef }, children));
|
|
29
|
-
});
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* © 2020 Atypon Systems LLC
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import React from 'react';
|
|
17
|
-
import styled from 'styled-components';
|
|
18
|
-
import { Avatar } from '../Avatar';
|
|
19
|
-
import { LightRelativeDate } from '../ManuscriptNoteList';
|
|
20
|
-
const CommentUserContainer = styled.div `
|
|
21
|
-
display: flex;
|
|
22
|
-
`;
|
|
23
|
-
const CommentUserName = styled.div `
|
|
24
|
-
margin: 0 ${(props) => props.theme.grid.unit * 2}px;
|
|
25
|
-
font-weight: ${(props) => props.theme.font.weight.normal};
|
|
26
|
-
max-width: ${(props) => props.theme.grid.unit * 50}px;
|
|
27
|
-
white-space: nowrap;
|
|
28
|
-
overflow: hidden;
|
|
29
|
-
text-overflow: ellipsis;
|
|
30
|
-
`;
|
|
31
|
-
const DateText = styled(CommentUserName) `
|
|
32
|
-
font-size: ${(props) => props.theme.font.size.small};
|
|
33
|
-
line-height: ${(props) => props.theme.font.lineHeight.normal};
|
|
34
|
-
font-weight: ${(props) => props.theme.font.weight.normal};
|
|
35
|
-
color: ${(props) => props.theme.colors.text.secondary};
|
|
36
|
-
`;
|
|
37
|
-
const Header = styled.div `
|
|
38
|
-
display: flex;
|
|
39
|
-
flex-direction: column;
|
|
40
|
-
font-size: ${(props) => props.theme.font.size.normal};
|
|
41
|
-
`;
|
|
42
|
-
export const CommentUser = ({ contributions, getCollaboratorById, displayName, createdAt }) => {
|
|
43
|
-
if (!contributions || !contributions.length) {
|
|
44
|
-
return (React.createElement(CommentUserContainer, null,
|
|
45
|
-
React.createElement(Header, null,
|
|
46
|
-
React.createElement(Avatar, { size: 20 })),
|
|
47
|
-
React.createElement(Header, null,
|
|
48
|
-
React.createElement(CommentUserName, null,
|
|
49
|
-
"By ",
|
|
50
|
-
displayName || '(unknown user)'),
|
|
51
|
-
React.createElement(DateText, null,
|
|
52
|
-
React.createElement(LightRelativeDate, { createdAt: createdAt })))));
|
|
53
|
-
}
|
|
54
|
-
const [contribution] = contributions;
|
|
55
|
-
const user = getCollaboratorById(contribution.profileID);
|
|
56
|
-
const buildName = (name) => [name.given, name.family].filter((item) => item).join(' ');
|
|
57
|
-
if (!user) {
|
|
58
|
-
return null;
|
|
59
|
-
}
|
|
60
|
-
return (React.createElement(CommentUserContainer, null,
|
|
61
|
-
React.createElement(Header, null,
|
|
62
|
-
React.createElement(Avatar, { size: 20 })),
|
|
63
|
-
React.createElement(Header, null,
|
|
64
|
-
React.createElement(CommentUserName, null,
|
|
65
|
-
"By ",
|
|
66
|
-
buildName(user.bibliographicName)),
|
|
67
|
-
React.createElement(DateText, null,
|
|
68
|
-
React.createElement(LightRelativeDate, { createdAt: createdAt })))));
|
|
69
|
-
};
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* © 2020 Atypon Systems LLC
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
17
|
-
import styled from 'styled-components';
|
|
18
|
-
import { isSavedComment } from '../../lib/comments';
|
|
19
|
-
import { CommentActions } from './CommentActions';
|
|
20
|
-
import { CommentBody } from './CommentBody';
|
|
21
|
-
import { CommentUser } from './CommentUser';
|
|
22
|
-
const isOwn = (comment, userId) => {
|
|
23
|
-
var _a;
|
|
24
|
-
return comment.contributions
|
|
25
|
-
? (_a = comment.contributions) === null || _a === void 0 ? void 0 : _a.some((c) => c.profileID === userId)
|
|
26
|
-
: false;
|
|
27
|
-
};
|
|
28
|
-
export const CommentWrapper = ({ createKeyword, comment, can, currentUserId, getCollaborator, getKeyword, listCollaborators, listKeywords, saveComment, deleteComment, isReply, isNew, handleCreateReply, handleSetResolved, isProdNote, isSelected, handleRequestSelect, scrollIntoHighlight, onFocusOut, children, }) => {
|
|
29
|
-
const [isEditing, setIsEditing] = useState();
|
|
30
|
-
const threadRef = useRef(null);
|
|
31
|
-
useEffect(() => {
|
|
32
|
-
if (isNew || isSelected) {
|
|
33
|
-
{
|
|
34
|
-
isNew && setIsEditing(true);
|
|
35
|
-
}
|
|
36
|
-
if (threadRef.current) {
|
|
37
|
-
setTimeout(() => {
|
|
38
|
-
var _a;
|
|
39
|
-
return (_a = threadRef.current) === null || _a === void 0 ? void 0 : _a.scrollIntoView({
|
|
40
|
-
block: 'nearest',
|
|
41
|
-
inline: 'nearest',
|
|
42
|
-
});
|
|
43
|
-
}, 100);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}, [isNew, isSelected]);
|
|
47
|
-
const onTitleMouseDown = useCallback((e) => {
|
|
48
|
-
e.preventDefault();
|
|
49
|
-
handleRequestSelect && handleRequestSelect();
|
|
50
|
-
}, [handleRequestSelect]);
|
|
51
|
-
const onTitleKeyDown = useCallback((e) => {
|
|
52
|
-
if ([' ', 'Enter'].includes(e.key)) {
|
|
53
|
-
e.preventDefault();
|
|
54
|
-
handleRequestSelect && handleRequestSelect();
|
|
55
|
-
}
|
|
56
|
-
}, [handleRequestSelect]);
|
|
57
|
-
const isOwnComment = useMemo(() => isOwn(comment, currentUserId), [comment, currentUserId]);
|
|
58
|
-
return (React.createElement(Note, { "data-cy": "note", ref: threadRef, isSelected: isSelected },
|
|
59
|
-
React.createElement(NoteHeader, { "data-cy": "note-header" },
|
|
60
|
-
React.createElement(NoteTitle, { type: "button", onMouseDown: onTitleMouseDown, onKeyDown: onTitleKeyDown }, comment.contributions && (React.createElement(CommentUser, { contributions: comment.contributions, getCollaboratorById: getCollaborator, displayName: comment.displayName, createdAt: isSavedComment(comment) ? comment.createdAt * 1000 : undefined }))),
|
|
61
|
-
React.createElement(CommentActions, { id: comment._id, isOwnComment: isOwnComment, can: can, target: comment.target, isResolved: comment.resolved, handleSetResolved: handleSetResolved, deleteComment: deleteComment, setIsEditing: setIsEditing, isProdNote: isProdNote })),
|
|
62
|
-
children,
|
|
63
|
-
React.createElement(CommentBody, { createKeyword: createKeyword, onFocusOut: onFocusOut, comment: comment, deleteComment: deleteComment, getCollaborator: getCollaborator, getKeyword: getKeyword, listCollaborators: listCollaborators, listKeywords: listKeywords, isReply: isReply, saveComment: saveComment, handleCreateReply: handleCreateReply, scrollIntoHighlight: scrollIntoHighlight, isNew: isNew, setIsEditing: setIsEditing, isEditing: isEditing, isProdNote: isProdNote })));
|
|
64
|
-
};
|
|
65
|
-
const Note = styled.div `
|
|
66
|
-
& .note-actions {
|
|
67
|
-
opacity: 0;
|
|
68
|
-
${({ isSelected }) => isSelected && 'opacity: 1'}
|
|
69
|
-
transition: 0.1s ease-in-out opacity;
|
|
70
|
-
}
|
|
71
|
-
&:hover .note-actions {
|
|
72
|
-
opacity: 1;
|
|
73
|
-
}
|
|
74
|
-
`;
|
|
75
|
-
const NoteTitle = styled.button `
|
|
76
|
-
border: none;
|
|
77
|
-
background: transparent;
|
|
78
|
-
padding: 0;
|
|
79
|
-
text-align: left;
|
|
80
|
-
`;
|
|
81
|
-
const NoteHeader = styled.div `
|
|
82
|
-
display: flex;
|
|
83
|
-
justify-content: space-between;
|
|
84
|
-
align-items: center;
|
|
85
|
-
font-size: ${(props) => props.theme.font.size.normal};
|
|
86
|
-
margin-bottom: 16px;
|
|
87
|
-
padding: 0 16px;
|
|
88
|
-
`;
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* © 2021 Atypon Systems LLC
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import React from 'react';
|
|
17
|
-
import styled from 'styled-components';
|
|
18
|
-
import { CommentResolveIcon } from '../icons';
|
|
19
|
-
import { Tooltip } from '../Tooltip';
|
|
20
|
-
export const ResolveButton = ({ id, resolved, resolvedCallback }) => {
|
|
21
|
-
return (React.createElement(Container, null,
|
|
22
|
-
React.createElement(Button, { className: resolved ? 'resolved' : '', "data-tooltip-id": id, onClick: resolvedCallback },
|
|
23
|
-
React.createElement(CommentResolveIcon, null)),
|
|
24
|
-
React.createElement(Tooltip, { id: id, place: "bottom" }, (resolved && 'Unresolve') || 'Resolve')));
|
|
25
|
-
};
|
|
26
|
-
const Container = styled.div `
|
|
27
|
-
display: flex;
|
|
28
|
-
justify-content: space-between;
|
|
29
|
-
align-items: center;
|
|
30
|
-
margin-right: ${(props) => props.theme.grid.unit};
|
|
31
|
-
`;
|
|
32
|
-
const Button = styled.button `
|
|
33
|
-
display: flex;
|
|
34
|
-
align-items: center;
|
|
35
|
-
width: 24px;
|
|
36
|
-
height: 24px;
|
|
37
|
-
border-radius: 12px;
|
|
38
|
-
border: none;
|
|
39
|
-
background: #ffffff;
|
|
40
|
-
padding: 0;
|
|
41
|
-
cursor: pointer;
|
|
42
|
-
|
|
43
|
-
&.resolved {
|
|
44
|
-
background: #f2fbfc;
|
|
45
|
-
border: 1px solid #bce7f6;
|
|
46
|
-
path {
|
|
47
|
-
fill: #1a9bc7;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
&:not([disabled]):hover,
|
|
52
|
-
&:not([disabled]):active {
|
|
53
|
-
path {
|
|
54
|
-
fill: #1a9bc7;
|
|
55
|
-
}
|
|
56
|
-
background: #f2fbfc;
|
|
57
|
-
border: 1px solid #c9c9c9;
|
|
58
|
-
}
|
|
59
|
-
`;
|
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* © 2020 Atypon Systems LLC
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
17
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
18
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
19
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
20
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
21
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
22
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
|
-
import { ObjectTypes, } from '@manuscripts/json-schema';
|
|
26
|
-
import { buildContribution, buildNote } from '@manuscripts/transform';
|
|
27
|
-
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
28
|
-
import styled from 'styled-components';
|
|
29
|
-
import { v4 as uuid } from 'uuid';
|
|
30
|
-
import { buildNoteTree, } from '../lib/comments';
|
|
31
|
-
import { IconTextButton } from './Button';
|
|
32
|
-
import { CheckboxField, CheckboxLabel } from './Checkbox';
|
|
33
|
-
import { CommentTarget } from './Comments/CommentTarget';
|
|
34
|
-
import { CommentWrapper } from './Comments/CommentWrapper';
|
|
35
|
-
import { AddIcon } from './icons';
|
|
36
|
-
import { RelativeDate } from './RelativeDate';
|
|
37
|
-
export const ManuscriptNoteList = React.memo(({ createKeyword, deleteModel, getCollaboratorById, currentUserId, displayName, getKeyword, listCollaborators, listKeywords, notes, noteSource, saveModel, selected, can, }) => {
|
|
38
|
-
const [newComment, setNewComment] = useState();
|
|
39
|
-
const [selectResolved, setSelectResolved] = useState(false);
|
|
40
|
-
const [noteTarget, setNoteTarget] = useState();
|
|
41
|
-
useEffect(() => {
|
|
42
|
-
if (noteTarget && !newComment) {
|
|
43
|
-
const newComment = buildNote(noteTarget, noteSource);
|
|
44
|
-
newComment.displayName = displayName;
|
|
45
|
-
if (currentUserId) {
|
|
46
|
-
const contribution = buildContribution(currentUserId);
|
|
47
|
-
newComment.contributions = [contribution];
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
newComment.contributions = [];
|
|
51
|
-
}
|
|
52
|
-
setNewComment(newComment);
|
|
53
|
-
}
|
|
54
|
-
}, [noteTarget, currentUserId, displayName, newComment, noteSource]);
|
|
55
|
-
const items = useMemo(() => {
|
|
56
|
-
const combinedComments = [...notes];
|
|
57
|
-
if (newComment) {
|
|
58
|
-
combinedComments.push(newComment);
|
|
59
|
-
}
|
|
60
|
-
const commentsTreeMap = buildNoteTree(combinedComments);
|
|
61
|
-
return Array.from(commentsTreeMap.entries());
|
|
62
|
-
}, [notes, newComment]);
|
|
63
|
-
const handleAddNewNote = useCallback((event) => {
|
|
64
|
-
event.preventDefault();
|
|
65
|
-
setNoteTarget(ObjectTypes.ManuscriptNote + ':' + uuid().toUpperCase());
|
|
66
|
-
setSelectResolved(false);
|
|
67
|
-
}, [setNoteTarget]);
|
|
68
|
-
const deleteNote = useCallback((id) => {
|
|
69
|
-
return deleteModel(id).finally(() => {
|
|
70
|
-
if (newComment && newComment._id === id) {
|
|
71
|
-
setNoteTarget(undefined);
|
|
72
|
-
setNewComment(undefined);
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
}, [deleteModel, newComment, setNoteTarget]);
|
|
76
|
-
const saveNote = useCallback((note) => {
|
|
77
|
-
return saveModel(note).then((note) => {
|
|
78
|
-
if (newComment && newComment._id === note._id) {
|
|
79
|
-
setNoteTarget(undefined);
|
|
80
|
-
setNewComment(undefined);
|
|
81
|
-
}
|
|
82
|
-
return note;
|
|
83
|
-
});
|
|
84
|
-
}, [newComment, setNoteTarget, saveModel]);
|
|
85
|
-
const isNew = useCallback((note) => {
|
|
86
|
-
return newComment ? newComment._id === note._id : false;
|
|
87
|
-
}, [newComment]);
|
|
88
|
-
const handleOnSelectChange = useCallback((e) => setSelectResolved(e.target.checked), []);
|
|
89
|
-
return (React.createElement(React.Fragment, null,
|
|
90
|
-
React.createElement(ActionHeader, { withAddButton: can.createNotes },
|
|
91
|
-
can.createNotes && (React.createElement(AddNoteButton, { onClick: handleAddNewNote },
|
|
92
|
-
"Add ",
|
|
93
|
-
React.createElement(AddIcon, null))),
|
|
94
|
-
items.length > 0 && (React.createElement(Checkbox, null,
|
|
95
|
-
React.createElement(CheckboxField, { checked: selectResolved, onChange: handleOnSelectChange }),
|
|
96
|
-
React.createElement(LabelText, null, "See resolved")))),
|
|
97
|
-
items.length >= 0 && (React.createElement(NoteListContainer, { "data-cy": "notes-list" }, items.map(([target, noteData]) => {
|
|
98
|
-
const isSelected = (selected &&
|
|
99
|
-
(selected.node.attrs.id === target ||
|
|
100
|
-
selected.node.attrs.rid === target)) ||
|
|
101
|
-
false;
|
|
102
|
-
const selectedNoteData = selectResolved
|
|
103
|
-
? noteData
|
|
104
|
-
: noteData.filter((note) => !note.comment.resolved);
|
|
105
|
-
return (React.createElement(CommentTarget, { key: target, isSelected: isSelected }, selectedNoteData.map(({ comment, children }) => (React.createElement(NoteThread, { key: comment._id },
|
|
106
|
-
React.createElement(NoteBodyContainer, { isSelected: isSelected, isNew: isNew(comment) },
|
|
107
|
-
React.createElement(CommentWrapper, { createKeyword: createKeyword, comment: comment, deleteComment: deleteNote, handleSetResolved: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
108
|
-
return yield saveModel(Object.assign(Object.assign({}, comment), { resolved: !comment.resolved }));
|
|
109
|
-
}), getCollaborator: getCollaboratorById, getKeyword: getKeyword, listCollaborators: listCollaborators, listKeywords: listKeywords, saveComment: saveNote, handleCreateReply: setNoteTarget, isNew: isNew(comment), isSelected: isSelected, isProdNote: true, can: can })),
|
|
110
|
-
children.map((note) => (React.createElement(ReplyBodyContainer, { key: note._id },
|
|
111
|
-
React.createElement(CommentWrapper, { createKeyword: createKeyword, comment: note, deleteComment: deleteNote, getCollaborator: getCollaboratorById, getKeyword: getKeyword, isReply: true, listCollaborators: listCollaborators, listKeywords: listKeywords, saveComment: saveNote, handleCreateReply: setNoteTarget, isNew: isNew(note), isProdNote: true, can: can })))))))));
|
|
112
|
-
})))));
|
|
113
|
-
});
|
|
114
|
-
const AddNoteButton = styled(IconTextButton) `
|
|
115
|
-
svg {
|
|
116
|
-
margin: 0 0 0 ${(props) => props.theme.grid.unit * 4}px;
|
|
117
|
-
path {
|
|
118
|
-
fill: ${(props) => props.theme.colors.text.secondary};
|
|
119
|
-
stroke: ${(props) => props.theme.colors.text.secondary};
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
font-size: ${(props) => props.theme.font.size.normal};
|
|
123
|
-
`;
|
|
124
|
-
const NoteListContainer = styled.div `
|
|
125
|
-
flex: 1;
|
|
126
|
-
overflow-y: auto;
|
|
127
|
-
`;
|
|
128
|
-
export const NoteBodyContainer = styled.div `
|
|
129
|
-
padding: ${(props) => props.theme.grid.unit * 4}px 0
|
|
130
|
-
${(props) => props.theme.grid.unit * 2}px;
|
|
131
|
-
background: ${(props) => props.theme.colors.background.primary};
|
|
132
|
-
|
|
133
|
-
${(props) => borderStyle(props.theme.colors.border.secondary)};
|
|
134
|
-
${(props) => (props.isNew || props.isSelected) &&
|
|
135
|
-
borderStyle(props.theme.colors.border.primary)}
|
|
136
|
-
${(props) => props.isSelected &&
|
|
137
|
-
`background: ${props.theme.colors.background.selected};`}
|
|
138
|
-
|
|
139
|
-
.tooltip {
|
|
140
|
-
border-radius: 6px;
|
|
141
|
-
padding: 8px;
|
|
142
|
-
text-align: center;
|
|
143
|
-
}
|
|
144
|
-
`;
|
|
145
|
-
const borderStyle = (color) => `
|
|
146
|
-
${'border: 1px solid ' + color};
|
|
147
|
-
${'border-left: 4px solid ' + color};
|
|
148
|
-
`;
|
|
149
|
-
const NoteThread = styled.div `
|
|
150
|
-
margin: ${(props) => props.theme.grid.unit * 4}px 0;
|
|
151
|
-
`;
|
|
152
|
-
export const ReplyBodyContainer = styled.div `
|
|
153
|
-
padding: ${(props) => props.theme.grid.unit * 4}px 0
|
|
154
|
-
${(props) => props.theme.grid.unit * 2}px;
|
|
155
|
-
margin-left: ${(props) => props.theme.grid.unit * 8}px;
|
|
156
|
-
border: 1px solid ${(props) => props.theme.colors.border.secondary};
|
|
157
|
-
border-top: none;
|
|
158
|
-
`;
|
|
159
|
-
export const LightRelativeDate = styled(RelativeDate) `
|
|
160
|
-
font-size: ${(props) => props.theme.font.size.small};
|
|
161
|
-
color: ${(props) => props.theme.colors.text.secondary};
|
|
162
|
-
letter-spacing: -0.2px;
|
|
163
|
-
`;
|
|
164
|
-
const ActionHeader = styled.div `
|
|
165
|
-
display: flex;
|
|
166
|
-
align-items: center;
|
|
167
|
-
justify-content: ${(props) => (props.withAddButton && 'space-between') || 'flex-end'};
|
|
168
|
-
padding-left: ${(props) => props.theme.grid.unit * 8}px;
|
|
169
|
-
`;
|
|
170
|
-
export const LabelText = styled.div `
|
|
171
|
-
font-family: ${(props) => props.theme.font.family.sans};
|
|
172
|
-
color: ${(props) => props.theme.colors.text.primary};
|
|
173
|
-
font-size: 14px;
|
|
174
|
-
line-height: 24px;
|
|
175
|
-
margin: 0 !important;
|
|
176
|
-
`;
|
|
177
|
-
const Checkbox = styled(CheckboxLabel) `
|
|
178
|
-
div {
|
|
179
|
-
color: ${(props) => props.theme.colors.text.primary};
|
|
180
|
-
}
|
|
181
|
-
`;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* © 2020 Atypon Systems LLC
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import React, { Dispatch, SetStateAction } from 'react';
|
|
17
|
-
import { Capabilities } from '../../lib/capabilities';
|
|
18
|
-
export declare const CommentActions: React.FC<{
|
|
19
|
-
id: string;
|
|
20
|
-
target: string;
|
|
21
|
-
can?: Capabilities;
|
|
22
|
-
isResolved?: boolean;
|
|
23
|
-
isOwnComment: boolean;
|
|
24
|
-
handleSetResolved?: () => void;
|
|
25
|
-
deleteComment: (id: string, target?: string) => void;
|
|
26
|
-
setIsEditing: Dispatch<SetStateAction<boolean | undefined>>;
|
|
27
|
-
isProdNote?: boolean;
|
|
28
|
-
}>;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* © 2020 Atypon Systems LLC
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import { Keyword, UserProfile } from '@manuscripts/json-schema';
|
|
17
|
-
import React, { Dispatch, SetStateAction } from 'react';
|
|
18
|
-
import { CommentType, UnsavedComment } from '../../lib/comments';
|
|
19
|
-
export interface CommentBodyProps {
|
|
20
|
-
createKeyword: (name: string) => Promise<Keyword>;
|
|
21
|
-
deleteComment: (id: string, target?: string) => void;
|
|
22
|
-
getCollaborator: (id: string) => UserProfile | undefined;
|
|
23
|
-
getKeyword: (id: string) => Keyword | undefined;
|
|
24
|
-
isNew: boolean;
|
|
25
|
-
isReply?: boolean;
|
|
26
|
-
listCollaborators: () => UserProfile[];
|
|
27
|
-
listKeywords: () => Keyword[];
|
|
28
|
-
comment: CommentType | UnsavedComment;
|
|
29
|
-
saveComment: (comment: CommentType | UnsavedComment) => Promise<CommentType>;
|
|
30
|
-
handleCreateReply: (id: string) => void;
|
|
31
|
-
scrollIntoHighlight?: (comment: CommentType | UnsavedComment) => void;
|
|
32
|
-
onFocusOut?: (id: string, content: string) => boolean;
|
|
33
|
-
}
|
|
34
|
-
export declare const CommentBody: React.FC<CommentBodyProps & {
|
|
35
|
-
setIsEditing: Dispatch<SetStateAction<boolean | undefined>>;
|
|
36
|
-
isEditing?: boolean;
|
|
37
|
-
isDeleting?: boolean;
|
|
38
|
-
isProdNote?: boolean;
|
|
39
|
-
}>;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* © 2020 Atypon Systems LLC
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import React from 'react';
|
|
17
|
-
interface Props {
|
|
18
|
-
isSelected: boolean;
|
|
19
|
-
}
|
|
20
|
-
export declare const CommentTarget: React.FC<Props>;
|
|
21
|
-
export {};
|