@manuscripts/body-editor 3.10.0 → 3.10.2

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 (36) hide show
  1. package/dist/cjs/commands.js +4 -5
  2. package/dist/cjs/components/affiliations/AffiliationsModal.js +10 -10
  3. package/dist/cjs/components/authors/AuthorDetailsForm.js +4 -4
  4. package/dist/cjs/components/authors/AuthorsModal.js +13 -17
  5. package/dist/cjs/components/keywords/AddKeywordInline.js +21 -8
  6. package/dist/cjs/lib/__tests__/authors.test.js +20 -46
  7. package/dist/cjs/lib/__tests__/plugins.test.js +1 -9
  8. package/dist/cjs/lib/authors.js +5 -6
  9. package/dist/cjs/lib/comments.js +1 -3
  10. package/dist/cjs/lib/normalize.js +6 -7
  11. package/dist/cjs/plugins/affiliations.js +1 -1
  12. package/dist/cjs/testing/default-editor-data.js +7 -34
  13. package/dist/cjs/versions.js +1 -1
  14. package/dist/cjs/views/contributors.js +1 -1
  15. package/dist/es/commands.js +4 -5
  16. package/dist/es/components/affiliations/AffiliationsModal.js +10 -10
  17. package/dist/es/components/authors/AuthorDetailsForm.js +4 -4
  18. package/dist/es/components/authors/AuthorsModal.js +14 -18
  19. package/dist/es/components/keywords/AddKeywordInline.js +21 -8
  20. package/dist/es/lib/__tests__/authors.test.js +20 -46
  21. package/dist/es/lib/__tests__/plugins.test.js +1 -9
  22. package/dist/es/lib/authors.js +5 -6
  23. package/dist/es/lib/comments.js +1 -3
  24. package/dist/es/lib/normalize.js +6 -7
  25. package/dist/es/plugins/affiliations.js +1 -1
  26. package/dist/es/testing/default-editor-data.js +6 -33
  27. package/dist/es/versions.js +1 -1
  28. package/dist/es/views/contributors.js +1 -1
  29. package/dist/types/components/keywords/AddKeywordInline.d.ts +15 -0
  30. package/dist/types/configs/ManuscriptsEditor.d.ts +1 -2
  31. package/dist/types/index.d.ts +0 -1
  32. package/dist/types/lib/authors.d.ts +1 -2
  33. package/dist/types/testing/default-editor-data.d.ts +0 -11
  34. package/dist/types/types.d.ts +0 -13
  35. package/dist/types/versions.d.ts +1 -1
  36. package/package.json +4 -6
@@ -17,7 +17,6 @@
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.addInlineComment = exports.addNodeComment = exports.createAndFillTableElement = exports.selectAllIsolating = exports.ignoreAtomBlockNodeForward = exports.isAtEndOfTextBlock = exports.ignoreMetaNodeBackspaceCommand = exports.ignoreAtomBlockNodeBackward = exports.isTextSelection = exports.isAtStartOfTextBlock = exports.insertTransGraphicalAbstract = exports.insertTransAbstract = exports.insertTOCSection = exports.insertBibliographySection = exports.insertList = exports.insertKeywords = exports.insertAward = exports.insertAffiliation = exports.insertContributors = exports.insertGraphicalAbstract = exports.insertBackmatterSection = exports.insertAbstractSection = exports.insertSection = exports.insertBoxElement = exports.insertInlineFootnote = exports.insertFootnotesElement = exports.insertTableElementFooter = exports.insertInlineEquation = exports.insertCrossReference = exports.insertInlineCitation = exports.insertLink = exports.insertSectionLabel = exports.findPosBeforeFirstSubsection = exports.insertBreak = exports.deleteBlock = exports.insertBlock = exports.insertAttachment = exports.insertSupplement = exports.insertTable = exports.insertEmbed = exports.insertFigure = exports.insertGeneralTableFootnote = exports.insertInlineTableFootnote = exports.createBlock = exports.createSelection = exports.canInsert = exports.blockActive = exports.isNodeSelection = exports.markActive = exports.addToStart = void 0;
19
19
  exports.paste = exports.copySelection = exports.exitEditorToContainer = exports.ignoreEnterInSubtitles = exports.insertHeroImage = exports.activateSearchReplace = exports.activateSearch = exports.autoComplete = exports.addColumns = exports.addHeaderRow = exports.addRows = void 0;
20
- const json_schema_1 = require("@manuscripts/json-schema");
21
20
  const track_changes_plugin_1 = require("@manuscripts/track-changes-plugin");
22
21
  const transform_1 = require("@manuscripts/transform");
23
22
  const prosemirror_model_1 = require("prosemirror-model");
@@ -1176,12 +1175,12 @@ const getParentNode = (selection) => {
1176
1175
  };
1177
1176
  const addNodeComment = (node, state, dispatch) => {
1178
1177
  const props = (0, editor_props_1.getEditorProps)(state);
1179
- const contribution = (0, json_schema_1.buildContribution)(props.userID);
1180
1178
  const attrs = {
1181
1179
  id: (0, transform_1.generateNodeID)(transform_1.schema.nodes.comment),
1182
1180
  contents: '',
1183
1181
  target: node.attrs.id,
1184
- contributions: [contribution],
1182
+ userID: props.userID,
1183
+ timestamp: Date.now(),
1185
1184
  };
1186
1185
  const comment = transform_1.schema.nodes.comment.create(attrs);
1187
1186
  const comments = (0, prosemirror_utils_1.findChildrenByType)(state.doc, transform_1.schema.nodes.comments)[0];
@@ -1212,12 +1211,12 @@ const addInlineComment = (state, dispatch) => {
1212
1211
  to = result.to;
1213
1212
  }
1214
1213
  const props = (0, editor_props_1.getEditorProps)(state);
1215
- const contribution = (0, json_schema_1.buildContribution)(props.userID);
1216
1214
  const attrs = {
1217
1215
  id: (0, transform_1.generateNodeID)(transform_1.schema.nodes.comment),
1218
1216
  contents: '',
1219
1217
  target: node.attrs.id,
1220
- contributions: [contribution],
1218
+ userID: props.userID,
1219
+ timestamp: Date.now(),
1221
1220
  originalText: selectedText() || state.doc.textBetween(from, to),
1222
1221
  selector: {
1223
1222
  from,
@@ -57,7 +57,7 @@ const AffiliationList_1 = require("./AffiliationList");
57
57
  function makeAuthorItems(authors) {
58
58
  return authors.map((author) => ({
59
59
  id: author.id,
60
- label: `${author.bibliographicName.given} ${author.bibliographicName.family}`,
60
+ label: `${author.given} ${author.family}`,
61
61
  }));
62
62
  }
63
63
  const AffiliationsModal = ({ authors: $authors, affiliations: $affiliations, affiliation, onSaveAffiliation, onDeleteAffiliation, onUpdateAuthors, clearSelection, addNewAffiliation = false, }) => {
@@ -84,7 +84,7 @@ const AffiliationsModal = ({ authors: $authors, affiliations: $affiliations, aff
84
84
  }
85
85
  const currentAffiliation = selection;
86
86
  const affiliatedAuthorIds = authors
87
- .filter((author) => author.affiliations?.includes(currentAffiliation.id))
87
+ .filter((author) => author.affiliationIDs?.includes(currentAffiliation.id))
88
88
  .map((author) => author.id);
89
89
  setSelectedAuthorIds(affiliatedAuthorIds);
90
90
  setAffiliationAuthorMap((prevMap) => {
@@ -137,7 +137,7 @@ const AffiliationsModal = ({ authors: $authors, affiliations: $affiliations, aff
137
137
  }
138
138
  else {
139
139
  const affiliatedAuthorIds = authors
140
- .filter((author) => author.affiliations?.includes(affiliation.id))
140
+ .filter((author) => author.affiliationIDs?.includes(affiliation.id))
141
141
  .map((author) => author.id);
142
142
  setNewAffiliation(false);
143
143
  setSelection(affiliation);
@@ -167,9 +167,9 @@ const AffiliationsModal = ({ authors: $authors, affiliations: $affiliations, aff
167
167
  setSelection(affiliation);
168
168
  const updatedAuthors = authors.map((author) => ({
169
169
  ...author,
170
- affiliations: selectedAuthorIds.includes(author.id)
171
- ? [...new Set([...(author.affiliations || []), affiliation.id])]
172
- : (author.affiliations || []).filter((id) => id !== affiliation.id),
170
+ affiliationIDs: selectedAuthorIds.includes(author.id)
171
+ ? [...new Set([...(author.affiliationIDs || []), affiliation.id])]
172
+ : (author.affiliationIDs || []).filter((id) => id !== affiliation.id),
173
173
  }));
174
174
  dispatchAuthors({
175
175
  type: 'update',
@@ -219,7 +219,7 @@ const AffiliationsModal = ({ authors: $authors, affiliations: $affiliations, aff
219
219
  }
220
220
  const updatedAuthors = authors.map((author) => ({
221
221
  ...author,
222
- affiliations: (author.affiliations || []).filter((id) => id !== selection.id),
222
+ affiliationIDs: (author.affiliationIDs || []).filter((id) => id !== selection.id),
223
223
  }));
224
224
  dispatchAuthors({
225
225
  type: 'update',
@@ -255,7 +255,7 @@ const AffiliationsModal = ({ authors: $authors, affiliations: $affiliations, aff
255
255
  return {
256
256
  id: authorId,
257
257
  label: author
258
- ? `${author.bibliographicName.given} ${author.bibliographicName.family}`
258
+ ? `${author.given} ${author.family}`
259
259
  : '',
260
260
  };
261
261
  })
@@ -300,7 +300,7 @@ const AffiliationsModal = ({ authors: $authors, affiliations: $affiliations, aff
300
300
  setSelection(pendingSelection);
301
301
  setNewAffiliation(false);
302
302
  const affiliatedAuthorIds = authors
303
- .filter((author) => author.affiliations?.some((aff) => aff === pendingSelection.id))
303
+ .filter((author) => author.affiliationIDs.some((aff) => aff === pendingSelection.id))
304
304
  .map((author) => author.id);
305
305
  setSelectedAuthorIds(affiliatedAuthorIds);
306
306
  valuesRef.current = (0, normalize_1.checkID)(pendingSelection, 'affiliation');
@@ -331,7 +331,7 @@ const AffiliationsModal = ({ authors: $authors, affiliations: $affiliations, aff
331
331
  setSelection(pendingSelection);
332
332
  setNewAffiliation(false);
333
333
  const affiliatedAuthorIds = authors
334
- .filter((author) => author.affiliations?.some((aff) => aff === pendingSelection.id))
334
+ .filter((author) => author.affiliationIDs?.some((aff) => aff === pendingSelection.id))
335
335
  .map((author) => author.id);
336
336
  setSelectedAuthorIds(affiliatedAuthorIds);
337
337
  }
@@ -79,7 +79,7 @@ const AuthorDetailsForm = ({ values, onChange, onSave, actionsRef, isEmailRequir
79
79
  const formRef = (0, react_1.useRef)(null);
80
80
  (0, react_1.useEffect)(() => {
81
81
  if (selectedAffiliations && formRef.current) {
82
- formRef.current.setFieldValue('affiliations', selectedAffiliations);
82
+ formRef.current.setFieldValue('affiliationIDs', selectedAffiliations);
83
83
  }
84
84
  }, [selectedAffiliations]);
85
85
  (0, react_1.useEffect)(() => {
@@ -112,11 +112,11 @@ const AuthorDetailsForm = ({ values, onChange, onSave, actionsRef, isEmailRequir
112
112
  react_1.default.createElement(style_guide_1.Label, { htmlFor: "prefix" }, "Prefix"),
113
113
  react_1.default.createElement(style_guide_1.TextField, { id: 'prefix', ...props.field }))))),
114
114
  react_1.default.createElement(style_guide_1.FormRow, null,
115
- react_1.default.createElement(formik_1.Field, { name: 'bibliographicName.given' }, (props) => (react_1.default.createElement(react_1.default.Fragment, null,
115
+ react_1.default.createElement(formik_1.Field, { name: 'given' }, (props) => (react_1.default.createElement(react_1.default.Fragment, null,
116
116
  react_1.default.createElement(style_guide_1.Label, { htmlFor: "given-name" }, "Given name"),
117
117
  react_1.default.createElement(style_guide_1.TextField, { id: 'given-name', ...props.field }))))),
118
118
  react_1.default.createElement(style_guide_1.FormRow, null,
119
- react_1.default.createElement(formik_1.Field, { name: 'bibliographicName.family' }, (props) => (react_1.default.createElement(react_1.default.Fragment, null,
119
+ react_1.default.createElement(formik_1.Field, { name: 'family' }, (props) => (react_1.default.createElement(react_1.default.Fragment, null,
120
120
  react_1.default.createElement(style_guide_1.Label, { htmlFor: "family-name" }, "Family name"),
121
121
  react_1.default.createElement(style_guide_1.TextField, { id: 'family-name', ...props.field }))))),
122
122
  react_1.default.createElement(style_guide_1.FormRow, null,
@@ -141,7 +141,7 @@ const AuthorDetailsForm = ({ values, onChange, onSave, actionsRef, isEmailRequir
141
141
  react_1.default.createElement(OrcidContainer, null,
142
142
  react_1.default.createElement(style_guide_1.FormRow, null,
143
143
  react_1.default.createElement(style_guide_1.Label, { htmlFor: "orcid" }, "ORCID"),
144
- react_1.default.createElement(formik_1.Field, { name: 'ORCIDIdentifier', type: 'text' }, (props) => (react_1.default.createElement(react_1.default.Fragment, null,
144
+ react_1.default.createElement(formik_1.Field, { name: 'ORCID', type: 'text' }, (props) => (react_1.default.createElement(react_1.default.Fragment, null,
145
145
  react_1.default.createElement(style_guide_1.Label, { htmlFor: "orcid", className: "sr-only" }, "ORCID"),
146
146
  react_1.default.createElement(style_guide_1.TextField, { id: 'orcid', placeholder: 'https://orcid.org/...', pattern: "https://orcid\\.org/\\d{4}-\\d{4}-\\d{4}-\\d{3}[0-9Xx]", title: "Please enter a valid ORCID URL format: https://orcid.org/xxxx-xxxx-xxxx-xxxx", ...props.field }))))))));
147
147
  }));
@@ -52,7 +52,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
52
52
  };
53
53
  Object.defineProperty(exports, "__esModule", { value: true });
54
54
  exports.AuthorsModal = exports.authorsReducer = void 0;
55
- const json_schema_1 = require("@manuscripts/json-schema");
56
55
  const style_guide_1 = require("@manuscripts/style-guide");
57
56
  const transform_1 = require("@manuscripts/transform");
58
57
  const lodash_1 = require("lodash");
@@ -100,7 +99,7 @@ const AuthorsModal = ({ authors: $authors, affiliations: $affiliations, author,
100
99
  const { showAffiliationDrawer, setShowAffiliationDrawer, selectedAffiliations, setSelectedAffiliations, removeAffiliation, selectAffiliation, affiliations, } = (0, useManageAffiliations_1.useManageAffiliations)(selection, $affiliations);
101
100
  (0, react_1.useEffect)(() => {
102
101
  const currentAuthor = selection;
103
- const relevantAffiliations = affiliations.filter((item) => currentAuthor?.affiliations?.includes(item.id));
102
+ const relevantAffiliations = affiliations.filter((item) => currentAuthor?.affiliationIDs?.includes(item.id));
104
103
  setSelectedAffiliations(relevantAffiliations);
105
104
  }, []);
106
105
  const selectAuthor = (author) => {
@@ -136,7 +135,7 @@ const AuthorsModal = ({ authors: $authors, affiliations: $affiliations, author,
136
135
  }
137
136
  };
138
137
  const updateAffiliationSelection = (author) => {
139
- const relevantAffiliations = affiliations.filter((item) => author.affiliations?.includes(item.id));
138
+ const relevantAffiliations = affiliations.filter((item) => author.affiliationIDs?.includes(item.id));
140
139
  setSelectedAffiliations(relevantAffiliations);
141
140
  };
142
141
  const close = () => {
@@ -183,7 +182,7 @@ const AuthorsModal = ({ authors: $authors, affiliations: $affiliations, author,
183
182
  const cancel = () => {
184
183
  resetAuthor();
185
184
  if (nextAuthor) {
186
- const nextAuthorAffiliations = nextAuthor.affiliations || [];
185
+ const nextAuthorAffiliations = nextAuthor.affiliationIDs || [];
187
186
  setSelectedAffiliations(affiliations.filter((item) => nextAuthorAffiliations.includes(item.id)));
188
187
  setSelection(nextAuthor);
189
188
  setNextAuthor(null);
@@ -254,8 +253,7 @@ const AuthorsModal = ({ authors: $authors, affiliations: $affiliations, author,
254
253
  });
255
254
  }, [authors, dispatchAuthors, onSaveAuthor]);
256
255
  const createNewAuthor = () => {
257
- const name = (0, json_schema_1.buildBibliographicName)({ given: '', family: '' });
258
- const author = createEmptyAuthor(name, authors.length);
256
+ const author = createEmptyAuthor(authors.length);
259
257
  setIsSwitchingAuthor(!!selection);
260
258
  setSelectedAffiliations([]);
261
259
  setSelectedCreditRoles([]);
@@ -296,7 +294,7 @@ const AuthorsModal = ({ authors: $authors, affiliations: $affiliations, author,
296
294
  };
297
295
  const resetAuthor = () => {
298
296
  actionsRef.current?.reset();
299
- const selectedAffs = selection?.affiliations || [];
297
+ const selectedAffs = selection?.affiliationIDs || [];
300
298
  setSelectedAffiliations(affiliations.filter((item) => selectedAffs.includes(item.id)));
301
299
  setShowConfirmationDialog(false);
302
300
  setShowRequiredFieldConfirmationDialog(false);
@@ -317,8 +315,7 @@ const AuthorsModal = ({ authors: $authors, affiliations: $affiliations, author,
317
315
  const hasChanges = !(0, lodash_1.isEqual)(updatedValues, normalized);
318
316
  setUnSavedChanges(isSameAuthor && hasChanges);
319
317
  valuesRef.current = { ...updatedValues, priority: values.priority };
320
- const { given, family } = values.bibliographicName;
321
- const { email, isCorresponding } = values;
318
+ const { given, family, email, isCorresponding } = values;
322
319
  const isNameFilled = given?.length || family?.length;
323
320
  if (hasChanges && isNameFilled) {
324
321
  if (isCorresponding) {
@@ -372,21 +369,20 @@ const AuthorsModal = ({ authors: $authors, affiliations: $affiliations, author,
372
369
  react_1.default.createElement(FormFooter_1.default, { onCancel: close }))));
373
370
  };
374
371
  exports.AuthorsModal = AuthorsModal;
375
- function createEmptyAuthor(name, priority) {
372
+ function createEmptyAuthor(priority) {
376
373
  return {
377
374
  id: (0, transform_1.generateNodeID)(transform_1.schema.nodes.contributor),
378
375
  role: '',
379
- affiliations: [],
380
- bibliographicName: name,
376
+ affiliationIDs: [],
377
+ given: '',
378
+ family: '',
381
379
  email: '',
382
380
  isCorresponding: false,
383
- ORCIDIdentifier: '',
381
+ ORCID: '',
384
382
  priority,
385
383
  isJointContributor: false,
386
- userID: '',
387
- invitationID: '',
388
- corresp: [],
389
- footnote: [],
384
+ correspIDs: [],
385
+ footnoteIDs: [],
390
386
  prefix: '',
391
387
  };
392
388
  }
@@ -1,4 +1,19 @@
1
1
  "use strict";
2
+ /*!
3
+ * © 2023 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
+ */
2
17
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
18
  if (k2 === undefined) k2 = k;
4
19
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -37,8 +52,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
37
52
  };
38
53
  Object.defineProperty(exports, "__esModule", { value: true });
39
54
  exports.AddKeywordInline = void 0;
40
- const json_schema_1 = require("@manuscripts/json-schema");
41
55
  const style_guide_1 = require("@manuscripts/style-guide");
56
+ const transform_1 = require("@manuscripts/transform");
42
57
  const prosemirror_state_1 = require("prosemirror-state");
43
58
  const react_1 = __importStar(require("react"));
44
59
  const styled_components_1 = __importDefault(require("styled-components"));
@@ -146,14 +161,11 @@ const AddKeywordInline = ({ viewProps, getUpdatedNode }) => {
146
161
  setNewKeyword('');
147
162
  };
148
163
  const handleAddKeyword = () => {
149
- const keyword = (0, json_schema_1.buildKeyword)(newKeyword);
150
164
  if (!isExistingKeyword() && isValidNewKeyword()) {
151
165
  const node = getUpdatedNode();
152
- const keywordNode = node.type.schema.nodes.keyword.create({
153
- id: keyword._id,
154
- contents: keyword.name,
155
- comments: [],
156
- }, node.type.schema.text(keyword.name));
166
+ const keywordNode = transform_1.schema.nodes.keyword.create({
167
+ id: (0, transform_1.generateNodeID)(transform_1.schema.nodes.keyword),
168
+ }, node.type.schema.text(newKeyword));
157
169
  const nodePosition = getPos() + node.nodeSize - 1;
158
170
  view.dispatch(view.state.tr.insert(nodePosition, keywordNode));
159
171
  setIsAddingNewKeyword(false);
@@ -202,7 +214,8 @@ const AddKeywordInline = ({ viewProps, getUpdatedNode }) => {
202
214
  },
203
215
  };
204
216
  return (react_1.default.createElement(AddNewKeyword, { ref: nodeRef },
205
- !isAddingNewKeyword && (react_1.default.createElement(NewKeywordButton, { tabIndex: -1, className: "keyword-add", onClick: () => {
217
+ !isAddingNewKeyword && (react_1.default.createElement(NewKeywordButton, { tabIndex: -1, className: "keyword-add", onClick: (e) => {
218
+ e.preventDefault();
206
219
  setIsAddingNewKeyword(true);
207
220
  }, onKeyDown: (e) => {
208
221
  if (e.key === 'Enter') {
@@ -22,58 +22,40 @@ describe('authorComparator', () => {
22
22
  {
23
23
  id: 'MPContributor:x',
24
24
  priority: 1,
25
- bibliographicName: {
26
- _id: 'MPBibliographicName:x-name',
27
- objectType: 'MPBibliographicName',
28
- },
29
25
  role: 'author',
30
- affiliations: [],
26
+ affiliationIDs: [],
31
27
  isCorresponding: false,
32
28
  isJointContributor: false,
33
- ORCIDIdentifier: '',
29
+ ORCID: '',
34
30
  email: '',
35
- userID: '',
36
- invitationID: '',
37
- corresp: [],
38
- footnote: [],
31
+ correspIDs: [],
32
+ footnoteIDs: [],
39
33
  prefix: '',
40
34
  },
41
35
  {
42
36
  id: 'MPContributor:y',
43
37
  priority: 0,
44
- bibliographicName: {
45
- _id: 'MPBibliographicName:y-name',
46
- objectType: 'MPBibliographicName',
47
- },
48
38
  role: 'author',
49
- affiliations: [],
39
+ affiliationIDs: [],
50
40
  isCorresponding: false,
51
41
  isJointContributor: false,
52
- ORCIDIdentifier: '',
42
+ ORCID: '',
53
43
  email: '',
54
- userID: '',
55
- invitationID: '',
56
- corresp: [],
57
- footnote: [],
44
+ correspIDs: [],
45
+ footnoteIDs: [],
58
46
  prefix: '',
59
47
  },
60
48
  {
61
49
  id: 'MPContributor:z',
62
50
  priority: 2,
63
- bibliographicName: {
64
- _id: 'MPBibliographicName:z-name',
65
- objectType: 'MPBibliographicName',
66
- },
67
51
  role: 'author',
68
- affiliations: [],
52
+ affiliationIDs: [],
69
53
  isCorresponding: false,
70
54
  isJointContributor: false,
71
- ORCIDIdentifier: '',
55
+ ORCID: '',
72
56
  email: '',
73
- userID: '',
74
- invitationID: '',
75
- corresp: [],
76
- footnote: [],
57
+ correspIDs: [],
58
+ footnoteIDs: [],
77
59
  prefix: '',
78
60
  },
79
61
  ];
@@ -87,39 +69,31 @@ describe('authorComparator', () => {
87
69
  });
88
70
  describe('initials', () => {
89
71
  it('initials exist when "given" is present with more than one given name', () => {
90
- const name = {
91
- _id: 'MPBibliographicName:X',
92
- objectType: 'MPBibliographicName',
72
+ const contributor = {
93
73
  given: 'Derek Gilbert',
94
74
  family: 'Dilbert',
95
75
  };
96
- expect((0, authors_1.initials)(name)).toEqual('D.G.');
76
+ expect((0, authors_1.initials)(contributor)).toEqual('D.G.');
97
77
  });
98
78
  it('initials empty when no given name is present', () => {
99
- const name = {
100
- _id: 'MPBibliographicName:X',
101
- objectType: 'MPBibliographicName',
79
+ const contributor = {
102
80
  family: 'Dilbert',
103
81
  };
104
- expect((0, authors_1.initials)(name)).toEqual('');
82
+ expect((0, authors_1.initials)(contributor)).toEqual('');
105
83
  });
106
84
  it('initials empty when given name is empty string', () => {
107
- const name = {
108
- _id: 'MPBibliographicName:X',
109
- objectType: 'MPBibliographicName',
85
+ const contributor = {
110
86
  family: 'Dilbert',
111
87
  given: '',
112
88
  };
113
- expect((0, authors_1.initials)(name)).toEqual('');
89
+ expect((0, authors_1.initials)(contributor)).toEqual('');
114
90
  });
115
91
  it('ignore extra white space', () => {
116
- const name = {
117
- _id: 'MPBibliographicName:X',
118
- objectType: 'MPBibliographicName',
92
+ const contributor = {
119
93
  given: 'Derek ',
120
94
  family: 'Dilbert',
121
95
  };
122
- expect((0, authors_1.initials)(name)).toEqual('D.');
96
+ expect((0, authors_1.initials)(contributor)).toEqual('D.');
123
97
  });
124
98
  });
125
99
  describe('affiliationLabel', () => {
@@ -3,7 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const json_schema_1 = require("@manuscripts/json-schema");
7
6
  const transform_1 = require("@manuscripts/transform");
8
7
  const history_1 = require("history");
9
8
  const prosemirror_state_1 = require("prosemirror-state");
@@ -16,14 +15,7 @@ const utils_1 = require("../utils");
16
15
  const doc_json_1 = __importDefault(require("./__fixtures__/doc.json"));
17
16
  const userProfile = {
18
17
  _id: 'MPUserProfile:1',
19
- objectType: json_schema_1.ObjectTypes.UserProfile,
20
- createdAt: 0,
21
- updatedAt: 0,
22
- bibliographicName: {
23
- _id: 'MPBibliographicName:1',
24
- objectType: json_schema_1.ObjectTypes.BibliographicName,
25
- },
26
- userID: 'User|test@example.com',
18
+ userID: 'MPUser:1',
27
19
  };
28
20
  const history = (0, history_1.createMemoryHistory)();
29
21
  const buildProps = (doc) => ({
@@ -40,18 +40,17 @@ const affiliationName = (affiliation) => {
40
40
  };
41
41
  exports.affiliationName = affiliationName;
42
42
  const authorLabel = (author) => {
43
- const name = author.bibliographicName;
44
43
  const parts = [
45
44
  author.prefix,
46
- name.family ? (0, exports.initials)(name) : name.given,
47
- name.family,
48
- name.suffix,
45
+ author.family ? (0, exports.initials)(author) : author.given,
46
+ author.family,
47
+ author.suffix,
49
48
  ].filter(Boolean);
50
49
  return parts.length ? parts.join(' ') : 'Unknown Author';
51
50
  };
52
51
  exports.authorLabel = authorLabel;
53
- const initials = (name) => name.given
54
- ? name.given
52
+ const initials = (contributor) => contributor.given
53
+ ? contributor.given
55
54
  .trim()
56
55
  .split(' ')
57
56
  .map((part) => part.substring(0, 1).toUpperCase() + '.')
@@ -4,9 +4,7 @@ exports.handleComment = exports.createCommentMarker = exports.getCommentRange =
4
4
  const commands_1 = require("../commands");
5
5
  const isNodeComment = (c) => !c.range;
6
6
  exports.isNodeComment = isNodeComment;
7
- const isReply = (comment) => {
8
- return comment.node.attrs.target.includes('MPCommentAnnotation');
9
- };
7
+ const isReply = (comment) => comment.node.attrs.target?.startsWith('MPComment');
10
8
  exports.isReply = isReply;
11
9
  const getCommentKey = (comment, range, target) => {
12
10
  if (!range) {
@@ -21,17 +21,16 @@ const normalizeAuthor = (author) => {
21
21
  const basic = {
22
22
  id: author.id,
23
23
  role: author.role || '',
24
- affiliations: (author.affiliations || []).sort(),
25
- bibliographicName: author.bibliographicName,
24
+ affiliationIDs: (author.affiliationIDs || []).sort(),
25
+ given: author.given || '',
26
+ family: author.family || '',
26
27
  email: author.email || '',
27
28
  isCorresponding: author.isCorresponding || false,
28
- ORCIDIdentifier: author.ORCIDIdentifier || '',
29
+ ORCID: author.ORCID || '',
29
30
  priority: author.priority,
30
31
  isJointContributor: author.isJointContributor || false,
31
- userID: author.userID || '',
32
- invitationID: author.invitationID || '',
33
- footnote: author.footnote || [],
34
- corresp: author.corresp || [],
32
+ footnoteIDs: author.footnoteIDs || [],
33
+ correspIDs: author.correspIDs || [],
35
34
  prefix: author.prefix || '',
36
35
  };
37
36
  if (author.creditRoles && Array.isArray(author.creditRoles)) {
@@ -51,7 +51,7 @@ const buildPluginState = (doc, $old) => {
51
51
  .filter((contrib) => !deletedContribId.has(contrib.id))
52
52
  .sort(authors_1.authorComparator)
53
53
  .forEach((attrs) => {
54
- attrs.affiliations.forEach((aff) => {
54
+ attrs.affiliationIDs?.forEach((aff) => {
55
55
  iAffiliations.add(aff);
56
56
  });
57
57
  });
@@ -18,43 +18,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
18
18
  return (mod && mod.__esModule) ? mod : { "default": mod };
19
19
  };
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.defaultEditorProps = exports.TEST_DATA = void 0;
21
+ exports.defaultEditorProps = void 0;
22
22
  const transform_1 = require("@manuscripts/transform");
23
23
  const history_1 = require("history");
24
24
  const popper_1 = require("../lib/popper");
25
25
  const default_capabilities_1 = require("./default-capabilities");
26
26
  const empty_editor_doc_json_1 = __importDefault(require("./empty-editor-doc.json"));
27
27
  const section_categories_json_1 = __importDefault(require("./section-categories.json"));
28
- const theme = {};
29
- exports.TEST_DATA = {
30
- MANUSCRIPT: {
31
- containerID: 'test-manuscript-1-containerID',
32
- _id: 'test-manuscript-1-id',
33
- objectType: 'MPManuscript',
34
- createdAt: 1618400000,
35
- updatedAt: 1618407000,
36
- },
37
- MODEL: {
38
- _id: 'test-model-1-id',
39
- objectType: 'MPSection',
40
- createdAt: 1618400000,
41
- updatedAt: 1618407000,
42
- prototype: 'test-model-1-prototype',
43
- },
44
- USER: {
45
- _id: 'test-user-profile-1-id',
46
- objectType: 'MPUserProfile',
47
- createdAt: 1618400000,
48
- updatedAt: 1618407000,
49
- bibliographicName: {
50
- _id: 'test-user-profile-bibliographicName-1',
51
- objectType: 'MPBibliographicName',
52
- },
53
- userID: 'test-user-profile-1-user-id',
54
- },
55
- DOC: transform_1.schema.nodeFromJSON(empty_editor_doc_json_1.default),
56
- MODEL_MAP: new Map(),
57
- };
58
28
  exports.defaultEditorProps = {
59
29
  attributes: {
60
30
  class: 'manuscript-editor',
@@ -63,13 +33,16 @@ exports.defaultEditorProps = {
63
33
  spellcheck: 'true',
64
34
  tabindex: '2',
65
35
  },
66
- doc: exports.TEST_DATA.DOC,
36
+ doc: transform_1.schema.nodeFromJSON(empty_editor_doc_json_1.default),
67
37
  locale: 'en-GB',
68
38
  popper: new popper_1.PopperManager(),
69
39
  projectID: 'test-project-id',
70
- getCurrentUser: () => exports.TEST_DATA.USER,
40
+ getCurrentUser: () => ({
41
+ _id: 'test-user-profile-1-id',
42
+ userID: '',
43
+ }),
71
44
  history: (0, history_1.createBrowserHistory)(),
72
- theme,
45
+ theme: {},
73
46
  getFiles: () => [],
74
47
  fileManagement: {
75
48
  upload: () => { },
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MATHJAX_VERSION = exports.VERSION = void 0;
4
- exports.VERSION = '3.10.0';
4
+ exports.VERSION = '3.10.2';
5
5
  exports.MATHJAX_VERSION = '3.2.2';
@@ -97,7 +97,7 @@ class ContributorsView extends block_view_1.default {
97
97
  : `<span class="name">${name}</span>`;
98
98
  const noteText = [];
99
99
  if (affs) {
100
- attrs.affiliations.map((a) => {
100
+ attrs.affiliationIDs?.map((a) => {
101
101
  const index = affs.get(a);
102
102
  if (index) {
103
103
  noteText.push(index.toString());
@@ -13,7 +13,6 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { buildContribution } from '@manuscripts/json-schema';
17
16
  import { skipTracking } from '@manuscripts/track-changes-plugin';
18
17
  import { generateNodeID, isElementNodeType, isListNode, isSectionNodeType, isTableElementNode, schema, } from '@manuscripts/transform';
19
18
  import { Fragment, NodeRange, Slice, } from 'prosemirror-model';
@@ -1124,12 +1123,12 @@ const getParentNode = (selection) => {
1124
1123
  };
1125
1124
  export const addNodeComment = (node, state, dispatch) => {
1126
1125
  const props = getEditorProps(state);
1127
- const contribution = buildContribution(props.userID);
1128
1126
  const attrs = {
1129
1127
  id: generateNodeID(schema.nodes.comment),
1130
1128
  contents: '',
1131
1129
  target: node.attrs.id,
1132
- contributions: [contribution],
1130
+ userID: props.userID,
1131
+ timestamp: Date.now(),
1133
1132
  };
1134
1133
  const comment = schema.nodes.comment.create(attrs);
1135
1134
  const comments = findChildrenByType(state.doc, schema.nodes.comments)[0];
@@ -1159,12 +1158,12 @@ export const addInlineComment = (state, dispatch) => {
1159
1158
  to = result.to;
1160
1159
  }
1161
1160
  const props = getEditorProps(state);
1162
- const contribution = buildContribution(props.userID);
1163
1161
  const attrs = {
1164
1162
  id: generateNodeID(schema.nodes.comment),
1165
1163
  contents: '',
1166
1164
  target: node.attrs.id,
1167
- contributions: [contribution],
1165
+ userID: props.userID,
1166
+ timestamp: Date.now(),
1168
1167
  originalText: selectedText() || state.doc.textBetween(from, to),
1169
1168
  selector: {
1170
1169
  from,