From d906496a861213e991e251c5449a8eb3e099736a Mon Sep 17 00:00:00 2001 From: Hongbo Wu Date: Fri, 3 Nov 2023 18:45:23 +0800 Subject: [PATCH] feat: expose positionPercent and positionAnchorIndex variables in highlight template (#150) --- src/api.ts | 4 +++- src/settings/template.ts | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/api.ts b/src/api.ts index 8ad032b..4ba915b 100644 --- a/src/api.ts +++ b/src/api.ts @@ -75,8 +75,9 @@ export interface Highlight { updatedAt: string; labels?: Label[]; type: HighlightType; - highlightPositionPercent?: number; + highlightPositionPercent: number; color?: string; + highlightPositionAnchorIndex: number; } const requestHeaders = (apiKey: string) => ({ @@ -132,6 +133,7 @@ export const loadArticles = async ( updatedAt type highlightPositionPercent + highlightPositionAnchorIndex labels { name } diff --git a/src/settings/template.ts b/src/settings/template.ts index e80b1c3..99ed2b7 100644 --- a/src/settings/template.ts +++ b/src/settings/template.ts @@ -49,6 +49,9 @@ export interface HighlightView { dateHighlighted: string; note?: string; labels?: LabelView[]; + color: string; + positionPercent: number; + positionAnchorIndex: number; } export type ArticleView = @@ -190,6 +193,8 @@ export const renderArticleContnet = async ( note: highlight.annotation ?? undefined, labels: renderLabels(highlight.labels), color: highlight.color ?? 'yellow', + positionPercent: highlight.highlightPositionPercent, + positionAnchorIndex: highlight.highlightPositionAnchorIndex, }; }); const dateSaved = formatDate(article.savedAt, dateSavedFormat);