reactjs-tiptap-editor 0.3.30 → 0.3.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/{ActionMenuButton-wiDnIxE2.cjs → ActionMenuButton-BCgqJsST.cjs} +1 -1
- package/lib/{ActionMenuButton-B6fitGKu.js → ActionMenuButton-D97K0UWT.js} +5 -5
- package/lib/Attachment.cjs +1 -1
- package/lib/Attachment.d.cts +15 -15
- package/lib/Attachment.d.ts +15 -15
- package/lib/Attachment.js +1 -1
- package/lib/Blockquote.cjs +1 -1
- package/lib/Blockquote.d.cts +15 -15
- package/lib/Blockquote.d.ts +15 -15
- package/lib/Blockquote.js +1 -1
- package/lib/Bold.cjs +1 -1
- package/lib/Bold.d.cts +15 -15
- package/lib/Bold.d.ts +15 -15
- package/lib/Bold.js +1 -1
- package/lib/BulletList.cjs +1 -1
- package/lib/BulletList.d.cts +15 -15
- package/lib/BulletList.d.ts +15 -15
- package/lib/BulletList.js +1 -1
- package/lib/Clear.cjs +1 -1
- package/lib/Clear.d.cts +15 -15
- package/lib/Clear.d.ts +15 -15
- package/lib/Clear.js +1 -1
- package/lib/Code.cjs +1 -1
- package/lib/Code.d.cts +15 -15
- package/lib/Code.d.ts +15 -15
- package/lib/Code.js +1 -1
- package/lib/CodeBlock.cjs +1 -1
- package/lib/CodeBlock.d.cts +15 -15
- package/lib/CodeBlock.d.ts +15 -15
- package/lib/CodeBlock.js +3 -2
- package/lib/CodeView.cjs +1 -1
- package/lib/CodeView.d.cts +15 -15
- package/lib/CodeView.d.ts +15 -15
- package/lib/CodeView.js +1 -1
- package/lib/Color.cjs +1 -1
- package/lib/Color.d.cts +15 -15
- package/lib/Color.d.ts +15 -15
- package/lib/Color.js +2 -2
- package/lib/Document.d.cts +15 -15
- package/lib/Document.d.ts +15 -15
- package/lib/Drawer-5Q_-WRhc.cjs +1 -0
- package/lib/{Drawer-BKTU9CpU.js → Drawer-BHkje8ys.js} +250 -249
- package/lib/Drawer.cjs +1 -1
- package/lib/Drawer.d.cts +15 -15
- package/lib/Drawer.d.ts +15 -15
- package/lib/Drawer.js +2 -2
- package/lib/Emoji.cjs +1 -1
- package/lib/Emoji.d.cts +15 -15
- package/lib/Emoji.d.ts +15 -15
- package/lib/Emoji.js +22 -21
- package/lib/Excalidraw-CG498239.js +290 -0
- package/lib/Excalidraw-GUVW-IqC.cjs +1 -0
- package/lib/Excalidraw.cjs +1 -1
- package/lib/Excalidraw.d.cts +15 -15
- package/lib/Excalidraw.d.ts +15 -15
- package/lib/Excalidraw.js +1 -1
- package/lib/ExportPdf.cjs +1 -1
- package/lib/ExportPdf.d.cts +15 -15
- package/lib/ExportPdf.d.ts +15 -15
- package/lib/ExportPdf.js +1 -1
- package/lib/ExportWord.cjs +1 -1
- package/lib/ExportWord.d.cts +15 -15
- package/lib/ExportWord.d.ts +15 -15
- package/lib/ExportWord.js +1 -1
- package/lib/FontFamily.cjs +1 -1
- package/lib/FontFamily.d.cts +15 -15
- package/lib/FontFamily.d.ts +15 -15
- package/lib/FontFamily.js +11 -10
- package/lib/FontSize.cjs +1 -1
- package/lib/FontSize.d.cts +15 -15
- package/lib/FontSize.d.ts +15 -15
- package/lib/FontSize.js +6 -5
- package/lib/FormatPainter.cjs +1 -1
- package/lib/FormatPainter.d.cts +15 -15
- package/lib/FormatPainter.d.ts +15 -15
- package/lib/FormatPainter.js +1 -1
- package/lib/Heading.cjs +1 -1
- package/lib/Heading.d.cts +15 -15
- package/lib/Heading.d.ts +15 -15
- package/lib/Heading.js +32 -31
- package/lib/Highlight.cjs +1 -1
- package/lib/Highlight.d.cts +15 -15
- package/lib/Highlight.d.ts +15 -15
- package/lib/Highlight.js +1 -1
- package/lib/History.cjs +1 -1
- package/lib/History.d.cts +15 -15
- package/lib/History.d.ts +15 -15
- package/lib/History.js +1 -1
- package/lib/HorizontalRule.cjs +1 -1
- package/lib/HorizontalRule.d.cts +15 -15
- package/lib/HorizontalRule.d.ts +15 -15
- package/lib/HorizontalRule.js +1 -1
- package/lib/Iframe.cjs +1 -1
- package/lib/Iframe.d.cts +15 -15
- package/lib/Iframe.d.ts +15 -15
- package/lib/Iframe.js +1 -1
- package/lib/Image.cjs +1 -1
- package/lib/Image.d.cts +15 -15
- package/lib/Image.d.ts +15 -15
- package/lib/Image.js +1 -1
- package/lib/ImageGif.cjs +1 -1
- package/lib/ImageGif.d.cts +15 -15
- package/lib/ImageGif.d.ts +15 -15
- package/lib/ImageGif.js +1 -1
- package/lib/ImportWord.cjs +2 -2
- package/lib/ImportWord.d.cts +15 -15
- package/lib/ImportWord.d.ts +15 -15
- package/lib/ImportWord.js +3 -2
- package/lib/Indent.cjs +1 -1
- package/lib/Indent.d.cts +15 -15
- package/lib/Indent.d.ts +15 -15
- package/lib/Indent.js +1 -1
- package/lib/Italic.cjs +1 -1
- package/lib/Italic.d.cts +15 -15
- package/lib/Italic.d.ts +15 -15
- package/lib/Italic.js +1 -1
- package/lib/Katex.cjs +1 -1
- package/lib/Katex.d.cts +15 -15
- package/lib/Katex.d.ts +15 -15
- package/lib/Katex.js +41 -40
- package/lib/LineHeight.cjs +1 -1
- package/lib/LineHeight.d.cts +15 -15
- package/lib/LineHeight.d.ts +15 -15
- package/lib/LineHeight.js +17 -16
- package/lib/Link.cjs +1 -1
- package/lib/Link.d.cts +15 -15
- package/lib/Link.d.ts +15 -15
- package/lib/Link.js +1 -1
- package/lib/ListItem.d.cts +15 -15
- package/lib/ListItem.d.ts +15 -15
- package/lib/Mention.d.cts +15 -15
- package/lib/Mention.d.ts +15 -15
- package/lib/Mermaid.cjs +2 -2
- package/lib/Mermaid.d.cts +15 -15
- package/lib/Mermaid.d.ts +15 -15
- package/lib/Mermaid.js +138 -137
- package/lib/MoreMark.cjs +1 -1
- package/lib/MoreMark.d.cts +15 -15
- package/lib/MoreMark.d.ts +15 -15
- package/lib/MoreMark.js +1 -1
- package/lib/MultiColumn.cjs +1 -1
- package/lib/MultiColumn.d.cts +15 -15
- package/lib/MultiColumn.d.ts +15 -15
- package/lib/MultiColumn.js +1 -1
- package/lib/OrderedList.cjs +1 -1
- package/lib/OrderedList.d.cts +15 -15
- package/lib/OrderedList.d.ts +15 -15
- package/lib/OrderedList.js +1 -1
- package/lib/{RichTextEditor-C8Sm1E6J.cjs → RichTextEditor-DWlLqTl9.cjs} +4 -4
- package/lib/{RichTextEditor-BQN2eLD_.js → RichTextEditor-KP2Rgcqe.js} +15 -39
- package/lib/SearchAndReplace.cjs +1 -1
- package/lib/SearchAndReplace.d.cts +15 -15
- package/lib/SearchAndReplace.d.ts +15 -15
- package/lib/SearchAndReplace.js +68 -67
- package/lib/Selection.d.cts +15 -15
- package/lib/Selection.d.ts +15 -15
- package/lib/SlashCommand.cjs +1 -1
- package/lib/SlashCommand.d.cts +15 -15
- package/lib/SlashCommand.d.ts +15 -15
- package/lib/SlashCommand.js +1 -1
- package/lib/Strike.cjs +1 -1
- package/lib/Strike.d.cts +15 -15
- package/lib/Strike.d.ts +15 -15
- package/lib/Strike.js +1 -1
- package/lib/SubAndSuperScript.cjs +1 -1
- package/lib/SubAndSuperScript.d.cts +15 -15
- package/lib/SubAndSuperScript.d.ts +15 -15
- package/lib/SubAndSuperScript.js +1 -1
- package/lib/Table.cjs +1 -1
- package/lib/Table.d.cts +15 -15
- package/lib/Table.d.ts +15 -15
- package/lib/Table.js +2 -1
- package/lib/TableOfContent.cjs +1 -1
- package/lib/TableOfContent.d.cts +15 -15
- package/lib/TableOfContent.d.ts +15 -15
- package/lib/TableOfContent.js +50 -49
- package/lib/TaskList.cjs +1 -1
- package/lib/TaskList.d.cts +15 -15
- package/lib/TaskList.d.ts +15 -15
- package/lib/TaskList.js +1 -1
- package/lib/TextAlign.cjs +1 -1
- package/lib/TextAlign.d.cts +15 -15
- package/lib/TextAlign.d.ts +15 -15
- package/lib/TextAlign.js +8 -7
- package/lib/TextBubble.cjs +1 -1
- package/lib/TextBubble.d.cts +15 -15
- package/lib/TextBubble.d.ts +15 -15
- package/lib/TextBubble.js +1 -1
- package/lib/TextDirection.cjs +1 -1
- package/lib/TextDirection.d.cts +15 -15
- package/lib/TextDirection.d.ts +15 -15
- package/lib/TextDirection.js +14 -13
- package/lib/TextUnderline.cjs +1 -1
- package/lib/TextUnderline.d.cts +15 -15
- package/lib/TextUnderline.d.ts +15 -15
- package/lib/TextUnderline.js +1 -1
- package/lib/TrailingNode.d.cts +15 -15
- package/lib/TrailingNode.d.ts +15 -15
- package/lib/{Twitter-Dg6WWauX.js → Twitter-99ivY5qv.js} +62 -61
- package/lib/{Twitter-CL2pu4QM.cjs → Twitter-BvfvUtNT.cjs} +2 -2
- package/lib/Twitter.cjs +1 -1
- package/lib/Twitter.d.cts +15 -15
- package/lib/Twitter.d.ts +15 -15
- package/lib/Twitter.js +1 -1
- package/lib/Video.cjs +1 -1
- package/lib/Video.d.cts +15 -15
- package/lib/Video.d.ts +15 -15
- package/lib/Video.js +1 -1
- package/lib/bubble-extra.cjs +1 -1
- package/lib/bubble-extra.d.cts +15 -15
- package/lib/bubble-extra.d.ts +15 -15
- package/lib/bubble-extra.js +5 -5
- package/lib/index.cjs +1 -1
- package/lib/index.d.cts +16 -15
- package/lib/index.d.ts +16 -15
- package/lib/index.js +2 -2
- package/lib/locale-bundle.d.cts +15 -15
- package/lib/locale-bundle.d.ts +15 -15
- package/lib/{textarea-BglwYF6b.js → textarea-CktfkXNe.js} +1 -1
- package/lib/{textarea-D5WVZMgt.cjs → textarea-DdH64g04.cjs} +1 -1
- package/package.json +1 -1
- package/lib/Drawer-CmoEF-Zg.cjs +0 -1
- package/lib/Excalidraw-CM74U5tG.js +0 -289
- package/lib/Excalidraw-DAPP9qgY.cjs +0 -1
package/lib/SlashCommand.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const A=require("./index-ByRfqzMr.cjs"),O=require("./dom-dataset-Byuf1YmW.cjs"),q=require("./index-BI-IcZcN.cjs"),D=require("tippy.js"),f=require("react/jsx-runtime"),x=require("react"),b=require("./RichTextEditor-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const A=require("./index-ByRfqzMr.cjs"),O=require("./dom-dataset-Byuf1YmW.cjs"),q=require("./index-BI-IcZcN.cjs"),D=require("tippy.js"),f=require("react/jsx-runtime"),x=require("react"),b=require("./RichTextEditor-DWlLqTl9.cjs"),h=require("./index-D_A0TBRA.cjs");function P(i,d){var k,N;const[t,n]=x.useState(0),[e,o]=x.useState(0),r=x.useRef(null),{t:s}=h.useLocale(),u=x.useRef([]);x.useImperativeHandle(d,()=>({onKeyDown:g})),x.useEffect(()=>{if(!r.current)return;const l=e*1e3+t,c=u.current[l];c&&c.scrollIntoView({behavior:"smooth",block:"nearest"})},[t,e]);function g({event:l}){return l.key==="ArrowUp"?(C(),!0):l.key==="ArrowDown"?(R(),!0):l.key==="Enter"?(L(),!0):!1}function C(){var m;if(i.items.length===0)return!1;let l=t-1,c=e;l<0&&(c=e-1,l=((m=i.items[c])==null?void 0:m.commands.length)-1||0),c<0&&(c=i.items.length-1,l=i.items[c].commands.length-1),n(l),o(c)}function R(){if(i.items.length===0)return!1;const l=i.items[e].commands;let c=t+1,m=e;l.length-1<c&&(c=0,m=e+1),i.items.length-1<m&&(m=0),n(c),o(m)}function L(){if(i.items.length===0||e===-1||t===-1)return!1;v(e,t)}function v(l,c){const m=i.items[l].commands[c];i.command(m)}function H(l,c){v(l,c)}function I(l,c,m){u.current[l*1e3+c]=m}return f.jsx("div",{className:"richtext-mb-8 richtext-max-h-[min(80vh,24rem)] richtext-flex-wrap richtext-overflow-auto richtext-rounded-lg !richtext-border !richtext-border-neutral-200 !richtext-bg-white richtext-p-1 !richtext-text-black richtext-shadow-sm dark:!richtext-border-neutral-800 dark:!richtext-bg-black",ref:r,children:(k=i==null?void 0:i.items)!=null&&k.length?f.jsx("div",{className:"richtext-grid richtext-min-w-48 richtext-grid-cols-1 richtext-gap-0.5",children:(N=i==null?void 0:i.items)==null?void 0:N.map((l,c)=>f.jsxs(x.Fragment,{children:[f.jsx("div",{className:"richtext-col-[1/-1] richtext-mx-2 richtext-mt-2 richtext-select-none richtext-text-[0.65rem] richtext-font-semibold richtext-uppercase richtext-tracking-wider !richtext-text-neutral-500 first:richtext-mt-0.5",children:l.title}),l.commands.map((m,y)=>f.jsxs("button",{onClick:()=>H(c,y),ref:S=>I(c,y,S),className:b.cn("richtext-flex richtext-items-center richtext-gap-3 richtext-px-2 richtext-py-1.5 richtext-text-sm !richtext-text-neutral-800 dark:!richtext-text-neutral-200 richtext-text-left richtext-w-full richtext-rounded-sm richtext-outline-none richtext-transition-colors !richtext-bg-transparent hover:!richtext-bg-accent ",{"slash-command-active":e===c&&t===y}),children:[m.iconUrl&&f.jsx("img",{alt:"",className:"richtext-size-6",src:m.iconUrl}),m.iconName&&f.jsx(b.IconComponent,{className:"!richtext-mr-1 !richtext-text-lg",name:m.iconName}),m.label]},`command-${y}`))]},`slash-${l.title}`))}):f.jsx("div",{className:"richtext-p-3",children:f.jsx("span",{className:"richtext-text-xs richtext-text-gray-800 dark:richtext-text-gray-100",children:s("editor.slash.empty")})})})}const $=x.forwardRef(P),j={setOpen:(i,d)=>{b.dispatchEvent(b.EVENTS.UPLOAD_VIDEO(i),d)}};function B(i,d){const t=[{name:"format",title:h.localeActions.t("editor.slash.format"),commands:[]},{name:"insert",title:h.localeActions.t("editor.slash.insert"),commands:[]}];return i.forEach(n=>{n.name.toLowerCase()==="heading"&&n.options.levels.forEach(e=>{t[0].commands.push({name:`heading${e}`,label:h.localeActions.t(`editor.heading.h${e}.tooltip`),aliases:[`h${e}`,"bt",`bt${e}`],iconName:`Heading${e}`,action:({editor:o,range:r})=>{o.chain().focus().deleteRange(r).setHeading({level:e}).run()}})}),n.name.toLowerCase()==="bulletlist"&&t[0].commands.push({name:"bulletList",label:h.localeActions.t("editor.bulletlist.tooltip"),aliases:["ul","yxlb"],iconName:"List",action:({editor:e,range:o})=>{e.chain().focus().deleteRange(o).toggleBulletList().run()}}),n.name.toLowerCase()==="orderedlist"&&t[0].commands.push({name:"numberedList",label:h.localeActions.t("editor.orderedlist.tooltip"),aliases:["ol","yxlb"],iconName:"ListOrdered",action:({editor:e,range:o})=>{e.chain().focus().deleteRange(o).toggleOrderedList().run()}}),n.name.toLowerCase()==="tasklist"&&t[0].commands.push({name:"taskList",label:h.localeActions.t("editor.tasklist.tooltip"),iconName:"ListTodo",description:"Task list with todo items",aliases:["todo"],action:({editor:e,range:o})=>{e.chain().focus().deleteRange(o).toggleTaskList().run()}}),n.name.toLowerCase()==="blockquote"&&t[0].commands.push({name:"blockquote",label:h.localeActions.t("editor.blockquote.tooltip"),description:"插入引入格式",aliases:["yr"],iconName:"TextQuote",action:({editor:e,range:o})=>{e.chain().focus().deleteRange(o).setBlockquote().run()}}),n.name.toLowerCase()==="codeblock"&&t[0].commands.push({name:"codeBlock",label:h.localeActions.t("editor.codeblock.tooltip"),iconName:"Code2",description:"Code block with syntax highlighting",shouldBeHidden:e=>e.isActive("columns"),action:({editor:e,range:o})=>{e.chain().focus().deleteRange(o).setCodeBlock().run()}}),n.name.toLowerCase()===b.Image$1.name&&t[1].commands.push({name:"image",label:h.localeActions.t("editor.image.tooltip"),iconName:"ImageUp",description:"Insert a image",aliases:["image","tp","tupian"],shouldBeHidden:e=>e.isActive("columns"),action:({editor:e,range:o})=>{e.chain().focus().deleteRange(o).run(),b.actionDialogImage.setOpen(e.id,!0)}}),n.name.toLowerCase()===b.Video.name&&t[1].commands.push({name:"video",label:h.localeActions.t("editor.video.tooltip"),iconName:"Video",description:"Insert a video",aliases:["video","sp","shipin"],shouldBeHidden:e=>e.isActive("columns"),action:({editor:e,range:o})=>{e.chain().focus().deleteRange(o).run(),j.setOpen(e.id,!0)}}),n.name.toLowerCase()==="table"&&t[1].commands.push({name:"table",label:h.localeActions.t("editor.table.tooltip"),iconName:"Table",description:"Insert a table",aliases:["table","bg","biaoge","biao"],shouldBeHidden:e=>e.isActive("columns"),action:({editor:e,range:o})=>{e.chain().focus().deleteRange(o).insertTable({rows:3,cols:3,withHeaderRow:!1}).run()}}),n.name.toLowerCase()==="horizontalrule"&&t[1].commands.push({name:"horizontalRule",label:h.localeActions.t("editor.horizontalrule.tooltip"),iconName:"Minus",description:"Insert a horizontal divider",aliases:["hr","fgx","fg"],action:({editor:e,range:o})=>{e.chain().focus().deleteRange(o).setHorizontalRule().run()}}),n.name.toLowerCase()==="columns"&&t[1].commands.push({name:"columns",label:h.localeActions.t("editor.columns.tooltip"),iconName:"Columns2",description:"Add two column content",action:({editor:e})=>{e.chain().focus().insertColumns({cols:2}).run()}}),d==null||d(n,t)}),t}const w="slashCommand";let a;const E=A.Extension.create({name:w,priority:200,onCreate(){a=D("body",{interactive:!0,trigger:"manual",placement:"bottom-start",theme:"slash-command",maxWidth:"16rem",offset:[16,8],popperOptions:{strategy:"fixed",modifiers:[{name:"flip",enabled:!1}]}})},addProseMirrorPlugins(){return[q.Suggestion({editor:this.editor,char:"/",allowSpaces:!0,startOfLine:!0,pluginKey:new A.PluginKey(w),allow:({state:i,range:d})=>{var g,C,R;const t=i.doc.resolve(d.from),n=t.depth===1,e=t.parent.type.name==="paragraph",o=((g=t.parent.textContent)==null?void 0:g.charAt(0))==="/",r=this.editor.isActive("column"),s=(R=t.parent.textContent)==null?void 0:R.slice(Math.max(0,(C=t.parent.textContent)==null?void 0:C.indexOf("/"))),u=!(s!=null&&s.endsWith(" "));return(n&&e&&o||r&&e&&o)&&u},command:({editor:i,range:d,props:t})=>{const{view:n}=i;t.action({editor:i,range:d}),n.focus()},items:({query:i,editor:d})=>B(d.extensionManager.extensions,this.options.renderGroupItem).map(r=>({...r,commands:r.commands.filter(s=>{const u=s.label.toLowerCase().trim(),g=i.toLowerCase().trim();if(s.aliases){const C=s.aliases.map(v=>v.toLowerCase().trim()),R=u.match(g),L=C.some(v=>v.match(g));return R||L}return u.match(g)}).filter(s=>s.shouldBeHidden?!s.shouldBeHidden(this.editor):!0)})).filter(r=>r.commands.length>0).map(r=>({...r,commands:r.commands.map(s=>({...s,isEnabled:!0}))})),render:()=>{let i,d=null;return{onStart:t=>{var o;i=new O.ReactRenderer($,{props:t,editor:t.editor});const{view:n}=t.editor,e=()=>{if(!t.clientRect)return t.editor.storage[w].rect;const r=t.clientRect();if(!r)return t.editor.storage[w].rect;let s=r.y;if(r.top+i.element.offsetHeight+40>window.innerHeight){const u=r.top+i.element.offsetHeight-window.innerHeight+40;s=r.y-u}return new DOMRect(r.x,s,r.width,r.height)};d=()=>{a==null||a[0].setProps({getReferenceClientRect:e})},(o=n.dom.parentElement)==null||o.addEventListener("scroll",d),a==null||a[0].setProps({getReferenceClientRect:e,appendTo:()=>document.body,content:i.element}),a==null||a[0].show()},onUpdate(t){var r;i.updateProps(t);const{view:n}=t.editor,e=()=>{if(!t.clientRect)return t.editor.storage[w].rect;const s=t.clientRect();return s?new DOMRect(s.x,s.y,s.width,s.height):t.editor.storage[w].rect},o=()=>{a==null||a[0].setProps({getReferenceClientRect:e})};(r=n.dom.parentElement)==null||r.addEventListener("scroll",o),t.editor.storage[w].rect=t.clientRect?e():{width:0,height:0,left:0,top:0,right:0,bottom:0},a==null||a[0].setProps({getReferenceClientRect:e})},onKeyDown(t){var n;return t.event.key==="Escape"?(a==null||a[0].hide(),!0):(a!=null&&a[0].state.isShown||a==null||a[0].show(),(n=i.ref)==null?void 0:n.onKeyDown(t))},onExit(t){var n;if(a==null||a[0].hide(),d){const{view:e}=t.editor;(n=e.dom.parentElement)==null||n.removeEventListener("scroll",d)}i.destroy()}}}})]},addStorage(){return{rect:{width:0,height:0,left:0,top:0,right:0,bottom:0}}}});exports.SlashCommand=E;exports.default=E;
|
package/lib/SlashCommand.d.cts
CHANGED
|
@@ -140,6 +140,21 @@ declare module '@tiptap/core' {
|
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
|
|
143
|
+
declare module '@tiptap/core' {
|
|
144
|
+
interface Commands<ReturnType> {
|
|
145
|
+
iframe: {
|
|
146
|
+
/**
|
|
147
|
+
* Add an iframe
|
|
148
|
+
*/
|
|
149
|
+
setIframe: (options: {
|
|
150
|
+
src: string;
|
|
151
|
+
service: string;
|
|
152
|
+
}) => ReturnType;
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
|
|
143
158
|
declare module '@tiptap/core' {
|
|
144
159
|
interface Commands<ReturnType> {
|
|
145
160
|
imageUpload: {
|
|
@@ -160,21 +175,6 @@ declare module '@tiptap/core' {
|
|
|
160
175
|
}
|
|
161
176
|
|
|
162
177
|
|
|
163
|
-
declare module '@tiptap/core' {
|
|
164
|
-
interface Commands<ReturnType> {
|
|
165
|
-
iframe: {
|
|
166
|
-
/**
|
|
167
|
-
* Add an iframe
|
|
168
|
-
*/
|
|
169
|
-
setIframe: (options: {
|
|
170
|
-
src: string;
|
|
171
|
-
service: string;
|
|
172
|
-
}) => ReturnType;
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
|
|
178
178
|
declare module '@tiptap/core' {
|
|
179
179
|
interface Commands<ReturnType> {
|
|
180
180
|
imageGifUpload: {
|
package/lib/SlashCommand.d.ts
CHANGED
|
@@ -140,6 +140,21 @@ declare module '@tiptap/core' {
|
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
|
|
143
|
+
declare module '@tiptap/core' {
|
|
144
|
+
interface Commands<ReturnType> {
|
|
145
|
+
iframe: {
|
|
146
|
+
/**
|
|
147
|
+
* Add an iframe
|
|
148
|
+
*/
|
|
149
|
+
setIframe: (options: {
|
|
150
|
+
src: string;
|
|
151
|
+
service: string;
|
|
152
|
+
}) => ReturnType;
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
|
|
143
158
|
declare module '@tiptap/core' {
|
|
144
159
|
interface Commands<ReturnType> {
|
|
145
160
|
imageUpload: {
|
|
@@ -160,21 +175,6 @@ declare module '@tiptap/core' {
|
|
|
160
175
|
}
|
|
161
176
|
|
|
162
177
|
|
|
163
|
-
declare module '@tiptap/core' {
|
|
164
|
-
interface Commands<ReturnType> {
|
|
165
|
-
iframe: {
|
|
166
|
-
/**
|
|
167
|
-
* Add an iframe
|
|
168
|
-
*/
|
|
169
|
-
setIframe: (options: {
|
|
170
|
-
src: string;
|
|
171
|
-
service: string;
|
|
172
|
-
}) => ReturnType;
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
|
|
178
178
|
declare module '@tiptap/core' {
|
|
179
179
|
interface Commands<ReturnType> {
|
|
180
180
|
imageGifUpload: {
|
package/lib/SlashCommand.js
CHANGED
|
@@ -4,7 +4,7 @@ import { S as P } from "./index-CbQQFj2T.js";
|
|
|
4
4
|
import B from "tippy.js";
|
|
5
5
|
import { jsx as g, jsxs as k } from "react/jsx-runtime";
|
|
6
6
|
import { forwardRef as $, useState as N, useRef as E, useImperativeHandle as z, useEffect as M, Fragment as T } from "react";
|
|
7
|
-
import { d as V, k as U, q, E as K, R as G, U as F, V as j } from "./RichTextEditor-
|
|
7
|
+
import { d as V, k as U, q, E as K, R as G, U as F, V as j } from "./RichTextEditor-KP2Rgcqe.js";
|
|
8
8
|
import { u as W, n as h } from "./index-CsK90iVd.js";
|
|
9
9
|
function Q(i, m) {
|
|
10
10
|
var L, v;
|
package/lib/Strike.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-ByRfqzMr.cjs"),i=require("./RichTextEditor-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-ByRfqzMr.cjs"),i=require("./RichTextEditor-DWlLqTl9.cjs"),o=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,a=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,u=e.Mark.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",e.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[e.markInputRule({find:o,type:this.type})]},addPasteRules(){return[e.markPasteRule({find:a,type:this.type})]}}),d=u.extend({addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),button:({editor:r,t:s,extension:n})=>({component:i.ActionButton,componentProps:{action:()=>r.commands.toggleStrike(),isActive:()=>r.isActive("strike")||!1,disabled:!1,icon:"Strikethrough",shortcutKeys:n.options.shortcutKeys??["shift","mod","S"],tooltip:s("editor.strike.tooltip")}})}}});exports.Strike=d;
|
package/lib/Strike.d.cts
CHANGED
|
@@ -186,6 +186,21 @@ declare module '@tiptap/core' {
|
|
|
186
186
|
}
|
|
187
187
|
|
|
188
188
|
|
|
189
|
+
declare module '@tiptap/core' {
|
|
190
|
+
interface Commands<ReturnType> {
|
|
191
|
+
iframe: {
|
|
192
|
+
/**
|
|
193
|
+
* Add an iframe
|
|
194
|
+
*/
|
|
195
|
+
setIframe: (options: {
|
|
196
|
+
src: string;
|
|
197
|
+
service: string;
|
|
198
|
+
}) => ReturnType;
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
|
|
189
204
|
declare module '@tiptap/core' {
|
|
190
205
|
interface Commands<ReturnType> {
|
|
191
206
|
imageUpload: {
|
|
@@ -206,21 +221,6 @@ declare module '@tiptap/core' {
|
|
|
206
221
|
}
|
|
207
222
|
|
|
208
223
|
|
|
209
|
-
declare module '@tiptap/core' {
|
|
210
|
-
interface Commands<ReturnType> {
|
|
211
|
-
iframe: {
|
|
212
|
-
/**
|
|
213
|
-
* Add an iframe
|
|
214
|
-
*/
|
|
215
|
-
setIframe: (options: {
|
|
216
|
-
src: string;
|
|
217
|
-
service: string;
|
|
218
|
-
}) => ReturnType;
|
|
219
|
-
};
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
|
|
224
224
|
declare module '@tiptap/core' {
|
|
225
225
|
interface Commands<ReturnType> {
|
|
226
226
|
imageGifUpload: {
|
package/lib/Strike.d.ts
CHANGED
|
@@ -186,6 +186,21 @@ declare module '@tiptap/core' {
|
|
|
186
186
|
}
|
|
187
187
|
|
|
188
188
|
|
|
189
|
+
declare module '@tiptap/core' {
|
|
190
|
+
interface Commands<ReturnType> {
|
|
191
|
+
iframe: {
|
|
192
|
+
/**
|
|
193
|
+
* Add an iframe
|
|
194
|
+
*/
|
|
195
|
+
setIframe: (options: {
|
|
196
|
+
src: string;
|
|
197
|
+
service: string;
|
|
198
|
+
}) => ReturnType;
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
|
|
189
204
|
declare module '@tiptap/core' {
|
|
190
205
|
interface Commands<ReturnType> {
|
|
191
206
|
imageUpload: {
|
|
@@ -206,21 +221,6 @@ declare module '@tiptap/core' {
|
|
|
206
221
|
}
|
|
207
222
|
|
|
208
223
|
|
|
209
|
-
declare module '@tiptap/core' {
|
|
210
|
-
interface Commands<ReturnType> {
|
|
211
|
-
iframe: {
|
|
212
|
-
/**
|
|
213
|
-
* Add an iframe
|
|
214
|
-
*/
|
|
215
|
-
setIframe: (options: {
|
|
216
|
-
src: string;
|
|
217
|
-
service: string;
|
|
218
|
-
}) => ReturnType;
|
|
219
|
-
};
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
|
|
224
224
|
declare module '@tiptap/core' {
|
|
225
225
|
interface Commands<ReturnType> {
|
|
226
226
|
imageGifUpload: {
|
package/lib/Strike.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { M as n, c as i, d as o, m as a } from "./index-DI9T3iLd.js";
|
|
2
|
-
import { A as u } from "./RichTextEditor-
|
|
2
|
+
import { A as u } from "./RichTextEditor-KP2Rgcqe.js";
|
|
3
3
|
const d = /(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/, m = /(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g, p = n.create({
|
|
4
4
|
name: "strike",
|
|
5
5
|
addOptions() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("./index-ByRfqzMr.cjs"),n=require("./index-Z4b9rzn-.cjs"),e=require("./RichTextEditor-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("./index-ByRfqzMr.cjs"),n=require("./index-Z4b9rzn-.cjs"),e=require("./RichTextEditor-DWlLqTl9.cjs"),l=b.Extension.create({name:"subAndSuperScript",addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),button:({editor:s,extension:o,t:p})=>{const c=o.options.subscript,r=o.options.superscript,u={component:e.ActionButton,componentProps:{action:()=>s.commands.toggleSubscript(),isActive:()=>s.isActive("subscript")||!1,disabled:!s.can().toggleSubscript(),icon:"Subscript",tooltip:p("editor.subscript.tooltip")}},a={component:e.ActionButton,componentProps:{action:()=>s.commands.toggleSuperscript(),isActive:()=>s.isActive("superscript")||!1,disabled:!s.can().toggleSuperscript(),icon:"Superscript",tooltip:p("editor.superscript.tooltip")}},i=[];return c!==!1&&i.push(u),r!==!1&&i.push(a),i}}},addExtensions(){const t=[];return this.options.subscript!==!1&&t.push(n.Subscript.configure(this.options.subscript)),this.options.superscript!==!1&&t.push(n.Superscript.configure(this.options.superscript)),t}});exports.SubAndSuperScript=l;
|
|
@@ -201,6 +201,21 @@ declare module '@tiptap/core' {
|
|
|
201
201
|
}
|
|
202
202
|
|
|
203
203
|
|
|
204
|
+
declare module '@tiptap/core' {
|
|
205
|
+
interface Commands<ReturnType> {
|
|
206
|
+
iframe: {
|
|
207
|
+
/**
|
|
208
|
+
* Add an iframe
|
|
209
|
+
*/
|
|
210
|
+
setIframe: (options: {
|
|
211
|
+
src: string;
|
|
212
|
+
service: string;
|
|
213
|
+
}) => ReturnType;
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
|
|
204
219
|
declare module '@tiptap/core' {
|
|
205
220
|
interface Commands<ReturnType> {
|
|
206
221
|
imageUpload: {
|
|
@@ -221,21 +236,6 @@ declare module '@tiptap/core' {
|
|
|
221
236
|
}
|
|
222
237
|
|
|
223
238
|
|
|
224
|
-
declare module '@tiptap/core' {
|
|
225
|
-
interface Commands<ReturnType> {
|
|
226
|
-
iframe: {
|
|
227
|
-
/**
|
|
228
|
-
* Add an iframe
|
|
229
|
-
*/
|
|
230
|
-
setIframe: (options: {
|
|
231
|
-
src: string;
|
|
232
|
-
service: string;
|
|
233
|
-
}) => ReturnType;
|
|
234
|
-
};
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
|
|
239
239
|
declare module '@tiptap/core' {
|
|
240
240
|
interface Commands<ReturnType> {
|
|
241
241
|
imageGifUpload: {
|
|
@@ -201,6 +201,21 @@ declare module '@tiptap/core' {
|
|
|
201
201
|
}
|
|
202
202
|
|
|
203
203
|
|
|
204
|
+
declare module '@tiptap/core' {
|
|
205
|
+
interface Commands<ReturnType> {
|
|
206
|
+
iframe: {
|
|
207
|
+
/**
|
|
208
|
+
* Add an iframe
|
|
209
|
+
*/
|
|
210
|
+
setIframe: (options: {
|
|
211
|
+
src: string;
|
|
212
|
+
service: string;
|
|
213
|
+
}) => ReturnType;
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
|
|
204
219
|
declare module '@tiptap/core' {
|
|
205
220
|
interface Commands<ReturnType> {
|
|
206
221
|
imageUpload: {
|
|
@@ -221,21 +236,6 @@ declare module '@tiptap/core' {
|
|
|
221
236
|
}
|
|
222
237
|
|
|
223
238
|
|
|
224
|
-
declare module '@tiptap/core' {
|
|
225
|
-
interface Commands<ReturnType> {
|
|
226
|
-
iframe: {
|
|
227
|
-
/**
|
|
228
|
-
* Add an iframe
|
|
229
|
-
*/
|
|
230
|
-
setIframe: (options: {
|
|
231
|
-
src: string;
|
|
232
|
-
service: string;
|
|
233
|
-
}) => ReturnType;
|
|
234
|
-
};
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
|
|
239
239
|
declare module '@tiptap/core' {
|
|
240
240
|
interface Commands<ReturnType> {
|
|
241
241
|
imageGifUpload: {
|
package/lib/SubAndSuperScript.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { E as a } from "./index-DI9T3iLd.js";
|
|
2
2
|
import { S as b, a as l } from "./index-LUL9mqY4.js";
|
|
3
|
-
import { A as r } from "./RichTextEditor-
|
|
3
|
+
import { A as r } from "./RichTextEditor-KP2Rgcqe.js";
|
|
4
4
|
const g = /* @__PURE__ */ a.create({
|
|
5
5
|
name: "subAndSuperScript",
|
|
6
6
|
addOptions() {
|
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-C8Sm1E6J.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-DWlLqTl9.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,tooltipOptions:t==null?void 0:t.tooltipOptions,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 {
|