pptx-vanilla-viewer 2.17.0 → 2.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +37 -0
- package/README.md +35 -24
- package/dist/ai-panel-7FC2OBYA.cjs +1 -0
- package/dist/ai-panel-CCANBBW5.js +1 -0
- package/dist/{chunk-KHVPUMYT.cjs → chunk-2GIA6P55.cjs} +270 -270
- package/dist/{chunk-MXXOTNOS.js → chunk-KYE4M4LZ.js} +270 -270
- package/dist/index.cjs +68 -63
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +67 -62
- package/dist/styles.css +5 -0
- package/package.json +3 -3
- package/dist/ai-panel-ICLR2XIL.js +0 -1
- package/dist/ai-panel-ZW2RUGKQ.cjs +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,43 @@ A release listed with no entries carried no Conventional Commit in this package'
|
|
|
7
7
|
scope: scripts/release-plan.mjs re-releases a package whenever any of its files
|
|
8
8
|
change, not only on conventional ones.
|
|
9
9
|
|
|
10
|
+
## [2.17.1](https://github.com/ChristopherVR/pptx-viewer/releases/tag/pptx-vanilla-viewer@2.17.1) - 2026-09-14
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
- **i18n:** Localize inspector and ribbon controls (by @yunfeizhu) ([a657a76](https://github.com/ChristopherVR/pptx-viewer/commit/a657a766d653106f04d50f7b13a94a6c12c77f1e))
|
|
15
|
+
|
|
16
|
+
## [2.17.0](https://github.com/ChristopherVR/pptx-viewer/releases/tag/pptx-vanilla-viewer@2.17.0) - 2026-09-13
|
|
17
|
+
|
|
18
|
+
### Features
|
|
19
|
+
|
|
20
|
+
- **shared:** Add configurable viewport fit options (by @Sudhansh6) ([93e3218](https://github.com/ChristopherVR/pptx-viewer/commit/93e3218de54ce8d153761e2fba83f3558fc3051b))
|
|
21
|
+
- **vanilla:** Add configurable viewport fit options (by @Sudhansh6) ([b29ca1a](https://github.com/ChristopherVR/pptx-viewer/commit/b29ca1a8c4fe5a3d55dbf17225002c9735c112f9))
|
|
22
|
+
- **shared:** Expose public element insertion across viewers (by @Sudhansh6) ([2701047](https://github.com/ChristopherVR/pptx-viewer/commit/2701047d5011b5d7ce8408009addc1dc31f6e3f7))
|
|
23
|
+
|
|
24
|
+
### Bug Fixes
|
|
25
|
+
|
|
26
|
+
- **core:** Preserve empty paragraph insertion formatting (by @Sudhansh6) ([121f6bf](https://github.com/ChristopherVR/pptx-viewer/commit/121f6bf9f64a29ab07e07b5d4f042a4b075d7876))
|
|
27
|
+
- **shared:** Preserve empty paragraph insertion formatting (by @Sudhansh6) ([b34d0f5](https://github.com/ChristopherVR/pptx-viewer/commit/b34d0f5ab9879e02f1de85c0e50b15f3947735c3))
|
|
28
|
+
- **vanilla:** Preserve empty paragraph insertion formatting (by @Sudhansh6) ([9fea926](https://github.com/ChristopherVR/pptx-viewer/commit/9fea926b0a36a08692cedee6708f1c7add012406))
|
|
29
|
+
- **vanilla:** Preserve split paragraph boundaries through native undo (by @Sudhansh6) ([9d7ba3d](https://github.com/ChristopherVR/pptx-viewer/commit/9d7ba3de8347180ab26d73ca86a5f0a48353a803))
|
|
30
|
+
- **shared:** Continue inserted paragraphs from the local list (by @Sudhansh6) ([78b8226](https://github.com/ChristopherVR/pptx-viewer/commit/78b82261a320b93052627ec9e6e460c4845f6f32))
|
|
31
|
+
- **shared:** Leave empty clipboard paste shortcuts unclaimed (by @Sudhansh6) ([aec446f](https://github.com/ChristopherVR/pptx-viewer/commit/aec446f7f36371ad2f9c1cf3e68b7aaeb4f2cc28))
|
|
32
|
+
|
|
33
|
+
### Other
|
|
34
|
+
|
|
35
|
+
- Retain empty paragraph styles with source alignment (by @Sudhansh6) ([d979cd2](https://github.com/ChristopherVR/pptx-viewer/commit/d979cd25b7c05cef0fc4d4501c39d2bb11e572e0))
|
|
36
|
+
- Integrate semantic list commands with empty paragraph formatting (by @Sudhansh6) ([c5d9a6f](https://github.com/ChristopherVR/pptx-viewer/commit/c5d9a6f4f52c44180111c1f5fca0f10299dce47a))
|
|
37
|
+
- Sync main font and SmartArt fixes (by @Sudhansh6) ([f2066eb](https://github.com/ChristopherVR/pptx-viewer/commit/f2066eb87b62884cadd77593e8b36426398c3312))
|
|
38
|
+
- Sync main paragraph and history fixes (by @Sudhansh6) ([a18a2d7](https://github.com/ChristopherVR/pptx-viewer/commit/a18a2d7fe2bccf7d8c49b72d7a80087d423d1da0))
|
|
39
|
+
- Sync viewport fit changes from main (by @Sudhansh6) ([3c3c0bd](https://github.com/ChristopherVR/pptx-viewer/commit/3c3c0bdb2f88648dd20ffac9b6fd5a691741253d))
|
|
40
|
+
- Sync public insertion with viewport fit API (by @Sudhansh6) ([47df3db](https://github.com/ChristopherVR/pptx-viewer/commit/47df3db6bb7bb6bbee06e36c9ff9565b2fc61252))
|
|
41
|
+
- Sync public insertion with empty paragraph formatting (by @Sudhansh6) ([d1ad9c9](https://github.com/ChristopherVR/pptx-viewer/commit/d1ad9c9562313085cab62f3b9f9fa0abc6d0fa1f))
|
|
42
|
+
|
|
43
|
+
### Documentation
|
|
44
|
+
|
|
45
|
+
- Move viewport fitting into developer guides (by @Sudhansh6) ([60707eb](https://github.com/ChristopherVR/pptx-viewer/commit/60707ebf8f261779b2ebfa41ff0741267a672bd3))
|
|
46
|
+
|
|
10
47
|
## [2.16.7](https://github.com/ChristopherVR/pptx-viewer/releases/tag/pptx-vanilla-viewer@2.16.7) - 2026-09-13
|
|
11
48
|
|
|
12
49
|
### Bug Fixes
|
package/README.md
CHANGED
|
@@ -21,8 +21,17 @@ The rendering is done by the framework-agnostic [`pptx-viewer-core`](https://www
|
|
|
21
21
|
npm install pptx-vanilla-viewer
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
+
Install `three` only when you enable a 3D SmartArt or 3D chart option. The viewer falls back to
|
|
25
|
+
SVG when it is absent. Install `yjs` with `y-websocket` or `y-webrtc` only for collaboration.
|
|
26
|
+
|
|
24
27
|
## Usage
|
|
25
28
|
|
|
29
|
+
For a copy-paste Vite project, including the `index.html`, `src/main.js`, and `public/` file
|
|
30
|
+
layout, see [the Vanilla Getting Started guide](https://christophervr.github.io/pptx-viewer/vanilla/getting-started/).
|
|
31
|
+
Place a local deck in `public/` and reference it with a root URL such as `/presentation.pptx`.
|
|
32
|
+
The viewer opens a successfully loaded `source` automatically; `onLoad` is for your application
|
|
33
|
+
code and does not need to click internal viewer controls.
|
|
34
|
+
|
|
26
35
|
```ts
|
|
27
36
|
import { createPptxViewer } from 'pptx-vanilla-viewer';
|
|
28
37
|
|
|
@@ -94,30 +103,32 @@ See the [cross-binding defaults](../../docs/guide/viewport-fit.md).
|
|
|
94
103
|
All options are optional except the container element itself. Beyond the ones
|
|
95
104
|
shown above:
|
|
96
105
|
|
|
97
|
-
| Option
|
|
98
|
-
|
|
|
99
|
-
| `source`
|
|
100
|
-
| `fonts`
|
|
101
|
-
| `theme`
|
|
102
|
-
| `fileName`
|
|
103
|
-
| `locale` / `messages`
|
|
104
|
-
| `initialSlide`
|
|
105
|
-
| `editable`
|
|
106
|
-
| `showToolbar`
|
|
107
|
-
| `showThumbnails`
|
|
108
|
-
| `showFormatToolbar`
|
|
109
|
-
| `showInspector`
|
|
110
|
-
| `hiddenActions`
|
|
111
|
-
| `registry`
|
|
112
|
-
| `smartArt3D`
|
|
113
|
-
| `
|
|
114
|
-
| `
|
|
115
|
-
| `
|
|
116
|
-
| `
|
|
117
|
-
| `
|
|
118
|
-
| `
|
|
119
|
-
| `
|
|
120
|
-
| `
|
|
106
|
+
| Option | Type | Default | Description |
|
|
107
|
+
| -------------------------------------------------------------------------- | ----------------------------------------------------- | ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
|
|
108
|
+
| `source` | `string \| ArrayBuffer \| Uint8Array \| Blob \| File` | - | The presentation to open (URL or bytes). Omit to start empty and call `loadFile`/`loadUrl`. |
|
|
109
|
+
| `fonts` | `ViewerFontSource[]` | - | Licensed font sources supplied by the host application. |
|
|
110
|
+
| `theme` | `ViewerTheme` | - | Chrome theme (colors, radius, CSS vars). |
|
|
111
|
+
| `fileName` | `string` | - | Display name shown in the title bar. |
|
|
112
|
+
| `locale` / `messages` | `string` / `TranslationMessages` | `'en'` | UI locale and per-locale `pptx.*` dictionaries (see [i18n](#i18n)). |
|
|
113
|
+
| `initialSlide` | `number` | `0` | Zero-based slide shown after load. |
|
|
114
|
+
| `editable` | `boolean` | `false` | Enable editing (see [Editing](#editing)). |
|
|
115
|
+
| `showToolbar` | `boolean` | `true` | Whole ribbon/title-bar/status-bar chrome. |
|
|
116
|
+
| `showThumbnails` | `boolean` | `true` | Thumbnail sidebar. |
|
|
117
|
+
| `showFormatToolbar` | `boolean` | `true` | Editing format toolbar row (visible only while editing). |
|
|
118
|
+
| `showInspector` | `boolean` | `true` | Property inspector panel (visible only while editing). |
|
|
119
|
+
| `hiddenActions` | `ToolbarActionId[]` | - | Hide individual buttons/tabs (see [Toolbar customization](#toolbar-customization)). |
|
|
120
|
+
| `registry` | `ElementRendererRegistry` | - | Custom element-renderer registry (see [Element coverage](#element-coverage)). |
|
|
121
|
+
| `smartArt3D` | `boolean` | `false` | Opt-in Three.js 3D SmartArt renderer (optional `three` peer, lazily imported). |
|
|
122
|
+
| `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. |
|
|
123
|
+
| `ai` | `PptxAiConfig` | - | Optional AI assistant configuration. The SDK peer loads only when its panel is opened. |
|
|
124
|
+
| `autosave` | `boolean` | `true` | Debounced crash-recovery autosave to IndexedDB. |
|
|
125
|
+
| `autosaveIntervalMs` | `number` | File > Options cadence | Autosave debounce window. |
|
|
126
|
+
| `autosaveFilePath` | `string` | `'presentation.pptx'` | IndexedDB recovery key for autosave snapshots. |
|
|
127
|
+
| `collaboration` | `CollaborationConfig` | - | Start a Yjs collaboration session immediately (y-websocket or serverless y-webrtc). |
|
|
128
|
+
| `shareDefaults` | `{ roomId?, userName?, serverUrl? }` | - | Prefilled values for the Share/Broadcast dialogs. |
|
|
129
|
+
| `availableThemes` / `availableLocales` | catalog entries | - | Choices offered by File > Options. |
|
|
130
|
+
| `onThemeChange` / `onLocaleChange` | `(key: string) => void` | - | Host hooks for the File > Options pickers (host owns persistence when supplied). |
|
|
131
|
+
| `accountAuth` | `AccountAuthConfig` | - | Optional sign-in hook point for File > Account. |
|
|
121
132
|
|
|
122
133
|
Callbacks: `onLoad`, `onError`, `onSlideChange`, `onZoomChange`,
|
|
123
134
|
`onPresentationChange`, `onChange` (any document mutation), `onDirtyChange`,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var chunk2GIA6P55_cjs=require('./chunk-2GIA6P55.cjs');require('./chunk-B5PFHICE.cjs');function K(o){let{doc:t,t:n,controller:i}=o,a=chunk2GIA6P55_cjs.mo(t,"div","pptxv-ai-focus"),h=(p,m,l)=>{let s=chunk2GIA6P55_cjs.mo(t,"button","pptxv-ai-focus-btn");return s.type="button",s.title=m,s.setAttribute("aria-label",m),s.appendChild(chunk2GIA6P55_cjs.Bo(t,p)),s.addEventListener("click",l),s},x=()=>{a.replaceChildren();let p=i.getEffectiveTargets(),m=i.hasPicks(),l=i.isPinned(),s=i.isPicking(),g=chunk2GIA6P55_cjs.mo(t,"div","pptxv-ai-focus-row"),f=chunk2GIA6P55_cjs.mo(t,"span","pptxv-ai-focus-label");f.textContent=n("pptx.ai.focusScope"),g.appendChild(f);for(let r of chunk2GIA6P55_cjs.$n(p,o.getSlides())){let b=chunk2GIA6P55_cjs.mo(t,"span","pptxv-ai-focus-chip");(m||l)&&b.classList.add("is-strong"),b.title=r.title,b.textContent=r.label,g.appendChild(b);}if(l){let r=chunk2GIA6P55_cjs.mo(t,"span","pptxv-ai-focus-pinned");r.textContent=n("pptx.ai.pinnedFocus"),g.appendChild(r);}let C=chunk2GIA6P55_cjs.mo(t,"div","pptxv-ai-focus-actions"),d=chunk2GIA6P55_cjs.ao(p,o.getSlides());if(d){let r=chunk2GIA6P55_cjs.mo(t,"button","pptxv-ai-focus-merge");r.type="button",r.append(chunk2GIA6P55_cjs.Bo(t,"git-merge"),t.createTextNode(n("pptx.ai.mergeSelectedTables"))),r.addEventListener("click",()=>o.onSendDirective(chunk2GIA6P55_cjs.bo(d.slideIndex,d.elementIdA,d.elementIdB))),C.appendChild(r);}let y=h("crosshair",n("pptx.ai.pickElement"),()=>s?i.stopPicking():i.startPicking());if(y.setAttribute("aria-pressed",String(s)),y.classList.toggle("is-active",s),C.appendChild(y),m?C.appendChild(h("close",n("pptx.ai.pickClear"),()=>i.clearPicks())):l?C.appendChild(h("pin-off",n("pptx.ai.clearFocus"),()=>i.clearPinnedFocus())):C.appendChild(h("pin",n("pptx.ai.pinFocus"),()=>i.pinFocus())),g.appendChild(C),a.appendChild(g),s){let r=chunk2GIA6P55_cjs.mo(t,"div","pptxv-ai-focus-pick"),b=chunk2GIA6P55_cjs.Bo(t,"crosshair");b.classList.add("pptxv-ai-focus-pick-icon");let k=chunk2GIA6P55_cjs.mo(t,"span","pptxv-ai-focus-pick-hint");k.textContent=n("pptx.ai.pickElementHint");let T=chunk2GIA6P55_cjs.mo(t,"button","pptxv-ai-focus-pick-done");T.type="button",T.textContent=n("pptx.ai.pickDone"),T.addEventListener("click",()=>i.stopPicking()),r.append(b,k,T),a.appendChild(r);}},c=i.subscribe(x);return x(),{el:a,destroy(){c(),a.remove();}}}function O(o){let{doc:t,t:n}=o,i=chunk2GIA6P55_cjs.mo(t,"button","pptxv-ai-chats");i.type="button",i.append(chunk2GIA6P55_cjs.Bo(t,"history"),t.createTextNode(n("pptx.ai.chats")));let a=chunk2GIA6P55_cjs.mo(t,"div","pptxv-ai-history");a.hidden=true;let h=chunk2GIA6P55_cjs.mo(t,"div","pptxv-ai-history-head"),x=chunk2GIA6P55_cjs.mo(t,"span","pptxv-ai-history-title");x.textContent=n("pptx.ai.historyTitle");let c=chunk2GIA6P55_cjs.mo(t,"button","pptxv-ai-history-new");c.type="button",c.append(chunk2GIA6P55_cjs.Bo(t,"plus"),t.createTextNode(n("pptx.ai.newChat"))),h.append(x,c);let p=chunk2GIA6P55_cjs.mo(t,"div","pptxv-ai-history-body"),m=chunk2GIA6P55_cjs.mo(t,"p","pptxv-ai-history-hint");m.textContent=n("pptx.ai.historyHint"),a.append(h,p,m);let l=chunk2GIA6P55_cjs.do({deckId:o.deckId,store:o.store,getMessages:o.getMessages,setMessages:o.setMessages,untitledLabel:n("pptx.ai.untitledChat"),onChatsChanged:()=>s()});function s(){p.replaceChildren();let f=l.chats();if(f.length===0){let d=chunk2GIA6P55_cjs.mo(t,"p","pptxv-ai-history-empty");d.textContent=n("pptx.ai.historyEmpty"),p.appendChild(d);return}let C=chunk2GIA6P55_cjs.mo(t,"ul","pptxv-ai-history-list");for(let d of f){let y=chunk2GIA6P55_cjs.mo(t,"li","pptxv-ai-history-row"),r=chunk2GIA6P55_cjs.mo(t,"button","pptxv-ai-history-resume");r.type="button",r.classList.toggle("is-active",d.id===l.activeChatId());let b=chunk2GIA6P55_cjs.mo(t,"span","pptxv-ai-history-text"),k=chunk2GIA6P55_cjs.mo(t,"span","pptxv-ai-history-name");k.textContent=d.title||n("pptx.ai.untitledChat");let T=chunk2GIA6P55_cjs.mo(t,"span","pptxv-ai-history-meta");T.textContent=n("pptx.ai.messageCount",{count:d.messageCount}),b.append(k,T),r.append(chunk2GIA6P55_cjs.Bo(t,"comment"),b),r.addEventListener("click",()=>{l.resumeChat(d.id),a.hidden=true;});let P=chunk2GIA6P55_cjs.mo(t,"button","pptxv-ai-history-delete");P.type="button",P.title=n("pptx.ai.deleteChat"),P.setAttribute("aria-label",n("pptx.ai.deleteChat")),P.appendChild(chunk2GIA6P55_cjs.Bo(t,"trash")),P.addEventListener("click",()=>{l.deleteChat(d.id);}),y.append(r,P),C.appendChild(y);}p.appendChild(C);}s(),i.addEventListener("click",()=>{a.hidden=!a.hidden;}),c.addEventListener("click",()=>{l.newChat(),a.hidden=true;});let g=f=>{a.hidden||!(f.target instanceof Node)||!a.contains(f.target)&&!i.contains(f.target)&&(a.hidden=true);};return t.addEventListener("mousedown",g),{button:i,el:a,notifyMessagesChanged:()=>l.notifyMessagesChanged(),destroy(){t.removeEventListener("mousedown",g),l.dispose(),i.remove(),a.remove();}}}var _={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 W(o,t,n){let i=t.state==="output-error",a=t.state==="output-available",h=!i&&!a,x=chunk2GIA6P55_cjs.io(t.toolName,t.input,h?"present":"past"),c=chunk2GIA6P55_cjs.mo(o,"div","pptxv-ai-tool"),p=chunk2GIA6P55_cjs.mo(o,"div","pptxv-ai-tool-head"),m=chunk2GIA6P55_cjs.Bo(o,_[x.icon]??"wrench");m.classList.add("pptxv-ai-tool-icon");let l=chunk2GIA6P55_cjs.mo(o,"span","pptxv-ai-tool-name");l.textContent=x.label;let s=chunk2GIA6P55_cjs.mo(o,"span","pptxv-ai-tool-state");if(i?(s.classList.add("is-error"),s.append(chunk2GIA6P55_cjs.Bo(o,"alert"),o.createTextNode(n("pptx.ai.toolFailed")))):a?(s.classList.add("is-done"),s.append(chunk2GIA6P55_cjs.Bo(o,"check"),o.createTextNode(n("pptx.ai.toolDone")))):(s.classList.add("is-running"),s.textContent=n("pptx.ai.toolRunning")),p.append(m,l,s),c.appendChild(p),i&&t.errorText){let f=chunk2GIA6P55_cjs.mo(o,"div","pptxv-ai-tool-error");f.textContent=t.errorText,c.appendChild(f);}let g=chunk2GIA6P55_cjs.ho(t.input);if(g){let f=chunk2GIA6P55_cjs.mo(o,"details","pptxv-ai-tool-details"),C=chunk2GIA6P55_cjs.mo(o,"summary");C.textContent=n("pptx.ai.toolDetails");let d=chunk2GIA6P55_cjs.mo(o,"div","pptxv-ai-tool-raw");d.textContent=`${chunk2GIA6P55_cjs.go(t.toolName)}: ${g}`,f.append(C,d),c.appendChild(f);}return c}function q(o,t,n,i){t.replaceChildren();for(let a of n){if(a.role==="system")continue;let h=a.role==="user",x=chunk2GIA6P55_cjs.Xn(a);if(x.length===0&&!h)continue;let c=chunk2GIA6P55_cjs.mo(o,"div",`pptxv-ai-msg pptxv-ai-msg-${a.role}`),p=chunk2GIA6P55_cjs.mo(o,"div","pptxv-ai-msg-avatar");p.setAttribute("aria-label",i(h?"pptx.ai.you":"pptx.ai.assistant")),p.appendChild(chunk2GIA6P55_cjs.Bo(o,h?"comment":"sparkles"));let m=chunk2GIA6P55_cjs.mo(o,"div","pptxv-ai-msg-body");for(let l of x)if(l.kind==="text"){let s=chunk2GIA6P55_cjs.mo(o,"div","pptxv-ai-msg-text");s.textContent=l.text,m.appendChild(s);}else m.appendChild(W(o,l,i));c.append(p,m),t.appendChild(c);}}function G(o,t,n,i,a){if(t.replaceChildren(),t.hidden=n.length===0,n.length===0)return;let h=chunk2GIA6P55_cjs.mo(o,"div","pptxv-ai-proposals-header"),x=chunk2GIA6P55_cjs.mo(o,"span","pptxv-ai-proposals-title");if(x.textContent=i("pptx.ai.pendingChanges",{count:n.length}),h.appendChild(x),n.length>1){let c=chunk2GIA6P55_cjs.mo(o,"button","pptxv-ai-proposal-btn is-accept-all");c.type="button",c.textContent=i("pptx.ai.acceptAll"),c.addEventListener("click",()=>a.acceptAll()),h.appendChild(c);}t.appendChild(h);for(let c of n)t.appendChild(tt(o,c,i,a));}function tt(o,t,n,i){let a=chunk2GIA6P55_cjs.mo(o,"div","pptxv-ai-proposal");a.dataset.proposalId=t.id;let h=chunk2GIA6P55_cjs.mo(o,"div","pptxv-ai-proposal-eyebrow");h.textContent=n("pptx.ai.proposedChange"),a.appendChild(h);let x=chunk2GIA6P55_cjs.mo(o,"div","pptxv-ai-proposal-label");if(x.textContent=t.label,a.appendChild(x),t.summary.length>0){let l=chunk2GIA6P55_cjs.mo(o,"ul","pptxv-ai-proposal-summary");for(let s of t.summary){let g=chunk2GIA6P55_cjs.mo(o,"li");g.textContent=chunk2GIA6P55_cjs.Un(s),l.appendChild(g);}a.appendChild(l);}let c=chunk2GIA6P55_cjs.mo(o,"div","pptxv-ai-proposal-actions"),p=chunk2GIA6P55_cjs.mo(o,"button","pptxv-ai-proposal-btn is-accept");p.type="button",p.append(chunk2GIA6P55_cjs.Bo(o,"check"),o.createTextNode(n("pptx.ai.accept"))),p.addEventListener("click",()=>i.accept(t.id));let m=chunk2GIA6P55_cjs.mo(o,"button","pptxv-ai-proposal-btn is-reject");return m.type="button",m.append(chunk2GIA6P55_cjs.Bo(o,"close"),o.createTextNode(n("pptx.ai.reject"))),m.addEventListener("click",()=>i.reject(t.id)),c.append(p,m),a.appendChild(c),a}async function wt(o){let{doc:t,host:n,t:i}=o;n.replaceChildren();let a=chunk2GIA6P55_cjs.mo(t,"div","pptxv-ai-header"),h=chunk2GIA6P55_cjs.mo(t,"span","pptxv-ai-title");h.textContent=i("pptx.ai.title");let x=chunk2GIA6P55_cjs.mo(t,"button","pptxv-ai-close");x.type="button",x.title=i("pptx.ai.close"),x.setAttribute("aria-label",i("pptx.ai.close")),x.appendChild(chunk2GIA6P55_cjs.Bo(t,"close")),x.addEventListener("click",()=>o.onClose?.()),a.append(chunk2GIA6P55_cjs.Bo(t,"sparkles"),h,x);let c,p=o.controller,m=p?K({doc:t,t:i,controller:p,getSlides:()=>o.bridge.getSlides(),onSendDirective:u=>{c?.sendMessage(u);}}):null,l=chunk2GIA6P55_cjs.mo(t,"div","pptxv-ai-messages");l.setAttribute("role","log"),l.setAttribute("aria-live","polite");let s=chunk2GIA6P55_cjs.mo(t,"div","pptxv-ai-empty");s.textContent=i("pptx.ai.emptyHint"),l.appendChild(s);let g=chunk2GIA6P55_cjs.mo(t,"div","pptxv-ai-proposals");g.hidden=true;let f=chunk2GIA6P55_cjs.mo(t,"div","pptxv-ai-error");f.setAttribute("role","alert"),f.hidden=true;let C=chunk2GIA6P55_cjs.mo(t,"form","pptxv-ai-composer"),d=chunk2GIA6P55_cjs.mo(t,"textarea","pptxv-ai-input");d.rows=2,d.placeholder=i("pptx.ai.placeholder"),d.setAttribute("aria-label",i("pptx.ai.placeholder"));let y=chunk2GIA6P55_cjs.mo(t,"button","pptxv-ai-send");y.type="submit",y.setAttribute("aria-label",i("pptx.ai.send")),y.appendChild(chunk2GIA6P55_cjs.Bo(t,"send")),C.append(d,y),n.append(a,...m?[m.el]:[],l,g,f,C);try{c=await(o.createChat??chunk2GIA6P55_cjs.eo)({bridge:o.bridge,config:o.config});}catch{return s.textContent=i("pptx.ai.unavailableTitle"),d.disabled=true,y.disabled=true,m?.destroy(),{destroy:()=>n.replaceChildren()}}let r=c,b=O({doc:t,t:i,deckId:chunk2GIA6P55_cjs.co(o.bridge),store:o.historyStore,getMessages:()=>r.getSnapshot().messages,setMessages:u=>r.setMessages(u)});a.insertBefore(b.button,x),n.appendChild(b.el);let k=r.subscribe(()=>b.notifyMessagesChanged()),T=new Set,P=u=>{if(!p)return;let A=u.messages.flatMap(Y=>chunk2GIA6P55_cjs.Xn(Y).filter(Z=>Z.kind==="tool")).at(-1);if(!A||A.kind!=="tool"||A.state==="input-streaming"||T.has(A.toolCallId))return;T.add(A.toolCallId);let L=chunk2GIA6P55_cjs.jo(A.toolName,A.input);L&&L.slideIndex!==void 0&&o.goToSlide?.(L.slideIndex),p.flashToolTarget(L);},M=u=>{q(t,l,u.messages,i),s.hidden=u.messages.length>0,u.messages.length===0&&l.appendChild(s),G(t,g,r.proposals.list(),i,{accept:A=>{p?.flashToolTarget(null),r.proposals.apply(A),M(r.getSnapshot());},reject:A=>{r.proposals.revert(A),M(r.getSnapshot());},acceptAll:()=>{p?.flashToolTarget(null),r.proposals.acceptAll(),M(r.getSnapshot());}});let w=u.status==="submitted"||u.status==="streaming";n.classList.toggle("is-busy",w),y.setAttribute("aria-label",i(w?"pptx.ai.stop":"pptx.ai.send")),f.hidden=!u.error,f.textContent=u.error?i("pptx.ai.errorPrefix"):"",l.scrollTop=l.scrollHeight,P(u);},S=()=>{if(n.classList.contains("is-busy")){r.stop();return}let u=d.value.trim();u&&(d.value="",r.sendMessage(u));};C.addEventListener("submit",u=>{u.preventDefault(),S();}),d.addEventListener("keydown",u=>{u.key==="Enter"&&!u.shiftKey&&(u.preventDefault(),S());});let I=p?.getPrefill().nonce??0,J=()=>{if(!p)return;let u=p.getPrefill();u.nonce!==I&&(I=u.nonce,d.value=u.text,d.focus());},Q=p?.subscribe(J),X=r.subscribe(M);return M(r.getSnapshot()),{changeAnimator:r.changeAnimator,destroy(){X(),k(),b.destroy(),Q?.(),m?.destroy(),n.replaceChildren();}}}exports.createAiPanel=wt;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {mo,Bo,eo,co,do as _do,Xn,jo,$n,ao,bo,io,ho,go,Un}from'./chunk-KYE4M4LZ.js';import'./chunk-62D2TNHX.js';function K(o){let{doc:t,t:n,controller:i}=o,a=mo(t,"div","pptxv-ai-focus"),h=(p,m,l)=>{let s=mo(t,"button","pptxv-ai-focus-btn");return s.type="button",s.title=m,s.setAttribute("aria-label",m),s.appendChild(Bo(t,p)),s.addEventListener("click",l),s},x=()=>{a.replaceChildren();let p=i.getEffectiveTargets(),m=i.hasPicks(),l=i.isPinned(),s=i.isPicking(),g=mo(t,"div","pptxv-ai-focus-row"),f=mo(t,"span","pptxv-ai-focus-label");f.textContent=n("pptx.ai.focusScope"),g.appendChild(f);for(let r of $n(p,o.getSlides())){let b=mo(t,"span","pptxv-ai-focus-chip");(m||l)&&b.classList.add("is-strong"),b.title=r.title,b.textContent=r.label,g.appendChild(b);}if(l){let r=mo(t,"span","pptxv-ai-focus-pinned");r.textContent=n("pptx.ai.pinnedFocus"),g.appendChild(r);}let C=mo(t,"div","pptxv-ai-focus-actions"),d=ao(p,o.getSlides());if(d){let r=mo(t,"button","pptxv-ai-focus-merge");r.type="button",r.append(Bo(t,"git-merge"),t.createTextNode(n("pptx.ai.mergeSelectedTables"))),r.addEventListener("click",()=>o.onSendDirective(bo(d.slideIndex,d.elementIdA,d.elementIdB))),C.appendChild(r);}let y=h("crosshair",n("pptx.ai.pickElement"),()=>s?i.stopPicking():i.startPicking());if(y.setAttribute("aria-pressed",String(s)),y.classList.toggle("is-active",s),C.appendChild(y),m?C.appendChild(h("close",n("pptx.ai.pickClear"),()=>i.clearPicks())):l?C.appendChild(h("pin-off",n("pptx.ai.clearFocus"),()=>i.clearPinnedFocus())):C.appendChild(h("pin",n("pptx.ai.pinFocus"),()=>i.pinFocus())),g.appendChild(C),a.appendChild(g),s){let r=mo(t,"div","pptxv-ai-focus-pick"),b=Bo(t,"crosshair");b.classList.add("pptxv-ai-focus-pick-icon");let k=mo(t,"span","pptxv-ai-focus-pick-hint");k.textContent=n("pptx.ai.pickElementHint");let T=mo(t,"button","pptxv-ai-focus-pick-done");T.type="button",T.textContent=n("pptx.ai.pickDone"),T.addEventListener("click",()=>i.stopPicking()),r.append(b,k,T),a.appendChild(r);}},c=i.subscribe(x);return x(),{el:a,destroy(){c(),a.remove();}}}function O(o){let{doc:t,t:n}=o,i=mo(t,"button","pptxv-ai-chats");i.type="button",i.append(Bo(t,"history"),t.createTextNode(n("pptx.ai.chats")));let a=mo(t,"div","pptxv-ai-history");a.hidden=true;let h=mo(t,"div","pptxv-ai-history-head"),x=mo(t,"span","pptxv-ai-history-title");x.textContent=n("pptx.ai.historyTitle");let c=mo(t,"button","pptxv-ai-history-new");c.type="button",c.append(Bo(t,"plus"),t.createTextNode(n("pptx.ai.newChat"))),h.append(x,c);let p=mo(t,"div","pptxv-ai-history-body"),m=mo(t,"p","pptxv-ai-history-hint");m.textContent=n("pptx.ai.historyHint"),a.append(h,p,m);let l=_do({deckId:o.deckId,store:o.store,getMessages:o.getMessages,setMessages:o.setMessages,untitledLabel:n("pptx.ai.untitledChat"),onChatsChanged:()=>s()});function s(){p.replaceChildren();let f=l.chats();if(f.length===0){let d=mo(t,"p","pptxv-ai-history-empty");d.textContent=n("pptx.ai.historyEmpty"),p.appendChild(d);return}let C=mo(t,"ul","pptxv-ai-history-list");for(let d of f){let y=mo(t,"li","pptxv-ai-history-row"),r=mo(t,"button","pptxv-ai-history-resume");r.type="button",r.classList.toggle("is-active",d.id===l.activeChatId());let b=mo(t,"span","pptxv-ai-history-text"),k=mo(t,"span","pptxv-ai-history-name");k.textContent=d.title||n("pptx.ai.untitledChat");let T=mo(t,"span","pptxv-ai-history-meta");T.textContent=n("pptx.ai.messageCount",{count:d.messageCount}),b.append(k,T),r.append(Bo(t,"comment"),b),r.addEventListener("click",()=>{l.resumeChat(d.id),a.hidden=true;});let P=mo(t,"button","pptxv-ai-history-delete");P.type="button",P.title=n("pptx.ai.deleteChat"),P.setAttribute("aria-label",n("pptx.ai.deleteChat")),P.appendChild(Bo(t,"trash")),P.addEventListener("click",()=>{l.deleteChat(d.id);}),y.append(r,P),C.appendChild(y);}p.appendChild(C);}s(),i.addEventListener("click",()=>{a.hidden=!a.hidden;}),c.addEventListener("click",()=>{l.newChat(),a.hidden=true;});let g=f=>{a.hidden||!(f.target instanceof Node)||!a.contains(f.target)&&!i.contains(f.target)&&(a.hidden=true);};return t.addEventListener("mousedown",g),{button:i,el:a,notifyMessagesChanged:()=>l.notifyMessagesChanged(),destroy(){t.removeEventListener("mousedown",g),l.dispose(),i.remove(),a.remove();}}}var _={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 W(o,t,n){let i=t.state==="output-error",a=t.state==="output-available",h=!i&&!a,x=io(t.toolName,t.input,h?"present":"past"),c=mo(o,"div","pptxv-ai-tool"),p=mo(o,"div","pptxv-ai-tool-head"),m=Bo(o,_[x.icon]??"wrench");m.classList.add("pptxv-ai-tool-icon");let l=mo(o,"span","pptxv-ai-tool-name");l.textContent=x.label;let s=mo(o,"span","pptxv-ai-tool-state");if(i?(s.classList.add("is-error"),s.append(Bo(o,"alert"),o.createTextNode(n("pptx.ai.toolFailed")))):a?(s.classList.add("is-done"),s.append(Bo(o,"check"),o.createTextNode(n("pptx.ai.toolDone")))):(s.classList.add("is-running"),s.textContent=n("pptx.ai.toolRunning")),p.append(m,l,s),c.appendChild(p),i&&t.errorText){let f=mo(o,"div","pptxv-ai-tool-error");f.textContent=t.errorText,c.appendChild(f);}let g=ho(t.input);if(g){let f=mo(o,"details","pptxv-ai-tool-details"),C=mo(o,"summary");C.textContent=n("pptx.ai.toolDetails");let d=mo(o,"div","pptxv-ai-tool-raw");d.textContent=`${go(t.toolName)}: ${g}`,f.append(C,d),c.appendChild(f);}return c}function q(o,t,n,i){t.replaceChildren();for(let a of n){if(a.role==="system")continue;let h=a.role==="user",x=Xn(a);if(x.length===0&&!h)continue;let c=mo(o,"div",`pptxv-ai-msg pptxv-ai-msg-${a.role}`),p=mo(o,"div","pptxv-ai-msg-avatar");p.setAttribute("aria-label",i(h?"pptx.ai.you":"pptx.ai.assistant")),p.appendChild(Bo(o,h?"comment":"sparkles"));let m=mo(o,"div","pptxv-ai-msg-body");for(let l of x)if(l.kind==="text"){let s=mo(o,"div","pptxv-ai-msg-text");s.textContent=l.text,m.appendChild(s);}else m.appendChild(W(o,l,i));c.append(p,m),t.appendChild(c);}}function G(o,t,n,i,a){if(t.replaceChildren(),t.hidden=n.length===0,n.length===0)return;let h=mo(o,"div","pptxv-ai-proposals-header"),x=mo(o,"span","pptxv-ai-proposals-title");if(x.textContent=i("pptx.ai.pendingChanges",{count:n.length}),h.appendChild(x),n.length>1){let c=mo(o,"button","pptxv-ai-proposal-btn is-accept-all");c.type="button",c.textContent=i("pptx.ai.acceptAll"),c.addEventListener("click",()=>a.acceptAll()),h.appendChild(c);}t.appendChild(h);for(let c of n)t.appendChild(tt(o,c,i,a));}function tt(o,t,n,i){let a=mo(o,"div","pptxv-ai-proposal");a.dataset.proposalId=t.id;let h=mo(o,"div","pptxv-ai-proposal-eyebrow");h.textContent=n("pptx.ai.proposedChange"),a.appendChild(h);let x=mo(o,"div","pptxv-ai-proposal-label");if(x.textContent=t.label,a.appendChild(x),t.summary.length>0){let l=mo(o,"ul","pptxv-ai-proposal-summary");for(let s of t.summary){let g=mo(o,"li");g.textContent=Un(s),l.appendChild(g);}a.appendChild(l);}let c=mo(o,"div","pptxv-ai-proposal-actions"),p=mo(o,"button","pptxv-ai-proposal-btn is-accept");p.type="button",p.append(Bo(o,"check"),o.createTextNode(n("pptx.ai.accept"))),p.addEventListener("click",()=>i.accept(t.id));let m=mo(o,"button","pptxv-ai-proposal-btn is-reject");return m.type="button",m.append(Bo(o,"close"),o.createTextNode(n("pptx.ai.reject"))),m.addEventListener("click",()=>i.reject(t.id)),c.append(p,m),a.appendChild(c),a}async function wt(o){let{doc:t,host:n,t:i}=o;n.replaceChildren();let a=mo(t,"div","pptxv-ai-header"),h=mo(t,"span","pptxv-ai-title");h.textContent=i("pptx.ai.title");let x=mo(t,"button","pptxv-ai-close");x.type="button",x.title=i("pptx.ai.close"),x.setAttribute("aria-label",i("pptx.ai.close")),x.appendChild(Bo(t,"close")),x.addEventListener("click",()=>o.onClose?.()),a.append(Bo(t,"sparkles"),h,x);let c,p=o.controller,m=p?K({doc:t,t:i,controller:p,getSlides:()=>o.bridge.getSlides(),onSendDirective:u=>{c?.sendMessage(u);}}):null,l=mo(t,"div","pptxv-ai-messages");l.setAttribute("role","log"),l.setAttribute("aria-live","polite");let s=mo(t,"div","pptxv-ai-empty");s.textContent=i("pptx.ai.emptyHint"),l.appendChild(s);let g=mo(t,"div","pptxv-ai-proposals");g.hidden=true;let f=mo(t,"div","pptxv-ai-error");f.setAttribute("role","alert"),f.hidden=true;let C=mo(t,"form","pptxv-ai-composer"),d=mo(t,"textarea","pptxv-ai-input");d.rows=2,d.placeholder=i("pptx.ai.placeholder"),d.setAttribute("aria-label",i("pptx.ai.placeholder"));let y=mo(t,"button","pptxv-ai-send");y.type="submit",y.setAttribute("aria-label",i("pptx.ai.send")),y.appendChild(Bo(t,"send")),C.append(d,y),n.append(a,...m?[m.el]:[],l,g,f,C);try{c=await(o.createChat??eo)({bridge:o.bridge,config:o.config});}catch{return s.textContent=i("pptx.ai.unavailableTitle"),d.disabled=true,y.disabled=true,m?.destroy(),{destroy:()=>n.replaceChildren()}}let r=c,b=O({doc:t,t:i,deckId:co(o.bridge),store:o.historyStore,getMessages:()=>r.getSnapshot().messages,setMessages:u=>r.setMessages(u)});a.insertBefore(b.button,x),n.appendChild(b.el);let k=r.subscribe(()=>b.notifyMessagesChanged()),T=new Set,P=u=>{if(!p)return;let A=u.messages.flatMap(Y=>Xn(Y).filter(Z=>Z.kind==="tool")).at(-1);if(!A||A.kind!=="tool"||A.state==="input-streaming"||T.has(A.toolCallId))return;T.add(A.toolCallId);let L=jo(A.toolName,A.input);L&&L.slideIndex!==void 0&&o.goToSlide?.(L.slideIndex),p.flashToolTarget(L);},M=u=>{q(t,l,u.messages,i),s.hidden=u.messages.length>0,u.messages.length===0&&l.appendChild(s),G(t,g,r.proposals.list(),i,{accept:A=>{p?.flashToolTarget(null),r.proposals.apply(A),M(r.getSnapshot());},reject:A=>{r.proposals.revert(A),M(r.getSnapshot());},acceptAll:()=>{p?.flashToolTarget(null),r.proposals.acceptAll(),M(r.getSnapshot());}});let w=u.status==="submitted"||u.status==="streaming";n.classList.toggle("is-busy",w),y.setAttribute("aria-label",i(w?"pptx.ai.stop":"pptx.ai.send")),f.hidden=!u.error,f.textContent=u.error?i("pptx.ai.errorPrefix"):"",l.scrollTop=l.scrollHeight,P(u);},S=()=>{if(n.classList.contains("is-busy")){r.stop();return}let u=d.value.trim();u&&(d.value="",r.sendMessage(u));};C.addEventListener("submit",u=>{u.preventDefault(),S();}),d.addEventListener("keydown",u=>{u.key==="Enter"&&!u.shiftKey&&(u.preventDefault(),S());});let I=p?.getPrefill().nonce??0,J=()=>{if(!p)return;let u=p.getPrefill();u.nonce!==I&&(I=u.nonce,d.value=u.text,d.focus());},Q=p?.subscribe(J),X=r.subscribe(M);return M(r.getSnapshot()),{changeAnimator:r.changeAnimator,destroy(){X(),k(),b.destroy(),Q?.(),m?.destroy(),n.replaceChildren();}}}export{wt as createAiPanel};
|