reactjs-tiptap-editor 0.3.27 → 0.3.29

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 (221) hide show
  1. package/lib/{ActionMenuButton-fkh63F_R.cjs → ActionMenuButton-5Y8QcYxD.cjs} +1 -1
  2. package/lib/{ActionMenuButton-D3nLtawn.js → ActionMenuButton-Cs9DM_16.js} +1 -1
  3. package/lib/Attachment.cjs +1 -1
  4. package/lib/Attachment.d.cts +6 -4
  5. package/lib/Attachment.d.ts +6 -4
  6. package/lib/Attachment.js +1 -1
  7. package/lib/Blockquote.cjs +1 -1
  8. package/lib/Blockquote.d.cts +6 -4
  9. package/lib/Blockquote.d.ts +6 -4
  10. package/lib/Blockquote.js +10 -10
  11. package/lib/Bold.cjs +1 -1
  12. package/lib/Bold.d.cts +6 -4
  13. package/lib/Bold.d.ts +6 -4
  14. package/lib/Bold.js +10 -10
  15. package/lib/BulletList.cjs +1 -1
  16. package/lib/BulletList.d.cts +6 -4
  17. package/lib/BulletList.d.ts +6 -4
  18. package/lib/BulletList.js +10 -10
  19. package/lib/Clear.cjs +1 -1
  20. package/lib/Clear.d.cts +6 -4
  21. package/lib/Clear.d.ts +6 -4
  22. package/lib/Clear.js +1 -1
  23. package/lib/Code.cjs +1 -1
  24. package/lib/Code.d.cts +6 -4
  25. package/lib/Code.d.ts +6 -4
  26. package/lib/Code.js +21 -21
  27. package/lib/CodeBlock.cjs +1 -1
  28. package/lib/CodeBlock.d.cts +6 -4
  29. package/lib/CodeBlock.d.ts +6 -4
  30. package/lib/CodeBlock.js +1 -1
  31. package/lib/CodeView.cjs +1 -1
  32. package/lib/CodeView.d.cts +6 -4
  33. package/lib/CodeView.d.ts +6 -4
  34. package/lib/CodeView.js +1 -1
  35. package/lib/Color.cjs +1 -1
  36. package/lib/Color.d.cts +6 -4
  37. package/lib/Color.d.ts +6 -4
  38. package/lib/Color.js +1 -1
  39. package/lib/Document.d.cts +4 -4
  40. package/lib/Document.d.ts +4 -4
  41. package/lib/{Drawer-BBVUujX4.js → Drawer-BCmNLh31.js} +1 -1
  42. package/lib/{Drawer-DetzmUvQ.cjs → Drawer-DCAp7eZF.cjs} +1 -1
  43. package/lib/Drawer.cjs +1 -1
  44. package/lib/Drawer.d.cts +6 -4
  45. package/lib/Drawer.d.ts +6 -4
  46. package/lib/Drawer.js +2 -2
  47. package/lib/Emoji.cjs +1 -1
  48. package/lib/Emoji.d.cts +4 -4
  49. package/lib/Emoji.d.ts +4 -4
  50. package/lib/Emoji.js +1 -1
  51. package/lib/{Excalidraw-DVnwdz-w.cjs → Excalidraw-BI50RQL-.cjs} +1 -1
  52. package/lib/{Excalidraw-BVdio4hk.js → Excalidraw-CYPcjYZB.js} +1 -1
  53. package/lib/Excalidraw.cjs +1 -1
  54. package/lib/Excalidraw.d.cts +4 -4
  55. package/lib/Excalidraw.d.ts +4 -4
  56. package/lib/Excalidraw.js +1 -1
  57. package/lib/ExportPdf.cjs +1 -1
  58. package/lib/ExportPdf.d.cts +6 -4
  59. package/lib/ExportPdf.d.ts +6 -4
  60. package/lib/ExportPdf.js +1 -1
  61. package/lib/ExportWord.cjs +1 -1
  62. package/lib/ExportWord.d.cts +6 -4
  63. package/lib/ExportWord.d.ts +6 -4
  64. package/lib/ExportWord.js +1 -1
  65. package/lib/FontFamily.cjs +1 -1
  66. package/lib/FontFamily.d.cts +6 -4
  67. package/lib/FontFamily.d.ts +6 -4
  68. package/lib/FontFamily.js +2 -2
  69. package/lib/FontSize.cjs +1 -1
  70. package/lib/FontSize.d.cts +6 -4
  71. package/lib/FontSize.d.ts +6 -4
  72. package/lib/FontSize.js +2 -2
  73. package/lib/FormatPainter.cjs +1 -1
  74. package/lib/FormatPainter.d.cts +6 -4
  75. package/lib/FormatPainter.d.ts +6 -4
  76. package/lib/FormatPainter.js +1 -1
  77. package/lib/Heading.cjs +1 -1
  78. package/lib/Heading.d.cts +6 -4
  79. package/lib/Heading.d.ts +6 -4
  80. package/lib/Heading.js +71 -68
  81. package/lib/Highlight.cjs +1 -1
  82. package/lib/Highlight.d.cts +10 -4
  83. package/lib/Highlight.d.ts +10 -4
  84. package/lib/Highlight.js +14 -13
  85. package/lib/History.cjs +1 -1
  86. package/lib/History.d.cts +6 -4
  87. package/lib/History.d.ts +6 -4
  88. package/lib/History.js +163 -160
  89. package/lib/HorizontalRule.cjs +1 -1
  90. package/lib/HorizontalRule.d.cts +6 -4
  91. package/lib/HorizontalRule.d.ts +6 -4
  92. package/lib/HorizontalRule.js +14 -14
  93. package/lib/Iframe.cjs +1 -1
  94. package/lib/Iframe.d.cts +4 -4
  95. package/lib/Iframe.d.ts +4 -4
  96. package/lib/Iframe.js +1 -1
  97. package/lib/Image.cjs +1 -1
  98. package/lib/Image.d.cts +6 -4
  99. package/lib/Image.d.ts +6 -4
  100. package/lib/Image.js +1 -1
  101. package/lib/ImageGif.cjs +1 -1
  102. package/lib/ImageGif.d.cts +7 -6
  103. package/lib/ImageGif.d.ts +7 -6
  104. package/lib/ImageGif.js +1 -1
  105. package/lib/ImportWord.cjs +2 -2
  106. package/lib/ImportWord.d.cts +6 -4
  107. package/lib/ImportWord.d.ts +6 -4
  108. package/lib/ImportWord.js +2 -2
  109. package/lib/Indent.cjs +1 -1
  110. package/lib/Indent.d.cts +6 -4
  111. package/lib/Indent.d.ts +6 -4
  112. package/lib/Indent.js +12 -11
  113. package/lib/Italic.cjs +1 -1
  114. package/lib/Italic.d.cts +6 -4
  115. package/lib/Italic.d.ts +6 -4
  116. package/lib/Italic.js +13 -13
  117. package/lib/Katex.cjs +1 -1
  118. package/lib/Katex.d.cts +4 -4
  119. package/lib/Katex.d.ts +4 -4
  120. package/lib/Katex.js +2 -2
  121. package/lib/LineHeight.cjs +1 -1
  122. package/lib/LineHeight.d.cts +6 -4
  123. package/lib/LineHeight.d.ts +6 -4
  124. package/lib/LineHeight.js +1 -1
  125. package/lib/Link.cjs +1 -1
  126. package/lib/Link.d.cts +6 -4
  127. package/lib/Link.d.ts +6 -4
  128. package/lib/Link.js +1 -1
  129. package/lib/ListItem.d.cts +4 -4
  130. package/lib/ListItem.d.ts +4 -4
  131. package/lib/Mention.d.cts +4 -4
  132. package/lib/Mention.d.ts +4 -4
  133. package/lib/Mermaid.cjs +1 -1
  134. package/lib/Mermaid.d.cts +6 -4
  135. package/lib/Mermaid.d.ts +6 -4
  136. package/lib/Mermaid.js +2 -2
  137. package/lib/MoreMark.cjs +1 -1
  138. package/lib/MoreMark.d.cts +6 -4
  139. package/lib/MoreMark.d.ts +6 -4
  140. package/lib/MoreMark.js +46 -45
  141. package/lib/MultiColumn.cjs +1 -1
  142. package/lib/MultiColumn.d.cts +4 -4
  143. package/lib/MultiColumn.d.ts +4 -4
  144. package/lib/MultiColumn.js +1 -1
  145. package/lib/OrderedList.cjs +1 -1
  146. package/lib/OrderedList.d.cts +6 -4
  147. package/lib/OrderedList.d.ts +6 -4
  148. package/lib/OrderedList.js +9 -9
  149. package/lib/{RichTextEditor-DoMu_nCj.cjs → RichTextEditor-DsUcQSbm.cjs} +7 -7
  150. package/lib/{RichTextEditor-BJWhWz4z.js → RichTextEditor-e6q30rbV.js} +1691 -1672
  151. package/lib/SearchAndReplace.cjs +1 -1
  152. package/lib/SearchAndReplace.d.cts +6 -4
  153. package/lib/SearchAndReplace.d.ts +6 -4
  154. package/lib/SearchAndReplace.js +1 -1
  155. package/lib/Selection.d.cts +4 -4
  156. package/lib/Selection.d.ts +4 -4
  157. package/lib/SlashCommand.cjs +1 -1
  158. package/lib/SlashCommand.d.cts +4 -4
  159. package/lib/SlashCommand.d.ts +4 -4
  160. package/lib/SlashCommand.js +1 -1
  161. package/lib/Strike.cjs +1 -1
  162. package/lib/Strike.d.cts +6 -4
  163. package/lib/Strike.d.ts +6 -4
  164. package/lib/Strike.js +13 -13
  165. package/lib/SubAndSuperScript.cjs +1 -1
  166. package/lib/SubAndSuperScript.d.cts +6 -4
  167. package/lib/SubAndSuperScript.d.ts +6 -4
  168. package/lib/SubAndSuperScript.js +1 -1
  169. package/lib/Table.cjs +1 -1
  170. package/lib/Table.d.cts +6 -4
  171. package/lib/Table.d.ts +6 -4
  172. package/lib/Table.js +1 -1
  173. package/lib/TableOfContent.cjs +1 -1
  174. package/lib/TableOfContent.d.cts +4 -4
  175. package/lib/TableOfContent.d.ts +4 -4
  176. package/lib/TableOfContent.js +1 -1
  177. package/lib/TaskList.cjs +1 -1
  178. package/lib/TaskList.d.cts +6 -4
  179. package/lib/TaskList.d.ts +6 -4
  180. package/lib/TaskList.js +15 -15
  181. package/lib/TextAlign.cjs +1 -1
  182. package/lib/TextAlign.d.cts +6 -4
  183. package/lib/TextAlign.d.ts +6 -4
  184. package/lib/TextAlign.js +41 -41
  185. package/lib/TextBubble.cjs +1 -1
  186. package/lib/TextBubble.d.cts +6 -4
  187. package/lib/TextBubble.d.ts +6 -4
  188. package/lib/TextBubble.js +1 -1
  189. package/lib/TextDirection.cjs +1 -1
  190. package/lib/TextDirection.d.cts +4 -4
  191. package/lib/TextDirection.d.ts +4 -4
  192. package/lib/TextDirection.js +1 -1
  193. package/lib/TextUnderline.cjs +1 -1
  194. package/lib/TextUnderline.d.cts +6 -4
  195. package/lib/TextUnderline.d.ts +6 -4
  196. package/lib/TextUnderline.js +8 -8
  197. package/lib/TrailingNode.d.cts +4 -4
  198. package/lib/TrailingNode.d.ts +4 -4
  199. package/lib/{Twitter--OkCPska.cjs → Twitter-D2Osj8qP.cjs} +1 -1
  200. package/lib/{Twitter-CXwmqolk.js → Twitter-Wb7cD3M-.js} +1 -1
  201. package/lib/Twitter.cjs +1 -1
  202. package/lib/Twitter.d.cts +4 -4
  203. package/lib/Twitter.d.ts +4 -4
  204. package/lib/Twitter.js +1 -1
  205. package/lib/Video.cjs +1 -1
  206. package/lib/Video.d.cts +6 -4
  207. package/lib/Video.d.ts +6 -4
  208. package/lib/Video.js +1 -1
  209. package/lib/bubble-extra.cjs +1 -1
  210. package/lib/bubble-extra.d.cts +4 -4
  211. package/lib/bubble-extra.d.ts +4 -4
  212. package/lib/bubble-extra.js +5 -5
  213. package/lib/index.cjs +1 -1
  214. package/lib/index.d.cts +23 -17
  215. package/lib/index.d.ts +23 -17
  216. package/lib/index.js +2 -2
  217. package/lib/locale-bundle.d.cts +4 -4
  218. package/lib/locale-bundle.d.ts +4 -4
  219. package/lib/{textarea-DkVc2MIQ.cjs → textarea-BVbzd9-k.cjs} +1 -1
  220. package/lib/{textarea-HW9QlrCS.js → textarea-Csmx5x-_.js} +1 -1
  221. package/package.json +1 -1
package/lib/Table.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const m=require("./index-ByRfqzMr.cjs"),R=require("react/jsx-runtime"),O=require("./RichTextEditor-DoMu_nCj.cjs"),X=require("react"),T=require("./index-D_A0TBRA.cjs");var q,U;if(typeof WeakMap<"u"){let t=new WeakMap;q=e=>t.get(e),U=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;q=o=>{for(let l=0;l<t.length;l+=2)if(t[l]==o)return t[l+1]},U=(o,l)=>(n==10&&(n=0),t[n++]=o,t[n++]=l)}var S=class{constructor(t,e,n,o){this.width=t,this.height=e,this.map=n,this.problems=o}findCell(t){for(let e=0;e<this.map.length;e++){const n=this.map[e];if(n!=t)continue;const o=e%this.width,l=e/this.width|0;let r=o+1,s=l+1;for(let i=1;r<this.width&&this.map[e+i]==n;i++)r++;for(let i=1;s<this.height&&this.map[e+this.width*i]==n;i++)s++;return{left:o,top:l,right:r,bottom:s}}throw new RangeError(`No cell with offset ${t} found`)}colCount(t){for(let e=0;e<this.map.length;e++)if(this.map[e]==t)return e%this.width;throw new RangeError(`No cell with offset ${t} found`)}nextCell(t,e,n){const{left:o,right:l,top:r,bottom:s}=this.findCell(t);return e=="horiz"?(n<0?o==0:l==this.width)?null:this.map[r*this.width+(n<0?o-1:l)]:(n<0?r==0:s==this.height)?null:this.map[o+this.width*(n<0?r-1:s)]}rectBetween(t,e){const{left:n,right:o,top:l,bottom:r}=this.findCell(t),{left:s,right:i,top:c,bottom:a}=this.findCell(e);return{left:Math.min(n,s),top:Math.min(l,c),right:Math.max(o,i),bottom:Math.max(r,a)}}cellsInRect(t){const e=[],n={};for(let o=t.top;o<t.bottom;o++)for(let l=t.left;l<t.right;l++){const r=o*this.width+l,s=this.map[r];n[s]||(n[s]=!0,!(l==t.left&&l&&this.map[r-1]==s||o==t.top&&o&&this.map[r-this.width]==s)&&e.push(s))}return e}positionAt(t,e,n){for(let o=0,l=0;;o++){const r=l+n.child(o).nodeSize;if(o==t){let s=e+t*this.width;const i=(t+1)*this.width;for(;s<i&&this.map[s]<l;)s++;return s==i?r-1:this.map[s]}l=r}}static get(t){return q(t)||U(t,Ne(t))}};function Ne(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);const e=ke(t),n=t.childCount,o=[];let l=0,r=null;const s=[];for(let a=0,u=e*n;a<u;a++)o[a]=0;for(let a=0,u=0;a<n;a++){const d=t.child(a);u++;for(let p=0;;p++){for(;l<o.length&&o[l]!=0;)l++;if(p==d.childCount)break;const g=d.child(p),{colspan:b,rowspan:C,colwidth:x}=g.attrs;for(let E=0;E<C;E++){if(E+a>=n){(r||(r=[])).push({type:"overlong_rowspan",pos:u,n:C-E});break}const D=l+E*e;for(let z=0;z<b;z++){o[D+z]==0?o[D+z]=u:(r||(r=[])).push({type:"collision",row:a,pos:u,n:b-z});const I=x&&x[z];if(I){const H=(D+z)%e*2,K=s[H];K==null||K!=I&&s[H+1]==1?(s[H]=I,s[H+1]=1):K==I&&s[H+1]++}}}l+=b,u+=g.nodeSize}const f=(a+1)*e;let h=0;for(;l<f;)o[l++]==0&&h++;h&&(r||(r=[])).push({type:"missing",row:a,n:h}),u++}(e===0||n===0)&&(r||(r=[])).push({type:"zero_sized"});const i=new S(e,n,o,r);let c=!1;for(let a=0;!c&&a<s.length;a+=2)s[a]!=null&&s[a+1]<n&&(c=!0);return c&&ze(i,s,t),i}function ke(t){let e=-1,n=!1;for(let o=0;o<t.childCount;o++){const l=t.child(o);let r=0;if(n)for(let s=0;s<o;s++){const i=t.child(s);for(let c=0;c<i.childCount;c++){const a=i.child(c);s+a.attrs.rowspan>o&&(r+=a.attrs.colspan)}}for(let s=0;s<l.childCount;s++){const i=l.child(s);r+=i.attrs.colspan,i.attrs.rowspan>1&&(n=!0)}e==-1?e=r:e!=r&&(e=Math.max(e,r))}return e}function ze(t,e,n){t.problems||(t.problems=[]);const o={};for(let l=0;l<t.map.length;l++){const r=t.map[l];if(o[r])continue;o[r]=!0;const s=n.nodeAt(r);if(!s)throw new RangeError(`No cell with offset ${r} found`);let i=null;const c=s.attrs;for(let a=0;a<c.colspan;a++){const u=(l+a)%t.width,d=e[u*2];d!=null&&(!c.colwidth||c.colwidth[a]!=d)&&((i||(i=Le(c)))[a]=d)}i&&t.problems.unshift({type:"colwidth mismatch",pos:r,colwidth:i})}}function Le(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let n=0;n<t.colspan;n++)e.push(0);return e}function y(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(const n in t.nodes){const o=t.nodes[n],l=o.spec.tableRole;l&&(e[l]=o)}}return e}var k=new m.PluginKey("selectingCells");function _(t){for(let e=t.depth-1;e>0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function _e(t){for(let e=t.depth;e>0;e--){const n=t.node(e).type.spec.tableRole;if(n==="cell"||n==="header_cell")return t.node(e)}return null}function M(t){const e=t.selection.$head;for(let n=e.depth;n>0;n--)if(e.node(n).type.spec.tableRole=="row")return!0;return!1}function V(t){const e=t.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const n=_(e.$head)||De(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function De(t){for(let e=t.nodeAfter,n=t.pos;e;e=e.firstChild,n++){const o=e.type.spec.tableRole;if(o=="cell"||o=="header_cell")return t.doc.resolve(n)}for(let e=t.nodeBefore,n=t.pos;e;e=e.lastChild,n--){const o=e.type.spec.tableRole;if(o=="cell"||o=="header_cell")return t.doc.resolve(n-e.nodeSize)}}function J(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function He(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function te(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function Ce(t,e,n){const o=t.node(-1),l=S.get(o),r=t.start(-1),s=l.nextCell(t.pos-r,e,n);return s==null?null:t.node(0).resolve(r+s)}function L(t,e,n=1){const o={...t,colspan:t.colspan-n};return o.colwidth&&(o.colwidth=o.colwidth.slice(),o.colwidth.splice(e,n),o.colwidth.some(l=>l>0)||(o.colwidth=null)),o}function Se(t,e,n=1){const o={...t,colspan:t.colspan+n};if(o.colwidth){o.colwidth=o.colwidth.slice();for(let l=0;l<n;l++)o.colwidth.splice(e,0,0)}return o}function Be(t,e,n){const o=y(e.type.schema).header_cell;for(let l=0;l<t.height;l++)if(e.nodeAt(t.map[n+l*t.width]).type!=o)return!1;return!0}var w=class N extends m.Selection{constructor(e,n=e){const o=e.node(-1),l=S.get(o),r=e.start(-1),s=l.rectBetween(e.pos-r,n.pos-r),i=e.node(0),c=l.cellsInRect(s).filter(u=>u!=n.pos-r);c.unshift(n.pos-r);const a=c.map(u=>{const d=o.nodeAt(u);if(!d)throw RangeError(`No cell with offset ${u} found`);const f=r+u+1;return new m.SelectionRange(i.resolve(f),i.resolve(f+d.content.size))});super(a[0].$from,a[0].$to,a),this.$anchorCell=e,this.$headCell=n}map(e,n){const o=e.resolve(n.map(this.$anchorCell.pos)),l=e.resolve(n.map(this.$headCell.pos));if(J(o)&&J(l)&&te(o,l)){const r=this.$anchorCell.node(-1)!=o.node(-1);return r&&this.isRowSelection()?N.rowSelection(o,l):r&&this.isColSelection()?N.colSelection(o,l):new N(o,l)}return m.TextSelection.between(o,l)}content(){const e=this.$anchorCell.node(-1),n=S.get(e),o=this.$anchorCell.start(-1),l=n.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o),r={},s=[];for(let c=l.top;c<l.bottom;c++){const a=[];for(let u=c*n.width+l.left,d=l.left;d<l.right;d++,u++){const f=n.map[u];if(r[f])continue;r[f]=!0;const h=n.findCell(f);let p=e.nodeAt(f);if(!p)throw RangeError(`No cell with offset ${f} found`);const g=l.left-h.left,b=h.right-l.right;if(g>0||b>0){let C=p.attrs;if(g>0&&(C=L(C,0,g)),b>0&&(C=L(C,C.colspan-b,b)),h.left<l.left){if(p=p.type.createAndFill(C),!p)throw RangeError(`Could not create cell with attrs ${JSON.stringify(C)}`)}else p=p.type.create(C,p.content)}if(h.top<l.top||h.bottom>l.bottom){const C={...p.attrs,rowspan:Math.min(h.bottom,l.bottom)-Math.max(h.top,l.top)};h.top<l.top?p=p.type.createAndFill(C):p=p.type.create(C,p.content)}a.push(p)}s.push(e.child(c).copy(m.Fragment.from(a)))}const i=this.isColSelection()&&this.isRowSelection()?e:s;return new m.Slice(m.Fragment.from(i),1,1)}replace(e,n=m.Slice.empty){const o=e.steps.length,l=this.ranges;for(let s=0;s<l.length;s++){const{$from:i,$to:c}=l[s],a=e.mapping.slice(o);e.replace(a.map(i.pos),a.map(c.pos),s?m.Slice.empty:n)}const r=m.Selection.findFrom(e.doc.resolve(e.mapping.slice(o).map(this.to)),-1);r&&e.setSelection(r)}replaceWith(e,n){this.replace(e,new m.Slice(m.Fragment.from(n),0,0))}forEachCell(e){const n=this.$anchorCell.node(-1),o=S.get(n),l=this.$anchorCell.start(-1),r=o.cellsInRect(o.rectBetween(this.$anchorCell.pos-l,this.$headCell.pos-l));for(let s=0;s<r.length;s++)e(n.nodeAt(r[s]),l+r[s])}isColSelection(){const e=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(e,n)>0)return!1;const o=e+this.$anchorCell.nodeAfter.attrs.rowspan,l=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(o,l)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){const o=e.node(-1),l=S.get(o),r=e.start(-1),s=l.findCell(e.pos-r),i=l.findCell(n.pos-r),c=e.node(0);return s.top<=i.top?(s.top>0&&(e=c.resolve(r+l.map[s.left])),i.bottom<l.height&&(n=c.resolve(r+l.map[l.width*(l.height-1)+i.right-1]))):(i.top>0&&(n=c.resolve(r+l.map[i.left])),s.bottom<l.height&&(e=c.resolve(r+l.map[l.width*(l.height-1)+s.right-1]))),new N(e,n)}isRowSelection(){const e=this.$anchorCell.node(-1),n=S.get(e),o=this.$anchorCell.start(-1),l=n.colCount(this.$anchorCell.pos-o),r=n.colCount(this.$headCell.pos-o);if(Math.min(l,r)>0)return!1;const s=l+this.$anchorCell.nodeAfter.attrs.colspan,i=r+this.$headCell.nodeAfter.attrs.colspan;return Math.max(s,i)==n.width}eq(e){return e instanceof N&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const o=e.node(-1),l=S.get(o),r=e.start(-1),s=l.findCell(e.pos-r),i=l.findCell(n.pos-r),c=e.node(0);return s.left<=i.left?(s.left>0&&(e=c.resolve(r+l.map[s.top*l.width])),i.right<l.width&&(n=c.resolve(r+l.map[l.width*(i.top+1)-1]))):(i.left>0&&(n=c.resolve(r+l.map[i.top*l.width])),s.right<l.width&&(e=c.resolve(r+l.map[l.width*(s.top+1)-1]))),new N(e,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new N(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,o=n){return new N(e.resolve(n),e.resolve(o))}getBookmark(){return new Ie(this.$anchorCell.pos,this.$headCell.pos)}};w.prototype.visible=!1;m.Selection.jsonID("cell",w);var Ie=class ye{constructor(e,n){this.anchor=e,this.head=n}map(e){return new ye(e.map(this.anchor),e.map(this.head))}resolve(e){const n=e.resolve(this.anchor),o=e.resolve(this.head);return n.parent.type.spec.tableRole=="row"&&o.parent.type.spec.tableRole=="row"&&n.index()<n.parent.childCount&&o.index()<o.parent.childCount&&te(n,o)?new w(n,o):m.Selection.near(o,1)}};function $e(t){if(!(t.selection instanceof w))return null;const e=[];return t.selection.forEachCell((n,o)=>{e.push(m.Decoration.node(o,o+n.nodeSize,{class:"selectedCell"}))}),m.DecorationSet.create(t.doc,e)}function We({$from:t,$to:e}){if(t.pos==e.pos||t.pos<e.pos-6)return!1;let n=t.pos,o=e.pos,l=t.depth;for(;l>=0&&!(t.after(l+1)<t.end(l));l--,n++);for(let r=e.depth;r>=0&&!(e.before(r+1)>e.start(r));r--,o--);return n==o&&/row|table/.test(t.node(l).type.spec.tableRole)}function Pe({$from:t,$to:e}){let n,o;for(let l=t.depth;l>0;l--){const r=t.node(l);if(r.type.spec.tableRole==="cell"||r.type.spec.tableRole==="header_cell"){n=r;break}}for(let l=e.depth;l>0;l--){const r=e.node(l);if(r.type.spec.tableRole==="cell"||r.type.spec.tableRole==="header_cell"){o=r;break}}return n!==o&&e.parentOffset===0}function Fe(t,e,n){const o=(e||t).selection,l=(e||t).doc;let r,s;if(o instanceof m.NodeSelection&&(s=o.node.type.spec.tableRole)){if(s=="cell"||s=="header_cell")r=w.create(l,o.from);else if(s=="row"){const i=l.resolve(o.from+1);r=w.rowSelection(i,i)}else if(!n){const i=S.get(o.node),c=o.from+1,a=c+i.map[i.width*i.height-1];r=w.create(l,c+1,a)}}else o instanceof m.TextSelection&&We(o)?r=m.TextSelection.create(l,o.from):o instanceof m.TextSelection&&Pe(o)&&(r=m.TextSelection.create(l,o.$from.start(),o.$from.end()));return r&&(e||(e=t.tr)).setSelection(r),e}var Oe=new m.PluginKey("fix-tables");function Ae(t,e,n,o){const l=t.childCount,r=e.childCount;e:for(let s=0,i=0;s<r;s++){const c=e.child(s);for(let a=i,u=Math.min(l,s+3);a<u;a++)if(t.child(a)==c){i=a+1,n+=c.nodeSize;continue e}o(c,n),i<l&&t.child(i).sameMarkup(c)?Ae(t.child(i),c,n+1,o):c.nodesBetween(0,c.content.size,o,n+1),n+=c.nodeSize}}function xe(t,e){let n;const o=(l,r)=>{l.type.spec.tableRole=="table"&&(n=je(t,l,r,n))};return e?e.doc!=t.doc&&Ae(e.doc,t.doc,0,o):t.doc.descendants(o),n}function je(t,e,n,o){const l=S.get(e);if(!l.problems)return o;o||(o=t.tr);const r=[];for(let c=0;c<l.height;c++)r.push(0);for(let c=0;c<l.problems.length;c++){const a=l.problems[c];if(a.type=="collision"){const u=e.nodeAt(a.pos);if(!u)continue;const d=u.attrs;for(let f=0;f<d.rowspan;f++)r[a.row+f]+=a.n;o.setNodeMarkup(o.mapping.map(n+1+a.pos),null,L(d,d.colspan-a.n,a.n))}else if(a.type=="missing")r[a.row]+=a.n;else if(a.type=="overlong_rowspan"){const u=e.nodeAt(a.pos);if(!u)continue;o.setNodeMarkup(o.mapping.map(n+1+a.pos),null,{...u.attrs,rowspan:u.attrs.rowspan-a.n})}else if(a.type=="colwidth mismatch"){const u=e.nodeAt(a.pos);if(!u)continue;o.setNodeMarkup(o.mapping.map(n+1+a.pos),null,{...u.attrs,colwidth:a.colwidth})}else if(a.type=="zero_sized"){const u=o.mapping.map(n);o.delete(u,u+e.nodeSize)}}let s,i;for(let c=0;c<r.length;c++)r[c]&&(s==null&&(s=c),i=c);for(let c=0,a=n+1;c<l.height;c++){const u=e.child(c),d=a+u.nodeSize,f=r[c];if(f>0){let h="cell";u.firstChild&&(h=u.firstChild.type.spec.tableRole);const p=[];for(let b=0;b<f;b++){const C=y(t.schema)[h].createAndFill();C&&p.push(C)}const g=(c==0||s==c-1)&&i==c?a+1:d-1;o.insert(o.mapping.map(g),p)}a=d}return o.setMeta(Oe,{fixTables:!0})}function v(t){const e=t.selection,n=V(t),o=n.node(-1),l=n.start(-1),r=S.get(o);return{...e instanceof w?r.rectBetween(e.$anchorCell.pos-l,e.$headCell.pos-l):r.findCell(n.pos-l),tableStart:l,map:r,table:o}}function Te(t,{map:e,tableStart:n,table:o},l){let r=l>0?-1:0;Be(e,o,l+r)&&(r=l==0||l==e.width?null:0);for(let s=0;s<e.height;s++){const i=s*e.width+l;if(l>0&&l<e.width&&e.map[i-1]==e.map[i]){const c=e.map[i],a=o.nodeAt(c);t.setNodeMarkup(t.mapping.map(n+c),null,Se(a.attrs,l-e.colCount(c))),s+=a.attrs.rowspan-1}else{const c=r==null?y(o.type.schema).cell:o.nodeAt(e.map[i+r]).type,a=e.positionAt(s,l,o);t.insert(t.mapping.map(n+a),c.createAndFill())}}return t}function Ge(t,e){if(!M(t))return!1;if(e){const n=v(t);e(Te(t.tr,n,n.left))}return!0}function Ve(t,e){if(!M(t))return!1;if(e){const n=v(t);e(Te(t.tr,n,n.right))}return!0}function Ke(t,{map:e,table:n,tableStart:o},l){const r=t.mapping.maps.length;for(let s=0;s<e.height;){const i=s*e.width+l,c=e.map[i],a=n.nodeAt(c),u=a.attrs;if(l>0&&e.map[i-1]==c||l<e.width-1&&e.map[i+1]==c)t.setNodeMarkup(t.mapping.slice(r).map(o+c),null,L(u,l-e.colCount(c)));else{const d=t.mapping.slice(r).map(o+c);t.delete(d,d+a.nodeSize)}s+=u.rowspan}}function Xe(t,e){if(!M(t))return!1;if(e){const n=v(t),o=t.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let l=n.right-1;Ke(o,n,l),l!=n.left;l--){const r=n.tableStart?o.doc.nodeAt(n.tableStart-1):o.doc;if(!r)throw RangeError("No table found");n.table=r,n.map=S.get(r)}e(o)}return!0}function Ze(t,e,n){var o;const l=y(e.type.schema).header_cell;for(let r=0;r<t.width;r++)if(((o=e.nodeAt(t.map[r+n*t.width]))==null?void 0:o.type)!=l)return!1;return!0}function Re(t,{map:e,tableStart:n,table:o},l){var r;let s=n;for(let a=0;a<l;a++)s+=o.child(a).nodeSize;const i=[];let c=l>0?-1:0;Ze(e,o,l+c)&&(c=l==0||l==e.height?null:0);for(let a=0,u=e.width*l;a<e.width;a++,u++)if(l>0&&l<e.height&&e.map[u]==e.map[u-e.width]){const d=e.map[u],f=o.nodeAt(d).attrs;t.setNodeMarkup(n+d,null,{...f,rowspan:f.rowspan+1}),a+=f.colspan-1}else{const d=c==null?y(o.type.schema).cell:(r=o.nodeAt(e.map[u+c*e.width]))==null?void 0:r.type,f=d==null?void 0:d.createAndFill();f&&i.push(f)}return t.insert(s,y(o.type.schema).row.create(null,i)),t}function qe(t,e){if(!M(t))return!1;if(e){const n=v(t);e(Re(t.tr,n,n.top))}return!0}function Ue(t,e){if(!M(t))return!1;if(e){const n=v(t);e(Re(t.tr,n,n.bottom))}return!0}function Je(t,{map:e,table:n,tableStart:o},l){let r=0;for(let a=0;a<l;a++)r+=n.child(a).nodeSize;const s=r+n.child(l).nodeSize,i=t.mapping.maps.length;t.delete(r+o,s+o);const c=new Set;for(let a=0,u=l*e.width;a<e.width;a++,u++){const d=e.map[u];if(!c.has(d)){if(c.add(d),l>0&&d==e.map[u-e.width]){const f=n.nodeAt(d).attrs;t.setNodeMarkup(t.mapping.slice(i).map(d+o),null,{...f,rowspan:f.rowspan-1}),a+=f.colspan-1}else if(l<e.height&&d==e.map[u+e.width]){const f=n.nodeAt(d),h=f.attrs,p=f.type.create({...h,rowspan:f.attrs.rowspan-1},f.content),g=e.positionAt(l+1,a,n);t.insert(t.mapping.slice(i).map(o+g),p),a+=h.colspan-1}}}}function Ye(t,e){if(!M(t))return!1;if(e){const n=v(t),o=t.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let l=n.bottom-1;Je(o,n,l),l!=n.top;l--){const r=n.tableStart?o.doc.nodeAt(n.tableStart-1):o.doc;if(!r)throw RangeError("No table found");n.table=r,n.map=S.get(n.table)}e(o)}return!0}function ne(t){const e=t.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function Qe({width:t,height:e,map:n},o){let l=o.top*t+o.left,r=l,s=(o.bottom-1)*t+o.left,i=l+(o.right-o.left-1);for(let c=o.top;c<o.bottom;c++){if(o.left>0&&n[r]==n[r-1]||o.right<t&&n[i]==n[i+1])return!0;r+=t,i+=t}for(let c=o.left;c<o.right;c++){if(o.top>0&&n[l]==n[l-t]||o.bottom<e&&n[s]==n[s+t])return!0;l++,s++}return!1}function oe(t,e){const n=t.selection;if(!(n instanceof w)||n.$anchorCell.pos==n.$headCell.pos)return!1;const o=v(t),{map:l}=o;if(Qe(l,o))return!1;if(e){const r=t.tr,s={};let i=m.Fragment.empty,c,a;for(let u=o.top;u<o.bottom;u++)for(let d=o.left;d<o.right;d++){const f=l.map[u*l.width+d],h=o.table.nodeAt(f);if(!(s[f]||!h))if(s[f]=!0,c==null)c=f,a=h;else{ne(h)||(i=i.append(h.content));const p=r.mapping.map(f+o.tableStart);r.delete(p,p+h.nodeSize)}}if(c==null||a==null)return!0;if(r.setNodeMarkup(c+o.tableStart,null,{...Se(a.attrs,a.attrs.colspan,o.right-o.left-a.attrs.colspan),rowspan:o.bottom-o.top}),i.size){const u=c+1+a.content.size,d=ne(a)?c+1:u;r.replaceWith(d+o.tableStart,u+o.tableStart,i)}r.setSelection(new w(r.doc.resolve(c+o.tableStart))),e(r)}return!0}function le(t,e){const n=y(t.schema);return et(({node:o})=>n[o.type.spec.tableRole])(t,e)}function et(t){return(e,n)=>{var o;const l=e.selection;let r,s;if(l instanceof w){if(l.$anchorCell.pos!=l.$headCell.pos)return!1;r=l.$anchorCell.nodeAfter,s=l.$anchorCell.pos}else{if(r=_e(l.$from),!r)return!1;s=(o=_(l.$from))==null?void 0:o.pos}if(r==null||s==null||r.attrs.colspan==1&&r.attrs.rowspan==1)return!1;if(n){let i=r.attrs;const c=[],a=i.colwidth;i.rowspan>1&&(i={...i,rowspan:1}),i.colspan>1&&(i={...i,colspan:1});const u=v(e),d=e.tr;for(let h=0;h<u.right-u.left;h++)c.push(a?{...i,colwidth:a&&a[h]?[a[h]]:null}:i);let f;for(let h=u.top;h<u.bottom;h++){let p=u.map.positionAt(h,u.left,u.table);h==u.top&&(p+=r.nodeSize);for(let g=u.left,b=0;g<u.right;g++,b++)g==u.left&&h==u.top||d.insert(f=d.mapping.map(p+u.tableStart,1),t({node:r,row:h,col:g}).createAndFill(c[b]))}d.setNodeMarkup(s,t({node:r,row:u.top,col:u.left}),c[0]),l instanceof w&&d.setSelection(new w(d.doc.resolve(l.$anchorCell.pos),f?d.doc.resolve(f):void 0)),n(d)}return!0}}function tt(t,e){return function(n,o){if(!M(n))return!1;const l=V(n);if(l.nodeAfter.attrs[t]===e)return!1;if(o){const r=n.tr;n.selection instanceof w?n.selection.forEachCell((s,i)=>{s.attrs[t]!==e&&r.setNodeMarkup(i,null,{...s.attrs,[t]:e})}):r.setNodeMarkup(l.pos,null,{...l.nodeAfter.attrs,[t]:e}),o(r)}return!0}}function nt(t){return function(e,n){if(!M(e))return!1;if(n){const o=y(e.schema),l=v(e),r=e.tr,s=l.map.cellsInRect(t=="column"?{left:l.left,top:0,right:l.right,bottom:l.map.height}:t=="row"?{left:0,top:l.top,right:l.map.width,bottom:l.bottom}:l),i=s.map(c=>l.table.nodeAt(c));for(let c=0;c<s.length;c++)i[c].type==o.header_cell&&r.setNodeMarkup(l.tableStart+s[c],o.cell,i[c].attrs);if(r.steps.length==0)for(let c=0;c<s.length;c++)r.setNodeMarkup(l.tableStart+s[c],o.header_cell,i[c].attrs);n(r)}return!0}}function re(t,e,n){const o=e.map.cellsInRect({left:0,top:0,right:t=="row"?e.map.width:1,bottom:t=="column"?e.map.height:1});for(let l=0;l<o.length;l++){const r=e.table.nodeAt(o[l]);if(r&&r.type!==n.header_cell)return!1}return!0}function B(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?nt(t):function(n,o){if(!M(n))return!1;if(o){const l=y(n.schema),r=v(n),s=n.tr,i=re("row",r,l),c=re("column",r,l),u=(t==="column"?i:t==="row"?c:!1)?1:0,d=t=="column"?{left:0,top:u,right:1,bottom:r.map.height}:t=="row"?{left:u,top:0,right:r.map.width,bottom:1}:r,f=t=="column"?c?l.cell:l.header_cell:t=="row"?i?l.cell:l.header_cell:l.cell;r.map.cellsInRect(d).forEach(h=>{const p=h+r.tableStart,g=s.doc.nodeAt(p);g&&s.setNodeMarkup(p,f,g.attrs)}),o(s)}return!0}}B("row",{useDeprecatedLogic:!0});B("column",{useDeprecatedLogic:!0});var ot=B("cell",{useDeprecatedLogic:!0});function lt(t,e){if(e<0){const n=t.nodeBefore;if(n)return t.pos-n.nodeSize;for(let o=t.index(-1)-1,l=t.before();o>=0;o--){const r=t.node(-1).child(o),s=r.lastChild;if(s)return l-1-s.nodeSize;l-=r.nodeSize}}else{if(t.index()<t.parent.childCount-1)return t.pos+t.nodeAfter.nodeSize;const n=t.node(-1);for(let o=t.indexAfter(-1),l=t.after();o<n.childCount;o++){const r=n.child(o);if(r.childCount)return l+1;l+=r.nodeSize}}return null}function se(t){return function(e,n){if(!M(e))return!1;const o=lt(V(e),t);if(o==null)return!1;if(n){const l=e.doc.resolve(o);n(e.tr.setSelection(m.TextSelection.between(l,He(l))).scrollIntoView())}return!0}}function rt(t,e){const n=t.selection.$anchor;for(let o=n.depth;o>0;o--)if(n.node(o).type.spec.tableRole=="table")return e&&e(t.tr.delete(n.before(o),n.after(o)).scrollIntoView()),!0;return!1}function $(t,e){const n=t.selection;if(!(n instanceof w))return!1;if(e){const o=t.tr,l=y(t.schema).cell.createAndFill().content;n.forEachCell((r,s)=>{r.content.eq(l)||o.replace(o.mapping.map(s+1),o.mapping.map(s+r.nodeSize-1),new m.Slice(l,0,0))}),o.docChanged&&e(o)}return!0}function st(t){if(!t.size)return null;let{content:e,openStart:n,openEnd:o}=t;for(;e.childCount==1&&(n>0&&o>0||e.child(0).type.spec.tableRole=="table");)n--,o--,e=e.child(0).content;const l=e.child(0),r=l.type.spec.tableRole,s=l.type.schema,i=[];if(r=="row")for(let c=0;c<e.childCount;c++){let a=e.child(c).content;const u=c?0:Math.max(0,n-1),d=c<e.childCount-1?0:Math.max(0,o-1);(u||d)&&(a=Y(y(s).row,new m.Slice(a,u,d)).content),i.push(a)}else if(r=="cell"||r=="header_cell")i.push(n||o?Y(y(s).row,new m.Slice(e,n,o)).content:e);else return null;return it(s,i)}function it(t,e){const n=[];for(let l=0;l<e.length;l++){const r=e[l];for(let s=r.childCount-1;s>=0;s--){const{rowspan:i,colspan:c}=r.child(s).attrs;for(let a=l;a<l+i;a++)n[a]=(n[a]||0)+c}}let o=0;for(let l=0;l<n.length;l++)o=Math.max(o,n[l]);for(let l=0;l<n.length;l++)if(l>=e.length&&e.push(m.Fragment.empty),n[l]<o){const r=y(t).cell.createAndFill(),s=[];for(let i=n[l];i<o;i++)s.push(r);e[l]=e[l].append(m.Fragment.from(s))}return{height:e.length,width:o,rows:e}}function Y(t,e){const n=t.createAndFill();return new m.Transform(n).replace(0,n.content.size,e).doc}function ct({width:t,height:e,rows:n},o,l){if(t!=o){const r=[],s=[];for(let i=0;i<n.length;i++){const c=n[i],a=[];for(let u=r[i]||0,d=0;u<o;d++){let f=c.child(d%c.childCount);u+f.attrs.colspan>o&&(f=f.type.createChecked(L(f.attrs,f.attrs.colspan,u+f.attrs.colspan-o),f.content)),a.push(f),u+=f.attrs.colspan;for(let h=1;h<f.attrs.rowspan;h++)r[i+h]=(r[i+h]||0)+f.attrs.colspan}s.push(m.Fragment.from(a))}n=s,t=o}if(e!=l){const r=[];for(let s=0,i=0;s<l;s++,i++){const c=[],a=n[i%e];for(let u=0;u<a.childCount;u++){let d=a.child(u);s+d.attrs.rowspan>l&&(d=d.type.create({...d.attrs,rowspan:Math.max(1,l-d.attrs.rowspan)},d.content)),c.push(d)}r.push(m.Fragment.from(c))}n=r,e=l}return{width:t,height:e,rows:n}}function at(t,e,n,o,l,r,s){const i=t.doc.type.schema,c=y(i);let a,u;if(l>e.width)for(let d=0,f=0;d<e.height;d++){const h=n.child(d);f+=h.nodeSize;const p=[];let g;h.lastChild==null||h.lastChild.type==c.cell?g=a||(a=c.cell.createAndFill()):g=u||(u=c.header_cell.createAndFill());for(let b=e.width;b<l;b++)p.push(g);t.insert(t.mapping.slice(s).map(f-1+o),p)}if(r>e.height){const d=[];for(let p=0,g=(e.height-1)*e.width;p<Math.max(e.width,l);p++){const b=p>=e.width?!1:n.nodeAt(e.map[g+p]).type==c.header_cell;d.push(b?u||(u=c.header_cell.createAndFill()):a||(a=c.cell.createAndFill()))}const f=c.row.create(null,m.Fragment.from(d)),h=[];for(let p=e.height;p<r;p++)h.push(f);t.insert(t.mapping.slice(s).map(o+n.nodeSize-2),h)}return!!(a||u)}function ie(t,e,n,o,l,r,s,i){if(s==0||s==e.height)return!1;let c=!1;for(let a=l;a<r;a++){const u=s*e.width+a,d=e.map[u];if(e.map[u-e.width]==d){c=!0;const f=n.nodeAt(d),{top:h,left:p}=e.findCell(d);t.setNodeMarkup(t.mapping.slice(i).map(d+o),null,{...f.attrs,rowspan:s-h}),t.insert(t.mapping.slice(i).map(e.positionAt(s,p,n)),f.type.createAndFill({...f.attrs,rowspan:h+f.attrs.rowspan-s})),a+=f.attrs.colspan-1}}return c}function ce(t,e,n,o,l,r,s,i){if(s==0||s==e.width)return!1;let c=!1;for(let a=l;a<r;a++){const u=a*e.width+s,d=e.map[u];if(e.map[u-1]==d){c=!0;const f=n.nodeAt(d),h=e.colCount(d),p=t.mapping.slice(i).map(d+o);t.setNodeMarkup(p,null,L(f.attrs,s-h,f.attrs.colspan-(s-h))),t.insert(p+f.nodeSize,f.type.createAndFill(L(f.attrs,0,s-h))),a+=f.attrs.rowspan-1}}return c}function ae(t,e,n,o,l){let r=n?t.doc.nodeAt(n-1):t.doc;if(!r)throw new Error("No table found");let s=S.get(r);const{top:i,left:c}=o,a=c+l.width,u=i+l.height,d=t.tr;let f=0;function h(){if(r=n?d.doc.nodeAt(n-1):d.doc,!r)throw new Error("No table found");s=S.get(r),f=d.mapping.maps.length}at(d,s,r,n,a,u,f)&&h(),ie(d,s,r,n,c,a,i,f)&&h(),ie(d,s,r,n,c,a,u,f)&&h(),ce(d,s,r,n,i,u,c,f)&&h(),ce(d,s,r,n,i,u,a,f)&&h();for(let p=i;p<u;p++){const g=s.positionAt(p,c,r),b=s.positionAt(p,a,r);d.replace(d.mapping.slice(f).map(g+n),d.mapping.slice(f).map(b+n),new m.Slice(l.rows[p-i],0,0))}h(),d.setSelection(new w(d.doc.resolve(n+s.positionAt(i,c,r)),d.doc.resolve(n+s.positionAt(u-1,a-1,r)))),e(d)}var dt=m.keydownHandler({ArrowLeft:W("horiz",-1),ArrowRight:W("horiz",1),ArrowUp:W("vert",-1),ArrowDown:W("vert",1),"Shift-ArrowLeft":P("horiz",-1),"Shift-ArrowRight":P("horiz",1),"Shift-ArrowUp":P("vert",-1),"Shift-ArrowDown":P("vert",1),Backspace:$,"Mod-Backspace":$,Delete:$,"Mod-Delete":$});function j(t,e,n){return n.eq(t.selection)?!1:(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function W(t,e){return(n,o,l)=>{if(!l)return!1;const r=n.selection;if(r instanceof w)return j(n,o,m.Selection.near(r.$headCell,e));if(t!="horiz"&&!r.empty)return!1;const s=Me(l,t,e);if(s==null)return!1;if(t=="horiz")return j(n,o,m.Selection.near(n.doc.resolve(r.head+e),e));{const i=n.doc.resolve(s),c=Ce(i,t,e);let a;return c?a=m.Selection.near(c,1):e<0?a=m.Selection.near(n.doc.resolve(i.before(-1)),-1):a=m.Selection.near(n.doc.resolve(i.after(-1)),1),j(n,o,a)}}}function P(t,e){return(n,o,l)=>{if(!l)return!1;const r=n.selection;let s;if(r instanceof w)s=r;else{const c=Me(l,t,e);if(c==null)return!1;s=new w(n.doc.resolve(c))}const i=Ce(s.$headCell,t,e);return i?j(n,o,new w(s.$anchorCell,i)):!1}}function ut(t,e){const n=t.state.doc,o=_(n.resolve(e));return o?(t.dispatch(t.state.tr.setSelection(new w(o))),!0):!1}function ft(t,e,n){if(!M(t.state))return!1;let o=st(n);const l=t.state.selection;if(l instanceof w){o||(o={width:1,height:1,rows:[m.Fragment.from(Y(y(t.state.schema).cell,n))]});const r=l.$anchorCell.node(-1),s=l.$anchorCell.start(-1),i=S.get(r).rectBetween(l.$anchorCell.pos-s,l.$headCell.pos-s);return o=ct(o,i.right-i.left,i.bottom-i.top),ae(t.state,t.dispatch,s,i,o),!0}else if(o){const r=V(t.state),s=r.start(-1);return ae(t.state,t.dispatch,s,S.get(r.node(-1)).findCell(r.pos-s),o),!0}else return!1}function ht(t,e){var n;if(e.ctrlKey||e.metaKey)return;const o=de(t,e.target);let l;if(e.shiftKey&&t.state.selection instanceof w)r(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&o&&(l=_(t.state.selection.$anchor))!=null&&((n=Z(t,e))==null?void 0:n.pos)!=l.pos)r(l,e),e.preventDefault();else if(!o)return;function r(c,a){let u=Z(t,a);const d=k.getState(t.state)==null;if(!u||!te(c,u))if(d)u=c;else return;const f=new w(c,u);if(d||!t.state.selection.eq(f)){const h=t.state.tr.setSelection(f);d&&h.setMeta(k,c.pos),t.dispatch(h)}}function s(){t.root.removeEventListener("mouseup",s),t.root.removeEventListener("dragstart",s),t.root.removeEventListener("mousemove",i),k.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(k,-1))}function i(c){const a=c,u=k.getState(t.state);let d;if(u!=null)d=t.state.doc.resolve(u);else if(de(t,a.target)!=o&&(d=Z(t,e),!d))return s();d&&r(d,a)}t.root.addEventListener("mouseup",s),t.root.addEventListener("dragstart",s),t.root.addEventListener("mousemove",i)}function Me(t,e,n){if(!(t.state.selection instanceof m.TextSelection))return null;const{$head:o}=t.state.selection;for(let l=o.depth-1;l>=0;l--){const r=o.node(l);if((n<0?o.index(l):o.indexAfter(l))!=(n<0?0:r.childCount))return null;if(r.type.spec.tableRole=="cell"||r.type.spec.tableRole=="header_cell"){const i=o.before(l),c=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(c)?i:null}}return null}function de(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Z(t,e){const n=t.posAtCoords({left:e.clientX,top:e.clientY});return n&&n?_(t.state.doc.resolve(n.pos)):null}var pt=class{constructor(e,n){this.node=e,this.defaultCellMinWidth=n,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${n}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Q(e,this.colgroup,this.table,n),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,Q(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function Q(t,e,n,o,l,r){var s;let i=0,c=!0,a=e.firstChild;const u=t.firstChild;if(u){for(let d=0,f=0;d<u.childCount;d++){const{colspan:h,colwidth:p}=u.child(d).attrs;for(let g=0;g<h;g++,f++){const b=l==f?r:p&&p[g],C=b?b+"px":"";if(i+=b||o,b||(c=!1),a)a.style.width!=C&&(a.style.width=C),a=a.nextSibling;else{const x=document.createElement("col");x.style.width=C,e.appendChild(x)}}}for(;a;){const d=a.nextSibling;(s=a.parentNode)==null||s.removeChild(a),a=d}c?(n.style.width=i+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=i+"px")}}var A=new m.PluginKey("tableColumnResizing");function mt({handleWidth:t=5,cellMinWidth:e=25,defaultCellMinWidth:n=100,View:o=pt,lastColumnResizable:l=!0}={}){const r=new m.Plugin({key:A,state:{init(s,i){var c,a;const u=(a=(c=r.spec)==null?void 0:c.props)==null?void 0:a.nodeViews,d=y(i.schema).table.name;return o&&u&&(u[d]=(f,h)=>new o(f,n,h)),new gt(-1,!1)},apply(s,i){return i.apply(s)}},props:{attributes:s=>{const i=A.getState(s);return i&&i.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(s,i)=>{bt(s,i,t,l)},mouseleave:s=>{wt(s)},mousedown:(s,i)=>{Ct(s,i,e,n)}},decorations:s=>{const i=A.getState(s);if(i&&i.activeHandle>-1)return Tt(s,i.activeHandle)},nodeViews:{}}});return r}var gt=class G{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){const n=this,o=e.getMeta(A);if(o&&o.setHandle!=null)return new G(o.setHandle,!1);if(o&&o.setDragging!==void 0)return new G(n.activeHandle,o.setDragging);if(n.activeHandle>-1&&e.docChanged){let l=e.mapping.map(n.activeHandle,-1);return J(e.doc.resolve(l))||(l=-1),new G(l,n.dragging)}return n}};function bt(t,e,n,o){if(!t.editable)return;const l=A.getState(t.state);if(l&&!l.dragging){const r=yt(e.target);let s=-1;if(r){const{left:i,right:c}=r.getBoundingClientRect();e.clientX-i<=n?s=ue(t,e,"left",n):c-e.clientX<=n&&(s=ue(t,e,"right",n))}if(s!=l.activeHandle){if(!o&&s!==-1){const i=t.state.doc.resolve(s),c=i.node(-1),a=S.get(c),u=i.start(-1);if(a.colCount(i.pos-u)+i.nodeAfter.attrs.colspan-1==a.width-1)return}ve(t,s)}}}function wt(t){if(!t.editable)return;const e=A.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&ve(t,-1)}function Ct(t,e,n,o){var l;if(!t.editable)return!1;const r=(l=t.dom.ownerDocument.defaultView)!=null?l:window,s=A.getState(t.state);if(!s||s.activeHandle==-1||s.dragging)return!1;const i=t.state.doc.nodeAt(s.activeHandle),c=St(t,s.activeHandle,i.attrs);t.dispatch(t.state.tr.setMeta(A,{setDragging:{startX:e.clientX,startWidth:c}}));function a(d){r.removeEventListener("mouseup",a),r.removeEventListener("mousemove",u);const f=A.getState(t.state);f!=null&&f.dragging&&(At(t,f.activeHandle,fe(f.dragging,d,n)),t.dispatch(t.state.tr.setMeta(A,{setDragging:null})))}function u(d){if(!d.which)return a(d);const f=A.getState(t.state);if(f&&f.dragging){const h=fe(f.dragging,d,n);he(t,f.activeHandle,h,o)}}return he(t,s.activeHandle,c,o),r.addEventListener("mouseup",a),r.addEventListener("mousemove",u),e.preventDefault(),!0}function St(t,e,{colspan:n,colwidth:o}){const l=o&&o[o.length-1];if(l)return l;const r=t.domAtPos(e);let i=r.node.childNodes[r.offset].offsetWidth,c=n;if(o)for(let a=0;a<n;a++)o[a]&&(i-=o[a],c--);return i/c}function yt(t){for(;t&&t.nodeName!="TD"&&t.nodeName!="TH";)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}function ue(t,e,n,o){const l=n=="right"?-o:o,r=t.posAtCoords({left:e.clientX+l,top:e.clientY});if(!r)return-1;const{pos:s}=r,i=_(t.state.doc.resolve(s));if(!i)return-1;if(n=="right")return i.pos;const c=S.get(i.node(-1)),a=i.start(-1),u=c.map.indexOf(i.pos-a);return u%c.width==0?-1:a+c.map[u-1]}function fe(t,e,n){const o=e.clientX-t.startX;return Math.max(n,t.startWidth+o)}function ve(t,e){t.dispatch(t.state.tr.setMeta(A,{setHandle:e}))}function At(t,e,n){const o=t.state.doc.resolve(e),l=o.node(-1),r=S.get(l),s=o.start(-1),i=r.colCount(o.pos-s)+o.nodeAfter.attrs.colspan-1,c=t.state.tr;for(let a=0;a<r.height;a++){const u=a*r.width+i;if(a&&r.map[u]==r.map[u-r.width])continue;const d=r.map[u],f=l.nodeAt(d).attrs,h=f.colspan==1?0:i-r.colCount(d);if(f.colwidth&&f.colwidth[h]==n)continue;const p=f.colwidth?f.colwidth.slice():xt(f.colspan);p[h]=n,c.setNodeMarkup(s+d,null,{...f,colwidth:p})}c.docChanged&&t.dispatch(c)}function he(t,e,n,o){const l=t.state.doc.resolve(e),r=l.node(-1),s=l.start(-1),i=S.get(r).colCount(l.pos-s)+l.nodeAfter.attrs.colspan-1;let c=t.domAtPos(l.start(-1)).node;for(;c&&c.nodeName!="TABLE";)c=c.parentNode;c&&Q(r,c.firstChild,c,o,i,n)}function xt(t){return Array(t).fill(0)}function Tt(t,e){var n;const o=[],l=t.doc.resolve(e),r=l.node(-1);if(!r)return m.DecorationSet.empty;const s=S.get(r),i=l.start(-1),c=s.colCount(l.pos-i)+l.nodeAfter.attrs.colspan-1;for(let a=0;a<s.height;a++){const u=c+a*s.width;if((c==s.width-1||s.map[u]!=s.map[u+1])&&(a==0||s.map[u]!=s.map[u-s.width])){const d=s.map[u],f=i+d+r.nodeAt(d).nodeSize-1,h=document.createElement("div");h.className="column-resize-handle",(n=A.getState(t))!=null&&n.dragging&&o.push(m.Decoration.node(i+d,i+d+r.nodeAt(d).nodeSize,{class:"column-resize-dragging"})),o.push(m.Decoration.widget(f,h))}}return m.DecorationSet.create(t.doc,o)}function Rt({allowTableNodeSelection:t=!1}={}){return new m.Plugin({key:k,state:{init(){return null},apply(e,n){const o=e.getMeta(k);if(o!=null)return o==-1?null:o;if(n==null||!e.docChanged)return n;const{deleted:l,pos:r}=e.mapping.mapResult(n);return l?null:r}},props:{decorations:$e,handleDOMEvents:{mousedown:ht},createSelectionBetween(e){return k.getState(e.state)!=null?e.state.selection:null},handleTripleClick:ut,handleKeyDown:dt,handlePaste:ft},appendTransaction(e,n,o){return Fe(o,xe(o,n),t)}})}function ee(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function pe(t,e,n,o,l,r){var s;let i=0,c=!0,a=e.firstChild;const u=t.firstChild;if(u!==null)for(let d=0,f=0;d<u.childCount;d+=1){const{colspan:h,colwidth:p}=u.child(d).attrs;for(let g=0;g<h;g+=1,f+=1){const b=l===f?r:p&&p[g],C=b?`${b}px`:"";if(i+=b||o,b||(c=!1),a){if(a.style.width!==C){const[x,E]=ee(o,b);a.style.setProperty(x,E)}a=a.nextSibling}else{const x=document.createElement("col"),[E,D]=ee(o,b);x.style.setProperty(E,D),e.appendChild(x)}}}for(;a;){const d=a.nextSibling;(s=a.parentNode)===null||s===void 0||s.removeChild(a),a=d}c?(n.style.width=`${i}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${i}px`)}class Mt{constructor(e,n){this.node=e,this.cellMinWidth=n,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),pe(e,this.colgroup,this.table,n),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!==this.node.type?!1:(this.node=e,pe(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return e.type==="attributes"&&(e.target===this.table||this.colgroup.contains(e.target))}}function vt(t,e,n,o){let l=0,r=!0;const s=[],i=t.firstChild;if(!i)return{};for(let d=0,f=0;d<i.childCount;d+=1){const{colspan:h,colwidth:p}=i.child(d).attrs;for(let g=0;g<h;g+=1,f+=1){const b=n===f?o:p&&p[g];l+=b||e,b||(r=!1);const[C,x]=ee(e,b);s.push(["col",{style:`${C}: ${x}`}])}}const c=r?`${l}px`:"",a=r?"":`${l}px`;return{colgroup:["colgroup",{},...s],tableWidth:c,tableMinWidth:a}}function me(t,e){return t.createAndFill()}function Et(t){if(t.cached.tableNodeTypes)return t.cached.tableNodeTypes;const e={};return Object.keys(t.nodes).forEach(n=>{const o=t.nodes[n];o.spec.tableRole&&(e[o.spec.tableRole]=o)}),t.cached.tableNodeTypes=e,e}function Nt(t,e,n,o,l){const r=Et(t),s=[],i=[];for(let a=0;a<n;a+=1){const u=me(r.cell);if(u&&i.push(u),o){const d=me(r.header_cell);d&&s.push(d)}}const c=[];for(let a=0;a<e;a+=1)c.push(r.row.createChecked(null,o&&a===0?s:i));return r.table.createChecked(null,c)}function kt(t){return t instanceof w}const F=({editor:t})=>{const{selection:e}=t.state;if(!kt(e))return!1;let n=0;const o=m.findParentNodeClosestToPos(e.ranges[0].$from,r=>r.type.name==="table");return o==null||o.node.descendants(r=>{if(r.type.name==="table")return!1;["tableCell","tableHeader"].includes(r.type.name)&&(n+=1)}),n===e.ranges.length?(t.commands.deleteTable(),!0):!1},zt=m.Node.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,handleWidth:5,cellMinWidth:25,View:Mt,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:t,HTMLAttributes:e}){const{colgroup:n,tableWidth:o,tableMinWidth:l}=vt(t,this.options.cellMinWidth);return["table",m.mergeAttributes(this.options.HTMLAttributes,e,{style:o?`width: ${o}`:`min-width: ${l}`}),n,["tbody",0]]},addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:o,dispatch:l,editor:r})=>{const s=Nt(r.schema,t,e,n);if(l){const i=o.selection.from+1;o.replaceSelectionWith(s).scrollIntoView().setSelection(m.TextSelection.near(o.doc.resolve(i)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>Ge(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>Ve(t,e),deleteColumn:()=>({state:t,dispatch:e})=>Xe(t,e),addRowBefore:()=>({state:t,dispatch:e})=>qe(t,e),addRowAfter:()=>({state:t,dispatch:e})=>Ue(t,e),deleteRow:()=>({state:t,dispatch:e})=>Ye(t,e),deleteTable:()=>({state:t,dispatch:e})=>rt(t,e),mergeCells:()=>({state:t,dispatch:e})=>oe(t,e),splitCell:()=>({state:t,dispatch:e})=>le(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>B("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>B("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>ot(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>oe(t,e)?!0:le(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:o})=>tt(t,e)(n,o),goToNextCell:()=>({state:t,dispatch:e})=>se(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>se(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&xe(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){const o=w.create(e.doc,t.anchorCell,t.headCell);e.setSelection(o)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:F,"Mod-Backspace":F,Delete:F,"Mod-Delete":F}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[mt({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],Rt({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){const e={name:t.name,options:t.options,storage:t.storage};return{tableRole:m.callOrReturn(m.getExtensionField(t,"tableRole",e))}}}),Lt=m.Node.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?e.split(",").map(o=>parseInt(o,10)):null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:t}){return["th",m.mergeAttributes(this.options.HTMLAttributes,t),0]}}),_t=/(android|bb\d+|meego).+mobile|armv7l|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series[46]0|samsungbrowser.*mobile|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i,Dt=/CrOS/,Ht=/android|ipad|playbook|silk/i;function ge(t={}){let e=t.ua||typeof navigator<"u"&&navigator.userAgent;return e&&typeof e=="object"&&e.headers&&typeof e.headers["user-agent"]=="string"&&(e=e.headers["user-agent"]),typeof e!="string"?!1:!!(_t.test(e)&&!Dt.test(e)||t.tablet&&Ht.test(e)||t.tablet&&t.featureDetect&&navigator&&navigator.maxTouchPoints>1&&e.includes("Macintosh")&&e.includes("Safari"))}const be=t=>Array.from({length:t}).map((e,n)=>n+1);function Bt(t){var u;const[e,n]=X.useState(!0),[o,l]=X.useState({rows:ge()?T.TABLE_MAX_GRID_SIZE:T.TABLE_INIT_GRID_SIZE,cols:ge()?T.TABLE_MAX_GRID_SIZE:T.TABLE_INIT_GRID_SIZE}),[r,s]=X.useState({rows:T.TABLE_DEFAULT_SELECTED_GRID_SIZE,cols:T.TABLE_DEFAULT_SELECTED_GRID_SIZE});function i(d,f){d===o.rows&&l(h=>({...h,rows:Math.min(d+1,T.TABLE_MAX_GRID_SIZE)})),f===o.cols&&l(h=>({...h,cols:Math.min(f+1,T.TABLE_MAX_GRID_SIZE)})),s({rows:d,cols:f})}function c(d,f){t==null||t.createTable({rows:d,cols:f,withHeaderRow:e}),a()}function a(){n(!1),l({rows:T.TABLE_INIT_GRID_SIZE,cols:T.TABLE_INIT_GRID_SIZE}),s({rows:T.TABLE_DEFAULT_SELECTED_GRID_SIZE,cols:T.TABLE_DEFAULT_SELECTED_GRID_SIZE})}return R.jsxs(O.Popover,{modal:!0,children:[R.jsx(O.PopoverTrigger,{asChild:!0,children:t==null?void 0:t.children}),R.jsx(O.PopoverContent,{align:"start",className:"richtext-w-full !richtext-p-2",side:"bottom",children:R.jsxs("div",{className:"table-grid-size-editor richtext-p-0",children:[R.jsx("div",{className:"richtext-flex richtext-flex-col richtext-flex-wrap richtext-justify-between richtext-gap-1",children:(u=be(o==null?void 0:o.rows))==null?void 0:u.map(d=>{var f;return R.jsx("div",{className:"richtext-flex richtext-gap-1",children:(f=be(o==null?void 0:o.cols))==null?void 0:f.map(h=>R.jsx("div",{onMouseDown:()=>c(d,h),onMouseOver:()=>i(d,h),className:`richtext-cursor-pointer richtext-border-border ${h<=r.cols&&d<=r.rows&&"tableCellActive !richtext-bg-foreground"}`,children:R.jsx("div",{className:"richtext-box-border richtext-size-4 richtext-rounded-[2px] !richtext-border richtext-border-solid !richtext-border-border richtext-p-1"})},`c-${h}`))},`r-${d}`)})}),R.jsxs("div",{className:"richtext-mt-2 richtext-text-center richtext-text-sm richtext-text-zinc-600",children:[r.rows," ","x",r.cols]})]})})]})}function It(t){function e(n){t.disabled||t.editor.chain().focus().insertTable({...n,withHeaderRow:!1}).run()}return R.jsx(Bt,{createTable:e,children:R.jsx(O.ActionButton,{icon:t==null?void 0:t.icon,tooltip:t==null?void 0:t.tooltip,disabled:t==null?void 0:t.disabled,color:t==null?void 0:t.color,action:t==null?void 0:t.action,isActive:t==null?void 0:t.isActive})})}function $t(t,e,n){if(!t.doc)return t;const o=t.doc.nodeAt(e);if(!o||n===o.attrs.backgroundColor)return t;const l={...o.attrs,backgroundColor:n};return t.setNodeMarkup(e,o.type,l,o.marks)}function Wt(t,e,n){const{doc:o,selection:l}=t;return!o||!l||!(l instanceof w)||l.forEachCell((r,s)=>{t=$t(t,s,n)}),t}function we(t,e){return({tr:n,state:o,dispatch:l})=>{const{selection:r}=o;return n=n.setSelection(r),n=Wt(n,e,t),n.docChanged?(l==null||l(n),!0):!1}}const Pt=m.Extension.create({name:"tableCellBackground",addOptions(){return{types:["tableCell"],HTMLAttributes:{}}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{parseHTML:t=>t.style.backgroundColor||"",renderHTML:t=>!t.backgroundColor||t.backgroundColor===""?{}:{style:`background-color: ${t.backgroundColor}`}}}}]},addCommands(){return{setTableCellBackground:t=>we(t,this.options),unsetTableCellBackground:()=>we("",this.options)}}}),Ft=m.Node.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",m.mergeAttributes(this.options.HTMLAttributes,t),0]}}),Ot=Ft.extend({addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),HTMLAttributes:{style:"border-bottom: 1px solid #000;"}}}}),jt=m.Node.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?e.split(",").map(o=>parseInt(o,10)):null}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:t}){return["td",m.mergeAttributes(this.options.HTMLAttributes,t),0]}}),Gt=jt.extend({addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),HTMLAttributes:{style:`
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const m=require("./index-ByRfqzMr.cjs"),R=require("react/jsx-runtime"),O=require("./RichTextEditor-DsUcQSbm.cjs"),X=require("react"),T=require("./index-D_A0TBRA.cjs");var q,U;if(typeof WeakMap<"u"){let t=new WeakMap;q=e=>t.get(e),U=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;q=o=>{for(let l=0;l<t.length;l+=2)if(t[l]==o)return t[l+1]},U=(o,l)=>(n==10&&(n=0),t[n++]=o,t[n++]=l)}var S=class{constructor(t,e,n,o){this.width=t,this.height=e,this.map=n,this.problems=o}findCell(t){for(let e=0;e<this.map.length;e++){const n=this.map[e];if(n!=t)continue;const o=e%this.width,l=e/this.width|0;let r=o+1,s=l+1;for(let i=1;r<this.width&&this.map[e+i]==n;i++)r++;for(let i=1;s<this.height&&this.map[e+this.width*i]==n;i++)s++;return{left:o,top:l,right:r,bottom:s}}throw new RangeError(`No cell with offset ${t} found`)}colCount(t){for(let e=0;e<this.map.length;e++)if(this.map[e]==t)return e%this.width;throw new RangeError(`No cell with offset ${t} found`)}nextCell(t,e,n){const{left:o,right:l,top:r,bottom:s}=this.findCell(t);return e=="horiz"?(n<0?o==0:l==this.width)?null:this.map[r*this.width+(n<0?o-1:l)]:(n<0?r==0:s==this.height)?null:this.map[o+this.width*(n<0?r-1:s)]}rectBetween(t,e){const{left:n,right:o,top:l,bottom:r}=this.findCell(t),{left:s,right:i,top:c,bottom:a}=this.findCell(e);return{left:Math.min(n,s),top:Math.min(l,c),right:Math.max(o,i),bottom:Math.max(r,a)}}cellsInRect(t){const e=[],n={};for(let o=t.top;o<t.bottom;o++)for(let l=t.left;l<t.right;l++){const r=o*this.width+l,s=this.map[r];n[s]||(n[s]=!0,!(l==t.left&&l&&this.map[r-1]==s||o==t.top&&o&&this.map[r-this.width]==s)&&e.push(s))}return e}positionAt(t,e,n){for(let o=0,l=0;;o++){const r=l+n.child(o).nodeSize;if(o==t){let s=e+t*this.width;const i=(t+1)*this.width;for(;s<i&&this.map[s]<l;)s++;return s==i?r-1:this.map[s]}l=r}}static get(t){return q(t)||U(t,Ne(t))}};function Ne(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);const e=ke(t),n=t.childCount,o=[];let l=0,r=null;const s=[];for(let a=0,u=e*n;a<u;a++)o[a]=0;for(let a=0,u=0;a<n;a++){const d=t.child(a);u++;for(let p=0;;p++){for(;l<o.length&&o[l]!=0;)l++;if(p==d.childCount)break;const g=d.child(p),{colspan:b,rowspan:C,colwidth:x}=g.attrs;for(let E=0;E<C;E++){if(E+a>=n){(r||(r=[])).push({type:"overlong_rowspan",pos:u,n:C-E});break}const D=l+E*e;for(let z=0;z<b;z++){o[D+z]==0?o[D+z]=u:(r||(r=[])).push({type:"collision",row:a,pos:u,n:b-z});const I=x&&x[z];if(I){const H=(D+z)%e*2,K=s[H];K==null||K!=I&&s[H+1]==1?(s[H]=I,s[H+1]=1):K==I&&s[H+1]++}}}l+=b,u+=g.nodeSize}const f=(a+1)*e;let h=0;for(;l<f;)o[l++]==0&&h++;h&&(r||(r=[])).push({type:"missing",row:a,n:h}),u++}(e===0||n===0)&&(r||(r=[])).push({type:"zero_sized"});const i=new S(e,n,o,r);let c=!1;for(let a=0;!c&&a<s.length;a+=2)s[a]!=null&&s[a+1]<n&&(c=!0);return c&&ze(i,s,t),i}function ke(t){let e=-1,n=!1;for(let o=0;o<t.childCount;o++){const l=t.child(o);let r=0;if(n)for(let s=0;s<o;s++){const i=t.child(s);for(let c=0;c<i.childCount;c++){const a=i.child(c);s+a.attrs.rowspan>o&&(r+=a.attrs.colspan)}}for(let s=0;s<l.childCount;s++){const i=l.child(s);r+=i.attrs.colspan,i.attrs.rowspan>1&&(n=!0)}e==-1?e=r:e!=r&&(e=Math.max(e,r))}return e}function ze(t,e,n){t.problems||(t.problems=[]);const o={};for(let l=0;l<t.map.length;l++){const r=t.map[l];if(o[r])continue;o[r]=!0;const s=n.nodeAt(r);if(!s)throw new RangeError(`No cell with offset ${r} found`);let i=null;const c=s.attrs;for(let a=0;a<c.colspan;a++){const u=(l+a)%t.width,d=e[u*2];d!=null&&(!c.colwidth||c.colwidth[a]!=d)&&((i||(i=Le(c)))[a]=d)}i&&t.problems.unshift({type:"colwidth mismatch",pos:r,colwidth:i})}}function Le(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let n=0;n<t.colspan;n++)e.push(0);return e}function y(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(const n in t.nodes){const o=t.nodes[n],l=o.spec.tableRole;l&&(e[l]=o)}}return e}var k=new m.PluginKey("selectingCells");function _(t){for(let e=t.depth-1;e>0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function _e(t){for(let e=t.depth;e>0;e--){const n=t.node(e).type.spec.tableRole;if(n==="cell"||n==="header_cell")return t.node(e)}return null}function M(t){const e=t.selection.$head;for(let n=e.depth;n>0;n--)if(e.node(n).type.spec.tableRole=="row")return!0;return!1}function V(t){const e=t.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const n=_(e.$head)||De(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function De(t){for(let e=t.nodeAfter,n=t.pos;e;e=e.firstChild,n++){const o=e.type.spec.tableRole;if(o=="cell"||o=="header_cell")return t.doc.resolve(n)}for(let e=t.nodeBefore,n=t.pos;e;e=e.lastChild,n--){const o=e.type.spec.tableRole;if(o=="cell"||o=="header_cell")return t.doc.resolve(n-e.nodeSize)}}function J(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function He(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function te(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function Ce(t,e,n){const o=t.node(-1),l=S.get(o),r=t.start(-1),s=l.nextCell(t.pos-r,e,n);return s==null?null:t.node(0).resolve(r+s)}function L(t,e,n=1){const o={...t,colspan:t.colspan-n};return o.colwidth&&(o.colwidth=o.colwidth.slice(),o.colwidth.splice(e,n),o.colwidth.some(l=>l>0)||(o.colwidth=null)),o}function Se(t,e,n=1){const o={...t,colspan:t.colspan+n};if(o.colwidth){o.colwidth=o.colwidth.slice();for(let l=0;l<n;l++)o.colwidth.splice(e,0,0)}return o}function Be(t,e,n){const o=y(e.type.schema).header_cell;for(let l=0;l<t.height;l++)if(e.nodeAt(t.map[n+l*t.width]).type!=o)return!1;return!0}var w=class N extends m.Selection{constructor(e,n=e){const o=e.node(-1),l=S.get(o),r=e.start(-1),s=l.rectBetween(e.pos-r,n.pos-r),i=e.node(0),c=l.cellsInRect(s).filter(u=>u!=n.pos-r);c.unshift(n.pos-r);const a=c.map(u=>{const d=o.nodeAt(u);if(!d)throw RangeError(`No cell with offset ${u} found`);const f=r+u+1;return new m.SelectionRange(i.resolve(f),i.resolve(f+d.content.size))});super(a[0].$from,a[0].$to,a),this.$anchorCell=e,this.$headCell=n}map(e,n){const o=e.resolve(n.map(this.$anchorCell.pos)),l=e.resolve(n.map(this.$headCell.pos));if(J(o)&&J(l)&&te(o,l)){const r=this.$anchorCell.node(-1)!=o.node(-1);return r&&this.isRowSelection()?N.rowSelection(o,l):r&&this.isColSelection()?N.colSelection(o,l):new N(o,l)}return m.TextSelection.between(o,l)}content(){const e=this.$anchorCell.node(-1),n=S.get(e),o=this.$anchorCell.start(-1),l=n.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o),r={},s=[];for(let c=l.top;c<l.bottom;c++){const a=[];for(let u=c*n.width+l.left,d=l.left;d<l.right;d++,u++){const f=n.map[u];if(r[f])continue;r[f]=!0;const h=n.findCell(f);let p=e.nodeAt(f);if(!p)throw RangeError(`No cell with offset ${f} found`);const g=l.left-h.left,b=h.right-l.right;if(g>0||b>0){let C=p.attrs;if(g>0&&(C=L(C,0,g)),b>0&&(C=L(C,C.colspan-b,b)),h.left<l.left){if(p=p.type.createAndFill(C),!p)throw RangeError(`Could not create cell with attrs ${JSON.stringify(C)}`)}else p=p.type.create(C,p.content)}if(h.top<l.top||h.bottom>l.bottom){const C={...p.attrs,rowspan:Math.min(h.bottom,l.bottom)-Math.max(h.top,l.top)};h.top<l.top?p=p.type.createAndFill(C):p=p.type.create(C,p.content)}a.push(p)}s.push(e.child(c).copy(m.Fragment.from(a)))}const i=this.isColSelection()&&this.isRowSelection()?e:s;return new m.Slice(m.Fragment.from(i),1,1)}replace(e,n=m.Slice.empty){const o=e.steps.length,l=this.ranges;for(let s=0;s<l.length;s++){const{$from:i,$to:c}=l[s],a=e.mapping.slice(o);e.replace(a.map(i.pos),a.map(c.pos),s?m.Slice.empty:n)}const r=m.Selection.findFrom(e.doc.resolve(e.mapping.slice(o).map(this.to)),-1);r&&e.setSelection(r)}replaceWith(e,n){this.replace(e,new m.Slice(m.Fragment.from(n),0,0))}forEachCell(e){const n=this.$anchorCell.node(-1),o=S.get(n),l=this.$anchorCell.start(-1),r=o.cellsInRect(o.rectBetween(this.$anchorCell.pos-l,this.$headCell.pos-l));for(let s=0;s<r.length;s++)e(n.nodeAt(r[s]),l+r[s])}isColSelection(){const e=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(e,n)>0)return!1;const o=e+this.$anchorCell.nodeAfter.attrs.rowspan,l=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(o,l)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){const o=e.node(-1),l=S.get(o),r=e.start(-1),s=l.findCell(e.pos-r),i=l.findCell(n.pos-r),c=e.node(0);return s.top<=i.top?(s.top>0&&(e=c.resolve(r+l.map[s.left])),i.bottom<l.height&&(n=c.resolve(r+l.map[l.width*(l.height-1)+i.right-1]))):(i.top>0&&(n=c.resolve(r+l.map[i.left])),s.bottom<l.height&&(e=c.resolve(r+l.map[l.width*(l.height-1)+s.right-1]))),new N(e,n)}isRowSelection(){const e=this.$anchorCell.node(-1),n=S.get(e),o=this.$anchorCell.start(-1),l=n.colCount(this.$anchorCell.pos-o),r=n.colCount(this.$headCell.pos-o);if(Math.min(l,r)>0)return!1;const s=l+this.$anchorCell.nodeAfter.attrs.colspan,i=r+this.$headCell.nodeAfter.attrs.colspan;return Math.max(s,i)==n.width}eq(e){return e instanceof N&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const o=e.node(-1),l=S.get(o),r=e.start(-1),s=l.findCell(e.pos-r),i=l.findCell(n.pos-r),c=e.node(0);return s.left<=i.left?(s.left>0&&(e=c.resolve(r+l.map[s.top*l.width])),i.right<l.width&&(n=c.resolve(r+l.map[l.width*(i.top+1)-1]))):(i.left>0&&(n=c.resolve(r+l.map[i.top*l.width])),s.right<l.width&&(e=c.resolve(r+l.map[l.width*(s.top+1)-1]))),new N(e,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new N(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,o=n){return new N(e.resolve(n),e.resolve(o))}getBookmark(){return new Ie(this.$anchorCell.pos,this.$headCell.pos)}};w.prototype.visible=!1;m.Selection.jsonID("cell",w);var Ie=class ye{constructor(e,n){this.anchor=e,this.head=n}map(e){return new ye(e.map(this.anchor),e.map(this.head))}resolve(e){const n=e.resolve(this.anchor),o=e.resolve(this.head);return n.parent.type.spec.tableRole=="row"&&o.parent.type.spec.tableRole=="row"&&n.index()<n.parent.childCount&&o.index()<o.parent.childCount&&te(n,o)?new w(n,o):m.Selection.near(o,1)}};function $e(t){if(!(t.selection instanceof w))return null;const e=[];return t.selection.forEachCell((n,o)=>{e.push(m.Decoration.node(o,o+n.nodeSize,{class:"selectedCell"}))}),m.DecorationSet.create(t.doc,e)}function We({$from:t,$to:e}){if(t.pos==e.pos||t.pos<e.pos-6)return!1;let n=t.pos,o=e.pos,l=t.depth;for(;l>=0&&!(t.after(l+1)<t.end(l));l--,n++);for(let r=e.depth;r>=0&&!(e.before(r+1)>e.start(r));r--,o--);return n==o&&/row|table/.test(t.node(l).type.spec.tableRole)}function Pe({$from:t,$to:e}){let n,o;for(let l=t.depth;l>0;l--){const r=t.node(l);if(r.type.spec.tableRole==="cell"||r.type.spec.tableRole==="header_cell"){n=r;break}}for(let l=e.depth;l>0;l--){const r=e.node(l);if(r.type.spec.tableRole==="cell"||r.type.spec.tableRole==="header_cell"){o=r;break}}return n!==o&&e.parentOffset===0}function Fe(t,e,n){const o=(e||t).selection,l=(e||t).doc;let r,s;if(o instanceof m.NodeSelection&&(s=o.node.type.spec.tableRole)){if(s=="cell"||s=="header_cell")r=w.create(l,o.from);else if(s=="row"){const i=l.resolve(o.from+1);r=w.rowSelection(i,i)}else if(!n){const i=S.get(o.node),c=o.from+1,a=c+i.map[i.width*i.height-1];r=w.create(l,c+1,a)}}else o instanceof m.TextSelection&&We(o)?r=m.TextSelection.create(l,o.from):o instanceof m.TextSelection&&Pe(o)&&(r=m.TextSelection.create(l,o.$from.start(),o.$from.end()));return r&&(e||(e=t.tr)).setSelection(r),e}var Oe=new m.PluginKey("fix-tables");function Ae(t,e,n,o){const l=t.childCount,r=e.childCount;e:for(let s=0,i=0;s<r;s++){const c=e.child(s);for(let a=i,u=Math.min(l,s+3);a<u;a++)if(t.child(a)==c){i=a+1,n+=c.nodeSize;continue e}o(c,n),i<l&&t.child(i).sameMarkup(c)?Ae(t.child(i),c,n+1,o):c.nodesBetween(0,c.content.size,o,n+1),n+=c.nodeSize}}function xe(t,e){let n;const o=(l,r)=>{l.type.spec.tableRole=="table"&&(n=je(t,l,r,n))};return e?e.doc!=t.doc&&Ae(e.doc,t.doc,0,o):t.doc.descendants(o),n}function je(t,e,n,o){const l=S.get(e);if(!l.problems)return o;o||(o=t.tr);const r=[];for(let c=0;c<l.height;c++)r.push(0);for(let c=0;c<l.problems.length;c++){const a=l.problems[c];if(a.type=="collision"){const u=e.nodeAt(a.pos);if(!u)continue;const d=u.attrs;for(let f=0;f<d.rowspan;f++)r[a.row+f]+=a.n;o.setNodeMarkup(o.mapping.map(n+1+a.pos),null,L(d,d.colspan-a.n,a.n))}else if(a.type=="missing")r[a.row]+=a.n;else if(a.type=="overlong_rowspan"){const u=e.nodeAt(a.pos);if(!u)continue;o.setNodeMarkup(o.mapping.map(n+1+a.pos),null,{...u.attrs,rowspan:u.attrs.rowspan-a.n})}else if(a.type=="colwidth mismatch"){const u=e.nodeAt(a.pos);if(!u)continue;o.setNodeMarkup(o.mapping.map(n+1+a.pos),null,{...u.attrs,colwidth:a.colwidth})}else if(a.type=="zero_sized"){const u=o.mapping.map(n);o.delete(u,u+e.nodeSize)}}let s,i;for(let c=0;c<r.length;c++)r[c]&&(s==null&&(s=c),i=c);for(let c=0,a=n+1;c<l.height;c++){const u=e.child(c),d=a+u.nodeSize,f=r[c];if(f>0){let h="cell";u.firstChild&&(h=u.firstChild.type.spec.tableRole);const p=[];for(let b=0;b<f;b++){const C=y(t.schema)[h].createAndFill();C&&p.push(C)}const g=(c==0||s==c-1)&&i==c?a+1:d-1;o.insert(o.mapping.map(g),p)}a=d}return o.setMeta(Oe,{fixTables:!0})}function v(t){const e=t.selection,n=V(t),o=n.node(-1),l=n.start(-1),r=S.get(o);return{...e instanceof w?r.rectBetween(e.$anchorCell.pos-l,e.$headCell.pos-l):r.findCell(n.pos-l),tableStart:l,map:r,table:o}}function Te(t,{map:e,tableStart:n,table:o},l){let r=l>0?-1:0;Be(e,o,l+r)&&(r=l==0||l==e.width?null:0);for(let s=0;s<e.height;s++){const i=s*e.width+l;if(l>0&&l<e.width&&e.map[i-1]==e.map[i]){const c=e.map[i],a=o.nodeAt(c);t.setNodeMarkup(t.mapping.map(n+c),null,Se(a.attrs,l-e.colCount(c))),s+=a.attrs.rowspan-1}else{const c=r==null?y(o.type.schema).cell:o.nodeAt(e.map[i+r]).type,a=e.positionAt(s,l,o);t.insert(t.mapping.map(n+a),c.createAndFill())}}return t}function Ge(t,e){if(!M(t))return!1;if(e){const n=v(t);e(Te(t.tr,n,n.left))}return!0}function Ve(t,e){if(!M(t))return!1;if(e){const n=v(t);e(Te(t.tr,n,n.right))}return!0}function Ke(t,{map:e,table:n,tableStart:o},l){const r=t.mapping.maps.length;for(let s=0;s<e.height;){const i=s*e.width+l,c=e.map[i],a=n.nodeAt(c),u=a.attrs;if(l>0&&e.map[i-1]==c||l<e.width-1&&e.map[i+1]==c)t.setNodeMarkup(t.mapping.slice(r).map(o+c),null,L(u,l-e.colCount(c)));else{const d=t.mapping.slice(r).map(o+c);t.delete(d,d+a.nodeSize)}s+=u.rowspan}}function Xe(t,e){if(!M(t))return!1;if(e){const n=v(t),o=t.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let l=n.right-1;Ke(o,n,l),l!=n.left;l--){const r=n.tableStart?o.doc.nodeAt(n.tableStart-1):o.doc;if(!r)throw RangeError("No table found");n.table=r,n.map=S.get(r)}e(o)}return!0}function Ze(t,e,n){var o;const l=y(e.type.schema).header_cell;for(let r=0;r<t.width;r++)if(((o=e.nodeAt(t.map[r+n*t.width]))==null?void 0:o.type)!=l)return!1;return!0}function Re(t,{map:e,tableStart:n,table:o},l){var r;let s=n;for(let a=0;a<l;a++)s+=o.child(a).nodeSize;const i=[];let c=l>0?-1:0;Ze(e,o,l+c)&&(c=l==0||l==e.height?null:0);for(let a=0,u=e.width*l;a<e.width;a++,u++)if(l>0&&l<e.height&&e.map[u]==e.map[u-e.width]){const d=e.map[u],f=o.nodeAt(d).attrs;t.setNodeMarkup(n+d,null,{...f,rowspan:f.rowspan+1}),a+=f.colspan-1}else{const d=c==null?y(o.type.schema).cell:(r=o.nodeAt(e.map[u+c*e.width]))==null?void 0:r.type,f=d==null?void 0:d.createAndFill();f&&i.push(f)}return t.insert(s,y(o.type.schema).row.create(null,i)),t}function qe(t,e){if(!M(t))return!1;if(e){const n=v(t);e(Re(t.tr,n,n.top))}return!0}function Ue(t,e){if(!M(t))return!1;if(e){const n=v(t);e(Re(t.tr,n,n.bottom))}return!0}function Je(t,{map:e,table:n,tableStart:o},l){let r=0;for(let a=0;a<l;a++)r+=n.child(a).nodeSize;const s=r+n.child(l).nodeSize,i=t.mapping.maps.length;t.delete(r+o,s+o);const c=new Set;for(let a=0,u=l*e.width;a<e.width;a++,u++){const d=e.map[u];if(!c.has(d)){if(c.add(d),l>0&&d==e.map[u-e.width]){const f=n.nodeAt(d).attrs;t.setNodeMarkup(t.mapping.slice(i).map(d+o),null,{...f,rowspan:f.rowspan-1}),a+=f.colspan-1}else if(l<e.height&&d==e.map[u+e.width]){const f=n.nodeAt(d),h=f.attrs,p=f.type.create({...h,rowspan:f.attrs.rowspan-1},f.content),g=e.positionAt(l+1,a,n);t.insert(t.mapping.slice(i).map(o+g),p),a+=h.colspan-1}}}}function Ye(t,e){if(!M(t))return!1;if(e){const n=v(t),o=t.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let l=n.bottom-1;Je(o,n,l),l!=n.top;l--){const r=n.tableStart?o.doc.nodeAt(n.tableStart-1):o.doc;if(!r)throw RangeError("No table found");n.table=r,n.map=S.get(n.table)}e(o)}return!0}function ne(t){const e=t.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function Qe({width:t,height:e,map:n},o){let l=o.top*t+o.left,r=l,s=(o.bottom-1)*t+o.left,i=l+(o.right-o.left-1);for(let c=o.top;c<o.bottom;c++){if(o.left>0&&n[r]==n[r-1]||o.right<t&&n[i]==n[i+1])return!0;r+=t,i+=t}for(let c=o.left;c<o.right;c++){if(o.top>0&&n[l]==n[l-t]||o.bottom<e&&n[s]==n[s+t])return!0;l++,s++}return!1}function oe(t,e){const n=t.selection;if(!(n instanceof w)||n.$anchorCell.pos==n.$headCell.pos)return!1;const o=v(t),{map:l}=o;if(Qe(l,o))return!1;if(e){const r=t.tr,s={};let i=m.Fragment.empty,c,a;for(let u=o.top;u<o.bottom;u++)for(let d=o.left;d<o.right;d++){const f=l.map[u*l.width+d],h=o.table.nodeAt(f);if(!(s[f]||!h))if(s[f]=!0,c==null)c=f,a=h;else{ne(h)||(i=i.append(h.content));const p=r.mapping.map(f+o.tableStart);r.delete(p,p+h.nodeSize)}}if(c==null||a==null)return!0;if(r.setNodeMarkup(c+o.tableStart,null,{...Se(a.attrs,a.attrs.colspan,o.right-o.left-a.attrs.colspan),rowspan:o.bottom-o.top}),i.size){const u=c+1+a.content.size,d=ne(a)?c+1:u;r.replaceWith(d+o.tableStart,u+o.tableStart,i)}r.setSelection(new w(r.doc.resolve(c+o.tableStart))),e(r)}return!0}function le(t,e){const n=y(t.schema);return et(({node:o})=>n[o.type.spec.tableRole])(t,e)}function et(t){return(e,n)=>{var o;const l=e.selection;let r,s;if(l instanceof w){if(l.$anchorCell.pos!=l.$headCell.pos)return!1;r=l.$anchorCell.nodeAfter,s=l.$anchorCell.pos}else{if(r=_e(l.$from),!r)return!1;s=(o=_(l.$from))==null?void 0:o.pos}if(r==null||s==null||r.attrs.colspan==1&&r.attrs.rowspan==1)return!1;if(n){let i=r.attrs;const c=[],a=i.colwidth;i.rowspan>1&&(i={...i,rowspan:1}),i.colspan>1&&(i={...i,colspan:1});const u=v(e),d=e.tr;for(let h=0;h<u.right-u.left;h++)c.push(a?{...i,colwidth:a&&a[h]?[a[h]]:null}:i);let f;for(let h=u.top;h<u.bottom;h++){let p=u.map.positionAt(h,u.left,u.table);h==u.top&&(p+=r.nodeSize);for(let g=u.left,b=0;g<u.right;g++,b++)g==u.left&&h==u.top||d.insert(f=d.mapping.map(p+u.tableStart,1),t({node:r,row:h,col:g}).createAndFill(c[b]))}d.setNodeMarkup(s,t({node:r,row:u.top,col:u.left}),c[0]),l instanceof w&&d.setSelection(new w(d.doc.resolve(l.$anchorCell.pos),f?d.doc.resolve(f):void 0)),n(d)}return!0}}function tt(t,e){return function(n,o){if(!M(n))return!1;const l=V(n);if(l.nodeAfter.attrs[t]===e)return!1;if(o){const r=n.tr;n.selection instanceof w?n.selection.forEachCell((s,i)=>{s.attrs[t]!==e&&r.setNodeMarkup(i,null,{...s.attrs,[t]:e})}):r.setNodeMarkup(l.pos,null,{...l.nodeAfter.attrs,[t]:e}),o(r)}return!0}}function nt(t){return function(e,n){if(!M(e))return!1;if(n){const o=y(e.schema),l=v(e),r=e.tr,s=l.map.cellsInRect(t=="column"?{left:l.left,top:0,right:l.right,bottom:l.map.height}:t=="row"?{left:0,top:l.top,right:l.map.width,bottom:l.bottom}:l),i=s.map(c=>l.table.nodeAt(c));for(let c=0;c<s.length;c++)i[c].type==o.header_cell&&r.setNodeMarkup(l.tableStart+s[c],o.cell,i[c].attrs);if(r.steps.length==0)for(let c=0;c<s.length;c++)r.setNodeMarkup(l.tableStart+s[c],o.header_cell,i[c].attrs);n(r)}return!0}}function re(t,e,n){const o=e.map.cellsInRect({left:0,top:0,right:t=="row"?e.map.width:1,bottom:t=="column"?e.map.height:1});for(let l=0;l<o.length;l++){const r=e.table.nodeAt(o[l]);if(r&&r.type!==n.header_cell)return!1}return!0}function B(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?nt(t):function(n,o){if(!M(n))return!1;if(o){const l=y(n.schema),r=v(n),s=n.tr,i=re("row",r,l),c=re("column",r,l),u=(t==="column"?i:t==="row"?c:!1)?1:0,d=t=="column"?{left:0,top:u,right:1,bottom:r.map.height}:t=="row"?{left:u,top:0,right:r.map.width,bottom:1}:r,f=t=="column"?c?l.cell:l.header_cell:t=="row"?i?l.cell:l.header_cell:l.cell;r.map.cellsInRect(d).forEach(h=>{const p=h+r.tableStart,g=s.doc.nodeAt(p);g&&s.setNodeMarkup(p,f,g.attrs)}),o(s)}return!0}}B("row",{useDeprecatedLogic:!0});B("column",{useDeprecatedLogic:!0});var ot=B("cell",{useDeprecatedLogic:!0});function lt(t,e){if(e<0){const n=t.nodeBefore;if(n)return t.pos-n.nodeSize;for(let o=t.index(-1)-1,l=t.before();o>=0;o--){const r=t.node(-1).child(o),s=r.lastChild;if(s)return l-1-s.nodeSize;l-=r.nodeSize}}else{if(t.index()<t.parent.childCount-1)return t.pos+t.nodeAfter.nodeSize;const n=t.node(-1);for(let o=t.indexAfter(-1),l=t.after();o<n.childCount;o++){const r=n.child(o);if(r.childCount)return l+1;l+=r.nodeSize}}return null}function se(t){return function(e,n){if(!M(e))return!1;const o=lt(V(e),t);if(o==null)return!1;if(n){const l=e.doc.resolve(o);n(e.tr.setSelection(m.TextSelection.between(l,He(l))).scrollIntoView())}return!0}}function rt(t,e){const n=t.selection.$anchor;for(let o=n.depth;o>0;o--)if(n.node(o).type.spec.tableRole=="table")return e&&e(t.tr.delete(n.before(o),n.after(o)).scrollIntoView()),!0;return!1}function $(t,e){const n=t.selection;if(!(n instanceof w))return!1;if(e){const o=t.tr,l=y(t.schema).cell.createAndFill().content;n.forEachCell((r,s)=>{r.content.eq(l)||o.replace(o.mapping.map(s+1),o.mapping.map(s+r.nodeSize-1),new m.Slice(l,0,0))}),o.docChanged&&e(o)}return!0}function st(t){if(!t.size)return null;let{content:e,openStart:n,openEnd:o}=t;for(;e.childCount==1&&(n>0&&o>0||e.child(0).type.spec.tableRole=="table");)n--,o--,e=e.child(0).content;const l=e.child(0),r=l.type.spec.tableRole,s=l.type.schema,i=[];if(r=="row")for(let c=0;c<e.childCount;c++){let a=e.child(c).content;const u=c?0:Math.max(0,n-1),d=c<e.childCount-1?0:Math.max(0,o-1);(u||d)&&(a=Y(y(s).row,new m.Slice(a,u,d)).content),i.push(a)}else if(r=="cell"||r=="header_cell")i.push(n||o?Y(y(s).row,new m.Slice(e,n,o)).content:e);else return null;return it(s,i)}function it(t,e){const n=[];for(let l=0;l<e.length;l++){const r=e[l];for(let s=r.childCount-1;s>=0;s--){const{rowspan:i,colspan:c}=r.child(s).attrs;for(let a=l;a<l+i;a++)n[a]=(n[a]||0)+c}}let o=0;for(let l=0;l<n.length;l++)o=Math.max(o,n[l]);for(let l=0;l<n.length;l++)if(l>=e.length&&e.push(m.Fragment.empty),n[l]<o){const r=y(t).cell.createAndFill(),s=[];for(let i=n[l];i<o;i++)s.push(r);e[l]=e[l].append(m.Fragment.from(s))}return{height:e.length,width:o,rows:e}}function Y(t,e){const n=t.createAndFill();return new m.Transform(n).replace(0,n.content.size,e).doc}function ct({width:t,height:e,rows:n},o,l){if(t!=o){const r=[],s=[];for(let i=0;i<n.length;i++){const c=n[i],a=[];for(let u=r[i]||0,d=0;u<o;d++){let f=c.child(d%c.childCount);u+f.attrs.colspan>o&&(f=f.type.createChecked(L(f.attrs,f.attrs.colspan,u+f.attrs.colspan-o),f.content)),a.push(f),u+=f.attrs.colspan;for(let h=1;h<f.attrs.rowspan;h++)r[i+h]=(r[i+h]||0)+f.attrs.colspan}s.push(m.Fragment.from(a))}n=s,t=o}if(e!=l){const r=[];for(let s=0,i=0;s<l;s++,i++){const c=[],a=n[i%e];for(let u=0;u<a.childCount;u++){let d=a.child(u);s+d.attrs.rowspan>l&&(d=d.type.create({...d.attrs,rowspan:Math.max(1,l-d.attrs.rowspan)},d.content)),c.push(d)}r.push(m.Fragment.from(c))}n=r,e=l}return{width:t,height:e,rows:n}}function at(t,e,n,o,l,r,s){const i=t.doc.type.schema,c=y(i);let a,u;if(l>e.width)for(let d=0,f=0;d<e.height;d++){const h=n.child(d);f+=h.nodeSize;const p=[];let g;h.lastChild==null||h.lastChild.type==c.cell?g=a||(a=c.cell.createAndFill()):g=u||(u=c.header_cell.createAndFill());for(let b=e.width;b<l;b++)p.push(g);t.insert(t.mapping.slice(s).map(f-1+o),p)}if(r>e.height){const d=[];for(let p=0,g=(e.height-1)*e.width;p<Math.max(e.width,l);p++){const b=p>=e.width?!1:n.nodeAt(e.map[g+p]).type==c.header_cell;d.push(b?u||(u=c.header_cell.createAndFill()):a||(a=c.cell.createAndFill()))}const f=c.row.create(null,m.Fragment.from(d)),h=[];for(let p=e.height;p<r;p++)h.push(f);t.insert(t.mapping.slice(s).map(o+n.nodeSize-2),h)}return!!(a||u)}function ie(t,e,n,o,l,r,s,i){if(s==0||s==e.height)return!1;let c=!1;for(let a=l;a<r;a++){const u=s*e.width+a,d=e.map[u];if(e.map[u-e.width]==d){c=!0;const f=n.nodeAt(d),{top:h,left:p}=e.findCell(d);t.setNodeMarkup(t.mapping.slice(i).map(d+o),null,{...f.attrs,rowspan:s-h}),t.insert(t.mapping.slice(i).map(e.positionAt(s,p,n)),f.type.createAndFill({...f.attrs,rowspan:h+f.attrs.rowspan-s})),a+=f.attrs.colspan-1}}return c}function ce(t,e,n,o,l,r,s,i){if(s==0||s==e.width)return!1;let c=!1;for(let a=l;a<r;a++){const u=a*e.width+s,d=e.map[u];if(e.map[u-1]==d){c=!0;const f=n.nodeAt(d),h=e.colCount(d),p=t.mapping.slice(i).map(d+o);t.setNodeMarkup(p,null,L(f.attrs,s-h,f.attrs.colspan-(s-h))),t.insert(p+f.nodeSize,f.type.createAndFill(L(f.attrs,0,s-h))),a+=f.attrs.rowspan-1}}return c}function ae(t,e,n,o,l){let r=n?t.doc.nodeAt(n-1):t.doc;if(!r)throw new Error("No table found");let s=S.get(r);const{top:i,left:c}=o,a=c+l.width,u=i+l.height,d=t.tr;let f=0;function h(){if(r=n?d.doc.nodeAt(n-1):d.doc,!r)throw new Error("No table found");s=S.get(r),f=d.mapping.maps.length}at(d,s,r,n,a,u,f)&&h(),ie(d,s,r,n,c,a,i,f)&&h(),ie(d,s,r,n,c,a,u,f)&&h(),ce(d,s,r,n,i,u,c,f)&&h(),ce(d,s,r,n,i,u,a,f)&&h();for(let p=i;p<u;p++){const g=s.positionAt(p,c,r),b=s.positionAt(p,a,r);d.replace(d.mapping.slice(f).map(g+n),d.mapping.slice(f).map(b+n),new m.Slice(l.rows[p-i],0,0))}h(),d.setSelection(new w(d.doc.resolve(n+s.positionAt(i,c,r)),d.doc.resolve(n+s.positionAt(u-1,a-1,r)))),e(d)}var dt=m.keydownHandler({ArrowLeft:W("horiz",-1),ArrowRight:W("horiz",1),ArrowUp:W("vert",-1),ArrowDown:W("vert",1),"Shift-ArrowLeft":P("horiz",-1),"Shift-ArrowRight":P("horiz",1),"Shift-ArrowUp":P("vert",-1),"Shift-ArrowDown":P("vert",1),Backspace:$,"Mod-Backspace":$,Delete:$,"Mod-Delete":$});function j(t,e,n){return n.eq(t.selection)?!1:(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function W(t,e){return(n,o,l)=>{if(!l)return!1;const r=n.selection;if(r instanceof w)return j(n,o,m.Selection.near(r.$headCell,e));if(t!="horiz"&&!r.empty)return!1;const s=Me(l,t,e);if(s==null)return!1;if(t=="horiz")return j(n,o,m.Selection.near(n.doc.resolve(r.head+e),e));{const i=n.doc.resolve(s),c=Ce(i,t,e);let a;return c?a=m.Selection.near(c,1):e<0?a=m.Selection.near(n.doc.resolve(i.before(-1)),-1):a=m.Selection.near(n.doc.resolve(i.after(-1)),1),j(n,o,a)}}}function P(t,e){return(n,o,l)=>{if(!l)return!1;const r=n.selection;let s;if(r instanceof w)s=r;else{const c=Me(l,t,e);if(c==null)return!1;s=new w(n.doc.resolve(c))}const i=Ce(s.$headCell,t,e);return i?j(n,o,new w(s.$anchorCell,i)):!1}}function ut(t,e){const n=t.state.doc,o=_(n.resolve(e));return o?(t.dispatch(t.state.tr.setSelection(new w(o))),!0):!1}function ft(t,e,n){if(!M(t.state))return!1;let o=st(n);const l=t.state.selection;if(l instanceof w){o||(o={width:1,height:1,rows:[m.Fragment.from(Y(y(t.state.schema).cell,n))]});const r=l.$anchorCell.node(-1),s=l.$anchorCell.start(-1),i=S.get(r).rectBetween(l.$anchorCell.pos-s,l.$headCell.pos-s);return o=ct(o,i.right-i.left,i.bottom-i.top),ae(t.state,t.dispatch,s,i,o),!0}else if(o){const r=V(t.state),s=r.start(-1);return ae(t.state,t.dispatch,s,S.get(r.node(-1)).findCell(r.pos-s),o),!0}else return!1}function ht(t,e){var n;if(e.ctrlKey||e.metaKey)return;const o=de(t,e.target);let l;if(e.shiftKey&&t.state.selection instanceof w)r(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&o&&(l=_(t.state.selection.$anchor))!=null&&((n=Z(t,e))==null?void 0:n.pos)!=l.pos)r(l,e),e.preventDefault();else if(!o)return;function r(c,a){let u=Z(t,a);const d=k.getState(t.state)==null;if(!u||!te(c,u))if(d)u=c;else return;const f=new w(c,u);if(d||!t.state.selection.eq(f)){const h=t.state.tr.setSelection(f);d&&h.setMeta(k,c.pos),t.dispatch(h)}}function s(){t.root.removeEventListener("mouseup",s),t.root.removeEventListener("dragstart",s),t.root.removeEventListener("mousemove",i),k.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(k,-1))}function i(c){const a=c,u=k.getState(t.state);let d;if(u!=null)d=t.state.doc.resolve(u);else if(de(t,a.target)!=o&&(d=Z(t,e),!d))return s();d&&r(d,a)}t.root.addEventListener("mouseup",s),t.root.addEventListener("dragstart",s),t.root.addEventListener("mousemove",i)}function Me(t,e,n){if(!(t.state.selection instanceof m.TextSelection))return null;const{$head:o}=t.state.selection;for(let l=o.depth-1;l>=0;l--){const r=o.node(l);if((n<0?o.index(l):o.indexAfter(l))!=(n<0?0:r.childCount))return null;if(r.type.spec.tableRole=="cell"||r.type.spec.tableRole=="header_cell"){const i=o.before(l),c=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(c)?i:null}}return null}function de(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Z(t,e){const n=t.posAtCoords({left:e.clientX,top:e.clientY});return n&&n?_(t.state.doc.resolve(n.pos)):null}var pt=class{constructor(e,n){this.node=e,this.defaultCellMinWidth=n,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${n}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Q(e,this.colgroup,this.table,n),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,Q(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function Q(t,e,n,o,l,r){var s;let i=0,c=!0,a=e.firstChild;const u=t.firstChild;if(u){for(let d=0,f=0;d<u.childCount;d++){const{colspan:h,colwidth:p}=u.child(d).attrs;for(let g=0;g<h;g++,f++){const b=l==f?r:p&&p[g],C=b?b+"px":"";if(i+=b||o,b||(c=!1),a)a.style.width!=C&&(a.style.width=C),a=a.nextSibling;else{const x=document.createElement("col");x.style.width=C,e.appendChild(x)}}}for(;a;){const d=a.nextSibling;(s=a.parentNode)==null||s.removeChild(a),a=d}c?(n.style.width=i+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=i+"px")}}var A=new m.PluginKey("tableColumnResizing");function mt({handleWidth:t=5,cellMinWidth:e=25,defaultCellMinWidth:n=100,View:o=pt,lastColumnResizable:l=!0}={}){const r=new m.Plugin({key:A,state:{init(s,i){var c,a;const u=(a=(c=r.spec)==null?void 0:c.props)==null?void 0:a.nodeViews,d=y(i.schema).table.name;return o&&u&&(u[d]=(f,h)=>new o(f,n,h)),new gt(-1,!1)},apply(s,i){return i.apply(s)}},props:{attributes:s=>{const i=A.getState(s);return i&&i.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(s,i)=>{bt(s,i,t,l)},mouseleave:s=>{wt(s)},mousedown:(s,i)=>{Ct(s,i,e,n)}},decorations:s=>{const i=A.getState(s);if(i&&i.activeHandle>-1)return Tt(s,i.activeHandle)},nodeViews:{}}});return r}var gt=class G{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){const n=this,o=e.getMeta(A);if(o&&o.setHandle!=null)return new G(o.setHandle,!1);if(o&&o.setDragging!==void 0)return new G(n.activeHandle,o.setDragging);if(n.activeHandle>-1&&e.docChanged){let l=e.mapping.map(n.activeHandle,-1);return J(e.doc.resolve(l))||(l=-1),new G(l,n.dragging)}return n}};function bt(t,e,n,o){if(!t.editable)return;const l=A.getState(t.state);if(l&&!l.dragging){const r=yt(e.target);let s=-1;if(r){const{left:i,right:c}=r.getBoundingClientRect();e.clientX-i<=n?s=ue(t,e,"left",n):c-e.clientX<=n&&(s=ue(t,e,"right",n))}if(s!=l.activeHandle){if(!o&&s!==-1){const i=t.state.doc.resolve(s),c=i.node(-1),a=S.get(c),u=i.start(-1);if(a.colCount(i.pos-u)+i.nodeAfter.attrs.colspan-1==a.width-1)return}ve(t,s)}}}function wt(t){if(!t.editable)return;const e=A.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&ve(t,-1)}function Ct(t,e,n,o){var l;if(!t.editable)return!1;const r=(l=t.dom.ownerDocument.defaultView)!=null?l:window,s=A.getState(t.state);if(!s||s.activeHandle==-1||s.dragging)return!1;const i=t.state.doc.nodeAt(s.activeHandle),c=St(t,s.activeHandle,i.attrs);t.dispatch(t.state.tr.setMeta(A,{setDragging:{startX:e.clientX,startWidth:c}}));function a(d){r.removeEventListener("mouseup",a),r.removeEventListener("mousemove",u);const f=A.getState(t.state);f!=null&&f.dragging&&(At(t,f.activeHandle,fe(f.dragging,d,n)),t.dispatch(t.state.tr.setMeta(A,{setDragging:null})))}function u(d){if(!d.which)return a(d);const f=A.getState(t.state);if(f&&f.dragging){const h=fe(f.dragging,d,n);he(t,f.activeHandle,h,o)}}return he(t,s.activeHandle,c,o),r.addEventListener("mouseup",a),r.addEventListener("mousemove",u),e.preventDefault(),!0}function St(t,e,{colspan:n,colwidth:o}){const l=o&&o[o.length-1];if(l)return l;const r=t.domAtPos(e);let i=r.node.childNodes[r.offset].offsetWidth,c=n;if(o)for(let a=0;a<n;a++)o[a]&&(i-=o[a],c--);return i/c}function yt(t){for(;t&&t.nodeName!="TD"&&t.nodeName!="TH";)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}function ue(t,e,n,o){const l=n=="right"?-o:o,r=t.posAtCoords({left:e.clientX+l,top:e.clientY});if(!r)return-1;const{pos:s}=r,i=_(t.state.doc.resolve(s));if(!i)return-1;if(n=="right")return i.pos;const c=S.get(i.node(-1)),a=i.start(-1),u=c.map.indexOf(i.pos-a);return u%c.width==0?-1:a+c.map[u-1]}function fe(t,e,n){const o=e.clientX-t.startX;return Math.max(n,t.startWidth+o)}function ve(t,e){t.dispatch(t.state.tr.setMeta(A,{setHandle:e}))}function At(t,e,n){const o=t.state.doc.resolve(e),l=o.node(-1),r=S.get(l),s=o.start(-1),i=r.colCount(o.pos-s)+o.nodeAfter.attrs.colspan-1,c=t.state.tr;for(let a=0;a<r.height;a++){const u=a*r.width+i;if(a&&r.map[u]==r.map[u-r.width])continue;const d=r.map[u],f=l.nodeAt(d).attrs,h=f.colspan==1?0:i-r.colCount(d);if(f.colwidth&&f.colwidth[h]==n)continue;const p=f.colwidth?f.colwidth.slice():xt(f.colspan);p[h]=n,c.setNodeMarkup(s+d,null,{...f,colwidth:p})}c.docChanged&&t.dispatch(c)}function he(t,e,n,o){const l=t.state.doc.resolve(e),r=l.node(-1),s=l.start(-1),i=S.get(r).colCount(l.pos-s)+l.nodeAfter.attrs.colspan-1;let c=t.domAtPos(l.start(-1)).node;for(;c&&c.nodeName!="TABLE";)c=c.parentNode;c&&Q(r,c.firstChild,c,o,i,n)}function xt(t){return Array(t).fill(0)}function Tt(t,e){var n;const o=[],l=t.doc.resolve(e),r=l.node(-1);if(!r)return m.DecorationSet.empty;const s=S.get(r),i=l.start(-1),c=s.colCount(l.pos-i)+l.nodeAfter.attrs.colspan-1;for(let a=0;a<s.height;a++){const u=c+a*s.width;if((c==s.width-1||s.map[u]!=s.map[u+1])&&(a==0||s.map[u]!=s.map[u-s.width])){const d=s.map[u],f=i+d+r.nodeAt(d).nodeSize-1,h=document.createElement("div");h.className="column-resize-handle",(n=A.getState(t))!=null&&n.dragging&&o.push(m.Decoration.node(i+d,i+d+r.nodeAt(d).nodeSize,{class:"column-resize-dragging"})),o.push(m.Decoration.widget(f,h))}}return m.DecorationSet.create(t.doc,o)}function Rt({allowTableNodeSelection:t=!1}={}){return new m.Plugin({key:k,state:{init(){return null},apply(e,n){const o=e.getMeta(k);if(o!=null)return o==-1?null:o;if(n==null||!e.docChanged)return n;const{deleted:l,pos:r}=e.mapping.mapResult(n);return l?null:r}},props:{decorations:$e,handleDOMEvents:{mousedown:ht},createSelectionBetween(e){return k.getState(e.state)!=null?e.state.selection:null},handleTripleClick:ut,handleKeyDown:dt,handlePaste:ft},appendTransaction(e,n,o){return Fe(o,xe(o,n),t)}})}function ee(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function pe(t,e,n,o,l,r){var s;let i=0,c=!0,a=e.firstChild;const u=t.firstChild;if(u!==null)for(let d=0,f=0;d<u.childCount;d+=1){const{colspan:h,colwidth:p}=u.child(d).attrs;for(let g=0;g<h;g+=1,f+=1){const b=l===f?r:p&&p[g],C=b?`${b}px`:"";if(i+=b||o,b||(c=!1),a){if(a.style.width!==C){const[x,E]=ee(o,b);a.style.setProperty(x,E)}a=a.nextSibling}else{const x=document.createElement("col"),[E,D]=ee(o,b);x.style.setProperty(E,D),e.appendChild(x)}}}for(;a;){const d=a.nextSibling;(s=a.parentNode)===null||s===void 0||s.removeChild(a),a=d}c?(n.style.width=`${i}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${i}px`)}class Mt{constructor(e,n){this.node=e,this.cellMinWidth=n,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),pe(e,this.colgroup,this.table,n),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!==this.node.type?!1:(this.node=e,pe(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return e.type==="attributes"&&(e.target===this.table||this.colgroup.contains(e.target))}}function vt(t,e,n,o){let l=0,r=!0;const s=[],i=t.firstChild;if(!i)return{};for(let d=0,f=0;d<i.childCount;d+=1){const{colspan:h,colwidth:p}=i.child(d).attrs;for(let g=0;g<h;g+=1,f+=1){const b=n===f?o:p&&p[g];l+=b||e,b||(r=!1);const[C,x]=ee(e,b);s.push(["col",{style:`${C}: ${x}`}])}}const c=r?`${l}px`:"",a=r?"":`${l}px`;return{colgroup:["colgroup",{},...s],tableWidth:c,tableMinWidth:a}}function me(t,e){return t.createAndFill()}function Et(t){if(t.cached.tableNodeTypes)return t.cached.tableNodeTypes;const e={};return Object.keys(t.nodes).forEach(n=>{const o=t.nodes[n];o.spec.tableRole&&(e[o.spec.tableRole]=o)}),t.cached.tableNodeTypes=e,e}function Nt(t,e,n,o,l){const r=Et(t),s=[],i=[];for(let a=0;a<n;a+=1){const u=me(r.cell);if(u&&i.push(u),o){const d=me(r.header_cell);d&&s.push(d)}}const c=[];for(let a=0;a<e;a+=1)c.push(r.row.createChecked(null,o&&a===0?s:i));return r.table.createChecked(null,c)}function kt(t){return t instanceof w}const F=({editor:t})=>{const{selection:e}=t.state;if(!kt(e))return!1;let n=0;const o=m.findParentNodeClosestToPos(e.ranges[0].$from,r=>r.type.name==="table");return o==null||o.node.descendants(r=>{if(r.type.name==="table")return!1;["tableCell","tableHeader"].includes(r.type.name)&&(n+=1)}),n===e.ranges.length?(t.commands.deleteTable(),!0):!1},zt=m.Node.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,handleWidth:5,cellMinWidth:25,View:Mt,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:t,HTMLAttributes:e}){const{colgroup:n,tableWidth:o,tableMinWidth:l}=vt(t,this.options.cellMinWidth);return["table",m.mergeAttributes(this.options.HTMLAttributes,e,{style:o?`width: ${o}`:`min-width: ${l}`}),n,["tbody",0]]},addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:o,dispatch:l,editor:r})=>{const s=Nt(r.schema,t,e,n);if(l){const i=o.selection.from+1;o.replaceSelectionWith(s).scrollIntoView().setSelection(m.TextSelection.near(o.doc.resolve(i)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>Ge(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>Ve(t,e),deleteColumn:()=>({state:t,dispatch:e})=>Xe(t,e),addRowBefore:()=>({state:t,dispatch:e})=>qe(t,e),addRowAfter:()=>({state:t,dispatch:e})=>Ue(t,e),deleteRow:()=>({state:t,dispatch:e})=>Ye(t,e),deleteTable:()=>({state:t,dispatch:e})=>rt(t,e),mergeCells:()=>({state:t,dispatch:e})=>oe(t,e),splitCell:()=>({state:t,dispatch:e})=>le(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>B("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>B("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>ot(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>oe(t,e)?!0:le(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:o})=>tt(t,e)(n,o),goToNextCell:()=>({state:t,dispatch:e})=>se(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>se(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&xe(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){const o=w.create(e.doc,t.anchorCell,t.headCell);e.setSelection(o)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:F,"Mod-Backspace":F,Delete:F,"Mod-Delete":F}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[mt({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],Rt({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){const e={name:t.name,options:t.options,storage:t.storage};return{tableRole:m.callOrReturn(m.getExtensionField(t,"tableRole",e))}}}),Lt=m.Node.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?e.split(",").map(o=>parseInt(o,10)):null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:t}){return["th",m.mergeAttributes(this.options.HTMLAttributes,t),0]}}),_t=/(android|bb\d+|meego).+mobile|armv7l|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series[46]0|samsungbrowser.*mobile|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i,Dt=/CrOS/,Ht=/android|ipad|playbook|silk/i;function ge(t={}){let e=t.ua||typeof navigator<"u"&&navigator.userAgent;return e&&typeof e=="object"&&e.headers&&typeof e.headers["user-agent"]=="string"&&(e=e.headers["user-agent"]),typeof e!="string"?!1:!!(_t.test(e)&&!Dt.test(e)||t.tablet&&Ht.test(e)||t.tablet&&t.featureDetect&&navigator&&navigator.maxTouchPoints>1&&e.includes("Macintosh")&&e.includes("Safari"))}const be=t=>Array.from({length:t}).map((e,n)=>n+1);function Bt(t){var u;const[e,n]=X.useState(!0),[o,l]=X.useState({rows:ge()?T.TABLE_MAX_GRID_SIZE:T.TABLE_INIT_GRID_SIZE,cols:ge()?T.TABLE_MAX_GRID_SIZE:T.TABLE_INIT_GRID_SIZE}),[r,s]=X.useState({rows:T.TABLE_DEFAULT_SELECTED_GRID_SIZE,cols:T.TABLE_DEFAULT_SELECTED_GRID_SIZE});function i(d,f){d===o.rows&&l(h=>({...h,rows:Math.min(d+1,T.TABLE_MAX_GRID_SIZE)})),f===o.cols&&l(h=>({...h,cols:Math.min(f+1,T.TABLE_MAX_GRID_SIZE)})),s({rows:d,cols:f})}function c(d,f){t==null||t.createTable({rows:d,cols:f,withHeaderRow:e}),a()}function a(){n(!1),l({rows:T.TABLE_INIT_GRID_SIZE,cols:T.TABLE_INIT_GRID_SIZE}),s({rows:T.TABLE_DEFAULT_SELECTED_GRID_SIZE,cols:T.TABLE_DEFAULT_SELECTED_GRID_SIZE})}return R.jsxs(O.Popover,{modal:!0,children:[R.jsx(O.PopoverTrigger,{asChild:!0,children:t==null?void 0:t.children}),R.jsx(O.PopoverContent,{align:"start",className:"richtext-w-full !richtext-p-2",side:"bottom",children:R.jsxs("div",{className:"table-grid-size-editor richtext-p-0",children:[R.jsx("div",{className:"richtext-flex richtext-flex-col richtext-flex-wrap richtext-justify-between richtext-gap-1",children:(u=be(o==null?void 0:o.rows))==null?void 0:u.map(d=>{var f;return R.jsx("div",{className:"richtext-flex richtext-gap-1",children:(f=be(o==null?void 0:o.cols))==null?void 0:f.map(h=>R.jsx("div",{onMouseDown:()=>c(d,h),onMouseOver:()=>i(d,h),className:`richtext-cursor-pointer richtext-border-border ${h<=r.cols&&d<=r.rows&&"tableCellActive !richtext-bg-foreground"}`,children:R.jsx("div",{className:"richtext-box-border richtext-size-4 richtext-rounded-[2px] !richtext-border richtext-border-solid !richtext-border-border richtext-p-1"})},`c-${h}`))},`r-${d}`)})}),R.jsxs("div",{className:"richtext-mt-2 richtext-text-center richtext-text-sm richtext-text-zinc-600",children:[r.rows," ","x",r.cols]})]})})]})}function It(t){function e(n){t.disabled||t.editor.chain().focus().insertTable({...n,withHeaderRow:!1}).run()}return R.jsx(Bt,{createTable:e,children:R.jsx(O.ActionButton,{icon:t==null?void 0:t.icon,tooltip:t==null?void 0:t.tooltip,disabled:t==null?void 0:t.disabled,color:t==null?void 0:t.color,action:t==null?void 0:t.action,isActive:t==null?void 0:t.isActive})})}function $t(t,e,n){if(!t.doc)return t;const o=t.doc.nodeAt(e);if(!o||n===o.attrs.backgroundColor)return t;const l={...o.attrs,backgroundColor:n};return t.setNodeMarkup(e,o.type,l,o.marks)}function Wt(t,e,n){const{doc:o,selection:l}=t;return!o||!l||!(l instanceof w)||l.forEachCell((r,s)=>{t=$t(t,s,n)}),t}function we(t,e){return({tr:n,state:o,dispatch:l})=>{const{selection:r}=o;return n=n.setSelection(r),n=Wt(n,e,t),n.docChanged?(l==null||l(n),!0):!1}}const Pt=m.Extension.create({name:"tableCellBackground",addOptions(){return{types:["tableCell"],HTMLAttributes:{}}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{parseHTML:t=>t.style.backgroundColor||"",renderHTML:t=>!t.backgroundColor||t.backgroundColor===""?{}:{style:`background-color: ${t.backgroundColor}`}}}}]},addCommands(){return{setTableCellBackground:t=>we(t,this.options),unsetTableCellBackground:()=>we("",this.options)}}}),Ft=m.Node.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",m.mergeAttributes(this.options.HTMLAttributes,t),0]}}),Ot=Ft.extend({addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),HTMLAttributes:{style:"border-bottom: 1px solid #000;"}}}}),jt=m.Node.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?e.split(",").map(o=>parseInt(o,10)):null}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:t}){return["td",m.mergeAttributes(this.options.HTMLAttributes,t),0]}}),Gt=jt.extend({addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),HTMLAttributes:{style:`
2
2
  border-right: 1px solid #000;
3
3
  padding: 8px 12px;
4
4
  &:last-child {
package/lib/Table.d.cts CHANGED
@@ -70,6 +70,8 @@ declare interface GeneralOptions<T> {
70
70
  button: ButtonView<T>;
71
71
  /** Show on Toolbar */
72
72
  toolbar?: boolean;
73
+ /** Shortcut keys override */
74
+ shortcutKeys?: string[] | string[][];
73
75
  }
74
76
 
75
77
  declare const Table: Node_2<TableOptions, any>;
@@ -155,8 +157,8 @@ declare module '@tiptap/core' {
155
157
 
156
158
  declare module '@tiptap/core' {
157
159
  interface Commands<ReturnType> {
158
- excalidraw: {
159
- setExcalidraw: (attrs?: IExcalidrawAttrs) => ReturnType;
160
+ exportPdf: {
161
+ exportToPdf: () => ReturnType;
160
162
  };
161
163
  }
162
164
  }
@@ -164,8 +166,8 @@ declare module '@tiptap/core' {
164
166
 
165
167
  declare module '@tiptap/core' {
166
168
  interface Commands<ReturnType> {
167
- exportPdf: {
168
- exportToPdf: () => ReturnType;
169
+ excalidraw: {
170
+ setExcalidraw: (attrs?: IExcalidrawAttrs) => ReturnType;
169
171
  };
170
172
  }
171
173
  }
package/lib/Table.d.ts CHANGED
@@ -70,6 +70,8 @@ declare interface GeneralOptions<T> {
70
70
  button: ButtonView<T>;
71
71
  /** Show on Toolbar */
72
72
  toolbar?: boolean;
73
+ /** Shortcut keys override */
74
+ shortcutKeys?: string[] | string[][];
73
75
  }
74
76
 
75
77
  declare const Table: Node_2<TableOptions, any>;
@@ -155,8 +157,8 @@ declare module '@tiptap/core' {
155
157
 
156
158
  declare module '@tiptap/core' {
157
159
  interface Commands<ReturnType> {
158
- excalidraw: {
159
- setExcalidraw: (attrs?: IExcalidrawAttrs) => ReturnType;
160
+ exportPdf: {
161
+ exportToPdf: () => ReturnType;
160
162
  };
161
163
  }
162
164
  }
@@ -164,8 +166,8 @@ declare module '@tiptap/core' {
164
166
 
165
167
  declare module '@tiptap/core' {
166
168
  interface Commands<ReturnType> {
167
- exportPdf: {
168
- exportToPdf: () => ReturnType;
169
+ excalidraw: {
170
+ setExcalidraw: (attrs?: IExcalidrawAttrs) => ReturnType;
169
171
  };
170
172
  }
171
173
  }
package/lib/Table.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { a as de, v as N, u as Pe, T as E, B as Oe, F as T, S as H, P as ke, D as ne, b as oe, g as Ie, C as Fe, N as U, x as je, y as Ve, m as J, G as Ke, E as Xe } from "./index-DI9T3iLd.js";
2
2
  import { jsxs as Q, jsx as k } from "react/jsx-runtime";
3
- import { P as Ge, m as qe, n as Ue, A as Je } from "./RichTextEditor-BJWhWz4z.js";
3
+ import { P as Ge, m as qe, n as Ue, A as Je } from "./RichTextEditor-e6q30rbV.js";
4
4
  import { useState as ee } from "react";
5
5
  import { T as O, p as I, q as F } from "./index-CsK90iVd.js";
6
6
  var le, re;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("./index-ByRfqzMr.cjs"),p=require("./dom-dataset-Byuf1YmW.cjs"),l=require("react/jsx-runtime"),c=require("react"),C=require("./index-D_A0TBRA.cjs"),b=require("./RichTextEditor-DoMu_nCj.cjs"),g="_toc_aag8a_1",x="_visible_aag8a_7",T="_list_aag8a_11",O="_item_aag8a_16",f={toc:g,visible:x,list:T,item:O};function _(e){const o=[],a=[o];return e.forEach(n=>{let t=-1,s=a[n.level+t];for(;!s;)t-=1,s=a[n.level+t];s.push({...n,children:a[n.level]=[]})}),o}function y({editor:e}){const o=b.useEditableEditor(),[a,n]=c.useState([]),{t}=C.useLocale(),s=c.useCallback(()=>{const i=[],r=e.state.tr;e.state.doc.descendants((u,v)=>{if(u.type.name==="heading"){const d=`heading-${i.length+1}`;u.attrs.id!==d&&r.setNodeMarkup(v,void 0,{...u.attrs,id:d}),i.push({level:u.attrs.level,text:u.textContent,id:d})}}),r.setMeta("addToHistory",!1),r.setMeta("preventUpdate",!0),e.view.dispatch(r),n(i),e.eventEmitter&&e.eventEmitter.emit("TableOfContents",_(i))},[e]);return c.useEffect(()=>{if(e){if(!e.options.editable){s();return}return e.on("update",s),()=>{e.off("update",s)}}},[e,s]),c.useEffect(()=>{s()},[]),l.jsx(p.NodeViewWrapper,{className:p.clsx("tableOfContent",f.toc,o&&f.visible),children:o?l.jsxs("div",{style:{position:"relative"},children:[l.jsx("p",{className:"text-[20px] richtext-mb-[8px] richtext-font-semibold",children:t("editor.table_of_content")}),l.jsx("ul",{className:f.list,children:a.map((i,r)=>l.jsx("li",{className:f.item,style:{paddingLeft:`${i.level-1}rem`},children:l.jsx("a",{href:`#${i.id}`,children:i.text})},`table-of-content-${r}`))})]}):null})}function N(e,...o){const[a,n]=c.useState(!1);return c.useEffect(()=>{const t=()=>{n(e.isActive.apply(e,o))};return e.on("selectionUpdate",t),e.on("transaction",t),()=>{e.off("selectionUpdate",t),e.off("transaction",t)}},[e,o,n]),a}function A({editor:e,icon:o,tooltip:a}){const n=N(e,m.name),t=c.useCallback(()=>{if(n){e.chain().focus().removeTableOfContents().run();return}e.chain().focus().setTableOfContents().run()},[e,n]);return l.jsx(b.ActionButton,{action:t,isActive:()=>n||!1,icon:o,tooltip:a})}function j(e){return e&&e.type.name==="title"}function E(e,o){const n=[e.getJSON()],t=[];for(;n.length>0;){const s=n.shift();s.type===o&&t.push(s),s.content&&s.content.length>0&&n.push(...s.content)}return t}const m=h.Node.create({name:"tableOfContents",group:"block",atom:!0,addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),onHasOneBeforeInsert:()=>{},resizable:!0,lastColumnResizable:!0,allowTableNodeSelection:!1,button:({editor:o,t:a})=>({component:A,componentProps:{disabled:!1,icon:"BookMarked",tooltip:a("editor.table_of_content"),editor:o}})}},parseHTML(){return[{tag:"toc"}]},renderHTML({HTMLAttributes:e}){return["toc",h.mergeAttributes(e)]},addNodeView(){return p.ReactNodeViewRenderer(y)},addCommands(){return{setTableOfContents:()=>({commands:e,editor:o,view:a})=>{if(E(o,this.name).length>0){this.options.onHasOneBeforeInsert();return}const t=a.props.state.doc.content.firstChild;if(j(t)){const s=(t.firstChild&&t.firstChild.nodeSize||0)+1;return e.insertContentAt(s,{type:this.name})}return e.insertContent({type:this.name})},removeTableOfContents:()=>({state:e,dispatch:o})=>{const{tr:a}=e,n=e.schema.nodes.tableOfContents;return e.doc.descendants((t,s)=>{if(t.type===n){const i=s,r=s+t.nodeSize;a.delete(i,r)}}),a.docChanged?(o(a),!0):!1}}},addGlobalAttributes(){return[{types:["heading"],attributes:{id:{default:null}}}]}});exports.TableOfContents=m;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("./index-ByRfqzMr.cjs"),p=require("./dom-dataset-Byuf1YmW.cjs"),l=require("react/jsx-runtime"),c=require("react"),C=require("./index-D_A0TBRA.cjs"),b=require("./RichTextEditor-DsUcQSbm.cjs"),g="_toc_aag8a_1",x="_visible_aag8a_7",T="_list_aag8a_11",O="_item_aag8a_16",f={toc:g,visible:x,list:T,item:O};function _(e){const o=[],a=[o];return e.forEach(n=>{let t=-1,s=a[n.level+t];for(;!s;)t-=1,s=a[n.level+t];s.push({...n,children:a[n.level]=[]})}),o}function y({editor:e}){const o=b.useEditableEditor(),[a,n]=c.useState([]),{t}=C.useLocale(),s=c.useCallback(()=>{const i=[],r=e.state.tr;e.state.doc.descendants((u,v)=>{if(u.type.name==="heading"){const d=`heading-${i.length+1}`;u.attrs.id!==d&&r.setNodeMarkup(v,void 0,{...u.attrs,id:d}),i.push({level:u.attrs.level,text:u.textContent,id:d})}}),r.setMeta("addToHistory",!1),r.setMeta("preventUpdate",!0),e.view.dispatch(r),n(i),e.eventEmitter&&e.eventEmitter.emit("TableOfContents",_(i))},[e]);return c.useEffect(()=>{if(e){if(!e.options.editable){s();return}return e.on("update",s),()=>{e.off("update",s)}}},[e,s]),c.useEffect(()=>{s()},[]),l.jsx(p.NodeViewWrapper,{className:p.clsx("tableOfContent",f.toc,o&&f.visible),children:o?l.jsxs("div",{style:{position:"relative"},children:[l.jsx("p",{className:"text-[20px] richtext-mb-[8px] richtext-font-semibold",children:t("editor.table_of_content")}),l.jsx("ul",{className:f.list,children:a.map((i,r)=>l.jsx("li",{className:f.item,style:{paddingLeft:`${i.level-1}rem`},children:l.jsx("a",{href:`#${i.id}`,children:i.text})},`table-of-content-${r}`))})]}):null})}function N(e,...o){const[a,n]=c.useState(!1);return c.useEffect(()=>{const t=()=>{n(e.isActive.apply(e,o))};return e.on("selectionUpdate",t),e.on("transaction",t),()=>{e.off("selectionUpdate",t),e.off("transaction",t)}},[e,o,n]),a}function A({editor:e,icon:o,tooltip:a}){const n=N(e,m.name),t=c.useCallback(()=>{if(n){e.chain().focus().removeTableOfContents().run();return}e.chain().focus().setTableOfContents().run()},[e,n]);return l.jsx(b.ActionButton,{action:t,isActive:()=>n||!1,icon:o,tooltip:a})}function j(e){return e&&e.type.name==="title"}function E(e,o){const n=[e.getJSON()],t=[];for(;n.length>0;){const s=n.shift();s.type===o&&t.push(s),s.content&&s.content.length>0&&n.push(...s.content)}return t}const m=h.Node.create({name:"tableOfContents",group:"block",atom:!0,addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),onHasOneBeforeInsert:()=>{},resizable:!0,lastColumnResizable:!0,allowTableNodeSelection:!1,button:({editor:o,t:a})=>({component:A,componentProps:{disabled:!1,icon:"BookMarked",tooltip:a("editor.table_of_content"),editor:o}})}},parseHTML(){return[{tag:"toc"}]},renderHTML({HTMLAttributes:e}){return["toc",h.mergeAttributes(e)]},addNodeView(){return p.ReactNodeViewRenderer(y)},addCommands(){return{setTableOfContents:()=>({commands:e,editor:o,view:a})=>{if(E(o,this.name).length>0){this.options.onHasOneBeforeInsert();return}const t=a.props.state.doc.content.firstChild;if(j(t)){const s=(t.firstChild&&t.firstChild.nodeSize||0)+1;return e.insertContentAt(s,{type:this.name})}return e.insertContent({type:this.name})},removeTableOfContents:()=>({state:e,dispatch:o})=>{const{tr:a}=e,n=e.schema.nodes.tableOfContents;return e.doc.descendants((t,s)=>{if(t.type===n){const i=s,r=s+t.nodeSize;a.delete(i,r)}}),a.docChanged?(o(a),!0):!1}}},addGlobalAttributes(){return[{types:["heading"],attributes:{id:{default:null}}}]}});exports.TableOfContents=m;
@@ -63,8 +63,8 @@ declare module '@tiptap/core' {
63
63
 
64
64
  declare module '@tiptap/core' {
65
65
  interface Commands<ReturnType> {
66
- excalidraw: {
67
- setExcalidraw: (attrs?: IExcalidrawAttrs) => ReturnType;
66
+ exportPdf: {
67
+ exportToPdf: () => ReturnType;
68
68
  };
69
69
  }
70
70
  }
@@ -72,8 +72,8 @@ declare module '@tiptap/core' {
72
72
 
73
73
  declare module '@tiptap/core' {
74
74
  interface Commands<ReturnType> {
75
- exportPdf: {
76
- exportToPdf: () => ReturnType;
75
+ excalidraw: {
76
+ setExcalidraw: (attrs?: IExcalidrawAttrs) => ReturnType;
77
77
  };
78
78
  }
79
79
  }
@@ -63,8 +63,8 @@ declare module '@tiptap/core' {
63
63
 
64
64
  declare module '@tiptap/core' {
65
65
  interface Commands<ReturnType> {
66
- excalidraw: {
67
- setExcalidraw: (attrs?: IExcalidrawAttrs) => ReturnType;
66
+ exportPdf: {
67
+ exportToPdf: () => ReturnType;
68
68
  };
69
69
  }
70
70
  }
@@ -72,8 +72,8 @@ declare module '@tiptap/core' {
72
72
 
73
73
  declare module '@tiptap/core' {
74
74
  interface Commands<ReturnType> {
75
- exportPdf: {
76
- exportToPdf: () => ReturnType;
75
+ excalidraw: {
76
+ setExcalidraw: (attrs?: IExcalidrawAttrs) => ReturnType;
77
77
  };
78
78
  }
79
79
  }
@@ -3,7 +3,7 @@ import { N as C, c as g, R as N } from "./dom-dataset-Di3tIRrR.js";
3
3
  import { jsx as l, jsxs as T } from "react/jsx-runtime";
4
4
  import { useState as p, useCallback as m, useEffect as d } from "react";
5
5
  import { u as O } from "./index-CsK90iVd.js";
6
- import { Z as _, A as y } from "./RichTextEditor-BJWhWz4z.js";
6
+ import { Z as _, A as y } from "./RichTextEditor-e6q30rbV.js";
7
7
  const x = "_toc_aag8a_1", A = "_visible_aag8a_7", w = "_list_aag8a_11", E = "_item_aag8a_16", f = {
8
8
  toc: x,
9
9
  visible: A,
package/lib/TaskList.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index-ByRfqzMr.cjs"),b=require("./RichTextEditor-DoMu_nCj.cjs"),f=/^\s*(\[([( |x])?\])\s$/,L=r.Node.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:t=>{const i=t.getAttribute("data-checked");return i===""||i==="true"},renderHTML:t=>({"data-checked":t.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:t,HTMLAttributes:i}){return["li",r.mergeAttributes(this.options.HTMLAttributes,i,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},addKeyboardShortcuts(){const t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:i,getPos:o,editor:c})=>{const a=document.createElement("li"),d=document.createElement("label"),k=document.createElement("span"),s=document.createElement("input"),l=document.createElement("div"),p=()=>{var e,n;s.ariaLabel=((n=(e=this.options.a11y)===null||e===void 0?void 0:e.checkboxLabel)===null||n===void 0?void 0:n.call(e,t,s.checked))||`Task item checkbox for ${t.textContent||"empty task item"}`};return p(),d.contentEditable="false",s.type="checkbox",s.addEventListener("mousedown",e=>e.preventDefault()),s.addEventListener("change",e=>{if(!c.isEditable&&!this.options.onReadOnlyChecked){s.checked=!s.checked;return}const{checked:n}=e.target;c.isEditable&&typeof o=="function"&&c.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:m})=>{const u=o();if(typeof u!="number")return!1;const h=m.doc.nodeAt(u);return m.setNodeMarkup(u,void 0,{...h==null?void 0:h.attrs,checked:n}),!0}).run(),!c.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,n)||(s.checked=!s.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([e,n])=>{a.setAttribute(e,n)}),a.dataset.checked=t.attrs.checked,s.checked=t.attrs.checked,d.append(s,k),a.append(d,l),Object.entries(i).forEach(([e,n])=>{a.setAttribute(e,n)}),{dom:a,contentDOM:l,update:e=>e.type!==this.type?!1:(a.dataset.checked=e.attrs.checked,s.checked=e.attrs.checked,p(),!0)}}},addInputRules(){return[r.wrappingInputRule({find:f,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),y=r.Node.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:t}){return["ul",r.mergeAttributes(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}}),T=y.extend({addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),HTMLAttributes:{class:"task-list"},taskItem:{HTMLAttributes:{class:"task-list-item"}},button:({editor:i,t:o})=>({component:b.ActionButton,componentProps:{action:()=>i.commands.toggleTaskList(),isActive:()=>i.isActive("taskList")||!1,disabled:!1,icon:"ListTodo",shortcutKeys:["shift","mod","9"],tooltip:o("editor.tasklist.tooltip")}})}},addExtensions(){return[L.configure(this.options.taskItem)]}});exports.TaskList=T;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./index-ByRfqzMr.cjs"),b=require("./RichTextEditor-DsUcQSbm.cjs"),f=/^\s*(\[([( |x])?\])\s$/,L=o.Node.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:t=>{const i=t.getAttribute("data-checked");return i===""||i==="true"},renderHTML:t=>({"data-checked":t.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:t,HTMLAttributes:i}){return["li",o.mergeAttributes(this.options.HTMLAttributes,i,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},addKeyboardShortcuts(){const t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:i,getPos:c,editor:a})=>{const r=document.createElement("li"),d=document.createElement("label"),k=document.createElement("span"),s=document.createElement("input"),l=document.createElement("div"),p=()=>{var e,n;s.ariaLabel=((n=(e=this.options.a11y)===null||e===void 0?void 0:e.checkboxLabel)===null||n===void 0?void 0:n.call(e,t,s.checked))||`Task item checkbox for ${t.textContent||"empty task item"}`};return p(),d.contentEditable="false",s.type="checkbox",s.addEventListener("mousedown",e=>e.preventDefault()),s.addEventListener("change",e=>{if(!a.isEditable&&!this.options.onReadOnlyChecked){s.checked=!s.checked;return}const{checked:n}=e.target;a.isEditable&&typeof c=="function"&&a.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:m})=>{const u=c();if(typeof u!="number")return!1;const h=m.doc.nodeAt(u);return m.setNodeMarkup(u,void 0,{...h==null?void 0:h.attrs,checked:n}),!0}).run(),!a.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,n)||(s.checked=!s.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([e,n])=>{r.setAttribute(e,n)}),r.dataset.checked=t.attrs.checked,s.checked=t.attrs.checked,d.append(s,k),r.append(d,l),Object.entries(i).forEach(([e,n])=>{r.setAttribute(e,n)}),{dom:r,contentDOM:l,update:e=>e.type!==this.type?!1:(r.dataset.checked=e.attrs.checked,s.checked=e.attrs.checked,p(),!0)}}},addInputRules(){return[o.wrappingInputRule({find:f,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),y=o.Node.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:t}){return["ul",o.mergeAttributes(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}}),T=y.extend({addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),HTMLAttributes:{class:"task-list"},taskItem:{HTMLAttributes:{class:"task-list-item"}},button:({editor:i,t:c,extension:a})=>({component:b.ActionButton,componentProps:{action:()=>i.commands.toggleTaskList(),isActive:()=>i.isActive("taskList")||!1,disabled:!1,icon:"ListTodo",shortcutKeys:a.options.shortcutKeys??["shift","mod","9"],tooltip:c("editor.tasklist.tooltip")}})}},addExtensions(){return[L.configure(this.options.taskItem)]}});exports.TaskList=T;
@@ -69,6 +69,8 @@ declare interface GeneralOptions<T> {
69
69
  button: ButtonView<T>;
70
70
  /** Show on Toolbar */
71
71
  toolbar?: boolean;
72
+ /** Shortcut keys override */
73
+ shortcutKeys?: string[] | string[][];
72
74
  }
73
75
 
74
76
  export declare const TaskList: Node_2<TaskListOptions, any>;
@@ -138,8 +140,8 @@ declare module '@tiptap/core' {
138
140
 
139
141
  declare module '@tiptap/core' {
140
142
  interface Commands<ReturnType> {
141
- excalidraw: {
142
- setExcalidraw: (attrs?: IExcalidrawAttrs) => ReturnType;
143
+ exportPdf: {
144
+ exportToPdf: () => ReturnType;
143
145
  };
144
146
  }
145
147
  }
@@ -147,8 +149,8 @@ declare module '@tiptap/core' {
147
149
 
148
150
  declare module '@tiptap/core' {
149
151
  interface Commands<ReturnType> {
150
- exportPdf: {
151
- exportToPdf: () => ReturnType;
152
+ excalidraw: {
153
+ setExcalidraw: (attrs?: IExcalidrawAttrs) => ReturnType;
152
154
  };
153
155
  }
154
156
  }
package/lib/TaskList.d.ts CHANGED
@@ -69,6 +69,8 @@ declare interface GeneralOptions<T> {
69
69
  button: ButtonView<T>;
70
70
  /** Show on Toolbar */
71
71
  toolbar?: boolean;
72
+ /** Shortcut keys override */
73
+ shortcutKeys?: string[] | string[][];
72
74
  }
73
75
 
74
76
  export declare const TaskList: Node_2<TaskListOptions, any>;
@@ -138,8 +140,8 @@ declare module '@tiptap/core' {
138
140
 
139
141
  declare module '@tiptap/core' {
140
142
  interface Commands<ReturnType> {
141
- excalidraw: {
142
- setExcalidraw: (attrs?: IExcalidrawAttrs) => ReturnType;
143
+ exportPdf: {
144
+ exportToPdf: () => ReturnType;
143
145
  };
144
146
  }
145
147
  }
@@ -147,8 +149,8 @@ declare module '@tiptap/core' {
147
149
 
148
150
  declare module '@tiptap/core' {
149
151
  interface Commands<ReturnType> {
150
- exportPdf: {
151
- exportToPdf: () => ReturnType;
152
+ excalidraw: {
153
+ setExcalidraw: (attrs?: IExcalidrawAttrs) => ReturnType;
152
154
  };
153
155
  }
154
156
  }
package/lib/TaskList.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { N as m, w as f, m as k } from "./index-DI9T3iLd.js";
2
- import { A as L } from "./RichTextEditor-BJWhWz4z.js";
2
+ import { A as L } from "./RichTextEditor-e6q30rbV.js";
3
3
  const y = /^\s*(\[([( |x])?\])\s$/, T = m.create({
4
4
  name: "taskItem",
5
5
  addOptions() {
@@ -68,19 +68,19 @@ const y = /^\s*(\[([( |x])?\])\s$/, T = m.create({
68
68
  } : t;
69
69
  },
70
70
  addNodeView() {
71
- return ({ node: t, HTMLAttributes: i, getPos: r, editor: o }) => {
72
- const a = document.createElement("li"), c = document.createElement("label"), b = document.createElement("span"), s = document.createElement("input"), h = document.createElement("div"), p = () => {
71
+ return ({ node: t, HTMLAttributes: i, getPos: o, editor: a }) => {
72
+ const r = document.createElement("li"), c = document.createElement("label"), b = document.createElement("span"), s = document.createElement("input"), h = document.createElement("div"), p = () => {
73
73
  var e, n;
74
74
  s.ariaLabel = ((n = (e = this.options.a11y) === null || e === void 0 ? void 0 : e.checkboxLabel) === null || n === void 0 ? void 0 : n.call(e, t, s.checked)) || `Task item checkbox for ${t.textContent || "empty task item"}`;
75
75
  };
76
76
  return p(), c.contentEditable = "false", s.type = "checkbox", s.addEventListener("mousedown", (e) => e.preventDefault()), s.addEventListener("change", (e) => {
77
- if (!o.isEditable && !this.options.onReadOnlyChecked) {
77
+ if (!a.isEditable && !this.options.onReadOnlyChecked) {
78
78
  s.checked = !s.checked;
79
79
  return;
80
80
  }
81
81
  const { checked: n } = e.target;
82
- o.isEditable && typeof r == "function" && o.chain().focus(void 0, { scrollIntoView: !1 }).command(({ tr: l }) => {
83
- const d = r();
82
+ a.isEditable && typeof o == "function" && a.chain().focus(void 0, { scrollIntoView: !1 }).command(({ tr: l }) => {
83
+ const d = o();
84
84
  if (typeof d != "number")
85
85
  return !1;
86
86
  const u = l.doc.nodeAt(d);
@@ -88,15 +88,15 @@ const y = /^\s*(\[([( |x])?\])\s$/, T = m.create({
88
88
  ...u == null ? void 0 : u.attrs,
89
89
  checked: n
90
90
  }), !0;
91
- }).run(), !o.isEditable && this.options.onReadOnlyChecked && (this.options.onReadOnlyChecked(t, n) || (s.checked = !s.checked));
91
+ }).run(), !a.isEditable && this.options.onReadOnlyChecked && (this.options.onReadOnlyChecked(t, n) || (s.checked = !s.checked));
92
92
  }), Object.entries(this.options.HTMLAttributes).forEach(([e, n]) => {
93
- a.setAttribute(e, n);
94
- }), a.dataset.checked = t.attrs.checked, s.checked = t.attrs.checked, c.append(s, b), a.append(c, h), Object.entries(i).forEach(([e, n]) => {
95
- a.setAttribute(e, n);
93
+ r.setAttribute(e, n);
94
+ }), r.dataset.checked = t.attrs.checked, s.checked = t.attrs.checked, c.append(s, b), r.append(c, h), Object.entries(i).forEach(([e, n]) => {
95
+ r.setAttribute(e, n);
96
96
  }), {
97
- dom: a,
97
+ dom: r,
98
98
  contentDOM: h,
99
- update: (e) => e.type !== this.type ? !1 : (a.dataset.checked = e.attrs.checked, s.checked = e.attrs.checked, p(), !0)
99
+ update: (e) => e.type !== this.type ? !1 : (r.dataset.checked = e.attrs.checked, s.checked = e.attrs.checked, p(), !0)
100
100
  };
101
101
  };
102
102
  },
@@ -157,15 +157,15 @@ const y = /^\s*(\[([( |x])?\])\s$/, T = m.create({
157
157
  class: "task-list-item"
158
158
  }
159
159
  },
160
- button: ({ editor: i, t: r }) => ({
160
+ button: ({ editor: i, t: o, extension: a }) => ({
161
161
  component: L,
162
162
  componentProps: {
163
163
  action: () => i.commands.toggleTaskList(),
164
164
  isActive: () => i.isActive("taskList") || !1,
165
165
  disabled: !1,
166
166
  icon: "ListTodo",
167
- shortcutKeys: ["shift", "mod", "9"],
168
- tooltip: r("editor.tasklist.tooltip")
167
+ shortcutKeys: a.options.shortcutKeys ?? ["shift", "mod", "9"],
168
+ tooltip: o("editor.tasklist.tooltip")
169
169
  }
170
170
  })
171
171
  };
package/lib/TextAlign.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("./index-ByRfqzMr.cjs"),n=require("react/jsx-runtime"),T=require("react"),s=require("./RichTextEditor-DoMu_nCj.cjs"),j=y.Extension.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:t=>{const e=t.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:t=>t.textAlign?{style:`text-align: ${t.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:t=>({commands:e})=>this.options.alignments.includes(t)?this.options.types.map(l=>e.updateAttributes(l,{textAlign:t})).every(l=>l):!1,unsetTextAlign:()=>({commands:t})=>this.options.types.map(e=>t.resetAttributes(e,"textAlign")).every(e=>e),toggleTextAlign:t=>({editor:e,commands:l})=>this.options.alignments.includes(t)?e.isActive({textAlign:t})?l.unsetTextAlign():l.setTextAlign(t):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}});function b(t){var l;const e=T.useMemo(()=>{var o;const i=(o=t==null?void 0:t.items)==null?void 0:o.find(a=>a.isActive());return i&&!i.default?{...i,icon:i.icon?i.icon:t.icon}:{title:t==null?void 0:t.tooltip,icon:t.icon,isActive:()=>!1}},[t]);return n.jsxs(s.Popover,{modal:!0,children:[n.jsx(s.PopoverTrigger,{asChild:!0,disabled:t==null?void 0:t.disabled,children:n.jsx(s.ActionButton,{customClass:"!richtext-w-12 richtext-h-12",disabled:t==null?void 0:t.disabled,icon:t==null?void 0:t.icon,tooltip:t==null?void 0:t.tooltip,children:n.jsx(s.IconComponent,{className:"richtext-ml-1 richtext-size-3 richtext-text-zinc-500",name:"MenuDown"})})}),n.jsx(s.PopoverContent,{align:"start",className:"richtext-flex richtext-w-full richtext-min-w-4 richtext-flex-row richtext-gap-1 !richtext-p-[4px]",side:"bottom",children:(l=t==null?void 0:t.items)==null?void 0:l.map((i,d)=>{var o,a;return n.jsxs(s.Tooltip,{children:[n.jsx(s.TooltipTrigger,{asChild:!0,children:n.jsx(s.Toggle,{className:"richtext-size-7 richtext-p-1","data-state":e.title===i.title?"on":"off",onClick:i==null?void 0:i.action,pressed:e.title===i.title,size:"sm",children:(i==null?void 0:i.icon)&&n.jsx(s.IconComponent,{name:i.icon})})}),n.jsxs(s.TooltipContent,{className:"richtext-flex richtext-flex-col richtext-items-center",children:[n.jsx("span",{children:i.title}),!!((o=i.shortcutKeys)!=null&&o.length)&&n.jsx("span",{children:(a=i.shortcutKeys)==null?void 0:a.map(r=>s.getShortcutKey(r)).join(" ")})]})]},`text-align-${d}`)})})]})}const v=j.extend({addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),types:["heading","paragraph","list_item","title"],button({editor:e,extension:l,t:i}){var x;const d=((x=l.options)==null?void 0:x.alignments)||[],o={left:["mod","Shift","L"],center:["mod","Shift","E"],right:["mod","Shift","R"],justify:["mod","Shift","J"]},a={left:"AlignLeft",center:"AlignCenter",right:"AlignRight",justify:"AlignJustify"},r=d.map(c=>{var g,h,f;return{title:i(`editor.textalign.${c}.tooltip`),icon:a[c],shortcutKeys:o[c],isActive:()=>e.isActive({textAlign:c})||!1,action:()=>{var u,A;return(A=(u=e.commands)==null?void 0:u.setTextAlign)==null?void 0:A.call(u,c)},disabled:!((f=(h=(g=e==null?void 0:e.can)==null?void 0:g.call(e))==null?void 0:h.setTextAlign)!=null&&f.call(h,c))}}),m=r.filter(c=>c.disabled).length===r.length;return{component:b,componentProps:{icon:"AlignJustify",tooltip:i("editor.textalign.tooltip"),disabled:m,items:r}}}}}});exports.TextAlign=v;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("./index-ByRfqzMr.cjs"),s=require("react/jsx-runtime"),M=require("react"),l=require("./RichTextEditor-DsUcQSbm.cjs"),S=v.Extension.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:t=>{const e=t.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:t=>t.textAlign?{style:`text-align: ${t.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:t=>({commands:e})=>this.options.alignments.includes(t)?this.options.types.map(n=>e.updateAttributes(n,{textAlign:t})).every(n=>n):!1,unsetTextAlign:()=>({commands:t})=>this.options.types.map(e=>t.resetAttributes(e,"textAlign")).every(e=>e),toggleTextAlign:t=>({editor:e,commands:n})=>this.options.alignments.includes(t)?e.isActive({textAlign:t})?n.unsetTextAlign():n.setTextAlign(t):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}});function C(t){var n;const e=M.useMemo(()=>{var o;const i=(o=t==null?void 0:t.items)==null?void 0:o.find(r=>r.isActive());return i&&!i.default?{...i,icon:i.icon?i.icon:t.icon}:{title:t==null?void 0:t.tooltip,icon:t.icon,isActive:()=>!1}},[t]);return s.jsxs(l.Popover,{modal:!0,children:[s.jsx(l.PopoverTrigger,{asChild:!0,disabled:t==null?void 0:t.disabled,children:s.jsx(l.ActionButton,{customClass:"!richtext-w-12 richtext-h-12",disabled:t==null?void 0:t.disabled,icon:t==null?void 0:t.icon,tooltip:t==null?void 0:t.tooltip,children:s.jsx(l.IconComponent,{className:"richtext-ml-1 richtext-size-3 richtext-text-zinc-500",name:"MenuDown"})})}),s.jsx(l.PopoverContent,{align:"start",className:"richtext-flex richtext-w-full richtext-min-w-4 richtext-flex-row richtext-gap-1 !richtext-p-[4px]",side:"bottom",children:(n=t==null?void 0:t.items)==null?void 0:n.map((i,h)=>{var o,r;return s.jsxs(l.Tooltip,{children:[s.jsx(l.TooltipTrigger,{asChild:!0,children:s.jsx(l.Toggle,{className:"richtext-size-7 richtext-p-1","data-state":e.title===i.title?"on":"off",onClick:i==null?void 0:i.action,pressed:e.title===i.title,size:"sm",children:(i==null?void 0:i.icon)&&s.jsx(l.IconComponent,{name:i.icon})})}),s.jsxs(l.TooltipContent,{className:"richtext-flex richtext-flex-col richtext-items-center",children:[s.jsx("span",{children:i.title}),!!((o=i.shortcutKeys)!=null&&o.length)&&s.jsx("span",{children:(r=i.shortcutKeys)==null?void 0:r.map(a=>l.getShortcutKey(a)).join(" ")})]})]},`text-align-${h}`)})})]})}const K=S.extend({addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),types:["heading","paragraph","list_item","title"],button({editor:e,extension:n,t:i}){var g,x,f,A,m;const h=((g=n.options)==null?void 0:g.alignments)||[],o={left:((x=n.options.shortcutKeys)==null?void 0:x[0])??["mod","Shift","L"],center:((f=n.options.shortcutKeys)==null?void 0:f[1])??["mod","Shift","E"],right:((A=n.options.shortcutKeys)==null?void 0:A[2])??["mod","Shift","R"],justify:((m=n.options.shortcutKeys)==null?void 0:m[3])??["mod","Shift","J"]},r={left:"AlignLeft",center:"AlignCenter",right:"AlignRight",justify:"AlignJustify"},a=h.map(c=>{var y,u,T;return{title:i(`editor.textalign.${c}.tooltip`),icon:r[c],shortcutKeys:o[c],isActive:()=>e.isActive({textAlign:c})||!1,action:()=>{var d,j;return(j=(d=e.commands)==null?void 0:d.setTextAlign)==null?void 0:j.call(d,c)},disabled:!((T=(u=(y=e==null?void 0:e.can)==null?void 0:y.call(e))==null?void 0:u.setTextAlign)!=null&&T.call(u,c))}}),b=a.filter(c=>c.disabled).length===a.length;return{component:C,componentProps:{icon:"AlignJustify",tooltip:i("editor.textalign.tooltip"),disabled:b,items:a}}}}}});exports.TextAlign=K;
@@ -69,6 +69,8 @@ declare interface GeneralOptions<T> {
69
69
  button: ButtonView<T>;
70
70
  /** Show on Toolbar */
71
71
  toolbar?: boolean;
72
+ /** Shortcut keys override */
73
+ shortcutKeys?: string[] | string[][];
72
74
  }
73
75
 
74
76
  export declare const TextAlign: Extension<TextAlignOptions, any>;
@@ -142,8 +144,8 @@ declare module '@tiptap/core' {
142
144
 
143
145
  declare module '@tiptap/core' {
144
146
  interface Commands<ReturnType> {
145
- excalidraw: {
146
- setExcalidraw: (attrs?: IExcalidrawAttrs) => ReturnType;
147
+ exportPdf: {
148
+ exportToPdf: () => ReturnType;
147
149
  };
148
150
  }
149
151
  }
@@ -151,8 +153,8 @@ declare module '@tiptap/core' {
151
153
 
152
154
  declare module '@tiptap/core' {
153
155
  interface Commands<ReturnType> {
154
- exportPdf: {
155
- exportToPdf: () => ReturnType;
156
+ excalidraw: {
157
+ setExcalidraw: (attrs?: IExcalidrawAttrs) => ReturnType;
156
158
  };
157
159
  }
158
160
  }