@manuscripts/transform 2.0.4 → 2.1.1-LEAN-3094
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-dom-parser.js +44 -73
- package/dist/cjs/jats/importer/jats-body-transformations.js +14 -0
- package/dist/cjs/jats/importer/jats-front-parser.js +0 -19
- package/dist/cjs/jats/importer/parse-jats-article.js +1 -4
- package/dist/cjs/jats/jats-exporter.js +19 -37
- package/dist/cjs/schema/index.js +6 -1
- package/dist/cjs/schema/nodes/affiliation.js +4 -1
- package/dist/cjs/schema/nodes/contributor.js +3 -1
- package/dist/cjs/schema/nodes/equation.js +12 -14
- package/dist/cjs/schema/nodes/equation_element.js +4 -5
- package/dist/cjs/schema/nodes/inline_equation.js +12 -16
- package/dist/cjs/schema/nodes/manuscript.js +1 -1
- package/dist/cjs/schema/nodes/supplement.js +63 -0
- package/dist/cjs/schema/nodes/supplements.js +45 -0
- package/dist/cjs/transformer/builders.js +1 -8
- package/dist/cjs/transformer/decode.js +31 -7
- package/dist/cjs/transformer/encode.js +16 -25
- package/dist/cjs/transformer/node-types.js +1 -1
- package/dist/cjs/transformer/object-types.js +0 -1
- package/dist/es/index.js +0 -1
- package/dist/es/jats/importer/jats-body-dom-parser.js +45 -74
- package/dist/es/jats/importer/jats-body-transformations.js +14 -0
- package/dist/es/jats/importer/jats-front-parser.js +1 -20
- package/dist/es/jats/importer/parse-jats-article.js +1 -4
- package/dist/es/jats/jats-exporter.js +19 -37
- package/dist/es/schema/index.js +6 -1
- package/dist/es/schema/nodes/affiliation.js +4 -1
- package/dist/es/schema/nodes/contributor.js +3 -1
- package/dist/es/schema/nodes/equation.js +12 -14
- package/dist/es/schema/nodes/equation_element.js +4 -5
- package/dist/es/schema/nodes/inline_equation.js +12 -16
- package/dist/es/schema/nodes/manuscript.js +1 -1
- package/dist/es/schema/nodes/supplement.js +60 -0
- package/dist/es/schema/nodes/supplements.js +42 -0
- package/dist/es/transformer/builders.js +0 -6
- package/dist/es/transformer/decode.js +31 -7
- package/dist/es/transformer/encode.js +16 -25
- package/dist/es/transformer/node-types.js +1 -1
- package/dist/es/transformer/object-types.js +0 -1
- package/dist/types/index.d.ts +0 -1
- package/dist/types/jats/importer/jats-body-transformations.d.ts +1 -0
- package/dist/types/jats/importer/jats-front-parser.d.ts +0 -1
- package/dist/types/schema/index.d.ts +2 -1
- package/dist/types/schema/nodes/affiliation.d.ts +2 -0
- package/dist/types/schema/nodes/contributor.d.ts +4 -2
- package/dist/types/schema/nodes/equation.d.ts +3 -4
- package/dist/types/schema/nodes/equation_element.d.ts +1 -2
- package/dist/types/schema/nodes/inline_equation.d.ts +4 -4
- package/dist/{cjs/mathjax/mathjax-packages.js → types/schema/nodes/supplement.d.ts} +14 -5
- package/dist/{es/mathjax/mathjax-packages.js → types/schema/nodes/supplements.d.ts} +10 -2
- package/dist/types/schema/types.d.ts +1 -1
- package/dist/types/transformer/builders.d.ts +1 -2
- package/dist/types/transformer/decode.d.ts +1 -0
- package/package.json +4 -5
- package/dist/cjs/mathjax/index.js +0 -41
- package/dist/cjs/mathjax/mathml-to-svg.js +0 -70
- package/dist/cjs/mathjax/tex-to-mathml.js +0 -49
- package/dist/cjs/mathjax/tex-to-svg.js +0 -59
- package/dist/es/mathjax/index.js +0 -12
- package/dist/es/mathjax/mathml-to-svg.js +0 -66
- package/dist/es/mathjax/tex-to-mathml.js +0 -45
- package/dist/es/mathjax/tex-to-svg.js +0 -55
- package/dist/types/mathjax/index.d.ts +0 -3
- package/dist/types/mathjax/mathjax-packages.d.ts +0 -16
- package/dist/types/mathjax/mathml-to-svg.d.ts +0 -17
- package/dist/types/mathjax/tex-to-mathml.d.ts +0 -17
- package/dist/types/mathjax/tex-to-svg.d.ts +0 -17
package/dist/es/schema/index.js
CHANGED
|
@@ -64,6 +64,8 @@ import { pullquoteElement } from './nodes/pullquote_element';
|
|
|
64
64
|
import { section } from './nodes/section';
|
|
65
65
|
import { sectionLabel } from './nodes/section_label';
|
|
66
66
|
import { sectionTitle } from './nodes/section_title';
|
|
67
|
+
import { supplement } from './nodes/supplement';
|
|
68
|
+
import { supplements } from './nodes/supplements';
|
|
67
69
|
import { table, tableBody } from './nodes/table';
|
|
68
70
|
import { tableCol, tableColGroup } from './nodes/table_col';
|
|
69
71
|
import { tableElement } from './nodes/table_element';
|
|
@@ -98,7 +100,6 @@ export * from './nodes/footnotes_section';
|
|
|
98
100
|
export * from './nodes/graphical_abstract_section';
|
|
99
101
|
export * from './nodes/hard_break';
|
|
100
102
|
export * from './nodes/highlight_marker';
|
|
101
|
-
export * from './nodes/inline_equation';
|
|
102
103
|
export * from './nodes/inline_footnote';
|
|
103
104
|
export * from './nodes/keyword';
|
|
104
105
|
export * from './nodes/keywords_element';
|
|
@@ -128,6 +129,8 @@ export * from './nodes/table_element_footer';
|
|
|
128
129
|
export * from './nodes/title';
|
|
129
130
|
export * from './nodes/affiliations';
|
|
130
131
|
export * from './nodes/contributors';
|
|
132
|
+
export * from './nodes/supplement';
|
|
133
|
+
export * from './nodes/supplements';
|
|
131
134
|
export const schema = new Schema({
|
|
132
135
|
marks: {
|
|
133
136
|
bold,
|
|
@@ -207,5 +210,7 @@ export const schema = new Schema({
|
|
|
207
210
|
title,
|
|
208
211
|
affiliations,
|
|
209
212
|
contributors,
|
|
213
|
+
supplements,
|
|
214
|
+
supplement,
|
|
210
215
|
},
|
|
211
216
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export const affiliation = {
|
|
2
|
+
content: 'inline*',
|
|
2
3
|
attrs: {
|
|
3
4
|
id: { default: '' },
|
|
4
5
|
institution: { default: '' },
|
|
@@ -8,6 +9,8 @@ export const affiliation = {
|
|
|
8
9
|
addressLine3: { default: '' },
|
|
9
10
|
postCode: { default: '' },
|
|
10
11
|
country: { default: '' },
|
|
12
|
+
county: { default: '' },
|
|
13
|
+
city: { default: '' },
|
|
11
14
|
priority: { default: undefined },
|
|
12
15
|
email: {
|
|
13
16
|
default: {
|
|
@@ -17,7 +20,7 @@ export const affiliation = {
|
|
|
17
20
|
},
|
|
18
21
|
dataTracked: { default: null },
|
|
19
22
|
},
|
|
20
|
-
group: 'block
|
|
23
|
+
group: 'block',
|
|
21
24
|
parseDOM: [
|
|
22
25
|
{
|
|
23
26
|
tag: 'div.affiliation',
|
|
@@ -3,6 +3,7 @@ export const contributor = {
|
|
|
3
3
|
attrs: {
|
|
4
4
|
id: { default: '' },
|
|
5
5
|
role: { default: '' },
|
|
6
|
+
email: { default: '' },
|
|
6
7
|
affiliations: { default: [] },
|
|
7
8
|
footnote: { default: undefined },
|
|
8
9
|
corresp: { default: undefined },
|
|
@@ -10,12 +11,13 @@ export const contributor = {
|
|
|
10
11
|
userID: { default: undefined },
|
|
11
12
|
invitationID: { default: undefined },
|
|
12
13
|
isCorresponding: { default: undefined },
|
|
14
|
+
isJointContributor: { default: undefined },
|
|
13
15
|
ORCIDIdentifier: { default: undefined },
|
|
14
16
|
priority: { default: undefined },
|
|
15
17
|
dataTracked: { default: null },
|
|
16
18
|
contents: { default: '' },
|
|
17
19
|
},
|
|
18
|
-
group: 'block
|
|
20
|
+
group: 'block',
|
|
19
21
|
toDOM: (node) => {
|
|
20
22
|
const contributorNode = node;
|
|
21
23
|
return [
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* ©
|
|
2
|
+
* © 2023 Atypon Systems LLC
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
* you may not use this file except in compliance with the License.
|
|
@@ -17,9 +17,8 @@ import { ObjectTypes } from '@manuscripts/json-schema';
|
|
|
17
17
|
export const equation = {
|
|
18
18
|
attrs: {
|
|
19
19
|
id: { default: '' },
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
TeXRepresentation: { default: '' },
|
|
20
|
+
contents: { default: '' },
|
|
21
|
+
format: { default: '' },
|
|
23
22
|
dataTracked: { default: null },
|
|
24
23
|
},
|
|
25
24
|
group: 'block',
|
|
@@ -27,26 +26,25 @@ export const equation = {
|
|
|
27
26
|
{
|
|
28
27
|
tag: `div.${ObjectTypes.Equation}`,
|
|
29
28
|
getAttrs: (p) => {
|
|
30
|
-
const
|
|
29
|
+
const htmlEl = p;
|
|
31
30
|
return {
|
|
32
|
-
id:
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
TeXRepresentation: dom.getAttribute('data-tex-representation'),
|
|
31
|
+
id: htmlEl.getAttribute('id'),
|
|
32
|
+
format: htmlEl.getAttribute('data-equation-format'),
|
|
33
|
+
contents: htmlEl.innerHTML,
|
|
36
34
|
};
|
|
37
35
|
},
|
|
38
36
|
},
|
|
39
37
|
],
|
|
40
38
|
toDOM: (node) => {
|
|
41
39
|
const equationNode = node;
|
|
40
|
+
const { id, contents, format } = equationNode.attrs;
|
|
42
41
|
const dom = document.createElement('div');
|
|
43
|
-
dom.setAttribute('id', equationNode.attrs.id);
|
|
44
42
|
dom.classList.add(ObjectTypes.Equation);
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
dom.setAttribute('id', id);
|
|
44
|
+
if (format) {
|
|
45
|
+
dom.setAttribute('data-equation-format', format);
|
|
47
46
|
}
|
|
48
|
-
dom.
|
|
49
|
-
dom.innerHTML = equationNode.attrs.SVGStringRepresentation;
|
|
47
|
+
dom.innerHTML = contents;
|
|
50
48
|
return dom;
|
|
51
49
|
},
|
|
52
50
|
};
|
|
@@ -14,11 +14,10 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
export const equationElement = {
|
|
17
|
-
content: '(equation | placeholder)
|
|
17
|
+
content: '(equation | placeholder)',
|
|
18
18
|
attrs: {
|
|
19
19
|
id: { default: '' },
|
|
20
|
-
|
|
21
|
-
suppressTitle: { default: undefined },
|
|
20
|
+
label: { default: '' },
|
|
22
21
|
dataTracked: { default: null },
|
|
23
22
|
comments: { default: null },
|
|
24
23
|
},
|
|
@@ -26,7 +25,7 @@ export const equationElement = {
|
|
|
26
25
|
group: 'block element',
|
|
27
26
|
parseDOM: [
|
|
28
27
|
{
|
|
29
|
-
tag: '
|
|
28
|
+
tag: 'div.equation',
|
|
30
29
|
getAttrs: (p) => {
|
|
31
30
|
const dom = p;
|
|
32
31
|
return {
|
|
@@ -38,7 +37,7 @@ export const equationElement = {
|
|
|
38
37
|
toDOM: (node) => {
|
|
39
38
|
const equationElementNode = node;
|
|
40
39
|
return [
|
|
41
|
-
'
|
|
40
|
+
'div',
|
|
42
41
|
{
|
|
43
42
|
class: 'equation',
|
|
44
43
|
id: equationElementNode.attrs.id,
|
|
@@ -13,43 +13,39 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { ObjectTypes } from '@manuscripts/json-schema';
|
|
17
16
|
export const inlineEquation = {
|
|
18
17
|
attrs: {
|
|
19
|
-
id: { default: '' },
|
|
20
|
-
MathMLRepresentation: { default: '' },
|
|
21
|
-
SVGRepresentation: { default: '' },
|
|
22
|
-
TeXRepresentation: { default: '' },
|
|
23
18
|
dataTracked: { default: null },
|
|
19
|
+
comments: { default: null },
|
|
20
|
+
contents: { default: '' },
|
|
21
|
+
format: { default: '' },
|
|
24
22
|
},
|
|
23
|
+
selectable: false,
|
|
25
24
|
atom: true,
|
|
26
25
|
inline: true,
|
|
27
26
|
draggable: true,
|
|
28
27
|
group: 'inline',
|
|
29
28
|
parseDOM: [
|
|
30
29
|
{
|
|
31
|
-
tag: `span
|
|
30
|
+
tag: `span.MPInlineMathFragment`,
|
|
32
31
|
getAttrs: (p) => {
|
|
33
32
|
const dom = p;
|
|
34
33
|
return {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
SVGRepresentation: dom.innerHTML || '',
|
|
38
|
-
TeXRepresentation: dom.getAttribute('data-tex-representation') || '',
|
|
34
|
+
format: dom.getAttribute('data-equation-format'),
|
|
35
|
+
contents: dom.innerHTML,
|
|
39
36
|
};
|
|
40
37
|
},
|
|
41
38
|
},
|
|
42
39
|
],
|
|
43
40
|
toDOM: (node) => {
|
|
44
41
|
const inlineEquationNode = node;
|
|
42
|
+
const { contents, format } = inlineEquationNode.attrs;
|
|
45
43
|
const dom = document.createElement('span');
|
|
46
|
-
dom.classList.add(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
if (inlineEquationNode.attrs.MathMLRepresentation) {
|
|
50
|
-
dom.setAttribute('data-mathml-representation', inlineEquationNode.attrs.MathMLRepresentation);
|
|
44
|
+
dom.classList.add('MPInlineMathFragment');
|
|
45
|
+
if (format) {
|
|
46
|
+
dom.setAttribute('data-equation-format', format);
|
|
51
47
|
}
|
|
52
|
-
dom.innerHTML =
|
|
48
|
+
dom.innerHTML = contents;
|
|
53
49
|
return dom;
|
|
54
50
|
},
|
|
55
51
|
};
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
export const manuscript = {
|
|
17
|
-
content: 'title? contributors? affiliations? keywords? abstracts body backmatter comments',
|
|
17
|
+
content: 'title? contributors? affiliations? keywords? supplements? abstracts body backmatter comments',
|
|
18
18
|
attrs: {
|
|
19
19
|
id: { default: '' },
|
|
20
20
|
},
|
|
@@ -0,0 +1,60 @@
|
|
|
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 supplement = {
|
|
17
|
+
attrs: {
|
|
18
|
+
id: { default: '' },
|
|
19
|
+
href: { default: '' },
|
|
20
|
+
mimeType: { default: '' },
|
|
21
|
+
mimeSubType: { default: '' },
|
|
22
|
+
title: { default: '' },
|
|
23
|
+
dataTracked: { default: null },
|
|
24
|
+
},
|
|
25
|
+
group: 'block',
|
|
26
|
+
parseDOM: [
|
|
27
|
+
{
|
|
28
|
+
tag: 'div.supplement',
|
|
29
|
+
getAttrs: (dom) => {
|
|
30
|
+
const el = dom;
|
|
31
|
+
const id = el.getAttribute('id');
|
|
32
|
+
const href = el.getAttribute('href');
|
|
33
|
+
const mimeType = el.getAttribute('mimeType');
|
|
34
|
+
const mimeSubType = el.getAttribute('mimeSubType');
|
|
35
|
+
const title = el.textContent;
|
|
36
|
+
return {
|
|
37
|
+
id,
|
|
38
|
+
href,
|
|
39
|
+
mimeType,
|
|
40
|
+
mimeSubType,
|
|
41
|
+
title,
|
|
42
|
+
};
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
toDOM: (node) => {
|
|
47
|
+
const supplement = node;
|
|
48
|
+
return [
|
|
49
|
+
'div',
|
|
50
|
+
{
|
|
51
|
+
id: supplement.attrs.id,
|
|
52
|
+
class: 'Supplement',
|
|
53
|
+
href: node.attrs.href,
|
|
54
|
+
mimeType: node.attrs.mimeType,
|
|
55
|
+
mimeSubType: node.attrs.mimeSubType,
|
|
56
|
+
title: node.attrs.title,
|
|
57
|
+
},
|
|
58
|
+
];
|
|
59
|
+
},
|
|
60
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
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 supplements = {
|
|
17
|
+
content: 'section_title supplement*',
|
|
18
|
+
attrs: {
|
|
19
|
+
id: { default: '' },
|
|
20
|
+
dataTracked: { default: null },
|
|
21
|
+
},
|
|
22
|
+
group: 'block',
|
|
23
|
+
selectable: false,
|
|
24
|
+
parseDOM: [
|
|
25
|
+
{
|
|
26
|
+
tag: 'div.supplements',
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
toDOM: (node) => {
|
|
30
|
+
const supplements = node;
|
|
31
|
+
return [
|
|
32
|
+
'div',
|
|
33
|
+
{
|
|
34
|
+
id: supplements.attrs.id,
|
|
35
|
+
class: 'supplements',
|
|
36
|
+
spellcheck: 'false',
|
|
37
|
+
contenteditable: false,
|
|
38
|
+
},
|
|
39
|
+
0,
|
|
40
|
+
];
|
|
41
|
+
},
|
|
42
|
+
};
|
|
@@ -95,12 +95,6 @@ export const buildNote = (target, source, contents = '') => ({
|
|
|
95
95
|
source,
|
|
96
96
|
contents,
|
|
97
97
|
});
|
|
98
|
-
export const buildInlineMathFragment = (containingObject, TeXRepresentation) => ({
|
|
99
|
-
_id: generateID(ObjectTypes.InlineMathFragment),
|
|
100
|
-
objectType: ObjectTypes.InlineMathFragment,
|
|
101
|
-
containingObject: containingObject || undefined,
|
|
102
|
-
TeXRepresentation,
|
|
103
|
-
});
|
|
104
98
|
export const buildFootnote = (containingObject, contents, kind = 'footnote') => ({
|
|
105
99
|
_id: generateID(ObjectTypes.Footnote),
|
|
106
100
|
objectType: ObjectTypes.Footnote,
|
|
@@ -55,6 +55,7 @@ const getSections = (modelMap) => getModelsByType(modelMap, ObjectTypes.Section)
|
|
|
55
55
|
const getAffiliations = (modelMap) => getModelsByType(modelMap, ObjectTypes.Affiliation);
|
|
56
56
|
const getContributors = (modelMap) => getModelsByType(modelMap, ObjectTypes.Contributor);
|
|
57
57
|
const getKeywordElements = (modelMap) => getModelsByType(modelMap, ObjectTypes.KeywordsElement);
|
|
58
|
+
const getSupplements = (modelMap) => getModelsByType(modelMap, ObjectTypes.Supplement);
|
|
58
59
|
const getKeywordGroups = (modelMap) => getModelsByType(modelMap, ObjectTypes.KeywordGroup);
|
|
59
60
|
const getKeywords = (modelMap) => getModelsByType(modelMap, ObjectTypes.Keyword);
|
|
60
61
|
const getTitles = (modelMap) => getModelsByType(modelMap, ObjectTypes.Titles)[0];
|
|
@@ -93,6 +94,15 @@ export class Decoder {
|
|
|
93
94
|
...elements,
|
|
94
95
|
]);
|
|
95
96
|
}
|
|
97
|
+
createSupplementsNode() {
|
|
98
|
+
const elements = getSupplements(this.modelMap)
|
|
99
|
+
.map((e) => this.decode(e))
|
|
100
|
+
.filter(Boolean);
|
|
101
|
+
return schema.nodes.supplements.createAndFill({}, [
|
|
102
|
+
schema.nodes.section_title.create({}, schema.text('SupplementaryMaterials')),
|
|
103
|
+
...elements,
|
|
104
|
+
]);
|
|
105
|
+
}
|
|
96
106
|
createCommentsNode() {
|
|
97
107
|
return schema.nodes.comments.createAndFill({}, [
|
|
98
108
|
...this.comments.values(),
|
|
@@ -262,9 +272,8 @@ export class Decoder {
|
|
|
262
272
|
const model = data;
|
|
263
273
|
return schema.nodes.equation.createChecked({
|
|
264
274
|
id: model._id,
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
TeXRepresentation: model.TeXRepresentation,
|
|
275
|
+
contents: model.contents,
|
|
276
|
+
format: model.format,
|
|
268
277
|
});
|
|
269
278
|
},
|
|
270
279
|
[ObjectTypes.EquationElement]: (data) => {
|
|
@@ -283,12 +292,10 @@ export class Decoder {
|
|
|
283
292
|
else {
|
|
284
293
|
throw new MissingElement(model.containedObjectID);
|
|
285
294
|
}
|
|
286
|
-
const figcaption = this.getFigcaption(model);
|
|
287
295
|
return schema.nodes.equation_element.createChecked({
|
|
288
296
|
id: model._id,
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
}, [equation, figcaption]);
|
|
297
|
+
label: model.label,
|
|
298
|
+
}, [equation]);
|
|
292
299
|
},
|
|
293
300
|
[ObjectTypes.FootnotesElement]: (data) => {
|
|
294
301
|
const foonotesElementModel = data;
|
|
@@ -609,6 +616,8 @@ export class Decoder {
|
|
|
609
616
|
addressLine3: model.addressLine3,
|
|
610
617
|
postCode: model.postCode,
|
|
611
618
|
country: model.country,
|
|
619
|
+
county: model.county,
|
|
620
|
+
city: model.city,
|
|
612
621
|
email: model.email,
|
|
613
622
|
department: model.department,
|
|
614
623
|
priority: model.priority,
|
|
@@ -620,6 +629,8 @@ export class Decoder {
|
|
|
620
629
|
id: model._id,
|
|
621
630
|
role: model.role,
|
|
622
631
|
affiliations: model.affiliations,
|
|
632
|
+
email: model.email,
|
|
633
|
+
isJointContributor: model.isJointContributor,
|
|
623
634
|
bibliographicName: model.bibliographicName,
|
|
624
635
|
userID: model.userID,
|
|
625
636
|
invitationID: model.invitationID,
|
|
@@ -630,6 +641,17 @@ export class Decoder {
|
|
|
630
641
|
priority: model.priority,
|
|
631
642
|
}, schema.text('_'));
|
|
632
643
|
},
|
|
644
|
+
[ObjectTypes.Supplement]: (data) => {
|
|
645
|
+
var _a, _b;
|
|
646
|
+
const model = data;
|
|
647
|
+
return schema.nodes.supplement.create({
|
|
648
|
+
id: model._id,
|
|
649
|
+
href: model.href,
|
|
650
|
+
mimeType: (_a = model.MIME) === null || _a === void 0 ? void 0 : _a.split('/')[0],
|
|
651
|
+
mimeSubType: (_b = model.MIME) === null || _b === void 0 ? void 0 : _b.split('/')[1],
|
|
652
|
+
title: model.title,
|
|
653
|
+
});
|
|
654
|
+
},
|
|
633
655
|
};
|
|
634
656
|
this.decode = (model) => {
|
|
635
657
|
if (!this.creators[model.objectType]) {
|
|
@@ -644,6 +666,7 @@ export class Decoder {
|
|
|
644
666
|
const contributors = this.createContributorsNode();
|
|
645
667
|
const affiliations = this.createAffiliationsNode();
|
|
646
668
|
const keywords = this.createKeywordsNode();
|
|
669
|
+
const suppl = this.createSupplementsNode();
|
|
647
670
|
const { abstracts, body, backmatter } = this.createContentSections();
|
|
648
671
|
const comments = this.createCommentsNode();
|
|
649
672
|
const contents = [
|
|
@@ -651,6 +674,7 @@ export class Decoder {
|
|
|
651
674
|
contributors,
|
|
652
675
|
affiliations,
|
|
653
676
|
keywords,
|
|
677
|
+
suppl,
|
|
654
678
|
abstracts,
|
|
655
679
|
body,
|
|
656
680
|
backmatter,
|
|
@@ -54,12 +54,6 @@ const listContents = (node) => {
|
|
|
54
54
|
}
|
|
55
55
|
return serializeToXML(output);
|
|
56
56
|
};
|
|
57
|
-
const svgDefs = (svg) => {
|
|
58
|
-
const template = document.createElement('template');
|
|
59
|
-
template.innerHTML = svg.trim();
|
|
60
|
-
const defs = template.content.querySelector('defs');
|
|
61
|
-
return defs ? serializeToXML(defs) : undefined;
|
|
62
|
-
};
|
|
63
57
|
const tableRowDisplayStyle = (tagName, parent) => {
|
|
64
58
|
switch (tagName) {
|
|
65
59
|
case 'thead':
|
|
@@ -345,20 +339,12 @@ const encoders = {
|
|
|
345
339
|
: false,
|
|
346
340
|
}),
|
|
347
341
|
equation: (node) => ({
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
SVGStringRepresentation: node.attrs.SVGStringRepresentation,
|
|
342
|
+
contents: node.attrs.contents,
|
|
343
|
+
format: node.attrs.format,
|
|
351
344
|
}),
|
|
352
345
|
equation_element: (node) => ({
|
|
353
346
|
containedObjectID: attributeOfNodeType(node, 'equation', 'id'),
|
|
354
|
-
|
|
355
|
-
title: inlineContentOfChildNodeType(node, node.type.schema.nodes.figcaption, node.type.schema.nodes.caption_title, false),
|
|
356
|
-
elementType: 'p',
|
|
357
|
-
suppressCaption: Boolean(node.attrs.suppressCaption) || undefined,
|
|
358
|
-
suppressTitle: node.attrs.suppressTitle === undefined ||
|
|
359
|
-
node.attrs.suppressTitle === true
|
|
360
|
-
? undefined
|
|
361
|
-
: false,
|
|
347
|
+
label: node.attrs.label,
|
|
362
348
|
}),
|
|
363
349
|
figure: (node) => ({
|
|
364
350
|
contentType: node.attrs.contentType || undefined,
|
|
@@ -405,12 +391,6 @@ const encoders = {
|
|
|
405
391
|
.map((childNode) => childNode.attrs.id)
|
|
406
392
|
.filter((id) => id),
|
|
407
393
|
}),
|
|
408
|
-
inline_equation: (node, parent) => ({
|
|
409
|
-
containingObject: parent.attrs.id,
|
|
410
|
-
TeXRepresentation: node.attrs.TeXRepresentation,
|
|
411
|
-
SVGRepresentation: node.attrs.SVGRepresentation,
|
|
412
|
-
SVGGlyphs: svgDefs(node.attrs.SVGRepresentation),
|
|
413
|
-
}),
|
|
414
394
|
keyword: (node, parent) => ({
|
|
415
395
|
containedGroup: parent.attrs.id,
|
|
416
396
|
name: keywordContents(node),
|
|
@@ -500,8 +480,11 @@ const encoders = {
|
|
|
500
480
|
addressLine1: node.attrs.addressLine1,
|
|
501
481
|
addressLine2: node.attrs.addressLine2,
|
|
502
482
|
addressLine3: node.attrs.addressLine3,
|
|
483
|
+
department: node.attrs.department,
|
|
503
484
|
postCode: node.attrs.postCode,
|
|
504
485
|
country: node.attrs.country,
|
|
486
|
+
county: node.attrs.county,
|
|
487
|
+
city: node.attrs.city,
|
|
505
488
|
email: node.attrs.email,
|
|
506
489
|
priority: node.attrs.priority,
|
|
507
490
|
}),
|
|
@@ -512,11 +495,19 @@ const encoders = {
|
|
|
512
495
|
userID: node.attrs.userID,
|
|
513
496
|
invitationID: node.attrs.invitationID,
|
|
514
497
|
isCorresponding: node.attrs.isCorresponding,
|
|
498
|
+
isJointContributor: node.attrs.isJointContributor,
|
|
515
499
|
ORCIDIdentifier: node.attrs.ORCIDIdentifier,
|
|
516
500
|
footnote: node.attrs.footnote,
|
|
517
501
|
corresp: node.attrs.corresp,
|
|
518
502
|
priority: node.attrs.priority,
|
|
519
503
|
}),
|
|
504
|
+
supplement: (node) => ({
|
|
505
|
+
href: node.attrs.href,
|
|
506
|
+
title: node.attrs.title,
|
|
507
|
+
MIME: node.attrs.mimeType && node.attrs.mimeSubType
|
|
508
|
+
? [node.attrs.mimeType, node.attrs.mimeSubType].join('/')
|
|
509
|
+
: '',
|
|
510
|
+
}),
|
|
520
511
|
};
|
|
521
512
|
const modelData = (node, parent, path, priority) => {
|
|
522
513
|
const encoder = encoders[node.type.name];
|
|
@@ -544,6 +535,7 @@ const containerTypes = [
|
|
|
544
535
|
schema.nodes.contributors,
|
|
545
536
|
schema.nodes.affiliations,
|
|
546
537
|
schema.nodes.keywords,
|
|
538
|
+
schema.nodes.supplements,
|
|
547
539
|
schema.nodes.abstracts,
|
|
548
540
|
schema.nodes.body,
|
|
549
541
|
schema.nodes.backmatter,
|
|
@@ -571,8 +563,7 @@ export const encode = (node) => {
|
|
|
571
563
|
if (placeholderTypes.includes(child.type)) {
|
|
572
564
|
return;
|
|
573
565
|
}
|
|
574
|
-
if (parent.type === schema.nodes.paragraph
|
|
575
|
-
child.type !== schema.nodes.inline_equation) {
|
|
566
|
+
if (parent.type === schema.nodes.paragraph) {
|
|
576
567
|
return;
|
|
577
568
|
}
|
|
578
569
|
const { model, markers } = modelFromNode(child, parent, path, priority);
|
|
@@ -36,7 +36,6 @@ export const nodeTypesMap = new Map([
|
|
|
36
36
|
[schema.nodes.footnotes_section, ObjectTypes.Section],
|
|
37
37
|
[schema.nodes.graphical_abstract_section, ObjectTypes.Section],
|
|
38
38
|
[schema.nodes.highlight_marker, ObjectTypes.HighlightMarker],
|
|
39
|
-
[schema.nodes.inline_equation, ObjectTypes.InlineMathFragment],
|
|
40
39
|
[schema.nodes.keyword, ObjectTypes.Keyword],
|
|
41
40
|
[schema.nodes.keywords_element, ObjectTypes.KeywordsElement],
|
|
42
41
|
[schema.nodes.keywords, ObjectTypes.Section],
|
|
@@ -58,6 +57,7 @@ export const nodeTypesMap = new Map([
|
|
|
58
57
|
[schema.nodes.contributors, ObjectTypes.Section],
|
|
59
58
|
[schema.nodes.affiliations, ObjectTypes.Section],
|
|
60
59
|
[schema.nodes.title, ObjectTypes.Titles],
|
|
60
|
+
[schema.nodes.supplement, ObjectTypes.Supplement],
|
|
61
61
|
]);
|
|
62
62
|
export const isExecutableNodeType = (type) => hasGroup(type, GROUP_EXECUTABLE);
|
|
63
63
|
export const isElementNodeType = (type) => hasGroup(type, GROUP_ELEMENT);
|
package/dist/types/index.d.ts
CHANGED
|
@@ -34,4 +34,5 @@ export declare const jatsBodyTransformations: {
|
|
|
34
34
|
fixTables(body: Element, createElement: (tagName: string) => HTMLElement): void;
|
|
35
35
|
moveFloatsGroupToBody(doc: Document, body: Element, createElement: (tagName: string) => HTMLElement): void;
|
|
36
36
|
createKeywords(document: Document, body: Element, createElement: (tagName: string) => HTMLElement): void;
|
|
37
|
+
createSuppleMaterials(document: Document, body: Element, createElement: (tagName: string) => HTMLElement): void;
|
|
37
38
|
};
|
|
@@ -58,7 +58,6 @@ export declare const jatsFrontParser: {
|
|
|
58
58
|
revisionReceiveDate?: number | undefined;
|
|
59
59
|
receiveDate?: number | undefined;
|
|
60
60
|
} | undefined;
|
|
61
|
-
parseSupplements(elements: Element[] | null): import("../../transformer").Build<import("@manuscripts/json-schema/dist/types").Supplement>[];
|
|
62
61
|
parseAffiliations(elements: Element[]): {
|
|
63
62
|
affiliations: import("../../transformer").Build<import("@manuscripts/json-schema/dist/types").Affiliation>[];
|
|
64
63
|
affiliationIDs: Map<string, string>;
|
|
@@ -40,7 +40,6 @@ export * from './nodes/footnotes_section';
|
|
|
40
40
|
export * from './nodes/graphical_abstract_section';
|
|
41
41
|
export * from './nodes/hard_break';
|
|
42
42
|
export * from './nodes/highlight_marker';
|
|
43
|
-
export * from './nodes/inline_equation';
|
|
44
43
|
export * from './nodes/inline_footnote';
|
|
45
44
|
export * from './nodes/keyword';
|
|
46
45
|
export * from './nodes/keywords_element';
|
|
@@ -70,4 +69,6 @@ export * from './nodes/table_element_footer';
|
|
|
70
69
|
export * from './nodes/title';
|
|
71
70
|
export * from './nodes/affiliations';
|
|
72
71
|
export * from './nodes/contributors';
|
|
72
|
+
export * from './nodes/supplement';
|
|
73
|
+
export * from './nodes/supplements';
|
|
73
74
|
export declare const schema: Schema<Nodes, Marks>;
|
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BibliographicName } from '@manuscripts/json-schema';
|
|
2
2
|
import { NodeSpec } from 'prosemirror-model';
|
|
3
3
|
import { ManuscriptNode } from '../types';
|
|
4
4
|
interface Attrs {
|
|
5
5
|
id: string;
|
|
6
6
|
role: string;
|
|
7
|
-
affiliations:
|
|
7
|
+
affiliations: string[];
|
|
8
8
|
bibliographicName: BibliographicName;
|
|
9
9
|
userID: string;
|
|
10
|
+
email: string;
|
|
10
11
|
invitationID: string;
|
|
11
12
|
isCorresponding: boolean;
|
|
12
13
|
ORCIDIdentifier: string;
|
|
13
14
|
priority: number;
|
|
15
|
+
isJointContributor: boolean;
|
|
14
16
|
}
|
|
15
17
|
export interface ContributorNode extends ManuscriptNode {
|
|
16
18
|
attrs: Attrs;
|