@lexical/table
Advanced tools
Comparing version 0.20.1-nightly.20241122.0 to 0.20.1-nightly.20241125.0
@@ -9,100 +9,110 @@ /** | ||
'use strict';var h=require("@lexical/utils"),u=require("lexical"),aa=require("@lexical/clipboard");let ba=/^(\d+(?:\.\d+)?)px$/,y={BOTH:3,COLUMN:2,NO_STATUS:0,ROW:1}; | ||
class z extends u.ElementNode{static getType(){return"tablecell"}static clone(a){return new z(a.__headerState,a.__colSpan,a.__width,a.__key)}afterCloneFrom(a){super.afterCloneFrom(a);this.__rowSpan=a.__rowSpan;this.__backgroundColor=a.__backgroundColor}static importDOM(){return{td:()=>({conversion:ca,priority:0}),th:()=>({conversion:ca,priority:0})}}static importJSON(a){let b=a.rowSpan||1;return B(a.headerState,a.colSpan||1,a.width||void 0).setRowSpan(b).setBackgroundColor(a.backgroundColor||null)}constructor(a= | ||
y.NO_STATUS,b=1,c,d){super(d);this.__colSpan=b;this.__rowSpan=1;this.__headerState=a;this.__width=c;this.__backgroundColor=null}createDOM(a){let b=document.createElement(this.getTag());this.__width&&(b.style.width=`${this.__width}px`);1<this.__colSpan&&(b.colSpan=this.__colSpan);1<this.__rowSpan&&(b.rowSpan=this.__rowSpan);null!==this.__backgroundColor&&(b.style.backgroundColor=this.__backgroundColor);h.addClassNamesToElement(b,a.theme.tableCell,this.hasHeader()&&a.theme.tableCellHeader);return b}exportDOM(a){({element:a}= | ||
super.exportDOM(a));if(a){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()||75}px`;a.style.verticalAlign="top";a.style.textAlign="start";let 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(),colSpan:this.__colSpan,headerState:this.__headerState, | ||
rowSpan:this.__rowSpan,type:"tablecell",width:this.getWidth()}}getColSpan(){return this.getLatest().__colSpan}setColSpan(a){let b=this.getWritable();b.__colSpan=a;return b}getRowSpan(){return this.getLatest().__rowSpan}setRowSpan(a){let b=this.getWritable();b.__rowSpan=a;return b}getTag(){return this.hasHeader()?"th":"td"}setHeaderStyles(a,b=y.BOTH){let c=this.getWritable();c.__headerState=a&b|c.__headerState&~b;return c}getHeaderStyles(){return this.getLatest().__headerState}setWidth(a){let b=this.getWritable(); | ||
b.__width=a;return b}getWidth(){return this.getLatest().__width}getBackgroundColor(){return this.getLatest().__backgroundColor}setBackgroundColor(a){let b=this.getWritable();b.__backgroundColor=a;return b}toggleHeaderStyle(a){let b=this.getWritable();b.__headerState=(b.__headerState&a)===a?b.__headerState-a:b.__headerState+a;return b}hasHeaderState(a){return(this.getHeaderStyles()&a)===a}hasHeader(){return this.getLatest().__headerState!==y.NO_STATUS}updateDOM(a){return a.__headerState!==this.__headerState|| | ||
'use strict';var h=require("@lexical/utils"),w=require("lexical"),aa=require("@lexical/clipboard");let ba=/^(\d+(?:\.\d+)?)px$/,x={BOTH:3,COLUMN:2,NO_STATUS:0,ROW:1}; | ||
class y extends w.ElementNode{static getType(){return"tablecell"}static clone(a){return new y(a.__headerState,a.__colSpan,a.__width,a.__key)}afterCloneFrom(a){super.afterCloneFrom(a);this.__rowSpan=a.__rowSpan;this.__backgroundColor=a.__backgroundColor}static importDOM(){return{td:()=>({conversion:ca,priority:0}),th:()=>({conversion:ca,priority:0})}}static importJSON(a){let b=a.rowSpan||1;return A(a.headerState,a.colSpan||1,a.width||void 0).setRowSpan(b).setBackgroundColor(a.backgroundColor||null)}constructor(a= | ||
x.NO_STATUS,b=1,c,d){super(d);this.__colSpan=b;this.__rowSpan=1;this.__headerState=a;this.__width=c;this.__backgroundColor=null}createDOM(a){let b=document.createElement(this.getTag());this.__width&&(b.style.width=`${this.__width}px`);1<this.__colSpan&&(b.colSpan=this.__colSpan);1<this.__rowSpan&&(b.rowSpan=this.__rowSpan);null!==this.__backgroundColor&&(b.style.backgroundColor=this.__backgroundColor);h.addClassNamesToElement(b,a.theme.tableCell,this.hasHeader()&&a.theme.tableCellHeader);return b}exportDOM(a){a= | ||
super.exportDOM(a);if(a.element){let b=a.element;b.style.border="1px solid black";1<this.__colSpan&&(b.colSpan=this.__colSpan);1<this.__rowSpan&&(b.rowSpan=this.__rowSpan);b.style.width=`${this.getWidth()||75}px`;b.style.verticalAlign="top";b.style.textAlign="start";null===this.__backgroundColor&&this.hasHeader()&&(b.style.backgroundColor="#f2f3f5")}return a}exportJSON(){return{...super.exportJSON(),backgroundColor:this.getBackgroundColor(),colSpan:this.__colSpan,headerState:this.__headerState,rowSpan:this.__rowSpan, | ||
type:"tablecell",width:this.getWidth()}}getColSpan(){return this.getLatest().__colSpan}setColSpan(a){let b=this.getWritable();b.__colSpan=a;return b}getRowSpan(){return this.getLatest().__rowSpan}setRowSpan(a){let b=this.getWritable();b.__rowSpan=a;return b}getTag(){return this.hasHeader()?"th":"td"}setHeaderStyles(a,b=x.BOTH){let c=this.getWritable();c.__headerState=a&b|c.__headerState&~b;return c}getHeaderStyles(){return this.getLatest().__headerState}setWidth(a){let b=this.getWritable();b.__width= | ||
a;return b}getWidth(){return this.getLatest().__width}getBackgroundColor(){return this.getLatest().__backgroundColor}setBackgroundColor(a){let b=this.getWritable();b.__backgroundColor=a;return b}toggleHeaderStyle(a){let b=this.getWritable();b.__headerState=(b.__headerState&a)===a?b.__headerState-a:b.__headerState+a;return b}hasHeaderState(a){return(this.getHeaderStyles()&a)===a}hasHeader(){return this.getLatest().__headerState!==x.NO_STATUS}updateDOM(a){return a.__headerState!==this.__headerState|| | ||
a.__width!==this.__width||a.__colSpan!==this.__colSpan||a.__rowSpan!==this.__rowSpan||a.__backgroundColor!==this.__backgroundColor}isShadowRoot(){return!0}collapseAtStart(){return!0}canBeEmpty(){return!1}canIndent(){return!1}} | ||
function ca(a){var b=a.nodeName.toLowerCase(),c=void 0;ba.test(a.style.width)&&(c=parseFloat(a.style.width));b=B("th"===b?y.ROW:y.NO_STATUS,a.colSpan,c);b.__rowSpan=a.rowSpan;c=a.style.backgroundColor;""!==c&&(b.__backgroundColor=c);a=a.style;c=(a&&a.textDecoration||"").split(" ");let d="700"===a.fontWeight||"bold"===a.fontWeight,f=c.includes("line-through"),e="italic"===a.fontStyle,g=c.includes("underline");return{after:m=>{0===m.length&&m.push(u.$createParagraphNode());return m},forChild:(m,p)=> | ||
{if(C(p)&&!u.$isElementNode(m)){p=u.$createParagraphNode();if(u.$isLineBreakNode(m)&&"\n"===m.getTextContent())return null;u.$isTextNode(m)&&(d&&m.toggleFormat("bold"),f&&m.toggleFormat("strikethrough"),e&&m.toggleFormat("italic"),g&&m.toggleFormat("underline"));p.append(m);return p}return m},node:b}}function B(a,b=1,c){return u.$applyNodeReplacement(new z(a,b,c))}function C(a){return a instanceof z}let da=u.createCommand("INSERT_TABLE_COMMAND");var E; | ||
function F(a){let b=new URLSearchParams;b.append("code",a);for(let c=1;c<arguments.length;c++)b.append("v",arguments[c]);throw Error(`Minified Lexical error #${a}; visit https://lexical.dev/docs/error?${b} for the full message or `+"use the non-minified dev environment for full errors and additional helpful warnings.");}E=F&&F.__esModule&&Object.prototype.hasOwnProperty.call(F,"default")?F["default"]:F;let ea="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement; | ||
class fa extends u.ElementNode{static getType(){return"tablerow"}static clone(a){return new fa(a.__height,a.__key)}static importDOM(){return{tr:()=>({conversion:ha,priority:0})}}static importJSON(a){return I(a.height)}constructor(a,b){super(b);this.__height=a}exportJSON(){return{...super.exportJSON(),...(this.getHeight()&&{height:this.getHeight()}),type:"tablerow",version:1}}createDOM(a){let b=document.createElement("tr");this.__height&&(b.style.height=`${this.__height}px`);h.addClassNamesToElement(b, | ||
a.theme.tableRow);return b}isShadowRoot(){return!0}setHeight(a){this.getWritable().__height=a;return this.__height}getHeight(){return this.getLatest().__height}updateDOM(a){return a.__height!==this.__height}canBeEmpty(){return!1}canIndent(){return!1}}function ha(a){let b=void 0;ba.test(a.style.height)&&(b=parseFloat(a.style.height));return{node:I(b)}}function I(a){return u.$applyNodeReplacement(new fa(a))}function K(a){return a instanceof fa} | ||
function ia(a){a=h.$findMatchingParent(a,b=>K(b));if(K(a))return a;throw Error("Expected table cell to be inside of table row.");}function ja(a){a=h.$findMatchingParent(a,b=>L(b));if(L(a))return a;throw Error("Expected table cell to be inside of table.");}function ka(a,b){let c=ja(a),{x:d,y:f}=c.getCordsFromCellNode(a,b);return{above:c.getCellNodeFromCords(d,f-1,b),below:c.getCellNodeFromCords(d,f+1,b),left:c.getCellNodeFromCords(d-1,f,b),right:c.getCellNodeFromCords(d+1,f,b)}} | ||
let la=(a,b)=>a===y.BOTH||a===b?b:y.NO_STATUS;function N(a){let b=a.getFirstDescendant();null==b?a.selectStart():b.getParentOrThrow().selectStart()}function ma(a,b){let c=a.getFirstChild();null!==c?c.insertBefore(b):a.append(b)}function O(a,b,c){let [d,f,e]=na(a,b,c);null===f&&E(207);null===e&&E(208);return[d,f,e]} | ||
function na(a,b,c){function d(p){let r=f[p];void 0===r&&(f[p]=r=[]);return r}let f=[],e=null,g=null;a=a.getChildren();for(let p=0;p<a.length;p++){var m=a[p];K(m)||E(209);for(let r=m.getFirstChild(),v=0;null!=r;r=r.getNextSibling()){C(r)||E(147);for(m=d(p);void 0!==m[v];)v++;m={cell:r,startColumn:v,startRow:p};let {__rowSpan:w,__colSpan:l}=r;for(let k=0;k<w&&!(p+k>=a.length);k++){let n=d(p+k);for(let q=0;q<l;q++)n[v+q]=m}null!==b&&null===e&&b.is(r)&&(e=m);null!==c&&null===g&&c.is(r)&&(g=m)}}return[f, | ||
e,g]}function P(a){a instanceof z||("__type"in a?(a=h.$findMatchingParent(a,C),C(a)||E(148)):(a=h.$findMatchingParent(a.getNode(),C),C(a)||E(148)));let b=a.getParent();K(b)||E(149);let c=b.getParent();L(c)||E(210);return[a,b,c]} | ||
function oa(a){let [b,,c]=P(a);a=c.getChildren();let d=a.length;var f=a[0].getChildren().length;let e=Array(d);for(var g=0;g<d;g++)e[g]=Array(f);for(f=0;f<d;f++){g=a[f].getChildren();let m=0;for(let p=0;p<g.length;p++){for(;e[f][m];)m++;let r=g[p],v=r.__rowSpan||1,w=r.__colSpan||1;for(let l=0;l<v;l++)for(let k=0;k<w;k++)e[f+l][m+k]=r;if(b===r)return{colSpan:w,columnIndex:m,rowIndex:f,rowSpan:v};m+=w}}return null} | ||
class pa{constructor(a,b,c){this.anchor=b;this.focus=c;b._selection=this;c._selection=this;this._cachedNodes=null;this.dirty=!1;this.tableKey=a}getStartEndPoints(){return[this.anchor,this.focus]}isBackward(){return this.focus.isBefore(this.anchor)}getCachedNodes(){return this._cachedNodes}setCachedNodes(a){this._cachedNodes=a}is(a){return Q(a)?this.tableKey===a.tableKey&&this.anchor.is(a.anchor)&&this.focus.is(a.focus):!1}set(a,b,c){this.dirty=!0;this.tableKey=a;this.anchor.key=b;this.focus.key=c; | ||
this._cachedNodes=null}clone(){return new pa(this.tableKey,this.anchor,this.focus)}isCollapsed(){return!1}extract(){return this.getNodes()}insertRawText(){}insertText(){}hasFormat(a){let b=0;this.getNodes().filter(C).forEach(c=>{c=c.getFirstChild();u.$isParagraphNode(c)&&(b|=c.getTextFormat())});return 0!==(b&u.TEXT_TYPE_TO_FORMAT[a])}insertNodes(a){let b=this.focus.getNode();u.$isElementNode(b)||E(151);u.$normalizeSelection__EXPERIMENTAL(b.select(0,b.getChildrenSize())).insertNodes(a)}getShape(){var a= | ||
u.$getNodeByKey(this.anchor.key);C(a)||E(152);a=oa(a);null===a&&E(153);var b=u.$getNodeByKey(this.focus.key);C(b)||E(154);let c=oa(b);null===c&&E(155);b=Math.min(a.columnIndex,c.columnIndex);let d=Math.max(a.columnIndex+a.colSpan-1,c.columnIndex+c.colSpan-1),f=Math.min(a.rowIndex,c.rowIndex);a=Math.max(a.rowIndex+a.rowSpan-1,c.rowIndex+c.rowSpan-1);return{fromX:Math.min(b,d),fromY:Math.min(f,a),toX:Math.max(b,d),toY:Math.max(f,a)}}getNodes(){function a(t){let {cell:x,startColumn:A,startRow:D}=t;r= | ||
Math.min(r,A);v=Math.min(v,D);w=Math.max(w,A+x.__colSpan-1);l=Math.max(l,D+x.__rowSpan-1)}var b=this._cachedNodes;if(null!==b)return b;var c=this.anchor.getNode();b=this.focus.getNode();var d=h.$findMatchingParent(c,C);c=h.$findMatchingParent(b,C);C(d)||E(152);C(c)||E(154);b=d.getParent();K(b)||E(156);b=b.getParent();L(b)||E(157);var f=c.getParents()[1];if(f!==b){if(b.isParentOf(c)){var e=f.getParent();null==e&&E(159);this.set(this.tableKey,c.getKey(),e.getKey())}else e=b.getParent(),null==e&&E(158), | ||
this.set(this.tableKey,e.getKey(),c.getKey());return this.getNodes()}let [g,m,p]=O(b,d,c),r=Math.min(m.startColumn,p.startColumn),v=Math.min(m.startRow,p.startRow),w=Math.max(m.startColumn+m.cell.__colSpan-1,p.startColumn+p.cell.__colSpan-1),l=Math.max(m.startRow+m.cell.__rowSpan-1,p.startRow+p.cell.__rowSpan-1);c=r;d=v;f=r;for(var k=v;r<c||v<d||w>f||l>k;){if(r<c){var n=k-d;--c;for(var q=0;q<=n;q++)a(g[d+q][c])}if(v<d)for(n=f-c,--d,q=0;q<=n;q++)a(g[d][c+q]);if(w>f)for(n=k-d,f+=1,q=0;q<=n;q++)a(g[d+ | ||
q][f]);if(l>k)for(n=f-c,k+=1,q=0;q<=n;q++)a(g[k][c+q])}b=new Map([[b.getKey(),b]]);c=null;for(d=v;d<=l;d++)for(f=r;f<=w;f++){({cell:k}=g[d][f]);n=k.getParent();K(n)||E(160);n!==c&&b.set(n.getKey(),n);b.set(k.getKey(),k);for(e of qa(k))b.set(e.getKey(),e);c=n}e=Array.from(b.values());u.isCurrentlyReadOnlyMode()||(this._cachedNodes=e);return e}getTextContent(){let a=this.getNodes().filter(c=>C(c)),b="";for(let c=0;c<a.length;c++){let d=a[c],f=d.__parent,e=(a[c+1]||{}).__parent;b+=d.getTextContent()+ | ||
(e!==f?"\n":"\t")}return b}}function Q(a){return a instanceof pa}function ra(){let a=u.$createPoint("root",0,"element"),b=u.$createPoint("root",0,"element");return new pa("root",a,b)}function qa(a){let b=[],c=[a];for(;0<c.length;){let d=c.pop();void 0===d&&E(112);u.$isElementNode(d)&&c.unshift(...d.getChildren());d!==a&&b.push(d)}return b}function ta(a,b=u.$getEditor()){let c=u.$getNodeByKey(a);L(c)||E(229,a);b=R(c,b.getElementByKey(a));null===b&&E(230,a);return{tableElement:b,tableNode:c}} | ||
class ua{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.trackTable()}getTable(){return this.table}removeListeners(){this.abortController.abort("removeListeners"); | ||
Array.from(this.listenersToRemove).forEach(a=>a());this.listenersToRemove.clear()}$lookup(){return ta(this.tableNodeKey,this.editor)}trackTable(){let a=new MutationObserver(b=>{this.editor.getEditorState().read(()=>{let c=!1;for(let e=0;e<b.length;e++){const g=b[e].target.nodeName;if("TABLE"===g||"TBODY"===g||"THEAD"===g||"TR"===g){c=!0;break}}if(c){var {tableNode:d,tableElement:f}=this.$lookup();this.table=S(d,f)}},{editor:this.editor})});this.editor.getEditorState().read(()=>{let {tableNode:b,tableElement:c}= | ||
this.$lookup();this.table=S(b,c);a.observe(c,{attributes:!0,childList:!0,subtree:!0})},{editor:this.editor})}clearHighlight(){let a=this.editor;this.isHighlightingCells=!1;this.focusY=this.focusX=this.anchorY=this.anchorX=-1;this.focusCell=this.anchorCell=this.focusCellNodeKey=this.anchorCellNodeKey=this.tableSelection=null;this.hasHijackedSelectionStyles=!1;this.enableHighlightStyle();a.update(()=>{let {tableNode:b,tableElement:c}=this.$lookup(),d=S(b,c);va(a,d,null);u.$setSelection(null);a.dispatchCommand(u.SELECTION_CHANGE_COMMAND, | ||
void 0)})}enableHighlightStyle(){let a=this.editor;a.getEditorState().read(()=>{let {tableElement:b}=this.$lookup();h.removeClassNamesFromElement(b,a._config.theme.tableSelection);b.classList.remove("disable-selection");this.hasHijackedSelectionStyles=!1},{editor:a})}disableHighlightStyle(){let a=this.editor;a.getEditorState().read(()=>{let {tableElement:b}=this.$lookup();h.addClassNamesToElement(b,a._config.theme.tableSelection);this.hasHijackedSelectionStyles=!0},{editor:a})}updateTableTableSelection(a){if(null!== | ||
a&&a.tableKey===this.tableNodeKey){let b=this.editor;this.tableSelection=a;this.isHighlightingCells=!0;this.disableHighlightStyle();va(b,this.table,this.tableSelection)}else null==a?this.clearHighlight():(this.tableNodeKey=a.tableKey,this.updateTableTableSelection(a))}setShouldCheckSelection(){this.shouldCheckSelection=!0}getAndClearShouldCheckSelection(){return this.shouldCheckSelection?(this.shouldCheckSelection=!1,!0):!1}setFocusCellForSelection(a,b=!1){let c=this.editor;c.update(()=>{var {tableNode:d}= | ||
this.$lookup(),f=a.x;let e=a.y;this.focusCell=a;if(null!==this.anchorCell){let g=ea?(c._window||window).getSelection():null;g&&g.setBaseAndExtent(this.anchorCell.elem,0,this.focusCell.elem,0)}if(!this.isHighlightingCells&&(this.anchorX!==f||this.anchorY!==e||b))this.isHighlightingCells=!0,this.disableHighlightStyle();else if(f===this.focusX&&e===this.focusY)return;this.focusX=f;this.focusY=e;this.isHighlightingCells&&(f=u.$getNearestNodeFromDOMNode(a.elem),null!=this.tableSelection&&null!=this.anchorCellNodeKey&& | ||
C(f)&&d.is(T(f))&&(d=f.getKey(),this.tableSelection=this.tableSelection.clone()||ra(),this.focusCellNodeKey=d,this.tableSelection.set(this.tableNodeKey,this.anchorCellNodeKey,this.focusCellNodeKey),u.$setSelection(this.tableSelection),c.dispatchCommand(u.SELECTION_CHANGE_COMMAND,void 0),va(c,this.table,this.tableSelection)))})}setAnchorCellForSelection(a){this.isHighlightingCells=!1;this.anchorCell=a;this.anchorX=a.x;this.anchorY=a.y;this.editor.update(()=>{var b=u.$getNearestNodeFromDOMNode(a.elem); | ||
C(b)&&(b=b.getKey(),this.tableSelection=null!=this.tableSelection?this.tableSelection.clone():ra(),this.anchorCellNodeKey=b)})}formatCells(a){this.editor.update(()=>{let b=u.$getSelection();Q(b)||E(11);let c=u.$createRangeSelection(),d=c.anchor,f=c.focus,e=b.getNodes().filter(C),g=e[0].getFirstChild(),m=u.$isParagraphNode(g)?g.getFormatFlags(a,null):null;e.forEach(p=>{d.set(p.getKey(),0,"element");f.set(p.getKey(),p.getChildrenSize(),"element");c.formatText(a,m)});u.$setSelection(b);this.editor.dispatchCommand(u.SELECTION_CHANGE_COMMAND, | ||
void 0)})}clearText(){let a=this.editor;a.update(()=>{let b=u.$getNodeByKey(this.tableNodeKey);if(!L(b))throw Error("Expected TableNode.");var c=u.$getSelection();Q(c)||E(11);c=c.getNodes().filter(C);c.length===this.table.columns*this.table.rows?(b.selectPrevious(),b.remove(),u.$getRoot().selectStart()):(c.forEach(d=>{if(u.$isElementNode(d)){let f=u.$createParagraphNode(),e=u.$createTextNode();f.append(e);d.append(f);d.getChildren().forEach(g=>{g!==f&&g.remove()})}}),va(a,this.table,null),u.$setSelection(null), | ||
a.dispatchCommand(u.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(233,b.nodeName);return a}function wa(a,b){null!==xa(a)&&E(205);a.__lexicalTableSelection=b}function xa(a){return a.__lexicalTableSelection||null}function ya(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 S(a,b){var c=R(a,b);a=[];b={columns:0,domRows:a,rows:0};var d=c.querySelector("tr");let f=c=0;for(a.length=0;null!=d;){var e=d.nodeName;if("TD"===e||"TH"===e){e=d;e={elem:e,hasBackgroundColor:""!==e.style.backgroundColor,highlighted:!1,x:c,y:f};d._cell=e;let g=a[f];void 0===g&&(g=a[f]=[]);g[c]=e}else if(e=d.firstChild,null!=e){d=e;continue}e=d.nextSibling;if(null!=e)c++,d=e;else if(e=d.parentNode,null!=e){d=e.nextSibling;if(null==d)break;f++;c=0}}b.columns=c+1;b.rows=f+1;return b} | ||
function va(a,b,c){let d=new Set(c?c.getNodes():[]);za(b,(f,e)=>{let g=f.elem;d.has(e)?(f.highlighted=!0,Aa(a,f)):(f.highlighted=!1,Ba(a,f),g.getAttribute("style")||g.removeAttribute("style"))})}function za(a,b){({domRows:a}=a);for(let c=0;c<a.length;c++){let d=a[c];if(d)for(let f=0;f<d.length;f++){let e=d[f];if(!e)continue;let g=u.$getNearestNodeFromDOMNode(e.elem);null!==g&&b(e,g,{x:f,y:c})}}}function Ca(a,b){b.disableHighlightStyle();za(b.table,c=>{c.highlighted=!0;Aa(a,c)})} | ||
function Da(a,b){b.enableHighlightStyle();za(b.table,c=>{let d=c.elem;c.highlighted=!1;Ba(a,c);d.getAttribute("style")||d.removeAttribute("style")})} | ||
let Ea=(a,b,c,d,f)=>{const e="forward"===f;switch(f){case "backward":case "forward":return c!==(e?a.table.columns-1:0)?(a=b.getCellNodeFromCordsOrThrow(c+(e?1:-1),d,a.table),e?a.selectStart():a.selectEnd()):d!==(e?a.table.rows-1:0)?(a=b.getCellNodeFromCordsOrThrow(e?0:a.table.columns-1,d+(e?1:-1),a.table),e?a.selectStart():a.selectEnd()):e?b.selectNext():b.selectPrevious(),!0;case "up":return 0!==d?b.getCellNodeFromCordsOrThrow(c,d-1,a.table).selectEnd():b.selectPrevious(),!0;case "down":return d!== | ||
a.table.rows-1?b.getCellNodeFromCordsOrThrow(c,d+1,a.table).selectStart():b.selectNext(),!0;default:return!1}},Fa=(a,b,c,d,f)=>{const e="forward"===f;switch(f){case "backward":case "forward":return c!==(e?a.table.columns-1:0)&&a.setFocusCellForSelection(b.getDOMCellFromCordsOrThrow(c+(e?1:-1),d,a.table)),!0;case "up":return 0!==d?(a.setFocusCellForSelection(b.getDOMCellFromCordsOrThrow(c,d-1,a.table)),!0):!1;case "down":return d!==a.table.rows-1?(a.setFocusCellForSelection(b.getDOMCellFromCordsOrThrow(c, | ||
d+1,a.table)),!0):!1;default:return!1}};function U(a,b){if(u.$isRangeSelection(a)||Q(a)){let c=b.isParentOf(a.anchor.getNode());a=b.isParentOf(a.focus.getNode());return c&&a}return!1} | ||
function Aa(a,b){a=b.elem;b=u.$getNearestNodeFromDOMNode(a);C(b)||E(131);null===b.getBackgroundColor()?a.style.setProperty("background-color","rgb(172,206,247)"):a.style.setProperty("background-image","linear-gradient(to right, rgba(172,206,247,0.85), rgba(172,206,247,0.85))");a.style.setProperty("caret-color","transparent")} | ||
function Ba(a,b){a=b.elem;b=u.$getNearestNodeFromDOMNode(a);C(b)||E(131);null===b.getBackgroundColor()&&a.style.removeProperty("background-color");a.style.removeProperty("background-image");a.style.removeProperty("caret-color")}function V(a){a=h.$findMatchingParent(a,C);return C(a)?a:null}function T(a){a=h.$findMatchingParent(a,L);return L(a)?a:null} | ||
function W(a,b,c,d,f){if(("up"===c||"down"===c)&&Ga(a))return!1;var e=u.$getSelection();if(!U(e,d)){if(u.$isRangeSelection(e)){if(e.isCollapsed()&&"backward"===c){c=e.anchor.type;d=e.anchor.offset;if("element"!==c&&("text"!==c||0!==d))return!1;c=e.anchor.getNode();if(!c)return!1;c=h.$findMatchingParent(c,r=>u.$isElementNode(r)&&!r.isInline());if(!c)return!1;c=c.getPreviousSibling();if(!c||!L(c))return!1;X(b);c.selectEnd();return!0}if(b.shiftKey&&("up"===c||"down"===c)){var g=e.focus.getNode();if(!e.isCollapsed()&& | ||
("up"===c&&!e.isBackward()||"down"===c&&e.isBackward())){f=h.$findMatchingParent(g,r=>L(r));C(f)&&(f=h.$findMatchingParent(f,L));if(f!==d||!f)return!1;d="down"===c?f.getNextSibling():f.getPreviousSibling();if(!d)return!1;f=0;"up"===c&&u.$isElementNode(d)&&(f=d.getChildrenSize());a=d;"up"===c&&u.$isElementNode(d)&&(a=(c=d.getLastChild())?c:d,f=u.$isTextNode(a)?a.getTextContentSize():0);c=e.clone();c.focus.set(a.getKey(),f,u.$isTextNode(a)?"text":"element");u.$setSelection(c);X(b);return!0}if(u.$isRootOrShadowRoot(g)){if((b= | ||
"up"===c?e.getNodes()[e.getNodes().length-1]:e.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,f.table);b=d.getCordsFromCellNode(b,f.table);c=d.getDOMCellFromCordsOrThrow(c.x,c.y,f.table);b=d.getDOMCellFromCordsOrThrow(b.x,b.y,f.table);f.setAnchorCellForSelection(c);f.setFocusCellForSelection(b,!0);return!0}return!1}d=h.$findMatchingParent(g,r=>u.$isElementNode(r)&&!r.isInline()); | ||
C(d)&&(d=h.$findMatchingParent(d,L));if(!d)return!1;d="down"===c?d.getNextSibling():d.getPreviousSibling();if(L(d)&&f.tableNodeKey===d.getKey()){f=d.getFirstDescendant();a=d.getLastDescendant();if(!f||!a)return!1;[d]=P(f);[f]=P(a);e=e.clone();e.focus.set(("up"===c?d:f).getKey(),"up"===c?0:f.getChildrenSize(),"element");X(b);u.$setSelection(e);return!0}}}"down"===c&&Ha(a)&&f.setShouldCheckSelection();return!1}if(u.$isRangeSelection(e)&&e.isCollapsed()){let {anchor:r,focus:v}=e;g=h.$findMatchingParent(r.getNode(), | ||
C);var m=h.$findMatchingParent(v.getNode(),C);if(!C(g)||!g.is(m))return!1;m=T(g);if(m!==d&&null!=m){var p=R(m,a.getElementByKey(m.getKey()));if(null!=p)return f.table=S(m,p),W(a,b,c,m,f)}if("backward"===c||"forward"===c){f=r.type;a=r.offset;g=r.getNode();if(!g)return!1;e=e.getNodes();return 1===e.length&&u.$isDecoratorNode(e[0])?!1:Ja(f,a,g,c)?Ka(b,g,d,c):!1}e=a.getElementByKey(g.__key);m=a.getElementByKey(r.key);if(null==m||null==e)return!1;if("element"===r.type)e=m.getBoundingClientRect();else{e= | ||
window.getSelection();if(null===e||0===e.rangeCount)return!1;e=e.getRangeAt(0).getBoundingClientRect()}m="up"===c?g.getFirstChild():g.getLastChild();if(null==m)return!1;a=a.getElementByKey(m.__key);if(null==a)return!1;a=a.getBoundingClientRect();if("up"===c?a.top>e.top-e.height:e.bottom+e.height>a.bottom){X(b);e=d.getCordsFromCellNode(g,f.table);if(b.shiftKey)b=d.getDOMCellFromCordsOrThrow(e.x,e.y,f.table),f.setAnchorCellForSelection(b),f.setFocusCellForSelection(b,!0);else return Ea(f,d,e.x,e.y, | ||
c);return!0}}else if(Q(e)){let {anchor:r,focus:v}=e;p=h.$findMatchingParent(r.getNode(),C);m=h.$findMatchingParent(v.getNode(),C);[g]=e.getNodes();L(g)||E(234);a=R(g,a.getElementByKey(g.getKey()));if(!C(p)||!C(m)||!L(g)||null==a)return!1;f.updateTableTableSelection(e);e=S(g,a);a=d.getCordsFromCellNode(p,e);a=d.getDOMCellFromCordsOrThrow(a.x,a.y,e);f.setAnchorCellForSelection(a);X(b);if(b.shiftKey)return b=d.getCordsFromCellNode(m,e),Fa(f,g,b.x,b.y,c);m.selectEnd();return!0}return!1} | ||
function X(a){a.preventDefault();a.stopImmediatePropagation();a.stopPropagation()}function Ga(a){return(a=a.getRootElement())?a.hasAttribute("aria-controls")&&"typeahead-menu"===a.getAttribute("aria-controls"):!1}function Ja(a,b,c,d){return"element"===a&&("backward"===d?null===c.getPreviousSibling():null===c.getNextSibling())||La(a,b,c,d)} | ||
function La(a,b,c,d){let f=h.$findMatchingParent(c,e=>u.$isElementNode(e)&&!e.isInline());if(!f)return!1;b="backward"===d?0===b:b===c.getTextContentSize();return"text"===a&&b&&("backward"===d?null===f.getPreviousSibling():null===f.getNextSibling())} | ||
function Ka(a,b,c,d){var f=h.$findMatchingParent(b,C);if(!C(f))return!1;let [e,g]=O(c,f,f);f=e[0][0];let m=e[e.length-1][e[0].length-1],{startColumn:p,startRow:r}=g;if("backward"===d?p!==f.startColumn||r!==f.startRow:p!==m.startColumn||r!==m.startRow)return!1;b=Ma(b,d,c);if(!b||L(b))return!1;X(a);"backward"===d?b.selectEnd():b.selectStart();return!0} | ||
function Ma(a,b,c){if(a=h.$findMatchingParent(a,d=>u.$isElementNode(d)&&!d.isInline()))return(a="backward"===b?a.getPreviousSibling():a.getNextSibling())&&L(a)?a:"backward"===b?c.getPreviousSibling():c.getNextSibling()}function Na(a,b,c){let d=u.$createParagraphNode();"first"===a?b.insertBefore(d):b.insertAfter(d);d.append(...(c||[]));d.selectEnd()} | ||
function Oa(a,b,c){var d=c.getParent();if(d){var f=window.getSelection();if(f&&(f=f.anchorNode,d=a.getElementByKey(d.getKey()),a=R(c,a.getElementByKey(c.getKey())),f&&d&&a&&d.contains(f)&&!a.contains(f)&&(b=h.$findMatchingParent(b.anchor.getNode(),r=>C(r))))&&(a=h.$findMatchingParent(b,r=>L(r)),L(a)&&a.is(c))){var [e,g]=O(c,b,b);c=e[0][0];b=e[e.length-1][e[0].length-1];var {startRow:m,startColumn:p}=g;if(m===c.startRow&&p===c.startColumn)return"first";if(m===b.startRow&&p===b.startColumn)return"last"}}} | ||
function Pa(a,b,c,d){if(a=a.querySelector("colgroup")){b=[];for(let f=0;f<c;f++){let e=document.createElement("col"),g=d&&d[f];g&&(e.style.width=`${g}px`);b.push(e)}a.replaceChildren(...b)}}function Qa(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 Ra=new WeakSet;function Ha(a=u.$getEditor()){return Ra.has(a)} | ||
class Sa extends u.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 Sa(a.__key)}afterCloneFrom(a){super.afterCloneFrom(a);this.__colWidths=a.__colWidths;this.__rowStriping=a.__rowStriping}static importDOM(){return{table:()=>({conversion:Ta,priority:1})}}static importJSON(a){let b=Ua();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(231);return super.getDOMSlot(a).withAfter(a.querySelector("colgroup"))}createDOM(a,b){let c=document.createElement("table"),d=document.createElement("colgroup");c.appendChild(d);Pa(c,a,this.getColumnCount(),this.getColWidths());u.setDOMUnmanaged(d); | ||
h.addClassNamesToElement(c,a.theme.table);this.__rowStriping&&Qa(c,a,!0);return Ha(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&&Qa(b,c,this.__rowStriping);Pa(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 f=d[b];if(null!=f&&(f=f.findIndex(e=>{if(e)return{elem:e}=e,u.$getNearestNodeFromDOMNode(e)===a}),-1!==f))return{x:f,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=u.$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 Ta(a){let b=Ua();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 Ua(){return u.$applyNodeReplacement(new Sa)}function L(a){return a instanceof Sa}exports.$computeTableMap=O;exports.$computeTableMapSkipCellCheck=na;exports.$createTableCellNode=B;exports.$createTableNode=Ua; | ||
exports.$createTableNodeWithDimensions=function(a,b,c=!0){let d=Ua();for(let e=0;e<a;e++){let g=I();for(let m=0;m<b;m++){var f=y.NO_STATUS;"object"===typeof c?(0===e&&c.rows&&(f|=y.ROW),0===m&&c.columns&&(f|=y.COLUMN)):c&&(0===e&&(f|=y.ROW),0===m&&(f|=y.COLUMN));f=B(f);let p=u.$createParagraphNode();p.append(u.$createTextNode());f.append(p);g.append(f)}d.append(g)}return d};exports.$createTableRowNode=I;exports.$createTableSelection=ra; | ||
exports.$deleteTableColumn=function(a,b){let c=a.getChildren();for(let f=0;f<c.length;f++){var d=c[f];if(K(d)){d=d.getChildren();if(b>=d.length||0>b)throw Error("Table column target index out of range");d[b].remove()}}return a}; | ||
exports.$deleteTableColumn__EXPERIMENTAL=function(){var a=u.$getSelection();u.$isRangeSelection(a)||Q(a)||E(188);var b=a.anchor.getNode();a=a.focus.getNode();let [c,,d]=P(b);var [f]=P(a);let [e,g,m]=O(d,c,f);var {startColumn:p}=g;let {startRow:r,startColumn:v}=m;b=Math.min(p,v);var w=Math.max(p+c.__colSpan-1,v+f.__colSpan-1);a=w-b+1;if(e[0].length===w-b+1)d.selectPrevious(),d.remove();else{var l=e.length;for(let k=0;k<l;k++)for(let n=b;n<=w;n++){let {cell:q,startColumn:t}=e[k][n];t<b?n===b&&q.setColSpan(q.__colSpan- | ||
Math.min(a,q.__colSpan-(b-t))):t+q.__colSpan-1>w?n===w&&q.setColSpan(q.__colSpan-(w-t+1)):q.remove()}w=e[r];f=p>v?w[p+c.__colSpan]:w[v+f.__colSpan];void 0!==f?({cell:p}=f,N(p)):({cell:p}=v<p?w[v-1]:w[p-1],N(p));if(p=d.getColWidths())p=[...p],p.splice(b,a),d.setColWidths(p)}}; | ||
exports.$deleteTableRow__EXPERIMENTAL=function(){var a=u.$getSelection();u.$isRangeSelection(a)||Q(a)||E(188);let [b,c]=a.isBackward()?[a.focus.getNode(),a.anchor.getNode()]:[a.anchor.getNode(),a.focus.getNode()],[d,,f]=P(b);var [e]=P(c);let [g,m,p]=O(f,d,e);({startRow:a}=m);var {startRow:r}=p;e=r+e.__rowSpan-1;if(g.length===e-a+1)f.remove();else{r=g[0].length;var v=g[e+1],w=f.getChildAtIndex(e+1);for(let k=e;k>=a;k--){for(var l=r-1;0<=l;l--){let {cell:n,startRow:q,startColumn:t}=g[k][l];if(t===l&& | ||
(k===a&&q<a&&n.setRowSpan(n.__rowSpan-(q-a)),q>=a&&q+n.__rowSpan-1>e))if(n.setRowSpan(n.__rowSpan-(e-q+1)),null===w&&E(122),0===l)ma(w,n);else{let {cell:x}=v[l-1];x.insertAfter(n)}}l=f.getChildAtIndex(k);K(l)||E(206,String(k));l.remove()}void 0!==v?({cell:a}=v[0],N(a)):({cell:a}=g[a-1][0],N(a))}};exports.$findCellNode=V;exports.$findTableNode=T;exports.$getElementForTableNode=function(a,b){a=a.getElementByKey(b.getKey());null===a&&E(232);return S(b,a)};exports.$getNodeTriplet=P; | ||
exports.$getTableAndElementByKey=ta;exports.$getTableCellNodeFromLexicalNode=function(a){a=h.$findMatchingParent(a,b=>C(b));return C(a)?a:null};exports.$getTableCellNodeRect=oa;exports.$getTableColumnIndexFromTableCellNode=function(a){return ia(a).getChildren().findIndex(b=>b.is(a))};exports.$getTableNodeFromLexicalNodeOrThrow=ja;exports.$getTableRowIndexFromTableCellNode=function(a){let b=ia(a);return ja(b).getChildren().findIndex(c=>c.is(b))};exports.$getTableRowNodeFromTableCellNodeOrThrow=ia; | ||
exports.$insertTableColumn=function(a,b,c=!0,d,f){let e=a.getChildren(),g=[];for(let r=0;r<e.length;r++){let v=e[r];if(K(v))for(let w=0;w<d;w++){var m=v.getChildren();if(b>=m.length||0>b)throw Error("Table column target index out of range");m=m[b];C(m)||E(12);let {left:l,right:k}=ka(m,f);var p=y.NO_STATUS;if(l&&l.hasHeaderState(y.ROW)||k&&k.hasHeaderState(y.ROW))p|=y.ROW;p=B(p);p.append(u.$createParagraphNode());g.push({newTableCell:p,targetCell:m})}}g.forEach(({newTableCell:r,targetCell:v})=>{c? | ||
v.insertAfter(r):v.insertBefore(r)});return a}; | ||
exports.$insertTableColumn__EXPERIMENTAL=function(a=!0){function b(w=y.NO_STATUS){w=B(w).append(u.$createParagraphNode());null===r&&(r=w);return w}var c=u.$getSelection();u.$isRangeSelection(c)||Q(c)||E(188);var d=c.anchor.getNode();c=c.focus.getNode();[d]=P(d);let [f,,e]=P(c),[g,m,p]=O(e,f,d);d=g.length;c=a?Math.max(m.startColumn,p.startColumn):Math.min(m.startColumn,p.startColumn);a=a?c+f.__colSpan-1:c-1;c=e.getFirstChild();K(c)||E(120);let r=null;var v=c;a:for(c=0;c<d;c++){0!==c&&(v=v.getNextSibling(), | ||
K(v)||E(121));let w=g[c],l=la(w[0>a?0:a].cell.__headerState,y.ROW);if(0>a){ma(v,b(l));continue}let {cell:k,startColumn:n,startRow:q}=w[a];if(n+k.__colSpan-1<=a){let t=k,x=q,A=a;for(;x!==c&&1<t.__rowSpan;)if(A-=k.__colSpan,0<=A){let {cell:D,startRow:G}=w[A];t=D;x=G}else{v.append(b(l));continue a}t.insertAfter(b(l))}else k.setColSpan(k.__colSpan+1)}null!==r&&N(r);if(d=e.getColWidths())d=[...d],a=0>a?0:a,d.splice(a,0,d[a]),e.setColWidths(d);return r}; | ||
exports.$insertTableRow=function(a,b,c=!0,d,f){var e=a.getChildren();if(b>=e.length||0>b)throw Error("Table row target index out of range");b=e[b];if(K(b))for(e=0;e<d;e++){let m=b.getChildren(),p=m.length,r=I();for(let v=0;v<p;v++){var g=m[v];C(g)||E(12);let {above:w,below:l}=ka(g,f);g=y.NO_STATUS;let k=w&&w.getWidth()||l&&l.getWidth()||void 0;if(w&&w.hasHeaderState(y.COLUMN)||l&&l.hasHeaderState(y.COLUMN))g|=y.COLUMN;g=B(g,1,k);g.append(u.$createParagraphNode());r.append(g)}c?b.insertAfter(r):b.insertBefore(r)}else throw Error("Row before insertion index does not exist."); | ||
function ca(a){var b=a.nodeName.toLowerCase(),c=void 0;ba.test(a.style.width)&&(c=parseFloat(a.style.width));b=A("th"===b?x.ROW:x.NO_STATUS,a.colSpan,c);b.__rowSpan=a.rowSpan;c=a.style.backgroundColor;""!==c&&(b.__backgroundColor=c);a=a.style;c=(a&&a.textDecoration||"").split(" ");let d="700"===a.fontWeight||"bold"===a.fontWeight,e=c.includes("line-through"),f="italic"===a.fontStyle,g=c.includes("underline");return{after:n=>{0===n.length&&n.push(w.$createParagraphNode());return n},forChild:(n,q)=> | ||
{if(C(q)&&!w.$isElementNode(n)){q=w.$createParagraphNode();if(w.$isLineBreakNode(n)&&"\n"===n.getTextContent())return null;w.$isTextNode(n)&&(d&&n.toggleFormat("bold"),e&&n.toggleFormat("strikethrough"),f&&n.toggleFormat("italic"),g&&n.toggleFormat("underline"));q.append(n);return q}return n},node:b}}function A(a,b=1,c){return w.$applyNodeReplacement(new y(a,b,c))}function C(a){return a instanceof y}let da=w.createCommand("INSERT_TABLE_COMMAND");var E; | ||
function F(a){let b=new URLSearchParams;b.append("code",a);for(let c=1;c<arguments.length;c++)b.append("v",arguments[c]);throw Error(`Minified Lexical error #${a}; visit https://lexical.dev/docs/error?${b} for the full message or `+"use the non-minified dev environment for full errors and additional helpful warnings.");}E=F&&F.__esModule&&Object.prototype.hasOwnProperty.call(F,"default")?F["default"]:F; | ||
let ea="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement,fa=ea&&"documentMode"in document?document.documentMode:null,ha=ea&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);ea&&"InputEvent"in window&&!fa?"getTargetRanges"in new window.InputEvent("input"):!1; | ||
class ia extends w.ElementNode{static getType(){return"tablerow"}static clone(a){return new ia(a.__height,a.__key)}static importDOM(){return{tr:()=>({conversion:ja,priority:0})}}static importJSON(a){return I(a.height)}constructor(a,b){super(b);this.__height=a}exportJSON(){return{...super.exportJSON(),...(this.getHeight()&&{height:this.getHeight()}),type:"tablerow",version:1}}createDOM(a){let b=document.createElement("tr");this.__height&&(b.style.height=`${this.__height}px`);h.addClassNamesToElement(b, | ||
a.theme.tableRow);return b}isShadowRoot(){return!0}setHeight(a){this.getWritable().__height=a;return this.__height}getHeight(){return this.getLatest().__height}updateDOM(a){return a.__height!==this.__height}canBeEmpty(){return!1}canIndent(){return!1}}function ja(a){let b=void 0;ba.test(a.style.height)&&(b=parseFloat(a.style.height));return{node:I(b)}}function I(a){return w.$applyNodeReplacement(new ia(a))}function J(a){return a instanceof ia} | ||
function ka(a){a=h.$findMatchingParent(a,b=>J(b));if(J(a))return a;throw Error("Expected table cell to be inside of table row.");}function la(a){a=h.$findMatchingParent(a,b=>K(b));if(K(a))return a;throw Error("Expected table cell to be inside of table.");}function ma(a,b){let c=la(a),{x:d,y:e}=c.getCordsFromCellNode(a,b);return{above:c.getCellNodeFromCords(d,e-1,b),below:c.getCellNodeFromCords(d,e+1,b),left:c.getCellNodeFromCords(d-1,e,b),right:c.getCellNodeFromCords(d+1,e,b)}} | ||
let na=(a,b)=>a===x.BOTH||a===b?b:x.NO_STATUS;function M(a){let b=a.getFirstDescendant();null==b?a.selectStart():b.getParentOrThrow().selectStart()}function oa(a,b){let c=a.getFirstChild();null!==c?c.insertBefore(b):a.append(b)}function N(a,b,c){let [d,e,f]=pa(a,b,c);null===e&&E(207);null===f&&E(208);return[d,e,f]} | ||
function pa(a,b,c){function d(q){let r=e[q];void 0===r&&(e[q]=r=[]);return r}let e=[],f=null,g=null;a=a.getChildren();for(let q=0;q<a.length;q++){var n=a[q];J(n)||E(209);for(let r=n.getFirstChild(),l=0;null!=r;r=r.getNextSibling()){C(r)||E(147);for(n=d(q);void 0!==n[l];)l++;n={cell:r,startColumn:l,startRow:q};let {__rowSpan:k,__colSpan:m}=r;for(let p=0;p<k&&!(q+p>=a.length);p++){let u=d(q+p);for(let t=0;t<m;t++)u[l+t]=n}null!==b&&null===f&&b.is(r)&&(f=n);null!==c&&null===g&&c.is(r)&&(g=n)}}return[e, | ||
f,g]}function P(a){a instanceof y||("__type"in a?(a=h.$findMatchingParent(a,C),C(a)||E(148)):(a=h.$findMatchingParent(a.getNode(),C),C(a)||E(148)));let b=a.getParent();J(b)||E(149);let c=b.getParent();K(c)||E(210);return[a,b,c]} | ||
function qa(a,b,c){function d(m){let {cell:p,startColumn:u,startRow:t}=m;e=Math.min(e,u);f=Math.min(f,t);g=Math.max(g,u+p.__colSpan-1);n=Math.max(n,t+p.__rowSpan-1)}let e=Math.min(b.startColumn,c.startColumn),f=Math.min(b.startRow,c.startRow),g=Math.max(b.startColumn+b.cell.__colSpan-1,c.startColumn+c.cell.__colSpan-1),n=Math.max(b.startRow+b.cell.__rowSpan-1,c.startRow+c.cell.__rowSpan-1);b=e;c=f;for(var q=e,r=f;e<b||f<c||g>q||n>r;){if(e<b){var l=r-c;--b;for(var k=0;k<=l;k++)d(a[c+k][b])}if(f<c)for(l= | ||
q-b,--c,k=0;k<=l;k++)d(a[c][b+k]);if(g>q)for(l=r-c,q+=1,k=0;k<=l;k++)d(a[c+k][q]);if(n>r)for(l=q-b,r+=1,k=0;k<=l;k++)d(a[r][b+k])}return{maxColumn:g,maxRow:n,minColumn:e,minRow:f}} | ||
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(231,r,l.getKey(),l.getType());const m=k.getParent();J(m)||E(232,r);const p=m.getParent();K(p)||E(233,r);return[l,k,m,p]});e.is(q)||E(234);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=== | ||
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= | ||
0;this.getNodes().filter(C).forEach(c=>{c=c.getFirstChild();w.$isParagraphNode(c)&&(b|=c.getTextFormat())});return 0!==(b&w.TEXT_TYPE_TO_FORMAT[a])}insertNodes(a){let b=this.focus.getNode();w.$isElementNode(b)||E(151);w.$normalizeSelection__EXPERIMENTAL(b.select(0,b.getChildrenSize())).insertNodes(a)}getShape(){let {anchorCell:a,focusCell:b}=sa(this);var c=ra(a);null===c&&E(153);let d=ra(b);null===d&&E(155);let e=Math.min(c.columnIndex,d.columnIndex),f=Math.max(c.columnIndex+c.colSpan-1,d.columnIndex+ | ||
d.colSpan-1),g=Math.min(c.rowIndex,d.rowIndex);c=Math.max(c.rowIndex+c.rowSpan-1,d.rowIndex+d.rowSpan-1);return{fromX:Math.min(e,f),fromY:Math.min(g,c),toX:Math.max(e,f),toY:Math.max(g,c)}}getNodes(){if(!this.isValid())return[];var a=this._cachedNodes;if(null!==a)return a;let {anchorTable:b,anchorCell:c,focusCell:d}=sa(this);a=d.getParents()[1];if(a!==b)return b.isParentOf(d)?(a=a.getParent(),null==a&&E(159),this.set(this.tableKey,d.getKey(),a.getKey())):(a=b.getParent(),null==a&&E(158),this.set(this.tableKey, | ||
a.getKey(),d.getKey())),this.getNodes();let [e,f,g]=N(b,c,d),{minColumn:n,maxColumn:q,minRow:r,maxRow:l}=qa(e,f,g),k=new Map([[b.getKey(),b]]);a=null;for(let m=r;m<=l;m++)for(let p=n;p<=q;p++){let {cell:u}=e[m][p],t=u.getParent();J(t)||E(160);t!==a&&(k.set(t.getKey(),t),a=t);k.has(u.getKey())||ua(u,v=>{k.set(v.getKey(),v)})}a=Array.from(k.values());w.isCurrentlyReadOnlyMode()||(this._cachedNodes=a);return a}getTextContent(){let a=this.getNodes().filter(c=>C(c)),b="";for(let c=0;c<a.length;c++){let d= | ||
a[c],e=d.__parent,f=(a[c+1]||{}).__parent;b+=d.getTextContent()+(f!==e?"\n":"\t")}return b}}function Q(a){return a instanceof 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}} | ||
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= | ||
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}= | ||
this.$lookup();this.table=S(d,e)}},{editor:this.editor})});this.editor.getEditorState().read(()=>{let {tableNode:b,tableElement:c}=this.$lookup();this.table=S(b,c);a.observe(c,{attributes:!0,childList:!0,subtree:!0})},{editor:this.editor})}$clearHighlight(){let a=this.editor;this.isHighlightingCells=!1;this.focusY=this.focusX=this.anchorY=this.anchorX=-1;this.focusCell=this.anchorCell=this.focusCellNodeKey=this.anchorCellNodeKey=this.tableSelection=null;this.hasHijackedSelectionStyles=!1;this.$enableHighlightStyle(); | ||
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= | ||
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"); | ||
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=> | ||
{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} | ||
let Aa=[[w.KEY_ARROW_DOWN_COMMAND,"down"],[w.KEY_ARROW_UP_COMMAND,"up"],[w.KEY_ARROW_LEFT_COMMAND,"backward"],[w.KEY_ARROW_RIGHT_COMMAND,"forward"]],Ba=[w.DELETE_WORD_COMMAND,w.DELETE_LINE_COMMAND,w.DELETE_CHARACTER_COMMAND],Ca=[w.KEY_BACKSPACE_COMMAND,w.KEY_DELETE_COMMAND];function Da(a,b){null!==Ea(a)&&E(205);a.__lexicalTableSelection=b}function Ea(a){return a.__lexicalTableSelection||null} | ||
function Fa(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 S(a,b){var c=R(a,b);a=[];b={columns:0,domRows:a,rows:0};var d=c.querySelector("tr");let e=c=0;for(a.length=0;null!=d;){var f=d.nodeName;if("TD"===f||"TH"===f){f=d;f={elem:f,hasBackgroundColor:""!==f.style.backgroundColor,highlighted:!1,x:c,y:e};d._cell=f;let g=a[e];void 0===g&&(g=a[e]=[]);g[c]=f}else if(f=d.firstChild,null!=f){d=f;continue}f=d.nextSibling;if(null!=f)c++,d=f;else if(f=d.parentNode,null!=f){d=f.nextSibling;if(null==d)break;e++;c=0}}b.columns=c+1;b.rows=e+1;return b} | ||
function ya(a,b,c){let d=new Set(c?c.getNodes():[]);Ga(b,(e,f)=>{let g=e.elem;d.has(f)?(e.highlighted=!0,Ha(a,e)):(e.highlighted=!1,Ia(a,e),g.getAttribute("style")||g.removeAttribute("style"))})}function Ga(a,b){({domRows:a}=a);for(let c=0;c<a.length;c++){let d=a[c];if(d)for(let e=0;e<d.length;e++){let f=d[e];if(!f)continue;let g=w.$getNearestNodeFromDOMNode(f.elem);null!==g&&b(f,g,{x:e,y:c})}}}function Ja(a,b){b.$disableHighlightStyle();Ga(b.table,c=>{c.highlighted=!0;Ha(a,c)})} | ||
function Ka(a,b){b.$enableHighlightStyle();Ga(b.table,c=>{let d=c.elem;c.highlighted=!1;Ia(a,c);d.getAttribute("style")||d.removeAttribute("style")})} | ||
let La=(a,b,c,d,e)=>{const f="forward"===e;switch(e){case "backward":case "forward":return c!==(f?a.table.columns-1:0)?(a=b.getCellNodeFromCordsOrThrow(c+(f?1:-1),d,a.table),f?a.selectStart():a.selectEnd()):d!==(f?a.table.rows-1:0)?(a=b.getCellNodeFromCordsOrThrow(f?0:a.table.columns-1,d+(f?1:-1),a.table),f?a.selectStart():a.selectEnd()):f?b.selectNext():b.selectPrevious(),!0;case "up":return 0!==d?b.getCellNodeFromCordsOrThrow(c,d-1,a.table).selectEnd():b.selectPrevious(),!0;case "down":return d!== | ||
a.table.rows-1?b.getCellNodeFromCordsOrThrow(c,d+1,a.table).selectStart():b.selectNext(),!0;default:return!1}};function Ma(a,b){let c;if(b.startColumn===a.minColumn)c="minColumn";else if(b.startColumn+b.cell.__colSpan-1===a.maxColumn)c="maxColumn";else return null;if(b.startRow===a.minRow)a="minRow";else if(b.startRow+b.cell.__rowSpan-1===a.maxRow)a="maxRow";else return null;return[c,a]}function Oa([a,b]){return["minColumn"===a?"maxColumn":"minColumn","minRow"===b?"maxRow":"minRow"]} | ||
function U(a,b,[c,d]){let e=b[d];a=a[e];void 0===a&&E(248,d,String(e));b=b[c];d=a[b];void 0===d&&E(248,c,String(b));return d} | ||
function Pa(a,b,c,d,e){d=qa(b,c,d);let {minColumn:f,maxColumn:g,minRow:n,maxRow:q}=d;var r=1;let l=1,k=1,m=1;var p=b[n];let u=b[q];for(let O=f;O<=g;O++)r=Math.max(r,p[O].cell.__rowSpan),m=Math.max(m,u[O].cell.__rowSpan);for(p=n;p<=q;p++)l=Math.max(l,b[p][f].cell.__colSpan),k=Math.max(k,b[p][g].cell.__colSpan);let {topSpan:t,leftSpan:v,bottomSpan:B,rightSpan:z}={bottomSpan:m,leftSpan:l,rightSpan:k,topSpan:r};r=Ma(d,c);null===r&&E(247,c.cell.getKey());let [D,G]=Oa(r);r=d[D];d=d[G];"forward"===e?r+= | ||
"maxColumn"===D?1:v:"backward"===e?r-="minColumn"===D?1:z:"down"===e?d+="maxRow"===G?1:t:"up"===e&&(d-="minRow"===G?1:B);e=b[d];if(void 0===e)return!1;d=e[r];if(void 0===d)return!1;e=qa(b,c,d);(c=Ma(e,c))?b=[U(b,e,c),U(b,e,Oa(c))]:(c=Ma(e,d))?b=[U(b,e,Oa(c)),U(b,e,c)]:(c=["minColumn","minRow"],b=[U(b,e,c),U(b,e,Oa(c))]);let [H,L]=b;b=V(a,H.cell);c=V(a,L.cell);a.$setAnchorCellForSelection(b);a.$setFocusCellForSelection(c,!0);return!0} | ||
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(229);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")); | ||
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; | ||
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}; | ||
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- | ||
Math.min(a,t.__colSpan-(b-v))):v+t.__colSpan-1>k?u===k&&t.setColSpan(t.__colSpan-(k-v+1)):t.remove()}k=f[r];e=q>l?k[q+c.__colSpan]:k[l+e.__colSpan];void 0!==e?({cell:q}=e,M(q)):({cell:q}=l<q?k[l-1]:k[q-1],M(q));if(q=d.getColWidths())q=[...q],q.splice(b,a),d.setColWidths(q)}}; | ||
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(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; | ||
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? | ||
l.insertAfter(r):l.insertBefore(r)});return a}; | ||
exports.$insertTableColumn__EXPERIMENTAL=function(a=!0){function b(k=x.NO_STATUS){k=A(k).append(w.$createParagraphNode());null===r&&(r=k);return k}var c=w.$getSelection();w.$isRangeSelection(c)||Q(c)||E(188);var d=c.anchor.getNode();c=c.focus.getNode();[d]=P(d);let [e,,f]=P(c),[g,n,q]=N(f,e,d);d=g.length;c=a?Math.max(n.startColumn,q.startColumn):Math.min(n.startColumn,q.startColumn);a=a?c+e.__colSpan-1:c-1;c=f.getFirstChild();J(c)||E(120);let r=null;var l=c;a:for(c=0;c<d;c++){0!==c&&(l=l.getNextSibling(), | ||
J(l)||E(121));let k=g[c],m=na(k[0>a?0:a].cell.__headerState,x.ROW);if(0>a){oa(l,b(m));continue}let {cell:p,startColumn:u,startRow:t}=k[a];if(u+p.__colSpan-1<=a){let v=p,B=t,z=a;for(;B!==c&&1<v.__rowSpan;)if(z-=p.__colSpan,0<=z){let {cell:D,startRow:G}=k[z];v=D;B=G}else{l.append(b(m));continue a}v.insertAfter(b(m))}else p.setColSpan(p.__colSpan+1)}null!==r&&M(r);if(d=f.getColWidths())d=[...d],a=0>a?0:a,d.splice(a,0,d[a]),f.setColWidths(d);return r}; | ||
exports.$insertTableRow=function(a,b,c=!0,d,e){var f=a.getChildren();if(b>=f.length||0>b)throw Error("Table row target index out of range");b=f[b];if(J(b))for(f=0;f<d;f++){let n=b.getChildren(),q=n.length,r=I();for(let l=0;l<q;l++){var g=n[l];C(g)||E(12);let {above:k,below:m}=ma(g,e);g=x.NO_STATUS;let p=k&&k.getWidth()||m&&m.getWidth()||void 0;if(k&&k.hasHeaderState(x.COLUMN)||m&&m.hasHeaderState(x.COLUMN))g|=x.COLUMN;g=A(g,1,p);g.append(w.$createParagraphNode());r.append(g)}c?b.insertAfter(r):b.insertBefore(r)}else throw Error("Row before insertion index does not exist."); | ||
return a}; | ||
exports.$insertTableRow__EXPERIMENTAL=function(a=!0){var b=u.$getSelection();u.$isRangeSelection(b)||Q(b)||E(188);b=b.focus.getNode();let [c,,d]=P(b),[f,e]=O(d,c,c);b=f[0].length;var {startRow:g}=e;if(a){a=g+c.__rowSpan-1;var m=f[a];g=I();for(var p=0;p<b;p++){let {cell:v,startRow:w}=m[p];if(w+v.__rowSpan-1<=a){var r=la(m[p].cell.__headerState,y.COLUMN);g.append(B(r).append(u.$createParagraphNode()))}else v.setRowSpan(v.__rowSpan+1)}b=d.getChildAtIndex(a);K(b)||E(145);b.insertAfter(g);b=g}else{m=f[g]; | ||
a=I();for(p=0;p<b;p++){let {cell:v,startRow:w}=m[p];w===g?(r=la(m[p].cell.__headerState,y.COLUMN),a.append(B(r).append(u.$createParagraphNode()))):v.setRowSpan(v.__rowSpan+1)}b=d.getChildAtIndex(g);K(b)||E(145);b.insertBefore(a);b=a}return b};exports.$isScrollableTablesActive=Ha;exports.$isTableCellNode=C;exports.$isTableNode=L;exports.$isTableRowNode=K;exports.$isTableSelection=Q; | ||
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; | ||
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=u.$getSelection();u.$isRangeSelection(a)||Q(a)||E(188);a=a.anchor.getNode();let [b,c,d]=P(a);a=b.__colSpan;let f=b.__rowSpan;if(1!==a||1!==f){var [e,g]=O(d,b,b),{startColumn:m,startRow:p}=g,r=b.__headerState&y.COLUMN,v=Array.from({length:a},(t,x)=>{t=r;for(let A=0;0!==t&&A<e.length;A++)t&=e[A][x+m].cell.__headerState;return t}),w=b.__headerState&y.ROW,l=Array.from({length:f},(t,x)=>{t=w;for(let A=0;0!==t&&A<e[0].length;A++)t&=e[x+p][A].cell.__headerState;return t}); | ||
if(1<a){for(var k=1;k<a;k++)b.insertAfter(B(v[k]|l[0]).append(u.$createParagraphNode()));b.setColSpan(1)}if(1<f){let t;for(k=1;k<f;k++){var n=p+k;let x=e[n];t=(t||c).getNextSibling();K(t)||E(125);var q=null;for(let A=0;A<m;A++){let D=x[A],G=D.cell;D.startRow===n&&(q=G);1<G.__colSpan&&(A+=G.__colSpan-1)}if(null===q)for(q=a-1;0<=q;q--)ma(t,B(v[q]|l[k]).append(u.$createParagraphNode()));else for(n=a-1;0<=n;n--)q.insertAfter(B(v[n]|l[k]).append(u.$createParagraphNode()))}b.setRowSpan(1)}}}; | ||
exports.INSERT_TABLE_COMMAND=da;exports.TableCellHeaderStates=y;exports.TableCellNode=z;exports.TableNode=Sa;exports.TableObserver=ua;exports.TableRowNode=fa; | ||
exports.applyTableHandlers=function(a,b,c,d){function f(l){l=a.getCordsFromCellNode(l,g.table);return a.getDOMCellFromCordsOrThrow(l.x,l.y,g.table)}let e=c.getRootElement();if(null===e)throw Error("No root element.");let g=new ua(c,a.getKey()),m=c._window||window,p=R(a,b);wa(p,g);g.listenersToRemove.add(()=>{var l=g;xa(p)===l&&delete p.__lexicalTableSelection});let r=()=>{const l=()=>{g.isSelecting=!1;m.removeEventListener("mouseup",l);m.removeEventListener("mousemove",k)},k=n=>{setTimeout(()=>{if(1!== | ||
(n.buttons&1)&&g.isSelecting)g.isSelecting=!1,m.removeEventListener("mouseup",l),m.removeEventListener("mousemove",k);else{var q=ya(n.target);null===q||g.anchorX===q.x&&g.anchorY===q.y||(n.preventDefault(),g.setFocusCellForSelection(q))}},0)};return{onMouseMove:k,onMouseUp:l}};p.addEventListener("mousedown",l=>{setTimeout(()=>{if(0===l.button&&m){var k=ya(l.target);null!==k&&(X(l),g.setAnchorCellForSelection(k));var {onMouseUp:n,onMouseMove:q}=r();g.isSelecting=!0;m.addEventListener("mouseup",n,g.listenerOptions); | ||
m.addEventListener("mousemove",q,g.listenerOptions)}},0)},g.listenerOptions);m.addEventListener("mousedown",l=>{0===l.button&&c.update(()=>{const k=u.$getSelection(),n=l.target;Q(k)&&k.tableKey===g.tableNodeKey&&e.contains(n)&&g.clearHighlight()})},g.listenerOptions);g.listenersToRemove.add(c.registerCommand(u.KEY_ARROW_DOWN_COMMAND,l=>W(c,l,"down",a,g),u.COMMAND_PRIORITY_HIGH));g.listenersToRemove.add(c.registerCommand(u.KEY_ARROW_UP_COMMAND,l=>W(c,l,"up",a,g),u.COMMAND_PRIORITY_HIGH));g.listenersToRemove.add(c.registerCommand(u.KEY_ARROW_LEFT_COMMAND, | ||
l=>W(c,l,"backward",a,g),u.COMMAND_PRIORITY_HIGH));g.listenersToRemove.add(c.registerCommand(u.KEY_ARROW_RIGHT_COMMAND,l=>W(c,l,"forward",a,g),u.COMMAND_PRIORITY_HIGH));g.listenersToRemove.add(c.registerCommand(u.KEY_ESCAPE_COMMAND,l=>{var k=u.$getSelection();return Q(k)&&(k=h.$findMatchingParent(k.focus.getNode(),C),C(k))?(X(l),k.selectEnd(),!0):!1},u.COMMAND_PRIORITY_HIGH));let v=l=>()=>{var k=u.$getSelection();if(!U(k,a))return!1;if(Q(k))return g.clearText(),!0;if(u.$isRangeSelection(k)){var n= | ||
h.$findMatchingParent(k.anchor.getNode(),t=>C(t));if(!C(n))return!1;var q=k.anchor.getNode();n=k.focus.getNode();q=a.isParentOf(q);n=a.isParentOf(n);if(q&&!n||n&&!q)return g.clearText(),!0;n=(k=h.$findMatchingParent(k.anchor.getNode(),t=>u.$isElementNode(t)))&&h.$findMatchingParent(k,t=>u.$isElementNode(t)&&C(t.getParent()));if(!u.$isElementNode(n)||!u.$isElementNode(k))return!1;if(l===u.DELETE_LINE_COMMAND&&null===n.getPreviousSibling())return!0}return!1};[u.DELETE_WORD_COMMAND,u.DELETE_LINE_COMMAND, | ||
u.DELETE_CHARACTER_COMMAND].forEach(l=>{g.listenersToRemove.add(c.registerCommand(l,v(l),u.COMMAND_PRIORITY_CRITICAL))});let w=l=>{const k=u.$getSelection();if(!Q(k)&&!u.$isRangeSelection(k))return!1;const n=a.isParentOf(k.anchor.getNode()),q=a.isParentOf(k.focus.getNode());if(n!==q){l=n?"focus":"anchor";const {key:t,offset:x,type:A}=k[l];a[k[n?"anchor":"focus"].isBefore(k[l])?"selectPrevious":"selectNext"]()[l].set(t,x,A);return!1}return Q(k)?(l&&(l.preventDefault(),l.stopPropagation()),g.clearText(), | ||
!0):!1};g.listenersToRemove.add(c.registerCommand(u.KEY_BACKSPACE_COMMAND,w,u.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(u.KEY_DELETE_COMMAND,w,u.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(u.CUT_COMMAND,l=>{let k=u.$getSelection();if(k){if(!Q(k)&&!u.$isRangeSelection(k))return!1;void aa.copyToClipboard(c,h.objectKlassEquals(l,ClipboardEvent)?l:null,aa.$getClipboardDataFromSelection(k));l=w(l);return u.$isRangeSelection(k)?(k.removeText(),!0):l}return!1}, | ||
u.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(u.FORMAT_TEXT_COMMAND,l=>{let k=u.$getSelection();if(!U(k,a))return!1;if(Q(k))return g.formatCells(l),!0;u.$isRangeSelection(k)&&(l=h.$findMatchingParent(k.anchor.getNode(),n=>C(n)),C(l));return!1},u.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(u.FORMAT_ELEMENT_COMMAND,l=>{var k=u.$getSelection();if(!Q(k)||!U(k,a))return!1;var n=k.anchor.getNode();k=k.focus.getNode();if(!C(n)||!C(k))return!1;let [q,t, | ||
x]=O(a,n,k);n=Math.max(t.startRow,x.startRow);k=Math.max(t.startColumn,x.startColumn);var A=Math.min(t.startRow,x.startRow);let D=Math.min(t.startColumn,x.startColumn);for(;A<=n;A++)for(let J=D;J<=k;J++){var G=q[A][J].cell;G.setFormat(l);G=G.getChildren();for(let M=0;M<G.length;M++){let H=G[M];u.$isElementNode(H)&&!H.isInline()&&H.setFormat(l)}}return!0},u.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(u.CONTROLLED_TEXT_INSERTION_COMMAND,l=>{var k=u.$getSelection();if(!U(k, | ||
a))return!1;if(Q(k))g.clearHighlight();else if(u.$isRangeSelection(k)){let n=h.$findMatchingParent(k.anchor.getNode(),q=>C(q));if(!C(n))return!1;if("string"===typeof l&&(k=Oa(c,k,a)))return Na(k,a,[u.$createTextNode(l)]),!0}return!1},u.COMMAND_PRIORITY_CRITICAL));d&&g.listenersToRemove.add(c.registerCommand(u.KEY_TAB_COMMAND,l=>{var k=u.$getSelection();if(!u.$isRangeSelection(k)||!k.isCollapsed()||!U(k,a))return!1;k=V(k.anchor.getNode());if(null===k)return!1;X(l);k=a.getCordsFromCellNode(k,g.table); | ||
Ea(g,a,k.x,k.y,l.shiftKey?"backward":"forward");return!0},u.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(u.FOCUS_COMMAND,()=>a.isSelected(),u.COMMAND_PRIORITY_HIGH));g.listenersToRemove.add(c.registerCommand(u.SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,l=>{let {nodes:k,selection:n}=l;l=n.getStartEndPoints();var q=Q(n);q=u.$isRangeSelection(n)&&null!==h.$findMatchingParent(n.anchor.getNode(),H=>C(H))&&null!==h.$findMatchingParent(n.focus.getNode(),H=>C(H))||q;if(1!==k.length|| | ||
!L(k[0])||!q||null===l)return!1;var [t]=l,x=k[0];l=x.getChildren();q=x.getFirstChildOrThrow().getChildrenSize();x=x.getChildrenSize();var A=h.$findMatchingParent(t.getNode(),H=>C(H)),D=A&&h.$findMatchingParent(A,H=>K(H)),G=D&&h.$findMatchingParent(D,H=>L(H));if(!C(A)||!K(D)||!L(G))return!1;t=D.getIndexWithinParent();var J=Math.min(G.getChildrenSize()-1,t+x-1);x=A.getIndexWithinParent();A=Math.min(D.getChildrenSize()-1,x+q-1);q=Math.min(x,A);D=Math.min(t,J);x=Math.max(x,A);t=Math.max(t,J);G=G.getChildren(); | ||
for(J=0;D<=t;D++){A=G[D];if(!K(A))return!1;var M=l[J];if(!K(M))return!1;A=A.getChildren();M=M.getChildren();let H=0;for(let Y=q;Y<=x;Y++){let sa=A[Y];if(!C(sa))return!1;let Ia=M[H];if(!C(Ia))return!1;let Va=sa.getChildren();Ia.getChildren().forEach(Z=>{u.$isTextNode(Z)&&u.$createParagraphNode().append(Z);sa.append(Z)});Va.forEach(Z=>Z.remove());H++}J++}return!0},u.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(u.SELECTION_CHANGE_COMMAND,()=>{let l=u.$getSelection(),k=u.$getPreviousSelection(); | ||
if(g.getAndClearShouldCheckSelection()&&u.$isRangeSelection(k)&&u.$isRangeSelection(l)&&l.isCollapsed()){var n=l.anchor.getNode(),q=a.getFirstChild();n=V(n);if(null!==n&&K(q)){let A=q.getFirstChild();if(C(A)&&a.is(h.$findMatchingParent(n,D=>D.is(a)||D.is(A))))return A.selectStart(),!0}}if(u.$isRangeSelection(l)){let {anchor:A,focus:D}=l;n=A.getNode();q=D.getNode();var t=V(n),x=V(q);let G=!(!t||!a.is(T(t))),J=!(!x||!a.is(T(x)));n=G!==J;let M=G&&J;q=l.isBackward();n?(n=l.clone(),J?([x]=O(a,x,x),t=x[0][0].cell, | ||
x=x[x.length-1].at(-1).cell,n.focus.set(q?t.getKey():x.getKey(),q?t.getChildrenSize():x.getChildrenSize(),"element")):G&&([x]=O(a,t,t),t=x[0][0].cell,x=x[x.length-1].at(-1).cell,n.anchor.set(q?x.getKey():t.getKey(),q?x.getChildrenSize():0,"element")),u.$setSelection(n),Ca(c,g)):M&&!t.is(x)&&(g.setAnchorCellForSelection(f(t)),g.setFocusCellForSelection(f(x),!0),g.isSelecting||setTimeout(()=>{let {onMouseUp:H,onMouseMove:Y}=r();g.isSelecting=!0;m.addEventListener("mouseup",H);m.addEventListener("mousemove", | ||
Y)},0))}else l&&Q(l)&&l.is(k)&&l.tableKey===a.getKey()&&(q=ea?(c._window||window).getSelection():null)&&q.anchorNode&&q.focusNode&&(n=(n=u.$getNearestNodeFromDOMNode(q.focusNode))&&!a.is(T(n)),t=(t=u.$getNearestNodeFromDOMNode(q.anchorNode))&&a.is(T(t)),n&&t&&0<q.rangeCount&&(n=u.$createRangeSelectionFromDom(q,c)))&&(n.anchor.set(a.getKey(),l.isBackward()?a.getChildrenSize():0,"element"),q.removeAllRanges(),u.$setSelection(n));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()?Da(c,g):!g.hasHijackedSelectionStyles&&a.isSelected()&&Ca(c,g);return!1},u.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(u.INSERT_PARAGRAPH_COMMAND,()=>{var l=u.$getSelection();return u.$isRangeSelection(l)&&l.isCollapsed()&&U(l,a)?(l=Oa(c,l,a))?(Na(l,a),!0):!1:!1},u.COMMAND_PRIORITY_CRITICAL)); | ||
return g};exports.getDOMCellFromTarget=ya;exports.getTableElement=R;exports.getTableObserverFromTableElement=xa;exports.setScrollableTablesActive=function(a,b){b?Ra.add(a):Ra.delete(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.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= | ||
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), | ||
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)); | ||
g.listenersToRemove.add(c.registerCommand(w.CUT_COMMAND,l=>{let k=w.$getSelection();if(k){if(!Q(k)&&!w.$isRangeSelection(k))return!1;void aa.copyToClipboard(c,h.objectKlassEquals(l,ClipboardEvent)?l:null,aa.$getClipboardDataFromSelection(k));l=r(l);return w.$isRangeSelection(k)?(k.removeText(),!0):l}return!1},w.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(w.FORMAT_TEXT_COMMAND,l=>{let k=w.$getSelection();if(!W(k,a))return!1;if(Q(k))return g.$formatCells(l),!0;w.$isRangeSelection(k)&& | ||
(l=h.$findMatchingParent(k.anchor.getNode(),m=>C(m)),C(l));return!1},w.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(w.FORMAT_ELEMENT_COMMAND,l=>{var k=w.$getSelection();if(!Q(k)||!W(k,a))return!1;var m=k.anchor.getNode();k=k.focus.getNode();if(!C(m)||!C(k))return!1;let [p,u,t]=N(a,m,k);m=Math.max(u.startRow+u.cell.__rowSpan-1,t.startRow+t.cell.__rowSpan-1);k=Math.max(u.startColumn+u.cell.__colSpan-1,t.startColumn+t.cell.__colSpan-1);var v=Math.min(u.startRow,t.startRow);let B= | ||
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, | ||
()=>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); | ||
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)} |
@@ -42,3 +42,3 @@ /** | ||
constructor(headerState?: number, colSpan?: number, width?: number, key?: NodeKey); | ||
createDOM(config: EditorConfig): HTMLElement; | ||
createDOM(config: EditorConfig): HTMLTableCellElement; | ||
exportDOM(editor: LexicalEditor): DOMExportOutput; | ||
@@ -50,3 +50,3 @@ exportJSON(): SerializedTableCellNode; | ||
setRowSpan(rowSpan: number): this; | ||
getTag(): string; | ||
getTag(): 'th' | 'td'; | ||
setHeaderStyles(headerState: TableCellHeaderState, mask?: TableCellHeaderState): this; | ||
@@ -53,0 +53,0 @@ getHeaderStyles(): TableCellHeaderState; |
@@ -9,2 +9,3 @@ /** | ||
import type { LexicalEditor, NodeKey, TextFormatType } from 'lexical'; | ||
import { TableCellNode } from './LexicalTableCellNode'; | ||
import { TableNode } from './LexicalTableNode'; | ||
@@ -52,2 +53,6 @@ import { type TableSelection } from './LexicalTableSelection'; | ||
}; | ||
nextFocus: { | ||
focusCell: TableDOMCell; | ||
override: boolean; | ||
} | null; | ||
constructor(editor: LexicalEditor, tableNodeKey: string); | ||
@@ -61,6 +66,6 @@ getTable(): TableDOMTable; | ||
trackTable(): void; | ||
clearHighlight(): void; | ||
enableHighlightStyle(): void; | ||
disableHighlightStyle(): void; | ||
updateTableTableSelection(selection: TableSelection | null): void; | ||
$clearHighlight(): void; | ||
$enableHighlightStyle(): void; | ||
$disableHighlightStyle(): void; | ||
$updateTableTableSelection(selection: TableSelection | null): void; | ||
/** | ||
@@ -80,6 +85,28 @@ * @internal | ||
getAndClearShouldCheckSelection(): boolean; | ||
setFocusCellForSelection(cell: TableDOMCell, ignoreStart?: boolean): void; | ||
setAnchorCellForSelection(cell: TableDOMCell): void; | ||
formatCells(type: TextFormatType): void; | ||
clearText(): void; | ||
/** | ||
* @internal | ||
* When handling mousemove events we track what the focus cell should be, but | ||
* the DOM selection may end up somewhere else entirely. We don't have an elegant | ||
* way to handle this after the DOM selection has been resolved in a | ||
* SELECTION_CHANGE_COMMAND callback. | ||
*/ | ||
setNextFocus(nextFocus: null | { | ||
focusCell: TableDOMCell; | ||
override: boolean; | ||
}): void; | ||
/** @internal */ | ||
getAndClearNextFocus(): { | ||
focusCell: TableDOMCell; | ||
override: boolean; | ||
} | null; | ||
/** @internal */ | ||
updateDOMSelection(): void; | ||
$setFocusCellForSelection(cell: TableDOMCell, ignoreStart?: boolean): boolean; | ||
$getAnchorTableCell(): TableCellNode | null; | ||
$getAnchorTableCellOrThrow(): TableCellNode; | ||
$getFocusTableCell(): TableCellNode | null; | ||
$getFocusTableCellOrThrow(): TableCellNode; | ||
$setAnchorCellForSelection(cell: TableDOMCell): void; | ||
$formatCells(type: TextFormatType): void; | ||
$clearText(): void; | ||
} |
@@ -10,2 +10,3 @@ /** | ||
import { TableCellNode } from './LexicalTableCellNode'; | ||
import { TableNode } from './LexicalTableNode'; | ||
export type TableSelectionShape = { | ||
@@ -32,2 +33,10 @@ fromX: number; | ||
/** | ||
* {@link $createTableSelection} unfortunately makes it very easy to create | ||
* nonsense selections, so we have a method to see if the selection probably | ||
* makes sense. | ||
* | ||
* @returns true if the TableSelection is (probably) valid | ||
*/ | ||
isValid(): boolean; | ||
/** | ||
* Returns whether the Selection is "backwards", meaning the focus | ||
@@ -62,2 +71,8 @@ * logically precedes the anchor in the EditorState. | ||
export declare function $createTableSelection(): TableSelection; | ||
export declare function $getChildrenRecursively(node: LexicalNode): Array<LexicalNode>; | ||
export declare function $createTableSelectionFrom(tableNode: TableNode, anchorCell: TableCellNode, focusCell: TableCellNode): TableSelection; | ||
/** | ||
* Depth first visitor | ||
* @param node The starting node | ||
* @param $visit The function to call for each node. If the function returns false, then children of this node will not be explored | ||
*/ | ||
export declare function $visitRecursively(node: LexicalNode, $visit: (childNode: LexicalNode) => boolean | undefined | void): void; |
@@ -15,4 +15,5 @@ /** | ||
declare const LEXICAL_ELEMENT_KEY = "__lexicalTableSelection"; | ||
export declare const getDOMSelection: (targetWindow: Window | null) => Selection | null; | ||
export declare function getTableElement<T extends HTMLElement | null>(tableNode: TableNode, dom: T): HTMLTableElementWithWithTableSelectionState | (T & null); | ||
export declare function getEditorWindow(editor: LexicalEditor): Window | null; | ||
export declare function $findParentTableCellNodeInTable(tableNode: LexicalNode, node: LexicalNode | null): TableCellNode | null; | ||
export declare function applyTableHandlers(tableNode: TableNode, element: HTMLElement, editor: LexicalEditor, hasTabHandler: boolean): TableObserver; | ||
@@ -37,2 +38,3 @@ export type HTMLTableElementWithWithTableSelectionState = HTMLTableElement & { | ||
export declare function $findTableNode(node: LexicalNode): null | TableNode; | ||
export declare function $getObserverCellFromCellNodeOrThrow(tableObserver: TableObserver, tableCellNode: TableCellNode): TableDOMCell; | ||
export {}; |
@@ -48,5 +48,23 @@ /** | ||
export declare function $unmergeCell(): void; | ||
export declare function $computeTableMap(grid: TableNode, cellA: TableCellNode, cellB: TableCellNode): [TableMapType, TableMapValueType, TableMapValueType]; | ||
export declare function $computeTableMapSkipCellCheck(grid: TableNode, cellA: null | TableCellNode, cellB: null | TableCellNode): [TableMapType, TableMapValueType | null, TableMapValueType | null]; | ||
export declare function $computeTableMap(tableNode: TableNode, cellA: TableCellNode, cellB: TableCellNode): [TableMapType, TableMapValueType, TableMapValueType]; | ||
export declare function $computeTableMapSkipCellCheck(tableNode: TableNode, cellA: null | TableCellNode, cellB: null | TableCellNode): [ | ||
tableMap: TableMapType, | ||
cellAValue: TableMapValueType | null, | ||
cellBValue: TableMapValueType | null | ||
]; | ||
export declare function $getNodeTriplet(source: PointType | LexicalNode | TableCellNode): [TableCellNode, TableRowNode, TableNode]; | ||
export interface TableCellRectBoundary { | ||
minColumn: number; | ||
minRow: number; | ||
maxColumn: number; | ||
maxRow: number; | ||
} | ||
export interface TableCellRectSpans { | ||
topSpan: number; | ||
leftSpan: number; | ||
rightSpan: number; | ||
bottomSpan: number; | ||
} | ||
export declare function $computeTableCellRectSpans(map: TableMapType, boundary: TableCellRectBoundary): TableCellRectSpans; | ||
export declare function $computeTableCellRectBoundary(map: TableMapType, cellAMap: TableMapValueType, cellBMap: TableMapValueType): TableCellRectBoundary; | ||
export declare function $getTableCellNodeRect(tableCellNode: TableCellNode): { | ||
@@ -53,0 +71,0 @@ rowIndex: number; |
@@ -11,9 +11,9 @@ { | ||
"license": "MIT", | ||
"version": "0.20.1-nightly.20241122.0", | ||
"version": "0.20.1-nightly.20241125.0", | ||
"main": "LexicalTable.js", | ||
"types": "index.d.ts", | ||
"dependencies": { | ||
"@lexical/clipboard": "0.20.1-nightly.20241122.0", | ||
"@lexical/utils": "0.20.1-nightly.20241122.0", | ||
"lexical": "0.20.1-nightly.20241122.0" | ||
"@lexical/clipboard": "0.20.1-nightly.20241125.0", | ||
"@lexical/utils": "0.20.1-nightly.20241125.0", | ||
"lexical": "0.20.1-nightly.20241125.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
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
389042
7709
+ Added@lexical/clipboard@0.20.1-nightly.20241125.0(transitive)
+ Added@lexical/html@0.20.1-nightly.20241125.0(transitive)
+ Added@lexical/list@0.20.1-nightly.20241125.0(transitive)
+ Added@lexical/selection@0.20.1-nightly.20241125.0(transitive)
+ Added@lexical/utils@0.20.1-nightly.20241125.0(transitive)
+ Addedlexical@0.20.1-nightly.20241125.0(transitive)
- Removed@lexical/clipboard@0.20.1-nightly.20241122.0(transitive)
- Removed@lexical/html@0.20.1-nightly.20241122.0(transitive)
- Removed@lexical/list@0.20.1-nightly.20241122.0(transitive)
- Removed@lexical/selection@0.20.1-nightly.20241122.0(transitive)
- Removed@lexical/utils@0.20.1-nightly.20241122.0(transitive)
- Removedlexical@0.20.1-nightly.20241122.0(transitive)