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