@manuscripts/transform 2.1.3-LEAN-3376-5 → 2.1.4

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.
@@ -202,9 +202,7 @@ exports.jatsBodyTransformations = {
202
202
  }
203
203
  },
204
204
  moveFootnotes(doc, group, createElement) {
205
- const footnotes = [
206
- ...doc.querySelectorAll('fn:not(table-wrap-foot fn, author-notes fn)'),
207
- ];
205
+ const footnotes = [...doc.querySelectorAll('fn:not(table-wrap-foot fn)')];
208
206
  const footnotesSection = doc.querySelector('sec[sec-type="endnotes"]');
209
207
  const footnotesSectionGroup = footnotesSection === null || footnotesSection === void 0 ? void 0 : footnotesSection.querySelector('fn-group');
210
208
  const containingGroup = footnotesSectionGroup || createElement('fn-group');
@@ -179,46 +179,7 @@ exports.jatsFrontParser = {
179
179
  affiliationIDs,
180
180
  };
181
181
  },
182
- parseAuthorNotes(element) {
183
- if (!element) {
184
- return {
185
- footnotes: [],
186
- footnoteIDs: new Map(),
187
- authorNotes: [],
188
- authorNotesParagraphs: [],
189
- correspondingIDs: new Map(),
190
- correspondingList: [],
191
- };
192
- }
193
- const { footnotes, footnoteIDs } = this.parseFootnotes([
194
- ...element.querySelectorAll('fn:not([fn-type])'),
195
- ]);
196
- const authorNotesParagraphs = this.parseParagraphs([
197
- ...element.querySelectorAll(':scope > p'),
198
- ]);
199
- const { correspondingList, correspondingIDs } = this.parseCorresp([
200
- ...element.querySelectorAll('corresp'),
201
- ]);
202
- const authorNotes = [
203
- (0, transformer_1.buildAuthorNotes)([
204
- ...correspondingIDs.values(),
205
- ...footnoteIDs.values(),
206
- ...authorNotesParagraphs.map((p) => p._id),
207
- ]),
208
- ];
209
- return {
210
- footnotes,
211
- footnoteIDs,
212
- authorNotesParagraphs,
213
- authorNotes,
214
- correspondingIDs,
215
- correspondingList,
216
- };
217
- },
218
- parseParagraphs(elements) {
219
- return elements.map((p) => (0, transformer_1.buildParagraph)(p.innerHTML));
220
- },
221
- parseFootnotes(elements) {
182
+ parseAuthorNotes(elements) {
222
183
  const footnoteIDs = new Map();
223
184
  const footnotes = elements.map((element) => {
224
185
  const fn = (0, transformer_1.buildFootnote)('', element.innerHTML);
@@ -35,7 +35,12 @@ const parseJATSFront = (doc, front) => {
35
35
  const { affiliations, affiliationIDs } = jats_front_parser_1.jatsFrontParser.parseAffiliations([
36
36
  ...front.querySelectorAll('article-meta > contrib-group > aff'),
37
37
  ]);
38
- const { footnotes, footnoteIDs, authorNotes, authorNotesParagraphs, correspondingIDs, correspondingList, } = jats_front_parser_1.jatsFrontParser.parseAuthorNotes(front.querySelector('article-meta > author-notes'));
38
+ const { footnotes, footnoteIDs } = jats_front_parser_1.jatsFrontParser.parseAuthorNotes([
39
+ ...front.querySelectorAll('article-meta > author-notes > fn:not([fn-type])'),
40
+ ]);
41
+ const { correspondingList, correspondingIDs } = jats_front_parser_1.jatsFrontParser.parseCorresp([
42
+ ...front.querySelectorAll('article-meta > author-notes > corresp'),
43
+ ]);
39
44
  const authors = jats_front_parser_1.jatsFrontParser.parseContributors([
40
45
  ...front.querySelectorAll('article-meta > contrib-group > contrib[contrib-type="author"]'),
41
46
  ], affiliationIDs, footnoteIDs, correspondingIDs);
@@ -46,8 +51,6 @@ const parseJATSFront = (doc, front) => {
46
51
  manuscript,
47
52
  titles,
48
53
  journal,
49
- ...authorNotesParagraphs,
50
- ...authorNotes,
51
54
  ...footnotes,
52
55
  ...authors,
53
56
  ...affiliations,
@@ -614,7 +614,6 @@ class JATSExporter {
614
614
  this.createSerializer = () => {
615
615
  const getModel = (id) => id ? this.modelMap.get(id) : undefined;
616
616
  const nodes = {
617
- author_notes: () => ['author-notes', 0],
618
617
  title: () => '',
619
618
  affiliations: () => '',
620
619
  contributors: () => '',
@@ -1059,7 +1058,6 @@ class JATSExporter {
1059
1058
  }
1060
1059
  };
1061
1060
  this.buildContributors = (articleMeta) => {
1062
- var _a;
1063
1061
  const contributors = this.models.filter(isContributor);
1064
1062
  const authorContributors = contributors
1065
1063
  .filter((contributor) => contributor.role === 'author')
@@ -1278,23 +1276,49 @@ class JATSExporter {
1278
1276
  }
1279
1277
  });
1280
1278
  }
1281
- const authorNotes = (_a = (0, json_schema_1.getModelsByType)(this.modelMap, json_schema_1.ObjectTypes.AuthorNotes)) === null || _a === void 0 ? void 0 : _a[0];
1282
- if (authorNotes) {
1279
+ const noteIDs = [];
1280
+ for (const contributor of [...authorContributors, ...otherContributors]) {
1281
+ if (contributor.footnote) {
1282
+ const ids = contributor.footnote.map((note) => {
1283
+ return note.noteID;
1284
+ });
1285
+ noteIDs.push(...ids);
1286
+ }
1287
+ if (contributor.corresp) {
1288
+ const ids = contributor.corresp.map((corresp) => {
1289
+ return corresp.correspID;
1290
+ });
1291
+ noteIDs.push(...ids);
1292
+ }
1293
+ }
1294
+ const footnotes = [];
1295
+ footnotes.push(...this.models.filter((0, object_types_1.hasObjectType)(json_schema_1.ObjectTypes.Footnote)));
1296
+ const correspodings = [];
1297
+ correspodings.push(...this.models.filter((0, object_types_1.hasObjectType)(json_schema_1.ObjectTypes.Corresponding)));
1298
+ if (footnotes || correspodings) {
1283
1299
  const authorNotesEl = this.document.createElement('author-notes');
1284
- authorNotes.containedObjectIDs.forEach((id) => {
1285
- const model = this.modelMap.get(id);
1286
- if (!model) {
1287
- return;
1288
- }
1289
- if (id.startsWith('MPParagraphElement')) {
1290
- this.appendParagraphToElement(model, authorNotesEl);
1291
- }
1292
- else if (id.startsWith('MPFootnote')) {
1293
- this.appendFootnoteToElement(model, authorNotesEl);
1294
- }
1295
- else if (id.startsWith('MPCorrepsonding')) {
1296
- this.appendCorrespondingToElement(model, authorNotesEl);
1300
+ const usedFootnotes = footnotes.filter((footnote) => {
1301
+ return noteIDs.includes(footnote._id);
1302
+ });
1303
+ const usedCorrespodings = correspodings.filter((corresp) => {
1304
+ return noteIDs.includes(corresp._id);
1305
+ });
1306
+ usedFootnotes.forEach((footnote) => {
1307
+ const authorFootNote = this.document.createElement('fn');
1308
+ authorFootNote.setAttribute('id', normalizeID(footnote._id));
1309
+ authorFootNote.innerHTML = footnote.contents;
1310
+ authorNotesEl.appendChild(authorFootNote);
1311
+ });
1312
+ usedCorrespodings.forEach((corresponding) => {
1313
+ const correspondingEl = this.document.createElement('corresp');
1314
+ correspondingEl.setAttribute('id', normalizeID(corresponding._id));
1315
+ if (corresponding.label) {
1316
+ const labelEl = this.document.createElement('label');
1317
+ labelEl.textContent = corresponding.label;
1318
+ correspondingEl.appendChild(labelEl);
1297
1319
  }
1320
+ correspondingEl.append(corresponding.contents);
1321
+ authorNotesEl.appendChild(correspondingEl);
1298
1322
  });
1299
1323
  if (authorNotesEl.childNodes.length > 0) {
1300
1324
  articleMeta.insertBefore(authorNotesEl, contribGroup.nextSibling);
@@ -1302,29 +1326,6 @@ class JATSExporter {
1302
1326
  }
1303
1327
  }
1304
1328
  };
1305
- this.appendCorrespondingToElement = (corresponding, element) => {
1306
- const correspondingEl = this.document.createElement('corresp');
1307
- correspondingEl.setAttribute('id', normalizeID(corresponding._id));
1308
- if (corresponding.label) {
1309
- const labelEl = this.document.createElement('label');
1310
- labelEl.textContent = corresponding.label;
1311
- correspondingEl.appendChild(labelEl);
1312
- }
1313
- correspondingEl.append(corresponding.contents);
1314
- element.appendChild(correspondingEl);
1315
- };
1316
- this.appendParagraphToElement = (paragraph, element) => {
1317
- const paragraphEl = this.document.createElement('p');
1318
- paragraphEl.setAttribute('id', normalizeID(paragraph._id));
1319
- paragraphEl.innerHTML = paragraph.contents;
1320
- element.appendChild(paragraphEl);
1321
- };
1322
- this.appendFootnoteToElement = (footnote, element) => {
1323
- const footnoteEl = this.document.createElement('fn');
1324
- footnoteEl.setAttribute('id', normalizeID(footnote._id));
1325
- footnoteEl.innerHTML = footnote.contents;
1326
- element.appendChild(footnoteEl);
1327
- };
1328
1329
  this.fixBody = (body, fragment) => {
1329
1330
  fragment.descendants((node) => {
1330
1331
  if (node.attrs.id) {
@@ -36,7 +36,6 @@ const abstracts_1 = require("./nodes/abstracts");
36
36
  const affiliation_1 = require("./nodes/affiliation");
37
37
  const affiliations_1 = require("./nodes/affiliations");
38
38
  const attribution_1 = require("./nodes/attribution");
39
- const author_notes_1 = require("./nodes/author_notes");
40
39
  const backmatter_1 = require("./nodes/backmatter");
41
40
  const bibliography_element_1 = require("./nodes/bibliography_element");
42
41
  const bibliography_item_1 = require("./nodes/bibliography_item");
@@ -217,7 +216,6 @@ exports.schema = new prosemirror_model_1.Schema({
217
216
  table_row: table_1.tableRow,
218
217
  table_col: table_col_1.tableCol,
219
218
  table_colgroup: table_col_1.tableColGroup,
220
- table_header: table_1.tableHeader,
221
219
  text: text_1.text,
222
220
  toc_element: toc_element_1.tocElement,
223
221
  toc_section: toc_section_1.tocSection,
@@ -229,6 +227,6 @@ exports.schema = new prosemirror_model_1.Schema({
229
227
  contributors: contributors_1.contributors,
230
228
  supplements: supplements_1.supplements,
231
229
  supplement: supplement_1.supplement,
232
- author_notes: author_notes_1.authorNotes,
230
+ table_header: table_1.tableHeader,
233
231
  },
234
232
  });
@@ -17,7 +17,7 @@
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.contributors = void 0;
19
19
  exports.contributors = {
20
- content: 'contributor* author_notes?',
20
+ content: 'contributor*',
21
21
  attrs: {
22
22
  id: { default: '' },
23
23
  },
@@ -18,7 +18,7 @@ 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.buildTitles = exports.buildElementsOrder = exports.auxiliaryObjectTypes = exports.buildJournal = exports.buildAttribution = exports.buildContributorRole = exports.buildContribution = exports.buildColor = exports.buildParagraph = exports.buildSection = exports.buildCorresp = exports.buildFootnotesOrder = exports.buildAuthorNotes = exports.buildFootnote = exports.buildInlineMathFragment = exports.buildNote = exports.buildComment = exports.buildSupplementaryMaterial = exports.buildAffiliation = exports.buildFigure = exports.buildKeywordGroup = exports.buildKeyword = exports.buildBibliographyElement = exports.buildBibliographicDate = exports.buildBibliographicName = exports.buildBibliographyItem = exports.buildContributor = exports.buildManuscript = exports.buildProject = void 0;
21
+ exports.buildTitles = exports.buildElementsOrder = exports.auxiliaryObjectTypes = exports.buildJournal = exports.buildAttribution = exports.buildContributorRole = exports.buildContribution = exports.buildColor = exports.buildParagraph = exports.buildSection = exports.buildCorresp = exports.buildFootnotesOrder = exports.buildFootnote = exports.buildInlineMathFragment = exports.buildNote = exports.buildComment = exports.buildSupplementaryMaterial = exports.buildAffiliation = exports.buildFigure = exports.buildKeywordGroup = exports.buildKeyword = exports.buildBibliographyElement = exports.buildBibliographicDate = exports.buildBibliographicName = exports.buildBibliographyItem = exports.buildContributor = exports.buildManuscript = exports.buildProject = void 0;
22
22
  const json_schema_1 = require("@manuscripts/json-schema");
23
23
  const w3c_xmlserializer_1 = __importDefault(require("w3c-xmlserializer"));
24
24
  const schema_1 = require("../schema");
@@ -130,12 +130,6 @@ const buildFootnote = (containingObject, contents, kind = 'footnote') => ({
130
130
  kind,
131
131
  });
132
132
  exports.buildFootnote = buildFootnote;
133
- const buildAuthorNotes = (containedObjectIDs) => ({
134
- _id: (0, id_1.generateID)(json_schema_1.ObjectTypes.AuthorNotes),
135
- objectType: json_schema_1.ObjectTypes.AuthorNotes,
136
- containedObjectIDs: containedObjectIDs,
137
- });
138
- exports.buildAuthorNotes = buildAuthorNotes;
139
133
  const buildFootnotesOrder = (footnotesList, containedObjectID) => ({
140
134
  _id: (0, id_1.generateID)(json_schema_1.ObjectTypes.FootnotesOrder),
141
135
  objectType: json_schema_1.ObjectTypes.FootnotesOrder,
@@ -62,7 +62,6 @@ const sortSectionsByPriority = (a, b) => a.priority === b.priority ? 0 : Number(
62
62
  exports.sortSectionsByPriority = sortSectionsByPriority;
63
63
  const getSections = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.Section).sort(exports.sortSectionsByPriority);
64
64
  const getAffiliations = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.Affiliation);
65
- const getAuthorNotes = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.AuthorNotes);
66
65
  const getContributors = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.Contributor);
67
66
  const getKeywordElements = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.KeywordsElement);
68
67
  const getSupplements = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.Supplement);
@@ -92,11 +91,7 @@ class Decoder {
92
91
  const contributors = getContributors(this.modelMap)
93
92
  .map((c) => this.decode(c))
94
93
  .filter(Boolean);
95
- const authorNotes = getAuthorNotes(this.modelMap)
96
- .map((authorNote) => this.decode(authorNote))
97
- .filter(Boolean);
98
- const content = [...contributors, ...authorNotes];
99
- return schema_1.schema.nodes.contributors.createAndFill({}, content);
94
+ return schema_1.schema.nodes.contributors.createAndFill({}, contributors);
100
95
  }
101
96
  createKeywordsNode() {
102
97
  const elements = getKeywordElements(this.modelMap)
@@ -497,15 +492,6 @@ class Decoder {
497
492
  id: model._id,
498
493
  }, content);
499
494
  },
500
- [json_schema_1.ObjectTypes.AuthorNotes]: (data) => {
501
- const model = data;
502
- const content = model.containedObjectIDs
503
- .filter((id) => !id.startsWith('MPCorresponding'))
504
- .map((id) => this.decode(this.modelMap.get(id)));
505
- return schema_1.schema.nodes.author_notes.create({
506
- id: model._id,
507
- }, content);
508
- },
509
495
  [json_schema_1.ObjectTypes.Section]: (data) => {
510
496
  const model = data;
511
497
  const elements = [];
@@ -396,9 +396,6 @@ const encoders = {
396
396
  table_element_footer: (node) => ({
397
397
  containedObjectIDs: containedObjectIDs(node),
398
398
  }),
399
- author_notes: (node) => ({
400
- containedObjectIDs: containedObjectIDs(node),
401
- }),
402
399
  footnotes_section: (node, parent, path, priority) => ({
403
400
  category: (0, section_category_1.buildSectionCategory)(node),
404
401
  priority: priority.value++,
@@ -62,8 +62,6 @@ exports.nodeTypesMap = new Map([
62
62
  [schema_1.schema.nodes.affiliations, json_schema_1.ObjectTypes.Section],
63
63
  [schema_1.schema.nodes.title, json_schema_1.ObjectTypes.Titles],
64
64
  [schema_1.schema.nodes.supplement, json_schema_1.ObjectTypes.Supplement],
65
- [schema_1.schema.nodes.author_notes, json_schema_1.ObjectTypes.AuthorNotes],
66
- [schema_1.schema.nodes.corresp, json_schema_1.ObjectTypes.Corresponding],
67
65
  ]);
68
66
  const isExecutableNodeType = (type) => (0, schema_1.hasGroup)(type, schema_1.GROUP_EXECUTABLE);
69
67
  exports.isExecutableNodeType = isExecutableNodeType;
@@ -199,9 +199,7 @@ export const jatsBodyTransformations = {
199
199
  }
200
200
  },
201
201
  moveFootnotes(doc, group, createElement) {
202
- const footnotes = [
203
- ...doc.querySelectorAll('fn:not(table-wrap-foot fn, author-notes fn)'),
204
- ];
202
+ const footnotes = [...doc.querySelectorAll('fn:not(table-wrap-foot fn)')];
205
203
  const footnotesSection = doc.querySelector('sec[sec-type="endnotes"]');
206
204
  const footnotesSectionGroup = footnotesSection === null || footnotesSection === void 0 ? void 0 : footnotesSection.querySelector('fn-group');
207
205
  const containingGroup = footnotesSectionGroup || createElement('fn-group');
@@ -15,7 +15,7 @@
15
15
  */
16
16
  import debug from 'debug';
17
17
  import { getTrimmedTextContent } from '../../lib/utils';
18
- import { buildAffiliation, buildAuthorNotes, buildBibliographicName, buildContributor, buildCorresp, buildFootnote, buildJournal, buildParagraph, buildTitles, } from '../../transformer';
18
+ import { buildAffiliation, buildBibliographicName, buildContributor, buildCorresp, buildFootnote, buildJournal, buildTitles, } from '../../transformer';
19
19
  import { parseJournalMeta } from './jats-journal-meta-parser';
20
20
  import { htmlFromJatsNode } from './jats-parser-utils';
21
21
  const warn = debug('manuscripts-transform');
@@ -173,46 +173,7 @@ export const jatsFrontParser = {
173
173
  affiliationIDs,
174
174
  };
175
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) {
176
+ parseAuthorNotes(elements) {
216
177
  const footnoteIDs = new Map();
217
178
  const footnotes = elements.map((element) => {
218
179
  const fn = buildFootnote('', element.innerHTML);
@@ -32,7 +32,12 @@ export const parseJATSFront = (doc, front) => {
32
32
  const { affiliations, affiliationIDs } = jatsFrontParser.parseAffiliations([
33
33
  ...front.querySelectorAll('article-meta > contrib-group > aff'),
34
34
  ]);
35
- const { footnotes, footnoteIDs, authorNotes, authorNotesParagraphs, correspondingIDs, correspondingList, } = jatsFrontParser.parseAuthorNotes(front.querySelector('article-meta > author-notes'));
35
+ const { footnotes, footnoteIDs } = jatsFrontParser.parseAuthorNotes([
36
+ ...front.querySelectorAll('article-meta > author-notes > fn:not([fn-type])'),
37
+ ]);
38
+ const { correspondingList, correspondingIDs } = jatsFrontParser.parseCorresp([
39
+ ...front.querySelectorAll('article-meta > author-notes > corresp'),
40
+ ]);
36
41
  const authors = jatsFrontParser.parseContributors([
37
42
  ...front.querySelectorAll('article-meta > contrib-group > contrib[contrib-type="author"]'),
38
43
  ], affiliationIDs, footnoteIDs, correspondingIDs);
@@ -43,8 +48,6 @@ export const parseJATSFront = (doc, front) => {
43
48
  manuscript,
44
49
  titles,
45
50
  journal,
46
- ...authorNotesParagraphs,
47
- ...authorNotes,
48
51
  ...footnotes,
49
52
  ...authors,
50
53
  ...affiliations,
@@ -13,7 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { getModelsByType, ObjectTypes, } from '@manuscripts/json-schema';
16
+ import { ObjectTypes, } from '@manuscripts/json-schema';
17
17
  import { CitationProvider } from '@manuscripts/library';
18
18
  import debug from 'debug';
19
19
  import { DOMParser, DOMSerializer } from 'prosemirror-model';
@@ -606,7 +606,6 @@ export class JATSExporter {
606
606
  this.createSerializer = () => {
607
607
  const getModel = (id) => id ? this.modelMap.get(id) : undefined;
608
608
  const nodes = {
609
- author_notes: () => ['author-notes', 0],
610
609
  title: () => '',
611
610
  affiliations: () => '',
612
611
  contributors: () => '',
@@ -1051,7 +1050,6 @@ export class JATSExporter {
1051
1050
  }
1052
1051
  };
1053
1052
  this.buildContributors = (articleMeta) => {
1054
- var _a;
1055
1053
  const contributors = this.models.filter(isContributor);
1056
1054
  const authorContributors = contributors
1057
1055
  .filter((contributor) => contributor.role === 'author')
@@ -1270,23 +1268,49 @@ export class JATSExporter {
1270
1268
  }
1271
1269
  });
1272
1270
  }
1273
- const authorNotes = (_a = getModelsByType(this.modelMap, ObjectTypes.AuthorNotes)) === null || _a === void 0 ? void 0 : _a[0];
1274
- if (authorNotes) {
1271
+ const noteIDs = [];
1272
+ for (const contributor of [...authorContributors, ...otherContributors]) {
1273
+ if (contributor.footnote) {
1274
+ const ids = contributor.footnote.map((note) => {
1275
+ return note.noteID;
1276
+ });
1277
+ noteIDs.push(...ids);
1278
+ }
1279
+ if (contributor.corresp) {
1280
+ const ids = contributor.corresp.map((corresp) => {
1281
+ return corresp.correspID;
1282
+ });
1283
+ noteIDs.push(...ids);
1284
+ }
1285
+ }
1286
+ const footnotes = [];
1287
+ footnotes.push(...this.models.filter(hasObjectType(ObjectTypes.Footnote)));
1288
+ const correspodings = [];
1289
+ correspodings.push(...this.models.filter(hasObjectType(ObjectTypes.Corresponding)));
1290
+ if (footnotes || correspodings) {
1275
1291
  const authorNotesEl = this.document.createElement('author-notes');
1276
- authorNotes.containedObjectIDs.forEach((id) => {
1277
- const model = this.modelMap.get(id);
1278
- if (!model) {
1279
- return;
1280
- }
1281
- if (id.startsWith('MPParagraphElement')) {
1282
- this.appendParagraphToElement(model, authorNotesEl);
1283
- }
1284
- else if (id.startsWith('MPFootnote')) {
1285
- this.appendFootnoteToElement(model, authorNotesEl);
1286
- }
1287
- else if (id.startsWith('MPCorrepsonding')) {
1288
- this.appendCorrespondingToElement(model, authorNotesEl);
1292
+ const usedFootnotes = footnotes.filter((footnote) => {
1293
+ return noteIDs.includes(footnote._id);
1294
+ });
1295
+ const usedCorrespodings = correspodings.filter((corresp) => {
1296
+ return noteIDs.includes(corresp._id);
1297
+ });
1298
+ usedFootnotes.forEach((footnote) => {
1299
+ const authorFootNote = this.document.createElement('fn');
1300
+ authorFootNote.setAttribute('id', normalizeID(footnote._id));
1301
+ authorFootNote.innerHTML = footnote.contents;
1302
+ authorNotesEl.appendChild(authorFootNote);
1303
+ });
1304
+ usedCorrespodings.forEach((corresponding) => {
1305
+ const correspondingEl = this.document.createElement('corresp');
1306
+ correspondingEl.setAttribute('id', normalizeID(corresponding._id));
1307
+ if (corresponding.label) {
1308
+ const labelEl = this.document.createElement('label');
1309
+ labelEl.textContent = corresponding.label;
1310
+ correspondingEl.appendChild(labelEl);
1289
1311
  }
1312
+ correspondingEl.append(corresponding.contents);
1313
+ authorNotesEl.appendChild(correspondingEl);
1290
1314
  });
1291
1315
  if (authorNotesEl.childNodes.length > 0) {
1292
1316
  articleMeta.insertBefore(authorNotesEl, contribGroup.nextSibling);
@@ -1294,29 +1318,6 @@ export class JATSExporter {
1294
1318
  }
1295
1319
  }
1296
1320
  };
1297
- this.appendCorrespondingToElement = (corresponding, element) => {
1298
- const correspondingEl = this.document.createElement('corresp');
1299
- correspondingEl.setAttribute('id', normalizeID(corresponding._id));
1300
- if (corresponding.label) {
1301
- const labelEl = this.document.createElement('label');
1302
- labelEl.textContent = corresponding.label;
1303
- correspondingEl.appendChild(labelEl);
1304
- }
1305
- correspondingEl.append(corresponding.contents);
1306
- element.appendChild(correspondingEl);
1307
- };
1308
- this.appendParagraphToElement = (paragraph, element) => {
1309
- const paragraphEl = this.document.createElement('p');
1310
- paragraphEl.setAttribute('id', normalizeID(paragraph._id));
1311
- paragraphEl.innerHTML = paragraph.contents;
1312
- element.appendChild(paragraphEl);
1313
- };
1314
- this.appendFootnoteToElement = (footnote, element) => {
1315
- const footnoteEl = this.document.createElement('fn');
1316
- footnoteEl.setAttribute('id', normalizeID(footnote._id));
1317
- footnoteEl.innerHTML = footnote.contents;
1318
- element.appendChild(footnoteEl);
1319
- };
1320
1321
  this.fixBody = (body, fragment) => {
1321
1322
  fragment.descendants((node) => {
1322
1323
  if (node.attrs.id) {
@@ -19,7 +19,6 @@ import { abstracts } from './nodes/abstracts';
19
19
  import { affiliation } from './nodes/affiliation';
20
20
  import { affiliations } from './nodes/affiliations';
21
21
  import { attribution } from './nodes/attribution';
22
- import { authorNotes } from './nodes/author_notes';
23
22
  import { backmatter } from './nodes/backmatter';
24
23
  import { bibliographyElement } from './nodes/bibliography_element';
25
24
  import { bibliographyItem } from './nodes/bibliography_item';
@@ -200,7 +199,6 @@ export const schema = new Schema({
200
199
  table_row: tableRow,
201
200
  table_col: tableCol,
202
201
  table_colgroup: tableColGroup,
203
- table_header: tableHeader,
204
202
  text,
205
203
  toc_element: tocElement,
206
204
  toc_section: tocSection,
@@ -212,6 +210,6 @@ export const schema = new Schema({
212
210
  contributors,
213
211
  supplements,
214
212
  supplement,
215
- author_notes: authorNotes,
213
+ table_header: tableHeader,
216
214
  },
217
215
  });
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  export const contributors = {
17
- content: 'contributor* author_notes?',
17
+ content: 'contributor*',
18
18
  attrs: {
19
19
  id: { default: '' },
20
20
  },
@@ -108,11 +108,6 @@ export const buildFootnote = (containingObject, contents, kind = 'footnote') =>
108
108
  contents,
109
109
  kind,
110
110
  });
111
- export const buildAuthorNotes = (containedObjectIDs) => ({
112
- _id: generateID(ObjectTypes.AuthorNotes),
113
- objectType: ObjectTypes.AuthorNotes,
114
- containedObjectIDs: containedObjectIDs,
115
- });
116
111
  export const buildFootnotesOrder = (footnotesList, containedObjectID) => ({
117
112
  _id: generateID(ObjectTypes.FootnotesOrder),
118
113
  objectType: ObjectTypes.FootnotesOrder,
@@ -53,7 +53,6 @@ export const getModelsByType = (modelMap, objectType) => {
53
53
  export const sortSectionsByPriority = (a, b) => a.priority === b.priority ? 0 : Number(a.priority) - Number(b.priority);
54
54
  const getSections = (modelMap) => getModelsByType(modelMap, ObjectTypes.Section).sort(sortSectionsByPriority);
55
55
  const getAffiliations = (modelMap) => getModelsByType(modelMap, ObjectTypes.Affiliation);
56
- const getAuthorNotes = (modelMap) => getModelsByType(modelMap, ObjectTypes.AuthorNotes);
57
56
  const getContributors = (modelMap) => getModelsByType(modelMap, ObjectTypes.Contributor);
58
57
  const getKeywordElements = (modelMap) => getModelsByType(modelMap, ObjectTypes.KeywordsElement);
59
58
  const getSupplements = (modelMap) => getModelsByType(modelMap, ObjectTypes.Supplement);
@@ -83,11 +82,7 @@ export class Decoder {
83
82
  const contributors = getContributors(this.modelMap)
84
83
  .map((c) => this.decode(c))
85
84
  .filter(Boolean);
86
- const authorNotes = getAuthorNotes(this.modelMap)
87
- .map((authorNote) => this.decode(authorNote))
88
- .filter(Boolean);
89
- const content = [...contributors, ...authorNotes];
90
- return schema.nodes.contributors.createAndFill({}, content);
85
+ return schema.nodes.contributors.createAndFill({}, contributors);
91
86
  }
92
87
  createKeywordsNode() {
93
88
  const elements = getKeywordElements(this.modelMap)
@@ -488,15 +483,6 @@ export class Decoder {
488
483
  id: model._id,
489
484
  }, content);
490
485
  },
491
- [ObjectTypes.AuthorNotes]: (data) => {
492
- const model = data;
493
- const content = model.containedObjectIDs
494
- .filter((id) => !id.startsWith('MPCorresponding'))
495
- .map((id) => this.decode(this.modelMap.get(id)));
496
- return schema.nodes.author_notes.create({
497
- id: model._id,
498
- }, content);
499
- },
500
486
  [ObjectTypes.Section]: (data) => {
501
487
  const model = data;
502
488
  const elements = [];
@@ -388,9 +388,6 @@ const encoders = {
388
388
  table_element_footer: (node) => ({
389
389
  containedObjectIDs: containedObjectIDs(node),
390
390
  }),
391
- author_notes: (node) => ({
392
- containedObjectIDs: containedObjectIDs(node),
393
- }),
394
391
  footnotes_section: (node, parent, path, priority) => ({
395
392
  category: buildSectionCategory(node),
396
393
  priority: priority.value++,
@@ -59,8 +59,6 @@ export const nodeTypesMap = new Map([
59
59
  [schema.nodes.affiliations, ObjectTypes.Section],
60
60
  [schema.nodes.title, ObjectTypes.Titles],
61
61
  [schema.nodes.supplement, ObjectTypes.Supplement],
62
- [schema.nodes.author_notes, ObjectTypes.AuthorNotes],
63
- [schema.nodes.corresp, ObjectTypes.Corresponding],
64
62
  ]);
65
63
  export const isExecutableNodeType = (type) => hasGroup(type, GROUP_EXECUTABLE);
66
64
  export const isElementNodeType = (type) => hasGroup(type, GROUP_ELEMENT);
@@ -63,16 +63,7 @@ export declare const jatsFrontParser: {
63
63
  affiliations: import("../../transformer").Build<import("@manuscripts/json-schema/dist/types").Affiliation>[];
64
64
  affiliationIDs: Map<string, string>;
65
65
  };
66
- parseAuthorNotes(element: Element | null): {
67
- footnotes: import("../../transformer").Build<import("@manuscripts/json-schema/dist/types").Footnote>[];
68
- footnoteIDs: Map<string, string>;
69
- authorNotesParagraphs: import("../../transformer").Build<import("@manuscripts/json-schema/dist/types").ParagraphElement>[];
70
- authorNotes: import("../../transformer").Build<import("@manuscripts/json-schema/dist/types").AuthorNotes>[];
71
- correspondingIDs: Map<string, string>;
72
- correspondingList: import("../../transformer").Build<import("@manuscripts/json-schema/dist/types").Corresponding>[];
73
- };
74
- parseParagraphs(elements: Element[]): import("../../transformer").Build<import("@manuscripts/json-schema/dist/types").ParagraphElement>[];
75
- parseFootnotes(elements: Element[]): {
66
+ parseAuthorNotes(elements: Element[]): {
76
67
  footnotes: import("../../transformer").Build<import("@manuscripts/json-schema/dist/types").Footnote>[];
77
68
  footnoteIDs: Map<string, string>;
78
69
  };
@@ -86,9 +86,6 @@ export declare class JATSExporter {
86
86
  protected serializeNode: (node: ManuscriptNode) => Node;
87
87
  private validateContributor;
88
88
  private buildContributors;
89
- private appendCorrespondingToElement;
90
- private appendParagraphToElement;
91
- private appendFootnoteToElement;
92
89
  private buildKeywords;
93
90
  private fixBody;
94
91
  private changeTag;
@@ -17,7 +17,7 @@ import { Fragment, Mark as ProsemirrorMark, MarkType, Node as ProsemirrorNode, N
17
17
  import { EditorState, NodeSelection, Plugin, TextSelection, Transaction } from 'prosemirror-state';
18
18
  import { EditorView, NodeView } from 'prosemirror-view';
19
19
  export type Marks = 'bold' | 'code' | 'italic' | 'smallcaps' | 'strikethrough' | 'styled' | 'subscript' | 'superscript' | 'underline' | 'tracked_insert' | 'tracked_delete';
20
- export type Nodes = 'attribution' | 'bibliography_item' | 'bibliography_element' | 'bibliography_section' | 'blockquote_element' | 'bullet_list' | 'caption' | 'caption_title' | 'comment' | 'comments' | 'citation' | 'cross_reference' | 'doc' | 'equation' | 'equation_element' | 'figcaption' | 'figure' | 'graphical_abstract_section' | 'figure_element' | 'footnote' | 'footnotes_element' | 'footnotes_section' | 'hard_break' | 'highlight_marker' | 'inline_equation' | 'inline_footnote' | 'keyword' | 'keywords_element' | 'keyword_group' | 'keywords' | 'link' | 'list_item' | 'listing' | 'listing_element' | 'manuscript' | 'abstracts' | 'body' | 'backmatter' | 'missing_figure' | 'ordered_list' | 'paragraph' | 'placeholder' | 'placeholder_element' | 'pullquote_element' | 'section' | 'section_label' | 'section_title' | 'section_title_plain' | 'table' | 'table_cell' | 'table_element' | 'table_row' | 'table_colgroup' | 'table_col' | 'table_header' | 'text' | 'toc_element' | 'toc_section' | 'affiliation' | 'contributor' | 'table_element_footer' | 'title' | 'affiliations' | 'contributors' | 'supplements' | 'supplement' | 'author_notes';
20
+ export type Nodes = 'attribution' | 'bibliography_item' | 'bibliography_element' | 'bibliography_section' | 'blockquote_element' | 'bullet_list' | 'caption' | 'caption_title' | 'comment' | 'comments' | 'citation' | 'cross_reference' | 'doc' | 'equation' | 'equation_element' | 'figcaption' | 'figure' | 'graphical_abstract_section' | 'figure_element' | 'footnote' | 'footnotes_element' | 'footnotes_section' | 'hard_break' | 'highlight_marker' | 'inline_equation' | 'inline_footnote' | 'keyword' | 'keywords_element' | 'keyword_group' | 'keywords' | 'link' | 'list_item' | 'listing' | 'listing_element' | 'manuscript' | 'abstracts' | 'body' | 'backmatter' | 'missing_figure' | 'ordered_list' | 'paragraph' | 'placeholder' | 'placeholder_element' | 'pullquote_element' | 'section' | 'section_label' | 'section_title' | 'section_title_plain' | 'table' | 'table_cell' | 'table_element' | 'table_row' | 'table_colgroup' | 'table_col' | 'text' | 'toc_element' | 'toc_section' | 'affiliation' | 'contributor' | 'table_element_footer' | 'title' | 'affiliations' | 'contributors' | 'supplements' | 'supplement' | 'table_header';
21
21
  export type ManuscriptSchema = Schema<Nodes, Marks>;
22
22
  export type ManuscriptEditorState = EditorState;
23
23
  export type ManuscriptEditorView = EditorView;
@@ -13,7 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { Affiliation, Attribution, AuthorNotes, BibliographicDate, BibliographicName, BibliographyElement, BibliographyItem, Color, CommentAnnotation, Contribution, Contributor, ContributorRole, Corresponding, ElementsOrder, EmbeddedModel, Figure, Footnote, FootnotesOrder, InlineMathFragment, Journal, Keyword, KeywordGroup, Manuscript, ManuscriptNote, ObjectTypes, ParagraphElement, Project, Section, Supplement, Titles } from '@manuscripts/json-schema';
16
+ import { Affiliation, Attribution, BibliographicDate, BibliographicName, BibliographyElement, BibliographyItem, Color, CommentAnnotation, Contribution, Contributor, ContributorRole, Corresponding, ElementsOrder, EmbeddedModel, Figure, Footnote, FootnotesOrder, InlineMathFragment, Journal, Keyword, KeywordGroup, Manuscript, ManuscriptNote, ObjectTypes, ParagraphElement, Project, Section, Supplement, Titles } from '@manuscripts/json-schema';
17
17
  import { FootnotesOrderIndexList } from './footnotes-order';
18
18
  import { CommentSelector, ManuscriptModel, ModelAttachment } from './models';
19
19
  export type Build<T> = Pick<T, Exclude<keyof T, keyof ManuscriptModel>> & {
@@ -46,7 +46,6 @@ export declare const buildComment: (target: string, contents?: string, selector?
46
46
  export declare const buildNote: (target: string, source: 'EMAIL' | 'EDITOR' | 'DASHBOARD', contents?: string) => Build<ManuscriptNote>;
47
47
  export declare const buildInlineMathFragment: (containingObject: string, TeXRepresentation: string) => Build<InlineMathFragment>;
48
48
  export declare const buildFootnote: (containingObject: string, contents: string, kind?: 'footnote' | 'endnote') => Build<Footnote>;
49
- export declare const buildAuthorNotes: (containedObjectIDs: string[]) => Build<AuthorNotes>;
50
49
  export declare const buildFootnotesOrder: (footnotesList: FootnotesOrderIndexList, containedObjectID: string) => Build<FootnotesOrder>;
51
50
  export declare const buildCorresp: (contents: string) => Build<Corresponding>;
52
51
  export declare const buildSection: (priority?: number, path?: string[]) => Build<Section>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@manuscripts/transform",
3
3
  "description": "ProseMirror transformer for Manuscripts applications",
4
- "version": "2.1.3-LEAN-3376-5",
4
+ "version": "2.1.4",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-transform",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -29,8 +29,8 @@
29
29
  "version": "yarn build"
30
30
  },
31
31
  "dependencies": {
32
- "@manuscripts/json-schema": "2.2.4-LEAN-3376-1",
33
- "@manuscripts/library": "1.3.3-LEAN-3376-1",
32
+ "@manuscripts/json-schema": "^2.2.4",
33
+ "@manuscripts/library": "^1.3.3",
34
34
  "debug": "^4.3.4",
35
35
  "jszip": "^3.10.1",
36
36
  "mathjax-full": "^3.2.2",
@@ -1,27 +0,0 @@
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.authorNotes = void 0;
19
- exports.authorNotes = {
20
- attrs: {
21
- id: { default: '' },
22
- dataTracked: { default: null },
23
- },
24
- content: '(footnote | paragraph)+',
25
- group: 'block element',
26
- toDOM: () => ['author-notes', 0],
27
- };
@@ -1,24 +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
- export const authorNotes = {
17
- attrs: {
18
- id: { default: '' },
19
- dataTracked: { default: null },
20
- },
21
- content: '(footnote | paragraph)+',
22
- group: 'block element',
23
- toDOM: () => ['author-notes', 0],
24
- };
@@ -1,25 +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 { NodeSpec } from 'prosemirror-model';
17
- import { ManuscriptNode } from '../types';
18
- interface Attrs {
19
- id: string;
20
- }
21
- export interface AuthorNotesNode extends ManuscriptNode {
22
- attrs: Attrs;
23
- }
24
- export declare const authorNotes: NodeSpec;
25
- export {};