teamsync-pdf-viewer 1.1.0 → 1.2.1
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 +47 -0
- package/README.md +185 -165
- package/dist/src/annotations/AnnotationManager.d.ts +90 -0
- package/dist/src/annotations/geometry.d.ts +51 -0
- package/dist/src/annotations/ids.d.ts +6 -0
- package/dist/src/annotations/types.d.ts +28 -1
- package/dist/src/annotations/xfdf.d.ts +18 -0
- package/dist/src/components/CompareCurtainSlider.d.ts +8 -0
- package/dist/src/components/CompareToolbar.d.ts +13 -0
- package/dist/src/components/DiffHighlightOverlay.d.ts +11 -0
- package/dist/src/components/DiffSummarySidebar.d.ts +13 -0
- package/dist/src/components/DocumentViewer.d.ts +4 -1
- package/dist/src/components/Header.d.ts +2 -1
- package/dist/src/components/SideBySideViewer.d.ts +29 -0
- package/dist/src/core/ViewerInstance.d.ts +12 -6
- package/dist/src/core/export.d.ts +4 -1
- package/dist/src/core/print.d.ts +12 -0
- package/dist/src/core/types.d.ts +5 -0
- package/dist/src/index.d.ts +12 -1
- package/dist/src/types/compare.d.ts +56 -0
- package/dist/src/utils/pdfDiffEngine.d.ts +37 -0
- package/dist/style.css +1 -1
- package/dist/teamsync-pdf-viewer.js +4006 -1655
- package/dist/teamsync-pdf-viewer.js.map +1 -1
- package/package.json +2 -2
|
@@ -6,7 +6,13 @@
|
|
|
6
6
|
* /Rotate applied (top-left origin, PDF points). UI rotation applied by the viewer is composed on
|
|
7
7
|
* top of this space at render time, so stored annotations are independent of the current view.
|
|
8
8
|
*/
|
|
9
|
-
export type AnnotationType = 'rectangle' | 'ellipse' | 'line' | 'arrow' | 'freehand' | 'text' | 'note' | 'callout' | 'signature' | 'highlight' | 'digital_signature_placeholder' | 'link'
|
|
9
|
+
export type AnnotationType = 'rectangle' | 'ellipse' | 'line' | 'arrow' | 'freehand' | 'text' | 'note' | 'callout' | 'signature' | 'highlight' | 'digital_signature_placeholder' | 'link'
|
|
10
|
+
/**
|
|
11
|
+
* An annotation imported from XFDF that this viewer cannot edit or render natively (e.g.
|
|
12
|
+
* underline, squiggly, polygon, redaction). It is drawn as a read-only outline at its bounding
|
|
13
|
+
* box and re-exported verbatim (`rawXfdf`) so nothing is lost on a save round-trip.
|
|
14
|
+
*/
|
|
15
|
+
| 'opaque';
|
|
10
16
|
export interface AnnotationPoint {
|
|
11
17
|
x: number;
|
|
12
18
|
y: number;
|
|
@@ -42,4 +48,25 @@ export interface Annotation {
|
|
|
42
48
|
authorId?: string;
|
|
43
49
|
/** When true the annotation cannot be moved, edited or deleted in the UI. */
|
|
44
50
|
readOnly?: boolean;
|
|
51
|
+
/** Multi-stroke ink (each stroke a polyline). `points` holds the first stroke for legacy consumers. */
|
|
52
|
+
strokes?: AnnotationPoint[][];
|
|
53
|
+
/** ISO-8601 timestamps (XFDF creationdate / date). */
|
|
54
|
+
createdAt?: string;
|
|
55
|
+
modifiedAt?: string;
|
|
56
|
+
/** Subject / XFDF element name of an opaque annotation (informational). */
|
|
57
|
+
opaqueKind?: string;
|
|
58
|
+
/** Verbatim XFDF element for `opaque` annotations. */
|
|
59
|
+
rawXfdf?: string;
|
|
60
|
+
/**
|
|
61
|
+
* XFDF attributes and child elements this viewer does not model (e.g. Apryse `trn-custom-data`,
|
|
62
|
+
* `defaultappearance`). Preserved on import and re-emitted on export so other viewers keep
|
|
63
|
+
* their metadata across a round-trip.
|
|
64
|
+
*/
|
|
65
|
+
xfdfExtras?: {
|
|
66
|
+
attrs?: Record<string, string>;
|
|
67
|
+
children?: string[];
|
|
68
|
+
};
|
|
45
69
|
}
|
|
70
|
+
export type AnnotationInput = Omit<Annotation, 'id'> & {
|
|
71
|
+
id?: string;
|
|
72
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Annotation } from './types';
|
|
2
|
+
import { GeometryResolver } from './geometry';
|
|
3
|
+
export declare const XFDF_NS = "http://ns.adobe.com/xfdf/";
|
|
4
|
+
export interface XfdfExportOptions {
|
|
5
|
+
/** Annotations to serialize (default: all given). */
|
|
6
|
+
annotList?: Annotation[];
|
|
7
|
+
/** Write the author's display name into `title` (default true). */
|
|
8
|
+
useDisplayAuthor?: boolean;
|
|
9
|
+
}
|
|
10
|
+
/** ISO-8601 -> PDF date `D:YYYYMMDDHHmmSS+HH'mm'`. */
|
|
11
|
+
export declare function toPdfDate(iso: string | undefined): string;
|
|
12
|
+
/** PDF date -> ISO-8601 (best effort; returns undefined when unparseable). */
|
|
13
|
+
export declare function fromPdfDate(pdf: string | null | undefined): string | undefined;
|
|
14
|
+
/** Serialize one annotation to an XFDF element (no envelope). */
|
|
15
|
+
export declare function annotationToXfdfFragment(a: Annotation, resolve: GeometryResolver, opts?: XfdfExportOptions): Promise<string>;
|
|
16
|
+
/** Serialize annotations to a complete XFDF document. */
|
|
17
|
+
export declare function annotationsToXfdf(annotations: Annotation[], resolve: GeometryResolver, opts?: XfdfExportOptions): Promise<string>;
|
|
18
|
+
export declare function parseXfdf(xml: string, resolve: GeometryResolver): Promise<Annotation[]>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
interface CompareCurtainSliderProps {
|
|
3
|
+
positionPercent: number;
|
|
4
|
+
onChangePosition: (pos: number) => void;
|
|
5
|
+
containerRef: React.RefObject<HTMLDivElement | null>;
|
|
6
|
+
}
|
|
7
|
+
export default function CompareCurtainSlider({ positionPercent, onChangePosition, containerRef }: CompareCurtainSliderProps): React.JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { CompareMode, CompareState } from '../types/compare';
|
|
3
|
+
interface CompareToolbarProps {
|
|
4
|
+
compareState: CompareState;
|
|
5
|
+
onSetMode: (mode: CompareMode) => void;
|
|
6
|
+
onSetColors: (colorA: string, colorB: string) => void;
|
|
7
|
+
onToggleCurtain: () => void;
|
|
8
|
+
onPrevDiff: () => void;
|
|
9
|
+
onNextDiff: () => void;
|
|
10
|
+
onExit: () => void;
|
|
11
|
+
}
|
|
12
|
+
export default function CompareToolbar({ compareState, onSetMode, onSetColors, onToggleCurtain, onPrevDiff, onNextDiff, onExit }: CompareToolbarProps): React.JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { DiffBoundingBox } from '../types/compare';
|
|
3
|
+
interface DiffHighlightOverlayProps {
|
|
4
|
+
boxes: DiffBoundingBox[];
|
|
5
|
+
scale: number;
|
|
6
|
+
colorScheme?: 'deletions' | 'additions' | 'all';
|
|
7
|
+
selectedDiffId?: string | null;
|
|
8
|
+
onSelectDiff?: (id: string) => void;
|
|
9
|
+
}
|
|
10
|
+
export default function DiffHighlightOverlay({ boxes, scale, colorScheme, selectedDiffId, onSelectDiff }: DiffHighlightOverlayProps): React.JSX.Element | null;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { DiffItem, TextDiffSegment } from '../types/compare';
|
|
3
|
+
interface DiffSummarySidebarProps {
|
|
4
|
+
isOpen: boolean;
|
|
5
|
+
onClose: () => void;
|
|
6
|
+
diffItems: DiffItem[];
|
|
7
|
+
textDiffs: TextDiffSegment[];
|
|
8
|
+
currentDiffIndex: number;
|
|
9
|
+
onSelectDiff: (index: number) => void;
|
|
10
|
+
onJumpToPage: (pageIndex: number) => void;
|
|
11
|
+
}
|
|
12
|
+
export default function DiffSummarySidebar({ isOpen, diffItems, textDiffs, currentDiffIndex, onSelectDiff, onJumpToPage }: DiffSummarySidebarProps): React.JSX.Element | null;
|
|
13
|
+
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { Annotation } from '../annotations/types';
|
|
3
|
+
import { AnnotationManager } from '../annotations/AnnotationManager';
|
|
3
4
|
import { Redaction, WatermarkOptions, SDKPermissions, PdfAssetPaths } from '../core/types';
|
|
4
5
|
import * as pdfjsLib from 'pdfjs-dist';
|
|
5
6
|
export interface DocumentLoadErrorInfo {
|
|
@@ -10,6 +11,8 @@ interface DocumentViewerProps {
|
|
|
10
11
|
leftSidebarOpen: boolean;
|
|
11
12
|
rightSidebarOpen: boolean;
|
|
12
13
|
activeTab: string;
|
|
14
|
+
/** Canonical annotation list, history, permissions and XFDF (owned by the viewer instance). */
|
|
15
|
+
annotationManager: AnnotationManager;
|
|
13
16
|
initialDoc?: string;
|
|
14
17
|
/** Bump to force a reload of the same URL (retry after a load error). */
|
|
15
18
|
loadNonce?: number;
|
|
@@ -43,5 +46,5 @@ interface DocumentViewerProps {
|
|
|
43
46
|
initialPage?: number;
|
|
44
47
|
permissions?: SDKPermissions;
|
|
45
48
|
}
|
|
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;
|
|
49
|
+
export default function DocumentViewer({ leftSidebarOpen, rightSidebarOpen, activeTab, annotationManager, 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
50
|
export {};
|
|
@@ -16,6 +16,7 @@ interface HeaderProps {
|
|
|
16
16
|
onDownload: () => void;
|
|
17
17
|
onFullScreen: () => void;
|
|
18
18
|
onSaveAs: () => void;
|
|
19
|
+
onPrint?: () => void;
|
|
19
20
|
onOpenSettings: () => void;
|
|
20
21
|
onOpenAbout: () => void;
|
|
21
22
|
onOpenSidebarTab: (tab: 'Comments' | 'Search') => void;
|
|
@@ -31,5 +32,5 @@ interface HeaderProps {
|
|
|
31
32
|
plugins?: ViewerPlugin[];
|
|
32
33
|
permissions?: SDKPermissions;
|
|
33
34
|
}
|
|
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 default function Header({ activeTab, setActiveTab, leftSidebarOpen, setLeftSidebarOpen, rightSidebarOpen, setRightSidebarOpen: _setRightSidebarOpen, sidebarTab, scale, onZoomIn, onZoomOut, onZoomSet, onDownload, onFullScreen, onSaveAs, onPrint, onOpenSettings, onOpenAbout, onOpenSidebarTab, pageTransition, setPageTransition, pageLayout, setPageLayout, rotation, setRotation, signatureCount, enableAnnotations, enableSign, plugins, permissions }: HeaderProps): React.JSX.Element;
|
|
35
36
|
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { SDKPermissions, WatermarkOptions, Redaction } from '../core/types';
|
|
3
|
+
import { DiffBoundingBox } from '../types/compare';
|
|
4
|
+
import * as pdfjsLib from 'pdfjs-dist';
|
|
5
|
+
interface SideBySideViewerProps {
|
|
6
|
+
pdfDocA: pdfjsLib.PDFDocumentProxy | null;
|
|
7
|
+
pdfDocB: pdfjsLib.PDFDocumentProxy | null;
|
|
8
|
+
pageNum: number;
|
|
9
|
+
scale: number;
|
|
10
|
+
rotation: number;
|
|
11
|
+
basePageDims: {
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
14
|
+
};
|
|
15
|
+
activeTab: string;
|
|
16
|
+
activeTool: string | null;
|
|
17
|
+
annotations: any[];
|
|
18
|
+
permissions?: SDKPermissions;
|
|
19
|
+
watermark?: WatermarkOptions;
|
|
20
|
+
watermarkText?: string;
|
|
21
|
+
redactions?: Redaction[];
|
|
22
|
+
diffsA?: DiffBoundingBox[];
|
|
23
|
+
diffsB?: DiffBoundingBox[];
|
|
24
|
+
selectedDiffId?: string | null;
|
|
25
|
+
onSelectDiff?: (id: string) => void;
|
|
26
|
+
onScrollSync?: (scrollTop: number, scrollLeft: number) => void;
|
|
27
|
+
}
|
|
28
|
+
export default function SideBySideViewer({ pdfDocA, pdfDocB, pageNum, scale, rotation, basePageDims, activeTab, activeTool, annotations, watermark, watermarkText, redactions, diffsA, diffsB, selectedDiffId, onSelectDiff }: SideBySideViewerProps): React.JSX.Element;
|
|
29
|
+
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ViewerBus } from './eventBus';
|
|
2
2
|
import { ExportOptions } from './export';
|
|
3
3
|
import { Annotation } from '../annotations/types';
|
|
4
|
+
import { AnnotationManager } from '../annotations/AnnotationManager';
|
|
4
5
|
import { Redaction, WatermarkOptions, ViewerEventMap, ViewerEventType } from './types';
|
|
5
6
|
/**
|
|
6
7
|
* © 2026 AngelBot Ai Pvt Ltd. All rights reserved.
|
|
@@ -23,12 +24,14 @@ export interface ViewerBinding {
|
|
|
23
24
|
}
|
|
24
25
|
export declare class WebViewerInstance {
|
|
25
26
|
readonly bus: ViewerBus;
|
|
27
|
+
/** Annotation list, history, permissions and XFDF import/export. */
|
|
28
|
+
readonly annotationManager: AnnotationManager;
|
|
26
29
|
/** Root element of the viewer once mounted. */
|
|
27
30
|
element: HTMLElement | null;
|
|
28
31
|
private binding;
|
|
29
32
|
private unmountRoot;
|
|
30
33
|
private destroyed;
|
|
31
|
-
constructor(bus: ViewerBus);
|
|
34
|
+
constructor(bus: ViewerBus, annotationManager?: AnnotationManager);
|
|
32
35
|
/** @internal */
|
|
33
36
|
_bind(binding: ViewerBinding, element: HTMLElement | null): void;
|
|
34
37
|
/** @internal */
|
|
@@ -54,6 +57,8 @@ export declare class WebViewerInstance {
|
|
|
54
57
|
getCurrentPage(): number;
|
|
55
58
|
getPageCount(): number;
|
|
56
59
|
getAnnotations(): Annotation[];
|
|
60
|
+
/** Print the exported document (annotations, redactions and watermark baked in). */
|
|
61
|
+
print(): void;
|
|
57
62
|
/**
|
|
58
63
|
* Build the exported PDF (annotations + watermark baked, redacted pages rasterized).
|
|
59
64
|
* Uses the bytes of the loaded document; never re-fetches the URL.
|
|
@@ -72,13 +77,14 @@ export declare class WebViewerInstance {
|
|
|
72
77
|
fitPage: () => void;
|
|
73
78
|
fitToWidth: () => void;
|
|
74
79
|
fitToPage: () => void;
|
|
80
|
+
startCompare: (docA: any, docB: any, options?: any) => void;
|
|
81
|
+
stopCompare: () => void;
|
|
82
|
+
setCompareMode: (mode: "overlay" | "side-by-side" | "semantic") => void;
|
|
83
|
+
setCompareColors: (colorA: string, colorB: string) => void;
|
|
75
84
|
};
|
|
76
85
|
readonly Core: {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
exportAnnotations: () => string;
|
|
80
|
-
getAnnotationsList: () => Annotation[];
|
|
81
|
-
};
|
|
86
|
+
/** The real AnnotationManager (XFDF import/export, granular events, permissions). */
|
|
87
|
+
readonly annotationManager: AnnotationManager;
|
|
82
88
|
documentViewer: {
|
|
83
89
|
addEventListener: (event: string, callback: (detail: unknown) => void) => (() => void);
|
|
84
90
|
removeEventListener: (event: string, callback: (detail: unknown) => void) => void;
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { Annotation } from '../annotations/types';
|
|
2
2
|
import { Redaction, WatermarkOptions } from './types';
|
|
3
|
+
import { GeometryResolver } from '../annotations/geometry';
|
|
3
4
|
/** Refuse to build documents larger than this in the browser (memory safety). */
|
|
4
5
|
export declare const MAX_EXPORT_BYTES: number;
|
|
5
6
|
export interface ExportInput {
|
|
6
7
|
/** Returns the original document bytes (prefer `pdfDocument.getData()`). */
|
|
7
8
|
getSourceBytes: () => Promise<Uint8Array | ArrayBuffer>;
|
|
9
|
+
/** Page geometry resolver (from the loaded pdf.js document). Derived from the bytes when absent. */
|
|
10
|
+
getPageGeometry?: GeometryResolver;
|
|
8
11
|
annotations: Annotation[];
|
|
9
12
|
redactions: Redaction[];
|
|
10
13
|
watermark?: WatermarkOptions;
|
|
@@ -14,7 +17,7 @@ export interface ExportInput {
|
|
|
14
17
|
export interface ExportOptions {
|
|
15
18
|
/** Bake exactly these annotations instead of the live list. */
|
|
16
19
|
explicitAnnotations?: Annotation[];
|
|
17
|
-
/** Accepted for API compatibility
|
|
20
|
+
/** Accepted for API compatibility; annotations are always taken from the live list / explicitAnnotations. */
|
|
18
21
|
xfdfString?: string;
|
|
19
22
|
}
|
|
20
23
|
export declare function buildPdfBytes(input: ExportInput, options?: ExportOptions): Promise<Uint8Array>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* © 2026 AngelBot Ai Pvt Ltd. All rights reserved.
|
|
3
|
+
* Printing: the exported document (annotations / redactions / watermark baked in) is loaded into a
|
|
4
|
+
* hidden iframe and printed through the browser's PDF viewer. Falls back to opening the PDF in a
|
|
5
|
+
* new tab when the frame cannot print (e.g. the browser has no inline PDF viewer).
|
|
6
|
+
*/
|
|
7
|
+
export interface PrintOptions {
|
|
8
|
+
title?: string;
|
|
9
|
+
/** How long the hidden frame is kept alive for the print dialog (default 60s). */
|
|
10
|
+
timeoutMs?: number;
|
|
11
|
+
}
|
|
12
|
+
export declare function printPdfBytes(bytes: Uint8Array, opts?: PrintOptions): Promise<void>;
|
package/dist/src/core/types.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ViewerPlugin } from '../plugins/types';
|
|
2
2
|
import { Annotation } from '../annotations/types';
|
|
3
|
+
import { AnnotationChangedEvent } from '../annotations/AnnotationManager';
|
|
3
4
|
import { PdfAssetPaths } from './pdfAssets';
|
|
4
5
|
export type { PdfAssetPaths };
|
|
5
6
|
export interface Redaction {
|
|
@@ -24,6 +25,8 @@ export interface SDKPermissions {
|
|
|
24
25
|
canEditAnnotations?: boolean;
|
|
25
26
|
canDeleteAnnotations?: boolean;
|
|
26
27
|
canRedact?: boolean;
|
|
28
|
+
/** Allow editing/deleting annotations authored by other users (default false). */
|
|
29
|
+
canEditOthers?: boolean;
|
|
27
30
|
}
|
|
28
31
|
export interface ViewerUser {
|
|
29
32
|
id: string;
|
|
@@ -95,6 +98,8 @@ export interface ViewerEventMap {
|
|
|
95
98
|
annotationsChanged: {
|
|
96
99
|
annotations: Annotation[];
|
|
97
100
|
};
|
|
101
|
+
/** Granular add / modify / delete (with the `imported` flag) from the AnnotationManager. */
|
|
102
|
+
annotationChanged: AnnotationChangedEvent;
|
|
98
103
|
toolChanged: {
|
|
99
104
|
tool: string | null;
|
|
100
105
|
};
|
package/dist/src/index.d.ts
CHANGED
|
@@ -9,6 +9,8 @@ export { createWebViewer, WebViewer } from './core/createWebViewer';
|
|
|
9
9
|
export { WebViewerInstance } from './core/ViewerInstance';
|
|
10
10
|
export { TeamSyncViewer } from './components/TeamSyncViewer';
|
|
11
11
|
export type { TeamSyncViewerProps } from './components/TeamSyncViewer';
|
|
12
|
+
export * from './types/compare';
|
|
13
|
+
export * from './utils/pdfDiffEngine';
|
|
12
14
|
export { configurePdfAssets, getPdfAssetPaths, isWorkerConfigured, pdfjsVersion } from './core/pdfAssets';
|
|
13
15
|
export type { PdfAssetPaths } from './core/pdfAssets';
|
|
14
16
|
export { ViewerBus } from './core/eventBus';
|
|
@@ -16,5 +18,14 @@ export type { BusListener } from './core/eventBus';
|
|
|
16
18
|
export { buildPdfBytes, MAX_EXPORT_BYTES } from './core/export';
|
|
17
19
|
export type { ExportInput, ExportOptions } from './core/export';
|
|
18
20
|
export type { WebViewerOptions, Redaction, WatermarkOptions, SDKPermissions, ViewerUser, InitialScale, ViewerEventMap, ViewerEventType, } from './core/types';
|
|
19
|
-
export type { Annotation, AnnotationType, AnnotationPoint } from './annotations/types';
|
|
21
|
+
export type { Annotation, AnnotationType, AnnotationPoint, AnnotationInput } from './annotations/types';
|
|
22
|
+
export { AnnotationManager } from './annotations/AnnotationManager';
|
|
23
|
+
export type { AnnotationAction, AnnotationChangedEvent, CommitOptions, ViewerUserInfo } from './annotations/AnnotationManager';
|
|
24
|
+
export { newAnnotationId } from './annotations/ids';
|
|
25
|
+
export { createPageGeometry, geometryFromPage, createGeometryResolver, toPdfPoint, fromPdfPoint, rectToPdf, rectFromPdf, rectToQuadPoints, quadPointsToRects, } from './annotations/geometry';
|
|
26
|
+
export type { PageGeometry, GeometryResolver, PdfRect, Rect, Point } from './annotations/geometry';
|
|
27
|
+
export { annotationsToXfdf, annotationToXfdfFragment, parseXfdf, toPdfDate, fromPdfDate, XFDF_NS } from './annotations/xfdf';
|
|
28
|
+
export type { XfdfExportOptions } from './annotations/xfdf';
|
|
29
|
+
export { printPdfBytes } from './core/print';
|
|
30
|
+
export type { PrintOptions } from './core/print';
|
|
20
31
|
export * from './plugins/types';
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* © 2026 AngelBot Ai Pvt Ltd. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
export type CompareMode = 'overlay' | 'side-by-side' | 'semantic';
|
|
5
|
+
export interface CompareOptions {
|
|
6
|
+
docA?: string | ArrayBuffer | Uint8Array;
|
|
7
|
+
docB?: string | ArrayBuffer | Uint8Array;
|
|
8
|
+
mode?: CompareMode;
|
|
9
|
+
colorA?: string;
|
|
10
|
+
colorB?: string;
|
|
11
|
+
opacityA?: number;
|
|
12
|
+
opacityB?: number;
|
|
13
|
+
blendMode?: 'multiply' | 'difference' | 'screen' | 'normal';
|
|
14
|
+
}
|
|
15
|
+
export interface TextDiffSegment {
|
|
16
|
+
type: 'equal' | 'add' | 'delete';
|
|
17
|
+
text: string;
|
|
18
|
+
pageIndex: number;
|
|
19
|
+
}
|
|
20
|
+
export interface DiffBoundingBox {
|
|
21
|
+
id: string;
|
|
22
|
+
pageIndex: number;
|
|
23
|
+
type: 'addition' | 'deletion' | 'modification';
|
|
24
|
+
text: string;
|
|
25
|
+
x: number;
|
|
26
|
+
y: number;
|
|
27
|
+
width: number;
|
|
28
|
+
height: number;
|
|
29
|
+
}
|
|
30
|
+
export interface DiffItem {
|
|
31
|
+
id: string;
|
|
32
|
+
pageIndex: number;
|
|
33
|
+
type: 'addition' | 'deletion' | 'modification';
|
|
34
|
+
description: string;
|
|
35
|
+
x?: number;
|
|
36
|
+
y?: number;
|
|
37
|
+
width?: number;
|
|
38
|
+
height?: number;
|
|
39
|
+
}
|
|
40
|
+
export interface CompareState {
|
|
41
|
+
isActive: boolean;
|
|
42
|
+
docA?: string | ArrayBuffer | Uint8Array;
|
|
43
|
+
docB?: string | ArrayBuffer | Uint8Array;
|
|
44
|
+
mode: CompareMode;
|
|
45
|
+
colorA: string;
|
|
46
|
+
colorB: string;
|
|
47
|
+
opacityA: number;
|
|
48
|
+
opacityB: number;
|
|
49
|
+
blendMode: 'multiply' | 'difference' | 'screen' | 'normal';
|
|
50
|
+
curtainPosition: number;
|
|
51
|
+
showCurtain: boolean;
|
|
52
|
+
diffItems: DiffItem[];
|
|
53
|
+
currentDiffIndex: number;
|
|
54
|
+
pageDiffsA?: Record<number, DiffBoundingBox[]>;
|
|
55
|
+
pageDiffsB?: Record<number, DiffBoundingBox[]>;
|
|
56
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { TextDiffSegment, DiffItem, DiffBoundingBox } from '../types/compare';
|
|
2
|
+
/**
|
|
3
|
+
* © 2026 AngelBot Ai Pvt Ltd. All rights reserved.
|
|
4
|
+
*/
|
|
5
|
+
import type * as pdfjsLib from 'pdfjs-dist';
|
|
6
|
+
export interface PageDiffResult {
|
|
7
|
+
diffsA: DiffBoundingBox[];
|
|
8
|
+
diffsB: DiffBoundingBox[];
|
|
9
|
+
summary: DiffItem[];
|
|
10
|
+
}
|
|
11
|
+
export interface WordToken {
|
|
12
|
+
text: string;
|
|
13
|
+
x: number;
|
|
14
|
+
y: number;
|
|
15
|
+
width: number;
|
|
16
|
+
height: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Extracts individual words with precise unscaled viewport bounding boxes from a PDF.js page.
|
|
20
|
+
*/
|
|
21
|
+
export declare function extractWordsFromPage(page: pdfjsLib.PDFPageProxy): Promise<WordToken[]>;
|
|
22
|
+
/**
|
|
23
|
+
* Computes exact text difference bounding boxes on a page for both Document A and Document B.
|
|
24
|
+
*/
|
|
25
|
+
export declare function computePageDiffBoxes(pdfDocA: pdfjsLib.PDFDocumentProxy, pdfDocB: pdfjsLib.PDFDocumentProxy, pageIndex: number): Promise<PageDiffResult>;
|
|
26
|
+
/**
|
|
27
|
+
* Lightweight client-side Myers Diff algorithm for raw text comparison.
|
|
28
|
+
*/
|
|
29
|
+
export declare function computeTextDiff(textA: string, textB: string, pageIndex: number): TextDiffSegment[];
|
|
30
|
+
/**
|
|
31
|
+
* Colorizes a rendered page canvas with a custom hex tint.
|
|
32
|
+
*/
|
|
33
|
+
export declare function tintCanvas(ctx: CanvasRenderingContext2D, width: number, height: number, colorHex: string, opacity?: number): void;
|
|
34
|
+
/**
|
|
35
|
+
* Computes pixel-level difference bounding boxes between two rendered page canvases.
|
|
36
|
+
*/
|
|
37
|
+
export declare function computeCanvasPixelDiff(canvasA: HTMLCanvasElement, canvasB: HTMLCanvasElement, pageIndex: number, scale: number): DiffItem[];
|