* 获取高亮对应的文件
(highlight: HighlightInfo)
| 247 | * 获取高亮对应的文件 |
| 248 | */ |
| 249 | private async getFileForHighlight(highlight: HighlightInfo): Promise<TFile | null> { |
| 250 | // 如果有当前文件,使用当前文件 |
| 251 | if (this.currentFile) { |
| 252 | return this.currentFile; |
| 253 | } |
| 254 | // 如果是全部高亮视图,使用 highlight.filePath 获取文件 |
| 255 | if (highlight.filePath) { |
| 256 | const file = this.app.vault.getAbstractFileByPath(highlight.filePath); |
| 257 | if (file instanceof TFile) { |
| 258 | return file; |
| 259 | } |
| 260 | } |
| 261 | // 如果通过 filePath 找不到,尝试通过 fileName |
| 262 | if (highlight.fileName) { |
| 263 | const files = this.app.vault.getFiles(); |
| 264 | const file = files.find(f => f.basename === highlight.fileName || f.name === highlight.fileName); |
| 265 | if (file) { |
| 266 | return file; |
| 267 | } |
| 268 | } |
| 269 | return null; |
| 270 | } |
| 271 | |
| 272 | /** |
| 273 | * 检查高亮是否已经创建了闪卡 |
no outgoing calls
no test coverage detected