@manuscripts/transform 1.3.7 → 1.3.8
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 +1 -0
- package/dist/cjs/jats/importer/jats-body-transformations.js +1 -1
- package/dist/cjs/lib/core-section-categories.js +29 -0
- package/dist/cjs/transformer/section-category.js +6 -13
- package/dist/es/index.js +1 -0
- package/dist/es/jats/importer/jats-body-transformations.js +2 -2
- package/dist/es/lib/core-section-categories.js +26 -0
- package/dist/es/transformer/section-category.js +5 -9
- package/dist/types/index.d.ts +1 -0
- package/dist/types/lib/core-section-categories.d.ts +8 -0
- package/dist/types/transformer/section-category.d.ts +1 -1
- package/package.json +1 -3
package/dist/cjs/index.js
CHANGED
|
@@ -15,6 +15,7 @@ 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);
|
|
18
19
|
__exportStar(require("./lib/table-cell-styles"), exports);
|
|
19
20
|
__exportStar(require("./lib/utils"), exports);
|
|
20
21
|
__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.getCoreSectionTitles)(sectionCategory)[0]
|
|
29
29
|
: ' ';
|
|
30
30
|
sectionContainer.appendChild(title);
|
|
31
31
|
return sectionContainer;
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
];
|
|
@@ -14,13 +14,10 @@
|
|
|
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
|
-
};
|
|
20
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.chooseSectionCategoryFromTitle = exports.chooseSectionCategory = exports.chooseSectionCategoryByType = exports.chooseSecType = exports.chooseJatsFnType = exports.buildSectionCategory = exports.guessSectionCategory = exports.chooseSectionLableName = exports.chooseSectionNodeType = exports.isAnySectionNode = exports.
|
|
22
|
-
const section_categories_json_1 = __importDefault(require("@manuscripts/data/dist/shared/section-categories.json"));
|
|
18
|
+
exports.chooseSectionCategoryFromTitle = exports.chooseSectionCategory = exports.chooseSectionCategoryByType = exports.chooseSecType = exports.chooseJatsFnType = exports.buildSectionCategory = exports.guessSectionCategory = exports.chooseSectionLableName = exports.chooseSectionNodeType = exports.isAnySectionNode = exports.getCoreSectionTitles = void 0;
|
|
23
19
|
const json_schema_1 = require("@manuscripts/json-schema");
|
|
20
|
+
const core_section_categories_1 = require("../lib/core-section-categories");
|
|
24
21
|
const schema_1 = require("../schema");
|
|
25
22
|
const sectionNodeTypes = [
|
|
26
23
|
schema_1.schema.nodes.bibliography_section,
|
|
@@ -29,18 +26,14 @@ const sectionNodeTypes = [
|
|
|
29
26
|
schema_1.schema.nodes.section,
|
|
30
27
|
schema_1.schema.nodes.toc_section,
|
|
31
28
|
];
|
|
32
|
-
const
|
|
33
|
-
section._id
|
|
34
|
-
section,
|
|
35
|
-
]));
|
|
36
|
-
const getSectionTitles = (sectionCategory) => {
|
|
37
|
-
const category = sectionCategoriesMap.get(sectionCategory);
|
|
29
|
+
const getCoreSectionTitles = (sectionCategory) => {
|
|
30
|
+
const category = core_section_categories_1.coreSectionCategories.find((section) => section._id === sectionCategory);
|
|
38
31
|
if (category) {
|
|
39
32
|
return category.titles.length ? category.titles : [' '];
|
|
40
33
|
}
|
|
41
|
-
throw new Error(`${sectionCategory} not found in
|
|
34
|
+
throw new Error(`${sectionCategory} not found in core sections`);
|
|
42
35
|
};
|
|
43
|
-
exports.
|
|
36
|
+
exports.getCoreSectionTitles = getCoreSectionTitles;
|
|
44
37
|
const isAnySectionNode = (node) => sectionNodeTypes.includes(node.type);
|
|
45
38
|
exports.isAnySectionNode = isAnySectionNode;
|
|
46
39
|
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, getCoreSectionTitles, } 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
|
+
? getCoreSectionTitles(sectionCategory)[0]
|
|
26
26
|
: ' ';
|
|
27
27
|
sectionContainer.appendChild(title);
|
|
28
28
|
return sectionContainer;
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
];
|
|
@@ -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 { ObjectTypes } from '@manuscripts/json-schema';
|
|
17
|
+
import { coreSectionCategories } from '../lib/core-section-categories';
|
|
18
18
|
import { schema } from '../schema';
|
|
19
19
|
const sectionNodeTypes = [
|
|
20
20
|
schema.nodes.bibliography_section,
|
|
@@ -23,16 +23,12 @@ const sectionNodeTypes = [
|
|
|
23
23
|
schema.nodes.section,
|
|
24
24
|
schema.nodes.toc_section,
|
|
25
25
|
];
|
|
26
|
-
const
|
|
27
|
-
section._id
|
|
28
|
-
section,
|
|
29
|
-
]));
|
|
30
|
-
export const getSectionTitles = (sectionCategory) => {
|
|
31
|
-
const category = sectionCategoriesMap.get(sectionCategory);
|
|
26
|
+
export const getCoreSectionTitles = (sectionCategory) => {
|
|
27
|
+
const category = coreSectionCategories.find((section) => section._id === sectionCategory);
|
|
32
28
|
if (category) {
|
|
33
29
|
return category.titles.length ? category.titles : [' '];
|
|
34
30
|
}
|
|
35
|
-
throw new Error(`${sectionCategory} not found in
|
|
31
|
+
throw new Error(`${sectionCategory} not found in core sections`);
|
|
36
32
|
};
|
|
37
33
|
export const isAnySectionNode = (node) => sectionNodeTypes.includes(node.type);
|
|
38
34
|
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 getCoreSectionTitles: (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.8",
|
|
5
5
|
"repository": "github:Atypon-OpenSource/manuscripts-transform",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|
|
@@ -43,9 +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",
|
|
47
46
|
"@manuscripts/eslint-config": "^0.5.1",
|
|
48
|
-
"@manuscripts/examples": "^0.1.0",
|
|
49
47
|
"@types/debug": "^4.1.7",
|
|
50
48
|
"@types/jest": "^29.2.4",
|
|
51
49
|
"@types/lodash.pickby": "^4.6.7",
|