@editora/plugins 1.0.19 → 1.0.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ "use strict";const e=require("./purify.es-B6PsRpEV.js");function r(t){return t?e.purify_default.sanitize(t,{USE_PROFILES:{html:!0},FORBID_TAGS:["style","form","input","button","textarea","select","option","base","meta","link"],ADD_ATTR:["target"]}):""}function n(t){return new DOMParser().parseFromString(`<body>${t}</body>`,"text/html").body}exports.parseHtmlInert=n;exports.sanitizeHtml=r;
@@ -0,0 +1,16 @@
1
+ import { p as e } from "./purify.es-DmCsrgBd.mjs";
2
+ function n(t) {
3
+ return t ? e.sanitize(t, {
4
+ USE_PROFILES: { html: !0 },
5
+ // <style> can restyle or exfiltrate through CSS; <form> and friends have no place in document content.
6
+ FORBID_TAGS: ["style", "form", "input", "button", "textarea", "select", "option", "base", "meta", "link"],
7
+ ADD_ATTR: ["target"]
8
+ }) : "";
9
+ }
10
+ function a(t) {
11
+ return new DOMParser().parseFromString(`<body>${t}</body>`, "text/html").body;
12
+ }
13
+ export {
14
+ a as p,
15
+ n as s
16
+ };
package/dist/table.cjs.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const L=require("./editorContainerHelpers-CFbfiOJI.js");let c=null,u=null,V=null,A=null,B=null,N=null,D=null;const H='[data-theme="dark"], .dark, .editora-theme-dark';let y=!1,k=null,q=0,O=0,T=!1,P=0,_=0,W=0,X=0;const J=new Set(["DIV","P","BLOCKQUOTE","PRE","H1","H2","H3","H4","H5","H6","LI","TD","TH"]);function K(e,t){let n=e;for(;n&&n!==t;){if(n.nodeType===Node.ELEMENT_NODE&&J.has(n.tagName))return n;n=n.parentNode}return null}function U(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 Z=()=>{const e=L.findEditorContainerFromSelection(),t=L.getContentElement(e);if(!t)return alert("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"),w=document.createElement("p");w.appendChild(document.createElement("br")),g.appendChild(w),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 w=0;w<3;w++){const x=document.createElement("td"),S=document.createElement("p");S.appendChild(document.createElement("br")),x.appendChild(S),g.appendChild(x)}i.appendChild(g)}l.appendChild(r),l.appendChild(i);const h=U(l),d=(m,g,w)=>{if(m!==t)return m;const x=w?g-1:g;return t.childNodes[Math.min(Math.max(x,0),t.childNodes.length-1)]||null},s=d(o.endContainer,o.endOffset,!0),b=d(o.startContainer,o.startOffset,!1),C=s&&K(s,t)||b&&K(b,t);C&&C.parentNode?C.parentNode.insertBefore(h,C.nextSibling):(o.collapse(!1),o.insertNode(h));const I=l.querySelector("th p");if(I){const m=document.createRange();m.setStart(I,0),m.collapse(!0),n.removeAllRanges(),n.addRange(m)}t.focus()},$=()=>{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"),h=document.createElement("p");h.innerHTML="<br>",i.appendChild(h),o.appendChild(i)}const r=t.rows[n];r&&r.parentElement?r.parentElement.insertBefore(o,r):t.appendChild(o),p()},ee=()=>{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()},te=()=>{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()},ne=()=>{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()},oe=()=>{const e=f();if(!e||e.rowCount<=1)return;const{table:t,rowIndex:n,colIndex:o}=e;t.deleteRow(n),G(t,n,o),p()},re=()=>{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)}G(t,n,o),p()},le=()=>{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 F(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 F(o,"th");p()};function F(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 ae=()=>{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 h=l.attributes[i];a.setAttribute(h.name,h.value)}l.parentNode?.replaceChild(a,l)}}p()},ie=()=>{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 v(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 j(e){if(!e)return!1;const t=e.closest("[contenteditable]");return!t||t.getAttribute("contenteditable")==="false"?!1:!t.closest('[data-readonly="true"]')}function de(){const e=window.getSelection(),t=e&&e.rangeCount>0?e.getRangeAt(0).startContainer:null;return v(t,".rte-content")||(u?u.closest(".rte-content"):null)}function se(e,t,n){const o=window.execEditorCommand||window.executeEditorCommand;if(typeof o=="function")try{o("recordDomTransaction",e,t,n)}catch{}}function Y(e){const t=de();if(t&&!j(t))return;const n=t?t.innerHTML:"";if(e(),!t)return;const o=t.innerHTML;o!==n&&(se(t,n,o),t.dispatchEvent(new Event("input",{bubbles:!0})))}function G(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 ce=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return;const n=e.getRangeAt(0).startContainer;if(!v(n,"table"))return;const o=v(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 b=parseInt(d.getAttribute(s)||"1",10);return Number.isFinite(b)&&b>0?b: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=v(n,"table");if(!o)return null;let l=0,r=0;const a=v(n,"td, th");if(a){const i=a.parentElement;for(;i&&i!==o.rows[l]&&(l++,!(l>=o.rows.length)););const h=i;if(h){for(let d=0;d<h.cells.length;d++)if(h.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(!c||!u)return;const e=f();if(!e)return;const t=e.rowCount>1,n=e.cellCount>1;Q(t,n)}function ue(){V=()=>{const e=f();e&&j(e.table)?he(e.table):z()},A=e=>{const t=v(e.target,"table"),n=v(e.target,".table-toolbar");!t&&!n&&z()},B=()=>{z()},N=()=>{u&&c&&c.style.display!=="none"&&M(u)},D=()=>{u&&c&&c.style.display!=="none"&&M(u)},document.addEventListener("selectionchange",V),document.addEventListener("mousedown",A),document.addEventListener("tableDeleted",B),window.addEventListener("scroll",N,!0),window.addEventListener("resize",D)}function M(e){if(!c)return;const t=e.getBoundingClientRect(),n=c.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 h=window.innerWidth;i+l>h-r&&(i=h-l-r);const d=window.innerHeight;a+o>d-r&&(a=d-o-r),c.style.top=a+"px",c.style.left=i+"px"}function he(e){u=e,c||(c=me(),document.body.appendChild(c));const t=!!e.closest(H)||document.body.matches(H)||document.documentElement.matches(H);c.classList.toggle("rte-theme-dark",t),c.style.display="flex",c.style.visibility="hidden",requestAnimationFrame(()=>{M(e),c&&(c.style.visibility="visible")});const n=f();n&&Q(n.rowCount>1,n.cellCount>1),fe(e)}function z(){if(c&&(c.style.display="none"),u){u.querySelectorAll(".resize-handle").forEach(o=>o.remove());const t=u.parentElement,n=t?.classList.contains("rte-table-wrapper")?t.querySelector(".table-resize-handle"):u.querySelector(".table-resize-handle");n&&n.remove()}u=null}function Q(e,t){if(!c)return;const n=c.querySelector('[data-action="deleteRow"]'),o=c.querySelector('[data-action="deleteColumn"]');n&&(n.disabled=!e),o&&(o.disabled=!t)}let R=!1;function be(){if(R||typeof document>"u")return;if(document.getElementById("rte-table-toolbar-styles")){R=!0;return}R=!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 A=require("./editorContainerHelpers-CFbfiOJI.js");let u=null,h=null,V=null,B=null,N=null,D=null,q=null;const H='[data-theme="dark"], .dark, .editora-theme-dark';let k=!1,y=null,P=0,O=0,T=!1,_=0,W=0,X=0,K=0;const $=new Set(["DIV","P","BLOCKQUOTE","PRE","H1","H2","H3","H4","H5","H6","LI","TD","TH"]);function F(e,t){let n=e;for(;n&&n!==t;){if(n.nodeType===Node.ELEMENT_NODE&&$.has(n.tagName))return n;n=n.parentNode}return null}function j(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 ee=()=>{const e=A.findEditorContainerFromSelection(),t=A.getContentElement(e);if(!t)return alert("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"),w=document.createElement("p");w.appendChild(document.createElement("br")),g.appendChild(w),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 w=0;w<3;w++){const x=document.createElement("td"),L=document.createElement("p");L.appendChild(document.createElement("br")),x.appendChild(L),g.appendChild(x)}i.appendChild(g)}l.appendChild(r),l.appendChild(i);const b=j(l),d=(m,g,w)=>{if(m!==t)return m;const x=w?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&&F(s,t)||c&&F(c,t);C&&C.parentNode?C.parentNode.insertBefore(b,C.nextSibling):(o.collapse(!1),o.insertNode(b));const S=l.querySelector("th p");if(S){const m=document.createRange();m.setStart(S,0),m.collapse(!0),n.removeAllRanges(),n.addRange(m)}t.focus()},te=()=>{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"),b=document.createElement("p");b.innerHTML="<br>",i.appendChild(b),o.appendChild(i)}const r=t.rows[n];r&&r.parentElement?r.parentElement.insertBefore(o,r):t.appendChild(o),p()},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 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()},oe=()=>{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()},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>=l.cells.length-1?l.appendChild(r):l.insertBefore(r,l.cells[n+1])}p()},le=()=>{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()},ae=()=>{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()},ie=()=>{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 U(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 U(o,"th");p()};function U(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 de=()=>{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 b=l.attributes[i];a.setAttribute(b.name,b.value)}l.parentNode?.replaceChild(a,l)}}p()},se=()=>{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 v(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 Y(e){if(!e)return!1;const t=e.closest("[contenteditable]");return!t||t.getAttribute("contenteditable")==="false"?!1:!t.closest('[data-readonly="true"]')}function ce(){const e=window.getSelection(),t=e&&e.rangeCount>0?e.getRangeAt(0).startContainer:null;return v(t,".rte-content")||(h?h.closest(".rte-content"):null)}function ue(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=ce();if(t&&!Y(t))return;const n=t?t.innerHTML:"";if(e(),!t)return;const o=t.innerHTML;o!==n&&(ue(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 he=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return;const n=e.getRangeAt(0).startContainer;if(!v(n,"table"))return;const o=v(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=v(n,"table");if(!o)return null;let l=0,r=0;const a=v(n,"td, th");if(a){const i=a.parentElement;for(;i&&i!==o.rows[l]&&(l++,!(l>=o.rows.length)););const b=i;if(b){for(let d=0;d<b.cells.length;d++)if(b.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(!u||!h)return;const e=f();if(!e)return;const t=e.rowCount>1,n=e.cellCount>1;Z(t,n)}function be(){V=()=>{const e=f();e&&Y(e.table)?me(e.table):z()},B=e=>{const t=v(e.target,"table"),n=v(e.target,".table-toolbar");!t&&!n&&z()},N=()=>{z()},D=()=>{h&&u&&u.style.display!=="none"&&M(h)},q=()=>{h&&u&&u.style.display!=="none"&&M(h)},document.addEventListener("selectionchange",V),document.addEventListener("mousedown",B),document.addEventListener("tableDeleted",N),window.addEventListener("scroll",D,!0),window.addEventListener("resize",q)}function M(e){if(!u)return;const t=e.getBoundingClientRect(),n=u.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 b=window.innerWidth;i+l>b-r&&(i=b-l-r);const d=window.innerHeight;a+o>d-r&&(a=d-o-r),u.style.top=a+"px",u.style.left=i+"px"}function me(e){h=e,u||(u=pe(),document.body.appendChild(u));const t=!!e.closest(H)||document.body.matches(H)||document.documentElement.matches(H);u.classList.toggle("rte-theme-dark",t),u.style.display="flex",u.style.visibility="hidden",requestAnimationFrame(()=>{M(e),u&&(u.style.visibility="visible")});const n=f();n&&Z(n.rowCount>1,n.cellCount>1),ge(e)}const I=new Set;function J(){I.forEach(e=>{e.style.position==="relative"&&(e.style.removeProperty("position"),e.getAttribute("style")?.trim()||e.removeAttribute("style"))}),I.clear()}function z(){if(u&&(u.style.display="none"),h){h.querySelectorAll(".resize-handle").forEach(o=>o.remove());const t=h.parentElement,n=t?.classList.contains("rte-table-wrapper")?t.querySelector(".table-resize-handle"):h.querySelector(".table-resize-handle");n&&n.remove()}J(),h=null}function Z(e,t){if(!u)return;const n=u.querySelector('[data-action="deleteRow"]'),o=u.querySelector('[data-action="deleteColumn"]');n&&(n.disabled=!e),o&&(o.disabled=!t)}let R=!1;function fe(){if(R||typeof document>"u")return;if(document.getElementById("rte-table-toolbar-styles")){R=!0;return}R=!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;
@@ -151,11 +151,11 @@
151
151
  display: none;
152
152
  }
153
153
  }
154
- `,document.head.appendChild(e)}function me(){be();const e=document.createElement("div");e.className="table-toolbar",e.style.cssText=`
154
+ `,document.head.appendChild(e)}function pe(){fe();const e=document.createElement("div");e.className="table-toolbar",e.style.cssText=`
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 b=document.createElement("button");return b.className="toolbar-icon-btn",s.danger&&b.classList.add("toolbar-icon-btn-danger"),s.delete&&b.classList.add("toolbar-icon-btn-delete"),b.innerHTML=s.icon,b.title=s.title,b.setAttribute("aria-label",s.title),b.setAttribute("type","button"),b.setAttribute("data-action",s.action),b.onclick=()=>E(s.action),b},n=()=>{const s=document.createElement("div");return s.className="toolbar-divider",s},o=(...s)=>{const b=document.createElement("div");return b.className="toolbar-section",s.forEach(C=>b.appendChild(C)),b},l=o(t({icon:we(),title:"Add row above (Ctrl+Shift+R)",action:"addRowAbove"}),t({icon:ve(),title:"Add row below",action:"addRowBelow"}),t({icon:Ce(),title:"Delete row",action:"deleteRow",danger:!0})),r=o(t({icon:ke(),title:"Add column left",action:"addColumnLeft"}),t({icon:ye(),title:"Add column right (Ctrl+Shift+C)",action:"addColumnRight"}),t({icon:Ee(),title:"Delete column",action:"deleteColumn",danger:!0})),a=o(t({icon:xe(),title:"Toggle header row",action:"toggleHeaderRow"}),t({icon:He(),title:"Toggle header column",action:"toggleHeaderColumn"})),i=o(t({icon:ze(),title:"Merge cells (horizontally)",action:"mergeCells"})),h=o(t({icon:Te(),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(h);const d=s=>{!c||c.style.display==="none"||(s.ctrlKey||s.metaKey)&&s.shiftKey&&(s.key==="r"||s.key==="R"?(s.preventDefault(),E("addRowBelow")):(s.key==="c"||s.key==="C")&&(s.preventDefault(),E("addColumnRight")))};return window.addEventListener("keydown",d),e}function E(e){Y(()=>{switch(e){case"addRowAbove":$();break;case"addRowBelow":ee();break;case"addColumnLeft":te();break;case"addColumnRight":ne();break;case"deleteRow":oe();break;case"deleteColumn":re();break;case"toggleHeaderRow":le();break;case"toggleHeaderColumn":ae();break;case"deleteTable":ie();break;case"mergeCells":ce();break}})}function fe(e){const t=U(e);e.querySelectorAll(".resize-handle").forEach(i=>i.remove());const o=t.querySelector(".table-resize-handle");o&&o.remove();const l=e.querySelector("thead tr, tbody tr:first-child");if(!l)return;const r=l.querySelectorAll("td, th");r.forEach((i,h)=>{if(h===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 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=()=>E(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:Ce(),title:"Add row above (Ctrl+Shift+R)",action:"addRowAbove"}),t({icon:ye(),title:"Add row below",action:"addRowBelow"}),t({icon:ke(),title:"Delete row",action:"deleteRow",danger:!0})),r=o(t({icon:Ee(),title:"Add column left",action:"addColumnLeft"}),t({icon:xe(),title:"Add column right (Ctrl+Shift+C)",action:"addColumnRight"}),t({icon:He(),title:"Delete column",action:"deleteColumn",danger:!0})),a=o(t({icon:Te(),title:"Toggle header row",action:"toggleHeaderRow"}),t({icon:ze(),title:"Toggle header column",action:"toggleHeaderColumn"})),i=o(t({icon:Me(),title:"Merge cells (horizontally)",action:"mergeCells"})),b=o(t({icon:Re(),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(b);const d=s=>{!u||u.style.display==="none"||(s.ctrlKey||s.metaKey)&&s.shiftKey&&(s.key==="r"||s.key==="R"?(s.preventDefault(),E("addRowBelow")):(s.key==="c"||s.key==="C")&&(s.preventDefault(),E("addColumnRight")))};return window.addEventListener("keydown",d),e}function E(e){G(()=>{switch(e){case"addRowAbove":te();break;case"addRowBelow":ne();break;case"addColumnLeft":oe();break;case"addColumnRight":re();break;case"deleteRow":le();break;case"deleteColumn":ae();break;case"toggleHeaderRow":ie();break;case"toggleHeaderColumn":de();break;case"deleteTable":se();break;case"mergeCells":he();break}})}function ge(e){const t=j(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,b)=>{if(b===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,24 +165,24 @@
165
165
  cursor: col-resize;
166
166
  z-index: 10;
167
167
  transition: background 0.15s ease;
168
- `,d.addEventListener("mouseenter",()=>{y||(d.style.background="rgba(0, 102, 204, 0.3)")}),d.addEventListener("mouseleave",()=>{y||(d.style.background="transparent")}),d.addEventListener("mousedown",s=>{s.preventDefault(),s.stopPropagation(),pe(s,h)}),i.style.position="relative",i.appendChild(d)});const a=document.createElement("div");a.className="table-resize-handle",a.addEventListener("mousedown",i=>{i.preventDefault(),i.stopPropagation(),ge(i)}),t.appendChild(a)}function pe(e,t){if(y=!0,k=t,q=e.clientX,!u)return;const n=u.querySelector("thead tr, tbody tr:first-child");n&&n.cells[t]&&(O=n.cells[t].offsetWidth),document.body.style.cursor="col-resize",document.body.style.userSelect="none";const o=r=>{if(!y||k===null||!u)return;const a=r.clientX-q,i=Math.max(50,O+a);u.querySelectorAll("tr").forEach(d=>{d.cells[k]&&(d.cells[k].style.width=i+"px")})},l=()=>{y=!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 ge(e){if(!u)return;T=!0,P=e.clientX,_=e.clientY,W=u.offsetWidth,X=u.offsetHeight,document.body.style.cursor="nwse-resize",document.body.style.userSelect="none";const t=o=>{if(!T||!u)return;const l=o.clientX-P,r=o.clientY-_,a=Math.max(200,W+l),i=Math.max(100,X+r);u.style.width=a+"px",u.style.height=i+"px"},n=()=>{T=!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 we(){return`<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
168
+ `,d.addEventListener("mouseenter",()=>{k||(d.style.background="rgba(0, 102, 204, 0.3)")}),d.addEventListener("mouseleave",()=>{k||(d.style.background="transparent")}),d.addEventListener("mousedown",c=>{c.preventDefault(),c.stopPropagation(),we(c,b)});const s=i;s.style.position||(s.style.position="relative",I.add(s)),i.appendChild(d)});const a=document.createElement("div");a.className="table-resize-handle",a.addEventListener("mousedown",i=>{i.preventDefault(),i.stopPropagation(),ve(i)}),t.appendChild(a)}function we(e,t){if(k=!0,y=t,P=e.clientX,!h)return;const n=h.querySelector("thead tr, tbody tr:first-child");n&&n.cells[t]&&(O=n.cells[t].offsetWidth),document.body.style.cursor="col-resize",document.body.style.userSelect="none";const o=r=>{if(!k||y===null||!h)return;const a=r.clientX-P,i=Math.max(50,O+a);h.querySelectorAll("tr").forEach(d=>{d.cells[y]&&(d.cells[y].style.width=i+"px")})},l=()=>{k=!1,y=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 ve(e){if(!h)return;T=!0,_=e.clientX,W=e.clientY,X=h.offsetWidth,K=h.offsetHeight,document.body.style.cursor="nwse-resize",document.body.style.userSelect="none";const t=o=>{if(!T||!h)return;const l=o.clientX-_,r=o.clientY-W,a=Math.max(200,X+l),i=Math.max(100,K+r);h.style.width=a+"px",h.style.height=i+"px"},n=()=>{T=!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 Ce(){return`<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
169
169
  <path d="M2 7h12V5H2v2zm0 4h12V9H2v2zM8 1v3H5v2h3v3h2V6h3V4h-3V1H8z"/>
170
- </svg>`}function ve(){return`<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
170
+ </svg>`}function ye(){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"/>
172
- </svg>`}function Ce(){return`<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
173
- <path d="M2 5h12v2H2V5zm0 4h12v2H2V9zm4-6v2H4v2h2v2h2V7h2V5H8V3H6z"/>
174
172
  </svg>`}function ke(){return`<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
173
+ <path d="M2 5h12v2H2V5zm0 4h12v2H2V9zm4-6v2H4v2h2v2h2V7h2V5H8V3H6z"/>
174
+ </svg>`}function Ee(){return`<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
175
175
  <path d="M7 2v12h2V2H7zm4 0v12h2V2h-2zM1 8h3v-3H1v3zm3 2H1v3h3v-3z"/>
176
- </svg>`}function ye(){return`<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
176
+ </svg>`}function xe(){return`<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
177
177
  <path d="M2 2v12h2V2H2zm4 0v12h2V2H6zM12 8h3v-3h-3v3zm0 2h3v3h-3v-3z"/>
178
- </svg>`}function Ee(){return`<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
178
+ </svg>`}function He(){return`<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
179
179
  <path d="M5 2v12h2V2H5zm4 0v12h2V2H9zm3 2h3V1h-3v3zm3 2h-3v3h3V6zm0 4h-3v3h3v-3z"/>
180
- </svg>`}function xe(){return`<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
180
+ </svg>`}function Te(){return`<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
181
181
  <path d="M2 2h12v3H2V2zm0 5h12v8H2V7zm2 2v4h2V9H4zm4 0v4h2V9H8zm4 0v4h2V9h-2z"/>
182
- </svg>`}function He(){return`<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
182
+ </svg>`}function ze(){return`<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
183
183
  <path d="M2 2v12h3V2H2zm5 0v12h8V2H7zm2 2h4v2H9V4zm0 4h4v2H9V8zm0 4h4v2H9v-2z"/>
184
- </svg>`}function Te(){return`<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
184
+ </svg>`}function Re(){return`<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
185
185
  <path d="M3 1h10v1H3V1zm1 2v11h8V3H4zM6 5h1v6H6V5zm3 0h1v6H9V5z"/>
186
- </svg>`}function ze(){return`<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
186
+ </svg>`}function Me(){return`<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
187
187
  <path d="M2 2h4v3H2V2zm5 0h4v3H7V2zm5 0h2v3h-2V2zm-10 4h4v3H2V6zm5 0h4v3H7V6zm5 0h2v3h-2V6zm-10 4h4v3H2v-3zm5 0h4v3H7v-3zm5 0h2v3h-2v-3z"/>
188
- </svg>`}if(typeof window<"u"&&!window.__tablePluginInitialized){window.__tablePluginInitialized=!0;const e=()=>{ue()};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",e):setTimeout(e,100)}const Re=()=>({name:"table",toolbar:[{label:"Insert Table",command:"insertTable",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><rect x="3" y="4" width="18" height="16" rx="2" fill="none" stroke="currentColor" stroke-width="1.8"/><path d="M3 10h18M3 15h18M9 4v16M15 4v16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/></svg>'}],commands:{insertTable:()=>(Y(()=>{Z()}),!0)},keymap:{"Mod-Shift-r":()=>(E("addRowBelow"),!0),"Mod-Shift-c":()=>(E("addColumnRight"),!0)}});exports.TablePlugin=Re;
188
+ </svg>`}if(typeof window<"u"&&!window.__tablePluginInitialized){window.__tablePluginInitialized=!0;const e=()=>{be()};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",e):setTimeout(e,100)}const Ie=()=>({name:"table",toolbar:[{label:"Insert Table",command:"insertTable",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><rect x="3" y="4" width="18" height="16" rx="2" fill="none" stroke="currentColor" stroke-width="1.8"/><path d="M3 10h18M3 15h18M9 4v16M15 4v16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/></svg>'}],commands:{insertTable:()=>(G(()=>{ee()}),!0)},keymap:{"Mod-Shift-r":()=>(E("addRowBelow"),!0),"Mod-Shift-c":()=>(E("addColumnRight"),!0)}});exports.TablePlugin=Ie;