diff --git a/src/anchor/debug-textlayer.css b/src/anchor/debug-textlayer.css index 9c251e7..6c029f0 100644 --- a/src/anchor/debug-textlayer.css +++ b/src/anchor/debug-textlayer.css @@ -33,3 +33,27 @@ .ce-debug-textlayer canvas { opacity: 0.4; } + +/* + * Layer-visibility toggles. Each `.ce-hide-` class is applied + * to the same viewer-wrapper element so a single parent can hide any + * combination of layers. Useful for diagnosing layer stacking issues + * (e.g. "is the textLayer covering the canvas?") by elimination. + */ + +.ce-hide-canvas canvas { + display: none !important; +} + +.ce-hide-text-layer .textLayer { + display: none !important; +} + +.ce-hide-annotation-layer .annotationLayer, +.ce-hide-annotation-layer .annotationEditorLayer { + display: none !important; +} + +.ce-hide-xfa-layer .xfaLayer { + display: none !important; +} diff --git a/src/anchor/pdf-viewer-adapter-spike.tsx b/src/anchor/pdf-viewer-adapter-spike.tsx index b2c501d..2b4f5df 100644 --- a/src/anchor/pdf-viewer-adapter-spike.tsx +++ b/src/anchor/pdf-viewer-adapter-spike.tsx @@ -199,6 +199,15 @@ export interface PdfSpikeViewerProps { * image-only. Also logs every onSelection event to the console. */ readonly debugTextLayer?: boolean; + /** + * Hide specific PDF.js layers so you can see what sits underneath. + * Helps diagnose layer-stacking issues (e.g. "is the text layer + * covering the canvas content?"). + */ + readonly hideCanvas?: boolean; + readonly hideTextLayer?: boolean; + readonly hideAnnotationLayer?: boolean; + readonly hideXfaLayer?: boolean; } export interface StoredAnnotation { @@ -222,11 +231,24 @@ export function PdfSpikeViewer(props: PdfSpikeViewerProps) { activeAnnotationId, onHighlightClicked, debugTextLayer, + hideCanvas, + hideTextLayer, + hideAnnotationLayer, + hideXfaLayer, } = props; const HighlightContainer = useMemo( () => makeSpikeHighlightContainer({ activeAnnotationId, onHighlightClicked }), [activeAnnotationId, onHighlightClicked], ); + const wrapperClasses = [ + debugTextLayer ? "ce-debug-textlayer" : null, + hideCanvas ? "ce-hide-canvas" : null, + hideTextLayer ? "ce-hide-text-layer" : null, + hideAnnotationLayer ? "ce-hide-annotation-layer" : null, + hideXfaLayer ? "ce-hide-xfa-layer" : null, + ] + .filter((c): c is string => c !== null) + .join(" "); const utilsRef = useRef(null); const [didScroll, setDidScroll] = useState(null); @@ -273,7 +295,7 @@ export function PdfSpikeViewer(props: PdfSpikeViewerProps) { return (
0 ? wrapperClasses : undefined} style={{ height: "100%" }} > diff --git a/src/app/sessions/SessionMenu.tsx b/src/app/sessions/SessionMenu.tsx index e7ee672..c4ffb55 100644 --- a/src/app/sessions/SessionMenu.tsx +++ b/src/app/sessions/SessionMenu.tsx @@ -36,6 +36,10 @@ export function SessionMenu({ onExportZip, onImportZip, onOpenSamples }: Session const tick = useSessionListTick(); const active = useActiveSession(); const [debugTextLayer, setDebugTextLayer] = useDebugFlag("textLayer"); + const [hideCanvas, setHideCanvas] = useDebugFlag("hideCanvas"); + const [hideTextLayer, setHideTextLayer] = useDebugFlag("hideTextLayer"); + const [hideAnnotationLayer, setHideAnnotationLayer] = useDebugFlag("hideAnnotationLayer"); + const [hideXfaLayer, setHideXfaLayer] = useDebugFlag("hideXfaLayer"); const [open, setOpen] = useState(false); const [newName, setNewName] = useState(""); @@ -407,25 +411,52 @@ export function SessionMenu({ onExportZip, onImportZip, onOpenSamples }: Session )}
- + PDF diagnostics +
+ + + + +