@@ -13,6 +13,7 @@ import { RenderLayer, RenderPluginPackage } from "@embedpdf/plugin-render/react"
1313import { Scroller , ScrollPluginPackage , ScrollStrategy } from "@embedpdf/plugin-scroll/react"
1414import { SearchLayer , SearchPluginPackage } from "@embedpdf/plugin-search/react"
1515import { SelectionLayer , SelectionPluginPackage } from "./plugin-selection-2"
16+ import { ThumbnailPluginPackage } from "@embedpdf/plugin-thumbnail/react"
1617import { TilingLayer , TilingPluginPackage } from "@embedpdf/plugin-tiling/react"
1718import { Viewport , ViewportPluginPackage } from "@embedpdf/plugin-viewport/react"
1819import { PinchWrapper , ZoomMode , ZoomPluginPackage } from "@embedpdf/plugin-zoom/react"
@@ -21,6 +22,8 @@ import AnnotationStoreSync from "../annotation-store/annotation-store-sync"
2122import { Spinner } from "../shadcn-ui/spinner"
2223import { AnnotationLayer , AnnotationPluginPackage } from "./plugin-annotation-2"
2324import Toolbar from "./toolbar"
25+ import ThumbnailSidebar from "./thumbnail-sidebar"
26+ import { Sidebar , SidebarContent , SidebarProvider } from "@/components/shadcn-ui/sidebar"
2427
2528const logger = new ConsoleLogger ( )
2629
@@ -46,106 +49,121 @@ export default function PDFContainer({ url }: PDFContainerProps) {
4649 }
4750
4851 return (
49- < div className = "flex h-screen flex-1 flex-col overflow-hidden" ref = { containerRef } >
50- < div className = "flex flex-1 overflow-hidden" data-testid = "embedpdf" >
51- < EmbedPDF
52- logger = { logger }
53- engine = { engine }
54- plugins = { [
55- // register Loader first
56- createPluginRegistration ( LoaderPluginPackage , {
57- loadingOptions : {
58- type : "url" ,
59- pdfFile : {
60- id : "1" ,
61- url : url ,
62- } ,
63- options : {
64- mode : "full-fetch" ,
65- } ,
66- } ,
67- } ) ,
68- createPluginRegistration ( ViewportPluginPackage , {
69- viewportGap : 5 ,
70- } ) ,
71- createPluginRegistration ( ScrollPluginPackage , {
72- strategy : ScrollStrategy . Vertical ,
73- } ) ,
74- createPluginRegistration ( RenderPluginPackage ) ,
75- createPluginRegistration ( InteractionManagerPluginPackage ) ,
76- createPluginRegistration ( TilingPluginPackage , {
77- tileSize : 768 ,
78- overlapPx : 2.5 ,
79- extraRings : 0 ,
80- } ) ,
81- createPluginRegistration ( SelectionPluginPackage ) ,
82- // register Annotation after InteractionManager, Seletion
83- createPluginRegistration ( AnnotationPluginPackage ) ,
84- // register Export after Annotation
85- createPluginRegistration ( ExportPluginPackage ) ,
86- // register Zoom after InteractionManager, Viewport, Scroll
87- createPluginRegistration ( ZoomPluginPackage , {
88- defaultZoomLevel : ZoomMode . Automatic ,
89- } ) ,
90- createPluginRegistration ( SearchPluginPackage ) ,
91- ] }
92- >
93- { ( { pluginsReady } ) => {
94- return (
95- < GlobalPointerProvider >
96- < AnnotationStoreSync />
97- < Toolbar data-testid = "annotation-toolbar" />
98- < Viewport className = "h-full w-full flex-1 overflow-auto bg-gray-100 select-none" >
99- { ! pluginsReady && (
100- < div className = "flex h-full w-full items-center justify-center" >
101- < Spinner data-testid = "spinner1" />
102- </ div >
103- ) }
104- { pluginsReady && (
105- < PinchWrapper >
106- < Scroller
107- renderPage = { ( { pageIndex, scale, width, height } ) => (
108- < PagePointerProvider
109- pageIndex = { pageIndex }
110- scale = { scale }
111- pageWidth = { width }
112- pageHeight = { height }
113- rotation = { 0 }
114- >
115- { /* RednerLayer must go first */ }
116- < RenderLayer pageIndex = { pageIndex } className = "pointer-events-none" />
117- < TilingLayer
118- pageIndex = { pageIndex }
119- scale = { scale }
120- className = "pointer-events-none"
121- />
122- < AnnotationLayer
123- pageIndex = { pageIndex }
124- scale = { scale }
125- pageWidth = { width }
126- pageHeight = { height }
127- rotation = { 0 }
128- data-testid = "annotation-layer"
129- />
130- < SearchLayer
131- pageIndex = { pageIndex }
132- scale = { scale }
133- highlightColor = { "#FFFF00" }
134- activeHighlightColor = { "#FFFF00" }
135- />
136- { /* SelectionLayer must go last */ }
137- < SelectionLayer pageIndex = { pageIndex } scale = { scale } />
138- </ PagePointerProvider >
139- ) }
140- />
141- </ PinchWrapper >
142- ) }
143- </ Viewport >
144- </ GlobalPointerProvider >
145- )
146- } }
147- </ EmbedPDF >
52+ < SidebarProvider >
53+ < div className = "flex h-screen w-full" ref = { containerRef } >
54+ < div className = "flex flex-1 flex-col overflow-hidden" >
55+ < div className = "flex flex-1 overflow-hidden" data-testid = "embedpdf" >
56+ < EmbedPDF
57+ logger = { logger }
58+ engine = { engine }
59+ plugins = { [
60+ // register Loader first
61+ createPluginRegistration ( LoaderPluginPackage , {
62+ loadingOptions : {
63+ type : "url" ,
64+ pdfFile : {
65+ id : "1" ,
66+ url : url ,
67+ } ,
68+ options : {
69+ mode : "full-fetch" ,
70+ } ,
71+ } ,
72+ } ) ,
73+ createPluginRegistration ( ViewportPluginPackage , {
74+ viewportGap : 5 ,
75+ } ) ,
76+ createPluginRegistration ( ScrollPluginPackage , {
77+ strategy : ScrollStrategy . Vertical ,
78+ } ) ,
79+ createPluginRegistration ( RenderPluginPackage ) ,
80+ createPluginRegistration ( InteractionManagerPluginPackage ) ,
81+ createPluginRegistration ( TilingPluginPackage , {
82+ tileSize : 768 ,
83+ overlapPx : 2.5 ,
84+ extraRings : 0 ,
85+ } ) ,
86+ createPluginRegistration ( SelectionPluginPackage ) ,
87+ // register Annotation after InteractionManager, Seletion
88+ createPluginRegistration ( AnnotationPluginPackage ) ,
89+ // register Export after Annotation
90+ createPluginRegistration ( ExportPluginPackage ) ,
91+ // register Zoom after InteractionManager, Viewport, Scroll
92+ createPluginRegistration ( ZoomPluginPackage , {
93+ defaultZoomLevel : ZoomMode . Automatic ,
94+ } ) ,
95+ createPluginRegistration ( SearchPluginPackage ) ,
96+ createPluginRegistration ( ThumbnailPluginPackage , {
97+ width : 120 ,
98+ } ) ,
99+ ] }
100+ >
101+ { ( { pluginsReady } ) => {
102+ return (
103+ < GlobalPointerProvider >
104+ < AnnotationStoreSync />
105+ < Toolbar data-testid = "annotation-toolbar" />
106+ < Viewport className = "h-full w-full flex-1 overflow-auto bg-gray-100 select-none" >
107+ { ! pluginsReady && (
108+ < div className = "flex h-full w-full items-center justify-center" >
109+ < Spinner data-testid = "spinner1" />
110+ </ div >
111+ ) }
112+ { pluginsReady && (
113+ < PinchWrapper >
114+ < Scroller
115+ renderPage = { ( { pageIndex, scale, width, height } ) => (
116+ < PagePointerProvider
117+ pageIndex = { pageIndex }
118+ scale = { scale }
119+ pageWidth = { width }
120+ pageHeight = { height }
121+ rotation = { 0 }
122+ >
123+ { /* RednerLayer must go first */ }
124+ < RenderLayer
125+ pageIndex = { pageIndex }
126+ className = "pointer-events-none"
127+ />
128+ < TilingLayer
129+ pageIndex = { pageIndex }
130+ scale = { scale }
131+ className = "pointer-events-none"
132+ />
133+ < AnnotationLayer
134+ pageIndex = { pageIndex }
135+ scale = { scale }
136+ pageWidth = { width }
137+ pageHeight = { height }
138+ rotation = { 0 }
139+ data-testid = "annotation-layer"
140+ />
141+ < SearchLayer
142+ pageIndex = { pageIndex }
143+ scale = { scale }
144+ highlightColor = { "#FFFF00" }
145+ activeHighlightColor = { "#FFFF00" }
146+ />
147+ { /* SelectionLayer must go last */ }
148+ < SelectionLayer pageIndex = { pageIndex } scale = { scale } />
149+ </ PagePointerProvider >
150+ ) }
151+ />
152+ </ PinchWrapper >
153+ ) }
154+ </ Viewport >
155+ </ GlobalPointerProvider >
156+ )
157+ } }
158+ </ EmbedPDF >
159+ </ div >
160+ </ div >
161+ < Sidebar side = "right" variant = "floating" collapsible = "none" >
162+ < SidebarContent className = "p-0" >
163+ < ThumbnailSidebar />
164+ </ SidebarContent >
165+ </ Sidebar >
148166 </ div >
149- </ div >
167+ </ SidebarProvider >
150168 )
151169}
0 commit comments