@libraz/mejiro-react 0.9.2 → 0.10.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/dist/index.d.ts +39 -22
- package/dist/index.js +1032 -808
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,8 @@ import { ReactNode, CSSProperties, PointerEvent, TextareaHTMLAttributes, Mutable
|
|
|
5
5
|
import { EpubBook, AssetResolver, EpubParseLimits, EditableEpub, ManuscriptDialect, EpubChapter, EditableEpubBook, EditableEpubSelection, AnnotatedParagraph, AddImageInput, EditableEpubImage, EpubExportOptions, EpubProjectMetadata, EpubProjectAsset, EpubProject } from '@libraz/mejiro/epub';
|
|
6
6
|
export { EditableEpubSelection } from '@libraz/mejiro/epub';
|
|
7
7
|
import { ChapterLayout, SpreadResult, BookOptions, MejiroBookOptions, ComputePageSizeOptions, InChapterAnchor, ReadingAnchor, ManuscriptChapter, PageResult, AnchorRect, AnchorRange, MejiroBook } from '@libraz/mejiro/book';
|
|
8
|
-
import { RenderPage } from '@libraz/mejiro/render';
|
|
8
|
+
import { PageNumberDisplay, RenderPage } from '@libraz/mejiro/render';
|
|
9
|
+
export { PageNumberDisplay } from '@libraz/mejiro/render';
|
|
9
10
|
import { FontFamily, InlineAnnotation } from '@libraz/mejiro/browser';
|
|
10
11
|
|
|
11
12
|
/** Provider that scopes a message catalog to its descendants. */
|
|
@@ -16,7 +17,10 @@ declare function MejiroI18nProvider({ locale, messages, children, }: {
|
|
|
16
17
|
}): ReactNode;
|
|
17
18
|
/** Options for {@link useI18n}. */
|
|
18
19
|
interface UseI18nOptions {
|
|
19
|
-
/**
|
|
20
|
+
/**
|
|
21
|
+
* Built-in locale to use as the base catalog. Defaults to the nearest
|
|
22
|
+
* `MejiroI18nProvider` locale, or `'en'` without one.
|
|
23
|
+
*/
|
|
20
24
|
locale?: MejiroLocale;
|
|
21
25
|
/** Overrides merged on top of the built-in catalog. */
|
|
22
26
|
messages?: Partial<MejiroMessages>;
|
|
@@ -107,7 +111,9 @@ interface MejiroEditorProps {
|
|
|
107
111
|
/** Font choices passed to the preview reader. */
|
|
108
112
|
fonts?: FontChoice[];
|
|
109
113
|
/**
|
|
110
|
-
* Allow editing paragraph text (the "Proofread" section).
|
|
114
|
+
* Allow editing paragraph text (the "Proofread" section). When `false` and
|
|
115
|
+
* `enableRuby` is on, the paragraph text stays visible read-only so a ruby
|
|
116
|
+
* base range can still be selected.
|
|
111
117
|
* @defaultValue true
|
|
112
118
|
*/
|
|
113
119
|
enableProofread?: boolean;
|
|
@@ -158,8 +164,9 @@ interface MejiroEditorProps {
|
|
|
158
164
|
/** Called after export completes. */
|
|
159
165
|
onExport?: (buffer: ArrayBuffer) => void;
|
|
160
166
|
/**
|
|
161
|
-
* Called when loading, image insertion
|
|
162
|
-
* shown in the editor
|
|
167
|
+
* Called when loading, image insertion, export or the preview reader fails.
|
|
168
|
+
* The error is also shown in the editor until a later load, image insertion
|
|
169
|
+
* or export succeeds.
|
|
163
170
|
*/
|
|
164
171
|
onError?: (error: Error) => void;
|
|
165
172
|
}
|
|
@@ -290,11 +297,7 @@ type MejiroReaderMode = 'paginated' | 'scroll';
|
|
|
290
297
|
* converting the index so the page on screen stays visible.
|
|
291
298
|
*/
|
|
292
299
|
type MejiroSpreadMode = 'double' | 'single' | 'auto';
|
|
293
|
-
|
|
294
|
-
* Which page of a spread prints its page number: `'both'` (right = odd,
|
|
295
|
-
* left = even), only `'right'`, only `'left'`, or `'none'`.
|
|
296
|
-
*/
|
|
297
|
-
type PageNumberDisplay = 'both' | 'right' | 'left' | 'none';
|
|
300
|
+
|
|
298
301
|
/**
|
|
299
302
|
* How the reader sizes itself inside its container.
|
|
300
303
|
* - `fill` — fill the container's given height; the spread is fitted inside it,
|
|
@@ -526,7 +529,8 @@ interface MejiroReaderCommonProps {
|
|
|
526
529
|
fetchEpub?: (url: string) => Promise<ArrayBuffer>;
|
|
527
530
|
/**
|
|
528
531
|
* Built-in locale for UI strings (`'en'` / `'ja'`). Pair with `messages`
|
|
529
|
-
* to override individual strings.
|
|
532
|
+
* to override individual strings. Defaults to the nearest `MejiroI18nProvider`
|
|
533
|
+
* locale, or `'en'` without one.
|
|
530
534
|
*/
|
|
531
535
|
locale?: MejiroLocale;
|
|
532
536
|
/**
|
|
@@ -625,9 +629,11 @@ interface MejiroReaderCommonProps {
|
|
|
625
629
|
/** Called when the spread index changes — pair with the `spreadIdx` prop for controlled use. */
|
|
626
630
|
onSpreadIdxChange?: (spreadIdx: number) => void;
|
|
627
631
|
/**
|
|
628
|
-
* Called when the reader
|
|
629
|
-
*
|
|
630
|
-
*
|
|
632
|
+
* Called when the reader moves from one spread to another within the shown
|
|
633
|
+
* book (a change of chapter or spread index, like `spreadChanged`). Receives
|
|
634
|
+
* the anchor of the spread that was just left and the dwell time in
|
|
635
|
+
* milliseconds (computed via `performance.now()`). A book swap and unmount
|
|
636
|
+
* do not report the spread being left. Useful for engagement analytics.
|
|
631
637
|
*/
|
|
632
638
|
onPageRead?: (anchor: ReadingAnchor, dwellMs: number) => void;
|
|
633
639
|
/**
|
|
@@ -813,7 +819,7 @@ interface MejiroManuscriptEditorProps {
|
|
|
813
819
|
onExport?: (buffer: ArrayBuffer) => void;
|
|
814
820
|
/**
|
|
815
821
|
* Called when the EPUB export fails (asset resolution, cover reading, or
|
|
816
|
-
* packaging). The same error is shown in the editor panel, so hosts only
|
|
822
|
+
* packaging) or the preview reader fails. The same error is shown in the editor panel, so hosts only
|
|
817
823
|
* need this to log or report it.
|
|
818
824
|
*/
|
|
819
825
|
onError?: (error: Error) => void;
|
|
@@ -1017,6 +1023,11 @@ interface MejiroScrollViewProps {
|
|
|
1017
1023
|
* provides one on every change.
|
|
1018
1024
|
*/
|
|
1019
1025
|
images?: MultiImageItem[];
|
|
1026
|
+
/**
|
|
1027
|
+
* Which pages print their page number in the running head, by the same rule
|
|
1028
|
+
* as the paginated reader. @defaultValue 'both'
|
|
1029
|
+
*/
|
|
1030
|
+
pageNumbers?: PageNumberDisplay;
|
|
1020
1031
|
/** Pointer-down on an image overlay. */
|
|
1021
1032
|
onImagePointerDown?: (id: string, e: PointerEvent) => void;
|
|
1022
1033
|
/** Pointer-down on an image resize handle. */
|
|
@@ -1030,7 +1041,7 @@ interface MejiroScrollViewProps {
|
|
|
1030
1041
|
* detected via `IntersectionObserver` and reported through
|
|
1031
1042
|
* {@link MejiroScrollViewProps.onVisiblePageChange}.
|
|
1032
1043
|
*/
|
|
1033
|
-
declare function MejiroScrollView({ layout, pageWidth, pageHeight, contentHeight, fontFamily, fontSize, lineSpacing, slotMode, onVisiblePageChange, scrollToPage, pageGap, selectionRects, spreadIdx, images, onImagePointerDown, onImageResizePointerDown, onImageClose, }: MejiroScrollViewProps): ReactNode;
|
|
1044
|
+
declare function MejiroScrollView({ layout, pageWidth, pageHeight, contentHeight, fontFamily, fontSize, lineSpacing, slotMode, onVisiblePageChange, scrollToPage, pageGap, selectionRects, spreadIdx, images, pageNumbers, onImagePointerDown, onImageResizePointerDown, onImageClose, }: MejiroScrollViewProps): ReactNode;
|
|
1034
1045
|
|
|
1035
1046
|
/** Props for {@link MejiroSelectionLayer}. */
|
|
1036
1047
|
interface MejiroSelectionLayerProps {
|
|
@@ -1285,7 +1296,9 @@ interface UseAnnotationsOptions {
|
|
|
1285
1296
|
* every render is safe — only `key` triggers a re-hydration.
|
|
1286
1297
|
*/
|
|
1287
1298
|
storage?: AnnotationsStorage;
|
|
1288
|
-
/**
|
|
1299
|
+
/**
|
|
1300
|
+
* Debounce delay (ms): the latest value is written this long after the last change. A pending write is flushed on page hide, key change and unmount. @defaultValue 250
|
|
1301
|
+
*/
|
|
1289
1302
|
throttleMs?: number;
|
|
1290
1303
|
/**
|
|
1291
1304
|
* Called immediately after each mutation (`add` / `remove` / `update` /
|
|
@@ -1804,7 +1817,8 @@ interface UseManuscriptLayoutReturn {
|
|
|
1804
1817
|
* {@link useManuscriptDraft} for the chapter array and feed the resulting
|
|
1805
1818
|
* {@link ChapterLayout} into {@link MejiroSpread} or {@link MejiroScrollView}.
|
|
1806
1819
|
*
|
|
1807
|
-
* Re-layouts whenever
|
|
1820
|
+
* Re-layouts whenever the chapter's id, title or body, `dialect`, or `book`
|
|
1821
|
+
* change; a new chapter object with the same content does not. The surface is
|
|
1808
1822
|
* observed with {@link ResizeObserver}; size changes trigger a full re-layout
|
|
1809
1823
|
* so pagination stays correct after non-trivial container changes.
|
|
1810
1824
|
*
|
|
@@ -1877,7 +1891,9 @@ interface UseReadingPositionOptions {
|
|
|
1877
1891
|
* SSR consumers can omit this and the hook will fall back to in-memory.
|
|
1878
1892
|
*/
|
|
1879
1893
|
storage?: ReadingPositionStorage;
|
|
1880
|
-
/**
|
|
1894
|
+
/**
|
|
1895
|
+
* Debounce delay (ms): the latest value is written this long after the last change. A pending write is flushed on page hide, key change and unmount. @defaultValue 250
|
|
1896
|
+
*/
|
|
1881
1897
|
throttleMs?: number;
|
|
1882
1898
|
/**
|
|
1883
1899
|
* Called immediately after `save()` (with the new anchor) or `clear()`
|
|
@@ -1890,14 +1906,14 @@ interface UseReadingPositionOptions {
|
|
|
1890
1906
|
interface UseReadingPositionReturn {
|
|
1891
1907
|
/** Most recently persisted position, or `null` if none. */
|
|
1892
1908
|
position: ReadingPositionValue | null;
|
|
1893
|
-
/** Persist a new position (
|
|
1909
|
+
/** Persist a new position (debounced by `throttleMs`). */
|
|
1894
1910
|
save(next: ReadingPositionValue): void;
|
|
1895
1911
|
/** Remove the persisted position. */
|
|
1896
1912
|
clear(): void;
|
|
1897
1913
|
}
|
|
1898
1914
|
/**
|
|
1899
1915
|
* Persistence helper for reader state. Returns the saved anchor and a
|
|
1900
|
-
*
|
|
1916
|
+
* debounced saver. Pair with {@link MejiroReaderHandle.goToAnchor} and
|
|
1901
1917
|
* {@link MejiroReaderHandle.subscribe} for exact reflow-safe restore.
|
|
1902
1918
|
*
|
|
1903
1919
|
* ```tsx
|
|
@@ -1986,4 +2002,5 @@ interface UseSpreadReturn {
|
|
|
1986
2002
|
*/
|
|
1987
2003
|
declare function useSpread(layout: ChapterLayout | null, options?: UseSpreadOptions): UseSpreadReturn;
|
|
1988
2004
|
|
|
1989
|
-
export {
|
|
2005
|
+
export { MejiroChapterNav, MejiroDropZone, MejiroEditor, MejiroI18nProvider, MejiroImageOverlay, MejiroManuscriptEditor, MejiroNotationHighlighter, MejiroPage, MejiroPageIndicator, MejiroPageView, MejiroReader, MejiroScrollView, MejiroSelectionLayer, MejiroSettingsPanel, MejiroShelf, MejiroSpread, MejiroStats, MejiroToc, format, resolveMessages, useAnnotations, useChapterLayout, useEditableEpub, useEpub, useEpubProject, useI18n, useImageOverlay, useLibrary, useManuscriptDraft, useManuscriptLayout, useMejiroBook, useMultiImageOverlay, useReadingPosition, useSpread };
|
|
2006
|
+
export type { AnnotationsStorage, EpubProjectChapterDraft, ImageRect, ManuscriptAutosaveDraft, ManuscriptEditorChapter, ManuscriptPageDimensions, ManuscriptPreviewProps, ManuscriptRecomputeOptions, MejiroChapterNavMode, MejiroChapterNavProps, MejiroChapterNavVariant, MejiroDropZoneProps, MejiroEditorProps, MejiroExportPolicy, MejiroImageOverlayProps, MejiroManuscriptEditorProps, MejiroNotationHighlighterProps, MejiroPageIndicatorProps, MejiroPageProps, MejiroPageViewProps, MejiroReaderCommonProps, MejiroReaderControlledProps, MejiroReaderEventMap, MejiroReaderFileProps, MejiroReaderFit, MejiroReaderHandle, MejiroReaderManuscriptProps, MejiroReaderMode, MejiroReaderProps, MejiroReaderSettingsSlot, MejiroReaderUrlProps, MejiroScrollViewProps, MejiroSelectionLayerProps, MejiroSettingsPanelProps, MejiroShelfProps, MejiroSpreadMode, MejiroSpreadProps, MejiroStatsProps, MejiroTheme, MejiroThemeName, MejiroTocProps, MultiImageItem, PageDimensions, ReadingPosition, ReadingPositionStorage, RecomputeOptions, UseAnnotationsOptions, UseAnnotationsReturn, UseChapterLayoutOptions, UseChapterLayoutReturn, UseEditableEpubOptions, UseEditableEpubReturn, UseEpubOptions, UseEpubProjectOptions, UseEpubProjectReturn, UseEpubReturn, UseI18nOptions, UseImageOverlayOptions, UseImageOverlayReturn, UseLibraryOptions, UseLibraryReturn, UseManuscriptDraftOptions, UseManuscriptDraftReturn, UseManuscriptLayoutOptions, UseManuscriptLayoutReturn, UseMejiroBookOptions, UseMejiroBookReturn, UseMultiImageOverlayOptions, UseMultiImageOverlayReturn, UseReadingPositionOptions, UseReadingPositionReturn, UseSpreadOptions, UseSpreadReturn, VolumeInfo };
|