@manuscripts/transform 2.1.1-LEAN-3336-3 → 2.1.1-LEAN-3092-1
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 +25 -73
- package/dist/cjs/jats/jats-exporter.js +18 -42
- package/dist/cjs/schema/index.js +1 -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/schema/nodes/table.js +15 -2
- package/dist/cjs/schema/nodes/table_row.js +6 -7
- package/dist/cjs/transformer/builders.js +1 -8
- package/dist/cjs/transformer/decode.js +4 -7
- package/dist/cjs/transformer/encode.js +23 -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 +26 -74
- package/dist/es/jats/jats-exporter.js +18 -42
- package/dist/es/schema/index.js +3 -4
- 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/table.js +14 -1
- package/dist/es/schema/nodes/table_row.js +5 -6
- package/dist/es/transformer/builders.js +0 -6
- package/dist/es/transformer/decode.js +4 -7
- package/dist/es/transformer/encode.js +23 -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/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/schema/nodes/table.d.ts +1 -0
- package/dist/types/schema/nodes/table_row.d.ts +0 -1
- package/dist/types/schema/types.d.ts +1 -1
- package/dist/types/transformer/builders.d.ts +1 -2
- package/package.json +3 -4
- 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
package/dist/cjs/index.js
CHANGED
|
@@ -18,7 +18,6 @@ exports.isSectionLabelNode = void 0;
|
|
|
18
18
|
__exportStar(require("./lib/section-group-type"), exports);
|
|
19
19
|
__exportStar(require("./lib/table-cell-styles"), exports);
|
|
20
20
|
__exportStar(require("./lib/utils"), exports);
|
|
21
|
-
__exportStar(require("./mathjax"), exports);
|
|
22
21
|
__exportStar(require("./schema"), exports);
|
|
23
22
|
__exportStar(require("./transformer"), exports);
|
|
24
23
|
__exportStar(require("./jats"), exports);
|
|
@@ -21,8 +21,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
21
21
|
exports.jatsBodyDOMParser = void 0;
|
|
22
22
|
const mime_1 = __importDefault(require("mime"));
|
|
23
23
|
const prosemirror_model_1 = require("prosemirror-model");
|
|
24
|
-
const mathml_to_svg_1 = require("../../mathjax/mathml-to-svg");
|
|
25
|
-
const tex_to_svg_1 = require("../../mathjax/tex-to-svg");
|
|
26
24
|
const schema_1 = require("../../schema");
|
|
27
25
|
const transformer_1 = require("../../transformer");
|
|
28
26
|
const XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
|
|
@@ -39,6 +37,24 @@ const chooseContentType = (graphicNode) => {
|
|
|
39
37
|
}
|
|
40
38
|
}
|
|
41
39
|
};
|
|
40
|
+
const getEquationContent = (p) => {
|
|
41
|
+
var _a;
|
|
42
|
+
const element = p;
|
|
43
|
+
const container = (_a = element.querySelector('alternatives')) !== null && _a !== void 0 ? _a : element;
|
|
44
|
+
let contents = '';
|
|
45
|
+
let format = '';
|
|
46
|
+
for (const child of container.childNodes) {
|
|
47
|
+
const nodeName = child.nodeName.replace(/^[a-z]:/, '');
|
|
48
|
+
switch (nodeName) {
|
|
49
|
+
case 'tex-math':
|
|
50
|
+
case 'mml:math':
|
|
51
|
+
contents = child.outerHTML;
|
|
52
|
+
format = nodeName === 'tex-math' ? 'tex' : 'mathml';
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return { format, contents };
|
|
57
|
+
};
|
|
42
58
|
const marks = [
|
|
43
59
|
{
|
|
44
60
|
tag: 'bold',
|
|
@@ -147,91 +163,27 @@ const nodes = [
|
|
|
147
163
|
tag: 'inline-formula',
|
|
148
164
|
node: 'inline_equation',
|
|
149
165
|
getAttrs: (node) => {
|
|
150
|
-
var _a, _b, _c, _d, _e;
|
|
151
166
|
const element = node;
|
|
152
|
-
|
|
153
|
-
id: element.getAttribute('id'),
|
|
154
|
-
MathMLRepresentation: '',
|
|
155
|
-
SVGRepresentation: '',
|
|
156
|
-
TeXRepresentation: '',
|
|
157
|
-
};
|
|
158
|
-
const container = (_a = element.querySelector('alternatives')) !== null && _a !== void 0 ? _a : element;
|
|
159
|
-
for (const child of container.childNodes) {
|
|
160
|
-
const nodeName = child.nodeName.replace(/^[a-z]:/, '');
|
|
161
|
-
switch (nodeName) {
|
|
162
|
-
case 'tex-math':
|
|
163
|
-
attrs.TeXRepresentation = (_c = (_b = child.textContent) === null || _b === void 0 ? void 0 : _b.trim()) !== null && _c !== void 0 ? _c : '';
|
|
164
|
-
if (attrs.TeXRepresentation) {
|
|
165
|
-
attrs.SVGRepresentation =
|
|
166
|
-
(_d = (0, tex_to_svg_1.convertTeXToSVG)(attrs.TeXRepresentation, true)) !== null && _d !== void 0 ? _d : '';
|
|
167
|
-
}
|
|
168
|
-
break;
|
|
169
|
-
case 'mml:math':
|
|
170
|
-
;
|
|
171
|
-
child.removeAttribute('id');
|
|
172
|
-
attrs.MathMLRepresentation = transformer_1.xmlSerializer.serializeToString(child);
|
|
173
|
-
if (attrs.MathMLRepresentation) {
|
|
174
|
-
attrs.SVGRepresentation =
|
|
175
|
-
(_e = (0, mathml_to_svg_1.convertMathMLToSVG)(attrs.MathMLRepresentation, true)) !== null && _e !== void 0 ? _e : '';
|
|
176
|
-
}
|
|
177
|
-
break;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
return attrs;
|
|
167
|
+
return getEquationContent(element);
|
|
181
168
|
},
|
|
182
169
|
},
|
|
183
170
|
{
|
|
184
171
|
tag: 'disp-formula',
|
|
185
172
|
node: 'equation_element',
|
|
186
173
|
getAttrs: (node) => {
|
|
174
|
+
var _a, _b;
|
|
187
175
|
const element = node;
|
|
188
|
-
const caption = element.querySelector('figcaption');
|
|
189
176
|
return {
|
|
190
177
|
id: element.getAttribute('id'),
|
|
191
|
-
|
|
178
|
+
label: (_b = (_a = element.querySelector('label')) === null || _a === void 0 ? void 0 : _a.textContent) !== null && _b !== void 0 ? _b : '',
|
|
192
179
|
};
|
|
193
180
|
},
|
|
194
181
|
getContent: (node, schema) => {
|
|
195
|
-
var _a, _b, _c, _d, _e;
|
|
196
182
|
const element = node;
|
|
197
|
-
const attrs =
|
|
198
|
-
|
|
199
|
-
SVGStringRepresentation: '',
|
|
200
|
-
TeXRepresentation: '',
|
|
201
|
-
};
|
|
202
|
-
const container = (_a = element.querySelector('alternatives')) !== null && _a !== void 0 ? _a : element;
|
|
203
|
-
for (const child of container.childNodes) {
|
|
204
|
-
const nodeName = child.nodeName.replace(/^[a-z]:/, '');
|
|
205
|
-
switch (nodeName) {
|
|
206
|
-
case 'tex-math':
|
|
207
|
-
attrs.TeXRepresentation = (_c = (_b = child.textContent) === null || _b === void 0 ? void 0 : _b.trim()) !== null && _c !== void 0 ? _c : '';
|
|
208
|
-
if (attrs.TeXRepresentation) {
|
|
209
|
-
attrs.SVGStringRepresentation =
|
|
210
|
-
(_d = (0, tex_to_svg_1.convertTeXToSVG)(attrs.TeXRepresentation, true)) !== null && _d !== void 0 ? _d : '';
|
|
211
|
-
}
|
|
212
|
-
break;
|
|
213
|
-
case 'mml:math':
|
|
214
|
-
;
|
|
215
|
-
child.removeAttribute('id');
|
|
216
|
-
attrs.MathMLStringRepresentation =
|
|
217
|
-
transformer_1.xmlSerializer.serializeToString(child);
|
|
218
|
-
if (attrs.MathMLStringRepresentation) {
|
|
219
|
-
attrs.SVGStringRepresentation =
|
|
220
|
-
(_e = (0, mathml_to_svg_1.convertMathMLToSVG)(attrs.MathMLStringRepresentation, true)) !== null && _e !== void 0 ? _e : '';
|
|
221
|
-
}
|
|
222
|
-
break;
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
const caption = element.querySelector('figcaption');
|
|
226
|
-
const figcaption = schema.nodes.figcaption.create();
|
|
183
|
+
const attrs = getEquationContent(element);
|
|
184
|
+
const id = element.getAttribute('id');
|
|
227
185
|
return prosemirror_model_1.Fragment.from([
|
|
228
|
-
schema.nodes.equation.createChecked(attrs),
|
|
229
|
-
caption
|
|
230
|
-
?
|
|
231
|
-
exports.jatsBodyDOMParser.parse(caption, {
|
|
232
|
-
topNode: figcaption,
|
|
233
|
-
})
|
|
234
|
-
: figcaption,
|
|
186
|
+
schema.nodes.equation.createChecked(Object.assign({ id }, attrs)),
|
|
235
187
|
]);
|
|
236
188
|
},
|
|
237
189
|
},
|
|
@@ -568,7 +520,7 @@ const nodes = [
|
|
|
568
520
|
},
|
|
569
521
|
{
|
|
570
522
|
tag: 'th',
|
|
571
|
-
node: '
|
|
523
|
+
node: 'table_cell',
|
|
572
524
|
getAttrs: (node) => {
|
|
573
525
|
const element = node;
|
|
574
526
|
const colspan = element.getAttribute('colspan');
|
|
@@ -164,6 +164,7 @@ class JATSExporter {
|
|
|
164
164
|
};
|
|
165
165
|
this.nodeFromJATS = (JATSFragment) => {
|
|
166
166
|
JATSFragment = JATSFragment.trim();
|
|
167
|
+
JATSFragment = JATSFragment.replace(' ', ' ');
|
|
167
168
|
if (!JATSFragment.length) {
|
|
168
169
|
return null;
|
|
169
170
|
}
|
|
@@ -614,11 +615,6 @@ class JATSExporter {
|
|
|
614
615
|
this.createSerializer = () => {
|
|
615
616
|
const getModel = (id) => id ? this.modelMap.get(id) : undefined;
|
|
616
617
|
const nodes = {
|
|
617
|
-
table_header: (node) => [
|
|
618
|
-
node.attrs.celltype,
|
|
619
|
-
Object.assign(Object.assign({ valign: node.attrs.valign, align: node.attrs.align, scope: node.attrs.scope, style: node.attrs.style }, (node.attrs.rowspan > 1 && { rowspan: node.attrs.rowspan })), (node.attrs.colspan > 1 && { colspan: node.attrs.colspan })),
|
|
620
|
-
0,
|
|
621
|
-
],
|
|
622
618
|
title: () => '',
|
|
623
619
|
affiliations: () => '',
|
|
624
620
|
contributors: () => '',
|
|
@@ -691,22 +687,23 @@ class JATSExporter {
|
|
|
691
687
|
},
|
|
692
688
|
doc: () => '',
|
|
693
689
|
equation: (node) => {
|
|
694
|
-
const
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
690
|
+
const math = this.nodeFromJATS(node.attrs.contents);
|
|
691
|
+
const mathEl = math;
|
|
692
|
+
mathEl.setAttribute('id', normalizeID(node.attrs.id));
|
|
693
|
+
return mathEl;
|
|
694
|
+
},
|
|
695
|
+
inline_equation: (node) => {
|
|
696
|
+
const eqElement = this.document.createElement('inline-formula');
|
|
697
|
+
const math = this.nodeFromJATS(node.attrs.contents);
|
|
698
|
+
eqElement.append(math);
|
|
699
|
+
return eqElement;
|
|
700
|
+
},
|
|
701
|
+
equation_element: (node) => {
|
|
702
|
+
const eqElement = this.document.createElement('disp-formula');
|
|
703
|
+
eqElement.setAttribute('id', normalizeID(node.attrs.id));
|
|
704
|
+
processChildNodes(eqElement, node, schema_1.schema.nodes.equation);
|
|
705
|
+
return eqElement;
|
|
708
706
|
},
|
|
709
|
-
equation_element: (node) => createFigureElement(node, 'fig', node.type.schema.nodes.equation, 'equation'),
|
|
710
707
|
figcaption: (node) => {
|
|
711
708
|
if (!node.textContent) {
|
|
712
709
|
return '';
|
|
@@ -756,28 +753,6 @@ class JATSExporter {
|
|
|
756
753
|
},
|
|
757
754
|
hard_break: () => '',
|
|
758
755
|
highlight_marker: () => '',
|
|
759
|
-
inline_equation: (node) => {
|
|
760
|
-
const formula = this.document.createElement('inline-formula');
|
|
761
|
-
formula.setAttribute('id', normalizeID(node.attrs.id));
|
|
762
|
-
if (node.attrs.TeXRepresentation) {
|
|
763
|
-
const math = this.document.createElement('tex-math');
|
|
764
|
-
math.textContent = node.attrs.TeXRepresentation;
|
|
765
|
-
formula.appendChild(math);
|
|
766
|
-
}
|
|
767
|
-
else if (node.attrs.MathMLRepresentation) {
|
|
768
|
-
const math = this.nodeFromJATS(node.attrs.MathMLRepresentation);
|
|
769
|
-
if (math) {
|
|
770
|
-
formula.appendChild(math);
|
|
771
|
-
}
|
|
772
|
-
}
|
|
773
|
-
else if (node.attrs.SVGRepresentation) {
|
|
774
|
-
const math = this.nodeFromJATS(node.attrs.SVGRepresentation);
|
|
775
|
-
if (math) {
|
|
776
|
-
formula.appendChild(math);
|
|
777
|
-
}
|
|
778
|
-
}
|
|
779
|
-
return formula;
|
|
780
|
-
},
|
|
781
756
|
inline_footnote: (node) => {
|
|
782
757
|
const xref = this.document.createElement('xref');
|
|
783
758
|
xref.setAttribute('ref-type', 'fn');
|
|
@@ -878,6 +853,7 @@ class JATSExporter {
|
|
|
878
853
|
element.setAttribute('position', 'anchor');
|
|
879
854
|
return element;
|
|
880
855
|
},
|
|
856
|
+
table_body: () => ['tbody', 0],
|
|
881
857
|
table_cell: (node) => [
|
|
882
858
|
node.attrs.celltype,
|
|
883
859
|
Object.assign(Object.assign({ valign: node.attrs.valign, align: node.attrs.align, scope: node.attrs.scope, style: node.attrs.style }, (node.attrs.rowspan > 1 && { rowspan: node.attrs.rowspan })), (node.attrs.colspan > 1 && { colspan: node.attrs.colspan })),
|
package/dist/cjs/schema/index.js
CHANGED
|
@@ -117,7 +117,6 @@ __exportStar(require("./nodes/footnotes_section"), exports);
|
|
|
117
117
|
__exportStar(require("./nodes/graphical_abstract_section"), exports);
|
|
118
118
|
__exportStar(require("./nodes/hard_break"), exports);
|
|
119
119
|
__exportStar(require("./nodes/highlight_marker"), exports);
|
|
120
|
-
__exportStar(require("./nodes/inline_equation"), exports);
|
|
121
120
|
__exportStar(require("./nodes/inline_footnote"), exports);
|
|
122
121
|
__exportStar(require("./nodes/keyword"), exports);
|
|
123
122
|
__exportStar(require("./nodes/keywords_element"), exports);
|
|
@@ -213,6 +212,7 @@ exports.schema = new prosemirror_model_1.Schema({
|
|
|
213
212
|
section_title: section_title_1.sectionTitle,
|
|
214
213
|
section_title_plain: section_title_1.sectionTitle,
|
|
215
214
|
table: table_1.table,
|
|
215
|
+
table_body: table_1.tableBody,
|
|
216
216
|
table_cell: table_row_1.tableCell,
|
|
217
217
|
table_element: table_element_1.tableElement,
|
|
218
218
|
table_row: table_row_1.tableRow,
|
|
@@ -229,6 +229,5 @@ exports.schema = new prosemirror_model_1.Schema({
|
|
|
229
229
|
contributors: contributors_1.contributors,
|
|
230
230
|
supplements: supplements_1.supplements,
|
|
231
231
|
supplement: supplement_1.supplement,
|
|
232
|
-
table_header: table_row_1.tableHeader,
|
|
233
232
|
},
|
|
234
233
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*!
|
|
3
|
-
* ©
|
|
3
|
+
* © 2023 Atypon Systems LLC
|
|
4
4
|
*
|
|
5
5
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
6
|
* you may not use this file except in compliance with the License.
|
|
@@ -20,9 +20,8 @@ const json_schema_1 = require("@manuscripts/json-schema");
|
|
|
20
20
|
exports.equation = {
|
|
21
21
|
attrs: {
|
|
22
22
|
id: { default: '' },
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
TeXRepresentation: { default: '' },
|
|
23
|
+
contents: { default: '' },
|
|
24
|
+
format: { default: '' },
|
|
26
25
|
dataTracked: { default: null },
|
|
27
26
|
},
|
|
28
27
|
group: 'block',
|
|
@@ -30,26 +29,25 @@ exports.equation = {
|
|
|
30
29
|
{
|
|
31
30
|
tag: `div.${json_schema_1.ObjectTypes.Equation}`,
|
|
32
31
|
getAttrs: (p) => {
|
|
33
|
-
const
|
|
32
|
+
const htmlEl = p;
|
|
34
33
|
return {
|
|
35
|
-
id:
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
TeXRepresentation: dom.getAttribute('data-tex-representation'),
|
|
34
|
+
id: htmlEl.getAttribute('id'),
|
|
35
|
+
format: htmlEl.getAttribute('data-equation-format'),
|
|
36
|
+
contents: htmlEl.innerHTML,
|
|
39
37
|
};
|
|
40
38
|
},
|
|
41
39
|
},
|
|
42
40
|
],
|
|
43
41
|
toDOM: (node) => {
|
|
44
42
|
const equationNode = node;
|
|
43
|
+
const { id, contents, format } = equationNode.attrs;
|
|
45
44
|
const dom = document.createElement('div');
|
|
46
|
-
dom.setAttribute('id', equationNode.attrs.id);
|
|
47
45
|
dom.classList.add(json_schema_1.ObjectTypes.Equation);
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
dom.setAttribute('id', id);
|
|
47
|
+
if (format) {
|
|
48
|
+
dom.setAttribute('data-equation-format', format);
|
|
50
49
|
}
|
|
51
|
-
dom.
|
|
52
|
-
dom.innerHTML = equationNode.attrs.SVGStringRepresentation;
|
|
50
|
+
dom.innerHTML = contents;
|
|
53
51
|
return dom;
|
|
54
52
|
},
|
|
55
53
|
};
|
|
@@ -17,11 +17,10 @@
|
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.equationElement = void 0;
|
|
19
19
|
exports.equationElement = {
|
|
20
|
-
content: '(equation | placeholder)
|
|
20
|
+
content: '(equation | placeholder)',
|
|
21
21
|
attrs: {
|
|
22
22
|
id: { default: '' },
|
|
23
|
-
|
|
24
|
-
suppressTitle: { default: undefined },
|
|
23
|
+
label: { default: '' },
|
|
25
24
|
dataTracked: { default: null },
|
|
26
25
|
comments: { default: null },
|
|
27
26
|
},
|
|
@@ -29,7 +28,7 @@ exports.equationElement = {
|
|
|
29
28
|
group: 'block element',
|
|
30
29
|
parseDOM: [
|
|
31
30
|
{
|
|
32
|
-
tag: '
|
|
31
|
+
tag: 'div.equation',
|
|
33
32
|
getAttrs: (p) => {
|
|
34
33
|
const dom = p;
|
|
35
34
|
return {
|
|
@@ -41,7 +40,7 @@ exports.equationElement = {
|
|
|
41
40
|
toDOM: (node) => {
|
|
42
41
|
const equationElementNode = node;
|
|
43
42
|
return [
|
|
44
|
-
'
|
|
43
|
+
'div',
|
|
45
44
|
{
|
|
46
45
|
class: 'equation',
|
|
47
46
|
id: equationElementNode.attrs.id,
|
|
@@ -16,43 +16,39 @@
|
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.inlineEquation = void 0;
|
|
19
|
-
const json_schema_1 = require("@manuscripts/json-schema");
|
|
20
19
|
exports.inlineEquation = {
|
|
21
20
|
attrs: {
|
|
22
|
-
id: { default: '' },
|
|
23
|
-
MathMLRepresentation: { default: '' },
|
|
24
|
-
SVGRepresentation: { default: '' },
|
|
25
|
-
TeXRepresentation: { default: '' },
|
|
26
21
|
dataTracked: { default: null },
|
|
22
|
+
comments: { default: null },
|
|
23
|
+
contents: { default: '' },
|
|
24
|
+
format: { default: '' },
|
|
27
25
|
},
|
|
26
|
+
selectable: false,
|
|
28
27
|
atom: true,
|
|
29
28
|
inline: true,
|
|
30
29
|
draggable: true,
|
|
31
30
|
group: 'inline',
|
|
32
31
|
parseDOM: [
|
|
33
32
|
{
|
|
34
|
-
tag: `span
|
|
33
|
+
tag: `span.MPInlineMathFragment`,
|
|
35
34
|
getAttrs: (p) => {
|
|
36
35
|
const dom = p;
|
|
37
36
|
return {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
SVGRepresentation: dom.innerHTML || '',
|
|
41
|
-
TeXRepresentation: dom.getAttribute('data-tex-representation') || '',
|
|
37
|
+
format: dom.getAttribute('data-equation-format'),
|
|
38
|
+
contents: dom.innerHTML,
|
|
42
39
|
};
|
|
43
40
|
},
|
|
44
41
|
},
|
|
45
42
|
],
|
|
46
43
|
toDOM: (node) => {
|
|
47
44
|
const inlineEquationNode = node;
|
|
45
|
+
const { contents, format } = inlineEquationNode.attrs;
|
|
48
46
|
const dom = document.createElement('span');
|
|
49
|
-
dom.classList.add(
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
if (inlineEquationNode.attrs.MathMLRepresentation) {
|
|
53
|
-
dom.setAttribute('data-mathml-representation', inlineEquationNode.attrs.MathMLRepresentation);
|
|
47
|
+
dom.classList.add('MPInlineMathFragment');
|
|
48
|
+
if (format) {
|
|
49
|
+
dom.setAttribute('data-equation-format', format);
|
|
54
50
|
}
|
|
55
|
-
dom.innerHTML =
|
|
51
|
+
dom.innerHTML = contents;
|
|
56
52
|
return dom;
|
|
57
53
|
},
|
|
58
54
|
};
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.table = void 0;
|
|
18
|
+
exports.tableBody = exports.table = void 0;
|
|
19
19
|
exports.table = {
|
|
20
|
-
content: '
|
|
20
|
+
content: 'table_colgroup? table_body',
|
|
21
21
|
tableRole: 'table',
|
|
22
22
|
isolating: true,
|
|
23
23
|
group: 'block',
|
|
@@ -55,3 +55,16 @@ exports.table = {
|
|
|
55
55
|
];
|
|
56
56
|
},
|
|
57
57
|
};
|
|
58
|
+
exports.tableBody = {
|
|
59
|
+
content: 'table_row+',
|
|
60
|
+
group: 'block',
|
|
61
|
+
tableRole: 'table',
|
|
62
|
+
parseDOM: [
|
|
63
|
+
{
|
|
64
|
+
tag: 'tbody',
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
toDOM() {
|
|
68
|
+
return ['tbody', 0];
|
|
69
|
+
},
|
|
70
|
+
};
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.
|
|
18
|
+
exports.tableCell = exports.tableRow = void 0;
|
|
19
19
|
const table_cell_styles_1 = require("../../lib/table-cell-styles");
|
|
20
20
|
const getCellAttrs = (p) => {
|
|
21
21
|
const dom = p;
|
|
@@ -43,7 +43,7 @@ const getCellAttrs = (p) => {
|
|
|
43
43
|
};
|
|
44
44
|
};
|
|
45
45
|
exports.tableRow = {
|
|
46
|
-
content: '
|
|
46
|
+
content: 'table_cell+',
|
|
47
47
|
tableRole: 'row',
|
|
48
48
|
attrs: {
|
|
49
49
|
placeholder: { default: '' },
|
|
@@ -79,7 +79,10 @@ exports.tableCell = {
|
|
|
79
79
|
},
|
|
80
80
|
tableRole: 'cell',
|
|
81
81
|
isolating: true,
|
|
82
|
-
parseDOM: [
|
|
82
|
+
parseDOM: [
|
|
83
|
+
{ tag: 'td', getAttrs: getCellAttrs },
|
|
84
|
+
{ tag: 'th', getAttrs: getCellAttrs },
|
|
85
|
+
],
|
|
83
86
|
toDOM: (node) => {
|
|
84
87
|
const tableCellNode = node;
|
|
85
88
|
const attrs = {};
|
|
@@ -118,7 +121,3 @@ exports.tableCell = {
|
|
|
118
121
|
return [tag, attrs, 0];
|
|
119
122
|
},
|
|
120
123
|
};
|
|
121
|
-
exports.tableHeader = exports.tableCell && {
|
|
122
|
-
tableRole: 'header_cell',
|
|
123
|
-
parseDOM: [{ tag: 'th', getAttrs: getCellAttrs }],
|
|
124
|
-
};
|
|
@@ -18,7 +18,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
18
18
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
19
|
};
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.buildTitles = exports.buildElementsOrder = exports.auxiliaryObjectTypes = exports.buildJournal = exports.buildAttribution = exports.buildContributorRole = exports.buildContribution = exports.buildColor = exports.buildParagraph = exports.buildSection = exports.buildCorresp = exports.buildFootnotesOrder = exports.buildFootnote = exports.
|
|
21
|
+
exports.buildTitles = exports.buildElementsOrder = exports.auxiliaryObjectTypes = exports.buildJournal = exports.buildAttribution = exports.buildContributorRole = exports.buildContribution = exports.buildColor = exports.buildParagraph = exports.buildSection = exports.buildCorresp = exports.buildFootnotesOrder = exports.buildFootnote = exports.buildNote = exports.buildComment = exports.buildSupplementaryMaterial = exports.buildAffiliation = exports.buildFigure = exports.buildKeywordGroup = exports.buildKeyword = exports.buildBibliographyElement = exports.buildBibliographicDate = exports.buildBibliographicName = exports.buildBibliographyItem = exports.buildContributor = exports.buildManuscript = exports.buildProject = void 0;
|
|
22
22
|
const json_schema_1 = require("@manuscripts/json-schema");
|
|
23
23
|
const w3c_xmlserializer_1 = __importDefault(require("w3c-xmlserializer"));
|
|
24
24
|
const schema_1 = require("../schema");
|
|
@@ -115,13 +115,6 @@ const buildNote = (target, source, contents = '') => ({
|
|
|
115
115
|
contents,
|
|
116
116
|
});
|
|
117
117
|
exports.buildNote = buildNote;
|
|
118
|
-
const buildInlineMathFragment = (containingObject, TeXRepresentation) => ({
|
|
119
|
-
_id: (0, id_1.generateID)(json_schema_1.ObjectTypes.InlineMathFragment),
|
|
120
|
-
objectType: json_schema_1.ObjectTypes.InlineMathFragment,
|
|
121
|
-
containingObject: containingObject || undefined,
|
|
122
|
-
TeXRepresentation,
|
|
123
|
-
});
|
|
124
|
-
exports.buildInlineMathFragment = buildInlineMathFragment;
|
|
125
118
|
const buildFootnote = (containingObject, contents, kind = 'footnote') => ({
|
|
126
119
|
_id: (0, id_1.generateID)(json_schema_1.ObjectTypes.Footnote),
|
|
127
120
|
objectType: json_schema_1.ObjectTypes.Footnote,
|
|
@@ -281,9 +281,8 @@ class Decoder {
|
|
|
281
281
|
const model = data;
|
|
282
282
|
return schema_1.schema.nodes.equation.createChecked({
|
|
283
283
|
id: model._id,
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
TeXRepresentation: model.TeXRepresentation,
|
|
284
|
+
contents: model.contents,
|
|
285
|
+
format: model.format,
|
|
287
286
|
});
|
|
288
287
|
},
|
|
289
288
|
[json_schema_1.ObjectTypes.EquationElement]: (data) => {
|
|
@@ -302,12 +301,10 @@ class Decoder {
|
|
|
302
301
|
else {
|
|
303
302
|
throw new errors_1.MissingElement(model.containedObjectID);
|
|
304
303
|
}
|
|
305
|
-
const figcaption = this.getFigcaption(model);
|
|
306
304
|
return schema_1.schema.nodes.equation_element.createChecked({
|
|
307
305
|
id: model._id,
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
}, [equation, figcaption]);
|
|
306
|
+
label: model.label,
|
|
307
|
+
}, [equation]);
|
|
311
308
|
},
|
|
312
309
|
[json_schema_1.ObjectTypes.FootnotesElement]: (data) => {
|
|
313
310
|
const foonotesElementModel = data;
|
|
@@ -62,12 +62,6 @@ const listContents = (node) => {
|
|
|
62
62
|
}
|
|
63
63
|
return (0, w3c_xmlserializer_1.default)(output);
|
|
64
64
|
};
|
|
65
|
-
const svgDefs = (svg) => {
|
|
66
|
-
const template = document.createElement('template');
|
|
67
|
-
template.innerHTML = svg.trim();
|
|
68
|
-
const defs = template.content.querySelector('defs');
|
|
69
|
-
return defs ? (0, w3c_xmlserializer_1.default)(defs) : undefined;
|
|
70
|
-
};
|
|
71
65
|
const tableRowDisplayStyle = (tagName, parent) => {
|
|
72
66
|
switch (tagName) {
|
|
73
67
|
case 'thead':
|
|
@@ -99,9 +93,27 @@ const buildTableSection = (tagName, inputRows, parent) => {
|
|
|
99
93
|
}
|
|
100
94
|
return section;
|
|
101
95
|
};
|
|
96
|
+
function buildTableColGroup(cols) {
|
|
97
|
+
if (cols.length === 0) {
|
|
98
|
+
return undefined;
|
|
99
|
+
}
|
|
100
|
+
const colgroup = document.createElement('colgroup');
|
|
101
|
+
for (const inputCol of cols) {
|
|
102
|
+
const col = document.createElement('col');
|
|
103
|
+
for (const attribute of inputCol.attributes) {
|
|
104
|
+
col.setAttribute(attribute.name, attribute.value);
|
|
105
|
+
}
|
|
106
|
+
colgroup.appendChild(inputCol);
|
|
107
|
+
}
|
|
108
|
+
return colgroup;
|
|
109
|
+
}
|
|
102
110
|
const tableContents = (node, parent) => {
|
|
103
111
|
const input = serializer.serializeNode(node);
|
|
104
112
|
const output = document.createElement('table');
|
|
113
|
+
const colgroup = buildTableColGroup(Array.from(input.querySelectorAll('col')));
|
|
114
|
+
if (colgroup) {
|
|
115
|
+
output.appendChild(colgroup);
|
|
116
|
+
}
|
|
105
117
|
output.setAttribute('id', parent.attrs.id);
|
|
106
118
|
output.classList.add('MPElement');
|
|
107
119
|
if (parent.attrs.tableStyle) {
|
|
@@ -335,20 +347,13 @@ const encoders = {
|
|
|
335
347
|
: false,
|
|
336
348
|
}),
|
|
337
349
|
equation: (node) => ({
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
SVGStringRepresentation: node.attrs.SVGStringRepresentation,
|
|
350
|
+
contents: node.attrs.contents,
|
|
351
|
+
format: node.attrs.format,
|
|
341
352
|
}),
|
|
342
353
|
equation_element: (node) => ({
|
|
343
354
|
containedObjectID: attributeOfNodeType(node, 'equation', 'id'),
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
elementType: 'p',
|
|
347
|
-
suppressCaption: Boolean(node.attrs.suppressCaption) || undefined,
|
|
348
|
-
suppressTitle: node.attrs.suppressTitle === undefined ||
|
|
349
|
-
node.attrs.suppressTitle === true
|
|
350
|
-
? undefined
|
|
351
|
-
: false,
|
|
355
|
+
elementType: 'div',
|
|
356
|
+
label: node.attrs.label,
|
|
352
357
|
}),
|
|
353
358
|
figure: (node) => ({
|
|
354
359
|
contentType: node.attrs.contentType || undefined,
|
|
@@ -395,12 +400,6 @@ const encoders = {
|
|
|
395
400
|
.map((childNode) => childNode.attrs.id)
|
|
396
401
|
.filter((id) => id),
|
|
397
402
|
}),
|
|
398
|
-
inline_equation: (node, parent) => ({
|
|
399
|
-
containingObject: parent.attrs.id,
|
|
400
|
-
TeXRepresentation: node.attrs.TeXRepresentation,
|
|
401
|
-
SVGRepresentation: node.attrs.SVGRepresentation,
|
|
402
|
-
SVGGlyphs: svgDefs(node.attrs.SVGRepresentation),
|
|
403
|
-
}),
|
|
404
403
|
keyword: (node, parent) => ({
|
|
405
404
|
containedGroup: parent.attrs.id,
|
|
406
405
|
name: keywordContents(node),
|
|
@@ -574,8 +573,7 @@ const encode = (node) => {
|
|
|
574
573
|
if (placeholderTypes.includes(child.type)) {
|
|
575
574
|
return;
|
|
576
575
|
}
|
|
577
|
-
if (parent.type === schema_1.schema.nodes.paragraph
|
|
578
|
-
child.type !== schema_1.schema.nodes.inline_equation) {
|
|
576
|
+
if (parent.type === schema_1.schema.nodes.paragraph) {
|
|
579
577
|
return;
|
|
580
578
|
}
|
|
581
579
|
const { model, markers } = (0, exports.modelFromNode)(child, parent, path, priority);
|
|
@@ -39,7 +39,6 @@ exports.nodeTypesMap = new Map([
|
|
|
39
39
|
[schema_1.schema.nodes.footnotes_section, json_schema_1.ObjectTypes.Section],
|
|
40
40
|
[schema_1.schema.nodes.graphical_abstract_section, json_schema_1.ObjectTypes.Section],
|
|
41
41
|
[schema_1.schema.nodes.highlight_marker, json_schema_1.ObjectTypes.HighlightMarker],
|
|
42
|
-
[schema_1.schema.nodes.inline_equation, json_schema_1.ObjectTypes.InlineMathFragment],
|
|
43
42
|
[schema_1.schema.nodes.keyword, json_schema_1.ObjectTypes.Keyword],
|
|
44
43
|
[schema_1.schema.nodes.keywords_element, json_schema_1.ObjectTypes.KeywordsElement],
|
|
45
44
|
[schema_1.schema.nodes.keywords, json_schema_1.ObjectTypes.Section],
|
|
@@ -38,7 +38,6 @@ exports.manuscriptObjects = [
|
|
|
38
38
|
json_schema_1.ObjectTypes.CommentAnnotation,
|
|
39
39
|
json_schema_1.ObjectTypes.Contributor,
|
|
40
40
|
json_schema_1.ObjectTypes.Footnote,
|
|
41
|
-
json_schema_1.ObjectTypes.InlineMathFragment,
|
|
42
41
|
json_schema_1.ObjectTypes.Section,
|
|
43
42
|
].concat(exports.elementObjects);
|
|
44
43
|
const isManuscriptModel = (model) => {
|