pptx-react-viewer 1.0.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 +982 -0
- package/dist/PowerPointViewer-K2URyPlJ.d.mts +522 -0
- package/dist/PowerPointViewer-K2URyPlJ.d.ts +522 -0
- package/dist/index.d.mts +71 -0
- package/dist/index.d.ts +71 -0
- package/dist/index.js +121771 -0
- package/dist/index.mjs +121737 -0
- package/dist/pptx-viewer.css +2 -0
- package/dist/viewer/index.d.mts +267 -0
- package/dist/viewer/index.d.ts +267 -0
- package/dist/viewer/index.js +121947 -0
- package/dist/viewer/index.mjs +121908 -0
- package/node_modules/emf-converter/README.md +629 -0
- package/node_modules/emf-converter/dist/index.d.mts +86 -0
- package/node_modules/emf-converter/dist/index.d.ts +86 -0
- package/node_modules/emf-converter/dist/index.js +4199 -0
- package/node_modules/emf-converter/dist/index.mjs +4195 -0
- package/node_modules/emf-converter/package.json +42 -0
- package/node_modules/mtx-decompressor/README.md +271 -0
- package/node_modules/mtx-decompressor/dist/index.d.mts +83 -0
- package/node_modules/mtx-decompressor/dist/index.d.ts +83 -0
- package/node_modules/mtx-decompressor/dist/index.js +1510 -0
- package/node_modules/mtx-decompressor/dist/index.mjs +1506 -0
- package/node_modules/mtx-decompressor/package.json +37 -0
- package/node_modules/pptx-viewer-core/README.md +1294 -0
- package/node_modules/pptx-viewer-core/dist/SvgExporter-BZJguJbp.d.ts +557 -0
- package/node_modules/pptx-viewer-core/dist/SvgExporter-DqcmwxFu.d.mts +557 -0
- package/node_modules/pptx-viewer-core/dist/cli/index.d.mts +150 -0
- package/node_modules/pptx-viewer-core/dist/cli/index.d.ts +150 -0
- package/node_modules/pptx-viewer-core/dist/cli/index.js +39790 -0
- package/node_modules/pptx-viewer-core/dist/cli/index.mjs +39757 -0
- package/node_modules/pptx-viewer-core/dist/converter/index.d.mts +48 -0
- package/node_modules/pptx-viewer-core/dist/converter/index.d.ts +48 -0
- package/node_modules/pptx-viewer-core/dist/converter/index.js +3676 -0
- package/node_modules/pptx-viewer-core/dist/converter/index.mjs +3664 -0
- package/node_modules/pptx-viewer-core/dist/index.d.mts +10796 -0
- package/node_modules/pptx-viewer-core/dist/index.d.ts +10796 -0
- package/node_modules/pptx-viewer-core/dist/index.js +49658 -0
- package/node_modules/pptx-viewer-core/dist/index.mjs +49270 -0
- package/node_modules/pptx-viewer-core/dist/presentation-Bo7cMMCe.d.mts +4558 -0
- package/node_modules/pptx-viewer-core/dist/presentation-Bo7cMMCe.d.ts +4558 -0
- package/node_modules/pptx-viewer-core/dist/text-operations-Bo-WG-Z8.d.mts +134 -0
- package/node_modules/pptx-viewer-core/dist/text-operations-D0f1jred.d.ts +134 -0
- package/node_modules/pptx-viewer-core/package.json +61 -0
- package/package.json +89 -0
|
@@ -0,0 +1,522 @@
|
|
|
1
|
+
import { PptxSlide, PptxElement, ShapeStyle, PptxAnimationPreset, ConnectorArrowType, XmlObject, PptxElementAnimation, PptxSlideTransition, StrokeDashType, PptxNativeAnimation } from 'pptx-viewer-core';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import React__default from 'react';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Core data-model types for the PowerPoint viewer/editor plugin.
|
|
7
|
+
*
|
|
8
|
+
* Framework-agnostic types (PptxElement, PptxSlide, TextStyle, etc.)
|
|
9
|
+
* live in `pptx-viewer-core`. This module defines additional types used
|
|
10
|
+
* by the React viewer layer for canvas layout, drag/resize interactions,
|
|
11
|
+
* clipboard operations, undo/redo history, geometry, and shape quick styles.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The current operating mode of the PowerPoint viewer.
|
|
16
|
+
*
|
|
17
|
+
* - `"preview"` -- Read-only viewing with no editing controls.
|
|
18
|
+
* - `"edit"` -- Full editing mode with toolbar, inspector, and canvas interaction.
|
|
19
|
+
* - `"present"` -- Fullscreen presentation/slideshow mode with animations.
|
|
20
|
+
* - `"master"` -- Slide master editing mode for template/layout manipulation.
|
|
21
|
+
*/
|
|
22
|
+
type ViewerMode = 'preview' | 'edit' | 'present' | 'master';
|
|
23
|
+
/**
|
|
24
|
+
* Union of all shape preset types that the viewer can insert or render.
|
|
25
|
+
* Maps to OOXML `a:prstGeom` preset values (e.g. "rect", "ellipse").
|
|
26
|
+
* Includes basic shapes, arrows, connectors, and freeform paths.
|
|
27
|
+
*/
|
|
28
|
+
type SupportedShapeType = 'rect' | 'roundRect' | 'ellipse' | 'triangle' | 'rtTriangle' | 'diamond' | 'cylinder' | 'parallelogram' | 'trapezoid' | 'pentagon' | 'hexagon' | 'octagon' | 'chevron' | 'star5' | 'star6' | 'star8' | 'plus' | 'heart' | 'cloud' | 'sun' | 'moon' | 'pie' | 'plaque' | 'teardrop' | 'line' | 'rtArrow' | 'leftArrow' | 'upArrow' | 'downArrow' | 'connector' | 'freeform';
|
|
29
|
+
/**
|
|
30
|
+
* Connector geometry presets corresponding to OOXML `a:prstGeom` connector types.
|
|
31
|
+
* Determines the routing style (straight, bent with N segments, or curved).
|
|
32
|
+
*/
|
|
33
|
+
type ConnectorGeometryType = 'straightConnector1' | 'bentConnector2' | 'bentConnector3' | 'bentConnector4' | 'bentConnector5' | 'curvedConnector2' | 'curvedConnector3' | 'curvedConnector4' | 'curvedConnector5';
|
|
34
|
+
/** The pixel dimensions of the slide canvas (presentation slide size). */
|
|
35
|
+
interface CanvasSize {
|
|
36
|
+
/** Width of the canvas in CSS pixels. */
|
|
37
|
+
width: number;
|
|
38
|
+
/** Height of the canvas in CSS pixels. */
|
|
39
|
+
height: number;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Tracks the state of an ongoing element drag operation.
|
|
43
|
+
* Created on pointer-down and destroyed on pointer-up.
|
|
44
|
+
* During the drag, position changes are applied directly to DOM elements
|
|
45
|
+
* for performance (bypassing React state) and committed to state on completion.
|
|
46
|
+
*/
|
|
47
|
+
interface DragState {
|
|
48
|
+
/** ID of the primary element being dragged. */
|
|
49
|
+
elementId: string;
|
|
50
|
+
/** Client X coordinate at the start of the drag. */
|
|
51
|
+
startClientX: number;
|
|
52
|
+
/** Client Y coordinate at the start of the drag. */
|
|
53
|
+
startClientY: number;
|
|
54
|
+
/** Original positions of all selected elements, keyed by element ID. */
|
|
55
|
+
startPositionsById: Record<string, {
|
|
56
|
+
x: number;
|
|
57
|
+
y: number;
|
|
58
|
+
}>;
|
|
59
|
+
/** DOM elements cached at drag-start to avoid per-frame querySelector calls. */
|
|
60
|
+
domEls: Map<string, HTMLElement>;
|
|
61
|
+
/** Whether the pointer has actually moved since the drag started. */
|
|
62
|
+
moved: boolean;
|
|
63
|
+
/** Accumulated delta — stored during DOM-only drag, committed on pointerup. */
|
|
64
|
+
lastDx: number;
|
|
65
|
+
lastDy: number;
|
|
66
|
+
}
|
|
67
|
+
/** Handle used as the resize anchor point (corners + edge midpoints). */
|
|
68
|
+
type ResizeHandle = 'nw' | 'ne' | 'sw' | 'se' | 'n' | 's' | 'e' | 'w';
|
|
69
|
+
/**
|
|
70
|
+
* Tracks the state of an ongoing element resize operation.
|
|
71
|
+
* Uses direct DOM manipulation during the resize for performance,
|
|
72
|
+
* then commits the final geometry to React state on pointer-up.
|
|
73
|
+
*/
|
|
74
|
+
interface ResizeState {
|
|
75
|
+
/** ID of the element being resized. */
|
|
76
|
+
elementId: string;
|
|
77
|
+
/** Client X coordinate at the start of the resize. */
|
|
78
|
+
startClientX: number;
|
|
79
|
+
/** Client Y coordinate at the start of the resize. */
|
|
80
|
+
startClientY: number;
|
|
81
|
+
/** Original X position of the element. */
|
|
82
|
+
startX: number;
|
|
83
|
+
/** Original Y position of the element. */
|
|
84
|
+
startY: number;
|
|
85
|
+
/** Original width of the element. */
|
|
86
|
+
startWidth: number;
|
|
87
|
+
/** Original height of the element. */
|
|
88
|
+
startHeight: number;
|
|
89
|
+
/** Which handle initiated the resize. */
|
|
90
|
+
handle: ResizeHandle;
|
|
91
|
+
/** Whether the pointer has actually moved since the resize started. */
|
|
92
|
+
moved: boolean;
|
|
93
|
+
/** DOM element cached at resize-start to avoid per-frame querySelector calls. */
|
|
94
|
+
domEl: HTMLElement | null;
|
|
95
|
+
/** Accumulated final geometry — committed on pointerup. */
|
|
96
|
+
lastX: number;
|
|
97
|
+
lastY: number;
|
|
98
|
+
lastWidth: number;
|
|
99
|
+
lastHeight: number;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Describes the position and value of a shape adjustment handle (yellow diamond).
|
|
103
|
+
* Adjustment handles allow users to modify shape parameters like corner radius,
|
|
104
|
+
* arrow width, etc. without a full resize.
|
|
105
|
+
*/
|
|
106
|
+
interface ShapeAdjustmentHandleDescriptor {
|
|
107
|
+
key: string;
|
|
108
|
+
left: number;
|
|
109
|
+
top: number;
|
|
110
|
+
value: number;
|
|
111
|
+
cursor: string;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Tracks the state of an ongoing shape adjustment handle drag.
|
|
115
|
+
* Used when the user drags the yellow diamond handle to alter
|
|
116
|
+
* shape-specific parameters (e.g. corner radius on a rounded rectangle).
|
|
117
|
+
*/
|
|
118
|
+
interface ShapeAdjustmentDragState {
|
|
119
|
+
elementId: string;
|
|
120
|
+
key: string;
|
|
121
|
+
shapeType: string;
|
|
122
|
+
startClientX: number;
|
|
123
|
+
startClientY: number;
|
|
124
|
+
startAdjustment: number;
|
|
125
|
+
startWidth: number;
|
|
126
|
+
startHeight: number;
|
|
127
|
+
moved: boolean;
|
|
128
|
+
}
|
|
129
|
+
/** Payload stored when an element is copied/cut to the internal clipboard. */
|
|
130
|
+
interface ElementClipboardPayload {
|
|
131
|
+
element: PptxElement;
|
|
132
|
+
isTemplate: boolean;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* A snapshot of editor state captured for undo/redo history.
|
|
136
|
+
* Contains the full slide deck state at a point in time so that
|
|
137
|
+
* any editing operation can be reverted or replayed.
|
|
138
|
+
*/
|
|
139
|
+
interface EditorHistorySnapshot {
|
|
140
|
+
width: number;
|
|
141
|
+
height: number;
|
|
142
|
+
activeSlideIndex: number;
|
|
143
|
+
slides: PptxSlide[];
|
|
144
|
+
templateElementsBySlideId: Record<string, PptxElement[]>;
|
|
145
|
+
actionLabel?: string;
|
|
146
|
+
}
|
|
147
|
+
/** Axis-aligned bounding box for an element, used for hit-testing and alignment. */
|
|
148
|
+
interface ElementBounds {
|
|
149
|
+
minX: number;
|
|
150
|
+
minY: number;
|
|
151
|
+
maxX: number;
|
|
152
|
+
maxY: number;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Geometry data for rendering a connector line as an SVG path.
|
|
156
|
+
* Includes start/end coordinates, the SVG path data string,
|
|
157
|
+
* and optional marker (arrowhead) identifiers.
|
|
158
|
+
*/
|
|
159
|
+
interface ConnectorPathGeometry {
|
|
160
|
+
startX: number;
|
|
161
|
+
startY: number;
|
|
162
|
+
endX: number;
|
|
163
|
+
endY: number;
|
|
164
|
+
pathData: string;
|
|
165
|
+
d?: string;
|
|
166
|
+
viewBox?: string;
|
|
167
|
+
startMarkerId?: string;
|
|
168
|
+
endMarkerId?: string;
|
|
169
|
+
}
|
|
170
|
+
/** A named preset shape style used in the Quick Styles gallery. */
|
|
171
|
+
interface ShapeQuickStyle {
|
|
172
|
+
name: string;
|
|
173
|
+
style: Partial<ShapeStyle>;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Theme configuration types for the PowerPoint viewer.
|
|
178
|
+
*
|
|
179
|
+
* All color values accept any valid CSS color string:
|
|
180
|
+
* hex (`#6366f1`), rgb (`rgb(99 102 241)`), hsl (`hsl(239 84% 67%)`),
|
|
181
|
+
* oklch (`oklch(0.585 0.233 277)`), named colors, etc.
|
|
182
|
+
*/
|
|
183
|
+
/**
|
|
184
|
+
* Semantic color tokens for the viewer UI.
|
|
185
|
+
*
|
|
186
|
+
* These map to CSS custom properties (`--pptx-<token>`) and drive all
|
|
187
|
+
* UI component colors. The naming follows the shadcn/ui convention so
|
|
188
|
+
* that Tailwind + shadcn users get a familiar experience.
|
|
189
|
+
*/
|
|
190
|
+
interface ViewerThemeColors {
|
|
191
|
+
/** Page / root background */
|
|
192
|
+
background: string;
|
|
193
|
+
/** Default text color */
|
|
194
|
+
foreground: string;
|
|
195
|
+
/** Card / panel surface */
|
|
196
|
+
card: string;
|
|
197
|
+
/** Text on card surfaces */
|
|
198
|
+
cardForeground: string;
|
|
199
|
+
/** Popover / dropdown surface */
|
|
200
|
+
popover: string;
|
|
201
|
+
/** Text inside popovers */
|
|
202
|
+
popoverForeground: string;
|
|
203
|
+
/** Primary action color (buttons, active indicators) */
|
|
204
|
+
primary: string;
|
|
205
|
+
/** Text on primary-colored backgrounds */
|
|
206
|
+
primaryForeground: string;
|
|
207
|
+
/** Secondary / subdued action color */
|
|
208
|
+
secondary: string;
|
|
209
|
+
/** Text on secondary backgrounds */
|
|
210
|
+
secondaryForeground: string;
|
|
211
|
+
/** Muted / disabled surface */
|
|
212
|
+
muted: string;
|
|
213
|
+
/** Text on muted surfaces (also used for secondary text) */
|
|
214
|
+
mutedForeground: string;
|
|
215
|
+
/** Accent / hover-highlight surface */
|
|
216
|
+
accent: string;
|
|
217
|
+
/** Text on accent surfaces */
|
|
218
|
+
accentForeground: string;
|
|
219
|
+
/** Destructive / danger action color */
|
|
220
|
+
destructive: string;
|
|
221
|
+
/** Text on destructive backgrounds */
|
|
222
|
+
destructiveForeground: string;
|
|
223
|
+
/** Default border color */
|
|
224
|
+
border: string;
|
|
225
|
+
/** Input field border color */
|
|
226
|
+
input: string;
|
|
227
|
+
/** Focus ring color */
|
|
228
|
+
ring: string;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Full viewer theme configuration.
|
|
232
|
+
*
|
|
233
|
+
* Every property is optional — unset values fall back to the built-in
|
|
234
|
+
* dark theme defaults.
|
|
235
|
+
*/
|
|
236
|
+
interface ViewerTheme {
|
|
237
|
+
/** Semantic UI colors. Each key maps to a `--pptx-<key>` CSS custom property. */
|
|
238
|
+
colors?: Partial<ViewerThemeColors>;
|
|
239
|
+
/** Base border-radius value (e.g. `"0.5rem"`, `"8px"`). */
|
|
240
|
+
radius?: string;
|
|
241
|
+
/**
|
|
242
|
+
* Escape hatch: arbitrary CSS custom properties to set on the viewer
|
|
243
|
+
* root element. Keys should include the `--` prefix.
|
|
244
|
+
*
|
|
245
|
+
* @example
|
|
246
|
+
* ```ts
|
|
247
|
+
* { "--my-custom-shadow": "0 4px 12px rgba(0,0,0,0.5)" }
|
|
248
|
+
* ```
|
|
249
|
+
*/
|
|
250
|
+
cssVars?: Record<string, string>;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Collaboration types — Shared type definitions for the real-time
|
|
255
|
+
* collaboration infrastructure (Yjs-backed CRDT sync, presence tracking,
|
|
256
|
+
* collaborative editing).
|
|
257
|
+
*
|
|
258
|
+
* @module collaboration/types
|
|
259
|
+
*/
|
|
260
|
+
/**
|
|
261
|
+
* Configuration for enabling real-time collaboration on a presentation.
|
|
262
|
+
*
|
|
263
|
+
* When provided to `PowerPointViewer`, the viewer wraps its content in a
|
|
264
|
+
* `CollaborationProvider` and wires up presence tracking, remote cursors,
|
|
265
|
+
* and CRDT-based state synchronisation.
|
|
266
|
+
*/
|
|
267
|
+
interface CollaborationConfig {
|
|
268
|
+
/** Unique identifier for the collaboration room (alphanumeric, hyphens, underscores). */
|
|
269
|
+
roomId: string;
|
|
270
|
+
/** WebSocket server URL for the Yjs provider (e.g. "wss://collab.example.com"). */
|
|
271
|
+
serverUrl: string;
|
|
272
|
+
/** Display name for the local user. */
|
|
273
|
+
userName: string;
|
|
274
|
+
/** Avatar URL for the local user (optional). */
|
|
275
|
+
userAvatar?: string;
|
|
276
|
+
/** Hex colour for the local user's cursor/presence indicator. */
|
|
277
|
+
userColor?: string;
|
|
278
|
+
/** Optional authentication token sent with the WebSocket handshake. */
|
|
279
|
+
authToken?: string;
|
|
280
|
+
}
|
|
281
|
+
/** Connection lifecycle states for the Yjs WebSocket provider. */
|
|
282
|
+
type ConnectionStatus = 'disconnected' | 'connecting' | 'connected' | 'error';
|
|
283
|
+
/**
|
|
284
|
+
* Presence data broadcast to other participants.
|
|
285
|
+
* Cursor position is relative to the slide canvas (0..canvasWidth, 0..canvasHeight).
|
|
286
|
+
*/
|
|
287
|
+
interface UserPresence {
|
|
288
|
+
/** Unique client ID (assigned by Yjs awareness). */
|
|
289
|
+
clientId: number;
|
|
290
|
+
/** Sanitised display name. */
|
|
291
|
+
userName: string;
|
|
292
|
+
/** Optional avatar URL (validated). */
|
|
293
|
+
userAvatar?: string;
|
|
294
|
+
/** Hex colour for the user's cursor ring. */
|
|
295
|
+
userColor: string;
|
|
296
|
+
/** Slide index the user is currently viewing. */
|
|
297
|
+
activeSlideIndex: number;
|
|
298
|
+
/** Cursor X on the canvas (clamped to slide bounds). */
|
|
299
|
+
cursorX: number;
|
|
300
|
+
/** Cursor Y on the canvas (clamped to slide bounds). */
|
|
301
|
+
cursorY: number;
|
|
302
|
+
/** ISO timestamp of last update (for stale-presence cleanup). */
|
|
303
|
+
lastUpdated: string;
|
|
304
|
+
/** Optional currently selected element ID. */
|
|
305
|
+
selectedElementId?: string;
|
|
306
|
+
}
|
|
307
|
+
/** Value exposed by `CollaborationContext`. */
|
|
308
|
+
interface CollaborationContextValue {
|
|
309
|
+
/** Current WebSocket connection status. */
|
|
310
|
+
status: ConnectionStatus;
|
|
311
|
+
/** Presence data for all remote users (excludes the local user). */
|
|
312
|
+
remoteUsers: UserPresence[];
|
|
313
|
+
/** Broadcast the local user's presence state. */
|
|
314
|
+
broadcastPresence: (update: Partial<Omit<UserPresence, 'clientId'>>) => void;
|
|
315
|
+
/** Total number of connected users (including local). */
|
|
316
|
+
connectedCount: number;
|
|
317
|
+
/** The collaboration config that was provided. */
|
|
318
|
+
config: CollaborationConfig;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Base handle interface for file viewer components.
|
|
323
|
+
* Defined locally to avoid dependency on external file-viewer plugin packages.
|
|
324
|
+
* Provides a standard `getContent` method used by the host application to
|
|
325
|
+
* retrieve the current file content (e.g. for saving).
|
|
326
|
+
*/
|
|
327
|
+
interface FileViewerHandle {
|
|
328
|
+
/** Get the current content of the file (for saving) */
|
|
329
|
+
getContent: () => Promise<string | Uint8Array>;
|
|
330
|
+
}
|
|
331
|
+
/** A shape preset entry used in the toolbar shape insertion palette. */
|
|
332
|
+
interface ShapePreset {
|
|
333
|
+
type: SupportedShapeType;
|
|
334
|
+
label: string;
|
|
335
|
+
icon: React__default.ReactNode;
|
|
336
|
+
}
|
|
337
|
+
/** Tracks the position and target element of an open context menu. */
|
|
338
|
+
interface ElementContextMenuState {
|
|
339
|
+
x: number;
|
|
340
|
+
y: number;
|
|
341
|
+
elementId: string;
|
|
342
|
+
}
|
|
343
|
+
/** Identifies an action triggered from the element right-click context menu. */
|
|
344
|
+
type ElementContextMenuAction = 'copy' | 'cut' | 'paste' | 'duplicate' | 'delete' | 'bring-forward' | 'send-backward' | 'bring-front' | 'send-back' | 'bringForward' | 'sendBackward' | 'bringToFront' | 'sendToBack' | 'comment' | 'addComment' | 'group' | 'ungroup' | 'editPoints' | 'editHyperlink';
|
|
345
|
+
/**
|
|
346
|
+
* State of an active marquee (rubber-band) selection rectangle.
|
|
347
|
+
* Created when the user clicks and drags on the canvas background,
|
|
348
|
+
* and used to compute which elements fall within the selection area.
|
|
349
|
+
*/
|
|
350
|
+
interface MarqueeSelectionState {
|
|
351
|
+
startX: number;
|
|
352
|
+
startY: number;
|
|
353
|
+
currentX: number;
|
|
354
|
+
currentY: number;
|
|
355
|
+
additive: boolean;
|
|
356
|
+
baseSelectionIds?: string[];
|
|
357
|
+
}
|
|
358
|
+
/** Tracks which table cell is selected and/or actively being edited. */
|
|
359
|
+
interface TableCellEditorState {
|
|
360
|
+
rowIndex: number;
|
|
361
|
+
columnIndex: number;
|
|
362
|
+
/** When true the cell has an active text input. */
|
|
363
|
+
isEditing?: boolean;
|
|
364
|
+
/** Optional multi-cell selection (Shift+Click range). Each entry is {row, col}. */
|
|
365
|
+
selectedCells?: Array<{
|
|
366
|
+
row: number;
|
|
367
|
+
col: number;
|
|
368
|
+
}>;
|
|
369
|
+
}
|
|
370
|
+
/** A single parsed table cell with its position, text content, and computed CSS style. */
|
|
371
|
+
interface ParsedTableCell {
|
|
372
|
+
rowIndex: number;
|
|
373
|
+
columnIndex: number;
|
|
374
|
+
text: string;
|
|
375
|
+
style: React__default.CSSProperties;
|
|
376
|
+
rawCell: XmlObject;
|
|
377
|
+
}
|
|
378
|
+
/** Complete parsed table data including row/column structure and all cells. */
|
|
379
|
+
interface ParsedTableData {
|
|
380
|
+
rowCount: number;
|
|
381
|
+
columnCount: number;
|
|
382
|
+
rows: XmlObject[];
|
|
383
|
+
columnPercentages: number[];
|
|
384
|
+
cells: ParsedTableCell[];
|
|
385
|
+
}
|
|
386
|
+
/** Runtime state for a single element's animation during presentation mode. */
|
|
387
|
+
interface PresentationAnimationRuntime {
|
|
388
|
+
elementId: string;
|
|
389
|
+
state: 'hidden' | 'entering' | 'visible';
|
|
390
|
+
animation: PptxElementAnimation;
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* Groups slides into named sections for the slides pane sidebar.
|
|
394
|
+
* Corresponds to OOXML `p15:section` elements in `presentation.xml`.
|
|
395
|
+
*/
|
|
396
|
+
interface SlideSectionGroup {
|
|
397
|
+
id: string;
|
|
398
|
+
label: string;
|
|
399
|
+
slideIndexes: number[];
|
|
400
|
+
/** Section highlight color from p15:sectionPr. */
|
|
401
|
+
color?: string;
|
|
402
|
+
/** Whether the section should start collapsed (from p15:sectionPr). */
|
|
403
|
+
defaultCollapsed?: boolean;
|
|
404
|
+
}
|
|
405
|
+
/** Alignment direction for distributing/aligning multiple selected elements on the slide. */
|
|
406
|
+
type SlideAlignment = 'left' | 'center' | 'right' | 'top' | 'middle' | 'bottom';
|
|
407
|
+
/** Identifies one of the ribbon-style toolbar tabs (home, insert, text, etc.). */
|
|
408
|
+
type ToolbarSection = 'home' | 'insert' | 'text' | 'arrange' | 'draw' | 'design' | 'transitions' | 'review' | 'view';
|
|
409
|
+
/** The active drawing/inking tool selected in the Draw toolbar tab. */
|
|
410
|
+
type DrawingTool = 'select' | 'pen' | 'highlighter' | 'eraser' | 'freeform';
|
|
411
|
+
/** A single entry in the keyboard shortcuts help panel. */
|
|
412
|
+
interface ShortcutReferenceItem {
|
|
413
|
+
action: string;
|
|
414
|
+
shortcut: string;
|
|
415
|
+
}
|
|
416
|
+
/** An accessibility audit finding (missing alt text, reading order issues, etc.). */
|
|
417
|
+
interface AccessibilityIssue {
|
|
418
|
+
slideIndex: number;
|
|
419
|
+
elementId?: string;
|
|
420
|
+
severity: 'error' | 'warning' | 'info';
|
|
421
|
+
message: string;
|
|
422
|
+
}
|
|
423
|
+
/** Dropdown option for selecting a connector geometry type. */
|
|
424
|
+
interface ConnectorGeometryOption {
|
|
425
|
+
value: ConnectorGeometryType;
|
|
426
|
+
label: string;
|
|
427
|
+
}
|
|
428
|
+
/** Dropdown option for selecting a connector arrowhead style. */
|
|
429
|
+
interface ConnectorArrowOption {
|
|
430
|
+
value: ConnectorArrowType;
|
|
431
|
+
label: string;
|
|
432
|
+
}
|
|
433
|
+
/** Dropdown option for selecting a stroke dash pattern. */
|
|
434
|
+
interface StrokeDashOption {
|
|
435
|
+
value: StrokeDashType;
|
|
436
|
+
label: string;
|
|
437
|
+
}
|
|
438
|
+
/** Dropdown option for selecting a slide transition type. */
|
|
439
|
+
interface SlideTransitionOption {
|
|
440
|
+
value: NonNullable<PptxSlideTransition['type']>;
|
|
441
|
+
label: string;
|
|
442
|
+
}
|
|
443
|
+
/** Dropdown option for selecting an animation effect preset. */
|
|
444
|
+
interface AnimationPresetOption {
|
|
445
|
+
value: Exclude<PptxAnimationPreset, 'none'>;
|
|
446
|
+
label: string;
|
|
447
|
+
}
|
|
448
|
+
interface PowerPointViewerProps {
|
|
449
|
+
/** PowerPoint content as Uint8Array */
|
|
450
|
+
content: Uint8Array;
|
|
451
|
+
/** Original file path — used for autosave recovery */
|
|
452
|
+
filePath?: string;
|
|
453
|
+
/** Callback when content has unsaved changes */
|
|
454
|
+
onDirtyChange?: (isDirty: boolean) => void;
|
|
455
|
+
onContentChange?: (content: Uint8Array) => void;
|
|
456
|
+
/** Callback when active slide changes */
|
|
457
|
+
onActiveSlideChange?: (slideIndex: number) => void;
|
|
458
|
+
/** Whether editing actions are enabled */
|
|
459
|
+
canEdit?: boolean;
|
|
460
|
+
/** Optional class name */
|
|
461
|
+
className?: string;
|
|
462
|
+
/**
|
|
463
|
+
* Theme configuration for customising the viewer's appearance.
|
|
464
|
+
*
|
|
465
|
+
* Accepts partial color overrides, a custom border-radius, and
|
|
466
|
+
* arbitrary CSS custom properties. Unset values fall back to the
|
|
467
|
+
* built-in dark theme.
|
|
468
|
+
*
|
|
469
|
+
* @example
|
|
470
|
+
* ```tsx
|
|
471
|
+
* <PowerPointViewer
|
|
472
|
+
* content={bytes}
|
|
473
|
+
* theme={{
|
|
474
|
+
* colors: { primary: "#6366f1", background: "#0f172a" },
|
|
475
|
+
* radius: "0.75rem",
|
|
476
|
+
* }}
|
|
477
|
+
* />
|
|
478
|
+
* ```
|
|
479
|
+
*
|
|
480
|
+
* @see {@link ViewerTheme} for the full type definition.
|
|
481
|
+
*/
|
|
482
|
+
theme?: ViewerTheme;
|
|
483
|
+
/**
|
|
484
|
+
* Optional real-time collaboration configuration.
|
|
485
|
+
*
|
|
486
|
+
* When provided, the viewer enables collaborative editing with live
|
|
487
|
+
* cursors, user presence indicators, and CRDT-based state sync via Yjs.
|
|
488
|
+
* Requires `yjs` and `y-websocket` peer dependencies.
|
|
489
|
+
*
|
|
490
|
+
* @example
|
|
491
|
+
* ```tsx
|
|
492
|
+
* <PowerPointViewer
|
|
493
|
+
* content={bytes}
|
|
494
|
+
* collaboration={{
|
|
495
|
+
* roomId: "my-room-123",
|
|
496
|
+
* serverUrl: "wss://collab.example.com",
|
|
497
|
+
* userName: "Alice",
|
|
498
|
+
* userColor: "#6366f1",
|
|
499
|
+
* }}
|
|
500
|
+
* />
|
|
501
|
+
* ```
|
|
502
|
+
*/
|
|
503
|
+
collaboration?: CollaborationConfig;
|
|
504
|
+
}
|
|
505
|
+
interface PowerPointViewerHandle extends FileViewerHandle {
|
|
506
|
+
getContent: () => Promise<Uint8Array>;
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
declare function getAnimationInitialStyle(preset: PptxAnimationPreset | undefined, nativeAnimation?: PptxNativeAnimation): React__default.CSSProperties;
|
|
510
|
+
|
|
511
|
+
/**
|
|
512
|
+
* Root React component for the PowerPoint viewer/editor.
|
|
513
|
+
*
|
|
514
|
+
* Accepts binary `.pptx` content and renders a full-featured editor with
|
|
515
|
+
* slide canvas, toolbar, inspector panels, presentation mode, and more.
|
|
516
|
+
*
|
|
517
|
+
* Uses `forwardRef` to expose a `PowerPointViewerHandle` for imperative
|
|
518
|
+
* access (e.g. serialising the current content for saving).
|
|
519
|
+
*/
|
|
520
|
+
declare const PowerPointViewer: React.ForwardRefExoticComponent<PowerPointViewerProps & React.RefAttributes<PowerPointViewerHandle>>;
|
|
521
|
+
|
|
522
|
+
export { type AccessibilityIssue as A, type SlideSectionGroup as B, type CollaborationConfig as C, type DragState as D, type EditorHistorySnapshot as E, type FileViewerHandle as F, type SlideTransitionOption as G, type StrokeDashOption as H, type SupportedShapeType as I, type ToolbarSection as J, type ViewerMode as K, type MarqueeSelectionState as M, PowerPointViewer as P, type ResizeHandle as R, type ShapeAdjustmentDragState as S, type TableCellEditorState as T, type UserPresence as U, type ViewerThemeColors as V, type ViewerTheme as a, type PowerPointViewerHandle as b, type PowerPointViewerProps as c, type ConnectionStatus as d, type CollaborationContextValue as e, type AnimationPresetOption as f, getAnimationInitialStyle as g, type CanvasSize as h, type ConnectorArrowOption as i, type ConnectorGeometryOption as j, type ConnectorGeometryType as k, type ConnectorPathGeometry as l, type DrawingTool as m, type ElementBounds as n, type ElementClipboardPayload as o, type ElementContextMenuAction as p, type ElementContextMenuState as q, type ParsedTableCell as r, type ParsedTableData as s, type PresentationAnimationRuntime as t, type ResizeState as u, type ShapeAdjustmentHandleDescriptor as v, type ShapePreset as w, type ShapeQuickStyle as x, type ShortcutReferenceItem as y, type SlideAlignment as z };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { V as ViewerThemeColors, a as ViewerTheme } from './PowerPointViewer-K2URyPlJ.mjs';
|
|
2
|
+
export { P as PowerPointViewer, b as PowerPointViewerHandle, c as PowerPointViewerProps, g as getAnimationInitialStyle } from './PowerPointViewer-K2URyPlJ.mjs';
|
|
3
|
+
import { Options } from 'html2canvas-pro';
|
|
4
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
|
+
import 'pptx-viewer-core';
|
|
6
|
+
import 'react';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Default dark-theme color values.
|
|
10
|
+
*
|
|
11
|
+
* These correspond to the built-in dark UI of the PowerPoint viewer and
|
|
12
|
+
* use Tailwind's gray palette as the neutral scale with indigo as the
|
|
13
|
+
* primary accent.
|
|
14
|
+
*/
|
|
15
|
+
declare const defaultThemeColors: ViewerThemeColors;
|
|
16
|
+
/** Default border-radius. */
|
|
17
|
+
declare const defaultRadius = "0.5rem";
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Convert a `ViewerTheme` into a flat `Record<string, string>` of CSS
|
|
21
|
+
* custom properties (including the `--` prefix) ready to be spread onto
|
|
22
|
+
* a `style` attribute.
|
|
23
|
+
*
|
|
24
|
+
* Only properties that differ from the built-in defaults are emitted when
|
|
25
|
+
* `omitDefaults` is true (the default).
|
|
26
|
+
*/
|
|
27
|
+
declare function themeToCssVars(theme: ViewerTheme | undefined, omitDefaults?: boolean): Record<string, string>;
|
|
28
|
+
/**
|
|
29
|
+
* Build the complete set of CSS custom properties with all defaults.
|
|
30
|
+
* Useful for generating a full fallback stylesheet.
|
|
31
|
+
*/
|
|
32
|
+
declare function defaultCssVars(): Record<string, string>;
|
|
33
|
+
|
|
34
|
+
interface ViewerThemeProviderProps {
|
|
35
|
+
theme?: ViewerTheme;
|
|
36
|
+
children: React.ReactNode;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Provides a `ViewerTheme` to all descendant viewer components.
|
|
40
|
+
*
|
|
41
|
+
* Typically you do **not** need to use this directly — passing a `theme`
|
|
42
|
+
* prop to `<PowerPointViewer>` is sufficient. This provider is exposed
|
|
43
|
+
* for advanced use-cases where you want to wrap multiple viewers or
|
|
44
|
+
* share a theme across a wider subtree.
|
|
45
|
+
*/
|
|
46
|
+
declare function ViewerThemeProvider({ theme, children }: ViewerThemeProviderProps): react_jsx_runtime.JSX.Element;
|
|
47
|
+
/**
|
|
48
|
+
* Returns the active `ViewerTheme` (if any) from the nearest
|
|
49
|
+
* `ViewerThemeProvider`.
|
|
50
|
+
*/
|
|
51
|
+
declare function useViewerTheme(): ViewerTheme | undefined;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* A drop-in replacement for `html2canvas(element, options)` that first
|
|
55
|
+
* resolves any oklch / oklab / lch / lab / color() values in the cloned
|
|
56
|
+
* DOM to rgb()/hex, preventing parse errors in html2canvas ≤ 1.x.
|
|
57
|
+
*
|
|
58
|
+
* Three-pronged approach:
|
|
59
|
+
* 1. Patch `<style>` elements to replace oklch in CSS custom properties.
|
|
60
|
+
* 2. Resolve `:root` / `<body>` inline custom properties.
|
|
61
|
+
* 3. Walk every element and convert computed colour values to sRGB.
|
|
62
|
+
*
|
|
63
|
+
* Usage:
|
|
64
|
+
* ```ts
|
|
65
|
+
* import { renderToCanvas } from "../lib/canvas-export";
|
|
66
|
+
* const canvas = await renderToCanvas(element, { scale: 2 });
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
declare function renderToCanvas(element: HTMLElement, options?: Partial<Options>): Promise<HTMLCanvasElement>;
|
|
70
|
+
|
|
71
|
+
export { ViewerTheme, ViewerThemeColors, ViewerThemeProvider, defaultCssVars, defaultRadius, defaultThemeColors, renderToCanvas, themeToCssVars, useViewerTheme };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { V as ViewerThemeColors, a as ViewerTheme } from './PowerPointViewer-K2URyPlJ.js';
|
|
2
|
+
export { P as PowerPointViewer, b as PowerPointViewerHandle, c as PowerPointViewerProps, g as getAnimationInitialStyle } from './PowerPointViewer-K2URyPlJ.js';
|
|
3
|
+
import { Options } from 'html2canvas-pro';
|
|
4
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
|
+
import 'pptx-viewer-core';
|
|
6
|
+
import 'react';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Default dark-theme color values.
|
|
10
|
+
*
|
|
11
|
+
* These correspond to the built-in dark UI of the PowerPoint viewer and
|
|
12
|
+
* use Tailwind's gray palette as the neutral scale with indigo as the
|
|
13
|
+
* primary accent.
|
|
14
|
+
*/
|
|
15
|
+
declare const defaultThemeColors: ViewerThemeColors;
|
|
16
|
+
/** Default border-radius. */
|
|
17
|
+
declare const defaultRadius = "0.5rem";
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Convert a `ViewerTheme` into a flat `Record<string, string>` of CSS
|
|
21
|
+
* custom properties (including the `--` prefix) ready to be spread onto
|
|
22
|
+
* a `style` attribute.
|
|
23
|
+
*
|
|
24
|
+
* Only properties that differ from the built-in defaults are emitted when
|
|
25
|
+
* `omitDefaults` is true (the default).
|
|
26
|
+
*/
|
|
27
|
+
declare function themeToCssVars(theme: ViewerTheme | undefined, omitDefaults?: boolean): Record<string, string>;
|
|
28
|
+
/**
|
|
29
|
+
* Build the complete set of CSS custom properties with all defaults.
|
|
30
|
+
* Useful for generating a full fallback stylesheet.
|
|
31
|
+
*/
|
|
32
|
+
declare function defaultCssVars(): Record<string, string>;
|
|
33
|
+
|
|
34
|
+
interface ViewerThemeProviderProps {
|
|
35
|
+
theme?: ViewerTheme;
|
|
36
|
+
children: React.ReactNode;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Provides a `ViewerTheme` to all descendant viewer components.
|
|
40
|
+
*
|
|
41
|
+
* Typically you do **not** need to use this directly — passing a `theme`
|
|
42
|
+
* prop to `<PowerPointViewer>` is sufficient. This provider is exposed
|
|
43
|
+
* for advanced use-cases where you want to wrap multiple viewers or
|
|
44
|
+
* share a theme across a wider subtree.
|
|
45
|
+
*/
|
|
46
|
+
declare function ViewerThemeProvider({ theme, children }: ViewerThemeProviderProps): react_jsx_runtime.JSX.Element;
|
|
47
|
+
/**
|
|
48
|
+
* Returns the active `ViewerTheme` (if any) from the nearest
|
|
49
|
+
* `ViewerThemeProvider`.
|
|
50
|
+
*/
|
|
51
|
+
declare function useViewerTheme(): ViewerTheme | undefined;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* A drop-in replacement for `html2canvas(element, options)` that first
|
|
55
|
+
* resolves any oklch / oklab / lch / lab / color() values in the cloned
|
|
56
|
+
* DOM to rgb()/hex, preventing parse errors in html2canvas ≤ 1.x.
|
|
57
|
+
*
|
|
58
|
+
* Three-pronged approach:
|
|
59
|
+
* 1. Patch `<style>` elements to replace oklch in CSS custom properties.
|
|
60
|
+
* 2. Resolve `:root` / `<body>` inline custom properties.
|
|
61
|
+
* 3. Walk every element and convert computed colour values to sRGB.
|
|
62
|
+
*
|
|
63
|
+
* Usage:
|
|
64
|
+
* ```ts
|
|
65
|
+
* import { renderToCanvas } from "../lib/canvas-export";
|
|
66
|
+
* const canvas = await renderToCanvas(element, { scale: 2 });
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
declare function renderToCanvas(element: HTMLElement, options?: Partial<Options>): Promise<HTMLCanvasElement>;
|
|
70
|
+
|
|
71
|
+
export { ViewerTheme, ViewerThemeColors, ViewerThemeProvider, defaultCssVars, defaultRadius, defaultThemeColors, renderToCanvas, themeToCssVars, useViewerTheme };
|