MCPcopy Create free account
hub / github.com/CatMuse/HiNote / removeHighlight

Method removeHighlight

src/services/HighlightManager.ts:75–102  ·  view source on GitHub ↗

* 移除高亮 * @param file 文件 * @param highlight 高亮信息 * @returns 是否成功移除

(file: TFile, highlight: HiNote)

Source from the content-addressed store, hash-verified

73 * @returns 是否成功移除
74 */
75 async removeHighlight(file: TFile, highlight: HiNote): Promise<boolean> {
76 const filePath = file.path;
77 const fileHighlights = await this.repository.getFileHighlights(filePath);
78
79 const highlightExists = fileHighlights.some(h => h.id === highlight.id);
80 if (!highlightExists) {
81 return false;
82 }
83
84 const updatedHighlights = fileHighlights.filter(h => h.id !== highlight.id);
85
86 if (updatedHighlights.length > 0) {
87 await this.repository.saveFileHighlights(filePath, updatedHighlights);
88 } else {
89 await this.repository.deleteFileHighlights(filePath);
90 }
91
92 if (this.eventManager && highlight.id) {
93 if (highlight.comments && highlight.comments.length > 0) {
94 const latestComment = highlight.comments[highlight.comments.length - 1];
95 this.eventManager.emitCommentDelete(filePath, latestComment.content, highlight.id);
96 } else {
97 this.eventManager.emitHighlightDelete(filePath, highlight.text, highlight.id);
98 }
99 }
100
101 return true;
102 }
103
104 /**
105 * 获取文件的所有高亮

Callers 5

deleteHighlightMethod · 0.80
removeHighlightDataMethod · 0.80
deleteCommentMethod · 0.80

Calls 5

emitCommentDeleteMethod · 0.80
emitHighlightDeleteMethod · 0.80
getFileHighlightsMethod · 0.65
saveFileHighlightsMethod · 0.65
deleteFileHighlightsMethod · 0.65

Tested by

no test coverage detected