fix: filepicker tsc error

This commit is contained in:
windingwind 2023-07-25 20:27:58 +08:00
parent a3524fd5e2
commit eb158efbd1
3 changed files with 13 additions and 13 deletions

View File

@ -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",

View File

@ -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,
});

View File

@ -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);