@manuscripts/transform 2.1.1-LEAN-3336-22 → 2.1.1-LEAN-3336-23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/jats/importer/jats-body-dom-parser.js +0 -8
- package/dist/cjs/jats/importer/jats-body-transformations.js +7 -3
- package/dist/cjs/jats/jats-exporter.js +5 -5
- package/dist/cjs/schema/nodes/table.js +34 -55
- package/dist/es/jats/importer/jats-body-dom-parser.js +0 -8
- package/dist/es/jats/importer/jats-body-transformations.js +7 -3
- package/dist/es/jats/jats-exporter.js +5 -5
- package/dist/es/schema/nodes/table.js +34 -55
- package/dist/types/schema/nodes/table.d.ts +3 -72
- package/package.json +2 -2
|
@@ -239,8 +239,12 @@ exports.jatsBodyTransformations = {
|
|
|
239
239
|
}
|
|
240
240
|
},
|
|
241
241
|
fixTables(body, createElement) {
|
|
242
|
-
const
|
|
243
|
-
|
|
242
|
+
const tableWraps = body.querySelectorAll('table-wrap');
|
|
243
|
+
tableWraps.forEach((tableWrap) => {
|
|
244
|
+
const table = tableWrap.querySelector('table');
|
|
245
|
+
if (!table) {
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
244
248
|
const colgroup = table.querySelector('colgroup');
|
|
245
249
|
const cols = table.querySelectorAll('col');
|
|
246
250
|
if (!colgroup && table.firstChild && cols.length > 0) {
|
|
@@ -248,7 +252,7 @@ exports.jatsBodyTransformations = {
|
|
|
248
252
|
for (const col of cols) {
|
|
249
253
|
colgroup.appendChild(col);
|
|
250
254
|
}
|
|
251
|
-
|
|
255
|
+
tableWrap.insertBefore(colgroup, tableWrap.firstChild);
|
|
252
256
|
}
|
|
253
257
|
});
|
|
254
258
|
},
|
|
@@ -614,11 +614,6 @@ class JATSExporter {
|
|
|
614
614
|
this.createSerializer = () => {
|
|
615
615
|
const getModel = (id) => id ? this.modelMap.get(id) : undefined;
|
|
616
616
|
const nodes = {
|
|
617
|
-
table_header: (node) => [
|
|
618
|
-
'th',
|
|
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
617
|
title: () => '',
|
|
623
618
|
affiliations: () => '',
|
|
624
619
|
contributors: () => '',
|
|
@@ -883,6 +878,11 @@ class JATSExporter {
|
|
|
883
878
|
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 })),
|
|
884
879
|
0,
|
|
885
880
|
],
|
|
881
|
+
table_header: (node) => [
|
|
882
|
+
'th',
|
|
883
|
+
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 })),
|
|
884
|
+
0,
|
|
885
|
+
],
|
|
886
886
|
table_row: () => ['tr', 0],
|
|
887
887
|
table_col: (node) => ['col', { width: node.attrs.width }],
|
|
888
888
|
table_colgroup: () => ['colgroup', 0],
|
|
@@ -17,64 +17,43 @@
|
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.tableHeader = exports.tableCell = exports.tableRow = exports.table = void 0;
|
|
19
19
|
const prosemirror_tables_1 = require("prosemirror-tables");
|
|
20
|
+
function createCellAttribute(attributeName, defaultValue = null, customGetFromDOM, customSetDOMAttr) {
|
|
21
|
+
return {
|
|
22
|
+
default: defaultValue,
|
|
23
|
+
getFromDOM(dom) {
|
|
24
|
+
if (customGetFromDOM) {
|
|
25
|
+
return customGetFromDOM(dom);
|
|
26
|
+
}
|
|
27
|
+
return dom.getAttribute(attributeName);
|
|
28
|
+
},
|
|
29
|
+
setDOMAttr(value, attrs) {
|
|
30
|
+
if (customSetDOMAttr) {
|
|
31
|
+
customSetDOMAttr(value, attrs);
|
|
32
|
+
}
|
|
33
|
+
else if (value) {
|
|
34
|
+
attrs[attributeName] = value;
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
}
|
|
20
39
|
const tableOptions = {
|
|
21
40
|
cellContent: 'inline*',
|
|
22
41
|
cellAttributes: {
|
|
23
|
-
placeholder:
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
},
|
|
39
|
-
setDOMAttr(value, attrs) {
|
|
40
|
-
if (value) {
|
|
41
|
-
attrs['valign'] = value;
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
align: {
|
|
46
|
-
default: null,
|
|
47
|
-
getFromDOM(dom) {
|
|
48
|
-
return dom.getAttribute('align');
|
|
49
|
-
},
|
|
50
|
-
setDOMAttr(value, attrs) {
|
|
51
|
-
if (value) {
|
|
52
|
-
attrs['align'] = value;
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
scope: {
|
|
57
|
-
default: null,
|
|
58
|
-
getFromDOM(dom) {
|
|
59
|
-
return dom.getAttribute('scope');
|
|
60
|
-
},
|
|
61
|
-
setDOMAttr(value, attrs) {
|
|
62
|
-
if (value) {
|
|
63
|
-
attrs['scope'] = value;
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
style: {
|
|
68
|
-
default: null,
|
|
69
|
-
getFromDOM(dom) {
|
|
70
|
-
return dom.getAttribute('style');
|
|
71
|
-
},
|
|
72
|
-
setDOMAttr(value, attrs) {
|
|
73
|
-
if (value) {
|
|
74
|
-
attrs['style'] = value;
|
|
75
|
-
}
|
|
76
|
-
},
|
|
77
|
-
},
|
|
42
|
+
placeholder: createCellAttribute('data-placeholder-text', 'Data', (dom) => dom.getAttribute('data-placeholder-text') || ''),
|
|
43
|
+
valign: createCellAttribute('valign'),
|
|
44
|
+
align: createCellAttribute('align'),
|
|
45
|
+
scope: createCellAttribute('scope'),
|
|
46
|
+
style: createCellAttribute('style'),
|
|
47
|
+
colspan: createCellAttribute('colspan', 1, (dom) => Number(dom.getAttribute('colspan') || 1), (value, attrs) => {
|
|
48
|
+
if (value && value !== 1) {
|
|
49
|
+
attrs['colspan'] = String(value);
|
|
50
|
+
}
|
|
51
|
+
}),
|
|
52
|
+
rowspan: createCellAttribute('rowspan', 1, (dom) => Number(dom.getAttribute('rowspan') || 1), (value, attrs) => {
|
|
53
|
+
if (value && value !== 1) {
|
|
54
|
+
attrs['rowspan'] = String(value);
|
|
55
|
+
}
|
|
56
|
+
}),
|
|
78
57
|
},
|
|
79
58
|
};
|
|
80
59
|
const tableNodes = (0, prosemirror_tables_1.tableNodes)(tableOptions);
|
|
@@ -236,8 +236,12 @@ export const jatsBodyTransformations = {
|
|
|
236
236
|
}
|
|
237
237
|
},
|
|
238
238
|
fixTables(body, createElement) {
|
|
239
|
-
const
|
|
240
|
-
|
|
239
|
+
const tableWraps = body.querySelectorAll('table-wrap');
|
|
240
|
+
tableWraps.forEach((tableWrap) => {
|
|
241
|
+
const table = tableWrap.querySelector('table');
|
|
242
|
+
if (!table) {
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
241
245
|
const colgroup = table.querySelector('colgroup');
|
|
242
246
|
const cols = table.querySelectorAll('col');
|
|
243
247
|
if (!colgroup && table.firstChild && cols.length > 0) {
|
|
@@ -245,7 +249,7 @@ export const jatsBodyTransformations = {
|
|
|
245
249
|
for (const col of cols) {
|
|
246
250
|
colgroup.appendChild(col);
|
|
247
251
|
}
|
|
248
|
-
|
|
252
|
+
tableWrap.insertBefore(colgroup, tableWrap.firstChild);
|
|
249
253
|
}
|
|
250
254
|
});
|
|
251
255
|
},
|
|
@@ -606,11 +606,6 @@ export class JATSExporter {
|
|
|
606
606
|
this.createSerializer = () => {
|
|
607
607
|
const getModel = (id) => id ? this.modelMap.get(id) : undefined;
|
|
608
608
|
const nodes = {
|
|
609
|
-
table_header: (node) => [
|
|
610
|
-
'th',
|
|
611
|
-
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 })),
|
|
612
|
-
0,
|
|
613
|
-
],
|
|
614
609
|
title: () => '',
|
|
615
610
|
affiliations: () => '',
|
|
616
611
|
contributors: () => '',
|
|
@@ -875,6 +870,11 @@ export class JATSExporter {
|
|
|
875
870
|
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 })),
|
|
876
871
|
0,
|
|
877
872
|
],
|
|
873
|
+
table_header: (node) => [
|
|
874
|
+
'th',
|
|
875
|
+
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 })),
|
|
876
|
+
0,
|
|
877
|
+
],
|
|
878
878
|
table_row: () => ['tr', 0],
|
|
879
879
|
table_col: (node) => ['col', { width: node.attrs.width }],
|
|
880
880
|
table_colgroup: () => ['colgroup', 0],
|
|
@@ -14,64 +14,43 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import { tableNodes as createTableNodes, } from 'prosemirror-tables';
|
|
17
|
+
function createCellAttribute(attributeName, defaultValue = null, customGetFromDOM, customSetDOMAttr) {
|
|
18
|
+
return {
|
|
19
|
+
default: defaultValue,
|
|
20
|
+
getFromDOM(dom) {
|
|
21
|
+
if (customGetFromDOM) {
|
|
22
|
+
return customGetFromDOM(dom);
|
|
23
|
+
}
|
|
24
|
+
return dom.getAttribute(attributeName);
|
|
25
|
+
},
|
|
26
|
+
setDOMAttr(value, attrs) {
|
|
27
|
+
if (customSetDOMAttr) {
|
|
28
|
+
customSetDOMAttr(value, attrs);
|
|
29
|
+
}
|
|
30
|
+
else if (value) {
|
|
31
|
+
attrs[attributeName] = value;
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
}
|
|
17
36
|
const tableOptions = {
|
|
18
37
|
cellContent: 'inline*',
|
|
19
38
|
cellAttributes: {
|
|
20
|
-
placeholder:
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
},
|
|
36
|
-
setDOMAttr(value, attrs) {
|
|
37
|
-
if (value) {
|
|
38
|
-
attrs['valign'] = value;
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
align: {
|
|
43
|
-
default: null,
|
|
44
|
-
getFromDOM(dom) {
|
|
45
|
-
return dom.getAttribute('align');
|
|
46
|
-
},
|
|
47
|
-
setDOMAttr(value, attrs) {
|
|
48
|
-
if (value) {
|
|
49
|
-
attrs['align'] = value;
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
scope: {
|
|
54
|
-
default: null,
|
|
55
|
-
getFromDOM(dom) {
|
|
56
|
-
return dom.getAttribute('scope');
|
|
57
|
-
},
|
|
58
|
-
setDOMAttr(value, attrs) {
|
|
59
|
-
if (value) {
|
|
60
|
-
attrs['scope'] = value;
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
style: {
|
|
65
|
-
default: null,
|
|
66
|
-
getFromDOM(dom) {
|
|
67
|
-
return dom.getAttribute('style');
|
|
68
|
-
},
|
|
69
|
-
setDOMAttr(value, attrs) {
|
|
70
|
-
if (value) {
|
|
71
|
-
attrs['style'] = value;
|
|
72
|
-
}
|
|
73
|
-
},
|
|
74
|
-
},
|
|
39
|
+
placeholder: createCellAttribute('data-placeholder-text', 'Data', (dom) => dom.getAttribute('data-placeholder-text') || ''),
|
|
40
|
+
valign: createCellAttribute('valign'),
|
|
41
|
+
align: createCellAttribute('align'),
|
|
42
|
+
scope: createCellAttribute('scope'),
|
|
43
|
+
style: createCellAttribute('style'),
|
|
44
|
+
colspan: createCellAttribute('colspan', 1, (dom) => Number(dom.getAttribute('colspan') || 1), (value, attrs) => {
|
|
45
|
+
if (value && value !== 1) {
|
|
46
|
+
attrs['colspan'] = String(value);
|
|
47
|
+
}
|
|
48
|
+
}),
|
|
49
|
+
rowspan: createCellAttribute('rowspan', 1, (dom) => Number(dom.getAttribute('rowspan') || 1), (value, attrs) => {
|
|
50
|
+
if (value && value !== 1) {
|
|
51
|
+
attrs['rowspan'] = String(value);
|
|
52
|
+
}
|
|
53
|
+
}),
|
|
75
54
|
},
|
|
76
55
|
};
|
|
77
56
|
const tableNodes = createTableNodes(tableOptions);
|
|
@@ -15,75 +15,6 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { NodeSpec } from 'prosemirror-model';
|
|
17
17
|
export declare const table: NodeSpec;
|
|
18
|
-
export declare const tableRow:
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
default: null;
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
content?: string | undefined;
|
|
25
|
-
marks?: string | undefined;
|
|
26
|
-
group?: string | undefined;
|
|
27
|
-
inline?: boolean | undefined;
|
|
28
|
-
atom?: boolean | undefined;
|
|
29
|
-
selectable?: boolean | undefined;
|
|
30
|
-
draggable?: boolean | undefined;
|
|
31
|
-
code?: boolean | undefined;
|
|
32
|
-
whitespace?: "pre" | "normal" | undefined;
|
|
33
|
-
definingAsContext?: boolean | undefined;
|
|
34
|
-
definingForContent?: boolean | undefined;
|
|
35
|
-
defining?: boolean | undefined;
|
|
36
|
-
isolating?: boolean | undefined;
|
|
37
|
-
toDOM?: ((node: import("prosemirror-model").Node) => import("prosemirror-model").DOMOutputSpec) | undefined;
|
|
38
|
-
parseDOM?: readonly import("prosemirror-model").ParseRule[] | undefined;
|
|
39
|
-
toDebugString?: ((node: import("prosemirror-model").Node) => string) | undefined;
|
|
40
|
-
leafText?: ((node: import("prosemirror-model").Node) => string) | undefined;
|
|
41
|
-
};
|
|
42
|
-
export declare const tableCell: {
|
|
43
|
-
attrs: {
|
|
44
|
-
dataTracked: {
|
|
45
|
-
default: null;
|
|
46
|
-
};
|
|
47
|
-
};
|
|
48
|
-
content?: string | undefined;
|
|
49
|
-
marks?: string | undefined;
|
|
50
|
-
group?: string | undefined;
|
|
51
|
-
inline?: boolean | undefined;
|
|
52
|
-
atom?: boolean | undefined;
|
|
53
|
-
selectable?: boolean | undefined;
|
|
54
|
-
draggable?: boolean | undefined;
|
|
55
|
-
code?: boolean | undefined;
|
|
56
|
-
whitespace?: "pre" | "normal" | undefined;
|
|
57
|
-
definingAsContext?: boolean | undefined;
|
|
58
|
-
definingForContent?: boolean | undefined;
|
|
59
|
-
defining?: boolean | undefined;
|
|
60
|
-
isolating?: boolean | undefined;
|
|
61
|
-
toDOM?: ((node: import("prosemirror-model").Node) => import("prosemirror-model").DOMOutputSpec) | undefined;
|
|
62
|
-
parseDOM?: readonly import("prosemirror-model").ParseRule[] | undefined;
|
|
63
|
-
toDebugString?: ((node: import("prosemirror-model").Node) => string) | undefined;
|
|
64
|
-
leafText?: ((node: import("prosemirror-model").Node) => string) | undefined;
|
|
65
|
-
};
|
|
66
|
-
export declare const tableHeader: {
|
|
67
|
-
attrs: {
|
|
68
|
-
dataTracked: {
|
|
69
|
-
default: null;
|
|
70
|
-
};
|
|
71
|
-
};
|
|
72
|
-
content?: string | undefined;
|
|
73
|
-
marks?: string | undefined;
|
|
74
|
-
group?: string | undefined;
|
|
75
|
-
inline?: boolean | undefined;
|
|
76
|
-
atom?: boolean | undefined;
|
|
77
|
-
selectable?: boolean | undefined;
|
|
78
|
-
draggable?: boolean | undefined;
|
|
79
|
-
code?: boolean | undefined;
|
|
80
|
-
whitespace?: "pre" | "normal" | undefined;
|
|
81
|
-
definingAsContext?: boolean | undefined;
|
|
82
|
-
definingForContent?: boolean | undefined;
|
|
83
|
-
defining?: boolean | undefined;
|
|
84
|
-
isolating?: boolean | undefined;
|
|
85
|
-
toDOM?: ((node: import("prosemirror-model").Node) => import("prosemirror-model").DOMOutputSpec) | undefined;
|
|
86
|
-
parseDOM?: readonly import("prosemirror-model").ParseRule[] | undefined;
|
|
87
|
-
toDebugString?: ((node: import("prosemirror-model").Node) => string) | undefined;
|
|
88
|
-
leafText?: ((node: import("prosemirror-model").Node) => string) | undefined;
|
|
89
|
-
};
|
|
18
|
+
export declare const tableRow: NodeSpec;
|
|
19
|
+
export declare const tableCell: NodeSpec;
|
|
20
|
+
export declare const tableHeader: NodeSpec;
|
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.1.1-LEAN-3336-
|
|
4
|
+
"version": "2.1.1-LEAN-3336-23",
|
|
5
5
|
"repository": "github:Atypon-OpenSource/manuscripts-transform",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"jszip": "^3.10.1",
|
|
36
36
|
"mathjax-full": "^3.2.2",
|
|
37
37
|
"mime": "^3.0.0",
|
|
38
|
-
"prosemirror-model": "^1.
|
|
38
|
+
"prosemirror-model": "^1.18.3",
|
|
39
39
|
"prosemirror-tables": "^1.3.5",
|
|
40
40
|
"uuid": "^9.0.0",
|
|
41
41
|
"w3c-xmlserializer": "^4.0.0"
|