woo / assets /DigitalWhiteboard-Ch5_H4le.js
admin08077's picture
Upload 117 files
c43d926 verified
import{r as c,j as t}from"./react-DKy9e2uO.js";import{u as v,p as k,q as S,S as C,L as z,M}from"./index-MnghlAu6.js";import"./bottleneck-Cpj98o6Y.js";import"./react-dom-CpxHE_eW.js";import"./scheduler-DYLXRpC5.js";import"./@google-CZdO-yDN.js";import"./idb-Dob3nYDb.js";import"./marked-CesSW9Du.js";import"./jszip-s56H2EZ-.js";const d=["bg-yellow-400","bg-green-400","bg-blue-400","bg-pink-400","bg-purple-400","bg-orange-400"],D=["text-yellow-900","text-green-900","text-blue-900","text-pink-900","text-purple-900","text-orange-900"],W=()=>{const[s,u]=v("devcore_whiteboard_notes",[]),[a,p]=c.useState(null),[n,g]=c.useState(!1),[m,l]=c.useState(""),h=c.useCallback(async()=>{if(s.length!==0){g(!0),l("");try{const e=s.map(i=>`- ${i.text}`).join(`
`),r=k(e);let o="";for await(const i of r)o+=i,l(o)}catch(e){console.error(e),l("Sorry, an error occurred while summarizing.")}finally{g(!1)}}},[s]),y=()=>{const e={id:Date.now(),text:"New idea...",x:50,y:50,color:d[s.length%d.length]};u([...s,e])},j=(e,r)=>{r.stopPropagation(),u(s.filter(o=>o.id!==e))},x=(e,r)=>{u(s.map(o=>o.id===e?{...o,...r}:o))},N=(e,r)=>{const o=e.target;if(o.tagName==="TEXTAREA"||o.dataset.role==="button")return;const b=e.currentTarget.getBoundingClientRect();p({id:r,offsetX:e.clientX-b.left,offsetY:e.clientY-b.top})},w=e=>{if(!a)return;const r=e.currentTarget.getBoundingClientRect();x(a.id,{x:e.clientX-a.offsetX-r.left,y:e.clientY-a.offsetY-r.top})},f=()=>p(null);return t.jsxs("div",{className:"h-full flex flex-col p-4 sm:p-6 lg:p-8 text-text-primary",children:[t.jsxs("header",{className:"mb-6 flex justify-between items-center",children:[t.jsxs("div",{children:[t.jsxs("h1",{className:"text-3xl font-bold flex items-center",children:[t.jsx(S,{}),t.jsx("span",{className:"ml-3",children:"Digital Whiteboard"})]}),t.jsx("p",{className:"text-text-secondary mt-1",children:"Organize your ideas with interactive sticky notes and AI summaries."})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsxs("button",{onClick:h,disabled:n||s.length===0,className:"btn-primary flex items-center gap-2 px-4 py-2",children:[t.jsx(C,{})," ",n?"Summarizing...":"AI Summarize"]}),t.jsx("button",{onClick:y,className:"btn-primary px-6 py-2",children:"Add Note"})]})]}),t.jsx("div",{className:"relative flex-grow bg-background border-2 border-dashed border-border rounded-lg overflow-hidden",onMouseMove:w,onMouseUp:f,onMouseLeave:f,children:s.map(e=>t.jsxs("div",{className:`group absolute w-56 h-56 p-2 flex flex-col shadow-lg cursor-grab active:cursor-grabbing rounded-md transition-transform duration-100 border border-black/40 ${e.color} ${D[d.indexOf(e.color)]}`,style:{top:e.y,left:e.x,transform:(a==null?void 0:a.id)===e.id?"scale(1.05)":"scale(1)"},onMouseDown:r=>N(r,e.id),children:[t.jsx("button",{"data-role":"button",onClick:r=>j(e.id,r),className:"absolute -top-2 -right-2 w-6 h-6 rounded-full bg-gray-700 text-white font-bold text-xs flex items-center justify-center opacity-0 group-hover:opacity-100 hover:bg-red-500 transition-all",children:"×"}),t.jsx("textarea",{value:e.text,onChange:r=>x(e.id,{text:r.target.value}),className:"w-full h-full bg-transparent resize-none focus:outline-none font-medium p-1"}),t.jsx("div",{"data-role":"button",className:"flex-shrink-0 flex justify-center gap-1 p-1 opacity-0 group-hover:opacity-100 transition-opacity",children:d.map((r,o)=>t.jsx("button",{onClick:()=>x(e.id,{color:r}),className:`w-4 h-4 rounded-full ${r} border border-black/20 ${e.color===r?"ring-2 ring-offset-1 ring-black/50":""}`},r))})]},e.id))}),(n||m)&&t.jsx("div",{className:"fixed inset-0 bg-gray-900/80 backdrop-blur-sm z-50 flex items-center justify-center",onClick:()=>l(""),children:t.jsxs("div",{className:"w-full max-w-2xl bg-surface border border-border rounded-lg shadow-2xl p-6",onClick:e=>e.stopPropagation(),children:[t.jsx("h2",{className:"text-xl font-bold mb-4",children:"AI Summary of Notes"}),n&&!m?t.jsx(z,{}):t.jsx(M,{content:m})]})})]})};export{W as DigitalWhiteboard};
//# sourceMappingURL=DigitalWhiteboard-Ch5_H4le.js.map