@rebodocs/viewer 0.0.0-stage → 0.12.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.
@@ -0,0 +1,52 @@
1
+ import { type Doc } from '@rebodocs/core/internal';
2
+ import { Editor } from '@rebodocs/editor';
3
+ /** A document: the bytes of a .docx, or one already read with `importDocx` of `@rebodocs/core`. */
4
+ export type ViewerSource = Uint8Array | ArrayBuffer | Doc;
5
+ /** How the pages are set out: one under another, each whole on the screen, or all of them at once. */
6
+ export type ViewerLayout = 'pages' | 'all';
7
+ export interface ViewerOptions {
8
+ /** How the pages are set out at first: one under another ('pages', as it comes), or all at once ('all'). */
9
+ layout?: ViewerLayout;
10
+ /** False to leave out the bar floating over the pages; the layout and the zoom are then the application's. */
11
+ bar?: boolean;
12
+ }
13
+ export interface Viewer {
14
+ /** The editor that draws the pages, read only. */
15
+ readonly editor: Editor;
16
+ /** How many pages the document has. */
17
+ readonly pages: number;
18
+ readonly layout: ViewerLayout;
19
+ setLayout(mode: ViewerLayout): void;
20
+ /** The browser's print dialog, with the pages as they are laid out: to paper, or to a PDF. */
21
+ print(): void;
22
+ destroy(): void;
23
+ }
24
+ /**
25
+ * The width each page is shown at so that `pages` pages, each `ratio` times as tall as it is wide, all fit in
26
+ * `width` × `height`, as many across as that takes: the largest that does. When none is as wide as a page is
27
+ * still made out at, pages of a set width, and the rest is scrolled to.
28
+ */
29
+ export declare function pageWidthToFit(pages: number, ratio: number, width: number, height: number): number;
30
+ /**
31
+ * A document to read in `container`, which must have a size: the editor, read only, and the status bar floating
32
+ * over its pages. The words are those of the language set with `setLocale`.
33
+ */
34
+ export declare function createViewer(container: HTMLElement, source: ViewerSource, options?: ViewerOptions): Viewer;
35
+ /**
36
+ * The first page of a document as the editor draws it, for a thumbnail: drawn once out of sight, and given as a copy
37
+ * of that page at its real size, its pictures in it, inside an element of the editor's class so its rules still hold
38
+ * (`data-width` and `data-height` say the size, in pixels), to be shown made smaller.
39
+ */
40
+ export declare function pageThumbnail(source: ViewerSource): Promise<HTMLElement>;
41
+ export interface PagePictureOptions {
42
+ /** 'image/jpeg', as it comes, or 'image/png'. */
43
+ type?: string;
44
+ /** Of a JPEG, from 0 to 1. */
45
+ quality?: number;
46
+ }
47
+ /**
48
+ * The first page of a document as a picture, its longest side `size` pixels: what the editor draws, put in an SVG
49
+ * with the editor's stylesheet and drawn on a canvas, its pictures in it. A font the document carries is drawn in
50
+ * the one of the system nearest it.
51
+ */
52
+ export declare function pagePicture(source: ViewerSource, size: number, options?: PagePictureOptions): Promise<Blob>;