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

Function convertToOptimizedHighlight

src/storage/HighlightDataFormat.ts:78–129  ·  view source on GitHub ↗
(highlight: HiNote)

Source from the content-addressed store, hash-verified

76 * 转换为优化格式
77 */
78export function convertToOptimizedHighlight(highlight: HiNote): OptimizedHighlight {
79 const now = Date.now();
80 const optimized: OptimizedHighlight = {
81 text: highlight.text,
82 position: highlight.position,
83 created: highlight.createdAt ?? now,
84 updated: highlight.updatedAt ?? now
85 };
86
87 if (highlight.backgroundColor) {
88 optimized.backgroundColor = highlight.backgroundColor;
89 }
90
91 if (highlight.blockId) {
92 optimized.blockId = highlight.blockId;
93 }
94
95 if (highlight.isCloze) {
96 optimized.isCloze = highlight.isCloze;
97 }
98
99 if (highlight.isVirtual) {
100 optimized.isVirtual = highlight.isVirtual;
101 }
102
103 if (highlight.paragraphOffset !== undefined) {
104 optimized.paragraphOffset = highlight.paragraphOffset;
105 }
106
107 if (highlight.contextBefore) {
108 optimized.contextBefore = highlight.contextBefore;
109 }
110
111 if (highlight.contextAfter) {
112 optimized.contextAfter = highlight.contextAfter;
113 }
114
115 if (highlight.textFingerprint) {
116 optimized.textFingerprint = highlight.textFingerprint;
117 }
118
119 if (highlight.comments && highlight.comments.length > 0) {
120 optimized.comments = highlight.comments.map((comment: CommentItem) => ({
121 id: comment.id,
122 content: comment.content,
123 created: comment.createdAt,
124 updated: comment.updatedAt
125 }));
126 }
127
128 return optimized;
129}

Callers 1

saveFileHighlightsMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected