pdfjs-annotation-extension-for-react 0.1.4 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -136,6 +136,7 @@ An advanced PDF viewer with annotation capabilities.
136
136
  | --------------------------- | ------------------------------------------------------------------- | ----------------------------------- | -------------------------------------------------------------------- |
137
137
  | `user` | `User` | `{ id: 'null', name: 'unknown' }` | Current user information<br />used to identify the annotation author |
138
138
  | `enableNativeAnnotations` | `boolean` | `false` | Native annotations embedded in the PDF file |
139
+ | `defaultShowAnnotationsSidebar` | `boolean` | `false` | Show Annotations Sidebar |
139
140
  | `defaultOptions` | `DeepPartial` | — | Default configuration for the annotator; |
140
141
  | `initialAnnotations` | `IAnnotationStore[]` | — | Existing annotations to be rendered during initialization |
141
142
  | `actions` | `React.ReactNode \| React.ComponentType` | — | Custom actions area  |
@@ -271,10 +272,10 @@ A lightweight PDF viewer with toolbar, sidebar, actions and extensible UI slots.
271
272
  | Name | Type | Default | Description |
272
273
  | ---------------------- | ------------------------------------------------------------------------- | --------- | ------------------------------------------------------------------------------------------ |
273
274
  | `actions` | `React.ReactNode \| (context: PdfViewerContextValue) => React.ReactNode` | — | Custom actions area in the toolbar |
274
- | `sidebar` | `React.ReactNode \| (context: PdfViewerContextValue) => React.ReactNode` | — | Custom sidebar component |
275
+ | `sidebar` | `SidebarPanel[]` | — | Custom sidebar component |
275
276
  | `toolbar` | `React.ReactNode \| (context: PdfViewerContextValue) => React.ReactNode` | — | Custom toolbar component |
276
- | `showSidebarTrigger` | `boolean` | `false` | Whether to display a button to toggle the sidebar visibility |
277
277
  | `showTextLayer` | `boolean` | `true` | Whether to render the text layer |
278
+ | `defaultActiveSidebarKey` | `string` | null | Default Active Sidebar Key |
278
279
  | `onDocumentLoaded` | `(pdfViewer: PDFViewer \| null) => void` | — | Callback invoked when the PDF <br />document is fully loaded and the viewer is initialized |
279
280
  | `onEventBusReady` | `(eventBus: EventBus \| null) => void` | — | Callback invoked when the pdf.js EventBus is ready |
280
281
 
@@ -309,34 +310,36 @@ A lightweight PDF viewer with toolbar, sidebar, actions and extensible UI slots.
309
310
  ```jsx
310
311
  <PdfViewer
311
312
  url={pdfUrl}
312
- sidebar={(context) => (
313
- <>
314
- <button onClick={() => console.log(context.pdfViewer)}>
315
- PDF Viewer
316
- </button>
317
- <button onClick={() => {
318
- context.pdfViewer?.scrollPageIntoView({
319
- pageNumber: 1
320
- })
321
- }}>
322
- page1
323
- </button>
324
- <button onClick={() => {
325
- context.pdfViewer?.scrollPageIntoView({
326
- pageNumber: 10
327
- })
328
- }}>
329
- page 10
330
- </button>
331
- <button onClick={() => {
332
- context.pdfViewer?.scrollPageIntoView({
333
- pageNumber: 100
334
- })
335
- }}>
336
- page 100
337
- </button>
338
- </>
339
- )}
313
+ sidebar={[{
314
+ key: 'sidebar-1',
315
+ title: 'Sidebar 1',
316
+ icon: <BsLayoutTextSidebar />,
317
+ render: (context) => (
318
+ <div style={{ display: 'flex', gap: 10, flexDirection: 'column' }}>
319
+ Sidebar 1
320
+ <button onClick={context.toggleSidebar}>
321
+ toggleSidebar
322
+ </button>
323
+ <button onClick={() => console.log(context.pdfViewer)}>
324
+ Get PDF Viewer
325
+ </button>
326
+ <button onClick={() => {
327
+ context.pdfViewer?.scrollPageIntoView({
328
+ pageNumber: 1
329
+ })
330
+ }}>
331
+ goto page1
332
+ </button>
333
+ <button onClick={() => {
334
+ context.pdfViewer?.scrollPageIntoView({
335
+ pageNumber: 10
336
+ })
337
+ }}>
338
+ goto page 10
339
+ </button>
340
+ </div>
341
+ )
342
+ }]}
340
343
  />
341
344
  ```
342
345