diff --git a/src/commands.ts b/src/commands.ts index 6d52c8d..af4aa20 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -244,10 +244,7 @@ const cmd_export_as_single_note = (plugin: NoteSyncPlugin) => ({ const path = require("path"); const { dialog } = require("electron").remote; - let cfiles = []; - if(plugin.easyapi.nc){ - cfiles = plugin.easyapi.nc.chain.get_selected_files() - } + let cfiles = plugin.easyapi.file.get_selected_files(); if(cfiles.length<=2){ // 1. 当前文件 let cfile = plugin.easyapi.cfile; diff --git a/src/easyapi/file.ts b/src/easyapi/file.ts index 5144bc6..dc39011 100644 --- a/src/easyapi/file.ts +++ b/src/easyapi/file.ts @@ -164,5 +164,25 @@ export class File { } return tags } + + get_selected_files(current_if_no_selected = true) { + let selector = document.querySelectorAll( + ".tree-item-self.is-selected" + ); + let items = Object.values(selector).map((x: any) => { + var _a; + return (_a = x.dataset) == null ? void 0 : _a.path; + }); + let tfiles = items.map( + (x) => this.get_tfile(x)).filter((x) => x.extension == "md" + ) + if (tfiles.length > 0) { + return tfiles + } else if (current_if_no_selected && this.app.workspace.getActiveFile()) { + return [this.app.workspace.getActiveFile()] + } else { + return [] + } + } } diff --git a/src/strings.ts b/src/strings.ts index 0dae822..3b1b9d2 100644 --- a/src/strings.ts +++ b/src/strings.ts @@ -52,9 +52,9 @@ export class Strings{ get cmd_export_as_single_note(){ if(this.language=='zh'){ - return '导出目录文件'; + return '导出多条笔记'; }else{ - return 'Export folder'; + return 'Export notes'; } }