@manuscripts/transform 1.4.6 → 1.5.0-LEAN-3014-B-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 (46) hide show
  1. package/dist/cjs/jats/importer/jats-body-dom-parser.js +126 -0
  2. package/dist/cjs/jats/importer/jats-body-transformations.js +59 -0
  3. package/dist/cjs/jats/importer/jats-front-parser.js +7 -7
  4. package/dist/cjs/jats/importer/jats-parser-utils.js +4 -0
  5. package/dist/cjs/jats/importer/parse-jats-article.js +7 -5
  6. package/dist/cjs/jats/jats-exporter.js +4 -2
  7. package/dist/cjs/lib/core-section-categories.js +2 -2
  8. package/dist/cjs/schema/index.js +8 -4
  9. package/dist/cjs/schema/nodes/affiliation.js +3 -0
  10. package/dist/cjs/schema/nodes/affiliations_section.js +15 -0
  11. package/dist/cjs/schema/nodes/contributor.js +8 -1
  12. package/dist/cjs/schema/nodes/contributors_section.js +15 -0
  13. package/dist/cjs/schema/nodes/meta_section.js +1 -1
  14. package/dist/cjs/transformer/decode.js +51 -23
  15. package/dist/cjs/transformer/encode.js +20 -0
  16. package/dist/cjs/transformer/node-types.js +2 -0
  17. package/dist/cjs/transformer/section-category.js +12 -0
  18. package/dist/es/jats/importer/jats-body-dom-parser.js +126 -0
  19. package/dist/es/jats/importer/jats-body-transformations.js +59 -0
  20. package/dist/es/jats/importer/jats-front-parser.js +1 -1
  21. package/dist/es/jats/importer/jats-parser-utils.js +4 -0
  22. package/dist/es/jats/importer/parse-jats-article.js +7 -5
  23. package/dist/es/jats/jats-exporter.js +4 -2
  24. package/dist/es/lib/core-section-categories.js +2 -2
  25. package/dist/es/schema/index.js +8 -4
  26. package/dist/es/schema/nodes/affiliation.js +3 -0
  27. package/dist/es/schema/nodes/affiliations_section.js +11 -0
  28. package/dist/es/schema/nodes/contributor.js +6 -0
  29. package/dist/es/schema/nodes/contributors_section.js +11 -0
  30. package/dist/es/schema/nodes/meta_section.js +1 -1
  31. package/dist/es/transformer/decode.js +51 -23
  32. package/dist/es/transformer/encode.js +20 -0
  33. package/dist/es/transformer/node-types.js +2 -0
  34. package/dist/es/transformer/section-category.js +12 -0
  35. package/dist/types/jats/importer/jats-body-transformations.d.ts +4 -1
  36. package/dist/types/jats/importer/jats-front-parser.d.ts +5 -5
  37. package/dist/types/jats/importer/parse-jats-article.d.ts +5 -2
  38. package/dist/types/schema/index.d.ts +2 -2
  39. package/dist/types/schema/nodes/affiliation.d.ts +1 -0
  40. package/dist/types/schema/nodes/affiliations_section.d.ts +11 -0
  41. package/dist/types/schema/nodes/contributor.d.ts +2 -0
  42. package/dist/types/schema/nodes/contributors_section.d.ts +11 -0
  43. package/dist/types/schema/types.d.ts +1 -1
  44. package/dist/types/transformer/decode.d.ts +3 -2
  45. package/dist/types/transformer/section-category.d.ts +2 -2
  46. package/package.json +2 -2
@@ -426,6 +426,22 @@ const encoders = {
426
426
  .map((childNode) => childNode.attrs.id)
427
427
  .filter((id) => id),
428
428
  }),
429
+ affiliations_section: (node, parent, path, priority) => ({
430
+ category: buildSectionCategory(node),
431
+ priority: priority.value++,
432
+ path: path.concat([node.attrs.id]),
433
+ elementIDs: childElements(node)
434
+ .map((childNode) => childNode.attrs.id)
435
+ .filter((id) => id),
436
+ }),
437
+ contributors_section: (node, parent, path, priority) => ({
438
+ category: buildSectionCategory(node),
439
+ priority: priority.value++,
440
+ path: path.concat([node.attrs.id]),
441
+ elementIDs: childElements(node)
442
+ .map((childNode) => childNode.attrs.id)
443
+ .filter((id) => id),
444
+ }),
429
445
  missing_figure: (node) => ({
430
446
  position: node.attrs.position || undefined,
431
447
  }),
@@ -506,6 +522,7 @@ const encoders = {
506
522
  postCode: node.attrs.postCode,
507
523
  country: node.attrs.country,
508
524
  email: node.attrs.email,
525
+ priority: node.attrs.priority,
509
526
  }),
510
527
  contributor: (node) => ({
511
528
  role: node.attrs.role,
@@ -515,6 +532,9 @@ const encoders = {
515
532
  invitationID: node.attrs.invitationID,
516
533
  isCorresponding: node.attrs.isCorresponding,
517
534
  ORCIDIdentifier: node.attrs.ORCIDIdentifier,
535
+ footnote: node.attrs.footnote,
536
+ corresp: node.attrs.corresp,
537
+ priority: node.attrs.priority,
518
538
  }),
519
539
  };
520
540
  const modelData = (node, parent, path, priority) => {
@@ -54,6 +54,8 @@ export const nodeTypesMap = new Map([
54
54
  [schema.nodes.affiliation, ObjectTypes.Affiliation],
55
55
  [schema.nodes.contributor, ObjectTypes.Contributor],
56
56
  [schema.nodes.table_element_footer, ObjectTypes.TableElementFooter],
57
+ [schema.nodes.contributors_section, ObjectTypes.Section],
58
+ [schema.nodes.affiliations_section, ObjectTypes.Section],
57
59
  ]);
58
60
  export const isExecutableNodeType = (type) => hasGroup(type, GROUP_EXECUTABLE);
59
61
  export const isElementNodeType = (type) => hasGroup(type, GROUP_ELEMENT);
@@ -41,6 +41,10 @@ export const chooseSectionNodeType = (category) => {
41
41
  return schema.nodes.footnotes_section;
42
42
  case 'MPSectionCategory:keywords':
43
43
  return schema.nodes.keywords_section;
44
+ case 'MPSectionCategory:affiliations':
45
+ return schema.nodes.affiliations_section;
46
+ case 'MPSectionCategory:contributors':
47
+ return schema.nodes.contributors_section;
44
48
  case 'MPSectionCategory:toc':
45
49
  return schema.nodes.toc_section;
46
50
  default:
@@ -84,6 +88,10 @@ export const buildSectionCategory = (node) => {
84
88
  return 'MPSectionCategory:toc';
85
89
  case schema.nodes.graphical_abstract_section:
86
90
  return 'MPSectionCategory:abstract-graphical';
91
+ case schema.nodes.affiliations_section:
92
+ return 'MPSectionCategory:affiliations';
93
+ case schema.nodes.contributors_section:
94
+ return 'MPSectionCategory:contributors';
87
95
  default:
88
96
  return node.attrs.category || undefined;
89
97
  }
@@ -174,6 +182,10 @@ export const chooseSectionCategoryByType = (secType) => {
174
182
  return 'MPSectionCategory:backmatter';
175
183
  case 'abstracts':
176
184
  return 'MPSectionCategory:abstracts';
185
+ case 'affiliations':
186
+ return 'MPSectionCategory:affiliations';
187
+ case 'contributors':
188
+ return 'MPSectionCategory:contributors';
177
189
  default:
178
190
  return undefined;
179
191
  }
@@ -13,7 +13,8 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { BibliographyItem } from '@manuscripts/json-schema';
16
+ import { Affiliation, BibliographyItem, Contributor } from '@manuscripts/json-schema';
17
+ import { Build } from '../../transformer';
17
18
  export declare const jatsBodyTransformations: {
18
19
  ensureSection(body: Element, createElement: (tagName: string) => HTMLElement): void;
19
20
  createAbstract(abstractNode: Element, createElement: (tagName: string) => HTMLElement): HTMLElement;
@@ -32,6 +33,8 @@ export declare const jatsBodyTransformations: {
32
33
  mapFootnotesToSections(doc: Document, backmatterContainer: Element, createElement: (tagName: string) => HTMLElement): void;
33
34
  moveCaptionsToEnd(body: Element): void;
34
35
  moveTableFooterToEnd(body: Element): void;
36
+ moveAffiliationsToBody(doc: Document, affiliations: Build<Affiliation>[] | undefined, body: Element, createElement: (tagName: string) => HTMLElement): void;
37
+ moveAuthorsToBody(doc: Document, authors: Build<Contributor>[] | undefined, body: Element, createElement: (tagName: string) => HTMLElement): void;
35
38
  moveFloatsGroupToBody(doc: Document, body: Element, createElement: (tagName: string) => HTMLElement): void;
36
39
  moveBlockNodesFromParagraph(doc: Document, body: Element, createElement: (tagName: string) => HTMLElement): void;
37
40
  moveKeywordsToBody(document: Document, body: Element, createElement: (tagName: string) => HTMLElement): void;
@@ -35,18 +35,18 @@ export declare const jatsFrontParser: {
35
35
  revisionReceiveDate?: number | undefined;
36
36
  receiveDate?: number | undefined;
37
37
  } | undefined;
38
- parseSupplements(supplementNodes: Element[] | null): import("../../transformer/builders").Build<import("@manuscripts/json-schema").Supplement>[];
38
+ parseSupplements(supplementNodes: Element[] | null): import("../../transformer").Build<import("@manuscripts/json-schema").Supplement>[];
39
39
  parseAffiliationNodes(affiliationNodes: Element[]): {
40
- affiliations: import("../../transformer/builders").Build<import("@manuscripts/json-schema").Affiliation>[];
40
+ affiliations: import("../../transformer").Build<import("@manuscripts/json-schema").Affiliation>[];
41
41
  affiliationIDs: Map<string, string>;
42
42
  };
43
43
  parseFootnoteNodes(footnoteNodes: Element[]): {
44
- footnotes: import("../../transformer/builders").Build<import("@manuscripts/json-schema").Footnote>[];
44
+ footnotes: import("../../transformer").Build<import("@manuscripts/json-schema").Footnote>[];
45
45
  footnoteIDs: Map<string, string>;
46
46
  };
47
47
  parseCorrespNodes(correspNodes: Element[]): {
48
- correspondingList: import("../../transformer/builders").Build<import("@manuscripts/json-schema").Corresponding>[];
48
+ correspondingList: import("../../transformer").Build<import("@manuscripts/json-schema").Corresponding>[];
49
49
  correspondingIDs: Map<string, string>;
50
50
  };
51
- parseAuthorNodes(authorNodes: Element[], affiliationIDs: Map<string, string>, footnoteIDs: Map<string, string>, correspondingIDs: Map<string, string>): import("../../transformer/builders").Build<import("@manuscripts/json-schema").Contributor>[];
51
+ parseAuthorNodes(authorNodes: Element[], affiliationIDs: Map<string, string>, footnoteIDs: Map<string, string>, correspondingIDs: Map<string, string>): import("../../transformer").Build<import("@manuscripts/json-schema").Contributor>[];
52
52
  };
@@ -13,10 +13,13 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { BibliographyItem, ElementsOrder, FootnotesOrder, Model } from '@manuscripts/json-schema';
16
+ import { Affiliation, BibliographyItem, Contributor, ElementsOrder, FootnotesOrder, Model } from '@manuscripts/json-schema';
17
17
  import { ManuscriptNode } from '../../schema';
18
+ import { Build } from '../../transformer/builders';
18
19
  export declare const parseJATSFront: (front: Element) => Promise<{
19
20
  models: Model[];
21
+ authors: Build<Contributor>[];
22
+ affiliations: Build<Affiliation>[];
20
23
  }>;
21
24
  export declare const parseJATSReferences: (back: Element | null, body: Element | null, createElement: (tagName: string) => HTMLElement) => {
22
25
  references: Model[];
@@ -24,6 +27,6 @@ export declare const parseJATSReferences: (back: Element | null, body: Element |
24
27
  referenceQueriesMap: Map<string, string[]> | undefined;
25
28
  referenceIdsMap: Map<string, string> | undefined;
26
29
  };
27
- export declare const parseJATSBody: (document: Document, body: Element, bibliographyItems: BibliographyItem[] | null, refModels: Model[], referenceIdsMap: Map<string, string> | undefined, footnotesOrder?: FootnotesOrder) => ManuscriptNode;
30
+ export declare const parseJATSBody: (document: Document, body: Element, bibliographyItems: BibliographyItem[] | null, authors: Build<Contributor>[], affiliations: Build<Affiliation>[], refModels: Model[], referenceIdsMap: Map<string, string> | undefined, footnotesOrder?: FootnotesOrder) => ManuscriptNode;
28
31
  export declare const parseJATSArticle: (doc: Document) => Promise<Model[]>;
29
32
  export declare const getElementsOrder: (node: ManuscriptNode) => ElementsOrder[];
@@ -65,9 +65,9 @@ export * from './nodes/text';
65
65
  export * from './nodes/toc_element';
66
66
  export * from './nodes/toc_section';
67
67
  export * from './nodes/affiliation';
68
- export * from './nodes/affiliation_list';
69
68
  export * from './nodes/meta_section';
70
- export * from './nodes/contributor_list';
71
69
  export * from './nodes/contributor';
72
70
  export * from './nodes/table_element_footer';
71
+ export * from './nodes/affiliations_section';
72
+ export * from './nodes/contributors_section';
73
73
  export declare const schema: Schema<Nodes, Marks>;
@@ -14,6 +14,7 @@ interface Attrs {
14
14
  postCode: string;
15
15
  country: string;
16
16
  email: Email;
17
+ priority: number;
17
18
  }
18
19
  export interface AffiliationNode extends ManuscriptNode {
19
20
  attrs: Attrs;
@@ -0,0 +1,11 @@
1
+ import { NodeSpec } from 'prosemirror-model';
2
+ import { ManuscriptNode } from '../types';
3
+ interface Attrs {
4
+ id: string;
5
+ }
6
+ export interface AffiliationsSectionNode extends ManuscriptNode {
7
+ attrs: Attrs;
8
+ }
9
+ export declare const affiliationsSection: NodeSpec;
10
+ export declare const isAffiliationsSectionNode: (node: ManuscriptNode) => node is AffiliationsSectionNode;
11
+ export {};
@@ -10,9 +10,11 @@ interface Attrs {
10
10
  invitationID: string;
11
11
  isCorresponding: boolean;
12
12
  ORCIDIdentifier: string;
13
+ priority: number;
13
14
  }
14
15
  export interface ContributorNode extends ManuscriptNode {
15
16
  attrs: Attrs;
16
17
  }
17
18
  export declare const contributor: NodeSpec;
19
+ export declare const isContributorNode: (node: ManuscriptNode) => node is ContributorNode;
18
20
  export {};
@@ -0,0 +1,11 @@
1
+ import { NodeSpec } from 'prosemirror-model';
2
+ import { ManuscriptNode } from '../types';
3
+ interface Attrs {
4
+ id: string;
5
+ }
6
+ export interface ContributorsSectionNode extends ManuscriptNode {
7
+ attrs: Attrs;
8
+ }
9
+ export declare const contributorsSection: NodeSpec;
10
+ export declare const isContributorsSectionNode: (node: ManuscriptNode) => node is ContributorsSectionNode;
11
+ 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' | 'comment_list' | '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' | 'keywords_group' | 'keywords_section' | 'link' | 'list_item' | 'listing' | 'listing_element' | 'manuscript' | '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' | 'meta_section' | 'affiliation_list' | 'contributor_list' | 'contributor' | 'table_element_footer';
20
+ export type Nodes = 'attribution' | 'bibliography_item' | 'bibliography_element' | 'bibliography_section' | 'blockquote_element' | 'bullet_list' | 'caption' | 'caption_title' | 'comment' | 'comment_list' | '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' | 'keywords_group' | 'keywords_section' | 'link' | 'list_item' | 'listing' | 'listing_element' | 'manuscript' | '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' | 'meta_section' | 'contributor' | 'table_element_footer' | 'affiliations_section' | 'contributors_section' | 'affiliation_list' | 'contributor_list';
21
21
  export type ManuscriptSchema = Schema<Nodes, Marks>;
22
22
  export type ManuscriptEditorState = EditorState;
23
23
  export type ManuscriptEditorView = EditorView;
@@ -25,10 +25,11 @@ export declare class Decoder {
25
25
  private readonly allowMissingElements;
26
26
  private comments;
27
27
  private creators;
28
- private createAffiliationListNode;
29
- private createContributorListNode;
30
28
  private createMetaSectionNode;
31
29
  private createCommentListNode;
30
+ private handleMissingRootSectionNodes;
31
+ private createAffiliationSectionNode;
32
+ private createContributorSectionNode;
32
33
  private createRootSectionNodes;
33
34
  private createCommentsNode;
34
35
  private getComments;
@@ -17,8 +17,8 @@ import { Element } from '@manuscripts/json-schema';
17
17
  import { ManuscriptNode, ManuscriptNodeType } from '../schema';
18
18
  export declare const getCoreSectionTitles: (sectionCategory: SectionCategory) => string[];
19
19
  export declare const isAnySectionNode: (node: ManuscriptNode) => boolean;
20
- export type SectionCategory = 'MPSectionCategory:abstract' | 'MPSectionCategory:abstract-teaser' | 'MPSectionCategory:abstract-graphical' | 'MPSectionCategory:acknowledgement' | 'MPSectionCategory:availability' | 'MPSectionCategory:bibliography' | 'MPSectionCategory:conclusions' | 'MPSectionCategory:discussion' | 'MPSectionCategory:endnotes' | 'MPSectionCategory:introduction' | 'MPSectionCategory:keywords' | 'MPSectionCategory:materials-method' | 'MPSectionCategory:results' | 'MPSectionCategory:toc' | 'MPSectionCategory:floating-element' | 'MPSectionCategory:appendices' | 'MPSectionCategory:competing-interests' | 'MPSectionCategory:financial-disclosure' | 'MPSectionCategory:con' | 'MPSectionCategory:deceased' | 'MPSectionCategory:equal' | 'MPSectionCategory:present-address' | 'MPSectionCategory:presented-at' | 'MPSectionCategory:previously-at' | 'MPSectionCategory:supplementary-material' | 'MPSectionCategory:supported-by' | 'MPSectionCategory:ethics-statement' | 'MPSectionCategory:body' | 'MPSectionCategory:abstracts' | 'MPSectionCategory:backmatter';
21
- export type SecType = 'abstract' | 'abstract-teaser' | 'abstract-graphical' | 'acknowledgments' | 'availability' | 'bibliography' | 'conclusions' | 'data-availability' | 'discussion' | 'endnotes' | 'intro' | 'keywords' | 'materials' | 'methods' | 'results' | 'toc' | 'floating-element' | 'appendices' | 'competing-interests' | 'financial-disclosure' | 'con' | 'deceased' | 'equal' | 'present-address' | 'presented-at' | 'previously-at' | 'supplementary-material' | 'supported-by' | 'ethics-statement' | 'abstracts' | 'body' | 'backmatter';
20
+ export type SectionCategory = 'MPSectionCategory:abstract' | 'MPSectionCategory:abstract-teaser' | 'MPSectionCategory:abstract-graphical' | 'MPSectionCategory:acknowledgement' | 'MPSectionCategory:availability' | 'MPSectionCategory:bibliography' | 'MPSectionCategory:conclusions' | 'MPSectionCategory:discussion' | 'MPSectionCategory:endnotes' | 'MPSectionCategory:introduction' | 'MPSectionCategory:keywords' | 'MPSectionCategory:materials-method' | 'MPSectionCategory:results' | 'MPSectionCategory:toc' | 'MPSectionCategory:floating-element' | 'MPSectionCategory:appendices' | 'MPSectionCategory:competing-interests' | 'MPSectionCategory:financial-disclosure' | 'MPSectionCategory:con' | 'MPSectionCategory:deceased' | 'MPSectionCategory:equal' | 'MPSectionCategory:present-address' | 'MPSectionCategory:presented-at' | 'MPSectionCategory:previously-at' | 'MPSectionCategory:supplementary-material' | 'MPSectionCategory:supported-by' | 'MPSectionCategory:ethics-statement' | 'MPSectionCategory:body' | 'MPSectionCategory:abstracts' | 'MPSectionCategory:backmatter' | 'MPSectionCategory:affiliations' | 'MPSectionCategory:contributors';
21
+ export type SecType = 'abstract' | 'abstract-teaser' | 'abstract-graphical' | 'acknowledgments' | 'availability' | 'bibliography' | 'conclusions' | 'data-availability' | 'discussion' | 'endnotes' | 'intro' | 'keywords' | 'materials' | 'methods' | 'results' | 'toc' | 'floating-element' | 'appendices' | 'competing-interests' | 'financial-disclosure' | 'con' | 'deceased' | 'equal' | 'present-address' | 'presented-at' | 'previously-at' | 'supplementary-material' | 'supported-by' | 'ethics-statement' | 'abstracts' | 'body' | 'backmatter' | 'affiliations' | 'contributors';
22
22
  export declare const chooseSectionNodeType: (category?: SectionCategory) => ManuscriptNodeType;
23
23
  export declare const chooseSectionLableName: (type?: SecType) => string;
24
24
  export declare const guessSectionCategory: (elements: Element[]) => SectionCategory | undefined;
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": "1.4.6",
4
+ "version": "1.5.0-LEAN-3014-B-0",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-transform",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -82,4 +82,4 @@
82
82
  "prosemirror-state": "^1.4.2",
83
83
  "prosemirror-view": "^1.29.1"
84
84
  }
85
- }
85
+ }