Skip to content

Commit

Permalink
EPUB/Snapshot: Make resize undoable
Browse files Browse the repository at this point in the history
Create an updated annotation object instead of mutating.
  • Loading branch information
AbeJellinek committed Jan 13, 2025
1 parent 1f135cf commit eae2b46
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/dom/common/dom-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1033,10 +1033,14 @@ abstract class DOMView<State extends DOMViewState, Data> {
if (!updatedAnnotation) {
throw new Error('Invalid resized range');
}
annotation.position = updatedAnnotation.position;
annotation.pageLabel = updatedAnnotation.pageLabel;
annotation.sortIndex = updatedAnnotation.sortIndex;
annotation.text = updatedAnnotation.text;

annotation = {
...annotation,
position: updatedAnnotation.position,
pageLabel: updatedAnnotation.pageLabel,
sortIndex: updatedAnnotation.sortIndex,
text: updatedAnnotation.text,
};
this._options.onUpdateAnnotations([annotation]);

// If the resize ends over a link, that somehow counts as a click in Fx
Expand Down

0 comments on commit eae2b46

Please sign in to comment.