zt-react-milkdown 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{dist-Cxaq2crg.js → commands-BJpevWrH.js} +123 -123
- package/dist/commands-BmZHd6RL.js +2 -0
- package/dist/{dist-CPVooDwj.cjs → commands-CM7IuhpT.cjs} +2 -2
- package/dist/commands-f4yOm8DQ.cjs +1 -0
- package/dist/{debounce-Bqj_3iJs.cjs → debounce-C_TNzOFT.cjs} +1 -1
- package/dist/{dist-DaM7GJv6.js → dist-CLTsQjPD.js} +319 -318
- package/dist/{dist-CxZn1qUo.js → dist-CZTw9GLV.js} +198 -198
- package/dist/dist-DQnWlYyo.cjs +5 -0
- package/dist/dist-ZPtYoqTI.cjs +1 -0
- package/dist/floating-ui.dom-CV-TLBRq.cjs +1 -0
- package/dist/floating-ui.dom-CoOubeUs.js +762 -0
- package/dist/index.cjs +25 -149
- package/dist/index.mjs +6235 -15737
- package/dist/{lib-C8xOD1Bp.cjs → lib-5pUyY-Tl.cjs} +1 -1
- package/dist/{lib-DkE7Uq2b.js → lib-Bhr5EVOu.js} +110 -112
- package/dist/lib-BmAQCwSQ.cjs +1 -0
- package/dist/{lib-wmHesNI0.js → lib-C1A-pN4b.js} +574 -575
- package/dist/lib-CVebEyb8.cjs +4 -0
- package/dist/lib-ChwoE6v5.js +331 -0
- package/dist/lib-DIx8C5AZ.cjs +1 -0
- package/dist/lib-DVE2k9i1.js +387 -0
- package/dist/{lib-DzK_kn7a.js → lib-D_0WAhKU.js} +3 -3
- package/dist/{lib-m8lKZKxK.js → lib-Dd20rlmV.js} +28 -28
- package/dist/lib-De0djIEV.cjs +5 -0
- package/dist/{lib-D4HMdvmK.cjs → lib-DgEwQN1U.cjs} +1 -1
- package/dist/{dist-Dhukmh4L.js → lib-DmD940Fq.js} +2849 -1735
- package/dist/lib-Dplx6t-N.cjs +3 -0
- package/dist/lib-DzY83R_P.cjs +39 -0
- package/dist/lib-F08NY8fk.cjs +1 -0
- package/dist/{lib-B0rHJ9lJ.js → lib-_NDReOAt.js} +3 -3
- package/dist/{lib-CK9MEMX-.js → lib-bsXGz3fj.js} +28 -27
- package/dist/schema-list-D9Q6QKgo.cjs +1 -0
- package/dist/schema-list-DooYP5HM.js +110 -0
- package/dist/src/core/createEditor.d.ts.map +1 -1
- package/dist/src/local/en-US.d.ts.map +1 -1
- package/dist/src/local/zh-CN.d.ts.map +1 -1
- package/dist/src/plugins/custom/block-transform/block-transform.d.ts +15 -0
- package/dist/src/plugins/custom/block-transform/block-transform.d.ts.map +1 -0
- package/dist/src/plugins/custom/block-transform/index.d.ts +2 -0
- package/dist/src/plugins/custom/block-transform/index.d.ts.map +1 -0
- package/dist/src/plugins/custom/math/index.d.ts +6 -0
- package/dist/src/plugins/custom/math/index.d.ts.map +1 -1
- package/dist/src/plugins/custom/math/math-block-editable.d.ts.map +1 -1
- package/dist/src/plugins/custom/math/math-inline-arrow-navigation.d.ts +5 -0
- package/dist/src/plugins/custom/math/math-inline-arrow-navigation.d.ts.map +1 -0
- package/dist/src/plugins/custom/math/math-inline-edit-plugin.d.ts +29 -0
- package/dist/src/plugins/custom/math/math-inline-edit-plugin.d.ts.map +1 -0
- package/dist/src/plugins/custom/math/math-inline-editable.d.ts +7 -0
- package/dist/src/plugins/custom/math/math-inline-editable.d.ts.map +1 -0
- package/dist/src/plugins/custom/math/math-plugin.d.ts.map +1 -1
- package/dist/src/plugins/custom/selection-tooltip/constants.d.ts +5 -1
- package/dist/src/plugins/custom/selection-tooltip/constants.d.ts.map +1 -1
- package/dist/src/plugins/custom/selection-tooltip/index.d.ts.map +1 -1
- package/dist/src/plugins/custom/selection-tooltip/tooltip-view.d.ts +34 -3
- package/dist/src/plugins/custom/selection-tooltip/tooltip-view.d.ts.map +1 -1
- package/dist/src/plugins/custom/selection-tooltip/types.d.ts +16 -1
- package/dist/src/plugins/custom/selection-tooltip/types.d.ts.map +1 -1
- package/dist/src/plugins/custom/slash-menu/slash-menu-commands.d.ts.map +1 -1
- package/dist/src/plugins/custom/slash-menu/slash-menu-logic.d.ts +4 -0
- package/dist/src/plugins/custom/slash-menu/slash-menu-logic.d.ts.map +1 -1
- package/dist/src/plugins/custom/slash-menu/slash-menu-view.d.ts.map +1 -1
- package/dist/src/plugins/custom/slash-menu/slash-menu.d.ts.map +1 -1
- package/dist/src/plugins/preset-common.d.ts +6 -0
- package/dist/src/plugins/preset-common.d.ts.map +1 -1
- package/dist/src/react/hooks/useMilkdownEditor.d.ts +2 -2
- package/dist/src/react/hooks/useMilkdownEditor.d.ts.map +1 -1
- package/dist/src/types/editor.d.ts +35 -5
- package/dist/src/types/editor.d.ts.map +1 -1
- package/dist/state-BC1dqWPQ.cjs +1 -0
- package/dist/state-BvRk9kiK.cjs +0 -0
- package/dist/state-BvRk9kiK.js +0 -0
- package/dist/state-rTW_1XVf.js +3 -0
- package/dist/style.css +2 -2
- package/package.json +1 -1
- package/dist/commands-CDrea4WB.cjs +0 -1
- package/dist/commands-DoqeX5uJ.js +0 -36
- package/dist/dist-BCCSKc3M.cjs +0 -5
- package/dist/dist-C0PSMrs7.cjs +0 -37
- package/dist/dist-mOpTMw1E.cjs +0 -1
- package/dist/floating-ui.dom-CKbcbmJV.js +0 -883
- package/dist/floating-ui.dom-VaZZ2gzS.cjs +0 -1
- package/dist/index.browser-5LtNN9G9.cjs +0 -1
- package/dist/index.browser-D2DmEB8o.js +0 -26
- package/dist/lib-38nxOnTd.cjs +0 -4
- package/dist/lib-8Tr6mAln.cjs +0 -1
- package/dist/lib-BJgvZywM.cjs +0 -3
- package/dist/lib-BNOSyYeU.cjs +0 -3
- package/dist/lib-C5AzmhNY.cjs +0 -5
- package/dist/lib-CCUU16r8.js +0 -1081
- package/dist/lib-DWZA8C0h.cjs +0 -1
- package/dist/lib-Dbe-cVjv.js +0 -367
- package/dist/lib-IahjxPWM.cjs +0 -3
- package/dist/lib-r5eNG0sa.js +0 -754
- package/dist/rolldown-runtime-CerMd-t8.cjs +0 -1
- package/dist/rolldown-runtime-DnwLefa7.js +0 -23
- package/dist/schema-list-DSdBEAWW.js +0 -171
- package/dist/schema-list-bL8FNes5.cjs +0 -1
- package/dist/state-CHAiIqOA.cjs +0 -1
- package/dist/state-DNxqltZl.js +0 -16
- /package/dist/{debounce-Cuk3VGPr.js → debounce-Z8-khnlZ.js} +0 -0
package/dist/dist-mOpTMw1E.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=require(`./dist-BCCSKc3M.cjs`),t=require(`./dist-C0PSMrs7.cjs`);var n,r;if(typeof WeakMap<`u`){let e=new WeakMap;n=t=>e.get(t),r=(t,n)=>(e.set(t,n),n)}else{let e=[],t=0;n=t=>{for(let n=0;n<e.length;n+=2)if(e[n]==t)return e[n+1]},r=(n,r)=>(t==10&&(t=0),e[t++]=n,e[t++]=r)}var i=class{constructor(e,t,n,r){this.width=e,this.height=t,this.map=n,this.problems=r}findCell(e){for(let t=0;t<this.map.length;t++){let n=this.map[t];if(n!=e)continue;let r=t%this.width,i=t/this.width|0,a=r+1,o=i+1;for(let e=1;a<this.width&&this.map[t+e]==n;e++)a++;for(let e=1;o<this.height&&this.map[t+this.width*e]==n;e++)o++;return{left:r,top:i,right:a,bottom:o}}throw RangeError(`No cell with offset ${e} found`)}colCount(e){for(let t=0;t<this.map.length;t++)if(this.map[t]==e)return t%this.width;throw RangeError(`No cell with offset ${e} found`)}nextCell(e,t,n){let{left:r,right:i,top:a,bottom:o}=this.findCell(e);return t==`horiz`?(n<0?r==0:i==this.width)?null:this.map[a*this.width+(n<0?r-1:i)]:(n<0?a==0:o==this.height)?null:this.map[r+this.width*(n<0?a-1:o)]}rectBetween(e,t){let{left:n,right:r,top:i,bottom:a}=this.findCell(e),{left:o,right:s,top:c,bottom:l}=this.findCell(t);return{left:Math.min(n,o),top:Math.min(i,c),right:Math.max(r,s),bottom:Math.max(a,l)}}cellsInRect(e){let t=[],n={};for(let r=e.top;r<e.bottom;r++)for(let i=e.left;i<e.right;i++){let a=r*this.width+i,o=this.map[a];n[o]||(n[o]=!0,!(i==e.left&&i&&this.map[a-1]==o||r==e.top&&r&&this.map[a-this.width]==o)&&t.push(o))}return t}positionAt(e,t,n){for(let r=0,i=0;;r++){let a=i+n.child(r).nodeSize;if(r==e){let n=t+e*this.width,r=(e+1)*this.width;for(;n<r&&this.map[n]<i;)n++;return n==r?a-1:this.map[n]}i=a}}static get(e){return n(e)||r(e,a(e))}};function a(e){if(e.type.spec.tableRole!=`table`)throw RangeError(`Not a table node: `+e.type.name);let t=o(e),n=e.childCount,r=[],a=0,c=null,l=[];for(let e=0,i=t*n;e<i;e++)r[e]=0;for(let i=0,o=0;i<n;i++){let s=e.child(i);o++;for(let e=0;;e++){for(;a<r.length&&r[a]!=0;)a++;if(e==s.childCount)break;let u=s.child(e),{colspan:d,rowspan:f,colwidth:p}=u.attrs;for(let e=0;e<f;e++){if(e+i>=n){(c||=[]).push({type:`overlong_rowspan`,pos:o,n:f-e});break}let s=a+e*t;for(let e=0;e<d;e++){r[s+e]==0?r[s+e]=o:(c||=[]).push({type:`collision`,row:i,pos:o,n:d-e});let n=p&&p[e];if(n){let r=(s+e)%t*2,i=l[r];i==null||i!=n&&l[r+1]==1?(l[r]=n,l[r+1]=1):i==n&&l[r+1]++}}}a+=d,o+=u.nodeSize}let u=(i+1)*t,d=0;for(;a<u;)r[a++]==0&&d++;d&&(c||=[]).push({type:`missing`,row:i,n:d}),o++}(t===0||n===0)&&(c||=[]).push({type:`zero_sized`});let u=new i(t,n,r,c),d=!1;for(let e=0;!d&&e<l.length;e+=2)l[e]!=null&&l[e+1]<n&&(d=!0);return d&&s(u,l,e),u}function o(e){let t=-1,n=!1;for(let r=0;r<e.childCount;r++){let i=e.child(r),a=0;if(n)for(let t=0;t<r;t++){let n=e.child(t);for(let e=0;e<n.childCount;e++){let i=n.child(e);t+i.attrs.rowspan>r&&(a+=i.attrs.colspan)}}for(let e=0;e<i.childCount;e++){let t=i.child(e);a+=t.attrs.colspan,t.attrs.rowspan>1&&(n=!0)}t==-1?t=a:t!=a&&(t=Math.max(t,a))}return t}function s(e,t,n){e.problems||=[];let r={};for(let i=0;i<e.map.length;i++){let a=e.map[i];if(r[a])continue;r[a]=!0;let o=n.nodeAt(a);if(!o)throw RangeError(`No cell with offset ${a} found`);let s=null,l=o.attrs;for(let n=0;n<l.colspan;n++){let r=t[(i+n)%e.width*2];r!=null&&(!l.colwidth||l.colwidth[n]!=r)&&((s||=c(l))[n]=r)}s&&e.problems.unshift({type:`colwidth mismatch`,pos:a,colwidth:s})}}function c(e){if(e.colwidth)return e.colwidth.slice();let t=[];for(let n=0;n<e.colspan;n++)t.push(0);return t}function l(e,t){if(typeof e==`string`)return{};let n=e.getAttribute(`data-colwidth`),r=n&&/^\d+(,\d+)*$/.test(n)?n.split(`,`).map(e=>Number(e)):null,i=Number(e.getAttribute(`colspan`)||1),a={colspan:i,rowspan:Number(e.getAttribute(`rowspan`)||1),colwidth:r&&r.length==i?r:null};for(let n in t){let r=t[n].getFromDOM,i=r&&r(e);i!=null&&(a[n]=i)}return a}function u(e,t){let n={};e.attrs.colspan!=1&&(n.colspan=e.attrs.colspan),e.attrs.rowspan!=1&&(n.rowspan=e.attrs.rowspan),e.attrs.colwidth&&(n[`data-colwidth`]=e.attrs.colwidth.join(`,`));for(let r in t){let i=t[r].setDOMAttr;i&&i(e.attrs[r],n)}return n}function d(e){if(e!==null){if(!Array.isArray(e))throw TypeError(`colwidth must be null or an array`);for(let t of e)if(typeof t!=`number`)throw TypeError(`colwidth must be null or an array of numbers`)}}function f(e){let t=e.cellAttributes||{},n={colspan:{default:1,validate:`number`},rowspan:{default:1,validate:`number`},colwidth:{default:null,validate:d}};for(let e in t)n[e]={default:t[e].default,validate:t[e].validate};return{table:{content:`table_row+`,tableRole:`table`,isolating:!0,group:e.tableGroup,parseDOM:[{tag:`table`}],toDOM(){return[`table`,[`tbody`,0]]}},table_row:{content:`(table_cell | table_header)*`,tableRole:`row`,parseDOM:[{tag:`tr`}],toDOM(){return[`tr`,0]}},table_cell:{content:e.cellContent,attrs:n,tableRole:`cell`,isolating:!0,parseDOM:[{tag:`td`,getAttrs:e=>l(e,t)}],toDOM(e){return[`td`,u(e,t),0]}},table_header:{content:e.cellContent,attrs:n,tableRole:`header_cell`,isolating:!0,parseDOM:[{tag:`th`,getAttrs:e=>l(e,t)}],toDOM(e){return[`th`,u(e,t),0]}}}}function p(e){let t=e.cached.tableNodeTypes;if(!t){t=e.cached.tableNodeTypes={};for(let n in e.nodes){let r=e.nodes[n],i=r.spec.tableRole;i&&(t[i]=r)}}return t}var m=new e.a(`selectingCells`);function h(e){for(let t=e.depth-1;t>0;t--)if(e.node(t).type.spec.tableRole==`row`)return e.node(0).resolve(e.before(t+1));return null}function g(e){let t=e.selection.$head;for(let e=t.depth;e>0;e--)if(t.node(e).type.spec.tableRole==`row`)return!0;return!1}function _(e){let t=e.selection;if(`$anchorCell`in t&&t.$anchorCell)return t.$anchorCell.pos>t.$headCell.pos?t.$anchorCell:t.$headCell;if(`node`in t&&t.node&&t.node.type.spec.tableRole==`cell`)return t.$anchor;let n=h(t.$head)||ee(t.$head);if(n)return n;throw RangeError(`No cell found around position ${t.head}`)}function ee(e){for(let t=e.nodeAfter,n=e.pos;t;t=t.firstChild,n++){let r=t.type.spec.tableRole;if(r==`cell`||r==`header_cell`)return e.doc.resolve(n)}for(let t=e.nodeBefore,n=e.pos;t;t=t.lastChild,n--){let r=t.type.spec.tableRole;if(r==`cell`||r==`header_cell`)return e.doc.resolve(n-t.nodeSize)}}function v(e){return e.parent.type.spec.tableRole==`row`&&!!e.nodeAfter}function te(e){return e.node(0).resolve(e.pos+e.nodeAfter.nodeSize)}function y(e,t){return e.depth==t.depth&&e.pos>=t.start(-1)&&e.pos<=t.end(-1)}function b(e,t,n){let r=e.node(-1),a=i.get(r),o=e.start(-1),s=a.nextCell(e.pos-o,t,n);return s==null?null:e.node(0).resolve(o+s)}function x(e,t,n=1){let r={...e,colspan:e.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(t,n),r.colwidth.some(e=>e>0)||(r.colwidth=null)),r}function ne(e,t,n=1){let r={...e,colspan:e.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let e=0;e<n;e++)r.colwidth.splice(t,0,0)}return r}function re(e,t,n){let r=p(t.type.schema).header_cell;for(let i=0;i<e.height;i++)if(t.nodeAt(e.map[n+i*e.width]).type!=r)return!1;return!0}var S=class t extends e.o{constructor(t,n=t){let r=t.node(-1),a=i.get(r),o=t.start(-1),s=a.rectBetween(t.pos-o,n.pos-o),c=t.node(0),l=a.cellsInRect(s).filter(e=>e!=n.pos-o);l.unshift(n.pos-o);let u=l.map(t=>{let n=r.nodeAt(t);if(!n)throw RangeError(`No cell with offset ${t} found`);let i=o+t+1;return new e.s(c.resolve(i),c.resolve(i+n.content.size))});super(u[0].$from,u[0].$to,u),this.$anchorCell=t,this.$headCell=n}map(n,r){let i=n.resolve(r.map(this.$anchorCell.pos)),a=n.resolve(r.map(this.$headCell.pos));if(v(i)&&v(a)&&y(i,a)){let e=this.$anchorCell.node(-1)!=i.node(-1);return e&&this.isRowSelection()?t.rowSelection(i,a):e&&this.isColSelection()?t.colSelection(i,a):new t(i,a)}return e.c.between(i,a)}content(){let t=this.$anchorCell.node(-1),n=i.get(t),r=this.$anchorCell.start(-1),a=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),o={},s=[];for(let r=a.top;r<a.bottom;r++){let i=[];for(let e=r*n.width+a.left,s=a.left;s<a.right;s++,e++){let r=n.map[e];if(o[r])continue;o[r]=!0;let s=n.findCell(r),c=t.nodeAt(r);if(!c)throw RangeError(`No cell with offset ${r} found`);let l=a.left-s.left,u=s.right-a.right;if(l>0||u>0){let e=c.attrs;if(l>0&&(e=x(e,0,l)),u>0&&(e=x(e,e.colspan-u,u)),s.left<a.left){if(c=c.type.createAndFill(e),!c)throw RangeError(`Could not create cell with attrs ${JSON.stringify(e)}`)}else c=c.type.create(e,c.content)}if(s.top<a.top||s.bottom>a.bottom){let e={...c.attrs,rowspan:Math.min(s.bottom,a.bottom)-Math.max(s.top,a.top)};c=s.top<a.top?c.type.createAndFill(e):c.type.create(e,c.content)}i.push(c)}s.push(t.child(r).copy(e.C.from(i)))}let c=this.isColSelection()&&this.isRowSelection()?t:s;return new e.k(e.C.from(c),1,1)}replace(t,n=e.k.empty){let r=t.steps.length,i=this.ranges;for(let a=0;a<i.length;a++){let{$from:o,$to:s}=i[a],c=t.mapping.slice(r);t.replace(c.map(o.pos),c.map(s.pos),a?e.k.empty:n)}let a=e.o.findFrom(t.doc.resolve(t.mapping.slice(r).map(this.to)),-1);a&&t.setSelection(a)}replaceWith(t,n){this.replace(t,new e.k(e.C.from(n),0,0))}forEachCell(e){let t=this.$anchorCell.node(-1),n=i.get(t),r=this.$anchorCell.start(-1),a=n.cellsInRect(n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r));for(let n=0;n<a.length;n++)e(t.nodeAt(a[n]),r+a[n])}isColSelection(){let e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;let n=e+this.$anchorCell.nodeAfter.attrs.rowspan,r=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(n,r)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){let r=e.node(-1),a=i.get(r),o=e.start(-1),s=a.findCell(e.pos-o),c=a.findCell(n.pos-o),l=e.node(0);return s.top<=c.top?(s.top>0&&(e=l.resolve(o+a.map[s.left])),c.bottom<a.height&&(n=l.resolve(o+a.map[a.width*(a.height-1)+c.right-1]))):(c.top>0&&(n=l.resolve(o+a.map[c.left])),s.bottom<a.height&&(e=l.resolve(o+a.map[a.width*(a.height-1)+s.right-1]))),new t(e,n)}isRowSelection(){let e=this.$anchorCell.node(-1),t=i.get(e),n=this.$anchorCell.start(-1),r=t.colCount(this.$anchorCell.pos-n),a=t.colCount(this.$headCell.pos-n);if(Math.min(r,a)>0)return!1;let o=r+this.$anchorCell.nodeAfter.attrs.colspan,s=a+this.$headCell.nodeAfter.attrs.colspan;return Math.max(o,s)==t.width}eq(e){return e instanceof t&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){let r=e.node(-1),a=i.get(r),o=e.start(-1),s=a.findCell(e.pos-o),c=a.findCell(n.pos-o),l=e.node(0);return s.left<=c.left?(s.left>0&&(e=l.resolve(o+a.map[s.top*a.width])),c.right<a.width&&(n=l.resolve(o+a.map[a.width*(c.top+1)-1]))):(c.left>0&&(n=l.resolve(o+a.map[c.top*a.width])),s.right<a.width&&(e=l.resolve(o+a.map[a.width*(s.top+1)-1]))),new t(e,n)}toJSON(){return{type:`cell`,anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new t(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){return new t(e.resolve(n),e.resolve(r))}getBookmark(){return new ie(this.$anchorCell.pos,this.$headCell.pos)}};S.prototype.visible=!1,e.o.jsonID(`cell`,S);var ie=class t{constructor(e,t){this.anchor=e,this.head=t}map(e){return new t(e.map(this.anchor),e.map(this.head))}resolve(t){let n=t.resolve(this.anchor),r=t.resolve(this.head);return n.parent.type.spec.tableRole==`row`&&r.parent.type.spec.tableRole==`row`&&n.index()<n.parent.childCount&&r.index()<r.parent.childCount&&y(n,r)?new S(n,r):e.o.near(r,1)}};function ae(e){if(!(e.selection instanceof S))return null;let n=[];return e.selection.forEachCell((e,r)=>{n.push(t.t.node(r,r+e.nodeSize,{class:`selectedCell`}))}),t.n.create(e.doc,n)}function oe({$from:e,$to:t}){if(e.pos==t.pos||e.pos<t.pos-6)return!1;let n=e.pos,r=t.pos,i=e.depth;for(;i>=0&&!(e.after(i+1)<e.end(i));i--,n++);for(let e=t.depth;e>=0&&!(t.before(e+1)>t.start(e));e--,r--);return n==r&&/row|table/.test(e.node(i).type.spec.tableRole)}function se({$from:e,$to:t}){let n,r;for(let t=e.depth;t>0;t--){let r=e.node(t);if(r.type.spec.tableRole===`cell`||r.type.spec.tableRole===`header_cell`){n=r;break}}for(let e=t.depth;e>0;e--){let n=t.node(e);if(n.type.spec.tableRole===`cell`||n.type.spec.tableRole===`header_cell`){r=n;break}}return n!==r&&t.parentOffset===0}function ce(t,n,r){let a=(n||t).selection,o=(n||t).doc,s,c;if(a instanceof e.r&&(c=a.node.type.spec.tableRole)){if(c==`cell`||c==`header_cell`)s=S.create(o,a.from);else if(c==`row`){let e=o.resolve(a.from+1);s=S.rowSelection(e,e)}else if(!r){let e=i.get(a.node),t=a.from+1,n=t+e.map[e.width*e.height-1];s=S.create(o,t+1,n)}}else a instanceof e.c&&oe(a)?s=e.c.create(o,a.from):a instanceof e.c&&se(a)&&(s=e.c.create(o,a.$from.start(),a.$from.end()));return s&&(n||=t.tr).setSelection(s),n}var le=new e.a(`fix-tables`);function C(e,t,n,r){let i=e.childCount,a=t.childCount;outer:for(let o=0,s=0;o<a;o++){let a=t.child(o);for(let t=s,r=Math.min(i,o+3);t<r;t++)if(e.child(t)==a){s=t+1,n+=a.nodeSize;continue outer}r(a,n),s<i&&e.child(s).sameMarkup(a)?C(e.child(s),a,n+1,r):a.nodesBetween(0,a.content.size,r,n+1),n+=a.nodeSize}}function ue(e,t){let n,r=(t,r)=>{t.type.spec.tableRole==`table`&&(n=de(e,t,r,n))};return t?t.doc!=e.doc&&C(t.doc,e.doc,0,r):e.doc.descendants(r),n}function de(e,t,n,r){let a=i.get(t);if(!a.problems)return r;r||=e.tr;let o=[];for(let e=0;e<a.height;e++)o.push(0);for(let e=0;e<a.problems.length;e++){let i=a.problems[e];if(i.type==`collision`){let e=t.nodeAt(i.pos);if(!e)continue;let a=e.attrs;for(let e=0;e<a.rowspan;e++)o[i.row+e]+=i.n;r.setNodeMarkup(r.mapping.map(n+1+i.pos),null,x(a,a.colspan-i.n,i.n))}else if(i.type==`missing`)o[i.row]+=i.n;else if(i.type==`overlong_rowspan`){let e=t.nodeAt(i.pos);if(!e)continue;r.setNodeMarkup(r.mapping.map(n+1+i.pos),null,{...e.attrs,rowspan:e.attrs.rowspan-i.n})}else if(i.type==`colwidth mismatch`){let e=t.nodeAt(i.pos);if(!e)continue;r.setNodeMarkup(r.mapping.map(n+1+i.pos),null,{...e.attrs,colwidth:i.colwidth})}else if(i.type==`zero_sized`){let e=r.mapping.map(n);r.delete(e,e+t.nodeSize)}}let s,c;for(let e=0;e<o.length;e++)o[e]&&(s??=e,c=e);for(let i=0,l=n+1;i<a.height;i++){let n=t.child(i),a=l+n.nodeSize,u=o[i];if(u>0){let t=`cell`;n.firstChild&&(t=n.firstChild.type.spec.tableRole);let o=[];for(let n=0;n<u;n++){let n=p(e.schema)[t].createAndFill();n&&o.push(n)}let d=(i==0||s==i-1)&&c==i?l+1:a-1;r.insert(r.mapping.map(d),o)}l=a}return r.setMeta(le,{fixTables:!0})}function w(e){let t=i.get(e),n=[],r=t.height,a=t.width;for(let i=0;i<r;i++){let r=[];for(let n=0;n<a;n++){let o=i*a+n,s=t.map[o];if(i>0){let e=o-a;if(s===t.map[e]){r.push(null);continue}}if(n>0){let e=o-1;if(s===t.map[e]){r.push(null);continue}}r.push(e.nodeAt(s))}n.push(r)}return n}function T(e,t){let n=[],r=i.get(e),a=r.height,o=r.width;for(let i=0;i<a;i++){let a=e.child(i),s=[];for(let n=0;n<o;n++){let a=t[i][n];if(!a)continue;let o=r.map[i*r.width+n],c=e.nodeAt(o);if(!c)continue;let l=c.type.createChecked(a.attrs,a.content,a.marks);s.push(l)}let c=a.type.createChecked(a.attrs,s,a.marks);n.push(c)}return e.type.createChecked(e.attrs,n,e.marks)}function E(e,t,n,r){let i=t[0]>n[0]?-1:1,a=e.splice(t[0],t.length),o=+(a.length%2==0),s;return s=r===-1&&i===1?n[0]-1:r===1&&i===-1?n[n.length-1]-o+1:i===-1?n[0]:n[n.length-1]-o,e.splice(s,0,...a),e}function D(e){return fe(e=>e.type.spec.tableRole===`table`,e)}function fe(e,t){for(let n=t.depth;n>=0;--n){let r=t.node(n);if(e(r))return{node:r,pos:n===0?0:t.before(n),start:t.start(n),depth:n}}return null}function O(e,t){let n=D(t.$from);if(!n)return;let r=i.get(n.node);if(!(e<0||e>r.width-1))return r.cellsInRect({left:e,right:e+1,top:0,bottom:r.height}).map(e=>{let t=n.node.nodeAt(e),r=e+n.start;return{pos:r,start:r+1,node:t,depth:n.depth+2}})}function k(e,t){let n=D(t.$from);if(!n)return;let r=i.get(n.node);if(!(e<0||e>r.height-1))return r.cellsInRect({left:0,right:r.width,top:e,bottom:e+1}).map(e=>{let t=n.node.nodeAt(e),r=e+n.start;return{pos:r,start:r+1,node:t,depth:n.depth+2}})}function A(e,t,n=t){let r=t,i=n;for(let n=t;n>=0;n--){let t=O(n,e.selection);t&&t.forEach(e=>{let t=e.node.attrs.colspan+n-1;t>=r&&(r=n),t>i&&(i=t)})}for(let n=t;n<=i;n++){let t=O(n,e.selection);t&&t.forEach(e=>{let t=e.node.attrs.colspan+n-1;e.node.attrs.colspan>1&&t>i&&(i=t)})}let a=[];for(let t=r;t<=i;t++){let n=O(t,e.selection);n&&n.length>0&&a.push(t)}r=a[0],i=a[a.length-1];let o=O(r,e.selection),s=k(0,e.selection);if(!o||!s)return;let c=e.doc.resolve(o[o.length-1].pos),l;for(let t=i;t>=r;t--){let n=O(t,e.selection);if(n&&n.length>0){for(let e=s.length-1;e>=0;e--)if(s[e].pos===n[0].pos){l=n[0];break}if(l)break}}if(l)return{$anchor:c,$head:e.doc.resolve(l.pos),indexes:a}}function j(e,t,n=t){let r=t,i=n;for(let n=t;n>=0;n--){let t=k(n,e.selection);t&&t.forEach(e=>{let t=e.node.attrs.rowspan+n-1;t>=r&&(r=n),t>i&&(i=t)})}for(let n=t;n<=i;n++){let t=k(n,e.selection);t&&t.forEach(e=>{let t=e.node.attrs.rowspan+n-1;e.node.attrs.rowspan>1&&t>i&&(i=t)})}let a=[];for(let t=r;t<=i;t++){let n=k(t,e.selection);n&&n.length>0&&a.push(t)}r=a[0],i=a[a.length-1];let o=k(r,e.selection),s=O(0,e.selection);if(!o||!s)return;let c=e.doc.resolve(o[o.length-1].pos),l;for(let t=i;t>=r;t--){let n=k(t,e.selection);if(n&&n.length>0){for(let e=s.length-1;e>=0;e--)if(s[e].pos===n[0].pos){l=n[0];break}if(l)break}}if(l)return{$anchor:c,$head:e.doc.resolve(l.pos),indexes:a}}function M(e){return e[0].map((t,n)=>e.map(e=>e[n]))}function pe(e){let{tr:t,originIndex:n,targetIndex:r,select:a,pos:o}=e,s=D(t.doc.resolve(o));if(!s)return!1;let c=A(t,n)?.indexes,l=A(t,r)?.indexes;if(!c||!l||c.includes(r))return!1;let u=me(s.node,c,l,0);if(t.replaceWith(s.pos,s.pos+s.node.nodeSize,u),!a)return!0;let d=i.get(u),f=s.start,p=r,m=d.positionAt(d.height-1,p,u),h=t.doc.resolve(f+m),g=d.positionAt(0,p,u),_=t.doc.resolve(f+g);return t.setSelection(S.colSelection(h,_)),!0}function me(e,t,n,r){let i=M(w(e));return i=E(i,t,n,r),i=M(i),T(e,i)}function he(e){let{tr:t,originIndex:n,targetIndex:r,select:a,pos:o}=e,s=D(t.doc.resolve(o));if(!s)return!1;let c=j(t,n)?.indexes,l=j(t,r)?.indexes;if(!c||!l||c.includes(r))return!1;let u=ge(s.node,c,l,0);if(t.replaceWith(s.pos,s.pos+s.node.nodeSize,u),!a)return!0;let d=i.get(u),f=s.start,p=r,m=d.positionAt(p,d.width-1,u),h=t.doc.resolve(f+m),g=d.positionAt(p,0,u),_=t.doc.resolve(f+g);return t.setSelection(S.rowSelection(h,_)),!0}function ge(e,t,n,r){let i=w(e);return i=E(i,t,n,r),T(e,i)}function N(e){let t=e.selection,n=_(e),r=n.node(-1),a=n.start(-1),o=i.get(r);return{...t instanceof S?o.rectBetween(t.$anchorCell.pos-a,t.$headCell.pos-a):o.findCell(n.pos-a),tableStart:a,map:o,table:r}}function P(e,{map:t,tableStart:n,table:r},i){let a=i>0?-1:0;re(t,r,i+a)&&(a=i==0||i==t.width?null:0);for(let o=0;o<t.height;o++){let s=o*t.width+i;if(i>0&&i<t.width&&t.map[s-1]==t.map[s]){let a=t.map[s],c=r.nodeAt(a);e.setNodeMarkup(e.mapping.map(n+a),null,ne(c.attrs,i-t.colCount(a))),o+=c.attrs.rowspan-1}else{let c=a==null?p(r.type.schema).cell:r.nodeAt(t.map[s+a]).type,l=t.positionAt(o,i,r);e.insert(e.mapping.map(n+l),c.createAndFill())}}return e}function _e(e,t){if(!g(e))return!1;if(t){let n=N(e);t(P(e.tr,n,n.left))}return!0}function ve(e,t){if(!g(e))return!1;if(t){let n=N(e);t(P(e.tr,n,n.right))}return!0}function ye(e,{map:t,table:n,tableStart:r},i){let a=e.mapping.maps.length;for(let o=0;o<t.height;){let s=o*t.width+i,c=t.map[s],l=n.nodeAt(c),u=l.attrs;if(i>0&&t.map[s-1]==c||i<t.width-1&&t.map[s+1]==c)e.setNodeMarkup(e.mapping.slice(a).map(r+c),null,x(u,i-t.colCount(c)));else{let t=e.mapping.slice(a).map(r+c);e.delete(t,t+l.nodeSize)}o+=u.rowspan}}function be(e,t){if(!g(e))return!1;if(t){let n=N(e),r=e.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let e=n.right-1;ye(r,n,e),e!=n.left;e--){let e=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!e)throw RangeError(`No table found`);n.table=e,n.map=i.get(e)}t(r)}return!0}function xe(e,t,n){let r=p(t.type.schema).header_cell;for(let i=0;i<e.width;i++)if(t.nodeAt(e.map[i+n*e.width])?.type!=r)return!1;return!0}function F(e,{map:t,tableStart:n,table:r},i){let a=n;for(let e=0;e<i;e++)a+=r.child(e).nodeSize;let o=[],s=i>0?-1:0;xe(t,r,i+s)&&(s=i==0||i==t.height?null:0);for(let a=0,c=t.width*i;a<t.width;a++,c++)if(i>0&&i<t.height&&t.map[c]==t.map[c-t.width]){let i=t.map[c],o=r.nodeAt(i).attrs;e.setNodeMarkup(n+i,null,{...o,rowspan:o.rowspan+1}),a+=o.colspan-1}else{let e=(s==null?p(r.type.schema).cell:r.nodeAt(t.map[c+s*t.width])?.type)?.createAndFill();e&&o.push(e)}return e.insert(a,p(r.type.schema).row.create(null,o)),e}function Se(e,t){if(!g(e))return!1;if(t){let n=N(e);t(F(e.tr,n,n.top))}return!0}function Ce(e,t){if(!g(e))return!1;if(t){let n=N(e);t(F(e.tr,n,n.bottom))}return!0}function we(e,{map:t,table:n,tableStart:r},i){let a=0;for(let e=0;e<i;e++)a+=n.child(e).nodeSize;let o=a+n.child(i).nodeSize,s=e.mapping.maps.length;e.delete(a+r,o+r);let c=new Set;for(let a=0,o=i*t.width;a<t.width;a++,o++){let l=t.map[o];if(!c.has(l)){if(c.add(l),i>0&&l==t.map[o-t.width]){let t=n.nodeAt(l).attrs;e.setNodeMarkup(e.mapping.slice(s).map(l+r),null,{...t,rowspan:t.rowspan-1}),a+=t.colspan-1}else if(i<t.height&&l==t.map[o+t.width]){let o=n.nodeAt(l),c=o.attrs,u=o.type.create({...c,rowspan:o.attrs.rowspan-1},o.content),d=t.positionAt(i+1,a,n);e.insert(e.mapping.slice(s).map(r+d),u),a+=c.colspan-1}}}}function Te(e,t){if(!g(e))return!1;if(t){let n=N(e),r=e.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let e=n.bottom-1;we(r,n,e),e!=n.top;e--){let e=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!e)throw RangeError(`No table found`);n.table=e,n.map=i.get(n.table)}t(r)}return!0}function Ee(e,t){return function(n,r){if(!g(n))return!1;let i=_(n);if(i.nodeAfter.attrs[e]===t)return!1;if(r){let a=n.tr;n.selection instanceof S?n.selection.forEachCell((n,r)=>{n.attrs[e]!==t&&a.setNodeMarkup(r,null,{...n.attrs,[e]:t})}):a.setNodeMarkup(i.pos,null,{...i.nodeAfter.attrs,[e]:t}),r(a)}return!0}}function De(e){return function(t,n){if(!g(t))return!1;if(n){let r=p(t.schema),i=N(t),a=t.tr,o=i.map.cellsInRect(e==`column`?{left:i.left,top:0,right:i.right,bottom:i.map.height}:e==`row`?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),s=o.map(e=>i.table.nodeAt(e));for(let e=0;e<o.length;e++)s[e].type==r.header_cell&&a.setNodeMarkup(i.tableStart+o[e],r.cell,s[e].attrs);if(a.steps.length===0)for(let e=0;e<o.length;e++)a.setNodeMarkup(i.tableStart+o[e],r.header_cell,s[e].attrs);n(a)}return!0}}function I(e,t,n){let r=t.map.cellsInRect({left:0,top:0,right:e==`row`?t.map.width:1,bottom:e==`column`?t.map.height:1});for(let e=0;e<r.length;e++){let i=t.table.nodeAt(r[e]);if(i&&i.type!==n.header_cell)return!1}return!0}function L(e,t){return t||={useDeprecatedLogic:!1},t.useDeprecatedLogic?De(e):function(t,n){if(!g(t))return!1;if(n){let r=p(t.schema),i=N(t),a=t.tr,o=I(`row`,i,r),s=I(`column`,i,r),c=(e===`column`?o:e===`row`&&s)?1:0,l=e==`column`?{left:0,top:c,right:1,bottom:i.map.height}:e==`row`?{left:c,top:0,right:i.map.width,bottom:1}:i,u=e==`column`?s?r.cell:r.header_cell:e==`row`?o?r.cell:r.header_cell:r.cell;i.map.cellsInRect(l).forEach(e=>{let t=e+i.tableStart,n=a.doc.nodeAt(t);n&&a.setNodeMarkup(t,u,n.attrs)}),n(a)}return!0}}L(`row`,{useDeprecatedLogic:!0}),L(`column`,{useDeprecatedLogic:!0}),L(`cell`,{useDeprecatedLogic:!0});function Oe(e,t){if(t<0){let t=e.nodeBefore;if(t)return e.pos-t.nodeSize;for(let t=e.index(-1)-1,n=e.before();t>=0;t--){let r=e.node(-1).child(t),i=r.lastChild;if(i)return n-1-i.nodeSize;n-=r.nodeSize}}else{if(e.index()<e.parent.childCount-1)return e.pos+e.nodeAfter.nodeSize;let t=e.node(-1);for(let n=e.indexAfter(-1),r=e.after();n<t.childCount;n++){let e=t.child(n);if(e.childCount)return r+1;r+=e.nodeSize}}return null}function ke(t){return function(n,r){if(!g(n))return!1;let i=Oe(_(n),t);if(i==null)return!1;if(r){let t=n.doc.resolve(i);r(n.tr.setSelection(e.c.between(t,te(t))).scrollIntoView())}return!0}}function Ae(e,t){let n=e.selection.$anchor;for(let r=n.depth;r>0;r--)if(n.node(r).type.spec.tableRole==`table`)return t&&t(e.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function R(t,n){let r=t.selection;if(!(r instanceof S))return!1;if(n){let i=t.tr,a=p(t.schema).cell.createAndFill().content;r.forEachCell((t,n)=>{t.content.eq(a)||i.replace(i.mapping.map(n+1),i.mapping.map(n+t.nodeSize-1),new e.k(a,0,0))}),i.docChanged&&n(i)}return!0}function je(e){return(t,n)=>{let{from:r,to:i,select:a=!0,pos:o=t.selection.from}=e,s=t.tr;return he({tr:s,originIndex:r,targetIndex:i,select:a,pos:o})?(n?.(s),!0):!1}}function Me(e){return(t,n)=>{let{from:r,to:i,select:a=!0,pos:o=t.selection.from}=e,s=t.tr;return pe({tr:s,originIndex:r,targetIndex:i,select:a,pos:o})?(n?.(s),!0):!1}}function Ne(t){if(t.size===0)return null;let{content:n,openStart:r,openEnd:i}=t;for(;n.childCount==1&&(r>0&&i>0||n.child(0).type.spec.tableRole==`table`);)r--,i--,n=n.child(0).content;let a=n.child(0),o=a.type.spec.tableRole,s=a.type.schema,c=[];if(o==`row`)for(let t=0;t<n.childCount;t++){let a=n.child(t).content,o=t?0:Math.max(0,r-1),l=t<n.childCount-1?0:Math.max(0,i-1);(o||l)&&(a=z(p(s).row,new e.k(a,o,l)).content),c.push(a)}else if(o==`cell`||o==`header_cell`)c.push(r||i?z(p(s).row,new e.k(n,r,i)).content:n);else return null;return Pe(s,c)}function Pe(t,n){let r=[];for(let e=0;e<n.length;e++){let t=n[e];for(let n=t.childCount-1;n>=0;n--){let{rowspan:i,colspan:a}=t.child(n).attrs;for(let t=e;t<e+i;t++)r[t]=(r[t]||0)+a}}let i=0;for(let e=0;e<r.length;e++)i=Math.max(i,r[e]);for(let a=0;a<r.length;a++)if(a>=n.length&&n.push(e.C.empty),r[a]<i){let o=p(t).cell.createAndFill(),s=[];for(let e=r[a];e<i;e++)s.push(o);n[a]=n[a].append(e.C.from(s))}return{height:n.length,width:i,rows:n}}function z(t,n){let r=t.createAndFill();return new e.p(r).replace(0,r.content.size,n).doc}function Fe({width:t,height:n,rows:r},i,a){if(t!=i){let n=[],a=[];for(let t=0;t<r.length;t++){let o=r[t],s=[];for(let e=n[t]||0,r=0;e<i;r++){let a=o.child(r%o.childCount);e+a.attrs.colspan>i&&(a=a.type.createChecked(x(a.attrs,a.attrs.colspan,e+a.attrs.colspan-i),a.content)),s.push(a),e+=a.attrs.colspan;for(let e=1;e<a.attrs.rowspan;e++)n[t+e]=(n[t+e]||0)+a.attrs.colspan}a.push(e.C.from(s))}r=a,t=i}if(n!=a){let t=[];for(let i=0,o=0;i<a;i++,o++){let s=[],c=r[o%n];for(let e=0;e<c.childCount;e++){let t=c.child(e);i+t.attrs.rowspan>a&&(t=t.type.create({...t.attrs,rowspan:Math.max(1,a-t.attrs.rowspan)},t.content)),s.push(t)}t.push(e.C.from(s))}r=t,n=a}return{width:t,height:n,rows:r}}function Ie(t,n,r,i,a,o,s){let c=t.doc.type.schema,l=p(c),u,d;if(a>n.width)for(let e=0,o=0;e<n.height;e++){let c=r.child(e);o+=c.nodeSize;let f=[],p;p=c.lastChild==null||c.lastChild.type==l.cell?u||=l.cell.createAndFill():d||=l.header_cell.createAndFill();for(let e=n.width;e<a;e++)f.push(p);t.insert(t.mapping.slice(s).map(o-1+i),f)}if(o>n.height){let c=[];for(let e=0,t=(n.height-1)*n.width;e<Math.max(n.width,a);e++){let i=e>=n.width?!1:r.nodeAt(n.map[t+e]).type==l.header_cell;c.push(i?d||=l.header_cell.createAndFill():u||=l.cell.createAndFill())}let f=l.row.create(null,e.C.from(c)),p=[];for(let e=n.height;e<o;e++)p.push(f);t.insert(t.mapping.slice(s).map(i+r.nodeSize-2),p)}return!!(u||d)}function B(e,t,n,r,i,a,o,s){if(o==0||o==t.height)return!1;let c=!1;for(let l=i;l<a;l++){let i=o*t.width+l,a=t.map[i];if(t.map[i-t.width]==a){c=!0;let i=n.nodeAt(a),{top:u,left:d}=t.findCell(a);e.setNodeMarkup(e.mapping.slice(s).map(a+r),null,{...i.attrs,rowspan:o-u}),e.insert(e.mapping.slice(s).map(t.positionAt(o,d,n)),i.type.createAndFill({...i.attrs,rowspan:u+i.attrs.rowspan-o})),l+=i.attrs.colspan-1}}return c}function V(e,t,n,r,i,a,o,s){if(o==0||o==t.width)return!1;let c=!1;for(let l=i;l<a;l++){let i=l*t.width+o,a=t.map[i];if(t.map[i-1]==a){c=!0;let i=n.nodeAt(a),u=t.colCount(a),d=e.mapping.slice(s).map(a+r);e.setNodeMarkup(d,null,x(i.attrs,o-u,i.attrs.colspan-(o-u))),e.insert(d+i.nodeSize,i.type.createAndFill(x(i.attrs,0,o-u))),l+=i.attrs.rowspan-1}}return c}function H(t,n,r,a,o){let s=r?t.doc.nodeAt(r-1):t.doc;if(!s)throw Error(`No table found`);let c=i.get(s),{top:l,left:u}=a,d=u+o.width,f=l+o.height,p=t.tr,m=0;function h(){if(s=r?p.doc.nodeAt(r-1):p.doc,!s)throw Error(`No table found`);c=i.get(s),m=p.mapping.maps.length}Ie(p,c,s,r,d,f,m)&&h(),B(p,c,s,r,u,d,l,m)&&h(),B(p,c,s,r,u,d,f,m)&&h(),V(p,c,s,r,l,f,u,m)&&h(),V(p,c,s,r,l,f,d,m)&&h();for(let t=l;t<f;t++){let n=c.positionAt(t,u,s),i=c.positionAt(t,d,s);p.replace(p.mapping.slice(m).map(n+r),p.mapping.slice(m).map(i+r),new e.k(o.rows[t-l],0,0))}h(),p.setSelection(new S(p.doc.resolve(r+c.positionAt(l,u,s)),p.doc.resolve(r+c.positionAt(f-1,d-1,s)))),n(p)}var Le=t.i({ArrowLeft:W(`horiz`,-1),ArrowRight:W(`horiz`,1),ArrowUp:W(`vert`,-1),ArrowDown:W(`vert`,1),"Shift-ArrowLeft":G(`horiz`,-1),"Shift-ArrowRight":G(`horiz`,1),"Shift-ArrowUp":G(`vert`,-1),"Shift-ArrowDown":G(`vert`,1),Backspace:R,"Mod-Backspace":R,Delete:R,"Mod-Delete":R});function U(e,t,n){return n.eq(e.selection)?!1:(t&&t(e.tr.setSelection(n).scrollIntoView()),!0)}function W(t,n){return(r,i,a)=>{if(!a)return!1;let o=r.selection;if(o instanceof S)return U(r,i,e.o.near(o.$headCell,n));if(t!=`horiz`&&!o.empty)return!1;let s=K(a,t,n);if(s==null)return!1;if(t==`horiz`)return U(r,i,e.o.near(r.doc.resolve(o.head+n),n));{let a=r.doc.resolve(s),o=b(a,t,n),c;return c=o?e.o.near(o,1):n<0?e.o.near(r.doc.resolve(a.before(-1)),-1):e.o.near(r.doc.resolve(a.after(-1)),1),U(r,i,c)}}}function G(e,t){return(n,r,i)=>{if(!i)return!1;let a=n.selection,o;if(a instanceof S)o=a;else{let r=K(i,e,t);if(r==null)return!1;o=new S(n.doc.resolve(r))}let s=b(o.$headCell,e,t);return s?U(n,r,new S(o.$anchorCell,s)):!1}}function Re(e,t){let n=e.state.doc,r=h(n.resolve(t));return r?(e.dispatch(e.state.tr.setSelection(new S(r))),!0):!1}function ze(t,n,r){if(!g(t.state))return!1;let a=Ne(r),o=t.state.selection;if(o instanceof S){a||={width:1,height:1,rows:[e.C.from(z(p(t.state.schema).cell,r))]};let n=o.$anchorCell.node(-1),s=o.$anchorCell.start(-1),c=i.get(n).rectBetween(o.$anchorCell.pos-s,o.$headCell.pos-s);return a=Fe(a,c.right-c.left,c.bottom-c.top),H(t.state,t.dispatch,s,c,a),!0}else if(a){let e=_(t.state),n=e.start(-1);return H(t.state,t.dispatch,n,i.get(e.node(-1)).findCell(e.pos-n),a),!0}else return!1}function Be(e,t){if(t.button!=0||t.ctrlKey||t.metaKey)return;let n=q(e,t.target),r;if(t.shiftKey&&e.state.selection instanceof S)i(e.state.selection.$anchorCell,t),t.preventDefault();else if(t.shiftKey&&n&&(r=h(e.state.selection.$anchor))!=null&&J(e,t)?.pos!=r.pos)i(r,t),t.preventDefault();else if(!n)return;function i(t,n){let r=J(e,n),i=m.getState(e.state)==null;if(!r||!y(t,r))if(i)r=t;else return;let a=new S(t,r);if(i||!e.state.selection.eq(a)){let n=e.state.tr.setSelection(a);i&&n.setMeta(m,t.pos),e.dispatch(n)}}function a(){e.root.removeEventListener(`mouseup`,a),e.root.removeEventListener(`dragstart`,a),e.root.removeEventListener(`mousemove`,o),m.getState(e.state)!=null&&e.dispatch(e.state.tr.setMeta(m,-1))}function o(r){let o=r,s=m.getState(e.state),c;if(s!=null)c=e.state.doc.resolve(s);else if(q(e,o.target)!=n&&(c=J(e,t),!c))return a();c&&i(c,o)}e.root.addEventListener(`mouseup`,a),e.root.addEventListener(`dragstart`,a),e.root.addEventListener(`mousemove`,o)}function K(t,n,r){if(!(t.state.selection instanceof e.c))return null;let{$head:i}=t.state.selection;for(let e=i.depth-1;e>=0;e--){let a=i.node(e);if((r<0?i.index(e):i.indexAfter(e))!=(r<0?0:a.childCount))return null;if(a.type.spec.tableRole==`cell`||a.type.spec.tableRole==`header_cell`){let a=i.before(e),o=n==`vert`?r>0?`down`:`up`:r>0?`right`:`left`;return t.endOfTextblock(o)?a:null}}return null}function q(e,t){for(;t&&t!=e.dom;t=t.parentNode)if(t.nodeName==`TD`||t.nodeName==`TH`)return t;return null}function J(e,t){let n=e.posAtCoords({left:t.clientX,top:t.clientY});if(!n)return null;let{inside:r,pos:i}=n;return r>=0&&h(e.state.doc.resolve(r))||h(e.state.doc.resolve(i))}var Ve=class{constructor(e,t){this.node=e,this.defaultCellMinWidth=t,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`,`${t}px`),this.colgroup=this.table.appendChild(document.createElement(`colgroup`)),Y(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement(`tbody`))}update(e){return e.type==this.node.type?(this.node=e,Y(e,this.colgroup,this.table,this.defaultCellMinWidth),!0):!1}ignoreMutation(e){return e.type==`attributes`&&(e.target==this.table||this.colgroup.contains(e.target))}};function Y(e,t,n,r,i,a){let o=0,s=!0,c=t.firstChild,l=e.firstChild;if(l){for(let e=0,n=0;e<l.childCount;e++){let{colspan:u,colwidth:d}=l.child(e).attrs;for(let e=0;e<u;e++,n++){let l=i==n?a:d&&d[e],u=l?l+`px`:``;if(o+=l||r,l||(s=!1),c)c.style.width!=u&&(c.style.width=u),c=c.nextSibling;else{let e=document.createElement(`col`);e.style.width=u,t.appendChild(e)}}}for(;c;){var u;let e=c.nextSibling;(u=c.parentNode)==null||u.removeChild(c),c=e}s?(n.style.width=o+`px`,n.style.minWidth=``):(n.style.width=``,n.style.minWidth=o+`px`)}}var X=new e.a(`tableColumnResizing`);function He({handleWidth:t=5,cellMinWidth:n=25,defaultCellMinWidth:r=100,View:i=Ve,lastColumnResizable:a=!0}={}){let o=new e.i({key:X,state:{init(e,t){var n;let a=(n=o.spec)==null||(n=n.props)==null?void 0:n.nodeViews,s=p(t.schema).table.name;return i&&a&&(a[s]=(e,t)=>new i(e,r,t)),new Ue(-1,!1)},apply(e,t){return t.apply(e)}},props:{attributes:e=>{let t=X.getState(e);return t&&t.activeHandle>-1?{class:`resize-cursor`}:{}},handleDOMEvents:{mousemove:(e,n)=>{We(e,n,t,a)},mouseleave:e=>{Ge(e)},mousedown:(e,t)=>{Ke(e,t,n,r)}},decorations:e=>{let t=X.getState(e);if(t&&t.activeHandle>-1)return Qe(e,t.activeHandle)},nodeViews:{}}});return o}var Ue=class e{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(t){let n=this,r=t.getMeta(X);if(r&&r.setHandle!=null)return new e(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new e(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&t.docChanged){let r=t.mapping.map(n.activeHandle,-1);return v(t.doc.resolve(r))||(r=-1),new e(r,n.dragging)}return n}};function We(e,t,n,r){if(!e.editable)return;let a=X.getState(e.state);if(a&&!a.dragging){let o=Je(t.target),s=-1;if(o){let{left:r,right:i}=o.getBoundingClientRect();t.clientX-r<=n?s=Z(e,t,`left`,n):i-t.clientX<=n&&(s=Z(e,t,`right`,n))}if(s!=a.activeHandle){if(!r&&s!==-1){let t=e.state.doc.resolve(s),n=t.node(-1),r=i.get(n),a=t.start(-1);if(r.colCount(t.pos-a)+t.nodeAfter.attrs.colspan-1==r.width-1)return}$(e,s)}}}function Ge(e){if(!e.editable)return;let t=X.getState(e.state);t&&t.activeHandle>-1&&!t.dragging&&$(e,-1)}function Ke(e,t,n,r){if(!e.editable)return!1;let i=e.dom.ownerDocument.defaultView??window,a=X.getState(e.state);if(!a||a.activeHandle==-1||a.dragging)return!1;let o=e.state.doc.nodeAt(a.activeHandle),s=qe(e,a.activeHandle,o.attrs);e.dispatch(e.state.tr.setMeta(X,{setDragging:{startX:t.clientX,startWidth:s}}));function c(t){i.removeEventListener(`mouseup`,c),i.removeEventListener(`mousemove`,l);let r=X.getState(e.state);r?.dragging&&(Ye(e,r.activeHandle,Q(r.dragging,t,n)),e.dispatch(e.state.tr.setMeta(X,{setDragging:null})))}function l(t){if(!t.which)return c(t);let i=X.getState(e.state);if(i&&i.dragging){let a=Q(i.dragging,t,n);Xe(e,i.activeHandle,a,r)}}return Xe(e,a.activeHandle,s,r),i.addEventListener(`mouseup`,c),i.addEventListener(`mousemove`,l),t.preventDefault(),!0}function qe(e,t,{colspan:n,colwidth:r}){let i=r&&r[r.length-1];if(i)return i;let a=e.domAtPos(t),o=a.node.childNodes[a.offset].offsetWidth,s=n;if(r)for(let e=0;e<n;e++)r[e]&&(o-=r[e],s--);return o/s}function Je(e){for(;e&&e.nodeName!=`TD`&&e.nodeName!=`TH`;)e=e.classList&&e.classList.contains(`ProseMirror`)?null:e.parentNode;return e}function Z(e,t,n,r){let a=n==`right`?-r:r,o=e.posAtCoords({left:t.clientX+a,top:t.clientY});if(!o)return-1;let{pos:s}=o,c=h(e.state.doc.resolve(s));if(!c)return-1;if(n==`right`)return c.pos;let l=i.get(c.node(-1)),u=c.start(-1),d=l.map.indexOf(c.pos-u);return d%l.width==0?-1:u+l.map[d-1]}function Q(e,t,n){let r=t.clientX-e.startX;return Math.max(n,e.startWidth+r)}function $(e,t){e.dispatch(e.state.tr.setMeta(X,{setHandle:t}))}function Ye(e,t,n){let r=e.state.doc.resolve(t),a=r.node(-1),o=i.get(a),s=r.start(-1),c=o.colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1,l=e.state.tr;for(let e=0;e<o.height;e++){let t=e*o.width+c;if(e&&o.map[t]==o.map[t-o.width])continue;let r=o.map[t],i=a.nodeAt(r).attrs,u=i.colspan==1?0:c-o.colCount(r);if(i.colwidth&&i.colwidth[u]==n)continue;let d=i.colwidth?i.colwidth.slice():Ze(i.colspan);d[u]=n,l.setNodeMarkup(s+r,null,{...i,colwidth:d})}l.docChanged&&e.dispatch(l)}function Xe(e,t,n,r){let a=e.state.doc.resolve(t),o=a.node(-1),s=a.start(-1),c=i.get(o).colCount(a.pos-s)+a.nodeAfter.attrs.colspan-1,l=e.domAtPos(a.start(-1)).node;for(;l&&l.nodeName!=`TABLE`;)l=l.parentNode;l&&Y(o,l.firstChild,l,r,c,n)}function Ze(e){return Array(e).fill(0)}function Qe(e,n){let r=[],a=e.doc.resolve(n),o=a.node(-1);if(!o)return t.n.empty;let s=i.get(o),c=a.start(-1),l=s.colCount(a.pos-c)+a.nodeAfter.attrs.colspan-1;for(let n=0;n<s.height;n++){let i=l+n*s.width;if((l==s.width-1||s.map[i]!=s.map[i+1])&&(n==0||s.map[i]!=s.map[i-s.width])){let n=s.map[i],a=c+n+o.nodeAt(n).nodeSize-1,l=document.createElement(`div`);l.className=`column-resize-handle`,X.getState(e)?.dragging&&r.push(t.t.node(c+n,c+n+o.nodeAt(n).nodeSize,{class:`column-resize-dragging`})),r.push(t.t.widget(a,l))}}return t.n.create(e.doc,r)}function $e({allowTableNodeSelection:t=!1}={}){return new e.i({key:m,state:{init(){return null},apply(e,t){let n=e.getMeta(m);if(n!=null)return n==-1?null:n;if(t==null||!e.docChanged)return t;let{deleted:r,pos:i}=e.mapping.mapResult(t);return r?null:i}},props:{decorations:ae,handleDOMEvents:{mousedown:Be},createSelectionBetween(e){return m.getState(e.state)==null?null:e.state.selection},handleTripleClick:Re,handleKeyDown:Le,handlePaste:ze},appendTransaction(e,n,r){return ce(r,ue(r,n),t)}})}Object.defineProperty(exports,`_`,{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return Ce}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return be}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,`f`,{enumerable:!0,get:function(){return ke}}),Object.defineProperty(exports,`g`,{enumerable:!0,get:function(){return N}}),Object.defineProperty(exports,`h`,{enumerable:!0,get:function(){return je}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return _e}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return Te}}),Object.defineProperty(exports,`m`,{enumerable:!0,get:function(){return Me}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return Se}}),Object.defineProperty(exports,`p`,{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return ve}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return He}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(exports,`v`,{enumerable:!0,get:function(){return $e}}),Object.defineProperty(exports,`y`,{enumerable:!0,get:function(){return f}});
|