@manuscripts/transform 1.5.6 → 1.5.7-LEAN-3030

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 (54) hide show
  1. package/dist/cjs/jats/importer/jats-body-dom-parser.js +23 -18
  2. package/dist/cjs/jats/importer/jats-body-transformations.js +3 -3
  3. package/dist/cjs/jats/jats-exporter.js +11 -6
  4. package/dist/cjs/lib/utils.js +10 -1
  5. package/dist/cjs/schema/index.js +15 -11
  6. package/dist/cjs/schema/nodes/{affiliations_section.js → affiliations.js} +9 -8
  7. package/dist/cjs/schema/nodes/{contributors_section.js → contributors.js} +8 -7
  8. package/dist/cjs/schema/nodes/core_section.js +27 -0
  9. package/dist/cjs/schema/nodes/graphical_abstract_section.js +1 -0
  10. package/dist/cjs/schema/nodes/keyword.js +0 -1
  11. package/dist/cjs/schema/nodes/{keywords_group.js → keyword_group.js} +6 -6
  12. package/dist/cjs/schema/nodes/{keywords_section.js → keywords.js} +7 -7
  13. package/dist/cjs/schema/nodes/keywords_element.js +1 -1
  14. package/dist/cjs/schema/nodes/manuscript.js +1 -1
  15. package/dist/cjs/transformer/decode.js +110 -113
  16. package/dist/cjs/transformer/encode.js +13 -26
  17. package/dist/cjs/transformer/node-names.js +1 -1
  18. package/dist/cjs/transformer/node-title.js +1 -1
  19. package/dist/cjs/transformer/node-types.js +7 -4
  20. package/dist/cjs/transformer/section-category.js +35 -8
  21. package/dist/es/jats/importer/jats-body-dom-parser.js +23 -18
  22. package/dist/es/jats/importer/jats-body-transformations.js +3 -3
  23. package/dist/es/jats/jats-exporter.js +11 -6
  24. package/dist/es/lib/utils.js +8 -0
  25. package/dist/es/schema/index.js +15 -11
  26. package/dist/es/schema/nodes/{affiliations_section.js → affiliations.js} +7 -6
  27. package/dist/es/schema/nodes/{contributors_section.js → contributors.js} +6 -5
  28. package/dist/es/schema/nodes/core_section.js +24 -0
  29. package/dist/es/schema/nodes/graphical_abstract_section.js +1 -0
  30. package/dist/es/schema/nodes/keyword.js +0 -1
  31. package/dist/es/schema/nodes/{keywords_group.js → keyword_group.js} +4 -4
  32. package/dist/es/schema/nodes/{keywords_section.js → keywords.js} +5 -5
  33. package/dist/es/schema/nodes/keywords_element.js +1 -1
  34. package/dist/es/schema/nodes/manuscript.js +1 -1
  35. package/dist/es/transformer/decode.js +111 -114
  36. package/dist/es/transformer/encode.js +13 -26
  37. package/dist/es/transformer/node-names.js +1 -1
  38. package/dist/es/transformer/node-title.js +1 -1
  39. package/dist/es/transformer/node-types.js +7 -4
  40. package/dist/es/transformer/section-category.js +33 -7
  41. package/dist/types/lib/utils.d.ts +1 -0
  42. package/dist/types/schema/index.d.ts +3 -3
  43. package/dist/types/schema/nodes/affiliations.d.ts +11 -0
  44. package/dist/types/schema/nodes/contributors.d.ts +12 -0
  45. package/dist/types/schema/nodes/core_section.d.ts +17 -0
  46. package/dist/types/schema/nodes/keyword.d.ts +0 -1
  47. package/dist/types/schema/nodes/{keywords_group.d.ts → keyword_group.d.ts} +3 -3
  48. package/dist/types/schema/nodes/{keywords_section.d.ts → keywords.d.ts} +3 -3
  49. package/dist/types/schema/types.d.ts +1 -1
  50. package/dist/types/transformer/decode.d.ts +6 -6
  51. package/dist/types/transformer/section-category.d.ts +1 -0
  52. package/package.json +1 -1
  53. package/dist/types/schema/nodes/affiliations_section.d.ts +0 -11
  54. package/dist/types/schema/nodes/contributors_section.d.ts +0 -12
@@ -47,7 +47,7 @@ export const nodeTitle = (node) => {
47
47
  case nodes.section:
48
48
  case nodes.bibliography_section:
49
49
  case nodes.footnotes_section:
50
- case nodes.keywords_section:
50
+ case nodes.keywords:
51
51
  case nodes.toc_section:
52
52
  case nodes.graphical_abstract_section:
53
53
  return snippetOfNodeType(node, nodes.section_title);
@@ -16,6 +16,9 @@
16
16
  import { ObjectTypes } from '@manuscripts/json-schema';
17
17
  import { GROUP_ELEMENT, GROUP_EXECUTABLE, GROUP_SECTION, hasGroup, schema, } from '../schema';
18
18
  export const nodeTypesMap = new Map([
19
+ [schema.nodes.abstracts, ObjectTypes.Section],
20
+ [schema.nodes.body, ObjectTypes.Section],
21
+ [schema.nodes.backmatter, ObjectTypes.Section],
19
22
  [schema.nodes.comment, ObjectTypes.CommentAnnotation],
20
23
  [schema.nodes.bibliography_item, ObjectTypes.BibliographyItem],
21
24
  [schema.nodes.bibliography_element, ObjectTypes.BibliographyElement],
@@ -37,8 +40,8 @@ export const nodeTypesMap = new Map([
37
40
  [schema.nodes.inline_equation, ObjectTypes.InlineMathFragment],
38
41
  [schema.nodes.keyword, ObjectTypes.Keyword],
39
42
  [schema.nodes.keywords_element, ObjectTypes.KeywordsElement],
40
- [schema.nodes.keywords_section, ObjectTypes.Section],
41
- [schema.nodes.keywords_group, ObjectTypes.KeywordGroup],
43
+ [schema.nodes.keywords, ObjectTypes.Section],
44
+ [schema.nodes.keyword_group, ObjectTypes.KeywordGroup],
42
45
  [schema.nodes.listing, ObjectTypes.Listing],
43
46
  [schema.nodes.listing_element, ObjectTypes.ListingElement],
44
47
  [schema.nodes.manuscript, ObjectTypes.Manuscript],
@@ -54,9 +57,9 @@ export const nodeTypesMap = new Map([
54
57
  [schema.nodes.affiliation, ObjectTypes.Affiliation],
55
58
  [schema.nodes.contributor, ObjectTypes.Contributor],
56
59
  [schema.nodes.table_element_footer, ObjectTypes.TableElementFooter],
60
+ [schema.nodes.contributors, ObjectTypes.Section],
61
+ [schema.nodes.affiliations, ObjectTypes.Section],
57
62
  [schema.nodes.title, ObjectTypes.Titles],
58
- [schema.nodes.contributors_section, ObjectTypes.Section],
59
- [schema.nodes.affiliations_section, ObjectTypes.Section],
60
63
  ]);
61
64
  export const isExecutableNodeType = (type) => hasGroup(type, GROUP_EXECUTABLE);
62
65
  export const isElementNodeType = (type) => hasGroup(type, GROUP_ELEMENT);
@@ -19,7 +19,7 @@ import { schema } from '../schema';
19
19
  const sectionNodeTypes = [
20
20
  schema.nodes.bibliography_section,
21
21
  schema.nodes.footnotes_section,
22
- schema.nodes.keywords_section,
22
+ schema.nodes.keywords,
23
23
  schema.nodes.section,
24
24
  schema.nodes.toc_section,
25
25
  ];
@@ -40,11 +40,11 @@ export const chooseSectionNodeType = (category) => {
40
40
  case 'MPSectionCategory:endnotes':
41
41
  return schema.nodes.footnotes_section;
42
42
  case 'MPSectionCategory:keywords':
43
- return schema.nodes.keywords_section;
43
+ return schema.nodes.keywords;
44
44
  case 'MPSectionCategory:affiliations':
45
- return schema.nodes.affiliations_section;
45
+ return schema.nodes.affiliations;
46
46
  case 'MPSectionCategory:contributors':
47
- return schema.nodes.contributors_section;
47
+ return schema.nodes.contributors;
48
48
  case 'MPSectionCategory:toc':
49
49
  return schema.nodes.toc_section;
50
50
  default:
@@ -82,15 +82,15 @@ export const buildSectionCategory = (node) => {
82
82
  return 'MPSectionCategory:bibliography';
83
83
  case schema.nodes.footnotes_section:
84
84
  return 'MPSectionCategory:endnotes';
85
- case schema.nodes.keywords_section:
85
+ case schema.nodes.keywords:
86
86
  return 'MPSectionCategory:keywords';
87
87
  case schema.nodes.toc_section:
88
88
  return 'MPSectionCategory:toc';
89
89
  case schema.nodes.graphical_abstract_section:
90
90
  return 'MPSectionCategory:abstract-graphical';
91
- case schema.nodes.affiliations_section:
91
+ case schema.nodes.affiliations:
92
92
  return 'MPSectionCategory:affiliations';
93
- case schema.nodes.contributors_section:
93
+ case schema.nodes.contributors:
94
94
  return 'MPSectionCategory:contributors';
95
95
  default:
96
96
  return node.attrs.category || undefined;
@@ -117,6 +117,32 @@ export const chooseSecType = (sectionCategory) => {
117
117
  return suffix;
118
118
  }
119
119
  };
120
+ export const chooseCoreSectionBySection = (section) => {
121
+ switch (section) {
122
+ case 'MPSectionCategory:abstract':
123
+ case 'MPSectionCategory:abstract-teaser':
124
+ case 'MPSectionCategory:abstract-graphical':
125
+ return 'MPSectionCategory:abstracts';
126
+ case 'MPSectionCategory:acknowledgement':
127
+ case 'MPSectionCategory:availability':
128
+ case 'MPSectionCategory:conclusions':
129
+ case 'MPSectionCategory:bibliography':
130
+ case 'MPSectionCategory:discussion':
131
+ case 'MPSectionCategory:endnotes':
132
+ case 'MPSectionCategory:appendices':
133
+ case 'MPSectionCategory:competing-interests':
134
+ case 'MPSectionCategory:con':
135
+ case 'MPSectionCategory:deceased':
136
+ case 'MPSectionCategory:ethics-statement':
137
+ case 'MPSectionCategory:financial-disclosure':
138
+ case 'MPSectionCategory:supplementary-material':
139
+ case 'MPSectionCategory:supported-by':
140
+ case 'MPSectionCategory:abbreviations':
141
+ case 'MPSectionCategory:results':
142
+ return 'MPSectionCategory:backmatter';
143
+ }
144
+ return 'MPSectionCategory:body';
145
+ };
120
146
  export const chooseSectionCategoryByType = (secType) => {
121
147
  switch (secType) {
122
148
  case 'abstract':
@@ -27,3 +27,4 @@ export declare const findParentNodeClosestToPos: ($pos: ResolvedPos, predicate:
27
27
  node: ProsemirrorNode;
28
28
  } | undefined;
29
29
  export declare const getTrimmedTextContent: (node: Element | Document, querySelector: string) => string | null | undefined;
30
+ export declare const groupBy: <T, K extends string | number | symbol>(list: T[], getKey: (item: T) => K) => Record<K, T[]>;
@@ -44,7 +44,7 @@ export * from './nodes/inline_equation';
44
44
  export * from './nodes/inline_footnote';
45
45
  export * from './nodes/keyword';
46
46
  export * from './nodes/keywords_element';
47
- export * from './nodes/keywords_section';
47
+ export * from './nodes/keywords';
48
48
  export * from './nodes/link';
49
49
  export * from './nodes/list';
50
50
  export * from './nodes/listing';
@@ -69,6 +69,6 @@ export * from './nodes/meta_section';
69
69
  export * from './nodes/contributor';
70
70
  export * from './nodes/table_element_footer';
71
71
  export * from './nodes/title';
72
- export * from './nodes/affiliations_section';
73
- export * from './nodes/contributors_section';
72
+ export * from './nodes/affiliations';
73
+ export * from './nodes/contributors';
74
74
  export declare const schema: Schema<Nodes, Marks>;
@@ -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 AffiliationsNode extends ManuscriptNode {
7
+ attrs: Attrs;
8
+ }
9
+ export declare const affiliations: NodeSpec;
10
+ export declare const isAffiliationsNode: (node: ManuscriptNode) => node is AffiliationsNode;
11
+ export {};
@@ -0,0 +1,12 @@
1
+ import { NodeSpec } from 'prosemirror-model';
2
+ import { ManuscriptNode } from '../types';
3
+ interface Attrs {
4
+ id: string;
5
+ contents: string;
6
+ }
7
+ export interface ContributorsNode extends ManuscriptNode {
8
+ attrs: Attrs;
9
+ }
10
+ export declare const contributors: NodeSpec;
11
+ export declare const isContributorsNode: (node: ManuscriptNode) => node is ContributorsNode;
12
+ export {};
@@ -0,0 +1,17 @@
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
+ export declare const coreSection: NodeSpec;
@@ -18,7 +18,6 @@ import { ManuscriptNode } from '../types';
18
18
  import { CommentNode } from './comment';
19
19
  interface Attrs {
20
20
  id: string;
21
- contents: string;
22
21
  comments?: CommentNode[];
23
22
  }
24
23
  export interface KeywordNode extends ManuscriptNode {
@@ -18,9 +18,9 @@ import { ManuscriptNode } from '../types';
18
18
  interface Attrs {
19
19
  id: string;
20
20
  }
21
- export interface KeywordsGroupNode extends ManuscriptNode {
21
+ export interface KeywordGroupNode extends ManuscriptNode {
22
22
  attrs: Attrs;
23
23
  }
24
- export declare const keywordsGroup: NodeSpec;
25
- export declare const isKeywordsGroupNode: (node: ManuscriptNode) => node is KeywordsGroupNode;
24
+ export declare const keywordGroup: NodeSpec;
25
+ export declare const isKeywordGroupNode: (node: ManuscriptNode) => node is KeywordGroupNode;
26
26
  export {};
@@ -18,9 +18,9 @@ import { ManuscriptNode } from '../types';
18
18
  interface Attrs {
19
19
  id: string;
20
20
  }
21
- export interface KeywordsSectionNode extends ManuscriptNode {
21
+ export interface KeywordsNode extends ManuscriptNode {
22
22
  attrs: Attrs;
23
23
  }
24
- export declare const keywordsSection: NodeSpec;
25
- export declare const isKeywordsSectionNode: (node: ManuscriptNode) => node is KeywordsSectionNode;
24
+ export declare const keywords: NodeSpec;
25
+ export declare const isKeywordsNode: (node: ManuscriptNode) => node is KeywordsNode;
26
26
  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' | 'contributor' | 'table_element_footer' | 'title' | 'affiliations_section' | 'contributors_section';
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' | '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' | 'meta_section' | 'contributor' | 'table_element_footer' | 'title' | 'affiliations' | 'contributors';
21
21
  export type ManuscriptSchema = Schema<Nodes, Marks>;
22
22
  export type ManuscriptEditorState = EditorState;
23
23
  export type ManuscriptEditorView = EditorView;
@@ -25,13 +25,15 @@ export declare class Decoder {
25
25
  private readonly allowMissingElements;
26
26
  private comments;
27
27
  private creators;
28
+ private createTitleNode;
29
+ private createAffiliationsNode;
30
+ private createContributorsNode;
31
+ private createKeywordsNode;
28
32
  private createMetaSectionNode;
29
33
  private createCommentListNode;
30
- private handleMissingRootSectionNodes;
31
- private createAffiliationSectionNode;
32
- private createContributorSectionNode;
33
- private createTitleNode;
34
34
  private createRootSectionNodes;
35
+ private ensureCoreSectionsExist;
36
+ private createAndFill;
35
37
  private createCommentsNode;
36
38
  private getComments;
37
39
  private extractListing;
@@ -41,11 +43,9 @@ export declare class Decoder {
41
43
  createArticleNode: (manuscriptID?: string) => ManuscriptNode;
42
44
  addGeneratedLabels: (sections: Section[]) => Section[];
43
45
  parseContents: (contents: string, wrapper?: string, commentAnnotations?: CommentAnnotation[], options?: ParseOptions) => ManuscriptNode;
44
- private getKeywords;
45
46
  private getManuscriptID;
46
47
  private getFigcaption;
47
48
  private createTable;
48
49
  private createTableElementFooter;
49
50
  private createListing;
50
- private getKeywordGroups;
51
51
  }
@@ -25,6 +25,7 @@ export declare const guessSectionCategory: (elements: Element[]) => SectionCateg
25
25
  export declare const buildSectionCategory: (node: ManuscriptNode) => SectionCategory | undefined;
26
26
  export declare const chooseJatsFnType: (footnoteType: string) => string;
27
27
  export declare const chooseSecType: (sectionCategory: SectionCategory) => SecType;
28
+ export declare const chooseCoreSectionBySection: (section: string) => string;
28
29
  export declare const chooseSectionCategoryByType: (secType: string) => SectionCategory | undefined;
29
30
  export declare const chooseSectionCategory: (section: HTMLElement) => SectionCategory | undefined;
30
31
  export declare const chooseSectionCategoryFromTitle: (title: string | null) => 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.5.6",
4
+ "version": "1.5.7-LEAN-3030",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-transform",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -1,11 +0,0 @@
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 {};
@@ -1,12 +0,0 @@
1
- import { NodeSpec } from 'prosemirror-model';
2
- import { ManuscriptNode } from '../types';
3
- interface Attrs {
4
- id: string;
5
- contents: string;
6
- }
7
- export interface ContributorsSectionNode extends ManuscriptNode {
8
- attrs: Attrs;
9
- }
10
- export declare const contributorsSection: NodeSpec;
11
- export declare const isContributorsSectionNode: (node: ManuscriptNode) => node is ContributorsSectionNode;
12
- export {};