@fiduswriter/document 0.1.0-alpha.4 → 0.1.0-alpha.6

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 (550) hide show
  1. package/dist/bibliography/common.d.ts +9 -91
  2. package/dist/bibliography/common.d.ts.map +1 -1
  3. package/dist/bibliography/common.js +3 -2
  4. package/dist/bibliography/common.js.map +1 -1
  5. package/dist/bibliography/csl_bib.d.ts +1 -1
  6. package/dist/bibliography/csl_bib.d.ts.map +1 -1
  7. package/dist/bibliography/csl_bib.js +7 -7
  8. package/dist/bibliography/csl_bib.js.map +1 -1
  9. package/dist/citations/citeproc_sys.d.ts +9 -10
  10. package/dist/citations/citeproc_sys.d.ts.map +1 -1
  11. package/dist/citations/citeproc_sys.js +6 -1
  12. package/dist/citations/citeproc_sys.js.map +1 -1
  13. package/dist/citations/format.d.ts +33 -16
  14. package/dist/citations/format.d.ts.map +1 -1
  15. package/dist/citations/format.js +29 -4
  16. package/dist/citations/format.js.map +1 -1
  17. package/dist/editor/e2ee/encryptor.d.ts +35 -35
  18. package/dist/editor/e2ee/encryptor.d.ts.map +1 -1
  19. package/dist/editor/e2ee/encryptor.js +31 -31
  20. package/dist/editor/e2ee/encryptor.js.map +1 -1
  21. package/dist/exporter/docx/citations.d.ts +27 -17
  22. package/dist/exporter/docx/citations.d.ts.map +1 -1
  23. package/dist/exporter/docx/citations.js +24 -7
  24. package/dist/exporter/docx/citations.js.map +1 -1
  25. package/dist/exporter/docx/comments.d.ts +15 -11
  26. package/dist/exporter/docx/comments.d.ts.map +1 -1
  27. package/dist/exporter/docx/comments.js +47 -14
  28. package/dist/exporter/docx/comments.js.map +1 -1
  29. package/dist/exporter/docx/footnotes.d.ts +36 -31
  30. package/dist/exporter/docx/footnotes.d.ts.map +1 -1
  31. package/dist/exporter/docx/footnotes.js +46 -12
  32. package/dist/exporter/docx/footnotes.js.map +1 -1
  33. package/dist/exporter/docx/images.d.ts +23 -12
  34. package/dist/exporter/docx/images.d.ts.map +1 -1
  35. package/dist/exporter/docx/images.js +35 -20
  36. package/dist/exporter/docx/images.js.map +1 -1
  37. package/dist/exporter/docx/index.d.ts +11 -17
  38. package/dist/exporter/docx/index.d.ts.map +1 -1
  39. package/dist/exporter/docx/index.js +15 -7
  40. package/dist/exporter/docx/index.js.map +1 -1
  41. package/dist/exporter/docx/lists.d.ts +27 -22
  42. package/dist/exporter/docx/lists.d.ts.map +1 -1
  43. package/dist/exporter/docx/lists.js +77 -30
  44. package/dist/exporter/docx/lists.js.map +1 -1
  45. package/dist/exporter/docx/math.d.ts +9 -9
  46. package/dist/exporter/docx/math.d.ts.map +1 -1
  47. package/dist/exporter/docx/math.js +22 -5
  48. package/dist/exporter/docx/math.js.map +1 -1
  49. package/dist/exporter/docx/metadata.d.ts +12 -9
  50. package/dist/exporter/docx/metadata.d.ts.map +1 -1
  51. package/dist/exporter/docx/metadata.js +59 -26
  52. package/dist/exporter/docx/metadata.js.map +1 -1
  53. package/dist/exporter/docx/rels.d.ts +14 -12
  54. package/dist/exporter/docx/rels.d.ts.map +1 -1
  55. package/dist/exporter/docx/rels.js +37 -22
  56. package/dist/exporter/docx/rels.js.map +1 -1
  57. package/dist/exporter/docx/render.d.ts +17 -15
  58. package/dist/exporter/docx/render.d.ts.map +1 -1
  59. package/dist/exporter/docx/render.js +37 -31
  60. package/dist/exporter/docx/render.js.map +1 -1
  61. package/dist/exporter/docx/richtext.d.ts +8 -8
  62. package/dist/exporter/docx/richtext.d.ts.map +1 -1
  63. package/dist/exporter/docx/richtext.js +61 -43
  64. package/dist/exporter/docx/richtext.js.map +1 -1
  65. package/dist/exporter/docx/tables.d.ts +11 -9
  66. package/dist/exporter/docx/tables.d.ts.map +1 -1
  67. package/dist/exporter/docx/tables.js +16 -10
  68. package/dist/exporter/docx/tables.js.map +1 -1
  69. package/dist/exporter/docx/tools.d.ts +3 -2
  70. package/dist/exporter/docx/tools.d.ts.map +1 -1
  71. package/dist/exporter/docx/tools.js +3 -3
  72. package/dist/exporter/docx/tools.js.map +1 -1
  73. package/dist/exporter/epub/index.d.ts +11 -3
  74. package/dist/exporter/epub/index.d.ts.map +1 -1
  75. package/dist/exporter/epub/index.js +10 -3
  76. package/dist/exporter/epub/index.js.map +1 -1
  77. package/dist/exporter/epub/templates.d.ts +62 -31
  78. package/dist/exporter/epub/templates.d.ts.map +1 -1
  79. package/dist/exporter/epub/templates.js +1 -1
  80. package/dist/exporter/epub/templates.js.map +1 -1
  81. package/dist/exporter/epub/tools.d.ts +12 -4
  82. package/dist/exporter/epub/tools.d.ts.map +1 -1
  83. package/dist/exporter/epub/tools.js +14 -13
  84. package/dist/exporter/epub/tools.js.map +1 -1
  85. package/dist/exporter/html/citations.d.ts +17 -15
  86. package/dist/exporter/html/citations.d.ts.map +1 -1
  87. package/dist/exporter/html/citations.js +37 -18
  88. package/dist/exporter/html/citations.js.map +1 -1
  89. package/dist/exporter/html/convert.d.ts +20 -70
  90. package/dist/exporter/html/convert.d.ts.map +1 -1
  91. package/dist/exporter/html/convert.js +74 -42
  92. package/dist/exporter/html/convert.js.map +1 -1
  93. package/dist/exporter/html/index.d.ts +55 -52
  94. package/dist/exporter/html/index.d.ts.map +1 -1
  95. package/dist/exporter/html/index.js +23 -3
  96. package/dist/exporter/html/index.js.map +1 -1
  97. package/dist/exporter/html/templates.d.ts +23 -9
  98. package/dist/exporter/html/templates.d.ts.map +1 -1
  99. package/dist/exporter/html/templates.js +1 -1
  100. package/dist/exporter/html/templates.js.map +1 -1
  101. package/dist/exporter/html/tools.d.ts +1 -1
  102. package/dist/exporter/html/tools.d.ts.map +1 -1
  103. package/dist/exporter/html/tools.js +2 -2
  104. package/dist/exporter/html/tools.js.map +1 -1
  105. package/dist/exporter/jats/bibliography.d.ts +2 -1
  106. package/dist/exporter/jats/bibliography.d.ts.map +1 -1
  107. package/dist/exporter/jats/bibliography.js +57 -52
  108. package/dist/exporter/jats/bibliography.js.map +1 -1
  109. package/dist/exporter/jats/citations.d.ts +13 -11
  110. package/dist/exporter/jats/citations.d.ts.map +1 -1
  111. package/dist/exporter/jats/citations.js +28 -6
  112. package/dist/exporter/jats/citations.js.map +1 -1
  113. package/dist/exporter/jats/convert.d.ts +24 -28
  114. package/dist/exporter/jats/convert.d.ts.map +1 -1
  115. package/dist/exporter/jats/convert.js +53 -36
  116. package/dist/exporter/jats/convert.js.map +1 -1
  117. package/dist/exporter/jats/index.d.ts +21 -15
  118. package/dist/exporter/jats/index.d.ts.map +1 -1
  119. package/dist/exporter/jats/index.js +21 -5
  120. package/dist/exporter/jats/index.js.map +1 -1
  121. package/dist/exporter/jats/templates.d.ts +17 -15
  122. package/dist/exporter/jats/templates.d.ts.map +1 -1
  123. package/dist/exporter/jats/templates.js.map +1 -1
  124. package/dist/exporter/jats/text.d.ts +3 -2
  125. package/dist/exporter/jats/text.d.ts.map +1 -1
  126. package/dist/exporter/jats/text.js +4 -4
  127. package/dist/exporter/jats/text.js.map +1 -1
  128. package/dist/exporter/latex/convert.d.ts +12 -15
  129. package/dist/exporter/latex/convert.d.ts.map +1 -1
  130. package/dist/exporter/latex/convert.js +70 -54
  131. package/dist/exporter/latex/convert.js.map +1 -1
  132. package/dist/exporter/latex/escape_latex.d.ts +1 -1
  133. package/dist/exporter/latex/escape_latex.d.ts.map +1 -1
  134. package/dist/exporter/latex/escape_latex.js +1 -1
  135. package/dist/exporter/latex/escape_latex.js.map +1 -1
  136. package/dist/exporter/latex/index.d.ts +20 -19
  137. package/dist/exporter/latex/index.d.ts.map +1 -1
  138. package/dist/exporter/latex/index.js +15 -5
  139. package/dist/exporter/latex/index.js.map +1 -1
  140. package/dist/exporter/latex/readme.d.ts +1 -1
  141. package/dist/exporter/latex/readme.d.ts.map +1 -1
  142. package/dist/exporter/latex/readme.js +2 -2
  143. package/dist/exporter/latex/readme.js.map +1 -1
  144. package/dist/exporter/native/copy.d.ts +30 -0
  145. package/dist/exporter/native/copy.d.ts.map +1 -0
  146. package/dist/exporter/native/copy.js +151 -0
  147. package/dist/exporter/native/copy.js.map +1 -0
  148. package/dist/exporter/native/file.d.ts +12 -0
  149. package/dist/exporter/native/file.d.ts.map +1 -0
  150. package/dist/exporter/native/file.js +38 -0
  151. package/dist/exporter/native/file.js.map +1 -0
  152. package/dist/exporter/native/index.d.ts +5 -0
  153. package/dist/exporter/native/index.d.ts.map +1 -0
  154. package/dist/exporter/native/index.js +5 -0
  155. package/dist/exporter/native/index.js.map +1 -0
  156. package/dist/exporter/native/revision.d.ts +18 -0
  157. package/dist/exporter/native/revision.d.ts.map +1 -0
  158. package/dist/exporter/native/revision.js +39 -0
  159. package/dist/exporter/native/revision.js.map +1 -0
  160. package/dist/exporter/native/shrink.d.ts +29 -14
  161. package/dist/exporter/native/shrink.d.ts.map +1 -1
  162. package/dist/exporter/native/shrink.js +27 -18
  163. package/dist/exporter/native/shrink.js.map +1 -1
  164. package/dist/exporter/native/zip.d.ts +25 -0
  165. package/dist/exporter/native/zip.d.ts.map +1 -0
  166. package/dist/exporter/native/zip.js +56 -0
  167. package/dist/exporter/native/zip.js.map +1 -0
  168. package/dist/exporter/odt/citations.d.ts +18 -15
  169. package/dist/exporter/odt/citations.d.ts.map +1 -1
  170. package/dist/exporter/odt/citations.js +21 -4
  171. package/dist/exporter/odt/citations.js.map +1 -1
  172. package/dist/exporter/odt/footnotes.d.ts +25 -19
  173. package/dist/exporter/odt/footnotes.d.ts.map +1 -1
  174. package/dist/exporter/odt/footnotes.js +23 -6
  175. package/dist/exporter/odt/footnotes.js.map +1 -1
  176. package/dist/exporter/odt/images.d.ts +23 -11
  177. package/dist/exporter/odt/images.d.ts.map +1 -1
  178. package/dist/exporter/odt/images.js +34 -26
  179. package/dist/exporter/odt/images.js.map +1 -1
  180. package/dist/exporter/odt/index.d.ts +12 -18
  181. package/dist/exporter/odt/index.d.ts.map +1 -1
  182. package/dist/exporter/odt/index.js +16 -7
  183. package/dist/exporter/odt/index.js.map +1 -1
  184. package/dist/exporter/odt/math.d.ts +10 -8
  185. package/dist/exporter/odt/math.d.ts.map +1 -1
  186. package/dist/exporter/odt/math.js +27 -4
  187. package/dist/exporter/odt/math.js.map +1 -1
  188. package/dist/exporter/odt/metadata.d.ts +13 -9
  189. package/dist/exporter/odt/metadata.d.ts.map +1 -1
  190. package/dist/exporter/odt/metadata.js +36 -15
  191. package/dist/exporter/odt/metadata.js.map +1 -1
  192. package/dist/exporter/odt/render.d.ts +17 -15
  193. package/dist/exporter/odt/render.d.ts.map +1 -1
  194. package/dist/exporter/odt/render.js +25 -18
  195. package/dist/exporter/odt/render.js.map +1 -1
  196. package/dist/exporter/odt/richtext.d.ts +9 -9
  197. package/dist/exporter/odt/richtext.d.ts.map +1 -1
  198. package/dist/exporter/odt/richtext.js +55 -40
  199. package/dist/exporter/odt/richtext.js.map +1 -1
  200. package/dist/exporter/odt/styles.d.ts +29 -21
  201. package/dist/exporter/odt/styles.d.ts.map +1 -1
  202. package/dist/exporter/odt/styles.js +44 -22
  203. package/dist/exporter/odt/styles.js.map +1 -1
  204. package/dist/exporter/odt/track.d.ts +14 -7
  205. package/dist/exporter/odt/track.d.ts.map +1 -1
  206. package/dist/exporter/odt/track.js +7 -0
  207. package/dist/exporter/odt/track.js.map +1 -1
  208. package/dist/exporter/pandoc/citations.d.ts +20 -14
  209. package/dist/exporter/pandoc/citations.d.ts.map +1 -1
  210. package/dist/exporter/pandoc/citations.js +18 -4
  211. package/dist/exporter/pandoc/citations.js.map +1 -1
  212. package/dist/exporter/pandoc/convert.d.ts +10 -29
  213. package/dist/exporter/pandoc/convert.d.ts.map +1 -1
  214. package/dist/exporter/pandoc/convert.js +45 -40
  215. package/dist/exporter/pandoc/convert.js.map +1 -1
  216. package/dist/exporter/pandoc/index.d.ts +20 -33
  217. package/dist/exporter/pandoc/index.d.ts.map +1 -1
  218. package/dist/exporter/pandoc/index.js +20 -8
  219. package/dist/exporter/pandoc/index.js.map +1 -1
  220. package/dist/exporter/pandoc/readme.d.ts +1 -1
  221. package/dist/exporter/pandoc/readme.d.ts.map +1 -1
  222. package/dist/exporter/pandoc/readme.js +0 -1
  223. package/dist/exporter/pandoc/readme.js.map +1 -1
  224. package/dist/exporter/pandoc/tools.d.ts +21 -5
  225. package/dist/exporter/pandoc/tools.d.ts.map +1 -1
  226. package/dist/exporter/pandoc/tools.js +2 -2
  227. package/dist/exporter/pandoc/tools.js.map +1 -1
  228. package/dist/exporter/print/index.d.ts +18 -7
  229. package/dist/exporter/print/index.d.ts.map +1 -1
  230. package/dist/exporter/print/index.js +12 -10
  231. package/dist/exporter/print/index.js.map +1 -1
  232. package/dist/exporter/tools/doc_content.d.ts +5 -6
  233. package/dist/exporter/tools/doc_content.d.ts.map +1 -1
  234. package/dist/exporter/tools/doc_content.js +17 -16
  235. package/dist/exporter/tools/doc_content.js.map +1 -1
  236. package/dist/exporter/tools/svg.d.ts +7 -1
  237. package/dist/exporter/tools/svg.d.ts.map +1 -1
  238. package/dist/exporter/tools/svg.js.map +1 -1
  239. package/dist/exporter/tools/xml.d.ts +39 -38
  240. package/dist/exporter/tools/xml.d.ts.map +1 -1
  241. package/dist/exporter/tools/xml.js +82 -55
  242. package/dist/exporter/tools/xml.js.map +1 -1
  243. package/dist/exporter/tools/xml_zip.d.ts +15 -14
  244. package/dist/exporter/tools/xml_zip.d.ts.map +1 -1
  245. package/dist/exporter/tools/xml_zip.js +8 -2
  246. package/dist/exporter/tools/xml_zip.js.map +1 -1
  247. package/dist/exporter/tools/zip.d.ts +28 -14
  248. package/dist/exporter/tools/zip.d.ts.map +1 -1
  249. package/dist/exporter/tools/zip.js +13 -6
  250. package/dist/exporter/tools/zip.js.map +1 -1
  251. package/dist/exporter/tools/zotero_csl.d.ts +19 -6
  252. package/dist/exporter/tools/zotero_csl.d.ts.map +1 -1
  253. package/dist/exporter/tools/zotero_csl.js +9 -9
  254. package/dist/exporter/tools/zotero_csl.js.map +1 -1
  255. package/dist/importer/citations.d.ts +25 -22
  256. package/dist/importer/citations.d.ts.map +1 -1
  257. package/dist/importer/citations.js +1 -49
  258. package/dist/importer/citations.js.map +1 -1
  259. package/dist/importer/docx/citations.d.ts +8 -30
  260. package/dist/importer/docx/citations.d.ts.map +1 -1
  261. package/dist/importer/docx/citations.js +1 -26
  262. package/dist/importer/docx/citations.js.map +1 -1
  263. package/dist/importer/docx/convert.d.ts +38 -116
  264. package/dist/importer/docx/convert.d.ts.map +1 -1
  265. package/dist/importer/docx/convert.js +99 -82
  266. package/dist/importer/docx/convert.js.map +1 -1
  267. package/dist/importer/docx/helpers.d.ts +1 -1
  268. package/dist/importer/docx/helpers.d.ts.map +1 -1
  269. package/dist/importer/docx/helpers.js +1 -1
  270. package/dist/importer/docx/helpers.js.map +1 -1
  271. package/dist/importer/docx/index.d.ts +27 -0
  272. package/dist/importer/docx/index.d.ts.map +1 -0
  273. package/dist/importer/docx/index.js +77 -0
  274. package/dist/importer/docx/index.js.map +1 -0
  275. package/dist/importer/docx/omml2mathml.d.ts +2 -3
  276. package/dist/importer/docx/omml2mathml.d.ts.map +1 -1
  277. package/dist/importer/docx/omml2mathml.js +23 -116
  278. package/dist/importer/docx/omml2mathml.js.map +1 -1
  279. package/dist/importer/docx/parse.d.ts +22 -131
  280. package/dist/importer/docx/parse.d.ts.map +1 -1
  281. package/dist/importer/docx/parse.js +73 -55
  282. package/dist/importer/docx/parse.js.map +1 -1
  283. package/dist/importer/native/extract_template.d.ts +6 -0
  284. package/dist/importer/native/extract_template.d.ts.map +1 -0
  285. package/dist/importer/native/extract_template.js +80 -0
  286. package/dist/importer/native/extract_template.js.map +1 -0
  287. package/dist/importer/native/file.d.ts +37 -0
  288. package/dist/importer/native/file.d.ts.map +1 -0
  289. package/dist/importer/native/file.js +162 -0
  290. package/dist/importer/native/file.js.map +1 -0
  291. package/dist/importer/native/get_images.d.ts +18 -8
  292. package/dist/importer/native/get_images.d.ts.map +1 -1
  293. package/dist/importer/native/get_images.js +39 -45
  294. package/dist/importer/native/get_images.js.map +1 -1
  295. package/dist/importer/native/importer.d.ts +41 -0
  296. package/dist/importer/native/importer.d.ts.map +1 -0
  297. package/dist/importer/native/importer.js +170 -0
  298. package/dist/importer/native/importer.js.map +1 -0
  299. package/dist/importer/native/index.d.ts +7 -0
  300. package/dist/importer/native/index.d.ts.map +1 -0
  301. package/dist/importer/native/index.js +7 -0
  302. package/dist/importer/native/index.js.map +1 -0
  303. package/dist/importer/native/update.d.ts +5 -4
  304. package/dist/importer/native/update.d.ts.map +1 -1
  305. package/dist/importer/native/update.js +4 -3
  306. package/dist/importer/native/update.js.map +1 -1
  307. package/dist/importer/native/update_template.d.ts +12 -0
  308. package/dist/importer/native/update_template.d.ts.map +1 -0
  309. package/dist/importer/native/update_template.js +19 -0
  310. package/dist/importer/native/update_template.js.map +1 -0
  311. package/dist/importer/odt/citations.d.ts +7 -27
  312. package/dist/importer/odt/citations.d.ts.map +1 -1
  313. package/dist/importer/odt/citations.js +0 -22
  314. package/dist/importer/odt/citations.js.map +1 -1
  315. package/dist/importer/odt/convert.d.ts +53 -237
  316. package/dist/importer/odt/convert.d.ts.map +1 -1
  317. package/dist/importer/odt/convert.js +162 -138
  318. package/dist/importer/odt/convert.js.map +1 -1
  319. package/dist/importer/odt/index.d.ts +30 -0
  320. package/dist/importer/odt/index.d.ts.map +1 -0
  321. package/dist/importer/odt/index.js +124 -0
  322. package/dist/importer/odt/index.js.map +1 -0
  323. package/dist/importer/pandoc/convert.d.ts +25 -77
  324. package/dist/importer/pandoc/convert.d.ts.map +1 -1
  325. package/dist/importer/pandoc/convert.js +65 -52
  326. package/dist/importer/pandoc/convert.js.map +1 -1
  327. package/dist/importer/pandoc/helpers.d.ts +4 -3
  328. package/dist/importer/pandoc/helpers.d.ts.map +1 -1
  329. package/dist/importer/pandoc/helpers.js +24 -26
  330. package/dist/importer/pandoc/helpers.js.map +1 -1
  331. package/dist/importer/pandoc/index.d.ts +31 -0
  332. package/dist/importer/pandoc/index.d.ts.map +1 -0
  333. package/dist/importer/pandoc/index.js +114 -0
  334. package/dist/importer/pandoc/index.js.map +1 -0
  335. package/dist/importer/registry.d.ts +21 -0
  336. package/dist/importer/registry.d.ts.map +1 -0
  337. package/dist/importer/registry.js +41 -0
  338. package/dist/importer/registry.js.map +1 -0
  339. package/dist/importer/zip_analyzer.d.ts +27 -21
  340. package/dist/importer/zip_analyzer.d.ts.map +1 -1
  341. package/dist/importer/zip_analyzer.js +10 -5
  342. package/dist/importer/zip_analyzer.js.map +1 -1
  343. package/dist/mathlive/opf_includes.d.ts +1 -1
  344. package/dist/mathlive/opf_includes.d.ts.map +1 -1
  345. package/dist/mathlive/opf_includes.js.map +1 -1
  346. package/dist/schema/common/annotate.d.ts +37 -49
  347. package/dist/schema/common/annotate.d.ts.map +1 -1
  348. package/dist/schema/common/annotate.js +2 -2
  349. package/dist/schema/common/annotate.js.map +1 -1
  350. package/dist/schema/common/base.d.ts +63 -81
  351. package/dist/schema/common/base.d.ts.map +1 -1
  352. package/dist/schema/common/base.js.map +1 -1
  353. package/dist/schema/common/citation.d.ts +23 -22
  354. package/dist/schema/common/citation.d.ts.map +1 -1
  355. package/dist/schema/common/citation.js +4 -5
  356. package/dist/schema/common/citation.js.map +1 -1
  357. package/dist/schema/common/equation.d.ts +13 -14
  358. package/dist/schema/common/equation.d.ts.map +1 -1
  359. package/dist/schema/common/equation.js +1 -1
  360. package/dist/schema/common/equation.js.map +1 -1
  361. package/dist/schema/common/figure.d.ts +72 -93
  362. package/dist/schema/common/figure.d.ts.map +1 -1
  363. package/dist/schema/common/figure.js +11 -9
  364. package/dist/schema/common/figure.js.map +1 -1
  365. package/dist/schema/common/heading.d.ts +8 -32
  366. package/dist/schema/common/heading.d.ts.map +1 -1
  367. package/dist/schema/common/heading.js +2 -2
  368. package/dist/schema/common/heading.js.map +1 -1
  369. package/dist/schema/common/index.d.ts +2 -2
  370. package/dist/schema/common/index.d.ts.map +1 -1
  371. package/dist/schema/common/index.js.map +1 -1
  372. package/dist/schema/common/list.d.ts +52 -72
  373. package/dist/schema/common/list.d.ts.map +1 -1
  374. package/dist/schema/common/list.js +3 -3
  375. package/dist/schema/common/list.js.map +1 -1
  376. package/dist/schema/common/reference.d.ts +51 -59
  377. package/dist/schema/common/reference.d.ts.map +1 -1
  378. package/dist/schema/common/reference.js +5 -5
  379. package/dist/schema/common/reference.js.map +1 -1
  380. package/dist/schema/common/table.d.ts +59 -75
  381. package/dist/schema/common/table.d.ts.map +1 -1
  382. package/dist/schema/common/table.js +3 -2
  383. package/dist/schema/common/table.js.map +1 -1
  384. package/dist/schema/common/track.d.ts +83 -97
  385. package/dist/schema/common/track.d.ts.map +1 -1
  386. package/dist/schema/common/track.js +18 -17
  387. package/dist/schema/common/track.js.map +1 -1
  388. package/dist/schema/convert.d.ts +2 -2
  389. package/dist/schema/convert.d.ts.map +1 -1
  390. package/dist/schema/convert.js +2 -2
  391. package/dist/schema/convert.js.map +1 -1
  392. package/dist/schema/document/content.d.ts +95 -122
  393. package/dist/schema/document/content.d.ts.map +1 -1
  394. package/dist/schema/document/content.js +9 -9
  395. package/dist/schema/document/content.js.map +1 -1
  396. package/dist/schema/document/index.d.ts +173 -257
  397. package/dist/schema/document/index.d.ts.map +1 -1
  398. package/dist/schema/document/index.js.map +1 -1
  399. package/dist/schema/document/structure.d.ts +149 -258
  400. package/dist/schema/document/structure.d.ts.map +1 -1
  401. package/dist/schema/document/structure.js +2 -2
  402. package/dist/schema/document/structure.js.map +1 -1
  403. package/dist/schema/export.d.ts +4 -877
  404. package/dist/schema/export.d.ts.map +1 -1
  405. package/dist/schema/export.js +1 -0
  406. package/dist/schema/export.js.map +1 -1
  407. package/dist/schema/footnotes.d.ts +110 -155
  408. package/dist/schema/footnotes.d.ts.map +1 -1
  409. package/dist/schema/footnotes.js +4 -2
  410. package/dist/schema/footnotes.js.map +1 -1
  411. package/dist/schema/footnotes_convert.d.ts +3 -3
  412. package/dist/schema/footnotes_convert.d.ts.map +1 -1
  413. package/dist/schema/footnotes_convert.js +10 -6
  414. package/dist/schema/footnotes_convert.js.map +1 -1
  415. package/dist/schema/i18n.d.ts +3 -534
  416. package/dist/schema/i18n.d.ts.map +1 -1
  417. package/dist/schema/i18n.js +1 -0
  418. package/dist/schema/i18n.js.map +1 -1
  419. package/dist/schema/index.d.ts +1 -1
  420. package/dist/schema/index.d.ts.map +1 -1
  421. package/dist/schema/index.js.map +1 -1
  422. package/dist/schema/mini_json.d.ts +3 -4
  423. package/dist/schema/mini_json.d.ts.map +1 -1
  424. package/dist/schema/mini_json.js +2 -0
  425. package/dist/schema/mini_json.js.map +1 -1
  426. package/dist/schema/text.d.ts +2 -1
  427. package/dist/schema/text.d.ts.map +1 -1
  428. package/dist/schema/text.js +1 -1
  429. package/dist/schema/text.js.map +1 -1
  430. package/dist/types.d.ts +167 -8
  431. package/dist/types.d.ts.map +1 -1
  432. package/package.json +24 -1
  433. package/src/bibliography/{common.js → common.ts} +15 -12
  434. package/src/bibliography/{csl_bib.js → csl_bib.ts} +16 -15
  435. package/src/citations/{citeproc_sys.js → citeproc_sys.ts} +26 -6
  436. package/src/citations/{format.js → format.ts} +80 -24
  437. package/src/editor/e2ee/{encryptor.js → encryptor.ts} +76 -44
  438. package/src/exporter/docx/{citations.js → citations.ts} +51 -23
  439. package/src/exporter/docx/{comments.js → comments.ts} +69 -26
  440. package/src/exporter/docx/{footnotes.js → footnotes.ts} +81 -42
  441. package/src/exporter/docx/images.ts +128 -0
  442. package/src/exporter/docx/{index.js → index.ts} +48 -25
  443. package/src/exporter/docx/{lists.js → lists.ts} +89 -46
  444. package/src/exporter/docx/{math.js → math.ts} +29 -9
  445. package/src/exporter/docx/{metadata.js → metadata.ts} +78 -42
  446. package/src/exporter/docx/{rels.js → rels.ts} +71 -50
  447. package/src/exporter/docx/{render.js → render.ts} +124 -87
  448. package/src/exporter/docx/{richtext.js → richtext.ts} +107 -84
  449. package/src/exporter/docx/{tables.js → tables.ts} +33 -23
  450. package/src/exporter/docx/{tools.js → tools.ts} +4 -3
  451. package/src/exporter/epub/{index.js → index.ts} +44 -15
  452. package/src/exporter/epub/{templates.js → templates.ts} +71 -7
  453. package/src/exporter/epub/{tools.js → tools.ts} +31 -25
  454. package/src/exporter/html/{citations.js → citations.ts} +79 -31
  455. package/src/exporter/html/{convert.js → convert.ts} +118 -71
  456. package/src/exporter/html/{index.js → index.ts} +63 -29
  457. package/src/exporter/html/{templates.js → templates.ts} +22 -2
  458. package/src/exporter/html/{tools.js → tools.ts} +9 -6
  459. package/src/exporter/jats/bibliography.ts +199 -0
  460. package/src/exporter/jats/{citations.js → citations.ts} +56 -20
  461. package/src/exporter/jats/{convert.js → convert.ts} +72 -53
  462. package/src/exporter/jats/index.ts +132 -0
  463. package/src/exporter/jats/{templates.js → templates.ts} +19 -3
  464. package/src/exporter/jats/{text.js → text.ts} +8 -6
  465. package/src/exporter/latex/{convert.js → convert.ts} +160 -125
  466. package/src/exporter/latex/{escape_latex.js → escape_latex.ts} +1 -1
  467. package/src/exporter/latex/{index.js → index.ts} +27 -12
  468. package/src/exporter/latex/{readme.js → readme.ts} +2 -2
  469. package/src/exporter/native/copy.ts +231 -0
  470. package/src/exporter/native/file.ts +65 -0
  471. package/src/exporter/native/index.ts +4 -0
  472. package/src/exporter/native/revision.ts +76 -0
  473. package/src/exporter/native/{shrink.js → shrink.ts} +64 -29
  474. package/src/exporter/native/zip.ts +85 -0
  475. package/src/exporter/odt/{citations.js → citations.ts} +35 -15
  476. package/src/exporter/odt/{footnotes.js → footnotes.ts} +53 -30
  477. package/src/exporter/odt/images.ts +135 -0
  478. package/src/exporter/odt/{index.js → index.ts} +49 -27
  479. package/src/exporter/odt/{math.js → math.ts} +38 -9
  480. package/src/exporter/odt/{metadata.js → metadata.ts} +54 -29
  481. package/src/exporter/odt/{render.js → render.ts} +89 -60
  482. package/src/exporter/odt/{richtext.js → richtext.ts} +102 -72
  483. package/src/exporter/odt/{styles.js → styles.ts} +98 -66
  484. package/src/exporter/odt/{track.js → track.ts} +22 -6
  485. package/src/exporter/pandoc/{citations.js → citations.ts} +31 -15
  486. package/src/exporter/pandoc/{convert.js → convert.ts} +98 -79
  487. package/src/exporter/pandoc/{index.js → index.ts} +36 -13
  488. package/src/exporter/pandoc/{readme.js → readme.ts} +0 -1
  489. package/src/exporter/pandoc/{tools.js → tools.ts} +28 -5
  490. package/src/exporter/print/{index.js → index.ts} +38 -19
  491. package/src/exporter/tools/{doc_content.js → doc_content.ts} +34 -24
  492. package/src/exporter/tools/{svg.js → svg.ts} +9 -3
  493. package/src/exporter/tools/{xml.js → xml.ts} +187 -138
  494. package/src/exporter/tools/{xml_zip.js → xml_zip.ts} +19 -11
  495. package/src/exporter/tools/{zip.js → zip.ts} +35 -11
  496. package/src/exporter/tools/{zotero_csl.js → zotero_csl.ts} +35 -18
  497. package/src/global.d.ts +2 -0
  498. package/src/importer/citations.ts +116 -0
  499. package/src/importer/docx/{citations.js → citations.ts} +22 -37
  500. package/src/importer/docx/{convert.js → convert.ts} +176 -141
  501. package/src/importer/docx/{helpers.js → helpers.ts} +1 -1
  502. package/src/importer/docx/index.ts +124 -0
  503. package/src/importer/docx/{omml2mathml.js → omml2mathml.ts} +154 -176
  504. package/src/importer/docx/{parse.js → parse.ts} +103 -81
  505. package/src/importer/native/extract_template.ts +83 -0
  506. package/src/importer/native/file.ts +282 -0
  507. package/src/importer/native/get_images.ts +82 -0
  508. package/src/importer/native/importer.ts +244 -0
  509. package/src/importer/native/index.ts +6 -0
  510. package/src/importer/native/{update.js → update.ts} +13 -5
  511. package/src/importer/native/update_template.ts +32 -0
  512. package/src/importer/odt/{citations.js → citations.ts} +17 -29
  513. package/src/importer/odt/{convert.js → convert.ts} +261 -237
  514. package/src/importer/odt/index.ts +202 -0
  515. package/src/importer/pandoc/{convert.js → convert.ts} +116 -94
  516. package/src/importer/pandoc/{helpers.js → helpers.ts} +24 -12
  517. package/src/importer/pandoc/index.ts +171 -0
  518. package/src/importer/registry.ts +69 -0
  519. package/src/importer/{zip_analyzer.js → zip_analyzer.ts} +44 -18
  520. package/src/mathlive/{opf_includes.js → opf_includes.ts} +1 -1
  521. package/src/modules.d.ts +40 -0
  522. package/src/schema/common/{annotate.js → annotate.ts} +10 -8
  523. package/src/schema/common/{base.js → base.ts} +12 -10
  524. package/src/schema/common/{citation.js → citation.ts} +17 -8
  525. package/src/schema/common/{equation.js → equation.ts} +6 -4
  526. package/src/schema/common/{figure.js → figure.ts} +43 -23
  527. package/src/schema/common/{heading.js → heading.ts} +7 -5
  528. package/src/schema/common/{list.js → list.ts} +15 -13
  529. package/src/schema/common/{reference.js → reference.ts} +14 -12
  530. package/src/schema/common/{table.js → table.ts} +16 -14
  531. package/src/schema/common/{track.js → track.ts} +42 -31
  532. package/src/schema/{convert.js → convert.ts} +6 -2
  533. package/src/schema/document/{content.js → content.ts} +22 -20
  534. package/src/schema/document/{structure.js → structure.ts} +15 -9
  535. package/src/schema/{export.js → export.ts} +4 -2
  536. package/src/schema/{footnotes.js → footnotes.ts} +11 -8
  537. package/src/schema/{footnotes_convert.js → footnotes_convert.ts} +11 -8
  538. package/src/schema/{i18n.js → i18n.ts} +7 -1
  539. package/src/schema/{mini_json.js → mini_json.ts} +11 -12
  540. package/src/schema/{text.js → text.ts} +6 -2
  541. package/src/types.ts +185 -7
  542. package/src/exporter/docx/images.js +0 -101
  543. package/src/exporter/jats/bibliography.js +0 -183
  544. package/src/exporter/jats/index.js +0 -92
  545. package/src/exporter/odt/images.js +0 -115
  546. package/src/importer/citations.js +0 -129
  547. package/src/importer/native/get_images.js +0 -76
  548. /package/src/schema/common/{index.js → index.ts} +0 -0
  549. /package/src/schema/document/{index.js → index.ts} +0 -0
  550. /package/src/schema/{index.js → index.ts} +0 -0
@@ -1,6 +1,7 @@
1
1
  import {MathMLToLaTeX} from "mathml-to-latex"
2
2
 
3
3
  import {xmlDOM} from "../../exporter/tools/xml.js"
4
+ import type {XMLElement} from "../../exporter/tools/xml.js"
4
5
  import {
5
6
  randomCommentId,
6
7
  randomFigureId,
@@ -16,17 +17,42 @@ import {
16
17
  parseOdtBibliographyMark,
17
18
  parseOdtReferenceMark
18
19
  } from "./citations.js"
20
+ import {gettext} from "fwtoolkit"
21
+ import type {BibDB, FidusDoc, FidusNode, ImageDBEntry} from "../../types.js"
22
+
23
+ function attr(node: unknown, name: string): string {
24
+ if (node && typeof node === "object" && "getAttribute" in node) {
25
+ return String((node as XMLElement).getAttribute(name) || "")
26
+ }
27
+ return ""
28
+ }
19
29
 
20
30
  export class OdtConvert {
31
+ importId: string
32
+ template: {content: FidusDoc}
33
+ bibliography: Record<string, any>
34
+ bibDB: BibDB
35
+ images: Record<number, ImageDBEntry>
36
+ styles: Record<string, any>
37
+ contentDoc: XMLElement | null
38
+ stylesDoc: XMLElement | null
39
+ metaDoc: XMLElement | null
40
+ manifestDoc: XMLElement | null
41
+ tracks: Record<string, any>
42
+ comments: Record<string, any>
43
+ currentCommentIds: string[]
44
+ currentTracks: any[]
45
+ referenceableObjects: Record<string, any>
46
+
21
47
  constructor(
22
- contentXml,
23
- stylesXml,
24
- metaXml,
25
- manifestXml,
26
- importId,
27
- template,
28
- bibliography,
29
- bibDb
48
+ contentXml: string,
49
+ stylesXml: string,
50
+ metaXml: string,
51
+ manifestXml: string,
52
+ importId: string,
53
+ template: {content: FidusDoc},
54
+ bibliography: Record<string, any>,
55
+ bibDb: BibDB
30
56
  ) {
31
57
  this.importId = importId
32
58
  this.template = template
@@ -47,7 +73,11 @@ export class OdtConvert {
47
73
  this.referenceableObjects = {} // All objects that can be referenced
48
74
  }
49
75
 
50
- init() {
76
+ init(): {
77
+ content: FidusDoc
78
+ settings: Record<string, any>
79
+ comments: Record<string, any>
80
+ } {
51
81
  this.parseTrackedChanges()
52
82
  this.parseStyles()
53
83
  this.parseComments()
@@ -66,7 +96,10 @@ export class OdtConvert {
66
96
  }
67
97
 
68
98
  parseTrackedChanges() {
69
- const trackedChangesEl = this.contentDoc.query("text:tracked-changes")
99
+ if (!this.contentDoc) {
100
+ return
101
+ }
102
+ const trackedChangesEl = this.contentDoc!.query("text:tracked-changes")
70
103
  if (!trackedChangesEl) {
71
104
  return
72
105
  }
@@ -80,11 +113,11 @@ export class OdtConvert {
80
113
  // This method takes all the deleted content and puts it back into the place where
81
114
  // it was previously. That way the structure is more similar to the output FW document
82
115
  // and is more easily converted.
83
- const deletions = {}
116
+ const deletions: Record<string, any> = {}
84
117
 
85
118
  const changedRegions = trackedChangesEl.queryAll("text:changed-region")
86
- changedRegions.forEach(region => {
87
- const id = region.getAttribute("text:id")
119
+ changedRegions.forEach((region: any) => {
120
+ const id = attr(region, "text:id")
88
121
 
89
122
  const insertion = region.query("text:insertion")
90
123
  const deletion = region.query("text:deletion")
@@ -94,11 +127,11 @@ export class OdtConvert {
94
127
  }
95
128
  const changeInfo = region.query("office:change-info")
96
129
  if (changeInfo) {
97
- const track = {
130
+ const track: Record<string, any> = {
98
131
  type: insertion ? "insertion" : "deletion",
99
132
  user: 1,
100
133
  username: changeInfo.query("dc:creator")?.textContent || "",
101
- date: parseInt(
134
+ date: Math.floor(
102
135
  new Date(
103
136
  changeInfo.query("dc:date")?.textContent || ""
104
137
  ).getTime() / 60000
@@ -112,55 +145,55 @@ export class OdtConvert {
112
145
  if (deletion) {
113
146
  // Store deletion content for later use
114
147
  deletions[id] = deletion.children.filter(
115
- child => child.tagName !== "office:change-info"
148
+ (child: any) => child.tagName !== "office:change-info"
116
149
  )
117
150
  }
118
151
  }
119
152
  })
120
153
 
121
154
  // Then find and replace all deletion change markers
122
- const changeMarkers = this.contentDoc.queryAll("text:change")
123
- changeMarkers.forEach(marker => {
124
- const changeId = marker.getAttribute("text:change-id")
155
+ const changeMarkers = this.contentDoc!.queryAll("text:change")
156
+ changeMarkers.forEach((marker: any) => {
157
+ const changeId = attr(marker, "text:change-id")
125
158
  const deletion = deletions[changeId]
126
159
  if (deletion) {
127
160
  if (deletion.length > 0) {
128
161
  // Create change-start and change-end elements
129
162
  const markerIndex =
130
- marker.parentElement.children.indexOf(marker)
163
+ marker.parentElement!.children.indexOf(marker)
131
164
 
132
- marker.parentElement.insertXMLAt(
165
+ marker.parentElement!.insertXMLAt(
133
166
  `<text:change-start text:change-id="${changeId}"/>`,
134
167
  markerIndex
135
168
  )
136
- marker.parentElement.insertXMLAt(
169
+ marker.parentElement!.insertXMLAt(
137
170
  `<text:change-end text:change-id="${changeId}"/>`,
138
171
  markerIndex + 2
139
172
  )
140
173
 
141
174
  if (deletion.length === 1) {
142
175
  // Single block - just insert the content
143
- deletion[0].children.forEach(content => {
144
- marker.parentElement.insertBefore(content, marker)
176
+ deletion[0].children.forEach((content: any) => {
177
+ marker.parentElement!.insertBefore(content, marker)
145
178
  })
146
179
  } else {
147
180
  // Multiple blocks - need to split the paragraph/headline
148
- const parentElement = marker.parentElement
181
+ const parentElement = marker.parentElement!
149
182
  parentElement.splitAtChildElement(
150
183
  marker,
151
184
  deletion[0].children
152
- ?.map(node => node.toString())
185
+ ?.map((node: any) => node.toString())
153
186
  .join("") || "", // First block content to be added to current node
154
187
  deletion
155
188
  .slice(1, -1)
156
- .map(node => node.toString())
189
+ .map((node: any) => node.toString())
157
190
  .join(""), // Middle blocks
158
191
  deletion[deletion.length - 1].toString() // Last block
159
192
  )
160
193
  }
161
194
  }
162
195
  // Remove the original change marker
163
- marker.parentElement.removeChild(marker)
196
+ marker.parentElement!.removeChild(marker)
164
197
  }
165
198
  })
166
199
  }
@@ -170,42 +203,40 @@ export class OdtConvert {
170
203
  return
171
204
  }
172
205
  const styleNodes = this.stylesDoc.queryAll("style:style")
173
- styleNodes.forEach(node => {
174
- const styleName = node.getAttribute("style:name")
206
+ styleNodes.forEach((node: any) => {
207
+ const styleName = attr(node, "style:name")
175
208
  this.styles[styleName] = this.parseStyle(node)
176
209
  })
177
- const contentStyleNodes = this.contentDoc.queryAll("style:style")
178
- contentStyleNodes.forEach(node => {
179
- const styleName = node.getAttribute("style:name")
210
+ const contentStyleNodes = this.contentDoc!.queryAll("style:style")
211
+ contentStyleNodes.forEach((node: any) => {
212
+ const styleName = attr(node, "style:name")
180
213
  this.styles[styleName] = this.parseStyle(node)
181
214
  })
182
215
  }
183
216
 
184
- parseStyle(styleNode) {
185
- const properties = {
217
+ parseStyle(styleNode: any) {
218
+ const properties: Record<string, any> = {
186
219
  // Basic style information
187
- parentStyleName: styleNode.getAttribute("style:parent-style-name"),
220
+ parentStyleName: attr(styleNode, "style:parent-style-name"),
188
221
  isSection:
189
- styleNode.getAttribute("style:family") === "section" ||
222
+ attr(styleNode, "style:family") === "section" ||
190
223
  Boolean(styleNode.query("style:section-properties")),
191
- title: styleNode.getAttribute("style:display-name"),
224
+ title: attr(styleNode, "style:display-name"),
192
225
 
193
226
  // Family and name info
194
- family: styleNode.getAttribute("style:family"),
195
- name: styleNode.getAttribute("style:name"),
227
+ family: attr(styleNode, "style:family"),
228
+ name: attr(styleNode, "style:name"),
196
229
 
197
230
  // Heading related
198
231
  isHeading:
199
- styleNode.getAttribute("style:family") === "paragraph" &&
200
- (styleNode
201
- .getAttribute("style:name")
232
+ attr(styleNode, "style:family") === "paragraph" &&
233
+ (attr(styleNode, "style:name")
202
234
  .toLowerCase()
203
235
  .includes("heading") ||
204
- styleNode
205
- .getAttribute("style:parent-style-name")
236
+ attr(styleNode, "style:parent-style-name")
206
237
  ?.toLowerCase()
207
238
  .includes("heading")),
208
- outlineLevel: styleNode.getAttribute("text:outline-level"),
239
+ outlineLevel: attr(styleNode, "text:outline-level"),
209
240
 
210
241
  // Text properties
211
242
  textProperties: {},
@@ -221,23 +252,19 @@ export class OdtConvert {
221
252
  const textProperties = styleNode.query("style:text-properties")
222
253
  if (textProperties) {
223
254
  properties.textProperties = {
224
- bold: textProperties.getAttribute("fo:font-weight") === "bold",
255
+ bold: attr(textProperties, "fo:font-weight") === "bold",
225
256
  italic:
226
- textProperties.getAttribute("fo:font-style") === "italic",
257
+ attr(textProperties, "fo:font-style") === "italic",
227
258
  fontSize: this.convertLength(
228
- textProperties.getAttribute("fo:font-size")
229
- ),
230
- fontFamily: textProperties.getAttribute("fo:font-family"),
231
- color: textProperties.getAttribute("fo:color"),
232
- backgroundColor: textProperties.getAttribute(
233
- "fo:background-color"
259
+ attr(textProperties, "fo:font-size")
234
260
  ),
261
+ fontFamily: attr(textProperties, "fo:font-family"),
262
+ color: attr(textProperties, "fo:color"),
263
+ backgroundColor: attr(textProperties, "fo:background-color"),
235
264
  textDecoration:
236
- textProperties.getAttribute("style:text-underline-style") ||
237
- textProperties.getAttribute(
238
- "style:text-line-through-style"
239
- ),
240
- textPosition: textProperties.getAttribute("style:text-position")
265
+ attr(textProperties, "style:text-underline-style") ||
266
+ attr(textProperties, "style:text-line-through-style"),
267
+ textPosition: attr(textProperties, "style:text-position")
241
268
  }
242
269
  }
243
270
 
@@ -248,26 +275,24 @@ export class OdtConvert {
248
275
  if (paragraphProperties) {
249
276
  properties.paragraphProperties = {
250
277
  marginTop: this.convertLength(
251
- paragraphProperties.getAttribute("fo:margin-top")
278
+ attr(paragraphProperties, "fo:margin-top")
252
279
  ),
253
280
  marginBottom: this.convertLength(
254
- paragraphProperties.getAttribute("fo:margin-bottom")
281
+ attr(paragraphProperties, "fo:margin-bottom")
255
282
  ),
256
283
  marginLeft: this.convertLength(
257
- paragraphProperties.getAttribute("fo:margin-left")
284
+ attr(paragraphProperties, "fo:margin-left")
258
285
  ),
259
286
  marginRight: this.convertLength(
260
- paragraphProperties.getAttribute("fo:margin-right")
261
- ),
262
- textAlign: paragraphProperties.getAttribute("fo:text-align"),
263
- lineHeight: paragraphProperties.getAttribute("fo:line-height"),
264
- backgroundColor: paragraphProperties.getAttribute(
265
- "fo:background-color"
287
+ attr(paragraphProperties, "fo:margin-right")
266
288
  ),
289
+ textAlign: attr(paragraphProperties, "fo:text-align"),
290
+ lineHeight: attr(paragraphProperties, "fo:line-height"),
291
+ backgroundColor: attr(paragraphProperties, "fo:background-color"),
267
292
  padding: this.convertLength(
268
- paragraphProperties.getAttribute("fo:padding")
293
+ attr(paragraphProperties, "fo:padding")
269
294
  ),
270
- borderStyle: paragraphProperties.getAttribute("fo:border-style")
295
+ borderStyle: attr(paragraphProperties, "fo:border-style")
271
296
  }
272
297
  }
273
298
 
@@ -275,45 +300,43 @@ export class OdtConvert {
275
300
  const sectionProperties = styleNode.query("style:section-properties")
276
301
  if (sectionProperties) {
277
302
  properties.sectionProperties = {
278
- columnCount: sectionProperties.getAttribute("fo:column-count"),
303
+ columnCount: attr(sectionProperties, "fo:column-count"),
279
304
  columnGap: this.convertLength(
280
- sectionProperties.getAttribute("fo:column-gap")
281
- ),
282
- backgroundColor: sectionProperties.getAttribute(
283
- "fo:background-color"
305
+ attr(sectionProperties, "fo:column-gap")
284
306
  ),
307
+ backgroundColor: attr(sectionProperties, "fo:background-color"),
285
308
  margins: {
286
309
  top: this.convertLength(
287
- sectionProperties.getAttribute("fo:margin-top")
310
+ attr(sectionProperties, "fo:margin-top")
288
311
  ),
289
312
  bottom: this.convertLength(
290
- sectionProperties.getAttribute("fo:margin-bottom")
313
+ attr(sectionProperties, "fo:margin-bottom")
291
314
  ),
292
315
  left: this.convertLength(
293
- sectionProperties.getAttribute("fo:margin-left")
316
+ attr(sectionProperties, "fo:margin-left")
294
317
  ),
295
318
  right: this.convertLength(
296
- sectionProperties.getAttribute("fo:margin-right")
319
+ attr(sectionProperties, "fo:margin-right")
297
320
  )
298
321
  }
299
322
  }
300
323
  }
301
324
 
302
325
  // Additional table-specific properties
303
- if (styleNode.getAttribute("style:family") === "table") {
326
+ if (attr(styleNode, "style:family") === "table") {
304
327
  properties.tableProperties = {
305
- align: styleNode.getAttribute("table:align"),
328
+ align: attr(styleNode, "table:align"),
306
329
  width: this.convertLength(
307
- styleNode.getAttribute("style:width")
330
+ attr(styleNode, "style:width")
308
331
  ),
309
- relWidth: styleNode.getAttribute("style:rel-width")
332
+ relWidth: attr(styleNode, "style:rel-width")
310
333
  }
311
334
  }
312
335
 
313
336
  return properties
314
337
  }
315
338
 
316
- convertObject(node, attrs) {
339
+ convertObject(node: any, attrs: any) {
317
340
  const mathEl = node.query("math")
318
341
  if (mathEl) {
319
342
  attrs = Object.assign(
@@ -331,14 +354,17 @@ export class OdtConvert {
331
354
  }
332
355
 
333
356
  parseComments() {
334
- const annotations = this.contentDoc.queryAll("office:annotation")
335
- annotations.forEach(annotation => {
357
+ if (!this.contentDoc) {
358
+ return
359
+ }
360
+ const annotations = this.contentDoc!.queryAll("office:annotation")
361
+ annotations.forEach((annotation: any) => {
336
362
  const username = annotation.query("dc:creator")?.textContent || ""
337
363
  const date = new Date(
338
364
  annotation.query("dc:date")?.textContent || ""
339
365
  ).getTime()
340
366
 
341
- const id = (annotation.getAttribute("office:name") || "")
367
+ const id = (attr(annotation, "office:name") || "")
342
368
  .replace(/\D/g, "")
343
369
  .slice(0, 9)
344
370
 
@@ -350,16 +376,16 @@ export class OdtConvert {
350
376
  date,
351
377
  comment: annotation
352
378
  .queryAll("text:p")
353
- .map(par => this.convertBlockNode(par))
354
- .filter(par => par)
379
+ .map((par: any) => this.convertBlockNode(par))
380
+ .filter((par: any) => par)
355
381
  .flat(),
356
382
  answers: [],
357
383
  resolved:
358
- annotation.getAttribute("loext:resolved") === "true"
384
+ attr(annotation, "loext:resolved") === "true"
359
385
  }
360
386
  } else {
361
387
  const parentId = (
362
- annotation.getAttribute("loext:parent-name") || ""
388
+ attr(annotation, "loext:parent-name") || ""
363
389
  )
364
390
  .replace(/\D/g, "")
365
391
  .slice(0, 9)
@@ -373,8 +399,8 @@ export class OdtConvert {
373
399
  answer: annotation
374
400
  .queryAll("text:p")
375
401
  .slice(1)
376
- .map(par => this.convertBlockNode(par))
377
- .filter(par => par)
402
+ .map((par: any) => this.convertBlockNode(par))
403
+ .filter((par: any) => par)
378
404
  .flat()
379
405
  })
380
406
  }
@@ -382,11 +408,11 @@ export class OdtConvert {
382
408
  })
383
409
  }
384
410
 
385
- collectReferenceableObjects(node) {
411
+ collectReferenceableObjects(node: any) {
386
412
  // Handle heading bookmarks
387
413
  const bookmarkStarts = node.queryAll("text:bookmark-start")
388
- bookmarkStarts.forEach(mark => {
389
- const refName = mark.getAttribute("text:name")
414
+ bookmarkStarts.forEach((mark: any) => {
415
+ const refName = attr(mark, "text:name")
390
416
  if (!refName) {
391
417
  return
392
418
  }
@@ -409,8 +435,8 @@ export class OdtConvert {
409
435
 
410
436
  // Handle figure sequences
411
437
  const sequences = node.queryAll("text:sequence")
412
- sequences.forEach(sequence => {
413
- const refName = sequence.getAttribute("text:ref-name")
438
+ sequences.forEach((sequence: any) => {
439
+ const refName = attr(sequence, "text:ref-name")
414
440
  if (!refName) {
415
441
  return
416
442
  }
@@ -432,11 +458,11 @@ export class OdtConvert {
432
458
  })
433
459
  }
434
460
 
435
- convert() {
461
+ convert(): FidusDoc {
436
462
  const templateParts = this.template.content.content.slice()
437
463
  templateParts.shift()
438
464
 
439
- const document = {
465
+ const document: any = {
440
466
  type: "doc",
441
467
  attrs: {
442
468
  import_id: this.importId
@@ -464,25 +490,25 @@ export class OdtConvert {
464
490
  ]
465
491
  })
466
492
  }
467
- title.containerNodes.forEach(node => {
468
- node.parentElement.removeChild(node)
493
+ title.containerNodes.forEach((node: any) => {
494
+ node.parentElement!.removeChild(node)
469
495
  })
470
496
 
471
- document.attrs.title =
472
- title.content.map(node => node.textContent).join("") ||
497
+ ;(document.attrs as any).title =
498
+ title.content.map((node: any) => node.textContent).join("") ||
473
499
  gettext("Untitled")
474
500
 
475
501
  // Get all content sections from the ODT
476
- const body = this.contentDoc.query("office:text")
502
+ const body = this.contentDoc!.query("office:text")
477
503
  if (!body) {
478
- return document
504
+ return document as FidusDoc
479
505
  }
480
506
 
481
507
  // Look for metadata sections first (author, abstract, etc.)
482
508
  const metadataContent = this.extractMetadata()
483
- metadataContent.forEach(({type, attrs, content}) => {
509
+ metadataContent.forEach(({type, attrs, content}: any) => {
484
510
  const templatePart = templateParts.find(
485
- part => part.attrs.metadata === type
511
+ (part: any) => part.attrs.metadata === type
486
512
  )
487
513
  if (templatePart) {
488
514
  document.content.push({
@@ -494,8 +520,8 @@ export class OdtConvert {
494
520
  content: content.content
495
521
  })
496
522
  // Remove paragraphs from content so they are not added to body
497
- content.containerNodes.forEach(node => {
498
- node.parentElement.removeChild(node)
523
+ content.containerNodes.forEach((node: any) => {
524
+ node.parentElement!.removeChild(node)
499
525
  })
500
526
  }
501
527
  })
@@ -504,7 +530,7 @@ export class OdtConvert {
504
530
  const sections = this.groupContentIntoSections(body)
505
531
 
506
532
  // Map ODT sections to template parts
507
- sections.forEach(section => {
533
+ sections.forEach((section: any) => {
508
534
  // Find matching template part
509
535
  const templatePart = this.findMatchingTemplatePart(
510
536
  section.title,
@@ -533,41 +559,39 @@ export class OdtConvert {
533
559
  // Add remaining content to body section
534
560
  const unassignedContent = sections
535
561
  .filter(
536
- section =>
562
+ (section: any) =>
537
563
  !this.findMatchingTemplatePart(section.title, templateParts)
538
564
  )
539
- .flatMap(section => section.content)
565
+ .flatMap((section: any) => section.content)
540
566
 
541
567
  if (unassignedContent.length) {
542
568
  // Find default body template part
543
569
  const bodyTemplatePart = templateParts.find(
544
- part => !part.attrs.metadata && part.type === "richtext_part"
570
+ (part: any) => !part.attrs.metadata && part.type === "richtext_part"
545
571
  )
546
572
 
547
573
  document.content.push({
548
574
  type: "richtext_part",
549
575
  attrs: {
550
- title: bodyTemplatePart
551
- ? bodyTemplatePart.attrs.title
552
- : "Body",
553
- id: bodyTemplatePart ? bodyTemplatePart.attrs.id : "body",
576
+ title: bodyTemplatePart?.attrs?.title || "Body",
577
+ id: bodyTemplatePart?.attrs?.id || "body",
554
578
  marks: ["strong", "em", "link"]
555
579
  },
556
580
  content: unassignedContent
557
581
  })
558
582
  }
559
583
 
560
- return document
584
+ return document as FidusDoc
561
585
  }
562
586
 
563
587
  extractMetadata() {
564
- const metadata = []
588
+ const metadata: any[] = []
565
589
 
566
590
  // Try structured contributor data from meta.xml first
567
591
  const contributorsByRole = this.extractContributorsFromMeta()
568
592
  if (Object.keys(contributorsByRole).length) {
569
593
  Object.entries(contributorsByRole).forEach(
570
- ([role, contributors]) => {
594
+ ([role, contributors]: any) => {
571
595
  metadata.push({
572
596
  type: role,
573
597
  content: {content: contributors, containerNodes: []}
@@ -612,10 +636,10 @@ export class OdtConvert {
612
636
  }
613
637
 
614
638
  const userDefined = this.metaDoc.queryAll("meta:user-defined")
615
- const contributors = []
639
+ const contributors: any[] = []
616
640
 
617
- userDefined.forEach(prop => {
618
- const name = prop.getAttribute("meta:name")
641
+ userDefined.forEach((prop: any) => {
642
+ const name = attr(prop, "meta:name")
619
643
  if (!name || !name.startsWith("fidus_contributor_")) {
620
644
  return
621
645
  }
@@ -657,8 +681,8 @@ export class OdtConvert {
657
681
  }
658
682
  })
659
683
 
660
- const byRole = {}
661
- contributors.forEach(contributor => {
684
+ const byRole: Record<string, any> = {}
685
+ contributors.forEach((contributor: any) => {
662
686
  if (!contributor) {
663
687
  return
664
688
  }
@@ -673,13 +697,13 @@ export class OdtConvert {
673
697
  }
674
698
 
675
699
  extractAuthors() {
676
- const authors = []
700
+ const authors: any[] = []
677
701
 
678
702
  // Try to find author information in metadata
679
- const metaAuthors = this.contentDoc.queryAll("meta:user-defined", {
703
+ const metaAuthors = this.contentDoc!.queryAll("meta:user-defined", {
680
704
  "meta:name": "author"
681
705
  })
682
- metaAuthors.forEach(authorMeta => {
706
+ metaAuthors.forEach((authorMeta: any) => {
683
707
  const authorText = authorMeta.textContent
684
708
  const [firstname = "", lastname = ""] = authorText.split(" ", 2)
685
709
  authors.push({
@@ -700,7 +724,7 @@ export class OdtConvert {
700
724
  }
701
725
 
702
726
  // Also check for creator in document metadata
703
- const creator = this.contentDoc.query("meta:creator")
727
+ const creator = this.contentDoc!.query("meta:creator")
704
728
  if (creator) {
705
729
  const [firstname = "", lastname = ""] = creator.textContent.split(
706
730
  " ",
@@ -728,16 +752,16 @@ export class OdtConvert {
728
752
  extractAbstract() {
729
753
  // Look for section titled "Abstract" or with abstract style
730
754
  const abstractSection =
731
- this.contentDoc.query("text:section", {
755
+ this.contentDoc!.query("text:section", {
732
756
  "text:style-name": "Abstract"
733
757
  }) ||
734
- this.contentDoc.query("text:h", {
758
+ this.contentDoc!.query("text:h", {
735
759
  "text:outline-level": "1"
736
760
  }) // Then check content for "Abstract"
737
761
 
738
762
  if (
739
763
  abstractSection &&
740
- (abstractSection.getAttribute("text:style-name") === "Abstract" ||
764
+ (attr(abstractSection, "text:style-name") === "Abstract" ||
741
765
  abstractSection.textContent.includes("Abstract"))
742
766
  ) {
743
767
  return {
@@ -755,8 +779,8 @@ export class OdtConvert {
755
779
  extractKeywords() {
756
780
  // Look for keywords section or metadata
757
781
  const keywordsSection =
758
- this.contentDoc.query("text:p", {"text:style-name": "Keywords"}) ||
759
- this.contentDoc.query("meta:user-defined", {
782
+ this.contentDoc!.query("text:p", {"text:style-name": "Keywords"}) ||
783
+ this.contentDoc!.query("meta:user-defined", {
760
784
  "meta:name": "keywords"
761
785
  })
762
786
 
@@ -770,14 +794,14 @@ export class OdtConvert {
770
794
  return {content: [], containerNodes: []}
771
795
  }
772
796
 
773
- findMatchingTemplatePart(sectionTitle, templateParts) {
797
+ findMatchingTemplatePart(sectionTitle: any, templateParts: any) {
774
798
  if (!sectionTitle) {
775
799
  return null
776
800
  }
777
801
 
778
802
  // Try exact match first
779
803
  let matchingPart = templateParts.find(
780
- part =>
804
+ (part: any) =>
781
805
  part.type === "richtext_part" &&
782
806
  !part.attrs.metadata &&
783
807
  part.attrs.title.toLowerCase() === sectionTitle.toLowerCase()
@@ -786,7 +810,7 @@ export class OdtConvert {
786
810
  if (!matchingPart) {
787
811
  // Try fuzzy matching if exact match fails
788
812
  matchingPart = templateParts.find(
789
- part =>
813
+ (part: any) =>
790
814
  part.type === "richtext_part" &&
791
815
  !part.attrs.metadata &&
792
816
  this.isSimilarTitle(part.attrs.title, sectionTitle)
@@ -796,9 +820,9 @@ export class OdtConvert {
796
820
  return matchingPart
797
821
  }
798
822
 
799
- isSimilarTitle(title1, title2) {
823
+ isSimilarTitle(title1: any, title2: any) {
800
824
  // Remove special characters and extra spaces
801
- const normalize = str =>
825
+ const normalize = (str: any) =>
802
826
  str
803
827
  .toLowerCase()
804
828
  .replace(/[^a-z0-9]/g, "")
@@ -816,7 +840,7 @@ export class OdtConvert {
816
840
 
817
841
  extractTitle() {
818
842
  // First try to find paragraph with Title style
819
- const titleParagraph = this.contentDoc.query("text:p", {
843
+ const titleParagraph = this.contentDoc!.query("text:p", {
820
844
  "text:style-name": "Title"
821
845
  })
822
846
  if (titleParagraph) {
@@ -827,7 +851,7 @@ export class OdtConvert {
827
851
  }
828
852
 
829
853
  // Fall back to first heading
830
- const titleHeading = this.contentDoc.query("text:h", {
854
+ const titleHeading = this.contentDoc!.query("text:h", {
831
855
  "text:outline-level": "1"
832
856
  })
833
857
  if (titleHeading) {
@@ -838,14 +862,14 @@ export class OdtConvert {
838
862
  }
839
863
 
840
864
  // Check for other common title style names
841
- const commonTitleStyles = [
865
+ const commonTitleStyles: any[] = [
842
866
  "title",
843
867
  "doctitle",
844
868
  "document-title",
845
869
  "heading-title"
846
870
  ]
847
871
  for (const styleName of commonTitleStyles) {
848
- const titleElement = this.contentDoc.query("text:p", {
872
+ const titleElement = this.contentDoc!.query("text:p", {
849
873
  "text:style-name": styleName
850
874
  })
851
875
  if (titleElement) {
@@ -857,9 +881,9 @@ export class OdtConvert {
857
881
  }
858
882
 
859
883
  // Check style properties for title-like formatting
860
- const firstParagraph = this.contentDoc.query("text:p")
884
+ const firstParagraph = this.contentDoc!.query("text:p")
861
885
  if (firstParagraph) {
862
- const styleName = firstParagraph.getAttribute("text:style-name")
886
+ const styleName = attr(firstParagraph, "text:style-name")
863
887
  const style = this.styles[styleName]
864
888
 
865
889
  if (style && this.isTitleStyle(style)) {
@@ -878,7 +902,7 @@ export class OdtConvert {
878
902
  }
879
903
  }
880
904
 
881
- isTitleStyle(style) {
905
+ isTitleStyle(style: any): boolean {
882
906
  // Check if style or its parent has characteristics of a title style
883
907
  if (!style) {
884
908
  return false
@@ -919,7 +943,7 @@ export class OdtConvert {
919
943
  return false
920
944
  }
921
945
 
922
- getSectionTitle(node, styleName) {
946
+ getSectionTitle(node: any, styleName: any) {
923
947
  if (!node || !styleName) {
924
948
  return null
925
949
  }
@@ -927,7 +951,7 @@ export class OdtConvert {
927
951
  // For headings, use the text content as section title
928
952
  if (node.tagName === "text:h") {
929
953
  // Get the heading level
930
- const level = parseInt(node.getAttribute("text:outline-level")) || 1
954
+ const level = parseInt(attr(node, "text:outline-level")) || 1
931
955
 
932
956
  // Only use level 1 and 2 headings as section titles
933
957
  if (level <= 2) {
@@ -961,7 +985,7 @@ export class OdtConvert {
961
985
 
962
986
  // For text:section elements, check for section-name attribute
963
987
  if (node.tagName === "text:section") {
964
- const sectionName = node.getAttribute("text:name")
988
+ const sectionName = attr(node, "text:name")
965
989
  if (sectionName) {
966
990
  return this.formatSectionName(sectionName)
967
991
  }
@@ -970,7 +994,7 @@ export class OdtConvert {
970
994
  return null
971
995
  }
972
996
 
973
- formatSectionName(name) {
997
+ formatSectionName(name: any) {
974
998
  // Remove common suffixes
975
999
  name = name.replace(/_?(section|part|chapter)$/i, "")
976
1000
 
@@ -980,22 +1004,22 @@ export class OdtConvert {
980
1004
  // Capitalize first letter of each word and join
981
1005
  return words
982
1006
  .map(
983
- word =>
1007
+ (word: any) =>
984
1008
  word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()
985
1009
  )
986
1010
  .join(" ")
987
1011
  .trim()
988
1012
  }
989
1013
 
990
- groupContentIntoSections(body) {
991
- const sections = []
992
- let currentSection = {
1014
+ groupContentIntoSections(body: any) {
1015
+ const sections: any[] = []
1016
+ let currentSection: Record<string, any> = {
993
1017
  title: null,
994
1018
  content: []
995
1019
  }
996
1020
 
997
- body.children.forEach(node => {
998
- const styleName = node.getAttribute("text:style-name")
1021
+ body.children.forEach((node: any) => {
1022
+ const styleName = attr(node, "text:style-name")
999
1023
  const title = this.getSectionTitle(node, styleName)
1000
1024
 
1001
1025
  if (title && this.isHeadingStyle(styleName)) {
@@ -1010,9 +1034,9 @@ export class OdtConvert {
1010
1034
  }
1011
1035
 
1012
1036
  const converted = [this.convertBlockNode(node)]
1013
- .filter(node => node)
1037
+ .filter((node: any) => node)
1014
1038
  .flat()
1015
- converted.forEach(node => currentSection.content.push(node))
1039
+ converted.forEach((node: any) => currentSection.content.push(node))
1016
1040
  })
1017
1041
 
1018
1042
  // Add final section
@@ -1023,7 +1047,7 @@ export class OdtConvert {
1023
1047
  return sections
1024
1048
  }
1025
1049
 
1026
- isCodeBlockStyle(styleName, style) {
1050
+ isCodeBlockStyle(styleName: any, style: any): boolean {
1027
1051
  if (!styleName) {
1028
1052
  return false
1029
1053
  }
@@ -1047,7 +1071,7 @@ export class OdtConvert {
1047
1071
  // Check text properties for monospace fonts
1048
1072
  if (style?.textProperties?.fontFamily) {
1049
1073
  const fontFamily = style.textProperties.fontFamily.toLowerCase()
1050
- const monospacePatterns = [
1074
+ const monospacePatterns: any[] = [
1051
1075
  "courier",
1052
1076
  "consolas",
1053
1077
  "monaco",
@@ -1059,7 +1083,7 @@ export class OdtConvert {
1059
1083
  "source code pro",
1060
1084
  "fira code"
1061
1085
  ]
1062
- return monospacePatterns.some(pattern =>
1086
+ return monospacePatterns.some((pattern: any) =>
1063
1087
  fontFamily.includes(pattern)
1064
1088
  )
1065
1089
  }
@@ -1067,7 +1091,7 @@ export class OdtConvert {
1067
1091
  return false
1068
1092
  }
1069
1093
 
1070
- isHeadingStyle(styleName) {
1094
+ isHeadingStyle(styleName: any): boolean {
1071
1095
  if (!styleName) {
1072
1096
  return false
1073
1097
  }
@@ -1106,15 +1130,15 @@ export class OdtConvert {
1106
1130
  )
1107
1131
  }
1108
1132
 
1109
- convertContainer(container) {
1133
+ convertContainer(container: any) {
1110
1134
  return container.children
1111
- .map(node => this.convertBlockNode(node))
1112
- .filter(node => node)
1135
+ .map((node: any) => this.convertBlockNode(node))
1136
+ .filter((node: any) => node)
1113
1137
  .flat()
1114
1138
  }
1115
1139
 
1116
- convertBlockNode(node) {
1117
- const track = this.currentTracks.map(track => ({
1140
+ convertBlockNode(node: any) {
1141
+ const track = this.currentTracks.map((track: any) => ({
1118
1142
  type: track.type,
1119
1143
  user: track.attrs.user,
1120
1144
  username: track.attrs.username,
@@ -1155,7 +1179,7 @@ export class OdtConvert {
1155
1179
  // Skip bibliography sections inserted by citation managers
1156
1180
  // (Zotero: name contains "ZOTERO_BIBL"/"CSL_BIBLIOGRAPHY",
1157
1181
  // JabRef: name is "JR_bib" / "JR_BIB").
1158
- const sectionName = node.getAttribute("text:name") || ""
1182
+ const sectionName = attr(node, "text:name") || ""
1159
1183
  if (isOdtBibliographySection(sectionName)) {
1160
1184
  return null
1161
1185
  }
@@ -1169,8 +1193,8 @@ export class OdtConvert {
1169
1193
  }
1170
1194
  }
1171
1195
 
1172
- convertParagraph(node, attrs = {}) {
1173
- const styleName = node.getAttribute("text:style-name")
1196
+ convertParagraph(node: any, attrs: any = {}) {
1197
+ const styleName = attr(node, "text:style-name")
1174
1198
  const style = this.styles[styleName]
1175
1199
 
1176
1200
  // Check if this is a code block (preformatted text)
@@ -1218,15 +1242,15 @@ export class OdtConvert {
1218
1242
  }
1219
1243
  }
1220
1244
 
1221
- convertHeading(node, attrs = {}) {
1245
+ convertHeading(node: any, attrs: any = {}) {
1222
1246
  const level =
1223
- parseInt(node.getAttribute("text:outline-level") || 1) || 1
1247
+ parseInt(attr(node, "text:outline-level") || "1") || 1
1224
1248
 
1225
1249
  // Check for bookmark
1226
1250
  let id = null
1227
1251
  const bookmarkStart = node.query("text:bookmark-start")
1228
1252
  if (bookmarkStart) {
1229
- const refName = bookmarkStart.getAttribute("text:name")
1253
+ const refName = attr(bookmarkStart, "text:name")
1230
1254
  if (refName && this.referenceableObjects[refName]) {
1231
1255
  id = this.referenceableObjects[refName].id
1232
1256
  }
@@ -1244,17 +1268,17 @@ export class OdtConvert {
1244
1268
  }
1245
1269
  }
1246
1270
 
1247
- convertNodeChildren(node, currentStyleMarks = []) {
1271
+ convertNodeChildren(node: any, currentStyleMarks: any = []) {
1248
1272
  let insideCitationReferenceMark = false
1249
1273
  let insideBibliographyReferenceMark = false
1250
1274
 
1251
1275
  return node.children
1252
- .map(child => {
1276
+ .map((child: any) => {
1253
1277
  if (insideBibliographyReferenceMark) {
1254
1278
  // Swallow all rendered bibliography content until the
1255
1279
  // closing mark — we have our own bibliography system.
1256
1280
  if (child.tagName === "text:reference-mark-end") {
1257
- const name = child.getAttribute("text:name")
1281
+ const name = attr(child, "text:name")
1258
1282
  if (name && isOdtBibliographyReferenceMark(name)) {
1259
1283
  insideBibliographyReferenceMark = false
1260
1284
  }
@@ -1265,7 +1289,7 @@ export class OdtConvert {
1265
1289
  if (insideCitationReferenceMark) {
1266
1290
  if (child.tagName === "text:reference-mark-end") {
1267
1291
  // Process citation when we hit the end mark
1268
- const name = child.getAttribute("text:name")
1292
+ const name = attr(child, "text:name")
1269
1293
  if (name && isOdtCitationMark(name)) {
1270
1294
  insideCitationReferenceMark = false
1271
1295
  return this.convertCitation(name, currentStyleMarks)
@@ -1276,10 +1300,10 @@ export class OdtConvert {
1276
1300
 
1277
1301
  switch (child.tagName) {
1278
1302
  case "text:change-start": {
1279
- const changeId = child.getAttribute("text:change-id")
1303
+ const changeId = attr(child, "text:change-id")
1280
1304
  const track = this.tracks[changeId]
1281
1305
  if (track) {
1282
- const trackMark = {
1306
+ const trackMark: Record<string, any> = {
1283
1307
  type: track.type,
1284
1308
  attrs: {
1285
1309
  user: track.user,
@@ -1295,11 +1319,11 @@ export class OdtConvert {
1295
1319
  return null
1296
1320
  }
1297
1321
  case "text:change-end": {
1298
- const changeId = child.getAttribute("text:change-id")
1322
+ const changeId = attr(child, "text:change-id")
1299
1323
  const track = this.tracks[changeId]
1300
1324
  if (track) {
1301
1325
  this.currentTracks = this.currentTracks.filter(
1302
- mark => mark.type !== track.type
1326
+ (mark: any) => mark.type !== track.type
1303
1327
  )
1304
1328
  }
1305
1329
  return null
@@ -1323,7 +1347,7 @@ export class OdtConvert {
1323
1347
  case "office:annotation-end":
1324
1348
  return this.convertAnnotationEnd(child)
1325
1349
  case "text:reference-mark-start": {
1326
- const name = child.getAttribute("text:name")
1350
+ const name = attr(child, "text:name")
1327
1351
  if (name && isOdtCitationMark(name)) {
1328
1352
  insideCitationReferenceMark = true
1329
1353
  } else if (
@@ -1351,14 +1375,14 @@ export class OdtConvert {
1351
1375
  )
1352
1376
  }
1353
1377
  })
1354
- .filter(node => node)
1378
+ .filter((node: any) => node)
1355
1379
  .flat()
1356
1380
  }
1357
1381
 
1358
- getCurrentMarks(currentStyleMarks = []) {
1359
- const commentMarks = []
1382
+ getCurrentMarks(currentStyleMarks: any = []) {
1383
+ const commentMarks: any[] = []
1360
1384
  // Add comment marks for any active comment IDs
1361
- this.currentCommentIds.forEach(commentId => {
1385
+ this.currentCommentIds.forEach((commentId: any) => {
1362
1386
  commentMarks.push({
1363
1387
  type: "comment",
1364
1388
  attrs: {
@@ -1369,8 +1393,8 @@ export class OdtConvert {
1369
1393
  return [...currentStyleMarks, ...this.currentTracks, ...commentMarks]
1370
1394
  }
1371
1395
 
1372
- convertText(text, currentStyleMarks) {
1373
- const textNode = {
1396
+ convertText(text: any, currentStyleMarks: any) {
1397
+ const textNode: Record<string, any> = {
1374
1398
  type: "text",
1375
1399
  text
1376
1400
  }
@@ -1381,8 +1405,8 @@ export class OdtConvert {
1381
1405
  return textNode
1382
1406
  }
1383
1407
 
1384
- convertSpan(node, currentStyleMarks) {
1385
- const styleName = node.getAttribute("text:style-name")
1408
+ convertSpan(node: any, currentStyleMarks: any) {
1409
+ const styleName = attr(node, "text:style-name")
1386
1410
  const style = this.styles[styleName]
1387
1411
  if (style?.textProperties?.bold) {
1388
1412
  currentStyleMarks = [...currentStyleMarks, {type: "strong"}]
@@ -1402,7 +1426,7 @@ export class OdtConvert {
1402
1426
  // Handle inline code (monospace fonts)
1403
1427
  if (style?.textProperties?.fontFamily) {
1404
1428
  const fontFamily = style.textProperties.fontFamily.toLowerCase()
1405
- const monospacePatterns = [
1429
+ const monospacePatterns: any[] = [
1406
1430
  "courier",
1407
1431
  "consolas",
1408
1432
  "monaco",
@@ -1417,7 +1441,7 @@ export class OdtConvert {
1417
1441
  "droid sans mono",
1418
1442
  "monospace"
1419
1443
  ]
1420
- const isMonospace = monospacePatterns.some(pattern =>
1444
+ const isMonospace = monospacePatterns.some((pattern: any) =>
1421
1445
  fontFamily.includes(pattern)
1422
1446
  )
1423
1447
  if (isMonospace) {
@@ -1427,7 +1451,7 @@ export class OdtConvert {
1427
1451
  return this.convertNodeChildren(node, currentStyleMarks)
1428
1452
  }
1429
1453
 
1430
- convertFootnote(node, currentStyleMarks) {
1454
+ convertFootnote(node: any, currentStyleMarks: any) {
1431
1455
  const noteBody = node.query("text:note-body")
1432
1456
  if (!noteBody) {
1433
1457
  return null
@@ -1445,7 +1469,7 @@ export class OdtConvert {
1445
1469
  )
1446
1470
  const referenceMarkEnd = firstParagraph.query("text:reference-mark-end")
1447
1471
 
1448
- const markName = referenceMarkStart?.getAttribute("text:name")
1472
+ const markName = attr(referenceMarkStart, "text:name")
1449
1473
  if (
1450
1474
  referenceMarkStart &&
1451
1475
  referenceMarkEnd &&
@@ -1453,7 +1477,7 @@ export class OdtConvert {
1453
1477
  isOdtCitationMark(markName) &&
1454
1478
  // Check that there's no content outside the reference marks
1455
1479
  firstParagraph.children.every(
1456
- child =>
1480
+ (child: any) =>
1457
1481
  child.tagName === "text:reference-mark-start" ||
1458
1482
  child.tagName === "text:reference-mark-end" ||
1459
1483
  (child.tagName === "text:span" &&
@@ -1477,7 +1501,7 @@ export class OdtConvert {
1477
1501
  }
1478
1502
  }
1479
1503
 
1480
- convertCitation(markName, currentStyleMarks) {
1504
+ convertCitation(markName: any, currentStyleMarks: any) {
1481
1505
  const citationNode = parseOdtReferenceMark(
1482
1506
  markName,
1483
1507
  this.bibliography,
@@ -1490,7 +1514,7 @@ export class OdtConvert {
1490
1514
  return null
1491
1515
  }
1492
1516
 
1493
- convertBibliographyMark(bibMarkNode, currentStyleMarks) {
1517
+ convertBibliographyMark(bibMarkNode: any, currentStyleMarks: any) {
1494
1518
  const citationNode = parseOdtBibliographyMark(
1495
1519
  bibMarkNode,
1496
1520
  this.bibliography
@@ -1502,8 +1526,8 @@ export class OdtConvert {
1502
1526
  return null
1503
1527
  }
1504
1528
 
1505
- convertList(node, attrs) {
1506
- const listStyle = node.getAttribute("text:style-name")
1529
+ convertList(node: any, attrs: any) {
1530
+ const listStyle = attr(node, "text:style-name")
1507
1531
  const isOrdered = this.isOrderedList(listStyle)
1508
1532
 
1509
1533
  attrs = Object.assign(
@@ -1520,15 +1544,15 @@ export class OdtConvert {
1520
1544
  return {
1521
1545
  type: isOrdered ? "ordered_list" : "bullet_list",
1522
1546
  attrs,
1523
- content: node.queryAll("text:list-item").map(item => ({
1547
+ content: node.queryAll("text:list-item").map((item: any) => ({
1524
1548
  type: "list_item",
1525
1549
  content: this.convertContainer(item)
1526
1550
  }))
1527
1551
  }
1528
1552
  }
1529
1553
 
1530
- convertAnnotationStart(node) {
1531
- const commentId = (node.getAttribute("office:name") || "")
1554
+ convertAnnotationStart(node: any) {
1555
+ const commentId = (attr(node, "office:name") || "")
1532
1556
  .replace(/\D/g, "")
1533
1557
  .slice(0, 9)
1534
1558
  if (commentId && this.comments[commentId]) {
@@ -1537,8 +1561,8 @@ export class OdtConvert {
1537
1561
  return null
1538
1562
  }
1539
1563
 
1540
- convertAnnotationEnd(node) {
1541
- const commentId = (node.getAttribute("office:name") || "")
1564
+ convertAnnotationEnd(node: any) {
1565
+ const commentId = (attr(node, "office:name") || "")
1542
1566
  .replace(/\D/g, "")
1543
1567
  .slice(0, 9)
1544
1568
  if (commentId) {
@@ -1550,8 +1574,8 @@ export class OdtConvert {
1550
1574
  return null
1551
1575
  }
1552
1576
 
1553
- convertHeadingReference(node) {
1554
- const refName = node.getAttribute("text:ref-name")
1577
+ convertHeadingReference(node: any) {
1578
+ const refName = attr(node, "text:ref-name")
1555
1579
  if (!refName || !this.referenceableObjects[refName]) {
1556
1580
  return null
1557
1581
  }
@@ -1570,8 +1594,8 @@ export class OdtConvert {
1570
1594
  }
1571
1595
  }
1572
1596
 
1573
- convertFigureReference(node) {
1574
- const refName = node.getAttribute("text:ref-name")
1597
+ convertFigureReference(node: any) {
1598
+ const refName = attr(node, "text:ref-name")
1575
1599
  if (!refName || !this.referenceableObjects[refName]) {
1576
1600
  return null
1577
1601
  }
@@ -1593,7 +1617,7 @@ export class OdtConvert {
1593
1617
  }
1594
1618
  }
1595
1619
 
1596
- isOrderedList(styleName) {
1620
+ isOrderedList(styleName: any) {
1597
1621
  if (!this.stylesDoc) {
1598
1622
  return false
1599
1623
  }
@@ -1603,7 +1627,7 @@ export class OdtConvert {
1603
1627
  return listStyle?.query("text:list-level-style-number") !== null
1604
1628
  }
1605
1629
 
1606
- convertImage(node, attrs = {}) {
1630
+ convertImage(node: any, attrs: any = {}) {
1607
1631
  const imageElement = node.query("draw:image")
1608
1632
  if (!imageElement) {
1609
1633
  return null
@@ -1614,14 +1638,14 @@ export class OdtConvert {
1614
1638
  return null
1615
1639
  }
1616
1640
 
1617
- const href = imageElement.getAttribute("xlink:href")
1641
+ const href = attr(imageElement, "xlink:href")
1618
1642
  if (!href || !href.startsWith("Pictures/")) {
1619
1643
  return null
1620
1644
  }
1621
1645
 
1622
1646
  const imageId = Math.floor(Math.random() * 1000000)
1623
- const width = this.convertLength(node.getAttribute("svg:width"))
1624
- const height = this.convertLength(node.getAttribute("svg:height"))
1647
+ const width = this.convertLength(attr(node, "svg:width"))
1648
+ const height = this.convertLength(attr(node, "svg:height"))
1625
1649
 
1626
1650
  const title = href.split("/").pop()
1627
1651
  this.images[imageId] = {
@@ -1645,7 +1669,7 @@ export class OdtConvert {
1645
1669
  const sequence = frame.query("text:sequence")
1646
1670
  let figureId = null
1647
1671
  if (sequence) {
1648
- const refName = sequence.getAttribute("text:ref-name")
1672
+ const refName = attr(sequence, "text:ref-name")
1649
1673
  if (refName && this.referenceableObjects[refName]) {
1650
1674
  figureId = this.referenceableObjects[refName].id
1651
1675
  }
@@ -1664,7 +1688,7 @@ export class OdtConvert {
1664
1688
  attrs
1665
1689
  )
1666
1690
 
1667
- const figureCaption = {type: "figure_caption"}
1691
+ const figureCaption: Record<string, any> = {type: "figure_caption"}
1668
1692
  if (captionContent.length) {
1669
1693
  figureCaption.content = captionContent
1670
1694
  }
@@ -1684,7 +1708,7 @@ export class OdtConvert {
1684
1708
  }
1685
1709
  }
1686
1710
 
1687
- getImageFileType(filename) {
1711
+ getImageFileType(filename: any) {
1688
1712
  const ext = filename.split(".").pop().toLowerCase()
1689
1713
  switch (ext) {
1690
1714
  case "avif":
@@ -1706,7 +1730,7 @@ export class OdtConvert {
1706
1730
  }
1707
1731
  }
1708
1732
 
1709
- convertLength(length) {
1733
+ convertLength(length: any) {
1710
1734
  if (!length) {
1711
1735
  return 0
1712
1736
  }
@@ -1741,17 +1765,17 @@ export class OdtConvert {
1741
1765
  }
1742
1766
  }
1743
1767
 
1744
- convertTable(node, attrs) {
1768
+ convertTable(node: any, attrs: any) {
1745
1769
  const width =
1746
- node.getAttribute("style:rel-width")?.replace("%", "") || "100"
1747
- const styleName = node.getAttribute("table:style-name")
1770
+ attr(node, "style:rel-width")?.replace("%", "") || "100"
1771
+ const styleName = attr(node, "table:style-name")
1748
1772
  const style = this.styles[styleName]
1749
1773
  const aligned = style?.tableProperties.align || "center"
1750
1774
 
1751
1775
  attrs = Object.assign(
1752
1776
  {
1753
1777
  id: randomTableId(),
1754
- track: parseTracks(node.getAttribute("text:change-id")),
1778
+ track: parseTracks(attr(node, "text:change-id")),
1755
1779
  width,
1756
1780
  aligned,
1757
1781
  layout: "fixed",
@@ -1769,22 +1793,22 @@ export class OdtConvert {
1769
1793
  type: "table_body",
1770
1794
  content: node
1771
1795
  .queryAll("table:table-row")
1772
- .map(row => this.convertTableRow(row))
1796
+ .map((row: any) => this.convertTableRow(row))
1773
1797
  }
1774
1798
  ]
1775
1799
  }
1776
1800
  }
1777
1801
 
1778
- convertTableRow(row) {
1802
+ convertTableRow(row: any) {
1779
1803
  return {
1780
1804
  type: "table_row",
1781
1805
  content: row
1782
1806
  .queryAll(["table:table-cell", "table:covered-table-cell"])
1783
- .map(cell => this.convertTableCell(cell))
1807
+ .map((cell: any) => this.convertTableCell(cell))
1784
1808
  }
1785
1809
  }
1786
1810
 
1787
- convertTableCell(node) {
1811
+ convertTableCell(node: any) {
1788
1812
  if (node.tagName === "table:covered-table-cell") {
1789
1813
  return null
1790
1814
  }
@@ -1793,19 +1817,19 @@ export class OdtConvert {
1793
1817
  attrs: {
1794
1818
  colspan:
1795
1819
  parseInt(
1796
- node.getAttribute("table:number-columns-spanned")
1820
+ attr(node, "table:number-columns-spanned")
1797
1821
  ) || 1,
1798
1822
  rowspan:
1799
- parseInt(node.getAttribute("table:number-rows-spanned")) ||
1823
+ parseInt(attr(node, "table:number-rows-spanned")) ||
1800
1824
  1,
1801
- track: parseTracks(node.getAttribute("text:change-id"))
1825
+ track: parseTracks(attr(node, "text:change-id"))
1802
1826
  },
1803
1827
  content: this.convertContainer(node)
1804
1828
  }
1805
1829
  }
1806
1830
 
1807
- convertLink(node, currentStyleMarks) {
1808
- const href = node.getAttribute("xlink:href")
1831
+ convertLink(node: any, currentStyleMarks: any) {
1832
+ const href = attr(node, "xlink:href")
1809
1833
  currentStyleMarks = currentStyleMarks.concat([
1810
1834
  {type: "link", attrs: {href}}
1811
1835
  ])
@@ -1821,15 +1845,15 @@ export class OdtConvert {
1821
1845
  // Check content language
1822
1846
  if (this.contentDoc) {
1823
1847
  const langAttr =
1824
- this.contentDoc.getAttribute("office:default-language") ||
1825
- this.contentDoc.getAttribute("dc:language")
1848
+ attr(this.contentDoc, "office:default-language") ||
1849
+ attr(this.contentDoc, "dc:language")
1826
1850
  if (langAttr) {
1827
1851
  return langAttr
1828
1852
  }
1829
1853
 
1830
- const firstParagraph = this.contentDoc.query("text:p")
1854
+ const firstParagraph = this.contentDoc!.query("text:p")
1831
1855
  if (firstParagraph) {
1832
- const paraLang = firstParagraph.getAttribute("xml:lang")
1856
+ const paraLang = attr(firstParagraph, "xml:lang")
1833
1857
  if (paraLang) {
1834
1858
  return paraLang
1835
1859
  }
@@ -1841,8 +1865,8 @@ export class OdtConvert {
1841
1865
  const defaultStyle = this.stylesDoc.query("style:default-style")
1842
1866
  if (defaultStyle) {
1843
1867
  const styleLang =
1844
- defaultStyle.getAttribute("fo:language") ||
1845
- defaultStyle.getAttribute("style:language-complex")
1868
+ attr(defaultStyle, "fo:language") ||
1869
+ attr(defaultStyle, "style:language-complex")
1846
1870
  if (styleLang) {
1847
1871
  return styleLang
1848
1872
  }