diff --git a/src/FormInputValues.ts b/src/FormInputValues.ts index 3d0d347..6da7a2b 100644 --- a/src/FormInputValues.ts +++ b/src/FormInputValues.ts @@ -6,4 +6,14 @@ export class FormInputValues { public readonly optionNameToSelectedIndex: Map = new Map(); public readonly radioGroupNameToSelectedIndex: Map = new Map(); + + public isEmpty(): boolean { + return ( + this.textNameToValue.size == 0 && + this.checkboxNameToValue.size == 0 && + this.dropdownNameToSelectedIndex.size == 0 && + this.optionNameToSelectedIndex.size == 0 && + this.radioGroupNameToSelectedIndex.size == 0 + ); + } } diff --git a/src/Main.ts b/src/Main.ts index 53cf11f..5920eed 100644 --- a/src/Main.ts +++ b/src/Main.ts @@ -165,8 +165,9 @@ function onPageLoad() { view.setOnPdfFileChosenListener( function () { const overlays: Overlays = extractOverlays(); + const formValues = view.extractFormInputValues(); return ( - overlays.pagesOverlays.size == 0 || + (overlays.pagesOverlays.size == 0 && formValues.isEmpty()) || confirm( "If you load another PDF, all changes in the current PDF will be lost. Are you sure?" )