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

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 (410) hide show
  1. package/README.md +22 -1
  2. package/dist/bibliography/common.d.ts +92 -0
  3. package/dist/bibliography/common.d.ts.map +1 -0
  4. package/dist/bibliography/common.js +85 -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 +13 -0
  11. package/dist/citations/citeproc_sys.d.ts.map +1 -0
  12. package/dist/citations/citeproc_sys.js +43 -0
  13. package/dist/citations/citeproc_sys.js.map +1 -0
  14. package/dist/citations/format.d.ts +23 -0
  15. package/dist/citations/format.d.ts.map +1 -0
  16. package/dist/citations/format.js +161 -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 +21 -0
  23. package/dist/exporter/docx/citations.d.ts.map +1 -0
  24. package/dist/exporter/docx/citations.js +154 -0
  25. package/dist/exporter/docx/citations.js.map +1 -0
  26. package/dist/exporter/docx/comments.d.ts +18 -0
  27. package/dist/exporter/docx/comments.d.ts.map +1 -0
  28. package/dist/exporter/docx/comments.js +137 -0
  29. package/dist/exporter/docx/comments.js.map +1 -0
  30. package/dist/exporter/docx/footnotes.d.ts +42 -0
  31. package/dist/exporter/docx/footnotes.d.ts.map +1 -0
  32. package/dist/exporter/docx/footnotes.js +182 -0
  33. package/dist/exporter/docx/footnotes.js.map +1 -0
  34. package/dist/exporter/docx/images.d.ts +14 -0
  35. package/dist/exporter/docx/images.d.ts.map +1 -0
  36. package/dist/exporter/docx/images.js +86 -0
  37. package/dist/exporter/docx/images.js.map +1 -0
  38. package/dist/exporter/docx/index.d.ts +22 -0
  39. package/dist/exporter/docx/index.d.ts.map +1 -0
  40. package/dist/exporter/docx/index.js +107 -0
  41. package/dist/exporter/docx/index.js.map +1 -0
  42. package/dist/exporter/docx/lists.d.ts +33 -0
  43. package/dist/exporter/docx/lists.d.ts.map +1 -0
  44. package/dist/exporter/docx/lists.js +229 -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 +42 -0
  49. package/dist/exporter/docx/math.js.map +1 -0
  50. package/dist/exporter/docx/metadata.d.ts +14 -0
  51. package/dist/exporter/docx/metadata.d.ts.map +1 -0
  52. package/dist/exporter/docx/metadata.js +239 -0
  53. package/dist/exporter/docx/metadata.js.map +1 -0
  54. package/dist/exporter/docx/rels.d.ts +25 -0
  55. package/dist/exporter/docx/rels.d.ts.map +1 -0
  56. package/dist/exporter/docx/rels.js +168 -0
  57. package/dist/exporter/docx/rels.js.map +1 -0
  58. package/dist/exporter/docx/render.d.ts +20 -0
  59. package/dist/exporter/docx/render.d.ts.map +1 -0
  60. package/dist/exporter/docx/render.js +774 -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 +1052 -0
  65. package/dist/exporter/docx/richtext.js.map +1 -0
  66. package/dist/exporter/docx/tables.d.ts +14 -0
  67. package/dist/exporter/docx/tables.d.ts.map +1 -0
  68. package/dist/exporter/docx/tables.js +109 -0
  69. package/dist/exporter/docx/tables.js.map +1 -0
  70. package/dist/exporter/docx/tools.d.ts +3 -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 +11 -0
  75. package/dist/exporter/epub/index.d.ts.map +1 -0
  76. package/dist/exporter/epub/index.js +102 -0
  77. package/dist/exporter/epub/index.js.map +1 -0
  78. package/dist/exporter/epub/templates.d.ts +32 -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 +5 -0
  83. package/dist/exporter/epub/tools.d.ts.map +1 -0
  84. package/dist/exporter/epub/tools.js +81 -0
  85. package/dist/exporter/epub/tools.js.map +1 -0
  86. package/dist/exporter/html/citations.d.ts +27 -0
  87. package/dist/exporter/html/citations.d.ts.map +1 -0
  88. package/dist/exporter/html/citations.js +91 -0
  89. package/dist/exporter/html/citations.js.map +1 -0
  90. package/dist/exporter/html/convert.d.ts +100 -0
  91. package/dist/exporter/html/convert.d.ts.map +1 -0
  92. package/dist/exporter/html/convert.js +718 -0
  93. package/dist/exporter/html/convert.js.map +1 -0
  94. package/dist/exporter/html/index.d.ts +61 -0
  95. package/dist/exporter/html/index.d.ts.map +1 -0
  96. package/dist/exporter/html/index.js +134 -0
  97. package/dist/exporter/html/index.js.map +1 -0
  98. package/dist/exporter/html/templates.d.ts +10 -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 +2 -0
  107. package/dist/exporter/jats/bibliography.d.ts.map +1 -0
  108. package/dist/exporter/jats/bibliography.js +153 -0
  109. package/dist/exporter/jats/bibliography.js.map +1 -0
  110. package/dist/exporter/jats/citations.d.ts +14 -0
  111. package/dist/exporter/jats/citations.d.ts.map +1 -0
  112. package/dist/exporter/jats/citations.js +83 -0
  113. package/dist/exporter/jats/citations.js.map +1 -0
  114. package/dist/exporter/jats/convert.d.ts +45 -0
  115. package/dist/exporter/jats/convert.d.ts.map +1 -0
  116. package/dist/exporter/jats/convert.js +799 -0
  117. package/dist/exporter/jats/convert.js.map +1 -0
  118. package/dist/exporter/jats/index.d.ts +19 -0
  119. package/dist/exporter/jats/index.d.ts.map +1 -0
  120. package/dist/exporter/jats/index.js +66 -0
  121. package/dist/exporter/jats/index.js.map +1 -0
  122. package/dist/exporter/jats/templates.d.ts +16 -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 +3 -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 +27 -0
  131. package/dist/exporter/latex/convert.d.ts.map +1 -0
  132. package/dist/exporter/latex/convert.js +865 -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 +23 -0
  139. package/dist/exporter/latex/index.d.ts.map +1 -0
  140. package/dist/exporter/latex/index.js +57 -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/shrink.d.ts +21 -0
  147. package/dist/exporter/native/shrink.d.ts.map +1 -0
  148. package/dist/exporter/native/shrink.js +115 -0
  149. package/dist/exporter/native/shrink.js.map +1 -0
  150. package/dist/exporter/odt/citations.d.ts +18 -0
  151. package/dist/exporter/odt/citations.d.ts.map +1 -0
  152. package/dist/exporter/odt/citations.js +87 -0
  153. package/dist/exporter/odt/citations.js.map +1 -0
  154. package/dist/exporter/odt/footnotes.d.ts +25 -0
  155. package/dist/exporter/odt/footnotes.d.ts.map +1 -0
  156. package/dist/exporter/odt/footnotes.js +112 -0
  157. package/dist/exporter/odt/footnotes.js.map +1 -0
  158. package/dist/exporter/odt/images.d.ts +13 -0
  159. package/dist/exporter/odt/images.d.ts.map +1 -0
  160. package/dist/exporter/odt/images.js +98 -0
  161. package/dist/exporter/odt/images.js.map +1 -0
  162. package/dist/exporter/odt/index.d.ts +23 -0
  163. package/dist/exporter/odt/index.d.ts.map +1 -0
  164. package/dist/exporter/odt/index.js +99 -0
  165. package/dist/exporter/odt/index.js.map +1 -0
  166. package/dist/exporter/odt/math.d.ts +13 -0
  167. package/dist/exporter/odt/math.d.ts.map +1 -0
  168. package/dist/exporter/odt/math.js +48 -0
  169. package/dist/exporter/odt/math.js.map +1 -0
  170. package/dist/exporter/odt/metadata.d.ts +14 -0
  171. package/dist/exporter/odt/metadata.d.ts.map +1 -0
  172. package/dist/exporter/odt/metadata.js +203 -0
  173. package/dist/exporter/odt/metadata.js.map +1 -0
  174. package/dist/exporter/odt/render.d.ts +24 -0
  175. package/dist/exporter/odt/render.d.ts.map +1 -0
  176. package/dist/exporter/odt/render.js +644 -0
  177. package/dist/exporter/odt/render.js.map +1 -0
  178. package/dist/exporter/odt/richtext.d.ts +22 -0
  179. package/dist/exporter/odt/richtext.d.ts.map +1 -0
  180. package/dist/exporter/odt/richtext.js +728 -0
  181. package/dist/exporter/odt/richtext.js.map +1 -0
  182. package/dist/exporter/odt/styles.d.ts +33 -0
  183. package/dist/exporter/odt/styles.d.ts.map +1 -0
  184. package/dist/exporter/odt/styles.js +348 -0
  185. package/dist/exporter/odt/styles.js.map +1 -0
  186. package/dist/exporter/odt/track.d.ts +11 -0
  187. package/dist/exporter/odt/track.d.ts.map +1 -0
  188. package/dist/exporter/odt/track.js +59 -0
  189. package/dist/exporter/odt/track.js.map +1 -0
  190. package/dist/exporter/pandoc/citations.d.ts +17 -0
  191. package/dist/exporter/pandoc/citations.d.ts.map +1 -0
  192. package/dist/exporter/pandoc/citations.js +85 -0
  193. package/dist/exporter/pandoc/citations.js.map +1 -0
  194. package/dist/exporter/pandoc/convert.d.ts +38 -0
  195. package/dist/exporter/pandoc/convert.d.ts.map +1 -0
  196. package/dist/exporter/pandoc/convert.js +881 -0
  197. package/dist/exporter/pandoc/convert.js.map +1 -0
  198. package/dist/exporter/pandoc/index.d.ts +38 -0
  199. package/dist/exporter/pandoc/index.d.ts.map +1 -0
  200. package/dist/exporter/pandoc/index.js +67 -0
  201. package/dist/exporter/pandoc/index.js.map +1 -0
  202. package/dist/exporter/pandoc/readme.d.ts +2 -0
  203. package/dist/exporter/pandoc/readme.d.ts.map +1 -0
  204. package/dist/exporter/pandoc/readme.js +9 -0
  205. package/dist/exporter/pandoc/readme.js.map +1 -0
  206. package/dist/exporter/pandoc/tools.d.ts +6 -0
  207. package/dist/exporter/pandoc/tools.d.ts.map +1 -0
  208. package/dist/exporter/pandoc/tools.js +52 -0
  209. package/dist/exporter/pandoc/tools.js.map +1 -0
  210. package/dist/exporter/print/index.d.ts +9 -0
  211. package/dist/exporter/print/index.d.ts.map +1 -0
  212. package/dist/exporter/print/index.js +140 -0
  213. package/dist/exporter/print/index.js.map +1 -0
  214. package/dist/exporter/tools/doc_content.d.ts +7 -0
  215. package/dist/exporter/tools/doc_content.d.ts.map +1 -0
  216. package/dist/exporter/tools/doc_content.js +129 -0
  217. package/dist/exporter/tools/doc_content.js.map +1 -0
  218. package/dist/exporter/tools/file.d.ts +2 -0
  219. package/dist/exporter/tools/file.d.ts.map +1 -0
  220. package/dist/exporter/tools/file.js +10 -0
  221. package/dist/exporter/tools/file.js.map +1 -0
  222. package/dist/exporter/tools/json.d.ts +7 -0
  223. package/dist/exporter/tools/json.d.ts.map +1 -0
  224. package/dist/exporter/tools/json.js +82 -0
  225. package/dist/exporter/tools/json.js.map +1 -0
  226. package/dist/exporter/tools/svg.d.ts +2 -0
  227. package/dist/exporter/tools/svg.d.ts.map +1 -0
  228. package/dist/exporter/tools/svg.js +26 -0
  229. package/dist/exporter/tools/svg.js.map +1 -0
  230. package/dist/exporter/tools/xml.d.ts +41 -0
  231. package/dist/exporter/tools/xml.d.ts.map +1 -0
  232. package/dist/exporter/tools/xml.js +440 -0
  233. package/dist/exporter/tools/xml.js.map +1 -0
  234. package/dist/exporter/tools/xml_zip.d.ts +20 -0
  235. package/dist/exporter/tools/xml_zip.d.ts.map +1 -0
  236. package/dist/exporter/tools/xml_zip.js +86 -0
  237. package/dist/exporter/tools/xml_zip.js.map +1 -0
  238. package/dist/exporter/tools/zip.d.ts +21 -0
  239. package/dist/exporter/tools/zip.d.ts.map +1 -0
  240. package/dist/exporter/tools/zip.js +71 -0
  241. package/dist/exporter/tools/zip.js.map +1 -0
  242. package/dist/exporter/tools/zotero_csl.d.ts +10 -0
  243. package/dist/exporter/tools/zotero_csl.d.ts.map +1 -0
  244. package/dist/exporter/tools/zotero_csl.js +78 -0
  245. package/dist/exporter/tools/zotero_csl.js.map +1 -0
  246. package/dist/importer/citations.d.ts +25 -0
  247. package/dist/importer/citations.d.ts.map +1 -0
  248. package/dist/importer/citations.js +116 -0
  249. package/dist/importer/citations.js.map +1 -0
  250. package/dist/importer/docx/citations.d.ts +65 -0
  251. package/dist/importer/docx/citations.d.ts.map +1 -0
  252. package/dist/importer/docx/citations.js +106 -0
  253. package/dist/importer/docx/citations.js.map +1 -0
  254. package/dist/importer/docx/convert.d.ts +228 -0
  255. package/dist/importer/docx/convert.d.ts.map +1 -0
  256. package/dist/importer/docx/convert.js +1226 -0
  257. package/dist/importer/docx/convert.js.map +1 -0
  258. package/dist/importer/docx/helpers.d.ts +2 -0
  259. package/dist/importer/docx/helpers.d.ts.map +1 -0
  260. package/dist/importer/docx/helpers.js +10 -0
  261. package/dist/importer/docx/helpers.js.map +1 -0
  262. package/dist/importer/docx/omml2mathml.d.ts +7 -0
  263. package/dist/importer/docx/omml2mathml.d.ts.map +1 -0
  264. package/dist/importer/docx/omml2mathml.js +1239 -0
  265. package/dist/importer/docx/omml2mathml.js.map +1 -0
  266. package/dist/importer/docx/parse.d.ts +205 -0
  267. package/dist/importer/docx/parse.d.ts.map +1 -0
  268. package/dist/importer/docx/parse.js +663 -0
  269. package/dist/importer/docx/parse.js.map +1 -0
  270. package/dist/importer/native/get_images.d.ts +11 -0
  271. package/dist/importer/native/get_images.d.ts.map +1 -0
  272. package/dist/importer/native/get_images.js +64 -0
  273. package/dist/importer/native/get_images.js.map +1 -0
  274. package/dist/importer/native/update.d.ts +6 -0
  275. package/dist/importer/native/update.d.ts.map +1 -0
  276. package/dist/importer/native/update.js +26 -0
  277. package/dist/importer/native/update.js.map +1 -0
  278. package/dist/importer/odt/citations.d.ts +47 -0
  279. package/dist/importer/odt/citations.d.ts.map +1 -0
  280. package/dist/importer/odt/citations.js +79 -0
  281. package/dist/importer/odt/citations.js.map +1 -0
  282. package/dist/importer/odt/convert.d.ts +330 -0
  283. package/dist/importer/odt/convert.d.ts.map +1 -0
  284. package/dist/importer/odt/convert.js +1506 -0
  285. package/dist/importer/odt/convert.js.map +1 -0
  286. package/dist/importer/pandoc/convert.d.ts +84 -0
  287. package/dist/importer/pandoc/convert.d.ts.map +1 -0
  288. package/dist/importer/pandoc/convert.js +777 -0
  289. package/dist/importer/pandoc/convert.js.map +1 -0
  290. package/dist/importer/pandoc/helpers.d.ts +4 -0
  291. package/dist/importer/pandoc/helpers.d.ts.map +1 -0
  292. package/dist/importer/pandoc/helpers.js +75 -0
  293. package/dist/importer/pandoc/helpers.js.map +1 -0
  294. package/dist/importer/zip_analyzer.d.ts +25 -0
  295. package/dist/importer/zip_analyzer.d.ts.map +1 -0
  296. package/dist/importer/zip_analyzer.js +84 -0
  297. package/dist/importer/zip_analyzer.js.map +1 -0
  298. package/dist/index.d.ts +2 -0
  299. package/dist/index.d.ts.map +1 -0
  300. package/dist/index.js +2 -0
  301. package/dist/index.js.map +1 -0
  302. package/dist/mathlive/opf_includes.d.ts +2 -0
  303. package/dist/mathlive/opf_includes.d.ts.map +1 -0
  304. package/dist/mathlive/opf_includes.js +25 -0
  305. package/dist/mathlive/opf_includes.js.map +1 -0
  306. package/dist/schema/common/annotate.d.ts +59 -0
  307. package/dist/schema/common/annotate.d.ts.map +1 -0
  308. package/dist/schema/common/annotate.js +75 -0
  309. package/dist/schema/common/annotate.js.map +1 -0
  310. package/dist/schema/common/base.d.ts +109 -0
  311. package/dist/schema/common/base.d.ts.map +1 -0
  312. package/dist/schema/common/base.js +109 -0
  313. package/dist/schema/common/base.js.map +1 -0
  314. package/dist/schema/common/citation.d.ts +29 -0
  315. package/dist/schema/common/citation.d.ts.map +1 -0
  316. package/dist/schema/common/citation.js +62 -0
  317. package/dist/schema/common/citation.js.map +1 -0
  318. package/dist/schema/common/equation.d.ts +18 -0
  319. package/dist/schema/common/equation.d.ts.map +1 -0
  320. package/dist/schema/common/equation.js +32 -0
  321. package/dist/schema/common/equation.js.map +1 -0
  322. package/dist/schema/common/figure.d.ts +108 -0
  323. package/dist/schema/common/figure.d.ts.map +1 -0
  324. package/dist/schema/common/figure.js +176 -0
  325. package/dist/schema/common/figure.js.map +1 -0
  326. package/dist/schema/common/heading.d.ts +33 -0
  327. package/dist/schema/common/heading.d.ts.map +1 -0
  328. package/dist/schema/common/heading.js +41 -0
  329. package/dist/schema/common/heading.js.map +1 -0
  330. package/dist/schema/common/index.d.ts +11 -0
  331. package/dist/schema/common/index.d.ts.map +1 -0
  332. package/dist/schema/common/index.js +11 -0
  333. package/dist/schema/common/index.js.map +1 -0
  334. package/dist/schema/common/list.d.ts +83 -0
  335. package/dist/schema/common/list.d.ts.map +1 -0
  336. package/dist/schema/common/list.js +92 -0
  337. package/dist/schema/common/list.js.map +1 -0
  338. package/dist/schema/common/reference.d.ts +78 -0
  339. package/dist/schema/common/reference.d.ts.map +1 -0
  340. package/dist/schema/common/reference.js +97 -0
  341. package/dist/schema/common/reference.js.map +1 -0
  342. package/dist/schema/common/table.d.ts +92 -0
  343. package/dist/schema/common/table.d.ts.map +1 -0
  344. package/dist/schema/common/table.js +85 -0
  345. package/dist/schema/common/table.js.map +1 -0
  346. package/dist/schema/common/track.d.ts +131 -0
  347. package/dist/schema/common/track.d.ts.map +1 -0
  348. package/dist/schema/common/track.js +184 -0
  349. package/dist/schema/common/track.js.map +1 -0
  350. package/dist/schema/const.d.ts +3 -0
  351. package/dist/schema/const.d.ts.map +1 -0
  352. package/{src → dist}/schema/const.js +3 -3
  353. package/dist/schema/const.js.map +1 -0
  354. package/dist/schema/convert.d.ts +3 -0
  355. package/dist/schema/convert.d.ts.map +1 -0
  356. package/dist/schema/convert.js +1215 -0
  357. package/dist/schema/convert.js.map +1 -0
  358. package/dist/schema/document/content.d.ts +137 -0
  359. package/dist/schema/document/content.d.ts.map +1 -0
  360. package/dist/schema/document/content.js +177 -0
  361. package/dist/schema/document/content.js.map +1 -0
  362. package/dist/schema/document/index.d.ts +879 -0
  363. package/dist/schema/document/index.d.ts.map +1 -0
  364. package/dist/schema/document/index.js +68 -0
  365. package/dist/schema/document/index.js.map +1 -0
  366. package/dist/schema/document/structure.d.ts +273 -0
  367. package/dist/schema/document/structure.d.ts.map +1 -0
  368. package/dist/schema/document/structure.js +445 -0
  369. package/dist/schema/document/structure.js.map +1 -0
  370. package/dist/schema/export.d.ts +880 -0
  371. package/dist/schema/export.d.ts.map +1 -0
  372. package/dist/schema/export.js +16 -0
  373. package/dist/schema/export.js.map +1 -0
  374. package/dist/schema/footnotes.d.ts +499 -0
  375. package/dist/schema/footnotes.d.ts.map +1 -0
  376. package/dist/schema/footnotes.js +88 -0
  377. package/dist/schema/footnotes.js.map +1 -0
  378. package/dist/schema/footnotes_convert.d.ts +5 -0
  379. package/dist/schema/footnotes_convert.d.ts.map +1 -0
  380. package/dist/schema/footnotes_convert.js +26 -0
  381. package/dist/schema/footnotes_convert.js.map +1 -0
  382. package/dist/schema/i18n.d.ts +586 -0
  383. package/dist/schema/i18n.d.ts.map +1 -0
  384. package/dist/schema/i18n.js +585 -0
  385. package/dist/schema/i18n.js.map +1 -0
  386. package/dist/schema/index.d.ts +6 -0
  387. package/dist/schema/index.d.ts.map +1 -0
  388. package/dist/schema/index.js +6 -0
  389. package/dist/schema/index.js.map +1 -0
  390. package/dist/schema/mini_json.d.ts +5 -0
  391. package/dist/schema/mini_json.d.ts.map +1 -0
  392. package/dist/schema/mini_json.js +50 -0
  393. package/dist/schema/mini_json.js.map +1 -0
  394. package/dist/schema/text.d.ts +2 -0
  395. package/dist/schema/text.d.ts.map +1 -0
  396. package/dist/schema/text.js +23 -0
  397. package/dist/schema/text.js.map +1 -0
  398. package/dist/types.d.ts +122 -0
  399. package/dist/types.d.ts.map +1 -0
  400. package/dist/types.js +9 -0
  401. package/dist/types.js.map +1 -0
  402. package/package.json +48 -16
  403. package/scripts/export-schema.js +1 -1
  404. package/src/exporter/tools/{file.js → file.ts} +1 -1
  405. package/src/exporter/tools/{json.js → json.ts} +30 -19
  406. package/src/global.d.ts +11 -0
  407. package/src/schema/const.ts +58 -0
  408. package/src/types.ts +136 -0
  409. package/jest.config.js +0 -24
  410. /package/src/{index.js → index.ts} +0 -0
@@ -0,0 +1,728 @@
1
+ import { escapeText } from "fwtoolkit";
2
+ import { CATS } from "../../schema/i18n.js";
3
+ import { createZoteroCitation } from "../tools/zotero_csl.js";
4
+ const TEXT_TYPES = {
5
+ heading1: { tag: "text:h", attrs: _options => 'text:outline-level="1"' },
6
+ heading2: { tag: "text:h", attrs: _options => 'text:outline-level="2"' },
7
+ heading3: { tag: "text:h", attrs: _options => 'text:outline-level="3"' },
8
+ heading4: { tag: "text:h", attrs: _options => 'text:outline-level="4"' },
9
+ heading5: { tag: "text:h", attrs: _options => 'text:outline-level="5"' },
10
+ heading6: { tag: "text:h", attrs: _options => 'text:outline-level="6"' },
11
+ paragraph: {
12
+ tag: "text:p",
13
+ attrs: options => `text:style-name="${options.section}"`
14
+ },
15
+ code_block: {
16
+ tag: "text:p",
17
+ attrs: _options => 'text:style-name="Preformatted_20_Text"'
18
+ }
19
+ };
20
+ const INLINE_TYPES = [
21
+ "citation",
22
+ "cross_reference",
23
+ "cslbib",
24
+ "cslblock",
25
+ "cslindent",
26
+ "cslinline",
27
+ "cslleftmargin",
28
+ "cslrightinline",
29
+ "equation",
30
+ "footnote",
31
+ "hard_break",
32
+ "image",
33
+ "text"
34
+ ];
35
+ /**
36
+ * Create Zotero reference mark name for ODT.
37
+ * @param {Array} references - Array of {id, prefix?, locator?} from citation node
38
+ * @param {Object} bibDB - Bibliography database
39
+ * @param {string} formattedCitation - Pre-formatted citation text from citeproc
40
+ * @param {string} citationId - Optional citation ID (generated if not provided)
41
+ * @returns {string} Reference mark name with JSON encoded
42
+ */
43
+ // Generate a random ID for Zotero bibliography section + Zotero citations
44
+ // Format: RND + random alphanumeric string (10 characters)
45
+ function generateZoteroId() {
46
+ const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
47
+ const length = 10;
48
+ let result = "RND";
49
+ for (let i = 0; i < length; i++) {
50
+ result += chars.charAt(Math.floor(Math.random() * chars.length));
51
+ }
52
+ return result;
53
+ }
54
+ function createZoteroCitationMark(references, bibDB, formattedCitation, citationId = null) {
55
+ const zoteroCitation = createZoteroCitation(references, bibDB, formattedCitation, citationId);
56
+ if (!zoteroCitation) {
57
+ return null;
58
+ }
59
+ const jsonStr = JSON.stringify(zoteroCitation);
60
+ // In ODT, quotes must be encoded as &quot; in attribute values
61
+ const encodedJson = jsonStr.replace(/"/g, "&quot;");
62
+ const zoteroId = generateZoteroId();
63
+ return `ZOTERO_ITEM CSL_CITATION ${encodedJson} ${zoteroId}`;
64
+ }
65
+ export class ODTExporterRichtext {
66
+ constructor(comments, settings, styles, tracks, footnotes, citations, math, images) {
67
+ this.comments = comments;
68
+ this.styles = styles;
69
+ this.tracks = tracks;
70
+ this.footnotes = footnotes;
71
+ this.citations = citations;
72
+ this.settings = settings;
73
+ this.math = math;
74
+ this.images = images;
75
+ this.imgCounter = 1;
76
+ this.fnCounter = 0; // real footnotes
77
+ this.fnAlikeCounter = 0; // real footnotes and citations as footnotes
78
+ this.categoryCounter = {}; // counters for each type of table/figure category (figure/table/photo)
79
+ this.fnCategoryCounter = {}; // counters for each type of table/figure category (figure/table/photo)
80
+ this.zIndex = 0;
81
+ this.citationCounter = 0; // Track which citation we're processing
82
+ }
83
+ run(node, options = {}, parent = null, siblingIndex = 0) {
84
+ options.comments = this.findComments(node); // Data related to comments. We need to mark the first and last occurence of comment
85
+ return this.transformRichtext(node, options, parent, siblingIndex);
86
+ }
87
+ findComments(node, comments = {}) {
88
+ if (node.marks) {
89
+ node.marks
90
+ .filter(mark => mark.type === "comment")
91
+ .forEach(comment => {
92
+ if (!comments[comment.attrs.id]) {
93
+ comments[comment.attrs.id] = {
94
+ start: node,
95
+ end: node,
96
+ content: this.comments[comment.attrs.id]
97
+ };
98
+ }
99
+ else {
100
+ comments[comment.attrs.id]["end"] = node;
101
+ }
102
+ });
103
+ }
104
+ if (node.content) {
105
+ for (let i = 0; i < node.content.length; i++) {
106
+ this.findComments(node.content[i], comments);
107
+ }
108
+ }
109
+ return comments;
110
+ }
111
+ transformRichtext(node, options = {}, parent = null, siblingIndex = 0) {
112
+ let start = "", content = "", end = "";
113
+ const siblings = parent?.content || [];
114
+ const previousSibling = siblings[siblingIndex - 1];
115
+ const nextSibling = siblings[siblingIndex + 1];
116
+ const inlineNode = INLINE_TYPES.includes(node.type);
117
+ let blockDelete, blockInsert;
118
+ if (!inlineNode && node.attrs?.track) {
119
+ blockDelete = node.attrs.track.find(mark => mark.type === "deletion");
120
+ if (blockDelete) {
121
+ options = Object.assign({}, options);
122
+ options.blockDelete = blockDelete;
123
+ }
124
+ blockInsert = node.attrs.track.find(mark => mark.type === "insertion");
125
+ if (blockInsert) {
126
+ options = Object.assign({}, options);
127
+ options.blockInsert = blockInsert;
128
+ }
129
+ }
130
+ if (node.marks) {
131
+ node.marks
132
+ .filter(mark => mark.type === "comment")
133
+ .forEach(comment => {
134
+ const commentData = options.comments[comment.attrs.id];
135
+ if (!commentData || !commentData.content) {
136
+ return;
137
+ }
138
+ if (commentData.start === node) {
139
+ start += `<office:annotation office:name="comment_${options.tag}_${comment.attrs.id}" loext:resolved="${commentData.content.resolved}">
140
+ <dc:creator>${escapeText(commentData.content.username)}</dc:creator>
141
+ <dc:date>${new Date(commentData.content.date).toISOString().slice(0, -1)}000000</dc:date>
142
+ ${commentData.content.comment.map(node => this.transformRichtext(node, options)).join("")}
143
+ </office:annotation>`;
144
+ }
145
+ if (commentData.end === node) {
146
+ end =
147
+ `<office:annotation-end office:name="comment_${options.tag}_${comment.attrs.id}"/>` +
148
+ (commentData.content.answers || [])
149
+ .map(answer => `<office:annotation loext:resolved="${commentData.content.resolved}">
150
+ <dc:creator>${escapeText(answer.username)}</dc:creator>
151
+ <dc:date>${new Date(answer.date).toISOString().slice(0, -1)}000000</dc:date>
152
+ ${answer.answer.map(node => this.transformRichtext(node, options)).join("")}
153
+ </office:annotation>`)
154
+ .join("") +
155
+ end;
156
+ }
157
+ });
158
+ }
159
+ switch (node.type) {
160
+ case "bibliography_heading":
161
+ this.styles.checkParStyle("Bibliography_20_Heading");
162
+ start += '<text:p text:style-name="Bibliography_20_Heading">';
163
+ end = "</text:p>" + end;
164
+ break;
165
+ case "code_block":
166
+ case "heading1":
167
+ case "heading2":
168
+ case "heading3":
169
+ case "heading4":
170
+ case "heading5":
171
+ case "heading6":
172
+ case "paragraph": {
173
+ // Handles all types of text blocks.
174
+ if (node.type === "code_block") {
175
+ this.styles.checkParStyle("Preformatted_20_Text");
176
+ }
177
+ else if (node.type === "paragraph") {
178
+ if (!options.section) {
179
+ options.section = "Text_20_body";
180
+ }
181
+ this.styles.checkParStyle(options.section);
182
+ }
183
+ const nextBlockDelete = nextSibling?.attrs?.track?.find(mark => mark.type === "deletion");
184
+ const nextBlockInsert = nextSibling?.attrs?.track?.find(mark => mark.type === "insertion");
185
+ let lastNonMergedBlock;
186
+ if (blockDelete) {
187
+ // This block has been deleted, so we need to check which text block
188
+ // it is being merged in to. If it has, we need to merge the
189
+ // two blocks.
190
+ if (!previousSibling || !TEXT_TYPES[previousSibling.type]) {
191
+ // We cannot merge into previous block. Therefore, we don't consider
192
+ // this text block as merged.
193
+ blockDelete = false;
194
+ }
195
+ else {
196
+ let searchNode = previousSibling;
197
+ while (searchNode && TEXT_TYPES[searchNode.type]) {
198
+ lastNonMergedBlock = searchNode;
199
+ if (searchNode?.attrs?.track?.find(mark => mark.type === "deletion")) {
200
+ searchNode =
201
+ siblings[siblings.indexOf(searchNode) - 1];
202
+ }
203
+ else {
204
+ searchNode = false;
205
+ }
206
+ }
207
+ }
208
+ }
209
+ if (blockDelete) {
210
+ // This block has been deleted, so instead we just add a text
211
+ // change marker.
212
+ if (previousSibling.type === "paragraph") {
213
+ if (!options.section) {
214
+ options.section = "Text_20_body";
215
+ }
216
+ this.styles.checkParStyle(options.section);
217
+ }
218
+ const trackId = this.tracks.addChange(blockDelete, `
219
+ <${TEXT_TYPES[previousSibling.type].tag} ${TEXT_TYPES[previousSibling.type].attrs(options)}/>
220
+ <${TEXT_TYPES[node.type].tag} ${TEXT_TYPES[node.type].attrs(options)}/>`);
221
+ start += `<text:change text:change-id="${trackId}"/>`;
222
+ }
223
+ else {
224
+ start += `<${TEXT_TYPES[node.type].tag} ${TEXT_TYPES[node.type].attrs(options)}>`;
225
+ }
226
+ if (blockInsert && blockInsert.trackId) {
227
+ // The previous block node is a text node , so the insertion is a textblock split.
228
+ // We need to put change track marks in both this and the previous text block.
229
+ start += `<text:change-end text:change-id="${blockInsert.trackId}"/>`;
230
+ }
231
+ const nextBlockDeleteTextType = nextBlockDelete && TEXT_TYPES[nextSibling.type];
232
+ if (!nextBlockDeleteTextType) {
233
+ const lastNonMergedBlockTextType = lastNonMergedBlock &&
234
+ TEXT_TYPES[lastNonMergedBlock.type];
235
+ if (lastNonMergedBlockTextType) {
236
+ // This block has been deleted and the next block is not.
237
+ // So we end it here as the last known non-deleted block type.
238
+ end = `</${lastNonMergedBlockTextType.tag}>` + end;
239
+ }
240
+ else {
241
+ // The next block is not deleted, so we close this block.
242
+ end = `</${TEXT_TYPES[node.type].tag}>` + end;
243
+ }
244
+ }
245
+ if (nextBlockInsert && TEXT_TYPES[nextSibling.type]) {
246
+ // The following block node is a text node , so the insertion is a textblock split.
247
+ // We need to put change track marks in both this and the next text block.
248
+ const trackId = this.tracks.addChange(nextBlockInsert);
249
+ end =
250
+ `<text:change-start text:change-id="${trackId}"/>` + end;
251
+ // Adding the track id here so that we can add find it at the beginning of the next text block.
252
+ nextBlockInsert.trackId = trackId;
253
+ }
254
+ if (TEXT_TYPES[node.type].tag === "text:h") {
255
+ start += `<text:bookmark-start text:name="${node.attrs.id}"/>`;
256
+ end =
257
+ `<text:bookmark-end text:name="${node.attrs.id}"/>` +
258
+ end;
259
+ }
260
+ // Handle code block category labels
261
+ if (node.type === "code_block") {
262
+ const category = node.attrs.category;
263
+ if (category && node.attrs.id) {
264
+ const categoryCounter = options.inFootnote
265
+ ? this.fnCategoryCounter
266
+ : this.categoryCounter;
267
+ if (!categoryCounter[category]) {
268
+ categoryCounter[category] = 1;
269
+ }
270
+ const catCount = categoryCounter[category]++;
271
+ const catCountXml = `<text:sequence text:ref-name="ref${category}${catCount - 1}${options.inFootnote ? "A" : ""}" text:name="${category}" text:formula="ooow:${category}+1" style:num-format="1">${catCount}${options.inFootnote ? "A" : ""}</text:sequence>`;
272
+ const title = node.attrs.title
273
+ ? `: ${escapeText(node.attrs.title)}`
274
+ : "";
275
+ const categoryLabel = `<text:bookmark-start text:name="${node.attrs.id}"/>${CATS[category][this.settings.language]} ${catCountXml}${title}<text:bookmark-end text:name="${node.attrs.id}"/><text:line-break/>`;
276
+ start += categoryLabel;
277
+ }
278
+ }
279
+ break;
280
+ }
281
+ case "blockquote":
282
+ // This is imperfect, but Word doesn't seem to provide section/quotation nesting
283
+ options = Object.assign({}, options);
284
+ options.section = "Quote";
285
+ break;
286
+ case "ordered_list": {
287
+ const olId = this.styles.getOrderedListStyleId(node.attrs.order);
288
+ start += `<text:list text:style-name="L${olId[0]}">`;
289
+ end = "</text:list>" + end;
290
+ options = Object.assign({}, options);
291
+ options.section = `P${olId[1]}`;
292
+ options.listStyles = (options.listStyles || []).concat([
293
+ `L${olId[0]}`
294
+ ]);
295
+ break;
296
+ }
297
+ case "bullet_list": {
298
+ const ulId = this.styles.getBulletListStyleId();
299
+ start += `<text:list text:style-name="L${ulId[0]}">`;
300
+ end = "</text:list>" + end;
301
+ options = Object.assign({}, options);
302
+ options.section = `P${ulId[1]}`;
303
+ options.listStyles = (options.listStyles || []).concat([
304
+ `L${ulId[0]}`
305
+ ]);
306
+ break;
307
+ }
308
+ case "list_item":
309
+ start += "<text:list-item>";
310
+ end = "</text:list-item>" + end;
311
+ break;
312
+ case "footnotecontainer":
313
+ break;
314
+ case "footnote": {
315
+ const fnCounter = this.fnAlikeCounter++;
316
+ const fnOptions = Object.assign({}, options);
317
+ fnOptions.section = "Footnote";
318
+ fnOptions.tag = `footnote${fnCounter}`;
319
+ fnOptions.inFootnote = true;
320
+ const fnNode = {
321
+ type: "footnotecontainer",
322
+ content: node.attrs.footnote
323
+ };
324
+ fnOptions.comments = this.findComments(fnNode);
325
+ content += this.transformRichtext(fnNode, fnOptions);
326
+ start += `
327
+ <text:note text:id="ftn${fnCounter}" text:note-class="footnote">
328
+ <text:note-citation>${fnCounter}</text:note-citation>
329
+ <text:note-body>`;
330
+ end =
331
+ `
332
+ </text:note-body>
333
+ </text:note>` + end;
334
+ break;
335
+ }
336
+ case "text": {
337
+ let hyperlink, strong, em, underline, sup, sub, smallcaps, code, anchor;
338
+ // Check for hyperlink, bold/strong and italic/em
339
+ if (node.marks) {
340
+ hyperlink = node.marks.find(mark => mark.type === "link");
341
+ anchor = node.marks.find(mark => mark.type === "anchor");
342
+ strong = node.marks.find(mark => mark.type === "strong");
343
+ em = node.marks.find(mark => mark.type === "em");
344
+ underline = node.marks.find(mark => mark.type === "underline");
345
+ smallcaps = node.marks.find(mark => mark.type === "smallcaps");
346
+ sup = node.marks.find(mark => mark.type === "sup");
347
+ sub = node.marks.find(mark => mark.type === "sub");
348
+ code = node.marks.find(mark => mark.type === "code");
349
+ }
350
+ if (hyperlink) {
351
+ start += `<text:a xlink:type="simple" xlink:href="${escapeText(hyperlink.attrs.href)}">`;
352
+ end = "</text:a>" + end;
353
+ }
354
+ if (anchor) {
355
+ start += `<text:reference-mark-start text:name="${anchor.attrs.id}"/>`;
356
+ end =
357
+ `<text:reference-mark-end text:name="${anchor.attrs.id}"/>` +
358
+ end;
359
+ start += `<text:bookmark-start text:name="${anchor.attrs.id}"/>`;
360
+ end =
361
+ `<text:bookmark-end text:name="${anchor.attrs.id}"/>` +
362
+ end;
363
+ }
364
+ let attributes = "";
365
+ if (em) {
366
+ attributes += "e";
367
+ }
368
+ if (strong) {
369
+ attributes += "s";
370
+ }
371
+ if (underline) {
372
+ attributes += "u";
373
+ }
374
+ if (smallcaps) {
375
+ attributes += "c";
376
+ }
377
+ if (sup) {
378
+ attributes += "p";
379
+ }
380
+ else if (sub) {
381
+ attributes += "b";
382
+ }
383
+ if (code) {
384
+ attributes += "t";
385
+ }
386
+ if (attributes.length) {
387
+ const styleId = this.styles.getInlineStyleId(attributes);
388
+ start += `<text:span text:style-name="T${styleId}">`;
389
+ end = "</text:span>" + end;
390
+ }
391
+ content += escapeText(node.text).replace(/^\s+|\s+$/g, match => "<text:s/>".repeat(match.length));
392
+ break;
393
+ }
394
+ case "citation": {
395
+ let cit;
396
+ // We take the first citation from the stack and remove it.
397
+ if (options.inFootnote) {
398
+ cit = this.footnotes.citations.pmCits.shift();
399
+ }
400
+ else {
401
+ cit = this.citations.pmCits.shift();
402
+ }
403
+ // Get citation info and formatted text for Zotero export
404
+ const citInfo = this.citations.citInfos[this.citationCounter];
405
+ const formattedText = this.citations.citationTexts[this.citationCounter];
406
+ this.citationCounter++;
407
+ // Create Zotero citation data on-the-fly
408
+ const markName = citInfo && formattedText
409
+ ? createZoteroCitationMark(citInfo.references, this.citations.bibDB, formattedText)
410
+ : null;
411
+ if (options.citationType === "note" && !options.inFootnote) {
412
+ // If the citations are in notes (footnotes), we need to
413
+ // put the contents of this citation in a footnote.
414
+ if (markName && formattedText) {
415
+ // Create Zotero reference mark for footnote citation
416
+ start += `
417
+ <text:note text:id="ftn${this.fnAlikeCounter++}" text:note-class="footnote">
418
+ <text:note-citation>${this.fnAlikeCounter}</text:note-citation>
419
+ <text:note-body>
420
+ <text:p text:style-name="Footnote">
421
+ <text:reference-mark-start text:name="${markName}"/>`;
422
+ content = formattedText;
423
+ end =
424
+ `<text:reference-mark-end text:name="${markName}"/></text:p>
425
+ </text:note-body>
426
+ </text:note>` + end;
427
+ }
428
+ else {
429
+ // Fallback to non-Zotero format
430
+ start += `
431
+ <text:note text:id="ftn${this.fnAlikeCounter++}" text:note-class="footnote">
432
+ <text:note-citation>${this.fnAlikeCounter}</text:note-citation>
433
+ <text:note-body>`;
434
+ end =
435
+ `
436
+ </text:note-body>
437
+ </text:note>` + end;
438
+ options = Object.assign({}, options);
439
+ options.section = "Footnote";
440
+ content += this.transformRichtext({ type: "paragraph", content: cit.content }, options);
441
+ }
442
+ }
443
+ else {
444
+ // For in-text citations, create Zotero reference mark
445
+ if (markName && formattedText) {
446
+ start += `<text:reference-mark-start text:name="${markName}"/>`;
447
+ content = formattedText;
448
+ end =
449
+ `<text:reference-mark-end text:name="${markName}"/>` +
450
+ end;
451
+ }
452
+ else {
453
+ // Fallback to formatted text only
454
+ cit.content.forEach(citContent => {
455
+ content += this.transformRichtext(citContent, options);
456
+ });
457
+ }
458
+ }
459
+ break;
460
+ }
461
+ case "figure": {
462
+ // NOTE: The difficulty is to make several images with different
463
+ // alignments/widths not overlap one-another. The below code
464
+ // makes a reasonable attempt at that, but it seems there is no
465
+ // way to guarantee it from happening.
466
+ options = Object.assign({}, options);
467
+ options.section = "Standard";
468
+ this.styles.checkParStyle(options.section);
469
+ start += `<text:p text:style-name="${options.section}">`;
470
+ end = "</text:p>" + end;
471
+ if (node.attrs.aligned === "center") {
472
+ // Needed to prevent subsequent image from overlapping
473
+ end = end + '<text:p text:style-name="Standard"></text:p>';
474
+ }
475
+ const figureCaption = node.content.find(node => node.type === "figure_caption");
476
+ let caption = node.attrs.caption
477
+ ? figureCaption?.content
478
+ ?.map((node, index) => this.transformRichtext(node, options, figureCaption, index))
479
+ .join("") || ""
480
+ : "";
481
+ // The figure category should not be in the
482
+ // user's language but rather the document language
483
+ const category = node.attrs.category;
484
+ if (category !== "none") {
485
+ const categoryCounter = options.inFootnote
486
+ ? this.fnCategoryCounter
487
+ : this.categoryCounter;
488
+ if (!categoryCounter[category]) {
489
+ categoryCounter[category] = 1;
490
+ }
491
+ const catCount = categoryCounter[category]++;
492
+ const catCountXml = `<text:sequence text:ref-name="ref${category}${catCount - 1}${options.inFootnote ? "A" : ""}" text:name="${category}" text:formula="ooow:${category}+1" style:num-format="1">${catCount}${options.inFootnote ? "A" : ""}</text:sequence>`;
493
+ if (caption.length) {
494
+ caption = `<text:bookmark-start text:name="${node.attrs.id}"/>${CATS[category][this.settings.language]} ${catCountXml}<text:bookmark-end text:name="${node.attrs.id}"/>: ${caption}`;
495
+ }
496
+ else {
497
+ caption = `<text:bookmark-start text:name="${node.attrs.id}"/>${CATS[category][this.settings.language]} ${catCountXml}<text:bookmark-end text:name="${node.attrs.id}"/>`;
498
+ }
499
+ }
500
+ let relWidth = node.attrs.width;
501
+ let aligned = node.attrs.aligned;
502
+ let frame;
503
+ const image = node.content.find(node => node.type === "image")?.attrs
504
+ .image || false;
505
+ if (caption.length || image === false) {
506
+ frame = true;
507
+ this.styles.checkParStyle("Caption");
508
+ this.styles.checkParStyle("Figure");
509
+ const graphicStyleId = this.styles.getGraphicStyleId("Frame", aligned);
510
+ start += `<draw:frame draw:style-name="fr${graphicStyleId}" draw:name="Frame${graphicStyleId}" text:anchor-type="paragraph" svg:width="0.0161in" style:rel-width="${relWidth}%" draw:z-index="${this.zIndex++}">
511
+ <draw:text-box fo:min-height="0in">
512
+ <text:p text:style-name="Figure">`;
513
+ relWidth = "100"; // percentage width of image inside of frame is always 100
514
+ aligned = "center"; // Aligned inside of frame is always 'center'
515
+ end =
516
+ `
517
+ </text:p>
518
+ </draw:text-box>
519
+ </draw:frame>` + end;
520
+ if (caption.length) {
521
+ end = `<text:line-break />${caption}` + end;
522
+ }
523
+ }
524
+ if (image !== false) {
525
+ const imageEntry = this.images.images[image];
526
+ const height = (imageEntry.height * 3) / 4; // more or less px to point
527
+ const width = (imageEntry.width * 3) / 4; // more or less px to point
528
+ const graphicStyleId = this.styles.getGraphicStyleId("Graphics", aligned);
529
+ content += `
530
+ <draw:frame draw:style-name="${graphicStyleId}" draw:name="Image${this.imgCounter++}" text:anchor-type="${frame && !blockInsert ? "char" : "as-char"}" style:rel-width="${relWidth}%" style:rel-height="scale" svg:width="${width}pt" svg:height="${height}pt" draw:z-index="${this.zIndex++}">
531
+ ${imageEntry.svg
532
+ ? `<draw:image xlink:href="Pictures/${imageEntry.svg}" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad" draw:mime-type="image/svg+xml"/>`
533
+ : ""}
534
+ <draw:image xlink:href="Pictures/${imageEntry.id}" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad" draw:mime-type="${imageEntry.type}"/>
535
+ </draw:frame>`;
536
+ }
537
+ else {
538
+ const latex = node.content.find(node => node.type === "figure_equation")?.attrs.equation;
539
+ const objectNumber = this.math.addMath(latex);
540
+ const graphicStyleId = this.styles.getGraphicStyleId("Formula");
541
+ content += `
542
+ <draw:frame draw:style-name="${graphicStyleId}" draw:name="Object${objectNumber}" text:anchor-type="as-char" draw:z-index="${this.zIndex++}">
543
+ <draw:object xlink:href="./Object ${objectNumber}.js" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
544
+ <svg:desc>formula</svg:desc>
545
+ </draw:frame>`;
546
+ }
547
+ if (category === "none") {
548
+ content = `<text:bookmark-start text:name="${node.attrs.id}"/>${content}<text:bookmark-end text:name="${node.attrs.id}"/>`;
549
+ }
550
+ if (blockDelete) {
551
+ const trackId = this.tracks.addChange(blockDelete, `<text:p text:style-name="Figure">${content}<text:span>‍‍</text:span></text:p>`);
552
+ content = `<text:change text:change-id="${trackId}"/>`;
553
+ }
554
+ if (blockInsert) {
555
+ const trackId = this.tracks.addChange(blockInsert);
556
+ start += `<text:change-start text:change-id="${trackId}"/>`;
557
+ end = `<text:change-end text:change-id="${trackId}"/>` + end;
558
+ }
559
+ break;
560
+ }
561
+ case "figure_caption":
562
+ // We are already dealing with this in the figure. Prevent content from being added a second time.
563
+ return "";
564
+ case "figure_equation":
565
+ // We are already dealing with this in the figure.
566
+ break;
567
+ case "image":
568
+ // We are already dealing with this in the figure.
569
+ break;
570
+ case "table": {
571
+ if (options.listStyles) {
572
+ options.listStyles.forEach(listStyle => {
573
+ end =
574
+ `<text:list text:continue-numbering="true" text:style-name="${listStyle}"><text:list-item>` +
575
+ end;
576
+ start += "</text:list-item></text:list>";
577
+ });
578
+ }
579
+ const tableCaption = node.content[0];
580
+ let caption = node.attrs.caption
581
+ ? tableCaption?.content
582
+ ?.map((node, index) => this.transformRichtext(node, options, tableCaption, index))
583
+ .join("") || ""
584
+ : "";
585
+ // The table category should not be in the
586
+ // user's language but rather the document language
587
+ const category = node.attrs.category;
588
+ if (category !== "none") {
589
+ const categoryCounter = options.inFootnote
590
+ ? this.fnCategoryCounter
591
+ : this.categoryCounter;
592
+ if (!categoryCounter[category]) {
593
+ categoryCounter[category] = 1;
594
+ }
595
+ const catCount = categoryCounter[category]++;
596
+ const catCountXml = `<text:sequence text:ref-name="ref${category}${catCount - 1}${options.inFootnote ? "A" : ""}" text:name="${category}" text:formula="ooow:${category}+1" style:num-format="1">${catCount}${options.inFootnote ? "A" : ""}</text:sequence>`;
597
+ if (caption.length) {
598
+ caption = `<text:bookmark-start text:name="${node.attrs.id}"/>${CATS[category][this.settings.language]} ${catCountXml}<text:bookmark-end text:name="${node.attrs.id}"/>: ${caption}`;
599
+ }
600
+ else {
601
+ caption = `<text:bookmark-start text:name="${node.attrs.id}"/>${CATS[category][this.settings.language]} ${catCountXml}<text:bookmark-end text:name="${node.attrs.id}"/>`;
602
+ }
603
+ }
604
+ if (caption.length) {
605
+ if (!options.section) {
606
+ options.section = "Text_20_body";
607
+ }
608
+ this.styles.checkParStyle(options.section);
609
+ start += `<text:p text:style-name="${options.section}">${caption}</text:p>`;
610
+ }
611
+ const columns = node.content[1].content[0].content.length;
612
+ const styleId = this.styles.getTableStyleId(node.attrs.aligned, node.attrs.width);
613
+ start += `<table:table table:name="Table${styleId}" table:style-name="Table${styleId}">`;
614
+ start += `<table:table-column table:number-columns-repeated="${columns}" />`;
615
+ end = "</table:table>" + end;
616
+ break;
617
+ }
618
+ case "table_body":
619
+ // Pass through to table.
620
+ break;
621
+ case "table_caption":
622
+ // We already deal with this in 'table'.
623
+ return "";
624
+ case "table_row":
625
+ start += "<table:table-row>";
626
+ end = "</table:table-row>" + end;
627
+ break;
628
+ case "table_cell":
629
+ case "table_header":
630
+ if (node.attrs.rowspan && node.attrs.colspan) {
631
+ start += `<table:table-cell${node.attrs.rowspan > 1
632
+ ? ` table:number-rows-spanned="${node.attrs.rowspan}"`
633
+ : ""}${node.attrs.colspan > 1
634
+ ? ` table:number-columns-spanned="${node.attrs.colspan}"`
635
+ : ""} office:value-type="string">`;
636
+ end = "</table:table-cell>" + end;
637
+ }
638
+ else {
639
+ start += "<table:covered-table-cell/>";
640
+ }
641
+ break;
642
+ case "equation": {
643
+ const latex = node.attrs.equation;
644
+ const objectNumber = this.math.addMath(latex);
645
+ const styleId = this.styles.getGraphicStyleId("Formula");
646
+ content += `<draw:frame draw:style-name="${styleId}" draw:name="Object${objectNumber}" text:anchor-type="as-char" draw:z-index="${this.zIndex++}">
647
+ <draw:object xlink:href="./Object ${objectNumber}.js" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
648
+ <svg:desc>formula</svg:desc>
649
+ </draw:frame>`;
650
+ break;
651
+ }
652
+ case "cross_reference": {
653
+ const title = node.attrs.title;
654
+ const id = node.attrs.id;
655
+ if (title) {
656
+ start += `<text:bookmark-ref text:reference-format="text" text:ref-name="${id}">`;
657
+ end = "</text:bookmark-ref>" + end;
658
+ }
659
+ content += escapeText(title || "MISSING TARGET");
660
+ break;
661
+ }
662
+ case "hard_break":
663
+ content += "<text:line-break/>";
664
+ break;
665
+ // CSL bib entries
666
+ case "cslbib": {
667
+ options = Object.assign({}, options);
668
+ options.section = "Bibliography_20_1";
669
+ // Ensure Sect1 section style exists
670
+ this.styles.checkSectionStyle("Sect1");
671
+ // Generate a unique bibliography ID for this document
672
+ const bibId = generateZoteroId();
673
+ start += `<text:section text:style-name="Sect1" text:name="ZOTERO_BIBL CSL_BIBLIOGRAPHY ${bibId}">`;
674
+ end = "</text:section>" + end;
675
+ break;
676
+ }
677
+ case "cslblock":
678
+ end = "<text:line-break/>" + end;
679
+ break;
680
+ case "cslleftmargin":
681
+ end = "<text:tab/>" + end;
682
+ break;
683
+ case "cslindent":
684
+ start += "<text:tab/>";
685
+ end = "<text:line-break/>" + end;
686
+ break;
687
+ case "cslentry":
688
+ this.styles.checkParStyle(options.section);
689
+ start += `<text:p text:style-name="${options.section}">`;
690
+ end = "</text:p>" + end;
691
+ break;
692
+ case "cslinline":
693
+ case "cslrightinline":
694
+ break;
695
+ default:
696
+ break;
697
+ }
698
+ if (node.content) {
699
+ for (let i = 0; i < node.content.length; i++) {
700
+ content += this.transformRichtext(node.content[i], options, node, i);
701
+ }
702
+ }
703
+ if (inlineNode) {
704
+ const inlineInsert = node.marks?.find(mark => mark.type === "insertion" &&
705
+ mark.attrs.approved === false)?.attrs || blockInsert;
706
+ const inlineDelete = node.marks?.find(mark => mark.type === "deletion")?.attrs ||
707
+ options.blockDelete;
708
+ if (inlineDelete) {
709
+ if (parent) {
710
+ const trackId = this.tracks.addChange(Object.assign({ type: "deletion" }, inlineDelete), `<${TEXT_TYPES[parent.type]?.tag || "text:p"} ${TEXT_TYPES[parent.type]?.attrs(options) || `text:style-name="${options.section}"`}>${start + content + end}</${TEXT_TYPES[parent.type]?.tag || "text:p"}>`);
711
+ content = `<text:change text:change-id="${trackId}"/>`;
712
+ }
713
+ else {
714
+ content = "";
715
+ }
716
+ start = "";
717
+ end = "";
718
+ }
719
+ if (inlineInsert) {
720
+ const trackId = this.tracks.addChange(Object.assign({ type: "insertion" }, inlineInsert));
721
+ start += `<text:change-start text:change-id="${trackId}"/>`;
722
+ end = `<text:change-end text:change-id="${trackId}"/>` + end;
723
+ }
724
+ }
725
+ return start + content + end;
726
+ }
727
+ }
728
+ //# sourceMappingURL=richtext.js.map