efficient-office 0.0.0 → 0.2.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/LICENSE +10 -0
- package/README.md +11 -0
- package/dist/Slides-ILKPLYAJ.js +1 -0
- package/dist/SlidesEditor-44ITB7B2.js +1 -0
- package/dist/chunk-3JJCHWPJ.js +1 -0
- package/dist/chunk-BTDWPUTS.js +1 -0
- package/dist/slides/index.d.ts +223 -0
- package/dist/slides/index.js +1 -0
- package/dist/slides/slides.css +72 -0
- package/package.json +68 -8
package/LICENSE
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
Copyright (c) 2026 Efficient Pty Ltd. All rights reserved.
|
|
2
|
+
|
|
3
|
+
This software and its documentation are proprietary to Efficient Pty Ltd and
|
|
4
|
+
are confidential. No licence is granted to use, copy, modify, merge, publish,
|
|
5
|
+
distribute, sublicense or sell this software, in whole or in part, except
|
|
6
|
+
under a written agreement with Efficient Pty Ltd.
|
|
7
|
+
|
|
8
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
9
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
10
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
package/README.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# efficient-office
|
|
2
|
+
|
|
3
|
+
The EFFICIENT office apps, on `efficient-shell` and `efficient-easel`.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { slidesApps, SlidesProvider } from 'efficient-office/slides';
|
|
7
|
+
import 'efficient-office/slides.css';
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
Load `efficient-shell`'s CSS first. `pptxgenjs` is an optional peer, needed only for
|
|
11
|
+
PowerPoint export. Without a `SlidesProvider`, decks stay in the browser.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useSlidesHost as e,useSlidesWords as i}from"./chunk-BTDWPUTS.js";import{lazy as l,Suspense as t,useCallback as n,useEffect as s,useState as r}from"react";import{Button as c}from"efficient-shell/ui";import{Icon as o}from"efficient-shell/icons";import{confirmDestructive as d}from"efficient-shell";import{EmptyState as a}from"efficient-shell/ui";import{WindowTitle as m}from"efficient-shell";import{toast as h}from"efficient-shell";import{jsx as f,jsxs as p}from"react/jsx-runtime";var u=l(()=>import("./SlidesEditor-44ITB7B2.js"));function k({id:l,onClose:o}){const d=i(),{store:m}=e(),[h,p]=r(null),[k,C]=r(!1),v=n(()=>{m.get(l).then(e=>p(i=>({deck:e,nonce:(i?.nonce??0)+1})),()=>C(!0))},[l,m]);return s(v,[v]),k?f("div",{className:"slides-list-empty",children:f(a,{title:d.openFailed,children:f(c,{onClick:o,children:d.backToDecks})})}):h?f(t,{fallback:null,children:f(u,{deck:h.deck,onClose:o,onReload:v},h.nonce)}):null}function C(){const l=i(),{store:t,canCreate:u=!0,canDelete:C=!0}=e(),[v,D]=r(null),[N,g]=r(null),y=n(()=>{t.list().then(g,()=>g([]))},[t]);if(s(y,[y]),v)return f(k,{id:v,onClose:()=>{D(null),y()}});const w=f(c,{disabled:!u,onClick:()=>{t.create(l.untitledDeck).then(e=>D(e.id),()=>h.error(l.createFailed))},children:l.newDeck});return p("div",{className:"slides-list",children:[f(m,{title:l.slidesPanel}),p("div",{className:"slides-list-head",children:[f("h2",{children:l.decks}),N&&N.length>0&&w]}),0===N?.length?f("div",{className:"slides-list-empty",children:f(a,{title:l.emptyTitle,description:l.emptyBody,children:w})}):f("ul",{className:"slides-list-rows",children:N?.map(e=>p("li",{className:"slides-list-row",children:[f(c,{variant:"link",onClick:()=>D(e.id),children:e.title}),f("span",{className:"slides-list-date",children:new Date(e.updatedAt).toLocaleDateString()}),C&&f(c,{variant:"ghost",leftIcon:f(o,{name:"trash",size:16}),onClick:async()=>{await d({message:l.deleteConfirm(e.title),confirmWord:l.delete})&&t.remove(e.id).then(y,()=>h.error(l.deleteFailed))},children:l.delete})]},e.id))})]})}export{k as OpenDeck,C as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{HANDLES as e,SLIDE_H as t,SLIDE_W as n,SlideView as l,alignElements as i,angleTo as a,asDocument as s,boundsOf as r,boxesTouch as o,bringForward as d,chartToText as c,copySlide as h,duplicateElements as u,historyReducer as m,insertSlideAfter as p,moveSlide as f,newElement as b,newSlide as v,removeElements as g,removeSlide as y,resizeBox as w,snapBox as x,tableToText as k,textToChart as C,textToTable as N,updateElements as S,updateSlide as D}from"./chunk-3JJCHWPJ.js";import{SlidesConflict as z,useSlidesHost as M,useSlidesWords as I}from"./chunk-BTDWPUTS.js";import{useCallback as P,useEffect as T,useReducer as j,useRef as A,useState as E}from"react";import{saveIndicator as L,useAutosave as K}from"efficient-easel/autosave";import{EaselIconButton as B,EaselTopBar as F,SaveState as R,TopBarCluster as U,TopBarDivider as O}from"efficient-easel/chrome";import{useEaselStrings as W}from"efficient-easel/strings";import"efficient-easel/shell.css";import"efficient-easel/chrome.css";import"efficient-easel/panel.css";import"efficient-easel/fields.css";import{Button as $}from"efficient-shell/ui";import{IconButton as q}from"efficient-shell/ui";import{Input as _}from"efficient-shell/ui";import{Textarea as H}from"efficient-shell/ui";import{Icon as J}from"efficient-shell/icons";import{toast as V}from"efficient-shell";import{useEffect as X,useRef as Y,useState as G}from"react";import{Button as Q}from"efficient-shell/ui";import{Icon as Z}from"efficient-shell/icons";import{useLayoutEffect as ee,useState as te}from"react";import{createPortal as ne}from"react-dom";import{jsx as le}from"react/jsx-runtime";function ie(e){const[l,i]=te(0);return ee(()=>{const l=e.current;if(!l)return;const a=l.ownerDocument.defaultView,s=()=>i(Math.min(l.clientWidth,l.clientHeight*n/t));s();const r=new(a?.ResizeObserver??ResizeObserver)(s);return r.observe(l),()=>r.disconnect()},[e]),l}function ae({slide:e,popup:t}){const[n]=te(()=>{const e=t.document.createElement("div");return e.style.cssText="position:fixed;inset:0;display:flex;align-items:center;justify-content:center;background:#000;cursor:pointer",t.document.body.appendChild(e),{current:e}}),i=ie(n);return ne(le("div",{onClick:()=>{t.document.documentElement.requestFullscreen?.()},children:le(l,{slide:e,width:i})}),n.current)}import{jsx as se,jsxs as re}from"react/jsx-runtime";var oe=e=>String(e).padStart(2,"0");function de({slides:e,startIndex:t,popup:n,onEnd:i}){const[a,s]=G(t),r=function(){const[e,t]=G(0);return X(()=>{const e=Date.now(),n=setInterval(()=>t(Math.floor((Date.now()-e)/1e3)),1e3);return()=>clearInterval(n)},[]),`${oe(Math.floor(e/60))}:${oe(e%60)}`}(),o=I(),d=e.length-1,c=Y(null),h=ie(c),u=e=>s(Math.max(0,Math.min(e,d)));X(()=>{const e=e=>{["ArrowRight","ArrowDown","PageDown"," "].includes(e.key)?(e.preventDefault(),s(e=>Math.min(e+1,d))):["ArrowLeft","ArrowUp","PageUp"].includes(e.key)?(e.preventDefault(),s(e=>Math.max(e-1,0))):"Escape"===e.key&&i()};return window.addEventListener("keydown",e),n?.addEventListener("keydown",e),()=>{window.removeEventListener("keydown",e),n?.removeEventListener("keydown",e)}},[d,i,n]),X(()=>{if(n)return()=>n.close()},[n]);const m=e[a],p=e[a+1];return re("div",{className:"slides-presenter",children:[re("div",{className:"slides-presenter-head",children:[se("span",{className:"slides-presenter-clock",children:r}),se("span",{children:o.slideOf(a+1,e.length)}),se(Q,{variant:"secondary",onClick:i,leftIcon:se(Z,{name:"close",size:16}),children:o.endShow})]}),!n&&se("p",{className:"slides-presenter-blocked",children:o.popupBlocked}),re("div",{className:"slides-presenter-body",children:[re("div",{className:"slides-presenter-main",children:[se("div",{ref:c,className:"slides-presenter-current",children:se(l,{slide:m,width:h})}),re("div",{className:"slides-presenter-steps",children:[se(Q,{variant:"secondary",onClick:()=>u(a-1),leftIcon:se(Z,{name:"arrow-left",size:16}),children:o.back}),se(Q,{variant:"secondary",onClick:()=>u(a+1),rightIcon:se(Z,{name:"arrow-right",size:16}),children:o.next})]})]}),re("div",{className:"slides-presenter-side",children:[se("p",{className:"slides-presenter-label",children:o.nextSlide}),p?se(l,{slide:p,width:280}):se("p",{children:o.endOfDeck}),se("p",{className:"slides-presenter-label",children:o.notes}),se("p",{className:"slides-presenter-notes",children:m.notes||o.noNotes})]})]}),n&&se(ae,{slide:m,popup:n})]})}import{useState as ce}from"react";import{SettingsColour as he}from"efficient-easel/panel";import{Button as ue}from"efficient-shell/ui";import{IconButton as me}from"efficient-shell/ui";import{Input as pe}from"efficient-shell/ui";import{Select as fe}from"efficient-shell/ui";import{Textarea as be}from"efficient-shell/ui";import{Icon as ve}from"efficient-shell/icons";import{jsx as ge,jsxs as ye}from"react/jsx-runtime";function we({label:e,value:t,onChange:n}){return ye("label",{className:"slides-number",children:[ge("span",{children:e}),ge(pe,{type:"number",value:Math.round(t),onChange:e=>{const t=Number(e.target.value);""!==e.target.value&&Number.isFinite(t)&&n(t)}})]})}function xe({label:e,hint:t,value:n,onChange:l}){const[i,a]=ce(null);return ye("label",{className:"slides-field",children:[ge("span",{children:e}),ge(be,{rows:5,value:i??n,onFocus:()=>a(n),onBlur:()=>a(null),onChange:e=>{a(e.target.value),l(e.target.value)}}),ge("small",{children:t})]})}function ke({slide:e,selected:t,onChangeSlide:n,onChangeSelected:l,onAlign:i,onForward:a,onDelete:s}){const r=I(),{pickImage:o}=M();if(0===t.length)return ye("aside",{className:"slides-inspector",children:[ge("h3",{children:r.slide}),ge("div",{className:"slides-section",children:ge(he,{label:r.background,value:e.background,onChange:e=>n({background:e})})})]});const d=1===t.length?t[0]:null,h={text:r.elementText,shape:r.elementShape,image:r.elementImage,chart:r.elementChart,table:r.elementTable},u=e=>l(t=>({...t,...e}));return ye("aside",{className:"slides-inspector",children:[ge("h3",{children:d?h[d.type]:r.objects(t.length)}),d&&ye("div",{className:"slides-section",children:[ge("p",{className:"slides-label",children:r.positionAndSize}),ye("div",{className:"slides-numbers",children:[ge(we,{label:"X",value:d.x,onChange:e=>u({x:e})}),ge(we,{label:"Y",value:d.y,onChange:e=>u({y:e})}),ge(we,{label:r.width,value:d.w,onChange:e=>u({w:Math.max(20,e)})}),ge(we,{label:r.height,value:d.h,onChange:e=>u({h:Math.max(20,e)})}),ge(we,{label:r.angle,value:d.rotation,onChange:e=>u({rotation:e})})]})]}),ye("div",{className:"slides-section",children:[ge("p",{className:"slides-label",children:r.align}),ye("div",{className:"slides-actions",children:[ge(me,{"aria-label":r.alignLeft,onClick:()=>i("left"),children:ge(ve,{name:"align-left",size:16})}),ge(me,{"aria-label":r.alignCentre,onClick:()=>i("center"),children:ge(ve,{name:"align-center",size:16})}),ge(me,{"aria-label":r.alignRight,onClick:()=>i("right"),children:ge(ve,{name:"align-right",size:16})}),ge(me,{"aria-label":r.bringForward,onClick:a,children:ge(ve,{name:"layers",size:16})}),ge(me,{"aria-label":r.delete,onClick:s,children:ge(ve,{name:"trash",size:16})})]})]}),"text"===d?.type&&ye("div",{className:"slides-section",children:[ge("div",{className:"slides-numbers",children:ge(we,{label:r.size,value:d.fontSize,onChange:e=>u({fontSize:Math.max(8,e)})})}),ge(fe,{"aria-label":r.weight,value:d.bold?"bold":"regular",onChange:e=>u({bold:"bold"===e}),options:[{value:"regular",label:r.regular},{value:"bold",label:r.bold}]}),ge(fe,{"aria-label":r.textAlignment,value:d.align,onChange:e=>u({align:e}),options:[{value:"left",label:r.left},{value:"center",label:r.centre},{value:"right",label:r.right}]}),ge(he,{label:r.colour,value:d.color,onChange:e=>u({color:e})})]}),"shape"===d?.type&&ye("div",{className:"slides-section",children:[ge(fe,{"aria-label":r.elementShape,value:d.shape,onChange:e=>u({shape:e}),options:[{value:"rect",label:r.rectangle},{value:"ellipse",label:r.ellipse}]}),ge(he,{label:r.colour,value:d.fill,onChange:e=>u({fill:e})})]}),"image"===d?.type&&ye("div",{className:"slides-section",children:[o?ge(ue,{variant:"secondary",block:!0,onClick:()=>{const{id:e}=d;o().then(t=>{t&&l(n=>n.id===e?{...n,src:t}:n)})},children:r.chooseImage}):ye("label",{className:"slides-field",children:[ge("span",{children:r.imageAddress}),ge(pe,{value:d.src,onChange:e=>u({src:e.target.value})})]}),ye("label",{className:"slides-field",children:[ge("span",{children:r.description}),ge(pe,{value:d.alt,onChange:e=>u({alt:e.target.value})})]})]}),"chart"===d?.type&&ye("div",{className:"slides-section",children:[ge("p",{className:"slides-label",children:r.data}),ge(fe,{"aria-label":r.chartType,value:d.kind,onChange:e=>u({kind:e}),options:[{value:"bar",label:r.bar},{value:"line",label:r.line}]}),ge(xe,{label:r.values,hint:r.valuesHint,value:c(d.points),onChange:e=>u({points:C(e)})}),ge(he,{label:r.colour,value:d.color,onChange:e=>u({color:e})})]}),"table"===d?.type&&ye("div",{className:"slides-section",children:[ge(xe,{label:r.rows,hint:r.rowsHint,value:k(d.rows),onChange:e=>u({rows:N(e)})}),ge(he,{label:r.headingColour,value:d.headerFill,onChange:e=>u({headerFill:e})})]})]})}import{useState as Ce}from"react";import{Button as Ne}from"efficient-shell/ui";import{IconButton as Se}from"efficient-shell/ui";import{Icon as De}from"efficient-shell/icons";import{jsx as ze,jsxs as Me}from"react/jsx-runtime";function Ie({slides:e,currentId:t,onShow:n,onAdd:i,onMove:a,onDuplicate:s,onDelete:r}){const[o,d]=Ce(null),c=I();return Me("nav",{className:"slides-rail","aria-label":c.slidesPanel,children:[e.map((e,i)=>Me("div",{className:"slides-thumb","data-current":e.id===t||void 0,draggable:!0,onDragStart:()=>d(e.id),onDragEnd:()=>d(null),onDragOver:e=>e.preventDefault(),onDrop:()=>{o&&o!==e.id&&a(o,i),d(null)},children:[ze("span",{className:"slides-thumb-number",children:i+1}),ze("div",{role:"button",tabIndex:0,"aria-label":c.slideNumber(i+1),"aria-current":e.id===t,className:"slides-thumb-image",onClick:()=>n(e.id),onKeyDown:t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),t.stopPropagation(),n(e.id))},children:ze(l,{slide:e,width:132})}),e.id===t&&Me("div",{className:"slides-thumb-actions",children:[ze(Se,{"aria-label":c.duplicateSlide,size:"sm",onClick:()=>s(e.id),children:ze(De,{name:"copy",size:14})}),ze(Se,{"aria-label":c.deleteSlide,size:"sm",onClick:()=>r(e.id),children:ze(De,{name:"trash",size:14})})]})]},e.id)),ze(Ne,{variant:"secondary",block:!0,onClick:i,children:c.addSlide})]})}import{useLayoutEffect as Pe,useRef as Te,useState as je}from"react";import{Fragment as Ae,jsx as Ee,jsxs as Le}from"react/jsx-runtime";var Ke={x:[],y:[]};function Be({element:e,onDone:t}){const n=Te(null),l=I();return Pe(()=>{const t=n.current;t&&(t.innerText=e.text,t.focus(),document.getSelection()?.selectAllChildren(t))},[e.text]),Ee("div",{ref:n,contentEditable:"plaintext-only",role:"textbox","aria-label":l.slideText,suppressContentEditableWarning:!0,className:"slides-text-edit",onPointerDown:e=>e.stopPropagation(),onBlur:e=>t(e.currentTarget.innerText),onKeyDown:e=>{e.stopPropagation(),"Escape"===e.key&&e.currentTarget.blur()},style:{fontSize:e.fontSize,fontWeight:e.bold?600:400,color:e.color,textAlign:e.align}})}function Fe({slide:i,selected:s,onSelect:d,onLive:c,onSettle:h,onCommit:u}){const m=Te(null),[p,f]=je(0),[b,v]=je(Ke),[g,y]=je(null),[k,C]=je(null),N=Te(null);Pe(()=>{const e=m.current;if(!e)return;const l=()=>{f(Math.max(0,Math.min(e.clientWidth-48,(e.clientHeight-48)*n/t)))};l();const i=new ResizeObserver(l);return i.observe(e),()=>i.disconnect()},[]);const D=p/n,z=Te(null),M=e=>{const t=z.current?.getBoundingClientRect();return{x:(e.clientX-(t?.left??0))/D,y:(e.clientY-(t?.top??0))/D}},I=(e,t)=>{for(let n=i.elements.length-1;n>=0;n-=1){const l=i.elements[n],a=-l.rotation*Math.PI/180,s=e-(l.x+l.w/2),r=t-(l.y+l.h/2),o=s*Math.cos(a)-r*Math.sin(a),d=s*Math.sin(a)+r*Math.cos(a);if(Math.abs(o)<=l.w/2&&Math.abs(d)<=l.h/2)return l}return null},P=(e,t)=>{e.stopPropagation(),e.currentTarget.setPointerCapture(e.pointerId),N.current=t},T=e=>{const t=N.current;if(!t)return;const{x:n,y:l}=M(e);if("marquee"===t.kind){const e={x:Math.min(t.px,n),y:Math.min(t.py,l),w:Math.abs(n-t.px),h:Math.abs(l-t.py)};y(e),d(new Set(i.elements.filter(t=>o(e,t)).map(e=>e.id)))}else if("move"===t.kind){const i=t.start.elements.filter(e=>s.has(e.id)),a=t.start.elements.filter(e=>!s.has(e.id)),o=r(i),d={...o,x:o.x+n-t.px,y:o.y+l-t.py},h=e.altKey?{box:d,guides:Ke}:x(d,a);v(h.guides);const u=h.box.x-o.x,m=h.box.y-o.y;c(S(t.start,s,e=>({...e,x:e.x+u,y:e.y+m})))}else"resize"===t.kind?c(S(t.start,new Set([t.id]),i=>{const a=-i.rotation*Math.PI/180,s=n-t.px,r=l-t.py,o=s*Math.cos(a)-r*Math.sin(a),d=s*Math.sin(a)+r*Math.cos(a);return{...i,...w(i,t.handle,o,d,e.shiftKey)}})):c(S(t.start,new Set([t.id]),t=>({...t,rotation:a(t,n,l,e.shiftKey)})))},j=()=>{const e=N.current;N.current=null,v(Ke),y(null),e&&"marquee"!==e.kind&&h()},A=1===s.size?i.elements.find(e=>s.has(e.id)):void 0,E=i.elements.filter(e=>s.has(e.id)),L=i.elements.find(e=>e.id===k&&"text"===e.type);return Ee("div",{ref:m,className:"slides-pane",children:Le("div",{ref:z,className:"slides-stage",style:{width:p,height:p*t/n},onPointerDown:e=>{if(0!==e.button)return;const{x:t,y:n}=M(e),l=I(t,n);if(!l)return e.shiftKey||d(new Set),void P(e,{kind:"marquee",px:t,py:n});let a=s;if(e.shiftKey){const e=new Set(s);e.has(l.id)?e.delete(l.id):e.add(l.id),a=e,d(e)}else s.has(l.id)||(a=new Set([l.id]),d(a));a.has(l.id)&&P(e,{kind:"move",start:i,px:t,py:n})},onPointerMove:T,onPointerUp:j,onPointerCancel:j,onDoubleClick:e=>{const{x:t,y:n}=M(e),l=I(t,n);"text"===l?.type&&C(l.id)},children:[Ee(l,{slide:i,width:p,editingId:L?.id,editor:L&&Ee(Be,{element:L,onDone:e=>{C(null),e!==L.text&&u(S(i,new Set([L.id]),t=>({...t,text:e})))}})}),!L&&E.map(t=>Ee("div",{className:"slides-selection",style:{left:t.x*D,top:t.y*D,width:t.w*D,height:t.h*D,transform:t.rotation?`rotate(${t.rotation}deg)`:void 0},children:A?.id===t.id&&Le(Ae,{children:[e.map(e=>Ee("div",{className:`slides-handle slides-handle-${e}`,onPointerDown:n=>P(n,{kind:"resize",start:i,id:t.id,handle:e,...Re(M(n))}),onPointerMove:T,onPointerUp:j,onPointerCancel:j},e)),Ee("div",{className:"slides-rotate-stem"}),Ee("div",{className:"slides-rotate",onPointerDown:e=>P(e,{kind:"rotate",start:i,id:t.id}),onPointerMove:T,onPointerUp:j,onPointerCancel:j})]})},t.id)),b.x.map(e=>Ee("div",{className:"slides-guide slides-guide-x",style:{left:e*D}},`x${e}`)),b.y.map(e=>Ee("div",{className:"slides-guide slides-guide-y",style:{top:e*D}},`y${e}`)),g&&Ee("div",{className:"slides-marquee",style:{left:g.x*D,top:g.y*D,width:g.w*D,height:g.h*D}})]})})}var Re=({x:e,y:t})=>({px:e,py:t}),Ue=13.333,Oe=e=>e/n*Ue,We=e=>e.replace("#","").toUpperCase();function $e(e){return`${e.replace(/[^\p{L}\p{N} _-]+/gu," ").replace(/ +/g," ").trim()||"Deck"}.pptx`}function qe(e,t,n){const l={x:Oe(n.x),y:Oe(n.y),w:Oe(n.w),h:Oe(n.h),rotate:n.rotation};switch(n.type){case"text":t.addText(n.text,{...l,fontSize:(i=n.fontSize,Math.round(72*Oe(i))),bold:n.bold,color:We(n.color),align:n.align,valign:"top",margin:0});break;case"shape":t.addShape("ellipse"===n.shape?e.ShapeType.ellipse:e.ShapeType.rect,{...l,fill:{color:We(n.fill)}});break;case"image":n.src&&t.addImage({...l,path:n.src,altText:n.alt});break;case"chart":t.addChart("line"===n.kind?e.ChartType.line:e.ChartType.bar,[{name:"Series",labels:n.points.map(e=>e.label),values:n.points.map(e=>e.value)}],{...l,chartColors:[We(n.color)],showValue:!0,showLegend:!1});break;case"table":t.addTable(n.rows.map((e,t)=>e.map(e=>({text:e,options:0===t?{bold:!0,fill:{color:We(n.headerFill)}}:{}}))),{x:l.x,y:l.y,w:l.w,border:{type:"solid",color:"B4B2A9",pt:1}})}var i}async function _e(e,t){const n=await async function(e,t){const{default:n}=await(import("pptxgenjs")),l=new n;l.defineLayout({name:"SLIDE_16_9",width:Ue,height:7.5}),l.layout="SLIDE_16_9",l.title=e;for(const e of t.slides){const t=l.addSlide();t.background={color:We(e.background)},e.notes&&t.addNotes(e.notes);for(const n of e.elements)qe(l,t,n)}return l}(e,t);await n.writeFile({fileName:$e(e)})}import{jsx as He,jsxs as Je}from"react/jsx-runtime";var Ve=[{type:"text",labelKey:"addText",icon:"type"},{type:"shape",labelKey:"addShape",icon:"square"},{type:"image",labelKey:"addImage",icon:"image"},{type:"chart",labelKey:"addChart",icon:"chart-bar"},{type:"table",labelKey:"addTable",icon:"table"}];function Xe({deck:e,onClose:t,onReload:n}){const l=I(),{store:a}=M(),[r,o]=E(e.title),[c,w]=j(m,void 0,()=>({past:[],present:s(e.document),future:[]})),x=c.present,[k,C]=E(x.slides[0].id),[N,X]=E(new Set),[Y,G]=E(!0),[Q,Z]=E(null),ee=x.slides.find(e=>e.id===k)??x.slides[0],te=x.slides.indexOf(ee),ne=A(e.version),[le,ie]=E(!1),ae=W(),se=K({save:async t=>{ne.current=await a.save(e.id,t,ne.current)},onFailure:(e,t)=>{e instanceof z?(se.stop(),ie(!0)):0===t&&V.error(l.saveFailed)}}),re=A(x),{push:oe,flush:ce}=se;T(()=>{x!==re.current&&(re.current=x,oe(x))},[x,oe]),T(()=>()=>{ce()},[ce]);const he=P(e=>w({type:"commit",doc:e}),[]),ue=e=>he(D(x,ee.id,()=>e)),me=A(null),pe=e=>{C(e),X(new Set)},fe=()=>{ue(g(ee,N)),X(new Set)};return Je("div",{className:"es-editor slides-editor",onKeyDown:e=>{if(Q)return;if(e.target.closest('input, textarea, select, [contenteditable], [role="listbox"]'))return;const t=e.metaKey||e.ctrlKey;if(t&&"z"===e.key.toLowerCase())e.preventDefault(),w({type:e.shiftKey?"redo":"undo"});else if(t&&"y"===e.key.toLowerCase())e.preventDefault(),w({type:"redo"});else if(t&&"a"===e.key.toLowerCase())e.preventDefault(),X(new Set(ee.elements.map(e=>e.id)));else if(t&&"d"===e.key.toLowerCase()&&N.size>0){e.preventDefault();const t=u(ee,N);ue(t.slide),X(new Set(t.ids))}else if(("Delete"===e.key||"Backspace"===e.key)&&N.size>0)e.preventDefault(),fe();else if("Escape"===e.key)X(new Set);else if(e.key.startsWith("Arrow")&&N.size>0){e.preventDefault();const t=e.shiftKey?1:10,n="ArrowLeft"===e.key?-t:"ArrowRight"===e.key?t:0,l="ArrowUp"===e.key?-t:"ArrowDown"===e.key?t:0;ue(S(ee,N,e=>({...e,x:e.x+n,y:e.y+l})))}},tabIndex:-1,children:[Je(F,{children:[Je(U,{children:[He(B,{label:l.backToDecks,onClick:t,children:He(J,{name:"chevron-left",size:16})}),He(B,{label:l.slidesPanel,state:Y?"active":"inactive",onClick:()=>G(e=>!e),children:He(J,{name:"bars-3-bottom-left",size:16})}),He("div",{className:"slides-title",children:He(_,{"aria-label":l.deckName,value:r,onChange:e=>o(e.target.value),onBlur:()=>{const t=r.trim();t&&t!==e.title?a.rename(e.id,t).catch(()=>V.error(l.renameFailed)):o(t||e.title)}})}),He(R,{...L(se.state,ae.save)}),He(O,{}),He(B,{label:l.undo,disabled:0===c.past.length,onClick:()=>w({type:"undo"}),children:He(J,{name:"undo",size:16})}),He(B,{label:l.redo,disabled:0===c.future.length,onClick:()=>w({type:"redo"}),children:He(J,{name:"redo",size:16})})]}),Je(U,{kind:"right",children:[He($,{variant:"secondary",leftIcon:He(J,{name:"download",size:16}),onClick:()=>_e(r,x).catch(()=>V.error(l.exportFailed)),children:l.export}),He($,{leftIcon:He(J,{name:"play",size:16}),onClick:()=>{const e=window.open("about:blank","_blank","popup,width=1280,height=720");e&&(e.document.title=r),Z({popup:e})},children:l.present})]})]}),le&&Je("div",{className:"slides-conflict",role:"alert",children:[He("span",{children:l.conflict}),He($,{variant:"secondary",onClick:n,children:l.reload})]}),Je("div",{className:"slides-body",children:[Y&&He(Ie,{slides:x.slides,currentId:ee.id,onShow:pe,onAdd:()=>{const e=v();he(p(x,ee.id,e)),pe(e.id)},onMove:(e,t)=>he(f(x,e,t)),onDuplicate:e=>{const t=x.slides.find(t=>t.id===e);if(!t)return;const n=h(t);he(p(x,e,n)),pe(n.id)},onDelete:e=>{const t=y(x,e);he(t),e===ee.id&&pe(t.slides[Math.min(te,t.slides.length-1)].id)}}),Je("div",{className:"slides-centre",children:[He("div",{className:"slides-toolbar",children:Ve.map(({type:e,labelKey:t,icon:n})=>He(q,{"aria-label":l[t],onClick:()=>(e=>{const t=b(e);ue({...ee,elements:[...ee.elements,t]}),X(new Set([t.id]))})(e),children:He(J,{name:n,size:16})},e))}),He(Fe,{slide:ee,selected:N,onSelect:X,onLive:e=>{me.current??=x,w({type:"live",doc:D(me.current,ee.id,()=>e)})},onSettle:()=>{me.current&&w({type:"settle",from:me.current}),me.current=null},onCommit:ue},ee.id),Je("label",{className:"slides-notes",children:[He("span",{children:l.speakerNotes}),He(H,{rows:2,value:ee.notes,onChange:e=>ue({...ee,notes:e.target.value})})]})]}),He(ke,{slide:ee,selected:ee.elements.filter(e=>N.has(e.id)),onChangeSlide:e=>ue({...ee,...e}),onChangeSelected:e=>ue(S(ee,N,e)),onAlign:e=>ue(i(ee,N,e)),onForward:()=>ue(d(ee,N)),onDelete:fe})]}),Q&&He(de,{slides:x.slides,startIndex:te,popup:Q.popup,onEnd:()=>Z(null)})]})}export{Xe as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=1920,t=1080,n=()=>crypto.randomUUID();function i(){return{id:n(),background:"#ffffff",notes:"",elements:[]}}function r(e){const t=e?.slides;return Array.isArray(t)&&t.length>0?{slides:t}:{slides:[i()]}}function a(i){const r=(i,r)=>({id:n(),x:(e-i)/2,y:(t-r)/2,w:i,h:r,rotation:0});switch(i){case"text":return{...r(800,160),type:i,text:"Text",fontSize:64,bold:!1,color:"#2c2c2a",align:"left"};case"shape":return{...r(400,400),type:i,shape:"rect",fill:"#afa9ec"};case"image":return{...r(800,450),type:i,src:"",alt:""};case"chart":return{...r(900,600),type:i,kind:"bar",color:"#534ab7",points:[{label:"A",value:40},{label:"B",value:65},{label:"C",value:90}]};case"table":return{...r(1e3,400),type:i,headerFill:"#eeedfe",rows:[["Heading","Heading"],["Cell","Cell"]]}}}function s(e,t,n){return{slides:e.slides.map(e=>e.id===t?n(e):e)}}function l(e,t,n){const i=e.slides.findIndex(e=>e.id===t),r=[...e.slides];return r.splice(-1===i?r.length:i+1,0,n),{slides:r}}function o(e){return{...e,id:n(),elements:e.elements.map(e=>({...e,id:n()}))}}function c(e,t){const n=e.slides.filter(e=>e.id!==t);return{slides:n.length>0?n:[i()]}}function h(e,t,n){const i=e.slides.findIndex(e=>e.id===t);if(-1===i)return e;const r=[...e.slides],[a]=r.splice(i,1);return r.splice(Math.max(0,Math.min(n,r.length)),0,a),{slides:r}}function d(e,t,n){return{...e,elements:e.elements.map(e=>t.has(e.id)?n(e):e)}}function u(e,t){return{...e,elements:e.elements.filter(e=>!t.has(e.id))}}function f(e,t){const i=e.elements.filter(e=>t.has(e.id)).map(e=>({...e,id:n(),x:e.x+40,y:e.y+40}));return{slide:{...e,elements:[...e.elements,...i]},ids:i.map(e=>e.id)}}function p(e,t){const n=[...e.elements];for(let e=n.length-2;e>=0;e-=1)t.has(n[e].id)&&!t.has(n[e+1].id)&&([n[e],n[e+1]]=[n[e+1],n[e]]);return{...e,elements:n}}function m(e){const t=Math.min(...e.map(e=>e.x)),n=Math.min(...e.map(e=>e.y));return{x:t,y:n,w:Math.max(...e.map(e=>e.x+e.w))-t,h:Math.max(...e.map(e=>e.y+e.h))-n}}function x(n,i,r){const a=n.elements.filter(e=>i.has(e.id));if(0===a.length)return n;const s=1===a.length?{x:0,y:0,w:e,h:t}:m(a);return d(n,i,e=>"left"===r?{...e,x:s.x}:"right"===r?{...e,x:s.x+s.w-e.w}:{...e,x:s.x+(s.w-e.w)/2})}function y(n,i){const r=[{x:0,y:0,w:e,h:t},...i],a=(e,t,n)=>{let i=null;for(const r of[e,e+t/2,e+t])for(const e of n){const t=e-r;Math.abs(t)<=8&&(!i||Math.abs(t)<Math.abs(i.shift))&&(i={shift:t,at:e})}return i},s=a(n.x,n.w,r.flatMap(e=>[e.x,e.x+e.w/2,e.x+e.w])),l=a(n.y,n.h,r.flatMap(e=>[e.y,e.y+e.h/2,e.y+e.h]));return{box:{...n,x:n.x+(s?.shift??0),y:n.y+(l?.shift??0)},guides:{x:s?[s.at]:[],y:l?[l.at]:[]}}}var w=["nw","n","ne","e","se","s","sw","w"];function g(e,t,n,i,r=!1){let{x:a,y:s,w:l,h:o}=e;if(t.includes("e")&&(l=Math.max(20,e.w+n)),t.includes("s")&&(o=Math.max(20,e.h+i)),t.includes("w")&&(l=Math.max(20,e.w-n),a=e.x+e.w-l),t.includes("n")&&(o=Math.max(20,e.h-i),s=e.y+e.h-o),r&&2===t.length){const n=Math.max(l/e.w,o/e.h);l=e.w*n,o=e.h*n,t.includes("w")&&(a=e.x+e.w-l),t.includes("n")&&(s=e.y+e.h-o)}return{x:a,y:s,w:l,h:o}}function b(e,t,n,i=!1){const r=180*Math.atan2(n-(e.y+e.h/2),t-(e.x+e.w/2))/Math.PI+90;return((i?15*Math.round(r/15):Math.round(r))%360+360)%360}function v(e,t){return e.x<t.x+t.w&&t.x<e.x+e.w&&e.y<t.y+t.h&&t.y<e.y+e.h}function M(e,t){switch(t.type){case"commit":return t.doc===e.present?e:{past:[...e.past,e.present].slice(-200),present:t.doc,future:[]};case"live":return{...e,present:t.doc};case"settle":return t.from===e.present?e:{past:[...e.past,t.from].slice(-200),present:e.present,future:[]};case"undo":{const t=e.past[e.past.length-1];return t?{past:e.past.slice(0,-1),present:t,future:[e.present,...e.future]}:e}case"redo":{const[t,...n]=e.future;return t?{past:[...e.past,e.present],present:t,future:n}:e}}}function k(e){return e.map(e=>`${e.label}, ${e.value}`).join("\n")}function $(e){return e.split("\n").flatMap(e=>{const t=e.lastIndexOf(",");if(-1===t)return[];const n=Number(e.slice(t+1).trim()),i=e.slice(0,t).trim();return i&&e.slice(t+1).trim()&&Number.isFinite(n)?[{label:i,value:n}]:[]})}function F(e){return e.map(e=>e.join(", ")).join("\n")}function I(e){const t=e.split("\n").map(e=>e.split(",").map(e=>e.trim())),n=Math.max(...t.map(e=>e.length));return t.map(e=>[...e,...Array(n-e.length).fill("")])}import{jsx as S,jsxs as j}from"react/jsx-runtime";var z="Inter, ui-sans-serif, system-ui, sans-serif";function A(e){return{position:"absolute",left:e.x,top:e.y,width:e.w,height:e.h,transform:e.rotation?`rotate(${e.rotation}deg)`:void 0}}function C({chart:e}){const{w:t,h:n,points:i,color:r,kind:a}=e,s=n-56,l=Math.max(...i.map(e=>e.value),1),o=t/Math.max(i.length,1),c=e=>s-Math.max(e,0)/l*(s-40);return j("svg",{width:t,height:n,viewBox:`0 0 ${t} ${n}`,role:"img","aria-label":"Chart",style:{display:"block"},children:["line"===a?S("polyline",{fill:"none",stroke:r,strokeWidth:8,points:i.map((e,t)=>`${o*t+o/2},${c(e.value)}`).join(" ")}):i.map((e,t)=>S("rect",{x:o*t+.15*o,y:c(e.value),width:.7*o,height:s-c(e.value),fill:r},t)),i.map((e,t)=>j("g",{fontFamily:z,fontSize:30,fill:"#444441",textAnchor:"middle",children:[S("text",{x:o*t+o/2,y:n-14,children:e.label}),S("text",{x:o*t+o/2,y:c(e.value)-12,children:e.value})]},t))]})}function W({table:e}){return S("table",{style:{width:"100%",height:"100%",borderCollapse:"collapse",fontFamily:z,fontSize:32,color:"#2c2c2a",tableLayout:"fixed"},children:S("tbody",{children:e.rows.map((t,n)=>S("tr",{style:{background:0===n?e.headerFill:void 0,fontWeight:0===n?500:400},children:t.map((e,t)=>S("td",{style:{border:"2px solid #b4b2a9",padding:"8px 16px",overflow:"hidden"},children:e},t))},n))})})}function H({element:e}){switch(e.type){case"text":return S("div",{style:{width:"100%",height:"100%",fontFamily:z,fontSize:e.fontSize,fontWeight:e.bold?600:400,color:e.color,textAlign:e.align,lineHeight:1.25,whiteSpace:"pre-wrap",overflowWrap:"break-word"},children:e.text});case"shape":return S("div",{style:{width:"100%",height:"100%",background:e.fill,borderRadius:"ellipse"===e.shape?"50%":0}});case"image":return e.src?S("img",{src:e.src,alt:e.alt,draggable:!1,style:{width:"100%",height:"100%",objectFit:"contain",display:"block"}}):S("div",{style:{width:"100%",height:"100%",background:"#f1efe8",border:"4px dashed #b4b2a9",boxSizing:"border-box"}});case"chart":return S(C,{chart:e});case"table":return S(W,{table:e})}}function B({slide:n,width:i,editingId:r,editor:a}){const s=i/e;return S("div",{style:{width:i,height:t*s,overflow:"hidden",position:"relative",background:n.background},children:S("div",{style:{width:e,height:t,transform:`scale(${s})`,transformOrigin:"0 0",position:"absolute",left:0,top:0},children:n.elements.map(e=>S("div",{style:A(e),children:e.id===r?a:S(H,{element:e})},e.id))})})}export{e as SLIDE_W,t as SLIDE_H,i as newSlide,r as asDocument,a as newElement,s as updateSlide,l as insertSlideAfter,o as copySlide,c as removeSlide,h as moveSlide,d as updateElements,u as removeElements,f as duplicateElements,p as bringForward,m as boundsOf,x as alignElements,y as snapBox,w as HANDLES,g as resizeBox,b as angleTo,v as boxesTouch,M as historyReducer,k as chartToText,$ as textToChart,F as tableToText,I as textToTable,B as SlideView};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e={decks:"Decks",newDeck:"New deck",untitledDeck:"Untitled deck",emptyTitle:"Make your first deck",emptyBody:"Build slides here, then present them or export to PowerPoint.",openFailed:"Couldn't open this deck",createFailed:"Could not create a deck.",deleteFailed:"Could not delete this deck.",backToDecks:"Back to decks",deleteConfirm:e=>`Delete "${e}"? This can't be undone.`,delete:"Delete",deckName:"Deck name",slidesPanel:"Slides",slideNumber:e=>`Slide ${e}`,slideOf:(e,t)=>`Slide ${e} of ${t}`,addSlide:"Add slide",duplicateSlide:"Duplicate slide",deleteSlide:"Delete slide",slideText:"Slide text",undo:"Undo",redo:"Redo",export:"Export",exportFailed:"Could not export this deck.",present:"Present",endShow:"End show",popupBlocked:"Your browser blocked the audience window. Allow pop-ups for this site, then end the show and present again.",back:"Back",next:"Next",nextSlide:"Next slide",endOfDeck:"End of the deck.",notes:"Notes",noNotes:"No notes for this slide.",speakerNotes:"Speaker notes",saveFailed:"Could not save this deck. Trying again.",renameFailed:"Could not rename this deck.",conflict:"Somebody else changed this deck. Your latest edits aren't saved. Reload to see their version.",reload:"Reload",addText:"Add text",addShape:"Add shape",addImage:"Add image",addChart:"Add chart",addTable:"Add table",elementText:"Text",elementShape:"Shape",elementImage:"Image",elementChart:"Chart",elementTable:"Table",slide:"Slide",objects:e=>`${e} objects`,background:"Background",positionAndSize:"Position and size",width:"W",height:"H",angle:"Angle",align:"Align",alignLeft:"Align left",alignCentre:"Align centre",alignRight:"Align right",bringForward:"Bring forward",size:"Size",weight:"Weight",regular:"Regular",bold:"Bold",textAlignment:"Text alignment",left:"Left",centre:"Centre",right:"Right",colour:"Colour",rectangle:"Rectangle",ellipse:"Ellipse",imageAddress:"Image address",chooseImage:"Choose image",imageTitle:"Slide image",description:"Description",data:"Data",chartType:"Chart type",bar:"Bar",line:"Line",values:"Values",valuesHint:"One label and number a line, like Sept, 42.",rows:"Rows",rowsHint:"One row a line, with commas between cells.",headingColour:"Heading colour"},t={decks:"演示文稿",newDeck:"新建演示文稿",untitledDeck:"未命名演示文稿",emptyTitle:"制作第一份演示文稿",emptyBody:"在这里制作幻灯片,然后放映或导出为 PowerPoint。",openFailed:"无法打开此演示文稿",createFailed:"无法创建演示文稿。",deleteFailed:"无法删除此演示文稿。",backToDecks:"返回演示文稿列表",deleteConfirm:e=>`要删除“${e}”吗?此操作无法撤销。`,delete:"删除",deckName:"演示文稿名称",slidesPanel:"幻灯片",slideNumber:e=>`第 ${e} 张幻灯片`,slideOf:(e,t)=>`第 ${e} 张,共 ${t} 张`,addSlide:"添加幻灯片",duplicateSlide:"复制幻灯片",deleteSlide:"删除幻灯片",slideText:"幻灯片文字",undo:"撤销",redo:"重做",export:"导出",exportFailed:"无法导出此演示文稿。",present:"放映",endShow:"结束放映",popupBlocked:"浏览器阻止了观众窗口。请允许此网站的弹出窗口,然后结束放映并重新放映。",back:"上一张",next:"下一张",nextSlide:"下一张幻灯片",endOfDeck:"演示文稿已结束。",notes:"备注",noNotes:"此幻灯片没有备注。",speakerNotes:"演讲者备注",saveFailed:"无法保存此演示文稿,正在重试。",renameFailed:"无法重命名此演示文稿。",conflict:"其他人修改了此演示文稿,您最近的编辑未保存。请重新加载以查看对方的版本。",reload:"重新加载",addText:"添加文字",addShape:"添加形状",addImage:"添加图片",addChart:"添加图表",addTable:"添加表格",elementText:"文字",elementShape:"形状",elementImage:"图片",elementChart:"图表",elementTable:"表格",slide:"幻灯片",objects:e=>`${e} 个对象`,background:"背景",positionAndSize:"位置和大小",width:"宽",height:"高",angle:"角度",align:"对齐",alignLeft:"左对齐",alignCentre:"居中对齐",alignRight:"右对齐",bringForward:"上移一层",size:"字号",weight:"字重",regular:"常规",bold:"粗体",textAlignment:"文字对齐",left:"左",centre:"中",right:"右",colour:"颜色",rectangle:"矩形",ellipse:"椭圆",imageAddress:"图片地址",chooseImage:"选择图片",imageTitle:"幻灯片图片",description:"描述",data:"数据",chartType:"图表类型",bar:"柱形图",line:"折线图",values:"数值",valuesHint:"每行一个标签和数字,例如 九月, 42。",rows:"行",rowsHint:"每行一行数据,单元格之间用逗号分隔。",headingColour:"标题颜色"};import{createContext as d,useContext as a}from"react";import{jsx as i}from"react/jsx-runtime";var n=class extends Error{},l="efficient-office:slides",o=()=>{try{return JSON.parse(localStorage.getItem(l)??"{}")}catch{return{}}},r=e=>localStorage.setItem(l,JSON.stringify(e)),s={list:async()=>Object.values(o()).map(({id:e,title:t,updatedAt:d})=>({id:e,title:t,updatedAt:d})).sort((e,t)=>t.updatedAt.localeCompare(e.updatedAt)),get:async e=>{const t=o()[e];if(!t)throw new Error("No such deck");return t},create:async e=>{const t=(new Date).toISOString(),d={id:crypto.randomUUID(),title:e,document:{},version:crypto.randomUUID(),updatedAt:t};return r({...o(),[d.id]:d}),d},rename:async(e,t)=>{const d=o();d[e]&&r({...d,[e]:{...d[e],title:t,updatedAt:(new Date).toISOString()}})},save:async(e,t,d)=>{const a=o();if(!a[e]||a[e].version!==d)throw new n;const i=crypto.randomUUID();return r({...a,[e]:{...a[e],document:t,version:i,updatedAt:(new Date).toISOString()}}),i},remove:async e=>{const{[e]:t,...d}=o();r(d)}},c=d({store:s});function g({value:e,children:t}){return i(c.Provider,{value:e,children:t})}var p=()=>a(c),h=()=>a(c).words??e;export{e as ENGLISH_WORDS,t as ZH_HANS_WORDS,n as SlidesConflict,s as browserSlidesStore,g as SlidesProvider,p as useSlidesHost,h as useSlidesWords};
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode, ComponentType } from 'react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The Slides app's words: its English, and each language this package carries. A
|
|
6
|
+
* host hands a language in through `SlidesProvider`'s `words`.
|
|
7
|
+
*/
|
|
8
|
+
interface SlidesWords {
|
|
9
|
+
decks: string;
|
|
10
|
+
newDeck: string;
|
|
11
|
+
untitledDeck: string;
|
|
12
|
+
emptyTitle: string;
|
|
13
|
+
emptyBody: string;
|
|
14
|
+
openFailed: string;
|
|
15
|
+
createFailed: string;
|
|
16
|
+
deleteFailed: string;
|
|
17
|
+
backToDecks: string;
|
|
18
|
+
deleteConfirm: (title: string) => string;
|
|
19
|
+
delete: string;
|
|
20
|
+
deckName: string;
|
|
21
|
+
slidesPanel: string;
|
|
22
|
+
slideNumber: (n: number) => string;
|
|
23
|
+
slideOf: (n: number, total: number) => string;
|
|
24
|
+
addSlide: string;
|
|
25
|
+
duplicateSlide: string;
|
|
26
|
+
deleteSlide: string;
|
|
27
|
+
slideText: string;
|
|
28
|
+
undo: string;
|
|
29
|
+
redo: string;
|
|
30
|
+
export: string;
|
|
31
|
+
exportFailed: string;
|
|
32
|
+
present: string;
|
|
33
|
+
endShow: string;
|
|
34
|
+
popupBlocked: string;
|
|
35
|
+
back: string;
|
|
36
|
+
next: string;
|
|
37
|
+
nextSlide: string;
|
|
38
|
+
endOfDeck: string;
|
|
39
|
+
notes: string;
|
|
40
|
+
noNotes: string;
|
|
41
|
+
speakerNotes: string;
|
|
42
|
+
saveFailed: string;
|
|
43
|
+
renameFailed: string;
|
|
44
|
+
conflict: string;
|
|
45
|
+
reload: string;
|
|
46
|
+
addText: string;
|
|
47
|
+
addShape: string;
|
|
48
|
+
addImage: string;
|
|
49
|
+
addChart: string;
|
|
50
|
+
addTable: string;
|
|
51
|
+
elementText: string;
|
|
52
|
+
elementShape: string;
|
|
53
|
+
elementImage: string;
|
|
54
|
+
elementChart: string;
|
|
55
|
+
elementTable: string;
|
|
56
|
+
slide: string;
|
|
57
|
+
objects: (count: number) => string;
|
|
58
|
+
background: string;
|
|
59
|
+
positionAndSize: string;
|
|
60
|
+
width: string;
|
|
61
|
+
height: string;
|
|
62
|
+
angle: string;
|
|
63
|
+
align: string;
|
|
64
|
+
alignLeft: string;
|
|
65
|
+
alignCentre: string;
|
|
66
|
+
alignRight: string;
|
|
67
|
+
bringForward: string;
|
|
68
|
+
size: string;
|
|
69
|
+
weight: string;
|
|
70
|
+
regular: string;
|
|
71
|
+
bold: string;
|
|
72
|
+
textAlignment: string;
|
|
73
|
+
left: string;
|
|
74
|
+
centre: string;
|
|
75
|
+
right: string;
|
|
76
|
+
colour: string;
|
|
77
|
+
rectangle: string;
|
|
78
|
+
ellipse: string;
|
|
79
|
+
imageAddress: string;
|
|
80
|
+
chooseImage: string;
|
|
81
|
+
imageTitle: string;
|
|
82
|
+
description: string;
|
|
83
|
+
data: string;
|
|
84
|
+
chartType: string;
|
|
85
|
+
bar: string;
|
|
86
|
+
line: string;
|
|
87
|
+
values: string;
|
|
88
|
+
valuesHint: string;
|
|
89
|
+
rows: string;
|
|
90
|
+
rowsHint: string;
|
|
91
|
+
headingColour: string;
|
|
92
|
+
}
|
|
93
|
+
declare const ENGLISH_WORDS: SlidesWords;
|
|
94
|
+
/** Machine-written and not yet reviewed. */
|
|
95
|
+
declare const ZH_HANS_WORDS: SlidesWords;
|
|
96
|
+
|
|
97
|
+
interface DeckSummary {
|
|
98
|
+
id: string;
|
|
99
|
+
title: string;
|
|
100
|
+
updatedAt: string;
|
|
101
|
+
}
|
|
102
|
+
interface StoredDeck {
|
|
103
|
+
id: string;
|
|
104
|
+
title: string;
|
|
105
|
+
/** The document as stored. Empty for a new deck. */
|
|
106
|
+
document: unknown;
|
|
107
|
+
/** The version this document was read at, opaque to the shell. */
|
|
108
|
+
version: string;
|
|
109
|
+
}
|
|
110
|
+
/** A save refused because somebody saved since this editor read the deck. */
|
|
111
|
+
declare class SlidesConflict extends Error {
|
|
112
|
+
}
|
|
113
|
+
interface SlidesStore {
|
|
114
|
+
list: () => Promise<DeckSummary[]>;
|
|
115
|
+
get: (id: string) => Promise<StoredDeck>;
|
|
116
|
+
create: (title: string) => Promise<StoredDeck>;
|
|
117
|
+
rename: (id: string, title: string) => Promise<void>;
|
|
118
|
+
/** Writes the document whole, and answers its new version. Rejects with
|
|
119
|
+
* `SlidesConflict` when `version` is no longer the stored one. */
|
|
120
|
+
save: (id: string, document: unknown, version: string) => Promise<string>;
|
|
121
|
+
remove: (id: string) => Promise<void>;
|
|
122
|
+
}
|
|
123
|
+
interface SlidesHost {
|
|
124
|
+
store: SlidesStore;
|
|
125
|
+
/** Absent: a person may. */
|
|
126
|
+
canCreate?: boolean;
|
|
127
|
+
canDelete?: boolean;
|
|
128
|
+
/** Choose an image for a slide, answering its address. Absent: the image field
|
|
129
|
+
* takes a typed address. */
|
|
130
|
+
pickImage?: () => Promise<string | null>;
|
|
131
|
+
/** The app's words in the host's language. Absent: English. */
|
|
132
|
+
words?: SlidesWords;
|
|
133
|
+
}
|
|
134
|
+
/** Decks in this browser. Two tabs of one deck still refuse each other's stale
|
|
135
|
+
* saves, through the version. */
|
|
136
|
+
declare const browserSlidesStore: SlidesStore;
|
|
137
|
+
declare function SlidesProvider({ value, children }: {
|
|
138
|
+
value: SlidesHost;
|
|
139
|
+
children: ReactNode;
|
|
140
|
+
}): react.JSX.Element;
|
|
141
|
+
|
|
142
|
+
interface Box {
|
|
143
|
+
x: number;
|
|
144
|
+
y: number;
|
|
145
|
+
w: number;
|
|
146
|
+
h: number;
|
|
147
|
+
}
|
|
148
|
+
interface ElementBase extends Box {
|
|
149
|
+
id: string;
|
|
150
|
+
rotation: number;
|
|
151
|
+
}
|
|
152
|
+
interface TextElement extends ElementBase {
|
|
153
|
+
type: 'text';
|
|
154
|
+
text: string;
|
|
155
|
+
fontSize: number;
|
|
156
|
+
bold: boolean;
|
|
157
|
+
color: string;
|
|
158
|
+
align: 'left' | 'center' | 'right';
|
|
159
|
+
}
|
|
160
|
+
interface ShapeElement extends ElementBase {
|
|
161
|
+
type: 'shape';
|
|
162
|
+
shape: 'rect' | 'ellipse';
|
|
163
|
+
fill: string;
|
|
164
|
+
}
|
|
165
|
+
interface ImageElement extends ElementBase {
|
|
166
|
+
type: 'image';
|
|
167
|
+
src: string;
|
|
168
|
+
alt: string;
|
|
169
|
+
}
|
|
170
|
+
interface ChartPoint {
|
|
171
|
+
label: string;
|
|
172
|
+
value: number;
|
|
173
|
+
}
|
|
174
|
+
interface ChartElement extends ElementBase {
|
|
175
|
+
type: 'chart';
|
|
176
|
+
kind: 'bar' | 'line';
|
|
177
|
+
points: ChartPoint[];
|
|
178
|
+
color: string;
|
|
179
|
+
}
|
|
180
|
+
interface TableElement extends ElementBase {
|
|
181
|
+
type: 'table';
|
|
182
|
+
rows: string[][];
|
|
183
|
+
headerFill: string;
|
|
184
|
+
}
|
|
185
|
+
type SlideElement = TextElement | ShapeElement | ImageElement | ChartElement | TableElement;
|
|
186
|
+
interface Slide {
|
|
187
|
+
id: string;
|
|
188
|
+
background: string;
|
|
189
|
+
notes: string;
|
|
190
|
+
elements: SlideElement[];
|
|
191
|
+
}
|
|
192
|
+
interface DeckDocument {
|
|
193
|
+
slides: Slide[];
|
|
194
|
+
}
|
|
195
|
+
/** A document that came back from the server with nothing in it yet. */
|
|
196
|
+
declare function asDocument(stored: unknown): DeckDocument;
|
|
197
|
+
|
|
198
|
+
/** The slide at `width` pixels. `editingId`'s element gives way to `editor`. */
|
|
199
|
+
declare function SlideView({ slide, width, editingId, editor, }: {
|
|
200
|
+
slide: Slide;
|
|
201
|
+
width: number;
|
|
202
|
+
editingId?: string | null;
|
|
203
|
+
editor?: ReactNode;
|
|
204
|
+
}): react.JSX.Element;
|
|
205
|
+
|
|
206
|
+
declare const Slides: ComponentType;
|
|
207
|
+
/** One deck in the editor, for a host with an address of its own for each file. */
|
|
208
|
+
declare const DeckEditor: ComponentType<{
|
|
209
|
+
id: string;
|
|
210
|
+
onClose: () => void;
|
|
211
|
+
}>;
|
|
212
|
+
declare const slidesApps: {
|
|
213
|
+
readonly '/slides': {
|
|
214
|
+
readonly component: react.FunctionComponent<{}>;
|
|
215
|
+
readonly label: "Slides";
|
|
216
|
+
readonly size: "3xl";
|
|
217
|
+
readonly appStyle: true;
|
|
218
|
+
readonly flushBody: true;
|
|
219
|
+
readonly autoHeight: false;
|
|
220
|
+
};
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
export { DeckEditor, type DeckSummary, ENGLISH_WORDS, SlideView, Slides, SlidesConflict, type SlidesHost, SlidesProvider, type SlidesStore, type SlidesWords, type StoredDeck, ZH_HANS_WORDS, asDocument, browserSlidesStore, slidesApps };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{SlideView as e,asDocument as o}from"../chunk-3JJCHWPJ.js";import{ENGLISH_WORDS as t,SlidesConflict as i,SlidesProvider as r,ZH_HANS_WORDS as s,browserSlidesStore as l}from"../chunk-BTDWPUTS.js";import{lazy as p}from"react";var m=p(()=>import("../Slides-ILKPLYAJ.js")),a=p(()=>import("../Slides-ILKPLYAJ.js").then(e=>({default:e.OpenDeck}))),d={"/slides":{component:m,label:"Slides",size:"3xl",appStyle:!0,flushBody:!0,autoHeight:!1}};export{a as DeckEditor,t as ENGLISH_WORDS,e as SlideView,m as Slides,i as SlidesConflict,r as SlidesProvider,s as ZH_HANS_WORDS,o as asDocument,l as browserSlidesStore,d as slidesApps};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/* The Slides app (src/apps/slides). */
|
|
2
|
+
.slides-editor { --slides-accent: var(--accent-600, var(--submit-bg)); position: relative; display: flex; flex-direction: column; height: 100%; min-height: 0; outline: none; background: var(--surface); color: var(--ink); }
|
|
3
|
+
.slides-body { flex: 1; display: flex; min-height: 0; }
|
|
4
|
+
.slides-top { display: flex; align-items: center; gap: 6px; padding: 6px 10px; border-bottom: 1px solid var(--line); }
|
|
5
|
+
.slides-top-gap { flex: 1; }
|
|
6
|
+
.slides-title { width: 240px; }
|
|
7
|
+
.slides-save { font-size: 12px; opacity: 0.7; white-space: nowrap; }
|
|
8
|
+
.slides-conflict { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 12px; background: var(--status-warning-bg, var(--surface-raised)); border-bottom: 1px solid var(--line); font-size: 12px; }
|
|
9
|
+
|
|
10
|
+
.slides-rail { width: 190px; flex: none; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 10px; border-right: 1px solid var(--line); background: var(--surface-raised); }
|
|
11
|
+
.slides-thumb { display: grid; grid-template-columns: 16px 1fr; gap: 4px; cursor: grab; }
|
|
12
|
+
.slides-thumb-number { font-size: 12px; opacity: 0.7; }
|
|
13
|
+
.slides-thumb-image { border: 1px solid var(--line); border-radius: 3px; overflow: hidden; cursor: pointer; width: fit-content; }
|
|
14
|
+
.slides-thumb[data-current] .slides-thumb-image { outline: 2px solid var(--slides-accent); outline-offset: 1px; }
|
|
15
|
+
.slides-thumb-actions { grid-column: 2; display: flex; justify-content: flex-end; gap: 2px; }
|
|
16
|
+
|
|
17
|
+
.slides-centre { flex: 1; min-width: 0; display: flex; flex-direction: column; }
|
|
18
|
+
.slides-toolbar { display: flex; gap: 2px; padding: 4px 8px; border-bottom: 1px solid var(--line); background: var(--surface); }
|
|
19
|
+
.slides-pane { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; background: var(--surface-raised); }
|
|
20
|
+
.slides-stage { position: relative; flex: none; touch-action: none; user-select: none; outline: 1px solid var(--line); }
|
|
21
|
+
.slides-notes { display: flex; flex-direction: column; gap: 4px; padding: 8px 12px; border-top: 1px solid var(--line); font-size: 12px; background: var(--surface); }
|
|
22
|
+
|
|
23
|
+
.slides-text-edit { width: 100%; height: 100%; line-height: 1.25; white-space: pre-wrap; overflow-wrap: break-word; outline: 2px solid var(--slides-accent); user-select: text; font-family: Inter, ui-sans-serif, system-ui, sans-serif; cursor: text; }
|
|
24
|
+
.slides-selection { position: absolute; box-sizing: border-box; border: 1.5px solid var(--slides-accent); pointer-events: none; }
|
|
25
|
+
.slides-handle { position: absolute; width: 12px; height: 12px; margin: -6px 0 0 -6px; box-sizing: border-box; background: #fff; border: 1.5px solid var(--slides-accent); border-radius: 2px; pointer-events: auto; touch-action: none; }
|
|
26
|
+
.slides-handle-nw { left: 0; top: 0; cursor: nwse-resize; }
|
|
27
|
+
.slides-handle-n { left: 50%; top: 0; cursor: ns-resize; }
|
|
28
|
+
.slides-handle-ne { left: 100%; top: 0; cursor: nesw-resize; }
|
|
29
|
+
.slides-handle-e { left: 100%; top: 50%; cursor: ew-resize; }
|
|
30
|
+
.slides-handle-se { left: 100%; top: 100%; cursor: nwse-resize; }
|
|
31
|
+
.slides-handle-s { left: 50%; top: 100%; cursor: ns-resize; }
|
|
32
|
+
.slides-handle-sw { left: 0; top: 100%; cursor: nesw-resize; }
|
|
33
|
+
.slides-handle-w { left: 0; top: 50%; cursor: ew-resize; }
|
|
34
|
+
.slides-rotate-stem { position: absolute; left: 50%; top: -22px; width: 1.5px; height: 22px; background: var(--slides-accent); }
|
|
35
|
+
.slides-rotate { position: absolute; left: 50%; top: -36px; width: 14px; height: 14px; margin-left: -7px; box-sizing: border-box; border-radius: 50%; background: #fff; border: 1.5px solid var(--slides-accent); pointer-events: auto; cursor: grab; touch-action: none; }
|
|
36
|
+
.slides-guide { position: absolute; pointer-events: none; }
|
|
37
|
+
.slides-guide-x { top: 0; bottom: 0; border-left: 1px dashed #d4537e; }
|
|
38
|
+
.slides-guide-y { left: 0; right: 0; border-top: 1px dashed #d4537e; }
|
|
39
|
+
.slides-marquee { position: absolute; border: 1px solid var(--slides-accent); background: color-mix(in srgb, var(--slides-accent) 12%, transparent); pointer-events: none; }
|
|
40
|
+
|
|
41
|
+
.slides-inspector { width: 240px; flex: none; overflow-y: auto; border-left: 1px solid var(--line); background: var(--surface); font-size: 12px; }
|
|
42
|
+
.slides-inspector h3 { margin: 0; padding: 12px; font-size: 14px; font-weight: 600; border-bottom: 1px solid var(--line); }
|
|
43
|
+
.slides-section { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-bottom: 1px solid var(--line); }
|
|
44
|
+
.slides-label { margin: 0; font-size: 12px; opacity: 0.7; }
|
|
45
|
+
.slides-numbers { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
|
|
46
|
+
.slides-number { display: flex; flex-direction: column; gap: 2px; font-size: 12px; }
|
|
47
|
+
.slides-actions { display: flex; flex-wrap: wrap; gap: 2px; }
|
|
48
|
+
.slides-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
|
|
49
|
+
.slides-field small { opacity: 0.7; }
|
|
50
|
+
|
|
51
|
+
/* The speaker's screen stays dark in every theme: it sits in a dim room, beside a
|
|
52
|
+
projected slide. */
|
|
53
|
+
.slides-presenter { position: absolute; inset: 0; z-index: 30; display: flex; flex-direction: column; background: #2c2c2a; color: #f1efe8; }
|
|
54
|
+
.slides-presenter-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; border-bottom: 1px solid #5f5e5a; font-size: 12px; }
|
|
55
|
+
.slides-presenter-clock { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
|
|
56
|
+
.slides-presenter-blocked { margin: 0; padding: 8px 12px; background: #633806; font-size: 12px; }
|
|
57
|
+
.slides-presenter-body { flex: 1; min-height: 0; display: flex; gap: 16px; padding: 16px; }
|
|
58
|
+
.slides-presenter-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
|
|
59
|
+
.slides-presenter-current { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; }
|
|
60
|
+
.slides-presenter-steps { display: flex; justify-content: center; gap: 12px; }
|
|
61
|
+
.slides-presenter-side { width: 280px; flex: none; overflow-y: auto; }
|
|
62
|
+
.slides-presenter-label { margin: 0 0 6px; font-size: 12px; color: #b4b2a9; }
|
|
63
|
+
.slides-presenter-side .slides-presenter-label:not(:first-child) { margin-top: 16px; }
|
|
64
|
+
.slides-presenter-notes { margin: 0; font-size: 18px; line-height: 1.5; white-space: pre-wrap; }
|
|
65
|
+
|
|
66
|
+
.slides-list { display: flex; flex-direction: column; height: 100%; color: var(--ink); }
|
|
67
|
+
.slides-list-head { display: flex; align-items: center; justify-content: space-between; padding: 16px; border-bottom: 1px solid var(--line); }
|
|
68
|
+
.slides-list-head h2 { margin: 0; font-size: 16px; font-weight: 500; }
|
|
69
|
+
.slides-list-empty { padding: 24px; }
|
|
70
|
+
.slides-list-rows { flex: 1; overflow-y: auto; margin: 0; padding: 0; list-style: none; }
|
|
71
|
+
.slides-list-row { display: flex; align-items: center; gap: 12px; padding: 8px 16px; border-bottom: 1px solid var(--line); }
|
|
72
|
+
.slides-list-date { flex: 1; text-align: right; font-size: 14px; opacity: 0.7; }
|
package/package.json
CHANGED
|
@@ -1,13 +1,73 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "efficient-office",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "",
|
|
5
|
-
"
|
|
3
|
+
"version": "0.2.1",
|
|
4
|
+
"description": "Efficient Office: the EFFICIENT office apps, on efficient-shell and efficient-easel.",
|
|
5
|
+
"license": "UNLICENSED",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/Efficient-Pty-Ltd/efficient-office.git"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://github.com/Efficient-Pty-Ltd/efficient-office#readme",
|
|
11
|
+
"type": "module",
|
|
12
|
+
"files": [
|
|
13
|
+
"dist"
|
|
14
|
+
],
|
|
15
|
+
"sideEffects": [
|
|
16
|
+
"**/*.css"
|
|
17
|
+
],
|
|
18
|
+
"exports": {
|
|
19
|
+
"./slides": {
|
|
20
|
+
"types": "./dist/slides/index.d.ts",
|
|
21
|
+
"import": "./dist/slides/index.js",
|
|
22
|
+
"default": "./dist/slides/index.js"
|
|
23
|
+
},
|
|
24
|
+
"./slides.css": "./dist/slides/slides.css"
|
|
25
|
+
},
|
|
6
26
|
"scripts": {
|
|
7
|
-
"
|
|
27
|
+
"build": "tsup && cp src/slides/slides.css dist/slides/slides.css",
|
|
28
|
+
"typecheck": "tsc --noEmit",
|
|
29
|
+
"test": "vitest run",
|
|
30
|
+
"standalone:dev": "vite standalone",
|
|
31
|
+
"standalone:build": "vite build standalone"
|
|
32
|
+
},
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"efficient-easel": "^26.8.0",
|
|
35
|
+
"efficient-shell": "^11.1.0",
|
|
36
|
+
"pptxgenjs": "^4.0.1",
|
|
37
|
+
"react": ">=19",
|
|
38
|
+
"react-dom": ">=19"
|
|
39
|
+
},
|
|
40
|
+
"peerDependenciesMeta": {
|
|
41
|
+
"pptxgenjs": {
|
|
42
|
+
"optional": true
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"publishConfig": {
|
|
46
|
+
"access": "public"
|
|
8
47
|
},
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@headlessui/react": "^2.2.10",
|
|
50
|
+
"@tailwindcss/vite": "^4.3.3",
|
|
51
|
+
"@tanstack/react-query": "^5.105.1",
|
|
52
|
+
"@testing-library/dom": "^10.4.2",
|
|
53
|
+
"@testing-library/react": "^16.3.3",
|
|
54
|
+
"@types/node": "^26.6.6",
|
|
55
|
+
"@types/react": "^19.3.0",
|
|
56
|
+
"@types/react-dom": "^19.3.0",
|
|
57
|
+
"@vitejs/plugin-react": "^6.1.2",
|
|
58
|
+
"efficient-easel": "^26.8.0",
|
|
59
|
+
"efficient-shell": "^11.8.0",
|
|
60
|
+
"jsdom": "^30.1.3",
|
|
61
|
+
"jszip": "^3.10.2",
|
|
62
|
+
"pptxgenjs": "^4.0.1",
|
|
63
|
+
"react": "^19.3.1",
|
|
64
|
+
"react-dom": "^19.3.1",
|
|
65
|
+
"react-router-dom": "^7.18.5",
|
|
66
|
+
"tailwindcss": "^4.3.3",
|
|
67
|
+
"terser": "^5.51.2",
|
|
68
|
+
"tsup": "^8.5.1",
|
|
69
|
+
"typescript": "^5.9.3",
|
|
70
|
+
"vite": "^8.3.5",
|
|
71
|
+
"vitest": "^5.0.5"
|
|
72
|
+
}
|
|
13
73
|
}
|