Repository navigation
is it possible to highlight the whole url when mouse move into #2038
Unanswered
jiangxiaoqiang
asked this question in
Q&A
Replies: 1 comment
|
This usually happens when the PDF stores the wrapped URL as two link annotations, one per line. react-pdf renders each one as its own function Viewer({ file }) {
const ref = useRef(null);
function onMouseOver(e) {
const link = e.target.closest('.linkAnnotation > a');
if (!link) return;
ref.current
.querySelectorAll('.linkAnnotation > a')
.forEach((a) => a.classList.toggle('hovered', a.href === link.href));
}
function onMouseOut() {
ref.current
.querySelectorAll('.linkAnnotation > a.hovered')
.forEach((a) => a.classList.remove('hovered'));
}
return (
<div ref={ref} onMouseOver={onMouseOver} onMouseOut={onMouseOut}>
<Document file={file}>
<Page pageNumber={1} />
</Document>
</div>
);
}.annotationLayer .linkAnnotation > a.hovered {
opacity: 0.2;
background: rgba(255, 255, 0, 1);
box-shadow: 0 2px 10px rgba(255, 255, 0, 1);
}The CSS is just react-pdf's own |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
when I move the mouse over the url in pdf, the triggered hightlight only contains one single line of the url:
but the whole url was multiline, is it possible to hightlight the whole multiline url when mouse moved into?
All reactions