@f-office/docs-react 0.2.2 → 0.2.3
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 +11 -2
- package/dist/chrome.d.ts +5 -1
- package/dist/f-office-docs.d.ts +6 -2
- package/dist/index.d.ts +0 -1
- package/dist/index.js +489 -418
- package/dist/styles.css +1 -2
- package/dist/ui/portal-theme.d.ts +5 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -10,6 +10,8 @@ npm install @f-office/docs-react @f-office/docs @f-office/core react react-dom
|
|
|
10
10
|
|
|
11
11
|
## Full UI (`<DocsApp />`)
|
|
12
12
|
|
|
13
|
+
`<DocsApp />` and `<DocsCanvas />` stream long documents from Page 1, show a top progress bar (`role="progressbar"`) while loading, and display the growing page count (`Page 1 of N…`) until layout finishes:
|
|
14
|
+
|
|
13
15
|
```tsx
|
|
14
16
|
import { DocsApp } from "@f-office/docs-react";
|
|
15
17
|
import "@f-office/docs-react/styles.css";
|
|
@@ -65,7 +67,7 @@ export function DocsRoute() {
|
|
|
65
67
|
|
|
66
68
|
## Headless React 19 wrapper (`<FOfficeDocs />`)
|
|
67
69
|
|
|
68
|
-
For zero UI chrome (no header, menus, dialogs, or stylesheet required):
|
|
70
|
+
For zero UI chrome (no header, menus, floating outline button, dialogs, or stylesheet required; pass `outlineButton` if you want the floating outline toggle), with optional `onProgress` and `onPagesChange` callbacks for progressive Page-1-first loading:
|
|
69
71
|
|
|
70
72
|
```tsx
|
|
71
73
|
import { FOfficeDocs } from "@f-office/docs-react";
|
|
@@ -73,7 +75,14 @@ import { FOfficeDocs } from "@f-office/docs-react";
|
|
|
73
75
|
export function EmbeddedDoc({ file }: { file: File }) {
|
|
74
76
|
return (
|
|
75
77
|
<div style={{ height: "80vh" }}>
|
|
76
|
-
<FOfficeDocs
|
|
78
|
+
<FOfficeDocs
|
|
79
|
+
source={file}
|
|
80
|
+
zoom="fit-width"
|
|
81
|
+
onProgress={(p) => console.log(p.stage, p.fraction, p.pagesReady)}
|
|
82
|
+
onPagesChange={({ pageCount, complete }) =>
|
|
83
|
+
console.log(`${pageCount}${complete ? "" : "…"} pages`)
|
|
84
|
+
}
|
|
85
|
+
/>
|
|
77
86
|
</div>
|
|
78
87
|
);
|
|
79
88
|
}
|
package/dist/chrome.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type CommandId, type FontMode } from "@f-office/docs/chrome";
|
|
1
|
+
import { type CommandId, type FontMode, type OpenProgress } from "@f-office/docs/chrome";
|
|
2
2
|
import type { Theme } from "./theme.js";
|
|
3
3
|
/** Dialogs opened from the menu bar. */
|
|
4
4
|
export type DialogKind = "shortcuts" | "about" | "advanced";
|
|
@@ -16,6 +16,10 @@ export type ChromeState = {
|
|
|
16
16
|
readonly zoomSteps: readonly number[];
|
|
17
17
|
readonly page: number;
|
|
18
18
|
readonly pageCount: number;
|
|
19
|
+
/** Whether full-document layout has finished (`false` while remaining pages stream). */
|
|
20
|
+
readonly layoutComplete: boolean;
|
|
21
|
+
/** Active loading/pagination progress snapshot, or `null` when idle. */
|
|
22
|
+
readonly progress: OpenProgress | null;
|
|
19
23
|
readonly theme: Theme;
|
|
20
24
|
readonly fonts: FontMode;
|
|
21
25
|
/** Whether the browser supports reading locally installed fonts. */
|
package/dist/f-office-docs.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type CSSProperties, type Ref } from "react";
|
|
2
|
-
import { type DocsChrome, type DocsEvents, type DocsSource, type FOfficeDocsElement, type FontSource, type HighlightItem, type ZoomSetting } from "@f-office/docs";
|
|
2
|
+
import { type DocsChrome, type DocsEvents, type DocsSource, type FOfficeDocsElement, type FontSource, type HighlightItem, type OpenProgress, type ZoomSetting } from "@f-office/docs";
|
|
3
3
|
import type { MenuRequest, View, ViewerFiles } from "@f-office/docs/chrome";
|
|
4
4
|
export type FOfficeDocsProps = {
|
|
5
5
|
/** Ref to the underlying `<f-office-docs>` Custom Element (React 19 plain ref prop). */
|
|
@@ -14,6 +14,8 @@ export type FOfficeDocsProps = {
|
|
|
14
14
|
target?: string | null;
|
|
15
15
|
/** Built-in shadow DOM bar mode (`"none"` by default for headless embedding). */
|
|
16
16
|
chrome?: DocsChrome;
|
|
17
|
+
/** Show the built-in floating outline toggle button (`false` by default when `chrome="none"`, `true` when `chrome="full"`). */
|
|
18
|
+
outlineButton?: boolean;
|
|
17
19
|
/** Read-only mode (`true` by default). */
|
|
18
20
|
readOnly?: boolean;
|
|
19
21
|
/** Outline panel open state. */
|
|
@@ -27,6 +29,8 @@ export type FOfficeDocsProps = {
|
|
|
27
29
|
className?: string;
|
|
28
30
|
style?: CSSProperties;
|
|
29
31
|
onOpen?: (detail: DocsEvents["open"]) => void;
|
|
32
|
+
onPagesChange?: (detail: DocsEvents["pageschange"]) => void;
|
|
33
|
+
onProgress?: (progress: OpenProgress) => void;
|
|
30
34
|
onViewChange?: (view: View) => void;
|
|
31
35
|
onPageChange?: (detail: DocsEvents["pagechange"]) => void;
|
|
32
36
|
onOutlineChange?: (detail: DocsEvents["outlinechange"]) => void;
|
|
@@ -39,4 +43,4 @@ export type FOfficeDocsProps = {
|
|
|
39
43
|
* Unopinionated React 19 wrapper around the `<f-office-docs>` Web Component.
|
|
40
44
|
* Assumes zero UI chrome, menus, or styling framework.
|
|
41
45
|
*/
|
|
42
|
-
export declare function FOfficeDocs({ ref, source, name, zoom, target, chrome, readOnly, outlineOpen, fontSource, highlights, moduleUrls, className, style, onOpen, onViewChange, onPageChange, onOutlineChange, onSelectionChange, onMenu, onError, }: FOfficeDocsProps): import("react").JSX.Element;
|
|
46
|
+
export declare function FOfficeDocs({ ref, source, name, zoom, target, chrome, outlineButton, readOnly, outlineOpen, fontSource, highlights, moduleUrls, className, style, onOpen, onPagesChange, onProgress, onViewChange, onPageChange, onOutlineChange, onSelectionChange, onMenu, onError, }: FOfficeDocsProps): import("react").JSX.Element;
|
package/dist/index.d.ts
CHANGED