@manuscripts/transform 1.4.4 → 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 +25 -0
- package/dist/cjs/jats/importer/jats-reference-parser.js +4 -0
- package/dist/cjs/jats/jats-exporter.js +6 -9
- package/dist/cjs/schema/index.js +3 -0
- package/dist/cjs/schema/nodes/citation.js +10 -1
- 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 +6 -2
- package/dist/cjs/transformer/html.js +2 -1
- package/dist/es/jats/importer/jats-body-dom-parser.js +25 -0
- package/dist/es/jats/importer/jats-reference-parser.js +4 -0
- package/dist/es/jats/jats-exporter.js +6 -9
- package/dist/es/schema/index.js +3 -0
- package/dist/es/schema/nodes/citation.js +10 -1
- 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 +6 -2
- package/dist/es/transformer/html.js +2 -1
- package/dist/types/schema/index.d.ts +1 -0
- package/dist/types/schema/nodes/citation.d.ts +4 -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',
|
|
@@ -651,9 +672,13 @@ const nodes = [
|
|
|
651
672
|
getAttrs: (node) => {
|
|
652
673
|
var _a;
|
|
653
674
|
const element = node;
|
|
675
|
+
const embeddedCitationAttr = element.getAttribute('data-reference-embedded-citation');
|
|
654
676
|
return {
|
|
655
677
|
rid: element.getAttribute('rid'),
|
|
656
678
|
contents: (_a = element.textContent) === null || _a === void 0 ? void 0 : _a.trim(),
|
|
679
|
+
embeddedCitationItems: embeddedCitationAttr
|
|
680
|
+
? JSON.parse(embeddedCitationAttr)
|
|
681
|
+
: null,
|
|
657
682
|
};
|
|
658
683
|
},
|
|
659
684
|
},
|
|
@@ -158,6 +158,10 @@ exports.jatsReferenceParser = {
|
|
|
158
158
|
const citation = (0, builders_1.buildCitation)('', rids);
|
|
159
159
|
modelNodes.push(citation);
|
|
160
160
|
crossReferenceNode.setAttribute('rid', citation._id);
|
|
161
|
+
crossReferenceNode.setAttribute('data-reference-embedded-citation', JSON.stringify(citation.embeddedCitationItems.map(({ _id: id, bibliographyItem }) => ({
|
|
162
|
+
id,
|
|
163
|
+
bibliographyItem,
|
|
164
|
+
}))));
|
|
161
165
|
}
|
|
162
166
|
else {
|
|
163
167
|
crossReferenceNode.removeAttribute('rid');
|
|
@@ -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) },
|
|
@@ -628,20 +629,16 @@ class JATSExporter {
|
|
|
628
629
|
warn(`${node.attrs.id} has no rid`);
|
|
629
630
|
return node.attrs.label;
|
|
630
631
|
}
|
|
631
|
-
const
|
|
632
|
-
|
|
633
|
-
warn(`Missing citation ${node.attrs.rid}`);
|
|
634
|
-
return '';
|
|
635
|
-
}
|
|
636
|
-
const rids = citation.embeddedCitationItems.filter((item) => {
|
|
632
|
+
const rids = node.attrs
|
|
633
|
+
.embeddedCitationItems.filter((item) => {
|
|
637
634
|
if (!this.modelMap.has(item.bibliographyItem)) {
|
|
638
|
-
warn(`Missing ${item.bibliographyItem} referenced by ${
|
|
635
|
+
warn(`Missing ${item.bibliographyItem} referenced by ${node.attrs.rid}`);
|
|
639
636
|
return false;
|
|
640
637
|
}
|
|
641
638
|
return true;
|
|
642
639
|
});
|
|
643
640
|
if (!rids.length) {
|
|
644
|
-
warn(`${
|
|
641
|
+
warn(`${node.attrs.rid} has no confirmed rids`);
|
|
645
642
|
return '';
|
|
646
643
|
}
|
|
647
644
|
const xref = this.document.createElement('xref');
|
|
@@ -690,7 +687,7 @@ class JATSExporter {
|
|
|
690
687
|
const rid = getReferencedObjectId(auxiliaryObjectReference.referencedObject);
|
|
691
688
|
xref.setAttribute('rid', rid);
|
|
692
689
|
}
|
|
693
|
-
xref.textContent = node.attrs.label;
|
|
690
|
+
xref.textContent = node.attrs.customLabel || node.attrs.label;
|
|
694
691
|
return xref;
|
|
695
692
|
},
|
|
696
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
|
});
|
|
@@ -26,16 +26,22 @@ exports.citation = {
|
|
|
26
26
|
contents: { default: '' },
|
|
27
27
|
selectedText: { default: '' },
|
|
28
28
|
dataTracked: { default: null },
|
|
29
|
+
embeddedCitationItems: { default: [] },
|
|
29
30
|
},
|
|
30
31
|
parseDOM: [
|
|
31
32
|
{
|
|
32
33
|
tag: 'span.citation[data-reference-id]',
|
|
33
34
|
getAttrs: (p) => {
|
|
34
35
|
const dom = p;
|
|
35
|
-
|
|
36
|
+
const attr = {
|
|
36
37
|
rid: dom.getAttribute('data-reference-id'),
|
|
37
38
|
contents: dom.innerHTML,
|
|
38
39
|
};
|
|
40
|
+
const embeddedCitationAttr = dom.getAttribute('data-reference-embedded-citation');
|
|
41
|
+
if (embeddedCitationAttr) {
|
|
42
|
+
attr['embeddedCitationItems'] = JSON.parse(embeddedCitationAttr);
|
|
43
|
+
}
|
|
44
|
+
return attr;
|
|
39
45
|
},
|
|
40
46
|
},
|
|
41
47
|
],
|
|
@@ -44,6 +50,9 @@ exports.citation = {
|
|
|
44
50
|
const dom = document.createElement('span');
|
|
45
51
|
dom.className = 'citation';
|
|
46
52
|
dom.setAttribute('data-reference-id', citationNode.attrs.rid);
|
|
53
|
+
if (citationNode.attrs.embeddedCitationItems) {
|
|
54
|
+
dom.setAttribute('data-reference-embedded-citation', JSON.stringify(citationNode.attrs.embeddedCitationItems));
|
|
55
|
+
}
|
|
47
56
|
dom.innerHTML = citationNode.attrs.contents;
|
|
48
57
|
return dom;
|
|
49
58
|
},
|
|
@@ -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]) {
|
|
@@ -271,8 +271,9 @@ const encoders = {
|
|
|
271
271
|
}),
|
|
272
272
|
bibliography_item: (node) => {
|
|
273
273
|
const { type, containerTitle, doi, volume, issue, supplement, page, title, literal, } = node.attrs;
|
|
274
|
-
const
|
|
275
|
-
const
|
|
274
|
+
const getObjectAtrr = (obj) => typeof obj === 'string' ? fromJson(obj) : obj;
|
|
275
|
+
const author = getObjectAtrr(node.attrs.author);
|
|
276
|
+
const issued = getObjectAtrr(node.attrs.issued);
|
|
276
277
|
const ref = {
|
|
277
278
|
type,
|
|
278
279
|
};
|
|
@@ -523,6 +524,9 @@ const encoders = {
|
|
|
523
524
|
isCorresponding: node.attrs.isCorresponding,
|
|
524
525
|
ORCIDIdentifier: node.attrs.ORCIDIdentifier,
|
|
525
526
|
}),
|
|
527
|
+
title: (node) => ({
|
|
528
|
+
contents: node.attrs.contents,
|
|
529
|
+
}),
|
|
526
530
|
};
|
|
527
531
|
const modelData = (node, parent, path, priority) => {
|
|
528
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',
|
|
@@ -645,9 +666,13 @@ const nodes = [
|
|
|
645
666
|
getAttrs: (node) => {
|
|
646
667
|
var _a;
|
|
647
668
|
const element = node;
|
|
669
|
+
const embeddedCitationAttr = element.getAttribute('data-reference-embedded-citation');
|
|
648
670
|
return {
|
|
649
671
|
rid: element.getAttribute('rid'),
|
|
650
672
|
contents: (_a = element.textContent) === null || _a === void 0 ? void 0 : _a.trim(),
|
|
673
|
+
embeddedCitationItems: embeddedCitationAttr
|
|
674
|
+
? JSON.parse(embeddedCitationAttr)
|
|
675
|
+
: null,
|
|
651
676
|
};
|
|
652
677
|
},
|
|
653
678
|
},
|
|
@@ -155,6 +155,10 @@ export const jatsReferenceParser = {
|
|
|
155
155
|
const citation = buildCitation('', rids);
|
|
156
156
|
modelNodes.push(citation);
|
|
157
157
|
crossReferenceNode.setAttribute('rid', citation._id);
|
|
158
|
+
crossReferenceNode.setAttribute('data-reference-embedded-citation', JSON.stringify(citation.embeddedCitationItems.map(({ _id: id, bibliographyItem }) => ({
|
|
159
|
+
id,
|
|
160
|
+
bibliographyItem,
|
|
161
|
+
}))));
|
|
158
162
|
}
|
|
159
163
|
else {
|
|
160
164
|
crossReferenceNode.removeAttribute('rid');
|
|
@@ -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) },
|
|
@@ -621,20 +622,16 @@ export class JATSExporter {
|
|
|
621
622
|
warn(`${node.attrs.id} has no rid`);
|
|
622
623
|
return node.attrs.label;
|
|
623
624
|
}
|
|
624
|
-
const
|
|
625
|
-
|
|
626
|
-
warn(`Missing citation ${node.attrs.rid}`);
|
|
627
|
-
return '';
|
|
628
|
-
}
|
|
629
|
-
const rids = citation.embeddedCitationItems.filter((item) => {
|
|
625
|
+
const rids = node.attrs
|
|
626
|
+
.embeddedCitationItems.filter((item) => {
|
|
630
627
|
if (!this.modelMap.has(item.bibliographyItem)) {
|
|
631
|
-
warn(`Missing ${item.bibliographyItem} referenced by ${
|
|
628
|
+
warn(`Missing ${item.bibliographyItem} referenced by ${node.attrs.rid}`);
|
|
632
629
|
return false;
|
|
633
630
|
}
|
|
634
631
|
return true;
|
|
635
632
|
});
|
|
636
633
|
if (!rids.length) {
|
|
637
|
-
warn(`${
|
|
634
|
+
warn(`${node.attrs.rid} has no confirmed rids`);
|
|
638
635
|
return '';
|
|
639
636
|
}
|
|
640
637
|
const xref = this.document.createElement('xref');
|
|
@@ -683,7 +680,7 @@ export class JATSExporter {
|
|
|
683
680
|
const rid = getReferencedObjectId(auxiliaryObjectReference.referencedObject);
|
|
684
681
|
xref.setAttribute('rid', rid);
|
|
685
682
|
}
|
|
686
|
-
xref.textContent = node.attrs.label;
|
|
683
|
+
xref.textContent = node.attrs.customLabel || node.attrs.label;
|
|
687
684
|
return xref;
|
|
688
685
|
},
|
|
689
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
|
});
|
|
@@ -23,16 +23,22 @@ export const citation = {
|
|
|
23
23
|
contents: { default: '' },
|
|
24
24
|
selectedText: { default: '' },
|
|
25
25
|
dataTracked: { default: null },
|
|
26
|
+
embeddedCitationItems: { default: [] },
|
|
26
27
|
},
|
|
27
28
|
parseDOM: [
|
|
28
29
|
{
|
|
29
30
|
tag: 'span.citation[data-reference-id]',
|
|
30
31
|
getAttrs: (p) => {
|
|
31
32
|
const dom = p;
|
|
32
|
-
|
|
33
|
+
const attr = {
|
|
33
34
|
rid: dom.getAttribute('data-reference-id'),
|
|
34
35
|
contents: dom.innerHTML,
|
|
35
36
|
};
|
|
37
|
+
const embeddedCitationAttr = dom.getAttribute('data-reference-embedded-citation');
|
|
38
|
+
if (embeddedCitationAttr) {
|
|
39
|
+
attr['embeddedCitationItems'] = JSON.parse(embeddedCitationAttr);
|
|
40
|
+
}
|
|
41
|
+
return attr;
|
|
36
42
|
},
|
|
37
43
|
},
|
|
38
44
|
],
|
|
@@ -41,6 +47,9 @@ export const citation = {
|
|
|
41
47
|
const dom = document.createElement('span');
|
|
42
48
|
dom.className = 'citation';
|
|
43
49
|
dom.setAttribute('data-reference-id', citationNode.attrs.rid);
|
|
50
|
+
if (citationNode.attrs.embeddedCitationItems) {
|
|
51
|
+
dom.setAttribute('data-reference-embedded-citation', JSON.stringify(citationNode.attrs.embeddedCitationItems));
|
|
52
|
+
}
|
|
44
53
|
dom.innerHTML = citationNode.attrs.contents;
|
|
45
54
|
return dom;
|
|
46
55
|
},
|
|
@@ -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]) {
|
|
@@ -263,8 +263,9 @@ const encoders = {
|
|
|
263
263
|
}),
|
|
264
264
|
bibliography_item: (node) => {
|
|
265
265
|
const { type, containerTitle, doi, volume, issue, supplement, page, title, literal, } = node.attrs;
|
|
266
|
-
const
|
|
267
|
-
const
|
|
266
|
+
const getObjectAtrr = (obj) => typeof obj === 'string' ? fromJson(obj) : obj;
|
|
267
|
+
const author = getObjectAtrr(node.attrs.author);
|
|
268
|
+
const issued = getObjectAtrr(node.attrs.issued);
|
|
268
269
|
const ref = {
|
|
269
270
|
type,
|
|
270
271
|
};
|
|
@@ -515,6 +516,9 @@ const encoders = {
|
|
|
515
516
|
isCorresponding: node.attrs.isCorresponding,
|
|
516
517
|
ORCIDIdentifier: node.attrs.ORCIDIdentifier,
|
|
517
518
|
}),
|
|
519
|
+
title: (node) => ({
|
|
520
|
+
contents: node.attrs.contents,
|
|
521
|
+
}),
|
|
518
522
|
};
|
|
519
523
|
const modelData = (node, parent, path, priority) => {
|
|
520
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) => {
|
|
@@ -18,6 +18,10 @@ import { ManuscriptNode } from '../types';
|
|
|
18
18
|
interface Attrs {
|
|
19
19
|
rid: string;
|
|
20
20
|
contents: string;
|
|
21
|
+
embeddedCitationItems: {
|
|
22
|
+
id: string;
|
|
23
|
+
bibliographyItem: string;
|
|
24
|
+
}[];
|
|
21
25
|
}
|
|
22
26
|
export interface CitationNode extends ManuscriptNode {
|
|
23
27
|
attrs: Attrs;
|
|
@@ -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
|
+
}
|