@notectl/core 2.2.5 → 2.2.6

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.
Files changed (92) hide show
  1. package/dist/chunks/{AlignmentPlugin-BCHxo16v.mjs → AlignmentPlugin-DeD4C4EP.mjs} +2 -2
  2. package/dist/chunks/{AlignmentPlugin-BCHxo16v.mjs.map → AlignmentPlugin-DeD4C4EP.mjs.map} +1 -1
  3. package/dist/chunks/{CodeBlockPlugin-DC0-BnNy.mjs → CodeBlockPlugin-3V2K3RBe.mjs} +2 -2
  4. package/dist/chunks/{CodeBlockPlugin-DC0-BnNy.mjs.map → CodeBlockPlugin-3V2K3RBe.mjs.map} +1 -1
  5. package/dist/chunks/{ColorGrid-CXRdpP_n.mjs → ColorGrid-DPNiXxpD.mjs} +2 -2
  6. package/dist/chunks/{ColorGrid-CXRdpP_n.mjs.map → ColorGrid-DPNiXxpD.mjs.map} +1 -1
  7. package/dist/chunks/{ColorPickerPopup-C_74bqid.mjs → ColorPickerPopup-lcf3jS6G.mjs} +2 -2
  8. package/dist/chunks/{ColorPickerPopup-C_74bqid.mjs.map → ColorPickerPopup-lcf3jS6G.mjs.map} +1 -1
  9. package/dist/chunks/FontPlugin-DQMj65Bc.mjs +2 -0
  10. package/dist/chunks/{FontPlugin-DB1_bgam.mjs.map → FontPlugin-DQMj65Bc.mjs.map} +1 -1
  11. package/dist/chunks/{FontSizePlugin-DFvp7Ki9.mjs → FontSizePlugin-9StCjEfN.mjs} +2 -2
  12. package/dist/chunks/{FontSizePlugin-DFvp7Ki9.mjs.map → FontSizePlugin-9StCjEfN.mjs.map} +1 -1
  13. package/dist/chunks/{FormulaPlugin-BLEcyazj.mjs → FormulaPlugin-CV5VUxkb.mjs} +2 -2
  14. package/dist/chunks/{FormulaPlugin-BLEcyazj.mjs.map → FormulaPlugin-CV5VUxkb.mjs.map} +1 -1
  15. package/dist/chunks/{HeadingPlugin-D9yvG2Aw.mjs → HeadingPlugin-BuGoM9Rz.mjs} +2 -2
  16. package/dist/chunks/{HeadingPlugin-D9yvG2Aw.mjs.map → HeadingPlugin-BuGoM9Rz.mjs.map} +1 -1
  17. package/dist/chunks/{HighlightPlugin-D4gh4RP7.mjs → HighlightPlugin-C6pHifVz.mjs} +2 -2
  18. package/dist/chunks/{HighlightPlugin-D4gh4RP7.mjs.map → HighlightPlugin-C6pHifVz.mjs.map} +1 -1
  19. package/dist/chunks/{ImagePlugin-Cp_RINtc.mjs → ImagePlugin-KpkuE2LH.mjs} +2 -2
  20. package/dist/chunks/{ImagePlugin-Cp_RINtc.mjs.map → ImagePlugin-KpkuE2LH.mjs.map} +1 -1
  21. package/dist/chunks/{InlineStyleMarkSpec-4R6DC7ij.mjs → InlineStyleMarkSpec-C6LJT7kp.mjs} +2 -2
  22. package/dist/chunks/{InlineStyleMarkSpec-4R6DC7ij.mjs.map → InlineStyleMarkSpec-C6LJT7kp.mjs.map} +1 -1
  23. package/dist/chunks/{ListPlugin-CVId2dE0.mjs → ListPlugin-2yl6KiTK.mjs} +2 -2
  24. package/dist/chunks/{ListPlugin-CVId2dE0.mjs.map → ListPlugin-2yl6KiTK.mjs.map} +1 -1
  25. package/dist/chunks/{PopupManager-CyOfZUab.mjs → PopupManager-DUtaK3WX.mjs} +2 -2
  26. package/dist/chunks/{PopupManager-CyOfZUab.mjs.map → PopupManager-DUtaK3WX.mjs.map} +1 -1
  27. package/dist/chunks/{PopupPositioning-DtUrY9bh.mjs → PopupPositioning-BB97-__N.mjs} +2 -2
  28. package/dist/chunks/{PopupPositioning-DtUrY9bh.mjs.map → PopupPositioning-BB97-__N.mjs.map} +1 -1
  29. package/dist/chunks/PrintPlugin-DyIZDY3Q.mjs +2 -0
  30. package/dist/chunks/PrintPlugin-DyIZDY3Q.mjs.map +1 -0
  31. package/dist/chunks/{PrintTypes-WdtgSj74.mjs → PrintTypes-CxU69qu3.mjs} +3 -2
  32. package/dist/chunks/PrintTypes-CxU69qu3.mjs.map +1 -0
  33. package/dist/chunks/StyleRuntime-BFKu52mS.mjs +2 -0
  34. package/dist/chunks/StyleRuntime-BFKu52mS.mjs.map +1 -0
  35. package/dist/chunks/{TablePlugin-D93RR5xH.mjs → TablePlugin-BTH9VRZq.mjs} +2 -2
  36. package/dist/chunks/{TablePlugin-D93RR5xH.mjs.map → TablePlugin-BTH9VRZq.mjs.map} +1 -1
  37. package/dist/chunks/{TextColorPlugin-C1qpzEOa.mjs → TextColorPlugin-CEfZQ6Md.mjs} +2 -2
  38. package/dist/chunks/{TextColorPlugin-C1qpzEOa.mjs.map → TextColorPlugin-CEfZQ6Md.mjs.map} +1 -1
  39. package/dist/chunks/{ToolbarPlugin-CLz2wa2c.mjs → ToolbarPlugin-DVGrFf8v.mjs} +2 -2
  40. package/dist/chunks/{ToolbarPlugin-CLz2wa2c.mjs.map → ToolbarPlugin-DVGrFf8v.mjs.map} +1 -1
  41. package/dist/chunks/{VideoPlugin-D9rQZol6.mjs → VideoPlugin-B3uf1Dwp.mjs} +2 -2
  42. package/dist/chunks/{VideoPlugin-D9rQZol6.mjs.map → VideoPlugin-B3uf1Dwp.mjs.map} +1 -1
  43. package/dist/chunks/{full-Cah3qjCT.mjs → full-BBl7mvwH.mjs} +2 -2
  44. package/dist/chunks/{full-Cah3qjCT.mjs.map → full-BBl7mvwH.mjs.map} +1 -1
  45. package/dist/chunks/minimal-CtnR4dqp.mjs +2 -0
  46. package/dist/chunks/{minimal-DqATlnAL.mjs.map → minimal-CtnR4dqp.mjs.map} +1 -1
  47. package/dist/chunks/src-C89Cw7ni.mjs +2 -0
  48. package/dist/chunks/{src-YY6n2SmV.mjs.map → src-C89Cw7ni.mjs.map} +1 -1
  49. package/dist/editor/NotectlEditor.d.ts +22 -3
  50. package/dist/editor/NotectlEditor.d.ts.map +1 -1
  51. package/dist/full.mjs +1 -1
  52. package/dist/notectl-core.mjs +1 -1
  53. package/dist/notectl-core.umd.js +1 -1
  54. package/dist/notectl-core.umd.js.map +1 -1
  55. package/dist/plugins/alignment.mjs +1 -1
  56. package/dist/plugins/code-block.mjs +1 -1
  57. package/dist/plugins/font-size.mjs +1 -1
  58. package/dist/plugins/font.mjs +1 -1
  59. package/dist/plugins/formula.mjs +1 -1
  60. package/dist/plugins/heading.mjs +1 -1
  61. package/dist/plugins/highlight.mjs +1 -1
  62. package/dist/plugins/image.mjs +1 -1
  63. package/dist/plugins/list.mjs +1 -1
  64. package/dist/plugins/print/PrintHostStyles.d.ts +50 -0
  65. package/dist/plugins/print/PrintHostStyles.d.ts.map +1 -0
  66. package/dist/plugins/print/PrintPlugin.d.ts.map +1 -1
  67. package/dist/plugins/print/PrintServiceImpl.d.ts +72 -3
  68. package/dist/plugins/print/PrintServiceImpl.d.ts.map +1 -1
  69. package/dist/plugins/print/PrintStyleCollector.d.ts +150 -21
  70. package/dist/plugins/print/PrintStyleCollector.d.ts.map +1 -1
  71. package/dist/plugins/print/StaticHostMarker.d.ts +18 -0
  72. package/dist/plugins/print/StaticHostMarker.d.ts.map +1 -0
  73. package/dist/plugins/print.mjs +1 -1
  74. package/dist/plugins/shared.mjs +1 -1
  75. package/dist/plugins/table.mjs +1 -1
  76. package/dist/plugins/text-color.mjs +1 -1
  77. package/dist/plugins/toolbar.mjs +1 -1
  78. package/dist/plugins/video.mjs +1 -1
  79. package/dist/presets/full.mjs +1 -1
  80. package/dist/presets/minimal.mjs +1 -1
  81. package/dist/presets.mjs +1 -1
  82. package/dist/style/StyleRuntime.d.ts +7 -0
  83. package/dist/style/StyleRuntime.d.ts.map +1 -1
  84. package/package.json +1 -1
  85. package/dist/chunks/FontPlugin-DB1_bgam.mjs +0 -2
  86. package/dist/chunks/PrintPlugin-C6gOJT6d.mjs +0 -2
  87. package/dist/chunks/PrintPlugin-C6gOJT6d.mjs.map +0 -1
  88. package/dist/chunks/PrintTypes-WdtgSj74.mjs.map +0 -1
  89. package/dist/chunks/StyleRuntime-BAutwDZT.mjs +0 -2
  90. package/dist/chunks/StyleRuntime-BAutwDZT.mjs.map +0 -1
  91. package/dist/chunks/minimal-DqATlnAL.mjs +0 -2
  92. package/dist/chunks/src-YY6n2SmV.mjs +0 -2
@@ -1,2 +1,2 @@
1
- import{c as t,d as e,i as n,o,p as r,u as l}from"./Document-r7vLOAGA.mjs";import{c as i,l as s,o as a,r as c,t as d,u}from"./Selection-HYoVFpAx.mjs";import{a as b}from"./TypeBrands-Ch9856Gb.mjs";import{r as p}from"./HTMLUtils-C6B4UT00.mjs";import{_ as h,s as m}from"./BlockInsertion-6rR9tIGP.mjs";import{i as f,t as v}from"./Decoration-ZeyVfwJB.mjs";import{a as g,o as x,s as w}from"./StyleRuntime-BAutwDZT.mjs";import{n as C}from"./TypedKeys-CA4bfw9O.mjs";import{c as I,i as y,o as k}from"./PluginHelpers-KDuTlmXm.mjs";import{t as S}from"./KeyboardNav-D0my3wuy.mjs";import{r as A}from"./PopupPositioning-DtUrY9bh.mjs";import{i as L}from"./ColorValidation-DAijTjG9.mjs";import{n as R,t as B}from"./ColorGrid-CXRdpP_n.mjs";function E(){const e=n(b("paragraph"),[t("")],l());return n(b("table_cell"),[e],l())}function T(t,n){const o=t.getNodePath(n);if(!o)return null;let r=null,l=null,i=null,s=null;for(const e of o){const n=t.getBlock(e);n&&("table"===n.type?(r=e,l=n):"table_row"===n.type?i=e:"table_cell"===n.type&&(s=e))}if("table_cell"===t.getBlock(n)?.type&&(s=n),!(r&&l&&s&&i))return null;const a=t.doc.children.findIndex(t=>t.id===r),c=e(l),d=c.findIndex(t=>t.id===i);if(-1===d)return null;const u=c[d];if(!u)return null;const b=e(u),p=b.findIndex(t=>t.id===s);if(-1===p)return null;const h=b.length,m=c.length;return{tableId:r,tableIndex:a,rowId:i,rowIndex:d,cellId:s,colIndex:p,totalRows:m,totalCols:h}}function M(t,n,o,r){const l=t.getBlock(n);if(!l)return null;const i=e(l)[o];return i?e(i)[r]?.id??null:null}function N(t,n){const o=t.getBlock(n);if(!o)return n;const r=e(o)[0];if(!r)return n;let l=r;for(;;){const t=e(l)[0];if(!t)return l.id;l=t}}function H(t,n){const o=t.getBlock(n);if(!o)return n;const r=e(o),l=r[r.length-1];if(!l)return n;let i=l;for(;;){const t=e(i),n=t[t.length-1];if(!n)return i.id;i=n}}function P(t,e){const n=t.getNodePath(e);if(!n)return!1;for(const o of n)if("table"===t.getBlock(o)?.type)return!0;return!1}var D={insertRowAbove:"Insert Row Above",insertRowBelow:"Insert Row Below",insertColumnLeft:"Insert Column Left",insertColumnRight:"Insert Column Right",deleteRow:"Delete Row",deleteColumn:"Delete Column",borderColorLabel:"Border Color...",deleteTable:"Delete Table",tableActions:"Table actions",menuKeyboardHint:"↑↓ Navigate · Enter Select · Esc Close",insertRow:"Insert row",insertColumn:"Insert column",addRow:"Add row",addColumn:"Add column",tableActionsHint:"Table actions (Right-click or Shift+F10)",contextMenuHint:"Right-click or Shift+F10 for table actions",borderColor:"Border color",defaultColor:"Default",noBorders:"No borders",borderColorPicker:"Border color picker",announceBorderColorSet:t=>`Table border color set to ${t}`,announceBorderReset:"Table borders reset to default",borderSwatchLabel:t=>`Border ${t}`,announceRowInsertedAbove:"Row inserted above",announceRowInsertedBelow:"Row inserted below",announceColumnInserted:t=>`Column inserted ${t}`,announceRowDeleted:"Row deleted",announceColumnDeleted:"Column deleted",announceTableDeleted:"Table deleted",insertTable:"Insert Table",tableAriaLabel:(t,e)=>`Table with ${t} rows and ${e} columns`,tableAriaDescription:"Right-click or press Shift+F10 for table actions"},z=/* #__PURE__ */Object.assign({"./locales/ar.ts":()=>import("./ar-jbplYWkC.mjs"),"./locales/de.ts":()=>import("./de-DN-e6G5A.mjs"),"./locales/es.ts":()=>import("./es-CM55WeEN.mjs"),"./locales/fr.ts":()=>import("./fr-C_2i5Ono.mjs"),"./locales/hi.ts":()=>import("./hi-C9fvG91d.mjs"),"./locales/pt.ts":()=>import("./pt-GqLw5tN0.mjs"),"./locales/ru.ts":()=>import("./ru-4g_qsaLr.mjs"),"./locales/zh.ts":()=>import("./zh-DeZP08HI.mjs")});async function $(t){return I(z,t,D)}var j=["#000000","#434343","#666666","#999999","#b7b7b7","#cccccc","#d9d9d9","#efefef","#980000","#cc0000","#e69138","#f1c232","#6aa84f","#45818e","#3c78d8","#3d85c6","#674ea7","#a64d79","#0b5394","#38761d"];function _(t,e,n){const o=t.getBlock(e);if(!o||"table"!==o.type)return null;const r=t.getNodePath(e);if(!r)return null;if(void 0===n){const{borderColor:e,...n}=o.attrs??{},l=n;return t.transaction("command").setNodeAttr(r,l).setSelection(t.selection).build()}const l={...o.attrs,borderColor:n};return t.transaction("command").setNodeAttr(r,l).setSelection(t.selection).build()}function V(t,e,n=D){const o=t.getState();if(!u(o.selection))return!1;const r=T(o,o.selection.anchor.blockId);if(!r)return!1;const l=_(o,r.tableId,e);if(!l)return!1;t.dispatch(l);const i="none"===e?"none":R(e);return t.announce(n.announceBorderColorSet(i)),!0}function O(t,e=D){const n=t.getState();if(!u(n.selection))return!1;const o=T(n,n.selection.anchor.blockId);if(!o)return!1;const r=_(n,o.tableId,void 0);return!!r&&(t.dispatch(r),t.announce(e.announceBorderReset),!0)}function F(t,e){const n=t.getBlock(e);if(n)return n.attrs?.borderColor}function q(t,e,n,o,r=D){t.classList.add("notectl-color-picker");const l=F(e.getState(),n),i=document.createElement("button");i.type="button",i.className="notectl-color-picker__default",i.textContent=r.defaultColor,i.addEventListener("mousedown",t=>{t.preventDefault(),t.stopPropagation(),O(e,r),o()}),i.addEventListener("keydown",t=>{"Escape"===t.key&&(t.preventDefault(),o())}),t.appendChild(i);const s=document.createElement("button");s.type="button",s.className="notectl-color-picker__default",s.textContent=r.noBorders,s.addEventListener("mousedown",t=>{t.preventDefault(),t.stopPropagation(),V(e,"none",r),o()}),s.addEventListener("keydown",t=>{"Escape"===t.key&&(t.preventDefault(),o())}),t.appendChild(s),B(t,{colors:j,columns:5,ariaLabel:r.borderColorPicker,ariaLabelPrefix:"",activeColor:l??null,swatchLabel:r.borderSwatchLabel,titleAsName:!0,onSelect:t=>{V(e,t,r),o()},onClose:o})}function Z(t,o,r){const i=t.getBlock(o);if(!i)return null;const s=e(i),a=s[0]?e(s[0]).length:0;if(0===a)return null;const c=function(t){const e=[];for(let n=0;n<t;n++)e.push(E());return n(b("table_row"),e,l())}(a),u=t.transaction("command").insertNode([o],r,c),p=e(c)[0],h=p?e(p)[0]:void 0;return h?u.setSelection(d(h.id,0)):p&&u.setSelection(d(p.id,0)),u.build()}function K(t,n,o){const r=t.getBlock(n);if(!r)return null;const l=e(r),i=t.transaction("command");for(const e of l){const t=E();i.insertNode([n,e.id],o,t)}return i.setSelection(t.selection),i.build()}function Y(t,n,o,r=0){const l=t.getBlock(n);if(!l)return null;if(e(l).length<=1)return W(t,n);const i=t.transaction("command").removeNode([n],o),s=M(t,n,o>0?o-1:1,r);if(s){const e=N(t,s);i.setSelection(d(e,0))}return i.build()}function X(t,n,o,r=0){const l=t.getBlock(n);if(!l)return null;const i=e(l);if((i[0]?e(i[0]).length:0)<=1)return W(t,n);const s=t.transaction("command");for(let e=i.length-1;e>=0;e--){const t=i[e];t&&s.removeNode([n,t.id],o)}const a=M(t,n,r,o>0?o-1:1);if(a){const e=N(t,a);s.setSelection(d(e,0))}return s.build()}function W(t,e){const n=t.doc.children.findIndex(t=>t.id===e);if(-1===n)return null;if(1===t.doc.children.length){const e=o(l());return t.transaction("command").insertNode([],0,e).removeNode([],1).setSelection(d(e.id,0)).build()}const r=t.transaction("command").removeNode([],n),i=t.doc.children[n+1];if(i){const e=h(t,i.id,"start");if(e)return r.setSelection(e),r.build()}const s=t.doc.children[n-1];if(s){const e=h(t,s.id,"end");if(e)return r.setSelection(e),r.build()}return null}function U(t,o,r){const i=t.getState(),s=y(i);if(!s)return!1;const a=function(t,e){const o=l(),r=[];for(let i=0;i<t;i++){const t=[];for(let n=0;n<e;n++)t.push(E());r.push(n(b("table_row"),t,l()))}return n(b("table"),r,o)}(o,r),c=i.transaction("command");if(!m(i,c,s,a))return!1;const u=e(a)[0],p=u?e(u)[0]:void 0,h=p?e(p)[0]:void 0;return h?c.setSelection(d(h.id,0)):p&&c.setSelection(d(p.id,0)),t.dispatch(c.build()),!0}function G(t,e){const n=t.getState();if(!u(n.selection))return!1;const o=T(n,n.selection.anchor.blockId);if(!o)return!1;const r=Z(n,o.tableId,o.rowIndex+1);return!!r&&(t.dispatch(r),t.announce(e.announceRowInsertedBelow),!0)}function Q(t,e,n){const o=t.getState();if(!u(o.selection))return!1;const r=T(o,o.selection.anchor.blockId);if(!r)return!1;const l="left"===e?r.colIndex:r.colIndex+1,i=K(o,r.tableId,l);return!!i&&(t.dispatch(i),t.announce(n.announceColumnInserted(e)),!0)}function J(t,e){t.registerCommand("insertTable",()=>U(t,3,3)),t.registerCommand("addRowAbove",()=>function(t,e){const n=t.getState();if(!u(n.selection))return!1;const o=T(n,n.selection.anchor.blockId);if(!o)return!1;const r=Z(n,o.tableId,o.rowIndex);return!!r&&(t.dispatch(r),t.announce(e.announceRowInsertedAbove),!0)}(t,e)),t.registerCommand("addRowBelow",()=>G(t,e)),t.registerCommand("addColumnLeft",()=>function(t,e){return Q(t,"left",e)}(t,e)),t.registerCommand("addColumnRight",()=>function(t,e){return Q(t,"right",e)}(t,e)),t.registerCommand("deleteRow",()=>function(t,e){const n=t.getState();if(!u(n.selection))return!1;const o=T(n,n.selection.anchor.blockId);if(!o)return!1;const r=Y(n,o.tableId,o.rowIndex,o.colIndex);return!!r&&(t.dispatch(r),t.announce(e.announceRowDeleted),!0)}(t,e)),t.registerCommand("deleteColumn",()=>function(t,e){const n=t.getState();if(!u(n.selection))return!1;const o=T(n,n.selection.anchor.blockId);if(!o)return!1;const r=X(n,o.tableId,o.colIndex,o.rowIndex);return!!r&&(t.dispatch(r),t.announce(e.announceColumnDeleted),!0)}(t,e)),t.registerCommand("selectTable",()=>function(t){const e=t.getState(),n=e.selection;if(s(n))return"table"===e.getBlock(n.nodeId)?.type;if(i(n))return!1;const o=T(e,n.anchor.blockId);if(!o)return!1;const r=e.getNodePath(o.tableId);if(!r)return!1;const l=e.transaction("command").setSelection(c(o.tableId,r)).build();return t.dispatch(l),!0}(t)),t.registerCommand("deleteTable",()=>function(t,e){const n=t.getState(),o=function(t){if(s(t.selection)){const e=t.getBlock(t.selection.nodeId);return"table"!==e?.type?null:{tableId:e.id}}if(i(t.selection))return null;const e=T(t,t.selection.anchor.blockId);return e?{tableId:e.tableId}:null}(n);if(!o)return!1;const r=W(n,o.tableId);return!!r&&(t.dispatch(r),t.announce(e.announceTableDeleted),!0)}(t,e))}function tt(t,e,n,o,r,l=D,i){let s=!0,a=null,c=null;const d=document.createElement("div");d.className="notectl-table-context-menu",d.setAttribute("role","menu"),d.setAttribute("aria-label",l.tableActions),d.setAttribute("contenteditable","false");const u=[];let b=0;const p=function(t){return[{type:"item",label:t.insertRowAbove,command:"addRowAbove"},{type:"item",label:t.insertRowBelow,command:"addRowBelow"},{type:"separator"},{type:"item",label:t.insertColumnLeft,command:"addColumnLeft"},{type:"item",label:t.insertColumnRight,command:"addColumnRight"},{type:"separator"},{type:"item",label:t.deleteRow,command:"deleteRow"},{type:"item",label:t.deleteColumn,command:"deleteColumn"},{type:"separator"},{type:"submenu",label:t.borderColorLabel,id:"borderColor"},{type:"separator"},{type:"item",label:t.deleteTable,command:"deleteTable"}]}(l);for(const I of p){if("separator"===I.type){const t=document.createElement("div");t.setAttribute("role","separator"),d.appendChild(t);continue}const t=document.createElement("button");t.type="button",t.setAttribute("role","menuitem"),t.textContent=I.label,"submenu"===I.type&&(t.dataset.submenu=I.id,t.setAttribute("aria-haspopup","true"),t.setAttribute("aria-expanded","false")),"item"===I.type&&(t.dataset.command=I.command),t.addEventListener("mousedown",t=>{t.preventDefault(),t.stopPropagation()}),t.addEventListener("click",n=>{n.stopPropagation(),"item"===I.type?(e.executeCommand(I.command),C()):"submenu"===I.type&&m(t)}),u.push(t),d.appendChild(t)}const h=document.createElement("div");function m(o){if(f(),o.setAttribute("aria-expanded","true"),i)c=i.open({anchor:o,position:"right",referenceNode:d,parent:{close:()=>C(),getElement:()=>d},onClose:()=>{c=null,a=null,v()},content:(t,r)=>{t.className="notectl-table-context-menu",t.setAttribute("contenteditable","false"),a=t,t.addEventListener("keydown",t=>{t.stopPropagation();const e="rtl"===getComputedStyle(d).direction?"ArrowRight":"ArrowLeft";t.key===e&&(t.preventDefault(),r(),o.focus())}),q(t,e,n,()=>C(),l)}});else{a=document.createElement("div"),a.className="notectl-table-context-menu",a.setAttribute("contenteditable","false"),a.addEventListener("keydown",t=>{t.stopPropagation();const e="rtl"===getComputedStyle(d).direction?"ArrowRight":"ArrowLeft";t.key===e&&(t.preventDefault(),f(),o.focus())}),q(a,e,n,()=>C(),l),t.appendChild(a);const r=d.getBoundingClientRect(),i="rtl"===getComputedStyle(d).direction;A(a,r,{position:"right",isRtl:i}),requestAnimationFrame(()=>{(a?.querySelector("button"))?.focus()})}}function f(){c?(c.close(),c=null,a=null):a&&(a.remove(),a=null),v()}function v(){for(const t of u)t.dataset.submenu&&t.setAttribute("aria-expanded","false")}h.className="notectl-table-context-menu__hint",h.setAttribute("aria-hidden","true"),h.textContent=l.menuKeyboardHint,d.appendChild(h),S(u,b),d.addEventListener("keydown",t=>{switch(t.stopPropagation(),t.key){case"Escape":return t.preventDefault(),void C();case"ArrowDown":return t.preventDefault(),b=(b+1)%u.length,S(u,b),void u[b]?.focus();case"ArrowUp":return t.preventDefault(),b=(b-1+u.length)%u.length,S(u,b),void u[b]?.focus();case"ArrowRight":case"ArrowLeft":{t.preventDefault();const e="rtl"===getComputedStyle(d).direction?"ArrowLeft":"ArrowRight";if(t.key===e){const t=u[b];t?.dataset.submenu&&m(t)}else f(),u[b]?.focus();return}case"Enter":case" ":{t.preventDefault();const n=u[b];if(!n)return;return void(n.dataset.submenu?m(n):n.dataset.command&&(e.executeCommand(n.dataset.command),C()))}case"Home":return t.preventDefault(),b=0,S(u,b),void u[b]?.focus();case"End":return t.preventDefault(),b=u.length-1,S(u,b),void u[b]?.focus()}}),A(d,o,{position:"below-start"}),t.appendChild(d),u[0]?.focus(),requestAnimationFrame(()=>{s&&u[0]&&u[0].focus()});const g=t=>{const e=t.composedPath();e.includes(d)||a&&e.includes(a)||C()};let x=null,w=!1;function C(){s&&(s=!1,f(),d.remove(),null!==x&&(clearTimeout(x),x=null),w&&(document.removeEventListener("mousedown",g,!0),w=!1),r?.())}return x=setTimeout(()=>{x=null,document.addEventListener("mousedown",g,!0),w=!0},0),{isOpen:()=>s,close:C,destroy:C}}var et=null;function nt(t,e){const n=t.getState();if(!u(n.selection))return!1;const o=n.selection,r=T(n,o.anchor.blockId);return!!r&&e(n,o,r)}function ot(t){return nt(t,(e,n,o)=>{const r=o.tableIndex+1;if(r>=e.doc.children.length)return!1;const l=e.doc.children[r];if(!l)return!1;const i=e.transaction("command").setSelection(d(l.id,0)).build();return t.dispatch(i),!0})}function rt(t,e,n,o){const r=t.getState(),l=M(r,e,n,o);if(!l)return!1;const i=N(r,l),s=r.transaction("command").setSelection(d(i,0)).build();return t.dispatch(s),!0}function lt(t,e,n,o){const l=t.getState(),i=M(l,e,n,o);if(!i)return!1;const s=H(l,i),a=l.getBlock(s);if(!a)return!1;const c=r(a),u=l.transaction("command").setSelection(d(s,c)).build();return t.dispatch(u),!0}function it(t,e){const n=t.getState(),o=n.getNodePath(e);if(!o)return!1;const r=n.transaction("input").setSelection(c(e,o)).build();return t.dispatch(r),!0}var st='<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12" fill="none"><path d="M6 1v10M1 6h10" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/></svg>';function at(t,e,n){const o=document.createElement("button");return o.className=t,o.innerHTML=e,o.title=n,o.type="button",o.setAttribute("aria-label",n),o.setAttribute("contenteditable","false"),o.addEventListener("mousedown",t=>{t.preventDefault(),t.stopPropagation()}),o}function ct(t,e){const n=document.createElement("div");n.className=`ntbl-insert-line ntbl-insert-line--${t}`,n.setAttribute("contenteditable","false"),n.setAttribute("data-notectl-no-print","");const o=at("ntbl-insert-btn",st,e);return n.appendChild(o),n}function dt(t,e){const n=document.createElement("button");n.className=`ntbl-add-zone ${t}`,n.type="button",n.setAttribute("contenteditable","false"),n.setAttribute("aria-label",e),n.setAttribute("data-notectl-no-print",""),n.title=e;const o=document.createElement("span");return o.className="ntbl-add-icon",o.innerHTML=st,n.appendChild(o),n.addEventListener("mousedown",t=>{t.preventDefault(),t.stopPropagation()}),n}function ut(t){const e=document.createElement("div");return e.className=t,e.setAttribute("contenteditable","false"),e.setAttribute("data-notectl-no-print",""),e}function bt(t,e){x(t,"none"===e?{backgroundColor:"transparent",border:"1px dashed rgba(128,128,128,0.4)"}:e?{backgroundColor:e,border:"1px solid rgba(0,0,0,0.15)"}:{backgroundColor:"var(--notectl-border)",border:"1px solid rgba(0,0,0,0.15)"})}function pt(t,e,n,o){const r=document.createElement("div");r.className=`ntbl-handle ${t}`,r.dataset.index=String(e);const l=at("ntbl-handle-delete",'<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10" viewBox="0 0 10 10" fill="none"><path d="M2 2l6 6M8 2l-6 6" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/></svg>',n);return l.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation(),o(e)}),r.appendChild(l),r}function ht(t,e){let n=0,o=0,r=t;for(;r&&r!==e;)n+=r.offsetTop,o+=r.offsetLeft,r=r.offsetParent;return{top:n,left:o}}var mt=class{tableId;numRows;numCols;activeRowIndex=-1;activeColIndex=-1;colBar;rowBar;insertLineH;insertLineV;addRowZone;addColZone;deleteTableBtn;borderColorBtn;actionsBtn;contextHint;observer;borderColorPopup=null;activeContextMenu=null;container;tableEl;getState;dispatchFn;pluginContext;locale;onMouseMove=t=>{const e=this.tableEl.getBoundingClientRect(),n=t.clientX-e.left,o=t.clientY-e.top;if(!(n>=-10&&n<=e.width+10&&o>=-10&&o<=e.height+10))return void this.hideInsertLines();const r=function(t,e,n,o){let r=Number.POSITIVE_INFINITY,l=null;for(const a of n){const t=Math.abs(e-a.position);t<r&&t<10&&(r=t,l=a)}let i=Number.POSITIVE_INFINITY,s=null;for(const a of o){const e=Math.abs(t-a.position);e<i&&e<10&&(i=e,s=a)}return l&&(!s||r<=i)?{type:"row",border:l}:s?{type:"col",border:s}:{type:"none",border:null}}(n,o,function(t){const e=t.querySelectorAll(":scope > tbody > tr"),n=t.offsetTop,o=[];for(let r=1;r<e.length;r++){const t=e[r];t&&o.push({position:t.offsetTop-n,index:r})}return o}(this.tableEl),function(t,e){if(e<=1)return[];const n=t/e,o=[];for(let r=1;r<e;r++)o.push({position:Math.round(n*r),index:r});return o}(this.tableEl.offsetWidth,this.numCols));"row"===r.type&&r.border?(this.showHorizontalLine(r.border),this.hideVerticalLine()):"col"===r.type&&r.border?(this.showVerticalLine(r.border),this.hideHorizontalLine()):this.hideInsertLines()};onMouseLeave=()=>{this.hideInsertLines()};constructor(t,n,o,r,l,i,s=D){if(this.container=t,this.tableEl=n,this.getState=r,this.dispatchFn=l,this.pluginContext=i??null,this.locale=s,this.tableId=o.id,this.numRows=e(o).length,this.numCols=this.countCols(o),this.colBar=ut("ntbl-col-bar"),this.rowBar=ut("ntbl-row-bar"),this.insertLineH=ct("horizontal",s.insertRow),this.insertLineV=ct("vertical",s.insertColumn),this.addRowZone=dt("ntbl-add-row",s.addRow),this.addColZone=dt("ntbl-add-col",s.addColumn),this.deleteTableBtn=at("ntbl-delete-table-btn",'<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none"><path d="M9 3h6m-9 4h12M10 11v6m4-6v6m-9 3h14l-1-13H6L5 20z" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"/></svg>',s.deleteTable),this.deleteTableBtn.setAttribute("data-notectl-no-print",""),i){const t=F(r(),this.tableId);this.borderColorBtn=function(t,e){const n=at("ntbl-border-color-btn",'<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none"><path d="M3 3h18v18H3V3zm0 6h18M3 15h18M9 3v18M15 3v18" stroke="currentColor" stroke-width="1.5"/></svg>',t);n.setAttribute("data-notectl-no-print","");const o=document.createElement("span");return o.className="ntbl-border-color-swatch",bt(o,e),n.appendChild(o),n}(s.borderColor,t),this.actionsBtn=function(t){const e=at("ntbl-actions-btn",'<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="currentColor"><circle cx="12" cy="5" r="2"/><circle cx="12" cy="12" r="2"/><circle cx="12" cy="19" r="2"/></svg>',t);return e.setAttribute("data-notectl-no-print",""),e}(s.tableActionsHint)}else this.borderColorBtn=null,this.actionsBtn=null;t.append(this.colBar,this.rowBar,this.insertLineH,this.insertLineV,this.addRowZone,this.addColZone,this.deleteTableBtn),this.borderColorBtn&&t.appendChild(this.borderColorBtn),this.actionsBtn&&t.appendChild(this.actionsBtn),this.contextHint=function(t){const e=document.createElement("div");return e.className="ntbl-context-hint",e.setAttribute("aria-hidden","true"),e.setAttribute("contenteditable","false"),e.setAttribute("data-notectl-no-print",""),e.textContent=t,e}(s.contextMenuHint),t.appendChild(this.contextHint),this.rebuildColHandles(),this.rebuildRowHandles(),this.bindEventListeners(),this.observer=new ResizeObserver(()=>{this.positionControls()}),this.observer.observe(n),requestAnimationFrame(()=>this.positionControls())}update(t){this.tableId=t.id;const n=e(t).length,o=this.countCols(t);if(n===this.numRows&&o===this.numCols||(this.numRows=n,this.numCols=o,this.rebuildColHandles(),this.rebuildRowHandles()),this.borderColorBtn){const e=this.borderColorBtn.querySelector(".ntbl-border-color-swatch");if(e){const n=t.attrs?.borderColor;bt(e,n)}}requestAnimationFrame(()=>this.positionControls())}destroy(){this.activeContextMenu?.destroy(),this.closeBorderColorPopup(),this.observer.disconnect(),this.container.removeEventListener("mousemove",this.onMouseMove),this.container.removeEventListener("mouseleave",this.onMouseLeave),this.colBar.remove(),this.rowBar.remove(),this.insertLineH.remove(),this.insertLineV.remove(),this.addRowZone.remove(),this.addColZone.remove(),this.deleteTableBtn.remove(),this.borderColorBtn?.remove(),this.actionsBtn?.remove(),this.contextHint.remove()}bindEventListeners(){const t=this.insertLineH.querySelector(".ntbl-insert-btn"),e=this.insertLineV.querySelector(".ntbl-insert-btn");if(t.addEventListener("click",()=>{this.activeRowIndex>=0&&this.dispatchTransaction(Z(this.getState(),this.tableId,this.activeRowIndex))}),e.addEventListener("click",()=>{this.activeColIndex>=0&&this.dispatchTransaction(K(this.getState(),this.tableId,this.activeColIndex))}),this.addRowZone.addEventListener("click",()=>{this.dispatchTransaction(Z(this.getState(),this.tableId,this.numRows))}),this.addColZone.addEventListener("click",()=>{this.dispatchTransaction(K(this.getState(),this.tableId,this.numCols))}),this.deleteTableBtn.addEventListener("click",()=>{this.dispatchTransaction(W(this.getState(),this.tableId))}),this.borderColorBtn&&this.pluginContext){const t=this.pluginContext;this.borderColorBtn.addEventListener("click",()=>{this.toggleBorderColorPopup(t)})}if(this.actionsBtn&&this.pluginContext){const t=this.pluginContext;this.actionsBtn.addEventListener("click",()=>{this.openActionsMenu(t)})}this.container.addEventListener("mousemove",this.onMouseMove),this.container.addEventListener("mouseleave",this.onMouseLeave)}openActionsMenu(t){if(this.activeContextMenu?.isOpen())return this.activeContextMenu.close(),void(this.activeContextMenu=null);if(!this.actionsBtn)return;const e=this.actionsBtn.getBoundingClientRect(),n=new DOMRect(e.left,e.bottom+4,0,0);this.activeContextMenu=tt(this.container,t,this.tableId,n,()=>{this.activeContextMenu=null},this.locale)}toggleBorderColorPopup(t){this.borderColorPopup?this.closeBorderColorPopup():(this.borderColorPopup=document.createElement("div"),this.borderColorPopup.className="notectl-table-context-menu",x(this.borderColorPopup,{position:"absolute",top:"24px",left:"24px",zIndex:"10000"}),this.borderColorPopup.setAttribute("contenteditable","false"),q(this.borderColorPopup,t,this.tableId,()=>{this.closeBorderColorPopup()},this.locale),this.container.appendChild(this.borderColorPopup))}closeBorderColorPopup(){this.borderColorPopup&&(this.borderColorPopup.remove(),this.borderColorPopup=null)}dispatchTransaction(t){t&&this.dispatchFn(t)}countCols(t){const n=e(t);return n[0]?e(n[0]).length:0}positionControls(){!function(t,e,n){const o=t.children;if(0===o.length)return;const r=e/n;for(let l=0;l<o.length;l++){const t=o[l];x(t,{left:`${Math.round(r*l)}px`,width:`${Math.round(r)}px`})}w(t,"width",`${e}px`)}(this.colBar,this.tableEl.offsetWidth,this.numCols),function(t,e){const n=t.children;if(0===n.length)return;const o=e.querySelectorAll(":scope > tbody > tr"),r=e.offsetTop;let l=0;for(let i=0;i<n.length;i++){const t=n[i],e=o[i];if(e){const n=e.offsetTop-r,o=e.offsetHeight;x(t,{top:`${n}px`,height:`${o}px`}),l=n+o}}w(t,"height",`${l}px`)}(this.rowBar,this.tableEl),function(t,e,n,o){const r=ht(n,o),l=n.offsetHeight,i=n.offsetWidth;x(t,{width:`${i}px`,left:`${r.left}px`}),x(e,{height:`${l}px`,top:`${r.top}px`})}(this.addRowZone,this.addColZone,this.tableEl,this.container)}showHorizontalLine(t){this.activeRowIndex=t.index;const e=ht(this.tableEl,this.container);x(this.insertLineH,{top:e.top+t.position-1+"px",left:`${e.left}px`,width:`${this.tableEl.offsetWidth}px`}),this.insertLineH.classList.add("ntbl-insert-line--visible")}showVerticalLine(t){this.activeColIndex=t.index;const e=ht(this.tableEl,this.container);x(this.insertLineV,{left:e.left+t.position-1+"px",top:`${e.top}px`,height:`${this.tableEl.offsetHeight}px`}),this.insertLineV.classList.add("ntbl-insert-line--visible")}hideInsertLines(){this.hideHorizontalLine(),this.hideVerticalLine()}hideHorizontalLine(){this.insertLineH.classList.remove("ntbl-insert-line--visible"),this.activeRowIndex=-1}hideVerticalLine(){this.insertLineV.classList.remove("ntbl-insert-line--visible"),this.activeColIndex=-1}rebuildColHandles(){this.colBar.innerHTML="";for(let t=0;t<this.numCols;t++){const e=pt("ntbl-col-handle",t,this.locale.deleteColumn,t=>{this.dispatchTransaction(X(this.getState(),this.tableId,t))});this.colBar.appendChild(e)}}rebuildRowHandles(){this.rowBar.innerHTML="";for(let t=0;t<this.numRows;t++){const e=pt("ntbl-row-handle",t,this.locale.deleteRow,t=>{this.dispatchTransaction(Y(this.getState(),this.tableId,t))});this.rowBar.appendChild(e)}}};function ft(t,e){"none"===e?(w(t,"--ntbl-border-color","transparent"),t.classList.add("notectl-table--borderless")):e?(w(t,"--ntbl-border-color",e),t.classList.remove("notectl-table--borderless")):(g(t,"--ntbl-border-color"),t.classList.remove("notectl-table--borderless"))}var vt=new C("tableSelection"),gt={maxPickerRows:8,maxPickerCols:8},xt="border-collapse: collapse; width: 100%; table-layout: fixed",wt="border: 1px solid var(--ntbl-bc, #d0d0d0); padding: 8px 12px; vertical-align: top",Ct=class{id="table";name="Table";priority=40;config;locale;selectionService=null;cleanupMouseSelection=null;context=null;constructor(t){this.config={...gt,...t}}async init(t){this.locale=await k(t,this.config.locale,D,$),t.registerStyleSheet('\n/* Table */\n.notectl-table-wrapper {\n\tmargin: 8px 0;\n\toverflow-x: auto;\n\tposition: relative;\n}\n\n.notectl-table {\n\twidth: 100%;\n\tborder-collapse: collapse;\n\ttable-layout: fixed;\n}\n\n/* Border resolution order: per-table local override → theme component token → theme global token.\n * The inline --ntbl-border-color is set by the toolbar\'s "border color" action and must win\n * over the theme so per-table customizations remain visible after a theme switch.\n */\n.notectl-table td {\n\tborder: 1px solid var(--ntbl-border-color, var(--notectl-table-border, var(--notectl-border)));\n\tbackground: var(--notectl-table-cell-bg, transparent);\n\tpadding: 8px 12px;\n\tmin-width: 60px;\n\tvertical-align: top;\n\tmin-height: 1.6em;\n}\n\n.notectl-table th {\n\tborder: 1px solid var(--ntbl-border-color, var(--notectl-table-border, var(--notectl-border)));\n\tbackground: var(--notectl-table-header-bg, var(--notectl-surface-raised));\n\tpadding: 8px 12px;\n\tmin-width: 60px;\n\tvertical-align: top;\n\ttext-align: start;\n\tfont-weight: 600;\n}\n\n.notectl-table--borderless td {\n\tborder: 1px dashed rgba(128, 128, 128, 0.15);\n}\n\n@media print {\n\t.notectl-table--borderless td {\n\t\tborder: none;\n\t}\n}\n\n.notectl-table td:focus-within {\n\toutline: 2px solid var(--notectl-primary);\n\toutline-offset: -2px;\n}\n\n.notectl-table-cell--selected {\n\tbackground: var(--notectl-primary-muted);\n}\n\n/* Table Context Menu */\n.notectl-table-context-menu {\n\tbackground: var(--notectl-surface-overlay);\n\tborder: 1px solid var(--notectl-border);\n\tborder-radius: 6px;\n\tbox-shadow: 0 4px 12px var(--notectl-shadow);\n\tpadding: 4px 0;\n\tmin-width: 180px;\n\tz-index: 10000;\n}\n\n.notectl-table-context-menu button {\n\tdisplay: block;\n\twidth: 100%;\n\tpadding: 8px 12px;\n\ttext-align: start;\n\tborder: none;\n\tbackground: none;\n\tcursor: pointer;\n\tfont-size: 14px;\n\tcolor: var(--notectl-fg);\n\tfont-family: inherit;\n}\n\n.notectl-table-context-menu button:hover {\n\tbackground: var(--notectl-hover-bg);\n}\n\n.notectl-table-context-menu hr {\n\tborder: none;\n\tborder-top: 1px solid var(--notectl-border);\n\tmargin: 4px 0;\n}\n\n/* === Table Controls === */\n\n/* Outer container for table + controls */\n.ntbl-container {\n\tposition: relative;\n\tmargin: 8px 0;\n\tpadding-block-start: 24px;\n\tpadding-inline-start: 24px;\n}\n\n.ntbl-container .notectl-table-wrapper {\n\tmargin: 0;\n}\n\n.ntbl-container.notectl-table--selected .notectl-table-wrapper {\n\toutline: 2px solid var(--notectl-primary-fg);\n\toutline-offset: 2px;\n\tborder-radius: 6px;\n}\n\n/* --- Column Handle Bar --- */\n.ntbl-col-bar {\n\tposition: absolute;\n\ttop: 0;\n\tinset-inline-start: 24px;\n\theight: 20px;\n\tdisplay: flex;\n\topacity: 0;\n\ttransition: opacity 0.2s ease;\n\tz-index: 3;\n\tpointer-events: none;\n}\n\n.ntbl-container:hover .ntbl-col-bar,\n.ntbl-container:focus-within .ntbl-col-bar {\n\topacity: 1;\n\tpointer-events: auto;\n}\n\n.ntbl-container.notectl-table--selected .ntbl-col-bar {\n\topacity: 1;\n\tpointer-events: auto;\n}\n\n/* --- Row Handle Bar --- */\n.ntbl-row-bar {\n\tposition: absolute;\n\ttop: 24px;\n\tinset-inline-start: 0;\n\twidth: 20px;\n\tdisplay: flex;\n\tflex-direction: column;\n\topacity: 0;\n\ttransition: opacity 0.2s ease;\n\tz-index: 3;\n\tpointer-events: none;\n}\n\n.ntbl-container:hover .ntbl-row-bar,\n.ntbl-container:focus-within .ntbl-row-bar {\n\topacity: 1;\n\tpointer-events: auto;\n}\n\n.ntbl-container.notectl-table--selected .ntbl-row-bar {\n\topacity: 1;\n\tpointer-events: auto;\n}\n\n/* --- Handle (shared base) --- */\n.ntbl-handle {\n\tposition: absolute;\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: center;\n\tcursor: pointer;\n\ttransition: background 0.15s ease;\n\tborder-radius: 3px;\n}\n\n.ntbl-col-handle {\n\theight: 100%;\n\tbackground: var(--notectl-hover-bg);\n\tborder-radius: 4px 4px 0 0;\n}\n\n.ntbl-col-handle:hover {\n\tbackground: var(--notectl-border);\n}\n\n.ntbl-row-handle {\n\twidth: 100%;\n\tbackground: var(--notectl-hover-bg);\n\tborder-start-start-radius: 4px;\n\tborder-end-start-radius: 4px;\n}\n\n.ntbl-row-handle:hover {\n\tbackground: var(--notectl-border);\n}\n\n/* --- Handle Delete Button --- */\n.ntbl-handle-delete {\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: center;\n\twidth: 16px;\n\theight: 16px;\n\tborder: none;\n\tbackground: transparent;\n\tcolor: var(--notectl-fg-muted);\n\tcursor: pointer;\n\tborder-radius: 3px;\n\tpadding: 0;\n\topacity: 0;\n\ttransform: scale(0.7);\n\ttransition: opacity 0.15s, transform 0.15s,\n\t\tbackground 0.15s, color 0.15s;\n}\n\n.ntbl-handle:hover .ntbl-handle-delete,\n.ntbl-handle:focus-within .ntbl-handle-delete {\n\topacity: 1;\n\ttransform: scale(1);\n}\n\n.ntbl-handle-delete:hover,\n.ntbl-handle-delete:focus-visible {\n\tbackground: var(--notectl-danger-muted);\n\tcolor: var(--notectl-danger);\n}\n\n.ntbl-handle-delete:focus-visible {\n\toutline: none;\n\tbox-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n/* --- Insert Lines --- */\n.ntbl-insert-line {\n\tposition: absolute;\n\tpointer-events: none;\n\topacity: 0;\n\ttransition: opacity 0.15s ease;\n\tz-index: 6;\n}\n\n.ntbl-insert-line--visible {\n\topacity: 1;\n\tpointer-events: auto;\n}\n\n.ntbl-insert-line--horizontal {\n\theight: 2px;\n\tbackground: linear-gradient(\n\t\t90deg,\n\t\ttransparent,\n\t\tvar(--notectl-primary) 8%,\n\t\tvar(--notectl-primary) 92%,\n\t\ttransparent\n\t);\n\tbox-shadow: 0 0 6px var(--notectl-focus-ring);\n}\n\n.ntbl-insert-line--vertical {\n\twidth: 2px;\n\tbackground: linear-gradient(\n\t\t180deg,\n\t\ttransparent,\n\t\tvar(--notectl-primary) 8%,\n\t\tvar(--notectl-primary) 92%,\n\t\ttransparent\n\t);\n\tbox-shadow: 0 0 6px var(--notectl-focus-ring);\n}\n\n/* --- Insert Button on Line --- */\n.ntbl-insert-btn {\n\tposition: absolute;\n\twidth: 20px;\n\theight: 20px;\n\tborder-radius: 50%;\n\tbackground: var(--notectl-surface-raised);\n\tborder: 2px solid var(--notectl-primary);\n\tcolor: var(--notectl-primary);\n\tcursor: pointer;\n\tpointer-events: all;\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: center;\n\tpadding: 0;\n\tbox-shadow: 0 2px 8px var(--notectl-focus-ring);\n\ttransition: background 0.15s, color 0.15s,\n\t\ttransform 0.15s, box-shadow 0.15s;\n}\n\n.ntbl-insert-line--horizontal .ntbl-insert-btn {\n\tleft: 50%;\n\ttop: -9px;\n\ttransform: translateX(-50%);\n}\n\n.ntbl-insert-line--vertical .ntbl-insert-btn {\n\ttop: 50%;\n\tinset-inline-start: -9px;\n\ttransform: translateY(-50%);\n}\n\n.ntbl-insert-btn:hover,\n.ntbl-insert-btn:focus-visible {\n\tbackground: var(--notectl-primary);\n\tcolor: var(--notectl-primary-fg);\n\tbox-shadow: 0 2px 12px var(--notectl-focus-ring);\n}\n\n.ntbl-insert-btn:focus-visible {\n\toutline: none;\n\tbox-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n.ntbl-insert-line--horizontal .ntbl-insert-btn:hover {\n\ttransform: translateX(-50%) scale(1.2);\n}\n\n.ntbl-insert-line--vertical .ntbl-insert-btn:hover {\n\ttransform: translateY(-50%) scale(1.2);\n}\n\n/* --- Add Row / Add Column Zones --- */\n.ntbl-add-zone {\n\tposition: absolute;\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: center;\n\tcursor: pointer;\n\tuser-select: none;\n\topacity: 0;\n\ttransition: opacity 0.2s ease, background 0.2s ease,\n\t\tborder-color 0.2s ease;\n}\n\n.ntbl-container:hover .ntbl-add-zone,\n.ntbl-container:focus-within .ntbl-add-zone {\n\topacity: 1;\n}\n\n.ntbl-container.notectl-table--selected .ntbl-add-zone {\n\topacity: 1;\n}\n\n.ntbl-delete-table-btn {\n\tposition: absolute;\n\ttop: 0;\n\tinset-inline-start: 0;\n\twidth: 20px;\n\theight: 20px;\n\tborder: 1px solid var(--notectl-danger);\n\tborder-radius: 4px;\n\tbackground: var(--notectl-surface-raised);\n\tcolor: var(--notectl-danger);\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\topacity: 0;\n\ttransition: opacity 0.2s ease, background 0.15s, border-color 0.15s;\n\tz-index: 7;\n}\n\n.ntbl-container:hover .ntbl-delete-table-btn,\n.ntbl-container:focus-within .ntbl-delete-table-btn,\n.ntbl-container.notectl-table--selected .ntbl-delete-table-btn {\n\topacity: 1;\n}\n\n.ntbl-delete-table-btn:hover,\n.ntbl-delete-table-btn:focus-visible {\n\tbackground: var(--notectl-danger-muted);\n\tborder-color: var(--notectl-danger);\n}\n\n.ntbl-delete-table-btn:focus-visible {\n\toutline: none;\n\tbox-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n/* --- Context Menu Discovery Hint --- */\n.ntbl-context-hint {\n\tposition: absolute;\n\ttop: 4px;\n\tinset-inline-end: 0;\n\tfont-size: 11px;\n\tcolor: var(--notectl-fg-muted);\n\tpadding: 2px 8px;\n\tborder-radius: 4px;\n\topacity: 0;\n\ttransition: opacity 0.2s ease;\n\tpointer-events: none;\n\twhite-space: nowrap;\n\tz-index: 5;\n}\n\n.ntbl-container:hover .ntbl-context-hint,\n.ntbl-container:focus-within .ntbl-context-hint,\n.ntbl-container.notectl-table--selected .ntbl-context-hint {\n\topacity: 1;\n}\n\n/* --- Table Actions Button --- */\n.ntbl-actions-btn {\n\tposition: absolute;\n\ttop: 0;\n\tinset-inline-start: 48px;\n\twidth: 20px;\n\theight: 20px;\n\tborder: 1px solid var(--notectl-border);\n\tborder-radius: 4px;\n\tbackground: var(--notectl-surface-raised);\n\tcolor: var(--notectl-fg-muted);\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\topacity: 0;\n\ttransition: opacity 0.2s ease, background 0.15s, border-color 0.15s;\n\tz-index: 7;\n\tcursor: pointer;\n\tpadding: 0;\n}\n\n.ntbl-container:hover .ntbl-actions-btn,\n.ntbl-container:focus-within .ntbl-actions-btn,\n.ntbl-container.notectl-table--selected .ntbl-actions-btn {\n\topacity: 1;\n}\n\n.ntbl-actions-btn:hover,\n.ntbl-actions-btn:focus-visible {\n\tbackground: var(--notectl-hover-bg);\n\tborder-color: var(--notectl-primary);\n}\n\n.ntbl-actions-btn:focus-visible {\n\toutline: none;\n\tbox-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n/* --- Border Color Button --- */\n.ntbl-border-color-btn {\n\tposition: absolute;\n\ttop: 0;\n\tinset-inline-start: 24px;\n\twidth: 20px;\n\theight: 20px;\n\tborder: 1px solid var(--notectl-border);\n\tborder-radius: 4px;\n\tbackground: var(--notectl-surface-raised);\n\tcolor: var(--notectl-fg-muted);\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\topacity: 0;\n\ttransition: opacity 0.2s ease, background 0.15s, border-color 0.15s;\n\tz-index: 7;\n\tcursor: pointer;\n\tpadding: 0;\n}\n\n.ntbl-container:hover .ntbl-border-color-btn,\n.ntbl-container:focus-within .ntbl-border-color-btn,\n.ntbl-container.notectl-table--selected .ntbl-border-color-btn {\n\topacity: 1;\n}\n\n.ntbl-border-color-btn:hover,\n.ntbl-border-color-btn:focus-visible {\n\tbackground: var(--notectl-hover-bg);\n\tborder-color: var(--notectl-primary);\n}\n\n.ntbl-border-color-btn:focus-visible {\n\toutline: none;\n\tbox-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n.ntbl-border-color-swatch {\n\twidth: 10px;\n\theight: 10px;\n\tborder-radius: 2px;\n\tborder: 1px solid rgba(0, 0, 0, 0.15);\n}\n\n/* --- Context Menu Keyboard Hint --- */\n.notectl-table-context-menu__hint {\n\tpadding: 4px 12px 6px;\n\tfont-size: 11px;\n\tcolor: var(--notectl-fg-muted);\n\tborder-top: 1px solid var(--notectl-border);\n\tmargin-top: 4px;\n\ttext-align: center;\n\tuser-select: none;\n}\n\n/* --- Context Menu Focus --- */\n.notectl-table-context-menu button:focus-visible {\n\toutline: none;\n\tbackground: var(--notectl-primary-muted);\n\tbox-shadow: inset 0 0 0 2px var(--notectl-focus-ring);\n}\n\n.notectl-table-context-menu [role="separator"] {\n\tborder: none;\n\tborder-top: 1px solid var(--notectl-border);\n\tmargin: 4px 0;\n\theight: 0;\n}\n\n.ntbl-add-row {\n\tbottom: 0;\n\theight: 24px;\n\tborder: 1px dashed var(--notectl-border);\n\tborder-end-start-radius: 6px;\n\tborder-end-end-radius: 6px;\n\tborder-block-start: none;\n\tcolor: var(--notectl-fg-muted);\n\ttransform: translateY(100%);\n}\n\n.ntbl-add-row:hover,\n.ntbl-add-row:focus-visible {\n\tbackground: var(--notectl-primary-muted);\n\tborder-color: var(--notectl-primary);\n\tcolor: var(--notectl-primary);\n}\n\n.ntbl-add-row:focus-visible {\n\toutline: none;\n\tbox-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n.ntbl-add-col {\n\tinset-inline-end: 0;\n\ttop: 24px;\n\twidth: 24px;\n\tborder: 1px dashed var(--notectl-border);\n\tborder-start-end-radius: 6px;\n\tborder-end-end-radius: 6px;\n\tborder-inline-start: none;\n\tcolor: var(--notectl-fg-muted);\n\ttransform: translateX(100%);\n}\n\n[dir="rtl"] .ntbl-add-col {\n\ttransform: translateX(-100%);\n}\n\n.ntbl-add-col:hover,\n.ntbl-add-col:focus-visible {\n\tbackground: var(--notectl-primary-muted);\n\tborder-color: var(--notectl-primary);\n\tcolor: var(--notectl-primary);\n}\n\n.ntbl-add-col:focus-visible {\n\toutline: none;\n\tbox-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n.ntbl-add-icon {\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: center;\n\ttransition: transform 0.2s ease;\n}\n\n.ntbl-add-zone:hover .ntbl-add-icon {\n\ttransform: scale(1.15);\n}\n'),this.context=t,this.registerNodeSpecs(t),this.registerNodeViews(t),J(t,this.locale),t.registerCommand("resetTableBorderColor",()=>O(t,this.locale)),function(t,e){t.registerKeymap({Tab:()=>function(t,e){return nt(t,(n,o,r)=>r.colIndex<r.totalCols-1?rt(t,r.tableId,r.rowIndex,r.colIndex+1):r.rowIndex<r.totalRows-1?rt(t,r.tableId,r.rowIndex+1,0):(G(t,e),!0))}(t,e),"Shift-Tab":()=>function(t){return nt(t,(e,n,o)=>o.colIndex>0?rt(t,o.tableId,o.rowIndex,o.colIndex-1):!(o.rowIndex>0)||rt(t,o.tableId,o.rowIndex-1,o.totalCols-1))}(t),Backspace:()=>function(t){return nt(t,(e,n,o)=>{if(!a(n))return!1;if(0!==n.anchor.offset)return!1;if(0!==o.rowIndex||0!==o.colIndex)return!1;const r=N(e,o.cellId);return n.anchor.blockId===r&&it(t,o.tableId)})}(t),Delete:()=>function(t){return nt(t,(e,n,o)=>{if(!a(n))return!1;const l=e.getBlock(n.anchor.blockId);if(!l)return!1;const i=r(l);if(n.anchor.offset!==i)return!1;if(o.rowIndex!==o.totalRows-1||o.colIndex!==o.totalCols-1)return!1;const s=H(e,o.cellId);return n.anchor.blockId===s&&it(t,o.tableId)})}(t),ArrowDown:()=>function(t){return nt(t,(e,n,o)=>{const r=H(e,o.cellId);return n.anchor.blockId===r&&(o.rowIndex>=o.totalRows-1?ot(t):rt(t,o.tableId,o.rowIndex+1,o.colIndex))})}(t),ArrowUp:()=>function(t){return nt(t,(e,n,o)=>{const r=N(e,o.cellId);return n.anchor.blockId===r&&!(o.rowIndex<=0)&&rt(t,o.tableId,o.rowIndex-1,o.colIndex)})}(t),ArrowRight:()=>function(t){return nt(t,(e,n,o)=>{if(!a(n))return!1;const l=e.getBlock(n.anchor.blockId);if(!l)return!1;const i=r(l);if(n.anchor.offset!==i)return!1;const s=H(e,o.cellId);return n.anchor.blockId===s&&(o.colIndex<o.totalCols-1?rt(t,o.tableId,o.rowIndex,o.colIndex+1):!(o.rowIndex<o.totalRows-1)||rt(t,o.tableId,o.rowIndex+1,0))})}(t),ArrowLeft:()=>function(t){return nt(t,(e,n,o)=>{if(!a(n))return!1;if(0!==n.anchor.offset)return!1;const r=N(e,o.cellId);return n.anchor.blockId===r&&(o.colIndex>0?lt(t,o.tableId,o.rowIndex,o.colIndex-1):!(o.rowIndex>0)||lt(t,o.tableId,o.rowIndex-1,o.totalCols-1))})}(t),Escape:()=>ot(t),"Shift-F10":()=>function(t){return nt(t,(e,n,o)=>{const r=t.getContainer(),l=r.querySelector(`[data-block-id="${o.cellId}"]`);if(!l)return!1;const i=l.getBoundingClientRect(),s=new DOMRect(i.left+i.width/2,i.bottom,0,0),a=r.querySelector(`[data-block-id="${o.tableId}"].ntbl-container`)??r;return et?.close(),et=tt(a,t,o.tableId,s,()=>{et=null}),!0})}(t)},{priority:"context"})}(t,this.locale),this.registerToolbarItem(t),this.selectionService=function(t){let e=null,n=[],o=/* @__PURE__ */new Set;function r(){if(!e)return n=[],void(o=/* @__PURE__ */new Set);const r=t.getState(),l=[],i=Math.min(e.fromRow,e.toRow),s=Math.max(e.fromRow,e.toRow),a=Math.min(e.fromCol,e.toCol),c=Math.max(e.fromCol,e.toCol);for(let t=i;t<=s;t++)for(let n=a;n<=c;n++){const o=M(r,e.tableId,t,n);o&&l.push(o)}n=l,o=new Set(l)}const l={getSelectedRange:()=>e,setSelectedRange(n){e=n,r();const o=t.getState();t.dispatch(o.transaction("api").setSelection(o.selection).build())},clearSelectionSilent(){e=null,r()},getSelectedCellIds:()=>n,isSelected:t=>o.has(t)};return t.registerService(vt,l),l}(t)}onReady(){this.context&&this.selectionService&&(this.cleanupMouseSelection=function(t,e){const n=t.getContainer();let o=null,r=!1;function l(n){const l=n.target.closest("td[data-block-id]");if(!l)return o=null,r=!1,void e.setSelectedRange(null);if(n.shiftKey){if(o){const r=T(t.getState(),l.getAttribute("data-block-id"));if(!r||r.tableId!==o.tableId)return o=null,void e.setSelectedRange(null);n.preventDefault(),e.setSelectedRange({tableId:o.tableId,fromRow:o.row,fromCol:o.col,toRow:r.rowIndex,toCol:r.colIndex})}}else{e.setSelectedRange(null);const n=T(t.getState(),l.getAttribute("data-block-id"));if(!n)return o=null,void(r=!1);o={tableId:n.tableId,row:n.rowIndex,col:n.colIndex},r=!0}}function i(n){if(!r||!o)return;const l=n.target.closest("td[data-block-id]");if(!l)return;const i=T(t.getState(),l.getAttribute("data-block-id"));i&&i.tableId===o.tableId&&(i.rowIndex===o.row&&i.colIndex===o.col||(n.preventDefault(),e.setSelectedRange({tableId:o.tableId,fromRow:o.row,fromCol:o.col,toRow:i.rowIndex,toCol:i.colIndex})))}function s(){r=!1}return n.addEventListener("mousedown",l),n.addEventListener("mousemove",i),document.addEventListener("mouseup",s),()=>{n.removeEventListener("mousedown",l),n.removeEventListener("mousemove",i),document.removeEventListener("mouseup",s)}}(this.context,this.selectionService))}destroy(){this.cleanupMouseSelection?.(),this.cleanupMouseSelection=null,this.selectionService=null,this.context=null}decorations(t){if(!this.selectionService)return v.empty;if(!this.selectionService.getSelectedRange())return v.empty;const e=t.selection;if(!u(e)||!P(t,e.anchor.blockId))return this.selectionService.clearSelectionSilent(),v.empty;const n=this.selectionService.getSelectedCellIds();if(0===n.length)return v.empty;const o=[];for(const r of n)o.push(f(r,{class:"notectl-table-cell--selected"}));return v.create(o)}registerNodeSpecs(t){t.registerNodeSpec({type:"table",group:"block",content:{allow:["table_row"],min:1},isolating:!0,selectable:!0,toDOM(t){const e=document.createElement("div");return e.className="notectl-table-wrapper",e.setAttribute("data-block-id",t.id),e.setAttribute("part","table"),e},toHTML(t,e,n){const o=t.attrs?.borderColor,r=function(t){return t?"none"===t?`${xt}; --ntbl-bc: transparent`:L(t)?`${xt}; --ntbl-bc: ${p(t)}`:xt:xt}(o);return`<table${n?.styleAttr(r)??` style="${r}"`}>${e}</table>`},sanitize:{tags:["table","tbody"]}}),t.registerNodeSpec({type:"table_row",group:"table_content",content:{allow:["table_cell"],min:1},toDOM(t){const e=document.createElement("tr");return e.setAttribute("data-block-id",t.id),e.setAttribute("role","row"),e.setAttribute("part","table-row"),e},toHTML:(t,e)=>`<tr>${e}</tr>`,sanitize:{tags:["tr"]}}),t.registerNodeSpec({type:"table_cell",group:"table_content",content:{allow:["paragraph","list_item","heading","blockquote","image","video","horizontal_rule"]},isolating:!0,toDOM(t){const e=document.createElement("td");return e.setAttribute("data-block-id",t.id),e.setAttribute("role","cell"),e.setAttribute("part","table-cell"),e},toHTML(t,e,n){const o=t.attrs?.colspan??1,r=t.attrs?.rowspan??1,l=[n?.styleAttr(wt)??` style="${wt}"`];return o>1&&l.push(` colspan="${o}"`),r>1&&l.push(` rowspan="${r}"`),`<td${l.join("")}>${e}</td>`},sanitize:{tags:["td"],attrs:["colspan","rowspan"]}})}registerNodeViews(t){t.getSchemaRegistry(),t.registerNodeView("table",function(t,n,o=D){return(t,r,l)=>{const i=document.createElement("div");i.className="ntbl-container",i.setAttribute("data-block-id",t.id),i.setAttribute("data-selectable","true");const s=document.createElement("div");s.className="notectl-table-wrapper",s.setAttribute("part","table");const a=document.createElement("table");a.className="notectl-table",a.setAttribute("role","table");const c=e(t),d=c.length,u=c[0]?e(c[0]).length:0;a.setAttribute("aria-label",o.tableAriaLabel(d,u)),a.setAttribute("aria-description",o.tableAriaDescription);const b=document.createElement("tbody");a.appendChild(b),s.appendChild(a),i.appendChild(s),ft(a,t.attrs?.borderColor);const p=document.createElement("div");p.className="notectl-sr-only",p.setAttribute("aria-live","polite"),p.setAttribute("aria-atomic","true"),i.appendChild(p);const h=function(t,e,n,o,r,l,i){return new mt(t,e,n,o,r,l,i)}(i,a,t,r,l,n,o);let m=null,f=t.id;const v=t=>{if(!n)return;t.preventDefault(),t.stopPropagation(),m?.close();const e=new DOMRect(t.clientX,t.clientY,0,0);m=tt(i,n,f,e,()=>{m=null},o)};return a.addEventListener("contextmenu",v),{dom:i,contentDOM:b,update(t){if("table"!==t.type)return!1;f=t.id,i.setAttribute("data-block-id",t.id),i.setAttribute("data-selectable","true");const n=e(t),r=n.length,l=n[0]?e(n[0]).length:0;return a.setAttribute("aria-label",o.tableAriaLabel(r,l)),ft(a,t.attrs?.borderColor),h.update(t),!1},destroy(){m?.destroy(),a.removeEventListener("contextmenu",v),h.destroy()},selectNode(){i.classList.add("notectl-table--selected")},deselectNode(){i.classList.remove("notectl-table--selected")}}}}(0,t,this.locale)),t.registerNodeView("table_row",(t,e,n)=>{const o=document.createElement("tr");return o.setAttribute("data-block-id",t.id),o.setAttribute("role","row"),o.setAttribute("part","table-row"),{dom:o,contentDOM:o,update:t=>("table_row"!==t.type||o.setAttribute("data-block-id",t.id),!1),destroy(){}}}),t.registerNodeView("table_cell",(t,e,n)=>{const o=document.createElement("td");o.setAttribute("data-block-id",t.id),o.setAttribute("role","cell"),o.setAttribute("part","table-cell");const r=t.attrs?.colspan??1,l=t.attrs?.rowspan??1;r>1&&(o.colSpan=r),l>1&&(o.rowSpan=l);const i=t.attrs?.align;return i&&"left"!==i&&w(o,"textAlign",i),{dom:o,contentDOM:o,update(t){if("table_cell"!==t.type)return!1;o.setAttribute("data-block-id",t.id);const e=t.attrs?.colspan??1,n=t.attrs?.rowspan??1;return e>1?o.colSpan=e:o.removeAttribute("colspan"),n>1?o.rowSpan=n:o.removeAttribute("rowspan"),!1},destroy(){}}})}registerToolbarItem(t){const e=this.config.maxPickerRows??8,n=this.config.maxPickerCols??8;t.registerToolbarItem({id:"table",group:"insert",icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M3 3h18v18H3V3zm2 2v4h6V5H5zm8 0v4h6V5h-6zm-8 6v4h6v-4H5zm8 0v4h6v-4h-6zm-8 6v4h6v-4H5zm8 0v4h6v-4h-6z"/></svg>',label:this.locale.insertTable,tooltip:this.locale.insertTable,command:"insertTable",popupType:"gridPicker",popupConfig:{maxRows:e,maxCols:n,onSelect:(e,n)=>{U(t,e,n)}},isActive:t=>!!u(t.selection)&&P(t,t.selection.anchor.blockId)})}};export{vt as n,Ct as t};
2
- //# sourceMappingURL=TablePlugin-D93RR5xH.mjs.map
1
+ import{c as t,d as e,i as n,o,p as r,u as l}from"./Document-r7vLOAGA.mjs";import{c as i,l as s,o as a,r as c,t as d,u}from"./Selection-HYoVFpAx.mjs";import{a as b}from"./TypeBrands-Ch9856Gb.mjs";import{r as p}from"./HTMLUtils-C6B4UT00.mjs";import{_ as h,s as m}from"./BlockInsertion-6rR9tIGP.mjs";import{i as f,t as v}from"./Decoration-ZeyVfwJB.mjs";import{c as g,o as x,s as w}from"./StyleRuntime-BFKu52mS.mjs";import{n as C}from"./TypedKeys-CA4bfw9O.mjs";import{c as I,i as y,o as k}from"./PluginHelpers-KDuTlmXm.mjs";import{t as S}from"./KeyboardNav-D0my3wuy.mjs";import{r as A}from"./PopupPositioning-BB97-__N.mjs";import{i as L}from"./ColorValidation-DAijTjG9.mjs";import{n as R,t as B}from"./ColorGrid-DPNiXxpD.mjs";function E(){const e=n(b("paragraph"),[t("")],l());return n(b("table_cell"),[e],l())}function T(t,n){const o=t.getNodePath(n);if(!o)return null;let r=null,l=null,i=null,s=null;for(const e of o){const n=t.getBlock(e);n&&("table"===n.type?(r=e,l=n):"table_row"===n.type?i=e:"table_cell"===n.type&&(s=e))}if("table_cell"===t.getBlock(n)?.type&&(s=n),!(r&&l&&s&&i))return null;const a=t.doc.children.findIndex(t=>t.id===r),c=e(l),d=c.findIndex(t=>t.id===i);if(-1===d)return null;const u=c[d];if(!u)return null;const b=e(u),p=b.findIndex(t=>t.id===s);if(-1===p)return null;const h=b.length,m=c.length;return{tableId:r,tableIndex:a,rowId:i,rowIndex:d,cellId:s,colIndex:p,totalRows:m,totalCols:h}}function M(t,n,o,r){const l=t.getBlock(n);if(!l)return null;const i=e(l)[o];return i?e(i)[r]?.id??null:null}function N(t,n){const o=t.getBlock(n);if(!o)return n;const r=e(o)[0];if(!r)return n;let l=r;for(;;){const t=e(l)[0];if(!t)return l.id;l=t}}function H(t,n){const o=t.getBlock(n);if(!o)return n;const r=e(o),l=r[r.length-1];if(!l)return n;let i=l;for(;;){const t=e(i),n=t[t.length-1];if(!n)return i.id;i=n}}function P(t,e){const n=t.getNodePath(e);if(!n)return!1;for(const o of n)if("table"===t.getBlock(o)?.type)return!0;return!1}var D={insertRowAbove:"Insert Row Above",insertRowBelow:"Insert Row Below",insertColumnLeft:"Insert Column Left",insertColumnRight:"Insert Column Right",deleteRow:"Delete Row",deleteColumn:"Delete Column",borderColorLabel:"Border Color...",deleteTable:"Delete Table",tableActions:"Table actions",menuKeyboardHint:"↑↓ Navigate · Enter Select · Esc Close",insertRow:"Insert row",insertColumn:"Insert column",addRow:"Add row",addColumn:"Add column",tableActionsHint:"Table actions (Right-click or Shift+F10)",contextMenuHint:"Right-click or Shift+F10 for table actions",borderColor:"Border color",defaultColor:"Default",noBorders:"No borders",borderColorPicker:"Border color picker",announceBorderColorSet:t=>`Table border color set to ${t}`,announceBorderReset:"Table borders reset to default",borderSwatchLabel:t=>`Border ${t}`,announceRowInsertedAbove:"Row inserted above",announceRowInsertedBelow:"Row inserted below",announceColumnInserted:t=>`Column inserted ${t}`,announceRowDeleted:"Row deleted",announceColumnDeleted:"Column deleted",announceTableDeleted:"Table deleted",insertTable:"Insert Table",tableAriaLabel:(t,e)=>`Table with ${t} rows and ${e} columns`,tableAriaDescription:"Right-click or press Shift+F10 for table actions"},z=/* #__PURE__ */Object.assign({"./locales/ar.ts":()=>import("./ar-jbplYWkC.mjs"),"./locales/de.ts":()=>import("./de-DN-e6G5A.mjs"),"./locales/es.ts":()=>import("./es-CM55WeEN.mjs"),"./locales/fr.ts":()=>import("./fr-C_2i5Ono.mjs"),"./locales/hi.ts":()=>import("./hi-C9fvG91d.mjs"),"./locales/pt.ts":()=>import("./pt-GqLw5tN0.mjs"),"./locales/ru.ts":()=>import("./ru-4g_qsaLr.mjs"),"./locales/zh.ts":()=>import("./zh-DeZP08HI.mjs")});async function $(t){return I(z,t,D)}var j=["#000000","#434343","#666666","#999999","#b7b7b7","#cccccc","#d9d9d9","#efefef","#980000","#cc0000","#e69138","#f1c232","#6aa84f","#45818e","#3c78d8","#3d85c6","#674ea7","#a64d79","#0b5394","#38761d"];function _(t,e,n){const o=t.getBlock(e);if(!o||"table"!==o.type)return null;const r=t.getNodePath(e);if(!r)return null;if(void 0===n){const{borderColor:e,...n}=o.attrs??{},l=n;return t.transaction("command").setNodeAttr(r,l).setSelection(t.selection).build()}const l={...o.attrs,borderColor:n};return t.transaction("command").setNodeAttr(r,l).setSelection(t.selection).build()}function V(t,e,n=D){const o=t.getState();if(!u(o.selection))return!1;const r=T(o,o.selection.anchor.blockId);if(!r)return!1;const l=_(o,r.tableId,e);if(!l)return!1;t.dispatch(l);const i="none"===e?"none":R(e);return t.announce(n.announceBorderColorSet(i)),!0}function O(t,e=D){const n=t.getState();if(!u(n.selection))return!1;const o=T(n,n.selection.anchor.blockId);if(!o)return!1;const r=_(n,o.tableId,void 0);return!!r&&(t.dispatch(r),t.announce(e.announceBorderReset),!0)}function F(t,e){const n=t.getBlock(e);if(n)return n.attrs?.borderColor}function q(t,e,n,o,r=D){t.classList.add("notectl-color-picker");const l=F(e.getState(),n),i=document.createElement("button");i.type="button",i.className="notectl-color-picker__default",i.textContent=r.defaultColor,i.addEventListener("mousedown",t=>{t.preventDefault(),t.stopPropagation(),O(e,r),o()}),i.addEventListener("keydown",t=>{"Escape"===t.key&&(t.preventDefault(),o())}),t.appendChild(i);const s=document.createElement("button");s.type="button",s.className="notectl-color-picker__default",s.textContent=r.noBorders,s.addEventListener("mousedown",t=>{t.preventDefault(),t.stopPropagation(),V(e,"none",r),o()}),s.addEventListener("keydown",t=>{"Escape"===t.key&&(t.preventDefault(),o())}),t.appendChild(s),B(t,{colors:j,columns:5,ariaLabel:r.borderColorPicker,ariaLabelPrefix:"",activeColor:l??null,swatchLabel:r.borderSwatchLabel,titleAsName:!0,onSelect:t=>{V(e,t,r),o()},onClose:o})}function Z(t,o,r){const i=t.getBlock(o);if(!i)return null;const s=e(i),a=s[0]?e(s[0]).length:0;if(0===a)return null;const c=function(t){const e=[];for(let n=0;n<t;n++)e.push(E());return n(b("table_row"),e,l())}(a),u=t.transaction("command").insertNode([o],r,c),p=e(c)[0],h=p?e(p)[0]:void 0;return h?u.setSelection(d(h.id,0)):p&&u.setSelection(d(p.id,0)),u.build()}function K(t,n,o){const r=t.getBlock(n);if(!r)return null;const l=e(r),i=t.transaction("command");for(const e of l){const t=E();i.insertNode([n,e.id],o,t)}return i.setSelection(t.selection),i.build()}function Y(t,n,o,r=0){const l=t.getBlock(n);if(!l)return null;if(e(l).length<=1)return W(t,n);const i=t.transaction("command").removeNode([n],o),s=M(t,n,o>0?o-1:1,r);if(s){const e=N(t,s);i.setSelection(d(e,0))}return i.build()}function X(t,n,o,r=0){const l=t.getBlock(n);if(!l)return null;const i=e(l);if((i[0]?e(i[0]).length:0)<=1)return W(t,n);const s=t.transaction("command");for(let e=i.length-1;e>=0;e--){const t=i[e];t&&s.removeNode([n,t.id],o)}const a=M(t,n,r,o>0?o-1:1);if(a){const e=N(t,a);s.setSelection(d(e,0))}return s.build()}function W(t,e){const n=t.doc.children.findIndex(t=>t.id===e);if(-1===n)return null;if(1===t.doc.children.length){const e=o(l());return t.transaction("command").insertNode([],0,e).removeNode([],1).setSelection(d(e.id,0)).build()}const r=t.transaction("command").removeNode([],n),i=t.doc.children[n+1];if(i){const e=h(t,i.id,"start");if(e)return r.setSelection(e),r.build()}const s=t.doc.children[n-1];if(s){const e=h(t,s.id,"end");if(e)return r.setSelection(e),r.build()}return null}function U(t,o,r){const i=t.getState(),s=y(i);if(!s)return!1;const a=function(t,e){const o=l(),r=[];for(let i=0;i<t;i++){const t=[];for(let n=0;n<e;n++)t.push(E());r.push(n(b("table_row"),t,l()))}return n(b("table"),r,o)}(o,r),c=i.transaction("command");if(!m(i,c,s,a))return!1;const u=e(a)[0],p=u?e(u)[0]:void 0,h=p?e(p)[0]:void 0;return h?c.setSelection(d(h.id,0)):p&&c.setSelection(d(p.id,0)),t.dispatch(c.build()),!0}function G(t,e){const n=t.getState();if(!u(n.selection))return!1;const o=T(n,n.selection.anchor.blockId);if(!o)return!1;const r=Z(n,o.tableId,o.rowIndex+1);return!!r&&(t.dispatch(r),t.announce(e.announceRowInsertedBelow),!0)}function Q(t,e,n){const o=t.getState();if(!u(o.selection))return!1;const r=T(o,o.selection.anchor.blockId);if(!r)return!1;const l="left"===e?r.colIndex:r.colIndex+1,i=K(o,r.tableId,l);return!!i&&(t.dispatch(i),t.announce(n.announceColumnInserted(e)),!0)}function J(t,e){t.registerCommand("insertTable",()=>U(t,3,3)),t.registerCommand("addRowAbove",()=>function(t,e){const n=t.getState();if(!u(n.selection))return!1;const o=T(n,n.selection.anchor.blockId);if(!o)return!1;const r=Z(n,o.tableId,o.rowIndex);return!!r&&(t.dispatch(r),t.announce(e.announceRowInsertedAbove),!0)}(t,e)),t.registerCommand("addRowBelow",()=>G(t,e)),t.registerCommand("addColumnLeft",()=>function(t,e){return Q(t,"left",e)}(t,e)),t.registerCommand("addColumnRight",()=>function(t,e){return Q(t,"right",e)}(t,e)),t.registerCommand("deleteRow",()=>function(t,e){const n=t.getState();if(!u(n.selection))return!1;const o=T(n,n.selection.anchor.blockId);if(!o)return!1;const r=Y(n,o.tableId,o.rowIndex,o.colIndex);return!!r&&(t.dispatch(r),t.announce(e.announceRowDeleted),!0)}(t,e)),t.registerCommand("deleteColumn",()=>function(t,e){const n=t.getState();if(!u(n.selection))return!1;const o=T(n,n.selection.anchor.blockId);if(!o)return!1;const r=X(n,o.tableId,o.colIndex,o.rowIndex);return!!r&&(t.dispatch(r),t.announce(e.announceColumnDeleted),!0)}(t,e)),t.registerCommand("selectTable",()=>function(t){const e=t.getState(),n=e.selection;if(s(n))return"table"===e.getBlock(n.nodeId)?.type;if(i(n))return!1;const o=T(e,n.anchor.blockId);if(!o)return!1;const r=e.getNodePath(o.tableId);if(!r)return!1;const l=e.transaction("command").setSelection(c(o.tableId,r)).build();return t.dispatch(l),!0}(t)),t.registerCommand("deleteTable",()=>function(t,e){const n=t.getState(),o=function(t){if(s(t.selection)){const e=t.getBlock(t.selection.nodeId);return"table"!==e?.type?null:{tableId:e.id}}if(i(t.selection))return null;const e=T(t,t.selection.anchor.blockId);return e?{tableId:e.tableId}:null}(n);if(!o)return!1;const r=W(n,o.tableId);return!!r&&(t.dispatch(r),t.announce(e.announceTableDeleted),!0)}(t,e))}function tt(t,e,n,o,r,l=D,i){let s=!0,a=null,c=null;const d=document.createElement("div");d.className="notectl-table-context-menu",d.setAttribute("role","menu"),d.setAttribute("aria-label",l.tableActions),d.setAttribute("contenteditable","false");const u=[];let b=0;const p=function(t){return[{type:"item",label:t.insertRowAbove,command:"addRowAbove"},{type:"item",label:t.insertRowBelow,command:"addRowBelow"},{type:"separator"},{type:"item",label:t.insertColumnLeft,command:"addColumnLeft"},{type:"item",label:t.insertColumnRight,command:"addColumnRight"},{type:"separator"},{type:"item",label:t.deleteRow,command:"deleteRow"},{type:"item",label:t.deleteColumn,command:"deleteColumn"},{type:"separator"},{type:"submenu",label:t.borderColorLabel,id:"borderColor"},{type:"separator"},{type:"item",label:t.deleteTable,command:"deleteTable"}]}(l);for(const I of p){if("separator"===I.type){const t=document.createElement("div");t.setAttribute("role","separator"),d.appendChild(t);continue}const t=document.createElement("button");t.type="button",t.setAttribute("role","menuitem"),t.textContent=I.label,"submenu"===I.type&&(t.dataset.submenu=I.id,t.setAttribute("aria-haspopup","true"),t.setAttribute("aria-expanded","false")),"item"===I.type&&(t.dataset.command=I.command),t.addEventListener("mousedown",t=>{t.preventDefault(),t.stopPropagation()}),t.addEventListener("click",n=>{n.stopPropagation(),"item"===I.type?(e.executeCommand(I.command),C()):"submenu"===I.type&&m(t)}),u.push(t),d.appendChild(t)}const h=document.createElement("div");function m(o){if(f(),o.setAttribute("aria-expanded","true"),i)c=i.open({anchor:o,position:"right",referenceNode:d,parent:{close:()=>C(),getElement:()=>d},onClose:()=>{c=null,a=null,v()},content:(t,r)=>{t.className="notectl-table-context-menu",t.setAttribute("contenteditable","false"),a=t,t.addEventListener("keydown",t=>{t.stopPropagation();const e="rtl"===getComputedStyle(d).direction?"ArrowRight":"ArrowLeft";t.key===e&&(t.preventDefault(),r(),o.focus())}),q(t,e,n,()=>C(),l)}});else{a=document.createElement("div"),a.className="notectl-table-context-menu",a.setAttribute("contenteditable","false"),a.addEventListener("keydown",t=>{t.stopPropagation();const e="rtl"===getComputedStyle(d).direction?"ArrowRight":"ArrowLeft";t.key===e&&(t.preventDefault(),f(),o.focus())}),q(a,e,n,()=>C(),l),t.appendChild(a);const r=d.getBoundingClientRect(),i="rtl"===getComputedStyle(d).direction;A(a,r,{position:"right",isRtl:i}),requestAnimationFrame(()=>{(a?.querySelector("button"))?.focus()})}}function f(){c?(c.close(),c=null,a=null):a&&(a.remove(),a=null),v()}function v(){for(const t of u)t.dataset.submenu&&t.setAttribute("aria-expanded","false")}h.className="notectl-table-context-menu__hint",h.setAttribute("aria-hidden","true"),h.textContent=l.menuKeyboardHint,d.appendChild(h),S(u,b),d.addEventListener("keydown",t=>{switch(t.stopPropagation(),t.key){case"Escape":return t.preventDefault(),void C();case"ArrowDown":return t.preventDefault(),b=(b+1)%u.length,S(u,b),void u[b]?.focus();case"ArrowUp":return t.preventDefault(),b=(b-1+u.length)%u.length,S(u,b),void u[b]?.focus();case"ArrowRight":case"ArrowLeft":{t.preventDefault();const e="rtl"===getComputedStyle(d).direction?"ArrowLeft":"ArrowRight";if(t.key===e){const t=u[b];t?.dataset.submenu&&m(t)}else f(),u[b]?.focus();return}case"Enter":case" ":{t.preventDefault();const n=u[b];if(!n)return;return void(n.dataset.submenu?m(n):n.dataset.command&&(e.executeCommand(n.dataset.command),C()))}case"Home":return t.preventDefault(),b=0,S(u,b),void u[b]?.focus();case"End":return t.preventDefault(),b=u.length-1,S(u,b),void u[b]?.focus()}}),A(d,o,{position:"below-start"}),t.appendChild(d),u[0]?.focus(),requestAnimationFrame(()=>{s&&u[0]&&u[0].focus()});const g=t=>{const e=t.composedPath();e.includes(d)||a&&e.includes(a)||C()};let x=null,w=!1;function C(){s&&(s=!1,f(),d.remove(),null!==x&&(clearTimeout(x),x=null),w&&(document.removeEventListener("mousedown",g,!0),w=!1),r?.())}return x=setTimeout(()=>{x=null,document.addEventListener("mousedown",g,!0),w=!0},0),{isOpen:()=>s,close:C,destroy:C}}var et=null;function nt(t,e){const n=t.getState();if(!u(n.selection))return!1;const o=n.selection,r=T(n,o.anchor.blockId);return!!r&&e(n,o,r)}function ot(t){return nt(t,(e,n,o)=>{const r=o.tableIndex+1;if(r>=e.doc.children.length)return!1;const l=e.doc.children[r];if(!l)return!1;const i=e.transaction("command").setSelection(d(l.id,0)).build();return t.dispatch(i),!0})}function rt(t,e,n,o){const r=t.getState(),l=M(r,e,n,o);if(!l)return!1;const i=N(r,l),s=r.transaction("command").setSelection(d(i,0)).build();return t.dispatch(s),!0}function lt(t,e,n,o){const l=t.getState(),i=M(l,e,n,o);if(!i)return!1;const s=H(l,i),a=l.getBlock(s);if(!a)return!1;const c=r(a),u=l.transaction("command").setSelection(d(s,c)).build();return t.dispatch(u),!0}function it(t,e){const n=t.getState(),o=n.getNodePath(e);if(!o)return!1;const r=n.transaction("input").setSelection(c(e,o)).build();return t.dispatch(r),!0}var st='<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12" fill="none"><path d="M6 1v10M1 6h10" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/></svg>';function at(t,e,n){const o=document.createElement("button");return o.className=t,o.innerHTML=e,o.title=n,o.type="button",o.setAttribute("aria-label",n),o.setAttribute("contenteditable","false"),o.addEventListener("mousedown",t=>{t.preventDefault(),t.stopPropagation()}),o}function ct(t,e){const n=document.createElement("div");n.className=`ntbl-insert-line ntbl-insert-line--${t}`,n.setAttribute("contenteditable","false"),n.setAttribute("data-notectl-no-print","");const o=at("ntbl-insert-btn",st,e);return n.appendChild(o),n}function dt(t,e){const n=document.createElement("button");n.className=`ntbl-add-zone ${t}`,n.type="button",n.setAttribute("contenteditable","false"),n.setAttribute("aria-label",e),n.setAttribute("data-notectl-no-print",""),n.title=e;const o=document.createElement("span");return o.className="ntbl-add-icon",o.innerHTML=st,n.appendChild(o),n.addEventListener("mousedown",t=>{t.preventDefault(),t.stopPropagation()}),n}function ut(t){const e=document.createElement("div");return e.className=t,e.setAttribute("contenteditable","false"),e.setAttribute("data-notectl-no-print",""),e}function bt(t,e){w(t,"none"===e?{backgroundColor:"transparent",border:"1px dashed rgba(128,128,128,0.4)"}:e?{backgroundColor:e,border:"1px solid rgba(0,0,0,0.15)"}:{backgroundColor:"var(--notectl-border)",border:"1px solid rgba(0,0,0,0.15)"})}function pt(t,e,n,o){const r=document.createElement("div");r.className=`ntbl-handle ${t}`,r.dataset.index=String(e);const l=at("ntbl-handle-delete",'<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10" viewBox="0 0 10 10" fill="none"><path d="M2 2l6 6M8 2l-6 6" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/></svg>',n);return l.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation(),o(e)}),r.appendChild(l),r}function ht(t,e){let n=0,o=0,r=t;for(;r&&r!==e;)n+=r.offsetTop,o+=r.offsetLeft,r=r.offsetParent;return{top:n,left:o}}var mt=class{tableId;numRows;numCols;activeRowIndex=-1;activeColIndex=-1;colBar;rowBar;insertLineH;insertLineV;addRowZone;addColZone;deleteTableBtn;borderColorBtn;actionsBtn;contextHint;observer;borderColorPopup=null;activeContextMenu=null;container;tableEl;getState;dispatchFn;pluginContext;locale;onMouseMove=t=>{const e=this.tableEl.getBoundingClientRect(),n=t.clientX-e.left,o=t.clientY-e.top;if(!(n>=-10&&n<=e.width+10&&o>=-10&&o<=e.height+10))return void this.hideInsertLines();const r=function(t,e,n,o){let r=Number.POSITIVE_INFINITY,l=null;for(const a of n){const t=Math.abs(e-a.position);t<r&&t<10&&(r=t,l=a)}let i=Number.POSITIVE_INFINITY,s=null;for(const a of o){const e=Math.abs(t-a.position);e<i&&e<10&&(i=e,s=a)}return l&&(!s||r<=i)?{type:"row",border:l}:s?{type:"col",border:s}:{type:"none",border:null}}(n,o,function(t){const e=t.querySelectorAll(":scope > tbody > tr"),n=t.offsetTop,o=[];for(let r=1;r<e.length;r++){const t=e[r];t&&o.push({position:t.offsetTop-n,index:r})}return o}(this.tableEl),function(t,e){if(e<=1)return[];const n=t/e,o=[];for(let r=1;r<e;r++)o.push({position:Math.round(n*r),index:r});return o}(this.tableEl.offsetWidth,this.numCols));"row"===r.type&&r.border?(this.showHorizontalLine(r.border),this.hideVerticalLine()):"col"===r.type&&r.border?(this.showVerticalLine(r.border),this.hideHorizontalLine()):this.hideInsertLines()};onMouseLeave=()=>{this.hideInsertLines()};constructor(t,n,o,r,l,i,s=D){if(this.container=t,this.tableEl=n,this.getState=r,this.dispatchFn=l,this.pluginContext=i??null,this.locale=s,this.tableId=o.id,this.numRows=e(o).length,this.numCols=this.countCols(o),this.colBar=ut("ntbl-col-bar"),this.rowBar=ut("ntbl-row-bar"),this.insertLineH=ct("horizontal",s.insertRow),this.insertLineV=ct("vertical",s.insertColumn),this.addRowZone=dt("ntbl-add-row",s.addRow),this.addColZone=dt("ntbl-add-col",s.addColumn),this.deleteTableBtn=at("ntbl-delete-table-btn",'<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none"><path d="M9 3h6m-9 4h12M10 11v6m4-6v6m-9 3h14l-1-13H6L5 20z" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"/></svg>',s.deleteTable),this.deleteTableBtn.setAttribute("data-notectl-no-print",""),i){const t=F(r(),this.tableId);this.borderColorBtn=function(t,e){const n=at("ntbl-border-color-btn",'<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none"><path d="M3 3h18v18H3V3zm0 6h18M3 15h18M9 3v18M15 3v18" stroke="currentColor" stroke-width="1.5"/></svg>',t);n.setAttribute("data-notectl-no-print","");const o=document.createElement("span");return o.className="ntbl-border-color-swatch",bt(o,e),n.appendChild(o),n}(s.borderColor,t),this.actionsBtn=function(t){const e=at("ntbl-actions-btn",'<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="currentColor"><circle cx="12" cy="5" r="2"/><circle cx="12" cy="12" r="2"/><circle cx="12" cy="19" r="2"/></svg>',t);return e.setAttribute("data-notectl-no-print",""),e}(s.tableActionsHint)}else this.borderColorBtn=null,this.actionsBtn=null;t.append(this.colBar,this.rowBar,this.insertLineH,this.insertLineV,this.addRowZone,this.addColZone,this.deleteTableBtn),this.borderColorBtn&&t.appendChild(this.borderColorBtn),this.actionsBtn&&t.appendChild(this.actionsBtn),this.contextHint=function(t){const e=document.createElement("div");return e.className="ntbl-context-hint",e.setAttribute("aria-hidden","true"),e.setAttribute("contenteditable","false"),e.setAttribute("data-notectl-no-print",""),e.textContent=t,e}(s.contextMenuHint),t.appendChild(this.contextHint),this.rebuildColHandles(),this.rebuildRowHandles(),this.bindEventListeners(),this.observer=new ResizeObserver(()=>{this.positionControls()}),this.observer.observe(n),requestAnimationFrame(()=>this.positionControls())}update(t){this.tableId=t.id;const n=e(t).length,o=this.countCols(t);if(n===this.numRows&&o===this.numCols||(this.numRows=n,this.numCols=o,this.rebuildColHandles(),this.rebuildRowHandles()),this.borderColorBtn){const e=this.borderColorBtn.querySelector(".ntbl-border-color-swatch");if(e){const n=t.attrs?.borderColor;bt(e,n)}}requestAnimationFrame(()=>this.positionControls())}destroy(){this.activeContextMenu?.destroy(),this.closeBorderColorPopup(),this.observer.disconnect(),this.container.removeEventListener("mousemove",this.onMouseMove),this.container.removeEventListener("mouseleave",this.onMouseLeave),this.colBar.remove(),this.rowBar.remove(),this.insertLineH.remove(),this.insertLineV.remove(),this.addRowZone.remove(),this.addColZone.remove(),this.deleteTableBtn.remove(),this.borderColorBtn?.remove(),this.actionsBtn?.remove(),this.contextHint.remove()}bindEventListeners(){const t=this.insertLineH.querySelector(".ntbl-insert-btn"),e=this.insertLineV.querySelector(".ntbl-insert-btn");if(t.addEventListener("click",()=>{this.activeRowIndex>=0&&this.dispatchTransaction(Z(this.getState(),this.tableId,this.activeRowIndex))}),e.addEventListener("click",()=>{this.activeColIndex>=0&&this.dispatchTransaction(K(this.getState(),this.tableId,this.activeColIndex))}),this.addRowZone.addEventListener("click",()=>{this.dispatchTransaction(Z(this.getState(),this.tableId,this.numRows))}),this.addColZone.addEventListener("click",()=>{this.dispatchTransaction(K(this.getState(),this.tableId,this.numCols))}),this.deleteTableBtn.addEventListener("click",()=>{this.dispatchTransaction(W(this.getState(),this.tableId))}),this.borderColorBtn&&this.pluginContext){const t=this.pluginContext;this.borderColorBtn.addEventListener("click",()=>{this.toggleBorderColorPopup(t)})}if(this.actionsBtn&&this.pluginContext){const t=this.pluginContext;this.actionsBtn.addEventListener("click",()=>{this.openActionsMenu(t)})}this.container.addEventListener("mousemove",this.onMouseMove),this.container.addEventListener("mouseleave",this.onMouseLeave)}openActionsMenu(t){if(this.activeContextMenu?.isOpen())return this.activeContextMenu.close(),void(this.activeContextMenu=null);if(!this.actionsBtn)return;const e=this.actionsBtn.getBoundingClientRect(),n=new DOMRect(e.left,e.bottom+4,0,0);this.activeContextMenu=tt(this.container,t,this.tableId,n,()=>{this.activeContextMenu=null},this.locale)}toggleBorderColorPopup(t){this.borderColorPopup?this.closeBorderColorPopup():(this.borderColorPopup=document.createElement("div"),this.borderColorPopup.className="notectl-table-context-menu",w(this.borderColorPopup,{position:"absolute",top:"24px",left:"24px",zIndex:"10000"}),this.borderColorPopup.setAttribute("contenteditable","false"),q(this.borderColorPopup,t,this.tableId,()=>{this.closeBorderColorPopup()},this.locale),this.container.appendChild(this.borderColorPopup))}closeBorderColorPopup(){this.borderColorPopup&&(this.borderColorPopup.remove(),this.borderColorPopup=null)}dispatchTransaction(t){t&&this.dispatchFn(t)}countCols(t){const n=e(t);return n[0]?e(n[0]).length:0}positionControls(){!function(t,e,n){const o=t.children;if(0===o.length)return;const r=e/n;for(let l=0;l<o.length;l++){const t=o[l];w(t,{left:`${Math.round(r*l)}px`,width:`${Math.round(r)}px`})}g(t,"width",`${e}px`)}(this.colBar,this.tableEl.offsetWidth,this.numCols),function(t,e){const n=t.children;if(0===n.length)return;const o=e.querySelectorAll(":scope > tbody > tr"),r=e.offsetTop;let l=0;for(let i=0;i<n.length;i++){const t=n[i],e=o[i];if(e){const n=e.offsetTop-r,o=e.offsetHeight;w(t,{top:`${n}px`,height:`${o}px`}),l=n+o}}g(t,"height",`${l}px`)}(this.rowBar,this.tableEl),function(t,e,n,o){const r=ht(n,o),l=n.offsetHeight,i=n.offsetWidth;w(t,{width:`${i}px`,left:`${r.left}px`}),w(e,{height:`${l}px`,top:`${r.top}px`})}(this.addRowZone,this.addColZone,this.tableEl,this.container)}showHorizontalLine(t){this.activeRowIndex=t.index;const e=ht(this.tableEl,this.container);w(this.insertLineH,{top:e.top+t.position-1+"px",left:`${e.left}px`,width:`${this.tableEl.offsetWidth}px`}),this.insertLineH.classList.add("ntbl-insert-line--visible")}showVerticalLine(t){this.activeColIndex=t.index;const e=ht(this.tableEl,this.container);w(this.insertLineV,{left:e.left+t.position-1+"px",top:`${e.top}px`,height:`${this.tableEl.offsetHeight}px`}),this.insertLineV.classList.add("ntbl-insert-line--visible")}hideInsertLines(){this.hideHorizontalLine(),this.hideVerticalLine()}hideHorizontalLine(){this.insertLineH.classList.remove("ntbl-insert-line--visible"),this.activeRowIndex=-1}hideVerticalLine(){this.insertLineV.classList.remove("ntbl-insert-line--visible"),this.activeColIndex=-1}rebuildColHandles(){this.colBar.innerHTML="";for(let t=0;t<this.numCols;t++){const e=pt("ntbl-col-handle",t,this.locale.deleteColumn,t=>{this.dispatchTransaction(X(this.getState(),this.tableId,t))});this.colBar.appendChild(e)}}rebuildRowHandles(){this.rowBar.innerHTML="";for(let t=0;t<this.numRows;t++){const e=pt("ntbl-row-handle",t,this.locale.deleteRow,t=>{this.dispatchTransaction(Y(this.getState(),this.tableId,t))});this.rowBar.appendChild(e)}}};function ft(t,e){"none"===e?(g(t,"--ntbl-border-color","transparent"),t.classList.add("notectl-table--borderless")):e?(g(t,"--ntbl-border-color",e),t.classList.remove("notectl-table--borderless")):(x(t,"--ntbl-border-color"),t.classList.remove("notectl-table--borderless"))}var vt=new C("tableSelection"),gt={maxPickerRows:8,maxPickerCols:8},xt="border-collapse: collapse; width: 100%; table-layout: fixed",wt="border: 1px solid var(--ntbl-bc, #d0d0d0); padding: 8px 12px; vertical-align: top",Ct=class{id="table";name="Table";priority=40;config;locale;selectionService=null;cleanupMouseSelection=null;context=null;constructor(t){this.config={...gt,...t}}async init(t){this.locale=await k(t,this.config.locale,D,$),t.registerStyleSheet('\n/* Table */\n.notectl-table-wrapper {\n\tmargin: 8px 0;\n\toverflow-x: auto;\n\tposition: relative;\n}\n\n.notectl-table {\n\twidth: 100%;\n\tborder-collapse: collapse;\n\ttable-layout: fixed;\n}\n\n/* Border resolution order: per-table local override → theme component token → theme global token.\n * The inline --ntbl-border-color is set by the toolbar\'s "border color" action and must win\n * over the theme so per-table customizations remain visible after a theme switch.\n */\n.notectl-table td {\n\tborder: 1px solid var(--ntbl-border-color, var(--notectl-table-border, var(--notectl-border)));\n\tbackground: var(--notectl-table-cell-bg, transparent);\n\tpadding: 8px 12px;\n\tmin-width: 60px;\n\tvertical-align: top;\n\tmin-height: 1.6em;\n}\n\n.notectl-table th {\n\tborder: 1px solid var(--ntbl-border-color, var(--notectl-table-border, var(--notectl-border)));\n\tbackground: var(--notectl-table-header-bg, var(--notectl-surface-raised));\n\tpadding: 8px 12px;\n\tmin-width: 60px;\n\tvertical-align: top;\n\ttext-align: start;\n\tfont-weight: 600;\n}\n\n.notectl-table--borderless td {\n\tborder: 1px dashed rgba(128, 128, 128, 0.15);\n}\n\n@media print {\n\t.notectl-table--borderless td {\n\t\tborder: none;\n\t}\n}\n\n.notectl-table td:focus-within {\n\toutline: 2px solid var(--notectl-primary);\n\toutline-offset: -2px;\n}\n\n.notectl-table-cell--selected {\n\tbackground: var(--notectl-primary-muted);\n}\n\n/* Table Context Menu */\n.notectl-table-context-menu {\n\tbackground: var(--notectl-surface-overlay);\n\tborder: 1px solid var(--notectl-border);\n\tborder-radius: 6px;\n\tbox-shadow: 0 4px 12px var(--notectl-shadow);\n\tpadding: 4px 0;\n\tmin-width: 180px;\n\tz-index: 10000;\n}\n\n.notectl-table-context-menu button {\n\tdisplay: block;\n\twidth: 100%;\n\tpadding: 8px 12px;\n\ttext-align: start;\n\tborder: none;\n\tbackground: none;\n\tcursor: pointer;\n\tfont-size: 14px;\n\tcolor: var(--notectl-fg);\n\tfont-family: inherit;\n}\n\n.notectl-table-context-menu button:hover {\n\tbackground: var(--notectl-hover-bg);\n}\n\n.notectl-table-context-menu hr {\n\tborder: none;\n\tborder-top: 1px solid var(--notectl-border);\n\tmargin: 4px 0;\n}\n\n/* === Table Controls === */\n\n/* Outer container for table + controls */\n.ntbl-container {\n\tposition: relative;\n\tmargin: 8px 0;\n\tpadding-block-start: 24px;\n\tpadding-inline-start: 24px;\n}\n\n.ntbl-container .notectl-table-wrapper {\n\tmargin: 0;\n}\n\n.ntbl-container.notectl-table--selected .notectl-table-wrapper {\n\toutline: 2px solid var(--notectl-primary-fg);\n\toutline-offset: 2px;\n\tborder-radius: 6px;\n}\n\n/* --- Column Handle Bar --- */\n.ntbl-col-bar {\n\tposition: absolute;\n\ttop: 0;\n\tinset-inline-start: 24px;\n\theight: 20px;\n\tdisplay: flex;\n\topacity: 0;\n\ttransition: opacity 0.2s ease;\n\tz-index: 3;\n\tpointer-events: none;\n}\n\n.ntbl-container:hover .ntbl-col-bar,\n.ntbl-container:focus-within .ntbl-col-bar {\n\topacity: 1;\n\tpointer-events: auto;\n}\n\n.ntbl-container.notectl-table--selected .ntbl-col-bar {\n\topacity: 1;\n\tpointer-events: auto;\n}\n\n/* --- Row Handle Bar --- */\n.ntbl-row-bar {\n\tposition: absolute;\n\ttop: 24px;\n\tinset-inline-start: 0;\n\twidth: 20px;\n\tdisplay: flex;\n\tflex-direction: column;\n\topacity: 0;\n\ttransition: opacity 0.2s ease;\n\tz-index: 3;\n\tpointer-events: none;\n}\n\n.ntbl-container:hover .ntbl-row-bar,\n.ntbl-container:focus-within .ntbl-row-bar {\n\topacity: 1;\n\tpointer-events: auto;\n}\n\n.ntbl-container.notectl-table--selected .ntbl-row-bar {\n\topacity: 1;\n\tpointer-events: auto;\n}\n\n/* --- Handle (shared base) --- */\n.ntbl-handle {\n\tposition: absolute;\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: center;\n\tcursor: pointer;\n\ttransition: background 0.15s ease;\n\tborder-radius: 3px;\n}\n\n.ntbl-col-handle {\n\theight: 100%;\n\tbackground: var(--notectl-hover-bg);\n\tborder-radius: 4px 4px 0 0;\n}\n\n.ntbl-col-handle:hover {\n\tbackground: var(--notectl-border);\n}\n\n.ntbl-row-handle {\n\twidth: 100%;\n\tbackground: var(--notectl-hover-bg);\n\tborder-start-start-radius: 4px;\n\tborder-end-start-radius: 4px;\n}\n\n.ntbl-row-handle:hover {\n\tbackground: var(--notectl-border);\n}\n\n/* --- Handle Delete Button --- */\n.ntbl-handle-delete {\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: center;\n\twidth: 16px;\n\theight: 16px;\n\tborder: none;\n\tbackground: transparent;\n\tcolor: var(--notectl-fg-muted);\n\tcursor: pointer;\n\tborder-radius: 3px;\n\tpadding: 0;\n\topacity: 0;\n\ttransform: scale(0.7);\n\ttransition: opacity 0.15s, transform 0.15s,\n\t\tbackground 0.15s, color 0.15s;\n}\n\n.ntbl-handle:hover .ntbl-handle-delete,\n.ntbl-handle:focus-within .ntbl-handle-delete {\n\topacity: 1;\n\ttransform: scale(1);\n}\n\n.ntbl-handle-delete:hover,\n.ntbl-handle-delete:focus-visible {\n\tbackground: var(--notectl-danger-muted);\n\tcolor: var(--notectl-danger);\n}\n\n.ntbl-handle-delete:focus-visible {\n\toutline: none;\n\tbox-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n/* --- Insert Lines --- */\n.ntbl-insert-line {\n\tposition: absolute;\n\tpointer-events: none;\n\topacity: 0;\n\ttransition: opacity 0.15s ease;\n\tz-index: 6;\n}\n\n.ntbl-insert-line--visible {\n\topacity: 1;\n\tpointer-events: auto;\n}\n\n.ntbl-insert-line--horizontal {\n\theight: 2px;\n\tbackground: linear-gradient(\n\t\t90deg,\n\t\ttransparent,\n\t\tvar(--notectl-primary) 8%,\n\t\tvar(--notectl-primary) 92%,\n\t\ttransparent\n\t);\n\tbox-shadow: 0 0 6px var(--notectl-focus-ring);\n}\n\n.ntbl-insert-line--vertical {\n\twidth: 2px;\n\tbackground: linear-gradient(\n\t\t180deg,\n\t\ttransparent,\n\t\tvar(--notectl-primary) 8%,\n\t\tvar(--notectl-primary) 92%,\n\t\ttransparent\n\t);\n\tbox-shadow: 0 0 6px var(--notectl-focus-ring);\n}\n\n/* --- Insert Button on Line --- */\n.ntbl-insert-btn {\n\tposition: absolute;\n\twidth: 20px;\n\theight: 20px;\n\tborder-radius: 50%;\n\tbackground: var(--notectl-surface-raised);\n\tborder: 2px solid var(--notectl-primary);\n\tcolor: var(--notectl-primary);\n\tcursor: pointer;\n\tpointer-events: all;\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: center;\n\tpadding: 0;\n\tbox-shadow: 0 2px 8px var(--notectl-focus-ring);\n\ttransition: background 0.15s, color 0.15s,\n\t\ttransform 0.15s, box-shadow 0.15s;\n}\n\n.ntbl-insert-line--horizontal .ntbl-insert-btn {\n\tleft: 50%;\n\ttop: -9px;\n\ttransform: translateX(-50%);\n}\n\n.ntbl-insert-line--vertical .ntbl-insert-btn {\n\ttop: 50%;\n\tinset-inline-start: -9px;\n\ttransform: translateY(-50%);\n}\n\n.ntbl-insert-btn:hover,\n.ntbl-insert-btn:focus-visible {\n\tbackground: var(--notectl-primary);\n\tcolor: var(--notectl-primary-fg);\n\tbox-shadow: 0 2px 12px var(--notectl-focus-ring);\n}\n\n.ntbl-insert-btn:focus-visible {\n\toutline: none;\n\tbox-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n.ntbl-insert-line--horizontal .ntbl-insert-btn:hover {\n\ttransform: translateX(-50%) scale(1.2);\n}\n\n.ntbl-insert-line--vertical .ntbl-insert-btn:hover {\n\ttransform: translateY(-50%) scale(1.2);\n}\n\n/* --- Add Row / Add Column Zones --- */\n.ntbl-add-zone {\n\tposition: absolute;\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: center;\n\tcursor: pointer;\n\tuser-select: none;\n\topacity: 0;\n\ttransition: opacity 0.2s ease, background 0.2s ease,\n\t\tborder-color 0.2s ease;\n}\n\n.ntbl-container:hover .ntbl-add-zone,\n.ntbl-container:focus-within .ntbl-add-zone {\n\topacity: 1;\n}\n\n.ntbl-container.notectl-table--selected .ntbl-add-zone {\n\topacity: 1;\n}\n\n.ntbl-delete-table-btn {\n\tposition: absolute;\n\ttop: 0;\n\tinset-inline-start: 0;\n\twidth: 20px;\n\theight: 20px;\n\tborder: 1px solid var(--notectl-danger);\n\tborder-radius: 4px;\n\tbackground: var(--notectl-surface-raised);\n\tcolor: var(--notectl-danger);\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\topacity: 0;\n\ttransition: opacity 0.2s ease, background 0.15s, border-color 0.15s;\n\tz-index: 7;\n}\n\n.ntbl-container:hover .ntbl-delete-table-btn,\n.ntbl-container:focus-within .ntbl-delete-table-btn,\n.ntbl-container.notectl-table--selected .ntbl-delete-table-btn {\n\topacity: 1;\n}\n\n.ntbl-delete-table-btn:hover,\n.ntbl-delete-table-btn:focus-visible {\n\tbackground: var(--notectl-danger-muted);\n\tborder-color: var(--notectl-danger);\n}\n\n.ntbl-delete-table-btn:focus-visible {\n\toutline: none;\n\tbox-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n/* --- Context Menu Discovery Hint --- */\n.ntbl-context-hint {\n\tposition: absolute;\n\ttop: 4px;\n\tinset-inline-end: 0;\n\tfont-size: 11px;\n\tcolor: var(--notectl-fg-muted);\n\tpadding: 2px 8px;\n\tborder-radius: 4px;\n\topacity: 0;\n\ttransition: opacity 0.2s ease;\n\tpointer-events: none;\n\twhite-space: nowrap;\n\tz-index: 5;\n}\n\n.ntbl-container:hover .ntbl-context-hint,\n.ntbl-container:focus-within .ntbl-context-hint,\n.ntbl-container.notectl-table--selected .ntbl-context-hint {\n\topacity: 1;\n}\n\n/* --- Table Actions Button --- */\n.ntbl-actions-btn {\n\tposition: absolute;\n\ttop: 0;\n\tinset-inline-start: 48px;\n\twidth: 20px;\n\theight: 20px;\n\tborder: 1px solid var(--notectl-border);\n\tborder-radius: 4px;\n\tbackground: var(--notectl-surface-raised);\n\tcolor: var(--notectl-fg-muted);\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\topacity: 0;\n\ttransition: opacity 0.2s ease, background 0.15s, border-color 0.15s;\n\tz-index: 7;\n\tcursor: pointer;\n\tpadding: 0;\n}\n\n.ntbl-container:hover .ntbl-actions-btn,\n.ntbl-container:focus-within .ntbl-actions-btn,\n.ntbl-container.notectl-table--selected .ntbl-actions-btn {\n\topacity: 1;\n}\n\n.ntbl-actions-btn:hover,\n.ntbl-actions-btn:focus-visible {\n\tbackground: var(--notectl-hover-bg);\n\tborder-color: var(--notectl-primary);\n}\n\n.ntbl-actions-btn:focus-visible {\n\toutline: none;\n\tbox-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n/* --- Border Color Button --- */\n.ntbl-border-color-btn {\n\tposition: absolute;\n\ttop: 0;\n\tinset-inline-start: 24px;\n\twidth: 20px;\n\theight: 20px;\n\tborder: 1px solid var(--notectl-border);\n\tborder-radius: 4px;\n\tbackground: var(--notectl-surface-raised);\n\tcolor: var(--notectl-fg-muted);\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\topacity: 0;\n\ttransition: opacity 0.2s ease, background 0.15s, border-color 0.15s;\n\tz-index: 7;\n\tcursor: pointer;\n\tpadding: 0;\n}\n\n.ntbl-container:hover .ntbl-border-color-btn,\n.ntbl-container:focus-within .ntbl-border-color-btn,\n.ntbl-container.notectl-table--selected .ntbl-border-color-btn {\n\topacity: 1;\n}\n\n.ntbl-border-color-btn:hover,\n.ntbl-border-color-btn:focus-visible {\n\tbackground: var(--notectl-hover-bg);\n\tborder-color: var(--notectl-primary);\n}\n\n.ntbl-border-color-btn:focus-visible {\n\toutline: none;\n\tbox-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n.ntbl-border-color-swatch {\n\twidth: 10px;\n\theight: 10px;\n\tborder-radius: 2px;\n\tborder: 1px solid rgba(0, 0, 0, 0.15);\n}\n\n/* --- Context Menu Keyboard Hint --- */\n.notectl-table-context-menu__hint {\n\tpadding: 4px 12px 6px;\n\tfont-size: 11px;\n\tcolor: var(--notectl-fg-muted);\n\tborder-top: 1px solid var(--notectl-border);\n\tmargin-top: 4px;\n\ttext-align: center;\n\tuser-select: none;\n}\n\n/* --- Context Menu Focus --- */\n.notectl-table-context-menu button:focus-visible {\n\toutline: none;\n\tbackground: var(--notectl-primary-muted);\n\tbox-shadow: inset 0 0 0 2px var(--notectl-focus-ring);\n}\n\n.notectl-table-context-menu [role="separator"] {\n\tborder: none;\n\tborder-top: 1px solid var(--notectl-border);\n\tmargin: 4px 0;\n\theight: 0;\n}\n\n.ntbl-add-row {\n\tbottom: 0;\n\theight: 24px;\n\tborder: 1px dashed var(--notectl-border);\n\tborder-end-start-radius: 6px;\n\tborder-end-end-radius: 6px;\n\tborder-block-start: none;\n\tcolor: var(--notectl-fg-muted);\n\ttransform: translateY(100%);\n}\n\n.ntbl-add-row:hover,\n.ntbl-add-row:focus-visible {\n\tbackground: var(--notectl-primary-muted);\n\tborder-color: var(--notectl-primary);\n\tcolor: var(--notectl-primary);\n}\n\n.ntbl-add-row:focus-visible {\n\toutline: none;\n\tbox-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n.ntbl-add-col {\n\tinset-inline-end: 0;\n\ttop: 24px;\n\twidth: 24px;\n\tborder: 1px dashed var(--notectl-border);\n\tborder-start-end-radius: 6px;\n\tborder-end-end-radius: 6px;\n\tborder-inline-start: none;\n\tcolor: var(--notectl-fg-muted);\n\ttransform: translateX(100%);\n}\n\n[dir="rtl"] .ntbl-add-col {\n\ttransform: translateX(-100%);\n}\n\n.ntbl-add-col:hover,\n.ntbl-add-col:focus-visible {\n\tbackground: var(--notectl-primary-muted);\n\tborder-color: var(--notectl-primary);\n\tcolor: var(--notectl-primary);\n}\n\n.ntbl-add-col:focus-visible {\n\toutline: none;\n\tbox-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n.ntbl-add-icon {\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: center;\n\ttransition: transform 0.2s ease;\n}\n\n.ntbl-add-zone:hover .ntbl-add-icon {\n\ttransform: scale(1.15);\n}\n'),this.context=t,this.registerNodeSpecs(t),this.registerNodeViews(t),J(t,this.locale),t.registerCommand("resetTableBorderColor",()=>O(t,this.locale)),function(t,e){t.registerKeymap({Tab:()=>function(t,e){return nt(t,(n,o,r)=>r.colIndex<r.totalCols-1?rt(t,r.tableId,r.rowIndex,r.colIndex+1):r.rowIndex<r.totalRows-1?rt(t,r.tableId,r.rowIndex+1,0):(G(t,e),!0))}(t,e),"Shift-Tab":()=>function(t){return nt(t,(e,n,o)=>o.colIndex>0?rt(t,o.tableId,o.rowIndex,o.colIndex-1):!(o.rowIndex>0)||rt(t,o.tableId,o.rowIndex-1,o.totalCols-1))}(t),Backspace:()=>function(t){return nt(t,(e,n,o)=>{if(!a(n))return!1;if(0!==n.anchor.offset)return!1;if(0!==o.rowIndex||0!==o.colIndex)return!1;const r=N(e,o.cellId);return n.anchor.blockId===r&&it(t,o.tableId)})}(t),Delete:()=>function(t){return nt(t,(e,n,o)=>{if(!a(n))return!1;const l=e.getBlock(n.anchor.blockId);if(!l)return!1;const i=r(l);if(n.anchor.offset!==i)return!1;if(o.rowIndex!==o.totalRows-1||o.colIndex!==o.totalCols-1)return!1;const s=H(e,o.cellId);return n.anchor.blockId===s&&it(t,o.tableId)})}(t),ArrowDown:()=>function(t){return nt(t,(e,n,o)=>{const r=H(e,o.cellId);return n.anchor.blockId===r&&(o.rowIndex>=o.totalRows-1?ot(t):rt(t,o.tableId,o.rowIndex+1,o.colIndex))})}(t),ArrowUp:()=>function(t){return nt(t,(e,n,o)=>{const r=N(e,o.cellId);return n.anchor.blockId===r&&!(o.rowIndex<=0)&&rt(t,o.tableId,o.rowIndex-1,o.colIndex)})}(t),ArrowRight:()=>function(t){return nt(t,(e,n,o)=>{if(!a(n))return!1;const l=e.getBlock(n.anchor.blockId);if(!l)return!1;const i=r(l);if(n.anchor.offset!==i)return!1;const s=H(e,o.cellId);return n.anchor.blockId===s&&(o.colIndex<o.totalCols-1?rt(t,o.tableId,o.rowIndex,o.colIndex+1):!(o.rowIndex<o.totalRows-1)||rt(t,o.tableId,o.rowIndex+1,0))})}(t),ArrowLeft:()=>function(t){return nt(t,(e,n,o)=>{if(!a(n))return!1;if(0!==n.anchor.offset)return!1;const r=N(e,o.cellId);return n.anchor.blockId===r&&(o.colIndex>0?lt(t,o.tableId,o.rowIndex,o.colIndex-1):!(o.rowIndex>0)||lt(t,o.tableId,o.rowIndex-1,o.totalCols-1))})}(t),Escape:()=>ot(t),"Shift-F10":()=>function(t){return nt(t,(e,n,o)=>{const r=t.getContainer(),l=r.querySelector(`[data-block-id="${o.cellId}"]`);if(!l)return!1;const i=l.getBoundingClientRect(),s=new DOMRect(i.left+i.width/2,i.bottom,0,0),a=r.querySelector(`[data-block-id="${o.tableId}"].ntbl-container`)??r;return et?.close(),et=tt(a,t,o.tableId,s,()=>{et=null}),!0})}(t)},{priority:"context"})}(t,this.locale),this.registerToolbarItem(t),this.selectionService=function(t){let e=null,n=[],o=/* @__PURE__ */new Set;function r(){if(!e)return n=[],void(o=/* @__PURE__ */new Set);const r=t.getState(),l=[],i=Math.min(e.fromRow,e.toRow),s=Math.max(e.fromRow,e.toRow),a=Math.min(e.fromCol,e.toCol),c=Math.max(e.fromCol,e.toCol);for(let t=i;t<=s;t++)for(let n=a;n<=c;n++){const o=M(r,e.tableId,t,n);o&&l.push(o)}n=l,o=new Set(l)}const l={getSelectedRange:()=>e,setSelectedRange(n){e=n,r();const o=t.getState();t.dispatch(o.transaction("api").setSelection(o.selection).build())},clearSelectionSilent(){e=null,r()},getSelectedCellIds:()=>n,isSelected:t=>o.has(t)};return t.registerService(vt,l),l}(t)}onReady(){this.context&&this.selectionService&&(this.cleanupMouseSelection=function(t,e){const n=t.getContainer();let o=null,r=!1;function l(n){const l=n.target.closest("td[data-block-id]");if(!l)return o=null,r=!1,void e.setSelectedRange(null);if(n.shiftKey){if(o){const r=T(t.getState(),l.getAttribute("data-block-id"));if(!r||r.tableId!==o.tableId)return o=null,void e.setSelectedRange(null);n.preventDefault(),e.setSelectedRange({tableId:o.tableId,fromRow:o.row,fromCol:o.col,toRow:r.rowIndex,toCol:r.colIndex})}}else{e.setSelectedRange(null);const n=T(t.getState(),l.getAttribute("data-block-id"));if(!n)return o=null,void(r=!1);o={tableId:n.tableId,row:n.rowIndex,col:n.colIndex},r=!0}}function i(n){if(!r||!o)return;const l=n.target.closest("td[data-block-id]");if(!l)return;const i=T(t.getState(),l.getAttribute("data-block-id"));i&&i.tableId===o.tableId&&(i.rowIndex===o.row&&i.colIndex===o.col||(n.preventDefault(),e.setSelectedRange({tableId:o.tableId,fromRow:o.row,fromCol:o.col,toRow:i.rowIndex,toCol:i.colIndex})))}function s(){r=!1}return n.addEventListener("mousedown",l),n.addEventListener("mousemove",i),document.addEventListener("mouseup",s),()=>{n.removeEventListener("mousedown",l),n.removeEventListener("mousemove",i),document.removeEventListener("mouseup",s)}}(this.context,this.selectionService))}destroy(){this.cleanupMouseSelection?.(),this.cleanupMouseSelection=null,this.selectionService=null,this.context=null}decorations(t){if(!this.selectionService)return v.empty;if(!this.selectionService.getSelectedRange())return v.empty;const e=t.selection;if(!u(e)||!P(t,e.anchor.blockId))return this.selectionService.clearSelectionSilent(),v.empty;const n=this.selectionService.getSelectedCellIds();if(0===n.length)return v.empty;const o=[];for(const r of n)o.push(f(r,{class:"notectl-table-cell--selected"}));return v.create(o)}registerNodeSpecs(t){t.registerNodeSpec({type:"table",group:"block",content:{allow:["table_row"],min:1},isolating:!0,selectable:!0,toDOM(t){const e=document.createElement("div");return e.className="notectl-table-wrapper",e.setAttribute("data-block-id",t.id),e.setAttribute("part","table"),e},toHTML(t,e,n){const o=t.attrs?.borderColor,r=function(t){return t?"none"===t?`${xt}; --ntbl-bc: transparent`:L(t)?`${xt}; --ntbl-bc: ${p(t)}`:xt:xt}(o);return`<table${n?.styleAttr(r)??` style="${r}"`}>${e}</table>`},sanitize:{tags:["table","tbody"]}}),t.registerNodeSpec({type:"table_row",group:"table_content",content:{allow:["table_cell"],min:1},toDOM(t){const e=document.createElement("tr");return e.setAttribute("data-block-id",t.id),e.setAttribute("role","row"),e.setAttribute("part","table-row"),e},toHTML:(t,e)=>`<tr>${e}</tr>`,sanitize:{tags:["tr"]}}),t.registerNodeSpec({type:"table_cell",group:"table_content",content:{allow:["paragraph","list_item","heading","blockquote","image","video","horizontal_rule"]},isolating:!0,toDOM(t){const e=document.createElement("td");return e.setAttribute("data-block-id",t.id),e.setAttribute("role","cell"),e.setAttribute("part","table-cell"),e},toHTML(t,e,n){const o=t.attrs?.colspan??1,r=t.attrs?.rowspan??1,l=[n?.styleAttr(wt)??` style="${wt}"`];return o>1&&l.push(` colspan="${o}"`),r>1&&l.push(` rowspan="${r}"`),`<td${l.join("")}>${e}</td>`},sanitize:{tags:["td"],attrs:["colspan","rowspan"]}})}registerNodeViews(t){t.getSchemaRegistry(),t.registerNodeView("table",function(t,n,o=D){return(t,r,l)=>{const i=document.createElement("div");i.className="ntbl-container",i.setAttribute("data-block-id",t.id),i.setAttribute("data-selectable","true");const s=document.createElement("div");s.className="notectl-table-wrapper",s.setAttribute("part","table");const a=document.createElement("table");a.className="notectl-table",a.setAttribute("role","table");const c=e(t),d=c.length,u=c[0]?e(c[0]).length:0;a.setAttribute("aria-label",o.tableAriaLabel(d,u)),a.setAttribute("aria-description",o.tableAriaDescription);const b=document.createElement("tbody");a.appendChild(b),s.appendChild(a),i.appendChild(s),ft(a,t.attrs?.borderColor);const p=document.createElement("div");p.className="notectl-sr-only",p.setAttribute("aria-live","polite"),p.setAttribute("aria-atomic","true"),i.appendChild(p);const h=function(t,e,n,o,r,l,i){return new mt(t,e,n,o,r,l,i)}(i,a,t,r,l,n,o);let m=null,f=t.id;const v=t=>{if(!n)return;t.preventDefault(),t.stopPropagation(),m?.close();const e=new DOMRect(t.clientX,t.clientY,0,0);m=tt(i,n,f,e,()=>{m=null},o)};return a.addEventListener("contextmenu",v),{dom:i,contentDOM:b,update(t){if("table"!==t.type)return!1;f=t.id,i.setAttribute("data-block-id",t.id),i.setAttribute("data-selectable","true");const n=e(t),r=n.length,l=n[0]?e(n[0]).length:0;return a.setAttribute("aria-label",o.tableAriaLabel(r,l)),ft(a,t.attrs?.borderColor),h.update(t),!1},destroy(){m?.destroy(),a.removeEventListener("contextmenu",v),h.destroy()},selectNode(){i.classList.add("notectl-table--selected")},deselectNode(){i.classList.remove("notectl-table--selected")}}}}(0,t,this.locale)),t.registerNodeView("table_row",(t,e,n)=>{const o=document.createElement("tr");return o.setAttribute("data-block-id",t.id),o.setAttribute("role","row"),o.setAttribute("part","table-row"),{dom:o,contentDOM:o,update:t=>("table_row"!==t.type||o.setAttribute("data-block-id",t.id),!1),destroy(){}}}),t.registerNodeView("table_cell",(t,e,n)=>{const o=document.createElement("td");o.setAttribute("data-block-id",t.id),o.setAttribute("role","cell"),o.setAttribute("part","table-cell");const r=t.attrs?.colspan??1,l=t.attrs?.rowspan??1;r>1&&(o.colSpan=r),l>1&&(o.rowSpan=l);const i=t.attrs?.align;return i&&"left"!==i&&g(o,"textAlign",i),{dom:o,contentDOM:o,update(t){if("table_cell"!==t.type)return!1;o.setAttribute("data-block-id",t.id);const e=t.attrs?.colspan??1,n=t.attrs?.rowspan??1;return e>1?o.colSpan=e:o.removeAttribute("colspan"),n>1?o.rowSpan=n:o.removeAttribute("rowspan"),!1},destroy(){}}})}registerToolbarItem(t){const e=this.config.maxPickerRows??8,n=this.config.maxPickerCols??8;t.registerToolbarItem({id:"table",group:"insert",icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M3 3h18v18H3V3zm2 2v4h6V5H5zm8 0v4h6V5h-6zm-8 6v4h6v-4H5zm8 0v4h6v-4h-6zm-8 6v4h6v-4H5zm8 0v4h6v-4h-6z"/></svg>',label:this.locale.insertTable,tooltip:this.locale.insertTable,command:"insertTable",popupType:"gridPicker",popupConfig:{maxRows:e,maxCols:n,onSelect:(e,n)=>{U(t,e,n)}},isActive:t=>!!u(t.selection)&&P(t,t.selection.anchor.blockId)})}};export{vt as n,Ct as t};
2
+ //# sourceMappingURL=TablePlugin-BTH9VRZq.mjs.map