@p10node/office-engine 0.2.3 → 0.4.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 +1 -0
- package/dist/{DocViewer-CT8VAa1L.js → DocViewer-BEaMBKhh.js} +2231 -2161
- package/dist/DocViewer-BEaMBKhh.js.map +1 -0
- package/dist/embed.js +17 -8
- package/dist/embed.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/office-engine.embed.js +40 -40
- package/dist/types/embed.d.ts +2 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/react/DocViewer.d.ts +11 -0
- package/dist/types/react/common/Slots.d.ts +6 -0
- package/dist/types/react/common/hooks.d.ts +11 -0
- package/package.json +1 -1
- package/dist/DocViewer-CT8VAa1L.js.map +0 -1
package/dist/types/embed.d.ts
CHANGED
|
@@ -10,7 +10,8 @@ export declare function mount(el: HTMLElement, options: MountOptions): MountedVi
|
|
|
10
10
|
/**
|
|
11
11
|
* `<office-viewer src="/file.xlsx" style="height:600px"></office-viewer>`
|
|
12
12
|
* Rendered inside a shadow root so host page CSS cannot leak in.
|
|
13
|
-
* Attributes: src, name, editable, toolbar / thumbnails / save / download / file-menu / open ("false" to
|
|
13
|
+
* Attributes: src, name, editable, toolbar / thumbnails / save / download / file-menu / open / capture-select-all ("false" to turn off),
|
|
14
|
+
* theme ("light" | "dark" | "auto");
|
|
14
15
|
* real-time collaboration: collab (hub WebSocket URL), room, user (display name), base (snapshot seq `src` was opened at).
|
|
15
16
|
* Property: `file` (File/Blob/ArrayBuffer) for local data.
|
|
16
17
|
*/
|
package/dist/types/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export { SlideView } from './react/pptx/Slide';
|
|
|
8
8
|
export { useDocument, type DocumentState } from './react/useDocument';
|
|
9
9
|
export { injectStyles, stylesText } from './react/injectStyles';
|
|
10
10
|
export type { Zoom } from './react/common/ZoomControl';
|
|
11
|
+
export type { Theme } from './react/common/hooks';
|
|
11
12
|
export { DocumentClient, setDefaultWorker, type OpenOptions } from './core/worker/client';
|
|
12
13
|
export type { DocSource } from './core/source';
|
|
13
14
|
export type { DocKind } from './core/opc';
|
|
@@ -3,6 +3,7 @@ import type { DocSource } from '../core/source';
|
|
|
3
3
|
import type { DocumentClient, OpenOptions } from '../core/worker/client';
|
|
4
4
|
import type { Zoom } from './common/ZoomControl';
|
|
5
5
|
import { type FileMenuItem } from './file/FileMenu';
|
|
6
|
+
import { type Theme } from './common/hooks';
|
|
6
7
|
import type { CollabOptions } from '../collab';
|
|
7
8
|
export interface DocViewerProps {
|
|
8
9
|
/** File, Blob, ArrayBuffer, Uint8Array or URL (HTTP Range requests are used when the server supports them). */
|
|
@@ -25,6 +26,11 @@ export interface DocViewerProps {
|
|
|
25
26
|
worker?: OpenOptions['worker'];
|
|
26
27
|
/** Where to inject the stylesheet (document or a shadow root). */
|
|
27
28
|
styleTarget?: Document | ShadowRoot;
|
|
29
|
+
/**
|
|
30
|
+
* Color scheme of the viewer chrome (bars, menus, dialogs): 'light', 'dark' or 'auto' (follows the OS / browser setting).
|
|
31
|
+
* The document itself keeps its own colors. Default 'light'.
|
|
32
|
+
*/
|
|
33
|
+
theme?: Theme;
|
|
28
34
|
onLoad?: (client: DocumentClient) => void;
|
|
29
35
|
onError?: (error: Error) => void;
|
|
30
36
|
/** Start in edit mode. Default false (view). */
|
|
@@ -57,5 +63,10 @@ export interface DocViewerProps {
|
|
|
57
63
|
* edits it together through the hub at `transport` (see src/collab).
|
|
58
64
|
*/
|
|
59
65
|
collab?: CollabOptions;
|
|
66
|
+
/**
|
|
67
|
+
* Ctrl/⌘+A anywhere on the page selects the document (text fields outside the viewer keep their own).
|
|
68
|
+
* Default true. With false the shortcut works from the viewer only (its content or toolbar).
|
|
69
|
+
*/
|
|
70
|
+
captureSelectAll?: boolean;
|
|
60
71
|
}
|
|
61
72
|
export declare function DocViewer(props: DocViewerProps): import("react").JSX.Element;
|
|
@@ -27,11 +27,17 @@ export interface ViewerApi {
|
|
|
27
27
|
fileOps: {
|
|
28
28
|
current: FileOps | null;
|
|
29
29
|
};
|
|
30
|
+
/** set by the mounted view (see useSelectAll): Ctrl/⌘+A */
|
|
31
|
+
selectAll: {
|
|
32
|
+
current: (() => void) | null;
|
|
33
|
+
};
|
|
30
34
|
}
|
|
31
35
|
export declare const ViewerContext: import("react").Context<ViewerApi>;
|
|
32
36
|
export declare const useViewer: () => ViewerApi;
|
|
33
37
|
/** Publishes the view's file operations (latest closure each render) to the File menu. */
|
|
34
38
|
export declare function useFileOps(ops: FileOps): void;
|
|
39
|
+
/** Publishes the view's select-all: Ctrl/⌘+A from the viewer chrome or, with `captureSelectAll`, from anywhere on the page. */
|
|
40
|
+
export declare function useSelectAll(fn: () => void): void;
|
|
35
41
|
/** Renders the editor bar into the viewer's toolbar row. */
|
|
36
42
|
export declare function EditorBar({ children }: {
|
|
37
43
|
children: ReactNode;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { useLayoutEffect } from 'react';
|
|
2
2
|
import type { DocumentClient } from '../../core/worker/client';
|
|
3
3
|
export declare const useIsoLayoutEffect: typeof useLayoutEffect;
|
|
4
|
+
/** Color scheme of the viewer chrome: 'auto' follows the browser / OS setting (prefers-color-scheme). */
|
|
5
|
+
export type Theme = 'light' | 'dark' | 'auto';
|
|
6
|
+
/** Whether the dark theme applies for `theme`; 'auto' tracks prefers-color-scheme live. */
|
|
7
|
+
export declare function useDarkTheme(theme?: Theme): boolean;
|
|
4
8
|
export declare function useForceUpdate(): [number, () => void];
|
|
5
9
|
/** Element size via ResizeObserver. */
|
|
6
10
|
export declare function useSize<T extends HTMLElement>(): [React.RefObject<T | null>, {
|
|
@@ -18,3 +22,10 @@ export declare function useMediaUrl(client: DocumentClient, path: string | undef
|
|
|
18
22
|
export declare function lowerIndex(arr: ArrayLike<number>, v: number): number;
|
|
19
23
|
export declare function useLatest<T>(v: T): import("react").RefObject<T>;
|
|
20
24
|
export declare function useStableCallback<A extends unknown[], R>(fn: (...a: A) => R): (...a: A) => R;
|
|
25
|
+
/** A control that takes typed text: Ctrl/⌘+A selects its own content. */
|
|
26
|
+
export declare function isTextEntry(target: EventTarget | null): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Focuses `el` so keyboard shortcuts work without a click. The focus stays where it is when a control
|
|
29
|
+
* outside the viewer has it (a host page form); the viewer's own chrome (or the page body) yields.
|
|
30
|
+
*/
|
|
31
|
+
export declare function claimFocus(el: HTMLElement | null): boolean;
|
package/package.json
CHANGED