diff options
author | bobzel <zzzman@gmail.com> | 2022-06-24 19:03:00 -0400 |
---|---|---|
committer | bobzel <zzzman@gmail.com> | 2022-06-24 19:03:00 -0400 |
commit | dccf5909f4a4bec35559b23a2f355ab4c7a94086 (patch) | |
tree | 6c419e5b3b6654c611cd097d2977cd4636edc12c /src/fields/Doc.ts | |
parent | 9c1f0a7d394affe955fb3f422647784b5bdd32b6 (diff) |
fixed myImports pane to show imports. fixed saving/loading zip files of a collection. fixed errors related to NumT casting to number
Diffstat (limited to 'src/fields/Doc.ts')
-rw-r--r-- | src/fields/Doc.ts | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/fields/Doc.ts b/src/fields/Doc.ts index 981514b25..4fe6eb1e7 100644 --- a/src/fields/Doc.ts +++ b/src/fields/Doc.ts @@ -658,7 +658,7 @@ export namespace Doc { const zip = new JSZip(); - zip.file(doc.title + ".json", docString); + zip.file("doc.json", docString); // // Generate a directory within the Zip file structure // var img = zip.folder("images"); @@ -1289,6 +1289,21 @@ export namespace Doc { } } + export async function importDocument(file:File) { + const upload = Utils.prepend("/uploadDoc"); + const formData = new FormData(); + if (file) { + formData.append('file', file); + formData.append('remap', "true"); + const response = await fetch(upload, { method: "POST", body: formData }); + const json = await response.json(); + if (json !== "error") { + const doc = await DocServer.GetRefField(json); + return doc; + } + } + return undefined; + } export namespace Get { |