@manuscripts/style-guide 1.12.16 → 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/RelativeDate.js +16 -4
- package/dist/cjs/index.js +0 -2
- package/dist/es/components/RelativeDate.js +16 -4
- package/dist/es/index.js +0 -2
- package/dist/types/components/RelativeDate.d.ts +4 -3
- package/dist/types/index.d.ts +0 -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,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
|
-
`;
|
|
@@ -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
|
-
};
|