mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Attempt to simplify the fileattachmentannotation
event dispatching
This attempts to reduced the level of indirection, and the amount of code, when dispatching `fileattachmentannotation` events, by removing the `PDFLinkService.onFileAttachmentAnnotation` method and just accessing `PDFLinkService.eventBus` directly in the `FileAttachmentAnnotationElement` constructor. Given that other properties, such as `externalLinkTarget`/`externalLinkRel`, are already being accessed directly this pattern seems fine here as well.
This commit is contained in:
parent
ec10cae5b6
commit
d60ce998f1
3 changed files with 11 additions and 30 deletions
|
@ -1130,15 +1130,18 @@ class FileAttachmentAnnotationElement extends AnnotationElement {
|
|||
constructor(parameters) {
|
||||
super(parameters, /* isRenderable = */ true);
|
||||
|
||||
let file = this.data.file;
|
||||
this.filename = getFilenameFromUrl(file.filename);
|
||||
this.content = file.content;
|
||||
const { filename, content, } = this.data.file;
|
||||
this.filename = getFilenameFromUrl(filename);
|
||||
this.content = content;
|
||||
|
||||
this.linkService.onFileAttachmentAnnotation({
|
||||
id: stringToPDFString(file.filename),
|
||||
filename: file.filename,
|
||||
content: file.content,
|
||||
});
|
||||
if (this.linkService.eventBus) {
|
||||
this.linkService.eventBus.dispatch('fileattachmentannotation', {
|
||||
source: this,
|
||||
id: stringToPDFString(filename),
|
||||
filename,
|
||||
content,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue