@lexical/table 0.17.2-nightly.20240912.0 → 0.17.2-nightly.20240916.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1585,12 +1585,13 @@ class TableObserver {
1585
1585
  const formatSelection = lexical.$createRangeSelection();
1586
1586
  const anchor = formatSelection.anchor;
1587
1587
  const focus = formatSelection.focus;
1588
- selection.getNodes().forEach(cellNode => {
1589
- if ($isTableCellNode(cellNode) && cellNode.getTextContentSize() !== 0) {
1590
- anchor.set(cellNode.getKey(), 0, 'element');
1591
- focus.set(cellNode.getKey(), cellNode.getChildrenSize(), 'element');
1592
- formatSelection.formatText(type);
1593
- }
1588
+ const cellNodes = selection.getNodes().filter($isTableCellNode);
1589
+ const paragraph = cellNodes[0].getFirstChild();
1590
+ const alignFormatWith = lexical.$isParagraphNode(paragraph) ? paragraph.getFormatFlags(type, null) : null;
1591
+ cellNodes.forEach(cellNode => {
1592
+ anchor.set(cellNode.getKey(), 0, 'element');
1593
+ focus.set(cellNode.getKey(), cellNode.getChildrenSize(), 'element');
1594
+ formatSelection.formatText(type, alignFormatWith);
1594
1595
  });
1595
1596
  lexical.$setSelection(selection);
1596
1597
  this.editor.dispatchCommand(lexical.SELECTION_CHANGE_COMMAND, undefined);
@@ -7,7 +7,7 @@
7
7
  */
8
8
 
9
9
  import { addClassNamesToElement, $findMatchingParent, removeClassNamesFromElement, objectKlassEquals, isHTMLElement } from '@lexical/utils';
10
- import { ElementNode, $createParagraphNode, $isElementNode, $isLineBreakNode, $isTextNode, $applyNodeReplacement, createCommand, $createTextNode, $getSelection, $isRangeSelection, $createPoint, $normalizeSelection__EXPERIMENTAL, $getNodeByKey, isCurrentlyReadOnlyMode, $setSelection, SELECTION_CHANGE_COMMAND, $getNearestNodeFromDOMNode, $createRangeSelection, $getRoot, KEY_ARROW_DOWN_COMMAND, COMMAND_PRIORITY_HIGH, KEY_ARROW_UP_COMMAND, KEY_ARROW_LEFT_COMMAND, KEY_ARROW_RIGHT_COMMAND, KEY_ESCAPE_COMMAND, DELETE_WORD_COMMAND, DELETE_LINE_COMMAND, DELETE_CHARACTER_COMMAND, COMMAND_PRIORITY_CRITICAL, KEY_BACKSPACE_COMMAND, KEY_DELETE_COMMAND, CUT_COMMAND, FORMAT_TEXT_COMMAND, FORMAT_ELEMENT_COMMAND, CONTROLLED_TEXT_INSERTION_COMMAND, KEY_TAB_COMMAND, FOCUS_COMMAND, SELECTION_INSERT_CLIPBOARD_NODES_COMMAND, $getPreviousSelection, $createRangeSelectionFromDom, INSERT_PARAGRAPH_COMMAND, $isRootOrShadowRoot, $isDecoratorNode } from 'lexical';
10
+ import { ElementNode, $createParagraphNode, $isElementNode, $isLineBreakNode, $isTextNode, $applyNodeReplacement, createCommand, $createTextNode, $getSelection, $isRangeSelection, $createPoint, $normalizeSelection__EXPERIMENTAL, $getNodeByKey, isCurrentlyReadOnlyMode, $setSelection, SELECTION_CHANGE_COMMAND, $getNearestNodeFromDOMNode, $createRangeSelection, $isParagraphNode, $getRoot, KEY_ARROW_DOWN_COMMAND, COMMAND_PRIORITY_HIGH, KEY_ARROW_UP_COMMAND, KEY_ARROW_LEFT_COMMAND, KEY_ARROW_RIGHT_COMMAND, KEY_ESCAPE_COMMAND, DELETE_WORD_COMMAND, DELETE_LINE_COMMAND, DELETE_CHARACTER_COMMAND, COMMAND_PRIORITY_CRITICAL, KEY_BACKSPACE_COMMAND, KEY_DELETE_COMMAND, CUT_COMMAND, FORMAT_TEXT_COMMAND, FORMAT_ELEMENT_COMMAND, CONTROLLED_TEXT_INSERTION_COMMAND, KEY_TAB_COMMAND, FOCUS_COMMAND, SELECTION_INSERT_CLIPBOARD_NODES_COMMAND, $getPreviousSelection, $createRangeSelectionFromDom, INSERT_PARAGRAPH_COMMAND, $isRootOrShadowRoot, $isDecoratorNode } from 'lexical';
11
11
  import { copyToClipboard, $getClipboardDataFromSelection } from '@lexical/clipboard';
12
12
 
13
13
  /**
@@ -1583,12 +1583,13 @@ class TableObserver {
1583
1583
  const formatSelection = $createRangeSelection();
1584
1584
  const anchor = formatSelection.anchor;
1585
1585
  const focus = formatSelection.focus;
1586
- selection.getNodes().forEach(cellNode => {
1587
- if ($isTableCellNode(cellNode) && cellNode.getTextContentSize() !== 0) {
1588
- anchor.set(cellNode.getKey(), 0, 'element');
1589
- focus.set(cellNode.getKey(), cellNode.getChildrenSize(), 'element');
1590
- formatSelection.formatText(type);
1591
- }
1586
+ const cellNodes = selection.getNodes().filter($isTableCellNode);
1587
+ const paragraph = cellNodes[0].getFirstChild();
1588
+ const alignFormatWith = $isParagraphNode(paragraph) ? paragraph.getFormatFlags(type, null) : null;
1589
+ cellNodes.forEach(cellNode => {
1590
+ anchor.set(cellNode.getKey(), 0, 'element');
1591
+ focus.set(cellNode.getKey(), cellNode.getChildrenSize(), 'element');
1592
+ formatSelection.formatText(type, alignFormatWith);
1592
1593
  });
1593
1594
  $setSelection(selection);
1594
1595
  this.editor.dispatchCommand(SELECTION_CHANGE_COMMAND, undefined);
@@ -13,22 +13,22 @@ super.exportDOM(a));if(a){a.style.border="1px solid black";1<this.__colSpan&&(a.
13
13
  rowSpan:this.__rowSpan,type:"tablecell",width:this.getWidth()}}getColSpan(){return this.getLatest().__colSpan}setColSpan(a){let b=this.getWritable();b.__colSpan=a;return b}getRowSpan(){return this.getLatest().__rowSpan}setRowSpan(a){let b=this.getWritable();b.__rowSpan=a;return b}getTag(){return this.hasHeader()?"th":"td"}setHeaderStyles(a,b=x.BOTH){let c=this.getWritable();c.__headerState=a&b|c.__headerState&~b;return c}getHeaderStyles(){return this.getLatest().__headerState}setWidth(a){let b=this.getWritable();
14
14
  b.__width=a;return b}getWidth(){return this.getLatest().__width}getBackgroundColor(){return this.getLatest().__backgroundColor}setBackgroundColor(a){let b=this.getWritable();b.__backgroundColor=a;return b}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||
15
15
  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}}
16
- 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:n=>{0===n.length&&n.push(w.$createParagraphNode());return n},forChild:(n,q)=>{if(C(q)&&
17
- !w.$isElementNode(n)){q=w.$createParagraphNode();if(w.$isLineBreakNode(n)&&"\n"===n.getTextContent())return null;w.$isTextNode(n)&&(d&&n.toggleFormat("bold"),e&&n.toggleFormat("strikethrough"),f&&n.toggleFormat("italic"),g&&n.toggleFormat("underline"));q.append(n);return q}return n},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");
16
+ 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)&&
17
+ !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");
18
18
  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,
19
19
  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;
20
20
  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;
21
21
  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)}}
22
22
  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(207);null===f&&J(208);return[d,e,f]}
23
- function ma(a,b,c){function d(q){let p=e[q];void 0===p&&(e[q]=p=[]);return p}let e=[],f=null,g=null;a=a.getChildren();for(let q=0;q<a.length;q++){var n=a[q];I(n)||J(209);for(let p=n.getFirstChild(),u=0;null!=p;p=p.getNextSibling()){C(p)||J(147);for(n=d(q);void 0!==n[u];)u++;n={cell:p,startColumn:u,startRow:q};let {__rowSpan:k,__colSpan:l}=p;for(let m=0;m<k&&!(q+m>=a.length);m++){let t=d(q+m);for(let r=0;r<l;r++)t[u+r]=n}null!==b&&null===f&&b.is(p)&&(f=n);null!==c&&null===g&&c.is(p)&&(g=n)}}return[e,
23
+ 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(209);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,
24
24
  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(210);return[a,b,c]}
25
- 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 n=0;for(let q=0;q<g.length;q++){for(;f[e][n];)n++;let p=g[q],u=p.__rowSpan||1,k=p.__colSpan||1;for(let l=0;l<u;l++)for(let m=0;m<k;m++)f[e+l][n+m]=p;if(b===p)return{colSpan:k,columnIndex:n,rowIndex:e,rowSpan:u};n+=k}}return null}
25
+ 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}
26
26
  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;
27
27
  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,
28
- 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;p=Math.min(p,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();
29
- 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,n,q]=O(b,d,c),p=Math.min(n.startColumn,q.startColumn),u=Math.min(n.startRow,q.startRow),k=Math.max(n.startColumn+
30
- n.cell.__colSpan-1,q.startColumn+q.cell.__colSpan-1),l=Math.max(n.startRow+n.cell.__rowSpan-1,q.startRow+q.cell.__rowSpan-1);c=p;d=u;e=p;for(var m=u;p<c||u<d||k>e||l>m;){if(p<c){var t=m-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=m-d,e+=1,r=0;r<=t;r++)a(g[d+r][e]);if(l>m)for(t=e-c,m+=1,r=0;r<=t;r++)a(g[m][c+r])}b=new Map([[b.getKey(),b]]);c=null;for(d=u;d<=l;d++)for(e=p;e<=k;e++){({cell:m}=g[d][e]);t=m.getParent();I(t)||J(160);t!==c&&b.set(t.getKey(),
31
- t);b.set(m.getKey(),m);for(f of qa(m))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)}
28
+ 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();
29
+ 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+
30
+ 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(),
31
+ 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)}
32
32
  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}
33
33
  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");
34
34
  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");
@@ -37,9 +37,9 @@ b=R(b);S(a,b,null);w.$setSelection(null);a.dispatchCommand(w.SELECTION_CHANGE_CO
37
37
  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);
38
38
  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=
39
39
  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=
40
- !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;b.getNodes().forEach(f=>{C(f)&&0!==f.getTextContentSize()&&(d.set(f.getKey(),0,"element"),e.set(f.getKey(),f.getChildrenSize(),
41
- "element"),c.formatText(a))});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();
42
- 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(205);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}
40
+ !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(),
41
+ 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=
42
+ 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(205);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}
43
43
  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}
44
44
  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)})}
45
45
  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")})}
@@ -48,55 +48,55 @@ a.table.rows-1?b.getCellNodeFromCordsOrThrow(c,d+1,a.table).selectStart():b.sele
48
48
  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}
49
49
  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")}
50
50
  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}
51
- 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,p=>w.$isElementNode(p)&&!p.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=
52
- 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,p=>w.$isElementNode(p)&&!p.isInline());if(!d)return!1;d="down"===c?d.getNextSibling():
53
- 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:p,focus:u}=f;var g=h.$findMatchingParent(p.getNode(),C),n=h.$findMatchingParent(u.getNode(),C);if(!C(g)||!g.is(n))return!1;n=T(g);if(n!==d&&null!=n){var q=a.getElementByKey(n.getKey());
54
- if(null!=q)return e.table=R(q),Y(a,b,c,n,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&&w.$isDecoratorNode(f[0])?!1:Fa(e,a,g,c)?Ga(b,g,d,c):!1}f=a.getElementByKey(g.__key);n=a.getElementByKey(p.key);if(null==n||null==f)return!1;if("element"===p.type)f=n.getBoundingClientRect();else{f=window.getSelection();if(null===f||0===f.rangeCount)return!1;f=f.getRangeAt(0).getBoundingClientRect()}n="up"===c?g.getFirstChild():g.getLastChild();
55
- if(null==n)return!1;a=a.getElementByKey(n.__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:p,focus:u}=f;q=h.$findMatchingParent(p.getNode(),C);n=h.$findMatchingParent(u.getNode(),C);[g]=f.getNodes();a=
56
- a.getElementByKey(g.getKey());if(!C(q)||!C(n)||!M(g)||null==a)return!1;e.updateTableTableSelection(f);f=R(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(n,f),Da(e,g,d.x,d.y,c);n.selectEnd();return!0}return!1}function Z(a){a.preventDefault();a.stopImmediatePropagation();a.stopPropagation()}
51
+ 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=
52
+ 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():
53
+ 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());
54
+ 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();
55
+ 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=
56
+ 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()}
57
57
  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)}
58
58
  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())}
59
- 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 n=f[f.length-1][f[0].length-1],{startColumn:q,startRow:p}=g;if("backward"===d?q!==e.startColumn||p!==e.startRow:q!==n.startColumn||p!==n.startRow)return!1;b=Ia(b,d,c);if(!b||M(b))return!1;Z(a);"backward"===d?b.selectEnd():b.selectStart();return!0}
59
+ 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}
60
60
  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()}
61
- 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(),q=>C(q)))&&(a=h.$findMatchingParent(b,q=>M(q)),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:n}=f;if(g===c.startRow&&n===c.startColumn)return"first";if(g===b.startRow&&n===b.startColumn)return"last"}}
61
+ 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"}}
62
62
  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"))}
63
63
  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=
64
64
  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();
65
65
  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?
66
66
  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=
67
67
  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;
68
- exports.$createTableNodeWithDimensions=function(a,b,c=!0){let d=Oa();for(let f=0;f<a;f++){let g=F();for(let n=0;n<b;n++){var e=x.NO_STATUS;"object"===typeof c?(0===f&&c.rows&&(e|=x.ROW),0===n&&c.columns&&(e|=x.COLUMN)):c&&(0===f&&(e|=x.ROW),0===n&&(e|=x.COLUMN));e=B(e);let q=w.$createParagraphNode();q.append(w.$createTextNode());e.append(q);g.append(e)}d.append(g)}return d};exports.$createTableRowNode=F;exports.$createTableSelection=ra;
68
+ 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;
69
69
  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};
70
- 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:n,startColumn:q}=g;var p=Math.min(b,q);let u=Math.max(b+c.__colSpan-1,q+a.__colSpan-1),k=u-p+1;if(e[0].length===u-p+1)d.selectPrevious(),d.remove();else{var l=e.length;for(let m=0;m<l;m++)for(let t=p;t<=u;t++){let {cell:r,startColumn:v}=e[m][t];v<p?t===p&&r.setColSpan(r.__colSpan-
71
- Math.min(k,r.__colSpan-(p-v))):v+r.__colSpan-1>u?t===u&&r.setColSpan(r.__colSpan-(u-v+1)):r.remove()}p=e[n];a=b>q?p[b+c.__colSpan]:p[q+a.__colSpan];void 0!==a?({cell:b}=a,N(b)):({cell:b}=q<b?p[q-1]:p[b-1],N(b))}};
72
- 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:n}=g;a=n+a.__rowSpan-1;if(e.length===a-b+1)d.remove();else{n=e[0].length;var q=e[a+1],p=d.getChildAtIndex(a+1);for(let k=a;k>=b;k--){for(var u=n-1;0<=u;u--){let {cell:l,startRow:m,startColumn:t}=e[k][u];if(t===u&&(k===b&&m<b&&l.setRowSpan(l.__rowSpan-(m-b)),m>=b&&m+l.__rowSpan-
73
- 1>a))if(l.setRowSpan(l.__rowSpan-(a-m+1)),null===p&&J(122),0===u)la(p,l);else{let {cell:r}=q[u-1];r.insertAfter(l)}}u=d.getChildAtIndex(k);I(u)||J(206,String(k));u.remove()}void 0!==q?({cell:b}=q[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;
70
+ 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-
71
+ 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))}};
72
+ 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-
73
+ 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(206,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;
74
74
  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;
75
- exports.$insertTableColumn=function(a,b,c=!0,d,e){let f=a.getChildren(),g=[];for(let p=0;p<f.length;p++){let u=f[p];if(I(u))for(let k=0;k<d;k++){var n=u.getChildren();if(b>=n.length||0>b)throw Error("Table column target index out of range");n=n[b];C(n)||J(12);let {left:l,right:m}=ja(n,e);var q=x.NO_STATUS;if(l&&l.hasHeaderState(x.ROW)||m&&m.hasHeaderState(x.ROW))q|=x.ROW;q=B(q);q.append(w.$createParagraphNode());g.push({newTableCell:q,targetCell:n})}}g.forEach(({newTableCell:p,targetCell:u})=>{c?
76
- u.insertAfter(p):u.insertBefore(p)});return a};
77
- exports.$insertTableColumn__EXPERIMENTAL=function(a=!0){function b(k=x.NO_STATUS){k=B(k).append(w.$createParagraphNode());null===p&&(p=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,n,q]=O(f,e,d);d=g.length;c=a?Math.max(n.startColumn,q.startColumn):Math.min(n.startColumn,q.startColumn);a=a?c+e.__colSpan-1:c-1;c=f.getFirstChild();I(c)||J(120);let p=null;var u=c;a:for(c=0;c<d;c++){0!==c&&(u=u.getNextSibling(),
78
- 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:m,startColumn:t,startRow:r}=k[a];if(t+m.__colSpan-1<=a){let v=m,A=r,z=a;for(;A!==c&&1<v.__rowSpan;)if(z-=m.__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 m.setColSpan(m.__colSpan+1)}null!==p&&N(p)};
79
- 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 n=b.getChildren(),q=n.length,p=F();for(let u=0;u<q;u++){var g=n[u];C(g)||J(12);let {above:k,below:l}=ja(g,e);g=x.NO_STATUS;let m=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,m);g.append(w.$createParagraphNode());p.append(g)}c?b.insertAfter(p):b.insertBefore(p)}else throw Error("Row before insertion index does not exist.");
75
+ 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?
76
+ u.insertAfter(q):u.insertBefore(q)});return a};
77
+ 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(),
78
+ 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)};
79
+ 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.");
80
80
  return a};
81
- 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 n=e[a];g=F();for(var q=0;q<b;q++){let {cell:u,startRow:k}=n[q];if(k+u.__rowSpan-1<=a){var p=ka(n[q].cell.__headerState,x.COLUMN);g.append(B(p).append(w.$createParagraphNode()))}else u.setRowSpan(u.__rowSpan+1)}b=d.getChildAtIndex(a);I(b)||J(145);b.insertAfter(g)}else{n=e[g];
82
- a=F();for(q=0;q<b;q++){let {cell:u,startRow:k}=n[q];k===g?(p=ka(n[q].cell.__headerState,x.COLUMN),a.append(B(p).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};
83
- 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:n,startRow:q}=g,p=b.__headerState&x.COLUMN,u=Array.from({length:a},(v,A)=>{v=p;for(let z=0;0!==v&&z<f.length;z++)v&=f[z][A+n].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+q][z].cell.__headerState;return v});
84
- if(1<a){for(var m=1;m<a;m++)b.insertAfter(B(u[m]|l[0]).append(w.$createParagraphNode()));b.setColSpan(1)}if(1<e){let v;for(m=1;m<e;m++){var t=q+m;let A=f[t];v=(v||c).getNextSibling();I(v)||J(125);var r=null;for(let z=0;z<n;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[m]).append(w.$createParagraphNode()));else for(t=a-1;0<=t;t--)r.insertAfter(B(u[t]|l[m]).append(w.$createParagraphNode()))}b.setRowSpan(1)}}};
81
+ 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];
82
+ 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};
83
+ 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});
84
+ 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)}}};
85
85
  exports.INSERT_TABLE_COMMAND=da;exports.TableCellHeaderStates=x;exports.TableCellNode=y;exports.TableNode=Ma;exports.TableObserver=sa;exports.TableRowNode=E;
86
- 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()),n=c._window||window;ta(b,g);g.listenersToRemove.add(()=>{var k=g;ua(b)===k&&delete b.__lexicalTableSelection});let q=()=>{const k=()=>{g.isSelecting=!1;n.removeEventListener("mouseup",k);n.removeEventListener("mousemove",l)},l=m=>{setTimeout(()=>{if(1!==(m.buttons&
87
- 1)&&g.isSelecting)g.isSelecting=!1,n.removeEventListener("mouseup",k),n.removeEventListener("mousemove",l);else{var t=va(m.target);null===t||g.anchorX===t.x&&g.anchorY===t.y||(m.preventDefault(),g.setFocusCellForSelection(t))}},0)};return{onMouseMove:l,onMouseUp:k}};b.addEventListener("mousedown",k=>{setTimeout(()=>{if(0===k.button&&n){var l=va(k.target);null!==l&&(Z(k),g.setAnchorCellForSelection(l));var {onMouseUp:m,onMouseMove:t}=q();g.isSelecting=!0;n.addEventListener("mouseup",m,g.listenerOptions);
88
- n.addEventListener("mousemove",t,g.listenerOptions)}},0)},g.listenerOptions);n.addEventListener("mousedown",k=>{0===k.button&&c.update(()=>{const l=w.$getSelection(),m=k.target;Q(l)&&l.tableKey===g.tableNodeKey&&f.contains(m)&&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,
89
- 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 p=k=>()=>{var l=w.$getSelection();if(!U(l,a))return!1;if(Q(l))return g.clearText(),!0;if(w.$isRangeSelection(l)){var m=
90
- h.$findMatchingParent(l.anchor.getNode(),r=>C(r));if(!C(m))return!1;var t=l.anchor.getNode();m=l.focus.getNode();t=a.isParentOf(t);m=a.isParentOf(m);if(t&&!m||m&&!t)return g.clearText(),!0;m=(l=h.$findMatchingParent(l.anchor.getNode(),r=>w.$isElementNode(r)))&&h.$findMatchingParent(l,r=>w.$isElementNode(r)&&C(r.getParent()));if(!w.$isElementNode(m)||!w.$isElementNode(l))return!1;if(k===w.DELETE_LINE_COMMAND&&null===m.getPreviousSibling())return!0}return!1};[w.DELETE_WORD_COMMAND,w.DELETE_LINE_COMMAND,
91
- w.DELETE_CHARACTER_COMMAND].forEach(k=>{g.listenersToRemove.add(c.registerCommand(k,p(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(m=>M(m)&&m.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(),m=>C(m)),C(k));return!1};g.listenersToRemove.add(c.registerCommand(w.KEY_BACKSPACE_COMMAND,
86
+ 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&
87
+ 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);
88
+ 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,
89
+ 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=
90
+ 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,
91
+ 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,
92
92
  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,
93
- 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(),m=>C(m)),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 m=l.anchor.getNode();l=l.focus.getNode();if(!C(m)||!C(l))return!1;let [t,r,v]=O(a,m,l);m=Math.max(r.startRow,v.startRow);l=Math.max(r.startColumn,v.startColumn);var A=Math.min(r.startRow,
94
- v.startRow);let z=Math.min(r.startColumn,v.startColumn);for(;A<=m;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 m=h.$findMatchingParent(l.anchor.getNode(),
95
- t=>C(t));if(!C(m))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,
96
- ()=>a.isSelected(),w.COMMAND_PRIORITY_HIGH));g.listenersToRemove.add(c.registerCommand(w.SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,k=>{let {nodes:l,selection:m}=k;k=m.getStartEndPoints();var t=Q(m);t=w.$isRangeSelection(m)&&null!==h.$findMatchingParent(m.anchor.getNode(),H=>C(H))&&null!==h.$findMatchingParent(m.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(),
93
+ 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,
94
+ 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(),
95
+ 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,
96
+ ()=>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(),
97
97
  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;
98
- 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 m=A.getNode(),t=z.getNode(),r=X(m),v=X(t);let D=!(!r||!a.is(T(r))),G=!(!v||!a.is(T(v)));m=D!==
99
- G;let L=D&&G;t=k.isBackward();m?(m=k.clone(),G?([v]=O(a,v,v),r=v[0][0].cell,v=v[v.length-1].at(-1).cell,m.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,m.anchor.set(t?v.getKey():r.getKey(),t?v.getChildrenSize():0,"element")),w.$setSelection(m),za(c,g)):L&&!r.is(v)&&(g.setAnchorCellForSelection(e(r)),g.setFocusCellForSelection(e(v),!0),g.isSelecting||setTimeout(()=>{let {onMouseUp:H,onMouseMove:V}=
100
- q();g.isSelecting=!0;n.addEventListener("mouseup",H);n.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&&(m=(m=w.$getNearestNodeFromDOMNode(t.focusNode))&&!a.is(T(m)),r=(r=w.$getNearestNodeFromDOMNode(t.anchorNode))&&a.is(T(r)),m&&r&&0<t.rangeCount&&(m=w.$createRangeSelectionFromDom(t,c)))&&(m.anchor.set(a.getKey(),k.isBackward()?a.getChildrenSize():0,"element"),t.removeAllRanges(),w.$setSelection(m));
98
+ 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!==
99
+ 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}=
100
+ 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));
101
101
  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)&&
102
102
  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
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- import{addClassNamesToElement as e,$findMatchingParent as t,removeClassNamesFromElement as n,objectKlassEquals as o,isHTMLElement as r}from"@lexical/utils";import{ElementNode as l,$createParagraphNode as s,$isElementNode as i,$isLineBreakNode as a,$isTextNode as c,$applyNodeReplacement as u,createCommand as d,$createTextNode as h,$getSelection as g,$isRangeSelection as f,$createPoint as m,$normalizeSelection__EXPERIMENTAL as p,$getNodeByKey as S,isCurrentlyReadOnlyMode as _,$setSelection as C,SELECTION_CHANGE_COMMAND as w,$getNearestNodeFromDOMNode as b,$createRangeSelection as y,$getRoot as N,KEY_ARROW_DOWN_COMMAND as x,COMMAND_PRIORITY_HIGH as T,KEY_ARROW_UP_COMMAND as v,KEY_ARROW_LEFT_COMMAND as O,KEY_ARROW_RIGHT_COMMAND as E,KEY_ESCAPE_COMMAND as R,DELETE_WORD_COMMAND as M,DELETE_LINE_COMMAND as K,DELETE_CHARACTER_COMMAND as F,COMMAND_PRIORITY_CRITICAL as k,KEY_BACKSPACE_COMMAND as A,KEY_DELETE_COMMAND as H,CUT_COMMAND as B,FORMAT_TEXT_COMMAND as D,FORMAT_ELEMENT_COMMAND as P,CONTROLLED_TEXT_INSERTION_COMMAND as L,KEY_TAB_COMMAND as I,FOCUS_COMMAND as W,SELECTION_INSERT_CLIPBOARD_NODES_COMMAND as U,$getPreviousSelection as z,$createRangeSelectionFromDom as Y,INSERT_PARAGRAPH_COMMAND as X,$isRootOrShadowRoot as J,$isDecoratorNode as $}from"lexical";import{copyToClipboard as j,$getClipboardDataFromSelection as q}from"@lexical/clipboard";const G=/^(\d+(?:\.\d+)?)px$/,Q={BOTH:3,COLUMN:2,NO_STATUS:0,ROW:1};class V extends l{static getType(){return"tablecell"}static clone(e){return new V(e.__headerState,e.__colSpan,e.__width,e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__rowSpan=e.__rowSpan,this.__backgroundColor=e.__backgroundColor}static importDOM(){return{td:e=>({conversion:Z,priority:0}),th:e=>({conversion:Z,priority:0})}}static importJSON(e){const t=e.colSpan||1,n=e.rowSpan||1;return ee(e.headerState,t,e.width||void 0).setRowSpan(n).setBackgroundColor(e.backgroundColor||null)}constructor(e=Q.NO_STATUS,t=1,n,o){super(o),this.__colSpan=t,this.__rowSpan=1,this.__headerState=e,this.__width=n,this.__backgroundColor=null}createDOM(t){const n=document.createElement(this.getTag());return this.__width&&(n.style.width=`${this.__width}px`),this.__colSpan>1&&(n.colSpan=this.__colSpan),this.__rowSpan>1&&(n.rowSpan=this.__rowSpan),null!==this.__backgroundColor&&(n.style.backgroundColor=this.__backgroundColor),e(n,t.theme.tableCell,this.hasHeader()&&t.theme.tableCellHeader),n}exportDOM(e){const{element:t}=super.exportDOM(e);if(t){const e=t;e.style.border="1px solid black",this.__colSpan>1&&(e.colSpan=this.__colSpan),this.__rowSpan>1&&(e.rowSpan=this.__rowSpan),e.style.width=`${this.getWidth()||75}px`,e.style.verticalAlign="top",e.style.textAlign="start";const n=this.getBackgroundColor();null!==n?e.style.backgroundColor=n:this.hasHeader()&&(e.style.backgroundColor="#f2f3f5")}return{element:t}}exportJSON(){return{...super.exportJSON(),backgroundColor:this.getBackgroundColor(),colSpan:this.__colSpan,headerState:this.__headerState,rowSpan:this.__rowSpan,type:"tablecell",width:this.getWidth()}}getColSpan(){return this.getLatest().__colSpan}setColSpan(e){const t=this.getWritable();return t.__colSpan=e,t}getRowSpan(){return this.getLatest().__rowSpan}setRowSpan(e){const t=this.getWritable();return t.__rowSpan=e,t}getTag(){return this.hasHeader()?"th":"td"}setHeaderStyles(e,t=Q.BOTH){const n=this.getWritable();return n.__headerState=e&t|n.__headerState&~t,n}getHeaderStyles(){return this.getLatest().__headerState}setWidth(e){const t=this.getWritable();return t.__width=e,t}getWidth(){return this.getLatest().__width}getBackgroundColor(){return this.getLatest().__backgroundColor}setBackgroundColor(e){const t=this.getWritable();return t.__backgroundColor=e,t}toggleHeaderStyle(e){const t=this.getWritable();return(t.__headerState&e)===e?t.__headerState-=e:t.__headerState+=e,t}hasHeaderState(e){return(this.getHeaderStyles()&e)===e}hasHeader(){return this.getLatest().__headerState!==Q.NO_STATUS}updateDOM(e){return e.__headerState!==this.__headerState||e.__width!==this.__width||e.__colSpan!==this.__colSpan||e.__rowSpan!==this.__rowSpan||e.__backgroundColor!==this.__backgroundColor}isShadowRoot(){return!0}collapseAtStart(){return!0}canBeEmpty(){return!1}canIndent(){return!1}}function Z(e){const t=e,n=e.nodeName.toLowerCase();let o;G.test(t.style.width)&&(o=parseFloat(t.style.width));const r=ee("th"===n?Q.ROW:Q.NO_STATUS,t.colSpan,o);r.__rowSpan=t.rowSpan;const l=t.style.backgroundColor;""!==l&&(r.__backgroundColor=l);const u=t.style,d=u.textDecoration.split(" "),h="700"===u.fontWeight||"bold"===u.fontWeight,g=d.includes("line-through"),f="italic"===u.fontStyle,m=d.includes("underline");return{after:e=>(0===e.length&&e.push(s()),e),forChild:(e,t)=>{if(te(t)&&!i(e)){const t=s();return a(e)&&"\n"===e.getTextContent()?null:(c(e)&&(h&&e.toggleFormat("bold"),g&&e.toggleFormat("strikethrough"),f&&e.toggleFormat("italic"),m&&e.toggleFormat("underline")),t.append(e),t)}return e},node:r}}function ee(e,t=1,n){return u(new V(e,t,n))}function te(e){return e instanceof V}const ne=d("INSERT_TABLE_COMMAND");class oe extends l{static getType(){return"tablerow"}static clone(e){return new oe(e.__height,e.__key)}static importDOM(){return{tr:e=>({conversion:re,priority:0})}}static importJSON(e){return le(e.height)}constructor(e,t){super(t),this.__height=e}exportJSON(){return{...super.exportJSON(),...this.getHeight()&&{height:this.getHeight()},type:"tablerow",version:1}}createDOM(t){const n=document.createElement("tr");return this.__height&&(n.style.height=`${this.__height}px`),e(n,t.theme.tableRow),n}isShadowRoot(){return!0}setHeight(e){return this.getWritable().__height=e,this.__height}getHeight(){return this.getLatest().__height}updateDOM(e){return e.__height!==this.__height}canBeEmpty(){return!1}canIndent(){return!1}}function re(e){const t=e;let n;return G.test(t.style.height)&&(n=parseFloat(t.style.height)),{node:le(n)}}function le(e){return u(new oe(e))}function se(e){return e instanceof oe}function ie(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ae=ie((function(e){const t=new URLSearchParams;t.append("code",e);for(let e=1;e<arguments.length;e++)t.append("v",arguments[e]);throw Error(`Minified Lexical error #${e}; visit https://lexical.dev/docs/error?${t} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}));const ce="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement;function ue(e,t,n=!0){const o=ut();for(let r=0;r<e;r++){const e=le();for(let o=0;o<t;o++){let t=Q.NO_STATUS;"object"==typeof n?(0===r&&n.rows&&(t|=Q.ROW),0===o&&n.columns&&(t|=Q.COLUMN)):n&&(0===r&&(t|=Q.ROW),0===o&&(t|=Q.COLUMN));const l=ee(t),i=s();i.append(h()),l.append(i),e.append(l)}o.append(e)}return o}function de(e){const n=t(e,(e=>te(e)));return te(n)?n:null}function he(e){const n=t(e,(e=>se(e)));if(se(n))return n;throw new Error("Expected table cell to be inside of table row.")}function ge(e){const n=t(e,(e=>dt(e)));if(dt(n))return n;throw new Error("Expected table cell to be inside of table.")}function fe(e){const t=he(e);return ge(t).getChildren().findIndex((e=>e.is(t)))}function me(e){return he(e).getChildren().findIndex((t=>t.is(e)))}function pe(e,t){const n=ge(e),{x:o,y:r}=n.getCordsFromCellNode(e,t);return{above:n.getCellNodeFromCords(o,r-1,t),below:n.getCellNodeFromCords(o,r+1,t),left:n.getCellNodeFromCords(o-1,r,t),right:n.getCellNodeFromCords(o+1,r,t)}}function Se(e,t){const n=e.getChildren();if(t>=n.length||t<0)throw new Error("Expected table cell to be inside of table row.");return n[t].remove(),e}function _e(e,t,n=!0,o,r){const l=e.getChildren();if(t>=l.length||t<0)throw new Error("Table row target index out of range");const i=l[t];if(!se(i))throw new Error("Row before insertion index does not exist.");for(let e=0;e<o;e++){const e=i.getChildren(),t=e.length,o=le();for(let n=0;n<t;n++){const t=e[n];te(t)||ae(12);const{above:l,below:i}=pe(t,r);let a=Q.NO_STATUS;const c=l&&l.getWidth()||i&&i.getWidth()||void 0;(l&&l.hasHeaderState(Q.COLUMN)||i&&i.hasHeaderState(Q.COLUMN))&&(a|=Q.COLUMN);const u=ee(a,1,c);u.append(s()),o.append(u)}n?i.insertAfter(o):i.insertBefore(o)}return e}const Ce=(e,t)=>e===Q.BOTH||e===t?t:Q.NO_STATUS;function we(e=!0){const t=g();f(t)||Ae(t)||ae(188);const n=t.focus.getNode(),[o,,r]=Ke(n),[l,i]=Re(r,o,o),a=l[0].length,{startRow:c}=i;if(e){const e=c+o.__rowSpan-1,t=l[e],n=le();for(let o=0;o<a;o++){const{cell:r,startRow:l}=t[o];if(l+r.__rowSpan-1<=e){const e=t[o].cell.__headerState,r=Ce(e,Q.COLUMN);n.append(ee(r).append(s()))}else r.setRowSpan(r.__rowSpan+1)}const i=r.getChildAtIndex(e);se(i)||ae(145),i.insertAfter(n)}else{const e=l[c],t=le();for(let n=0;n<a;n++){const{cell:o,startRow:r}=e[n];if(r===c){const o=e[n].cell.__headerState,r=Ce(o,Q.COLUMN);t.append(ee(r).append(s()))}else o.setRowSpan(o.__rowSpan+1)}const n=r.getChildAtIndex(c);se(n)||ae(145),n.insertBefore(t)}}function be(e,t,n=!0,o,r){const l=e.getChildren(),i=[];for(let e=0;e<l.length;e++){const n=l[e];if(se(n))for(let e=0;e<o;e++){const e=n.getChildren();if(t>=e.length||t<0)throw new Error("Table column target index out of range");const o=e[t];te(o)||ae(12);const{left:l,right:a}=pe(o,r);let c=Q.NO_STATUS;(l&&l.hasHeaderState(Q.ROW)||a&&a.hasHeaderState(Q.ROW))&&(c|=Q.ROW);const u=ee(c);u.append(s()),i.push({newTableCell:u,targetCell:o})}}return i.forEach((({newTableCell:e,targetCell:t})=>{n?t.insertAfter(e):t.insertBefore(e)})),e}function ye(e=!0){const t=g();f(t)||Ae(t)||ae(188);const n=t.anchor.getNode(),o=t.focus.getNode(),[r]=Ke(n),[l,,i]=Ke(o),[a,c,u]=Re(i,l,r),d=a.length,h=e?Math.max(c.startColumn,u.startColumn):Math.min(c.startColumn,u.startColumn),m=e?h+l.__colSpan-1:h-1,p=i.getFirstChild();se(p)||ae(120);let S=null;function _(e=Q.NO_STATUS){const t=ee(e).append(s());return null===S&&(S=t),t}let C=p;e:for(let e=0;e<d;e++){if(0!==e){const e=C.getNextSibling();se(e)||ae(121),C=e}const t=a[e],n=t[m<0?0:m].cell.__headerState,o=Ce(n,Q.ROW);if(m<0){Oe(C,_(o));continue}const{cell:r,startColumn:l,startRow:s}=t[m];if(l+r.__colSpan-1<=m){let n=r,l=s,i=m;for(;l!==e&&n.__rowSpan>1;){if(i-=r.__colSpan,!(i>=0)){C.append(_(o));continue e}{const{cell:e,startRow:o}=t[i];n=e,l=o}}n.insertAfter(_(o))}else r.setColSpan(r.__colSpan+1)}null!==S&&ve(S)}function Ne(e,t){const n=e.getChildren();for(let e=0;e<n.length;e++){const o=n[e];if(se(o)){const e=o.getChildren();if(t>=e.length||t<0)throw new Error("Table column target index out of range");e[t].remove()}}return e}function xe(){const e=g();f(e)||Ae(e)||ae(188);const t=e.anchor.getNode(),n=e.focus.getNode(),[o,,r]=Ke(t),[l]=Ke(n),[s,i,a]=Re(r,o,l),{startRow:c}=i,{startRow:u}=a,d=u+l.__rowSpan-1;if(s.length===d-c+1)return void r.remove();const h=s[0].length,m=s[d+1],p=r.getChildAtIndex(d+1);for(let e=d;e>=c;e--){for(let t=h-1;t>=0;t--){const{cell:n,startRow:o,startColumn:r}=s[e][t];if(r===t&&(e===c&&o<c&&n.setRowSpan(n.__rowSpan-(o-c)),o>=c&&o+n.__rowSpan-1>d))if(n.setRowSpan(n.__rowSpan-(d-o+1)),null===p&&ae(122),0===t)Oe(p,n);else{const{cell:e}=m[t-1];e.insertAfter(n)}}const t=r.getChildAtIndex(e);se(t)||ae(206,String(e)),t.remove()}if(void 0!==m){const{cell:e}=m[0];ve(e)}else{const e=s[c-1],{cell:t}=e[0];ve(t)}}function Te(){const e=g();f(e)||Ae(e)||ae(188);const t=e.anchor.getNode(),n=e.focus.getNode(),[o,,r]=Ke(t),[l]=Ke(n),[s,i,a]=Re(r,o,l),{startColumn:c}=i,{startRow:u,startColumn:d}=a,h=Math.min(c,d),m=Math.max(c+o.__colSpan-1,d+l.__colSpan-1),p=m-h+1;if(s[0].length===m-h+1)return r.selectPrevious(),void r.remove();const S=s.length;for(let e=0;e<S;e++)for(let t=h;t<=m;t++){const{cell:n,startColumn:o}=s[e][t];if(o<h){if(t===h){const e=h-o;n.setColSpan(n.__colSpan-Math.min(p,n.__colSpan-e))}}else if(o+n.__colSpan-1>m){if(t===m){const e=m-o+1;n.setColSpan(n.__colSpan-e)}}else n.remove()}const _=s[u],C=c>d?_[c+o.__colSpan]:_[d+l.__colSpan];if(void 0!==C){const{cell:e}=C;ve(e)}else{const e=d<c?_[d-1]:_[c-1],{cell:t}=e;ve(t)}}function ve(e){const t=e.getFirstDescendant();null==t?e.selectStart():t.getParentOrThrow().selectStart()}function Oe(e,t){const n=e.getFirstChild();null!==n?n.insertBefore(t):e.append(t)}function Ee(){const e=g();f(e)||Ae(e)||ae(188);const t=e.anchor.getNode(),[n,o,r]=Ke(t),l=n.__colSpan,i=n.__rowSpan;if(1===l&&1===i)return;const[a,c]=Re(r,n,n),{startColumn:u,startRow:d}=c,h=n.__headerState&Q.COLUMN,m=Array.from({length:l},((e,t)=>{let n=h;for(let e=0;0!==n&&e<a.length;e++)n&=a[e][t+u].cell.__headerState;return n})),p=n.__headerState&Q.ROW,S=Array.from({length:i},((e,t)=>{let n=p;for(let e=0;0!==n&&e<a[0].length;e++)n&=a[t+d][e].cell.__headerState;return n}));if(l>1){for(let e=1;e<l;e++)n.insertAfter(ee(m[e]|S[0]).append(s()));n.setColSpan(1)}if(i>1){let e;for(let t=1;t<i;t++){const n=d+t,r=a[n];e=(e||o).getNextSibling(),se(e)||ae(125);let i=null;for(let e=0;e<u;e++){const t=r[e],o=t.cell;t.startRow===n&&(i=o),o.__colSpan>1&&(e+=o.__colSpan-1)}if(null===i)for(let n=l-1;n>=0;n--)Oe(e,ee(m[n]|S[t]).append(s()));else for(let e=l-1;e>=0;e--)i.insertAfter(ee(m[e]|S[t]).append(s()))}n.setRowSpan(1)}}function Re(e,t,n){const[o,r,l]=Me(e,t,n);return null===r&&ae(207),null===l&&ae(208),[o,r,l]}function Me(e,t,n){const o=[];let r=null,l=null;function s(e){let t=o[e];return void 0===t&&(o[e]=t=[]),t}const i=e.getChildren();for(let e=0;e<i.length;e++){const o=i[e];se(o)||ae(209);for(let a=o.getFirstChild(),c=0;null!=a;a=a.getNextSibling()){te(a)||ae(147);const o=s(e);for(;void 0!==o[c];)c++;const u={cell:a,startColumn:c,startRow:e},{__rowSpan:d,__colSpan:h}=a;for(let t=0;t<d&&!(e+t>=i.length);t++){const n=s(e+t);for(let e=0;e<h;e++)n[c+e]=u}null!==t&&null===r&&t.is(a)&&(r=u),null!==n&&null===l&&n.is(a)&&(l=u)}}return[o,r,l]}function Ke(e){let n;if(e instanceof V)n=e;else if("__type"in e){const o=t(e,te);te(o)||ae(148),n=o}else{const o=t(e.getNode(),te);te(o)||ae(148),n=o}const o=n.getParent();se(o)||ae(149);const r=o.getParent();return dt(r)||ae(210),[n,o,r]}function Fe(e){const[t,,n]=Ke(e),o=n.getChildren(),r=o.length,l=o[0].getChildren().length,s=new Array(r);for(let e=0;e<r;e++)s[e]=new Array(l);for(let e=0;e<r;e++){const n=o[e].getChildren();let r=0;for(let o=0;o<n.length;o++){for(;s[e][r];)r++;const l=n[o],i=l.__rowSpan||1,a=l.__colSpan||1;for(let t=0;t<i;t++)for(let n=0;n<a;n++)s[e+t][r+n]=l;if(t===l)return{colSpan:a,columnIndex:r,rowIndex:e,rowSpan:i};r+=a}}return null}class ke{constructor(e,t,n){this.anchor=t,this.focus=n,t._selection=this,n._selection=this,this._cachedNodes=null,this.dirty=!1,this.tableKey=e}getStartEndPoints(){return[this.anchor,this.focus]}isBackward(){return this.focus.isBefore(this.anchor)}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e}is(e){return!!Ae(e)&&(this.tableKey===e.tableKey&&this.anchor.is(e.anchor)&&this.focus.is(e.focus))}set(e,t,n){this.dirty=!0,this.tableKey=e,this.anchor.key=t,this.focus.key=n,this._cachedNodes=null}clone(){return new ke(this.tableKey,this.anchor,this.focus)}isCollapsed(){return!1}extract(){return this.getNodes()}insertRawText(e){}insertText(){}insertNodes(e){const t=this.focus.getNode();i(t)||ae(151);p(t.select(0,t.getChildrenSize())).insertNodes(e)}getShape(){const e=S(this.anchor.key);te(e)||ae(152);const t=Fe(e);null===t&&ae(153);const n=S(this.focus.key);te(n)||ae(154);const o=Fe(n);null===o&&ae(155);const r=Math.min(t.columnIndex,o.columnIndex),l=Math.max(t.columnIndex+t.colSpan-1,o.columnIndex+o.colSpan-1),s=Math.min(t.rowIndex,o.rowIndex),i=Math.max(t.rowIndex+t.rowSpan-1,o.rowIndex+o.rowSpan-1);return{fromX:Math.min(r,l),fromY:Math.min(s,i),toX:Math.max(r,l),toY:Math.max(s,i)}}getNodes(){const e=this._cachedNodes;if(null!==e)return e;const n=this.anchor.getNode(),o=this.focus.getNode(),r=t(n,te),l=t(o,te);te(r)||ae(152),te(l)||ae(154);const s=r.getParent();se(s)||ae(156);const i=s.getParent();dt(i)||ae(157);const a=l.getParents()[1];if(a!==i){if(i.isParentOf(l)){const e=a.getParent();null==e&&ae(159),this.set(this.tableKey,l.getKey(),e.getKey())}else{const e=i.getParent();null==e&&ae(158),this.set(this.tableKey,e.getKey(),l.getKey())}return this.getNodes()}const[c,u,d]=Re(i,r,l);let h=Math.min(u.startColumn,d.startColumn),g=Math.min(u.startRow,d.startRow),f=Math.max(u.startColumn+u.cell.__colSpan-1,d.startColumn+d.cell.__colSpan-1),m=Math.max(u.startRow+u.cell.__rowSpan-1,d.startRow+d.cell.__rowSpan-1),p=h,S=g,C=h,w=g;function b(e){const{cell:t,startColumn:n,startRow:o}=e;h=Math.min(h,n),g=Math.min(g,o),f=Math.max(f,n+t.__colSpan-1),m=Math.max(m,o+t.__rowSpan-1)}for(;h<p||g<S||f>C||m>w;){if(h<p){const e=w-S,t=p-1;for(let n=0;n<=e;n++)b(c[S+n][t]);p=t}if(g<S){const e=C-p,t=S-1;for(let n=0;n<=e;n++)b(c[t][p+n]);S=t}if(f>C){const e=w-S,t=C+1;for(let n=0;n<=e;n++)b(c[S+n][t]);C=t}if(m>w){const e=C-p,t=w+1;for(let n=0;n<=e;n++)b(c[t][p+n]);w=t}}const y=new Map([[i.getKey(),i]]);let N=null;for(let e=g;e<=m;e++)for(let t=h;t<=f;t++){const{cell:n}=c[e][t],o=n.getParent();se(o)||ae(160),o!==N&&y.set(o.getKey(),o),y.set(n.getKey(),n);for(const e of Be(n))y.set(e.getKey(),e);N=o}const x=Array.from(y.values());return _()||(this._cachedNodes=x),x}getTextContent(){const e=this.getNodes().filter((e=>te(e)));let t="";for(let n=0;n<e.length;n++){const o=e[n],r=o.__parent,l=(e[n+1]||{}).__parent;t+=o.getTextContent()+(l!==r?"\n":"\t")}return t}}function Ae(e){return e instanceof ke}function He(){const e=m("root",0,"element"),t=m("root",0,"element");return new ke("root",e,t)}function Be(e){const t=[],n=[e];for(;n.length>0;){const o=n.pop();void 0===o&&ae(112),i(o)&&n.unshift(...o.getChildren()),o!==e&&t.push(o)}return t}class De{constructor(e,t){this.isHighlightingCells=!1,this.anchorX=-1,this.anchorY=-1,this.focusX=-1,this.focusY=-1,this.listenersToRemove=new Set,this.tableNodeKey=t,this.editor=e,this.table={columns:0,domRows:[],rows:0},this.tableSelection=null,this.anchorCellNodeKey=null,this.focusCellNodeKey=null,this.anchorCell=null,this.focusCell=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"),Array.from(this.listenersToRemove).forEach((e=>e())),this.listenersToRemove.clear()}trackTable(){const e=new MutationObserver((e=>{this.editor.update((()=>{let t=!1;for(let n=0;n<e.length;n++){const o=e[n].target.nodeName;if("TABLE"===o||"TBODY"===o||"THEAD"===o||"TR"===o){t=!0;break}}if(!t)return;const n=this.editor.getElementByKey(this.tableNodeKey);if(!n)throw new Error("Expected to find TableElement in DOM");this.table=ze(n)}))}));this.editor.update((()=>{const t=this.editor.getElementByKey(this.tableNodeKey);if(!t)throw new Error("Expected to find TableElement in DOM");this.table=ze(t),e.observe(t,{attributes:!0,childList:!0,subtree:!0})}))}clearHighlight(){const e=this.editor;this.isHighlightingCells=!1,this.anchorX=-1,this.anchorY=-1,this.focusX=-1,this.focusY=-1,this.tableSelection=null,this.anchorCellNodeKey=null,this.focusCellNodeKey=null,this.anchorCell=null,this.focusCell=null,this.hasHijackedSelectionStyles=!1,this.enableHighlightStyle(),e.update((()=>{if(!dt(S(this.tableNodeKey)))throw new Error("Expected TableNode.");const t=e.getElementByKey(this.tableNodeKey);if(!t)throw new Error("Expected to find TableElement in DOM");const n=ze(t);Ye(e,n,null),C(null),e.dispatchCommand(w,void 0)}))}enableHighlightStyle(){const e=this.editor;e.update((()=>{const t=e.getElementByKey(this.tableNodeKey);if(!t)throw new Error("Expected to find TableElement in DOM");n(t,e._config.theme.tableSelection),t.classList.remove("disable-selection"),this.hasHijackedSelectionStyles=!1}))}disableHighlightStyle(){const t=this.editor;t.update((()=>{const n=t.getElementByKey(this.tableNodeKey);if(!n)throw new Error("Expected to find TableElement in DOM");e(n,t._config.theme.tableSelection),this.hasHijackedSelectionStyles=!0}))}updateTableTableSelection(e){if(null!==e&&e.tableKey===this.tableNodeKey){const t=this.editor;this.tableSelection=e,this.isHighlightingCells=!0,this.disableHighlightStyle(),Ye(t,this.table,this.tableSelection)}else null==e?this.clearHighlight():(this.tableNodeKey=e.tableKey,this.updateTableTableSelection(e))}setFocusCellForSelection(e,t=!1){const n=this.editor;n.update((()=>{const o=S(this.tableNodeKey);if(!dt(o))throw new Error("Expected TableNode.");if(!n.getElementByKey(this.tableNodeKey))throw new Error("Expected to find TableElement in DOM");const r=e.x,l=e.y;if(this.focusCell=e,null!==this.anchorCell){const e=Le(n._window);e&&e.setBaseAndExtent(this.anchorCell.elem,0,this.focusCell.elem,0)}if(this.isHighlightingCells||this.anchorX===r&&this.anchorY===l&&!t){if(r===this.focusX&&l===this.focusY)return}else this.isHighlightingCells=!0,this.disableHighlightStyle();if(this.focusX=r,this.focusY=l,this.isHighlightingCells){const t=b(e.elem);if(null!=this.tableSelection&&null!=this.anchorCellNodeKey&&te(t)&&o.is(tt(t))){const e=t.getKey();this.tableSelection=this.tableSelection.clone()||He(),this.focusCellNodeKey=e,this.tableSelection.set(this.tableNodeKey,this.anchorCellNodeKey,this.focusCellNodeKey),C(this.tableSelection),n.dispatchCommand(w,void 0),Ye(n,this.table,this.tableSelection)}}}))}setAnchorCellForSelection(e){this.isHighlightingCells=!1,this.anchorCell=e,this.anchorX=e.x,this.anchorY=e.y,this.editor.update((()=>{const t=b(e.elem);if(te(t)){const e=t.getKey();this.tableSelection=null!=this.tableSelection?this.tableSelection.clone():He(),this.anchorCellNodeKey=e}}))}formatCells(e){this.editor.update((()=>{const t=g();Ae(t)||ae(11);const n=y(),o=n.anchor,r=n.focus;t.getNodes().forEach((t=>{te(t)&&0!==t.getTextContentSize()&&(o.set(t.getKey(),0,"element"),r.set(t.getKey(),t.getChildrenSize(),"element"),n.formatText(e))})),C(t),this.editor.dispatchCommand(w,void 0)}))}clearText(){const e=this.editor;e.update((()=>{const t=S(this.tableNodeKey);if(!dt(t))throw new Error("Expected TableNode.");const n=g();Ae(n)||ae(11);const o=n.getNodes().filter(te);if(o.length!==this.table.columns*this.table.rows)o.forEach((e=>{if(i(e)){const t=s(),n=h();t.append(n),e.append(t),e.getChildren().forEach((e=>{e!==t&&e.remove()}))}})),Ye(e,this.table,null),C(null),e.dispatchCommand(w,void 0);else{t.selectPrevious(),t.remove();N().selectStart()}}))}}const Pe="__lexicalTableSelection",Le=e=>ce?(e||window).getSelection():null;function Ie(e,n,r,l){const a=r.getRootElement();if(null===a)throw new Error("No root element.");const u=new De(r,e.getKey()),d=r._window||window;!function(e,t){null!==We(e)&&ae(205);e[Pe]=t}(n,u),u.listenersToRemove.add((()=>function(e,t){We(e)===t&&delete e[Pe]}(n,u)));const m=()=>{const e=()=>{u.isSelecting=!1,d.removeEventListener("mouseup",e),d.removeEventListener("mousemove",t)},t=n=>{setTimeout((()=>{if(1&~n.buttons&&u.isSelecting)return u.isSelecting=!1,d.removeEventListener("mouseup",e),void d.removeEventListener("mousemove",t);const o=Ue(n.target);null===o||u.anchorX===o.x&&u.anchorY===o.y||(n.preventDefault(),u.setFocusCellForSelection(o))}),0)};return{onMouseMove:t,onMouseUp:e}};n.addEventListener("mousedown",(e=>{setTimeout((()=>{if(0!==e.button)return;if(!d)return;const t=Ue(e.target);null!==t&&(ot(e),u.setAnchorCellForSelection(t));const{onMouseUp:n,onMouseMove:o}=m();u.isSelecting=!0,d.addEventListener("mouseup",n,u.listenerOptions),d.addEventListener("mousemove",o,u.listenerOptions)}),0)}),u.listenerOptions);d.addEventListener("mousedown",(e=>{0===e.button&&r.update((()=>{const t=g(),n=e.target;Ae(t)&&t.tableKey===u.tableNodeKey&&a.contains(n)&&u.clearHighlight()}))}),u.listenerOptions),u.listenersToRemove.add(r.registerCommand(x,(t=>nt(r,t,"down",e,u)),T)),u.listenersToRemove.add(r.registerCommand(v,(t=>nt(r,t,"up",e,u)),T)),u.listenersToRemove.add(r.registerCommand(O,(t=>nt(r,t,"backward",e,u)),T)),u.listenersToRemove.add(r.registerCommand(E,(t=>nt(r,t,"forward",e,u)),T)),u.listenersToRemove.add(r.registerCommand(R,(e=>{const n=g();if(Ae(n)){const o=t(n.focus.getNode(),te);if(te(o))return ot(e),o.selectEnd(),!0}return!1}),T));[M,K,F].forEach((n=>{u.listenersToRemove.add(r.registerCommand(n,(n=>()=>{const o=g();if(!qe(o,e))return!1;if(Ae(o))return u.clearText(),!0;if(f(o)){const r=t(o.anchor.getNode(),(e=>te(e)));if(!te(r))return!1;const l=o.anchor.getNode(),s=o.focus.getNode(),a=e.isParentOf(l),c=e.isParentOf(s);if(a&&!c||c&&!a)return u.clearText(),!0;const d=t(o.anchor.getNode(),(e=>i(e))),h=d&&t(d,(e=>i(e)&&te(e.getParent())));if(!i(h)||!i(d))return!1;if(n===K&&null===h.getPreviousSibling())return!0}return!1})(n),k))}));const p=n=>{const o=g();if(!qe(o,e)){const e=o?o.getNodes():null;if(e){const t=e.find((e=>dt(e)&&e.getKey()===u.tableNodeKey));if(dt(t)){if(!t.getParent())return!1;t.remove()}}return!1}if(Ae(o))return n&&(n.preventDefault(),n.stopPropagation()),u.clearText(),!0;if(f(o)){const e=t(o.anchor.getNode(),(e=>te(e)));if(!te(e))return!1}return!1};function S(t){const n=e.getCordsFromCellNode(t,u.table);return e.getDOMCellFromCordsOrThrow(n.x,n.y,u.table)}return u.listenersToRemove.add(r.registerCommand(A,p,k)),u.listenersToRemove.add(r.registerCommand(H,p,k)),u.listenersToRemove.add(r.registerCommand(B,(e=>{const t=g();if(t){if(!Ae(t)&&!f(t))return!1;j(r,o(e,ClipboardEvent)?e:null,q(t));const n=p(e);return f(t)?(t.removeText(),!0):n}return!1}),k)),u.listenersToRemove.add(r.registerCommand(D,(n=>{const o=g();if(!qe(o,e))return!1;if(Ae(o))return u.formatCells(n),!0;if(f(o)){const e=t(o.anchor.getNode(),(e=>te(e)));if(!te(e))return!1}return!1}),k)),u.listenersToRemove.add(r.registerCommand(P,(t=>{const n=g();if(!Ae(n)||!qe(n,e))return!1;const o=n.anchor.getNode(),r=n.focus.getNode();if(!te(o)||!te(r))return!1;const[l,s,a]=Re(e,o,r),c=Math.max(s.startRow,a.startRow),u=Math.max(s.startColumn,a.startColumn),d=Math.min(s.startRow,a.startRow),h=Math.min(s.startColumn,a.startColumn);for(let e=d;e<=c;e++)for(let n=h;n<=u;n++){const o=l[e][n].cell;o.setFormat(t);const r=o.getChildren();for(let e=0;e<r.length;e++){const n=r[e];i(n)&&!n.isInline()&&n.setFormat(t)}}return!0}),k)),u.listenersToRemove.add(r.registerCommand(L,(n=>{const o=g();if(!qe(o,e))return!1;if(Ae(o))return u.clearHighlight(),!1;if(f(o)){const l=t(o.anchor.getNode(),(e=>te(e)));if(!te(l))return!1;if("string"==typeof n){const t=lt(r,o,e);if(t)return rt(t,e,[h(n)]),!0}}return!1}),k)),l&&u.listenersToRemove.add(r.registerCommand(I,(t=>{const n=g();if(!f(n)||!n.isCollapsed()||!qe(n,e))return!1;const o=et(n.anchor.getNode());if(null===o)return!1;ot(t);const r=e.getCordsFromCellNode(o,u.table);return $e(u,e,r.x,r.y,t.shiftKey?"backward":"forward"),!0}),k)),u.listenersToRemove.add(r.registerCommand(W,(t=>e.isSelected()),T)),u.listenersToRemove.add(r.registerCommand(U,(e=>{const{nodes:n,selection:o}=e,r=o.getStartEndPoints(),l=Ae(o),i=f(o)&&null!==t(o.anchor.getNode(),(e=>te(e)))&&null!==t(o.focus.getNode(),(e=>te(e)))||l;if(1!==n.length||!dt(n[0])||!i||null===r)return!1;const[a]=r,u=n[0],d=u.getChildren(),h=u.getFirstChildOrThrow().getChildrenSize(),g=u.getChildrenSize(),m=t(a.getNode(),(e=>te(e))),p=m&&t(m,(e=>se(e))),S=p&&t(p,(e=>dt(e)));if(!te(m)||!se(p)||!dt(S))return!1;const _=p.getIndexWithinParent(),C=Math.min(S.getChildrenSize()-1,_+g-1),w=m.getIndexWithinParent(),b=Math.min(p.getChildrenSize()-1,w+h-1),y=Math.min(w,b),N=Math.min(_,C),x=Math.max(w,b),T=Math.max(_,C),v=S.getChildren();let O=0;for(let e=N;e<=T;e++){const t=v[e];if(!se(t))return!1;const n=d[O];if(!se(n))return!1;const o=t.getChildren(),r=n.getChildren();let l=0;for(let e=y;e<=x;e++){const t=o[e];if(!te(t))return!1;const n=r[l];if(!te(n))return!1;const i=t.getChildren();n.getChildren().forEach((e=>{if(c(e)){s().append(e),t.append(e)}else t.append(e)})),i.forEach((e=>e.remove())),l++}O++}return!0}),k)),u.listenersToRemove.add(r.registerCommand(w,(()=>{const t=g(),n=z();if(f(t)){const{anchor:n,focus:o}=t,l=n.getNode(),s=o.getNode(),i=et(l),a=et(s),c=!(!i||!e.is(tt(i))),h=!(!a||!e.is(tt(a))),g=c!==h,f=c&&h,p=t.isBackward();if(g){const n=t.clone();if(h){const[t]=Re(e,a,a),o=t[0][0].cell,r=t[t.length-1].at(-1).cell;n.focus.set(p?o.getKey():r.getKey(),p?o.getChildrenSize():r.getChildrenSize(),"element")}else if(c){const[t]=Re(e,i,i),o=t[0][0].cell,r=t[t.length-1].at(-1).cell;n.anchor.set(p?r.getKey():o.getKey(),p?r.getChildrenSize():0,"element")}C(n),Je(r,u)}else f&&(i.is(a)||(u.setAnchorCellForSelection(S(i)),u.setFocusCellForSelection(S(a),!0),u.isSelecting||setTimeout((()=>{const{onMouseUp:e,onMouseMove:t}=m();u.isSelecting=!0,d.addEventListener("mouseup",e),d.addEventListener("mousemove",t)}),0)))}else if(t&&Ae(t)&&t.is(n)&&t.tableKey===e.getKey()){const n=Le(r._window);if(n&&n.anchorNode&&n.focusNode){const o=b(n.focusNode),l=o&&!e.is(tt(o)),s=b(n.anchorNode),i=s&&e.is(tt(s));if(l&&i&&n.rangeCount>0){const o=Y(n,r);o&&(o.anchor.set(e.getKey(),t.isBackward()?e.getChildrenSize():0,"element"),n.removeAllRanges(),C(o))}}}return t&&!t.is(n)&&(Ae(t)||Ae(n))&&u.tableSelection&&!u.tableSelection.is(n)?(Ae(t)&&t.tableKey===u.tableNodeKey?u.updateTableTableSelection(t):!Ae(t)&&Ae(n)&&n.tableKey===u.tableNodeKey&&u.updateTableTableSelection(null),!1):(u.hasHijackedSelectionStyles&&!e.isSelected()?function(e,t){t.enableHighlightStyle(),Xe(t.table,(t=>{const n=t.elem;t.highlighted=!1,Ze(e,t),n.getAttribute("style")||n.removeAttribute("style")}))}(r,u):!u.hasHijackedSelectionStyles&&e.isSelected()&&Je(r,u),!1)}),k)),u.listenersToRemove.add(r.registerCommand(X,(()=>{const t=g();if(!f(t)||!t.isCollapsed()||!qe(t,e))return!1;const n=lt(r,t,e);return!!n&&(rt(n,e),!0)}),k)),u}function We(e){return e[Pe]||null}function Ue(e){let t=e;for(;null!=t;){const e=t.nodeName;if("TD"===e||"TH"===e){const e=t._cell;return void 0===e?null:e}t=t.parentNode}return null}function ze(e){const t=[],n={columns:0,domRows:t,rows:0};let o=e.firstChild,r=0,l=0;for(t.length=0;null!=o;){const e=o.nodeName;if("TD"===e||"TH"===e){const e={elem:o,hasBackgroundColor:""!==o.style.backgroundColor,highlighted:!1,x:r,y:l};o._cell=e;let n=t[l];void 0===n&&(n=t[l]=[]),n[r]=e}else{const e=o.firstChild;if(null!=e){o=e;continue}}const n=o.nextSibling;if(null!=n){r++,o=n;continue}const s=o.parentNode;if(null!=s){const e=s.nextSibling;if(null==e)break;l++,r=0,o=e}}return n.columns=r+1,n.rows=l+1,n}function Ye(e,t,n){const o=new Set(n?n.getNodes():[]);Xe(t,((t,n)=>{const r=t.elem;o.has(n)?(t.highlighted=!0,Ve(e,t)):(t.highlighted=!1,Ze(e,t),r.getAttribute("style")||r.removeAttribute("style"))}))}function Xe(e,t){const{domRows:n}=e;for(let e=0;e<n.length;e++){const o=n[e];if(o)for(let n=0;n<o.length;n++){const r=o[n];if(!r)continue;const l=b(r.elem);null!==l&&t(r,l,{x:n,y:e})}}}function Je(e,t){t.disableHighlightStyle(),Xe(t.table,(t=>{t.highlighted=!0,Ve(e,t)}))}const $e=(e,t,n,o,r)=>{const l="forward"===r;switch(r){case"backward":case"forward":return n!==(l?e.table.columns-1:0)?Ge(t.getCellNodeFromCordsOrThrow(n+(l?1:-1),o,e.table),l):o!==(l?e.table.rows-1:0)?Ge(t.getCellNodeFromCordsOrThrow(l?0:e.table.columns-1,o+(l?1:-1),e.table),l):l?t.selectNext():t.selectPrevious(),!0;case"up":return 0!==o?Ge(t.getCellNodeFromCordsOrThrow(n,o-1,e.table),!1):t.selectPrevious(),!0;case"down":return o!==e.table.rows-1?Ge(t.getCellNodeFromCordsOrThrow(n,o+1,e.table),!0):t.selectNext(),!0;default:return!1}},je=(e,t,n,o,r)=>{const l="forward"===r;switch(r){case"backward":case"forward":return n!==(l?e.table.columns-1:0)&&e.setFocusCellForSelection(t.getDOMCellFromCordsOrThrow(n+(l?1:-1),o,e.table)),!0;case"up":return 0!==o&&(e.setFocusCellForSelection(t.getDOMCellFromCordsOrThrow(n,o-1,e.table)),!0);case"down":return o!==e.table.rows-1&&(e.setFocusCellForSelection(t.getDOMCellFromCordsOrThrow(n,o+1,e.table)),!0);default:return!1}};function qe(e,t){if(f(e)||Ae(e)){const n=t.isParentOf(e.anchor.getNode()),o=t.isParentOf(e.focus.getNode());return n&&o}return!1}function Ge(e,t){t?e.selectStart():e.selectEnd()}const Qe="172,206,247";function Ve(e,t){const n=t.elem,o=b(n);te(o)||ae(131);null===o.getBackgroundColor()?n.style.setProperty("background-color",`rgb(${Qe})`):n.style.setProperty("background-image",`linear-gradient(to right, rgba(${Qe},0.85), rgba(${Qe},0.85))`),n.style.setProperty("caret-color","transparent")}function Ze(e,t){const n=t.elem,o=b(n);te(o)||ae(131);null===o.getBackgroundColor()&&n.style.removeProperty("background-color"),n.style.removeProperty("background-image"),n.style.removeProperty("caret-color")}function et(e){const n=t(e,te);return te(n)?n:null}function tt(e){const n=t(e,dt);return dt(n)?n:null}function nt(e,n,o,r,l){if(("up"===o||"down"===o)&&function(e){const t=e.getRootElement();if(!t)return!1;return t.hasAttribute("aria-controls")&&"typeahead-menu"===t.getAttribute("aria-controls")}(e))return!1;const s=g();if(!qe(s,r)){if(f(s)){if(s.isCollapsed()&&"backward"===o){const e=s.anchor.type,o=s.anchor.offset;if("element"!==e&&("text"!==e||0!==o))return!1;const r=s.anchor.getNode();if(!r)return!1;const l=t(r,(e=>i(e)&&!e.isInline()));if(!l)return!1;const a=l.getPreviousSibling();return!(!a||!dt(a))&&(ot(n),a.selectEnd(),!0)}if(n.shiftKey&&("up"===o||"down"===o)){const e=s.focus.getNode();if(J(e)){const e=s.getNodes()[0];if(e){const n=t(e,te);if(n&&r.isParentOf(n)){const e=r.getFirstDescendant(),t=r.getLastDescendant();if(!e||!t)return!1;const[n]=Ke(e),[o]=Ke(t),s=r.getCordsFromCellNode(n,l.table),i=r.getCordsFromCellNode(o,l.table),a=r.getDOMCellFromCordsOrThrow(s.x,s.y,l.table),c=r.getDOMCellFromCordsOrThrow(i.x,i.y,l.table);return l.setAnchorCellForSelection(a),l.setFocusCellForSelection(c,!0),!0}}return!1}{const n=t(e,(e=>i(e)&&!e.isInline()));if(!n)return!1;const r="down"===o?n.getNextSibling():n.getPreviousSibling();if(dt(r)&&l.tableNodeKey===r.getKey()){const e=r.getFirstDescendant(),t=r.getLastDescendant();if(!e||!t)return!1;const[n]=Ke(e),[l]=Ke(t),i=s.clone();return i.focus.set(("up"===o?n:l).getKey(),"up"===o?0:l.getChildrenSize(),"element"),C(i),!0}}}}return!1}if(f(s)&&s.isCollapsed()){const{anchor:a,focus:c}=s,u=t(a.getNode(),te),d=t(c.getNode(),te);if(!te(u)||!u.is(d))return!1;const h=tt(u);if(h!==r&&null!=h){const t=e.getElementByKey(h.getKey());if(null!=t)return l.table=ze(t),nt(e,n,o,h,l)}if("backward"===o||"forward"===o){const e=a.type,l=a.offset,c=a.getNode();if(!c)return!1;const u=s.getNodes();return(1!==u.length||!$(u[0]))&&(!!function(e,n,o,r){return function(e,t,n){return"element"===e&&("backward"===n?null===t.getPreviousSibling():null===t.getNextSibling())}(e,o,r)||function(e,n,o,r){const l=t(o,(e=>i(e)&&!e.isInline()));if(!l)return!1;const s="backward"===r?0===n:n===o.getTextContentSize();return"text"===e&&s&&("backward"===r?null===l.getPreviousSibling():null===l.getNextSibling())}(e,n,o,r)}(e,l,c,o)&&function(e,n,o,r){const l=t(n,te);if(!te(l))return!1;const[s,a]=Re(o,l,l);if(!function(e,t,n){const o=e[0][0],r=e[e.length-1][e[0].length-1],{startColumn:l,startRow:s}=t;return"backward"===n?l===o.startColumn&&s===o.startRow:l===r.startColumn&&s===r.startRow}(s,a,r))return!1;const c=function(e,n,o){const r=t(e,(e=>i(e)&&!e.isInline()));if(!r)return;const l="backward"===n?r.getPreviousSibling():r.getNextSibling();return l&&dt(l)?l:"backward"===n?o.getPreviousSibling():o.getNextSibling()}(n,r,o);if(!c||dt(c))return!1;ot(e),"backward"===r?c.selectEnd():c.selectStart();return!0}(n,c,r,o))}const g=e.getElementByKey(u.__key),f=e.getElementByKey(a.key);if(null==f||null==g)return!1;let m;if("element"===a.type)m=f.getBoundingClientRect();else{const e=window.getSelection();if(null===e||0===e.rangeCount)return!1;m=e.getRangeAt(0).getBoundingClientRect()}const p="up"===o?u.getFirstChild():u.getLastChild();if(null==p)return!1;const S=e.getElementByKey(p.__key);if(null==S)return!1;const _=S.getBoundingClientRect();if("up"===o?_.top>m.top-m.height:m.bottom+m.height>_.bottom){ot(n);const e=r.getCordsFromCellNode(u,l.table);if(!n.shiftKey)return $e(l,r,e.x,e.y,o);{const t=r.getDOMCellFromCordsOrThrow(e.x,e.y,l.table);l.setAnchorCellForSelection(t),l.setFocusCellForSelection(t,!0)}return!0}}else if(Ae(s)){const{anchor:i,focus:a}=s,c=t(i.getNode(),te),u=t(a.getNode(),te),[d]=s.getNodes(),h=e.getElementByKey(d.getKey());if(!te(c)||!te(u)||!dt(d)||null==h)return!1;l.updateTableTableSelection(s);const g=ze(h),f=r.getCordsFromCellNode(c,g),m=r.getDOMCellFromCordsOrThrow(f.x,f.y,g);if(l.setAnchorCellForSelection(m),ot(n),n.shiftKey){const e=r.getCordsFromCellNode(u,g);return je(l,d,e.x,e.y,o)}return u.selectEnd(),!0}return!1}function ot(e){e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation()}function rt(e,t,n){const o=s();"first"===e?t.insertBefore(o):t.insertAfter(o),o.append(...n||[]),o.selectEnd()}function lt(e,n,o){const r=o.getParent();if(!r)return;const l=e.getElementByKey(r.getKey());if(!l)return;const s=window.getSelection();if(!s||s.anchorNode!==l)return;const i=t(n.anchor.getNode(),(e=>te(e)));if(!i)return;const a=t(i,(e=>dt(e)));if(!dt(a)||!a.is(o))return;const[c,u]=Re(o,i,i),d=c[0][0],h=c[c.length-1][c[0].length-1],{startRow:g,startColumn:f}=u,m=g===d.startRow&&f===d.startColumn,p=g===h.startRow&&f===h.startColumn;return m?"first":p?"last":void 0}function st(t,o,r){r?(e(t,o.theme.tableRowStriping),t.setAttribute("data-lexical-row-striping","true")):(n(t,o.theme.tableRowStriping),t.removeAttribute("data-lexical-row-striping"))}class it extends l{static getType(){return"table"}static clone(e){return new it(e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__rowStriping=e.__rowStriping}static importDOM(){return{table:e=>({conversion:ct,priority:1})}}static importJSON(e){const t=ut();return t.__rowStriping=e.rowStriping||!1,t}constructor(e){super(e),this.__rowStriping=!1}exportJSON(){return{...super.exportJSON(),rowStriping:this.__rowStriping?this.__rowStriping:void 0,type:"table",version:1}}createDOM(t,n){const o=document.createElement("table");return e(o,t.theme.table),this.__rowStriping&&st(o,t,!0),o}updateDOM(e,t,n){return e.__rowStriping!==this.__rowStriping&&st(t,n,this.__rowStriping),!1}exportDOM(e){return{...super.exportDOM(e),after:e=>{if(e){const t=e.cloneNode(),n=document.createElement("colgroup"),o=document.createElement("tbody");r(e)&&o.append(...e.children);const l=this.getFirstChildOrThrow();if(!se(l))throw new Error("Expected to find row node.");const s=l.getChildrenSize();for(let e=0;e<s;e++){const e=document.createElement("col");n.append(e)}return t.replaceChildren(n,o),t}}}}canBeEmpty(){return!1}isShadowRoot(){return!0}getCordsFromCellNode(e,t){const{rows:n,domRows:o}=t;for(let t=0;t<n;t++){const n=o[t];if(null==n)continue;const r=n.findIndex((t=>{if(!t)return;const{elem:n}=t;return b(n)===e}));if(-1!==r)return{x:r,y:t}}throw new Error("Cell not found in table.")}getDOMCellFromCords(e,t,n){const{domRows:o}=n,r=o[t];if(null==r)return null;const l=r[e<r.length?e:r.length-1];return null==l?null:l}getDOMCellFromCordsOrThrow(e,t,n){const o=this.getDOMCellFromCords(e,t,n);if(!o)throw new Error("Cell not found at cords.");return o}getCellNodeFromCords(e,t,n){const o=this.getDOMCellFromCords(e,t,n);if(null==o)return null;const r=b(o.elem);return te(r)?r:null}getCellNodeFromCordsOrThrow(e,t,n){const o=this.getCellNodeFromCords(e,t,n);if(!o)throw new Error("Node at cords not TableCellNode.");return o}getRowStriping(){return Boolean(this.getLatest().__rowStriping)}setRowStriping(e){this.getWritable().__rowStriping=e}canSelectBefore(){return!0}canIndent(){return!1}}function at(e,t){const n=e.getElementByKey(t.getKey());if(null==n)throw new Error("Table Element Not Found");return ze(n)}function ct(e){const t=ut();return e.hasAttribute("data-lexical-row-striping")&&t.setRowStriping(!0),{node:t}}function ut(){return u(new it)}function dt(e){return e instanceof it}export{Re as $computeTableMap,Me as $computeTableMapSkipCellCheck,ee as $createTableCellNode,ut as $createTableNode,ue as $createTableNodeWithDimensions,le as $createTableRowNode,He as $createTableSelection,Ne as $deleteTableColumn,Te as $deleteTableColumn__EXPERIMENTAL,xe as $deleteTableRow__EXPERIMENTAL,et as $findCellNode,tt as $findTableNode,at as $getElementForTableNode,Ke as $getNodeTriplet,de as $getTableCellNodeFromLexicalNode,Fe as $getTableCellNodeRect,me as $getTableColumnIndexFromTableCellNode,ge as $getTableNodeFromLexicalNodeOrThrow,fe as $getTableRowIndexFromTableCellNode,he as $getTableRowNodeFromTableCellNodeOrThrow,be as $insertTableColumn,ye as $insertTableColumn__EXPERIMENTAL,_e as $insertTableRow,we as $insertTableRow__EXPERIMENTAL,te as $isTableCellNode,dt as $isTableNode,se as $isTableRowNode,Ae as $isTableSelection,Se as $removeTableRowAtIndex,Ee as $unmergeCell,ne as INSERT_TABLE_COMMAND,Q as TableCellHeaderStates,V as TableCellNode,it as TableNode,De as TableObserver,oe as TableRowNode,Ie as applyTableHandlers,Ue as getDOMCellFromTarget,We as getTableObserverFromTableElement};
9
+ import{addClassNamesToElement as e,$findMatchingParent as t,removeClassNamesFromElement as n,objectKlassEquals as o,isHTMLElement as r}from"@lexical/utils";import{ElementNode as l,$createParagraphNode as s,$isElementNode as i,$isLineBreakNode as a,$isTextNode as c,$applyNodeReplacement as u,createCommand as d,$createTextNode as h,$getSelection as g,$isRangeSelection as f,$createPoint as m,$normalizeSelection__EXPERIMENTAL as p,$getNodeByKey as S,isCurrentlyReadOnlyMode as _,$setSelection as C,SELECTION_CHANGE_COMMAND as w,$getNearestNodeFromDOMNode as b,$createRangeSelection as y,$isParagraphNode as N,$getRoot as x,KEY_ARROW_DOWN_COMMAND as T,COMMAND_PRIORITY_HIGH as v,KEY_ARROW_UP_COMMAND as O,KEY_ARROW_LEFT_COMMAND as E,KEY_ARROW_RIGHT_COMMAND as R,KEY_ESCAPE_COMMAND as M,DELETE_WORD_COMMAND as K,DELETE_LINE_COMMAND as F,DELETE_CHARACTER_COMMAND as k,COMMAND_PRIORITY_CRITICAL as A,KEY_BACKSPACE_COMMAND as H,KEY_DELETE_COMMAND as B,CUT_COMMAND as D,FORMAT_TEXT_COMMAND as P,FORMAT_ELEMENT_COMMAND as L,CONTROLLED_TEXT_INSERTION_COMMAND as I,KEY_TAB_COMMAND as W,FOCUS_COMMAND as U,SELECTION_INSERT_CLIPBOARD_NODES_COMMAND as z,$getPreviousSelection as Y,$createRangeSelectionFromDom as X,INSERT_PARAGRAPH_COMMAND as J,$isRootOrShadowRoot as $,$isDecoratorNode as j}from"lexical";import{copyToClipboard as q,$getClipboardDataFromSelection as G}from"@lexical/clipboard";const Q=/^(\d+(?:\.\d+)?)px$/,V={BOTH:3,COLUMN:2,NO_STATUS:0,ROW:1};class Z extends l{static getType(){return"tablecell"}static clone(e){return new Z(e.__headerState,e.__colSpan,e.__width,e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__rowSpan=e.__rowSpan,this.__backgroundColor=e.__backgroundColor}static importDOM(){return{td:e=>({conversion:ee,priority:0}),th:e=>({conversion:ee,priority:0})}}static importJSON(e){const t=e.colSpan||1,n=e.rowSpan||1;return te(e.headerState,t,e.width||void 0).setRowSpan(n).setBackgroundColor(e.backgroundColor||null)}constructor(e=V.NO_STATUS,t=1,n,o){super(o),this.__colSpan=t,this.__rowSpan=1,this.__headerState=e,this.__width=n,this.__backgroundColor=null}createDOM(t){const n=document.createElement(this.getTag());return this.__width&&(n.style.width=`${this.__width}px`),this.__colSpan>1&&(n.colSpan=this.__colSpan),this.__rowSpan>1&&(n.rowSpan=this.__rowSpan),null!==this.__backgroundColor&&(n.style.backgroundColor=this.__backgroundColor),e(n,t.theme.tableCell,this.hasHeader()&&t.theme.tableCellHeader),n}exportDOM(e){const{element:t}=super.exportDOM(e);if(t){const e=t;e.style.border="1px solid black",this.__colSpan>1&&(e.colSpan=this.__colSpan),this.__rowSpan>1&&(e.rowSpan=this.__rowSpan),e.style.width=`${this.getWidth()||75}px`,e.style.verticalAlign="top",e.style.textAlign="start";const n=this.getBackgroundColor();null!==n?e.style.backgroundColor=n:this.hasHeader()&&(e.style.backgroundColor="#f2f3f5")}return{element:t}}exportJSON(){return{...super.exportJSON(),backgroundColor:this.getBackgroundColor(),colSpan:this.__colSpan,headerState:this.__headerState,rowSpan:this.__rowSpan,type:"tablecell",width:this.getWidth()}}getColSpan(){return this.getLatest().__colSpan}setColSpan(e){const t=this.getWritable();return t.__colSpan=e,t}getRowSpan(){return this.getLatest().__rowSpan}setRowSpan(e){const t=this.getWritable();return t.__rowSpan=e,t}getTag(){return this.hasHeader()?"th":"td"}setHeaderStyles(e,t=V.BOTH){const n=this.getWritable();return n.__headerState=e&t|n.__headerState&~t,n}getHeaderStyles(){return this.getLatest().__headerState}setWidth(e){const t=this.getWritable();return t.__width=e,t}getWidth(){return this.getLatest().__width}getBackgroundColor(){return this.getLatest().__backgroundColor}setBackgroundColor(e){const t=this.getWritable();return t.__backgroundColor=e,t}toggleHeaderStyle(e){const t=this.getWritable();return(t.__headerState&e)===e?t.__headerState-=e:t.__headerState+=e,t}hasHeaderState(e){return(this.getHeaderStyles()&e)===e}hasHeader(){return this.getLatest().__headerState!==V.NO_STATUS}updateDOM(e){return e.__headerState!==this.__headerState||e.__width!==this.__width||e.__colSpan!==this.__colSpan||e.__rowSpan!==this.__rowSpan||e.__backgroundColor!==this.__backgroundColor}isShadowRoot(){return!0}collapseAtStart(){return!0}canBeEmpty(){return!1}canIndent(){return!1}}function ee(e){const t=e,n=e.nodeName.toLowerCase();let o;Q.test(t.style.width)&&(o=parseFloat(t.style.width));const r=te("th"===n?V.ROW:V.NO_STATUS,t.colSpan,o);r.__rowSpan=t.rowSpan;const l=t.style.backgroundColor;""!==l&&(r.__backgroundColor=l);const u=t.style,d=u.textDecoration.split(" "),h="700"===u.fontWeight||"bold"===u.fontWeight,g=d.includes("line-through"),f="italic"===u.fontStyle,m=d.includes("underline");return{after:e=>(0===e.length&&e.push(s()),e),forChild:(e,t)=>{if(ne(t)&&!i(e)){const t=s();return a(e)&&"\n"===e.getTextContent()?null:(c(e)&&(h&&e.toggleFormat("bold"),g&&e.toggleFormat("strikethrough"),f&&e.toggleFormat("italic"),m&&e.toggleFormat("underline")),t.append(e),t)}return e},node:r}}function te(e,t=1,n){return u(new Z(e,t,n))}function ne(e){return e instanceof Z}const oe=d("INSERT_TABLE_COMMAND");class re extends l{static getType(){return"tablerow"}static clone(e){return new re(e.__height,e.__key)}static importDOM(){return{tr:e=>({conversion:le,priority:0})}}static importJSON(e){return se(e.height)}constructor(e,t){super(t),this.__height=e}exportJSON(){return{...super.exportJSON(),...this.getHeight()&&{height:this.getHeight()},type:"tablerow",version:1}}createDOM(t){const n=document.createElement("tr");return this.__height&&(n.style.height=`${this.__height}px`),e(n,t.theme.tableRow),n}isShadowRoot(){return!0}setHeight(e){return this.getWritable().__height=e,this.__height}getHeight(){return this.getLatest().__height}updateDOM(e){return e.__height!==this.__height}canBeEmpty(){return!1}canIndent(){return!1}}function le(e){const t=e;let n;return Q.test(t.style.height)&&(n=parseFloat(t.style.height)),{node:se(n)}}function se(e){return u(new re(e))}function ie(e){return e instanceof re}function ae(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ce=ae((function(e){const t=new URLSearchParams;t.append("code",e);for(let e=1;e<arguments.length;e++)t.append("v",arguments[e]);throw Error(`Minified Lexical error #${e}; visit https://lexical.dev/docs/error?${t} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}));const ue="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement;function de(e,t,n=!0){const o=dt();for(let r=0;r<e;r++){const e=se();for(let o=0;o<t;o++){let t=V.NO_STATUS;"object"==typeof n?(0===r&&n.rows&&(t|=V.ROW),0===o&&n.columns&&(t|=V.COLUMN)):n&&(0===r&&(t|=V.ROW),0===o&&(t|=V.COLUMN));const l=te(t),i=s();i.append(h()),l.append(i),e.append(l)}o.append(e)}return o}function he(e){const n=t(e,(e=>ne(e)));return ne(n)?n:null}function ge(e){const n=t(e,(e=>ie(e)));if(ie(n))return n;throw new Error("Expected table cell to be inside of table row.")}function fe(e){const n=t(e,(e=>ht(e)));if(ht(n))return n;throw new Error("Expected table cell to be inside of table.")}function me(e){const t=ge(e);return fe(t).getChildren().findIndex((e=>e.is(t)))}function pe(e){return ge(e).getChildren().findIndex((t=>t.is(e)))}function Se(e,t){const n=fe(e),{x:o,y:r}=n.getCordsFromCellNode(e,t);return{above:n.getCellNodeFromCords(o,r-1,t),below:n.getCellNodeFromCords(o,r+1,t),left:n.getCellNodeFromCords(o-1,r,t),right:n.getCellNodeFromCords(o+1,r,t)}}function _e(e,t){const n=e.getChildren();if(t>=n.length||t<0)throw new Error("Expected table cell to be inside of table row.");return n[t].remove(),e}function Ce(e,t,n=!0,o,r){const l=e.getChildren();if(t>=l.length||t<0)throw new Error("Table row target index out of range");const i=l[t];if(!ie(i))throw new Error("Row before insertion index does not exist.");for(let e=0;e<o;e++){const e=i.getChildren(),t=e.length,o=se();for(let n=0;n<t;n++){const t=e[n];ne(t)||ce(12);const{above:l,below:i}=Se(t,r);let a=V.NO_STATUS;const c=l&&l.getWidth()||i&&i.getWidth()||void 0;(l&&l.hasHeaderState(V.COLUMN)||i&&i.hasHeaderState(V.COLUMN))&&(a|=V.COLUMN);const u=te(a,1,c);u.append(s()),o.append(u)}n?i.insertAfter(o):i.insertBefore(o)}return e}const we=(e,t)=>e===V.BOTH||e===t?t:V.NO_STATUS;function be(e=!0){const t=g();f(t)||He(t)||ce(188);const n=t.focus.getNode(),[o,,r]=Fe(n),[l,i]=Me(r,o,o),a=l[0].length,{startRow:c}=i;if(e){const e=c+o.__rowSpan-1,t=l[e],n=se();for(let o=0;o<a;o++){const{cell:r,startRow:l}=t[o];if(l+r.__rowSpan-1<=e){const e=t[o].cell.__headerState,r=we(e,V.COLUMN);n.append(te(r).append(s()))}else r.setRowSpan(r.__rowSpan+1)}const i=r.getChildAtIndex(e);ie(i)||ce(145),i.insertAfter(n)}else{const e=l[c],t=se();for(let n=0;n<a;n++){const{cell:o,startRow:r}=e[n];if(r===c){const o=e[n].cell.__headerState,r=we(o,V.COLUMN);t.append(te(r).append(s()))}else o.setRowSpan(o.__rowSpan+1)}const n=r.getChildAtIndex(c);ie(n)||ce(145),n.insertBefore(t)}}function ye(e,t,n=!0,o,r){const l=e.getChildren(),i=[];for(let e=0;e<l.length;e++){const n=l[e];if(ie(n))for(let e=0;e<o;e++){const e=n.getChildren();if(t>=e.length||t<0)throw new Error("Table column target index out of range");const o=e[t];ne(o)||ce(12);const{left:l,right:a}=Se(o,r);let c=V.NO_STATUS;(l&&l.hasHeaderState(V.ROW)||a&&a.hasHeaderState(V.ROW))&&(c|=V.ROW);const u=te(c);u.append(s()),i.push({newTableCell:u,targetCell:o})}}return i.forEach((({newTableCell:e,targetCell:t})=>{n?t.insertAfter(e):t.insertBefore(e)})),e}function Ne(e=!0){const t=g();f(t)||He(t)||ce(188);const n=t.anchor.getNode(),o=t.focus.getNode(),[r]=Fe(n),[l,,i]=Fe(o),[a,c,u]=Me(i,l,r),d=a.length,h=e?Math.max(c.startColumn,u.startColumn):Math.min(c.startColumn,u.startColumn),m=e?h+l.__colSpan-1:h-1,p=i.getFirstChild();ie(p)||ce(120);let S=null;function _(e=V.NO_STATUS){const t=te(e).append(s());return null===S&&(S=t),t}let C=p;e:for(let e=0;e<d;e++){if(0!==e){const e=C.getNextSibling();ie(e)||ce(121),C=e}const t=a[e],n=t[m<0?0:m].cell.__headerState,o=we(n,V.ROW);if(m<0){Ee(C,_(o));continue}const{cell:r,startColumn:l,startRow:s}=t[m];if(l+r.__colSpan-1<=m){let n=r,l=s,i=m;for(;l!==e&&n.__rowSpan>1;){if(i-=r.__colSpan,!(i>=0)){C.append(_(o));continue e}{const{cell:e,startRow:o}=t[i];n=e,l=o}}n.insertAfter(_(o))}else r.setColSpan(r.__colSpan+1)}null!==S&&Oe(S)}function xe(e,t){const n=e.getChildren();for(let e=0;e<n.length;e++){const o=n[e];if(ie(o)){const e=o.getChildren();if(t>=e.length||t<0)throw new Error("Table column target index out of range");e[t].remove()}}return e}function Te(){const e=g();f(e)||He(e)||ce(188);const t=e.anchor.getNode(),n=e.focus.getNode(),[o,,r]=Fe(t),[l]=Fe(n),[s,i,a]=Me(r,o,l),{startRow:c}=i,{startRow:u}=a,d=u+l.__rowSpan-1;if(s.length===d-c+1)return void r.remove();const h=s[0].length,m=s[d+1],p=r.getChildAtIndex(d+1);for(let e=d;e>=c;e--){for(let t=h-1;t>=0;t--){const{cell:n,startRow:o,startColumn:r}=s[e][t];if(r===t&&(e===c&&o<c&&n.setRowSpan(n.__rowSpan-(o-c)),o>=c&&o+n.__rowSpan-1>d))if(n.setRowSpan(n.__rowSpan-(d-o+1)),null===p&&ce(122),0===t)Ee(p,n);else{const{cell:e}=m[t-1];e.insertAfter(n)}}const t=r.getChildAtIndex(e);ie(t)||ce(206,String(e)),t.remove()}if(void 0!==m){const{cell:e}=m[0];Oe(e)}else{const e=s[c-1],{cell:t}=e[0];Oe(t)}}function ve(){const e=g();f(e)||He(e)||ce(188);const t=e.anchor.getNode(),n=e.focus.getNode(),[o,,r]=Fe(t),[l]=Fe(n),[s,i,a]=Me(r,o,l),{startColumn:c}=i,{startRow:u,startColumn:d}=a,h=Math.min(c,d),m=Math.max(c+o.__colSpan-1,d+l.__colSpan-1),p=m-h+1;if(s[0].length===m-h+1)return r.selectPrevious(),void r.remove();const S=s.length;for(let e=0;e<S;e++)for(let t=h;t<=m;t++){const{cell:n,startColumn:o}=s[e][t];if(o<h){if(t===h){const e=h-o;n.setColSpan(n.__colSpan-Math.min(p,n.__colSpan-e))}}else if(o+n.__colSpan-1>m){if(t===m){const e=m-o+1;n.setColSpan(n.__colSpan-e)}}else n.remove()}const _=s[u],C=c>d?_[c+o.__colSpan]:_[d+l.__colSpan];if(void 0!==C){const{cell:e}=C;Oe(e)}else{const e=d<c?_[d-1]:_[c-1],{cell:t}=e;Oe(t)}}function Oe(e){const t=e.getFirstDescendant();null==t?e.selectStart():t.getParentOrThrow().selectStart()}function Ee(e,t){const n=e.getFirstChild();null!==n?n.insertBefore(t):e.append(t)}function Re(){const e=g();f(e)||He(e)||ce(188);const t=e.anchor.getNode(),[n,o,r]=Fe(t),l=n.__colSpan,i=n.__rowSpan;if(1===l&&1===i)return;const[a,c]=Me(r,n,n),{startColumn:u,startRow:d}=c,h=n.__headerState&V.COLUMN,m=Array.from({length:l},((e,t)=>{let n=h;for(let e=0;0!==n&&e<a.length;e++)n&=a[e][t+u].cell.__headerState;return n})),p=n.__headerState&V.ROW,S=Array.from({length:i},((e,t)=>{let n=p;for(let e=0;0!==n&&e<a[0].length;e++)n&=a[t+d][e].cell.__headerState;return n}));if(l>1){for(let e=1;e<l;e++)n.insertAfter(te(m[e]|S[0]).append(s()));n.setColSpan(1)}if(i>1){let e;for(let t=1;t<i;t++){const n=d+t,r=a[n];e=(e||o).getNextSibling(),ie(e)||ce(125);let i=null;for(let e=0;e<u;e++){const t=r[e],o=t.cell;t.startRow===n&&(i=o),o.__colSpan>1&&(e+=o.__colSpan-1)}if(null===i)for(let n=l-1;n>=0;n--)Ee(e,te(m[n]|S[t]).append(s()));else for(let e=l-1;e>=0;e--)i.insertAfter(te(m[e]|S[t]).append(s()))}n.setRowSpan(1)}}function Me(e,t,n){const[o,r,l]=Ke(e,t,n);return null===r&&ce(207),null===l&&ce(208),[o,r,l]}function Ke(e,t,n){const o=[];let r=null,l=null;function s(e){let t=o[e];return void 0===t&&(o[e]=t=[]),t}const i=e.getChildren();for(let e=0;e<i.length;e++){const o=i[e];ie(o)||ce(209);for(let a=o.getFirstChild(),c=0;null!=a;a=a.getNextSibling()){ne(a)||ce(147);const o=s(e);for(;void 0!==o[c];)c++;const u={cell:a,startColumn:c,startRow:e},{__rowSpan:d,__colSpan:h}=a;for(let t=0;t<d&&!(e+t>=i.length);t++){const n=s(e+t);for(let e=0;e<h;e++)n[c+e]=u}null!==t&&null===r&&t.is(a)&&(r=u),null!==n&&null===l&&n.is(a)&&(l=u)}}return[o,r,l]}function Fe(e){let n;if(e instanceof Z)n=e;else if("__type"in e){const o=t(e,ne);ne(o)||ce(148),n=o}else{const o=t(e.getNode(),ne);ne(o)||ce(148),n=o}const o=n.getParent();ie(o)||ce(149);const r=o.getParent();return ht(r)||ce(210),[n,o,r]}function ke(e){const[t,,n]=Fe(e),o=n.getChildren(),r=o.length,l=o[0].getChildren().length,s=new Array(r);for(let e=0;e<r;e++)s[e]=new Array(l);for(let e=0;e<r;e++){const n=o[e].getChildren();let r=0;for(let o=0;o<n.length;o++){for(;s[e][r];)r++;const l=n[o],i=l.__rowSpan||1,a=l.__colSpan||1;for(let t=0;t<i;t++)for(let n=0;n<a;n++)s[e+t][r+n]=l;if(t===l)return{colSpan:a,columnIndex:r,rowIndex:e,rowSpan:i};r+=a}}return null}class Ae{constructor(e,t,n){this.anchor=t,this.focus=n,t._selection=this,n._selection=this,this._cachedNodes=null,this.dirty=!1,this.tableKey=e}getStartEndPoints(){return[this.anchor,this.focus]}isBackward(){return this.focus.isBefore(this.anchor)}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e}is(e){return!!He(e)&&(this.tableKey===e.tableKey&&this.anchor.is(e.anchor)&&this.focus.is(e.focus))}set(e,t,n){this.dirty=!0,this.tableKey=e,this.anchor.key=t,this.focus.key=n,this._cachedNodes=null}clone(){return new Ae(this.tableKey,this.anchor,this.focus)}isCollapsed(){return!1}extract(){return this.getNodes()}insertRawText(e){}insertText(){}insertNodes(e){const t=this.focus.getNode();i(t)||ce(151);p(t.select(0,t.getChildrenSize())).insertNodes(e)}getShape(){const e=S(this.anchor.key);ne(e)||ce(152);const t=ke(e);null===t&&ce(153);const n=S(this.focus.key);ne(n)||ce(154);const o=ke(n);null===o&&ce(155);const r=Math.min(t.columnIndex,o.columnIndex),l=Math.max(t.columnIndex+t.colSpan-1,o.columnIndex+o.colSpan-1),s=Math.min(t.rowIndex,o.rowIndex),i=Math.max(t.rowIndex+t.rowSpan-1,o.rowIndex+o.rowSpan-1);return{fromX:Math.min(r,l),fromY:Math.min(s,i),toX:Math.max(r,l),toY:Math.max(s,i)}}getNodes(){const e=this._cachedNodes;if(null!==e)return e;const n=this.anchor.getNode(),o=this.focus.getNode(),r=t(n,ne),l=t(o,ne);ne(r)||ce(152),ne(l)||ce(154);const s=r.getParent();ie(s)||ce(156);const i=s.getParent();ht(i)||ce(157);const a=l.getParents()[1];if(a!==i){if(i.isParentOf(l)){const e=a.getParent();null==e&&ce(159),this.set(this.tableKey,l.getKey(),e.getKey())}else{const e=i.getParent();null==e&&ce(158),this.set(this.tableKey,e.getKey(),l.getKey())}return this.getNodes()}const[c,u,d]=Me(i,r,l);let h=Math.min(u.startColumn,d.startColumn),g=Math.min(u.startRow,d.startRow),f=Math.max(u.startColumn+u.cell.__colSpan-1,d.startColumn+d.cell.__colSpan-1),m=Math.max(u.startRow+u.cell.__rowSpan-1,d.startRow+d.cell.__rowSpan-1),p=h,S=g,C=h,w=g;function b(e){const{cell:t,startColumn:n,startRow:o}=e;h=Math.min(h,n),g=Math.min(g,o),f=Math.max(f,n+t.__colSpan-1),m=Math.max(m,o+t.__rowSpan-1)}for(;h<p||g<S||f>C||m>w;){if(h<p){const e=w-S,t=p-1;for(let n=0;n<=e;n++)b(c[S+n][t]);p=t}if(g<S){const e=C-p,t=S-1;for(let n=0;n<=e;n++)b(c[t][p+n]);S=t}if(f>C){const e=w-S,t=C+1;for(let n=0;n<=e;n++)b(c[S+n][t]);C=t}if(m>w){const e=C-p,t=w+1;for(let n=0;n<=e;n++)b(c[t][p+n]);w=t}}const y=new Map([[i.getKey(),i]]);let N=null;for(let e=g;e<=m;e++)for(let t=h;t<=f;t++){const{cell:n}=c[e][t],o=n.getParent();ie(o)||ce(160),o!==N&&y.set(o.getKey(),o),y.set(n.getKey(),n);for(const e of De(n))y.set(e.getKey(),e);N=o}const x=Array.from(y.values());return _()||(this._cachedNodes=x),x}getTextContent(){const e=this.getNodes().filter((e=>ne(e)));let t="";for(let n=0;n<e.length;n++){const o=e[n],r=o.__parent,l=(e[n+1]||{}).__parent;t+=o.getTextContent()+(l!==r?"\n":"\t")}return t}}function He(e){return e instanceof Ae}function Be(){const e=m("root",0,"element"),t=m("root",0,"element");return new Ae("root",e,t)}function De(e){const t=[],n=[e];for(;n.length>0;){const o=n.pop();void 0===o&&ce(112),i(o)&&n.unshift(...o.getChildren()),o!==e&&t.push(o)}return t}class Pe{constructor(e,t){this.isHighlightingCells=!1,this.anchorX=-1,this.anchorY=-1,this.focusX=-1,this.focusY=-1,this.listenersToRemove=new Set,this.tableNodeKey=t,this.editor=e,this.table={columns:0,domRows:[],rows:0},this.tableSelection=null,this.anchorCellNodeKey=null,this.focusCellNodeKey=null,this.anchorCell=null,this.focusCell=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"),Array.from(this.listenersToRemove).forEach((e=>e())),this.listenersToRemove.clear()}trackTable(){const e=new MutationObserver((e=>{this.editor.update((()=>{let t=!1;for(let n=0;n<e.length;n++){const o=e[n].target.nodeName;if("TABLE"===o||"TBODY"===o||"THEAD"===o||"TR"===o){t=!0;break}}if(!t)return;const n=this.editor.getElementByKey(this.tableNodeKey);if(!n)throw new Error("Expected to find TableElement in DOM");this.table=Ye(n)}))}));this.editor.update((()=>{const t=this.editor.getElementByKey(this.tableNodeKey);if(!t)throw new Error("Expected to find TableElement in DOM");this.table=Ye(t),e.observe(t,{attributes:!0,childList:!0,subtree:!0})}))}clearHighlight(){const e=this.editor;this.isHighlightingCells=!1,this.anchorX=-1,this.anchorY=-1,this.focusX=-1,this.focusY=-1,this.tableSelection=null,this.anchorCellNodeKey=null,this.focusCellNodeKey=null,this.anchorCell=null,this.focusCell=null,this.hasHijackedSelectionStyles=!1,this.enableHighlightStyle(),e.update((()=>{if(!ht(S(this.tableNodeKey)))throw new Error("Expected TableNode.");const t=e.getElementByKey(this.tableNodeKey);if(!t)throw new Error("Expected to find TableElement in DOM");const n=Ye(t);Xe(e,n,null),C(null),e.dispatchCommand(w,void 0)}))}enableHighlightStyle(){const e=this.editor;e.update((()=>{const t=e.getElementByKey(this.tableNodeKey);if(!t)throw new Error("Expected to find TableElement in DOM");n(t,e._config.theme.tableSelection),t.classList.remove("disable-selection"),this.hasHijackedSelectionStyles=!1}))}disableHighlightStyle(){const t=this.editor;t.update((()=>{const n=t.getElementByKey(this.tableNodeKey);if(!n)throw new Error("Expected to find TableElement in DOM");e(n,t._config.theme.tableSelection),this.hasHijackedSelectionStyles=!0}))}updateTableTableSelection(e){if(null!==e&&e.tableKey===this.tableNodeKey){const t=this.editor;this.tableSelection=e,this.isHighlightingCells=!0,this.disableHighlightStyle(),Xe(t,this.table,this.tableSelection)}else null==e?this.clearHighlight():(this.tableNodeKey=e.tableKey,this.updateTableTableSelection(e))}setFocusCellForSelection(e,t=!1){const n=this.editor;n.update((()=>{const o=S(this.tableNodeKey);if(!ht(o))throw new Error("Expected TableNode.");if(!n.getElementByKey(this.tableNodeKey))throw new Error("Expected to find TableElement in DOM");const r=e.x,l=e.y;if(this.focusCell=e,null!==this.anchorCell){const e=Ie(n._window);e&&e.setBaseAndExtent(this.anchorCell.elem,0,this.focusCell.elem,0)}if(this.isHighlightingCells||this.anchorX===r&&this.anchorY===l&&!t){if(r===this.focusX&&l===this.focusY)return}else this.isHighlightingCells=!0,this.disableHighlightStyle();if(this.focusX=r,this.focusY=l,this.isHighlightingCells){const t=b(e.elem);if(null!=this.tableSelection&&null!=this.anchorCellNodeKey&&ne(t)&&o.is(nt(t))){const e=t.getKey();this.tableSelection=this.tableSelection.clone()||Be(),this.focusCellNodeKey=e,this.tableSelection.set(this.tableNodeKey,this.anchorCellNodeKey,this.focusCellNodeKey),C(this.tableSelection),n.dispatchCommand(w,void 0),Xe(n,this.table,this.tableSelection)}}}))}setAnchorCellForSelection(e){this.isHighlightingCells=!1,this.anchorCell=e,this.anchorX=e.x,this.anchorY=e.y,this.editor.update((()=>{const t=b(e.elem);if(ne(t)){const e=t.getKey();this.tableSelection=null!=this.tableSelection?this.tableSelection.clone():Be(),this.anchorCellNodeKey=e}}))}formatCells(e){this.editor.update((()=>{const t=g();He(t)||ce(11);const n=y(),o=n.anchor,r=n.focus,l=t.getNodes().filter(ne),s=l[0].getFirstChild(),i=N(s)?s.getFormatFlags(e,null):null;l.forEach((t=>{o.set(t.getKey(),0,"element"),r.set(t.getKey(),t.getChildrenSize(),"element"),n.formatText(e,i)})),C(t),this.editor.dispatchCommand(w,void 0)}))}clearText(){const e=this.editor;e.update((()=>{const t=S(this.tableNodeKey);if(!ht(t))throw new Error("Expected TableNode.");const n=g();He(n)||ce(11);const o=n.getNodes().filter(ne);if(o.length!==this.table.columns*this.table.rows)o.forEach((e=>{if(i(e)){const t=s(),n=h();t.append(n),e.append(t),e.getChildren().forEach((e=>{e!==t&&e.remove()}))}})),Xe(e,this.table,null),C(null),e.dispatchCommand(w,void 0);else{t.selectPrevious(),t.remove();x().selectStart()}}))}}const Le="__lexicalTableSelection",Ie=e=>ue?(e||window).getSelection():null;function We(e,n,r,l){const a=r.getRootElement();if(null===a)throw new Error("No root element.");const u=new Pe(r,e.getKey()),d=r._window||window;!function(e,t){null!==Ue(e)&&ce(205);e[Le]=t}(n,u),u.listenersToRemove.add((()=>function(e,t){Ue(e)===t&&delete e[Le]}(n,u)));const m=()=>{const e=()=>{u.isSelecting=!1,d.removeEventListener("mouseup",e),d.removeEventListener("mousemove",t)},t=n=>{setTimeout((()=>{if(1&~n.buttons&&u.isSelecting)return u.isSelecting=!1,d.removeEventListener("mouseup",e),void d.removeEventListener("mousemove",t);const o=ze(n.target);null===o||u.anchorX===o.x&&u.anchorY===o.y||(n.preventDefault(),u.setFocusCellForSelection(o))}),0)};return{onMouseMove:t,onMouseUp:e}};n.addEventListener("mousedown",(e=>{setTimeout((()=>{if(0!==e.button)return;if(!d)return;const t=ze(e.target);null!==t&&(rt(e),u.setAnchorCellForSelection(t));const{onMouseUp:n,onMouseMove:o}=m();u.isSelecting=!0,d.addEventListener("mouseup",n,u.listenerOptions),d.addEventListener("mousemove",o,u.listenerOptions)}),0)}),u.listenerOptions);d.addEventListener("mousedown",(e=>{0===e.button&&r.update((()=>{const t=g(),n=e.target;He(t)&&t.tableKey===u.tableNodeKey&&a.contains(n)&&u.clearHighlight()}))}),u.listenerOptions),u.listenersToRemove.add(r.registerCommand(T,(t=>ot(r,t,"down",e,u)),v)),u.listenersToRemove.add(r.registerCommand(O,(t=>ot(r,t,"up",e,u)),v)),u.listenersToRemove.add(r.registerCommand(E,(t=>ot(r,t,"backward",e,u)),v)),u.listenersToRemove.add(r.registerCommand(R,(t=>ot(r,t,"forward",e,u)),v)),u.listenersToRemove.add(r.registerCommand(M,(e=>{const n=g();if(He(n)){const o=t(n.focus.getNode(),ne);if(ne(o))return rt(e),o.selectEnd(),!0}return!1}),v));[K,F,k].forEach((n=>{u.listenersToRemove.add(r.registerCommand(n,(n=>()=>{const o=g();if(!Ge(o,e))return!1;if(He(o))return u.clearText(),!0;if(f(o)){const r=t(o.anchor.getNode(),(e=>ne(e)));if(!ne(r))return!1;const l=o.anchor.getNode(),s=o.focus.getNode(),a=e.isParentOf(l),c=e.isParentOf(s);if(a&&!c||c&&!a)return u.clearText(),!0;const d=t(o.anchor.getNode(),(e=>i(e))),h=d&&t(d,(e=>i(e)&&ne(e.getParent())));if(!i(h)||!i(d))return!1;if(n===F&&null===h.getPreviousSibling())return!0}return!1})(n),A))}));const p=n=>{const o=g();if(!Ge(o,e)){const e=o?o.getNodes():null;if(e){const t=e.find((e=>ht(e)&&e.getKey()===u.tableNodeKey));if(ht(t)){if(!t.getParent())return!1;t.remove()}}return!1}if(He(o))return n&&(n.preventDefault(),n.stopPropagation()),u.clearText(),!0;if(f(o)){const e=t(o.anchor.getNode(),(e=>ne(e)));if(!ne(e))return!1}return!1};function S(t){const n=e.getCordsFromCellNode(t,u.table);return e.getDOMCellFromCordsOrThrow(n.x,n.y,u.table)}return u.listenersToRemove.add(r.registerCommand(H,p,A)),u.listenersToRemove.add(r.registerCommand(B,p,A)),u.listenersToRemove.add(r.registerCommand(D,(e=>{const t=g();if(t){if(!He(t)&&!f(t))return!1;q(r,o(e,ClipboardEvent)?e:null,G(t));const n=p(e);return f(t)?(t.removeText(),!0):n}return!1}),A)),u.listenersToRemove.add(r.registerCommand(P,(n=>{const o=g();if(!Ge(o,e))return!1;if(He(o))return u.formatCells(n),!0;if(f(o)){const e=t(o.anchor.getNode(),(e=>ne(e)));if(!ne(e))return!1}return!1}),A)),u.listenersToRemove.add(r.registerCommand(L,(t=>{const n=g();if(!He(n)||!Ge(n,e))return!1;const o=n.anchor.getNode(),r=n.focus.getNode();if(!ne(o)||!ne(r))return!1;const[l,s,a]=Me(e,o,r),c=Math.max(s.startRow,a.startRow),u=Math.max(s.startColumn,a.startColumn),d=Math.min(s.startRow,a.startRow),h=Math.min(s.startColumn,a.startColumn);for(let e=d;e<=c;e++)for(let n=h;n<=u;n++){const o=l[e][n].cell;o.setFormat(t);const r=o.getChildren();for(let e=0;e<r.length;e++){const n=r[e];i(n)&&!n.isInline()&&n.setFormat(t)}}return!0}),A)),u.listenersToRemove.add(r.registerCommand(I,(n=>{const o=g();if(!Ge(o,e))return!1;if(He(o))return u.clearHighlight(),!1;if(f(o)){const l=t(o.anchor.getNode(),(e=>ne(e)));if(!ne(l))return!1;if("string"==typeof n){const t=st(r,o,e);if(t)return lt(t,e,[h(n)]),!0}}return!1}),A)),l&&u.listenersToRemove.add(r.registerCommand(W,(t=>{const n=g();if(!f(n)||!n.isCollapsed()||!Ge(n,e))return!1;const o=tt(n.anchor.getNode());if(null===o)return!1;rt(t);const r=e.getCordsFromCellNode(o,u.table);return je(u,e,r.x,r.y,t.shiftKey?"backward":"forward"),!0}),A)),u.listenersToRemove.add(r.registerCommand(U,(t=>e.isSelected()),v)),u.listenersToRemove.add(r.registerCommand(z,(e=>{const{nodes:n,selection:o}=e,r=o.getStartEndPoints(),l=He(o),i=f(o)&&null!==t(o.anchor.getNode(),(e=>ne(e)))&&null!==t(o.focus.getNode(),(e=>ne(e)))||l;if(1!==n.length||!ht(n[0])||!i||null===r)return!1;const[a]=r,u=n[0],d=u.getChildren(),h=u.getFirstChildOrThrow().getChildrenSize(),g=u.getChildrenSize(),m=t(a.getNode(),(e=>ne(e))),p=m&&t(m,(e=>ie(e))),S=p&&t(p,(e=>ht(e)));if(!ne(m)||!ie(p)||!ht(S))return!1;const _=p.getIndexWithinParent(),C=Math.min(S.getChildrenSize()-1,_+g-1),w=m.getIndexWithinParent(),b=Math.min(p.getChildrenSize()-1,w+h-1),y=Math.min(w,b),N=Math.min(_,C),x=Math.max(w,b),T=Math.max(_,C),v=S.getChildren();let O=0;for(let e=N;e<=T;e++){const t=v[e];if(!ie(t))return!1;const n=d[O];if(!ie(n))return!1;const o=t.getChildren(),r=n.getChildren();let l=0;for(let e=y;e<=x;e++){const t=o[e];if(!ne(t))return!1;const n=r[l];if(!ne(n))return!1;const i=t.getChildren();n.getChildren().forEach((e=>{if(c(e)){s().append(e),t.append(e)}else t.append(e)})),i.forEach((e=>e.remove())),l++}O++}return!0}),A)),u.listenersToRemove.add(r.registerCommand(w,(()=>{const t=g(),n=Y();if(f(t)){const{anchor:n,focus:o}=t,l=n.getNode(),s=o.getNode(),i=tt(l),a=tt(s),c=!(!i||!e.is(nt(i))),h=!(!a||!e.is(nt(a))),g=c!==h,f=c&&h,p=t.isBackward();if(g){const n=t.clone();if(h){const[t]=Me(e,a,a),o=t[0][0].cell,r=t[t.length-1].at(-1).cell;n.focus.set(p?o.getKey():r.getKey(),p?o.getChildrenSize():r.getChildrenSize(),"element")}else if(c){const[t]=Me(e,i,i),o=t[0][0].cell,r=t[t.length-1].at(-1).cell;n.anchor.set(p?r.getKey():o.getKey(),p?r.getChildrenSize():0,"element")}C(n),$e(r,u)}else f&&(i.is(a)||(u.setAnchorCellForSelection(S(i)),u.setFocusCellForSelection(S(a),!0),u.isSelecting||setTimeout((()=>{const{onMouseUp:e,onMouseMove:t}=m();u.isSelecting=!0,d.addEventListener("mouseup",e),d.addEventListener("mousemove",t)}),0)))}else if(t&&He(t)&&t.is(n)&&t.tableKey===e.getKey()){const n=Ie(r._window);if(n&&n.anchorNode&&n.focusNode){const o=b(n.focusNode),l=o&&!e.is(nt(o)),s=b(n.anchorNode),i=s&&e.is(nt(s));if(l&&i&&n.rangeCount>0){const o=X(n,r);o&&(o.anchor.set(e.getKey(),t.isBackward()?e.getChildrenSize():0,"element"),n.removeAllRanges(),C(o))}}}return t&&!t.is(n)&&(He(t)||He(n))&&u.tableSelection&&!u.tableSelection.is(n)?(He(t)&&t.tableKey===u.tableNodeKey?u.updateTableTableSelection(t):!He(t)&&He(n)&&n.tableKey===u.tableNodeKey&&u.updateTableTableSelection(null),!1):(u.hasHijackedSelectionStyles&&!e.isSelected()?function(e,t){t.enableHighlightStyle(),Je(t.table,(t=>{const n=t.elem;t.highlighted=!1,et(e,t),n.getAttribute("style")||n.removeAttribute("style")}))}(r,u):!u.hasHijackedSelectionStyles&&e.isSelected()&&$e(r,u),!1)}),A)),u.listenersToRemove.add(r.registerCommand(J,(()=>{const t=g();if(!f(t)||!t.isCollapsed()||!Ge(t,e))return!1;const n=st(r,t,e);return!!n&&(lt(n,e),!0)}),A)),u}function Ue(e){return e[Le]||null}function ze(e){let t=e;for(;null!=t;){const e=t.nodeName;if("TD"===e||"TH"===e){const e=t._cell;return void 0===e?null:e}t=t.parentNode}return null}function Ye(e){const t=[],n={columns:0,domRows:t,rows:0};let o=e.firstChild,r=0,l=0;for(t.length=0;null!=o;){const e=o.nodeName;if("TD"===e||"TH"===e){const e={elem:o,hasBackgroundColor:""!==o.style.backgroundColor,highlighted:!1,x:r,y:l};o._cell=e;let n=t[l];void 0===n&&(n=t[l]=[]),n[r]=e}else{const e=o.firstChild;if(null!=e){o=e;continue}}const n=o.nextSibling;if(null!=n){r++,o=n;continue}const s=o.parentNode;if(null!=s){const e=s.nextSibling;if(null==e)break;l++,r=0,o=e}}return n.columns=r+1,n.rows=l+1,n}function Xe(e,t,n){const o=new Set(n?n.getNodes():[]);Je(t,((t,n)=>{const r=t.elem;o.has(n)?(t.highlighted=!0,Ze(e,t)):(t.highlighted=!1,et(e,t),r.getAttribute("style")||r.removeAttribute("style"))}))}function Je(e,t){const{domRows:n}=e;for(let e=0;e<n.length;e++){const o=n[e];if(o)for(let n=0;n<o.length;n++){const r=o[n];if(!r)continue;const l=b(r.elem);null!==l&&t(r,l,{x:n,y:e})}}}function $e(e,t){t.disableHighlightStyle(),Je(t.table,(t=>{t.highlighted=!0,Ze(e,t)}))}const je=(e,t,n,o,r)=>{const l="forward"===r;switch(r){case"backward":case"forward":return n!==(l?e.table.columns-1:0)?Qe(t.getCellNodeFromCordsOrThrow(n+(l?1:-1),o,e.table),l):o!==(l?e.table.rows-1:0)?Qe(t.getCellNodeFromCordsOrThrow(l?0:e.table.columns-1,o+(l?1:-1),e.table),l):l?t.selectNext():t.selectPrevious(),!0;case"up":return 0!==o?Qe(t.getCellNodeFromCordsOrThrow(n,o-1,e.table),!1):t.selectPrevious(),!0;case"down":return o!==e.table.rows-1?Qe(t.getCellNodeFromCordsOrThrow(n,o+1,e.table),!0):t.selectNext(),!0;default:return!1}},qe=(e,t,n,o,r)=>{const l="forward"===r;switch(r){case"backward":case"forward":return n!==(l?e.table.columns-1:0)&&e.setFocusCellForSelection(t.getDOMCellFromCordsOrThrow(n+(l?1:-1),o,e.table)),!0;case"up":return 0!==o&&(e.setFocusCellForSelection(t.getDOMCellFromCordsOrThrow(n,o-1,e.table)),!0);case"down":return o!==e.table.rows-1&&(e.setFocusCellForSelection(t.getDOMCellFromCordsOrThrow(n,o+1,e.table)),!0);default:return!1}};function Ge(e,t){if(f(e)||He(e)){const n=t.isParentOf(e.anchor.getNode()),o=t.isParentOf(e.focus.getNode());return n&&o}return!1}function Qe(e,t){t?e.selectStart():e.selectEnd()}const Ve="172,206,247";function Ze(e,t){const n=t.elem,o=b(n);ne(o)||ce(131);null===o.getBackgroundColor()?n.style.setProperty("background-color",`rgb(${Ve})`):n.style.setProperty("background-image",`linear-gradient(to right, rgba(${Ve},0.85), rgba(${Ve},0.85))`),n.style.setProperty("caret-color","transparent")}function et(e,t){const n=t.elem,o=b(n);ne(o)||ce(131);null===o.getBackgroundColor()&&n.style.removeProperty("background-color"),n.style.removeProperty("background-image"),n.style.removeProperty("caret-color")}function tt(e){const n=t(e,ne);return ne(n)?n:null}function nt(e){const n=t(e,ht);return ht(n)?n:null}function ot(e,n,o,r,l){if(("up"===o||"down"===o)&&function(e){const t=e.getRootElement();if(!t)return!1;return t.hasAttribute("aria-controls")&&"typeahead-menu"===t.getAttribute("aria-controls")}(e))return!1;const s=g();if(!Ge(s,r)){if(f(s)){if(s.isCollapsed()&&"backward"===o){const e=s.anchor.type,o=s.anchor.offset;if("element"!==e&&("text"!==e||0!==o))return!1;const r=s.anchor.getNode();if(!r)return!1;const l=t(r,(e=>i(e)&&!e.isInline()));if(!l)return!1;const a=l.getPreviousSibling();return!(!a||!ht(a))&&(rt(n),a.selectEnd(),!0)}if(n.shiftKey&&("up"===o||"down"===o)){const e=s.focus.getNode();if($(e)){const e=s.getNodes()[0];if(e){const n=t(e,ne);if(n&&r.isParentOf(n)){const e=r.getFirstDescendant(),t=r.getLastDescendant();if(!e||!t)return!1;const[n]=Fe(e),[o]=Fe(t),s=r.getCordsFromCellNode(n,l.table),i=r.getCordsFromCellNode(o,l.table),a=r.getDOMCellFromCordsOrThrow(s.x,s.y,l.table),c=r.getDOMCellFromCordsOrThrow(i.x,i.y,l.table);return l.setAnchorCellForSelection(a),l.setFocusCellForSelection(c,!0),!0}}return!1}{const n=t(e,(e=>i(e)&&!e.isInline()));if(!n)return!1;const r="down"===o?n.getNextSibling():n.getPreviousSibling();if(ht(r)&&l.tableNodeKey===r.getKey()){const e=r.getFirstDescendant(),t=r.getLastDescendant();if(!e||!t)return!1;const[n]=Fe(e),[l]=Fe(t),i=s.clone();return i.focus.set(("up"===o?n:l).getKey(),"up"===o?0:l.getChildrenSize(),"element"),C(i),!0}}}}return!1}if(f(s)&&s.isCollapsed()){const{anchor:a,focus:c}=s,u=t(a.getNode(),ne),d=t(c.getNode(),ne);if(!ne(u)||!u.is(d))return!1;const h=nt(u);if(h!==r&&null!=h){const t=e.getElementByKey(h.getKey());if(null!=t)return l.table=Ye(t),ot(e,n,o,h,l)}if("backward"===o||"forward"===o){const e=a.type,l=a.offset,c=a.getNode();if(!c)return!1;const u=s.getNodes();return(1!==u.length||!j(u[0]))&&(!!function(e,n,o,r){return function(e,t,n){return"element"===e&&("backward"===n?null===t.getPreviousSibling():null===t.getNextSibling())}(e,o,r)||function(e,n,o,r){const l=t(o,(e=>i(e)&&!e.isInline()));if(!l)return!1;const s="backward"===r?0===n:n===o.getTextContentSize();return"text"===e&&s&&("backward"===r?null===l.getPreviousSibling():null===l.getNextSibling())}(e,n,o,r)}(e,l,c,o)&&function(e,n,o,r){const l=t(n,ne);if(!ne(l))return!1;const[s,a]=Me(o,l,l);if(!function(e,t,n){const o=e[0][0],r=e[e.length-1][e[0].length-1],{startColumn:l,startRow:s}=t;return"backward"===n?l===o.startColumn&&s===o.startRow:l===r.startColumn&&s===r.startRow}(s,a,r))return!1;const c=function(e,n,o){const r=t(e,(e=>i(e)&&!e.isInline()));if(!r)return;const l="backward"===n?r.getPreviousSibling():r.getNextSibling();return l&&ht(l)?l:"backward"===n?o.getPreviousSibling():o.getNextSibling()}(n,r,o);if(!c||ht(c))return!1;rt(e),"backward"===r?c.selectEnd():c.selectStart();return!0}(n,c,r,o))}const g=e.getElementByKey(u.__key),f=e.getElementByKey(a.key);if(null==f||null==g)return!1;let m;if("element"===a.type)m=f.getBoundingClientRect();else{const e=window.getSelection();if(null===e||0===e.rangeCount)return!1;m=e.getRangeAt(0).getBoundingClientRect()}const p="up"===o?u.getFirstChild():u.getLastChild();if(null==p)return!1;const S=e.getElementByKey(p.__key);if(null==S)return!1;const _=S.getBoundingClientRect();if("up"===o?_.top>m.top-m.height:m.bottom+m.height>_.bottom){rt(n);const e=r.getCordsFromCellNode(u,l.table);if(!n.shiftKey)return je(l,r,e.x,e.y,o);{const t=r.getDOMCellFromCordsOrThrow(e.x,e.y,l.table);l.setAnchorCellForSelection(t),l.setFocusCellForSelection(t,!0)}return!0}}else if(He(s)){const{anchor:i,focus:a}=s,c=t(i.getNode(),ne),u=t(a.getNode(),ne),[d]=s.getNodes(),h=e.getElementByKey(d.getKey());if(!ne(c)||!ne(u)||!ht(d)||null==h)return!1;l.updateTableTableSelection(s);const g=Ye(h),f=r.getCordsFromCellNode(c,g),m=r.getDOMCellFromCordsOrThrow(f.x,f.y,g);if(l.setAnchorCellForSelection(m),rt(n),n.shiftKey){const e=r.getCordsFromCellNode(u,g);return qe(l,d,e.x,e.y,o)}return u.selectEnd(),!0}return!1}function rt(e){e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation()}function lt(e,t,n){const o=s();"first"===e?t.insertBefore(o):t.insertAfter(o),o.append(...n||[]),o.selectEnd()}function st(e,n,o){const r=o.getParent();if(!r)return;const l=e.getElementByKey(r.getKey());if(!l)return;const s=window.getSelection();if(!s||s.anchorNode!==l)return;const i=t(n.anchor.getNode(),(e=>ne(e)));if(!i)return;const a=t(i,(e=>ht(e)));if(!ht(a)||!a.is(o))return;const[c,u]=Me(o,i,i),d=c[0][0],h=c[c.length-1][c[0].length-1],{startRow:g,startColumn:f}=u,m=g===d.startRow&&f===d.startColumn,p=g===h.startRow&&f===h.startColumn;return m?"first":p?"last":void 0}function it(t,o,r){r?(e(t,o.theme.tableRowStriping),t.setAttribute("data-lexical-row-striping","true")):(n(t,o.theme.tableRowStriping),t.removeAttribute("data-lexical-row-striping"))}class at extends l{static getType(){return"table"}static clone(e){return new at(e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__rowStriping=e.__rowStriping}static importDOM(){return{table:e=>({conversion:ut,priority:1})}}static importJSON(e){const t=dt();return t.__rowStriping=e.rowStriping||!1,t}constructor(e){super(e),this.__rowStriping=!1}exportJSON(){return{...super.exportJSON(),rowStriping:this.__rowStriping?this.__rowStriping:void 0,type:"table",version:1}}createDOM(t,n){const o=document.createElement("table");return e(o,t.theme.table),this.__rowStriping&&it(o,t,!0),o}updateDOM(e,t,n){return e.__rowStriping!==this.__rowStriping&&it(t,n,this.__rowStriping),!1}exportDOM(e){return{...super.exportDOM(e),after:e=>{if(e){const t=e.cloneNode(),n=document.createElement("colgroup"),o=document.createElement("tbody");r(e)&&o.append(...e.children);const l=this.getFirstChildOrThrow();if(!ie(l))throw new Error("Expected to find row node.");const s=l.getChildrenSize();for(let e=0;e<s;e++){const e=document.createElement("col");n.append(e)}return t.replaceChildren(n,o),t}}}}canBeEmpty(){return!1}isShadowRoot(){return!0}getCordsFromCellNode(e,t){const{rows:n,domRows:o}=t;for(let t=0;t<n;t++){const n=o[t];if(null==n)continue;const r=n.findIndex((t=>{if(!t)return;const{elem:n}=t;return b(n)===e}));if(-1!==r)return{x:r,y:t}}throw new Error("Cell not found in table.")}getDOMCellFromCords(e,t,n){const{domRows:o}=n,r=o[t];if(null==r)return null;const l=r[e<r.length?e:r.length-1];return null==l?null:l}getDOMCellFromCordsOrThrow(e,t,n){const o=this.getDOMCellFromCords(e,t,n);if(!o)throw new Error("Cell not found at cords.");return o}getCellNodeFromCords(e,t,n){const o=this.getDOMCellFromCords(e,t,n);if(null==o)return null;const r=b(o.elem);return ne(r)?r:null}getCellNodeFromCordsOrThrow(e,t,n){const o=this.getCellNodeFromCords(e,t,n);if(!o)throw new Error("Node at cords not TableCellNode.");return o}getRowStriping(){return Boolean(this.getLatest().__rowStriping)}setRowStriping(e){this.getWritable().__rowStriping=e}canSelectBefore(){return!0}canIndent(){return!1}}function ct(e,t){const n=e.getElementByKey(t.getKey());if(null==n)throw new Error("Table Element Not Found");return Ye(n)}function ut(e){const t=dt();return e.hasAttribute("data-lexical-row-striping")&&t.setRowStriping(!0),{node:t}}function dt(){return u(new at)}function ht(e){return e instanceof at}export{Me as $computeTableMap,Ke as $computeTableMapSkipCellCheck,te as $createTableCellNode,dt as $createTableNode,de as $createTableNodeWithDimensions,se as $createTableRowNode,Be as $createTableSelection,xe as $deleteTableColumn,ve as $deleteTableColumn__EXPERIMENTAL,Te as $deleteTableRow__EXPERIMENTAL,tt as $findCellNode,nt as $findTableNode,ct as $getElementForTableNode,Fe as $getNodeTriplet,he as $getTableCellNodeFromLexicalNode,ke as $getTableCellNodeRect,pe as $getTableColumnIndexFromTableCellNode,fe as $getTableNodeFromLexicalNodeOrThrow,me as $getTableRowIndexFromTableCellNode,ge as $getTableRowNodeFromTableCellNodeOrThrow,ye as $insertTableColumn,Ne as $insertTableColumn__EXPERIMENTAL,Ce as $insertTableRow,be as $insertTableRow__EXPERIMENTAL,ne as $isTableCellNode,ht as $isTableNode,ie as $isTableRowNode,He as $isTableSelection,_e as $removeTableRowAtIndex,Re as $unmergeCell,oe as INSERT_TABLE_COMMAND,V as TableCellHeaderStates,Z as TableCellNode,at as TableNode,Pe as TableObserver,re as TableRowNode,We as applyTableHandlers,ze as getDOMCellFromTarget,Ue as getTableObserverFromTableElement};
package/package.json CHANGED
@@ -8,13 +8,13 @@
8
8
  "table"
9
9
  ],
10
10
  "license": "MIT",
11
- "version": "0.17.2-nightly.20240912.0",
11
+ "version": "0.17.2-nightly.20240916.0",
12
12
  "main": "LexicalTable.js",
13
13
  "types": "index.d.ts",
14
14
  "dependencies": {
15
- "@lexical/clipboard": "0.17.2-nightly.20240912.0",
16
- "@lexical/utils": "0.17.2-nightly.20240912.0",
17
- "lexical": "0.17.2-nightly.20240912.0"
15
+ "@lexical/clipboard": "0.17.2-nightly.20240916.0",
16
+ "@lexical/utils": "0.17.2-nightly.20240916.0",
17
+ "lexical": "0.17.2-nightly.20240916.0"
18
18
  },
19
19
  "repository": {
20
20
  "type": "git",