@editora/plugins 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/plugins.css CHANGED
@@ -1 +1 @@
1
- .rte-table-wrapper{position:relative}.rte-table,table{border-collapse:collapse;width:100%;margin:1rem 0;border:1px solid #ddd;font-size:14px;line-height:1.4;position:relative}.rte-table td,.rte-table th,table td,table th{border:1px solid #ddd;padding:8px 12px;min-width:80px;vertical-align:top;position:relative;-webkit-user-select:none;user-select:none}.rte-table td:focus,.rte-table th:focus,table td:focus,table th:focus{outline:2px solid #007acc;outline-offset:-2px}.rte-table th,table th{background-color:#f8f9fa;font-weight:600;text-align:left}.rte-table td p,table td p{margin:0;padding:0}.rte-table td p:empty:before,table td p:empty:before{content:"​";display:inline-block}.rte-table td[contenteditable]:empty:before,table td[contenteditable]:empty:before{content:"Type here...";color:#999;font-style:italic;pointer-events:none}.rte-table tr:hover,table tr:hover{background-color:#f8f9fa}.rte-table td.selected,table td.selected{background-color:#e3f2fd;border-color:#2196f3}.table-toolbar{background:#fff;border:1px solid #d0d0d0;border-radius:4px;box-shadow:0 2px 8px #0000001a;padding:4px;display:flex;align-items:center;gap:0;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,sans-serif;min-width:max-content}.toolbar-section{display:flex;align-items:center;gap:2px}.toolbar-divider{width:1px;height:20px;background:#e0e0e0;margin:0 4px}.toolbar-icon-btn{display:flex;align-items:center;justify-content:center;width:28px;height:28px;padding:0;border:1px solid transparent;background:transparent;cursor:pointer;color:#333;border-radius:3px;transition:all .2s ease;flex-shrink:0;font-size:14px;line-height:1}.toolbar-icon-btn svg{width:16px;height:16px}.toolbar-icon-btn:hover:not(:disabled){background:#f0f0f0;border-color:#d0d0d0;color:#06c}.toolbar-icon-btn:active:not(:disabled){background:#e8f0ff;border-color:#06c;transform:scale(.95)}.toolbar-icon-btn:disabled{opacity:.4;cursor:not-allowed;color:#ccc}.toolbar-icon-btn-danger{color:#d32f2f}.toolbar-icon-btn-danger:hover:not(:disabled){background:#fff3f3;border-color:#fcc;color:#d32f2f}.toolbar-icon-btn-danger:active:not(:disabled){background:#ffebee}.toolbar-icon-btn-delete{color:#d32f2f}.toolbar-icon-btn-delete:hover:not(:disabled){background:#fff3f3;border-color:#fcc;color:#d32f2f}.toolbar-icon-btn-delete:active:not(:disabled){background:#ffebee}.resize-handle{opacity:0;transition:all .15s ease}.resize-handle:hover{opacity:1}td:hover>.resize-handle,th:hover>.resize-handle{opacity:1}.table-resize-handle{position:absolute;bottom:-4px;right:-4px;width:12px;height:12px;background:transparent;cursor:nwse-resize;z-index:10;transition:background .15s ease}.table-resize-handle:after{content:"";position:absolute;bottom:0;right:0;width:8px;height:8px;background:#0066cc4d;border-bottom:2px solid #0066cc;border-right:2px solid #0066cc;border-radius:0 0 2px;opacity:0;transition:opacity .15s ease}.table-resize-handle:hover:after{opacity:1}.rte-table:hover .table-resize-handle:after,table:hover .table-resize-handle:after{opacity:1}:is([data-theme=dark],.dark,.editora-theme-dark) :is(.rte-table,table){border-color:#607088;background:#24303c;color:#e6eefb}:is([data-theme=dark],.dark,.editora-theme-dark) :is(.rte-table td,.rte-table th,table td,table th){border-color:#607088;color:#e6eefb}:is([data-theme=dark],.dark,.editora-theme-dark) :is(.rte-table th,table th){background:linear-gradient(180deg,#3b4553,#333d4a);color:#f3f8ff}:is([data-theme=dark],.dark,.editora-theme-dark) :is(.rte-table tr:hover,table tr:hover){background-color:#58a6ff1f}:is([data-theme=dark],.dark,.editora-theme-dark) :is(.rte-table td.selected,table td.selected){background-color:#58a6ff47;border-color:#79beff}:is([data-theme=dark],.dark,.editora-theme-dark) :is(.rte-table td[contenteditable]:empty:before,table td[contenteditable]:empty:before){color:#94a3b8}:is([data-theme=dark],.dark,.editora-theme-dark) .table-toolbar{background:linear-gradient(180deg,#2f3844,#2a323c);border-color:#4d596b;box-shadow:0 8px 20px #00000073}.table-toolbar.rte-theme-dark{background:linear-gradient(180deg,#2f3844,#2a323c);border-color:#4d596b;box-shadow:0 8px 20px #00000073}:is([data-theme=dark],.dark,.editora-theme-dark) .toolbar-divider{background:#4d596b}.table-toolbar.rte-theme-dark .toolbar-divider{background:#4d596b}:is([data-theme=dark],.dark,.editora-theme-dark) .toolbar-icon-btn{color:#d7deea;border-color:transparent}.table-toolbar.rte-theme-dark .toolbar-icon-btn{color:#d7deea;border-color:transparent}:is([data-theme=dark],.dark,.editora-theme-dark) .toolbar-icon-btn svg{color:currentColor}.table-toolbar.rte-theme-dark .toolbar-icon-btn svg{color:currentColor}:is([data-theme=dark],.dark,.editora-theme-dark) .toolbar-icon-btn svg [stroke="#000" i],:is([data-theme=dark],.dark,.editora-theme-dark) .toolbar-icon-btn svg [stroke="#000000" i],:is([data-theme=dark],.dark,.editora-theme-dark) .toolbar-icon-btn svg [stroke=black i]{stroke:currentColor!important}.table-toolbar.rte-theme-dark .toolbar-icon-btn svg [stroke="#000" i],.table-toolbar.rte-theme-dark .toolbar-icon-btn svg [stroke="#000000" i],.table-toolbar.rte-theme-dark .toolbar-icon-btn svg [stroke=black i]{stroke:currentColor!important}:is([data-theme=dark],.dark,.editora-theme-dark) .toolbar-icon-btn svg [fill="#000" i],:is([data-theme=dark],.dark,.editora-theme-dark) .toolbar-icon-btn svg [fill="#000000" i],:is([data-theme=dark],.dark,.editora-theme-dark) .toolbar-icon-btn svg [fill=black i]{fill:currentColor!important}.table-toolbar.rte-theme-dark .toolbar-icon-btn svg [fill="#000" i],.table-toolbar.rte-theme-dark .toolbar-icon-btn svg [fill="#000000" i],.table-toolbar.rte-theme-dark .toolbar-icon-btn svg [fill=black i]{fill:currentColor!important}:is([data-theme=dark],.dark,.editora-theme-dark) .toolbar-icon-btn:hover:not(:disabled){background:#3a4554;border-color:#607088;color:#f3f8ff}.table-toolbar.rte-theme-dark .toolbar-icon-btn:hover:not(:disabled){background:#3a4554;border-color:#607088;color:#f3f8ff}:is([data-theme=dark],.dark,.editora-theme-dark) .toolbar-icon-btn:active:not(:disabled){background:#4a95de;border-color:#67adf4;color:#0f1b2a}.table-toolbar.rte-theme-dark .toolbar-icon-btn:active:not(:disabled){background:#4a95de;border-color:#67adf4;color:#0f1b2a}:is([data-theme=dark],.dark,.editora-theme-dark) .toolbar-icon-btn:disabled{color:#7f8ca1}.table-toolbar.rte-theme-dark .toolbar-icon-btn:disabled{color:#7f8ca1}@media(max-width:768px){.rte-table,table{font-size:12px}.rte-table td,.rte-table th,table td,table th{padding:4px 6px;min-width:60px}.table-toolbar{padding:3px;gap:0;max-width:90vw;overflow-x:auto}.toolbar-icon-btn{width:26px;height:26px}.toolbar-divider{height:18px}}@media print{.rte-table,table{border:1px solid #000}.rte-table td,.rte-table th,table td,table th{border:1px solid #000;padding:4px}.table-toolbar{display:none}}
1
+ .rte-table-wrapper{position:relative}.rte-table,table{border-collapse:collapse;width:100%;margin:1rem 0;border:1px solid #ddd;font-size:14px;line-height:1.4;position:relative}.rte-table td,.rte-table th,table td,table th{border:1px solid #ddd;padding:8px 12px;min-width:80px;vertical-align:top;position:relative}.rte-table td:focus,.rte-table th:focus,table td:focus,table th:focus{outline:2px solid #007acc;outline-offset:-2px}.rte-table th,table th{background-color:#f8f9fa;font-weight:600;text-align:left}.rte-table td p,table td p{margin:0;padding:0}.rte-table td p:empty:before,table td p:empty:before{content:"​";display:inline-block}.rte-table td[contenteditable]:empty:before,table td[contenteditable]:empty:before{content:"Type here...";color:#999;font-style:italic;pointer-events:none}.rte-table tr:hover,table tr:hover{background-color:#f8f9fa}.rte-table td.selected,table td.selected{background-color:#e3f2fd;border-color:#2196f3}.table-toolbar{background:#fff;border:1px solid #d0d0d0;border-radius:4px;box-shadow:0 2px 8px #0000001a;padding:4px;display:flex;align-items:center;gap:0;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,sans-serif;min-width:max-content}.toolbar-section{display:flex;align-items:center;gap:2px}.toolbar-divider{width:1px;height:20px;background:#e0e0e0;margin:0 4px}.toolbar-icon-btn{display:flex;align-items:center;justify-content:center;width:28px;height:28px;padding:0;border:1px solid transparent;background:transparent;cursor:pointer;color:#333;border-radius:3px;transition:all .2s ease;flex-shrink:0;font-size:14px;line-height:1}.toolbar-icon-btn svg{width:16px;height:16px}.toolbar-icon-btn:hover:not(:disabled){background:#f0f0f0;border-color:#d0d0d0;color:#06c}.toolbar-icon-btn:active:not(:disabled){background:#e8f0ff;border-color:#06c;transform:scale(.95)}.toolbar-icon-btn:disabled{opacity:.4;cursor:not-allowed;color:#ccc}.toolbar-icon-btn-danger{color:#d32f2f}.toolbar-icon-btn-danger:hover:not(:disabled){background:#fff3f3;border-color:#fcc;color:#d32f2f}.toolbar-icon-btn-danger:active:not(:disabled){background:#ffebee}.toolbar-icon-btn-delete{color:#d32f2f}.toolbar-icon-btn-delete:hover:not(:disabled){background:#fff3f3;border-color:#fcc;color:#d32f2f}.toolbar-icon-btn-delete:active:not(:disabled){background:#ffebee}.resize-handle{opacity:0;transition:all .15s ease}.resize-handle:hover{opacity:1}td:hover>.resize-handle,th:hover>.resize-handle{opacity:1}.table-resize-handle{position:absolute;bottom:-4px;right:-4px;width:12px;height:12px;background:transparent;cursor:nwse-resize;z-index:10;transition:background .15s ease}.table-resize-handle:after{content:"";position:absolute;bottom:0;right:0;width:8px;height:8px;background:#0066cc4d;border-bottom:2px solid #0066cc;border-right:2px solid #0066cc;border-radius:0 0 2px;opacity:0;transition:opacity .15s ease}.table-resize-handle:hover:after{opacity:1}.rte-table:hover .table-resize-handle:after,table:hover .table-resize-handle:after{opacity:1}:is([data-theme=dark],.dark,.editora-theme-dark) :is(.rte-table,table){border-color:#607088;background:#24303c;color:#e6eefb}:is([data-theme=dark],.dark,.editora-theme-dark) :is(.rte-table td,.rte-table th,table td,table th){border-color:#607088;color:#e6eefb}:is([data-theme=dark],.dark,.editora-theme-dark) :is(.rte-table th,table th){background:linear-gradient(180deg,#3b4553,#333d4a);color:#f3f8ff}:is([data-theme=dark],.dark,.editora-theme-dark) :is(.rte-table tr:hover,table tr:hover){background-color:#58a6ff1f}:is([data-theme=dark],.dark,.editora-theme-dark) :is(.rte-table td.selected,table td.selected){background-color:#58a6ff47;border-color:#79beff}:is([data-theme=dark],.dark,.editora-theme-dark) :is(.rte-table td[contenteditable]:empty:before,table td[contenteditable]:empty:before){color:#94a3b8}:is([data-theme=dark],.dark,.editora-theme-dark) .table-toolbar{background:linear-gradient(180deg,#2f3844,#2a323c);border-color:#4d596b;box-shadow:0 8px 20px #00000073}.table-toolbar.rte-theme-dark{background:linear-gradient(180deg,#2f3844,#2a323c);border-color:#4d596b;box-shadow:0 8px 20px #00000073}:is([data-theme=dark],.dark,.editora-theme-dark) .toolbar-divider{background:#4d596b}.table-toolbar.rte-theme-dark .toolbar-divider{background:#4d596b}:is([data-theme=dark],.dark,.editora-theme-dark) .toolbar-icon-btn{color:#d7deea;border-color:transparent}.table-toolbar.rte-theme-dark .toolbar-icon-btn{color:#d7deea;border-color:transparent}:is([data-theme=dark],.dark,.editora-theme-dark) .toolbar-icon-btn svg{color:currentColor}.table-toolbar.rte-theme-dark .toolbar-icon-btn svg{color:currentColor}:is([data-theme=dark],.dark,.editora-theme-dark) .toolbar-icon-btn svg [stroke="#000" i],:is([data-theme=dark],.dark,.editora-theme-dark) .toolbar-icon-btn svg [stroke="#000000" i],:is([data-theme=dark],.dark,.editora-theme-dark) .toolbar-icon-btn svg [stroke=black i]{stroke:currentColor!important}.table-toolbar.rte-theme-dark .toolbar-icon-btn svg [stroke="#000" i],.table-toolbar.rte-theme-dark .toolbar-icon-btn svg [stroke="#000000" i],.table-toolbar.rte-theme-dark .toolbar-icon-btn svg [stroke=black i]{stroke:currentColor!important}:is([data-theme=dark],.dark,.editora-theme-dark) .toolbar-icon-btn svg [fill="#000" i],:is([data-theme=dark],.dark,.editora-theme-dark) .toolbar-icon-btn svg [fill="#000000" i],:is([data-theme=dark],.dark,.editora-theme-dark) .toolbar-icon-btn svg [fill=black i]{fill:currentColor!important}.table-toolbar.rte-theme-dark .toolbar-icon-btn svg [fill="#000" i],.table-toolbar.rte-theme-dark .toolbar-icon-btn svg [fill="#000000" i],.table-toolbar.rte-theme-dark .toolbar-icon-btn svg [fill=black i]{fill:currentColor!important}:is([data-theme=dark],.dark,.editora-theme-dark) .toolbar-icon-btn:hover:not(:disabled){background:#3a4554;border-color:#607088;color:#f3f8ff}.table-toolbar.rte-theme-dark .toolbar-icon-btn:hover:not(:disabled){background:#3a4554;border-color:#607088;color:#f3f8ff}:is([data-theme=dark],.dark,.editora-theme-dark) .toolbar-icon-btn:active:not(:disabled){background:#4a95de;border-color:#67adf4;color:#0f1b2a}.table-toolbar.rte-theme-dark .toolbar-icon-btn:active:not(:disabled){background:#4a95de;border-color:#67adf4;color:#0f1b2a}:is([data-theme=dark],.dark,.editora-theme-dark) .toolbar-icon-btn:disabled{color:#7f8ca1}.table-toolbar.rte-theme-dark .toolbar-icon-btn:disabled{color:#7f8ca1}@media(max-width:768px){.rte-table,table{font-size:12px}.rte-table td,.rte-table th,table td,table th{padding:4px 6px;min-width:60px}.table-toolbar{padding:3px;gap:0;max-width:90vw;overflow-x:auto}.toolbar-icon-btn{width:26px;height:26px}.toolbar-divider{height:18px}}@media print{.rte-table,table{border:1px solid #000}.rte-table td,.rte-table th,table td,table th{border:1px solid #000;padding:4px}.table-toolbar{display:none}}
package/dist/table.cjs.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const $=require("./notify-BkbzMopb.js"),V=require("./editorContainerHelpers-CFbfiOJI.js");let h=null,b=null,B=null,N=null,D=null,q=null,P=null;const H='[data-theme="dark"], .dark, .editora-theme-dark';let E=!1,k=null,O=0,K=0,R=!1,_=0,W=0,X=0,F=0;const ee=new Set(["DIV","P","BLOCKQUOTE","PRE","H1","H2","H3","H4","H5","H6","LI","TD","TH"]);function U(e,t){let n=e;for(;n&&n!==t;){if(n.nodeType===Node.ELEMENT_NODE&&ee.has(n.tagName))return n;n=n.parentNode}return null}function Y(e){const t=e.parentElement;if(t&&t.classList.contains("rte-table-wrapper"))return t;const n=document.createElement("div");return n.className="rte-table-wrapper",t?.insertBefore(n,e),n.appendChild(e),n}const te=()=>{const e=V.findEditorContainerFromSelection(),t=V.getContentElement(e);if(!t)return $.notify("Please place your cursor in the editor before inserting a table"),!1;const n=window.getSelection();if(!n||n.rangeCount===0)return;const o=n.getRangeAt(0),l=document.createElement("table");l.className="rte-table";const r=document.createElement("thead"),a=document.createElement("tr");for(let m=0;m<3;m++){const g=document.createElement("th"),v=document.createElement("p");v.appendChild(document.createElement("br")),g.appendChild(v),a.appendChild(g)}r.appendChild(a);const i=document.createElement("tbody");for(let m=0;m<2;m++){const g=document.createElement("tr");for(let v=0;v<3;v++){const x=document.createElement("td"),A=document.createElement("p");A.appendChild(document.createElement("br")),x.appendChild(A),g.appendChild(x)}i.appendChild(g)}l.appendChild(r),l.appendChild(i);const u=Y(l),d=(m,g,v)=>{if(m!==t)return m;const x=v?g-1:g;return t.childNodes[Math.min(Math.max(x,0),t.childNodes.length-1)]||null},s=d(o.endContainer,o.endOffset,!0),c=d(o.startContainer,o.startOffset,!1),C=s&&U(s,t)||c&&U(c,t);C&&C.parentNode?C.parentNode.insertBefore(u,C.nextSibling):(o.collapse(!1),o.insertNode(u));const L=l.querySelector("th p");if(L){const m=document.createRange();m.setStart(L,0),m.collapse(!0),n.removeAllRanges(),n.addRange(m)}t.focus()},ne=()=>{const e=f();if(!e)return;const{table:t,rowIndex:n}=e,o=document.createElement("tr"),l=t.rows[0]?.cells.length||0;for(let a=0;a<l;a++){const i=document.createElement("td"),u=document.createElement("p");u.innerHTML="<br>",i.appendChild(u),o.appendChild(i)}const r=t.rows[n];r&&r.parentElement?r.parentElement.insertBefore(o,r):t.appendChild(o),p()},oe=()=>{const e=f();if(!e)return;const{table:t,rowIndex:n}=e,o=document.createElement("tr"),l=t.rows[0]?.cells.length||0;for(let r=0;r<l;r++){const a=document.createElement("td"),i=document.createElement("p");i.innerHTML="<br>",a.appendChild(i),o.appendChild(a)}if(n>=t.rows.length-1){const r=t.rows[t.rows.length-1];r&&r.parentElement?r.parentElement.appendChild(o):t.appendChild(o)}else{const r=t.rows[n+1];r.parentElement?.insertBefore(o,r)}p()},re=()=>{const e=f();if(!e)return;const{table:t,colIndex:n}=e;for(let o=0;o<t.rows.length;o++){const l=t.rows[o],r=document.createElement("td"),a=document.createElement("p");a.innerHTML="<br>",r.appendChild(a),n===0?l.insertBefore(r,l.cells[0]):l.insertBefore(r,l.cells[n])}p()},le=()=>{const e=f();if(!e)return;const{table:t,colIndex:n}=e;for(let o=0;o<t.rows.length;o++){const l=t.rows[o],r=document.createElement("td"),a=document.createElement("p");a.innerHTML="<br>",r.appendChild(a),n>=l.cells.length-1?l.appendChild(r):l.insertBefore(r,l.cells[n+1])}p()},ae=()=>{const e=f();if(!e||e.rowCount<=1)return;const{table:t,rowIndex:n,colIndex:o}=e;t.deleteRow(n),Q(t,n,o),p()},ie=()=>{const e=f();if(!e||e.cellCount<=1)return;const{table:t,rowIndex:n,colIndex:o}=e;for(let l=0;l<t.rows.length;l++){const r=t.rows[l];r.cells[o]&&r.deleteCell(o)}Q(t,n,o),p()},de=()=>{const e=f();if(!e)return;const{table:t,rowIndex:n}=e,o=t.rows[n];if(!o)return;const l=o.parentElement?.tagName.toLowerCase()==="thead",r=t.querySelector("thead");if(l){const a=o.parentElement;if(o===a.rows[a.rows.length-1]){const i=t.querySelector("tbody")||t.appendChild(document.createElement("tbody"));i.insertBefore(o,i.firstChild),a.rows.length===0&&a.remove()}else j(o,"td")}else if(!r||o===t.tBodies[0]?.rows[0]){let a=r;a||(a=document.createElement("thead"),t.insertBefore(a,t.firstChild)),a.appendChild(o)}else j(o,"th");p()};function j(e,t){Array.from(e.cells).forEach(n=>{if(n.tagName.toLowerCase()===t)return;const o=document.createElement(t);o.innerHTML=n.innerHTML;for(let l=0;l<n.attributes.length;l++){const r=n.attributes[l];o.setAttribute(r.name,r.value)}n.parentNode?.replaceChild(o,n)})}const se=()=>{const e=f();if(!e)return;const{table:t,colIndex:n}=e;for(let o=0;o<t.rows.length;o++){const l=t.rows[o].cells[n];if(l){const r=l.tagName.toLowerCase()==="th"?"td":"th",a=document.createElement(r);a.innerHTML=l.innerHTML;for(let i=0;i<l.attributes.length;i++){const u=l.attributes[i];a.setAttribute(u.name,u.value)}l.parentNode?.replaceChild(a,l)}}p()},ce=()=>{const e=f();if(!e)return;const t=e.table,n=t.parentElement;n&&n.classList.contains("rte-table-wrapper")?n.remove():t.remove(),document.dispatchEvent(new CustomEvent("tableDeleted"))};function w(e,t){if(!e||!(e instanceof Node))return null;const n=e.nodeType===Node.ELEMENT_NODE?e:e.parentElement;return n?n.closest(t):null}function I(e){if(!e)return!1;const t=e.closest("[contenteditable]");return!t||t.getAttribute("contenteditable")==="false"?!1:!t.closest('[data-readonly="true"]')}function ue(){const e=window.getSelection(),t=e&&e.rangeCount>0?e.getRangeAt(0).startContainer:null;return w(t,".rte-content")||(b?b.closest(".rte-content"):null)}function he(e,t,n){const o=window.execEditorCommand||window.executeEditorCommand;if(typeof o=="function")try{o("recordDomTransaction",e,t,n)}catch{}}function G(e){const t=ue();if(t&&!I(t))return;const n=t?t.innerHTML:"";if(e(),!t)return;const o=t.innerHTML;o!==n&&(he(t,n,o),t.dispatchEvent(new Event("input",{bubbles:!0})))}function Q(e,t,n){if(!e.isConnected||e.rows.length===0)return;const o=e.rows[Math.min(t,e.rows.length-1)],l=o.cells[Math.min(n,o.cells.length-1)];if(!l)return;const r=document.createRange(),a=l.querySelector("p, div, li")||l;r.selectNodeContents(a),r.collapse(!0);const i=window.getSelection();i?.removeAllRanges(),i?.addRange(r)}const be=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return;const n=e.getRangeAt(0).startContainer;if(!w(n,"table"))return;const o=w(n,"td, th");if(!o)return;const l=o.parentElement;if(!l)return;let r=-1;for(let d=0;d<l.cells.length;d++)if(l.cells[d]===o){r=d;break}if(r===-1||r===l.cells.length-1)return;const a=l.cells[r+1];if(!a)return;const i=(d,s)=>{const c=parseInt(d.getAttribute(s)||"1",10);return Number.isFinite(c)&&c>0?c:1};if(i(o,"rowspan")!==i(a,"rowspan"))return;o.setAttribute("colspan",String(i(o,"colspan")+i(a,"colspan"))),Array.from(a.childNodes).forEach(d=>{o.appendChild(d)}),a.remove(),p()};function f(){const e=window.getSelection();if(!e||e.rangeCount===0)return null;const n=e.getRangeAt(0).startContainer,o=w(n,"table");if(!o)return null;let l=0,r=0;const a=w(n,"td, th");if(a){const i=a.parentElement;for(;i&&i!==o.rows[l]&&(l++,!(l>=o.rows.length)););const u=i;if(u){for(let d=0;d<u.cells.length;d++)if(u.cells[d]===a){r=d;break}}}return{table:o,rowIndex:l,colIndex:r,rowCount:o.rows.length,cellCount:o.rows[0]?.cells.length||0}}function p(){if(!h||!b)return;const e=f();if(!e)return;const t=e.rowCount>1,n=e.cellCount>1;Z(t,n)}function me(e){const t=window.getSelection();if(!t)return;const n=document.createRange();(e.textContent??"").trim()===""?(n.selectNodeContents(e.querySelector("p, div")||e),n.collapse(!0)):n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n)}function fe(e){if(e.key!=="Tab"||e.defaultPrevented||e.ctrlKey||e.metaKey||e.altKey)return;const t=window.getSelection();if(!t||t.rangeCount===0)return;const n=w(t.getRangeAt(0).startContainer,"td, th"),o=n?.closest("table");if(!n||!o||!I(o))return;const l=o.closest("[contenteditable]");if(!l||!(e.target instanceof Node)||!l.contains(e.target))return;const r=Array.from(o.querySelectorAll("th, td")).filter(u=>u.closest("table")===o),a=r.indexOf(n);let i;e.shiftKey?i=r[a-1]:a<r.length-1?i=r[a+1]:(y("addRowBelow"),i=n.parentElement?.nextElementSibling?.querySelector("th, td")),i&&(e.preventDefault(),me(i))}function pe(){B=()=>{const e=f();e&&I(e.table)?ge(e.table):T()},N=e=>{const t=w(e.target,"table"),n=w(e.target,".table-toolbar");!t&&!n&&T()},D=()=>{T()},q=()=>{b&&h&&h.style.display!=="none"&&S(b)},P=()=>{b&&h&&h.style.display!=="none"&&S(b)},document.addEventListener("selectionchange",B),document.addEventListener("keydown",fe),document.addEventListener("mousedown",N),document.addEventListener("tableDeleted",D),window.addEventListener("scroll",q,!0),window.addEventListener("resize",P)}function S(e){if(!h)return;const t=e.getBoundingClientRect(),n=h.getBoundingClientRect(),o=n.height||40,l=n.width||280,r=10;let a=t.top-o-r,i=t.left+t.width/2-l/2;a<r&&(a=t.bottom+r),i<r&&(i=r);const u=window.innerWidth;i+l>u-r&&(i=u-l-r);const d=window.innerHeight;a+o>d-r&&(a=d-o-r),h.style.top=a+"px",h.style.left=i+"px"}function ge(e){b=e,h||(h=ve(),document.body.appendChild(h));const t=!!e.closest(H)||document.body.matches(H)||document.documentElement.matches(H);h.classList.toggle("rte-theme-dark",t),h.style.display="flex",h.style.visibility="hidden",requestAnimationFrame(()=>{S(e),h&&(h.style.visibility="visible")});const n=f();n&&Z(n.rowCount>1,n.cellCount>1),Ce(e)}const M=new Set;function J(){M.forEach(e=>{e.style.position==="relative"&&(e.style.removeProperty("position"),e.getAttribute("style")?.trim()||e.removeAttribute("style"))}),M.clear()}function T(){if(h&&(h.style.display="none"),b){b.querySelectorAll(".resize-handle").forEach(o=>o.remove());const t=b.parentElement,n=t?.classList.contains("rte-table-wrapper")?t.querySelector(".table-resize-handle"):b.querySelector(".table-resize-handle");n&&n.remove()}J(),b=null}function Z(e,t){if(!h)return;const n=h.querySelector('[data-action="deleteRow"]'),o=h.querySelector('[data-action="deleteColumn"]');n&&(n.disabled=!e),o&&(o.disabled=!t)}let z=!1;function we(){if(z||typeof document>"u")return;if(document.getElementById("rte-table-toolbar-styles")){z=!0;return}z=!0;const e=document.createElement("style");e.id="rte-table-toolbar-styles",e.textContent=`
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const $=require("./notify-BkbzMopb.js"),B=require("./editorContainerHelpers-CFbfiOJI.js");let h=null,b=null,V=null,N=null,D=null,q=null,O=null;const H='[data-theme="dark"], .dark, .editora-theme-dark';let E=!1,k=null,P=0,K=0,R=!1,_=0,W=0,X=0,F=0;const ee=new Set(["DIV","P","BLOCKQUOTE","PRE","H1","H2","H3","H4","H5","H6","LI","TD","TH"]);function U(e,t){let o=e;for(;o&&o!==t;){if(o.nodeType===Node.ELEMENT_NODE&&ee.has(o.tagName))return o;o=o.parentNode}return null}function Y(e){const t=e.parentElement;if(t&&t.classList.contains("rte-table-wrapper"))return t;const o=window.getSelection(),{anchorNode:n,anchorOffset:l,focusNode:r,focusOffset:a}=o??{},i=!!o&&!!n&&!!r&&(e.contains(n)||e.contains(r)),c=document.createElement("div");return c.className="rte-table-wrapper",t?.insertBefore(c,e),c.appendChild(e),i&&o&&n&&r&&n.isConnected&&r.isConnected&&o.setBaseAndExtent(n,l??0,r,a??0),c}const te=()=>{const e=B.findEditorContainerFromSelection(),t=B.getContentElement(e);if(!t)return $.notify("Please place your cursor in the editor before inserting a table"),!1;const o=window.getSelection();if(!o||o.rangeCount===0)return;const n=o.getRangeAt(0),l=document.createElement("table");l.className="rte-table";const r=document.createElement("thead"),a=document.createElement("tr");for(let m=0;m<3;m++){const g=document.createElement("th"),v=document.createElement("p");v.appendChild(document.createElement("br")),g.appendChild(v),a.appendChild(g)}r.appendChild(a);const i=document.createElement("tbody");for(let m=0;m<2;m++){const g=document.createElement("tr");for(let v=0;v<3;v++){const x=document.createElement("td"),A=document.createElement("p");A.appendChild(document.createElement("br")),x.appendChild(A),g.appendChild(x)}i.appendChild(g)}l.appendChild(r),l.appendChild(i);const c=Y(l),d=(m,g,v)=>{if(m!==t)return m;const x=v?g-1:g;return t.childNodes[Math.min(Math.max(x,0),t.childNodes.length-1)]||null},s=d(n.endContainer,n.endOffset,!0),u=d(n.startContainer,n.startOffset,!1),C=s&&U(s,t)||u&&U(u,t);C&&C.parentNode?C.parentNode.insertBefore(c,C.nextSibling):(n.collapse(!1),n.insertNode(c));const L=l.querySelector("th p");if(L){const m=document.createRange();m.setStart(L,0),m.collapse(!0),o.removeAllRanges(),o.addRange(m)}t.focus()},ne=()=>{const e=f();if(!e)return;const{table:t,rowIndex:o}=e,n=document.createElement("tr"),l=t.rows[0]?.cells.length||0;for(let a=0;a<l;a++){const i=document.createElement("td"),c=document.createElement("p");c.innerHTML="<br>",i.appendChild(c),n.appendChild(i)}const r=t.rows[o];r&&r.parentElement?r.parentElement.insertBefore(n,r):t.appendChild(n),p()},oe=()=>{const e=f();if(!e)return;const{table:t,rowIndex:o}=e,n=document.createElement("tr"),l=t.rows[0]?.cells.length||0;for(let r=0;r<l;r++){const a=document.createElement("td"),i=document.createElement("p");i.innerHTML="<br>",a.appendChild(i),n.appendChild(a)}if(o>=t.rows.length-1){const r=t.rows[t.rows.length-1];r&&r.parentElement?r.parentElement.appendChild(n):t.appendChild(n)}else{const r=t.rows[o+1];r.parentElement?.insertBefore(n,r)}p()},re=()=>{const e=f();if(!e)return;const{table:t,colIndex:o}=e;for(let n=0;n<t.rows.length;n++){const l=t.rows[n],r=document.createElement("td"),a=document.createElement("p");a.innerHTML="<br>",r.appendChild(a),o===0?l.insertBefore(r,l.cells[0]):l.insertBefore(r,l.cells[o])}p()},le=()=>{const e=f();if(!e)return;const{table:t,colIndex:o}=e;for(let n=0;n<t.rows.length;n++){const l=t.rows[n],r=document.createElement("td"),a=document.createElement("p");a.innerHTML="<br>",r.appendChild(a),o>=l.cells.length-1?l.appendChild(r):l.insertBefore(r,l.cells[o+1])}p()},ae=()=>{const e=f();if(!e||e.rowCount<=1)return;const{table:t,rowIndex:o,colIndex:n}=e;t.deleteRow(o),Q(t,o,n),p()},ie=()=>{const e=f();if(!e||e.cellCount<=1)return;const{table:t,rowIndex:o,colIndex:n}=e;for(let l=0;l<t.rows.length;l++){const r=t.rows[l];r.cells[n]&&r.deleteCell(n)}Q(t,o,n),p()},de=()=>{const e=f();if(!e)return;const{table:t,rowIndex:o}=e,n=t.rows[o];if(!n)return;const l=n.parentElement?.tagName.toLowerCase()==="thead",r=t.querySelector("thead");if(l){const a=n.parentElement;if(n===a.rows[a.rows.length-1]){const i=t.querySelector("tbody")||t.appendChild(document.createElement("tbody"));i.insertBefore(n,i.firstChild),a.rows.length===0&&a.remove()}else j(n,"td")}else if(!r||n===t.tBodies[0]?.rows[0]){let a=r;a||(a=document.createElement("thead"),t.insertBefore(a,t.firstChild)),a.appendChild(n)}else j(n,"th");p()};function j(e,t){Array.from(e.cells).forEach(o=>{if(o.tagName.toLowerCase()===t)return;const n=document.createElement(t);n.innerHTML=o.innerHTML;for(let l=0;l<o.attributes.length;l++){const r=o.attributes[l];n.setAttribute(r.name,r.value)}o.parentNode?.replaceChild(n,o)})}const se=()=>{const e=f();if(!e)return;const{table:t,colIndex:o}=e;for(let n=0;n<t.rows.length;n++){const l=t.rows[n].cells[o];if(l){const r=l.tagName.toLowerCase()==="th"?"td":"th",a=document.createElement(r);a.innerHTML=l.innerHTML;for(let i=0;i<l.attributes.length;i++){const c=l.attributes[i];a.setAttribute(c.name,c.value)}l.parentNode?.replaceChild(a,l)}}p()},ce=()=>{const e=f();if(!e)return;const t=e.table,o=t.parentElement;o&&o.classList.contains("rte-table-wrapper")?o.remove():t.remove(),document.dispatchEvent(new CustomEvent("tableDeleted"))};function w(e,t){if(!e||!(e instanceof Node))return null;const o=e.nodeType===Node.ELEMENT_NODE?e:e.parentElement;return o?o.closest(t):null}function I(e){if(!e)return!1;const t=e.closest("[contenteditable]");return!t||t.getAttribute("contenteditable")==="false"?!1:!t.closest('[data-readonly="true"]')}function ue(){const e=window.getSelection(),t=e&&e.rangeCount>0?e.getRangeAt(0).startContainer:null;return w(t,".rte-content")||(b?b.closest(".rte-content"):null)}function he(e,t,o){const n=window.execEditorCommand||window.executeEditorCommand;if(typeof n=="function")try{n("recordDomTransaction",e,t,o)}catch{}}function G(e){const t=ue();if(t&&!I(t))return;const o=t?t.innerHTML:"";if(e(),!t)return;const n=t.innerHTML;n!==o&&(he(t,o,n),t.dispatchEvent(new Event("input",{bubbles:!0})))}function Q(e,t,o){if(!e.isConnected||e.rows.length===0)return;const n=e.rows[Math.min(t,e.rows.length-1)],l=n.cells[Math.min(o,n.cells.length-1)];if(!l)return;const r=document.createRange(),a=l.querySelector("p, div, li")||l;r.selectNodeContents(a),r.collapse(!0);const i=window.getSelection();i?.removeAllRanges(),i?.addRange(r)}const be=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return;const o=e.getRangeAt(0).startContainer;if(!w(o,"table"))return;const n=w(o,"td, th");if(!n)return;const l=n.parentElement;if(!l)return;let r=-1;for(let d=0;d<l.cells.length;d++)if(l.cells[d]===n){r=d;break}if(r===-1||r===l.cells.length-1)return;const a=l.cells[r+1];if(!a)return;const i=(d,s)=>{const u=parseInt(d.getAttribute(s)||"1",10);return Number.isFinite(u)&&u>0?u:1};if(i(n,"rowspan")!==i(a,"rowspan"))return;n.setAttribute("colspan",String(i(n,"colspan")+i(a,"colspan"))),Array.from(a.childNodes).forEach(d=>{n.appendChild(d)}),a.remove(),p()};function f(){const e=window.getSelection();if(!e||e.rangeCount===0)return null;const o=e.getRangeAt(0).startContainer,n=w(o,"table");if(!n)return null;let l=0,r=0;const a=w(o,"td, th");if(a){const i=a.parentElement;for(;i&&i!==n.rows[l]&&(l++,!(l>=n.rows.length)););const c=i;if(c){for(let d=0;d<c.cells.length;d++)if(c.cells[d]===a){r=d;break}}}return{table:n,rowIndex:l,colIndex:r,rowCount:n.rows.length,cellCount:n.rows[0]?.cells.length||0}}function p(){if(!h||!b)return;const e=f();if(!e)return;const t=e.rowCount>1,o=e.cellCount>1;Z(t,o)}function me(e){const t=window.getSelection();if(!t)return;const o=document.createRange();(e.textContent??"").trim()===""?(o.selectNodeContents(e.querySelector("p, div")||e),o.collapse(!0)):o.selectNodeContents(e),t.removeAllRanges(),t.addRange(o)}function fe(e){if(e.key!=="Tab"||e.defaultPrevented||e.ctrlKey||e.metaKey||e.altKey)return;const t=window.getSelection();if(!t||t.rangeCount===0)return;const o=w(t.getRangeAt(0).startContainer,"td, th"),n=o?.closest("table");if(!o||!n||!I(n))return;const l=n.closest("[contenteditable]");if(!l||!(e.target instanceof Node)||!l.contains(e.target))return;const r=Array.from(n.querySelectorAll("th, td")).filter(c=>c.closest("table")===n),a=r.indexOf(o);let i;e.shiftKey?i=r[a-1]:a<r.length-1?i=r[a+1]:(y("addRowBelow"),i=o.parentElement?.nextElementSibling?.querySelector("th, td")),i&&(e.preventDefault(),me(i))}function pe(){V=()=>{const e=f();e&&I(e.table)?ge(e.table):T()},N=e=>{const t=w(e.target,"table"),o=w(e.target,".table-toolbar");!t&&!o&&T()},D=()=>{T()},q=()=>{b&&h&&h.style.display!=="none"&&S(b)},O=()=>{b&&h&&h.style.display!=="none"&&S(b)},document.addEventListener("selectionchange",V),document.addEventListener("keydown",fe),document.addEventListener("mousedown",N),document.addEventListener("tableDeleted",D),window.addEventListener("scroll",q,!0),window.addEventListener("resize",O)}function S(e){if(!h)return;const t=e.getBoundingClientRect(),o=h.getBoundingClientRect(),n=o.height||40,l=o.width||280,r=10;let a=t.top-n-r,i=t.left+t.width/2-l/2;a<r&&(a=t.bottom+r),i<r&&(i=r);const c=window.innerWidth;i+l>c-r&&(i=c-l-r);const d=window.innerHeight;a+n>d-r&&(a=d-n-r),h.style.top=a+"px",h.style.left=i+"px"}function ge(e){b=e,h||(h=ve(),document.body.appendChild(h));const t=!!e.closest(H)||document.body.matches(H)||document.documentElement.matches(H);h.classList.toggle("rte-theme-dark",t),h.style.display="flex",h.style.visibility="hidden",requestAnimationFrame(()=>{S(e),h&&(h.style.visibility="visible")});const o=f();o&&Z(o.rowCount>1,o.cellCount>1),Ce(e)}const M=new Set;function J(){M.forEach(e=>{e.style.position==="relative"&&(e.style.removeProperty("position"),e.getAttribute("style")?.trim()||e.removeAttribute("style"))}),M.clear()}function T(){if(h&&(h.style.display="none"),b){b.querySelectorAll(".resize-handle").forEach(n=>n.remove());const t=b.parentElement,o=t?.classList.contains("rte-table-wrapper")?t.querySelector(".table-resize-handle"):b.querySelector(".table-resize-handle");o&&o.remove()}J(),b=null}function Z(e,t){if(!h)return;const o=h.querySelector('[data-action="deleteRow"]'),n=h.querySelector('[data-action="deleteColumn"]');o&&(o.disabled=!e),n&&(n.disabled=!t)}let z=!1;function we(){if(z||typeof document>"u")return;if(document.getElementById("rte-table-toolbar-styles")){z=!0;return}z=!0;const e=document.createElement("style");e.id="rte-table-toolbar-styles",e.textContent=`
2
2
  .table-toolbar {
3
3
  background: white;
4
4
  border: 1px solid #d0d0d0;
@@ -155,7 +155,7 @@
155
155
  position: fixed;
156
156
  z-index: 1000;
157
157
  display: none;
158
- `,e.setAttribute("role","toolbar"),e.setAttribute("aria-label","Table editing toolbar");const t=s=>{const c=document.createElement("button");return c.className="toolbar-icon-btn",s.danger&&c.classList.add("toolbar-icon-btn-danger"),s.delete&&c.classList.add("toolbar-icon-btn-delete"),c.innerHTML=s.icon,c.title=s.title,c.setAttribute("aria-label",s.title),c.setAttribute("type","button"),c.setAttribute("data-action",s.action),c.onclick=()=>y(s.action),c},n=()=>{const s=document.createElement("div");return s.className="toolbar-divider",s},o=(...s)=>{const c=document.createElement("div");return c.className="toolbar-section",s.forEach(C=>c.appendChild(C)),c},l=o(t({icon:Ee(),title:"Add row above (Ctrl+Shift+R)",action:"addRowAbove"}),t({icon:xe(),title:"Add row below",action:"addRowBelow"}),t({icon:He(),title:"Delete row",action:"deleteRow",danger:!0})),r=o(t({icon:Re(),title:"Add column left",action:"addColumnLeft"}),t({icon:Te(),title:"Add column right (Ctrl+Shift+C)",action:"addColumnRight"}),t({icon:ze(),title:"Delete column",action:"deleteColumn",danger:!0})),a=o(t({icon:Se(),title:"Toggle header row",action:"toggleHeaderRow"}),t({icon:Me(),title:"Toggle header column",action:"toggleHeaderColumn"})),i=o(t({icon:Le(),title:"Merge cells (horizontally)",action:"mergeCells"})),u=o(t({icon:Ie(),title:"Delete table",action:"deleteTable",delete:!0}));e.appendChild(l),e.appendChild(n()),e.appendChild(r),e.appendChild(n()),e.appendChild(a),e.appendChild(n()),e.appendChild(i),e.appendChild(n()),e.appendChild(u);const d=s=>{!h||h.style.display==="none"||(s.ctrlKey||s.metaKey)&&s.shiftKey&&(s.key==="r"||s.key==="R"?(s.preventDefault(),y("addRowBelow")):(s.key==="c"||s.key==="C")&&(s.preventDefault(),y("addColumnRight")))};return window.addEventListener("keydown",d),e}function y(e){G(()=>{switch(e){case"addRowAbove":ne();break;case"addRowBelow":oe();break;case"addColumnLeft":re();break;case"addColumnRight":le();break;case"deleteRow":ae();break;case"deleteColumn":ie();break;case"toggleHeaderRow":de();break;case"toggleHeaderColumn":se();break;case"deleteTable":ce();break;case"mergeCells":be();break}})}function Ce(e){const t=Y(e);e.querySelectorAll(".resize-handle").forEach(i=>i.remove());const o=t.querySelector(".table-resize-handle");o&&o.remove(),J();const l=e.querySelector("thead tr, tbody tr:first-child");if(!l)return;const r=l.querySelectorAll("td, th");r.forEach((i,u)=>{if(u===r.length-1)return;const d=document.createElement("div");d.className="resize-handle",d.style.cssText=`
158
+ `,e.setAttribute("role","toolbar"),e.setAttribute("aria-label","Table editing toolbar");const t=s=>{const u=document.createElement("button");return u.className="toolbar-icon-btn",s.danger&&u.classList.add("toolbar-icon-btn-danger"),s.delete&&u.classList.add("toolbar-icon-btn-delete"),u.innerHTML=s.icon,u.title=s.title,u.setAttribute("aria-label",s.title),u.setAttribute("type","button"),u.setAttribute("data-action",s.action),u.onclick=()=>y(s.action),u},o=()=>{const s=document.createElement("div");return s.className="toolbar-divider",s},n=(...s)=>{const u=document.createElement("div");return u.className="toolbar-section",s.forEach(C=>u.appendChild(C)),u},l=n(t({icon:Ee(),title:"Add row above (Ctrl+Shift+R)",action:"addRowAbove"}),t({icon:xe(),title:"Add row below",action:"addRowBelow"}),t({icon:He(),title:"Delete row",action:"deleteRow",danger:!0})),r=n(t({icon:Re(),title:"Add column left",action:"addColumnLeft"}),t({icon:Te(),title:"Add column right (Ctrl+Shift+C)",action:"addColumnRight"}),t({icon:ze(),title:"Delete column",action:"deleteColumn",danger:!0})),a=n(t({icon:Se(),title:"Toggle header row",action:"toggleHeaderRow"}),t({icon:Me(),title:"Toggle header column",action:"toggleHeaderColumn"})),i=n(t({icon:Le(),title:"Merge cells (horizontally)",action:"mergeCells"})),c=n(t({icon:Ie(),title:"Delete table",action:"deleteTable",delete:!0}));e.appendChild(l),e.appendChild(o()),e.appendChild(r),e.appendChild(o()),e.appendChild(a),e.appendChild(o()),e.appendChild(i),e.appendChild(o()),e.appendChild(c);const d=s=>{!h||h.style.display==="none"||(s.ctrlKey||s.metaKey)&&s.shiftKey&&(s.key==="r"||s.key==="R"?(s.preventDefault(),y("addRowBelow")):(s.key==="c"||s.key==="C")&&(s.preventDefault(),y("addColumnRight")))};return window.addEventListener("keydown",d),e}function y(e){G(()=>{switch(e){case"addRowAbove":ne();break;case"addRowBelow":oe();break;case"addColumnLeft":re();break;case"addColumnRight":le();break;case"deleteRow":ae();break;case"deleteColumn":ie();break;case"toggleHeaderRow":de();break;case"toggleHeaderColumn":se();break;case"deleteTable":ce();break;case"mergeCells":be();break}})}function Ce(e){const t=Y(e);e.querySelectorAll(".resize-handle").forEach(i=>i.remove());const n=t.querySelector(".table-resize-handle");n&&n.remove(),J();const l=e.querySelector("thead tr, tbody tr:first-child");if(!l)return;const r=l.querySelectorAll("td, th");r.forEach((i,c)=>{if(c===r.length-1)return;const d=document.createElement("div");d.className="resize-handle",d.style.cssText=`
159
159
  position: absolute;
160
160
  right: -4px;
161
161
  top: 0;
@@ -165,7 +165,7 @@
165
165
  cursor: col-resize;
166
166
  z-index: 10;
167
167
  transition: background 0.15s ease;
168
- `,d.addEventListener("mouseenter",()=>{E||(d.style.background="rgba(0, 102, 204, 0.3)")}),d.addEventListener("mouseleave",()=>{E||(d.style.background="transparent")}),d.addEventListener("mousedown",c=>{c.preventDefault(),c.stopPropagation(),ye(c,u)});const s=i;s.style.position||(s.style.position="relative",M.add(s)),i.appendChild(d)});const a=document.createElement("div");a.className="table-resize-handle",a.addEventListener("mousedown",i=>{i.preventDefault(),i.stopPropagation(),ke(i)}),t.appendChild(a)}function ye(e,t){if(E=!0,k=t,O=e.clientX,!b)return;const n=b.querySelector("thead tr, tbody tr:first-child");n&&n.cells[t]&&(K=n.cells[t].offsetWidth),document.body.style.cursor="col-resize",document.body.style.userSelect="none";const o=r=>{if(!E||k===null||!b)return;const a=r.clientX-O,i=Math.max(50,K+a);b.querySelectorAll("tr").forEach(d=>{d.cells[k]&&(d.cells[k].style.width=i+"px")})},l=()=>{E=!1,k=null,document.body.style.cursor="",document.body.style.userSelect="",document.removeEventListener("mousemove",o),document.removeEventListener("mouseup",l)};document.addEventListener("mousemove",o),document.addEventListener("mouseup",l)}function ke(e){if(!b)return;R=!0,_=e.clientX,W=e.clientY,X=b.offsetWidth,F=b.offsetHeight,document.body.style.cursor="nwse-resize",document.body.style.userSelect="none";const t=o=>{if(!R||!b)return;const l=o.clientX-_,r=o.clientY-W,a=Math.max(200,X+l),i=Math.max(100,F+r);b.style.width=a+"px",b.style.height=i+"px"},n=()=>{R=!1,document.body.style.cursor="",document.body.style.userSelect="",document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",n)};document.addEventListener("mousemove",t),document.addEventListener("mouseup",n)}function Ee(){return`<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
168
+ `,d.addEventListener("mouseenter",()=>{E||(d.style.background="rgba(0, 102, 204, 0.3)")}),d.addEventListener("mouseleave",()=>{E||(d.style.background="transparent")}),d.addEventListener("mousedown",u=>{u.preventDefault(),u.stopPropagation(),ye(u,c)});const s=i;s.style.position||(s.style.position="relative",M.add(s)),i.appendChild(d)});const a=document.createElement("div");a.className="table-resize-handle",a.addEventListener("mousedown",i=>{i.preventDefault(),i.stopPropagation(),ke(i)}),t.appendChild(a)}function ye(e,t){if(E=!0,k=t,P=e.clientX,!b)return;const o=b.querySelector("thead tr, tbody tr:first-child");o&&o.cells[t]&&(K=o.cells[t].offsetWidth),document.body.style.cursor="col-resize",document.body.style.userSelect="none";const n=r=>{if(!E||k===null||!b)return;const a=r.clientX-P,i=Math.max(50,K+a);b.querySelectorAll("tr").forEach(d=>{d.cells[k]&&(d.cells[k].style.width=i+"px")})},l=()=>{E=!1,k=null,document.body.style.cursor="",document.body.style.userSelect="",document.removeEventListener("mousemove",n),document.removeEventListener("mouseup",l)};document.addEventListener("mousemove",n),document.addEventListener("mouseup",l)}function ke(e){if(!b)return;R=!0,_=e.clientX,W=e.clientY,X=b.offsetWidth,F=b.offsetHeight,document.body.style.cursor="nwse-resize",document.body.style.userSelect="none";const t=n=>{if(!R||!b)return;const l=n.clientX-_,r=n.clientY-W,a=Math.max(200,X+l),i=Math.max(100,F+r);b.style.width=a+"px",b.style.height=i+"px"},o=()=>{R=!1,document.body.style.cursor="",document.body.style.userSelect="",document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",o)};document.addEventListener("mousemove",t),document.addEventListener("mouseup",o)}function Ee(){return`<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
169
169
  <path d="M2 7h12V5H2v2zm0 4h12V9H2v2zM8 1v3H5v2h3v3h2V6h3V4h-3V1H8z"/>
170
170
  </svg>`}function xe(){return`<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
171
171
  <path d="M2 3h12V1H2v2zm0 4h12V5H2v2zm6 4v3h3v-2h2v-2h-2v-3h-2v3H5v2h3z"/>
package/dist/table.esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { n as Z } from "./notify-zOp-mUOJ.mjs";
2
2
  import { f as $, g as ee } from "./editorContainerHelpers-C7kdWnS0.mjs";
3
- let h = null, b = null, V = null, B = null, N = null, D = null, q = null;
3
+ let h = null, b = null, B = null, V = null, N = null, D = null, q = null;
4
4
  const H = '[data-theme="dark"], .dark, .editora-theme-dark';
5
5
  let E = !1, k = null, O = 0, P = 0, R = !1, K = 0, W = 0, _ = 0, X = 0;
6
6
  const te = /* @__PURE__ */ new Set([
@@ -19,11 +19,11 @@ const te = /* @__PURE__ */ new Set([
19
19
  "TH"
20
20
  ]);
21
21
  function F(e, t) {
22
- let n = e;
23
- for (; n && n !== t; ) {
24
- if (n.nodeType === Node.ELEMENT_NODE && te.has(n.tagName))
25
- return n;
26
- n = n.parentNode;
22
+ let o = e;
23
+ for (; o && o !== t; ) {
24
+ if (o.nodeType === Node.ELEMENT_NODE && te.has(o.tagName))
25
+ return o;
26
+ o = o.parentNode;
27
27
  }
28
28
  return null;
29
29
  }
@@ -31,16 +31,16 @@ function Y(e) {
31
31
  const t = e.parentElement;
32
32
  if (t && t.classList.contains("rte-table-wrapper"))
33
33
  return t;
34
- const n = document.createElement("div");
35
- return n.className = "rte-table-wrapper", t?.insertBefore(n, e), n.appendChild(e), n;
34
+ const o = window.getSelection(), { anchorNode: n, anchorOffset: l, focusNode: r, focusOffset: a } = o ?? {}, i = !!o && !!n && !!r && (e.contains(n) || e.contains(r)), c = document.createElement("div");
35
+ return c.className = "rte-table-wrapper", t?.insertBefore(c, e), c.appendChild(e), i && o && n && r && n.isConnected && r.isConnected && o.setBaseAndExtent(n, l ?? 0, r, a ?? 0), c;
36
36
  }
37
37
  const ne = () => {
38
38
  const e = $(), t = ee(e);
39
39
  if (!t)
40
40
  return Z("Please place your cursor in the editor before inserting a table"), !1;
41
- const n = window.getSelection();
42
- if (!n || n.rangeCount === 0) return;
43
- const o = n.getRangeAt(0), l = document.createElement("table");
41
+ const o = window.getSelection();
42
+ if (!o || o.rangeCount === 0) return;
43
+ const n = o.getRangeAt(0), l = document.createElement("table");
44
44
  l.className = "rte-table";
45
45
  const r = document.createElement("thead"), a = document.createElement("tr");
46
46
  for (let m = 0; m < 3; m++) {
@@ -58,120 +58,120 @@ const ne = () => {
58
58
  i.appendChild(g);
59
59
  }
60
60
  l.appendChild(r), l.appendChild(i);
61
- const u = Y(l), d = (m, g, v) => {
61
+ const c = Y(l), d = (m, g, v) => {
62
62
  if (m !== t) return m;
63
63
  const x = v ? g - 1 : g;
64
64
  return t.childNodes[Math.min(Math.max(x, 0), t.childNodes.length - 1)] || null;
65
- }, s = d(o.endContainer, o.endOffset, !0), c = d(o.startContainer, o.startOffset, !1), C = s && F(s, t) || c && F(c, t);
66
- C && C.parentNode ? C.parentNode.insertBefore(u, C.nextSibling) : (o.collapse(!1), o.insertNode(u));
65
+ }, s = d(n.endContainer, n.endOffset, !0), u = d(n.startContainer, n.startOffset, !1), C = s && F(s, t) || u && F(u, t);
66
+ C && C.parentNode ? C.parentNode.insertBefore(c, C.nextSibling) : (n.collapse(!1), n.insertNode(c));
67
67
  const L = l.querySelector("th p");
68
68
  if (L) {
69
69
  const m = document.createRange();
70
- m.setStart(L, 0), m.collapse(!0), n.removeAllRanges(), n.addRange(m);
70
+ m.setStart(L, 0), m.collapse(!0), o.removeAllRanges(), o.addRange(m);
71
71
  }
72
72
  t.focus();
73
73
  }, oe = () => {
74
74
  const e = f();
75
75
  if (!e) return;
76
- const { table: t, rowIndex: n } = e, o = document.createElement("tr"), l = t.rows[0]?.cells.length || 0;
76
+ const { table: t, rowIndex: o } = e, n = document.createElement("tr"), l = t.rows[0]?.cells.length || 0;
77
77
  for (let a = 0; a < l; a++) {
78
- const i = document.createElement("td"), u = document.createElement("p");
79
- u.innerHTML = "<br>", i.appendChild(u), o.appendChild(i);
78
+ const i = document.createElement("td"), c = document.createElement("p");
79
+ c.innerHTML = "<br>", i.appendChild(c), n.appendChild(i);
80
80
  }
81
- const r = t.rows[n];
82
- r && r.parentElement ? r.parentElement.insertBefore(o, r) : t.appendChild(o), p();
81
+ const r = t.rows[o];
82
+ r && r.parentElement ? r.parentElement.insertBefore(n, r) : t.appendChild(n), p();
83
83
  }, re = () => {
84
84
  const e = f();
85
85
  if (!e) return;
86
- const { table: t, rowIndex: n } = e, o = document.createElement("tr"), l = t.rows[0]?.cells.length || 0;
86
+ const { table: t, rowIndex: o } = e, n = document.createElement("tr"), l = t.rows[0]?.cells.length || 0;
87
87
  for (let r = 0; r < l; r++) {
88
88
  const a = document.createElement("td"), i = document.createElement("p");
89
- i.innerHTML = "<br>", a.appendChild(i), o.appendChild(a);
89
+ i.innerHTML = "<br>", a.appendChild(i), n.appendChild(a);
90
90
  }
91
- if (n >= t.rows.length - 1) {
91
+ if (o >= t.rows.length - 1) {
92
92
  const r = t.rows[t.rows.length - 1];
93
- r && r.parentElement ? r.parentElement.appendChild(o) : t.appendChild(o);
93
+ r && r.parentElement ? r.parentElement.appendChild(n) : t.appendChild(n);
94
94
  } else {
95
- const r = t.rows[n + 1];
96
- r.parentElement?.insertBefore(o, r);
95
+ const r = t.rows[o + 1];
96
+ r.parentElement?.insertBefore(n, r);
97
97
  }
98
98
  p();
99
99
  }, le = () => {
100
100
  const e = f();
101
101
  if (!e) return;
102
- const { table: t, colIndex: n } = e;
103
- for (let o = 0; o < t.rows.length; o++) {
104
- const l = t.rows[o], r = document.createElement("td"), a = document.createElement("p");
105
- a.innerHTML = "<br>", r.appendChild(a), n === 0 ? l.insertBefore(r, l.cells[0]) : l.insertBefore(r, l.cells[n]);
102
+ const { table: t, colIndex: o } = e;
103
+ for (let n = 0; n < t.rows.length; n++) {
104
+ const l = t.rows[n], r = document.createElement("td"), a = document.createElement("p");
105
+ a.innerHTML = "<br>", r.appendChild(a), o === 0 ? l.insertBefore(r, l.cells[0]) : l.insertBefore(r, l.cells[o]);
106
106
  }
107
107
  p();
108
108
  }, ae = () => {
109
109
  const e = f();
110
110
  if (!e) return;
111
- const { table: t, colIndex: n } = e;
112
- for (let o = 0; o < t.rows.length; o++) {
113
- const l = t.rows[o], r = document.createElement("td"), a = document.createElement("p");
114
- a.innerHTML = "<br>", r.appendChild(a), n >= l.cells.length - 1 ? l.appendChild(r) : l.insertBefore(r, l.cells[n + 1]);
111
+ const { table: t, colIndex: o } = e;
112
+ for (let n = 0; n < t.rows.length; n++) {
113
+ const l = t.rows[n], r = document.createElement("td"), a = document.createElement("p");
114
+ a.innerHTML = "<br>", r.appendChild(a), o >= l.cells.length - 1 ? l.appendChild(r) : l.insertBefore(r, l.cells[o + 1]);
115
115
  }
116
116
  p();
117
117
  }, ie = () => {
118
118
  const e = f();
119
119
  if (!e || e.rowCount <= 1) return;
120
- const { table: t, rowIndex: n, colIndex: o } = e;
121
- t.deleteRow(n), G(t, n, o), p();
120
+ const { table: t, rowIndex: o, colIndex: n } = e;
121
+ t.deleteRow(o), G(t, o, n), p();
122
122
  }, de = () => {
123
123
  const e = f();
124
124
  if (!e || e.cellCount <= 1) return;
125
- const { table: t, rowIndex: n, colIndex: o } = e;
125
+ const { table: t, rowIndex: o, colIndex: n } = e;
126
126
  for (let l = 0; l < t.rows.length; l++) {
127
127
  const r = t.rows[l];
128
- r.cells[o] && r.deleteCell(o);
128
+ r.cells[n] && r.deleteCell(n);
129
129
  }
130
- G(t, n, o), p();
130
+ G(t, o, n), p();
131
131
  }, se = () => {
132
132
  const e = f();
133
133
  if (!e) return;
134
- const { table: t, rowIndex: n } = e, o = t.rows[n];
135
- if (!o) return;
136
- const l = o.parentElement?.tagName.toLowerCase() === "thead", r = t.querySelector("thead");
134
+ const { table: t, rowIndex: o } = e, n = t.rows[o];
135
+ if (!n) return;
136
+ const l = n.parentElement?.tagName.toLowerCase() === "thead", r = t.querySelector("thead");
137
137
  if (l) {
138
- const a = o.parentElement;
139
- if (o === a.rows[a.rows.length - 1]) {
138
+ const a = n.parentElement;
139
+ if (n === a.rows[a.rows.length - 1]) {
140
140
  const i = t.querySelector("tbody") || t.appendChild(document.createElement("tbody"));
141
- i.insertBefore(o, i.firstChild), a.rows.length === 0 && a.remove();
141
+ i.insertBefore(n, i.firstChild), a.rows.length === 0 && a.remove();
142
142
  } else
143
- U(o, "td");
144
- } else if (!r || o === t.tBodies[0]?.rows[0]) {
143
+ U(n, "td");
144
+ } else if (!r || n === t.tBodies[0]?.rows[0]) {
145
145
  let a = r;
146
- a || (a = document.createElement("thead"), t.insertBefore(a, t.firstChild)), a.appendChild(o);
146
+ a || (a = document.createElement("thead"), t.insertBefore(a, t.firstChild)), a.appendChild(n);
147
147
  } else
148
- U(o, "th");
148
+ U(n, "th");
149
149
  p();
150
150
  };
151
151
  function U(e, t) {
152
- Array.from(e.cells).forEach((n) => {
153
- if (n.tagName.toLowerCase() === t) return;
154
- const o = document.createElement(t);
155
- o.innerHTML = n.innerHTML;
156
- for (let l = 0; l < n.attributes.length; l++) {
157
- const r = n.attributes[l];
158
- o.setAttribute(r.name, r.value);
159
- }
160
- n.parentNode?.replaceChild(o, n);
152
+ Array.from(e.cells).forEach((o) => {
153
+ if (o.tagName.toLowerCase() === t) return;
154
+ const n = document.createElement(t);
155
+ n.innerHTML = o.innerHTML;
156
+ for (let l = 0; l < o.attributes.length; l++) {
157
+ const r = o.attributes[l];
158
+ n.setAttribute(r.name, r.value);
159
+ }
160
+ o.parentNode?.replaceChild(n, o);
161
161
  });
162
162
  }
163
163
  const ce = () => {
164
164
  const e = f();
165
165
  if (!e) return;
166
- const { table: t, colIndex: n } = e;
167
- for (let o = 0; o < t.rows.length; o++) {
168
- const l = t.rows[o].cells[n];
166
+ const { table: t, colIndex: o } = e;
167
+ for (let n = 0; n < t.rows.length; n++) {
168
+ const l = t.rows[n].cells[o];
169
169
  if (l) {
170
170
  const r = l.tagName.toLowerCase() === "th" ? "td" : "th", a = document.createElement(r);
171
171
  a.innerHTML = l.innerHTML;
172
172
  for (let i = 0; i < l.attributes.length; i++) {
173
- const u = l.attributes[i];
174
- a.setAttribute(u.name, u.value);
173
+ const c = l.attributes[i];
174
+ a.setAttribute(c.name, c.value);
175
175
  }
176
176
  l.parentNode?.replaceChild(a, l);
177
177
  }
@@ -180,13 +180,13 @@ const ce = () => {
180
180
  }, ue = () => {
181
181
  const e = f();
182
182
  if (!e) return;
183
- const t = e.table, n = t.parentElement;
184
- n && n.classList.contains("rte-table-wrapper") ? n.remove() : t.remove(), document.dispatchEvent(new CustomEvent("tableDeleted"));
183
+ const t = e.table, o = t.parentElement;
184
+ o && o.classList.contains("rte-table-wrapper") ? o.remove() : t.remove(), document.dispatchEvent(new CustomEvent("tableDeleted"));
185
185
  };
186
186
  function w(e, t) {
187
187
  if (!e || !(e instanceof Node)) return null;
188
- const n = e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement;
189
- return n ? n.closest(t) : null;
188
+ const o = e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement;
189
+ return o ? o.closest(t) : null;
190
190
  }
191
191
  function M(e) {
192
192
  if (!e) return !1;
@@ -197,25 +197,25 @@ function he() {
197
197
  const e = window.getSelection(), t = e && e.rangeCount > 0 ? e.getRangeAt(0).startContainer : null;
198
198
  return w(t, ".rte-content") || (b ? b.closest(".rte-content") : null);
199
199
  }
200
- function be(e, t, n) {
201
- const o = window.execEditorCommand || window.executeEditorCommand;
202
- if (typeof o == "function")
200
+ function be(e, t, o) {
201
+ const n = window.execEditorCommand || window.executeEditorCommand;
202
+ if (typeof n == "function")
203
203
  try {
204
- o("recordDomTransaction", e, t, n);
204
+ n("recordDomTransaction", e, t, o);
205
205
  } catch {
206
206
  }
207
207
  }
208
208
  function j(e) {
209
209
  const t = he();
210
210
  if (t && !M(t)) return;
211
- const n = t ? t.innerHTML : "";
211
+ const o = t ? t.innerHTML : "";
212
212
  if (e(), !t) return;
213
- const o = t.innerHTML;
214
- o !== n && (be(t, n, o), t.dispatchEvent(new Event("input", { bubbles: !0 })));
213
+ const n = t.innerHTML;
214
+ n !== o && (be(t, o, n), t.dispatchEvent(new Event("input", { bubbles: !0 })));
215
215
  }
216
- function G(e, t, n) {
216
+ function G(e, t, o) {
217
217
  if (!e.isConnected || e.rows.length === 0) return;
218
- const o = e.rows[Math.min(t, e.rows.length - 1)], l = o.cells[Math.min(n, o.cells.length - 1)];
218
+ const n = e.rows[Math.min(t, e.rows.length - 1)], l = n.cells[Math.min(o, n.cells.length - 1)];
219
219
  if (!l) return;
220
220
  const r = document.createRange(), a = l.querySelector("p, div, li") || l;
221
221
  r.selectNodeContents(a), r.collapse(!0);
@@ -225,15 +225,15 @@ function G(e, t, n) {
225
225
  const me = () => {
226
226
  const e = window.getSelection();
227
227
  if (!e || e.rangeCount === 0) return;
228
- const n = e.getRangeAt(0).startContainer;
229
- if (!w(n, "table")) return;
230
- const o = w(n, "td, th");
231
- if (!o) return;
232
- const l = o.parentElement;
228
+ const o = e.getRangeAt(0).startContainer;
229
+ if (!w(o, "table")) return;
230
+ const n = w(o, "td, th");
231
+ if (!n) return;
232
+ const l = n.parentElement;
233
233
  if (!l) return;
234
234
  let r = -1;
235
235
  for (let d = 0; d < l.cells.length; d++)
236
- if (l.cells[d] === o) {
236
+ if (l.cells[d] === n) {
237
237
  r = d;
238
238
  break;
239
239
  }
@@ -241,93 +241,93 @@ const me = () => {
241
241
  const a = l.cells[r + 1];
242
242
  if (!a) return;
243
243
  const i = (d, s) => {
244
- const c = parseInt(d.getAttribute(s) || "1", 10);
245
- return Number.isFinite(c) && c > 0 ? c : 1;
244
+ const u = parseInt(d.getAttribute(s) || "1", 10);
245
+ return Number.isFinite(u) && u > 0 ? u : 1;
246
246
  };
247
- if (i(o, "rowspan") !== i(a, "rowspan")) return;
248
- o.setAttribute("colspan", String(i(o, "colspan") + i(a, "colspan"))), Array.from(a.childNodes).forEach((d) => {
249
- o.appendChild(d);
247
+ if (i(n, "rowspan") !== i(a, "rowspan")) return;
248
+ n.setAttribute("colspan", String(i(n, "colspan") + i(a, "colspan"))), Array.from(a.childNodes).forEach((d) => {
249
+ n.appendChild(d);
250
250
  }), a.remove(), p();
251
251
  };
252
252
  function f() {
253
253
  const e = window.getSelection();
254
254
  if (!e || e.rangeCount === 0) return null;
255
- const n = e.getRangeAt(0).startContainer, o = w(n, "table");
256
- if (!o) return null;
255
+ const o = e.getRangeAt(0).startContainer, n = w(o, "table");
256
+ if (!n) return null;
257
257
  let l = 0, r = 0;
258
- const a = w(n, "td, th");
258
+ const a = w(o, "td, th");
259
259
  if (a) {
260
260
  const i = a.parentElement;
261
- for (; i && i !== o.rows[l] && (l++, !(l >= o.rows.length)); )
261
+ for (; i && i !== n.rows[l] && (l++, !(l >= n.rows.length)); )
262
262
  ;
263
- const u = i;
264
- if (u) {
265
- for (let d = 0; d < u.cells.length; d++)
266
- if (u.cells[d] === a) {
263
+ const c = i;
264
+ if (c) {
265
+ for (let d = 0; d < c.cells.length; d++)
266
+ if (c.cells[d] === a) {
267
267
  r = d;
268
268
  break;
269
269
  }
270
270
  }
271
271
  }
272
272
  return {
273
- table: o,
273
+ table: n,
274
274
  rowIndex: l,
275
275
  colIndex: r,
276
- rowCount: o.rows.length,
277
- cellCount: o.rows[0]?.cells.length || 0
276
+ rowCount: n.rows.length,
277
+ cellCount: n.rows[0]?.cells.length || 0
278
278
  };
279
279
  }
280
280
  function p() {
281
281
  if (!h || !b) return;
282
282
  const e = f();
283
283
  if (!e) return;
284
- const t = e.rowCount > 1, n = e.cellCount > 1;
285
- J(t, n);
284
+ const t = e.rowCount > 1, o = e.cellCount > 1;
285
+ J(t, o);
286
286
  }
287
287
  function fe(e) {
288
288
  const t = window.getSelection();
289
289
  if (!t) return;
290
- const n = document.createRange();
291
- (e.textContent ?? "").trim() === "" ? (n.selectNodeContents(e.querySelector("p, div") || e), n.collapse(!0)) : n.selectNodeContents(e), t.removeAllRanges(), t.addRange(n);
290
+ const o = document.createRange();
291
+ (e.textContent ?? "").trim() === "" ? (o.selectNodeContents(e.querySelector("p, div") || e), o.collapse(!0)) : o.selectNodeContents(e), t.removeAllRanges(), t.addRange(o);
292
292
  }
293
293
  function pe(e) {
294
294
  if (e.key !== "Tab" || e.defaultPrevented || e.ctrlKey || e.metaKey || e.altKey) return;
295
295
  const t = window.getSelection();
296
296
  if (!t || t.rangeCount === 0) return;
297
- const n = w(t.getRangeAt(0).startContainer, "td, th"), o = n?.closest("table");
298
- if (!n || !o || !M(o)) return;
299
- const l = o.closest("[contenteditable]");
297
+ const o = w(t.getRangeAt(0).startContainer, "td, th"), n = o?.closest("table");
298
+ if (!o || !n || !M(n)) return;
299
+ const l = n.closest("[contenteditable]");
300
300
  if (!l || !(e.target instanceof Node) || !l.contains(e.target)) return;
301
- const r = Array.from(o.querySelectorAll("th, td")).filter(
302
- (u) => u.closest("table") === o
303
- ), a = r.indexOf(n);
301
+ const r = Array.from(n.querySelectorAll("th, td")).filter(
302
+ (c) => c.closest("table") === n
303
+ ), a = r.indexOf(o);
304
304
  let i;
305
- e.shiftKey ? i = r[a - 1] : a < r.length - 1 ? i = r[a + 1] : (y("addRowBelow"), i = n.parentElement?.nextElementSibling?.querySelector("th, td")), i && (e.preventDefault(), fe(i));
305
+ e.shiftKey ? i = r[a - 1] : a < r.length - 1 ? i = r[a + 1] : (y("addRowBelow"), i = o.parentElement?.nextElementSibling?.querySelector("th, td")), i && (e.preventDefault(), fe(i));
306
306
  }
307
307
  function ge() {
308
- V = () => {
308
+ B = () => {
309
309
  const e = f();
310
310
  e && M(e.table) ? we(e.table) : T();
311
- }, B = (e) => {
312
- const t = w(e.target, "table"), n = w(e.target, ".table-toolbar");
313
- !t && !n && T();
311
+ }, V = (e) => {
312
+ const t = w(e.target, "table"), o = w(e.target, ".table-toolbar");
313
+ !t && !o && T();
314
314
  }, N = () => {
315
315
  T();
316
316
  }, D = () => {
317
317
  b && h && h.style.display !== "none" && S(b);
318
318
  }, q = () => {
319
319
  b && h && h.style.display !== "none" && S(b);
320
- }, document.addEventListener("selectionchange", V), document.addEventListener("keydown", pe), document.addEventListener("mousedown", B), document.addEventListener("tableDeleted", N), window.addEventListener("scroll", D, !0), window.addEventListener("resize", q);
320
+ }, document.addEventListener("selectionchange", B), document.addEventListener("keydown", pe), document.addEventListener("mousedown", V), document.addEventListener("tableDeleted", N), window.addEventListener("scroll", D, !0), window.addEventListener("resize", q);
321
321
  }
322
322
  function S(e) {
323
323
  if (!h) return;
324
- const t = e.getBoundingClientRect(), n = h.getBoundingClientRect(), o = n.height || 40, l = n.width || 280, r = 10;
325
- let a = t.top - o - r, i = t.left + t.width / 2 - l / 2;
324
+ const t = e.getBoundingClientRect(), o = h.getBoundingClientRect(), n = o.height || 40, l = o.width || 280, r = 10;
325
+ let a = t.top - n - r, i = t.left + t.width / 2 - l / 2;
326
326
  a < r && (a = t.bottom + r), i < r && (i = r);
327
- const u = window.innerWidth;
328
- i + l > u - r && (i = u - l - r);
327
+ const c = window.innerWidth;
328
+ i + l > c - r && (i = c - l - r);
329
329
  const d = window.innerHeight;
330
- a + o > d - r && (a = d - o - r), h.style.top = a + "px", h.style.left = i + "px";
330
+ a + n > d - r && (a = d - n - r), h.style.top = a + "px", h.style.left = i + "px";
331
331
  }
332
332
  function we(e) {
333
333
  b = e, h || (h = Ce(), document.body.appendChild(h));
@@ -335,8 +335,8 @@ function we(e) {
335
335
  h.classList.toggle("rte-theme-dark", t), h.style.display = "flex", h.style.visibility = "hidden", requestAnimationFrame(() => {
336
336
  S(e), h && (h.style.visibility = "visible");
337
337
  });
338
- const n = f();
339
- n && J(n.rowCount > 1, n.cellCount > 1), ye(e);
338
+ const o = f();
339
+ o && J(o.rowCount > 1, o.cellCount > 1), ye(e);
340
340
  }
341
341
  const I = /* @__PURE__ */ new Set();
342
342
  function Q() {
@@ -346,16 +346,16 @@ function Q() {
346
346
  }
347
347
  function T() {
348
348
  if (h && (h.style.display = "none"), b) {
349
- b.querySelectorAll(".resize-handle").forEach((o) => o.remove());
350
- const t = b.parentElement, n = t?.classList.contains("rte-table-wrapper") ? t.querySelector(".table-resize-handle") : b.querySelector(".table-resize-handle");
351
- n && n.remove();
349
+ b.querySelectorAll(".resize-handle").forEach((n) => n.remove());
350
+ const t = b.parentElement, o = t?.classList.contains("rte-table-wrapper") ? t.querySelector(".table-resize-handle") : b.querySelector(".table-resize-handle");
351
+ o && o.remove();
352
352
  }
353
353
  Q(), b = null;
354
354
  }
355
355
  function J(e, t) {
356
356
  if (!h) return;
357
- const n = h.querySelector('[data-action="deleteRow"]'), o = h.querySelector('[data-action="deleteColumn"]');
358
- n && (n.disabled = !e), o && (o.disabled = !t);
357
+ const o = h.querySelector('[data-action="deleteRow"]'), n = h.querySelector('[data-action="deleteColumn"]');
358
+ o && (o.disabled = !e), n && (n.disabled = !t);
359
359
  }
360
360
  let z = !1;
361
361
  function ve() {
@@ -530,15 +530,15 @@ function Ce() {
530
530
  display: none;
531
531
  `, e.setAttribute("role", "toolbar"), e.setAttribute("aria-label", "Table editing toolbar");
532
532
  const t = (s) => {
533
- const c = document.createElement("button");
534
- return c.className = "toolbar-icon-btn", s.danger && c.classList.add("toolbar-icon-btn-danger"), s.delete && c.classList.add("toolbar-icon-btn-delete"), c.innerHTML = s.icon, c.title = s.title, c.setAttribute("aria-label", s.title), c.setAttribute("type", "button"), c.setAttribute("data-action", s.action), c.onclick = () => y(s.action), c;
535
- }, n = () => {
533
+ const u = document.createElement("button");
534
+ return u.className = "toolbar-icon-btn", s.danger && u.classList.add("toolbar-icon-btn-danger"), s.delete && u.classList.add("toolbar-icon-btn-delete"), u.innerHTML = s.icon, u.title = s.title, u.setAttribute("aria-label", s.title), u.setAttribute("type", "button"), u.setAttribute("data-action", s.action), u.onclick = () => y(s.action), u;
535
+ }, o = () => {
536
536
  const s = document.createElement("div");
537
537
  return s.className = "toolbar-divider", s;
538
- }, o = (...s) => {
539
- const c = document.createElement("div");
540
- return c.className = "toolbar-section", s.forEach((C) => c.appendChild(C)), c;
541
- }, l = o(
538
+ }, n = (...s) => {
539
+ const u = document.createElement("div");
540
+ return u.className = "toolbar-section", s.forEach((C) => u.appendChild(C)), u;
541
+ }, l = n(
542
542
  t({
543
543
  icon: xe(),
544
544
  title: "Add row above (Ctrl+Shift+R)",
@@ -555,7 +555,7 @@ function Ce() {
555
555
  action: "deleteRow",
556
556
  danger: !0
557
557
  })
558
- ), r = o(
558
+ ), r = n(
559
559
  t({
560
560
  icon: Te(),
561
561
  title: "Add column left",
@@ -572,7 +572,7 @@ function Ce() {
572
572
  action: "deleteColumn",
573
573
  danger: !0
574
574
  })
575
- ), a = o(
575
+ ), a = n(
576
576
  t({
577
577
  icon: Ie(),
578
578
  title: "Toggle header row",
@@ -583,13 +583,13 @@ function Ce() {
583
583
  title: "Toggle header column",
584
584
  action: "toggleHeaderColumn"
585
585
  })
586
- ), i = o(
586
+ ), i = n(
587
587
  t({
588
588
  icon: Ae(),
589
589
  title: "Merge cells (horizontally)",
590
590
  action: "mergeCells"
591
591
  })
592
- ), u = o(
592
+ ), c = n(
593
593
  t({
594
594
  icon: Le(),
595
595
  title: "Delete table",
@@ -597,7 +597,7 @@ function Ce() {
597
597
  delete: !0
598
598
  })
599
599
  );
600
- e.appendChild(l), e.appendChild(n()), e.appendChild(r), e.appendChild(n()), e.appendChild(a), e.appendChild(n()), e.appendChild(i), e.appendChild(n()), e.appendChild(u);
600
+ e.appendChild(l), e.appendChild(o()), e.appendChild(r), e.appendChild(o()), e.appendChild(a), e.appendChild(o()), e.appendChild(i), e.appendChild(o()), e.appendChild(c);
601
601
  const d = (s) => {
602
602
  !h || h.style.display === "none" || (s.ctrlKey || s.metaKey) && s.shiftKey && (s.key === "r" || s.key === "R" ? (s.preventDefault(), y("addRowBelow")) : (s.key === "c" || s.key === "C") && (s.preventDefault(), y("addColumnRight")));
603
603
  };
@@ -642,13 +642,13 @@ function y(e) {
642
642
  function ye(e) {
643
643
  const t = Y(e);
644
644
  e.querySelectorAll(".resize-handle").forEach((i) => i.remove());
645
- const o = t.querySelector(".table-resize-handle");
646
- o && o.remove(), Q();
645
+ const n = t.querySelector(".table-resize-handle");
646
+ n && n.remove(), Q();
647
647
  const l = e.querySelector("thead tr, tbody tr:first-child");
648
648
  if (!l) return;
649
649
  const r = l.querySelectorAll("td, th");
650
- r.forEach((i, u) => {
651
- if (u === r.length - 1) return;
650
+ r.forEach((i, c) => {
651
+ if (c === r.length - 1) return;
652
652
  const d = document.createElement("div");
653
653
  d.className = "resize-handle", d.style.cssText = `
654
654
  position: absolute;
@@ -664,8 +664,8 @@ function ye(e) {
664
664
  E || (d.style.background = "rgba(0, 102, 204, 0.3)");
665
665
  }), d.addEventListener("mouseleave", () => {
666
666
  E || (d.style.background = "transparent");
667
- }), d.addEventListener("mousedown", (c) => {
668
- c.preventDefault(), c.stopPropagation(), ke(c, u);
667
+ }), d.addEventListener("mousedown", (u) => {
668
+ u.preventDefault(), u.stopPropagation(), ke(u, c);
669
669
  });
670
670
  const s = i;
671
671
  s.style.position || (s.style.position = "relative", I.add(s)), i.appendChild(d);
@@ -677,30 +677,30 @@ function ye(e) {
677
677
  }
678
678
  function ke(e, t) {
679
679
  if (E = !0, k = t, O = e.clientX, !b) return;
680
- const n = b.querySelector("thead tr, tbody tr:first-child");
681
- n && n.cells[t] && (P = n.cells[t].offsetWidth), document.body.style.cursor = "col-resize", document.body.style.userSelect = "none";
682
- const o = (r) => {
680
+ const o = b.querySelector("thead tr, tbody tr:first-child");
681
+ o && o.cells[t] && (P = o.cells[t].offsetWidth), document.body.style.cursor = "col-resize", document.body.style.userSelect = "none";
682
+ const n = (r) => {
683
683
  if (!E || k === null || !b) return;
684
684
  const a = r.clientX - O, i = Math.max(50, P + a);
685
685
  b.querySelectorAll("tr").forEach((d) => {
686
686
  d.cells[k] && (d.cells[k].style.width = i + "px");
687
687
  });
688
688
  }, l = () => {
689
- E = !1, k = null, document.body.style.cursor = "", document.body.style.userSelect = "", document.removeEventListener("mousemove", o), document.removeEventListener("mouseup", l);
689
+ E = !1, k = null, document.body.style.cursor = "", document.body.style.userSelect = "", document.removeEventListener("mousemove", n), document.removeEventListener("mouseup", l);
690
690
  };
691
- document.addEventListener("mousemove", o), document.addEventListener("mouseup", l);
691
+ document.addEventListener("mousemove", n), document.addEventListener("mouseup", l);
692
692
  }
693
693
  function Ee(e) {
694
694
  if (!b) return;
695
695
  R = !0, K = e.clientX, W = e.clientY, _ = b.offsetWidth, X = b.offsetHeight, document.body.style.cursor = "nwse-resize", document.body.style.userSelect = "none";
696
- const t = (o) => {
696
+ const t = (n) => {
697
697
  if (!R || !b) return;
698
- const l = o.clientX - K, r = o.clientY - W, a = Math.max(200, _ + l), i = Math.max(100, X + r);
698
+ const l = n.clientX - K, r = n.clientY - W, a = Math.max(200, _ + l), i = Math.max(100, X + r);
699
699
  b.style.width = a + "px", b.style.height = i + "px";
700
- }, n = () => {
701
- R = !1, document.body.style.cursor = "", document.body.style.userSelect = "", document.removeEventListener("mousemove", t), document.removeEventListener("mouseup", n);
700
+ }, o = () => {
701
+ R = !1, document.body.style.cursor = "", document.body.style.userSelect = "", document.removeEventListener("mousemove", t), document.removeEventListener("mouseup", o);
702
702
  };
703
- document.addEventListener("mousemove", t), document.addEventListener("mouseup", n);
703
+ document.addEventListener("mousemove", t), document.addEventListener("mouseup", o);
704
704
  }
705
705
  function xe() {
706
706
  return `<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@editora/plugins",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "Enterprise plugin suite for Editora rich text editor in React and web apps, including tables, media, workflow, and compliance tooling.",
5
5
  "author": "Ajay Kumar <ajaykr089@gmail.com>",
6
6
  "license": "MIT",