@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
@@ -18,7 +18,7 @@ import { AffiliationList } from './AffiliationList';
18
18
  function makeAuthorItems(authors) {
19
19
  return authors.map((author) => ({
20
20
  id: author.id,
21
- label: `${author.bibliographicName.given} ${author.bibliographicName.family}`,
21
+ label: `${author.given} ${author.family}`,
22
22
  }));
23
23
  }
24
24
  export const AffiliationsModal = ({ authors: $authors, affiliations: $affiliations, affiliation, onSaveAffiliation, onDeleteAffiliation, onUpdateAuthors, clearSelection, addNewAffiliation = false, }) => {
@@ -45,7 +45,7 @@ export const AffiliationsModal = ({ authors: $authors, affiliations: $affiliatio
45
45
  }
46
46
  const currentAffiliation = selection;
47
47
  const affiliatedAuthorIds = authors
48
- .filter((author) => author.affiliations?.includes(currentAffiliation.id))
48
+ .filter((author) => author.affiliationIDs?.includes(currentAffiliation.id))
49
49
  .map((author) => author.id);
50
50
  setSelectedAuthorIds(affiliatedAuthorIds);
51
51
  setAffiliationAuthorMap((prevMap) => {
@@ -98,7 +98,7 @@ export const AffiliationsModal = ({ authors: $authors, affiliations: $affiliatio
98
98
  }
99
99
  else {
100
100
  const affiliatedAuthorIds = authors
101
- .filter((author) => author.affiliations?.includes(affiliation.id))
101
+ .filter((author) => author.affiliationIDs?.includes(affiliation.id))
102
102
  .map((author) => author.id);
103
103
  setNewAffiliation(false);
104
104
  setSelection(affiliation);
@@ -128,9 +128,9 @@ export const AffiliationsModal = ({ authors: $authors, affiliations: $affiliatio
128
128
  setSelection(affiliation);
129
129
  const updatedAuthors = authors.map((author) => ({
130
130
  ...author,
131
- affiliations: selectedAuthorIds.includes(author.id)
132
- ? [...new Set([...(author.affiliations || []), affiliation.id])]
133
- : (author.affiliations || []).filter((id) => id !== affiliation.id),
131
+ affiliationIDs: selectedAuthorIds.includes(author.id)
132
+ ? [...new Set([...(author.affiliationIDs || []), affiliation.id])]
133
+ : (author.affiliationIDs || []).filter((id) => id !== affiliation.id),
134
134
  }));
135
135
  dispatchAuthors({
136
136
  type: 'update',
@@ -180,7 +180,7 @@ export const AffiliationsModal = ({ authors: $authors, affiliations: $affiliatio
180
180
  }
181
181
  const updatedAuthors = authors.map((author) => ({
182
182
  ...author,
183
- affiliations: (author.affiliations || []).filter((id) => id !== selection.id),
183
+ affiliationIDs: (author.affiliationIDs || []).filter((id) => id !== selection.id),
184
184
  }));
185
185
  dispatchAuthors({
186
186
  type: 'update',
@@ -216,7 +216,7 @@ export const AffiliationsModal = ({ authors: $authors, affiliations: $affiliatio
216
216
  return {
217
217
  id: authorId,
218
218
  label: author
219
- ? `${author.bibliographicName.given} ${author.bibliographicName.family}`
219
+ ? `${author.given} ${author.family}`
220
220
  : '',
221
221
  };
222
222
  })
@@ -261,7 +261,7 @@ export const AffiliationsModal = ({ authors: $authors, affiliations: $affiliatio
261
261
  setSelection(pendingSelection);
262
262
  setNewAffiliation(false);
263
263
  const affiliatedAuthorIds = authors
264
- .filter((author) => author.affiliations?.some((aff) => aff === pendingSelection.id))
264
+ .filter((author) => author.affiliationIDs.some((aff) => aff === pendingSelection.id))
265
265
  .map((author) => author.id);
266
266
  setSelectedAuthorIds(affiliatedAuthorIds);
267
267
  valuesRef.current = checkID(pendingSelection, 'affiliation');
@@ -292,7 +292,7 @@ export const AffiliationsModal = ({ authors: $authors, affiliations: $affiliatio
292
292
  setSelection(pendingSelection);
293
293
  setNewAffiliation(false);
294
294
  const affiliatedAuthorIds = authors
295
- .filter((author) => author.affiliations?.some((aff) => aff === pendingSelection.id))
295
+ .filter((author) => author.affiliationIDs?.some((aff) => aff === pendingSelection.id))
296
296
  .map((author) => author.id);
297
297
  setSelectedAuthorIds(affiliatedAuthorIds);
298
298
  }
@@ -40,7 +40,7 @@ export const AuthorDetailsForm = ({ values, onChange, onSave, actionsRef, isEmai
40
40
  const formRef = useRef(null);
41
41
  useEffect(() => {
42
42
  if (selectedAffiliations && formRef.current) {
43
- formRef.current.setFieldValue('affiliations', selectedAffiliations);
43
+ formRef.current.setFieldValue('affiliationIDs', selectedAffiliations);
44
44
  }
45
45
  }, [selectedAffiliations]);
46
46
  useEffect(() => {
@@ -73,11 +73,11 @@ export const AuthorDetailsForm = ({ values, onChange, onSave, actionsRef, isEmai
73
73
  React.createElement(Label, { htmlFor: "prefix" }, "Prefix"),
74
74
  React.createElement(TextField, { id: 'prefix', ...props.field }))))),
75
75
  React.createElement(FormRow, null,
76
- React.createElement(Field, { name: 'bibliographicName.given' }, (props) => (React.createElement(React.Fragment, null,
76
+ React.createElement(Field, { name: 'given' }, (props) => (React.createElement(React.Fragment, null,
77
77
  React.createElement(Label, { htmlFor: "given-name" }, "Given name"),
78
78
  React.createElement(TextField, { id: 'given-name', ...props.field }))))),
79
79
  React.createElement(FormRow, null,
80
- React.createElement(Field, { name: 'bibliographicName.family' }, (props) => (React.createElement(React.Fragment, null,
80
+ React.createElement(Field, { name: 'family' }, (props) => (React.createElement(React.Fragment, null,
81
81
  React.createElement(Label, { htmlFor: "family-name" }, "Family name"),
82
82
  React.createElement(TextField, { id: 'family-name', ...props.field }))))),
83
83
  React.createElement(FormRow, null,
@@ -102,7 +102,7 @@ export const AuthorDetailsForm = ({ values, onChange, onSave, actionsRef, isEmai
102
102
  React.createElement(OrcidContainer, null,
103
103
  React.createElement(FormRow, null,
104
104
  React.createElement(Label, { htmlFor: "orcid" }, "ORCID"),
105
- React.createElement(Field, { name: 'ORCIDIdentifier', type: 'text' }, (props) => (React.createElement(React.Fragment, null,
105
+ React.createElement(Field, { name: 'ORCID', type: 'text' }, (props) => (React.createElement(React.Fragment, null,
106
106
  React.createElement(Label, { htmlFor: "orcid", className: "sr-only" }, "ORCID"),
107
107
  React.createElement(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 }))))))));
108
108
  }));
@@ -13,9 +13,8 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { buildBibliographicName, } from '@manuscripts/json-schema';
17
16
  import { AddIcon, AddInstitutionIcon, AddRoleIcon, AuthorPlaceholderIcon, CloseButton, ModalBody, ModalContainer, ModalHeader, ModalSidebar, ModalSidebarHeader, ModalSidebarTitle, ScrollableModalContent, SidebarContent, StyledModal, InspectorTabs, InspectorTabPanel, InspectorTabList, InspectorTab, InspectorTabPanels, } from '@manuscripts/style-guide';
18
- import { generateNodeID, schema } from '@manuscripts/transform';
17
+ import { generateNodeID, schema, } from '@manuscripts/transform';
19
18
  import { cloneDeep, isEqual, omit } from 'lodash';
20
19
  import React, { useCallback, useEffect, useReducer, useRef, useState, } from 'react';
21
20
  import styled from 'styled-components';
@@ -61,7 +60,7 @@ export const AuthorsModal = ({ authors: $authors, affiliations: $affiliations, a
61
60
  const { showAffiliationDrawer, setShowAffiliationDrawer, selectedAffiliations, setSelectedAffiliations, removeAffiliation, selectAffiliation, affiliations, } = useManageAffiliations(selection, $affiliations);
62
61
  useEffect(() => {
63
62
  const currentAuthor = selection;
64
- const relevantAffiliations = affiliations.filter((item) => currentAuthor?.affiliations?.includes(item.id));
63
+ const relevantAffiliations = affiliations.filter((item) => currentAuthor?.affiliationIDs?.includes(item.id));
65
64
  setSelectedAffiliations(relevantAffiliations);
66
65
  }, []);
67
66
  const selectAuthor = (author) => {
@@ -97,7 +96,7 @@ export const AuthorsModal = ({ authors: $authors, affiliations: $affiliations, a
97
96
  }
98
97
  };
99
98
  const updateAffiliationSelection = (author) => {
100
- const relevantAffiliations = affiliations.filter((item) => author.affiliations?.includes(item.id));
99
+ const relevantAffiliations = affiliations.filter((item) => author.affiliationIDs?.includes(item.id));
101
100
  setSelectedAffiliations(relevantAffiliations);
102
101
  };
103
102
  const close = () => {
@@ -144,7 +143,7 @@ export const AuthorsModal = ({ authors: $authors, affiliations: $affiliations, a
144
143
  const cancel = () => {
145
144
  resetAuthor();
146
145
  if (nextAuthor) {
147
- const nextAuthorAffiliations = nextAuthor.affiliations || [];
146
+ const nextAuthorAffiliations = nextAuthor.affiliationIDs || [];
148
147
  setSelectedAffiliations(affiliations.filter((item) => nextAuthorAffiliations.includes(item.id)));
149
148
  setSelection(nextAuthor);
150
149
  setNextAuthor(null);
@@ -215,8 +214,7 @@ export const AuthorsModal = ({ authors: $authors, affiliations: $affiliations, a
215
214
  });
216
215
  }, [authors, dispatchAuthors, onSaveAuthor]);
217
216
  const createNewAuthor = () => {
218
- const name = buildBibliographicName({ given: '', family: '' });
219
- const author = createEmptyAuthor(name, authors.length);
217
+ const author = createEmptyAuthor(authors.length);
220
218
  setIsSwitchingAuthor(!!selection);
221
219
  setSelectedAffiliations([]);
222
220
  setSelectedCreditRoles([]);
@@ -257,7 +255,7 @@ export const AuthorsModal = ({ authors: $authors, affiliations: $affiliations, a
257
255
  };
258
256
  const resetAuthor = () => {
259
257
  actionsRef.current?.reset();
260
- const selectedAffs = selection?.affiliations || [];
258
+ const selectedAffs = selection?.affiliationIDs || [];
261
259
  setSelectedAffiliations(affiliations.filter((item) => selectedAffs.includes(item.id)));
262
260
  setShowConfirmationDialog(false);
263
261
  setShowRequiredFieldConfirmationDialog(false);
@@ -278,8 +276,7 @@ export const AuthorsModal = ({ authors: $authors, affiliations: $affiliations, a
278
276
  const hasChanges = !isEqual(updatedValues, normalized);
279
277
  setUnSavedChanges(isSameAuthor && hasChanges);
280
278
  valuesRef.current = { ...updatedValues, priority: values.priority };
281
- const { given, family } = values.bibliographicName;
282
- const { email, isCorresponding } = values;
279
+ const { given, family, email, isCorresponding } = values;
283
280
  const isNameFilled = given?.length || family?.length;
284
281
  if (hasChanges && isNameFilled) {
285
282
  if (isCorresponding) {
@@ -332,21 +329,20 @@ export const AuthorsModal = ({ authors: $authors, affiliations: $affiliations, a
332
329
  React.createElement(ConfirmationDialog, { isOpen: showConfirmationDialog, onPrimary: save, onSecondary: cancel, type: DialogType.SAVE, entityType: "author" }))) : (React.createElement(FormPlaceholder, { type: "author", title: "Author Details", message: "Select an author from the list to display their details here.", placeholderIcon: React.createElement(AuthorPlaceholderIcon, null) })))),
333
330
  React.createElement(FormFooter, { onCancel: close }))));
334
331
  };
335
- function createEmptyAuthor(name, priority) {
332
+ function createEmptyAuthor(priority) {
336
333
  return {
337
334
  id: generateNodeID(schema.nodes.contributor),
338
335
  role: '',
339
- affiliations: [],
340
- bibliographicName: name,
336
+ affiliationIDs: [],
337
+ given: '',
338
+ family: '',
341
339
  email: '',
342
340
  isCorresponding: false,
343
- ORCIDIdentifier: '',
341
+ ORCID: '',
344
342
  priority,
345
343
  isJointContributor: false,
346
- userID: '',
347
- invitationID: '',
348
- corresp: [],
349
- footnote: [],
344
+ correspIDs: [],
345
+ footnoteIDs: [],
350
346
  prefix: '',
351
347
  };
352
348
  }
@@ -1,5 +1,20 @@
1
- import { buildKeyword } from '@manuscripts/json-schema';
1
+ /*!
2
+ * © 2023 Atypon Systems LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
2
16
  import { Category, Dialog, PlusIcon } from '@manuscripts/style-guide';
17
+ import { generateNodeID, schema, } from '@manuscripts/transform';
3
18
  import { TextSelection } from 'prosemirror-state';
4
19
  import React, { useCallback, useEffect, useRef, useState, } from 'react';
5
20
  import styled from 'styled-components';
@@ -107,14 +122,11 @@ export const AddKeywordInline = ({ viewProps, getUpdatedNode }) => {
107
122
  setNewKeyword('');
108
123
  };
109
124
  const handleAddKeyword = () => {
110
- const keyword = buildKeyword(newKeyword);
111
125
  if (!isExistingKeyword() && isValidNewKeyword()) {
112
126
  const node = getUpdatedNode();
113
- const keywordNode = node.type.schema.nodes.keyword.create({
114
- id: keyword._id,
115
- contents: keyword.name,
116
- comments: [],
117
- }, node.type.schema.text(keyword.name));
127
+ const keywordNode = schema.nodes.keyword.create({
128
+ id: generateNodeID(schema.nodes.keyword),
129
+ }, node.type.schema.text(newKeyword));
118
130
  const nodePosition = getPos() + node.nodeSize - 1;
119
131
  view.dispatch(view.state.tr.insert(nodePosition, keywordNode));
120
132
  setIsAddingNewKeyword(false);
@@ -163,7 +175,8 @@ export const AddKeywordInline = ({ viewProps, getUpdatedNode }) => {
163
175
  },
164
176
  };
165
177
  return (React.createElement(AddNewKeyword, { ref: nodeRef },
166
- !isAddingNewKeyword && (React.createElement(NewKeywordButton, { tabIndex: -1, className: "keyword-add", onClick: () => {
178
+ !isAddingNewKeyword && (React.createElement(NewKeywordButton, { tabIndex: -1, className: "keyword-add", onClick: (e) => {
179
+ e.preventDefault();
167
180
  setIsAddingNewKeyword(true);
168
181
  }, onKeyDown: (e) => {
169
182
  if (e.key === 'Enter') {
@@ -20,58 +20,40 @@ describe('authorComparator', () => {
20
20
  {
21
21
  id: 'MPContributor:x',
22
22
  priority: 1,
23
- bibliographicName: {
24
- _id: 'MPBibliographicName:x-name',
25
- objectType: 'MPBibliographicName',
26
- },
27
23
  role: 'author',
28
- affiliations: [],
24
+ affiliationIDs: [],
29
25
  isCorresponding: false,
30
26
  isJointContributor: false,
31
- ORCIDIdentifier: '',
27
+ ORCID: '',
32
28
  email: '',
33
- userID: '',
34
- invitationID: '',
35
- corresp: [],
36
- footnote: [],
29
+ correspIDs: [],
30
+ footnoteIDs: [],
37
31
  prefix: '',
38
32
  },
39
33
  {
40
34
  id: 'MPContributor:y',
41
35
  priority: 0,
42
- bibliographicName: {
43
- _id: 'MPBibliographicName:y-name',
44
- objectType: 'MPBibliographicName',
45
- },
46
36
  role: 'author',
47
- affiliations: [],
37
+ affiliationIDs: [],
48
38
  isCorresponding: false,
49
39
  isJointContributor: false,
50
- ORCIDIdentifier: '',
40
+ ORCID: '',
51
41
  email: '',
52
- userID: '',
53
- invitationID: '',
54
- corresp: [],
55
- footnote: [],
42
+ correspIDs: [],
43
+ footnoteIDs: [],
56
44
  prefix: '',
57
45
  },
58
46
  {
59
47
  id: 'MPContributor:z',
60
48
  priority: 2,
61
- bibliographicName: {
62
- _id: 'MPBibliographicName:z-name',
63
- objectType: 'MPBibliographicName',
64
- },
65
49
  role: 'author',
66
- affiliations: [],
50
+ affiliationIDs: [],
67
51
  isCorresponding: false,
68
52
  isJointContributor: false,
69
- ORCIDIdentifier: '',
53
+ ORCID: '',
70
54
  email: '',
71
- userID: '',
72
- invitationID: '',
73
- corresp: [],
74
- footnote: [],
55
+ correspIDs: [],
56
+ footnoteIDs: [],
75
57
  prefix: '',
76
58
  },
77
59
  ];
@@ -85,39 +67,31 @@ describe('authorComparator', () => {
85
67
  });
86
68
  describe('initials', () => {
87
69
  it('initials exist when "given" is present with more than one given name', () => {
88
- const name = {
89
- _id: 'MPBibliographicName:X',
90
- objectType: 'MPBibliographicName',
70
+ const contributor = {
91
71
  given: 'Derek Gilbert',
92
72
  family: 'Dilbert',
93
73
  };
94
- expect(initials(name)).toEqual('D.G.');
74
+ expect(initials(contributor)).toEqual('D.G.');
95
75
  });
96
76
  it('initials empty when no given name is present', () => {
97
- const name = {
98
- _id: 'MPBibliographicName:X',
99
- objectType: 'MPBibliographicName',
77
+ const contributor = {
100
78
  family: 'Dilbert',
101
79
  };
102
- expect(initials(name)).toEqual('');
80
+ expect(initials(contributor)).toEqual('');
103
81
  });
104
82
  it('initials empty when given name is empty string', () => {
105
- const name = {
106
- _id: 'MPBibliographicName:X',
107
- objectType: 'MPBibliographicName',
83
+ const contributor = {
108
84
  family: 'Dilbert',
109
85
  given: '',
110
86
  };
111
- expect(initials(name)).toEqual('');
87
+ expect(initials(contributor)).toEqual('');
112
88
  });
113
89
  it('ignore extra white space', () => {
114
- const name = {
115
- _id: 'MPBibliographicName:X',
116
- objectType: 'MPBibliographicName',
90
+ const contributor = {
117
91
  given: 'Derek ',
118
92
  family: 'Dilbert',
119
93
  };
120
- expect(initials(name)).toEqual('D.');
94
+ expect(initials(contributor)).toEqual('D.');
121
95
  });
122
96
  });
123
97
  describe('affiliationLabel', () => {
@@ -1,4 +1,3 @@
1
- import { ObjectTypes } from '@manuscripts/json-schema';
2
1
  import { schema, } from '@manuscripts/transform';
3
2
  import { createMemoryHistory } from 'history';
4
3
  import { EditorState } from 'prosemirror-state';
@@ -11,14 +10,7 @@ import { getMatchingDescendant } from '../utils';
11
10
  import jsonDoc from './__fixtures__/doc.json';
12
11
  const userProfile = {
13
12
  _id: 'MPUserProfile:1',
14
- objectType: ObjectTypes.UserProfile,
15
- createdAt: 0,
16
- updatedAt: 0,
17
- bibliographicName: {
18
- _id: 'MPBibliographicName:1',
19
- objectType: ObjectTypes.BibliographicName,
20
- },
21
- userID: 'User|test@example.com',
13
+ userID: 'MPUser:1',
22
14
  };
23
15
  const history = createMemoryHistory();
24
16
  const buildProps = (doc) => ({
@@ -35,17 +35,16 @@ export const affiliationName = (affiliation) => {
35
35
  .join(', ');
36
36
  };
37
37
  export const authorLabel = (author) => {
38
- const name = author.bibliographicName;
39
38
  const parts = [
40
39
  author.prefix,
41
- name.family ? initials(name) : name.given,
42
- name.family,
43
- name.suffix,
40
+ author.family ? initials(author) : author.given,
41
+ author.family,
42
+ author.suffix,
44
43
  ].filter(Boolean);
45
44
  return parts.length ? parts.join(' ') : 'Unknown Author';
46
45
  };
47
- export const initials = (name) => name.given
48
- ? name.given
46
+ export const initials = (contributor) => contributor.given
47
+ ? contributor.given
49
48
  .trim()
50
49
  .split(' ')
51
50
  .map((part) => part.substring(0, 1).toUpperCase() + '.')
@@ -1,8 +1,6 @@
1
1
  import { addNodeComment } from '../commands';
2
2
  export const isNodeComment = (c) => !c.range;
3
- export const isReply = (comment) => {
4
- return comment.node.attrs.target.includes('MPCommentAnnotation');
5
- };
3
+ export const isReply = (comment) => comment.node.attrs.target?.startsWith('MPComment');
6
4
  export const getCommentKey = (comment, range, target) => {
7
5
  if (!range) {
8
6
  return target.attrs.id;
@@ -18,17 +18,16 @@ export const normalizeAuthor = (author) => {
18
18
  const basic = {
19
19
  id: author.id,
20
20
  role: author.role || '',
21
- affiliations: (author.affiliations || []).sort(),
22
- bibliographicName: author.bibliographicName,
21
+ affiliationIDs: (author.affiliationIDs || []).sort(),
22
+ given: author.given || '',
23
+ family: author.family || '',
23
24
  email: author.email || '',
24
25
  isCorresponding: author.isCorresponding || false,
25
- ORCIDIdentifier: author.ORCIDIdentifier || '',
26
+ ORCID: author.ORCID || '',
26
27
  priority: author.priority,
27
28
  isJointContributor: author.isJointContributor || false,
28
- userID: author.userID || '',
29
- invitationID: author.invitationID || '',
30
- footnote: author.footnote || [],
31
- corresp: author.corresp || [],
29
+ footnoteIDs: author.footnoteIDs || [],
30
+ correspIDs: author.correspIDs || [],
32
31
  prefix: author.prefix || '',
33
32
  };
34
33
  if (author.creditRoles && Array.isArray(author.creditRoles)) {
@@ -48,7 +48,7 @@ export const buildPluginState = (doc, $old) => {
48
48
  .filter((contrib) => !deletedContribId.has(contrib.id))
49
49
  .sort(authorComparator)
50
50
  .forEach((attrs) => {
51
- attrs.affiliations.forEach((aff) => {
51
+ attrs.affiliationIDs?.forEach((aff) => {
52
52
  iAffiliations.add(aff);
53
53
  });
54
54
  });
@@ -19,36 +19,6 @@ import { PopperManager } from '../lib/popper';
19
19
  import { defaultCapabilities } from './default-capabilities';
20
20
  import emptyEditorDocJson from './empty-editor-doc.json';
21
21
  import sectionCategories from './section-categories.json';
22
- const theme = {};
23
- export const TEST_DATA = {
24
- MANUSCRIPT: {
25
- containerID: 'test-manuscript-1-containerID',
26
- _id: 'test-manuscript-1-id',
27
- objectType: 'MPManuscript',
28
- createdAt: 1618400000,
29
- updatedAt: 1618407000,
30
- },
31
- MODEL: {
32
- _id: 'test-model-1-id',
33
- objectType: 'MPSection',
34
- createdAt: 1618400000,
35
- updatedAt: 1618407000,
36
- prototype: 'test-model-1-prototype',
37
- },
38
- USER: {
39
- _id: 'test-user-profile-1-id',
40
- objectType: 'MPUserProfile',
41
- createdAt: 1618400000,
42
- updatedAt: 1618407000,
43
- bibliographicName: {
44
- _id: 'test-user-profile-bibliographicName-1',
45
- objectType: 'MPBibliographicName',
46
- },
47
- userID: 'test-user-profile-1-user-id',
48
- },
49
- DOC: schema.nodeFromJSON(emptyEditorDocJson),
50
- MODEL_MAP: new Map(),
51
- };
52
22
  export const defaultEditorProps = {
53
23
  attributes: {
54
24
  class: 'manuscript-editor',
@@ -57,13 +27,16 @@ export const defaultEditorProps = {
57
27
  spellcheck: 'true',
58
28
  tabindex: '2',
59
29
  },
60
- doc: TEST_DATA.DOC,
30
+ doc: schema.nodeFromJSON(emptyEditorDocJson),
61
31
  locale: 'en-GB',
62
32
  popper: new PopperManager(),
63
33
  projectID: 'test-project-id',
64
- getCurrentUser: () => TEST_DATA.USER,
34
+ getCurrentUser: () => ({
35
+ _id: 'test-user-profile-1-id',
36
+ userID: '',
37
+ }),
65
38
  history: createBrowserHistory(),
66
- theme,
39
+ theme: {},
67
40
  getFiles: () => [],
68
41
  fileManagement: {
69
42
  upload: () => { },
@@ -1,2 +1,2 @@
1
- export const VERSION = '3.10.0';
1
+ export const VERSION = '3.10.2';
2
2
  export const MATHJAX_VERSION = '3.2.2';
@@ -91,7 +91,7 @@ export class ContributorsView extends BlockView {
91
91
  : `<span class="name">${name}</span>`;
92
92
  const noteText = [];
93
93
  if (affs) {
94
- attrs.affiliations.map((a) => {
94
+ attrs.affiliationIDs?.map((a) => {
95
95
  const index = affs.get(a);
96
96
  if (index) {
97
97
  noteText.push(index.toString());
@@ -1,3 +1,18 @@
1
+ /*!
2
+ * © 2023 Atypon Systems LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
1
16
  import { ManuscriptEditorView, ManuscriptNode } from '@manuscripts/transform';
2
17
  import React from 'react';
3
18
  export declare const AddKeywordInline: React.FC<{
@@ -14,8 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import 'prosemirror-view/style/prosemirror.css';
17
- import { UserProfile } from '@manuscripts/json-schema';
18
- import { ManuscriptNode, ManuscriptNodeType, SectionCategory } from '@manuscripts/transform';
17
+ import { ManuscriptNode, ManuscriptNodeType, SectionCategory, UserProfile } from '@manuscripts/transform';
19
18
  import { EditorState } from 'prosemirror-state';
20
19
  import { EditorView } from 'prosemirror-view';
21
20
  import { Location, NavigateFunction } from 'react-router-dom';
@@ -21,7 +21,6 @@ export { default as LanguageDropdown } from './components/LanguageDropdown';
21
21
  export * from './components/toolbar/ListMenuItem';
22
22
  export * from './components/toolbar/InsertTableDialog';
23
23
  export * from './menus';
24
- export { ChangeReceiver } from './types';
25
24
  export { CollabProvider } from './classes/collabProvider';
26
25
  export { PopperManager } from './lib/popper';
27
26
  export * from './toolbar';
@@ -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 { BibliographicName } from '@manuscripts/json-schema';
17
16
  import { AffiliationNode, ContributorNode } from '@manuscripts/transform';
18
17
  import { TrackableAttributes } from '../types';
19
18
  export type AffiliationAttrs = TrackableAttributes<AffiliationNode>;
@@ -21,5 +20,5 @@ export type ContributorAttrs = TrackableAttributes<ContributorNode>;
21
20
  export declare const affiliationLabel: (affiliation: AffiliationAttrs) => string;
22
21
  export declare const affiliationName: (affiliation: AffiliationAttrs) => string;
23
22
  export declare const authorLabel: (author: ContributorAttrs) => string;
24
- export declare const initials: (name: BibliographicName) => string;
23
+ export declare const initials: (contributor: ContributorAttrs) => string;
25
24
  export declare const authorComparator: (a: ContributorAttrs, b: ContributorAttrs) => number;
@@ -13,16 +13,5 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { Manuscript, Model, UserProfile } from '@manuscripts/json-schema';
17
- import { ActualManuscriptNode } from '@manuscripts/transform';
18
16
  import { EditorProps } from '../configs/ManuscriptsEditor';
19
- type TestData = {
20
- MANUSCRIPT: Manuscript;
21
- MODEL: Model;
22
- USER: UserProfile;
23
- DOC: ActualManuscriptNode;
24
- MODEL_MAP: Map<string, Model>;
25
- };
26
- export declare const TEST_DATA: TestData;
27
17
  export declare const defaultEditorProps: EditorProps;
28
- export {};
@@ -18,23 +18,10 @@ import { ManuscriptEditorState, ManuscriptEditorView, ManuscriptNode, Manuscript
18
18
  import { Decoration } from 'prosemirror-view';
19
19
  export type EditorAction = (state: ManuscriptEditorState, dispatch?: (tr: ManuscriptTransaction) => void, view?: ManuscriptEditorView) => boolean;
20
20
  export type NodeViewCreator<T extends ManuscriptNodeView> = (node: ManuscriptNode, view: ManuscriptEditorView, getPos: () => number | undefined, decorations: readonly Decoration[]) => T;
21
- export interface ChangeReceiverCommand {
22
- childSections?: ManuscriptNode[];
23
- }
24
- export type ChangeReceiver = (op: string, id?: string, data?: ManuscriptNode | null, command?: ChangeReceiverCommand) => void;
25
- export interface SyncError {
26
- _id: string;
27
- }
28
21
  export type TrackableAttributes<T extends ManuscriptNode> = T['attrs'] & {
29
22
  dataTracked?: TrackedAttrs[];
30
23
  };
31
24
  export type Trackable<T extends ManuscriptNode> = Omit<T, 'attrs'> & {
32
25
  attrs: TrackableAttributes<T>;
33
26
  };
34
- export type WidgetDecoration = Decoration & {
35
- type: {
36
- toDOM: () => HTMLElement;
37
- spec: Decoration['spec'];
38
- };
39
- };
40
27
  export type PartialExcept<T, K extends keyof T> = Partial<Omit<T, K>> & Pick<T, K>;
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "3.10.0";
1
+ export declare const VERSION = "3.10.2";
2
2
  export declare const MATHJAX_VERSION = "3.2.2";