@manuscripts/transform 2.0.4 → 2.1.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 (32) hide show
  1. package/dist/cjs/jats/importer/jats-body-dom-parser.js +20 -1
  2. package/dist/cjs/jats/importer/jats-body-transformations.js +14 -0
  3. package/dist/cjs/jats/importer/jats-front-parser.js +0 -19
  4. package/dist/cjs/jats/importer/parse-jats-article.js +1 -4
  5. package/dist/cjs/jats/jats-exporter.js +2 -0
  6. package/dist/cjs/schema/index.js +6 -0
  7. package/dist/cjs/schema/nodes/manuscript.js +1 -1
  8. package/dist/cjs/schema/nodes/supplement.js +63 -0
  9. package/dist/cjs/schema/nodes/supplements.js +45 -0
  10. package/dist/cjs/transformer/decode.js +23 -0
  11. package/dist/cjs/transformer/encode.js +8 -0
  12. package/dist/cjs/transformer/node-types.js +1 -0
  13. package/dist/es/jats/importer/jats-body-dom-parser.js +20 -1
  14. package/dist/es/jats/importer/jats-body-transformations.js +14 -0
  15. package/dist/es/jats/importer/jats-front-parser.js +1 -20
  16. package/dist/es/jats/importer/parse-jats-article.js +1 -4
  17. package/dist/es/jats/jats-exporter.js +2 -0
  18. package/dist/es/schema/index.js +6 -0
  19. package/dist/es/schema/nodes/manuscript.js +1 -1
  20. package/dist/es/schema/nodes/supplement.js +60 -0
  21. package/dist/es/schema/nodes/supplements.js +42 -0
  22. package/dist/es/transformer/decode.js +23 -0
  23. package/dist/es/transformer/encode.js +8 -0
  24. package/dist/es/transformer/node-types.js +1 -0
  25. package/dist/types/jats/importer/jats-body-transformations.d.ts +1 -0
  26. package/dist/types/jats/importer/jats-front-parser.d.ts +0 -1
  27. package/dist/types/schema/index.d.ts +2 -0
  28. package/dist/types/schema/nodes/supplement.d.ts +29 -0
  29. package/dist/types/schema/nodes/supplements.d.ts +25 -0
  30. package/dist/types/schema/types.d.ts +1 -1
  31. package/dist/types/transformer/decode.d.ts +1 -0
  32. package/package.json +2 -2
@@ -430,6 +430,25 @@ const nodes = [
430
430
  tag: 'sec[sec-type="keywords"]',
431
431
  node: 'keywords',
432
432
  },
433
+ {
434
+ tag: 'sec[sec-type="supplementary-material"]',
435
+ node: 'supplements',
436
+ },
437
+ {
438
+ tag: 'supplementary-material',
439
+ node: 'supplement',
440
+ getAttrs: (node) => {
441
+ var _a;
442
+ const element = node;
443
+ return {
444
+ id: element.getAttribute('id'),
445
+ href: element.getAttributeNS(XLINK_NAMESPACE, 'href'),
446
+ mimeType: element.getAttribute('mimetype'),
447
+ mimeSubType: element.getAttribute('mime-subtype'),
448
+ title: (_a = element.querySelector('title')) === null || _a === void 0 ? void 0 : _a.textContent,
449
+ };
450
+ },
451
+ },
433
452
  {
434
453
  tag: 'sec[sec-type="abstracts"]',
435
454
  node: 'abstracts',
@@ -526,7 +545,7 @@ const nodes = [
526
545
  {
527
546
  tag: 'title',
528
547
  node: 'section_title',
529
- context: 'section/|footnotes_section/|bibliography_section/|keywords/',
548
+ context: 'section/|footnotes_section/|bibliography_section/|keywords/|supplements/',
530
549
  },
531
550
  {
532
551
  tag: 'title',
@@ -287,4 +287,18 @@ exports.jatsBodyTransformations = {
287
287
  body.prepend(section);
288
288
  }
289
289
  },
290
+ createSuppleMaterials(document, body, createElement) {
291
+ const suppleMaterials = [
292
+ ...document.querySelectorAll('article-meta > supplementary-material'),
293
+ ];
294
+ if (suppleMaterials.length > 0) {
295
+ const section = createElement('sec');
296
+ section.setAttribute('sec-type', 'supplementary-material');
297
+ const title = createElement('title');
298
+ title.textContent = 'supplementary-material';
299
+ section.append(title);
300
+ section.append(...suppleMaterials);
301
+ body.prepend(section);
302
+ }
303
+ },
290
304
  };
@@ -128,25 +128,6 @@ exports.jatsFrontParser = {
128
128
  }
129
129
  return history;
130
130
  },
131
- parseSupplements(elements) {
132
- var _a, _b, _c, _d;
133
- if (!(elements === null || elements === void 0 ? void 0 : elements.length)) {
134
- return [];
135
- }
136
- const supplements = [];
137
- for (const element of elements) {
138
- const title = (_a = (0, utils_1.getTrimmedTextContent)(element, 'caption > title')) !== null && _a !== void 0 ? _a : '';
139
- const href = (_b = element.getAttributeNS(XLINK_NAMESPACE, 'href')) !== null && _b !== void 0 ? _b : '';
140
- const supplement = (0, transformer_1.buildSupplementaryMaterial)(title, href);
141
- const mimeType = (_c = element.getAttribute('mimetype')) !== null && _c !== void 0 ? _c : '';
142
- const mimeSubtype = (_d = element.getAttribute('mime-subtype')) !== null && _d !== void 0 ? _d : '';
143
- if (mimeType && mimeSubtype) {
144
- supplement.MIME = [mimeType, mimeSubtype].join('/');
145
- }
146
- supplements.push(supplement);
147
- }
148
- return supplements;
149
- },
150
131
  parseAffiliations(elements) {
151
132
  const affiliationIDs = new Map();
152
133
  const affiliations = elements.map((element, priority) => {
@@ -43,9 +43,6 @@ const parseJATSFront = (doc, front) => {
43
43
  const authors = jats_front_parser_1.jatsFrontParser.parseContributors([
44
44
  ...front.querySelectorAll('article-meta > contrib-group > contrib[contrib-type="author"]'),
45
45
  ], affiliationIDs, footnoteIDs, correspondingIDs);
46
- const supplements = jats_front_parser_1.jatsFrontParser.parseSupplements([
47
- ...front.querySelectorAll('article-meta > supplementary-material'),
48
- ]);
49
46
  const history = jats_front_parser_1.jatsFrontParser.parseDates(front.querySelector('article-meta > history'));
50
47
  const counts = jats_front_parser_1.jatsFrontParser.parseCounts(front.querySelector('article-meta counts'));
51
48
  const manuscript = Object.assign(Object.assign(Object.assign({}, (0, builders_1.buildManuscript)()), counts), history);
@@ -57,7 +54,6 @@ const parseJATSFront = (doc, front) => {
57
54
  ...authors,
58
55
  ...affiliations,
59
56
  ...correspondingList,
60
- ...supplements,
61
57
  ]);
62
58
  };
63
59
  exports.parseJATSFront = parseJATSFront;
@@ -69,6 +65,7 @@ const parseJATSBody = (doc, body, references) => {
69
65
  jats_body_transformations_1.jatsBodyTransformations.createBody(doc, body, createElement);
70
66
  jats_body_transformations_1.jatsBodyTransformations.createAbstracts(doc, body, createElement);
71
67
  jats_body_transformations_1.jatsBodyTransformations.createBackmatter(doc, body, createElement);
68
+ jats_body_transformations_1.jatsBodyTransformations.createSuppleMaterials(doc, body, createElement);
72
69
  jats_body_transformations_1.jatsBodyTransformations.createKeywords(doc, body, createElement);
73
70
  const node = jats_body_dom_parser_1.jatsBodyDOMParser.parse(body).firstChild;
74
71
  if (!node) {
@@ -628,6 +628,8 @@ class JATSExporter {
628
628
  body: () => ['body', 0],
629
629
  abstracts: () => ['abstract', 0],
630
630
  backmatter: () => ['backmatter', 0],
631
+ supplement: () => '',
632
+ supplements: () => '',
631
633
  bibliography_section: (node) => [
632
634
  'ref-list',
633
635
  { id: normalizeID(node.attrs.id) },
@@ -81,6 +81,8 @@ const pullquote_element_1 = require("./nodes/pullquote_element");
81
81
  const section_1 = require("./nodes/section");
82
82
  const section_label_1 = require("./nodes/section_label");
83
83
  const section_title_1 = require("./nodes/section_title");
84
+ const supplement_1 = require("./nodes/supplement");
85
+ const supplements_1 = require("./nodes/supplements");
84
86
  const table_1 = require("./nodes/table");
85
87
  const table_col_1 = require("./nodes/table_col");
86
88
  const table_element_1 = require("./nodes/table_element");
@@ -145,6 +147,8 @@ __exportStar(require("./nodes/table_element_footer"), exports);
145
147
  __exportStar(require("./nodes/title"), exports);
146
148
  __exportStar(require("./nodes/affiliations"), exports);
147
149
  __exportStar(require("./nodes/contributors"), exports);
150
+ __exportStar(require("./nodes/supplement"), exports);
151
+ __exportStar(require("./nodes/supplements"), exports);
148
152
  exports.schema = new prosemirror_model_1.Schema({
149
153
  marks: {
150
154
  bold: marks_1.bold,
@@ -224,5 +228,7 @@ exports.schema = new prosemirror_model_1.Schema({
224
228
  title: title_1.title,
225
229
  affiliations: affiliations_1.affiliations,
226
230
  contributors: contributors_1.contributors,
231
+ supplements: supplements_1.supplements,
232
+ supplement: supplement_1.supplement,
227
233
  },
228
234
  });
@@ -17,7 +17,7 @@
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.isManuscriptNode = exports.manuscript = void 0;
19
19
  exports.manuscript = {
20
- content: 'title? contributors? affiliations? keywords? abstracts body backmatter comments',
20
+ content: 'title? contributors? affiliations? keywords? supplements? abstracts body backmatter comments',
21
21
  attrs: {
22
22
  id: { default: '' },
23
23
  },
@@ -0,0 +1,63 @@
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.supplement = void 0;
19
+ exports.supplement = {
20
+ attrs: {
21
+ id: { default: '' },
22
+ href: { default: '' },
23
+ mimeType: { default: '' },
24
+ mimeSubType: { default: '' },
25
+ title: { default: '' },
26
+ dataTracked: { default: null },
27
+ },
28
+ group: 'block',
29
+ parseDOM: [
30
+ {
31
+ tag: 'div.supplement',
32
+ getAttrs: (dom) => {
33
+ const el = dom;
34
+ const id = el.getAttribute('id');
35
+ const href = el.getAttribute('href');
36
+ const mimeType = el.getAttribute('mimeType');
37
+ const mimeSubType = el.getAttribute('mimeSubType');
38
+ const title = el.textContent;
39
+ return {
40
+ id,
41
+ href,
42
+ mimeType,
43
+ mimeSubType,
44
+ title,
45
+ };
46
+ },
47
+ },
48
+ ],
49
+ toDOM: (node) => {
50
+ const supplement = node;
51
+ return [
52
+ 'div',
53
+ {
54
+ id: supplement.attrs.id,
55
+ class: 'Supplement',
56
+ href: node.attrs.href,
57
+ mimeType: node.attrs.mimeType,
58
+ mimeSubType: node.attrs.mimeSubType,
59
+ title: node.attrs.title,
60
+ },
61
+ ];
62
+ },
63
+ };
@@ -0,0 +1,45 @@
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.supplements = void 0;
19
+ exports.supplements = {
20
+ content: 'section_title supplement*',
21
+ attrs: {
22
+ id: { default: '' },
23
+ dataTracked: { default: null },
24
+ },
25
+ group: 'block',
26
+ selectable: false,
27
+ parseDOM: [
28
+ {
29
+ tag: 'div.supplements',
30
+ },
31
+ ],
32
+ toDOM: (node) => {
33
+ const supplements = node;
34
+ return [
35
+ 'div',
36
+ {
37
+ id: supplements.attrs.id,
38
+ class: 'supplements',
39
+ spellcheck: 'false',
40
+ contenteditable: false,
41
+ },
42
+ 0,
43
+ ];
44
+ },
45
+ };
@@ -64,6 +64,7 @@ const getSections = (modelMap) => (0, exports.getModelsByType)(modelMap, json_sc
64
64
  const getAffiliations = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.Affiliation);
65
65
  const getContributors = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.Contributor);
66
66
  const getKeywordElements = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.KeywordsElement);
67
+ const getSupplements = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.Supplement);
67
68
  const getKeywordGroups = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.KeywordGroup);
68
69
  const getKeywords = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.Keyword);
69
70
  const getTitles = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.Titles)[0];
@@ -102,6 +103,15 @@ class Decoder {
102
103
  ...elements,
103
104
  ]);
104
105
  }
106
+ createSupplementsNode() {
107
+ const elements = getSupplements(this.modelMap)
108
+ .map((e) => this.decode(e))
109
+ .filter(Boolean);
110
+ return schema_1.schema.nodes.supplements.createAndFill({}, [
111
+ schema_1.schema.nodes.section_title.create({}, schema_1.schema.text('SupplementaryMaterials')),
112
+ ...elements,
113
+ ]);
114
+ }
105
115
  createCommentsNode() {
106
116
  return schema_1.schema.nodes.comments.createAndFill({}, [
107
117
  ...this.comments.values(),
@@ -639,6 +649,17 @@ class Decoder {
639
649
  priority: model.priority,
640
650
  }, schema_1.schema.text('_'));
641
651
  },
652
+ [json_schema_1.ObjectTypes.Supplement]: (data) => {
653
+ var _a, _b;
654
+ const model = data;
655
+ return schema_1.schema.nodes.supplement.create({
656
+ id: model._id,
657
+ href: model.href,
658
+ mimeType: (_a = model.MIME) === null || _a === void 0 ? void 0 : _a.split('/')[0],
659
+ mimeSubType: (_b = model.MIME) === null || _b === void 0 ? void 0 : _b.split('/')[1],
660
+ title: model.title,
661
+ });
662
+ },
642
663
  };
643
664
  this.decode = (model) => {
644
665
  if (!this.creators[model.objectType]) {
@@ -653,6 +674,7 @@ class Decoder {
653
674
  const contributors = this.createContributorsNode();
654
675
  const affiliations = this.createAffiliationsNode();
655
676
  const keywords = this.createKeywordsNode();
677
+ const suppl = this.createSupplementsNode();
656
678
  const { abstracts, body, backmatter } = this.createContentSections();
657
679
  const comments = this.createCommentsNode();
658
680
  const contents = [
@@ -660,6 +682,7 @@ class Decoder {
660
682
  contributors,
661
683
  affiliations,
662
684
  keywords,
685
+ suppl,
663
686
  abstracts,
664
687
  body,
665
688
  backmatter,
@@ -525,6 +525,13 @@ const encoders = {
525
525
  corresp: node.attrs.corresp,
526
526
  priority: node.attrs.priority,
527
527
  }),
528
+ supplement: (node) => ({
529
+ href: node.attrs.href,
530
+ title: node.attrs.title,
531
+ MIME: node.attrs.mimeType && node.attrs.mimeSubType
532
+ ? [node.attrs.mimeType, node.attrs.mimeSubType].join('/')
533
+ : '',
534
+ }),
528
535
  };
529
536
  const modelData = (node, parent, path, priority) => {
530
537
  const encoder = encoders[node.type.name];
@@ -553,6 +560,7 @@ const containerTypes = [
553
560
  schema_1.schema.nodes.contributors,
554
561
  schema_1.schema.nodes.affiliations,
555
562
  schema_1.schema.nodes.keywords,
563
+ schema_1.schema.nodes.supplements,
556
564
  schema_1.schema.nodes.abstracts,
557
565
  schema_1.schema.nodes.body,
558
566
  schema_1.schema.nodes.backmatter,
@@ -61,6 +61,7 @@ exports.nodeTypesMap = new Map([
61
61
  [schema_1.schema.nodes.contributors, json_schema_1.ObjectTypes.Section],
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
+ [schema_1.schema.nodes.supplement, json_schema_1.ObjectTypes.Supplement],
64
65
  ]);
65
66
  const isExecutableNodeType = (type) => (0, schema_1.hasGroup)(type, schema_1.GROUP_EXECUTABLE);
66
67
  exports.isExecutableNodeType = isExecutableNodeType;
@@ -424,6 +424,25 @@ const nodes = [
424
424
  tag: 'sec[sec-type="keywords"]',
425
425
  node: 'keywords',
426
426
  },
427
+ {
428
+ tag: 'sec[sec-type="supplementary-material"]',
429
+ node: 'supplements',
430
+ },
431
+ {
432
+ tag: 'supplementary-material',
433
+ node: 'supplement',
434
+ getAttrs: (node) => {
435
+ var _a;
436
+ const element = node;
437
+ return {
438
+ id: element.getAttribute('id'),
439
+ href: element.getAttributeNS(XLINK_NAMESPACE, 'href'),
440
+ mimeType: element.getAttribute('mimetype'),
441
+ mimeSubType: element.getAttribute('mime-subtype'),
442
+ title: (_a = element.querySelector('title')) === null || _a === void 0 ? void 0 : _a.textContent,
443
+ };
444
+ },
445
+ },
427
446
  {
428
447
  tag: 'sec[sec-type="abstracts"]',
429
448
  node: 'abstracts',
@@ -520,7 +539,7 @@ const nodes = [
520
539
  {
521
540
  tag: 'title',
522
541
  node: 'section_title',
523
- context: 'section/|footnotes_section/|bibliography_section/|keywords/',
542
+ context: 'section/|footnotes_section/|bibliography_section/|keywords/|supplements/',
524
543
  },
525
544
  {
526
545
  tag: 'title',
@@ -284,4 +284,18 @@ export const jatsBodyTransformations = {
284
284
  body.prepend(section);
285
285
  }
286
286
  },
287
+ createSuppleMaterials(document, body, createElement) {
288
+ const suppleMaterials = [
289
+ ...document.querySelectorAll('article-meta > supplementary-material'),
290
+ ];
291
+ if (suppleMaterials.length > 0) {
292
+ const section = createElement('sec');
293
+ section.setAttribute('sec-type', 'supplementary-material');
294
+ const title = createElement('title');
295
+ title.textContent = 'supplementary-material';
296
+ section.append(title);
297
+ section.append(...suppleMaterials);
298
+ body.prepend(section);
299
+ }
300
+ },
287
301
  };
@@ -15,7 +15,7 @@
15
15
  */
16
16
  import debug from 'debug';
17
17
  import { getTrimmedTextContent } from '../../lib/utils';
18
- import { buildAffiliation, buildBibliographicName, buildContributor, buildCorresp, buildFootnote, buildJournal, buildSupplementaryMaterial, 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');
@@ -122,25 +122,6 @@ export const jatsFrontParser = {
122
122
  }
123
123
  return history;
124
124
  },
125
- parseSupplements(elements) {
126
- var _a, _b, _c, _d;
127
- if (!(elements === null || elements === void 0 ? void 0 : elements.length)) {
128
- return [];
129
- }
130
- const supplements = [];
131
- for (const element of elements) {
132
- const title = (_a = getTrimmedTextContent(element, 'caption > title')) !== null && _a !== void 0 ? _a : '';
133
- const href = (_b = element.getAttributeNS(XLINK_NAMESPACE, 'href')) !== null && _b !== void 0 ? _b : '';
134
- const supplement = buildSupplementaryMaterial(title, href);
135
- const mimeType = (_c = element.getAttribute('mimetype')) !== null && _c !== void 0 ? _c : '';
136
- const mimeSubtype = (_d = element.getAttribute('mime-subtype')) !== null && _d !== void 0 ? _d : '';
137
- if (mimeType && mimeSubtype) {
138
- supplement.MIME = [mimeType, mimeSubtype].join('/');
139
- }
140
- supplements.push(supplement);
141
- }
142
- return supplements;
143
- },
144
125
  parseAffiliations(elements) {
145
126
  const affiliationIDs = new Map();
146
127
  const affiliations = elements.map((element, priority) => {
@@ -40,9 +40,6 @@ export const parseJATSFront = (doc, front) => {
40
40
  const authors = jatsFrontParser.parseContributors([
41
41
  ...front.querySelectorAll('article-meta > contrib-group > contrib[contrib-type="author"]'),
42
42
  ], affiliationIDs, footnoteIDs, correspondingIDs);
43
- const supplements = jatsFrontParser.parseSupplements([
44
- ...front.querySelectorAll('article-meta > supplementary-material'),
45
- ]);
46
43
  const history = jatsFrontParser.parseDates(front.querySelector('article-meta > history'));
47
44
  const counts = jatsFrontParser.parseCounts(front.querySelector('article-meta counts'));
48
45
  const manuscript = Object.assign(Object.assign(Object.assign({}, buildManuscript()), counts), history);
@@ -54,7 +51,6 @@ export const parseJATSFront = (doc, front) => {
54
51
  ...authors,
55
52
  ...affiliations,
56
53
  ...correspondingList,
57
- ...supplements,
58
54
  ]);
59
55
  };
60
56
  export const parseJATSBody = (doc, body, references) => {
@@ -65,6 +61,7 @@ export const parseJATSBody = (doc, body, references) => {
65
61
  jatsBodyTransformations.createBody(doc, body, createElement);
66
62
  jatsBodyTransformations.createAbstracts(doc, body, createElement);
67
63
  jatsBodyTransformations.createBackmatter(doc, body, createElement);
64
+ jatsBodyTransformations.createSuppleMaterials(doc, body, createElement);
68
65
  jatsBodyTransformations.createKeywords(doc, body, createElement);
69
66
  const node = jatsBodyDOMParser.parse(body).firstChild;
70
67
  if (!node) {
@@ -620,6 +620,8 @@ export class JATSExporter {
620
620
  body: () => ['body', 0],
621
621
  abstracts: () => ['abstract', 0],
622
622
  backmatter: () => ['backmatter', 0],
623
+ supplement: () => '',
624
+ supplements: () => '',
623
625
  bibliography_section: (node) => [
624
626
  'ref-list',
625
627
  { id: normalizeID(node.attrs.id) },
@@ -64,6 +64,8 @@ import { pullquoteElement } from './nodes/pullquote_element';
64
64
  import { section } from './nodes/section';
65
65
  import { sectionLabel } from './nodes/section_label';
66
66
  import { sectionTitle } from './nodes/section_title';
67
+ import { supplement } from './nodes/supplement';
68
+ import { supplements } from './nodes/supplements';
67
69
  import { table, tableBody } from './nodes/table';
68
70
  import { tableCol, tableColGroup } from './nodes/table_col';
69
71
  import { tableElement } from './nodes/table_element';
@@ -128,6 +130,8 @@ export * from './nodes/table_element_footer';
128
130
  export * from './nodes/title';
129
131
  export * from './nodes/affiliations';
130
132
  export * from './nodes/contributors';
133
+ export * from './nodes/supplement';
134
+ export * from './nodes/supplements';
131
135
  export const schema = new Schema({
132
136
  marks: {
133
137
  bold,
@@ -207,5 +211,7 @@ export const schema = new Schema({
207
211
  title,
208
212
  affiliations,
209
213
  contributors,
214
+ supplements,
215
+ supplement,
210
216
  },
211
217
  });
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  export const manuscript = {
17
- content: 'title? contributors? affiliations? keywords? abstracts body backmatter comments',
17
+ content: 'title? contributors? affiliations? keywords? supplements? abstracts body backmatter comments',
18
18
  attrs: {
19
19
  id: { default: '' },
20
20
  },
@@ -0,0 +1,60 @@
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 supplement = {
17
+ attrs: {
18
+ id: { default: '' },
19
+ href: { default: '' },
20
+ mimeType: { default: '' },
21
+ mimeSubType: { default: '' },
22
+ title: { default: '' },
23
+ dataTracked: { default: null },
24
+ },
25
+ group: 'block',
26
+ parseDOM: [
27
+ {
28
+ tag: 'div.supplement',
29
+ getAttrs: (dom) => {
30
+ const el = dom;
31
+ const id = el.getAttribute('id');
32
+ const href = el.getAttribute('href');
33
+ const mimeType = el.getAttribute('mimeType');
34
+ const mimeSubType = el.getAttribute('mimeSubType');
35
+ const title = el.textContent;
36
+ return {
37
+ id,
38
+ href,
39
+ mimeType,
40
+ mimeSubType,
41
+ title,
42
+ };
43
+ },
44
+ },
45
+ ],
46
+ toDOM: (node) => {
47
+ const supplement = node;
48
+ return [
49
+ 'div',
50
+ {
51
+ id: supplement.attrs.id,
52
+ class: 'Supplement',
53
+ href: node.attrs.href,
54
+ mimeType: node.attrs.mimeType,
55
+ mimeSubType: node.attrs.mimeSubType,
56
+ title: node.attrs.title,
57
+ },
58
+ ];
59
+ },
60
+ };
@@ -0,0 +1,42 @@
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 supplements = {
17
+ content: 'section_title supplement*',
18
+ attrs: {
19
+ id: { default: '' },
20
+ dataTracked: { default: null },
21
+ },
22
+ group: 'block',
23
+ selectable: false,
24
+ parseDOM: [
25
+ {
26
+ tag: 'div.supplements',
27
+ },
28
+ ],
29
+ toDOM: (node) => {
30
+ const supplements = node;
31
+ return [
32
+ 'div',
33
+ {
34
+ id: supplements.attrs.id,
35
+ class: 'supplements',
36
+ spellcheck: 'false',
37
+ contenteditable: false,
38
+ },
39
+ 0,
40
+ ];
41
+ },
42
+ };
@@ -55,6 +55,7 @@ const getSections = (modelMap) => getModelsByType(modelMap, ObjectTypes.Section)
55
55
  const getAffiliations = (modelMap) => getModelsByType(modelMap, ObjectTypes.Affiliation);
56
56
  const getContributors = (modelMap) => getModelsByType(modelMap, ObjectTypes.Contributor);
57
57
  const getKeywordElements = (modelMap) => getModelsByType(modelMap, ObjectTypes.KeywordsElement);
58
+ const getSupplements = (modelMap) => getModelsByType(modelMap, ObjectTypes.Supplement);
58
59
  const getKeywordGroups = (modelMap) => getModelsByType(modelMap, ObjectTypes.KeywordGroup);
59
60
  const getKeywords = (modelMap) => getModelsByType(modelMap, ObjectTypes.Keyword);
60
61
  const getTitles = (modelMap) => getModelsByType(modelMap, ObjectTypes.Titles)[0];
@@ -93,6 +94,15 @@ export class Decoder {
93
94
  ...elements,
94
95
  ]);
95
96
  }
97
+ createSupplementsNode() {
98
+ const elements = getSupplements(this.modelMap)
99
+ .map((e) => this.decode(e))
100
+ .filter(Boolean);
101
+ return schema.nodes.supplements.createAndFill({}, [
102
+ schema.nodes.section_title.create({}, schema.text('SupplementaryMaterials')),
103
+ ...elements,
104
+ ]);
105
+ }
96
106
  createCommentsNode() {
97
107
  return schema.nodes.comments.createAndFill({}, [
98
108
  ...this.comments.values(),
@@ -630,6 +640,17 @@ export class Decoder {
630
640
  priority: model.priority,
631
641
  }, schema.text('_'));
632
642
  },
643
+ [ObjectTypes.Supplement]: (data) => {
644
+ var _a, _b;
645
+ const model = data;
646
+ return schema.nodes.supplement.create({
647
+ id: model._id,
648
+ href: model.href,
649
+ mimeType: (_a = model.MIME) === null || _a === void 0 ? void 0 : _a.split('/')[0],
650
+ mimeSubType: (_b = model.MIME) === null || _b === void 0 ? void 0 : _b.split('/')[1],
651
+ title: model.title,
652
+ });
653
+ },
633
654
  };
634
655
  this.decode = (model) => {
635
656
  if (!this.creators[model.objectType]) {
@@ -644,6 +665,7 @@ export class Decoder {
644
665
  const contributors = this.createContributorsNode();
645
666
  const affiliations = this.createAffiliationsNode();
646
667
  const keywords = this.createKeywordsNode();
668
+ const suppl = this.createSupplementsNode();
647
669
  const { abstracts, body, backmatter } = this.createContentSections();
648
670
  const comments = this.createCommentsNode();
649
671
  const contents = [
@@ -651,6 +673,7 @@ export class Decoder {
651
673
  contributors,
652
674
  affiliations,
653
675
  keywords,
676
+ suppl,
654
677
  abstracts,
655
678
  body,
656
679
  backmatter,
@@ -517,6 +517,13 @@ const encoders = {
517
517
  corresp: node.attrs.corresp,
518
518
  priority: node.attrs.priority,
519
519
  }),
520
+ supplement: (node) => ({
521
+ href: node.attrs.href,
522
+ title: node.attrs.title,
523
+ MIME: node.attrs.mimeType && node.attrs.mimeSubType
524
+ ? [node.attrs.mimeType, node.attrs.mimeSubType].join('/')
525
+ : '',
526
+ }),
520
527
  };
521
528
  const modelData = (node, parent, path, priority) => {
522
529
  const encoder = encoders[node.type.name];
@@ -544,6 +551,7 @@ const containerTypes = [
544
551
  schema.nodes.contributors,
545
552
  schema.nodes.affiliations,
546
553
  schema.nodes.keywords,
554
+ schema.nodes.supplements,
547
555
  schema.nodes.abstracts,
548
556
  schema.nodes.body,
549
557
  schema.nodes.backmatter,
@@ -58,6 +58,7 @@ export const nodeTypesMap = new Map([
58
58
  [schema.nodes.contributors, ObjectTypes.Section],
59
59
  [schema.nodes.affiliations, ObjectTypes.Section],
60
60
  [schema.nodes.title, ObjectTypes.Titles],
61
+ [schema.nodes.supplement, ObjectTypes.Supplement],
61
62
  ]);
62
63
  export const isExecutableNodeType = (type) => hasGroup(type, GROUP_EXECUTABLE);
63
64
  export const isElementNodeType = (type) => hasGroup(type, GROUP_ELEMENT);
@@ -34,4 +34,5 @@ export declare const jatsBodyTransformations: {
34
34
  fixTables(body: Element, createElement: (tagName: string) => HTMLElement): void;
35
35
  moveFloatsGroupToBody(doc: Document, body: Element, createElement: (tagName: string) => HTMLElement): void;
36
36
  createKeywords(document: Document, body: Element, createElement: (tagName: string) => HTMLElement): void;
37
+ createSuppleMaterials(document: Document, body: Element, createElement: (tagName: string) => HTMLElement): void;
37
38
  };
@@ -58,7 +58,6 @@ export declare const jatsFrontParser: {
58
58
  revisionReceiveDate?: number | undefined;
59
59
  receiveDate?: number | undefined;
60
60
  } | undefined;
61
- parseSupplements(elements: Element[] | null): import("../../transformer").Build<import("@manuscripts/json-schema/dist/types").Supplement>[];
62
61
  parseAffiliations(elements: Element[]): {
63
62
  affiliations: import("../../transformer").Build<import("@manuscripts/json-schema/dist/types").Affiliation>[];
64
63
  affiliationIDs: Map<string, string>;
@@ -70,4 +70,6 @@ export * from './nodes/table_element_footer';
70
70
  export * from './nodes/title';
71
71
  export * from './nodes/affiliations';
72
72
  export * from './nodes/contributors';
73
+ export * from './nodes/supplement';
74
+ export * from './nodes/supplements';
73
75
  export declare const schema: Schema<Nodes, Marks>;
@@ -0,0 +1,29 @@
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
+ href: string;
21
+ mimeType: string;
22
+ mimeSubType: string;
23
+ title: string;
24
+ }
25
+ export interface SupplementNode extends ManuscriptNode {
26
+ attrs: Attrs;
27
+ }
28
+ export declare const supplement: NodeSpec;
29
+ export {};
@@ -0,0 +1,25 @@
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 SupplementsNode extends ManuscriptNode {
22
+ attrs: Attrs;
23
+ }
24
+ export declare const supplements: NodeSpec;
25
+ export {};
@@ -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_body' | 'table_cell' | 'table_element' | 'table_row' | 'table_colgroup' | 'table_col' | 'text' | 'toc_element' | 'toc_section' | 'affiliation' | 'contributor' | 'table_element_footer' | 'title' | 'affiliations' | 'contributors';
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_body' | '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';
21
21
  export type ManuscriptSchema = Schema<Nodes, Marks>;
22
22
  export type ManuscriptEditorState = EditorState;
23
23
  export type ManuscriptEditorView = EditorView;
@@ -28,6 +28,7 @@ export declare class Decoder {
28
28
  private createAffiliationsNode;
29
29
  private createContributorsNode;
30
30
  private createKeywordsNode;
31
+ private createSupplementsNode;
31
32
  private createCommentsNode;
32
33
  private createContentSections;
33
34
  private createCommentNodes;
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.0.4",
4
+ "version": "2.1.0",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-transform",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -78,4 +78,4 @@
78
78
  "rimraf": "^3.0.2",
79
79
  "typescript": "^4.0.5"
80
80
  }
81
- }
81
+ }