axiom-editor 1.0.0 → 1.0.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.
@@ -231,4 +231,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
231
231
 
232
232
  `,`1) content: element.innerHTML
233
233
  `,"2) content: () => element.cloneNode(true)"].join(" "))}var a=i.reduce(function(l,c){var u=c&&VM(c,r);return u&&l.push(u),l},[]);return Ss(t)?a[0]:a}Os.defaultProps=Dt;Os.setDefaultProps=$M;Os.currentInput=ln;Object.assign({},Rb,{effect:function(e){var n=e.state,r={popper:{position:n.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};Object.assign(n.elements.popper.style,r.popper),n.styles=r,n.elements.arrow&&Object.assign(n.elements.arrow.style,r.arrow)}});Os.setDefaultProps({render:Jb});const Xb=W.forwardRef((t,e)=>{const[n,r]=W.useState(0),i=l=>{const c=t.items[l];c&&t.command(c)},s=()=>{r((n+t.items.length-1)%t.items.length)},o=()=>{r((n+1)%t.items.length)},a=()=>{i(n)};return W.useEffect(()=>{r(0)},[t.items]),W.useImperativeHandle(e,()=>({onKeyDown:({event:l})=>l.key==="ArrowUp"?(s(),!0):l.key==="ArrowDown"?(o(),!0):l.key==="Enter"?(a(),!0):!1})),t.items.length?E.jsx("div",{className:"bg-obsidian border border-smoke/60 shadow-2xl rounded-xl overflow-hidden py-2 min-w-[240px]",children:t.items.map((l,c)=>{const u=l.icon;return E.jsxs("button",{className:`w-full flex items-center gap-3 px-4 py-2.5 text-left transition-colors
234
- ${c===n?"bg-amber/10 text-amber":"text-bone hover:bg-charcoal/50 hover:text-amber/80"}`,onClick:()=>i(c),children:[E.jsx("div",{className:"flex items-center justify-center w-8 h-8 rounded-md bg-charcoal/30 border border-smoke/30 shrink-0",children:E.jsx(u,{className:"w-4 h-4"})}),E.jsxs("div",{className:"flex flex-col",children:[E.jsx("span",{className:"font-semibold text-sm font-display tracking-wide",children:l.title}),E.jsx("span",{className:"text-xs text-steel",children:l.description})]})]},c)})}):null});Xb.displayName="CommandList";const WM=({query:t})=>[{title:"Heading 1",description:"Big section heading.",icon:X.Heading1,command:({editor:n,range:r})=>{n.chain().focus().deleteRange(r).setNode("heading",{level:1}).run()}},{title:"Heading 2",description:"Medium section heading.",icon:X.Heading2,command:({editor:n,range:r})=>{n.chain().focus().deleteRange(r).setNode("heading",{level:2}).run()}},{title:"Heading 3",description:"Small section heading.",icon:X.Heading3,command:({editor:n,range:r})=>{n.chain().focus().deleteRange(r).setNode("heading",{level:3}).run()}},{title:"Bullet List",description:"Create a simple bulleted list.",icon:X.List,command:({editor:n,range:r})=>{n.chain().focus().deleteRange(r).toggleBulletList().run()}},{title:"Numbered List",description:"Create a list with numbering.",icon:X.ListOrdered,command:({editor:n,range:r})=>{n.chain().focus().deleteRange(r).toggleOrderedList().run()}},{title:"Quote",description:"Capture a quote.",icon:X.Quote,command:({editor:n,range:r})=>{n.chain().focus().deleteRange(r).toggleBlockquote().run()}},{title:"Task List",description:"Track tasks with a to-do list.",icon:X.CheckSquare,command:({editor:n,range:r})=>{n.chain().focus().deleteRange(r).toggleTaskList().run()}},{title:"Code Block",description:"Capture a code snippet.",icon:X.Code,command:({editor:n,range:r})=>{n.chain().focus().deleteRange(r).toggleCodeBlock().run()}},{title:"Callout",description:"Highlight important information.",icon:X.MessageSquareWarning,command:({editor:n,range:r})=>{n.chain().focus().deleteRange(r).insertContent({type:"callout",content:[{type:"paragraph"}]}).run()}},{title:"Stash Note",description:"Hidden journalist draft note.",icon:X.Archive,command:({editor:n,range:r})=>{n.chain().focus().deleteRange(r).insertContent({type:"stash",content:[{type:"paragraph"}]}).run()}}].filter(n=>n.title.toLowerCase().includes(t.toLowerCase())).slice(0,10),KM=ke.create({name:"slashMenu",addOptions(){return{suggestion:{char:"/",command:({editor:t,range:e,props:n})=>{n.command({editor:t,range:e})}}}},addProseMirrorPlugins(){return[dC({editor:this.editor,...this.options.suggestion,items:WM,render:()=>{let t,e;return{onStart:n=>{t=new Ym(Xb,{props:n,editor:n.editor}),n.clientRect&&(e=Os("body",{getReferenceClientRect:n.clientRect,appendTo:()=>document.body,content:t.element,showOnCreate:!0,interactive:!0,trigger:"manual",placement:"bottom-start"}))},onUpdate(n){t.updateProps(n),n.clientRect&&e[0].setProps({getReferenceClientRect:n.clientRect})},onKeyDown(n){var r;return n.event.key==="Escape"?(e[0].hide(),!0):(r=t.ref)==null?void 0:r.onKeyDown(n)},onExit(){e[0].destroy(),t.destroy()}}}})]}});function qM(){try{return lx}catch{return null}}function GM(t,e){if(t&&typeof t.serializeForClipboard=="function")return t.serializeForClipboard(e);const n=qM();if(n&&typeof(n==null?void 0:n.__serializeForClipboard)=="function")return n.__serializeForClipboard(t,e);throw new Error("No supported clipboard serialization method found.")}function YM(t){const e=t.getBoundingClientRect(),n=t.closest('[role="dialog"]');if(n&&window.getComputedStyle(n).transform!=="none"){const r=n.getBoundingClientRect();return{top:e.top-r.top,left:e.left-r.left,width:e.width}}return{top:e.top,left:e.left,width:e.width}}function Tp(t,e){const n=["li","p:not(:first-child)","pre","blockquote","h1","h2","h3","h4","h5","h6",...e.customNodes.map(r=>`[data-type=${r}]`)].join(", ");return document.elementsFromPoint(t.x,t.y).find(r=>{var i,s;return((s=(i=r.parentElement)==null?void 0:i.matches)==null?void 0:s.call(i,".ProseMirror"))||r.matches(n)})}function JM(t,e,n){var i;const r=t.getBoundingClientRect();return(i=e.posAtCoords({left:r.left+50+n.dragHandleWidth,top:r.top+1}))==null?void 0:i.inside}function Np(t,e){const n=e.state.doc.resolve(t);return n.depth>1?n.before(n.depth):t}function XM(t){let e="";function n(a,l){if(l.focus(),!a.dataTransfer)return;const c=Tp({x:a.clientX+50+t.dragHandleWidth,y:a.clientY},t);if(!(c instanceof Element))return;let u=JM(c,l,t);if(u==null||u<0)return;u=Np(u,l);const{from:d,to:p}=l.state.selection,f=d-p,h=Np(d,l);let m=!1;const g=l.state.doc.resolve(h);if(g.node().type.name==="doc")m=!0;else{const x=ee.create(l.state.doc,g.before());m=!(u+1>=x.$from.pos&&u<=x.$to.pos)}let y=l.state.selection;if(!m&&f!==0&&!(l.state.selection instanceof ee)){const x=ee.create(l.state.doc,p-1);y=le.create(l.state.doc,u,x.$to.pos)}else if(y=ee.create(l.state.doc,u),y.node.type.isInline||y.node.type.name==="tableRow"){let x=l.state.doc.resolve(y.from);y=ee.create(l.state.doc,x.before())}l.dispatch(l.state.tr.setSelection(y)),l.state.selection instanceof ee&&l.state.selection.node.type.name==="listItem"&&(e=c.parentElement.tagName);const w=l.state.selection.content(),{dom:S,text:b}=GM(l,w);a.dataTransfer.clearData(),a.dataTransfer.setData("text/html",S.innerHTML),a.dataTransfer.setData("text/plain",b),a.dataTransfer.effectAllowed="copyMove",a.dataTransfer.setDragImage(c,0,0),l.dragging={slice:w,move:a.ctrlKey}}let r=null;function i(){r&&r.classList.add("hide")}function s(){r&&r.classList.remove("hide")}function o(a){if(a.target instanceof Element){const l=a.relatedTarget;if((l==null?void 0:l.classList.contains("tiptap"))||(l==null?void 0:l.classList.contains("drag-handle")))return}i()}return new Me({key:new ze(t.pluginKey),view:a=>{var d,p,f,h;const l=t.dragHandleSelector?document.querySelector(t.dragHandleSelector):null;r=l??document.createElement("div"),r.draggable=!0,r.dataset.dragHandle="",r.classList.add("drag-handle");function c(m){n(m,a)}r.addEventListener("dragstart",c);function u(m){i();let g=window.scrollY;m.clientY<t.scrollTreshold?window.scrollTo({top:g-30,behavior:"smooth"}):window.innerHeight-m.clientY<t.scrollTreshold&&window.scrollTo({top:g+30,behavior:"smooth"})}return r.addEventListener("drag",u),i(),l||(p=(d=a==null?void 0:a.dom)==null?void 0:d.parentElement)==null||p.appendChild(r),(h=(f=a==null?void 0:a.dom)==null?void 0:f.parentElement)==null||h.addEventListener("mouseout",o),{destroy:()=>{var m,g,y;l||(m=r==null?void 0:r.remove)==null||m.call(r),r==null||r.removeEventListener("drag",u),r==null||r.removeEventListener("dragstart",c),r=null,(y=(g=a==null?void 0:a.dom)==null?void 0:g.parentElement)==null||y.removeEventListener("mouseout",o)}}},props:{handleDOMEvents:{mousemove:(a,l)=>{if(!a.editable)return;const c=Tp({x:l.clientX+50+t.dragHandleWidth,y:l.clientY},t),u=c==null?void 0:c.closest(".not-draggable"),d=t.excludedTags.concat(["ol","ul"]).join(", ");if(!(c instanceof Element)||c.matches(d)||u){i();return}const p=window.getComputedStyle(c),f=parseInt(p.lineHeight,10),h=isNaN(f)?parseInt(p.fontSize)*1.2:f,m=parseInt(p.paddingTop,10),g=YM(c);g.top+=(h-24)/2,g.top+=m,c.matches("ul:not([data-type=taskList]) li, ol li")&&(g.left-=t.dragHandleWidth),g.width=t.dragHandleWidth,r&&(r.style.left=`${g.left-g.width}px`,r.style.top=`${g.top}px`,s())},keydown:()=>{i()},mousewheel:()=>{i()},dragstart:a=>{a.dom.classList.add("dragging")},drop:(a,l)=>{var f;a.dom.classList.remove("dragging"),i();let c=null;const u=a.posAtCoords({left:l.clientX,top:l.clientY});if(!u||(a.state.selection instanceof ee&&(c=a.state.selection.node),!c))return;const p=a.state.doc.resolve(u.pos).parent.type.name==="listItem";if(a.state.selection instanceof ee&&a.state.selection.node.type.name==="listItem"&&!p&&e=="OL"){const h=(f=a.state.schema.nodes.orderedList)==null?void 0:f.createAndFill(null,c),m=new G(F.from(h),0,0);a.dragging={slice:m,move:l.ctrlKey}}},dragend:a=>{a.dom.classList.remove("dragging")}}}})}const ZM=ke.create({name:"globalDragHandle",addOptions(){return{dragHandleWidth:20,scrollTreshold:100,excludedTags:[],customNodes:[]}},addProseMirrorPlugins(){return[XM({pluginKey:"globalDragHandle",dragHandleWidth:this.options.dragHandleWidth,scrollTreshold:this.options.scrollTreshold,dragHandleSelector:this.options.dragHandleSelector,excludedTags:this.options.excludedTags,customNodes:this.options.customNodes})]}}),QM=Fg.extend({addAttributes(){return{color:{default:null,parseHTML:t=>t.style.textDecorationColor||null,renderHTML:t=>t.color?{style:`text-decoration-color: ${t.color};`}:{}}}},addCommands(){return{setUnderline:t=>({commands:e})=>e.setMark(this.name,t),toggleUnderline:t=>({commands:e})=>e.toggleMark(this.name,t),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}}}),eO=Bg.extend({addAttributes(){return{color:{default:null,parseHTML:t=>t.style.textDecorationColor||null,renderHTML:t=>t.color?{style:`text-decoration-color: ${t.color};`}:{}}}},addCommands(){return{setStrike:t=>({commands:e})=>e.setMark(this.name,t),toggleStrike:t=>({commands:e})=>e.toggleMark(this.name,t),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}}}),tO=G_(QN);Ab.addHook("uponSanitizeElement",(t,e)=>{var n;e.tagName==="iframe"&&((t.getAttribute("src")||"").startsWith("https://www.youtube.com/embed/")||(n=t.parentNode)==null||n.removeChild(t))});const Zb=({initialContent:t,onChange:e,uploadImage:n,children:r,minHeightClass:i="min-h-[150px]",maxHeightClass:s="max-h-[500px]"})=>{const[o,a]=W.useState(!0),[l,c]=W.useState(!1),[u,d]=W.useState("link"),[p,f]=W.useState(""),h=vS({extensions:[RT.configure({heading:{levels:[1,2,3]},strike:!1,codeBlock:!1}),QM,eO,Sb,kb,uA.configure({types:["heading","paragraph","image","youtube"]}),_k.configure({openOnClick:!1,HTMLAttributes:{class:"text-amber hover:text-amber/80 transition-colors underline underline-offset-4 cursor-pointer"}}),jA.configure({inline:!1}),XA.configure({inline:!1}),QA,nC,iC,oC,UA,eA.configure({lowlight:tO}),tA,nA.configure({nested:!0}),KM,ZM.configure({dragHandleWidth:20,scrollTreshold:100})],content:typeof t=="string"?t?Ab.sanitize(t,{ADD_TAGS:["iframe"],ADD_ATTR:["allowfullscreen","frameborder","src"]}):"<p></p>":t,onUpdate:({editor:m})=>{a(!1);const g=m.getJSON(),y=m.getHTML();e&&e(g,y),setTimeout(()=>a(!0),800)},editorProps:{attributes:{class:"prose prose-invert max-w-none focus:outline-none min-h-full p-4 sm:p-6 md:p-8 pb-16 md:pb-24 text-bone font-body leading-relaxed prose-p:my-1 prose-headings:my-4"}}});return W.useEffect(()=>{const m=async g=>{const y=g,{file:w,position:S}=y.detail;if(w)if(n){a(!1);try{const b=await n(w);S!==void 0?h==null||h.chain().insertContentAt(S,{type:"image",attrs:{src:b}}).focus().run():h==null||h.chain().focus().insertContent({type:"image",attrs:{src:b}}).run()}catch(b){console.error("Image upload failed",b)}finally{a(!0)}}else{const b=URL.createObjectURL(w);S!==void 0?h==null||h.chain().insertContentAt(S,{type:"image",attrs:{src:b}}).focus().run():h==null||h.chain().focus().insertContent({type:"image",attrs:{src:b}}).run()}};return window.addEventListener("axiom-image-upload",m),()=>window.removeEventListener("axiom-image-upload",m)},[h,n]),E.jsx(Cb.Provider,{value:{editor:h,isSaved:o,setIsSaved:a,mediaModalOpen:l,setMediaModalOpen:c,mediaModalType:u,setMediaModalType:d,mediaModalInput:p,setMediaModalInput:f,uploadImage:n,minHeightClass:i,maxHeightClass:s},children:r})},Oe=W.forwardRef(({active:t,icon:e,label:n,variant:r="icon",className:i="",...s},o)=>{const a="transition-all rounded-lg shrink-0 flex items-center justify-center gap-2",l=r==="icon"?"p-2.5":"px-3 py-2 text-xs font-semibold",c=t?"text-amber bg-amber/5":"text-steel hover:text-amber hover:bg-amber/5",u=s.disabled?"opacity-30 cursor-not-allowed":"";return E.jsxs("button",{ref:o,type:"button",className:`${a} ${l} ${c} ${u} ${i}`,...s,children:[e,n&&E.jsx("span",{className:"hidden lg:inline",children:n})]})});Oe.displayName="ToolbarButton";const nO=()=>{const{editor:t,isSaved:e,setMediaModalOpen:n,setMediaModalType:r,setMediaModalInput:i}=Ca(),[s,o]=W.useState(!1),a=W.useRef(null),[l,c]=W.useState(!1),u=W.useRef(null),[d,p]=W.useState(!1),f=W.useRef(null);if(W.useEffect(()=>{const g=y=>{a.current&&!a.current.contains(y.target)&&o(!1),u.current&&!u.current.contains(y.target)&&c(!1),f.current&&!f.current.contains(y.target)&&p(!1)};return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[]),!t)return null;const h=g=>{i(""),r(g),n(!0)},m=()=>{const g=t.state.selection.from,y=document.createElement("input");y.type="file",y.accept="image/*",y.onchange=async w=>{var b;const S=(b=w.target.files)==null?void 0:b[0];S&&window.dispatchEvent(new CustomEvent("axiom-image-upload",{detail:{file:S,position:g}}))},y.click()};return E.jsx("div",{className:"-mx-1 px-1 mb-2",children:E.jsxs("div",{className:"flex items-center gap-1 p-2 bg-obsidian border border-smoke/60 rounded-xl sticky top-4 z-20 shadow-xl shadow-black/20 flex-wrap",children:[E.jsxs("div",{className:"flex items-center gap-0.5 mr-1",children:[E.jsx(Oe,{icon:E.jsx(X.Undo,{className:"w-4 h-4"}),title:"Undo",onClick:()=>t.chain().focus().undo().run(),disabled:!t.can().undo()}),E.jsx(Oe,{icon:E.jsx(X.Redo,{className:"w-4 h-4"}),title:"Redo",onClick:()=>t.chain().focus().redo().run(),disabled:!t.can().redo()})]}),E.jsx("div",{className:"w-px h-6 bg-smoke/60 mx-1"}),E.jsx(Oe,{icon:E.jsx(X.Bold,{className:"w-4 h-4"}),title:"Bold",active:t.isActive("bold"),onClick:()=>t.chain().focus().toggleBold().run()}),E.jsx(Oe,{icon:E.jsx(X.Italic,{className:"w-4 h-4"}),title:"Italic",active:t.isActive("italic"),onClick:()=>t.chain().focus().toggleItalic().run()}),E.jsxs("div",{ref:u,className:"relative",children:[E.jsx(Oe,{icon:E.jsx(X.Underline,{className:"w-4 h-4"}),title:"Underline",active:t.isActive("underline"),onClick:()=>{t.isActive("underline")?t.chain().focus().unsetUnderline().run():c(!l)}}),l&&E.jsxs("div",{className:"absolute top-full left-0 mt-2 p-3 bg-charcoal border border-smoke/80 rounded-xl shadow-2xl grid grid-cols-4 gap-2 z-30 min-w-[120px]",children:[["#f9761f","#ffffff","#94a3b8","#ef4444","#22c55e","#3b82f6","#a855f7","#eab308"].map(g=>E.jsx("button",{type:"button",onClick:()=>{t.chain().focus().setUnderline({color:g}).run(),c(!1)},className:"w-6 h-6 rounded-full border border-white/10 hover:scale-110 active:scale-95 transition-all shadow-md cursor-pointer",style:{backgroundColor:g},title:g},g)),E.jsx("button",{type:"button",onClick:()=>{t.chain().focus().unsetUnderline().run(),c(!1)},className:"w-6 h-6 rounded-full border border-white/20 hover:scale-110 active:scale-95 transition-all flex items-center justify-center bg-transparent cursor-pointer text-red-500 font-bold text-xs",title:"Remove Underline",style:{display:"flex",alignItems:"center",justifyContent:"center"},children:"/"})]})]}),E.jsxs("div",{ref:f,className:"relative",children:[E.jsx(Oe,{icon:E.jsx(X.Strikethrough,{className:"w-4 h-4"}),title:"Strikethrough",active:t.isActive("strike"),onClick:()=>{t.isActive("strike")?t.chain().focus().unsetStrike().run():p(!d)}}),d&&E.jsxs("div",{className:"absolute top-full left-0 mt-2 p-3 bg-charcoal border border-smoke/80 rounded-xl shadow-2xl grid grid-cols-4 gap-2 z-30 min-w-[120px]",children:[["#f9761f","#ffffff","#94a3b8","#ef4444","#22c55e","#3b82f6","#a855f7","#eab308"].map(g=>E.jsx("button",{type:"button",onClick:()=>{t.chain().focus().setStrike({color:g}).run(),p(!1)},className:"w-6 h-6 rounded-full border border-white/10 hover:scale-110 active:scale-95 transition-all shadow-md cursor-pointer",style:{backgroundColor:g},title:g},g)),E.jsx("button",{type:"button",onClick:()=>{t.chain().focus().unsetStrike().run(),p(!1)},className:"w-6 h-6 rounded-full border border-white/20 hover:scale-110 active:scale-95 transition-all flex items-center justify-center bg-transparent cursor-pointer text-red-500 font-bold text-xs",title:"Remove Strikethrough",style:{display:"flex",alignItems:"center",justifyContent:"center"},children:"/"})]})]}),E.jsxs("div",{ref:a,className:"relative",children:[E.jsx(Oe,{icon:E.jsx(X.Highlighter,{className:"w-4 h-4"}),title:"Text Color",active:!!t.getAttributes("textStyle").color,onClick:()=>{t.getAttributes("textStyle").color?t.chain().focus().unsetColor().run():o(!s)}}),s&&E.jsxs("div",{className:"absolute top-full left-0 mt-2 p-3 bg-charcoal border border-smoke/80 rounded-xl shadow-2xl grid grid-cols-4 gap-2 z-30 min-w-[120px]",children:[["#f9761f","#ffffff","#94a3b8","#ef4444","#22c55e","#3b82f6","#a855f7","#eab308"].map(g=>E.jsx("button",{type:"button",onClick:()=>{t.chain().focus().setColor(g).run(),o(!1)},className:"w-6 h-6 rounded-full border border-white/10 hover:scale-110 active:scale-95 transition-all shadow-md cursor-pointer",style:{backgroundColor:g},title:g},g)),E.jsx("button",{type:"button",onClick:()=>{t.chain().focus().unsetColor().run(),o(!1)},className:"w-6 h-6 rounded-full border border-white/20 hover:scale-110 active:scale-95 transition-all flex items-center justify-center bg-transparent cursor-pointer text-red-500 font-bold text-xs",title:"Remove Text Color",style:{display:"flex",alignItems:"center",justifyContent:"center"},children:"/"})]})]}),E.jsx(Oe,{icon:E.jsx(X.Link,{className:"w-4 h-4"}),title:"Link",active:t.isActive("link"),onClick:()=>t.getAttributes("link").href?t.chain().focus().unsetLink().run():h("link")}),E.jsx("div",{className:"w-px h-6 bg-smoke/60 mx-1"}),E.jsx(Oe,{variant:"text",label:"H1",title:"Heading 1",active:t.isActive("heading",{level:1}),onClick:()=>t.chain().focus().toggleHeading({level:1}).run()}),E.jsx(Oe,{variant:"text",label:"H2",title:"Heading 2",active:t.isActive("heading",{level:2}),onClick:()=>t.chain().focus().toggleHeading({level:2}).run()}),E.jsx(Oe,{variant:"text",label:"H3",title:"Heading 3",active:t.isActive("heading",{level:3}),onClick:()=>t.chain().focus().toggleHeading({level:3}).run()}),E.jsx(Oe,{icon:E.jsx(X.Quote,{className:"w-4 h-4"}),title:"Blockquote",active:t.isActive("blockquote"),onClick:()=>t.chain().focus().toggleBlockquote().run()}),E.jsx(Oe,{icon:E.jsx(X.Code,{className:"w-4 h-4"}),title:"Code Block",active:t.isActive("codeBlock"),onClick:()=>t.chain().focus().toggleCodeBlock().run()}),E.jsx(Oe,{icon:E.jsx(X.MessageSquareWarning,{className:"w-4 h-4"}),title:"Callout",active:t.isActive("callout"),onClick:()=>t.chain().focus().insertContent({type:"callout",content:[{type:"paragraph"}]}).run()}),E.jsx("div",{className:"w-px h-6 bg-smoke/60 mx-1"}),E.jsx(Oe,{icon:E.jsx(X.List,{className:"w-4 h-4"}),title:"Bullet List",active:t.isActive("bulletList"),onClick:()=>t.chain().focus().toggleBulletList().run()}),E.jsx(Oe,{icon:E.jsx(X.ListOrdered,{className:"w-4 h-4"}),title:"Numbered List",active:t.isActive("orderedList"),onClick:()=>t.chain().focus().toggleOrderedList().run()}),E.jsx(Oe,{icon:E.jsx(X.CheckSquare,{className:"w-4 h-4"}),title:"Task List",active:t.isActive("taskList"),onClick:()=>t.chain().focus().toggleTaskList().run()}),E.jsx("div",{className:"w-px h-6 bg-smoke/60 mx-1"}),E.jsx(Oe,{icon:E.jsx(X.AlignLeft,{className:"w-4 h-4"}),title:"Align Left",active:t.isActive({textAlign:"left"}),onClick:()=>t.chain().focus().setTextAlign("left").run()}),E.jsx(Oe,{icon:E.jsx(X.AlignCenter,{className:"w-4 h-4"}),title:"Align Center",active:t.isActive({textAlign:"center"}),onClick:()=>t.chain().focus().setTextAlign("center").run()}),E.jsx(Oe,{icon:E.jsx(X.AlignRight,{className:"w-4 h-4"}),title:"Align Right",active:t.isActive({textAlign:"right"}),onClick:()=>t.chain().focus().setTextAlign("right").run()}),E.jsx("div",{className:"w-px h-6 bg-smoke/60 mx-1"}),E.jsx(Oe,{icon:E.jsx(X.ImagePlus,{className:"w-4 h-4"}),label:"Image",title:"Insert Image",onClick:m}),E.jsx(Oe,{icon:E.jsx(X.Video,{className:"w-4 h-4"}),label:"Video",title:"Insert Video",onClick:()=>h("video")}),E.jsx(Oe,{icon:E.jsx(X.MessageSquare,{className:"w-4 h-4"}),label:"Tweet",title:"Insert Tweet",onClick:()=>h("tweet")}),E.jsx(Oe,{icon:E.jsx(X.Camera,{className:"w-4 h-4"}),label:"Instagram",title:"Insert Instagram",onClick:()=>h("instagram")}),E.jsx("div",{className:"flex-1"}),E.jsxs("div",{className:"flex items-center gap-3",children:[E.jsxs("div",{className:"text-xs text-steel font-medium tracking-wide",children:[t.storage.characterCount.words()," words"]}),E.jsx("div",{className:"flex items-center gap-2 px-3 py-1 bg-white/5 rounded-lg border border-white/5",children:e?E.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-emerald-400 font-semibold uppercase tracking-wider",children:[E.jsx(X.CheckCircle2,{className:"w-3 h-3"}),E.jsx("span",{children:"Saved"})]}):E.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-amber/70 font-semibold uppercase tracking-wider",children:[E.jsx(X.CloudUpload,{className:"w-3 h-3 animate-pulse"}),E.jsx("span",{children:"Syncing"})]})})]})]})})},rO=()=>{const{editor:t}=Ca();return t?E.jsx("div",{className:"axiom-editor-canvas relative border border-smoke/60 rounded-xl overflow-y-auto overflow-x-hidden shadow-inner bg-obsidian text-bone transition-colors duration-300 custom-scrollbar axiom-editor-fixed-size min-h-0",children:E.jsx(Hm,{editor:t,className:"min-h-full"})}):null},iO=()=>{const{editor:t,mediaModalOpen:e,setMediaModalOpen:n,mediaModalType:r,mediaModalInput:i,setMediaModalInput:s}=Ca(),o=W.useCallback(()=>{const a=i.trim();if(!a||!t){n(!1);return}if(r==="link"){let l=a;!/^https?:\/\//i.test(l)&&!/^mailto:/i.test(l)&&!/^tel:/i.test(l)&&(l="https://"+l),t.chain().focus().extendMarkRange("link").setLink({href:l}).run()}else r==="video"?t.chain().focus().setYoutubeVideo({src:a}).run():r==="tweet"?t.chain().focus().insertContent({type:"tweet",attrs:{url:a}}).run():r==="instagram"&&t.chain().focus().insertContent({type:"instagram",attrs:{url:a}}).run();n(!1),s("")},[i,r,t,n,s]);return e?E.jsx("div",{className:"fixed inset-0 z-[9999] bg-black/80 flex items-center justify-center p-4 backdrop-blur-sm",children:E.jsxs("div",{className:"bg-obsidian border border-smoke/60 p-5 md:p-6 rounded-2xl w-full max-w-md shadow-2xl mx-4 sm:mx-0",children:[E.jsxs("h3",{className:"text-bone font-display font-semibold mb-4",children:[r==="link"&&"Insert Hyperlink",r==="video"&&"Insert YouTube Embed",r==="tweet"&&"Insert X / Twitter Embed",r==="instagram"&&"Insert Instagram Embed"]}),E.jsx("input",{type:"text",value:i,onChange:a=>s(a.target.value),placeholder:r==="link"?"https://example.com":r==="video"?"https://youtube.com/watch?v=...":r==="tweet"?"https://x.com/username/status/...":"https://instagram.com/reel/...",className:"w-full bg-charcoal/30 border border-smoke/60 rounded-xl px-4 py-3 text-bone focus:outline-none focus:border-amber mb-6 transition-colors text-sm",autoFocus:!0,onKeyDown:a=>{a.key==="Enter"?(a.preventDefault(),o()):a.key==="Escape"&&n(!1)}}),E.jsxs("div",{className:"flex justify-end gap-3",children:[E.jsx("button",{type:"button",onClick:()=>n(!1),className:"px-5 py-2.5 text-steel hover:text-bone text-sm font-medium transition-colors",children:"Cancel"}),E.jsxs("button",{type:"button",onClick:o,className:"px-5 py-2.5 bg-amber hover:bg-amber/90 text-obsidian font-semibold rounded-xl text-sm transition-all shadow-[0_0_15px_rgba(255,191,0,0.15)]",children:[r==="link"&&"Insert Link",r==="video"&&"Insert Video",r==="tweet"&&"Insert Tweet",r==="instagram"&&"Insert Instagram"]})]})]})}):null},sO=({initialContent:t,onChange:e,uploadImage:n,minHeightClass:r,maxHeightClass:i})=>E.jsx(Zb,{initialContent:t,onChange:e,uploadImage:n,minHeightClass:r,maxHeightClass:i,children:E.jsxs("div",{className:"flex flex-col gap-4",children:[E.jsx(nO,{}),E.jsx(rO,{}),E.jsx(iO,{})]})}),vc=(t,e)=>{var s,o;if(t.type==="doc")return E.jsx(E.Fragment,{children:(s=t.content)==null?void 0:s.map((a,l)=>vc(a,l))});if(t.type==="text"){let a=t.text||"";return t.marks&&t.marks.forEach(l=>{var c,u,d,p;if(l.type==="bold"&&(a=E.jsx("strong",{children:a},l.type)),l.type==="italic"&&(a=E.jsx("em",{children:a},l.type)),l.type==="underline"){const f=(c=l.attrs)==null?void 0:c.color;a=E.jsx("u",{style:f?{textDecorationColor:f}:{},children:a},l.type)}if(l.type==="strike"){const f=(u=l.attrs)==null?void 0:u.color;a=E.jsx("s",{style:f?{textDecorationColor:f}:{},children:a},l.type)}if(l.type==="textStyle"){const f=(d=l.attrs)==null?void 0:d.color;f&&(a=E.jsx("span",{style:{color:f},children:a},l.type))}if(l.type==="link"){const f=(p=l.attrs)==null?void 0:p.href;f&&(a=E.jsx("a",{href:f,target:"_blank",rel:"noopener noreferrer",className:"text-amber hover:text-amber/80 transition-colors underline underline-offset-4",children:a},l.type))}}),E.jsx(W.Fragment,{children:a},e)}const n=(o=t.content)==null?void 0:o.map((a,l)=>vc(a,l)),r=t.attrs||{},i=r.textAlign?{textAlign:r.textAlign}:{};switch(t.type){case"paragraph":return E.jsx("p",{style:i,children:n},e);case"heading":{const a=`h${r.level||1}`;return E.jsx(a,{style:i,children:n},e)}case"blockquote":return E.jsx("blockquote",{className:"border-l-4 border-amber/50 pl-4 py-1 italic bg-charcoal/30 rounded-r-lg",children:n},e);case"bulletList":return E.jsx("ul",{className:"list-disc pl-6 marker:text-amber",children:n},e);case"orderedList":return E.jsx("ol",{className:"list-decimal pl-6 marker:text-amber",children:n},e);case"listItem":return E.jsx("li",{children:n},e);case"image":{const a=r.align||"center",l=r.width||"100%";let c="items-center mx-auto";return a==="left"&&(c="items-start mr-auto ml-0"),a==="right"&&(c="items-end ml-auto mr-0"),E.jsxs("div",{className:`flex flex-col my-8 w-full ${c}`,children:[r.caption&&r.captionPosition==="above"&&E.jsx("p",{className:"text-steel text-xs md:text-sm italic mb-3 uppercase tracking-widest font-medium px-2",children:r.caption}),E.jsx("img",{src:r.src,alt:r.alt||"",title:r.title,style:{width:l,minWidth:"150px"},className:"rounded-xl object-cover shadow-2xl border border-smoke/30 max-w-full"}),r.caption&&r.captionPosition==="below"&&E.jsx("p",{className:"text-steel text-xs md:text-sm italic mt-3 uppercase tracking-widest font-medium px-2",children:r.caption})]},e)}case"youtube":return E.jsx("div",{className:"my-8 aspect-video rounded-2xl overflow-hidden shadow-[0_0_40px_rgba(0,0,0,0.5)] border border-smoke/30 bg-black relative",children:E.jsx("iframe",{src:r.src,className:"absolute inset-0 w-full h-full border-0",allowFullScreen:!0})},e);case"tweet":return E.jsx("div",{className:"my-6",children:E.jsx("blockquote",{className:"twitter-tweet",children:E.jsx("a",{href:r.url})})},e);case"instagram":return E.jsx("div",{className:"my-6",children:E.jsx("blockquote",{className:"instagram-media","data-instgrm-permalink":r.url})},e);case"callout":{const a={info:"bg-blue-500/10 border-blue-500/30 text-blue-100",warning:"bg-amber-500/10 border-amber-500/30 text-amber-100",success:"bg-emerald-500/10 border-emerald-500/30 text-emerald-100",error:"bg-red-500/10 border-red-500/30 text-red-100"},l=a[r.type]||a.info;return E.jsxs("div",{className:`my-6 flex gap-4 p-4 md:p-5 rounded-2xl border shadow-md ${l}`,children:[E.jsx("div",{className:"text-2xl shrink-0 mt-0.5 select-none",children:r.emoji}),E.jsx("div",{className:"flex-1 font-medium leading-relaxed",children:n})]},e)}case"codeBlock":return E.jsx("pre",{className:"bg-obsidian border border-smoke/30 p-4 rounded-xl overflow-x-auto text-sm my-6 font-mono text-steel",children:E.jsx("code",{className:`language-${r.language||"plaintext"}`,children:n})},e);case"taskList":return E.jsx("ul",{className:"list-none pl-0 my-6 space-y-2","data-type":"taskList",children:n},e);case"taskItem":return E.jsxs("li",{className:"flex items-start gap-3","data-type":"taskItem",children:[E.jsx("input",{type:"checkbox",className:"mt-1.5 w-4 h-4 rounded border-smoke/30 bg-charcoal text-amber accent-amber cursor-not-allowed",checked:r.checked,readOnly:!0}),E.jsx("div",{className:"flex-1 text-bone",children:n})]},e);case"stash":return null;default:return E.jsx(W.Fragment,{children:n},e)}},oO=({content:t})=>E.jsx("div",{className:"prose prose-invert max-w-none text-bone font-body leading-relaxed prose-p:my-1 prose-headings:my-4",children:vc(t)});exports.AxiomEditor=sO;exports.AxiomEditorProvider=Zb;exports.AxiomJSONRenderer=oO;exports.useAxiomEditor=Ca;
234
+ ${c===n?"bg-amber/10 text-amber":"text-bone hover:bg-charcoal/50 hover:text-amber/80"}`,onClick:()=>i(c),children:[E.jsx("div",{className:"flex items-center justify-center w-8 h-8 rounded-md bg-charcoal/30 border border-smoke/30 shrink-0",children:E.jsx(u,{className:"w-4 h-4"})}),E.jsxs("div",{className:"flex flex-col",children:[E.jsx("span",{className:"font-semibold text-sm font-display tracking-wide",children:l.title}),E.jsx("span",{className:"text-xs text-steel",children:l.description})]})]},c)})}):null});Xb.displayName="CommandList";const WM=({query:t})=>[{title:"Heading 1",description:"Big section heading.",icon:X.Heading1,command:({editor:n,range:r})=>{n.chain().focus().deleteRange(r).setNode("heading",{level:1}).run()}},{title:"Heading 2",description:"Medium section heading.",icon:X.Heading2,command:({editor:n,range:r})=>{n.chain().focus().deleteRange(r).setNode("heading",{level:2}).run()}},{title:"Heading 3",description:"Small section heading.",icon:X.Heading3,command:({editor:n,range:r})=>{n.chain().focus().deleteRange(r).setNode("heading",{level:3}).run()}},{title:"Bullet List",description:"Create a simple bulleted list.",icon:X.List,command:({editor:n,range:r})=>{n.chain().focus().deleteRange(r).toggleBulletList().run()}},{title:"Numbered List",description:"Create a list with numbering.",icon:X.ListOrdered,command:({editor:n,range:r})=>{n.chain().focus().deleteRange(r).toggleOrderedList().run()}},{title:"Quote",description:"Capture a quote.",icon:X.Quote,command:({editor:n,range:r})=>{n.chain().focus().deleteRange(r).toggleBlockquote().run()}},{title:"Task List",description:"Track tasks with a to-do list.",icon:X.CheckSquare,command:({editor:n,range:r})=>{n.chain().focus().deleteRange(r).toggleTaskList().run()}},{title:"Code Block",description:"Capture a code snippet.",icon:X.Code,command:({editor:n,range:r})=>{n.chain().focus().deleteRange(r).toggleCodeBlock().run()}},{title:"Callout",description:"Highlight important information.",icon:X.MessageSquareWarning,command:({editor:n,range:r})=>{n.chain().focus().deleteRange(r).insertContent({type:"callout",content:[{type:"paragraph"}]}).run()}},{title:"Stash Note",description:"Hidden journalist draft note.",icon:X.Archive,command:({editor:n,range:r})=>{n.chain().focus().deleteRange(r).insertContent({type:"stash",content:[{type:"paragraph"}]}).run()}}].filter(n=>n.title.toLowerCase().includes(t.toLowerCase())).slice(0,10),KM=ke.create({name:"slashMenu",addOptions(){return{suggestion:{char:"/",command:({editor:t,range:e,props:n})=>{n.command({editor:t,range:e})}}}},addProseMirrorPlugins(){return[dC({editor:this.editor,...this.options.suggestion,items:WM,render:()=>{let t,e;return{onStart:n=>{t=new Ym(Xb,{props:n,editor:n.editor}),n.clientRect&&(e=Os("body",{getReferenceClientRect:n.clientRect,appendTo:()=>document.body,content:t.element,showOnCreate:!0,interactive:!0,trigger:"manual",placement:"bottom-start"}))},onUpdate(n){t.updateProps(n),n.clientRect&&e[0].setProps({getReferenceClientRect:n.clientRect})},onKeyDown(n){var r;return n.event.key==="Escape"?(e[0].hide(),!0):(r=t.ref)==null?void 0:r.onKeyDown(n)},onExit(){e[0].destroy(),t.destroy()}}}})]}});function qM(){try{return lx}catch{return null}}function GM(t,e){if(t&&typeof t.serializeForClipboard=="function")return t.serializeForClipboard(e);const n=qM();if(n&&typeof(n==null?void 0:n.__serializeForClipboard)=="function")return n.__serializeForClipboard(t,e);throw new Error("No supported clipboard serialization method found.")}function YM(t){const e=t.getBoundingClientRect(),n=t.closest('[role="dialog"]');if(n&&window.getComputedStyle(n).transform!=="none"){const r=n.getBoundingClientRect();return{top:e.top-r.top,left:e.left-r.left,width:e.width}}return{top:e.top,left:e.left,width:e.width}}function Tp(t,e){const n=["li","p:not(:first-child)","pre","blockquote","h1","h2","h3","h4","h5","h6",...e.customNodes.map(r=>`[data-type=${r}]`)].join(", ");return document.elementsFromPoint(t.x,t.y).find(r=>{var i,s;return((s=(i=r.parentElement)==null?void 0:i.matches)==null?void 0:s.call(i,".ProseMirror"))||r.matches(n)})}function JM(t,e,n){var i;const r=t.getBoundingClientRect();return(i=e.posAtCoords({left:r.left+50+n.dragHandleWidth,top:r.top+1}))==null?void 0:i.inside}function Np(t,e){const n=e.state.doc.resolve(t);return n.depth>1?n.before(n.depth):t}function XM(t){let e="";function n(a,l){if(l.focus(),!a.dataTransfer)return;const c=Tp({x:a.clientX+50+t.dragHandleWidth,y:a.clientY},t);if(!(c instanceof Element))return;let u=JM(c,l,t);if(u==null||u<0)return;u=Np(u,l);const{from:d,to:p}=l.state.selection,f=d-p,h=Np(d,l);let m=!1;const g=l.state.doc.resolve(h);if(g.node().type.name==="doc")m=!0;else{const x=ee.create(l.state.doc,g.before());m=!(u+1>=x.$from.pos&&u<=x.$to.pos)}let y=l.state.selection;if(!m&&f!==0&&!(l.state.selection instanceof ee)){const x=ee.create(l.state.doc,p-1);y=le.create(l.state.doc,u,x.$to.pos)}else if(y=ee.create(l.state.doc,u),y.node.type.isInline||y.node.type.name==="tableRow"){let x=l.state.doc.resolve(y.from);y=ee.create(l.state.doc,x.before())}l.dispatch(l.state.tr.setSelection(y)),l.state.selection instanceof ee&&l.state.selection.node.type.name==="listItem"&&(e=c.parentElement.tagName);const w=l.state.selection.content(),{dom:S,text:b}=GM(l,w);a.dataTransfer.clearData(),a.dataTransfer.setData("text/html",S.innerHTML),a.dataTransfer.setData("text/plain",b),a.dataTransfer.effectAllowed="copyMove",a.dataTransfer.setDragImage(c,0,0),l.dragging={slice:w,move:a.ctrlKey}}let r=null;function i(){r&&r.classList.add("hide")}function s(){r&&r.classList.remove("hide")}function o(a){if(a.target instanceof Element){const l=a.relatedTarget;if((l==null?void 0:l.classList.contains("tiptap"))||(l==null?void 0:l.classList.contains("drag-handle")))return}i()}return new Me({key:new ze(t.pluginKey),view:a=>{var d,p,f,h;const l=t.dragHandleSelector?document.querySelector(t.dragHandleSelector):null;r=l??document.createElement("div"),r.draggable=!0,r.dataset.dragHandle="",r.classList.add("drag-handle");function c(m){n(m,a)}r.addEventListener("dragstart",c);function u(m){i();let g=window.scrollY;m.clientY<t.scrollTreshold?window.scrollTo({top:g-30,behavior:"smooth"}):window.innerHeight-m.clientY<t.scrollTreshold&&window.scrollTo({top:g+30,behavior:"smooth"})}return r.addEventListener("drag",u),i(),l||(p=(d=a==null?void 0:a.dom)==null?void 0:d.parentElement)==null||p.appendChild(r),(h=(f=a==null?void 0:a.dom)==null?void 0:f.parentElement)==null||h.addEventListener("mouseout",o),{destroy:()=>{var m,g,y;l||(m=r==null?void 0:r.remove)==null||m.call(r),r==null||r.removeEventListener("drag",u),r==null||r.removeEventListener("dragstart",c),r=null,(y=(g=a==null?void 0:a.dom)==null?void 0:g.parentElement)==null||y.removeEventListener("mouseout",o)}}},props:{handleDOMEvents:{mousemove:(a,l)=>{if(!a.editable)return;const c=Tp({x:l.clientX+50+t.dragHandleWidth,y:l.clientY},t),u=c==null?void 0:c.closest(".not-draggable"),d=t.excludedTags.concat(["ol","ul"]).join(", ");if(!(c instanceof Element)||c.matches(d)||u){i();return}const p=window.getComputedStyle(c),f=parseInt(p.lineHeight,10),h=isNaN(f)?parseInt(p.fontSize)*1.2:f,m=parseInt(p.paddingTop,10),g=YM(c);g.top+=(h-24)/2,g.top+=m,c.matches("ul:not([data-type=taskList]) li, ol li")&&(g.left-=t.dragHandleWidth),g.width=t.dragHandleWidth,r&&(r.style.left=`${g.left-g.width}px`,r.style.top=`${g.top}px`,s())},keydown:()=>{i()},mousewheel:()=>{i()},dragstart:a=>{a.dom.classList.add("dragging")},drop:(a,l)=>{var f;a.dom.classList.remove("dragging"),i();let c=null;const u=a.posAtCoords({left:l.clientX,top:l.clientY});if(!u||(a.state.selection instanceof ee&&(c=a.state.selection.node),!c))return;const p=a.state.doc.resolve(u.pos).parent.type.name==="listItem";if(a.state.selection instanceof ee&&a.state.selection.node.type.name==="listItem"&&!p&&e=="OL"){const h=(f=a.state.schema.nodes.orderedList)==null?void 0:f.createAndFill(null,c),m=new G(F.from(h),0,0);a.dragging={slice:m,move:l.ctrlKey}}},dragend:a=>{a.dom.classList.remove("dragging")}}}})}const ZM=ke.create({name:"globalDragHandle",addOptions(){return{dragHandleWidth:20,scrollTreshold:100,excludedTags:[],customNodes:[]}},addProseMirrorPlugins(){return[XM({pluginKey:"globalDragHandle",dragHandleWidth:this.options.dragHandleWidth,scrollTreshold:this.options.scrollTreshold,dragHandleSelector:this.options.dragHandleSelector,excludedTags:this.options.excludedTags,customNodes:this.options.customNodes})]}}),QM=Fg.extend({addAttributes(){return{color:{default:null,parseHTML:t=>t.style.textDecorationColor||null,renderHTML:t=>t.color?{style:`text-decoration-color: ${t.color};`}:{}}}},addCommands(){return{setUnderline:t=>({commands:e})=>e.setMark(this.name,t),toggleUnderline:t=>({commands:e})=>e.toggleMark(this.name,t),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}}}),eO=Bg.extend({addAttributes(){return{color:{default:null,parseHTML:t=>t.style.textDecorationColor||null,renderHTML:t=>t.color?{style:`text-decoration-color: ${t.color};`}:{}}}},addCommands(){return{setStrike:t=>({commands:e})=>e.setMark(this.name,t),toggleStrike:t=>({commands:e})=>e.toggleMark(this.name,t),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}}}),tO=G_(QN);typeof window<"u"&&Ab.addHook("uponSanitizeElement",(t,e)=>{var n;e.tagName==="iframe"&&((t.getAttribute("src")||"").startsWith("https://www.youtube.com/embed/")||(n=t.parentNode)==null||n.removeChild(t))});const Zb=({initialContent:t,onChange:e,uploadImage:n,children:r,minHeightClass:i="min-h-[150px]",maxHeightClass:s="max-h-[500px]"})=>{const[o,a]=W.useState(!0),[l,c]=W.useState(!1),[u,d]=W.useState("link"),[p,f]=W.useState(""),h=vS({extensions:[RT.configure({heading:{levels:[1,2,3]},strike:!1,codeBlock:!1}),QM,eO,Sb,kb,uA.configure({types:["heading","paragraph","image","youtube"]}),_k.configure({openOnClick:!1,HTMLAttributes:{class:"text-amber hover:text-amber/80 transition-colors underline underline-offset-4 cursor-pointer"}}),jA.configure({inline:!1}),XA.configure({inline:!1}),QA,nC,iC,oC,UA,eA.configure({lowlight:tO}),tA,nA.configure({nested:!0}),KM,ZM.configure({dragHandleWidth:20,scrollTreshold:100})],content:typeof t=="string"?t?Ab.sanitize(t,{ADD_TAGS:["iframe"],ADD_ATTR:["allowfullscreen","frameborder","src"]}):"<p></p>":t,onUpdate:({editor:m})=>{a(!1);const g=m.getJSON(),y=m.getHTML();e&&e(g,y),setTimeout(()=>a(!0),800)},editorProps:{attributes:{class:"prose prose-invert max-w-none focus:outline-none min-h-full p-4 sm:p-6 md:p-8 pb-16 md:pb-24 text-bone font-body leading-relaxed prose-p:my-1 prose-headings:my-4"}}});return W.useEffect(()=>{const m=async g=>{const y=g,{file:w,position:S}=y.detail;if(w)if(n){a(!1);try{const b=await n(w);S!==void 0?h==null||h.chain().insertContentAt(S,{type:"image",attrs:{src:b}}).focus().run():h==null||h.chain().focus().insertContent({type:"image",attrs:{src:b}}).run()}catch(b){console.error("Image upload failed",b)}finally{a(!0)}}else{const b=URL.createObjectURL(w);S!==void 0?h==null||h.chain().insertContentAt(S,{type:"image",attrs:{src:b}}).focus().run():h==null||h.chain().focus().insertContent({type:"image",attrs:{src:b}}).run()}};return window.addEventListener("axiom-image-upload",m),()=>window.removeEventListener("axiom-image-upload",m)},[h,n]),E.jsx(Cb.Provider,{value:{editor:h,isSaved:o,setIsSaved:a,mediaModalOpen:l,setMediaModalOpen:c,mediaModalType:u,setMediaModalType:d,mediaModalInput:p,setMediaModalInput:f,uploadImage:n,minHeightClass:i,maxHeightClass:s},children:r})},Oe=W.forwardRef(({active:t,icon:e,label:n,variant:r="icon",className:i="",...s},o)=>{const a="transition-all rounded-lg shrink-0 flex items-center justify-center gap-2",l=r==="icon"?"p-2.5":"px-3 py-2 text-xs font-semibold",c=t?"text-amber bg-amber/5":"text-steel hover:text-amber hover:bg-amber/5",u=s.disabled?"opacity-30 cursor-not-allowed":"";return E.jsxs("button",{ref:o,type:"button",className:`${a} ${l} ${c} ${u} ${i}`,...s,children:[e,n&&E.jsx("span",{className:"hidden lg:inline",children:n})]})});Oe.displayName="ToolbarButton";const nO=()=>{const{editor:t,isSaved:e,setMediaModalOpen:n,setMediaModalType:r,setMediaModalInput:i}=Ca(),[s,o]=W.useState(!1),a=W.useRef(null),[l,c]=W.useState(!1),u=W.useRef(null),[d,p]=W.useState(!1),f=W.useRef(null);if(W.useEffect(()=>{const g=y=>{a.current&&!a.current.contains(y.target)&&o(!1),u.current&&!u.current.contains(y.target)&&c(!1),f.current&&!f.current.contains(y.target)&&p(!1)};return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[]),!t)return null;const h=g=>{i(""),r(g),n(!0)},m=()=>{const g=t.state.selection.from,y=document.createElement("input");y.type="file",y.accept="image/*",y.onchange=async w=>{var b;const S=(b=w.target.files)==null?void 0:b[0];S&&window.dispatchEvent(new CustomEvent("axiom-image-upload",{detail:{file:S,position:g}}))},y.click()};return E.jsx("div",{className:"-mx-1 px-1 mb-2",children:E.jsxs("div",{className:"flex items-center gap-1 p-2 bg-obsidian border border-smoke/60 rounded-xl sticky top-4 z-20 shadow-xl shadow-black/20 flex-wrap",children:[E.jsxs("div",{className:"flex items-center gap-0.5 mr-1",children:[E.jsx(Oe,{icon:E.jsx(X.Undo,{className:"w-4 h-4"}),title:"Undo",onClick:()=>t.chain().focus().undo().run(),disabled:!t.can().undo()}),E.jsx(Oe,{icon:E.jsx(X.Redo,{className:"w-4 h-4"}),title:"Redo",onClick:()=>t.chain().focus().redo().run(),disabled:!t.can().redo()})]}),E.jsx("div",{className:"w-px h-6 bg-smoke/60 mx-1"}),E.jsx(Oe,{icon:E.jsx(X.Bold,{className:"w-4 h-4"}),title:"Bold",active:t.isActive("bold"),onClick:()=>t.chain().focus().toggleBold().run()}),E.jsx(Oe,{icon:E.jsx(X.Italic,{className:"w-4 h-4"}),title:"Italic",active:t.isActive("italic"),onClick:()=>t.chain().focus().toggleItalic().run()}),E.jsxs("div",{ref:u,className:"relative",children:[E.jsx(Oe,{icon:E.jsx(X.Underline,{className:"w-4 h-4"}),title:"Underline",active:t.isActive("underline"),onClick:()=>{t.isActive("underline")?t.chain().focus().unsetUnderline().run():c(!l)}}),l&&E.jsxs("div",{className:"absolute top-full left-0 mt-2 p-3 bg-charcoal border border-smoke/80 rounded-xl shadow-2xl grid grid-cols-4 gap-2 z-30 min-w-[120px]",children:[["#f9761f","#ffffff","#94a3b8","#ef4444","#22c55e","#3b82f6","#a855f7","#eab308"].map(g=>E.jsx("button",{type:"button",onClick:()=>{t.chain().focus().setUnderline({color:g}).run(),c(!1)},className:"w-6 h-6 rounded-full border border-white/10 hover:scale-110 active:scale-95 transition-all shadow-md cursor-pointer",style:{backgroundColor:g},title:g},g)),E.jsx("button",{type:"button",onClick:()=>{t.chain().focus().unsetUnderline().run(),c(!1)},className:"w-6 h-6 rounded-full border border-white/20 hover:scale-110 active:scale-95 transition-all flex items-center justify-center bg-transparent cursor-pointer text-red-500 font-bold text-xs",title:"Remove Underline",style:{display:"flex",alignItems:"center",justifyContent:"center"},children:"/"})]})]}),E.jsxs("div",{ref:f,className:"relative",children:[E.jsx(Oe,{icon:E.jsx(X.Strikethrough,{className:"w-4 h-4"}),title:"Strikethrough",active:t.isActive("strike"),onClick:()=>{t.isActive("strike")?t.chain().focus().unsetStrike().run():p(!d)}}),d&&E.jsxs("div",{className:"absolute top-full left-0 mt-2 p-3 bg-charcoal border border-smoke/80 rounded-xl shadow-2xl grid grid-cols-4 gap-2 z-30 min-w-[120px]",children:[["#f9761f","#ffffff","#94a3b8","#ef4444","#22c55e","#3b82f6","#a855f7","#eab308"].map(g=>E.jsx("button",{type:"button",onClick:()=>{t.chain().focus().setStrike({color:g}).run(),p(!1)},className:"w-6 h-6 rounded-full border border-white/10 hover:scale-110 active:scale-95 transition-all shadow-md cursor-pointer",style:{backgroundColor:g},title:g},g)),E.jsx("button",{type:"button",onClick:()=>{t.chain().focus().unsetStrike().run(),p(!1)},className:"w-6 h-6 rounded-full border border-white/20 hover:scale-110 active:scale-95 transition-all flex items-center justify-center bg-transparent cursor-pointer text-red-500 font-bold text-xs",title:"Remove Strikethrough",style:{display:"flex",alignItems:"center",justifyContent:"center"},children:"/"})]})]}),E.jsxs("div",{ref:a,className:"relative",children:[E.jsx(Oe,{icon:E.jsx(X.Highlighter,{className:"w-4 h-4"}),title:"Text Color",active:!!t.getAttributes("textStyle").color,onClick:()=>{t.getAttributes("textStyle").color?t.chain().focus().unsetColor().run():o(!s)}}),s&&E.jsxs("div",{className:"absolute top-full left-0 mt-2 p-3 bg-charcoal border border-smoke/80 rounded-xl shadow-2xl grid grid-cols-4 gap-2 z-30 min-w-[120px]",children:[["#f9761f","#ffffff","#94a3b8","#ef4444","#22c55e","#3b82f6","#a855f7","#eab308"].map(g=>E.jsx("button",{type:"button",onClick:()=>{t.chain().focus().setColor(g).run(),o(!1)},className:"w-6 h-6 rounded-full border border-white/10 hover:scale-110 active:scale-95 transition-all shadow-md cursor-pointer",style:{backgroundColor:g},title:g},g)),E.jsx("button",{type:"button",onClick:()=>{t.chain().focus().unsetColor().run(),o(!1)},className:"w-6 h-6 rounded-full border border-white/20 hover:scale-110 active:scale-95 transition-all flex items-center justify-center bg-transparent cursor-pointer text-red-500 font-bold text-xs",title:"Remove Text Color",style:{display:"flex",alignItems:"center",justifyContent:"center"},children:"/"})]})]}),E.jsx(Oe,{icon:E.jsx(X.Link,{className:"w-4 h-4"}),title:"Link",active:t.isActive("link"),onClick:()=>t.getAttributes("link").href?t.chain().focus().unsetLink().run():h("link")}),E.jsx("div",{className:"w-px h-6 bg-smoke/60 mx-1"}),E.jsx(Oe,{variant:"text",label:"H1",title:"Heading 1",active:t.isActive("heading",{level:1}),onClick:()=>t.chain().focus().toggleHeading({level:1}).run()}),E.jsx(Oe,{variant:"text",label:"H2",title:"Heading 2",active:t.isActive("heading",{level:2}),onClick:()=>t.chain().focus().toggleHeading({level:2}).run()}),E.jsx(Oe,{variant:"text",label:"H3",title:"Heading 3",active:t.isActive("heading",{level:3}),onClick:()=>t.chain().focus().toggleHeading({level:3}).run()}),E.jsx(Oe,{icon:E.jsx(X.Quote,{className:"w-4 h-4"}),title:"Blockquote",active:t.isActive("blockquote"),onClick:()=>t.chain().focus().toggleBlockquote().run()}),E.jsx(Oe,{icon:E.jsx(X.Code,{className:"w-4 h-4"}),title:"Code Block",active:t.isActive("codeBlock"),onClick:()=>t.chain().focus().toggleCodeBlock().run()}),E.jsx(Oe,{icon:E.jsx(X.MessageSquareWarning,{className:"w-4 h-4"}),title:"Callout",active:t.isActive("callout"),onClick:()=>t.chain().focus().insertContent({type:"callout",content:[{type:"paragraph"}]}).run()}),E.jsx("div",{className:"w-px h-6 bg-smoke/60 mx-1"}),E.jsx(Oe,{icon:E.jsx(X.List,{className:"w-4 h-4"}),title:"Bullet List",active:t.isActive("bulletList"),onClick:()=>t.chain().focus().toggleBulletList().run()}),E.jsx(Oe,{icon:E.jsx(X.ListOrdered,{className:"w-4 h-4"}),title:"Numbered List",active:t.isActive("orderedList"),onClick:()=>t.chain().focus().toggleOrderedList().run()}),E.jsx(Oe,{icon:E.jsx(X.CheckSquare,{className:"w-4 h-4"}),title:"Task List",active:t.isActive("taskList"),onClick:()=>t.chain().focus().toggleTaskList().run()}),E.jsx("div",{className:"w-px h-6 bg-smoke/60 mx-1"}),E.jsx(Oe,{icon:E.jsx(X.AlignLeft,{className:"w-4 h-4"}),title:"Align Left",active:t.isActive({textAlign:"left"}),onClick:()=>t.chain().focus().setTextAlign("left").run()}),E.jsx(Oe,{icon:E.jsx(X.AlignCenter,{className:"w-4 h-4"}),title:"Align Center",active:t.isActive({textAlign:"center"}),onClick:()=>t.chain().focus().setTextAlign("center").run()}),E.jsx(Oe,{icon:E.jsx(X.AlignRight,{className:"w-4 h-4"}),title:"Align Right",active:t.isActive({textAlign:"right"}),onClick:()=>t.chain().focus().setTextAlign("right").run()}),E.jsx("div",{className:"w-px h-6 bg-smoke/60 mx-1"}),E.jsx(Oe,{icon:E.jsx(X.ImagePlus,{className:"w-4 h-4"}),label:"Image",title:"Insert Image",onClick:m}),E.jsx(Oe,{icon:E.jsx(X.Video,{className:"w-4 h-4"}),label:"Video",title:"Insert Video",onClick:()=>h("video")}),E.jsx(Oe,{icon:E.jsx(X.MessageSquare,{className:"w-4 h-4"}),label:"Tweet",title:"Insert Tweet",onClick:()=>h("tweet")}),E.jsx(Oe,{icon:E.jsx(X.Camera,{className:"w-4 h-4"}),label:"Instagram",title:"Insert Instagram",onClick:()=>h("instagram")}),E.jsx("div",{className:"flex-1"}),E.jsxs("div",{className:"flex items-center gap-3",children:[E.jsxs("div",{className:"text-xs text-steel font-medium tracking-wide",children:[t.storage.characterCount.words()," words"]}),E.jsx("div",{className:"flex items-center gap-2 px-3 py-1 bg-white/5 rounded-lg border border-white/5",children:e?E.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-emerald-400 font-semibold uppercase tracking-wider",children:[E.jsx(X.CheckCircle2,{className:"w-3 h-3"}),E.jsx("span",{children:"Saved"})]}):E.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-amber/70 font-semibold uppercase tracking-wider",children:[E.jsx(X.CloudUpload,{className:"w-3 h-3 animate-pulse"}),E.jsx("span",{children:"Syncing"})]})})]})]})})},rO=()=>{const{editor:t}=Ca();return t?E.jsx("div",{className:"axiom-editor-canvas relative border border-smoke/60 rounded-xl overflow-y-auto overflow-x-hidden shadow-inner bg-obsidian text-bone transition-colors duration-300 custom-scrollbar axiom-editor-fixed-size min-h-0",children:E.jsx(Hm,{editor:t,className:"min-h-full"})}):null},iO=()=>{const{editor:t,mediaModalOpen:e,setMediaModalOpen:n,mediaModalType:r,mediaModalInput:i,setMediaModalInput:s}=Ca(),o=W.useCallback(()=>{const a=i.trim();if(!a||!t){n(!1);return}if(r==="link"){let l=a;!/^https?:\/\//i.test(l)&&!/^mailto:/i.test(l)&&!/^tel:/i.test(l)&&(l="https://"+l),t.chain().focus().extendMarkRange("link").setLink({href:l}).run()}else r==="video"?t.chain().focus().setYoutubeVideo({src:a}).run():r==="tweet"?t.chain().focus().insertContent({type:"tweet",attrs:{url:a}}).run():r==="instagram"&&t.chain().focus().insertContent({type:"instagram",attrs:{url:a}}).run();n(!1),s("")},[i,r,t,n,s]);return e?E.jsx("div",{className:"fixed inset-0 z-[9999] bg-black/80 flex items-center justify-center p-4 backdrop-blur-sm",children:E.jsxs("div",{className:"bg-obsidian border border-smoke/60 p-5 md:p-6 rounded-2xl w-full max-w-md shadow-2xl mx-4 sm:mx-0",children:[E.jsxs("h3",{className:"text-bone font-display font-semibold mb-4",children:[r==="link"&&"Insert Hyperlink",r==="video"&&"Insert YouTube Embed",r==="tweet"&&"Insert X / Twitter Embed",r==="instagram"&&"Insert Instagram Embed"]}),E.jsx("input",{type:"text",value:i,onChange:a=>s(a.target.value),placeholder:r==="link"?"https://example.com":r==="video"?"https://youtube.com/watch?v=...":r==="tweet"?"https://x.com/username/status/...":"https://instagram.com/reel/...",className:"w-full bg-charcoal/30 border border-smoke/60 rounded-xl px-4 py-3 text-bone focus:outline-none focus:border-amber mb-6 transition-colors text-sm",autoFocus:!0,onKeyDown:a=>{a.key==="Enter"?(a.preventDefault(),o()):a.key==="Escape"&&n(!1)}}),E.jsxs("div",{className:"flex justify-end gap-3",children:[E.jsx("button",{type:"button",onClick:()=>n(!1),className:"px-5 py-2.5 text-steel hover:text-bone text-sm font-medium transition-colors",children:"Cancel"}),E.jsxs("button",{type:"button",onClick:o,className:"px-5 py-2.5 bg-amber hover:bg-amber/90 text-obsidian font-semibold rounded-xl text-sm transition-all shadow-[0_0_15px_rgba(255,191,0,0.15)]",children:[r==="link"&&"Insert Link",r==="video"&&"Insert Video",r==="tweet"&&"Insert Tweet",r==="instagram"&&"Insert Instagram"]})]})]})}):null},sO=({initialContent:t,onChange:e,uploadImage:n,minHeightClass:r,maxHeightClass:i})=>E.jsx(Zb,{initialContent:t,onChange:e,uploadImage:n,minHeightClass:r,maxHeightClass:i,children:E.jsxs("div",{className:"flex flex-col gap-4",children:[E.jsx(nO,{}),E.jsx(rO,{}),E.jsx(iO,{})]})}),vc=(t,e)=>{var s,o;if(t.type==="doc")return E.jsx(E.Fragment,{children:(s=t.content)==null?void 0:s.map((a,l)=>vc(a,l))});if(t.type==="text"){let a=t.text||"";return t.marks&&t.marks.forEach(l=>{var c,u,d,p;if(l.type==="bold"&&(a=E.jsx("strong",{children:a},l.type)),l.type==="italic"&&(a=E.jsx("em",{children:a},l.type)),l.type==="underline"){const f=(c=l.attrs)==null?void 0:c.color;a=E.jsx("u",{style:f?{textDecorationColor:f}:{},children:a},l.type)}if(l.type==="strike"){const f=(u=l.attrs)==null?void 0:u.color;a=E.jsx("s",{style:f?{textDecorationColor:f}:{},children:a},l.type)}if(l.type==="textStyle"){const f=(d=l.attrs)==null?void 0:d.color;f&&(a=E.jsx("span",{style:{color:f},children:a},l.type))}if(l.type==="link"){const f=(p=l.attrs)==null?void 0:p.href;f&&(a=E.jsx("a",{href:f,target:"_blank",rel:"noopener noreferrer",className:"text-amber hover:text-amber/80 transition-colors underline underline-offset-4",children:a},l.type))}}),E.jsx(W.Fragment,{children:a},e)}const n=(o=t.content)==null?void 0:o.map((a,l)=>vc(a,l)),r=t.attrs||{},i=r.textAlign?{textAlign:r.textAlign}:{};switch(t.type){case"paragraph":return E.jsx("p",{style:i,children:n},e);case"heading":{const a=`h${r.level||1}`;return E.jsx(a,{style:i,children:n},e)}case"blockquote":return E.jsx("blockquote",{className:"border-l-4 border-amber/50 pl-4 py-1 italic bg-charcoal/30 rounded-r-lg",children:n},e);case"bulletList":return E.jsx("ul",{className:"list-disc pl-6 marker:text-amber",children:n},e);case"orderedList":return E.jsx("ol",{className:"list-decimal pl-6 marker:text-amber",children:n},e);case"listItem":return E.jsx("li",{children:n},e);case"image":{const a=r.align||"center",l=r.width||"100%";let c="items-center mx-auto";return a==="left"&&(c="items-start mr-auto ml-0"),a==="right"&&(c="items-end ml-auto mr-0"),E.jsxs("div",{className:`flex flex-col my-8 w-full ${c}`,children:[r.caption&&r.captionPosition==="above"&&E.jsx("p",{className:"text-steel text-xs md:text-sm italic mb-3 uppercase tracking-widest font-medium px-2",children:r.caption}),E.jsx("img",{src:r.src,alt:r.alt||"",title:r.title,style:{width:l,minWidth:"150px"},className:"rounded-xl object-cover shadow-2xl border border-smoke/30 max-w-full"}),r.caption&&r.captionPosition==="below"&&E.jsx("p",{className:"text-steel text-xs md:text-sm italic mt-3 uppercase tracking-widest font-medium px-2",children:r.caption})]},e)}case"youtube":return E.jsx("div",{className:"my-8 aspect-video rounded-2xl overflow-hidden shadow-[0_0_40px_rgba(0,0,0,0.5)] border border-smoke/30 bg-black relative",children:E.jsx("iframe",{src:r.src,className:"absolute inset-0 w-full h-full border-0",allowFullScreen:!0})},e);case"tweet":return E.jsx("div",{className:"my-6",children:E.jsx("blockquote",{className:"twitter-tweet",children:E.jsx("a",{href:r.url})})},e);case"instagram":return E.jsx("div",{className:"my-6",children:E.jsx("blockquote",{className:"instagram-media","data-instgrm-permalink":r.url})},e);case"callout":{const a={info:"bg-blue-500/10 border-blue-500/30 text-blue-100",warning:"bg-amber-500/10 border-amber-500/30 text-amber-100",success:"bg-emerald-500/10 border-emerald-500/30 text-emerald-100",error:"bg-red-500/10 border-red-500/30 text-red-100"},l=a[r.type]||a.info;return E.jsxs("div",{className:`my-6 flex gap-4 p-4 md:p-5 rounded-2xl border shadow-md ${l}`,children:[E.jsx("div",{className:"text-2xl shrink-0 mt-0.5 select-none",children:r.emoji}),E.jsx("div",{className:"flex-1 font-medium leading-relaxed",children:n})]},e)}case"codeBlock":return E.jsx("pre",{className:"bg-obsidian border border-smoke/30 p-4 rounded-xl overflow-x-auto text-sm my-6 font-mono text-steel",children:E.jsx("code",{className:`language-${r.language||"plaintext"}`,children:n})},e);case"taskList":return E.jsx("ul",{className:"list-none pl-0 my-6 space-y-2","data-type":"taskList",children:n},e);case"taskItem":return E.jsxs("li",{className:"flex items-start gap-3","data-type":"taskItem",children:[E.jsx("input",{type:"checkbox",className:"mt-1.5 w-4 h-4 rounded border-smoke/30 bg-charcoal text-amber accent-amber cursor-not-allowed",checked:r.checked,readOnly:!0}),E.jsx("div",{className:"flex-1 text-bone",children:n})]},e);case"stash":return null;default:return E.jsx(W.Fragment,{children:n},e)}},oO=({content:t})=>E.jsx("div",{className:"prose prose-invert max-w-none text-bone font-body leading-relaxed prose-p:my-1 prose-headings:my-4",children:vc(t)});exports.AxiomEditor=sO;exports.AxiomEditorProvider=Zb;exports.AxiomJSONRenderer=oO;exports.useAxiomEditor=Ca;
@@ -38460,7 +38460,7 @@ const jO = we.create({
38460
38460
  };
38461
38461
  }
38462
38462
  }), KO = zA(V_);
38463
- Jb.addHook("uponSanitizeElement", (t, e) => {
38463
+ typeof window < "u" && Jb.addHook("uponSanitizeElement", (t, e) => {
38464
38464
  var n;
38465
38465
  e.tagName === "iframe" && ((t.getAttribute("src") || "").startsWith("https://www.youtube.com/embed/") || (n = t.parentNode) == null || n.removeChild(t));
38466
38466
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "axiom-editor",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "A premium narrative architecture block editor built on Tiptap",
5
5
  "type": "module",
6
6
  "main": "./dist/axiom-editor.cjs",