@daneshnaik/rich-text-editor 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -0
- package/dist/rich-text-editor.js +1031 -977
- package/dist/rich-text-editor.umd.cjs +2 -2
- package/dist/style.css +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
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:J,onClose:j,onInsert:Y,onRemove:le,isEditing:ie=!1,initialUrl:V="",initialText:Z="",existingLinks:q=[]})=>{const[X,G]=v.useState(V),[R,K]=v.useState(Z);return v.useEffect(()=>{J&&(G(V||""),K(Z||""))},[J,V,Z]),J?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:X,onChange:N=>G(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=>K(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:()=>{G(N.href),K(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&&le&&e.jsx("button",{className:"btn-secondary",onClick:()=>{le(),j()},style:{marginRight:8},children:"Remove Link"}),e.jsx("button",{className:"btn-primary",onClick:()=>{Y({url:X||"",text:R||X||""})},children:"Insert"})]})]})}):null},ze=()=>{const[J,j]=v.useState(""),[Y,le]=v.useState(!1),[ie,V]=v.useState(!1),[Z,q]=v.useState(!1),[X,G]=v.useState(""),[R,K]=v.useState(!1),[N,de]=v.useState({rows:1,cols:1}),[je,he]=v.useState(!1),[Oe,D]=v.useState(!1),[_,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 o=window.getSelection(),l=o&&o.anchorNode?o.anchorNode.nodeType===3?o.anchorNode.parentElement:o.anchorNode:null;let r="";try{r=document.queryCommandValue&&document.queryCommandValue("fontName")||""}catch{r=""}!r&&l&&(r=(window.getComputedStyle(l).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&&l){const h=parseFloat(window.getComputedStyle(l).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&&l){let h=l;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,o=null)=>{try{document.execCommand(t,!1,o)}catch(l){console.error("execCommand failed:",l)}},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 l=window.getSelection();if(l&&l.rangeCount>0){const r=l.getRangeAt(0);if(u.current&&u.current.contains(r.commonAncestorContainer)){F.current=r,l.isCollapsed||(t=l.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 o=[];try{const l=u.current;l&&l.querySelectorAll("a").forEach(a=>o.push({href:a.getAttribute("href"),text:a.innerText}))}catch{}k.current?te({open:!0,initialUrl:k.current.getAttribute("href")||"",initialText:k.current.innerText||"",existingLinks:o,isEditing:!0}):te({open:!0,initialUrl:"",initialText:t,existingLinks:o,isEditing:!1})},tt=({url:t,text:o})=>{if(te(l=>({...l,open:!1})),!t){F.current=null,k.current=null;return}try{const l=window.getSelection();l.removeAllRanges(),F.current&&l.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=o||t}catch{const l=a=>String(a).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,"""),r=`<a href="${l(t)}" target="_blank" rel="noopener noreferrer" contenteditable="false">${l(o||t)}</a>`;y("insertHTML",r)}else if(u.current){u.current.focus();const l=a=>String(a).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,"""),r=`<a href="${l(t)}" target="_blank" rel="noopener noreferrer" contenteditable="false">${l(o||t)}</a>`;y("insertHTML",r)}}catch{try{y("createLink",t)}catch{}}F.current=null,k.current=null},ot=()=>{if(!k.current)return;const t=k.current,o=t.innerText||t.getAttribute("href")||"",l=document.createTextNode(o);t.parentNode.replaceChild(l,t),k.current=null,te(r=>({...r,open:!1}))},lt=t=>{y("foreColor",t.target.value)},nt=t=>{y("hiliteColor",t.target.value)},rt=t=>{const o=t&&t.target?t.target.value:t;y("fontSize",o),Se(String(o))},at=t=>{const o=t&&t.target?t.target.value:t;y("fontName",o),Ne(String(o))},ct=()=>{q(!0)},st=()=>{X&&(Te(X),G(""),q(!1))},it=t=>{const o=t.target.files?.[0];if(o&&o.type.startsWith("image/")){const l=new FileReader;l.onload=r=>{const a=r.target?.result;Te(a),q(!1)},l.readAsDataURL(o)}},Te=t=>{if(!u.current)return;u.current.focus();const o=document.createElement("div");o.className="editable-image-wrap",o.contentEditable="false";const l=document.createElement("img");l.src=t,l.alt="Image",l.style.maxWidth="100%",l.style.height="auto",o.appendChild(l);try{const r=window.getSelection();if(r&&r.rangeCount>0){const a=r.getRangeAt(0);a.deleteContents(),a.insertNode(o),a.setStartAfter(o),a.collapse(!0),r.removeAllRanges(),r.addRange(a)}else u.current.appendChild(o)}catch{u.current.appendChild(o)}setTimeout(()=>Me(o),50)},Me=t=>{if(!t||t.dataset.enhanced)return;const o=t.querySelector("img");if(!o)return;const l=h=>{h.stopPropagation();try{u.current?.querySelectorAll(".editable-image-wrap")?.forEach(S=>S.classList.remove("selected"))}catch{}t.classList.add("selected")};t.addEventListener("click",l);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","⇤",()=>{t.style.display="block",t.style.marginLeft="0",t.style.marginRight="auto"})),r.appendChild(a("Center","≡",()=>{t.style.display="block",t.style.marginLeft="auto",t.style.marginRight="auto"})),r.appendChild(a("Align Right","⇥",()=>{t.style.display="block",t.style.marginLeft="auto",t.style.marginRight="0"})),r.appendChild(d()),r.appendChild(a("Original Size","1:1",()=>{o.style.width="",o.style.height="",o.style.maxWidth="100%"})),r.appendChild(a("50% Width","50%",()=>{o.style.width="50%",o.style.height="auto"})),r.appendChild(a("75% Width","75%",()=>{o.style.width="75%",o.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,o,h)}),t.appendChild(C)}),t.dataset.enhanced="1"},dt=(t,o,l)=>{const r=t.clientX,a=o.offsetWidth,d=o.offsetHeight,h=a/d,C=E=>{const U=E.clientX-r;let A=a;l.includes("e")?A=Math.max(50,a+U):l.includes("w")&&(A=Math.max(50,a-U));const Q=A/h;o.style.width=A+"px",o.style.height=Q+"px",o.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 o=l=>{try{const r=l.target.closest&&l.target.closest("a");if(r&&r.getAttribute("href")){const a=r.getAttribute("href");if(l.metaKey||l.ctrlKey||l.shiftKey)return;l.preventDefault(),window.open(a,"_blank")}}catch{}};return t.addEventListener("click",o),()=>t.removeEventListener("click",o)},[]);const ht=t=>{y("formatBlock",t),fe(t)},Ee=(t,o)=>{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 l=typeof t=="number"?t:me,r=typeof o=="number"?o: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<l;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,o)=>{de({rows:t+1,cols:o+1})},ft=(t,o)=>{Ee(t+1,o+1),K(!1)},ue=()=>{if(!_||!u.current){B("Enter text to find");return}try{const t=window.find(_,!1,!1,!1,!1,!0,!1);B(t?"Found":"No matches found")}catch{B("Search not available in this browser")}},ut=()=>{if(!_||!u.current){B("Enter text to find");return}try{const t=window.getSelection();if(t&&t.toString().toLowerCase()===_.toLowerCase()){const o=t.getRangeAt(0);o.deleteContents(),o.insertNode(document.createTextNode(pe)),B("Replaced 1 occurrence"),setTimeout(()=>ue(),100)}else ue()}catch{B("Replace failed")}},gt=()=>{if(!_||!u.current){B("Enter text to find");return}try{let t=0;const o=u.current.textContent||"",l=new RegExp(_.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"gi"),r=o.match(l);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();)l.test(h.nodeValue)&&d.push(h);d.forEach(C=>{const S=C.nodeValue.replace(l,pe),E=(C.nodeValue.match(l)||[]).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 o=document.createElement("div");o.className="editable-table-wrap",t.parentNode.insertBefore(o,t),o.appendChild(t);const l=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{}o.classList.add("selected"),l(n)};t.addEventListener("click",r);try{t.querySelectorAll("td,th").forEach(i=>i.addEventListener("click",l))}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},Q=(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)}Q(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{}})),o.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,o,t,n)}),o.appendChild(i)});const re=document.createElement("div");re.className="table-drag-handle",re.title="Drag to move table",o.appendChild(re);const P=document.createElement("div");P.className="table-context-menu",P.innerHTML=`
|
|
1
|
+
(function($,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):($=typeof globalThis<"u"?globalThis:$||self,e($.RichTextEditor={},$["react/jsx-runtime"],$.React))})(this,(function($,e,y){"use strict";const be=({isOpen:Q,onClose:G,onInsert:oe,onRemove:J,isEditing:he=!1,initialUrl:_="",initialText:Z="",existingLinks:D=[]})=>{const[O,R]=y.useState(_),[ne,j]=y.useState(Z);return y.useEffect(()=>{Q&&(R(_||""),j(Z||""))},[Q,_,Z]),Q?e.jsx("div",{className:"modal-overlay",onClick:G,children:e.jsxs("div",{className:"modal-content",onClick:E=>E.stopPropagation(),children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h3",{children:"Insert Link"}),e.jsx("button",{className:"modal-close",onClick:G,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:O,onChange:E=>R(E.target.value)})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Display text:"}),e.jsx("input",{type:"text",className:"form-input",value:ne,onChange:E=>j(E.target.value)})]}),D&&D.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:D.map((E,V)=>e.jsxs("li",{style:{display:"flex",gap:8,alignItems:"center",marginBottom:6},children:[e.jsx("a",{href:E.href,target:"_blank",rel:"noreferrer",children:E.text||E.href}),e.jsx("button",{type:"button",className:"toolbar-btn",onClick:()=>{R(E.href),j(E.text||E.href)},style:{marginLeft:"auto"},children:"Use"})]},V))})]})]}),e.jsxs("div",{className:"modal-footer",children:[e.jsx("button",{className:"btn-secondary",onClick:G,children:"Cancel"}),he&&J&&e.jsx("button",{className:"btn-secondary",onClick:()=>{J(),G()},style:{marginRight:8},children:"Remove Link"}),e.jsx("button",{className:"btn-primary",onClick:()=>{oe({url:O||"",text:ne||O||""})},children:"Insert"})]})]})}):null},Xe=({width:Q=null,height:G=null,fullBleed:oe=!0,onComponentDrop:J=null})=>{const[he,_]=y.useState(!1),[Z,D]=y.useState(""),[O,R]=y.useState(!1),[ne,j]=y.useState(!1),[E,V]=y.useState(!1),[pe,Ce]=y.useState(""),[xe,we]=y.useState(!1),[re,_e]=y.useState({rows:1,cols:1}),[Ye,fe]=y.useState(!1),[Ge,X]=y.useState(!1),[Y,Ke]=y.useState(""),[ue,Qe]=y.useState(""),[ke,B]=y.useState(""),[Je,ae]=y.useState(!1),[Ne,Se]=y.useState(3),[Le,Te]=y.useState(3),[Me,Ze]=y.useState("a4"),[z,Re]=y.useState({bold:!1,italic:!1,underline:!1,strikeThrough:!1,justifyLeft:!1,justifyCenter:!1,justifyRight:!1,insertUnorderedList:!1,insertOrderedList:!1}),Ee=()=>{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")};Re(t);try{const l=window.getSelection(),o=l&&l.anchorNode?l.anchorNode.nodeType===3?l.anchorNode.parentElement:l.anchorNode:null;let n="";try{n=document.queryCommandValue&&document.queryCommandValue("fontName")||""}catch{n=""}!n&&o&&(n=(window.getComputedStyle(o).fontFamily||"").split(",")[0].replace(/["']/g,"").trim()),n&&(n=String(n).replace(/^[<>"']+|[<>"']+$/g,"").split(",")[0].trim(),Ae(n),ot(h=>h.includes(n)?h:[n,...h]));let r="";try{r=document.queryCommandValue("fontSize")||""}catch{r=""}if(!r&&o){const h=parseFloat(window.getComputedStyle(o).fontSize||"16");h<12?r="1":h<16?r="2":h<18?r="3":h<22?r="4":h<26?r="5":h<32?r="6":r="7"}r&&He(String(r));let d="";try{d=document.queryCommandValue&&document.queryCommandValue("formatBlock")||""}catch{d=""}if(!d&&o){let h=o;for(;h&&h!==f.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"),ge(d))}catch{}}catch{}},[et,Ae]=y.useState("Arial"),[tt,He]=y.useState("3"),[lt,ge]=y.useState("p"),[Ot,ot]=y.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"]),f=y.useRef(null),Ie=y.useRef(null),q=y.useRef(null),k=y.useRef(null),T=y.useRef(null),nt=y.useRef(null),v=(t,l=null)=>{try{document.execCommand(t,!1,l)}catch(o){console.error("execCommand failed:",o)}},rt=()=>{f.current&&(D(f.current.innerHTML),Ee())},at=t=>{t.preventDefault(),t.dataTransfer.dropEffect="copy",_(!0)},ct=t=>{_(!1)},st=async t=>{t.preventDefault(),_(!1);const l=t.dataTransfer,o={html:null,text:null,files:[],types:Array.from(l.types||[])};try{if(l.files&&l.files.length>0)for(let n=0;n<l.files.length;n++)o.files.push(l.files[n]);try{o.html=l.getData("text/html")||null}catch{o.html=null}try{o.text=l.getData("text/plain")||null}catch{o.text=null}}catch{}try{if(o.html?f.current&&(f.current.focus(),v("insertHTML",o.html)):o.text&&f.current&&(f.current.focus(),v("insertText",o.text)),o.files.length>0){for(const n of o.files)if(n.type&&n.type.startsWith("image/")){const r=new FileReader;r.onload=d=>ye(d.target.result),r.readAsDataURL(n)}}}catch{}try{typeof J=="function"&&J(o,t)}catch{}};y.useEffect(()=>{const t=()=>{(document.activeElement===f.current||f.current?.contains(document.activeElement))&&Ee()};return document.addEventListener("selectionchange",t),()=>document.removeEventListener("selectionchange",t)},[]);const[ee,te]=y.useState({open:!1,initialUrl:"",initialText:"",existingLinks:[]}),it=()=>{let t="";try{const o=window.getSelection();if(o&&o.rangeCount>0){const n=o.getRangeAt(0);if(f.current&&f.current.contains(n.commonAncestorContainer)){q.current=n,o.isCollapsed||(t=o.toString().trim());try{const r=n.commonAncestorContainer.nodeType===3?n.commonAncestorContainer.parentElement:n.commonAncestorContainer,d=r&&r.closest?r.closest("a"):null;d&&f.current.contains(d)?k.current=d:k.current=null}catch{k.current=null}}else q.current=null,k.current=null}}catch{q.current=null,k.current=null}const l=[];try{const o=f.current;o&&o.querySelectorAll("a").forEach(r=>l.push({href:r.getAttribute("href"),text:r.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})},dt=({url:t,text:l})=>{if(te(o=>({...o,open:!1})),!t){q.current=null,k.current=null;return}try{const o=window.getSelection();o.removeAllRanges(),q.current&&o.addRange(q.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=r=>String(r).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,"""),n=`<a href="${o(t)}" target="_blank" rel="noopener noreferrer" contenteditable="false">${o(l||t)}</a>`;v("insertHTML",n)}else if(f.current){f.current.focus();const o=r=>String(r).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,"""),n=`<a href="${o(t)}" target="_blank" rel="noopener noreferrer" contenteditable="false">${o(l||t)}</a>`;v("insertHTML",n)}}catch{try{v("createLink",t)}catch{}}q.current=null,k.current=null},ht=()=>{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(n=>({...n,open:!1}))},pt=t=>{v("foreColor",t.target.value)},ft=t=>{v("hiliteColor",t.target.value)},ut=t=>{const l=t&&t.target?t.target.value:t;v("fontSize",l),He(String(l))},gt=t=>{const l=t&&t.target?t.target.value:t;v("fontName",l),Ae(String(l))},yt=()=>{V(!0)},vt=()=>{pe&&(ye(pe),Ce(""),V(!1))},mt=t=>{const l=t.target.files?.[0];if(l&&l.type.startsWith("image/")){const o=new FileReader;o.onload=n=>{const r=n.target?.result;ye(r),V(!1)},o.readAsDataURL(l)}},ye=t=>{if(!f.current)return;f.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 n=window.getSelection();if(n&&n.rangeCount>0){const r=n.getRangeAt(0);r.deleteContents(),r.insertNode(l),r.setStartAfter(l),r.collapse(!0),n.removeAllRanges(),n.addRange(r)}else f.current.appendChild(l)}catch{f.current.appendChild(l)}setTimeout(()=>Be(l),50)},Be=t=>{if(!t||t.dataset.enhanced)return;const l=t.querySelector("img");if(!l)return;const o=h=>{h.stopPropagation();try{f.current?.querySelectorAll(".editable-image-wrap")?.forEach(N=>N.classList.remove("selected"))}catch{}t.classList.add("selected")};t.addEventListener("click",o);const n=document.createElement("div");n.className="image-controls";const r=(h,C,N)=>{const M=document.createElement("button");return M.type="button",M.className="image-control-btn",M.title=h,M.innerHTML=C,M.addEventListener("click",F=>{F.stopPropagation(),N()}),M},d=()=>{const h=document.createElement("div");return h.className="image-control-divider",h};n.appendChild(r("Align Left","⇤",()=>{t.style.display="block",t.style.marginLeft="0",t.style.marginRight="auto"})),n.appendChild(r("Center","≡",()=>{t.style.display="block",t.style.marginLeft="auto",t.style.marginRight="auto"})),n.appendChild(r("Align Right","⇥",()=>{t.style.display="block",t.style.marginLeft="auto",t.style.marginRight="0"})),n.appendChild(d()),n.appendChild(r("Original Size","1:1",()=>{l.style.width="",l.style.height="",l.style.maxWidth="100%"})),n.appendChild(r("50% Width","50%",()=>{l.style.width="50%",l.style.height="auto"})),n.appendChild(r("75% Width","75%",()=>{l.style.width="75%",l.style.height="auto"})),n.appendChild(d()),n.appendChild(r("Delete Image","×",()=>{confirm("Delete this image?")&&t.remove()})),t.appendChild(n),["nw","ne","sw","se"].forEach(h=>{const C=document.createElement("div");C.className=`image-resize-handle ${h}`,C.addEventListener("mousedown",N=>{N.preventDefault(),N.stopPropagation(),bt(N,l,h)}),t.appendChild(C)}),t.dataset.enhanced="1"},bt=(t,l,o)=>{const n=t.clientX,r=l.offsetWidth,d=l.offsetHeight,h=r/d,C=M=>{const F=M.clientX-n;let A=r;o.includes("e")?A=Math.max(50,r+F):o.includes("w")&&(A=Math.max(50,r-F));const K=A/h;l.style.width=A+"px",l.style.height=K+"px",l.style.maxWidth="none"},N=()=>{document.removeEventListener("mousemove",C),document.removeEventListener("mouseup",N),document.body.style.cursor=""};document.addEventListener("mousemove",C),document.addEventListener("mouseup",N)};y.useEffect(()=>{const t=f.current;if(!t)return;const l=o=>{try{const n=o.target.closest&&o.target.closest("a");if(n&&n.getAttribute("href")){const r=n.getAttribute("href");if(o.metaKey||o.ctrlKey||o.shiftKey)return;o.preventDefault(),window.open(r,"_blank")}}catch{}};return t.addEventListener("click",l),()=>t.removeEventListener("click",l)},[]);const Ct=t=>{v("formatBlock",t),ge(t)},We=(t,l)=>{try{const d=window.getSelection();if(d.removeAllRanges(),q.current)d.addRange(q.current);else if(f.current){f.current.focus();const h=document.createRange();h.selectNodeContents(f.current),h.collapse(!1),d.removeAllRanges(),d.addRange(h)}}catch{}const o=typeof t=="number"?t:Ne,n=typeof l=="number"?l:Le;let r='<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse; width: auto; margin: 16px 0;">';r+="<thead><tr>";for(let d=0;d<n;d++)r+=`<th style="border: 1px solid #cbd5e1; padding: 12px 16px; background: #f8f9fa; text-align: left; font-weight: 700;">Header ${d+1}</th>`;r+="</tr></thead>",r+="<tbody>";for(let d=0;d<o;d++){r+="<tr>";for(let h=0;h<n;h++)r+=`<td style="border: 1px solid #cbd5e1; padding: 12px 16px; background: #fff;">Cell ${d+1}-${h+1}</td>`;r+="</tr>"}r+="</tbody></table>",v("insertHTML",r),setTimeout(()=>{try{const d=f.current;if(!d)return;const h=d.querySelector("table:last-of-type");h&&qe(h)}catch{}},20),ae(!1),Se(3),Te(3)},xt=(t,l)=>{_e({rows:t+1,cols:l+1})},wt=(t,l)=>{We(t+1,l+1),we(!1)},ve=()=>{if(!Y||!f.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")}},kt=()=>{if(!Y||!f.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(ue)),B("Replaced 1 occurrence"),setTimeout(()=>ve(),100)}else ve()}catch{B("Replace failed")}},Nt=()=>{if(!Y||!f.current){B("Enter text to find");return}try{let t=0;const l=f.current.textContent||"",o=new RegExp(Y.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"gi"),n=l.match(o);if(!n||n.length===0){B("No matches found");return}const r=document.createTreeWalker(f.current,NodeFilter.SHOW_TEXT,null,!1),d=[];let h;for(;h=r.nextNode();)o.test(h.nodeValue)&&d.push(h);d.forEach(C=>{const N=C.nodeValue.replace(o,ue),M=(C.nodeValue.match(o)||[]).length;t+=M,C.nodeValue=N}),D(f.current.innerHTML),B(`Replaced ${t} occurrence(s)`)}catch{B("Replace all failed")}},qe=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=a=>{const i=a.target.closest("td,th");if(i){if(a.shiftKey&&T.current&&T.current!==i){try{f.current.querySelectorAll(".selected-cell").forEach(s=>s.classList.remove("selected-cell"))}catch{}Dt(T.current,i,t),T.current=i;return}try{f.current.querySelectorAll(".selected-cell").forEach(s=>s.classList.remove("selected-cell"))}catch{}i.classList.add("selected-cell"),T.current=i}},n=a=>{try{f.current?.querySelectorAll(".editable-table-wrap")?.forEach(c=>c.classList.remove("selected"))}catch{}l.classList.add("selected"),o(a)};t.addEventListener("click",n);try{t.querySelectorAll("td,th").forEach(i=>i.addEventListener("click",o))}catch{}const r=document.createElement("div");r.className="table-controls";const d=(a,i,c)=>{const s=document.createElement("button");return s.type="button",s.className="table-control-btn",s.title=a,s.innerHTML=i,s.addEventListener("click",p=>{p.stopPropagation(),c(t)}),s};r.appendChild(d("Add Row Below","+R",a=>Fe(a))),r.appendChild(d("Add Column Right","+C",a=>Ue(a))),r.appendChild(d("Delete Row","-R",a=>Lt(a))),r.appendChild(d("Delete Column","-C",a=>Tt(a))),r.appendChild(d("Delete Table","×",a=>Pe(a)));const h=document.createElement("input");h.type="color",h.style.display="none",h.addEventListener("input",a=>{try{const i=a.target.value;T.current&&(T.current.style.background=i)}catch{}});const C=document.createElement("input");C.type="color",C.style.display="none",C.addEventListener("input",a=>{try{const i=a.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=M(i)})}catch{}});const N=()=>{try{const a=t.querySelector("thead");(a?Array.from(a.querySelectorAll("th")):t.rows[0]?Array.from(t.rows[0].cells):[]).forEach(c=>{c.style.background="",c.style.color=""})}catch{}},M=a=>{if(!a)return"#000";const i=a.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"},F=a=>{const i=[];for(let c=0;c<a.rows.length;c++){const s=a.rows[c];i[c]=i[c]||[];let p=0;for(let u=0;u<s.cells.length;u++){const g=s.cells[u];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=(a,i)=>{const c=F(a);for(let s=0;s<c.length;s++){const p=c[s]||[];for(let u=0;u<p.length;u++)if(p[u]===i)return{r:s,c:u,matrix:c}}return null},K=(a,i)=>{const c=F(a);let s=1/0,p=1/0,u=-1/0,g=-1/0;const x=new Set(i);for(let L=0;L<c.length;L++)for(let H=0;H<(c[L]||[]).length;H++){const P=c[L][H];!P||!x.has(P)||(s=Math.min(s,L),p=Math.min(p,H),u=Math.max(u,L),g=Math.max(g,H))}if(s===1/0)return;const m=c[s][p],w=new Set;let b="";for(let L=s;L<=u;L++)for(let H=p;H<=g;H++){const P=c[L][H];P&&(P!==m&&w.add(P),b.includes(P.innerHTML)||(b+=(b?"<br/>":"")+P.innerHTML))}const S=u-s+1,W=g-p+1;try{m.rowSpan=S,m.colSpan=W,m.innerHTML=b}catch{}w.forEach(L=>{try{L.remove()}catch{}});try{m.classList.add("selected-cell"),T.current=m}catch{}},I=(a,i,c)=>{const s=A(c,a);if(!s)return;const{r:p,c:u,matrix:g}=s,x=parseInt(a.getAttribute("rowspan")||a.rowSpan||1,10),m=parseInt(a.getAttribute("colspan")||a.colSpan||1,10);let w=p,b=u;if(i==="right"&&(b=u+m),i==="left"&&(b=u-1),i==="down"&&(w=p+x),i==="up"&&(w=p-1),!g[w]||typeof g[w][b]>"u")return;const S=g[w][b];if(!S||S===a)return;const W=Math.min(p,w),L=Math.max(p,w+(parseInt(S.getAttribute("rowspan")||S.rowSpan||1,10)-1)),H=Math.min(u,b),P=Math.max(u+(m-1),b+(parseInt(S.getAttribute("colspan")||S.colSpan||1,10)-1)),je=new Set;for(let de=W;de<=L;de++)for(let me=H;me<=P;me++){const Ve=g[de]&&g[de][me];Ve&&je.add(Ve)}K(c,je)},$e=(a,i,c)=>{try{if(i==="vertical"){const s=parseInt(a.getAttribute("rowspan")||a.rowSpan||1,10);if(s<=1)return;const p=A(c,a);if(!p)return;const{r:u,c:g}=p;a.rowSpan=1;for(let x=1;x<s;x++){const m=c.rows[u+x];if(m){const w=(()=>{let S=0;for(let W=0;W<m.cells.length;W++){const L=m.cells[W],H=parseInt(L.getAttribute("colspan")||L.colSpan||1,10);if(S>=g)return W;S+=H}return m.cells.length})(),b=m.insertCell(w);b.innerHTML=""}}}else if(i==="horizontal"){const s=parseInt(a.getAttribute("colspan")||a.colSpan||1,10);if(s<=1)return;const p=a.parentElement,u=Array.prototype.indexOf.call(p.children,a);a.colSpan=1;for(let g=1;g<s;g++){const x=p.insertCell(u+g);x.innerHTML=""}}}catch{}},Pt=(a,i)=>{const c=A(i,a);if(!c)return;const{r:s,matrix:p}=c;try{f.current.querySelectorAll(".selected-cell").forEach(g=>g.classList.remove("selected-cell"))}catch{}for(let u=0;u<(p[s]||[]).length;u++){const g=p[s][u];g&&g.classList.add("selected-cell")}},$t=(a,i)=>{const c=A(i,a);if(!c)return;const{c:s,matrix:p}=c;try{f.current.querySelectorAll(".selected-cell").forEach(g=>g.classList.remove("selected-cell"))}catch{}for(let u=0;u<p.length;u++){const g=p[u]&&p[u][s];g&&g.classList.add("selected-cell")}},zt=a=>{try{f.current.querySelectorAll(".selected-cell").forEach(c=>c.classList.remove("selected-cell"))}catch{}try{a.querySelectorAll("td,th").forEach(c=>c.classList.add("selected-cell"))}catch{}},Dt=(a,i,c)=>{const s=A(c,a),p=A(c,i);if(!s||!p)return;const u=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{f.current.querySelectorAll(".selected-cell").forEach(S=>S.classList.remove("selected-cell"))}catch{}const w=s.matrix;for(let b=u;b<=g;b++)for(let S=x;S<=m;S++){const W=w[b]&&w[b][S];W&&W.classList.add("selected-cell")}};r.appendChild(h),r.appendChild(d("Cell Color","■",()=>{if(!T.current){alert("Select a table cell first");return}h.click()})),r.appendChild(C),r.appendChild(d("Header Color","🎨",()=>{try{const a=t.rows[0];if(!a)return alert("Table has no rows");if(!(a.cells[0]&&a.cells[0].tagName.toLowerCase()==="th")){const c=document.createElement("thead"),s=t.rows[0],p=document.createElement("tr");for(let u=0;u<s.cells.length;u++){const g=document.createElement("th");g.innerHTML=s.cells[u].innerHTML,p.appendChild(g)}c.appendChild(p),t.deleteRow(0),t.insertBefore(c,t.firstChild)}}catch{}C.click()})),r.appendChild(d("Clear Header Color","✖",()=>{N()})),r.appendChild(d("Toggle Header","H",()=>{try{const a=t.rows[0];if(!a)return;if(a.cells[0]&&a.cells[0].tagName.toLowerCase()==="th"){const c=document.createElement("tbody");for(let s=0;s<t.rows.length;s++){const p=t.rows[0],u=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,u.appendChild(m)}c.appendChild(u),t.deleteRow(0)}t.appendChild(c)}else{const c=document.createElement("thead"),s=t.rows[0],p=document.createElement("tr"),u=s.cells;for(let g=0;g<u.length;g++){const x=document.createElement("th");x.innerHTML=u[g].innerHTML,x.style.cssText=u[g].style.cssText,p.appendChild(x)}c.appendChild(p),t.deleteRow(0),t.insertBefore(c,t.firstChild)}}catch{}})),l.appendChild(r),["nw","ne","sw","se"].forEach(a=>{const i=document.createElement("div");i.className=`table-resize-handle ${a}`,i.addEventListener("mousedown",c=>{c.preventDefault(),c.stopPropagation(),St(c,l,t,a)}),l.appendChild(i)});const ce=document.createElement("div");ce.className="table-drag-handle",ce.title="Drag to move table",l.appendChild(ce);const U=document.createElement("div");U.className="table-context-menu",U.innerHTML=`
|
|
2
2
|
<button type="button" data-action="select-row">Select row</button>
|
|
3
3
|
<button type="button" data-action="select-column">Select column</button>
|
|
4
4
|
<button type="button" data-action="select-table">Select table</button>
|
|
@@ -14,4 +14,4 @@
|
|
|
14
14
|
<button type="button" data-action="add-row">Add row below</button>
|
|
15
15
|
<button type="button" data-action="add-col">Add column right</button>
|
|
16
16
|
<button type="button" data-action="delete-table">Delete table</button>
|
|
17
|
-
`,P.style.display="none",o.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","⋮",()=>{ae(P.style.display!=="block")});qe.className+=" table-menu-btn",a.appendChild(qe),o.addEventListener("contextmenu",n=>{n.preventDefault(),F.current=null,M.current=n.target.closest("td,th")||M.current;const i=o.getBoundingClientRect();ae(!0,n.clientX-i.left,n.clientY-i.top)}),document.addEventListener("click",n=>{o.contains(n.target)||ae(!1)});let ce=!1,oe=null;const Fe=n=>{if(!ce)return;const i=n.clientX-oe.x,c=n.clientY-oe.y;o.style.transform=`translate(${oe.tx+i}px, ${oe.ty+c}px)`},Ue=()=>{if(!ce)return;ce=!1,document.removeEventListener("mousemove",Fe),document.removeEventListener("mouseup",Ue);const n=o.style.transform.match(/translate\((-?\d+)px,\s*(-?\d+)px\)/);if(n){const i=parseInt(n[1],10),c=parseInt(n[2],10);o.style.left=o.offsetLeft+i+"px",o.style.top=o.offsetTop+c+"px",o.style.transform="",o.style.position="absolute"}};re.addEventListener("mousedown",n=>{n.preventDefault(),n.stopPropagation(),ce=!0,oe={x:n.clientX,y:n.clientY,tx:0,ty:0},document.addEventListener("mousemove",Fe),document.addEventListener("mouseup",Ue)}),t.dataset.enhanced="1"},vt=(t,o,l,r)=>{const a=t.clientX,d=t.clientY,h=l.offsetWidth,C=l.offsetHeight,S=U=>{const A=U.clientX-a,Q=U.clientY-d;if(r.includes("e")){const I=Math.max(200,h+A);l.style.width=I+"px"}else if(r.includes("w")){const I=Math.max(200,h-A);l.style.width=I+"px"}if(r.includes("s")){const I=Math.max(100,C+Q);l.style.height=I+"px"}else if(r.includes("n")){const I=Math.max(100,C-Q);l.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 o=M.current;let l=-1;o&&(l=o.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(l+1);for(let d=0;d<r;d++){const h=a.insertCell(-1);h.innerHTML=`Cell ${a.rowIndex}-${d+1}`}},Ie=t=>{const o=M.current;let l=-1;o&&(l=Array.prototype.indexOf.call(o.parentElement.children,o));for(let r=0;r<t.rows.length;r++){const a=t.rows[r],d=l+1,h=a.insertCell(d);h.innerHTML=""}},yt=t=>{if(t.rows.length<=1)return;const o=M.current;let l=o?o.parentElement.rowIndex:t.rows.length-1;t.deleteRow(l)},mt=t=>{const o=t.rows[0]?t.rows[0].cells.length:0;if(o<=1)return;const l=M.current;let r=l?Array.prototype.indexOf.call(l.parentElement.children,l):o-1;for(let a=0;a<t.rows.length;a++){const d=t.rows[a];d.cells[r]&&d.deleteCell(r)}},Be=t=>{const o=t.closest(".editable-table-wrap");o?o.remove():t.remove()},bt=()=>{try{const t=u.current;if(!t)return;t.querySelectorAll("table").forEach(l=>Ae(l))}catch{}},Ct=()=>{try{const t=u.current;if(!t)return;t.querySelectorAll("img:not(.editable-image-wrap img)").forEach(l=>{if(!l.closest(".editable-image-wrap")){const r=document.createElement("div");r.className="editable-image-wrap",r.contentEditable="false",l.parentNode.insertBefore(r,l),r.appendChild(l),Me(r)}})}catch{}},xt=()=>{le(!Y)},wt=()=>{const t=u.current?.innerHTML||"",o=new Blob([t],{type:"text/html"}),l=URL.createObjectURL(o),r=document.createElement("a");r.href=l,r.download="document.html",r.click(),URL.revokeObjectURL(l)};v.useEffect(()=>{const t=()=>{const o=u.current?.innerText||"",l=new Blob([o],{type:"text/plain"}),r=URL.createObjectURL(l),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=o=>{try{const l=o.target.closest(".editable-table-wrap"),r=o.target.closest(".editable-image-wrap");!l&&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 o=t.target.files?.[0];if(o){const l=new FileReader;l.onload=r=>{const a=r.target?.result;u.current&&(u.current.innerHTML=a,j(a),setTimeout(()=>{bt(),Ct()},50))},l.readAsText(o)}},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 o=`<pre><code>${t}</code></pre>`;y("insertHTML",o)}},Mt=()=>{y("formatBlock","blockquote")};return e.jsxs("div",{className:`editor-container ${Y?"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:lt,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:()=>K(!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,o)=>Array.from({length:10},(l,r)=>e.jsx("div",{className:`table-cell-preview ${o<N.rows&&r<N.cols?"hover":""}`,onMouseEnter:()=>pt(o,r),onClick:()=>ft(o,r)},`${o}-${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:Y?"Exit Fullscreen":"Fullscreen",children:e.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:Y?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,"data-placeholder":"Start typing your content here..."})]})}),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:J||""})}),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:_,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:X,onChange:t=>G(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:ot,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"})}));
|
|
17
|
+
`,U.style.display="none",l.appendChild(U);const se=(a,i,c)=>{a?(U.style.display="block",U.style.left=typeof i=="number"?i+"px":"8px",U.style.top=typeof c=="number"?c+"px":"36px"):U.style.display="none"};U.addEventListener("click",a=>{a.stopPropagation();const i=a.target.closest("button[data-action]");if(!i)return;const c=i.getAttribute("data-action");try{const s=T.current||t.rows[0].cells[0];if(!s)return;c==="select-row"&&Pt(s,t),c==="select-column"&&$t(s,t),c==="select-table"&&zt(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"&&$e(s,"vertical",t),c==="split-horizontal"&&$e(s,"horizontal",t),c==="add-row"&&Fe(t),c==="add-col"&&Ue(t),c==="delete-table"&&Pe(t)}catch{}se(!1)});const ze=d("Table Menu","⋮",()=>{se(U.style.display!=="block")});ze.className+=" table-menu-btn",r.appendChild(ze),l.addEventListener("contextmenu",a=>{a.preventDefault(),q.current=null,T.current=a.target.closest("td,th")||T.current;const i=l.getBoundingClientRect();se(!0,a.clientX-i.left,a.clientY-i.top)}),document.addEventListener("click",a=>{l.contains(a.target)||se(!1)});let ie=!1,le=null;const De=a=>{if(!ie)return;const i=a.clientX-le.x,c=a.clientY-le.y;l.style.transform=`translate(${le.tx+i}px, ${le.ty+c}px)`},Oe=()=>{if(!ie)return;ie=!1,document.removeEventListener("mousemove",De),document.removeEventListener("mouseup",Oe);const a=l.style.transform.match(/translate\((-?\d+)px,\s*(-?\d+)px\)/);if(a){const i=parseInt(a[1],10),c=parseInt(a[2],10);l.style.left=l.offsetLeft+i+"px",l.style.top=l.offsetTop+c+"px",l.style.transform="",l.style.position="absolute"}};ce.addEventListener("mousedown",a=>{a.preventDefault(),a.stopPropagation(),ie=!0,le={x:a.clientX,y:a.clientY,tx:0,ty:0},document.addEventListener("mousemove",De),document.addEventListener("mouseup",Oe)}),t.dataset.enhanced="1"},St=(t,l,o,n)=>{const r=t.clientX,d=t.clientY,h=o.offsetWidth,C=o.offsetHeight,N=F=>{const A=F.clientX-r,K=F.clientY-d;if(n.includes("e")){const I=Math.max(200,h+A);o.style.width=I+"px"}else if(n.includes("w")){const I=Math.max(200,h-A);o.style.width=I+"px"}if(n.includes("s")){const I=Math.max(100,C+K);o.style.height=I+"px"}else if(n.includes("n")){const I=Math.max(100,C-K);o.style.height=I+"px"}},M=()=>{document.removeEventListener("mousemove",N),document.removeEventListener("mouseup",M),document.body.style.cursor=""};document.addEventListener("mousemove",N),document.addEventListener("mouseup",M)},Fe=t=>{const l=T.current;let o=-1;l&&(o=l.parentElement.rowIndex);const n=t.rows[0]?t.rows[0].cells.length:t.tBodies[0]&&t.tBodies[0].rows[0]?t.tBodies[0].rows[0].cells.length:1,r=t.insertRow(o+1);for(let d=0;d<n;d++){const h=r.insertCell(-1);h.innerHTML=`Cell ${r.rowIndex}-${d+1}`}},Ue=t=>{const l=T.current;let o=-1;l&&(o=Array.prototype.indexOf.call(l.parentElement.children,l));for(let n=0;n<t.rows.length;n++){const r=t.rows[n],d=o+1,h=r.insertCell(d);h.innerHTML=""}},Lt=t=>{if(t.rows.length<=1)return;const l=T.current;let o=l?l.parentElement.rowIndex:t.rows.length-1;t.deleteRow(o)},Tt=t=>{const l=t.rows[0]?t.rows[0].cells.length:0;if(l<=1)return;const o=T.current;let n=o?Array.prototype.indexOf.call(o.parentElement.children,o):l-1;for(let r=0;r<t.rows.length;r++){const d=t.rows[r];d.cells[n]&&d.deleteCell(n)}},Pe=t=>{const l=t.closest(".editable-table-wrap");l?l.remove():t.remove()},Mt=()=>{try{const t=f.current;if(!t)return;t.querySelectorAll("table").forEach(o=>qe(o))}catch{}},Et=()=>{try{const t=f.current;if(!t)return;t.querySelectorAll("img:not(.editable-image-wrap img)").forEach(o=>{if(!o.closest(".editable-image-wrap")){const n=document.createElement("div");n.className="editable-image-wrap",n.contentEditable="false",o.parentNode.insertBefore(n,o),n.appendChild(o),Be(n)}})}catch{}},At=()=>{R(!O)},Ht=()=>{const t=f.current?.innerHTML||"",l=new Blob([t],{type:"text/html"}),o=URL.createObjectURL(l),n=document.createElement("a");n.href=o,n.download="document.html",n.click(),URL.revokeObjectURL(o)};y.useEffect(()=>{const t=()=>{const l=f.current?.innerText||"",o=new Blob([l],{type:"text/plain"}),n=URL.createObjectURL(o),r=document.createElement("a");r.href=n,r.download="document.txt",r.click(),URL.revokeObjectURL(n)};try{window._exportAsText=t}catch{}return()=>{try{delete window._exportAsText}catch{}}},[]),y.useEffect(()=>{const t=l=>{try{const o=l.target.closest(".editable-table-wrap"),n=l.target.closest(".editable-image-wrap");!o&&f.current&&f.current.querySelectorAll(".editable-table-wrap.selected").forEach(d=>d.classList.remove("selected")),!n&&f.current&&f.current.querySelectorAll(".editable-image-wrap.selected").forEach(d=>d.classList.remove("selected"))}catch{}};return document.addEventListener("click",t),()=>document.removeEventListener("click",t)},[]);const It=t=>{const l=t.target.files?.[0];if(l){const o=new FileReader;o.onload=n=>{const r=n.target?.result;f.current&&(f.current.innerHTML=r,D(r),setTimeout(()=>{Mt(),Et()},50))},o.readAsText(l)}},Bt=()=>{j(!0)},Wt=()=>{const t=f.current?.innerHTML||"";navigator.clipboard.writeText(t).then(()=>{alert("HTML copied to clipboard!")})},qt=()=>{confirm("Are you sure you want to clear all content?")&&f.current&&(v("selectAll"),v("delete"),D(""))},Ft=()=>{const t=prompt("Enter your code:");if(t){const l=`<pre><code>${t}</code></pre>`;v("insertHTML",l)}},Ut=()=>{v("formatBlock","blockquote")};return e.jsxs("div",{className:`editor-container ${O?"fullscreen":""}`,onDragOver:at,onDragLeave:ct,onDrop:st,children:[e.jsx("input",{type:"file",ref:Ie,onChange:It,accept:".html,.txt",style:{display:"none"}}),e.jsx("div",{className:`editor-content ${oe?"full-bleed":""}`,children:e.jsxs("div",{className:`page-card size-${Me} ${oe?"no-gutters":""}`,style:{width:Q||void 0},children:[e.jsxs("div",{className:"editor-toolbar",children:[e.jsxs("div",{className:"toolbar-group",children:[e.jsx("button",{className:"toolbar-btn",onClick:()=>v("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:()=>v("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:gt,value:et,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:ut,value:tt,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=>{Ct(t.target.value),ge(t.target.value)},value:lt,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 ${z.bold?"active":""}`,onClick:()=>v("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 ${z.italic?"active":""}`,onClick:()=>v("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 ${z.underline?"active":""}`,onClick:()=>v("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 ${z.strikeThrough?"active":""}`,onClick:()=>v("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:pt,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:ft,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:()=>X(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"})]})}),Ge&&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 ${z.justifyLeft?"active":""}`,onClick:()=>{v("justifyLeft"),X(!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 ${z.justifyCenter?"active":""}`,onClick:()=>{v("justifyCenter"),X(!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 ${z.justifyRight?"active":""}`,onClick:()=>{v("justifyRight"),X(!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 ${z.insertUnorderedList?"active":""}`,onClick:()=>{v("insertUnorderedList"),X(!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 ${z.insertOrderedList?"active":""}`,onClick:()=>{v("insertOrderedList"),X(!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:()=>{v("indent"),X(!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:()=>{v("outdent"),X(!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:it,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:yt,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:()=>we(!xe),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"})]})}),xe&&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,n)=>e.jsx("div",{className:`table-cell-preview ${l<re.rows&&n<re.cols?"hover":""}`,onMouseEnter:()=>xt(l,n),onClick:()=>wt(l,n)},`${l}-${n}`))).flat()}),e.jsxs("div",{className:"table-size-label",children:[re.rows," × ",re.cols]})]})]}),e.jsx("button",{className:"toolbar-btn",onClick:()=>fe(!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:()=>v("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:Ut,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:Ft,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:Me,onChange:t=>Ze(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:()=>Ie.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:Ht,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:Bt,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:qt,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:At,title:O?"Exit Fullscreen":"Fullscreen",children:e.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:O?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:()=>v("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:f,className:"page-body",contentEditable:!0,onInput:rt,suppressContentEditableWarning:!0,"data-placeholder":"Start typing your content here...",style:{minHeight:G||void 0}})]})}),he&&e.jsx("div",{className:"rte-drop-overlay",children:"Drop to insert into editor"}),Je&&e.jsx("div",{className:"modal-overlay",onClick:()=>ae(!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:()=>ae(!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:Ne,onChange:t=>Se(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:Le,onChange:t=>Te(parseInt(t.target.value)||1),className:"form-input"})]})]}),e.jsxs("div",{className:"modal-footer",children:[e.jsx("button",{className:"btn-secondary",onClick:()=>ae(!1),children:"Cancel"}),e.jsx("button",{className:"btn-primary",onClick:We,children:"Insert Table"})]})]})}),ne&&e.jsx("div",{className:"modal-overlay",onClick:()=>j(!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:()=>j(!1),children:"×"})]}),e.jsx("div",{className:"modal-body",children:e.jsx("pre",{className:"html-preview",children:Z||""})}),e.jsxs("div",{className:"modal-footer",children:[e.jsx("button",{className:"btn-secondary",onClick:()=>j(!1),children:"Close"}),e.jsx("button",{className:"btn-primary",onClick:Wt,children:"Copy HTML"})]})]})}),Ye&&e.jsx("div",{className:"link-modal-overlay",onClick:()=>fe(!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=>Ke(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:ue,onChange:t=>Qe(t.target.value),placeholder:"Enter replacement text..."})]}),ke&&e.jsx("div",{className:"find-replace-status",children:ke}),e.jsxs("div",{className:"find-replace-buttons",children:[e.jsx("button",{className:"find-replace-btn primary",onClick:ve,children:"Find Next"}),e.jsx("button",{className:"find-replace-btn",onClick:kt,children:"Replace"}),e.jsx("button",{className:"find-replace-btn",onClick:Nt,children:"Replace All"}),e.jsx("button",{className:"find-replace-btn",onClick:()=>fe(!1),children:"Close"})]})]})}),E&&e.jsx("div",{className:"modal-overlay",onClick:()=>V(!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:()=>V(!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:pe,onChange:t=>Ce(t.target.value),className:"form-input"}),e.jsx("button",{className:"btn-primary",onClick:vt,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:nt,onChange:mt,accept:"image/*",className:"form-input",style:{padding:"8px"}})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsx("button",{className:"btn-secondary",onClick:()=>V(!1),children:"Cancel"})})]})}),e.jsx(be,{isOpen:ee.open,onClose:()=>te(t=>({...t,open:!1})),onInsert:dt,onRemove:ht,isEditing:!!ee.isEditing,initialUrl:ee.initialUrl,initialText:ee.initialText,existingLinks:ee.existingLinks})]})};$.LinkModal=be,$.RichTextEditor=Xe,Object.defineProperty($,Symbol.toStringTag,{value:"Module"})}));
|
package/dist/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
*{margin:0;padding:0;box-sizing:border-box}:root{--toolbar-height: 64px;--toolbar-row-height: 44px;--toolbar-rows: 2;--toolbar-gap: 8px}.editor-container{width:100%;max-width:100%;margin:0;min-height:600px;height:auto;background:#f8f9fa;border-radius:0;box-shadow:none;overflow:visible;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{flex:1;overflow-y:auto;overflow-x:hidden;background:#f8f9fa;padding:24px;display:flex;justify-content:center;align-items:flex-start;width:100%}.page-card{width:794px;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:64px 96px;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;outline:none;cursor:text}.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-legal{width:816px;min-height:1344px}.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-legal,.page-card.size-custom{width:calc(100% - 48px);height:auto}.page-card .page-body{padding:32px 48px}}@media(max-width:768px){.page-card{width:calc(100% - 24px)!important}.page-card .page-body{padding:24px 32px}}.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[data-placeholder]:empty:before{content:attr(data-placeholder);color:#9aa0a6;font-style:italic;pointer-events:none;position:absolute}.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,.status-bar-bottom{display: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}}@media print{body *{visibility:hidden!important}.editor-toolbar,.editor-container,.editor-container *{visibility:visible!important}.editor-container{position:absolute!important;left:0!important;top:0!important;width:100%!important}.editor-toolbar{position:fixed!important;top:0!important;left:0!important;right:0!important;z-index:9999!important}.page-card,.page-card .page-body{background:#fff!important;box-shadow:none!important;border:none!important}}body.export-only *{display:none!important}body.export-only .editor-toolbar,body.export-only .editor-container,body.export-only .editor-container *{display:block!important}body.export-only{background:transparent!important}@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}}
|
|
1
|
+
*{margin:0;padding:0;box-sizing:border-box}:root{--toolbar-height: 64px;--toolbar-row-height: 44px;--toolbar-rows: 2;--toolbar-gap: 8px}.editor-container{width:100%;max-width:100%;margin:0;min-height:600px;height:auto;background:#f8f9fa;border-radius:0;box-shadow:none;overflow:visible;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{flex:1;overflow-y:auto;overflow-x:hidden;background:#f8f9fa;padding:24px;display:flex;justify-content:center;align-items:flex-start;width:100%}.editor-content.full-bleed{justify-content:flex-start;padding:12px 8px}.page-card{width:794px;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.no-gutters{margin:0 0 24px;width:100%;max-width:100%;border-radius:0}.page-card .page-body{background:var(--editor-bg);min-height:1000px;padding:64px 96px;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;outline:none;cursor:text}.page-card.no-gutters .page-body{padding:24px 20px}.rte-drop-overlay{position:fixed;inset:0;display:flex;align-items:center;justify-content:center;pointer-events:none;z-index:20000;color:#111;font-weight:700;background:#ffffffb3;-webkit-backdrop-filter:blur(2px);backdrop-filter:blur(2px)}.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-legal{width:816px;min-height:1344px}.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-legal,.page-card.size-custom{width:calc(100% - 48px);height:auto}.page-card .page-body{padding:32px 48px}}@media(max-width:768px){.page-card{width:calc(100% - 24px)!important}.page-card .page-body{padding:24px 32px}}.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[data-placeholder]:empty:before{content:attr(data-placeholder);color:#9aa0a6;font-style:italic;pointer-events:none;position:absolute}.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,.status-bar-bottom{display: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}}@media print{body *{visibility:hidden!important}.editor-toolbar,.editor-container,.editor-container *{visibility:visible!important}.editor-container{position:absolute!important;left:0!important;top:0!important;width:100%!important}.editor-toolbar{position:fixed!important;top:0!important;left:0!important;right:0!important;z-index:9999!important}.page-card,.page-card .page-body{background:#fff!important;box-shadow:none!important;border:none!important}}body.export-only *{display:none!important}body.export-only .editor-toolbar,body.export-only .editor-container,body.export-only .editor-container *{display:block!important}body.export-only{background:transparent!important}@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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@daneshnaik/rich-text-editor",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "A powerful and feature-rich WYSIWYG rich text editor for React with table editing, image handling, and extensive formatting options",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/rich-text-editor.umd.cjs",
|