Skip to content

Commit

Permalink
Replace customTextRenderer in test suite and documentation
Browse files Browse the repository at this point in the history
Related to #1151
  • Loading branch information
wojtekmaj committed Nov 9, 2022
1 parent 69d0c3e commit 5cdd8a0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -405,7 +405,7 @@ Displays a page. Should be placed inside `<Document />`. Alternatively, it can h
| canvasBackground | Canvas background color. Any valid `canvas.fillStyle` can be used. If you set `renderMode` to `"svg"` this prop will be ignored. | n/a | `"transparent"` |
| canvasRef | A prop that behaves like [ref](https://reactjs.org/docs/refs-and-the-dom.html), but it's passed to `<canvas>` rendered by `<PageCanvas>` component. If you set `renderMode` to `"svg"` this prop will be ignored. | n/a | <ul><li>Function:<br />`(ref) => { this.myPage = ref; }`</li><li>Ref created using `React.createRef`:<br />`this.ref = React.createRef();`<br />…<br />`inputRef={this.ref}`</li><li>Ref created using `React.useRef`:<br />`const ref = React.useRef();`<br />…<br />`inputRef={ref}`</li></ul> |
| className | Class name(s) that will be added to rendered element along with the default `react-pdf__Page`. | n/a | <ul><li>String:<br />`"custom-class-name-1 custom-class-name-2"`</li><li>Array of strings:<br />`["custom-class-name-1", "custom-class-name-2"]`</li></ul> |
| customTextRenderer | Function that customizes how a text layer is rendered. | n/a | `` ({ str, itemIndex }) => { return `<mark>${str}</mark>` } `` |
| customTextRenderer | Function that customizes how a text layer is rendered. | n/a | `` ({ str, itemIndex }) => str && str.replace(/ipsum/g, `<mark>ipsum</mark>`) `` |
| error | What the component should display in case of an error. | `"Failed to load the page."` | <ul><li>String:<br />`"An error occurred!"`</li><li>React element:<br />`<div>An error occurred!</div>`</li><li>Function:<br />`this.renderError`</li></ul> |
| height | Page height. If neither `height` nor `width` are defined, page will be rendered at the size defined in PDF. If you define `width` and `height` at the same time, `height` will be ignored. If you define `height` and `scale` at the same time, the height will be multiplied by a given factor. | Page's default height | `300` |
| imageResourcesPath | The path used to prefix the src attributes of annotation SVGs. | n/a (pdf.js will fallback to an empty string) | `"/public/images/"` |
Expand Down
12 changes: 1 addition & 11 deletions test/Test.jsx
Expand Up @@ -183,17 +183,7 @@ export default function Test() {
renderTextLayer,
scale: pageScale,
width: pageWidth,
customTextRenderer: (textItem) =>
textItem.str
.split('ipsum')
.reduce(
(strArray, currentValue, currentIndex) =>
currentIndex === 0
? [...strArray, currentValue]
: [...strArray, '<mark>ipsum</mark>', currentValue],
[],
)
.join(''),
customTextRenderer: ({ str }) => str && str.replace(/ipsum/g, `<mark>ipsum</mark>`),
};
}

Expand Down

0 comments on commit 5cdd8a0

Please sign in to comment.