Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@lexical/table

Package Overview
Dependencies
Maintainers
5
Versions
199
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lexical/table - npm Package Compare versions

Comparing version 0.17.1-nightly.20240822.0 to 0.17.1-nightly.20240823.0

161

LexicalTable.prod.js

@@ -9,4 +9,4 @@ /**

'use strict';var h=require("@lexical/utils"),v=require("lexical");let aa=/^(\d+(?:\.\d+)?)px$/,x={BOTH:3,COLUMN:2,NO_STATUS:0,ROW:1};
class y extends v.ElementNode{static getType(){return"tablecell"}static clone(a){let b=new y(a.__headerState,a.__colSpan,a.__width,a.__key);b.__rowSpan=a.__rowSpan;b.__backgroundColor=a.__backgroundColor;return b}static importDOM(){return{td:()=>({conversion:ba,priority:0}),th:()=>({conversion:ba,priority:0})}}static importJSON(a){let b=a.rowSpan||1,c=z(a.headerState,a.colSpan||1,a.width||void 0);c.__rowSpan=b;c.__backgroundColor=a.backgroundColor||null;return c}constructor(a=x.NO_STATUS,b=1,c,d){super(d);
'use strict';var h=require("@lexical/utils"),u=require("lexical"),aa=require("@lexical/clipboard");let ba=/^(\d+(?:\.\d+)?)px$/,x={BOTH:3,COLUMN:2,NO_STATUS:0,ROW:1};
class y extends u.ElementNode{static getType(){return"tablecell"}static clone(a){let b=new y(a.__headerState,a.__colSpan,a.__width,a.__key);b.__rowSpan=a.__rowSpan;b.__backgroundColor=a.__backgroundColor;return b}static importDOM(){return{td:()=>({conversion:ca,priority:0}),th:()=>({conversion:ca,priority:0})}}static importJSON(a){let b=a.rowSpan||1,c=A(a.headerState,a.colSpan||1,a.width||void 0);c.__rowSpan=b;c.__backgroundColor=a.backgroundColor||null;return c}constructor(a=x.NO_STATUS,b=1,c,d){super(d);
this.__colSpan=b;this.__rowSpan=1;this.__headerState=a;this.__width=c;this.__backgroundColor=null}createDOM(a){let b=document.createElement(this.getTag());this.__width&&(b.style.width=`${this.__width}px`);1<this.__colSpan&&(b.colSpan=this.__colSpan);1<this.__rowSpan&&(b.rowSpan=this.__rowSpan);null!==this.__backgroundColor&&(b.style.backgroundColor=this.__backgroundColor);h.addClassNamesToElement(b,a.theme.tableCell,this.hasHeader()&&a.theme.tableCellHeader);return b}exportDOM(a){({element:a}=super.exportDOM(a));

@@ -16,83 +16,84 @@ if(a){a.style.border="1px solid black";1<this.__colSpan&&(a.colSpan=this.__colSpan);1<this.__rowSpan&&(a.rowSpan=this.__rowSpan);a.style.width=`${this.getWidth()||75}px`;a.style.verticalAlign="top";a.style.textAlign="start";let b=this.getBackgroundColor();null!==b?a.style.backgroundColor=b:this.hasHeader()&&(a.style.backgroundColor="#f2f3f5")}return{element:a}}exportJSON(){return{...super.exportJSON(),backgroundColor:this.getBackgroundColor(),colSpan:this.__colSpan,headerState:this.__headerState,

a}toggleHeaderStyle(a){let b=this.getWritable();b.__headerState=(b.__headerState&a)===a?b.__headerState-a:b.__headerState+a;return b}hasHeaderState(a){return(this.getHeaderStyles()&a)===a}hasHeader(){return this.getLatest().__headerState!==x.NO_STATUS}updateDOM(a){return a.__headerState!==this.__headerState||a.__width!==this.__width||a.__colSpan!==this.__colSpan||a.__rowSpan!==this.__rowSpan||a.__backgroundColor!==this.__backgroundColor}isShadowRoot(){return!0}collapseAtStart(){return!0}canBeEmpty(){return!1}canIndent(){return!1}}
function ba(a){var b=a.nodeName.toLowerCase(),c=void 0;aa.test(a.style.width)&&(c=parseFloat(a.style.width));b=z("th"===b?x.ROW:x.NO_STATUS,a.colSpan,c);b.__rowSpan=a.rowSpan;c=a.style.backgroundColor;""!==c&&(b.__backgroundColor=c);a=a.style;c=a.textDecoration.split(" ");let d="700"===a.fontWeight||"bold"===a.fontWeight,e=c.includes("line-through"),f="italic"===a.fontStyle,g=c.includes("underline");return{after:m=>{0===m.length&&m.push(v.$createParagraphNode());return m},forChild:(m,r)=>{if(A(r)&&
!v.$isElementNode(m)){r=v.$createParagraphNode();if(v.$isLineBreakNode(m)&&"\n"===m.getTextContent())return null;v.$isTextNode(m)&&(d&&m.toggleFormat("bold"),e&&m.toggleFormat("strikethrough"),f&&m.toggleFormat("italic"),g&&m.toggleFormat("underline"));r.append(m);return r}return m},node:b}}function z(a,b=1,c){return v.$applyNodeReplacement(new y(a,b,c))}function A(a){return a instanceof y}let ca=v.createCommand("INSERT_TABLE_COMMAND");
class C extends v.ElementNode{static getType(){return"tablerow"}static clone(a){return new C(a.__height,a.__key)}static importDOM(){return{tr:()=>({conversion:da,priority:0})}}static importJSON(a){return D(a.height)}constructor(a,b){super(b);this.__height=a}exportJSON(){return{...super.exportJSON(),...(this.getHeight()&&{height:this.getHeight()}),type:"tablerow",version:1}}createDOM(a){let b=document.createElement("tr");this.__height&&(b.style.height=`${this.__height}px`);h.addClassNamesToElement(b,
a.theme.tableRow);return b}isShadowRoot(){return!0}setHeight(a){this.getWritable().__height=a;return this.__height}getHeight(){return this.getLatest().__height}updateDOM(a){return a.__height!==this.__height}canBeEmpty(){return!1}canIndent(){return!1}}function da(a){let b=void 0;aa.test(a.style.height)&&(b=parseFloat(a.style.height));return{node:D(b)}}function D(a){return v.$applyNodeReplacement(new C(a))}function G(a){return a instanceof C}var I;
function K(a){let b=new URLSearchParams;b.append("code",a);for(let c=1;c<arguments.length;c++)b.append("v",arguments[c]);throw Error(`Minified Lexical error #${a}; visit https://lexical.dev/docs/error?${b} for the full message or `+"use the non-minified dev environment for full errors and additional helpful warnings.");}I=K&&K.__esModule&&Object.prototype.hasOwnProperty.call(K,"default")?K["default"]:K;let ea="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement;
function ia(a){a=h.$findMatchingParent(a,b=>G(b));if(G(a))return a;throw Error("Expected table cell to be inside of table row.");}function ja(a){a=h.$findMatchingParent(a,b=>N(b));if(N(a))return a;throw Error("Expected table cell to be inside of table.");}function ka(a,b){let c=ja(a),{x:d,y:e}=c.getCordsFromCellNode(a,b);return{above:c.getCellNodeFromCords(d,e-1,b),below:c.getCellNodeFromCords(d,e+1,b),left:c.getCellNodeFromCords(d-1,e,b),right:c.getCellNodeFromCords(d+1,e,b)}}
let la=(a,b)=>a===x.BOTH||a===b?b:x.NO_STATUS;function O(a){let b=a.getFirstDescendant();null==b?a.selectStart():b.getParentOrThrow().selectStart()}function ma(a,b){let c=a.getFirstChild();null!==c?c.insertBefore(b):a.append(b)}function P(a,b,c){let [d,e,f]=na(a,b,c);null===e&&I(110);null===f&&I(111);return[d,e,f]}
function na(a,b,c){let d=[],e=null,f=null;a=a.getChildren();for(let t=0;t<a.length;t++){var g=a[t];G(g)||I(146);var m=g.getChildren();g=0;for(let k of m){for(A(k)||I(147);void 0!==d[t]&&void 0!==d[t][g];)g++;m=t;var r=g,p=k;let l={cell:p,startColumn:r,startRow:m},n=p.__rowSpan,q=p.__colSpan;for(let u=0;u<n;u++){void 0===d[m+u]&&(d[m+u]=[]);for(let w=0;w<q;w++)d[m+u][r+w]=l}null!==b&&b.is(p)&&(e=l);null!==c&&c.is(p)&&(f=l);g+=k.__colSpan}}return[d,e,f]}
function Q(a){a instanceof y||("__type"in a?(a=h.$findMatchingParent(a,A),A(a)||I(148)):(a=h.$findMatchingParent(a.getNode(),A),A(a)||I(148)));let b=a.getParent();G(b)||I(149);let c=b.getParent();N(c)||I(150);return[a,b,c]}
function oa(a){let [b,,c]=Q(a);a=c.getChildren();let d=a.length;var e=a[0].getChildren().length;let f=Array(d);for(var g=0;g<d;g++)f[g]=Array(e);for(e=0;e<d;e++){g=a[e].getChildren();let m=0;for(let r=0;r<g.length;r++){for(;f[e][m];)m++;let p=g[r],t=p.__rowSpan||1,k=p.__colSpan||1;for(let l=0;l<t;l++)for(let n=0;n<k;n++)f[e+l][m+n]=p;if(b===p)return{colSpan:k,columnIndex:m,rowIndex:e,rowSpan:t};m+=k}}return null}
class pa{constructor(a,b,c){this.anchor=b;this.focus=c;b._selection=this;c._selection=this;this._cachedNodes=null;this.dirty=!1;this.tableKey=a}getStartEndPoints(){return[this.anchor,this.focus]}isBackward(){return this.focus.isBefore(this.anchor)}getCachedNodes(){return this._cachedNodes}setCachedNodes(a){this._cachedNodes=a}is(a){return R(a)?this.tableKey===a.tableKey&&this.anchor.is(a.anchor)&&this.focus.is(a.focus):!1}set(a,b,c){this.dirty=!0;this.tableKey=a;this.anchor.key=b;this.focus.key=c;
this._cachedNodes=null}clone(){return new pa(this.tableKey,this.anchor,this.focus)}isCollapsed(){return!1}extract(){return this.getNodes()}insertRawText(){}insertText(){}insertNodes(a){let b=this.focus.getNode();v.$isElementNode(b)||I(151);v.$normalizeSelection__EXPERIMENTAL(b.select(0,b.getChildrenSize())).insertNodes(a)}getShape(){var a=v.$getNodeByKey(this.anchor.key);A(a)||I(152);a=oa(a);null===a&&I(153);var b=v.$getNodeByKey(this.focus.key);A(b)||I(154);let c=oa(b);null===c&&I(155);b=Math.min(a.columnIndex,
c.columnIndex);let d=Math.max(a.columnIndex,c.columnIndex),e=Math.min(a.rowIndex,c.rowIndex);a=Math.max(a.rowIndex,c.rowIndex);return{fromX:Math.min(b,d),fromY:Math.min(e,a),toX:Math.max(b,d),toY:Math.max(e,a)}}getNodes(){function a(u){let {cell:w,startColumn:B,startRow:E}=u;r=Math.min(r,B);p=Math.min(p,E);t=Math.max(t,B+w.__colSpan-1);k=Math.max(k,E+w.__rowSpan-1)}var b=this._cachedNodes;if(null!==b)return b;var c=this.anchor.getNode();b=this.focus.getNode();var d=h.$findMatchingParent(c,A);c=h.$findMatchingParent(b,
A);A(d)||I(152);A(c)||I(154);b=d.getParent();G(b)||I(156);b=b.getParent();N(b)||I(157);var e=c.getParents()[1];if(e!==b)return b.isParentOf(c)?(b=e.getParent(),null==b&&I(159),this.set(this.tableKey,c.getKey(),b.getKey())):(b=b.getParent(),null==b&&I(158),this.set(this.tableKey,b.getKey(),c.getKey())),this.getNodes();let [f,g,m]=P(b,d,c),r=Math.min(g.startColumn,m.startColumn),p=Math.min(g.startRow,m.startRow),t=Math.max(g.startColumn+g.cell.__colSpan-1,m.startColumn+m.cell.__colSpan-1),k=Math.max(g.startRow+
g.cell.__rowSpan-1,m.startRow+m.cell.__rowSpan-1);c=r;d=p;e=r;for(var l=p;r<c||p<d||t>e||k>l;){if(r<c){var n=l-d;--c;for(var q=0;q<=n;q++)a(f[d+q][c])}if(p<d)for(n=e-c,--d,q=0;q<=n;q++)a(f[d][c+q]);if(t>e)for(n=l-d,e+=1,q=0;q<=n;q++)a(f[d+q][e]);if(k>l)for(n=e-c,l+=1,q=0;q<=n;q++)a(f[l][c+q])}b=[b];c=null;for(d=p;d<=k;d++)for(e=r;e<=t;e++)({cell:l}=f[d][e]),n=l.getParent(),G(n)||I(160),n!==c&&b.push(n),b.push(l,...qa(l)),c=n;v.isCurrentlyReadOnlyMode()||(this._cachedNodes=b);return b}getTextContent(){let a=
this.getNodes(),b="";for(let c=0;c<a.length;c++)b+=a[c].getTextContent();return b}}function R(a){return a instanceof pa}function ra(){let a=v.$createPoint("root",0,"element"),b=v.$createPoint("root",0,"element");return new pa("root",a,b)}function qa(a){let b=[],c=[a];for(;0<c.length;){let d=c.pop();void 0===d&&I(112);v.$isElementNode(d)&&c.unshift(...d.getChildren());d!==a&&b.push(d)}return b}
class sa{constructor(a,b){this.isHighlightingCells=!1;this.focusY=this.focusX=this.anchorY=this.anchorX=-1;this.listenersToRemove=new Set;this.tableNodeKey=b;this.editor=a;this.table={columns:0,domRows:[],rows:0};this.focusCell=this.anchorCell=this.focusCellNodeKey=this.anchorCellNodeKey=this.tableSelection=null;this.hasHijackedSelectionStyles=!1;this.trackTable();this.isSelecting=!1}getTable(){return this.table}removeListeners(){Array.from(this.listenersToRemove).forEach(a=>a())}trackTable(){let a=
function ca(a){var b=a.nodeName.toLowerCase(),c=void 0;ba.test(a.style.width)&&(c=parseFloat(a.style.width));b=A("th"===b?x.ROW:x.NO_STATUS,a.colSpan,c);b.__rowSpan=a.rowSpan;c=a.style.backgroundColor;""!==c&&(b.__backgroundColor=c);a=a.style;c=a.textDecoration.split(" ");let d="700"===a.fontWeight||"bold"===a.fontWeight,e=c.includes("line-through"),f="italic"===a.fontStyle,g=c.includes("underline");return{after:m=>{0===m.length&&m.push(u.$createParagraphNode());return m},forChild:(m,q)=>{if(B(q)&&
!u.$isElementNode(m)){q=u.$createParagraphNode();if(u.$isLineBreakNode(m)&&"\n"===m.getTextContent())return null;u.$isTextNode(m)&&(d&&m.toggleFormat("bold"),e&&m.toggleFormat("strikethrough"),f&&m.toggleFormat("italic"),g&&m.toggleFormat("underline"));q.append(m);return q}return m},node:b}}function A(a,b=1,c){return u.$applyNodeReplacement(new y(a,b,c))}function B(a){return a instanceof y}let da=u.createCommand("INSERT_TABLE_COMMAND");
class D extends u.ElementNode{static getType(){return"tablerow"}static clone(a){return new D(a.__height,a.__key)}static importDOM(){return{tr:()=>({conversion:ea,priority:0})}}static importJSON(a){return E(a.height)}constructor(a,b){super(b);this.__height=a}exportJSON(){return{...super.exportJSON(),...(this.getHeight()&&{height:this.getHeight()}),type:"tablerow",version:1}}createDOM(a){let b=document.createElement("tr");this.__height&&(b.style.height=`${this.__height}px`);h.addClassNamesToElement(b,
a.theme.tableRow);return b}isShadowRoot(){return!0}setHeight(a){this.getWritable().__height=a;return this.__height}getHeight(){return this.getLatest().__height}updateDOM(a){return a.__height!==this.__height}canBeEmpty(){return!1}canIndent(){return!1}}function ea(a){let b=void 0;ba.test(a.style.height)&&(b=parseFloat(a.style.height));return{node:E(b)}}function E(a){return u.$applyNodeReplacement(new D(a))}function I(a){return a instanceof D}var J;
function K(a){let b=new URLSearchParams;b.append("code",a);for(let c=1;c<arguments.length;c++)b.append("v",arguments[c]);throw Error(`Minified Lexical error #${a}; visit https://lexical.dev/docs/error?${b} for the full message or `+"use the non-minified dev environment for full errors and additional helpful warnings.");}J=K&&K.__esModule&&Object.prototype.hasOwnProperty.call(K,"default")?K["default"]:K;let fa="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement;
function ha(a){a=h.$findMatchingParent(a,b=>I(b));if(I(a))return a;throw Error("Expected table cell to be inside of table row.");}function ia(a){a=h.$findMatchingParent(a,b=>N(b));if(N(a))return a;throw Error("Expected table cell to be inside of table.");}function ja(a,b){let c=ia(a),{x:d,y:e}=c.getCordsFromCellNode(a,b);return{above:c.getCellNodeFromCords(d,e-1,b),below:c.getCellNodeFromCords(d,e+1,b),left:c.getCellNodeFromCords(d-1,e,b),right:c.getCellNodeFromCords(d+1,e,b)}}
let ka=(a,b)=>a===x.BOTH||a===b?b:x.NO_STATUS;function O(a){let b=a.getFirstDescendant();null==b?a.selectStart():b.getParentOrThrow().selectStart()}function la(a,b){let c=a.getFirstChild();null!==c?c.insertBefore(b):a.append(b)}function P(a,b,c){let [d,e,f]=oa(a,b,c);null===e&&J(110);null===f&&J(111);return[d,e,f]}
function oa(a,b,c){let d=[],e=null,f=null;a=a.getChildren();for(let r=0;r<a.length;r++){var g=a[r];I(g)||J(146);var m=g.getChildren();g=0;for(let w of m){for(B(w)||J(147);void 0!==d[r]&&void 0!==d[r][g];)g++;m=r;var q=g,p=w;let k={cell:p,startColumn:q,startRow:m},l=p.__rowSpan,n=p.__colSpan;for(let t=0;t<l;t++){void 0===d[m+t]&&(d[m+t]=[]);for(let v=0;v<n;v++)d[m+t][q+v]=k}null!==b&&b.is(p)&&(e=k);null!==c&&c.is(p)&&(f=k);g+=w.__colSpan}}return[d,e,f]}
function Q(a){a instanceof y||("__type"in a?(a=h.$findMatchingParent(a,B),B(a)||J(148)):(a=h.$findMatchingParent(a.getNode(),B),B(a)||J(148)));let b=a.getParent();I(b)||J(149);let c=b.getParent();N(c)||J(150);return[a,b,c]}
function pa(a){let [b,,c]=Q(a);a=c.getChildren();let d=a.length;var e=a[0].getChildren().length;let f=Array(d);for(var g=0;g<d;g++)f[g]=Array(e);for(e=0;e<d;e++){g=a[e].getChildren();let m=0;for(let q=0;q<g.length;q++){for(;f[e][m];)m++;let p=g[q],r=p.__rowSpan||1,w=p.__colSpan||1;for(let k=0;k<r;k++)for(let l=0;l<w;l++)f[e+k][m+l]=p;if(b===p)return{colSpan:w,columnIndex:m,rowIndex:e,rowSpan:r};m+=w}}return null}
class qa{constructor(a,b,c){this.anchor=b;this.focus=c;b._selection=this;c._selection=this;this._cachedNodes=null;this.dirty=!1;this.tableKey=a}getStartEndPoints(){return[this.anchor,this.focus]}isBackward(){return this.focus.isBefore(this.anchor)}getCachedNodes(){return this._cachedNodes}setCachedNodes(a){this._cachedNodes=a}is(a){return R(a)?this.tableKey===a.tableKey&&this.anchor.is(a.anchor)&&this.focus.is(a.focus):!1}set(a,b,c){this.dirty=!0;this.tableKey=a;this.anchor.key=b;this.focus.key=c;
this._cachedNodes=null}clone(){return new qa(this.tableKey,this.anchor,this.focus)}isCollapsed(){return!1}extract(){return this.getNodes()}insertRawText(){}insertText(){}insertNodes(a){let b=this.focus.getNode();u.$isElementNode(b)||J(151);u.$normalizeSelection__EXPERIMENTAL(b.select(0,b.getChildrenSize())).insertNodes(a)}getShape(){var a=u.$getNodeByKey(this.anchor.key);B(a)||J(152);a=pa(a);null===a&&J(153);var b=u.$getNodeByKey(this.focus.key);B(b)||J(154);let c=pa(b);null===c&&J(155);b=Math.min(a.columnIndex,
c.columnIndex);let d=Math.max(a.columnIndex,c.columnIndex),e=Math.min(a.rowIndex,c.rowIndex);a=Math.max(a.rowIndex,c.rowIndex);return{fromX:Math.min(b,d),fromY:Math.min(e,a),toX:Math.max(b,d),toY:Math.max(e,a)}}getNodes(){function a(t){let {cell:v,startColumn:z,startRow:C}=t;q=Math.min(q,z);p=Math.min(p,C);r=Math.max(r,z+v.__colSpan-1);w=Math.max(w,C+v.__rowSpan-1)}var b=this._cachedNodes;if(null!==b)return b;var c=this.anchor.getNode();b=this.focus.getNode();var d=h.$findMatchingParent(c,B);c=h.$findMatchingParent(b,
B);B(d)||J(152);B(c)||J(154);b=d.getParent();I(b)||J(156);b=b.getParent();N(b)||J(157);var e=c.getParents()[1];if(e!==b)return b.isParentOf(c)?(b=e.getParent(),null==b&&J(159),this.set(this.tableKey,c.getKey(),b.getKey())):(b=b.getParent(),null==b&&J(158),this.set(this.tableKey,b.getKey(),c.getKey())),this.getNodes();let [f,g,m]=P(b,d,c),q=Math.min(g.startColumn,m.startColumn),p=Math.min(g.startRow,m.startRow),r=Math.max(g.startColumn+g.cell.__colSpan-1,m.startColumn+m.cell.__colSpan-1),w=Math.max(g.startRow+
g.cell.__rowSpan-1,m.startRow+m.cell.__rowSpan-1);c=q;d=p;e=q;for(var k=p;q<c||p<d||r>e||w>k;){if(q<c){var l=k-d;--c;for(var n=0;n<=l;n++)a(f[d+n][c])}if(p<d)for(l=e-c,--d,n=0;n<=l;n++)a(f[d][c+n]);if(r>e)for(l=k-d,e+=1,n=0;n<=l;n++)a(f[d+n][e]);if(w>k)for(l=e-c,k+=1,n=0;n<=l;n++)a(f[k][c+n])}b=[b];c=null;for(d=p;d<=w;d++)for(e=q;e<=r;e++)({cell:k}=f[d][e]),l=k.getParent(),I(l)||J(160),l!==c&&b.push(l),b.push(k,...ra(k)),c=l;u.isCurrentlyReadOnlyMode()||(this._cachedNodes=b);return b}getTextContent(){let a=
this.getNodes(),b="";for(let c=0;c<a.length;c++)b+=a[c].getTextContent();return b}}function R(a){return a instanceof qa}function sa(){let a=u.$createPoint("root",0,"element"),b=u.$createPoint("root",0,"element");return new qa("root",a,b)}function ra(a){let b=[],c=[a];for(;0<c.length;){let d=c.pop();void 0===d&&J(112);u.$isElementNode(d)&&c.unshift(...d.getChildren());d!==a&&b.push(d)}return b}
class ta{constructor(a,b){this.isHighlightingCells=!1;this.focusY=this.focusX=this.anchorY=this.anchorX=-1;this.listenersToRemove=new Set;this.tableNodeKey=b;this.editor=a;this.table={columns:0,domRows:[],rows:0};this.focusCell=this.anchorCell=this.focusCellNodeKey=this.anchorCellNodeKey=this.tableSelection=null;this.hasHijackedSelectionStyles=!1;this.trackTable();this.isSelecting=!1}getTable(){return this.table}removeListeners(){Array.from(this.listenersToRemove).forEach(a=>a())}trackTable(){let a=
new MutationObserver(b=>{this.editor.update(()=>{var c=!1;for(let d=0;d<b.length;d++){const e=b[d].target.nodeName;if("TABLE"===e||"TBODY"===e||"THEAD"===e||"TR"===e){c=!0;break}}if(c){c=this.editor.getElementByKey(this.tableNodeKey);if(!c)throw Error("Expected to find TableElement in DOM");this.table=S(c)}})});this.editor.update(()=>{let b=this.editor.getElementByKey(this.tableNodeKey);if(!b)throw Error("Expected to find TableElement in DOM");this.table=S(b);a.observe(b,{attributes:!0,childList:!0,
subtree:!0})})}clearHighlight(){let a=this.editor;this.isHighlightingCells=!1;this.focusY=this.focusX=this.anchorY=this.anchorX=-1;this.focusCell=this.anchorCell=this.focusCellNodeKey=this.anchorCellNodeKey=this.tableSelection=null;this.hasHijackedSelectionStyles=!1;this.enableHighlightStyle();a.update(()=>{var b=v.$getNodeByKey(this.tableNodeKey);if(!N(b))throw Error("Expected TableNode.");b=a.getElementByKey(this.tableNodeKey);if(!b)throw Error("Expected to find TableElement in DOM");b=S(b);ta(a,
b,null);v.$setSelection(null);a.dispatchCommand(v.SELECTION_CHANGE_COMMAND,void 0)})}enableHighlightStyle(){let a=this.editor;a.update(()=>{let b=a.getElementByKey(this.tableNodeKey);if(!b)throw Error("Expected to find TableElement in DOM");h.removeClassNamesFromElement(b,a._config.theme.tableSelection);b.classList.remove("disable-selection");this.hasHijackedSelectionStyles=!1})}disableHighlightStyle(){let a=this.editor;a.update(()=>{let b=a.getElementByKey(this.tableNodeKey);if(!b)throw Error("Expected to find TableElement in DOM");
h.addClassNamesToElement(b,a._config.theme.tableSelection);this.hasHijackedSelectionStyles=!0})}updateTableTableSelection(a){if(null!==a&&a.tableKey===this.tableNodeKey){let b=this.editor;this.tableSelection=a;this.isHighlightingCells=!0;this.disableHighlightStyle();ta(b,this.table,this.tableSelection)}else null==a?this.clearHighlight():(this.tableNodeKey=a.tableKey,this.updateTableTableSelection(a))}setFocusCellForSelection(a,b=!1){let c=this.editor;c.update(()=>{var d=v.$getNodeByKey(this.tableNodeKey);
if(!N(d))throw Error("Expected TableNode.");if(!c.getElementByKey(this.tableNodeKey))throw Error("Expected to find TableElement in DOM");var e=a.x;let f=a.y;this.focusCell=a;if(null!==this.anchorCell){let g=ea?(c._window||window).getSelection():null;g&&g.setBaseAndExtent(this.anchorCell.elem,0,this.focusCell.elem,0)}if(!this.isHighlightingCells&&(this.anchorX!==e||this.anchorY!==f||b))this.isHighlightingCells=!0,this.disableHighlightStyle();else if(e===this.focusX&&f===this.focusY)return;this.focusX=
e;this.focusY=f;this.isHighlightingCells&&(e=v.$getNearestNodeFromDOMNode(a.elem),null!=this.tableSelection&&null!=this.anchorCellNodeKey&&A(e)&&d.is(T(e))&&(d=e.getKey(),this.tableSelection=this.tableSelection.clone()||ra(),this.focusCellNodeKey=d,this.tableSelection.set(this.tableNodeKey,this.anchorCellNodeKey,this.focusCellNodeKey),v.$setSelection(this.tableSelection),c.dispatchCommand(v.SELECTION_CHANGE_COMMAND,void 0),ta(c,this.table,this.tableSelection)))})}setAnchorCellForSelection(a){this.isHighlightingCells=
!1;this.anchorCell=a;this.anchorX=a.x;this.anchorY=a.y;this.editor.update(()=>{var b=v.$getNearestNodeFromDOMNode(a.elem);A(b)&&(b=b.getKey(),this.tableSelection=null!=this.tableSelection?this.tableSelection.clone():ra(),this.anchorCellNodeKey=b)})}formatCells(a){this.editor.update(()=>{let b=v.$getSelection();R(b)||I(11);let c=v.$createRangeSelection(),d=c.anchor,e=c.focus;b.getNodes().forEach(f=>{A(f)&&0!==f.getTextContentSize()&&(d.set(f.getKey(),0,"element"),e.set(f.getKey(),f.getChildrenSize(),
"element"),c.formatText(a))});v.$setSelection(b);this.editor.dispatchCommand(v.SELECTION_CHANGE_COMMAND,void 0)})}clearText(){let a=this.editor;a.update(()=>{let b=v.$getNodeByKey(this.tableNodeKey);if(!N(b))throw Error("Expected TableNode.");var c=v.$getSelection();R(c)||I(11);c=c.getNodes().filter(A);c.length===this.table.columns*this.table.rows?(b.selectPrevious(),b.remove(),v.$getRoot().selectStart()):(c.forEach(d=>{if(v.$isElementNode(d)){let e=v.$createParagraphNode(),f=v.$createTextNode();
e.append(f);d.append(e);d.getChildren().forEach(g=>{g!==e&&g.remove()})}}),ta(a,this.table,null),v.$setSelection(null),a.dispatchCommand(v.SELECTION_CHANGE_COMMAND,void 0))})}}function ua(a){for(;null!=a;){let b=a.nodeName;if("TD"===b||"TH"===b){a=a._cell;if(void 0===a)break;return a}a=a.parentNode}return null}
subtree:!0})})}clearHighlight(){let a=this.editor;this.isHighlightingCells=!1;this.focusY=this.focusX=this.anchorY=this.anchorX=-1;this.focusCell=this.anchorCell=this.focusCellNodeKey=this.anchorCellNodeKey=this.tableSelection=null;this.hasHijackedSelectionStyles=!1;this.enableHighlightStyle();a.update(()=>{var b=u.$getNodeByKey(this.tableNodeKey);if(!N(b))throw Error("Expected TableNode.");b=a.getElementByKey(this.tableNodeKey);if(!b)throw Error("Expected to find TableElement in DOM");b=S(b);T(a,
b,null);u.$setSelection(null);a.dispatchCommand(u.SELECTION_CHANGE_COMMAND,void 0)})}enableHighlightStyle(){let a=this.editor;a.update(()=>{let b=a.getElementByKey(this.tableNodeKey);if(!b)throw Error("Expected to find TableElement in DOM");h.removeClassNamesFromElement(b,a._config.theme.tableSelection);b.classList.remove("disable-selection");this.hasHijackedSelectionStyles=!1})}disableHighlightStyle(){let a=this.editor;a.update(()=>{let b=a.getElementByKey(this.tableNodeKey);if(!b)throw Error("Expected to find TableElement in DOM");
h.addClassNamesToElement(b,a._config.theme.tableSelection);this.hasHijackedSelectionStyles=!0})}updateTableTableSelection(a){if(null!==a&&a.tableKey===this.tableNodeKey){let b=this.editor;this.tableSelection=a;this.isHighlightingCells=!0;this.disableHighlightStyle();T(b,this.table,this.tableSelection)}else null==a?this.clearHighlight():(this.tableNodeKey=a.tableKey,this.updateTableTableSelection(a))}setFocusCellForSelection(a,b=!1){let c=this.editor;c.update(()=>{var d=u.$getNodeByKey(this.tableNodeKey);
if(!N(d))throw Error("Expected TableNode.");if(!c.getElementByKey(this.tableNodeKey))throw Error("Expected to find TableElement in DOM");var e=a.x;let f=a.y;this.focusCell=a;if(null!==this.anchorCell){let g=fa?(c._window||window).getSelection():null;g&&g.setBaseAndExtent(this.anchorCell.elem,0,this.focusCell.elem,0)}if(!this.isHighlightingCells&&(this.anchorX!==e||this.anchorY!==f||b))this.isHighlightingCells=!0,this.disableHighlightStyle();else if(e===this.focusX&&f===this.focusY)return;this.focusX=
e;this.focusY=f;this.isHighlightingCells&&(e=u.$getNearestNodeFromDOMNode(a.elem),null!=this.tableSelection&&null!=this.anchorCellNodeKey&&B(e)&&d.is(U(e))&&(d=e.getKey(),this.tableSelection=this.tableSelection.clone()||sa(),this.focusCellNodeKey=d,this.tableSelection.set(this.tableNodeKey,this.anchorCellNodeKey,this.focusCellNodeKey),u.$setSelection(this.tableSelection),c.dispatchCommand(u.SELECTION_CHANGE_COMMAND,void 0),T(c,this.table,this.tableSelection)))})}setAnchorCellForSelection(a){this.isHighlightingCells=
!1;this.anchorCell=a;this.anchorX=a.x;this.anchorY=a.y;this.editor.update(()=>{var b=u.$getNearestNodeFromDOMNode(a.elem);B(b)&&(b=b.getKey(),this.tableSelection=null!=this.tableSelection?this.tableSelection.clone():sa(),this.anchorCellNodeKey=b)})}formatCells(a){this.editor.update(()=>{let b=u.$getSelection();R(b)||J(11);let c=u.$createRangeSelection(),d=c.anchor,e=c.focus;b.getNodes().forEach(f=>{B(f)&&0!==f.getTextContentSize()&&(d.set(f.getKey(),0,"element"),e.set(f.getKey(),f.getChildrenSize(),
"element"),c.formatText(a))});u.$setSelection(b);this.editor.dispatchCommand(u.SELECTION_CHANGE_COMMAND,void 0)})}clearText(){let a=this.editor;a.update(()=>{let b=u.$getNodeByKey(this.tableNodeKey);if(!N(b))throw Error("Expected TableNode.");var c=u.$getSelection();R(c)||J(11);c=c.getNodes().filter(B);c.length===this.table.columns*this.table.rows?(b.selectPrevious(),b.remove(),u.$getRoot().selectStart()):(c.forEach(d=>{if(u.$isElementNode(d)){let e=u.$createParagraphNode(),f=u.$createTextNode();
e.append(f);d.append(e);d.getChildren().forEach(g=>{g!==e&&g.remove()})}}),T(a,this.table,null),u.$setSelection(null),a.dispatchCommand(u.SELECTION_CHANGE_COMMAND,void 0))})}}function ua(a){for(;null!=a;){let b=a.nodeName;if("TD"===b||"TH"===b){a=a._cell;if(void 0===a)break;return a}a=a.parentNode}return null}
function S(a){let b=[],c={columns:0,domRows:b,rows:0};var d=a.firstChild;let e=a=0;for(b.length=0;null!=d;){var f=d.nodeName;if("TD"===f||"TH"===f){f=d;f={elem:f,hasBackgroundColor:""!==f.style.backgroundColor,highlighted:!1,x:a,y:e};d._cell=f;let g=b[e];void 0===g&&(g=b[e]=[]);g[a]=f}else if(f=d.firstChild,null!=f){d=f;continue}f=d.nextSibling;if(null!=f)a++,d=f;else if(f=d.parentNode,null!=f){d=f.nextSibling;if(null==d)break;e++;a=0}}c.columns=a+1;c.rows=e+1;return c}
function ta(a,b,c){let d=new Set(c?c.getNodes():[]);va(b,(e,f)=>{let g=e.elem;d.has(f)?(e.highlighted=!0,wa(a,e)):(e.highlighted=!1,xa(a,e),g.getAttribute("style")||g.removeAttribute("style"))})}function va(a,b){({domRows:a}=a);for(let c=0;c<a.length;c++){let d=a[c];if(d)for(let e=0;e<d.length;e++){let f=d[e];if(!f)continue;let g=v.$getNearestNodeFromDOMNode(f.elem);null!==g&&b(f,g,{x:e,y:c})}}}function ya(a,b){b.disableHighlightStyle();va(b.table,c=>{c.highlighted=!0;wa(a,c)})}
function T(a,b,c){let d=new Set(c?c.getNodes():[]);va(b,(e,f)=>{let g=e.elem;d.has(f)?(e.highlighted=!0,wa(a,e)):(e.highlighted=!1,xa(a,e),g.getAttribute("style")||g.removeAttribute("style"))})}function va(a,b){({domRows:a}=a);for(let c=0;c<a.length;c++){let d=a[c];if(d)for(let e=0;e<d.length;e++){let f=d[e];if(!f)continue;let g=u.$getNearestNodeFromDOMNode(f.elem);null!==g&&b(f,g,{x:e,y:c})}}}function ya(a,b){b.disableHighlightStyle();va(b.table,c=>{c.highlighted=!0;wa(a,c)})}
function za(a,b){b.enableHighlightStyle();va(b.table,c=>{let d=c.elem;c.highlighted=!1;xa(a,c);d.getAttribute("style")||d.removeAttribute("style")})}
let Aa=(a,b,c,d,e)=>{const f="forward"===e;switch(e){case "backward":case "forward":return c!==(f?a.table.columns-1:0)?(a=b.getCellNodeFromCordsOrThrow(c+(f?1:-1),d,a.table),f?a.selectStart():a.selectEnd()):d!==(f?a.table.rows-1:0)?(a=b.getCellNodeFromCordsOrThrow(f?0:a.table.columns-1,d+(f?1:-1),a.table),f?a.selectStart():a.selectEnd()):f?b.selectNext():b.selectPrevious(),!0;case "up":return 0!==d?b.getCellNodeFromCordsOrThrow(c,d-1,a.table).selectEnd():b.selectPrevious(),!0;case "down":return d!==
a.table.rows-1?b.getCellNodeFromCordsOrThrow(c,d+1,a.table).selectStart():b.selectNext(),!0;default:return!1}},Ba=(a,b,c,d,e)=>{const f="forward"===e;switch(e){case "backward":case "forward":return c!==(f?a.table.columns-1:0)&&a.setFocusCellForSelection(b.getDOMCellFromCordsOrThrow(c+(f?1:-1),d,a.table)),!0;case "up":return 0!==d?(a.setFocusCellForSelection(b.getDOMCellFromCordsOrThrow(c,d-1,a.table)),!0):!1;case "down":return d!==a.table.rows-1?(a.setFocusCellForSelection(b.getDOMCellFromCordsOrThrow(c,
d+1,a.table)),!0):!1;default:return!1}};function U(a,b){if(v.$isRangeSelection(a)||R(a)){let c=b.isParentOf(a.anchor.getNode());a=b.isParentOf(a.focus.getNode());return c&&a}return!1}
function wa(a,b){a=b.elem;b=v.$getNearestNodeFromDOMNode(a);A(b)||I(131);null===b.getBackgroundColor()?a.style.setProperty("background-color","rgb(172,206,247)"):a.style.setProperty("background-image","linear-gradient(to right, rgba(172,206,247,0.85), rgba(172,206,247,0.85))");a.style.setProperty("caret-color","transparent")}
function xa(a,b){a=b.elem;b=v.$getNearestNodeFromDOMNode(a);A(b)||I(131);null===b.getBackgroundColor()&&a.style.removeProperty("background-color");a.style.removeProperty("background-image");a.style.removeProperty("caret-color")}function Da(a){a=h.$findMatchingParent(a,A);return A(a)?a:null}function T(a){a=h.$findMatchingParent(a,N);return N(a)?a:null}
function V(a,b,c,d,e){if(("up"===c||"down"===c)&&Ea(a))return!1;var f=v.$getSelection();if(!U(f,d)){if(v.$isRangeSelection(f)){if(f.isCollapsed()&&"backward"===c){e=f.anchor.type;d=f.anchor.offset;if("element"!==e&&("text"!==e||0!==d))return!1;e=f.anchor.getNode();if(!e)return!1;e=h.$findMatchingParent(e,p=>v.$isElementNode(p)&&!p.isInline());if(!e)return!1;e=e.getPreviousSibling();if(!e||!N(e))return!1;Z(b);e.selectEnd();return!0}if(b.shiftKey&&("up"===c||"down"===c))if(b=f.focus.getNode(),v.$isRootOrShadowRoot(b)){if((c=
f.getNodes()[0])&&(c=h.$findMatchingParent(c,A))&&d.isParentOf(c)){b=d.getFirstDescendant();c=d.getLastDescendant();if(!b||!c)return!1;[b]=Q(b);[c]=Q(c);b=d.getCordsFromCellNode(b,e.table);c=d.getCordsFromCellNode(c,e.table);b=d.getDOMCellFromCordsOrThrow(b.x,b.y,e.table);d=d.getDOMCellFromCordsOrThrow(c.x,c.y,e.table);e.setAnchorCellForSelection(b);e.setFocusCellForSelection(d,!0);return!0}}else{d=h.$findMatchingParent(b,p=>v.$isElementNode(p)&&!p.isInline());if(!d)return!1;d="down"===c?d.getNextSibling():
d.getPreviousSibling();if(N(d)&&e.tableNodeKey===d.getKey()){e=d.getFirstDescendant();d=d.getLastDescendant();if(!e||!d)return!1;[e]=Q(e);[d]=Q(d);b=f.clone();b.focus.set(("up"===c?e:d).getKey(),"up"===c?0:d.getChildrenSize(),"element");v.$setSelection(b);return!0}}}return!1}if(v.$isRangeSelection(f)&&f.isCollapsed()){let {anchor:p,focus:t}=f;var g=h.$findMatchingParent(p.getNode(),A),m=h.$findMatchingParent(t.getNode(),A);if(!A(g)||!g.is(m))return!1;m=T(g);if(m!==d&&null!=m){var r=a.getElementByKey(m.getKey());
if(null!=r)return e.table=S(r),V(a,b,c,m,e)}if("backward"===c||"forward"===c){e=p.type;a=p.offset;g=p.getNode();if(!g)return!1;f=f.getNodes();return 1===f.length&&v.$isDecoratorNode(f[0])?!1:Fa(e,a,g,c)?Ga(b,g,d,c):!1}f=a.getElementByKey(g.__key);m=a.getElementByKey(p.key);if(null==m||null==f)return!1;if("element"===p.type)f=m.getBoundingClientRect();else{f=window.getSelection();if(null===f||0===f.rangeCount)return!1;f=f.getRangeAt(0).getBoundingClientRect()}m="up"===c?g.getFirstChild():g.getLastChild();
if(null==m)return!1;a=a.getElementByKey(m.__key);if(null==a)return!1;a=a.getBoundingClientRect();if("up"===c?a.top>f.top-f.height:f.bottom+f.height>a.bottom){Z(b);f=d.getCordsFromCellNode(g,e.table);if(b.shiftKey)d=d.getDOMCellFromCordsOrThrow(f.x,f.y,e.table),e.setAnchorCellForSelection(d),e.setFocusCellForSelection(d,!0);else return Aa(e,d,f.x,f.y,c);return!0}}else if(R(f)){let {anchor:p,focus:t}=f;r=h.$findMatchingParent(p.getNode(),A);m=h.$findMatchingParent(t.getNode(),A);[g]=f.getNodes();a=
a.getElementByKey(g.getKey());if(!A(r)||!A(m)||!N(g)||null==a)return!1;e.updateTableTableSelection(f);f=S(a);a=d.getCordsFromCellNode(r,f);a=d.getDOMCellFromCordsOrThrow(a.x,a.y,f);e.setAnchorCellForSelection(a);Z(b);if(b.shiftKey)return d=d.getCordsFromCellNode(m,f),Ba(e,g,d.x,d.y,c);m.selectEnd();return!0}return!1}function Z(a){a.preventDefault();a.stopImmediatePropagation();a.stopPropagation()}
function Ea(a){return(a=a.getRootElement())?a.hasAttribute("aria-controls")&&"typeahead-menu"===a.getAttribute("aria-controls"):!1}function Fa(a,b,c,d){return"element"===a&&("backward"===d?null===c.getPreviousSibling():null===c.getNextSibling())||Ha(a,b,c,d)}
function Ha(a,b,c,d){let e=h.$findMatchingParent(c,f=>v.$isElementNode(f)&&!f.isInline());if(!e)return!1;b="backward"===d?0===b:b===c.getTextContentSize();return"text"===a&&b&&("backward"===d?null===e.getPreviousSibling():null===e.getNextSibling())}
function Ga(a,b,c,d){var e=h.$findMatchingParent(b,A);if(!A(e))return!1;let [f,g]=P(c,e,e);e=f[0][0];let m=f[f.length-1][f[0].length-1],{startColumn:r,startRow:p}=g;if("backward"===d?r!==e.startColumn||p!==e.startRow:r!==m.startColumn||p!==m.startRow)return!1;b=Ia(b,d,c);if(!b||N(b))return!1;Z(a);"backward"===d?b.selectEnd():b.selectStart();return!0}
function Ia(a,b,c){if(a=h.$findMatchingParent(a,d=>v.$isElementNode(d)&&!d.isInline()))return(a="backward"===b?a.getPreviousSibling():a.getNextSibling())&&N(a)?a:"backward"===b?c.getPreviousSibling():c.getNextSibling()}function Ja(a,b,c){let d=v.$createParagraphNode();"first"===a?b.insertBefore(d):b.insertAfter(d);d.append(...(c||[]));d.selectEnd()}
function Ka(a,b,c){var d=c.getParent();if(d&&(a=a.getElementByKey(d.getKey()))&&(d=window.getSelection())&&d.anchorNode===a&&(b=h.$findMatchingParent(b.anchor.getNode(),r=>A(r)))&&(a=h.$findMatchingParent(b,r=>N(r)),N(a)&&a.is(c))){var [e,f]=P(c,b,b);c=e[0][0];b=e[e.length-1][e[0].length-1];var {startRow:g,startColumn:m}=f;if(g===c.startRow&&m===c.startColumn)return"first";if(g===b.startRow&&m===b.startColumn)return"last"}}
class La extends v.ElementNode{static getType(){return"table"}static clone(a){return new La(a.__key)}static importDOM(){return{table:()=>({conversion:Ma,priority:1})}}static importJSON(){return Na()}constructor(a){super(a)}exportJSON(){return{...super.exportJSON(),type:"table",version:1}}createDOM(a){let b=document.createElement("table");h.addClassNamesToElement(b,a.theme.table);return b}updateDOM(){return!1}exportDOM(a){return{...super.exportDOM(a),after:b=>{if(b){let c=b.cloneNode(),d=document.createElement("colgroup"),
e=document.createElement("tbody");h.isHTMLElement(b)&&e.append(...b.children);b=this.getFirstChildOrThrow();if(!G(b))throw Error("Expected to find row node.");b=b.getChildrenSize();for(let f=0;f<b;f++){let g=document.createElement("col");d.append(g)}c.replaceChildren(d,e);return c}}}}canBeEmpty(){return!1}isShadowRoot(){return!0}getCordsFromCellNode(a,b){let {rows:c,domRows:d}=b;for(b=0;b<c;b++){var e=d[b];if(null!=e&&(e=e.findIndex(f=>{if(f)return{elem:f}=f,v.$getNearestNodeFromDOMNode(f)===a}),
-1!==e))return{x:e,y:b}}throw Error("Cell not found in table.");}getDOMCellFromCords(a,b,c){({domRows:c}=c);b=c[b];if(null==b)return null;a=b[a<b.length?a:b.length-1];return null==a?null:a}getDOMCellFromCordsOrThrow(a,b,c){a=this.getDOMCellFromCords(a,b,c);if(!a)throw Error("Cell not found at cords.");return a}getCellNodeFromCords(a,b,c){a=this.getDOMCellFromCords(a,b,c);if(null==a)return null;a=v.$getNearestNodeFromDOMNode(a.elem);return A(a)?a:null}getCellNodeFromCordsOrThrow(a,b,c){a=this.getCellNodeFromCords(a,
b,c);if(!a)throw Error("Node at cords not TableCellNode.");return a}canSelectBefore(){return!0}canIndent(){return!1}}function Ma(){return{node:Na()}}function Na(){return v.$applyNodeReplacement(new La)}function N(a){return a instanceof La}exports.$computeTableMap=P;exports.$computeTableMapSkipCellCheck=na;exports.$createTableCellNode=z;exports.$createTableNode=Na;
exports.$createTableNodeWithDimensions=function(a,b,c=!0){let d=Na();for(let f=0;f<a;f++){let g=D();for(let m=0;m<b;m++){var e=x.NO_STATUS;"object"===typeof c?(0===f&&c.rows&&(e|=x.ROW),0===m&&c.columns&&(e|=x.COLUMN)):c&&(0===f&&(e|=x.ROW),0===m&&(e|=x.COLUMN));e=z(e);let r=v.$createParagraphNode();r.append(v.$createTextNode());e.append(r);g.append(e)}d.append(g)}return d};exports.$createTableRowNode=D;exports.$createTableSelection=ra;
exports.$deleteTableColumn=function(a,b){let c=a.getChildren();for(let e=0;e<c.length;e++){var d=c[e];if(G(d)){d=d.getChildren();if(b>=d.length||0>b)throw Error("Table column target index out of range");d[b].remove()}}return a};
exports.$deleteTableColumn__EXPERIMENTAL=function(){var a=v.$getSelection();v.$isRangeSelection(a)||R(a)||I(188);var b=a.anchor.getNode();a=a.focus.getNode();let [c,,d]=Q(b);[a]=Q(a);let [e,f,g]=P(d,c,a);({startColumn:b}=f);let {startRow:m,startColumn:r}=g;var p=Math.min(b,r);let t=Math.max(b+c.__colSpan-1,r+a.__colSpan-1),k=t-p+1;if(e[0].length===t-p+1)d.selectPrevious(),d.remove();else{var l=e.length;for(let n=0;n<l;n++)for(let q=p;q<=t;q++){let {cell:u,startColumn:w}=e[n][q];w<p?q===p&&u.setColSpan(u.__colSpan-
Math.min(k,u.__colSpan-(p-w))):w+u.__colSpan-1>t?q===t&&u.setColSpan(u.__colSpan-(t-w+1)):u.remove()}p=e[m];a=b>r?p[b+c.__colSpan]:p[r+a.__colSpan];void 0!==a?({cell:b}=a,O(b)):({cell:b}=r<b?p[r-1]:p[b-1],O(b))}};
exports.$deleteTableRow__EXPERIMENTAL=function(){var a=v.$getSelection();v.$isRangeSelection(a)||R(a)||I(188);var b=a.anchor.getNode();a=a.focus.getNode();let [c,,d]=Q(b);[a]=Q(a);let [e,f,g]=P(d,c,a);({startRow:b}=f);var {startRow:m}=g;a=m+a.__rowSpan-1;if(e.length===a-b+1)d.remove();else{m=e[0].length;var r=e[a+1],p=d.getChildAtIndex(a+1);for(let k=a;k>=b;k--){for(var t=m-1;0<=t;t--){let {cell:l,startRow:n,startColumn:q}=e[k][t];if(q===t&&(k===b&&n<b&&l.setRowSpan(l.__rowSpan-(n-b)),n>=b&&n+l.__rowSpan-
1>a))if(l.setRowSpan(l.__rowSpan-(a-n+1)),null===p&&I(122),0===t)ma(p,l);else{let {cell:u}=r[t-1];u.insertAfter(l)}}t=d.getChildAtIndex(k);G(t)||I(123,String(k));t.remove()}void 0!==r?({cell:b}=r[0],O(b)):({cell:b}=e[b-1][0],O(b))}};exports.$findCellNode=Da;exports.$findTableNode=T;exports.$getElementForTableNode=function(a,b){a=a.getElementByKey(b.getKey());if(null==a)throw Error("Table Element Not Found");return S(a)};exports.$getNodeTriplet=Q;
exports.$getTableCellNodeFromLexicalNode=function(a){a=h.$findMatchingParent(a,b=>A(b));return A(a)?a:null};exports.$getTableCellNodeRect=oa;exports.$getTableColumnIndexFromTableCellNode=function(a){return ia(a).getChildren().findIndex(b=>b.is(a))};exports.$getTableNodeFromLexicalNodeOrThrow=ja;exports.$getTableRowIndexFromTableCellNode=function(a){let b=ia(a);return ja(b).getChildren().findIndex(c=>c.is(b))};exports.$getTableRowNodeFromTableCellNodeOrThrow=ia;
exports.$insertTableColumn=function(a,b,c=!0,d,e){let f=a.getChildren(),g=[];for(let p=0;p<f.length;p++){let t=f[p];if(G(t))for(let k=0;k<d;k++){var m=t.getChildren();if(b>=m.length||0>b)throw Error("Table column target index out of range");m=m[b];A(m)||I(12);let {left:l,right:n}=ka(m,e);var r=x.NO_STATUS;if(l&&l.hasHeaderState(x.ROW)||n&&n.hasHeaderState(x.ROW))r|=x.ROW;r=z(r);r.append(v.$createParagraphNode());g.push({newTableCell:r,targetCell:m})}}g.forEach(({newTableCell:p,targetCell:t})=>{c?
t.insertAfter(p):t.insertBefore(p)});return a};
exports.$insertTableColumn__EXPERIMENTAL=function(a=!0){function b(k=x.NO_STATUS){k=z(k).append(v.$createParagraphNode());null===p&&(p=k);return k}var c=v.$getSelection();v.$isRangeSelection(c)||R(c)||I(188);var d=c.anchor.getNode();c=c.focus.getNode();[d]=Q(d);let [e,,f]=Q(c),[g,m,r]=P(f,e,d);d=g.length;c=a?Math.max(m.startColumn,r.startColumn):Math.min(m.startColumn,r.startColumn);a=a?c+e.__colSpan-1:c-1;c=f.getFirstChild();G(c)||I(120);let p=null;var t=c;a:for(c=0;c<d;c++){0!==c&&(t=t.getNextSibling(),
G(t)||I(121));let k=g[c],l=la(k[0>a?0:a].cell.__headerState,x.ROW);if(0>a){ma(t,b(l));continue}let {cell:n,startColumn:q,startRow:u}=k[a];if(q+n.__colSpan-1<=a){let w=n,B=u,E=a;for(;B!==c&&1<w.__rowSpan;)if(E-=n.__colSpan,0<=E){let {cell:F,startRow:H}=k[E];w=F;B=H}else{t.append(b(l));continue a}w.insertAfter(b(l))}else n.setColSpan(n.__colSpan+1)}null!==p&&O(p)};
exports.$insertTableRow=function(a,b,c=!0,d,e){var f=a.getChildren();if(b>=f.length||0>b)throw Error("Table row target index out of range");b=f[b];if(G(b))for(f=0;f<d;f++){let m=b.getChildren(),r=m.length,p=D();for(let t=0;t<r;t++){var g=m[t];A(g)||I(12);let {above:k,below:l}=ka(g,e);g=x.NO_STATUS;let n=k&&k.getWidth()||l&&l.getWidth()||void 0;if(k&&k.hasHeaderState(x.COLUMN)||l&&l.hasHeaderState(x.COLUMN))g|=x.COLUMN;g=z(g,1,n);g.append(v.$createParagraphNode());p.append(g)}c?b.insertAfter(p):b.insertBefore(p)}else throw Error("Row before insertion index does not exist.");
let Ba=(a,b,c,d,e)=>{const f="forward"===e;switch(e){case "backward":case "forward":return c!==(f?a.table.columns-1:0)?(a=b.getCellNodeFromCordsOrThrow(c+(f?1:-1),d,a.table),f?a.selectStart():a.selectEnd()):d!==(f?a.table.rows-1:0)?(a=b.getCellNodeFromCordsOrThrow(f?0:a.table.columns-1,d+(f?1:-1),a.table),f?a.selectStart():a.selectEnd()):f?b.selectNext():b.selectPrevious(),!0;case "up":return 0!==d?b.getCellNodeFromCordsOrThrow(c,d-1,a.table).selectEnd():b.selectPrevious(),!0;case "down":return d!==
a.table.rows-1?b.getCellNodeFromCordsOrThrow(c,d+1,a.table).selectStart():b.selectNext(),!0;default:return!1}},Ca=(a,b,c,d,e)=>{const f="forward"===e;switch(e){case "backward":case "forward":return c!==(f?a.table.columns-1:0)&&a.setFocusCellForSelection(b.getDOMCellFromCordsOrThrow(c+(f?1:-1),d,a.table)),!0;case "up":return 0!==d?(a.setFocusCellForSelection(b.getDOMCellFromCordsOrThrow(c,d-1,a.table)),!0):!1;case "down":return d!==a.table.rows-1?(a.setFocusCellForSelection(b.getDOMCellFromCordsOrThrow(c,
d+1,a.table)),!0):!1;default:return!1}};function V(a,b){if(u.$isRangeSelection(a)||R(a)){let c=b.isParentOf(a.anchor.getNode());a=b.isParentOf(a.focus.getNode());return c&&a}return!1}
function wa(a,b){a=b.elem;b=u.$getNearestNodeFromDOMNode(a);B(b)||J(131);null===b.getBackgroundColor()?a.style.setProperty("background-color","rgb(172,206,247)"):a.style.setProperty("background-image","linear-gradient(to right, rgba(172,206,247,0.85), rgba(172,206,247,0.85))");a.style.setProperty("caret-color","transparent")}
function xa(a,b){a=b.elem;b=u.$getNearestNodeFromDOMNode(a);B(b)||J(131);null===b.getBackgroundColor()&&a.style.removeProperty("background-color");a.style.removeProperty("background-image");a.style.removeProperty("caret-color")}function X(a){a=h.$findMatchingParent(a,B);return B(a)?a:null}function U(a){a=h.$findMatchingParent(a,N);return N(a)?a:null}
function Y(a,b,c,d,e){if(("up"===c||"down"===c)&&Da(a))return!1;var f=u.$getSelection();if(!V(f,d)){if(u.$isRangeSelection(f)){if(f.isCollapsed()&&"backward"===c){e=f.anchor.type;d=f.anchor.offset;if("element"!==e&&("text"!==e||0!==d))return!1;e=f.anchor.getNode();if(!e)return!1;e=h.$findMatchingParent(e,p=>u.$isElementNode(p)&&!p.isInline());if(!e)return!1;e=e.getPreviousSibling();if(!e||!N(e))return!1;Z(b);e.selectEnd();return!0}if(b.shiftKey&&("up"===c||"down"===c))if(b=f.focus.getNode(),u.$isRootOrShadowRoot(b)){if((c=
f.getNodes()[0])&&(c=h.$findMatchingParent(c,B))&&d.isParentOf(c)){b=d.getFirstDescendant();c=d.getLastDescendant();if(!b||!c)return!1;[b]=Q(b);[c]=Q(c);b=d.getCordsFromCellNode(b,e.table);c=d.getCordsFromCellNode(c,e.table);b=d.getDOMCellFromCordsOrThrow(b.x,b.y,e.table);d=d.getDOMCellFromCordsOrThrow(c.x,c.y,e.table);e.setAnchorCellForSelection(b);e.setFocusCellForSelection(d,!0);return!0}}else{d=h.$findMatchingParent(b,p=>u.$isElementNode(p)&&!p.isInline());if(!d)return!1;d="down"===c?d.getNextSibling():
d.getPreviousSibling();if(N(d)&&e.tableNodeKey===d.getKey()){e=d.getFirstDescendant();d=d.getLastDescendant();if(!e||!d)return!1;[e]=Q(e);[d]=Q(d);b=f.clone();b.focus.set(("up"===c?e:d).getKey(),"up"===c?0:d.getChildrenSize(),"element");u.$setSelection(b);return!0}}}return!1}if(u.$isRangeSelection(f)&&f.isCollapsed()){let {anchor:p,focus:r}=f;var g=h.$findMatchingParent(p.getNode(),B),m=h.$findMatchingParent(r.getNode(),B);if(!B(g)||!g.is(m))return!1;m=U(g);if(m!==d&&null!=m){var q=a.getElementByKey(m.getKey());
if(null!=q)return e.table=S(q),Y(a,b,c,m,e)}if("backward"===c||"forward"===c){e=p.type;a=p.offset;g=p.getNode();if(!g)return!1;f=f.getNodes();return 1===f.length&&u.$isDecoratorNode(f[0])?!1:Ea(e,a,g,c)?Fa(b,g,d,c):!1}f=a.getElementByKey(g.__key);m=a.getElementByKey(p.key);if(null==m||null==f)return!1;if("element"===p.type)f=m.getBoundingClientRect();else{f=window.getSelection();if(null===f||0===f.rangeCount)return!1;f=f.getRangeAt(0).getBoundingClientRect()}m="up"===c?g.getFirstChild():g.getLastChild();
if(null==m)return!1;a=a.getElementByKey(m.__key);if(null==a)return!1;a=a.getBoundingClientRect();if("up"===c?a.top>f.top-f.height:f.bottom+f.height>a.bottom){Z(b);f=d.getCordsFromCellNode(g,e.table);if(b.shiftKey)d=d.getDOMCellFromCordsOrThrow(f.x,f.y,e.table),e.setAnchorCellForSelection(d),e.setFocusCellForSelection(d,!0);else return Ba(e,d,f.x,f.y,c);return!0}}else if(R(f)){let {anchor:p,focus:r}=f;q=h.$findMatchingParent(p.getNode(),B);m=h.$findMatchingParent(r.getNode(),B);[g]=f.getNodes();a=
a.getElementByKey(g.getKey());if(!B(q)||!B(m)||!N(g)||null==a)return!1;e.updateTableTableSelection(f);f=S(a);a=d.getCordsFromCellNode(q,f);a=d.getDOMCellFromCordsOrThrow(a.x,a.y,f);e.setAnchorCellForSelection(a);Z(b);if(b.shiftKey)return d=d.getCordsFromCellNode(m,f),Ca(e,g,d.x,d.y,c);m.selectEnd();return!0}return!1}function Z(a){a.preventDefault();a.stopImmediatePropagation();a.stopPropagation()}
function Da(a){return(a=a.getRootElement())?a.hasAttribute("aria-controls")&&"typeahead-menu"===a.getAttribute("aria-controls"):!1}function Ea(a,b,c,d){return"element"===a&&("backward"===d?null===c.getPreviousSibling():null===c.getNextSibling())||Ga(a,b,c,d)}
function Ga(a,b,c,d){let e=h.$findMatchingParent(c,f=>u.$isElementNode(f)&&!f.isInline());if(!e)return!1;b="backward"===d?0===b:b===c.getTextContentSize();return"text"===a&&b&&("backward"===d?null===e.getPreviousSibling():null===e.getNextSibling())}
function Fa(a,b,c,d){var e=h.$findMatchingParent(b,B);if(!B(e))return!1;let [f,g]=P(c,e,e);e=f[0][0];let m=f[f.length-1][f[0].length-1],{startColumn:q,startRow:p}=g;if("backward"===d?q!==e.startColumn||p!==e.startRow:q!==m.startColumn||p!==m.startRow)return!1;b=Ha(b,d,c);if(!b||N(b))return!1;Z(a);"backward"===d?b.selectEnd():b.selectStart();return!0}
function Ha(a,b,c){if(a=h.$findMatchingParent(a,d=>u.$isElementNode(d)&&!d.isInline()))return(a="backward"===b?a.getPreviousSibling():a.getNextSibling())&&N(a)?a:"backward"===b?c.getPreviousSibling():c.getNextSibling()}function Ia(a,b,c){let d=u.$createParagraphNode();"first"===a?b.insertBefore(d):b.insertAfter(d);d.append(...(c||[]));d.selectEnd()}
function Ja(a,b,c){var d=c.getParent();if(d&&(a=a.getElementByKey(d.getKey()))&&(d=window.getSelection())&&d.anchorNode===a&&(b=h.$findMatchingParent(b.anchor.getNode(),q=>B(q)))&&(a=h.$findMatchingParent(b,q=>N(q)),N(a)&&a.is(c))){var [e,f]=P(c,b,b);c=e[0][0];b=e[e.length-1][e[0].length-1];var {startRow:g,startColumn:m}=f;if(g===c.startRow&&m===c.startColumn)return"first";if(g===b.startRow&&m===b.startColumn)return"last"}}
class Ka extends u.ElementNode{static getType(){return"table"}static clone(a){return new Ka(a.__key)}static importDOM(){return{table:()=>({conversion:La,priority:1})}}static importJSON(){return Ma()}constructor(a){super(a)}exportJSON(){return{...super.exportJSON(),type:"table",version:1}}createDOM(a){let b=document.createElement("table");h.addClassNamesToElement(b,a.theme.table);return b}updateDOM(){return!1}exportDOM(a){return{...super.exportDOM(a),after:b=>{if(b){let c=b.cloneNode(),d=document.createElement("colgroup"),
e=document.createElement("tbody");h.isHTMLElement(b)&&e.append(...b.children);b=this.getFirstChildOrThrow();if(!I(b))throw Error("Expected to find row node.");b=b.getChildrenSize();for(let f=0;f<b;f++){let g=document.createElement("col");d.append(g)}c.replaceChildren(d,e);return c}}}}canBeEmpty(){return!1}isShadowRoot(){return!0}getCordsFromCellNode(a,b){let {rows:c,domRows:d}=b;for(b=0;b<c;b++){var e=d[b];if(null!=e&&(e=e.findIndex(f=>{if(f)return{elem:f}=f,u.$getNearestNodeFromDOMNode(f)===a}),
-1!==e))return{x:e,y:b}}throw Error("Cell not found in table.");}getDOMCellFromCords(a,b,c){({domRows:c}=c);b=c[b];if(null==b)return null;a=b[a<b.length?a:b.length-1];return null==a?null:a}getDOMCellFromCordsOrThrow(a,b,c){a=this.getDOMCellFromCords(a,b,c);if(!a)throw Error("Cell not found at cords.");return a}getCellNodeFromCords(a,b,c){a=this.getDOMCellFromCords(a,b,c);if(null==a)return null;a=u.$getNearestNodeFromDOMNode(a.elem);return B(a)?a:null}getCellNodeFromCordsOrThrow(a,b,c){a=this.getCellNodeFromCords(a,
b,c);if(!a)throw Error("Node at cords not TableCellNode.");return a}canSelectBefore(){return!0}canIndent(){return!1}}function La(){return{node:Ma()}}function Ma(){return u.$applyNodeReplacement(new Ka)}function N(a){return a instanceof Ka}exports.$computeTableMap=P;exports.$computeTableMapSkipCellCheck=oa;exports.$createTableCellNode=A;exports.$createTableNode=Ma;
exports.$createTableNodeWithDimensions=function(a,b,c=!0){let d=Ma();for(let f=0;f<a;f++){let g=E();for(let m=0;m<b;m++){var e=x.NO_STATUS;"object"===typeof c?(0===f&&c.rows&&(e|=x.ROW),0===m&&c.columns&&(e|=x.COLUMN)):c&&(0===f&&(e|=x.ROW),0===m&&(e|=x.COLUMN));e=A(e);let q=u.$createParagraphNode();q.append(u.$createTextNode());e.append(q);g.append(e)}d.append(g)}return d};exports.$createTableRowNode=E;exports.$createTableSelection=sa;
exports.$deleteTableColumn=function(a,b){let c=a.getChildren();for(let e=0;e<c.length;e++){var d=c[e];if(I(d)){d=d.getChildren();if(b>=d.length||0>b)throw Error("Table column target index out of range");d[b].remove()}}return a};
exports.$deleteTableColumn__EXPERIMENTAL=function(){var a=u.$getSelection();u.$isRangeSelection(a)||R(a)||J(188);var b=a.anchor.getNode();a=a.focus.getNode();let [c,,d]=Q(b);[a]=Q(a);let [e,f,g]=P(d,c,a);({startColumn:b}=f);let {startRow:m,startColumn:q}=g;var p=Math.min(b,q);let r=Math.max(b+c.__colSpan-1,q+a.__colSpan-1),w=r-p+1;if(e[0].length===r-p+1)d.selectPrevious(),d.remove();else{var k=e.length;for(let l=0;l<k;l++)for(let n=p;n<=r;n++){let {cell:t,startColumn:v}=e[l][n];v<p?n===p&&t.setColSpan(t.__colSpan-
Math.min(w,t.__colSpan-(p-v))):v+t.__colSpan-1>r?n===r&&t.setColSpan(t.__colSpan-(r-v+1)):t.remove()}p=e[m];a=b>q?p[b+c.__colSpan]:p[q+a.__colSpan];void 0!==a?({cell:b}=a,O(b)):({cell:b}=q<b?p[q-1]:p[b-1],O(b))}};
exports.$deleteTableRow__EXPERIMENTAL=function(){var a=u.$getSelection();u.$isRangeSelection(a)||R(a)||J(188);var b=a.anchor.getNode();a=a.focus.getNode();let [c,,d]=Q(b);[a]=Q(a);let [e,f,g]=P(d,c,a);({startRow:b}=f);var {startRow:m}=g;a=m+a.__rowSpan-1;if(e.length===a-b+1)d.remove();else{m=e[0].length;var q=e[a+1],p=d.getChildAtIndex(a+1);for(let w=a;w>=b;w--){for(var r=m-1;0<=r;r--){let {cell:k,startRow:l,startColumn:n}=e[w][r];if(n===r&&(w===b&&l<b&&k.setRowSpan(k.__rowSpan-(l-b)),l>=b&&l+k.__rowSpan-
1>a))if(k.setRowSpan(k.__rowSpan-(a-l+1)),null===p&&J(122),0===r)la(p,k);else{let {cell:t}=q[r-1];t.insertAfter(k)}}r=d.getChildAtIndex(w);I(r)||J(123,String(w));r.remove()}void 0!==q?({cell:b}=q[0],O(b)):({cell:b}=e[b-1][0],O(b))}};exports.$findCellNode=X;exports.$findTableNode=U;exports.$getElementForTableNode=function(a,b){a=a.getElementByKey(b.getKey());if(null==a)throw Error("Table Element Not Found");return S(a)};exports.$getNodeTriplet=Q;
exports.$getTableCellNodeFromLexicalNode=function(a){a=h.$findMatchingParent(a,b=>B(b));return B(a)?a:null};exports.$getTableCellNodeRect=pa;exports.$getTableColumnIndexFromTableCellNode=function(a){return ha(a).getChildren().findIndex(b=>b.is(a))};exports.$getTableNodeFromLexicalNodeOrThrow=ia;exports.$getTableRowIndexFromTableCellNode=function(a){let b=ha(a);return ia(b).getChildren().findIndex(c=>c.is(b))};exports.$getTableRowNodeFromTableCellNodeOrThrow=ha;
exports.$insertTableColumn=function(a,b,c=!0,d,e){let f=a.getChildren(),g=[];for(let p=0;p<f.length;p++){let r=f[p];if(I(r))for(let w=0;w<d;w++){var m=r.getChildren();if(b>=m.length||0>b)throw Error("Table column target index out of range");m=m[b];B(m)||J(12);let {left:k,right:l}=ja(m,e);var q=x.NO_STATUS;if(k&&k.hasHeaderState(x.ROW)||l&&l.hasHeaderState(x.ROW))q|=x.ROW;q=A(q);q.append(u.$createParagraphNode());g.push({newTableCell:q,targetCell:m})}}g.forEach(({newTableCell:p,targetCell:r})=>{c?
r.insertAfter(p):r.insertBefore(p)});return a};
exports.$insertTableColumn__EXPERIMENTAL=function(a=!0){function b(w=x.NO_STATUS){w=A(w).append(u.$createParagraphNode());null===p&&(p=w);return w}var c=u.$getSelection();u.$isRangeSelection(c)||R(c)||J(188);var d=c.anchor.getNode();c=c.focus.getNode();[d]=Q(d);let [e,,f]=Q(c),[g,m,q]=P(f,e,d);d=g.length;c=a?Math.max(m.startColumn,q.startColumn):Math.min(m.startColumn,q.startColumn);a=a?c+e.__colSpan-1:c-1;c=f.getFirstChild();I(c)||J(120);let p=null;var r=c;a:for(c=0;c<d;c++){0!==c&&(r=r.getNextSibling(),
I(r)||J(121));let w=g[c],k=ka(w[0>a?0:a].cell.__headerState,x.ROW);if(0>a){la(r,b(k));continue}let {cell:l,startColumn:n,startRow:t}=w[a];if(n+l.__colSpan-1<=a){let v=l,z=t,C=a;for(;z!==c&&1<v.__rowSpan;)if(C-=l.__colSpan,0<=C){let {cell:G,startRow:H}=w[C];v=G;z=H}else{r.append(b(k));continue a}v.insertAfter(b(k))}else l.setColSpan(l.__colSpan+1)}null!==p&&O(p)};
exports.$insertTableRow=function(a,b,c=!0,d,e){var f=a.getChildren();if(b>=f.length||0>b)throw Error("Table row target index out of range");b=f[b];if(I(b))for(f=0;f<d;f++){let m=b.getChildren(),q=m.length,p=E();for(let r=0;r<q;r++){var g=m[r];B(g)||J(12);let {above:w,below:k}=ja(g,e);g=x.NO_STATUS;let l=w&&w.getWidth()||k&&k.getWidth()||void 0;if(w&&w.hasHeaderState(x.COLUMN)||k&&k.hasHeaderState(x.COLUMN))g|=x.COLUMN;g=A(g,1,l);g.append(u.$createParagraphNode());p.append(g)}c?b.insertAfter(p):b.insertBefore(p)}else throw Error("Row before insertion index does not exist.");
return a};
exports.$insertTableRow__EXPERIMENTAL=function(a=!0){var b=v.$getSelection();v.$isRangeSelection(b)||R(b)||I(188);b=b.focus.getNode();let [c,,d]=Q(b),[e,f]=P(d,c,c);b=e[0].length;var {startRow:g}=f;if(a){a=g+c.__rowSpan-1;var m=e[a];g=D();for(var r=0;r<b;r++){let {cell:t,startRow:k}=m[r];if(k+t.__rowSpan-1<=a){var p=la(m[r].cell.__headerState,x.COLUMN);g.append(z(p).append(v.$createParagraphNode()))}else t.setRowSpan(t.__rowSpan+1)}b=d.getChildAtIndex(a);G(b)||I(145);b.insertAfter(g)}else{m=e[g];
a=D();for(r=0;r<b;r++){let {cell:t,startRow:k}=m[r];k===g?(p=la(m[r].cell.__headerState,x.COLUMN),a.append(z(p).append(v.$createParagraphNode()))):t.setRowSpan(t.__rowSpan+1)}b=d.getChildAtIndex(g);G(b)||I(145);b.insertBefore(a)}};exports.$isTableCellNode=A;exports.$isTableNode=N;exports.$isTableRowNode=G;exports.$isTableSelection=R;exports.$removeTableRowAtIndex=function(a,b){let c=a.getChildren();if(b>=c.length||0>b)throw Error("Expected table cell to be inside of table row.");c[b].remove();return a};
exports.$unmergeCell=function(){var a=v.$getSelection();v.$isRangeSelection(a)||R(a)||I(188);a=a.anchor.getNode();let [b,c,d]=Q(a);a=b.__colSpan;let e=b.__rowSpan;if(1<a){for(var f=1;f<a;f++)b.insertAfter(z(x.NO_STATUS));b.setColSpan(1)}if(1<e){let [r,p]=P(d,b,b),{startColumn:t,startRow:k}=p,l;for(f=1;f<e;f++){var g=k+f;let n=r[g];l=(l||c).getNextSibling();G(l)||I(125);var m=null;for(let q=0;q<t;q++){let u=n[q],w=u.cell;u.startRow===g&&(m=w);1<w.__colSpan&&(q+=w.__colSpan-1)}if(null===m)for(m=0;m<
a;m++)ma(l,z(x.NO_STATUS));else for(g=0;g<a;g++)m.insertAfter(z(x.NO_STATUS))}b.setRowSpan(1)}};exports.INSERT_TABLE_COMMAND=ca;exports.TableCellHeaderStates=x;exports.TableCellNode=y;exports.TableNode=La;exports.TableObserver=sa;exports.TableRowNode=C;
exports.applyTableHandlers=function(a,b,c,d){function e(k){k=a.getCordsFromCellNode(k,g.table);return a.getDOMCellFromCordsOrThrow(k.x,k.y,g.table)}let f=c.getRootElement();if(null===f)throw Error("No root element.");let g=new sa(c,a.getKey()),m=c._window||window;b.__lexicalTableSelection=g;let r=()=>{const k=()=>{g.isSelecting=!1;m.removeEventListener("mouseup",k);m.removeEventListener("mousemove",l)},l=n=>{setTimeout(()=>{if(1!==(n.buttons&1)&&g.isSelecting)g.isSelecting=!1,m.removeEventListener("mouseup",
k),m.removeEventListener("mousemove",l);else{var q=ua(n.target);null===q||g.anchorX===q.x&&g.anchorY===q.y||(n.preventDefault(),g.setFocusCellForSelection(q))}},0)};return{onMouseMove:l,onMouseUp:k}};b.addEventListener("mousedown",k=>{setTimeout(()=>{if(0===k.button&&m){var l=ua(k.target);null!==l&&(Z(k),g.setAnchorCellForSelection(l));var {onMouseUp:n,onMouseMove:q}=r();g.isSelecting=!0;m.addEventListener("mouseup",n);m.addEventListener("mousemove",q)}},0)});let p=k=>{0===k.button&&c.update(()=>
{const l=v.$getSelection(),n=k.target;R(l)&&l.tableKey===g.tableNodeKey&&f.contains(n)&&g.clearHighlight()})};m.addEventListener("mousedown",p);g.listenersToRemove.add(()=>m.removeEventListener("mousedown",p));g.listenersToRemove.add(c.registerCommand(v.KEY_ARROW_DOWN_COMMAND,k=>V(c,k,"down",a,g),v.COMMAND_PRIORITY_HIGH));g.listenersToRemove.add(c.registerCommand(v.KEY_ARROW_UP_COMMAND,k=>V(c,k,"up",a,g),v.COMMAND_PRIORITY_HIGH));g.listenersToRemove.add(c.registerCommand(v.KEY_ARROW_LEFT_COMMAND,
k=>V(c,k,"backward",a,g),v.COMMAND_PRIORITY_HIGH));g.listenersToRemove.add(c.registerCommand(v.KEY_ARROW_RIGHT_COMMAND,k=>V(c,k,"forward",a,g),v.COMMAND_PRIORITY_HIGH));g.listenersToRemove.add(c.registerCommand(v.KEY_ESCAPE_COMMAND,k=>{var l=v.$getSelection();return R(l)&&(l=h.$findMatchingParent(l.focus.getNode(),A),A(l))?(Z(k),l.selectEnd(),!0):!1},v.COMMAND_PRIORITY_HIGH));let t=k=>()=>{var l=v.$getSelection();if(!U(l,a))return!1;if(R(l))return g.clearText(),!0;if(v.$isRangeSelection(l)){var n=
h.$findMatchingParent(l.anchor.getNode(),u=>A(u));if(!A(n))return!1;var q=l.anchor.getNode();n=l.focus.getNode();q=a.isParentOf(q);n=a.isParentOf(n);if(q&&!n||n&&!q)return g.clearText(),!0;n=(l=h.$findMatchingParent(l.anchor.getNode(),u=>v.$isElementNode(u)))&&h.$findMatchingParent(l,u=>v.$isElementNode(u)&&A(u.getParent()));if(!v.$isElementNode(n)||!v.$isElementNode(l))return!1;if(k===v.DELETE_LINE_COMMAND&&null===n.getPreviousSibling())return!0}return!1};[v.DELETE_WORD_COMMAND,v.DELETE_LINE_COMMAND,
v.DELETE_CHARACTER_COMMAND].forEach(k=>{g.listenersToRemove.add(c.registerCommand(k,t(k),v.COMMAND_PRIORITY_CRITICAL))});b=k=>{const l=v.$getSelection();if(!U(l,a)){if(k=l?l.getNodes():null)if(k=k.find(n=>N(n)&&n.getKey()===g.tableNodeKey),N(k)){if(!k.getParent())return!1;k.remove()}return!1}if(R(l))return k.preventDefault(),k.stopPropagation(),g.clearText(),!0;v.$isRangeSelection(l)&&(k=h.$findMatchingParent(l.anchor.getNode(),n=>A(n)),A(k));return!1};g.listenersToRemove.add(c.registerCommand(v.KEY_BACKSPACE_COMMAND,
b,v.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(v.KEY_DELETE_COMMAND,b,v.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(v.FORMAT_TEXT_COMMAND,k=>{let l=v.$getSelection();if(!U(l,a))return!1;if(R(l))return g.formatCells(k),!0;v.$isRangeSelection(l)&&(k=h.$findMatchingParent(l.anchor.getNode(),n=>A(n)),A(k));return!1},v.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(v.FORMAT_ELEMENT_COMMAND,k=>{var l=v.$getSelection();if(!R(l)||
!U(l,a))return!1;var n=l.anchor.getNode();l=l.focus.getNode();if(!A(n)||!A(l))return!1;let [q,u,w]=P(a,n,l);n=Math.max(u.startRow,w.startRow);l=Math.max(u.startColumn,w.startColumn);var B=Math.min(u.startRow,w.startRow);let E=Math.min(u.startColumn,w.startColumn);for(;B<=n;B++)for(let H=E;H<=l;H++){var F=q[B][H].cell;F.setFormat(k);F=F.getChildren();for(let L=0;L<F.length;L++){let M=F[L];v.$isElementNode(M)&&!M.isInline()&&M.setFormat(k)}}return!0},v.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(v.CONTROLLED_TEXT_INSERTION_COMMAND,
k=>{var l=v.$getSelection();if(!U(l,a))return!1;if(R(l))g.clearHighlight();else if(v.$isRangeSelection(l)){let n=h.$findMatchingParent(l.anchor.getNode(),q=>A(q));if(!A(n))return!1;if("string"===typeof k&&(l=Ka(c,l,a)))return Ja(l,a,[v.$createTextNode(k)]),!0}return!1},v.COMMAND_PRIORITY_CRITICAL));d&&g.listenersToRemove.add(c.registerCommand(v.KEY_TAB_COMMAND,k=>{var l=v.$getSelection();if(!v.$isRangeSelection(l)||!l.isCollapsed()||!U(l,a))return!1;l=Da(l.anchor.getNode());if(null===l)return!1;Z(k);
l=a.getCordsFromCellNode(l,g.table);Aa(g,a,l.x,l.y,k.shiftKey?"backward":"forward");return!0},v.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(v.FOCUS_COMMAND,()=>a.isSelected(),v.COMMAND_PRIORITY_HIGH));g.listenersToRemove.add(c.registerCommand(v.SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,k=>{let {nodes:l,selection:n}=k;k=n.getStartEndPoints();var q=R(n);q=v.$isRangeSelection(n)&&null!==h.$findMatchingParent(n.anchor.getNode(),J=>A(J))&&null!==h.$findMatchingParent(n.focus.getNode(),
J=>A(J))||q;if(1!==l.length||!N(l[0])||!q||null===k)return!1;var [u]=k,w=l[0];k=w.getChildren();q=w.getFirstChildOrThrow().getChildrenSize();w=w.getChildrenSize();var B=h.$findMatchingParent(u.getNode(),J=>A(J)),E=(u=B&&h.$findMatchingParent(B,J=>G(J)))&&h.$findMatchingParent(u,J=>N(J));if(!A(B)||!G(u)||!N(E))return!1;var F=u.getIndexWithinParent(),H=Math.min(E.getChildrenSize()-1,F+w-1);w=B.getIndexWithinParent();B=Math.min(u.getChildrenSize()-1,w+q-1);q=Math.min(w,B);u=Math.min(F,H);w=Math.max(w,
B);F=Math.max(F,H);E=E.getChildren();H=0;let L,M;for(B=u;B<=F;B++){var fa=E[B];if(!G(fa))return!1;var ha=k[H];if(!G(ha))return!1;fa=fa.getChildren();ha=ha.getChildren();let J=0;for(let W=q;W<=w;W++){let X=fa[W];if(!A(X))return!1;let Ca=ha[J];if(!A(Ca))return!1;B===u&&W===q?L=X.getKey():B===F&&W===w&&(M=X.getKey());let Oa=X.getChildren();Ca.getChildren().forEach(Y=>{v.$isTextNode(Y)&&v.$createParagraphNode().append(Y);X.append(Y)});Oa.forEach(Y=>Y.remove());J++}H++}L&&M&&(k=ra(),k.set(l[0].getKey(),
L,M),v.$setSelection(k));return!0},v.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(v.SELECTION_CHANGE_COMMAND,()=>{let k=v.$getSelection(),l=v.$getPreviousSelection();if(v.$isRangeSelection(k)){let {anchor:B,focus:E}=k;var n=B.getNode(),q=E.getNode();n=Da(n);var u=Da(q);q=!(!n||!a.is(T(n)));var w=!(!u||!a.is(T(u)));let F=q!==w,H=q&&w;q=k.isBackward();F?(n=k.clone(),w?([w]=P(a,u,u),u=w[0][0].cell,w=w[w.length-1].at(-1).cell,n.focus.set(q?u.getKey():w.getKey(),q?u.getChildrenSize():
w.getChildrenSize(),"element")):n.anchor.set(a.getParentOrThrow().getKey(),q?a.getIndexWithinParent()+1:a.getIndexWithinParent(),"element"),v.$setSelection(n),ya(c,g)):H&&!n.is(u)&&(g.setAnchorCellForSelection(e(n)),g.setFocusCellForSelection(e(u),!0),g.isSelecting||setTimeout(()=>{let {onMouseUp:L,onMouseMove:M}=r();g.isSelecting=!0;m.addEventListener("mouseup",L);m.addEventListener("mousemove",M)},0))}else k&&R(k)&&k.is(l)&&k.tableKey===a.getKey()&&(q=ea?(c._window||window).getSelection():null)&&
q.anchorNode&&q.focusNode&&(n=(n=v.$getNearestNodeFromDOMNode(q.focusNode))&&!a.is(T(n)),u=(u=v.$getNearestNodeFromDOMNode(q.anchorNode))&&a.is(T(u)),n&&u&&0<q.rangeCount&&(n=v.$createRangeSelectionFromDom(q,c)))&&(n.anchor.set(a.getKey(),k.isBackward()?a.getChildrenSize():0,"element"),q.removeAllRanges(),v.$setSelection(n));if(k&&!k.is(l)&&(R(k)||R(l))&&g.tableSelection&&!g.tableSelection.is(l))return R(k)&&k.tableKey===g.tableNodeKey?g.updateTableTableSelection(k):!R(k)&&R(l)&&l.tableKey===g.tableNodeKey&&
g.updateTableTableSelection(null),!1;g.hasHijackedSelectionStyles&&!a.isSelected()?za(c,g):!g.hasHijackedSelectionStyles&&a.isSelected()&&ya(c,g);return!1},v.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(v.INSERT_PARAGRAPH_COMMAND,()=>{var k=v.$getSelection();return v.$isRangeSelection(k)&&k.isCollapsed()&&U(k,a)?(k=Ka(c,k,a))?(Ja(k,a),!0):!1:!1},v.COMMAND_PRIORITY_CRITICAL));return g};exports.getDOMCellFromTarget=ua;exports.getTableObserverFromTableElement=function(a){return a.__lexicalTableSelection}
exports.$insertTableRow__EXPERIMENTAL=function(a=!0){var b=u.$getSelection();u.$isRangeSelection(b)||R(b)||J(188);b=b.focus.getNode();let [c,,d]=Q(b),[e,f]=P(d,c,c);b=e[0].length;var {startRow:g}=f;if(a){a=g+c.__rowSpan-1;var m=e[a];g=E();for(var q=0;q<b;q++){let {cell:r,startRow:w}=m[q];if(w+r.__rowSpan-1<=a){var p=ka(m[q].cell.__headerState,x.COLUMN);g.append(A(p).append(u.$createParagraphNode()))}else r.setRowSpan(r.__rowSpan+1)}b=d.getChildAtIndex(a);I(b)||J(145);b.insertAfter(g)}else{m=e[g];
a=E();for(q=0;q<b;q++){let {cell:r,startRow:w}=m[q];w===g?(p=ka(m[q].cell.__headerState,x.COLUMN),a.append(A(p).append(u.$createParagraphNode()))):r.setRowSpan(r.__rowSpan+1)}b=d.getChildAtIndex(g);I(b)||J(145);b.insertBefore(a)}};exports.$isTableCellNode=B;exports.$isTableNode=N;exports.$isTableRowNode=I;exports.$isTableSelection=R;exports.$removeTableRowAtIndex=function(a,b){let c=a.getChildren();if(b>=c.length||0>b)throw Error("Expected table cell to be inside of table row.");c[b].remove();return a};
exports.$unmergeCell=function(){var a=u.$getSelection();u.$isRangeSelection(a)||R(a)||J(188);a=a.anchor.getNode();let [b,c,d]=Q(a);a=b.__colSpan;let e=b.__rowSpan;if(1<a){for(var f=1;f<a;f++)b.insertAfter(A(x.NO_STATUS));b.setColSpan(1)}if(1<e){let [q,p]=P(d,b,b),{startColumn:r,startRow:w}=p,k;for(f=1;f<e;f++){var g=w+f;let l=q[g];k=(k||c).getNextSibling();I(k)||J(125);var m=null;for(let n=0;n<r;n++){let t=l[n],v=t.cell;t.startRow===g&&(m=v);1<v.__colSpan&&(n+=v.__colSpan-1)}if(null===m)for(m=0;m<
a;m++)la(k,A(x.NO_STATUS));else for(g=0;g<a;g++)m.insertAfter(A(x.NO_STATUS))}b.setRowSpan(1)}};exports.INSERT_TABLE_COMMAND=da;exports.TableCellHeaderStates=x;exports.TableCellNode=y;exports.TableNode=Ka;exports.TableObserver=ta;exports.TableRowNode=D;
exports.applyTableHandlers=function(a,b,c,d){function e(k){k=a.getCordsFromCellNode(k,g.table);return a.getDOMCellFromCordsOrThrow(k.x,k.y,g.table)}let f=c.getRootElement();if(null===f)throw Error("No root element.");let g=new ta(c,a.getKey()),m=c._window||window;b.__lexicalTableSelection=g;let q=()=>{const k=()=>{g.isSelecting=!1;m.removeEventListener("mouseup",k);m.removeEventListener("mousemove",l)},l=n=>{setTimeout(()=>{if(1!==(n.buttons&1)&&g.isSelecting)g.isSelecting=!1,m.removeEventListener("mouseup",
k),m.removeEventListener("mousemove",l);else{var t=ua(n.target);null===t||g.anchorX===t.x&&g.anchorY===t.y||(n.preventDefault(),g.setFocusCellForSelection(t))}},0)};return{onMouseMove:l,onMouseUp:k}};b.addEventListener("mousedown",k=>{setTimeout(()=>{if(0===k.button&&m){var l=ua(k.target);null!==l&&(Z(k),g.setAnchorCellForSelection(l));var {onMouseUp:n,onMouseMove:t}=q();g.isSelecting=!0;m.addEventListener("mouseup",n);m.addEventListener("mousemove",t)}},0)});let p=k=>{0===k.button&&c.update(()=>
{const l=u.$getSelection(),n=k.target;R(l)&&l.tableKey===g.tableNodeKey&&f.contains(n)&&g.clearHighlight()})};m.addEventListener("mousedown",p);g.listenersToRemove.add(()=>m.removeEventListener("mousedown",p));g.listenersToRemove.add(c.registerCommand(u.KEY_ARROW_DOWN_COMMAND,k=>Y(c,k,"down",a,g),u.COMMAND_PRIORITY_HIGH));g.listenersToRemove.add(c.registerCommand(u.KEY_ARROW_UP_COMMAND,k=>Y(c,k,"up",a,g),u.COMMAND_PRIORITY_HIGH));g.listenersToRemove.add(c.registerCommand(u.KEY_ARROW_LEFT_COMMAND,
k=>Y(c,k,"backward",a,g),u.COMMAND_PRIORITY_HIGH));g.listenersToRemove.add(c.registerCommand(u.KEY_ARROW_RIGHT_COMMAND,k=>Y(c,k,"forward",a,g),u.COMMAND_PRIORITY_HIGH));g.listenersToRemove.add(c.registerCommand(u.KEY_ESCAPE_COMMAND,k=>{var l=u.$getSelection();return R(l)&&(l=h.$findMatchingParent(l.focus.getNode(),B),B(l))?(Z(k),l.selectEnd(),!0):!1},u.COMMAND_PRIORITY_HIGH));let r=k=>()=>{var l=u.$getSelection();if(!V(l,a))return!1;if(R(l))return g.clearText(),!0;if(u.$isRangeSelection(l)){var n=
h.$findMatchingParent(l.anchor.getNode(),v=>B(v));if(!B(n))return!1;var t=l.anchor.getNode();n=l.focus.getNode();t=a.isParentOf(t);n=a.isParentOf(n);if(t&&!n||n&&!t)return g.clearText(),!0;n=(l=h.$findMatchingParent(l.anchor.getNode(),v=>u.$isElementNode(v)))&&h.$findMatchingParent(l,v=>u.$isElementNode(v)&&B(v.getParent()));if(!u.$isElementNode(n)||!u.$isElementNode(l))return!1;if(k===u.DELETE_LINE_COMMAND&&null===n.getPreviousSibling())return!0}return!1};[u.DELETE_WORD_COMMAND,u.DELETE_LINE_COMMAND,
u.DELETE_CHARACTER_COMMAND].forEach(k=>{g.listenersToRemove.add(c.registerCommand(k,r(k),u.COMMAND_PRIORITY_CRITICAL))});let w=k=>{const l=u.$getSelection();if(!V(l,a)){if(k=l?l.getNodes():null)if(k=k.find(n=>N(n)&&n.getKey()===g.tableNodeKey),N(k)){if(!k.getParent())return!1;k.remove()}return!1}if(R(l))return k&&(k.preventDefault(),k.stopPropagation()),g.clearText(),!0;u.$isRangeSelection(l)&&(k=h.$findMatchingParent(l.anchor.getNode(),n=>B(n)),B(k));return!1};g.listenersToRemove.add(c.registerCommand(u.KEY_BACKSPACE_COMMAND,
w,u.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(u.KEY_DELETE_COMMAND,w,u.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(u.CUT_COMMAND,k=>{let l=u.$getSelection();if(l){if(u.$isNodeSelection(l))return!1;aa.copyToClipboard(c,h.objectKlassEquals(k,ClipboardEvent)?k:null);if(R(l))return w(k),!0;if(u.$isRangeSelection(l))return w(k),l.removeText(),!0}return!1},u.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(u.FORMAT_TEXT_COMMAND,
k=>{let l=u.$getSelection();if(!V(l,a))return!1;if(R(l))return g.formatCells(k),!0;u.$isRangeSelection(l)&&(k=h.$findMatchingParent(l.anchor.getNode(),n=>B(n)),B(k));return!1},u.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(u.FORMAT_ELEMENT_COMMAND,k=>{var l=u.$getSelection();if(!R(l)||!V(l,a))return!1;var n=l.anchor.getNode();l=l.focus.getNode();if(!B(n)||!B(l))return!1;let [t,v,z]=P(a,n,l);n=Math.max(v.startRow,z.startRow);l=Math.max(v.startColumn,z.startColumn);var C=Math.min(v.startRow,
z.startRow);let G=Math.min(v.startColumn,z.startColumn);for(;C<=n;C++)for(let L=G;L<=l;L++){var H=t[C][L].cell;H.setFormat(k);H=H.getChildren();for(let M=0;M<H.length;M++){let F=H[M];u.$isElementNode(F)&&!F.isInline()&&F.setFormat(k)}}return!0},u.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(u.CONTROLLED_TEXT_INSERTION_COMMAND,k=>{var l=u.$getSelection();if(!V(l,a))return!1;if(R(l))g.clearHighlight();else if(u.$isRangeSelection(l)){let n=h.$findMatchingParent(l.anchor.getNode(),
t=>B(t));if(!B(n))return!1;if("string"===typeof k&&(l=Ja(c,l,a)))return Ia(l,a,[u.$createTextNode(k)]),!0}return!1},u.COMMAND_PRIORITY_CRITICAL));d&&g.listenersToRemove.add(c.registerCommand(u.KEY_TAB_COMMAND,k=>{var l=u.$getSelection();if(!u.$isRangeSelection(l)||!l.isCollapsed()||!V(l,a))return!1;l=X(l.anchor.getNode());if(null===l)return!1;Z(k);l=a.getCordsFromCellNode(l,g.table);Ba(g,a,l.x,l.y,k.shiftKey?"backward":"forward");return!0},u.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(u.FOCUS_COMMAND,
()=>a.isSelected(),u.COMMAND_PRIORITY_HIGH));g.listenersToRemove.add(c.registerCommand(u.SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,k=>{let {nodes:l,selection:n}=k;k=n.getStartEndPoints();var t=R(n);t=u.$isRangeSelection(n)&&null!==h.$findMatchingParent(n.anchor.getNode(),F=>B(F))&&null!==h.$findMatchingParent(n.focus.getNode(),F=>B(F))||t;if(1!==l.length||!N(l[0])||!t||null===k)return!1;var [v]=k,z=l[0];k=z.getChildren();t=z.getFirstChildOrThrow().getChildrenSize();z=z.getChildrenSize();var C=h.$findMatchingParent(v.getNode(),
F=>B(F)),G=C&&h.$findMatchingParent(C,F=>I(F)),H=G&&h.$findMatchingParent(G,F=>N(F));if(!B(C)||!I(G)||!N(H))return!1;v=G.getIndexWithinParent();var L=Math.min(H.getChildrenSize()-1,v+z-1);z=C.getIndexWithinParent();C=Math.min(G.getChildrenSize()-1,z+t-1);t=Math.min(z,C);G=Math.min(v,L);z=Math.max(z,C);v=Math.max(v,L);H=H.getChildren();for(L=0;G<=v;G++){C=H[G];if(!I(C))return!1;var M=k[L];if(!I(M))return!1;C=C.getChildren();M=M.getChildren();let F=0;for(let ma=t;ma<=z;ma++){let na=C[ma];if(!B(na))return!1;
let Aa=M[F];if(!B(Aa))return!1;let Na=na.getChildren();Aa.getChildren().forEach(W=>{u.$isTextNode(W)&&u.$createParagraphNode().append(W);na.append(W)});Na.forEach(W=>W.remove());F++}L++}return!0},u.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(u.SELECTION_CHANGE_COMMAND,()=>{let k=u.$getSelection(),l=u.$getPreviousSelection();if(u.$isRangeSelection(k)){let {anchor:C,focus:G}=k;var n=C.getNode(),t=G.getNode();n=X(n);var v=X(t);t=!(!n||!a.is(U(n)));var z=!(!v||!a.is(U(v)));let H=
t!==z,L=t&&z;t=k.isBackward();H?(n=k.clone(),z&&([z]=P(a,v,v),v=z[0][0].cell,z=z[z.length-1].at(-1).cell,n.focus.set(t?v.getKey():z.getKey(),t?v.getChildrenSize():z.getChildrenSize(),"element")),u.$setSelection(n),ya(c,g)):L&&!n.is(v)&&(g.setAnchorCellForSelection(e(n)),g.setFocusCellForSelection(e(v),!0),g.isSelecting||setTimeout(()=>{let {onMouseUp:M,onMouseMove:F}=q();g.isSelecting=!0;m.addEventListener("mouseup",M);m.addEventListener("mousemove",F)},0))}else k&&R(k)&&k.is(l)&&k.tableKey===a.getKey()&&
(t=fa?(c._window||window).getSelection():null)&&t.anchorNode&&t.focusNode&&(n=(n=u.$getNearestNodeFromDOMNode(t.focusNode))&&!a.is(U(n)),v=(v=u.$getNearestNodeFromDOMNode(t.anchorNode))&&a.is(U(v)),n&&v&&0<t.rangeCount&&(n=u.$createRangeSelectionFromDom(t,c)))&&(n.anchor.set(a.getKey(),k.isBackward()?a.getChildrenSize():0,"element"),t.removeAllRanges(),u.$setSelection(n));if(k&&!k.is(l)&&(R(k)||R(l))&&g.tableSelection&&!g.tableSelection.is(l))return R(k)&&k.tableKey===g.tableNodeKey?g.updateTableTableSelection(k):
!R(k)&&R(l)&&l.tableKey===g.tableNodeKey&&g.updateTableTableSelection(null),!1;g.hasHijackedSelectionStyles&&!a.isSelected()?za(c,g):!g.hasHijackedSelectionStyles&&a.isSelected()&&ya(c,g);return!1},u.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(u.INSERT_PARAGRAPH_COMMAND,()=>{var k=u.$getSelection();return u.$isRangeSelection(k)&&k.isCollapsed()&&V(k,a)?(k=Ja(c,k,a))?(Ia(k,a),!0):!1:!1},u.COMMAND_PRIORITY_CRITICAL));return g};exports.getDOMCellFromTarget=ua;
exports.getTableObserverFromTableElement=function(a){return a.__lexicalTableSelection}

@@ -11,8 +11,8 @@ {

"license": "MIT",
"version": "0.17.1-nightly.20240822.0",
"version": "0.17.1-nightly.20240823.0",
"main": "LexicalTable.js",
"types": "index.d.ts",
"dependencies": {
"@lexical/utils": "0.17.1-nightly.20240822.0",
"lexical": "0.17.1-nightly.20240822.0"
"@lexical/utils": "0.17.1-nightly.20240823.0",
"lexical": "0.17.1-nightly.20240823.0"
},

@@ -19,0 +19,0 @@ "repository": {

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc