@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,90 @@
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 const PAGE_BREAK_NONE = 0;
17
+ export const PAGE_BREAK_BEFORE = 1;
18
+ export const PAGE_BREAK_AFTER = 2;
19
+ export const PAGE_BREAK_BEFORE_AND_AFTER = 4;
20
+ const choosePageBreakStyle = (element) => {
21
+ const pageBreakAfter = element.classList.contains('page-break-after');
22
+ const pageBreakBefore = element.classList.contains('page-break-before');
23
+ if (pageBreakBefore && pageBreakAfter) {
24
+ return PAGE_BREAK_BEFORE_AND_AFTER;
25
+ }
26
+ if (pageBreakBefore) {
27
+ return PAGE_BREAK_BEFORE;
28
+ }
29
+ if (pageBreakAfter) {
30
+ return PAGE_BREAK_AFTER;
31
+ }
32
+ return PAGE_BREAK_NONE;
33
+ };
34
+ export const section = {
35
+ content: 'section_label? section_title (paragraph | element)* section*',
36
+ attrs: {
37
+ id: { default: '' },
38
+ category: { default: '' },
39
+ titleSuppressed: { default: false },
40
+ generatedLabel: { default: undefined },
41
+ pageBreakStyle: { default: undefined },
42
+ dataTracked: { default: null },
43
+ comments: { default: null },
44
+ },
45
+ group: 'block sections',
46
+ selectable: false,
47
+ parseDOM: [
48
+ {
49
+ tag: 'section',
50
+ getAttrs: (dom) => {
51
+ const element = dom;
52
+ return {
53
+ id: element.getAttribute('id') || '',
54
+ category: element.getAttribute('data-category') || '',
55
+ titleSuppressed: element.classList.contains('title-suppressed'),
56
+ generatedLabel: element.classList.contains('generated-label'),
57
+ pageBreakStyle: choosePageBreakStyle(element) || undefined,
58
+ };
59
+ },
60
+ },
61
+ ],
62
+ toDOM: (node) => {
63
+ const sectionNode = node;
64
+ const { id, category, titleSuppressed, generatedLabel, pageBreakStyle } = sectionNode.attrs;
65
+ const classnames = [];
66
+ if (titleSuppressed) {
67
+ classnames.push('title-suppressed');
68
+ }
69
+ if (typeof generatedLabel === 'undefined' || generatedLabel) {
70
+ classnames.push('generated-label');
71
+ }
72
+ if (pageBreakStyle === PAGE_BREAK_BEFORE ||
73
+ pageBreakStyle === PAGE_BREAK_BEFORE_AND_AFTER) {
74
+ classnames.push('page-break-before');
75
+ }
76
+ if (pageBreakStyle === PAGE_BREAK_AFTER ||
77
+ pageBreakStyle === PAGE_BREAK_BEFORE_AND_AFTER) {
78
+ classnames.push('page-break-after');
79
+ }
80
+ const attrs = { id };
81
+ if (classnames.length) {
82
+ attrs['class'] = classnames.join(' ');
83
+ }
84
+ if (category) {
85
+ attrs['data-category'] = node.attrs.category;
86
+ }
87
+ return ['section', attrs, 0];
88
+ },
89
+ };
90
+ export const isSectionNode = (node) => node.type === node.type.schema.nodes.section;
@@ -0,0 +1,26 @@
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 const sectionLabel = {
17
+ content: 'inline*',
18
+ group: 'block',
19
+ attrs: { dataTracked: { default: null } },
20
+ selectable: false,
21
+ parseDOM: [{ tag: 'label' }],
22
+ toDOM() {
23
+ return ['label', 0];
24
+ },
25
+ };
26
+ export const isSectionLabelNode = (node) => node.type === node.type.schema.nodes.section_label;
@@ -0,0 +1,44 @@
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 const sectionTitle = {
17
+ content: '(text | highlight_marker)*',
18
+ marks: 'italic superscript subscript smallcaps bold tracked_insert tracked_delete',
19
+ group: 'block',
20
+ attrs: { dataTracked: { default: null } },
21
+ selectable: false,
22
+ parseDOM: [
23
+ {
24
+ tag: 'h1',
25
+ },
26
+ {
27
+ tag: 'h2',
28
+ },
29
+ {
30
+ tag: 'h3',
31
+ },
32
+ {
33
+ tag: 'h4',
34
+ },
35
+ {
36
+ tag: 'h5',
37
+ },
38
+ {
39
+ tag: 'h6',
40
+ },
41
+ ],
42
+ toDOM: () => ['h1', 0],
43
+ };
44
+ export const isSectionTitleNode = (node) => node.type === node.type.schema.nodes.section_title;
@@ -0,0 +1,67 @@
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 const table = {
17
+ content: 'table_colgroup? table_body',
18
+ tableRole: 'table',
19
+ isolating: true,
20
+ group: 'block',
21
+ selectable: false,
22
+ attrs: {
23
+ id: { default: '' },
24
+ headerRows: { default: 1 },
25
+ footerRows: { default: 1 },
26
+ dataTracked: { default: null },
27
+ comments: { default: null },
28
+ },
29
+ parseDOM: [
30
+ {
31
+ tag: 'table',
32
+ getAttrs: (p) => {
33
+ const dom = p;
34
+ return {
35
+ id: dom.getAttribute('id'),
36
+ headerRows: dom.dataset && dom.dataset['header-rows'],
37
+ footerRows: dom.dataset && dom.dataset['footer-rows'],
38
+ };
39
+ },
40
+ },
41
+ ],
42
+ toDOM: (node) => {
43
+ const tableNode = node;
44
+ return [
45
+ 'table',
46
+ {
47
+ id: tableNode.attrs.id,
48
+ 'data-header-rows': String(node.attrs.headerRows),
49
+ 'data-footer-rows': String(node.attrs.footerRows),
50
+ },
51
+ 0,
52
+ ];
53
+ },
54
+ };
55
+ export const tableBody = {
56
+ content: 'table_row+',
57
+ group: 'block',
58
+ tableRole: 'table',
59
+ parseDOM: [
60
+ {
61
+ tag: 'tbody',
62
+ },
63
+ ],
64
+ toDOM() {
65
+ return ['tbody', 0];
66
+ },
67
+ };
@@ -0,0 +1,54 @@
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 const tableColGroup = {
17
+ content: 'table_col+',
18
+ group: 'block',
19
+ tableRole: 'colgroup',
20
+ parseDOM: [
21
+ {
22
+ tag: 'colgroup',
23
+ },
24
+ ],
25
+ toDOM() {
26
+ return ['colgroup', 0];
27
+ },
28
+ };
29
+ export const tableCol = {
30
+ attrs: {
31
+ width: { default: '' },
32
+ },
33
+ group: 'block',
34
+ tableRole: 'col',
35
+ parseDOM: [
36
+ {
37
+ tag: 'col',
38
+ getAttrs: (p) => {
39
+ const dom = p;
40
+ return {
41
+ width: dom.getAttribute('width'),
42
+ };
43
+ },
44
+ },
45
+ ],
46
+ toDOM: (node) => {
47
+ const tableColNode = node;
48
+ const attrs = {};
49
+ if (tableColNode.attrs.width) {
50
+ attrs['width'] = tableColNode.attrs.width;
51
+ }
52
+ return ['col', attrs];
53
+ },
54
+ };
@@ -0,0 +1,59 @@
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 const tableElement = {
17
+ content: '(table | placeholder) figcaption? footnotes_element? (listing | placeholder)',
18
+ attrs: {
19
+ id: { default: '' },
20
+ paragraphStyle: { default: '' },
21
+ tableStyle: { default: '' },
22
+ label: { default: '' },
23
+ suppressCaption: { default: false },
24
+ suppressTitle: { default: undefined },
25
+ suppressFooter: { default: false },
26
+ suppressHeader: { default: false },
27
+ expandListing: { default: false },
28
+ dataTracked: { default: null },
29
+ comments: { default: null },
30
+ },
31
+ selectable: false,
32
+ group: 'block element executable',
33
+ parseDOM: [
34
+ {
35
+ tag: 'figure.table',
36
+ getAttrs: (dom) => {
37
+ const element = dom;
38
+ return {
39
+ id: element.getAttribute('id'),
40
+ paragraphStyle: element.getAttribute('data-paragraph-style') || '',
41
+ tableStyle: element.getAttribute('data-table-style') || '',
42
+ };
43
+ },
44
+ },
45
+ ],
46
+ toDOM: (node) => {
47
+ const tableElementNode = node;
48
+ return [
49
+ 'figure',
50
+ {
51
+ class: 'table',
52
+ id: tableElementNode.attrs.id,
53
+ 'data-paragraph-style': tableElementNode.attrs.paragraphStyle,
54
+ 'data-table-style': tableElementNode.attrs.tableStyle,
55
+ },
56
+ 0,
57
+ ];
58
+ },
59
+ };
@@ -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 { getTableCellStyles, serializeTableCellStyles, } from '../../lib/table-cell-styles';
17
+ const getCellAttrs = (p) => {
18
+ const dom = p;
19
+ const celltype = dom.tagName.toLowerCase();
20
+ const widthAttr = dom.getAttribute('data-colwidth');
21
+ const widths = widthAttr && /^\d+(,\d+)*$/.test(widthAttr)
22
+ ? widthAttr.split(',').map((s) => Number(s))
23
+ : null;
24
+ const colspan = Number(dom.getAttribute('colspan') || 1);
25
+ const valign = dom.getAttribute('valign');
26
+ const align = dom.getAttribute('align');
27
+ const scope = dom.getAttribute('scope');
28
+ const style = dom.getAttribute('style');
29
+ return {
30
+ celltype,
31
+ colspan,
32
+ rowspan: Number(dom.getAttribute('rowspan') || 1),
33
+ colwidth: widths && widths.length === colspan ? widths : null,
34
+ placeholder: dom.getAttribute('data-placeholder-text') || '',
35
+ styles: getTableCellStyles(dom.style),
36
+ valign,
37
+ align,
38
+ scope,
39
+ style,
40
+ };
41
+ };
42
+ export const tableRow = {
43
+ content: 'table_cell+',
44
+ tableRole: 'row',
45
+ attrs: {
46
+ placeholder: { default: '' },
47
+ },
48
+ parseDOM: [
49
+ {
50
+ tag: 'tr',
51
+ priority: 80,
52
+ },
53
+ ],
54
+ toDOM: (node) => {
55
+ const tableRowNode = node;
56
+ const attrs = {};
57
+ if (tableRowNode.attrs.placeholder) {
58
+ attrs['data-placeholder-text'] = tableRowNode.attrs.placeholder;
59
+ }
60
+ return ['tr', attrs, 0];
61
+ },
62
+ };
63
+ export const tableCell = {
64
+ content: 'inline*',
65
+ attrs: {
66
+ celltype: { default: 'td' },
67
+ colspan: { default: 1 },
68
+ rowspan: { default: 1 },
69
+ colwidth: { default: null },
70
+ placeholder: { default: 'Data' },
71
+ styles: { default: {} },
72
+ valign: { default: null },
73
+ align: { default: null },
74
+ scope: { default: null },
75
+ style: { default: null },
76
+ },
77
+ tableRole: 'cell',
78
+ isolating: true,
79
+ parseDOM: [
80
+ { tag: 'td', getAttrs: getCellAttrs },
81
+ { tag: 'th', getAttrs: getCellAttrs },
82
+ ],
83
+ toDOM: (node) => {
84
+ const tableCellNode = node;
85
+ const attrs = {};
86
+ const tag = tableCellNode.attrs.celltype;
87
+ if (tableCellNode.attrs.colspan && tableCellNode.attrs.colspan !== 1) {
88
+ attrs.colspan = String(tableCellNode.attrs.colspan);
89
+ }
90
+ if (tableCellNode.attrs.rowspan && tableCellNode.attrs.rowspan !== 1) {
91
+ attrs.rowspan = String(tableCellNode.attrs.rowspan);
92
+ }
93
+ if (tableCellNode.attrs.colwidth) {
94
+ attrs['data-colwidth'] = tableCellNode.attrs.colwidth.join(',');
95
+ }
96
+ if (tableCellNode.attrs.placeholder) {
97
+ attrs['data-placeholder-text'] = tableCellNode.attrs.placeholder;
98
+ }
99
+ if (!tableCellNode.textContent) {
100
+ attrs.class = 'placeholder';
101
+ }
102
+ const styleString = serializeTableCellStyles(tableCellNode.attrs.styles);
103
+ if (styleString) {
104
+ attrs.style = styleString;
105
+ }
106
+ if (tableCellNode.attrs.valign) {
107
+ attrs.valign = tableCellNode.attrs.valign;
108
+ }
109
+ if (tableCellNode.attrs.align) {
110
+ attrs.align = tableCellNode.attrs.align;
111
+ }
112
+ if (tableCellNode.attrs.scope) {
113
+ attrs.scope = tableCellNode.attrs.scope;
114
+ }
115
+ if (tableCellNode.attrs.style) {
116
+ attrs.style = tableCellNode.attrs.style;
117
+ }
118
+ return [tag, attrs, 0];
119
+ },
120
+ };
@@ -0,0 +1,18 @@
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 const text = {
17
+ group: 'inline',
18
+ };
@@ -0,0 +1,49 @@
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 { nodeFromHTML } from '../../lib/html';
17
+ const createBodyElement = (node) => {
18
+ const dom = document.createElement('div');
19
+ dom.classList.add('manuscript-toc');
20
+ dom.id = node.attrs.id;
21
+ return dom;
22
+ };
23
+ export const tocElement = {
24
+ atom: true,
25
+ attrs: {
26
+ id: { default: '' },
27
+ contents: { default: '' },
28
+ paragraphStyle: { default: '' },
29
+ dataTracked: { default: null },
30
+ },
31
+ group: 'block element',
32
+ selectable: false,
33
+ parseDOM: [
34
+ {
35
+ tag: 'div.manuscript-toc',
36
+ getAttrs: (p) => {
37
+ const dom = p;
38
+ return {
39
+ contents: dom.innerHTML,
40
+ };
41
+ },
42
+ },
43
+ ],
44
+ toDOM: (node) => {
45
+ const tocElementNode = node;
46
+ return (nodeFromHTML(tocElementNode.attrs.contents) ||
47
+ createBodyElement(tocElementNode));
48
+ },
49
+ };
@@ -0,0 +1,42 @@
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 const tocSection = {
17
+ content: 'section_title (toc_element | placeholder_element)',
18
+ attrs: {
19
+ id: { default: '' },
20
+ dataTracked: { default: null },
21
+ },
22
+ group: 'block sections',
23
+ selectable: false,
24
+ parseDOM: [
25
+ {
26
+ tag: 'section.toc',
27
+ },
28
+ ],
29
+ toDOM: (node) => {
30
+ const tocSectioNode = node;
31
+ return [
32
+ 'section',
33
+ {
34
+ id: tocSectioNode.attrs.id,
35
+ class: 'toc',
36
+ spellcheck: 'false',
37
+ },
38
+ 0,
39
+ ];
40
+ },
41
+ };
42
+ export const isTOCSectionNode = (node) => node.type === node.type.schema.nodes.toc_section;
@@ -0,0 +1,16 @@
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 {};
@@ -0,0 +1,28 @@
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
+ const supportedCommands = [];
18
+ Object.defineProperty(document, 'queryCommandSupported', {
19
+ value: (cmd) => supportedCommands.includes(cmd),
20
+ });
21
+ Object.defineProperty(document, 'execCommand', {
22
+ value: (cmd) => supportedCommands.includes(cmd),
23
+ });
24
+ if (!window.URL.createObjectURL) {
25
+ Object.defineProperty(window.URL, 'createObjectURL', {
26
+ value: jest.fn(() => 'blob:https://localhost/' + uuid()),
27
+ });
28
+ }