@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,76 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*!
|
|
3
|
-
* © 2020 Atypon Systems LLC
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
-
};
|
|
20
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.CommentUser = void 0;
|
|
22
|
-
const react_1 = __importDefault(require("react"));
|
|
23
|
-
const styled_components_1 = __importDefault(require("styled-components"));
|
|
24
|
-
const Avatar_1 = require("../Avatar");
|
|
25
|
-
const ManuscriptNoteList_1 = require("../ManuscriptNoteList");
|
|
26
|
-
const CommentUserContainer = styled_components_1.default.div `
|
|
27
|
-
display: flex;
|
|
28
|
-
`;
|
|
29
|
-
const CommentUserName = styled_components_1.default.div `
|
|
30
|
-
margin: 0 ${(props) => props.theme.grid.unit * 2}px;
|
|
31
|
-
font-weight: ${(props) => props.theme.font.weight.normal};
|
|
32
|
-
max-width: ${(props) => props.theme.grid.unit * 50}px;
|
|
33
|
-
white-space: nowrap;
|
|
34
|
-
overflow: hidden;
|
|
35
|
-
text-overflow: ellipsis;
|
|
36
|
-
`;
|
|
37
|
-
const DateText = (0, styled_components_1.default)(CommentUserName) `
|
|
38
|
-
font-size: ${(props) => props.theme.font.size.small};
|
|
39
|
-
line-height: ${(props) => props.theme.font.lineHeight.normal};
|
|
40
|
-
font-weight: ${(props) => props.theme.font.weight.normal};
|
|
41
|
-
color: ${(props) => props.theme.colors.text.secondary};
|
|
42
|
-
`;
|
|
43
|
-
const Header = styled_components_1.default.div `
|
|
44
|
-
display: flex;
|
|
45
|
-
flex-direction: column;
|
|
46
|
-
font-size: ${(props) => props.theme.font.size.normal};
|
|
47
|
-
`;
|
|
48
|
-
const CommentUser = ({ contributions, getCollaboratorById, displayName, createdAt }) => {
|
|
49
|
-
if (!contributions || !contributions.length) {
|
|
50
|
-
return (react_1.default.createElement(CommentUserContainer, null,
|
|
51
|
-
react_1.default.createElement(Header, null,
|
|
52
|
-
react_1.default.createElement(Avatar_1.Avatar, { size: 20 })),
|
|
53
|
-
react_1.default.createElement(Header, null,
|
|
54
|
-
react_1.default.createElement(CommentUserName, null,
|
|
55
|
-
"By ",
|
|
56
|
-
displayName || '(unknown user)'),
|
|
57
|
-
react_1.default.createElement(DateText, null,
|
|
58
|
-
react_1.default.createElement(ManuscriptNoteList_1.LightRelativeDate, { createdAt: createdAt })))));
|
|
59
|
-
}
|
|
60
|
-
const [contribution] = contributions;
|
|
61
|
-
const user = getCollaboratorById(contribution.profileID);
|
|
62
|
-
const buildName = (name) => [name.given, name.family].filter((item) => item).join(' ');
|
|
63
|
-
if (!user) {
|
|
64
|
-
return null;
|
|
65
|
-
}
|
|
66
|
-
return (react_1.default.createElement(CommentUserContainer, null,
|
|
67
|
-
react_1.default.createElement(Header, null,
|
|
68
|
-
react_1.default.createElement(Avatar_1.Avatar, { size: 20 })),
|
|
69
|
-
react_1.default.createElement(Header, null,
|
|
70
|
-
react_1.default.createElement(CommentUserName, null,
|
|
71
|
-
"By ",
|
|
72
|
-
buildName(user.bibliographicName)),
|
|
73
|
-
react_1.default.createElement(DateText, null,
|
|
74
|
-
react_1.default.createElement(ManuscriptNoteList_1.LightRelativeDate, { createdAt: createdAt })))));
|
|
75
|
-
};
|
|
76
|
-
exports.CommentUser = CommentUser;
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*!
|
|
3
|
-
* © 2020 Atypon Systems LLC
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
18
|
-
if (k2 === undefined) k2 = k;
|
|
19
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
20
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
21
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
22
|
-
}
|
|
23
|
-
Object.defineProperty(o, k2, desc);
|
|
24
|
-
}) : (function(o, m, k, k2) {
|
|
25
|
-
if (k2 === undefined) k2 = k;
|
|
26
|
-
o[k2] = m[k];
|
|
27
|
-
}));
|
|
28
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
29
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
30
|
-
}) : function(o, v) {
|
|
31
|
-
o["default"] = v;
|
|
32
|
-
});
|
|
33
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
34
|
-
if (mod && mod.__esModule) return mod;
|
|
35
|
-
var result = {};
|
|
36
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
37
|
-
__setModuleDefault(result, mod);
|
|
38
|
-
return result;
|
|
39
|
-
};
|
|
40
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
41
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
42
|
-
};
|
|
43
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
|
-
exports.CommentWrapper = void 0;
|
|
45
|
-
const react_1 = __importStar(require("react"));
|
|
46
|
-
const styled_components_1 = __importDefault(require("styled-components"));
|
|
47
|
-
const comments_1 = require("../../lib/comments");
|
|
48
|
-
const CommentActions_1 = require("./CommentActions");
|
|
49
|
-
const CommentBody_1 = require("./CommentBody");
|
|
50
|
-
const CommentUser_1 = require("./CommentUser");
|
|
51
|
-
const isOwn = (comment, userId) => {
|
|
52
|
-
var _a;
|
|
53
|
-
return comment.contributions
|
|
54
|
-
? (_a = comment.contributions) === null || _a === void 0 ? void 0 : _a.some((c) => c.profileID === userId)
|
|
55
|
-
: false;
|
|
56
|
-
};
|
|
57
|
-
const CommentWrapper = ({ createKeyword, comment, can, currentUserId, getCollaborator, getKeyword, listCollaborators, listKeywords, saveComment, deleteComment, isReply, isNew, handleCreateReply, handleSetResolved, isProdNote, isSelected, handleRequestSelect, scrollIntoHighlight, onFocusOut, children, }) => {
|
|
58
|
-
const [isEditing, setIsEditing] = (0, react_1.useState)();
|
|
59
|
-
const threadRef = (0, react_1.useRef)(null);
|
|
60
|
-
(0, react_1.useEffect)(() => {
|
|
61
|
-
if (isNew || isSelected) {
|
|
62
|
-
{
|
|
63
|
-
isNew && setIsEditing(true);
|
|
64
|
-
}
|
|
65
|
-
if (threadRef.current) {
|
|
66
|
-
setTimeout(() => {
|
|
67
|
-
var _a;
|
|
68
|
-
return (_a = threadRef.current) === null || _a === void 0 ? void 0 : _a.scrollIntoView({
|
|
69
|
-
block: 'nearest',
|
|
70
|
-
inline: 'nearest',
|
|
71
|
-
});
|
|
72
|
-
}, 100);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}, [isNew, isSelected]);
|
|
76
|
-
const onTitleMouseDown = (0, react_1.useCallback)((e) => {
|
|
77
|
-
e.preventDefault();
|
|
78
|
-
handleRequestSelect && handleRequestSelect();
|
|
79
|
-
}, [handleRequestSelect]);
|
|
80
|
-
const onTitleKeyDown = (0, react_1.useCallback)((e) => {
|
|
81
|
-
if ([' ', 'Enter'].includes(e.key)) {
|
|
82
|
-
e.preventDefault();
|
|
83
|
-
handleRequestSelect && handleRequestSelect();
|
|
84
|
-
}
|
|
85
|
-
}, [handleRequestSelect]);
|
|
86
|
-
const isOwnComment = (0, react_1.useMemo)(() => isOwn(comment, currentUserId), [comment, currentUserId]);
|
|
87
|
-
return (react_1.default.createElement(Note, { "data-cy": "note", ref: threadRef, isSelected: isSelected },
|
|
88
|
-
react_1.default.createElement(NoteHeader, { "data-cy": "note-header" },
|
|
89
|
-
react_1.default.createElement(NoteTitle, { type: "button", onMouseDown: onTitleMouseDown, onKeyDown: onTitleKeyDown }, comment.contributions && (react_1.default.createElement(CommentUser_1.CommentUser, { contributions: comment.contributions, getCollaboratorById: getCollaborator, displayName: comment.displayName, createdAt: (0, comments_1.isSavedComment)(comment) ? comment.createdAt * 1000 : undefined }))),
|
|
90
|
-
react_1.default.createElement(CommentActions_1.CommentActions, { id: comment._id, isOwnComment: isOwnComment, can: can, target: comment.target, isResolved: comment.resolved, handleSetResolved: handleSetResolved, deleteComment: deleteComment, setIsEditing: setIsEditing, isProdNote: isProdNote })),
|
|
91
|
-
children,
|
|
92
|
-
react_1.default.createElement(CommentBody_1.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 })));
|
|
93
|
-
};
|
|
94
|
-
exports.CommentWrapper = CommentWrapper;
|
|
95
|
-
const Note = styled_components_1.default.div `
|
|
96
|
-
& .note-actions {
|
|
97
|
-
opacity: 0;
|
|
98
|
-
${({ isSelected }) => isSelected && 'opacity: 1'}
|
|
99
|
-
transition: 0.1s ease-in-out opacity;
|
|
100
|
-
}
|
|
101
|
-
&:hover .note-actions {
|
|
102
|
-
opacity: 1;
|
|
103
|
-
}
|
|
104
|
-
`;
|
|
105
|
-
const NoteTitle = styled_components_1.default.button `
|
|
106
|
-
border: none;
|
|
107
|
-
background: transparent;
|
|
108
|
-
padding: 0;
|
|
109
|
-
text-align: left;
|
|
110
|
-
`;
|
|
111
|
-
const NoteHeader = styled_components_1.default.div `
|
|
112
|
-
display: flex;
|
|
113
|
-
justify-content: space-between;
|
|
114
|
-
align-items: center;
|
|
115
|
-
font-size: ${(props) => props.theme.font.size.normal};
|
|
116
|
-
margin-bottom: 16px;
|
|
117
|
-
padding: 0 16px;
|
|
118
|
-
`;
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*!
|
|
3
|
-
* © 2021 Atypon Systems LLC
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
-
};
|
|
20
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.ResolveButton = void 0;
|
|
22
|
-
const react_1 = __importDefault(require("react"));
|
|
23
|
-
const styled_components_1 = __importDefault(require("styled-components"));
|
|
24
|
-
const icons_1 = require("../icons");
|
|
25
|
-
const Tooltip_1 = require("../Tooltip");
|
|
26
|
-
const ResolveButton = ({ id, resolved, resolvedCallback }) => {
|
|
27
|
-
return (react_1.default.createElement(Container, null,
|
|
28
|
-
react_1.default.createElement(Button, { className: resolved ? 'resolved' : '', "data-tooltip-id": id, onClick: resolvedCallback },
|
|
29
|
-
react_1.default.createElement(icons_1.CommentResolveIcon, null)),
|
|
30
|
-
react_1.default.createElement(Tooltip_1.Tooltip, { id: id, place: "bottom" }, (resolved && 'Unresolve') || 'Resolve')));
|
|
31
|
-
};
|
|
32
|
-
exports.ResolveButton = ResolveButton;
|
|
33
|
-
const Container = styled_components_1.default.div `
|
|
34
|
-
display: flex;
|
|
35
|
-
justify-content: space-between;
|
|
36
|
-
align-items: center;
|
|
37
|
-
margin-right: ${(props) => props.theme.grid.unit};
|
|
38
|
-
`;
|
|
39
|
-
const Button = styled_components_1.default.button `
|
|
40
|
-
display: flex;
|
|
41
|
-
align-items: center;
|
|
42
|
-
width: 24px;
|
|
43
|
-
height: 24px;
|
|
44
|
-
border-radius: 12px;
|
|
45
|
-
border: none;
|
|
46
|
-
background: #ffffff;
|
|
47
|
-
padding: 0;
|
|
48
|
-
cursor: pointer;
|
|
49
|
-
|
|
50
|
-
&.resolved {
|
|
51
|
-
background: #f2fbfc;
|
|
52
|
-
border: 1px solid #bce7f6;
|
|
53
|
-
path {
|
|
54
|
-
fill: #1a9bc7;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
&:not([disabled]):hover,
|
|
59
|
-
&:not([disabled]):active {
|
|
60
|
-
path {
|
|
61
|
-
fill: #1a9bc7;
|
|
62
|
-
}
|
|
63
|
-
background: #f2fbfc;
|
|
64
|
-
border: 1px solid #c9c9c9;
|
|
65
|
-
}
|
|
66
|
-
`;
|
|
@@ -1,21 +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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./CommentBody"), exports);
|
|
18
|
-
__exportStar(require("./CommentTarget"), exports);
|
|
19
|
-
__exportStar(require("./CommentUser"), exports);
|
|
20
|
-
__exportStar(require("./ResolveButton"), exports);
|
|
21
|
-
__exportStar(require("./CommentWrapper"), exports);
|
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*!
|
|
3
|
-
* © 2020 Atypon Systems LLC
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
18
|
-
if (k2 === undefined) k2 = k;
|
|
19
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
20
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
21
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
22
|
-
}
|
|
23
|
-
Object.defineProperty(o, k2, desc);
|
|
24
|
-
}) : (function(o, m, k, k2) {
|
|
25
|
-
if (k2 === undefined) k2 = k;
|
|
26
|
-
o[k2] = m[k];
|
|
27
|
-
}));
|
|
28
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
29
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
30
|
-
}) : function(o, v) {
|
|
31
|
-
o["default"] = v;
|
|
32
|
-
});
|
|
33
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
34
|
-
if (mod && mod.__esModule) return mod;
|
|
35
|
-
var result = {};
|
|
36
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
37
|
-
__setModuleDefault(result, mod);
|
|
38
|
-
return result;
|
|
39
|
-
};
|
|
40
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
41
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
42
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
43
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
44
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
45
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
46
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
47
|
-
});
|
|
48
|
-
};
|
|
49
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
|
-
};
|
|
52
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
-
exports.LabelText = exports.LightRelativeDate = exports.ReplyBodyContainer = exports.NoteBodyContainer = exports.ManuscriptNoteList = void 0;
|
|
54
|
-
const json_schema_1 = require("@manuscripts/json-schema");
|
|
55
|
-
const transform_1 = require("@manuscripts/transform");
|
|
56
|
-
const react_1 = __importStar(require("react"));
|
|
57
|
-
const styled_components_1 = __importDefault(require("styled-components"));
|
|
58
|
-
const uuid_1 = require("uuid");
|
|
59
|
-
const comments_1 = require("../lib/comments");
|
|
60
|
-
const Button_1 = require("./Button");
|
|
61
|
-
const Checkbox_1 = require("./Checkbox");
|
|
62
|
-
const CommentTarget_1 = require("./Comments/CommentTarget");
|
|
63
|
-
const CommentWrapper_1 = require("./Comments/CommentWrapper");
|
|
64
|
-
const icons_1 = require("./icons");
|
|
65
|
-
const RelativeDate_1 = require("./RelativeDate");
|
|
66
|
-
exports.ManuscriptNoteList = react_1.default.memo(({ createKeyword, deleteModel, getCollaboratorById, currentUserId, displayName, getKeyword, listCollaborators, listKeywords, notes, noteSource, saveModel, selected, can, }) => {
|
|
67
|
-
const [newComment, setNewComment] = (0, react_1.useState)();
|
|
68
|
-
const [selectResolved, setSelectResolved] = (0, react_1.useState)(false);
|
|
69
|
-
const [noteTarget, setNoteTarget] = (0, react_1.useState)();
|
|
70
|
-
(0, react_1.useEffect)(() => {
|
|
71
|
-
if (noteTarget && !newComment) {
|
|
72
|
-
const newComment = (0, transform_1.buildNote)(noteTarget, noteSource);
|
|
73
|
-
newComment.displayName = displayName;
|
|
74
|
-
if (currentUserId) {
|
|
75
|
-
const contribution = (0, transform_1.buildContribution)(currentUserId);
|
|
76
|
-
newComment.contributions = [contribution];
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
newComment.contributions = [];
|
|
80
|
-
}
|
|
81
|
-
setNewComment(newComment);
|
|
82
|
-
}
|
|
83
|
-
}, [noteTarget, currentUserId, displayName, newComment, noteSource]);
|
|
84
|
-
const items = (0, react_1.useMemo)(() => {
|
|
85
|
-
const combinedComments = [...notes];
|
|
86
|
-
if (newComment) {
|
|
87
|
-
combinedComments.push(newComment);
|
|
88
|
-
}
|
|
89
|
-
const commentsTreeMap = (0, comments_1.buildNoteTree)(combinedComments);
|
|
90
|
-
return Array.from(commentsTreeMap.entries());
|
|
91
|
-
}, [notes, newComment]);
|
|
92
|
-
const handleAddNewNote = (0, react_1.useCallback)((event) => {
|
|
93
|
-
event.preventDefault();
|
|
94
|
-
setNoteTarget(json_schema_1.ObjectTypes.ManuscriptNote + ':' + (0, uuid_1.v4)().toUpperCase());
|
|
95
|
-
setSelectResolved(false);
|
|
96
|
-
}, [setNoteTarget]);
|
|
97
|
-
const deleteNote = (0, react_1.useCallback)((id) => {
|
|
98
|
-
return deleteModel(id).finally(() => {
|
|
99
|
-
if (newComment && newComment._id === id) {
|
|
100
|
-
setNoteTarget(undefined);
|
|
101
|
-
setNewComment(undefined);
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
}, [deleteModel, newComment, setNoteTarget]);
|
|
105
|
-
const saveNote = (0, react_1.useCallback)((note) => {
|
|
106
|
-
return saveModel(note).then((note) => {
|
|
107
|
-
if (newComment && newComment._id === note._id) {
|
|
108
|
-
setNoteTarget(undefined);
|
|
109
|
-
setNewComment(undefined);
|
|
110
|
-
}
|
|
111
|
-
return note;
|
|
112
|
-
});
|
|
113
|
-
}, [newComment, setNoteTarget, saveModel]);
|
|
114
|
-
const isNew = (0, react_1.useCallback)((note) => {
|
|
115
|
-
return newComment ? newComment._id === note._id : false;
|
|
116
|
-
}, [newComment]);
|
|
117
|
-
const handleOnSelectChange = (0, react_1.useCallback)((e) => setSelectResolved(e.target.checked), []);
|
|
118
|
-
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
119
|
-
react_1.default.createElement(ActionHeader, { withAddButton: can.createNotes },
|
|
120
|
-
can.createNotes && (react_1.default.createElement(AddNoteButton, { onClick: handleAddNewNote },
|
|
121
|
-
"Add ",
|
|
122
|
-
react_1.default.createElement(icons_1.AddIcon, null))),
|
|
123
|
-
items.length > 0 && (react_1.default.createElement(Checkbox, null,
|
|
124
|
-
react_1.default.createElement(Checkbox_1.CheckboxField, { checked: selectResolved, onChange: handleOnSelectChange }),
|
|
125
|
-
react_1.default.createElement(exports.LabelText, null, "See resolved")))),
|
|
126
|
-
items.length >= 0 && (react_1.default.createElement(NoteListContainer, { "data-cy": "notes-list" }, items.map(([target, noteData]) => {
|
|
127
|
-
const isSelected = (selected &&
|
|
128
|
-
(selected.node.attrs.id === target ||
|
|
129
|
-
selected.node.attrs.rid === target)) ||
|
|
130
|
-
false;
|
|
131
|
-
const selectedNoteData = selectResolved
|
|
132
|
-
? noteData
|
|
133
|
-
: noteData.filter((note) => !note.comment.resolved);
|
|
134
|
-
return (react_1.default.createElement(CommentTarget_1.CommentTarget, { key: target, isSelected: isSelected }, selectedNoteData.map(({ comment, children }) => (react_1.default.createElement(NoteThread, { key: comment._id },
|
|
135
|
-
react_1.default.createElement(exports.NoteBodyContainer, { isSelected: isSelected, isNew: isNew(comment) },
|
|
136
|
-
react_1.default.createElement(CommentWrapper_1.CommentWrapper, { createKeyword: createKeyword, comment: comment, deleteComment: deleteNote, handleSetResolved: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
137
|
-
return yield saveModel(Object.assign(Object.assign({}, comment), { resolved: !comment.resolved }));
|
|
138
|
-
}), getCollaborator: getCollaboratorById, getKeyword: getKeyword, listCollaborators: listCollaborators, listKeywords: listKeywords, saveComment: saveNote, handleCreateReply: setNoteTarget, isNew: isNew(comment), isSelected: isSelected, isProdNote: true, can: can })),
|
|
139
|
-
children.map((note) => (react_1.default.createElement(exports.ReplyBodyContainer, { key: note._id },
|
|
140
|
-
react_1.default.createElement(CommentWrapper_1.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 })))))))));
|
|
141
|
-
})))));
|
|
142
|
-
});
|
|
143
|
-
const AddNoteButton = (0, styled_components_1.default)(Button_1.IconTextButton) `
|
|
144
|
-
svg {
|
|
145
|
-
margin: 0 0 0 ${(props) => props.theme.grid.unit * 4}px;
|
|
146
|
-
path {
|
|
147
|
-
fill: ${(props) => props.theme.colors.text.secondary};
|
|
148
|
-
stroke: ${(props) => props.theme.colors.text.secondary};
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
font-size: ${(props) => props.theme.font.size.normal};
|
|
152
|
-
`;
|
|
153
|
-
const NoteListContainer = styled_components_1.default.div `
|
|
154
|
-
flex: 1;
|
|
155
|
-
overflow-y: auto;
|
|
156
|
-
`;
|
|
157
|
-
exports.NoteBodyContainer = styled_components_1.default.div `
|
|
158
|
-
padding: ${(props) => props.theme.grid.unit * 4}px 0
|
|
159
|
-
${(props) => props.theme.grid.unit * 2}px;
|
|
160
|
-
background: ${(props) => props.theme.colors.background.primary};
|
|
161
|
-
|
|
162
|
-
${(props) => borderStyle(props.theme.colors.border.secondary)};
|
|
163
|
-
${(props) => (props.isNew || props.isSelected) &&
|
|
164
|
-
borderStyle(props.theme.colors.border.primary)}
|
|
165
|
-
${(props) => props.isSelected &&
|
|
166
|
-
`background: ${props.theme.colors.background.selected};`}
|
|
167
|
-
|
|
168
|
-
.tooltip {
|
|
169
|
-
border-radius: 6px;
|
|
170
|
-
padding: 8px;
|
|
171
|
-
text-align: center;
|
|
172
|
-
}
|
|
173
|
-
`;
|
|
174
|
-
const borderStyle = (color) => `
|
|
175
|
-
${'border: 1px solid ' + color};
|
|
176
|
-
${'border-left: 4px solid ' + color};
|
|
177
|
-
`;
|
|
178
|
-
const NoteThread = styled_components_1.default.div `
|
|
179
|
-
margin: ${(props) => props.theme.grid.unit * 4}px 0;
|
|
180
|
-
`;
|
|
181
|
-
exports.ReplyBodyContainer = styled_components_1.default.div `
|
|
182
|
-
padding: ${(props) => props.theme.grid.unit * 4}px 0
|
|
183
|
-
${(props) => props.theme.grid.unit * 2}px;
|
|
184
|
-
margin-left: ${(props) => props.theme.grid.unit * 8}px;
|
|
185
|
-
border: 1px solid ${(props) => props.theme.colors.border.secondary};
|
|
186
|
-
border-top: none;
|
|
187
|
-
`;
|
|
188
|
-
exports.LightRelativeDate = (0, styled_components_1.default)(RelativeDate_1.RelativeDate) `
|
|
189
|
-
font-size: ${(props) => props.theme.font.size.small};
|
|
190
|
-
color: ${(props) => props.theme.colors.text.secondary};
|
|
191
|
-
letter-spacing: -0.2px;
|
|
192
|
-
`;
|
|
193
|
-
const ActionHeader = styled_components_1.default.div `
|
|
194
|
-
display: flex;
|
|
195
|
-
align-items: center;
|
|
196
|
-
justify-content: ${(props) => (props.withAddButton && 'space-between') || 'flex-end'};
|
|
197
|
-
padding-left: ${(props) => props.theme.grid.unit * 8}px;
|
|
198
|
-
`;
|
|
199
|
-
exports.LabelText = styled_components_1.default.div `
|
|
200
|
-
font-family: ${(props) => props.theme.font.family.sans};
|
|
201
|
-
color: ${(props) => props.theme.colors.text.primary};
|
|
202
|
-
font-size: 14px;
|
|
203
|
-
line-height: 24px;
|
|
204
|
-
margin: 0 !important;
|
|
205
|
-
`;
|
|
206
|
-
const Checkbox = (0, styled_components_1.default)(Checkbox_1.CheckboxLabel) `
|
|
207
|
-
div {
|
|
208
|
-
color: ${(props) => props.theme.colors.text.primary};
|
|
209
|
-
}
|
|
210
|
-
`;
|
|
@@ -1,68 +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, useMemo } from 'react';
|
|
17
|
-
import styled from 'styled-components';
|
|
18
|
-
import { useDropdown } from '../../hooks/use-dropdown';
|
|
19
|
-
import { IconTextButton } from '../Button';
|
|
20
|
-
import { DropdownButton, DropdownContainer, DropdownList } from '../Dropdown';
|
|
21
|
-
import { DotsIcon } from '../icons';
|
|
22
|
-
import { ResolveButton } from './ResolveButton';
|
|
23
|
-
export const CommentActions = ({ id, target, can, isResolved, handleSetResolved, deleteComment, setIsEditing, isOwnComment, isProdNote, }) => {
|
|
24
|
-
const { isOpen, toggleOpen, wrapperRef } = useDropdown();
|
|
25
|
-
const handleRequestEdit = useCallback(() => {
|
|
26
|
-
setIsEditing(true);
|
|
27
|
-
}, [setIsEditing]);
|
|
28
|
-
const handleRequestDelete = useCallback(() => deleteComment(id, target), [deleteComment, id, target]);
|
|
29
|
-
const canResolve = useMemo(() => {
|
|
30
|
-
if (!isProdNote) {
|
|
31
|
-
return ((isOwnComment && (can === null || can === void 0 ? void 0 : can.resolveOwnComment)) || (can === null || can === void 0 ? void 0 : can.resolveOthersComment));
|
|
32
|
-
}
|
|
33
|
-
return can === null || can === void 0 ? void 0 : can.handleNotes;
|
|
34
|
-
}, [isProdNote, isOwnComment, can]);
|
|
35
|
-
const canHandle = useMemo(() => {
|
|
36
|
-
if (!isProdNote) {
|
|
37
|
-
return ((isOwnComment && (can === null || can === void 0 ? void 0 : can.handleOwnComments)) || (can === null || can === void 0 ? void 0 : can.handleOthersComments));
|
|
38
|
-
}
|
|
39
|
-
return can === null || can === void 0 ? void 0 : can.handleNotes;
|
|
40
|
-
}, [isProdNote, isOwnComment, can]);
|
|
41
|
-
return (React.createElement(Container, null,
|
|
42
|
-
canResolve && handleSetResolved && (React.createElement(ResolveButton, { id: id, resolved: isResolved, resolvedCallback: handleSetResolved, "aria-label": 'resolve comment' })),
|
|
43
|
-
canHandle && (React.createElement(DropdownContainer, { ref: wrapperRef },
|
|
44
|
-
React.createElement(ActionDropdownButton, { onClick: toggleOpen, className: "note-actions", "aria-label": 'actions list' },
|
|
45
|
-
React.createElement(DotsIcon, null)),
|
|
46
|
-
isOpen && (React.createElement(DropdownList, { direction: 'right', width: 125, height: 96, onClick: toggleOpen },
|
|
47
|
-
React.createElement(ActionButton, { onClick: handleRequestEdit }, "Edit"),
|
|
48
|
-
React.createElement(ActionButton, { onClick: handleRequestDelete }, "Delete")))))));
|
|
49
|
-
};
|
|
50
|
-
const Container = styled.div `
|
|
51
|
-
display: flex;
|
|
52
|
-
align-items: center;
|
|
53
|
-
height: ${(props) => props.theme.grid.unit * 6}px;
|
|
54
|
-
`;
|
|
55
|
-
const ActionButton = styled(IconTextButton) `
|
|
56
|
-
display: inline-block;
|
|
57
|
-
text-align: left;
|
|
58
|
-
padding-left: ${(props) => props.theme.grid.unit * 4}px;
|
|
59
|
-
`;
|
|
60
|
-
const ActionDropdownButton = styled(DropdownButton) `
|
|
61
|
-
&:not([disabled]):focus {
|
|
62
|
-
circle {
|
|
63
|
-
fill: ${(props) => props.theme.colors.brand.medium};
|
|
64
|
-
}
|
|
65
|
-
opacity: 1;
|
|
66
|
-
}
|
|
67
|
-
margin-left: ${(props) => props.theme.grid.unit}px;
|
|
68
|
-
`;
|