mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 13:49:40 +08:00
A PDF page is one bitmap by the time it reaches the DOM, so a picture inside it has no element to click and no way to be read at its own size. A thumbnail in a 600-page scan could not be opened at all. The operator list still knows where each picture was placed: `paintImageXObject` draws the unit square through the current transformation matrix, so replaying save/restore/transform/form-object pairing recovers the rectangle each picture covers. Those rectangles become hotspots; clicking one opens the picture whole in a preview with pan and zoom. Four things that only show up once this meets real documents: - **Hotspots sit UNDER the text layer, not over it.** They were DOM siblings after the text layer, so they stacked above it — and on an OCR scan, where one image covers the whole page, a single button sat over every word: selection, highlighting and clicking an existing annotation all stopped responding. A box covering most of the page is dropped in the geometry layer (it is the page bitmap, not a picture in it), the hotspots render before the text layer, and the mouseup guard that swallowed a selection ending on a picture is gone. - **Only the active page is measured.** `getOperatorList` runs its own rendering intent, cached separately from the display one, so measuring the whole retained window parsed and decoded thirteen pages of images twice — full-resolution bitmaps kept on the main thread, past the canvas budget the visible ones obey. - **Pictures inside annotation streams are skipped.** A stamp or signature is painted into the annotation's own canvas after the renderer resets the transform, so replaying its matrix as page space put the hotspot near the page origin, over whatever happened to be there. - **The preview is a real modal.** It declared itself one but never took focus, so ⌘+/− acted on the page behind it and closing dropped focus on `<body>`. It focuses itself on open, restores the previous element on close, and stops Escape from also reaching the Guided Learning handler — both listeners sit on `window`, so `preventDefault` was never going to work. The stage no longer swallows every click either: a click on the empty area closes the overlay, a click on the picture does not. The preview also sizes the canvas from the picture's box rather than its width alone: a scanned page — one full-page hotspot — opened at 2.7x showing its middle third, with zoom clamped at 1 and no way out.