@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,25 +1,42 @@
|
|
|
1
1
|
import {printHTML} from "@vivliostyle/print"
|
|
2
|
-
import {addAlert, shortFileTitle} from "fwtoolkit"
|
|
2
|
+
import {addAlert, shortFileTitle, gettext, staticUrl} from "fwtoolkit"
|
|
3
|
+
|
|
3
4
|
import {PAPER_SIZES} from "../../schema/const.js"
|
|
5
|
+
import type {BibDB, CSL, ExportDoc, FidusNode, ImageDB} from "../../types.js"
|
|
4
6
|
import {HTMLExporter} from "../html/index.js"
|
|
5
7
|
import {HTMLExporterConvert} from "../html/convert.js"
|
|
6
8
|
import {removeHidden} from "../tools/doc_content.js"
|
|
7
9
|
|
|
8
10
|
export class PrintExporter extends HTMLExporter {
|
|
9
|
-
constructor(
|
|
11
|
+
constructor(
|
|
12
|
+
doc: ExportDoc,
|
|
13
|
+
bibDB: BibDB,
|
|
14
|
+
imageDB: ImageDB,
|
|
15
|
+
csl: CSL,
|
|
16
|
+
updated: unknown,
|
|
17
|
+
documentStyles: Array<{
|
|
18
|
+
slug: string
|
|
19
|
+
contents: string
|
|
20
|
+
documentstylefile_set: Array<[string, string]>
|
|
21
|
+
}>
|
|
22
|
+
) {
|
|
10
23
|
super(doc, bibDB, imageDB, csl, updated, documentStyles, {
|
|
11
24
|
relativeUrls: false
|
|
12
25
|
})
|
|
13
26
|
}
|
|
14
27
|
|
|
15
|
-
async init() {
|
|
28
|
+
async init(): Promise<void> {
|
|
16
29
|
addAlert(
|
|
17
30
|
"info",
|
|
18
|
-
`${shortFileTitle(this.doc.title, this.doc.path)}: ${gettext("Printing has been initiated.")}`
|
|
31
|
+
`${shortFileTitle(this.doc.title, this.doc.path || "")}: ${gettext("Printing has been initiated.")}`
|
|
19
32
|
)
|
|
20
|
-
this.docContent = removeHidden(this.doc.content)
|
|
33
|
+
this.docContent = removeHidden(this.doc.content) as FidusNode
|
|
21
34
|
|
|
22
|
-
const styleSheets
|
|
35
|
+
const styleSheets: Array<{
|
|
36
|
+
url?: string
|
|
37
|
+
contents?: string
|
|
38
|
+
filename?: string
|
|
39
|
+
}> = [
|
|
23
40
|
{url: staticUrl("css/document.css")},
|
|
24
41
|
{
|
|
25
42
|
contents: `a.footnote, a.affiliation {
|
|
@@ -84,7 +101,7 @@ export class PrintExporter extends HTMLExporter {
|
|
|
84
101
|
background-color: white;
|
|
85
102
|
}
|
|
86
103
|
@page {
|
|
87
|
-
size: ${PAPER_SIZES.find(size => size[0] === this.doc.settings.papersize)[1]};
|
|
104
|
+
size: ${(PAPER_SIZES.find(size => size[0] === this.doc.settings.papersize) || ["", "A4"])[1]};
|
|
88
105
|
@top-center {
|
|
89
106
|
content: env(doc-title);
|
|
90
107
|
}
|
|
@@ -121,18 +138,20 @@ export class PrintExporter extends HTMLExporter {
|
|
|
121
138
|
|
|
122
139
|
const {html, metaData} = await this.converter.init()
|
|
123
140
|
|
|
124
|
-
const config
|
|
141
|
+
const config: {title?: string; printCallback?: (iframeWin: Window) => void} = {
|
|
142
|
+
title: metaData.title
|
|
143
|
+
}
|
|
125
144
|
|
|
126
145
|
if (navigator.userAgent.includes("Gecko/")) {
|
|
127
146
|
// Firefox has issues printing images when in iframe. This workaround can be
|
|
128
147
|
// removed once that has been fixed. TODO: Add gecko bug number if there is one.
|
|
129
148
|
config.printCallback = iframeWin => {
|
|
130
149
|
const oldBody = document.body
|
|
131
|
-
document.body.parentElement
|
|
150
|
+
document.body.parentElement!.dataset.vivliostylePaginated = "true"
|
|
132
151
|
document.body = iframeWin.document.body
|
|
133
152
|
document.body
|
|
134
153
|
.querySelectorAll("figure, table")
|
|
135
|
-
.forEach(el => delete el.dataset.category)
|
|
154
|
+
.forEach(el => delete (el as HTMLElement).dataset.category)
|
|
136
155
|
iframeWin.document
|
|
137
156
|
.querySelectorAll("style")
|
|
138
157
|
.forEach(el => document.body.appendChild(el))
|
|
@@ -141,33 +160,33 @@ export class PrintExporter extends HTMLExporter {
|
|
|
141
160
|
document.body.appendChild(backgroundStyle)
|
|
142
161
|
window.print()
|
|
143
162
|
document.body = oldBody
|
|
144
|
-
delete document.body.parentElement
|
|
163
|
+
delete document.body.parentElement!.dataset.vivliostylePaginated
|
|
145
164
|
}
|
|
146
165
|
}
|
|
147
|
-
|
|
166
|
+
await printHTML(html, config)
|
|
148
167
|
}
|
|
149
168
|
|
|
150
|
-
getDocStyle(doc) {
|
|
169
|
+
getDocStyle(doc: ExportDoc): {contents: string; filename: string} | false {
|
|
151
170
|
// Override the default as we need to use the original URLs in print.
|
|
152
171
|
const docStyle = this.documentStyles.find(
|
|
153
|
-
|
|
172
|
+
(ds: {slug: string}) => ds.slug === doc.settings.documentstyle
|
|
154
173
|
)
|
|
155
174
|
if (!docStyle) {
|
|
156
|
-
return
|
|
175
|
+
return false
|
|
157
176
|
}
|
|
158
177
|
|
|
159
178
|
let contents = docStyle.contents
|
|
160
179
|
docStyle.documentstylefile_set.forEach(
|
|
161
|
-
([url, filename]) =>
|
|
180
|
+
([url, filename]: [string, string]) =>
|
|
162
181
|
(contents = contents.replace(
|
|
163
182
|
new RegExp(filename, "g"),
|
|
164
|
-
new URL(url, window.location).href
|
|
183
|
+
new URL(url, window.location.href).href
|
|
165
184
|
))
|
|
166
185
|
)
|
|
167
|
-
return {contents}
|
|
186
|
+
return {contents, filename: ""}
|
|
168
187
|
}
|
|
169
188
|
|
|
170
|
-
loadStyle(sheet) {
|
|
189
|
+
loadStyle(sheet: {url?: string; filename?: string; contents?: string}): Promise<void> {
|
|
171
190
|
if (sheet.url) {
|
|
172
191
|
sheet.filename = sheet.url
|
|
173
192
|
delete sheet.url
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import type {FidusNode} from "../../types.js"
|
|
2
|
+
|
|
1
3
|
// Return a json that is the same as the existing json, but with all parts
|
|
2
4
|
// marked as hidden removed.
|
|
3
5
|
|
|
4
6
|
export const removeHidden = (
|
|
5
|
-
node,
|
|
7
|
+
node: FidusNode,
|
|
6
8
|
// Whether to leave the outer part of the removed node.
|
|
7
9
|
// True for tree-walking exporters, false for DOM-changing exporters.
|
|
8
10
|
leaveStub = true,
|
|
@@ -10,12 +12,12 @@ export const removeHidden = (
|
|
|
10
12
|
removeTableCaptionText = false,
|
|
11
13
|
removeFigureCaption = false,
|
|
12
14
|
removeFigureCaptionText = false
|
|
13
|
-
) => {
|
|
14
|
-
const returnNode = {}
|
|
15
|
+
): FidusNode | false => {
|
|
16
|
+
const returnNode: FidusNode = {type: node.type}
|
|
15
17
|
|
|
16
18
|
Object.keys(node).forEach(key => {
|
|
17
19
|
if (key !== "content") {
|
|
18
|
-
returnNode[key] = node[key]
|
|
20
|
+
;(returnNode as unknown as Record<string, unknown>)[key] = (node as unknown as Record<string, unknown>)[key]
|
|
19
21
|
}
|
|
20
22
|
})
|
|
21
23
|
if (node.attrs?.hidden) {
|
|
@@ -60,15 +62,15 @@ export const removeHidden = (
|
|
|
60
62
|
removeFigureCaptionText
|
|
61
63
|
)
|
|
62
64
|
if (cleanedChild) {
|
|
63
|
-
returnNode.content
|
|
65
|
+
returnNode.content!.push(cleanedChild)
|
|
64
66
|
}
|
|
65
67
|
})
|
|
66
68
|
}
|
|
67
69
|
return returnNode
|
|
68
70
|
}
|
|
69
71
|
|
|
70
|
-
export const descendantNodes = node => {
|
|
71
|
-
let returnValue = [node]
|
|
72
|
+
export const descendantNodes = (node: FidusNode): FidusNode[] => {
|
|
73
|
+
let returnValue: FidusNode[] = [node]
|
|
72
74
|
if (node.content) {
|
|
73
75
|
node.content.forEach(childNode => {
|
|
74
76
|
returnValue = returnValue.concat(descendantNodes(childNode))
|
|
@@ -77,7 +79,7 @@ export const descendantNodes = node => {
|
|
|
77
79
|
return returnValue
|
|
78
80
|
}
|
|
79
81
|
|
|
80
|
-
export const textContent = node =>
|
|
82
|
+
export const textContent = (node: FidusNode): string =>
|
|
81
83
|
descendantNodes(node).reduce((returnString, subNode) => {
|
|
82
84
|
if (subNode.text) {
|
|
83
85
|
returnString += subNode.text
|
|
@@ -88,43 +90,51 @@ export const textContent = node =>
|
|
|
88
90
|
// PM/HTML don't have cells that have been covered, but in ODT/DOCX, these cells
|
|
89
91
|
// need to be present. So we add them.
|
|
90
92
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
93
|
+
interface TableCellAttrs {
|
|
94
|
+
rowspan?: number
|
|
95
|
+
colspan?: number
|
|
96
|
+
[key: string]: unknown
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const addCoveredTableCells = (node: FidusNode): void => {
|
|
100
|
+
const rows = node.content!
|
|
101
|
+
const columns = (rows[0].content || []).reduce(
|
|
102
|
+
(cols, cell) => cols + ((cell.attrs?.colspan as number) || 1),
|
|
94
103
|
0
|
|
95
104
|
)
|
|
96
|
-
const rows = node.content.length
|
|
97
105
|
// Add empty cells for col/rowspan
|
|
98
|
-
const fixedTableMatrix = Array.
|
|
106
|
+
const fixedTableMatrix: FidusNode[] = Array.from({length: rows.length}, () => ({
|
|
99
107
|
type: "table_row",
|
|
100
|
-
content: Array.
|
|
108
|
+
content: Array.from({length: columns}, () => ({} as FidusNode))
|
|
101
109
|
}))
|
|
102
110
|
let rowIndex = -1
|
|
103
|
-
|
|
111
|
+
rows.forEach(row => {
|
|
104
112
|
let columnIndex = 0
|
|
105
113
|
rowIndex++
|
|
106
114
|
if (!row.content) {
|
|
107
115
|
return
|
|
108
116
|
}
|
|
109
117
|
row.content.forEach(cell => {
|
|
110
|
-
while (fixedTableMatrix[rowIndex].content[columnIndex]) {
|
|
118
|
+
while (fixedTableMatrix[rowIndex].content![columnIndex]) {
|
|
111
119
|
columnIndex++
|
|
112
120
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
121
|
+
const rowspan = ((cell.attrs as TableCellAttrs)?.rowspan as number) || 1
|
|
122
|
+
const colspan = ((cell.attrs as TableCellAttrs)?.colspan as number) || 1
|
|
123
|
+
for (let i = 0; i < rowspan; i++) {
|
|
124
|
+
for (let j = 0; j < colspan; j++) {
|
|
125
|
+
let fixedCell: FidusNode
|
|
116
126
|
if (i === 0 && j === 0) {
|
|
117
127
|
fixedCell = cell
|
|
118
128
|
} else {
|
|
119
129
|
fixedCell = {
|
|
120
130
|
type: "table_cell",
|
|
121
131
|
attrs: {
|
|
122
|
-
rowspan:
|
|
123
|
-
colspan:
|
|
124
|
-
}
|
|
132
|
+
rowspan: rowspan > 1 ? 0 : 1,
|
|
133
|
+
colspan: colspan > 1 ? 0 : 1
|
|
134
|
+
} as TableCellAttrs
|
|
125
135
|
}
|
|
126
136
|
}
|
|
127
|
-
fixedTableMatrix[rowIndex + i].content[columnIndex + j] =
|
|
137
|
+
fixedTableMatrix[rowIndex + i].content![columnIndex + j] =
|
|
128
138
|
fixedCell
|
|
129
139
|
}
|
|
130
140
|
}
|
|
@@ -133,7 +143,7 @@ const addCoveredTableCells = node => {
|
|
|
133
143
|
node.content = fixedTableMatrix
|
|
134
144
|
}
|
|
135
145
|
|
|
136
|
-
export const fixTables = node => {
|
|
146
|
+
export const fixTables = (node: FidusNode): FidusNode => {
|
|
137
147
|
if (node.type === "table_body") {
|
|
138
148
|
addCoveredTableCells(node)
|
|
139
149
|
}
|
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import type {NativeDomNode} from "../../types.js"
|
|
2
|
+
|
|
3
|
+
/** Same functionality as objToNode/nodeToObj in diffDOM.js, but also offers
|
|
4
|
+
* output in XHTML format (obj2Node) and without form support.
|
|
5
|
+
*/
|
|
6
|
+
export const obj2Node = (
|
|
7
|
+
obj: NativeDomNode | undefined,
|
|
8
|
+
docType?: "xhtml"
|
|
9
|
+
): Node | false => {
|
|
10
|
+
let parser: Document
|
|
4
11
|
if (obj === undefined) {
|
|
5
12
|
return false
|
|
6
13
|
}
|
|
@@ -10,28 +17,28 @@ export const obj2Node = (obj, docType) => {
|
|
|
10
17
|
parser = document
|
|
11
18
|
}
|
|
12
19
|
|
|
13
|
-
function inner(obj, insideSvg) {
|
|
14
|
-
let node
|
|
15
|
-
if (
|
|
16
|
-
node = parser.createTextNode(obj.t)
|
|
17
|
-
} else if (
|
|
18
|
-
node = parser.createComment(obj.co)
|
|
20
|
+
function inner(obj: NativeDomNode, insideSvg = false): Node {
|
|
21
|
+
let node: Node
|
|
22
|
+
if (Object.prototype.hasOwnProperty.call(obj, "t")) {
|
|
23
|
+
node = parser.createTextNode(obj.t as string)
|
|
24
|
+
} else if (Object.prototype.hasOwnProperty.call(obj, "co")) {
|
|
25
|
+
node = parser.createComment(obj.co as string)
|
|
19
26
|
} else {
|
|
20
27
|
if (obj.nn === "svg" || insideSvg) {
|
|
21
28
|
node = parser.createElementNS(
|
|
22
29
|
"http://www.w3.org/2000/svg",
|
|
23
|
-
obj.nn
|
|
30
|
+
obj.nn as string
|
|
24
31
|
)
|
|
25
32
|
insideSvg = true
|
|
26
33
|
} else if (obj.nn === "script") {
|
|
27
34
|
// Do not allow scripts
|
|
28
35
|
return parser.createTextNode("")
|
|
29
36
|
} else {
|
|
30
|
-
node = parser.createElement(obj.nn.toLowerCase())
|
|
37
|
+
node = parser.createElement((obj.nn as string).toLowerCase())
|
|
31
38
|
}
|
|
32
39
|
if (obj.a) {
|
|
33
40
|
for (let i = 0; i < obj.a.length; i++) {
|
|
34
|
-
node.setAttribute(obj.a[i][0], obj.a[i][1])
|
|
41
|
+
;(node as Element).setAttribute(obj.a[i][0], obj.a[i][1])
|
|
35
42
|
}
|
|
36
43
|
}
|
|
37
44
|
if (obj.c) {
|
|
@@ -45,19 +52,23 @@ export const obj2Node = (obj, docType) => {
|
|
|
45
52
|
return inner(obj)
|
|
46
53
|
}
|
|
47
54
|
|
|
48
|
-
export const node2Obj = node => {
|
|
49
|
-
const obj = {}
|
|
55
|
+
export const node2Obj = (node: Node): NativeDomNode => {
|
|
56
|
+
const obj: NativeDomNode = {}
|
|
50
57
|
|
|
51
58
|
if (node.nodeType === 3) {
|
|
52
|
-
obj.t = node.data
|
|
59
|
+
obj.t = (node as Text).data
|
|
53
60
|
} else if (node.nodeType === 8) {
|
|
54
|
-
obj.co = node.data
|
|
61
|
+
obj.co = (node as Comment).data
|
|
55
62
|
} else {
|
|
56
63
|
obj.nn = node.nodeName
|
|
57
|
-
|
|
64
|
+
const element = node as Element
|
|
65
|
+
if (element.attributes?.length > 0) {
|
|
58
66
|
obj.a = []
|
|
59
|
-
for (let i = 0; i <
|
|
60
|
-
obj.a.push([
|
|
67
|
+
for (let i = 0; i < element.attributes.length; i++) {
|
|
68
|
+
obj.a.push([
|
|
69
|
+
element.attributes[i].name,
|
|
70
|
+
element.attributes[i].value
|
|
71
|
+
])
|
|
61
72
|
}
|
|
62
73
|
}
|
|
63
74
|
if (node.childNodes?.length > 0) {
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import {convertDataURIToBlob} from "fwtoolkit"
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
interface Svg2pngResult {
|
|
4
|
+
blob: Blob
|
|
5
|
+
width: number
|
|
6
|
+
height: number
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function svg2png(blob: Blob): Promise<Svg2pngResult> {
|
|
4
10
|
const img = document.createElement("img")
|
|
5
11
|
const src = URL.createObjectURL(blob)
|
|
6
12
|
img.src = src
|
|
@@ -8,7 +14,7 @@ export function svg2png(blob) {
|
|
|
8
14
|
return new Promise(resolve => {
|
|
9
15
|
img.onload = function onload() {
|
|
10
16
|
const canvas = document.createElement("canvas")
|
|
11
|
-
const ctx = canvas.getContext("2d")
|
|
17
|
+
const ctx = canvas.getContext("2d")!
|
|
12
18
|
const ratio = Math.min(
|
|
13
19
|
Math.min(img.width, img.height) / img.width,
|
|
14
20
|
Math.min(img.width, img.height) / img.height
|
|
@@ -19,7 +25,7 @@ export function svg2png(blob) {
|
|
|
19
25
|
canvas.height = height
|
|
20
26
|
ctx.drawImage(img, 0, 0, width, height)
|
|
21
27
|
const src = canvas.toDataURL("image/png")
|
|
22
|
-
img.parentElement
|
|
28
|
+
img.parentElement!.removeChild(img)
|
|
23
29
|
URL.revokeObjectURL(src)
|
|
24
30
|
const pngBlob = convertDataURIToBlob(src)
|
|
25
31
|
resolve({blob: pngBlob, width, height})
|