@manuscripts/transform 1.0.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.
Files changed (315) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +193 -0
  3. package/dist/cjs/errors.js +17 -0
  4. package/dist/cjs/index.js +27 -0
  5. package/dist/cjs/jats/importer/index.js +24 -0
  6. package/dist/cjs/jats/importer/jats-body-dom-parser.js +650 -0
  7. package/dist/cjs/jats/importer/jats-body-transformations.js +269 -0
  8. package/dist/cjs/jats/importer/jats-comments.js +131 -0
  9. package/dist/cjs/jats/importer/jats-front-parser.js +341 -0
  10. package/dist/cjs/jats/importer/jats-journal-meta-parser.js +77 -0
  11. package/dist/cjs/jats/importer/jats-parser-utils.js +145 -0
  12. package/dist/cjs/jats/importer/jats-reference-parser.js +180 -0
  13. package/dist/cjs/jats/importer/parse-jats-article.js +237 -0
  14. package/dist/cjs/jats/index.js +40 -0
  15. package/dist/cjs/jats/jats-exporter.js +1569 -0
  16. package/dist/cjs/jats/jats-versions.js +41 -0
  17. package/dist/cjs/lib/attributes.js +26 -0
  18. package/dist/cjs/lib/html.js +48 -0
  19. package/dist/cjs/lib/styled-content.js +28 -0
  20. package/dist/cjs/lib/table-cell-styles.js +52 -0
  21. package/dist/cjs/lib/utils.js +66 -0
  22. package/dist/cjs/mathjax/index.js +41 -0
  23. package/dist/cjs/mathjax/mathjax-packages.js +20 -0
  24. package/dist/cjs/mathjax/mathml-to-svg.js +56 -0
  25. package/dist/cjs/mathjax/tex-to-mathml.js +49 -0
  26. package/dist/cjs/mathjax/tex-to-svg.js +59 -0
  27. package/dist/cjs/schema/groups.js +31 -0
  28. package/dist/cjs/schema/index.js +195 -0
  29. package/dist/cjs/schema/marks.js +159 -0
  30. package/dist/cjs/schema/nodes/attribution.js +32 -0
  31. package/dist/cjs/schema/nodes/bibliography_element.js +44 -0
  32. package/dist/cjs/schema/nodes/bibliography_item.js +101 -0
  33. package/dist/cjs/schema/nodes/bibliography_section.js +46 -0
  34. package/dist/cjs/schema/nodes/blockquote_element.js +62 -0
  35. package/dist/cjs/schema/nodes/caption.js +52 -0
  36. package/dist/cjs/schema/nodes/caption_title.js +51 -0
  37. package/dist/cjs/schema/nodes/citation.js +52 -0
  38. package/dist/cjs/schema/nodes/comment.js +26 -0
  39. package/dist/cjs/schema/nodes/cross_reference.js +58 -0
  40. package/dist/cjs/schema/nodes/doc.js +21 -0
  41. package/dist/cjs/schema/nodes/equation.js +55 -0
  42. package/dist/cjs/schema/nodes/equation_element.js +52 -0
  43. package/dist/cjs/schema/nodes/figcaption.js +31 -0
  44. package/dist/cjs/schema/nodes/figure.js +52 -0
  45. package/dist/cjs/schema/nodes/figure_element.js +78 -0
  46. package/dist/cjs/schema/nodes/footnote.js +67 -0
  47. package/dist/cjs/schema/nodes/footnotes_element.js +54 -0
  48. package/dist/cjs/schema/nodes/footnotes_section.js +45 -0
  49. package/dist/cjs/schema/nodes/graphical_abstract_section.js +46 -0
  50. package/dist/cjs/schema/nodes/hard_break.js +30 -0
  51. package/dist/cjs/schema/nodes/highlight_marker.js +53 -0
  52. package/dist/cjs/schema/nodes/inline_equation.js +58 -0
  53. package/dist/cjs/schema/nodes/inline_footnote.js +51 -0
  54. package/dist/cjs/schema/nodes/keywords_element.js +52 -0
  55. package/dist/cjs/schema/nodes/keywords_section.js +46 -0
  56. package/dist/cjs/schema/nodes/link.js +61 -0
  57. package/dist/cjs/schema/nodes/list.js +121 -0
  58. package/dist/cjs/schema/nodes/listing.js +73 -0
  59. package/dist/cjs/schema/nodes/listing_element.js +52 -0
  60. package/dist/cjs/schema/nodes/manuscript.js +46 -0
  61. package/dist/cjs/schema/nodes/missing_figure.js +50 -0
  62. package/dist/cjs/schema/nodes/paragraph.js +63 -0
  63. package/dist/cjs/schema/nodes/placeholder.js +49 -0
  64. package/dist/cjs/schema/nodes/placeholder_element.js +48 -0
  65. package/dist/cjs/schema/nodes/pullquote_element.js +65 -0
  66. package/dist/cjs/schema/nodes/section.js +94 -0
  67. package/dist/cjs/schema/nodes/section_label.js +30 -0
  68. package/dist/cjs/schema/nodes/section_title.js +48 -0
  69. package/dist/cjs/schema/nodes/table.js +70 -0
  70. package/dist/cjs/schema/nodes/table_col.js +57 -0
  71. package/dist/cjs/schema/nodes/table_element.js +62 -0
  72. package/dist/cjs/schema/nodes/table_row.js +123 -0
  73. package/dist/cjs/schema/nodes/text.js +21 -0
  74. package/dist/cjs/schema/nodes/toc_element.js +52 -0
  75. package/dist/cjs/schema/nodes/toc_section.js +46 -0
  76. package/dist/cjs/schema/types.js +17 -0
  77. package/dist/cjs/tests.js +30 -0
  78. package/dist/cjs/transformer/builders.js +305 -0
  79. package/dist/cjs/transformer/bundles-data.js +36 -0
  80. package/dist/cjs/transformer/bundles.js +32 -0
  81. package/dist/cjs/transformer/decode.js +619 -0
  82. package/dist/cjs/transformer/document-object-types.js +31 -0
  83. package/dist/cjs/transformer/encode.js +545 -0
  84. package/dist/cjs/transformer/filename.js +27 -0
  85. package/dist/cjs/transformer/footnote-category.js +20 -0
  86. package/dist/cjs/transformer/footnotes-order.js +59 -0
  87. package/dist/cjs/transformer/highlight-markers.js +126 -0
  88. package/dist/cjs/transformer/html.js +414 -0
  89. package/dist/cjs/transformer/id.js +28 -0
  90. package/dist/cjs/transformer/index.js +54 -0
  91. package/dist/cjs/transformer/labels.js +85 -0
  92. package/dist/cjs/transformer/manuscript-dependencies.js +74 -0
  93. package/dist/cjs/transformer/model-map.js +26 -0
  94. package/dist/cjs/transformer/models.js +17 -0
  95. package/dist/cjs/transformer/node-names.js +42 -0
  96. package/dist/cjs/transformer/node-title.js +87 -0
  97. package/dist/cjs/transformer/node-types.js +62 -0
  98. package/dist/cjs/transformer/object-types.js +57 -0
  99. package/dist/cjs/transformer/project-bundle.js +86 -0
  100. package/dist/cjs/transformer/section-category.js +222 -0
  101. package/dist/cjs/transformer/serializer.js +23 -0
  102. package/dist/cjs/transformer/shared-data.js +31 -0
  103. package/dist/cjs/transformer/tei-grobid-importer.js +121 -0
  104. package/dist/cjs/transformer/timestamp.js +20 -0
  105. package/dist/cjs/transformer/update-identifiers.js +93 -0
  106. package/dist/cjs/types.js +2 -0
  107. package/dist/es/errors.js +12 -0
  108. package/dist/es/index.js +9 -0
  109. package/dist/es/jats/importer/index.js +16 -0
  110. package/dist/es/jats/importer/jats-body-dom-parser.js +644 -0
  111. package/dist/es/jats/importer/jats-body-transformations.js +266 -0
  112. package/dist/es/jats/importer/jats-comments.js +124 -0
  113. package/dist/es/jats/importer/jats-front-parser.js +335 -0
  114. package/dist/es/jats/importer/jats-journal-meta-parser.js +70 -0
  115. package/dist/es/jats/importer/jats-parser-utils.js +139 -0
  116. package/dist/es/jats/importer/jats-reference-parser.js +177 -0
  117. package/dist/es/jats/importer/parse-jats-article.js +229 -0
  118. package/dist/es/jats/index.js +18 -0
  119. package/dist/es/jats/jats-exporter.js +1561 -0
  120. package/dist/es/jats/jats-versions.js +36 -0
  121. package/dist/es/lib/attributes.js +22 -0
  122. package/dist/es/lib/html.js +43 -0
  123. package/dist/es/lib/styled-content.js +23 -0
  124. package/dist/es/lib/table-cell-styles.js +47 -0
  125. package/dist/es/lib/utils.js +59 -0
  126. package/dist/es/mathjax/index.js +12 -0
  127. package/dist/es/mathjax/mathjax-packages.js +17 -0
  128. package/dist/es/mathjax/mathml-to-svg.js +52 -0
  129. package/dist/es/mathjax/tex-to-mathml.js +45 -0
  130. package/dist/es/mathjax/tex-to-svg.js +55 -0
  131. package/dist/es/schema/groups.js +27 -0
  132. package/dist/es/schema/index.js +178 -0
  133. package/dist/es/schema/marks.js +156 -0
  134. package/dist/es/schema/nodes/attribution.js +29 -0
  135. package/dist/es/schema/nodes/bibliography_element.js +41 -0
  136. package/dist/es/schema/nodes/bibliography_item.js +98 -0
  137. package/dist/es/schema/nodes/bibliography_section.js +42 -0
  138. package/dist/es/schema/nodes/blockquote_element.js +58 -0
  139. package/dist/es/schema/nodes/caption.js +49 -0
  140. package/dist/es/schema/nodes/caption_title.js +48 -0
  141. package/dist/es/schema/nodes/citation.js +48 -0
  142. package/dist/es/schema/nodes/comment.js +23 -0
  143. package/dist/es/schema/nodes/cross_reference.js +55 -0
  144. package/dist/es/schema/nodes/doc.js +18 -0
  145. package/dist/es/schema/nodes/equation.js +52 -0
  146. package/dist/es/schema/nodes/equation_element.js +49 -0
  147. package/dist/es/schema/nodes/figcaption.js +28 -0
  148. package/dist/es/schema/nodes/figure.js +49 -0
  149. package/dist/es/schema/nodes/figure_element.js +74 -0
  150. package/dist/es/schema/nodes/footnote.js +63 -0
  151. package/dist/es/schema/nodes/footnotes_element.js +50 -0
  152. package/dist/es/schema/nodes/footnotes_section.js +41 -0
  153. package/dist/es/schema/nodes/graphical_abstract_section.js +42 -0
  154. package/dist/es/schema/nodes/hard_break.js +27 -0
  155. package/dist/es/schema/nodes/highlight_marker.js +49 -0
  156. package/dist/es/schema/nodes/inline_equation.js +55 -0
  157. package/dist/es/schema/nodes/inline_footnote.js +47 -0
  158. package/dist/es/schema/nodes/keywords_element.js +49 -0
  159. package/dist/es/schema/nodes/keywords_section.js +42 -0
  160. package/dist/es/schema/nodes/link.js +58 -0
  161. package/dist/es/schema/nodes/list.js +117 -0
  162. package/dist/es/schema/nodes/listing.js +69 -0
  163. package/dist/es/schema/nodes/listing_element.js +49 -0
  164. package/dist/es/schema/nodes/manuscript.js +43 -0
  165. package/dist/es/schema/nodes/missing_figure.js +47 -0
  166. package/dist/es/schema/nodes/paragraph.js +59 -0
  167. package/dist/es/schema/nodes/placeholder.js +46 -0
  168. package/dist/es/schema/nodes/placeholder_element.js +45 -0
  169. package/dist/es/schema/nodes/pullquote_element.js +61 -0
  170. package/dist/es/schema/nodes/section.js +90 -0
  171. package/dist/es/schema/nodes/section_label.js +26 -0
  172. package/dist/es/schema/nodes/section_title.js +44 -0
  173. package/dist/es/schema/nodes/table.js +67 -0
  174. package/dist/es/schema/nodes/table_col.js +54 -0
  175. package/dist/es/schema/nodes/table_element.js +59 -0
  176. package/dist/es/schema/nodes/table_row.js +120 -0
  177. package/dist/es/schema/nodes/text.js +18 -0
  178. package/dist/es/schema/nodes/toc_element.js +49 -0
  179. package/dist/es/schema/nodes/toc_section.js +42 -0
  180. package/dist/es/schema/types.js +16 -0
  181. package/dist/es/tests.js +28 -0
  182. package/dist/es/transformer/builders.js +261 -0
  183. package/dist/es/transformer/bundles-data.js +8 -0
  184. package/dist/es/transformer/bundles.js +27 -0
  185. package/dist/es/transformer/decode.js +608 -0
  186. package/dist/es/transformer/document-object-types.js +28 -0
  187. package/dist/es/transformer/encode.js +535 -0
  188. package/dist/es/transformer/filename.js +23 -0
  189. package/dist/es/transformer/footnote-category.js +16 -0
  190. package/dist/es/transformer/footnotes-order.js +53 -0
  191. package/dist/es/transformer/highlight-markers.js +120 -0
  192. package/dist/es/transformer/html.js +407 -0
  193. package/dist/es/transformer/id.js +23 -0
  194. package/dist/es/transformer/index.js +38 -0
  195. package/dist/es/transformer/labels.js +81 -0
  196. package/dist/es/transformer/manuscript-dependencies.js +64 -0
  197. package/dist/es/transformer/model-map.js +22 -0
  198. package/dist/es/transformer/models.js +16 -0
  199. package/dist/es/transformer/node-names.js +39 -0
  200. package/dist/es/transformer/node-title.js +82 -0
  201. package/dist/es/transformer/node-types.js +55 -0
  202. package/dist/es/transformer/object-types.js +52 -0
  203. package/dist/es/transformer/project-bundle.js +77 -0
  204. package/dist/es/transformer/section-category.js +210 -0
  205. package/dist/es/transformer/serializer.js +17 -0
  206. package/dist/es/transformer/shared-data.js +1 -0
  207. package/dist/es/transformer/tei-grobid-importer.js +115 -0
  208. package/dist/es/transformer/timestamp.js +16 -0
  209. package/dist/es/transformer/update-identifiers.js +87 -0
  210. package/dist/es/types.js +1 -0
  211. package/dist/types/errors.d.ts +6 -0
  212. package/dist/types/index.d.ts +9 -0
  213. package/dist/types/jats/importer/index.d.ts +16 -0
  214. package/dist/types/jats/importer/jats-body-dom-parser.d.ts +24 -0
  215. package/dist/types/jats/importer/jats-body-transformations.d.ts +31 -0
  216. package/dist/types/jats/importer/jats-comments.d.ts +26 -0
  217. package/dist/types/jats/importer/jats-front-parser.d.ts +62 -0
  218. package/dist/types/jats/importer/jats-journal-meta-parser.d.ts +37 -0
  219. package/dist/types/jats/importer/jats-parser-utils.d.ts +23 -0
  220. package/dist/types/jats/importer/jats-reference-parser.d.ts +23 -0
  221. package/dist/types/jats/importer/parse-jats-article.d.ts +30 -0
  222. package/dist/types/jats/index.d.ts +18 -0
  223. package/dist/types/jats/jats-exporter.d.ts +72 -0
  224. package/dist/types/jats/jats-versions.d.ts +23 -0
  225. package/dist/types/lib/attributes.d.ts +20 -0
  226. package/dist/types/lib/html.d.ts +17 -0
  227. package/dist/types/lib/styled-content.d.ts +22 -0
  228. package/dist/types/lib/table-cell-styles.d.ts +27 -0
  229. package/dist/types/lib/utils.d.ts +26 -0
  230. package/dist/types/mathjax/index.d.ts +3 -0
  231. package/dist/types/mathjax/mathjax-packages.d.ts +16 -0
  232. package/dist/types/mathjax/mathml-to-svg.d.ts +17 -0
  233. package/dist/types/mathjax/tex-to-mathml.d.ts +17 -0
  234. package/dist/types/mathjax/tex-to-svg.d.ts +17 -0
  235. package/dist/types/schema/groups.d.ts +22 -0
  236. package/dist/types/schema/index.d.ts +65 -0
  237. package/dist/types/schema/marks.d.ts +27 -0
  238. package/dist/types/schema/nodes/attribution.d.ts +21 -0
  239. package/dist/types/schema/nodes/bibliography_element.d.ts +26 -0
  240. package/dist/types/schema/nodes/bibliography_item.d.ts +36 -0
  241. package/dist/types/schema/nodes/bibliography_section.d.ts +26 -0
  242. package/dist/types/schema/nodes/blockquote_element.d.ts +28 -0
  243. package/dist/types/schema/nodes/caption.d.ts +25 -0
  244. package/dist/types/schema/nodes/caption_title.d.ts +25 -0
  245. package/dist/types/schema/nodes/citation.d.ts +27 -0
  246. package/dist/types/schema/nodes/comment.d.ts +31 -0
  247. package/dist/types/schema/nodes/cross_reference.d.ts +26 -0
  248. package/dist/types/schema/nodes/doc.d.ts +17 -0
  249. package/dist/types/schema/nodes/equation.d.ts +28 -0
  250. package/dist/types/schema/nodes/equation_element.d.ts +29 -0
  251. package/dist/types/schema/nodes/figcaption.d.ts +21 -0
  252. package/dist/types/schema/nodes/figure.d.ts +25 -0
  253. package/dist/types/schema/nodes/figure_element.d.ts +44 -0
  254. package/dist/types/schema/nodes/footnote.d.ts +32 -0
  255. package/dist/types/schema/nodes/footnotes_element.d.ts +28 -0
  256. package/dist/types/schema/nodes/footnotes_section.d.ts +26 -0
  257. package/dist/types/schema/nodes/graphical_abstract_section.d.ts +26 -0
  258. package/dist/types/schema/nodes/hard_break.d.ts +21 -0
  259. package/dist/types/schema/nodes/highlight_marker.d.ts +29 -0
  260. package/dist/types/schema/nodes/inline_equation.d.ts +28 -0
  261. package/dist/types/schema/nodes/inline_footnote.d.ts +27 -0
  262. package/dist/types/schema/nodes/keywords_element.d.ts +27 -0
  263. package/dist/types/schema/nodes/keywords_section.d.ts +26 -0
  264. package/dist/types/schema/nodes/link.d.ts +26 -0
  265. package/dist/types/schema/nodes/list.d.ts +39 -0
  266. package/dist/types/schema/nodes/listing.d.ts +33 -0
  267. package/dist/types/schema/nodes/listing_element.d.ts +29 -0
  268. package/dist/types/schema/nodes/manuscript.d.ts +23 -0
  269. package/dist/types/schema/nodes/missing_figure.d.ts +23 -0
  270. package/dist/types/schema/nodes/paragraph.d.ts +30 -0
  271. package/dist/types/schema/nodes/placeholder.d.ts +26 -0
  272. package/dist/types/schema/nodes/placeholder_element.d.ts +25 -0
  273. package/dist/types/schema/nodes/pullquote_element.d.ts +28 -0
  274. package/dist/types/schema/nodes/section.d.ts +36 -0
  275. package/dist/types/schema/nodes/section_label.d.ts +22 -0
  276. package/dist/types/schema/nodes/section_title.d.ts +22 -0
  277. package/dist/types/schema/nodes/table.d.ts +27 -0
  278. package/dist/types/schema/nodes/table_col.d.ts +24 -0
  279. package/dist/types/schema/nodes/table_element.d.ts +35 -0
  280. package/dist/types/schema/nodes/table_row.d.ts +41 -0
  281. package/dist/types/schema/nodes/text.d.ts +17 -0
  282. package/dist/types/schema/nodes/toc_element.d.ts +27 -0
  283. package/dist/types/schema/nodes/toc_section.d.ts +26 -0
  284. package/dist/types/schema/types.d.ts +45 -0
  285. package/dist/types/tests.d.ts +16 -0
  286. package/dist/types/transformer/builders.d.ts +74 -0
  287. package/dist/types/transformer/bundles-data.d.ts +3 -0
  288. package/dist/types/transformer/bundles.d.ts +3 -0
  289. package/dist/types/transformer/decode.d.ts +38 -0
  290. package/dist/types/transformer/document-object-types.d.ts +17 -0
  291. package/dist/types/transformer/encode.d.ts +29 -0
  292. package/dist/types/transformer/filename.d.ts +16 -0
  293. package/dist/types/transformer/footnote-category.d.ts +17 -0
  294. package/dist/types/transformer/footnotes-order.d.ts +23 -0
  295. package/dist/types/transformer/highlight-markers.d.ts +26 -0
  296. package/dist/types/transformer/html.d.ts +36 -0
  297. package/dist/types/transformer/id.d.ts +20 -0
  298. package/dist/types/transformer/index.d.ts +38 -0
  299. package/dist/types/transformer/labels.d.ts +24 -0
  300. package/dist/types/transformer/manuscript-dependencies.d.ts +12 -0
  301. package/dist/types/transformer/model-map.d.ts +19 -0
  302. package/dist/types/transformer/models.d.ts +48 -0
  303. package/dist/types/transformer/node-names.d.ts +17 -0
  304. package/dist/types/transformer/node-title.d.ts +19 -0
  305. package/dist/types/transformer/node-types.d.ts +22 -0
  306. package/dist/types/transformer/object-types.d.ts +29 -0
  307. package/dist/types/transformer/project-bundle.d.ts +30 -0
  308. package/dist/types/transformer/section-category.d.ts +28 -0
  309. package/dist/types/transformer/serializer.d.ts +19 -0
  310. package/dist/types/transformer/shared-data.d.ts +2 -0
  311. package/dist/types/transformer/tei-grobid-importer.d.ts +20 -0
  312. package/dist/types/transformer/timestamp.d.ts +16 -0
  313. package/dist/types/transformer/update-identifiers.d.ts +23 -0
  314. package/dist/types/types.d.ts +2 -0
  315. package/package.json +89 -0
@@ -0,0 +1,120 @@
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 { buildComment } from './builders';
17
+ const highlightableFields = [
18
+ 'caption',
19
+ 'contents',
20
+ 'title',
21
+ ];
22
+ export const isHighlightableModel = (model) => {
23
+ for (const field of highlightableFields) {
24
+ if (field in model) {
25
+ return true;
26
+ }
27
+ }
28
+ return false;
29
+ };
30
+ export const extractHighlightMarkers = (model, commentAnnotationsMap) => {
31
+ for (const field of highlightableFields) {
32
+ let html = model[field];
33
+ if (html === undefined) {
34
+ continue;
35
+ }
36
+ const template = document.createElement('template');
37
+ template.innerHTML = `<div>${html}</div>`;
38
+ const element = template.content.firstChild;
39
+ if (!(element instanceof Element)) {
40
+ continue;
41
+ }
42
+ const markers = element.querySelectorAll('span.highlight-marker');
43
+ if (markers.length) {
44
+ for (const marker of markers) {
45
+ const markerHTML = marker.outerHTML;
46
+ const offset = html.indexOf(markerHTML);
47
+ if (offset === -1) {
48
+ continue;
49
+ }
50
+ const _id = marker.getAttribute('id');
51
+ const target = marker.getAttribute('data-target-id');
52
+ if (_id && target) {
53
+ const position = marker.getAttribute('data-position');
54
+ const commentAnnotation = Object.assign(Object.assign({}, buildComment(target, '')), { _id: _id });
55
+ if (position === 'start') {
56
+ commentAnnotationsMap.set(commentAnnotation._id, Object.assign(Object.assign({}, commentAnnotation), { selector: {
57
+ from: offset,
58
+ to: -1,
59
+ } }));
60
+ }
61
+ else if (position === 'end') {
62
+ const comment = commentAnnotationsMap.get(commentAnnotation._id);
63
+ if (comment && comment.selector) {
64
+ commentAnnotationsMap.set(comment._id, Object.assign(Object.assign({}, comment), { selector: Object.assign(Object.assign({}, comment.selector), { to: offset }) }));
65
+ }
66
+ }
67
+ else if (position === 'point') {
68
+ commentAnnotationsMap.set(commentAnnotation._id, Object.assign(Object.assign({}, commentAnnotation), { selector: { from: offset, to: offset } }));
69
+ }
70
+ }
71
+ html = html.substr(0, offset) + html.substr(offset + markerHTML.length);
72
+ }
73
+ model[field] = html;
74
+ }
75
+ }
76
+ };
77
+ export const insertHighlightMarkers = (contents, commentAnnotations) => {
78
+ let output = contents;
79
+ const sortedComments = commentAnnotations.sort((a, b) => {
80
+ if (a.selector && b.selector) {
81
+ return b.selector.from - a.selector.from;
82
+ }
83
+ else {
84
+ return 0;
85
+ }
86
+ });
87
+ for (const comment of sortedComments) {
88
+ let element;
89
+ if (comment.selector) {
90
+ if (comment.selector.from === comment.selector.to) {
91
+ element = createHighlightElement(comment, 'point');
92
+ output = injectHighlightMarker(element, comment.selector.from, output);
93
+ }
94
+ else {
95
+ element = createHighlightElement(comment, 'start');
96
+ output = injectHighlightMarker(element, comment.selector.from, output);
97
+ const updatedEndOffset = element.outerHTML.length + comment.selector.to;
98
+ element = createHighlightElement(comment, 'end');
99
+ output = injectHighlightMarker(element, updatedEndOffset, output);
100
+ }
101
+ }
102
+ }
103
+ return output;
104
+ };
105
+ function injectHighlightMarker(element, offset, contents) {
106
+ const parts = [
107
+ contents.substring(0, offset),
108
+ element.outerHTML,
109
+ contents.substring(offset),
110
+ ];
111
+ return parts.join('');
112
+ }
113
+ const createHighlightElement = (comment, position) => {
114
+ const element = document.createElement('span');
115
+ element.className = 'highlight-marker';
116
+ element.setAttribute('id', comment._id);
117
+ element.setAttribute('data-target-id', comment.target);
118
+ element.setAttribute('data-position', position);
119
+ return element;
120
+ };
@@ -0,0 +1,407 @@
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 { ObjectTypes, } from '@manuscripts/manuscripts-json-schema';
17
+ import { DOMSerializer } from 'prosemirror-model';
18
+ import serializeToXML from 'w3c-xmlserializer';
19
+ import { createCounter } from '../jats/jats-exporter';
20
+ import { buildStyledContentClass } from '../lib/styled-content';
21
+ import { schema, } from '../schema';
22
+ import { generateAttachmentFilename } from './filename';
23
+ import { buildTargets } from './labels';
24
+ import { isNodeType } from './node-types';
25
+ import { hasObjectType } from './object-types';
26
+ import { findJournal, findManuscript } from './project-bundle';
27
+ import { chooseSecType } from './section-category';
28
+ const chooseNodeName = (element) => {
29
+ const nodeName = element.nodeName.toLowerCase();
30
+ if (nodeName === 'figure') {
31
+ if (element.classList.contains('table')) {
32
+ return 'figure-table';
33
+ }
34
+ if (element.classList.contains('listing')) {
35
+ return 'figure-listing';
36
+ }
37
+ if (element.classList.contains('equation')) {
38
+ return 'figure-equation';
39
+ }
40
+ return 'figure';
41
+ }
42
+ else if (nodeName === 'section') {
43
+ const sectionCategory = element.getAttribute('data-category');
44
+ if (sectionCategory) {
45
+ const secType = chooseSecType(sectionCategory);
46
+ if (secType) {
47
+ return secType;
48
+ }
49
+ }
50
+ }
51
+ else if (element.classList.length === 1) {
52
+ const className = element.classList.item(0);
53
+ if (className && !className.startsWith('MP')) {
54
+ return className;
55
+ }
56
+ }
57
+ return nodeName;
58
+ };
59
+ const createDefaultIdGenerator = () => {
60
+ const counter = createCounter();
61
+ return async (element) => {
62
+ const nodeName = chooseNodeName(element);
63
+ const index = counter.increment(nodeName);
64
+ return `${nodeName}-${index}`;
65
+ };
66
+ };
67
+ export class HTMLTransformer {
68
+ constructor() {
69
+ this.serializeToHTML = async (fragment, modelMap, options = {}) => {
70
+ const { idGenerator, mediaPathGenerator } = options;
71
+ this.modelMap = modelMap;
72
+ const manuscript = findManuscript(this.modelMap);
73
+ this.labelTargets = buildTargets(fragment, manuscript);
74
+ this.document = document.implementation.createDocument('http://www.w3.org/1999/xhtml', 'html', document.implementation.createDocumentType('html', '', ''));
75
+ const article = this.document.createElement('article');
76
+ this.document.documentElement.appendChild(article);
77
+ article.appendChild(this.buildFront());
78
+ article.appendChild(this.buildBody(fragment));
79
+ this.fixBody(fragment);
80
+ await this.rewriteIDs(idGenerator);
81
+ if (mediaPathGenerator) {
82
+ await this.rewriteMediaPaths(mediaPathGenerator);
83
+ }
84
+ return serializeToXML(this.document);
85
+ };
86
+ this.rewriteMediaPaths = async (mediaPathGenerator) => {
87
+ for (const image of this.document.querySelectorAll('figure > img')) {
88
+ const parentFigure = image.parentNode;
89
+ if (parentFigure) {
90
+ const parentID = parentFigure.getAttribute('data-uuid');
91
+ if (parentID) {
92
+ const newSrc = await mediaPathGenerator(image, parentID);
93
+ image.setAttribute('src', newSrc);
94
+ }
95
+ }
96
+ }
97
+ };
98
+ this.rewriteIDs = async (idGenerator = createDefaultIdGenerator()) => {
99
+ const idMap = new Map();
100
+ for (const element of this.document.querySelectorAll('[id]')) {
101
+ const previousID = element.getAttribute('id');
102
+ if (previousID && !previousID.match(/^MP[a-z]+:[a-z0-9-]+$/i)) {
103
+ continue;
104
+ }
105
+ const newID = await idGenerator(element);
106
+ if (newID) {
107
+ element.setAttribute('id', newID);
108
+ if (previousID) {
109
+ const ancores = [
110
+ ...this.document.querySelectorAll(`a[href="#${previousID}"]`),
111
+ ];
112
+ ancores.map((a) => a.setAttribute('href', `#${newID}`));
113
+ element.setAttribute('data-uuid', previousID);
114
+ }
115
+ }
116
+ else {
117
+ element.removeAttribute('id');
118
+ }
119
+ if (previousID) {
120
+ idMap.set(previousID, newID);
121
+ }
122
+ }
123
+ for (const node of this.document.querySelectorAll('[data-reference-ids]')) {
124
+ const rids = node.getAttribute('data-reference-ids');
125
+ if (rids) {
126
+ const newRIDs = rids
127
+ .split(/\s+/)
128
+ .filter(Boolean)
129
+ .map((previousRID) => idMap.get(previousRID))
130
+ .filter(Boolean);
131
+ if (newRIDs.length) {
132
+ node.setAttribute('data-reference-ids', newRIDs.join(' '));
133
+ }
134
+ }
135
+ }
136
+ for (const node of this.document.querySelectorAll('[data-reference-id]')) {
137
+ const rid = node.getAttribute('data-reference-id');
138
+ if (rid) {
139
+ const newRID = idMap.get(rid);
140
+ if (newRID) {
141
+ node.setAttribute('data-reference-id', newRID);
142
+ }
143
+ }
144
+ }
145
+ };
146
+ this.buildFront = () => {
147
+ const manuscript = findManuscript(this.modelMap);
148
+ const journal = findJournal(this.modelMap);
149
+ if (!manuscript) {
150
+ throw new Error('Manuscript not found in project modelMap');
151
+ }
152
+ const front = this.document.createElement('header');
153
+ if (manuscript.headerFigure) {
154
+ const figure = this.modelMap.get(manuscript.headerFigure);
155
+ if (figure) {
156
+ const headerFigure = document.createElement('figure');
157
+ headerFigure.setAttribute('id', figure._id);
158
+ front.appendChild(headerFigure);
159
+ const filename = generateAttachmentFilename(figure._id, figure.contentType);
160
+ const img = this.document.createElement('img');
161
+ img.setAttribute('src', filename);
162
+ headerFigure.appendChild(img);
163
+ }
164
+ }
165
+ const articleMeta = this.document.createElement('div');
166
+ front.appendChild(articleMeta);
167
+ const articleTitle = this.document.createElement('h1');
168
+ if (manuscript.title) {
169
+ articleTitle.innerHTML = manuscript.title;
170
+ }
171
+ if (journal === null || journal === void 0 ? void 0 : journal.title) {
172
+ articleTitle.setAttribute('data-journal', journal.title);
173
+ }
174
+ articleMeta.appendChild(articleTitle);
175
+ if (manuscript.DOI) {
176
+ const articleID = this.document.createElement('article-id');
177
+ articleID.setAttribute('pub-id-type', 'doi');
178
+ articleID.innerHTML = manuscript.DOI;
179
+ articleMeta.append(articleID);
180
+ }
181
+ this.buildContributors(articleMeta);
182
+ return front;
183
+ };
184
+ this.buildBody = (fragment) => {
185
+ const getModel = (id) => id ? this.modelMap.get(id) : undefined;
186
+ const nodes = {};
187
+ for (const [name, node] of Object.entries(schema.nodes)) {
188
+ if (node.spec.toDOM) {
189
+ nodes[name] = node.spec.toDOM;
190
+ }
191
+ }
192
+ nodes.citation = (node) => {
193
+ const citationNode = node;
194
+ const element = this.document.createElement('span');
195
+ element.setAttribute('class', 'citation');
196
+ const citation = getModel(citationNode.attrs.rid);
197
+ if (citation) {
198
+ element.setAttribute('data-reference-ids', citation.embeddedCitationItems
199
+ .map((item) => item.bibliographyItem)
200
+ .join(' '));
201
+ }
202
+ if (citationNode.attrs.contents) {
203
+ element.innerHTML = citationNode.attrs.contents;
204
+ }
205
+ return element;
206
+ };
207
+ nodes.cross_reference = (node) => {
208
+ const crossReferenceNode = node;
209
+ const element = this.document.createElement('a');
210
+ element.classList.add('cross-reference');
211
+ const auxiliaryObjectReference = getModel(crossReferenceNode.attrs.rid);
212
+ if (auxiliaryObjectReference &&
213
+ auxiliaryObjectReference.referencedObject) {
214
+ if (auxiliaryObjectReference.referencedObject.startsWith('MPFigureElement')) {
215
+ const model = getModel(auxiliaryObjectReference.referencedObject);
216
+ if (model && model.containedObjectIDs.length > 0) {
217
+ element.setAttribute('href', `#${model.containedObjectIDs[0]}`);
218
+ }
219
+ }
220
+ else {
221
+ element.setAttribute('href', `#${auxiliaryObjectReference.referencedObject}`);
222
+ }
223
+ element.setAttribute('data-reference-ids', crossReferenceNode.attrs.rid);
224
+ }
225
+ element.textContent = crossReferenceNode.attrs.label;
226
+ return element;
227
+ };
228
+ nodes.listing = (node) => {
229
+ const listingNode = node;
230
+ const pre = this.document.createElement('pre');
231
+ if (listingNode.attrs.id) {
232
+ pre.setAttribute('id', listingNode.attrs.id);
233
+ }
234
+ pre.classList.add('listing');
235
+ const code = this.document.createElement('code');
236
+ if (listingNode.attrs.languageKey) {
237
+ code.setAttribute('data-language', listingNode.attrs.languageKey);
238
+ }
239
+ code.textContent = listingNode.attrs.contents;
240
+ pre.appendChild(code);
241
+ return pre;
242
+ };
243
+ nodes.text = (node) => node.text;
244
+ const marks = {};
245
+ for (const [name, mark] of Object.entries(schema.marks)) {
246
+ if (mark.spec.toDOM) {
247
+ marks[name] = mark.spec.toDOM;
248
+ }
249
+ }
250
+ marks.styled = (mark) => {
251
+ const inlineStyle = getModel(mark.attrs.rid);
252
+ const attrs = {
253
+ class: buildStyledContentClass(mark.attrs, inlineStyle),
254
+ };
255
+ return ['span', attrs];
256
+ };
257
+ const serializer = new DOMSerializer(nodes, marks);
258
+ return serializer.serializeFragment(fragment, { document });
259
+ };
260
+ this.idSelector = (id) => '#' + id.replace(/:/g, '\\:');
261
+ this.fixFigure = (node) => {
262
+ const figure = this.document.querySelector(`[id="${node.attrs.id}"]`);
263
+ if (figure) {
264
+ const filename = generateAttachmentFilename(node.attrs.id, node.attrs.contentType);
265
+ const img = this.document.createElement('img');
266
+ img.setAttribute('src', filename);
267
+ figure.insertBefore(img, figure.firstChild);
268
+ }
269
+ };
270
+ this.fixBody = (fragment) => {
271
+ fragment.descendants((node) => {
272
+ if (node.attrs.id) {
273
+ const selector = this.idSelector(node.attrs.id);
274
+ const element = this.document.querySelector(`${selector}`);
275
+ if (element && this.labelTargets) {
276
+ const target = this.labelTargets.get(node.attrs.id);
277
+ if (target) {
278
+ const label = this.document.createElement('label');
279
+ label.textContent = target.label;
280
+ element.appendChild(label);
281
+ }
282
+ }
283
+ if (node.attrs.titleSuppressed) {
284
+ const title = this.document.querySelector(`${selector} > h1`);
285
+ if (title && title.parentNode) {
286
+ title.parentNode.removeChild(title);
287
+ }
288
+ }
289
+ if (node.attrs.suppressCaption) {
290
+ const caption = this.document.querySelector(`${selector} > figcaption`);
291
+ if (caption && caption.parentNode) {
292
+ caption.parentNode.removeChild(caption);
293
+ }
294
+ }
295
+ if (isNodeType(node, 'figure')) {
296
+ this.fixFigure(node);
297
+ }
298
+ if (isNodeType(node, 'figure_element')) {
299
+ const figureGroup = this.document.querySelector(`${selector}`);
300
+ if (figureGroup) {
301
+ const figures = this.document.querySelectorAll(`${selector} > figure`);
302
+ const caption = this.document.querySelector(`${selector} > figcaption`);
303
+ const listing = this.document.querySelector(`${selector} > pre.listing`);
304
+ if (listing && !listing.textContent) {
305
+ listing.remove();
306
+ }
307
+ if (figures.length === 1) {
308
+ const [figure] = figures;
309
+ figure.setAttribute('data-fig-type', 'figure');
310
+ if (caption) {
311
+ figure.insertBefore(caption, figure.firstChild);
312
+ }
313
+ const label = this.document.querySelector(`${selector} > label`);
314
+ if (label) {
315
+ figure.insertBefore(label, figure.firstChild);
316
+ }
317
+ if (figureGroup.parentElement) {
318
+ figureGroup.parentElement.replaceChild(figure, figureGroup);
319
+ }
320
+ }
321
+ if (figures.length === 0 && !caption) {
322
+ figureGroup.remove();
323
+ }
324
+ }
325
+ }
326
+ }
327
+ });
328
+ };
329
+ }
330
+ buildContributors(articleMeta) {
331
+ const contributors = Array.from(this.modelMap.values()).filter(hasObjectType(ObjectTypes.Contributor));
332
+ const affiliationIDs = [];
333
+ if (contributors && contributors.length) {
334
+ const contribGroup = this.document.createElement('div');
335
+ contribGroup.classList.add('contrib-group');
336
+ articleMeta.appendChild(contribGroup);
337
+ contributors.sort((a, b) => Number(a.priority) - Number(b.priority));
338
+ contributors.forEach((contributor) => {
339
+ const contrib = this.document.createElement('span');
340
+ contrib.classList.add('contrib');
341
+ contrib.setAttribute('id', contributor._id);
342
+ if (contributor.isCorresponding) {
343
+ contrib.setAttribute('data-corresp', 'yes');
344
+ }
345
+ const name = this.document.createElement('span');
346
+ name.classList.add('contrib-name');
347
+ contrib.appendChild(name);
348
+ const { given, family } = contributor.bibliographicName;
349
+ if (given) {
350
+ const givenNames = this.document.createElement('span');
351
+ givenNames.classList.add('contrib-given-names');
352
+ givenNames.textContent = given;
353
+ name.appendChild(givenNames);
354
+ }
355
+ if (family) {
356
+ if (given) {
357
+ const separator = document.createTextNode(' ');
358
+ name.appendChild(separator);
359
+ }
360
+ const surname = this.document.createElement('span');
361
+ surname.classList.add('contrib-surname');
362
+ surname.textContent = family;
363
+ name.appendChild(surname);
364
+ }
365
+ if (contributor.email) {
366
+ const link = this.document.createElement('a');
367
+ link.href = `mailto:${contributor.email}`;
368
+ contrib.appendChild(link);
369
+ }
370
+ if (contributor.affiliations) {
371
+ contributor.affiliations.forEach((rid) => {
372
+ const link = this.document.createElement('a');
373
+ link.setAttribute('data-ref-type', 'aff');
374
+ link.setAttribute('href', '#' + rid);
375
+ const affiliationIndex = affiliationIDs.indexOf(rid);
376
+ if (affiliationIndex > -1) {
377
+ link.textContent = String(affiliationIndex + 1);
378
+ }
379
+ else {
380
+ affiliationIDs.push(rid);
381
+ link.textContent = String(affiliationIDs.length);
382
+ }
383
+ contrib.appendChild(link);
384
+ });
385
+ }
386
+ contribGroup.appendChild(contrib);
387
+ });
388
+ }
389
+ if (affiliationIDs.length) {
390
+ const affiliationList = this.document.createElement('ol');
391
+ affiliationList.classList.add('affiliations-list');
392
+ articleMeta.appendChild(affiliationList);
393
+ for (const affiliationID of affiliationIDs) {
394
+ const affiliation = this.modelMap.get(affiliationID);
395
+ if (affiliation) {
396
+ const affiliationItem = this.document.createElement('li');
397
+ affiliationItem.classList.add('affiliation');
398
+ affiliationItem.setAttribute('id', affiliation._id);
399
+ if (affiliation.institution) {
400
+ affiliationItem.textContent = affiliation.institution;
401
+ }
402
+ affiliationList.appendChild(affiliationItem);
403
+ }
404
+ }
405
+ }
406
+ }
407
+ }
@@ -0,0 +1,23 @@
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 { v4 as uuid } from 'uuid';
17
+ import { nodeTypesMap } from './node-types';
18
+ export const generateNodeID = (type) => {
19
+ return nodeTypesMap.get(type) + ':' + uuid().toUpperCase();
20
+ };
21
+ export const generateID = (objectType) => {
22
+ return objectType + ':' + uuid().toUpperCase();
23
+ };
@@ -0,0 +1,38 @@
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
+ export * from './builders';
17
+ export * from './bundles';
18
+ export * from './decode';
19
+ export * from './document-object-types';
20
+ export * from './encode';
21
+ export * from './filename';
22
+ export * from './highlight-markers';
23
+ export * from './html';
24
+ export * from './id';
25
+ export * from './labels';
26
+ export * from './manuscript-dependencies';
27
+ export * from './models';
28
+ export * from './node-names';
29
+ export * from './node-title';
30
+ export * from './node-types';
31
+ export * from './object-types';
32
+ export * from './project-bundle';
33
+ export * from './section-category';
34
+ export * from './serializer';
35
+ export * from './shared-data';
36
+ export * from './tei-grobid-importer';
37
+ export * from './timestamp';
38
+ export * from './update-identifiers';
@@ -0,0 +1,81 @@
1
+ /*!
2
+ * © 2020 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 { schema } from '../schema';
17
+ import { nodeNames } from './node-names';
18
+ const labelledNodeTypes = [
19
+ schema.nodes.figure_element,
20
+ schema.nodes.table_element,
21
+ schema.nodes.equation_element,
22
+ schema.nodes.listing_element,
23
+ ];
24
+ const labelProperties = new Map([
25
+ [schema.nodes.figure_element, 'figureElementLabel'],
26
+ [schema.nodes.table_element, 'tableElementLabel'],
27
+ [schema.nodes.equation_element, 'equationElementLabel'],
28
+ [schema.nodes.listing_element, 'listingElementLabel'],
29
+ ]);
30
+ const chooseLabel = (nodeType, manuscript) => {
31
+ const labelProperty = labelProperties.get(nodeType);
32
+ if (labelProperty) {
33
+ const label = manuscript[labelProperty];
34
+ if (label) {
35
+ return label;
36
+ }
37
+ }
38
+ return nodeNames.get(nodeType);
39
+ };
40
+ export const buildTargets = (fragment, manuscript) => {
41
+ const counters = {};
42
+ for (const nodeType of labelledNodeTypes) {
43
+ counters[nodeType.name] = {
44
+ label: chooseLabel(nodeType, manuscript),
45
+ index: 0,
46
+ };
47
+ }
48
+ const buildLabel = (type) => {
49
+ const viewLabel = type;
50
+ const counter = counters[viewLabel.name];
51
+ counter.index++;
52
+ return `${counter.label} ${counter.index}`;
53
+ };
54
+ const targets = new Map();
55
+ const figures = [];
56
+ fragment.forEach((node) => {
57
+ if (node.type === node.type.schema.nodes.graphical_abstract_section) {
58
+ node.forEach((item) => {
59
+ if (item.type === node.type.schema.nodes.figure_element) {
60
+ figures.push(item.attrs.id);
61
+ }
62
+ });
63
+ }
64
+ });
65
+ fragment.descendants((node) => {
66
+ if (node.type.name in counters) {
67
+ const isInGraphicalAbstract = figures.indexOf(node.attrs.id) > -1;
68
+ if (isInGraphicalAbstract) {
69
+ return;
70
+ }
71
+ const label = buildLabel(node.type);
72
+ targets.set(node.attrs.id, {
73
+ type: node.type.name,
74
+ id: node.attrs.id,
75
+ label,
76
+ caption: node.textContent,
77
+ });
78
+ }
79
+ });
80
+ return targets;
81
+ };