Skip to content

Commit

Permalink
resolve: #702
Browse files Browse the repository at this point in the history
  • Loading branch information
windingwind committed Sep 21, 2023
1 parent 788c590 commit 40f2774
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 10 deletions.
1 change: 1 addition & 0 deletions addon/locale/en-US/addon.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions addon/locale/ru-RU/addon.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -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 файл
Expand Down
1 change: 1 addition & 0 deletions addon/locale/zh-CN/addon.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -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文件
Expand Down
1 change: 1 addition & 0 deletions addon/prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
19 changes: 18 additions & 1 deletion src/modules/export/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };

Expand All @@ -17,6 +17,7 @@ async function exportNotes(
exportNote?: boolean;
exportMD?: boolean;
setAutoSync?: boolean;
autoMDFileName?: boolean;
syncDir?: string;
withYAMLHeader?: boolean;
exportDocx?: boolean;
Expand Down Expand Up @@ -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,
});
Expand Down
19 changes: 10 additions & 9 deletions src/modules/export/exportWindow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"), {
Expand Down

0 comments on commit 40f2774

Please sign in to comment.