zreader 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/LICENSE +21 -0
- package/README.md +467 -2
- package/dist/agent/index.d.ts +90 -0
- package/dist/agent/index.js +293 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/agent/react/index.d.ts +65 -0
- package/dist/agent/react/index.js +286 -0
- package/dist/agent/react/index.js.map +1 -0
- package/dist/blocks-DwR7l7pz.d.ts +20 -0
- package/dist/chunk-3WQBK6DE.js +47 -0
- package/dist/chunk-3WQBK6DE.js.map +1 -0
- package/dist/chunk-DYQNGV46.js +31 -0
- package/dist/chunk-DYQNGV46.js.map +1 -0
- package/dist/chunk-ISI35TCM.js +62 -0
- package/dist/chunk-ISI35TCM.js.map +1 -0
- package/dist/chunk-RNSAFDZ5.js +105 -0
- package/dist/chunk-RNSAFDZ5.js.map +1 -0
- package/dist/config/index.cjs +196 -0
- package/dist/config/index.cjs.map +1 -0
- package/dist/config/index.d.cts +159 -0
- package/dist/config/index.d.ts +159 -0
- package/dist/config/index.js +182 -0
- package/dist/config/index.js.map +1 -0
- package/dist/content/index.d.ts +143 -0
- package/dist/content/index.js +379 -0
- package/dist/content/index.js.map +1 -0
- package/dist/core/index.d.ts +262 -0
- package/dist/core/index.js +935 -0
- package/dist/core/index.js.map +1 -0
- package/dist/editor/index.d.ts +19 -0
- package/dist/editor/index.js +277 -0
- package/dist/editor/index.js.map +1 -0
- package/dist/index-Bp5oIiZd.d.ts +61 -0
- package/dist/next/client/index.d.ts +8 -0
- package/dist/next/client/index.js +13 -0
- package/dist/next/client/index.js.map +1 -0
- package/dist/next/index.cjs +275 -0
- package/dist/next/index.cjs.map +1 -0
- package/dist/next/index.d.cts +47 -0
- package/dist/next/index.d.ts +47 -0
- package/dist/next/index.js +265 -0
- package/dist/next/index.js.map +1 -0
- package/dist/next/server/index.d.ts +81 -0
- package/dist/next/server/index.js +51 -0
- package/dist/next/server/index.js.map +1 -0
- package/dist/react/index.d.ts +392 -0
- package/dist/react/index.js +2798 -0
- package/dist/react/index.js.map +1 -0
- package/dist/reader.css +116 -0
- package/dist/rehype/index.d.ts +27 -0
- package/dist/rehype/index.js +4 -0
- package/dist/rehype/index.js.map +1 -0
- package/dist/stubs/empty-config.d.ts +9 -0
- package/dist/stubs/empty-config.js +7 -0
- package/dist/stubs/empty-config.js.map +1 -0
- package/dist/stubs/server-only.d.ts +2 -0
- package/dist/stubs/server-only.js +6 -0
- package/dist/stubs/server-only.js.map +1 -0
- package/dist/styles.css +1 -0
- package/dist/tailwind.css +42 -0
- package/dist/types-xkdpkPxA.d.ts +147 -0
- package/dist/user-config/index.d.ts +17 -0
- package/dist/user-config/index.js +35 -0
- package/dist/user-config/index.js.map +1 -0
- package/dist/virtual-config/index.d.ts +6 -0
- package/dist/virtual-config/index.js +10 -0
- package/dist/virtual-config/index.js.map +1 -0
- package/package.json +237 -4
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ComponentType, AnchorHTMLAttributes, ReactNode } from 'react';
|
|
3
|
+
import { BookMeta, ReaderClientOptions, StorageAdapter, ReaderStore, Bookmark, Highlight, PadScope, Pad, BookProgress, ReaderSettings, ChapterMeta, TocEntry, ResolvedHighlight, TextSpan, TextIndex, PadScopeKind, FontFamily, Leading, Measure, HighlightColor, TextSize } from 'zreader';
|
|
4
|
+
export { BookMeta, BookProgress, Bookmark, ChapterMeta, ChapterProgress, Highlight, HighlightColor, Pad, PadScope, ReaderClientOptions, ReaderSettings, ThemeName, TocEntry } from 'zreader';
|
|
5
|
+
|
|
6
|
+
/** Any router link with an `href` (e.g. next/link). */
|
|
7
|
+
type LinkComponent = ComponentType<AnchorHTMLAttributes<HTMLAnchorElement> & {
|
|
8
|
+
href: string;
|
|
9
|
+
children?: ReactNode;
|
|
10
|
+
}>;
|
|
11
|
+
declare const DefaultLink: react.ForwardRefExoticComponent<AnchorHTMLAttributes<HTMLAnchorElement> & {
|
|
12
|
+
href: string;
|
|
13
|
+
} & react.RefAttributes<HTMLAnchorElement>>;
|
|
14
|
+
/** `${basePath}/${bookId}/${chapterId}#${hash}` */
|
|
15
|
+
declare function defaultHref(basePath: string, bookId: string, chapterId?: string, hash?: string): string;
|
|
16
|
+
|
|
17
|
+
type DeepPartial<T> = T extends unknown[] ? T : T extends object ? {
|
|
18
|
+
[K in keyof T]?: DeepPartial<T[K]>;
|
|
19
|
+
} : T;
|
|
20
|
+
/** Deep merge for client options (arrays replace). Kept here so zod stays out of the client bundle. */
|
|
21
|
+
declare function mergeOptions<T>(base: T, ...overrides: unknown[]): T;
|
|
22
|
+
/** Builds a link into the reader. `chapterId` omitted = the book's contents page. */
|
|
23
|
+
type HrefFor = (bookId: string, chapterId?: string, hash?: string) => string;
|
|
24
|
+
/** What the reader shows in the middle of its top bar. */
|
|
25
|
+
type HeaderSlot = ReactNode | ((ctx: {
|
|
26
|
+
book: BookMeta;
|
|
27
|
+
chapter: {
|
|
28
|
+
id: string;
|
|
29
|
+
title: string;
|
|
30
|
+
};
|
|
31
|
+
}) => ReactNode);
|
|
32
|
+
interface Library {
|
|
33
|
+
/** Every book known to the provider (from `books`). */
|
|
34
|
+
books: BookMeta[];
|
|
35
|
+
getBook(id: string): BookMeta | undefined;
|
|
36
|
+
Link: LinkComponent;
|
|
37
|
+
href: HrefFor;
|
|
38
|
+
headerSlot?: HeaderSlot;
|
|
39
|
+
readerActions?: ReactNode;
|
|
40
|
+
}
|
|
41
|
+
interface ReaderContextValue {
|
|
42
|
+
store: ReaderStore;
|
|
43
|
+
options: ReaderClientOptions;
|
|
44
|
+
library: Library;
|
|
45
|
+
}
|
|
46
|
+
interface ReaderProviderProps {
|
|
47
|
+
/** Usually `config.reader` from reader.config.ts (see <ReaderRoot>). */
|
|
48
|
+
options?: DeepPartial<ReaderClientOptions>;
|
|
49
|
+
/** Inline overrides, merged on top of `options`. */
|
|
50
|
+
overrides?: DeepPartial<ReaderClientOptions>;
|
|
51
|
+
adapter?: StorageAdapter;
|
|
52
|
+
/** Provide your own store (advanced; e.g. tests). */
|
|
53
|
+
store?: ReaderStore;
|
|
54
|
+
onStorageError?: (error: unknown) => void;
|
|
55
|
+
/**
|
|
56
|
+
* Manage the colour theme with next-themes (class on <html>, no-flash script).
|
|
57
|
+
* Set to `false` if your app already renders a next-themes <ThemeProvider>.
|
|
58
|
+
*/
|
|
59
|
+
manageTheme?: boolean;
|
|
60
|
+
/** Render a sonner <Toaster>. Set to `false` if your app already has one. */
|
|
61
|
+
toaster?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* The catalogue: lets <BookShelf />, <BookHome book="id" /> and
|
|
64
|
+
* <Reader book="id" chapter="id" /> work from ids alone.
|
|
65
|
+
*/
|
|
66
|
+
books?: BookMeta[];
|
|
67
|
+
/** Router link used by every component (e.g. next/link). Defaults to <a>. */
|
|
68
|
+
Link?: LinkComponent;
|
|
69
|
+
/** URL builder. Defaults to `${basePath}/${bookId}/${chapterId}#hash`. */
|
|
70
|
+
hrefFor?: HrefFor;
|
|
71
|
+
/**
|
|
72
|
+
* Default content for the middle of the reader's top bar: text, your logo,
|
|
73
|
+
* or any component. Omit to show the book and chapter titles.
|
|
74
|
+
*/
|
|
75
|
+
headerSlot?: HeaderSlot;
|
|
76
|
+
/**
|
|
77
|
+
* Default buttons for the right of the reader's top bar (before the bookmark
|
|
78
|
+
* toggle), e.g. `<CopyReference markdown />`. A <Reader>'s `actions` replaces
|
|
79
|
+
* them; `actions={null}` hides them for that chapter.
|
|
80
|
+
*/
|
|
81
|
+
readerActions?: ReactNode;
|
|
82
|
+
children: ReactNode;
|
|
83
|
+
}
|
|
84
|
+
declare function ReaderProvider({ options, overrides, adapter, store: external, onStorageError, manageTheme, toaster, books, Link, hrefFor, headerSlot, readerActions, children, }: ReaderProviderProps): react.JSX.Element;
|
|
85
|
+
declare function useReader(): ReaderContextValue;
|
|
86
|
+
/** The provider's catalogue, link component and URL builder. */
|
|
87
|
+
declare function useLibrary(): Library;
|
|
88
|
+
/**
|
|
89
|
+
* Resolve a book given as an id (looked up in the provider's `books`) or as
|
|
90
|
+
* metadata. Throws a descriptive error when an id is unknown.
|
|
91
|
+
*/
|
|
92
|
+
declare function useBook(book: BookMeta | string): BookMeta;
|
|
93
|
+
declare function useReaderStore(): ReaderStore;
|
|
94
|
+
/** `false` during SSR and hydration, `true` afterwards. */
|
|
95
|
+
declare function useHydrated(): boolean;
|
|
96
|
+
declare function useSettings(): [ReaderSettings, ReaderStore["updateSettings"]];
|
|
97
|
+
declare function useHighlights(bookId: string, chapterId?: string): Highlight[];
|
|
98
|
+
declare function useBookmarks(bookId: string): Bookmark[];
|
|
99
|
+
declare function useProgress(bookId: string): BookProgress;
|
|
100
|
+
declare function usePad(scope: PadScope): Pad;
|
|
101
|
+
declare function useMediaQuery(query: string, serverValue?: boolean): boolean;
|
|
102
|
+
/** Desktop layout breakpoint (Tailwind `lg`). Mobile-first: `false` on the server. */
|
|
103
|
+
declare function useIsDesktop(): boolean;
|
|
104
|
+
|
|
105
|
+
interface ReaderProps {
|
|
106
|
+
/** A book id from the provider's catalogue, or the book's metadata. */
|
|
107
|
+
book: BookMeta | string;
|
|
108
|
+
/** A chapter id of that book, or the chapter's metadata. */
|
|
109
|
+
chapter: ChapterMeta | string;
|
|
110
|
+
/** Defaults to the neighbouring chapters in the book. Pass `null` to hide. */
|
|
111
|
+
prev?: ChapterMeta | null;
|
|
112
|
+
next?: ChapterMeta | null;
|
|
113
|
+
/** Contents of this chapter. Defaults to the h2/h3 headings found in the rendered content. */
|
|
114
|
+
toc?: TocEntry[];
|
|
115
|
+
contentHash?: string;
|
|
116
|
+
/** Sanitized chapter HTML (from `renderChapter()` / `renderHtml()` on the server). */
|
|
117
|
+
html?: string;
|
|
118
|
+
/** Or render the chapter yourself (e.g. an MDX component). */
|
|
119
|
+
children?: ReactNode;
|
|
120
|
+
/** Router link, e.g. `next/link`. Defaults to the provider's. */
|
|
121
|
+
Link?: LinkComponent;
|
|
122
|
+
/** Override URL building. Defaults to the provider's. */
|
|
123
|
+
hrefFor?: HrefFor;
|
|
124
|
+
/**
|
|
125
|
+
* Middle of the top bar: a string (shown as text), any element (your logo,
|
|
126
|
+
* a description…), or a function of `{ book, chapter }`. Defaults to the
|
|
127
|
+
* provider's `headerSlot`, then to <ReaderTitle />. Combine freely, e.g.
|
|
128
|
+
* `<><Logo /><ReaderTitle /></>`.
|
|
129
|
+
*/
|
|
130
|
+
header?: HeaderSlot;
|
|
131
|
+
/**
|
|
132
|
+
* Buttons for the right side of the top bar, before the bookmark toggle,
|
|
133
|
+
* e.g. `<CopyReference />` from `zreader/agent/react`. Defaults to the
|
|
134
|
+
* provider's `readerActions`; `null` hides them.
|
|
135
|
+
*/
|
|
136
|
+
actions?: ReactNode;
|
|
137
|
+
/** Where the back button goes. Defaults to the book page. */
|
|
138
|
+
backHref?: string;
|
|
139
|
+
className?: string;
|
|
140
|
+
}
|
|
141
|
+
interface ReaderChapterValue {
|
|
142
|
+
book: BookMeta;
|
|
143
|
+
chapter: ChapterMeta;
|
|
144
|
+
/** Page URL within this book (the reader's `hrefFor`): `href()` is the book, `href(chapterId)` a chapter. */
|
|
145
|
+
href: (chapterId?: string, hash?: string) => string;
|
|
146
|
+
}
|
|
147
|
+
/** The book and chapter of the surrounding <Reader> (for custom header content and actions). */
|
|
148
|
+
declare function useReaderChapter(): ReaderChapterValue;
|
|
149
|
+
/** The default header content: book title over chapter title. */
|
|
150
|
+
declare function ReaderTitle({ className }: {
|
|
151
|
+
className?: string;
|
|
152
|
+
}): react.JSX.Element;
|
|
153
|
+
declare function Reader({ book: bookArg, chapter: chapterArg, prev: prevArg, next: nextArg, toc: tocProp, contentHash, html, children, Link: LinkProp, hrefFor, header, actions, backHref, className, }: ReaderProps): react.JSX.Element;
|
|
154
|
+
|
|
155
|
+
interface BookNavProps {
|
|
156
|
+
/** A book id from the provider's catalogue, or the book's metadata. */
|
|
157
|
+
book: BookMeta | string;
|
|
158
|
+
/** Overrides the provider's link component. */
|
|
159
|
+
Link?: LinkComponent;
|
|
160
|
+
/** Overrides the provider's URL builder. */
|
|
161
|
+
hrefFor?: HrefFor;
|
|
162
|
+
className?: string;
|
|
163
|
+
}
|
|
164
|
+
/** "Start reading" / "Continue: Chapter 3 · 42%" card for a book page. */
|
|
165
|
+
declare function ContinueReading({ book: bookArg, Link: LinkProp, hrefFor, className }: BookNavProps): react.JSX.Element | null;
|
|
166
|
+
/** Chapter list with read state, grouped by `part` when chapters declare one. */
|
|
167
|
+
declare function ChapterList({ book: bookArg, Link: LinkProp, hrefFor, className }: BookNavProps): react.JSX.Element;
|
|
168
|
+
interface BookShelfProps {
|
|
169
|
+
/** Defaults to the provider's catalogue (<ReaderProvider books>). */
|
|
170
|
+
books?: BookMeta[];
|
|
171
|
+
Link?: LinkComponent;
|
|
172
|
+
hrefFor?: HrefFor;
|
|
173
|
+
title?: string;
|
|
174
|
+
description?: string;
|
|
175
|
+
/**
|
|
176
|
+
* Render only the grid, without the full-page shell (background, padding,
|
|
177
|
+
* title), for embedding inside a host site's own page layout.
|
|
178
|
+
*/
|
|
179
|
+
embedded?: boolean;
|
|
180
|
+
className?: string;
|
|
181
|
+
}
|
|
182
|
+
/** Grid of book cards linking to each book's home. */
|
|
183
|
+
declare function BookShelf({ books: booksProp, Link: LinkProp, hrefFor, title, description, embedded, className }: BookShelfProps): react.JSX.Element;
|
|
184
|
+
interface BookHomeProps extends BookNavProps {
|
|
185
|
+
/** Back link (e.g. to the shelf). */
|
|
186
|
+
backHref?: string;
|
|
187
|
+
backLabel?: string;
|
|
188
|
+
/**
|
|
189
|
+
* Render only the continue card and chapter list, without the full-page shell
|
|
190
|
+
* or title block, for embedding inside a host site's own page layout.
|
|
191
|
+
*/
|
|
192
|
+
embedded?: boolean;
|
|
193
|
+
}
|
|
194
|
+
/** A book's contents page: title, authors, continue card and chapter list. */
|
|
195
|
+
declare function BookHome({ book: bookArg, Link: LinkProp, hrefFor, backHref, backLabel, embedded, className }: BookHomeProps): react.JSX.Element;
|
|
196
|
+
/** Alias of <BookHome>: a book's contents page. */
|
|
197
|
+
declare const BookContents: typeof BookHome;
|
|
198
|
+
type BookContentsProps = BookHomeProps;
|
|
199
|
+
|
|
200
|
+
type ContentsTab = "contents" | "highlights" | "bookmarks";
|
|
201
|
+
interface ContentsSheetProps {
|
|
202
|
+
open: boolean;
|
|
203
|
+
onOpenChange: (open: boolean) => void;
|
|
204
|
+
tab: ContentsTab;
|
|
205
|
+
onTabChange: (tab: ContentsTab) => void;
|
|
206
|
+
book: BookMeta;
|
|
207
|
+
chapterId: string;
|
|
208
|
+
toc: TocEntry[];
|
|
209
|
+
hrefFor: (chapterId: string, hash?: string) => string;
|
|
210
|
+
Link: LinkComponent;
|
|
211
|
+
orphanedIds: ReadonlySet<string>;
|
|
212
|
+
onJumpHighlight: (id: string) => void;
|
|
213
|
+
onJumpBlock: (blockId: string) => void;
|
|
214
|
+
onJumpHeading: (id: string) => void;
|
|
215
|
+
}
|
|
216
|
+
declare function ContentsSheet(p: ContentsSheetProps): react.JSX.Element;
|
|
217
|
+
|
|
218
|
+
interface HighlightPanelProps {
|
|
219
|
+
highlight: Highlight | null;
|
|
220
|
+
colors: string[];
|
|
221
|
+
focusNote?: boolean;
|
|
222
|
+
onColor: (color: string) => void;
|
|
223
|
+
onNote: (note: string) => void;
|
|
224
|
+
onDelete: () => void;
|
|
225
|
+
onQuote?: () => void;
|
|
226
|
+
onCopy?: () => void;
|
|
227
|
+
onClose: () => void;
|
|
228
|
+
}
|
|
229
|
+
declare function HighlightPanel({ highlight, colors, focusNote, onColor, onNote, onDelete, onQuote, onCopy, onClose }: HighlightPanelProps): react.JSX.Element;
|
|
230
|
+
|
|
231
|
+
interface SelectionRect {
|
|
232
|
+
top: number;
|
|
233
|
+
left: number;
|
|
234
|
+
bottom: number;
|
|
235
|
+
right: number;
|
|
236
|
+
width: number;
|
|
237
|
+
height: number;
|
|
238
|
+
}
|
|
239
|
+
interface SelectionState {
|
|
240
|
+
span: TextSpan;
|
|
241
|
+
text: string;
|
|
242
|
+
rect: SelectionRect;
|
|
243
|
+
}
|
|
244
|
+
interface ResumeState {
|
|
245
|
+
blockId: string;
|
|
246
|
+
percent: number;
|
|
247
|
+
}
|
|
248
|
+
interface ChapterEngineOptions {
|
|
249
|
+
bookId: string;
|
|
250
|
+
chapterId: string;
|
|
251
|
+
contentHash?: string;
|
|
252
|
+
/** The chapter root element (pass callback-ref state so remounts re-bind). */
|
|
253
|
+
root: HTMLElement | null;
|
|
254
|
+
/** Scrolling element. `null` = the window (mobile layout). */
|
|
255
|
+
scroller?: HTMLElement | null;
|
|
256
|
+
/** px reserved at the top of the scroll viewport (sticky header). */
|
|
257
|
+
topOffset?: number;
|
|
258
|
+
onHighlightTap?: (id: string) => void;
|
|
259
|
+
}
|
|
260
|
+
/** Tiny external store so only <ReadingProgress> re-renders while scrolling. */
|
|
261
|
+
declare function createValueStore(initial: number): {
|
|
262
|
+
get: () => number;
|
|
263
|
+
set(v: number): void;
|
|
264
|
+
subscribe(l: () => void): () => boolean;
|
|
265
|
+
};
|
|
266
|
+
type ValueStore = ReturnType<typeof createValueStore>;
|
|
267
|
+
declare function useValueStore(store: ValueStore): number;
|
|
268
|
+
declare function useChapterEngine(opts: ChapterEngineOptions): {
|
|
269
|
+
highlights: Highlight[];
|
|
270
|
+
resolved: ResolvedHighlight[];
|
|
271
|
+
orphaned: Highlight[];
|
|
272
|
+
selection: SelectionState | null;
|
|
273
|
+
activeId: string | null;
|
|
274
|
+
setActiveId: react.Dispatch<react.SetStateAction<string | null>>;
|
|
275
|
+
resume: ResumeState | null;
|
|
276
|
+
dismissResume: () => void;
|
|
277
|
+
percentStore: {
|
|
278
|
+
get: () => number;
|
|
279
|
+
set(v: number): void;
|
|
280
|
+
subscribe(l: () => void): () => boolean;
|
|
281
|
+
};
|
|
282
|
+
domToc: TocEntry[];
|
|
283
|
+
clearSelection: () => void;
|
|
284
|
+
selectSpan: (span: TextSpan) => void;
|
|
285
|
+
expandSelectionToSentences: (span?: TextSpan) => void;
|
|
286
|
+
createHighlight: (span: TextSpan, color?: string, note?: string) => Highlight | null;
|
|
287
|
+
scrollToHighlight: (id: string, smooth?: boolean) => boolean;
|
|
288
|
+
scrollToBlock: (blockId: string, smooth?: boolean) => boolean;
|
|
289
|
+
scrollToHeading: (id: string, smooth?: boolean) => boolean;
|
|
290
|
+
scrollToTop: () => void;
|
|
291
|
+
getTopBlock: () => Element | null;
|
|
292
|
+
getIndex: () => TextIndex | null;
|
|
293
|
+
};
|
|
294
|
+
type ChapterEngine = ReturnType<typeof useChapterEngine>;
|
|
295
|
+
|
|
296
|
+
interface SelectionToolbarProps {
|
|
297
|
+
selection: SelectionState | null;
|
|
298
|
+
colors: string[];
|
|
299
|
+
onHighlight: (span: TextSpan, color: string) => void;
|
|
300
|
+
onNote: (span: TextSpan) => void;
|
|
301
|
+
onSentence: (span: TextSpan) => void;
|
|
302
|
+
onQuote?: (span: TextSpan, text: string) => void;
|
|
303
|
+
onCopy?: (text: string) => void;
|
|
304
|
+
onDismiss: () => void;
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Actions for the current text selection. Desktop: a Popover anchored to the
|
|
308
|
+
* selection (virtual anchor). Mobile: docked above the safe area, out of the
|
|
309
|
+
* way of the native selection callout.
|
|
310
|
+
*/
|
|
311
|
+
declare function SelectionToolbar({ selection, colors, onHighlight, onNote, onSentence, onQuote, onCopy, onDismiss }: SelectionToolbarProps): react.JSX.Element | null;
|
|
312
|
+
|
|
313
|
+
interface SettingsPanelProps {
|
|
314
|
+
open: boolean;
|
|
315
|
+
onOpenChange: (open: boolean) => void;
|
|
316
|
+
book?: BookMeta;
|
|
317
|
+
}
|
|
318
|
+
declare function SettingsPanel({ open, onOpenChange, book }: SettingsPanelProps): react.JSX.Element;
|
|
319
|
+
|
|
320
|
+
declare function scopeFor(kind: PadScopeKind, bookId: string, chapterId: string): PadScope;
|
|
321
|
+
declare function scopeKey(scope: PadScope): string;
|
|
322
|
+
interface ScratchpadPanelProps {
|
|
323
|
+
bookId: string;
|
|
324
|
+
chapterId: string;
|
|
325
|
+
kind: PadScopeKind;
|
|
326
|
+
onKindChange: (kind: PadScopeKind) => void;
|
|
327
|
+
onClose?: () => void;
|
|
328
|
+
onEditorFocus?: () => void;
|
|
329
|
+
/** Filename stem for exports. */
|
|
330
|
+
title?: string;
|
|
331
|
+
}
|
|
332
|
+
declare function ScratchpadPanel({ bookId, chapterId, kind, onKindChange, onClose, onEditorFocus, title }: ScratchpadPanelProps): react.JSX.Element;
|
|
333
|
+
|
|
334
|
+
interface ResponsivePanelProps {
|
|
335
|
+
open: boolean;
|
|
336
|
+
onOpenChange: (open: boolean) => void;
|
|
337
|
+
title: ReactNode;
|
|
338
|
+
description?: ReactNode;
|
|
339
|
+
/** Desktop surface. Mobile is always a bottom drawer. */
|
|
340
|
+
desktop?: "dialog" | "sheet-left" | "sheet-right";
|
|
341
|
+
/** Hide the header visually (still announced to assistive tech). */
|
|
342
|
+
hideHeader?: boolean;
|
|
343
|
+
footer?: ReactNode;
|
|
344
|
+
className?: string;
|
|
345
|
+
children: ReactNode;
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* shadcn "responsive dialog" pattern: a vaul Drawer on mobile, a Dialog or
|
|
349
|
+
* Sheet on desktop. Mobile-first: renders the Drawer during SSR.
|
|
350
|
+
*/
|
|
351
|
+
declare function ResponsivePanel({ open, onOpenChange, title, description, desktop, hideHeader, footer, className, children, }: ResponsivePanelProps): react.JSX.Element;
|
|
352
|
+
|
|
353
|
+
interface PartGroup {
|
|
354
|
+
part: string | null;
|
|
355
|
+
items: Array<{
|
|
356
|
+
chapter: ChapterMeta;
|
|
357
|
+
index: number;
|
|
358
|
+
}>;
|
|
359
|
+
}
|
|
360
|
+
/** Consecutive chapters sharing a `part` are grouped; books without parts yield one group. */
|
|
361
|
+
declare function groupByPart(chapters: ChapterMeta[]): PartGroup[];
|
|
362
|
+
/** Short list marker: frontmatter `number`, else the 1-based position. */
|
|
363
|
+
declare function chapterMarker(chapter: ChapterMeta, index: number): string;
|
|
364
|
+
|
|
365
|
+
/** Trigger a client-side file download. */
|
|
366
|
+
declare function downloadFile(filename: string, content: string, type?: string): void;
|
|
367
|
+
declare function copyText(text: string): Promise<boolean>;
|
|
368
|
+
|
|
369
|
+
interface CalloutProps {
|
|
370
|
+
title?: string;
|
|
371
|
+
children?: ReactNode;
|
|
372
|
+
}
|
|
373
|
+
/** `<Callout title="…">…</Callout>` for MDX chapters. Ignored by highlighting. */
|
|
374
|
+
declare function Callout({ title, children }: CalloutProps): react.JSX.Element;
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* Settings → literal Tailwind classes. Keeping every class as a full string
|
|
378
|
+
* literal lets Tailwind see them at build time; nothing is styled inline.
|
|
379
|
+
*/
|
|
380
|
+
declare const TEXT_SIZE_CLASS: Record<TextSize, string>;
|
|
381
|
+
declare const LEADING_CLASS: Record<Leading, string>;
|
|
382
|
+
declare const MEASURE_CLASS: Record<Measure, string>;
|
|
383
|
+
declare const FONT_CLASS: Record<FontFamily, string>;
|
|
384
|
+
declare const SWATCH_CLASS: Record<HighlightColor, string>;
|
|
385
|
+
declare const QUOTE_BORDER_CLASS: Record<HighlightColor, string>;
|
|
386
|
+
declare function swatchClass(color: string): string;
|
|
387
|
+
declare function quoteBorderClass(color: string): string;
|
|
388
|
+
/** Shared typography for chapter content: shadcn tokens via typography modifiers. */
|
|
389
|
+
declare const PROSE_CLASS = "prose max-w-none text-foreground prose-headings:text-foreground prose-headings:scroll-mt-20 prose-p:text-foreground prose-li:text-foreground prose-strong:text-foreground prose-a:text-primary prose-a:underline-offset-4 prose-blockquote:border-l-border prose-blockquote:text-muted-foreground prose-code:text-foreground prose-pre:bg-muted prose-pre:text-foreground prose-hr:border-border prose-th:text-foreground prose-td:text-foreground prose-figcaption:text-muted-foreground prose-img:rounded-lg prose-table:block prose-table:max-w-full prose-table:overflow-x-auto prose-th:align-bottom prose-td:align-top";
|
|
390
|
+
|
|
391
|
+
export { BookContents, BookHome, BookShelf, Callout, ChapterList, ContentsSheet, ContinueReading, DefaultLink, FONT_CLASS, HighlightPanel, LEADING_CLASS, MEASURE_CLASS, PROSE_CLASS, QUOTE_BORDER_CLASS, Reader, ReaderProvider, ReaderTitle, ResponsivePanel, SWATCH_CLASS, ScratchpadPanel, SelectionToolbar, SettingsPanel, TEXT_SIZE_CLASS, chapterMarker, copyText, defaultHref, downloadFile, groupByPart, mergeOptions, quoteBorderClass, scopeFor, scopeKey, swatchClass, useBook, useBookmarks, useChapterEngine, useHighlights, useHydrated, useIsDesktop, useLibrary, useMediaQuery, usePad, useProgress, useReader, useReaderChapter, useReaderStore, useSettings, useValueStore };
|
|
392
|
+
export type { BookContentsProps, BookHomeProps, BookNavProps, BookShelfProps, CalloutProps, ChapterEngine, ChapterEngineOptions, ContentsSheetProps, ContentsTab, HeaderSlot, HighlightPanelProps, HrefFor, Library, LinkComponent, PartGroup, ReaderChapterValue, ReaderProps, ReaderProviderProps, ResponsivePanelProps, ScratchpadPanelProps, SelectionState, SelectionToolbarProps, SettingsPanelProps };
|