@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.
@@ -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
- const dom = document.createElement('span');
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.from, output);
109
+ output = injectHighlightMarker(element, comment.selector, output);
110
110
  }
111
111
  else {
112
- element = createHighlightElement(comment, 'start');
113
- output = injectHighlightMarker(element, comment.selector.from, output);
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, offset, contents) {
120
+ function injectHighlightMarker(element, selector, contents) {
121
+ if (!selector) {
122
+ return '';
123
+ }
124
124
  const parts = [
125
- contents.substring(0, offset),
125
+ contents.substring(0, selector.from),
126
126
  element.outerHTML,
127
- contents.substring(offset),
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
- const dom = document.createElement('span');
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.from, output);
104
+ output = injectHighlightMarker(element, comment.selector, output);
105
105
  }
106
106
  else {
107
- element = createHighlightElement(comment, 'start');
108
- output = injectHighlightMarker(element, comment.selector.from, output);
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, offset, contents) {
114
+ function injectHighlightMarker(element, selector, contents) {
115
+ if (!selector) {
116
+ return '';
117
+ }
118
118
  const parts = [
119
- contents.substring(0, offset),
119
+ contents.substring(0, selector.from),
120
120
  element.outerHTML,
121
- contents.substring(offset),
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
  };
@@ -19,7 +19,7 @@ interface Attrs {
19
19
  id: string;
20
20
  tid: string;
21
21
  position: string;
22
- text: string;
22
+ content?: string;
23
23
  }
24
24
  export interface HighlightMarkerNode extends ManuscriptNode {
25
25
  attrs: Attrs;
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.11",
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
+ }