From eb158efbd1247859a8408a94b8417e16aae9370b Mon Sep 17 00:00:00 2001 From: windingwind <33902321+windingwind@users.noreply.github.com> Date: Tue, 25 Jul 2023 20:27:58 +0800 Subject: [PATCH] fix: filepicker tsc error --- package.json | 2 +- src/modules/createNote.ts | 8 ++++---- src/modules/export/api.ts | 16 ++++++++-------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index a1b3be8..72de484 100644 --- a/package.json +++ b/package.json @@ -70,7 +70,7 @@ "unist-util-visit": "^4.1.2", "unist-util-visit-parents": "^5.1.3", "yamljs": "^0.3.0", - "zotero-plugin-toolkit": "^2.1.6" + "zotero-plugin-toolkit": "^2.1.7" }, "devDependencies": { "@types/browser-or-node": "^1.3.0", diff --git a/src/modules/createNote.ts b/src/modules/createNote.ts index 72ed372..ba554c4 100644 --- a/src/modules/createNote.ts +++ b/src/modules/createNote.ts @@ -91,17 +91,17 @@ async function createNoteFromMD() { const syncNotes = window.confirm(getString("alert-syncImportedNotes")); - const filePaths = (await new ztoolkit.FilePicker( + const filepaths = await new ztoolkit.FilePicker( "Import MarkDown", "multiple", [[`MarkDown(*.md)`, `*.md`]] - ).open()) as string[]; + ).open(); - if (!filePaths.length) { + if (!filepaths) { return; } - for (const filepath of filePaths) { + for (const filepath of filepaths) { const noteItem = await addon.api.$import.fromMD(filepath, { ignoreVersion: true, }); diff --git a/src/modules/export/api.ts b/src/modules/export/api.ts index ac05896..ffdf401 100644 --- a/src/modules/export/api.ts +++ b/src/modules/export/api.ts @@ -68,10 +68,10 @@ async function exportNotes( ); if (options.exportMD) { if (options.setAutoSync) { - const raw = (await new ztoolkit.FilePicker( + const raw = await new ztoolkit.FilePicker( `${getString("fileInterface.sync")} MarkDown File`, "folder" - ).open()) as string; + ).open(); if (raw) { const syncDir = formatPath(raw); // Hard reset sync status for input notes @@ -140,12 +140,12 @@ async function toMD( ) { let filename = options.filename; if (!filename) { - const raw = (await new ztoolkit.FilePicker( + const raw = await new ztoolkit.FilePicker( `${Zotero.getString("fileInterface.export")} MarkDown File`, "save", [["MarkDown File(*.md)", "*.md"]], `${noteItem.getNoteTitle()}.md` - ).open()) as string; + ).open(); if (!raw) return; filename = formatPath(raw, ".md"); } @@ -171,24 +171,24 @@ async function toSync( } async function toDocx(noteItem: Zotero.Item) { - const raw = (await new ztoolkit.FilePicker( + const raw = await new ztoolkit.FilePicker( `${Zotero.getString("fileInterface.export")} MS Word Docx`, "save", [["MS Word Docx File(*.docx)", "*.docx"]], `${noteItem.getNoteTitle()}.docx` - ).open()) as string; + ).open(); if (!raw) return; const filename = formatPath(raw, ".docx"); await addon.api.$export.saveDocx(filename, noteItem.id); } async function toFreeMind(noteItem: Zotero.Item) { - const raw = (await new ztoolkit.FilePicker( + const raw = await new ztoolkit.FilePicker( `${Zotero.getString("fileInterface.export")} FreeMind XML`, "save", [["FreeMind XML File(*.mm)", "*.mm"]], `${noteItem.getNoteTitle()}.mm` - ).open()) as string; + ).open(); if (!raw) return; const filename = formatPath(raw, ".mm"); await addon.api.$export.saveFreeMind(filename, noteItem.id);