Skip to content

Commit

Permalink
Fix customTextRenderer not called on items outside of marked content (#…
Browse files Browse the repository at this point in the history
…1623)

Closes #1593
  • Loading branch information
wojtekmaj authored Oct 5, 2023
1 parent 178317f commit b862a52
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/react-pdf/src/Page/TextLayer.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function renderWithContext(children: React.ReactNode, context: Partial<PageConte
function getTextItems(container: HTMLElement) {
const wrapper = container.firstElementChild as HTMLDivElement;

return wrapper.querySelectorAll('.markedContent > *:not(.markedContent');
return wrapper.querySelectorAll('[role="presentation"]');
}

describe('TextLayer', () => {
Expand Down
6 changes: 1 addition & 5 deletions packages/react-pdf/src/Page/TextLayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,7 @@ export default function TextLayer() {
layer.append(end);
endElement.current = end;

const hasMarkedContent = Boolean(layer.querySelector('.markedContent'));

const layerChildren = hasMarkedContent
? layer.querySelectorAll('.markedContent > *:not(.markedContent')
: layer.children;
const layerChildren = layer.querySelectorAll('[role="presentation"]');

if (customTextRenderer) {
let index = 0;
Expand Down

0 comments on commit b862a52

Please sign in to comment.