@manuscripts/transform 1.5.3 → 1.5.4-3019-v1

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 (43) hide show
  1. package/dist/cjs/jats/importer/parse-jats-article.js +11 -2
  2. package/dist/cjs/jats/jats-exporter.js +8 -6
  3. package/dist/cjs/schema/index.js +3 -0
  4. package/dist/cjs/schema/nodes/affiliation.js +22 -1
  5. package/dist/cjs/schema/nodes/affiliations_section.js +23 -2
  6. package/dist/cjs/schema/nodes/contributor.js +13 -1
  7. package/dist/cjs/schema/nodes/contributors_element.js +49 -0
  8. package/dist/cjs/schema/nodes/contributors_section.js +23 -2
  9. package/dist/cjs/schema/nodes/manuscript.js +1 -1
  10. package/dist/cjs/schema/nodes/title.js +29 -0
  11. package/dist/cjs/transformer/builders.js +8 -3
  12. package/dist/cjs/transformer/decode.js +22 -3
  13. package/dist/cjs/transformer/encode.js +6 -0
  14. package/dist/cjs/transformer/html.js +6 -5
  15. package/dist/cjs/transformer/node-title.js +6 -4
  16. package/dist/cjs/transformer/node-types.js +1 -0
  17. package/dist/cjs/transformer/project-bundle.js +22 -1
  18. package/dist/es/jats/importer/parse-jats-article.js +11 -2
  19. package/dist/es/jats/jats-exporter.js +9 -7
  20. package/dist/es/schema/index.js +3 -0
  21. package/dist/es/schema/nodes/affiliation.js +22 -1
  22. package/dist/es/schema/nodes/affiliations_section.js +23 -2
  23. package/dist/es/schema/nodes/contributor.js +13 -1
  24. package/dist/es/schema/nodes/contributors_element.js +46 -0
  25. package/dist/es/schema/nodes/contributors_section.js +23 -2
  26. package/dist/es/schema/nodes/manuscript.js +1 -1
  27. package/dist/es/schema/nodes/title.js +26 -0
  28. package/dist/es/transformer/builders.js +6 -2
  29. package/dist/es/transformer/decode.js +22 -3
  30. package/dist/es/transformer/encode.js +6 -0
  31. package/dist/es/transformer/html.js +7 -6
  32. package/dist/es/transformer/node-title.js +7 -5
  33. package/dist/es/transformer/node-types.js +1 -0
  34. package/dist/es/transformer/project-bundle.js +20 -0
  35. package/dist/types/schema/index.d.ts +1 -0
  36. package/dist/types/schema/nodes/contributors_element.d.ts +27 -0
  37. package/dist/types/schema/nodes/contributors_section.d.ts +1 -0
  38. package/dist/types/schema/nodes/title.d.ts +28 -0
  39. package/dist/types/schema/types.d.ts +1 -1
  40. package/dist/types/transformer/builders.d.ts +3 -2
  41. package/dist/types/transformer/decode.d.ts +1 -0
  42. package/dist/types/transformer/project-bundle.d.ts +2 -1
  43. package/package.json +2 -2
@@ -16,6 +16,7 @@
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.getElementsOrder = exports.parseJATSArticle = exports.parseJATSBody = exports.parseJATSReferences = exports.parseJATSFront = void 0;
19
+ const json_schema_1 = require("@manuscripts/json-schema");
19
20
  const prosemirror_model_1 = require("prosemirror-model");
20
21
  const errors_1 = require("../../errors");
21
22
  const html_1 = require("../../lib/html");
@@ -51,9 +52,16 @@ const parseJATSFront = async (front) => {
51
52
  const title = (_a = articleMeta === null || articleMeta === void 0 ? void 0 : articleMeta.querySelector('title-group > article-title')) === null || _a === void 0 ? void 0 : _a.innerHTML;
52
53
  const subtitle = (_b = articleMeta === null || articleMeta === void 0 ? void 0 : articleMeta.querySelector('title-group > subtitle')) === null || _b === void 0 ? void 0 : _b.innerHTML;
53
54
  const runningTitle = (_c = articleMeta === null || articleMeta === void 0 ? void 0 : articleMeta.querySelector('title-group > alt-title[alt-title-type="right-running"]')) === null || _c === void 0 ? void 0 : _c.innerHTML;
54
- const manuscriptMeta = Object.assign({ title: title ? inlineContentsFromJATSTitle(title) : undefined, subtitle: subtitle ? inlineContentsFromJATSTitle(subtitle) : undefined, runningTitle: runningTitle
55
+ const manuscriptMeta = Object.assign({}, jats_front_parser_1.jatsFrontParser.parseCounts(articleMeta === null || articleMeta === void 0 ? void 0 : articleMeta.querySelector('counts')));
56
+ const titles = {
57
+ objectType: json_schema_1.ObjectTypes.Titles,
58
+ _id: (0, id_1.generateID)(json_schema_1.ObjectTypes.Titles),
59
+ title: title ? inlineContentsFromJATSTitle(title) : undefined,
60
+ subtitle: subtitle ? inlineContentsFromJATSTitle(subtitle) : undefined,
61
+ runningTitle: runningTitle
55
62
  ? inlineContentsFromJATSTitle(runningTitle)
56
- : undefined }, jats_front_parser_1.jatsFrontParser.parseCounts(articleMeta === null || articleMeta === void 0 ? void 0 : articleMeta.querySelector('counts')));
63
+ : undefined,
64
+ };
57
65
  const { affiliations, affiliationIDs } = jats_front_parser_1.jatsFrontParser.parseAffiliationNodes([
58
66
  ...front.querySelectorAll('article-meta > contrib-group > aff'),
59
67
  ]);
@@ -73,6 +81,7 @@ const parseJATSFront = async (front) => {
73
81
  const manuscript = Object.assign(Object.assign(Object.assign({}, (0, builders_1.buildManuscript)()), manuscriptMeta), history);
74
82
  return {
75
83
  models: generateModelIDs([
84
+ titles,
76
85
  manuscript,
77
86
  ...footnotes,
78
87
  ...correspondingList,
@@ -238,6 +238,7 @@ class JATSExporter {
238
238
  this.buildFront = (doi, id, links) => {
239
239
  var _a, _b, _c, _d;
240
240
  const manuscript = (0, project_bundle_1.findManuscript)(this.modelMap);
241
+ const titles = (0, project_bundle_1.findTitles)(this.modelMap);
241
242
  const front = this.document.createElement('front');
242
243
  const journalMeta = this.document.createElement('journal-meta');
243
244
  front.appendChild(journalMeta);
@@ -315,20 +316,20 @@ class JATSExporter {
315
316
  articleMeta.appendChild(link);
316
317
  }
317
318
  }
318
- if (manuscript.title) {
319
+ if (titles.title) {
319
320
  const element = this.document.createElement('article-title');
320
- this.setTitleContent(element, manuscript.title);
321
+ this.setTitleContent(element, titles.title);
321
322
  titleGroup.appendChild(element);
322
323
  }
323
- if (manuscript.subtitle) {
324
+ if (titles.subtitle) {
324
325
  const element = this.document.createElement('subtitle');
325
- this.setTitleContent(element, manuscript.subtitle);
326
+ this.setTitleContent(element, titles.subtitle);
326
327
  titleGroup.appendChild(element);
327
328
  }
328
- if (manuscript.runningTitle) {
329
+ if (titles.runningTitle) {
329
330
  const element = this.document.createElement('alt-title');
330
331
  element.setAttribute('alt-title-type', 'right-running');
331
- this.setTitleContent(element, manuscript.runningTitle);
332
+ this.setTitleContent(element, titles.runningTitle);
332
333
  titleGroup.appendChild(element);
333
334
  }
334
335
  const supplements = [...this.modelMap.values()].filter((model) => model.objectType === json_schema_1.ObjectTypes.Supplement);
@@ -598,6 +599,7 @@ class JATSExporter {
598
599
  this.createSerializer = () => {
599
600
  const getModel = (id) => id ? this.modelMap.get(id) : undefined;
600
601
  const nodes = {
602
+ title: () => '',
601
603
  affiliations_section: () => '',
602
604
  contributors_section: () => '',
603
605
  table_element_footer: () => ['table-wrap-foot', 0],
@@ -85,6 +85,7 @@ const table_element_1 = require("./nodes/table_element");
85
85
  const table_element_footer_1 = require("./nodes/table_element_footer");
86
86
  const table_row_1 = require("./nodes/table_row");
87
87
  const text_1 = require("./nodes/text");
88
+ const title_1 = require("./nodes/title");
88
89
  const toc_element_1 = require("./nodes/toc_element");
89
90
  const toc_section_1 = require("./nodes/toc_section");
90
91
  __exportStar(require("./groups"), exports);
@@ -140,6 +141,7 @@ __exportStar(require("./nodes/affiliation"), exports);
140
141
  __exportStar(require("./nodes/meta_section"), exports);
141
142
  __exportStar(require("./nodes/contributor"), exports);
142
143
  __exportStar(require("./nodes/table_element_footer"), exports);
144
+ __exportStar(require("./nodes/title"), exports);
143
145
  __exportStar(require("./nodes/affiliations_section"), exports);
144
146
  __exportStar(require("./nodes/contributors_section"), exports);
145
147
  exports.schema = new prosemirror_model_1.Schema({
@@ -216,6 +218,7 @@ exports.schema = new prosemirror_model_1.Schema({
216
218
  meta_section: meta_section_1.metaSection,
217
219
  contributor: contributor_1.contributor,
218
220
  table_element_footer: table_element_footer_1.tableElementFooter,
221
+ title: title_1.title,
219
222
  affiliations_section: affiliations_section_1.affiliationsSection,
220
223
  contributors_section: contributors_section_1.contributorsSection,
221
224
  },
@@ -18,9 +18,30 @@ exports.affiliation = {
18
18
  text: undefined,
19
19
  },
20
20
  },
21
+ dataTracked: { default: null },
21
22
  },
22
23
  group: 'block element',
23
- toDOM: () => ['span'],
24
+ parseDOM: [
25
+ {
26
+ tag: 'div.affiliation',
27
+ getAttrs: (node) => {
28
+ const dom = node;
29
+ return {
30
+ id: dom.getAttribute('id'),
31
+ };
32
+ },
33
+ },
34
+ ],
35
+ toDOM: (node) => {
36
+ const affiliationNode = node;
37
+ return [
38
+ 'div',
39
+ {
40
+ class: 'affiliation',
41
+ id: affiliationNode.attrs.id,
42
+ },
43
+ ];
44
+ },
24
45
  };
25
46
  const isAffiliationNode = (node) => node.type === node.type.schema.nodes.affiliation;
26
47
  exports.isAffiliationNode = isAffiliationNode;
@@ -4,12 +4,33 @@ exports.isAffiliationsSectionNode = exports.affiliationsSection = void 0;
4
4
  exports.affiliationsSection = {
5
5
  content: 'section_title? affiliation*',
6
6
  attrs: {
7
- id: { default: '' },
7
+ id: { default: 'META_SECTION_AFFILLIATIONS' },
8
8
  dataTracked: { default: null },
9
9
  },
10
10
  group: 'block sections',
11
11
  selectable: false,
12
- toDOM: () => ['section', 0],
12
+ parseDOM: [
13
+ {
14
+ tag: 'section.affiliations',
15
+ getAttrs: (section) => {
16
+ const dom = section;
17
+ return {
18
+ contents: dom.innerHTML,
19
+ };
20
+ },
21
+ },
22
+ ],
23
+ toDOM: (node) => {
24
+ const affiliationsSectionNode = node;
25
+ return [
26
+ 'section',
27
+ {
28
+ class: 'affiliations',
29
+ id: affiliationsSectionNode.attrs.id,
30
+ },
31
+ 0
32
+ ];
33
+ },
13
34
  };
14
35
  const isAffiliationsSectionNode = (node) => node.type === node.type.schema.nodes.affiliations_section;
15
36
  exports.isAffiliationsSectionNode = isAffiliationsSectionNode;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isContributorNode = exports.contributor = void 0;
4
4
  exports.contributor = {
5
+ content: 'inline*',
5
6
  attrs: {
6
7
  id: { default: '' },
7
8
  role: { default: '' },
@@ -14,9 +15,20 @@ exports.contributor = {
14
15
  isCorresponding: { default: undefined },
15
16
  ORCIDIdentifier: { default: undefined },
16
17
  priority: { default: undefined },
18
+ dataTracked: { default: null },
19
+ contents: { default: '' },
17
20
  },
18
21
  group: 'block element',
19
- toDOM: () => ['span'],
22
+ toDOM: (node) => {
23
+ const contributorNode = node;
24
+ return [
25
+ 'div',
26
+ {
27
+ class: 'contributor',
28
+ id: contributorNode.attrs.id,
29
+ },
30
+ ];
31
+ },
20
32
  };
21
33
  const isContributorNode = (node) => node.type === node.type.schema.nodes.contributor;
22
34
  exports.isContributorNode = isContributorNode;
@@ -0,0 +1,49 @@
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.contributorsElement = void 0;
19
+ exports.contributorsElement = {
20
+ content: 'contributor*',
21
+ attrs: {
22
+ id: { default: '' },
23
+ contents: { default: '' },
24
+ dataTracked: { default: null },
25
+ },
26
+ group: 'block element',
27
+ selectable: false,
28
+ parseDOM: [
29
+ {
30
+ tag: 'div.manuscript-contributors',
31
+ getAttrs: () => {
32
+ return {
33
+ contents: '',
34
+ };
35
+ },
36
+ },
37
+ ],
38
+ toDOM: (node) => {
39
+ const contributorsElementNode = node;
40
+ return [
41
+ 'div',
42
+ {
43
+ class: 'manuscript-contributors',
44
+ id: contributorsElementNode.attrs.id,
45
+ },
46
+ 0,
47
+ ];
48
+ },
49
+ };
@@ -4,12 +4,33 @@ exports.isContributorsSectionNode = exports.contributorsSection = void 0;
4
4
  exports.contributorsSection = {
5
5
  content: 'section_title? contributor*',
6
6
  attrs: {
7
- id: { default: '' },
7
+ id: { default: 'META_SECTION_CONTRIBUTORS' },
8
8
  dataTracked: { default: null },
9
+ contents: { default: '' },
9
10
  },
10
11
  group: 'block sections',
11
12
  selectable: false,
12
- toDOM: () => ['section', 0],
13
+ parseDOM: [
14
+ {
15
+ tag: 'section.contributors',
16
+ getAttrs: () => {
17
+ return {
18
+ contents: '',
19
+ };
20
+ },
21
+ },
22
+ ],
23
+ toDOM: (node) => {
24
+ const contributorsSectionNode = node;
25
+ return [
26
+ 'section',
27
+ {
28
+ class: 'contributors',
29
+ id: contributorsSectionNode.attrs.id,
30
+ },
31
+ 0,
32
+ ];
33
+ },
13
34
  };
14
35
  const isContributorsSectionNode = (node) => node.type === node.type.schema.nodes.contributors_section;
15
36
  exports.isContributorsSectionNode = isContributorsSectionNode;
@@ -17,7 +17,7 @@
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.manuscript = void 0;
19
19
  exports.manuscript = {
20
- content: '(section | sections)+ meta_section',
20
+ content: 'title* (section | sections)+ meta_section',
21
21
  attrs: {
22
22
  id: { default: '' },
23
23
  },
@@ -0,0 +1,29 @@
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.title = void 0;
19
+ exports.title = {
20
+ content: 'text*',
21
+ marks: 'italic smallcaps subscript superscript tracked_insert tracked_delete',
22
+ attrs: {
23
+ id: { default: '' },
24
+ dataTracked: { default: null },
25
+ },
26
+ group: 'block element',
27
+ parseDOM: [{ tag: 'div' }],
28
+ toDOM: () => ['div', 0],
29
+ };
@@ -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.buildElementsOrder = exports.auxiliaryObjectTypes = exports.buildStatusLabel = exports.buildJournal = exports.buildAttribution = exports.buildInlineStyle = exports.buildContributorRole = exports.buildContribution = exports.buildHighlightMarker = exports.buildHighlight = exports.buildColor = exports.buildParagraph = exports.buildSection = exports.buildCorresp = exports.buildFootnotesOrder = exports.buildFootnote = exports.buildInlineMathFragment = exports.buildValidation = exports.buildNote = exports.buildComment = exports.buildUserProfileAffiliation = exports.buildSupplementaryMaterial = exports.buildAffiliation = exports.buildFigure = exports.buildLibraryCollection = exports.buildManuscriptKeyword = exports.buildKeywordGroup = exports.buildKeyword = exports.buildCitation = exports.buildEmbeddedCitationItem = exports.buildAuxiliaryObjectReference = exports.buildBibliographicDate = exports.buildBibliographicName = exports.buildBibliographyItem = exports.buildContributor = exports.buildManuscript = exports.buildProject = exports.DEFAULT_PAGE_LAYOUT = exports.DEFAULT_BUNDLE = void 0;
21
+ exports.buildTitles = exports.buildElementsOrder = exports.auxiliaryObjectTypes = exports.buildStatusLabel = exports.buildJournal = exports.buildAttribution = exports.buildInlineStyle = exports.buildContributorRole = exports.buildContribution = exports.buildHighlightMarker = exports.buildHighlight = exports.buildColor = exports.buildParagraph = exports.buildSection = exports.buildCorresp = exports.buildFootnotesOrder = exports.buildFootnote = exports.buildInlineMathFragment = exports.buildValidation = exports.buildNote = exports.buildComment = exports.buildUserProfileAffiliation = exports.buildSupplementaryMaterial = exports.buildAffiliation = exports.buildFigure = exports.buildLibraryCollection = exports.buildManuscriptKeyword = exports.buildKeywordGroup = exports.buildKeyword = exports.buildCitation = exports.buildEmbeddedCitationItem = exports.buildAuxiliaryObjectReference = exports.buildBibliographicDate = exports.buildBibliographicName = exports.buildBibliographyItem = exports.buildContributor = exports.buildManuscript = exports.buildProject = exports.DEFAULT_PAGE_LAYOUT = exports.DEFAULT_BUNDLE = 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");
@@ -35,10 +35,9 @@ const buildProject = (owner) => ({
35
35
  title: '',
36
36
  });
37
37
  exports.buildProject = buildProject;
38
- const buildManuscript = (title = '') => ({
38
+ const buildManuscript = () => ({
39
39
  _id: (0, id_1.generateID)(json_schema_1.ObjectTypes.Manuscript),
40
40
  objectType: json_schema_1.ObjectTypes.Manuscript,
41
- title,
42
41
  });
43
42
  exports.buildManuscript = buildManuscript;
44
43
  const buildContributor = (bibliographicName, role = 'author', priority = 0, userID, invitationID) => ({
@@ -291,3 +290,9 @@ const buildElementsOrder = (elementType) => ({
291
290
  elements: [],
292
291
  });
293
292
  exports.buildElementsOrder = buildElementsOrder;
293
+ const buildTitles = (title) => ({
294
+ _id: (0, id_1.generateID)(json_schema_1.ObjectTypes.Titles),
295
+ objectType: json_schema_1.ObjectTypes.Titles,
296
+ title: title || '',
297
+ });
298
+ exports.buildTitles = buildTitles;
@@ -35,6 +35,7 @@ const debug_1 = __importDefault(require("debug"));
35
35
  const prosemirror_model_1 = require("prosemirror-model");
36
36
  const errors_1 = require("../errors");
37
37
  const schema_1 = require("../schema");
38
+ const builders_1 = require("./builders");
38
39
  const highlight_markers_1 = require("./highlight-markers");
39
40
  const id_1 = require("./id");
40
41
  const object_types_1 = require("./object-types");
@@ -115,6 +116,11 @@ class Decoder {
115
116
  rootSectionNodes.unshift(node);
116
117
  }
117
118
  }
119
+ createTitleNode() {
120
+ const titles = (0, exports.getModelsByType)(this.modelMap, json_schema_1.ObjectTypes.Titles)[0] ||
121
+ (0, builders_1.buildTitles)();
122
+ return this.decode(titles);
123
+ }
118
124
  createRootSectionNodes() {
119
125
  let rootSections = getSections(this.modelMap).filter((section) => !section.path || section.path.length <= 1);
120
126
  rootSections = this.addGeneratedLabels(rootSections);
@@ -147,6 +153,14 @@ class Decoder {
147
153
  constructor(modelMap, allowMissingElements = false) {
148
154
  this.comments = new Map();
149
155
  this.creators = {
156
+ [json_schema_1.ObjectTypes.Titles]: (data) => {
157
+ const model = data;
158
+ return this.parseContents(model.title, 'div', undefined, {
159
+ topNode: schema_1.schema.nodes.title.create({
160
+ id: model._id,
161
+ }),
162
+ });
163
+ },
150
164
  [json_schema_1.ObjectTypes.BibliographyElement]: (data) => {
151
165
  var _a;
152
166
  const model = data;
@@ -603,7 +617,7 @@ class Decoder {
603
617
  email: model.email,
604
618
  department: model.department,
605
619
  priority: model.priority,
606
- });
620
+ }, schema_1.schema.text('_'));
607
621
  },
608
622
  [json_schema_1.ObjectTypes.Contributor]: (data) => {
609
623
  const model = data;
@@ -619,7 +633,7 @@ class Decoder {
619
633
  footnote: model.footnote,
620
634
  corresp: model.corresp,
621
635
  priority: model.priority,
622
- });
636
+ }, schema_1.schema.text('_'));
623
637
  },
624
638
  };
625
639
  this.decode = (model) => {
@@ -631,9 +645,14 @@ class Decoder {
631
645
  };
632
646
  this.getModel = (id) => this.modelMap.get(id);
633
647
  this.createArticleNode = (manuscriptID) => {
648
+ const titlesNode = this.createTitleNode();
634
649
  const rootSectionNodes = this.createRootSectionNodes();
635
650
  const metaSectionNode = this.createMetaSectionNode();
636
- const contents = [...rootSectionNodes, metaSectionNode];
651
+ const contents = [
652
+ titlesNode,
653
+ ...rootSectionNodes,
654
+ metaSectionNode,
655
+ ];
637
656
  return schema_1.schema.nodes.manuscript.create({
638
657
  id: manuscriptID || this.getManuscriptID(),
639
658
  }, contents);
@@ -263,6 +263,12 @@ function figureElementEncoder(node) {
263
263
  };
264
264
  }
265
265
  const encoders = {
266
+ title: (node) => ({
267
+ title: (0, exports.inlineContents)(node),
268
+ subtitle: node.attrs.subtitle,
269
+ runningTitle: node.attrs.runningTitle,
270
+ _id: node.attrs._id,
271
+ }),
266
272
  bibliography_element: (node) => ({
267
273
  elementType: 'div',
268
274
  contents: '',
@@ -152,6 +152,7 @@ class HTMLTransformer {
152
152
  this.buildFront = () => {
153
153
  const manuscript = (0, project_bundle_1.findManuscript)(this.modelMap);
154
154
  const journal = (0, project_bundle_1.findJournal)(this.modelMap);
155
+ const titles = (0, project_bundle_1.findTitles)(this.modelMap);
155
156
  if (!manuscript) {
156
157
  throw new Error('Manuscript not found in project modelMap');
157
158
  }
@@ -170,14 +171,14 @@ class HTMLTransformer {
170
171
  }
171
172
  const articleMeta = this.document.createElement('div');
172
173
  front.appendChild(articleMeta);
173
- const articleTitle = this.document.createElement('h1');
174
- if (manuscript.title) {
175
- articleTitle.innerHTML = manuscript.title;
174
+ const title = this.document.createElement('h1');
175
+ if (titles.title) {
176
+ title.innerHTML = titles.title;
176
177
  }
177
178
  if (journal === null || journal === void 0 ? void 0 : journal.title) {
178
- articleTitle.setAttribute('data-journal', journal.title);
179
+ title.setAttribute('data-journal', journal.title);
179
180
  }
180
- articleMeta.appendChild(articleTitle);
181
+ articleMeta.appendChild(title);
181
182
  if (manuscript.DOI) {
182
183
  const articleID = this.document.createElement('article-id');
183
184
  articleID.setAttribute('pub-id-type', 'doi');
@@ -32,7 +32,7 @@ const textSnippet = (node, max = 100) => {
32
32
  text += ' ';
33
33
  }
34
34
  });
35
- return text.substr(0, max);
35
+ return text.substring(0, max);
36
36
  };
37
37
  const snippetOfNodeType = (node, nodeType) => {
38
38
  for (const child of (0, utils_1.iterateChildren)(node, true)) {
@@ -43,8 +43,10 @@ const snippetOfNodeType = (node, nodeType) => {
43
43
  return null;
44
44
  };
45
45
  const nodeTitle = (node) => {
46
- const nodes = node.type.schema.nodes;
46
+ const nodes = schema_1.schema.nodes;
47
47
  switch (node.type) {
48
+ case nodes.manuscript:
49
+ return snippetOfNodeType(node, nodes.title);
48
50
  case nodes.section:
49
51
  case nodes.bibliography_section:
50
52
  case nodes.footnotes_section:
@@ -72,9 +74,9 @@ const nodeTitle = (node) => {
72
74
  };
73
75
  exports.nodeTitle = nodeTitle;
74
76
  const nodeTitlePlaceholder = (nodeType) => {
75
- const nodes = nodeType.schema.nodes;
77
+ const nodes = schema_1.schema.nodes;
76
78
  switch (nodeType) {
77
- case nodes.title:
79
+ case nodes.manuscript:
78
80
  return 'Untitled Manuscript';
79
81
  case nodes.section:
80
82
  return 'Untitled Section';
@@ -57,6 +57,7 @@ exports.nodeTypesMap = new Map([
57
57
  [schema_1.schema.nodes.affiliation, json_schema_1.ObjectTypes.Affiliation],
58
58
  [schema_1.schema.nodes.contributor, json_schema_1.ObjectTypes.Contributor],
59
59
  [schema_1.schema.nodes.table_element_footer, json_schema_1.ObjectTypes.TableElementFooter],
60
+ [schema_1.schema.nodes.title, json_schema_1.ObjectTypes.Titles],
60
61
  [schema_1.schema.nodes.contributors_section, json_schema_1.ObjectTypes.Section],
61
62
  [schema_1.schema.nodes.affiliations_section, json_schema_1.ObjectTypes.Section],
62
63
  ]);
@@ -15,7 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.findManuscriptById = exports.findManuscriptModelByType = exports.findJournal = exports.findManuscript = exports.parseProjectBundle = void 0;
18
+ exports.findTitles = exports.findManuscriptById = exports.findManuscriptModelByType = exports.findJournal = exports.findManuscript = exports.parseProjectBundle = void 0;
19
19
  const json_schema_1 = require("@manuscripts/json-schema");
20
20
  const decode_1 = require("./decode");
21
21
  const object_types_1 = require("./object-types");
@@ -71,3 +71,24 @@ const findManuscriptById = (modelMap, manuscriptID) => {
71
71
  throw new Error(`There is no manuscript found for the following _id (${manuscriptID})`);
72
72
  };
73
73
  exports.findManuscriptById = findManuscriptById;
74
+ const isTitle = (0, object_types_1.hasObjectType)(json_schema_1.ObjectTypes.Titles);
75
+ const findTitles = (modelMap) => {
76
+ for (const model of modelMap.values()) {
77
+ if (isTitle(model)) {
78
+ return model;
79
+ }
80
+ }
81
+ const defaultTitle = {
82
+ _id: 'MPTitles:8EB79C14-9F61-483A-902F-A0B8EF5973C1',
83
+ createdAt: 1538472121.690101,
84
+ updatedAt: 1538472121.690101,
85
+ objectType: 'MPTitles',
86
+ title: 'main title',
87
+ subtitle: 'subtitle',
88
+ runningTitle: 'running title',
89
+ manuscriptID: 'MPManuscript:E3830344-E77B-42BA-BD77-3E95489712A0',
90
+ containerID: 'MPProject:1',
91
+ };
92
+ return defaultTitle;
93
+ };
94
+ exports.findTitles = findTitles;
@@ -13,6 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+ import { ObjectTypes, } from '@manuscripts/json-schema';
16
17
  import { DOMParser } from 'prosemirror-model';
17
18
  import { InvalidInput } from '../../errors';
18
19
  import { nodeFromHTML } from '../../lib/html';
@@ -48,9 +49,16 @@ export const parseJATSFront = async (front) => {
48
49
  const title = (_a = articleMeta === null || articleMeta === void 0 ? void 0 : articleMeta.querySelector('title-group > article-title')) === null || _a === void 0 ? void 0 : _a.innerHTML;
49
50
  const subtitle = (_b = articleMeta === null || articleMeta === void 0 ? void 0 : articleMeta.querySelector('title-group > subtitle')) === null || _b === void 0 ? void 0 : _b.innerHTML;
50
51
  const runningTitle = (_c = articleMeta === null || articleMeta === void 0 ? void 0 : articleMeta.querySelector('title-group > alt-title[alt-title-type="right-running"]')) === null || _c === void 0 ? void 0 : _c.innerHTML;
51
- const manuscriptMeta = Object.assign({ title: title ? inlineContentsFromJATSTitle(title) : undefined, subtitle: subtitle ? inlineContentsFromJATSTitle(subtitle) : undefined, runningTitle: runningTitle
52
+ const manuscriptMeta = Object.assign({}, jatsFrontParser.parseCounts(articleMeta === null || articleMeta === void 0 ? void 0 : articleMeta.querySelector('counts')));
53
+ const titles = {
54
+ objectType: ObjectTypes.Titles,
55
+ _id: generateID(ObjectTypes.Titles),
56
+ title: title ? inlineContentsFromJATSTitle(title) : undefined,
57
+ subtitle: subtitle ? inlineContentsFromJATSTitle(subtitle) : undefined,
58
+ runningTitle: runningTitle
52
59
  ? inlineContentsFromJATSTitle(runningTitle)
53
- : undefined }, jatsFrontParser.parseCounts(articleMeta === null || articleMeta === void 0 ? void 0 : articleMeta.querySelector('counts')));
60
+ : undefined,
61
+ };
54
62
  const { affiliations, affiliationIDs } = jatsFrontParser.parseAffiliationNodes([
55
63
  ...front.querySelectorAll('article-meta > contrib-group > aff'),
56
64
  ]);
@@ -70,6 +78,7 @@ export const parseJATSFront = async (front) => {
70
78
  const manuscript = Object.assign(Object.assign(Object.assign({}, buildManuscript()), manuscriptMeta), history);
71
79
  return {
72
80
  models: generateModelIDs([
81
+ titles,
73
82
  manuscript,
74
83
  ...footnotes,
75
84
  ...correspondingList,
@@ -25,7 +25,7 @@ import { generateAttachmentFilename } from '../transformer/filename';
25
25
  import { buildTargets } from '../transformer/labels';
26
26
  import { isExecutableNodeType, isNodeType } from '../transformer/node-types';
27
27
  import { hasObjectType } from '../transformer/object-types';
28
- import { findManuscript, findManuscriptById, } from '../transformer/project-bundle';
28
+ import { findManuscript, findManuscriptById, findTitles, } from '../transformer/project-bundle';
29
29
  import { chooseJatsFnType, chooseSecType, } from '../transformer/section-category';
30
30
  import { selectVersionIds } from './jats-versions';
31
31
  const warn = debug('manuscripts-transform');
@@ -231,6 +231,7 @@ export class JATSExporter {
231
231
  this.buildFront = (doi, id, links) => {
232
232
  var _a, _b, _c, _d;
233
233
  const manuscript = findManuscript(this.modelMap);
234
+ const titles = findTitles(this.modelMap);
234
235
  const front = this.document.createElement('front');
235
236
  const journalMeta = this.document.createElement('journal-meta');
236
237
  front.appendChild(journalMeta);
@@ -308,20 +309,20 @@ export class JATSExporter {
308
309
  articleMeta.appendChild(link);
309
310
  }
310
311
  }
311
- if (manuscript.title) {
312
+ if (titles.title) {
312
313
  const element = this.document.createElement('article-title');
313
- this.setTitleContent(element, manuscript.title);
314
+ this.setTitleContent(element, titles.title);
314
315
  titleGroup.appendChild(element);
315
316
  }
316
- if (manuscript.subtitle) {
317
+ if (titles.subtitle) {
317
318
  const element = this.document.createElement('subtitle');
318
- this.setTitleContent(element, manuscript.subtitle);
319
+ this.setTitleContent(element, titles.subtitle);
319
320
  titleGroup.appendChild(element);
320
321
  }
321
- if (manuscript.runningTitle) {
322
+ if (titles.runningTitle) {
322
323
  const element = this.document.createElement('alt-title');
323
324
  element.setAttribute('alt-title-type', 'right-running');
324
- this.setTitleContent(element, manuscript.runningTitle);
325
+ this.setTitleContent(element, titles.runningTitle);
325
326
  titleGroup.appendChild(element);
326
327
  }
327
328
  const supplements = [...this.modelMap.values()].filter((model) => model.objectType === ObjectTypes.Supplement);
@@ -591,6 +592,7 @@ export class JATSExporter {
591
592
  this.createSerializer = () => {
592
593
  const getModel = (id) => id ? this.modelMap.get(id) : undefined;
593
594
  const nodes = {
595
+ title: () => '',
594
596
  affiliations_section: () => '',
595
597
  contributors_section: () => '',
596
598
  table_element_footer: () => ['table-wrap-foot', 0],