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

Method buildDecorations

src/editor/EditorHighlightDecorations.ts:34–63  ·  view source on GitHub ↗
(view: EditorView)

Source from the content-addressed store, hash-verified

32 }
33
34 private buildDecorations(view: EditorView): DecorationSet {
35 const activeView = plugin.app.workspace.getActiveViewOfType(MarkdownView);
36 const file = activeView?.file;
37
38 if (!file || !highlightService.shouldProcessFile(file)) {
39 return Decoration.none;
40 }
41
42 const decorations: Range<Decoration>[] = [];
43 const highlights = highlightService.extractHighlights(view.state.doc.toString(), file);
44
45 for (const highlight of highlights) {
46 if (highlight.position === undefined) continue;
47
48 const commentHighlight = highlightCommentResolver.normalizeHighlight(highlight);
49 commentHighlight.comments = highlightCommentResolver.getCommentsForHighlight(file, commentHighlight, {
50 onTextChanged: (storedHighlight, currentHighlight) => {
51 emitHighlightTextChange(plugin, file, storedHighlight, currentHighlight);
52 }
53 });
54
55 const highlightEndPos = highlight.position + (highlight.originalLength ?? highlight.text.length + 4);
56
57 if (shouldShowCommentWidget(plugin)) {
58 decorations.push(createCommentWidget(plugin, commentHighlight).range(highlightEndPos));
59 }
60 }
61
62 return Decoration.set(decorations.sort((a, b) => a.from - b.from));
63 }
64 }, {
65 decorations: value => value.decorations
66 });

Callers 2

constructorMethod · 0.80
updateMethod · 0.80

Calls 8

emitHighlightTextChangeFunction · 0.85
shouldShowCommentWidgetFunction · 0.85
createCommentWidgetFunction · 0.85
normalizeHighlightMethod · 0.80
setMethod · 0.80
shouldProcessFileMethod · 0.45
extractHighlightsMethod · 0.45

Tested by

no test coverage detected