@fiduswriter/document 0.1.0-alpha.3 → 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.
- package/README.md +22 -1
- package/dist/bibliography/common.d.ts +92 -0
- package/dist/bibliography/common.d.ts.map +1 -0
- package/dist/bibliography/common.js +85 -0
- package/dist/bibliography/common.js.map +1 -0
- package/dist/bibliography/csl_bib.d.ts +3 -0
- package/dist/bibliography/csl_bib.d.ts.map +1 -0
- package/dist/bibliography/csl_bib.js +131 -0
- package/dist/bibliography/csl_bib.js.map +1 -0
- package/dist/citations/citeproc_sys.d.ts +13 -0
- package/dist/citations/citeproc_sys.d.ts.map +1 -0
- package/dist/citations/citeproc_sys.js +43 -0
- package/dist/citations/citeproc_sys.js.map +1 -0
- package/dist/citations/format.d.ts +23 -0
- package/dist/citations/format.d.ts.map +1 -0
- package/dist/citations/format.js +161 -0
- package/dist/citations/format.js.map +1 -0
- package/dist/editor/e2ee/encryptor.d.ts +123 -0
- package/dist/editor/e2ee/encryptor.d.ts.map +1 -0
- package/dist/editor/e2ee/encryptor.js +201 -0
- package/dist/editor/e2ee/encryptor.js.map +1 -0
- package/dist/exporter/docx/citations.d.ts +21 -0
- package/dist/exporter/docx/citations.d.ts.map +1 -0
- package/dist/exporter/docx/citations.js +154 -0
- package/dist/exporter/docx/citations.js.map +1 -0
- package/dist/exporter/docx/comments.d.ts +18 -0
- package/dist/exporter/docx/comments.d.ts.map +1 -0
- package/dist/exporter/docx/comments.js +137 -0
- package/dist/exporter/docx/comments.js.map +1 -0
- package/dist/exporter/docx/footnotes.d.ts +42 -0
- package/dist/exporter/docx/footnotes.d.ts.map +1 -0
- package/dist/exporter/docx/footnotes.js +182 -0
- package/dist/exporter/docx/footnotes.js.map +1 -0
- package/dist/exporter/docx/images.d.ts +14 -0
- package/dist/exporter/docx/images.d.ts.map +1 -0
- package/dist/exporter/docx/images.js +86 -0
- package/dist/exporter/docx/images.js.map +1 -0
- package/dist/exporter/docx/index.d.ts +22 -0
- package/dist/exporter/docx/index.d.ts.map +1 -0
- package/dist/exporter/docx/index.js +107 -0
- package/dist/exporter/docx/index.js.map +1 -0
- package/dist/exporter/docx/lists.d.ts +33 -0
- package/dist/exporter/docx/lists.d.ts.map +1 -0
- package/dist/exporter/docx/lists.js +229 -0
- package/dist/exporter/docx/lists.js.map +1 -0
- package/dist/exporter/docx/math.d.ts +13 -0
- package/dist/exporter/docx/math.d.ts.map +1 -0
- package/dist/exporter/docx/math.js +42 -0
- package/dist/exporter/docx/math.js.map +1 -0
- package/dist/exporter/docx/metadata.d.ts +14 -0
- package/dist/exporter/docx/metadata.d.ts.map +1 -0
- package/dist/exporter/docx/metadata.js +239 -0
- package/dist/exporter/docx/metadata.js.map +1 -0
- package/dist/exporter/docx/rels.d.ts +25 -0
- package/dist/exporter/docx/rels.d.ts.map +1 -0
- package/dist/exporter/docx/rels.js +168 -0
- package/dist/exporter/docx/rels.js.map +1 -0
- package/dist/exporter/docx/render.d.ts +20 -0
- package/dist/exporter/docx/render.d.ts.map +1 -0
- package/dist/exporter/docx/render.js +774 -0
- package/dist/exporter/docx/render.js.map +1 -0
- package/dist/exporter/docx/richtext.d.ts +25 -0
- package/dist/exporter/docx/richtext.d.ts.map +1 -0
- package/dist/exporter/docx/richtext.js +1052 -0
- package/dist/exporter/docx/richtext.js.map +1 -0
- package/dist/exporter/docx/tables.d.ts +14 -0
- package/dist/exporter/docx/tables.d.ts.map +1 -0
- package/dist/exporter/docx/tables.js +109 -0
- package/dist/exporter/docx/tables.js.map +1 -0
- package/dist/exporter/docx/tools.d.ts +3 -0
- package/dist/exporter/docx/tools.d.ts.map +1 -0
- package/dist/exporter/docx/tools.js +48 -0
- package/dist/exporter/docx/tools.js.map +1 -0
- package/dist/exporter/epub/index.d.ts +11 -0
- package/dist/exporter/epub/index.d.ts.map +1 -0
- package/dist/exporter/epub/index.js +102 -0
- package/dist/exporter/epub/index.js.map +1 -0
- package/dist/exporter/epub/templates.d.ts +32 -0
- package/dist/exporter/epub/templates.d.ts.map +1 -0
- package/dist/exporter/epub/templates.js +95 -0
- package/dist/exporter/epub/templates.js.map +1 -0
- package/dist/exporter/epub/tools.d.ts +5 -0
- package/dist/exporter/epub/tools.d.ts.map +1 -0
- package/dist/exporter/epub/tools.js +81 -0
- package/dist/exporter/epub/tools.js.map +1 -0
- package/dist/exporter/html/citations.d.ts +27 -0
- package/dist/exporter/html/citations.d.ts.map +1 -0
- package/dist/exporter/html/citations.js +91 -0
- package/dist/exporter/html/citations.js.map +1 -0
- package/dist/exporter/html/convert.d.ts +100 -0
- package/dist/exporter/html/convert.d.ts.map +1 -0
- package/dist/exporter/html/convert.js +718 -0
- package/dist/exporter/html/convert.js.map +1 -0
- package/dist/exporter/html/index.d.ts +61 -0
- package/dist/exporter/html/index.d.ts.map +1 -0
- package/dist/exporter/html/index.js +134 -0
- package/dist/exporter/html/index.js.map +1 -0
- package/dist/exporter/html/templates.d.ts +10 -0
- package/dist/exporter/html/templates.d.ts.map +1 -0
- package/dist/exporter/html/templates.js +21 -0
- package/dist/exporter/html/templates.js.map +1 -0
- package/dist/exporter/html/tools.d.ts +2 -0
- package/dist/exporter/html/tools.d.ts.map +1 -0
- package/dist/exporter/html/tools.js +49 -0
- package/dist/exporter/html/tools.js.map +1 -0
- package/dist/exporter/jats/bibliography.d.ts +2 -0
- package/dist/exporter/jats/bibliography.d.ts.map +1 -0
- package/dist/exporter/jats/bibliography.js +153 -0
- package/dist/exporter/jats/bibliography.js.map +1 -0
- package/dist/exporter/jats/citations.d.ts +14 -0
- package/dist/exporter/jats/citations.d.ts.map +1 -0
- package/dist/exporter/jats/citations.js +83 -0
- package/dist/exporter/jats/citations.js.map +1 -0
- package/dist/exporter/jats/convert.d.ts +45 -0
- package/dist/exporter/jats/convert.d.ts.map +1 -0
- package/dist/exporter/jats/convert.js +799 -0
- package/dist/exporter/jats/convert.js.map +1 -0
- package/dist/exporter/jats/index.d.ts +19 -0
- package/dist/exporter/jats/index.d.ts.map +1 -0
- package/dist/exporter/jats/index.js +66 -0
- package/dist/exporter/jats/index.js.map +1 -0
- package/dist/exporter/jats/templates.d.ts +16 -0
- package/dist/exporter/jats/templates.d.ts.map +1 -0
- package/dist/exporter/jats/templates.js +25 -0
- package/dist/exporter/jats/templates.js.map +1 -0
- package/dist/exporter/jats/text.d.ts +3 -0
- package/dist/exporter/jats/text.d.ts.map +1 -0
- package/dist/exporter/jats/text.js +72 -0
- package/dist/exporter/jats/text.js.map +1 -0
- package/dist/exporter/latex/convert.d.ts +27 -0
- package/dist/exporter/latex/convert.d.ts.map +1 -0
- package/dist/exporter/latex/convert.js +865 -0
- package/dist/exporter/latex/convert.js.map +1 -0
- package/dist/exporter/latex/escape_latex.d.ts +2 -0
- package/dist/exporter/latex/escape_latex.d.ts.map +1 -0
- package/dist/exporter/latex/escape_latex.js +20 -0
- package/dist/exporter/latex/escape_latex.js.map +1 -0
- package/dist/exporter/latex/index.d.ts +23 -0
- package/dist/exporter/latex/index.d.ts.map +1 -0
- package/dist/exporter/latex/index.js +57 -0
- package/dist/exporter/latex/index.js.map +1 -0
- package/dist/exporter/latex/readme.d.ts +2 -0
- package/dist/exporter/latex/readme.d.ts.map +1 -0
- package/dist/exporter/latex/readme.js +23 -0
- package/dist/exporter/latex/readme.js.map +1 -0
- package/dist/exporter/native/shrink.d.ts +21 -0
- package/dist/exporter/native/shrink.d.ts.map +1 -0
- package/dist/exporter/native/shrink.js +115 -0
- package/dist/exporter/native/shrink.js.map +1 -0
- package/dist/exporter/odt/citations.d.ts +18 -0
- package/dist/exporter/odt/citations.d.ts.map +1 -0
- package/dist/exporter/odt/citations.js +87 -0
- package/dist/exporter/odt/citations.js.map +1 -0
- package/dist/exporter/odt/footnotes.d.ts +25 -0
- package/dist/exporter/odt/footnotes.d.ts.map +1 -0
- package/dist/exporter/odt/footnotes.js +112 -0
- package/dist/exporter/odt/footnotes.js.map +1 -0
- package/dist/exporter/odt/images.d.ts +13 -0
- package/dist/exporter/odt/images.d.ts.map +1 -0
- package/dist/exporter/odt/images.js +98 -0
- package/dist/exporter/odt/images.js.map +1 -0
- package/dist/exporter/odt/index.d.ts +23 -0
- package/dist/exporter/odt/index.d.ts.map +1 -0
- package/dist/exporter/odt/index.js +99 -0
- package/dist/exporter/odt/index.js.map +1 -0
- package/dist/exporter/odt/math.d.ts +13 -0
- package/dist/exporter/odt/math.d.ts.map +1 -0
- package/dist/exporter/odt/math.js +48 -0
- package/dist/exporter/odt/math.js.map +1 -0
- package/dist/exporter/odt/metadata.d.ts +14 -0
- package/dist/exporter/odt/metadata.d.ts.map +1 -0
- package/dist/exporter/odt/metadata.js +203 -0
- package/dist/exporter/odt/metadata.js.map +1 -0
- package/dist/exporter/odt/render.d.ts +24 -0
- package/dist/exporter/odt/render.d.ts.map +1 -0
- package/dist/exporter/odt/render.js +644 -0
- package/dist/exporter/odt/render.js.map +1 -0
- package/dist/exporter/odt/richtext.d.ts +22 -0
- package/dist/exporter/odt/richtext.d.ts.map +1 -0
- package/dist/exporter/odt/richtext.js +728 -0
- package/dist/exporter/odt/richtext.js.map +1 -0
- package/dist/exporter/odt/styles.d.ts +33 -0
- package/dist/exporter/odt/styles.d.ts.map +1 -0
- package/dist/exporter/odt/styles.js +348 -0
- package/dist/exporter/odt/styles.js.map +1 -0
- package/dist/exporter/odt/track.d.ts +11 -0
- package/dist/exporter/odt/track.d.ts.map +1 -0
- package/dist/exporter/odt/track.js +59 -0
- package/dist/exporter/odt/track.js.map +1 -0
- package/dist/exporter/pandoc/citations.d.ts +17 -0
- package/dist/exporter/pandoc/citations.d.ts.map +1 -0
- package/dist/exporter/pandoc/citations.js +85 -0
- package/dist/exporter/pandoc/citations.js.map +1 -0
- package/dist/exporter/pandoc/convert.d.ts +38 -0
- package/dist/exporter/pandoc/convert.d.ts.map +1 -0
- package/dist/exporter/pandoc/convert.js +881 -0
- package/dist/exporter/pandoc/convert.js.map +1 -0
- package/dist/exporter/pandoc/index.d.ts +38 -0
- package/dist/exporter/pandoc/index.d.ts.map +1 -0
- package/dist/exporter/pandoc/index.js +67 -0
- package/dist/exporter/pandoc/index.js.map +1 -0
- package/dist/exporter/pandoc/readme.d.ts +2 -0
- package/dist/exporter/pandoc/readme.d.ts.map +1 -0
- package/dist/exporter/pandoc/readme.js +9 -0
- package/dist/exporter/pandoc/readme.js.map +1 -0
- package/dist/exporter/pandoc/tools.d.ts +6 -0
- package/dist/exporter/pandoc/tools.d.ts.map +1 -0
- package/dist/exporter/pandoc/tools.js +52 -0
- package/dist/exporter/pandoc/tools.js.map +1 -0
- package/dist/exporter/print/index.d.ts +9 -0
- package/dist/exporter/print/index.d.ts.map +1 -0
- package/dist/exporter/print/index.js +140 -0
- package/dist/exporter/print/index.js.map +1 -0
- package/dist/exporter/tools/doc_content.d.ts +7 -0
- package/dist/exporter/tools/doc_content.d.ts.map +1 -0
- package/dist/exporter/tools/doc_content.js +129 -0
- package/dist/exporter/tools/doc_content.js.map +1 -0
- package/dist/exporter/tools/file.d.ts +2 -0
- package/dist/exporter/tools/file.d.ts.map +1 -0
- package/dist/exporter/tools/file.js +10 -0
- package/dist/exporter/tools/file.js.map +1 -0
- package/dist/exporter/tools/json.d.ts +7 -0
- package/dist/exporter/tools/json.d.ts.map +1 -0
- package/dist/exporter/tools/json.js +82 -0
- package/dist/exporter/tools/json.js.map +1 -0
- package/dist/exporter/tools/svg.d.ts +2 -0
- package/dist/exporter/tools/svg.d.ts.map +1 -0
- package/dist/exporter/tools/svg.js +26 -0
- package/dist/exporter/tools/svg.js.map +1 -0
- package/dist/exporter/tools/xml.d.ts +41 -0
- package/dist/exporter/tools/xml.d.ts.map +1 -0
- package/dist/exporter/tools/xml.js +440 -0
- package/dist/exporter/tools/xml.js.map +1 -0
- package/dist/exporter/tools/xml_zip.d.ts +20 -0
- package/dist/exporter/tools/xml_zip.d.ts.map +1 -0
- package/dist/exporter/tools/xml_zip.js +86 -0
- package/dist/exporter/tools/xml_zip.js.map +1 -0
- package/dist/exporter/tools/zip.d.ts +21 -0
- package/dist/exporter/tools/zip.d.ts.map +1 -0
- package/dist/exporter/tools/zip.js +71 -0
- package/dist/exporter/tools/zip.js.map +1 -0
- package/dist/exporter/tools/zotero_csl.d.ts +10 -0
- package/dist/exporter/tools/zotero_csl.d.ts.map +1 -0
- package/dist/exporter/tools/zotero_csl.js +78 -0
- package/dist/exporter/tools/zotero_csl.js.map +1 -0
- package/dist/importer/citations.d.ts +25 -0
- package/dist/importer/citations.d.ts.map +1 -0
- package/dist/importer/citations.js +116 -0
- package/dist/importer/citations.js.map +1 -0
- package/dist/importer/docx/citations.d.ts +65 -0
- package/dist/importer/docx/citations.d.ts.map +1 -0
- package/dist/importer/docx/citations.js +106 -0
- package/dist/importer/docx/citations.js.map +1 -0
- package/dist/importer/docx/convert.d.ts +228 -0
- package/dist/importer/docx/convert.d.ts.map +1 -0
- package/dist/importer/docx/convert.js +1226 -0
- package/dist/importer/docx/convert.js.map +1 -0
- package/dist/importer/docx/helpers.d.ts +2 -0
- package/dist/importer/docx/helpers.d.ts.map +1 -0
- package/dist/importer/docx/helpers.js +10 -0
- package/dist/importer/docx/helpers.js.map +1 -0
- package/dist/importer/docx/omml2mathml.d.ts +7 -0
- package/dist/importer/docx/omml2mathml.d.ts.map +1 -0
- package/dist/importer/docx/omml2mathml.js +1239 -0
- package/dist/importer/docx/omml2mathml.js.map +1 -0
- package/dist/importer/docx/parse.d.ts +205 -0
- package/dist/importer/docx/parse.d.ts.map +1 -0
- package/dist/importer/docx/parse.js +663 -0
- package/dist/importer/docx/parse.js.map +1 -0
- package/dist/importer/native/get_images.d.ts +11 -0
- package/dist/importer/native/get_images.d.ts.map +1 -0
- package/dist/importer/native/get_images.js +64 -0
- package/dist/importer/native/get_images.js.map +1 -0
- package/dist/importer/native/update.d.ts +6 -0
- package/dist/importer/native/update.d.ts.map +1 -0
- package/dist/importer/native/update.js +26 -0
- package/dist/importer/native/update.js.map +1 -0
- package/dist/importer/odt/citations.d.ts +47 -0
- package/dist/importer/odt/citations.d.ts.map +1 -0
- package/dist/importer/odt/citations.js +79 -0
- package/dist/importer/odt/citations.js.map +1 -0
- package/dist/importer/odt/convert.d.ts +330 -0
- package/dist/importer/odt/convert.d.ts.map +1 -0
- package/dist/importer/odt/convert.js +1506 -0
- package/dist/importer/odt/convert.js.map +1 -0
- package/dist/importer/pandoc/convert.d.ts +84 -0
- package/dist/importer/pandoc/convert.d.ts.map +1 -0
- package/dist/importer/pandoc/convert.js +777 -0
- package/dist/importer/pandoc/convert.js.map +1 -0
- package/dist/importer/pandoc/helpers.d.ts +4 -0
- package/dist/importer/pandoc/helpers.d.ts.map +1 -0
- package/dist/importer/pandoc/helpers.js +75 -0
- package/dist/importer/pandoc/helpers.js.map +1 -0
- package/dist/importer/zip_analyzer.d.ts +25 -0
- package/dist/importer/zip_analyzer.d.ts.map +1 -0
- package/dist/importer/zip_analyzer.js +84 -0
- package/dist/importer/zip_analyzer.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/mathlive/opf_includes.d.ts +2 -0
- package/dist/mathlive/opf_includes.d.ts.map +1 -0
- package/dist/mathlive/opf_includes.js +25 -0
- package/dist/mathlive/opf_includes.js.map +1 -0
- package/dist/schema/common/annotate.d.ts +59 -0
- package/dist/schema/common/annotate.d.ts.map +1 -0
- package/dist/schema/common/annotate.js +75 -0
- package/dist/schema/common/annotate.js.map +1 -0
- package/dist/schema/common/base.d.ts +109 -0
- package/dist/schema/common/base.d.ts.map +1 -0
- package/dist/schema/common/base.js +109 -0
- package/dist/schema/common/base.js.map +1 -0
- package/dist/schema/common/citation.d.ts +29 -0
- package/dist/schema/common/citation.d.ts.map +1 -0
- package/dist/schema/common/citation.js +62 -0
- package/dist/schema/common/citation.js.map +1 -0
- package/dist/schema/common/equation.d.ts +18 -0
- package/dist/schema/common/equation.d.ts.map +1 -0
- package/dist/schema/common/equation.js +32 -0
- package/dist/schema/common/equation.js.map +1 -0
- package/dist/schema/common/figure.d.ts +108 -0
- package/dist/schema/common/figure.d.ts.map +1 -0
- package/dist/schema/common/figure.js +176 -0
- package/dist/schema/common/figure.js.map +1 -0
- package/dist/schema/common/heading.d.ts +33 -0
- package/dist/schema/common/heading.d.ts.map +1 -0
- package/dist/schema/common/heading.js +41 -0
- package/dist/schema/common/heading.js.map +1 -0
- package/dist/schema/common/index.d.ts +11 -0
- package/dist/schema/common/index.d.ts.map +1 -0
- package/dist/schema/common/index.js +11 -0
- package/dist/schema/common/index.js.map +1 -0
- package/dist/schema/common/list.d.ts +83 -0
- package/dist/schema/common/list.d.ts.map +1 -0
- package/dist/schema/common/list.js +92 -0
- package/dist/schema/common/list.js.map +1 -0
- package/dist/schema/common/reference.d.ts +78 -0
- package/dist/schema/common/reference.d.ts.map +1 -0
- package/dist/schema/common/reference.js +97 -0
- package/dist/schema/common/reference.js.map +1 -0
- package/dist/schema/common/table.d.ts +92 -0
- package/dist/schema/common/table.d.ts.map +1 -0
- package/dist/schema/common/table.js +85 -0
- package/dist/schema/common/table.js.map +1 -0
- package/dist/schema/common/track.d.ts +131 -0
- package/dist/schema/common/track.d.ts.map +1 -0
- package/dist/schema/common/track.js +184 -0
- package/dist/schema/common/track.js.map +1 -0
- package/dist/schema/const.d.ts +3 -0
- package/dist/schema/const.d.ts.map +1 -0
- package/{src → dist}/schema/const.js +3 -3
- package/dist/schema/const.js.map +1 -0
- package/dist/schema/convert.d.ts +3 -0
- package/dist/schema/convert.d.ts.map +1 -0
- package/dist/schema/convert.js +1215 -0
- package/dist/schema/convert.js.map +1 -0
- package/dist/schema/document/content.d.ts +137 -0
- package/dist/schema/document/content.d.ts.map +1 -0
- package/dist/schema/document/content.js +177 -0
- package/dist/schema/document/content.js.map +1 -0
- package/dist/schema/document/index.d.ts +879 -0
- package/dist/schema/document/index.d.ts.map +1 -0
- package/dist/schema/document/index.js +68 -0
- package/dist/schema/document/index.js.map +1 -0
- package/dist/schema/document/structure.d.ts +273 -0
- package/dist/schema/document/structure.d.ts.map +1 -0
- package/dist/schema/document/structure.js +445 -0
- package/dist/schema/document/structure.js.map +1 -0
- package/dist/schema/export.d.ts +880 -0
- package/dist/schema/export.d.ts.map +1 -0
- package/dist/schema/export.js +16 -0
- package/dist/schema/export.js.map +1 -0
- package/dist/schema/footnotes.d.ts +499 -0
- package/dist/schema/footnotes.d.ts.map +1 -0
- package/dist/schema/footnotes.js +88 -0
- package/dist/schema/footnotes.js.map +1 -0
- package/dist/schema/footnotes_convert.d.ts +5 -0
- package/dist/schema/footnotes_convert.d.ts.map +1 -0
- package/dist/schema/footnotes_convert.js +26 -0
- package/dist/schema/footnotes_convert.js.map +1 -0
- package/dist/schema/i18n.d.ts +586 -0
- package/dist/schema/i18n.d.ts.map +1 -0
- package/dist/schema/i18n.js +585 -0
- package/dist/schema/i18n.js.map +1 -0
- package/dist/schema/index.d.ts +6 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/index.js +6 -0
- package/dist/schema/index.js.map +1 -0
- package/dist/schema/mini_json.d.ts +5 -0
- package/dist/schema/mini_json.d.ts.map +1 -0
- package/dist/schema/mini_json.js +50 -0
- package/dist/schema/mini_json.js.map +1 -0
- package/dist/schema/text.d.ts +2 -0
- package/dist/schema/text.d.ts.map +1 -0
- package/dist/schema/text.js +23 -0
- package/dist/schema/text.js.map +1 -0
- package/dist/types.d.ts +122 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +9 -0
- package/dist/types.js.map +1 -0
- package/package.json +48 -16
- package/scripts/export-schema.js +1 -1
- package/src/exporter/tools/{file.js → file.ts} +1 -1
- package/src/exporter/tools/{json.js → json.ts} +30 -19
- package/src/global.d.ts +11 -0
- package/src/schema/const.ts +58 -0
- package/src/types.ts +136 -0
- package/jest.config.js +0 -24
- /package/src/{index.js → index.ts} +0 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { xmlDOM } from "./xml.js";
|
|
2
|
+
import { get } from "fwtoolkit";
|
|
3
|
+
// Handle a zip file containing XML files. Make sure files are only opened once,
|
|
4
|
+
// and provide a mechanism to save the file.
|
|
5
|
+
export class XmlZip {
|
|
6
|
+
constructor(url, mimeType) {
|
|
7
|
+
this.url = url;
|
|
8
|
+
this.mimeType = mimeType;
|
|
9
|
+
this.docs = {};
|
|
10
|
+
this.extraFiles = {};
|
|
11
|
+
this.rawFile = false;
|
|
12
|
+
}
|
|
13
|
+
init() {
|
|
14
|
+
return import("jszip")
|
|
15
|
+
.then(({ default: JSZip }) => {
|
|
16
|
+
this.zip = new JSZip();
|
|
17
|
+
return this.downloadZip();
|
|
18
|
+
})
|
|
19
|
+
.then(() => this.loadZip());
|
|
20
|
+
}
|
|
21
|
+
downloadZip() {
|
|
22
|
+
return get(this.url)
|
|
23
|
+
.then(response => response.blob())
|
|
24
|
+
.then(blob => (this.rawFile = blob));
|
|
25
|
+
}
|
|
26
|
+
loadZip() {
|
|
27
|
+
return this.zip.loadAsync(this.rawFile);
|
|
28
|
+
}
|
|
29
|
+
// Open file at filePath from zip file and parse it as XML.
|
|
30
|
+
getXml(filePath, defaultContents) {
|
|
31
|
+
if (this.docs[filePath]) {
|
|
32
|
+
// file has been loaded already.
|
|
33
|
+
return Promise.resolve(this.docs[filePath]);
|
|
34
|
+
}
|
|
35
|
+
else if (this.zip.files[filePath]) {
|
|
36
|
+
return this.zip
|
|
37
|
+
.file(filePath)
|
|
38
|
+
.async("string")
|
|
39
|
+
.then(string => {
|
|
40
|
+
this.docs[filePath] = xmlDOM(string);
|
|
41
|
+
return Promise.resolve(this.docs[filePath]);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
else if (defaultContents) {
|
|
45
|
+
return Promise.resolve(defaultContents).then(string => {
|
|
46
|
+
this.docs[filePath] = xmlDOM(string);
|
|
47
|
+
return Promise.resolve(this.docs[filePath]);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
// File couldn't be found and there was no default value.
|
|
52
|
+
return Promise.reject(new Error("File not found"));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
// Add an xml file at filepath without checking for previous version
|
|
56
|
+
addXmlFile(filePath, xmlContents) {
|
|
57
|
+
this.docs[filePath] = xmlContents;
|
|
58
|
+
}
|
|
59
|
+
// Add extra file to be saved in zip later.
|
|
60
|
+
addExtraFile(filePath, fileContents) {
|
|
61
|
+
this.extraFiles[filePath] = fileContents;
|
|
62
|
+
}
|
|
63
|
+
// Put all currently open XML files into zip.
|
|
64
|
+
allXMLToZip() {
|
|
65
|
+
for (const fileName in this.docs) {
|
|
66
|
+
this.xmlToZip(fileName);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
// Put all extra files into zip.
|
|
70
|
+
allExtraToZip() {
|
|
71
|
+
for (const fileName in this.extraFiles) {
|
|
72
|
+
this.zip.file(fileName, this.extraFiles[fileName]);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
// Put the xml identified by filePath into zip.
|
|
76
|
+
xmlToZip(filePath) {
|
|
77
|
+
const string = this.docs[filePath].toString();
|
|
78
|
+
this.zip.file(filePath, string);
|
|
79
|
+
}
|
|
80
|
+
prepareBlob() {
|
|
81
|
+
this.allXMLToZip();
|
|
82
|
+
this.allExtraToZip();
|
|
83
|
+
return this.zip.generateAsync({ type: "blob", mimeType: this.mimeType });
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=xml_zip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"xml_zip.js","sourceRoot":"","sources":["../../../src/exporter/tools/xml_zip.js"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAA;AAE/B,OAAO,EAAC,GAAG,EAAC,MAAM,WAAW,CAAA;AAC7B,gFAAgF;AAChF,4CAA4C;AAE5C,MAAM,OAAO,MAAM;IACf,YAAY,GAAG,EAAE,QAAQ;QACrB,IAAI,CAAC,GAA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AAI,CAAC,QAAQ,EAAE,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAA;QACtD,CAAC;IACL,CAAC;IAED,+CAA+C;IAC/C,QAAQ,CAAC,QAAQ;QACb,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,QAAQ,EAAE,CAAA;QAC7C,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;IACnC,CAAC;IAED,WAAW;QACP,IAAI,CAAC,WAAW,EAAE,CAAA;QAClB,IAAI,CAAC,aAAa,EAAE,CAAA;QAEpB,OAAO,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,EAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAC,CAAC,CAAA;IAC1E,CAAC;CACJ"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** Creates a zip file.
|
|
2
|
+
* @function zipFileCreator
|
|
3
|
+
* @param {list} textFiles A list of files in plain text format.
|
|
4
|
+
* @param {list} binaryFiles A list fo files that have to be downloaded from the internet before being included.
|
|
5
|
+
* @param {list} includeZips A list of zip files to be merged into the output zip file.
|
|
6
|
+
* @param {string} [mimeType=application/zip] The mimetype of the file that is to be created.
|
|
7
|
+
*/
|
|
8
|
+
export class ZipFileCreator {
|
|
9
|
+
constructor(textFiles?: any[], binaryFiles?: any[], zipFiles?: any[], mimeType?: string, date?: Date);
|
|
10
|
+
textFiles: any[];
|
|
11
|
+
binaryFiles: any[];
|
|
12
|
+
zipFiles: any[];
|
|
13
|
+
mimeType: string;
|
|
14
|
+
date: Date;
|
|
15
|
+
init(): Promise<Blob>;
|
|
16
|
+
zipFs: import("jszip") | undefined;
|
|
17
|
+
includeZips(): Promise<Blob>;
|
|
18
|
+
createZip(): Promise<Blob>;
|
|
19
|
+
convertDataURIToBlob(dataURI: any): Blob;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=zip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zip.d.ts","sourceRoot":"","sources":["../../../src/exporter/tools/zip.js"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAEH;IACI,sGAYC;IALG,iBAA0B;IAC1B,mBAA8B;IAC9B,gBAAwB;IACxB,iBAAwB;IACxB,WAAgB;IAGpB,sBAYC;IATO,mCAAwB;IAWhC,6BAiBC;IAED,2BAyBC;IAGD,yCAEC;CACJ"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { convertDataURIToBlob, get } from "fwtoolkit";
|
|
2
|
+
/** Creates a zip file.
|
|
3
|
+
* @function zipFileCreator
|
|
4
|
+
* @param {list} textFiles A list of files in plain text format.
|
|
5
|
+
* @param {list} binaryFiles A list fo files that have to be downloaded from the internet before being included.
|
|
6
|
+
* @param {list} includeZips A list of zip files to be merged into the output zip file.
|
|
7
|
+
* @param {string} [mimeType=application/zip] The mimetype of the file that is to be created.
|
|
8
|
+
*/
|
|
9
|
+
export class ZipFileCreator {
|
|
10
|
+
constructor(textFiles = [], binaryFiles = [], zipFiles = [], mimeType = "application/zip", date = new Date()) {
|
|
11
|
+
this.textFiles = textFiles;
|
|
12
|
+
this.binaryFiles = binaryFiles;
|
|
13
|
+
this.zipFiles = zipFiles;
|
|
14
|
+
this.mimeType = mimeType;
|
|
15
|
+
this.date = date;
|
|
16
|
+
}
|
|
17
|
+
init() {
|
|
18
|
+
return import("jszip").then(({ default: JSZip }) => {
|
|
19
|
+
JSZip.defaults.date = this.date;
|
|
20
|
+
this.zipFs = new JSZip();
|
|
21
|
+
if (this.mimeType !== "application/zip") {
|
|
22
|
+
this.zipFs.file("mimetype", this.mimeType, {
|
|
23
|
+
compression: "STORE"
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
return this.includeZips();
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
includeZips() {
|
|
30
|
+
const getZipBlobs = this.zipFiles.map(zipFile => {
|
|
31
|
+
return get(zipFile.url)
|
|
32
|
+
.then(response => response.blob())
|
|
33
|
+
.then(blob => (zipFile.blob = blob));
|
|
34
|
+
});
|
|
35
|
+
return Promise.all(getZipBlobs)
|
|
36
|
+
.then(() => {
|
|
37
|
+
return this.zipFiles.map(zipFile => {
|
|
38
|
+
const zipDir = zipFile.directory === ""
|
|
39
|
+
? this.zipFs
|
|
40
|
+
: this.zipFs.folder(zipFile.directory);
|
|
41
|
+
return zipDir.loadAsync(zipFile.blob);
|
|
42
|
+
});
|
|
43
|
+
})
|
|
44
|
+
.then(() => this.createZip());
|
|
45
|
+
}
|
|
46
|
+
createZip() {
|
|
47
|
+
this.textFiles.forEach(textFile => {
|
|
48
|
+
this.zipFs.file(textFile.filename, textFile.contents, {
|
|
49
|
+
compression: "DEFLATE"
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
const blobPromises = this.binaryFiles.map(binaryFile => get(binaryFile.url)
|
|
53
|
+
.then(response => response.blob())
|
|
54
|
+
.then(blob => Promise.resolve({ blob, filename: binaryFile.filename })));
|
|
55
|
+
return Promise.all(blobPromises).then(promises => {
|
|
56
|
+
promises.forEach(promise => this.zipFs.file(promise.filename, promise.blob, {
|
|
57
|
+
binary: true,
|
|
58
|
+
compression: "DEFLATE"
|
|
59
|
+
}));
|
|
60
|
+
return this.zipFs.generateAsync({
|
|
61
|
+
type: "blob",
|
|
62
|
+
mimeType: this.mimeType
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
// Legacy - remove in 3.12. Can be sued directly from function in common/blob.js
|
|
67
|
+
convertDataURIToBlob(dataURI) {
|
|
68
|
+
return convertDataURIToBlob(dataURI);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=zip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zip.js","sourceRoot":"","sources":["../../../src/exporter/tools/zip.js"],"names":[],"mappings":"AAAA,OAAO,E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,CAAC,EAAE;YAC7C,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CACvB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,IAAI,EAAE;gBAC5C,MAAM,EAAE,IAAI;gBACZ,WAAW,EAAE,SAAS;aACzB,CAAC,CACL,CAAA;YACD,OAAO,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC;gBAC5B,IAAI,EAAE,MAAM;gBACZ,QAAQ,EAAE,IAAI,CAAC,QAAQ;aAC1B,CAAC,CAAA;QACN,CAAC,CAAC,CAAA;IACN,CAAC;IAED,gFAAgF;IAChF,oBAAoB,CAAC,OAAO;QACxB,OAAO,oBAAoB,CAAC,OAAO,CAAC,CAAA;IACxC,CAAC;CACJ"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a Zotero citation JSON object.
|
|
3
|
+
* @param {Array} references - Array of {id, prefix?, locator?} from citation node
|
|
4
|
+
* @param {Object} bibDB - Bibliography database
|
|
5
|
+
* @param {string} formattedCitation - Pre-formatted citation text from citeproc
|
|
6
|
+
* @param {string} citationId - Optional citation ID (generated if not provided)
|
|
7
|
+
* @returns {Object} Zotero citation JSON object
|
|
8
|
+
*/
|
|
9
|
+
export function createZoteroCitation(references: any[], bibDB: Object, formattedCitation: string, citationId?: string): Object;
|
|
10
|
+
//# sourceMappingURL=zotero_csl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zotero_csl.d.ts","sourceRoot":"","sources":["../../../src/exporter/tools/zotero_csl.js"],"names":[],"mappings":"AAgCA;;;;;;;GAOG;AACH,+DALW,MAAM,qBACN,MAAM,eACN,MAAM,GACJ,MAAM,CAsDlB"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper functions for creating Zotero-compatible citation data.
|
|
3
|
+
* Uses CSLExporter from biblatex-csl-converter to convert Fidus Writer's
|
|
4
|
+
* internal BibLaTeX format to CSL-JSON.
|
|
5
|
+
*/
|
|
6
|
+
import { CSLExporter } from "biblatex-csl-converter";
|
|
7
|
+
/**
|
|
8
|
+
* Generate a random citation ID similar to Zotero's format.
|
|
9
|
+
* Zotero uses 8-10 character alphanumeric IDs.
|
|
10
|
+
*/
|
|
11
|
+
function generateCitationId() {
|
|
12
|
+
const chars = "abcdefghijklmnopqrstuvwxyz0123456789";
|
|
13
|
+
let id = "";
|
|
14
|
+
for (let i = 0; i < 8; i++) {
|
|
15
|
+
id += chars.charAt(Math.floor(Math.random() * chars.length));
|
|
16
|
+
}
|
|
17
|
+
return id;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Convert bibliography entries to CSL-JSON format.
|
|
21
|
+
* @param {Object} bibDB - The bibliography database
|
|
22
|
+
* @param {Array} ids - Array of entry IDs to convert
|
|
23
|
+
* @returns {Object} Object mapping IDs to CSL-JSON entries
|
|
24
|
+
*/
|
|
25
|
+
function convertToCSL(bibDB, ids) {
|
|
26
|
+
const exporter = new CSLExporter(bibDB.db, ids);
|
|
27
|
+
return exporter.parse();
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Create a Zotero citation JSON object.
|
|
31
|
+
* @param {Array} references - Array of {id, prefix?, locator?} from citation node
|
|
32
|
+
* @param {Object} bibDB - Bibliography database
|
|
33
|
+
* @param {string} formattedCitation - Pre-formatted citation text from citeproc
|
|
34
|
+
* @param {string} citationId - Optional citation ID (generated if not provided)
|
|
35
|
+
* @returns {Object} Zotero citation JSON object
|
|
36
|
+
*/
|
|
37
|
+
export function createZoteroCitation(references, bibDB, formattedCitation, citationId = null) {
|
|
38
|
+
const citationID = citationId || generateCitationId();
|
|
39
|
+
// Get the IDs of all referenced items
|
|
40
|
+
const ids = references.map(ref => ref.id);
|
|
41
|
+
// Convert to CSL-JSON
|
|
42
|
+
const _cslData = convertToCSL(bibDB, ids);
|
|
43
|
+
const citationItems = references
|
|
44
|
+
.map(ref => {
|
|
45
|
+
const entry = bibDB.db[ref.id];
|
|
46
|
+
if (!entry) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
const citationKey = entry.entry_key || String(ref.id);
|
|
50
|
+
const item = {
|
|
51
|
+
id: ref.id,
|
|
52
|
+
uris: [],
|
|
53
|
+
itemData: {
|
|
54
|
+
...ref.item,
|
|
55
|
+
id: citationKey
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
if (ref.locator) {
|
|
59
|
+
item.locator = ref.locator;
|
|
60
|
+
}
|
|
61
|
+
if (ref.prefix) {
|
|
62
|
+
item.prefix = ref.prefix;
|
|
63
|
+
}
|
|
64
|
+
return item;
|
|
65
|
+
})
|
|
66
|
+
.filter(item => item !== null);
|
|
67
|
+
return {
|
|
68
|
+
citationID,
|
|
69
|
+
properties: {
|
|
70
|
+
formattedCitation,
|
|
71
|
+
plainCitation: formattedCitation,
|
|
72
|
+
noteIndex: 0
|
|
73
|
+
},
|
|
74
|
+
citationItems,
|
|
75
|
+
schema: "https://github.com/citation-style-language/schema/raw/master/csl-citation.json"
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=zotero_csl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zotero_csl.js","sourceRoot":"","sources":["../../../src/exporter/tools/zotero_csl.js"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAC,WAAW,EAAC,MAAM,wBAAwB,CAAA;AAElD;;;GAGG;AACH,SAAS,kBAAkB;IACvB,MAAM,KAAK,GAAG,sCAAsC,CAAA;IACpD,IAAI,EAAE,GAAG,EAAE,CAAA;IACX,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QACzB,EAAE,IAAI,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,KA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AI,GAAG,CAAC,MAAM,EAAE,CAAC;YACb,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC,MAAM,CAAA;QAC5B,CAAC;QAED,OAAO,IAAI,CAAA;IACf,CAAC,CAAC;SACD,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,KAAK,IAAI,CAAC,CAAA;IAElC,OAAO;QACH,UAAU;QACV,UAAU,EAAE;YACR,iBAAiB;YACjB,aAAa,EAAE,iBAAiB;YAChC,SAAS,EAAE,CAAC;SACf;QACD,aAAa;QACb,MAAM,EAAE,gFAAgF;KAC3F,CAAA;AACL,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert a CitationResult from a static DocxCitationsParser or
|
|
3
|
+
* OdtCitationsParser call into a Fidus Writer citation node.
|
|
4
|
+
*
|
|
5
|
+
* The `bibliography` object is mutated in place to include any new entries.
|
|
6
|
+
*
|
|
7
|
+
* Each item in `metadata` (when `retrieveMetadata` was true) may carry:
|
|
8
|
+
* - id : entry_key string identifying which entry this item refers to
|
|
9
|
+
* - prefix : citation prefix text
|
|
10
|
+
* - suffix : citation suffix / locator text (used as `locator`)
|
|
11
|
+
* - locator : explicit locator string (preferred over suffix when present)
|
|
12
|
+
* - authorOnly : boolean – render author name only (maps to "textcite")
|
|
13
|
+
* - suppressAuthor : boolean – suppress author name (ignored, maps to default)
|
|
14
|
+
* - authorYear : boolean – render author name and year (maps to "textcite")
|
|
15
|
+
*
|
|
16
|
+
* `format` on the returned citation node matches the Fidus Writer citation schema:
|
|
17
|
+
* - "textcite" when authorOnly or authorYear is set on the (single) item (biblatex \textcite)
|
|
18
|
+
* - "autocite" otherwise, including when suppressAuthor is set (biblatex \autocite)
|
|
19
|
+
*
|
|
20
|
+
* @param {Object} result CitationResult from a static parser method
|
|
21
|
+
* @param {Object} bibliography Fidus Writer bibliography (mutated in place)
|
|
22
|
+
* @returns {Object|null} ProseMirror citation node or null
|
|
23
|
+
*/
|
|
24
|
+
export function citationResultToNode(result: Object, bibliography: Object, bibDB?: boolean): Object | null;
|
|
25
|
+
//# sourceMappingURL=citations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"citations.d.ts","sourceRoot":"","sources":["../../src/importer/citations.js"],"names":[],"mappings":"AA0DA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,6CAJW,MAAM,gBACN,MAAM,oBACJ,MAAM,GAAC,IAAI,CAiDvB"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared citation utilities for DOCX and ODT importers.
|
|
3
|
+
*
|
|
4
|
+
* Converts a CitationResult (from DocxCitationsParser or OdtCitationsParser
|
|
5
|
+
* static methods) plus a BibDB (entries) into a Fidus Writer citation node,
|
|
6
|
+
* and merges the new BibDB entries into the document bibliography.
|
|
7
|
+
*
|
|
8
|
+
* The `bibliography` object passed in is mutated in place: new entries are
|
|
9
|
+
* appended with sequential numeric string keys ("1", "2", …).
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Given a BibDB returned by a static Citations parser call and the current
|
|
13
|
+
* document bibliography, add every entry that is not yet present (matched by
|
|
14
|
+
* entry_key) and return a mapping from entry_key → bibliography key string.
|
|
15
|
+
*
|
|
16
|
+
* @param {Object} entries BibDB (Record<number, EntryObject>) from parser
|
|
17
|
+
* @param {Object} bibliography Fidus Writer bibliography (mutated in place)
|
|
18
|
+
* @returns {Object} Map of entry_key → bibKey string
|
|
19
|
+
*/
|
|
20
|
+
function mergeBibEntries(entries, bibliography, bibDB) {
|
|
21
|
+
const keyMap = {};
|
|
22
|
+
for (const entry of Object.values(entries)) {
|
|
23
|
+
if (!entry || !entry.entry_key) {
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
const entryKey = entry.entry_key;
|
|
27
|
+
// Check whether this entry_key is already in the bibliography.
|
|
28
|
+
const existing = Object.entries(bibliography).find(([, bibEntry]) => bibEntry && bibEntry.entry_key === entryKey);
|
|
29
|
+
if (existing) {
|
|
30
|
+
keyMap[entryKey] = existing[0];
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
if (bibDB && Object.keys(entry.fields).length === 0) {
|
|
34
|
+
// Jabref citations don't contain any fields. Look up values in bibDB instead
|
|
35
|
+
const bibEntry = Object.values(bibDB.db).find(bibEntry => bibEntry && bibEntry.entry_key === entryKey);
|
|
36
|
+
if (bibEntry) {
|
|
37
|
+
entry.fields = JSON.parse(JSON.stringify(bibEntry.fields));
|
|
38
|
+
entry.bib_type = bibEntry.bib_type;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
// TODO: add for jabref citations - according to entry_key import from user
|
|
42
|
+
// library if useExternalDB is true
|
|
43
|
+
const bibKey = String(Object.keys(bibliography).length + 1);
|
|
44
|
+
bibliography[bibKey] = entry;
|
|
45
|
+
keyMap[entryKey] = bibKey;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return keyMap;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Convert a CitationResult from a static DocxCitationsParser or
|
|
52
|
+
* OdtCitationsParser call into a Fidus Writer citation node.
|
|
53
|
+
*
|
|
54
|
+
* The `bibliography` object is mutated in place to include any new entries.
|
|
55
|
+
*
|
|
56
|
+
* Each item in `metadata` (when `retrieveMetadata` was true) may carry:
|
|
57
|
+
* - id : entry_key string identifying which entry this item refers to
|
|
58
|
+
* - prefix : citation prefix text
|
|
59
|
+
* - suffix : citation suffix / locator text (used as `locator`)
|
|
60
|
+
* - locator : explicit locator string (preferred over suffix when present)
|
|
61
|
+
* - authorOnly : boolean – render author name only (maps to "textcite")
|
|
62
|
+
* - suppressAuthor : boolean – suppress author name (ignored, maps to default)
|
|
63
|
+
* - authorYear : boolean – render author name and year (maps to "textcite")
|
|
64
|
+
*
|
|
65
|
+
* `format` on the returned citation node matches the Fidus Writer citation schema:
|
|
66
|
+
* - "textcite" when authorOnly or authorYear is set on the (single) item (biblatex \textcite)
|
|
67
|
+
* - "autocite" otherwise, including when suppressAuthor is set (biblatex \autocite)
|
|
68
|
+
*
|
|
69
|
+
* @param {Object} result CitationResult from a static parser method
|
|
70
|
+
* @param {Object} bibliography Fidus Writer bibliography (mutated in place)
|
|
71
|
+
* @returns {Object|null} ProseMirror citation node or null
|
|
72
|
+
*/
|
|
73
|
+
export function citationResultToNode(result, bibliography, bibDB = false) {
|
|
74
|
+
if (!result || !result.isCitation || !result.entries) {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
const entries = result.entries;
|
|
78
|
+
const metadata = result.metadata || [];
|
|
79
|
+
if (Object.keys(entries).length === 0) {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
const keyMap = mergeBibEntries(entries, bibliography, bibDB);
|
|
83
|
+
// Build the references array from entries.
|
|
84
|
+
//
|
|
85
|
+
const references = Object.entries(entries).map(([_entryId, entry]) => {
|
|
86
|
+
const entryKey = entry.entry_key;
|
|
87
|
+
const entryMetadata = metadata.find(meta => meta.entry_key === entryKey);
|
|
88
|
+
return {
|
|
89
|
+
id: keyMap[entryKey],
|
|
90
|
+
prefix: entryMetadata?.prefix || "",
|
|
91
|
+
locator: entryMetadata?.locator || entryMetadata?.suffix || ""
|
|
92
|
+
};
|
|
93
|
+
});
|
|
94
|
+
if (references.length === 0) {
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
// Determine citation format from the first item's metadata flags.
|
|
98
|
+
// "textcite" corresponds to biblatex's \textcite (author-in-text / authorYear).
|
|
99
|
+
// Even authorOnly comes through as "textcite" since it's a similar concept.
|
|
100
|
+
// Everything else, including suppressAuthor, falls back to "autocite".
|
|
101
|
+
// TODO: When an authorOnly citation is followed directly by a suppressAuthor
|
|
102
|
+
// citation, this would display the same as a single authorYear citation and
|
|
103
|
+
// should be treated as such.
|
|
104
|
+
const format = metadata.length === 1 &&
|
|
105
|
+
(metadata[0].authorOnly || metadata[0].authorYear)
|
|
106
|
+
? "textcite"
|
|
107
|
+
: "autocite";
|
|
108
|
+
return {
|
|
109
|
+
type: "citation",
|
|
110
|
+
attrs: {
|
|
111
|
+
format,
|
|
112
|
+
references
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=citations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"citations.js","sourceRoot":"","sources":["../../src/importer/citations.js"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH;;;;;;;;GAQG;AACH,SAAS,eAAe,CAAC,OAAO,EAAE,YAAY,EAAE,KAAK;IACjD,MAAM,MAAM,GAAG,EAAE,CAAA;IAEjB,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;QACzC,IAAI,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC;YAC7B,SAAQ;QACZ,CAAC;QACD,MAAM,QAAQ,GAAG,KAAK,CAAC,SAAS,CAAA;QAEhC,+DAA+D;QAC/D,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,IAAI,CAC9C,CAAC,CAAC,EAAE,QAAQ,CAAC,EAAE,EAAE,CAAC,QAAQ,IAAI,QAAQ,CAAC,SAAS,KAAK,QAAQ,CAChE,CAAA;QAED,IAAI,QAAQ,EAAE,CAAC;YACX,MAAM,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAA;QAClC,CAAC;aAAM,CAAC;YACJ,IAAI,KAAK,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAClD,6EAA6E;gBAC7E,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,IAAI,CACzC,QAAQ,CAAC,EAAE,CAAC,QAAQ,IAAI,QAAQ,CAAC,SAAS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AE,KAAK,CAAC,EAAE,EAAE;QACjE,MAAM,QAAQ,GAAG,KAAK,CAAC,SAAS,CAAA;QAChC,MAAM,aAAa,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,KAAK,QAAQ,CAAC,CAAA;QACxE,OAAO;YACH,EAAE,EAAE,MAAM,CAAC,QAAQ,CAAC;YACpB,MAAM,EAAE,aAAa,EAAE,MAAM,IAAI,EAAE;YACnC,OAAO,EAAE,aAAa,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,IAAI,EAAE;SACjE,CAAA;IACL,CAAC,CAAC,CAAA;IAEF,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1B,OAAO,IAAI,CAAA;IACf,CAAC;IAED,kEAAkE;IAClE,gFAAgF;IAChF,4EAA4E;IAC5E,uEAAuE;IACvE,6EAA6E;IAC7E,4EAA4E;IAC5E,6BAA6B;IAC7B,MAAM,MAAM,GACR,QAAQ,CAAC,MAAM,KAAK,CAAC;QACrB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,UAAU,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC;QAC9C,CAAC,CAAC,UAAU;QACZ,CAAC,CAAC,UAAU,CAAA;IAEpB,OAAO;QACH,IAAI,EAAE,UAAU;QAChB,KAAK,EAAE;YACH,MAAM;YACN,UAAU;SACb;KACJ,CAAA;AACL,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check whether a field instruction string belongs to a citation.
|
|
3
|
+
* Uses DocxCitationsParser.fieldCitation() with retrieve=false so no BibDB
|
|
4
|
+
* is allocated for the check.
|
|
5
|
+
*
|
|
6
|
+
* @param {string} instrText - Concatenated w:instrText content
|
|
7
|
+
* @returns {boolean}
|
|
8
|
+
*/
|
|
9
|
+
export function isDocxCitationField(instrText: string): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Check whether a field instruction string belongs to a bibliography region
|
|
12
|
+
* (Zotero ZOTERO_BIBL, Word native BIBLIOGRAPHY, EN.REFLIST, etc.).
|
|
13
|
+
* Uses DocxCitationsParser.fieldBibliography() with the accumulated
|
|
14
|
+
* instruction text between begin and separate markers.
|
|
15
|
+
*
|
|
16
|
+
* @param {string} instrText - Concatenated w:instrText content
|
|
17
|
+
* @returns {boolean}
|
|
18
|
+
*/
|
|
19
|
+
export function isDocxBibliographyField(instrText: string): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Check whether a w:sdt node contains a citation (Mendeley v3, Citavi).
|
|
22
|
+
* Uses DocxCitationsParser.sdtCitation() with retrieve=false.
|
|
23
|
+
*
|
|
24
|
+
* @param {Object} sdtNode - The parsed w:sdt XMLElement node
|
|
25
|
+
* @returns {boolean}
|
|
26
|
+
*/
|
|
27
|
+
export function isDocxSdtCitation(sdtNode: Object): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Check whether a w:sdt node is a bibliography rendering region
|
|
30
|
+
* (Mendeley v3 bibliography, Citavi bibliography).
|
|
31
|
+
* Uses DocxCitationsParser.sdtBibliography().
|
|
32
|
+
*
|
|
33
|
+
* @param {Object} sdtNode - The parsed w:sdt XMLElement node
|
|
34
|
+
* @returns {boolean}
|
|
35
|
+
*/
|
|
36
|
+
export function isDocxSdtBibliography(sdtNode: Object): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Parse a citation from a DOCX field instruction and add any new bibliography
|
|
39
|
+
* entries into `bibliography`.
|
|
40
|
+
*
|
|
41
|
+
* Handles all field-based citation managers: Zotero, Mendeley Desktop
|
|
42
|
+
* (legacy), EndNote (both inline and fldData forms), Citavi (older ADDIN
|
|
43
|
+
* form), and Word native (requires sourcesXml).
|
|
44
|
+
*
|
|
45
|
+
* @param {string} instrText - Concatenated w:instrText for this field
|
|
46
|
+
* @param {string|null} fldData - Base64 content of w:fldData (EndNote),
|
|
47
|
+
* or null/undefined if absent
|
|
48
|
+
* @param {string|null} sourcesXml - Content of customXml/item1.xml (required
|
|
49
|
+
* only for Word-native citations)
|
|
50
|
+
* @param {Object} bibliography - Fidus Writer bibliography (mutated)
|
|
51
|
+
* @returns {Object|null} ProseMirror citation node or null
|
|
52
|
+
*/
|
|
53
|
+
export function parseDocxFieldCitation(instrText: string, fldData: string | null, sourcesXml: string | null, bibliography: Object): Object | null;
|
|
54
|
+
/**
|
|
55
|
+
* Parse a citation from a DOCX structured document tag (w:sdt) and add any
|
|
56
|
+
* new bibliography entries into `bibliography`.
|
|
57
|
+
*
|
|
58
|
+
* Handles Mendeley Cite v3 and Citavi (modern SDT form).
|
|
59
|
+
*
|
|
60
|
+
* @param {Object} sdtNode - The parsed w:sdt XMLElement node
|
|
61
|
+
* @param {Object} bibliography - Fidus Writer bibliography (mutated)
|
|
62
|
+
* @returns {Object|null} ProseMirror citation node or null
|
|
63
|
+
*/
|
|
64
|
+
export function parseDocxSdtCitation(sdtNode: Object, bibliography: Object): Object | null;
|
|
65
|
+
//# sourceMappingURL=citations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"citations.d.ts","sourceRoot":"","sources":["../../../src/importer/docx/citations.js"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AACH,+CAHW,MAAM,GACJ,OAAO,CAOnB;AAED;;;;;;;;GAQG;AACH,mDAHW,MAAM,GACJ,OAAO,CAQnB;AAED;;;;;;GAMG;AACH,2CAHW,MAAM,GACJ,OAAO,CAOnB;AAED;;;;;;;GAOG;AACH,+CAHW,MAAM,GACJ,OAAO,CAOnB;AAED;;;;;;;;;;;;;;;GAeG;AACH,kDARW,MAAM,WACN,MAAM,GAAC,IAAI,cAEX,MAAM,GAAC,IAAI,gBAEX,MAAM,GACJ,MAAM,GAAC,IAAI,CAsBvB;AAED;;;;;;;;;GASG;AACH,8CAJW,MAAM,gBACN,MAAM,GACJ,MAAM,GAAC,IAAI,CAYvB"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { DocxCitationsParser } from "biblatex-csl-converter";
|
|
2
|
+
import { citationResultToNode } from "../citations.js";
|
|
3
|
+
/**
|
|
4
|
+
* Check whether a field instruction string belongs to a citation.
|
|
5
|
+
* Uses DocxCitationsParser.fieldCitation() with retrieve=false so no BibDB
|
|
6
|
+
* is allocated for the check.
|
|
7
|
+
*
|
|
8
|
+
* @param {string} instrText - Concatenated w:instrText content
|
|
9
|
+
* @returns {boolean}
|
|
10
|
+
*/
|
|
11
|
+
export function isDocxCitationField(instrText) {
|
|
12
|
+
if (!instrText) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
return DocxCitationsParser.fieldCitation(instrText, false).isCitation;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Check whether a field instruction string belongs to a bibliography region
|
|
19
|
+
* (Zotero ZOTERO_BIBL, Word native BIBLIOGRAPHY, EN.REFLIST, etc.).
|
|
20
|
+
* Uses DocxCitationsParser.fieldBibliography() with the accumulated
|
|
21
|
+
* instruction text between begin and separate markers.
|
|
22
|
+
*
|
|
23
|
+
* @param {string} instrText - Concatenated w:instrText content
|
|
24
|
+
* @returns {boolean}
|
|
25
|
+
*/
|
|
26
|
+
export function isDocxBibliographyField(instrText) {
|
|
27
|
+
if (!instrText) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
return DocxCitationsParser.fieldBibliography(instrText).isBibliography;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Check whether a w:sdt node contains a citation (Mendeley v3, Citavi).
|
|
34
|
+
* Uses DocxCitationsParser.sdtCitation() with retrieve=false.
|
|
35
|
+
*
|
|
36
|
+
* @param {Object} sdtNode - The parsed w:sdt XMLElement node
|
|
37
|
+
* @returns {boolean}
|
|
38
|
+
*/
|
|
39
|
+
export function isDocxSdtCitation(sdtNode) {
|
|
40
|
+
if (!sdtNode) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
return DocxCitationsParser.sdtCitation(sdtNode.outerXML, false).isCitation;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Check whether a w:sdt node is a bibliography rendering region
|
|
47
|
+
* (Mendeley v3 bibliography, Citavi bibliography).
|
|
48
|
+
* Uses DocxCitationsParser.sdtBibliography().
|
|
49
|
+
*
|
|
50
|
+
* @param {Object} sdtNode - The parsed w:sdt XMLElement node
|
|
51
|
+
* @returns {boolean}
|
|
52
|
+
*/
|
|
53
|
+
export function isDocxSdtBibliography(sdtNode) {
|
|
54
|
+
if (!sdtNode) {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
return DocxCitationsParser.sdtBibliography(sdtNode.outerXML).isBibliography;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Parse a citation from a DOCX field instruction and add any new bibliography
|
|
61
|
+
* entries into `bibliography`.
|
|
62
|
+
*
|
|
63
|
+
* Handles all field-based citation managers: Zotero, Mendeley Desktop
|
|
64
|
+
* (legacy), EndNote (both inline and fldData forms), Citavi (older ADDIN
|
|
65
|
+
* form), and Word native (requires sourcesXml).
|
|
66
|
+
*
|
|
67
|
+
* @param {string} instrText - Concatenated w:instrText for this field
|
|
68
|
+
* @param {string|null} fldData - Base64 content of w:fldData (EndNote),
|
|
69
|
+
* or null/undefined if absent
|
|
70
|
+
* @param {string|null} sourcesXml - Content of customXml/item1.xml (required
|
|
71
|
+
* only for Word-native citations)
|
|
72
|
+
* @param {Object} bibliography - Fidus Writer bibliography (mutated)
|
|
73
|
+
* @returns {Object|null} ProseMirror citation node or null
|
|
74
|
+
*/
|
|
75
|
+
export function parseDocxFieldCitation(instrText, fldData, sourcesXml, bibliography) {
|
|
76
|
+
if (!instrText) {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
const options = sourcesXml ? { sourcesXml } : {};
|
|
80
|
+
const result = DocxCitationsParser.fieldCitation(instrText, true, // retrieve
|
|
81
|
+
true, // retrieveMetadata
|
|
82
|
+
true, // extractWordNative
|
|
83
|
+
fldData || undefined, options);
|
|
84
|
+
const node = citationResultToNode(result, bibliography);
|
|
85
|
+
return node;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Parse a citation from a DOCX structured document tag (w:sdt) and add any
|
|
89
|
+
* new bibliography entries into `bibliography`.
|
|
90
|
+
*
|
|
91
|
+
* Handles Mendeley Cite v3 and Citavi (modern SDT form).
|
|
92
|
+
*
|
|
93
|
+
* @param {Object} sdtNode - The parsed w:sdt XMLElement node
|
|
94
|
+
* @param {Object} bibliography - Fidus Writer bibliography (mutated)
|
|
95
|
+
* @returns {Object|null} ProseMirror citation node or null
|
|
96
|
+
*/
|
|
97
|
+
export function parseDocxSdtCitation(sdtNode, bibliography) {
|
|
98
|
+
if (!sdtNode) {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
const result = DocxCitationsParser.sdtCitation(sdtNode.outerXML, true, // retrieve
|
|
102
|
+
true // retrieveMetadata
|
|
103
|
+
);
|
|
104
|
+
return citationResultToNode(result, bibliography);
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=citations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"citations.js","sourceRoot":"","sources":["../../../src/importer/docx/citations.js"],"names":[],"mappings":"AAAA,OAAO,EAAC,mBAAmB,EAAC,MAAM,wBAAwB,CAAA;AAC1D,OAAO,EAAC,oBAAoB,EAAC,MAAM,iBAAiB,CAAA;AAEpD;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CAAC,SAAS;IACzC,IAAI,CAAC,SAAS,EAAE,CAAC;QACb,OAAO,KAAK,CAAA;IAChB,CAAC;IACD,OAAO,mBAAmB,CAAC,aAAa,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,UAAU,CAAA;AACzE,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,uBAAuB,CAAC,SAAS;IAC7C,IAAI,CAAC,SAAS,EAAE,CAAC;QACb,OAAO,KAAK,CAAA;IAChB,CAAC;I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