@hypercard-ai/hyper-jump 1.0.1 → 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/README.md +39 -4
- package/dist/index.d.ts +4 -23
- package/dist/index.d.ts.map +1 -0
- package/dist/{types-Ce3M8ej7.d.ts → lib/types.d.ts} +6 -6
- package/dist/lib/types.d.ts.map +1 -0
- package/dist/lib/use-element-size.d.ts +6 -0
- package/dist/lib/use-element-size.d.ts.map +1 -0
- package/dist/markdown/index.css +137 -0
- package/dist/markdown/index.css.map +1 -0
- package/dist/markdown/index.d.ts +3 -0
- package/dist/markdown/index.d.ts.map +1 -0
- package/dist/markdown/index.js +73 -0
- package/dist/markdown/index.js.map +1 -0
- package/dist/markdown/markdown-viewer.d.ts +7 -0
- package/dist/markdown/markdown-viewer.d.ts.map +1 -0
- package/dist/pdf/constants.d.ts +3 -0
- package/dist/pdf/constants.d.ts.map +1 -0
- package/dist/pdf/controls.d.ts +13 -0
- package/dist/pdf/controls.d.ts.map +1 -0
- package/dist/pdf/error-page.d.ts +3 -0
- package/dist/pdf/error-page.d.ts.map +1 -0
- package/dist/pdf/index.d.ts +3 -12
- package/dist/pdf/index.d.ts.map +1 -0
- package/dist/pdf/loading-page.d.ts +3 -0
- package/dist/pdf/loading-page.d.ts.map +1 -0
- package/dist/pdf/pdf-viewer.d.ts +13 -0
- package/dist/pdf/pdf-viewer.d.ts.map +1 -0
- package/dist/pdf/renderer.d.ts +8 -0
- package/dist/pdf/renderer.d.ts.map +1 -0
- package/dist/pdf/utils.d.ts +6 -0
- package/dist/pdf/utils.d.ts.map +1 -0
- package/dist/pdf/viewer.stories.d.ts +11 -0
- package/dist/pdf/viewer.stories.d.ts.map +1 -0
- package/dist/video/index.d.ts +3 -11
- package/dist/video/index.d.ts.map +1 -0
- package/dist/video/video-viewer.d.ts +10 -0
- package/dist/video/video-viewer.d.ts.map +1 -0
- package/dist/video/viewer.stories.d.ts +9 -0
- package/dist/video/viewer.stories.d.ts.map +1 -0
- package/dist/viewer/viewer.d.ts +20 -0
- package/dist/viewer/viewer.d.ts.map +1 -0
- package/package.json +14 -3
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ Renderers are opt-in — only bundle what you use.
|
|
|
10
10
|
|
|
11
11
|
## Features
|
|
12
12
|
|
|
13
|
-
- **Pluggable renderers** — import only the file types you need (PDF, video, and more coming soon)
|
|
13
|
+
- **Pluggable renderers** — import only the file types you need (PDF, video, markdown, and more coming soon)
|
|
14
14
|
- Virtualized rendering via `react-window` for smooth viewing of large PDFs
|
|
15
15
|
- Unified `jump()` API for instant navigation to cited content across all file types
|
|
16
16
|
- Zoom controls with preset levels and automatic fit-to-width
|
|
@@ -23,6 +23,9 @@ Renderers are opt-in — only bundle what you use.
|
|
|
23
23
|
# Core + PDF renderer
|
|
24
24
|
npm install @hypercard-ai/hyper-jump react-pdf react-window
|
|
25
25
|
|
|
26
|
+
# Core + Markdown renderer
|
|
27
|
+
npm install @hypercard-ai/hyper-jump react-markdown
|
|
28
|
+
|
|
26
29
|
# Core + Video renderer (no extra dependencies needed)
|
|
27
30
|
npm install @hypercard-ai/hyper-jump
|
|
28
31
|
```
|
|
@@ -47,7 +50,7 @@ function App() {
|
|
|
47
50
|
|
|
48
51
|
### Open at a specific position
|
|
49
52
|
|
|
50
|
-
Pass `initialPosition` to start at a specific location when the file loads. The meaning depends on the renderer — page index for PDF, seconds for video:
|
|
53
|
+
Pass `initialPosition` to start at a specific location when the file loads. The meaning depends on the renderer — page index for PDF, seconds for video, pixel offset for markdown:
|
|
51
54
|
|
|
52
55
|
```tsx
|
|
53
56
|
// PDF: open at page 4 (0-indexed)
|
|
@@ -55,6 +58,9 @@ Pass `initialPosition` to start at a specific location when the file loads. The
|
|
|
55
58
|
|
|
56
59
|
// Video: start at 30 seconds
|
|
57
60
|
<HyperJumpViewer url="/clip.mp4" renderers={[VideoRenderer]} initialPosition={30} />
|
|
61
|
+
|
|
62
|
+
// Markdown: start at 200px scroll offset
|
|
63
|
+
<HyperJumpViewer url="/doc.md" renderers={[MarkdownRenderer]} initialPosition={200} />
|
|
58
64
|
```
|
|
59
65
|
|
|
60
66
|
### Jump to a position imperatively
|
|
@@ -96,7 +102,7 @@ The core component. It detects the file type from the URL extension (or an expli
|
|
|
96
102
|
| `renderers` | `FileRenderer[]` | Yes | Renderers the viewer can use (first match wins) |
|
|
97
103
|
| `type` | `string` | No | Explicit file type override (e.g. `"pdf"`). If omitted, detected from URL extension |
|
|
98
104
|
| `ref` | `Ref<HyperJumpAPI>` | No | Forwarded to the active renderer for the `jump()` API |
|
|
99
|
-
| `initialPosition` | `number` | No | Position to start at when the file loads (page index for PDF, seconds for video) |
|
|
105
|
+
| `initialPosition` | `number` | No | Position to start at when the file loads (page index for PDF, seconds for video, pixel offset for markdown) |
|
|
100
106
|
| `onPositionChange` | `(position: number) => void` | No | Called when the current position changes |
|
|
101
107
|
| `rendererProps` | `T` | No | Additional props forwarded to the matched renderer (generic, typed per renderer) |
|
|
102
108
|
|
|
@@ -106,7 +112,7 @@ All renderers expose the same imperative API:
|
|
|
106
112
|
|
|
107
113
|
| Method | Description |
|
|
108
114
|
| --- | --- |
|
|
109
|
-
| `jump(position: number)` | Jump to a position. Page index for PDF (0-indexed, clamped), seconds for video. |
|
|
115
|
+
| `jump(position: number)` | Jump to a position. Page index for PDF (0-indexed, clamped), seconds for video, pixel offset for markdown. |
|
|
110
116
|
|
|
111
117
|
### PDF Renderer
|
|
112
118
|
|
|
@@ -118,6 +124,26 @@ Imported from `@hypercard-ai/hyper-jump/pdf`. Requires `react-pdf` and `react-wi
|
|
|
118
124
|
| --- | --- | --- | --- |
|
|
119
125
|
| `scrollBehavior` | `"auto" \| "instant" \| "smooth"` | No | Scroll behavior when navigating between pages (default: `"instant"`) |
|
|
120
126
|
|
|
127
|
+
### Markdown Renderer
|
|
128
|
+
|
|
129
|
+
Imported from `@hypercard-ai/hyper-jump/markdown`. Requires `react-markdown` as a peer dependency. Fetches the markdown file from the URL and renders it with GitHub-flavored styling.
|
|
130
|
+
|
|
131
|
+
```tsx
|
|
132
|
+
import { HyperJumpViewer } from "@hypercard-ai/hyper-jump";
|
|
133
|
+
import { MarkdownRenderer } from "@hypercard-ai/hyper-jump/markdown";
|
|
134
|
+
import "@hypercard-ai/hyper-jump/styles.css";
|
|
135
|
+
import "@hypercard-ai/hyper-jump/markdown/styles.css";
|
|
136
|
+
|
|
137
|
+
function App() {
|
|
138
|
+
return (
|
|
139
|
+
<HyperJumpViewer
|
|
140
|
+
url="/path/to/document.md"
|
|
141
|
+
renderers={[MarkdownRenderer]}
|
|
142
|
+
/>
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
121
147
|
### Video Renderer
|
|
122
148
|
|
|
123
149
|
Imported from `@hypercard-ai/hyper-jump/video`. Uses the native HTML `<video>` element — no extra dependencies required.
|
|
@@ -165,6 +191,14 @@ function App() {
|
|
|
165
191
|
| `HyperJumpPdfViewerProps` | Type | Full props for the PDF renderer |
|
|
166
192
|
| `ScrollBehavior` | Type | Scroll behavior union type |
|
|
167
193
|
|
|
194
|
+
#### `@hypercard-ai/hyper-jump/markdown`
|
|
195
|
+
|
|
196
|
+
| Export | Type | Description |
|
|
197
|
+
| --- | --- | --- |
|
|
198
|
+
| `MarkdownRenderer` | `FileRenderer` | Renderer descriptor for markdown files |
|
|
199
|
+
| `HyperJumpMarkdownViewerAPI` | Type | Alias for `HyperJumpAPI` |
|
|
200
|
+
| `HyperJumpMarkdownViewerProps` | Type | Full props for the markdown renderer |
|
|
201
|
+
|
|
168
202
|
#### `@hypercard-ai/hyper-jump/video`
|
|
169
203
|
|
|
170
204
|
| Export | Type | Description |
|
|
@@ -196,6 +230,7 @@ const MyVideoRenderer: FileRenderer = {
|
|
|
196
230
|
- React 19+
|
|
197
231
|
- react-pdf 10+ (when using `PdfRenderer`)
|
|
198
232
|
- react-window 2+ (when using `PdfRenderer`)
|
|
233
|
+
- react-markdown 9+ (when using `MarkdownRenderer`)
|
|
199
234
|
|
|
200
235
|
## Development
|
|
201
236
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,23 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
interface HyperJumpViewerProps<T extends Record<string, unknown> = Record<string, unknown>> {
|
|
6
|
-
/** URL of the file to display */
|
|
7
|
-
url: string;
|
|
8
|
-
/** Explicit file type override (e.g. "pdf", "video"). If omitted, detected from URL extension. */
|
|
9
|
-
type?: string;
|
|
10
|
-
/** Renderers that this viewer can use. The first matching renderer wins. */
|
|
11
|
-
renderers: FileRenderer[];
|
|
12
|
-
/** Ref forwarded to the active renderer (e.g. for imperative APIs like jump). */
|
|
13
|
-
ref?: React.Ref<HyperJumpAPI>;
|
|
14
|
-
/** Initial position to show when the content first loads. Meaning depends on renderer (page index for PDF, seconds for video). */
|
|
15
|
-
initialPosition?: number;
|
|
16
|
-
/** Called when the current position changes. Meaning depends on renderer (page index for PDF, seconds for video). */
|
|
17
|
-
onPositionChange?: (position: number) => void;
|
|
18
|
-
/** Additional props forwarded to the matched renderer. */
|
|
19
|
-
rendererProps?: T;
|
|
20
|
-
}
|
|
21
|
-
declare function HyperJumpViewer<T extends Record<string, unknown> = Record<string, unknown>>(props: HyperJumpViewerProps<T>): react_jsx_runtime.JSX.Element;
|
|
22
|
-
|
|
23
|
-
export { FileRenderer, HyperJumpAPI, HyperJumpViewer, type HyperJumpViewerProps };
|
|
1
|
+
export type { FileRenderer, HyperJumpAPI, RendererProps, ZoomConfig, } from "./lib/types";
|
|
2
|
+
export type { HyperJumpViewerProps } from "./viewer/viewer";
|
|
3
|
+
export { HyperJumpViewer } from "./viewer/viewer";
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACX,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,UAAU,GACV,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
type ZoomMode = "automatic" | "page-width" | "manual";
|
|
2
|
-
interface ZoomConfig {
|
|
2
|
+
export interface ZoomConfig {
|
|
3
3
|
mode: ZoomMode;
|
|
4
4
|
value: number;
|
|
5
5
|
}
|
|
6
6
|
/** Props that the core viewer passes to every renderer. */
|
|
7
|
-
interface RendererProps {
|
|
7
|
+
export interface RendererProps {
|
|
8
8
|
url: string;
|
|
9
9
|
containerWidth: number;
|
|
10
10
|
containerHeight: number;
|
|
@@ -14,12 +14,12 @@ interface RendererProps {
|
|
|
14
14
|
onPositionChange?: (position: number) => void;
|
|
15
15
|
}
|
|
16
16
|
/** Imperative API shared by all renderers. Exposed via ref on HyperJumpViewer. */
|
|
17
|
-
interface HyperJumpAPI {
|
|
17
|
+
export interface HyperJumpAPI {
|
|
18
18
|
/** Jump to a position. Meaning depends on renderer (page index for PDF, seconds for video). */
|
|
19
19
|
jump: (position: number) => void;
|
|
20
20
|
}
|
|
21
21
|
/** A renderer descriptor that tells the core viewer how to handle a file type. */
|
|
22
|
-
interface FileRenderer {
|
|
22
|
+
export interface FileRenderer {
|
|
23
23
|
/** Unique identifier for this renderer type (e.g. "pdf", "video"). */
|
|
24
24
|
type: string;
|
|
25
25
|
/** File extensions this renderer handles, without dots (e.g. ["pdf"]). */
|
|
@@ -27,5 +27,5 @@ interface FileRenderer {
|
|
|
27
27
|
/** The component that renders the file. */
|
|
28
28
|
Component: React.ComponentType<RendererProps & Record<string, unknown>>;
|
|
29
29
|
}
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
export {};
|
|
31
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/types.ts"],"names":[],"mappings":"AAAA,KAAK,QAAQ,GAAG,WAAW,GAAG,YAAY,GAAG,QAAQ,CAAC;AAEtD,MAAM,WAAW,UAAU;IAC1B,IAAI,EAAE,QAAQ,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACd;AAED,2DAA2D;AAC3D,MAAM,WAAW,aAAa;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,kIAAkI;IAClI,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,qHAAqH;IACrH,gBAAgB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;CAC9C;AAED,kFAAkF;AAClF,MAAM,WAAW,YAAY;IAC5B,+FAA+F;IAC/F,IAAI,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;CACjC;AAED,kFAAkF;AAClF,MAAM,WAAW,YAAY;IAC5B,sEAAsE;IACtE,IAAI,EAAE,MAAM,CAAC;IACb,0EAA0E;IAC1E,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,2CAA2C;IAC3C,SAAS,EAAE,KAAK,CAAC,aAAa,CAAC,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACxE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-element-size.d.ts","sourceRoot":"","sources":["../../src/lib/use-element-size.ts"],"names":[],"mappings":"AAEA,wBAAgB,cAAc,CAAC,CAAC,SAAS,WAAW,GAAG,cAAc;gBAIrC,CAAC,GAAG,IAAI;;;EAoBvC"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/* src/markdown/markdown-viewer.css */
|
|
2
|
+
.hj-markdown {
|
|
3
|
+
height: 100%;
|
|
4
|
+
width: 100%;
|
|
5
|
+
overflow-y: auto;
|
|
6
|
+
padding: 24px 32px;
|
|
7
|
+
box-sizing: border-box;
|
|
8
|
+
font-family:
|
|
9
|
+
-apple-system,
|
|
10
|
+
BlinkMacSystemFont,
|
|
11
|
+
"Segoe UI",
|
|
12
|
+
Helvetica,
|
|
13
|
+
Arial,
|
|
14
|
+
sans-serif;
|
|
15
|
+
font-size: 16px;
|
|
16
|
+
line-height: 1.6;
|
|
17
|
+
color: #1f2328;
|
|
18
|
+
word-wrap: break-word;
|
|
19
|
+
}
|
|
20
|
+
.hj-markdown--loading,
|
|
21
|
+
.hj-markdown--error {
|
|
22
|
+
display: flex;
|
|
23
|
+
align-items: center;
|
|
24
|
+
justify-content: center;
|
|
25
|
+
}
|
|
26
|
+
.hj-markdown h1,
|
|
27
|
+
.hj-markdown h2,
|
|
28
|
+
.hj-markdown h3,
|
|
29
|
+
.hj-markdown h4,
|
|
30
|
+
.hj-markdown h5,
|
|
31
|
+
.hj-markdown h6 {
|
|
32
|
+
margin-top: 24px;
|
|
33
|
+
margin-bottom: 16px;
|
|
34
|
+
font-weight: 600;
|
|
35
|
+
line-height: 1.25;
|
|
36
|
+
}
|
|
37
|
+
.hj-markdown h1 {
|
|
38
|
+
font-size: 2em;
|
|
39
|
+
padding-bottom: 0.3em;
|
|
40
|
+
border-bottom: 1px solid #d1d9e0;
|
|
41
|
+
}
|
|
42
|
+
.hj-markdown h2 {
|
|
43
|
+
font-size: 1.5em;
|
|
44
|
+
padding-bottom: 0.3em;
|
|
45
|
+
border-bottom: 1px solid #d1d9e0;
|
|
46
|
+
}
|
|
47
|
+
.hj-markdown h3 {
|
|
48
|
+
font-size: 1.25em;
|
|
49
|
+
}
|
|
50
|
+
.hj-markdown p {
|
|
51
|
+
margin-top: 0;
|
|
52
|
+
margin-bottom: 16px;
|
|
53
|
+
}
|
|
54
|
+
.hj-markdown a {
|
|
55
|
+
color: #0969da;
|
|
56
|
+
text-decoration: none;
|
|
57
|
+
}
|
|
58
|
+
.hj-markdown a:hover {
|
|
59
|
+
text-decoration: underline;
|
|
60
|
+
}
|
|
61
|
+
.hj-markdown code {
|
|
62
|
+
padding: 0.2em 0.4em;
|
|
63
|
+
margin: 0;
|
|
64
|
+
font-size: 85%;
|
|
65
|
+
background-color: rgba(175, 184, 193, 0.2);
|
|
66
|
+
border-radius: 6px;
|
|
67
|
+
font-family:
|
|
68
|
+
ui-monospace,
|
|
69
|
+
SFMono-Regular,
|
|
70
|
+
"SF Mono",
|
|
71
|
+
Menlo,
|
|
72
|
+
Consolas,
|
|
73
|
+
"Liberation Mono",
|
|
74
|
+
monospace;
|
|
75
|
+
}
|
|
76
|
+
.hj-markdown pre {
|
|
77
|
+
padding: 16px;
|
|
78
|
+
overflow: auto;
|
|
79
|
+
font-size: 85%;
|
|
80
|
+
line-height: 1.45;
|
|
81
|
+
background-color: #f6f8fa;
|
|
82
|
+
border-radius: 6px;
|
|
83
|
+
margin-bottom: 16px;
|
|
84
|
+
}
|
|
85
|
+
.hj-markdown pre code {
|
|
86
|
+
padding: 0;
|
|
87
|
+
background-color: transparent;
|
|
88
|
+
border-radius: 0;
|
|
89
|
+
font-size: 100%;
|
|
90
|
+
}
|
|
91
|
+
.hj-markdown blockquote {
|
|
92
|
+
padding: 0 1em;
|
|
93
|
+
color: #656d76;
|
|
94
|
+
border-left: 0.25em solid #d1d9e0;
|
|
95
|
+
margin: 0 0 16px 0;
|
|
96
|
+
}
|
|
97
|
+
.hj-markdown ul,
|
|
98
|
+
.hj-markdown ol {
|
|
99
|
+
padding-left: 2em;
|
|
100
|
+
margin-top: 0;
|
|
101
|
+
margin-bottom: 16px;
|
|
102
|
+
}
|
|
103
|
+
.hj-markdown li + li {
|
|
104
|
+
margin-top: 0.25em;
|
|
105
|
+
}
|
|
106
|
+
.hj-markdown hr {
|
|
107
|
+
height: 0.25em;
|
|
108
|
+
padding: 0;
|
|
109
|
+
margin: 24px 0;
|
|
110
|
+
background-color: #d1d9e0;
|
|
111
|
+
border: 0;
|
|
112
|
+
}
|
|
113
|
+
.hj-markdown img {
|
|
114
|
+
max-width: 100%;
|
|
115
|
+
height: auto;
|
|
116
|
+
}
|
|
117
|
+
.hj-markdown table {
|
|
118
|
+
border-spacing: 0;
|
|
119
|
+
border-collapse: collapse;
|
|
120
|
+
margin-bottom: 16px;
|
|
121
|
+
width: max-content;
|
|
122
|
+
max-width: 100%;
|
|
123
|
+
overflow: auto;
|
|
124
|
+
}
|
|
125
|
+
.hj-markdown table th,
|
|
126
|
+
.hj-markdown table td {
|
|
127
|
+
padding: 6px 13px;
|
|
128
|
+
border: 1px solid #d1d9e0;
|
|
129
|
+
}
|
|
130
|
+
.hj-markdown table th {
|
|
131
|
+
font-weight: 600;
|
|
132
|
+
background-color: #f6f8fa;
|
|
133
|
+
}
|
|
134
|
+
.hj-markdown table tr:nth-child(2n) {
|
|
135
|
+
background-color: #f6f8fa;
|
|
136
|
+
}
|
|
137
|
+
/*# sourceMappingURL=index.css.map */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/markdown/markdown-viewer.css"],"sourcesContent":[".hj-markdown {\n\theight: 100%;\n\twidth: 100%;\n\toverflow-y: auto;\n\tpadding: 24px 32px;\n\tbox-sizing: border-box;\n\tfont-family:\n\t\t-apple-system, BlinkMacSystemFont, \"Segoe UI\", Helvetica, Arial, sans-serif;\n\tfont-size: 16px;\n\tline-height: 1.6;\n\tcolor: #1f2328;\n\tword-wrap: break-word;\n}\n\n.hj-markdown--loading,\n.hj-markdown--error {\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: center;\n}\n\n.hj-markdown h1,\n.hj-markdown h2,\n.hj-markdown h3,\n.hj-markdown h4,\n.hj-markdown h5,\n.hj-markdown h6 {\n\tmargin-top: 24px;\n\tmargin-bottom: 16px;\n\tfont-weight: 600;\n\tline-height: 1.25;\n}\n\n.hj-markdown h1 {\n\tfont-size: 2em;\n\tpadding-bottom: 0.3em;\n\tborder-bottom: 1px solid #d1d9e0;\n}\n\n.hj-markdown h2 {\n\tfont-size: 1.5em;\n\tpadding-bottom: 0.3em;\n\tborder-bottom: 1px solid #d1d9e0;\n}\n\n.hj-markdown h3 {\n\tfont-size: 1.25em;\n}\n\n.hj-markdown p {\n\tmargin-top: 0;\n\tmargin-bottom: 16px;\n}\n\n.hj-markdown a {\n\tcolor: #0969da;\n\ttext-decoration: none;\n}\n\n.hj-markdown a:hover {\n\ttext-decoration: underline;\n}\n\n.hj-markdown code {\n\tpadding: 0.2em 0.4em;\n\tmargin: 0;\n\tfont-size: 85%;\n\tbackground-color: rgba(175, 184, 193, 0.2);\n\tborder-radius: 6px;\n\tfont-family:\n\t\tui-monospace, SFMono-Regular, \"SF Mono\", Menlo, Consolas, \"Liberation Mono\",\n\t\tmonospace;\n}\n\n.hj-markdown pre {\n\tpadding: 16px;\n\toverflow: auto;\n\tfont-size: 85%;\n\tline-height: 1.45;\n\tbackground-color: #f6f8fa;\n\tborder-radius: 6px;\n\tmargin-bottom: 16px;\n}\n\n.hj-markdown pre code {\n\tpadding: 0;\n\tbackground-color: transparent;\n\tborder-radius: 0;\n\tfont-size: 100%;\n}\n\n.hj-markdown blockquote {\n\tpadding: 0 1em;\n\tcolor: #656d76;\n\tborder-left: 0.25em solid #d1d9e0;\n\tmargin: 0 0 16px 0;\n}\n\n.hj-markdown ul,\n.hj-markdown ol {\n\tpadding-left: 2em;\n\tmargin-top: 0;\n\tmargin-bottom: 16px;\n}\n\n.hj-markdown li + li {\n\tmargin-top: 0.25em;\n}\n\n.hj-markdown hr {\n\theight: 0.25em;\n\tpadding: 0;\n\tmargin: 24px 0;\n\tbackground-color: #d1d9e0;\n\tborder: 0;\n}\n\n.hj-markdown img {\n\tmax-width: 100%;\n\theight: auto;\n}\n\n.hj-markdown table {\n\tborder-spacing: 0;\n\tborder-collapse: collapse;\n\tmargin-bottom: 16px;\n\twidth: max-content;\n\tmax-width: 100%;\n\toverflow: auto;\n}\n\n.hj-markdown table th,\n.hj-markdown table td {\n\tpadding: 6px 13px;\n\tborder: 1px solid #d1d9e0;\n}\n\n.hj-markdown table th {\n\tfont-weight: 600;\n\tbackground-color: #f6f8fa;\n}\n\n.hj-markdown table tr:nth-child(2n) {\n\tbackground-color: #f6f8fa;\n}\n"],"mappings":";AAAA,CAAC;AACA,UAAQ;AACR,SAAO;AACP,cAAY;AACZ,WAAS,KAAK;AACd,cAAY;AACZ;AAAA,IACC,aAAa;AAAA,IAAE,kBAAkB;AAAA,IAAE,UAAU;AAAA,IAAE,SAAS;AAAA,IAAE,KAAK;AAAA,IAAE;AAClE,aAAW;AACX,eAAa;AACb,SAAO;AACP,aAAW;AACZ;AAEA,CAAC;AACD,CAAC;AACA,WAAS;AACT,eAAa;AACb,mBAAiB;AAClB;AAEA,CArBC,YAqBY;AACb,CAtBC,YAsBY;AACb,CAvBC,YAuBY;AACb,CAxBC,YAwBY;AACb,CAzBC,YAyBY;AACb,CA1BC,YA0BY;AACZ,cAAY;AACZ,iBAAe;AACf,eAAa;AACb,eAAa;AACd;AAEA,CAjCC,YAiCY;AACZ,aAAW;AACX,kBAAgB;AAChB,iBAAe,IAAI,MAAM;AAC1B;AAEA,CAvCC,YAuCY;AACZ,aAAW;AACX,kBAAgB;AAChB,iBAAe,IAAI,MAAM;AAC1B;AAEA,CA7CC,YA6CY;AACZ,aAAW;AACZ;AAEA,CAjDC,YAiDY;AACZ,cAAY;AACZ,iBAAe;AAChB;AAEA,CAtDC,YAsDY;AACZ,SAAO;AACP,mBAAiB;AAClB;AAEA,CA3DC,YA2DY,CAAC;AACb,mBAAiB;AAClB;AAEA,CA/DC,YA+DY;AACZ,WAAS,MAAM;AACf,UAAQ;AACR,aAAW;AACX,oBAAkB,KAAK,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE;AACtC,iBAAe;AACf;AAAA,IACC,YAAY;AAAA,IAAE,cAAc;AAAA,IAAE,SAAS;AAAA,IAAE,KAAK;AAAA,IAAE,QAAQ;AAAA,IAAE,iBAAiB;AAAA,IAC3E;AACF;AAEA,CA1EC,YA0EY;AACZ,WAAS;AACT,YAAU;AACV,aAAW;AACX,eAAa;AACb,oBAAkB;AAClB,iBAAe;AACf,iBAAe;AAChB;AAEA,CApFC,YAoFY,IAAI;AAChB,WAAS;AACT,oBAAkB;AAClB,iBAAe;AACf,aAAW;AACZ;AAEA,CA3FC,YA2FY;AACZ,WAAS,EAAE;AACX,SAAO;AACP,eAAa,OAAO,MAAM;AAC1B,UAAQ,EAAE,EAAE,KAAK;AAClB;AAEA,CAlGC,YAkGY;AACb,CAnGC,YAmGY;AACZ,gBAAc;AACd,cAAY;AACZ,iBAAe;AAChB;AAEA,CAzGC,YAyGY,GAAG,EAAE;AACjB,cAAY;AACb;AAEA,CA7GC,YA6GY;AACZ,UAAQ;AACR,WAAS;AACT,UAAQ,KAAK;AACb,oBAAkB;AAClB,UAAQ;AACT;AAEA,CArHC,YAqHY;AACZ,aAAW;AACX,UAAQ;AACT;AAEA,CA1HC,YA0HY;AACZ,kBAAgB;AAChB,mBAAiB;AACjB,iBAAe;AACf,SAAO;AACP,aAAW;AACX,YAAU;AACX;AAEA,CAnIC,YAmIY,MAAM;AACnB,CApIC,YAoIY,MAAM;AAClB,WAAS,IAAI;AACb,UAAQ,IAAI,MAAM;AACnB;AAEA,CAzIC,YAyIY,MAAM;AAClB,eAAa;AACb,oBAAkB;AACnB;AAEA,CA9IC,YA8IY,MAAM,EAAE;AACpB,oBAAkB;AACnB;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/markdown/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACX,0BAA0B,EAC1B,4BAA4B,GAC5B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// src/markdown/markdown-viewer.tsx
|
|
2
|
+
import {
|
|
3
|
+
forwardRef,
|
|
4
|
+
useCallback,
|
|
5
|
+
useEffect,
|
|
6
|
+
useImperativeHandle,
|
|
7
|
+
useRef,
|
|
8
|
+
useState
|
|
9
|
+
} from "react";
|
|
10
|
+
import Markdown from "react-markdown";
|
|
11
|
+
import { jsx } from "react/jsx-runtime";
|
|
12
|
+
var MarkdownViewerComponent = forwardRef(function MarkdownViewerComponent2(props, ref) {
|
|
13
|
+
const { url, initialPosition, onPositionChange } = props;
|
|
14
|
+
const containerRef = useRef(null);
|
|
15
|
+
const hasAppliedInitialPosition = useRef(false);
|
|
16
|
+
const [content, setContent] = useState(null);
|
|
17
|
+
const [error, setError] = useState(null);
|
|
18
|
+
useImperativeHandle(
|
|
19
|
+
ref,
|
|
20
|
+
() => ({
|
|
21
|
+
jump: (position) => {
|
|
22
|
+
if (containerRef.current) {
|
|
23
|
+
containerRef.current.scrollTop = position;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}),
|
|
27
|
+
[]
|
|
28
|
+
);
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
let cancelled = false;
|
|
31
|
+
setContent(null);
|
|
32
|
+
setError(null);
|
|
33
|
+
hasAppliedInitialPosition.current = false;
|
|
34
|
+
fetch(url).then((res) => {
|
|
35
|
+
if (!res.ok) throw new Error(`Failed to fetch: ${res.status}`);
|
|
36
|
+
return res.text();
|
|
37
|
+
}).then((text) => {
|
|
38
|
+
if (!cancelled) setContent(text);
|
|
39
|
+
}).catch((err) => {
|
|
40
|
+
if (!cancelled) setError(err.message);
|
|
41
|
+
});
|
|
42
|
+
return () => {
|
|
43
|
+
cancelled = true;
|
|
44
|
+
};
|
|
45
|
+
}, [url]);
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
if (!hasAppliedInitialPosition.current && initialPosition !== void 0 && content !== null && containerRef.current) {
|
|
48
|
+
hasAppliedInitialPosition.current = true;
|
|
49
|
+
containerRef.current.scrollTop = initialPosition;
|
|
50
|
+
}
|
|
51
|
+
}, [initialPosition, content]);
|
|
52
|
+
const handleScroll = useCallback(() => {
|
|
53
|
+
if (containerRef.current) {
|
|
54
|
+
onPositionChange?.(containerRef.current.scrollTop);
|
|
55
|
+
}
|
|
56
|
+
}, [onPositionChange]);
|
|
57
|
+
if (error) {
|
|
58
|
+
return /* @__PURE__ */ jsx("div", { className: "hj-markdown hj-markdown--error", children: error });
|
|
59
|
+
}
|
|
60
|
+
if (content === null) {
|
|
61
|
+
return /* @__PURE__ */ jsx("div", { className: "hj-markdown hj-markdown--loading", children: "Loading\u2026" });
|
|
62
|
+
}
|
|
63
|
+
return /* @__PURE__ */ jsx("div", { className: "hj-markdown", ref: containerRef, onScroll: handleScroll, children: /* @__PURE__ */ jsx(Markdown, { children: content }) });
|
|
64
|
+
});
|
|
65
|
+
var MarkdownRenderer = {
|
|
66
|
+
type: "markdown",
|
|
67
|
+
extensions: ["md", "markdown"],
|
|
68
|
+
Component: MarkdownViewerComponent
|
|
69
|
+
};
|
|
70
|
+
export {
|
|
71
|
+
MarkdownRenderer
|
|
72
|
+
};
|
|
73
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/markdown/markdown-viewer.tsx"],"sourcesContent":["import {\n\tforwardRef,\n\tuseCallback,\n\tuseEffect,\n\tuseImperativeHandle,\n\tuseRef,\n\tuseState,\n} from \"react\";\nimport Markdown from \"react-markdown\";\nimport type { FileRenderer, HyperJumpAPI, RendererProps } from \"../lib/types\";\nimport \"./markdown-viewer.css\";\n\nexport type HyperJumpMarkdownViewerAPI = HyperJumpAPI;\n\nexport interface HyperJumpMarkdownViewerProps extends RendererProps {}\n\nconst MarkdownViewerComponent = forwardRef<\n\tHyperJumpMarkdownViewerAPI,\n\tHyperJumpMarkdownViewerProps\n>(function MarkdownViewerComponent(props, ref) {\n\tconst { url, initialPosition, onPositionChange } = props;\n\tconst containerRef = useRef<HTMLDivElement>(null);\n\tconst hasAppliedInitialPosition = useRef(false);\n\tconst [content, setContent] = useState<string | null>(null);\n\tconst [error, setError] = useState<string | null>(null);\n\n\tuseImperativeHandle(\n\t\tref,\n\t\t() => ({\n\t\t\tjump: (position: number) => {\n\t\t\t\tif (containerRef.current) {\n\t\t\t\t\tcontainerRef.current.scrollTop = position;\n\t\t\t\t}\n\t\t\t},\n\t\t}),\n\t\t[],\n\t);\n\n\tuseEffect(() => {\n\t\tlet cancelled = false;\n\t\tsetContent(null);\n\t\tsetError(null);\n\t\thasAppliedInitialPosition.current = false;\n\n\t\tfetch(url)\n\t\t\t.then((res) => {\n\t\t\t\tif (!res.ok) throw new Error(`Failed to fetch: ${res.status}`);\n\t\t\t\treturn res.text();\n\t\t\t})\n\t\t\t.then((text) => {\n\t\t\t\tif (!cancelled) setContent(text);\n\t\t\t})\n\t\t\t.catch((err) => {\n\t\t\t\tif (!cancelled) setError(err.message);\n\t\t\t});\n\n\t\treturn () => {\n\t\t\tcancelled = true;\n\t\t};\n\t}, [url]);\n\n\tuseEffect(() => {\n\t\tif (\n\t\t\t!hasAppliedInitialPosition.current &&\n\t\t\tinitialPosition !== undefined &&\n\t\t\tcontent !== null &&\n\t\t\tcontainerRef.current\n\t\t) {\n\t\t\thasAppliedInitialPosition.current = true;\n\t\t\tcontainerRef.current.scrollTop = initialPosition;\n\t\t}\n\t}, [initialPosition, content]);\n\n\tconst handleScroll = useCallback(() => {\n\t\tif (containerRef.current) {\n\t\t\tonPositionChange?.(containerRef.current.scrollTop);\n\t\t}\n\t}, [onPositionChange]);\n\n\tif (error) {\n\t\treturn <div className=\"hj-markdown hj-markdown--error\">{error}</div>;\n\t}\n\n\tif (content === null) {\n\t\treturn <div className=\"hj-markdown hj-markdown--loading\">Loading…</div>;\n\t}\n\n\treturn (\n\t\t<div className=\"hj-markdown\" ref={containerRef} onScroll={handleScroll}>\n\t\t\t<Markdown>{content}</Markdown>\n\t\t</div>\n\t);\n});\n\nexport const MarkdownRenderer: FileRenderer = {\n\ttype: \"markdown\",\n\textensions: [\"md\", \"markdown\"],\n\tComponent: MarkdownViewerComponent as React.ComponentType<\n\t\tRendererProps & Record<string, unknown>\n\t>,\n};\n"],"mappings":";AAAA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,OAAO,cAAc;AAwEZ;AAhET,IAAM,0BAA0B,WAG9B,SAASA,yBAAwB,OAAO,KAAK;AAC9C,QAAM,EAAE,KAAK,iBAAiB,iBAAiB,IAAI;AACnD,QAAM,eAAe,OAAuB,IAAI;AAChD,QAAM,4BAA4B,OAAO,KAAK;AAC9C,QAAM,CAAC,SAAS,UAAU,IAAI,SAAwB,IAAI;AAC1D,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAwB,IAAI;AAEtD;AAAA,IACC;AAAA,IACA,OAAO;AAAA,MACN,MAAM,CAAC,aAAqB;AAC3B,YAAI,aAAa,SAAS;AACzB,uBAAa,QAAQ,YAAY;AAAA,QAClC;AAAA,MACD;AAAA,IACD;AAAA,IACA,CAAC;AAAA,EACF;AAEA,YAAU,MAAM;AACf,QAAI,YAAY;AAChB,eAAW,IAAI;AACf,aAAS,IAAI;AACb,8BAA0B,UAAU;AAEpC,UAAM,GAAG,EACP,KAAK,CAAC,QAAQ;AACd,UAAI,CAAC,IAAI,GAAI,OAAM,IAAI,MAAM,oBAAoB,IAAI,MAAM,EAAE;AAC7D,aAAO,IAAI,KAAK;AAAA,IACjB,CAAC,EACA,KAAK,CAAC,SAAS;AACf,UAAI,CAAC,UAAW,YAAW,IAAI;AAAA,IAChC,CAAC,EACA,MAAM,CAAC,QAAQ;AACf,UAAI,CAAC,UAAW,UAAS,IAAI,OAAO;AAAA,IACrC,CAAC;AAEF,WAAO,MAAM;AACZ,kBAAY;AAAA,IACb;AAAA,EACD,GAAG,CAAC,GAAG,CAAC;AAER,YAAU,MAAM;AACf,QACC,CAAC,0BAA0B,WAC3B,oBAAoB,UACpB,YAAY,QACZ,aAAa,SACZ;AACD,gCAA0B,UAAU;AACpC,mBAAa,QAAQ,YAAY;AAAA,IAClC;AAAA,EACD,GAAG,CAAC,iBAAiB,OAAO,CAAC;AAE7B,QAAM,eAAe,YAAY,MAAM;AACtC,QAAI,aAAa,SAAS;AACzB,yBAAmB,aAAa,QAAQ,SAAS;AAAA,IAClD;AAAA,EACD,GAAG,CAAC,gBAAgB,CAAC;AAErB,MAAI,OAAO;AACV,WAAO,oBAAC,SAAI,WAAU,kCAAkC,iBAAM;AAAA,EAC/D;AAEA,MAAI,YAAY,MAAM;AACrB,WAAO,oBAAC,SAAI,WAAU,oCAAmC,2BAAQ;AAAA,EAClE;AAEA,SACC,oBAAC,SAAI,WAAU,eAAc,KAAK,cAAc,UAAU,cACzD,8BAAC,YAAU,mBAAQ,GACpB;AAEF,CAAC;AAEM,IAAM,mBAAiC;AAAA,EAC7C,MAAM;AAAA,EACN,YAAY,CAAC,MAAM,UAAU;AAAA,EAC7B,WAAW;AAGZ;","names":["MarkdownViewerComponent"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { FileRenderer, HyperJumpAPI, RendererProps } from "../lib/types";
|
|
2
|
+
import "./markdown-viewer.css";
|
|
3
|
+
export type HyperJumpMarkdownViewerAPI = HyperJumpAPI;
|
|
4
|
+
export interface HyperJumpMarkdownViewerProps extends RendererProps {
|
|
5
|
+
}
|
|
6
|
+
export declare const MarkdownRenderer: FileRenderer;
|
|
7
|
+
//# sourceMappingURL=markdown-viewer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown-viewer.d.ts","sourceRoot":"","sources":["../../src/markdown/markdown-viewer.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC9E,OAAO,uBAAuB,CAAC;AAE/B,MAAM,MAAM,0BAA0B,GAAG,YAAY,CAAC;AAEtD,MAAM,WAAW,4BAA6B,SAAQ,aAAa;CAAG;AAgFtE,eAAO,MAAM,gBAAgB,EAAE,YAM9B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/pdf/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,MAAM,CAAC;AAC/B,eAAO,MAAM,UAAU,MAAM,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import "./controls.css";
|
|
2
|
+
import type { ZoomConfig } from "../lib/types";
|
|
3
|
+
interface IProps {
|
|
4
|
+
onChangeZoom(value: string): void;
|
|
5
|
+
pageIndex: number;
|
|
6
|
+
numPages: number;
|
|
7
|
+
zoomConfig: ZoomConfig;
|
|
8
|
+
onNextPage(): void;
|
|
9
|
+
onPrevPage(): void;
|
|
10
|
+
}
|
|
11
|
+
export default function PDFViewerControls(props: IProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=controls.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controls.d.ts","sourceRoot":"","sources":["../../src/pdf/controls.tsx"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAc/C,UAAU,MAAM;IACf,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,UAAU,CAAC;IACvB,UAAU,IAAI,IAAI,CAAC;IACnB,UAAU,IAAI,IAAI,CAAC;CACnB;AAsCD,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,KAAK,EAAE,MAAM,2CAyDtD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-page.d.ts","sourceRoot":"","sources":["../../src/pdf/error-page.tsx"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAE1B,MAAM,CAAC,OAAO,UAAU,YAAY,4CAEnC"}
|
package/dist/pdf/index.d.ts
CHANGED
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
type ScrollBehavior = "auto" | "instant" | "smooth";
|
|
5
|
-
interface HyperJumpPdfViewerProps extends RendererProps {
|
|
6
|
-
/** Scroll behavior when navigating between pages (default: "instant") */
|
|
7
|
-
scrollBehavior?: ScrollBehavior;
|
|
8
|
-
}
|
|
9
|
-
/** Renderer descriptor for PDF files. Pass this to HyperJumpViewer's `renderers` prop. */
|
|
10
|
-
declare const PdfRenderer: FileRenderer;
|
|
11
|
-
|
|
12
|
-
export { type HyperJumpPdfViewerAPI, type HyperJumpPdfViewerProps, PdfRenderer, type ScrollBehavior };
|
|
1
|
+
export type { HyperJumpPdfViewerAPI, HyperJumpPdfViewerProps, ScrollBehavior, } from "./pdf-viewer";
|
|
2
|
+
export { PdfRenderer } from "./pdf-viewer";
|
|
3
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/pdf/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACX,qBAAqB,EACrB,uBAAuB,EACvB,cAAc,GACd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loading-page.d.ts","sourceRoot":"","sources":["../../src/pdf/loading-page.tsx"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,CAAC;AAE5B,MAAM,CAAC,OAAO,UAAU,cAAc,4CAMrC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import "react-pdf/dist/Page/AnnotationLayer.css";
|
|
2
|
+
import "react-pdf/dist/Page/TextLayer.css";
|
|
3
|
+
import type { FileRenderer, HyperJumpAPI, RendererProps } from "../lib/types";
|
|
4
|
+
import "./pdf-viewer.css";
|
|
5
|
+
export type HyperJumpPdfViewerAPI = HyperJumpAPI;
|
|
6
|
+
export type ScrollBehavior = "auto" | "instant" | "smooth";
|
|
7
|
+
export interface HyperJumpPdfViewerProps extends RendererProps {
|
|
8
|
+
/** Scroll behavior when navigating between pages (default: "instant") */
|
|
9
|
+
scrollBehavior?: ScrollBehavior;
|
|
10
|
+
}
|
|
11
|
+
/** Renderer descriptor for PDF files. Pass this to HyperJumpViewer's `renderers` prop. */
|
|
12
|
+
export declare const PdfRenderer: FileRenderer;
|
|
13
|
+
//# sourceMappingURL=pdf-viewer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pdf-viewer.d.ts","sourceRoot":"","sources":["../../src/pdf/pdf-viewer.tsx"],"names":[],"mappings":"AAWA,OAAO,yCAAyC,CAAC;AACjD,OAAO,mCAAmC,CAAC;AAG3C,OAAO,KAAK,EACX,YAAY,EACZ,YAAY,EACZ,aAAa,EAEb,MAAM,cAAc,CAAC;AAItB,OAAO,kBAAkB,CAAC;AAQ1B,MAAM,MAAM,qBAAqB,GAAG,YAAY,CAAC;AAEjD,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE3D,MAAM,WAAW,uBAAwB,SAAQ,aAAa;IAC7D,yEAAyE;IACzE,cAAc,CAAC,EAAE,cAAc,CAAC;CAChC;AAwKD,0FAA0F;AAC1F,eAAO,MAAM,WAAW,EAAE,YAMzB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { RowComponentProps } from "react-window";
|
|
2
|
+
import "./renderer.css";
|
|
3
|
+
interface RowProps {
|
|
4
|
+
scale: number;
|
|
5
|
+
}
|
|
6
|
+
export default function PDFPageRenderer(props: RowComponentProps<RowProps>): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=renderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../../src/pdf/renderer.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEtD,OAAO,gBAAgB,CAAC;AAExB,UAAU,QAAQ;IACjB,KAAK,EAAE,MAAM,CAAC;CACd;AAED,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,KAAK,EAAE,iBAAiB,CAAC,QAAQ,CAAC,2CAOzE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/pdf/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAGnD,wBAAsB,iBAAiB,CACtC,QAAQ,EAAE,gBAAgB,EAC1B,KAAK,EAAE,MAAM;;;KAkBb"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { StoryObj } from "@storybook/react";
|
|
2
|
+
import { HyperJumpViewer } from "../viewer/viewer";
|
|
3
|
+
declare const meta: {
|
|
4
|
+
title: string;
|
|
5
|
+
component: typeof HyperJumpViewer;
|
|
6
|
+
};
|
|
7
|
+
export default meta;
|
|
8
|
+
export declare const CitationJumps: StoryObj<typeof meta>;
|
|
9
|
+
export declare const Loading: StoryObj<typeof meta>;
|
|
10
|
+
export declare const ErrorState: StoryObj<typeof meta>;
|
|
11
|
+
//# sourceMappingURL=viewer.stories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"viewer.stories.d.ts","sourceRoot":"","sources":["../../src/pdf/viewer.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAKnD,QAAA,MAAM,IAAI;;;CAG8B,CAAC;AAEzC,eAAe,IAAI,CAAC;AAwEpB,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,OAAO,IAAI,CAyL/C,CAAC;AAEF,eAAO,MAAM,OAAO,EAAE,QAAQ,CAAC,OAAO,IAAI,CASzC,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAC,OAAO,IAAI,CAS5C,CAAC"}
|
package/dist/video/index.d.ts
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
interface HyperJumpVideoViewerProps extends RendererProps {
|
|
5
|
-
/** Whether the video should autoplay (default: false). */
|
|
6
|
-
autoPlay?: boolean;
|
|
7
|
-
}
|
|
8
|
-
/** Renderer descriptor for video files. Pass this to HyperJumpViewer's `renderers` prop. */
|
|
9
|
-
declare const VideoRenderer: FileRenderer;
|
|
10
|
-
|
|
11
|
-
export { type HyperJumpVideoViewerAPI, type HyperJumpVideoViewerProps, VideoRenderer };
|
|
1
|
+
export type { HyperJumpVideoViewerAPI, HyperJumpVideoViewerProps, } from "./video-viewer";
|
|
2
|
+
export { VideoRenderer } from "./video-viewer";
|
|
3
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/video/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACX,uBAAuB,EACvB,yBAAyB,GACzB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { FileRenderer, HyperJumpAPI, RendererProps } from "../lib/types";
|
|
2
|
+
import "./video-viewer.css";
|
|
3
|
+
export type HyperJumpVideoViewerAPI = HyperJumpAPI;
|
|
4
|
+
export interface HyperJumpVideoViewerProps extends RendererProps {
|
|
5
|
+
/** Whether the video should autoplay (default: false). */
|
|
6
|
+
autoPlay?: boolean;
|
|
7
|
+
}
|
|
8
|
+
/** Renderer descriptor for video files. Pass this to HyperJumpViewer's `renderers` prop. */
|
|
9
|
+
export declare const VideoRenderer: FileRenderer;
|
|
10
|
+
//# sourceMappingURL=video-viewer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"video-viewer.d.ts","sourceRoot":"","sources":["../../src/video/video-viewer.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC9E,OAAO,oBAAoB,CAAC;AAE5B,MAAM,MAAM,uBAAuB,GAAG,YAAY,CAAC;AAEnD,MAAM,WAAW,yBAA0B,SAAQ,aAAa;IAC/D,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,OAAO,CAAC;CACnB;AAmDD,4FAA4F;AAC5F,eAAO,MAAM,aAAa,EAAE,YAM3B,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { StoryObj } from "@storybook/react";
|
|
2
|
+
import { HyperJumpViewer } from "../viewer/viewer";
|
|
3
|
+
declare const meta: {
|
|
4
|
+
title: string;
|
|
5
|
+
component: typeof HyperJumpViewer;
|
|
6
|
+
};
|
|
7
|
+
export default meta;
|
|
8
|
+
export declare const Playground: StoryObj<typeof meta>;
|
|
9
|
+
//# sourceMappingURL=viewer.stories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"viewer.stories.d.ts","sourceRoot":"","sources":["../../src/video/viewer.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAGnD,QAAA,MAAM,IAAI;;;CAG8B,CAAC;AAEzC,eAAe,IAAI,CAAC;AAapB,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAC,OAAO,IAAI,CAyI5C,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { FileRenderer, HyperJumpAPI } from "../lib/types";
|
|
2
|
+
import "./viewer.css";
|
|
3
|
+
export interface HyperJumpViewerProps<T extends Record<string, unknown> = Record<string, unknown>> {
|
|
4
|
+
/** URL of the file to display */
|
|
5
|
+
url: string;
|
|
6
|
+
/** Explicit file type override (e.g. "pdf", "video"). If omitted, detected from URL extension. */
|
|
7
|
+
type?: string;
|
|
8
|
+
/** Renderers that this viewer can use. The first matching renderer wins. */
|
|
9
|
+
renderers: FileRenderer[];
|
|
10
|
+
/** Ref forwarded to the active renderer (e.g. for imperative APIs like jump). */
|
|
11
|
+
ref?: React.Ref<HyperJumpAPI>;
|
|
12
|
+
/** Initial position to show when the content first loads. Meaning depends on renderer (page index for PDF, seconds for video). */
|
|
13
|
+
initialPosition?: number;
|
|
14
|
+
/** Called when the current position changes. Meaning depends on renderer (page index for PDF, seconds for video). */
|
|
15
|
+
onPositionChange?: (position: number) => void;
|
|
16
|
+
/** Additional props forwarded to the matched renderer. */
|
|
17
|
+
rendererProps?: T;
|
|
18
|
+
}
|
|
19
|
+
export declare function HyperJumpViewer<T extends Record<string, unknown> = Record<string, unknown>>(props: HyperJumpViewerProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
//# sourceMappingURL=viewer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"viewer.d.ts","sourceRoot":"","sources":["../../src/viewer/viewer.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE/D,OAAO,cAAc,CAAC;AAEtB,MAAM,WAAW,oBAAoB,CACpC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAE3D,iCAAiC;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,kGAAkG;IAClG,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,4EAA4E;IAC5E,SAAS,EAAE,YAAY,EAAE,CAAC;IAC1B,iFAAiF;IACjF,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IAC9B,kIAAkI;IAClI,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,qHAAqH;IACrH,gBAAgB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9C,0DAA0D;IAC1D,aAAa,CAAC,EAAE,CAAC,CAAC;CAClB;AAaD,wBAAgB,eAAe,CAC9B,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC1D,KAAK,EAAE,oBAAoB,CAAC,CAAC,CAAC,2CAwC/B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hypercard-ai/hyper-jump",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Document viewer built for RAG",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "HyperCard AI",
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"url": "https://github.com/hypercard-ai/hyper-jump/issues"
|
|
14
14
|
},
|
|
15
15
|
"keywords": [
|
|
16
|
+
"markdown",
|
|
16
17
|
"pdf",
|
|
17
18
|
"video",
|
|
18
19
|
"viewer",
|
|
@@ -38,7 +39,12 @@
|
|
|
38
39
|
"types": "./dist/video/index.d.ts",
|
|
39
40
|
"default": "./dist/video/index.js"
|
|
40
41
|
},
|
|
41
|
-
"./video/styles.css": "./dist/video/index.css"
|
|
42
|
+
"./video/styles.css": "./dist/video/index.css",
|
|
43
|
+
"./markdown": {
|
|
44
|
+
"types": "./dist/markdown/index.d.ts",
|
|
45
|
+
"default": "./dist/markdown/index.js"
|
|
46
|
+
},
|
|
47
|
+
"./markdown/styles.css": "./dist/markdown/index.css"
|
|
42
48
|
},
|
|
43
49
|
"files": [
|
|
44
50
|
"dist",
|
|
@@ -52,7 +58,7 @@
|
|
|
52
58
|
"access": "public"
|
|
53
59
|
},
|
|
54
60
|
"scripts": {
|
|
55
|
-
"build": "tsup",
|
|
61
|
+
"build": "tsup && tsc --emitDeclarationOnly --outDir dist",
|
|
56
62
|
"dev": "tsup --watch",
|
|
57
63
|
"test": "vitest run",
|
|
58
64
|
"test:watch": "vitest",
|
|
@@ -67,12 +73,16 @@
|
|
|
67
73
|
"react": ">=19.0.0",
|
|
68
74
|
"react-dom": ">=19.0.0",
|
|
69
75
|
"react-pdf": ">=10.0.0",
|
|
76
|
+
"react-markdown": ">=9.0.0",
|
|
70
77
|
"react-window": ">=2.0.0"
|
|
71
78
|
},
|
|
72
79
|
"peerDependenciesMeta": {
|
|
73
80
|
"react-pdf": {
|
|
74
81
|
"optional": true
|
|
75
82
|
},
|
|
83
|
+
"react-markdown": {
|
|
84
|
+
"optional": true
|
|
85
|
+
},
|
|
76
86
|
"react-window": {
|
|
77
87
|
"optional": true
|
|
78
88
|
}
|
|
@@ -88,6 +98,7 @@
|
|
|
88
98
|
"jsdom": "^28.0.0",
|
|
89
99
|
"react": "^19.2.4",
|
|
90
100
|
"react-dom": "^19.2.4",
|
|
101
|
+
"react-markdown": "^9.0.0",
|
|
91
102
|
"react-pdf": "10.3.0",
|
|
92
103
|
"react-window": "^2.2.7",
|
|
93
104
|
"storybook": "^10.2.8",
|