Repository: mozilla/pdf.js
File: web/pdf_viewer.js (JavaScript)

Code before:
    editId = null,
    isFromKeyboard = false,
    mustEnterInEditMode = false,
    editComment = false,
  }) {
    if (!this.#annotationEditorUIManager) {
      throw new Error(`The AnnotationEditor is not enabled.`);
    }
    if (this.#annotationEditorMode === mode) {
      return; // The AnnotationEditor mode didn't change.
    }
    if (!isValidAnnotationEditorMode(mode)) {
      throw new Error(`Invalid AnnotationEditor mode: ${mode}`);
    }
    if (!this.pdfDocument) {
      return;
    }
    this.#preloadEditingData(mode);

    const { eventBus, pdfDocument } = this;
    const updater = async () => {
      this.#cleanupSwitchAnnotationEditorMode();
      this.#annotationEditorMode = mode;
      await this.#annotationEditorUIManager.updateMode(
        mode,
        true,
        editId,
        isFromKeyboard,
        mustEnterInEditMode,
        editComment
      );
      if (
        mode !== this.#annotationEditorMode ||
        pdfDocument !== this.pdfDocument
      ) {
        // Since `updateMode` is async, the active mode could have changed.
        return;
      }
      eventBus.dispatch("annotationeditormodechanged", {
        source: this,
        mode,
      });
    };

    if (
      mode === AnnotationEditorType.NONE ||
      this.#annotationEditorMode === AnnotationEditorType.NONE
    ) {
      const isEditing = mode !== AnnotationEditorType.NONE;
      if (!isEditing) {
        this.pdfDocument.annotationStorage.resetModifiedIds();

Review comment (suggestion):
To make it a bit more clear what `true` represents here, given that there is no variable like `isFromKeyboard` that immediately makes the intention clear, we usually add an inline comment like this:

```
await this.#annotationEditorUIManager.updateMode(
  mode,
  editId,
  /* isFromUser = */ true,
  isFromKeyboard,
  ...
);
```

(also here with `editId` before the optional parameters)

Code after:
    editId = null,
    isFromKeyboard = false,
    mustEnterInEditMode = false,
    editComment = false,
  }) {
    if (!this.#annotationEditorUIManager) {
      throw new Error(`The AnnotationEditor is not enabled.`);
    }
    if (this.#annotationEditorMode === mode) {
      return; // The AnnotationEditor mode didn't change.
    }
    if (!isValidAnnotationEditorMode(mode)) {
      throw new Error(`Invalid AnnotationEditor mode: ${mode}`);
    }
    if (!this.pdfDocument) {
      return;
    }
    this.#preloadEditingData(mode);

    const { eventBus, pdfDocument } = this;
    const updater = async () => {
      this.#cleanupSwitchAnnotationEditorMode();
      this.#annotationEditorMode = mode;
      await this.#annotationEditorUIManager.updateMode(
        mode,
        editId,
        /* isFromUser = */ true,
        isFromKeyboard,
        mustEnterInEditMode,
        editComment
      );
      if (
        mode !== this.#annotationEditorMode ||
        pdfDocument !== this.pdfDocument
      ) {
        // Since `updateMode` is async, the active mode could have changed.
        return;
      }
      eventBus.dispatch("annotationeditormodechanged", {
        source: this,
        mode,
      });
    };

    if (
      mode === AnnotationEditorType.NONE ||
      this.#annotationEditorMode === AnnotationEditorType.NONE
    ) {
      const isEditing = mode !== AnnotationEditorType.NONE;
      if (!isEditing) {
        this.pdfDocument.annotationStorage.resetModifiedIds();