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
206
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.2-nightly.20240918.0 to 0.17.2-nightly.20240919.0

123

LexicalTable.prod.js

@@ -17,18 +17,18 @@ /**

function ca(a){var b=a.nodeName.toLowerCase(),c=void 0;ba.test(a.style.width)&&(c=parseFloat(a.style.width));b=B("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(w.$createParagraphNode());return m},forChild:(m,p)=>{if(C(p)&&
!w.$isElementNode(m)){p=w.$createParagraphNode();if(w.$isLineBreakNode(m)&&"\n"===m.getTextContent())return null;w.$isTextNode(m)&&(d&&m.toggleFormat("bold"),e&&m.toggleFormat("strikethrough"),f&&m.toggleFormat("italic"),g&&m.toggleFormat("underline"));p.append(m);return p}return m},node:b}}function B(a,b=1,c){return w.$applyNodeReplacement(new y(a,b,c))}function C(a){return a instanceof y}let da=w.createCommand("INSERT_TABLE_COMMAND");
class E extends w.ElementNode{static getType(){return"tablerow"}static clone(a){return new E(a.__height,a.__key)}static importDOM(){return{tr:()=>({conversion:ea,priority:0})}}static importJSON(a){return F(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:F(b)}}function F(a){return w.$applyNodeReplacement(new E(a))}function I(a){return a instanceof E}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=>M(b));if(M(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 N(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 O(a,b,c){let [d,e,f]=ma(a,b,c);null===e&&J(206);null===f&&J(207);return[d,e,f]}
function ma(a,b,c){function d(p){let q=e[p];void 0===q&&(e[p]=q=[]);return q}let e=[],f=null,g=null;a=a.getChildren();for(let p=0;p<a.length;p++){var m=a[p];I(m)||J(208);for(let q=m.getFirstChild(),u=0;null!=q;q=q.getNextSibling()){C(q)||J(147);for(m=d(p);void 0!==m[u];)u++;m={cell:q,startColumn:u,startRow:p};let {__rowSpan:k,__colSpan:l}=q;for(let n=0;n<k&&!(p+n>=a.length);n++){let t=d(p+n);for(let r=0;r<l;r++)t[u+r]=m}null!==b&&null===f&&b.is(q)&&(f=m);null!==c&&null===g&&c.is(q)&&(g=m)}}return[e,
f,g]}function P(a){a instanceof y||("__type"in a?(a=h.$findMatchingParent(a,C),C(a)||J(148)):(a=h.$findMatchingParent(a.getNode(),C),C(a)||J(148)));let b=a.getParent();I(b)||J(149);let c=b.getParent();M(c)||J(209);return[a,b,c]}
function oa(a){let [b,,c]=P(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 p=0;p<g.length;p++){for(;f[e][m];)m++;let q=g[p],u=q.__rowSpan||1,k=q.__colSpan||1;for(let l=0;l<u;l++)for(let n=0;n<k;n++)f[e+l][m+n]=q;if(b===q)return{colSpan:k,columnIndex:m,rowIndex:e,rowSpan:u};m+=k}}return null}
!w.$isElementNode(m)){p=w.$createParagraphNode();if(w.$isLineBreakNode(m)&&"\n"===m.getTextContent())return null;w.$isTextNode(m)&&(d&&m.toggleFormat("bold"),e&&m.toggleFormat("strikethrough"),f&&m.toggleFormat("italic"),g&&m.toggleFormat("underline"));p.append(m);return p}return m},node:b}}function B(a,b=1,c){return w.$applyNodeReplacement(new y(a,b,c))}function C(a){return a instanceof y}let da=w.createCommand("INSERT_TABLE_COMMAND");var E;
function F(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.");}E=F&&F.__esModule&&Object.prototype.hasOwnProperty.call(F,"default")?F["default"]:F;let ea="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement;
class I extends w.ElementNode{static getType(){return"tablerow"}static clone(a){return new I(a.__height,a.__key)}static importDOM(){return{tr:()=>({conversion:fa,priority:0})}}static importJSON(a){return J(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 fa(a){let b=void 0;ba.test(a.style.height)&&(b=parseFloat(a.style.height));return{node:J(b)}}function J(a){return w.$applyNodeReplacement(new I(a))}function K(a){return a instanceof I}
function ha(a){a=h.$findMatchingParent(a,b=>K(b));if(K(a))return a;throw Error("Expected table cell to be inside of table row.");}function ia(a){a=h.$findMatchingParent(a,b=>M(b));if(M(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 N(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 O(a,b,c){let [d,e,f]=ma(a,b,c);null===e&&E(206);null===f&&E(207);return[d,e,f]}
function ma(a,b,c){function d(p){let r=e[p];void 0===r&&(e[p]=r=[]);return r}let e=[],f=null,g=null;a=a.getChildren();for(let p=0;p<a.length;p++){var m=a[p];K(m)||E(208);for(let r=m.getFirstChild(),u=0;null!=r;r=r.getNextSibling()){C(r)||E(147);for(m=d(p);void 0!==m[u];)u++;m={cell:r,startColumn:u,startRow:p};let {__rowSpan:k,__colSpan:l}=r;for(let n=0;n<k&&!(p+n>=a.length);n++){let t=d(p+n);for(let q=0;q<l;q++)t[u+q]=m}null!==b&&null===f&&b.is(r)&&(f=m);null!==c&&null===g&&c.is(r)&&(g=m)}}return[e,
f,g]}function P(a){a instanceof y||("__type"in a?(a=h.$findMatchingParent(a,C),C(a)||E(148)):(a=h.$findMatchingParent(a.getNode(),C),C(a)||E(148)));let b=a.getParent();K(b)||E(149);let c=b.getParent();M(c)||E(209);return[a,b,c]}
function oa(a){let [b,,c]=P(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 p=0;p<g.length;p++){for(;f[e][m];)m++;let r=g[p],u=r.__rowSpan||1,k=r.__colSpan||1;for(let l=0;l<u;l++)for(let n=0;n<k;n++)f[e+l][m+n]=r;if(b===r)return{colSpan:k,columnIndex:m,rowIndex:e,rowSpan:u};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 Q(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();w.$isElementNode(b)||J(151);w.$normalizeSelection__EXPERIMENTAL(b.select(0,b.getChildrenSize())).insertNodes(a)}getShape(){var a=w.$getNodeByKey(this.anchor.key);C(a)||J(152);a=oa(a);null===a&&J(153);var b=w.$getNodeByKey(this.focus.key);C(b)||J(154);let c=oa(b);null===c&&J(155);b=Math.min(a.columnIndex,
c.columnIndex);let d=Math.max(a.columnIndex+a.colSpan-1,c.columnIndex+c.colSpan-1),e=Math.min(a.rowIndex,c.rowIndex);a=Math.max(a.rowIndex+a.rowSpan-1,c.rowIndex+c.rowSpan-1);return{fromX:Math.min(b,d),fromY:Math.min(e,a),toX:Math.max(b,d),toY:Math.max(e,a)}}getNodes(){function a(v){let {cell:A,startColumn:z,startRow:D}=v;q=Math.min(q,z);u=Math.min(u,D);k=Math.max(k,z+A.__colSpan-1);l=Math.max(l,D+A.__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,C);c=h.$findMatchingParent(b,C);C(d)||J(152);C(c)||J(154);b=d.getParent();I(b)||J(156);b=b.getParent();M(b)||J(157);var e=c.getParents()[1];if(e!==b){if(b.isParentOf(c)){var f=e.getParent();null==f&&J(159);this.set(this.tableKey,c.getKey(),f.getKey())}else f=b.getParent(),null==f&&J(158),this.set(this.tableKey,f.getKey(),c.getKey());return this.getNodes()}let [g,m,p]=O(b,d,c),q=Math.min(m.startColumn,p.startColumn),u=Math.min(m.startRow,p.startRow),k=Math.max(m.startColumn+
m.cell.__colSpan-1,p.startColumn+p.cell.__colSpan-1),l=Math.max(m.startRow+m.cell.__rowSpan-1,p.startRow+p.cell.__rowSpan-1);c=q;d=u;e=q;for(var n=u;q<c||u<d||k>e||l>n;){if(q<c){var t=n-d;--c;for(var r=0;r<=t;r++)a(g[d+r][c])}if(u<d)for(t=e-c,--d,r=0;r<=t;r++)a(g[d][c+r]);if(k>e)for(t=n-d,e+=1,r=0;r<=t;r++)a(g[d+r][e]);if(l>n)for(t=e-c,n+=1,r=0;r<=t;r++)a(g[n][c+r])}b=new Map([[b.getKey(),b]]);c=null;for(d=u;d<=l;d++)for(e=q;e<=k;e++){({cell:n}=g[d][e]);t=n.getParent();I(t)||J(160);t!==c&&b.set(t.getKey(),
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();w.$isElementNode(b)||E(151);w.$normalizeSelection__EXPERIMENTAL(b.select(0,b.getChildrenSize())).insertNodes(a)}getShape(){var a=w.$getNodeByKey(this.anchor.key);C(a)||E(152);a=oa(a);null===a&&E(153);var b=w.$getNodeByKey(this.focus.key);C(b)||E(154);let c=oa(b);null===c&&E(155);b=Math.min(a.columnIndex,
c.columnIndex);let d=Math.max(a.columnIndex+a.colSpan-1,c.columnIndex+c.colSpan-1),e=Math.min(a.rowIndex,c.rowIndex);a=Math.max(a.rowIndex+a.rowSpan-1,c.rowIndex+c.rowSpan-1);return{fromX:Math.min(b,d),fromY:Math.min(e,a),toX:Math.max(b,d),toY:Math.max(e,a)}}getNodes(){function a(v){let {cell:A,startColumn:z,startRow:D}=v;r=Math.min(r,z);u=Math.min(u,D);k=Math.max(k,z+A.__colSpan-1);l=Math.max(l,D+A.__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,C);c=h.$findMatchingParent(b,C);C(d)||E(152);C(c)||E(154);b=d.getParent();K(b)||E(156);b=b.getParent();M(b)||E(157);var e=c.getParents()[1];if(e!==b){if(b.isParentOf(c)){var f=e.getParent();null==f&&E(159);this.set(this.tableKey,c.getKey(),f.getKey())}else f=b.getParent(),null==f&&E(158),this.set(this.tableKey,f.getKey(),c.getKey());return this.getNodes()}let [g,m,p]=O(b,d,c),r=Math.min(m.startColumn,p.startColumn),u=Math.min(m.startRow,p.startRow),k=Math.max(m.startColumn+
m.cell.__colSpan-1,p.startColumn+p.cell.__colSpan-1),l=Math.max(m.startRow+m.cell.__rowSpan-1,p.startRow+p.cell.__rowSpan-1);c=r;d=u;e=r;for(var n=u;r<c||u<d||k>e||l>n;){if(r<c){var t=n-d;--c;for(var q=0;q<=t;q++)a(g[d+q][c])}if(u<d)for(t=e-c,--d,q=0;q<=t;q++)a(g[d][c+q]);if(k>e)for(t=n-d,e+=1,q=0;q<=t;q++)a(g[d+q][e]);if(l>n)for(t=e-c,n+=1,q=0;q<=t;q++)a(g[n][c+q])}b=new Map([[b.getKey(),b]]);c=null;for(d=u;d<=l;d++)for(e=r;e<=k;e++){({cell:n}=g[d][e]);t=n.getParent();K(t)||E(160);t!==c&&b.set(t.getKey(),
t);b.set(n.getKey(),n);for(f of qa(n))b.set(f.getKey(),f);c=t}f=Array.from(b.values());w.isCurrentlyReadOnlyMode()||(this._cachedNodes=f);return f}getTextContent(){let a=this.getNodes().filter(c=>C(c)),b="";for(let c=0;c<a.length;c++){let d=a[c],e=d.__parent,f=(a[c+1]||{}).__parent;b+=d.getTextContent()+(f!==e?"\n":"\t")}return b}}function Q(a){return a instanceof pa}function ra(){let a=w.$createPoint("root",0,"element"),b=w.$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&&J(112);w.$isElementNode(d)&&c.unshift(...d.getChildren());d!==a&&b.push(d)}return b}
function qa(a){let b=[],c=[a];for(;0<c.length;){let d=c.pop();void 0===d&&E(112);w.$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;this.abortController=new AbortController;this.listenerOptions={signal:this.abortController.signal}}getTable(){return this.table}removeListeners(){this.abortController.abort("removeListeners");

@@ -39,66 +39,67 @@ Array.from(this.listenersToRemove).forEach(a=>a());this.listenersToRemove.clear()}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=R(c)}})});this.editor.update(()=>{let b=this.editor.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();S(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=w.$getNodeByKey(this.tableNodeKey);
if(!M(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=
if(!M(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=w.$getNearestNodeFromDOMNode(a.elem),null!=this.tableSelection&&null!=this.anchorCellNodeKey&&C(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),w.$setSelection(this.tableSelection),c.dispatchCommand(w.SELECTION_CHANGE_COMMAND,void 0),S(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=w.$getNearestNodeFromDOMNode(a.elem);C(b)&&(b=b.getKey(),this.tableSelection=null!=this.tableSelection?this.tableSelection.clone():ra(),this.anchorCellNodeKey=b)})}formatCells(a){this.editor.update(()=>{let b=w.$getSelection();Q(b)||J(11);let c=w.$createRangeSelection(),d=c.anchor,e=c.focus,f=b.getNodes().filter(C),g=f[0].getFirstChild(),m=w.$isParagraphNode(g)?g.getFormatFlags(a,null):null;f.forEach(p=>{d.set(p.getKey(),
0,"element");e.set(p.getKey(),p.getChildrenSize(),"element");c.formatText(a,m)});w.$setSelection(b);this.editor.dispatchCommand(w.SELECTION_CHANGE_COMMAND,void 0)})}clearText(){let a=this.editor;a.update(()=>{let b=w.$getNodeByKey(this.tableNodeKey);if(!M(b))throw Error("Expected TableNode.");var c=w.$getSelection();Q(c)||J(11);c=c.getNodes().filter(C);c.length===this.table.columns*this.table.rows?(b.selectPrevious(),b.remove(),w.$getRoot().selectStart()):(c.forEach(d=>{if(w.$isElementNode(d)){let e=
w.$createParagraphNode(),f=w.$createTextNode();e.append(f);d.append(e);d.getChildren().forEach(g=>{g!==e&&g.remove()})}}),S(a,this.table,null),w.$setSelection(null),a.dispatchCommand(w.SELECTION_CHANGE_COMMAND,void 0))})}}function ta(a,b){null!==ua(a)&&J(210);a.__lexicalTableSelection=b}function ua(a){return a.__lexicalTableSelection||null}function va(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 R(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}
!1;this.anchorCell=a;this.anchorX=a.x;this.anchorY=a.y;this.editor.update(()=>{var b=w.$getNearestNodeFromDOMNode(a.elem);C(b)&&(b=b.getKey(),this.tableSelection=null!=this.tableSelection?this.tableSelection.clone():ra(),this.anchorCellNodeKey=b)})}formatCells(a){this.editor.update(()=>{let b=w.$getSelection();Q(b)||E(11);let c=w.$createRangeSelection(),d=c.anchor,e=c.focus,f=b.getNodes().filter(C),g=f[0].getFirstChild(),m=w.$isParagraphNode(g)?g.getFormatFlags(a,null):null;f.forEach(p=>{d.set(p.getKey(),
0,"element");e.set(p.getKey(),p.getChildrenSize(),"element");c.formatText(a,m)});w.$setSelection(b);this.editor.dispatchCommand(w.SELECTION_CHANGE_COMMAND,void 0)})}clearText(){let a=this.editor;a.update(()=>{let b=w.$getNodeByKey(this.tableNodeKey);if(!M(b))throw Error("Expected TableNode.");var c=w.$getSelection();Q(c)||E(11);c=c.getNodes().filter(C);c.length===this.table.columns*this.table.rows?(b.selectPrevious(),b.remove(),w.$getRoot().selectStart()):(c.forEach(d=>{if(w.$isElementNode(d)){let e=
w.$createParagraphNode(),f=w.$createTextNode();e.append(f);d.append(e);d.getChildren().forEach(g=>{g!==e&&g.remove()})}}),S(a,this.table,null),w.$setSelection(null),a.dispatchCommand(w.SELECTION_CHANGE_COMMAND,void 0))})}}function ta(a,b){null!==ua(a)&&E(210);a.__lexicalTableSelection=b}function ua(a){return a.__lexicalTableSelection||null}function va(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 R(a){let b=[],c={columns:0,domRows:b,rows:0};var d=a.querySelector("tr");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 S(a,b,c){let d=new Set(c?c.getNodes():[]);wa(b,(e,f)=>{let g=e.elem;d.has(f)?(e.highlighted=!0,xa(a,e)):(e.highlighted=!1,ya(a,e),g.getAttribute("style")||g.removeAttribute("style"))})}function wa(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=w.$getNearestNodeFromDOMNode(f.elem);null!==g&&b(f,g,{x:e,y:c})}}}function za(a,b){b.disableHighlightStyle();wa(b.table,c=>{c.highlighted=!0;xa(a,c)})}
function Aa(a,b){b.enableHighlightStyle();wa(b.table,c=>{let d=c.elem;c.highlighted=!1;ya(a,c);d.getAttribute("style")||d.removeAttribute("style")})}
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}},Da=(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,
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 U(a,b){if(w.$isRangeSelection(a)||Q(a)){let c=b.isParentOf(a.anchor.getNode());a=b.isParentOf(a.focus.getNode());return c&&a}return!1}
function xa(a,b){a=b.elem;b=w.$getNearestNodeFromDOMNode(a);C(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 ya(a,b){a=b.elem;b=w.$getNearestNodeFromDOMNode(a);C(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,C);return C(a)?a:null}function T(a){a=h.$findMatchingParent(a,M);return M(a)?a:null}
function Y(a,b,c,d,e){if(("up"===c||"down"===c)&&Ea(a))return!1;var f=w.$getSelection();if(!U(f,d)){if(w.$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,q=>w.$isElementNode(q)&&!q.isInline());if(!e)return!1;e=e.getPreviousSibling();if(!e||!M(e))return!1;Z(b);e.selectEnd();return!0}if(b.shiftKey&&("up"===c||"down"===c))if(b=f.focus.getNode(),w.$isRootOrShadowRoot(b)){if((c=
f.getNodes()[0])&&(c=h.$findMatchingParent(c,C))&&d.isParentOf(c)){b=d.getFirstDescendant();c=d.getLastDescendant();if(!b||!c)return!1;[b]=P(b);[c]=P(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,q=>w.$isElementNode(q)&&!q.isInline());if(!d)return!1;d="down"===c?d.getNextSibling():
d.getPreviousSibling();if(M(d)&&e.tableNodeKey===d.getKey()){e=d.getFirstDescendant();d=d.getLastDescendant();if(!e||!d)return!1;[e]=P(e);[d]=P(d);b=f.clone();b.focus.set(("up"===c?e:d).getKey(),"up"===c?0:d.getChildrenSize(),"element");w.$setSelection(b);return!0}}}return!1}if(w.$isRangeSelection(f)&&f.isCollapsed()){let {anchor:q,focus:u}=f;var g=h.$findMatchingParent(q.getNode(),C),m=h.$findMatchingParent(u.getNode(),C);if(!C(g)||!g.is(m))return!1;m=T(g);if(m!==d&&null!=m){var p=a.getElementByKey(m.getKey());
if(null!=p)return e.table=R(p),Y(a,b,c,m,e)}if("backward"===c||"forward"===c){e=q.type;a=q.offset;g=q.getNode();if(!g)return!1;f=f.getNodes();return 1===f.length&&w.$isDecoratorNode(f[0])?!1:Fa(e,a,g,c)?Ga(b,g,d,c):!1}f=a.getElementByKey(g.__key);m=a.getElementByKey(q.key);if(null==m||null==f)return!1;if("element"===q.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(Q(f)){let {anchor:q,focus:u}=f;p=h.$findMatchingParent(q.getNode(),C);m=h.$findMatchingParent(u.getNode(),C);[g]=f.getNodes();a=
a.getElementByKey(g.getKey());if(!C(p)||!C(m)||!M(g)||null==a)return!1;e.updateTableTableSelection(f);f=R(a);a=d.getCordsFromCellNode(p,f);a=d.getDOMCellFromCordsOrThrow(a.x,a.y,f);e.setAnchorCellForSelection(a);Z(b);if(b.shiftKey)return d=d.getCordsFromCellNode(m,f),Da(e,g,d.x,d.y,c);m.selectEnd();return!0}return!1}function Z(a){a.preventDefault();a.stopImmediatePropagation();a.stopPropagation()}
function xa(a,b){a=b.elem;b=w.$getNearestNodeFromDOMNode(a);C(b)||E(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 ya(a,b){a=b.elem;b=w.$getNearestNodeFromDOMNode(a);C(b)||E(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,C);return C(a)?a:null}function T(a){a=h.$findMatchingParent(a,M);return M(a)?a:null}
function Y(a,b,c,d,e){if(("up"===c||"down"===c)&&Ea(a))return!1;var f=w.$getSelection();if(!U(f,d)){if(w.$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,r=>w.$isElementNode(r)&&!r.isInline());if(!e)return!1;e=e.getPreviousSibling();if(!e||!M(e))return!1;Z(b);e.selectEnd();return!0}if(b.shiftKey&&("up"===c||"down"===c))if(b=f.focus.getNode(),w.$isRootOrShadowRoot(b)){if((c=
f.getNodes()[0])&&(c=h.$findMatchingParent(c,C))&&d.isParentOf(c)){b=d.getFirstDescendant();c=d.getLastDescendant();if(!b||!c)return!1;[b]=P(b);[c]=P(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,r=>w.$isElementNode(r)&&!r.isInline());if(!d)return!1;d="down"===c?d.getNextSibling():
d.getPreviousSibling();if(M(d)&&e.tableNodeKey===d.getKey()){e=d.getFirstDescendant();d=d.getLastDescendant();if(!e||!d)return!1;[e]=P(e);[d]=P(d);b=f.clone();b.focus.set(("up"===c?e:d).getKey(),"up"===c?0:d.getChildrenSize(),"element");w.$setSelection(b);return!0}}}return!1}if(w.$isRangeSelection(f)&&f.isCollapsed()){let {anchor:r,focus:u}=f;var g=h.$findMatchingParent(r.getNode(),C),m=h.$findMatchingParent(u.getNode(),C);if(!C(g)||!g.is(m))return!1;m=T(g);if(m!==d&&null!=m){var p=a.getElementByKey(m.getKey());
if(null!=p)return e.table=R(p),Y(a,b,c,m,e)}if("backward"===c||"forward"===c){e=r.type;a=r.offset;g=r.getNode();if(!g)return!1;f=f.getNodes();return 1===f.length&&w.$isDecoratorNode(f[0])?!1:Fa(e,a,g,c)?Ga(b,g,d,c):!1}f=a.getElementByKey(g.__key);m=a.getElementByKey(r.key);if(null==m||null==f)return!1;if("element"===r.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(Q(f)){let {anchor:r,focus:u}=f;p=h.$findMatchingParent(r.getNode(),C);m=h.$findMatchingParent(u.getNode(),C);[g]=f.getNodes();a=
a.getElementByKey(g.getKey());if(!C(p)||!C(m)||!M(g)||null==a)return!1;e.updateTableTableSelection(f);f=R(a);a=d.getCordsFromCellNode(p,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 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=>w.$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,C);if(!C(e))return!1;let [f,g]=O(c,e,e);e=f[0][0];let m=f[f.length-1][f[0].length-1],{startColumn:p,startRow:q}=g;if("backward"===d?p!==e.startColumn||q!==e.startRow:p!==m.startColumn||q!==m.startRow)return!1;b=Ia(b,d,c);if(!b||M(b))return!1;Z(a);"backward"===d?b.selectEnd():b.selectStart();return!0}
function Ga(a,b,c,d){var e=h.$findMatchingParent(b,C);if(!C(e))return!1;let [f,g]=O(c,e,e);e=f[0][0];let m=f[f.length-1][f[0].length-1],{startColumn:p,startRow:r}=g;if("backward"===d?p!==e.startColumn||r!==e.startRow:p!==m.startColumn||r!==m.startRow)return!1;b=Ia(b,d,c);if(!b||M(b))return!1;Z(a);"backward"===d?b.selectEnd():b.selectStart();return!0}
function Ia(a,b,c){if(a=h.$findMatchingParent(a,d=>w.$isElementNode(d)&&!d.isInline()))return(a="backward"===b?a.getPreviousSibling():a.getNextSibling())&&M(a)?a:"backward"===b?c.getPreviousSibling():c.getNextSibling()}function Ja(a,b,c){let d=w.$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(),p=>C(p)))&&(a=h.$findMatchingParent(b,p=>M(p)),M(a)&&a.is(c))){var [e,f]=O(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"}}
function La(a,b,c){c?(h.addClassNamesToElement(a,b.theme.tableRowStriping),a.setAttribute("data-lexical-row-striping","true")):(h.removeClassNamesFromElement(a,b.theme.tableRowStriping),a.removeAttribute("data-lexical-row-striping"))}
class Ma extends w.ElementNode{static getType(){return"table"}static clone(a){return new Ma(a.__key)}afterCloneFrom(a){super.afterCloneFrom(a);this.__rowStriping=a.__rowStriping}static importDOM(){return{table:()=>({conversion:Na,priority:1})}}static importJSON(a){let b=Oa();b.__rowStriping=a.rowStriping||!1;return b}constructor(a){super(a);this.__rowStriping=!1}exportJSON(){return{...super.exportJSON(),rowStriping:this.__rowStriping?this.__rowStriping:void 0,type:"table",version:1}}createDOM(a){let b=
document.createElement("table");h.addClassNamesToElement(b,a.theme.table);this.__rowStriping&&La(b,a,!0);return b}updateDOM(a,b,c){a.__rowStriping!==this.__rowStriping&&La(b,c,this.__rowStriping);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,w.$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=w.$getNearestNodeFromDOMNode(a.elem);return C(a)?a:null}getCellNodeFromCordsOrThrow(a,b,c){a=this.getCellNodeFromCords(a,b,c);if(!a)throw Error("Node at cords not TableCellNode.");return a}getRowStriping(){return!!this.getLatest().__rowStriping}setRowStriping(a){this.getWritable().__rowStriping=
a}canSelectBefore(){return!0}canIndent(){return!1}}function Na(a){let b=Oa();a.hasAttribute("data-lexical-row-striping")&&b.setRowStriping(!0);return{node:b}}function Oa(){return w.$applyNodeReplacement(new Ma)}function M(a){return a instanceof Ma}exports.$computeTableMap=O;exports.$computeTableMapSkipCellCheck=ma;exports.$createTableCellNode=B;exports.$createTableNode=Oa;
exports.$createTableNodeWithDimensions=function(a,b,c=!0){let d=Oa();for(let f=0;f<a;f++){let g=F();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=B(e);let p=w.$createParagraphNode();p.append(w.$createTextNode());e.append(p);g.append(e)}d.append(g)}return d};exports.$createTableRowNode=F;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(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=w.$getSelection();w.$isRangeSelection(a)||Q(a)||J(188);var b=a.anchor.getNode();a=a.focus.getNode();let [c,,d]=P(b);[a]=P(a);let [e,f,g]=O(d,c,a);({startColumn:b}=f);let {startRow:m,startColumn:p}=g;var q=Math.min(b,p);let u=Math.max(b+c.__colSpan-1,p+a.__colSpan-1),k=u-q+1;if(e[0].length===u-q+1)d.selectPrevious(),d.remove();else{var l=e.length;for(let n=0;n<l;n++)for(let t=q;t<=u;t++){let {cell:r,startColumn:v}=e[n][t];v<q?t===q&&r.setColSpan(r.__colSpan-
Math.min(k,r.__colSpan-(q-v))):v+r.__colSpan-1>u?t===u&&r.setColSpan(r.__colSpan-(u-v+1)):r.remove()}q=e[m];a=b>p?q[b+c.__colSpan]:q[p+a.__colSpan];void 0!==a?({cell:b}=a,N(b)):({cell:b}=p<b?q[p-1]:q[b-1],N(b))}};
exports.$deleteTableRow__EXPERIMENTAL=function(){var a=w.$getSelection();w.$isRangeSelection(a)||Q(a)||J(188);var b=a.anchor.getNode();a=a.focus.getNode();let [c,,d]=P(b);[a]=P(a);let [e,f,g]=O(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 p=e[a+1],q=d.getChildAtIndex(a+1);for(let k=a;k>=b;k--){for(var u=m-1;0<=u;u--){let {cell:l,startRow:n,startColumn:t}=e[k][u];if(t===u&&(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===q&&J(122),0===u)la(q,l);else{let {cell:r}=p[u-1];r.insertAfter(l)}}u=d.getChildAtIndex(k);I(u)||J(205,String(k));u.remove()}void 0!==p?({cell:b}=p[0],N(b)):({cell:b}=e[b-1][0],N(b))}};exports.$findCellNode=X;exports.$findTableNode=T;exports.$getElementForTableNode=function(a,b){a=a.getElementByKey(b.getKey());if(null==a)throw Error("Table Element Not Found");return R(a)};exports.$getNodeTriplet=P;
function La(a,b,c,d){if(a=a.querySelector("colgroup")){b=[];for(let e=0;e<c;e++){let f=document.createElement("col"),g=d&&d[e];g&&(f.style.width=`${g}px`);b.push(f)}a.replaceChildren(...b)}}function Ma(a,b,c){c?(h.addClassNamesToElement(a,b.theme.tableRowStriping),a.setAttribute("data-lexical-row-striping","true")):(h.removeClassNamesFromElement(a,b.theme.tableRowStriping),a.removeAttribute("data-lexical-row-striping"))}
class Na extends w.ElementNode{static getType(){return"table"}getColWidths(){return this.getLatest().__colWidths}setColWidths(a){let b=this.getWritable();b.__colWidths=a;return b}static clone(a){return new Na(a.__key)}afterCloneFrom(a){super.afterCloneFrom(a);this.__colWidths=a.__colWidths;this.__rowStriping=a.__rowStriping}static importDOM(){return{table:()=>({conversion:Oa,priority:1})}}static importJSON(a){let b=Pa();b.__rowStriping=a.rowStriping||!1;b.__colWidths=a.colWidths;return b}constructor(a){super(a);
this.__rowStriping=!1}exportJSON(){return{...super.exportJSON(),colWidths:this.getColWidths(),rowStriping:this.__rowStriping?this.__rowStriping:void 0,type:"table",version:1}}createDOM(a){let b=document.createElement("table"),c=document.createElement("colgroup");b.appendChild(c);La(b,a,this.getColumnCount(),this.getColWidths());h.addClassNamesToElement(b,a.theme.table);this.__rowStriping&&Ma(b,a,!0);return b}updateDOM(a,b,c){a.__rowStriping!==this.__rowStriping&&Ma(b,c,this.__rowStriping);La(b,c,
this.getColumnCount(),this.getColWidths());return!1}exportDOM(a){return{...super.exportDOM(a),after:b=>{if(b){let c=b.cloneNode(),d=document.createElement("colgroup"),e=document.createElement("tbody");if(h.isHTMLElement(b)){let f=b.querySelectorAll("col");d.append(...f);b=b.querySelectorAll("tr");e.append(...b)}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,w.$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=w.$getNearestNodeFromDOMNode(a.elem);return C(a)?
a:null}getCellNodeFromCordsOrThrow(a,b,c){a=this.getCellNodeFromCords(a,b,c);if(!a)throw Error("Node at cords not TableCellNode.");return a}getRowStriping(){return!!this.getLatest().__rowStriping}setRowStriping(a){this.getWritable().__rowStriping=a}canSelectBefore(){return!0}canIndent(){return!1}getColumnCount(){let a=this.getFirstChild();if(!a)return 0;let b=0;a.getChildren().forEach(c=>{C(c)&&(b+=c.getColSpan())});return b}}
function Oa(a){let b=Pa();a.hasAttribute("data-lexical-row-striping")&&b.setRowStriping(!0);return{node:b}}function Pa(){return w.$applyNodeReplacement(new Na)}function M(a){return a instanceof Na}exports.$computeTableMap=O;exports.$computeTableMapSkipCellCheck=ma;exports.$createTableCellNode=B;exports.$createTableNode=Pa;
exports.$createTableNodeWithDimensions=function(a,b,c=!0){let d=Pa();for(let f=0;f<a;f++){let g=J();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=B(e);let p=w.$createParagraphNode();p.append(w.$createTextNode());e.append(p);g.append(e)}d.append(g)}return d};exports.$createTableRowNode=J;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(K(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=w.$getSelection();w.$isRangeSelection(a)||Q(a)||E(188);var b=a.anchor.getNode();a=a.focus.getNode();let [c,,d]=P(b);var [e]=P(a);let [f,g,m]=O(d,c,e);var {startColumn:p}=g;let {startRow:r,startColumn:u}=m;b=Math.min(p,u);var k=Math.max(p+c.__colSpan-1,u+e.__colSpan-1);a=k-b+1;if(f[0].length===k-b+1)d.selectPrevious(),d.remove();else{var l=f.length;for(let n=0;n<l;n++)for(let t=b;t<=k;t++){let {cell:q,startColumn:v}=f[n][t];v<b?t===b&&q.setColSpan(q.__colSpan-
Math.min(a,q.__colSpan-(b-v))):v+q.__colSpan-1>k?t===k&&q.setColSpan(q.__colSpan-(k-v+1)):q.remove()}k=f[r];e=p>u?k[p+c.__colSpan]:k[u+e.__colSpan];void 0!==e?({cell:p}=e,N(p)):({cell:p}=u<p?k[u-1]:k[p-1],N(p));if(p=d.getColWidths())p=[...p],p.splice(b,a),d.setColWidths(p)}};
exports.$deleteTableRow__EXPERIMENTAL=function(){var a=w.$getSelection();w.$isRangeSelection(a)||Q(a)||E(188);var b=a.anchor.getNode();a=a.focus.getNode();let [c,,d]=P(b);[a]=P(a);let [e,f,g]=O(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 p=e[a+1],r=d.getChildAtIndex(a+1);for(let k=a;k>=b;k--){for(var u=m-1;0<=u;u--){let {cell:l,startRow:n,startColumn:t}=e[k][u];if(t===u&&(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===r&&E(122),0===u)la(r,l);else{let {cell:q}=p[u-1];q.insertAfter(l)}}u=d.getChildAtIndex(k);K(u)||E(205,String(k));u.remove()}void 0!==p?({cell:b}=p[0],N(b)):({cell:b}=e[b-1][0],N(b))}};exports.$findCellNode=X;exports.$findTableNode=T;exports.$getElementForTableNode=function(a,b){a=a.getElementByKey(b.getKey());if(null==a)throw Error("Table Element Not Found");return R(a)};exports.$getNodeTriplet=P;
exports.$getTableCellNodeFromLexicalNode=function(a){a=h.$findMatchingParent(a,b=>C(b));return C(a)?a:null};exports.$getTableCellNodeRect=oa;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 q=0;q<f.length;q++){let u=f[q];if(I(u))for(let k=0;k<d;k++){var m=u.getChildren();if(b>=m.length||0>b)throw Error("Table column target index out of range");m=m[b];C(m)||J(12);let {left:l,right:n}=ja(m,e);var p=x.NO_STATUS;if(l&&l.hasHeaderState(x.ROW)||n&&n.hasHeaderState(x.ROW))p|=x.ROW;p=B(p);p.append(w.$createParagraphNode());g.push({newTableCell:p,targetCell:m})}}g.forEach(({newTableCell:q,targetCell:u})=>{c?
u.insertAfter(q):u.insertBefore(q)});return a};
exports.$insertTableColumn__EXPERIMENTAL=function(a=!0){function b(k=x.NO_STATUS){k=B(k).append(w.$createParagraphNode());null===q&&(q=k);return k}var c=w.$getSelection();w.$isRangeSelection(c)||Q(c)||J(188);var d=c.anchor.getNode();c=c.focus.getNode();[d]=P(d);let [e,,f]=P(c),[g,m,p]=O(f,e,d);d=g.length;c=a?Math.max(m.startColumn,p.startColumn):Math.min(m.startColumn,p.startColumn);a=a?c+e.__colSpan-1:c-1;c=f.getFirstChild();I(c)||J(120);let q=null;var u=c;a:for(c=0;c<d;c++){0!==c&&(u=u.getNextSibling(),
I(u)||J(121));let k=g[c],l=ka(k[0>a?0:a].cell.__headerState,x.ROW);if(0>a){la(u,b(l));continue}let {cell:n,startColumn:t,startRow:r}=k[a];if(t+n.__colSpan-1<=a){let v=n,A=r,z=a;for(;A!==c&&1<v.__rowSpan;)if(z-=n.__colSpan,0<=z){let {cell:D,startRow:G}=k[z];v=D;A=G}else{u.append(b(l));continue a}v.insertAfter(b(l))}else n.setColSpan(n.__colSpan+1)}null!==q&&N(q)};
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(),p=m.length,q=F();for(let u=0;u<p;u++){var g=m[u];C(g)||J(12);let {above:k,below:l}=ja(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=B(g,1,n);g.append(w.$createParagraphNode());q.append(g)}c?b.insertAfter(q):b.insertBefore(q)}else throw Error("Row before insertion index does not exist.");
exports.$insertTableColumn=function(a,b,c=!0,d,e){let f=a.getChildren(),g=[];for(let r=0;r<f.length;r++){let u=f[r];if(K(u))for(let k=0;k<d;k++){var m=u.getChildren();if(b>=m.length||0>b)throw Error("Table column target index out of range");m=m[b];C(m)||E(12);let {left:l,right:n}=ja(m,e);var p=x.NO_STATUS;if(l&&l.hasHeaderState(x.ROW)||n&&n.hasHeaderState(x.ROW))p|=x.ROW;p=B(p);p.append(w.$createParagraphNode());g.push({newTableCell:p,targetCell:m})}}g.forEach(({newTableCell:r,targetCell:u})=>{c?
u.insertAfter(r):u.insertBefore(r)});return a};
exports.$insertTableColumn__EXPERIMENTAL=function(a=!0){function b(k=x.NO_STATUS){k=B(k).append(w.$createParagraphNode());null===r&&(r=k);return k}var c=w.$getSelection();w.$isRangeSelection(c)||Q(c)||E(188);var d=c.anchor.getNode();c=c.focus.getNode();[d]=P(d);let [e,,f]=P(c),[g,m,p]=O(f,e,d);d=g.length;c=a?Math.max(m.startColumn,p.startColumn):Math.min(m.startColumn,p.startColumn);a=a?c+e.__colSpan-1:c-1;c=f.getFirstChild();K(c)||E(120);let r=null;var u=c;a:for(c=0;c<d;c++){0!==c&&(u=u.getNextSibling(),
K(u)||E(121));let k=g[c],l=ka(k[0>a?0:a].cell.__headerState,x.ROW);if(0>a){la(u,b(l));continue}let {cell:n,startColumn:t,startRow:q}=k[a];if(t+n.__colSpan-1<=a){let v=n,A=q,z=a;for(;A!==c&&1<v.__rowSpan;)if(z-=n.__colSpan,0<=z){let {cell:D,startRow:G}=k[z];v=D;A=G}else{u.append(b(l));continue a}v.insertAfter(b(l))}else n.setColSpan(n.__colSpan+1)}null!==r&&N(r);if(d=f.getColWidths())d=[...d],a=0>a?0:a,d.splice(a,0,d[a]),f.setColWidths(d)};
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(K(b))for(f=0;f<d;f++){let m=b.getChildren(),p=m.length,r=J();for(let u=0;u<p;u++){var g=m[u];C(g)||E(12);let {above:k,below:l}=ja(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=B(g,1,n);g.append(w.$createParagraphNode());r.append(g)}c?b.insertAfter(r):b.insertBefore(r)}else throw Error("Row before insertion index does not exist.");
return a};
exports.$insertTableRow__EXPERIMENTAL=function(a=!0){var b=w.$getSelection();w.$isRangeSelection(b)||Q(b)||J(188);b=b.focus.getNode();let [c,,d]=P(b),[e,f]=O(d,c,c);b=e[0].length;var {startRow:g}=f;if(a){a=g+c.__rowSpan-1;var m=e[a];g=F();for(var p=0;p<b;p++){let {cell:u,startRow:k}=m[p];if(k+u.__rowSpan-1<=a){var q=ka(m[p].cell.__headerState,x.COLUMN);g.append(B(q).append(w.$createParagraphNode()))}else u.setRowSpan(u.__rowSpan+1)}b=d.getChildAtIndex(a);I(b)||J(145);b.insertAfter(g)}else{m=e[g];
a=F();for(p=0;p<b;p++){let {cell:u,startRow:k}=m[p];k===g?(q=ka(m[p].cell.__headerState,x.COLUMN),a.append(B(q).append(w.$createParagraphNode()))):u.setRowSpan(u.__rowSpan+1)}b=d.getChildAtIndex(g);I(b)||J(145);b.insertBefore(a)}};exports.$isTableCellNode=C;exports.$isTableNode=M;exports.$isTableRowNode=I;exports.$isTableSelection=Q;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=w.$getSelection();w.$isRangeSelection(a)||Q(a)||J(188);a=a.anchor.getNode();let [b,c,d]=P(a);a=b.__colSpan;let e=b.__rowSpan;if(1!==a||1!==e){var [f,g]=O(d,b,b),{startColumn:m,startRow:p}=g,q=b.__headerState&x.COLUMN,u=Array.from({length:a},(v,A)=>{v=q;for(let z=0;0!==v&&z<f.length;z++)v&=f[z][A+m].cell.__headerState;return v}),k=b.__headerState&x.ROW,l=Array.from({length:e},(v,A)=>{v=k;for(let z=0;0!==v&&z<f[0].length;z++)v&=f[A+p][z].cell.__headerState;return v});
if(1<a){for(var n=1;n<a;n++)b.insertAfter(B(u[n]|l[0]).append(w.$createParagraphNode()));b.setColSpan(1)}if(1<e){let v;for(n=1;n<e;n++){var t=p+n;let A=f[t];v=(v||c).getNextSibling();I(v)||J(125);var r=null;for(let z=0;z<m;z++){let D=A[z],G=D.cell;D.startRow===t&&(r=G);1<G.__colSpan&&(z+=G.__colSpan-1)}if(null===r)for(r=a-1;0<=r;r--)la(v,B(u[r]|l[n]).append(w.$createParagraphNode()));else for(t=a-1;0<=t;t--)r.insertAfter(B(u[t]|l[n]).append(w.$createParagraphNode()))}b.setRowSpan(1)}}};
exports.INSERT_TABLE_COMMAND=da;exports.TableCellHeaderStates=x;exports.TableCellNode=y;exports.TableNode=Ma;exports.TableObserver=sa;exports.TableRowNode=E;
exports.$insertTableRow__EXPERIMENTAL=function(a=!0){var b=w.$getSelection();w.$isRangeSelection(b)||Q(b)||E(188);b=b.focus.getNode();let [c,,d]=P(b),[e,f]=O(d,c,c);b=e[0].length;var {startRow:g}=f;if(a){a=g+c.__rowSpan-1;var m=e[a];g=J();for(var p=0;p<b;p++){let {cell:u,startRow:k}=m[p];if(k+u.__rowSpan-1<=a){var r=ka(m[p].cell.__headerState,x.COLUMN);g.append(B(r).append(w.$createParagraphNode()))}else u.setRowSpan(u.__rowSpan+1)}b=d.getChildAtIndex(a);K(b)||E(145);b.insertAfter(g)}else{m=e[g];
a=J();for(p=0;p<b;p++){let {cell:u,startRow:k}=m[p];k===g?(r=ka(m[p].cell.__headerState,x.COLUMN),a.append(B(r).append(w.$createParagraphNode()))):u.setRowSpan(u.__rowSpan+1)}b=d.getChildAtIndex(g);K(b)||E(145);b.insertBefore(a)}};exports.$isTableCellNode=C;exports.$isTableNode=M;exports.$isTableRowNode=K;exports.$isTableSelection=Q;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=w.$getSelection();w.$isRangeSelection(a)||Q(a)||E(188);a=a.anchor.getNode();let [b,c,d]=P(a);a=b.__colSpan;let e=b.__rowSpan;if(1!==a||1!==e){var [f,g]=O(d,b,b),{startColumn:m,startRow:p}=g,r=b.__headerState&x.COLUMN,u=Array.from({length:a},(v,A)=>{v=r;for(let z=0;0!==v&&z<f.length;z++)v&=f[z][A+m].cell.__headerState;return v}),k=b.__headerState&x.ROW,l=Array.from({length:e},(v,A)=>{v=k;for(let z=0;0!==v&&z<f[0].length;z++)v&=f[A+p][z].cell.__headerState;return v});
if(1<a){for(var n=1;n<a;n++)b.insertAfter(B(u[n]|l[0]).append(w.$createParagraphNode()));b.setColSpan(1)}if(1<e){let v;for(n=1;n<e;n++){var t=p+n;let A=f[t];v=(v||c).getNextSibling();K(v)||E(125);var q=null;for(let z=0;z<m;z++){let D=A[z],G=D.cell;D.startRow===t&&(q=G);1<G.__colSpan&&(z+=G.__colSpan-1)}if(null===q)for(q=a-1;0<=q;q--)la(v,B(u[q]|l[n]).append(w.$createParagraphNode()));else for(t=a-1;0<=t;t--)q.insertAfter(B(u[t]|l[n]).append(w.$createParagraphNode()))}b.setRowSpan(1)}}};
exports.INSERT_TABLE_COMMAND=da;exports.TableCellHeaderStates=x;exports.TableCellNode=y;exports.TableNode=Na;exports.TableObserver=sa;exports.TableRowNode=I;
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;ta(b,g);g.listenersToRemove.add(()=>{var k=g;ua(b)===k&&delete b.__lexicalTableSelection});let p=()=>{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=va(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=va(k.target);null!==l&&(Z(k),g.setAnchorCellForSelection(l));var {onMouseUp:n,onMouseMove:t}=p();g.isSelecting=!0;m.addEventListener("mouseup",n,g.listenerOptions);
m.addEventListener("mousemove",t,g.listenerOptions)}},0)},g.listenerOptions);m.addEventListener("mousedown",k=>{0===k.button&&c.update(()=>{const l=w.$getSelection(),n=k.target;Q(l)&&l.tableKey===g.tableNodeKey&&f.contains(n)&&g.clearHighlight()})},g.listenerOptions);g.listenersToRemove.add(c.registerCommand(w.KEY_ARROW_DOWN_COMMAND,k=>Y(c,k,"down",a,g),w.COMMAND_PRIORITY_HIGH));g.listenersToRemove.add(c.registerCommand(w.KEY_ARROW_UP_COMMAND,k=>Y(c,k,"up",a,g),w.COMMAND_PRIORITY_HIGH));g.listenersToRemove.add(c.registerCommand(w.KEY_ARROW_LEFT_COMMAND,
k=>Y(c,k,"backward",a,g),w.COMMAND_PRIORITY_HIGH));g.listenersToRemove.add(c.registerCommand(w.KEY_ARROW_RIGHT_COMMAND,k=>Y(c,k,"forward",a,g),w.COMMAND_PRIORITY_HIGH));g.listenersToRemove.add(c.registerCommand(w.KEY_ESCAPE_COMMAND,k=>{var l=w.$getSelection();return Q(l)&&(l=h.$findMatchingParent(l.focus.getNode(),C),C(l))?(Z(k),l.selectEnd(),!0):!1},w.COMMAND_PRIORITY_HIGH));let q=k=>()=>{var l=w.$getSelection();if(!U(l,a))return!1;if(Q(l))return g.clearText(),!0;if(w.$isRangeSelection(l)){var n=
h.$findMatchingParent(l.anchor.getNode(),r=>C(r));if(!C(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(),r=>w.$isElementNode(r)))&&h.$findMatchingParent(l,r=>w.$isElementNode(r)&&C(r.getParent()));if(!w.$isElementNode(n)||!w.$isElementNode(l))return!1;if(k===w.DELETE_LINE_COMMAND&&null===n.getPreviousSibling())return!0}return!1};[w.DELETE_WORD_COMMAND,w.DELETE_LINE_COMMAND,
w.DELETE_CHARACTER_COMMAND].forEach(k=>{g.listenersToRemove.add(c.registerCommand(k,q(k),w.COMMAND_PRIORITY_CRITICAL))});let u=k=>{const l=w.$getSelection();if(!U(l,a)){if(k=l?l.getNodes():null)if(k=k.find(n=>M(n)&&n.getKey()===g.tableNodeKey),M(k)){if(!k.getParent())return!1;k.remove()}return!1}if(Q(l))return k&&(k.preventDefault(),k.stopPropagation()),g.clearText(),!0;w.$isRangeSelection(l)&&(k=h.$findMatchingParent(l.anchor.getNode(),n=>C(n)),C(k));return!1};g.listenersToRemove.add(c.registerCommand(w.KEY_BACKSPACE_COMMAND,
k=>Y(c,k,"backward",a,g),w.COMMAND_PRIORITY_HIGH));g.listenersToRemove.add(c.registerCommand(w.KEY_ARROW_RIGHT_COMMAND,k=>Y(c,k,"forward",a,g),w.COMMAND_PRIORITY_HIGH));g.listenersToRemove.add(c.registerCommand(w.KEY_ESCAPE_COMMAND,k=>{var l=w.$getSelection();return Q(l)&&(l=h.$findMatchingParent(l.focus.getNode(),C),C(l))?(Z(k),l.selectEnd(),!0):!1},w.COMMAND_PRIORITY_HIGH));let r=k=>()=>{var l=w.$getSelection();if(!U(l,a))return!1;if(Q(l))return g.clearText(),!0;if(w.$isRangeSelection(l)){var n=
h.$findMatchingParent(l.anchor.getNode(),q=>C(q));if(!C(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(),q=>w.$isElementNode(q)))&&h.$findMatchingParent(l,q=>w.$isElementNode(q)&&C(q.getParent()));if(!w.$isElementNode(n)||!w.$isElementNode(l))return!1;if(k===w.DELETE_LINE_COMMAND&&null===n.getPreviousSibling())return!0}return!1};[w.DELETE_WORD_COMMAND,w.DELETE_LINE_COMMAND,
w.DELETE_CHARACTER_COMMAND].forEach(k=>{g.listenersToRemove.add(c.registerCommand(k,r(k),w.COMMAND_PRIORITY_CRITICAL))});let u=k=>{const l=w.$getSelection();if(!U(l,a)){if(k=l?l.getNodes():null)if(k=k.find(n=>M(n)&&n.getKey()===g.tableNodeKey),M(k)){if(!k.getParent())return!1;k.remove()}return!1}if(Q(l))return k&&(k.preventDefault(),k.stopPropagation()),g.clearText(),!0;w.$isRangeSelection(l)&&(k=h.$findMatchingParent(l.anchor.getNode(),n=>C(n)),C(k));return!1};g.listenersToRemove.add(c.registerCommand(w.KEY_BACKSPACE_COMMAND,
u,w.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(w.KEY_DELETE_COMMAND,u,w.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(w.CUT_COMMAND,k=>{let l=w.$getSelection();if(l){if(!Q(l)&&!w.$isRangeSelection(l))return!1;void aa.copyToClipboard(c,h.objectKlassEquals(k,ClipboardEvent)?k:null,aa.$getClipboardDataFromSelection(l));k=u(k);return w.$isRangeSelection(l)?(l.removeText(),!0):k}return!1},w.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(w.FORMAT_TEXT_COMMAND,
k=>{let l=w.$getSelection();if(!U(l,a))return!1;if(Q(l))return g.formatCells(k),!0;w.$isRangeSelection(l)&&(k=h.$findMatchingParent(l.anchor.getNode(),n=>C(n)),C(k));return!1},w.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(w.FORMAT_ELEMENT_COMMAND,k=>{var l=w.$getSelection();if(!Q(l)||!U(l,a))return!1;var n=l.anchor.getNode();l=l.focus.getNode();if(!C(n)||!C(l))return!1;let [t,r,v]=O(a,n,l);n=Math.max(r.startRow,v.startRow);l=Math.max(r.startColumn,v.startColumn);var A=Math.min(r.startRow,
v.startRow);let z=Math.min(r.startColumn,v.startColumn);for(;A<=n;A++)for(let G=z;G<=l;G++){var D=t[A][G].cell;D.setFormat(k);D=D.getChildren();for(let L=0;L<D.length;L++){let H=D[L];w.$isElementNode(H)&&!H.isInline()&&H.setFormat(k)}}return!0},w.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(w.CONTROLLED_TEXT_INSERTION_COMMAND,k=>{var l=w.$getSelection();if(!U(l,a))return!1;if(Q(l))g.clearHighlight();else if(w.$isRangeSelection(l)){let n=h.$findMatchingParent(l.anchor.getNode(),
k=>{let l=w.$getSelection();if(!U(l,a))return!1;if(Q(l))return g.formatCells(k),!0;w.$isRangeSelection(l)&&(k=h.$findMatchingParent(l.anchor.getNode(),n=>C(n)),C(k));return!1},w.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(w.FORMAT_ELEMENT_COMMAND,k=>{var l=w.$getSelection();if(!Q(l)||!U(l,a))return!1;var n=l.anchor.getNode();l=l.focus.getNode();if(!C(n)||!C(l))return!1;let [t,q,v]=O(a,n,l);n=Math.max(q.startRow,v.startRow);l=Math.max(q.startColumn,v.startColumn);var A=Math.min(q.startRow,
v.startRow);let z=Math.min(q.startColumn,v.startColumn);for(;A<=n;A++)for(let G=z;G<=l;G++){var D=t[A][G].cell;D.setFormat(k);D=D.getChildren();for(let L=0;L<D.length;L++){let H=D[L];w.$isElementNode(H)&&!H.isInline()&&H.setFormat(k)}}return!0},w.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(w.CONTROLLED_TEXT_INSERTION_COMMAND,k=>{var l=w.$getSelection();if(!U(l,a))return!1;if(Q(l))g.clearHighlight();else if(w.$isRangeSelection(l)){let n=h.$findMatchingParent(l.anchor.getNode(),
t=>C(t));if(!C(n))return!1;if("string"===typeof k&&(l=Ka(c,l,a)))return Ja(l,a,[w.$createTextNode(k)]),!0}return!1},w.COMMAND_PRIORITY_CRITICAL));d&&g.listenersToRemove.add(c.registerCommand(w.KEY_TAB_COMMAND,k=>{var l=w.$getSelection();if(!w.$isRangeSelection(l)||!l.isCollapsed()||!U(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},w.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(w.FOCUS_COMMAND,
()=>a.isSelected(),w.COMMAND_PRIORITY_HIGH));g.listenersToRemove.add(c.registerCommand(w.SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,k=>{let {nodes:l,selection:n}=k;k=n.getStartEndPoints();var t=Q(n);t=w.$isRangeSelection(n)&&null!==h.$findMatchingParent(n.anchor.getNode(),H=>C(H))&&null!==h.$findMatchingParent(n.focus.getNode(),H=>C(H))||t;if(1!==l.length||!M(l[0])||!t||null===k)return!1;var [r]=k,v=l[0];k=v.getChildren();t=v.getFirstChildOrThrow().getChildrenSize();v=v.getChildrenSize();var A=h.$findMatchingParent(r.getNode(),
H=>C(H)),z=A&&h.$findMatchingParent(A,H=>I(H)),D=z&&h.$findMatchingParent(z,H=>M(H));if(!C(A)||!I(z)||!M(D))return!1;r=z.getIndexWithinParent();var G=Math.min(D.getChildrenSize()-1,r+v-1);v=A.getIndexWithinParent();A=Math.min(z.getChildrenSize()-1,v+t-1);t=Math.min(v,A);z=Math.min(r,G);v=Math.max(v,A);r=Math.max(r,G);D=D.getChildren();for(G=0;z<=r;z++){A=D[z];if(!I(A))return!1;var L=k[G];if(!I(L))return!1;A=A.getChildren();L=L.getChildren();let H=0;for(let V=t;V<=v;V++){let na=A[V];if(!C(na))return!1;
let Ca=L[H];if(!C(Ca))return!1;let Pa=na.getChildren();Ca.getChildren().forEach(W=>{w.$isTextNode(W)&&w.$createParagraphNode().append(W);na.append(W)});Pa.forEach(W=>W.remove());H++}G++}return!0},w.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(w.SELECTION_CHANGE_COMMAND,()=>{let k=w.$getSelection(),l=w.$getPreviousSelection();if(w.$isRangeSelection(k)){let {anchor:A,focus:z}=k;var n=A.getNode(),t=z.getNode(),r=X(n),v=X(t);let D=!(!r||!a.is(T(r))),G=!(!v||!a.is(T(v)));n=D!==
G;let L=D&&G;t=k.isBackward();n?(n=k.clone(),G?([v]=O(a,v,v),r=v[0][0].cell,v=v[v.length-1].at(-1).cell,n.focus.set(t?r.getKey():v.getKey(),t?r.getChildrenSize():v.getChildrenSize(),"element")):D&&([v]=O(a,r,r),r=v[0][0].cell,v=v[v.length-1].at(-1).cell,n.anchor.set(t?v.getKey():r.getKey(),t?v.getChildrenSize():0,"element")),w.$setSelection(n),za(c,g)):L&&!r.is(v)&&(g.setAnchorCellForSelection(e(r)),g.setFocusCellForSelection(e(v),!0),g.isSelecting||setTimeout(()=>{let {onMouseUp:H,onMouseMove:V}=
p();g.isSelecting=!0;m.addEventListener("mouseup",H);m.addEventListener("mousemove",V)},0))}else k&&Q(k)&&k.is(l)&&k.tableKey===a.getKey()&&(t=fa?(c._window||window).getSelection():null)&&t.anchorNode&&t.focusNode&&(n=(n=w.$getNearestNodeFromDOMNode(t.focusNode))&&!a.is(T(n)),r=(r=w.$getNearestNodeFromDOMNode(t.anchorNode))&&a.is(T(r)),n&&r&&0<t.rangeCount&&(n=w.$createRangeSelectionFromDom(t,c)))&&(n.anchor.set(a.getKey(),k.isBackward()?a.getChildrenSize():0,"element"),t.removeAllRanges(),w.$setSelection(n));
()=>a.isSelected(),w.COMMAND_PRIORITY_HIGH));g.listenersToRemove.add(c.registerCommand(w.SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,k=>{let {nodes:l,selection:n}=k;k=n.getStartEndPoints();var t=Q(n);t=w.$isRangeSelection(n)&&null!==h.$findMatchingParent(n.anchor.getNode(),H=>C(H))&&null!==h.$findMatchingParent(n.focus.getNode(),H=>C(H))||t;if(1!==l.length||!M(l[0])||!t||null===k)return!1;var [q]=k,v=l[0];k=v.getChildren();t=v.getFirstChildOrThrow().getChildrenSize();v=v.getChildrenSize();var A=h.$findMatchingParent(q.getNode(),
H=>C(H)),z=A&&h.$findMatchingParent(A,H=>K(H)),D=z&&h.$findMatchingParent(z,H=>M(H));if(!C(A)||!K(z)||!M(D))return!1;q=z.getIndexWithinParent();var G=Math.min(D.getChildrenSize()-1,q+v-1);v=A.getIndexWithinParent();A=Math.min(z.getChildrenSize()-1,v+t-1);t=Math.min(v,A);z=Math.min(q,G);v=Math.max(v,A);q=Math.max(q,G);D=D.getChildren();for(G=0;z<=q;z++){A=D[z];if(!K(A))return!1;var L=k[G];if(!K(L))return!1;A=A.getChildren();L=L.getChildren();let H=0;for(let V=t;V<=v;V++){let na=A[V];if(!C(na))return!1;
let Da=L[H];if(!C(Da))return!1;let Qa=na.getChildren();Da.getChildren().forEach(W=>{w.$isTextNode(W)&&w.$createParagraphNode().append(W);na.append(W)});Qa.forEach(W=>W.remove());H++}G++}return!0},w.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(w.SELECTION_CHANGE_COMMAND,()=>{let k=w.$getSelection(),l=w.$getPreviousSelection();if(w.$isRangeSelection(k)){let {anchor:A,focus:z}=k;var n=A.getNode(),t=z.getNode(),q=X(n),v=X(t);let D=!(!q||!a.is(T(q))),G=!(!v||!a.is(T(v)));n=D!==
G;let L=D&&G;t=k.isBackward();n?(n=k.clone(),G?([v]=O(a,v,v),q=v[0][0].cell,v=v[v.length-1].at(-1).cell,n.focus.set(t?q.getKey():v.getKey(),t?q.getChildrenSize():v.getChildrenSize(),"element")):D&&([v]=O(a,q,q),q=v[0][0].cell,v=v[v.length-1].at(-1).cell,n.anchor.set(t?v.getKey():q.getKey(),t?v.getChildrenSize():0,"element")),w.$setSelection(n),za(c,g)):L&&!q.is(v)&&(g.setAnchorCellForSelection(e(q)),g.setFocusCellForSelection(e(v),!0),g.isSelecting||setTimeout(()=>{let {onMouseUp:H,onMouseMove:V}=
p();g.isSelecting=!0;m.addEventListener("mouseup",H);m.addEventListener("mousemove",V)},0))}else k&&Q(k)&&k.is(l)&&k.tableKey===a.getKey()&&(t=ea?(c._window||window).getSelection():null)&&t.anchorNode&&t.focusNode&&(n=(n=w.$getNearestNodeFromDOMNode(t.focusNode))&&!a.is(T(n)),q=(q=w.$getNearestNodeFromDOMNode(t.anchorNode))&&a.is(T(q)),n&&q&&0<t.rangeCount&&(n=w.$createRangeSelectionFromDom(t,c)))&&(n.anchor.set(a.getKey(),k.isBackward()?a.getChildrenSize():0,"element"),t.removeAllRanges(),w.$setSelection(n));
if(k&&!k.is(l)&&(Q(k)||Q(l))&&g.tableSelection&&!g.tableSelection.is(l))return Q(k)&&k.tableKey===g.tableNodeKey?g.updateTableTableSelection(k):!Q(k)&&Q(l)&&l.tableKey===g.tableNodeKey&&g.updateTableTableSelection(null),!1;g.hasHijackedSelectionStyles&&!a.isSelected()?Aa(c,g):!g.hasHijackedSelectionStyles&&a.isSelected()&&za(c,g);return!1},w.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(w.INSERT_PARAGRAPH_COMMAND,()=>{var k=w.$getSelection();return w.$isRangeSelection(k)&&
k.isCollapsed()&&U(k,a)?(k=Ka(c,k,a))?(Ja(k,a),!0):!1:!1},w.COMMAND_PRIORITY_CRITICAL));return g};exports.getDOMCellFromTarget=va;exports.getTableObserverFromTableElement=ua

@@ -13,2 +13,3 @@ /**

export type SerializedTableNode = Spread<{
colWidths?: readonly number[];
rowStriping?: boolean;

@@ -20,3 +21,6 @@ }, SerializedElementNode>;

__rowStriping: boolean;
__colWidths?: number[] | readonly number[];
static getType(): string;
getColWidths(): number[] | readonly number[] | undefined;
setColWidths(colWidths: readonly number[]): this;
static clone(node: TableNode): TableNode;

@@ -45,2 +49,3 @@ afterCloneFrom(prevNode: this): void;

canIndent(): false;
getColumnCount(): number;
}

@@ -47,0 +52,0 @@ export declare function $getElementForTableNode(editor: LexicalEditor, tableNode: TableNode): TableDOMTable;

@@ -11,9 +11,9 @@ {

"license": "MIT",
"version": "0.17.2-nightly.20240918.0",
"version": "0.17.2-nightly.20240919.0",
"main": "LexicalTable.js",
"types": "index.d.ts",
"dependencies": {
"@lexical/clipboard": "0.17.2-nightly.20240918.0",
"@lexical/utils": "0.17.2-nightly.20240918.0",
"lexical": "0.17.2-nightly.20240918.0"
"@lexical/clipboard": "0.17.2-nightly.20240919.0",
"@lexical/utils": "0.17.2-nightly.20240919.0",
"lexical": "0.17.2-nightly.20240919.0"
},

@@ -20,0 +20,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