EANCH-WP-0004: HtmlViewer scroll parity and viewer-shell workplan
All checks were successful
CI Smoke / host-smoke (push) Successful in 0s
CI Smoke / container-smoke (push) Successful in 2s

Export HtmlViewerAdapter from package root, add scrollRequestKey parity,
register finished workplan, update SCOPE.
This commit is contained in:
tegwick 2026-07-09 09:58:41 +02:00
parent 49d9810c93
commit bbeba96173
4 changed files with 119 additions and 5 deletions

View file

@ -32,6 +32,11 @@ export interface HtmlViewerAdapterProps {
readonly representation: DocumentRepresentation;
readonly storedAnnotations?: readonly StoredHtmlAnnotation[];
readonly scrollToAnnotationId?: string;
/**
* Bumps when the same annotation should be re-scrolled (e.g. repeat click).
* Format is opaque typically `${annotationId}:${version}`.
*/
readonly scrollRequestKey?: string;
readonly activeAnnotationId?: string | null;
readonly debug?: HtmlViewerDebugOptions;
onSelectionCaptured?(capture: DomSelectionCapture, selectors: Selector[]): void;
@ -50,6 +55,7 @@ export function HtmlViewerAdapter(props: HtmlViewerAdapterProps): ReactNode {
representation,
storedAnnotations = [],
scrollToAnnotationId,
scrollRequestKey,
activeAnnotationId,
debug,
onSelectionCaptured,
@ -91,12 +97,13 @@ export function HtmlViewerAdapter(props: HtmlViewerAdapterProps): ReactNode {
}, [html, storedAnnotations, representation, activeAnnotationId]);
useEffect(() => {
if (!scrollToAnnotationId || !rootRef.current) return;
const requestKey = scrollRequestKey ?? scrollToAnnotationId ?? null;
if (!requestKey || !scrollToAnnotationId || !rootRef.current) return;
const mark = rootRef.current.querySelector(
`[data-highlight-id="${CSS.escape(scrollToAnnotationId)}"]`,
);
mark?.scrollIntoView({ block: "center", behavior: "smooth" });
}, [scrollToAnnotationId, renderedHtml]);
}, [scrollToAnnotationId, scrollRequestKey, renderedHtml]);
return (
<div

View file

@ -20,6 +20,20 @@ export {
type CreateSelectorsOptions,
} from "./selectors";
// DOM adapter (re-exported from the src/dom/ boundary).
export {
HtmlViewerAdapter,
resolveHtmlSelectors,
scrollToHtmlTarget,
renderHtmlHighlight,
captureFromRange,
domPathToNode,
nodeAtPath,
type HtmlViewerAdapterProps,
type HtmlViewerDebugOptions,
type StoredHtmlAnnotation,
} from "./dom";
// PDF adapter + helpers (re-exported from the src/pdf/ boundary).
export {
PdfViewerAdapter,