Socket
Socket
Sign inDemoInstall

@lexical/table

Package Overview
Dependencies
Maintainers
8
Versions
184
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lexical/table - npm Package Compare versions

Comparing version 0.12.6 to 0.13.0

LexicalTableCommands.d.ts

27

index.d.ts

@@ -9,25 +9,16 @@ /** @module @lexical/table */

*/
import type { LexicalCommand } from 'lexical';
export type { GridSelection, GridSelectionShape } from './LexicalGridSelection';
export { $createGridSelection, $isGridSelection } from './LexicalGridSelection';
export type { SerializedTableCellNode } from './LexicalTableCellNode';
export { $createTableCellNode, $isTableCellNode, TableCellHeaderStates, TableCellNode, } from './LexicalTableCellNode';
export type { InsertTableCommandPayload, InsertTableCommandPayloadHeaders, } from './LexicalTableCommands';
export { INSERT_TABLE_COMMAND } from './LexicalTableCommands';
export type { SerializedTableNode } from './LexicalTableNode';
export { $createTableNode, $getElementGridForTableNode, $isTableNode, TableNode, } from './LexicalTableNode';
export { $createTableNode, $getElementForTableNode, $isTableNode, TableNode, } from './LexicalTableNode';
export type { TableDOMCell } from './LexicalTableObserver';
export { TableObserver } from './LexicalTableObserver';
export type { SerializedTableRowNode } from './LexicalTableRowNode';
export { $createTableRowNode, $isTableRowNode, TableRowNode, } from './LexicalTableRowNode';
export type { Cell } from './LexicalTableSelection';
export { TableSelection } from './LexicalTableSelection';
export type { TableSelection, TableSelectionShape, } from './LexicalTableSelection';
export { $createTableSelection, $isTableSelection, } from './LexicalTableSelection';
export type { HTMLTableElementWithWithTableSelectionState } from './LexicalTableSelectionHelpers';
export { applyTableHandlers, getCellFromTarget, getTableSelectionFromTableElement, } from './LexicalTableSelectionHelpers';
export { $createTableNodeWithDimensions, $deleteTableColumn, $deleteTableColumn__EXPERIMENTAL, $deleteTableRow__EXPERIMENTAL, $getTableCellNodeFromLexicalNode, $getTableColumnIndexFromTableCellNode, $getTableNodeFromLexicalNodeOrThrow, $getTableRowIndexFromTableCellNode, $getTableRowNodeFromTableCellNodeOrThrow, $insertTableColumn, $insertTableColumn__EXPERIMENTAL, $insertTableRow, $insertTableRow__EXPERIMENTAL, $removeTableRowAtIndex, $unmergeCell, } from './LexicalTableUtils';
export type InsertTableCommandPayloadHeaders = Readonly<{
rows: boolean;
columns: boolean;
}> | boolean;
export type InsertTableCommandPayload = Readonly<{
columns: string;
rows: string;
includeHeaders?: InsertTableCommandPayloadHeaders;
}>;
export declare const INSERT_TABLE_COMMAND: LexicalCommand<InsertTableCommandPayload>;
export { applyTableHandlers, getDOMCellFromTarget, getTableObserverFromTableElement, } from './LexicalTableSelectionHelpers';
export { $computeTableMap, $createTableNodeWithDimensions, $deleteTableColumn, $deleteTableColumn__EXPERIMENTAL, $deleteTableRow__EXPERIMENTAL, $getNodeTriplet, $getTableCellNodeFromLexicalNode, $getTableCellNodeRect, $getTableColumnIndexFromTableCellNode, $getTableNodeFromLexicalNodeOrThrow, $getTableRowIndexFromTableCellNode, $getTableRowNodeFromTableCellNodeOrThrow, $insertTableColumn, $insertTableColumn__EXPERIMENTAL, $insertTableRow, $insertTableRow__EXPERIMENTAL, $removeTableRowAtIndex, $unmergeCell, } from './LexicalTableUtils';

@@ -7,76 +7,80 @@ /**

*/
'use strict';var d=require("lexical"),v=require("@lexical/utils");function w(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.");}
class y extends d.INTERNAL_PointSelection{constructor(a,b,c){super(b,c);this.gridKey=a}getCachedNodes(){return this._cachedNodes}setCachedNodes(a){this._cachedNodes=a}is(a){return z(a)?this.gridKey===a.gridKey&&this.anchor.is(a.anchor)&&this.focus.is(a.focus):!1}set(a,b,c){this.dirty=!0;this.gridKey=a;this.anchor.key=b;this.focus.key=c;this._cachedNodes=null}clone(){return new y(this.gridKey,this.anchor,this.focus)}isCollapsed(){return!1}extract(){return this.getNodes()}insertRawText(){}insertText(){}insertNodes(a){let b=
this.focus.getNode();if(!d.$isElementNode(b))throw Error("Expected GridSelection focus to be an ElementNode");d.$normalizeSelection__EXPERIMENTAL(b.select(0,b.getChildrenSize())).insertNodes(a)}getShape(){var a=d.$getNodeByKey(this.anchor.key);d.DEPRECATED_$isGridCellNode(a)||w(103);a=d.DEPRECATED_$getGridCellNodeRect(a);if(null===a)throw Error("getCellRect: expected to find AnchorNode");var b=d.$getNodeByKey(this.focus.key);d.DEPRECATED_$isGridCellNode(b)||w(104);let c=d.DEPRECATED_$getGridCellNodeRect(b);
if(null===c)throw Error("getCellRect: expected to find focusCellNode");b=Math.min(a.columnIndex,c.columnIndex);let e=Math.max(a.columnIndex,c.columnIndex),f=Math.min(a.rowIndex,c.rowIndex);a=Math.max(a.rowIndex,c.rowIndex);return{fromX:Math.min(b,e),fromY:Math.min(f,a),toX:Math.max(b,e),toY:Math.max(f,a)}}getNodes(){function a(t){let {cell:x,startColumn:B,startRow:C}=t;q=Math.min(q,B);u=Math.min(u,C);h=Math.max(h,B+x.__colSpan-1);l=Math.max(l,C+x.__rowSpan-1)}var b=this._cachedNodes;if(null!==b)return b;
var c=this.anchor.getNode();b=this.focus.getNode();var e=v.$findMatchingParent(c,d.DEPRECATED_$isGridCellNode);c=v.$findMatchingParent(b,d.DEPRECATED_$isGridCellNode);d.DEPRECATED_$isGridCellNode(e)||w(103);d.DEPRECATED_$isGridCellNode(c)||w(104);b=e.getParent();d.DEPRECATED_$isGridRowNode(b)||w(105);b=b.getParent();d.DEPRECATED_$isGridNode(b)||w(106);var f=c.getParents()[1];if(f!==b){if(b.isParentOf(c)){b=f.getParent();if(null==b)throw Error("Expected focusCellParent to have a parent");this.set(this.gridKey,
c.getKey(),b.getKey())}else{b=b.getParent();if(null==b)throw Error("Expected gridParent to have a parent");this.set(this.gridKey,b.getKey(),c.getKey())}return this.getNodes()}let [k,g,m]=d.DEPRECATED_$computeGridMap(b,e,c),q=Math.min(g.startColumn,m.startColumn),u=Math.min(g.startRow,m.startRow),h=Math.max(g.startColumn+g.cell.__colSpan-1,m.startColumn+m.cell.__colSpan-1),l=Math.max(g.startRow+g.cell.__rowSpan-1,m.startRow+m.cell.__rowSpan-1);c=q;e=u;f=q;for(var n=u;q<c||u<e||h>f||l>n;){if(q<c){var p=
n-e;--c;for(var r=0;r<=p;r++)a(k[e+r][c])}if(u<e)for(p=f-c,--e,r=0;r<=p;r++)a(k[e][c+r]);if(h>f)for(p=n-e,f+=1,r=0;r<=p;r++)a(k[e+r][f]);if(l>n)for(p=f-c,n+=1,r=0;r<=p;r++)a(k[n][c+r])}b=[b];c=null;for(e=u;e<=l;e++)for(f=q;f<=h;f++)({cell:n}=k[e][f]),p=n.getParent(),d.DEPRECATED_$isGridRowNode(p)||w(107),p!==c&&b.push(p),b.push(n,...aa(n)),c=p;d.isCurrentlyReadOnlyMode()||(this._cachedNodes=b);return b}getTextContent(){let a=this.getNodes(),b="";for(let c=0;c<a.length;c++)b+=a[c].getTextContent();
return b}}function z(a){return a instanceof y}function A(){let a=d.$createPoint("root",0,"element"),b=d.$createPoint("root",0,"element");return new y("root",a,b)}function aa(a){let b=[],c=[a];for(;0<c.length;){let e=c.pop();void 0===e&&w(112);d.$isElementNode(e)&&c.unshift(...e.getChildren());e!==a&&b.push(e)}return b}let ba=/^(\d+(?:\.\d+)?)px$/,D={BOTH:3,COLUMN:2,NO_STATUS:0,ROW:1};
class F extends d.DEPRECATED_GridCellNode{static getType(){return"tablecell"}static clone(a){let b=new F(a.__headerState,a.__colSpan,a.__width,a.__key);b.__rowSpan=a.__rowSpan;b.__backgroundColor=a.__backgroundColor;return b}static importDOM(){return{td:()=>({conversion:ca,priority:0}),th:()=>({conversion:ca,priority:0})}}static importJSON(a){let b=a.rowSpan||1,c=G(a.headerState,a.colSpan||1,a.width||void 0);c.__rowSpan=b;c.__backgroundColor=a.backgroundColor||null;return c}constructor(a=D.NO_STATUS,
b=1,c,e){super(b,e);this.__headerState=a;this.__width=c;this.__backgroundColor=null}createDOM(a){let b=document.createElement(this.getTag());this.__width&&(b.style.width=`${this.__width}px`);1<this.__colSpan&&(b.colSpan=this.__colSpan);1<this.__rowSpan&&(b.rowSpan=this.__rowSpan);null!==this.__backgroundColor&&(b.style.backgroundColor=this.__backgroundColor);v.addClassNamesToElement(b,a.theme.tableCell,this.hasHeader()&&a.theme.tableCellHeader);return b}exportDOM(a){({element:a}=super.exportDOM(a));
'use strict';var h=require("@lexical/utils"),v=require("lexical");let ba=/^(\d+(?:\.\d+)?)px$/,w={BOTH:3,COLUMN:2,NO_STATUS:0,ROW:1};
class x extends v.ElementNode{static getType(){return"tablecell"}static clone(a){let b=new x(a.__headerState,a.__colSpan,a.__width,a.__key);b.__rowSpan=a.__rowSpan;b.__backgroundColor=a.__backgroundColor;return b}static importDOM(){return{td:()=>({conversion:ca,priority:0}),th:()=>({conversion:ca,priority:0})}}static importJSON(a){let b=a.rowSpan||1,c=z(a.headerState,a.colSpan||1,a.width||void 0);c.__rowSpan=b;c.__backgroundColor=a.backgroundColor||null;return c}constructor(a=w.NO_STATUS,b=1,c,d){super(d);
this.__colSpan=b;this.__rowSpan=1;this.__headerState=a;this.__width=c;this.__backgroundColor=null}createDOM(a){let b=document.createElement(this.getTag());this.__width&&(b.style.width=`${this.__width}px`);1<this.__colSpan&&(b.colSpan=this.__colSpan);1<this.__rowSpan&&(b.rowSpan=this.__rowSpan);null!==this.__backgroundColor&&(b.style.backgroundColor=this.__backgroundColor);h.addClassNamesToElement(b,a.theme.tableCell,this.hasHeader()&&a.theme.tableCellHeader);return b}exportDOM(a){({element:a}=super.exportDOM(a));
if(a){var b=this.getParentOrThrow().getChildrenSize();a.style.border="1px solid black";1<this.__colSpan&&(a.colSpan=this.__colSpan);1<this.__rowSpan&&(a.rowSpan=this.__rowSpan);a.style.width=`${this.getWidth()||Math.max(90,700/b)}px`;a.style.verticalAlign="top";a.style.textAlign="start";b=this.getBackgroundColor();null!==b?a.style.backgroundColor=b:this.hasHeader()&&(a.style.backgroundColor="#f2f3f5")}return{element:a}}exportJSON(){return{...super.exportJSON(),backgroundColor:this.getBackgroundColor(),
headerState:this.__headerState,type:"tablecell",width:this.getWidth()}}getTag(){return this.hasHeader()?"th":"td"}setHeaderStyles(a){this.getWritable().__headerState=a;return this.__headerState}getHeaderStyles(){return this.getLatest().__headerState}setWidth(a){this.getWritable().__width=a;return this.__width}getWidth(){return this.getLatest().__width}getBackgroundColor(){return this.getLatest().__backgroundColor}setBackgroundColor(a){this.getWritable().__backgroundColor=a}toggleHeaderStyle(a){let b=
this.getWritable();b.__headerState=(b.__headerState&a)===a?b.__headerState-a:b.__headerState+a;return b}hasHeaderState(a){return(this.getHeaderStyles()&a)===a}hasHeader(){return this.getLatest().__headerState!==D.NO_STATUS}updateDOM(a){return a.__headerState!==this.__headerState||a.__width!==this.__width||a.__colSpan!==this.__colSpan||a.__rowSpan!==this.__rowSpan||a.__backgroundColor!==this.__backgroundColor}isShadowRoot(){return!0}collapseAtStart(){return!0}canBeEmpty(){return!1}canIndent(){return!1}}
function ca(a){var b=a.nodeName.toLowerCase();let c=void 0;ba.test(a.style.width)&&(c=parseFloat(a.style.width));b=G("th"===b?D.ROW:D.NO_STATUS,a.colSpan,c);b.__rowSpan=a.rowSpan;a=a.style.backgroundColor;""!==a&&(b.__backgroundColor=a);return{forChild:(e,f)=>{if(H(f)&&!d.$isElementNode(e)){f=d.$createParagraphNode();if(d.$isLineBreakNode(e)&&"\n"===e.getTextContent())return null;f.append(e);return f}return e},node:b}}function G(a,b=1,c){return d.$applyNodeReplacement(new F(a,b,c))}
function H(a){return a instanceof F}
class J extends d.DEPRECATED_GridRowNode{static getType(){return"tablerow"}static clone(a){return new J(a.__height,a.__key)}static importDOM(){return{tr:()=>({conversion:da,priority:0})}}static importJSON(a){return K(a.height)}constructor(a,b){super(b);this.__height=a}exportJSON(){return{...super.exportJSON(),type:"tablerow",version:1}}createDOM(a){let b=document.createElement("tr");this.__height&&(b.style.height=`${this.__height}px`);v.addClassNamesToElement(b,a.theme.tableRow);return b}isShadowRoot(){return!0}setHeight(a){this.getWritable().__height=
a;return this.__height}getHeight(){return this.getLatest().__height}updateDOM(a){return a.__height!==this.__height}canBeEmpty(){return!1}canIndent(){return!1}}function da(a){let b=void 0;ba.test(a.style.height)&&(b=parseFloat(a.style.height));return{node:K(b)}}function K(a){return d.$applyNodeReplacement(new J(a))}function L(a){return a instanceof J}let ea="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement;
class fa{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.grid={cells:[],columns:0,rows:0};this.focusCell=this.anchorCell=this.focusCellNodeKey=this.anchorCellNodeKey=this.gridSelection=null;this.hasHijackedSelectionStyles=!1;this.trackTableGrid()}getGrid(){return this.grid}removeListeners(){Array.from(this.listenersToRemove).forEach(a=>a())}trackTableGrid(){let a=new MutationObserver(b=>
{this.editor.update(()=>{var c=!1;for(let e=0;e<b.length;e++){const f=b[e].target.nodeName;if("TABLE"===f||"TR"===f){c=!0;break}}if(c){c=this.editor.getElementByKey(this.tableNodeKey);if(!c)throw Error("Expected to find TableElement in DOM");this.grid=M(c)}})});this.editor.update(()=>{let b=this.editor.getElementByKey(this.tableNodeKey);if(!b)throw Error("Expected to find TableElement in DOM");this.grid=M(b);a.observe(b,{childList:!0,subtree:!0})})}clearHighlight(){let a=this.editor;this.isHighlightingCells=
!1;this.focusY=this.focusX=this.anchorY=this.anchorX=-1;this.focusCell=this.anchorCell=this.focusCellNodeKey=this.anchorCellNodeKey=this.gridSelection=null;this.hasHijackedSelectionStyles=!1;this.enableHighlightStyle();a.update(()=>{var b=d.$getNodeByKey(this.tableNodeKey);if(!N(b))throw Error("Expected TableNode.");b=a.getElementByKey(this.tableNodeKey);if(!b)throw Error("Expected to find TableElement in DOM");b=M(b);R(a,b,null);d.$setSelection(null);a.dispatchCommand(d.SELECTION_CHANGE_COMMAND,
void 0)})}enableHighlightStyle(){let a=this.editor;a.update(()=>{let b=a.getElementByKey(this.tableNodeKey);if(!b)throw Error("Expected to find TableElement in DOM");v.removeClassNamesFromElement(b,a._config.theme.tableSelection);b.classList.remove("disable-selection");this.hasHijackedSelectionStyles=!1})}disableHighlightStyle(){let a=this.editor;a.update(()=>{let b=a.getElementByKey(this.tableNodeKey);if(!b)throw Error("Expected to find TableElement in DOM");v.addClassNamesToElement(b,a._config.theme.tableSelection);
this.hasHijackedSelectionStyles=!0})}updateTableGridSelection(a){if(null!=a&&a.gridKey===this.tableNodeKey){let b=this.editor;this.gridSelection=a;this.isHighlightingCells=!0;this.disableHighlightStyle();R(b,this.grid,this.gridSelection)}else null==a?this.clearHighlight():(this.tableNodeKey=a.gridKey,this.updateTableGridSelection(a))}setFocusCellForSelection(a,b=!1){let c=this.editor;c.update(()=>{var e=d.$getNodeByKey(this.tableNodeKey);if(!N(e))throw Error("Expected TableNode.");if(!c.getElementByKey(this.tableNodeKey))throw Error("Expected to find TableElement in DOM");
e=a.x;let f=a.y;this.focusCell=a;if(null!==this.anchorCell){let k=ea?(c._window||window).getSelection():null;k&&k.setBaseAndExtent(this.anchorCell.elem,0,this.focusCell.elem,0)}if(!this.isHighlightingCells&&(this.anchorX!==e||this.anchorY!==f||b))this.isHighlightingCells=!0,this.disableHighlightStyle();else if(e===this.focusX&&f===this.focusY)return;this.focusX=e;this.focusY=f;this.isHighlightingCells&&(e=d.$getNearestNodeFromDOMNode(a.elem),null!=this.gridSelection&&null!=this.anchorCellNodeKey&&
H(e)&&(e=e.getKey(),this.gridSelection=this.gridSelection.clone()||A(),this.focusCellNodeKey=e,this.gridSelection.set(this.tableNodeKey,this.anchorCellNodeKey,this.focusCellNodeKey),d.$setSelection(this.gridSelection),c.dispatchCommand(d.SELECTION_CHANGE_COMMAND,void 0),R(c,this.grid,this.gridSelection)))})}setAnchorCellForSelection(a){this.isHighlightingCells=!1;this.anchorCell=a;this.anchorX=a.x;this.anchorY=a.y;this.editor.update(()=>{var b=d.$getNearestNodeFromDOMNode(a.elem);H(b)&&(b=b.getKey(),
this.gridSelection=null!=this.gridSelection?this.gridSelection.clone():A(),this.anchorCellNodeKey=b)})}formatCells(a){this.editor.update(()=>{let b=d.$getSelection();z(b)||w(11);let c=d.$createRangeSelection(),e=c.anchor,f=c.focus;b.getNodes().forEach(k=>{H(k)&&0!==k.getTextContentSize()&&(e.set(k.getKey(),0,"element"),f.set(k.getKey(),k.getChildrenSize(),"element"),c.formatText(a))});d.$setSelection(b);this.editor.dispatchCommand(d.SELECTION_CHANGE_COMMAND,void 0)})}clearText(){let a=this.editor;
a.update(()=>{let b=d.$getNodeByKey(this.tableNodeKey);if(!N(b))throw Error("Expected TableNode.");var c=d.$getSelection();z(c)||w(11);c=c.getNodes().filter(H);c.length===this.grid.columns*this.grid.rows?(b.selectPrevious(),b.remove(),d.$getRoot().selectStart()):(c.forEach(e=>{if(d.$isElementNode(e)){let f=d.$createParagraphNode(),k=d.$createTextNode();f.append(k);e.append(f);e.getChildren().forEach(g=>{g!==f&&g.remove()})}}),R(a,this.grid,null),d.$setSelection(null),a.dispatchCommand(d.SELECTION_CHANGE_COMMAND,
void 0))})}}function ha(a){for(;null!=a;){let b=a.nodeName;if("TD"===b||"TH"===b){a=a._cell;if(void 0===a)break;return a}a=a.parentNode}return null}
function M(a){let b=[],c={cells:b,columns:0,rows:0};var e=a.firstChild;let f=a=0;for(b.length=0;null!=e;){var k=e.nodeName;if("TD"===k||"TH"===k){k=e;k={elem:k,hasBackgroundColor:""!==k.style.backgroundColor,highlighted:!1,x:a,y:f};e._cell=k;let g=b[f];void 0===g&&(g=b[f]=[]);g[a]=k}else if(k=e.firstChild,null!=k){e=k;continue}k=e.nextSibling;if(null!=k)a++,e=k;else if(k=e.parentNode,null!=k){e=k.nextSibling;if(null==e)break;f++;a=0}}c.columns=a+1;c.rows=f+1;return c}
function R(a,b,c){let e=new Set(c?c.getNodes():[]);ka(b,(f,k)=>{let g=f.elem;e.has(k)?(f.highlighted=!0,la(a,f)):(f.highlighted=!1,ma(a,f),g.getAttribute("style")||g.removeAttribute("style"))})}function ka(a,b){({cells:a}=a);for(let c=0;c<a.length;c++){let e=a[c];if(e)for(let f=0;f<e.length;f++){let k=e[f];if(!k)continue;let g=d.$getNearestNodeFromDOMNode(k.elem);null!==g&&b(k,g,{x:f,y:c})}}}function na(a,b){b.disableHighlightStyle();ka(b.grid,c=>{c.highlighted=!0;la(a,c)})}
function oa(a,b){b.enableHighlightStyle();ka(b.grid,c=>{let e=c.elem;c.highlighted=!1;ma(a,c);e.getAttribute("style")||e.removeAttribute("style")})}
let pa=(a,b,c,e,f)=>{const k="forward"===f;switch(f){case "backward":case "forward":return c!==(k?a.grid.columns-1:0)?(a=b.getCellNodeFromCordsOrThrow(c+(k?1:-1),e,a.grid),k?a.selectStart():a.selectEnd()):e!==(k?a.grid.rows-1:0)?(a=b.getCellNodeFromCordsOrThrow(k?0:a.grid.columns-1,e+(k?1:-1),a.grid),k?a.selectStart():a.selectEnd()):k?b.selectNext():b.selectPrevious(),!0;case "up":return 0!==e?b.getCellNodeFromCordsOrThrow(c,e-1,a.grid).selectEnd():b.selectPrevious(),!0;case "down":return e!==a.grid.rows-
1?b.getCellNodeFromCordsOrThrow(c,e+1,a.grid).selectStart():b.selectNext(),!0;default:return!1}},qa=(a,b,c,e,f)=>{const k="forward"===f;switch(f){case "backward":case "forward":return c!==(k?a.grid.columns-1:0)&&a.setFocusCellForSelection(b.getCellFromCordsOrThrow(c+(k?1:-1),e,a.grid)),!0;case "up":return 0!==e?(a.setFocusCellForSelection(b.getCellFromCordsOrThrow(c,e-1,a.grid)),!0):!1;case "down":return e!==a.grid.rows-1?(a.setFocusCellForSelection(b.getCellFromCordsOrThrow(c,e+1,a.grid)),!0):!1;
default:return!1}};function S(a,b){if(d.$isRangeSelection(a)||z(a)){let c=b.isParentOf(a.anchor.getNode());a=b.isParentOf(a.focus.getNode());return c&&a}return!1}function la(a,b){a=b.elem;b=d.$getNearestNodeFromDOMNode(a);H(b)||w(131);null===b.getBackgroundColor()?a.style.setProperty("background-color","rgb(172,206,247)"):a.style.setProperty("background-image","linear-gradient(to right, rgba(172,206,247,0.85), rgba(172,206,247,0.85))");a.style.setProperty("caret-color","transparent")}
function ma(a,b){a=b.elem;b=d.$getNearestNodeFromDOMNode(a);H(b)||w(131);null===b.getBackgroundColor()&&a.style.removeProperty("background-color");a.style.removeProperty("background-image");a.style.removeProperty("caret-color")}function ra(a){a=v.$findMatchingParent(a,H);return H(a)?a:null}function ta(a){a=v.$findMatchingParent(a,N);return N(a)?a:null}
function T(a,b,c,e,f){let k=d.$getSelection();if(!S(k,e))return!1;if(d.$isRangeSelection(k)&&k.isCollapsed()){if("backward"===c||"forward"===c)return!1;let {anchor:u,focus:h}=k;var g=v.$findMatchingParent(u.getNode(),H),m=v.$findMatchingParent(h.getNode(),H);if(!H(g)||!g.is(m))return!1;m=ta(g);if(m!==e&&null!=m){var q=a.getElementByKey(m.getKey());if(null!=q)return f.grid=M(q),T(a,b,c,m,f)}m=a.getElementByKey(g.__key);q=a.getElementByKey(u.key);if(null==q||null==m)return!1;if("element"===u.type)m=
q.getBoundingClientRect();else{m=window.getSelection();if(null===m||0===m.rangeCount)return!1;m=m.getRangeAt(0).getBoundingClientRect()}q="up"===c?g.getFirstChild():g.getLastChild();if(null==q)return!1;a=a.getElementByKey(q.__key);if(null==a)return!1;a=a.getBoundingClientRect();if("up"===c?a.top>m.top-m.height:m.bottom+m.height>a.bottom){U(b);a=e.getCordsFromCellNode(g,f.grid);if(b.shiftKey)c=e.getCellFromCordsOrThrow(a.x,a.y,f.grid),f.setAnchorCellForSelection(c),f.setFocusCellForSelection(c,!0);
else return pa(f,e,a.x,a.y,c);return!0}}else if(z(k)){let {anchor:u,focus:h}=k;q=v.$findMatchingParent(u.getNode(),H);m=v.$findMatchingParent(h.getNode(),H);[g]=k.getNodes();a=a.getElementByKey(g.getKey());if(!H(q)||!H(m)||!N(g)||null==a)return!1;f.updateTableGridSelection(k);a=M(a);q=e.getCordsFromCellNode(q,a);q=e.getCellFromCordsOrThrow(q.x,q.y,a);f.setAnchorCellForSelection(q);U(b);if(b.shiftKey)return b=e.getCordsFromCellNode(m,a),qa(f,g,b.x,b.y,c);m.selectEnd();return!0}return!1}
function U(a){a.preventDefault();a.stopImmediatePropagation();a.stopPropagation()}
class V extends d.DEPRECATED_GridNode{static getType(){return"table"}static clone(a){return new V(a.__key)}static importDOM(){return{table:()=>({conversion:ua,priority:1})}}static importJSON(){return W()}constructor(a){super(a)}exportJSON(){return{...super.exportJSON(),type:"table",version:1}}createDOM(a){let b=document.createElement("table");v.addClassNamesToElement(b,a.theme.table);return b}updateDOM(){return!1}exportDOM(a){return{...super.exportDOM(a),after:b=>{if(b){let c=b.cloneNode(),e=document.createElement("colgroup"),
f=document.createElement("tbody");v.isHTMLElement(b)&&f.append(...b.children);b=this.getFirstChildOrThrow();if(!L(b))throw Error("Expected to find row node.");b=b.getChildrenSize();for(let k=0;k<b;k++){let g=document.createElement("col");e.append(g)}c.replaceChildren(e,f);return c}}}}canExtractContents(){return!1}canBeEmpty(){return!1}isShadowRoot(){return!0}getCordsFromCellNode(a,b){let {rows:c,cells:e}=b;for(b=0;b<c;b++){var f=e[b];if(null!=f&&(f=f.findIndex(k=>{if(k)return{elem:k}=k,d.$getNearestNodeFromDOMNode(k)===
a}),-1!==f))return{x:f,y:b}}throw Error("Cell not found in table.");}getCellFromCords(a,b,c){({cells:c}=c);b=c[b];if(null==b)return null;a=b[a];return null==a?null:a}getCellFromCordsOrThrow(a,b,c){a=this.getCellFromCords(a,b,c);if(!a)throw Error("Cell not found at cords.");return a}getCellNodeFromCords(a,b,c){a=this.getCellFromCords(a,b,c);if(null==a)return null;a=d.$getNearestNodeFromDOMNode(a.elem);return H(a)?a:null}getCellNodeFromCordsOrThrow(a,b,c){a=this.getCellNodeFromCords(a,b,c);if(!a)throw Error("Node at cords not TableCellNode.");
return a}canSelectBefore(){return!0}canIndent(){return!1}}function ua(){return{node:W()}}function W(){return d.$applyNodeReplacement(new V)}function N(a){return a instanceof V}function va(a){a=v.$findMatchingParent(a,b=>L(b));if(L(a))return a;throw Error("Expected table cell to be inside of table row.");}function wa(a){a=v.$findMatchingParent(a,b=>N(b));if(N(a))return a;throw Error("Expected table cell to be inside of table.");}
function xa(a,b){let c=wa(a),{x:e,y:f}=c.getCordsFromCellNode(a,b);return{above:c.getCellNodeFromCords(e,f-1,b),below:c.getCellNodeFromCords(e,f+1,b),left:c.getCellNodeFromCords(e-1,f,b),right:c.getCellNodeFromCords(e+1,f,b)}}function Z(a){let b=a.getFirstDescendant();null==b?a.selectStart():b.getParentOrThrow().selectStart()}function ya(a,b){let c=a.getFirstChild();null!==c?c.insertBefore(b):a.append(b)}let za=d.createCommand("INSERT_TABLE_COMMAND");exports.$createGridSelection=A;
exports.$createTableCellNode=G;exports.$createTableNode=W;exports.$createTableNodeWithDimensions=function(a,b,c=!0){let e=W();for(let k=0;k<a;k++){let g=K();for(let m=0;m<b;m++){var f=D.NO_STATUS;"object"===typeof c?(0===k&&c.rows&&(f|=D.ROW),0===m&&c.columns&&(f|=D.COLUMN)):c&&(0===k&&(f|=D.ROW),0===m&&(f|=D.COLUMN));f=G(f);let q=d.$createParagraphNode();q.append(d.$createTextNode());f.append(q);g.append(f)}e.append(g)}return e};exports.$createTableRowNode=K;
exports.$deleteTableColumn=function(a,b){let c=a.getChildren();for(let f=0;f<c.length;f++){var e=c[f];if(L(e)){e=e.getChildren();if(b>=e.length||0>b)throw Error("Table column target index out of range");e[b].remove()}}return a};
exports.$deleteTableColumn__EXPERIMENTAL=function(){var a=d.$getSelection();if(!d.$INTERNAL_isPointSelection(a))throw Error("Expected a INTERNAL_PointSelection");var b=a.anchor.getNode();a=a.focus.getNode();let [c,,e]=d.DEPRECATED_$getNodeTriplet(b);[b]=d.DEPRECATED_$getNodeTriplet(a);let [f,k,g]=d.DEPRECATED_$computeGridMap(e,c,b);var {startColumn:m}=k;let {startRow:q,startColumn:u}=g;a=Math.min(m,u);m=Math.max(m+c.__colSpan-1,u+b.__colSpan-1);let h=m-a+1;if(f[0].length===m-a+1)e.selectPrevious(),
e.remove();else{var l=f.length;for(let n=0;n<l;n++)for(let p=a;p<=m;p++){let {cell:r,startColumn:t}=f[n][p];t<a?p===a&&r.setColSpan(r.__colSpan-Math.min(h,r.__colSpan-(a-t))):t+r.__colSpan-1>m?p===m&&r.setColSpan(r.__colSpan-(m-t+1)):r.remove()}a=f[q];b=a[u+b.__colSpan];void 0!==b?({cell:b}=b,Z(b)):({cell:b}=a[u-1],Z(b))}};
exports.$deleteTableRow__EXPERIMENTAL=function(){var a=d.$getSelection();if(!d.$INTERNAL_isPointSelection(a))throw Error("Expected a INTERNAL_PointSelection");var b=a.anchor.getNode();a=a.focus.getNode();let [c,,e]=d.DEPRECATED_$getNodeTriplet(b);[a]=d.DEPRECATED_$getNodeTriplet(a);let [f,k,g]=d.DEPRECATED_$computeGridMap(e,c,a);({startRow:b}=k);var {startRow:m}=g;a=m+a.__rowSpan-1;if(f.length===a-b+1)e.remove();else{m=f[0].length;var q=f[a+1],u=e.getChildAtIndex(a+1);for(let l=a;l>=b;l--){for(var h=
m-1;0<=h;h--){let {cell:n,startRow:p,startColumn:r}=f[l][h];if(r===h&&(l===b&&p<b&&n.setRowSpan(n.__rowSpan-(p-b)),p>=b&&p+n.__rowSpan-1>a))if(n.setRowSpan(n.__rowSpan-(a-p+1)),null===u&&w(122),0===h)ya(u,n);else{let {cell:t}=q[h-1];t.insertAfter(n)}}h=e.getChildAtIndex(l);d.DEPRECATED_$isGridRowNode(h)||w(123,String(l));h.remove()}void 0!==q?({cell:b}=q[0],Z(b)):({cell:b}=f[b-1][0],Z(b))}};
exports.$getElementGridForTableNode=function(a,b){a=a.getElementByKey(b.getKey());if(null==a)throw Error("Table Element Not Found");return M(a)};exports.$getTableCellNodeFromLexicalNode=function(a){a=v.$findMatchingParent(a,b=>H(b));return H(a)?a:null};exports.$getTableColumnIndexFromTableCellNode=function(a){return va(a).getChildren().findIndex(b=>b.is(a))};exports.$getTableNodeFromLexicalNodeOrThrow=wa;
exports.$getTableRowIndexFromTableCellNode=function(a){let b=va(a);return wa(b).getChildren().findIndex(c=>c.is(b))};exports.$getTableRowNodeFromTableCellNodeOrThrow=va;
exports.$insertTableColumn=function(a,b,c=!0,e,f){let k=a.getChildren(),g=[];for(let u=0;u<k.length;u++){let h=k[u];if(L(h))for(let l=0;l<e;l++){var m=h.getChildren();if(b>=m.length||0>b)throw Error("Table column target index out of range");m=m[b];H(m)||w(12);let {left:n,right:p}=xa(m,f);var q=D.NO_STATUS;if(n&&n.hasHeaderState(D.ROW)||p&&p.hasHeaderState(D.ROW))q|=D.ROW;q=G(q);q.append(d.$createParagraphNode());g.push({newTableCell:q,targetCell:m})}}g.forEach(({newTableCell:u,targetCell:h})=>{c?
h.insertAfter(u):h.insertBefore(u)});return a};
exports.$insertTableColumn__EXPERIMENTAL=function(a=!0){function b(){let l=G(D.NO_STATUS).append(d.$createParagraphNode());null===u&&(u=l);return l}var c=d.$getSelection();if(!d.$INTERNAL_isPointSelection(c))throw Error("Expected a PointSeleciton");var e=c.anchor.getNode();c=c.focus.getNode();[e]=d.DEPRECATED_$getNodeTriplet(e);let [f,,k]=d.DEPRECATED_$getNodeTriplet(c),[g,m,q]=d.DEPRECATED_$computeGridMap(k,f,e);e=g.length;c=a?Math.max(m.startColumn,q.startColumn):Math.min(m.startColumn,q.startColumn);
a=a?c+f.__colSpan-1:c-1;c=k.getFirstChild();d.DEPRECATED_$isGridRowNode(c)||w(120);let u=null;var h=c;a:for(c=0;c<e;c++){0!==c&&(h=h.getNextSibling(),d.DEPRECATED_$isGridRowNode(h)||w(121));let l=g[c];if(0>a){ya(h,b());continue}let {cell:n,startColumn:p,startRow:r}=l[a];if(p+n.__colSpan-1<=a){let t=n,x=r,B=a;for(;x!==c&&1<t.__rowSpan;)if(B-=n.__colSpan,0<=B){let {cell:C,startRow:I}=l[B];t=C;x=I}else{h.append(b());continue a}t.insertAfter(b())}else n.setColSpan(n.__colSpan+1)}null!==u&&Z(u)};
exports.$insertTableRow=function(a,b,c=!0,e,f){var k=a.getChildren();if(b>=k.length||0>b)throw Error("Table row target index out of range");b=k[b];if(L(b))for(k=0;k<e;k++){let m=b.getChildren(),q=m.length,u=K();for(let h=0;h<q;h++){var g=m[h];H(g)||w(12);let {above:l,below:n}=xa(g,f);g=D.NO_STATUS;let p=l&&l.getWidth()||n&&n.getWidth()||void 0;if(l&&l.hasHeaderState(D.COLUMN)||n&&n.hasHeaderState(D.COLUMN))g|=D.COLUMN;g=G(g,1,p);g.append(d.$createParagraphNode());u.append(g)}c?b.insertAfter(u):b.insertBefore(u)}else throw Error("Row before insertion index does not exist.");
colSpan:this.__colSpan,headerState:this.__headerState,rowSpan:this.__rowSpan,type:"tablecell",width:this.getWidth()}}getColSpan(){return this.__colSpan}setColSpan(a){this.getWritable().__colSpan=a;return this}getRowSpan(){return this.__rowSpan}setRowSpan(a){this.getWritable().__rowSpan=a;return this}getTag(){return this.hasHeader()?"th":"td"}setHeaderStyles(a){this.getWritable().__headerState=a;return this.__headerState}getHeaderStyles(){return this.getLatest().__headerState}setWidth(a){this.getWritable().__width=
a;return this.__width}getWidth(){return this.getLatest().__width}getBackgroundColor(){return this.getLatest().__backgroundColor}setBackgroundColor(a){this.getWritable().__backgroundColor=a}toggleHeaderStyle(a){let b=this.getWritable();b.__headerState=(b.__headerState&a)===a?b.__headerState-a:b.__headerState+a;return b}hasHeaderState(a){return(this.getHeaderStyles()&a)===a}hasHeader(){return this.getLatest().__headerState!==w.NO_STATUS}updateDOM(a){return a.__headerState!==this.__headerState||a.__width!==
this.__width||a.__colSpan!==this.__colSpan||a.__rowSpan!==this.__rowSpan||a.__backgroundColor!==this.__backgroundColor}isShadowRoot(){return!0}collapseAtStart(){return!0}canBeEmpty(){return!1}canIndent(){return!1}}
function ca(a){var b=a.nodeName.toLowerCase();let c=void 0;ba.test(a.style.width)&&(c=parseFloat(a.style.width));b=z("th"===b?w.ROW:w.NO_STATUS,a.colSpan,c);b.__rowSpan=a.rowSpan;a=a.style.backgroundColor;""!==a&&(b.__backgroundColor=a);return{forChild:(d,e)=>{if(A(e)&&!v.$isElementNode(d)){e=v.$createParagraphNode();if(v.$isLineBreakNode(d)&&"\n"===d.getTextContent())return null;e.append(d);return e}return d},node:b}}function z(a,b=1,c){return v.$applyNodeReplacement(new x(a,b,c))}
function A(a){return a instanceof x}let da=v.createCommand("INSERT_TABLE_COMMAND");
class B extends v.ElementNode{static getType(){return"tablerow"}static clone(a){return new B(a.__height,a.__key)}static importDOM(){return{tr:()=>({conversion:ea,priority:0})}}static importJSON(a){return C(a.height)}constructor(a,b){super(b);this.__height=a}exportJSON(){return{...super.exportJSON(),type:"tablerow",version:1}}createDOM(a){let b=document.createElement("tr");this.__height&&(b.style.height=`${this.__height}px`);h.addClassNamesToElement(b,a.theme.tableRow);return b}isShadowRoot(){return!0}setHeight(a){this.getWritable().__height=
a;return this.__height}getHeight(){return this.getLatest().__height}updateDOM(a){return a.__height!==this.__height}canBeEmpty(){return!1}canIndent(){return!1}}function ea(a){let b=void 0;ba.test(a.style.height)&&(b=parseFloat(a.style.height));return{node:C(b)}}function C(a){return v.$applyNodeReplacement(new B(a))}function F(a){return a instanceof B}
function H(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.");}let fa="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement;
function ha(a){a=h.$findMatchingParent(a,b=>F(b));if(F(a))return a;throw Error("Expected table cell to be inside of table row.");}function ia(a){a=h.$findMatchingParent(a,b=>I(b));if(I(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)}}
function J(a){let b=a.getFirstDescendant();null==b?a.selectStart():b.getParentOrThrow().selectStart()}function ka(a,b){let c=a.getFirstChild();null!==c?c.insertBefore(b):a.append(b)}
function L(a,b,c){let d=[],e=null,k=null;a=a.getChildren();for(let g=0;g<a.length;g++){var f=a[g];F(f)||H(146);var m=f.getChildren();f=0;for(let l of m){for(A(l)||H(147);void 0!==d[g]&&void 0!==d[g][f];)f++;m=g;var q=f,r=l;let n={cell:r,startColumn:q,startRow:m},p=r.__rowSpan,t=r.__colSpan;for(let u=0;u<p;u++){void 0===d[m+u]&&(d[m+u]=[]);for(let y=0;y<t;y++)d[m+u][q+y]=n}b.is(r)&&(e=n);c.is(r)&&(k=n);f+=l.__colSpan}}null===e&&H(110);null===k&&H(111);return[d,e,k]}
function M(a){a instanceof x||("__type"in a?(a=h.$findMatchingParent(a,A),A(a)||H(148)):(a=h.$findMatchingParent(a.getNode(),A),A(a)||H(148)));let b=a.getParent();F(b)||H(149);let c=b.getParent();I(c)||H(150);return[a,b,c]}
function na(a){let [b,,c]=M(a);a=c.getChildren();let d=a.length;var e=a[0].getChildren().length;let k=Array(d);for(var f=0;f<d;f++)k[f]=Array(e);for(e=0;e<d;e++){f=a[e].getChildren();let m=0;for(let q=0;q<f.length;q++){for(;k[e][m];)m++;let r=f[q],g=r.__rowSpan||1,l=r.__colSpan||1;for(let n=0;n<g;n++)for(let p=0;p<l;p++)k[e+n][m+p]=r;if(b===r)return{colSpan:l,columnIndex:m,rowIndex:e,rowSpan:g};m+=l}}return null}
class oa{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 N(a)?this.tableKey===a.tableKey&&this.anchor.is(a.anchor)&&this.focus.is(a.focus):!1}set(a,b,c){this.dirty=!0;this.tableKey=a;this.anchor.key=b;this.focus.key=c;
this._cachedNodes=null}clone(){return new oa(this.tableKey,this.anchor,this.focus)}isCollapsed(){return!1}extract(){return this.getNodes()}insertRawText(){}insertText(){}insertNodes(a){let b=this.focus.getNode();v.$isElementNode(b)||H(151);v.$normalizeSelection__EXPERIMENTAL(b.select(0,b.getChildrenSize())).insertNodes(a)}getShape(){var a=v.$getNodeByKey(this.anchor.key);A(a)||H(152);a=na(a);null===a&&H(153);var b=v.$getNodeByKey(this.focus.key);A(b)||H(154);let c=na(b);null===c&&H(155);b=Math.min(a.columnIndex,
c.columnIndex);let d=Math.max(a.columnIndex,c.columnIndex),e=Math.min(a.rowIndex,c.rowIndex);a=Math.max(a.rowIndex,c.rowIndex);return{fromX:Math.min(b,d),fromY:Math.min(e,a),toX:Math.max(b,d),toY:Math.max(e,a)}}getNodes(){function a(u){let {cell:y,startColumn:D,startRow:E}=u;q=Math.min(q,D);r=Math.min(r,E);g=Math.max(g,D+y.__colSpan-1);l=Math.max(l,E+y.__rowSpan-1)}var b=this._cachedNodes;if(null!==b)return b;var c=this.anchor.getNode();b=this.focus.getNode();var d=h.$findMatchingParent(c,A);c=h.$findMatchingParent(b,
A);A(d)||H(152);A(c)||H(154);b=d.getParent();F(b)||H(156);b=b.getParent();I(b)||H(157);var e=c.getParents()[1];if(e!==b)return b.isParentOf(c)?(b=e.getParent(),null==b&&H(159),this.set(this.tableKey,c.getKey(),b.getKey())):(b=b.getParent(),null==b&&H(158),this.set(this.tableKey,b.getKey(),c.getKey())),this.getNodes();let [k,f,m]=L(b,d,c),q=Math.min(f.startColumn,m.startColumn),r=Math.min(f.startRow,m.startRow),g=Math.max(f.startColumn+f.cell.__colSpan-1,m.startColumn+m.cell.__colSpan-1),l=Math.max(f.startRow+
f.cell.__rowSpan-1,m.startRow+m.cell.__rowSpan-1);c=q;d=r;e=q;for(var n=r;q<c||r<d||g>e||l>n;){if(q<c){var p=n-d;--c;for(var t=0;t<=p;t++)a(k[d+t][c])}if(r<d)for(p=e-c,--d,t=0;t<=p;t++)a(k[d][c+t]);if(g>e)for(p=n-d,e+=1,t=0;t<=p;t++)a(k[d+t][e]);if(l>n)for(p=e-c,n+=1,t=0;t<=p;t++)a(k[n][c+t])}b=[b];c=null;for(d=r;d<=l;d++)for(e=q;e<=g;e++)({cell:n}=k[d][e]),p=n.getParent(),F(p)||H(160),p!==c&&b.push(p),b.push(n,...pa(n)),c=p;v.isCurrentlyReadOnlyMode()||(this._cachedNodes=b);return b}getTextContent(){let a=
this.getNodes(),b="";for(let c=0;c<a.length;c++)b+=a[c].getTextContent();return b}}function N(a){return a instanceof oa}function O(){let a=v.$createPoint("root",0,"element"),b=v.$createPoint("root",0,"element");return new oa("root",a,b)}function pa(a){let b=[],c=[a];for(;0<c.length;){let d=c.pop();void 0===d&&H(112);v.$isElementNode(d)&&c.unshift(...d.getChildren());d!==a&&b.push(d)}return b}
class qa{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()}getTable(){return this.table}removeListeners(){Array.from(this.listenersToRemove).forEach(a=>a())}trackTable(){let a=new MutationObserver(b=>
{this.editor.update(()=>{var c=!1;for(let d=0;d<b.length;d++){const e=b[d].target.nodeName;if("TABLE"===e||"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=P(c)}})});this.editor.update(()=>{let b=this.editor.getElementByKey(this.tableNodeKey);if(!b)throw Error("Expected to find TableElement in DOM");this.table=P(b);a.observe(b,{childList:!0,subtree:!0})})}clearHighlight(){let a=this.editor;this.isHighlightingCells=
!1;this.focusY=this.focusX=this.anchorY=this.anchorX=-1;this.focusCell=this.anchorCell=this.focusCellNodeKey=this.anchorCellNodeKey=this.tableSelection=null;this.hasHijackedSelectionStyles=!1;this.enableHighlightStyle();a.update(()=>{var b=v.$getNodeByKey(this.tableNodeKey);if(!I(b))throw Error("Expected TableNode.");b=a.getElementByKey(this.tableNodeKey);if(!b)throw Error("Expected to find TableElement in DOM");b=P(b);Q(a,b,null);v.$setSelection(null);a.dispatchCommand(v.SELECTION_CHANGE_COMMAND,
void 0)})}enableHighlightStyle(){let a=this.editor;a.update(()=>{let b=a.getElementByKey(this.tableNodeKey);if(!b)throw Error("Expected to find TableElement in DOM");h.removeClassNamesFromElement(b,a._config.theme.tableSelection);b.classList.remove("disable-selection");this.hasHijackedSelectionStyles=!1})}disableHighlightStyle(){let a=this.editor;a.update(()=>{let b=a.getElementByKey(this.tableNodeKey);if(!b)throw Error("Expected to find TableElement in DOM");h.addClassNamesToElement(b,a._config.theme.tableSelection);
this.hasHijackedSelectionStyles=!0})}updateTableTableSelection(a){if(null!==a&&a.tableKey===this.tableNodeKey){let b=this.editor;this.tableSelection=a;this.isHighlightingCells=!0;this.disableHighlightStyle();Q(b,this.table,this.tableSelection)}else null==a?this.clearHighlight():(this.tableNodeKey=a.tableKey,this.updateTableTableSelection(a))}setFocusCellForSelection(a,b=!1){let c=this.editor;c.update(()=>{var d=v.$getNodeByKey(this.tableNodeKey);if(!I(d))throw Error("Expected TableNode.");if(!c.getElementByKey(this.tableNodeKey))throw Error("Expected to find TableElement in DOM");
d=a.x;let e=a.y;this.focusCell=a;if(null!==this.anchorCell){let k=fa?(c._window||window).getSelection():null;k&&k.setBaseAndExtent(this.anchorCell.elem,0,this.focusCell.elem,0)}if(!this.isHighlightingCells&&(this.anchorX!==d||this.anchorY!==e||b))this.isHighlightingCells=!0,this.disableHighlightStyle();else if(d===this.focusX&&e===this.focusY)return;this.focusX=d;this.focusY=e;this.isHighlightingCells&&(d=v.$getNearestNodeFromDOMNode(a.elem),null!=this.tableSelection&&null!=this.anchorCellNodeKey&&
A(d)&&(d=d.getKey(),this.tableSelection=this.tableSelection.clone()||O(),this.focusCellNodeKey=d,this.tableSelection.set(this.tableNodeKey,this.anchorCellNodeKey,this.focusCellNodeKey),v.$setSelection(this.tableSelection),c.dispatchCommand(v.SELECTION_CHANGE_COMMAND,void 0),Q(c,this.table,this.tableSelection)))})}setAnchorCellForSelection(a){this.isHighlightingCells=!1;this.anchorCell=a;this.anchorX=a.x;this.anchorY=a.y;this.editor.update(()=>{var b=v.$getNearestNodeFromDOMNode(a.elem);A(b)&&(b=b.getKey(),
this.tableSelection=null!=this.tableSelection?this.tableSelection.clone():O(),this.anchorCellNodeKey=b)})}formatCells(a){this.editor.update(()=>{let b=v.$getSelection();N(b)||H(11);let c=v.$createRangeSelection(),d=c.anchor,e=c.focus;b.getNodes().forEach(k=>{A(k)&&0!==k.getTextContentSize()&&(d.set(k.getKey(),0,"element"),e.set(k.getKey(),k.getChildrenSize(),"element"),c.formatText(a))});v.$setSelection(b);this.editor.dispatchCommand(v.SELECTION_CHANGE_COMMAND,void 0)})}clearText(){let a=this.editor;
a.update(()=>{let b=v.$getNodeByKey(this.tableNodeKey);if(!I(b))throw Error("Expected TableNode.");var c=v.$getSelection();N(c)||H(11);c=c.getNodes().filter(A);c.length===this.table.columns*this.table.rows?(b.selectPrevious(),b.remove(),v.$getRoot().selectStart()):(c.forEach(d=>{if(v.$isElementNode(d)){let e=v.$createParagraphNode(),k=v.$createTextNode();e.append(k);d.append(e);d.getChildren().forEach(f=>{f!==e&&f.remove()})}}),Q(a,this.table,null),v.$setSelection(null),a.dispatchCommand(v.SELECTION_CHANGE_COMMAND,
void 0))})}}function ra(a){for(;null!=a;){let b=a.nodeName;if("TD"===b||"TH"===b){a=a._cell;if(void 0===a)break;return a}a=a.parentNode}return null}
function P(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 k=d.nodeName;if("TD"===k||"TH"===k){k=d;k={elem:k,hasBackgroundColor:""!==k.style.backgroundColor,highlighted:!1,x:a,y:e};d._cell=k;let f=b[e];void 0===f&&(f=b[e]=[]);f[a]=k}else if(k=d.firstChild,null!=k){d=k;continue}k=d.nextSibling;if(null!=k)a++,d=k;else if(k=d.parentNode,null!=k){d=k.nextSibling;if(null==d)break;e++;a=0}}c.columns=a+1;c.rows=e+1;return c}
function Q(a,b,c){let d=new Set(c?c.getNodes():[]);sa(b,(e,k)=>{let f=e.elem;d.has(k)?(e.highlighted=!0,ta(a,e)):(e.highlighted=!1,ua(a,e),f.getAttribute("style")||f.removeAttribute("style"))})}function sa(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 k=d[e];if(!k)continue;let f=v.$getNearestNodeFromDOMNode(k.elem);null!==f&&b(k,f,{x:e,y:c})}}}function wa(a,b){b.disableHighlightStyle();sa(b.table,c=>{c.highlighted=!0;ta(a,c)})}
function xa(a,b){b.enableHighlightStyle();sa(b.table,c=>{let d=c.elem;c.highlighted=!1;ua(a,c);d.getAttribute("style")||d.removeAttribute("style")})}
let ya=(a,b,c,d,e)=>{const k="forward"===e;switch(e){case "backward":case "forward":return c!==(k?a.table.columns-1:0)?(a=b.getCellNodeFromCordsOrThrow(c+(k?1:-1),d,a.table),k?a.selectStart():a.selectEnd()):d!==(k?a.table.rows-1:0)?(a=b.getCellNodeFromCordsOrThrow(k?0:a.table.columns-1,d+(k?1:-1),a.table),k?a.selectStart():a.selectEnd()):k?b.selectNext():b.selectPrevious(),!0;case "up":return 0!==d?b.getCellNodeFromCordsOrThrow(c,d-1,a.table).selectEnd():b.selectPrevious(),!0;case "down":return d!==
a.table.rows-1?b.getCellNodeFromCordsOrThrow(c,d+1,a.table).selectStart():b.selectNext(),!0;default:return!1}},za=(a,b,c,d,e)=>{const k="forward"===e;switch(e){case "backward":case "forward":return c!==(k?a.table.columns-1:0)&&a.setFocusCellForSelection(b.getDOMCellFromCordsOrThrow(c+(k?1:-1),d,a.table)),!0;case "up":return 0!==d?(a.setFocusCellForSelection(b.getDOMCellFromCordsOrThrow(c,d-1,a.table)),!0):!1;case "down":return d!==a.table.rows-1?(a.setFocusCellForSelection(b.getDOMCellFromCordsOrThrow(c,
d+1,a.table)),!0):!1;default:return!1}};function U(a,b){if(v.$isRangeSelection(a)||N(a)){let c=b.isParentOf(a.anchor.getNode());a=b.isParentOf(a.focus.getNode());return c&&a}return!1}
function ta(a,b){a=b.elem;b=v.$getNearestNodeFromDOMNode(a);A(b)||H(131);null===b.getBackgroundColor()?a.style.setProperty("background-color","rgb(172,206,247)"):a.style.setProperty("background-image","linear-gradient(to right, rgba(172,206,247,0.85), rgba(172,206,247,0.85))");a.style.setProperty("caret-color","transparent")}
function ua(a,b){a=b.elem;b=v.$getNearestNodeFromDOMNode(a);A(b)||H(131);null===b.getBackgroundColor()&&a.style.removeProperty("background-color");a.style.removeProperty("background-image");a.style.removeProperty("caret-color")}function Aa(a){a=h.$findMatchingParent(a,A);return A(a)?a:null}function Ba(a){a=h.$findMatchingParent(a,I);return I(a)?a:null}
function V(a,b,c,d,e){let k=v.$getSelection();if(!U(k,d))return!1;if(v.$isRangeSelection(k)&&k.isCollapsed()){if("backward"===c||"forward"===c)return!1;let {anchor:r,focus:g}=k;var f=h.$findMatchingParent(r.getNode(),A),m=h.$findMatchingParent(g.getNode(),A);if(!A(f)||!f.is(m))return!1;m=Ba(f);if(m!==d&&null!=m){var q=a.getElementByKey(m.getKey());if(null!=q)return e.table=P(q),V(a,b,c,m,e)}m=a.getElementByKey(f.__key);q=a.getElementByKey(r.key);if(null==q||null==m)return!1;if("element"===r.type)m=
q.getBoundingClientRect();else{m=window.getSelection();if(null===m||0===m.rangeCount)return!1;m=m.getRangeAt(0).getBoundingClientRect()}q="up"===c?f.getFirstChild():f.getLastChild();if(null==q)return!1;a=a.getElementByKey(q.__key);if(null==a)return!1;a=a.getBoundingClientRect();if("up"===c?a.top>m.top-m.height:m.bottom+m.height>a.bottom){W(b);a=d.getCordsFromCellNode(f,e.table);if(b.shiftKey)c=d.getDOMCellFromCordsOrThrow(a.x,a.y,e.table),e.setAnchorCellForSelection(c),e.setFocusCellForSelection(c,
!0);else return ya(e,d,a.x,a.y,c);return!0}}else if(N(k)){let {anchor:r,focus:g}=k;q=h.$findMatchingParent(r.getNode(),A);m=h.$findMatchingParent(g.getNode(),A);[f]=k.getNodes();a=a.getElementByKey(f.getKey());if(!A(q)||!A(m)||!I(f)||null==a)return!1;e.updateTableTableSelection(k);a=P(a);q=d.getCordsFromCellNode(q,a);q=d.getDOMCellFromCordsOrThrow(q.x,q.y,a);e.setAnchorCellForSelection(q);W(b);if(b.shiftKey)return b=d.getCordsFromCellNode(m,a),za(e,f,b.x,b.y,c);m.selectEnd();return!0}return!1}
function W(a){a.preventDefault();a.stopImmediatePropagation();a.stopPropagation()}
class X extends v.ElementNode{static getType(){return"table"}static clone(a){return new X(a.__key)}static importDOM(){return{table:()=>({conversion:Ca,priority:1})}}static importJSON(){return Y()}constructor(a){super(a)}exportJSON(){return{...super.exportJSON(),type:"table",version:1}}createDOM(a){let b=document.createElement("table");h.addClassNamesToElement(b,a.theme.table);return b}updateDOM(){return!1}exportDOM(a){return{...super.exportDOM(a),after:b=>{if(b){let c=b.cloneNode(),d=document.createElement("colgroup"),
e=document.createElement("tbody");h.isHTMLElement(b)&&e.append(...b.children);b=this.getFirstChildOrThrow();if(!F(b))throw Error("Expected to find row node.");b=b.getChildrenSize();for(let k=0;k<b;k++){let f=document.createElement("col");d.append(f)}c.replaceChildren(d,e);return c}}}}canExtractContents(){return!1}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(k=>{if(k)return{elem:k}=k,v.$getNearestNodeFromDOMNode(k)===
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];return null==a?null:a}getDOMCellFromCordsOrThrow(a,b,c){a=this.getDOMCellFromCords(a,b,c);if(!a)throw Error("Cell not found at cords.");return a}getCellNodeFromCords(a,b,c){a=this.getDOMCellFromCords(a,b,c);if(null==a)return null;a=v.$getNearestNodeFromDOMNode(a.elem);return A(a)?a:null}getCellNodeFromCordsOrThrow(a,b,c){a=this.getCellNodeFromCords(a,
b,c);if(!a)throw Error("Node at cords not TableCellNode.");return a}canSelectBefore(){return!0}canIndent(){return!1}}function Ca(){return{node:Y()}}function Y(){return v.$applyNodeReplacement(new X)}function I(a){return a instanceof X}exports.$computeTableMap=L;exports.$createTableCellNode=z;exports.$createTableNode=Y;
exports.$createTableNodeWithDimensions=function(a,b,c=!0){let d=Y();for(let k=0;k<a;k++){let f=C();for(let m=0;m<b;m++){var e=w.NO_STATUS;"object"===typeof c?(0===k&&c.rows&&(e|=w.ROW),0===m&&c.columns&&(e|=w.COLUMN)):c&&(0===k&&(e|=w.ROW),0===m&&(e|=w.COLUMN));e=z(e);let q=v.$createParagraphNode();q.append(v.$createTextNode());e.append(q);f.append(e)}d.append(f)}return d};exports.$createTableRowNode=C;exports.$createTableSelection=O;
exports.$deleteTableColumn=function(a,b){let c=a.getChildren();for(let e=0;e<c.length;e++){var d=c[e];if(F(d)){d=d.getChildren();if(b>=d.length||0>b)throw Error("Table column target index out of range");d[b].remove()}}return a};
exports.$deleteTableColumn__EXPERIMENTAL=function(){var a=v.$getSelection();v.$isRangeSelection(a)||N(a)||H(118);var b=a.anchor.getNode();a=a.focus.getNode();let [c,,d]=M(b);[b]=M(a);let [e,k,f]=L(d,c,b);var {startColumn:m}=k;let {startRow:q,startColumn:r}=f;a=Math.min(m,r);m=Math.max(m+c.__colSpan-1,r+b.__colSpan-1);let g=m-a+1;if(e[0].length===m-a+1)d.selectPrevious(),d.remove();else{var l=e.length;for(let n=0;n<l;n++)for(let p=a;p<=m;p++){let {cell:t,startColumn:u}=e[n][p];u<a?p===a&&t.setColSpan(t.__colSpan-
Math.min(g,t.__colSpan-(a-u))):u+t.__colSpan-1>m?p===m&&t.setColSpan(t.__colSpan-(m-u+1)):t.remove()}a=e[q];b=a[r+b.__colSpan];void 0!==b?({cell:b}=b,J(b)):({cell:b}=a[r-1],J(b))}};
exports.$deleteTableRow__EXPERIMENTAL=function(){var a=v.$getSelection();v.$isRangeSelection(a)||N(a)||H(118);var b=a.anchor.getNode();a=a.focus.getNode();let [c,,d]=M(b);[a]=M(a);let [e,k,f]=L(d,c,a);({startRow:b}=k);var {startRow:m}=f;a=m+a.__rowSpan-1;if(e.length===a-b+1)d.remove();else{m=e[0].length;var q=e[a+1],r=d.getChildAtIndex(a+1);for(let l=a;l>=b;l--){for(var g=m-1;0<=g;g--){let {cell:n,startRow:p,startColumn:t}=e[l][g];if(t===g&&(l===b&&p<b&&n.setRowSpan(n.__rowSpan-(p-b)),p>=b&&p+n.__rowSpan-
1>a))if(n.setRowSpan(n.__rowSpan-(a-p+1)),null===r&&H(122),0===g)ka(r,n);else{let {cell:u}=q[g-1];u.insertAfter(n)}}g=d.getChildAtIndex(l);F(g)||H(123,String(l));g.remove()}void 0!==q?({cell:b}=q[0],J(b)):({cell:b}=e[b-1][0],J(b))}};exports.$getElementForTableNode=function(a,b){a=a.getElementByKey(b.getKey());if(null==a)throw Error("Table Element Not Found");return P(a)};exports.$getNodeTriplet=M;
exports.$getTableCellNodeFromLexicalNode=function(a){a=h.$findMatchingParent(a,b=>A(b));return A(a)?a:null};exports.$getTableCellNodeRect=na;exports.$getTableColumnIndexFromTableCellNode=function(a){return ha(a).getChildren().findIndex(b=>b.is(a))};exports.$getTableNodeFromLexicalNodeOrThrow=ia;exports.$getTableRowIndexFromTableCellNode=function(a){let b=ha(a);return ia(b).getChildren().findIndex(c=>c.is(b))};exports.$getTableRowNodeFromTableCellNodeOrThrow=ha;
exports.$insertTableColumn=function(a,b,c=!0,d,e){let k=a.getChildren(),f=[];for(let r=0;r<k.length;r++){let g=k[r];if(F(g))for(let l=0;l<d;l++){var m=g.getChildren();if(b>=m.length||0>b)throw Error("Table column target index out of range");m=m[b];A(m)||H(12);let {left:n,right:p}=ja(m,e);var q=w.NO_STATUS;if(n&&n.hasHeaderState(w.ROW)||p&&p.hasHeaderState(w.ROW))q|=w.ROW;q=z(q);q.append(v.$createParagraphNode());f.push({newTableCell:q,targetCell:m})}}f.forEach(({newTableCell:r,targetCell:g})=>{c?
g.insertAfter(r):g.insertBefore(r)});return a};
exports.$insertTableColumn__EXPERIMENTAL=function(a=!0){function b(){let l=z(w.NO_STATUS).append(v.$createParagraphNode());null===r&&(r=l);return l}var c=v.$getSelection();v.$isRangeSelection(c)||N(c)||H(118);var d=c.anchor.getNode();c=c.focus.getNode();[d]=M(d);let [e,,k]=M(c),[f,m,q]=L(k,e,d);d=f.length;c=a?Math.max(m.startColumn,q.startColumn):Math.min(m.startColumn,q.startColumn);a=a?c+e.__colSpan-1:c-1;c=k.getFirstChild();F(c)||H(120);let r=null;var g=c;a:for(c=0;c<d;c++){0!==c&&(g=g.getNextSibling(),
F(g)||H(121));let l=f[c];if(0>a){ka(g,b());continue}let {cell:n,startColumn:p,startRow:t}=l[a];if(p+n.__colSpan-1<=a){let u=n,y=t,D=a;for(;y!==c&&1<u.__rowSpan;)if(D-=n.__colSpan,0<=D){let {cell:E,startRow:K}=l[D];u=E;y=K}else{g.append(b());continue a}u.insertAfter(b())}else n.setColSpan(n.__colSpan+1)}null!==r&&J(r)};
exports.$insertTableRow=function(a,b,c=!0,d,e){var k=a.getChildren();if(b>=k.length||0>b)throw Error("Table row target index out of range");b=k[b];if(F(b))for(k=0;k<d;k++){let m=b.getChildren(),q=m.length,r=C();for(let g=0;g<q;g++){var f=m[g];A(f)||H(12);let {above:l,below:n}=ja(f,e);f=w.NO_STATUS;let p=l&&l.getWidth()||n&&n.getWidth()||void 0;if(l&&l.hasHeaderState(w.COLUMN)||n&&n.hasHeaderState(w.COLUMN))f|=w.COLUMN;f=z(f,1,p);f.append(v.$createParagraphNode());r.append(f)}c?b.insertAfter(r):b.insertBefore(r)}else throw Error("Row before insertion index does not exist.");
return a};
exports.$insertTableRow__EXPERIMENTAL=function(a=!0){var b=d.$getSelection();if(!d.$INTERNAL_isPointSelection(b))throw Error("Expected a INTERNAL_PointSelection");b=b.focus.getNode();let [c,,e]=d.DEPRECATED_$getNodeTriplet(b),[f,k]=d.DEPRECATED_$computeGridMap(e,c,c);b=f[0].length;var {startRow:g}=k;if(a){a=g+c.__rowSpan-1;var m=f[a];g=K();for(var q=0;q<b;q++){let {cell:u,startRow:h}=m[q];h+u.__rowSpan-1<=a?g.append(G(D.NO_STATUS).append(d.$createParagraphNode())):u.setRowSpan(u.__rowSpan+1)}b=e.getChildAtIndex(a);
d.DEPRECATED_$isGridRowNode(b)||w(119);b.insertAfter(g)}else{m=f[g];a=K();for(q=0;q<b;q++){let {cell:u,startRow:h}=m[q];h===g?a.append(G(D.NO_STATUS).append(d.$createParagraphNode())):u.setRowSpan(u.__rowSpan+1)}b=e.getChildAtIndex(g);d.DEPRECATED_$isGridRowNode(b)||w(119);b.insertBefore(a)}};exports.$isGridSelection=z;exports.$isTableCellNode=H;exports.$isTableNode=N;exports.$isTableRowNode=L;
exports.$removeTableRowAtIndex=function(a,b){let c=a.getChildren();if(b>=c.length||0>b)throw Error("Expected table cell to be inside of table row.");c[b].remove();return a};
exports.$unmergeCell=function(){var a=d.$getSelection();if(!d.$INTERNAL_isPointSelection(a))throw Error("Expected a INTERNAL_PointSelection");a=a.anchor.getNode();let [b,c,e]=d.DEPRECATED_$getNodeTriplet(a);a=b.__colSpan;let f=b.__rowSpan;if(1<a){for(var k=1;k<a;k++)b.insertAfter(G(D.NO_STATUS));b.setColSpan(1)}if(1<f){let [q,u]=d.DEPRECATED_$computeGridMap(e,b,b),{startColumn:h,startRow:l}=u,n;for(k=1;k<f;k++){var g=l+k;let p=q[g];n=(n||c).getNextSibling();d.DEPRECATED_$isGridRowNode(n)||w(125);
var m=null;for(let r=0;r<h;r++){let t=p[r],x=t.cell;t.startRow===g&&(m=x);1<x.__colSpan&&(r+=x.__colSpan-1)}if(null===m)for(m=0;m<a;m++)ya(n,G(D.NO_STATUS));else for(g=0;g<a;g++)m.insertAfter(G(D.NO_STATUS))}b.setRowSpan(1)}};exports.INSERT_TABLE_COMMAND=za;exports.TableCellHeaderStates=D;exports.TableCellNode=F;exports.TableNode=V;exports.TableRowNode=J;exports.TableSelection=fa;
exports.applyTableHandlers=function(a,b,c,e){function f(h){h=a.getCordsFromCellNode(h,g.grid);return a.getCellFromCordsOrThrow(h.x,h.y,g.grid)}let k=c.getRootElement();if(null===k)throw Error("No root element.");let g=new fa(c,a.getKey()),m=c._window||window;b.__lexicalTableSelection=g;b.addEventListener("mousedown",h=>{setTimeout(()=>{if(0===h.button&&m){var l=ha(h.target);null!==l&&(U(h),g.setAnchorCellForSelection(l));var n=()=>{m.removeEventListener("mouseup",n);m.removeEventListener("mousemove",
p)},p=r=>{const t=ha(r.target);null===t||g.anchorX===t.x&&g.anchorY===t.y||(r.preventDefault(),g.setFocusCellForSelection(t))};m.addEventListener("mouseup",n);m.addEventListener("mousemove",p)}},0)});let q=h=>{0===h.button&&c.update(()=>{const l=d.$getSelection(),n=h.target;z(l)&&l.gridKey===g.tableNodeKey&&k.contains(n)&&g.clearHighlight()})};m.addEventListener("mousedown",q);g.listenersToRemove.add(()=>m.removeEventListener("mousedown",q));g.listenersToRemove.add(c.registerCommand(d.KEY_ARROW_DOWN_COMMAND,
h=>T(c,h,"down",a,g),d.COMMAND_PRIORITY_HIGH));g.listenersToRemove.add(c.registerCommand(d.KEY_ARROW_UP_COMMAND,h=>T(c,h,"up",a,g),d.COMMAND_PRIORITY_HIGH));g.listenersToRemove.add(c.registerCommand(d.KEY_ARROW_LEFT_COMMAND,h=>T(c,h,"backward",a,g),d.COMMAND_PRIORITY_HIGH));g.listenersToRemove.add(c.registerCommand(d.KEY_ARROW_RIGHT_COMMAND,h=>T(c,h,"forward",a,g),d.COMMAND_PRIORITY_HIGH));g.listenersToRemove.add(c.registerCommand(d.KEY_ESCAPE_COMMAND,h=>{var l=d.$getSelection();return z(l)&&(l=v.$findMatchingParent(l.focus.getNode(),
H),H(l))?(U(h),l.selectEnd(),!0):!1},d.COMMAND_PRIORITY_HIGH));let u=h=>()=>{var l=d.$getSelection();if(!S(l,a))return!1;if(z(l))return g.clearText(),!0;if(d.$isRangeSelection(l)){const r=v.$findMatchingParent(l.anchor.getNode(),t=>H(t));if(!H(r))return!1;var n=l.anchor.getNode(),p=l.focus.getNode();n=a.isParentOf(n);p=a.isParentOf(p);if(n&&!p||p&&!n)return g.clearText(),!0;n=(p=v.$findMatchingParent(l.anchor.getNode(),t=>d.$isElementNode(t)))&&v.$findMatchingParent(p,t=>d.$isElementNode(t)&&H(t.getParent()));
if(!d.$isElementNode(n)||!d.$isElementNode(p))return!1;if(h===d.DELETE_LINE_COMMAND&&null===n.getPreviousSibling())return!0;if((h===d.DELETE_CHARACTER_COMMAND||h===d.DELETE_WORD_COMMAND)&&l.isCollapsed()&&0===l.anchor.offset&&p!==n){l=p.getChildren();const t=d.$createParagraphNode();l.forEach(x=>t.append(x));p.replace(t);p.getWritable().__parent=r.getKey();return!0}}return!1};[d.DELETE_WORD_COMMAND,d.DELETE_LINE_COMMAND,d.DELETE_CHARACTER_COMMAND].forEach(h=>{g.listenersToRemove.add(c.registerCommand(h,
u(h),d.COMMAND_PRIORITY_CRITICAL))});b=h=>{const l=d.$getSelection();if(!S(l,a))return!1;if(z(l))return h.preventDefault(),h.stopPropagation(),g.clearText(),!0;d.$isRangeSelection(l)&&(h=v.$findMatchingParent(l.anchor.getNode(),n=>H(n)),H(h));return!1};g.listenersToRemove.add(c.registerCommand(d.KEY_BACKSPACE_COMMAND,b,d.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(d.KEY_DELETE_COMMAND,b,d.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(d.FORMAT_TEXT_COMMAND,
h=>{let l=d.$getSelection();if(!S(l,a))return!1;if(z(l))return g.formatCells(h),!0;d.$isRangeSelection(l)&&(h=v.$findMatchingParent(l.anchor.getNode(),n=>H(n)),H(h));return!1},d.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(d.CONTROLLED_TEXT_INSERTION_COMMAND,()=>{var h=d.$getSelection();if(!S(h,a))return!1;z(h)?g.clearHighlight():d.$isRangeSelection(h)&&(h=v.$findMatchingParent(h.anchor.getNode(),l=>H(l)),H(h));return!1},d.COMMAND_PRIORITY_CRITICAL));e&&g.listenersToRemove.add(c.registerCommand(d.KEY_TAB_COMMAND,
h=>{var l=d.$getSelection();if(!d.$isRangeSelection(l)||!l.isCollapsed()||!S(l,a))return!1;l=ra(l.anchor.getNode());if(null===l)return!1;U(h);l=a.getCordsFromCellNode(l,g.grid);pa(g,a,l.x,l.y,h.shiftKey?"backward":"forward");return!0},d.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(d.FOCUS_COMMAND,()=>a.isSelected(),d.COMMAND_PRIORITY_HIGH));g.listenersToRemove.add(c.registerCommand(d.SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,h=>{let {nodes:l,selection:n}=h;h=d.$INTERNAL_isPointSelection(n);
var p=d.$isRangeSelection(n);h=p&&null!==v.$findMatchingParent(n.anchor.getNode(),E=>d.DEPRECATED_$isGridCellNode(E))&&null!==v.$findMatchingParent(n.focus.getNode(),E=>d.DEPRECATED_$isGridCellNode(E))||h&&!p;if(1!==l.length||!d.DEPRECATED_$isGridNode(l[0])||!h)return!1;var {anchor:r}=n,t=l[0];h=t.getChildren();p=t.getFirstChildOrThrow().getChildrenSize();t=t.getChildrenSize();var x=v.$findMatchingParent(r.getNode(),E=>d.DEPRECATED_$isGridCellNode(E)),B=(r=x&&v.$findMatchingParent(x,E=>d.DEPRECATED_$isGridRowNode(E)))&&
v.$findMatchingParent(r,E=>d.DEPRECATED_$isGridNode(E));if(!d.DEPRECATED_$isGridCellNode(x)||!d.DEPRECATED_$isGridRowNode(r)||!d.DEPRECATED_$isGridNode(B))return!1;var C=r.getIndexWithinParent(),I=Math.min(B.getChildrenSize()-1,C+t-1);t=x.getIndexWithinParent();x=Math.min(r.getChildrenSize()-1,t+p-1);p=Math.min(t,x);r=Math.min(C,I);t=Math.max(t,x);C=Math.max(C,I);B=B.getChildren();I=0;let ia,ja;for(x=r;x<=C;x++){var X=B[x];if(!d.DEPRECATED_$isGridRowNode(X))return!1;var Y=h[I];if(!d.DEPRECATED_$isGridRowNode(Y))return!1;
X=X.getChildren();Y=Y.getChildren();let E=0;for(let O=p;O<=t;O++){let P=X[O];if(!d.DEPRECATED_$isGridCellNode(P))return!1;let sa=Y[E];if(!d.DEPRECATED_$isGridCellNode(sa))return!1;x===r&&O===p?ia=P.getKey():x===C&&O===t&&(ja=P.getKey());let Aa=P.getChildren();sa.getChildren().forEach(Q=>{d.$isTextNode(Q)&&d.$createParagraphNode().append(Q);P.append(Q)});Aa.forEach(Q=>Q.remove());E++}I++}ia&&ja&&(h=A(),h.set(l[0].getKey(),ia,ja),d.$setSelection(h));return!0},d.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(d.SELECTION_CHANGE_COMMAND,
()=>{let h=d.$getSelection(),l=d.$getPreviousSelection();if(d.$isRangeSelection(h)){let {anchor:x,focus:B}=h;var n=x.getNode(),p=B.getNode();n=ra(n);p=ra(p);var r=n&&a.is(ta(n)),t=p&&a.is(ta(p));let C=r!==t;t=r&&t;r=h.isBackward();C?(n=h.clone(),n.focus.set(a.getKey(),r?0:a.getChildrenSize(),"element"),d.$setSelection(n),na(c,g)):t&&!n.is(p)&&(g.setAnchorCellForSelection(f(n)),g.setFocusCellForSelection(f(p),!0))}if(h&&!h.is(l)&&(z(h)||z(l))&&g.gridSelection&&!g.gridSelection.is(l))return z(h)&&h.gridKey===
g.tableNodeKey?g.updateTableGridSelection(h):!z(h)&&z(l)&&l.gridKey===g.tableNodeKey&&g.updateTableGridSelection(null),!1;g.hasHijackedSelectionStyles&&!a.isSelected()?oa(c,g):!g.hasHijackedSelectionStyles&&a.isSelected()&&na(c,g);return!1},d.COMMAND_PRIORITY_CRITICAL));return g};exports.getCellFromTarget=ha;exports.getTableSelectionFromTableElement=function(a){return a.__lexicalTableSelection}
exports.$insertTableRow__EXPERIMENTAL=function(a=!0){var b=v.$getSelection();v.$isRangeSelection(b)||N(b)||H(118);b=b.focus.getNode();let [c,,d]=M(b),[e,k]=L(d,c,c);b=e[0].length;var {startRow:f}=k;if(a){a=f+c.__rowSpan-1;var m=e[a];f=C();for(var q=0;q<b;q++){let {cell:r,startRow:g}=m[q];g+r.__rowSpan-1<=a?f.append(z(w.NO_STATUS).append(v.$createParagraphNode())):r.setRowSpan(r.__rowSpan+1)}b=d.getChildAtIndex(a);F(b)||H(145);b.insertAfter(f)}else{m=e[f];a=C();for(q=0;q<b;q++){let {cell:r,startRow:g}=
m[q];g===f?a.append(z(w.NO_STATUS).append(v.$createParagraphNode())):r.setRowSpan(r.__rowSpan+1)}b=d.getChildAtIndex(f);F(b)||H(145);b.insertBefore(a)}};exports.$isTableCellNode=A;exports.$isTableNode=I;exports.$isTableRowNode=F;exports.$isTableSelection=N;exports.$removeTableRowAtIndex=function(a,b){let c=a.getChildren();if(b>=c.length||0>b)throw Error("Expected table cell to be inside of table row.");c[b].remove();return a};
exports.$unmergeCell=function(){var a=v.$getSelection();v.$isRangeSelection(a)||N(a)||H(118);a=a.anchor.getNode();let [b,c,d]=M(a);a=b.__colSpan;let e=b.__rowSpan;if(1<a){for(var k=1;k<a;k++)b.insertAfter(z(w.NO_STATUS));b.setColSpan(1)}if(1<e){let [q,r]=L(d,b,b),{startColumn:g,startRow:l}=r,n;for(k=1;k<e;k++){var f=l+k;let p=q[f];n=(n||c).getNextSibling();F(n)||H(125);var m=null;for(let t=0;t<g;t++){let u=p[t],y=u.cell;u.startRow===f&&(m=y);1<y.__colSpan&&(t+=y.__colSpan-1)}if(null===m)for(m=0;m<
a;m++)ka(n,z(w.NO_STATUS));else for(f=0;f<a;f++)m.insertAfter(z(w.NO_STATUS))}b.setRowSpan(1)}};exports.INSERT_TABLE_COMMAND=da;exports.TableCellHeaderStates=w;exports.TableCellNode=x;exports.TableNode=X;exports.TableObserver=qa;exports.TableRowNode=B;
exports.applyTableHandlers=function(a,b,c,d){function e(g){g=a.getCordsFromCellNode(g,f.table);return a.getDOMCellFromCordsOrThrow(g.x,g.y,f.table)}let k=c.getRootElement();if(null===k)throw Error("No root element.");let f=new qa(c,a.getKey()),m=c._window||window;b.__lexicalTableSelection=f;b.addEventListener("mousedown",g=>{setTimeout(()=>{if(0===g.button&&m){var l=ra(g.target);null!==l&&(W(g),f.setAnchorCellForSelection(l));var n=()=>{m.removeEventListener("mouseup",n);m.removeEventListener("mousemove",
p)},p=t=>{const u=ra(t.target);null===u||f.anchorX===u.x&&f.anchorY===u.y||(t.preventDefault(),f.setFocusCellForSelection(u))};m.addEventListener("mouseup",n);m.addEventListener("mousemove",p)}},0)});let q=g=>{0===g.button&&c.update(()=>{const l=v.$getSelection(),n=g.target;N(l)&&l.tableKey===f.tableNodeKey&&k.contains(n)&&f.clearHighlight()})};m.addEventListener("mousedown",q);f.listenersToRemove.add(()=>m.removeEventListener("mousedown",q));f.listenersToRemove.add(c.registerCommand(v.KEY_ARROW_DOWN_COMMAND,
g=>V(c,g,"down",a,f),v.COMMAND_PRIORITY_HIGH));f.listenersToRemove.add(c.registerCommand(v.KEY_ARROW_UP_COMMAND,g=>V(c,g,"up",a,f),v.COMMAND_PRIORITY_HIGH));f.listenersToRemove.add(c.registerCommand(v.KEY_ARROW_LEFT_COMMAND,g=>V(c,g,"backward",a,f),v.COMMAND_PRIORITY_HIGH));f.listenersToRemove.add(c.registerCommand(v.KEY_ARROW_RIGHT_COMMAND,g=>V(c,g,"forward",a,f),v.COMMAND_PRIORITY_HIGH));f.listenersToRemove.add(c.registerCommand(v.KEY_ESCAPE_COMMAND,g=>{var l=v.$getSelection();return N(l)&&(l=h.$findMatchingParent(l.focus.getNode(),
A),A(l))?(W(g),l.selectEnd(),!0):!1},v.COMMAND_PRIORITY_HIGH));let r=g=>()=>{var l=v.$getSelection();if(!U(l,a))return!1;if(N(l))return f.clearText(),!0;if(v.$isRangeSelection(l)){const t=h.$findMatchingParent(l.anchor.getNode(),u=>A(u));if(!A(t))return!1;var n=l.anchor.getNode(),p=l.focus.getNode();n=a.isParentOf(n);p=a.isParentOf(p);if(n&&!p||p&&!n)return f.clearText(),!0;n=(p=h.$findMatchingParent(l.anchor.getNode(),u=>v.$isElementNode(u)))&&h.$findMatchingParent(p,u=>v.$isElementNode(u)&&A(u.getParent()));
if(!v.$isElementNode(n)||!v.$isElementNode(p))return!1;if(g===v.DELETE_LINE_COMMAND&&null===n.getPreviousSibling())return!0;if((g===v.DELETE_CHARACTER_COMMAND||g===v.DELETE_WORD_COMMAND)&&l.isCollapsed()&&0===l.anchor.offset&&p!==n){l=p.getChildren();const u=v.$createParagraphNode();l.forEach(y=>u.append(y));p.replace(u);p.getWritable().__parent=t.getKey();return!0}}return!1};[v.DELETE_WORD_COMMAND,v.DELETE_LINE_COMMAND,v.DELETE_CHARACTER_COMMAND].forEach(g=>{f.listenersToRemove.add(c.registerCommand(g,
r(g),v.COMMAND_PRIORITY_CRITICAL))});b=g=>{const l=v.$getSelection();if(!U(l,a))return!1;if(N(l))return g.preventDefault(),g.stopPropagation(),f.clearText(),!0;v.$isRangeSelection(l)&&(g=h.$findMatchingParent(l.anchor.getNode(),n=>A(n)),A(g));return!1};f.listenersToRemove.add(c.registerCommand(v.KEY_BACKSPACE_COMMAND,b,v.COMMAND_PRIORITY_CRITICAL));f.listenersToRemove.add(c.registerCommand(v.KEY_DELETE_COMMAND,b,v.COMMAND_PRIORITY_CRITICAL));f.listenersToRemove.add(c.registerCommand(v.FORMAT_TEXT_COMMAND,
g=>{let l=v.$getSelection();if(!U(l,a))return!1;if(N(l))return f.formatCells(g),!0;v.$isRangeSelection(l)&&(g=h.$findMatchingParent(l.anchor.getNode(),n=>A(n)),A(g));return!1},v.COMMAND_PRIORITY_CRITICAL));f.listenersToRemove.add(c.registerCommand(v.CONTROLLED_TEXT_INSERTION_COMMAND,()=>{var g=v.$getSelection();if(!U(g,a))return!1;N(g)?f.clearHighlight():v.$isRangeSelection(g)&&(g=h.$findMatchingParent(g.anchor.getNode(),l=>A(l)),A(g));return!1},v.COMMAND_PRIORITY_CRITICAL));d&&f.listenersToRemove.add(c.registerCommand(v.KEY_TAB_COMMAND,
g=>{var l=v.$getSelection();if(!v.$isRangeSelection(l)||!l.isCollapsed()||!U(l,a))return!1;l=Aa(l.anchor.getNode());if(null===l)return!1;W(g);l=a.getCordsFromCellNode(l,f.table);ya(f,a,l.x,l.y,g.shiftKey?"backward":"forward");return!0},v.COMMAND_PRIORITY_CRITICAL));f.listenersToRemove.add(c.registerCommand(v.FOCUS_COMMAND,()=>a.isSelected(),v.COMMAND_PRIORITY_HIGH));f.listenersToRemove.add(c.registerCommand(v.SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,g=>{let {nodes:l,selection:n}=g;g=n.getStartEndPoints();
var p=N(n);p=v.$isRangeSelection(n)&&null!==h.$findMatchingParent(n.anchor.getNode(),G=>A(G))&&null!==h.$findMatchingParent(n.focus.getNode(),G=>A(G))||p;if(1!==l.length||!I(l[0])||!p||null===g)return!1;var [t]=g,u=l[0];g=u.getChildren();p=u.getFirstChildOrThrow().getChildrenSize();u=u.getChildrenSize();var y=h.$findMatchingParent(t.getNode(),G=>A(G)),D=(t=y&&h.$findMatchingParent(y,G=>F(G)))&&h.$findMatchingParent(t,G=>I(G));if(!A(y)||!F(t)||!I(D))return!1;var E=t.getIndexWithinParent(),K=Math.min(D.getChildrenSize()-
1,E+u-1);u=y.getIndexWithinParent();y=Math.min(t.getChildrenSize()-1,u+p-1);p=Math.min(u,y);t=Math.min(E,K);u=Math.max(u,y);E=Math.max(E,K);D=D.getChildren();K=0;let la,ma;for(y=t;y<=E;y++){var Z=D[y];if(!F(Z))return!1;var aa=g[K];if(!F(aa))return!1;Z=Z.getChildren();aa=aa.getChildren();let G=0;for(let R=p;R<=u;R++){let S=Z[R];if(!A(S))return!1;let va=aa[G];if(!A(va))return!1;y===t&&R===p?la=S.getKey():y===E&&R===u&&(ma=S.getKey());let Da=S.getChildren();va.getChildren().forEach(T=>{v.$isTextNode(T)&&
v.$createParagraphNode().append(T);S.append(T)});Da.forEach(T=>T.remove());G++}K++}la&&ma&&(g=O(),g.set(l[0].getKey(),la,ma),v.$setSelection(g));return!0},v.COMMAND_PRIORITY_CRITICAL));f.listenersToRemove.add(c.registerCommand(v.SELECTION_CHANGE_COMMAND,()=>{let g=v.$getSelection(),l=v.$getPreviousSelection();if(v.$isRangeSelection(g)){let {anchor:y,focus:D}=g;var n=y.getNode(),p=D.getNode();n=Aa(n);p=Aa(p);var t=n&&a.is(Ba(n)),u=p&&a.is(Ba(p));let E=t!==u;u=t&&u;t=g.isBackward();E?(n=g.clone(),n.focus.set(a.getKey(),
t?0:a.getChildrenSize(),"element"),v.$setSelection(n),wa(c,f)):u&&!n.is(p)&&(f.setAnchorCellForSelection(e(n)),f.setFocusCellForSelection(e(p),!0))}if(g&&!g.is(l)&&(N(g)||N(l))&&f.tableSelection&&!f.tableSelection.is(l))return N(g)&&g.tableKey===f.tableNodeKey?f.updateTableTableSelection(g):!N(g)&&N(l)&&l.tableKey===f.tableNodeKey&&f.updateTableTableSelection(null),!1;f.hasHijackedSelectionStyles&&!a.isSelected()?xa(c,f):!f.hasHijackedSelectionStyles&&a.isSelected()&&wa(c,f);return!1},v.COMMAND_PRIORITY_CRITICAL));
return f};exports.getDOMCellFromTarget=ra;exports.getTableObserverFromTableElement=function(a){return a.__lexicalTableSelection}

@@ -8,4 +8,4 @@ /**

*/
import type { DOMConversionMap, DOMConversionOutput, DOMExportOutput, EditorConfig, LexicalEditor, LexicalNode, NodeKey, SerializedGridCellNode, Spread } from 'lexical';
import { DEPRECATED_GridCellNode } from 'lexical';
import type { DOMConversionMap, DOMConversionOutput, DOMExportOutput, EditorConfig, LexicalEditor, LexicalNode, NodeKey, SerializedElementNode, Spread } from 'lexical';
import { ElementNode } from 'lexical';
export declare const TableCellHeaderStates: {

@@ -19,9 +19,15 @@ BOTH: number;

export type SerializedTableCellNode = Spread<{
colSpan?: number;
rowSpan?: number;
headerState: TableCellHeaderState;
width?: number;
backgroundColor?: null | string;
}, SerializedGridCellNode>;
}, SerializedElementNode>;
/** @noInheritDoc */
export declare class TableCellNode extends DEPRECATED_GridCellNode {
export declare class TableCellNode extends ElementNode {
/** @internal */
__colSpan: number;
/** @internal */
__rowSpan: number;
/** @internal */
__headerState: TableCellHeaderState;

@@ -40,2 +46,6 @@ /** @internal */

exportJSON(): SerializedTableCellNode;
getColSpan(): number;
setColSpan(colSpan: number): this;
getRowSpan(): number;
setRowSpan(rowSpan: number): this;
getTag(): string;

@@ -42,0 +52,0 @@ setHeaderStyles(headerState: TableCellHeaderState): TableCellHeaderState;

@@ -9,10 +9,8 @@ /**

import type { TableCellNode } from './LexicalTableCellNode';
import type { Cell, Grid } from './LexicalTableSelection';
import type { DOMConversionMap, DOMConversionOutput, DOMExportOutput, EditorConfig, LexicalEditor, LexicalNode, NodeKey, SerializedElementNode } from 'lexical';
import { DEPRECATED_GridNode } from 'lexical';
import { ElementNode } from 'lexical';
import { TableDOMCell, TableDOMTable } from './LexicalTableObserver';
export type SerializedTableNode = SerializedElementNode;
/** @noInheritDoc */
export declare class TableNode extends DEPRECATED_GridNode {
/** @internal */
__grid?: Grid;
export declare class TableNode extends ElementNode {
static getType(): string;

@@ -30,16 +28,16 @@ static clone(node: TableNode): TableNode;

isShadowRoot(): boolean;
getCordsFromCellNode(tableCellNode: TableCellNode, grid: Grid): {
getCordsFromCellNode(tableCellNode: TableCellNode, table: TableDOMTable): {
x: number;
y: number;
};
getCellFromCords(x: number, y: number, grid: Grid): Cell | null;
getCellFromCordsOrThrow(x: number, y: number, grid: Grid): Cell;
getCellNodeFromCords(x: number, y: number, grid: Grid): TableCellNode | null;
getCellNodeFromCordsOrThrow(x: number, y: number, grid: Grid): TableCellNode;
getDOMCellFromCords(x: number, y: number, table: TableDOMTable): null | TableDOMCell;
getDOMCellFromCordsOrThrow(x: number, y: number, table: TableDOMTable): TableDOMCell;
getCellNodeFromCords(x: number, y: number, table: TableDOMTable): null | TableCellNode;
getCellNodeFromCordsOrThrow(x: number, y: number, table: TableDOMTable): TableCellNode;
canSelectBefore(): true;
canIndent(): false;
}
export declare function $getElementGridForTableNode(editor: LexicalEditor, tableNode: TableNode): Grid;
export declare function $getElementForTableNode(editor: LexicalEditor, tableNode: TableNode): TableDOMTable;
export declare function convertTableElement(_domNode: Node): DOMConversionOutput;
export declare function $createTableNode(): TableNode;
export declare function $isTableNode(node: LexicalNode | null | undefined): node is TableNode;

@@ -9,3 +9,3 @@ /**

import type { Spread } from 'lexical';
import { DEPRECATED_GridRowNode, DOMConversionMap, DOMConversionOutput, EditorConfig, LexicalNode, NodeKey, SerializedElementNode } from 'lexical';
import { DOMConversionMap, DOMConversionOutput, EditorConfig, ElementNode, LexicalNode, NodeKey, SerializedElementNode } from 'lexical';
export type SerializedTableRowNode = Spread<{

@@ -15,3 +15,3 @@ height: number;

/** @noInheritDoc */
export declare class TableRowNode extends DEPRECATED_GridRowNode {
export declare class TableRowNode extends ElementNode {
/** @internal */

@@ -18,0 +18,0 @@ __height?: number;

@@ -8,45 +8,46 @@ /**

*/
import type { LexicalEditor, NodeKey, TextFormatType } from 'lexical';
import { type GridSelection } from './LexicalGridSelection';
export type Cell = {
elem: HTMLElement;
highlighted: boolean;
hasBackgroundColor: boolean;
x: number;
y: number;
import { BaseSelection, LexicalNode, NodeKey, PointType } from 'lexical';
import { TableCellNode } from './LexicalTableCellNode';
export type TableSelectionShape = {
fromX: number;
fromY: number;
toX: number;
toY: number;
};
export type Cells = Array<Array<Cell | undefined> | undefined>;
export type Grid = {
cells: Cells;
columns: number;
rows: number;
export type TableMapValueType = {
cell: TableCellNode;
startRow: number;
startColumn: number;
};
export declare class TableSelection {
focusX: number;
focusY: number;
listenersToRemove: Set<() => void>;
grid: Grid;
isHighlightingCells: boolean;
anchorX: number;
anchorY: number;
tableNodeKey: NodeKey;
anchorCell: Cell | null;
focusCell: Cell | null;
anchorCellNodeKey: NodeKey | null;
focusCellNodeKey: NodeKey | null;
editor: LexicalEditor;
gridSelection: GridSelection | null;
hasHijackedSelectionStyles: boolean;
constructor(editor: LexicalEditor, tableNodeKey: string);
getGrid(): Grid;
removeListeners(): void;
trackTableGrid(): void;
clearHighlight(): void;
enableHighlightStyle(): void;
disableHighlightStyle(): void;
updateTableGridSelection(selection: GridSelection | null): void;
setFocusCellForSelection(cell: Cell, ignoreStart?: boolean): void;
setAnchorCellForSelection(cell: Cell): void;
formatCells(type: TextFormatType): void;
clearText(): void;
export type TableMapType = Array<Array<TableMapValueType>>;
export declare class TableSelection implements BaseSelection {
tableKey: NodeKey;
anchor: PointType;
focus: PointType;
_cachedNodes: Array<LexicalNode> | null;
dirty: boolean;
constructor(tableKey: NodeKey, anchor: PointType, focus: PointType);
getStartEndPoints(): [PointType, PointType];
/**
* Returns whether the Selection is "backwards", meaning the focus
* logically precedes the anchor in the EditorState.
* @returns true if the Selection is backwards, false otherwise.
*/
isBackward(): boolean;
getCachedNodes(): LexicalNode[] | null;
setCachedNodes(nodes: LexicalNode[] | null): void;
is(selection: null | BaseSelection): boolean;
set(tableKey: NodeKey, anchorCellKey: NodeKey, focusCellKey: NodeKey): void;
clone(): TableSelection;
isCollapsed(): boolean;
extract(): Array<LexicalNode>;
insertRawText(text: string): void;
insertText(): void;
insertNodes(nodes: Array<LexicalNode>): void;
getShape(): TableSelectionShape;
getNodes(): Array<LexicalNode>;
getTextContent(): string;
}
export declare function $isTableSelection(x: unknown): x is TableSelection;
export declare function $createTableSelection(): TableSelection;
export declare function $getChildrenRecursively(node: LexicalNode): Array<LexicalNode>;

@@ -8,22 +8,22 @@ /**

*/
import type { GridSelection } from './LexicalGridSelection';
import type { TableNode } from './LexicalTableNode';
import type { Cell, Grid } from './LexicalTableSelection';
import type { TableDOMCell } from './LexicalTableObserver';
import type { TableSelection } from './LexicalTableSelection';
import type { LexicalEditor, LexicalNode, RangeSelection } from 'lexical';
import { TableSelection } from './LexicalTableSelection';
import { TableDOMTable, TableObserver } from './LexicalTableObserver';
declare const LEXICAL_ELEMENT_KEY = "__lexicalTableSelection";
export declare function applyTableHandlers(tableNode: TableNode, tableElement: HTMLTableElementWithWithTableSelectionState, editor: LexicalEditor, hasTabHandler: boolean): TableSelection;
export type HTMLTableElementWithWithTableSelectionState = HTMLTableElement & Record<typeof LEXICAL_ELEMENT_KEY, TableSelection>;
export declare function attachTableSelectionToTableElement(tableElement: HTMLTableElementWithWithTableSelectionState, tableSelection: TableSelection): void;
export declare function getTableSelectionFromTableElement(tableElement: HTMLTableElementWithWithTableSelectionState): TableSelection | null;
export declare function getCellFromTarget(node: Node): Cell | null;
export declare function applyTableHandlers(tableNode: TableNode, tableElement: HTMLTableElementWithWithTableSelectionState, editor: LexicalEditor, hasTabHandler: boolean): TableObserver;
export type HTMLTableElementWithWithTableSelectionState = HTMLTableElement & Record<typeof LEXICAL_ELEMENT_KEY, TableObserver>;
export declare function attachTableObserverToTableElement(tableElement: HTMLTableElementWithWithTableSelectionState, tableObserver: TableObserver): void;
export declare function getTableObserverFromTableElement(tableElement: HTMLTableElementWithWithTableSelectionState): TableObserver | null;
export declare function getDOMCellFromTarget(node: Node): TableDOMCell | null;
export declare function doesTargetContainText(node: Node): boolean;
export declare function getTableGrid(tableElement: HTMLElement): Grid;
export declare function $updateDOMForSelection(editor: LexicalEditor, grid: Grid, selection: GridSelection | RangeSelection | null): void;
export declare function $forEachGridCell(grid: Grid, cb: (cell: Cell, lexicalNode: LexicalNode, cords: {
export declare function getTable(tableElement: HTMLElement): TableDOMTable;
export declare function $updateDOMForSelection(editor: LexicalEditor, table: TableDOMTable, selection: TableSelection | RangeSelection | null): void;
export declare function $forEachTableCell(grid: TableDOMTable, cb: (cell: TableDOMCell, lexicalNode: LexicalNode, cords: {
x: number;
y: number;
}) => void): void;
export declare function $addHighlightStyleToTable(editor: LexicalEditor, tableSelection: TableSelection): void;
export declare function $removeHighlightStyleToTable(editor: LexicalEditor, tableSelection: TableSelection): void;
export declare function $addHighlightStyleToTable(editor: LexicalEditor, tableSelection: TableObserver): void;
export declare function $removeHighlightStyleToTable(editor: LexicalEditor, tableObserver: TableObserver): void;
export {};

@@ -8,3 +8,4 @@ /**

*/
import type { Grid } from './LexicalTableSelection';
import type { TableMapType, TableMapValueType } from './LexicalTableSelection';
import type { PointType } from 'lexical';
import { LexicalNode } from 'lexical';

@@ -14,2 +15,3 @@ import { InsertTableCommandPayloadHeaders } from '.';

import { TableNode } from './LexicalTableNode';
import { TableDOMTable } from './LexicalTableObserver';
import { TableRowNode } from './LexicalTableRowNode';

@@ -28,7 +30,7 @@ export declare function $createTableNodeWithDimensions(rowCount: number, columnCount: number, includeHeaders?: InsertTableCommandPayloadHeaders): TableNode;

};
export declare function $getTableCellSiblingsFromTableCellNode(tableCellNode: TableCellNode, grid: Grid): TableCellSiblings;
export declare function $getTableCellSiblingsFromTableCellNode(tableCellNode: TableCellNode, table: TableDOMTable): TableCellSiblings;
export declare function $removeTableRowAtIndex(tableNode: TableNode, indexToDelete: number): TableNode;
export declare function $insertTableRow(tableNode: TableNode, targetIndex: number, shouldInsertAfter: boolean | undefined, rowCount: number, grid: Grid): TableNode;
export declare function $insertTableRow(tableNode: TableNode, targetIndex: number, shouldInsertAfter: boolean | undefined, rowCount: number, table: TableDOMTable): TableNode;
export declare function $insertTableRow__EXPERIMENTAL(insertAfter?: boolean): void;
export declare function $insertTableColumn(tableNode: TableNode, targetIndex: number, shouldInsertAfter: boolean | undefined, columnCount: number, grid: Grid): TableNode;
export declare function $insertTableColumn(tableNode: TableNode, targetIndex: number, shouldInsertAfter: boolean | undefined, columnCount: number, table: TableDOMTable): TableNode;
export declare function $insertTableColumn__EXPERIMENTAL(insertAfter?: boolean): void;

@@ -39,1 +41,9 @@ export declare function $deleteTableColumn(tableNode: TableNode, targetIndex: number): TableNode;

export declare function $unmergeCell(): void;
export declare function $computeTableMap(grid: TableNode, cellA: TableCellNode, cellB: TableCellNode): [TableMapType, TableMapValueType, TableMapValueType];
export declare function $getNodeTriplet(source: PointType | LexicalNode | TableCellNode): [TableCellNode, TableRowNode, TableNode];
export declare function $getTableCellNodeRect(tableCellNode: TableCellNode): {
rowIndex: number;
columnIndex: number;
rowSpan: number;
colSpan: number;
} | null;

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

"license": "MIT",
"version": "0.12.6",
"version": "0.13.0",
"main": "LexicalTable.js",
"peerDependencies": {
"lexical": "0.12.6"
"lexical": "0.13.0"
},
"dependencies": {
"@lexical/utils": "0.12.6"
"@lexical/utils": "0.13.0"
},

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

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

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc