pptx-vanilla-viewer 2.16.7 → 2.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +53 -0
- package/README.md +25 -2
- package/dist/ai-panel-3SXCA56Y.cjs +1 -0
- package/dist/ai-panel-QMFZSLXF.js +1 -0
- package/dist/{chunk-W2TZKEZG.js → chunk-MVGP6Q7E.js} +306 -302
- package/dist/{chunk-TC3MIUY5.cjs → chunk-SLYBMMV5.cjs} +306 -302
- package/dist/index.cjs +65 -65
- package/dist/index.d.ts +46 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +64 -64
- package/package.json +1 -1
- package/dist/ai-panel-AHZWAKKU.cjs +0 -1
- package/dist/ai-panel-DUWETVD3.js +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,59 @@ 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.0](https://github.com/ChristopherVR/pptx-viewer/releases/tag/pptx-vanilla-viewer@2.17.0) - 2026-09-13
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
- **shared:** Add configurable viewport fit options (by @Sudhansh6) ([93e3218](https://github.com/ChristopherVR/pptx-viewer/commit/93e3218de54ce8d153761e2fba83f3558fc3051b))
|
|
15
|
+
- **vanilla:** Add configurable viewport fit options (by @Sudhansh6) ([b29ca1a](https://github.com/ChristopherVR/pptx-viewer/commit/b29ca1a8c4fe5a3d55dbf17225002c9735c112f9))
|
|
16
|
+
- **shared:** Expose public element insertion across viewers (by @Sudhansh6) ([2701047](https://github.com/ChristopherVR/pptx-viewer/commit/2701047d5011b5d7ce8408009addc1dc31f6e3f7))
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
- **core:** Preserve empty paragraph insertion formatting (by @Sudhansh6) ([121f6bf](https://github.com/ChristopherVR/pptx-viewer/commit/121f6bf9f64a29ab07e07b5d4f042a4b075d7876))
|
|
21
|
+
- **shared:** Preserve empty paragraph insertion formatting (by @Sudhansh6) ([b34d0f5](https://github.com/ChristopherVR/pptx-viewer/commit/b34d0f5ab9879e02f1de85c0e50b15f3947735c3))
|
|
22
|
+
- **vanilla:** Preserve empty paragraph insertion formatting (by @Sudhansh6) ([9fea926](https://github.com/ChristopherVR/pptx-viewer/commit/9fea926b0a36a08692cedee6708f1c7add012406))
|
|
23
|
+
- **vanilla:** Preserve split paragraph boundaries through native undo (by @Sudhansh6) ([9d7ba3d](https://github.com/ChristopherVR/pptx-viewer/commit/9d7ba3de8347180ab26d73ca86a5f0a48353a803))
|
|
24
|
+
- **shared:** Continue inserted paragraphs from the local list (by @Sudhansh6) ([78b8226](https://github.com/ChristopherVR/pptx-viewer/commit/78b82261a320b93052627ec9e6e460c4845f6f32))
|
|
25
|
+
- **shared:** Leave empty clipboard paste shortcuts unclaimed (by @Sudhansh6) ([aec446f](https://github.com/ChristopherVR/pptx-viewer/commit/aec446f7f36371ad2f9c1cf3e68b7aaeb4f2cc28))
|
|
26
|
+
|
|
27
|
+
### Other
|
|
28
|
+
|
|
29
|
+
- Retain empty paragraph styles with source alignment (by @Sudhansh6) ([d979cd2](https://github.com/ChristopherVR/pptx-viewer/commit/d979cd25b7c05cef0fc4d4501c39d2bb11e572e0))
|
|
30
|
+
- Integrate semantic list commands with empty paragraph formatting (by @Sudhansh6) ([c5d9a6f](https://github.com/ChristopherVR/pptx-viewer/commit/c5d9a6f4f52c44180111c1f5fca0f10299dce47a))
|
|
31
|
+
- Sync main font and SmartArt fixes (by @Sudhansh6) ([f2066eb](https://github.com/ChristopherVR/pptx-viewer/commit/f2066eb87b62884cadd77593e8b36426398c3312))
|
|
32
|
+
- Sync main paragraph and history fixes (by @Sudhansh6) ([a18a2d7](https://github.com/ChristopherVR/pptx-viewer/commit/a18a2d7fe2bccf7d8c49b72d7a80087d423d1da0))
|
|
33
|
+
- Sync viewport fit changes from main (by @Sudhansh6) ([3c3c0bd](https://github.com/ChristopherVR/pptx-viewer/commit/3c3c0bdb2f88648dd20ffac9b6fd5a691741253d))
|
|
34
|
+
- Sync public insertion with viewport fit API (by @Sudhansh6) ([47df3db](https://github.com/ChristopherVR/pptx-viewer/commit/47df3db6bb7bb6bbee06e36c9ff9565b2fc61252))
|
|
35
|
+
- Sync public insertion with empty paragraph formatting (by @Sudhansh6) ([d1ad9c9](https://github.com/ChristopherVR/pptx-viewer/commit/d1ad9c9562313085cab62f3b9f9fa0abc6d0fa1f))
|
|
36
|
+
|
|
37
|
+
### Documentation
|
|
38
|
+
|
|
39
|
+
- Move viewport fitting into developer guides (by @Sudhansh6) ([60707eb](https://github.com/ChristopherVR/pptx-viewer/commit/60707ebf8f261779b2ebfa41ff0741267a672bd3))
|
|
40
|
+
|
|
41
|
+
## [2.16.7](https://github.com/ChristopherVR/pptx-viewer/releases/tag/pptx-vanilla-viewer@2.16.7) - 2026-09-13
|
|
42
|
+
|
|
43
|
+
### Bug Fixes
|
|
44
|
+
|
|
45
|
+
- **vanilla:** Settle SmartArt node edits before closing (by @Sudhansh6) ([b2614f1](https://github.com/ChristopherVR/pptx-viewer/commit/b2614f119aed855d120d98aa037b5eac0e912830))
|
|
46
|
+
- **shared:** Preserve paragraph properties across text insertion (by @Sudhansh6) ([624c880](https://github.com/ChristopherVR/pptx-viewer/commit/624c880ed0a1396b91a4203334bb59a409b9eec0))
|
|
47
|
+
- **core:** Preserve run styles after text-only edits (by @Sudhansh6) ([3cb843c](https://github.com/ChristopherVR/pptx-viewer/commit/3cb843c0a3bf609da00007036ec601274214890c))
|
|
48
|
+
- **core:** Size percentage bullets from the first text run (by @Sudhansh6) ([51e26e1](https://github.com/ChristopherVR/pptx-viewer/commit/51e26e1ace134a48ae7eb74207ac12a11ee44ea1))
|
|
49
|
+
|
|
50
|
+
### Refactor
|
|
51
|
+
|
|
52
|
+
- **core:** Expose numbering sequence for paragraph edits (by @Sudhansh6) ([a27fb46](https://github.com/ChristopherVR/pptx-viewer/commit/a27fb465f8b7bbb9b373106fbc3051709329a5bf))
|
|
53
|
+
|
|
54
|
+
### Testing
|
|
55
|
+
|
|
56
|
+
- **vanilla:** Cover paragraph insertion and edit history (by @Sudhansh6) ([18ae358](https://github.com/ChristopherVR/pptx-viewer/commit/18ae358f3f08247dbcc14393716330099a57055d))
|
|
57
|
+
|
|
58
|
+
### Chores
|
|
59
|
+
|
|
60
|
+
- Merge updated SmartArt geometry coverage (by @Sudhansh6) ([d0364a9](https://github.com/ChristopherVR/pptx-viewer/commit/d0364a9169fc8520b91ccd73ac30962cbbf520d2))
|
|
61
|
+
- Merge main before SmartArt cancellation contribution (by @Sudhansh6) ([4581de6](https://github.com/ChristopherVR/pptx-viewer/commit/4581de613b294edc07534bd4721c0e1e1afe2ebb))
|
|
62
|
+
|
|
10
63
|
## [2.16.6](https://github.com/ChristopherVR/pptx-viewer/releases/tag/pptx-vanilla-viewer@2.16.6) - 2026-09-12
|
|
11
64
|
|
|
12
65
|
### Bug Fixes
|
package/README.md
CHANGED
|
@@ -71,6 +71,24 @@ viewer.destroy();
|
|
|
71
71
|
|
|
72
72
|
The container should have a size (the viewer fills it: `width/height: 100%`).
|
|
73
73
|
|
|
74
|
+
### Viewport fit options
|
|
75
|
+
|
|
76
|
+
```ts
|
|
77
|
+
const viewer = createPptxViewer(container, {
|
|
78
|
+
source,
|
|
79
|
+
fitPadding: 0,
|
|
80
|
+
maxFitScale: null,
|
|
81
|
+
});
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
`fitPadding` is a per-side CSS-pixel number or `{ horizontal, vertical }`;
|
|
85
|
+
`maxFitScale` is a positive fit-factor ceiling or `null` for unlimited enlargement.
|
|
86
|
+
Omission preserves the existing 16 px fit allowance on each side, unlimited
|
|
87
|
+
enlargement, and mobile CSS padding. Explicit padding also sets the viewport's
|
|
88
|
+
physical CSS padding. Configure these options when creating the viewer; they
|
|
89
|
+
do not change document geometry, user zoom, or presentation-mode fitting.
|
|
90
|
+
See the [cross-binding defaults](../../docs/guide/viewport-fit.md).
|
|
91
|
+
|
|
74
92
|
## Options
|
|
75
93
|
|
|
76
94
|
All options are optional except the container element itself. Beyond the ones
|
|
@@ -113,8 +131,13 @@ The handle returned by `createPptxViewer` implements the shared
|
|
|
113
131
|
Svelte bindings: `getContent`, `goTo`, `undo`/`redo`, zoom and mode getters/
|
|
114
132
|
setters, `getSlides`/`getSlide`/`getActiveSlide`, `addSlide`/`deleteSlides`/
|
|
115
133
|
`duplicateSlides`/`moveSlide`/`toggleHideSlides`, `getElements`/
|
|
116
|
-
`getElementById`/`updateElement`/`deleteElements`/`duplicateElement`, and the
|
|
117
|
-
selection methods)
|
|
134
|
+
`getElementById`/`addElement`/`updateElement`/`deleteElements`/`duplicateElement`, and the
|
|
135
|
+
selection methods).
|
|
136
|
+
|
|
137
|
+
See [element insertion](https://christophervr.github.io/pptx-viewer/vanilla/api#add-element)
|
|
138
|
+
for the `addElement` contract and a core-factory example.
|
|
139
|
+
|
|
140
|
+
Additional vanilla-specific methods:
|
|
118
141
|
|
|
119
142
|
- **Loading**: `loadFile(bytesOrBlob)`, `loadUrl(url)`.
|
|
120
143
|
- **Navigation / zoom**: `next()`, `prev()`, `goToSlide(index)`,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var chunkSLYBMMV5_cjs=require('./chunk-SLYBMMV5.cjs');require('./chunk-B5PFHICE.cjs');function K(o){let{doc:t,t:n,controller:i}=o,a=chunkSLYBMMV5_cjs.lo(t,"div","pptxv-ai-focus"),h=(p,m,l)=>{let s=chunkSLYBMMV5_cjs.lo(t,"button","pptxv-ai-focus-btn");return s.type="button",s.title=m,s.setAttribute("aria-label",m),s.appendChild(chunkSLYBMMV5_cjs.Ao(t,p)),s.addEventListener("click",l),s},x=()=>{a.replaceChildren();let p=i.getEffectiveTargets(),m=i.hasPicks(),l=i.isPinned(),s=i.isPicking(),g=chunkSLYBMMV5_cjs.lo(t,"div","pptxv-ai-focus-row"),f=chunkSLYBMMV5_cjs.lo(t,"span","pptxv-ai-focus-label");f.textContent=n("pptx.ai.focusScope"),g.appendChild(f);for(let r of chunkSLYBMMV5_cjs._n(p,o.getSlides())){let b=chunkSLYBMMV5_cjs.lo(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=chunkSLYBMMV5_cjs.lo(t,"span","pptxv-ai-focus-pinned");r.textContent=n("pptx.ai.pinnedFocus"),g.appendChild(r);}let C=chunkSLYBMMV5_cjs.lo(t,"div","pptxv-ai-focus-actions"),d=chunkSLYBMMV5_cjs.$n(p,o.getSlides());if(d){let r=chunkSLYBMMV5_cjs.lo(t,"button","pptxv-ai-focus-merge");r.type="button",r.append(chunkSLYBMMV5_cjs.Ao(t,"git-merge"),t.createTextNode(n("pptx.ai.mergeSelectedTables"))),r.addEventListener("click",()=>o.onSendDirective(chunkSLYBMMV5_cjs.ao(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=chunkSLYBMMV5_cjs.lo(t,"div","pptxv-ai-focus-pick"),b=chunkSLYBMMV5_cjs.Ao(t,"crosshair");b.classList.add("pptxv-ai-focus-pick-icon");let k=chunkSLYBMMV5_cjs.lo(t,"span","pptxv-ai-focus-pick-hint");k.textContent=n("pptx.ai.pickElementHint");let T=chunkSLYBMMV5_cjs.lo(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=chunkSLYBMMV5_cjs.lo(t,"button","pptxv-ai-chats");i.type="button",i.append(chunkSLYBMMV5_cjs.Ao(t,"history"),t.createTextNode(n("pptx.ai.chats")));let a=chunkSLYBMMV5_cjs.lo(t,"div","pptxv-ai-history");a.hidden=true;let h=chunkSLYBMMV5_cjs.lo(t,"div","pptxv-ai-history-head"),x=chunkSLYBMMV5_cjs.lo(t,"span","pptxv-ai-history-title");x.textContent=n("pptx.ai.historyTitle");let c=chunkSLYBMMV5_cjs.lo(t,"button","pptxv-ai-history-new");c.type="button",c.append(chunkSLYBMMV5_cjs.Ao(t,"plus"),t.createTextNode(n("pptx.ai.newChat"))),h.append(x,c);let p=chunkSLYBMMV5_cjs.lo(t,"div","pptxv-ai-history-body"),m=chunkSLYBMMV5_cjs.lo(t,"p","pptxv-ai-history-hint");m.textContent=n("pptx.ai.historyHint"),a.append(h,p,m);let l=chunkSLYBMMV5_cjs.co({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=chunkSLYBMMV5_cjs.lo(t,"p","pptxv-ai-history-empty");d.textContent=n("pptx.ai.historyEmpty"),p.appendChild(d);return}let C=chunkSLYBMMV5_cjs.lo(t,"ul","pptxv-ai-history-list");for(let d of f){let y=chunkSLYBMMV5_cjs.lo(t,"li","pptxv-ai-history-row"),r=chunkSLYBMMV5_cjs.lo(t,"button","pptxv-ai-history-resume");r.type="button",r.classList.toggle("is-active",d.id===l.activeChatId());let b=chunkSLYBMMV5_cjs.lo(t,"span","pptxv-ai-history-text"),k=chunkSLYBMMV5_cjs.lo(t,"span","pptxv-ai-history-name");k.textContent=d.title||n("pptx.ai.untitledChat");let T=chunkSLYBMMV5_cjs.lo(t,"span","pptxv-ai-history-meta");T.textContent=n("pptx.ai.messageCount",{count:d.messageCount}),b.append(k,T),r.append(chunkSLYBMMV5_cjs.Ao(t,"comment"),b),r.addEventListener("click",()=>{l.resumeChat(d.id),a.hidden=true;});let P=chunkSLYBMMV5_cjs.lo(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(chunkSLYBMMV5_cjs.Ao(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=chunkSLYBMMV5_cjs.ho(t.toolName,t.input,h?"present":"past"),c=chunkSLYBMMV5_cjs.lo(o,"div","pptxv-ai-tool"),p=chunkSLYBMMV5_cjs.lo(o,"div","pptxv-ai-tool-head"),m=chunkSLYBMMV5_cjs.Ao(o,_[x.icon]??"wrench");m.classList.add("pptxv-ai-tool-icon");let l=chunkSLYBMMV5_cjs.lo(o,"span","pptxv-ai-tool-name");l.textContent=x.label;let s=chunkSLYBMMV5_cjs.lo(o,"span","pptxv-ai-tool-state");if(i?(s.classList.add("is-error"),s.append(chunkSLYBMMV5_cjs.Ao(o,"alert"),o.createTextNode(n("pptx.ai.toolFailed")))):a?(s.classList.add("is-done"),s.append(chunkSLYBMMV5_cjs.Ao(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=chunkSLYBMMV5_cjs.lo(o,"div","pptxv-ai-tool-error");f.textContent=t.errorText,c.appendChild(f);}let g=chunkSLYBMMV5_cjs.go(t.input);if(g){let f=chunkSLYBMMV5_cjs.lo(o,"details","pptxv-ai-tool-details"),C=chunkSLYBMMV5_cjs.lo(o,"summary");C.textContent=n("pptx.ai.toolDetails");let d=chunkSLYBMMV5_cjs.lo(o,"div","pptxv-ai-tool-raw");d.textContent=`${chunkSLYBMMV5_cjs.fo(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=chunkSLYBMMV5_cjs.Wn(a);if(x.length===0&&!h)continue;let c=chunkSLYBMMV5_cjs.lo(o,"div",`pptxv-ai-msg pptxv-ai-msg-${a.role}`),p=chunkSLYBMMV5_cjs.lo(o,"div","pptxv-ai-msg-avatar");p.setAttribute("aria-label",i(h?"pptx.ai.you":"pptx.ai.assistant")),p.appendChild(chunkSLYBMMV5_cjs.Ao(o,h?"comment":"sparkles"));let m=chunkSLYBMMV5_cjs.lo(o,"div","pptxv-ai-msg-body");for(let l of x)if(l.kind==="text"){let s=chunkSLYBMMV5_cjs.lo(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=chunkSLYBMMV5_cjs.lo(o,"div","pptxv-ai-proposals-header"),x=chunkSLYBMMV5_cjs.lo(o,"span","pptxv-ai-proposals-title");if(x.textContent=i("pptx.ai.pendingChanges",{count:n.length}),h.appendChild(x),n.length>1){let c=chunkSLYBMMV5_cjs.lo(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=chunkSLYBMMV5_cjs.lo(o,"div","pptxv-ai-proposal");a.dataset.proposalId=t.id;let h=chunkSLYBMMV5_cjs.lo(o,"div","pptxv-ai-proposal-eyebrow");h.textContent=n("pptx.ai.proposedChange"),a.appendChild(h);let x=chunkSLYBMMV5_cjs.lo(o,"div","pptxv-ai-proposal-label");if(x.textContent=t.label,a.appendChild(x),t.summary.length>0){let l=chunkSLYBMMV5_cjs.lo(o,"ul","pptxv-ai-proposal-summary");for(let s of t.summary){let g=chunkSLYBMMV5_cjs.lo(o,"li");g.textContent=chunkSLYBMMV5_cjs.Tn(s),l.appendChild(g);}a.appendChild(l);}let c=chunkSLYBMMV5_cjs.lo(o,"div","pptxv-ai-proposal-actions"),p=chunkSLYBMMV5_cjs.lo(o,"button","pptxv-ai-proposal-btn is-accept");p.type="button",p.append(chunkSLYBMMV5_cjs.Ao(o,"check"),o.createTextNode(n("pptx.ai.accept"))),p.addEventListener("click",()=>i.accept(t.id));let m=chunkSLYBMMV5_cjs.lo(o,"button","pptxv-ai-proposal-btn is-reject");return m.type="button",m.append(chunkSLYBMMV5_cjs.Ao(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=chunkSLYBMMV5_cjs.lo(t,"div","pptxv-ai-header"),h=chunkSLYBMMV5_cjs.lo(t,"span","pptxv-ai-title");h.textContent=i("pptx.ai.title");let x=chunkSLYBMMV5_cjs.lo(t,"button","pptxv-ai-close");x.type="button",x.title=i("pptx.ai.close"),x.setAttribute("aria-label",i("pptx.ai.close")),x.appendChild(chunkSLYBMMV5_cjs.Ao(t,"close")),x.addEventListener("click",()=>o.onClose?.()),a.append(chunkSLYBMMV5_cjs.Ao(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=chunkSLYBMMV5_cjs.lo(t,"div","pptxv-ai-messages");l.setAttribute("role","log"),l.setAttribute("aria-live","polite");let s=chunkSLYBMMV5_cjs.lo(t,"div","pptxv-ai-empty");s.textContent=i("pptx.ai.emptyHint"),l.appendChild(s);let g=chunkSLYBMMV5_cjs.lo(t,"div","pptxv-ai-proposals");g.hidden=true;let f=chunkSLYBMMV5_cjs.lo(t,"div","pptxv-ai-error");f.setAttribute("role","alert"),f.hidden=true;let C=chunkSLYBMMV5_cjs.lo(t,"form","pptxv-ai-composer"),d=chunkSLYBMMV5_cjs.lo(t,"textarea","pptxv-ai-input");d.rows=2,d.placeholder=i("pptx.ai.placeholder"),d.setAttribute("aria-label",i("pptx.ai.placeholder"));let y=chunkSLYBMMV5_cjs.lo(t,"button","pptxv-ai-send");y.type="submit",y.setAttribute("aria-label",i("pptx.ai.send")),y.appendChild(chunkSLYBMMV5_cjs.Ao(t,"send")),C.append(d,y),n.append(a,...m?[m.el]:[],l,g,f,C);try{c=await(o.createChat??chunkSLYBMMV5_cjs.do)({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:chunkSLYBMMV5_cjs.bo(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=>chunkSLYBMMV5_cjs.Wn(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=chunkSLYBMMV5_cjs.io(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 {lo,Ao,do as _do,bo,co,Wn,io,_n,$n,ao,ho,go,fo,Tn}from'./chunk-MVGP6Q7E.js';import'./chunk-62D2TNHX.js';function K(o){let{doc:t,t:n,controller:i}=o,a=lo(t,"div","pptxv-ai-focus"),h=(p,m,l)=>{let s=lo(t,"button","pptxv-ai-focus-btn");return s.type="button",s.title=m,s.setAttribute("aria-label",m),s.appendChild(Ao(t,p)),s.addEventListener("click",l),s},x=()=>{a.replaceChildren();let p=i.getEffectiveTargets(),m=i.hasPicks(),l=i.isPinned(),s=i.isPicking(),g=lo(t,"div","pptxv-ai-focus-row"),f=lo(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=lo(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=lo(t,"span","pptxv-ai-focus-pinned");r.textContent=n("pptx.ai.pinnedFocus"),g.appendChild(r);}let C=lo(t,"div","pptxv-ai-focus-actions"),d=$n(p,o.getSlides());if(d){let r=lo(t,"button","pptxv-ai-focus-merge");r.type="button",r.append(Ao(t,"git-merge"),t.createTextNode(n("pptx.ai.mergeSelectedTables"))),r.addEventListener("click",()=>o.onSendDirective(ao(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=lo(t,"div","pptxv-ai-focus-pick"),b=Ao(t,"crosshair");b.classList.add("pptxv-ai-focus-pick-icon");let k=lo(t,"span","pptxv-ai-focus-pick-hint");k.textContent=n("pptx.ai.pickElementHint");let T=lo(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=lo(t,"button","pptxv-ai-chats");i.type="button",i.append(Ao(t,"history"),t.createTextNode(n("pptx.ai.chats")));let a=lo(t,"div","pptxv-ai-history");a.hidden=true;let h=lo(t,"div","pptxv-ai-history-head"),x=lo(t,"span","pptxv-ai-history-title");x.textContent=n("pptx.ai.historyTitle");let c=lo(t,"button","pptxv-ai-history-new");c.type="button",c.append(Ao(t,"plus"),t.createTextNode(n("pptx.ai.newChat"))),h.append(x,c);let p=lo(t,"div","pptxv-ai-history-body"),m=lo(t,"p","pptxv-ai-history-hint");m.textContent=n("pptx.ai.historyHint"),a.append(h,p,m);let l=co({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=lo(t,"p","pptxv-ai-history-empty");d.textContent=n("pptx.ai.historyEmpty"),p.appendChild(d);return}let C=lo(t,"ul","pptxv-ai-history-list");for(let d of f){let y=lo(t,"li","pptxv-ai-history-row"),r=lo(t,"button","pptxv-ai-history-resume");r.type="button",r.classList.toggle("is-active",d.id===l.activeChatId());let b=lo(t,"span","pptxv-ai-history-text"),k=lo(t,"span","pptxv-ai-history-name");k.textContent=d.title||n("pptx.ai.untitledChat");let T=lo(t,"span","pptxv-ai-history-meta");T.textContent=n("pptx.ai.messageCount",{count:d.messageCount}),b.append(k,T),r.append(Ao(t,"comment"),b),r.addEventListener("click",()=>{l.resumeChat(d.id),a.hidden=true;});let P=lo(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(Ao(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=ho(t.toolName,t.input,h?"present":"past"),c=lo(o,"div","pptxv-ai-tool"),p=lo(o,"div","pptxv-ai-tool-head"),m=Ao(o,_[x.icon]??"wrench");m.classList.add("pptxv-ai-tool-icon");let l=lo(o,"span","pptxv-ai-tool-name");l.textContent=x.label;let s=lo(o,"span","pptxv-ai-tool-state");if(i?(s.classList.add("is-error"),s.append(Ao(o,"alert"),o.createTextNode(n("pptx.ai.toolFailed")))):a?(s.classList.add("is-done"),s.append(Ao(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=lo(o,"div","pptxv-ai-tool-error");f.textContent=t.errorText,c.appendChild(f);}let g=go(t.input);if(g){let f=lo(o,"details","pptxv-ai-tool-details"),C=lo(o,"summary");C.textContent=n("pptx.ai.toolDetails");let d=lo(o,"div","pptxv-ai-tool-raw");d.textContent=`${fo(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=Wn(a);if(x.length===0&&!h)continue;let c=lo(o,"div",`pptxv-ai-msg pptxv-ai-msg-${a.role}`),p=lo(o,"div","pptxv-ai-msg-avatar");p.setAttribute("aria-label",i(h?"pptx.ai.you":"pptx.ai.assistant")),p.appendChild(Ao(o,h?"comment":"sparkles"));let m=lo(o,"div","pptxv-ai-msg-body");for(let l of x)if(l.kind==="text"){let s=lo(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=lo(o,"div","pptxv-ai-proposals-header"),x=lo(o,"span","pptxv-ai-proposals-title");if(x.textContent=i("pptx.ai.pendingChanges",{count:n.length}),h.appendChild(x),n.length>1){let c=lo(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=lo(o,"div","pptxv-ai-proposal");a.dataset.proposalId=t.id;let h=lo(o,"div","pptxv-ai-proposal-eyebrow");h.textContent=n("pptx.ai.proposedChange"),a.appendChild(h);let x=lo(o,"div","pptxv-ai-proposal-label");if(x.textContent=t.label,a.appendChild(x),t.summary.length>0){let l=lo(o,"ul","pptxv-ai-proposal-summary");for(let s of t.summary){let g=lo(o,"li");g.textContent=Tn(s),l.appendChild(g);}a.appendChild(l);}let c=lo(o,"div","pptxv-ai-proposal-actions"),p=lo(o,"button","pptxv-ai-proposal-btn is-accept");p.type="button",p.append(Ao(o,"check"),o.createTextNode(n("pptx.ai.accept"))),p.addEventListener("click",()=>i.accept(t.id));let m=lo(o,"button","pptxv-ai-proposal-btn is-reject");return m.type="button",m.append(Ao(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=lo(t,"div","pptxv-ai-header"),h=lo(t,"span","pptxv-ai-title");h.textContent=i("pptx.ai.title");let x=lo(t,"button","pptxv-ai-close");x.type="button",x.title=i("pptx.ai.close"),x.setAttribute("aria-label",i("pptx.ai.close")),x.appendChild(Ao(t,"close")),x.addEventListener("click",()=>o.onClose?.()),a.append(Ao(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=lo(t,"div","pptxv-ai-messages");l.setAttribute("role","log"),l.setAttribute("aria-live","polite");let s=lo(t,"div","pptxv-ai-empty");s.textContent=i("pptx.ai.emptyHint"),l.appendChild(s);let g=lo(t,"div","pptxv-ai-proposals");g.hidden=true;let f=lo(t,"div","pptxv-ai-error");f.setAttribute("role","alert"),f.hidden=true;let C=lo(t,"form","pptxv-ai-composer"),d=lo(t,"textarea","pptxv-ai-input");d.rows=2,d.placeholder=i("pptx.ai.placeholder"),d.setAttribute("aria-label",i("pptx.ai.placeholder"));let y=lo(t,"button","pptxv-ai-send");y.type="submit",y.setAttribute("aria-label",i("pptx.ai.send")),y.appendChild(Ao(t,"send")),C.append(d,y),n.append(a,...m?[m.el]:[],l,g,f,C);try{c=await(o.createChat??_do)({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:bo(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=>Wn(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=io(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};
|