In pdf.js, annotationEditor.addComment() has a hasEditedComment check. Comments that were deserialized from a copy don't pass this because initialText === text.
Because of that, comments are lost in the following scenario:
- User makes a highlight and adds a comment on it
- Annotations are serialized using
pdfViewerService.getSerializedAnnotations() and saved to external storage.
- User reloads the document
- Annotations are fetched from the external storage and loaded using
pdfViewerService.addEditorAnnotation()
- User annotates something else and doesn't touch the comment
- Annotations are saved
- User reloads document
- Annotations are fetched and loaded
I already have a fix and I'll make a PR in the pdf.js fork. I'm just creating this issue to have something to reference in the commit messages and code comments.