, the "onDeleteAnnotations" function may help.
onDeleteAnnotations: async (ids) => {
let keys = ids;
let attachment = this._item;
let libraryID = attachment.libraryID;
let notifierQueue = new Zotero.Notifier.Queue();
try {
for (let key of keys) {
let annotation = Zotero.Items.getByLibraryAndKey(libraryID, key);
// Make sure the annotation actually belongs to the current PDF
if (annotation && annotation.isAnnotation() && annotation.parentID === this._
item.id) {
this.annotationItemIDs = this.annotationItemIDs.filter(id => id !==
annotation.id);
await annotation.eraseTx({ notifierQueue });
}
}
}
catch (e) {
this.displayError(e);
throw e;
}
finally {
await Zotero.Notifier.commit(notifierQueue);
}
},