teamsync-pdf-viewer 1.0.3 → 1.1.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/CHANGELOG.md +53 -0
- package/LICENSE +96 -1
- package/README.md +166 -165
- package/dist/src/annotations/types.d.ts +45 -0
- package/dist/src/components/AboutModal.d.ts +6 -0
- package/dist/src/components/AnnotationContextMenu.d.ts +17 -0
- package/dist/src/components/DocumentViewer.d.ts +47 -0
- package/dist/src/components/Header.d.ts +35 -0
- package/dist/src/components/InsertLinkModal.d.ts +10 -0
- package/dist/src/components/LeftSidebar.d.ts +10 -0
- package/dist/src/components/PageContextMenu.d.ts +20 -0
- package/dist/src/components/PageRenderer.d.ts +40 -0
- package/dist/src/components/SettingsModal.d.ts +8 -0
- package/dist/src/components/Sidebar.d.ts +18 -0
- package/dist/src/components/TeamSyncViewer.d.ts +35 -0
- package/dist/src/components/TextSelectionMenu.d.ts +18 -0
- package/dist/src/core/ViewerInstance.d.ts +92 -0
- package/dist/src/core/busContext.d.ts +3 -0
- package/dist/src/core/createWebViewer.d.ts +5 -0
- package/dist/src/core/eventBus.d.ts +25 -0
- package/dist/src/core/export.d.ts +20 -0
- package/dist/src/core/pdfAssets.d.ts +27 -0
- package/dist/src/core/types.d.ts +103 -0
- package/dist/src/hooks/usePdfSearch.d.ts +23 -0
- package/dist/src/hooks/useShortcuts.d.ts +13 -0
- package/dist/src/hooks/useViewerBus.d.ts +7 -0
- package/dist/src/index.d.ts +20 -0
- package/dist/src/plugins/index.d.ts +1 -0
- package/dist/src/plugins/types.d.ts +26 -0
- package/dist/src/utils/findRegexRedactions.d.ts +6 -0
- package/dist/src/utils/rotationUtils.d.ts +32 -0
- package/dist/style.css +2 -0
- package/dist/teamsync-pdf-viewer.js +5086 -0
- package/dist/teamsync-pdf-viewer.js.map +1 -0
- package/package.json +48 -15
- package/dist/TeamSync.pdf +0 -0
- package/dist/ThirdPartyNotices.txt +0 -639
- package/dist/favicon.svg +0 -16
- package/dist/icons.svg +0 -24
- package/dist/index.d.ts +0 -1
- package/dist/teamsync-pdf-viewer.css +0 -2
- package/dist/teamsync-pdf-viewer.es.js +0 -51524
- package/dist/teamsync-pdf-viewer.umd.cjs +0 -327
- package/dist/webviewer.js +0 -92
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { Annotation } from '../annotations/types';
|
|
3
|
+
import { SDKPermissions } from '../core/types';
|
|
4
|
+
interface AnnotationContextMenuProps {
|
|
5
|
+
annotation: Annotation;
|
|
6
|
+
position: {
|
|
7
|
+
top: number;
|
|
8
|
+
left: number;
|
|
9
|
+
};
|
|
10
|
+
onCopy: () => void;
|
|
11
|
+
onDelete: () => void;
|
|
12
|
+
onUpdateColor: (color: string) => void;
|
|
13
|
+
onOpenLinkModal: () => void;
|
|
14
|
+
permissions?: SDKPermissions;
|
|
15
|
+
}
|
|
16
|
+
export default function AnnotationContextMenu({ annotation, position, onCopy, onDelete, onUpdateColor, onOpenLinkModal, permissions }: AnnotationContextMenuProps): React.JSX.Element;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { Annotation } from '../annotations/types';
|
|
3
|
+
import { Redaction, WatermarkOptions, SDKPermissions, PdfAssetPaths } from '../core/types';
|
|
4
|
+
import * as pdfjsLib from 'pdfjs-dist';
|
|
5
|
+
export interface DocumentLoadErrorInfo {
|
|
6
|
+
url: string;
|
|
7
|
+
passwordRequired: boolean;
|
|
8
|
+
}
|
|
9
|
+
interface DocumentViewerProps {
|
|
10
|
+
leftSidebarOpen: boolean;
|
|
11
|
+
rightSidebarOpen: boolean;
|
|
12
|
+
activeTab: string;
|
|
13
|
+
initialDoc?: string;
|
|
14
|
+
/** Bump to force a reload of the same URL (retry after a load error). */
|
|
15
|
+
loadNonce?: number;
|
|
16
|
+
/** Send cookies with the document request. */
|
|
17
|
+
withCredentials?: boolean;
|
|
18
|
+
/** pdf.js asset locations, applied right before the document is opened. */
|
|
19
|
+
assets?: PdfAssetPaths;
|
|
20
|
+
/** Render the thumbnails (left) and comments/search (right) panels. Default true. */
|
|
21
|
+
sidebars?: boolean;
|
|
22
|
+
redactions?: Redaction[];
|
|
23
|
+
regexRedactions?: RegExp[];
|
|
24
|
+
scale: number;
|
|
25
|
+
setScale: (scale: number | ((prev: number) => number)) => void;
|
|
26
|
+
sidebarTab: 'Comments' | 'Search';
|
|
27
|
+
setSidebarTab: (tab: 'Comments' | 'Search') => void;
|
|
28
|
+
onAnnotationsChange?: (annotations: Annotation[]) => void;
|
|
29
|
+
/** Reports the combined (prop + regex + manual) redaction list whenever it changes. */
|
|
30
|
+
onRedactionsChange?: (redactions: Redaction[]) => void;
|
|
31
|
+
onDocumentLoaded?: (doc: pdfjsLib.PDFDocumentProxy, url: string) => void;
|
|
32
|
+
onLoadError?: (error: Error, info: DocumentLoadErrorInfo) => void;
|
|
33
|
+
/** Fires once per loaded document, after the first page canvas has been painted. */
|
|
34
|
+
onFirstPageRendered?: (pageNumber: number) => void;
|
|
35
|
+
onPageChange?: (pageNumber: number, numPages: number) => void;
|
|
36
|
+
pageTransition: 'continuous' | 'page-by-page';
|
|
37
|
+
pageLayout: 'single' | 'double' | 'cover-facing';
|
|
38
|
+
rotation: number;
|
|
39
|
+
setRotation: (r: number | ((prev: number) => number)) => void;
|
|
40
|
+
watermark?: WatermarkOptions;
|
|
41
|
+
watermarkText?: string;
|
|
42
|
+
enableAnnotations?: boolean;
|
|
43
|
+
initialPage?: number;
|
|
44
|
+
permissions?: SDKPermissions;
|
|
45
|
+
}
|
|
46
|
+
export default function DocumentViewer({ leftSidebarOpen, rightSidebarOpen, activeTab, initialDoc, loadNonce, withCredentials, assets, sidebars, redactions, regexRedactions, scale, setScale, sidebarTab, setSidebarTab, onAnnotationsChange, onRedactionsChange, onDocumentLoaded, onLoadError, onFirstPageRendered, onPageChange, pageTransition, pageLayout, rotation, setRotation, watermark, watermarkText, enableAnnotations: _enableAnnotations, initialPage, permissions }: DocumentViewerProps): React.JSX.Element;
|
|
47
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { SDKPermissions } from '../core/types';
|
|
3
|
+
import { ViewerPlugin } from '../plugins/types';
|
|
4
|
+
interface HeaderProps {
|
|
5
|
+
activeTab: string;
|
|
6
|
+
setActiveTab: (tab: string) => void;
|
|
7
|
+
leftSidebarOpen: boolean;
|
|
8
|
+
setLeftSidebarOpen: (open: boolean) => void;
|
|
9
|
+
rightSidebarOpen: boolean;
|
|
10
|
+
setRightSidebarOpen: (open: boolean) => void;
|
|
11
|
+
sidebarTab: 'Comments' | 'Search';
|
|
12
|
+
scale: number;
|
|
13
|
+
onZoomIn: () => void;
|
|
14
|
+
onZoomOut: () => void;
|
|
15
|
+
onZoomSet: (scale: number) => void;
|
|
16
|
+
onDownload: () => void;
|
|
17
|
+
onFullScreen: () => void;
|
|
18
|
+
onSaveAs: () => void;
|
|
19
|
+
onOpenSettings: () => void;
|
|
20
|
+
onOpenAbout: () => void;
|
|
21
|
+
onOpenSidebarTab: (tab: 'Comments' | 'Search') => void;
|
|
22
|
+
pageTransition: 'continuous' | 'page-by-page';
|
|
23
|
+
setPageTransition: (t: 'continuous' | 'page-by-page') => void;
|
|
24
|
+
pageLayout: 'single' | 'double' | 'cover-facing';
|
|
25
|
+
setPageLayout: (l: 'single' | 'double' | 'cover-facing') => void;
|
|
26
|
+
rotation: number;
|
|
27
|
+
setRotation: (r: number) => void;
|
|
28
|
+
signatureCount?: number;
|
|
29
|
+
enableAnnotations?: boolean;
|
|
30
|
+
enableSign?: boolean;
|
|
31
|
+
plugins?: ViewerPlugin[];
|
|
32
|
+
permissions?: SDKPermissions;
|
|
33
|
+
}
|
|
34
|
+
export default function Header({ activeTab, setActiveTab, leftSidebarOpen, setLeftSidebarOpen, rightSidebarOpen, setRightSidebarOpen: _setRightSidebarOpen, sidebarTab, scale, onZoomIn, onZoomOut, onZoomSet, onDownload, onFullScreen, onSaveAs, onOpenSettings, onOpenAbout, onOpenSidebarTab, pageTransition, setPageTransition, pageLayout, setPageLayout, rotation, setRotation, signatureCount, enableAnnotations, enableSign, plugins, permissions }: HeaderProps): React.JSX.Element;
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
interface InsertLinkModalProps {
|
|
3
|
+
initialUrl?: string;
|
|
4
|
+
initialText?: string;
|
|
5
|
+
showTextInput?: boolean;
|
|
6
|
+
onClose: () => void;
|
|
7
|
+
onSave: (url: string, text?: string) => void;
|
|
8
|
+
}
|
|
9
|
+
export default function InsertLinkModal({ initialUrl, initialText, showTextInput, onClose, onSave }: InsertLinkModalProps): React.JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import * as pdfjsLib from 'pdfjs-dist';
|
|
3
|
+
interface LeftSidebarProps {
|
|
4
|
+
isOpen: boolean;
|
|
5
|
+
pdfDoc: pdfjsLib.PDFDocumentProxy | null;
|
|
6
|
+
pageNum: number;
|
|
7
|
+
setPageNum: (p: number) => void;
|
|
8
|
+
}
|
|
9
|
+
export default function LeftSidebar({ isOpen, pdfDoc, pageNum, setPageNum }: LeftSidebarProps): React.JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
interface PageContextMenuProps {
|
|
3
|
+
position: {
|
|
4
|
+
top: number;
|
|
5
|
+
left: number;
|
|
6
|
+
};
|
|
7
|
+
hasSelection?: boolean;
|
|
8
|
+
onSetTool: (tool: any) => void;
|
|
9
|
+
onZoomIn: () => void;
|
|
10
|
+
onZoomOut: () => void;
|
|
11
|
+
onClose: () => void;
|
|
12
|
+
onLink?: () => void;
|
|
13
|
+
onHighlight?: () => void;
|
|
14
|
+
onUnderline?: () => void;
|
|
15
|
+
onStrikethrough?: () => void;
|
|
16
|
+
onCopy?: () => void;
|
|
17
|
+
enableAnnotations?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export default function PageContextMenu({ position, hasSelection, onSetTool, onZoomIn, onZoomOut, onClose, onLink, onHighlight, onUnderline, onStrikethrough, onCopy, enableAnnotations }: PageContextMenuProps): React.JSX.Element;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { SearchResult } from '../hooks/usePdfSearch';
|
|
3
|
+
import { Redaction, WatermarkOptions } from '../core/types';
|
|
4
|
+
import { Annotation } from '../annotations/types';
|
|
5
|
+
import * as pdfjsLib from 'pdfjs-dist';
|
|
6
|
+
export type { Annotation };
|
|
7
|
+
interface PageRendererProps {
|
|
8
|
+
pageNum: number;
|
|
9
|
+
pdfDoc: pdfjsLib.PDFDocumentProxy;
|
|
10
|
+
scale: number;
|
|
11
|
+
rotation: number;
|
|
12
|
+
containerWidth: number;
|
|
13
|
+
containerHeight: number;
|
|
14
|
+
scrollTop: number;
|
|
15
|
+
scrollLeft: number;
|
|
16
|
+
pageTop: number;
|
|
17
|
+
pageLeft?: number;
|
|
18
|
+
basePageWidth: number;
|
|
19
|
+
basePageHeight: number;
|
|
20
|
+
activeTab: string;
|
|
21
|
+
activeTool: string | null;
|
|
22
|
+
annotations: Annotation[];
|
|
23
|
+
selectedAnnotationId: string | null;
|
|
24
|
+
activeSearchResult: SearchResult | null;
|
|
25
|
+
onMouseDown: (e: React.MouseEvent<Element>, pageNum: number) => void;
|
|
26
|
+
onMouseMove: (e: React.MouseEvent<Element>, pageNum: number) => void;
|
|
27
|
+
onMouseUp: (e: React.MouseEvent<Element>, pageNum: number) => void;
|
|
28
|
+
onAnnotationClick: (id: string, e: React.MouseEvent) => void;
|
|
29
|
+
onAnnotationMouseEnter: (id: string) => void;
|
|
30
|
+
onClearSelection: () => void;
|
|
31
|
+
watermark?: WatermarkOptions;
|
|
32
|
+
watermarkText?: string;
|
|
33
|
+
redactions?: Redaction[];
|
|
34
|
+
onDiscardRedaction?: (redaction: Redaction) => void;
|
|
35
|
+
/** Called after the page canvas has been painted (used for first-page-rendered telemetry). */
|
|
36
|
+
onRendered?: (pageNum: number) => void;
|
|
37
|
+
}
|
|
38
|
+
declare function PageRendererComponent({ pageNum, pdfDoc, scale, rotation, containerWidth: _containerWidth, containerHeight: _containerHeight, scrollTop: _scrollTop, scrollLeft: _scrollLeft, pageTop, pageLeft, basePageWidth, basePageHeight, activeTab, activeTool, annotations, selectedAnnotationId, activeSearchResult, onMouseDown, onMouseMove, onMouseUp, onAnnotationClick, onAnnotationMouseEnter, onClearSelection, watermark, watermarkText, redactions, onDiscardRedaction, onRendered }: PageRendererProps): React.JSX.Element;
|
|
39
|
+
declare const PageRenderer: React.MemoExoticComponent<typeof PageRendererComponent>;
|
|
40
|
+
export default PageRenderer;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
interface SettingsModalProps {
|
|
3
|
+
onClose: () => void;
|
|
4
|
+
watermarkText: string;
|
|
5
|
+
setWatermarkText: (text: string) => void;
|
|
6
|
+
}
|
|
7
|
+
export default function SettingsModal({ onClose, watermarkText, setWatermarkText }: SettingsModalProps): React.JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { SearchResult } from '../hooks/usePdfSearch';
|
|
3
|
+
interface SidebarProps {
|
|
4
|
+
isOpen: boolean;
|
|
5
|
+
annotations: any[];
|
|
6
|
+
setAnnotations: (anns: any[]) => void;
|
|
7
|
+
selectedAnnotationId: string | null;
|
|
8
|
+
setSelectedAnnotationId: (id: string | null) => void;
|
|
9
|
+
onSearch: (query: string) => void;
|
|
10
|
+
searchResults: SearchResult[];
|
|
11
|
+
isSearching: boolean;
|
|
12
|
+
searchProgress: number;
|
|
13
|
+
onResultClick: (result: SearchResult) => void;
|
|
14
|
+
activeTab: 'Comments' | 'Search';
|
|
15
|
+
setActiveTab: (tab: 'Comments' | 'Search') => void;
|
|
16
|
+
}
|
|
17
|
+
export default function Sidebar({ isOpen, annotations, setAnnotations, selectedAnnotationId, setSelectedAnnotationId, onSearch, searchResults, isSearching, searchProgress, onResultClick, activeTab, setActiveTab }: SidebarProps): React.JSX.Element;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { DocumentLoadErrorInfo } from './DocumentViewer';
|
|
3
|
+
import { WebViewerInstance } from '../core/ViewerInstance';
|
|
4
|
+
import { WebViewerOptions } from '../core/types';
|
|
5
|
+
import { Annotation } from '../annotations/types';
|
|
6
|
+
export interface TeamSyncViewerProps extends Omit<WebViewerOptions, 'path'> {
|
|
7
|
+
/** URL of the PDF to display. Alias of `initialDoc`; `fileUrl` wins when both are set. */
|
|
8
|
+
fileUrl?: string;
|
|
9
|
+
/** Fires once, after mount, with the instance handle. */
|
|
10
|
+
onReady?: (instance: WebViewerInstance) => void;
|
|
11
|
+
onDocumentLoaded?: (info: {
|
|
12
|
+
url: string;
|
|
13
|
+
numPages: number;
|
|
14
|
+
}) => void;
|
|
15
|
+
/**
|
|
16
|
+
* Fires when the document could not be loaded. `retry(newUrl?)` reloads — pass a fresh URL when
|
|
17
|
+
* the previous one was a presigned link that expired.
|
|
18
|
+
*/
|
|
19
|
+
onDocumentLoadError?: (error: Error, retry: (newUrl?: string) => void, info: DocumentLoadErrorInfo) => void;
|
|
20
|
+
/** Fires once per document, after the first page canvas has been painted. */
|
|
21
|
+
onFirstPageRendered?: (info: {
|
|
22
|
+
url: string;
|
|
23
|
+
pageNumber: number;
|
|
24
|
+
}) => void;
|
|
25
|
+
/** Fires (in addition to onDocumentLoadError) when the document is password protected. */
|
|
26
|
+
onPasswordRequired?: (info: {
|
|
27
|
+
url: string;
|
|
28
|
+
}) => void;
|
|
29
|
+
onPageChange?: (pageNumber: number, numPages: number) => void;
|
|
30
|
+
onAnnotationsChange?: (annotations: Annotation[]) => void;
|
|
31
|
+
className?: string;
|
|
32
|
+
style?: React.CSSProperties;
|
|
33
|
+
}
|
|
34
|
+
export declare const TeamSyncViewer: React.ForwardRefExoticComponent<TeamSyncViewerProps & React.RefAttributes<WebViewerInstance>>;
|
|
35
|
+
export default TeamSyncViewer;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { SDKPermissions } from '../core/types';
|
|
3
|
+
interface TextSelectionMenuProps {
|
|
4
|
+
position: {
|
|
5
|
+
top: number;
|
|
6
|
+
left: number;
|
|
7
|
+
};
|
|
8
|
+
onHighlight: () => void;
|
|
9
|
+
onText?: () => void;
|
|
10
|
+
onRedact?: () => void;
|
|
11
|
+
onCopy?: () => void;
|
|
12
|
+
onLink?: () => void;
|
|
13
|
+
permissions?: SDKPermissions;
|
|
14
|
+
isViewMode?: boolean;
|
|
15
|
+
hasText?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export default function TextSelectionMenu({ position, onHighlight, onText, onRedact, onCopy, onLink, permissions, isViewMode, hasText }: TextSelectionMenuProps): React.JSX.Element | null;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { ViewerBus } from './eventBus';
|
|
2
|
+
import { ExportOptions } from './export';
|
|
3
|
+
import { Annotation } from '../annotations/types';
|
|
4
|
+
import { Redaction, WatermarkOptions, ViewerEventMap, ViewerEventType } from './types';
|
|
5
|
+
/**
|
|
6
|
+
* © 2026 AngelBot Ai Pvt Ltd. All rights reserved.
|
|
7
|
+
* WebViewerInstance — the imperative handle returned by `createWebViewer()` and exposed through
|
|
8
|
+
* `<TeamSyncViewer ref>`. Keeps the legacy `UI` / `Core` facade for drop-in compatibility.
|
|
9
|
+
*/
|
|
10
|
+
import type * as pdfjsLib from 'pdfjs-dist';
|
|
11
|
+
/** Callbacks the React component installs so the instance can reach live state. */
|
|
12
|
+
export interface ViewerBinding {
|
|
13
|
+
getAnnotations(): Annotation[];
|
|
14
|
+
getRedactions(): Redaction[];
|
|
15
|
+
getWatermark(): WatermarkOptions | undefined;
|
|
16
|
+
getPdfDocument(): pdfjsLib.PDFDocumentProxy | null;
|
|
17
|
+
getDocumentUrl(): string | undefined;
|
|
18
|
+
getFileName(): string | undefined;
|
|
19
|
+
getCurrentUserName(): string | undefined;
|
|
20
|
+
getCurrentPage(): number;
|
|
21
|
+
getPageCount(): number;
|
|
22
|
+
loadDocument(url: string): void;
|
|
23
|
+
}
|
|
24
|
+
export declare class WebViewerInstance {
|
|
25
|
+
readonly bus: ViewerBus;
|
|
26
|
+
/** Root element of the viewer once mounted. */
|
|
27
|
+
element: HTMLElement | null;
|
|
28
|
+
private binding;
|
|
29
|
+
private unmountRoot;
|
|
30
|
+
private destroyed;
|
|
31
|
+
constructor(bus: ViewerBus);
|
|
32
|
+
/** @internal */
|
|
33
|
+
_bind(binding: ViewerBinding, element: HTMLElement | null): void;
|
|
34
|
+
/** @internal */
|
|
35
|
+
_unbind(): void;
|
|
36
|
+
/** @internal — installed by createWebViewer() so destroy() can unmount the React root. */
|
|
37
|
+
_setUnmount(fn: () => void): void;
|
|
38
|
+
get isDestroyed(): boolean;
|
|
39
|
+
get isMounted(): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Tear the viewer down: unmounts the React tree created by `createWebViewer()`, drops every
|
|
42
|
+
* listener and refuses further use. Safe to call twice.
|
|
43
|
+
*/
|
|
44
|
+
destroy(): void;
|
|
45
|
+
on<K extends ViewerEventType>(type: K, listener: (detail: ViewerEventMap[K]) => void): () => void;
|
|
46
|
+
off<K extends ViewerEventType>(type: K, listener: (detail: ViewerEventMap[K]) => void): void;
|
|
47
|
+
/** Load (or reload) a document by URL. Resolves when loaded, rejects on load error. */
|
|
48
|
+
loadDocument(url: string): Promise<{
|
|
49
|
+
url: string;
|
|
50
|
+
numPages: number;
|
|
51
|
+
}>;
|
|
52
|
+
getDocumentUrl(): string | undefined;
|
|
53
|
+
getPdfDocument(): pdfjsLib.PDFDocumentProxy | null;
|
|
54
|
+
getCurrentPage(): number;
|
|
55
|
+
getPageCount(): number;
|
|
56
|
+
getAnnotations(): Annotation[];
|
|
57
|
+
/**
|
|
58
|
+
* Build the exported PDF (annotations + watermark baked, redacted pages rasterized).
|
|
59
|
+
* Uses the bytes of the loaded document; never re-fetches the URL.
|
|
60
|
+
*/
|
|
61
|
+
getFileData(options?: ExportOptions): Promise<Uint8Array>;
|
|
62
|
+
readonly UI: {
|
|
63
|
+
/** Theming is not implemented; kept for API compatibility. */
|
|
64
|
+
setTheme: (_theme: string) => void;
|
|
65
|
+
openElements: (elements: string[]) => void;
|
|
66
|
+
closeElements: (elements: string[]) => void;
|
|
67
|
+
enableElements: (elements: string[]) => void;
|
|
68
|
+
disableElements: (elements: string[]) => void;
|
|
69
|
+
setActiveLeftPanel: (panel: string) => void;
|
|
70
|
+
setToolMode: (tool: string | null) => void;
|
|
71
|
+
fitWidth: () => void;
|
|
72
|
+
fitPage: () => void;
|
|
73
|
+
fitToWidth: () => void;
|
|
74
|
+
fitToPage: () => void;
|
|
75
|
+
};
|
|
76
|
+
readonly Core: {
|
|
77
|
+
annotationManager: {
|
|
78
|
+
/** Legacy: returns the bespoke JSON annotation list. XFDF import/export arrives in 1.2.0. */
|
|
79
|
+
exportAnnotations: () => string;
|
|
80
|
+
getAnnotationsList: () => Annotation[];
|
|
81
|
+
};
|
|
82
|
+
documentViewer: {
|
|
83
|
+
addEventListener: (event: string, callback: (detail: unknown) => void) => (() => void);
|
|
84
|
+
removeEventListener: (event: string, callback: (detail: unknown) => void) => void;
|
|
85
|
+
getCurrentPage: () => number;
|
|
86
|
+
getPageCount: () => number;
|
|
87
|
+
getDocument: () => {
|
|
88
|
+
getFileData: (options?: ExportOptions) => Promise<Uint8Array<ArrayBufferLike>>;
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { WebViewerInstance } from './ViewerInstance';
|
|
2
|
+
import { WebViewerOptions } from './types';
|
|
3
|
+
export declare function createWebViewer(options: WebViewerOptions, viewerElement: HTMLElement): Promise<WebViewerInstance>;
|
|
4
|
+
/** @deprecated Use `createWebViewer`. Kept as an alias for drop-in compatibility. */
|
|
5
|
+
export declare const WebViewer: typeof createWebViewer;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* © 2026 AngelBot Ai Pvt Ltd. All rights reserved.
|
|
3
|
+
* Per-instance event bus.
|
|
4
|
+
*
|
|
5
|
+
* Replaces the former `window.dispatchEvent(new CustomEvent('action-*'))` plumbing so that several
|
|
6
|
+
* viewer instances can coexist on one page without cross-talk, and so that `destroy()` can drop
|
|
7
|
+
* every listener an instance ever registered.
|
|
8
|
+
*/
|
|
9
|
+
export type BusListener<T = unknown> = (detail: T) => void;
|
|
10
|
+
export declare class ViewerBus {
|
|
11
|
+
private readonly listeners;
|
|
12
|
+
private destroyed;
|
|
13
|
+
/** Subscribe. Returns an unsubscribe function. */
|
|
14
|
+
on<T = unknown>(type: string, listener: BusListener<T>): () => void;
|
|
15
|
+
/** Subscribe for a single delivery. */
|
|
16
|
+
once<T = unknown>(type: string, listener: BusListener<T>): () => void;
|
|
17
|
+
off<T = unknown>(type: string, listener: BusListener<T>): void;
|
|
18
|
+
/** Dispatch synchronously to every listener. Listener errors are isolated and logged. */
|
|
19
|
+
emit<T = unknown>(type: string, detail?: T): void;
|
|
20
|
+
listenerCount(type?: string): number;
|
|
21
|
+
removeAll(): void;
|
|
22
|
+
/** Drop every listener and refuse further subscriptions/emissions. */
|
|
23
|
+
destroy(): void;
|
|
24
|
+
get isDestroyed(): boolean;
|
|
25
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Annotation } from '../annotations/types';
|
|
2
|
+
import { Redaction, WatermarkOptions } from './types';
|
|
3
|
+
/** Refuse to build documents larger than this in the browser (memory safety). */
|
|
4
|
+
export declare const MAX_EXPORT_BYTES: number;
|
|
5
|
+
export interface ExportInput {
|
|
6
|
+
/** Returns the original document bytes (prefer `pdfDocument.getData()`). */
|
|
7
|
+
getSourceBytes: () => Promise<Uint8Array | ArrayBuffer>;
|
|
8
|
+
annotations: Annotation[];
|
|
9
|
+
redactions: Redaction[];
|
|
10
|
+
watermark?: WatermarkOptions;
|
|
11
|
+
/** Name printed on digital-signature placeholder blocks when the annotation has no signer. */
|
|
12
|
+
signerName?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface ExportOptions {
|
|
15
|
+
/** Bake exactly these annotations instead of the live list. */
|
|
16
|
+
explicitAnnotations?: Annotation[];
|
|
17
|
+
/** Accepted for API compatibility. Honoured from 1.2.0 (native XFDF import). */
|
|
18
|
+
xfdfString?: string;
|
|
19
|
+
}
|
|
20
|
+
export declare function buildPdfBytes(input: ExportInput, options?: ExportOptions): Promise<Uint8Array>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { DocumentInitParameters } from 'pdfjs-dist/types/src/display/api';
|
|
2
|
+
export interface PdfAssetPaths {
|
|
3
|
+
/** URL of `pdf.worker.min.mjs` matching the installed pdfjs-dist version. REQUIRED. */
|
|
4
|
+
workerSrc?: string;
|
|
5
|
+
/** Directory URL (trailing slash) of the packed CMaps — needed for CJK/Indic text. */
|
|
6
|
+
cMapUrl?: string;
|
|
7
|
+
/** Directory URL (trailing slash) of the standard 14 font substitutes. */
|
|
8
|
+
standardFontDataUrl?: string;
|
|
9
|
+
/** Directory URL (trailing slash) of the wasm decoders (JPX/OpenJPEG, qcms). */
|
|
10
|
+
wasmUrl?: string;
|
|
11
|
+
/** Directory URL (trailing slash) of ICC profiles. */
|
|
12
|
+
iccUrl?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function configurePdfAssets(paths: PdfAssetPaths): void;
|
|
15
|
+
export declare function getPdfAssetPaths(): Readonly<PdfAssetPaths>;
|
|
16
|
+
/** True once a worker URL has been configured (either via configurePdfAssets or directly on pdf.js). */
|
|
17
|
+
export declare function isWorkerConfigured(): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Throws a descriptive error when the worker has not been configured. Called lazily right before
|
|
20
|
+
* the first `getDocument()` — never at module scope, so importing the package is side-effect free
|
|
21
|
+
* and safe under SSR.
|
|
22
|
+
*/
|
|
23
|
+
export declare function assertWorkerConfigured(): void;
|
|
24
|
+
/** Extra `getDocument()` parameters derived from the configured asset paths. */
|
|
25
|
+
export declare function getDocumentParams(): Partial<DocumentInitParameters>;
|
|
26
|
+
/** pdfjs-dist version this build was compiled against (useful for worker-version mismatch checks). */
|
|
27
|
+
export declare const pdfjsVersion: string;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { ViewerPlugin } from '../plugins/types';
|
|
2
|
+
import { Annotation } from '../annotations/types';
|
|
3
|
+
import { PdfAssetPaths } from './pdfAssets';
|
|
4
|
+
export type { PdfAssetPaths };
|
|
5
|
+
export interface Redaction {
|
|
6
|
+
id?: string;
|
|
7
|
+
/** 1-based page number */
|
|
8
|
+
pageIndex: number;
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
width: number;
|
|
12
|
+
height: number;
|
|
13
|
+
status?: 'pending' | 'applied';
|
|
14
|
+
}
|
|
15
|
+
export interface WatermarkOptions {
|
|
16
|
+
text: string;
|
|
17
|
+
opacity?: number;
|
|
18
|
+
size?: number;
|
|
19
|
+
mode?: 'single' | 'tiled';
|
|
20
|
+
color?: string;
|
|
21
|
+
}
|
|
22
|
+
export interface SDKPermissions {
|
|
23
|
+
canAddAnnotations?: boolean;
|
|
24
|
+
canEditAnnotations?: boolean;
|
|
25
|
+
canDeleteAnnotations?: boolean;
|
|
26
|
+
canRedact?: boolean;
|
|
27
|
+
}
|
|
28
|
+
export interface ViewerUser {
|
|
29
|
+
id: string;
|
|
30
|
+
name: string;
|
|
31
|
+
}
|
|
32
|
+
export type InitialScale = number | 'fit-width' | 'fit-page';
|
|
33
|
+
/**
|
|
34
|
+
* Options accepted by `createWebViewer()` (and the deprecated `WebViewer()` alias).
|
|
35
|
+
* Every option is also available as a prop on `<TeamSyncViewer>`.
|
|
36
|
+
*/
|
|
37
|
+
export interface WebViewerOptions {
|
|
38
|
+
/** @deprecated Only meaningful for the iframe package (`public/webviewer.js`). */
|
|
39
|
+
path?: string;
|
|
40
|
+
/** URL of the PDF to load. Presigned/CORS-enabled URLs work; bytes are fetched by pdf.js. */
|
|
41
|
+
initialDoc?: string;
|
|
42
|
+
/** Display name used for downloads. */
|
|
43
|
+
fileName?: string;
|
|
44
|
+
initialScale?: InitialScale;
|
|
45
|
+
/** 1-based page to scroll to after load. */
|
|
46
|
+
initialPage?: number;
|
|
47
|
+
plugins?: ViewerPlugin[];
|
|
48
|
+
redactions?: Redaction[];
|
|
49
|
+
regexRedactions?: RegExp[];
|
|
50
|
+
enableAnnotations?: boolean;
|
|
51
|
+
enableSign?: boolean;
|
|
52
|
+
signOptions?: ('digital' | 'ades' | 'simple')[];
|
|
53
|
+
watermark?: WatermarkOptions;
|
|
54
|
+
permissions?: SDKPermissions;
|
|
55
|
+
enableRedactions?: boolean;
|
|
56
|
+
canAddAnnotations?: boolean;
|
|
57
|
+
canEditAnnotations?: boolean;
|
|
58
|
+
canDeleteAnnotations?: boolean;
|
|
59
|
+
/** Shorthand for "no annotation/redaction editing at all". */
|
|
60
|
+
readOnly?: boolean;
|
|
61
|
+
/** Author attached to annotations created in this viewer. */
|
|
62
|
+
currentUser?: ViewerUser;
|
|
63
|
+
/** pdf.js worker / CMap / font / wasm locations (see `configurePdfAssets`). */
|
|
64
|
+
assets?: PdfAssetPaths;
|
|
65
|
+
/** Send cookies with the document request (same-origin session-bound URLs). Default false. */
|
|
66
|
+
withCredentials?: boolean;
|
|
67
|
+
/** Render the top toolbar. Default true. */
|
|
68
|
+
toolbar?: boolean;
|
|
69
|
+
/** Render the left (thumbnails) and right (comments/search) panels. Default true. */
|
|
70
|
+
sidebars?: boolean;
|
|
71
|
+
/** Start with the thumbnails panel open. Default true. */
|
|
72
|
+
leftPanelOpen?: boolean;
|
|
73
|
+
/** Focus the viewer on mount so keyboard shortcuts work immediately. Default false. */
|
|
74
|
+
autoFocus?: boolean;
|
|
75
|
+
}
|
|
76
|
+
/** Events available through `instance.on(type, listener)`. */
|
|
77
|
+
export interface ViewerEventMap {
|
|
78
|
+
documentLoaded: {
|
|
79
|
+
url: string;
|
|
80
|
+
numPages: number;
|
|
81
|
+
};
|
|
82
|
+
documentLoadError: {
|
|
83
|
+
url: string;
|
|
84
|
+
error: Error;
|
|
85
|
+
passwordRequired: boolean;
|
|
86
|
+
};
|
|
87
|
+
firstPageRendered: {
|
|
88
|
+
url: string;
|
|
89
|
+
pageNumber: number;
|
|
90
|
+
};
|
|
91
|
+
pageChanged: {
|
|
92
|
+
pageNumber: number;
|
|
93
|
+
numPages: number;
|
|
94
|
+
};
|
|
95
|
+
annotationsChanged: {
|
|
96
|
+
annotations: Annotation[];
|
|
97
|
+
};
|
|
98
|
+
toolChanged: {
|
|
99
|
+
tool: string | null;
|
|
100
|
+
};
|
|
101
|
+
destroy: Record<string, never>;
|
|
102
|
+
}
|
|
103
|
+
export type ViewerEventType = keyof ViewerEventMap;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Redaction } from '../core/types';
|
|
2
|
+
import * as pdfjsLib from 'pdfjs-dist';
|
|
3
|
+
export interface SearchBounds {
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
width: number;
|
|
7
|
+
height: number;
|
|
8
|
+
}
|
|
9
|
+
export interface SearchResult {
|
|
10
|
+
id: string;
|
|
11
|
+
pageIndex: number;
|
|
12
|
+
snippet: string;
|
|
13
|
+
matchStartIndex: number;
|
|
14
|
+
matchLength: number;
|
|
15
|
+
bounds: SearchBounds[];
|
|
16
|
+
}
|
|
17
|
+
export declare function usePdfSearch(pdfDoc: pdfjsLib.PDFDocumentProxy | null, redactions?: Redaction[]): {
|
|
18
|
+
search: (query: string) => Promise<void>;
|
|
19
|
+
searchResults: SearchResult[];
|
|
20
|
+
isSearching: boolean;
|
|
21
|
+
searchProgress: number;
|
|
22
|
+
clearSearch: () => void;
|
|
23
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type ActionType = 'ROTATE_CW' | 'ROTATE_CCW' | 'UNDO' | 'REDO' | 'DELETE' | 'COPY' | 'PASTE' | 'FILE_PICKER' | 'SEARCH';
|
|
2
|
+
export interface Shortcut {
|
|
3
|
+
action: ActionType;
|
|
4
|
+
description: string;
|
|
5
|
+
defaultCommand: string;
|
|
6
|
+
command: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function useShortcuts(): {
|
|
9
|
+
shortcuts: Shortcut[];
|
|
10
|
+
updateShortcut: (action: ActionType, newCommand: string) => void;
|
|
11
|
+
getCommand: (action: ActionType) => string;
|
|
12
|
+
};
|
|
13
|
+
export declare function matchShortcut(e: KeyboardEvent, commandString: string): boolean;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ViewerBus, BusListener } from '../core/eventBus';
|
|
2
|
+
export declare function useViewerBus(): ViewerBus;
|
|
3
|
+
/**
|
|
4
|
+
* Subscribe to a bus event for the lifetime of the component.
|
|
5
|
+
* The latest `listener` is always invoked (no stale closures) without re-subscribing on every render.
|
|
6
|
+
*/
|
|
7
|
+
export declare function useBusEvent<T = unknown>(type: string, listener: BusListener<T>): void;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* © 2026 AngelBot Ai Pvt Ltd. All rights reserved.
|
|
3
|
+
* TeamSync PDF Viewer SDK — public entry point.
|
|
4
|
+
*
|
|
5
|
+
* This module is side-effect free: importing it never touches `window`/`document`, so it is safe
|
|
6
|
+
* to import under SSR. Mount with `createWebViewer()` or render `<TeamSyncViewer>` on the client.
|
|
7
|
+
*/
|
|
8
|
+
export { createWebViewer, WebViewer } from './core/createWebViewer';
|
|
9
|
+
export { WebViewerInstance } from './core/ViewerInstance';
|
|
10
|
+
export { TeamSyncViewer } from './components/TeamSyncViewer';
|
|
11
|
+
export type { TeamSyncViewerProps } from './components/TeamSyncViewer';
|
|
12
|
+
export { configurePdfAssets, getPdfAssetPaths, isWorkerConfigured, pdfjsVersion } from './core/pdfAssets';
|
|
13
|
+
export type { PdfAssetPaths } from './core/pdfAssets';
|
|
14
|
+
export { ViewerBus } from './core/eventBus';
|
|
15
|
+
export type { BusListener } from './core/eventBus';
|
|
16
|
+
export { buildPdfBytes, MAX_EXPORT_BYTES } from './core/export';
|
|
17
|
+
export type { ExportInput, ExportOptions } from './core/export';
|
|
18
|
+
export type { WebViewerOptions, Redaction, WatermarkOptions, SDKPermissions, ViewerUser, InitialScale, ViewerEventMap, ViewerEventType, } from './core/types';
|
|
19
|
+
export type { Annotation, AnnotationType, AnnotationPoint } from './annotations/types';
|
|
20
|
+
export * from './plugins/types';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './types';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
export interface PluginContext {
|
|
3
|
+
activeTool: string | null;
|
|
4
|
+
setActiveTool: (tool: string | null) => void;
|
|
5
|
+
annotations: any[];
|
|
6
|
+
setAnnotations: React.Dispatch<React.SetStateAction<any[]>>;
|
|
7
|
+
commitAnnotations: (anns: any[]) => void;
|
|
8
|
+
scale: number;
|
|
9
|
+
pdfDoc: any;
|
|
10
|
+
permissions?: any;
|
|
11
|
+
initialDoc?: string;
|
|
12
|
+
watermark?: any;
|
|
13
|
+
}
|
|
14
|
+
export interface ViewerPlugin {
|
|
15
|
+
id: string;
|
|
16
|
+
name: string;
|
|
17
|
+
renderHeaderActions?: (context: PluginContext) => React.ReactNode;
|
|
18
|
+
renderModals?: (context: PluginContext) => React.ReactNode;
|
|
19
|
+
onInit?: (context: PluginContext) => void;
|
|
20
|
+
onBeforeSave?: (pdfBytes: Uint8Array, context: PluginContext) => Promise<Uint8Array>;
|
|
21
|
+
}
|
|
22
|
+
export interface DigitalSignerOptions {
|
|
23
|
+
allowedTypes?: Array<'digital' | 'ades' | 'simple'>;
|
|
24
|
+
usbBridgeUrl?: string;
|
|
25
|
+
defaultSignerName?: string;
|
|
26
|
+
}
|