tiptop-editor 2.3.0 → 2.3.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.
@@ -16792,13 +16792,13 @@ const e0 = ge(({ items: t, command: e }, n) => {
16792
16792
  }), document.body.appendChild(t.element), sl(e.editor, t.element));
16793
16793
  },
16794
16794
  onUpdate(e) {
16795
- t.updateProps(e), e.clientRect && sl(e.editor, t.element);
16795
+ t && (t.updateProps(e), e.clientRect && sl(e.editor, t.element));
16796
16796
  },
16797
16797
  onKeyDown(e) {
16798
- return e.event.key === "Escape" ? (t.destroy(), t.element.remove(), t.editor.commands.setMeta("lockDragHandle", !1), !0) : t.ref?.onKeyDown(e) || !1;
16798
+ return t ? e.event.key === "Escape" ? (t.destroy(), t.element.remove(), t.editor.commands.setMeta("lockDragHandle", !1), !0) : t.ref?.onKeyDown(e) || !1 : !1;
16799
16799
  },
16800
16800
  onExit() {
16801
- t.destroy(), t.element.remove(), t.editor.commands.setMeta("lockDragHandle", !1);
16801
+ t && (t.destroy(), t.element.remove(), t.editor.commands.setMeta("lockDragHandle", !1));
16802
16802
  }
16803
16803
  };
16804
16804
  }
@@ -17341,13 +17341,13 @@ const a0 = xe.create({
17341
17341
  }), t.element.style.position = "fixed", document.body.appendChild(t.element), ll(e.editor, t.element));
17342
17342
  },
17343
17343
  onUpdate(e) {
17344
- t.updateProps(e), e.clientRect && ll(e.editor, t.element);
17344
+ t && (t.updateProps(e), e.clientRect && ll(e.editor, t.element));
17345
17345
  },
17346
17346
  onKeyDown(e) {
17347
- return e.event.key === "Escape" ? (t.destroy(), t.element.remove(), t.editor.commands.setMeta("lockDragHandle", !1), !0) : t.ref?.onKeyDown(e) || !1;
17347
+ return t ? e.event.key === "Escape" ? (t.destroy(), t.element.remove(), t.editor.commands.setMeta("lockDragHandle", !1), !0) : t.ref?.onKeyDown(e) || !1 : !1;
17348
17348
  },
17349
17349
  onExit() {
17350
- t.destroy(), t.element.remove(), t.editor.commands.setMeta("lockDragHandle", !1);
17350
+ t && (t.destroy(), t.element.remove(), t.editor.commands.setMeta("lockDragHandle", !1));
17351
17351
  }
17352
17352
  };
17353
17353
  }
@@ -40,4 +40,4 @@ ${h}`}}),l}var xr=class Yd extends Ja{constructor(){super(...arguments),this.typ
40
40
  `;const g=new Array(i).fill(0).map((b,w)=>u&&d[w]&&d[w].text||"");return p+=`| ${g.map((b,w)=>l(b,s[w])).join(" | ")} |
41
41
  `,p+=`| ${s.map((b,w)=>{const y=Math.max(3,b),x=f[w];return x==="left"?`:${"-".repeat(y)}`:x==="right"?`${"-".repeat(y)}:`:x==="center"?`:${"-".repeat(y)}:`:"-".repeat(y)}).join(" | ")} |
42
42
  `,(u?n.slice(1):n).forEach(b=>{p+=`| ${new Array(i).fill(0).map((w,y)=>l(b[y]&&b[y].text||"",s[y])).join(" | ")} |
43
- `}),p}var Gw=qw,Yw=xr.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:Fw,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:t,HTMLAttributes:e}){const{colgroup:r,tableWidth:o,tableMinWidth:a}=Bw(t,this.options.cellMinWidth),n=e.style;function i(){return n||(o?`width: ${o}`:`min-width: ${a}`)}const s=["table",Vt(this.options.HTMLAttributes,e,{style:i()}),r,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},s]:s},parseMarkdown:(t,e)=>{const r=[],o=Array.isArray(t.align)?t.align:[];if(t.header){const a=[];t.header.forEach((n,i)=>{var s;const l=So((s=o[i])!=null?s:n.align),d=l?{align:l}:{};a.push(e.createNode("tableHeader",d,[{type:"paragraph",content:e.parseInline(n.tokens)}]))}),r.push(e.createNode("tableRow",{},a))}return t.rows&&t.rows.forEach(a=>{const n=[];a.forEach((i,s)=>{var l;const d=So((l=o[s])!=null?l:i.align),u=d?{align:d}:{};n.push(e.createNode("tableCell",u,[{type:"paragraph",content:e.parseInline(i.tokens)}]))}),r.push(e.createNode("tableRow",{},n))}),e.createNode("table",void 0,r)},renderMarkdown:(t,e)=>Gw(t,e),addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:r=!0}={})=>({tr:o,dispatch:a,editor:n})=>{const i=Vw(n.schema,t,e,r);if(a){const s=o.selection.from+1;o.replaceSelectionWith(i).scrollIntoView().setSelection(F.TextSelection.near(o.doc.resolve(s)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>ae.addColumnBefore(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>ae.addColumnAfter(t,e),deleteColumn:()=>({state:t,dispatch:e})=>ae.deleteColumn(t,e),addRowBefore:()=>({state:t,dispatch:e})=>ae.addRowBefore(t,e),addRowAfter:()=>({state:t,dispatch:e})=>ae.addRowAfter(t,e),deleteRow:()=>({state:t,dispatch:e})=>ae.deleteRow(t,e),deleteTable:()=>({state:t,dispatch:e})=>ae.deleteTable(t,e),mergeCells:()=>({state:t,dispatch:e})=>ae.mergeCells(t,e),splitCell:()=>({state:t,dispatch:e})=>ae.splitCell(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>ae.toggleHeader("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>ae.toggleHeader("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>ae.toggleHeaderCell(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>ae.mergeCells(t,e)?!0:ae.splitCell(t,e),setCellAttribute:(t,e)=>({state:r,dispatch:o})=>ae.setCellAttr(t,e)(r,o),goToNextCell:()=>({state:t,dispatch:e})=>ae.goToNextCell(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>ae.goToNextCell(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&ae.fixTables(t),!0),setCellSelection:t=>({tr:e,dispatch:r})=>{if(r){const o=ae.CellSelection.create(e.doc,t.anchorCell,t.headCell);e.setSelection(o)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:Po,"Mod-Backspace":Po,Delete:Po,"Mod-Delete":Po}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[ae.columnResizing({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],ae.tableEditing({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){const e={name:t.name,options:t.options,storage:t.storage};return{tableRole:wo(Ht(t,"tableRole",e))}}}),Zw=pe.create({name:"tableKit",addExtensions(){const t=[];return this.options.table!==!1&&t.push(Yw.configure(this.options.table)),this.options.tableCell!==!1&&t.push(zw.configure(this.options.tableCell)),this.options.tableHeader!==!1&&t.push(jw.configure(this.options.tableHeader)),this.options.tableRow!==!1&&t.push(Ow.configure(this.options.tableRow)),t}}),Jw=pe.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:t=>{const e=t.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:t=>t.textAlign?{style:`text-align: ${t.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:t=>({commands:e})=>this.options.alignments.includes(t)?this.options.types.map(r=>e.updateAttributes(r,{textAlign:t})).some(r=>r):!1,unsetTextAlign:()=>({commands:t})=>this.options.types.map(e=>t.resetAttributes(e,"textAlign")).some(e=>e),toggleTextAlign:t=>({editor:e,commands:r})=>this.options.alignments.includes(t)?e.isActive({textAlign:t})?r.unsetTextAlign():r.setTextAlign(t):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),Xw=Jw;const Qw=c.forwardRef(({items:t,command:e},r)=>{const[o,a]=c.useState(0);c.useImperativeHandle(r,()=>({onKeyDown({event:d}){return d.key==="ArrowUp"?(n(),!0):d.key==="ArrowDown"?(i(),!0):d.key==="Enter"?(s(),!0):!1}})),c.useEffect(()=>{a(0)},[t]);const n=()=>{a(d=>(d+t.length-1)%t.length)},i=()=>{a(d=>(d+1)%t.length)},s=()=>{l(o)},l=d=>{const u=t[d];u&&e(u)};return m.jsx("div",{className:"w-full max-w-[250px] max-h-[500px] bg-background border shadow rounded-2xl flex flex-col gap-1 p-2.5 relative overflow-hidden",children:m.jsx("div",{className:"w-full flex flex-col gap-1 overflow-y-auto",children:t.length>0?t.map((d,u)=>m.jsxs("button",{className:tr("w-full h-7 rounded-lg flex gap-1.5 items-center p-2 bg-transparent hover:bg-default/10 cursor-pointer text-muted transition-all",o===u?"bg-default/10 text-accent":"hover:text-foreground"),"data-emoji-name":d.name,onClick:()=>l(u),children:[d.fallbackImage?m.jsx("img",{src:d.fallbackImage,width:20,height:20,alt:d.emoji}):d.emoji," ",m.jsx("span",{title:d.name,className:"text-sm text-ellipsis overflow-hidden",children:d.name})]},d.name)):m.jsx("p",{className:"text-muted text-sm",children:"No results"})})})}),zd=(t,e)=>{const r={getBoundingClientRect:()=>ud(t.view,t.state.selection.from,t.state.selection.to)};ye.computePosition(r,e,{placement:"bottom-start"}).then(o=>{Object.assign(e.style,{left:`${o.x}px`,top:`${o.y}px`,position:o.strategy==="fixed"?"fixed":"absolute",zIndex:"9999"})})},ey={allowSpaces:!1,items:({editor:t,query:e})=>t.storage.emoji.emojis.filter(({name:r,tags:o})=>r.toLocaleLowerCase().trim().startsWith(e.toLocaleLowerCase().trim())||o.find(a=>a.startsWith(e.toLowerCase()))).slice(0,50),render:()=>{let t;return{onStart:e=>{e.clientRect&&(e.editor.commands.setMeta("lockDragHandle",!0),t=new Be.ReactRenderer(Qw,{props:e,editor:e.editor}),document.body.appendChild(t.element),zd(e.editor,t.element))},onUpdate(e){t.updateProps(e),e.clientRect&&zd(e.editor,t.element)},onKeyDown(e){return e.event.key==="Escape"?(t.destroy(),t.element.remove(),t.editor.commands.setMeta("lockDragHandle",!1),!0):t.ref?.onKeyDown(e)||!1},onExit(){t.destroy(),t.element.remove(),t.editor.commands.setMeta("lockDragHandle",!1)}}}},ty=wn.configure({emojis:wn.gitHubEmojis,enableEmoticons:!0,forceFallbackImages:!1,suggestion:ey}).extend({addProseMirrorPlugins(){return[bn({editor:this.editor,...this.options.suggestion,decorationClass:"tiptop-slash-highlight"})]}}),ry=t=>{const e=c.useRef(0),r=c.useRef(null),o=c.useRef(null),[a,n]=c.useState(!1),{editor:i,node:s}=t,{uploading:l,src:d,failed:u,progress:f,selectMedia:p,id:g,errorMessage:h,name:b,size:w}=s.attrs,y=()=>{o.current?.click()},x=P=>{if(l)return;const I=P.target.files?.[0];if(I&&g){r.current=I;const K=typeof t.getPos=="function"?t.getPos():void 0;i?.storage.imageUploaderExtension.uploadImageFromFile(i,I,g,!0,K)}o.current&&(o.current.value="")},$=P=>{P.preventDefault()},k=c.useCallback(P=>{if(P.preventDefault(),P.stopPropagation(),P.nativeEvent.stopImmediatePropagation(),e.current=0,n(!1),l)return;const I=P.dataTransfer?.files?.[0];if(I&&g){r.current=I;const K=typeof t.getPos=="function"?t.getPos():void 0;i?.storage.imageUploaderExtension.uploadImageFromFile(i,I,g,!0,K)}o.current&&(o.current.value="")},[i,g,t,l]),N=()=>{e.current++,n(!0)},L=()=>{e.current--,e.current===0&&n(!1)},S=()=>{const P=typeof t.getPos=="function"?t.getPos():void 0;i?.storage.imageUploaderExtension.cancelUpload(i,g,P),Co("Info","accent","Upload cancelled")};return c.useEffect(()=>{(u||h)&&(Co("Error","danger",h),t.updateAttributes({failed:!1,selectMedia:!0,errorMessage:null}))},[u,h,t]),m.jsx(Be.NodeViewWrapper,{"data-drag-handle":!0,"data-uploading":l,"data-type":"image-uploader",className:"w-full h-full rounded-lg",onDrop:!l&&!d?k:void 0,onDragOver:!l&&!d?$:void 0,onDragEnter:!l&&!d?N:void 0,onDragLeave:!l&&!d?L:void 0,children:m.jsxs("div",{className:tr(a?"bg-accent-soft":" bg-background",p?"border border-dashed px-6 py-8":"","w-full h-full flex flex-col rounded-lg text-center cursor-pointer relative overflow-hidden transition-all"),draggable:!1,contentEditable:!1,children:[m.jsx("input",{type:"file",ref:o,style:{display:"none"},accept:"image/png, image/jpeg, image/jpg",onChange:x}),p&&!l&&m.jsxs("div",{onClick:y,className:"flex flex-col gap-2 items-center justify-center",children:[m.jsx("div",{children:m.jsx(he,{name:"File",className:"w-14 h-14"})}),m.jsxs("div",{className:"flex flex-col items-center justify-center gap-1",children:[m.jsxs("span",{className:"text-foreground-700 font-normal text-sm",children:[m.jsx("span",{className:"underline",children:"Click to upload "}),"or drag and drop"]}),m.jsx("span",{className:"text-foreground-400 font-medium text-xs",children:"Maximum file size 5MB."})]})]}),l&&m.jsxs("div",{className:"w-full flex justify-between items-center gap-5 border p-4 overflow-hidden rounded-lg relative",children:[m.jsx("div",{className:"h-full bg-accent-soft dark:bg-accent/20 absolute top-0 left-0 z-0 transition-all",style:{width:`${f}%`}}),m.jsxs("div",{className:"w-full flex items-center gap-3 z-1",children:[m.jsx("div",{className:"w-[46px] h-10 flex items-center justify-center bg-accent dark:bg-foreground rounded-lg",children:m.jsx(he,{name:"CloudUpload",className:"text-background w-6 h-6"})}),m.jsxs("div",{className:"w-full flex flex-col items-start gap-1",children:[m.jsx("span",{className:"text-sm text-foreground",children:b?b?.toLowerCase():r.current?.name.toLowerCase()}),m.jsxs("span",{className:"text-sm text-foreground-500",children:[w?(w/(1024*1024)).toFixed(2):r.current?.size?(r.current.size/(1024*1024)).toFixed(2):"0.00"," MB"]})]})]}),m.jsxs("div",{className:"flex items-center gap-3 z-1",children:[m.jsxs("span",{className:"text-sm text-accent",children:[f,"%"]}),m.jsx(De,{size:"sm",variant:"ghost",isIconOnly:!0,onPress:S,children:m.jsx(he,{name:"X"})})]})]}),!l&&d&&m.jsx("div",{className:"uploaded-image w-full pointer-events-none",children:m.jsx("img",{src:d,alt:"Uploaded",draggable:!1,style:{maxWidth:"100%"},className:"h-[350px] rounded-lg pointer-events-none select-none"})})]})})},oy=xr.create({name:"imageUploader",group:"block",defining:!0,isolating:!0,draggable:!0,selectable:!0,inline:!1,addAttributes(){return{id:{default:void 0},src:{default:null},progress:{default:0},failed:{default:!1},uploading:{default:!0},selectMedia:{default:!0},errorMessage:{default:null},name:{default:void 0},size:{default:void 0}}},parseHTML(){return[{tag:'div[data-type="image-uploader"]'}]},renderHTML({HTMLAttributes:t}){return["div",Vt(t,{"data-type":"image-uploader","data-uploading":String(t.uploading)})]},addNodeView(){return Be.ReactNodeViewRenderer(ry)},addCommands(){return{insertImageUploader:()=>({commands:t})=>{const e=mw();return t.insertContent({type:this.name,attrs:{id:e,uploading:!1,selectMedia:!0,src:null,failed:!1,progress:0,errorMessage:null}})}}}});var ay=({key:t,editor:e,onPaste:r,onDrop:o,allowedMimeTypes:a})=>new F.Plugin({key:t||new F.PluginKey("fileHandler"),props:{handleDrop(n,i){var s;if(!o||!((s=i.dataTransfer)!=null&&s.files.length))return!1;const l=n.posAtCoords({left:i.clientX,top:i.clientY});let d=Array.from(i.dataTransfer.files);return a&&(d=d.filter(u=>a.includes(u.type))),d.length===0?!1:(i.preventDefault(),i.stopPropagation(),o(e,d,l?.pos||0),!0)},handlePaste(n,i){var s;if(!r||!((s=i.clipboardData)!=null&&s.files.length))return!1;let l=Array.from(i.clipboardData.files);const d=i.clipboardData.getData("text/html");return a&&(l=l.filter(u=>a.includes(u.type))),!(l.length===0||(i.preventDefault(),i.stopPropagation(),r(e,l,d),d.length>0))}}}),ny=pe.create({name:"fileHandler",addOptions(){return{onPaste:void 0,onDrop:void 0,allowedMimeTypes:void 0}},addProseMirrorPlugins(){return[ay({key:new F.PluginKey(this.name),editor:this.editor,allowedMimeTypes:this.options.allowedMimeTypes,onDrop:this.options.onDrop,onPaste:this.options.onPaste})]}}),iy=ny;const sy=pe.create({name:"imageUploaderExtension",addOptions(){return{imgUploadUrl:void 0,imgUploadResponseKey:void 0,imgUploadHeaders:void 0,allowedMimeTypes:["image/jpeg","image/png","image/jpg"],maxFileSize:5*1024*1024}},addExtensions(){return[iy.configure({allowedMimeTypes:this.options.allowedMimeTypes,onDrop:(t,e,r)=>{},onPaste:(t,e)=>{}})]},addStorage(){const t=new Map;return{uploadImageFromFile:(e,r,o,a,n)=>{const{imgUploadUrl:i,imgUploadResponseKey:s,imgUploadHeaders:l,allowedMimeTypes:d,maxFileSize:u}=this.options;if(!r)return;let f=null;if(!d?.includes(r.type))f=`Unsupported file type: ${r.type}`;else if(r.size>=u){const x=Math.round(u/1048576);f=`File too large: ${(r.size/(1024*1024)).toFixed(2)}MB. Maximum size is ${x}MB.`}if(f){if(!a){Co("Error","danger",f);return}jd(e,o,a,{failed:!0,uploading:!1,selectMedia:!0,errorMessage:f},n);return}const p=()=>t.has(o);jd(e,o,a,{src:null,progress:0,failed:!1,uploading:!0,selectMedia:!1,errorMessage:null,name:r.name,size:r.size},n);const g=x=>{p()&&$o(e,{id:o,pos:n},x)},h=x=>{p()&&(g({uploading:!1,failed:!1,src:x,progress:100}),t.delete(o))},b=(x="Upload failed")=>{p()&&(g({uploading:!1,failed:!0,errorMessage:x,progress:0}),t.delete(o))},w=()=>{$o(e,{id:o,pos:n},{uploading:!1,failed:!0,errorMessage:"Upload cancelled",progress:0}),t.delete(o)},y=(x,$)=>{const k=t.get(o);return!k||k.cancelled?!1:(g({progress:x}),!0)};(async()=>{try{if(!i){const L=URL.createObjectURL(r),S=Date.now(),P=1,I=200,K=100/P*I;let U;const W=()=>{if(t.get(o)?.cancelled){w(),URL.revokeObjectURL(L);return}const v=Date.now()-S,E=Math.min(v/K*100,100),M=Math.floor(E/P)*P;y(Math.min(M,100),r)&&(E>=100?h(L):U=setTimeout(W,I))};t.set(o,{cancelled:!1,cleanup:()=>{clearTimeout(U),URL.revokeObjectURL(L)}}),U=setTimeout(W,I);return}const x=new AbortController;t.set(o,{cancelled:!1,cleanup:()=>{x.abort()}});const $=await pw({file:r,url:i,onProgress:y,signal:x.signal,headers:l});if(t.get(o)?.cancelled){w();return}if(!s)throw new Error("You need to specify a key or resolver for the upload response using *imgUploadResponseKey* in editorOptions.");const N=typeof s=="function"?s($):hw($,s);if(!N)throw new Error("No URL returned from server");if(typeof N!="string")throw new Error("The upload response resolver must return a string URL");h(N)}catch(x){x instanceof Error&&(x.name==="AbortError"?w():b(x.message))}})()},cancelUpload:(e,r,o)=>{const a=t.get(r);a&&(a.cancelled=!0,a.cleanup?.(),t.delete(r)),$o(e,{id:r,pos:o},{src:null,progress:0,failed:!1,uploading:!1,selectMedia:!0,errorMessage:null})}}}}),jd=(t,e,r,o,a)=>{r?$o(t,{id:e,pos:a},o):t.commands.insertContent({type:"imageUploader",attrs:{id:e,...o}})},ly=pe.create({name:"slash-commands",addOptions(){return{suggestion:{char:"/",command:({editor:t,range:e,props:r})=>{r.command({editor:t,range:e})}}}},addProseMirrorPlugins(){return[bn({editor:this.editor,...this.options.suggestion,decorationClass:"tiptop-slash-highlight"})]}}),cy=c.forwardRef(({items:t,command:e},r)=>{const o=t.flatMap(u=>u.commands),[a,n]=c.useState(0);c.useImperativeHandle(r,()=>({onKeyDown({event:u}){return u.key==="ArrowUp"?(i(),!0):u.key==="ArrowDown"?(s(),!0):u.key==="Enter"?(l(),!0):!1}})),c.useEffect(()=>{n(0)},[t]);const i=()=>{n(u=>(u+o.length-1)%o.length)},s=()=>{n(u=>(u+1)%o.length)},l=()=>{d(a)},d=u=>{const f=o[u];f&&e(f)};return m.jsx("div",{"aria-label":"Command menu",className:"w-[200px] bg-background border shadow rounded-2xl flex flex-col gap-2 p-2.5 relative overflow-y-auto",style:{maxHeight:"var(--slash-available-height, none)"},children:t.length>0?t.map((u,f)=>m.jsxs("div",{className:"flex flex-col gap-2",children:[m.jsxs("div",{className:"w-full items-start flex flex-col gap-1",children:[m.jsx("p",{className:"px-1 text-sm font-medium text-foreground",children:u.title}),u.commands.map((p,g)=>{const h=t.slice(0,f).reduce((b,w)=>b+w.commands.length,0)+g;return m.jsxs("button",{className:tr("w-full h-8 rounded-lg flex gap-1.5 items-center p-2 bg-transparent hover:bg-default/10 cursor-pointer text-muted transition-all",a===h?"bg-default/10 text-accent":"hover:text-foreground"),onClick:()=>d(h),children:[m.jsx("div",{children:m.jsx(he,{name:p.icon})}),m.jsx("span",{className:"text-sm",children:p.title})]},p.key)})]}),f!==t.length-1&&m.jsx(Se,{})]},u.key)):m.jsx("p",{className:"text-muted text-sm",children:"No results"})})}),Od=(t,e)=>{const r={getBoundingClientRect:()=>Be.posToDOMRect(t.view,t.state.selection.from,t.state.selection.to)};ye.computePosition(r,e,{placement:"bottom-start",middleware:[ye.flip(),ye.shift(),ye.size({apply({availableHeight:o,elements:a}){a.floating.style.setProperty("--slash-available-height",`${Math.max(o-8,0)}px`)}})]}).then(o=>{Object.assign(e.style,{width:"max-content",left:`${o.x}px`,top:`${o.y}px`,position:o.strategy==="fixed"?"fixed":"absolute",zIndex:"9999"})})},dy={pluginKey:new F.PluginKey("slashCommand"),items:({query:t})=>Md.map(o=>({...o,commands:o.commands.filter(a=>{const n=a.title.toLocaleLowerCase().trim(),i=t.toLocaleLowerCase().trim();return n.startsWith(i)})})).filter(o=>o.commands.length>0),render:()=>{let t;return{onStart:e=>{e.clientRect&&(e.editor.commands.setMeta("lockDragHandle",!0),t=new Be.ReactRenderer(cy,{props:e,editor:e.editor}),t.element.style.position="fixed",document.body.appendChild(t.element),Od(e.editor,t.element))},onUpdate(e){t.updateProps(e),e.clientRect&&Od(e.editor,t.element)},onKeyDown(e){return e.event.key==="Escape"?(t.destroy(),t.element.remove(),t.editor.commands.setMeta("lockDragHandle",!1),!0):t.ref?.onKeyDown(e)||!1},onExit(){t.destroy(),t.element.remove(),t.editor.commands.setMeta("lockDragHandle",!1)}}}},uy=({imgUploadUrl:t,imgUploadResponseKey:e,imgUploadHeaders:r})=>[ou.configure({bulletList:!1,orderedList:!1,listItem:!1,listKeymap:!1,codeBlock:!1,heading:{levels:[1,2,3]},horizontalRule:!1,link:{openOnClick:!1,defaultProtocol:"https"},dropcursor:{width:1.5,color:"hsl(var(--heroui-primary))"}}),tu.ListKit,eu.Placeholder.configure({placeholder:"Write something, or type '/' for commands."}),kd,xd,vn.TextStyle,vn.Color,ru.configure({multicolor:!0}),Xw.configure({types:["paragraph","heading"]}),au,nu,ty,Zw.configure({table:{resizable:!0}}),oy,sy.configure({imgUploadUrl:t,imgUploadResponseKey:e,imgUploadHeaders:r}),ly.configure({suggestion:dy})],_t=(t,e)=>t==null?null:typeof t!="function"?t:e?t({editor:e}):null,fy=(t,e)=>{const r=new Set(t.map(o=>o.name));return Array.from(new Set(e.map(o=>o.name).filter(o=>r.has(o))))},gy=(t,e)=>{const r=c.useRef(null),o=c.useMemo(()=>fy(t,e),[t,e]),a=o.join(",");c.useEffect(()=>{if(!o.length){r.current=null;return}if(r.current===a)return;r.current=a;const i=`Duplicate extension names found in extraExtensions: [${o.map(s=>`'${s}'`).join(", ")}]. extraExtensions is additive only; duplicate names can cause unstable behavior.`;console.warn(`[tiptop-editor warn]: ${i}`)},[o,a])},Fd=c.createContext(null),sn=()=>c.useContext(Fd),Bd=({editor:t})=>{const e=sn(),r=c.useCallback(()=>t.isEditable?!1:_o(t)&&_d(t)&&!$d(t),[t]),o=c.useCallback(()=>{if(!e)return;const{from:a,to:n}=t.state.selection;a!==n&&e.setPendingComment({id:crypto.randomUUID(),type:"inline",from:a,to:n})},[t,e]);return e?m.jsx(ko,{ref:a=>{a&&(a.style.zIndex="9999")},editor:t,updateDelay:200,shouldShow:r,options:{offset:{alignmentAxis:10}},children:m.jsx("div",{className:"bubble-menu",children:m.jsxs(ve,{delay:0,closeDelay:0,children:[m.jsx(De,{size:"sm",variant:"ghost",isIconOnly:!0,className:"text-muted hover:text-foreground",onPress:o,children:m.jsx(_r.MessageSquarePlus,{size:16})}),m.jsx(ve.Content,{children:m.jsx("p",{children:"Add comment"})})]})})}):null},py=({editor:t})=>{const[e,r]=c.useState("");c.useEffect(()=>{const i=()=>r(t.getAttributes("link").href??"");return t.on("selectionUpdate",i),t.on("transaction",i),()=>{t.off("selectionUpdate",i),t.off("transaction",i)}},[t]);const o=c.useCallback(()=>t.isEditable&&t.isActive("link")&&!_o(t),[t]),a=c.useCallback(()=>{e&&window.open(e,"_blank","noopener,noreferrer")},[e]),n=c.useCallback(()=>{Cd(t)},[t]);return m.jsx(ko,{ref:i=>{i&&(i.style.zIndex="9999")},editor:t,updateDelay:0,shouldShow:o,children:m.jsxs("div",{className:"bubble-menu",children:[m.jsx("span",{className:"text-sm text-muted truncate max-w-[200px] px-1 select-none",children:e}),m.jsx(Se,{orientation:"vertical",className:"h-6"}),m.jsxs(ve,{delay:0,closeDelay:0,children:[m.jsx(De,{size:"sm",variant:"ghost",isIconOnly:!0,className:"text-muted hover:text-foreground",onPress:a,children:m.jsx(_r.ExternalLink,{size:16})}),m.jsx(ve.Content,{children:m.jsx("p",{children:"Open link"})})]}),m.jsxs(ve,{delay:0,closeDelay:0,children:[m.jsx(De,{size:"sm",variant:"ghost",isIconOnly:!0,className:"text-danger hover:text-danger",onPress:n,children:m.jsx(_r.Unlink,{size:16})}),m.jsx(ve.Content,{children:m.jsx("p",{children:"Remove link"})})]})]})})},Hd=hb.create({name:"comment",addAttributes(){return{commentId:{default:null,parseHTML:t=>t.getAttribute("data-comment-id"),renderHTML:t=>t.commentId?{"data-comment-id":t.commentId}:{}}}},parseHTML(){return[{tag:"span[data-comment-id]"}]},renderHTML({HTMLAttributes:t}){return["span",{...t,class:"tiptop-comment"},0]},addCommands(){return{setComment:(t,e)=>({tr:r,dispatch:o,state:a})=>{const n=a.schema.marks[this.name];return n?(o&&(r.addMark(e.from,e.to,n.create({commentId:t})),o(r)),!0):!1},unsetComment:t=>({tr:e,dispatch:r,state:o})=>{const a=o.schema.marks[this.name];return a?(r&&(o.doc.descendants((n,i)=>{if(!n.isInline)return;const s=n.marks.find(l=>l.type===a&&l.attrs.commentId===t);s&&e.removeMark(i,i+n.nodeSize,s)}),r(e)),!0):!1}}},addProseMirrorPlugins(){return[new F.Plugin({props:{handleClick(t,e,r){const a=r.target.closest("[data-comment-id]");if(!a)return!1;const n=a.getAttribute("data-comment-id");return n&&t.dom.dispatchEvent(new CustomEvent("tiptop:comment-click",{bubbles:!0,detail:{commentId:n}})),!1}}})]}}),hy=["paragraph","heading","blockquote","bulletList","orderedList","taskList","codeBlock"],Vd=pe.create({name:"nodeComment",addGlobalAttributes(){return[{types:hy,attributes:{commentId:{default:null,parseHTML:t=>t.getAttribute("data-node-comment-id")||null,renderHTML:t=>t.commentId?{"data-node-comment-id":t.commentId}:{}}}}]},addCommands(){return{setNodeComment:(t,e)=>({tr:r,dispatch:o,state:a})=>{const n=a.doc.nodeAt(e);return n?(o&&(r.setNodeMarkup(e,void 0,{...n.attrs,commentId:t}),o(r)),!0):!1},unsetNodeComment:t=>({tr:e,dispatch:r,state:o})=>(r&&(o.doc.forEach((a,n)=>{a.attrs.commentId===t&&e.setNodeMarkup(n,void 0,{...a.attrs,commentId:null})}),r(e)),!0)}},addProseMirrorPlugins(){return[new F.Plugin({props:{decorations(t){const e=[];return t.doc.forEach((r,o)=>{r.attrs.commentId&&e.push(hn.Decoration.node(o,o+r.nodeSize,{class:"tiptop-node-comment","data-node-comment-id":r.attrs.commentId}))}),hn.DecorationSet.create(t.doc,e)}}})]}}),Ud=t=>JSON.stringify(t,(e,r)=>typeof r=="function"?"[function]":r),Wd=c.forwardRef(({editorOptions:t={},slots:e={},className:r,...o},a)=>{const{imgUploadUrl:n,imgUploadResponseKey:i,imgUploadHeaders:s,disableDefaultContainer:l=!1,showDragHandle:d=!0,showCommentMenu:u=!1,extraExtensions:f=[],editable:p,...g}=t,h=c.useMemo(()=>uy({imgUploadUrl:n,imgUploadResponseKey:i,imgUploadHeaders:s}),[i,n,s]),b=c.useMemo(()=>u?[Hd,Vd]:[],[u]),w=c.useMemo(()=>[...h,...b,...f],[h,b,f]);gy(h,f);const y=c.useMemo(()=>Ud(g),[g]),x=c.useMemo(()=>Ud(f.map(S=>({name:S.name,options:"options"in S?S.options:void 0}))),[f]),$=c.useMemo(()=>[y,x,n,i,s],[x,i,n,s,y]),k=Be.useEditor({content:"<p>This is just a content</p>",extensions:w,editable:p??!0,...g},$);c.useEffect(()=>{k&&p!==void 0&&k.setEditable(p)},[k,p]),c.useImperativeHandle(a,()=>({getEditor:()=>k,on:((...S)=>(k?.on(...S),k)),off:((...S)=>(k?.off(...S),k)),once:((...S)=>(k?.once(...S),k)),getDocumentMap:()=>k?Eo(k):null,applyTargetedUpdate:S=>k?rn(k,S):!1,applyTargetedUpdates:S=>k?Pd(k,S):!1}),[k]);const N=l?c.Fragment:um,L=l?{}:{className:"w-full overflow-visible"};return m.jsx(an.Provider,{value:k,children:m.jsxs(N,{...L,children:[_t(e.editorTop,k),k&&m.jsxs(m.Fragment,{children:[d?m.jsx(Iw,{editor:k,dragHandleSlot:_t(e.dragHandleDropdown,k)}):null,m.jsx(Pw,{editor:k,prepend:_t(e.selectionMenuPrepend,k),append:_t(e.selectionMenuAppend,k)}),m.jsx(Mw,{editor:k,prepend:_t(e.tableMenuPrepend,k),append:_t(e.tableMenuAppend,k)}),m.jsx(py,{editor:k}),u&&m.jsx(Bd,{editor:k})]}),m.jsx(Be.EditorContent,{...o,className:tr(r,l?"tiptop-editor-no-padding":null),editor:k}),_t(e.editorBottom,k)]})})});Wd.displayName="TiptapEditor";const my=({children:t,initialComments:e,onCommentsChange:r})=>{const[o,a]=c.useState(e??[]),[n,i]=c.useState(null),[s,l]=c.useState(null),d=c.useRef(r);d.current=r;const u=c.useCallback(y=>{a(x=>{const $=y(x);return d.current?.($),$})},[]),f=c.useCallback((y,x,$,k)=>{u(N=>[...N,{id:y,type:x,content:$,author:k,createdAt:new Date,replies:[],resolved:!1}]),i(y),l(null)},[u]),p=c.useCallback(y=>{u(x=>x.filter($=>$.id!==y)),i(x=>x===y?null:x)},[u]),g=c.useCallback(y=>{u(x=>x.map($=>$.id===y?{...$,resolved:!0}:$)),i(x=>x===y?null:x)},[u]),h=c.useCallback((y,x,$)=>{u(k=>k.map(N=>N.id!==y?N:{...N,replies:[...N.replies,{id:crypto.randomUUID(),content:x,author:$,createdAt:new Date}]}))},[u]),b=c.useCallback(y=>o.find(x=>x.id===y),[o]),w=c.useRef(null);return c.useEffect(()=>{const y=w.current;if(!y)return;const x=$=>{const k=$.detail.commentId;i(k),l(null)};return y.addEventListener("tiptop:comment-click",x),()=>y.removeEventListener("tiptop:comment-click",x)},[]),m.jsx(Fd.Provider,{value:{comments:o,activeCommentId:n,pendingComment:s,addComment:f,removeComment:p,resolveComment:g,replyToComment:h,setActiveCommentId:i,setPendingComment:l,getComment:b},children:m.jsx("div",{ref:w,style:{display:"contents"},children:t})})},vy=()=>{const t=Dd(),e=sn(),r=c.useCallback((n,i,s)=>{!t||!e||!i.trim()||(n.type==="inline"?t.commands.setComment(n.id,{from:n.from,to:n.to}):t.commands.setNodeComment(n.id,n.nodePos),e.addComment(n.id,n.type,i.trim(),s))},[t,e]),o=c.useCallback(n=>{if(!t||!e)return;const i=e.getComment(n);i&&(i.type==="inline"?t.commands.unsetComment(n):t.commands.unsetNodeComment(n),e.resolveComment(n))},[t,e]),a=c.useCallback(n=>{if(!t||!e)return;const i=e.getComment(n);i&&(i.type==="inline"?t.commands.unsetComment(n):t.commands.unsetNodeComment(n),e.removeComment(n))},[t,e]);return{submit:r,resolve:o,remove:a}};Y.CommentMark=Hd,Y.CommentSelectionMenu=Bd,Y.CommentsProvider=my,Y.NodeCommentExtension=Vd,Y.TiptopEditor=Wd,Y.TiptopEditorContext=an,Y.applyTargetedUpdate=rn,Y.applyTargetedUpdates=Pd,Y.getDocumentMap=Eo,Y.useCommentActions=vy,Y.useComments=sn,Y.useTiptopEditor=Dd,Object.defineProperty(Y,Symbol.toStringTag,{value:"Module"})}));
43
+ `}),p}var Gw=qw,Yw=xr.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:Fw,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:t,HTMLAttributes:e}){const{colgroup:r,tableWidth:o,tableMinWidth:a}=Bw(t,this.options.cellMinWidth),n=e.style;function i(){return n||(o?`width: ${o}`:`min-width: ${a}`)}const s=["table",Vt(this.options.HTMLAttributes,e,{style:i()}),r,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},s]:s},parseMarkdown:(t,e)=>{const r=[],o=Array.isArray(t.align)?t.align:[];if(t.header){const a=[];t.header.forEach((n,i)=>{var s;const l=So((s=o[i])!=null?s:n.align),d=l?{align:l}:{};a.push(e.createNode("tableHeader",d,[{type:"paragraph",content:e.parseInline(n.tokens)}]))}),r.push(e.createNode("tableRow",{},a))}return t.rows&&t.rows.forEach(a=>{const n=[];a.forEach((i,s)=>{var l;const d=So((l=o[s])!=null?l:i.align),u=d?{align:d}:{};n.push(e.createNode("tableCell",u,[{type:"paragraph",content:e.parseInline(i.tokens)}]))}),r.push(e.createNode("tableRow",{},n))}),e.createNode("table",void 0,r)},renderMarkdown:(t,e)=>Gw(t,e),addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:r=!0}={})=>({tr:o,dispatch:a,editor:n})=>{const i=Vw(n.schema,t,e,r);if(a){const s=o.selection.from+1;o.replaceSelectionWith(i).scrollIntoView().setSelection(F.TextSelection.near(o.doc.resolve(s)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>ae.addColumnBefore(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>ae.addColumnAfter(t,e),deleteColumn:()=>({state:t,dispatch:e})=>ae.deleteColumn(t,e),addRowBefore:()=>({state:t,dispatch:e})=>ae.addRowBefore(t,e),addRowAfter:()=>({state:t,dispatch:e})=>ae.addRowAfter(t,e),deleteRow:()=>({state:t,dispatch:e})=>ae.deleteRow(t,e),deleteTable:()=>({state:t,dispatch:e})=>ae.deleteTable(t,e),mergeCells:()=>({state:t,dispatch:e})=>ae.mergeCells(t,e),splitCell:()=>({state:t,dispatch:e})=>ae.splitCell(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>ae.toggleHeader("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>ae.toggleHeader("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>ae.toggleHeaderCell(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>ae.mergeCells(t,e)?!0:ae.splitCell(t,e),setCellAttribute:(t,e)=>({state:r,dispatch:o})=>ae.setCellAttr(t,e)(r,o),goToNextCell:()=>({state:t,dispatch:e})=>ae.goToNextCell(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>ae.goToNextCell(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&ae.fixTables(t),!0),setCellSelection:t=>({tr:e,dispatch:r})=>{if(r){const o=ae.CellSelection.create(e.doc,t.anchorCell,t.headCell);e.setSelection(o)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:Po,"Mod-Backspace":Po,Delete:Po,"Mod-Delete":Po}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[ae.columnResizing({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],ae.tableEditing({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){const e={name:t.name,options:t.options,storage:t.storage};return{tableRole:wo(Ht(t,"tableRole",e))}}}),Zw=pe.create({name:"tableKit",addExtensions(){const t=[];return this.options.table!==!1&&t.push(Yw.configure(this.options.table)),this.options.tableCell!==!1&&t.push(zw.configure(this.options.tableCell)),this.options.tableHeader!==!1&&t.push(jw.configure(this.options.tableHeader)),this.options.tableRow!==!1&&t.push(Ow.configure(this.options.tableRow)),t}}),Jw=pe.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:t=>{const e=t.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:t=>t.textAlign?{style:`text-align: ${t.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:t=>({commands:e})=>this.options.alignments.includes(t)?this.options.types.map(r=>e.updateAttributes(r,{textAlign:t})).some(r=>r):!1,unsetTextAlign:()=>({commands:t})=>this.options.types.map(e=>t.resetAttributes(e,"textAlign")).some(e=>e),toggleTextAlign:t=>({editor:e,commands:r})=>this.options.alignments.includes(t)?e.isActive({textAlign:t})?r.unsetTextAlign():r.setTextAlign(t):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),Xw=Jw;const Qw=c.forwardRef(({items:t,command:e},r)=>{const[o,a]=c.useState(0);c.useImperativeHandle(r,()=>({onKeyDown({event:d}){return d.key==="ArrowUp"?(n(),!0):d.key==="ArrowDown"?(i(),!0):d.key==="Enter"?(s(),!0):!1}})),c.useEffect(()=>{a(0)},[t]);const n=()=>{a(d=>(d+t.length-1)%t.length)},i=()=>{a(d=>(d+1)%t.length)},s=()=>{l(o)},l=d=>{const u=t[d];u&&e(u)};return m.jsx("div",{className:"w-full max-w-[250px] max-h-[500px] bg-background border shadow rounded-2xl flex flex-col gap-1 p-2.5 relative overflow-hidden",children:m.jsx("div",{className:"w-full flex flex-col gap-1 overflow-y-auto",children:t.length>0?t.map((d,u)=>m.jsxs("button",{className:tr("w-full h-7 rounded-lg flex gap-1.5 items-center p-2 bg-transparent hover:bg-default/10 cursor-pointer text-muted transition-all",o===u?"bg-default/10 text-accent":"hover:text-foreground"),"data-emoji-name":d.name,onClick:()=>l(u),children:[d.fallbackImage?m.jsx("img",{src:d.fallbackImage,width:20,height:20,alt:d.emoji}):d.emoji," ",m.jsx("span",{title:d.name,className:"text-sm text-ellipsis overflow-hidden",children:d.name})]},d.name)):m.jsx("p",{className:"text-muted text-sm",children:"No results"})})})}),zd=(t,e)=>{const r={getBoundingClientRect:()=>ud(t.view,t.state.selection.from,t.state.selection.to)};ye.computePosition(r,e,{placement:"bottom-start"}).then(o=>{Object.assign(e.style,{left:`${o.x}px`,top:`${o.y}px`,position:o.strategy==="fixed"?"fixed":"absolute",zIndex:"9999"})})},ey={allowSpaces:!1,items:({editor:t,query:e})=>t.storage.emoji.emojis.filter(({name:r,tags:o})=>r.toLocaleLowerCase().trim().startsWith(e.toLocaleLowerCase().trim())||o.find(a=>a.startsWith(e.toLowerCase()))).slice(0,50),render:()=>{let t;return{onStart:e=>{e.clientRect&&(e.editor.commands.setMeta("lockDragHandle",!0),t=new Be.ReactRenderer(Qw,{props:e,editor:e.editor}),document.body.appendChild(t.element),zd(e.editor,t.element))},onUpdate(e){t&&(t.updateProps(e),e.clientRect&&zd(e.editor,t.element))},onKeyDown(e){return t?e.event.key==="Escape"?(t.destroy(),t.element.remove(),t.editor.commands.setMeta("lockDragHandle",!1),!0):t.ref?.onKeyDown(e)||!1:!1},onExit(){t&&(t.destroy(),t.element.remove(),t.editor.commands.setMeta("lockDragHandle",!1))}}}},ty=wn.configure({emojis:wn.gitHubEmojis,enableEmoticons:!0,forceFallbackImages:!1,suggestion:ey}).extend({addProseMirrorPlugins(){return[bn({editor:this.editor,...this.options.suggestion,decorationClass:"tiptop-slash-highlight"})]}}),ry=t=>{const e=c.useRef(0),r=c.useRef(null),o=c.useRef(null),[a,n]=c.useState(!1),{editor:i,node:s}=t,{uploading:l,src:d,failed:u,progress:f,selectMedia:p,id:g,errorMessage:h,name:b,size:w}=s.attrs,y=()=>{o.current?.click()},x=P=>{if(l)return;const I=P.target.files?.[0];if(I&&g){r.current=I;const K=typeof t.getPos=="function"?t.getPos():void 0;i?.storage.imageUploaderExtension.uploadImageFromFile(i,I,g,!0,K)}o.current&&(o.current.value="")},$=P=>{P.preventDefault()},k=c.useCallback(P=>{if(P.preventDefault(),P.stopPropagation(),P.nativeEvent.stopImmediatePropagation(),e.current=0,n(!1),l)return;const I=P.dataTransfer?.files?.[0];if(I&&g){r.current=I;const K=typeof t.getPos=="function"?t.getPos():void 0;i?.storage.imageUploaderExtension.uploadImageFromFile(i,I,g,!0,K)}o.current&&(o.current.value="")},[i,g,t,l]),N=()=>{e.current++,n(!0)},L=()=>{e.current--,e.current===0&&n(!1)},S=()=>{const P=typeof t.getPos=="function"?t.getPos():void 0;i?.storage.imageUploaderExtension.cancelUpload(i,g,P),Co("Info","accent","Upload cancelled")};return c.useEffect(()=>{(u||h)&&(Co("Error","danger",h),t.updateAttributes({failed:!1,selectMedia:!0,errorMessage:null}))},[u,h,t]),m.jsx(Be.NodeViewWrapper,{"data-drag-handle":!0,"data-uploading":l,"data-type":"image-uploader",className:"w-full h-full rounded-lg",onDrop:!l&&!d?k:void 0,onDragOver:!l&&!d?$:void 0,onDragEnter:!l&&!d?N:void 0,onDragLeave:!l&&!d?L:void 0,children:m.jsxs("div",{className:tr(a?"bg-accent-soft":" bg-background",p?"border border-dashed px-6 py-8":"","w-full h-full flex flex-col rounded-lg text-center cursor-pointer relative overflow-hidden transition-all"),draggable:!1,contentEditable:!1,children:[m.jsx("input",{type:"file",ref:o,style:{display:"none"},accept:"image/png, image/jpeg, image/jpg",onChange:x}),p&&!l&&m.jsxs("div",{onClick:y,className:"flex flex-col gap-2 items-center justify-center",children:[m.jsx("div",{children:m.jsx(he,{name:"File",className:"w-14 h-14"})}),m.jsxs("div",{className:"flex flex-col items-center justify-center gap-1",children:[m.jsxs("span",{className:"text-foreground-700 font-normal text-sm",children:[m.jsx("span",{className:"underline",children:"Click to upload "}),"or drag and drop"]}),m.jsx("span",{className:"text-foreground-400 font-medium text-xs",children:"Maximum file size 5MB."})]})]}),l&&m.jsxs("div",{className:"w-full flex justify-between items-center gap-5 border p-4 overflow-hidden rounded-lg relative",children:[m.jsx("div",{className:"h-full bg-accent-soft dark:bg-accent/20 absolute top-0 left-0 z-0 transition-all",style:{width:`${f}%`}}),m.jsxs("div",{className:"w-full flex items-center gap-3 z-1",children:[m.jsx("div",{className:"w-[46px] h-10 flex items-center justify-center bg-accent dark:bg-foreground rounded-lg",children:m.jsx(he,{name:"CloudUpload",className:"text-background w-6 h-6"})}),m.jsxs("div",{className:"w-full flex flex-col items-start gap-1",children:[m.jsx("span",{className:"text-sm text-foreground",children:b?b?.toLowerCase():r.current?.name.toLowerCase()}),m.jsxs("span",{className:"text-sm text-foreground-500",children:[w?(w/(1024*1024)).toFixed(2):r.current?.size?(r.current.size/(1024*1024)).toFixed(2):"0.00"," MB"]})]})]}),m.jsxs("div",{className:"flex items-center gap-3 z-1",children:[m.jsxs("span",{className:"text-sm text-accent",children:[f,"%"]}),m.jsx(De,{size:"sm",variant:"ghost",isIconOnly:!0,onPress:S,children:m.jsx(he,{name:"X"})})]})]}),!l&&d&&m.jsx("div",{className:"uploaded-image w-full pointer-events-none",children:m.jsx("img",{src:d,alt:"Uploaded",draggable:!1,style:{maxWidth:"100%"},className:"h-[350px] rounded-lg pointer-events-none select-none"})})]})})},oy=xr.create({name:"imageUploader",group:"block",defining:!0,isolating:!0,draggable:!0,selectable:!0,inline:!1,addAttributes(){return{id:{default:void 0},src:{default:null},progress:{default:0},failed:{default:!1},uploading:{default:!0},selectMedia:{default:!0},errorMessage:{default:null},name:{default:void 0},size:{default:void 0}}},parseHTML(){return[{tag:'div[data-type="image-uploader"]'}]},renderHTML({HTMLAttributes:t}){return["div",Vt(t,{"data-type":"image-uploader","data-uploading":String(t.uploading)})]},addNodeView(){return Be.ReactNodeViewRenderer(ry)},addCommands(){return{insertImageUploader:()=>({commands:t})=>{const e=mw();return t.insertContent({type:this.name,attrs:{id:e,uploading:!1,selectMedia:!0,src:null,failed:!1,progress:0,errorMessage:null}})}}}});var ay=({key:t,editor:e,onPaste:r,onDrop:o,allowedMimeTypes:a})=>new F.Plugin({key:t||new F.PluginKey("fileHandler"),props:{handleDrop(n,i){var s;if(!o||!((s=i.dataTransfer)!=null&&s.files.length))return!1;const l=n.posAtCoords({left:i.clientX,top:i.clientY});let d=Array.from(i.dataTransfer.files);return a&&(d=d.filter(u=>a.includes(u.type))),d.length===0?!1:(i.preventDefault(),i.stopPropagation(),o(e,d,l?.pos||0),!0)},handlePaste(n,i){var s;if(!r||!((s=i.clipboardData)!=null&&s.files.length))return!1;let l=Array.from(i.clipboardData.files);const d=i.clipboardData.getData("text/html");return a&&(l=l.filter(u=>a.includes(u.type))),!(l.length===0||(i.preventDefault(),i.stopPropagation(),r(e,l,d),d.length>0))}}}),ny=pe.create({name:"fileHandler",addOptions(){return{onPaste:void 0,onDrop:void 0,allowedMimeTypes:void 0}},addProseMirrorPlugins(){return[ay({key:new F.PluginKey(this.name),editor:this.editor,allowedMimeTypes:this.options.allowedMimeTypes,onDrop:this.options.onDrop,onPaste:this.options.onPaste})]}}),iy=ny;const sy=pe.create({name:"imageUploaderExtension",addOptions(){return{imgUploadUrl:void 0,imgUploadResponseKey:void 0,imgUploadHeaders:void 0,allowedMimeTypes:["image/jpeg","image/png","image/jpg"],maxFileSize:5*1024*1024}},addExtensions(){return[iy.configure({allowedMimeTypes:this.options.allowedMimeTypes,onDrop:(t,e,r)=>{},onPaste:(t,e)=>{}})]},addStorage(){const t=new Map;return{uploadImageFromFile:(e,r,o,a,n)=>{const{imgUploadUrl:i,imgUploadResponseKey:s,imgUploadHeaders:l,allowedMimeTypes:d,maxFileSize:u}=this.options;if(!r)return;let f=null;if(!d?.includes(r.type))f=`Unsupported file type: ${r.type}`;else if(r.size>=u){const x=Math.round(u/1048576);f=`File too large: ${(r.size/(1024*1024)).toFixed(2)}MB. Maximum size is ${x}MB.`}if(f){if(!a){Co("Error","danger",f);return}jd(e,o,a,{failed:!0,uploading:!1,selectMedia:!0,errorMessage:f},n);return}const p=()=>t.has(o);jd(e,o,a,{src:null,progress:0,failed:!1,uploading:!0,selectMedia:!1,errorMessage:null,name:r.name,size:r.size},n);const g=x=>{p()&&$o(e,{id:o,pos:n},x)},h=x=>{p()&&(g({uploading:!1,failed:!1,src:x,progress:100}),t.delete(o))},b=(x="Upload failed")=>{p()&&(g({uploading:!1,failed:!0,errorMessage:x,progress:0}),t.delete(o))},w=()=>{$o(e,{id:o,pos:n},{uploading:!1,failed:!0,errorMessage:"Upload cancelled",progress:0}),t.delete(o)},y=(x,$)=>{const k=t.get(o);return!k||k.cancelled?!1:(g({progress:x}),!0)};(async()=>{try{if(!i){const L=URL.createObjectURL(r),S=Date.now(),P=1,I=200,K=100/P*I;let U;const W=()=>{if(t.get(o)?.cancelled){w(),URL.revokeObjectURL(L);return}const v=Date.now()-S,E=Math.min(v/K*100,100),M=Math.floor(E/P)*P;y(Math.min(M,100),r)&&(E>=100?h(L):U=setTimeout(W,I))};t.set(o,{cancelled:!1,cleanup:()=>{clearTimeout(U),URL.revokeObjectURL(L)}}),U=setTimeout(W,I);return}const x=new AbortController;t.set(o,{cancelled:!1,cleanup:()=>{x.abort()}});const $=await pw({file:r,url:i,onProgress:y,signal:x.signal,headers:l});if(t.get(o)?.cancelled){w();return}if(!s)throw new Error("You need to specify a key or resolver for the upload response using *imgUploadResponseKey* in editorOptions.");const N=typeof s=="function"?s($):hw($,s);if(!N)throw new Error("No URL returned from server");if(typeof N!="string")throw new Error("The upload response resolver must return a string URL");h(N)}catch(x){x instanceof Error&&(x.name==="AbortError"?w():b(x.message))}})()},cancelUpload:(e,r,o)=>{const a=t.get(r);a&&(a.cancelled=!0,a.cleanup?.(),t.delete(r)),$o(e,{id:r,pos:o},{src:null,progress:0,failed:!1,uploading:!1,selectMedia:!0,errorMessage:null})}}}}),jd=(t,e,r,o,a)=>{r?$o(t,{id:e,pos:a},o):t.commands.insertContent({type:"imageUploader",attrs:{id:e,...o}})},ly=pe.create({name:"slash-commands",addOptions(){return{suggestion:{char:"/",command:({editor:t,range:e,props:r})=>{r.command({editor:t,range:e})}}}},addProseMirrorPlugins(){return[bn({editor:this.editor,...this.options.suggestion,decorationClass:"tiptop-slash-highlight"})]}}),cy=c.forwardRef(({items:t,command:e},r)=>{const o=t.flatMap(u=>u.commands),[a,n]=c.useState(0);c.useImperativeHandle(r,()=>({onKeyDown({event:u}){return u.key==="ArrowUp"?(i(),!0):u.key==="ArrowDown"?(s(),!0):u.key==="Enter"?(l(),!0):!1}})),c.useEffect(()=>{n(0)},[t]);const i=()=>{n(u=>(u+o.length-1)%o.length)},s=()=>{n(u=>(u+1)%o.length)},l=()=>{d(a)},d=u=>{const f=o[u];f&&e(f)};return m.jsx("div",{"aria-label":"Command menu",className:"w-[200px] bg-background border shadow rounded-2xl flex flex-col gap-2 p-2.5 relative overflow-y-auto",style:{maxHeight:"var(--slash-available-height, none)"},children:t.length>0?t.map((u,f)=>m.jsxs("div",{className:"flex flex-col gap-2",children:[m.jsxs("div",{className:"w-full items-start flex flex-col gap-1",children:[m.jsx("p",{className:"px-1 text-sm font-medium text-foreground",children:u.title}),u.commands.map((p,g)=>{const h=t.slice(0,f).reduce((b,w)=>b+w.commands.length,0)+g;return m.jsxs("button",{className:tr("w-full h-8 rounded-lg flex gap-1.5 items-center p-2 bg-transparent hover:bg-default/10 cursor-pointer text-muted transition-all",a===h?"bg-default/10 text-accent":"hover:text-foreground"),onClick:()=>d(h),children:[m.jsx("div",{children:m.jsx(he,{name:p.icon})}),m.jsx("span",{className:"text-sm",children:p.title})]},p.key)})]}),f!==t.length-1&&m.jsx(Se,{})]},u.key)):m.jsx("p",{className:"text-muted text-sm",children:"No results"})})}),Od=(t,e)=>{const r={getBoundingClientRect:()=>Be.posToDOMRect(t.view,t.state.selection.from,t.state.selection.to)};ye.computePosition(r,e,{placement:"bottom-start",middleware:[ye.flip(),ye.shift(),ye.size({apply({availableHeight:o,elements:a}){a.floating.style.setProperty("--slash-available-height",`${Math.max(o-8,0)}px`)}})]}).then(o=>{Object.assign(e.style,{width:"max-content",left:`${o.x}px`,top:`${o.y}px`,position:o.strategy==="fixed"?"fixed":"absolute",zIndex:"9999"})})},dy={pluginKey:new F.PluginKey("slashCommand"),items:({query:t})=>Md.map(o=>({...o,commands:o.commands.filter(a=>{const n=a.title.toLocaleLowerCase().trim(),i=t.toLocaleLowerCase().trim();return n.startsWith(i)})})).filter(o=>o.commands.length>0),render:()=>{let t;return{onStart:e=>{e.clientRect&&(e.editor.commands.setMeta("lockDragHandle",!0),t=new Be.ReactRenderer(cy,{props:e,editor:e.editor}),t.element.style.position="fixed",document.body.appendChild(t.element),Od(e.editor,t.element))},onUpdate(e){t&&(t.updateProps(e),e.clientRect&&Od(e.editor,t.element))},onKeyDown(e){return t?e.event.key==="Escape"?(t.destroy(),t.element.remove(),t.editor.commands.setMeta("lockDragHandle",!1),!0):t.ref?.onKeyDown(e)||!1:!1},onExit(){t&&(t.destroy(),t.element.remove(),t.editor.commands.setMeta("lockDragHandle",!1))}}}},uy=({imgUploadUrl:t,imgUploadResponseKey:e,imgUploadHeaders:r})=>[ou.configure({bulletList:!1,orderedList:!1,listItem:!1,listKeymap:!1,codeBlock:!1,heading:{levels:[1,2,3]},horizontalRule:!1,link:{openOnClick:!1,defaultProtocol:"https"},dropcursor:{width:1.5,color:"hsl(var(--heroui-primary))"}}),tu.ListKit,eu.Placeholder.configure({placeholder:"Write something, or type '/' for commands."}),kd,xd,vn.TextStyle,vn.Color,ru.configure({multicolor:!0}),Xw.configure({types:["paragraph","heading"]}),au,nu,ty,Zw.configure({table:{resizable:!0}}),oy,sy.configure({imgUploadUrl:t,imgUploadResponseKey:e,imgUploadHeaders:r}),ly.configure({suggestion:dy})],_t=(t,e)=>t==null?null:typeof t!="function"?t:e?t({editor:e}):null,fy=(t,e)=>{const r=new Set(t.map(o=>o.name));return Array.from(new Set(e.map(o=>o.name).filter(o=>r.has(o))))},gy=(t,e)=>{const r=c.useRef(null),o=c.useMemo(()=>fy(t,e),[t,e]),a=o.join(",");c.useEffect(()=>{if(!o.length){r.current=null;return}if(r.current===a)return;r.current=a;const i=`Duplicate extension names found in extraExtensions: [${o.map(s=>`'${s}'`).join(", ")}]. extraExtensions is additive only; duplicate names can cause unstable behavior.`;console.warn(`[tiptop-editor warn]: ${i}`)},[o,a])},Fd=c.createContext(null),sn=()=>c.useContext(Fd),Bd=({editor:t})=>{const e=sn(),r=c.useCallback(()=>t.isEditable?!1:_o(t)&&_d(t)&&!$d(t),[t]),o=c.useCallback(()=>{if(!e)return;const{from:a,to:n}=t.state.selection;a!==n&&e.setPendingComment({id:crypto.randomUUID(),type:"inline",from:a,to:n})},[t,e]);return e?m.jsx(ko,{ref:a=>{a&&(a.style.zIndex="9999")},editor:t,updateDelay:200,shouldShow:r,options:{offset:{alignmentAxis:10}},children:m.jsx("div",{className:"bubble-menu",children:m.jsxs(ve,{delay:0,closeDelay:0,children:[m.jsx(De,{size:"sm",variant:"ghost",isIconOnly:!0,className:"text-muted hover:text-foreground",onPress:o,children:m.jsx(_r.MessageSquarePlus,{size:16})}),m.jsx(ve.Content,{children:m.jsx("p",{children:"Add comment"})})]})})}):null},py=({editor:t})=>{const[e,r]=c.useState("");c.useEffect(()=>{const i=()=>r(t.getAttributes("link").href??"");return t.on("selectionUpdate",i),t.on("transaction",i),()=>{t.off("selectionUpdate",i),t.off("transaction",i)}},[t]);const o=c.useCallback(()=>t.isEditable&&t.isActive("link")&&!_o(t),[t]),a=c.useCallback(()=>{e&&window.open(e,"_blank","noopener,noreferrer")},[e]),n=c.useCallback(()=>{Cd(t)},[t]);return m.jsx(ko,{ref:i=>{i&&(i.style.zIndex="9999")},editor:t,updateDelay:0,shouldShow:o,children:m.jsxs("div",{className:"bubble-menu",children:[m.jsx("span",{className:"text-sm text-muted truncate max-w-[200px] px-1 select-none",children:e}),m.jsx(Se,{orientation:"vertical",className:"h-6"}),m.jsxs(ve,{delay:0,closeDelay:0,children:[m.jsx(De,{size:"sm",variant:"ghost",isIconOnly:!0,className:"text-muted hover:text-foreground",onPress:a,children:m.jsx(_r.ExternalLink,{size:16})}),m.jsx(ve.Content,{children:m.jsx("p",{children:"Open link"})})]}),m.jsxs(ve,{delay:0,closeDelay:0,children:[m.jsx(De,{size:"sm",variant:"ghost",isIconOnly:!0,className:"text-danger hover:text-danger",onPress:n,children:m.jsx(_r.Unlink,{size:16})}),m.jsx(ve.Content,{children:m.jsx("p",{children:"Remove link"})})]})]})})},Hd=hb.create({name:"comment",addAttributes(){return{commentId:{default:null,parseHTML:t=>t.getAttribute("data-comment-id"),renderHTML:t=>t.commentId?{"data-comment-id":t.commentId}:{}}}},parseHTML(){return[{tag:"span[data-comment-id]"}]},renderHTML({HTMLAttributes:t}){return["span",{...t,class:"tiptop-comment"},0]},addCommands(){return{setComment:(t,e)=>({tr:r,dispatch:o,state:a})=>{const n=a.schema.marks[this.name];return n?(o&&(r.addMark(e.from,e.to,n.create({commentId:t})),o(r)),!0):!1},unsetComment:t=>({tr:e,dispatch:r,state:o})=>{const a=o.schema.marks[this.name];return a?(r&&(o.doc.descendants((n,i)=>{if(!n.isInline)return;const s=n.marks.find(l=>l.type===a&&l.attrs.commentId===t);s&&e.removeMark(i,i+n.nodeSize,s)}),r(e)),!0):!1}}},addProseMirrorPlugins(){return[new F.Plugin({props:{handleClick(t,e,r){const a=r.target.closest("[data-comment-id]");if(!a)return!1;const n=a.getAttribute("data-comment-id");return n&&t.dom.dispatchEvent(new CustomEvent("tiptop:comment-click",{bubbles:!0,detail:{commentId:n}})),!1}}})]}}),hy=["paragraph","heading","blockquote","bulletList","orderedList","taskList","codeBlock"],Vd=pe.create({name:"nodeComment",addGlobalAttributes(){return[{types:hy,attributes:{commentId:{default:null,parseHTML:t=>t.getAttribute("data-node-comment-id")||null,renderHTML:t=>t.commentId?{"data-node-comment-id":t.commentId}:{}}}}]},addCommands(){return{setNodeComment:(t,e)=>({tr:r,dispatch:o,state:a})=>{const n=a.doc.nodeAt(e);return n?(o&&(r.setNodeMarkup(e,void 0,{...n.attrs,commentId:t}),o(r)),!0):!1},unsetNodeComment:t=>({tr:e,dispatch:r,state:o})=>(r&&(o.doc.forEach((a,n)=>{a.attrs.commentId===t&&e.setNodeMarkup(n,void 0,{...a.attrs,commentId:null})}),r(e)),!0)}},addProseMirrorPlugins(){return[new F.Plugin({props:{decorations(t){const e=[];return t.doc.forEach((r,o)=>{r.attrs.commentId&&e.push(hn.Decoration.node(o,o+r.nodeSize,{class:"tiptop-node-comment","data-node-comment-id":r.attrs.commentId}))}),hn.DecorationSet.create(t.doc,e)}}})]}}),Ud=t=>JSON.stringify(t,(e,r)=>typeof r=="function"?"[function]":r),Wd=c.forwardRef(({editorOptions:t={},slots:e={},className:r,...o},a)=>{const{imgUploadUrl:n,imgUploadResponseKey:i,imgUploadHeaders:s,disableDefaultContainer:l=!1,showDragHandle:d=!0,showCommentMenu:u=!1,extraExtensions:f=[],editable:p,...g}=t,h=c.useMemo(()=>uy({imgUploadUrl:n,imgUploadResponseKey:i,imgUploadHeaders:s}),[i,n,s]),b=c.useMemo(()=>u?[Hd,Vd]:[],[u]),w=c.useMemo(()=>[...h,...b,...f],[h,b,f]);gy(h,f);const y=c.useMemo(()=>Ud(g),[g]),x=c.useMemo(()=>Ud(f.map(S=>({name:S.name,options:"options"in S?S.options:void 0}))),[f]),$=c.useMemo(()=>[y,x,n,i,s],[x,i,n,s,y]),k=Be.useEditor({content:"<p>This is just a content</p>",extensions:w,editable:p??!0,...g},$);c.useEffect(()=>{k&&p!==void 0&&k.setEditable(p)},[k,p]),c.useImperativeHandle(a,()=>({getEditor:()=>k,on:((...S)=>(k?.on(...S),k)),off:((...S)=>(k?.off(...S),k)),once:((...S)=>(k?.once(...S),k)),getDocumentMap:()=>k?Eo(k):null,applyTargetedUpdate:S=>k?rn(k,S):!1,applyTargetedUpdates:S=>k?Pd(k,S):!1}),[k]);const N=l?c.Fragment:um,L=l?{}:{className:"w-full overflow-visible"};return m.jsx(an.Provider,{value:k,children:m.jsxs(N,{...L,children:[_t(e.editorTop,k),k&&m.jsxs(m.Fragment,{children:[d?m.jsx(Iw,{editor:k,dragHandleSlot:_t(e.dragHandleDropdown,k)}):null,m.jsx(Pw,{editor:k,prepend:_t(e.selectionMenuPrepend,k),append:_t(e.selectionMenuAppend,k)}),m.jsx(Mw,{editor:k,prepend:_t(e.tableMenuPrepend,k),append:_t(e.tableMenuAppend,k)}),m.jsx(py,{editor:k}),u&&m.jsx(Bd,{editor:k})]}),m.jsx(Be.EditorContent,{...o,className:tr(r,l?"tiptop-editor-no-padding":null),editor:k}),_t(e.editorBottom,k)]})})});Wd.displayName="TiptapEditor";const my=({children:t,initialComments:e,onCommentsChange:r})=>{const[o,a]=c.useState(e??[]),[n,i]=c.useState(null),[s,l]=c.useState(null),d=c.useRef(r);d.current=r;const u=c.useCallback(y=>{a(x=>{const $=y(x);return d.current?.($),$})},[]),f=c.useCallback((y,x,$,k)=>{u(N=>[...N,{id:y,type:x,content:$,author:k,createdAt:new Date,replies:[],resolved:!1}]),i(y),l(null)},[u]),p=c.useCallback(y=>{u(x=>x.filter($=>$.id!==y)),i(x=>x===y?null:x)},[u]),g=c.useCallback(y=>{u(x=>x.map($=>$.id===y?{...$,resolved:!0}:$)),i(x=>x===y?null:x)},[u]),h=c.useCallback((y,x,$)=>{u(k=>k.map(N=>N.id!==y?N:{...N,replies:[...N.replies,{id:crypto.randomUUID(),content:x,author:$,createdAt:new Date}]}))},[u]),b=c.useCallback(y=>o.find(x=>x.id===y),[o]),w=c.useRef(null);return c.useEffect(()=>{const y=w.current;if(!y)return;const x=$=>{const k=$.detail.commentId;i(k),l(null)};return y.addEventListener("tiptop:comment-click",x),()=>y.removeEventListener("tiptop:comment-click",x)},[]),m.jsx(Fd.Provider,{value:{comments:o,activeCommentId:n,pendingComment:s,addComment:f,removeComment:p,resolveComment:g,replyToComment:h,setActiveCommentId:i,setPendingComment:l,getComment:b},children:m.jsx("div",{ref:w,style:{display:"contents"},children:t})})},vy=()=>{const t=Dd(),e=sn(),r=c.useCallback((n,i,s)=>{!t||!e||!i.trim()||(n.type==="inline"?t.commands.setComment(n.id,{from:n.from,to:n.to}):t.commands.setNodeComment(n.id,n.nodePos),e.addComment(n.id,n.type,i.trim(),s))},[t,e]),o=c.useCallback(n=>{if(!t||!e)return;const i=e.getComment(n);i&&(i.type==="inline"?t.commands.unsetComment(n):t.commands.unsetNodeComment(n),e.resolveComment(n))},[t,e]),a=c.useCallback(n=>{if(!t||!e)return;const i=e.getComment(n);i&&(i.type==="inline"?t.commands.unsetComment(n):t.commands.unsetNodeComment(n),e.removeComment(n))},[t,e]);return{submit:r,resolve:o,remove:a}};Y.CommentMark=Hd,Y.CommentSelectionMenu=Bd,Y.CommentsProvider=my,Y.NodeCommentExtension=Vd,Y.TiptopEditor=Wd,Y.TiptopEditorContext=an,Y.applyTargetedUpdate=rn,Y.applyTargetedUpdates=Pd,Y.getDocumentMap=Eo,Y.useCommentActions=vy,Y.useComments=sn,Y.useTiptopEditor=Dd,Object.defineProperty(Y,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tiptop-editor",
3
- "version": "2.3.0",
3
+ "version": "2.3.1",
4
4
  "description": "Notion-like editor built with Tiptap v3 and HeroUI",
5
5
  "type": "module",
6
6
  "main": "./dist/tiptop-editor.umd.js",