@manuscripts/transform 2.0.1-LEAN-3083-3 → 2.0.1-LEAN-3092
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 +24 -72
- package/dist/cjs/jats/jats-exporter.js +17 -37
- package/dist/cjs/schema/index.js +0 -1
- package/dist/cjs/schema/nodes/contributor.js +0 -2
- 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/transformer/builders.js +1 -8
- package/dist/cjs/transformer/decode.js +4 -8
- package/dist/cjs/transformer/encode.js +4 -25
- package/dist/cjs/transformer/node-types.js +0 -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 +25 -73
- package/dist/es/jats/jats-exporter.js +17 -37
- package/dist/es/schema/index.js +0 -1
- package/dist/es/schema/nodes/contributor.js +0 -2
- 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/transformer/builders.js +0 -6
- package/dist/es/transformer/decode.js +4 -8
- package/dist/es/transformer/encode.js +4 -25
- package/dist/es/transformer/node-types.js +0 -1
- package/dist/es/transformer/object-types.js +0 -1
- package/dist/types/index.d.ts +0 -1
- package/dist/types/schema/index.d.ts +0 -1
- package/dist/types/schema/nodes/contributor.d.ts +2 -4
- 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/types/transformer/builders.d.ts +1 -2
- package/package.json +2 -3
- package/dist/cjs/mathjax/index.js +0 -41
- package/dist/cjs/mathjax/mathjax-packages.js +0 -20
- 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/mathjax-packages.js +0 -17
- 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
|
@@ -15,10 +15,8 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import mime from 'mime';
|
|
17
17
|
import { DOMParser, Fragment } from 'prosemirror-model';
|
|
18
|
-
import { convertMathMLToSVG } from '../../mathjax/mathml-to-svg';
|
|
19
|
-
import { convertTeXToSVG } from '../../mathjax/tex-to-svg';
|
|
20
18
|
import { schema } from '../../schema';
|
|
21
|
-
import { chooseSectionCategory
|
|
19
|
+
import { chooseSectionCategory } from '../../transformer';
|
|
22
20
|
const XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
|
|
23
21
|
const chooseContentType = (graphicNode) => {
|
|
24
22
|
if (graphicNode) {
|
|
@@ -33,6 +31,24 @@ const chooseContentType = (graphicNode) => {
|
|
|
33
31
|
}
|
|
34
32
|
}
|
|
35
33
|
};
|
|
34
|
+
const getEquationContent = (p) => {
|
|
35
|
+
var _a;
|
|
36
|
+
const element = p;
|
|
37
|
+
const container = (_a = element.querySelector('alternatives')) !== null && _a !== void 0 ? _a : element;
|
|
38
|
+
let contents = '';
|
|
39
|
+
let format = '';
|
|
40
|
+
for (const child of container.childNodes) {
|
|
41
|
+
const nodeName = child.nodeName.replace(/^[a-z]:/, '');
|
|
42
|
+
switch (nodeName) {
|
|
43
|
+
case 'tex-math':
|
|
44
|
+
case 'mml:math':
|
|
45
|
+
contents = child.outerHTML;
|
|
46
|
+
format = nodeName === 'tex-math' ? 'tex' : 'mathml';
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return { format, contents };
|
|
51
|
+
};
|
|
36
52
|
const marks = [
|
|
37
53
|
{
|
|
38
54
|
tag: 'bold',
|
|
@@ -141,91 +157,27 @@ const nodes = [
|
|
|
141
157
|
tag: 'inline-formula',
|
|
142
158
|
node: 'inline_equation',
|
|
143
159
|
getAttrs: (node) => {
|
|
144
|
-
var _a, _b, _c, _d, _e;
|
|
145
160
|
const element = node;
|
|
146
|
-
|
|
147
|
-
id: element.getAttribute('id'),
|
|
148
|
-
MathMLRepresentation: '',
|
|
149
|
-
SVGRepresentation: '',
|
|
150
|
-
TeXRepresentation: '',
|
|
151
|
-
};
|
|
152
|
-
const container = (_a = element.querySelector('alternatives')) !== null && _a !== void 0 ? _a : element;
|
|
153
|
-
for (const child of container.childNodes) {
|
|
154
|
-
const nodeName = child.nodeName.replace(/^[a-z]:/, '');
|
|
155
|
-
switch (nodeName) {
|
|
156
|
-
case 'tex-math':
|
|
157
|
-
attrs.TeXRepresentation = (_c = (_b = child.textContent) === null || _b === void 0 ? void 0 : _b.trim()) !== null && _c !== void 0 ? _c : '';
|
|
158
|
-
if (attrs.TeXRepresentation) {
|
|
159
|
-
attrs.SVGRepresentation =
|
|
160
|
-
(_d = convertTeXToSVG(attrs.TeXRepresentation, true)) !== null && _d !== void 0 ? _d : '';
|
|
161
|
-
}
|
|
162
|
-
break;
|
|
163
|
-
case 'mml:math':
|
|
164
|
-
;
|
|
165
|
-
child.removeAttribute('id');
|
|
166
|
-
attrs.MathMLRepresentation = xmlSerializer.serializeToString(child);
|
|
167
|
-
if (attrs.MathMLRepresentation) {
|
|
168
|
-
attrs.SVGRepresentation =
|
|
169
|
-
(_e = convertMathMLToSVG(attrs.MathMLRepresentation, true)) !== null && _e !== void 0 ? _e : '';
|
|
170
|
-
}
|
|
171
|
-
break;
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
return attrs;
|
|
161
|
+
return getEquationContent(element);
|
|
175
162
|
},
|
|
176
163
|
},
|
|
177
164
|
{
|
|
178
165
|
tag: 'disp-formula',
|
|
179
166
|
node: 'equation_element',
|
|
180
167
|
getAttrs: (node) => {
|
|
168
|
+
var _a, _b;
|
|
181
169
|
const element = node;
|
|
182
|
-
const caption = element.querySelector('figcaption');
|
|
183
170
|
return {
|
|
184
171
|
id: element.getAttribute('id'),
|
|
185
|
-
|
|
172
|
+
label: (_b = (_a = element.querySelector('label')) === null || _a === void 0 ? void 0 : _a.textContent) !== null && _b !== void 0 ? _b : '',
|
|
186
173
|
};
|
|
187
174
|
},
|
|
188
175
|
getContent: (node, schema) => {
|
|
189
|
-
var _a, _b, _c, _d, _e;
|
|
190
176
|
const element = node;
|
|
191
|
-
const attrs =
|
|
192
|
-
|
|
193
|
-
SVGStringRepresentation: '',
|
|
194
|
-
TeXRepresentation: '',
|
|
195
|
-
};
|
|
196
|
-
const container = (_a = element.querySelector('alternatives')) !== null && _a !== void 0 ? _a : element;
|
|
197
|
-
for (const child of container.childNodes) {
|
|
198
|
-
const nodeName = child.nodeName.replace(/^[a-z]:/, '');
|
|
199
|
-
switch (nodeName) {
|
|
200
|
-
case 'tex-math':
|
|
201
|
-
attrs.TeXRepresentation = (_c = (_b = child.textContent) === null || _b === void 0 ? void 0 : _b.trim()) !== null && _c !== void 0 ? _c : '';
|
|
202
|
-
if (attrs.TeXRepresentation) {
|
|
203
|
-
attrs.SVGStringRepresentation =
|
|
204
|
-
(_d = convertTeXToSVG(attrs.TeXRepresentation, true)) !== null && _d !== void 0 ? _d : '';
|
|
205
|
-
}
|
|
206
|
-
break;
|
|
207
|
-
case 'mml:math':
|
|
208
|
-
;
|
|
209
|
-
child.removeAttribute('id');
|
|
210
|
-
attrs.MathMLStringRepresentation =
|
|
211
|
-
xmlSerializer.serializeToString(child);
|
|
212
|
-
if (attrs.MathMLStringRepresentation) {
|
|
213
|
-
attrs.SVGStringRepresentation =
|
|
214
|
-
(_e = convertMathMLToSVG(attrs.MathMLStringRepresentation, true)) !== null && _e !== void 0 ? _e : '';
|
|
215
|
-
}
|
|
216
|
-
break;
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
const caption = element.querySelector('figcaption');
|
|
220
|
-
const figcaption = schema.nodes.figcaption.create();
|
|
177
|
+
const attrs = getEquationContent(element);
|
|
178
|
+
const id = element.getAttribute('id');
|
|
221
179
|
return Fragment.from([
|
|
222
|
-
schema.nodes.equation.createChecked(attrs),
|
|
223
|
-
caption
|
|
224
|
-
?
|
|
225
|
-
jatsBodyDOMParser.parse(caption, {
|
|
226
|
-
topNode: figcaption,
|
|
227
|
-
})
|
|
228
|
-
: figcaption,
|
|
180
|
+
schema.nodes.equation.createChecked(Object.assign({ id }, attrs)),
|
|
229
181
|
]);
|
|
230
182
|
},
|
|
231
183
|
},
|
|
@@ -145,6 +145,7 @@ export class JATSExporter {
|
|
|
145
145
|
};
|
|
146
146
|
this.nodeFromJATS = (JATSFragment) => {
|
|
147
147
|
JATSFragment = JATSFragment.trim();
|
|
148
|
+
JATSFragment = JATSFragment.replace(' ', ' ');
|
|
148
149
|
if (!JATSFragment.length) {
|
|
149
150
|
return null;
|
|
150
151
|
}
|
|
@@ -665,22 +666,23 @@ export class JATSExporter {
|
|
|
665
666
|
},
|
|
666
667
|
doc: () => '',
|
|
667
668
|
equation: (node) => {
|
|
668
|
-
const
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
669
|
+
const math = this.nodeFromJATS(node.attrs.contents);
|
|
670
|
+
const mathEl = math;
|
|
671
|
+
mathEl.setAttribute('id', normalizeID(node.attrs.id));
|
|
672
|
+
return mathEl;
|
|
673
|
+
},
|
|
674
|
+
inline_equation: (node) => {
|
|
675
|
+
const eqElement = this.document.createElement('inline-formula');
|
|
676
|
+
const math = this.nodeFromJATS(node.attrs.contents);
|
|
677
|
+
eqElement.append(math);
|
|
678
|
+
return eqElement;
|
|
679
|
+
},
|
|
680
|
+
equation_element: (node) => {
|
|
681
|
+
const eqElement = this.document.createElement('disp-formula');
|
|
682
|
+
eqElement.setAttribute('id', normalizeID(node.attrs.id));
|
|
683
|
+
processChildNodes(eqElement, node, schema.nodes.equation);
|
|
684
|
+
return eqElement;
|
|
682
685
|
},
|
|
683
|
-
equation_element: (node) => createFigureElement(node, 'fig', node.type.schema.nodes.equation, 'equation'),
|
|
684
686
|
figcaption: (node) => {
|
|
685
687
|
if (!node.textContent) {
|
|
686
688
|
return '';
|
|
@@ -730,28 +732,6 @@ export class JATSExporter {
|
|
|
730
732
|
},
|
|
731
733
|
hard_break: () => '',
|
|
732
734
|
highlight_marker: () => '',
|
|
733
|
-
inline_equation: (node) => {
|
|
734
|
-
const formula = this.document.createElement('inline-formula');
|
|
735
|
-
formula.setAttribute('id', normalizeID(node.attrs.id));
|
|
736
|
-
if (node.attrs.TeXRepresentation) {
|
|
737
|
-
const math = this.document.createElement('tex-math');
|
|
738
|
-
math.textContent = node.attrs.TeXRepresentation;
|
|
739
|
-
formula.appendChild(math);
|
|
740
|
-
}
|
|
741
|
-
else if (node.attrs.MathMLRepresentation) {
|
|
742
|
-
const math = this.nodeFromJATS(node.attrs.MathMLRepresentation);
|
|
743
|
-
if (math) {
|
|
744
|
-
formula.appendChild(math);
|
|
745
|
-
}
|
|
746
|
-
}
|
|
747
|
-
else if (node.attrs.SVGRepresentation) {
|
|
748
|
-
const math = this.nodeFromJATS(node.attrs.SVGRepresentation);
|
|
749
|
-
if (math) {
|
|
750
|
-
formula.appendChild(math);
|
|
751
|
-
}
|
|
752
|
-
}
|
|
753
|
-
return formula;
|
|
754
|
-
},
|
|
755
735
|
inline_footnote: (node) => {
|
|
756
736
|
const xref = this.document.createElement('xref');
|
|
757
737
|
xref.setAttribute('ref-type', 'fn');
|
package/dist/es/schema/index.js
CHANGED
|
@@ -98,7 +98,6 @@ export * from './nodes/footnotes_section';
|
|
|
98
98
|
export * from './nodes/graphical_abstract_section';
|
|
99
99
|
export * from './nodes/hard_break';
|
|
100
100
|
export * from './nodes/highlight_marker';
|
|
101
|
-
export * from './nodes/inline_equation';
|
|
102
101
|
export * from './nodes/inline_footnote';
|
|
103
102
|
export * from './nodes/keyword';
|
|
104
103
|
export * from './nodes/keywords_element';
|
|
@@ -3,7 +3,6 @@ export const contributor = {
|
|
|
3
3
|
attrs: {
|
|
4
4
|
id: { default: '' },
|
|
5
5
|
role: { default: '' },
|
|
6
|
-
email: { default: '' },
|
|
7
6
|
affiliations: { default: [] },
|
|
8
7
|
footnote: { default: undefined },
|
|
9
8
|
corresp: { default: undefined },
|
|
@@ -11,7 +10,6 @@ export const contributor = {
|
|
|
11
10
|
userID: { default: undefined },
|
|
12
11
|
invitationID: { default: undefined },
|
|
13
12
|
isCorresponding: { default: undefined },
|
|
14
|
-
isJointContributor: { default: undefined },
|
|
15
13
|
ORCIDIdentifier: { default: undefined },
|
|
16
14
|
priority: { default: undefined },
|
|
17
15
|
dataTracked: { default: null },
|
|
@@ -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
|
};
|
|
@@ -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,
|
|
@@ -262,9 +262,8 @@ export class Decoder {
|
|
|
262
262
|
const model = data;
|
|
263
263
|
return schema.nodes.equation.createChecked({
|
|
264
264
|
id: model._id,
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
TeXRepresentation: model.TeXRepresentation,
|
|
265
|
+
contents: model.contents,
|
|
266
|
+
format: model.format,
|
|
268
267
|
});
|
|
269
268
|
},
|
|
270
269
|
[ObjectTypes.EquationElement]: (data) => {
|
|
@@ -283,12 +282,10 @@ export class Decoder {
|
|
|
283
282
|
else {
|
|
284
283
|
throw new MissingElement(model.containedObjectID);
|
|
285
284
|
}
|
|
286
|
-
const figcaption = this.getFigcaption(model);
|
|
287
285
|
return schema.nodes.equation_element.createChecked({
|
|
288
286
|
id: model._id,
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
}, [equation, figcaption]);
|
|
287
|
+
label: model.label,
|
|
288
|
+
}, [equation]);
|
|
292
289
|
},
|
|
293
290
|
[ObjectTypes.FootnotesElement]: (data) => {
|
|
294
291
|
const foonotesElementModel = data;
|
|
@@ -620,7 +617,6 @@ export class Decoder {
|
|
|
620
617
|
id: model._id,
|
|
621
618
|
role: model.role,
|
|
622
619
|
affiliations: model.affiliations,
|
|
623
|
-
email: model.email,
|
|
624
620
|
bibliographicName: model.bibliographicName,
|
|
625
621
|
userID: model.userID,
|
|
626
622
|
invitationID: model.invitationID,
|
|
@@ -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),
|
|
@@ -571,8 +551,7 @@ export const encode = (node) => {
|
|
|
571
551
|
if (placeholderTypes.includes(child.type)) {
|
|
572
552
|
return;
|
|
573
553
|
}
|
|
574
|
-
if (parent.type === schema.nodes.paragraph
|
|
575
|
-
child.type !== schema.nodes.inline_equation) {
|
|
554
|
+
if (parent.type === schema.nodes.paragraph) {
|
|
576
555
|
return;
|
|
577
556
|
}
|
|
578
557
|
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],
|
package/dist/types/index.d.ts
CHANGED
|
@@ -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';
|
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
import { BibliographicName } from '@manuscripts/json-schema';
|
|
1
|
+
import { Affiliation, 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: Affiliation[];
|
|
8
8
|
bibliographicName: BibliographicName;
|
|
9
9
|
userID: string;
|
|
10
|
-
email: string;
|
|
11
10
|
invitationID: string;
|
|
12
11
|
isCorresponding: boolean;
|
|
13
12
|
ORCIDIdentifier: string;
|
|
14
13
|
priority: number;
|
|
15
|
-
isJointContributor: boolean;
|
|
16
14
|
}
|
|
17
15
|
export interface ContributorNode extends ManuscriptNode {
|
|
18
16
|
attrs: Attrs;
|
|
@@ -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 { NodeSpec } from 'prosemirror-model';
|
|
|
17
17
|
import { ManuscriptNode } from '../types';
|
|
18
18
|
interface Attrs {
|
|
19
19
|
id: string;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
TeXRepresentation: string;
|
|
20
|
+
format: string;
|
|
21
|
+
contents: string;
|
|
23
22
|
}
|
|
24
23
|
export interface EquationNode extends ManuscriptNode {
|
|
25
24
|
attrs: Attrs;
|
|
@@ -18,8 +18,7 @@ import { ManuscriptNode } from '../types';
|
|
|
18
18
|
import { CommentNode } from './comment';
|
|
19
19
|
interface Attrs {
|
|
20
20
|
id: string;
|
|
21
|
-
|
|
22
|
-
suppressTitle?: boolean;
|
|
21
|
+
label: string;
|
|
23
22
|
comments?: CommentNode[];
|
|
24
23
|
}
|
|
25
24
|
export interface EquationElementNode extends ManuscriptNode {
|
|
@@ -15,11 +15,11 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { NodeSpec } from 'prosemirror-model';
|
|
17
17
|
import { ManuscriptNode } from '../types';
|
|
18
|
+
import { CommentNode } from './comment';
|
|
18
19
|
interface Attrs {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
TeXRepresentation: string;
|
|
20
|
+
contents: string;
|
|
21
|
+
format: string;
|
|
22
|
+
comments?: CommentNode[];
|
|
23
23
|
}
|
|
24
24
|
export interface InlineEquationNode extends ManuscriptNode {
|
|
25
25
|
attrs: Attrs;
|
|
@@ -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 { Affiliation, Attribution, BibliographicDate, BibliographicName, BibliographyElement, BibliographyItem, Color, CommentAnnotation, Contribution, Contributor, ContributorRole, Corresponding, ElementsOrder, EmbeddedModel, Figure, Footnote, FootnotesOrder,
|
|
16
|
+
import { Affiliation, Attribution, BibliographicDate, BibliographicName, BibliographyElement, BibliographyItem, Color, CommentAnnotation, Contribution, Contributor, ContributorRole, Corresponding, ElementsOrder, EmbeddedModel, Figure, Footnote, FootnotesOrder, Journal, Keyword, KeywordGroup, Manuscript, ManuscriptNote, ObjectTypes, ParagraphElement, Project, Section, Supplement, Titles } from '@manuscripts/json-schema';
|
|
17
17
|
import { FootnotesOrderIndexList } from './footnotes-order';
|
|
18
18
|
import { CommentSelector, ManuscriptModel, ModelAttachment } from './models';
|
|
19
19
|
export type Build<T> = Pick<T, Exclude<keyof T, keyof ManuscriptModel>> & {
|
|
@@ -44,7 +44,6 @@ export declare const buildAffiliation: (institution: string, priority?: number)
|
|
|
44
44
|
export declare const buildSupplementaryMaterial: (title: string, href: string) => Build<Supplement>;
|
|
45
45
|
export declare const buildComment: (target: string, contents?: string, selector?: CommentSelector, contributions?: Contribution[], annotationColor?: string) => Build<CommentAnnotation>;
|
|
46
46
|
export declare const buildNote: (target: string, source: 'EMAIL' | 'EDITOR' | 'DASHBOARD', contents?: string) => Build<ManuscriptNote>;
|
|
47
|
-
export declare const buildInlineMathFragment: (containingObject: string, TeXRepresentation: string) => Build<InlineMathFragment>;
|
|
48
47
|
export declare const buildFootnote: (containingObject: string, contents: string, kind?: 'footnote' | 'endnote') => Build<Footnote>;
|
|
49
48
|
export declare const buildFootnotesOrder: (footnotesList: FootnotesOrderIndexList) => Build<FootnotesOrder>;
|
|
50
49
|
export declare const buildCorresp: (contents: string) => Build<Corresponding>;
|
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.0.1-LEAN-
|
|
4
|
+
"version": "2.0.1-LEAN-3092",
|
|
5
5
|
"repository": "github:Atypon-OpenSource/manuscripts-transform",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|
|
@@ -29,10 +29,9 @@
|
|
|
29
29
|
"version": "yarn build"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@manuscripts/json-schema": "2.2.1",
|
|
32
|
+
"@manuscripts/json-schema": "2.2.1-LEAN-3092-v2",
|
|
33
33
|
"debug": "^4.3.4",
|
|
34
34
|
"jszip": "^3.10.1",
|
|
35
|
-
"mathjax-full": "^3.2.2",
|
|
36
35
|
"mime": "^3.0.0",
|
|
37
36
|
"prosemirror-model": "^1.18.3",
|
|
38
37
|
"uuid": "^9.0.0",
|