@manuscripts/transform 1.3.6-LEAN-2650-v2 → 1.3.7
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/dist/cjs/index.js +0 -1
- package/dist/cjs/jats/importer/jats-body-transformations.js +8 -6
- package/dist/cjs/schema/nodes/bibliography_item.js +1 -0
- package/dist/cjs/transformer/section-category.js +13 -6
- package/dist/es/index.js +0 -1
- package/dist/es/jats/importer/jats-body-transformations.js +9 -7
- package/dist/es/schema/nodes/bibliography_item.js +1 -0
- package/dist/es/transformer/section-category.js +9 -5
- package/dist/types/index.d.ts +0 -1
- package/dist/types/transformer/section-category.d.ts +1 -1
- package/package.json +2 -1
- package/dist/cjs/lib/core-section-categories.js +0 -29
- package/dist/es/lib/core-section-categories.js +0 -26
- package/dist/types/lib/core-section-categories.d.ts +0 -8
package/dist/cjs/index.js
CHANGED
|
@@ -15,7 +15,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.isSectionLabelNode = void 0;
|
|
18
|
-
__exportStar(require("./lib/core-section-categories"), exports);
|
|
19
18
|
__exportStar(require("./lib/table-cell-styles"), exports);
|
|
20
19
|
__exportStar(require("./lib/utils"), exports);
|
|
21
20
|
__exportStar(require("./mathjax"), exports);
|
|
@@ -25,7 +25,7 @@ const createSectionContainer = (type, createElement) => {
|
|
|
25
25
|
sectionContainer.setAttribute('sec-type', sectionCategory ? (0, transformer_1.chooseSecType)(sectionCategory) : '');
|
|
26
26
|
const title = createElement('title');
|
|
27
27
|
title.textContent = sectionCategory
|
|
28
|
-
? (0, transformer_1.
|
|
28
|
+
? (0, transformer_1.getSectionTitles)(sectionCategory)[0]
|
|
29
29
|
: ' ';
|
|
30
30
|
sectionContainer.appendChild(title);
|
|
31
31
|
return sectionContainer;
|
|
@@ -63,11 +63,13 @@ exports.jatsBodyTransformations = {
|
|
|
63
63
|
const section = createElement('sec');
|
|
64
64
|
const sectionType = abstractType ? `abstract-${abstractType}` : 'abstract';
|
|
65
65
|
section.setAttribute('sec-type', sectionType);
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
66
|
+
if (!abstractNode.querySelector('abstract > title')) {
|
|
67
|
+
const title = createElement('title');
|
|
68
|
+
title.textContent = abstractType
|
|
69
|
+
? `${capitalizeFirstLetter(abstractType)} Abstract`
|
|
70
|
+
: 'Abstract';
|
|
71
|
+
section.appendChild(title);
|
|
72
|
+
}
|
|
71
73
|
while (abstractNode.firstChild) {
|
|
72
74
|
section.appendChild(abstractNode.firstChild);
|
|
73
75
|
}
|
|
@@ -14,10 +14,13 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
+
};
|
|
17
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.chooseSectionCategoryFromTitle = exports.chooseSectionCategory = exports.chooseSectionCategoryByType = exports.chooseSecType = exports.chooseJatsFnType = exports.buildSectionCategory = exports.guessSectionCategory = exports.chooseSectionLableName = exports.chooseSectionNodeType = exports.isAnySectionNode = exports.
|
|
21
|
+
exports.chooseSectionCategoryFromTitle = exports.chooseSectionCategory = exports.chooseSectionCategoryByType = exports.chooseSecType = exports.chooseJatsFnType = exports.buildSectionCategory = exports.guessSectionCategory = exports.chooseSectionLableName = exports.chooseSectionNodeType = exports.isAnySectionNode = exports.getSectionTitles = void 0;
|
|
22
|
+
const section_categories_json_1 = __importDefault(require("@manuscripts/data/dist/shared/section-categories.json"));
|
|
19
23
|
const json_schema_1 = require("@manuscripts/json-schema");
|
|
20
|
-
const core_section_categories_1 = require("../lib/core-section-categories");
|
|
21
24
|
const schema_1 = require("../schema");
|
|
22
25
|
const sectionNodeTypes = [
|
|
23
26
|
schema_1.schema.nodes.bibliography_section,
|
|
@@ -26,14 +29,18 @@ const sectionNodeTypes = [
|
|
|
26
29
|
schema_1.schema.nodes.section,
|
|
27
30
|
schema_1.schema.nodes.toc_section,
|
|
28
31
|
];
|
|
29
|
-
const
|
|
30
|
-
|
|
32
|
+
const sectionCategoriesMap = new Map(section_categories_json_1.default.map((section) => [
|
|
33
|
+
section._id,
|
|
34
|
+
section,
|
|
35
|
+
]));
|
|
36
|
+
const getSectionTitles = (sectionCategory) => {
|
|
37
|
+
const category = sectionCategoriesMap.get(sectionCategory);
|
|
31
38
|
if (category) {
|
|
32
39
|
return category.titles.length ? category.titles : [' '];
|
|
33
40
|
}
|
|
34
|
-
throw new Error(`${sectionCategory} not found in
|
|
41
|
+
throw new Error(`${sectionCategory} not found in section categories`);
|
|
35
42
|
};
|
|
36
|
-
exports.
|
|
43
|
+
exports.getSectionTitles = getSectionTitles;
|
|
37
44
|
const isAnySectionNode = (node) => sectionNodeTypes.includes(node.type);
|
|
38
45
|
exports.isAnySectionNode = isAnySectionNode;
|
|
39
46
|
const chooseSectionNodeType = (category) => {
|
package/dist/es/index.js
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { chooseSectionCategoryByType, chooseSecType,
|
|
16
|
+
import { chooseSectionCategoryByType, chooseSecType, getSectionTitles, } from '../../transformer';
|
|
17
17
|
const removeNodeFromParent = (node) => node.parentNode && node.parentNode.removeChild(node);
|
|
18
18
|
const capitalizeFirstLetter = (str) => str.charAt(0).toUpperCase() + str.slice(1);
|
|
19
19
|
const createSectionContainer = (type, createElement) => {
|
|
@@ -22,7 +22,7 @@ const createSectionContainer = (type, createElement) => {
|
|
|
22
22
|
sectionContainer.setAttribute('sec-type', sectionCategory ? chooseSecType(sectionCategory) : '');
|
|
23
23
|
const title = createElement('title');
|
|
24
24
|
title.textContent = sectionCategory
|
|
25
|
-
?
|
|
25
|
+
? getSectionTitles(sectionCategory)[0]
|
|
26
26
|
: ' ';
|
|
27
27
|
sectionContainer.appendChild(title);
|
|
28
28
|
return sectionContainer;
|
|
@@ -60,11 +60,13 @@ export const jatsBodyTransformations = {
|
|
|
60
60
|
const section = createElement('sec');
|
|
61
61
|
const sectionType = abstractType ? `abstract-${abstractType}` : 'abstract';
|
|
62
62
|
section.setAttribute('sec-type', sectionType);
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
63
|
+
if (!abstractNode.querySelector('abstract > title')) {
|
|
64
|
+
const title = createElement('title');
|
|
65
|
+
title.textContent = abstractType
|
|
66
|
+
? `${capitalizeFirstLetter(abstractType)} Abstract`
|
|
67
|
+
: 'Abstract';
|
|
68
|
+
section.appendChild(title);
|
|
69
|
+
}
|
|
68
70
|
while (abstractNode.firstChild) {
|
|
69
71
|
section.appendChild(abstractNode.firstChild);
|
|
70
72
|
}
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import
|
|
17
|
-
import {
|
|
16
|
+
import sectionCategories from '@manuscripts/data/dist/shared/section-categories.json';
|
|
17
|
+
import { ObjectTypes, } from '@manuscripts/json-schema';
|
|
18
18
|
import { schema } from '../schema';
|
|
19
19
|
const sectionNodeTypes = [
|
|
20
20
|
schema.nodes.bibliography_section,
|
|
@@ -23,12 +23,16 @@ const sectionNodeTypes = [
|
|
|
23
23
|
schema.nodes.section,
|
|
24
24
|
schema.nodes.toc_section,
|
|
25
25
|
];
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
const sectionCategoriesMap = new Map(sectionCategories.map((section) => [
|
|
27
|
+
section._id,
|
|
28
|
+
section,
|
|
29
|
+
]));
|
|
30
|
+
export const getSectionTitles = (sectionCategory) => {
|
|
31
|
+
const category = sectionCategoriesMap.get(sectionCategory);
|
|
28
32
|
if (category) {
|
|
29
33
|
return category.titles.length ? category.titles : [' '];
|
|
30
34
|
}
|
|
31
|
-
throw new Error(`${sectionCategory} not found in
|
|
35
|
+
throw new Error(`${sectionCategory} not found in section categories`);
|
|
32
36
|
};
|
|
33
37
|
export const isAnySectionNode = (node) => sectionNodeTypes.includes(node.type);
|
|
34
38
|
export const chooseSectionNodeType = (category) => {
|
package/dist/types/index.d.ts
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { Element } from '@manuscripts/json-schema';
|
|
17
17
|
import { ManuscriptNode, ManuscriptNodeType } from '../schema';
|
|
18
|
-
export declare const
|
|
18
|
+
export declare const getSectionTitles: (sectionCategory: SectionCategory) => string[];
|
|
19
19
|
export declare const isAnySectionNode: (node: ManuscriptNode) => boolean;
|
|
20
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
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';
|
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.3.
|
|
4
|
+
"version": "1.3.7",
|
|
5
5
|
"repository": "github:Atypon-OpenSource/manuscripts-transform",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
"@babel/preset-env": "^7.20.2",
|
|
44
44
|
"@babel/preset-typescript": "^7.18.6",
|
|
45
45
|
"@jats4r/dtds": "^0.0.8",
|
|
46
|
+
"@manuscripts/data": "^1.0.2",
|
|
46
47
|
"@manuscripts/eslint-config": "^0.5.1",
|
|
47
48
|
"@manuscripts/examples": "^0.1.0",
|
|
48
49
|
"@types/debug": "^4.1.7",
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.coreSectionCategories = void 0;
|
|
4
|
-
exports.coreSectionCategories = [
|
|
5
|
-
{
|
|
6
|
-
_id: 'MPSectionCategory:abstracts',
|
|
7
|
-
name: 'Abstracts',
|
|
8
|
-
desc: 'Abstracts section for grouping',
|
|
9
|
-
objectType: 'MPSectionCategory',
|
|
10
|
-
titles: [],
|
|
11
|
-
priority: 120,
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
_id: 'MPSectionCategory:backmatter',
|
|
15
|
-
name: 'Backmatter',
|
|
16
|
-
desc: 'Backmatter section for grouping',
|
|
17
|
-
objectType: 'MPSectionCategory',
|
|
18
|
-
titles: [],
|
|
19
|
-
priority: 170,
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
_id: 'MPSectionCategory:body',
|
|
23
|
-
name: 'Body',
|
|
24
|
-
desc: 'Body section for grouping',
|
|
25
|
-
objectType: 'MPSectionCategory',
|
|
26
|
-
titles: [],
|
|
27
|
-
priority: 190,
|
|
28
|
-
},
|
|
29
|
-
];
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export const coreSectionCategories = [
|
|
2
|
-
{
|
|
3
|
-
_id: 'MPSectionCategory:abstracts',
|
|
4
|
-
name: 'Abstracts',
|
|
5
|
-
desc: 'Abstracts section for grouping',
|
|
6
|
-
objectType: 'MPSectionCategory',
|
|
7
|
-
titles: [],
|
|
8
|
-
priority: 120,
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
_id: 'MPSectionCategory:backmatter',
|
|
12
|
-
name: 'Backmatter',
|
|
13
|
-
desc: 'Backmatter section for grouping',
|
|
14
|
-
objectType: 'MPSectionCategory',
|
|
15
|
-
titles: [],
|
|
16
|
-
priority: 170,
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
_id: 'MPSectionCategory:body',
|
|
20
|
-
name: 'Body',
|
|
21
|
-
desc: 'Body section for grouping',
|
|
22
|
-
objectType: 'MPSectionCategory',
|
|
23
|
-
titles: [],
|
|
24
|
-
priority: 190,
|
|
25
|
-
},
|
|
26
|
-
];
|