pptx-vanilla-viewer 0.15.0 → 0.16.1

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 CHANGED
@@ -4,6 +4,18 @@ 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
+ ## [0.16.0](https://github.com/ChristopherVR/pptx-viewer/releases/tag/pptx-vanilla-viewer@0.16.0) - 2026-07-18
8
+
9
+ ### Features
10
+
11
+ - **vanilla:** Export createRibbon for independent composition (by @ChristopherVR) ([521d494](https://github.com/ChristopherVR/pptx-viewer/commit/521d4943e2d457d87e5305c15090928212c58a3c))
12
+
13
+ ## [0.15.0](https://github.com/ChristopherVR/pptx-viewer/releases/tag/pptx-vanilla-viewer@0.15.0) - 2026-07-18
14
+
15
+ ### Dependencies
16
+
17
+ - **deps:** Update dependencies to latest and migrate core/shared/locales to TypeScript 7 (by @ChristopherVR) ([cc72948](https://github.com/ChristopherVR/pptx-viewer/commit/cc729482cc5ae4ae56e1219f290c2953ec83c12a))
18
+
7
19
  ## [0.14.0](https://github.com/ChristopherVR/pptx-viewer/releases/tag/pptx-vanilla-viewer@0.14.0) - 2026-07-18
8
20
 
9
21
  ### Bug Fixes
package/README.md CHANGED
@@ -71,6 +71,73 @@ viewer.destroy();
71
71
 
72
72
  The container should have a size (the viewer fills it: `width/height: 100%`).
73
73
 
74
+ ## Options
75
+
76
+ All options are optional except the container element itself. Beyond the ones
77
+ shown above:
78
+
79
+ | Option | Type | Default | Description |
80
+ | -------------------------------------- | ----------------------------------------------------- | --------------------- | ------------------------------------------------------------------------------------------- |
81
+ | `source` | `string \| ArrayBuffer \| Uint8Array \| Blob \| File` | - | The presentation to open (URL or bytes). Omit to start empty and call `loadFile`/`loadUrl`. |
82
+ | `fonts` | `ViewerFontSource[]` | - | Licensed font sources supplied by the host application. |
83
+ | `theme` | `ViewerTheme` | - | Chrome theme (colors, radius, CSS vars). |
84
+ | `fileName` | `string` | - | Display name shown in the title bar. |
85
+ | `locale` / `messages` | `string` / `TranslationMessages` | `'en'` | UI locale and per-locale `pptx.*` dictionaries (see [i18n](#i18n)). |
86
+ | `initialSlide` | `number` | `0` | Zero-based slide shown after load. |
87
+ | `editable` | `boolean` | `false` | Enable editing (see [Editing](#editing)). |
88
+ | `showToolbar` | `boolean` | `true` | Whole ribbon/title-bar/status-bar chrome. |
89
+ | `showThumbnails` | `boolean` | `true` | Thumbnail sidebar. |
90
+ | `showFormatToolbar` | `boolean` | `true` | Editing format toolbar row (visible only while editing). |
91
+ | `showInspector` | `boolean` | `true` | Property inspector panel (visible only while editing). |
92
+ | `hiddenActions` | `ToolbarActionId[]` | - | Hide individual buttons/tabs (see [Toolbar customization](#toolbar-customization)). |
93
+ | `registry` | `ElementRendererRegistry` | - | Custom element-renderer registry (see [Element coverage](#element-coverage)). |
94
+ | `smartArt3D` | `boolean` | `false` | Opt-in Three.js 3D SmartArt renderer (optional `three` peer, lazily imported). |
95
+ | `autosave` | `boolean` | `false` | Debounced crash-recovery autosave to IndexedDB. |
96
+ | `autosaveIntervalMs` | `number` | `2000` | Autosave debounce window. |
97
+ | `autosaveFilePath` | `string` | `'presentation.pptx'` | IndexedDB recovery key for autosave snapshots. |
98
+ | `collaboration` | `CollaborationConfig` | - | Start a Yjs collaboration session immediately (y-websocket or serverless y-webrtc). |
99
+ | `shareDefaults` | `{ roomId?, userName?, serverUrl? }` | - | Prefilled values for the Share/Broadcast dialogs. |
100
+ | `availableThemes` / `availableLocales` | catalog entries | - | Choices offered by File > Options. |
101
+ | `onThemeChange` / `onLocaleChange` | `(key: string) => void` | - | Host hooks for the File > Options pickers (host owns persistence when supplied). |
102
+ | `accountAuth` | `AccountAuthConfig` | - | Optional sign-in hook point for File > Account. |
103
+
104
+ Callbacks: `onLoad`, `onError`, `onSlideChange`, `onZoomChange`,
105
+ `onPresentationChange`, `onChange` (any document mutation), `onDirtyChange`,
106
+ `onSelectionChange`, `onAutosaveStatus`, `onAutosaveRecovery` (offers a prior
107
+ session's recovery snapshot), `onToggleAutosave`, and `onCollaborationStatus`.
108
+
109
+ ## Instance API
110
+
111
+ The handle returned by `createPptxViewer` implements the shared
112
+ `PowerPointViewerAPI` (the same imperative contract as the React/Vue/Angular/
113
+ Svelte bindings: `getContent`, `goTo`, `undo`/`redo`, zoom and mode getters/
114
+ setters, `getSlides`/`getSlide`/`getActiveSlide`, `addSlide`/`deleteSlides`/
115
+ `duplicateSlides`/`moveSlide`/`toggleHideSlides`, `getElements`/
116
+ `getElementById`/`updateElement`/`deleteElements`/`duplicateElement`, and the
117
+ selection methods) plus vanilla-specific methods:
118
+
119
+ - **Loading**: `loadFile(bytesOrBlob)`, `loadUrl(url)`.
120
+ - **Navigation / zoom**: `next()`, `prev()`, `goToSlide(index)`,
121
+ `getSlideCount()`, `getCurrentSlide()`, `getZoom()`, `setZoom(scale)`,
122
+ `zoomIn()`, `zoomOut()`, `zoomToFit()`.
123
+ - **Presentation**: `enterPresentation()`, `exitPresentation()`.
124
+ - **Editing**: `setEditable(flag)`, `setEditTemplateMode(flag)`, `undo()`,
125
+ `redo()`, `canUndo()`, `canRedo()`, `deleteSelected()`,
126
+ `getSelectedElementId()`.
127
+ - **Saving**: `save(format?)`, `downloadPptx(fileName?)`,
128
+ `downloadAs(format, fileName?)`, `packageForSharing(fileName?)`.
129
+ - **Export / print**: `exportSlidePng(index?)`, `copySlideAsImage(index?)`,
130
+ `exportPdf(options?)`, `exportGif(options?)`, `exportVideo(options?)`,
131
+ `print(options?)` (returns `false` when the popup was blocked; call from a
132
+ click handler).
133
+ - **Collaboration**: `startCollaboration(config)`, `stopCollaboration()`,
134
+ `getCollaborationStatus()`.
135
+ - **Autosave**: `autosaveNow()`, `setAutosaveEnabled(flag)`,
136
+ `isAutosaveEnabled()`.
137
+ - **Chrome / extension**: `setTheme(theme?)`, `setLocale(locale)`,
138
+ `getRegistry()`, `getHandler()` (the live `pptx-viewer-core` handler),
139
+ `destroy()`.
140
+
74
141
  ## Keyboard
75
142
 
76
143
  Navigation: arrow keys / PageUp / PageDown / Space, Home/End jump to the
@@ -137,9 +204,6 @@ Pass `editable: true` (or call `setEditable(true)` at runtime) to turn on:
137
204
  - The toolbar's Save button (shown only when `editable`), which calls
138
205
  `downloadPptx()` to serialise and download the edited `.pptx`.
139
206
 
140
- For CSP-strict hosts, import `pptx-vanilla-viewer/styles.css` instead of using
141
- automatic style injection.
142
-
143
207
  Use `viewer.getSelectedElementId()` and the `onSelectionChange` /
144
208
  `onDirtyChange` callbacks to build your own chrome around the selection
145
209
  state.
@@ -172,6 +236,76 @@ viewer.getRegistry().register('table', renderTable);
172
236
 
173
237
  See `src/viewer/render/elements/README.md` for the full renderer contract.
174
238
 
239
+ ## Building your own chrome
240
+
241
+ `createPptxViewer` mounts the whole viewer (ribbon, canvas, inspector,
242
+ controllers) as one unit. If you want to build custom chrome around the same
243
+ primitives instead, the ribbon builder and the canvas renderer are both
244
+ importable independently:
245
+
246
+ ```ts
247
+ import {
248
+ createRibbon,
249
+ createStore,
250
+ createInitialViewerState,
251
+ renderSlideStage,
252
+ createDefaultRegistry,
253
+ type RibbonHandlers,
254
+ type Store,
255
+ type ViewerState,
256
+ } from 'pptx-vanilla-viewer';
257
+
258
+ // Your own reactive container, seeded with the same shape `createPptxViewer`
259
+ // uses internally.
260
+ const store: Store<ViewerState> = createStore(createInitialViewerState());
261
+
262
+ // `createRibbon` is callback-driven: it never reaches into a `PptxViewer`
263
+ // instance or a store directly, so it renders against whatever `RibbonHandlers`
264
+ // you hand it.
265
+ const handlers: RibbonHandlers = {
266
+ /* nav, primary, file, slideShow, insert, edit, findReplace, design, draw */
267
+ };
268
+ const ribbon = createRibbon(document, t, handlers);
269
+ host.appendChild(ribbon.el);
270
+
271
+ // Draw the current slide with the same DOM renderer the bundled viewer uses.
272
+ const registry = createDefaultRegistry();
273
+ const stageEl = renderSlideStage({
274
+ doc: document,
275
+ slide: store.get().slides[store.get().currentSlide],
276
+ registry,
277
+ // ...canvasSize, scale, editable, selection, etc. (see `SlideStageOptions`)
278
+ });
279
+ canvasHost.appendChild(stageEl);
280
+
281
+ // Re-render on every store change.
282
+ store.subscribe((state) => {
283
+ ribbon.update({ current: state.currentSlide, total: state.slides.length, zoomPercent: 100 });
284
+ /* re-render the stage, drive ribbon.setEditState/updateSelection/etc. */
285
+ });
286
+ ```
287
+
288
+ Be aware of what this buys you and what it doesn't:
289
+
290
+ - `renderSlideStage`, `createElementRendererRegistry` / `createDefaultRegistry`,
291
+ and `createRibbon` are pure, callback-driven building blocks with no hidden
292
+ coupling to `PptxViewer`; they are safe to use standalone.
293
+ - `createStore` / `createInitialViewerState` give you the same reactive
294
+ container and `ViewerState` shape `createPptxViewer` uses, so you can seed
295
+ state and pass slices of it into `renderSlideStage`.
296
+ - `RibbonHandlers` (the `edit` and `findReplace` groups especially, typed by
297
+ the exported `EditActions` / `FindReplaceActions` interfaces) is a large
298
+ surface: insert/format/arrange/clipboard/history/animation/transition
299
+ actions, comments, sections, and more. The built-in implementations of
300
+ these (`createEditorController`, `createEditActions`, `RenderController`,
301
+ `LoadingController`, ...) are **not** exported: they're wired directly
302
+ into `PptxViewer`'s own mount lifecycle (`getChrome`, `getHandler`, history,
303
+ autosave) and aren't decomposable into standalone pieces without a larger
304
+ refactor. Building a fully-featured custom editor chrome today means
305
+ implementing `RibbonHandlers` yourself against your own store and history,
306
+ not reusing the bundled editor logic; `createPptxViewer` remains the
307
+ supported path for a complete, batteries-included editor.
308
+
175
309
  ## License
176
310
 
177
311
  Apache-2.0. See `LICENSE` and `NOTICE`.