@fiduswriter/document 0.1.0-alpha.2 → 0.1.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -1
- package/dist/bibliography/common.d.ts +92 -0
- package/dist/bibliography/common.d.ts.map +1 -0
- package/dist/bibliography/common.js +85 -0
- package/dist/bibliography/common.js.map +1 -0
- package/dist/bibliography/csl_bib.d.ts +3 -0
- package/dist/bibliography/csl_bib.d.ts.map +1 -0
- package/dist/bibliography/csl_bib.js +131 -0
- package/dist/bibliography/csl_bib.js.map +1 -0
- package/dist/citations/citeproc_sys.d.ts +13 -0
- package/dist/citations/citeproc_sys.d.ts.map +1 -0
- package/dist/citations/citeproc_sys.js +43 -0
- package/dist/citations/citeproc_sys.js.map +1 -0
- package/dist/citations/format.d.ts +23 -0
- package/dist/citations/format.d.ts.map +1 -0
- package/dist/citations/format.js +161 -0
- package/dist/citations/format.js.map +1 -0
- package/dist/editor/e2ee/encryptor.d.ts +123 -0
- package/dist/editor/e2ee/encryptor.d.ts.map +1 -0
- package/dist/editor/e2ee/encryptor.js +201 -0
- package/dist/editor/e2ee/encryptor.js.map +1 -0
- package/dist/exporter/docx/citations.d.ts +21 -0
- package/dist/exporter/docx/citations.d.ts.map +1 -0
- package/dist/exporter/docx/citations.js +154 -0
- package/dist/exporter/docx/citations.js.map +1 -0
- package/dist/exporter/docx/comments.d.ts +18 -0
- package/dist/exporter/docx/comments.d.ts.map +1 -0
- package/dist/exporter/docx/comments.js +137 -0
- package/dist/exporter/docx/comments.js.map +1 -0
- package/dist/exporter/docx/footnotes.d.ts +42 -0
- package/dist/exporter/docx/footnotes.d.ts.map +1 -0
- package/dist/exporter/docx/footnotes.js +182 -0
- package/dist/exporter/docx/footnotes.js.map +1 -0
- package/dist/exporter/docx/images.d.ts +14 -0
- package/dist/exporter/docx/images.d.ts.map +1 -0
- package/dist/exporter/docx/images.js +86 -0
- package/dist/exporter/docx/images.js.map +1 -0
- package/dist/exporter/docx/index.d.ts +22 -0
- package/dist/exporter/docx/index.d.ts.map +1 -0
- package/dist/exporter/docx/index.js +107 -0
- package/dist/exporter/docx/index.js.map +1 -0
- package/dist/exporter/docx/lists.d.ts +33 -0
- package/dist/exporter/docx/lists.d.ts.map +1 -0
- package/dist/exporter/docx/lists.js +229 -0
- package/dist/exporter/docx/lists.js.map +1 -0
- package/dist/exporter/docx/math.d.ts +13 -0
- package/dist/exporter/docx/math.d.ts.map +1 -0
- package/dist/exporter/docx/math.js +42 -0
- package/dist/exporter/docx/math.js.map +1 -0
- package/dist/exporter/docx/metadata.d.ts +14 -0
- package/dist/exporter/docx/metadata.d.ts.map +1 -0
- package/dist/exporter/docx/metadata.js +239 -0
- package/dist/exporter/docx/metadata.js.map +1 -0
- package/dist/exporter/docx/rels.d.ts +25 -0
- package/dist/exporter/docx/rels.d.ts.map +1 -0
- package/dist/exporter/docx/rels.js +168 -0
- package/dist/exporter/docx/rels.js.map +1 -0
- package/dist/exporter/docx/render.d.ts +20 -0
- package/dist/exporter/docx/render.d.ts.map +1 -0
- package/dist/exporter/docx/render.js +774 -0
- package/dist/exporter/docx/render.js.map +1 -0
- package/dist/exporter/docx/richtext.d.ts +25 -0
- package/dist/exporter/docx/richtext.d.ts.map +1 -0
- package/dist/exporter/docx/richtext.js +1052 -0
- package/dist/exporter/docx/richtext.js.map +1 -0
- package/dist/exporter/docx/tables.d.ts +14 -0
- package/dist/exporter/docx/tables.d.ts.map +1 -0
- package/dist/exporter/docx/tables.js +109 -0
- package/dist/exporter/docx/tables.js.map +1 -0
- package/dist/exporter/docx/tools.d.ts +3 -0
- package/dist/exporter/docx/tools.d.ts.map +1 -0
- package/dist/exporter/docx/tools.js +48 -0
- package/dist/exporter/docx/tools.js.map +1 -0
- package/dist/exporter/epub/index.d.ts +11 -0
- package/dist/exporter/epub/index.d.ts.map +1 -0
- package/dist/exporter/epub/index.js +102 -0
- package/dist/exporter/epub/index.js.map +1 -0
- package/dist/exporter/epub/templates.d.ts +32 -0
- package/dist/exporter/epub/templates.d.ts.map +1 -0
- package/dist/exporter/epub/templates.js +95 -0
- package/dist/exporter/epub/templates.js.map +1 -0
- package/dist/exporter/epub/tools.d.ts +5 -0
- package/dist/exporter/epub/tools.d.ts.map +1 -0
- package/dist/exporter/epub/tools.js +81 -0
- package/dist/exporter/epub/tools.js.map +1 -0
- package/dist/exporter/html/citations.d.ts +27 -0
- package/dist/exporter/html/citations.d.ts.map +1 -0
- package/dist/exporter/html/citations.js +91 -0
- package/dist/exporter/html/citations.js.map +1 -0
- package/dist/exporter/html/convert.d.ts +100 -0
- package/dist/exporter/html/convert.d.ts.map +1 -0
- package/dist/exporter/html/convert.js +718 -0
- package/dist/exporter/html/convert.js.map +1 -0
- package/dist/exporter/html/index.d.ts +61 -0
- package/dist/exporter/html/index.d.ts.map +1 -0
- package/dist/exporter/html/index.js +134 -0
- package/dist/exporter/html/index.js.map +1 -0
- package/dist/exporter/html/templates.d.ts +10 -0
- package/dist/exporter/html/templates.d.ts.map +1 -0
- package/dist/exporter/html/templates.js +21 -0
- package/dist/exporter/html/templates.js.map +1 -0
- package/dist/exporter/html/tools.d.ts +2 -0
- package/dist/exporter/html/tools.d.ts.map +1 -0
- package/dist/exporter/html/tools.js +49 -0
- package/dist/exporter/html/tools.js.map +1 -0
- package/dist/exporter/jats/bibliography.d.ts +2 -0
- package/dist/exporter/jats/bibliography.d.ts.map +1 -0
- package/dist/exporter/jats/bibliography.js +153 -0
- package/dist/exporter/jats/bibliography.js.map +1 -0
- package/dist/exporter/jats/citations.d.ts +14 -0
- package/dist/exporter/jats/citations.d.ts.map +1 -0
- package/dist/exporter/jats/citations.js +83 -0
- package/dist/exporter/jats/citations.js.map +1 -0
- package/dist/exporter/jats/convert.d.ts +45 -0
- package/dist/exporter/jats/convert.d.ts.map +1 -0
- package/dist/exporter/jats/convert.js +799 -0
- package/dist/exporter/jats/convert.js.map +1 -0
- package/dist/exporter/jats/index.d.ts +19 -0
- package/dist/exporter/jats/index.d.ts.map +1 -0
- package/dist/exporter/jats/index.js +66 -0
- package/dist/exporter/jats/index.js.map +1 -0
- package/dist/exporter/jats/templates.d.ts +16 -0
- package/dist/exporter/jats/templates.d.ts.map +1 -0
- package/dist/exporter/jats/templates.js +25 -0
- package/dist/exporter/jats/templates.js.map +1 -0
- package/dist/exporter/jats/text.d.ts +3 -0
- package/dist/exporter/jats/text.d.ts.map +1 -0
- package/dist/exporter/jats/text.js +72 -0
- package/dist/exporter/jats/text.js.map +1 -0
- package/dist/exporter/latex/convert.d.ts +27 -0
- package/dist/exporter/latex/convert.d.ts.map +1 -0
- package/dist/exporter/latex/convert.js +865 -0
- package/dist/exporter/latex/convert.js.map +1 -0
- package/dist/exporter/latex/escape_latex.d.ts +2 -0
- package/dist/exporter/latex/escape_latex.d.ts.map +1 -0
- package/dist/exporter/latex/escape_latex.js +20 -0
- package/dist/exporter/latex/escape_latex.js.map +1 -0
- package/dist/exporter/latex/index.d.ts +23 -0
- package/dist/exporter/latex/index.d.ts.map +1 -0
- package/dist/exporter/latex/index.js +57 -0
- package/dist/exporter/latex/index.js.map +1 -0
- package/dist/exporter/latex/readme.d.ts +2 -0
- package/dist/exporter/latex/readme.d.ts.map +1 -0
- package/dist/exporter/latex/readme.js +23 -0
- package/dist/exporter/latex/readme.js.map +1 -0
- package/dist/exporter/native/shrink.d.ts +21 -0
- package/dist/exporter/native/shrink.d.ts.map +1 -0
- package/dist/exporter/native/shrink.js +115 -0
- package/dist/exporter/native/shrink.js.map +1 -0
- package/dist/exporter/odt/citations.d.ts +18 -0
- package/dist/exporter/odt/citations.d.ts.map +1 -0
- package/dist/exporter/odt/citations.js +87 -0
- package/dist/exporter/odt/citations.js.map +1 -0
- package/dist/exporter/odt/footnotes.d.ts +25 -0
- package/dist/exporter/odt/footnotes.d.ts.map +1 -0
- package/dist/exporter/odt/footnotes.js +112 -0
- package/dist/exporter/odt/footnotes.js.map +1 -0
- package/dist/exporter/odt/images.d.ts +13 -0
- package/dist/exporter/odt/images.d.ts.map +1 -0
- package/dist/exporter/odt/images.js +98 -0
- package/dist/exporter/odt/images.js.map +1 -0
- package/dist/exporter/odt/index.d.ts +23 -0
- package/dist/exporter/odt/index.d.ts.map +1 -0
- package/dist/exporter/odt/index.js +99 -0
- package/dist/exporter/odt/index.js.map +1 -0
- package/dist/exporter/odt/math.d.ts +13 -0
- package/dist/exporter/odt/math.d.ts.map +1 -0
- package/dist/exporter/odt/math.js +48 -0
- package/dist/exporter/odt/math.js.map +1 -0
- package/dist/exporter/odt/metadata.d.ts +14 -0
- package/dist/exporter/odt/metadata.d.ts.map +1 -0
- package/dist/exporter/odt/metadata.js +203 -0
- package/dist/exporter/odt/metadata.js.map +1 -0
- package/dist/exporter/odt/render.d.ts +24 -0
- package/dist/exporter/odt/render.d.ts.map +1 -0
- package/dist/exporter/odt/render.js +644 -0
- package/dist/exporter/odt/render.js.map +1 -0
- package/dist/exporter/odt/richtext.d.ts +22 -0
- package/dist/exporter/odt/richtext.d.ts.map +1 -0
- package/dist/exporter/odt/richtext.js +728 -0
- package/dist/exporter/odt/richtext.js.map +1 -0
- package/dist/exporter/odt/styles.d.ts +33 -0
- package/dist/exporter/odt/styles.d.ts.map +1 -0
- package/dist/exporter/odt/styles.js +348 -0
- package/dist/exporter/odt/styles.js.map +1 -0
- package/dist/exporter/odt/track.d.ts +11 -0
- package/dist/exporter/odt/track.d.ts.map +1 -0
- package/dist/exporter/odt/track.js +59 -0
- package/dist/exporter/odt/track.js.map +1 -0
- package/dist/exporter/pandoc/citations.d.ts +17 -0
- package/dist/exporter/pandoc/citations.d.ts.map +1 -0
- package/dist/exporter/pandoc/citations.js +85 -0
- package/dist/exporter/pandoc/citations.js.map +1 -0
- package/dist/exporter/pandoc/convert.d.ts +38 -0
- package/dist/exporter/pandoc/convert.d.ts.map +1 -0
- package/dist/exporter/pandoc/convert.js +881 -0
- package/dist/exporter/pandoc/convert.js.map +1 -0
- package/dist/exporter/pandoc/index.d.ts +38 -0
- package/dist/exporter/pandoc/index.d.ts.map +1 -0
- package/dist/exporter/pandoc/index.js +67 -0
- package/dist/exporter/pandoc/index.js.map +1 -0
- package/dist/exporter/pandoc/readme.d.ts +2 -0
- package/dist/exporter/pandoc/readme.d.ts.map +1 -0
- package/dist/exporter/pandoc/readme.js +9 -0
- package/dist/exporter/pandoc/readme.js.map +1 -0
- package/dist/exporter/pandoc/tools.d.ts +6 -0
- package/dist/exporter/pandoc/tools.d.ts.map +1 -0
- package/dist/exporter/pandoc/tools.js +52 -0
- package/dist/exporter/pandoc/tools.js.map +1 -0
- package/dist/exporter/print/index.d.ts +9 -0
- package/dist/exporter/print/index.d.ts.map +1 -0
- package/dist/exporter/print/index.js +140 -0
- package/dist/exporter/print/index.js.map +1 -0
- package/dist/exporter/tools/doc_content.d.ts +7 -0
- package/dist/exporter/tools/doc_content.d.ts.map +1 -0
- package/dist/exporter/tools/doc_content.js +129 -0
- package/dist/exporter/tools/doc_content.js.map +1 -0
- package/dist/exporter/tools/file.d.ts +2 -0
- package/dist/exporter/tools/file.d.ts.map +1 -0
- package/dist/exporter/tools/file.js +10 -0
- package/dist/exporter/tools/file.js.map +1 -0
- package/dist/exporter/tools/json.d.ts +7 -0
- package/dist/exporter/tools/json.d.ts.map +1 -0
- package/dist/exporter/tools/json.js +82 -0
- package/dist/exporter/tools/json.js.map +1 -0
- package/dist/exporter/tools/svg.d.ts +2 -0
- package/dist/exporter/tools/svg.d.ts.map +1 -0
- package/dist/exporter/tools/svg.js +26 -0
- package/dist/exporter/tools/svg.js.map +1 -0
- package/dist/exporter/tools/xml.d.ts +41 -0
- package/dist/exporter/tools/xml.d.ts.map +1 -0
- package/dist/exporter/tools/xml.js +440 -0
- package/dist/exporter/tools/xml.js.map +1 -0
- package/dist/exporter/tools/xml_zip.d.ts +20 -0
- package/dist/exporter/tools/xml_zip.d.ts.map +1 -0
- package/dist/exporter/tools/xml_zip.js +86 -0
- package/dist/exporter/tools/xml_zip.js.map +1 -0
- package/dist/exporter/tools/zip.d.ts +21 -0
- package/dist/exporter/tools/zip.d.ts.map +1 -0
- package/dist/exporter/tools/zip.js +71 -0
- package/dist/exporter/tools/zip.js.map +1 -0
- package/dist/exporter/tools/zotero_csl.d.ts +10 -0
- package/dist/exporter/tools/zotero_csl.d.ts.map +1 -0
- package/dist/exporter/tools/zotero_csl.js +78 -0
- package/dist/exporter/tools/zotero_csl.js.map +1 -0
- package/dist/importer/citations.d.ts +25 -0
- package/dist/importer/citations.d.ts.map +1 -0
- package/dist/importer/citations.js +116 -0
- package/dist/importer/citations.js.map +1 -0
- package/dist/importer/docx/citations.d.ts +65 -0
- package/dist/importer/docx/citations.d.ts.map +1 -0
- package/dist/importer/docx/citations.js +106 -0
- package/dist/importer/docx/citations.js.map +1 -0
- package/dist/importer/docx/convert.d.ts +228 -0
- package/dist/importer/docx/convert.d.ts.map +1 -0
- package/dist/importer/docx/convert.js +1226 -0
- package/dist/importer/docx/convert.js.map +1 -0
- package/dist/importer/docx/helpers.d.ts +2 -0
- package/dist/importer/docx/helpers.d.ts.map +1 -0
- package/dist/importer/docx/helpers.js +10 -0
- package/dist/importer/docx/helpers.js.map +1 -0
- package/dist/importer/docx/omml2mathml.d.ts +7 -0
- package/dist/importer/docx/omml2mathml.d.ts.map +1 -0
- package/dist/importer/docx/omml2mathml.js +1239 -0
- package/dist/importer/docx/omml2mathml.js.map +1 -0
- package/dist/importer/docx/parse.d.ts +205 -0
- package/dist/importer/docx/parse.d.ts.map +1 -0
- package/dist/importer/docx/parse.js +663 -0
- package/dist/importer/docx/parse.js.map +1 -0
- package/dist/importer/native/get_images.d.ts +11 -0
- package/dist/importer/native/get_images.d.ts.map +1 -0
- package/dist/importer/native/get_images.js +64 -0
- package/dist/importer/native/get_images.js.map +1 -0
- package/dist/importer/native/update.d.ts +6 -0
- package/dist/importer/native/update.d.ts.map +1 -0
- package/dist/importer/native/update.js +26 -0
- package/dist/importer/native/update.js.map +1 -0
- package/dist/importer/odt/citations.d.ts +47 -0
- package/dist/importer/odt/citations.d.ts.map +1 -0
- package/dist/importer/odt/citations.js +79 -0
- package/dist/importer/odt/citations.js.map +1 -0
- package/dist/importer/odt/convert.d.ts +330 -0
- package/dist/importer/odt/convert.d.ts.map +1 -0
- package/dist/importer/odt/convert.js +1506 -0
- package/dist/importer/odt/convert.js.map +1 -0
- package/dist/importer/pandoc/convert.d.ts +84 -0
- package/dist/importer/pandoc/convert.d.ts.map +1 -0
- package/dist/importer/pandoc/convert.js +777 -0
- package/dist/importer/pandoc/convert.js.map +1 -0
- package/dist/importer/pandoc/helpers.d.ts +4 -0
- package/dist/importer/pandoc/helpers.d.ts.map +1 -0
- package/dist/importer/pandoc/helpers.js +75 -0
- package/dist/importer/pandoc/helpers.js.map +1 -0
- package/dist/importer/zip_analyzer.d.ts +25 -0
- package/dist/importer/zip_analyzer.d.ts.map +1 -0
- package/dist/importer/zip_analyzer.js +84 -0
- package/dist/importer/zip_analyzer.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/mathlive/opf_includes.d.ts +2 -0
- package/dist/mathlive/opf_includes.d.ts.map +1 -0
- package/dist/mathlive/opf_includes.js +25 -0
- package/dist/mathlive/opf_includes.js.map +1 -0
- package/dist/schema/common/annotate.d.ts +59 -0
- package/dist/schema/common/annotate.d.ts.map +1 -0
- package/dist/schema/common/annotate.js +75 -0
- package/dist/schema/common/annotate.js.map +1 -0
- package/dist/schema/common/base.d.ts +109 -0
- package/dist/schema/common/base.d.ts.map +1 -0
- package/dist/schema/common/base.js +109 -0
- package/dist/schema/common/base.js.map +1 -0
- package/dist/schema/common/citation.d.ts +29 -0
- package/dist/schema/common/citation.d.ts.map +1 -0
- package/dist/schema/common/citation.js +62 -0
- package/dist/schema/common/citation.js.map +1 -0
- package/dist/schema/common/equation.d.ts +18 -0
- package/dist/schema/common/equation.d.ts.map +1 -0
- package/dist/schema/common/equation.js +32 -0
- package/dist/schema/common/equation.js.map +1 -0
- package/dist/schema/common/figure.d.ts +108 -0
- package/dist/schema/common/figure.d.ts.map +1 -0
- package/dist/schema/common/figure.js +176 -0
- package/dist/schema/common/figure.js.map +1 -0
- package/dist/schema/common/heading.d.ts +33 -0
- package/dist/schema/common/heading.d.ts.map +1 -0
- package/dist/schema/common/heading.js +41 -0
- package/dist/schema/common/heading.js.map +1 -0
- package/dist/schema/common/index.d.ts +11 -0
- package/dist/schema/common/index.d.ts.map +1 -0
- package/dist/schema/common/index.js +11 -0
- package/dist/schema/common/index.js.map +1 -0
- package/dist/schema/common/list.d.ts +83 -0
- package/dist/schema/common/list.d.ts.map +1 -0
- package/dist/schema/common/list.js +92 -0
- package/dist/schema/common/list.js.map +1 -0
- package/dist/schema/common/reference.d.ts +78 -0
- package/dist/schema/common/reference.d.ts.map +1 -0
- package/dist/schema/common/reference.js +97 -0
- package/dist/schema/common/reference.js.map +1 -0
- package/dist/schema/common/table.d.ts +92 -0
- package/dist/schema/common/table.d.ts.map +1 -0
- package/dist/schema/common/table.js +85 -0
- package/dist/schema/common/table.js.map +1 -0
- package/dist/schema/common/track.d.ts +131 -0
- package/dist/schema/common/track.d.ts.map +1 -0
- package/dist/schema/common/track.js +184 -0
- package/dist/schema/common/track.js.map +1 -0
- package/dist/schema/const.d.ts +3 -0
- package/dist/schema/const.d.ts.map +1 -0
- package/{src → dist}/schema/const.js +3 -3
- package/dist/schema/const.js.map +1 -0
- package/dist/schema/convert.d.ts +3 -0
- package/dist/schema/convert.d.ts.map +1 -0
- package/dist/schema/convert.js +1215 -0
- package/dist/schema/convert.js.map +1 -0
- package/dist/schema/document/content.d.ts +137 -0
- package/dist/schema/document/content.d.ts.map +1 -0
- package/dist/schema/document/content.js +177 -0
- package/dist/schema/document/content.js.map +1 -0
- package/dist/schema/document/index.d.ts +879 -0
- package/dist/schema/document/index.d.ts.map +1 -0
- package/dist/schema/document/index.js +68 -0
- package/dist/schema/document/index.js.map +1 -0
- package/dist/schema/document/structure.d.ts +273 -0
- package/dist/schema/document/structure.d.ts.map +1 -0
- package/dist/schema/document/structure.js +445 -0
- package/dist/schema/document/structure.js.map +1 -0
- package/dist/schema/export.d.ts +880 -0
- package/dist/schema/export.d.ts.map +1 -0
- package/dist/schema/export.js +16 -0
- package/dist/schema/export.js.map +1 -0
- package/dist/schema/footnotes.d.ts +499 -0
- package/dist/schema/footnotes.d.ts.map +1 -0
- package/dist/schema/footnotes.js +88 -0
- package/dist/schema/footnotes.js.map +1 -0
- package/dist/schema/footnotes_convert.d.ts +5 -0
- package/dist/schema/footnotes_convert.d.ts.map +1 -0
- package/dist/schema/footnotes_convert.js +26 -0
- package/dist/schema/footnotes_convert.js.map +1 -0
- package/dist/schema/i18n.d.ts +586 -0
- package/dist/schema/i18n.d.ts.map +1 -0
- package/dist/schema/i18n.js +585 -0
- package/dist/schema/i18n.js.map +1 -0
- package/dist/schema/index.d.ts +6 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/index.js +6 -0
- package/dist/schema/index.js.map +1 -0
- package/dist/schema/mini_json.d.ts +5 -0
- package/dist/schema/mini_json.d.ts.map +1 -0
- package/dist/schema/mini_json.js +50 -0
- package/dist/schema/mini_json.js.map +1 -0
- package/dist/schema/text.d.ts +2 -0
- package/dist/schema/text.d.ts.map +1 -0
- package/dist/schema/text.js +23 -0
- package/dist/schema/text.js.map +1 -0
- package/dist/types.d.ts +122 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +9 -0
- package/dist/types.js.map +1 -0
- package/package.json +48 -16
- package/scripts/export-schema.js +1 -1
- package/src/exporter/tools/{file.js → file.ts} +1 -1
- package/src/exporter/tools/{json.js → json.ts} +30 -19
- package/src/global.d.ts +11 -0
- package/src/schema/const.ts +58 -0
- package/src/types.ts +136 -0
- package/jest.config.js +0 -24
- /package/src/{index.js → index.ts} +0 -0
|
@@ -0,0 +1,1215 @@
|
|
|
1
|
+
/* To convert to and from how the document is stored in the database to how ProseMirror expects it.
|
|
2
|
+
We use the DOM import for ProseMirror as the JSON we store in the database is really jsonized HTML.
|
|
3
|
+
*/
|
|
4
|
+
import deepEqual from "fast-deep-equal";
|
|
5
|
+
import { randomFigureId, randomHeadingId, randomListId, randomTableId } from "./common/index.js";
|
|
6
|
+
export const getSettings = pmDoc => {
|
|
7
|
+
const settings = JSON.parse(JSON.stringify(pmDoc.attrs));
|
|
8
|
+
return settings;
|
|
9
|
+
};
|
|
10
|
+
export const updateDoc = (doc, docVersion, bibliography = false) => {
|
|
11
|
+
/* This is to clean documents taking all the accepted formatting from older
|
|
12
|
+
versions and outputting the current version of the doc format.
|
|
13
|
+
Notice that the docVersion isn't the same as the version of the FW export
|
|
14
|
+
file in Fidus Writer < 3.2 (docVersion/FW file versions versions -1.X).
|
|
15
|
+
While the FW file version also says something about what files could be
|
|
16
|
+
available inside the FW zip, the doc_version refers to how the data is
|
|
17
|
+
stored in those files.
|
|
18
|
+
In general, an update to the doc_version will likely also trigger an
|
|
19
|
+
update to the version of the FW export file, the reverse is not always
|
|
20
|
+
true.
|
|
21
|
+
*/
|
|
22
|
+
switch (docVersion) {
|
|
23
|
+
// Import from versions up to 3.0 no longer supported starting with Fidus Writer 3.5
|
|
24
|
+
case 1: // Fidus Writer 3.1 prerelease
|
|
25
|
+
doc = convertDocV1(doc);
|
|
26
|
+
doc = convertDocV11(doc);
|
|
27
|
+
doc = convertDocV12(doc);
|
|
28
|
+
doc = convertDocV13(doc, bibliography);
|
|
29
|
+
doc = convertDocV20(doc);
|
|
30
|
+
doc = convertDocV21(doc);
|
|
31
|
+
doc = convertDocV22(doc);
|
|
32
|
+
doc = convertDocV23(doc);
|
|
33
|
+
doc = convertDocV30(doc);
|
|
34
|
+
doc = convertDocV31(doc);
|
|
35
|
+
doc = convertDocV32(doc);
|
|
36
|
+
doc = convertDocV33(doc);
|
|
37
|
+
doc = convertDocV34(doc);
|
|
38
|
+
doc = convertDocV35(doc);
|
|
39
|
+
break;
|
|
40
|
+
case 1.1: // Fidus Writer 3.1
|
|
41
|
+
doc = convertDocV11(doc);
|
|
42
|
+
doc = convertDocV12(doc);
|
|
43
|
+
doc = convertDocV13(doc, bibliography);
|
|
44
|
+
doc = convertDocV20(doc);
|
|
45
|
+
doc = convertDocV21(doc);
|
|
46
|
+
doc = convertDocV22(doc);
|
|
47
|
+
doc = convertDocV23(doc);
|
|
48
|
+
doc = convertDocV30(doc);
|
|
49
|
+
doc = convertDocV31(doc);
|
|
50
|
+
doc = convertDocV32(doc);
|
|
51
|
+
doc = convertDocV33(doc);
|
|
52
|
+
doc = convertDocV34(doc);
|
|
53
|
+
doc = convertDocV35(doc);
|
|
54
|
+
break;
|
|
55
|
+
case 1.2: // Fidus Writer 3.2
|
|
56
|
+
doc = convertDocV12(doc);
|
|
57
|
+
doc = convertDocV13(doc, bibliography);
|
|
58
|
+
doc = convertDocV20(doc);
|
|
59
|
+
doc = convertDocV21(doc);
|
|
60
|
+
doc = convertDocV22(doc);
|
|
61
|
+
doc = convertDocV23(doc);
|
|
62
|
+
doc = convertDocV30(doc);
|
|
63
|
+
doc = convertDocV31(doc);
|
|
64
|
+
doc = convertDocV32(doc);
|
|
65
|
+
doc = convertDocV33(doc);
|
|
66
|
+
doc = convertDocV34(doc);
|
|
67
|
+
doc = convertDocV35(doc);
|
|
68
|
+
break;
|
|
69
|
+
case 1.3: // Fidus Writer 3.3 prerelease
|
|
70
|
+
doc = convertDocV13(doc, bibliography);
|
|
71
|
+
doc = convertDocV20(doc);
|
|
72
|
+
doc = convertDocV21(doc);
|
|
73
|
+
doc = convertDocV22(doc);
|
|
74
|
+
doc = convertDocV23(doc);
|
|
75
|
+
doc = convertDocV30(doc);
|
|
76
|
+
doc = convertDocV31(doc);
|
|
77
|
+
doc = convertDocV32(doc);
|
|
78
|
+
doc = convertDocV33(doc);
|
|
79
|
+
doc = convertDocV34(doc);
|
|
80
|
+
doc = convertDocV35(doc);
|
|
81
|
+
break;
|
|
82
|
+
case 2.0: // Fidus Writer 3.3
|
|
83
|
+
doc = convertDocV20(doc);
|
|
84
|
+
doc = convertDocV21(doc);
|
|
85
|
+
doc = convertDocV22(doc);
|
|
86
|
+
doc = convertDocV23(doc);
|
|
87
|
+
doc = convertDocV30(doc);
|
|
88
|
+
doc = convertDocV31(doc);
|
|
89
|
+
doc = convertDocV32(doc);
|
|
90
|
+
doc = convertDocV33(doc);
|
|
91
|
+
doc = convertDocV34(doc);
|
|
92
|
+
doc = convertDocV35(doc);
|
|
93
|
+
break;
|
|
94
|
+
case 2.1: // Fidus Writer 3.4
|
|
95
|
+
doc = convertDocV21(doc);
|
|
96
|
+
doc = convertDocV22(doc);
|
|
97
|
+
doc = convertDocV23(doc);
|
|
98
|
+
doc = convertDocV30(doc);
|
|
99
|
+
doc = convertDocV31(doc);
|
|
100
|
+
doc = convertDocV32(doc);
|
|
101
|
+
doc = convertDocV33(doc);
|
|
102
|
+
doc = convertDocV34(doc);
|
|
103
|
+
doc = convertDocV35(doc);
|
|
104
|
+
break;
|
|
105
|
+
case 2.2: // Fidus Writer 3.5.7
|
|
106
|
+
doc = convertDocV22(doc);
|
|
107
|
+
doc = convertDocV23(doc);
|
|
108
|
+
doc = convertDocV30(doc);
|
|
109
|
+
doc = convertDocV31(doc);
|
|
110
|
+
doc = convertDocV32(doc);
|
|
111
|
+
doc = convertDocV33(doc);
|
|
112
|
+
doc = convertDocV34(doc);
|
|
113
|
+
doc = convertDocV35(doc);
|
|
114
|
+
break;
|
|
115
|
+
case 2.3: // Fidus Writer 3.5.10
|
|
116
|
+
doc = convertDocV23(doc);
|
|
117
|
+
doc = convertDocV30(doc);
|
|
118
|
+
doc = convertDocV31(doc);
|
|
119
|
+
doc = convertDocV32(doc);
|
|
120
|
+
doc = convertDocV33(doc);
|
|
121
|
+
doc = convertDocV34(doc);
|
|
122
|
+
doc = convertDocV35(doc);
|
|
123
|
+
break;
|
|
124
|
+
case 3.0: // Fidus Writer 3.6
|
|
125
|
+
doc = convertDocV30(doc);
|
|
126
|
+
doc = convertDocV31(doc);
|
|
127
|
+
doc = convertDocV32(doc);
|
|
128
|
+
doc = convertDocV33(doc);
|
|
129
|
+
doc = convertDocV34(doc);
|
|
130
|
+
doc = convertDocV35(doc);
|
|
131
|
+
break;
|
|
132
|
+
case 3.1: // Fidus Writer 3.7
|
|
133
|
+
doc = convertDocV31(doc);
|
|
134
|
+
doc = convertDocV32(doc);
|
|
135
|
+
doc = convertDocV33(doc);
|
|
136
|
+
doc = convertDocV34(doc);
|
|
137
|
+
doc = convertDocV35(doc);
|
|
138
|
+
break;
|
|
139
|
+
case 3.2: // Fidus Writer 3.8
|
|
140
|
+
doc = convertDocV32(doc);
|
|
141
|
+
doc = convertDocV33(doc);
|
|
142
|
+
doc = convertDocV34(doc);
|
|
143
|
+
doc = convertDocV35(doc);
|
|
144
|
+
break;
|
|
145
|
+
case 3.3: // Fidus Writer 3.9
|
|
146
|
+
doc = convertDocV33(doc);
|
|
147
|
+
doc = convertDocV34(doc);
|
|
148
|
+
doc = convertDocV35(doc);
|
|
149
|
+
break;
|
|
150
|
+
case 3.4: // Fidus Writer 3.10
|
|
151
|
+
doc = convertDocV34(doc);
|
|
152
|
+
doc = convertDocV35(doc);
|
|
153
|
+
break;
|
|
154
|
+
case 3.5: // Fidus Writer 4.0
|
|
155
|
+
doc = convertDocV35(doc);
|
|
156
|
+
break;
|
|
157
|
+
case 3.6: // Fidus Writer 4.1
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
160
|
+
return doc;
|
|
161
|
+
};
|
|
162
|
+
const convertDocV1 = doc => {
|
|
163
|
+
const returnDoc = JSON.parse(JSON.stringify(doc));
|
|
164
|
+
convertNodeV1(returnDoc.content);
|
|
165
|
+
return returnDoc;
|
|
166
|
+
};
|
|
167
|
+
const convertNodeV1 = node => {
|
|
168
|
+
let prefixes, locators, ids, references;
|
|
169
|
+
switch (node.type) {
|
|
170
|
+
case "citation":
|
|
171
|
+
prefixes = node.attrs.bibBefore
|
|
172
|
+
? node.attrs.bibBefore.split(",,,")
|
|
173
|
+
: [];
|
|
174
|
+
locators = node.attrs.bibPage ? node.attrs.bibPage.split(",,,") : [];
|
|
175
|
+
ids = node.attrs.bibEntry ? node.attrs.bibEntry.split(",") : [];
|
|
176
|
+
references = ids.map((id, index) => {
|
|
177
|
+
const returnObj = { id: Number.parseInt(id) };
|
|
178
|
+
if (prefixes[index] !== "") {
|
|
179
|
+
returnObj["prefix"] = prefixes[index];
|
|
180
|
+
}
|
|
181
|
+
if (locators[index] !== "") {
|
|
182
|
+
returnObj["locator"] = locators[index];
|
|
183
|
+
}
|
|
184
|
+
return returnObj;
|
|
185
|
+
});
|
|
186
|
+
node.attrs = {
|
|
187
|
+
format: node.attrs.bibFormat,
|
|
188
|
+
references
|
|
189
|
+
};
|
|
190
|
+
break;
|
|
191
|
+
case "footnote":
|
|
192
|
+
if (node.attrs?.footnote) {
|
|
193
|
+
node.attrs.footnote.forEach(childNode => {
|
|
194
|
+
convertNodeV1(childNode);
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
if (node.content) {
|
|
200
|
+
node.content.forEach(childNode => {
|
|
201
|
+
convertNodeV1(childNode);
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
const convertDocV11 = doc => {
|
|
206
|
+
const returnDoc = JSON.parse(JSON.stringify(doc));
|
|
207
|
+
convertNodeV11(returnDoc.content);
|
|
208
|
+
return returnDoc;
|
|
209
|
+
};
|
|
210
|
+
const convertNodeV11 = (node, ids = []) => {
|
|
211
|
+
let blockId;
|
|
212
|
+
switch (node.type) {
|
|
213
|
+
case "heading":
|
|
214
|
+
blockId = node.attrs.id;
|
|
215
|
+
while (!blockId || ids.includes(blockId)) {
|
|
216
|
+
blockId = randomHeadingId();
|
|
217
|
+
}
|
|
218
|
+
node.attrs.id = blockId;
|
|
219
|
+
ids.push(blockId);
|
|
220
|
+
break;
|
|
221
|
+
}
|
|
222
|
+
if (node.content) {
|
|
223
|
+
node.content.forEach(childNode => {
|
|
224
|
+
convertNodeV11(childNode, ids);
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
const convertDocV12 = doc => {
|
|
229
|
+
const returnDoc = JSON.parse(JSON.stringify(doc));
|
|
230
|
+
convertNodeV12(returnDoc.content);
|
|
231
|
+
return returnDoc;
|
|
232
|
+
};
|
|
233
|
+
const convertNodeV12 = (node, ids = []) => {
|
|
234
|
+
let blockId;
|
|
235
|
+
switch (node.type) {
|
|
236
|
+
case "figure":
|
|
237
|
+
blockId = node.attrs.id;
|
|
238
|
+
while (!blockId || ids.includes(blockId)) {
|
|
239
|
+
blockId = randomFigureId();
|
|
240
|
+
}
|
|
241
|
+
node.attrs.id = blockId;
|
|
242
|
+
ids.push(blockId);
|
|
243
|
+
break;
|
|
244
|
+
}
|
|
245
|
+
if (node.content) {
|
|
246
|
+
node.content.forEach(childNode => {
|
|
247
|
+
convertNodeV12(childNode, ids);
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
const convertDocV13 = (doc, bibliography) => {
|
|
252
|
+
const returnDoc = JSON.parse(JSON.stringify(doc));
|
|
253
|
+
delete returnDoc.settings;
|
|
254
|
+
delete returnDoc.metadata;
|
|
255
|
+
returnDoc.bibliography = {};
|
|
256
|
+
returnDoc.imageIds = [];
|
|
257
|
+
convertNodeV13(returnDoc.content, returnDoc.bibliography, bibliography, returnDoc.imageIds);
|
|
258
|
+
return returnDoc;
|
|
259
|
+
};
|
|
260
|
+
const convertNodeV13 = (node, shrunkBib, fullBib, imageIds) => {
|
|
261
|
+
let authorsText, keywordsText;
|
|
262
|
+
switch (node.type) {
|
|
263
|
+
case "article":
|
|
264
|
+
node.attrs.language = "en-US";
|
|
265
|
+
break;
|
|
266
|
+
case "authors":
|
|
267
|
+
authorsText = node.content
|
|
268
|
+
? node.content.reduce((text, item) => item.type === "text" ? text + item.text : text, "")
|
|
269
|
+
: "";
|
|
270
|
+
node.content = authorsText
|
|
271
|
+
.split(/[,;]/g)
|
|
272
|
+
.map(authorString => {
|
|
273
|
+
const author = authorString.trim();
|
|
274
|
+
if (!author.length) {
|
|
275
|
+
return false;
|
|
276
|
+
}
|
|
277
|
+
const authorParts = author.split(" ");
|
|
278
|
+
return {
|
|
279
|
+
type: "author",
|
|
280
|
+
attrs: {
|
|
281
|
+
firstname: authorParts.length > 1
|
|
282
|
+
? authorParts.shift()
|
|
283
|
+
: false,
|
|
284
|
+
lastname: authorParts.join(" "),
|
|
285
|
+
institution: false,
|
|
286
|
+
email: false
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
})
|
|
290
|
+
.filter(authorObj => authorObj);
|
|
291
|
+
if (!node.content.length) {
|
|
292
|
+
delete node.content;
|
|
293
|
+
}
|
|
294
|
+
break;
|
|
295
|
+
case "citation":
|
|
296
|
+
node.attrs.references.forEach(ref => {
|
|
297
|
+
let item = fullBib[ref.id];
|
|
298
|
+
if (!item) {
|
|
299
|
+
item = {
|
|
300
|
+
fields: { title: [{ type: "text", text: "Deleted" }] },
|
|
301
|
+
bib_type: "misc",
|
|
302
|
+
entry_key: "FidusWriter"
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
item = Object.assign({}, item);
|
|
306
|
+
delete item.cats;
|
|
307
|
+
shrunkBib[ref.id] = item;
|
|
308
|
+
});
|
|
309
|
+
break;
|
|
310
|
+
case "keywords":
|
|
311
|
+
keywordsText = node.content
|
|
312
|
+
? node.content.reduce((text, item) => item.type === "text" ? text + item.text : text, "")
|
|
313
|
+
: "";
|
|
314
|
+
node.content = keywordsText
|
|
315
|
+
.split(/[,;]/g)
|
|
316
|
+
.map(keywordString => {
|
|
317
|
+
const keyword = keywordString.trim();
|
|
318
|
+
if (!keyword.length) {
|
|
319
|
+
return false;
|
|
320
|
+
}
|
|
321
|
+
return {
|
|
322
|
+
type: "keyword",
|
|
323
|
+
attrs: {
|
|
324
|
+
keyword
|
|
325
|
+
}
|
|
326
|
+
};
|
|
327
|
+
})
|
|
328
|
+
.filter(keywordObj => keywordObj);
|
|
329
|
+
if (!node.content.length) {
|
|
330
|
+
delete node.content;
|
|
331
|
+
}
|
|
332
|
+
break;
|
|
333
|
+
case "figure":
|
|
334
|
+
if (isNaN(Number.parseInt(node.attrs.image))) {
|
|
335
|
+
node.attrs.image = false;
|
|
336
|
+
}
|
|
337
|
+
else {
|
|
338
|
+
imageIds.push(Number.parseInt(node.attrs.image));
|
|
339
|
+
}
|
|
340
|
+
break;
|
|
341
|
+
}
|
|
342
|
+
if (node.content) {
|
|
343
|
+
node.content.forEach(childNode => {
|
|
344
|
+
convertNodeV13(childNode, shrunkBib, fullBib, imageIds);
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
};
|
|
348
|
+
const convertDocV20 = doc => {
|
|
349
|
+
const returnDoc = JSON.parse(JSON.stringify(doc));
|
|
350
|
+
delete returnDoc.added;
|
|
351
|
+
delete returnDoc.is_owner;
|
|
352
|
+
delete returnDoc.revisions;
|
|
353
|
+
delete returnDoc.rights;
|
|
354
|
+
delete returnDoc.updated;
|
|
355
|
+
if (returnDoc.content.attrs) {
|
|
356
|
+
returnDoc.content.attrs.tracked = false;
|
|
357
|
+
}
|
|
358
|
+
Object.values(returnDoc.comments).forEach(comment => {
|
|
359
|
+
comment.username = comment.userName;
|
|
360
|
+
comment.isMajor = comment["review:isMajor"];
|
|
361
|
+
delete comment.userAvatar;
|
|
362
|
+
delete comment.userName;
|
|
363
|
+
delete comment["review:isMajor"];
|
|
364
|
+
if (comment.answers) {
|
|
365
|
+
comment.answers.forEach(answer => {
|
|
366
|
+
answer.username = answer.userName;
|
|
367
|
+
delete answer.userAvatar;
|
|
368
|
+
delete answer.userName;
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
});
|
|
372
|
+
return returnDoc;
|
|
373
|
+
};
|
|
374
|
+
const convertNodeV21 = node => {
|
|
375
|
+
let commentMark;
|
|
376
|
+
if (node.marks &&
|
|
377
|
+
(commentMark = node.marks.find(mark => mark.type === "comment"))) {
|
|
378
|
+
commentMark.attrs.id = String(commentMark.attrs.id);
|
|
379
|
+
}
|
|
380
|
+
if (node.content) {
|
|
381
|
+
node.content.forEach(childNode => convertNodeV21(childNode));
|
|
382
|
+
}
|
|
383
|
+
};
|
|
384
|
+
const convertDocV21 = doc => {
|
|
385
|
+
const returnDoc = JSON.parse(JSON.stringify(doc));
|
|
386
|
+
convertNodeV21(returnDoc.content);
|
|
387
|
+
Object.entries(returnDoc.comment).forEach(([commentId, comment]) => {
|
|
388
|
+
delete comment.id;
|
|
389
|
+
comment.assignedUser = false;
|
|
390
|
+
comment.assignedUsername = false;
|
|
391
|
+
comment.resolved = false;
|
|
392
|
+
comment.comment = comment.comment.split("\n").map(text => ({
|
|
393
|
+
type: "paragraph",
|
|
394
|
+
content: [{ type: "text", text }]
|
|
395
|
+
}));
|
|
396
|
+
if (comment.answers) {
|
|
397
|
+
comment.answers.forEach(answer => {
|
|
398
|
+
answer.id = answer.answerId
|
|
399
|
+
? String(answer.answerId)
|
|
400
|
+
: answer.id && String(answer.id) !== String(commentId)
|
|
401
|
+
? String(answer.id)
|
|
402
|
+
: String(Math.floor(Math.random() * 0xffffffff));
|
|
403
|
+
delete answer.answerId;
|
|
404
|
+
answer.answer = answer.answer.split("\n").map(text => ({
|
|
405
|
+
type: "paragraph",
|
|
406
|
+
content: [{ type: "text", text }]
|
|
407
|
+
}));
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
});
|
|
411
|
+
return returnDoc;
|
|
412
|
+
};
|
|
413
|
+
const convertNodeV22 = (node, imageIds) => {
|
|
414
|
+
switch (node.type) {
|
|
415
|
+
case "figure":
|
|
416
|
+
if (!isNaN(Number.parseInt(node.attrs.image))) {
|
|
417
|
+
imageIds.push(Number.parseInt(node.attrs.image));
|
|
418
|
+
}
|
|
419
|
+
break;
|
|
420
|
+
default:
|
|
421
|
+
break;
|
|
422
|
+
}
|
|
423
|
+
if (node.content) {
|
|
424
|
+
const deleteChildren = [];
|
|
425
|
+
node.content.forEach(childNode => {
|
|
426
|
+
if (childNode.type === "text" && !childNode.text.length) {
|
|
427
|
+
deleteChildren.push(childNode);
|
|
428
|
+
}
|
|
429
|
+
else {
|
|
430
|
+
convertNodeV22(childNode, imageIds);
|
|
431
|
+
}
|
|
432
|
+
});
|
|
433
|
+
node.content = node.content.filter(childNode => !deleteChildren.includes(childNode));
|
|
434
|
+
}
|
|
435
|
+
};
|
|
436
|
+
const convertDocV22 = doc => {
|
|
437
|
+
const returnDoc = JSON.parse(JSON.stringify(doc));
|
|
438
|
+
returnDoc.imageIds = [];
|
|
439
|
+
convertNodeV22(returnDoc.content, returnDoc.imageIds);
|
|
440
|
+
Object.entries(returnDoc.comment).forEach(([_commentId, comment]) => {
|
|
441
|
+
comment.comment.forEach(commentNode => convertNodeV22(commentNode, returnDoc.imageIds));
|
|
442
|
+
if (comment.answers) {
|
|
443
|
+
comment.answers.forEach(answer => {
|
|
444
|
+
answer.answer.forEach(answerNode => convertNodeV22(answerNode, returnDoc.imageIds));
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
});
|
|
448
|
+
return returnDoc;
|
|
449
|
+
};
|
|
450
|
+
const v23ExtraAttrs = {
|
|
451
|
+
languages: [
|
|
452
|
+
"af-ZA",
|
|
453
|
+
"sq-AL",
|
|
454
|
+
"ar",
|
|
455
|
+
"ast",
|
|
456
|
+
"be",
|
|
457
|
+
"br",
|
|
458
|
+
"bg",
|
|
459
|
+
"ca",
|
|
460
|
+
"ca-ES-Valencia",
|
|
461
|
+
"zh-CN",
|
|
462
|
+
"da",
|
|
463
|
+
"nl",
|
|
464
|
+
"en-AU",
|
|
465
|
+
"en-CA",
|
|
466
|
+
"en-NZ",
|
|
467
|
+
"en-ZA",
|
|
468
|
+
"en-GB",
|
|
469
|
+
"en-US",
|
|
470
|
+
"eo",
|
|
471
|
+
"fr",
|
|
472
|
+
"gl",
|
|
473
|
+
"de-DE",
|
|
474
|
+
"de-AU",
|
|
475
|
+
"de-CH",
|
|
476
|
+
"el",
|
|
477
|
+
"he",
|
|
478
|
+
"is",
|
|
479
|
+
"it",
|
|
480
|
+
"ja",
|
|
481
|
+
"km",
|
|
482
|
+
"lt",
|
|
483
|
+
"ml",
|
|
484
|
+
"nb-NO",
|
|
485
|
+
"nn-NO",
|
|
486
|
+
"fa",
|
|
487
|
+
"pl",
|
|
488
|
+
"pt-BR",
|
|
489
|
+
"pt-PT",
|
|
490
|
+
"ro",
|
|
491
|
+
"ru",
|
|
492
|
+
"tr",
|
|
493
|
+
"sr-SP-Cy",
|
|
494
|
+
"sr-SP-Lt",
|
|
495
|
+
"sk",
|
|
496
|
+
"sl",
|
|
497
|
+
"es",
|
|
498
|
+
"sv",
|
|
499
|
+
"ta",
|
|
500
|
+
"tl",
|
|
501
|
+
"uk"
|
|
502
|
+
],
|
|
503
|
+
papersizes: ["A4", "US Letter"],
|
|
504
|
+
footnote_marks: ["strong", "em", "link", "anchor"],
|
|
505
|
+
footnote_elements: [
|
|
506
|
+
"paragraph",
|
|
507
|
+
"heading1",
|
|
508
|
+
"heading2",
|
|
509
|
+
"heading3",
|
|
510
|
+
"heading4",
|
|
511
|
+
"heading5",
|
|
512
|
+
"heading6",
|
|
513
|
+
"figure",
|
|
514
|
+
"ordered_list",
|
|
515
|
+
"bullet_list",
|
|
516
|
+
"horizontal_rule",
|
|
517
|
+
"equation",
|
|
518
|
+
"citation",
|
|
519
|
+
"blockquote",
|
|
520
|
+
"table"
|
|
521
|
+
],
|
|
522
|
+
template: "Standard Article"
|
|
523
|
+
};
|
|
524
|
+
const convertNodeV23 = node => {
|
|
525
|
+
switch (node.type) {
|
|
526
|
+
case "article":
|
|
527
|
+
node.attrs = Object.assign({}, node.attrs, v23ExtraAttrs);
|
|
528
|
+
break;
|
|
529
|
+
case "title":
|
|
530
|
+
node.attrs = {
|
|
531
|
+
title: "Title",
|
|
532
|
+
id: "title"
|
|
533
|
+
};
|
|
534
|
+
break;
|
|
535
|
+
case "subtitle":
|
|
536
|
+
node.type = "heading_part";
|
|
537
|
+
node.attrs = {
|
|
538
|
+
title: "Subtitle",
|
|
539
|
+
id: "subtitle",
|
|
540
|
+
locking: false,
|
|
541
|
+
language: false,
|
|
542
|
+
optional: "hidden",
|
|
543
|
+
hidden: node.attrs.hidden,
|
|
544
|
+
help: false,
|
|
545
|
+
deleted: false,
|
|
546
|
+
elements: ["heading1"],
|
|
547
|
+
marks: ["strong", "em", "link", "anchor"]
|
|
548
|
+
};
|
|
549
|
+
node.content = [
|
|
550
|
+
{
|
|
551
|
+
type: "heading1",
|
|
552
|
+
attrs: {
|
|
553
|
+
id: "H5302207",
|
|
554
|
+
track: []
|
|
555
|
+
},
|
|
556
|
+
content: node.content
|
|
557
|
+
}
|
|
558
|
+
];
|
|
559
|
+
break;
|
|
560
|
+
case "authors":
|
|
561
|
+
node.type = "contributors_part";
|
|
562
|
+
node.attrs = {
|
|
563
|
+
title: "Authors",
|
|
564
|
+
id: "authors",
|
|
565
|
+
locking: false,
|
|
566
|
+
language: false,
|
|
567
|
+
optional: "hidden",
|
|
568
|
+
hidden: node.attrs.hidden,
|
|
569
|
+
help: false,
|
|
570
|
+
deleted: false,
|
|
571
|
+
item_title: "Author"
|
|
572
|
+
};
|
|
573
|
+
break;
|
|
574
|
+
case "author":
|
|
575
|
+
node.type = "contributor";
|
|
576
|
+
break;
|
|
577
|
+
case "abstract":
|
|
578
|
+
node.type = "richtext_part";
|
|
579
|
+
node.attrs = {
|
|
580
|
+
title: "Abstract",
|
|
581
|
+
id: "abstract",
|
|
582
|
+
locking: false,
|
|
583
|
+
language: false,
|
|
584
|
+
optional: "hidden",
|
|
585
|
+
hidden: node.attrs.hidden,
|
|
586
|
+
help: false,
|
|
587
|
+
deleted: false,
|
|
588
|
+
elements: [
|
|
589
|
+
"paragraph",
|
|
590
|
+
"heading1",
|
|
591
|
+
"heading2",
|
|
592
|
+
"heading3",
|
|
593
|
+
"heading4",
|
|
594
|
+
"heading5",
|
|
595
|
+
"heading6",
|
|
596
|
+
"figure",
|
|
597
|
+
"ordered_list",
|
|
598
|
+
"bullet_list",
|
|
599
|
+
"horizontal_rule",
|
|
600
|
+
"equation",
|
|
601
|
+
"citation",
|
|
602
|
+
"blockquote",
|
|
603
|
+
"footnote",
|
|
604
|
+
"table"
|
|
605
|
+
],
|
|
606
|
+
marks: ["strong", "em", "link", "anchor"]
|
|
607
|
+
};
|
|
608
|
+
break;
|
|
609
|
+
case "keywords":
|
|
610
|
+
node.type = "tags_part";
|
|
611
|
+
node.attrs = {
|
|
612
|
+
title: "Keywords",
|
|
613
|
+
id: "keywords",
|
|
614
|
+
locking: false,
|
|
615
|
+
language: false,
|
|
616
|
+
optional: "hidden",
|
|
617
|
+
hidden: node.attrs.hidden,
|
|
618
|
+
help: false,
|
|
619
|
+
deleted: false,
|
|
620
|
+
item_title: "Keyword"
|
|
621
|
+
};
|
|
622
|
+
break;
|
|
623
|
+
case "keyword":
|
|
624
|
+
node.type = "tag";
|
|
625
|
+
node.attrs = {
|
|
626
|
+
tag: node.attrs.keyword
|
|
627
|
+
};
|
|
628
|
+
break;
|
|
629
|
+
case "body":
|
|
630
|
+
node.type = "richtext_part";
|
|
631
|
+
node.attrs = {
|
|
632
|
+
title: "Body",
|
|
633
|
+
id: "body",
|
|
634
|
+
locking: false,
|
|
635
|
+
language: false,
|
|
636
|
+
optional: false,
|
|
637
|
+
hidden: false,
|
|
638
|
+
help: false,
|
|
639
|
+
deleted: false,
|
|
640
|
+
elements: [
|
|
641
|
+
"paragraph",
|
|
642
|
+
"heading1",
|
|
643
|
+
"heading2",
|
|
644
|
+
"heading3",
|
|
645
|
+
"heading4",
|
|
646
|
+
"heading5",
|
|
647
|
+
"heading6",
|
|
648
|
+
"figure",
|
|
649
|
+
"ordered_list",
|
|
650
|
+
"bullet_list",
|
|
651
|
+
"horizontal_rule",
|
|
652
|
+
"equation",
|
|
653
|
+
"citation",
|
|
654
|
+
"blockquote",
|
|
655
|
+
"footnote",
|
|
656
|
+
"table"
|
|
657
|
+
],
|
|
658
|
+
marks: ["strong", "em", "link", "anchor"]
|
|
659
|
+
};
|
|
660
|
+
break;
|
|
661
|
+
case "heading":
|
|
662
|
+
node.type = `heading${node.attrs.level}`;
|
|
663
|
+
delete node.attrs.level;
|
|
664
|
+
break;
|
|
665
|
+
default:
|
|
666
|
+
break;
|
|
667
|
+
}
|
|
668
|
+
if (node.content) {
|
|
669
|
+
node.content.forEach(childNode => {
|
|
670
|
+
convertNodeV23(childNode);
|
|
671
|
+
});
|
|
672
|
+
}
|
|
673
|
+
};
|
|
674
|
+
const convertDocV23 = doc => {
|
|
675
|
+
const returnDoc = JSON.parse(JSON.stringify(doc));
|
|
676
|
+
convertNodeV23(returnDoc.content);
|
|
677
|
+
returnDoc.settings = Object.assign({}, returnDoc.settings, v23ExtraAttrs);
|
|
678
|
+
return returnDoc;
|
|
679
|
+
};
|
|
680
|
+
const convertNodeV30 = node => {
|
|
681
|
+
if (node.attrs?.marks && node.attrs.marks.filter) {
|
|
682
|
+
node.attrs.marks = node.attrs.marks.filter(mark => mark !== "anchor");
|
|
683
|
+
}
|
|
684
|
+
if (node.attrs?.footnote_marks) {
|
|
685
|
+
node.attrs.footnote_marks = node.attrs.footnote_marks.filter(mark => mark !== "anchor");
|
|
686
|
+
}
|
|
687
|
+
let attrs;
|
|
688
|
+
switch (node.type) {
|
|
689
|
+
case "article":
|
|
690
|
+
attrs = {
|
|
691
|
+
documentstyle: "",
|
|
692
|
+
tracked: false,
|
|
693
|
+
citationstyle: "apa",
|
|
694
|
+
language: "en-US",
|
|
695
|
+
languages: [
|
|
696
|
+
"af-ZA",
|
|
697
|
+
"sq-AL",
|
|
698
|
+
"ar",
|
|
699
|
+
"ast",
|
|
700
|
+
"be",
|
|
701
|
+
"br",
|
|
702
|
+
"bg",
|
|
703
|
+
"ca",
|
|
704
|
+
"ca-ES-Valencia",
|
|
705
|
+
"zh-CN",
|
|
706
|
+
"da",
|
|
707
|
+
"nl",
|
|
708
|
+
"en-AU",
|
|
709
|
+
"en-CA",
|
|
710
|
+
"en-NZ",
|
|
711
|
+
"en-ZA",
|
|
712
|
+
"en-GB",
|
|
713
|
+
"en-US",
|
|
714
|
+
"eo",
|
|
715
|
+
"fr",
|
|
716
|
+
"gl",
|
|
717
|
+
"de-DE",
|
|
718
|
+
"de-AU",
|
|
719
|
+
"de-CH",
|
|
720
|
+
"el",
|
|
721
|
+
"he",
|
|
722
|
+
"is",
|
|
723
|
+
"it",
|
|
724
|
+
"ja",
|
|
725
|
+
"km",
|
|
726
|
+
"lt",
|
|
727
|
+
"ml",
|
|
728
|
+
"nb-NO",
|
|
729
|
+
"nn-NO",
|
|
730
|
+
"fa",
|
|
731
|
+
"pl",
|
|
732
|
+
"pt-BR",
|
|
733
|
+
"pt-PT",
|
|
734
|
+
"ro",
|
|
735
|
+
"ru",
|
|
736
|
+
"tr",
|
|
737
|
+
"sr-SP-Cy",
|
|
738
|
+
"sr-SP-Lt",
|
|
739
|
+
"sk",
|
|
740
|
+
"sl",
|
|
741
|
+
"es",
|
|
742
|
+
"sv",
|
|
743
|
+
"ta",
|
|
744
|
+
"tl",
|
|
745
|
+
"uk"
|
|
746
|
+
],
|
|
747
|
+
papersize: "A4",
|
|
748
|
+
papersizes: ["A4", "US Letter"],
|
|
749
|
+
footnote_marks: ["strong", "em", "link"],
|
|
750
|
+
footnote_elements: [
|
|
751
|
+
"paragraph",
|
|
752
|
+
"heading1",
|
|
753
|
+
"heading2",
|
|
754
|
+
"heading3",
|
|
755
|
+
"heading4",
|
|
756
|
+
"heading5",
|
|
757
|
+
"heading6",
|
|
758
|
+
"figure",
|
|
759
|
+
"ordered_list",
|
|
760
|
+
"bullet_list",
|
|
761
|
+
"horizontal_rule",
|
|
762
|
+
"equation",
|
|
763
|
+
"citation",
|
|
764
|
+
"blockquote",
|
|
765
|
+
"table"
|
|
766
|
+
]
|
|
767
|
+
};
|
|
768
|
+
break;
|
|
769
|
+
case "richtext_part":
|
|
770
|
+
attrs = {
|
|
771
|
+
title: "",
|
|
772
|
+
id: "",
|
|
773
|
+
locking: false,
|
|
774
|
+
language: false,
|
|
775
|
+
optional: false,
|
|
776
|
+
hidden: false,
|
|
777
|
+
help: false,
|
|
778
|
+
initial: false,
|
|
779
|
+
deleted: false,
|
|
780
|
+
elements: [
|
|
781
|
+
"paragraph",
|
|
782
|
+
"heading1",
|
|
783
|
+
"heading2",
|
|
784
|
+
"heading3",
|
|
785
|
+
"heading4",
|
|
786
|
+
"heading5",
|
|
787
|
+
"heading6",
|
|
788
|
+
"figure",
|
|
789
|
+
"ordered_list",
|
|
790
|
+
"bullet_list",
|
|
791
|
+
"horizontal_rule",
|
|
792
|
+
"equation",
|
|
793
|
+
"citation",
|
|
794
|
+
"blockquote",
|
|
795
|
+
"footnote",
|
|
796
|
+
"table"
|
|
797
|
+
],
|
|
798
|
+
marks: ["strong", "em", "link"],
|
|
799
|
+
metadata: false
|
|
800
|
+
};
|
|
801
|
+
break;
|
|
802
|
+
case "heading_part":
|
|
803
|
+
attrs = {
|
|
804
|
+
title: "",
|
|
805
|
+
id: "",
|
|
806
|
+
locking: false,
|
|
807
|
+
language: false,
|
|
808
|
+
optional: false,
|
|
809
|
+
hidden: false,
|
|
810
|
+
help: false,
|
|
811
|
+
initial: false,
|
|
812
|
+
deleted: false,
|
|
813
|
+
elements: ["heading1"],
|
|
814
|
+
marks: ["strong", "em", "link"],
|
|
815
|
+
metadata: false
|
|
816
|
+
};
|
|
817
|
+
break;
|
|
818
|
+
case "contributors_part":
|
|
819
|
+
attrs = {
|
|
820
|
+
title: "",
|
|
821
|
+
id: "",
|
|
822
|
+
locking: false,
|
|
823
|
+
language: false,
|
|
824
|
+
optional: false,
|
|
825
|
+
hidden: false,
|
|
826
|
+
help: false,
|
|
827
|
+
initial: false,
|
|
828
|
+
deleted: false,
|
|
829
|
+
item_title: "Contributor",
|
|
830
|
+
metadata: false
|
|
831
|
+
};
|
|
832
|
+
break;
|
|
833
|
+
case "tags_part":
|
|
834
|
+
attrs = {
|
|
835
|
+
title: "",
|
|
836
|
+
id: "",
|
|
837
|
+
locking: false,
|
|
838
|
+
language: false,
|
|
839
|
+
optional: false,
|
|
840
|
+
hidden: false,
|
|
841
|
+
help: false,
|
|
842
|
+
initial: false,
|
|
843
|
+
deleted: false,
|
|
844
|
+
item_title: "Tag",
|
|
845
|
+
metadata: false
|
|
846
|
+
};
|
|
847
|
+
break;
|
|
848
|
+
case "table_part":
|
|
849
|
+
attrs = {
|
|
850
|
+
title: "",
|
|
851
|
+
id: "",
|
|
852
|
+
locking: false,
|
|
853
|
+
language: false,
|
|
854
|
+
optional: false,
|
|
855
|
+
hidden: false,
|
|
856
|
+
help: false,
|
|
857
|
+
initial: false,
|
|
858
|
+
deleted: false,
|
|
859
|
+
elements: [
|
|
860
|
+
"paragraph",
|
|
861
|
+
"heading1",
|
|
862
|
+
"heading2",
|
|
863
|
+
"heading3",
|
|
864
|
+
"heading4",
|
|
865
|
+
"heading5",
|
|
866
|
+
"heading6",
|
|
867
|
+
"figure",
|
|
868
|
+
"ordered_list",
|
|
869
|
+
"bullet_list",
|
|
870
|
+
"horizontal_rule",
|
|
871
|
+
"equation",
|
|
872
|
+
"citation",
|
|
873
|
+
"blockquote",
|
|
874
|
+
"footnote"
|
|
875
|
+
],
|
|
876
|
+
marks: ["strong", "em", "link"],
|
|
877
|
+
metadata: false
|
|
878
|
+
};
|
|
879
|
+
break;
|
|
880
|
+
case "table_of_contents":
|
|
881
|
+
attrs = {
|
|
882
|
+
title: "Table of Contents",
|
|
883
|
+
id: "toc",
|
|
884
|
+
optional: false,
|
|
885
|
+
hidden: false
|
|
886
|
+
};
|
|
887
|
+
break;
|
|
888
|
+
case "separator_part":
|
|
889
|
+
attrs = {
|
|
890
|
+
id: "separator"
|
|
891
|
+
};
|
|
892
|
+
break;
|
|
893
|
+
case "title":
|
|
894
|
+
attrs = {
|
|
895
|
+
id: "title"
|
|
896
|
+
};
|
|
897
|
+
break;
|
|
898
|
+
case "contributor":
|
|
899
|
+
attrs = {
|
|
900
|
+
firstname: false,
|
|
901
|
+
lastname: false,
|
|
902
|
+
email: false,
|
|
903
|
+
institution: false
|
|
904
|
+
};
|
|
905
|
+
break;
|
|
906
|
+
case "tag":
|
|
907
|
+
attrs = {
|
|
908
|
+
tag: ""
|
|
909
|
+
};
|
|
910
|
+
break;
|
|
911
|
+
case "footnote":
|
|
912
|
+
attrs = {
|
|
913
|
+
footnote: [
|
|
914
|
+
{
|
|
915
|
+
type: "paragraph"
|
|
916
|
+
}
|
|
917
|
+
]
|
|
918
|
+
};
|
|
919
|
+
break;
|
|
920
|
+
case "code_block":
|
|
921
|
+
case "paragraph":
|
|
922
|
+
case "blockquote":
|
|
923
|
+
case "horizontal_rule":
|
|
924
|
+
case "bullet_list":
|
|
925
|
+
case "list_item":
|
|
926
|
+
attrs = {
|
|
927
|
+
track: []
|
|
928
|
+
};
|
|
929
|
+
break;
|
|
930
|
+
case "ordered_list":
|
|
931
|
+
attrs = {
|
|
932
|
+
order: 1,
|
|
933
|
+
track: []
|
|
934
|
+
};
|
|
935
|
+
break;
|
|
936
|
+
case "citation":
|
|
937
|
+
attrs = {
|
|
938
|
+
format: "autocite",
|
|
939
|
+
references: []
|
|
940
|
+
};
|
|
941
|
+
break;
|
|
942
|
+
case "equation":
|
|
943
|
+
attrs = {
|
|
944
|
+
equation: ""
|
|
945
|
+
};
|
|
946
|
+
break;
|
|
947
|
+
case "figure":
|
|
948
|
+
attrs = {
|
|
949
|
+
equation: "",
|
|
950
|
+
image: false,
|
|
951
|
+
figureCategory: "",
|
|
952
|
+
caption: "",
|
|
953
|
+
id: false,
|
|
954
|
+
track: [],
|
|
955
|
+
aligned: "center",
|
|
956
|
+
width: "100"
|
|
957
|
+
};
|
|
958
|
+
break;
|
|
959
|
+
case "heading1":
|
|
960
|
+
case "heading2":
|
|
961
|
+
case "heading3":
|
|
962
|
+
case "heading4":
|
|
963
|
+
case "heading5":
|
|
964
|
+
case "heading6":
|
|
965
|
+
attrs = {
|
|
966
|
+
id: false,
|
|
967
|
+
track: []
|
|
968
|
+
};
|
|
969
|
+
break;
|
|
970
|
+
default:
|
|
971
|
+
break;
|
|
972
|
+
}
|
|
973
|
+
if (attrs && node.attrs) {
|
|
974
|
+
for (const attr in attrs) {
|
|
975
|
+
if (attr in node.attrs &&
|
|
976
|
+
deepEqual(node.attrs[attr], attrs[attr])) {
|
|
977
|
+
delete node.attrs[attr];
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
switch (node.type) {
|
|
981
|
+
case "article": {
|
|
982
|
+
if (node.attrs.language === "") {
|
|
983
|
+
delete node.attrs.language;
|
|
984
|
+
}
|
|
985
|
+
const template = node.attrs.template || "default";
|
|
986
|
+
node.attrs.import_id = template
|
|
987
|
+
.normalize("NFKC")
|
|
988
|
+
.replace(/[^\w\s-]/g, "")
|
|
989
|
+
.toLowerCase()
|
|
990
|
+
.trim()
|
|
991
|
+
.replace(/[-\s]+/g, "-");
|
|
992
|
+
switch (node.attrs.citationstyle) {
|
|
993
|
+
case "harvard1":
|
|
994
|
+
node.attrs.citationstyle = "harvard-cite-them-right";
|
|
995
|
+
break;
|
|
996
|
+
case "mla":
|
|
997
|
+
node.attrs.citationstyle = "modern-language-association";
|
|
998
|
+
break;
|
|
999
|
+
case "american-anthropological-association":
|
|
1000
|
+
case "chicago-author-date":
|
|
1001
|
+
case "chicago-note-bibliography":
|
|
1002
|
+
case "oxford-university-press-humsoc":
|
|
1003
|
+
case "nature":
|
|
1004
|
+
break;
|
|
1005
|
+
default:
|
|
1006
|
+
delete node.attrs.citationstyle;
|
|
1007
|
+
}
|
|
1008
|
+
break;
|
|
1009
|
+
}
|
|
1010
|
+
case "title":
|
|
1011
|
+
delete node.attrs.title;
|
|
1012
|
+
break;
|
|
1013
|
+
default:
|
|
1014
|
+
break;
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
if (node.marks) {
|
|
1018
|
+
for (const mark in node.marks) {
|
|
1019
|
+
let attrs;
|
|
1020
|
+
switch (mark.type) {
|
|
1021
|
+
case "comment":
|
|
1022
|
+
attrs = {
|
|
1023
|
+
id: false
|
|
1024
|
+
};
|
|
1025
|
+
break;
|
|
1026
|
+
case "annotation_tag":
|
|
1027
|
+
attrs = {
|
|
1028
|
+
type: "",
|
|
1029
|
+
key: "",
|
|
1030
|
+
value: ""
|
|
1031
|
+
};
|
|
1032
|
+
break;
|
|
1033
|
+
case "anchor":
|
|
1034
|
+
attrs = {
|
|
1035
|
+
id: false
|
|
1036
|
+
};
|
|
1037
|
+
break;
|
|
1038
|
+
case "deletion":
|
|
1039
|
+
attrs = {
|
|
1040
|
+
user: 0,
|
|
1041
|
+
username: "",
|
|
1042
|
+
date: 0
|
|
1043
|
+
};
|
|
1044
|
+
break;
|
|
1045
|
+
case "insertion":
|
|
1046
|
+
attrs = {
|
|
1047
|
+
user: 0,
|
|
1048
|
+
username: "",
|
|
1049
|
+
date: 0,
|
|
1050
|
+
approved: true
|
|
1051
|
+
};
|
|
1052
|
+
break;
|
|
1053
|
+
case "format_change":
|
|
1054
|
+
attrs = {
|
|
1055
|
+
user: 0,
|
|
1056
|
+
username: "",
|
|
1057
|
+
date: 0,
|
|
1058
|
+
before: [],
|
|
1059
|
+
after: []
|
|
1060
|
+
};
|
|
1061
|
+
break;
|
|
1062
|
+
}
|
|
1063
|
+
if (attrs && mark.attrs) {
|
|
1064
|
+
for (const attr in attrs) {
|
|
1065
|
+
if (attr in mark.attrs &&
|
|
1066
|
+
deepEqual(mark.attrs[attr], attrs[attr])) {
|
|
1067
|
+
delete mark.attrs[attr];
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
if (node.content) {
|
|
1074
|
+
node.content.forEach(childNode => {
|
|
1075
|
+
convertNodeV30(childNode);
|
|
1076
|
+
});
|
|
1077
|
+
}
|
|
1078
|
+
};
|
|
1079
|
+
const convertDocV30 = doc => {
|
|
1080
|
+
const returnDoc = JSON.parse(JSON.stringify(doc));
|
|
1081
|
+
convertNodeV30(returnDoc.content);
|
|
1082
|
+
return returnDoc;
|
|
1083
|
+
};
|
|
1084
|
+
const convertDocV31 = doc => {
|
|
1085
|
+
// Conversion adds no new requirements. Version update is required so that
|
|
1086
|
+
// users don't try to open file in a previous FW file. That won't work as
|
|
1087
|
+
// additional syntax has been added (copyright + cross references).
|
|
1088
|
+
const returnDoc = JSON.parse(JSON.stringify(doc));
|
|
1089
|
+
return returnDoc;
|
|
1090
|
+
};
|
|
1091
|
+
const convertNodeV32 = (node, ids = []) => {
|
|
1092
|
+
let blockId, attrs;
|
|
1093
|
+
switch (node.type) {
|
|
1094
|
+
case "table":
|
|
1095
|
+
attrs = node.attrs || {};
|
|
1096
|
+
blockId = attrs.id;
|
|
1097
|
+
while (!blockId || ids.includes(blockId)) {
|
|
1098
|
+
blockId = randomTableId();
|
|
1099
|
+
}
|
|
1100
|
+
attrs.id = blockId;
|
|
1101
|
+
attrs.caption = false;
|
|
1102
|
+
node.attrs = attrs;
|
|
1103
|
+
ids.push(blockId);
|
|
1104
|
+
node.content = [
|
|
1105
|
+
{ type: "table_caption" },
|
|
1106
|
+
{
|
|
1107
|
+
type: "table_body",
|
|
1108
|
+
content: node.content
|
|
1109
|
+
}
|
|
1110
|
+
];
|
|
1111
|
+
break;
|
|
1112
|
+
case "table_cell":
|
|
1113
|
+
if (!node.content || !node.content.length) {
|
|
1114
|
+
node.content = [{ type: "paragraph" }];
|
|
1115
|
+
}
|
|
1116
|
+
break;
|
|
1117
|
+
case "table_header":
|
|
1118
|
+
if (!node.content || !node.content.length) {
|
|
1119
|
+
node.content = [{ type: "paragraph" }];
|
|
1120
|
+
}
|
|
1121
|
+
break;
|
|
1122
|
+
case "bullet_list":
|
|
1123
|
+
case "ordered_list":
|
|
1124
|
+
attrs = node.attrs || {};
|
|
1125
|
+
blockId = attrs.id;
|
|
1126
|
+
while (!blockId || ids.includes(blockId)) {
|
|
1127
|
+
blockId = randomListId();
|
|
1128
|
+
}
|
|
1129
|
+
attrs.id = blockId;
|
|
1130
|
+
node.attrs = attrs;
|
|
1131
|
+
ids.push(blockId);
|
|
1132
|
+
break;
|
|
1133
|
+
case "figure": {
|
|
1134
|
+
attrs = node.attrs || {};
|
|
1135
|
+
if (attrs.figureCategory) {
|
|
1136
|
+
attrs.category = attrs.figureCategory;
|
|
1137
|
+
delete attrs.figureCategory;
|
|
1138
|
+
}
|
|
1139
|
+
node.content = [];
|
|
1140
|
+
if (attrs.image) {
|
|
1141
|
+
node.content.push({ type: "image", attrs: { image: attrs.image } });
|
|
1142
|
+
}
|
|
1143
|
+
else {
|
|
1144
|
+
node.content.push({
|
|
1145
|
+
type: "figure_equation",
|
|
1146
|
+
attrs: { equation: attrs.equation || "" }
|
|
1147
|
+
});
|
|
1148
|
+
}
|
|
1149
|
+
delete attrs.image;
|
|
1150
|
+
delete attrs.equation;
|
|
1151
|
+
const caption = { type: "figure_caption" };
|
|
1152
|
+
if (attrs.caption) {
|
|
1153
|
+
if (attrs.caption.length) {
|
|
1154
|
+
caption.content = [{ type: "text", text: attrs.caption }];
|
|
1155
|
+
attrs.caption = true;
|
|
1156
|
+
}
|
|
1157
|
+
else {
|
|
1158
|
+
attrs.caption = false;
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1161
|
+
else {
|
|
1162
|
+
attrs.caption = false;
|
|
1163
|
+
}
|
|
1164
|
+
if (attrs.category === "table") {
|
|
1165
|
+
node.content.unshift(caption);
|
|
1166
|
+
}
|
|
1167
|
+
else {
|
|
1168
|
+
node.content.push(caption);
|
|
1169
|
+
}
|
|
1170
|
+
node.attrs = attrs;
|
|
1171
|
+
break;
|
|
1172
|
+
}
|
|
1173
|
+
case "footnote":
|
|
1174
|
+
if (node.attrs?.footnote) {
|
|
1175
|
+
node.attrs.footnote.forEach(childNode => {
|
|
1176
|
+
convertNodeV32(childNode, ids);
|
|
1177
|
+
});
|
|
1178
|
+
}
|
|
1179
|
+
break;
|
|
1180
|
+
}
|
|
1181
|
+
if (node.content) {
|
|
1182
|
+
node.content.forEach(childNode => {
|
|
1183
|
+
convertNodeV32(childNode, ids);
|
|
1184
|
+
});
|
|
1185
|
+
}
|
|
1186
|
+
if (node.attrs?.initial) {
|
|
1187
|
+
node.attrs.initial.forEach(childNode => {
|
|
1188
|
+
convertNodeV32(childNode, ids);
|
|
1189
|
+
});
|
|
1190
|
+
}
|
|
1191
|
+
};
|
|
1192
|
+
const convertDocV32 = doc => {
|
|
1193
|
+
const returnDoc = JSON.parse(JSON.stringify(doc));
|
|
1194
|
+
convertNodeV32(returnDoc.content);
|
|
1195
|
+
return returnDoc;
|
|
1196
|
+
};
|
|
1197
|
+
const convertDocV33 = doc => {
|
|
1198
|
+
// We just need to increase the version number so that documents cannot
|
|
1199
|
+
// be moved from a 3.10 to an 3.9 system, but 3.3 files should be readable
|
|
1200
|
+
// as 3.4 files.
|
|
1201
|
+
return JSON.parse(JSON.stringify(doc));
|
|
1202
|
+
};
|
|
1203
|
+
const convertDocV34 = doc => {
|
|
1204
|
+
// The top node needs to be changed from "article" to "doc".
|
|
1205
|
+
const returnDoc = JSON.parse(JSON.stringify(doc));
|
|
1206
|
+
returnDoc.content.type = "doc";
|
|
1207
|
+
return returnDoc;
|
|
1208
|
+
};
|
|
1209
|
+
const convertDocV35 = doc => {
|
|
1210
|
+
// We just need to increase the version number so that documents cannot
|
|
1211
|
+
// be moved from a 4.1 to an 4.0 system, but 3.5 files should be readable
|
|
1212
|
+
// as 3.6 files.
|
|
1213
|
+
return JSON.parse(JSON.stringify(doc));
|
|
1214
|
+
};
|
|
1215
|
+
//# sourceMappingURL=convert.js.map
|