Remove the eventBus parameter from getViewerConfiguration

This structure contains *almost* exclusively references to DOM elements (and a couple of simple strings), rather than complete classes/functions. Hence the `eventBus`-option sticks out a fair bit, and I'd guess that it's *mostly* unused in e.g. third-party implementations.

Given that we, in multiple places, mention that the default viewer shouldn't be used as-is I really don't think that we need to keep this special `eventBus`-option around. Furthermore, nowadays it's also a lot easier to (safely) access the existing `EventBus`-instance in the viewer; see https://github.com/mozilla/pdf.js/wiki/Third-party-viewer-usage#initialization-promise which shows how to listen for the default viewer being initialized (and its `eventBus` thus being available).
This commit is contained in:
Jonas Jenwald 2022-01-06 12:09:57 +01:00
parent 290cbc5232
commit 08256e6795
2 changed files with 3 additions and 9 deletions

View File

@ -463,14 +463,9 @@ const PDFViewerApplication = {
async _initializeViewerComponents() {
const { appConfig, externalServices } = this;
let eventBus;
if (appConfig.eventBus) {
eventBus = appConfig.eventBus;
} else if (externalServices.isInAutomation) {
eventBus = new AutomationEventBus();
} else {
eventBus = new EventBus();
}
const eventBus = externalServices.isInAutomation
? new AutomationEventBus()
: new EventBus();
this.eventBus = eventBus;
this.overlayManager = new OverlayManager();

View File

@ -77,7 +77,6 @@ function getViewerConfiguration() {
appContainer: document.body,
mainContainer: document.getElementById("viewerContainer"),
viewerContainer: document.getElementById("viewer"),
eventBus: null,
toolbar: {
container: document.getElementById("toolbarViewer"),
numPages: document.getElementById("numPages"),