Fix v0.4 reader workflow issues

This commit is contained in:
Akshay Kolli
2026-06-30 10:36:12 -07:00
parent 9bdc1a4b09
commit c62f0bf9c7
9 changed files with 568 additions and 91 deletions

View File

@@ -6,7 +6,7 @@ import SwiftUI
final class AcademicPDFView: PDFView {
var onAnnotationClick: ((PDFAnnotation, PDFPage) -> Void)?
var onPlacementClick: ((PDFPage, CGPoint) -> Void)?
var onCancelPlacement: (() -> Void)?
var onCancelActiveMode: (() -> Void)?
var onSelectionComment: (() -> Void)?
var onHighlighterSelection: (() -> Void)?
var onToggleHighlighterKey: (() -> Void)?
@@ -14,6 +14,7 @@ final class AcademicPDFView: PDFView {
var onCommentSelectionKey: (() -> Void)?
var onPreviousPageKey: (() -> Void)?
var onNextPageKey: (() -> Void)?
var onDeleteSelectedAnnotationKey: (() -> Void)?
var placementTool: AnnotationPlacementTool? {
didSet {
guard oldValue != placementTool else { return }
@@ -118,8 +119,14 @@ final class AcademicPDFView: PDFView {
}
override func keyDown(with event: NSEvent) {
if event.keyCode == 53, placementTool != nil {
onCancelPlacement?()
if event.keyCode == 53, placementTool != nil || isHighlighterModeActive {
onCancelActiveMode?()
return
}
if [51, 117].contains(event.keyCode),
event.modifierFlags.intersection([.command, .control, .option, .shift]).isEmpty {
onDeleteSelectedAnnotationKey?()
return
}
@@ -506,9 +513,9 @@ struct PDFKitRepresentedView: NSViewRepresentable {
appState.placePendingAnnotation(on: page, near: point)
}
}
view.onCancelPlacement = {
view.onCancelActiveMode = {
Task { @MainActor in
appState.cancelPlacementTool()
appState.cancelActiveMode()
}
}
view.onSelectionComment = {
@@ -546,6 +553,11 @@ struct PDFKitRepresentedView: NSViewRepresentable {
appState.goToNextPage()
}
}
view.onDeleteSelectedAnnotationKey = {
Task { @MainActor in
appState.deleteSelectedAnnotation()
}
}
appState.attachPDFView(view)
return view
}