From d8aa36f1485dd017f1e6430bcdfd98ce432a79d7 Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Thu, 2 Feb 2023 15:19:58 +0800 Subject: [PATCH] Start passing in position info when creating highlights on PDFs --- .../Sources/App/PDFSupport/PDFViewer.swift | 8 +++++++- .../App/PDFSupport/PDFViewerViewModel.swift | 16 +++++++++------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/apple/OmnivoreKit/Sources/App/PDFSupport/PDFViewer.swift b/apple/OmnivoreKit/Sources/App/PDFSupport/PDFViewer.swift index d64b600fc..dc1091f7b 100644 --- a/apple/OmnivoreKit/Sources/App/PDFSupport/PDFViewer.swift +++ b/apple/OmnivoreKit/Sources/App/PDFSupport/PDFViewer.swift @@ -296,7 +296,10 @@ import Utils shortId: shortId, highlightID: highlightID, quote: quote, - patch: patch + patch: patch, + // TODO + positionPercent: nil, + positionAnchorIndex: Int(pageView.pageIndex) ) } else { let overlappingRects = overlapping.map(\.rects).compactMap { $0 }.flatMap { $0 } @@ -317,6 +320,9 @@ import Utils highlightID: highlightID, quote: quote, patch: patch, + // TODO: + positionPercent: nil, + positionAnchorIndex: Int(pageView.pageIndex), overlapHighlightIdList: highlightIds(overlapping) ) } diff --git a/apple/OmnivoreKit/Sources/App/PDFSupport/PDFViewerViewModel.swift b/apple/OmnivoreKit/Sources/App/PDFSupport/PDFViewerViewModel.swift index 89b4dd7a2..4b443aaed 100644 --- a/apple/OmnivoreKit/Sources/App/PDFSupport/PDFViewerViewModel.swift +++ b/apple/OmnivoreKit/Sources/App/PDFSupport/PDFViewerViewModel.swift @@ -22,7 +22,9 @@ final class PDFViewerViewModel: ObservableObject { shortId: String, highlightID: String, quote: String, - patch: String + patch: String, + positionPercent: Double?, + positionAnchorIndex: Int? ) { _ = dataService.createHighlight( shortId: shortId, @@ -30,9 +32,8 @@ final class PDFViewerViewModel: ObservableObject { quote: quote, patch: patch, articleId: pdfItem.itemID, - // TODO: - positionPercent: nil, - positionAnchorIndex: nil + positionPercent: positionPercent, + positionAnchorIndex: positionAnchorIndex ) } @@ -43,6 +44,8 @@ final class PDFViewerViewModel: ObservableObject { highlightID: String, quote: String, patch: String, + positionPercent: Double?, + positionAnchorIndex: Int?, overlapHighlightIdList: [String] ) { _ = dataService.mergeHighlights( @@ -51,9 +54,8 @@ final class PDFViewerViewModel: ObservableObject { quote: quote, patch: patch, articleId: pdfItem.itemID, - // TODO: - positionPercent: nil, - positionAnchorIndex: nil, + positionPercent: positionPercent, + positionAnchorIndex: positionAnchorIndex, overlapHighlightIdList: overlapHighlightIdList ) }