@fiduswriter/document 0.1.0-alpha.3 → 0.1.0-alpha.5

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 (582) hide show
  1. package/README.md +22 -1
  2. package/dist/bibliography/common.d.ts +10 -0
  3. package/dist/bibliography/common.d.ts.map +1 -0
  4. package/dist/bibliography/common.js +86 -0
  5. package/dist/bibliography/common.js.map +1 -0
  6. package/dist/bibliography/csl_bib.d.ts +3 -0
  7. package/dist/bibliography/csl_bib.d.ts.map +1 -0
  8. package/dist/bibliography/csl_bib.js +131 -0
  9. package/dist/bibliography/csl_bib.js.map +1 -0
  10. package/dist/citations/citeproc_sys.d.ts +12 -0
  11. package/dist/citations/citeproc_sys.d.ts.map +1 -0
  12. package/dist/citations/citeproc_sys.js +48 -0
  13. package/dist/citations/citeproc_sys.js.map +1 -0
  14. package/dist/citations/format.d.ts +40 -0
  15. package/dist/citations/format.d.ts.map +1 -0
  16. package/dist/citations/format.js +186 -0
  17. package/dist/citations/format.js.map +1 -0
  18. package/dist/editor/e2ee/encryptor.d.ts +123 -0
  19. package/dist/editor/e2ee/encryptor.d.ts.map +1 -0
  20. package/dist/editor/e2ee/encryptor.js +201 -0
  21. package/dist/editor/e2ee/encryptor.js.map +1 -0
  22. package/dist/exporter/docx/citations.d.ts +31 -0
  23. package/dist/exporter/docx/citations.d.ts.map +1 -0
  24. package/dist/exporter/docx/citations.js +171 -0
  25. package/dist/exporter/docx/citations.js.map +1 -0
  26. package/dist/exporter/docx/comments.d.ts +22 -0
  27. package/dist/exporter/docx/comments.d.ts.map +1 -0
  28. package/dist/exporter/docx/comments.js +170 -0
  29. package/dist/exporter/docx/comments.js.map +1 -0
  30. package/dist/exporter/docx/footnotes.d.ts +47 -0
  31. package/dist/exporter/docx/footnotes.d.ts.map +1 -0
  32. package/dist/exporter/docx/footnotes.js +216 -0
  33. package/dist/exporter/docx/footnotes.js.map +1 -0
  34. package/dist/exporter/docx/images.d.ts +25 -0
  35. package/dist/exporter/docx/images.d.ts.map +1 -0
  36. package/dist/exporter/docx/images.js +101 -0
  37. package/dist/exporter/docx/images.js.map +1 -0
  38. package/dist/exporter/docx/index.d.ts +16 -0
  39. package/dist/exporter/docx/index.d.ts.map +1 -0
  40. package/dist/exporter/docx/index.js +115 -0
  41. package/dist/exporter/docx/index.js.map +1 -0
  42. package/dist/exporter/docx/lists.d.ts +38 -0
  43. package/dist/exporter/docx/lists.d.ts.map +1 -0
  44. package/dist/exporter/docx/lists.js +276 -0
  45. package/dist/exporter/docx/lists.js.map +1 -0
  46. package/dist/exporter/docx/math.d.ts +13 -0
  47. package/dist/exporter/docx/math.d.ts.map +1 -0
  48. package/dist/exporter/docx/math.js +59 -0
  49. package/dist/exporter/docx/math.js.map +1 -0
  50. package/dist/exporter/docx/metadata.d.ts +17 -0
  51. package/dist/exporter/docx/metadata.d.ts.map +1 -0
  52. package/dist/exporter/docx/metadata.js +272 -0
  53. package/dist/exporter/docx/metadata.js.map +1 -0
  54. package/dist/exporter/docx/rels.d.ts +27 -0
  55. package/dist/exporter/docx/rels.d.ts.map +1 -0
  56. package/dist/exporter/docx/rels.js +183 -0
  57. package/dist/exporter/docx/rels.js.map +1 -0
  58. package/dist/exporter/docx/render.d.ts +22 -0
  59. package/dist/exporter/docx/render.d.ts.map +1 -0
  60. package/dist/exporter/docx/render.js +780 -0
  61. package/dist/exporter/docx/render.js.map +1 -0
  62. package/dist/exporter/docx/richtext.d.ts +25 -0
  63. package/dist/exporter/docx/richtext.d.ts.map +1 -0
  64. package/dist/exporter/docx/richtext.js +1070 -0
  65. package/dist/exporter/docx/richtext.js.map +1 -0
  66. package/dist/exporter/docx/tables.d.ts +16 -0
  67. package/dist/exporter/docx/tables.d.ts.map +1 -0
  68. package/dist/exporter/docx/tables.js +115 -0
  69. package/dist/exporter/docx/tables.js.map +1 -0
  70. package/dist/exporter/docx/tools.d.ts +4 -0
  71. package/dist/exporter/docx/tools.d.ts.map +1 -0
  72. package/dist/exporter/docx/tools.js +48 -0
  73. package/dist/exporter/docx/tools.js.map +1 -0
  74. package/dist/exporter/epub/index.d.ts +19 -0
  75. package/dist/exporter/epub/index.d.ts.map +1 -0
  76. package/dist/exporter/epub/index.js +109 -0
  77. package/dist/exporter/epub/index.js.map +1 -0
  78. package/dist/exporter/epub/templates.d.ts +63 -0
  79. package/dist/exporter/epub/templates.d.ts.map +1 -0
  80. package/dist/exporter/epub/templates.js +95 -0
  81. package/dist/exporter/epub/templates.js.map +1 -0
  82. package/dist/exporter/epub/tools.d.ts +13 -0
  83. package/dist/exporter/epub/tools.d.ts.map +1 -0
  84. package/{src → dist}/exporter/epub/tools.js +32 -46
  85. package/dist/exporter/epub/tools.js.map +1 -0
  86. package/dist/exporter/html/citations.d.ts +29 -0
  87. package/dist/exporter/html/citations.d.ts.map +1 -0
  88. package/dist/exporter/html/citations.js +110 -0
  89. package/dist/exporter/html/citations.js.map +1 -0
  90. package/dist/exporter/html/convert.d.ts +50 -0
  91. package/dist/exporter/html/convert.d.ts.map +1 -0
  92. package/dist/exporter/html/convert.js +750 -0
  93. package/dist/exporter/html/convert.js.map +1 -0
  94. package/dist/exporter/html/index.d.ts +64 -0
  95. package/dist/exporter/html/index.d.ts.map +1 -0
  96. package/dist/exporter/html/index.js +154 -0
  97. package/dist/exporter/html/index.js.map +1 -0
  98. package/dist/exporter/html/templates.d.ts +24 -0
  99. package/dist/exporter/html/templates.d.ts.map +1 -0
  100. package/dist/exporter/html/templates.js +21 -0
  101. package/dist/exporter/html/templates.js.map +1 -0
  102. package/dist/exporter/html/tools.d.ts +2 -0
  103. package/dist/exporter/html/tools.d.ts.map +1 -0
  104. package/dist/exporter/html/tools.js +49 -0
  105. package/dist/exporter/html/tools.js.map +1 -0
  106. package/dist/exporter/jats/bibliography.d.ts +3 -0
  107. package/dist/exporter/jats/bibliography.d.ts.map +1 -0
  108. package/dist/exporter/jats/bibliography.js +158 -0
  109. package/dist/exporter/jats/bibliography.js.map +1 -0
  110. package/dist/exporter/jats/citations.d.ts +16 -0
  111. package/dist/exporter/jats/citations.d.ts.map +1 -0
  112. package/dist/exporter/jats/citations.js +105 -0
  113. package/dist/exporter/jats/citations.js.map +1 -0
  114. package/dist/exporter/jats/convert.d.ts +41 -0
  115. package/dist/exporter/jats/convert.d.ts.map +1 -0
  116. package/dist/exporter/jats/convert.js +816 -0
  117. package/dist/exporter/jats/convert.js.map +1 -0
  118. package/dist/exporter/jats/index.d.ts +25 -0
  119. package/dist/exporter/jats/index.d.ts.map +1 -0
  120. package/dist/exporter/jats/index.js +82 -0
  121. package/dist/exporter/jats/index.js.map +1 -0
  122. package/dist/exporter/jats/templates.d.ts +18 -0
  123. package/dist/exporter/jats/templates.d.ts.map +1 -0
  124. package/dist/exporter/jats/templates.js +25 -0
  125. package/dist/exporter/jats/templates.js.map +1 -0
  126. package/dist/exporter/jats/text.d.ts +4 -0
  127. package/dist/exporter/jats/text.d.ts.map +1 -0
  128. package/dist/exporter/jats/text.js +72 -0
  129. package/dist/exporter/jats/text.js.map +1 -0
  130. package/dist/exporter/latex/convert.d.ts +24 -0
  131. package/dist/exporter/latex/convert.d.ts.map +1 -0
  132. package/dist/exporter/latex/convert.js +881 -0
  133. package/dist/exporter/latex/convert.js.map +1 -0
  134. package/dist/exporter/latex/escape_latex.d.ts +2 -0
  135. package/dist/exporter/latex/escape_latex.d.ts.map +1 -0
  136. package/dist/exporter/latex/escape_latex.js +20 -0
  137. package/dist/exporter/latex/escape_latex.js.map +1 -0
  138. package/dist/exporter/latex/index.d.ts +24 -0
  139. package/dist/exporter/latex/index.d.ts.map +1 -0
  140. package/dist/exporter/latex/index.js +67 -0
  141. package/dist/exporter/latex/index.js.map +1 -0
  142. package/dist/exporter/latex/readme.d.ts +2 -0
  143. package/dist/exporter/latex/readme.d.ts.map +1 -0
  144. package/dist/exporter/latex/readme.js +23 -0
  145. package/dist/exporter/latex/readme.js.map +1 -0
  146. package/dist/exporter/native/copy.d.ts +30 -0
  147. package/dist/exporter/native/copy.d.ts.map +1 -0
  148. package/dist/exporter/native/copy.js +151 -0
  149. package/dist/exporter/native/copy.js.map +1 -0
  150. package/dist/exporter/native/file.d.ts +12 -0
  151. package/dist/exporter/native/file.d.ts.map +1 -0
  152. package/dist/exporter/native/file.js +38 -0
  153. package/dist/exporter/native/file.js.map +1 -0
  154. package/dist/exporter/native/index.d.ts +5 -0
  155. package/dist/exporter/native/index.d.ts.map +1 -0
  156. package/dist/exporter/native/index.js +5 -0
  157. package/dist/exporter/native/index.js.map +1 -0
  158. package/dist/exporter/native/revision.d.ts +18 -0
  159. package/dist/exporter/native/revision.d.ts.map +1 -0
  160. package/dist/exporter/native/revision.js +39 -0
  161. package/dist/exporter/native/revision.js.map +1 -0
  162. package/dist/exporter/native/shrink.d.ts +36 -0
  163. package/dist/exporter/native/shrink.d.ts.map +1 -0
  164. package/dist/exporter/native/shrink.js +124 -0
  165. package/dist/exporter/native/shrink.js.map +1 -0
  166. package/dist/exporter/native/zip.d.ts +25 -0
  167. package/dist/exporter/native/zip.d.ts.map +1 -0
  168. package/dist/exporter/native/zip.js +56 -0
  169. package/dist/exporter/native/zip.js.map +1 -0
  170. package/dist/exporter/odt/citations.d.ts +21 -0
  171. package/dist/exporter/odt/citations.d.ts.map +1 -0
  172. package/dist/exporter/odt/citations.js +104 -0
  173. package/dist/exporter/odt/citations.js.map +1 -0
  174. package/dist/exporter/odt/footnotes.d.ts +31 -0
  175. package/dist/exporter/odt/footnotes.d.ts.map +1 -0
  176. package/dist/exporter/odt/footnotes.js +129 -0
  177. package/dist/exporter/odt/footnotes.js.map +1 -0
  178. package/dist/exporter/odt/images.d.ts +25 -0
  179. package/dist/exporter/odt/images.d.ts.map +1 -0
  180. package/dist/exporter/odt/images.js +106 -0
  181. package/dist/exporter/odt/images.js.map +1 -0
  182. package/dist/exporter/odt/index.d.ts +17 -0
  183. package/dist/exporter/odt/index.d.ts.map +1 -0
  184. package/dist/exporter/odt/index.js +108 -0
  185. package/dist/exporter/odt/index.js.map +1 -0
  186. package/dist/exporter/odt/math.d.ts +15 -0
  187. package/dist/exporter/odt/math.d.ts.map +1 -0
  188. package/dist/exporter/odt/math.js +71 -0
  189. package/dist/exporter/odt/math.js.map +1 -0
  190. package/dist/exporter/odt/metadata.d.ts +18 -0
  191. package/dist/exporter/odt/metadata.d.ts.map +1 -0
  192. package/dist/exporter/odt/metadata.js +224 -0
  193. package/dist/exporter/odt/metadata.js.map +1 -0
  194. package/dist/exporter/odt/render.d.ts +26 -0
  195. package/dist/exporter/odt/render.d.ts.map +1 -0
  196. package/dist/exporter/odt/render.js +651 -0
  197. package/dist/exporter/odt/render.js.map +1 -0
  198. package/dist/exporter/odt/richtext.d.ts +22 -0
  199. package/dist/exporter/odt/richtext.d.ts.map +1 -0
  200. package/dist/exporter/odt/richtext.js +743 -0
  201. package/dist/exporter/odt/richtext.js.map +1 -0
  202. package/dist/exporter/odt/styles.d.ts +41 -0
  203. package/dist/exporter/odt/styles.d.ts.map +1 -0
  204. package/dist/exporter/odt/styles.js +370 -0
  205. package/dist/exporter/odt/styles.js.map +1 -0
  206. package/dist/exporter/odt/track.d.ts +18 -0
  207. package/dist/exporter/odt/track.d.ts.map +1 -0
  208. package/dist/exporter/odt/track.js +66 -0
  209. package/dist/exporter/odt/track.js.map +1 -0
  210. package/dist/exporter/pandoc/citations.d.ts +23 -0
  211. package/dist/exporter/pandoc/citations.d.ts.map +1 -0
  212. package/dist/exporter/pandoc/citations.js +99 -0
  213. package/dist/exporter/pandoc/citations.js.map +1 -0
  214. package/dist/exporter/pandoc/convert.d.ts +19 -0
  215. package/dist/exporter/pandoc/convert.d.ts.map +1 -0
  216. package/dist/exporter/pandoc/convert.js +886 -0
  217. package/dist/exporter/pandoc/convert.js.map +1 -0
  218. package/dist/exporter/pandoc/index.d.ts +25 -0
  219. package/dist/exporter/pandoc/index.d.ts.map +1 -0
  220. package/dist/exporter/pandoc/index.js +79 -0
  221. package/dist/exporter/pandoc/index.js.map +1 -0
  222. package/dist/exporter/pandoc/readme.d.ts +2 -0
  223. package/dist/exporter/pandoc/readme.d.ts.map +1 -0
  224. package/dist/exporter/pandoc/readme.js +8 -0
  225. package/dist/exporter/pandoc/readme.js.map +1 -0
  226. package/dist/exporter/pandoc/tools.d.ts +22 -0
  227. package/dist/exporter/pandoc/tools.d.ts.map +1 -0
  228. package/dist/exporter/pandoc/tools.js +52 -0
  229. package/dist/exporter/pandoc/tools.js.map +1 -0
  230. package/dist/exporter/print/index.d.ts +20 -0
  231. package/dist/exporter/print/index.d.ts.map +1 -0
  232. package/dist/exporter/print/index.js +142 -0
  233. package/dist/exporter/print/index.js.map +1 -0
  234. package/dist/exporter/tools/doc_content.d.ts +6 -0
  235. package/dist/exporter/tools/doc_content.d.ts.map +1 -0
  236. package/dist/exporter/tools/doc_content.js +130 -0
  237. package/dist/exporter/tools/doc_content.js.map +1 -0
  238. package/dist/exporter/tools/file.d.ts +2 -0
  239. package/dist/exporter/tools/file.d.ts.map +1 -0
  240. package/dist/exporter/tools/file.js +10 -0
  241. package/dist/exporter/tools/file.js.map +1 -0
  242. package/dist/exporter/tools/json.d.ts +7 -0
  243. package/dist/exporter/tools/json.d.ts.map +1 -0
  244. package/dist/exporter/tools/json.js +82 -0
  245. package/dist/exporter/tools/json.js.map +1 -0
  246. package/dist/exporter/tools/svg.d.ts +8 -0
  247. package/dist/exporter/tools/svg.d.ts.map +1 -0
  248. package/dist/exporter/tools/svg.js +26 -0
  249. package/dist/exporter/tools/svg.js.map +1 -0
  250. package/dist/exporter/tools/xml.d.ts +42 -0
  251. package/dist/exporter/tools/xml.d.ts.map +1 -0
  252. package/dist/exporter/tools/xml.js +467 -0
  253. package/dist/exporter/tools/xml.js.map +1 -0
  254. package/dist/exporter/tools/xml_zip.d.ts +21 -0
  255. package/dist/exporter/tools/xml_zip.d.ts.map +1 -0
  256. package/dist/exporter/tools/xml_zip.js +92 -0
  257. package/dist/exporter/tools/xml_zip.js.map +1 -0
  258. package/dist/exporter/tools/zip.d.ts +35 -0
  259. package/dist/exporter/tools/zip.d.ts.map +1 -0
  260. package/dist/exporter/tools/zip.js +78 -0
  261. package/dist/exporter/tools/zip.js.map +1 -0
  262. package/dist/exporter/tools/zotero_csl.d.ts +23 -0
  263. package/dist/exporter/tools/zotero_csl.d.ts.map +1 -0
  264. package/dist/exporter/tools/zotero_csl.js +78 -0
  265. package/dist/exporter/tools/zotero_csl.js.map +1 -0
  266. package/dist/importer/citations.d.ts +28 -0
  267. package/dist/importer/citations.d.ts.map +1 -0
  268. package/dist/importer/citations.js +68 -0
  269. package/dist/importer/citations.js.map +1 -0
  270. package/dist/importer/docx/citations.d.ts +43 -0
  271. package/dist/importer/docx/citations.d.ts.map +1 -0
  272. package/dist/importer/docx/citations.js +81 -0
  273. package/dist/importer/docx/citations.js.map +1 -0
  274. package/dist/importer/docx/convert.d.ts +150 -0
  275. package/dist/importer/docx/convert.d.ts.map +1 -0
  276. package/dist/importer/docx/convert.js +1243 -0
  277. package/dist/importer/docx/convert.js.map +1 -0
  278. package/dist/importer/docx/helpers.d.ts +2 -0
  279. package/dist/importer/docx/helpers.d.ts.map +1 -0
  280. package/dist/importer/docx/helpers.js +10 -0
  281. package/dist/importer/docx/helpers.js.map +1 -0
  282. package/dist/importer/docx/index.d.ts +27 -0
  283. package/dist/importer/docx/index.d.ts.map +1 -0
  284. package/dist/importer/docx/index.js +77 -0
  285. package/dist/importer/docx/index.js.map +1 -0
  286. package/dist/importer/docx/omml2mathml.d.ts +6 -0
  287. package/dist/importer/docx/omml2mathml.d.ts.map +1 -0
  288. package/dist/importer/docx/omml2mathml.js +1146 -0
  289. package/dist/importer/docx/omml2mathml.js.map +1 -0
  290. package/dist/importer/docx/parse.d.ts +96 -0
  291. package/dist/importer/docx/parse.d.ts.map +1 -0
  292. package/dist/importer/docx/parse.js +681 -0
  293. package/dist/importer/docx/parse.js.map +1 -0
  294. package/dist/importer/native/extract_template.d.ts +6 -0
  295. package/dist/importer/native/extract_template.d.ts.map +1 -0
  296. package/dist/importer/native/extract_template.js +80 -0
  297. package/dist/importer/native/extract_template.js.map +1 -0
  298. package/dist/importer/native/file.d.ts +37 -0
  299. package/dist/importer/native/file.d.ts.map +1 -0
  300. package/dist/importer/native/file.js +162 -0
  301. package/dist/importer/native/file.js.map +1 -0
  302. package/dist/importer/native/get_images.d.ts +21 -0
  303. package/dist/importer/native/get_images.d.ts.map +1 -0
  304. package/dist/importer/native/get_images.js +58 -0
  305. package/dist/importer/native/get_images.js.map +1 -0
  306. package/dist/importer/native/importer.d.ts +41 -0
  307. package/dist/importer/native/importer.d.ts.map +1 -0
  308. package/dist/importer/native/importer.js +170 -0
  309. package/dist/importer/native/importer.js.map +1 -0
  310. package/dist/importer/native/index.d.ts +7 -0
  311. package/dist/importer/native/index.d.ts.map +1 -0
  312. package/dist/importer/native/index.js +7 -0
  313. package/dist/importer/native/index.js.map +1 -0
  314. package/dist/importer/native/update.d.ts +7 -0
  315. package/dist/importer/native/update.d.ts.map +1 -0
  316. package/dist/importer/native/update.js +27 -0
  317. package/dist/importer/native/update.js.map +1 -0
  318. package/dist/importer/native/update_template.d.ts +12 -0
  319. package/dist/importer/native/update_template.d.ts.map +1 -0
  320. package/dist/importer/native/update_template.js +19 -0
  321. package/dist/importer/native/update_template.js.map +1 -0
  322. package/dist/importer/odt/citations.d.ts +27 -0
  323. package/dist/importer/odt/citations.d.ts.map +1 -0
  324. package/dist/importer/odt/citations.js +57 -0
  325. package/dist/importer/odt/citations.js.map +1 -0
  326. package/dist/importer/odt/convert.d.ts +146 -0
  327. package/dist/importer/odt/convert.d.ts.map +1 -0
  328. package/dist/importer/odt/convert.js +1530 -0
  329. package/dist/importer/odt/convert.js.map +1 -0
  330. package/dist/importer/odt/index.d.ts +30 -0
  331. package/dist/importer/odt/index.d.ts.map +1 -0
  332. package/dist/importer/odt/index.js +124 -0
  333. package/dist/importer/odt/index.js.map +1 -0
  334. package/dist/importer/pandoc/convert.d.ts +32 -0
  335. package/dist/importer/pandoc/convert.d.ts.map +1 -0
  336. package/dist/importer/pandoc/convert.js +790 -0
  337. package/dist/importer/pandoc/convert.js.map +1 -0
  338. package/dist/importer/pandoc/helpers.d.ts +5 -0
  339. package/dist/importer/pandoc/helpers.d.ts.map +1 -0
  340. package/dist/importer/pandoc/helpers.js +73 -0
  341. package/dist/importer/pandoc/helpers.js.map +1 -0
  342. package/dist/importer/pandoc/index.d.ts +31 -0
  343. package/dist/importer/pandoc/index.d.ts.map +1 -0
  344. package/dist/importer/pandoc/index.js +114 -0
  345. package/dist/importer/pandoc/index.js.map +1 -0
  346. package/dist/importer/registry.d.ts +21 -0
  347. package/dist/importer/registry.d.ts.map +1 -0
  348. package/dist/importer/registry.js +41 -0
  349. package/dist/importer/registry.js.map +1 -0
  350. package/dist/importer/zip_analyzer.d.ts +31 -0
  351. package/dist/importer/zip_analyzer.d.ts.map +1 -0
  352. package/dist/importer/zip_analyzer.js +89 -0
  353. package/dist/importer/zip_analyzer.js.map +1 -0
  354. package/dist/index.d.ts +2 -0
  355. package/dist/index.d.ts.map +1 -0
  356. package/dist/index.js +2 -0
  357. package/dist/index.js.map +1 -0
  358. package/dist/mathlive/opf_includes.d.ts +2 -0
  359. package/dist/mathlive/opf_includes.d.ts.map +1 -0
  360. package/dist/mathlive/opf_includes.js +25 -0
  361. package/dist/mathlive/opf_includes.js.map +1 -0
  362. package/dist/schema/common/annotate.d.ts +47 -0
  363. package/dist/schema/common/annotate.d.ts.map +1 -0
  364. package/dist/schema/common/annotate.js +75 -0
  365. package/dist/schema/common/annotate.js.map +1 -0
  366. package/dist/schema/common/base.d.ts +91 -0
  367. package/dist/schema/common/base.d.ts.map +1 -0
  368. package/dist/schema/common/base.js +109 -0
  369. package/dist/schema/common/base.js.map +1 -0
  370. package/dist/schema/common/citation.d.ts +30 -0
  371. package/dist/schema/common/citation.d.ts.map +1 -0
  372. package/dist/schema/common/citation.js +61 -0
  373. package/dist/schema/common/citation.js.map +1 -0
  374. package/dist/schema/common/equation.d.ts +17 -0
  375. package/dist/schema/common/equation.d.ts.map +1 -0
  376. package/dist/schema/common/equation.js +32 -0
  377. package/dist/schema/common/equation.js.map +1 -0
  378. package/dist/schema/common/figure.d.ts +87 -0
  379. package/dist/schema/common/figure.d.ts.map +1 -0
  380. package/dist/schema/common/figure.js +178 -0
  381. package/dist/schema/common/figure.js.map +1 -0
  382. package/dist/schema/common/heading.d.ts +9 -0
  383. package/dist/schema/common/heading.d.ts.map +1 -0
  384. package/dist/schema/common/heading.js +41 -0
  385. package/dist/schema/common/heading.js.map +1 -0
  386. package/dist/schema/common/index.d.ts +11 -0
  387. package/dist/schema/common/index.d.ts.map +1 -0
  388. package/dist/schema/common/index.js +11 -0
  389. package/dist/schema/common/index.js.map +1 -0
  390. package/dist/schema/common/list.d.ts +63 -0
  391. package/dist/schema/common/list.d.ts.map +1 -0
  392. package/dist/schema/common/list.js +92 -0
  393. package/dist/schema/common/list.js.map +1 -0
  394. package/dist/schema/common/reference.d.ts +70 -0
  395. package/dist/schema/common/reference.d.ts.map +1 -0
  396. package/dist/schema/common/reference.js +97 -0
  397. package/dist/schema/common/reference.js.map +1 -0
  398. package/dist/schema/common/table.d.ts +76 -0
  399. package/dist/schema/common/table.d.ts.map +1 -0
  400. package/dist/schema/common/table.js +86 -0
  401. package/dist/schema/common/table.js.map +1 -0
  402. package/dist/schema/common/track.d.ts +117 -0
  403. package/dist/schema/common/track.d.ts.map +1 -0
  404. package/{src → dist}/schema/common/track.js +44 -49
  405. package/dist/schema/common/track.js.map +1 -0
  406. package/dist/schema/const.d.ts +3 -0
  407. package/dist/schema/const.d.ts.map +1 -0
  408. package/{src → dist}/schema/const.js +3 -3
  409. package/dist/schema/const.js.map +1 -0
  410. package/dist/schema/convert.d.ts +3 -0
  411. package/dist/schema/convert.d.ts.map +1 -0
  412. package/dist/schema/convert.js +1215 -0
  413. package/dist/schema/convert.js.map +1 -0
  414. package/dist/schema/document/content.d.ts +110 -0
  415. package/dist/schema/document/content.d.ts.map +1 -0
  416. package/dist/schema/document/content.js +177 -0
  417. package/dist/schema/document/content.js.map +1 -0
  418. package/dist/schema/document/index.d.ts +795 -0
  419. package/dist/schema/document/index.d.ts.map +1 -0
  420. package/dist/schema/document/index.js +68 -0
  421. package/dist/schema/document/index.js.map +1 -0
  422. package/dist/schema/document/structure.d.ts +164 -0
  423. package/dist/schema/document/structure.d.ts.map +1 -0
  424. package/dist/schema/document/structure.js +445 -0
  425. package/dist/schema/document/structure.js.map +1 -0
  426. package/dist/schema/export.d.ts +7 -0
  427. package/dist/schema/export.d.ts.map +1 -0
  428. package/dist/schema/export.js +17 -0
  429. package/dist/schema/export.js.map +1 -0
  430. package/dist/schema/footnotes.d.ts +454 -0
  431. package/dist/schema/footnotes.d.ts.map +1 -0
  432. package/dist/schema/footnotes.js +90 -0
  433. package/dist/schema/footnotes.js.map +1 -0
  434. package/dist/schema/footnotes_convert.d.ts +5 -0
  435. package/dist/schema/footnotes_convert.d.ts.map +1 -0
  436. package/dist/schema/footnotes_convert.js +30 -0
  437. package/dist/schema/footnotes_convert.js.map +1 -0
  438. package/dist/schema/i18n.d.ts +55 -0
  439. package/dist/schema/i18n.d.ts.map +1 -0
  440. package/{src → dist}/schema/i18n.js +14 -23
  441. package/dist/schema/i18n.js.map +1 -0
  442. package/dist/schema/index.d.ts +6 -0
  443. package/dist/schema/index.d.ts.map +1 -0
  444. package/dist/schema/index.js +6 -0
  445. package/dist/schema/index.js.map +1 -0
  446. package/dist/schema/mini_json.d.ts +4 -0
  447. package/dist/schema/mini_json.d.ts.map +1 -0
  448. package/{src → dist}/schema/mini_json.js +19 -28
  449. package/dist/schema/mini_json.js.map +1 -0
  450. package/dist/schema/text.d.ts +3 -0
  451. package/dist/schema/text.d.ts.map +1 -0
  452. package/dist/schema/text.js +23 -0
  453. package/dist/schema/text.js.map +1 -0
  454. package/dist/types.d.ts +281 -0
  455. package/dist/types.d.ts.map +1 -0
  456. package/dist/types.js +9 -0
  457. package/dist/types.js.map +1 -0
  458. package/package.json +51 -16
  459. package/scripts/export-schema.js +1 -1
  460. package/src/bibliography/{common.js → common.ts} +15 -12
  461. package/src/bibliography/{csl_bib.js → csl_bib.ts} +16 -15
  462. package/src/citations/{citeproc_sys.js → citeproc_sys.ts} +26 -6
  463. package/src/citations/{format.js → format.ts} +80 -24
  464. package/src/editor/e2ee/{encryptor.js → encryptor.ts} +76 -44
  465. package/src/exporter/docx/{citations.js → citations.ts} +51 -23
  466. package/src/exporter/docx/{comments.js → comments.ts} +69 -26
  467. package/src/exporter/docx/{footnotes.js → footnotes.ts} +81 -42
  468. package/src/exporter/docx/images.ts +128 -0
  469. package/src/exporter/docx/{index.js → index.ts} +48 -25
  470. package/src/exporter/docx/{lists.js → lists.ts} +89 -46
  471. package/src/exporter/docx/{math.js → math.ts} +29 -9
  472. package/src/exporter/docx/{metadata.js → metadata.ts} +78 -42
  473. package/src/exporter/docx/{rels.js → rels.ts} +71 -50
  474. package/src/exporter/docx/{render.js → render.ts} +124 -87
  475. package/src/exporter/docx/{richtext.js → richtext.ts} +107 -84
  476. package/src/exporter/docx/{tables.js → tables.ts} +33 -23
  477. package/src/exporter/docx/{tools.js → tools.ts} +4 -3
  478. package/src/exporter/epub/{index.js → index.ts} +44 -15
  479. package/src/exporter/epub/{templates.js → templates.ts} +71 -7
  480. package/src/exporter/epub/tools.ts +102 -0
  481. package/src/exporter/html/{citations.js → citations.ts} +79 -31
  482. package/src/exporter/html/{convert.js → convert.ts} +118 -71
  483. package/src/exporter/html/{index.js → index.ts} +63 -29
  484. package/src/exporter/html/{templates.js → templates.ts} +22 -2
  485. package/src/exporter/html/{tools.js → tools.ts} +9 -6
  486. package/src/exporter/jats/bibliography.ts +199 -0
  487. package/src/exporter/jats/{citations.js → citations.ts} +56 -20
  488. package/src/exporter/jats/{convert.js → convert.ts} +72 -53
  489. package/src/exporter/jats/index.ts +132 -0
  490. package/src/exporter/jats/{templates.js → templates.ts} +19 -3
  491. package/src/exporter/jats/{text.js → text.ts} +8 -6
  492. package/src/exporter/latex/{convert.js → convert.ts} +160 -125
  493. package/src/exporter/latex/{escape_latex.js → escape_latex.ts} +1 -1
  494. package/src/exporter/latex/{index.js → index.ts} +27 -12
  495. package/src/exporter/latex/{readme.js → readme.ts} +2 -2
  496. package/src/exporter/native/copy.ts +231 -0
  497. package/src/exporter/native/file.ts +65 -0
  498. package/src/exporter/native/index.ts +4 -0
  499. package/src/exporter/native/revision.ts +76 -0
  500. package/src/exporter/native/{shrink.js → shrink.ts} +64 -29
  501. package/src/exporter/native/zip.ts +85 -0
  502. package/src/exporter/odt/{citations.js → citations.ts} +35 -15
  503. package/src/exporter/odt/{footnotes.js → footnotes.ts} +53 -30
  504. package/src/exporter/odt/images.ts +135 -0
  505. package/src/exporter/odt/{index.js → index.ts} +49 -27
  506. package/src/exporter/odt/{math.js → math.ts} +38 -9
  507. package/src/exporter/odt/{metadata.js → metadata.ts} +54 -29
  508. package/src/exporter/odt/{render.js → render.ts} +89 -60
  509. package/src/exporter/odt/{richtext.js → richtext.ts} +102 -72
  510. package/src/exporter/odt/{styles.js → styles.ts} +98 -66
  511. package/src/exporter/odt/{track.js → track.ts} +22 -6
  512. package/src/exporter/pandoc/{citations.js → citations.ts} +31 -15
  513. package/src/exporter/pandoc/{convert.js → convert.ts} +98 -79
  514. package/src/exporter/pandoc/{index.js → index.ts} +36 -13
  515. package/src/exporter/pandoc/{readme.js → readme.ts} +0 -1
  516. package/src/exporter/pandoc/{tools.js → tools.ts} +28 -5
  517. package/src/exporter/print/{index.js → index.ts} +38 -19
  518. package/src/exporter/tools/{doc_content.js → doc_content.ts} +34 -24
  519. package/src/exporter/tools/{file.js → file.ts} +1 -1
  520. package/src/exporter/tools/{json.js → json.ts} +30 -19
  521. package/src/exporter/tools/{svg.js → svg.ts} +9 -3
  522. package/src/exporter/tools/{xml.js → xml.ts} +187 -138
  523. package/src/exporter/tools/{xml_zip.js → xml_zip.ts} +19 -11
  524. package/src/exporter/tools/{zip.js → zip.ts} +35 -11
  525. package/src/exporter/tools/{zotero_csl.js → zotero_csl.ts} +35 -18
  526. package/src/global.d.ts +13 -0
  527. package/src/importer/citations.ts +116 -0
  528. package/src/importer/docx/{citations.js → citations.ts} +22 -37
  529. package/src/importer/docx/{convert.js → convert.ts} +176 -141
  530. package/src/importer/docx/{helpers.js → helpers.ts} +1 -1
  531. package/src/importer/docx/index.ts +124 -0
  532. package/src/importer/docx/{omml2mathml.js → omml2mathml.ts} +154 -176
  533. package/src/importer/docx/{parse.js → parse.ts} +103 -81
  534. package/src/importer/native/extract_template.ts +83 -0
  535. package/src/importer/native/file.ts +282 -0
  536. package/src/importer/native/get_images.ts +82 -0
  537. package/src/importer/native/importer.ts +244 -0
  538. package/src/importer/native/index.ts +6 -0
  539. package/src/importer/native/{update.js → update.ts} +13 -5
  540. package/src/importer/native/update_template.ts +32 -0
  541. package/src/importer/odt/{citations.js → citations.ts} +17 -29
  542. package/src/importer/odt/{convert.js → convert.ts} +261 -237
  543. package/src/importer/odt/index.ts +202 -0
  544. package/src/importer/pandoc/{convert.js → convert.ts} +116 -94
  545. package/src/importer/pandoc/{helpers.js → helpers.ts} +24 -12
  546. package/src/importer/pandoc/index.ts +171 -0
  547. package/src/importer/registry.ts +69 -0
  548. package/src/importer/{zip_analyzer.js → zip_analyzer.ts} +44 -18
  549. package/src/mathlive/{opf_includes.js → opf_includes.ts} +1 -1
  550. package/src/modules.d.ts +40 -0
  551. package/src/schema/common/{annotate.js → annotate.ts} +10 -8
  552. package/src/schema/common/{base.js → base.ts} +12 -10
  553. package/src/schema/common/{citation.js → citation.ts} +17 -8
  554. package/src/schema/common/{equation.js → equation.ts} +6 -4
  555. package/src/schema/common/{figure.js → figure.ts} +43 -23
  556. package/src/schema/common/{heading.js → heading.ts} +7 -5
  557. package/src/schema/common/{list.js → list.ts} +15 -13
  558. package/src/schema/common/{reference.js → reference.ts} +14 -12
  559. package/src/schema/common/{table.js → table.ts} +16 -14
  560. package/src/schema/common/track.ts +201 -0
  561. package/src/schema/const.ts +58 -0
  562. package/src/schema/{convert.js → convert.ts} +6 -2
  563. package/src/schema/document/{content.js → content.ts} +22 -20
  564. package/src/schema/document/{structure.js → structure.ts} +15 -9
  565. package/src/schema/{export.js → export.ts} +4 -2
  566. package/src/schema/{footnotes.js → footnotes.ts} +11 -8
  567. package/src/schema/{footnotes_convert.js → footnotes_convert.ts} +11 -8
  568. package/src/schema/i18n.ts +601 -0
  569. package/src/schema/mini_json.ts +60 -0
  570. package/src/schema/{text.js → text.ts} +6 -2
  571. package/src/types.ts +314 -0
  572. package/jest.config.js +0 -24
  573. package/src/exporter/docx/images.js +0 -101
  574. package/src/exporter/jats/bibliography.js +0 -183
  575. package/src/exporter/jats/index.js +0 -92
  576. package/src/exporter/odt/images.js +0 -115
  577. package/src/importer/citations.js +0 -129
  578. package/src/importer/native/get_images.js +0 -76
  579. /package/src/{index.js → index.ts} +0 -0
  580. /package/src/schema/common/{index.js → index.ts} +0 -0
  581. /package/src/schema/document/{index.js → index.ts} +0 -0
  582. /package/src/schema/{index.js → index.ts} +0 -0
@@ -0,0 +1,1215 @@
1
+ /* To convert to and from how the document is stored in the database to how ProseMirror expects it.
2
+ We use the DOM import for ProseMirror as the JSON we store in the database is really jsonized HTML.
3
+ */
4
+ import deepEqual from "fast-deep-equal";
5
+ import { randomFigureId, randomHeadingId, randomListId, randomTableId } from "./common/index.js";
6
+ export const getSettings = pmDoc => {
7
+ const settings = JSON.parse(JSON.stringify(pmDoc.attrs));
8
+ return settings;
9
+ };
10
+ export const updateDoc = (doc, docVersion, bibliography = false) => {
11
+ /* This is to clean documents taking all the accepted formatting from older
12
+ versions and outputting the current version of the doc format.
13
+ Notice that the docVersion isn't the same as the version of the FW export
14
+ file in Fidus Writer < 3.2 (docVersion/FW file versions versions -1.X).
15
+ While the FW file version also says something about what files could be
16
+ available inside the FW zip, the doc_version refers to how the data is
17
+ stored in those files.
18
+ In general, an update to the doc_version will likely also trigger an
19
+ update to the version of the FW export file, the reverse is not always
20
+ true.
21
+ */
22
+ switch (docVersion) {
23
+ // Import from versions up to 3.0 no longer supported starting with Fidus Writer 3.5
24
+ case 1: // Fidus Writer 3.1 prerelease
25
+ doc = convertDocV1(doc);
26
+ doc = convertDocV11(doc);
27
+ doc = convertDocV12(doc);
28
+ doc = convertDocV13(doc, bibliography);
29
+ doc = convertDocV20(doc);
30
+ doc = convertDocV21(doc);
31
+ doc = convertDocV22(doc);
32
+ doc = convertDocV23(doc);
33
+ doc = convertDocV30(doc);
34
+ doc = convertDocV31(doc);
35
+ doc = convertDocV32(doc);
36
+ doc = convertDocV33(doc);
37
+ doc = convertDocV34(doc);
38
+ doc = convertDocV35(doc);
39
+ break;
40
+ case 1.1: // Fidus Writer 3.1
41
+ doc = convertDocV11(doc);
42
+ doc = convertDocV12(doc);
43
+ doc = convertDocV13(doc, bibliography);
44
+ doc = convertDocV20(doc);
45
+ doc = convertDocV21(doc);
46
+ doc = convertDocV22(doc);
47
+ doc = convertDocV23(doc);
48
+ doc = convertDocV30(doc);
49
+ doc = convertDocV31(doc);
50
+ doc = convertDocV32(doc);
51
+ doc = convertDocV33(doc);
52
+ doc = convertDocV34(doc);
53
+ doc = convertDocV35(doc);
54
+ break;
55
+ case 1.2: // Fidus Writer 3.2
56
+ doc = convertDocV12(doc);
57
+ doc = convertDocV13(doc, bibliography);
58
+ doc = convertDocV20(doc);
59
+ doc = convertDocV21(doc);
60
+ doc = convertDocV22(doc);
61
+ doc = convertDocV23(doc);
62
+ doc = convertDocV30(doc);
63
+ doc = convertDocV31(doc);
64
+ doc = convertDocV32(doc);
65
+ doc = convertDocV33(doc);
66
+ doc = convertDocV34(doc);
67
+ doc = convertDocV35(doc);
68
+ break;
69
+ case 1.3: // Fidus Writer 3.3 prerelease
70
+ doc = convertDocV13(doc, bibliography);
71
+ doc = convertDocV20(doc);
72
+ doc = convertDocV21(doc);
73
+ doc = convertDocV22(doc);
74
+ doc = convertDocV23(doc);
75
+ doc = convertDocV30(doc);
76
+ doc = convertDocV31(doc);
77
+ doc = convertDocV32(doc);
78
+ doc = convertDocV33(doc);
79
+ doc = convertDocV34(doc);
80
+ doc = convertDocV35(doc);
81
+ break;
82
+ case 2.0: // Fidus Writer 3.3
83
+ doc = convertDocV20(doc);
84
+ doc = convertDocV21(doc);
85
+ doc = convertDocV22(doc);
86
+ doc = convertDocV23(doc);
87
+ doc = convertDocV30(doc);
88
+ doc = convertDocV31(doc);
89
+ doc = convertDocV32(doc);
90
+ doc = convertDocV33(doc);
91
+ doc = convertDocV34(doc);
92
+ doc = convertDocV35(doc);
93
+ break;
94
+ case 2.1: // Fidus Writer 3.4
95
+ doc = convertDocV21(doc);
96
+ doc = convertDocV22(doc);
97
+ doc = convertDocV23(doc);
98
+ doc = convertDocV30(doc);
99
+ doc = convertDocV31(doc);
100
+ doc = convertDocV32(doc);
101
+ doc = convertDocV33(doc);
102
+ doc = convertDocV34(doc);
103
+ doc = convertDocV35(doc);
104
+ break;
105
+ case 2.2: // Fidus Writer 3.5.7
106
+ doc = convertDocV22(doc);
107
+ doc = convertDocV23(doc);
108
+ doc = convertDocV30(doc);
109
+ doc = convertDocV31(doc);
110
+ doc = convertDocV32(doc);
111
+ doc = convertDocV33(doc);
112
+ doc = convertDocV34(doc);
113
+ doc = convertDocV35(doc);
114
+ break;
115
+ case 2.3: // Fidus Writer 3.5.10
116
+ doc = convertDocV23(doc);
117
+ doc = convertDocV30(doc);
118
+ doc = convertDocV31(doc);
119
+ doc = convertDocV32(doc);
120
+ doc = convertDocV33(doc);
121
+ doc = convertDocV34(doc);
122
+ doc = convertDocV35(doc);
123
+ break;
124
+ case 3.0: // Fidus Writer 3.6
125
+ doc = convertDocV30(doc);
126
+ doc = convertDocV31(doc);
127
+ doc = convertDocV32(doc);
128
+ doc = convertDocV33(doc);
129
+ doc = convertDocV34(doc);
130
+ doc = convertDocV35(doc);
131
+ break;
132
+ case 3.1: // Fidus Writer 3.7
133
+ doc = convertDocV31(doc);
134
+ doc = convertDocV32(doc);
135
+ doc = convertDocV33(doc);
136
+ doc = convertDocV34(doc);
137
+ doc = convertDocV35(doc);
138
+ break;
139
+ case 3.2: // Fidus Writer 3.8
140
+ doc = convertDocV32(doc);
141
+ doc = convertDocV33(doc);
142
+ doc = convertDocV34(doc);
143
+ doc = convertDocV35(doc);
144
+ break;
145
+ case 3.3: // Fidus Writer 3.9
146
+ doc = convertDocV33(doc);
147
+ doc = convertDocV34(doc);
148
+ doc = convertDocV35(doc);
149
+ break;
150
+ case 3.4: // Fidus Writer 3.10
151
+ doc = convertDocV34(doc);
152
+ doc = convertDocV35(doc);
153
+ break;
154
+ case 3.5: // Fidus Writer 4.0
155
+ doc = convertDocV35(doc);
156
+ break;
157
+ case 3.6: // Fidus Writer 4.1
158
+ break;
159
+ }
160
+ return doc;
161
+ };
162
+ const convertDocV1 = doc => {
163
+ const returnDoc = JSON.parse(JSON.stringify(doc));
164
+ convertNodeV1(returnDoc.content);
165
+ return returnDoc;
166
+ };
167
+ const convertNodeV1 = node => {
168
+ let prefixes, locators, ids, references;
169
+ switch (node.type) {
170
+ case "citation":
171
+ prefixes = node.attrs.bibBefore
172
+ ? node.attrs.bibBefore.split(",,,")
173
+ : [];
174
+ locators = node.attrs.bibPage ? node.attrs.bibPage.split(",,,") : [];
175
+ ids = node.attrs.bibEntry ? node.attrs.bibEntry.split(",") : [];
176
+ references = ids.map((id, index) => {
177
+ const returnObj = { id: Number.parseInt(id) };
178
+ if (prefixes[index] !== "") {
179
+ returnObj["prefix"] = prefixes[index];
180
+ }
181
+ if (locators[index] !== "") {
182
+ returnObj["locator"] = locators[index];
183
+ }
184
+ return returnObj;
185
+ });
186
+ node.attrs = {
187
+ format: node.attrs.bibFormat,
188
+ references
189
+ };
190
+ break;
191
+ case "footnote":
192
+ if (node.attrs?.footnote) {
193
+ node.attrs.footnote.forEach(childNode => {
194
+ convertNodeV1(childNode);
195
+ });
196
+ }
197
+ break;
198
+ }
199
+ if (node.content) {
200
+ node.content.forEach(childNode => {
201
+ convertNodeV1(childNode);
202
+ });
203
+ }
204
+ };
205
+ const convertDocV11 = doc => {
206
+ const returnDoc = JSON.parse(JSON.stringify(doc));
207
+ convertNodeV11(returnDoc.content);
208
+ return returnDoc;
209
+ };
210
+ const convertNodeV11 = (node, ids = []) => {
211
+ let blockId;
212
+ switch (node.type) {
213
+ case "heading":
214
+ blockId = node.attrs.id;
215
+ while (!blockId || ids.includes(blockId)) {
216
+ blockId = randomHeadingId();
217
+ }
218
+ node.attrs.id = blockId;
219
+ ids.push(blockId);
220
+ break;
221
+ }
222
+ if (node.content) {
223
+ node.content.forEach(childNode => {
224
+ convertNodeV11(childNode, ids);
225
+ });
226
+ }
227
+ };
228
+ const convertDocV12 = doc => {
229
+ const returnDoc = JSON.parse(JSON.stringify(doc));
230
+ convertNodeV12(returnDoc.content);
231
+ return returnDoc;
232
+ };
233
+ const convertNodeV12 = (node, ids = []) => {
234
+ let blockId;
235
+ switch (node.type) {
236
+ case "figure":
237
+ blockId = node.attrs.id;
238
+ while (!blockId || ids.includes(blockId)) {
239
+ blockId = randomFigureId();
240
+ }
241
+ node.attrs.id = blockId;
242
+ ids.push(blockId);
243
+ break;
244
+ }
245
+ if (node.content) {
246
+ node.content.forEach(childNode => {
247
+ convertNodeV12(childNode, ids);
248
+ });
249
+ }
250
+ };
251
+ const convertDocV13 = (doc, bibliography) => {
252
+ const returnDoc = JSON.parse(JSON.stringify(doc));
253
+ delete returnDoc.settings;
254
+ delete returnDoc.metadata;
255
+ returnDoc.bibliography = {};
256
+ returnDoc.imageIds = [];
257
+ convertNodeV13(returnDoc.content, returnDoc.bibliography, bibliography, returnDoc.imageIds);
258
+ return returnDoc;
259
+ };
260
+ const convertNodeV13 = (node, shrunkBib, fullBib, imageIds) => {
261
+ let authorsText, keywordsText;
262
+ switch (node.type) {
263
+ case "article":
264
+ node.attrs.language = "en-US";
265
+ break;
266
+ case "authors":
267
+ authorsText = node.content
268
+ ? node.content.reduce((text, item) => item.type === "text" ? text + item.text : text, "")
269
+ : "";
270
+ node.content = authorsText
271
+ .split(/[,;]/g)
272
+ .map(authorString => {
273
+ const author = authorString.trim();
274
+ if (!author.length) {
275
+ return false;
276
+ }
277
+ const authorParts = author.split(" ");
278
+ return {
279
+ type: "author",
280
+ attrs: {
281
+ firstname: authorParts.length > 1
282
+ ? authorParts.shift()
283
+ : false,
284
+ lastname: authorParts.join(" "),
285
+ institution: false,
286
+ email: false
287
+ }
288
+ };
289
+ })
290
+ .filter(authorObj => authorObj);
291
+ if (!node.content.length) {
292
+ delete node.content;
293
+ }
294
+ break;
295
+ case "citation":
296
+ node.attrs.references.forEach(ref => {
297
+ let item = fullBib[ref.id];
298
+ if (!item) {
299
+ item = {
300
+ fields: { title: [{ type: "text", text: "Deleted" }] },
301
+ bib_type: "misc",
302
+ entry_key: "FidusWriter"
303
+ };
304
+ }
305
+ item = Object.assign({}, item);
306
+ delete item.cats;
307
+ shrunkBib[ref.id] = item;
308
+ });
309
+ break;
310
+ case "keywords":
311
+ keywordsText = node.content
312
+ ? node.content.reduce((text, item) => item.type === "text" ? text + item.text : text, "")
313
+ : "";
314
+ node.content = keywordsText
315
+ .split(/[,;]/g)
316
+ .map(keywordString => {
317
+ const keyword = keywordString.trim();
318
+ if (!keyword.length) {
319
+ return false;
320
+ }
321
+ return {
322
+ type: "keyword",
323
+ attrs: {
324
+ keyword
325
+ }
326
+ };
327
+ })
328
+ .filter(keywordObj => keywordObj);
329
+ if (!node.content.length) {
330
+ delete node.content;
331
+ }
332
+ break;
333
+ case "figure":
334
+ if (isNaN(Number.parseInt(node.attrs.image))) {
335
+ node.attrs.image = false;
336
+ }
337
+ else {
338
+ imageIds.push(Number.parseInt(node.attrs.image));
339
+ }
340
+ break;
341
+ }
342
+ if (node.content) {
343
+ node.content.forEach(childNode => {
344
+ convertNodeV13(childNode, shrunkBib, fullBib, imageIds);
345
+ });
346
+ }
347
+ };
348
+ const convertDocV20 = doc => {
349
+ const returnDoc = JSON.parse(JSON.stringify(doc));
350
+ delete returnDoc.added;
351
+ delete returnDoc.is_owner;
352
+ delete returnDoc.revisions;
353
+ delete returnDoc.rights;
354
+ delete returnDoc.updated;
355
+ if (returnDoc.content.attrs) {
356
+ returnDoc.content.attrs.tracked = false;
357
+ }
358
+ Object.values(returnDoc.comments).forEach(comment => {
359
+ comment.username = comment.userName;
360
+ comment.isMajor = comment["review:isMajor"];
361
+ delete comment.userAvatar;
362
+ delete comment.userName;
363
+ delete comment["review:isMajor"];
364
+ if (comment.answers) {
365
+ comment.answers.forEach(answer => {
366
+ answer.username = answer.userName;
367
+ delete answer.userAvatar;
368
+ delete answer.userName;
369
+ });
370
+ }
371
+ });
372
+ return returnDoc;
373
+ };
374
+ const convertNodeV21 = node => {
375
+ let commentMark;
376
+ if (node.marks &&
377
+ (commentMark = node.marks.find(mark => mark.type === "comment"))) {
378
+ commentMark.attrs.id = String(commentMark.attrs.id);
379
+ }
380
+ if (node.content) {
381
+ node.content.forEach(childNode => convertNodeV21(childNode));
382
+ }
383
+ };
384
+ const convertDocV21 = doc => {
385
+ const returnDoc = JSON.parse(JSON.stringify(doc));
386
+ convertNodeV21(returnDoc.content);
387
+ Object.entries(returnDoc.comment).forEach(([commentId, comment]) => {
388
+ delete comment.id;
389
+ comment.assignedUser = false;
390
+ comment.assignedUsername = false;
391
+ comment.resolved = false;
392
+ comment.comment = comment.comment.split("\n").map(text => ({
393
+ type: "paragraph",
394
+ content: [{ type: "text", text }]
395
+ }));
396
+ if (comment.answers) {
397
+ comment.answers.forEach(answer => {
398
+ answer.id = answer.answerId
399
+ ? String(answer.answerId)
400
+ : answer.id && String(answer.id) !== String(commentId)
401
+ ? String(answer.id)
402
+ : String(Math.floor(Math.random() * 0xffffffff));
403
+ delete answer.answerId;
404
+ answer.answer = answer.answer.split("\n").map(text => ({
405
+ type: "paragraph",
406
+ content: [{ type: "text", text }]
407
+ }));
408
+ });
409
+ }
410
+ });
411
+ return returnDoc;
412
+ };
413
+ const convertNodeV22 = (node, imageIds) => {
414
+ switch (node.type) {
415
+ case "figure":
416
+ if (!isNaN(Number.parseInt(node.attrs.image))) {
417
+ imageIds.push(Number.parseInt(node.attrs.image));
418
+ }
419
+ break;
420
+ default:
421
+ break;
422
+ }
423
+ if (node.content) {
424
+ const deleteChildren = [];
425
+ node.content.forEach(childNode => {
426
+ if (childNode.type === "text" && !childNode.text.length) {
427
+ deleteChildren.push(childNode);
428
+ }
429
+ else {
430
+ convertNodeV22(childNode, imageIds);
431
+ }
432
+ });
433
+ node.content = node.content.filter(childNode => !deleteChildren.includes(childNode));
434
+ }
435
+ };
436
+ const convertDocV22 = doc => {
437
+ const returnDoc = JSON.parse(JSON.stringify(doc));
438
+ returnDoc.imageIds = [];
439
+ convertNodeV22(returnDoc.content, returnDoc.imageIds);
440
+ Object.entries(returnDoc.comment).forEach(([_commentId, comment]) => {
441
+ comment.comment.forEach(commentNode => convertNodeV22(commentNode, returnDoc.imageIds));
442
+ if (comment.answers) {
443
+ comment.answers.forEach(answer => {
444
+ answer.answer.forEach(answerNode => convertNodeV22(answerNode, returnDoc.imageIds));
445
+ });
446
+ }
447
+ });
448
+ return returnDoc;
449
+ };
450
+ const v23ExtraAttrs = {
451
+ languages: [
452
+ "af-ZA",
453
+ "sq-AL",
454
+ "ar",
455
+ "ast",
456
+ "be",
457
+ "br",
458
+ "bg",
459
+ "ca",
460
+ "ca-ES-Valencia",
461
+ "zh-CN",
462
+ "da",
463
+ "nl",
464
+ "en-AU",
465
+ "en-CA",
466
+ "en-NZ",
467
+ "en-ZA",
468
+ "en-GB",
469
+ "en-US",
470
+ "eo",
471
+ "fr",
472
+ "gl",
473
+ "de-DE",
474
+ "de-AU",
475
+ "de-CH",
476
+ "el",
477
+ "he",
478
+ "is",
479
+ "it",
480
+ "ja",
481
+ "km",
482
+ "lt",
483
+ "ml",
484
+ "nb-NO",
485
+ "nn-NO",
486
+ "fa",
487
+ "pl",
488
+ "pt-BR",
489
+ "pt-PT",
490
+ "ro",
491
+ "ru",
492
+ "tr",
493
+ "sr-SP-Cy",
494
+ "sr-SP-Lt",
495
+ "sk",
496
+ "sl",
497
+ "es",
498
+ "sv",
499
+ "ta",
500
+ "tl",
501
+ "uk"
502
+ ],
503
+ papersizes: ["A4", "US Letter"],
504
+ footnote_marks: ["strong", "em", "link", "anchor"],
505
+ footnote_elements: [
506
+ "paragraph",
507
+ "heading1",
508
+ "heading2",
509
+ "heading3",
510
+ "heading4",
511
+ "heading5",
512
+ "heading6",
513
+ "figure",
514
+ "ordered_list",
515
+ "bullet_list",
516
+ "horizontal_rule",
517
+ "equation",
518
+ "citation",
519
+ "blockquote",
520
+ "table"
521
+ ],
522
+ template: "Standard Article"
523
+ };
524
+ const convertNodeV23 = node => {
525
+ switch (node.type) {
526
+ case "article":
527
+ node.attrs = Object.assign({}, node.attrs, v23ExtraAttrs);
528
+ break;
529
+ case "title":
530
+ node.attrs = {
531
+ title: "Title",
532
+ id: "title"
533
+ };
534
+ break;
535
+ case "subtitle":
536
+ node.type = "heading_part";
537
+ node.attrs = {
538
+ title: "Subtitle",
539
+ id: "subtitle",
540
+ locking: false,
541
+ language: false,
542
+ optional: "hidden",
543
+ hidden: node.attrs.hidden,
544
+ help: false,
545
+ deleted: false,
546
+ elements: ["heading1"],
547
+ marks: ["strong", "em", "link", "anchor"]
548
+ };
549
+ node.content = [
550
+ {
551
+ type: "heading1",
552
+ attrs: {
553
+ id: "H5302207",
554
+ track: []
555
+ },
556
+ content: node.content
557
+ }
558
+ ];
559
+ break;
560
+ case "authors":
561
+ node.type = "contributors_part";
562
+ node.attrs = {
563
+ title: "Authors",
564
+ id: "authors",
565
+ locking: false,
566
+ language: false,
567
+ optional: "hidden",
568
+ hidden: node.attrs.hidden,
569
+ help: false,
570
+ deleted: false,
571
+ item_title: "Author"
572
+ };
573
+ break;
574
+ case "author":
575
+ node.type = "contributor";
576
+ break;
577
+ case "abstract":
578
+ node.type = "richtext_part";
579
+ node.attrs = {
580
+ title: "Abstract",
581
+ id: "abstract",
582
+ locking: false,
583
+ language: false,
584
+ optional: "hidden",
585
+ hidden: node.attrs.hidden,
586
+ help: false,
587
+ deleted: false,
588
+ elements: [
589
+ "paragraph",
590
+ "heading1",
591
+ "heading2",
592
+ "heading3",
593
+ "heading4",
594
+ "heading5",
595
+ "heading6",
596
+ "figure",
597
+ "ordered_list",
598
+ "bullet_list",
599
+ "horizontal_rule",
600
+ "equation",
601
+ "citation",
602
+ "blockquote",
603
+ "footnote",
604
+ "table"
605
+ ],
606
+ marks: ["strong", "em", "link", "anchor"]
607
+ };
608
+ break;
609
+ case "keywords":
610
+ node.type = "tags_part";
611
+ node.attrs = {
612
+ title: "Keywords",
613
+ id: "keywords",
614
+ locking: false,
615
+ language: false,
616
+ optional: "hidden",
617
+ hidden: node.attrs.hidden,
618
+ help: false,
619
+ deleted: false,
620
+ item_title: "Keyword"
621
+ };
622
+ break;
623
+ case "keyword":
624
+ node.type = "tag";
625
+ node.attrs = {
626
+ tag: node.attrs.keyword
627
+ };
628
+ break;
629
+ case "body":
630
+ node.type = "richtext_part";
631
+ node.attrs = {
632
+ title: "Body",
633
+ id: "body",
634
+ locking: false,
635
+ language: false,
636
+ optional: false,
637
+ hidden: false,
638
+ help: false,
639
+ deleted: false,
640
+ elements: [
641
+ "paragraph",
642
+ "heading1",
643
+ "heading2",
644
+ "heading3",
645
+ "heading4",
646
+ "heading5",
647
+ "heading6",
648
+ "figure",
649
+ "ordered_list",
650
+ "bullet_list",
651
+ "horizontal_rule",
652
+ "equation",
653
+ "citation",
654
+ "blockquote",
655
+ "footnote",
656
+ "table"
657
+ ],
658
+ marks: ["strong", "em", "link", "anchor"]
659
+ };
660
+ break;
661
+ case "heading":
662
+ node.type = `heading${node.attrs.level}`;
663
+ delete node.attrs.level;
664
+ break;
665
+ default:
666
+ break;
667
+ }
668
+ if (node.content) {
669
+ node.content.forEach(childNode => {
670
+ convertNodeV23(childNode);
671
+ });
672
+ }
673
+ };
674
+ const convertDocV23 = doc => {
675
+ const returnDoc = JSON.parse(JSON.stringify(doc));
676
+ convertNodeV23(returnDoc.content);
677
+ returnDoc.settings = Object.assign({}, returnDoc.settings, v23ExtraAttrs);
678
+ return returnDoc;
679
+ };
680
+ const convertNodeV30 = node => {
681
+ if (node.attrs?.marks && node.attrs.marks.filter) {
682
+ node.attrs.marks = node.attrs.marks.filter(mark => mark !== "anchor");
683
+ }
684
+ if (node.attrs?.footnote_marks) {
685
+ node.attrs.footnote_marks = node.attrs.footnote_marks.filter(mark => mark !== "anchor");
686
+ }
687
+ let attrs;
688
+ switch (node.type) {
689
+ case "article":
690
+ attrs = {
691
+ documentstyle: "",
692
+ tracked: false,
693
+ citationstyle: "apa",
694
+ language: "en-US",
695
+ languages: [
696
+ "af-ZA",
697
+ "sq-AL",
698
+ "ar",
699
+ "ast",
700
+ "be",
701
+ "br",
702
+ "bg",
703
+ "ca",
704
+ "ca-ES-Valencia",
705
+ "zh-CN",
706
+ "da",
707
+ "nl",
708
+ "en-AU",
709
+ "en-CA",
710
+ "en-NZ",
711
+ "en-ZA",
712
+ "en-GB",
713
+ "en-US",
714
+ "eo",
715
+ "fr",
716
+ "gl",
717
+ "de-DE",
718
+ "de-AU",
719
+ "de-CH",
720
+ "el",
721
+ "he",
722
+ "is",
723
+ "it",
724
+ "ja",
725
+ "km",
726
+ "lt",
727
+ "ml",
728
+ "nb-NO",
729
+ "nn-NO",
730
+ "fa",
731
+ "pl",
732
+ "pt-BR",
733
+ "pt-PT",
734
+ "ro",
735
+ "ru",
736
+ "tr",
737
+ "sr-SP-Cy",
738
+ "sr-SP-Lt",
739
+ "sk",
740
+ "sl",
741
+ "es",
742
+ "sv",
743
+ "ta",
744
+ "tl",
745
+ "uk"
746
+ ],
747
+ papersize: "A4",
748
+ papersizes: ["A4", "US Letter"],
749
+ footnote_marks: ["strong", "em", "link"],
750
+ footnote_elements: [
751
+ "paragraph",
752
+ "heading1",
753
+ "heading2",
754
+ "heading3",
755
+ "heading4",
756
+ "heading5",
757
+ "heading6",
758
+ "figure",
759
+ "ordered_list",
760
+ "bullet_list",
761
+ "horizontal_rule",
762
+ "equation",
763
+ "citation",
764
+ "blockquote",
765
+ "table"
766
+ ]
767
+ };
768
+ break;
769
+ case "richtext_part":
770
+ attrs = {
771
+ title: "",
772
+ id: "",
773
+ locking: false,
774
+ language: false,
775
+ optional: false,
776
+ hidden: false,
777
+ help: false,
778
+ initial: false,
779
+ deleted: false,
780
+ elements: [
781
+ "paragraph",
782
+ "heading1",
783
+ "heading2",
784
+ "heading3",
785
+ "heading4",
786
+ "heading5",
787
+ "heading6",
788
+ "figure",
789
+ "ordered_list",
790
+ "bullet_list",
791
+ "horizontal_rule",
792
+ "equation",
793
+ "citation",
794
+ "blockquote",
795
+ "footnote",
796
+ "table"
797
+ ],
798
+ marks: ["strong", "em", "link"],
799
+ metadata: false
800
+ };
801
+ break;
802
+ case "heading_part":
803
+ attrs = {
804
+ title: "",
805
+ id: "",
806
+ locking: false,
807
+ language: false,
808
+ optional: false,
809
+ hidden: false,
810
+ help: false,
811
+ initial: false,
812
+ deleted: false,
813
+ elements: ["heading1"],
814
+ marks: ["strong", "em", "link"],
815
+ metadata: false
816
+ };
817
+ break;
818
+ case "contributors_part":
819
+ attrs = {
820
+ title: "",
821
+ id: "",
822
+ locking: false,
823
+ language: false,
824
+ optional: false,
825
+ hidden: false,
826
+ help: false,
827
+ initial: false,
828
+ deleted: false,
829
+ item_title: "Contributor",
830
+ metadata: false
831
+ };
832
+ break;
833
+ case "tags_part":
834
+ attrs = {
835
+ title: "",
836
+ id: "",
837
+ locking: false,
838
+ language: false,
839
+ optional: false,
840
+ hidden: false,
841
+ help: false,
842
+ initial: false,
843
+ deleted: false,
844
+ item_title: "Tag",
845
+ metadata: false
846
+ };
847
+ break;
848
+ case "table_part":
849
+ attrs = {
850
+ title: "",
851
+ id: "",
852
+ locking: false,
853
+ language: false,
854
+ optional: false,
855
+ hidden: false,
856
+ help: false,
857
+ initial: false,
858
+ deleted: false,
859
+ elements: [
860
+ "paragraph",
861
+ "heading1",
862
+ "heading2",
863
+ "heading3",
864
+ "heading4",
865
+ "heading5",
866
+ "heading6",
867
+ "figure",
868
+ "ordered_list",
869
+ "bullet_list",
870
+ "horizontal_rule",
871
+ "equation",
872
+ "citation",
873
+ "blockquote",
874
+ "footnote"
875
+ ],
876
+ marks: ["strong", "em", "link"],
877
+ metadata: false
878
+ };
879
+ break;
880
+ case "table_of_contents":
881
+ attrs = {
882
+ title: "Table of Contents",
883
+ id: "toc",
884
+ optional: false,
885
+ hidden: false
886
+ };
887
+ break;
888
+ case "separator_part":
889
+ attrs = {
890
+ id: "separator"
891
+ };
892
+ break;
893
+ case "title":
894
+ attrs = {
895
+ id: "title"
896
+ };
897
+ break;
898
+ case "contributor":
899
+ attrs = {
900
+ firstname: false,
901
+ lastname: false,
902
+ email: false,
903
+ institution: false
904
+ };
905
+ break;
906
+ case "tag":
907
+ attrs = {
908
+ tag: ""
909
+ };
910
+ break;
911
+ case "footnote":
912
+ attrs = {
913
+ footnote: [
914
+ {
915
+ type: "paragraph"
916
+ }
917
+ ]
918
+ };
919
+ break;
920
+ case "code_block":
921
+ case "paragraph":
922
+ case "blockquote":
923
+ case "horizontal_rule":
924
+ case "bullet_list":
925
+ case "list_item":
926
+ attrs = {
927
+ track: []
928
+ };
929
+ break;
930
+ case "ordered_list":
931
+ attrs = {
932
+ order: 1,
933
+ track: []
934
+ };
935
+ break;
936
+ case "citation":
937
+ attrs = {
938
+ format: "autocite",
939
+ references: []
940
+ };
941
+ break;
942
+ case "equation":
943
+ attrs = {
944
+ equation: ""
945
+ };
946
+ break;
947
+ case "figure":
948
+ attrs = {
949
+ equation: "",
950
+ image: false,
951
+ figureCategory: "",
952
+ caption: "",
953
+ id: false,
954
+ track: [],
955
+ aligned: "center",
956
+ width: "100"
957
+ };
958
+ break;
959
+ case "heading1":
960
+ case "heading2":
961
+ case "heading3":
962
+ case "heading4":
963
+ case "heading5":
964
+ case "heading6":
965
+ attrs = {
966
+ id: false,
967
+ track: []
968
+ };
969
+ break;
970
+ default:
971
+ break;
972
+ }
973
+ if (attrs && node.attrs) {
974
+ for (const attr in attrs) {
975
+ if (attr in node.attrs &&
976
+ deepEqual(node.attrs[attr], attrs[attr])) {
977
+ delete node.attrs[attr];
978
+ }
979
+ }
980
+ switch (node.type) {
981
+ case "article": {
982
+ if (node.attrs.language === "") {
983
+ delete node.attrs.language;
984
+ }
985
+ const template = node.attrs.template || "default";
986
+ node.attrs.import_id = template
987
+ .normalize("NFKC")
988
+ .replace(/[^\w\s-]/g, "")
989
+ .toLowerCase()
990
+ .trim()
991
+ .replace(/[-\s]+/g, "-");
992
+ switch (node.attrs.citationstyle) {
993
+ case "harvard1":
994
+ node.attrs.citationstyle = "harvard-cite-them-right";
995
+ break;
996
+ case "mla":
997
+ node.attrs.citationstyle = "modern-language-association";
998
+ break;
999
+ case "american-anthropological-association":
1000
+ case "chicago-author-date":
1001
+ case "chicago-note-bibliography":
1002
+ case "oxford-university-press-humsoc":
1003
+ case "nature":
1004
+ break;
1005
+ default:
1006
+ delete node.attrs.citationstyle;
1007
+ }
1008
+ break;
1009
+ }
1010
+ case "title":
1011
+ delete node.attrs.title;
1012
+ break;
1013
+ default:
1014
+ break;
1015
+ }
1016
+ }
1017
+ if (node.marks) {
1018
+ for (const mark in node.marks) {
1019
+ let attrs;
1020
+ switch (mark.type) {
1021
+ case "comment":
1022
+ attrs = {
1023
+ id: false
1024
+ };
1025
+ break;
1026
+ case "annotation_tag":
1027
+ attrs = {
1028
+ type: "",
1029
+ key: "",
1030
+ value: ""
1031
+ };
1032
+ break;
1033
+ case "anchor":
1034
+ attrs = {
1035
+ id: false
1036
+ };
1037
+ break;
1038
+ case "deletion":
1039
+ attrs = {
1040
+ user: 0,
1041
+ username: "",
1042
+ date: 0
1043
+ };
1044
+ break;
1045
+ case "insertion":
1046
+ attrs = {
1047
+ user: 0,
1048
+ username: "",
1049
+ date: 0,
1050
+ approved: true
1051
+ };
1052
+ break;
1053
+ case "format_change":
1054
+ attrs = {
1055
+ user: 0,
1056
+ username: "",
1057
+ date: 0,
1058
+ before: [],
1059
+ after: []
1060
+ };
1061
+ break;
1062
+ }
1063
+ if (attrs && mark.attrs) {
1064
+ for (const attr in attrs) {
1065
+ if (attr in mark.attrs &&
1066
+ deepEqual(mark.attrs[attr], attrs[attr])) {
1067
+ delete mark.attrs[attr];
1068
+ }
1069
+ }
1070
+ }
1071
+ }
1072
+ }
1073
+ if (node.content) {
1074
+ node.content.forEach(childNode => {
1075
+ convertNodeV30(childNode);
1076
+ });
1077
+ }
1078
+ };
1079
+ const convertDocV30 = doc => {
1080
+ const returnDoc = JSON.parse(JSON.stringify(doc));
1081
+ convertNodeV30(returnDoc.content);
1082
+ return returnDoc;
1083
+ };
1084
+ const convertDocV31 = doc => {
1085
+ // Conversion adds no new requirements. Version update is required so that
1086
+ // users don't try to open file in a previous FW file. That won't work as
1087
+ // additional syntax has been added (copyright + cross references).
1088
+ const returnDoc = JSON.parse(JSON.stringify(doc));
1089
+ return returnDoc;
1090
+ };
1091
+ const convertNodeV32 = (node, ids = []) => {
1092
+ let blockId, attrs;
1093
+ switch (node.type) {
1094
+ case "table":
1095
+ attrs = node.attrs || {};
1096
+ blockId = attrs.id;
1097
+ while (!blockId || ids.includes(blockId)) {
1098
+ blockId = randomTableId();
1099
+ }
1100
+ attrs.id = blockId;
1101
+ attrs.caption = false;
1102
+ node.attrs = attrs;
1103
+ ids.push(blockId);
1104
+ node.content = [
1105
+ { type: "table_caption" },
1106
+ {
1107
+ type: "table_body",
1108
+ content: node.content
1109
+ }
1110
+ ];
1111
+ break;
1112
+ case "table_cell":
1113
+ if (!node.content || !node.content.length) {
1114
+ node.content = [{ type: "paragraph" }];
1115
+ }
1116
+ break;
1117
+ case "table_header":
1118
+ if (!node.content || !node.content.length) {
1119
+ node.content = [{ type: "paragraph" }];
1120
+ }
1121
+ break;
1122
+ case "bullet_list":
1123
+ case "ordered_list":
1124
+ attrs = node.attrs || {};
1125
+ blockId = attrs.id;
1126
+ while (!blockId || ids.includes(blockId)) {
1127
+ blockId = randomListId();
1128
+ }
1129
+ attrs.id = blockId;
1130
+ node.attrs = attrs;
1131
+ ids.push(blockId);
1132
+ break;
1133
+ case "figure": {
1134
+ attrs = node.attrs || {};
1135
+ if (attrs.figureCategory) {
1136
+ attrs.category = attrs.figureCategory;
1137
+ delete attrs.figureCategory;
1138
+ }
1139
+ node.content = [];
1140
+ if (attrs.image) {
1141
+ node.content.push({ type: "image", attrs: { image: attrs.image } });
1142
+ }
1143
+ else {
1144
+ node.content.push({
1145
+ type: "figure_equation",
1146
+ attrs: { equation: attrs.equation || "" }
1147
+ });
1148
+ }
1149
+ delete attrs.image;
1150
+ delete attrs.equation;
1151
+ const caption = { type: "figure_caption" };
1152
+ if (attrs.caption) {
1153
+ if (attrs.caption.length) {
1154
+ caption.content = [{ type: "text", text: attrs.caption }];
1155
+ attrs.caption = true;
1156
+ }
1157
+ else {
1158
+ attrs.caption = false;
1159
+ }
1160
+ }
1161
+ else {
1162
+ attrs.caption = false;
1163
+ }
1164
+ if (attrs.category === "table") {
1165
+ node.content.unshift(caption);
1166
+ }
1167
+ else {
1168
+ node.content.push(caption);
1169
+ }
1170
+ node.attrs = attrs;
1171
+ break;
1172
+ }
1173
+ case "footnote":
1174
+ if (node.attrs?.footnote) {
1175
+ node.attrs.footnote.forEach(childNode => {
1176
+ convertNodeV32(childNode, ids);
1177
+ });
1178
+ }
1179
+ break;
1180
+ }
1181
+ if (node.content) {
1182
+ node.content.forEach(childNode => {
1183
+ convertNodeV32(childNode, ids);
1184
+ });
1185
+ }
1186
+ if (node.attrs?.initial) {
1187
+ node.attrs.initial.forEach(childNode => {
1188
+ convertNodeV32(childNode, ids);
1189
+ });
1190
+ }
1191
+ };
1192
+ const convertDocV32 = doc => {
1193
+ const returnDoc = JSON.parse(JSON.stringify(doc));
1194
+ convertNodeV32(returnDoc);
1195
+ return returnDoc;
1196
+ };
1197
+ const convertDocV33 = doc => {
1198
+ // We just need to increase the version number so that documents cannot
1199
+ // be moved from a 3.10 to an 3.9 system, but 3.3 files should be readable
1200
+ // as 3.4 files.
1201
+ return JSON.parse(JSON.stringify(doc));
1202
+ };
1203
+ const convertDocV34 = doc => {
1204
+ // The top node needs to be changed from "article" to "doc".
1205
+ const returnDoc = JSON.parse(JSON.stringify(doc));
1206
+ returnDoc.type = "doc";
1207
+ return returnDoc;
1208
+ };
1209
+ const convertDocV35 = doc => {
1210
+ // We just need to increase the version number so that documents cannot
1211
+ // be moved from a 4.1 to an 4.0 system, but 3.5 files should be readable
1212
+ // as 3.6 files.
1213
+ return JSON.parse(JSON.stringify(doc));
1214
+ };
1215
+ //# sourceMappingURL=convert.js.map