This commit is contained in:
windingwind 2023-09-21 16:32:38 +08:00
parent 788c590dfa
commit 40f2774ece
6 changed files with 32 additions and 10 deletions

View File

@ -46,6 +46,7 @@ export-keepLink = Keep Zotero Links(zotero://note/)
export-exportMD = Export MD File(s)
export-setAutoSync = Set Auto-Sync
export-withYAMLHeader = With YAML Header
export-autoMDFileName = Auto Generate MD File Name
export-exportDocx = Export Docx File
export-exportPDF = Export PDF File
export-exportFreeMind = Export FreeMind File

View File

@ -46,6 +46,7 @@ export-keepLink=Сохранять Zotero ссылки(zotero://note/)
export-exportMD=Экспорт MD файл(-ов)
export-setAutoSync=Установить Авто-синк
export-withYAMLHeader=С YAML заголовком
export-autoMDFileName = Авто-имя MD файла
export-exportDocx=Экспорт Docx файл
export-exportPDF=Экспорт PDF файл
export-exportFreeMind=Экспорт FreeMind файл

View File

@ -46,6 +46,7 @@ export-keepLink=保留Zotero链接(zotero://note/)
export-exportMD=导出MD文件
export-setAutoSync=设置自动同步
export-withYAMLHeader=带有YAML头
export-autoMDFileName=自动生成MD文件名
export-exportDocx=导出Word文件
export-exportPDF=导出PDF文件
export-exportFreeMind=导出FreeMind文件

View File

@ -11,6 +11,7 @@ pref("__prefsPrefix__.keepLink", true);
pref("__prefsPrefix__.exportMD", true);
pref("__prefsPrefix__.setAutoSync", false);
pref("__prefsPrefix__.withYAMLHeader", false);
pref("__prefsPrefix__.autoMDFileName", false);
pref("__prefsPrefix__.exportDocx", false);
pref("__prefsPrefix__.exportPDF", false);
pref("__prefsPrefix__.exportFreeMind", false);

View File

@ -5,7 +5,7 @@ import {
} from "../../utils/link";
import { getString } from "../../utils/locale";
import { getLinesInNote } from "../../utils/note";
import { formatPath } from "../../utils/str";
import { formatPath, jointPath } from "../../utils/str";
export { exportNotes };
@ -17,6 +17,7 @@ async function exportNotes(
exportNote?: boolean;
exportMD?: boolean;
setAutoSync?: boolean;
autoMDFileName?: boolean;
syncDir?: string;
withYAMLHeader?: boolean;
exportDocx?: boolean;
@ -91,8 +92,24 @@ async function exportNotes(
});
}
} else {
let exportDir: string | false = false;
if (options.autoMDFileName) {
const raw = await new ztoolkit.FilePicker(
`${getString("fileInterface.export")} MarkDown File`,
"folder",
).open();
exportDir = raw && formatPath(raw);
}
for (const noteItem of allNoteItems) {
await toMD(noteItem, {
filename:
(exportDir &&
jointPath(
exportDir,
await addon.api.sync.getMDFileName(noteItem.id, exportDir),
)) ||
undefined,
withYAMLHeader: options.withYAMLHeader,
keepNoteLink: true,
});

View File

@ -64,7 +64,7 @@ export async function showExportNoteOptions(
updateSyncCheckbox();
};
const dialog = new ztoolkit.Dialog(17, 1)
const dialog = new ztoolkit.Dialog(18, 1)
.setDialogData(data)
.addCell(0, 0, {
tag: "div",
@ -96,14 +96,15 @@ export async function showExportNoteOptions(
.addCell(6, 0, makeCheckboxLine("exportMD"))
.addCell(7, 0, makeCheckboxLine("setAutoSync"))
.addCell(8, 0, makeCheckboxLine("withYAMLHeader"))
.addCell(9, 0, makeHeadingLine(getString("export.options.Docx")))
.addCell(10, 0, makeCheckboxLine("exportDocx"))
.addCell(11, 0, makeHeadingLine(getString("export.options.PDF")))
.addCell(12, 0, makeCheckboxLine("exportPDF"))
.addCell(13, 0, makeHeadingLine(getString("export.options.mm")))
.addCell(14, 0, makeCheckboxLine("exportFreeMind"))
.addCell(15, 0, makeHeadingLine(getString("export.options.note")))
.addCell(16, 0, makeCheckboxLine("exportNote"))
.addCell(9, 0, makeCheckboxLine("autoMDFileName"))
.addCell(10, 0, makeHeadingLine(getString("export.options.Docx")))
.addCell(11, 0, makeCheckboxLine("exportDocx"))
.addCell(12, 0, makeHeadingLine(getString("export.options.PDF")))
.addCell(13, 0, makeCheckboxLine("exportPDF"))
.addCell(14, 0, makeHeadingLine(getString("export.options.mm")))
.addCell(15, 0, makeCheckboxLine("exportFreeMind"))
.addCell(16, 0, makeHeadingLine(getString("export.options.note")))
.addCell(17, 0, makeCheckboxLine("exportNote"))
.addButton(getString("export.confirm"), "confirm")
.addButton(getString("export.cancel"), "cancel")
.open(getString("export.title"), {