Socket
Socket
Sign inDemoInstall

@lexical/table

Package Overview
Dependencies
Maintainers
7
Versions
183
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.11.2 to 0.11.3

110

LexicalTable.prod.js

@@ -7,65 +7,65 @@ /**

*/
'use strict';var d=require("lexical"),t=require("@lexical/utils"),w=require("@lexical/table");let x=/^(\d+(?:\.\d+)?)px$/,y={BOTH:3,COLUMN:2,NO_STATUS:0,ROW:1};
class z extends d.DEPRECATED_GridCellNode{static getType(){return"tablecell"}static clone(a){let b=new z(a.__headerState,a.__colSpan,a.__width,a.__key);b.__rowSpan=a.__rowSpan;b.__backgroundColor=a.__backgroundColor;return b}static importDOM(){return{td:()=>({conversion:B,priority:0}),th:()=>({conversion:B,priority:0})}}static importJSON(a){let b=a.rowSpan||1,c=C(a.headerState,a.colSpan||1,a.width||void 0);c.__rowSpan=b;c.__backgroundColor=a.backgroundColor||null;return c}constructor(a=y.NO_STATUS,
'use strict';var d=require("lexical"),t=require("@lexical/utils");let w=/^(\d+(?:\.\d+)?)px$/,x={BOTH:3,COLUMN:2,NO_STATUS:0,ROW:1};
class y extends d.DEPRECATED_GridCellNode{static getType(){return"tablecell"}static clone(a){let b=new y(a.__headerState,a.__colSpan,a.__width,a.__key);b.__rowSpan=a.__rowSpan;b.__backgroundColor=a.__backgroundColor;return b}static importDOM(){return{td:()=>({conversion:z,priority:0}),th:()=>({conversion:z,priority:0})}}static importJSON(a){let b=a.rowSpan||1,c=B(a.headerState,a.colSpan||1,a.width||void 0);c.__rowSpan=b;c.__backgroundColor=a.backgroundColor||null;return c}constructor(a=x.NO_STATUS,
b=1,c,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);t.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!==y.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 B(a){var b=a.nodeName.toLowerCase();let c=void 0;x.test(a.style.width)&&(c=parseFloat(a.style.width));b=C("th"===b?y.ROW:y.NO_STATUS,a.colSpan,c);b.__rowSpan=a.rowSpan;a=a.style.backgroundColor;""!==a&&(b.__backgroundColor=a);return{forChild:(e,g)=>{if(D(g)&&!d.$isElementNode(e)){g=d.$createParagraphNode();if(d.$isLineBreakNode(e)&&"\n"===e.getTextContent())return null;g.append(e);return g}return e},node:b}}function C(a,b=1,c){return d.$applyNodeReplacement(new z(a,b,c))}
function D(a){return a instanceof z}
class E extends d.DEPRECATED_GridRowNode{static getType(){return"tablerow"}static clone(a){return new E(a.__height,a.__key)}static importDOM(){return{tr:()=>({conversion:aa,priority:0})}}static importJSON(a){return F(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`);t.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 aa(a){let b=void 0;x.test(a.style.height)&&(b=parseFloat(a.style.height));return{node:F(b)}}function F(a){return d.$applyNodeReplacement(new E(a))}function G(a){return a instanceof E}
function I(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 ba="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement;
class J{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 g=b[e].target.nodeName;if("TABLE"===g||"TR"===g){c=!0;break}}if(c){c=this.editor.getElementByKey(this.tableNodeKey);if(!c)throw Error("Expected to find TableElement in DOM");this.grid=K(c)}})});this.editor.update(()=>{let b=this.editor.getElementByKey(this.tableNodeKey);if(!b)throw Error("Expected to find TableElement in DOM");this.grid=K(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(!L(b))throw Error("Expected TableNode.");b=a.getElementByKey(this.tableNodeKey);if(!b)throw Error("Expected to find TableElement in DOM");b=K(b);M(a,b,null);d.$setSelection(null);a.dispatchCommand(d.SELECTION_CHANGE_COMMAND,
this.getWritable();b.__headerState=(b.__headerState&a)===a?b.__headerState-a:b.__headerState+a;return b}hasHeaderState(a){return(this.getHeaderStyles()&a)===a}hasHeader(){return this.getLatest().__headerState!==x.NO_STATUS}updateDOM(a){return a.__headerState!==this.__headerState||a.__width!==this.__width||a.__colSpan!==this.__colSpan||a.__rowSpan!==this.__rowSpan||a.__backgroundColor!==this.__backgroundColor}isShadowRoot(){return!0}collapseAtStart(){return!0}canBeEmpty(){return!1}canIndent(){return!1}}
function z(a){var b=a.nodeName.toLowerCase();let c=void 0;w.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;a=a.style.backgroundColor;""!==a&&(b.__backgroundColor=a);return{forChild:(e,g)=>{if(C(g)&&!d.$isElementNode(e)){g=d.$createParagraphNode();if(d.$isLineBreakNode(e)&&"\n"===e.getTextContent())return null;g.append(e);return g}return e},node:b}}function B(a,b=1,c){return d.$applyNodeReplacement(new y(a,b,c))}
function C(a){return a instanceof y}
class D extends d.DEPRECATED_GridRowNode{static getType(){return"tablerow"}static clone(a){return new D(a.__height,a.__key)}static importDOM(){return{tr:()=>({conversion:aa,priority:0})}}static importJSON(a){return E(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`);t.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 aa(a){let b=void 0;w.test(a.style.height)&&(b=parseFloat(a.style.height));return{node:E(b)}}function E(a){return d.$applyNodeReplacement(new D(a))}function F(a){return a instanceof D}
function G(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 ba="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement;
class I{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 g=b[e].target.nodeName;if("TABLE"===g||"TR"===g){c=!0;break}}if(c){c=this.editor.getElementByKey(this.tableNodeKey);if(!c)throw Error("Expected to find TableElement in DOM");this.grid=J(c)}})});this.editor.update(()=>{let b=this.editor.getElementByKey(this.tableNodeKey);if(!b)throw Error("Expected to find TableElement in DOM");this.grid=J(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(!K(b))throw Error("Expected TableNode.");b=a.getElementByKey(this.tableNodeKey);if(!b)throw Error("Expected to find TableElement in DOM");b=J(b);L(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");t.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");t.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();M(b,this.grid,this.gridSelection)}else null==a&&this.clearHighlight()}setFocusCellForSelection(a,b=!1){let c=this.editor;c.update(()=>{var e=d.$getNodeByKey(this.tableNodeKey);if(!L(e))throw Error("Expected TableNode.");if(!c.getElementByKey(this.tableNodeKey))throw Error("Expected to find TableElement in DOM");
this.hasHijackedSelectionStyles=!0})}updateTableGridSelection(a){if(null!=a&&a.gridKey===this.tableNodeKey){let b=this.editor;this.gridSelection=a;this.isHighlightingCells=!0;this.disableHighlightStyle();L(b,this.grid,this.gridSelection)}else null==a&&this.clearHighlight()}setFocusCellForSelection(a,b=!1){let c=this.editor;c.update(()=>{var e=d.$getNodeByKey(this.tableNodeKey);if(!K(e))throw Error("Expected TableNode.");if(!c.getElementByKey(this.tableNodeKey))throw Error("Expected to find TableElement in DOM");
e=a.x;let g=a.y;this.focusCell=a;if(null!==this.anchorCell){let h=ba?(c._window||window).getSelection():null;h&&h.setBaseAndExtent(this.anchorCell.elem,0,this.focusCell.elem,0)}if(!this.isHighlightingCells&&(this.anchorX!==e||this.anchorY!==g||b))this.isHighlightingCells=!0,this.disableHighlightStyle();else if(e===this.focusX&&g===this.focusY)return;this.focusX=e;this.focusY=g;this.isHighlightingCells&&(e=d.$getNearestNodeFromDOMNode(a.elem),null!=this.gridSelection&&null!=this.anchorCellNodeKey&&
D(e)&&(e=e.getKey(),this.gridSelection=this.gridSelection.clone()||d.DEPRECATED_$createGridSelection(),this.focusCellNodeKey=e,this.gridSelection.set(this.tableNodeKey,this.anchorCellNodeKey,this.focusCellNodeKey),d.$setSelection(this.gridSelection),c.dispatchCommand(d.SELECTION_CHANGE_COMMAND,void 0),M(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);
D(b)&&(b=b.getKey(),this.gridSelection=d.DEPRECATED_$createGridSelection(),this.anchorCellNodeKey=b)})}formatCells(a){this.editor.update(()=>{let b=d.$getSelection();d.DEPRECATED_$isGridSelection(b)||I(11);let c=d.$createRangeSelection(),e=c.anchor,g=c.focus;b.getNodes().forEach(h=>{D(h)&&0!==h.getTextContentSize()&&(e.set(h.getKey(),0,"element"),g.set(h.getKey(),h.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(!L(b))throw Error("Expected TableNode.");var c=d.$getSelection();d.DEPRECATED_$isGridSelection(c)||I(11);c=c.getNodes().filter(D);c.length===this.grid.columns*this.grid.rows?(b.selectPrevious(),b.remove(),d.$getRoot().selectStart()):(c.forEach(e=>{if(d.$isElementNode(e)){let g=d.$createParagraphNode(),h=d.$createTextNode();g.append(h);e.append(g);e.getChildren().forEach(f=>{f!==g&&f.remove()})}}),M(a,this.grid,null),d.$setSelection(null),
a.dispatchCommand(d.SELECTION_CHANGE_COMMAND,void 0))})}}function N(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 K(a){let b=[],c={cells:b,columns:0,rows:0};var e=a.firstChild;let g=a=0;for(b.length=0;null!=e;){var h=e.nodeName;if("TD"===h||"TH"===h)h=e,h={elem:h,hasBackgroundColor:""!==h.style.backgroundColor,highlighted:!1,x:a,y:g},e._cell=h,void 0===b[g]&&(b[g]=[]),b[g][a]=h;else if(h=e.firstChild,null!=h){e=h;continue}h=e.nextSibling;if(null!=h)a++,e=h;else if(h=e.parentNode,null!=h){e=h.nextSibling;if(null==e)break;g++;a=0}}c.columns=a+1;c.rows=g+1;return c}
function M(a,b,c){let e=new Set(c?c.getNodes():[]);O(b,(g,h)=>{let f=g.elem;e.has(h)?(g.highlighted=!0,ca(a,g)):(g.highlighted=!1,da(a,g),f.getAttribute("style")||f.removeAttribute("style"))})}function O(a,b){({cells:a}=a);for(let c=0;c<a.length;c++){let e=a[c];for(let g=0;g<e.length;g++){let h=e[g],f=d.$getNearestNodeFromDOMNode(h.elem);null!==f&&b(h,f,{x:g,y:c})}}}function ea(a,b){b.disableHighlightStyle();O(b.grid,c=>{c.highlighted=!0;ca(a,c)})}
function fa(a,b){b.enableHighlightStyle();O(b.grid,c=>{let e=c.elem;c.highlighted=!1;da(a,c);e.getAttribute("style")||e.removeAttribute("style")})}
let ha=(a,b,c,e,g)=>{const h="forward"===g;switch(g){case "backward":case "forward":return c!==(h?a.grid.columns-1:0)?(a=b.getCellNodeFromCordsOrThrow(c+(h?1:-1),e,a.grid),h?a.selectStart():a.selectEnd()):e!==(h?a.grid.rows-1:0)?(a=b.getCellNodeFromCordsOrThrow(h?0:a.grid.columns-1,e+(h?1:-1),a.grid),h?a.selectStart():a.selectEnd()):h?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}},ia=(a,b,c,e,g)=>{const h="forward"===g;switch(g){case "backward":case "forward":return c!==(h?a.grid.columns-1:0)&&a.setFocusCellForSelection(b.getCellFromCordsOrThrow(c+(h?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;
C(e)&&(e=e.getKey(),this.gridSelection=this.gridSelection.clone()||d.DEPRECATED_$createGridSelection(),this.focusCellNodeKey=e,this.gridSelection.set(this.tableNodeKey,this.anchorCellNodeKey,this.focusCellNodeKey),d.$setSelection(this.gridSelection),c.dispatchCommand(d.SELECTION_CHANGE_COMMAND,void 0),L(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);
C(b)&&(b=b.getKey(),this.gridSelection=d.DEPRECATED_$createGridSelection(),this.anchorCellNodeKey=b)})}formatCells(a){this.editor.update(()=>{let b=d.$getSelection();d.DEPRECATED_$isGridSelection(b)||G(11);let c=d.$createRangeSelection(),e=c.anchor,g=c.focus;b.getNodes().forEach(h=>{C(h)&&0!==h.getTextContentSize()&&(e.set(h.getKey(),0,"element"),g.set(h.getKey(),h.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(!K(b))throw Error("Expected TableNode.");var c=d.$getSelection();d.DEPRECATED_$isGridSelection(c)||G(11);c=c.getNodes().filter(C);c.length===this.grid.columns*this.grid.rows?(b.selectPrevious(),b.remove(),d.$getRoot().selectStart()):(c.forEach(e=>{if(d.$isElementNode(e)){let g=d.$createParagraphNode(),h=d.$createTextNode();g.append(h);e.append(g);e.getChildren().forEach(f=>{f!==g&&f.remove()})}}),L(a,this.grid,null),d.$setSelection(null),
a.dispatchCommand(d.SELECTION_CHANGE_COMMAND,void 0))})}}function M(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 J(a){let b=[],c={cells:b,columns:0,rows:0};var e=a.firstChild;let g=a=0;for(b.length=0;null!=e;){var h=e.nodeName;if("TD"===h||"TH"===h)h=e,h={elem:h,hasBackgroundColor:""!==h.style.backgroundColor,highlighted:!1,x:a,y:g},e._cell=h,void 0===b[g]&&(b[g]=[]),b[g][a]=h;else if(h=e.firstChild,null!=h){e=h;continue}h=e.nextSibling;if(null!=h)a++,e=h;else if(h=e.parentNode,null!=h){e=h.nextSibling;if(null==e)break;g++;a=0}}c.columns=a+1;c.rows=g+1;return c}
function L(a,b,c){let e=new Set(c?c.getNodes():[]);N(b,(g,h)=>{let f=g.elem;e.has(h)?(g.highlighted=!0,O(a,g)):(g.highlighted=!1,ca(a,g),f.getAttribute("style")||f.removeAttribute("style"))})}function N(a,b){({cells:a}=a);for(let c=0;c<a.length;c++){let e=a[c];for(let g=0;g<e.length;g++){let h=e[g],f=d.$getNearestNodeFromDOMNode(h.elem);null!==f&&b(h,f,{x:g,y:c})}}}function da(a,b){b.disableHighlightStyle();N(b.grid,c=>{c.highlighted=!0;O(a,c)})}
function ea(a,b){b.enableHighlightStyle();N(b.grid,c=>{let e=c.elem;c.highlighted=!1;ca(a,c);e.getAttribute("style")||e.removeAttribute("style")})}
let fa=(a,b,c,e,g)=>{const h="forward"===g;switch(g){case "backward":case "forward":return c!==(h?a.grid.columns-1:0)?(a=b.getCellNodeFromCordsOrThrow(c+(h?1:-1),e,a.grid),h?a.selectStart():a.selectEnd()):e!==(h?a.grid.rows-1:0)?(a=b.getCellNodeFromCordsOrThrow(h?0:a.grid.columns-1,e+(h?1:-1),a.grid),h?a.selectStart():a.selectEnd()):h?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}},ha=(a,b,c,e,g)=>{const h="forward"===g;switch(g){case "backward":case "forward":return c!==(h?a.grid.columns-1:0)&&a.setFocusCellForSelection(b.getCellFromCordsOrThrow(c+(h?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 P(a,b){if(d.$isRangeSelection(a)||d.DEPRECATED_$isGridSelection(a)){let c=b.isParentOf(a.anchor.getNode());a=b.isParentOf(a.focus.getNode());return c&&a}return!1}
function ca(a,b){a=b.elem;b=d.$getNearestNodeFromDOMNode(a);D(b)||I(131);null===b.getBackgroundColor()?a.style.setProperty("background-color","rgb(172,206,247)"):a.style.setProperty("background-image","linear-gradient(to right, rgba(172,206,247,0.85), rgba(172,206,247,0.85))");a.style.setProperty("caret-color","transparent")}
function da(a,b){a=b.elem;b=d.$getNearestNodeFromDOMNode(a);D(b)||I(131);null===b.getBackgroundColor()&&a.style.removeProperty("background-color");a.style.removeProperty("background-image");a.style.removeProperty("caret-color")}function Q(a){a=t.$findMatchingParent(a,D);return D(a)?a:null}function ja(a){a=t.$findMatchingParent(a,w.$isTableNode);return w.$isTableNode(a)?a:null}
function R(a,b,c,e,g){var h=d.$getSelection();if(!P(h,e))return!1;if(d.$isRangeSelection(h)&&h.isCollapsed()){if("backward"===c||"forward"===c)return!1;let {anchor:q,focus:r}=h;h=t.$findMatchingParent(q.getNode(),D);var f=t.$findMatchingParent(r.getNode(),D);if(!D(h)||!h.is(f))return!1;f=a.getElementByKey(h.__key);var 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?h.getFirstChild():h.getLastChild();if(null==m)return!1;a=a.getElementByKey(m.__key);if(null==a)return!1;a=a.getBoundingClientRect();if("up"===c?a.top>f.top-f.height:f.bottom+f.height>a.bottom){S(b);h=e.getCordsFromCellNode(h,g.grid);if(b.shiftKey)c=e.getCellFromCordsOrThrow(h.x,h.y,g.grid),g.setAnchorCellForSelection(c),g.setFocusCellForSelection(c,!0);else return ha(g,e,h.x,h.y,c);return!0}}else if(d.DEPRECATED_$isGridSelection(h)){let {anchor:q,focus:r}=h;h=t.$findMatchingParent(q.getNode(),
D);a=t.$findMatchingParent(r.getNode(),D);if(!D(h)||!D(a))return!1;S(b);if(b.shiftKey)return b=e.getCordsFromCellNode(a,g.grid),ia(g,e,b.x,b.y,c);a.selectEnd();return!0}return!1}function S(a){a.preventDefault();a.stopImmediatePropagation();a.stopPropagation()}
class T extends d.DEPRECATED_GridNode{static getType(){return"table"}static clone(a){return new T(a.__key)}static importDOM(){return{table:()=>({conversion:ka,priority:1})}}static importJSON(){return U()}constructor(a){super(a)}exportJSON(){return{...super.exportJSON(),type:"table",version:1}}createDOM(a){let b=document.createElement("table");t.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"),
g=document.createElement("tbody");g.append(...b.children);b=this.getFirstChildOrThrow();if(!G(b))throw Error("Expected to find row node.");b=b.getChildrenSize();for(let h=0;h<b;h++){let f=document.createElement("col");e.append(f)}c.replaceChildren(e,g);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 g=e[b];if(null==g)throw Error(`Row not found at y:${b}`);g=g.findIndex(({elem:h})=>d.$getNearestNodeFromDOMNode(h)===
a);if(-1!==g)return{x:g,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 D(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 ka(){return{node:U()}}function U(){return d.$applyNodeReplacement(new T)}function L(a){return a instanceof T}function W(a){a=t.$findMatchingParent(a,b=>G(b));if(G(a))return a;throw Error("Expected table cell to be inside of table row.");}function X(a){a=t.$findMatchingParent(a,b=>L(b));if(L(a))return a;throw Error("Expected table cell to be inside of table.");}
function la(a,b){let c=X(a),{x:e,y:g}=c.getCordsFromCellNode(a,b);return{above:c.getCellNodeFromCords(e,g-1,b),below:c.getCellNodeFromCords(e,g+1,b),left:c.getCellNodeFromCords(e-1,g,b),right:c.getCellNodeFromCords(e+1,g,b)}}function Y(a){a=a.getFirstDescendant();null===a&&I(124);a.getParentOrThrow().selectStart()}function Z(a,b){let c=a.getFirstChild();null!==c?c.insertBefore(b):a.append(b)}let ma=d.createCommand("INSERT_TABLE_COMMAND");exports.$createTableCellNode=C;exports.$createTableNode=U;
exports.$createTableNodeWithDimensions=function(a,b,c=!0){let e=U();for(let h=0;h<a;h++){let f=F();for(let m=0;m<b;m++){var g=y.NO_STATUS;"object"===typeof c?(0===h&&c.rows&&(g|=y.ROW),0===m&&c.columns&&(g|=y.COLUMN)):c&&(0===h&&(g|=y.ROW),0===m&&(g|=y.COLUMN));g=C(g);let q=d.$createParagraphNode();q.append(d.$createTextNode());g.append(q);f.append(g)}e.append(f)}return e};exports.$createTableRowNode=F;
exports.$deleteTableColumn=function(a,b){let c=a.getChildren();for(let g=0;g<c.length;g++){var e=c[g];if(G(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();d.$isRangeSelection(a)||d.DEPRECATED_$isGridSelection(a)||I(118);var b=a.anchor.getNode();a=a.focus.getNode();let [c,,e]=d.DEPRECATED_$getNodeTriplet(b);[b]=d.DEPRECATED_$getNodeTriplet(a);let [g,h,f]=d.DEPRECATED_$computeGridMap(e,c,b);var {startColumn:m}=h;let {startRow:q,startColumn:r}=f;a=Math.min(m,r);m=Math.max(m+c.__colSpan-1,r+b.__colSpan-1);let k=m-a+1;if(g[0].length===m-a+1)e.selectPrevious(),e.remove();else{var l=
function O(a,b){a=b.elem;b=d.$getNearestNodeFromDOMNode(a);C(b)||G(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 ca(a,b){a=b.elem;b=d.$getNearestNodeFromDOMNode(a);C(b)||G(131);null===b.getBackgroundColor()&&a.style.removeProperty("background-color");a.style.removeProperty("background-image");a.style.removeProperty("caret-color")}function Q(a){a=t.$findMatchingParent(a,C);return C(a)?a:null}function ia(a){a=t.$findMatchingParent(a,K);return K(a)?a:null}
function R(a,b,c,e,g){var h=d.$getSelection();if(!P(h,e))return!1;if(d.$isRangeSelection(h)&&h.isCollapsed()){if("backward"===c||"forward"===c)return!1;let {anchor:q,focus:r}=h;h=t.$findMatchingParent(q.getNode(),C);var f=t.$findMatchingParent(r.getNode(),C);if(!C(h)||!h.is(f))return!1;f=a.getElementByKey(h.__key);var 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?h.getFirstChild():h.getLastChild();if(null==m)return!1;a=a.getElementByKey(m.__key);if(null==a)return!1;a=a.getBoundingClientRect();if("up"===c?a.top>f.top-f.height:f.bottom+f.height>a.bottom){S(b);h=e.getCordsFromCellNode(h,g.grid);if(b.shiftKey)c=e.getCellFromCordsOrThrow(h.x,h.y,g.grid),g.setAnchorCellForSelection(c),g.setFocusCellForSelection(c,!0);else return fa(g,e,h.x,h.y,c);return!0}}else if(d.DEPRECATED_$isGridSelection(h)){let {anchor:q,focus:r}=h;h=t.$findMatchingParent(q.getNode(),
C);a=t.$findMatchingParent(r.getNode(),C);if(!C(h)||!C(a))return!1;S(b);if(b.shiftKey)return b=e.getCordsFromCellNode(a,g.grid),ha(g,e,b.x,b.y,c);a.selectEnd();return!0}return!1}function S(a){a.preventDefault();a.stopImmediatePropagation();a.stopPropagation()}
class T extends d.DEPRECATED_GridNode{static getType(){return"table"}static clone(a){return new T(a.__key)}static importDOM(){return{table:()=>({conversion:ja,priority:1})}}static importJSON(){return U()}constructor(a){super(a)}exportJSON(){return{...super.exportJSON(),type:"table",version:1}}createDOM(a){let b=document.createElement("table");t.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"),
g=document.createElement("tbody");g.append(...b.children);b=this.getFirstChildOrThrow();if(!F(b))throw Error("Expected to find row node.");b=b.getChildrenSize();for(let h=0;h<b;h++){let f=document.createElement("col");e.append(f)}c.replaceChildren(e,g);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 g=e[b];if(null==g)throw Error(`Row not found at y:${b}`);g=g.findIndex(({elem:h})=>d.$getNearestNodeFromDOMNode(h)===
a);if(-1!==g)return{x:g,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 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}canSelectBefore(){return!0}canIndent(){return!1}}function ja(){return{node:U()}}function U(){return d.$applyNodeReplacement(new T)}function K(a){return a instanceof T}function W(a){a=t.$findMatchingParent(a,b=>F(b));if(F(a))return a;throw Error("Expected table cell to be inside of table row.");}function X(a){a=t.$findMatchingParent(a,b=>K(b));if(K(a))return a;throw Error("Expected table cell to be inside of table.");}
function ka(a,b){let c=X(a),{x:e,y:g}=c.getCordsFromCellNode(a,b);return{above:c.getCellNodeFromCords(e,g-1,b),below:c.getCellNodeFromCords(e,g+1,b),left:c.getCellNodeFromCords(e-1,g,b),right:c.getCellNodeFromCords(e+1,g,b)}}function Y(a){a=a.getFirstDescendant();null===a&&G(124);a.getParentOrThrow().selectStart()}function Z(a,b){let c=a.getFirstChild();null!==c?c.insertBefore(b):a.append(b)}let la=d.createCommand("INSERT_TABLE_COMMAND");exports.$createTableCellNode=B;exports.$createTableNode=U;
exports.$createTableNodeWithDimensions=function(a,b,c=!0){let e=U();for(let h=0;h<a;h++){let f=E();for(let m=0;m<b;m++){var g=x.NO_STATUS;"object"===typeof c?(0===h&&c.rows&&(g|=x.ROW),0===m&&c.columns&&(g|=x.COLUMN)):c&&(0===h&&(g|=x.ROW),0===m&&(g|=x.COLUMN));g=B(g);let q=d.$createParagraphNode();q.append(d.$createTextNode());g.append(q);f.append(g)}e.append(f)}return e};exports.$createTableRowNode=E;
exports.$deleteTableColumn=function(a,b){let c=a.getChildren();for(let g=0;g<c.length;g++){var e=c[g];if(F(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();d.$isRangeSelection(a)||d.DEPRECATED_$isGridSelection(a)||G(118);var b=a.anchor.getNode();a=a.focus.getNode();let [c,,e]=d.DEPRECATED_$getNodeTriplet(b);[b]=d.DEPRECATED_$getNodeTriplet(a);let [g,h,f]=d.DEPRECATED_$computeGridMap(e,c,b);var {startColumn:m}=h;let {startRow:q,startColumn:r}=f;a=Math.min(m,r);m=Math.max(m+c.__colSpan-1,r+b.__colSpan-1);let k=m-a+1;if(g[0].length===m-a+1)e.selectPrevious(),e.remove();else{var l=
g.length;for(let n=0;n<l;n++)for(let p=a;p<=m;p++){let {cell:v,startColumn:u}=g[n][p];u<a?p===a&&v.setColSpan(v.__colSpan-Math.min(k,v.__colSpan-(a-u))):u+v.__colSpan-1>m?p===m&&v.setColSpan(v.__colSpan-(m-u+1)):v.remove()}a=g[q];b=a[r+b.__colSpan];void 0!==b?({cell:b}=b,Y(b)):({cell:b}=a[r-1],Y(b))}};
exports.$deleteTableRow__EXPERIMENTAL=function(){var a=d.$getSelection();d.$isRangeSelection(a)||d.DEPRECATED_$isGridSelection(a)||I(118);var b=a.anchor.getNode();a=a.focus.getNode();let [c,,e]=d.DEPRECATED_$getNodeTriplet(b);[a]=d.DEPRECATED_$getNodeTriplet(a);let [g,h,f]=d.DEPRECATED_$computeGridMap(e,c,a);({startRow:b}=h);var {startRow:m}=f;a=m+a.__rowSpan-1;if(g.length===a-b+1)e.remove();else{m=g[0].length;var q=g[a+1],r=e.getChildAtIndex(a+1);for(let l=a;l>=b;l--){for(var k=m-1;0<=k;k--){let {cell:n,
startRow:p,startColumn:v}=g[l][k];if(v===k&&(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&&I(122),0===k)Z(r,n);else{let {cell:u}=q[k-1];u.insertAfter(n)}}k=e.getChildAtIndex(l);d.DEPRECATED_$isGridRowNode(k)||I(123,String(l));k.remove()}void 0!==q?({cell:b}=q[0],Y(b)):({cell:b}=g[b-1][0],Y(b))}};exports.$getElementGridForTableNode=function(a,b){a=a.getElementByKey(b.getKey());if(null==a)throw Error("Table Element Not Found");return K(a)};
exports.$getTableCellNodeFromLexicalNode=function(a){a=t.$findMatchingParent(a,b=>D(b));return D(a)?a:null};exports.$getTableColumnIndexFromTableCellNode=function(a){return W(a).getChildren().findIndex(b=>b.is(a))};exports.$getTableNodeFromLexicalNodeOrThrow=X;exports.$getTableRowIndexFromTableCellNode=function(a){let b=W(a);return X(b).getChildren().findIndex(c=>c.is(b))};exports.$getTableRowNodeFromTableCellNodeOrThrow=W;
exports.$insertTableColumn=function(a,b,c=!0,e,g){let h=a.getChildren();for(let q=0;q<h.length;q++){let r=h[q];if(G(r))for(let k=0;k<e;k++){var f=r.getChildren();if(b>=f.length||0>b)throw Error("Table column target index out of range");f=f[b];D(f)||I(12);let {left:l,right:n}=la(f,g);var m=y.NO_STATUS;if(l&&l.hasHeaderState(y.ROW)||n&&n.hasHeaderState(y.ROW))m|=y.ROW;m=C(m);m.append(d.$createParagraphNode());c?f.insertAfter(m):f.insertBefore(m)}}return a};
exports.$insertTableColumn__EXPERIMENTAL=function(a=!0){function b(){let l=C(y.NO_STATUS).append(d.$createParagraphNode());null===r&&(r=l);return l}var c=d.$getSelection();d.$isRangeSelection(c)||d.DEPRECATED_$isGridSelection(c)||I(118);var e=c.anchor.getNode();c=c.focus.getNode();[e]=d.DEPRECATED_$getNodeTriplet(e);let [g,,h]=d.DEPRECATED_$getNodeTriplet(c),[f,m,q]=d.DEPRECATED_$computeGridMap(h,g,e);e=f.length;c=a?Math.max(m.startColumn,q.startColumn):Math.min(m.startColumn,q.startColumn);a=a?c+
g.__colSpan-1:c-1;c=h.getFirstChild();d.DEPRECATED_$isGridRowNode(c)||I(120);let r=null;var k=c;a:for(c=0;c<e;c++){0!==c&&(k=k.getNextSibling(),d.DEPRECATED_$isGridRowNode(k)||I(121));let l=f[c];if(0>a){Z(k,b());continue}let {cell:n,startColumn:p,startRow:v}=l[a];if(p+n.__colSpan-1<=a){let u=n,A=v,H=a;for(;A!==c&&1<u.__rowSpan;)if(H-=n.__colSpan,0<=H){let {cell:V,startRow:na}=l[H];u=V;A=na}else{k.append(b());continue a}u.insertAfter(b())}else n.setColSpan(n.__colSpan+1)}null!==r&&Y(r)};
exports.$insertTableRow=function(a,b,c=!0,e,g){var h=a.getChildren();if(b>=h.length||0>b)throw Error("Table row target index out of range");b=h[b];if(G(b))for(h=0;h<e;h++){let m=b.getChildren(),q=m.length,r=F();for(let k=0;k<q;k++){var f=m[k];D(f)||I(12);let {above:l,below:n}=la(f,g);f=y.NO_STATUS;let p=l&&l.getWidth()||n&&n.getWidth()||void 0;if(l&&l.hasHeaderState(y.COLUMN)||n&&n.hasHeaderState(y.COLUMN))f|=y.COLUMN;f=C(f,1,p);f.append(d.$createParagraphNode());r.append(f)}c?b.insertAfter(r):b.insertBefore(r)}else throw Error("Row before insertion index does not exist.");
exports.$deleteTableRow__EXPERIMENTAL=function(){var a=d.$getSelection();d.$isRangeSelection(a)||d.DEPRECATED_$isGridSelection(a)||G(118);var b=a.anchor.getNode();a=a.focus.getNode();let [c,,e]=d.DEPRECATED_$getNodeTriplet(b);[a]=d.DEPRECATED_$getNodeTriplet(a);let [g,h,f]=d.DEPRECATED_$computeGridMap(e,c,a);({startRow:b}=h);var {startRow:m}=f;a=m+a.__rowSpan-1;if(g.length===a-b+1)e.remove();else{m=g[0].length;var q=g[a+1],r=e.getChildAtIndex(a+1);for(let l=a;l>=b;l--){for(var k=m-1;0<=k;k--){let {cell:n,
startRow:p,startColumn:v}=g[l][k];if(v===k&&(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&&G(122),0===k)Z(r,n);else{let {cell:u}=q[k-1];u.insertAfter(n)}}k=e.getChildAtIndex(l);d.DEPRECATED_$isGridRowNode(k)||G(123,String(l));k.remove()}void 0!==q?({cell:b}=q[0],Y(b)):({cell:b}=g[b-1][0],Y(b))}};exports.$getElementGridForTableNode=function(a,b){a=a.getElementByKey(b.getKey());if(null==a)throw Error("Table Element Not Found");return J(a)};
exports.$getTableCellNodeFromLexicalNode=function(a){a=t.$findMatchingParent(a,b=>C(b));return C(a)?a:null};exports.$getTableColumnIndexFromTableCellNode=function(a){return W(a).getChildren().findIndex(b=>b.is(a))};exports.$getTableNodeFromLexicalNodeOrThrow=X;exports.$getTableRowIndexFromTableCellNode=function(a){let b=W(a);return X(b).getChildren().findIndex(c=>c.is(b))};exports.$getTableRowNodeFromTableCellNodeOrThrow=W;
exports.$insertTableColumn=function(a,b,c=!0,e,g){let h=a.getChildren();for(let q=0;q<h.length;q++){let r=h[q];if(F(r))for(let k=0;k<e;k++){var f=r.getChildren();if(b>=f.length||0>b)throw Error("Table column target index out of range");f=f[b];C(f)||G(12);let {left:l,right:n}=ka(f,g);var m=x.NO_STATUS;if(l&&l.hasHeaderState(x.ROW)||n&&n.hasHeaderState(x.ROW))m|=x.ROW;m=B(m);m.append(d.$createParagraphNode());c?f.insertAfter(m):f.insertBefore(m)}}return a};
exports.$insertTableColumn__EXPERIMENTAL=function(a=!0){function b(){let l=B(x.NO_STATUS).append(d.$createParagraphNode());null===r&&(r=l);return l}var c=d.$getSelection();d.$isRangeSelection(c)||d.DEPRECATED_$isGridSelection(c)||G(118);var e=c.anchor.getNode();c=c.focus.getNode();[e]=d.DEPRECATED_$getNodeTriplet(e);let [g,,h]=d.DEPRECATED_$getNodeTriplet(c),[f,m,q]=d.DEPRECATED_$computeGridMap(h,g,e);e=f.length;c=a?Math.max(m.startColumn,q.startColumn):Math.min(m.startColumn,q.startColumn);a=a?c+
g.__colSpan-1:c-1;c=h.getFirstChild();d.DEPRECATED_$isGridRowNode(c)||G(120);let r=null;var k=c;a:for(c=0;c<e;c++){0!==c&&(k=k.getNextSibling(),d.DEPRECATED_$isGridRowNode(k)||G(121));let l=f[c];if(0>a){Z(k,b());continue}let {cell:n,startColumn:p,startRow:v}=l[a];if(p+n.__colSpan-1<=a){let u=n,A=v,H=a;for(;A!==c&&1<u.__rowSpan;)if(H-=n.__colSpan,0<=H){let {cell:V,startRow:ma}=l[H];u=V;A=ma}else{k.append(b());continue a}u.insertAfter(b())}else n.setColSpan(n.__colSpan+1)}null!==r&&Y(r)};
exports.$insertTableRow=function(a,b,c=!0,e,g){var h=a.getChildren();if(b>=h.length||0>b)throw Error("Table row target index out of range");b=h[b];if(F(b))for(h=0;h<e;h++){let m=b.getChildren(),q=m.length,r=E();for(let k=0;k<q;k++){var f=m[k];C(f)||G(12);let {above:l,below:n}=ka(f,g);f=x.NO_STATUS;let p=l&&l.getWidth()||n&&n.getWidth()||void 0;if(l&&l.hasHeaderState(x.COLUMN)||n&&n.hasHeaderState(x.COLUMN))f|=x.COLUMN;f=B(f,1,p);f.append(d.$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();d.$isRangeSelection(b)||d.DEPRECATED_$isGridSelection(b)||I(118);b=b.focus.getNode();let [c,,e]=d.DEPRECATED_$getNodeTriplet(b),[g,h]=d.DEPRECATED_$computeGridMap(e,c,c);b=g[0].length;var {startRow:f}=h;if(a){a=f+c.__rowSpan-1;var m=g[a];f=F();for(var q=0;q<b;q++){let {cell:r,startRow:k}=m[q];k+r.__rowSpan-1<=a?f.append(C(y.NO_STATUS)):r.setRowSpan(r.__rowSpan+1)}b=e.getChildAtIndex(a);d.DEPRECATED_$isGridRowNode(b)||I(119);
b.insertAfter(f)}else{m=g[f];a=F();for(q=0;q<b;q++){let {cell:r,startRow:k}=m[q];k===f?a.append(C(y.NO_STATUS)):r.setRowSpan(r.__rowSpan+1)}b=e.getChildAtIndex(f);d.DEPRECATED_$isGridRowNode(b)||I(119);b.insertBefore(a)}};exports.$isTableCellNode=D;exports.$isTableNode=L;exports.$isTableRowNode=G;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();d.$isRangeSelection(a)||d.DEPRECATED_$isGridSelection(a)||I(118);a=a.anchor.getNode();let [b,c,e]=d.DEPRECATED_$getNodeTriplet(a);a=b.__colSpan;let g=b.__rowSpan;if(1<a){for(var h=1;h<a;h++)b.insertAfter(C(y.NO_STATUS));b.setColSpan(1)}if(1<g){let [q,r]=d.DEPRECATED_$computeGridMap(e,b,b),{startColumn:k,startRow:l}=r;for(h=1;h<g;h++){let n=l+h,p=q[n];var f=c.getNextSibling();d.DEPRECATED_$isGridRowNode(f)||I(125);var m=null;for(let v=0;v<k;v++){let u=
p[v],A=u.cell;u.startRow===n&&(m=A);1<A.__colSpan&&(v+=A.__colSpan-1)}if(null===m)for(m=0;m<a;m++)Z(f,C(y.NO_STATUS));else for(f=0;f<a;f++)m.insertAfter(C(y.NO_STATUS))}b.setRowSpan(1)}};exports.INSERT_TABLE_COMMAND=ma;exports.TableCellHeaderStates=y;exports.TableCellNode=z;exports.TableNode=T;exports.TableRowNode=E;exports.TableSelection=J;
exports.applyTableHandlers=function(a,b,c,e){function g(k){k=a.getCordsFromCellNode(k,f.grid);return a.getCellFromCordsOrThrow(k.x,k.y,f.grid)}let h=c.getRootElement();if(null===h)throw Error("No root element.");let f=new J(c,a.getKey()),m=c._window||window;b.__lexicalTableSelection=f;b.addEventListener("mousedown",k=>{setTimeout(()=>{if(0===k.button&&m){var l=N(k.target);null!==l&&(S(k),f.setAnchorCellForSelection(l));var n=()=>{m.removeEventListener("mouseup",n);m.removeEventListener("mousemove",
p)},p=v=>{const u=N(v.target);null===u||f.anchorX===u.x&&f.anchorY===u.y||(v.preventDefault(),f.setFocusCellForSelection(u))};m.addEventListener("mouseup",n);m.addEventListener("mousemove",p)}},0)});let q=k=>{0===k.button&&c.update(()=>{const l=d.$getSelection(),n=k.target;d.DEPRECATED_$isGridSelection(l)&&l.gridKey===f.tableNodeKey&&h.contains(n)&&f.clearHighlight()})};m.addEventListener("mousedown",q);f.listenersToRemove.add(()=>m.removeEventListener("mousedown",q));f.listenersToRemove.add(c.registerCommand(d.KEY_ARROW_DOWN_COMMAND,
exports.$insertTableRow__EXPERIMENTAL=function(a=!0){var b=d.$getSelection();d.$isRangeSelection(b)||d.DEPRECATED_$isGridSelection(b)||G(118);b=b.focus.getNode();let [c,,e]=d.DEPRECATED_$getNodeTriplet(b),[g,h]=d.DEPRECATED_$computeGridMap(e,c,c);b=g[0].length;var {startRow:f}=h;if(a){a=f+c.__rowSpan-1;var m=g[a];f=E();for(var q=0;q<b;q++){let {cell:r,startRow:k}=m[q];k+r.__rowSpan-1<=a?f.append(B(x.NO_STATUS)):r.setRowSpan(r.__rowSpan+1)}b=e.getChildAtIndex(a);d.DEPRECATED_$isGridRowNode(b)||G(119);
b.insertAfter(f)}else{m=g[f];a=E();for(q=0;q<b;q++){let {cell:r,startRow:k}=m[q];k===f?a.append(B(x.NO_STATUS)):r.setRowSpan(r.__rowSpan+1)}b=e.getChildAtIndex(f);d.DEPRECATED_$isGridRowNode(b)||G(119);b.insertBefore(a)}};exports.$isTableCellNode=C;exports.$isTableNode=K;exports.$isTableRowNode=F;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();d.$isRangeSelection(a)||d.DEPRECATED_$isGridSelection(a)||G(118);a=a.anchor.getNode();let [b,c,e]=d.DEPRECATED_$getNodeTriplet(a);a=b.__colSpan;let g=b.__rowSpan;if(1<a){for(var h=1;h<a;h++)b.insertAfter(B(x.NO_STATUS));b.setColSpan(1)}if(1<g){let [q,r]=d.DEPRECATED_$computeGridMap(e,b,b),{startColumn:k,startRow:l}=r;for(h=1;h<g;h++){let n=l+h,p=q[n];var f=c.getNextSibling();d.DEPRECATED_$isGridRowNode(f)||G(125);var m=null;for(let v=0;v<k;v++){let u=
p[v],A=u.cell;u.startRow===n&&(m=A);1<A.__colSpan&&(v+=A.__colSpan-1)}if(null===m)for(m=0;m<a;m++)Z(f,B(x.NO_STATUS));else for(f=0;f<a;f++)m.insertAfter(B(x.NO_STATUS))}b.setRowSpan(1)}};exports.INSERT_TABLE_COMMAND=la;exports.TableCellHeaderStates=x;exports.TableCellNode=y;exports.TableNode=T;exports.TableRowNode=D;exports.TableSelection=I;
exports.applyTableHandlers=function(a,b,c,e){function g(k){k=a.getCordsFromCellNode(k,f.grid);return a.getCellFromCordsOrThrow(k.x,k.y,f.grid)}let h=c.getRootElement();if(null===h)throw Error("No root element.");let f=new I(c,a.getKey()),m=c._window||window;b.__lexicalTableSelection=f;b.addEventListener("mousedown",k=>{setTimeout(()=>{if(0===k.button&&m){var l=M(k.target);null!==l&&(S(k),f.setAnchorCellForSelection(l));var n=()=>{m.removeEventListener("mouseup",n);m.removeEventListener("mousemove",
p)},p=v=>{const u=M(v.target);null===u||f.anchorX===u.x&&f.anchorY===u.y||(v.preventDefault(),f.setFocusCellForSelection(u))};m.addEventListener("mouseup",n);m.addEventListener("mousemove",p)}},0)});let q=k=>{0===k.button&&c.update(()=>{const l=d.$getSelection(),n=k.target;d.DEPRECATED_$isGridSelection(l)&&l.gridKey===f.tableNodeKey&&h.contains(n)&&f.clearHighlight()})};m.addEventListener("mousedown",q);f.listenersToRemove.add(()=>m.removeEventListener("mousedown",q));f.listenersToRemove.add(c.registerCommand(d.KEY_ARROW_DOWN_COMMAND,
k=>R(c,k,"down",a,f),d.COMMAND_PRIORITY_HIGH));f.listenersToRemove.add(c.registerCommand(d.KEY_ARROW_UP_COMMAND,k=>R(c,k,"up",a,f),d.COMMAND_PRIORITY_HIGH));f.listenersToRemove.add(c.registerCommand(d.KEY_ARROW_LEFT_COMMAND,k=>R(c,k,"backward",a,f),d.COMMAND_PRIORITY_HIGH));f.listenersToRemove.add(c.registerCommand(d.KEY_ARROW_RIGHT_COMMAND,k=>R(c,k,"forward",a,f),d.COMMAND_PRIORITY_HIGH));f.listenersToRemove.add(c.registerCommand(d.KEY_ESCAPE_COMMAND,k=>{var l=d.$getSelection();return d.DEPRECATED_$isGridSelection(l)&&
(l=t.$findMatchingParent(l.focus.getNode(),D),D(l))?(S(k),l.selectEnd(),!0):!1},d.COMMAND_PRIORITY_HIGH));let r=k=>()=>{var l=d.$getSelection();if(!P(l,a))return!1;if(d.DEPRECATED_$isGridSelection(l))return f.clearText(),!0;if(d.$isRangeSelection(l)){const v=t.$findMatchingParent(l.anchor.getNode(),u=>D(u));if(!D(v))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=t.$findMatchingParent(l.anchor.getNode(),u=>d.$isElementNode(u)))&&
t.$findMatchingParent(p,u=>d.$isElementNode(u)&&D(u.getParent()));if(!d.$isElementNode(n)||!d.$isElementNode(p))return!1;if(k===d.DELETE_LINE_COMMAND&&null===n.getPreviousSibling())return!0;if((k===d.DELETE_CHARACTER_COMMAND||k===d.DELETE_WORD_COMMAND)&&l.isCollapsed()&&0===l.anchor.offset&&p!==n){l=p.getChildren();const u=d.$createParagraphNode();l.forEach(A=>u.append(A));p.replace(u);p.getWritable().__parent=v.getKey();return!0}}return!1};[d.DELETE_WORD_COMMAND,d.DELETE_LINE_COMMAND,d.DELETE_CHARACTER_COMMAND].forEach(k=>
{f.listenersToRemove.add(c.registerCommand(k,r(k),d.COMMAND_PRIORITY_CRITICAL))});b=k=>{const l=d.$getSelection();if(!P(l,a))return!1;if(d.DEPRECATED_$isGridSelection(l))return k.preventDefault(),k.stopPropagation(),f.clearText(),!0;d.$isRangeSelection(l)&&(k=t.$findMatchingParent(l.anchor.getNode(),n=>D(n)),D(k));return!1};f.listenersToRemove.add(c.registerCommand(d.KEY_BACKSPACE_COMMAND,b,d.COMMAND_PRIORITY_CRITICAL));f.listenersToRemove.add(c.registerCommand(d.KEY_DELETE_COMMAND,b,d.COMMAND_PRIORITY_CRITICAL));
f.listenersToRemove.add(c.registerCommand(d.FORMAT_TEXT_COMMAND,k=>{let l=d.$getSelection();if(!P(l,a))return!1;if(d.DEPRECATED_$isGridSelection(l))return f.formatCells(k),!0;d.$isRangeSelection(l)&&(k=t.$findMatchingParent(l.anchor.getNode(),n=>D(n)),D(k));return!1},d.COMMAND_PRIORITY_CRITICAL));f.listenersToRemove.add(c.registerCommand(d.CONTROLLED_TEXT_INSERTION_COMMAND,()=>{var k=d.$getSelection();if(!P(k,a))return!1;d.DEPRECATED_$isGridSelection(k)?f.clearHighlight():d.$isRangeSelection(k)&&
(k=t.$findMatchingParent(k.anchor.getNode(),l=>D(l)),D(k));return!1},d.COMMAND_PRIORITY_CRITICAL));e&&f.listenersToRemove.add(c.registerCommand(d.KEY_TAB_COMMAND,k=>{var l=d.$getSelection();if(!d.$isRangeSelection(l)||!l.isCollapsed()||!P(l,a))return!1;l=Q(l.anchor.getNode());if(null===l)return!1;S(k);l=a.getCordsFromCellNode(l,f.grid);ha(f,a,l.x,l.y,k.shiftKey?"backward":"forward");return!0},d.COMMAND_PRIORITY_CRITICAL));f.listenersToRemove.add(c.registerCommand(d.FOCUS_COMMAND,()=>a.isSelected(),
d.COMMAND_PRIORITY_HIGH));f.listenersToRemove.add(c.registerCommand(d.SELECTION_CHANGE_COMMAND,()=>{let k=d.$getSelection(),l=d.$getPreviousSelection();if(d.$isRangeSelection(k)){let {anchor:A,focus:H}=k;var n=A.getNode(),p=H.getNode();n=Q(n);p=Q(p);var v=n&&a.is(ja(n)),u=p&&a.is(ja(p));let V=v!==u;u=v&&u;v=k.isBackward();V?(n=k.clone(),n.focus.set(a.getKey(),v?0:a.getChildrenSize(),"element"),d.$setSelection(n),ea(c,f)):u&&!n.is(p)&&(f.setAnchorCellForSelection(g(n)),f.setFocusCellForSelection(g(p),
!0))}if(k&&!k.is(l)&&(d.DEPRECATED_$isGridSelection(k)||d.DEPRECATED_$isGridSelection(l))&&f.gridSelection&&!f.gridSelection.is(l))return d.DEPRECATED_$isGridSelection(k)&&k.gridKey===f.tableNodeKey?f.updateTableGridSelection(k):!d.DEPRECATED_$isGridSelection(k)&&d.DEPRECATED_$isGridSelection(l)&&l.gridKey===f.tableNodeKey&&f.updateTableGridSelection(null),!1;f.hasHijackedSelectionStyles&&!a.isSelected()?fa(c,f):!f.hasHijackedSelectionStyles&&a.isSelected()&&ea(c,f);return!1},d.COMMAND_PRIORITY_CRITICAL));
return f};exports.getCellFromTarget=N;exports.getTableSelectionFromTableElement=function(a){return a.__lexicalTableSelection}
(l=t.$findMatchingParent(l.focus.getNode(),C),C(l))?(S(k),l.selectEnd(),!0):!1},d.COMMAND_PRIORITY_HIGH));let r=k=>()=>{var l=d.$getSelection();if(!P(l,a))return!1;if(d.DEPRECATED_$isGridSelection(l))return f.clearText(),!0;if(d.$isRangeSelection(l)){const v=t.$findMatchingParent(l.anchor.getNode(),u=>C(u));if(!C(v))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=t.$findMatchingParent(l.anchor.getNode(),u=>d.$isElementNode(u)))&&
t.$findMatchingParent(p,u=>d.$isElementNode(u)&&C(u.getParent()));if(!d.$isElementNode(n)||!d.$isElementNode(p))return!1;if(k===d.DELETE_LINE_COMMAND&&null===n.getPreviousSibling())return!0;if((k===d.DELETE_CHARACTER_COMMAND||k===d.DELETE_WORD_COMMAND)&&l.isCollapsed()&&0===l.anchor.offset&&p!==n){l=p.getChildren();const u=d.$createParagraphNode();l.forEach(A=>u.append(A));p.replace(u);p.getWritable().__parent=v.getKey();return!0}}return!1};[d.DELETE_WORD_COMMAND,d.DELETE_LINE_COMMAND,d.DELETE_CHARACTER_COMMAND].forEach(k=>
{f.listenersToRemove.add(c.registerCommand(k,r(k),d.COMMAND_PRIORITY_CRITICAL))});b=k=>{const l=d.$getSelection();if(!P(l,a))return!1;if(d.DEPRECATED_$isGridSelection(l))return k.preventDefault(),k.stopPropagation(),f.clearText(),!0;d.$isRangeSelection(l)&&(k=t.$findMatchingParent(l.anchor.getNode(),n=>C(n)),C(k));return!1};f.listenersToRemove.add(c.registerCommand(d.KEY_BACKSPACE_COMMAND,b,d.COMMAND_PRIORITY_CRITICAL));f.listenersToRemove.add(c.registerCommand(d.KEY_DELETE_COMMAND,b,d.COMMAND_PRIORITY_CRITICAL));
f.listenersToRemove.add(c.registerCommand(d.FORMAT_TEXT_COMMAND,k=>{let l=d.$getSelection();if(!P(l,a))return!1;if(d.DEPRECATED_$isGridSelection(l))return f.formatCells(k),!0;d.$isRangeSelection(l)&&(k=t.$findMatchingParent(l.anchor.getNode(),n=>C(n)),C(k));return!1},d.COMMAND_PRIORITY_CRITICAL));f.listenersToRemove.add(c.registerCommand(d.CONTROLLED_TEXT_INSERTION_COMMAND,()=>{var k=d.$getSelection();if(!P(k,a))return!1;d.DEPRECATED_$isGridSelection(k)?f.clearHighlight():d.$isRangeSelection(k)&&
(k=t.$findMatchingParent(k.anchor.getNode(),l=>C(l)),C(k));return!1},d.COMMAND_PRIORITY_CRITICAL));e&&f.listenersToRemove.add(c.registerCommand(d.KEY_TAB_COMMAND,k=>{var l=d.$getSelection();if(!d.$isRangeSelection(l)||!l.isCollapsed()||!P(l,a))return!1;l=Q(l.anchor.getNode());if(null===l)return!1;S(k);l=a.getCordsFromCellNode(l,f.grid);fa(f,a,l.x,l.y,k.shiftKey?"backward":"forward");return!0},d.COMMAND_PRIORITY_CRITICAL));f.listenersToRemove.add(c.registerCommand(d.FOCUS_COMMAND,()=>a.isSelected(),
d.COMMAND_PRIORITY_HIGH));f.listenersToRemove.add(c.registerCommand(d.SELECTION_CHANGE_COMMAND,()=>{let k=d.$getSelection(),l=d.$getPreviousSelection();if(d.$isRangeSelection(k)){let {anchor:A,focus:H}=k;var n=A.getNode(),p=H.getNode();n=Q(n);p=Q(p);var v=n&&a.is(ia(n)),u=p&&a.is(ia(p));let V=v!==u;u=v&&u;v=k.isBackward();V?(n=k.clone(),n.focus.set(a.getKey(),v?0:a.getChildrenSize(),"element"),d.$setSelection(n),da(c,f)):u&&!n.is(p)&&(f.setAnchorCellForSelection(g(n)),f.setFocusCellForSelection(g(p),
!0))}if(k&&!k.is(l)&&(d.DEPRECATED_$isGridSelection(k)||d.DEPRECATED_$isGridSelection(l))&&f.gridSelection&&!f.gridSelection.is(l))return d.DEPRECATED_$isGridSelection(k)&&k.gridKey===f.tableNodeKey?f.updateTableGridSelection(k):!d.DEPRECATED_$isGridSelection(k)&&d.DEPRECATED_$isGridSelection(l)&&l.gridKey===f.tableNodeKey&&f.updateTableGridSelection(null),!1;f.hasHijackedSelectionStyles&&!a.isSelected()?ea(c,f):!f.hasHijackedSelectionStyles&&a.isSelected()&&da(c,f);return!1},d.COMMAND_PRIORITY_CRITICAL));
return f};exports.getCellFromTarget=M;exports.getTableSelectionFromTableElement=function(a){return a.__lexicalTableSelection}

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

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

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

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

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