@manuscripts/transform 2.3.21 → 2.3.22-JSR
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/jats/importer/jats-body-transformations.js +1 -1
- package/dist/cjs/jats/jats-exporter.js +1 -1
- package/dist/cjs/schema/migration/migration-scripts/2.3.22.js +28 -0
- package/dist/cjs/schema/migration/migration-scripts/index.js +2 -1
- package/dist/cjs/schema/nodes/manuscript.js +3 -0
- package/dist/cjs/schema/nodes/table_element.js +1 -1
- package/dist/cjs/transformer/decode.js +8 -5
- package/dist/cjs/transformer/html.js +1 -2
- package/dist/cjs/transformer/labels.js +3 -16
- package/dist/cjs/version.js +1 -1
- package/dist/es/jats/importer/jats-body-transformations.js +1 -1
- package/dist/es/jats/jats-exporter.js +1 -1
- package/dist/es/schema/migration/migration-scripts/2.3.22.js +26 -0
- package/dist/es/schema/migration/migration-scripts/index.js +2 -1
- package/dist/es/schema/nodes/manuscript.js +3 -0
- package/dist/es/schema/nodes/table_element.js +1 -1
- package/dist/es/transformer/decode.js +8 -5
- package/dist/es/transformer/html.js +1 -2
- package/dist/es/transformer/labels.js +3 -16
- package/dist/es/version.js +1 -1
- package/dist/types/schema/migration/migration-scripts/2.3.22.d.ts +8 -0
- package/dist/types/schema/migration/migration-scripts/index.d.ts +2 -1
- package/dist/types/schema/nodes/manuscript.d.ts +3 -0
- package/dist/types/transformer/decode.d.ts +1 -1
- package/dist/types/transformer/labels.d.ts +1 -2
- package/dist/types/version.d.ts +1 -1
- package/package.json +2 -2
|
@@ -221,7 +221,7 @@ exports.jatsBodyTransformations = {
|
|
|
221
221
|
moveCaptionsToEnd(body) {
|
|
222
222
|
const captions = body.querySelectorAll('caption');
|
|
223
223
|
for (const caption of captions) {
|
|
224
|
-
if (caption.parentNode) {
|
|
224
|
+
if (caption.parentNode && caption.parentNode.nodeName !== 'table-wrap') {
|
|
225
225
|
caption.parentNode.appendChild(caption);
|
|
226
226
|
}
|
|
227
227
|
}
|
|
@@ -143,7 +143,7 @@ class JATSExporter {
|
|
|
143
143
|
const manuscript = (0, project_bundle_1.findManuscriptById)(this.modelMap, manuscriptID);
|
|
144
144
|
article.setAttribute('article-type', manuscript.articleType || 'other');
|
|
145
145
|
if (!frontMatterOnly) {
|
|
146
|
-
this.labelTargets = (0, labels_1.buildTargets)(fragment
|
|
146
|
+
this.labelTargets = (0, labels_1.buildTargets)(fragment);
|
|
147
147
|
const body = this.buildBody(fragment);
|
|
148
148
|
article.appendChild(body);
|
|
149
149
|
const back = this.buildBack(body);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class Migration2322 {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.fromVersion = '2.3.21';
|
|
6
|
+
this.toVersion = '2.3.22';
|
|
7
|
+
}
|
|
8
|
+
migrateNode(node) {
|
|
9
|
+
if (node.type === 'table_element' && Array.isArray(node.content)) {
|
|
10
|
+
let figcaptionNode = null;
|
|
11
|
+
const remainingContent = [];
|
|
12
|
+
for (const child of node.content) {
|
|
13
|
+
if (child.type === 'figcaption') {
|
|
14
|
+
figcaptionNode = child;
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
remainingContent.push(child);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
const newContent = figcaptionNode
|
|
21
|
+
? [figcaptionNode, ...remainingContent]
|
|
22
|
+
: remainingContent;
|
|
23
|
+
return Object.assign(Object.assign({}, node), { content: newContent });
|
|
24
|
+
}
|
|
25
|
+
return node;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.default = Migration2322;
|
|
@@ -19,5 +19,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
19
19
|
};
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
21
|
const _1_2_5_1 = __importDefault(require("./1.2.5"));
|
|
22
|
-
const
|
|
22
|
+
const _2_3_22_1 = __importDefault(require("./2.3.22"));
|
|
23
|
+
const migrations = [new _1_2_5_1.default(), new _2_3_22_1.default()];
|
|
23
24
|
exports.default = migrations;
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.tableElement = void 0;
|
|
19
19
|
exports.tableElement = {
|
|
20
|
-
content: '(table | placeholder) table_colgroup? table_element_footer?
|
|
20
|
+
content: ' figcaption? (table | placeholder) table_colgroup? table_element_footer? (listing | placeholder)',
|
|
21
21
|
attrs: {
|
|
22
22
|
id: { default: '' },
|
|
23
23
|
paragraphStyle: { default: '' },
|
|
@@ -615,14 +615,13 @@ class Decoder {
|
|
|
615
615
|
const figcaption = this.getFigcaption(model);
|
|
616
616
|
const comments = this.createCommentNodes(model);
|
|
617
617
|
comments.forEach((c) => this.comments.set(c.attrs.id, c));
|
|
618
|
-
const content = [table];
|
|
618
|
+
const content = [figcaption, table];
|
|
619
619
|
if (tableColGroup) {
|
|
620
620
|
content.push(tableColGroup);
|
|
621
621
|
}
|
|
622
622
|
if (tableElementFooter) {
|
|
623
623
|
content.push(tableElementFooter);
|
|
624
624
|
}
|
|
625
|
-
content.push(figcaption);
|
|
626
625
|
const listing = model.listingID
|
|
627
626
|
? this.createListing(model.listingID)
|
|
628
627
|
: schema_1.schema.nodes.listing.create();
|
|
@@ -727,9 +726,13 @@ class Decoder {
|
|
|
727
726
|
this.createCommentsNode(),
|
|
728
727
|
];
|
|
729
728
|
const contents = nodes.filter((node) => node !== false);
|
|
729
|
+
const props = this.getManuscript();
|
|
730
730
|
return schema_1.schema.nodes.manuscript.create({
|
|
731
731
|
id: manuscriptID || this.getManuscriptID(),
|
|
732
|
-
doi:
|
|
732
|
+
doi: (props === null || props === void 0 ? void 0 : props.DOI) || '',
|
|
733
|
+
articleType: props === null || props === void 0 ? void 0 : props.articleType,
|
|
734
|
+
prototype: props === null || props === void 0 ? void 0 : props.prototype,
|
|
735
|
+
primaryLanguageCode: props === null || props === void 0 ? void 0 : props.primaryLanguageCode,
|
|
733
736
|
}, contents);
|
|
734
737
|
};
|
|
735
738
|
this.addGeneratedLabels = (sections) => {
|
|
@@ -775,10 +778,10 @@ class Decoder {
|
|
|
775
778
|
}
|
|
776
779
|
}
|
|
777
780
|
};
|
|
778
|
-
this.
|
|
781
|
+
this.getManuscript = () => {
|
|
779
782
|
for (const item of this.modelMap.values()) {
|
|
780
783
|
if ((0, object_types_1.isManuscript)(item)) {
|
|
781
|
-
return item
|
|
784
|
+
return item;
|
|
782
785
|
}
|
|
783
786
|
}
|
|
784
787
|
};
|
|
@@ -75,8 +75,7 @@ class HTMLTransformer {
|
|
|
75
75
|
this.serializeToHTML = async (fragment, modelMap, options = {}) => {
|
|
76
76
|
const { idGenerator, mediaPathGenerator } = options;
|
|
77
77
|
this.modelMap = modelMap;
|
|
78
|
-
|
|
79
|
-
this.labelTargets = (0, labels_1.buildTargets)(fragment, manuscript);
|
|
78
|
+
this.labelTargets = (0, labels_1.buildTargets)(fragment);
|
|
80
79
|
this.document = document.implementation.createDocument('http://www.w3.org/1999/xhtml', 'html', document.implementation.createDocumentType('html', '', ''));
|
|
81
80
|
const article = this.document.createElement('article');
|
|
82
81
|
this.document.documentElement.appendChild(article);
|
|
@@ -24,28 +24,15 @@ const labelledNodeTypes = [
|
|
|
24
24
|
schema_1.schema.nodes.equation_element,
|
|
25
25
|
schema_1.schema.nodes.listing_element,
|
|
26
26
|
];
|
|
27
|
-
const labelProperties = new Map([
|
|
28
|
-
[schema_1.schema.nodes.figure_element, 'figureElementLabel'],
|
|
29
|
-
[schema_1.schema.nodes.table_element, 'tableElementLabel'],
|
|
30
|
-
[schema_1.schema.nodes.equation_element, 'equationElementLabel'],
|
|
31
|
-
[schema_1.schema.nodes.listing_element, 'listingElementLabel'],
|
|
32
|
-
]);
|
|
33
27
|
const excludedTypes = [schema_1.schema.nodes.graphical_abstract_section];
|
|
34
|
-
const chooseLabel = (nodeType
|
|
35
|
-
const labelProperty = labelProperties.get(nodeType);
|
|
36
|
-
if (labelProperty) {
|
|
37
|
-
const label = manuscript[labelProperty];
|
|
38
|
-
if (label) {
|
|
39
|
-
return label;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
28
|
+
const chooseLabel = (nodeType) => {
|
|
42
29
|
return node_names_1.nodeNames.get(nodeType);
|
|
43
30
|
};
|
|
44
|
-
const buildTargets = (fragment
|
|
31
|
+
const buildTargets = (fragment) => {
|
|
45
32
|
const counters = {};
|
|
46
33
|
for (const nodeType of labelledNodeTypes) {
|
|
47
34
|
counters[nodeType.name] = {
|
|
48
|
-
label: chooseLabel(nodeType
|
|
35
|
+
label: chooseLabel(nodeType),
|
|
49
36
|
index: 0,
|
|
50
37
|
};
|
|
51
38
|
}
|
package/dist/cjs/version.js
CHANGED
|
@@ -218,7 +218,7 @@ export const jatsBodyTransformations = {
|
|
|
218
218
|
moveCaptionsToEnd(body) {
|
|
219
219
|
const captions = body.querySelectorAll('caption');
|
|
220
220
|
for (const caption of captions) {
|
|
221
|
-
if (caption.parentNode) {
|
|
221
|
+
if (caption.parentNode && caption.parentNode.nodeName !== 'table-wrap') {
|
|
222
222
|
caption.parentNode.appendChild(caption);
|
|
223
223
|
}
|
|
224
224
|
}
|
|
@@ -135,7 +135,7 @@ export class JATSExporter {
|
|
|
135
135
|
const manuscript = findManuscriptById(this.modelMap, manuscriptID);
|
|
136
136
|
article.setAttribute('article-type', manuscript.articleType || 'other');
|
|
137
137
|
if (!frontMatterOnly) {
|
|
138
|
-
this.labelTargets = buildTargets(fragment
|
|
138
|
+
this.labelTargets = buildTargets(fragment);
|
|
139
139
|
const body = this.buildBody(fragment);
|
|
140
140
|
article.appendChild(body);
|
|
141
141
|
const back = this.buildBack(body);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
class Migration2322 {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.fromVersion = '2.3.21';
|
|
4
|
+
this.toVersion = '2.3.22';
|
|
5
|
+
}
|
|
6
|
+
migrateNode(node) {
|
|
7
|
+
if (node.type === 'table_element' && Array.isArray(node.content)) {
|
|
8
|
+
let figcaptionNode = null;
|
|
9
|
+
const remainingContent = [];
|
|
10
|
+
for (const child of node.content) {
|
|
11
|
+
if (child.type === 'figcaption') {
|
|
12
|
+
figcaptionNode = child;
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
remainingContent.push(child);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
const newContent = figcaptionNode
|
|
19
|
+
? [figcaptionNode, ...remainingContent]
|
|
20
|
+
: remainingContent;
|
|
21
|
+
return Object.assign(Object.assign({}, node), { content: newContent });
|
|
22
|
+
}
|
|
23
|
+
return node;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export default Migration2322;
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
export const tableElement = {
|
|
17
|
-
content: '(table | placeholder) table_colgroup? table_element_footer?
|
|
17
|
+
content: ' figcaption? (table | placeholder) table_colgroup? table_element_footer? (listing | placeholder)',
|
|
18
18
|
attrs: {
|
|
19
19
|
id: { default: '' },
|
|
20
20
|
paragraphStyle: { default: '' },
|
|
@@ -606,14 +606,13 @@ export class Decoder {
|
|
|
606
606
|
const figcaption = this.getFigcaption(model);
|
|
607
607
|
const comments = this.createCommentNodes(model);
|
|
608
608
|
comments.forEach((c) => this.comments.set(c.attrs.id, c));
|
|
609
|
-
const content = [table];
|
|
609
|
+
const content = [figcaption, table];
|
|
610
610
|
if (tableColGroup) {
|
|
611
611
|
content.push(tableColGroup);
|
|
612
612
|
}
|
|
613
613
|
if (tableElementFooter) {
|
|
614
614
|
content.push(tableElementFooter);
|
|
615
615
|
}
|
|
616
|
-
content.push(figcaption);
|
|
617
616
|
const listing = model.listingID
|
|
618
617
|
? this.createListing(model.listingID)
|
|
619
618
|
: schema.nodes.listing.create();
|
|
@@ -718,9 +717,13 @@ export class Decoder {
|
|
|
718
717
|
this.createCommentsNode(),
|
|
719
718
|
];
|
|
720
719
|
const contents = nodes.filter((node) => node !== false);
|
|
720
|
+
const props = this.getManuscript();
|
|
721
721
|
return schema.nodes.manuscript.create({
|
|
722
722
|
id: manuscriptID || this.getManuscriptID(),
|
|
723
|
-
doi:
|
|
723
|
+
doi: (props === null || props === void 0 ? void 0 : props.DOI) || '',
|
|
724
|
+
articleType: props === null || props === void 0 ? void 0 : props.articleType,
|
|
725
|
+
prototype: props === null || props === void 0 ? void 0 : props.prototype,
|
|
726
|
+
primaryLanguageCode: props === null || props === void 0 ? void 0 : props.primaryLanguageCode,
|
|
724
727
|
}, contents);
|
|
725
728
|
};
|
|
726
729
|
this.addGeneratedLabels = (sections) => {
|
|
@@ -766,10 +769,10 @@ export class Decoder {
|
|
|
766
769
|
}
|
|
767
770
|
}
|
|
768
771
|
};
|
|
769
|
-
this.
|
|
772
|
+
this.getManuscript = () => {
|
|
770
773
|
for (const item of this.modelMap.values()) {
|
|
771
774
|
if (isManuscript(item)) {
|
|
772
|
-
return item
|
|
775
|
+
return item;
|
|
773
776
|
}
|
|
774
777
|
}
|
|
775
778
|
};
|
|
@@ -69,8 +69,7 @@ export class HTMLTransformer {
|
|
|
69
69
|
this.serializeToHTML = async (fragment, modelMap, options = {}) => {
|
|
70
70
|
const { idGenerator, mediaPathGenerator } = options;
|
|
71
71
|
this.modelMap = modelMap;
|
|
72
|
-
|
|
73
|
-
this.labelTargets = buildTargets(fragment, manuscript);
|
|
72
|
+
this.labelTargets = buildTargets(fragment);
|
|
74
73
|
this.document = document.implementation.createDocument('http://www.w3.org/1999/xhtml', 'html', document.implementation.createDocumentType('html', '', ''));
|
|
75
74
|
const article = this.document.createElement('article');
|
|
76
75
|
this.document.documentElement.appendChild(article);
|
|
@@ -21,28 +21,15 @@ const labelledNodeTypes = [
|
|
|
21
21
|
schema.nodes.equation_element,
|
|
22
22
|
schema.nodes.listing_element,
|
|
23
23
|
];
|
|
24
|
-
const labelProperties = new Map([
|
|
25
|
-
[schema.nodes.figure_element, 'figureElementLabel'],
|
|
26
|
-
[schema.nodes.table_element, 'tableElementLabel'],
|
|
27
|
-
[schema.nodes.equation_element, 'equationElementLabel'],
|
|
28
|
-
[schema.nodes.listing_element, 'listingElementLabel'],
|
|
29
|
-
]);
|
|
30
24
|
const excludedTypes = [schema.nodes.graphical_abstract_section];
|
|
31
|
-
const chooseLabel = (nodeType
|
|
32
|
-
const labelProperty = labelProperties.get(nodeType);
|
|
33
|
-
if (labelProperty) {
|
|
34
|
-
const label = manuscript[labelProperty];
|
|
35
|
-
if (label) {
|
|
36
|
-
return label;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
25
|
+
const chooseLabel = (nodeType) => {
|
|
39
26
|
return nodeNames.get(nodeType);
|
|
40
27
|
};
|
|
41
|
-
export const buildTargets = (fragment
|
|
28
|
+
export const buildTargets = (fragment) => {
|
|
42
29
|
const counters = {};
|
|
43
30
|
for (const nodeType of labelledNodeTypes) {
|
|
44
31
|
counters[nodeType.name] = {
|
|
45
|
-
label: chooseLabel(nodeType
|
|
32
|
+
label: chooseLabel(nodeType),
|
|
46
33
|
index: 0,
|
|
47
34
|
};
|
|
48
35
|
}
|
package/dist/es/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "2.3.
|
|
1
|
+
export const VERSION = "2.3.22-JSR";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { JSONNode } from '../migrate';
|
|
2
|
+
import { MigrationScript } from '../migration-script';
|
|
3
|
+
declare class Migration2322 implements MigrationScript {
|
|
4
|
+
fromVersion: string;
|
|
5
|
+
toVersion: string;
|
|
6
|
+
migrateNode(node: JSONNode): JSONNode;
|
|
7
|
+
}
|
|
8
|
+
export default Migration2322;
|
|
@@ -42,7 +42,7 @@ export declare class Decoder {
|
|
|
42
42
|
addGeneratedLabels: (sections: Section[]) => Section[];
|
|
43
43
|
parseContents: (contents: string, wrapper?: string, commentAnnotations?: CommentAnnotation[], options?: ParseOptions) => ManuscriptNode;
|
|
44
44
|
private getManuscriptID;
|
|
45
|
-
private
|
|
45
|
+
private getManuscript;
|
|
46
46
|
private getFigcaption;
|
|
47
47
|
private createTable;
|
|
48
48
|
private createTableColGroup;
|
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { Manuscript } from '@manuscripts/json-schema';
|
|
17
16
|
import { ManuscriptFragment } from '../schema';
|
|
18
17
|
export interface Target {
|
|
19
18
|
type: string;
|
|
@@ -21,4 +20,4 @@ export interface Target {
|
|
|
21
20
|
label: string;
|
|
22
21
|
caption: string;
|
|
23
22
|
}
|
|
24
|
-
export declare const buildTargets: (fragment: ManuscriptFragment
|
|
23
|
+
export declare const buildTargets: (fragment: ManuscriptFragment) => Map<string, Target>;
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "2.3.
|
|
1
|
+
export declare const VERSION = "2.3.22-JSR";
|
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": "2.3.
|
|
4
|
+
"version": "2.3.22-JSR",
|
|
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
|
"rimraf": "^3.0.2",
|
|
83
83
|
"typescript": "^4.0.5"
|
|
84
84
|
}
|
|
85
|
-
}
|
|
85
|
+
}
|