* 导出文件的高亮和评论内容为新的笔记 * @param sourceFile 源文件 * @returns 返回创建的新文件
(sourceFile: TFile)
| 109 | * @returns 返回创建的新文件 |
| 110 | */ |
| 111 | async exportHighlightsToNote(sourceFile: TFile): Promise<TFile> { |
| 112 | // 获取文件的所有高亮和评论 |
| 113 | const highlights = await this.getFileHighlights(sourceFile); |
| 114 | if (!highlights || highlights.length === 0) { |
| 115 | throw new Error(t("No highlights found in the current file.")); |
| 116 | } |
| 117 | |
| 118 | // 生成导出内容 |
| 119 | const content = await this.generateExportContent(sourceFile, highlights); |
| 120 | |
| 121 | // 获取导出路径并创建文件 |
| 122 | const settings = this.getPluginSettings(); |
| 123 | const exportPath = settings?.export?.exportPath || ''; |
| 124 | const fileName = `${sourceFile.basename} - HiNote ${window.moment().format("YYYYMMDDHHmmss")}`; |
| 125 | |
| 126 | return await this.createExportFile(fileName, content, exportPath); |
| 127 | } |
| 128 | |
| 129 | /** |
| 130 | * 获取文件的所有高亮和评论 |
no test coverage detected