@manuscripts/transform 2.1.11 → 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/schema/nodes/affiliation.js +1 -6
- package/dist/cjs/schema/nodes/highlight_marker.js +3 -6
- package/dist/cjs/transformer/highlight-markers.js +13 -10
- package/dist/es/schema/nodes/affiliation.js +1 -6
- package/dist/es/schema/nodes/highlight_marker.js +3 -6
- package/dist/es/transformer/highlight-markers.js +13 -10
- package/dist/types/schema/nodes/highlight_marker.d.ts +1 -1
- 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;
|
|
@@ -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
|
};
|
|
@@ -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;
|
|
@@ -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
|
};
|
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
|
+
}
|