Repository: mozilla/pdf.js
File: src/display/editor/tools.js (JavaScript)

Code before:
      signal,
    });
    eventBus._on("setpreference", this.onSetPreference.bind(this), { signal });
    eventBus._on(
      "switchannotationeditorparams",
      evt => this.updateParams(evt.type, evt.value),
      { signal }
    );
    this.#addSelectionListener();
    this.#addDragAndDropListeners();
    this.#addKeyboardManager();
    this.#annotationStorage = pdfDocument.annotationStorage;
    this.#filterFactory = pdfDocument.filterFactory;
    this.#pageColors = pageColors;
    this.#highlightColors = highlightColors || null;
    this.#enableHighlightFloatingButton = enableHighlightFloatingButton;
    this.#enableUpdatedAddImage = enableUpdatedAddImage;
    this.#enableNewAltTextWhenAddingImage = enableNewAltTextWhenAddingImage;
    this.#mlManager = mlManager || null;
    this.viewParameters = {
      realScale: PixelsPerInch.PDF_TO_CSS_UNITS,
      rotation: 0,
    };
    this.isShiftKeyDown = false;
    this._editorUndoBar = editorUndoBar || null;
    this._supportsPinchToZoom = supportsPinchToZoom || false;

    if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("TESTING")) {
      Object.defineProperty(this, "reset", {
        value: () => {
          this.selectAll();
          this.delete();
          this.#idManager.reset();
        },
      });
    }
  }

  destroy() {
    this.#updateModeCapability?.resolve();
    this.#updateModeCapability = null;

    this.#abortController?.abort();
    this.#abortController = null;
    this._signal = null;

    for (const layer of this.#allLayers.values()) {
      layer.destroy();
    }
    this.#allLayers.clear();
    this.#allEditors.clear();

Review comment (suggestion):
Everywhere through-out this patch the default value for this option should instead be `true` such that it's consistent with https://github.com/mozilla/pdf.js/blob/8fa439826632c5e7e2f3671673998a3a4791bea0/web/app_options.js#L129-L133

*Note:* The only reason for having that configurable at all is because it can be disabled via preferences in Firefox (manually in about:config).

Code after:
      signal,
    });
    eventBus._on("setpreference", this.onSetPreference.bind(this), { signal });
    eventBus._on(
      "switchannotationeditorparams",
      evt => this.updateParams(evt.type, evt.value),
      { signal }
    );
    this.#addSelectionListener();
    this.#addDragAndDropListeners();
    this.#addKeyboardManager();
    this.#annotationStorage = pdfDocument.annotationStorage;
    this.#filterFactory = pdfDocument.filterFactory;
    this.#pageColors = pageColors;
    this.#highlightColors = highlightColors || null;
    this.#enableHighlightFloatingButton = enableHighlightFloatingButton;
    this.#enableUpdatedAddImage = enableUpdatedAddImage;
    this.#enableNewAltTextWhenAddingImage = enableNewAltTextWhenAddingImage;
    this.#mlManager = mlManager || null;
    this.viewParameters = {
      realScale: PixelsPerInch.PDF_TO_CSS_UNITS,
      rotation: 0,
    };
    this.isShiftKeyDown = false;
    this._editorUndoBar = editorUndoBar || null;
    this._supportsPinchToZoom = supportsPinchToZoom !== false;

    if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("TESTING")) {
      Object.defineProperty(this, "reset", {
        value: () => {
          this.selectAll();
          this.delete();
          this.#idManager.reset();
        },
      });
    }
  }

  destroy() {
    this.#updateModeCapability?.resolve();
    this.#updateModeCapability = null;

    this.#abortController?.abort();
    this.#abortController = null;
    this._signal = null;

    for (const layer of this.#allLayers.values()) {
      layer.destroy();
    }
    this.#allLayers.clear();
    this.#allEditors.clear();