@daneshnaik/rich-text-editor 1.0.0

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.
@@ -0,0 +1,17 @@
1
+ (function(z,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],e):(z=typeof globalThis<"u"?globalThis:z||self,e(z.RichTextEditor={},z["react/jsx-runtime"],z.React))})(this,(function(z,e,v){"use strict";const ve=({isOpen:X,onClose:j,onInsert:G,onRemove:oe,isEditing:ie=!1,initialUrl:V="",initialText:Z="",existingLinks:q=[]})=>{const[_,K]=v.useState(V),[R,Q]=v.useState(Z);return v.useEffect(()=>{X&&(K(V||""),Q(Z||""))},[X,V,Z]),X?e.jsx("div",{className:"modal-overlay",onClick:j,children:e.jsxs("div",{className:"modal-content",onClick:N=>N.stopPropagation(),children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h3",{children:"Insert Link"}),e.jsx("button",{className:"modal-close",onClick:j,children:"×"})]}),e.jsxs("div",{className:"modal-body",children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"URL:"}),e.jsx("input",{type:"text",className:"form-input",placeholder:"https://example.com",value:_,onChange:N=>K(N.target.value)})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Display text:"}),e.jsx("input",{type:"text",className:"form-input",value:R,onChange:N=>Q(N.target.value)})]}),q&&q.length>0&&e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Existing links:"}),e.jsx("ul",{className:"existing-links",style:{maxHeight:160,overflow:"auto",paddingLeft:16},children:q.map((N,de)=>e.jsxs("li",{style:{display:"flex",gap:8,alignItems:"center",marginBottom:6},children:[e.jsx("a",{href:N.href,target:"_blank",rel:"noreferrer",children:N.text||N.href}),e.jsx("button",{type:"button",className:"toolbar-btn",onClick:()=>{K(N.href),Q(N.text||N.href)},style:{marginLeft:"auto"},children:"Use"})]},de))})]})]}),e.jsxs("div",{className:"modal-footer",children:[e.jsx("button",{className:"btn-secondary",onClick:j,children:"Cancel"}),ie&&oe&&e.jsx("button",{className:"btn-secondary",onClick:()=>{oe(),j()},style:{marginRight:8},children:"Remove Link"}),e.jsx("button",{className:"btn-primary",onClick:()=>{G({url:_||"",text:R||_||""})},children:"Insert"})]})]})}):null},ze=()=>{const[X,j]=v.useState(""),[G,oe]=v.useState(!1),[ie,V]=v.useState(!1),[Z,q]=v.useState(!1),[_,K]=v.useState(""),[R,Q]=v.useState(!1),[N,de]=v.useState({rows:1,cols:1}),[je,he]=v.useState(!1),[Oe,D]=v.useState(!1),[Y,Ve]=v.useState(""),[pe,De]=v.useState(""),[ye,B]=v.useState(""),[Xe,ne]=v.useState(!1),[me,be]=v.useState(3),[Ce,xe]=v.useState(3),[we,_e]=v.useState("a4"),[O,Ye]=v.useState({bold:!1,italic:!1,underline:!1,strikeThrough:!1,justifyLeft:!1,justifyCenter:!1,justifyRight:!1,insertUnorderedList:!1,insertOrderedList:!1}),ke=()=>{try{const t={bold:document.queryCommandState("bold"),italic:document.queryCommandState("italic"),underline:document.queryCommandState("underline"),strikeThrough:document.queryCommandState("strikeThrough"),justifyLeft:document.queryCommandState("justifyLeft"),justifyCenter:document.queryCommandState("justifyCenter"),justifyRight:document.queryCommandState("justifyRight"),insertUnorderedList:document.queryCommandState("insertUnorderedList"),insertOrderedList:document.queryCommandState("insertOrderedList")};Ye(t);try{const l=window.getSelection(),o=l&&l.anchorNode?l.anchorNode.nodeType===3?l.anchorNode.parentElement:l.anchorNode:null;let r="";try{r=document.queryCommandValue&&document.queryCommandValue("fontName")||""}catch{r=""}!r&&o&&(r=(window.getComputedStyle(o).fontFamily||"").split(",")[0].replace(/["']/g,"").trim()),r&&(r=String(r).replace(/^[<>"']+|[<>"']+$/g,"").split(",")[0].trim(),Ne(r),Je(h=>h.includes(r)?h:[r,...h]));let a="";try{a=document.queryCommandValue("fontSize")||""}catch{a=""}if(!a&&o){const h=parseFloat(window.getComputedStyle(o).fontSize||"16");h<12?a="1":h<16?a="2":h<18?a="3":h<22?a="4":h<26?a="5":h<32?a="6":a="7"}a&&Se(String(a));let d="";try{d=document.queryCommandValue&&document.queryCommandValue("formatBlock")||""}catch{d=""}if(!d&&o){let h=o;for(;h&&h!==u.current;){if(h.tagName&&/H[1-6]|P|BLOCKQUOTE|DIV/.test(h.tagName)){d=h.tagName.toLowerCase();break}h=h.parentElement}}d&&(d=String(d).replace(/[<>]/g,"").toLowerCase(),/^(p|h[1-6]|blockquote)$/.test(d)||(d="p"),fe(d))}catch{}}catch{}},[Ge,Ne]=v.useState("Arial"),[Ke,Se]=v.useState("3"),[Qe,fe]=v.useState("p"),[Bt,Je]=v.useState(["Arial","Helvetica","Segoe UI","Roboto","Open Sans","Lato","Montserrat","Source Sans Pro","Tahoma","Verdana","Trebuchet MS","Georgia","Times New Roman","Palatino Linotype","Garamond","Courier New","Brush Script MT","Impact","Comic Sans MS","Candara","Cambria","Calibri","Merriweather","Noto Sans","Palatino","Bookman","Lucida Sans","Righteous","Poppins"]),u=v.useRef(null),Le=v.useRef(null),F=v.useRef(null),k=v.useRef(null),M=v.useRef(null),Ze=v.useRef(null),y=(t,l=null)=>{try{document.execCommand(t,!1,l)}catch(o){console.error("execCommand failed:",o)}},Re=()=>{u.current&&(j(u.current.innerHTML),ke())};v.useEffect(()=>{const t=()=>{(document.activeElement===u.current||u.current?.contains(document.activeElement))&&ke()};return document.addEventListener("selectionchange",t),()=>document.removeEventListener("selectionchange",t)},[]);const[ee,te]=v.useState({open:!1,initialUrl:"",initialText:"",existingLinks:[]}),et=()=>{let t="";try{const o=window.getSelection();if(o&&o.rangeCount>0){const r=o.getRangeAt(0);if(u.current&&u.current.contains(r.commonAncestorContainer)){F.current=r,o.isCollapsed||(t=o.toString().trim());try{const a=r.commonAncestorContainer.nodeType===3?r.commonAncestorContainer.parentElement:r.commonAncestorContainer,d=a&&a.closest?a.closest("a"):null;d&&u.current.contains(d)?k.current=d:k.current=null}catch{k.current=null}}else F.current=null,k.current=null}}catch{F.current=null,k.current=null}const l=[];try{const o=u.current;o&&o.querySelectorAll("a").forEach(a=>l.push({href:a.getAttribute("href"),text:a.innerText}))}catch{}k.current?te({open:!0,initialUrl:k.current.getAttribute("href")||"",initialText:k.current.innerText||"",existingLinks:l,isEditing:!0}):te({open:!0,initialUrl:"",initialText:t,existingLinks:l,isEditing:!1})},tt=({url:t,text:l})=>{if(te(o=>({...o,open:!1})),!t){F.current=null,k.current=null;return}try{const o=window.getSelection();o.removeAllRanges(),F.current&&o.addRange(F.current)}catch{}try{if(k.current)try{k.current.setAttribute("href",t),k.current.setAttribute("target","_blank"),k.current.setAttribute("rel","noopener noreferrer"),k.current.innerText=l||t}catch{const o=a=>String(a).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),r=`<a href="${o(t)}" target="_blank" rel="noopener noreferrer" contenteditable="false">${o(l||t)}</a>`;y("insertHTML",r)}else if(u.current){u.current.focus();const o=a=>String(a).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),r=`<a href="${o(t)}" target="_blank" rel="noopener noreferrer" contenteditable="false">${o(l||t)}</a>`;y("insertHTML",r)}}catch{try{y("createLink",t)}catch{}}F.current=null,k.current=null},lt=()=>{if(!k.current)return;const t=k.current,l=t.innerText||t.getAttribute("href")||"",o=document.createTextNode(l);t.parentNode.replaceChild(o,t),k.current=null,te(r=>({...r,open:!1}))},ot=t=>{y("foreColor",t.target.value)},nt=t=>{y("hiliteColor",t.target.value)},rt=t=>{const l=t&&t.target?t.target.value:t;y("fontSize",l),Se(String(l))},at=t=>{const l=t&&t.target?t.target.value:t;y("fontName",l),Ne(String(l))},ct=()=>{q(!0)},st=()=>{_&&(Te(_),K(""),q(!1))},it=t=>{const l=t.target.files?.[0];if(l&&l.type.startsWith("image/")){const o=new FileReader;o.onload=r=>{const a=r.target?.result;Te(a),q(!1)},o.readAsDataURL(l)}},Te=t=>{if(!u.current)return;u.current.focus();const l=document.createElement("div");l.className="editable-image-wrap",l.contentEditable="false";const o=document.createElement("img");o.src=t,o.alt="Image",o.style.maxWidth="100%",o.style.height="auto",l.appendChild(o);try{const r=window.getSelection();if(r&&r.rangeCount>0){const a=r.getRangeAt(0);a.deleteContents(),a.insertNode(l),a.setStartAfter(l),a.collapse(!0),r.removeAllRanges(),r.addRange(a)}else u.current.appendChild(l)}catch{u.current.appendChild(l)}setTimeout(()=>Me(l),50)},Me=t=>{if(!t||t.dataset.enhanced)return;const l=t.querySelector("img");if(!l)return;const o=h=>{h.stopPropagation();try{u.current?.querySelectorAll(".editable-image-wrap")?.forEach(S=>S.classList.remove("selected"))}catch{}t.classList.add("selected")};t.addEventListener("click",o);const r=document.createElement("div");r.className="image-controls";const a=(h,C,S)=>{const E=document.createElement("button");return E.type="button",E.className="image-control-btn",E.title=h,E.innerHTML=C,E.addEventListener("click",U=>{U.stopPropagation(),S()}),E},d=()=>{const h=document.createElement("div");return h.className="image-control-divider",h};r.appendChild(a("Align Left","&#8676;",()=>{t.style.display="block",t.style.marginLeft="0",t.style.marginRight="auto"})),r.appendChild(a("Center","&#8801;",()=>{t.style.display="block",t.style.marginLeft="auto",t.style.marginRight="auto"})),r.appendChild(a("Align Right","&#8677;",()=>{t.style.display="block",t.style.marginLeft="auto",t.style.marginRight="0"})),r.appendChild(d()),r.appendChild(a("Original Size","1:1",()=>{l.style.width="",l.style.height="",l.style.maxWidth="100%"})),r.appendChild(a("50% Width","50%",()=>{l.style.width="50%",l.style.height="auto"})),r.appendChild(a("75% Width","75%",()=>{l.style.width="75%",l.style.height="auto"})),r.appendChild(d()),r.appendChild(a("Delete Image","×",()=>{confirm("Delete this image?")&&t.remove()})),t.appendChild(r),["nw","ne","sw","se"].forEach(h=>{const C=document.createElement("div");C.className=`image-resize-handle ${h}`,C.addEventListener("mousedown",S=>{S.preventDefault(),S.stopPropagation(),dt(S,l,h)}),t.appendChild(C)}),t.dataset.enhanced="1"},dt=(t,l,o)=>{const r=t.clientX,a=l.offsetWidth,d=l.offsetHeight,h=a/d,C=E=>{const U=E.clientX-r;let A=a;o.includes("e")?A=Math.max(50,a+U):o.includes("w")&&(A=Math.max(50,a-U));const J=A/h;l.style.width=A+"px",l.style.height=J+"px",l.style.maxWidth="none"},S=()=>{document.removeEventListener("mousemove",C),document.removeEventListener("mouseup",S),document.body.style.cursor=""};document.addEventListener("mousemove",C),document.addEventListener("mouseup",S)};v.useEffect(()=>{const t=u.current;if(!t)return;const l=o=>{try{const r=o.target.closest&&o.target.closest("a");if(r&&r.getAttribute("href")){const a=r.getAttribute("href");if(o.metaKey||o.ctrlKey||o.shiftKey)return;o.preventDefault(),window.open(a,"_blank")}}catch{}};return t.addEventListener("click",l),()=>t.removeEventListener("click",l)},[]);const ht=t=>{y("formatBlock",t),fe(t)},Ee=(t,l)=>{try{const d=window.getSelection();if(d.removeAllRanges(),F.current)d.addRange(F.current);else if(u.current){u.current.focus();const h=document.createRange();h.selectNodeContents(u.current),h.collapse(!1),d.removeAllRanges(),d.addRange(h)}}catch{}const o=typeof t=="number"?t:me,r=typeof l=="number"?l:Ce;let a='<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse; width: auto; margin: 16px 0;">';a+="<thead><tr>";for(let d=0;d<r;d++)a+=`<th style="border: 1px solid #cbd5e1; padding: 12px 16px; background: #f8f9fa; text-align: left; font-weight: 700;">Header ${d+1}</th>`;a+="</tr></thead>",a+="<tbody>";for(let d=0;d<o;d++){a+="<tr>";for(let h=0;h<r;h++)a+=`<td style="border: 1px solid #cbd5e1; padding: 12px 16px; background: #fff;">Cell ${d+1}-${h+1}</td>`;a+="</tr>"}a+="</tbody></table>",y("insertHTML",a),setTimeout(()=>{try{const d=u.current;if(!d)return;const h=d.querySelector("table:last-of-type");h&&Ae(h)}catch{}},20),ne(!1),be(3),xe(3)},pt=(t,l)=>{de({rows:t+1,cols:l+1})},ft=(t,l)=>{Ee(t+1,l+1),Q(!1)},ue=()=>{if(!Y||!u.current){B("Enter text to find");return}try{const t=window.find(Y,!1,!1,!1,!1,!0,!1);B(t?"Found":"No matches found")}catch{B("Search not available in this browser")}},ut=()=>{if(!Y||!u.current){B("Enter text to find");return}try{const t=window.getSelection();if(t&&t.toString().toLowerCase()===Y.toLowerCase()){const l=t.getRangeAt(0);l.deleteContents(),l.insertNode(document.createTextNode(pe)),B("Replaced 1 occurrence"),setTimeout(()=>ue(),100)}else ue()}catch{B("Replace failed")}},gt=()=>{if(!Y||!u.current){B("Enter text to find");return}try{let t=0;const l=u.current.textContent||"",o=new RegExp(Y.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"gi"),r=l.match(o);if(!r||r.length===0){B("No matches found");return}const a=document.createTreeWalker(u.current,NodeFilter.SHOW_TEXT,null,!1),d=[];let h;for(;h=a.nextNode();)o.test(h.nodeValue)&&d.push(h);d.forEach(C=>{const S=C.nodeValue.replace(o,pe),E=(C.nodeValue.match(o)||[]).length;t+=E,C.nodeValue=S}),j(u.current.innerHTML),B(`Replaced ${t} occurrence(s)`)}catch{B("Replace all failed")}},Ae=t=>{if(!t||t.dataset.enhanced)return;const l=document.createElement("div");l.className="editable-table-wrap",t.parentNode.insertBefore(l,t),l.appendChild(t);const o=n=>{const i=n.target.closest("td,th");if(i){if(n.shiftKey&&M.current&&M.current!==i){try{u.current.querySelectorAll(".selected-cell").forEach(s=>s.classList.remove("selected-cell"))}catch{}It(M.current,i,t),M.current=i;return}try{u.current.querySelectorAll(".selected-cell").forEach(s=>s.classList.remove("selected-cell"))}catch{}i.classList.add("selected-cell"),M.current=i}},r=n=>{try{u.current?.querySelectorAll(".editable-table-wrap")?.forEach(c=>c.classList.remove("selected"))}catch{}l.classList.add("selected"),o(n)};t.addEventListener("click",r);try{t.querySelectorAll("td,th").forEach(i=>i.addEventListener("click",o))}catch{}const a=document.createElement("div");a.className="table-controls";const d=(n,i,c)=>{const s=document.createElement("button");return s.type="button",s.className="table-control-btn",s.title=n,s.innerHTML=i,s.addEventListener("click",p=>{p.stopPropagation(),c(t)}),s};a.appendChild(d("Add Row Below","+R",n=>He(n))),a.appendChild(d("Add Column Right","+C",n=>Ie(n))),a.appendChild(d("Delete Row","-R",n=>yt(n))),a.appendChild(d("Delete Column","-C",n=>mt(n))),a.appendChild(d("Delete Table","×",n=>Be(n)));const h=document.createElement("input");h.type="color",h.style.display="none",h.addEventListener("input",n=>{try{const i=n.target.value;M.current&&(M.current.style.background=i)}catch{}});const C=document.createElement("input");C.type="color",C.style.display="none",C.addEventListener("input",n=>{try{const i=n.target.value;let c=[];const s=t.querySelector("thead");s?c=Array.from(s.querySelectorAll("th")):t.rows&&t.rows[0]&&(c=Array.from(t.rows[0].cells)),c.forEach(p=>{p.style.background=i,p.style.color=E(i)})}catch{}});const S=()=>{try{const n=t.querySelector("thead");(n?Array.from(n.querySelectorAll("th")):t.rows[0]?Array.from(t.rows[0].cells):[]).forEach(c=>{c.style.background="",c.style.color=""})}catch{}},E=n=>{if(!n)return"#000";const i=n.replace("#",""),c=parseInt(i.substr(0,2),16),s=parseInt(i.substr(2,2),16),p=parseInt(i.substr(4,2),16);return(c*299+s*587+p*114)/1e3>=128?"#000":"#fff"},U=n=>{const i=[];for(let c=0;c<n.rows.length;c++){const s=n.rows[c];i[c]=i[c]||[];let p=0;for(let f=0;f<s.cells.length;f++){const g=s.cells[f];for(;i[c][p];)p++;const x=parseInt(g.getAttribute("rowspan")||g.rowSpan||1,10),m=parseInt(g.getAttribute("colspan")||g.colSpan||1,10);for(let w=0;w<x;w++)for(let b=0;b<m;b++)i[c+w]=i[c+w]||[],i[c+w][p+b]=g;p+=m}}return i},A=(n,i)=>{const c=U(n);for(let s=0;s<c.length;s++){const p=c[s]||[];for(let f=0;f<p.length;f++)if(p[f]===i)return{r:s,c:f,matrix:c}}return null},J=(n,i)=>{const c=U(n);let s=1/0,p=1/0,f=-1/0,g=-1/0;const x=new Set(i);for(let T=0;T<c.length;T++)for(let H=0;H<(c[T]||[]).length;H++){const $=c[T][H];!$||!x.has($)||(s=Math.min(s,T),p=Math.min(p,H),f=Math.max(f,T),g=Math.max(g,H))}if(s===1/0)return;const m=c[s][p],w=new Set;let b="";for(let T=s;T<=f;T++)for(let H=p;H<=g;H++){const $=c[T][H];$&&($!==m&&w.add($),b.includes($.innerHTML)||(b+=(b?"<br/>":"")+$.innerHTML))}const L=f-s+1,W=g-p+1;try{m.rowSpan=L,m.colSpan=W,m.innerHTML=b}catch{}w.forEach(T=>{try{T.remove()}catch{}});try{m.classList.add("selected-cell"),M.current=m}catch{}},I=(n,i,c)=>{const s=A(c,n);if(!s)return;const{r:p,c:f,matrix:g}=s,x=parseInt(n.getAttribute("rowspan")||n.rowSpan||1,10),m=parseInt(n.getAttribute("colspan")||n.colSpan||1,10);let w=p,b=f;if(i==="right"&&(b=f+m),i==="left"&&(b=f-1),i==="down"&&(w=p+x),i==="up"&&(w=p-1),!g[w]||typeof g[w][b]>"u")return;const L=g[w][b];if(!L||L===n)return;const W=Math.min(p,w),T=Math.max(p,w+(parseInt(L.getAttribute("rowspan")||L.rowSpan||1,10)-1)),H=Math.min(f,b),$=Math.max(f+(m-1),b+(parseInt(L.getAttribute("colspan")||L.colSpan||1,10)-1)),Pe=new Set;for(let se=W;se<=T;se++)for(let ge=H;ge<=$;ge++){const $e=g[se]&&g[se][ge];$e&&Pe.add($e)}J(c,Pe)},We=(n,i,c)=>{try{if(i==="vertical"){const s=parseInt(n.getAttribute("rowspan")||n.rowSpan||1,10);if(s<=1)return;const p=A(c,n);if(!p)return;const{r:f,c:g}=p;n.rowSpan=1;for(let x=1;x<s;x++){const m=c.rows[f+x];if(m){const w=(()=>{let L=0;for(let W=0;W<m.cells.length;W++){const T=m.cells[W],H=parseInt(T.getAttribute("colspan")||T.colSpan||1,10);if(L>=g)return W;L+=H}return m.cells.length})(),b=m.insertCell(w);b.innerHTML=""}}}else if(i==="horizontal"){const s=parseInt(n.getAttribute("colspan")||n.colSpan||1,10);if(s<=1)return;const p=n.parentElement,f=Array.prototype.indexOf.call(p.children,n);n.colSpan=1;for(let g=1;g<s;g++){const x=p.insertCell(f+g);x.innerHTML=""}}}catch{}},Et=(n,i)=>{const c=A(i,n);if(!c)return;const{r:s,matrix:p}=c;try{u.current.querySelectorAll(".selected-cell").forEach(g=>g.classList.remove("selected-cell"))}catch{}for(let f=0;f<(p[s]||[]).length;f++){const g=p[s][f];g&&g.classList.add("selected-cell")}},At=(n,i)=>{const c=A(i,n);if(!c)return;const{c:s,matrix:p}=c;try{u.current.querySelectorAll(".selected-cell").forEach(g=>g.classList.remove("selected-cell"))}catch{}for(let f=0;f<p.length;f++){const g=p[f]&&p[f][s];g&&g.classList.add("selected-cell")}},Ht=n=>{try{u.current.querySelectorAll(".selected-cell").forEach(c=>c.classList.remove("selected-cell"))}catch{}try{n.querySelectorAll("td,th").forEach(c=>c.classList.add("selected-cell"))}catch{}},It=(n,i,c)=>{const s=A(c,n),p=A(c,i);if(!s||!p)return;const f=Math.min(s.r,p.r),g=Math.max(s.r,p.r),x=Math.min(s.c,p.c),m=Math.max(s.c,p.c);try{u.current.querySelectorAll(".selected-cell").forEach(L=>L.classList.remove("selected-cell"))}catch{}const w=s.matrix;for(let b=f;b<=g;b++)for(let L=x;L<=m;L++){const W=w[b]&&w[b][L];W&&W.classList.add("selected-cell")}};a.appendChild(h),a.appendChild(d("Cell Color","■",()=>{if(!M.current){alert("Select a table cell first");return}h.click()})),a.appendChild(C),a.appendChild(d("Header Color","🎨",()=>{try{const n=t.rows[0];if(!n)return alert("Table has no rows");if(!(n.cells[0]&&n.cells[0].tagName.toLowerCase()==="th")){const c=document.createElement("thead"),s=t.rows[0],p=document.createElement("tr");for(let f=0;f<s.cells.length;f++){const g=document.createElement("th");g.innerHTML=s.cells[f].innerHTML,p.appendChild(g)}c.appendChild(p),t.deleteRow(0),t.insertBefore(c,t.firstChild)}}catch{}C.click()})),a.appendChild(d("Clear Header Color","✖",()=>{S()})),a.appendChild(d("Toggle Header","H",()=>{try{const n=t.rows[0];if(!n)return;if(n.cells[0]&&n.cells[0].tagName.toLowerCase()==="th"){const c=document.createElement("tbody");for(let s=0;s<t.rows.length;s++){const p=t.rows[0],f=document.createElement("tr"),g=p.cells;for(let x=0;x<g.length;x++){const m=document.createElement("td");m.innerHTML=g[x].innerHTML,m.style.cssText=g[x].style.cssText,f.appendChild(m)}c.appendChild(f),t.deleteRow(0)}t.appendChild(c)}else{const c=document.createElement("thead"),s=t.rows[0],p=document.createElement("tr"),f=s.cells;for(let g=0;g<f.length;g++){const x=document.createElement("th");x.innerHTML=f[g].innerHTML,x.style.cssText=f[g].style.cssText,p.appendChild(x)}c.appendChild(p),t.deleteRow(0),t.insertBefore(c,t.firstChild)}}catch{}})),l.appendChild(a),["nw","ne","sw","se"].forEach(n=>{const i=document.createElement("div");i.className=`table-resize-handle ${n}`,i.addEventListener("mousedown",c=>{c.preventDefault(),c.stopPropagation(),vt(c,l,t,n)}),l.appendChild(i)});const re=document.createElement("div");re.className="table-drag-handle",re.title="Drag to move table",l.appendChild(re);const P=document.createElement("div");P.className="table-context-menu",P.innerHTML=`
2
+ <button type="button" data-action="select-row">Select row</button>
3
+ <button type="button" data-action="select-column">Select column</button>
4
+ <button type="button" data-action="select-table">Select table</button>
5
+ <hr/>
6
+ <button type="button" data-action="merge-up">Merge cell up</button>
7
+ <button type="button" data-action="merge-right">Merge cell right</button>
8
+ <button type="button" data-action="merge-down">Merge cell down</button>
9
+ <button type="button" data-action="merge-left">Merge cell left</button>
10
+ <hr/>
11
+ <button type="button" data-action="split-vertical">Split cell vertically</button>
12
+ <button type="button" data-action="split-horizontal">Split cell horizontally</button>
13
+ <hr/>
14
+ <button type="button" data-action="add-row">Add row below</button>
15
+ <button type="button" data-action="add-col">Add column right</button>
16
+ <button type="button" data-action="delete-table">Delete table</button>
17
+ `,P.style.display="none",l.appendChild(P);const ae=(n,i,c)=>{n?(P.style.display="block",P.style.left=typeof i=="number"?i+"px":"8px",P.style.top=typeof c=="number"?c+"px":"36px"):P.style.display="none"};P.addEventListener("click",n=>{n.stopPropagation();const i=n.target.closest("button[data-action]");if(!i)return;const c=i.getAttribute("data-action");try{const s=M.current||t.rows[0].cells[0];if(!s)return;c==="select-row"&&Et(s,t),c==="select-column"&&At(s,t),c==="select-table"&&Ht(t),c==="merge-right"&&I(s,"right",t),c==="merge-left"&&I(s,"left",t),c==="merge-up"&&I(s,"up",t),c==="merge-down"&&I(s,"down",t),c==="split-vertical"&&We(s,"vertical",t),c==="split-horizontal"&&We(s,"horizontal",t),c==="add-row"&&He(t),c==="add-col"&&Ie(t),c==="delete-table"&&Be(t)}catch{}ae(!1)});const qe=d("Table Menu","&#8942;",()=>{ae(P.style.display!=="block")});qe.className+=" table-menu-btn",a.appendChild(qe),l.addEventListener("contextmenu",n=>{n.preventDefault(),F.current=null,M.current=n.target.closest("td,th")||M.current;const i=l.getBoundingClientRect();ae(!0,n.clientX-i.left,n.clientY-i.top)}),document.addEventListener("click",n=>{l.contains(n.target)||ae(!1)});let ce=!1,le=null;const Fe=n=>{if(!ce)return;const i=n.clientX-le.x,c=n.clientY-le.y;l.style.transform=`translate(${le.tx+i}px, ${le.ty+c}px)`},Ue=()=>{if(!ce)return;ce=!1,document.removeEventListener("mousemove",Fe),document.removeEventListener("mouseup",Ue);const n=l.style.transform.match(/translate\((-?\d+)px,\s*(-?\d+)px\)/);if(n){const i=parseInt(n[1],10),c=parseInt(n[2],10);l.style.left=l.offsetLeft+i+"px",l.style.top=l.offsetTop+c+"px",l.style.transform="",l.style.position="absolute"}};re.addEventListener("mousedown",n=>{n.preventDefault(),n.stopPropagation(),ce=!0,le={x:n.clientX,y:n.clientY,tx:0,ty:0},document.addEventListener("mousemove",Fe),document.addEventListener("mouseup",Ue)}),t.dataset.enhanced="1"},vt=(t,l,o,r)=>{const a=t.clientX,d=t.clientY,h=o.offsetWidth,C=o.offsetHeight,S=U=>{const A=U.clientX-a,J=U.clientY-d;if(r.includes("e")){const I=Math.max(200,h+A);o.style.width=I+"px"}else if(r.includes("w")){const I=Math.max(200,h-A);o.style.width=I+"px"}if(r.includes("s")){const I=Math.max(100,C+J);o.style.height=I+"px"}else if(r.includes("n")){const I=Math.max(100,C-J);o.style.height=I+"px"}},E=()=>{document.removeEventListener("mousemove",S),document.removeEventListener("mouseup",E),document.body.style.cursor=""};document.addEventListener("mousemove",S),document.addEventListener("mouseup",E)},He=t=>{const l=M.current;let o=-1;l&&(o=l.parentElement.rowIndex);const r=t.rows[0]?t.rows[0].cells.length:t.tBodies[0]&&t.tBodies[0].rows[0]?t.tBodies[0].rows[0].cells.length:1,a=t.insertRow(o+1);for(let d=0;d<r;d++){const h=a.insertCell(-1);h.innerHTML=`Cell ${a.rowIndex}-${d+1}`}},Ie=t=>{const l=M.current;let o=-1;l&&(o=Array.prototype.indexOf.call(l.parentElement.children,l));for(let r=0;r<t.rows.length;r++){const a=t.rows[r],d=o+1,h=a.insertCell(d);h.innerHTML=""}},yt=t=>{if(t.rows.length<=1)return;const l=M.current;let o=l?l.parentElement.rowIndex:t.rows.length-1;t.deleteRow(o)},mt=t=>{const l=t.rows[0]?t.rows[0].cells.length:0;if(l<=1)return;const o=M.current;let r=o?Array.prototype.indexOf.call(o.parentElement.children,o):l-1;for(let a=0;a<t.rows.length;a++){const d=t.rows[a];d.cells[r]&&d.deleteCell(r)}},Be=t=>{const l=t.closest(".editable-table-wrap");l?l.remove():t.remove()},bt=()=>{try{const t=u.current;if(!t)return;t.querySelectorAll("table").forEach(o=>Ae(o))}catch{}},Ct=()=>{try{const t=u.current;if(!t)return;t.querySelectorAll("img:not(.editable-image-wrap img)").forEach(o=>{if(!o.closest(".editable-image-wrap")){const r=document.createElement("div");r.className="editable-image-wrap",r.contentEditable="false",o.parentNode.insertBefore(r,o),r.appendChild(o),Me(r)}})}catch{}},xt=()=>{oe(!G)},wt=()=>{const t=u.current?.innerHTML||"",l=new Blob([t],{type:"text/html"}),o=URL.createObjectURL(l),r=document.createElement("a");r.href=o,r.download="document.html",r.click(),URL.revokeObjectURL(o)};v.useEffect(()=>{const t=()=>{const l=u.current?.innerText||"",o=new Blob([l],{type:"text/plain"}),r=URL.createObjectURL(o),a=document.createElement("a");a.href=r,a.download="document.txt",a.click(),URL.revokeObjectURL(r)};try{window._exportAsText=t}catch{}return()=>{try{delete window._exportAsText}catch{}}},[]),v.useEffect(()=>{const t=l=>{try{const o=l.target.closest(".editable-table-wrap"),r=l.target.closest(".editable-image-wrap");!o&&u.current&&u.current.querySelectorAll(".editable-table-wrap.selected").forEach(d=>d.classList.remove("selected")),!r&&u.current&&u.current.querySelectorAll(".editable-image-wrap.selected").forEach(d=>d.classList.remove("selected"))}catch{}};return document.addEventListener("click",t),()=>document.removeEventListener("click",t)},[]);const kt=t=>{const l=t.target.files?.[0];if(l){const o=new FileReader;o.onload=r=>{const a=r.target?.result;u.current&&(u.current.innerHTML=a,j(a),setTimeout(()=>{bt(),Ct()},50))},o.readAsText(l)}},Nt=()=>{V(!0)},St=()=>{const t=u.current?.innerHTML||"";navigator.clipboard.writeText(t).then(()=>{alert("HTML copied to clipboard!")})},Lt=()=>{confirm("Are you sure you want to clear all content?")&&u.current&&(y("selectAll"),y("delete"),j(""))},Tt=()=>{const t=prompt("Enter your code:");if(t){const l=`<pre><code>${t}</code></pre>`;y("insertHTML",l)}},Mt=()=>{y("formatBlock","blockquote")};return e.jsxs("div",{className:`editor-container ${G?"fullscreen":""}`,children:[e.jsx("input",{type:"file",ref:Le,onChange:kt,accept:".html,.txt",style:{display:"none"}}),e.jsx("div",{className:"editor-content",children:e.jsxs("div",{className:`page-card size-${we}`,children:[e.jsxs("div",{className:"editor-toolbar",children:[e.jsxs("div",{className:"toolbar-group",children:[e.jsx("button",{className:"toolbar-btn",onClick:()=>y("undo"),title:"Undo",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M3 7v6h6"}),e.jsx("path",{d:"M21 17a9 9 0 00-9-9 9 9 0 00-6 2.3L3 13"})]})}),e.jsx("button",{className:"toolbar-btn",onClick:()=>y("redo"),title:"Redo",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M21 7v6h-6"}),e.jsx("path",{d:"M3 17a9 9 0 019-9 9 9 0 016 2.3l3 2.7"})]})})]}),e.jsx("div",{className:"toolbar-divider"}),e.jsxs("div",{className:"toolbar-group",children:[e.jsxs("select",{className:"toolbar-select",onChange:at,value:Ge,children:[e.jsx("option",{value:"Arial",children:"Arial"}),e.jsx("option",{value:"Helvetica",children:"Helvetica"}),e.jsx("option",{value:"Segoe UI",children:"Segoe UI"}),e.jsx("option",{value:"Roboto",children:"Roboto"}),e.jsx("option",{value:"Open Sans",children:"Open Sans"}),e.jsx("option",{value:"Lato",children:"Lato"}),e.jsx("option",{value:"Montserrat",children:"Montserrat"}),e.jsx("option",{value:"Source Sans Pro",children:"Source Sans Pro"}),e.jsx("option",{value:"Tahoma",children:"Tahoma"}),e.jsx("option",{value:"Verdana",children:"Verdana"}),e.jsx("option",{value:"Trebuchet MS",children:"Trebuchet MS"}),e.jsx("option",{value:"Georgia",children:"Georgia"}),e.jsx("option",{value:"Times New Roman",children:"Times New Roman"}),e.jsx("option",{value:"Palatino Linotype",children:"Palatino Linotype"}),e.jsx("option",{value:"Garamond",children:"Garamond"}),e.jsx("option",{value:"Courier New",children:"Courier New"}),e.jsx("option",{value:"Brush Script MT",children:"Brush Script MT"}),e.jsx("option",{value:"Impact",children:"Impact"}),e.jsx("option",{value:"Comic Sans MS",children:"Comic Sans MS"}),e.jsx("option",{value:"Candara",children:"Candara"}),e.jsx("option",{value:"Cambria",children:"Cambria"}),e.jsx("option",{value:"Calibri",children:"Calibri"}),e.jsx("option",{value:"Merriweather",children:"Merriweather"}),e.jsx("option",{value:"Noto Sans",children:"Noto Sans"}),e.jsx("option",{value:"Palatino",children:"Palatino"}),e.jsx("option",{value:"Bookman",children:"Bookman"}),e.jsx("option",{value:"Lucida Sans",children:"Lucida Sans"}),e.jsx("option",{value:"Righteous",children:"Righteous"}),e.jsx("option",{value:"Poppins",children:"Poppins"})]}),e.jsxs("select",{className:"toolbar-select",onChange:rt,value:Ke,children:[e.jsx("option",{value:"1",children:"Small"}),e.jsx("option",{value:"3",children:"Normal"}),e.jsx("option",{value:"5",children:"Large"}),e.jsx("option",{value:"7",children:"Huge"})]}),e.jsxs("select",{className:"toolbar-select",onChange:t=>{ht(t.target.value),fe(t.target.value)},value:Qe,children:[e.jsx("option",{value:"p",children:"Paragraph"}),e.jsx("option",{value:"h1",children:"Heading 1"}),e.jsx("option",{value:"h2",children:"Heading 2"}),e.jsx("option",{value:"h3",children:"Heading 3"}),e.jsx("option",{value:"h4",children:"Heading 4"})]})]}),e.jsx("div",{className:"toolbar-divider"}),e.jsxs("div",{className:"toolbar-group",children:[e.jsx("button",{className:`toolbar-btn ${O.bold?"active":""}`,onClick:()=>y("bold"),title:"Bold",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[e.jsx("path",{d:"M6 4h8a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z"}),e.jsx("path",{d:"M6 12h9a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z"})]})}),e.jsx("button",{className:`toolbar-btn ${O.italic?"active":""}`,onClick:()=>y("italic"),title:"Italic",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("line",{x1:"19",y1:"4",x2:"10",y2:"4"}),e.jsx("line",{x1:"14",y1:"20",x2:"5",y2:"20"}),e.jsx("line",{x1:"15",y1:"4",x2:"9",y2:"20"})]})}),e.jsx("button",{className:`toolbar-btn ${O.underline?"active":""}`,onClick:()=>y("underline"),title:"Underline",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M6 3v7a6 6 0 0 0 6 6 6 6 0 0 0 6-6V3"}),e.jsx("line",{x1:"4",y1:"21",x2:"20",y2:"21"})]})}),e.jsx("button",{className:`toolbar-btn ${O.strikeThrough?"active":""}`,onClick:()=>y("strikeThrough"),title:"Strikethrough",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M16 4H9a3 3 0 0 0-2.83 4"}),e.jsx("path",{d:"M14 12a4 4 0 0 1 0 8H6"}),e.jsx("line",{x1:"4",y1:"12",x2:"20",y2:"12"})]})})]}),e.jsx("div",{className:"toolbar-divider"}),e.jsxs("div",{className:"toolbar-group",children:[e.jsxs("div",{className:"color-picker-wrapper","data-tooltip":"Text color","aria-label":"Text color picker",children:[e.jsx("input",{type:"color",onChange:ot,className:"color-picker",title:"Text Color",defaultValue:"#111827","aria-label":"Text color"}),e.jsx("span",{className:"color-label",children:"A"}),e.jsx("span",{className:"color-caption",children:"Text color"})]}),e.jsxs("div",{className:"color-picker-wrapper","data-tooltip":"Highlight / background color","aria-label":"Background color picker",children:[e.jsx("input",{type:"color",onChange:nt,className:"color-picker",title:"Background Color",defaultValue:"#ffffff","aria-label":"Background color"}),e.jsx("span",{className:"color-label",children:"◼"}),e.jsx("span",{className:"color-caption",children:"Highlight"})]})]}),e.jsx("div",{className:"toolbar-divider"}),e.jsx("div",{className:"toolbar-group",children:e.jsxs("div",{style:{position:"relative",display:"inline-block"},children:[e.jsx("button",{className:"toolbar-btn",onClick:()=>D(t=>!t),title:"More formatting",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("circle",{cx:"5",cy:"6",r:"1.2"}),e.jsx("circle",{cx:"5",cy:"12",r:"1.2"}),e.jsx("circle",{cx:"5",cy:"18",r:"1.2"}),e.jsx("line",{x1:"10",y1:"6",x2:"21",y2:"6"}),e.jsx("line",{x1:"10",y1:"12",x2:"21",y2:"12"}),e.jsx("line",{x1:"10",y1:"18",x2:"21",y2:"18"})]})}),Oe&&e.jsxs("div",{className:"toolbar-dropdown-panel",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"toolbar-dropdown-row",children:[e.jsx("button",{className:`toolbar-btn ${O.justifyLeft?"active":""}`,onClick:()=>{y("justifyLeft"),D(!1)},title:"Align Left",children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("line",{x1:"17",y1:"10",x2:"3",y2:"10"}),e.jsx("line",{x1:"21",y1:"6",x2:"3",y2:"6"}),e.jsx("line",{x1:"21",y1:"14",x2:"3",y2:"14"})]})}),e.jsx("button",{className:`toolbar-btn ${O.justifyCenter?"active":""}`,onClick:()=>{y("justifyCenter"),D(!1)},title:"Align Center",children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("line",{x1:"18",y1:"10",x2:"6",y2:"10"}),e.jsx("line",{x1:"21",y1:"6",x2:"3",y2:"6"}),e.jsx("line",{x1:"21",y1:"14",x2:"3",y2:"14"})]})}),e.jsx("button",{className:`toolbar-btn ${O.justifyRight?"active":""}`,onClick:()=>{y("justifyRight"),D(!1)},title:"Align Right",children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("line",{x1:"21",y1:"10",x2:"7",y2:"10"}),e.jsx("line",{x1:"21",y1:"6",x2:"3",y2:"6"}),e.jsx("line",{x1:"21",y1:"14",x2:"3",y2:"14"})]})})]}),e.jsx("div",{className:"toolbar-dropdown-sep"}),e.jsxs("div",{className:"toolbar-dropdown-row",children:[e.jsx("button",{className:`toolbar-btn ${O.insertUnorderedList?"active":""}`,onClick:()=>{y("insertUnorderedList"),D(!1)},title:"Bullet List",children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("line",{x1:"8",y1:"6",x2:"21",y2:"6"}),e.jsx("line",{x1:"8",y1:"12",x2:"21",y2:"12"}),e.jsx("circle",{cx:"4",cy:"6",r:"1",fill:"currentColor"})]})}),e.jsx("button",{className:`toolbar-btn ${O.insertOrderedList?"active":""}`,onClick:()=>{y("insertOrderedList"),D(!1)},title:"Numbered List",children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("line",{x1:"10",y1:"6",x2:"21",y2:"6"}),e.jsx("line",{x1:"10",y1:"12",x2:"21",y2:"12"})]})}),e.jsx("button",{className:"toolbar-btn",onClick:()=>{y("indent"),D(!1)},title:"Indent",children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("line",{x1:"21",y1:"4",x2:"9",y2:"4"})})}),e.jsx("button",{className:"toolbar-btn",onClick:()=>{y("outdent"),D(!1)},title:"Outdent",children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("line",{x1:"21",y1:"4",x2:"9",y2:"4"})})})]})]})]})}),e.jsx("div",{className:"toolbar-divider"}),e.jsxs("div",{className:"toolbar-group",children:[e.jsx("button",{className:"toolbar-btn",onClick:et,title:"Insert Link",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),e.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})}),e.jsx("button",{className:"toolbar-btn",onClick:ct,title:"Insert Image",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),e.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),e.jsx("polyline",{points:"21 15 16 10 5 21"})]})}),e.jsxs("div",{style:{position:"relative",display:"inline-block"},children:[e.jsx("button",{className:"toolbar-btn",onClick:()=>Q(!R),title:"Insert Table",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),e.jsx("line",{x1:"3",y1:"9",x2:"21",y2:"9"}),e.jsx("line",{x1:"3",y1:"15",x2:"21",y2:"15"}),e.jsx("line",{x1:"9",y1:"3",x2:"9",y2:"21"}),e.jsx("line",{x1:"15",y1:"3",x2:"15",y2:"21"})]})}),R&&e.jsxs("div",{className:"table-size-picker show",children:[e.jsx("div",{className:"table-size-grid",style:{gridTemplateColumns:"repeat(10, 18px)"},children:Array.from({length:10},(t,l)=>Array.from({length:10},(o,r)=>e.jsx("div",{className:`table-cell-preview ${l<N.rows&&r<N.cols?"hover":""}`,onMouseEnter:()=>pt(l,r),onClick:()=>ft(l,r)},`${l}-${r}`))).flat()}),e.jsxs("div",{className:"table-size-label",children:[N.rows," × ",N.cols]})]})]}),e.jsx("button",{className:"toolbar-btn",onClick:()=>he(!0),title:"Find and Replace",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("path",{d:"m21 21-4.35-4.35"})]})}),e.jsx("button",{className:"toolbar-btn",onClick:()=>y("insertHorizontalRule"),title:"Horizontal Rule",children:e.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("line",{x1:"3",y1:"12",x2:"21",y2:"12"})})}),e.jsx("button",{className:"toolbar-btn",onClick:Mt,title:"Insert Quote",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M3 21c3 0 7-1 7-8V5c0-1.25-.756-2.017-2-2H4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2 1 0 1 0 1 1v1c0 1-1 2-2 2s-1 .008-1 1.031V20c0 1 0 1 1 1z"}),e.jsx("path",{d:"M15 21c3 0 7-1 7-8V5c0-1.25-.757-2.017-2-2h-4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2h.75c0 2.25.25 4-2.75 4v3c0 1 0 1 1 1z"})]})}),e.jsx("button",{className:"toolbar-btn",onClick:Tt,title:"Code Block",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("polyline",{points:"16 18 22 12 16 6"}),e.jsx("polyline",{points:"8 6 2 12 8 18"})]})})]}),e.jsx("div",{className:"toolbar-divider"}),e.jsxs("div",{className:"toolbar-group",children:[e.jsxs("select",{className:"toolbar-select",value:we,onChange:t=>_e(t.target.value),title:"Page size","aria-label":"Page size",children:[e.jsx("option",{value:"a0",children:"A0"}),e.jsx("option",{value:"a1",children:"A1"}),e.jsx("option",{value:"a2",children:"A2"}),e.jsx("option",{value:"a3",children:"A3"}),e.jsx("option",{value:"a4",children:"A4"}),e.jsx("option",{value:"a5",children:"A5"}),e.jsx("option",{value:"a6",children:"A6"}),e.jsx("option",{value:"b0",children:"B0"}),e.jsx("option",{value:"b1",children:"B1"}),e.jsx("option",{value:"b2",children:"B2"}),e.jsx("option",{value:"b3",children:"B3"}),e.jsx("option",{value:"b4",children:"B4"}),e.jsx("option",{value:"b5",children:"B5"}),e.jsx("option",{value:"letter",children:"Letter"}),e.jsx("option",{value:"legal",children:"Legal"}),e.jsx("option",{value:"ledger",children:"Ledger"}),e.jsx("option",{value:"tabloid",children:"Tabloid"}),e.jsx("option",{value:"executive",children:"Executive"}),e.jsx("option",{value:"statement",children:"Statement"}),e.jsx("option",{value:"folio",children:"Folio"}),e.jsx("option",{value:"c4",children:"C4"}),e.jsx("option",{value:"c5",children:"C5"}),e.jsx("option",{value:"monarch",children:"Monarch"}),e.jsx("option",{value:"dl-envelope",children:"Envelope DL"}),e.jsx("option",{value:"c6-envelope",children:"Envelope C6"}),e.jsx("option",{value:"custom",children:"Custom"})]}),e.jsx("button",{className:"toolbar-btn",onClick:()=>Le.current?.click(),title:"Import",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.jsx("polyline",{points:"7 10 12 15 17 10"}),e.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})}),e.jsx("button",{className:"toolbar-btn",onClick:wt,title:"Export HTML",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.jsx("polyline",{points:"17 8 12 3 7 8"}),e.jsx("line",{x1:"12",y1:"3",x2:"12",y2:"15"})]})}),e.jsx("button",{className:"toolbar-btn",onClick:Nt,title:"View HTML",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("polyline",{points:"16 18 22 12 16 6"}),e.jsx("polyline",{points:"8 6 2 12 8 18"})]})}),e.jsx("button",{className:"toolbar-btn",onClick:Lt,title:"Clear All",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("polyline",{points:"3 6 5 6 21 6"}),e.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]})}),e.jsx("button",{className:"toolbar-btn",onClick:xt,title:G?"Exit Fullscreen":"Fullscreen",children:e.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:G?e.jsx("path",{d:"M8 3v3a2 2 0 0 1-2 2H3m18 0h-3a2 2 0 0 1-2-2V3m0 18v-3a2 2 0 0 1 2-2h3M3 16h3a2 2 0 0 1 2 2v3"}):e.jsx("path",{d:"M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7"})})})]}),e.jsx("div",{className:"toolbar-divider"}),e.jsx("div",{className:"toolbar-group",children:e.jsx("button",{className:"toolbar-btn",onClick:()=>y("removeFormat"),title:"Clear Formatting",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M4 7h16M9 20h6M12 4v16"}),e.jsx("line",{x1:"3",y1:"3",x2:"21",y2:"21",strokeWidth:"1.5"})]})})})]}),e.jsx("div",{ref:u,className:"page-body",contentEditable:!0,onInput:Re,suppressContentEditableWarning:!0})]})}),e.jsxs("div",{className:"status-bar-bottom",children:[e.jsxs("span",{className:"status-item",children:["Characters: ",X.replace(/<[^>]*>/g,"").length]}),e.jsx("span",{className:"status-item",children:"•"}),e.jsxs("span",{className:"status-item",children:["Words: ",X.replace(/<[^>]*>/g,"").trim().split(/\s+/).filter(t=>t).length]})]}),Xe&&e.jsx("div",{className:"modal-overlay",onClick:()=>ne(!1),children:e.jsxs("div",{className:"modal-content",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h3",{children:"Insert Table"}),e.jsx("button",{className:"modal-close",onClick:()=>ne(!1),children:"×"})]}),e.jsxs("div",{className:"modal-body",children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Rows:"}),e.jsx("input",{type:"number",min:"1",max:"20",value:me,onChange:t=>be(parseInt(t.target.value)||1),className:"form-input"})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Columns:"}),e.jsx("input",{type:"number",min:"1",max:"10",value:Ce,onChange:t=>xe(parseInt(t.target.value)||1),className:"form-input"})]})]}),e.jsxs("div",{className:"modal-footer",children:[e.jsx("button",{className:"btn-secondary",onClick:()=>ne(!1),children:"Cancel"}),e.jsx("button",{className:"btn-primary",onClick:Ee,children:"Insert Table"})]})]})}),ie&&e.jsx("div",{className:"modal-overlay",onClick:()=>V(!1),children:e.jsxs("div",{className:"modal-content modal-large",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h3",{children:"HTML Source Code"}),e.jsx("button",{className:"modal-close",onClick:()=>V(!1),children:"×"})]}),e.jsx("div",{className:"modal-body",children:e.jsx("pre",{className:"html-preview",children:X||""})}),e.jsxs("div",{className:"modal-footer",children:[e.jsx("button",{className:"btn-secondary",onClick:()=>V(!1),children:"Close"}),e.jsx("button",{className:"btn-primary",onClick:St,children:"Copy HTML"})]})]})}),je&&e.jsx("div",{className:"link-modal-overlay",onClick:()=>he(!1),children:e.jsxs("div",{className:"find-replace-modal",onClick:t=>t.stopPropagation(),children:[e.jsx("h3",{children:"Find and Replace"}),e.jsxs("div",{className:"find-replace-group",children:[e.jsx("label",{children:"Find:"}),e.jsx("input",{type:"text",className:"find-replace-input",value:Y,onChange:t=>Ve(t.target.value),placeholder:"Enter text to find...",autoFocus:!0})]}),e.jsxs("div",{className:"find-replace-group",children:[e.jsx("label",{children:"Replace with:"}),e.jsx("input",{type:"text",className:"find-replace-input",value:pe,onChange:t=>De(t.target.value),placeholder:"Enter replacement text..."})]}),ye&&e.jsx("div",{className:"find-replace-status",children:ye}),e.jsxs("div",{className:"find-replace-buttons",children:[e.jsx("button",{className:"find-replace-btn primary",onClick:ue,children:"Find Next"}),e.jsx("button",{className:"find-replace-btn",onClick:ut,children:"Replace"}),e.jsx("button",{className:"find-replace-btn",onClick:gt,children:"Replace All"}),e.jsx("button",{className:"find-replace-btn",onClick:()=>he(!1),children:"Close"})]})]})}),Z&&e.jsx("div",{className:"modal-overlay",onClick:()=>q(!1),children:e.jsxs("div",{className:"modal-content",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h3",{children:"Insert Image"}),e.jsx("button",{className:"modal-close",onClick:()=>q(!1),children:"×"})]}),e.jsxs("div",{className:"modal-body",children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Image URL:"}),e.jsx("input",{type:"text",placeholder:"https://example.com/image.jpg",value:_,onChange:t=>K(t.target.value),className:"form-input"}),e.jsx("button",{className:"btn-primary",onClick:st,style:{marginTop:"10px",width:"100%"},children:"Insert from URL"})]}),e.jsxs("div",{className:"form-group",style:{marginTop:"20px"},children:[e.jsx("label",{children:"Or upload from your device:"}),e.jsx("input",{type:"file",ref:Ze,onChange:it,accept:"image/*",className:"form-input",style:{padding:"8px"}})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsx("button",{className:"btn-secondary",onClick:()=>q(!1),children:"Cancel"})})]})}),e.jsx(ve,{isOpen:ee.open,onClose:()=>te(t=>({...t,open:!1})),onInsert:tt,onRemove:lt,isEditing:!!ee.isEditing,initialUrl:ee.initialUrl,initialText:ee.initialText,existingLinks:ee.existingLinks})]})};z.LinkModal=ve,z.RichTextEditor=ze,Object.defineProperty(z,Symbol.toStringTag,{value:"Module"})}));
package/dist/style.css ADDED
@@ -0,0 +1 @@
1
+ *{margin:0;padding:0;box-sizing:border-box}html,body{height:100%;overflow:hidden}:root{--toolbar-height: 64px;--toolbar-row-height: 44px;--toolbar-rows: 2;--toolbar-gap: 8px}.editor-container{width:100%;max-width:100%;margin:0;height:100vh;background:#f8f9fa;border-radius:0;box-shadow:none;overflow:hidden;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif;display:block;transition:all .3s cubic-bezier(.4,0,.2,1);position:relative;padding-top:0;padding-bottom:0}.editor-container.fullscreen{width:100vw;height:100vh;max-width:100%;margin:0;border-radius:0;z-index:9999}.editor-header,.editor-title,.editor-brand,.editor-badge,.editor-actions,.action-btn{display:none}.action-btn svg{display:none}.page-card .page-body{height:auto;overflow:visible;-webkit-overflow-scrolling:touch}.action-btn.active{display:none}.page-card .page-body img{max-width:100%;height:auto}.page-card .page-body:focus{outline:none!important;box-shadow:none!important}.page-card .page-body[contenteditable]{border:none!important;outline:none!important;box-shadow:none!important}.editor-toolbar{display:flex;gap:var(--toolbar-gap);padding:12px 24px;align-items:center;border-bottom:1px solid #e0e0e0;background:#fff;position:sticky;top:0;left:0;right:0;z-index:100;flex-wrap:wrap;flex-shrink:0;box-shadow:0 1px 3px #0000000f;max-height:calc((var(--toolbar-row-height) * var(--toolbar-rows)) + 24px);overflow:visible}.toolbar-group{display:flex;gap:4px;align-items:center;padding:0;position:relative;flex:0 1 auto}.toolbar-group:not(:last-child):after{content:"";width:1px;height:24px;background:#e0e0e0;margin-left:8px}.toolbar-btn{display:inline-flex;align-items:center;justify-content:center;min-width:32px;height:32px;padding:6px;border-radius:4px;background:transparent;color:#5f6368;cursor:pointer;transition:all .15s ease;border:none;position:relative;flex:0 0 auto}.toolbar-btn svg{width:18px;height:18px;stroke-width:2}.toolbar-btn:hover{background:#f1f3f4;color:#202124}.toolbar-btn:active{background:#e8eaed;transform:scale(.95)}.toolbar-btn.active{background:#e8f0fe;color:#1967d2}.toolbar-select{height:32px;padding:6px 28px 6px 12px;border:1px solid #dadce0;border-radius:4px;background:#fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1L6 6L11 1' stroke='%235f6368' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 8px center;background-size:12px;color:#202124;appearance:none;min-width:88px;font-weight:500;font-size:14px;cursor:pointer;transition:all .15s ease;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,sans-serif;flex:0 1 140px}.toolbar-select:hover{border-color:#5f6368;background-color:#f8f9fa}.toolbar-select:focus{outline:none;border-color:#1967d2;box-shadow:0 0 0 2px #1967d21a}.color-picker-wrapper{width:32px;height:32px;border:1px solid #d1d5db;border-radius:6px;background:#fff;position:relative;overflow:hidden;cursor:pointer;transition:all .15s ease}.color-picker-wrapper:hover{border-color:#9ca3af;box-shadow:0 2px 4px #0000000f}.toolbar-dropdown-panel{position:absolute;top:calc(100% + 4px);left:0;background:#fff;border:1px solid #d1d5db;border-radius:6px;padding:6px;box-shadow:0 4px 16px #0000001f;z-index:2000;display:flex;gap:4px;align-items:center;max-width:400px;overflow-x:auto;overflow-y:hidden}.toolbar-dropdown-panel::-webkit-scrollbar{height:6px}.toolbar-dropdown-panel::-webkit-scrollbar-track{background:#f3f4f6;border-radius:3px}.toolbar-dropdown-panel::-webkit-scrollbar-thumb{background:#d1d5db;border-radius:3px}.toolbar-dropdown-panel .toolbar-btn{min-width:32px;width:32px;height:32px;flex-shrink:0;border:1px solid #e5e7eb}.toolbar-dropdown-panel .toolbar-btn:hover{background:#f3f4f6;border-color:#3b82f6}.color-picker-wrapper input[type=color]{position:absolute;left:0;top:0;width:100%;height:100%;border:none;padding:0;cursor:pointer}.color-picker-wrapper .color-label{position:absolute;right:4px;bottom:4px;font-size:9px;color:#6b7280;pointer-events:none;font-weight:600}.color-picker-wrapper:focus-within{box-shadow:0 6px 18px #0000001f,0 0 0 4px #22c55e0f;border-color:var(--accent)}.editor-content{display:flex;justify-content:center;align-items:flex-start;position:absolute;inset:0 0 50px;padding:0 0 24px;overflow-y:auto;overflow-x:hidden;-webkit-overflow-scrolling:touch;background:transparent;color:var(--text-color);font-size:17px;line-height:1.8}.page-card{max-width:1200px;width:100%;margin:0 auto 24px;background:var(--card-bg);border-radius:0;box-shadow:0 4px 20px #00000014;padding:0;border:1px solid var(--border);border-top:none;display:flex;flex-direction:column;overflow:visible}.page-card .page-body{background:var(--editor-bg);min-height:1000px;padding:48px 80px;border-radius:0;box-shadow:none;border:none;color:#202124;overflow-wrap:break-word;word-wrap:break-word;overflow:visible;flex:1;font-size:16px;line-height:1.6;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,sans-serif}.page-card.size-a4{width:794px;min-height:1123px}.page-card.size-letter{width:816px;min-height:1056px}.page-card.size-a3{width:1122px;min-height:1587px}.page-card.size-custom{width:900px;min-height:1200px}.page-card{display:block;box-sizing:border-box}.page-card .page-body{height:auto;overflow:visible}.page-card .page-body table{width:100%;max-width:100%;table-layout:fixed;border-collapse:collapse}.page-card .page-body *{max-width:100%}.page-card .page-body th,.page-card .page-body td{white-space:normal;word-break:break-word;box-sizing:border-box}@media(max-width:1300px){.page-card.size-a3{width:calc(100% - 48px);height:auto}}@media(max-width:1000px){.page-card.size-a4,.page-card.size-letter,.page-card.size-custom{width:calc(100% - 48px);height:auto;padding:20px}.page-card{padding:16px 20px}.page-card .page-body{padding:14px}}.page-size-select{height:36px;padding:6px 10px;border-radius:8px;border:1px solid var(--border);background:#fff;color:var(--text-color);font-weight:600;margin-right:8px}.page-card .page-body h1{font-size:40px;font-weight:700;line-height:1.2;margin:24px 0 16px;color:#202124;letter-spacing:-.5px}.page-card .page-body h1 .page-card .page-body thead th{background:#0f172a88;color:#fff}.page-card .page-body h2{font-size:32px;font-weight:700;line-height:1.3;margin:20px 0 12px;color:#202124;letter-spacing:-.3px}.page-card .page-body h3{font-size:24px;font-weight:600;line-height:1.4;margin:16px 0 10px;color:#202124}.page-card .page-body h4{font-size:20px;font-weight:600;line-height:1.4;margin:14px 0 8px;color:#202124}.page-card .page-body p{margin:0 0 12px;line-height:1.6;color:#3c4043}.page-card .page-body strong,.page-card .page-body b{font-weight:700;color:#202124}.page-card .page-body em,.page-card .page-body i{font-style:italic}.page-card .page-body ul,.page-card .page-body ol{margin:12px 0;padding-left:28px}.page-card .page-body li{margin:6px 0;line-height:1.6;color:#3c4043}.editor-content:focus{outline:none;background:var(--editor-bg)}.editor-content p{margin:0 0 16px;transition:color .2s ease}.editor-content h3,.editor-content h4,.editor-content h5,.editor-content h6{color:var(--text-color);margin:24px 0 16px;font-weight:700;transition:color .2s ease}.editor-content a{color:var(--accent);text-decoration:underline}.page-card .page-body a{color:#1d4ed8;text-decoration:underline;cursor:pointer}.page-card .page-body a:hover{opacity:.92}.page-card .page-body a[contenteditable=false]{cursor:pointer}.editable-image-wrap{position:relative;display:inline-block;margin:4px;max-width:100%;vertical-align:top;width:fit-content}.editable-image-wrap.selected{outline:3px solid #3b82f6;outline-offset:2px;box-shadow:0 0 0 1px #3b82f633}.editable-image-wrap img{display:block;max-width:100%;height:auto}.image-resize-handle{position:absolute;width:12px;height:12px;background:#3b82f6;border:2px solid #fff;border-radius:50%;box-shadow:0 2px 6px #0003;z-index:20;display:none}.editable-image-wrap.selected .image-resize-handle{display:block}.image-resize-handle.nw{top:-6px;left:-6px;cursor:nw-resize}.image-resize-handle.ne{top:-6px;right:-6px;cursor:ne-resize}.image-resize-handle.sw{bottom:-6px;left:-6px;cursor:sw-resize}.image-resize-handle.se{bottom:-6px;right:-6px;cursor:se-resize}.image-resize-handle:hover{background:#2563eb;transform:scale(1.2)}.image-controls{position:absolute;bottom:-44px;left:50%;transform:translate(-50%);display:none;gap:4px;background:#fff;border:1px solid #cbd5e1;padding:6px 8px;border-radius:6px;box-shadow:0 4px 12px #00000026;z-index:100;white-space:nowrap}.editable-image-wrap.selected .image-controls{display:flex}.image-control-btn{min-width:32px;height:32px;display:inline-flex;align-items:center;justify-content:center;font-weight:600;font-size:11px;background:#fff;border:1px solid #e5e7eb;border-radius:4px;cursor:pointer;color:#374151;transition:all .15s ease;padding:0 8px}.image-control-btn:hover{background:#3b82f6;color:#fff;border-color:#3b82f6;transform:translateY(-1px);box-shadow:0 2px 6px #0000001a}.image-control-btn svg{width:14px;height:14px}.image-control-divider{width:1px;height:24px;background:#e5e7eb;margin:0 4px}.editor-content img{max-width:100%;height:auto;border-radius:6px;margin:12px 0}.editor-content hr{border:none;border-top:1px solid var(--border);margin:20px 0}.editor-content blockquote{border-left:4px solid var(--border);padding-left:12px;color:var(--muted);font-style:italic}.editor-content code{background:var(--surface-1);color:var(--text-color);padding:3px 6px;border-radius:4px;font-family:Monaco,Menlo,monospace}.editor-content table{border-collapse:collapse;width:100%;margin:16px 0;background:var(--editor-bg);border-radius:0;overflow:visible;box-shadow:none;position:relative}.editor-content table th{background:#f8f9fa;color:var(--text-color);font-weight:700;text-align:left;padding:12px 16px;border:1px solid #cbd5e1;font-size:14px}.editor-content table td{padding:12px 16px;border:1px solid #cbd5e1;color:var(--text-color);background:#fff;font-size:14px}.editor-content table tr:hover td{background:#fefce8}.editable-table-wrap{position:relative;margin:20px 0;display:inline-block;min-width:200px}.editable-table-wrap.selected{outline:3px solid #fbbf24;outline-offset:2px;box-shadow:0 0 0 1px #fbbf2433}.table-resize-handle{position:absolute;width:14px;height:14px;background:#fbbf24;border:2px solid #fff;border-radius:50%;box-shadow:0 2px 6px #0003;cursor:nwse-resize;z-index:20;display:none}.editable-table-wrap.selected .table-resize-handle{display:block}.table-resize-handle.nw{top:-7px;left:-7px;cursor:nw-resize}.table-resize-handle.ne{top:-7px;right:-7px;cursor:ne-resize}.table-resize-handle.sw{bottom:-7px;left:-7px;cursor:sw-resize}.table-resize-handle.se{bottom:-7px;right:-7px;cursor:se-resize}.table-resize-handle:hover{background:#f59e0b;transform:scale(1.2)}.table-controls{position:absolute;top:-48px;left:0;display:none;gap:4px;background:#fff;border:1px solid #cbd5e1;padding:6px;border-radius:6px;box-shadow:0 4px 12px #0000001a;z-index:100}.editable-table-wrap.selected .table-controls{display:flex}.table-control-btn{min-width:32px;height:32px;display:inline-flex;align-items:center;justify-content:center;font-weight:600;font-size:11px;background:#fff;border:1px solid #e5e7eb;border-radius:4px;cursor:pointer;color:#374151;transition:all .15s ease}.table-control-btn:hover{background:#fbbf24;color:#fff;border-color:#fbbf24;transform:translateY(-1px);box-shadow:0 2px 6px #0000001a}.editor-content pre{background:#0b0b0b;color:#f7f7f7;padding:16px;border-radius:8px;overflow-x:auto;margin:16px 0}.editor-content pre code{background:none;color:inherit;padding:0;font-family:Monaco,Menlo,monospace}.editor-footer,.status-bar,.status-item{display:none}.status-bar-bottom{position:fixed;bottom:0;left:50%;transform:translate(-50%);background:#fffffff2;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);padding:8px 24px;border-radius:20px 20px 0 0;box-shadow:0 -2px 10px #00000014;display:flex;gap:12px;align-items:center;z-index:1000;font-size:13px;color:#64748b;font-weight:500;border:1px solid #e5e7eb;border-bottom:none}.status-bar-bottom .status-item{display:inline;white-space:nowrap;padding:0;background:none;border:none}.status-item:hover{transform:translateY(-2px);box-shadow:0 4px 8px #0000000f}.editor-content::-webkit-scrollbar,.modal-body::-webkit-scrollbar{width:12px}.editor-content::-webkit-scrollbar-track,.modal-body::-webkit-scrollbar-track{background:#f3f4f6;border-radius:6px}.editor-content::-webkit-scrollbar-thumb,.modal-body::-webkit-scrollbar-thumb{background:#9aa3ad;border-radius:6px;border:2px solid #f3f4f6}.modal-overlay,.link-modal-overlay{position:fixed;inset:0;background:#00000080;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px);display:flex;align-items:center;justify-content:center;z-index:10000;animation:rte-fadeIn .18s ease}@keyframes rte-fadeIn{0%{opacity:0}to{opacity:1}}.modal-content{background:var(--card-bg);border-radius:12px;box-shadow:0 25px 50px -12px #00000040;width:90%;max-width:680px;max-height:90vh;overflow:hidden;display:flex;flex-direction:column;animation:rte-slideUp .28s ease}@keyframes rte-slideUp{0%{transform:translateY(12px);opacity:0}to{transform:translateY(0);opacity:1}}.modal-header{display:flex;justify-content:space-between;align-items:center;padding:18px 20px;background:var(--header-bg);color:#fff}.modal-header h3{margin:0;font-size:18px;font-weight:600}.modal-close{background:#ffffff0f;border:1px solid rgba(255,255,255,.08);color:#fff;width:36px;height:36px;border-radius:8px;display:flex;align-items:center;justify-content:center;cursor:pointer}.modal-close:hover{background:#ffffff1f;transform:rotate(90deg)}.modal-body{padding:20px;overflow-y:auto;flex:1}.modal-footer{display:flex;justify-content:flex-end;gap:12px;padding:16px 20px;background:var(--surface-1);border-top:1px solid var(--border)}.form-group{margin-bottom:16px}.form-group label{display:block;margin-bottom:8px;font-weight:600;color:var(--muted);font-size:14px}.form-input{width:100%;padding:10px 12px;border:1px solid var(--border);border-radius:8px;font-size:15px;font-family:inherit}.form-input:focus{outline:none;box-shadow:0 0 0 4px #0000000a;border-color:var(--border)}.btn-primary{padding:10px 20px;background:var(--inverse-bg);color:#fff;border:none;border-radius:8px;font-weight:600;cursor:pointer}.btn-primary:hover{transform:translateY(-2px);box-shadow:0 6px 12px #00000014}.btn-secondary{padding:10px 20px;background:var(--editor-bg);color:var(--text-color);border:1px solid var(--border);border-radius:8px;cursor:pointer}.html-preview{background:#0b0b0b;color:#f7f7f7;padding:16px;border-radius:8px;overflow-x:auto;font-size:13px;font-family:Monaco,Menlo,monospace;white-space:pre-wrap;word-break:break-all}.editor-content::selection{background:#11182714;color:var(--text-color)}.table-size-picker{position:absolute;top:calc(100% + 4px);left:0;background:#fff;border:1px solid #d1d5db;border-radius:8px;padding:12px;box-shadow:0 10px 25px #0000001a,0 4px 8px #0000000f;z-index:2000;display:none}.table-size-picker.show{display:block}.table-size-grid{display:grid;gap:2px;cursor:pointer}.table-drag-handle{width:18px;height:18px;border-radius:4px;background:#0000000f;position:absolute;top:8px;left:8px;display:flex;align-items:center;justify-content:center;cursor:grab;z-index:1500}.table-drag-handle:active{cursor:grabbing}.table-context-menu{position:absolute;right:8px;top:36px;background:#fff;border:1px solid #d1d5db;border-radius:8px;padding:8px;box-shadow:0 8px 30px #0000001f;display:flex;flex-direction:column;gap:6px;min-width:160px;z-index:2000}.table-context-menu button{background:transparent;border:none;text-align:left;padding:8px 10px;border-radius:6px;cursor:pointer}.table-context-menu button:hover{background:#f3f4f6}.table-context-menu hr{border:none;height:1px;background:#eef2f7;margin:6px 0}.table-cell-preview{width:18px;height:18px;border:1px solid #d1d5db;background:#fff;transition:all .1s;border-radius:2px}.table-cell-preview.hover{background:#3b82f6;border-color:#2563eb}.table-size-label{text-align:center;margin-top:8px;font-size:12px;color:#6b7280;font-weight:600}.page-card .page-body td.selected-cell,.page-card .page-body th.selected-cell{outline:2px solid rgba(59,130,246,.9);background:#3b82f60f}.find-replace-modal{background:#fff;padding:24px;border-radius:12px;box-shadow:0 20px 50px #00000026;max-width:450px;width:90%}.find-replace-modal h3{margin:0 0 20px;font-size:18px;color:#1e293b;font-weight:700}.find-replace-group{margin-bottom:16px}.find-replace-group label{display:block;margin-bottom:6px;font-size:13px;color:#475569;font-weight:600}.find-replace-input{width:100%;padding:8px 12px;border:1px solid #cbd5e1;border-radius:6px;font-size:14px;transition:all .15s ease}.find-replace-input:focus{outline:none;border-color:#3b82f6;box-shadow:0 0 0 3px #3b82f61a}.find-replace-buttons{display:flex;gap:8px;margin-top:20px;flex-wrap:wrap}.find-replace-btn{padding:8px 16px;border-radius:6px;font-size:13px;font-weight:600;cursor:pointer;border:1px solid #cbd5e1;background:#fff;color:#374151;transition:all .15s}.find-replace-btn:hover{background:#f8fafc;border-color:#94a3b8}.find-replace-btn.primary{background:#3b82f6;color:#fff;border-color:#3b82f6}.find-replace-btn.primary:hover{background:#2563eb;border-color:#2563eb}.find-replace-status{margin-top:12px;font-size:13px;color:#64748b;min-height:18px;font-weight:500}.editor-content::-moz-selection{background:#11182714;color:var(--text-color)}@keyframes editorFadeIn{0%{opacity:0}to{opacity:1}}@keyframes slideDown{0%{transform:translateY(-20px);opacity:0}to{transform:translateY(0);opacity:1}}@keyframes slideUp{0%{transform:translateY(20px);opacity:0}to{transform:translateY(0);opacity:1}}@keyframes fadeInLeft{0%{transform:translate(-20px);opacity:0}to{transform:translate(0);opacity:1}}@keyframes fadeInRight{0%{transform:translate(20px);opacity:0}to{transform:translate(0);opacity:1}}@keyframes fadeInUp{0%{transform:translateY(30px);opacity:0}to{transform:translateY(0);opacity:1}}@keyframes pulse{0%,to{opacity:.5}50%{opacity:.8}}@media(max-width:1024px){.editor-content{padding:40px 60px}.editor-header,.editor-toolbar,.editor-footer{padding-left:24px;padding-right:24px}}@media(max-width:768px){.editor-container{margin:0}.editor-header{flex-direction:column;gap:12px;align-items:flex-start;padding:16px 20px}.editor-title{font-size:18px}.action-btn span{display:none}.action-btn{padding:8px;min-width:40px}.editor-toolbar{padding:12px 20px;top:auto;position:relative}.toolbar-group{padding:2px}.toolbar-btn{width:38px;height:38px}.toolbar-select{min-width:110px;height:38px;font-size:13px}.color-picker-wrapper{width:38px;height:38px}.editor-content{padding:24px 20px;min-height:400px;font-size:16px}.editor-footer{padding:12px 20px;position:relative}.modal-content{width:95%;max-width:620px}}@media print{.editor-header,.editor-toolbar,.editor-footer{display:none}.editor-container{box-shadow:none;border:none}.editor-content{max-height:none}}
package/dist/vite.svg ADDED
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
package/package.json ADDED
@@ -0,0 +1,66 @@
1
+ {
2
+ "name": "@daneshnaik/rich-text-editor",
3
+ "version": "1.0.0",
4
+ "description": "A powerful and feature-rich WYSIWYG rich text editor for React with table editing, image handling, and extensive formatting options",
5
+ "type": "module",
6
+ "main": "./dist/rich-text-editor.umd.cjs",
7
+ "module": "./dist/rich-text-editor.js",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/rich-text-editor.js",
11
+ "require": "./dist/rich-text-editor.umd.cjs"
12
+ },
13
+ "./dist/style.css": "./dist/style.css"
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "README.md",
18
+ "LICENSE"
19
+ ],
20
+ "scripts": {
21
+ "dev": "vite",
22
+ "build": "vite build",
23
+ "lint": "eslint .",
24
+ "preview": "vite preview",
25
+ "prepublishOnly": "npm run build"
26
+ },
27
+ "keywords": [
28
+ "react",
29
+ "rich-text-editor",
30
+ "wysiwyg",
31
+ "editor",
32
+ "text-editor",
33
+ "contenteditable",
34
+ "react-component",
35
+ "formatting",
36
+ "table-editor",
37
+ "image-editor"
38
+ ],
39
+ "author": "Danesh Naik",
40
+ "license": "MIT",
41
+ "repository": {
42
+ "type": "git",
43
+ "url": "https://github.com/danu20002/extmaneditor.git"
44
+ },
45
+ "bugs": {
46
+ "url": "https://github.com/danu20002/extmaneditor/issues"
47
+ },
48
+ "homepage": "https://github.com/danu20002/extmaneditor#readme",
49
+ "peerDependencies": {
50
+ "react": "^18.0.0 || ^19.0.0",
51
+ "react-dom": "^18.0.0 || ^19.0.0"
52
+ },
53
+ "devDependencies": {
54
+ "@eslint/js": "^9.39.1",
55
+ "@types/react": "^19.2.5",
56
+ "@types/react-dom": "^19.2.3",
57
+ "@vitejs/plugin-react": "^5.1.1",
58
+ "eslint": "^9.39.1",
59
+ "eslint-plugin-react-hooks": "^7.0.1",
60
+ "eslint-plugin-react-refresh": "^0.4.24",
61
+ "globals": "^16.5.0",
62
+ "react": "^19.2.0",
63
+ "react-dom": "^19.2.0",
64
+ "vite": "^7.2.4"
65
+ }
66
+ }