@manuscripts/body-editor 1.7.19 → 1.7.20

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.
Files changed (83) hide show
  1. package/dist/cjs/components/authors/AffiliationButton.js +105 -0
  2. package/dist/cjs/components/authors/AffiliationForm.js +50 -0
  3. package/dist/cjs/components/authors/AuthorActions.js +61 -0
  4. package/dist/cjs/components/authors/AuthorAffiliations.js +116 -0
  5. package/dist/cjs/components/authors/AuthorDetailsForm.js +97 -0
  6. package/dist/cjs/components/authors/AuthorFormPlaceholder.js +57 -0
  7. package/dist/cjs/components/authors/AuthorList.js +40 -0
  8. package/dist/cjs/components/authors/AuthorsModal.js +226 -0
  9. package/dist/cjs/components/authors/ChangeHandlingForm.js +37 -0
  10. package/dist/cjs/components/authors/DeleteAuthorConfirmationDialog.js +23 -0
  11. package/dist/cjs/components/authors/DraggableAuthor.js +170 -0
  12. package/dist/cjs/components/authors/SaveAuthorConfirmationDialog.js +21 -0
  13. package/dist/cjs/lib/array-reducer.js +2 -0
  14. package/dist/cjs/lib/authors.js +43 -0
  15. package/dist/cjs/lib/track-changes-utils.js +5 -1
  16. package/dist/cjs/lib/utils.js +1 -5
  17. package/dist/cjs/lib/view.js +97 -0
  18. package/dist/cjs/views/base_node_view.js +0 -19
  19. package/dist/cjs/views/bibliography_element.js +3 -2
  20. package/dist/cjs/views/citation_editable.js +3 -2
  21. package/dist/cjs/views/contributors.js +78 -25
  22. package/dist/es/components/authors/AffiliationButton.js +75 -0
  23. package/dist/es/components/authors/AffiliationForm.js +43 -0
  24. package/dist/es/components/authors/AuthorActions.js +31 -0
  25. package/dist/es/components/authors/AuthorAffiliations.js +85 -0
  26. package/dist/es/components/authors/AuthorDetailsForm.js +67 -0
  27. package/dist/es/components/authors/AuthorFormPlaceholder.js +50 -0
  28. package/dist/es/components/authors/AuthorList.js +33 -0
  29. package/dist/es/components/authors/AuthorsModal.js +196 -0
  30. package/dist/es/components/authors/ChangeHandlingForm.js +10 -0
  31. package/dist/es/components/authors/DeleteAuthorConfirmationDialog.js +16 -0
  32. package/dist/es/components/authors/DraggableAuthor.js +140 -0
  33. package/dist/es/components/authors/SaveAuthorConfirmationDialog.js +14 -0
  34. package/dist/es/configs/editor-views.js +2 -2
  35. package/dist/es/lib/array-reducer.js +2 -0
  36. package/dist/es/lib/authors.js +36 -0
  37. package/dist/es/lib/track-changes-utils.js +3 -0
  38. package/dist/es/lib/utils.js +1 -4
  39. package/dist/es/lib/view.js +64 -0
  40. package/dist/es/views/base_node_view.js +0 -19
  41. package/dist/es/views/bibliography_element.js +3 -2
  42. package/dist/es/views/citation_editable.js +3 -2
  43. package/dist/es/views/contributors.js +79 -26
  44. package/dist/types/components/authors/AffiliationButton.d.ts +8 -0
  45. package/dist/types/components/authors/AffiliationForm.d.ts +7 -0
  46. package/dist/types/components/authors/AuthorActions.d.ts +9 -0
  47. package/dist/types/components/authors/AuthorAffiliations.d.ts +11 -0
  48. package/dist/types/components/authors/AuthorDetailsForm.d.ts +30 -0
  49. package/dist/types/components/authors/AuthorFormPlaceholder.d.ts +2 -0
  50. package/dist/types/components/authors/AuthorList.d.ts +25 -0
  51. package/dist/types/components/authors/AuthorsModal.d.ts +26 -0
  52. package/dist/types/components/authors/ChangeHandlingForm.d.ts +5 -0
  53. package/dist/types/components/authors/DeleteAuthorConfirmationDialog.d.ts +9 -0
  54. package/dist/types/components/authors/DraggableAuthor.d.ts +25 -0
  55. package/dist/types/components/authors/SaveAuthorConfirmationDialog.d.ts +7 -0
  56. package/dist/types/components/outline/DraggableTree.d.ts +1 -1
  57. package/dist/types/configs/ManuscriptsEditor.d.ts +0 -2
  58. package/dist/types/configs/editor-views.d.ts +0 -28
  59. package/dist/types/lib/array-reducer.d.ts +5 -1
  60. package/dist/types/lib/authors.d.ts +23 -0
  61. package/dist/types/lib/track-changes-utils.d.ts +1 -0
  62. package/dist/types/lib/utils.d.ts +0 -1
  63. package/dist/types/lib/view.d.ts +25 -0
  64. package/dist/types/views/base_node_view.d.ts +1 -4
  65. package/dist/types/views/bibliography_element_editable.d.ts +0 -2
  66. package/dist/types/views/blockquote_element_editable.d.ts +0 -2
  67. package/dist/types/views/bullet_list_editable.d.ts +0 -2
  68. package/dist/types/views/contributors.d.ts +25 -8
  69. package/dist/types/views/editable_block.d.ts +0 -2
  70. package/dist/types/views/equation_element_editable.d.ts +0 -2
  71. package/dist/types/views/figure_element_editable.d.ts +0 -2
  72. package/dist/types/views/footnote_editable.d.ts +0 -2
  73. package/dist/types/views/footnotes_element_editable.d.ts +0 -2
  74. package/dist/types/views/listing_element_editable.d.ts +0 -2
  75. package/dist/types/views/ordered_list_editable.d.ts +0 -2
  76. package/dist/types/views/paragraph_editable.d.ts +0 -2
  77. package/dist/types/views/placeholder_element_editable.d.ts +0 -2
  78. package/dist/types/views/pullquote_element_editable.d.ts +0 -2
  79. package/dist/types/views/section_title_editable.d.ts +0 -2
  80. package/dist/types/views/table_element_editable.d.ts +0 -2
  81. package/dist/types/views/toc_element_editable.d.ts +0 -2
  82. package/package.json +4 -3
  83. package/styles/AdvancedEditor.css +3 -3
@@ -0,0 +1,226 @@
1
+ "use strict";
2
+ /*!
3
+ * © 2024 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.AuthorsModal = void 0;
45
+ const AddIcon_1 = __importDefault(require("@manuscripts/assets/react/AddIcon"));
46
+ const json_schema_1 = require("@manuscripts/json-schema");
47
+ const style_guide_1 = require("@manuscripts/style-guide");
48
+ const lodash_1 = require("lodash");
49
+ const react_1 = __importStar(require("react"));
50
+ const styled_components_1 = __importDefault(require("styled-components"));
51
+ const array_reducer_1 = require("../../lib/array-reducer");
52
+ const authors_1 = require("../../lib/authors");
53
+ const AuthorActions_1 = require("./AuthorActions");
54
+ const AuthorAffiliations_1 = require("./AuthorAffiliations");
55
+ const AuthorDetailsForm_1 = require("./AuthorDetailsForm");
56
+ const AuthorFormPlaceholder_1 = require("./AuthorFormPlaceholder");
57
+ const AuthorList_1 = require("./AuthorList");
58
+ const SaveAuthorConfirmationDialog_1 = require("./SaveAuthorConfirmationDialog");
59
+ const AddAuthorButton = styled_components_1.default.div `
60
+ display: flex;
61
+ align-items: center;
62
+ margin-bottom: ${(props) => props.theme.grid.unit * 4}px;
63
+ margin-left: ${(props) => props.theme.grid.unit * 2}px;
64
+ cursor: pointer;
65
+ `;
66
+ const ActionTitle = styled_components_1.default.div `
67
+ padding-left: ${(props) => props.theme.grid.unit * 2}px;
68
+ `;
69
+ const FormLabel = styled_components_1.default.legend `
70
+ margin-top: 12px;
71
+ margin-bottom: 12px;
72
+ font: ${(props) => props.theme.font.weight.normal}
73
+ ${(props) => props.theme.font.size.xlarge} /
74
+ ${(props) => props.theme.font.lineHeight.large}
75
+ ${(props) => props.theme.font.family.sans};
76
+ letter-spacing: -0.4px;
77
+ color: ${(props) => props.theme.colors.text.secondary};
78
+ `;
79
+ const AuthorForms = styled_components_1.default.div `
80
+ padding-left: ${(props) => props.theme.grid.unit * 3}px;
81
+ padding-right: ${(props) => props.theme.grid.unit * 3}px;
82
+ `;
83
+ const authorsReducer = (0, array_reducer_1.arrayReducer)((a, b) => a.id === b.id);
84
+ const affiliationsReducer = (0, array_reducer_1.arrayReducer)((a, b) => a.id === b.id);
85
+ const normalize = (author) => {
86
+ return {
87
+ id: author.id,
88
+ role: author.role,
89
+ affiliations: author.affiliations || [],
90
+ bibliographicName: author.bibliographicName,
91
+ email: author.email || '',
92
+ isCorresponding: author.isCorresponding || false,
93
+ ORCIDIdentifier: author.ORCIDIdentifier || '',
94
+ priority: author.priority,
95
+ isJointContributor: author.isJointContributor || false,
96
+ };
97
+ };
98
+ const AuthorsModal = ({ authors: $authors, affiliations: $affiliations, author, onSaveAuthor, onDeleteAuthor, onSaveAffiliation, }) => {
99
+ const [isOpen, setOpen] = (0, react_1.useState)(true);
100
+ const [showConfirmationDialog, setShowConfirmationDialog] = (0, react_1.useState)(false);
101
+ const valuesRef = (0, react_1.useRef)();
102
+ const actionsRef = (0, react_1.useRef)();
103
+ const [authors, dispatchAuthors] = (0, react_1.useReducer)(authorsReducer, $authors.sort(authors_1.authorComparator));
104
+ const [affiliations, dispatchAffiliations] = (0, react_1.useReducer)(affiliationsReducer, $affiliations);
105
+ const [selection, setSelection] = (0, react_1.useState)(author);
106
+ const handleSelect = (author) => {
107
+ const values = valuesRef.current;
108
+ if (values && selection && !(0, lodash_1.isEqual)(values, normalize(selection))) {
109
+ setShowConfirmationDialog(true);
110
+ }
111
+ else {
112
+ setSelection(author);
113
+ }
114
+ };
115
+ const handleSaveAuthor = (values) => {
116
+ if (!values || !selection) {
117
+ return;
118
+ }
119
+ const author = Object.assign(Object.assign({}, selection), values);
120
+ onSaveAuthor(author);
121
+ setSelection(author);
122
+ setShowConfirmationDialog(false);
123
+ dispatchAuthors({
124
+ type: 'update',
125
+ items: [author],
126
+ });
127
+ };
128
+ const handleMoveAuthor = (from, to) => {
129
+ const copy = [...authors];
130
+ const order = copy.map((_, i) => (i === from ? to : i));
131
+ copy.sort((a, b) => order[authors.indexOf(a)] - order[authors.indexOf(b)]);
132
+ copy.forEach((a, i) => {
133
+ if (a.priority !== i) {
134
+ a.priority = i;
135
+ onSaveAuthor(a);
136
+ }
137
+ });
138
+ dispatchAuthors({
139
+ type: 'set',
140
+ state: copy,
141
+ });
142
+ };
143
+ const handleAddAuthor = () => {
144
+ const name = (0, json_schema_1.buildBibliographicName)({ given: '', family: '' });
145
+ const author = {
146
+ id: (0, json_schema_1.generateID)(json_schema_1.ObjectTypes.Contributor),
147
+ role: 'author',
148
+ affiliations: [],
149
+ bibliographicName: name,
150
+ email: '',
151
+ isCorresponding: false,
152
+ ORCIDIdentifier: '',
153
+ priority: authors.length,
154
+ isJointContributor: false,
155
+ };
156
+ onSaveAuthor(author);
157
+ setSelection(author);
158
+ dispatchAuthors({
159
+ type: 'update',
160
+ items: [author],
161
+ });
162
+ };
163
+ const handleDeleteAuthor = () => {
164
+ if (!selection) {
165
+ return;
166
+ }
167
+ onDeleteAuthor(selection);
168
+ setSelection(undefined);
169
+ dispatchAuthors({
170
+ type: 'delete',
171
+ item: selection,
172
+ });
173
+ };
174
+ const handleSaveAffiliation = (affiliation) => {
175
+ onSaveAffiliation(affiliation);
176
+ dispatchAffiliations({
177
+ type: 'update',
178
+ items: [affiliation],
179
+ });
180
+ };
181
+ const handleAddAffiliation = (affiliation) => {
182
+ if (!valuesRef.current) {
183
+ return;
184
+ }
185
+ const values = valuesRef.current;
186
+ const affiliations = values.affiliations || [];
187
+ handleSaveAuthor(Object.assign(Object.assign({}, values), { affiliations: [...affiliations, affiliation.id] }));
188
+ };
189
+ const handleRemoveAffiliation = (affiliation) => {
190
+ var _a;
191
+ if (!valuesRef.current) {
192
+ return;
193
+ }
194
+ const values = valuesRef.current;
195
+ handleSaveAuthor(Object.assign(Object.assign({}, values), { affiliations: (_a = values.affiliations) === null || _a === void 0 ? void 0 : _a.filter((i) => i !== affiliation.id) }));
196
+ };
197
+ const handleResetAuthor = () => {
198
+ var _a;
199
+ (_a = actionsRef.current) === null || _a === void 0 ? void 0 : _a.reset();
200
+ setShowConfirmationDialog(false);
201
+ };
202
+ const handleChangeAuthor = (values) => {
203
+ valuesRef.current = values;
204
+ };
205
+ return (react_1.default.createElement(style_guide_1.StyledModal, { isOpen: isOpen, onRequestClose: () => setOpen(false), shouldCloseOnOverlayClick: true },
206
+ react_1.default.createElement(style_guide_1.ModalContainer, null,
207
+ react_1.default.createElement(style_guide_1.ModalHeader, null,
208
+ react_1.default.createElement(style_guide_1.CloseButton, { onClick: () => setOpen(false), "data-cy": 'modal-close-button' })),
209
+ react_1.default.createElement(style_guide_1.ModalBody, null,
210
+ react_1.default.createElement(style_guide_1.ModalSidebar, { "data-cy": 'authors-sidebar' },
211
+ react_1.default.createElement(style_guide_1.ModalSidebarHeader, null,
212
+ react_1.default.createElement(style_guide_1.ModalSidebarTitle, null, "Authors")),
213
+ react_1.default.createElement(style_guide_1.SidebarContent, null,
214
+ react_1.default.createElement(AddAuthorButton, { onClick: handleAddAuthor },
215
+ react_1.default.createElement(AddIcon_1.default, { width: 40, height: 40 }),
216
+ react_1.default.createElement(ActionTitle, null, "Add Author")),
217
+ react_1.default.createElement(AuthorList_1.AuthorList, { author: selection, authors: authors, onSelect: handleSelect, moveAuthor: handleMoveAuthor }))),
218
+ react_1.default.createElement(style_guide_1.ScrollableModalContent, null, selection ? (react_1.default.createElement(AuthorForms, null,
219
+ react_1.default.createElement(SaveAuthorConfirmationDialog_1.SaveAuthorConfirmationDialog, { isOpen: showConfirmationDialog, onSave: () => handleSaveAuthor(valuesRef.current), onCancel: handleResetAuthor }),
220
+ react_1.default.createElement(AuthorActions_1.AuthorActions, { author: selection, onSave: () => handleSaveAuthor(valuesRef.current), onDelete: handleDeleteAuthor, onCancel: () => setOpen(false) }),
221
+ react_1.default.createElement(FormLabel, null, "Details"),
222
+ react_1.default.createElement(AuthorDetailsForm_1.AuthorDetailsForm, { values: normalize(selection), onChange: handleChangeAuthor, onSave: handleSaveAuthor, actionsRef: actionsRef }),
223
+ react_1.default.createElement(FormLabel, null, "Affiliations"),
224
+ react_1.default.createElement(AuthorAffiliations_1.AuthorAffiliations, { author: selection, affiliations: affiliations, onSave: handleSaveAffiliation, onAdd: handleAddAffiliation, onRemove: handleRemoveAffiliation }))) : (react_1.default.createElement(AuthorFormPlaceholder_1.AuthorFormPlaceholder, null)))))));
225
+ };
226
+ exports.AuthorsModal = AuthorsModal;
@@ -0,0 +1,37 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.ChangeHandlingForm = void 0;
27
+ const formik_1 = require("formik");
28
+ const react_1 = __importStar(require("react"));
29
+ const ChangeHandlingForm = (props) => {
30
+ const { values } = (0, formik_1.useFormikContext)();
31
+ (0, react_1.useEffect)(() => {
32
+ var _a;
33
+ (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, values);
34
+ }, [props.onChange, values]);
35
+ return react_1.default.createElement(formik_1.Form, null, props.children);
36
+ };
37
+ exports.ChangeHandlingForm = ChangeHandlingForm;
@@ -0,0 +1,23 @@
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.DeleteAuthorConfirmationDialog = void 0;
7
+ const style_guide_1 = require("@manuscripts/style-guide");
8
+ const react_1 = __importDefault(require("react"));
9
+ const authors_1 = require("../../lib/authors");
10
+ const DeleteAuthorConfirmationDialog = ({ isOpen, author, onDelete, onCancel }) => {
11
+ const label = (0, authors_1.authorLabel)(author);
12
+ return (react_1.default.createElement(style_guide_1.Dialog, { isOpen: isOpen, category: style_guide_1.Category.confirmation, header: 'Remove author', message: `Are you sure you want to remove ${label} from the authors list?`, actions: {
13
+ secondary: {
14
+ action: onDelete,
15
+ title: 'Delete',
16
+ },
17
+ primary: {
18
+ action: onCancel,
19
+ title: 'Cancel',
20
+ },
21
+ } }));
22
+ };
23
+ exports.DeleteAuthorConfirmationDialog = DeleteAuthorConfirmationDialog;
@@ -0,0 +1,170 @@
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.DraggableAuthor = void 0;
45
+ const CorrespondingAuthorBadge_1 = __importDefault(require("@manuscripts/assets/react/CorrespondingAuthorBadge"));
46
+ const VerticalEllipsis_1 = __importDefault(require("@manuscripts/assets/react/VerticalEllipsis"));
47
+ const style_guide_1 = require("@manuscripts/style-guide");
48
+ const react_1 = __importStar(require("react"));
49
+ const react_dnd_1 = require("react-dnd");
50
+ const styled_components_1 = __importDefault(require("styled-components"));
51
+ const authors_1 = require("../../lib/authors");
52
+ const AuthorContainer = styled_components_1.default.div `
53
+ padding: ${(props) => props.theme.grid.unit * 2}px;
54
+ display: flex;
55
+ justify-content: space-between;
56
+ align-items: center;
57
+ cursor: pointer;
58
+ transition: background-color 0.25s;
59
+ border: 1px solid transparent;
60
+ border-left: 0;
61
+ border-right: 0;
62
+
63
+ &:hover,
64
+ &.active {
65
+ background: ${(props) => props.theme.colors.background.fifth};
66
+ }
67
+
68
+ &.active {
69
+ border-color: ${(props) => props.theme.colors.border.primary};
70
+ }
71
+
72
+ &.dragging {
73
+ visibility: hidden;
74
+ }
75
+
76
+ &.drop-before {
77
+ border-top-color: ${(props) => props.theme.colors.brand.dark};
78
+ }
79
+
80
+ &.drop-after {
81
+ border-bottom-color: ${(props) => props.theme.colors.brand.dark};
82
+ }
83
+ `;
84
+ const AvatarContainer = styled_components_1.default.div `
85
+ display: inline-flex;
86
+ position: relative;
87
+ `;
88
+ const AuthorBadge = styled_components_1.default.div `
89
+ display: inline-flex;
90
+ align-items: center;
91
+ justify-content: center;
92
+ position: relative;
93
+ `;
94
+ const AuthorNotes = styled_components_1.default.div `
95
+ position: absolute;
96
+ top: 0;
97
+ right: 0;
98
+
99
+ & ${AuthorBadge}:not(:last-child) {
100
+ right: -20%;
101
+ }
102
+ `;
103
+ const AuthorName = styled_components_1.default.div `
104
+ margin-left: 12px;
105
+ flex: 1;
106
+ `;
107
+ const DragHandle = (0, styled_components_1.default)(VerticalEllipsis_1.default) `
108
+ cursor: move;
109
+ `;
110
+ const BEFORE = {
111
+ id: 'before',
112
+ diff: -0.5,
113
+ };
114
+ const AFTER = {
115
+ id: 'after',
116
+ diff: 0.5,
117
+ };
118
+ const getDropPosition = (element, monitor) => {
119
+ const rect = element.getBoundingClientRect();
120
+ const middle = (rect.bottom - rect.top) / 2;
121
+ const cursor = monitor.getClientOffset();
122
+ return cursor.y > middle + rect.top ? AFTER : BEFORE;
123
+ };
124
+ const DraggableAuthor = ({ author, isSelected, onClick, moveAuthor, }) => {
125
+ const [dropPosition, setDropPosition] = (0, react_1.useState)();
126
+ const ref = (0, react_1.useRef)(null);
127
+ const [{ isDragging }, dragRef] = (0, react_dnd_1.useDrag)({
128
+ item: {
129
+ type: 'author',
130
+ author,
131
+ },
132
+ collect: (monitor) => ({
133
+ isDragging: monitor.isDragging(),
134
+ }),
135
+ });
136
+ const [{ isOver }, dropRef] = (0, react_dnd_1.useDrop)({
137
+ accept: 'author',
138
+ collect: (monitor) => ({
139
+ isOver: monitor.isOver(),
140
+ }),
141
+ hover: (item, monitor) => {
142
+ if (!ref.current) {
143
+ return;
144
+ }
145
+ const position = getDropPosition(ref.current, monitor);
146
+ setDropPosition(position);
147
+ },
148
+ drop: (item, monitor) => {
149
+ if (!ref.current) {
150
+ return;
151
+ }
152
+ const position = getDropPosition(ref.current, monitor);
153
+ const from = item.author.priority;
154
+ const to = author.priority;
155
+ moveAuthor(from, to + position.diff);
156
+ },
157
+ });
158
+ dragRef(dropRef(ref));
159
+ const dragClass = isDragging ? 'dragging' : '';
160
+ const dropClass = isOver && dropPosition ? `drop-${dropPosition.id}` : '';
161
+ const activeClass = isSelected ? 'active' : '';
162
+ return (react_1.default.createElement(AuthorContainer, { ref: ref, className: `${dragClass} ${dropClass} ${activeClass}`, onClick: onClick },
163
+ react_1.default.createElement(AvatarContainer, null,
164
+ react_1.default.createElement(style_guide_1.Avatar, { size: 36, color: '#6e6e6e' }),
165
+ react_1.default.createElement(AuthorNotes, null, author.isCorresponding && (react_1.default.createElement(AuthorBadge, null,
166
+ react_1.default.createElement(CorrespondingAuthorBadge_1.default, null))))),
167
+ react_1.default.createElement(AuthorName, null, (0, authors_1.authorLabel)(author)),
168
+ isSelected && react_1.default.createElement(DragHandle, null)));
169
+ };
170
+ exports.DraggableAuthor = DraggableAuthor;
@@ -0,0 +1,21 @@
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.SaveAuthorConfirmationDialog = void 0;
7
+ const style_guide_1 = require("@manuscripts/style-guide");
8
+ const react_1 = __importDefault(require("react"));
9
+ const SaveAuthorConfirmationDialog = ({ isOpen, onSave, onCancel }) => {
10
+ return (react_1.default.createElement(style_guide_1.Dialog, { isOpen: isOpen, category: style_guide_1.Category.confirmation, header: "You've made changes to this option", message: "Would you like to save or discard your changes?", actions: {
11
+ secondary: {
12
+ action: onCancel,
13
+ title: 'Discard',
14
+ },
15
+ primary: {
16
+ action: onSave,
17
+ title: 'Save',
18
+ },
19
+ } }));
20
+ };
21
+ exports.SaveAuthorConfirmationDialog = SaveAuthorConfirmationDialog;
@@ -39,6 +39,8 @@ const arrayReducer = (isEqual = (a, b) => a === b) => {
39
39
  return handleUpdate(state, action.items);
40
40
  case 'delete':
41
41
  return handleDelete(state, action.item);
42
+ case 'set':
43
+ return action.state;
42
44
  }
43
45
  };
44
46
  };
@@ -0,0 +1,43 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.authorComparator = exports.initials = exports.authorLabel = exports.affiliationLabel = void 0;
19
+ const affiliationLabel = (affiliation) => {
20
+ const institution = affiliation.institution;
21
+ if (!institution) {
22
+ return '(unknown institution)';
23
+ }
24
+ const department = affiliation.department;
25
+ return department ? `${institution} (${department})`.trim() : institution;
26
+ };
27
+ exports.affiliationLabel = affiliationLabel;
28
+ const authorLabel = (author) => {
29
+ const name = author.bibliographicName;
30
+ const parts = [(0, exports.initials)(name), name.family, name.suffix].filter(Boolean);
31
+ return parts.length ? parts.join(' ') : 'Unknown Author';
32
+ };
33
+ exports.authorLabel = authorLabel;
34
+ const initials = (name) => name.given
35
+ ? name.given
36
+ .trim()
37
+ .split(' ')
38
+ .map((part) => part.substring(0, 1).toUpperCase() + '.')
39
+ .join('')
40
+ : '';
41
+ exports.initials = initials;
42
+ const authorComparator = (a, b) => a.priority - b.priority;
43
+ exports.authorComparator = authorComparator;
@@ -15,7 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.getAttrsTrackingButton = exports.getActualAttrs = exports.isTracked = exports.getChangeClasses = exports.isPendingSetAttrs = exports.isPending = exports.isPendingInsert = exports.isDeleted = exports.isRejectedInsert = void 0;
18
+ exports.isHidden = exports.getAttrsTrackingButton = exports.getActualAttrs = exports.isTracked = exports.getChangeClasses = exports.isPendingSetAttrs = exports.isPending = exports.isPendingInsert = exports.isDeleted = exports.isRejectedInsert = void 0;
19
19
  const assets_1 = require("../assets");
20
20
  function isRejectedInsert(node) {
21
21
  if (node.attrs.dataTracked) {
@@ -99,3 +99,7 @@ const getAttrsTrackingButton = (changeID) => {
99
99
  return el;
100
100
  };
101
101
  exports.getAttrsTrackingButton = getAttrsTrackingButton;
102
+ function isHidden(node) {
103
+ return isDeleted(node) || isRejectedInsert(node);
104
+ }
105
+ exports.isHidden = isHidden;
@@ -15,7 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.isMetaNode = exports.findParentElement = exports.findParentSection = exports.findParentNodeWithIdValue = exports.findParentNodeWithId = exports.getChildOfType = exports.getMatchingDescendant = exports.getMatchingChild = exports.iterateChildren = void 0;
18
+ exports.findParentElement = exports.findParentSection = exports.findParentNodeWithIdValue = exports.findParentNodeWithId = exports.getChildOfType = exports.getMatchingDescendant = exports.getMatchingChild = exports.iterateChildren = void 0;
19
19
  const transform_1 = require("@manuscripts/transform");
20
20
  const prosemirror_utils_1 = require("prosemirror-utils");
21
21
  function* iterateChildren(node, recurse = false) {
@@ -58,7 +58,3 @@ const findParentElement = (selection, validIds) => (0, prosemirror_utils_1.findP
58
58
  return (0, transform_1.isElementNodeType)(node.type) && node.attrs.id;
59
59
  })(selection);
60
60
  exports.findParentElement = findParentElement;
61
- const isMetaNode = (nodeType) => nodeType === transform_1.schema.nodes.bibliography_item.name ||
62
- nodeType === transform_1.schema.nodes.affiliation.name ||
63
- nodeType === transform_1.schema.nodes.contributor.name;
64
- exports.isMetaNode = isMetaNode;
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ /*!
3
+ * © 2024 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
+ Object.defineProperty(exports, "__esModule", { value: true });
41
+ exports.deleteNode = exports.updateNodeAttrs = exports.updateNode = exports.findChildrenAttrsByType = exports.findChildrenByType = exports.findChildByType = exports.findChildByID = void 0;
42
+ const transform_1 = require("@manuscripts/transform");
43
+ const utils = __importStar(require("prosemirror-utils"));
44
+ const track_changes_utils_1 = require("./track-changes-utils");
45
+ const metaNodeTypes = [
46
+ transform_1.schema.nodes.bibliography_item,
47
+ transform_1.schema.nodes.affiliation,
48
+ transform_1.schema.nodes.contributor,
49
+ ];
50
+ const updateMetaNode = 'track-changes-update-meta-node';
51
+ const findChildByID = (view, id) => {
52
+ const doc = view.state.doc;
53
+ const children = utils.findChildren(doc, (n) => n.attrs.id === id);
54
+ return children.length ? children[0] : undefined;
55
+ };
56
+ exports.findChildByID = findChildByID;
57
+ const findChildByType = (view, type) => {
58
+ const children = (0, exports.findChildrenByType)(view, type);
59
+ return children.length ? children[0] : undefined;
60
+ };
61
+ exports.findChildByType = findChildByType;
62
+ const findChildrenByType = (view, type) => {
63
+ const doc = view.state.doc;
64
+ return utils.findChildrenByType(doc, type).filter((n) => !(0, track_changes_utils_1.isHidden)(n.node));
65
+ };
66
+ exports.findChildrenByType = findChildrenByType;
67
+ const findChildrenAttrsByType = (view, type) => {
68
+ return (0, exports.findChildrenByType)(view, type).map((n) => (0, track_changes_utils_1.getActualAttrs)(n.node));
69
+ };
70
+ exports.findChildrenAttrsByType = findChildrenAttrsByType;
71
+ const updateNode = (view, node) => {
72
+ (0, exports.updateNodeAttrs)(view, node.type, node.attrs);
73
+ };
74
+ exports.updateNode = updateNode;
75
+ const updateNodeAttrs = (view, type, attrs) => {
76
+ const copy = Object.assign({}, attrs);
77
+ delete copy.dataTracked;
78
+ const child = (0, exports.findChildByID)(view, attrs.id);
79
+ if (child) {
80
+ const pos = child.pos;
81
+ const tr = view.state.tr.setNodeMarkup(pos, undefined, attrs);
82
+ if (metaNodeTypes.includes(type)) {
83
+ tr.setMeta(updateMetaNode, true);
84
+ }
85
+ view.dispatch(tr);
86
+ }
87
+ };
88
+ exports.updateNodeAttrs = updateNodeAttrs;
89
+ const deleteNode = (view, id) => {
90
+ const child = (0, exports.findChildByID)(view, id);
91
+ if (child) {
92
+ const pos = child.pos;
93
+ const node = child.node;
94
+ view.dispatch(view.state.tr.delete(pos, pos + node.nodeSize));
95
+ }
96
+ };
97
+ exports.deleteNode = deleteNode;