@manuscripts/transform 1.0.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.
- package/LICENSE +201 -0
- package/README.md +193 -0
- package/dist/cjs/errors.js +17 -0
- package/dist/cjs/index.js +27 -0
- package/dist/cjs/jats/importer/index.js +24 -0
- package/dist/cjs/jats/importer/jats-body-dom-parser.js +650 -0
- package/dist/cjs/jats/importer/jats-body-transformations.js +269 -0
- package/dist/cjs/jats/importer/jats-comments.js +131 -0
- package/dist/cjs/jats/importer/jats-front-parser.js +341 -0
- package/dist/cjs/jats/importer/jats-journal-meta-parser.js +77 -0
- package/dist/cjs/jats/importer/jats-parser-utils.js +145 -0
- package/dist/cjs/jats/importer/jats-reference-parser.js +180 -0
- package/dist/cjs/jats/importer/parse-jats-article.js +237 -0
- package/dist/cjs/jats/index.js +40 -0
- package/dist/cjs/jats/jats-exporter.js +1569 -0
- package/dist/cjs/jats/jats-versions.js +41 -0
- package/dist/cjs/lib/attributes.js +26 -0
- package/dist/cjs/lib/html.js +48 -0
- package/dist/cjs/lib/styled-content.js +28 -0
- package/dist/cjs/lib/table-cell-styles.js +52 -0
- package/dist/cjs/lib/utils.js +66 -0
- package/dist/cjs/mathjax/index.js +41 -0
- package/dist/cjs/mathjax/mathjax-packages.js +20 -0
- package/dist/cjs/mathjax/mathml-to-svg.js +56 -0
- package/dist/cjs/mathjax/tex-to-mathml.js +49 -0
- package/dist/cjs/mathjax/tex-to-svg.js +59 -0
- package/dist/cjs/schema/groups.js +31 -0
- package/dist/cjs/schema/index.js +195 -0
- package/dist/cjs/schema/marks.js +159 -0
- package/dist/cjs/schema/nodes/attribution.js +32 -0
- package/dist/cjs/schema/nodes/bibliography_element.js +44 -0
- package/dist/cjs/schema/nodes/bibliography_item.js +101 -0
- package/dist/cjs/schema/nodes/bibliography_section.js +46 -0
- package/dist/cjs/schema/nodes/blockquote_element.js +62 -0
- package/dist/cjs/schema/nodes/caption.js +52 -0
- package/dist/cjs/schema/nodes/caption_title.js +51 -0
- package/dist/cjs/schema/nodes/citation.js +52 -0
- package/dist/cjs/schema/nodes/comment.js +26 -0
- package/dist/cjs/schema/nodes/cross_reference.js +58 -0
- package/dist/cjs/schema/nodes/doc.js +21 -0
- package/dist/cjs/schema/nodes/equation.js +55 -0
- package/dist/cjs/schema/nodes/equation_element.js +52 -0
- package/dist/cjs/schema/nodes/figcaption.js +31 -0
- package/dist/cjs/schema/nodes/figure.js +52 -0
- package/dist/cjs/schema/nodes/figure_element.js +78 -0
- package/dist/cjs/schema/nodes/footnote.js +67 -0
- package/dist/cjs/schema/nodes/footnotes_element.js +54 -0
- package/dist/cjs/schema/nodes/footnotes_section.js +45 -0
- package/dist/cjs/schema/nodes/graphical_abstract_section.js +46 -0
- package/dist/cjs/schema/nodes/hard_break.js +30 -0
- package/dist/cjs/schema/nodes/highlight_marker.js +53 -0
- package/dist/cjs/schema/nodes/inline_equation.js +58 -0
- package/dist/cjs/schema/nodes/inline_footnote.js +51 -0
- package/dist/cjs/schema/nodes/keywords_element.js +52 -0
- package/dist/cjs/schema/nodes/keywords_section.js +46 -0
- package/dist/cjs/schema/nodes/link.js +61 -0
- package/dist/cjs/schema/nodes/list.js +121 -0
- package/dist/cjs/schema/nodes/listing.js +73 -0
- package/dist/cjs/schema/nodes/listing_element.js +52 -0
- package/dist/cjs/schema/nodes/manuscript.js +46 -0
- package/dist/cjs/schema/nodes/missing_figure.js +50 -0
- package/dist/cjs/schema/nodes/paragraph.js +63 -0
- package/dist/cjs/schema/nodes/placeholder.js +49 -0
- package/dist/cjs/schema/nodes/placeholder_element.js +48 -0
- package/dist/cjs/schema/nodes/pullquote_element.js +65 -0
- package/dist/cjs/schema/nodes/section.js +94 -0
- package/dist/cjs/schema/nodes/section_label.js +30 -0
- package/dist/cjs/schema/nodes/section_title.js +48 -0
- package/dist/cjs/schema/nodes/table.js +70 -0
- package/dist/cjs/schema/nodes/table_col.js +57 -0
- package/dist/cjs/schema/nodes/table_element.js +62 -0
- package/dist/cjs/schema/nodes/table_row.js +123 -0
- package/dist/cjs/schema/nodes/text.js +21 -0
- package/dist/cjs/schema/nodes/toc_element.js +52 -0
- package/dist/cjs/schema/nodes/toc_section.js +46 -0
- package/dist/cjs/schema/types.js +17 -0
- package/dist/cjs/tests.js +30 -0
- package/dist/cjs/transformer/builders.js +305 -0
- package/dist/cjs/transformer/bundles-data.js +36 -0
- package/dist/cjs/transformer/bundles.js +32 -0
- package/dist/cjs/transformer/decode.js +619 -0
- package/dist/cjs/transformer/document-object-types.js +31 -0
- package/dist/cjs/transformer/encode.js +545 -0
- package/dist/cjs/transformer/filename.js +27 -0
- package/dist/cjs/transformer/footnote-category.js +20 -0
- package/dist/cjs/transformer/footnotes-order.js +59 -0
- package/dist/cjs/transformer/highlight-markers.js +126 -0
- package/dist/cjs/transformer/html.js +414 -0
- package/dist/cjs/transformer/id.js +28 -0
- package/dist/cjs/transformer/index.js +54 -0
- package/dist/cjs/transformer/labels.js +85 -0
- package/dist/cjs/transformer/manuscript-dependencies.js +74 -0
- package/dist/cjs/transformer/model-map.js +26 -0
- package/dist/cjs/transformer/models.js +17 -0
- package/dist/cjs/transformer/node-names.js +42 -0
- package/dist/cjs/transformer/node-title.js +87 -0
- package/dist/cjs/transformer/node-types.js +62 -0
- package/dist/cjs/transformer/object-types.js +57 -0
- package/dist/cjs/transformer/project-bundle.js +86 -0
- package/dist/cjs/transformer/section-category.js +222 -0
- package/dist/cjs/transformer/serializer.js +23 -0
- package/dist/cjs/transformer/shared-data.js +31 -0
- package/dist/cjs/transformer/tei-grobid-importer.js +121 -0
- package/dist/cjs/transformer/timestamp.js +20 -0
- package/dist/cjs/transformer/update-identifiers.js +93 -0
- package/dist/cjs/types.js +2 -0
- package/dist/es/errors.js +12 -0
- package/dist/es/index.js +9 -0
- package/dist/es/jats/importer/index.js +16 -0
- package/dist/es/jats/importer/jats-body-dom-parser.js +644 -0
- package/dist/es/jats/importer/jats-body-transformations.js +266 -0
- package/dist/es/jats/importer/jats-comments.js +124 -0
- package/dist/es/jats/importer/jats-front-parser.js +335 -0
- package/dist/es/jats/importer/jats-journal-meta-parser.js +70 -0
- package/dist/es/jats/importer/jats-parser-utils.js +139 -0
- package/dist/es/jats/importer/jats-reference-parser.js +177 -0
- package/dist/es/jats/importer/parse-jats-article.js +229 -0
- package/dist/es/jats/index.js +18 -0
- package/dist/es/jats/jats-exporter.js +1561 -0
- package/dist/es/jats/jats-versions.js +36 -0
- package/dist/es/lib/attributes.js +22 -0
- package/dist/es/lib/html.js +43 -0
- package/dist/es/lib/styled-content.js +23 -0
- package/dist/es/lib/table-cell-styles.js +47 -0
- package/dist/es/lib/utils.js +59 -0
- package/dist/es/mathjax/index.js +12 -0
- package/dist/es/mathjax/mathjax-packages.js +17 -0
- package/dist/es/mathjax/mathml-to-svg.js +52 -0
- package/dist/es/mathjax/tex-to-mathml.js +45 -0
- package/dist/es/mathjax/tex-to-svg.js +55 -0
- package/dist/es/schema/groups.js +27 -0
- package/dist/es/schema/index.js +178 -0
- package/dist/es/schema/marks.js +156 -0
- package/dist/es/schema/nodes/attribution.js +29 -0
- package/dist/es/schema/nodes/bibliography_element.js +41 -0
- package/dist/es/schema/nodes/bibliography_item.js +98 -0
- package/dist/es/schema/nodes/bibliography_section.js +42 -0
- package/dist/es/schema/nodes/blockquote_element.js +58 -0
- package/dist/es/schema/nodes/caption.js +49 -0
- package/dist/es/schema/nodes/caption_title.js +48 -0
- package/dist/es/schema/nodes/citation.js +48 -0
- package/dist/es/schema/nodes/comment.js +23 -0
- package/dist/es/schema/nodes/cross_reference.js +55 -0
- package/dist/es/schema/nodes/doc.js +18 -0
- package/dist/es/schema/nodes/equation.js +52 -0
- package/dist/es/schema/nodes/equation_element.js +49 -0
- package/dist/es/schema/nodes/figcaption.js +28 -0
- package/dist/es/schema/nodes/figure.js +49 -0
- package/dist/es/schema/nodes/figure_element.js +74 -0
- package/dist/es/schema/nodes/footnote.js +63 -0
- package/dist/es/schema/nodes/footnotes_element.js +50 -0
- package/dist/es/schema/nodes/footnotes_section.js +41 -0
- package/dist/es/schema/nodes/graphical_abstract_section.js +42 -0
- package/dist/es/schema/nodes/hard_break.js +27 -0
- package/dist/es/schema/nodes/highlight_marker.js +49 -0
- package/dist/es/schema/nodes/inline_equation.js +55 -0
- package/dist/es/schema/nodes/inline_footnote.js +47 -0
- package/dist/es/schema/nodes/keywords_element.js +49 -0
- package/dist/es/schema/nodes/keywords_section.js +42 -0
- package/dist/es/schema/nodes/link.js +58 -0
- package/dist/es/schema/nodes/list.js +117 -0
- package/dist/es/schema/nodes/listing.js +69 -0
- package/dist/es/schema/nodes/listing_element.js +49 -0
- package/dist/es/schema/nodes/manuscript.js +43 -0
- package/dist/es/schema/nodes/missing_figure.js +47 -0
- package/dist/es/schema/nodes/paragraph.js +59 -0
- package/dist/es/schema/nodes/placeholder.js +46 -0
- package/dist/es/schema/nodes/placeholder_element.js +45 -0
- package/dist/es/schema/nodes/pullquote_element.js +61 -0
- package/dist/es/schema/nodes/section.js +90 -0
- package/dist/es/schema/nodes/section_label.js +26 -0
- package/dist/es/schema/nodes/section_title.js +44 -0
- package/dist/es/schema/nodes/table.js +67 -0
- package/dist/es/schema/nodes/table_col.js +54 -0
- package/dist/es/schema/nodes/table_element.js +59 -0
- package/dist/es/schema/nodes/table_row.js +120 -0
- package/dist/es/schema/nodes/text.js +18 -0
- package/dist/es/schema/nodes/toc_element.js +49 -0
- package/dist/es/schema/nodes/toc_section.js +42 -0
- package/dist/es/schema/types.js +16 -0
- package/dist/es/tests.js +28 -0
- package/dist/es/transformer/builders.js +261 -0
- package/dist/es/transformer/bundles-data.js +8 -0
- package/dist/es/transformer/bundles.js +27 -0
- package/dist/es/transformer/decode.js +608 -0
- package/dist/es/transformer/document-object-types.js +28 -0
- package/dist/es/transformer/encode.js +535 -0
- package/dist/es/transformer/filename.js +23 -0
- package/dist/es/transformer/footnote-category.js +16 -0
- package/dist/es/transformer/footnotes-order.js +53 -0
- package/dist/es/transformer/highlight-markers.js +120 -0
- package/dist/es/transformer/html.js +407 -0
- package/dist/es/transformer/id.js +23 -0
- package/dist/es/transformer/index.js +38 -0
- package/dist/es/transformer/labels.js +81 -0
- package/dist/es/transformer/manuscript-dependencies.js +64 -0
- package/dist/es/transformer/model-map.js +22 -0
- package/dist/es/transformer/models.js +16 -0
- package/dist/es/transformer/node-names.js +39 -0
- package/dist/es/transformer/node-title.js +82 -0
- package/dist/es/transformer/node-types.js +55 -0
- package/dist/es/transformer/object-types.js +52 -0
- package/dist/es/transformer/project-bundle.js +77 -0
- package/dist/es/transformer/section-category.js +210 -0
- package/dist/es/transformer/serializer.js +17 -0
- package/dist/es/transformer/shared-data.js +1 -0
- package/dist/es/transformer/tei-grobid-importer.js +115 -0
- package/dist/es/transformer/timestamp.js +16 -0
- package/dist/es/transformer/update-identifiers.js +87 -0
- package/dist/es/types.js +1 -0
- package/dist/types/errors.d.ts +6 -0
- package/dist/types/index.d.ts +9 -0
- package/dist/types/jats/importer/index.d.ts +16 -0
- package/dist/types/jats/importer/jats-body-dom-parser.d.ts +24 -0
- package/dist/types/jats/importer/jats-body-transformations.d.ts +31 -0
- package/dist/types/jats/importer/jats-comments.d.ts +26 -0
- package/dist/types/jats/importer/jats-front-parser.d.ts +62 -0
- package/dist/types/jats/importer/jats-journal-meta-parser.d.ts +37 -0
- package/dist/types/jats/importer/jats-parser-utils.d.ts +23 -0
- package/dist/types/jats/importer/jats-reference-parser.d.ts +23 -0
- package/dist/types/jats/importer/parse-jats-article.d.ts +30 -0
- package/dist/types/jats/index.d.ts +18 -0
- package/dist/types/jats/jats-exporter.d.ts +72 -0
- package/dist/types/jats/jats-versions.d.ts +23 -0
- package/dist/types/lib/attributes.d.ts +20 -0
- package/dist/types/lib/html.d.ts +17 -0
- package/dist/types/lib/styled-content.d.ts +22 -0
- package/dist/types/lib/table-cell-styles.d.ts +27 -0
- package/dist/types/lib/utils.d.ts +26 -0
- package/dist/types/mathjax/index.d.ts +3 -0
- package/dist/types/mathjax/mathjax-packages.d.ts +16 -0
- package/dist/types/mathjax/mathml-to-svg.d.ts +17 -0
- package/dist/types/mathjax/tex-to-mathml.d.ts +17 -0
- package/dist/types/mathjax/tex-to-svg.d.ts +17 -0
- package/dist/types/schema/groups.d.ts +22 -0
- package/dist/types/schema/index.d.ts +65 -0
- package/dist/types/schema/marks.d.ts +27 -0
- package/dist/types/schema/nodes/attribution.d.ts +21 -0
- package/dist/types/schema/nodes/bibliography_element.d.ts +26 -0
- package/dist/types/schema/nodes/bibliography_item.d.ts +36 -0
- package/dist/types/schema/nodes/bibliography_section.d.ts +26 -0
- package/dist/types/schema/nodes/blockquote_element.d.ts +28 -0
- package/dist/types/schema/nodes/caption.d.ts +25 -0
- package/dist/types/schema/nodes/caption_title.d.ts +25 -0
- package/dist/types/schema/nodes/citation.d.ts +27 -0
- package/dist/types/schema/nodes/comment.d.ts +31 -0
- package/dist/types/schema/nodes/cross_reference.d.ts +26 -0
- package/dist/types/schema/nodes/doc.d.ts +17 -0
- package/dist/types/schema/nodes/equation.d.ts +28 -0
- package/dist/types/schema/nodes/equation_element.d.ts +29 -0
- package/dist/types/schema/nodes/figcaption.d.ts +21 -0
- package/dist/types/schema/nodes/figure.d.ts +25 -0
- package/dist/types/schema/nodes/figure_element.d.ts +44 -0
- package/dist/types/schema/nodes/footnote.d.ts +32 -0
- package/dist/types/schema/nodes/footnotes_element.d.ts +28 -0
- package/dist/types/schema/nodes/footnotes_section.d.ts +26 -0
- package/dist/types/schema/nodes/graphical_abstract_section.d.ts +26 -0
- package/dist/types/schema/nodes/hard_break.d.ts +21 -0
- package/dist/types/schema/nodes/highlight_marker.d.ts +29 -0
- package/dist/types/schema/nodes/inline_equation.d.ts +28 -0
- package/dist/types/schema/nodes/inline_footnote.d.ts +27 -0
- package/dist/types/schema/nodes/keywords_element.d.ts +27 -0
- package/dist/types/schema/nodes/keywords_section.d.ts +26 -0
- package/dist/types/schema/nodes/link.d.ts +26 -0
- package/dist/types/schema/nodes/list.d.ts +39 -0
- package/dist/types/schema/nodes/listing.d.ts +33 -0
- package/dist/types/schema/nodes/listing_element.d.ts +29 -0
- package/dist/types/schema/nodes/manuscript.d.ts +23 -0
- package/dist/types/schema/nodes/missing_figure.d.ts +23 -0
- package/dist/types/schema/nodes/paragraph.d.ts +30 -0
- package/dist/types/schema/nodes/placeholder.d.ts +26 -0
- package/dist/types/schema/nodes/placeholder_element.d.ts +25 -0
- package/dist/types/schema/nodes/pullquote_element.d.ts +28 -0
- package/dist/types/schema/nodes/section.d.ts +36 -0
- package/dist/types/schema/nodes/section_label.d.ts +22 -0
- package/dist/types/schema/nodes/section_title.d.ts +22 -0
- package/dist/types/schema/nodes/table.d.ts +27 -0
- package/dist/types/schema/nodes/table_col.d.ts +24 -0
- package/dist/types/schema/nodes/table_element.d.ts +35 -0
- package/dist/types/schema/nodes/table_row.d.ts +41 -0
- package/dist/types/schema/nodes/text.d.ts +17 -0
- package/dist/types/schema/nodes/toc_element.d.ts +27 -0
- package/dist/types/schema/nodes/toc_section.d.ts +26 -0
- package/dist/types/schema/types.d.ts +45 -0
- package/dist/types/tests.d.ts +16 -0
- package/dist/types/transformer/builders.d.ts +74 -0
- package/dist/types/transformer/bundles-data.d.ts +3 -0
- package/dist/types/transformer/bundles.d.ts +3 -0
- package/dist/types/transformer/decode.d.ts +38 -0
- package/dist/types/transformer/document-object-types.d.ts +17 -0
- package/dist/types/transformer/encode.d.ts +29 -0
- package/dist/types/transformer/filename.d.ts +16 -0
- package/dist/types/transformer/footnote-category.d.ts +17 -0
- package/dist/types/transformer/footnotes-order.d.ts +23 -0
- package/dist/types/transformer/highlight-markers.d.ts +26 -0
- package/dist/types/transformer/html.d.ts +36 -0
- package/dist/types/transformer/id.d.ts +20 -0
- package/dist/types/transformer/index.d.ts +38 -0
- package/dist/types/transformer/labels.d.ts +24 -0
- package/dist/types/transformer/manuscript-dependencies.d.ts +12 -0
- package/dist/types/transformer/model-map.d.ts +19 -0
- package/dist/types/transformer/models.d.ts +48 -0
- package/dist/types/transformer/node-names.d.ts +17 -0
- package/dist/types/transformer/node-title.d.ts +19 -0
- package/dist/types/transformer/node-types.d.ts +22 -0
- package/dist/types/transformer/object-types.d.ts +29 -0
- package/dist/types/transformer/project-bundle.d.ts +30 -0
- package/dist/types/transformer/section-category.d.ts +28 -0
- package/dist/types/transformer/serializer.d.ts +19 -0
- package/dist/types/transformer/shared-data.d.ts +2 -0
- package/dist/types/transformer/tei-grobid-importer.d.ts +20 -0
- package/dist/types/transformer/timestamp.d.ts +16 -0
- package/dist/types/transformer/update-identifiers.d.ts +23 -0
- package/dist/types/types.d.ts +2 -0
- package/package.json +89 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { ObjectTypes, } from '@manuscripts/manuscripts-json-schema';
|
|
13
|
+
import { generateID } from './id';
|
|
14
|
+
import { hasObjectType } from './object-types';
|
|
15
|
+
import { loadSharedData } from './shared-data';
|
|
16
|
+
const isStatusLabel = hasObjectType(ObjectTypes.StatusLabel);
|
|
17
|
+
const isBundledModel = (model) => model.bundled === true;
|
|
18
|
+
const loadBundledData = async (file) => {
|
|
19
|
+
const models = await loadSharedData(file);
|
|
20
|
+
return models.filter(isBundledModel);
|
|
21
|
+
};
|
|
22
|
+
export const loadStyles = () => loadBundledData('styles');
|
|
23
|
+
export const loadKeywords = () => loadBundledData('keywords');
|
|
24
|
+
export const loadContributorRoles = () => loadBundledData('contributor-roles');
|
|
25
|
+
export const loadBundledDependencies = async () => {
|
|
26
|
+
const contributorRoles = await loadContributorRoles();
|
|
27
|
+
const keywords = await loadKeywords();
|
|
28
|
+
const styles = await loadStyles();
|
|
29
|
+
return [...contributorRoles, ...keywords.filter(isStatusLabel), ...styles];
|
|
30
|
+
};
|
|
31
|
+
export const fromPrototype = (model) => {
|
|
32
|
+
const { _id, _rev } = model, data = __rest(model, ["_id", "_rev"]);
|
|
33
|
+
const output = Object.assign(Object.assign({}, data), { prototype: _id, _id: generateID(model.objectType) });
|
|
34
|
+
return output;
|
|
35
|
+
};
|
|
36
|
+
export const getByPrototype = (modelMap, prototype) => {
|
|
37
|
+
for (const model of modelMap.values()) {
|
|
38
|
+
if (model.prototype === prototype) {
|
|
39
|
+
return model;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
const isParagraphStyle = hasObjectType(ObjectTypes.ParagraphStyle);
|
|
44
|
+
const chooseNewDefaultParagraphStyle = (styles) => {
|
|
45
|
+
for (const style of styles.values()) {
|
|
46
|
+
if (isParagraphStyle(style)) {
|
|
47
|
+
if (style.title === 'Body Text') {
|
|
48
|
+
return style;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
export const updatedPageLayout = (styleMap, pageLayoutID) => {
|
|
54
|
+
const newPageLayout = getByPrototype(styleMap, pageLayoutID);
|
|
55
|
+
if (!newPageLayout) {
|
|
56
|
+
throw new Error('Page layout not found');
|
|
57
|
+
}
|
|
58
|
+
const newDefaultParagraphStyle = getByPrototype(styleMap, newPageLayout.defaultParagraphStyle) || chooseNewDefaultParagraphStyle(styleMap);
|
|
59
|
+
if (!newDefaultParagraphStyle) {
|
|
60
|
+
throw new Error('Default paragraph style not found');
|
|
61
|
+
}
|
|
62
|
+
newPageLayout.defaultParagraphStyle = newDefaultParagraphStyle._id;
|
|
63
|
+
return newPageLayout;
|
|
64
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* © 2020 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 { generateID } from './id';
|
|
17
|
+
export const addModelToMap = (modelMap) => (data) => {
|
|
18
|
+
if (!data._id) {
|
|
19
|
+
data._id = generateID(data.objectType);
|
|
20
|
+
}
|
|
21
|
+
modelMap.set(data._id, data);
|
|
22
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
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 {};
|
|
@@ -0,0 +1,39 @@
|
|
|
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 { schema } from '../schema';
|
|
17
|
+
export const nodeNames = new Map([
|
|
18
|
+
[schema.nodes.bibliography_element, 'Bibliography'],
|
|
19
|
+
[schema.nodes.bibliography_section, 'Section'],
|
|
20
|
+
[schema.nodes.citation, 'Citation'],
|
|
21
|
+
[schema.nodes.listing_element, 'Listing'],
|
|
22
|
+
[schema.nodes.cross_reference, 'Cross Reference'],
|
|
23
|
+
[schema.nodes.equation_element, 'Equation'],
|
|
24
|
+
[schema.nodes.figure_element, 'Figure'],
|
|
25
|
+
[schema.nodes.footnote, 'Footnote'],
|
|
26
|
+
[schema.nodes.footnotes_element, 'Notes'],
|
|
27
|
+
[schema.nodes.bullet_list, 'Bullet List'],
|
|
28
|
+
[schema.nodes.ordered_list, 'Ordered List'],
|
|
29
|
+
[schema.nodes.manuscript, 'Manuscript'],
|
|
30
|
+
[schema.nodes.paragraph, 'Paragraph'],
|
|
31
|
+
[schema.nodes.section, 'Section'],
|
|
32
|
+
[schema.nodes.section_title, 'Section'],
|
|
33
|
+
[schema.nodes.table, 'Table'],
|
|
34
|
+
[schema.nodes.table_element, 'Table'],
|
|
35
|
+
[schema.nodes.blockquote_element, 'Block Quote'],
|
|
36
|
+
[schema.nodes.pullquote_element, 'Pull Quote'],
|
|
37
|
+
[schema.nodes.keywords_section, 'Section'],
|
|
38
|
+
[schema.nodes.toc_section, 'Section'],
|
|
39
|
+
]);
|
|
@@ -0,0 +1,82 @@
|
|
|
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 { iterateChildren } from '../lib/utils';
|
|
17
|
+
import { isHighlightMarkerNode } from '../schema';
|
|
18
|
+
import { nodeNames } from './node-names';
|
|
19
|
+
const textSnippet = (node, max = 100) => {
|
|
20
|
+
let text = '';
|
|
21
|
+
node.forEach((child) => {
|
|
22
|
+
if (child.isText) {
|
|
23
|
+
text += child.text;
|
|
24
|
+
}
|
|
25
|
+
else if (isHighlightMarkerNode(node)) {
|
|
26
|
+
text += '';
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
text += ' ';
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
return text.substr(0, max);
|
|
33
|
+
};
|
|
34
|
+
const snippetOfNodeType = (node, nodeType) => {
|
|
35
|
+
for (const child of iterateChildren(node, true)) {
|
|
36
|
+
if (child.type === nodeType) {
|
|
37
|
+
return textSnippet(child);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return null;
|
|
41
|
+
};
|
|
42
|
+
export const nodeTitle = (node) => {
|
|
43
|
+
const nodes = node.type.schema.nodes;
|
|
44
|
+
switch (node.type) {
|
|
45
|
+
case nodes.section:
|
|
46
|
+
case nodes.bibliography_section:
|
|
47
|
+
case nodes.footnotes_section:
|
|
48
|
+
case nodes.keywords_section:
|
|
49
|
+
case nodes.toc_section:
|
|
50
|
+
case nodes.graphical_abstract_section:
|
|
51
|
+
return snippetOfNodeType(node, nodes.section_title);
|
|
52
|
+
case nodes.footnotes_element:
|
|
53
|
+
return node.attrs.collateByKind === 'footnote' ? 'Footnotes' : 'Endnotes';
|
|
54
|
+
case nodes.ordered_list:
|
|
55
|
+
case nodes.bullet_list:
|
|
56
|
+
case nodes.blockquote_element:
|
|
57
|
+
case nodes.footnote:
|
|
58
|
+
case nodes.pullquote_element:
|
|
59
|
+
return snippetOfNodeType(node, nodes.paragraph);
|
|
60
|
+
case nodes.figure_element:
|
|
61
|
+
case nodes.table_element:
|
|
62
|
+
case nodes.equation_element:
|
|
63
|
+
case nodes.listing_element:
|
|
64
|
+
case nodes.multi_graphic_figure_element:
|
|
65
|
+
return '';
|
|
66
|
+
default:
|
|
67
|
+
return textSnippet(node);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
export const nodeTitlePlaceholder = (nodeType) => {
|
|
71
|
+
const nodes = nodeType.schema.nodes;
|
|
72
|
+
switch (nodeType) {
|
|
73
|
+
case nodes.title:
|
|
74
|
+
return 'Untitled Manuscript';
|
|
75
|
+
case nodes.section:
|
|
76
|
+
return 'Untitled Section';
|
|
77
|
+
case nodes.bibliography_section:
|
|
78
|
+
return 'Bibliography';
|
|
79
|
+
default:
|
|
80
|
+
return nodeNames.get(nodeType) || '';
|
|
81
|
+
}
|
|
82
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
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 { ObjectTypes } from '@manuscripts/manuscripts-json-schema';
|
|
17
|
+
import { GROUP_ELEMENT, GROUP_EXECUTABLE, GROUP_SECTION, hasGroup, schema, } from '../schema';
|
|
18
|
+
export const nodeTypesMap = new Map([
|
|
19
|
+
[schema.nodes.comment, ObjectTypes.CommentAnnotation],
|
|
20
|
+
[schema.nodes.bibliography_item, ObjectTypes.BibliographyItem],
|
|
21
|
+
[schema.nodes.bibliography_element, ObjectTypes.BibliographyElement],
|
|
22
|
+
[schema.nodes.bibliography_section, ObjectTypes.Section],
|
|
23
|
+
[schema.nodes.blockquote_element, ObjectTypes.QuoteElement],
|
|
24
|
+
[schema.nodes.bullet_list, ObjectTypes.ListElement],
|
|
25
|
+
[schema.nodes.citation, ObjectTypes.Citation],
|
|
26
|
+
[schema.nodes.cross_reference, ObjectTypes.AuxiliaryObjectReference],
|
|
27
|
+
[schema.nodes.equation, ObjectTypes.Equation],
|
|
28
|
+
[schema.nodes.equation_element, ObjectTypes.EquationElement],
|
|
29
|
+
[schema.nodes.figure, ObjectTypes.Figure],
|
|
30
|
+
[schema.nodes.missing_figure, ObjectTypes.MissingFigure],
|
|
31
|
+
[schema.nodes.figure_element, ObjectTypes.FigureElement],
|
|
32
|
+
[schema.nodes.footnote, ObjectTypes.Footnote],
|
|
33
|
+
[schema.nodes.footnotes_element, ObjectTypes.FootnotesElement],
|
|
34
|
+
[schema.nodes.footnotes_section, ObjectTypes.Section],
|
|
35
|
+
[schema.nodes.graphical_abstract_section, ObjectTypes.Section],
|
|
36
|
+
[schema.nodes.highlight_marker, ObjectTypes.HighlightMarker],
|
|
37
|
+
[schema.nodes.inline_equation, ObjectTypes.InlineMathFragment],
|
|
38
|
+
[schema.nodes.keywords_element, ObjectTypes.KeywordsElement],
|
|
39
|
+
[schema.nodes.keywords_section, ObjectTypes.Section],
|
|
40
|
+
[schema.nodes.listing, ObjectTypes.Listing],
|
|
41
|
+
[schema.nodes.listing_element, ObjectTypes.ListingElement],
|
|
42
|
+
[schema.nodes.manuscript, ObjectTypes.Manuscript],
|
|
43
|
+
[schema.nodes.ordered_list, ObjectTypes.ListElement],
|
|
44
|
+
[schema.nodes.paragraph, ObjectTypes.ParagraphElement],
|
|
45
|
+
[schema.nodes.pullquote_element, ObjectTypes.QuoteElement],
|
|
46
|
+
[schema.nodes.section, ObjectTypes.Section],
|
|
47
|
+
[schema.nodes.table, ObjectTypes.Table],
|
|
48
|
+
[schema.nodes.table_element, ObjectTypes.TableElement],
|
|
49
|
+
[schema.nodes.toc_element, ObjectTypes.TOCElement],
|
|
50
|
+
[schema.nodes.toc_section, ObjectTypes.Section],
|
|
51
|
+
]);
|
|
52
|
+
export const isExecutableNodeType = (type) => hasGroup(type, GROUP_EXECUTABLE);
|
|
53
|
+
export const isElementNodeType = (type) => hasGroup(type, GROUP_ELEMENT);
|
|
54
|
+
export const isSectionNodeType = (type) => hasGroup(type, GROUP_SECTION);
|
|
55
|
+
export const isNodeType = (node, type) => node.type === node.type.schema.nodes[type];
|
|
@@ -0,0 +1,52 @@
|
|
|
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 { manuscriptIDTypes, ObjectTypes, } from '@manuscripts/manuscripts-json-schema';
|
|
17
|
+
export var ExtraObjectTypes;
|
|
18
|
+
(function (ExtraObjectTypes) {
|
|
19
|
+
ExtraObjectTypes["PlaceholderElement"] = "MPPlaceholderElement";
|
|
20
|
+
})(ExtraObjectTypes || (ExtraObjectTypes = {}));
|
|
21
|
+
export const elementObjects = [
|
|
22
|
+
ObjectTypes.BibliographyElement,
|
|
23
|
+
ObjectTypes.EquationElement,
|
|
24
|
+
ObjectTypes.FigureElement,
|
|
25
|
+
ObjectTypes.FootnotesElement,
|
|
26
|
+
ObjectTypes.ListElement,
|
|
27
|
+
ObjectTypes.ListingElement,
|
|
28
|
+
ObjectTypes.ParagraphElement,
|
|
29
|
+
ObjectTypes.TableElement,
|
|
30
|
+
ObjectTypes.TOCElement,
|
|
31
|
+
];
|
|
32
|
+
export const manuscriptObjects = [
|
|
33
|
+
ObjectTypes.Affiliation,
|
|
34
|
+
ObjectTypes.Citation,
|
|
35
|
+
ObjectTypes.CommentAnnotation,
|
|
36
|
+
ObjectTypes.Contributor,
|
|
37
|
+
ObjectTypes.Footnote,
|
|
38
|
+
ObjectTypes.InlineMathFragment,
|
|
39
|
+
ObjectTypes.Section,
|
|
40
|
+
].concat(elementObjects);
|
|
41
|
+
export const isManuscriptModel = (model) => {
|
|
42
|
+
if (!model.objectType) {
|
|
43
|
+
throw new Error('Model must have objectType');
|
|
44
|
+
}
|
|
45
|
+
return manuscriptIDTypes.has(model.objectType);
|
|
46
|
+
};
|
|
47
|
+
export const hasObjectType = (objectType) => (model) => model.objectType === objectType;
|
|
48
|
+
export const isFigure = hasObjectType(ObjectTypes.Figure);
|
|
49
|
+
export const isManuscript = hasObjectType(ObjectTypes.Manuscript);
|
|
50
|
+
export const isTable = hasObjectType(ObjectTypes.Table);
|
|
51
|
+
export const isUserProfile = hasObjectType(ObjectTypes.UserProfile);
|
|
52
|
+
export const isCommentAnnotation = hasObjectType(ObjectTypes.CommentAnnotation);
|
|
@@ -0,0 +1,77 @@
|
|
|
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 { ObjectTypes, } from '@manuscripts/manuscripts-json-schema';
|
|
17
|
+
import { Decoder } from './decode';
|
|
18
|
+
import { hasObjectType } from './object-types';
|
|
19
|
+
export const parseProjectBundle = (projectBundle, manuscriptID) => {
|
|
20
|
+
const manuscriptData = manuscriptID
|
|
21
|
+
? projectBundle.data.filter((doc) => !doc.manuscriptID || doc.manuscriptID === manuscriptID)
|
|
22
|
+
: projectBundle.data;
|
|
23
|
+
const modelMap = new Map();
|
|
24
|
+
for (const component of manuscriptData) {
|
|
25
|
+
modelMap.set(component._id, component);
|
|
26
|
+
}
|
|
27
|
+
const decoder = new Decoder(modelMap);
|
|
28
|
+
const doc = decoder.createArticleNode();
|
|
29
|
+
return { doc, modelMap };
|
|
30
|
+
};
|
|
31
|
+
const isManuscript = hasObjectType(ObjectTypes.Manuscript);
|
|
32
|
+
export const findManuscript = (modelMap) => {
|
|
33
|
+
for (const model of modelMap.values()) {
|
|
34
|
+
if (isManuscript(model)) {
|
|
35
|
+
return model;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
throw new Error('No manuscript found');
|
|
39
|
+
};
|
|
40
|
+
const isJournal = hasObjectType(ObjectTypes.Journal);
|
|
41
|
+
export const findJournal = (modelMap) => {
|
|
42
|
+
for (const model of modelMap.values()) {
|
|
43
|
+
if (isJournal(model)) {
|
|
44
|
+
return model;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return null;
|
|
48
|
+
};
|
|
49
|
+
const isManuscriptModel = (model) => 'manuscriptID' in model;
|
|
50
|
+
export const findManuscriptModelByType = (modelMap, manuscript, objectType) => {
|
|
51
|
+
for (const model of modelMap.values()) {
|
|
52
|
+
if (model.objectType === objectType &&
|
|
53
|
+
isManuscriptModel(model) &&
|
|
54
|
+
manuscript._id === model.manuscriptID) {
|
|
55
|
+
return model;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
const isSubmission = hasObjectType(ObjectTypes.Submission);
|
|
60
|
+
const newestFirst = (a, b) => b.createdAt - a.createdAt;
|
|
61
|
+
export const findLatestManuscriptSubmission = (modelMap, manuscript) => {
|
|
62
|
+
const submissions = [];
|
|
63
|
+
for (const model of modelMap.values()) {
|
|
64
|
+
if (isSubmission(model) && model.manuscriptID === manuscript._id) {
|
|
65
|
+
submissions.push(model);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
submissions.sort(newestFirst);
|
|
69
|
+
return submissions.length ? submissions[0] : undefined;
|
|
70
|
+
};
|
|
71
|
+
export const findManuscriptById = (modelMap, manuscriptID) => {
|
|
72
|
+
const manuscript = modelMap.get(manuscriptID);
|
|
73
|
+
if (manuscript && isManuscript(manuscript)) {
|
|
74
|
+
return manuscript;
|
|
75
|
+
}
|
|
76
|
+
throw new Error(`There is no manuscript found for the following _id (${manuscriptID})`);
|
|
77
|
+
};
|
|
@@ -0,0 +1,210 @@
|
|
|
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 { ObjectTypes } from '@manuscripts/manuscripts-json-schema';
|
|
17
|
+
import { schema } from '../schema';
|
|
18
|
+
const sectionNodeTypes = [
|
|
19
|
+
schema.nodes.bibliography_section,
|
|
20
|
+
schema.nodes.footnotes_section,
|
|
21
|
+
schema.nodes.keywords_section,
|
|
22
|
+
schema.nodes.section,
|
|
23
|
+
schema.nodes.toc_section,
|
|
24
|
+
];
|
|
25
|
+
export const isAnySectionNode = (node) => sectionNodeTypes.includes(node.type);
|
|
26
|
+
export const chooseSectionNodeType = (category) => {
|
|
27
|
+
switch (category) {
|
|
28
|
+
case 'MPSectionCategory:bibliography':
|
|
29
|
+
return schema.nodes.bibliography_section;
|
|
30
|
+
case 'MPSectionCategory:abstract-graphical':
|
|
31
|
+
return schema.nodes.graphical_abstract_section;
|
|
32
|
+
case 'MPSectionCategory:endnotes':
|
|
33
|
+
return schema.nodes.footnotes_section;
|
|
34
|
+
case 'MPSectionCategory:keywords':
|
|
35
|
+
return schema.nodes.keywords_section;
|
|
36
|
+
case 'MPSectionCategory:toc':
|
|
37
|
+
return schema.nodes.toc_section;
|
|
38
|
+
default:
|
|
39
|
+
return schema.nodes.section;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
export const chooseSectionLableName = (type) => {
|
|
43
|
+
switch (type) {
|
|
44
|
+
case 'appendices':
|
|
45
|
+
return 'Appendix';
|
|
46
|
+
default:
|
|
47
|
+
return type;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
export const guessSectionCategory = (elements) => {
|
|
51
|
+
if (!elements.length) {
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
switch (elements[0].objectType) {
|
|
55
|
+
case ObjectTypes.BibliographyElement:
|
|
56
|
+
return 'MPSectionCategory:bibliography';
|
|
57
|
+
case ObjectTypes.FootnotesElement:
|
|
58
|
+
return 'MPSectionCategory:endnotes';
|
|
59
|
+
case ObjectTypes.KeywordsElement:
|
|
60
|
+
return 'MPSectionCategory:keywords';
|
|
61
|
+
case ObjectTypes.TOCElement:
|
|
62
|
+
return 'MPSectionCategory:toc';
|
|
63
|
+
default:
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
export const buildSectionCategory = (node) => {
|
|
68
|
+
switch (node.type) {
|
|
69
|
+
case schema.nodes.bibliography_section:
|
|
70
|
+
return 'MPSectionCategory:bibliography';
|
|
71
|
+
case schema.nodes.footnotes_section:
|
|
72
|
+
return 'MPSectionCategory:endnotes';
|
|
73
|
+
case schema.nodes.keywords_section:
|
|
74
|
+
return 'MPSectionCategory:keywords';
|
|
75
|
+
case schema.nodes.toc_section:
|
|
76
|
+
return 'MPSectionCategory:toc';
|
|
77
|
+
case schema.nodes.graphical_abstract_section:
|
|
78
|
+
return 'MPSectionCategory:abstract-graphical';
|
|
79
|
+
default:
|
|
80
|
+
return node.attrs.category || undefined;
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
export const chooseSecType = (sectionCategory) => {
|
|
84
|
+
const [, suffix] = sectionCategory.split(':', 2);
|
|
85
|
+
switch (suffix) {
|
|
86
|
+
case 'acknowledgement':
|
|
87
|
+
return 'acknowledgments';
|
|
88
|
+
case 'introduction':
|
|
89
|
+
return 'intro';
|
|
90
|
+
case 'materials-method':
|
|
91
|
+
return 'methods';
|
|
92
|
+
default:
|
|
93
|
+
return suffix;
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
export const chooseSectionCategoryByType = (secType) => {
|
|
97
|
+
switch (secType) {
|
|
98
|
+
case 'abstract':
|
|
99
|
+
return 'MPSectionCategory:abstract';
|
|
100
|
+
case 'abstract-teaser':
|
|
101
|
+
return 'MPSectionCategory:abstract-teaser';
|
|
102
|
+
case 'abstract-graphical':
|
|
103
|
+
return 'MPSectionCategory:abstract-graphical';
|
|
104
|
+
case 'acknowledgments':
|
|
105
|
+
return 'MPSectionCategory:acknowledgement';
|
|
106
|
+
case 'availability':
|
|
107
|
+
case 'data-availability':
|
|
108
|
+
return 'MPSectionCategory:availability';
|
|
109
|
+
case 'bibliography':
|
|
110
|
+
return 'MPSectionCategory:bibliography';
|
|
111
|
+
case 'conclusions':
|
|
112
|
+
return 'MPSectionCategory:conclusions';
|
|
113
|
+
case 'discussion':
|
|
114
|
+
return 'MPSectionCategory:discussion';
|
|
115
|
+
case 'endnotes':
|
|
116
|
+
return 'MPSectionCategory:endnotes';
|
|
117
|
+
case 'intro':
|
|
118
|
+
return 'MPSectionCategory:introduction';
|
|
119
|
+
case 'keywords':
|
|
120
|
+
return 'MPSectionCategory:keywords';
|
|
121
|
+
case 'materials':
|
|
122
|
+
case 'methods':
|
|
123
|
+
return 'MPSectionCategory:materials-method';
|
|
124
|
+
case 'results':
|
|
125
|
+
return 'MPSectionCategory:results';
|
|
126
|
+
case 'toc':
|
|
127
|
+
return 'MPSectionCategory:toc';
|
|
128
|
+
case 'floating-element':
|
|
129
|
+
return 'MPSectionCategory:floating-element';
|
|
130
|
+
case 'appendices':
|
|
131
|
+
return 'MPSectionCategory:appendices';
|
|
132
|
+
case 'competing-interests':
|
|
133
|
+
case 'conflict':
|
|
134
|
+
return 'MPSectionCategory:competing-interests';
|
|
135
|
+
case 'financial-disclosure':
|
|
136
|
+
return 'MPSectionCategory:financial-disclosure';
|
|
137
|
+
case 'con':
|
|
138
|
+
return 'MPSectionCategory:con';
|
|
139
|
+
case 'deceased':
|
|
140
|
+
return 'MPSectionCategory:deceased';
|
|
141
|
+
case 'equal':
|
|
142
|
+
return 'MPSectionCategory:equal';
|
|
143
|
+
case 'present-address':
|
|
144
|
+
return 'MPSectionCategory:present-address';
|
|
145
|
+
case 'presented-at':
|
|
146
|
+
return 'MPSectionCategory:presented-at';
|
|
147
|
+
case 'previously-at':
|
|
148
|
+
return 'MPSectionCategory:previously-at';
|
|
149
|
+
case 'supplementary-material':
|
|
150
|
+
return 'MPSectionCategory:supplementary-material';
|
|
151
|
+
case 'supported-by':
|
|
152
|
+
return 'MPSectionCategory:supported-by';
|
|
153
|
+
case 'ethics-statement':
|
|
154
|
+
return 'MPSectionCategory:ethics-statement';
|
|
155
|
+
default:
|
|
156
|
+
return undefined;
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
export const chooseSectionCategory = (section) => {
|
|
160
|
+
const secType = section.getAttribute('sec-type');
|
|
161
|
+
const secCat = chooseSectionCategoryByType(secType);
|
|
162
|
+
if (secCat) {
|
|
163
|
+
return secCat;
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
const titleNode = section.firstElementChild;
|
|
167
|
+
if (titleNode && titleNode.nodeName === 'title' && titleNode.textContent) {
|
|
168
|
+
return chooseSectionCategoryFromTitle(titleNode.textContent.trim().toLowerCase());
|
|
169
|
+
}
|
|
170
|
+
return undefined;
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
export const chooseSectionCategoryFromTitle = (title) => {
|
|
174
|
+
if (!title) {
|
|
175
|
+
return undefined;
|
|
176
|
+
}
|
|
177
|
+
switch (title) {
|
|
178
|
+
case 'abstract':
|
|
179
|
+
return 'MPSectionCategory:abstract';
|
|
180
|
+
case 'acknowledgments':
|
|
181
|
+
case 'acknowledgements':
|
|
182
|
+
return 'MPSectionCategory:acknowledgement';
|
|
183
|
+
case 'availability':
|
|
184
|
+
case 'data availability':
|
|
185
|
+
return 'MPSectionCategory:availability';
|
|
186
|
+
case 'conclusions':
|
|
187
|
+
return 'MPSectionCategory:conclusions';
|
|
188
|
+
case 'discussion':
|
|
189
|
+
return 'MPSectionCategory:discussion';
|
|
190
|
+
case 'introduction':
|
|
191
|
+
return 'MPSectionCategory:introduction';
|
|
192
|
+
case 'methods':
|
|
193
|
+
case 'materials':
|
|
194
|
+
case 'materials and methods':
|
|
195
|
+
case 'materials & methods':
|
|
196
|
+
return 'MPSectionCategory:materials-method';
|
|
197
|
+
case 'results':
|
|
198
|
+
return 'MPSectionCategory:results';
|
|
199
|
+
case 'bibliography':
|
|
200
|
+
case 'references':
|
|
201
|
+
return 'MPSectionCategory:bibliography';
|
|
202
|
+
case 'conflict':
|
|
203
|
+
case 'conflict of interest':
|
|
204
|
+
case 'competing interests':
|
|
205
|
+
return 'MPSectionCategory:competing-interests';
|
|
206
|
+
case 'financial-disclosure':
|
|
207
|
+
case 'funding information':
|
|
208
|
+
return 'MPSectionCategory:financial-disclosure';
|
|
209
|
+
}
|
|
210
|
+
};
|
|
@@ -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 serializeToString from 'w3c-xmlserializer';
|
|
17
|
+
export const xmlSerializer = { serializeToString };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const loadSharedData = (file) => import(`@manuscripts/data/dist/shared/${file}.json`).then((module) => module.default);
|