@manuscripts/style-guide 1.1.11 → 1.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/Comments/CommentBody.js +6 -3
- package/dist/cjs/components/Comments/CommentWrapper.js +2 -2
- package/dist/es/components/Comments/CommentBody.js +6 -3
- package/dist/es/components/Comments/CommentWrapper.js +2 -2
- package/dist/types/components/Comments/CommentBody.d.ts +2 -0
- package/package.json +3 -3
|
@@ -35,7 +35,7 @@ const react_tooltip_1 = __importDefault(require("react-tooltip"));
|
|
|
35
35
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
36
36
|
const Button_1 = require("../Button");
|
|
37
37
|
const Form_1 = require("../Form");
|
|
38
|
-
exports.CommentBody = react_1.default.memo(({ createKeyword, comment, getCollaborator, getKeyword, listCollaborators, listKeywords, saveComment, deleteComment, isReply, isNew, handleCreateReply, setIsEditing, scrollIntoHighlight, isEditing, isProdNote, }) => {
|
|
38
|
+
exports.CommentBody = react_1.default.memo(({ createKeyword, comment, getCollaborator, getKeyword, listCollaborators, listKeywords, saveComment, deleteComment, isReply, isNew, handleCreateReply, setIsEditing, scrollIntoHighlight, onFocusOut, isEditing, isProdNote, }) => {
|
|
39
39
|
(0, react_1.useEffect)(() => {
|
|
40
40
|
if (isNew) {
|
|
41
41
|
setIsEditing(true);
|
|
@@ -54,11 +54,14 @@ exports.CommentBody = react_1.default.memo(({ createKeyword, comment, getCollabo
|
|
|
54
54
|
} }, ({ errors, values, setFieldValue }) => (react_1.default.createElement(formik_1.Form, null,
|
|
55
55
|
errors.contents && react_1.default.createElement(Form_1.FormError, null, errors.contents),
|
|
56
56
|
react_1.default.createElement(formik_1.Field, { name: 'contents' }, (props) => (react_1.default.createElement(CommentContent, null,
|
|
57
|
-
react_1.default.createElement(StyledCommentField, { autoFocus: isEditing, value: values.contents, handleChange: (data) => setFieldValue(props.field.name, data), createKeyword: createKeyword, listCollaborators: listCollaborators, listKeywords: listKeywords, notePlaceholder: !isReply ? 'Comment or @mention...' : 'Reply...' })))),
|
|
57
|
+
react_1.default.createElement(StyledCommentField, { id: comment._id, autoFocus: isEditing, value: values.contents, handleChange: (data) => setFieldValue(props.field.name, data), handleBlur: onFocusOut, createKeyword: createKeyword, listCollaborators: listCollaborators, listKeywords: listKeywords, notePlaceholder: !isReply ? 'Comment or @mention...' : 'Reply...' })))),
|
|
58
58
|
react_1.default.createElement(EditingCommentFooter, null,
|
|
59
59
|
react_1.default.createElement(Actions, null,
|
|
60
60
|
react_1.default.createElement(Button_1.SecondaryButton, { onClick: cancelEditing }, "Cancel"),
|
|
61
|
-
react_1.default.createElement(Button_1.PrimaryButton, {
|
|
61
|
+
react_1.default.createElement(Button_1.PrimaryButton, { disabled: !values.contents.replace(/<[^>]+>/g, '').length ||
|
|
62
|
+
(!isNew &&
|
|
63
|
+
(comment.contents === values.contents ||
|
|
64
|
+
!values.contents.replace(/<[^>]+>/g, '').length)), type: "submit" }, "Save"))))))) : (react_1.default.createElement("div", null,
|
|
62
65
|
react_1.default.createElement(CommentContent, { onClick: () => scrollIntoHighlight && scrollIntoHighlight(comment) },
|
|
63
66
|
react_1.default.createElement(StyledCommentViewer, { value: comment.contents, getCollaborator: getCollaborator, getKeyword: getKeyword })),
|
|
64
67
|
!isReply && (react_1.default.createElement(CommentFooter, null,
|
|
@@ -54,7 +54,7 @@ const isOwn = (comment, userId) => {
|
|
|
54
54
|
? (_a = comment.contributions) === null || _a === void 0 ? void 0 : _a.some((c) => c.profileID === userId)
|
|
55
55
|
: false;
|
|
56
56
|
};
|
|
57
|
-
const CommentWrapper = ({ createKeyword, comment, can, currentUserId, getCollaborator, getKeyword, listCollaborators, listKeywords, saveComment, deleteComment, isReply, isNew, handleCreateReply, handleSetResolved, isProdNote, isSelected, handleRequestSelect, scrollIntoHighlight, children, }) => {
|
|
57
|
+
const CommentWrapper = ({ createKeyword, comment, can, currentUserId, getCollaborator, getKeyword, listCollaborators, listKeywords, saveComment, deleteComment, isReply, isNew, handleCreateReply, handleSetResolved, isProdNote, isSelected, handleRequestSelect, scrollIntoHighlight, onFocusOut, children, }) => {
|
|
58
58
|
const [isEditing, setIsEditing] = (0, react_1.useState)();
|
|
59
59
|
const threadRef = (0, react_1.useRef)(null);
|
|
60
60
|
(0, react_1.useEffect)(() => {
|
|
@@ -89,7 +89,7 @@ const CommentWrapper = ({ createKeyword, comment, can, currentUserId, getCollabo
|
|
|
89
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
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
91
|
children,
|
|
92
|
-
react_1.default.createElement(CommentBody_1.CommentBody, { createKeyword: createKeyword, 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 })));
|
|
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
93
|
};
|
|
94
94
|
exports.CommentWrapper = CommentWrapper;
|
|
95
95
|
const Note = styled_components_1.default.div `
|
|
@@ -6,7 +6,7 @@ import ReactTooltip from 'react-tooltip';
|
|
|
6
6
|
import styled from 'styled-components';
|
|
7
7
|
import { ButtonGroup, PrimaryButton, SecondaryButton } from '../Button';
|
|
8
8
|
import { FormError } from '../Form';
|
|
9
|
-
export const CommentBody = React.memo(({ createKeyword, comment, getCollaborator, getKeyword, listCollaborators, listKeywords, saveComment, deleteComment, isReply, isNew, handleCreateReply, setIsEditing, scrollIntoHighlight, isEditing, isProdNote, }) => {
|
|
9
|
+
export const CommentBody = React.memo(({ createKeyword, comment, getCollaborator, getKeyword, listCollaborators, listKeywords, saveComment, deleteComment, isReply, isNew, handleCreateReply, setIsEditing, scrollIntoHighlight, onFocusOut, isEditing, isProdNote, }) => {
|
|
10
10
|
useEffect(() => {
|
|
11
11
|
if (isNew) {
|
|
12
12
|
setIsEditing(true);
|
|
@@ -25,11 +25,14 @@ export const CommentBody = React.memo(({ createKeyword, comment, getCollaborator
|
|
|
25
25
|
} }, ({ errors, values, setFieldValue }) => (React.createElement(Form, null,
|
|
26
26
|
errors.contents && React.createElement(FormError, null, errors.contents),
|
|
27
27
|
React.createElement(Field, { name: 'contents' }, (props) => (React.createElement(CommentContent, null,
|
|
28
|
-
React.createElement(StyledCommentField, { autoFocus: isEditing, value: values.contents, handleChange: (data) => setFieldValue(props.field.name, data), createKeyword: createKeyword, listCollaborators: listCollaborators, listKeywords: listKeywords, notePlaceholder: !isReply ? 'Comment or @mention...' : 'Reply...' })))),
|
|
28
|
+
React.createElement(StyledCommentField, { id: comment._id, autoFocus: isEditing, value: values.contents, handleChange: (data) => setFieldValue(props.field.name, data), handleBlur: onFocusOut, createKeyword: createKeyword, listCollaborators: listCollaborators, listKeywords: listKeywords, notePlaceholder: !isReply ? 'Comment or @mention...' : 'Reply...' })))),
|
|
29
29
|
React.createElement(EditingCommentFooter, null,
|
|
30
30
|
React.createElement(Actions, null,
|
|
31
31
|
React.createElement(SecondaryButton, { onClick: cancelEditing }, "Cancel"),
|
|
32
|
-
React.createElement(PrimaryButton, {
|
|
32
|
+
React.createElement(PrimaryButton, { disabled: !values.contents.replace(/<[^>]+>/g, '').length ||
|
|
33
|
+
(!isNew &&
|
|
34
|
+
(comment.contents === values.contents ||
|
|
35
|
+
!values.contents.replace(/<[^>]+>/g, '').length)), type: "submit" }, "Save"))))))) : (React.createElement("div", null,
|
|
33
36
|
React.createElement(CommentContent, { onClick: () => scrollIntoHighlight && scrollIntoHighlight(comment) },
|
|
34
37
|
React.createElement(StyledCommentViewer, { value: comment.contents, getCollaborator: getCollaborator, getKeyword: getKeyword })),
|
|
35
38
|
!isReply && (React.createElement(CommentFooter, null,
|
|
@@ -25,7 +25,7 @@ const isOwn = (comment, userId) => {
|
|
|
25
25
|
? (_a = comment.contributions) === null || _a === void 0 ? void 0 : _a.some((c) => c.profileID === userId)
|
|
26
26
|
: false;
|
|
27
27
|
};
|
|
28
|
-
export const CommentWrapper = ({ createKeyword, comment, can, currentUserId, getCollaborator, getKeyword, listCollaborators, listKeywords, saveComment, deleteComment, isReply, isNew, handleCreateReply, handleSetResolved, isProdNote, isSelected, handleRequestSelect, scrollIntoHighlight, children, }) => {
|
|
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
29
|
const [isEditing, setIsEditing] = useState();
|
|
30
30
|
const threadRef = useRef(null);
|
|
31
31
|
useEffect(() => {
|
|
@@ -60,7 +60,7 @@ export const CommentWrapper = ({ createKeyword, comment, can, currentUserId, get
|
|
|
60
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
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
62
|
children,
|
|
63
|
-
React.createElement(CommentBody, { createKeyword: createKeyword, 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 })));
|
|
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
64
|
};
|
|
65
65
|
const Note = styled.div `
|
|
66
66
|
& .note-actions {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Keyword, UserProfile } from '@manuscripts/json-schema';
|
|
2
|
+
import { EditorView } from 'prosemirror-view';
|
|
2
3
|
import React, { Dispatch, SetStateAction } from 'react';
|
|
3
4
|
import { CommentType, UnsavedComment } from '../../lib/comments';
|
|
4
5
|
export interface CommentBodyProps {
|
|
@@ -14,6 +15,7 @@ export interface CommentBodyProps {
|
|
|
14
15
|
saveComment: (comment: CommentType | UnsavedComment) => Promise<CommentType>;
|
|
15
16
|
handleCreateReply: (id: string) => void;
|
|
16
17
|
scrollIntoHighlight?: (comment: CommentType | UnsavedComment) => void;
|
|
18
|
+
onFocusOut?: (view: EditorView, event: Event) => boolean;
|
|
17
19
|
}
|
|
18
20
|
export declare const CommentBody: React.FC<CommentBodyProps & {
|
|
19
21
|
setIsEditing: Dispatch<SetStateAction<boolean | undefined>>;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@manuscripts/style-guide",
|
|
3
3
|
"description": "Shared components for Manuscripts applications",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.12",
|
|
5
5
|
"repository": "github:Atypon-OpenSource/manuscripts-style-guide",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|
|
@@ -36,10 +36,10 @@
|
|
|
36
36
|
"@formatjs/intl-relativetimeformat": "^4.5.9",
|
|
37
37
|
"@formatjs/intl-utils": "^2.2.0",
|
|
38
38
|
"@manuscripts/assets": "^0.6.2",
|
|
39
|
-
"@manuscripts/transform": "^1.3.
|
|
39
|
+
"@manuscripts/transform": "^1.3.1",
|
|
40
40
|
"@manuscripts/json-schema": "^2.0.2",
|
|
41
41
|
"@manuscripts/title-editor": "^1.1.0",
|
|
42
|
-
"@manuscripts/comment-editor": "^1.0.
|
|
42
|
+
"@manuscripts/comment-editor": "^1.0.2",
|
|
43
43
|
"@reach/tabs": "^0.11.2",
|
|
44
44
|
"formik": "^2.2.9",
|
|
45
45
|
"date-fns": "^2.29.3",
|