Skip to content

Commit

Permalink
EPUB/Snapshot: Open popup after adding note
Browse files Browse the repository at this point in the history
  • Loading branch information
AbeJellinek committed Aug 22, 2024
1 parent 930e639 commit c2ffd30
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/dom/common/dom-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,20 @@ abstract class DOMView<State extends DOMViewState, Data> {
}
}

protected _openAnnotationPopup(annotation: WADMAnnotation) {
protected _openAnnotationPopup(annotation?: WADMAnnotation) {
if (!annotation) {
if (this._selectedAnnotationIDs.length != 1) {
console.log('No selected annotation to open popup for');
return;
}
annotation = this._annotationsByID.get(this._selectedAnnotationIDs[0]);
if (!annotation) {
// Shouldn't happen
console.log('Selected annotation not found');
return;
}
}

// Note: Popup won't be visible if sidebar is opened
let domRect;
if (annotation.type == 'note') {
Expand Down Expand Up @@ -1049,7 +1062,9 @@ abstract class DOMView<State extends DOMViewState, Data> {
// The note tool will be automatically deactivated in reader.js,
// because this is what we do in PDF reader
if (event.button == 0 && this._tool.type == 'note' && this._previewAnnotation) {
this._options.onAddAnnotation(this._previewAnnotation, true);
this._options.onAddAnnotation(this._previewAnnotation!, true);
this._renderAnnotations(true);
this._openAnnotationPopup();
event.preventDefault();

// preventDefault() doesn't stop pointerup/click from firing, so our link handler will still fire
Expand Down

0 comments on commit c2ffd30

Please sign in to comment.