@manuscripts/transform 2.1.1-LEAN-3092-9 → 2.1.1-LEAN-3336-21
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 +1 -0
- package/dist/cjs/jats/importer/jats-body-dom-parser.js +74 -33
- package/dist/cjs/jats/importer/jats-body-transformations.js +0 -13
- package/dist/cjs/jats/importer/jats-parser-utils.js +0 -6
- package/dist/cjs/jats/jats-exporter.js +64 -32
- package/dist/cjs/mathjax/index.js +41 -0
- package/dist/cjs/mathjax/mathjax-packages.js +20 -0
- package/dist/cjs/mathjax/mathml-to-svg.js +70 -0
- package/dist/cjs/mathjax/tex-to-mathml.js +49 -0
- package/dist/cjs/mathjax/tex-to-svg.js +59 -0
- package/dist/cjs/schema/index.js +4 -5
- package/dist/cjs/schema/nodes/equation.js +14 -12
- package/dist/cjs/schema/nodes/equation_element.js +5 -4
- package/dist/cjs/schema/nodes/inline_equation.js +15 -13
- package/dist/cjs/schema/nodes/table.js +73 -30
- package/dist/cjs/schema/nodes/table_element.js +1 -1
- package/dist/cjs/transformer/builders.js +8 -1
- package/dist/cjs/transformer/decode.js +26 -7
- package/dist/cjs/transformer/encode.js +27 -6
- package/dist/cjs/transformer/node-types.js +1 -0
- package/dist/cjs/transformer/object-types.js +1 -0
- package/dist/es/index.js +1 -0
- package/dist/es/jats/importer/jats-body-dom-parser.js +75 -34
- package/dist/es/jats/importer/jats-body-transformations.js +0 -13
- package/dist/es/jats/importer/jats-parser-utils.js +0 -6
- package/dist/es/jats/jats-exporter.js +64 -32
- package/dist/es/mathjax/index.js +12 -0
- package/dist/es/mathjax/mathjax-packages.js +17 -0
- package/dist/es/mathjax/mathml-to-svg.js +66 -0
- package/dist/es/mathjax/tex-to-mathml.js +45 -0
- package/dist/es/mathjax/tex-to-svg.js +55 -0
- package/dist/es/schema/index.js +3 -4
- package/dist/es/schema/nodes/equation.js +14 -12
- package/dist/es/schema/nodes/equation_element.js +5 -4
- package/dist/es/schema/nodes/inline_equation.js +15 -13
- package/dist/es/schema/nodes/table.js +72 -29
- package/dist/es/schema/nodes/table_element.js +1 -1
- package/dist/es/transformer/builders.js +6 -0
- package/dist/es/transformer/decode.js +26 -7
- package/dist/es/transformer/encode.js +27 -6
- package/dist/es/transformer/node-types.js +1 -0
- package/dist/es/transformer/object-types.js +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/jats/jats-exporter.d.ts +0 -1
- package/dist/types/mathjax/index.d.ts +3 -0
- package/dist/types/mathjax/mathjax-packages.d.ts +16 -0
- package/dist/types/mathjax/mathml-to-svg.d.ts +17 -0
- package/dist/types/mathjax/tex-to-mathml.d.ts +17 -0
- package/dist/types/mathjax/tex-to-svg.d.ts +17 -0
- package/dist/types/schema/index.d.ts +1 -1
- package/dist/types/schema/nodes/equation.d.ts +4 -3
- package/dist/types/schema/nodes/equation_element.d.ts +2 -1
- package/dist/types/schema/nodes/inline_equation.d.ts +3 -4
- package/dist/types/schema/nodes/table.d.ts +72 -10
- package/dist/types/schema/types.d.ts +1 -1
- package/dist/types/transformer/builders.d.ts +2 -1
- package/dist/types/transformer/decode.d.ts +1 -0
- package/package.json +7 -5
- package/dist/cjs/schema/nodes/table_row.js +0 -123
- package/dist/es/schema/nodes/table_row.js +0 -120
- package/dist/types/schema/nodes/table_row.d.ts +0 -41
|
@@ -1,123 +0,0 @@
|
|
|
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.tableCell = exports.tableRow = void 0;
|
|
19
|
-
const table_cell_styles_1 = require("../../lib/table-cell-styles");
|
|
20
|
-
const getCellAttrs = (p) => {
|
|
21
|
-
const dom = p;
|
|
22
|
-
const celltype = dom.tagName.toLowerCase();
|
|
23
|
-
const widthAttr = dom.getAttribute('data-colwidth');
|
|
24
|
-
const widths = widthAttr && /^\d+(,\d+)*$/.test(widthAttr)
|
|
25
|
-
? widthAttr.split(',').map((s) => Number(s))
|
|
26
|
-
: null;
|
|
27
|
-
const colspan = Number(dom.getAttribute('colspan') || 1);
|
|
28
|
-
const valign = dom.getAttribute('valign');
|
|
29
|
-
const align = dom.getAttribute('align');
|
|
30
|
-
const scope = dom.getAttribute('scope');
|
|
31
|
-
const style = dom.getAttribute('style');
|
|
32
|
-
return {
|
|
33
|
-
celltype,
|
|
34
|
-
colspan,
|
|
35
|
-
rowspan: Number(dom.getAttribute('rowspan') || 1),
|
|
36
|
-
colwidth: widths && widths.length === colspan ? widths : null,
|
|
37
|
-
placeholder: dom.getAttribute('data-placeholder-text') || '',
|
|
38
|
-
styles: (0, table_cell_styles_1.getTableCellStyles)(dom.style),
|
|
39
|
-
valign,
|
|
40
|
-
align,
|
|
41
|
-
scope,
|
|
42
|
-
style,
|
|
43
|
-
};
|
|
44
|
-
};
|
|
45
|
-
exports.tableRow = {
|
|
46
|
-
content: 'table_cell+',
|
|
47
|
-
tableRole: 'row',
|
|
48
|
-
attrs: {
|
|
49
|
-
placeholder: { default: '' },
|
|
50
|
-
},
|
|
51
|
-
parseDOM: [
|
|
52
|
-
{
|
|
53
|
-
tag: 'tr',
|
|
54
|
-
priority: 80,
|
|
55
|
-
},
|
|
56
|
-
],
|
|
57
|
-
toDOM: (node) => {
|
|
58
|
-
const tableRowNode = node;
|
|
59
|
-
const attrs = {};
|
|
60
|
-
if (tableRowNode.attrs.placeholder) {
|
|
61
|
-
attrs['data-placeholder-text'] = tableRowNode.attrs.placeholder;
|
|
62
|
-
}
|
|
63
|
-
return ['tr', attrs, 0];
|
|
64
|
-
},
|
|
65
|
-
};
|
|
66
|
-
exports.tableCell = {
|
|
67
|
-
content: 'inline*',
|
|
68
|
-
attrs: {
|
|
69
|
-
celltype: { default: 'td' },
|
|
70
|
-
colspan: { default: 1 },
|
|
71
|
-
rowspan: { default: 1 },
|
|
72
|
-
colwidth: { default: null },
|
|
73
|
-
placeholder: { default: 'Data' },
|
|
74
|
-
styles: { default: {} },
|
|
75
|
-
valign: { default: null },
|
|
76
|
-
align: { default: null },
|
|
77
|
-
scope: { default: null },
|
|
78
|
-
style: { default: null },
|
|
79
|
-
},
|
|
80
|
-
tableRole: 'cell',
|
|
81
|
-
isolating: true,
|
|
82
|
-
parseDOM: [
|
|
83
|
-
{ tag: 'td', getAttrs: getCellAttrs },
|
|
84
|
-
{ tag: 'th', getAttrs: getCellAttrs },
|
|
85
|
-
],
|
|
86
|
-
toDOM: (node) => {
|
|
87
|
-
const tableCellNode = node;
|
|
88
|
-
const attrs = {};
|
|
89
|
-
const tag = tableCellNode.attrs.celltype;
|
|
90
|
-
if (tableCellNode.attrs.colspan && tableCellNode.attrs.colspan !== 1) {
|
|
91
|
-
attrs.colspan = String(tableCellNode.attrs.colspan);
|
|
92
|
-
}
|
|
93
|
-
if (tableCellNode.attrs.rowspan && tableCellNode.attrs.rowspan !== 1) {
|
|
94
|
-
attrs.rowspan = String(tableCellNode.attrs.rowspan);
|
|
95
|
-
}
|
|
96
|
-
if (tableCellNode.attrs.colwidth) {
|
|
97
|
-
attrs['data-colwidth'] = tableCellNode.attrs.colwidth.join(',');
|
|
98
|
-
}
|
|
99
|
-
if (tableCellNode.attrs.placeholder) {
|
|
100
|
-
attrs['data-placeholder-text'] = tableCellNode.attrs.placeholder;
|
|
101
|
-
}
|
|
102
|
-
if (!tableCellNode.textContent) {
|
|
103
|
-
attrs.class = 'placeholder';
|
|
104
|
-
}
|
|
105
|
-
const styleString = (0, table_cell_styles_1.serializeTableCellStyles)(tableCellNode.attrs.styles);
|
|
106
|
-
if (styleString) {
|
|
107
|
-
attrs.style = styleString;
|
|
108
|
-
}
|
|
109
|
-
if (tableCellNode.attrs.valign) {
|
|
110
|
-
attrs.valign = tableCellNode.attrs.valign;
|
|
111
|
-
}
|
|
112
|
-
if (tableCellNode.attrs.align) {
|
|
113
|
-
attrs.align = tableCellNode.attrs.align;
|
|
114
|
-
}
|
|
115
|
-
if (tableCellNode.attrs.scope) {
|
|
116
|
-
attrs.scope = tableCellNode.attrs.scope;
|
|
117
|
-
}
|
|
118
|
-
if (tableCellNode.attrs.style) {
|
|
119
|
-
attrs.style = tableCellNode.attrs.style;
|
|
120
|
-
}
|
|
121
|
-
return [tag, attrs, 0];
|
|
122
|
-
},
|
|
123
|
-
};
|
|
@@ -1,120 +0,0 @@
|
|
|
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 { getTableCellStyles, serializeTableCellStyles, } from '../../lib/table-cell-styles';
|
|
17
|
-
const getCellAttrs = (p) => {
|
|
18
|
-
const dom = p;
|
|
19
|
-
const celltype = dom.tagName.toLowerCase();
|
|
20
|
-
const widthAttr = dom.getAttribute('data-colwidth');
|
|
21
|
-
const widths = widthAttr && /^\d+(,\d+)*$/.test(widthAttr)
|
|
22
|
-
? widthAttr.split(',').map((s) => Number(s))
|
|
23
|
-
: null;
|
|
24
|
-
const colspan = Number(dom.getAttribute('colspan') || 1);
|
|
25
|
-
const valign = dom.getAttribute('valign');
|
|
26
|
-
const align = dom.getAttribute('align');
|
|
27
|
-
const scope = dom.getAttribute('scope');
|
|
28
|
-
const style = dom.getAttribute('style');
|
|
29
|
-
return {
|
|
30
|
-
celltype,
|
|
31
|
-
colspan,
|
|
32
|
-
rowspan: Number(dom.getAttribute('rowspan') || 1),
|
|
33
|
-
colwidth: widths && widths.length === colspan ? widths : null,
|
|
34
|
-
placeholder: dom.getAttribute('data-placeholder-text') || '',
|
|
35
|
-
styles: getTableCellStyles(dom.style),
|
|
36
|
-
valign,
|
|
37
|
-
align,
|
|
38
|
-
scope,
|
|
39
|
-
style,
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
|
-
export const tableRow = {
|
|
43
|
-
content: 'table_cell+',
|
|
44
|
-
tableRole: 'row',
|
|
45
|
-
attrs: {
|
|
46
|
-
placeholder: { default: '' },
|
|
47
|
-
},
|
|
48
|
-
parseDOM: [
|
|
49
|
-
{
|
|
50
|
-
tag: 'tr',
|
|
51
|
-
priority: 80,
|
|
52
|
-
},
|
|
53
|
-
],
|
|
54
|
-
toDOM: (node) => {
|
|
55
|
-
const tableRowNode = node;
|
|
56
|
-
const attrs = {};
|
|
57
|
-
if (tableRowNode.attrs.placeholder) {
|
|
58
|
-
attrs['data-placeholder-text'] = tableRowNode.attrs.placeholder;
|
|
59
|
-
}
|
|
60
|
-
return ['tr', attrs, 0];
|
|
61
|
-
},
|
|
62
|
-
};
|
|
63
|
-
export const tableCell = {
|
|
64
|
-
content: 'inline*',
|
|
65
|
-
attrs: {
|
|
66
|
-
celltype: { default: 'td' },
|
|
67
|
-
colspan: { default: 1 },
|
|
68
|
-
rowspan: { default: 1 },
|
|
69
|
-
colwidth: { default: null },
|
|
70
|
-
placeholder: { default: 'Data' },
|
|
71
|
-
styles: { default: {} },
|
|
72
|
-
valign: { default: null },
|
|
73
|
-
align: { default: null },
|
|
74
|
-
scope: { default: null },
|
|
75
|
-
style: { default: null },
|
|
76
|
-
},
|
|
77
|
-
tableRole: 'cell',
|
|
78
|
-
isolating: true,
|
|
79
|
-
parseDOM: [
|
|
80
|
-
{ tag: 'td', getAttrs: getCellAttrs },
|
|
81
|
-
{ tag: 'th', getAttrs: getCellAttrs },
|
|
82
|
-
],
|
|
83
|
-
toDOM: (node) => {
|
|
84
|
-
const tableCellNode = node;
|
|
85
|
-
const attrs = {};
|
|
86
|
-
const tag = tableCellNode.attrs.celltype;
|
|
87
|
-
if (tableCellNode.attrs.colspan && tableCellNode.attrs.colspan !== 1) {
|
|
88
|
-
attrs.colspan = String(tableCellNode.attrs.colspan);
|
|
89
|
-
}
|
|
90
|
-
if (tableCellNode.attrs.rowspan && tableCellNode.attrs.rowspan !== 1) {
|
|
91
|
-
attrs.rowspan = String(tableCellNode.attrs.rowspan);
|
|
92
|
-
}
|
|
93
|
-
if (tableCellNode.attrs.colwidth) {
|
|
94
|
-
attrs['data-colwidth'] = tableCellNode.attrs.colwidth.join(',');
|
|
95
|
-
}
|
|
96
|
-
if (tableCellNode.attrs.placeholder) {
|
|
97
|
-
attrs['data-placeholder-text'] = tableCellNode.attrs.placeholder;
|
|
98
|
-
}
|
|
99
|
-
if (!tableCellNode.textContent) {
|
|
100
|
-
attrs.class = 'placeholder';
|
|
101
|
-
}
|
|
102
|
-
const styleString = serializeTableCellStyles(tableCellNode.attrs.styles);
|
|
103
|
-
if (styleString) {
|
|
104
|
-
attrs.style = styleString;
|
|
105
|
-
}
|
|
106
|
-
if (tableCellNode.attrs.valign) {
|
|
107
|
-
attrs.valign = tableCellNode.attrs.valign;
|
|
108
|
-
}
|
|
109
|
-
if (tableCellNode.attrs.align) {
|
|
110
|
-
attrs.align = tableCellNode.attrs.align;
|
|
111
|
-
}
|
|
112
|
-
if (tableCellNode.attrs.scope) {
|
|
113
|
-
attrs.scope = tableCellNode.attrs.scope;
|
|
114
|
-
}
|
|
115
|
-
if (tableCellNode.attrs.style) {
|
|
116
|
-
attrs.style = tableCellNode.attrs.style;
|
|
117
|
-
}
|
|
118
|
-
return [tag, attrs, 0];
|
|
119
|
-
},
|
|
120
|
-
};
|
|
@@ -1,41 +0,0 @@
|
|
|
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 { TableCellStyleKey } from '../../lib/table-cell-styles';
|
|
17
|
-
import { ManuscriptNode, TableNodeSpec } from '../types';
|
|
18
|
-
export interface TableRowNode extends ManuscriptNode {
|
|
19
|
-
attrs: {
|
|
20
|
-
placeholder: string;
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
export declare const tableRow: TableNodeSpec;
|
|
24
|
-
export type TableCellStyles = {
|
|
25
|
-
[key in TableCellStyleKey]?: string | null;
|
|
26
|
-
};
|
|
27
|
-
export interface TableCellNode extends ManuscriptNode {
|
|
28
|
-
attrs: {
|
|
29
|
-
celltype: 'td' | 'th';
|
|
30
|
-
colspan: number | null;
|
|
31
|
-
rowspan: number | null;
|
|
32
|
-
colwidth: number[] | null;
|
|
33
|
-
placeholder: string | null;
|
|
34
|
-
styles: TableCellStyles;
|
|
35
|
-
valign: string | null;
|
|
36
|
-
align: string | null;
|
|
37
|
-
scope: string | null;
|
|
38
|
-
style: string | null;
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
export declare const tableCell: TableNodeSpec;
|