@manuscripts/transform 1.4.5 → 1.4.6-LEAN-2852-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/dist/cjs/jats/importer/jats-body-dom-parser.js +21 -0
- package/dist/cjs/jats/jats-exporter.js +2 -1
- package/dist/cjs/schema/index.js +3 -0
- package/dist/cjs/schema/nodes/cross_reference.js +6 -1
- package/dist/cjs/schema/nodes/title.js +29 -0
- package/dist/cjs/transformer/decode.js +6 -0
- package/dist/cjs/transformer/encode.js +3 -0
- package/dist/cjs/transformer/html.js +2 -1
- package/dist/es/jats/importer/jats-body-dom-parser.js +21 -0
- package/dist/es/jats/jats-exporter.js +2 -1
- package/dist/es/schema/index.js +3 -0
- package/dist/es/schema/nodes/cross_reference.js +6 -1
- package/dist/es/schema/nodes/title.js +26 -0
- package/dist/es/transformer/decode.js +6 -0
- package/dist/es/transformer/encode.js +3 -0
- package/dist/es/transformer/html.js +2 -1
- package/dist/types/schema/index.d.ts +1 -0
- package/dist/types/schema/nodes/cross_reference.d.ts +1 -0
- package/dist/types/schema/nodes/title.d.ts +25 -0
- package/dist/types/schema/types.d.ts +1 -1
- package/package.json +3 -3
|
@@ -607,6 +607,27 @@ const nodes = [
|
|
|
607
607
|
node: 'caption_title',
|
|
608
608
|
context: 'figcaption/',
|
|
609
609
|
},
|
|
610
|
+
{
|
|
611
|
+
tag: 'article-title',
|
|
612
|
+
node: 'title',
|
|
613
|
+
context: 'front/',
|
|
614
|
+
getContent: (node, schema) => {
|
|
615
|
+
const element = node;
|
|
616
|
+
const content = [];
|
|
617
|
+
const title = element.querySelector('article-title');
|
|
618
|
+
if (title) {
|
|
619
|
+
const articleTitle = schema.nodes.title.create();
|
|
620
|
+
const titleText = title.textContent;
|
|
621
|
+
if (titleText !== null) {
|
|
622
|
+
const trimmedText = titleText.trim();
|
|
623
|
+
const trimmedTitleNode = document.createElement('article-title');
|
|
624
|
+
trimmedTitleNode.textContent = trimmedText;
|
|
625
|
+
content.push(exports.jatsBodyDOMParser.parse(trimmedTitleNode, { topNode: articleTitle }));
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
return prosemirror_model_1.Fragment.from(content);
|
|
629
|
+
},
|
|
630
|
+
},
|
|
610
631
|
{
|
|
611
632
|
tag: 'tr',
|
|
612
633
|
node: 'table_row',
|
|
@@ -609,6 +609,7 @@ class JATSExporter {
|
|
|
609
609
|
bibliography_item: () => '',
|
|
610
610
|
comment_list: () => '',
|
|
611
611
|
keywords_group: () => '',
|
|
612
|
+
title: () => '',
|
|
612
613
|
bibliography_section: (node) => [
|
|
613
614
|
'ref-list',
|
|
614
615
|
{ id: normalizeID(node.attrs.id) },
|
|
@@ -686,7 +687,7 @@ class JATSExporter {
|
|
|
686
687
|
const rid = getReferencedObjectId(auxiliaryObjectReference.referencedObject);
|
|
687
688
|
xref.setAttribute('rid', rid);
|
|
688
689
|
}
|
|
689
|
-
xref.textContent = node.attrs.label;
|
|
690
|
+
xref.textContent = node.attrs.customLabel || node.attrs.label;
|
|
690
691
|
return xref;
|
|
691
692
|
},
|
|
692
693
|
doc: () => '',
|
package/dist/cjs/schema/index.js
CHANGED
|
@@ -85,6 +85,7 @@ const table_element_1 = require("./nodes/table_element");
|
|
|
85
85
|
const table_element_footer_1 = require("./nodes/table_element_footer");
|
|
86
86
|
const table_row_1 = require("./nodes/table_row");
|
|
87
87
|
const text_1 = require("./nodes/text");
|
|
88
|
+
const title_1 = require("./nodes/title");
|
|
88
89
|
const toc_element_1 = require("./nodes/toc_element");
|
|
89
90
|
const toc_section_1 = require("./nodes/toc_section");
|
|
90
91
|
__exportStar(require("./groups"), exports);
|
|
@@ -142,6 +143,7 @@ __exportStar(require("./nodes/meta_section"), exports);
|
|
|
142
143
|
__exportStar(require("./nodes/contributor_list"), exports);
|
|
143
144
|
__exportStar(require("./nodes/contributor"), exports);
|
|
144
145
|
__exportStar(require("./nodes/table_element_footer"), exports);
|
|
146
|
+
__exportStar(require("./nodes/title"), exports);
|
|
145
147
|
exports.schema = new prosemirror_model_1.Schema({
|
|
146
148
|
marks: {
|
|
147
149
|
bold: marks_1.bold,
|
|
@@ -218,5 +220,6 @@ exports.schema = new prosemirror_model_1.Schema({
|
|
|
218
220
|
contributor_list: contributor_list_1.contributorList,
|
|
219
221
|
contributor: contributor_1.contributor,
|
|
220
222
|
table_element_footer: table_element_footer_1.tableElementFooter,
|
|
223
|
+
title: title_1.title,
|
|
221
224
|
},
|
|
222
225
|
});
|
|
@@ -24,6 +24,7 @@ exports.crossReference = {
|
|
|
24
24
|
attrs: {
|
|
25
25
|
rid: { default: '' },
|
|
26
26
|
label: { default: '' },
|
|
27
|
+
customLabel: { default: '' },
|
|
27
28
|
dataTracked: { default: null },
|
|
28
29
|
},
|
|
29
30
|
parseDOM: [
|
|
@@ -51,7 +52,11 @@ exports.crossReference = {
|
|
|
51
52
|
{
|
|
52
53
|
class: 'kind elementIndex',
|
|
53
54
|
},
|
|
54
|
-
[
|
|
55
|
+
[
|
|
56
|
+
'b',
|
|
57
|
+
crossReferenceNode.attrs.customLabel ||
|
|
58
|
+
crossReferenceNode.attrs.label,
|
|
59
|
+
],
|
|
55
60
|
],
|
|
56
61
|
];
|
|
57
62
|
},
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* © 2019 Atypon Systems LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.title = void 0;
|
|
19
|
+
exports.title = {
|
|
20
|
+
content: 'text*',
|
|
21
|
+
marks: 'italic smallcaps subscript superscript',
|
|
22
|
+
attrs: {
|
|
23
|
+
id: { default: '' },
|
|
24
|
+
dataTracked: { default: null },
|
|
25
|
+
},
|
|
26
|
+
group: 'block element',
|
|
27
|
+
parseDOM: [{ tag: 'div' }],
|
|
28
|
+
toDOM: () => ['div', 0],
|
|
29
|
+
};
|
|
@@ -593,6 +593,12 @@ class Decoder {
|
|
|
593
593
|
ORCIDIdentifier: model.ORCIDIdentifier,
|
|
594
594
|
});
|
|
595
595
|
},
|
|
596
|
+
[json_schema_1.ObjectTypes.Title]: (data) => {
|
|
597
|
+
const model = data;
|
|
598
|
+
return this.parseContents(model.contents || '<div></div>', undefined, this.getComments(model), {
|
|
599
|
+
topNode: schema_1.schema.nodes.title.create(),
|
|
600
|
+
});
|
|
601
|
+
},
|
|
596
602
|
};
|
|
597
603
|
this.decode = (model) => {
|
|
598
604
|
if (!this.creators[model.objectType]) {
|
|
@@ -524,6 +524,9 @@ const encoders = {
|
|
|
524
524
|
isCorresponding: node.attrs.isCorresponding,
|
|
525
525
|
ORCIDIdentifier: node.attrs.ORCIDIdentifier,
|
|
526
526
|
}),
|
|
527
|
+
title: (node) => ({
|
|
528
|
+
contents: node.attrs.contents,
|
|
529
|
+
}),
|
|
527
530
|
};
|
|
528
531
|
const modelData = (node, parent, path, priority) => {
|
|
529
532
|
const encoder = encoders[node.type.name];
|
|
@@ -228,7 +228,8 @@ class HTMLTransformer {
|
|
|
228
228
|
}
|
|
229
229
|
element.setAttribute('data-reference-ids', crossReferenceNode.attrs.rid);
|
|
230
230
|
}
|
|
231
|
-
element.textContent =
|
|
231
|
+
element.textContent =
|
|
232
|
+
crossReferenceNode.attrs.customLabel || crossReferenceNode.attrs.label;
|
|
232
233
|
return element;
|
|
233
234
|
};
|
|
234
235
|
nodes.listing = (node) => {
|
|
@@ -601,6 +601,27 @@ const nodes = [
|
|
|
601
601
|
node: 'caption_title',
|
|
602
602
|
context: 'figcaption/',
|
|
603
603
|
},
|
|
604
|
+
{
|
|
605
|
+
tag: 'article-title',
|
|
606
|
+
node: 'title',
|
|
607
|
+
context: 'front/',
|
|
608
|
+
getContent: (node, schema) => {
|
|
609
|
+
const element = node;
|
|
610
|
+
const content = [];
|
|
611
|
+
const title = element.querySelector('article-title');
|
|
612
|
+
if (title) {
|
|
613
|
+
const articleTitle = schema.nodes.title.create();
|
|
614
|
+
const titleText = title.textContent;
|
|
615
|
+
if (titleText !== null) {
|
|
616
|
+
const trimmedText = titleText.trim();
|
|
617
|
+
const trimmedTitleNode = document.createElement('article-title');
|
|
618
|
+
trimmedTitleNode.textContent = trimmedText;
|
|
619
|
+
content.push(jatsBodyDOMParser.parse(trimmedTitleNode, { topNode: articleTitle }));
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
return Fragment.from(content);
|
|
623
|
+
},
|
|
624
|
+
},
|
|
604
625
|
{
|
|
605
626
|
tag: 'tr',
|
|
606
627
|
node: 'table_row',
|
|
@@ -602,6 +602,7 @@ export class JATSExporter {
|
|
|
602
602
|
bibliography_item: () => '',
|
|
603
603
|
comment_list: () => '',
|
|
604
604
|
keywords_group: () => '',
|
|
605
|
+
title: () => '',
|
|
605
606
|
bibliography_section: (node) => [
|
|
606
607
|
'ref-list',
|
|
607
608
|
{ id: normalizeID(node.attrs.id) },
|
|
@@ -679,7 +680,7 @@ export class JATSExporter {
|
|
|
679
680
|
const rid = getReferencedObjectId(auxiliaryObjectReference.referencedObject);
|
|
680
681
|
xref.setAttribute('rid', rid);
|
|
681
682
|
}
|
|
682
|
-
xref.textContent = node.attrs.label;
|
|
683
|
+
xref.textContent = node.attrs.customLabel || node.attrs.label;
|
|
683
684
|
return xref;
|
|
684
685
|
},
|
|
685
686
|
doc: () => '',
|
package/dist/es/schema/index.js
CHANGED
|
@@ -68,6 +68,7 @@ import { tableElement } from './nodes/table_element';
|
|
|
68
68
|
import { tableElementFooter } from './nodes/table_element_footer';
|
|
69
69
|
import { tableCell, tableRow } from './nodes/table_row';
|
|
70
70
|
import { text } from './nodes/text';
|
|
71
|
+
import { title } from './nodes/title';
|
|
71
72
|
import { tocElement } from './nodes/toc_element';
|
|
72
73
|
import { tocSection } from './nodes/toc_section';
|
|
73
74
|
export * from './groups';
|
|
@@ -125,6 +126,7 @@ export * from './nodes/meta_section';
|
|
|
125
126
|
export * from './nodes/contributor_list';
|
|
126
127
|
export * from './nodes/contributor';
|
|
127
128
|
export * from './nodes/table_element_footer';
|
|
129
|
+
export * from './nodes/title';
|
|
128
130
|
export const schema = new Schema({
|
|
129
131
|
marks: {
|
|
130
132
|
bold,
|
|
@@ -201,5 +203,6 @@ export const schema = new Schema({
|
|
|
201
203
|
contributor_list: contributorList,
|
|
202
204
|
contributor: contributor,
|
|
203
205
|
table_element_footer: tableElementFooter,
|
|
206
|
+
title: title,
|
|
204
207
|
},
|
|
205
208
|
});
|
|
@@ -21,6 +21,7 @@ export const crossReference = {
|
|
|
21
21
|
attrs: {
|
|
22
22
|
rid: { default: '' },
|
|
23
23
|
label: { default: '' },
|
|
24
|
+
customLabel: { default: '' },
|
|
24
25
|
dataTracked: { default: null },
|
|
25
26
|
},
|
|
26
27
|
parseDOM: [
|
|
@@ -48,7 +49,11 @@ export const crossReference = {
|
|
|
48
49
|
{
|
|
49
50
|
class: 'kind elementIndex',
|
|
50
51
|
},
|
|
51
|
-
[
|
|
52
|
+
[
|
|
53
|
+
'b',
|
|
54
|
+
crossReferenceNode.attrs.customLabel ||
|
|
55
|
+
crossReferenceNode.attrs.label,
|
|
56
|
+
],
|
|
52
57
|
],
|
|
53
58
|
];
|
|
54
59
|
},
|
|
@@ -0,0 +1,26 @@
|
|
|
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 const title = {
|
|
17
|
+
content: 'text*',
|
|
18
|
+
marks: 'italic smallcaps subscript superscript',
|
|
19
|
+
attrs: {
|
|
20
|
+
id: { default: '' },
|
|
21
|
+
dataTracked: { default: null },
|
|
22
|
+
},
|
|
23
|
+
group: 'block element',
|
|
24
|
+
parseDOM: [{ tag: 'div' }],
|
|
25
|
+
toDOM: () => ['div', 0],
|
|
26
|
+
};
|
|
@@ -583,6 +583,12 @@ export class Decoder {
|
|
|
583
583
|
ORCIDIdentifier: model.ORCIDIdentifier,
|
|
584
584
|
});
|
|
585
585
|
},
|
|
586
|
+
[ObjectTypes.Title]: (data) => {
|
|
587
|
+
const model = data;
|
|
588
|
+
return this.parseContents(model.contents || '<div></div>', undefined, this.getComments(model), {
|
|
589
|
+
topNode: schema.nodes.title.create(),
|
|
590
|
+
});
|
|
591
|
+
},
|
|
586
592
|
};
|
|
587
593
|
this.decode = (model) => {
|
|
588
594
|
if (!this.creators[model.objectType]) {
|
|
@@ -516,6 +516,9 @@ const encoders = {
|
|
|
516
516
|
isCorresponding: node.attrs.isCorresponding,
|
|
517
517
|
ORCIDIdentifier: node.attrs.ORCIDIdentifier,
|
|
518
518
|
}),
|
|
519
|
+
title: (node) => ({
|
|
520
|
+
contents: node.attrs.contents,
|
|
521
|
+
}),
|
|
519
522
|
};
|
|
520
523
|
const modelData = (node, parent, path, priority) => {
|
|
521
524
|
const encoder = encoders[node.type.name];
|
|
@@ -222,7 +222,8 @@ export class HTMLTransformer {
|
|
|
222
222
|
}
|
|
223
223
|
element.setAttribute('data-reference-ids', crossReferenceNode.attrs.rid);
|
|
224
224
|
}
|
|
225
|
-
element.textContent =
|
|
225
|
+
element.textContent =
|
|
226
|
+
crossReferenceNode.attrs.customLabel || crossReferenceNode.attrs.label;
|
|
226
227
|
return element;
|
|
227
228
|
};
|
|
228
229
|
nodes.listing = (node) => {
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
import { ManuscriptNode } from '../types';
|
|
18
|
+
interface Attrs {
|
|
19
|
+
id: string;
|
|
20
|
+
}
|
|
21
|
+
export interface TitleNode extends ManuscriptNode {
|
|
22
|
+
attrs: Attrs;
|
|
23
|
+
}
|
|
24
|
+
export declare const title: NodeSpec;
|
|
25
|
+
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' | 'affiliation_list' | 'contributor_list' | 'contributor' | 'table_element_footer';
|
|
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' | 'affiliation_list' | 'contributor_list' | 'contributor' | 'table_element_footer' | 'title';
|
|
21
21
|
export type ManuscriptSchema = Schema<Nodes, Marks>;
|
|
22
22
|
export type ManuscriptEditorState = EditorState;
|
|
23
23
|
export type ManuscriptEditorView = EditorView;
|
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.4.
|
|
4
|
+
"version": "1.4.6-LEAN-2852-0",
|
|
5
5
|
"repository": "github:Atypon-OpenSource/manuscripts-transform",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"version": "yarn build"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@manuscripts/json-schema": "
|
|
32
|
+
"@manuscripts/json-schema": "2.2.0-LEAN-2852-0",
|
|
33
33
|
"debug": "^4.3.4",
|
|
34
34
|
"jszip": "^3.10.1",
|
|
35
35
|
"mathjax-full": "^3.2.2",
|
|
@@ -82,4 +82,4 @@
|
|
|
82
82
|
"prosemirror-state": "^1.4.2",
|
|
83
83
|
"prosemirror-view": "^1.29.1"
|
|
84
84
|
}
|
|
85
|
-
}
|
|
85
|
+
}
|