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

@lexical/table

Package Overview
Dependencies
Maintainers
5
Versions
219
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.20.1-nightly.20241127.0 to 0.20.1-nightly.20241128.0

68

LexicalTable.prod.js

@@ -29,3 +29,3 @@ /**

function ra(a){let [b,,c]=P(a);a=c.getChildren();let d=a.length;var e=a[0].getChildren().length;let f=Array(d);for(var g=0;g<d;g++)f[g]=Array(e);for(e=0;e<d;e++){g=a[e].getChildren();let n=0;for(let q=0;q<g.length;q++){for(;f[e][n];)n++;let r=g[q],l=r.__rowSpan||1,k=r.__colSpan||1;for(let m=0;m<l;m++)for(let p=0;p<k;p++)f[e+m][n+p]=r;if(b===r)return{colSpan:k,columnIndex:n,rowIndex:e,rowSpan:l};n+=k}}return null}
function sa(a){let [[b,c,d,e],[f,g,n,q]]=["anchor","focus"].map(r=>{const l=a[r].getNode(),k=h.$findMatchingParent(l,C);C(k)||E(229,r,l.getKey(),l.getType());const m=k.getParent();J(m)||E(230,r);const p=m.getParent();K(p)||E(231,r);return[l,k,m,p]});e.is(q)||E(232);return{anchorCell:c,anchorNode:b,anchorRow:d,anchorTable:e,focusCell:g,focusNode:f,focusRow:n,focusTable:q}}
function sa(a){let [[b,c,d,e],[f,g,n,q]]=["anchor","focus"].map(r=>{const l=a[r].getNode(),k=h.$findMatchingParent(l,C);C(k)||E(238,r,l.getKey(),l.getType());const m=k.getParent();J(m)||E(239,r);const p=m.getParent();K(p)||E(240,r);return[l,k,m,p]});e.is(q)||E(241);return{anchorCell:c,anchorNode:b,anchorRow:d,anchorTable:e,focusCell:g,focusNode:f,focusRow:n,focusTable:q}}
class ta{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]}isValid(){return"root"!==this.tableKey&&"root"!==this.anchor.key&&"element"===this.anchor.type&&"root"!==this.focus.key&&"element"===this.focus.type}isBackward(){return this.focus.isBefore(this.anchor)}getCachedNodes(){return this._cachedNodes}setCachedNodes(a){this._cachedNodes=a}is(a){return Q(a)&&this.tableKey===

@@ -37,3 +37,3 @@ a.tableKey&&this.anchor.is(a.anchor)&&this.focus.is(a.focus)}set(a,b,c){this.dirty=this.dirty||a!==this.tableKey||b!==this.anchor.key||c!==this.focus.key;this.tableKey=a;this.anchor.key=b;this.focus.key=c;this._cachedNodes=null}clone(){return new ta(this.tableKey,w.$createPoint(this.anchor.key,this.anchor.offset,this.anchor.type),w.$createPoint(this.focus.key,this.focus.offset,this.focus.type))}isCollapsed(){return!1}extract(){return this.getNodes()}insertRawText(){}insertText(){}hasFormat(a){let b=

a[c],e=d.__parent,f=(a[c+1]||{}).__parent;b+=d.getTextContent()+(f!==e?"\n":"\t")}return b}}function Q(a){return a instanceof ta}function va(){let a=w.$createPoint("root",0,"element"),b=w.$createPoint("root",0,"element");return new ta("root",a,b)}function ua(a,b){a=[[a]];for(var c=a.at(-1);void 0!==c&&0<a.length;c=a.at(-1))c=c.pop(),void 0===c?a.pop():!1!==b(c)&&w.$isElementNode(c)&&a.push(c.getChildren())}
function wa(a,b=w.$getEditor()){let c=w.$getNodeByKey(a);K(c)||E(238,a);b=R(c,b.getElementByKey(a));null===b&&E(239,a);return{tableElement:b,tableNode:c}}
function wa(a,b=w.$getEditor()){let c=w.$getNodeByKey(a);K(c)||E(231,a);b=R(c,b.getElementByKey(a));null===b&&E(232,a);return{tableElement:b,tableNode:c}}
class xa{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.shouldCheckSelection=this.isSelecting=this.hasHijackedSelectionStyles=!1;this.abortController=new AbortController;this.listenerOptions={signal:this.abortController.signal};this.nextFocus=

@@ -43,7 +43,7 @@ null;this.trackTable()}getTable(){return this.table}removeListeners(){this.abortController.abort("removeListeners");Array.from(this.listenersToRemove).forEach(a=>a());this.listenersToRemove.clear()}$lookup(){return wa(this.tableNodeKey,this.editor)}trackTable(){let a=new MutationObserver(b=>{this.editor.getEditorState().read(()=>{let c=!1;for(let f=0;f<b.length;f++){const g=b[f].target.nodeName;if("TABLE"===g||"TBODY"===g||"THEAD"===g||"TR"===g){c=!0;break}}if(c){var {tableNode:d,tableElement:e}=

let {tableNode:b,tableElement:c}=this.$lookup(),d=S(b,c);ya(a,d,null);null!==w.$getSelection()&&(w.$setSelection(null),a.dispatchCommand(w.SELECTION_CHANGE_COMMAND,void 0))}$enableHighlightStyle(){let a=this.editor,{tableElement:b}=this.$lookup();h.removeClassNamesFromElement(b,a._config.theme.tableSelection);b.classList.remove("disable-selection");this.hasHijackedSelectionStyles=!1}$disableHighlightStyle(){let {tableElement:a}=this.$lookup();h.addClassNamesToElement(a,this.editor._config.theme.tableSelection);
this.hasHijackedSelectionStyles=!0}$updateTableTableSelection(a){if(null!==a){a.tableKey!==this.tableNodeKey&&E(240,a.tableKey,this.tableNodeKey);let b=this.editor;this.tableSelection=a;this.isHighlightingCells=!0;this.$disableHighlightStyle();this.updateDOMSelection();ya(b,this.table,this.tableSelection)}else this.$clearHighlight()}setShouldCheckSelection(){this.shouldCheckSelection=!0}getAndClearShouldCheckSelection(){return this.shouldCheckSelection?(this.shouldCheckSelection=!1,!0):!1}setNextFocus(a){this.nextFocus=
this.hasHijackedSelectionStyles=!0}$updateTableTableSelection(a){if(null!==a){a.tableKey!==this.tableNodeKey&&E(233,a.tableKey,this.tableNodeKey);let b=this.editor;this.tableSelection=a;this.isHighlightingCells=!0;this.$disableHighlightStyle();this.updateDOMSelection();ya(b,this.table,this.tableSelection)}else this.$clearHighlight()}setShouldCheckSelection(){this.shouldCheckSelection=!0}getAndClearShouldCheckSelection(){return this.shouldCheckSelection?(this.shouldCheckSelection=!1,!0):!1}setNextFocus(a){this.nextFocus=
a}getAndClearNextFocus(){let {nextFocus:a}=this;null!==a&&(this.nextFocus=null);return a}updateDOMSelection(){if(null!==this.anchorCell&&null!==this.focusCell){let a=w.getDOMSelection(this.editor._window);a&&0<a.rangeCount&&a.removeAllRanges()}}$setFocusCellForSelection(a,b=!1){let c=this.editor,{tableNode:d}=this.$lookup();var e=a.x;let f=a.y;this.focusCell=a;if(!this.isHighlightingCells&&(this.anchorX!==e||this.anchorY!==f||b))this.isHighlightingCells=!0,this.$disableHighlightStyle();else if(e===
this.focusX&&f===this.focusY)return!1;this.focusX=e;this.focusY=f;return this.isHighlightingCells&&(b=w.$getNearestNodeFromDOMNode(a.elem),null!=this.tableSelection&&null!=this.anchorCellNodeKey&&C(b)&&d.is(T(b)))?(this.focusCellNodeKey=b.getKey(),a=this.$getAnchorTableCellOrThrow(),d.getKey(),a.getKey(),b.getKey(),e=w.$getSelection(),e=Q(e)?e.clone():va(),e.set(d.getKey(),a.getKey(),b.getKey()),this.tableSelection=e,w.$setSelection(this.tableSelection),c.dispatchCommand(w.SELECTION_CHANGE_COMMAND,
void 0),ya(c,this.table,this.tableSelection),!0):!1}$getAnchorTableCell(){return this.anchorCellNodeKey?w.$getNodeByKey(this.anchorCellNodeKey):null}$getAnchorTableCellOrThrow(){let a=this.$getAnchorTableCell();null===a&&E(241);return a}$getFocusTableCell(){return this.focusCellNodeKey?w.$getNodeByKey(this.focusCellNodeKey):null}$getFocusTableCellOrThrow(){let a=this.$getFocusTableCell();null===a&&E(242);return a}$setAnchorCellForSelection(a){this.isHighlightingCells=!1;this.anchorCell=a;this.anchorX=
a.x;this.anchorY=a.y;a=w.$getNearestNodeFromDOMNode(a.elem);C(a)&&(a=a.getKey(),this.tableSelection=null!=this.tableSelection?this.tableSelection.clone():va(),this.anchorCellNodeKey=a)}$formatCells(a){let b=w.$getSelection();Q(b)||E(243);let c=w.$createRangeSelection(),d=c.anchor,e=c.focus,f=b.getNodes().filter(C);0<f.length||E(244);let g=f[0].getFirstChild(),n=w.$isParagraphNode(g)?g.getFormatFlags(a,null):null;f.forEach(q=>{d.set(q.getKey(),0,"element");e.set(q.getKey(),q.getChildrenSize(),"element");
void 0),ya(c,this.table,this.tableSelection),!0):!1}$getAnchorTableCell(){return this.anchorCellNodeKey?w.$getNodeByKey(this.anchorCellNodeKey):null}$getAnchorTableCellOrThrow(){let a=this.$getAnchorTableCell();null===a&&E(234);return a}$getFocusTableCell(){return this.focusCellNodeKey?w.$getNodeByKey(this.focusCellNodeKey):null}$getFocusTableCellOrThrow(){let a=this.$getFocusTableCell();null===a&&E(235);return a}$setAnchorCellForSelection(a){this.isHighlightingCells=!1;this.anchorCell=a;this.anchorX=
a.x;this.anchorY=a.y;a=w.$getNearestNodeFromDOMNode(a.elem);C(a)&&(a=a.getKey(),this.tableSelection=null!=this.tableSelection?this.tableSelection.clone():va(),this.anchorCellNodeKey=a)}$formatCells(a){let b=w.$getSelection();Q(b)||E(236);let c=w.$createRangeSelection(),d=c.anchor,e=c.focus,f=b.getNodes().filter(C);0<f.length||E(237);let g=f[0].getFirstChild(),n=w.$isParagraphNode(g)?g.getFormatFlags(a,null):null;f.forEach(q=>{d.set(q.getKey(),0,"element");e.set(q.getKey(),q.getChildrenSize(),"element");
c.formatText(a,n)});w.$setSelection(b);this.editor.dispatchCommand(w.SELECTION_CHANGE_COMMAND,void 0)}$clearText(){let {editor:a}=this,b=w.$getNodeByKey(this.tableNodeKey);if(!K(b))throw Error("Expected TableNode.");var c=w.$getSelection();Q(c)||E(11);c=c.getNodes().filter(C);c.length===this.table.columns*this.table.rows?(b.selectPrevious(),b.remove(),w.$getRoot().selectStart()):(c.forEach(d=>{if(w.$isElementNode(d)){let e=w.$createParagraphNode(),f=w.$createTextNode();e.append(f);d.append(e);d.getChildren().forEach(g=>

@@ -62,25 +62,25 @@ {g!==e&&g.remove()})}}),ya(a,this.table,null),w.$setSelection(null),a.dispatchCommand(w.SELECTION_CHANGE_COMMAND,void 0))}}function R(a,b){if(!b)return b;a="TABLE"===b.nodeName?b:a.getDOMSlot(b).element;"TABLE"!==a.nodeName&&E(245,b.nodeName);return a}function za(a,b){for(let c=b,d=null;null!==c;c=c.getParent()){if(a.is(c))return d;C(c)&&(d=c)}return null}

function W(a,b){if(w.$isRangeSelection(a)||Q(a)){let c=b.isParentOf(a.anchor.getNode());a=b.isParentOf(a.focus.getNode());return c&&a}return!1}function Ha(a,b){b=b.elem;a=a._config.theme;let c=w.$getNearestNodeFromDOMNode(b);C(c)||E(131);h.addClassNamesToElement(b,a.tableCellSelected)}function Ia(a,b){b=b.elem;let c=w.$getNearestNodeFromDOMNode(b);C(c)||E(131);h.removeClassNamesFromElement(b,a._config.theme.tableCellSelected)}function X(a){a=h.$findMatchingParent(a,C);return C(a)?a:null}
function T(a){a=h.$findMatchingParent(a,K);return K(a)?a:null}
function Qa(a,b,c,d,e){if(("up"===c||"down"===c)&&Ra(a))return!1;var f=w.$getSelection();if(!W(f,d)){if(w.$isRangeSelection(f)){if(f.isCollapsed()&&"backward"===c){c=f.anchor.type;d=f.anchor.offset;if("element"!==c&&("text"!==c||0!==d))return!1;c=f.anchor.getNode();if(!c)return!1;c=h.$findMatchingParent(c,r=>w.$isElementNode(r)&&!r.isInline());if(!c)return!1;c=c.getPreviousSibling();if(!c||!K(c))return!1;Y(b);c.selectEnd();return!0}if(b.shiftKey&&("up"===c||"down"===c)){var g=f.focus.getNode();if(!f.isCollapsed()&&
("up"===c&&!f.isBackward()||"down"===c&&f.isBackward())){e=h.$findMatchingParent(g,r=>K(r));C(e)&&(e=h.$findMatchingParent(e,K));if(e!==d||!e)return!1;d="down"===c?e.getNextSibling():e.getPreviousSibling();if(!d)return!1;e=0;"up"===c&&w.$isElementNode(d)&&(e=d.getChildrenSize());a=d;"up"===c&&w.$isElementNode(d)&&(a=(c=d.getLastChild())?c:d,e=w.$isTextNode(a)?a.getTextContentSize():0);c=f.clone();c.focus.set(a.getKey(),e,w.$isTextNode(a)?"text":"element");w.$setSelection(c);Y(b);return!0}if(w.$isRootOrShadowRoot(g)){if((b=
"up"===c?f.getNodes()[f.getNodes().length-1]:f.getNodes()[0])&&(b=h.$findMatchingParent(b,C))&&d.isParentOf(b)){c=d.getFirstDescendant();b=d.getLastDescendant();if(!c||!b)return!1;[c]=P(c);[b]=P(b);c=d.getCordsFromCellNode(c,e.table);b=d.getCordsFromCellNode(b,e.table);c=d.getDOMCellFromCordsOrThrow(c.x,c.y,e.table);b=d.getDOMCellFromCordsOrThrow(b.x,b.y,e.table);e.$setAnchorCellForSelection(c);e.$setFocusCellForSelection(b,!0);return!0}return!1}d=h.$findMatchingParent(g,r=>w.$isElementNode(r)&&!r.isInline());
C(d)&&(d=h.$findMatchingParent(d,K));if(!d)return!1;d="down"===c?d.getNextSibling():d.getPreviousSibling();if(K(d)&&e.tableNodeKey===d.getKey()){e=d.getFirstDescendant();a=d.getLastDescendant();if(!e||!a)return!1;[d]=P(e);[e]=P(a);f=f.clone();f.focus.set(("up"===c?d:e).getKey(),"up"===c?0:e.getChildrenSize(),"element");Y(b);w.$setSelection(f);return!0}}}"down"===c&&Sa(a)&&e.setShouldCheckSelection();return!1}if(w.$isRangeSelection(f)&&f.isCollapsed()){let {anchor:r,focus:l}=f;g=h.$findMatchingParent(r.getNode(),
C);var n=h.$findMatchingParent(l.getNode(),C);if(!C(g)||!g.is(n))return!1;n=T(g);if(n!==d&&null!=n){var q=R(n,a.getElementByKey(n.getKey()));if(null!=q)return e.table=S(n,q),Qa(a,b,c,n,e)}if("backward"===c||"forward"===c){e=r.type;a=r.offset;n=r.getNode();if(!n)return!1;f=f.getNodes();return 1===f.length&&w.$isDecoratorNode(f[0])?!1:Ta(e,a,n,c)?Ua(b,n,g,d,c):!1}f=a.getElementByKey(g.__key);n=a.getElementByKey(r.key);if(null==n||null==f)return!1;if("element"===r.type)f=n.getBoundingClientRect();else{f=
w.getDOMSelection(a._window);if(null===f||0===f.rangeCount)return!1;f=f.getRangeAt(0).getBoundingClientRect()}n="up"===c?g.getFirstChild():g.getLastChild();if(null==n)return!1;a=a.getElementByKey(n.__key);if(null==a)return!1;a=a.getBoundingClientRect();if("up"===c?a.top>f.top-f.height:f.bottom+f.height>a.bottom){Y(b);f=d.getCordsFromCellNode(g,e.table);if(b.shiftKey)b=d.getDOMCellFromCordsOrThrow(f.x,f.y,e.table),e.$setAnchorCellForSelection(b),e.$setFocusCellForSelection(b,!0);else return La(e,d,
f.x,f.y,c);return!0}}else if(Q(f)){let {anchor:r,focus:l}=f;g=h.$findMatchingParent(r.getNode(),C);n=h.$findMatchingParent(l.getNode(),C);[q]=f.getNodes();K(q)||E(249);a=R(q,a.getElementByKey(q.getKey()));if(!C(g)||!C(n)||!K(q)||null==a)return!1;e.$updateTableTableSelection(f);f=S(q,a);a=d.getCordsFromCellNode(g,f);f=d.getDOMCellFromCordsOrThrow(a.x,a.y,f);e.$setAnchorCellForSelection(f);Y(b);if(b.shiftKey){let [k,m,p]=N(d,g,n);return Pa(e,k,m,p,c)}n.selectEnd();return!0}return!1}
function Y(a){a.preventDefault();a.stopImmediatePropagation();a.stopPropagation()}function Ra(a){return(a=a.getRootElement())?a.hasAttribute("aria-controls")&&"typeahead-menu"===a.getAttribute("aria-controls"):!1}function Ta(a,b,c,d){return"element"===a&&("backward"===d?null===c.getPreviousSibling():null===c.getNextSibling())||Va(a,b,c,d)}
function Va(a,b,c,d){let e=h.$findMatchingParent(c,f=>w.$isElementNode(f)&&!f.isInline());if(!e)return!1;b="backward"===d?0===b:b===c.getTextContentSize();return"text"===a&&b&&("backward"===d?null===e.getPreviousSibling():null===e.getNextSibling())}
function Ua(a,b,c,d,e){let [f,g]=N(d,c,c);c=f[0][0];let n=f[f.length-1][f[0].length-1],{startColumn:q,startRow:r}=g;if("backward"===e?q!==c.startColumn||r!==c.startRow:q!==n.startColumn||r!==n.startRow)return!1;b=Wa(b,e,d);if(!b||K(b))return!1;Y(a);"backward"===e?b.selectEnd():b.selectStart();return!0}
function Wa(a,b,c){if(a=h.$findMatchingParent(a,d=>w.$isElementNode(d)&&!d.isInline()))return(a="backward"===b?a.getPreviousSibling():a.getNextSibling())&&K(a)?a:"backward"===b?c.getPreviousSibling():c.getNextSibling()}function Xa(a,b,c){let d=w.$createParagraphNode();"first"===a?b.insertBefore(d):b.insertAfter(d);d.append(...(c||[]));d.selectEnd()}
function Ya(a,b,c){var d=c.getParent();if(d){var e=w.getDOMSelection(a._window);if(e&&(e=e.anchorNode,d=a.getElementByKey(d.getKey()),a=R(c,a.getElementByKey(c.getKey())),e&&d&&a&&d.contains(e)&&!a.contains(e)&&(b=h.$findMatchingParent(b.anchor.getNode(),r=>C(r))))&&(a=h.$findMatchingParent(b,r=>K(r)),K(a)&&a.is(c))){var [f,g]=N(c,b,b);c=f[0][0];b=f[f.length-1][f[0].length-1];var {startRow:n,startColumn:q}=g;if(n===c.startRow&&q===c.startColumn)return"first";if(n===b.startRow&&q===b.startColumn)return"last"}}}
function V(a,b){let {tableNode:c}=a.$lookup();b=c.getCordsFromCellNode(b,a.table);return c.getDOMCellFromCordsOrThrow(b.x,b.y,a.table)}function Za(a,b,c,d){if(a=a.querySelector("colgroup")){b=[];for(let e=0;e<c;e++){let f=document.createElement("col"),g=d&&d[e];g&&(f.style.width=`${g}px`);b.push(f)}a.replaceChildren(...b)}}
function $a(a,b,c){c?(h.addClassNamesToElement(a,b.theme.tableRowStriping),a.setAttribute("data-lexical-row-striping","true")):(h.removeClassNamesFromElement(a,b.theme.tableRowStriping),a.removeAttribute("data-lexical-row-striping"))}let ab=new WeakSet;function Sa(a=w.$getEditor()){return ab.has(a)}
class bb extends w.ElementNode{static getType(){return"table"}getColWidths(){return this.getLatest().__colWidths}setColWidths(a){let b=this.getWritable();b.__colWidths=a;return b}static clone(a){return new bb(a.__key)}afterCloneFrom(a){super.afterCloneFrom(a);this.__colWidths=a.__colWidths;this.__rowStriping=a.__rowStriping}static importDOM(){return{table:()=>({conversion:cb,priority:1})}}static importJSON(a){let b=db();b.__rowStriping=a.rowStriping||!1;b.__colWidths=a.colWidths;return b}constructor(a){super(a);
this.__rowStriping=!1}exportJSON(){return{...super.exportJSON(),colWidths:this.getColWidths(),rowStriping:this.__rowStriping?this.__rowStriping:void 0,type:"table",version:1}}getDOMSlot(a){a="TABLE"!==a.nodeName&&a.querySelector("table")||a;"TABLE"!==a.nodeName&&E(236);return super.getDOMSlot(a).withAfter(a.querySelector("colgroup"))}createDOM(a,b){let c=document.createElement("table"),d=document.createElement("colgroup");c.appendChild(d);Za(c,a,this.getColumnCount(),this.getColWidths());w.setDOMUnmanaged(d);
h.addClassNamesToElement(c,a.theme.table);this.__rowStriping&&$a(c,a,!0);return Sa(b)?(b=document.createElement("div"),(a=a.theme.tableScrollableWrapper)?h.addClassNamesToElement(b,a):b.style.cssText="overflow-x: auto;",b.appendChild(c),b):c}updateDOM(a,b,c){a.__rowStriping!==this.__rowStriping&&$a(b,c,this.__rowStriping);Za(b,c,this.getColumnCount(),this.getColWidths());return!1}exportDOM(a){return{...super.exportDOM(a),after:b=>{b&&h.isHTMLElement(b)&&"TABLE"!==b.nodeName&&(b=b.querySelector("table"));
function T(a){a=h.$findMatchingParent(a,K);return K(a)?a:null}function Qa(a){for(let b=a,c=a;null!==c;b=c,c=c.getParent())if(w.$isElementNode(c))if(c!==b&&c.getFirstChild()!==b)break;else if(!c.isInline())return c;return null}
function Ra(a,b,c,d,e){if(("up"===c||"down"===c)&&Sa(a))return!1;var f=w.$getSelection();if(!W(f,d)){if(w.$isRangeSelection(f)){if("backward"===c){if(0<f.focus.offset)return!1;c=Qa(f.focus.getNode());if(!c)return!1;c=c.getPreviousSibling();if(!K(c))return!1;Y(b);b.shiftKey?f.focus.set(c.getParentOrThrow().getKey(),c.getIndexWithinParent(),"element"):c.selectEnd();return!0}if(b.shiftKey&&("up"===c||"down"===c)){var g=f.focus.getNode();if(!f.isCollapsed()&&("up"===c&&!f.isBackward()||"down"===c&&f.isBackward())){e=
h.$findMatchingParent(g,r=>K(r));C(e)&&(e=h.$findMatchingParent(e,K));if(e!==d||!e)return!1;d="down"===c?e.getNextSibling():e.getPreviousSibling();if(!d)return!1;e=0;"up"===c&&w.$isElementNode(d)&&(e=d.getChildrenSize());a=d;"up"===c&&w.$isElementNode(d)&&(a=(c=d.getLastChild())?c:d,e=w.$isTextNode(a)?a.getTextContentSize():0);c=f.clone();c.focus.set(a.getKey(),e,w.$isTextNode(a)?"text":"element");w.$setSelection(c);Y(b);return!0}if(w.$isRootOrShadowRoot(g)){if((b="up"===c?f.getNodes()[f.getNodes().length-
1]:f.getNodes()[0])&&(b=h.$findMatchingParent(b,C))&&d.isParentOf(b)){c=d.getFirstDescendant();b=d.getLastDescendant();if(!c||!b)return!1;[c]=P(c);[b]=P(b);c=d.getCordsFromCellNode(c,e.table);b=d.getCordsFromCellNode(b,e.table);c=d.getDOMCellFromCordsOrThrow(c.x,c.y,e.table);b=d.getDOMCellFromCordsOrThrow(b.x,b.y,e.table);e.$setAnchorCellForSelection(c);e.$setFocusCellForSelection(b,!0);return!0}return!1}d=h.$findMatchingParent(g,r=>w.$isElementNode(r)&&!r.isInline());C(d)&&(d=h.$findMatchingParent(d,
K));if(!d)return!1;d="down"===c?d.getNextSibling():d.getPreviousSibling();if(K(d)&&e.tableNodeKey===d.getKey()){e=d.getFirstDescendant();a=d.getLastDescendant();if(!e||!a)return!1;[d]=P(e);[e]=P(a);f=f.clone();f.focus.set(("up"===c?d:e).getKey(),"up"===c?0:e.getChildrenSize(),"element");Y(b);w.$setSelection(f);return!0}}}"down"===c&&Ta(a)&&e.setShouldCheckSelection();return!1}if(w.$isRangeSelection(f)&&f.isCollapsed()){let {anchor:r,focus:l}=f;g=h.$findMatchingParent(r.getNode(),C);var n=h.$findMatchingParent(l.getNode(),
C);if(!C(g)||!g.is(n))return!1;n=T(g);if(n!==d&&null!=n){var q=R(n,a.getElementByKey(n.getKey()));if(null!=q)return e.table=S(n,q),Ra(a,b,c,n,e)}if("backward"===c||"forward"===c){e=r.type;a=r.offset;n=r.getNode();if(!n)return!1;f=f.getNodes();return 1===f.length&&w.$isDecoratorNode(f[0])?!1:Ua(e,a,n,c)?Va(b,n,g,d,c):!1}f=a.getElementByKey(g.__key);n=a.getElementByKey(r.key);if(null==n||null==f)return!1;if("element"===r.type)f=n.getBoundingClientRect();else{f=w.getDOMSelection(a._window);if(null===
f||0===f.rangeCount)return!1;f=f.getRangeAt(0).getBoundingClientRect()}n="up"===c?g.getFirstChild():g.getLastChild();if(null==n)return!1;a=a.getElementByKey(n.__key);if(null==a)return!1;a=a.getBoundingClientRect();if("up"===c?a.top>f.top-f.height:f.bottom+f.height>a.bottom){Y(b);f=d.getCordsFromCellNode(g,e.table);if(b.shiftKey)b=d.getDOMCellFromCordsOrThrow(f.x,f.y,e.table),e.$setAnchorCellForSelection(b),e.$setFocusCellForSelection(b,!0);else return La(e,d,f.x,f.y,c);return!0}}else if(Q(f)){let {anchor:r,
focus:l}=f;g=h.$findMatchingParent(r.getNode(),C);n=h.$findMatchingParent(l.getNode(),C);[q]=f.getNodes();K(q)||E(249);a=R(q,a.getElementByKey(q.getKey()));if(!C(g)||!C(n)||!K(q)||null==a)return!1;e.$updateTableTableSelection(f);f=S(q,a);a=d.getCordsFromCellNode(g,f);f=d.getDOMCellFromCordsOrThrow(a.x,a.y,f);e.$setAnchorCellForSelection(f);Y(b);if(b.shiftKey){let [k,m,p]=N(d,g,n);return Pa(e,k,m,p,c)}n.selectEnd();return!0}return!1}
function Y(a){a.preventDefault();a.stopImmediatePropagation();a.stopPropagation()}function Sa(a){return(a=a.getRootElement())?a.hasAttribute("aria-controls")&&"typeahead-menu"===a.getAttribute("aria-controls"):!1}function Ua(a,b,c,d){return"element"===a&&("backward"===d?null===c.getPreviousSibling():null===c.getNextSibling())||Wa(a,b,c,d)}
function Wa(a,b,c,d){let e=h.$findMatchingParent(c,f=>w.$isElementNode(f)&&!f.isInline());if(!e)return!1;b="backward"===d?0===b:b===c.getTextContentSize();return"text"===a&&b&&("backward"===d?null===e.getPreviousSibling():null===e.getNextSibling())}
function Va(a,b,c,d,e){let [f,g]=N(d,c,c);c=f[0][0];let n=f[f.length-1][f[0].length-1],{startColumn:q,startRow:r}=g;if("backward"===e?q!==c.startColumn||r!==c.startRow:q!==n.startColumn||r!==n.startRow)return!1;b=Xa(b,e,d);if(!b||K(b))return!1;Y(a);"backward"===e?b.selectEnd():b.selectStart();return!0}
function Xa(a,b,c){if(a=h.$findMatchingParent(a,d=>w.$isElementNode(d)&&!d.isInline()))return(a="backward"===b?a.getPreviousSibling():a.getNextSibling())&&K(a)?a:"backward"===b?c.getPreviousSibling():c.getNextSibling()}function Ya(a,b,c){let d=w.$createParagraphNode();"first"===a?b.insertBefore(d):b.insertAfter(d);d.append(...(c||[]));d.selectEnd()}
function Za(a,b,c){var d=c.getParent();if(d){var e=w.getDOMSelection(a._window);if(e&&(e=e.anchorNode,d=a.getElementByKey(d.getKey()),a=R(c,a.getElementByKey(c.getKey())),e&&d&&a&&d.contains(e)&&!a.contains(e)&&(b=h.$findMatchingParent(b.anchor.getNode(),r=>C(r))))&&(a=h.$findMatchingParent(b,r=>K(r)),K(a)&&a.is(c))){var [f,g]=N(c,b,b);c=f[0][0];b=f[f.length-1][f[0].length-1];var {startRow:n,startColumn:q}=g;if(n===c.startRow&&q===c.startColumn)return"first";if(n===b.startRow&&q===b.startColumn)return"last"}}}
function V(a,b){let {tableNode:c}=a.$lookup();b=c.getCordsFromCellNode(b,a.table);return c.getDOMCellFromCordsOrThrow(b.x,b.y,a.table)}function $a(a,b,c,d){if(a=a.querySelector("colgroup")){b=[];for(let e=0;e<c;e++){let f=document.createElement("col"),g=d&&d[e];g&&(f.style.width=`${g}px`);b.push(f)}a.replaceChildren(...b)}}
function ab(a,b,c){c?(h.addClassNamesToElement(a,b.theme.tableRowStriping),a.setAttribute("data-lexical-row-striping","true")):(h.removeClassNamesFromElement(a,b.theme.tableRowStriping),a.removeAttribute("data-lexical-row-striping"))}let bb=new WeakSet;function Ta(a=w.$getEditor()){return bb.has(a)}
class cb extends w.ElementNode{static getType(){return"table"}getColWidths(){return this.getLatest().__colWidths}setColWidths(a){let b=this.getWritable();b.__colWidths=a;return b}static clone(a){return new cb(a.__key)}afterCloneFrom(a){super.afterCloneFrom(a);this.__colWidths=a.__colWidths;this.__rowStriping=a.__rowStriping}static importDOM(){return{table:()=>({conversion:db,priority:1})}}static importJSON(a){let b=eb();b.__rowStriping=a.rowStriping||!1;b.__colWidths=a.colWidths;return b}constructor(a){super(a);
this.__rowStriping=!1}exportJSON(){return{...super.exportJSON(),colWidths:this.getColWidths(),rowStriping:this.__rowStriping?this.__rowStriping:void 0,type:"table",version:1}}getDOMSlot(a){a="TABLE"!==a.nodeName&&a.querySelector("table")||a;"TABLE"!==a.nodeName&&E(229);return super.getDOMSlot(a).withAfter(a.querySelector("colgroup"))}createDOM(a,b){let c=document.createElement("table"),d=document.createElement("colgroup");c.appendChild(d);$a(c,a,this.getColumnCount(),this.getColWidths());w.setDOMUnmanaged(d);
h.addClassNamesToElement(c,a.theme.table);this.__rowStriping&&ab(c,a,!0);return Ta(b)?(b=document.createElement("div"),(a=a.theme.tableScrollableWrapper)?h.addClassNamesToElement(b,a):b.style.cssText="overflow-x: auto;",b.appendChild(c),b):c}updateDOM(a,b,c){a.__rowStriping!==this.__rowStriping&&ab(b,c,this.__rowStriping);$a(b,c,this.getColumnCount(),this.getColWidths());return!1}exportDOM(a){return{...super.exportDOM(a),after:b=>{b&&h.isHTMLElement(b)&&"TABLE"!==b.nodeName&&(b=b.querySelector("table"));
if(!b||!h.isHTMLElement(b))return null;let c=b.querySelectorAll(":scope > tr");if(0<c.length){let d=document.createElement("tbody");d.append(...c);b.append(d)}return b}}}canBeEmpty(){return!1}isShadowRoot(){return!0}getCordsFromCellNode(a,b){let {rows:c,domRows:d}=b;for(b=0;b<c;b++){var e=d[b];if(null!=e&&(e=e.findIndex(f=>{if(f)return{elem:f}=f,w.$getNearestNodeFromDOMNode(f)===a}),-1!==e))return{x:e,y:b}}throw Error("Cell not found in table.");}getDOMCellFromCords(a,b,c){({domRows:c}=c);b=c[b];
if(null==b)return null;a=b[a<b.length?a:b.length-1];return null==a?null:a}getDOMCellFromCordsOrThrow(a,b,c){a=this.getDOMCellFromCords(a,b,c);if(!a)throw Error("Cell not found at cords.");return a}getCellNodeFromCords(a,b,c){a=this.getDOMCellFromCords(a,b,c);if(null==a)return null;a=w.$getNearestNodeFromDOMNode(a.elem);return C(a)?a:null}getCellNodeFromCordsOrThrow(a,b,c){a=this.getCellNodeFromCords(a,b,c);if(!a)throw Error("Node at cords not TableCellNode.");return a}getRowStriping(){return!!this.getLatest().__rowStriping}setRowStriping(a){this.getWritable().__rowStriping=
a}canSelectBefore(){return!0}canIndent(){return!1}getColumnCount(){let a=this.getFirstChild();if(!a)return 0;let b=0;a.getChildren().forEach(c=>{C(c)&&(b+=c.getColSpan())});return b}}function cb(a){let b=db();a.hasAttribute("data-lexical-row-striping")&&b.setRowStriping(!0);var c=a.querySelector(":scope > colgroup");if(c){a=[];for(let d of c.querySelectorAll(":scope > col")){c=d.style.width;if(!c||!ba.test(c)){a=void 0;break}a.push(parseFloat(c))}a&&b.setColWidths(a)}return{node:b}}
function db(){return w.$applyNodeReplacement(new bb)}function K(a){return a instanceof bb}exports.$computeTableMap=N;exports.$computeTableMapSkipCellCheck=pa;exports.$createTableCellNode=A;exports.$createTableNode=db;
exports.$createTableNodeWithDimensions=function(a,b,c=!0){let d=db();for(let f=0;f<a;f++){let g=I();for(let n=0;n<b;n++){var e=x.NO_STATUS;"object"===typeof c?(0===f&&c.rows&&(e|=x.ROW),0===n&&c.columns&&(e|=x.COLUMN)):c&&(0===f&&(e|=x.ROW),0===n&&(e|=x.COLUMN));e=A(e);let q=w.$createParagraphNode();q.append(w.$createTextNode());e.append(q);g.append(e)}d.append(g)}return d};exports.$createTableRowNode=I;exports.$createTableSelection=va;
a}canSelectBefore(){return!0}canIndent(){return!1}getColumnCount(){let a=this.getFirstChild();if(!a)return 0;let b=0;a.getChildren().forEach(c=>{C(c)&&(b+=c.getColSpan())});return b}}function db(a){let b=eb();a.hasAttribute("data-lexical-row-striping")&&b.setRowStriping(!0);var c=a.querySelector(":scope > colgroup");if(c){a=[];for(let d of c.querySelectorAll(":scope > col")){c=d.style.width;if(!c||!ba.test(c)){a=void 0;break}a.push(parseFloat(c))}a&&b.setColWidths(a)}return{node:b}}
function eb(){return w.$applyNodeReplacement(new cb)}function K(a){return a instanceof cb}exports.$computeTableMap=N;exports.$computeTableMapSkipCellCheck=pa;exports.$createTableCellNode=A;exports.$createTableNode=eb;
exports.$createTableNodeWithDimensions=function(a,b,c=!0){let d=eb();for(let f=0;f<a;f++){let g=I();for(let n=0;n<b;n++){var e=x.NO_STATUS;"object"===typeof c?(0===f&&c.rows&&(e|=x.ROW),0===n&&c.columns&&(e|=x.COLUMN)):c&&(0===f&&(e|=x.ROW),0===n&&(e|=x.COLUMN));e=A(e);let q=w.$createParagraphNode();q.append(w.$createTextNode());e.append(q);g.append(e)}d.append(g)}return d};exports.$createTableRowNode=I;exports.$createTableSelection=va;
exports.$deleteTableColumn=function(a,b){let c=a.getChildren();for(let e=0;e<c.length;e++){var d=c[e];if(J(d)){d=d.getChildren();if(b>=d.length||0>b)throw Error("Table column target index out of range");d[b].remove()}}return a};

@@ -90,3 +90,3 @@ exports.$deleteTableColumn__EXPERIMENTAL=function(){var a=w.$getSelection();w.$isRangeSelection(a)||Q(a)||E(188);var b=a.anchor.getNode();a=a.focus.getNode();let [c,,d]=P(b);var [e]=P(a);let [f,g,n]=N(d,c,e);var {startColumn:q}=g;let {startRow:r,startColumn:l}=n;b=Math.min(q,l);var k=Math.max(q+c.__colSpan-1,l+e.__colSpan-1);a=k-b+1;if(f[0].length===k-b+1)d.selectPrevious(),d.remove();else{var m=f.length;for(let p=0;p<m;p++)for(let u=b;u<=k;u++){let {cell:t,startColumn:v}=f[p][u];v<b?u===b&&t.setColSpan(t.__colSpan-

exports.$deleteTableRow__EXPERIMENTAL=function(){var a=w.$getSelection();w.$isRangeSelection(a)||Q(a)||E(188);let [b,c]=a.isBackward()?[a.focus.getNode(),a.anchor.getNode()]:[a.anchor.getNode(),a.focus.getNode()],[d,,e]=P(b);var [f]=P(c);let [g,n,q]=N(e,d,f);({startRow:a}=n);var {startRow:r}=q;f=r+f.__rowSpan-1;if(g.length===f-a+1)e.remove();else{r=g[0].length;var l=g[f+1],k=e.getChildAtIndex(f+1);for(let p=f;p>=a;p--){for(var m=r-1;0<=m;m--){let {cell:u,startRow:t,startColumn:v}=g[p][m];if(v===m&&
(p===a&&t<a&&u.setRowSpan(u.__rowSpan-(t-a)),t>=a&&t+u.__rowSpan-1>f))if(u.setRowSpan(u.__rowSpan-(f-t+1)),null===k&&E(122),0===m)oa(k,u);else{let {cell:B}=l[m-1];B.insertAfter(u)}}m=e.getChildAtIndex(p);J(m)||E(206,String(p));m.remove()}void 0!==l?({cell:a}=l[0],M(a)):({cell:a}=g[a-1][0],M(a))}};exports.$findCellNode=X;exports.$findTableNode=T;exports.$getElementForTableNode=function(a,b){a=a.getElementByKey(b.getKey());null===a&&E(237);return S(b,a)};exports.$getNodeTriplet=P;
(p===a&&t<a&&u.setRowSpan(u.__rowSpan-(t-a)),t>=a&&t+u.__rowSpan-1>f))if(u.setRowSpan(u.__rowSpan-(f-t+1)),null===k&&E(122),0===m)oa(k,u);else{let {cell:B}=l[m-1];B.insertAfter(u)}}m=e.getChildAtIndex(p);J(m)||E(206,String(p));m.remove()}void 0!==l?({cell:a}=l[0],M(a)):({cell:a}=g[a-1][0],M(a))}};exports.$findCellNode=X;exports.$findTableNode=T;exports.$getElementForTableNode=function(a,b){a=a.getElementByKey(b.getKey());null===a&&E(230);return S(b,a)};exports.$getNodeTriplet=P;
exports.$getTableAndElementByKey=wa;exports.$getTableCellNodeFromLexicalNode=function(a){a=h.$findMatchingParent(a,b=>C(b));return C(a)?a:null};exports.$getTableCellNodeRect=ra;exports.$getTableColumnIndexFromTableCellNode=function(a){return ka(a).getChildren().findIndex(b=>b.is(a))};exports.$getTableNodeFromLexicalNodeOrThrow=la;exports.$getTableRowIndexFromTableCellNode=function(a){let b=ka(a);return la(b).getChildren().findIndex(c=>c.is(b))};exports.$getTableRowNodeFromTableCellNodeOrThrow=ka;

@@ -100,11 +100,11 @@ exports.$insertTableColumn=function(a,b,c=!0,d,e){let f=a.getChildren(),g=[];for(let r=0;r<f.length;r++){let l=f[r];if(J(l))for(let k=0;k<d;k++){var n=l.getChildren();if(b>=n.length||0>b)throw Error("Table column target index out of range");n=n[b];C(n)||E(12);let {left:m,right:p}=ma(n,e);var q=x.NO_STATUS;if(m&&m.hasHeaderState(x.ROW)||p&&p.hasHeaderState(x.ROW))q|=x.ROW;q=A(q);q.append(w.$createParagraphNode());g.push({newTableCell:q,targetCell:n})}}g.forEach(({newTableCell:r,targetCell:l})=>{c?

exports.$insertTableRow__EXPERIMENTAL=function(a=!0){var b=w.$getSelection();w.$isRangeSelection(b)||Q(b)||E(188);b=b.focus.getNode();let [c,,d]=P(b),[e,f]=N(d,c,c);b=e[0].length;var {startRow:g}=f;if(a){a=g+c.__rowSpan-1;var n=e[a];g=I();for(var q=0;q<b;q++){let {cell:l,startRow:k}=n[q];if(k+l.__rowSpan-1<=a){var r=na(n[q].cell.__headerState,x.COLUMN);g.append(A(r).append(w.$createParagraphNode()))}else l.setRowSpan(l.__rowSpan+1)}b=d.getChildAtIndex(a);J(b)||E(145);b.insertAfter(g);b=g}else{n=e[g];
a=I();for(q=0;q<b;q++){let {cell:l,startRow:k}=n[q];k===g?(r=na(n[q].cell.__headerState,x.COLUMN),a.append(A(r).append(w.$createParagraphNode()))):l.setRowSpan(l.__rowSpan+1)}b=d.getChildAtIndex(g);J(b)||E(145);b.insertBefore(a);b=a}return b};exports.$isScrollableTablesActive=Sa;exports.$isTableCellNode=C;exports.$isTableNode=K;exports.$isTableRowNode=J;exports.$isTableSelection=Q;
a=I();for(q=0;q<b;q++){let {cell:l,startRow:k}=n[q];k===g?(r=na(n[q].cell.__headerState,x.COLUMN),a.append(A(r).append(w.$createParagraphNode()))):l.setRowSpan(l.__rowSpan+1)}b=d.getChildAtIndex(g);J(b)||E(145);b.insertBefore(a);b=a}return b};exports.$isScrollableTablesActive=Ta;exports.$isTableCellNode=C;exports.$isTableNode=K;exports.$isTableRowNode=J;exports.$isTableSelection=Q;
exports.$removeTableRowAtIndex=function(a,b){let c=a.getChildren();if(b>=c.length||0>b)throw Error("Expected table cell to be inside of table row.");c[b].remove();return a};
exports.$unmergeCell=function(){var a=w.$getSelection();w.$isRangeSelection(a)||Q(a)||E(188);a=a.anchor.getNode();let [b,c,d]=P(a);a=b.__colSpan;let e=b.__rowSpan;if(1!==a||1!==e){var [f,g]=N(d,b,b),{startColumn:n,startRow:q}=g,r=b.__headerState&x.COLUMN,l=Array.from({length:a},(v,B)=>{v=r;for(let z=0;0!==v&&z<f.length;z++)v&=f[z][B+n].cell.__headerState;return v}),k=b.__headerState&x.ROW,m=Array.from({length:e},(v,B)=>{v=k;for(let z=0;0!==v&&z<f[0].length;z++)v&=f[B+q][z].cell.__headerState;return v});
if(1<a){for(var p=1;p<a;p++)b.insertAfter(A(l[p]|m[0]).append(w.$createParagraphNode()));b.setColSpan(1)}if(1<e){let v;for(p=1;p<e;p++){var u=q+p;let B=f[u];v=(v||c).getNextSibling();J(v)||E(125);var t=null;for(let z=0;z<n;z++){let D=B[z],G=D.cell;D.startRow===u&&(t=G);1<G.__colSpan&&(z+=G.__colSpan-1)}if(null===t)for(t=a-1;0<=t;t--)oa(v,A(l[t]|m[p]).append(w.$createParagraphNode()));else for(u=a-1;0<=u;u--)t.insertAfter(A(l[u]|m[p]).append(w.$createParagraphNode()))}b.setRowSpan(1)}}};
exports.INSERT_TABLE_COMMAND=da;exports.TableCellHeaderStates=x;exports.TableCellNode=y;exports.TableNode=bb;exports.TableObserver=xa;exports.TableRowNode=ia;
exports.INSERT_TABLE_COMMAND=da;exports.TableCellHeaderStates=x;exports.TableCellNode=y;exports.TableNode=cb;exports.TableObserver=xa;exports.TableRowNode=ia;
exports.applyTableHandlers=function(a,b,c,d){let e=c.getRootElement(),f=c._window;null!==e&&null!==f||E(246);let g=new xa(c,a.getKey()),n=R(a,b);Da(n,g);g.listenersToRemove.add(()=>{Ea(n)===g&&delete n.__lexicalTableSelection});let q=()=>{if(!g.isSelecting){var l=()=>{g.isSelecting=!1;f.removeEventListener("mouseup",l);f.removeEventListener("mousemove",k)},k=m=>{if(1!==(m.buttons&1)&&g.isSelecting)g.isSelecting=!1,f.removeEventListener("mouseup",l),f.removeEventListener("mousemove",k);else{var p=
!n.contains(m.target),u=null;if(p)for(const t of document.elementsFromPoint(m.clientX,m.clientY)){if(u=n.contains(t)?Fa(t):null)break}else u=Fa(m.target);!u||null!==g.focusCell&&u.elem===g.focusCell.elem||(g.setNextFocus({focusCell:u,override:p}),c.dispatchCommand(w.SELECTION_CHANGE_COMMAND,void 0))}};g.isSelecting=!0;f.addEventListener("mouseup",l,g.listenerOptions);f.addEventListener("mousemove",k,g.listenerOptions)}};n.addEventListener("mousedown",l=>{if(0===l.button&&f){var k=Fa(l.target);null!==
k&&c.update(()=>{const m=w.$getPreviousSelection();if(ha&&l.shiftKey&&W(m,a)&&(w.$isRangeSelection(m)||Q(m))){const p=m.anchor.getNode(),u=za(a,m.anchor.getNode());u?(g.$setAnchorCellForSelection(V(g,u)),g.$setFocusCellForSelection(k),Y(l)):(a.isBefore(p)?a.selectStart():a.selectEnd()).anchor.set(m.anchor.key,m.anchor.offset,m.anchor.type)}else g.$setAnchorCellForSelection(k)});q()}},g.listenerOptions);f.addEventListener("mousedown",l=>{0===l.button&&c.update(()=>{const k=w.$getSelection(),m=l.target;
Q(k)&&k.tableKey===g.tableNodeKey&&e.contains(m)&&g.$clearHighlight()})},g.listenerOptions);for(let [l,k]of Aa)g.listenersToRemove.add(c.registerCommand(l,m=>Qa(c,m,k,a,g),w.COMMAND_PRIORITY_HIGH));g.listenersToRemove.add(c.registerCommand(w.KEY_ESCAPE_COMMAND,l=>{var k=w.$getSelection();return Q(k)&&(k=za(a,k.focus.getNode()),null!==k)?(Y(l),k.selectEnd(),!0):!1},w.COMMAND_PRIORITY_HIGH));b=l=>()=>{var k=w.$getSelection();if(!W(k,a))return!1;if(Q(k))return g.$clearText(),!0;if(w.$isRangeSelection(k)){var m=
Q(k)&&k.tableKey===g.tableNodeKey&&e.contains(m)&&g.$clearHighlight()})},g.listenerOptions);for(let [l,k]of Aa)g.listenersToRemove.add(c.registerCommand(l,m=>Ra(c,m,k,a,g),w.COMMAND_PRIORITY_HIGH));g.listenersToRemove.add(c.registerCommand(w.KEY_ESCAPE_COMMAND,l=>{var k=w.$getSelection();return Q(k)&&(k=za(a,k.focus.getNode()),null!==k)?(Y(l),k.selectEnd(),!0):!1},w.COMMAND_PRIORITY_HIGH));b=l=>()=>{var k=w.$getSelection();if(!W(k,a))return!1;if(Q(k))return g.$clearText(),!0;if(w.$isRangeSelection(k)){var m=
za(a,k.anchor.getNode());if(!C(m))return!1;var p=k.anchor.getNode();m=k.focus.getNode();p=a.isParentOf(p);m=a.isParentOf(m);if(p&&!m||m&&!p)return g.$clearText(),!0;m=(k=h.$findMatchingParent(k.anchor.getNode(),u=>w.$isElementNode(u)))&&h.$findMatchingParent(k,u=>w.$isElementNode(u)&&C(u.getParent()));if(!w.$isElementNode(m)||!w.$isElementNode(k))return!1;if(l===w.DELETE_LINE_COMMAND&&null===m.getPreviousSibling())return!0}return!1};for(let l of Ba)g.listenersToRemove.add(c.registerCommand(l,b(l),

@@ -115,10 +115,10 @@ w.COMMAND_PRIORITY_CRITICAL));let r=l=>{const k=w.$getSelection();if(!Q(k)&&!w.$isRangeSelection(k))return!1;const m=a.isParentOf(k.anchor.getNode()),p=a.isParentOf(k.focus.getNode());if(m!==p){l=m?"focus":"anchor";const {key:u,offset:t,type:v}=k[l];a[k[m?"anchor":"focus"].isBefore(k[l])?"selectPrevious":"selectNext"]()[l].set(u,t,v);return!1}return Q(k)?(l&&(l.preventDefault(),l.stopPropagation()),g.$clearText(),!0):!1};for(let l of Ca)g.listenersToRemove.add(c.registerCommand(l,r,w.COMMAND_PRIORITY_CRITICAL));

Math.min(u.startColumn,t.startColumn),z=new Set;for(;v<=m;v++)for(let G=B;G<=k;G++){var D=p[v][G].cell;if(!z.has(D)){z.add(D);D.setFormat(l);D=D.getChildren();for(let H=0;H<D.length;H++){let L=D[H];w.$isElementNode(L)&&!L.isInline()&&L.setFormat(l)}}}return!0},w.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(w.CONTROLLED_TEXT_INSERTION_COMMAND,l=>{var k=w.$getSelection();if(!W(k,a))return!1;if(Q(k))g.$clearHighlight();else if(w.$isRangeSelection(k)){let m=h.$findMatchingParent(k.anchor.getNode(),
p=>C(p));if(!C(m))return!1;if("string"===typeof l&&(k=Ya(c,k,a)))return Xa(k,a,[w.$createTextNode(l)]),!0}return!1},w.COMMAND_PRIORITY_CRITICAL));d&&g.listenersToRemove.add(c.registerCommand(w.KEY_TAB_COMMAND,l=>{var k=w.$getSelection();if(!w.$isRangeSelection(k)||!k.isCollapsed()||!W(k,a))return!1;k=X(k.anchor.getNode());if(null===k)return!1;Y(l);k=a.getCordsFromCellNode(k,g.table);La(g,a,k.x,k.y,l.shiftKey?"backward":"forward");return!0},w.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(w.FOCUS_COMMAND,
p=>C(p));if(!C(m))return!1;if("string"===typeof l&&(k=Za(c,k,a)))return Ya(k,a,[w.$createTextNode(l)]),!0}return!1},w.COMMAND_PRIORITY_CRITICAL));d&&g.listenersToRemove.add(c.registerCommand(w.KEY_TAB_COMMAND,l=>{var k=w.$getSelection();if(!w.$isRangeSelection(k)||!k.isCollapsed()||!W(k,a))return!1;k=X(k.anchor.getNode());if(null===k)return!1;Y(l);k=a.getCordsFromCellNode(k,g.table);La(g,a,k.x,k.y,l.shiftKey?"backward":"forward");return!0},w.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(w.FOCUS_COMMAND,
()=>a.isSelected(),w.COMMAND_PRIORITY_HIGH));g.listenersToRemove.add(c.registerCommand(w.SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,l=>{let {nodes:k,selection:m}=l;l=m.getStartEndPoints();var p=Q(m);p=w.$isRangeSelection(m)&&null!==h.$findMatchingParent(m.anchor.getNode(),H=>C(H))&&null!==h.$findMatchingParent(m.focus.getNode(),H=>C(H))||p;if(1!==k.length||!K(k[0])||!p||null===l)return!1;var [u]=l,t=k[0];l=t.getChildren();p=t.getFirstChildOrThrow().getChildrenSize();t=t.getChildrenSize();var v=h.$findMatchingParent(u.getNode(),
H=>C(H)),B=v&&h.$findMatchingParent(v,H=>J(H)),z=B&&h.$findMatchingParent(B,H=>K(H));if(!C(v)||!J(B)||!K(z))return!1;u=B.getIndexWithinParent();var D=Math.min(z.getChildrenSize()-1,u+t-1);t=v.getIndexWithinParent();v=Math.min(B.getChildrenSize()-1,t+p-1);p=Math.min(t,v);B=Math.min(u,D);t=Math.max(t,v);u=Math.max(u,D);z=z.getChildren();for(D=0;B<=u;B++){v=z[B];if(!J(v))return!1;var G=l[D];if(!J(G))return!1;v=v.getChildren();G=G.getChildren();let H=0;for(let L=p;L<=t;L++){let O=v[L];if(!C(O))return!1;
let Na=G[H];if(!C(Na))return!1;let eb=O.getChildren();Na.getChildren().forEach(Z=>{w.$isTextNode(Z)&&w.$createParagraphNode().append(Z);O.append(Z)});eb.forEach(Z=>Z.remove());H++}D++}return!0},w.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(w.SELECTION_CHANGE_COMMAND,()=>{let l=w.$getSelection(),k=w.$getPreviousSelection();var m=g.getAndClearNextFocus();if(null!==m){({focusCell:m}=m);if(Q(l)&&l.tableKey===g.tableNodeKey){if(m.x===g.focusX&&m.y===g.focusY)return!1;g.$setFocusCellForSelection(m);
let Na=G[H];if(!C(Na))return!1;let fb=O.getChildren();Na.getChildren().forEach(Z=>{w.$isTextNode(Z)&&w.$createParagraphNode().append(Z);O.append(Z)});fb.forEach(Z=>Z.remove());H++}D++}return!0},w.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(w.SELECTION_CHANGE_COMMAND,()=>{let l=w.$getSelection(),k=w.$getPreviousSelection();var m=g.getAndClearNextFocus();if(null!==m){({focusCell:m}=m);if(Q(l)&&l.tableKey===g.tableNodeKey){if(m.x===g.focusX&&m.y===g.focusY)return!1;g.$setFocusCellForSelection(m);
return!0}if(m!==g.anchorCell&&W(l,a))return g.$setFocusCellForSelection(m),!0}if(g.getAndClearShouldCheckSelection()&&w.$isRangeSelection(k)&&w.$isRangeSelection(l)&&l.isCollapsed()){var p=l.anchor.getNode();m=a.getFirstChild();p=X(p);if(null!==p&&J(m)){let v=m.getFirstChild();if(C(v)&&a.is(h.$findMatchingParent(p,B=>B.is(a)||B.is(v))))return v.selectStart(),!0}}if(w.$isRangeSelection(l)){let {anchor:v,focus:B}=l;p=v.getNode();m=B.getNode();var u=X(p),t=X(m);let z=!(!u||!a.is(T(u))),D=!(!t||!a.is(T(t)));
p=z!==D;let G=z&&D;m=l.isBackward();p?(p=l.clone(),D?([t]=N(a,t,t),u=t[0][0].cell,t=t[t.length-1].at(-1).cell,p.focus.set(m?u.getKey():t.getKey(),m?u.getChildrenSize():t.getChildrenSize(),"element")):z&&([t]=N(a,u,u),u=t[0][0].cell,t=t[t.length-1].at(-1).cell,p.anchor.set(m?t.getKey():u.getKey(),m?t.getChildrenSize():0,"element")),w.$setSelection(p),Ja(c,g)):G&&!u.is(t)&&(g.$setAnchorCellForSelection(V(g,u)),g.$setFocusCellForSelection(V(g,t),!0))}else l&&Q(l)&&l.is(k)&&l.tableKey===a.getKey()&&(m=
w.getDOMSelection(f))&&m.anchorNode&&m.focusNode&&(p=(p=w.$getNearestNodeFromDOMNode(m.focusNode))&&!a.is(T(p)),u=(u=w.$getNearestNodeFromDOMNode(m.anchorNode))&&a.is(T(u)),p&&u&&0<m.rangeCount&&(p=w.$createRangeSelectionFromDom(m,c)))&&(p.anchor.set(a.getKey(),l.isBackward()?a.getChildrenSize():0,"element"),m.removeAllRanges(),w.$setSelection(p));if(l&&!l.is(k)&&(Q(l)||Q(k))&&g.tableSelection&&!g.tableSelection.is(k))return Q(l)&&l.tableKey===g.tableNodeKey?g.$updateTableTableSelection(l):!Q(l)&&
Q(k)&&k.tableKey===g.tableNodeKey&&g.$updateTableTableSelection(null),!1;g.hasHijackedSelectionStyles&&!a.isSelected()?Ka(c,g):!g.hasHijackedSelectionStyles&&a.isSelected()&&Ja(c,g);return!1},w.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(w.INSERT_PARAGRAPH_COMMAND,()=>{var l=w.$getSelection();return w.$isRangeSelection(l)&&l.isCollapsed()&&W(l,a)?(l=Ya(c,l,a))?(Xa(l,a),!0):!1:!1},w.COMMAND_PRIORITY_CRITICAL));return g};exports.getDOMCellFromTarget=Fa;
exports.getTableElement=R;exports.getTableObserverFromTableElement=Ea;exports.setScrollableTablesActive=function(a,b){b?ab.add(a):ab.delete(a)}
Q(k)&&k.tableKey===g.tableNodeKey&&g.$updateTableTableSelection(null),!1;g.hasHijackedSelectionStyles&&!a.isSelected()?Ka(c,g):!g.hasHijackedSelectionStyles&&a.isSelected()&&Ja(c,g);return!1},w.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(w.INSERT_PARAGRAPH_COMMAND,()=>{var l=w.$getSelection();return w.$isRangeSelection(l)&&l.isCollapsed()&&W(l,a)?(l=Za(c,l,a))?(Ya(l,a),!0):!1:!1},w.COMMAND_PRIORITY_CRITICAL));return g};exports.getDOMCellFromTarget=Fa;
exports.getTableElement=R;exports.getTableObserverFromTableElement=Ea;exports.setScrollableTablesActive=function(a,b){b?bb.add(a):bb.delete(a)}

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

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

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

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc