* 根据文本和位置查找高亮 * @param file 文件 * @param highlight 高亮信息(包含 text 和 position) * @returns 匹配的高亮数组
(file: TFile, highlight: { text: string; position?: number })
| 118 | * @returns 匹配的高亮数组 |
| 119 | */ |
| 120 | async findHighlights(file: TFile, highlight: { text: string; position?: number }): Promise<HiNote[]> { |
| 121 | if (!file) return []; |
| 122 | |
| 123 | const fileHighlights = await this.repository.getFileHighlights(file.path); |
| 124 | |
| 125 | return fileHighlights.filter(c => { |
| 126 | const textMatch = c.text === highlight.text; |
| 127 | if (!textMatch) return false; |
| 128 | |
| 129 | if (typeof c.position === 'number' && typeof highlight.position === 'number') { |
| 130 | return Math.abs(c.position - highlight.position) < 1000; |
| 131 | } |
| 132 | return true; |
| 133 | }); |
| 134 | } |
| 135 | |
| 136 | /** |
| 137 | * 根据 blockId 查找高亮 |
nothing calls this directly
no test coverage detected