File tree Expand file tree Collapse file tree 3 files changed +13
-5
lines changed Expand file tree Collapse file tree 3 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -66,7 +66,14 @@ describe('Canvas', () => {
6666
6767 expect . assertions ( 1 ) ;
6868
69- await expect ( onRenderSuccessPromise ) . resolves . toMatchObject ( [ { } ] ) ;
69+ await expect ( onRenderSuccessPromise ) . resolves . toMatchObject ( [
70+ { } ,
71+ {
72+ annotationMode : 1 ,
73+ canvasContext : expect . any ( Object ) ,
74+ viewport : page . getViewport ( { scale : 1 , rotation : 0 } ) ,
75+ } ,
76+ ] ) ;
7077
7178 restoreConsole ( ) ;
7279 } ) ;
Original file line number Diff line number Diff line change @@ -51,14 +51,14 @@ export default function Canvas(props: CanvasProps): React.ReactElement {
5151 /**
5252 * Called when a page is rendered successfully.
5353 */
54- function onRenderSuccess ( ) {
54+ function onRenderSuccess ( renderContext : RenderParameters ) {
5555 if ( ! page ) {
5656 // Impossible, but TypeScript doesn't know that
5757 return ;
5858 }
5959
6060 if ( onRenderSuccessProps ) {
61- onRenderSuccessProps ( makePageCallback ( page , scale ) ) ;
61+ onRenderSuccessProps ( makePageCallback ( page , scale ) , renderContext ) ;
6262 }
6363 }
6464
@@ -126,7 +126,7 @@ export default function Canvas(props: CanvasProps): React.ReactElement {
126126 . then ( ( ) => {
127127 canvas . style . visibility = '' ;
128128
129- onRenderSuccess ( ) ;
129+ onRenderSuccess ( renderContext ) ;
130130 } )
131131 . catch ( onRenderError ) ;
132132
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import type {
1111 StructTreeNode ,
1212 TextContent ,
1313 TextItem ,
14+ RenderParameters ,
1415} from 'pdfjs-dist/types/src/display/api.js' ;
1516import type { AnnotationLayerParameters } from 'pdfjs-dist/types/src/display/annotation_layer.js' ;
1617import type LinkService from '../LinkService.js' ;
@@ -116,7 +117,7 @@ export type OnRenderAnnotationLayerSuccess = () => void;
116117
117118export type OnRenderError = OnError ;
118119
119- export type OnRenderSuccess = ( page : PageCallback ) => void ;
120+ export type OnRenderSuccess = ( page : PageCallback , renderContext : RenderParameters ) => void ;
120121
121122export type OnRenderTextLayerError = OnError ;
122123
You can’t perform that action at this time.
0 commit comments