pptx-react-viewer 1.5.2 → 1.6.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 +4 -0
- package/README.md +27 -3
- package/dist/{PowerPointViewer-BqfQdZFN.d.mts → PowerPointViewer-e7LyTw3o.d.mts} +167 -72
- package/dist/{PowerPointViewer-BqfQdZFN.d.ts → PowerPointViewer-e7LyTw3o.d.ts} +167 -72
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +96 -96
- package/dist/index.js.br +0 -0
- package/dist/index.js.gz +0 -0
- package/dist/index.mjs +95 -95
- package/dist/index.mjs.br +0 -0
- package/dist/index.mjs.gz +0 -0
- package/dist/viewer/index.d.mts +2 -2
- package/dist/viewer/index.d.ts +2 -2
- package/dist/viewer/index.js +96 -96
- package/dist/viewer/index.js.br +0 -0
- package/dist/viewer/index.js.gz +0 -0
- package/dist/viewer/index.mjs +95 -95
- package/dist/viewer/index.mjs.br +0 -0
- package/dist/viewer/index.mjs.gz +0 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,10 @@ All notable changes to this project are documented here.
|
|
|
4
4
|
This file is generated from [Conventional Commits](https://www.conventionalcommits.org)
|
|
5
5
|
by [git-cliff](https://git-cliff.org); do not edit it by hand.
|
|
6
6
|
|
|
7
|
+
## [1.5.3](https://github.com/ChristopherVR/pptx-viewer/releases/tag/pptx-react-viewer@1.5.3) - 2026-07-04
|
|
8
|
+
|
|
9
|
+
## [1.5.2](https://github.com/ChristopherVR/pptx-viewer/releases/tag/pptx-react-viewer@1.5.2) - 2026-07-04
|
|
10
|
+
|
|
7
11
|
## [1.5.1](https://github.com/ChristopherVR/pptx-viewer/releases/tag/pptx-react-viewer@1.5.1) - 2026-07-04
|
|
8
12
|
|
|
9
13
|
## [1.5.0](https://github.com/ChristopherVR/pptx-viewer/releases/tag/pptx-react-viewer@1.5.0) - 2026-07-04
|
package/README.md
CHANGED
|
@@ -101,13 +101,37 @@ const bytes = await viewerRef.current?.getContent(); // Uint8Array of a valid .p
|
|
|
101
101
|
| `onContentChange` | `(dirty: boolean) => void` | n/a | Called when content changes |
|
|
102
102
|
| `onDirtyChange` | `(isDirty: boolean) => void` | n/a | Called when dirty state changes |
|
|
103
103
|
| `onActiveSlideChange` | `(index: number) => void` | n/a | Called when the active slide changes |
|
|
104
|
+
| `onModeChange` | `(mode: ViewerMode) => void` | n/a | Called when the viewer mode changes |
|
|
105
|
+
| `onZoomChange` | `(zoom: number) => void` | n/a | Called when the zoom level changes |
|
|
106
|
+
| `onSelectionChange` | `(ids: string[]) => void` | n/a | Called when element selection changes |
|
|
107
|
+
| `onSlideCountChange` | `(count: number) => void` | n/a | Called when the total slide count changes |
|
|
104
108
|
| `theme` | `ViewerTheme` | n/a | Theme configuration for customising colours, radius, and CSS vars |
|
|
105
109
|
|
|
106
110
|
### `PowerPointViewerHandle` (via `ref`)
|
|
107
111
|
|
|
108
|
-
| Method
|
|
109
|
-
|
|
|
110
|
-
| `getContent`
|
|
112
|
+
| Method | Signature | Description |
|
|
113
|
+
| ----------------------- | ---------------------------- | ---------------------------------------- |
|
|
114
|
+
| `getContent` | `() => Promise<Uint8Array>` | Serialise current state to .pptx bytes |
|
|
115
|
+
| `goTo` | `(index: number) => void` | Navigate to a slide by zero-based index |
|
|
116
|
+
| `goPrev` | `() => void` | Navigate to the previous slide |
|
|
117
|
+
| `goNext` | `() => void` | Navigate to the next slide |
|
|
118
|
+
| `undo` | `() => void` | Undo the last editing action |
|
|
119
|
+
| `redo` | `() => void` | Redo the last undone action |
|
|
120
|
+
| `canUndo` | `() => boolean` | Whether an undo action is available |
|
|
121
|
+
| `canRedo` | `() => boolean` | Whether a redo action is available |
|
|
122
|
+
| `getZoom` | `() => number` | Get the current zoom level (1 = 100%) |
|
|
123
|
+
| `setZoom` | `(level: number) => void` | Set the zoom level |
|
|
124
|
+
| `zoomIn` | `() => void` | Zoom in by one step |
|
|
125
|
+
| `zoomOut` | `() => void` | Zoom out by one step |
|
|
126
|
+
| `zoomReset` | `() => void` | Reset zoom to 100% |
|
|
127
|
+
| `getMode` | `() => ViewerMode` | Get the current viewer mode |
|
|
128
|
+
| `setMode` | `(mode: ViewerMode) => void` | Switch mode programmatically |
|
|
129
|
+
| `getActiveSlideIndex` | `() => number` | Get the zero-based active slide index |
|
|
130
|
+
| `getSlideCount` | `() => number` | Get the total number of slides |
|
|
131
|
+
| `isDirty` | `() => boolean` | Whether the document has unsaved changes |
|
|
132
|
+
| `getSelectedElementIds` | `() => string[]` | Get IDs of selected elements |
|
|
133
|
+
| `selectElements` | `(ids: string[]) => void` | Programmatically select elements by ID |
|
|
134
|
+
| `clearSelection` | `() => void` | Clear the current selection |
|
|
111
135
|
|
|
112
136
|
### `renderToCanvas`
|
|
113
137
|
|
|
@@ -3,6 +3,163 @@ import * as React from 'react';
|
|
|
3
3
|
import React__default from 'react';
|
|
4
4
|
import { ViewerTheme } from './theme/index.js';
|
|
5
5
|
|
|
6
|
+
/** Viewer interaction mode: read-only, edit, presentation, or master-view. */
|
|
7
|
+
type ViewerMode = 'preview' | 'edit' | 'present' | 'master';
|
|
8
|
+
/**
|
|
9
|
+
* Framework-agnostic imperative API contract for the PowerPoint viewer.
|
|
10
|
+
*
|
|
11
|
+
* Each binding (React `forwardRef` handle, Vue `defineExpose`, Angular public
|
|
12
|
+
* methods) implements this interface so consumers get a consistent progressive
|
|
13
|
+
* API regardless of framework.
|
|
14
|
+
*/
|
|
15
|
+
interface PowerPointViewerAPI {
|
|
16
|
+
/** Serialise the current presentation to `.pptx` bytes. */
|
|
17
|
+
getContent: () => Promise<Uint8Array>;
|
|
18
|
+
/** Navigate to a specific slide by zero-based index. */
|
|
19
|
+
goTo: (slideIndex: number) => void;
|
|
20
|
+
/** Navigate to the previous slide. */
|
|
21
|
+
goPrev: () => void;
|
|
22
|
+
/** Navigate to the next slide. */
|
|
23
|
+
goNext: () => void;
|
|
24
|
+
/** Undo the last editing action. No-op when nothing to undo. */
|
|
25
|
+
undo: () => void;
|
|
26
|
+
/** Redo the last undone action. No-op when nothing to redo. */
|
|
27
|
+
redo: () => void;
|
|
28
|
+
/** Whether an undo action is available. */
|
|
29
|
+
canUndo: () => boolean;
|
|
30
|
+
/** Whether a redo action is available. */
|
|
31
|
+
canRedo: () => boolean;
|
|
32
|
+
/** Get the current zoom level (1 = 100%). */
|
|
33
|
+
getZoom: () => number;
|
|
34
|
+
/** Set the zoom level (clamped to min/max bounds). */
|
|
35
|
+
setZoom: (level: number) => void;
|
|
36
|
+
/** Zoom in by one step. */
|
|
37
|
+
zoomIn: () => void;
|
|
38
|
+
/** Zoom out by one step. */
|
|
39
|
+
zoomOut: () => void;
|
|
40
|
+
/** Reset zoom to 100%. */
|
|
41
|
+
zoomReset: () => void;
|
|
42
|
+
/** Get the current viewer mode. */
|
|
43
|
+
getMode: () => ViewerMode;
|
|
44
|
+
/** Switch the viewer mode (e.g. 'edit', 'preview', 'present'). */
|
|
45
|
+
setMode: (mode: ViewerMode) => void;
|
|
46
|
+
/** Get the zero-based active slide index. */
|
|
47
|
+
getActiveSlideIndex: () => number;
|
|
48
|
+
/** Set the active slide by zero-based index (alias of goTo). */
|
|
49
|
+
setActiveSlideIndex: (index: number) => void;
|
|
50
|
+
/** Get the total number of slides. */
|
|
51
|
+
getSlideCount: () => number;
|
|
52
|
+
/** Whether the document has unsaved changes. */
|
|
53
|
+
isDirty: () => boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Get the full slide array. Returns the actual `PptxSlide[]` from the
|
|
56
|
+
* internal model with full type information (elements, notes, transitions,
|
|
57
|
+
* animations, etc.). The returned reference is a snapshot; mutations are
|
|
58
|
+
* not reflected back unless done via the manipulation methods.
|
|
59
|
+
*/
|
|
60
|
+
getSlides: () => readonly l[];
|
|
61
|
+
/** Get a single slide by zero-based index, or undefined if out of range. */
|
|
62
|
+
getSlide: (index: number) => l | undefined;
|
|
63
|
+
/** Get the currently active slide. */
|
|
64
|
+
getActiveSlide: () => l | undefined;
|
|
65
|
+
/** Add a blank slide after the given index (or at end if omitted). */
|
|
66
|
+
addSlide: (afterIndex?: number) => void;
|
|
67
|
+
/** Delete slides at the given zero-based indexes. At least one slide is kept. */
|
|
68
|
+
deleteSlides: (indexes: number[]) => void;
|
|
69
|
+
/** Duplicate slides at the given zero-based indexes. */
|
|
70
|
+
duplicateSlides: (indexes: number[]) => void;
|
|
71
|
+
/** Move a slide from one position to another. */
|
|
72
|
+
moveSlide: (fromIndex: number, toIndex: number) => void;
|
|
73
|
+
/** Toggle the hidden flag on slides at the given indexes. */
|
|
74
|
+
toggleHideSlides: (indexes: number[]) => void;
|
|
75
|
+
/**
|
|
76
|
+
* Get the elements on a slide. Defaults to the active slide when
|
|
77
|
+
* `slideIndex` is omitted. Returns the full `PptxElement[]` with
|
|
78
|
+
* all type-specific properties intact.
|
|
79
|
+
*/
|
|
80
|
+
getElements: (slideIndex?: number) => readonly P[];
|
|
81
|
+
/** Get a single element by ID from the active slide (or a specified slide). */
|
|
82
|
+
getElementById: (elementId: string, slideIndex?: number) => P | undefined;
|
|
83
|
+
/**
|
|
84
|
+
* Update one or more properties of an element by ID on the active slide.
|
|
85
|
+
* Accepts a `Partial<PptxElement>` patch (e.g. `{ x: 100, width: 300 }`).
|
|
86
|
+
*/
|
|
87
|
+
updateElement: (elementId: string, updates: Partial<P>) => void;
|
|
88
|
+
/** Delete elements by their IDs from the active slide. */
|
|
89
|
+
deleteElements: (elementIds: string[]) => void;
|
|
90
|
+
/**
|
|
91
|
+
* Duplicate an element on the active slide.
|
|
92
|
+
* Returns the new element's ID, or undefined if the source was not found.
|
|
93
|
+
*/
|
|
94
|
+
duplicateElement: (elementId: string) => string | undefined;
|
|
95
|
+
/** Get the IDs of currently selected elements. */
|
|
96
|
+
getSelectedElementIds: () => string[];
|
|
97
|
+
/** Programmatically select elements by their IDs. */
|
|
98
|
+
selectElements: (ids: string[]) => void;
|
|
99
|
+
/** Clear the current selection. */
|
|
100
|
+
clearSelection: () => void;
|
|
101
|
+
}
|
|
102
|
+
/** Collaboration role within a session. */
|
|
103
|
+
type CollaborationRole = 'owner' | 'collaborator' | 'viewer';
|
|
104
|
+
/**
|
|
105
|
+
* Collaboration transport.
|
|
106
|
+
*
|
|
107
|
+
* - `'websocket'` (default): y-websocket against `serverUrl`.
|
|
108
|
+
* - `'webrtc'`: y-webrtc peer-to-peer; needs no document server. Peers meet
|
|
109
|
+
* through the `signaling` servers (WebRTC signaling only, no document data)
|
|
110
|
+
* and same-browser tabs additionally sync via BroadcastChannel even without
|
|
111
|
+
* any signaling server, which makes this mode usable from static hosting.
|
|
112
|
+
*/
|
|
113
|
+
type CollaborationTransport = 'websocket' | 'webrtc';
|
|
114
|
+
/**
|
|
115
|
+
* Real-time collaboration configuration.
|
|
116
|
+
*
|
|
117
|
+
* The same shape is accepted by the React, Vue, and Angular bindings.
|
|
118
|
+
*/
|
|
119
|
+
interface CollaborationConfig {
|
|
120
|
+
/** Unique identifier for the collaboration room (alphanumeric, hyphens, underscores). */
|
|
121
|
+
roomId: string;
|
|
122
|
+
/**
|
|
123
|
+
* WebSocket server URL for the Yjs provider (e.g. "wss://collab.example.com").
|
|
124
|
+
* Ignored (may be empty) when `transport` is `'webrtc'`.
|
|
125
|
+
*/
|
|
126
|
+
serverUrl: string;
|
|
127
|
+
/** Transport to use. Defaults to `'websocket'`. */
|
|
128
|
+
transport?: CollaborationTransport;
|
|
129
|
+
/**
|
|
130
|
+
* WebRTC signaling server URLs (only used when `transport` is `'webrtc'`).
|
|
131
|
+
* Defaults to y-webrtc's built-in public signaling list. Same-browser tabs
|
|
132
|
+
* sync via BroadcastChannel regardless of signaling availability.
|
|
133
|
+
*/
|
|
134
|
+
signaling?: string[];
|
|
135
|
+
/** Display name for the local user. */
|
|
136
|
+
userName: string;
|
|
137
|
+
/** Avatar URL for the local user (optional). */
|
|
138
|
+
userAvatar?: string;
|
|
139
|
+
/** Hex colour for the local user's cursor/presence indicator. */
|
|
140
|
+
userColor?: string;
|
|
141
|
+
/** Optional authentication token sent with the WebSocket handshake. */
|
|
142
|
+
authToken?: string;
|
|
143
|
+
/** Role in the session; defaults to `'collaborator'`. */
|
|
144
|
+
role?: CollaborationRole;
|
|
145
|
+
/**
|
|
146
|
+
* Elected-writer write-back callback (Area 3 of the C3 hardening plan).
|
|
147
|
+
*
|
|
148
|
+
* When the local user has `role: 'owner'`, the binding debounces changes and
|
|
149
|
+
* serializes the current Y.Doc state to a PPTX byte array, then calls this
|
|
150
|
+
* callback so the host can persist the snapshot. Only one writer (the owner)
|
|
151
|
+
* does this; other collaborators never trigger write-back, eliminating the
|
|
152
|
+
* last-save-wins problem.
|
|
153
|
+
*/
|
|
154
|
+
onWriteBack?: (bytes: Uint8Array) => void;
|
|
155
|
+
/**
|
|
156
|
+
* Debounce delay (ms) between the last Y.Doc change and the write-back
|
|
157
|
+
* invocation. Defaults to 5000 ms. Set to 0 to write back on every change
|
|
158
|
+
* (not recommended for large documents).
|
|
159
|
+
*/
|
|
160
|
+
writeBackDebounceMs?: number;
|
|
161
|
+
}
|
|
162
|
+
|
|
6
163
|
/**
|
|
7
164
|
* Core data-model types for the PowerPoint viewer/editor plugin.
|
|
8
165
|
*
|
|
@@ -12,15 +169,6 @@ import { ViewerTheme } from './theme/index.js';
|
|
|
12
169
|
* clipboard operations, undo/redo history, geometry, and shape quick styles.
|
|
13
170
|
*/
|
|
14
171
|
|
|
15
|
-
/**
|
|
16
|
-
* The current operating mode of the PowerPoint viewer.
|
|
17
|
-
*
|
|
18
|
-
* - `"preview"` -- Read-only viewing with no editing controls.
|
|
19
|
-
* - `"edit"` -- Full editing mode with toolbar, inspector, and canvas interaction.
|
|
20
|
-
* - `"present"` -- Fullscreen presentation/slideshow mode with animations.
|
|
21
|
-
* - `"master"` -- Slide master editing mode for template/layout manipulation.
|
|
22
|
-
*/
|
|
23
|
-
type ViewerMode = 'preview' | 'edit' | 'present' | 'master';
|
|
24
172
|
/**
|
|
25
173
|
* Union of all shape preset types that the viewer can insert or render.
|
|
26
174
|
* Maps to OOXML `a:prstGeom` preset values (e.g. "rect", "ellipse").
|
|
@@ -174,67 +322,6 @@ interface ShapeQuickStyle {
|
|
|
174
322
|
style: Partial<$>;
|
|
175
323
|
}
|
|
176
324
|
|
|
177
|
-
/** Collaboration role within a session. */
|
|
178
|
-
type CollaborationRole = 'owner' | 'collaborator' | 'viewer';
|
|
179
|
-
/**
|
|
180
|
-
* Collaboration transport.
|
|
181
|
-
*
|
|
182
|
-
* - `'websocket'` (default): y-websocket against `serverUrl`.
|
|
183
|
-
* - `'webrtc'`: y-webrtc peer-to-peer; needs no document server. Peers meet
|
|
184
|
-
* through the `signaling` servers (WebRTC signaling only, no document data)
|
|
185
|
-
* and same-browser tabs additionally sync via BroadcastChannel even without
|
|
186
|
-
* any signaling server, which makes this mode usable from static hosting.
|
|
187
|
-
*/
|
|
188
|
-
type CollaborationTransport = 'websocket' | 'webrtc';
|
|
189
|
-
/**
|
|
190
|
-
* Real-time collaboration configuration.
|
|
191
|
-
*
|
|
192
|
-
* The same shape is accepted by the React, Vue, and Angular bindings.
|
|
193
|
-
*/
|
|
194
|
-
interface CollaborationConfig {
|
|
195
|
-
/** Unique identifier for the collaboration room (alphanumeric, hyphens, underscores). */
|
|
196
|
-
roomId: string;
|
|
197
|
-
/**
|
|
198
|
-
* WebSocket server URL for the Yjs provider (e.g. "wss://collab.example.com").
|
|
199
|
-
* Ignored (may be empty) when `transport` is `'webrtc'`.
|
|
200
|
-
*/
|
|
201
|
-
serverUrl: string;
|
|
202
|
-
/** Transport to use. Defaults to `'websocket'`. */
|
|
203
|
-
transport?: CollaborationTransport;
|
|
204
|
-
/**
|
|
205
|
-
* WebRTC signaling server URLs (only used when `transport` is `'webrtc'`).
|
|
206
|
-
* Defaults to y-webrtc's built-in public signaling list. Same-browser tabs
|
|
207
|
-
* sync via BroadcastChannel regardless of signaling availability.
|
|
208
|
-
*/
|
|
209
|
-
signaling?: string[];
|
|
210
|
-
/** Display name for the local user. */
|
|
211
|
-
userName: string;
|
|
212
|
-
/** Avatar URL for the local user (optional). */
|
|
213
|
-
userAvatar?: string;
|
|
214
|
-
/** Hex colour for the local user's cursor/presence indicator. */
|
|
215
|
-
userColor?: string;
|
|
216
|
-
/** Optional authentication token sent with the WebSocket handshake. */
|
|
217
|
-
authToken?: string;
|
|
218
|
-
/** Role in the session; defaults to `'collaborator'`. */
|
|
219
|
-
role?: CollaborationRole;
|
|
220
|
-
/**
|
|
221
|
-
* Elected-writer write-back callback (Area 3 of the C3 hardening plan).
|
|
222
|
-
*
|
|
223
|
-
* When the local user has `role: 'owner'`, the binding debounces changes and
|
|
224
|
-
* serializes the current Y.Doc state to a PPTX byte array, then calls this
|
|
225
|
-
* callback so the host can persist the snapshot. Only one writer (the owner)
|
|
226
|
-
* does this; other collaborators never trigger write-back, eliminating the
|
|
227
|
-
* last-save-wins problem.
|
|
228
|
-
*/
|
|
229
|
-
onWriteBack?: (bytes: Uint8Array) => void;
|
|
230
|
-
/**
|
|
231
|
-
* Debounce delay (ms) between the last Y.Doc change and the write-back
|
|
232
|
-
* invocation. Defaults to 5000 ms. Set to 0 to write back on every change
|
|
233
|
-
* (not recommended for large documents).
|
|
234
|
-
*/
|
|
235
|
-
writeBackDebounceMs?: number;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
325
|
/**
|
|
239
326
|
* Base handle interface for file viewer components.
|
|
240
327
|
* Defined locally to avoid dependency on external file-viewer plugin packages.
|
|
@@ -377,6 +464,14 @@ interface PowerPointViewerProps {
|
|
|
377
464
|
onContentChange?: (content: Uint8Array) => void;
|
|
378
465
|
/** Callback when active slide changes */
|
|
379
466
|
onActiveSlideChange?: (slideIndex: number) => void;
|
|
467
|
+
/** Callback when the viewer mode changes (e.g. edit to present). */
|
|
468
|
+
onModeChange?: (mode: ViewerMode) => void;
|
|
469
|
+
/** Callback when the zoom level changes. */
|
|
470
|
+
onZoomChange?: (zoom: number) => void;
|
|
471
|
+
/** Callback when element selection changes. */
|
|
472
|
+
onSelectionChange?: (elementIds: string[]) => void;
|
|
473
|
+
/** Callback when the total slide count changes (slide added/deleted). */
|
|
474
|
+
onSlideCountChange?: (count: number) => void;
|
|
380
475
|
/**
|
|
381
476
|
* Host override for the File ▸ Open action. When provided, the built-in
|
|
382
477
|
* native file picker is bypassed and this is invoked instead; the host is
|
|
@@ -476,7 +571,7 @@ interface PowerPointViewerProps {
|
|
|
476
571
|
*/
|
|
477
572
|
smartArt3D?: boolean;
|
|
478
573
|
}
|
|
479
|
-
interface PowerPointViewerHandle extends FileViewerHandle {
|
|
574
|
+
interface PowerPointViewerHandle extends FileViewerHandle, PowerPointViewerAPI {
|
|
480
575
|
getContent: () => Promise<Uint8Array>;
|
|
481
576
|
}
|
|
482
577
|
|
|
@@ -500,4 +595,4 @@ declare function getAnimationInitialStyle(preset: f | undefined, nativeAnimation
|
|
|
500
595
|
*/
|
|
501
596
|
declare const PowerPointViewer: React.ForwardRefExoticComponent<PowerPointViewerProps & React.RefAttributes<PowerPointViewerHandle>>;
|
|
502
597
|
|
|
503
|
-
export { type AccessibilityIssue as A, type
|
|
598
|
+
export { type AccessibilityIssue as A, type SlideTransitionOption as B, type CollaborationRole as C, type DragState as D, type EditorHistorySnapshot as E, type FileViewerHandle as F, type StrokeDashOption as G, type SupportedShapeType as H, type ToolbarSection as I, type MarqueeSelectionState as M, PowerPointViewer as P, type ResizeHandle as R, type ShapeAdjustmentDragState as S, type TableCellEditorState as T, type ViewerMode as V, type PowerPointViewerAPI as a, type PowerPointViewerHandle as b, type PowerPointViewerProps as c, type CollaborationConfig as d, type AnimationPresetOption as e, type CanvasSize as f, getAnimationInitialStyle as g, type ConnectorArrowOption as h, type ConnectorGeometryOption as i, type ConnectorGeometryType as j, type ConnectorPathGeometry as k, type DrawingTool as l, type ElementBounds as m, type ElementClipboardPayload as n, type ElementContextMenuAction as o, type ElementContextMenuState as p, type ParsedTableCell as q, type ParsedTableData as r, type PresentationAnimationRuntime as s, type ResizeState as t, type ShapeAdjustmentHandleDescriptor as u, type ShapePreset as v, type ShapeQuickStyle as w, type ShortcutReferenceItem as x, type SlideAlignment as y, type SlideSectionGroup as z };
|
|
@@ -3,6 +3,163 @@ import * as React from 'react';
|
|
|
3
3
|
import React__default from 'react';
|
|
4
4
|
import { ViewerTheme } from './theme/index.js';
|
|
5
5
|
|
|
6
|
+
/** Viewer interaction mode: read-only, edit, presentation, or master-view. */
|
|
7
|
+
type ViewerMode = 'preview' | 'edit' | 'present' | 'master';
|
|
8
|
+
/**
|
|
9
|
+
* Framework-agnostic imperative API contract for the PowerPoint viewer.
|
|
10
|
+
*
|
|
11
|
+
* Each binding (React `forwardRef` handle, Vue `defineExpose`, Angular public
|
|
12
|
+
* methods) implements this interface so consumers get a consistent progressive
|
|
13
|
+
* API regardless of framework.
|
|
14
|
+
*/
|
|
15
|
+
interface PowerPointViewerAPI {
|
|
16
|
+
/** Serialise the current presentation to `.pptx` bytes. */
|
|
17
|
+
getContent: () => Promise<Uint8Array>;
|
|
18
|
+
/** Navigate to a specific slide by zero-based index. */
|
|
19
|
+
goTo: (slideIndex: number) => void;
|
|
20
|
+
/** Navigate to the previous slide. */
|
|
21
|
+
goPrev: () => void;
|
|
22
|
+
/** Navigate to the next slide. */
|
|
23
|
+
goNext: () => void;
|
|
24
|
+
/** Undo the last editing action. No-op when nothing to undo. */
|
|
25
|
+
undo: () => void;
|
|
26
|
+
/** Redo the last undone action. No-op when nothing to redo. */
|
|
27
|
+
redo: () => void;
|
|
28
|
+
/** Whether an undo action is available. */
|
|
29
|
+
canUndo: () => boolean;
|
|
30
|
+
/** Whether a redo action is available. */
|
|
31
|
+
canRedo: () => boolean;
|
|
32
|
+
/** Get the current zoom level (1 = 100%). */
|
|
33
|
+
getZoom: () => number;
|
|
34
|
+
/** Set the zoom level (clamped to min/max bounds). */
|
|
35
|
+
setZoom: (level: number) => void;
|
|
36
|
+
/** Zoom in by one step. */
|
|
37
|
+
zoomIn: () => void;
|
|
38
|
+
/** Zoom out by one step. */
|
|
39
|
+
zoomOut: () => void;
|
|
40
|
+
/** Reset zoom to 100%. */
|
|
41
|
+
zoomReset: () => void;
|
|
42
|
+
/** Get the current viewer mode. */
|
|
43
|
+
getMode: () => ViewerMode;
|
|
44
|
+
/** Switch the viewer mode (e.g. 'edit', 'preview', 'present'). */
|
|
45
|
+
setMode: (mode: ViewerMode) => void;
|
|
46
|
+
/** Get the zero-based active slide index. */
|
|
47
|
+
getActiveSlideIndex: () => number;
|
|
48
|
+
/** Set the active slide by zero-based index (alias of goTo). */
|
|
49
|
+
setActiveSlideIndex: (index: number) => void;
|
|
50
|
+
/** Get the total number of slides. */
|
|
51
|
+
getSlideCount: () => number;
|
|
52
|
+
/** Whether the document has unsaved changes. */
|
|
53
|
+
isDirty: () => boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Get the full slide array. Returns the actual `PptxSlide[]` from the
|
|
56
|
+
* internal model with full type information (elements, notes, transitions,
|
|
57
|
+
* animations, etc.). The returned reference is a snapshot; mutations are
|
|
58
|
+
* not reflected back unless done via the manipulation methods.
|
|
59
|
+
*/
|
|
60
|
+
getSlides: () => readonly l[];
|
|
61
|
+
/** Get a single slide by zero-based index, or undefined if out of range. */
|
|
62
|
+
getSlide: (index: number) => l | undefined;
|
|
63
|
+
/** Get the currently active slide. */
|
|
64
|
+
getActiveSlide: () => l | undefined;
|
|
65
|
+
/** Add a blank slide after the given index (or at end if omitted). */
|
|
66
|
+
addSlide: (afterIndex?: number) => void;
|
|
67
|
+
/** Delete slides at the given zero-based indexes. At least one slide is kept. */
|
|
68
|
+
deleteSlides: (indexes: number[]) => void;
|
|
69
|
+
/** Duplicate slides at the given zero-based indexes. */
|
|
70
|
+
duplicateSlides: (indexes: number[]) => void;
|
|
71
|
+
/** Move a slide from one position to another. */
|
|
72
|
+
moveSlide: (fromIndex: number, toIndex: number) => void;
|
|
73
|
+
/** Toggle the hidden flag on slides at the given indexes. */
|
|
74
|
+
toggleHideSlides: (indexes: number[]) => void;
|
|
75
|
+
/**
|
|
76
|
+
* Get the elements on a slide. Defaults to the active slide when
|
|
77
|
+
* `slideIndex` is omitted. Returns the full `PptxElement[]` with
|
|
78
|
+
* all type-specific properties intact.
|
|
79
|
+
*/
|
|
80
|
+
getElements: (slideIndex?: number) => readonly P[];
|
|
81
|
+
/** Get a single element by ID from the active slide (or a specified slide). */
|
|
82
|
+
getElementById: (elementId: string, slideIndex?: number) => P | undefined;
|
|
83
|
+
/**
|
|
84
|
+
* Update one or more properties of an element by ID on the active slide.
|
|
85
|
+
* Accepts a `Partial<PptxElement>` patch (e.g. `{ x: 100, width: 300 }`).
|
|
86
|
+
*/
|
|
87
|
+
updateElement: (elementId: string, updates: Partial<P>) => void;
|
|
88
|
+
/** Delete elements by their IDs from the active slide. */
|
|
89
|
+
deleteElements: (elementIds: string[]) => void;
|
|
90
|
+
/**
|
|
91
|
+
* Duplicate an element on the active slide.
|
|
92
|
+
* Returns the new element's ID, or undefined if the source was not found.
|
|
93
|
+
*/
|
|
94
|
+
duplicateElement: (elementId: string) => string | undefined;
|
|
95
|
+
/** Get the IDs of currently selected elements. */
|
|
96
|
+
getSelectedElementIds: () => string[];
|
|
97
|
+
/** Programmatically select elements by their IDs. */
|
|
98
|
+
selectElements: (ids: string[]) => void;
|
|
99
|
+
/** Clear the current selection. */
|
|
100
|
+
clearSelection: () => void;
|
|
101
|
+
}
|
|
102
|
+
/** Collaboration role within a session. */
|
|
103
|
+
type CollaborationRole = 'owner' | 'collaborator' | 'viewer';
|
|
104
|
+
/**
|
|
105
|
+
* Collaboration transport.
|
|
106
|
+
*
|
|
107
|
+
* - `'websocket'` (default): y-websocket against `serverUrl`.
|
|
108
|
+
* - `'webrtc'`: y-webrtc peer-to-peer; needs no document server. Peers meet
|
|
109
|
+
* through the `signaling` servers (WebRTC signaling only, no document data)
|
|
110
|
+
* and same-browser tabs additionally sync via BroadcastChannel even without
|
|
111
|
+
* any signaling server, which makes this mode usable from static hosting.
|
|
112
|
+
*/
|
|
113
|
+
type CollaborationTransport = 'websocket' | 'webrtc';
|
|
114
|
+
/**
|
|
115
|
+
* Real-time collaboration configuration.
|
|
116
|
+
*
|
|
117
|
+
* The same shape is accepted by the React, Vue, and Angular bindings.
|
|
118
|
+
*/
|
|
119
|
+
interface CollaborationConfig {
|
|
120
|
+
/** Unique identifier for the collaboration room (alphanumeric, hyphens, underscores). */
|
|
121
|
+
roomId: string;
|
|
122
|
+
/**
|
|
123
|
+
* WebSocket server URL for the Yjs provider (e.g. "wss://collab.example.com").
|
|
124
|
+
* Ignored (may be empty) when `transport` is `'webrtc'`.
|
|
125
|
+
*/
|
|
126
|
+
serverUrl: string;
|
|
127
|
+
/** Transport to use. Defaults to `'websocket'`. */
|
|
128
|
+
transport?: CollaborationTransport;
|
|
129
|
+
/**
|
|
130
|
+
* WebRTC signaling server URLs (only used when `transport` is `'webrtc'`).
|
|
131
|
+
* Defaults to y-webrtc's built-in public signaling list. Same-browser tabs
|
|
132
|
+
* sync via BroadcastChannel regardless of signaling availability.
|
|
133
|
+
*/
|
|
134
|
+
signaling?: string[];
|
|
135
|
+
/** Display name for the local user. */
|
|
136
|
+
userName: string;
|
|
137
|
+
/** Avatar URL for the local user (optional). */
|
|
138
|
+
userAvatar?: string;
|
|
139
|
+
/** Hex colour for the local user's cursor/presence indicator. */
|
|
140
|
+
userColor?: string;
|
|
141
|
+
/** Optional authentication token sent with the WebSocket handshake. */
|
|
142
|
+
authToken?: string;
|
|
143
|
+
/** Role in the session; defaults to `'collaborator'`. */
|
|
144
|
+
role?: CollaborationRole;
|
|
145
|
+
/**
|
|
146
|
+
* Elected-writer write-back callback (Area 3 of the C3 hardening plan).
|
|
147
|
+
*
|
|
148
|
+
* When the local user has `role: 'owner'`, the binding debounces changes and
|
|
149
|
+
* serializes the current Y.Doc state to a PPTX byte array, then calls this
|
|
150
|
+
* callback so the host can persist the snapshot. Only one writer (the owner)
|
|
151
|
+
* does this; other collaborators never trigger write-back, eliminating the
|
|
152
|
+
* last-save-wins problem.
|
|
153
|
+
*/
|
|
154
|
+
onWriteBack?: (bytes: Uint8Array) => void;
|
|
155
|
+
/**
|
|
156
|
+
* Debounce delay (ms) between the last Y.Doc change and the write-back
|
|
157
|
+
* invocation. Defaults to 5000 ms. Set to 0 to write back on every change
|
|
158
|
+
* (not recommended for large documents).
|
|
159
|
+
*/
|
|
160
|
+
writeBackDebounceMs?: number;
|
|
161
|
+
}
|
|
162
|
+
|
|
6
163
|
/**
|
|
7
164
|
* Core data-model types for the PowerPoint viewer/editor plugin.
|
|
8
165
|
*
|
|
@@ -12,15 +169,6 @@ import { ViewerTheme } from './theme/index.js';
|
|
|
12
169
|
* clipboard operations, undo/redo history, geometry, and shape quick styles.
|
|
13
170
|
*/
|
|
14
171
|
|
|
15
|
-
/**
|
|
16
|
-
* The current operating mode of the PowerPoint viewer.
|
|
17
|
-
*
|
|
18
|
-
* - `"preview"` -- Read-only viewing with no editing controls.
|
|
19
|
-
* - `"edit"` -- Full editing mode with toolbar, inspector, and canvas interaction.
|
|
20
|
-
* - `"present"` -- Fullscreen presentation/slideshow mode with animations.
|
|
21
|
-
* - `"master"` -- Slide master editing mode for template/layout manipulation.
|
|
22
|
-
*/
|
|
23
|
-
type ViewerMode = 'preview' | 'edit' | 'present' | 'master';
|
|
24
172
|
/**
|
|
25
173
|
* Union of all shape preset types that the viewer can insert or render.
|
|
26
174
|
* Maps to OOXML `a:prstGeom` preset values (e.g. "rect", "ellipse").
|
|
@@ -174,67 +322,6 @@ interface ShapeQuickStyle {
|
|
|
174
322
|
style: Partial<$>;
|
|
175
323
|
}
|
|
176
324
|
|
|
177
|
-
/** Collaboration role within a session. */
|
|
178
|
-
type CollaborationRole = 'owner' | 'collaborator' | 'viewer';
|
|
179
|
-
/**
|
|
180
|
-
* Collaboration transport.
|
|
181
|
-
*
|
|
182
|
-
* - `'websocket'` (default): y-websocket against `serverUrl`.
|
|
183
|
-
* - `'webrtc'`: y-webrtc peer-to-peer; needs no document server. Peers meet
|
|
184
|
-
* through the `signaling` servers (WebRTC signaling only, no document data)
|
|
185
|
-
* and same-browser tabs additionally sync via BroadcastChannel even without
|
|
186
|
-
* any signaling server, which makes this mode usable from static hosting.
|
|
187
|
-
*/
|
|
188
|
-
type CollaborationTransport = 'websocket' | 'webrtc';
|
|
189
|
-
/**
|
|
190
|
-
* Real-time collaboration configuration.
|
|
191
|
-
*
|
|
192
|
-
* The same shape is accepted by the React, Vue, and Angular bindings.
|
|
193
|
-
*/
|
|
194
|
-
interface CollaborationConfig {
|
|
195
|
-
/** Unique identifier for the collaboration room (alphanumeric, hyphens, underscores). */
|
|
196
|
-
roomId: string;
|
|
197
|
-
/**
|
|
198
|
-
* WebSocket server URL for the Yjs provider (e.g. "wss://collab.example.com").
|
|
199
|
-
* Ignored (may be empty) when `transport` is `'webrtc'`.
|
|
200
|
-
*/
|
|
201
|
-
serverUrl: string;
|
|
202
|
-
/** Transport to use. Defaults to `'websocket'`. */
|
|
203
|
-
transport?: CollaborationTransport;
|
|
204
|
-
/**
|
|
205
|
-
* WebRTC signaling server URLs (only used when `transport` is `'webrtc'`).
|
|
206
|
-
* Defaults to y-webrtc's built-in public signaling list. Same-browser tabs
|
|
207
|
-
* sync via BroadcastChannel regardless of signaling availability.
|
|
208
|
-
*/
|
|
209
|
-
signaling?: string[];
|
|
210
|
-
/** Display name for the local user. */
|
|
211
|
-
userName: string;
|
|
212
|
-
/** Avatar URL for the local user (optional). */
|
|
213
|
-
userAvatar?: string;
|
|
214
|
-
/** Hex colour for the local user's cursor/presence indicator. */
|
|
215
|
-
userColor?: string;
|
|
216
|
-
/** Optional authentication token sent with the WebSocket handshake. */
|
|
217
|
-
authToken?: string;
|
|
218
|
-
/** Role in the session; defaults to `'collaborator'`. */
|
|
219
|
-
role?: CollaborationRole;
|
|
220
|
-
/**
|
|
221
|
-
* Elected-writer write-back callback (Area 3 of the C3 hardening plan).
|
|
222
|
-
*
|
|
223
|
-
* When the local user has `role: 'owner'`, the binding debounces changes and
|
|
224
|
-
* serializes the current Y.Doc state to a PPTX byte array, then calls this
|
|
225
|
-
* callback so the host can persist the snapshot. Only one writer (the owner)
|
|
226
|
-
* does this; other collaborators never trigger write-back, eliminating the
|
|
227
|
-
* last-save-wins problem.
|
|
228
|
-
*/
|
|
229
|
-
onWriteBack?: (bytes: Uint8Array) => void;
|
|
230
|
-
/**
|
|
231
|
-
* Debounce delay (ms) between the last Y.Doc change and the write-back
|
|
232
|
-
* invocation. Defaults to 5000 ms. Set to 0 to write back on every change
|
|
233
|
-
* (not recommended for large documents).
|
|
234
|
-
*/
|
|
235
|
-
writeBackDebounceMs?: number;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
325
|
/**
|
|
239
326
|
* Base handle interface for file viewer components.
|
|
240
327
|
* Defined locally to avoid dependency on external file-viewer plugin packages.
|
|
@@ -377,6 +464,14 @@ interface PowerPointViewerProps {
|
|
|
377
464
|
onContentChange?: (content: Uint8Array) => void;
|
|
378
465
|
/** Callback when active slide changes */
|
|
379
466
|
onActiveSlideChange?: (slideIndex: number) => void;
|
|
467
|
+
/** Callback when the viewer mode changes (e.g. edit to present). */
|
|
468
|
+
onModeChange?: (mode: ViewerMode) => void;
|
|
469
|
+
/** Callback when the zoom level changes. */
|
|
470
|
+
onZoomChange?: (zoom: number) => void;
|
|
471
|
+
/** Callback when element selection changes. */
|
|
472
|
+
onSelectionChange?: (elementIds: string[]) => void;
|
|
473
|
+
/** Callback when the total slide count changes (slide added/deleted). */
|
|
474
|
+
onSlideCountChange?: (count: number) => void;
|
|
380
475
|
/**
|
|
381
476
|
* Host override for the File ▸ Open action. When provided, the built-in
|
|
382
477
|
* native file picker is bypassed and this is invoked instead; the host is
|
|
@@ -476,7 +571,7 @@ interface PowerPointViewerProps {
|
|
|
476
571
|
*/
|
|
477
572
|
smartArt3D?: boolean;
|
|
478
573
|
}
|
|
479
|
-
interface PowerPointViewerHandle extends FileViewerHandle {
|
|
574
|
+
interface PowerPointViewerHandle extends FileViewerHandle, PowerPointViewerAPI {
|
|
480
575
|
getContent: () => Promise<Uint8Array>;
|
|
481
576
|
}
|
|
482
577
|
|
|
@@ -500,4 +595,4 @@ declare function getAnimationInitialStyle(preset: f | undefined, nativeAnimation
|
|
|
500
595
|
*/
|
|
501
596
|
declare const PowerPointViewer: React.ForwardRefExoticComponent<PowerPointViewerProps & React.RefAttributes<PowerPointViewerHandle>>;
|
|
502
597
|
|
|
503
|
-
export { type AccessibilityIssue as A, type
|
|
598
|
+
export { type AccessibilityIssue as A, type SlideTransitionOption as B, type CollaborationRole as C, type DragState as D, type EditorHistorySnapshot as E, type FileViewerHandle as F, type StrokeDashOption as G, type SupportedShapeType as H, type ToolbarSection as I, type MarqueeSelectionState as M, PowerPointViewer as P, type ResizeHandle as R, type ShapeAdjustmentDragState as S, type TableCellEditorState as T, type ViewerMode as V, type PowerPointViewerAPI as a, type PowerPointViewerHandle as b, type PowerPointViewerProps as c, type CollaborationConfig as d, type AnimationPresetOption as e, type CanvasSize as f, getAnimationInitialStyle as g, type ConnectorArrowOption as h, type ConnectorGeometryOption as i, type ConnectorGeometryType as j, type ConnectorPathGeometry as k, type DrawingTool as l, type ElementBounds as m, type ElementClipboardPayload as n, type ElementContextMenuAction as o, type ElementContextMenuState as p, type ParsedTableCell as q, type ParsedTableData as r, type PresentationAnimationRuntime as s, type ResizeState as t, type ShapeAdjustmentHandleDescriptor as u, type ShapePreset as v, type ShapeQuickStyle as w, type ShortcutReferenceItem as x, type SlideAlignment as y, type SlideSectionGroup as z };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { P as PowerPointViewer, a as
|
|
1
|
+
export { P as PowerPointViewer, a as PowerPointViewerAPI, b as PowerPointViewerHandle, c as PowerPointViewerProps, V as ViewerMode, g as getAnimationInitialStyle } from './PowerPointViewer-e7LyTw3o.mjs';
|
|
2
2
|
import { Options } from 'html2canvas-pro';
|
|
3
|
+
import * as React$1 from 'react';
|
|
3
4
|
import { ViewerTheme } from './theme/index.js';
|
|
4
5
|
export { ViewerTheme, ViewerThemeColors, defaultCssVars, defaultRadius, defaultThemeColors, themeToCssVars } from './theme/index.js';
|
|
5
|
-
import * as React$1 from 'react';
|
|
6
6
|
import './presentation-BRAUjTRt.js';
|
|
7
7
|
|
|
8
8
|
interface ViewerThemeProviderProps {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { P as PowerPointViewer, a as
|
|
1
|
+
export { P as PowerPointViewer, a as PowerPointViewerAPI, b as PowerPointViewerHandle, c as PowerPointViewerProps, V as ViewerMode, g as getAnimationInitialStyle } from './PowerPointViewer-e7LyTw3o.js';
|
|
2
2
|
import { Options } from 'html2canvas-pro';
|
|
3
|
+
import * as React$1 from 'react';
|
|
3
4
|
import { ViewerTheme } from './theme/index.js';
|
|
4
5
|
export { ViewerTheme, ViewerThemeColors, defaultCssVars, defaultRadius, defaultThemeColors, themeToCssVars } from './theme/index.js';
|
|
5
|
-
import * as React$1 from 'react';
|
|
6
6
|
import './presentation-BRAUjTRt.js';
|
|
7
7
|
|
|
8
8
|
interface ViewerThemeProviderProps {
|