pptx-vanilla-viewer 3.80.0 → 4.1.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 CHANGED
@@ -1,21 +1,15 @@
1
1
  # pptx-vanilla-viewer
2
2
 
3
+ Open, edit, present and save PowerPoint (`.pptx`) files in any web page with one function call. No framework, no server, no conversion step, no PowerPoint install.
4
+
3
5
  [![npm version](https://img.shields.io/npm/v/pptx-vanilla-viewer.svg)](https://www.npmjs.com/package/pptx-vanilla-viewer)
4
6
  [![license](https://img.shields.io/npm/l/pptx-vanilla-viewer.svg)](https://github.com/ChristopherVR/ooxml/blob/main/viewers/pptx/LICENSE)
5
7
 
6
- Show, edit, and present Microsoft PowerPoint (`.pptx`) files directly in the
7
- browser with **zero framework**: no React, Vue, Angular, or Svelte required, no
8
- server, no conversion step, no PowerPoint install. Call one factory function,
9
- `createPptxViewer(container, options)`, and slides render as real HTML and
10
- CSS.
11
-
12
- ![Editing, undoing, and rendering a deck with the zero-framework Vanilla JavaScript demo](https://raw.githubusercontent.com/ChristopherVR/ooxml/main/viewers/pptx/.github/assets/packages/vanilla-demo.webp)
13
-
14
- The rendering is done by the framework-agnostic [`pptx-viewer-core`](https://www.npmjs.com/package/pptx-viewer-core) engine, which turns a `.pptx` file into a structured slide model. This package is the plain-DOM layer that draws that model on screen, and the engine is **bundled in**, so you install just one package.
8
+ [Live demo](https://christophervr.github.io/ooxml/pptx/demo-vanilla/) · [Docs](https://christophervr.github.io/ooxml/pptx/vanilla/) · [Changelog](https://github.com/ChristopherVR/ooxml/blob/main/viewers/pptx/packages/vanilla/CHANGELOG.md) · [Report a bug](https://github.com/ChristopherVR/ooxml/issues)
15
9
 
16
- <samp>**[▶️ Try the live demo](https://christophervr.github.io/ooxml/pptx/demo-vanilla/)** · **[📦 npm](https://www.npmjs.com/package/pptx-vanilla-viewer)** · **[📖 Full docs](https://christophervr.github.io/ooxml/pptx/vanilla/)** · **[🧩 Core SDK](https://www.npmjs.com/package/pptx-viewer-core)**</samp>
10
+ ![Editing, undoing and rendering a deck with the zero-framework demo](https://raw.githubusercontent.com/ChristopherVR/ooxml/main/viewers/pptx/.github/assets/packages/vanilla-demo.webp)
17
11
 
18
- Part of [ooxml](https://github.com/ChristopherVR/ooxml#readme): [Office](https://github.com/ChristopherVR/ooxml#ooxml-office-the-whole-suite-in-one-app) &middot; [Word](https://github.com/ChristopherVR/ooxml/tree/main/viewers/docx#readme) &middot; [Excel](https://github.com/ChristopherVR/ooxml/tree/main/viewers/xlsx#readme) &middot; **[PowerPoint](https://github.com/ChristopherVR/ooxml/tree/main/viewers/pptx#readme)** &middot; [Visio](https://github.com/ChristopherVR/ooxml/tree/main/viewers/visio#readme) &middot; [OpenTeams](https://github.com/ChristopherVR/ooxml/tree/main/viewers/teams#readme) &middot; [Core](https://github.com/ChristopherVR/ooxml/tree/main/src/core#readme)
12
+ Slides are drawn as HTML, CSS and SVG, not as a canvas bitmap, so text stays sharp at any zoom, can be selected and is read by screen readers. The [`pptx-viewer-core`](https://www.npmjs.com/package/pptx-viewer-core) engine that parses and writes the file is bundled in.
19
13
 
20
14
  ## Install
21
15
 
@@ -23,394 +17,113 @@ Part of [ooxml](https://github.com/ChristopherVR/ooxml#readme): [Office](https:/
23
17
  npm install pptx-vanilla-viewer
24
18
  ```
25
19
 
26
- Install `three` only when you enable a 3D SmartArt or 3D chart option. The viewer falls back to
27
- SVG when it is absent. Install `yjs` with `y-websocket` or `y-webrtc` only for collaboration.
20
+ There are no required peer dependencies. Optional extras:
28
21
 
29
- ## Usage
22
+ | For | Add |
23
+ | ------------------------------------ | -------------------------------------------------------------- |
24
+ | Real-time collaboration | `yjs` (`y-websocket` and `y-webrtc` are optional dependencies) |
25
+ | 3D models, 3D SmartArt and 3D charts | `three` |
26
+ | The AI assistant panel | `ai` |
30
27
 
31
- For a copy-paste Vite project, including the `index.html`, `src/main.js`, and `public/` file
32
- layout, see [the Vanilla Getting Started guide](https://christophervr.github.io/ooxml/pptx/vanilla/getting-started/).
33
- Place a local deck in `public/` and reference it with a root URL such as `/presentation.pptx`.
34
- The viewer opens a successfully loaded `source` automatically; `onLoad` is for your application
35
- code and does not need to click internal viewer controls.
28
+ Without them, those features stay off and everything else works.
29
+
30
+ ## Quick start
36
31
 
37
32
  ```ts
38
33
  import { createPptxViewer } from 'pptx-vanilla-viewer';
39
34
 
40
35
  const viewer = createPptxViewer(document.getElementById('host')!, {
41
- source: '/decks/quarterly.pptx', // URL, ArrayBuffer, Uint8Array, Blob, or File
42
- theme: { colors: { primary: '#e34f26' } },
43
- locale: 'en',
44
- initialSlide: 0,
45
- editable: true, // select, drag, resize, rotate, inline text, undo/redo, save
46
- showToolbar: true,
47
- showThumbnails: true,
36
+ source: '/decks/quarterly.pptx', // a URL, ArrayBuffer, Uint8Array, Blob or File
37
+ editable: true,
48
38
  onLoad: ({ slideCount }) => console.log(`${slideCount} slides`),
49
- onSlideChange: (index) => console.log('slide', index + 1),
50
- onError: (message) => console.error(message),
51
39
  onDirtyChange: (dirty) => console.log('unsaved edits:', dirty),
52
40
  });
53
41
 
54
- // Navigation / zoom
55
- viewer.next();
56
- viewer.prev();
57
- viewer.goToSlide(3);
58
- viewer.setZoom(1.5); // or 'fit'
59
- viewer.zoomToFit();
60
-
61
- // Presentation mode (real Fullscreen API; Esc exits)
62
- await viewer.enterPresentation();
63
-
64
- // Editing (click/drag/resize/rotate/double-click-to-edit-text happen via the
65
- // DOM; these are the programmatic entry points)
66
- viewer.undo();
67
- viewer.redo();
68
- viewer.deleteSelected();
69
- const bytes = await viewer.save(); // serialise the edited deck to .pptx bytes
70
- await viewer.downloadPptx('quarterly-edited.pptx'); // save() + trigger a download
71
-
72
- // Load a different file later
73
- await viewer.loadFile(fileInput.files![0]);
74
- await viewer.loadUrl('/other-deck.pptx');
75
-
76
- // Escape hatch: the live pptx-viewer-core handler (save, markdown, archive access)
77
- const handler = viewer.getHandler();
78
-
79
- // Tear down DOM, listeners, Blob URLs, and the core handler
80
- viewer.destroy();
81
- ```
82
-
83
- The container should have a size (the viewer fills it: `width/height: 100%`).
84
-
85
- ### Viewport fit options
86
-
87
- ```ts
88
- const viewer = createPptxViewer(container, {
89
- source,
90
- fitPadding: 0,
91
- maxFitScale: null,
92
- });
93
- ```
94
-
95
- `fitPadding` is a per-side CSS-pixel number or `{ horizontal, vertical }`;
96
- `maxFitScale` is a positive fit-factor ceiling or `null` for unlimited enlargement.
97
- Omission preserves the existing 16 px fit allowance on each side, unlimited
98
- enlargement, and mobile CSS padding. Explicit padding also sets the viewport's
99
- physical CSS padding. Configure these options when creating the viewer; they
100
- do not change document geometry, user zoom, or presentation-mode fitting.
101
- See the [cross-binding defaults](../../docs/guide/viewport-fit.md).
102
-
103
- ## Options
104
-
105
- All options are optional except the container element itself. Beyond the ones
106
- shown above:
107
-
108
- | Option | Type | Default | Description |
109
- | -------------------------------------------------------------------------- | ----------------------------------------------------- | ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
110
- | `source` | `string \| ArrayBuffer \| Uint8Array \| Blob \| File` | - | The presentation to open (URL or bytes). Omit to start empty and call `loadFile`/`loadUrl`. |
111
- | `fonts` | `ViewerFontSource[]` | - | Licensed font sources supplied by the host application. |
112
- | `theme` | `ViewerTheme` | - | Chrome theme (colors, radius, CSS vars). |
113
- | `fileName` | `string` | - | Display name shown in the title bar. |
114
- | `locale` / `messages` | `string` / `TranslationMessages` | `'en'` | UI locale and per-locale `pptx.*` dictionaries (see [i18n](#i18n)). |
115
- | `initialSlide` | `number` | `0` | Zero-based slide shown after load. |
116
- | `editable` | `boolean` | `false` | Enable editing (see [Editing](#editing)). |
117
- | `showToolbar` | `boolean` | `true` | Whole ribbon/title-bar/status-bar chrome. |
118
- | `showThumbnails` | `boolean` | `true` | Thumbnail sidebar. |
119
- | `showCompatibilityToasts` | `boolean` | `true` | Compatibility warning toast stack; `false` hides it, warnings are still collected. |
120
- | `showFormatToolbar` | `boolean` | `true` | Editing format toolbar row (visible only while editing). |
121
- | `showInspector` | `boolean` | `true` | Property inspector panel (visible only while editing). |
122
- | `hiddenActions` | `ToolbarActionId[]` | - | Hide individual buttons/tabs (see [Toolbar customization](#toolbar-customization)). |
123
- | `ribbonAddIns` | `RibbonAddInTab[]` | n/a | Ribbon tabs the host adds after Help; a command runs its `run` callback and raises `office-ribbon-add-in` (see the customization guide) |
124
- | `customization` | `ViewerCustomization` | - | Hide, lock or remap any part of the UI (ribbon tabs/buttons, File > Options pages/sections/settings, File tab, context menus, shortcuts, panels, AI/collaboration, dialogs); the same helpers (`hideRibbonTab`, `lockSetting`, ...) are on the viewer instance. See the [UI Customization guide](https://christophervr.github.io/ooxml/pptx/guide/customization). |
125
- | `registry` | `ElementRendererRegistry` | - | Custom element-renderer registry (see [Element coverage](#element-coverage)). |
126
- | `smartArt3D` | `boolean` | `false` | Opt-in Three.js 3D SmartArt renderer (optional `three` peer, lazily imported). |
127
- | `surfaceChart3D`, `barChart3D`, `lineChart3D`, `areaChart3D`, `pieChart3D` | `boolean` | `false` | Independently opt in to interactive Three.js renderers for the matching 3D chart kinds; each falls back to SVG when WebGL is unavailable. |
128
- | `ai` | `PptxAiAssistant \| PptxAiConfig` | - | Optional AI assistant: a handle from `createAiAssistant` (`pptx-vanilla-viewer/ai`), or a plain config. The SDK peer loads only when its panel is opened. See the [AI assistant guide](https://christophervr.github.io/ooxml/pptx/guide/ai-assistant#ai-entry). |
129
- | `autosave` | `boolean` | `true` | Crash-recovery autosave to IndexedDB, written while there are unsaved edits. |
130
- | `autosaveIntervalMs` | `number` | File > Options cadence | Interval between recovery snapshots while there are unsaved edits. |
131
- | `autosaveFilePath` | `string` | `'presentation.pptx'` | IndexedDB recovery key for autosave snapshots. |
132
- | `collaboration` | `CollaborationConfig` | - | Start a Yjs collaboration session immediately (y-websocket or serverless y-webrtc). |
133
- | `shareDefaults` | `{ roomId?, userName?, serverUrl? }` | - | Prefilled values for the Share/Broadcast dialogs. |
134
- | `availableThemes` / `availableLocales` | catalog entries | - | Choices offered by File > Options. |
135
- | `onThemeChange` / `onLocaleChange` | `(key: string) => void` | - | Host hooks for the File > Options pickers (host owns persistence when supplied). |
136
- | `accountAuth` | `AccountAuthConfig` | - | Optional sign-in hook point for File > Account. |
137
-
138
- Callbacks: `onLoad`, `onError`, `onSlideChange`, `onZoomChange`,
139
- `onPresentationChange`, `onChange` (any document mutation), `onDirtyChange`,
140
- `onSelectionChange`, `onAutosaveStatus`, `onAutosaveRecovery` (offers a prior
141
- session's recovery snapshot), `onToggleAutosave`, and `onCollaborationStatus`.
142
-
143
- ## Instance API
144
-
145
- The handle returned by `createPptxViewer` implements the shared
146
- `PowerPointViewerAPI` (the same imperative contract as the React/Vue/Angular/
147
- Svelte bindings: `getContent`, `goTo`, `undo`/`redo`, zoom and mode getters/
148
- setters, `getSlides`/`getSlide`/`getActiveSlide`, `addSlide`/`deleteSlides`/
149
- `duplicateSlides`/`moveSlide`/`toggleHideSlides`, `getElements`/
150
- `getElementById`/`addElement`/`updateElement`/`deleteElements`/`duplicateElement`, and the
151
- selection methods).
152
-
153
- See [element insertion](https://christophervr.github.io/ooxml/pptx/vanilla/api#add-element)
154
- for the `addElement` contract and a core-factory example.
155
-
156
- Additional vanilla-specific methods:
157
-
158
- - **Loading**: `loadFile(bytesOrBlob)`, `loadUrl(url)`.
159
- - **Navigation / zoom**: `next()`, `prev()`, `goToSlide(index)`,
160
- `getSlideCount()`, `getCurrentSlide()`, `getZoom()`, `setZoom(scale)`,
161
- `zoomIn()`, `zoomOut()`, `zoomToFit()`.
162
- - **Presentation**: `enterPresentation()`, `exitPresentation()`.
163
- - **Editing**: `setEditable(flag)`, `setEditTemplateMode(flag)`, `undo()`,
164
- `redo()`, `canUndo()`, `canRedo()`, `deleteSelected()`,
165
- `getSelectedElementId()`.
166
- - **Saving**: `save(format?)`, `downloadPptx(fileName?)`,
167
- `downloadAs(format, fileName?)`.
168
- - **Export / print**: `exportSlidePng(index?)`, `copySlideAsImage(index?)`,
169
- `exportPdf(options?)`, `exportGif(options?)`, `exportVideo(options?)`,
170
- `print(options?)` (returns `false` when the popup was blocked; call from a
171
- click handler).
172
- - **Collaboration**: `startCollaboration(config)`, `stopCollaboration()`,
173
- `getCollaborationStatus()`.
174
- - **Autosave**: `autosaveNow()`, `setAutosaveEnabled(flag)`,
175
- `isAutosaveEnabled()`.
176
- - **Chrome / extension**: `setTheme(theme?)`, `setLocale(locale)`,
177
- `getRegistry()`, `getHandler()` (the live `pptx-viewer-core` handler),
178
- `destroy()`.
179
-
180
- ## Keyboard
181
-
182
- Navigation: arrow keys / PageUp / PageDown / Space, Home/End jump to the
183
- first or last slide, Esc exits presentation mode. The viewer root is
184
- focusable (`tabindex="0"`).
185
-
186
- When `editable` is on and an element is selected: Ctrl/Cmd+Z undoes,
187
- Ctrl/Cmd+Shift+Z (or Ctrl+Y) redoes, Delete/Backspace deletes the selection,
188
- Ctrl/Cmd+D duplicates it, arrow keys nudge it by 1px (Shift+arrow for 10px),
189
- and Escape deselects. Double-click a text-capable element to edit its text
190
- inline.
191
-
192
- ## Styling and theming
193
-
194
- Styles are injected once per document as a `<style id="pptx-vanilla-viewer-styles">`
195
- tag, scoped under the `.pptxv` root class. CSP-strict hosts can import the
196
- packaged static stylesheet with `import 'pptx-vanilla-viewer/styles.css'`.
197
- `getViewerCss()` remains available when the host needs the stylesheet text.
198
-
199
- All chrome colors come from the shared `--pptx-*` CSS custom properties. Pass
200
- a `ViewerTheme` (`theme` option or `setTheme`) to override them; the
201
- `vermilionLightTheme` / `vermilionDarkTheme` presets are re-exported.
202
-
203
- ## Toolbar customization
204
-
205
- `showToolbar` hides the whole ribbon/title-bar/status-bar chrome; to hide
206
- individual buttons or ribbon tabs instead, pass `hiddenActions`:
207
-
208
- ```ts
209
- const viewer = createPptxViewer(document.getElementById('host')!, {
210
- source: '/decks/quarterly.pptx',
211
- editable: true,
212
- // Hide Share, the Broadcast action, and the whole Insert ribbon tab, while
213
- // keeping every other button and tab visible.
214
- hiddenActions: ['share', 'broadcast', 'insert'],
215
- });
216
- ```
217
-
218
- Each id in `hiddenActions` hides a single quick-access button (`'share'`,
219
- `'broadcast'`, `'export'`, `'undo'`, `'redo'`, `'notes'`, `'fullscreen'`), a
220
- whole control cluster as a unit (`'zoom'` covers zoom in/out/fit, `'navigation'`
221
- covers the presentation slide-show's prev/next controls), or a ribbon tab
222
- (`'file'`, `'home'`, `'insert'`, `'draw'`, `'design'`, `'transitions'`,
223
- `'animations'`, `'slideShow'`, `'record'`, `'review'`, `'view'`, `'help'`).
224
- `'record'` hides both the quick-access Record control and the Record ribbon
225
- tab, since they surface the same feature. Hidden actions are never built (not
226
- just visually hidden), on desktop and mobile chrome alike. Omit the option (or
227
- leave it `undefined`) to keep today's fully-visible default.
228
-
229
- ## Editing
230
-
231
- Pass `editable: true` (or call `setEditable(true)` at runtime) to turn on:
232
-
233
- - Click to select an element, click empty space to deselect.
234
- - Drag to move, with snap-to-sibling-edge guides.
235
- - Resize via 8 handles (Shift locks aspect ratio on the corner handles) and
236
- rotate via a rotate handle (Shift snaps to angle increments).
237
- - Double-click a text-capable element for inline text editing.
238
- - Undo/redo (100-step history), delete, and duplicate (`Ctrl/Cmd+D`).
239
- - Insert, format, z-order, group, and ungroup elements from the ribbon.
240
- - Edit inherited master/layout elements by enabling template editing in the
241
- View ribbon or calling `setEditTemplateMode(true)`.
242
- - Rich speaker notes, accessibility checks, autosave, and collaboration.
243
- - The toolbar's Save button (shown only when `editable`), which calls
244
- `downloadPptx()` to serialise and download the edited `.pptx`.
245
-
246
- Use `viewer.getSelectedElementId()` and the `onSelectionChange` /
247
- `onDirtyChange` callbacks to build your own chrome around the selection
248
- state.
249
-
250
- ## i18n
251
-
252
- All UI strings go through the shared `pptx.*` dictionary (English built in).
253
- Provide `messages: { de: { 'pptx.presenter.nextSlide': 'Nächste Folie', ... } }`
254
- plus `locale: 'de'` (or call `setLocale`) for other languages; missing keys
255
- fall back to English, then to a humanised label.
256
-
257
- ## Element coverage
258
-
259
- Dedicated renderers ship for every element type: text, shape, image/picture,
260
- group, connector, table, chart, SmartArt (2D and opt-in 3D), media
261
- (video/audio), ink, OLE, content parts, zoom links, and 3D models. Renderers
262
- are dispatched through an open registry, so any of them can be overridden
263
- without forking:
264
-
265
- ```ts
266
- import { createPptxViewer, type ElementRenderer } from 'pptx-vanilla-viewer';
267
-
268
- const renderTable: ElementRenderer = (element, zIndex, context) => {
269
- /* build and return a DOM node */
270
- };
42
+ const bytes = await viewer.save(); // a valid .pptx
43
+ await viewer.downloadPptx('quarterly-edited.pptx');
271
44
 
272
- const viewer = createPptxViewer(host, { source });
273
- viewer.getRegistry().register('table', renderTable);
45
+ viewer.destroy(); // removes the DOM, listeners, blob URLs and the engine handler
274
46
  ```
275
47
 
276
- See `src/viewer/render/elements/README.md` for the full renderer contract.
48
+ The viewer fills its container, so give the container a size. Styles are injected once per document; a page with a strict Content Security Policy imports `pptx-vanilla-viewer/styles.css` instead (`getViewerCss()` returns the same text). For a copy-paste Vite project, see [getting started](https://christophervr.github.io/ooxml/pptx/vanilla/getting-started).
277
49
 
278
- ## Building your own chrome
50
+ ## What you get
279
51
 
280
- `createPptxViewer` mounts the whole viewer (ribbon, canvas, inspector,
281
- controllers) as one unit. If you want to build custom chrome around the same
282
- primitives instead, the ribbon builder and the canvas renderer are both
283
- importable independently:
52
+ - **Viewing**: text, all 187 preset shapes, pictures, tables, charts, SmartArt, connectors, audio, video, ink, OLE objects and 3D models, with themes, masters and layouts resolved.
53
+ - **Editing**: a PowerPoint-style ribbon, inspector and on-canvas handles; inline text, tables, chart data, SmartArt, masters and layouts; full undo and redo.
54
+ - **Presenting**: transitions (including Morph), animations and motion paths, presenter view with notes and timer, rehearse timings, pen, highlighter and laser.
55
+ - **Exporting**: PDF, PNG, GIF, video and JSON, slides copied as images, printed handouts and notes pages, and Save As `.pptx`, `.ppsx`, `.pptm` or legacy `.ppt`.
56
+ - **Working together**: real-time co-editing and Broadcast over Yjs, through your server or peer to peer, with presence, cursors and threaded comments.
57
+ - **Assistant**: an optional AI panel whose edits follow a write policy you choose (apply, stage or approve).
58
+ - **Keyboard and screen readers**: F6 between regions, Tab through slide objects, Enter to edit text, and names that match the visible captions.
59
+ - **Seven UI languages**: English, French, Spanish, German, Simplified Chinese, Japanese and Korean.
284
60
 
285
- ```ts
286
- import {
287
- createRibbon,
288
- createStore,
289
- createInitialViewerState,
290
- renderSlideStage,
291
- createDefaultRegistry,
292
- type RibbonHandlers,
293
- type Store,
294
- type ViewerState,
295
- } from 'pptx-vanilla-viewer';
296
-
297
- // Your own reactive container, seeded with the same shape `createPptxViewer`
298
- // uses internally.
299
- const store: Store<ViewerState> = createStore(createInitialViewerState());
300
-
301
- // `createRibbon` is callback-driven: it never reaches into a `PptxViewer`
302
- // instance or a store directly, so it renders against whatever `RibbonHandlers`
303
- // you hand it.
304
- const handlers: RibbonHandlers = {
305
- /* nav, primary, file, slideShow, insert, edit, findReplace, design, draw */
306
- };
307
- const ribbon = createRibbon(document, t, handlers);
308
- host.appendChild(ribbon.el);
309
-
310
- // Draw the current slide with the same DOM renderer the bundled viewer uses.
311
- const registry = createDefaultRegistry();
312
- const stageEl = renderSlideStage({
313
- doc: document,
314
- slide: store.get().slides[store.get().currentSlide],
315
- registry,
316
- // ...canvasSize, scale, editable, selection, etc. (see `SlideStageOptions`)
317
- });
318
- canvasHost.appendChild(stageEl);
61
+ Some effects are approximated or not yet supported; the [limitations page](https://christophervr.github.io/ooxml/pptx/guide/limitations) lists them, and a deck that uses one reports it as a load warning.
319
62
 
320
- // Re-render on every store change.
321
- store.subscribe((state) => {
322
- ribbon.update({ current: state.currentSlide, total: state.slides.length, zoomPercent: 100 });
323
- /* re-render the stage, drive ribbon.setEditState/updateSelection/etc. */
324
- });
325
- ```
63
+ ## Using it without a framework
326
64
 
327
- Be aware of what this buys you and what it doesn't:
328
-
329
- - `renderSlideStage`, `createElementRendererRegistry` / `createDefaultRegistry`,
330
- and `createRibbon` are pure, callback-driven building blocks with no hidden
331
- coupling to `PptxViewer`; they are safe to use standalone.
332
- - `createStore` / `createInitialViewerState` give you the same reactive
333
- container and `ViewerState` shape `createPptxViewer` uses, so you can seed
334
- state and pass slices of it into `renderSlideStage`.
335
- - `RibbonHandlers` (the `edit` and `findReplace` groups especially, typed by
336
- the exported `EditActions` / `FindReplaceActions` interfaces) is a large
337
- surface: insert/format/arrange/clipboard/history/animation/transition
338
- actions, comments, sections, and more. The built-in implementations of
339
- these (`createEditorController`, `createEditActions`, `RenderController`,
340
- `LoadingController`, ...) are **not** exported: they're wired directly
341
- into `PptxViewer`'s own mount lifecycle (`getChrome`, `getHandler`, history,
342
- autosave) and aren't decomposable into standalone pieces without a larger
343
- refactor. Building a fully-featured custom editor chrome today means
344
- implementing `RibbonHandlers` yourself against your own store and history,
345
- not reusing the bundled editor logic; `createPptxViewer` remains the
346
- supported path for a complete, batteries-included editor.
347
-
348
- ### Internal building blocks & slide-transition helpers
349
-
350
- Most of this package's cross-framework logic (colour/geometry/connector/animation/chart math,
351
- slide transitions, and more) lives in `pptx-viewer-shared`, a private facade over the shared renderer in `ooxml-ui/pptx`, that is **never
352
- published to npm**. The framework-neutral slide-transition resolver/keyframes
353
- (`resolveSlideTransition`, `resolveTransitionDurationMs`, `SLIDE_TRANSITION_KEYFRAMES`) and
354
- `playTransitionOverlay` (the DOM-level driver behind presentation mode's slide-change animation)
355
- are re-exported from the `pptx-vanilla-viewer/internals` subpath, not covered by semver, so you
356
- never need `pptx-viewer-shared` yourself:
65
+ **The instance.** `createPptxViewer` returns a handle with the shared slide and element API (`getContent`, `getSlides`, `addSlide`, `addElement`, `updateElement`, undo and redo, zoom, mode and selection) plus loading (`loadFile`, `loadUrl`), navigation (`next`, `prev`, `goToSlide`, `zoomToFit`), presenting (`enterPresentation`), saving and export (`save`, `downloadAs`, `exportPdf`, `exportSlidePng`, `print`), collaboration, autosave, `setTheme`, `setLocale` and `getHandler()` for the live engine. Callbacks are options (`onLoad`, `onError`, `onSlideChange`, `onChange`, `onSelectionChange` and more). See [the API](https://christophervr.github.io/ooxml/pptx/vanilla/api) and [options](https://christophervr.github.io/ooxml/pptx/vanilla/options).
357
66
 
358
- ```ts
359
- import { resolveSlideTransition, playTransitionOverlay } from 'pptx-vanilla-viewer/internals';
360
- ```
67
+ **Custom renderers.** Elements are drawn through an open registry, so you can replace one kind without forking: `viewer.getRegistry().register('table', renderTable)`. See [renderers](https://christophervr.github.io/ooxml/pptx/vanilla/renderers).
361
68
 
362
- ## Reference translations
69
+ **Your own shell.** `createViewerBuildingBlocks` runs the full viewer engine behind a canvas, a compact toolbar and the slide rail that you mount where you like (`mountCanvas`, `mountToolbar`, `mountSlidesPane`), and lets you answer picker and dialog requests with your own UI. `createExternalContentBar`, `createSlidesPane`, `renderSlideThumbnail` and `createRibbon` are exported for deeper custom chrome. See [building blocks](https://christophervr.github.io/ooxml/pptx/vanilla/building-blocks).
363
70
 
364
- Optional French, Spanish, German, and Simplified Chinese dictionaries ship with
365
- this package. Import only the language you need:
71
+ **Translations.** English is built in. Pass `messages` (one `pptx.*` dictionary per locale) with `locale`, or call `setLocale`; missing keys fall back to English. Dictionaries for the other languages are at `pptx-vanilla-viewer/i18n/fr`, `/es`, `/de`, `/zh-CN`, `/ja` and `/ko`. See [localization](https://christophervr.github.io/ooxml/pptx/guide/localization).
366
72
 
367
- ```ts
368
- import { translationsZhCN } from 'pptx-vanilla-viewer/i18n/zh-CN';
369
- ```
73
+ **AI assistant.** Create one assistant with `createAiAssistant` from `pptx-vanilla-viewer/ai` and pass it as `ai`. Its panel and the AI SDK load only when the user opens it. See the [assistant guide](https://christophervr.github.io/ooxml/pptx/guide/ai-assistant).
370
74
 
371
- The other subpaths are `i18n/fr` (`translationsFr`), `i18n/es`
372
- (`translationsEs`), and `i18n/de` (`translationsDe`). See the
373
- [localization guide](https://christophervr.github.io/ooxml/pptx/guide/localization)
374
- for registration and runtime switching. Existing English imports are unchanged.
75
+ ## Configuration
375
76
 
376
- ## Custom DOM stage cleanup
77
+ The most used options; the [options reference](https://christophervr.github.io/ooxml/pptx/vanilla/options) has all of them, and every binding takes the same set.
377
78
 
378
- The cleanup helpers belong to the shared DOM renderer:
79
+ | Option | What it does |
80
+ | ------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------- |
81
+ | `editable`, `readOnly` | Turn editing on, or force the deck read-only. |
82
+ | `initialSlide`, `showToolbar`, `showThumbnails` | Starting slide and which chrome to show. |
83
+ | `locale`, `messages` | The UI language and your dictionaries. |
84
+ | `theme`, `defaultThemeKey`, `availableThemes` | Colours and radius as `--pptx-*` tokens, and the File > Options appearance choices. |
85
+ | `customization`, `hiddenActions`, `ribbonAddIns` | Hide, lock or remap ribbon tabs, commands, options, menus, shortcuts and panels; add your own tabs. |
86
+ | `fonts`, `googleFonts` | Supply licensed fonts, and control or redirect web font downloads. |
87
+ | `allowExternalContent` | Download a deck's linked pictures and media without asking (`true`) or block them silently (`false`). |
88
+ | `limits` | Bound the work a load may do, for decks you do not trust. |
89
+ | `collaboration`, `shareDefaults` | Join or seed a real-time session. |
90
+ | `storage`, `fileProviders`, `autosave` | Save to your own storage or OneDrive, and control recovery autosave. |
91
+ | `registry` | Your own element renderers. |
92
+ | `ai` | The optional assistant. |
93
+ | `fitPadding`, `maxFitScale` | How the slide fits its viewport ([viewport fit](https://christophervr.github.io/ooxml/pptx/guide/viewport-fit)). |
379
94
 
380
- ```ts
381
- import { disposePptxRenderStage, releasePptxRenderCaches } from 'ooxml-ui/pptx/dom';
382
- ```
95
+ OneDrive needs a Microsoft sign-in your host provides; see the [OneDrive guide](https://christophervr.github.io/ooxml/pptx/guide/onedrive). It stores files and does not provide Office co-authoring.
383
96
 
384
- Before a custom host replaces or removes a `renderSlideStage` result, call
385
- `disposePptxRenderStage(stage)` to release chart subscriptions, then remove the
386
- node. It also accepts a host containing multiple stages. The built-in viewer
387
- performs this cleanup for its canvas, thumbnails, reading/presenter previews,
388
- layout/template galleries and export stages.
97
+ ## Supported environments
389
98
 
390
- A host that has closed all viewers sharing the renderer module may call
391
- `releasePptxRenderCaches()` (from `ooxml-ui/pptx/dom`) to release retained image
392
- memoisation. This is global, so wait until other live viewers no longer need
393
- pending picture samples. Stage disposal itself only affects its own subtree.
99
+ - Browsers: the last two major versions of Chrome, Edge, Firefox and Safari, and Safari 16.4 at least ([browser support](https://github.com/ChristopherVR/ooxml/blob/main/docs/browser-support.md)).
100
+ - Any bundler that resolves ES modules, or none: the package has no framework dependency.
101
+ - Node.js 22.3 or newer to install, build and test.
394
102
 
395
103
  ## Privacy and network use
396
104
 
397
105
  The viewer renders and saves decks in the browser and never uploads them. It contacts other servers only in these cases:
398
106
 
399
- - **Fonts that are neither installed nor embedded.** When a deck uses such a font and Google Fonts serves it (or a metric-compatible clone, such as Carlito for Calibri), the viewer downloads it from `fonts.googleapis.com` and `fonts.gstatic.com`, so the reader's IP address and the needed family names reach Google. This is on by default, as in PowerPoint, which downloads its cloud fonts. Turn it off with `googleFonts: false`, or send the same requests to a self-hosted mirror with `googleFonts: { baseUrl: 'https://fonts.example.com/css2' }`. Readers can also turn it off in File > Options > Trust Center ("Download fonts that are not installed or embedded (Google Fonts)"); a host value locks that toggle. With downloads off, text uses installed, embedded or substitute fonts and line breaks can differ from PowerPoint. If the download is slow, the deck waits up to 8 seconds, and it opens at once when the font server cannot be reached (offline use works). See [font loading](https://github.com/ChristopherVR/ooxml/blob/main/docs/font-loading.md).
400
- - **Linked pictures and media** in a deck are fetched from their URLs while the Trust Center option "Allow external content" is on (the default). `allowExternalContent: false` blocks them.
401
- - **Share and Broadcast**, only when started: updates go to the server you configure; with no server, peers meet through y-webrtc's public signaling server and public STUN servers.
107
+ - **Fonts that are neither installed nor embedded.** When a deck uses such a font and Google Fonts serves it (or a metric-compatible clone, such as Carlito for Calibri), the viewer downloads it from `fonts.googleapis.com` and `fonts.gstatic.com`, so the reader's IP address and the needed family names reach Google. This is on by default, as PowerPoint downloads its cloud fonts. Turn it off with `googleFonts: false`, or send the same requests to your own mirror with `googleFonts: { baseUrl: 'https://fonts.example.com/css2' }`. Readers can turn it off in File > Options > Trust Center ("Download fonts that are not installed or embedded (Google Fonts)"); a host value locks that toggle. With downloads off, text uses installed, embedded or substitute fonts, so line breaks can differ from PowerPoint. A slow download holds the deck for up to 8 seconds, and the deck opens at once when the font server cannot be reached, so offline use works. See [font loading](https://github.com/ChristopherVR/ooxml/blob/main/docs/font-loading.md).
108
+ - **Linked pictures and media** are not fetched when a deck opens, as in PowerPoint. A security bar ("References to external pictures and other media have been blocked") offers **Enable Content**, which draws them without reloading: edits and undo history stay, and in a shared session each participant chooses for themselves. The choice lasts until another presentation opens. The Trust Center option "Allow external content" (off by default) fetches them without asking; `allowExternalContent: true` does the same and `false` blocks them without the bar, each locking that option.
109
+ - **Hyperlinks** open only when the reader clicks them, always in a new tab with `noopener` and `noreferrer`, so the linked site receives no referrer and cannot script the viewer's page, whatever frame the deck names. `file:` and `ftp:` links stay in the deck but never open. Relative links (no scheme, such as `notes.html`) open, against the host page's address, only after the host calls `setOpenRelativeHyperlinks(true)` from `ooxml-ui/pptx`.
110
+ - **Share and Broadcast**, only when started. Updates go to the server you configure. With no server, peers meet through y-webrtc's public signaling server and public STUN servers; the signaling server sees a hash of the secret in the invitation link's `#key=` fragment (never the room name), the participants' IP addresses and encrypted signaling messages.
402
111
 
403
112
  Nothing collects analytics or telemetry. The full list, including what is kept in local storage, is in [PRIVACY.md](https://github.com/ChristopherVR/ooxml/blob/main/PRIVACY.md).
404
113
 
405
- ## License
114
+ ## Related packages
406
115
 
407
- Apache-2.0. See `LICENSE` and `NOTICE`.
116
+ | Package | Use it for |
117
+ | -------------------------------------------------------------------------- | -------------------------------------------------------------- |
118
+ | [`pptx-react-viewer`](https://www.npmjs.com/package/pptx-react-viewer) | The same viewer for React. |
119
+ | [`pptx-vue-viewer`](https://www.npmjs.com/package/pptx-vue-viewer) | The same viewer for Vue 3. |
120
+ | [`pptx-angular-viewer`](https://www.npmjs.com/package/pptx-angular-viewer) | The same viewer for Angular. |
121
+ | [`pptx-svelte-viewer`](https://www.npmjs.com/package/pptx-svelte-viewer) | The same viewer for Svelte 5. |
122
+ | [`pptx-viewer-core`](https://www.npmjs.com/package/pptx-viewer-core) | Reading, building and saving decks in Node or a worker, no UI. |
123
+ | [`pptx-viewer-mcp`](https://www.npmjs.com/package/pptx-viewer-mcp) | PowerPoint editing tools for AI agents, as an MCP server. |
408
124
 
409
- ## OneDrive integration
125
+ Part of [ooxml](https://github.com/ChristopherVR/ooxml#readme), which also has [Word](https://github.com/ChristopherVR/ooxml/tree/main/viewers/docx#readme), [Excel](https://github.com/ChristopherVR/ooxml/tree/main/viewers/xlsx#readme) and [Visio](https://github.com/ChristopherVR/ooxml/tree/main/viewers/visio#readme) viewers.
126
+
127
+ ## License
410
128
 
411
- Use the optional shared `ooxml-core/embedding/onedrive` connection with host-supplied Microsoft
412
- sign-in. See the [Office package and integration reference](https://github.com/ChristopherVR/ooxml/blob/main/docs/onedrive-integration.md#powerpoint-pptx)
413
- for this product's load/save API, native storage wiring, sharing permissions and conflict recovery.
414
- The [testing guide](https://github.com/ChristopherVR/ooxml/blob/main/docs/onedrive-testing.md)
415
- separates test-local transports from live Microsoft acceptance. No simulation service is shipped;
416
- OneDrive storage does not provide Microsoft Office coauthoring or automatic document merging.
129
+ [Apache-2.0](https://github.com/ChristopherVR/ooxml/blob/main/viewers/pptx/LICENSE). Keep the [NOTICE](https://github.com/ChristopherVR/ooxml/blob/main/viewers/pptx/NOTICE) file with redistributions.
@@ -0,0 +1 @@
1
+ import {a as a$1}from'./chunk-OZKSMNX3.js';import {a}from'./chunk-PWXGY3J7.js';import'./chunk-CNU4N4AY.js';import {createVanillaChat,deckIdFromBridge,createAiChatHistoryController,toRenderableParts,canAcceptAllProposals,toolCanvasTarget,focusTargetChips,isTwoTableFocus,mergeTablesDirective,describeToolActivity,summarizeToolArgs,toolLabel,humanizeDiffLine}from'ooxml-ui/pptx/ai';function D(o){let{doc:t,t:i,controller:n}=o,s=(0, a.createEl)(t,"div","pptxv-ai-focus"),h=(a$2,x,r)=>{let p=(0, a.createEl)(t,"button","pptxv-ai-focus-btn");return p.type="button",p.title=x,p.setAttribute("aria-label",x),p.appendChild(a$1(t,a$2)),p.addEventListener("click",r),p},u=()=>{s.replaceChildren();let a$2=n.getEffectiveTargets(),x=n.hasPicks(),r=n.isPinned(),p=n.isPicking(),C=(0, a.createEl)(t,"div","pptxv-ai-focus-row"),g=(0, a.createEl)(t,"span","pptxv-ai-focus-label");g.textContent=i("pptx.ai.focusScope"),C.appendChild(g);for(let v of focusTargetChips(a$2,o.getSlides())){let l=(0, a.createEl)(t,"span","pptxv-ai-focus-chip");(x||r)&&l.classList.add("is-strong"),l.title=v.title,l.textContent=v.label,C.appendChild(l);}if(r){let v=(0, a.createEl)(t,"span","pptxv-ai-focus-pinned");v.textContent=i("pptx.ai.pinnedFocus"),C.appendChild(v);}let b=(0, a.createEl)(t,"div","pptxv-ai-focus-actions"),d=isTwoTableFocus(a$2,o.getSlides());if(d){let v=(0, a.createEl)(t,"button","pptxv-ai-focus-merge");v.type="button",v.append(a$1(t,"git-merge"),t.createTextNode(i("pptx.ai.mergeSelectedTables"))),v.addEventListener("click",()=>o.onSendDirective(mergeTablesDirective(d.slideIndex,d.elementIdA,d.elementIdB))),b.appendChild(v);}let y=h("crosshair",i("pptx.ai.pickElement"),()=>p?n.stopPicking():n.startPicking());if(y.setAttribute("aria-pressed",String(p)),y.classList.toggle("is-active",p),b.appendChild(y),x?b.appendChild(h("close",i("pptx.ai.pickClear"),()=>n.clearPicks())):r?b.appendChild(h("pin-off",i("pptx.ai.clearFocus"),()=>n.clearPinnedFocus())):b.appendChild(h("pin",i("pptx.ai.pinFocus"),()=>n.pinFocus())),C.appendChild(b),s.appendChild(C),p){let v=(0, a.createEl)(t,"div","pptxv-ai-focus-pick"),l=a$1(t,"crosshair");l.classList.add("pptxv-ai-focus-pick-icon");let T=(0, a.createEl)(t,"span","pptxv-ai-focus-pick-hint");T.textContent=i("pptx.ai.pickElementHint");let P=(0, a.createEl)(t,"button","pptxv-ai-focus-pick-done");P.type="button",P.textContent=i("pptx.ai.pickDone"),P.addEventListener("click",()=>n.stopPicking()),v.append(l,T,P),s.appendChild(v);}},m=n.subscribe(u);return u(),{el:s,destroy(){m(),s.remove();}}}function w(o){let{doc:t,t:i}=o,n=(0, a.createEl)(t,"button","pptxv-ai-chats");n.type="button",n.append(a$1(t,"history"),t.createTextNode(i("pptx.ai.chats")));let s=(0, a.createEl)(t,"div","pptxv-ai-history");s.hidden=true;let h=(0, a.createEl)(t,"div","pptxv-ai-history-head"),u=(0, a.createEl)(t,"span","pptxv-ai-history-title");u.textContent=i("pptx.ai.historyTitle");let m=(0, a.createEl)(t,"button","pptxv-ai-history-new");m.type="button",m.append(a$1(t,"plus"),t.createTextNode(i("pptx.ai.newChat"))),h.append(u,m);let a$2=(0, a.createEl)(t,"div","pptxv-ai-history-body"),x=(0, a.createEl)(t,"p","pptxv-ai-history-hint");x.textContent=i("pptx.ai.historyHint"),s.append(h,a$2,x);let r=createAiChatHistoryController({deckId:o.deckId,store:o.store,getMessages:o.getMessages,setMessages:o.setMessages,untitledLabel:i("pptx.ai.untitledChat"),onChatsChanged:()=>p()});function p(){a$2.replaceChildren();let g=r.chats();if(g.length===0){let d=(0, a.createEl)(t,"p","pptxv-ai-history-empty");d.textContent=i("pptx.ai.historyEmpty"),a$2.appendChild(d);return}let b=(0, a.createEl)(t,"ul","pptxv-ai-history-list");for(let d of g){let y=(0, a.createEl)(t,"li","pptxv-ai-history-row"),v=(0, a.createEl)(t,"button","pptxv-ai-history-resume");v.type="button",v.classList.toggle("is-active",d.id===r.activeChatId());let l=(0, a.createEl)(t,"span","pptxv-ai-history-text"),T=(0, a.createEl)(t,"span","pptxv-ai-history-name");T.textContent=d.title||i("pptx.ai.untitledChat");let P=(0, a.createEl)(t,"span","pptxv-ai-history-meta");P.textContent=i("pptx.ai.messageCount",{count:d.messageCount}),l.append(T,P),v.append(a$1(t,"comment"),l),v.addEventListener("click",()=>{r.resumeChat(d.id),s.hidden=true;});let k=(0, a.createEl)(t,"button","pptxv-ai-history-delete");k.type="button",k.title=i("pptx.ai.deleteChat"),k.setAttribute("aria-label",i("pptx.ai.deleteChat")),k.appendChild(a$1(t,"trash")),k.addEventListener("click",()=>{r.deleteChat(d.id);}),y.append(v,k),b.appendChild(y);}a$2.appendChild(b);}p(),n.addEventListener("click",()=>{s.hidden=!s.hidden;}),m.addEventListener("click",()=>{r.newChat(),s.hidden=true;});let C=g=>{s.hidden||!(g.target instanceof Node)||!s.contains(g.target)&&!n.contains(g.target)&&(s.hidden=true);};return t.addEventListener("mousedown",C),{button:n,el:s,notifyMessagesChanged:()=>r.notifyMessagesChanged(),destroy(){t.removeEventListener("mousedown",C),r.dispose(),n.remove(),s.remove();}}}var Q={view:"eye",text:"text-box",shape:"shapes",theme:"font-color",table:"table",slide:"layout",chart:"chart",move:"move-right",delete:"trash",search:"search",nav:"move-right",animation:"play",notes:"sticky-note",tool:"wrench"};function F(o,t,i){let n=t.state==="output-error",s=t.state==="output-available",h=!n&&!s,u=describeToolActivity(t.toolName,t.input,h?"present":"past"),m=(0, a.createEl)(o,"div","pptxv-ai-tool"),a$2=(0, a.createEl)(o,"div","pptxv-ai-tool-head"),x=a$1(o,Q[u.icon]??"wrench");x.classList.add("pptxv-ai-tool-icon");let r=(0, a.createEl)(o,"span","pptxv-ai-tool-name");r.textContent=u.label;let p=(0, a.createEl)(o,"span","pptxv-ai-tool-state");if(n?(p.classList.add("is-error"),p.append(a$1(o,"alert"),o.createTextNode(i("pptx.ai.toolFailed")))):s?(p.classList.add("is-done"),p.append(a$1(o,"check"),o.createTextNode(i("pptx.ai.toolDone")))):(p.classList.add("is-running"),p.textContent=i("pptx.ai.toolRunning")),a$2.append(x,r,p),m.appendChild(a$2),n&&t.errorText){let g=(0, a.createEl)(o,"div","pptxv-ai-tool-error");g.textContent=t.errorText,m.appendChild(g);}let C=summarizeToolArgs(t.input);if(C){let g=(0, a.createEl)(o,"details","pptxv-ai-tool-details"),b=(0, a.createEl)(o,"summary");b.textContent=i("pptx.ai.toolDetails");let d=(0, a.createEl)(o,"div","pptxv-ai-tool-raw");d.textContent=`${toolLabel(t.toolName)}: ${C}`,g.append(b,d),m.appendChild(g);}return m}function H(o,t,i,n){t.replaceChildren();for(let s of i){if(s.role==="system")continue;let h=s.role==="user",u=toRenderableParts(s);if(u.length===0&&!h)continue;let m=(0, a.createEl)(o,"div",`pptxv-ai-msg pptxv-ai-msg-${s.role}`),a$2=(0, a.createEl)(o,"div","pptxv-ai-msg-avatar");a$2.setAttribute("aria-label",n(h?"pptx.ai.you":"pptx.ai.assistant")),a$2.appendChild(a$1(o,h?"comment":"sparkles"));let x=(0, a.createEl)(o,"div","pptxv-ai-msg-body");for(let r of u)if(r.kind==="text"){let p=(0, a.createEl)(o,"div","pptxv-ai-msg-text");p.textContent=r.text,x.appendChild(p);}else x.appendChild(F(o,r,n));m.append(a$2,x),t.appendChild(m);}}function B(o,t,i,n,s,h=false){if(t.replaceChildren(),t.hidden=i.length===0&&!h,i.length===0){if(h){let a$1=(0, a.createEl)(o,"p","pptxv-ai-proposals-discarded");a$1.setAttribute("role","status"),a$1.dataset.testid="pptx-ai-proposals-discarded",a$1.textContent=n("pptx.ai.proposalsDiscarded"),t.appendChild(a$1);}return}let u=(0, a.createEl)(o,"div","pptxv-ai-proposals-header"),m=(0, a.createEl)(o,"span","pptxv-ai-proposals-title");if(m.textContent=n("pptx.ai.pendingChanges",{count:i.length}),u.appendChild(m),canAcceptAllProposals(i)){let a$1=(0, a.createEl)(o,"button","pptxv-ai-proposal-btn is-accept-all");a$1.type="button",a$1.textContent=n("pptx.ai.acceptAll"),a$1.addEventListener("click",()=>s.acceptAll()),u.appendChild(a$1);}t.appendChild(u);for(let a of i)t.appendChild(_(o,a,n,s));}function _(o,t,i,n){let s=(0, a.createEl)(o,"div","pptxv-ai-proposal");s.dataset.proposalId=t.id;let h=(0, a.createEl)(o,"div","pptxv-ai-proposal-eyebrow");h.textContent=i("pptx.ai.proposedChange"),s.appendChild(h);let u=(0, a.createEl)(o,"div","pptxv-ai-proposal-label");if(u.textContent=t.label,s.appendChild(u),t.summary.length>0){let r=(0, a.createEl)(o,"ul","pptxv-ai-proposal-summary");for(let p of t.summary){let C=(0, a.createEl)(o,"li");C.textContent=humanizeDiffLine(p),r.appendChild(C);}s.appendChild(r);}if(t.requiresApproval&&!t.conflict){let r=(0, a.createEl)(o,"div","pptxv-ai-proposal-notice");r.textContent=i("pptx.ai.proposalNeedsApproval"),s.appendChild(r);}if(t.conflict){let r=(0, a.createEl)(o,"div","pptxv-ai-proposal-notice is-conflict");r.setAttribute("role","alert"),r.textContent=i("pptx.ai.proposalConflict"),s.appendChild(r);}let m=(0, a.createEl)(o,"div","pptxv-ai-proposal-actions"),a$2=(0, a.createEl)(o,"button","pptxv-ai-proposal-btn is-accept");a$2.type="button",a$2.append(a$1(o,"check"),o.createTextNode(i("pptx.ai.accept"))),a$2.addEventListener("click",()=>n.accept(t.id));let x=(0, a.createEl)(o,"button","pptxv-ai-proposal-btn is-reject");return x.type="button",x.append(a$1(o,"close"),o.createTextNode(i("pptx.ai.reject"))),x.addEventListener("click",()=>n.reject(t.id)),m.append(a$2,x),s.appendChild(m),s}async function wt(o){let{doc:t,host:i,t:n}=o;i.replaceChildren();let s=(0, a.createEl)(t,"div","pptxv-ai-header"),h=(0, a.createEl)(t,"span","pptxv-ai-title");h.textContent=n("pptx.ai.title");let u=(0, a.createEl)(t,"button","pptxv-ai-close");u.type="button",u.title=n("pptx.ai.close"),u.setAttribute("aria-label",n("pptx.ai.close")),u.appendChild(a$1(t,"close")),u.addEventListener("click",()=>o.onClose?.()),s.append(a$1(t,"sparkles"),h,u);let m,a$2=o.controller,x=a$2?D({doc:t,t:n,controller:a$2,getSlides:()=>o.bridge.getSlides(),onSendDirective:c=>{m?.sendMessage(c);}}):null,r=(0, a.createEl)(t,"div","pptxv-ai-messages");r.setAttribute("role","log"),r.setAttribute("aria-live","polite");let p=(0, a.createEl)(t,"div","pptxv-ai-empty");p.textContent=n("pptx.ai.emptyHint"),r.appendChild(p);let C=(0, a.createEl)(t,"div","pptxv-ai-proposals");C.hidden=true;let g=(0, a.createEl)(t,"div","pptxv-ai-error");g.setAttribute("role","alert"),g.hidden=true;let b=(0, a.createEl)(t,"form","pptxv-ai-composer"),d=(0, a.createEl)(t,"textarea","pptxv-ai-input");d.rows=2,d.placeholder=n("pptx.ai.placeholder"),d.setAttribute("aria-label",n("pptx.ai.placeholder"));let y=(0, a.createEl)(t,"button","pptxv-ai-send");y.type="submit",y.setAttribute("aria-label",n("pptx.ai.send")),y.appendChild(a$1(t,"send")),b.append(d,y),i.append(s,...x?[x.el]:[],r,C,g);let v=a$2?.getPrefill().nonce??0;try{m=await(o.createChat??createVanillaChat)({bridge:o.bridge,config:o.config});}catch{return p.textContent=n("pptx.ai.unavailableTitle"),d.disabled=true,y.disabled=true,i.append(b),x?.destroy(),{destroy:()=>i.replaceChildren()}}let l=m;i.append(b);let T=w({doc:t,t:n,deckId:deckIdFromBridge(o.bridge),store:o.historyStore,getMessages:()=>l.getSnapshot().messages,setMessages:c=>l.setMessages(c)});s.insertBefore(T.button,u),i.appendChild(T.el);let P=l.subscribe(()=>T.notifyMessagesChanged()),k=new Set,N=c=>{if(!a$2)return;let A=c.messages.flatMap(U=>toRenderableParts(U).filter($=>$.kind==="tool")).at(-1);if(!A||A.kind!=="tool"||A.state==="input-streaming"||k.has(A.toolCallId))return;k.add(A.toolCallId);let M=toolCanvasTarget(A.toolName,A.input);M&&M.slideIndex!==void 0&&o.goToSlide?.(M.slideIndex),a$2.flashToolTarget(M);},L=c=>{H(t,r,c.messages,n),p.hidden=c.messages.length>0,c.messages.length===0&&r.appendChild(p),B(t,C,l.proposals.list(),n,{accept:A=>{a$2?.flashToolTarget(null),l.proposals.apply(A),L(l.getSnapshot());},reject:A=>{l.proposals.revert(A),L(l.getSnapshot());},acceptAll:()=>{a$2?.flashToolTarget(null),l.proposals.acceptAll(),L(l.getSnapshot());}},l.proposals.discarded);let E=c.status==="submitted"||c.status==="streaming";i.classList.toggle("is-busy",E),y.setAttribute("aria-label",n(E?"pptx.ai.stop":"pptx.ai.send")),g.hidden=!c.error,g.textContent=c.error?`${n("pptx.ai.errorPrefix")}: ${c.error.message}`:"",r.scrollTop=r.scrollHeight,N(c);},S=()=>{if(i.classList.contains("is-busy")){l.stop();return}let c=d.value.trim();c&&(d.value="",l.sendMessage(c));};b.addEventListener("submit",c=>{c.preventDefault(),S();}),d.addEventListener("keydown",c=>{c.key==="Enter"&&!c.shiftKey&&(c.preventDefault(),S());});let I=()=>{if(!a$2)return;let c=a$2.getPrefill();c.nonce!==v&&(v=c.nonce,d.value=c.text,d.focus());},V=a$2?.subscribe(I);I();let j=l.subscribe(L);L(l.getSnapshot());let R=o.subscribeDeckLoad?.(()=>L(l.getSnapshot()));return {changeAnimator:l.changeAnimator,destroy(){j(),R?.(),P(),T.destroy(),V?.(),x?.destroy(),i.replaceChildren();}}}export{wt as createAiPanel};
@@ -0,0 +1 @@
1
+ 'use strict';var chunkLRW2J5GY_cjs=require('./chunk-LRW2J5GY.cjs'),chunkXCLRGHGD_cjs=require('./chunk-XCLRGHGD.cjs');require('./chunk-FRJYQEIV.cjs');var ai=require('ooxml-ui/pptx/ai');function D(o){let{doc:t,t:i,controller:n}=o,s=(0, chunkXCLRGHGD_cjs.a.createEl)(t,"div","pptxv-ai-focus"),h=(a,x,r)=>{let p=(0, chunkXCLRGHGD_cjs.a.createEl)(t,"button","pptxv-ai-focus-btn");return p.type="button",p.title=x,p.setAttribute("aria-label",x),p.appendChild(chunkLRW2J5GY_cjs.a(t,a)),p.addEventListener("click",r),p},u=()=>{s.replaceChildren();let a=n.getEffectiveTargets(),x=n.hasPicks(),r=n.isPinned(),p=n.isPicking(),C=(0, chunkXCLRGHGD_cjs.a.createEl)(t,"div","pptxv-ai-focus-row"),g=(0, chunkXCLRGHGD_cjs.a.createEl)(t,"span","pptxv-ai-focus-label");g.textContent=i("pptx.ai.focusScope"),C.appendChild(g);for(let v of ai.focusTargetChips(a,o.getSlides())){let l=(0, chunkXCLRGHGD_cjs.a.createEl)(t,"span","pptxv-ai-focus-chip");(x||r)&&l.classList.add("is-strong"),l.title=v.title,l.textContent=v.label,C.appendChild(l);}if(r){let v=(0, chunkXCLRGHGD_cjs.a.createEl)(t,"span","pptxv-ai-focus-pinned");v.textContent=i("pptx.ai.pinnedFocus"),C.appendChild(v);}let b=(0, chunkXCLRGHGD_cjs.a.createEl)(t,"div","pptxv-ai-focus-actions"),d=ai.isTwoTableFocus(a,o.getSlides());if(d){let v=(0, chunkXCLRGHGD_cjs.a.createEl)(t,"button","pptxv-ai-focus-merge");v.type="button",v.append(chunkLRW2J5GY_cjs.a(t,"git-merge"),t.createTextNode(i("pptx.ai.mergeSelectedTables"))),v.addEventListener("click",()=>o.onSendDirective(ai.mergeTablesDirective(d.slideIndex,d.elementIdA,d.elementIdB))),b.appendChild(v);}let y=h("crosshair",i("pptx.ai.pickElement"),()=>p?n.stopPicking():n.startPicking());if(y.setAttribute("aria-pressed",String(p)),y.classList.toggle("is-active",p),b.appendChild(y),x?b.appendChild(h("close",i("pptx.ai.pickClear"),()=>n.clearPicks())):r?b.appendChild(h("pin-off",i("pptx.ai.clearFocus"),()=>n.clearPinnedFocus())):b.appendChild(h("pin",i("pptx.ai.pinFocus"),()=>n.pinFocus())),C.appendChild(b),s.appendChild(C),p){let v=(0, chunkXCLRGHGD_cjs.a.createEl)(t,"div","pptxv-ai-focus-pick"),l=chunkLRW2J5GY_cjs.a(t,"crosshair");l.classList.add("pptxv-ai-focus-pick-icon");let T=(0, chunkXCLRGHGD_cjs.a.createEl)(t,"span","pptxv-ai-focus-pick-hint");T.textContent=i("pptx.ai.pickElementHint");let P=(0, chunkXCLRGHGD_cjs.a.createEl)(t,"button","pptxv-ai-focus-pick-done");P.type="button",P.textContent=i("pptx.ai.pickDone"),P.addEventListener("click",()=>n.stopPicking()),v.append(l,T,P),s.appendChild(v);}},m=n.subscribe(u);return u(),{el:s,destroy(){m(),s.remove();}}}function w(o){let{doc:t,t:i}=o,n=(0, chunkXCLRGHGD_cjs.a.createEl)(t,"button","pptxv-ai-chats");n.type="button",n.append(chunkLRW2J5GY_cjs.a(t,"history"),t.createTextNode(i("pptx.ai.chats")));let s=(0, chunkXCLRGHGD_cjs.a.createEl)(t,"div","pptxv-ai-history");s.hidden=true;let h=(0, chunkXCLRGHGD_cjs.a.createEl)(t,"div","pptxv-ai-history-head"),u=(0, chunkXCLRGHGD_cjs.a.createEl)(t,"span","pptxv-ai-history-title");u.textContent=i("pptx.ai.historyTitle");let m=(0, chunkXCLRGHGD_cjs.a.createEl)(t,"button","pptxv-ai-history-new");m.type="button",m.append(chunkLRW2J5GY_cjs.a(t,"plus"),t.createTextNode(i("pptx.ai.newChat"))),h.append(u,m);let a=(0, chunkXCLRGHGD_cjs.a.createEl)(t,"div","pptxv-ai-history-body"),x=(0, chunkXCLRGHGD_cjs.a.createEl)(t,"p","pptxv-ai-history-hint");x.textContent=i("pptx.ai.historyHint"),s.append(h,a,x);let r=ai.createAiChatHistoryController({deckId:o.deckId,store:o.store,getMessages:o.getMessages,setMessages:o.setMessages,untitledLabel:i("pptx.ai.untitledChat"),onChatsChanged:()=>p()});function p(){a.replaceChildren();let g=r.chats();if(g.length===0){let d=(0, chunkXCLRGHGD_cjs.a.createEl)(t,"p","pptxv-ai-history-empty");d.textContent=i("pptx.ai.historyEmpty"),a.appendChild(d);return}let b=(0, chunkXCLRGHGD_cjs.a.createEl)(t,"ul","pptxv-ai-history-list");for(let d of g){let y=(0, chunkXCLRGHGD_cjs.a.createEl)(t,"li","pptxv-ai-history-row"),v=(0, chunkXCLRGHGD_cjs.a.createEl)(t,"button","pptxv-ai-history-resume");v.type="button",v.classList.toggle("is-active",d.id===r.activeChatId());let l=(0, chunkXCLRGHGD_cjs.a.createEl)(t,"span","pptxv-ai-history-text"),T=(0, chunkXCLRGHGD_cjs.a.createEl)(t,"span","pptxv-ai-history-name");T.textContent=d.title||i("pptx.ai.untitledChat");let P=(0, chunkXCLRGHGD_cjs.a.createEl)(t,"span","pptxv-ai-history-meta");P.textContent=i("pptx.ai.messageCount",{count:d.messageCount}),l.append(T,P),v.append(chunkLRW2J5GY_cjs.a(t,"comment"),l),v.addEventListener("click",()=>{r.resumeChat(d.id),s.hidden=true;});let k=(0, chunkXCLRGHGD_cjs.a.createEl)(t,"button","pptxv-ai-history-delete");k.type="button",k.title=i("pptx.ai.deleteChat"),k.setAttribute("aria-label",i("pptx.ai.deleteChat")),k.appendChild(chunkLRW2J5GY_cjs.a(t,"trash")),k.addEventListener("click",()=>{r.deleteChat(d.id);}),y.append(v,k),b.appendChild(y);}a.appendChild(b);}p(),n.addEventListener("click",()=>{s.hidden=!s.hidden;}),m.addEventListener("click",()=>{r.newChat(),s.hidden=true;});let C=g=>{s.hidden||!(g.target instanceof Node)||!s.contains(g.target)&&!n.contains(g.target)&&(s.hidden=true);};return t.addEventListener("mousedown",C),{button:n,el:s,notifyMessagesChanged:()=>r.notifyMessagesChanged(),destroy(){t.removeEventListener("mousedown",C),r.dispose(),n.remove(),s.remove();}}}var Q={view:"eye",text:"text-box",shape:"shapes",theme:"font-color",table:"table",slide:"layout",chart:"chart",move:"move-right",delete:"trash",search:"search",nav:"move-right",animation:"play",notes:"sticky-note",tool:"wrench"};function F(o,t,i){let n=t.state==="output-error",s=t.state==="output-available",h=!n&&!s,u=ai.describeToolActivity(t.toolName,t.input,h?"present":"past"),m=(0, chunkXCLRGHGD_cjs.a.createEl)(o,"div","pptxv-ai-tool"),a=(0, chunkXCLRGHGD_cjs.a.createEl)(o,"div","pptxv-ai-tool-head"),x=chunkLRW2J5GY_cjs.a(o,Q[u.icon]??"wrench");x.classList.add("pptxv-ai-tool-icon");let r=(0, chunkXCLRGHGD_cjs.a.createEl)(o,"span","pptxv-ai-tool-name");r.textContent=u.label;let p=(0, chunkXCLRGHGD_cjs.a.createEl)(o,"span","pptxv-ai-tool-state");if(n?(p.classList.add("is-error"),p.append(chunkLRW2J5GY_cjs.a(o,"alert"),o.createTextNode(i("pptx.ai.toolFailed")))):s?(p.classList.add("is-done"),p.append(chunkLRW2J5GY_cjs.a(o,"check"),o.createTextNode(i("pptx.ai.toolDone")))):(p.classList.add("is-running"),p.textContent=i("pptx.ai.toolRunning")),a.append(x,r,p),m.appendChild(a),n&&t.errorText){let g=(0, chunkXCLRGHGD_cjs.a.createEl)(o,"div","pptxv-ai-tool-error");g.textContent=t.errorText,m.appendChild(g);}let C=ai.summarizeToolArgs(t.input);if(C){let g=(0, chunkXCLRGHGD_cjs.a.createEl)(o,"details","pptxv-ai-tool-details"),b=(0, chunkXCLRGHGD_cjs.a.createEl)(o,"summary");b.textContent=i("pptx.ai.toolDetails");let d=(0, chunkXCLRGHGD_cjs.a.createEl)(o,"div","pptxv-ai-tool-raw");d.textContent=`${ai.toolLabel(t.toolName)}: ${C}`,g.append(b,d),m.appendChild(g);}return m}function H(o,t,i,n){t.replaceChildren();for(let s of i){if(s.role==="system")continue;let h=s.role==="user",u=ai.toRenderableParts(s);if(u.length===0&&!h)continue;let m=(0, chunkXCLRGHGD_cjs.a.createEl)(o,"div",`pptxv-ai-msg pptxv-ai-msg-${s.role}`),a=(0, chunkXCLRGHGD_cjs.a.createEl)(o,"div","pptxv-ai-msg-avatar");a.setAttribute("aria-label",n(h?"pptx.ai.you":"pptx.ai.assistant")),a.appendChild(chunkLRW2J5GY_cjs.a(o,h?"comment":"sparkles"));let x=(0, chunkXCLRGHGD_cjs.a.createEl)(o,"div","pptxv-ai-msg-body");for(let r of u)if(r.kind==="text"){let p=(0, chunkXCLRGHGD_cjs.a.createEl)(o,"div","pptxv-ai-msg-text");p.textContent=r.text,x.appendChild(p);}else x.appendChild(F(o,r,n));m.append(a,x),t.appendChild(m);}}function B(o,t,i,n,s,h=false){if(t.replaceChildren(),t.hidden=i.length===0&&!h,i.length===0){if(h){let a=(0, chunkXCLRGHGD_cjs.a.createEl)(o,"p","pptxv-ai-proposals-discarded");a.setAttribute("role","status"),a.dataset.testid="pptx-ai-proposals-discarded",a.textContent=n("pptx.ai.proposalsDiscarded"),t.appendChild(a);}return}let u=(0, chunkXCLRGHGD_cjs.a.createEl)(o,"div","pptxv-ai-proposals-header"),m=(0, chunkXCLRGHGD_cjs.a.createEl)(o,"span","pptxv-ai-proposals-title");if(m.textContent=n("pptx.ai.pendingChanges",{count:i.length}),u.appendChild(m),ai.canAcceptAllProposals(i)){let a=(0, chunkXCLRGHGD_cjs.a.createEl)(o,"button","pptxv-ai-proposal-btn is-accept-all");a.type="button",a.textContent=n("pptx.ai.acceptAll"),a.addEventListener("click",()=>s.acceptAll()),u.appendChild(a);}t.appendChild(u);for(let a of i)t.appendChild(_(o,a,n,s));}function _(o,t,i,n){let s=(0, chunkXCLRGHGD_cjs.a.createEl)(o,"div","pptxv-ai-proposal");s.dataset.proposalId=t.id;let h=(0, chunkXCLRGHGD_cjs.a.createEl)(o,"div","pptxv-ai-proposal-eyebrow");h.textContent=i("pptx.ai.proposedChange"),s.appendChild(h);let u=(0, chunkXCLRGHGD_cjs.a.createEl)(o,"div","pptxv-ai-proposal-label");if(u.textContent=t.label,s.appendChild(u),t.summary.length>0){let r=(0, chunkXCLRGHGD_cjs.a.createEl)(o,"ul","pptxv-ai-proposal-summary");for(let p of t.summary){let C=(0, chunkXCLRGHGD_cjs.a.createEl)(o,"li");C.textContent=ai.humanizeDiffLine(p),r.appendChild(C);}s.appendChild(r);}if(t.requiresApproval&&!t.conflict){let r=(0, chunkXCLRGHGD_cjs.a.createEl)(o,"div","pptxv-ai-proposal-notice");r.textContent=i("pptx.ai.proposalNeedsApproval"),s.appendChild(r);}if(t.conflict){let r=(0, chunkXCLRGHGD_cjs.a.createEl)(o,"div","pptxv-ai-proposal-notice is-conflict");r.setAttribute("role","alert"),r.textContent=i("pptx.ai.proposalConflict"),s.appendChild(r);}let m=(0, chunkXCLRGHGD_cjs.a.createEl)(o,"div","pptxv-ai-proposal-actions"),a=(0, chunkXCLRGHGD_cjs.a.createEl)(o,"button","pptxv-ai-proposal-btn is-accept");a.type="button",a.append(chunkLRW2J5GY_cjs.a(o,"check"),o.createTextNode(i("pptx.ai.accept"))),a.addEventListener("click",()=>n.accept(t.id));let x=(0, chunkXCLRGHGD_cjs.a.createEl)(o,"button","pptxv-ai-proposal-btn is-reject");return x.type="button",x.append(chunkLRW2J5GY_cjs.a(o,"close"),o.createTextNode(i("pptx.ai.reject"))),x.addEventListener("click",()=>n.reject(t.id)),m.append(a,x),s.appendChild(m),s}async function wt(o){let{doc:t,host:i,t:n}=o;i.replaceChildren();let s=(0, chunkXCLRGHGD_cjs.a.createEl)(t,"div","pptxv-ai-header"),h=(0, chunkXCLRGHGD_cjs.a.createEl)(t,"span","pptxv-ai-title");h.textContent=n("pptx.ai.title");let u=(0, chunkXCLRGHGD_cjs.a.createEl)(t,"button","pptxv-ai-close");u.type="button",u.title=n("pptx.ai.close"),u.setAttribute("aria-label",n("pptx.ai.close")),u.appendChild(chunkLRW2J5GY_cjs.a(t,"close")),u.addEventListener("click",()=>o.onClose?.()),s.append(chunkLRW2J5GY_cjs.a(t,"sparkles"),h,u);let m,a=o.controller,x=a?D({doc:t,t:n,controller:a,getSlides:()=>o.bridge.getSlides(),onSendDirective:c=>{m?.sendMessage(c);}}):null,r=(0, chunkXCLRGHGD_cjs.a.createEl)(t,"div","pptxv-ai-messages");r.setAttribute("role","log"),r.setAttribute("aria-live","polite");let p=(0, chunkXCLRGHGD_cjs.a.createEl)(t,"div","pptxv-ai-empty");p.textContent=n("pptx.ai.emptyHint"),r.appendChild(p);let C=(0, chunkXCLRGHGD_cjs.a.createEl)(t,"div","pptxv-ai-proposals");C.hidden=true;let g=(0, chunkXCLRGHGD_cjs.a.createEl)(t,"div","pptxv-ai-error");g.setAttribute("role","alert"),g.hidden=true;let b=(0, chunkXCLRGHGD_cjs.a.createEl)(t,"form","pptxv-ai-composer"),d=(0, chunkXCLRGHGD_cjs.a.createEl)(t,"textarea","pptxv-ai-input");d.rows=2,d.placeholder=n("pptx.ai.placeholder"),d.setAttribute("aria-label",n("pptx.ai.placeholder"));let y=(0, chunkXCLRGHGD_cjs.a.createEl)(t,"button","pptxv-ai-send");y.type="submit",y.setAttribute("aria-label",n("pptx.ai.send")),y.appendChild(chunkLRW2J5GY_cjs.a(t,"send")),b.append(d,y),i.append(s,...x?[x.el]:[],r,C,g);let v=a?.getPrefill().nonce??0;try{m=await(o.createChat??ai.createVanillaChat)({bridge:o.bridge,config:o.config});}catch{return p.textContent=n("pptx.ai.unavailableTitle"),d.disabled=true,y.disabled=true,i.append(b),x?.destroy(),{destroy:()=>i.replaceChildren()}}let l=m;i.append(b);let T=w({doc:t,t:n,deckId:ai.deckIdFromBridge(o.bridge),store:o.historyStore,getMessages:()=>l.getSnapshot().messages,setMessages:c=>l.setMessages(c)});s.insertBefore(T.button,u),i.appendChild(T.el);let P=l.subscribe(()=>T.notifyMessagesChanged()),k=new Set,N=c=>{if(!a)return;let A=c.messages.flatMap(U=>ai.toRenderableParts(U).filter($=>$.kind==="tool")).at(-1);if(!A||A.kind!=="tool"||A.state==="input-streaming"||k.has(A.toolCallId))return;k.add(A.toolCallId);let M=ai.toolCanvasTarget(A.toolName,A.input);M&&M.slideIndex!==void 0&&o.goToSlide?.(M.slideIndex),a.flashToolTarget(M);},L=c=>{H(t,r,c.messages,n),p.hidden=c.messages.length>0,c.messages.length===0&&r.appendChild(p),B(t,C,l.proposals.list(),n,{accept:A=>{a?.flashToolTarget(null),l.proposals.apply(A),L(l.getSnapshot());},reject:A=>{l.proposals.revert(A),L(l.getSnapshot());},acceptAll:()=>{a?.flashToolTarget(null),l.proposals.acceptAll(),L(l.getSnapshot());}},l.proposals.discarded);let E=c.status==="submitted"||c.status==="streaming";i.classList.toggle("is-busy",E),y.setAttribute("aria-label",n(E?"pptx.ai.stop":"pptx.ai.send")),g.hidden=!c.error,g.textContent=c.error?`${n("pptx.ai.errorPrefix")}: ${c.error.message}`:"",r.scrollTop=r.scrollHeight,N(c);},S=()=>{if(i.classList.contains("is-busy")){l.stop();return}let c=d.value.trim();c&&(d.value="",l.sendMessage(c));};b.addEventListener("submit",c=>{c.preventDefault(),S();}),d.addEventListener("keydown",c=>{c.key==="Enter"&&!c.shiftKey&&(c.preventDefault(),S());});let I=()=>{if(!a)return;let c=a.getPrefill();c.nonce!==v&&(v=c.nonce,d.value=c.text,d.focus());},V=a?.subscribe(I);I();let j=l.subscribe(L);L(l.getSnapshot());let R=o.subscribeDeckLoad?.(()=>L(l.getSnapshot()));return {changeAnimator:l.changeAnimator,destroy(){j(),R?.(),P(),T.destroy(),V?.(),x?.destroy(),i.replaceChildren();}}}exports.createAiPanel=wt;
package/dist/ai.cjs CHANGED
@@ -1 +1 @@
1
- 'use strict';var chunkPCF72CT4_cjs=require('./chunk-PCF72CT4.cjs');require('./chunk-FRJYQEIV.cjs');var o=()=>import('./ai-panel-IWCC7TBE.cjs');function e(i){return chunkPCF72CT4_cjs.a.register(i,o)}exports.createAiAssistant=e;
1
+ 'use strict';var chunkPCF72CT4_cjs=require('./chunk-PCF72CT4.cjs');require('./chunk-FRJYQEIV.cjs');var o=()=>import('./ai-panel-SXVNV3LN.cjs');function e(i){return chunkPCF72CT4_cjs.a.register(i,o)}exports.createAiAssistant=e;
package/dist/ai.js CHANGED
@@ -1 +1 @@
1
- import {a}from'./chunk-5TJJZ2IN.js';import'./chunk-CNU4N4AY.js';var o=()=>import('./ai-panel-SSGS4M3M.js');function e(i){return a.register(i,o)}export{e as createAiAssistant};
1
+ import {a}from'./chunk-5TJJZ2IN.js';import'./chunk-CNU4N4AY.js';var o=()=>import('./ai-panel-6JMUOAO6.js');function e(i){return a.register(i,o)}export{e as createAiAssistant};