@manuscripts/body-editor 1.7.19 → 1.7.21
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/commands.js +7 -4
- package/dist/cjs/components/authors/AffiliationButton.js +105 -0
- package/dist/cjs/components/authors/AffiliationForm.js +50 -0
- package/dist/cjs/components/authors/AuthorActions.js +61 -0
- package/dist/cjs/components/authors/AuthorAffiliations.js +116 -0
- package/dist/cjs/components/authors/AuthorDetailsForm.js +97 -0
- package/dist/cjs/components/authors/AuthorFormPlaceholder.js +57 -0
- package/dist/cjs/components/authors/AuthorList.js +40 -0
- package/dist/cjs/components/authors/AuthorsModal.js +226 -0
- package/dist/cjs/components/authors/ChangeHandlingForm.js +37 -0
- package/dist/cjs/components/authors/DeleteAuthorConfirmationDialog.js +23 -0
- package/dist/cjs/components/authors/DraggableAuthor.js +170 -0
- package/dist/cjs/components/authors/SaveAuthorConfirmationDialog.js +21 -0
- package/dist/cjs/lib/array-reducer.js +2 -0
- package/dist/cjs/lib/authors.js +43 -0
- package/dist/cjs/lib/context-menu.js +8 -5
- package/dist/cjs/lib/track-changes-utils.js +5 -1
- package/dist/cjs/lib/utils.js +1 -5
- package/dist/cjs/lib/view.js +97 -0
- package/dist/cjs/plugins/footnotes/index.js +3 -3
- package/dist/cjs/views/base_node_view.js +0 -19
- package/dist/cjs/views/bibliography_element.js +3 -2
- package/dist/cjs/views/citation_editable.js +3 -2
- package/dist/cjs/views/contributors.js +78 -25
- package/dist/cjs/views/footnote.js +12 -2
- package/dist/cjs/views/footnote_editable.js +1 -1
- package/dist/cjs/views/footnotes_element.js +2 -1
- package/dist/cjs/views/footnotes_element_editable.js +2 -1
- package/dist/cjs/views/inline_footnote.js +5 -0
- package/dist/es/commands.js +7 -4
- package/dist/es/components/authors/AffiliationButton.js +75 -0
- package/dist/es/components/authors/AffiliationForm.js +43 -0
- package/dist/es/components/authors/AuthorActions.js +31 -0
- package/dist/es/components/authors/AuthorAffiliations.js +85 -0
- package/dist/es/components/authors/AuthorDetailsForm.js +67 -0
- package/dist/es/components/authors/AuthorFormPlaceholder.js +50 -0
- package/dist/es/components/authors/AuthorList.js +33 -0
- package/dist/es/components/authors/AuthorsModal.js +196 -0
- package/dist/es/components/authors/ChangeHandlingForm.js +10 -0
- package/dist/es/components/authors/DeleteAuthorConfirmationDialog.js +16 -0
- package/dist/es/components/authors/DraggableAuthor.js +140 -0
- package/dist/es/components/authors/SaveAuthorConfirmationDialog.js +14 -0
- package/dist/es/configs/editor-views.js +2 -2
- package/dist/es/lib/array-reducer.js +2 -0
- package/dist/es/lib/authors.js +36 -0
- package/dist/es/lib/context-menu.js +8 -5
- package/dist/es/lib/track-changes-utils.js +3 -0
- package/dist/es/lib/utils.js +1 -4
- package/dist/es/lib/view.js +64 -0
- package/dist/es/plugins/footnotes/index.js +3 -3
- package/dist/es/views/base_node_view.js +0 -19
- package/dist/es/views/bibliography_element.js +3 -2
- package/dist/es/views/citation_editable.js +3 -2
- package/dist/es/views/contributors.js +79 -26
- package/dist/es/views/footnote.js +10 -1
- package/dist/es/views/footnote_editable.js +2 -2
- package/dist/es/views/footnotes_element.js +2 -1
- package/dist/es/views/footnotes_element_editable.js +2 -1
- package/dist/es/views/inline_footnote.js +5 -0
- package/dist/types/components/authors/AffiliationButton.d.ts +8 -0
- package/dist/types/components/authors/AffiliationForm.d.ts +7 -0
- package/dist/types/components/authors/AuthorActions.d.ts +9 -0
- package/dist/types/components/authors/AuthorAffiliations.d.ts +11 -0
- package/dist/types/components/authors/AuthorDetailsForm.d.ts +30 -0
- package/dist/types/components/authors/AuthorFormPlaceholder.d.ts +2 -0
- package/dist/types/components/authors/AuthorList.d.ts +25 -0
- package/dist/types/components/authors/AuthorsModal.d.ts +26 -0
- package/dist/types/components/authors/ChangeHandlingForm.d.ts +5 -0
- package/dist/types/components/authors/DeleteAuthorConfirmationDialog.d.ts +9 -0
- package/dist/types/components/authors/DraggableAuthor.d.ts +25 -0
- package/dist/types/components/authors/SaveAuthorConfirmationDialog.d.ts +7 -0
- package/dist/types/components/outline/DraggableTree.d.ts +1 -1
- package/dist/types/configs/ManuscriptsEditor.d.ts +0 -2
- package/dist/types/configs/editor-views.d.ts +0 -28
- package/dist/types/lib/array-reducer.d.ts +5 -1
- package/dist/types/lib/authors.d.ts +23 -0
- package/dist/types/lib/track-changes-utils.d.ts +1 -0
- package/dist/types/lib/utils.d.ts +0 -1
- package/dist/types/lib/view.d.ts +25 -0
- package/dist/types/views/base_node_view.d.ts +1 -4
- package/dist/types/views/bibliography_element_editable.d.ts +0 -2
- package/dist/types/views/blockquote_element_editable.d.ts +0 -2
- package/dist/types/views/bullet_list_editable.d.ts +0 -2
- package/dist/types/views/contributors.d.ts +25 -8
- package/dist/types/views/editable_block.d.ts +0 -2
- package/dist/types/views/equation_element_editable.d.ts +0 -2
- package/dist/types/views/figure_element_editable.d.ts +0 -2
- package/dist/types/views/footnote.d.ts +2 -0
- package/dist/types/views/footnote_editable.d.ts +0 -2
- package/dist/types/views/footnotes_element_editable.d.ts +0 -2
- package/dist/types/views/listing_element_editable.d.ts +0 -2
- package/dist/types/views/ordered_list_editable.d.ts +0 -2
- package/dist/types/views/paragraph_editable.d.ts +0 -2
- package/dist/types/views/placeholder_element_editable.d.ts +0 -2
- package/dist/types/views/pullquote_element_editable.d.ts +0 -2
- package/dist/types/views/section_title_editable.d.ts +0 -2
- package/dist/types/views/table_element_editable.d.ts +0 -2
- package/dist/types/views/toc_element_editable.d.ts +0 -2
- package/package.json +3 -2
- package/styles/AdvancedEditor.css +3 -3
- package/styles/Editor.css +5 -5
package/dist/cjs/commands.js
CHANGED
|
@@ -26,6 +26,7 @@ const prosemirror_transform_1 = require("prosemirror-transform");
|
|
|
26
26
|
const prosemirror_utils_1 = require("prosemirror-utils");
|
|
27
27
|
const list_1 = require("./keys/list");
|
|
28
28
|
const helpers_1 = require("./lib/helpers");
|
|
29
|
+
const track_changes_utils_1 = require("./lib/track-changes-utils");
|
|
29
30
|
const utils_1 = require("./lib/utils");
|
|
30
31
|
const comment_annotation_1 = require("./plugins/comment_annotation");
|
|
31
32
|
const highlight_1 = require("./plugins/highlight");
|
|
@@ -737,10 +738,12 @@ const insertTableFootnote = (node, position, state, dispatch) => {
|
|
|
737
738
|
const tr = state.tr;
|
|
738
739
|
tr.insert(insertedAt, inlineFootnoteNode);
|
|
739
740
|
let insertionPos;
|
|
740
|
-
const footnotesElement = (0, prosemirror_utils_1.findChildrenByType)(node, transform_1.schema.nodes.footnotes_element);
|
|
741
|
-
if (footnotesElement
|
|
742
|
-
|
|
743
|
-
|
|
741
|
+
const footnotesElement = (0, prosemirror_utils_1.findChildrenByType)(node, transform_1.schema.nodes.footnotes_element).pop();
|
|
742
|
+
if (footnotesElement &&
|
|
743
|
+
!(0, track_changes_utils_1.isDeleted)(footnotesElement.node) &&
|
|
744
|
+
!(0, track_changes_utils_1.isRejectedInsert)(footnotesElement.node)) {
|
|
745
|
+
const pos = footnotesElement.pos;
|
|
746
|
+
insertionPos = position + pos + footnotesElement.node.nodeSize + 1;
|
|
744
747
|
tr.insert(insertionPos, footnote);
|
|
745
748
|
}
|
|
746
749
|
else {
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.AffiliationButton = void 0;
|
|
30
|
+
const ArrowDownBlue_1 = __importDefault(require("@manuscripts/assets/react/ArrowDownBlue"));
|
|
31
|
+
const style_guide_1 = require("@manuscripts/style-guide");
|
|
32
|
+
const lodash_1 = require("lodash");
|
|
33
|
+
const react_1 = __importStar(require("react"));
|
|
34
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
35
|
+
const authors_1 = require("../../lib/authors");
|
|
36
|
+
const AffiliationForm_1 = require("./AffiliationForm");
|
|
37
|
+
const Container = styled_components_1.default.div `
|
|
38
|
+
border: 1px solid ${(props) => props.theme.colors.border.field.default};
|
|
39
|
+
border-radius: ${(props) => props.theme.grid.radius.default};
|
|
40
|
+
background: ${(props) => props.theme.colors.background.primary};
|
|
41
|
+
margin-bottom: 2px;
|
|
42
|
+
overflow: hidden;
|
|
43
|
+
`;
|
|
44
|
+
const AffiliationFormContainer = styled_components_1.default.div `
|
|
45
|
+
border: 1px solid ${(props) => props.theme.colors.border.field.default};
|
|
46
|
+
border-radius: ${(props) => props.theme.grid.radius.default};
|
|
47
|
+
margin: 6px 12px 12px;
|
|
48
|
+
overflow: hidden;
|
|
49
|
+
`;
|
|
50
|
+
const AffiliationLabel = styled_components_1.default.div `
|
|
51
|
+
margin: 0;
|
|
52
|
+
display: flex;
|
|
53
|
+
align-items: center;
|
|
54
|
+
font-size: 0.875rem;
|
|
55
|
+
padding-right: 0.5rem;
|
|
56
|
+
`;
|
|
57
|
+
const DropdownIndicator = (0, styled_components_1.default)(ArrowDownBlue_1.default) `
|
|
58
|
+
border: 0;
|
|
59
|
+
border-radius: 50%;
|
|
60
|
+
margin-right: 0.6em;
|
|
61
|
+
min-width: 20px;
|
|
62
|
+
`;
|
|
63
|
+
const ToggleButton = styled_components_1.default.button `
|
|
64
|
+
flex-grow: 1;
|
|
65
|
+
display: flex;
|
|
66
|
+
align-items: center;
|
|
67
|
+
width: 100%;
|
|
68
|
+
background: transparent;
|
|
69
|
+
border: none;
|
|
70
|
+
text-align: left;
|
|
71
|
+
font-family: ${(props) => props.theme.font.family.sans};
|
|
72
|
+
font-size: 1rem;
|
|
73
|
+
padding: 0.6em 0.5em;
|
|
74
|
+
outline: none;
|
|
75
|
+
|
|
76
|
+
&.open svg {
|
|
77
|
+
transform: rotateX(180deg);
|
|
78
|
+
}
|
|
79
|
+
`;
|
|
80
|
+
const RemoveButton = styled_components_1.default.div `
|
|
81
|
+
cursor: pointer;
|
|
82
|
+
`;
|
|
83
|
+
const AffiliationButton = ({ affiliation, onSave, onRemove, }) => {
|
|
84
|
+
const [isOpen, setOpen] = (0, react_1.useState)(false);
|
|
85
|
+
const toggleOpen = () => {
|
|
86
|
+
setOpen((o) => !o);
|
|
87
|
+
};
|
|
88
|
+
const handleSave = (values) => {
|
|
89
|
+
if ((0, lodash_1.isEqual)(values, affiliation)) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const copy = Object.assign(Object.assign({}, affiliation), values);
|
|
93
|
+
onSave(copy);
|
|
94
|
+
};
|
|
95
|
+
return (react_1.default.createElement(Container, null,
|
|
96
|
+
react_1.default.createElement(AffiliationLabel, null,
|
|
97
|
+
react_1.default.createElement(ToggleButton, { type: "button", className: isOpen ? 'open' : '', onClick: toggleOpen },
|
|
98
|
+
react_1.default.createElement(DropdownIndicator, null),
|
|
99
|
+
(0, authors_1.affiliationLabel)(affiliation)),
|
|
100
|
+
react_1.default.createElement(RemoveButton, { onClick: onRemove },
|
|
101
|
+
react_1.default.createElement(style_guide_1.DeleteIcon, null))),
|
|
102
|
+
isOpen && (react_1.default.createElement(AffiliationFormContainer, null,
|
|
103
|
+
react_1.default.createElement(AffiliationForm_1.AffiliationForm, { values: affiliation, onSave: handleSave })))));
|
|
104
|
+
};
|
|
105
|
+
exports.AffiliationButton = AffiliationButton;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.AffiliationForm = void 0;
|
|
7
|
+
const style_guide_1 = require("@manuscripts/style-guide");
|
|
8
|
+
const formik_1 = require("formik");
|
|
9
|
+
const react_1 = __importDefault(require("react"));
|
|
10
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
11
|
+
const ChangeHandlingForm_1 = require("./ChangeHandlingForm");
|
|
12
|
+
const Row = styled_components_1.default.div `
|
|
13
|
+
display: flex;
|
|
14
|
+
border-top: 1px solid ${(props) => props.theme.colors.border.field.default};
|
|
15
|
+
&:first-child {
|
|
16
|
+
border-top: none;
|
|
17
|
+
}
|
|
18
|
+
`;
|
|
19
|
+
const AffiliationsTextField = (0, styled_components_1.default)(style_guide_1.TextField) `
|
|
20
|
+
border: none;
|
|
21
|
+
border-radius: 0;
|
|
22
|
+
background: transparent;
|
|
23
|
+
&:not(:first-child) {
|
|
24
|
+
border-left: 1px solid ${(props) => props.theme.colors.border.field.default};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
&[aria-invalid] {
|
|
28
|
+
background: ${(props) => props.theme.colors.background.warning};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
&[aria-invalid]:focus {
|
|
32
|
+
background: transparent;
|
|
33
|
+
}
|
|
34
|
+
`;
|
|
35
|
+
const AffiliationForm = ({ values, onSave, }) => {
|
|
36
|
+
return (react_1.default.createElement(formik_1.Formik, { initialValues: values, onSubmit: onSave }, () => (react_1.default.createElement(ChangeHandlingForm_1.ChangeHandlingForm, { onChange: onSave },
|
|
37
|
+
react_1.default.createElement(Row, null,
|
|
38
|
+
react_1.default.createElement(formik_1.Field, { name: "institution" }, (props) => (react_1.default.createElement(AffiliationsTextField, Object.assign({ id: "institution", placeholder: "Institution Name" }, props.field))))),
|
|
39
|
+
react_1.default.createElement(Row, null,
|
|
40
|
+
react_1.default.createElement(formik_1.Field, { name: "department" }, (props) => (react_1.default.createElement(AffiliationsTextField, Object.assign({ id: "department", placeholder: "Department" }, props.field))))),
|
|
41
|
+
react_1.default.createElement(Row, null,
|
|
42
|
+
react_1.default.createElement(formik_1.Field, { name: "addressLine1" }, (props) => (react_1.default.createElement(AffiliationsTextField, Object.assign({ id: "addressLine1", placeholder: "Street Address" }, props.field))))),
|
|
43
|
+
react_1.default.createElement(Row, null,
|
|
44
|
+
react_1.default.createElement(formik_1.Field, { name: "city" }, (props) => (react_1.default.createElement(AffiliationsTextField, Object.assign({ id: "city", placeholder: "City" }, props.field)))),
|
|
45
|
+
react_1.default.createElement(formik_1.Field, { name: "county" }, (props) => (react_1.default.createElement(AffiliationsTextField, Object.assign({ id: "county", placeholder: "State / Province" }, props.field))))),
|
|
46
|
+
react_1.default.createElement(Row, null,
|
|
47
|
+
react_1.default.createElement(formik_1.Field, { name: "postCode" }, (props) => (react_1.default.createElement(AffiliationsTextField, Object.assign({ id: "postCode", placeholder: "Postal Code" }, props.field)))),
|
|
48
|
+
react_1.default.createElement(formik_1.Field, { name: "country" }, (props) => (react_1.default.createElement(AffiliationsTextField, Object.assign({ id: "country", placeholder: "Country" }, props.field)))))))));
|
|
49
|
+
};
|
|
50
|
+
exports.AffiliationForm = AffiliationForm;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.AuthorActions = void 0;
|
|
30
|
+
const style_guide_1 = require("@manuscripts/style-guide");
|
|
31
|
+
const react_1 = __importStar(require("react"));
|
|
32
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
33
|
+
const DeleteAuthorConfirmationDialog_1 = require("./DeleteAuthorConfirmationDialog");
|
|
34
|
+
const AuthorActionsContainer = styled_components_1.default.div `
|
|
35
|
+
display: flex;
|
|
36
|
+
`;
|
|
37
|
+
const RemoveButton = styled_components_1.default.div `
|
|
38
|
+
display: flex;
|
|
39
|
+
align-items: center;
|
|
40
|
+
|
|
41
|
+
svg {
|
|
42
|
+
cursor: pointer;
|
|
43
|
+
}
|
|
44
|
+
`;
|
|
45
|
+
const StyledButtonGroup = (0, styled_components_1.default)(style_guide_1.ButtonGroup) `
|
|
46
|
+
flex: 1;
|
|
47
|
+
`;
|
|
48
|
+
const AuthorActions = ({ author, onSave, onDelete, onCancel, }) => {
|
|
49
|
+
const [showDeleteDialog, setShowDeleteDialog] = (0, react_1.useState)(false);
|
|
50
|
+
return (react_1.default.createElement(AuthorActionsContainer, null,
|
|
51
|
+
react_1.default.createElement(DeleteAuthorConfirmationDialog_1.DeleteAuthorConfirmationDialog, { author: author, isOpen: showDeleteDialog, onDelete: () => {
|
|
52
|
+
setShowDeleteDialog(true);
|
|
53
|
+
onDelete();
|
|
54
|
+
}, onCancel: () => setShowDeleteDialog(false) }),
|
|
55
|
+
react_1.default.createElement(RemoveButton, { onClick: () => setShowDeleteDialog(true) },
|
|
56
|
+
react_1.default.createElement(style_guide_1.DeleteIcon, null)),
|
|
57
|
+
react_1.default.createElement(StyledButtonGroup, null,
|
|
58
|
+
react_1.default.createElement(style_guide_1.SecondaryButton, { onClick: onCancel }, "Cancel"),
|
|
59
|
+
react_1.default.createElement(style_guide_1.PrimaryButton, { onClick: onSave }, "Save"))));
|
|
60
|
+
};
|
|
61
|
+
exports.AuthorActions = AuthorActions;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.AuthorAffiliations = exports.AddAffiliationIndicator = void 0;
|
|
30
|
+
const AddAuthor_1 = __importDefault(require("@manuscripts/assets/react/AddAuthor"));
|
|
31
|
+
const json_schema_1 = require("@manuscripts/json-schema");
|
|
32
|
+
const react_1 = __importStar(require("react"));
|
|
33
|
+
const creatable_1 = __importDefault(require("react-select/creatable"));
|
|
34
|
+
const styled_components_1 = __importStar(require("styled-components"));
|
|
35
|
+
const authors_1 = require("../../lib/authors");
|
|
36
|
+
const AffiliationButton_1 = require("./AffiliationButton");
|
|
37
|
+
const AddAffiliation = (0, styled_components_1.default)(AddAuthor_1.default) `
|
|
38
|
+
width: 24px;
|
|
39
|
+
height: 24px;
|
|
40
|
+
margin-right: 4px;
|
|
41
|
+
|
|
42
|
+
circle,
|
|
43
|
+
use {
|
|
44
|
+
fill: ${(props) => props.theme.colors.brand.default};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
path {
|
|
48
|
+
mask: none;
|
|
49
|
+
}
|
|
50
|
+
`;
|
|
51
|
+
const AddAffiliationIndicator = () => react_1.default.createElement(AddAffiliation, null);
|
|
52
|
+
exports.AddAffiliationIndicator = AddAffiliationIndicator;
|
|
53
|
+
const getSelectStyles = (focus, theme) => ({
|
|
54
|
+
backgroundColor: focus
|
|
55
|
+
? theme.colors.background.fifth
|
|
56
|
+
: theme.colors.background.primary,
|
|
57
|
+
borderColor: focus
|
|
58
|
+
? theme.colors.border.field.active
|
|
59
|
+
: theme.colors.border.field.default,
|
|
60
|
+
'&:hover': {
|
|
61
|
+
backgroundColor: theme.colors.background.fifth,
|
|
62
|
+
},
|
|
63
|
+
borderRadius: theme.grid.radius.default,
|
|
64
|
+
boxShadow: 'none',
|
|
65
|
+
fontFamily: theme.font.family.sans,
|
|
66
|
+
});
|
|
67
|
+
const AuthorAffiliations = ({ author, affiliations, onSave, onAdd, onRemove, }) => {
|
|
68
|
+
const theme = (0, react_1.useContext)(styled_components_1.ThemeContext);
|
|
69
|
+
const [searchText, setSearchText] = (0, react_1.useState)('');
|
|
70
|
+
const affiliationMap = (0, react_1.useMemo)(() => new Map(affiliations.map((a) => [a.id, a])), [affiliations]);
|
|
71
|
+
const authorAffiliations = (0, react_1.useMemo)(() => {
|
|
72
|
+
var _a;
|
|
73
|
+
return (_a = author.affiliations) === null || _a === void 0 ? void 0 : _a.map((i) => affiliationMap.get(i));
|
|
74
|
+
}, [affiliationMap, author]);
|
|
75
|
+
const otherAffiliations = (0, react_1.useMemo)(() => {
|
|
76
|
+
var _a;
|
|
77
|
+
const copy = new Map(affiliationMap);
|
|
78
|
+
(_a = author.affiliations) === null || _a === void 0 ? void 0 : _a.forEach((i) => copy.delete(i));
|
|
79
|
+
return Array.from(copy.values());
|
|
80
|
+
}, [affiliationMap, author]);
|
|
81
|
+
const options = otherAffiliations.map((a) => ({
|
|
82
|
+
value: a.id,
|
|
83
|
+
label: (0, authors_1.affiliationLabel)(a),
|
|
84
|
+
}));
|
|
85
|
+
const handleChange = (id) => {
|
|
86
|
+
const affiliation = affiliationMap.get(id);
|
|
87
|
+
if (!affiliation) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
onAdd(affiliation);
|
|
91
|
+
setSearchText('');
|
|
92
|
+
};
|
|
93
|
+
const handleCreate = (institution) => {
|
|
94
|
+
const affiliation = {
|
|
95
|
+
id: (0, json_schema_1.generateID)(json_schema_1.ObjectTypes.Affiliation),
|
|
96
|
+
addressLine1: '',
|
|
97
|
+
city: '',
|
|
98
|
+
country: '',
|
|
99
|
+
county: '',
|
|
100
|
+
department: '',
|
|
101
|
+
institution: institution,
|
|
102
|
+
postCode: '',
|
|
103
|
+
priority: 0,
|
|
104
|
+
};
|
|
105
|
+
onSave(affiliation);
|
|
106
|
+
onAdd(affiliation);
|
|
107
|
+
};
|
|
108
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
109
|
+
authorAffiliations.map((a) => (react_1.default.createElement(AffiliationButton_1.AffiliationButton, { key: `${author.id}-${a.id}`, affiliation: a, onSave: onSave, onRemove: () => onRemove(a) }))),
|
|
110
|
+
react_1.default.createElement(creatable_1.default, { options: options, isMulti: false, isClearable: true, value: null, inputValue: searchText, components: {
|
|
111
|
+
IndicatorsContainer: exports.AddAffiliationIndicator,
|
|
112
|
+
}, placeholder: "Begin typing to add affiliation", noOptionsMessage: () => 'Type the name of an institution', onChange: (i) => i && handleChange(i.value), onInputChange: setSearchText, onCreateOption: (v) => v && handleCreate(v), isValidNewOption: (t) => !!t, styles: {
|
|
113
|
+
control: (provided, state) => (Object.assign(Object.assign({}, provided), getSelectStyles(state.isFocused, theme))),
|
|
114
|
+
} })));
|
|
115
|
+
};
|
|
116
|
+
exports.AuthorAffiliations = AuthorAffiliations;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* © 2019 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.AuthorDetailsForm = exports.Fieldset = exports.LabelText = void 0;
|
|
45
|
+
const style_guide_1 = require("@manuscripts/style-guide");
|
|
46
|
+
const formik_1 = require("formik");
|
|
47
|
+
const react_1 = __importStar(require("react"));
|
|
48
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
49
|
+
const ChangeHandlingForm_1 = require("./ChangeHandlingForm");
|
|
50
|
+
exports.LabelText = styled_components_1.default.div `
|
|
51
|
+
font: ${(props) => props.theme.font.weight.normal}
|
|
52
|
+
${(props) => props.theme.font.size.normal} / 1
|
|
53
|
+
${(props) => props.theme.font.family.sans};
|
|
54
|
+
letter-spacing: -0.2px;
|
|
55
|
+
color: ${(props) => props.theme.colors.text.primary};
|
|
56
|
+
`;
|
|
57
|
+
exports.Fieldset = styled_components_1.default.fieldset `
|
|
58
|
+
padding: 0;
|
|
59
|
+
margin: 0;
|
|
60
|
+
border: none;
|
|
61
|
+
`;
|
|
62
|
+
const OrcidContainer = styled_components_1.default.div `
|
|
63
|
+
margin: 16px 0 0;
|
|
64
|
+
`;
|
|
65
|
+
const AuthorDetailsForm = ({ values, onChange, onSave, actionsRef, }) => {
|
|
66
|
+
const formRef = (0, react_1.useRef)(null);
|
|
67
|
+
if (actionsRef && !actionsRef.current) {
|
|
68
|
+
actionsRef.current = {
|
|
69
|
+
reset: () => {
|
|
70
|
+
var _a;
|
|
71
|
+
(_a = formRef.current) === null || _a === void 0 ? void 0 : _a.resetForm();
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
return (react_1.default.createElement(formik_1.Formik, { initialValues: values, onSubmit: onSave, enableReinitialize: true, validateOnChange: false, innerRef: formRef }, (formik) => {
|
|
76
|
+
const isAuthor = formik.values.role === 'author';
|
|
77
|
+
return (react_1.default.createElement(ChangeHandlingForm_1.ChangeHandlingForm, { onChange: onChange },
|
|
78
|
+
react_1.default.createElement(exports.Fieldset, null,
|
|
79
|
+
react_1.default.createElement(style_guide_1.TextFieldGroupContainer, null,
|
|
80
|
+
react_1.default.createElement(formik_1.Field, { name: 'bibliographicName.given' }, (props) => (react_1.default.createElement(style_guide_1.TextField, Object.assign({ id: 'given-name', placeholder: 'Given name' }, props.field)))),
|
|
81
|
+
react_1.default.createElement(formik_1.Field, { name: 'bibliographicName.family' }, (props) => (react_1.default.createElement(style_guide_1.TextField, Object.assign({ id: 'family-name', placeholder: 'Family name' }, props.field))))),
|
|
82
|
+
react_1.default.createElement(formik_1.Field, { name: 'email', type: 'email' }, (props) => (react_1.default.createElement(style_guide_1.TextField, Object.assign({ id: 'email', placeholder: 'Email address' }, props.field)))),
|
|
83
|
+
react_1.default.createElement(style_guide_1.CheckboxLabel, { disabled: !isAuthor },
|
|
84
|
+
react_1.default.createElement(formik_1.Field, { name: 'isCorresponding' }, (props) => (react_1.default.createElement(style_guide_1.CheckboxField, Object.assign({ id: 'isCorresponding', checked: props.field.value, disabled: !isAuthor }, props.field)))),
|
|
85
|
+
react_1.default.createElement(exports.LabelText, null, "Corresponding Author")),
|
|
86
|
+
react_1.default.createElement(style_guide_1.CheckboxLabel, null,
|
|
87
|
+
react_1.default.createElement(formik_1.Field, { name: 'role', type: 'checkbox' }, (props) => (react_1.default.createElement(style_guide_1.CheckboxField, { name: 'role', checked: isAuthor, onChange: (e) => {
|
|
88
|
+
formik.setFieldValue(props.field.name, e.target.checked ? 'author' : 'other', false);
|
|
89
|
+
} }))),
|
|
90
|
+
react_1.default.createElement(exports.LabelText, null, "Include in Authors List")),
|
|
91
|
+
react_1.default.createElement(OrcidContainer, null,
|
|
92
|
+
react_1.default.createElement(style_guide_1.TextFieldLabel, null,
|
|
93
|
+
react_1.default.createElement(exports.LabelText, null, "ORCID"),
|
|
94
|
+
react_1.default.createElement(formik_1.Field, { name: 'ORCIDIdentifier', type: 'text' }, (props) => (react_1.default.createElement(style_guide_1.TextField, Object.assign({ id: 'orcid', placeholder: 'https://orcid.org/...' }, props.field)))))))));
|
|
95
|
+
}));
|
|
96
|
+
};
|
|
97
|
+
exports.AuthorDetailsForm = AuthorDetailsForm;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.AuthorFormPlaceholder = void 0;
|
|
7
|
+
const ContributorDetailsPlaceholder_1 = __importDefault(require("@manuscripts/assets/react/ContributorDetailsPlaceholder"));
|
|
8
|
+
const react_1 = __importDefault(require("react"));
|
|
9
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
10
|
+
const OuterContainer = styled_components_1.default.div `
|
|
11
|
+
display: flex;
|
|
12
|
+
flex-direction: column;
|
|
13
|
+
align-items: center;
|
|
14
|
+
justify-content: center;
|
|
15
|
+
height: 100%;
|
|
16
|
+
overflow-y: auto;
|
|
17
|
+
`;
|
|
18
|
+
const InnerContainer = styled_components_1.default.div `
|
|
19
|
+
text-align: center;
|
|
20
|
+
max-width: 480px;
|
|
21
|
+
font-size: ${(props) => props.theme.font.size.xlarge};
|
|
22
|
+
line-height: ${(props) => props.theme.font.lineHeight.large};
|
|
23
|
+
`;
|
|
24
|
+
const Placeholder = styled_components_1.default.div `
|
|
25
|
+
display: flex;
|
|
26
|
+
justify-content: center;
|
|
27
|
+
margin-bottom: ${(props) => props.theme.grid.unit * 5}px;
|
|
28
|
+
`;
|
|
29
|
+
const Action = styled_components_1.default.div `
|
|
30
|
+
display: flex;
|
|
31
|
+
align-items: center;
|
|
32
|
+
justify-content: center;
|
|
33
|
+
font-size: ${(props) => props.theme.font.size.xlarge};
|
|
34
|
+
font-weight: ${(props) => props.theme.font.weight.medium};
|
|
35
|
+
letter-spacing: -0.5px;
|
|
36
|
+
`;
|
|
37
|
+
const Message = styled_components_1.default.div `
|
|
38
|
+
max-width: 400px;
|
|
39
|
+
font-size: ${(props) => props.theme.font.size.xlarge};
|
|
40
|
+
margin-top: ${(props) => props.theme.grid.unit * 6}px;
|
|
41
|
+
font-weight: ${(props) => props.theme.font.weight.light};
|
|
42
|
+
color: ${(props) => props.theme.colors.text.secondary};
|
|
43
|
+
|
|
44
|
+
@media (max-width: 850px) {
|
|
45
|
+
margin-right: ${(props) => props.theme.grid.unit * 5}px;
|
|
46
|
+
margin-left: ${(props) => props.theme.grid.unit * 5}px;
|
|
47
|
+
max-width: 350px;
|
|
48
|
+
}
|
|
49
|
+
`;
|
|
50
|
+
const AuthorFormPlaceholder = () => (react_1.default.createElement(OuterContainer, { "data-cy": 'author-details' },
|
|
51
|
+
react_1.default.createElement(InnerContainer, null,
|
|
52
|
+
react_1.default.createElement(Placeholder, null,
|
|
53
|
+
react_1.default.createElement(ContributorDetailsPlaceholder_1.default, null)),
|
|
54
|
+
react_1.default.createElement(react_1.default.Fragment, null,
|
|
55
|
+
react_1.default.createElement(Action, null, "Author Details"),
|
|
56
|
+
react_1.default.createElement(Message, null, "Select an author from the list to display their details here.")))));
|
|
57
|
+
exports.AuthorFormPlaceholder = AuthorFormPlaceholder;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* © 2019 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.AuthorList = void 0;
|
|
22
|
+
const style_guide_1 = require("@manuscripts/style-guide");
|
|
23
|
+
const react_1 = __importDefault(require("react"));
|
|
24
|
+
const react_dnd_1 = require("react-dnd");
|
|
25
|
+
const react_dnd_html5_backend_1 = require("react-dnd-html5-backend");
|
|
26
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
27
|
+
const DraggableAuthor_1 = require("./DraggableAuthor");
|
|
28
|
+
const AuthorListContainer = styled_components_1.default.div `
|
|
29
|
+
flex: 1;
|
|
30
|
+
overflow-y: visible;
|
|
31
|
+
`;
|
|
32
|
+
const AuthorList = ({ author, authors, onSelect, moveAuthor, }) => {
|
|
33
|
+
return (react_1.default.createElement(react_dnd_1.DndProvider, { backend: react_dnd_html5_backend_1.HTML5Backend },
|
|
34
|
+
react_1.default.createElement(AuthorListContainer, null,
|
|
35
|
+
react_1.default.createElement(style_guide_1.DragLayer, null),
|
|
36
|
+
authors.map((a) => {
|
|
37
|
+
return (react_1.default.createElement(DraggableAuthor_1.DraggableAuthor, { key: a.id, author: a, isSelected: a.id === (author === null || author === void 0 ? void 0 : author.id), onClick: () => onSelect(a), moveAuthor: moveAuthor }));
|
|
38
|
+
}))));
|
|
39
|
+
};
|
|
40
|
+
exports.AuthorList = AuthorList;
|