@manuscripts/transform 2.1.10 → 2.1.12-LEAN-3509-0
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/jats-exporter.js +3 -0
- package/dist/cjs/schema/nodes/affiliation.js +1 -6
- package/dist/cjs/schema/nodes/highlight_marker.js +3 -6
- package/dist/cjs/schema/nodes/table_col.js +0 -2
- package/dist/cjs/schema/nodes/table_element_footer.js +2 -1
- package/dist/cjs/transformer/highlight-markers.js +13 -10
- package/dist/es/jats/jats-exporter.js +3 -0
- package/dist/es/schema/nodes/affiliation.js +1 -6
- package/dist/es/schema/nodes/highlight_marker.js +3 -6
- package/dist/es/schema/nodes/table_col.js +0 -2
- package/dist/es/schema/nodes/table_element_footer.js +2 -1
- package/dist/es/transformer/highlight-markers.js +13 -10
- package/dist/types/schema/nodes/highlight_marker.d.ts +1 -1
- package/dist/types/schema/nodes/table_col.d.ts +4 -4
- package/package.json +2 -2
|
@@ -15,12 +15,7 @@ exports.affiliation = {
|
|
|
15
15
|
county: { default: '' },
|
|
16
16
|
city: { default: '' },
|
|
17
17
|
priority: { default: undefined },
|
|
18
|
-
email: {
|
|
19
|
-
default: {
|
|
20
|
-
href: undefined,
|
|
21
|
-
text: undefined,
|
|
22
|
-
},
|
|
23
|
-
},
|
|
18
|
+
email: { default: undefined },
|
|
24
19
|
dataTracked: { default: null },
|
|
25
20
|
},
|
|
26
21
|
group: 'block',
|
|
@@ -24,6 +24,7 @@ exports.highlightMarker = {
|
|
|
24
24
|
id: { default: '' },
|
|
25
25
|
tid: { default: '' },
|
|
26
26
|
position: { default: '' },
|
|
27
|
+
content: { default: null },
|
|
27
28
|
dataTracked: { default: null },
|
|
28
29
|
},
|
|
29
30
|
parseDOM: [
|
|
@@ -35,18 +36,14 @@ exports.highlightMarker = {
|
|
|
35
36
|
id: dom.getAttribute('id'),
|
|
36
37
|
tid: dom.getAttribute('data-target-id'),
|
|
37
38
|
position: dom.getAttribute('data-position'),
|
|
39
|
+
content: dom.innerHTML,
|
|
38
40
|
};
|
|
39
41
|
},
|
|
40
42
|
},
|
|
41
43
|
],
|
|
42
44
|
toDOM: (node) => {
|
|
43
45
|
const highlightMarkerNode = node;
|
|
44
|
-
|
|
45
|
-
dom.className = 'highlight-marker';
|
|
46
|
-
dom.setAttribute('id', highlightMarkerNode.attrs.id);
|
|
47
|
-
dom.setAttribute('data-target-id', highlightMarkerNode.attrs.tid);
|
|
48
|
-
dom.setAttribute('data-position', highlightMarkerNode.attrs.position);
|
|
49
|
-
return dom;
|
|
46
|
+
return highlightMarkerNode.attrs.content || '';
|
|
50
47
|
},
|
|
51
48
|
};
|
|
52
49
|
const isHighlightMarkerNode = (node) => node.type === node.type.schema.nodes.highlight_marker;
|
|
@@ -19,7 +19,6 @@ exports.tableCol = exports.tableColGroup = void 0;
|
|
|
19
19
|
exports.tableColGroup = {
|
|
20
20
|
content: 'table_col+',
|
|
21
21
|
group: 'block',
|
|
22
|
-
tableRole: 'colgroup',
|
|
23
22
|
parseDOM: [
|
|
24
23
|
{
|
|
25
24
|
tag: 'colgroup',
|
|
@@ -34,7 +33,6 @@ exports.tableCol = {
|
|
|
34
33
|
width: { default: '' },
|
|
35
34
|
},
|
|
36
35
|
group: 'block',
|
|
37
|
-
tableRole: 'col',
|
|
38
36
|
parseDOM: [
|
|
39
37
|
{
|
|
40
38
|
tag: 'col',
|
|
@@ -19,8 +19,9 @@ exports.tableElementFooter = void 0;
|
|
|
19
19
|
exports.tableElementFooter = {
|
|
20
20
|
attrs: {
|
|
21
21
|
id: { default: '' },
|
|
22
|
+
dataTracked: { default: null }
|
|
22
23
|
},
|
|
23
|
-
content: '(paragraph | footnotes_element)
|
|
24
|
+
content: '(paragraph | footnotes_element)*',
|
|
24
25
|
group: 'block element',
|
|
25
26
|
toDOM: () => ['table-wrap-foot', 0],
|
|
26
27
|
};
|
|
@@ -106,33 +106,36 @@ const insertHighlightMarkers = (contents, commentAnnotations) => {
|
|
|
106
106
|
if (comment.selector) {
|
|
107
107
|
if (comment.selector.from === comment.selector.to) {
|
|
108
108
|
element = createHighlightElement(comment, 'point');
|
|
109
|
-
output = injectHighlightMarker(element, comment.selector
|
|
109
|
+
output = injectHighlightMarker(element, comment.selector, output);
|
|
110
110
|
}
|
|
111
111
|
else {
|
|
112
|
-
element = createHighlightElement(comment, '
|
|
113
|
-
output = injectHighlightMarker(element, comment.selector
|
|
114
|
-
const updatedEndOffset = element.outerHTML.length + comment.selector.to;
|
|
115
|
-
element = createHighlightElement(comment, 'end');
|
|
116
|
-
output = injectHighlightMarker(element, updatedEndOffset, output);
|
|
112
|
+
element = createHighlightElement(comment, 'range', output.substring(comment.selector.from, comment.selector.to));
|
|
113
|
+
output = injectHighlightMarker(element, comment.selector, output);
|
|
117
114
|
}
|
|
118
115
|
}
|
|
119
116
|
}
|
|
120
117
|
return output;
|
|
121
118
|
};
|
|
122
119
|
exports.insertHighlightMarkers = insertHighlightMarkers;
|
|
123
|
-
function injectHighlightMarker(element,
|
|
120
|
+
function injectHighlightMarker(element, selector, contents) {
|
|
121
|
+
if (!selector) {
|
|
122
|
+
return '';
|
|
123
|
+
}
|
|
124
124
|
const parts = [
|
|
125
|
-
contents.substring(0,
|
|
125
|
+
contents.substring(0, selector.from),
|
|
126
126
|
element.outerHTML,
|
|
127
|
-
contents.substring(
|
|
127
|
+
contents.substring(selector.to),
|
|
128
128
|
];
|
|
129
129
|
return parts.join('');
|
|
130
130
|
}
|
|
131
|
-
const createHighlightElement = (comment, position) => {
|
|
131
|
+
const createHighlightElement = (comment, position, content) => {
|
|
132
132
|
const element = document.createElement('span');
|
|
133
133
|
element.className = 'highlight-marker';
|
|
134
134
|
element.setAttribute('id', comment._id);
|
|
135
135
|
element.setAttribute('data-target-id', comment.target);
|
|
136
136
|
element.setAttribute('data-position', position);
|
|
137
|
+
if (content) {
|
|
138
|
+
element.innerHTML = content;
|
|
139
|
+
}
|
|
137
140
|
return element;
|
|
138
141
|
};
|
|
@@ -735,6 +735,9 @@ export class JATSExporter {
|
|
|
735
735
|
return ['fn', attrs, 0];
|
|
736
736
|
},
|
|
737
737
|
footnotes_element: (node) => {
|
|
738
|
+
if (!node.textContent) {
|
|
739
|
+
return '';
|
|
740
|
+
}
|
|
738
741
|
const kind = node.attrs.kind;
|
|
739
742
|
let tag = 'fn-group';
|
|
740
743
|
if (kind && kind.includes('table')) {
|
|
@@ -12,12 +12,7 @@ export const affiliation = {
|
|
|
12
12
|
county: { default: '' },
|
|
13
13
|
city: { default: '' },
|
|
14
14
|
priority: { default: undefined },
|
|
15
|
-
email: {
|
|
16
|
-
default: {
|
|
17
|
-
href: undefined,
|
|
18
|
-
text: undefined,
|
|
19
|
-
},
|
|
20
|
-
},
|
|
15
|
+
email: { default: undefined },
|
|
21
16
|
dataTracked: { default: null },
|
|
22
17
|
},
|
|
23
18
|
group: 'block',
|
|
@@ -21,6 +21,7 @@ export const highlightMarker = {
|
|
|
21
21
|
id: { default: '' },
|
|
22
22
|
tid: { default: '' },
|
|
23
23
|
position: { default: '' },
|
|
24
|
+
content: { default: null },
|
|
24
25
|
dataTracked: { default: null },
|
|
25
26
|
},
|
|
26
27
|
parseDOM: [
|
|
@@ -32,18 +33,14 @@ export const highlightMarker = {
|
|
|
32
33
|
id: dom.getAttribute('id'),
|
|
33
34
|
tid: dom.getAttribute('data-target-id'),
|
|
34
35
|
position: dom.getAttribute('data-position'),
|
|
36
|
+
content: dom.innerHTML,
|
|
35
37
|
};
|
|
36
38
|
},
|
|
37
39
|
},
|
|
38
40
|
],
|
|
39
41
|
toDOM: (node) => {
|
|
40
42
|
const highlightMarkerNode = node;
|
|
41
|
-
|
|
42
|
-
dom.className = 'highlight-marker';
|
|
43
|
-
dom.setAttribute('id', highlightMarkerNode.attrs.id);
|
|
44
|
-
dom.setAttribute('data-target-id', highlightMarkerNode.attrs.tid);
|
|
45
|
-
dom.setAttribute('data-position', highlightMarkerNode.attrs.position);
|
|
46
|
-
return dom;
|
|
43
|
+
return highlightMarkerNode.attrs.content || '';
|
|
47
44
|
},
|
|
48
45
|
};
|
|
49
46
|
export const isHighlightMarkerNode = (node) => node.type === node.type.schema.nodes.highlight_marker;
|
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
export const tableColGroup = {
|
|
17
17
|
content: 'table_col+',
|
|
18
18
|
group: 'block',
|
|
19
|
-
tableRole: 'colgroup',
|
|
20
19
|
parseDOM: [
|
|
21
20
|
{
|
|
22
21
|
tag: 'colgroup',
|
|
@@ -31,7 +30,6 @@ export const tableCol = {
|
|
|
31
30
|
width: { default: '' },
|
|
32
31
|
},
|
|
33
32
|
group: 'block',
|
|
34
|
-
tableRole: 'col',
|
|
35
33
|
parseDOM: [
|
|
36
34
|
{
|
|
37
35
|
tag: 'col',
|
|
@@ -16,8 +16,9 @@
|
|
|
16
16
|
export const tableElementFooter = {
|
|
17
17
|
attrs: {
|
|
18
18
|
id: { default: '' },
|
|
19
|
+
dataTracked: { default: null }
|
|
19
20
|
},
|
|
20
|
-
content: '(paragraph | footnotes_element)
|
|
21
|
+
content: '(paragraph | footnotes_element)*',
|
|
21
22
|
group: 'block element',
|
|
22
23
|
toDOM: () => ['table-wrap-foot', 0],
|
|
23
24
|
};
|
|
@@ -101,32 +101,35 @@ export const insertHighlightMarkers = (contents, commentAnnotations) => {
|
|
|
101
101
|
if (comment.selector) {
|
|
102
102
|
if (comment.selector.from === comment.selector.to) {
|
|
103
103
|
element = createHighlightElement(comment, 'point');
|
|
104
|
-
output = injectHighlightMarker(element, comment.selector
|
|
104
|
+
output = injectHighlightMarker(element, comment.selector, output);
|
|
105
105
|
}
|
|
106
106
|
else {
|
|
107
|
-
element = createHighlightElement(comment, '
|
|
108
|
-
output = injectHighlightMarker(element, comment.selector
|
|
109
|
-
const updatedEndOffset = element.outerHTML.length + comment.selector.to;
|
|
110
|
-
element = createHighlightElement(comment, 'end');
|
|
111
|
-
output = injectHighlightMarker(element, updatedEndOffset, output);
|
|
107
|
+
element = createHighlightElement(comment, 'range', output.substring(comment.selector.from, comment.selector.to));
|
|
108
|
+
output = injectHighlightMarker(element, comment.selector, output);
|
|
112
109
|
}
|
|
113
110
|
}
|
|
114
111
|
}
|
|
115
112
|
return output;
|
|
116
113
|
};
|
|
117
|
-
function injectHighlightMarker(element,
|
|
114
|
+
function injectHighlightMarker(element, selector, contents) {
|
|
115
|
+
if (!selector) {
|
|
116
|
+
return '';
|
|
117
|
+
}
|
|
118
118
|
const parts = [
|
|
119
|
-
contents.substring(0,
|
|
119
|
+
contents.substring(0, selector.from),
|
|
120
120
|
element.outerHTML,
|
|
121
|
-
contents.substring(
|
|
121
|
+
contents.substring(selector.to),
|
|
122
122
|
];
|
|
123
123
|
return parts.join('');
|
|
124
124
|
}
|
|
125
|
-
const createHighlightElement = (comment, position) => {
|
|
125
|
+
const createHighlightElement = (comment, position, content) => {
|
|
126
126
|
const element = document.createElement('span');
|
|
127
127
|
element.className = 'highlight-marker';
|
|
128
128
|
element.setAttribute('id', comment._id);
|
|
129
129
|
element.setAttribute('data-target-id', comment.target);
|
|
130
130
|
element.setAttribute('data-position', position);
|
|
131
|
+
if (content) {
|
|
132
|
+
element.innerHTML = content;
|
|
133
|
+
}
|
|
131
134
|
return element;
|
|
132
135
|
};
|
|
@@ -13,12 +13,12 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import {
|
|
17
|
-
|
|
16
|
+
import { NodeSpec } from 'prosemirror-model';
|
|
17
|
+
import { ManuscriptNode } from '../types';
|
|
18
18
|
export interface TableColNode extends ManuscriptNode {
|
|
19
19
|
attrs: {
|
|
20
20
|
width: string;
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
-
export declare const tableColGroup:
|
|
24
|
-
export declare const tableCol:
|
|
23
|
+
export declare const tableColGroup: NodeSpec;
|
|
24
|
+
export declare const tableCol: 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.
|
|
4
|
+
"version": "2.1.12-LEAN-3509-0",
|
|
5
5
|
"repository": "github:Atypon-OpenSource/manuscripts-transform",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|
|
@@ -78,4 +78,4 @@
|
|
|
78
78
|
"rimraf": "^3.0.2",
|
|
79
79
|
"typescript": "^4.0.5"
|
|
80
80
|
}
|
|
81
|
-
}
|
|
81
|
+
}
|