Skip to content

Commit f65ac3b

Browse files
committed
fix: resolve lint issues
1 parent 2a7ffea commit f65ac3b

1 file changed

Lines changed: 46 additions & 22 deletions

File tree

src/display/editor/tools.js

Lines changed: 46 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2564,21 +2564,29 @@ class AnnotationEditorUIManager {
25642564
const drawingEditor = this.currentLayer?.endDrawingSession(
25652565
/* isAborted = */ true
25662566
);
2567-
if (!this.hasSelection && !drawingEditor && !(this.#selectedUnrenderedAnnotationIds?.size > 0)) {
2567+
if (
2568+
!this.hasSelection &&
2569+
!drawingEditor &&
2570+
!(this.#selectedUnrenderedAnnotationIds?.size > 0)
2571+
) {
25682572
return;
25692573
}
25702574

25712575
const editors = drawingEditor
25722576
? [drawingEditor]
25732577
: [...this.#selectedEditors];
2574-
2578+
25752579
// Capture unrendered annotation IDs that were selected via Ctrl+A
2576-
const unrenderedIds = this.#selectedUnrenderedAnnotationIds ? Array.from(this.#selectedUnrenderedAnnotationIds) : [];
2580+
const unrenderedIds = this.#selectedUnrenderedAnnotationIds
2581+
? Array.from(this.#selectedUnrenderedAnnotationIds)
2582+
: [];
25772583

25782584
const cmd = () => {
25792585
this._editorUndoBar?.show(
25802586
undo,
2581-
editors.length === 1 ? editors[0].editorType : (editors.length + unrenderedIds.length)
2587+
editors.length === 1
2588+
? editors[0].editorType
2589+
: editors.length + unrenderedIds.length
25822590
);
25832591
for (const editor of editors) {
25842592
editor.remove();
@@ -2627,41 +2635,57 @@ class AnnotationEditorUIManager {
26272635
this.#selectedEditors.add(editor);
26282636
editor.select();
26292637
}
2630-
this.#dispatchUpdateStates({ hasSelectedEditor: this.hasSelection || (this.#selectedUnrenderedAnnotationIds?.size > 0) });
2638+
this.#dispatchUpdateStates({
2639+
hasSelectedEditor:
2640+
this.hasSelection || this.#selectedUnrenderedAnnotationIds?.size > 0,
2641+
});
26312642
}
26322643

26332644
/**
26342645
* Select all the editors.
26352646
*/
26362647
async selectAll() {
2637-
const pdfDocument = typeof window !== "undefined" ? window.PDFViewerApplication?.pdfDocument : null;
2648+
const pdfDocument =
2649+
typeof window !== "undefined"
2650+
? window.PDFViewerApplication?.pdfDocument
2651+
: null;
26382652

26392653
if (pdfDocument) {
26402654
this.#selectedUnrenderedAnnotationIds = new Set();
26412655
const totalPages = pdfDocument.numPages;
26422656
for (let i = 1; i <= totalPages; i++) {
26432657
try {
26442658
const pdfPage = await pdfDocument.getPage(i);
2645-
const annotations = await pdfPage.getAnnotations({ intent: "display" });
2646-
2659+
const annotations = await pdfPage.getAnnotations({
2660+
intent: "display",
2661+
});
2662+
26472663
if (annotations && annotations.length > 0) {
26482664
for (const ann of annotations) {
2649-
// We only care about editable annotations (like Highlights/Ink/Text)
2650-
// Check if the annotation corresponds to an editor we ALREADY have loaded
2651-
let hasMatch = false;
2652-
for (const editor of this.#allEditors.values()) {
2653-
if (editor.annotationElementId === ann.id) {
2654-
hasMatch = true;
2655-
break;
2656-
}
2657-
}
2658-
// If it's an unrendered annotation, cache its ID so we can mass-delete it.
2659-
if (!hasMatch && (ann.isEditable || ann.annotationType === 8 || ann.annotationType === 3)) {
2660-
this.#selectedUnrenderedAnnotationIds.add(ann.id);
2661-
}
2665+
// We only care about editable annotations (like
2666+
// Highlights/Ink/Text)
2667+
// Check if the annotation corresponds to an editor we ALREADY
2668+
// have loaded
2669+
let hasMatch = false;
2670+
for (const editor of this.#allEditors.values()) {
2671+
if (editor.annotationElementId === ann.id) {
2672+
hasMatch = true;
2673+
break;
2674+
}
2675+
}
2676+
// If it's an unrendered annotation, cache its ID so we can
2677+
// mass-delete it.
2678+
if (
2679+
!hasMatch &&
2680+
(ann.isEditable ||
2681+
ann.annotationType === 8 ||
2682+
ann.annotationType === 3)
2683+
) {
2684+
this.#selectedUnrenderedAnnotationIds.add(ann.id);
2685+
}
26622686
}
26632687
}
2664-
} catch (ex) {
2688+
} catch {
26652689
// ignore error fetching metadata
26662690
}
26672691
}

0 commit comments

Comments
 (0)