pdf-tsx 0.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/LICENSE +21 -0
- package/README.md +190 -0
- package/dist/cjs/_virtual/_rolldown/runtime.cjs +1 -0
- package/dist/cjs/components/PDFSidebar.cjs +1 -0
- package/dist/cjs/components/PDFSidebar.module.cjs +1 -0
- package/dist/cjs/components/PDFViewer.cjs +1 -0
- package/dist/cjs/components/PDFViewer.module.cjs +1 -0
- package/dist/cjs/components/features/PDFAnnotations.cjs +1 -0
- package/dist/cjs/components/features/PDFAnnotations.module.cjs +1 -0
- package/dist/cjs/components/features/PDFChangeFile.cjs +1 -0
- package/dist/cjs/components/features/PDFDownloadButton.cjs +1 -0
- package/dist/cjs/components/features/PDFNavigation.cjs +1 -0
- package/dist/cjs/components/features/PDFNavigation.module.cjs +1 -0
- package/dist/cjs/components/features/PDFOutline.cjs +1 -0
- package/dist/cjs/components/features/PDFOutline.module.cjs +1 -0
- package/dist/cjs/components/features/PDFPageFit.cjs +1 -0
- package/dist/cjs/components/features/PDFPrintButton.cjs +1 -0
- package/dist/cjs/components/features/PDFRotationControl.cjs +1 -0
- package/dist/cjs/components/features/PDFSearch.cjs +1 -0
- package/dist/cjs/components/features/PDFSearch.module.cjs +1 -0
- package/dist/cjs/components/features/PDFSignatures.cjs +1 -0
- package/dist/cjs/components/features/PDFSignatures.module.cjs +1 -0
- package/dist/cjs/components/features/PDFThemeToggle.cjs +1 -0
- package/dist/cjs/components/features/PDFThumbnails.cjs +1 -0
- package/dist/cjs/components/features/PDFThumbnails.module.cjs +1 -0
- package/dist/cjs/components/features/PDFZoomControls.cjs +1 -0
- package/dist/cjs/components/features/PDFZoomControls.module.cjs +1 -0
- package/dist/cjs/components/ui/ToolbarButton.cjs +1 -0
- package/dist/cjs/components/ui/ToolbarButton.module.cjs +1 -0
- package/dist/cjs/components/ui/icons.cjs +1 -0
- package/dist/cjs/context/PDFViewerContext.cjs +1 -0
- package/dist/cjs/context/ThemeContext.cjs +1 -0
- package/dist/cjs/hooks/useAnnotationLayer.cjs +1 -0
- package/dist/cjs/hooks/useAnnotations.cjs +1 -0
- package/dist/cjs/hooks/useKeyboardShortcuts.cjs +1 -0
- package/dist/cjs/hooks/useOutline.cjs +1 -0
- package/dist/cjs/hooks/useScrollTracking.cjs +1 -0
- package/dist/cjs/hooks/useSignatures.cjs +1 -0
- package/dist/cjs/hooks/useTextLayer.cjs +1 -0
- package/dist/cjs/hooks/useTextSearch.cjs +1 -0
- package/dist/cjs/hooks/useThumbnails.cjs +1 -0
- package/dist/cjs/index.cjs +1 -0
- package/dist/cjs/node_modules/react/cjs/react-compiler-runtime.development.cjs +5 -0
- package/dist/cjs/node_modules/react/cjs/react-compiler-runtime.production.cjs +1 -0
- package/dist/cjs/node_modules/react/compiler-runtime.cjs +1 -0
- package/dist/cjs/pdf-tsx.css +2 -0
- package/dist/cjs/theme.cjs +1 -0
- package/dist/cjs/utils/url.cjs +1 -0
- package/dist/cjs/vite.svg +1 -0
- package/dist/components/PDFSidebar.d.ts +11 -0
- package/dist/components/PDFViewer.d.ts +10 -0
- package/dist/components/features/PDFAnnotations.d.ts +1 -0
- package/dist/components/features/PDFChangeFile.d.ts +6 -0
- package/dist/components/features/PDFDownloadButton.d.ts +6 -0
- package/dist/components/features/PDFNavigation.d.ts +7 -0
- package/dist/components/features/PDFOutline.d.ts +1 -0
- package/dist/components/features/PDFPageFit.d.ts +7 -0
- package/dist/components/features/PDFPrintButton.d.ts +6 -0
- package/dist/components/features/PDFRotationControl.d.ts +6 -0
- package/dist/components/features/PDFSearch.d.ts +9 -0
- package/dist/components/features/PDFSignatures.d.ts +1 -0
- package/dist/components/features/PDFThemeToggle.d.ts +7 -0
- package/dist/components/features/PDFThumbnails.d.ts +1 -0
- package/dist/components/features/PDFZoomControls.d.ts +7 -0
- package/dist/components/ui/ToolbarButton.d.ts +6 -0
- package/dist/components/ui/icons.d.ts +20 -0
- package/dist/context/PDFViewerContext.d.ts +25 -0
- package/dist/context/ThemeContext.d.ts +12 -0
- package/dist/es/_virtual/_rolldown/runtime.js +7 -0
- package/dist/es/components/PDFSidebar.js +43 -0
- package/dist/es/components/PDFSidebar.module.js +11 -0
- package/dist/es/components/PDFViewer.js +263 -0
- package/dist/es/components/PDFViewer.module.js +16 -0
- package/dist/es/components/features/PDFAnnotations.js +94 -0
- package/dist/es/components/features/PDFAnnotations.module.js +14 -0
- package/dist/es/components/features/PDFChangeFile.js +36 -0
- package/dist/es/components/features/PDFDownloadButton.js +23 -0
- package/dist/es/components/features/PDFNavigation.js +71 -0
- package/dist/es/components/features/PDFNavigation.module.js +7 -0
- package/dist/es/components/features/PDFOutline.js +101 -0
- package/dist/es/components/features/PDFOutline.module.js +9 -0
- package/dist/es/components/features/PDFPageFit.js +43 -0
- package/dist/es/components/features/PDFPrintButton.js +26 -0
- package/dist/es/components/features/PDFRotationControl.js +22 -0
- package/dist/es/components/features/PDFSearch.js +77 -0
- package/dist/es/components/features/PDFSearch.module.js +8 -0
- package/dist/es/components/features/PDFSignatures.js +133 -0
- package/dist/es/components/features/PDFSignatures.module.js +18 -0
- package/dist/es/components/features/PDFThemeToggle.js +17 -0
- package/dist/es/components/features/PDFThumbnails.js +40 -0
- package/dist/es/components/features/PDFThumbnails.module.js +11 -0
- package/dist/es/components/features/PDFZoomControls.js +47 -0
- package/dist/es/components/features/PDFZoomControls.module.js +3 -0
- package/dist/es/components/ui/ToolbarButton.js +16 -0
- package/dist/es/components/ui/ToolbarButton.module.js +6 -0
- package/dist/es/components/ui/icons.js +28 -0
- package/dist/es/context/PDFViewerContext.js +11 -0
- package/dist/es/context/ThemeContext.js +43 -0
- package/dist/es/hooks/useAnnotationLayer.js +71 -0
- package/dist/es/hooks/useAnnotations.js +44 -0
- package/dist/es/hooks/useKeyboardShortcuts.js +54 -0
- package/dist/es/hooks/useOutline.js +20 -0
- package/dist/es/hooks/useScrollTracking.js +46 -0
- package/dist/es/hooks/useSignatures.js +45 -0
- package/dist/es/hooks/useTextLayer.js +42 -0
- package/dist/es/hooks/useTextSearch.js +53 -0
- package/dist/es/hooks/useThumbnails.js +31 -0
- package/dist/es/index.js +16 -0
- package/dist/es/node_modules/react/cjs/react-compiler-runtime.development.js +14 -0
- package/dist/es/node_modules/react/cjs/react-compiler-runtime.production.js +11 -0
- package/dist/es/node_modules/react/compiler-runtime.js +10 -0
- package/dist/es/pdf-tsx.css +2 -0
- package/dist/es/theme.js +67 -0
- package/dist/es/utils/url.js +11 -0
- package/dist/es/vite.svg +1 -0
- package/dist/hooks/useAnnotationLayer.d.ts +20 -0
- package/dist/hooks/useAnnotations.d.ts +20 -0
- package/dist/hooks/useKeyboardShortcuts.d.ts +11 -0
- package/dist/hooks/useOutline.d.ts +14 -0
- package/dist/hooks/useScrollTracking.d.ts +14 -0
- package/dist/hooks/useSignatures.d.ts +17 -0
- package/dist/hooks/useTextLayer.d.ts +10 -0
- package/dist/hooks/useTextSearch.d.ts +12 -0
- package/dist/hooks/useThumbnails.d.ts +9 -0
- package/dist/index.d.ts +15 -0
- package/dist/pdf-tsx.cjs.js +5 -0
- package/dist/pdf-tsx.css +2 -0
- package/dist/pdf-tsx.es.js +2637 -0
- package/dist/theme.d.ts +24 -0
- package/dist/utils/url.d.ts +1 -0
- package/dist/vite.svg +1 -0
- package/package.json +60 -0
package/dist/es/theme.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
//#region src/theme.ts
|
|
2
|
+
var e = {
|
|
3
|
+
bg: "#18181b",
|
|
4
|
+
surface: "#27272a",
|
|
5
|
+
surfaceHover: "#3f3f46",
|
|
6
|
+
border: "#3f3f46",
|
|
7
|
+
borderLight: "#52525b",
|
|
8
|
+
scrollArea: "#525659",
|
|
9
|
+
textPrimary: "#fafafa",
|
|
10
|
+
textSecondary: "#a1a1aa",
|
|
11
|
+
textMuted: "#71717a",
|
|
12
|
+
textPlaceholder: "#52525b",
|
|
13
|
+
accent: "#3b82f6",
|
|
14
|
+
accentHover: "#2563eb",
|
|
15
|
+
accentDark: "#1d4ed8",
|
|
16
|
+
accentLight: "#60a5fa",
|
|
17
|
+
accentSubtle: "rgba(59, 130, 246, 0.15)",
|
|
18
|
+
panelBg: "#1f1f23",
|
|
19
|
+
panelBorder: "#27272a",
|
|
20
|
+
panelHeaderBg: "#18181b",
|
|
21
|
+
shadowPage: "rgba(0, 0, 0, 0.4)"
|
|
22
|
+
}, t = {
|
|
23
|
+
bg: "#f4f4f5",
|
|
24
|
+
surface: "#ffffff",
|
|
25
|
+
surfaceHover: "#f4f4f5",
|
|
26
|
+
border: "#e4e4e7",
|
|
27
|
+
borderLight: "#d4d4d8",
|
|
28
|
+
scrollArea: "#e4e4e7",
|
|
29
|
+
textPrimary: "#18181b",
|
|
30
|
+
textSecondary: "#52525b",
|
|
31
|
+
textMuted: "#71717a",
|
|
32
|
+
textPlaceholder: "#a1a1aa",
|
|
33
|
+
accent: "#3b82f6",
|
|
34
|
+
accentHover: "#2563eb",
|
|
35
|
+
accentDark: "#1d4ed8",
|
|
36
|
+
accentLight: "#60a5fa",
|
|
37
|
+
accentSubtle: "rgba(59, 130, 246, 0.1)",
|
|
38
|
+
panelBg: "#ffffff",
|
|
39
|
+
panelBorder: "#e4e4e7",
|
|
40
|
+
panelHeaderBg: "#fafafa",
|
|
41
|
+
shadowPage: "rgba(0, 0, 0, 0.12)"
|
|
42
|
+
};
|
|
43
|
+
function n(e) {
|
|
44
|
+
return {
|
|
45
|
+
"--pdf-bg": e.bg,
|
|
46
|
+
"--pdf-surface": e.surface,
|
|
47
|
+
"--pdf-surface-hover": e.surfaceHover,
|
|
48
|
+
"--pdf-border": e.border,
|
|
49
|
+
"--pdf-border-light": e.borderLight,
|
|
50
|
+
"--pdf-scroll-area": e.scrollArea,
|
|
51
|
+
"--pdf-text-primary": e.textPrimary,
|
|
52
|
+
"--pdf-text-secondary": e.textSecondary,
|
|
53
|
+
"--pdf-text-muted": e.textMuted,
|
|
54
|
+
"--pdf-text-placeholder": e.textPlaceholder,
|
|
55
|
+
"--pdf-accent": e.accent,
|
|
56
|
+
"--pdf-accent-hover": e.accentHover,
|
|
57
|
+
"--pdf-accent-dark": e.accentDark,
|
|
58
|
+
"--pdf-accent-light": e.accentLight,
|
|
59
|
+
"--pdf-accent-subtle": e.accentSubtle,
|
|
60
|
+
"--pdf-panel-bg": e.panelBg,
|
|
61
|
+
"--pdf-panel-border": e.panelBorder,
|
|
62
|
+
"--pdf-panel-header-bg": e.panelHeaderBg,
|
|
63
|
+
"--pdf-shadow-page": e.shadowPage
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
//#endregion
|
|
67
|
+
export { e as darkTheme, t as lightTheme, n as themeToCssVars };
|
package/dist/es/vite.svg
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as pdfjsLib from "pdfjs-dist";
|
|
2
|
+
export interface LinkOverlay {
|
|
3
|
+
page: number;
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
width: number;
|
|
7
|
+
height: number;
|
|
8
|
+
url?: string;
|
|
9
|
+
dest?: string | unknown[];
|
|
10
|
+
newWindow?: boolean;
|
|
11
|
+
}
|
|
12
|
+
interface UseAnnotationLayerOptions {
|
|
13
|
+
pdf: pdfjsLib.PDFDocumentProxy | null;
|
|
14
|
+
zoom: number;
|
|
15
|
+
rotation: number;
|
|
16
|
+
numPages: number;
|
|
17
|
+
goToPage: (page: number) => void;
|
|
18
|
+
}
|
|
19
|
+
export declare function useAnnotationLayer({ pdf, zoom, rotation, numPages, goToPage, }: UseAnnotationLayerOptions): LinkOverlay[];
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as pdfjsLib from "pdfjs-dist";
|
|
2
|
+
export interface PDFAnnotation {
|
|
3
|
+
id: string;
|
|
4
|
+
page: number;
|
|
5
|
+
subtype: string;
|
|
6
|
+
contents?: string;
|
|
7
|
+
title?: string;
|
|
8
|
+
color?: {
|
|
9
|
+
r: number;
|
|
10
|
+
g: number;
|
|
11
|
+
b: number;
|
|
12
|
+
};
|
|
13
|
+
rect?: [number, number, number, number];
|
|
14
|
+
}
|
|
15
|
+
export declare function useAnnotations({ pdf }: {
|
|
16
|
+
pdf: pdfjsLib.PDFDocumentProxy | null;
|
|
17
|
+
}): {
|
|
18
|
+
annotations: PDFAnnotation[];
|
|
19
|
+
loading: boolean;
|
|
20
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as pdfjsLib from "pdfjs-dist";
|
|
2
|
+
interface UseKeyboardShortcutsOptions {
|
|
3
|
+
pdf: pdfjsLib.PDFDocumentProxy | null;
|
|
4
|
+
currentPage: number;
|
|
5
|
+
numPages: number;
|
|
6
|
+
goToPage: (page: number) => void;
|
|
7
|
+
setZoom: React.Dispatch<React.SetStateAction<number>>;
|
|
8
|
+
setRotation: React.Dispatch<React.SetStateAction<number>>;
|
|
9
|
+
}
|
|
10
|
+
export declare function useKeyboardShortcuts({ pdf, currentPage, numPages, goToPage, setZoom, setRotation, }: UseKeyboardShortcutsOptions): void;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as pdfjsLib from "pdfjs-dist";
|
|
2
|
+
export interface OutlineNode {
|
|
3
|
+
title: string;
|
|
4
|
+
dest: string | unknown[] | null;
|
|
5
|
+
items: OutlineNode[];
|
|
6
|
+
bold: boolean;
|
|
7
|
+
italic: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare function useOutline({ pdf }: {
|
|
10
|
+
pdf: pdfjsLib.PDFDocumentProxy | null;
|
|
11
|
+
}): {
|
|
12
|
+
outline: OutlineNode[];
|
|
13
|
+
loading: boolean;
|
|
14
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as pdfjsLib from "pdfjs-dist";
|
|
2
|
+
interface UseScrollTrackingOptions {
|
|
3
|
+
pdf: pdfjsLib.PDFDocumentProxy | null;
|
|
4
|
+
numPages: number;
|
|
5
|
+
zoom: number;
|
|
6
|
+
rotation: number;
|
|
7
|
+
containerRef: React.RefObject<HTMLDivElement | null>;
|
|
8
|
+
canvasRefs: React.RefObject<(HTMLCanvasElement | null)[]>;
|
|
9
|
+
}
|
|
10
|
+
export declare function useScrollTracking({ pdf, numPages, zoom, rotation, containerRef, canvasRefs, }: UseScrollTrackingOptions): {
|
|
11
|
+
currentPage: number;
|
|
12
|
+
goToPage: (pageNum: number) => void;
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as pdfjsLib from "pdfjs-dist";
|
|
2
|
+
export interface PDFSignature {
|
|
3
|
+
fieldName: string;
|
|
4
|
+
page: number;
|
|
5
|
+
signed: boolean;
|
|
6
|
+
signerName?: string;
|
|
7
|
+
signDate?: string;
|
|
8
|
+
reason?: string;
|
|
9
|
+
location?: string;
|
|
10
|
+
rect?: [number, number, number, number];
|
|
11
|
+
}
|
|
12
|
+
export declare function useSignatures({ pdf }: {
|
|
13
|
+
pdf: pdfjsLib.PDFDocumentProxy | null;
|
|
14
|
+
}): {
|
|
15
|
+
signatures: PDFSignature[];
|
|
16
|
+
loading: boolean;
|
|
17
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as pdfjsLib from "pdfjs-dist";
|
|
2
|
+
interface UseTextLayerOptions {
|
|
3
|
+
pdf: pdfjsLib.PDFDocumentProxy | null;
|
|
4
|
+
zoom: number;
|
|
5
|
+
rotation: number;
|
|
6
|
+
numPages: number;
|
|
7
|
+
canvasRefs: React.RefObject<(HTMLCanvasElement | null)[]>;
|
|
8
|
+
}
|
|
9
|
+
export declare function useTextLayer({ pdf, zoom, rotation, numPages, canvasRefs, }: UseTextLayerOptions): React.RefObject<(HTMLDivElement | null)[]>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as pdfjsLib from "pdfjs-dist";
|
|
2
|
+
export interface SearchMatch {
|
|
3
|
+
page: number;
|
|
4
|
+
pdfRect: [number, number, number, number];
|
|
5
|
+
}
|
|
6
|
+
export declare function useTextSearch({ pdf, query, }: {
|
|
7
|
+
pdf: pdfjsLib.PDFDocumentProxy | null;
|
|
8
|
+
query: string;
|
|
9
|
+
}): {
|
|
10
|
+
matches: SearchMatch[];
|
|
11
|
+
searching: boolean;
|
|
12
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as pdfjsLib from "pdfjs-dist";
|
|
2
|
+
interface UseThumbnailsOptions {
|
|
3
|
+
pdf: pdfjsLib.PDFDocumentProxy | null;
|
|
4
|
+
rotation: number;
|
|
5
|
+
}
|
|
6
|
+
export declare function useThumbnails({ pdf, rotation }: UseThumbnailsOptions): {
|
|
7
|
+
thumbnails: string[];
|
|
8
|
+
};
|
|
9
|
+
export {};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export { default as PDFViewer } from './components/PDFViewer';
|
|
2
|
+
export { PDFSidebar } from './components/PDFSidebar';
|
|
3
|
+
export { PDFAnnotations } from './components/features/PDFAnnotations';
|
|
4
|
+
export { PDFChangeFile } from './components/features/PDFChangeFile';
|
|
5
|
+
export { PDFDownloadButton } from './components/features/PDFDownloadButton';
|
|
6
|
+
export { PDFNavigation } from './components/features/PDFNavigation';
|
|
7
|
+
export { PDFOutline } from './components/features/PDFOutline';
|
|
8
|
+
export { PDFPageFit } from './components/features/PDFPageFit';
|
|
9
|
+
export { PDFRotationControl } from './components/features/PDFRotationControl';
|
|
10
|
+
export { PDFSearch } from './components/features/PDFSearch';
|
|
11
|
+
export { PDFSignatures } from './components/features/PDFSignatures';
|
|
12
|
+
export { PDFThumbnails } from './components/features/PDFThumbnails';
|
|
13
|
+
export { PDFZoomControls } from './components/features/PDFZoomControls';
|
|
14
|
+
export { PDFThemeToggle } from './components/features/PDFThemeToggle';
|
|
15
|
+
export { PDFPrintButton } from './components/features/PDFPrintButton';
|