@manuscripts/transform 2.3.36 → 2.3.37-LEAN-3911.0

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 (113) hide show
  1. package/dist/cjs/jats/importer/create-article-node.js +31 -0
  2. package/dist/cjs/jats/importer/index.js +3 -3
  3. package/dist/cjs/jats/importer/jats-body-transformations.js +70 -0
  4. package/dist/cjs/jats/importer/jats-comments.js +27 -104
  5. package/dist/cjs/jats/importer/{jats-body-dom-parser.js → jats-dom-parser.js} +229 -9
  6. package/dist/cjs/jats/importer/jats-front-transformations.js +262 -0
  7. package/dist/cjs/jats/importer/jats-journal-meta-parser.js +8 -1
  8. package/dist/cjs/jats/importer/jats-parser-utils.js +39 -5
  9. package/dist/cjs/jats/importer/jats-reference-parser.js +16 -27
  10. package/dist/cjs/jats/importer/jats-references.js +18 -18
  11. package/dist/cjs/jats/importer/parse-jats-article.js +42 -78
  12. package/dist/cjs/jats/index.js +4 -3
  13. package/dist/cjs/jats/jats-exporter.js +251 -354
  14. package/dist/cjs/{transformer → jats}/labels.js +3 -3
  15. package/dist/cjs/lib/utils.js +9 -1
  16. package/dist/cjs/transformer/id.js +10 -5
  17. package/dist/cjs/transformer/index.js +0 -18
  18. package/dist/cjs/version.js +1 -1
  19. package/dist/{cjs/transformer/serializer.js → es/jats/importer/create-article-node.js} +12 -8
  20. package/dist/es/jats/importer/index.js +2 -1
  21. package/dist/es/jats/importer/jats-body-transformations.js +70 -0
  22. package/dist/es/jats/importer/jats-comments.js +26 -101
  23. package/dist/es/jats/importer/{jats-body-dom-parser.js → jats-dom-parser.js} +230 -10
  24. package/dist/es/jats/importer/jats-front-transformations.js +259 -0
  25. package/dist/es/jats/importer/jats-journal-meta-parser.js +6 -0
  26. package/dist/es/jats/importer/jats-parser-utils.js +40 -6
  27. package/dist/es/jats/importer/jats-reference-parser.js +16 -27
  28. package/dist/es/jats/importer/jats-references.js +18 -18
  29. package/dist/es/jats/importer/parse-jats-article.js +43 -77
  30. package/dist/es/jats/index.js +3 -1
  31. package/dist/es/jats/jats-exporter.js +253 -356
  32. package/dist/es/{transformer → jats}/labels.js +3 -3
  33. package/dist/es/lib/utils.js +7 -0
  34. package/dist/es/transformer/id.js +8 -3
  35. package/dist/es/transformer/index.js +0 -16
  36. package/dist/es/version.js +1 -1
  37. package/dist/{cjs/transformer/models.js → types/jats/importer/create-article-node.d.ts} +3 -3
  38. package/dist/types/jats/importer/index.d.ts +2 -1
  39. package/dist/types/jats/importer/jats-body-transformations.d.ts +5 -0
  40. package/dist/types/jats/importer/jats-comments.d.ts +4 -10
  41. package/dist/types/jats/importer/{jats-body-dom-parser.d.ts → jats-dom-parser.d.ts} +1 -1
  42. package/dist/types/jats/importer/jats-front-transformations.d.ts +38 -0
  43. package/dist/types/jats/importer/jats-journal-meta-parser.d.ts +10 -0
  44. package/dist/types/jats/importer/jats-references.d.ts +19 -8
  45. package/dist/types/jats/importer/parse-jats-article.d.ts +12 -5
  46. package/dist/types/jats/index.d.ts +3 -1
  47. package/dist/types/jats/jats-exporter.d.ts +10 -29
  48. package/dist/types/{transformer → jats}/labels.d.ts +2 -1
  49. package/dist/types/lib/utils.d.ts +3 -0
  50. package/dist/types/schema/nodes/bibliography_item.d.ts +28 -5
  51. package/dist/types/schema/nodes/contributor.d.ts +10 -0
  52. package/dist/types/schema/nodes/keyword_group.d.ts +1 -0
  53. package/dist/types/transformer/id.d.ts +5 -2
  54. package/dist/types/transformer/index.d.ts +0 -16
  55. package/dist/types/version.d.ts +1 -1
  56. package/package.json +3 -2
  57. package/dist/cjs/__tests__/data/project-dump.json +0 -825
  58. package/dist/cjs/jats/importer/jats-front-parser.js +0 -321
  59. package/dist/cjs/transformer/__tests__/__helpers__/doc.js +0 -37
  60. package/dist/cjs/transformer/builders.js +0 -219
  61. package/dist/cjs/transformer/decode.js +0 -874
  62. package/dist/cjs/transformer/document-object-types.js +0 -31
  63. package/dist/cjs/transformer/encode.js +0 -664
  64. package/dist/cjs/transformer/footnote-category.js +0 -20
  65. package/dist/cjs/transformer/footnotes-order.js +0 -60
  66. package/dist/cjs/transformer/highlight-markers.js +0 -138
  67. package/dist/cjs/transformer/html.js +0 -400
  68. package/dist/cjs/transformer/manuscript-dependencies.js +0 -21
  69. package/dist/cjs/transformer/model-map.js +0 -26
  70. package/dist/cjs/transformer/object-types.js +0 -57
  71. package/dist/cjs/transformer/project-bundle.js +0 -94
  72. package/dist/cjs/transformer/update-identifiers.js +0 -93
  73. package/dist/es/__tests__/data/project-dump.json +0 -825
  74. package/dist/es/jats/importer/jats-front-parser.js +0 -315
  75. package/dist/es/transformer/__tests__/__helpers__/doc.js +0 -29
  76. package/dist/es/transformer/builders.js +0 -186
  77. package/dist/es/transformer/decode.js +0 -864
  78. package/dist/es/transformer/document-object-types.js +0 -28
  79. package/dist/es/transformer/encode.js +0 -654
  80. package/dist/es/transformer/footnote-category.js +0 -16
  81. package/dist/es/transformer/footnotes-order.js +0 -55
  82. package/dist/es/transformer/highlight-markers.js +0 -132
  83. package/dist/es/transformer/html.js +0 -393
  84. package/dist/es/transformer/manuscript-dependencies.js +0 -17
  85. package/dist/es/transformer/model-map.js +0 -22
  86. package/dist/es/transformer/models.js +0 -16
  87. package/dist/es/transformer/object-types.js +0 -52
  88. package/dist/es/transformer/project-bundle.js +0 -85
  89. package/dist/es/transformer/serializer.js +0 -17
  90. package/dist/es/transformer/update-identifiers.js +0 -87
  91. package/dist/types/jats/importer/jats-front-parser.d.ts +0 -84
  92. package/dist/types/transformer/__tests__/__helpers__/doc.d.ts +0 -18
  93. package/dist/types/transformer/builders.d.ts +0 -61
  94. package/dist/types/transformer/decode.d.ts +0 -51
  95. package/dist/types/transformer/document-object-types.d.ts +0 -17
  96. package/dist/types/transformer/encode.d.ts +0 -29
  97. package/dist/types/transformer/footnote-category.d.ts +0 -17
  98. package/dist/types/transformer/footnotes-order.d.ts +0 -22
  99. package/dist/types/transformer/highlight-markers.d.ts +0 -31
  100. package/dist/types/transformer/html.d.ts +0 -36
  101. package/dist/types/transformer/manuscript-dependencies.d.ts +0 -4
  102. package/dist/types/transformer/model-map.d.ts +0 -19
  103. package/dist/types/transformer/models.d.ts +0 -48
  104. package/dist/types/transformer/object-types.d.ts +0 -30
  105. package/dist/types/transformer/project-bundle.d.ts +0 -30
  106. package/dist/types/transformer/serializer.d.ts +0 -19
  107. package/dist/types/transformer/update-identifiers.d.ts +0 -23
  108. /package/dist/cjs/{transformer → jats}/filename.js +0 -0
  109. /package/dist/cjs/{transformer → jats}/timestamp.js +0 -0
  110. /package/dist/es/{transformer → jats}/filename.js +0 -0
  111. /package/dist/es/{transformer → jats}/timestamp.js +0 -0
  112. /package/dist/types/{transformer → jats}/filename.d.ts +0 -0
  113. /package/dist/types/{transformer → jats}/timestamp.d.ts +0 -0
@@ -1,315 +0,0 @@
1
- /*!
2
- * © 2020 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
- */
16
- import debug from 'debug';
17
- import { getTrimmedTextContent } from '../../lib/utils';
18
- import { buildAffiliation, buildAuthorNotes, buildBibliographicName, buildContributor, buildCorresp, buildFootnote, buildJournal, buildParagraph, buildTitles, } from '../../transformer';
19
- import { parseJournalMeta } from './jats-journal-meta-parser';
20
- import { htmlFromJatsNode } from './jats-parser-utils';
21
- const warn = debug('manuscripts-transform');
22
- const XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
23
- const defaultTitle = 'Untitled Manuscript';
24
- export const jatsFrontParser = {
25
- parseTitles(element, createElement) {
26
- var _a;
27
- if (!element) {
28
- return buildTitles(defaultTitle);
29
- }
30
- const title = element.querySelector('article-title');
31
- const subtitle = element.querySelector('subtitle');
32
- const runningTitle = element.querySelector('alt-title[alt-title-type="right-running"]');
33
- const titles = buildTitles((_a = htmlFromJatsNode(title, createElement)) !== null && _a !== void 0 ? _a : defaultTitle);
34
- if (subtitle) {
35
- titles.subtitle = htmlFromJatsNode(subtitle, createElement);
36
- }
37
- if (runningTitle) {
38
- titles.runningTitle = htmlFromJatsNode(runningTitle, createElement);
39
- }
40
- return titles;
41
- },
42
- parseDOI(front) {
43
- var _a;
44
- const doi = front === null || front === void 0 ? void 0 : front.querySelector('article-meta > article-id[pub-id-type="doi"]');
45
- return (_a = doi === null || doi === void 0 ? void 0 : doi.textContent) !== null && _a !== void 0 ? _a : undefined;
46
- },
47
- parseCounts(counts) {
48
- var _a, _b, _c, _d, _e;
49
- if (counts) {
50
- const parseCount = (count) => {
51
- if (count && /^-?\d+$/.test(count)) {
52
- return parseInt(count);
53
- }
54
- else if (count) {
55
- warn(`Invalid count number for ${count}`);
56
- }
57
- };
58
- const genericCounts = [];
59
- const countElements = counts.querySelectorAll('count');
60
- for (const element of countElements.values()) {
61
- const countType = element.getAttribute('count-type');
62
- const count = parseCount(element.getAttribute('count'));
63
- if (countType) {
64
- const genericCount = { count, countType };
65
- genericCounts.push(genericCount);
66
- }
67
- }
68
- return {
69
- wordCount: parseCount((_a = counts.querySelector('word-count')) === null || _a === void 0 ? void 0 : _a.getAttribute('count')),
70
- figureCount: parseCount((_b = counts.querySelector('fig-count')) === null || _b === void 0 ? void 0 : _b.getAttribute('count')),
71
- tableCount: parseCount((_c = counts.querySelector('table-count')) === null || _c === void 0 ? void 0 : _c.getAttribute('count')),
72
- equationCount: parseCount((_d = counts.querySelector('equation-count')) === null || _d === void 0 ? void 0 : _d.getAttribute('count')),
73
- referencesCount: parseCount((_e = counts.querySelector('ref-count')) === null || _e === void 0 ? void 0 : _e.getAttribute('count')),
74
- genericCounts: genericCounts.length > 0 ? genericCounts : undefined,
75
- };
76
- }
77
- },
78
- parseJournal(element) {
79
- const meta = parseJournalMeta(element);
80
- return Object.assign(Object.assign({}, meta), buildJournal());
81
- },
82
- parseDates(historyNode) {
83
- if (!historyNode) {
84
- return undefined;
85
- }
86
- const history = {};
87
- const dateToTimestamp = (dateElement) => {
88
- const selectors = ['year', 'month', 'day'];
89
- const values = [];
90
- for (const selector of selectors) {
91
- const value = getTrimmedTextContent(dateElement, selector);
92
- if (!value || isNaN(+value)) {
93
- return;
94
- }
95
- values.push(+value);
96
- }
97
- return Date.UTC(values[0], values[1], values[2]) / 1000;
98
- };
99
- for (const date of historyNode.children) {
100
- const dateType = date.getAttribute('date-type');
101
- switch (dateType) {
102
- case 'received': {
103
- history.receiveDate = dateToTimestamp(date);
104
- break;
105
- }
106
- case 'rev-recd': {
107
- history.revisionReceiveDate = dateToTimestamp(date);
108
- break;
109
- }
110
- case 'accepted': {
111
- history.acceptanceDate = dateToTimestamp(date);
112
- break;
113
- }
114
- case 'rev-request': {
115
- history.revisionRequestDate = dateToTimestamp(date);
116
- break;
117
- }
118
- case 'retracted': {
119
- history.retractionDate = dateToTimestamp(date);
120
- break;
121
- }
122
- case 'corrected': {
123
- history.correctionDate = dateToTimestamp(date);
124
- break;
125
- }
126
- }
127
- }
128
- return history;
129
- },
130
- parseAffiliations(elements) {
131
- const affiliationIDs = new Map();
132
- const affiliations = elements.map((element, priority) => {
133
- var _a, _b;
134
- const affiliation = buildAffiliation('', priority);
135
- for (const node of element.querySelectorAll('institution')) {
136
- const content = (_a = node.textContent) === null || _a === void 0 ? void 0 : _a.trim();
137
- if (!content) {
138
- continue;
139
- }
140
- const type = node.getAttribute('content-type');
141
- if (type === 'dept') {
142
- affiliation.department = content;
143
- }
144
- else {
145
- affiliation.institution = content;
146
- }
147
- }
148
- affiliation.addressLine1 =
149
- getTrimmedTextContent(element, 'addr-line:nth-of-type(1)') || undefined;
150
- affiliation.addressLine2 =
151
- getTrimmedTextContent(element, 'addr-line:nth-of-type(2)') || undefined;
152
- affiliation.addressLine3 =
153
- getTrimmedTextContent(element, 'addr-line:nth-of-type(3)') || undefined;
154
- affiliation.postCode =
155
- getTrimmedTextContent(element, 'postal-code') || undefined;
156
- affiliation.country =
157
- getTrimmedTextContent(element, 'country') || undefined;
158
- const email = element.querySelector('email');
159
- if (email) {
160
- affiliation.email = {
161
- href: email.getAttributeNS(XLINK_NAMESPACE, 'href') || undefined,
162
- text: ((_b = email.textContent) === null || _b === void 0 ? void 0 : _b.trim()) || undefined,
163
- };
164
- }
165
- const id = element.getAttribute('id');
166
- if (id) {
167
- affiliationIDs.set(id, affiliation._id);
168
- }
169
- return affiliation;
170
- });
171
- return {
172
- affiliations,
173
- affiliationIDs,
174
- };
175
- },
176
- parseAuthorNotes(element) {
177
- if (!element) {
178
- return {
179
- footnotes: [],
180
- footnoteIDs: new Map(),
181
- authorNotes: [],
182
- authorNotesParagraphs: [],
183
- correspondingIDs: new Map(),
184
- correspondingList: [],
185
- };
186
- }
187
- const { footnotes, footnoteIDs } = this.parseFootnotes([
188
- ...element.querySelectorAll('fn:not([fn-type])'),
189
- ]);
190
- const authorNotesParagraphs = this.parseParagraphs([
191
- ...element.querySelectorAll(':scope > p'),
192
- ]);
193
- const { correspondingList, correspondingIDs } = this.parseCorresp([
194
- ...element.querySelectorAll('corresp'),
195
- ]);
196
- const authorNotes = [
197
- buildAuthorNotes([
198
- ...correspondingIDs.values(),
199
- ...footnoteIDs.values(),
200
- ...authorNotesParagraphs.map((p) => p._id),
201
- ]),
202
- ];
203
- return {
204
- footnotes,
205
- footnoteIDs,
206
- authorNotesParagraphs,
207
- authorNotes,
208
- correspondingIDs,
209
- correspondingList,
210
- };
211
- },
212
- parseParagraphs(elements) {
213
- return elements.map((p) => buildParagraph(p.innerHTML));
214
- },
215
- parseFootnotes(elements) {
216
- const footnoteIDs = new Map();
217
- const footnotes = elements.map((element) => {
218
- const fn = buildFootnote('', element.innerHTML);
219
- const id = element.getAttribute('id');
220
- if (id) {
221
- footnoteIDs.set(id, fn._id);
222
- }
223
- return fn;
224
- });
225
- return {
226
- footnotes,
227
- footnoteIDs,
228
- };
229
- },
230
- parseCorresp(elements) {
231
- const correspondingIDs = new Map();
232
- const correspondingList = elements.map((element) => {
233
- var _a, _b, _c;
234
- const label = element.querySelector('label');
235
- if (label) {
236
- label.remove();
237
- }
238
- const corresponding = buildCorresp((_b = (_a = element.textContent) === null || _a === void 0 ? void 0 : _a.trim()) !== null && _b !== void 0 ? _b : '');
239
- corresponding.label = ((_c = label === null || label === void 0 ? void 0 : label.textContent) === null || _c === void 0 ? void 0 : _c.trim()) || undefined;
240
- const id = element.getAttribute('id');
241
- if (id) {
242
- correspondingIDs.set(id, corresponding._id);
243
- }
244
- return corresponding;
245
- });
246
- return {
247
- correspondingList,
248
- correspondingIDs,
249
- };
250
- },
251
- parseContributors(elements, affiliationIDs, footnoteIDs, correspondingIDs) {
252
- return elements.map((element, priority) => {
253
- var _a, _b;
254
- const name = buildBibliographicName({});
255
- const given = getTrimmedTextContent(element, 'name > given-names');
256
- if (given) {
257
- name.given = given;
258
- }
259
- const surname = getTrimmedTextContent(element, 'name > surname');
260
- if (surname) {
261
- name.family = surname;
262
- }
263
- const contributor = buildContributor(name, 'author', priority);
264
- const corresponding = element.getAttribute('corresp') === 'yes';
265
- if (corresponding) {
266
- contributor.isCorresponding = corresponding;
267
- }
268
- const orcid = getTrimmedTextContent(element, 'contrib-id[contrib-id-type="orcid"]');
269
- if (orcid) {
270
- contributor.ORCIDIdentifier = orcid;
271
- }
272
- const xrefs = element.querySelectorAll('xref');
273
- for (const xref of xrefs) {
274
- if (xref) {
275
- const rid = xref.getAttribute('rid');
276
- const type = xref.getAttribute('ref-type');
277
- if (rid) {
278
- if (type === 'fn') {
279
- contributor.footnote = [];
280
- const footnoteID = footnoteIDs.get(rid);
281
- if (footnoteID) {
282
- const authorFootNoteRef = {
283
- noteID: footnoteID,
284
- noteLabel: ((_a = xref.textContent) === null || _a === void 0 ? void 0 : _a.trim()) || '',
285
- };
286
- contributor.footnote.push(authorFootNoteRef);
287
- }
288
- }
289
- else if (type === 'corresp') {
290
- contributor.corresp = [];
291
- const correspID = correspondingIDs.get(rid);
292
- if (correspID) {
293
- const authorCorrespRef = {
294
- correspID: correspID,
295
- correspLabel: ((_b = xref.textContent) === null || _b === void 0 ? void 0 : _b.trim()) || '',
296
- };
297
- contributor.corresp.push(authorCorrespRef);
298
- }
299
- }
300
- else if (type === 'aff') {
301
- const rids = rid
302
- .split(/\s+/)
303
- .map((id) => affiliationIDs.get(id))
304
- .filter(Boolean);
305
- if (rids.length) {
306
- contributor.affiliations = rids;
307
- }
308
- }
309
- }
310
- }
311
- }
312
- return contributor;
313
- });
314
- },
315
- };
@@ -1,29 +0,0 @@
1
- /*!
2
- * © 2019 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
- */
16
- import projectDump from '../../../__tests__/data/project-dump.json';
17
- import { Decoder } from '../../decode';
18
- export const createTestModelMap = () => {
19
- const modelMap = new Map();
20
- for (const component of projectDump.data) {
21
- modelMap.set(component._id, component);
22
- }
23
- return modelMap;
24
- };
25
- export const createTestDoc = () => {
26
- const modelMap = createTestModelMap();
27
- const decoder = new Decoder(modelMap);
28
- return decoder.createArticleNode();
29
- };
@@ -1,186 +0,0 @@
1
- /*!
2
- * © 2019 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
- */
16
- import { ObjectTypes, } from '@manuscripts/json-schema';
17
- import serializeToXML from 'w3c-xmlserializer';
18
- import { schema } from '../schema';
19
- import { generateID } from './id';
20
- import { timestamp } from './timestamp';
21
- export const buildProject = (owner) => ({
22
- _id: generateID(ObjectTypes.Project),
23
- objectType: ObjectTypes.Project,
24
- owners: [owner],
25
- writers: [],
26
- viewers: [],
27
- title: '',
28
- });
29
- export const buildManuscript = () => ({
30
- _id: generateID(ObjectTypes.Manuscript),
31
- objectType: ObjectTypes.Manuscript,
32
- });
33
- export const buildContributor = (bibliographicName, role = 'author', priority = 0, userID, invitationID) => ({
34
- _id: generateID(ObjectTypes.Contributor),
35
- objectType: ObjectTypes.Contributor,
36
- priority,
37
- role,
38
- affiliations: [],
39
- bibliographicName: buildBibliographicName(bibliographicName),
40
- userID,
41
- invitationID,
42
- });
43
- export const buildBibliographyItem = (data) => (Object.assign(Object.assign({}, data), { type: data.type || 'article-journal', _id: generateID(ObjectTypes.BibliographyItem), objectType: ObjectTypes.BibliographyItem }));
44
- export const buildBibliographicName = (data) => (Object.assign(Object.assign({}, data), { _id: generateID(ObjectTypes.BibliographicName), objectType: ObjectTypes.BibliographicName }));
45
- export const buildBibliographicDate = (data) => (Object.assign(Object.assign({}, data), { _id: generateID(ObjectTypes.BibliographicDate), objectType: ObjectTypes.BibliographicDate }));
46
- export const buildBibliographyElement = (bibliographyItems) => ({
47
- _id: generateID(ObjectTypes.BibliographyElement),
48
- objectType: ObjectTypes.BibliographyElement,
49
- contents: '',
50
- elementType: 'div',
51
- containedObjectIDs: bibliographyItems.map((b) => b._id),
52
- });
53
- export const buildKeyword = (name) => ({
54
- _id: generateID(ObjectTypes.Keyword),
55
- objectType: ObjectTypes.Keyword,
56
- name,
57
- });
58
- export const buildKeywordGroup = (attributes) => (Object.assign(Object.assign(Object.assign({ _id: generateID(ObjectTypes.KeywordGroup), objectType: ObjectTypes.KeywordGroup }, (attributes.type && { type: attributes.type })), (attributes.title && { title: attributes.title })), (attributes.label && { label: attributes.label })));
59
- export const buildFigure = (blob) => ({
60
- _id: generateID(ObjectTypes.Figure),
61
- objectType: ObjectTypes.Figure,
62
- contentType: blob.type,
63
- src: window.URL.createObjectURL(blob),
64
- attachment: {
65
- id: 'image',
66
- type: blob.type,
67
- data: blob,
68
- },
69
- });
70
- export const buildAffiliation = (institution, priority = 0) => ({
71
- _id: generateID(ObjectTypes.Affiliation),
72
- objectType: ObjectTypes.Affiliation,
73
- institution,
74
- priority,
75
- });
76
- export const buildSupplementaryMaterial = (title, href) => ({
77
- _id: generateID(ObjectTypes.Supplement),
78
- objectType: ObjectTypes.Supplement,
79
- title,
80
- href,
81
- });
82
- export const buildComment = (target, contents = '', selector, contributions, annotationColor) => ({
83
- _id: generateID(ObjectTypes.CommentAnnotation),
84
- objectType: ObjectTypes.CommentAnnotation,
85
- target,
86
- selector,
87
- contents,
88
- contributions,
89
- annotationColor,
90
- });
91
- export const buildNote = (target, source, contents = '') => ({
92
- _id: generateID(ObjectTypes.ManuscriptNote),
93
- objectType: ObjectTypes.ManuscriptNote,
94
- target,
95
- source,
96
- contents,
97
- });
98
- export const buildFootnote = (containingObject, contents, kind = 'footnote') => ({
99
- _id: generateID(ObjectTypes.Footnote),
100
- objectType: ObjectTypes.Footnote,
101
- containingObject: containingObject || undefined,
102
- contents,
103
- kind,
104
- });
105
- export const buildAuthorNotes = (containedObjectIDs) => ({
106
- _id: generateID(ObjectTypes.AuthorNotes),
107
- objectType: ObjectTypes.AuthorNotes,
108
- containedObjectIDs: containedObjectIDs,
109
- });
110
- export const buildFootnotesOrder = (footnotesList, containedObjectID) => ({
111
- _id: generateID(ObjectTypes.FootnotesOrder),
112
- objectType: ObjectTypes.FootnotesOrder,
113
- footnotesList,
114
- containedObjectID,
115
- });
116
- export const buildCorresp = (contents) => ({
117
- _id: generateID(ObjectTypes.Corresponding),
118
- objectType: ObjectTypes.Corresponding,
119
- contents,
120
- });
121
- export const buildSection = (priority = 0, path = []) => {
122
- const id = generateID(ObjectTypes.Section);
123
- return {
124
- _id: id,
125
- objectType: ObjectTypes.Section,
126
- priority,
127
- path: path.concat(id),
128
- };
129
- };
130
- export const buildParagraph = (innerHTML = '') => {
131
- const _id = generateID(ObjectTypes.ParagraphElement);
132
- const element = document.createElementNS(null, 'p');
133
- element.setAttribute('id', _id);
134
- if (innerHTML) {
135
- element.innerHTML = innerHTML;
136
- }
137
- const contents = serializeToXML(element);
138
- return {
139
- _id,
140
- objectType: ObjectTypes.ParagraphElement,
141
- elementType: 'p',
142
- contents,
143
- };
144
- };
145
- export const buildColor = (value, priority) => ({
146
- _id: generateID(ObjectTypes.Color),
147
- objectType: ObjectTypes.Color,
148
- priority,
149
- value,
150
- });
151
- export const buildContribution = (profileID) => ({
152
- _id: generateID(ObjectTypes.Contribution),
153
- objectType: ObjectTypes.Contribution,
154
- profileID,
155
- timestamp: timestamp(),
156
- });
157
- export const buildContributorRole = (name) => ({
158
- _id: generateID(ObjectTypes.ContributorRole),
159
- objectType: ObjectTypes.ContributorRole,
160
- name,
161
- });
162
- export const buildAttribution = () => ({
163
- _id: generateID(ObjectTypes.Attribution),
164
- objectType: ObjectTypes.Attribution,
165
- });
166
- export const buildJournal = () => ({
167
- _id: generateID(ObjectTypes.Journal),
168
- objectType: ObjectTypes.Journal,
169
- });
170
- export const auxiliaryObjectTypes = new Set([
171
- schema.nodes.figure_element,
172
- schema.nodes.table_element,
173
- schema.nodes.equation_element,
174
- schema.nodes.listing_element,
175
- ]);
176
- export const buildElementsOrder = (elementType) => ({
177
- _id: generateID(ObjectTypes.ElementsOrder),
178
- objectType: ObjectTypes.ElementsOrder,
179
- elementType: elementType,
180
- elements: [],
181
- });
182
- export const buildTitles = (title) => ({
183
- _id: generateID(ObjectTypes.Titles),
184
- objectType: ObjectTypes.Titles,
185
- title: title || '',
186
- });