diff --git a/src/Page.jsx b/src/Page.jsx index 56d4af3a6..4ad78fe83 100644 --- a/src/Page.jsx +++ b/src/Page.jsx @@ -79,6 +79,7 @@ export class PageInternal extends PureComponent { const { canvasBackground, + customTextLayerRenderer, customTextRenderer, devicePixelRatio, onGetAnnotationsError, @@ -98,6 +99,7 @@ export class PageInternal extends PureComponent { return { canvasBackground, customTextRenderer, + customTextLayerRenderer, devicePixelRatio, onGetAnnotationsError, onGetAnnotationsSuccess, @@ -382,6 +384,7 @@ PageInternal.propTypes = { canvasBackground: PropTypes.string, children: PropTypes.node, className: isClassName, + customTextLayerRenderer: PropTypes.func, customTextRenderer: PropTypes.func, devicePixelRatio: PropTypes.number, error: isFunctionOrNode, diff --git a/src/Page/TextLayer.jsx b/src/Page/TextLayer.jsx index b553a5e71..65cd541e6 100644 --- a/src/Page/TextLayer.jsx +++ b/src/Page/TextLayer.jsx @@ -145,7 +145,7 @@ export class TextLayerInternal extends PureComponent { const container = this.layerElement.current; const { viewport } = this; - const { customTextRenderer, pageIndex, pageNumber } = this.props; + const { customTextLayerRenderer, customTextRenderer, pageIndex, pageNumber } = this.props; // If another rendering is in progress, let's cancel it cancelRunningTask(this.runningTask); @@ -168,7 +168,10 @@ export class TextLayerInternal extends PureComponent { container.append(end); this.endElement.current = end; - if (customTextRenderer) { + if (customTextLayerRenderer) { + this.customTextLayerRenderer(textContent.items, this.layerElement.current.children, pageIndex, pageNumber); + } + else if (customTextRenderer) { let index = 0; textContent.items.forEach((item, itemIndex) => { const child = this.layerElement.current.children[index]; @@ -208,6 +211,7 @@ export class TextLayerInternal extends PureComponent { } TextLayerInternal.propTypes = { + customTextLayerRenderer: PropTypes.func, customTextRenderer: PropTypes.func, onGetTextError: PropTypes.func, onGetTextSuccess: PropTypes.func,