@lexical/table
Advanced tools
Comparing version 0.20.1-nightly.20241113.0 to 0.20.1-nightly.20241114.0
@@ -13,5 +13,5 @@ /** | ||
export type { SerializedTableNode } from './LexicalTableNode'; | ||
export { $createTableNode, $getElementForTableNode, $isTableNode, TableNode, } from './LexicalTableNode'; | ||
export { $createTableNode, $getElementForTableNode, $isScrollableTablesActive, $isTableNode, setScrollableTablesActive, TableNode, } from './LexicalTableNode'; | ||
export type { TableDOMCell } from './LexicalTableObserver'; | ||
export { TableObserver } from './LexicalTableObserver'; | ||
export { $getTableAndElementByKey, TableObserver } from './LexicalTableObserver'; | ||
export type { SerializedTableRowNode } from './LexicalTableRowNode'; | ||
@@ -22,3 +22,3 @@ export { $createTableRowNode, $isTableRowNode, TableRowNode, } from './LexicalTableRowNode'; | ||
export type { HTMLTableElementWithWithTableSelectionState } from './LexicalTableSelectionHelpers'; | ||
export { $findCellNode, $findTableNode, applyTableHandlers, getDOMCellFromTarget, getTableObserverFromTableElement, } from './LexicalTableSelectionHelpers'; | ||
export { $findCellNode, $findTableNode, applyTableHandlers, getDOMCellFromTarget, getTableElement, getTableObserverFromTableElement, } from './LexicalTableSelectionHelpers'; | ||
export { $computeTableMap, $computeTableMapSkipCellCheck, $createTableNodeWithDimensions, $deleteTableColumn, $deleteTableColumn__EXPERIMENTAL, $deleteTableRow__EXPERIMENTAL, $getNodeTriplet, $getTableCellNodeFromLexicalNode, $getTableCellNodeRect, $getTableColumnIndexFromTableCellNode, $getTableNodeFromLexicalNodeOrThrow, $getTableRowIndexFromTableCellNode, $getTableRowNodeFromTableCellNodeOrThrow, $insertTableColumn, $insertTableColumn__EXPERIMENTAL, $insertTableRow, $insertTableRow__EXPERIMENTAL, $removeTableRowAtIndex, $unmergeCell, } from './LexicalTableUtils'; |
@@ -9,98 +9,100 @@ /** | ||
'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 B(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){({element:a}= | ||
'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=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|| | ||
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|| | ||
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?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,p)=> | ||
{if(C(p)&&!w.$isElementNode(n)){p=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"));p.append(n);return p}return n},node:b}}function B(a,b=1,c){return w.$applyNodeReplacement(new y(a,b,c))}function C(a){return a instanceof y}let da=w.createCommand("INSERT_TABLE_COMMAND");var D; | ||
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 D; | ||
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.");}D=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 I extends w.ElementNode{static getType(){return"tablerow"}static clone(a){return new I(a.__height,a.__key)}static importDOM(){return{tr:()=>({conversion:fa,priority:0})}}static importJSON(a){return J(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 fa(a){let b=void 0;ba.test(a.style.height)&&(b=parseFloat(a.style.height));return{node:J(b)}}function J(a){return w.$applyNodeReplacement(new I(a))}function K(a){return a instanceof I} | ||
function ha(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 ia(a){a=h.$findMatchingParent(a,b=>M(b));if(M(a))return a;throw Error("Expected table cell to be inside of table.");}function ja(a,b){let c=ia(a),{x:d,y:e}=c.getCordsFromCellNode(a,b);return{above:c.getCellNodeFromCords(d,e-1,b),below:c.getCellNodeFromCords(d,e+1,b),left:c.getCellNodeFromCords(d-1,e,b),right:c.getCellNodeFromCords(d+1,e,b)}} | ||
let ka=(a,b)=>a===x.BOTH||a===b?b:x.NO_STATUS;function N(a){let b=a.getFirstDescendant();null==b?a.selectStart():b.getParentOrThrow().selectStart()}function la(a,b){let c=a.getFirstChild();null!==c?c.insertBefore(b):a.append(b)}function O(a,b,c){let [d,e,f]=ma(a,b,c);null===e&&D(207);null===f&&D(208);return[d,e,f]} | ||
function ma(a,b,c){function d(p){let t=e[p];void 0===t&&(e[p]=t=[]);return t}let e=[],f=null,g=null;a=a.getChildren();for(let p=0;p<a.length;p++){var n=a[p];K(n)||D(209);for(let t=n.getFirstChild(),v=0;null!=t;t=t.getNextSibling()){C(t)||D(147);for(n=d(p);void 0!==n[v];)v++;n={cell:t,startColumn:v,startRow:p};let {__rowSpan:k,__colSpan:l}=t;for(let m=0;m<k&&!(p+m>=a.length);m++){let r=d(p+m);for(let q=0;q<l;q++)r[v+q]=n}null!==b&&null===f&&b.is(t)&&(f=n);null!==c&&null===g&&c.is(t)&&(g=n)}}return[e, | ||
f,g]}function P(a){a instanceof y||("__type"in a?(a=h.$findMatchingParent(a,C),C(a)||D(148)):(a=h.$findMatchingParent(a.getNode(),C),C(a)||D(148)));let b=a.getParent();K(b)||D(149);let c=b.getParent();M(c)||D(210);return[a,b,c]} | ||
function na(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 p=0;p<g.length;p++){for(;f[e][n];)n++;let t=g[p],v=t.__rowSpan||1,k=t.__colSpan||1;for(let l=0;l<v;l++)for(let m=0;m<k;m++)f[e+l][n+m]=t;if(b===t)return{colSpan:k,columnIndex:n,rowIndex:e,rowSpan:v};n+=k}}return null} | ||
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&&D(207);null===e&&D(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)||D(209);for(let r=m.getFirstChild(),v=0;null!=r;r=r.getNextSibling()){C(r)||D(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)||D(148)):(a=h.$findMatchingParent(a.getNode(),C),C(a)||D(148)));let b=a.getParent();K(b)||D(149);let c=b.getParent();L(c)||D(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();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)||D(151);w.$normalizeSelection__EXPERIMENTAL(b.select(0,b.getChildrenSize())).insertNodes(a)}getShape(){var a= | ||
w.$getNodeByKey(this.anchor.key);C(a)||D(152);a=na(a);null===a&&D(153);var b=w.$getNodeByKey(this.focus.key);C(b)||D(154);let c=na(b);null===c&&D(155);b=Math.min(a.columnIndex,c.columnIndex);let d=Math.max(a.columnIndex+a.colSpan-1,c.columnIndex+c.colSpan-1),e=Math.min(a.rowIndex,c.rowIndex);a=Math.max(a.rowIndex+a.rowSpan-1,c.rowIndex+c.rowSpan-1);return{fromX:Math.min(b,d),fromY:Math.min(e,a),toX:Math.max(b,d),toY:Math.max(e,a)}}getNodes(){function a(u){let {cell:z,startColumn:A,startRow:E}=u;t= | ||
Math.min(t,A);v=Math.min(v,E);k=Math.max(k,A+z.__colSpan-1);l=Math.max(l,E+z.__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)||D(152);C(c)||D(154);b=d.getParent();K(b)||D(156);b=b.getParent();M(b)||D(157);var e=c.getParents()[1];if(e!==b){if(b.isParentOf(c)){var f=e.getParent();null==f&&D(159);this.set(this.tableKey,c.getKey(),f.getKey())}else f=b.getParent(),null==f&&D(158), | ||
this.set(this.tableKey,f.getKey(),c.getKey());return this.getNodes()}let [g,n,p]=O(b,d,c),t=Math.min(n.startColumn,p.startColumn),v=Math.min(n.startRow,p.startRow),k=Math.max(n.startColumn+n.cell.__colSpan-1,p.startColumn+p.cell.__colSpan-1),l=Math.max(n.startRow+n.cell.__rowSpan-1,p.startRow+p.cell.__rowSpan-1);c=t;d=v;e=t;for(var m=v;t<c||v<d||k>e||l>m;){if(t<c){var r=m-d;--c;for(var q=0;q<=r;q++)a(g[d+q][c])}if(v<d)for(r=e-c,--d,q=0;q<=r;q++)a(g[d][c+q]);if(k>e)for(r=m-d,e+=1,q=0;q<=r;q++)a(g[d+ | ||
q][e]);if(l>m)for(r=e-c,m+=1,q=0;q<=r;q++)a(g[m][c+q])}b=new Map([[b.getKey(),b]]);c=null;for(d=v;d<=l;d++)for(e=t;e<=k;e++){({cell:m}=g[d][e]);r=m.getParent();K(r)||D(160);r!==c&&b.set(r.getKey(),r);b.set(m.getKey(),m);for(f of qa(m))b.set(f.getKey(),f);c=r}f=Array.from(b.values());w.isCurrentlyReadOnlyMode()||(this._cachedNodes=f);return f}getTextContent(){let a=this.getNodes().filter(c=>C(c)),b="";for(let c=0;c<a.length;c++){let d=a[c],e=d.__parent,f=(a[c+1]||{}).__parent;b+=d.getTextContent()+ | ||
(f!==e?"\n":"\t")}return b}}function Q(a){return a instanceof pa}function ra(){let a=w.$createPoint("root",0,"element"),b=w.$createPoint("root",0,"element");return new pa("root",a,b)}function qa(a){let b=[],c=[a];for(;0<c.length;){let d=c.pop();void 0===d&&D(112);w.$isElementNode(d)&&c.unshift(...d.getChildren());d!==a&&b.push(d)}return b} | ||
class sa{constructor(a,b){this.isHighlightingCells=!1;this.focusY=this.focusX=this.anchorY=this.anchorX=-1;this.listenersToRemove=new Set;this.tableNodeKey=b;this.editor=a;this.table={columns:0,domRows:[],rows:0};this.focusCell=this.anchorCell=this.focusCellNodeKey=this.anchorCellNodeKey=this.tableSelection=null;this.hasHijackedSelectionStyles=!1;this.trackTable();this.isSelecting=!1;this.abortController=new AbortController;this.listenerOptions={signal:this.abortController.signal}}getTable(){return this.table}removeListeners(){this.abortController.abort("removeListeners"); | ||
Array.from(this.listenersToRemove).forEach(a=>a());this.listenersToRemove.clear()}trackTable(){let a=new MutationObserver(b=>{this.editor.update(()=>{var c=!1;for(let d=0;d<b.length;d++){const e=b[d].target.nodeName;if("TABLE"===e||"TBODY"===e||"THEAD"===e||"TR"===e){c=!0;break}}if(c){c=this.editor.getElementByKey(this.tableNodeKey);if(!c)throw Error("Expected to find TableElement in DOM");this.table=R(c)}})});this.editor.update(()=>{let b=this.editor.getElementByKey(this.tableNodeKey);if(!b)throw Error("Expected to find TableElement in DOM"); | ||
this.table=R(b);a.observe(b,{attributes:!0,childList:!0,subtree:!0})})}clearHighlight(){let a=this.editor;this.isHighlightingCells=!1;this.focusY=this.focusX=this.anchorY=this.anchorX=-1;this.focusCell=this.anchorCell=this.focusCellNodeKey=this.anchorCellNodeKey=this.tableSelection=null;this.hasHijackedSelectionStyles=!1;this.enableHighlightStyle();a.update(()=>{var b=w.$getNodeByKey(this.tableNodeKey);if(!M(b))throw Error("Expected TableNode.");b=a.getElementByKey(this.tableNodeKey);if(!b)throw Error("Expected to find TableElement in DOM"); | ||
b=R(b);S(a,b,null);w.$setSelection(null);a.dispatchCommand(w.SELECTION_CHANGE_COMMAND,void 0)})}enableHighlightStyle(){let a=this.editor;a.update(()=>{let b=a.getElementByKey(this.tableNodeKey);if(!b)throw Error("Expected to find TableElement in DOM");h.removeClassNamesFromElement(b,a._config.theme.tableSelection);b.classList.remove("disable-selection");this.hasHijackedSelectionStyles=!1})}disableHighlightStyle(){let a=this.editor;a.update(()=>{let b=a.getElementByKey(this.tableNodeKey);if(!b)throw Error("Expected to find TableElement in DOM"); | ||
h.addClassNamesToElement(b,a._config.theme.tableSelection);this.hasHijackedSelectionStyles=!0})}updateTableTableSelection(a){if(null!==a&&a.tableKey===this.tableNodeKey){let b=this.editor;this.tableSelection=a;this.isHighlightingCells=!0;this.disableHighlightStyle();S(b,this.table,this.tableSelection)}else null==a?this.clearHighlight():(this.tableNodeKey=a.tableKey,this.updateTableTableSelection(a))}setFocusCellForSelection(a,b=!1){let c=this.editor;c.update(()=>{var d=w.$getNodeByKey(this.tableNodeKey); | ||
if(!M(d))throw Error("Expected TableNode.");if(!c.getElementByKey(this.tableNodeKey))throw Error("Expected to find TableElement in DOM");var e=a.x;let f=a.y;this.focusCell=a;if(null!==this.anchorCell){let g=ea?(c._window||window).getSelection():null;g&&g.setBaseAndExtent(this.anchorCell.elem,0,this.focusCell.elem,0)}if(!this.isHighlightingCells&&(this.anchorX!==e||this.anchorY!==f||b))this.isHighlightingCells=!0,this.disableHighlightStyle();else if(e===this.focusX&&f===this.focusY)return;this.focusX= | ||
e;this.focusY=f;this.isHighlightingCells&&(e=w.$getNearestNodeFromDOMNode(a.elem),null!=this.tableSelection&&null!=this.anchorCellNodeKey&&C(e)&&d.is(T(e))&&(d=e.getKey(),this.tableSelection=this.tableSelection.clone()||ra(),this.focusCellNodeKey=d,this.tableSelection.set(this.tableNodeKey,this.anchorCellNodeKey,this.focusCellNodeKey),w.$setSelection(this.tableSelection),c.dispatchCommand(w.SELECTION_CHANGE_COMMAND,void 0),S(c,this.table,this.tableSelection)))})}setAnchorCellForSelection(a){this.isHighlightingCells= | ||
!1;this.anchorCell=a;this.anchorX=a.x;this.anchorY=a.y;this.editor.update(()=>{var b=w.$getNearestNodeFromDOMNode(a.elem);C(b)&&(b=b.getKey(),this.tableSelection=null!=this.tableSelection?this.tableSelection.clone():ra(),this.anchorCellNodeKey=b)})}formatCells(a){this.editor.update(()=>{let b=w.$getSelection();Q(b)||D(11);let c=w.$createRangeSelection(),d=c.anchor,e=c.focus,f=b.getNodes().filter(C),g=f[0].getFirstChild(),n=w.$isParagraphNode(g)?g.getFormatFlags(a,null):null;f.forEach(p=>{d.set(p.getKey(), | ||
0,"element");e.set(p.getKey(),p.getChildrenSize(),"element");c.formatText(a,n)});w.$setSelection(b);this.editor.dispatchCommand(w.SELECTION_CHANGE_COMMAND,void 0)})}clearText(){let a=this.editor;a.update(()=>{let b=w.$getNodeByKey(this.tableNodeKey);if(!M(b))throw Error("Expected TableNode.");var c=w.$getSelection();Q(c)||D(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()})}}),S(a,this.table,null),w.$setSelection(null),a.dispatchCommand(w.SELECTION_CHANGE_COMMAND,void 0))})}}function ta(a,b){null!==ua(a)&&D(205);a.__lexicalTableSelection=b}function ua(a){return a.__lexicalTableSelection||null}function va(a){for(;null!=a;){let b=a.nodeName;if("TD"===b||"TH"===b){a=a._cell;if(void 0===a)break;return a}a=a.parentNode}return null} | ||
function R(a){let b=[],c={columns:0,domRows:b,rows:0};var d=a.querySelector("tr");let e=a=0;for(b.length=0;null!=d;){var f=d.nodeName;if("TD"===f||"TH"===f){f=d;f={elem:f,hasBackgroundColor:""!==f.style.backgroundColor,highlighted:!1,x:a,y:e};d._cell=f;let g=b[e];void 0===g&&(g=b[e]=[]);g[a]=f}else if(f=d.firstChild,null!=f){d=f;continue}f=d.nextSibling;if(null!=f)a++,d=f;else if(f=d.parentNode,null!=f){d=f.nextSibling;if(null==d)break;e++;a=0}}c.columns=a+1;c.rows=e+1;return c} | ||
function S(a,b,c){let d=new Set(c?c.getNodes():[]);wa(b,(e,f)=>{let g=e.elem;d.has(f)?(e.highlighted=!0,xa(a,e)):(e.highlighted=!1,ya(a,e),g.getAttribute("style")||g.removeAttribute("style"))})}function wa(a,b){({domRows:a}=a);for(let c=0;c<a.length;c++){let d=a[c];if(d)for(let e=0;e<d.length;e++){let f=d[e];if(!f)continue;let g=w.$getNearestNodeFromDOMNode(f.elem);null!==g&&b(f,g,{x:e,y:c})}}}function za(a,b){b.disableHighlightStyle();wa(b.table,c=>{c.highlighted=!0;xa(a,c)})} | ||
function Aa(a,b){b.enableHighlightStyle();wa(b.table,c=>{let d=c.elem;c.highlighted=!1;ya(a,c);d.getAttribute("style")||d.removeAttribute("style")})} | ||
let Ba=(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}},Ca=(a,b,c,d,e)=>{const f="forward"===e;switch(e){case "backward":case "forward":return c!==(f?a.table.columns-1:0)&&a.setFocusCellForSelection(b.getDOMCellFromCordsOrThrow(c+(f?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(w.$isRangeSelection(a)||Q(a)){let c=b.isParentOf(a.anchor.getNode());a=b.isParentOf(a.focus.getNode());return c&&a}return!1} | ||
function xa(a,b){a=b.elem;b=w.$getNearestNodeFromDOMNode(a);C(b)||D(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 ya(a,b){a=b.elem;b=w.$getNearestNodeFromDOMNode(a);C(b)||D(131);null===b.getBackgroundColor()&&a.style.removeProperty("background-color");a.style.removeProperty("background-image");a.style.removeProperty("caret-color")}function X(a){a=h.$findMatchingParent(a,C);return C(a)?a:null}function T(a){a=h.$findMatchingParent(a,M);return M(a)?a:null} | ||
function Y(a,b,c,d,e){if(("up"===c||"down"===c)&&Ea(a))return!1;var f=w.$getSelection();if(!U(f,d)){if(w.$isRangeSelection(f)){if(f.isCollapsed()&&"backward"===c){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,t=>w.$isElementNode(t)&&!t.isInline());if(!c)return!1;c=c.getPreviousSibling();if(!c||!M(c))return!1;Z(b);c.selectEnd();return!0}if(b.shiftKey&&("up"===c||"down"===c)){a=f.focus.getNode();if(!f.isCollapsed()&& | ||
("up"===c&&!f.isBackward()||"down"===c&&f.isBackward())){e=h.$findMatchingParent(a,t=>M(t));C(e)&&(e=h.$findMatchingParent(e,M));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);Z(b);return!0}if(w.$isRootOrShadowRoot(a)){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}}else{d=h.$findMatchingParent(a,t=>w.$isElementNode(t)&&!t.isInline()); | ||
C(d)&&(d=h.$findMatchingParent(d,M));if(!d)return!1;d="down"===c?d.getNextSibling():d.getPreviousSibling();if(M(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");Z(b);w.$setSelection(f);return!0}}}}return!1}if(w.$isRangeSelection(f)&&f.isCollapsed()){let {anchor:t,focus:v}=f;var g=h.$findMatchingParent(t.getNode(),C),n=h.$findMatchingParent(v.getNode(), | ||
C);if(!C(g)||!g.is(n))return!1;n=T(g);if(n!==d&&null!=n){var p=a.getElementByKey(n.getKey());if(null!=p)return e.table=R(p),Y(a,b,c,n,e)}if("backward"===c||"forward"===c){e=t.type;a=t.offset;g=t.getNode();if(!g)return!1;f=f.getNodes();return 1===f.length&&w.$isDecoratorNode(f[0])?!1:Fa(e,a,g,c)?Ga(b,g,d,c):!1}f=a.getElementByKey(g.__key);n=a.getElementByKey(t.key);if(null==n||null==f)return!1;if("element"===t.type)f=n.getBoundingClientRect();else{f=window.getSelection();if(null===f||0===f.rangeCount)return!1; | ||
f=f.getRangeAt(0).getBoundingClientRect()}n="up"===c?g.getFirstChild():g.getLastChild();if(null==n)return!1;a=a.getElementByKey(n.__key);if(null==a)return!1;a=a.getBoundingClientRect();if("up"===c?a.top>f.top-f.height:f.bottom+f.height>a.bottom){Z(b);f=d.getCordsFromCellNode(g,e.table);if(b.shiftKey)b=d.getDOMCellFromCordsOrThrow(f.x,f.y,e.table),e.setAnchorCellForSelection(b),e.setFocusCellForSelection(b,!0);else return Ba(e,d,f.x,f.y,c);return!0}}else if(Q(f)){let {anchor:t,focus:v}=f;p=h.$findMatchingParent(t.getNode(), | ||
C);n=h.$findMatchingParent(v.getNode(),C);[g]=f.getNodes();a=a.getElementByKey(g.getKey());if(!C(p)||!C(n)||!M(g)||null==a)return!1;e.updateTableTableSelection(f);f=R(a);a=d.getCordsFromCellNode(p,f);a=d.getDOMCellFromCordsOrThrow(a.x,a.y,f);e.setAnchorCellForSelection(a);Z(b);if(b.shiftKey)return b=d.getCordsFromCellNode(n,f),Ca(e,g,b.x,b.y,c);n.selectEnd();return!0}return!1}function Z(a){a.preventDefault();a.stopImmediatePropagation();a.stopPropagation()} | ||
function Ea(a){return(a=a.getRootElement())?a.hasAttribute("aria-controls")&&"typeahead-menu"===a.getAttribute("aria-controls"):!1}function Fa(a,b,c,d){return"element"===a&&("backward"===d?null===c.getPreviousSibling():null===c.getNextSibling())||Ha(a,b,c,d)} | ||
function Ha(a,b,c,d){let e=h.$findMatchingParent(c,f=>w.$isElementNode(f)&&!f.isInline());if(!e)return!1;b="backward"===d?0===b:b===c.getTextContentSize();return"text"===a&&b&&("backward"===d?null===e.getPreviousSibling():null===e.getNextSibling())} | ||
function Ga(a,b,c,d){var e=h.$findMatchingParent(b,C);if(!C(e))return!1;let [f,g]=O(c,e,e);e=f[0][0];let n=f[f.length-1][f[0].length-1],{startColumn:p,startRow:t}=g;if("backward"===d?p!==e.startColumn||t!==e.startRow:p!==n.startColumn||t!==n.startRow)return!1;b=Ia(b,d,c);if(!b||M(b))return!1;Z(a);"backward"===d?b.selectEnd():b.selectStart();return!0} | ||
function Ia(a,b,c){if(a=h.$findMatchingParent(a,d=>w.$isElementNode(d)&&!d.isInline()))return(a="backward"===b?a.getPreviousSibling():a.getNextSibling())&&M(a)?a:"backward"===b?c.getPreviousSibling():c.getNextSibling()}function Ja(a,b,c){let d=w.$createParagraphNode();"first"===a?b.insertBefore(d):b.insertAfter(d);d.append(...(c||[]));d.selectEnd()} | ||
function Ka(a,b,c){var d=c.getParent();if(d&&(a=a.getElementByKey(d.getKey()))&&(d=window.getSelection())&&d.anchorNode===a&&(b=h.$findMatchingParent(b.anchor.getNode(),p=>C(p)))&&(a=h.$findMatchingParent(b,p=>M(p)),M(a)&&a.is(c))){var [e,f]=O(c,b,b);c=e[0][0];b=e[e.length-1][e[0].length-1];var {startRow:g,startColumn:n}=f;if(g===c.startRow&&n===c.startColumn)return"first";if(g===b.startRow&&n===b.startColumn)return"last"}} | ||
function La(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 Ma(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"))} | ||
class Na 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 Na(a.__key)}afterCloneFrom(a){super.afterCloneFrom(a);this.__colWidths=a.__colWidths;this.__rowStriping=a.__rowStriping}static importDOM(){return{table:()=>({conversion:Oa,priority:1})}}static importJSON(a){let b=Pa();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}}createDOM(a){let b=document.createElement("table"),c=document.createElement("colgroup");b.appendChild(c);La(b,a,this.getColumnCount(),this.getColWidths());h.addClassNamesToElement(b,a.theme.table);this.__rowStriping&&Ma(b,a,!0);return b}updateDOM(a,b,c){a.__rowStriping!==this.__rowStriping&&Ma(b,c,this.__rowStriping);La(b,c, | ||
this.getColumnCount(),this.getColWidths());return!1}exportDOM(a){return{...super.exportDOM(a),after:b=>{if(b){let c=b.cloneNode(),d=document.createElement("colgroup"),e=document.createElement("tbody");if(h.isHTMLElement(b)){let f=b.querySelectorAll("col");d.append(...f);b=b.querySelectorAll("tr");e.append(...b)}c.replaceChildren(d,e);return c}}}}canBeEmpty(){return!1}isShadowRoot(){return!0}getCordsFromCellNode(a,b){let {rows:c,domRows:d}=b;for(b=0;b<c;b++){var e=d[b];if(null!=e&&(e=e.findIndex(f=> | ||
{if(f)return{elem:f}=f,w.$getNearestNodeFromDOMNode(f)===a}),-1!==e))return{x:e,y:b}}throw Error("Cell not found in table.");}getDOMCellFromCords(a,b,c){({domRows:c}=c);b=c[b];if(null==b)return null;a=b[a<b.length?a:b.length-1];return null==a?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 Oa(a){let b=Pa();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 Pa(){return w.$applyNodeReplacement(new Na)}function M(a){return a instanceof Na}exports.$computeTableMap=O;exports.$computeTableMapSkipCellCheck=ma;exports.$createTableCellNode=B; | ||
exports.$createTableNode=Pa;exports.$createTableNodeWithDimensions=function(a,b,c=!0){let d=Pa();for(let f=0;f<a;f++){let g=J();for(let n=0;n<b;n++){var e=x.NO_STATUS;"object"===typeof c?(0===f&&c.rows&&(e|=x.ROW),0===n&&c.columns&&(e|=x.COLUMN)):c&&(0===f&&(e|=x.ROW),0===n&&(e|=x.COLUMN));e=B(e);let p=w.$createParagraphNode();p.append(w.$createTextNode());e.append(p);g.append(e)}d.append(g)}return d};exports.$createTableRowNode=J;exports.$createTableSelection=ra; | ||
exports.$deleteTableColumn=function(a,b){let c=a.getChildren();for(let e=0;e<c.length;e++){var d=c[e];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=w.$getSelection();w.$isRangeSelection(a)||Q(a)||D(188);var b=a.anchor.getNode();a=a.focus.getNode();let [c,,d]=P(b);var [e]=P(a);let [f,g,n]=O(d,c,e);var {startColumn:p}=g;let {startRow:t,startColumn:v}=n;b=Math.min(p,v);var k=Math.max(p+c.__colSpan-1,v+e.__colSpan-1);a=k-b+1;if(f[0].length===k-b+1)d.selectPrevious(),d.remove();else{var l=f.length;for(let m=0;m<l;m++)for(let r=b;r<=k;r++){let {cell:q,startColumn:u}=f[m][r];u<b?r===b&&q.setColSpan(q.__colSpan- | ||
Math.min(a,q.__colSpan-(b-u))):u+q.__colSpan-1>k?r===k&&q.setColSpan(q.__colSpan-(k-u+1)):q.remove()}k=f[t];e=p>v?k[p+c.__colSpan]:k[v+e.__colSpan];void 0!==e?({cell:p}=e,N(p)):({cell:p}=v<p?k[v-1]:k[p-1],N(p));if(p=d.getColWidths())p=[...p],p.splice(b,a),d.setColWidths(p)}}; | ||
exports.$deleteTableRow__EXPERIMENTAL=function(){var a=w.$getSelection();w.$isRangeSelection(a)||Q(a)||D(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,p]=O(e,d,f);({startRow:a}=n);var {startRow:t}=p;f=t+f.__rowSpan-1;if(g.length===f-a+1)e.remove();else{t=g[0].length;var v=g[f+1],k=e.getChildAtIndex(f+1);for(let m=f;m>=a;m--){for(var l=t-1;0<=l;l--){let {cell:r,startRow:q,startColumn:u}=g[m][l];if(u===l&& | ||
(m===a&&q<a&&r.setRowSpan(r.__rowSpan-(q-a)),q>=a&&q+r.__rowSpan-1>f))if(r.setRowSpan(r.__rowSpan-(f-q+1)),null===k&&D(122),0===l)la(k,r);else{let {cell:z}=v[l-1];z.insertAfter(r)}}l=e.getChildAtIndex(m);K(l)||D(206,String(m));l.remove()}void 0!==v?({cell:a}=v[0],N(a)):({cell:a}=g[a-1][0],N(a))}};exports.$findCellNode=X;exports.$findTableNode=T;exports.$getElementForTableNode=function(a,b){a=a.getElementByKey(b.getKey());if(null==a)throw Error("Table Element Not Found");return R(a)}; | ||
exports.$getNodeTriplet=P;exports.$getTableCellNodeFromLexicalNode=function(a){a=h.$findMatchingParent(a,b=>C(b));return C(a)?a:null};exports.$getTableCellNodeRect=na;exports.$getTableColumnIndexFromTableCellNode=function(a){return ha(a).getChildren().findIndex(b=>b.is(a))};exports.$getTableNodeFromLexicalNodeOrThrow=ia;exports.$getTableRowIndexFromTableCellNode=function(a){let b=ha(a);return ia(b).getChildren().findIndex(c=>c.is(b))};exports.$getTableRowNodeFromTableCellNodeOrThrow=ha; | ||
exports.$insertTableColumn=function(a,b,c=!0,d,e){let f=a.getChildren(),g=[];for(let t=0;t<f.length;t++){let v=f[t];if(K(v))for(let k=0;k<d;k++){var n=v.getChildren();if(b>=n.length||0>b)throw Error("Table column target index out of range");n=n[b];C(n)||D(12);let {left:l,right:m}=ja(n,e);var p=x.NO_STATUS;if(l&&l.hasHeaderState(x.ROW)||m&&m.hasHeaderState(x.ROW))p|=x.ROW;p=B(p);p.append(w.$createParagraphNode());g.push({newTableCell:p,targetCell:n})}}g.forEach(({newTableCell:t,targetCell:v})=>{c? | ||
v.insertAfter(t):v.insertBefore(t)});return a}; | ||
exports.$insertTableColumn__EXPERIMENTAL=function(a=!0){function b(k=x.NO_STATUS){k=B(k).append(w.$createParagraphNode());null===t&&(t=k);return k}var c=w.$getSelection();w.$isRangeSelection(c)||Q(c)||D(188);var d=c.anchor.getNode();c=c.focus.getNode();[d]=P(d);let [e,,f]=P(c),[g,n,p]=O(f,e,d);d=g.length;c=a?Math.max(n.startColumn,p.startColumn):Math.min(n.startColumn,p.startColumn);a=a?c+e.__colSpan-1:c-1;c=f.getFirstChild();K(c)||D(120);let t=null;var v=c;a:for(c=0;c<d;c++){0!==c&&(v=v.getNextSibling(), | ||
K(v)||D(121));let k=g[c],l=ka(k[0>a?0:a].cell.__headerState,x.ROW);if(0>a){la(v,b(l));continue}let {cell:m,startColumn:r,startRow:q}=k[a];if(r+m.__colSpan-1<=a){let u=m,z=q,A=a;for(;z!==c&&1<u.__rowSpan;)if(A-=m.__colSpan,0<=A){let {cell:E,startRow:G}=k[A];u=E;z=G}else{v.append(b(l));continue a}u.insertAfter(b(l))}else m.setColSpan(m.__colSpan+1)}null!==t&&N(t);if(d=f.getColWidths())d=[...d],a=0>a?0:a,d.splice(a,0,d[a]),f.setColWidths(d);return t}; | ||
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(K(b))for(f=0;f<d;f++){let n=b.getChildren(),p=n.length,t=J();for(let v=0;v<p;v++){var g=n[v];C(g)||D(12);let {above:k,below:l}=ja(g,e);g=x.NO_STATUS;let m=k&&k.getWidth()||l&&l.getWidth()||void 0;if(k&&k.hasHeaderState(x.COLUMN)||l&&l.hasHeaderState(x.COLUMN))g|=x.COLUMN;g=B(g,1,m);g.append(w.$createParagraphNode());t.append(g)}c?b.insertAfter(t):b.insertBefore(t)}else throw Error("Row before insertion index does not exist."); | ||
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)||D(151);u.$normalizeSelection__EXPERIMENTAL(b.select(0,b.getChildrenSize())).insertNodes(a)}getShape(){var a= | ||
u.$getNodeByKey(this.anchor.key);C(a)||D(152);a=oa(a);null===a&&D(153);var b=u.$getNodeByKey(this.focus.key);C(b)||D(154);let c=oa(b);null===c&&D(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:E}=t;r= | ||
Math.min(r,A);v=Math.min(v,E);w=Math.max(w,A+x.__colSpan-1);l=Math.max(l,E+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)||D(152);C(c)||D(154);b=d.getParent();K(b)||D(156);b=b.getParent();L(b)||D(157);var f=c.getParents()[1];if(f!==b){if(b.isParentOf(c)){var e=f.getParent();null==e&&D(159);this.set(this.tableKey,c.getKey(),e.getKey())}else e=b.getParent(),null==e&&D(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)||D(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&&D(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)||D(231,a);b=R(c,b.getElementByKey(a));null===b&&D(232,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)||D(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)||D(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&&D(233,b.nodeName);return a}function wa(a,b){null!==xa(a)&&D(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)||D(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)||D(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)||D(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&&D(229);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)||D(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)||D(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&&D(122),0===l)ma(w,n);else{let {cell:x}=v[l-1];x.insertAfter(n)}}l=f.getChildAtIndex(k);K(l)||D(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&&D(230);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)||D(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)||D(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)||D(120);let r=null;var v=c;a:for(c=0;c<d;c++){0!==c&&(v=v.getNextSibling(), | ||
K(v)||D(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:E,startRow:G}=w[A];t=E;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)||D(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."); | ||
return a}; | ||
exports.$insertTableRow__EXPERIMENTAL=function(a=!0){var b=w.$getSelection();w.$isRangeSelection(b)||Q(b)||D(188);b=b.focus.getNode();let [c,,d]=P(b),[e,f]=O(d,c,c);b=e[0].length;var {startRow:g}=f;if(a){a=g+c.__rowSpan-1;var n=e[a];g=J();for(var p=0;p<b;p++){let {cell:v,startRow:k}=n[p];if(k+v.__rowSpan-1<=a){var t=ka(n[p].cell.__headerState,x.COLUMN);g.append(B(t).append(w.$createParagraphNode()))}else v.setRowSpan(v.__rowSpan+1)}b=d.getChildAtIndex(a);K(b)||D(145);b.insertAfter(g);b=g}else{n=e[g]; | ||
a=J();for(p=0;p<b;p++){let {cell:v,startRow:k}=n[p];k===g?(t=ka(n[p].cell.__headerState,x.COLUMN),a.append(B(t).append(w.$createParagraphNode()))):v.setRowSpan(v.__rowSpan+1)}b=d.getChildAtIndex(g);K(b)||D(145);b.insertBefore(a);b=a}return b};exports.$isTableCellNode=C;exports.$isTableNode=M;exports.$isTableRowNode=K;exports.$isTableSelection=Q; | ||
exports.$insertTableRow__EXPERIMENTAL=function(a=!0){var b=u.$getSelection();u.$isRangeSelection(b)||Q(b)||D(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)||D(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)||D(145);b.insertBefore(a);b=a}return b};exports.$isScrollableTablesActive=Ha;exports.$isTableCellNode=C;exports.$isTableNode=L;exports.$isTableRowNode=K;exports.$isTableSelection=Q; | ||
exports.$removeTableRowAtIndex=function(a,b){let c=a.getChildren();if(b>=c.length||0>b)throw Error("Expected table cell to be inside of table row.");c[b].remove();return a}; | ||
exports.$unmergeCell=function(){var a=w.$getSelection();w.$isRangeSelection(a)||Q(a)||D(188);a=a.anchor.getNode();let [b,c,d]=P(a);a=b.__colSpan;let e=b.__rowSpan;if(1!==a||1!==e){var [f,g]=O(d,b,b),{startColumn:n,startRow:p}=g,t=b.__headerState&x.COLUMN,v=Array.from({length:a},(u,z)=>{u=t;for(let A=0;0!==u&&A<f.length;A++)u&=f[A][z+n].cell.__headerState;return u}),k=b.__headerState&x.ROW,l=Array.from({length:e},(u,z)=>{u=k;for(let A=0;0!==u&&A<f[0].length;A++)u&=f[z+p][A].cell.__headerState;return u}); | ||
if(1<a){for(var m=1;m<a;m++)b.insertAfter(B(v[m]|l[0]).append(w.$createParagraphNode()));b.setColSpan(1)}if(1<e){let u;for(m=1;m<e;m++){var r=p+m;let z=f[r];u=(u||c).getNextSibling();K(u)||D(125);var q=null;for(let A=0;A<n;A++){let E=z[A],G=E.cell;E.startRow===r&&(q=G);1<G.__colSpan&&(A+=G.__colSpan-1)}if(null===q)for(q=a-1;0<=q;q--)la(u,B(v[q]|l[m]).append(w.$createParagraphNode()));else for(r=a-1;0<=r;r--)q.insertAfter(B(v[r]|l[m]).append(w.$createParagraphNode()))}b.setRowSpan(1)}}}; | ||
exports.INSERT_TABLE_COMMAND=da;exports.TableCellHeaderStates=x;exports.TableCellNode=y;exports.TableNode=Na;exports.TableObserver=sa;exports.TableRowNode=I; | ||
exports.applyTableHandlers=function(a,b,c,d){function e(k){k=a.getCordsFromCellNode(k,g.table);return a.getDOMCellFromCordsOrThrow(k.x,k.y,g.table)}let f=c.getRootElement();if(null===f)throw Error("No root element.");let g=new sa(c,a.getKey()),n=c._window||window;ta(b,g);g.listenersToRemove.add(()=>{var k=g;ua(b)===k&&delete b.__lexicalTableSelection});let p=()=>{const k=()=>{g.isSelecting=!1;n.removeEventListener("mouseup",k);n.removeEventListener("mousemove",l)},l=m=>{setTimeout(()=>{if(1!==(m.buttons& | ||
1)&&g.isSelecting)g.isSelecting=!1,n.removeEventListener("mouseup",k),n.removeEventListener("mousemove",l);else{var r=va(m.target);null===r||g.anchorX===r.x&&g.anchorY===r.y||(m.preventDefault(),g.setFocusCellForSelection(r))}},0)};return{onMouseMove:l,onMouseUp:k}};b.addEventListener("mousedown",k=>{setTimeout(()=>{if(0===k.button&&n){var l=va(k.target);null!==l&&(Z(k),g.setAnchorCellForSelection(l));var {onMouseUp:m,onMouseMove:r}=p();g.isSelecting=!0;n.addEventListener("mouseup",m,g.listenerOptions); | ||
n.addEventListener("mousemove",r,g.listenerOptions)}},0)},g.listenerOptions);n.addEventListener("mousedown",k=>{0===k.button&&c.update(()=>{const l=w.$getSelection(),m=k.target;Q(l)&&l.tableKey===g.tableNodeKey&&f.contains(m)&&g.clearHighlight()})},g.listenerOptions);g.listenersToRemove.add(c.registerCommand(w.KEY_ARROW_DOWN_COMMAND,k=>Y(c,k,"down",a,g),w.COMMAND_PRIORITY_HIGH));g.listenersToRemove.add(c.registerCommand(w.KEY_ARROW_UP_COMMAND,k=>Y(c,k,"up",a,g),w.COMMAND_PRIORITY_HIGH));g.listenersToRemove.add(c.registerCommand(w.KEY_ARROW_LEFT_COMMAND, | ||
k=>Y(c,k,"backward",a,g),w.COMMAND_PRIORITY_HIGH));g.listenersToRemove.add(c.registerCommand(w.KEY_ARROW_RIGHT_COMMAND,k=>Y(c,k,"forward",a,g),w.COMMAND_PRIORITY_HIGH));g.listenersToRemove.add(c.registerCommand(w.KEY_ESCAPE_COMMAND,k=>{var l=w.$getSelection();return Q(l)&&(l=h.$findMatchingParent(l.focus.getNode(),C),C(l))?(Z(k),l.selectEnd(),!0):!1},w.COMMAND_PRIORITY_HIGH));let t=k=>()=>{var l=w.$getSelection();if(!U(l,a))return!1;if(Q(l))return g.clearText(),!0;if(w.$isRangeSelection(l)){var m= | ||
h.$findMatchingParent(l.anchor.getNode(),q=>C(q));if(!C(m))return!1;var r=l.anchor.getNode();m=l.focus.getNode();r=a.isParentOf(r);m=a.isParentOf(m);if(r&&!m||m&&!r)return g.clearText(),!0;m=(l=h.$findMatchingParent(l.anchor.getNode(),q=>w.$isElementNode(q)))&&h.$findMatchingParent(l,q=>w.$isElementNode(q)&&C(q.getParent()));if(!w.$isElementNode(m)||!w.$isElementNode(l))return!1;if(k===w.DELETE_LINE_COMMAND&&null===m.getPreviousSibling())return!0}return!1};[w.DELETE_WORD_COMMAND,w.DELETE_LINE_COMMAND, | ||
w.DELETE_CHARACTER_COMMAND].forEach(k=>{g.listenersToRemove.add(c.registerCommand(k,t(k),w.COMMAND_PRIORITY_CRITICAL))});let v=k=>{const l=w.$getSelection();if(!Q(l)&&!w.$isRangeSelection(l))return!1;const m=a.isParentOf(l.anchor.getNode()),r=a.isParentOf(l.focus.getNode());if(m!==r){k=m?"focus":"anchor";const {key:q,offset:u,type:z}=l[k];a[l[m?"anchor":"focus"].isBefore(l[k])?"selectPrevious":"selectNext"]()[k].set(q,u,z);return!1}return Q(l)?(k&&(k.preventDefault(),k.stopPropagation()),g.clearText(), | ||
!0):!1};g.listenersToRemove.add(c.registerCommand(w.KEY_BACKSPACE_COMMAND,v,w.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(w.KEY_DELETE_COMMAND,v,w.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(w.CUT_COMMAND,k=>{let l=w.$getSelection();if(l){if(!Q(l)&&!w.$isRangeSelection(l))return!1;void aa.copyToClipboard(c,h.objectKlassEquals(k,ClipboardEvent)?k:null,aa.$getClipboardDataFromSelection(l));k=v(k);return w.$isRangeSelection(l)?(l.removeText(),!0):k}return!1}, | ||
w.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(w.FORMAT_TEXT_COMMAND,k=>{let l=w.$getSelection();if(!U(l,a))return!1;if(Q(l))return g.formatCells(k),!0;w.$isRangeSelection(l)&&(k=h.$findMatchingParent(l.anchor.getNode(),m=>C(m)),C(k));return!1},w.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(w.FORMAT_ELEMENT_COMMAND,k=>{var l=w.$getSelection();if(!Q(l)||!U(l,a))return!1;var m=l.anchor.getNode();l=l.focus.getNode();if(!C(m)||!C(l))return!1;let [r,q, | ||
u]=O(a,m,l);m=Math.max(q.startRow,u.startRow);l=Math.max(q.startColumn,u.startColumn);var z=Math.min(q.startRow,u.startRow);let A=Math.min(q.startColumn,u.startColumn);for(;z<=m;z++)for(let G=A;G<=l;G++){var E=r[z][G].cell;E.setFormat(k);E=E.getChildren();for(let L=0;L<E.length;L++){let H=E[L];w.$isElementNode(H)&&!H.isInline()&&H.setFormat(k)}}return!0},w.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(w.CONTROLLED_TEXT_INSERTION_COMMAND,k=>{var l=w.$getSelection();if(!U(l, | ||
a))return!1;if(Q(l))g.clearHighlight();else if(w.$isRangeSelection(l)){let m=h.$findMatchingParent(l.anchor.getNode(),r=>C(r));if(!C(m))return!1;if("string"===typeof k&&(l=Ka(c,l,a)))return Ja(l,a,[w.$createTextNode(k)]),!0}return!1},w.COMMAND_PRIORITY_CRITICAL));d&&g.listenersToRemove.add(c.registerCommand(w.KEY_TAB_COMMAND,k=>{var l=w.$getSelection();if(!w.$isRangeSelection(l)||!l.isCollapsed()||!U(l,a))return!1;l=X(l.anchor.getNode());if(null===l)return!1;Z(k);l=a.getCordsFromCellNode(l,g.table); | ||
Ba(g,a,l.x,l.y,k.shiftKey?"backward":"forward");return!0},w.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(w.FOCUS_COMMAND,()=>a.isSelected(),w.COMMAND_PRIORITY_HIGH));g.listenersToRemove.add(c.registerCommand(w.SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,k=>{let {nodes:l,selection:m}=k;k=m.getStartEndPoints();var r=Q(m);r=w.$isRangeSelection(m)&&null!==h.$findMatchingParent(m.anchor.getNode(),H=>C(H))&&null!==h.$findMatchingParent(m.focus.getNode(),H=>C(H))||r;if(1!==l.length|| | ||
!M(l[0])||!r||null===k)return!1;var [q]=k,u=l[0];k=u.getChildren();r=u.getFirstChildOrThrow().getChildrenSize();u=u.getChildrenSize();var z=h.$findMatchingParent(q.getNode(),H=>C(H)),A=z&&h.$findMatchingParent(z,H=>K(H)),E=A&&h.$findMatchingParent(A,H=>M(H));if(!C(z)||!K(A)||!M(E))return!1;q=A.getIndexWithinParent();var G=Math.min(E.getChildrenSize()-1,q+u-1);u=z.getIndexWithinParent();z=Math.min(A.getChildrenSize()-1,u+r-1);r=Math.min(u,z);A=Math.min(q,G);u=Math.max(u,z);q=Math.max(q,G);E=E.getChildren(); | ||
for(G=0;A<=q;A++){z=E[A];if(!K(z))return!1;var L=k[G];if(!K(L))return!1;z=z.getChildren();L=L.getChildren();let H=0;for(let V=r;V<=u;V++){let oa=z[V];if(!C(oa))return!1;let Da=L[H];if(!C(Da))return!1;let Qa=oa.getChildren();Da.getChildren().forEach(W=>{w.$isTextNode(W)&&w.$createParagraphNode().append(W);oa.append(W)});Qa.forEach(W=>W.remove());H++}G++}return!0},w.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(w.SELECTION_CHANGE_COMMAND,()=>{let k=w.$getSelection(),l=w.$getPreviousSelection(); | ||
if(w.$isRangeSelection(k)){let {anchor:z,focus:A}=k;var m=z.getNode(),r=A.getNode(),q=X(m),u=X(r);let E=!(!q||!a.is(T(q))),G=!(!u||!a.is(T(u)));m=E!==G;let L=E&&G;r=k.isBackward();m?(m=k.clone(),G?([u]=O(a,u,u),q=u[0][0].cell,u=u[u.length-1].at(-1).cell,m.focus.set(r?q.getKey():u.getKey(),r?q.getChildrenSize():u.getChildrenSize(),"element")):E&&([u]=O(a,q,q),q=u[0][0].cell,u=u[u.length-1].at(-1).cell,m.anchor.set(r?u.getKey():q.getKey(),r?u.getChildrenSize():0,"element")),w.$setSelection(m),za(c, | ||
g)):L&&!q.is(u)&&(g.setAnchorCellForSelection(e(q)),g.setFocusCellForSelection(e(u),!0),g.isSelecting||setTimeout(()=>{let {onMouseUp:H,onMouseMove:V}=p();g.isSelecting=!0;n.addEventListener("mouseup",H);n.addEventListener("mousemove",V)},0))}else k&&Q(k)&&k.is(l)&&k.tableKey===a.getKey()&&(r=ea?(c._window||window).getSelection():null)&&r.anchorNode&&r.focusNode&&(m=(m=w.$getNearestNodeFromDOMNode(r.focusNode))&&!a.is(T(m)),q=(q=w.$getNearestNodeFromDOMNode(r.anchorNode))&&a.is(T(q)),m&&q&&0<r.rangeCount&& | ||
(m=w.$createRangeSelectionFromDom(r,c)))&&(m.anchor.set(a.getKey(),k.isBackward()?a.getChildrenSize():0,"element"),r.removeAllRanges(),w.$setSelection(m));if(k&&!k.is(l)&&(Q(k)||Q(l))&&g.tableSelection&&!g.tableSelection.is(l))return Q(k)&&k.tableKey===g.tableNodeKey?g.updateTableTableSelection(k):!Q(k)&&Q(l)&&l.tableKey===g.tableNodeKey&&g.updateTableTableSelection(null),!1;g.hasHijackedSelectionStyles&&!a.isSelected()?Aa(c,g):!g.hasHijackedSelectionStyles&&a.isSelected()&&za(c,g);return!1},w.COMMAND_PRIORITY_CRITICAL)); | ||
g.listenersToRemove.add(c.registerCommand(w.INSERT_PARAGRAPH_COMMAND,()=>{var k=w.$getSelection();return w.$isRangeSelection(k)&&k.isCollapsed()&&U(k,a)?(k=Ka(c,k,a))?(Ja(k,a),!0):!1:!1},w.COMMAND_PRIORITY_CRITICAL));return g};exports.getDOMCellFromTarget=va;exports.getTableObserverFromTableElement=ua | ||
exports.$unmergeCell=function(){var a=u.$getSelection();u.$isRangeSelection(a)||Q(a)||D(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)||D(125);var q=null;for(let A=0;A<m;A++){let E=x[A],G=E.cell;E.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 E=Math.min(t.startColumn,x.startColumn);for(;A<=n;A++)for(let J=E;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)),E=A&&h.$findMatchingParent(A,H=>K(H)),G=E&&h.$findMatchingParent(E,H=>L(H));if(!C(A)||!K(E)||!L(G))return!1;t=E.getIndexWithinParent();var J=Math.min(G.getChildrenSize()-1,t+x-1);x=A.getIndexWithinParent();A=Math.min(E.getChildrenSize()-1,x+q-1);q=Math.min(x,A);E=Math.min(t,J);x=Math.max(x,A);t=Math.max(t,J);G=G.getChildren(); | ||
for(J=0;E<=t;E++){A=G[E];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)&&!h.$findMatchingParent(n,E=>E.is(A)))return A.selectStart(),!0}}if(u.$isRangeSelection(l)){let {anchor:A,focus:E}=l;n=A.getNode();q=E.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)} |
@@ -8,4 +8,3 @@ /** | ||
*/ | ||
import type { DOMConversionMap, DOMConversionOutput, DOMExportOutput, EditorConfig, LexicalEditor, LexicalNode, NodeKey, SerializedElementNode, Spread } from 'lexical'; | ||
import { ElementNode } from 'lexical'; | ||
import { DOMConversionMap, DOMConversionOutput, DOMExportOutput, EditorConfig, ElementDOMSlot, ElementNode, LexicalEditor, LexicalNode, NodeKey, SerializedElementNode, Spread } from 'lexical'; | ||
import { TableCellNode } from './LexicalTableCellNode'; | ||
@@ -17,2 +16,4 @@ import { TableDOMCell, TableDOMTable } from './LexicalTableObserver'; | ||
}, SerializedElementNode>; | ||
export declare function $isScrollableTablesActive(editor?: LexicalEditor): boolean; | ||
export declare function setScrollableTablesActive(editor: LexicalEditor, active: boolean): void; | ||
/** @noInheritDoc */ | ||
@@ -32,2 +33,3 @@ export declare class TableNode extends ElementNode { | ||
exportJSON(): SerializedTableNode; | ||
getDOMSlot(element: HTMLElement): ElementDOMSlot; | ||
createDOM(config: EditorConfig, editor?: LexicalEditor): HTMLElement; | ||
@@ -34,0 +36,0 @@ updateDOM(prevNode: TableNode, dom: HTMLElement, config: EditorConfig): boolean; |
@@ -9,3 +9,5 @@ /** | ||
import type { LexicalEditor, NodeKey, TextFormatType } from 'lexical'; | ||
import { TableNode } from './LexicalTableNode'; | ||
import { type TableSelection } from './LexicalTableSelection'; | ||
import { HTMLTableElementWithWithTableSelectionState } from './LexicalTableSelectionHelpers'; | ||
export type TableDOMCell = { | ||
@@ -24,2 +26,6 @@ elem: HTMLElement; | ||
}; | ||
export declare function $getTableAndElementByKey(tableNodeKey: NodeKey, editor?: LexicalEditor): { | ||
tableNode: TableNode; | ||
tableElement: HTMLTableElementWithWithTableSelectionState; | ||
}; | ||
export declare class TableObserver { | ||
@@ -42,2 +48,3 @@ focusX: number; | ||
isSelecting: boolean; | ||
shouldCheckSelection: boolean; | ||
abortController: AbortController; | ||
@@ -50,2 +57,6 @@ listenerOptions: { | ||
removeListeners(): void; | ||
$lookup(): { | ||
tableNode: TableNode; | ||
tableElement: HTMLTableElementWithWithTableSelectionState; | ||
}; | ||
trackTable(): void; | ||
@@ -56,2 +67,16 @@ clearHighlight(): void; | ||
updateTableTableSelection(selection: TableSelection | null): void; | ||
/** | ||
* @internal | ||
* Firefox has a strange behavior where pressing the down arrow key from | ||
* above the table will move the caret after the table and then lexical | ||
* will select the last cell instead of the first. | ||
* We do still want to let the browser handle caret movement but we will | ||
* use this property to "tag" the update so that we can recheck the | ||
* selection after the event is processed. | ||
*/ | ||
setShouldCheckSelection(): void; | ||
/** | ||
* @internal | ||
*/ | ||
getAndClearShouldCheckSelection(): boolean; | ||
setFocusCellForSelection(cell: TableDOMCell, ignoreStart?: boolean): void; | ||
@@ -58,0 +83,0 @@ setAnchorCellForSelection(cell: TableDOMCell): void; |
@@ -9,14 +9,15 @@ /** | ||
import type { TableCellNode } from './LexicalTableCellNode'; | ||
import type { TableNode } from './LexicalTableNode'; | ||
import type { TableDOMCell } from './LexicalTableObserver'; | ||
import type { TableSelection } from './LexicalTableSelection'; | ||
import type { LexicalEditor, LexicalNode, RangeSelection } from 'lexical'; | ||
import { TableNode } from './LexicalTableNode'; | ||
import { TableDOMTable, TableObserver } from './LexicalTableObserver'; | ||
declare const LEXICAL_ELEMENT_KEY = "__lexicalTableSelection"; | ||
export declare const getDOMSelection: (targetWindow: Window | null) => Selection | null; | ||
export declare function applyTableHandlers(tableNode: TableNode, tableElement: HTMLTableElementWithWithTableSelectionState, editor: LexicalEditor, hasTabHandler: boolean): TableObserver; | ||
export declare function getTableElement<T extends HTMLElement | null>(tableNode: TableNode, dom: T): HTMLTableElementWithWithTableSelectionState | (T & null); | ||
export declare function applyTableHandlers(tableNode: TableNode, element: HTMLElement, editor: LexicalEditor, hasTabHandler: boolean): TableObserver; | ||
export type HTMLTableElementWithWithTableSelectionState = HTMLTableElement & { | ||
[LEXICAL_ELEMENT_KEY]?: TableObserver | undefined; | ||
}; | ||
export declare function deatatchTableObserverFromTableElement(tableElement: HTMLTableElementWithWithTableSelectionState, tableObserver: TableObserver): void; | ||
export declare function detatchTableObserverFromTableElement(tableElement: HTMLTableElementWithWithTableSelectionState, tableObserver: TableObserver): void; | ||
export declare function attachTableObserverToTableElement(tableElement: HTMLTableElementWithWithTableSelectionState, tableObserver: TableObserver): void; | ||
@@ -26,3 +27,3 @@ export declare function getTableObserverFromTableElement(tableElement: HTMLTableElementWithWithTableSelectionState): TableObserver | null; | ||
export declare function doesTargetContainText(node: Node): boolean; | ||
export declare function getTable(tableElement: HTMLElement): TableDOMTable; | ||
export declare function getTable(tableNode: TableNode, dom: HTMLElement): TableDOMTable; | ||
export declare function $updateDOMForSelection(editor: LexicalEditor, table: TableDOMTable, selection: TableSelection | RangeSelection | null): void; | ||
@@ -29,0 +30,0 @@ export declare function $forEachTableCell(grid: TableDOMTable, cb: (cell: TableDOMCell, lexicalNode: LexicalNode, cords: { |
@@ -11,9 +11,9 @@ { | ||
"license": "MIT", | ||
"version": "0.20.1-nightly.20241113.0", | ||
"version": "0.20.1-nightly.20241114.0", | ||
"main": "LexicalTable.js", | ||
"types": "index.d.ts", | ||
"dependencies": { | ||
"@lexical/clipboard": "0.20.1-nightly.20241113.0", | ||
"@lexical/utils": "0.20.1-nightly.20241113.0", | ||
"lexical": "0.20.1-nightly.20241113.0" | ||
"@lexical/clipboard": "0.20.1-nightly.20241114.0", | ||
"@lexical/utils": "0.20.1-nightly.20241114.0", | ||
"lexical": "0.20.1-nightly.20241114.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
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
361748
7135
+ Added@lexical/clipboard@0.20.1-nightly.20241114.0(transitive)
+ Added@lexical/html@0.20.1-nightly.20241114.0(transitive)
+ Added@lexical/list@0.20.1-nightly.20241114.0(transitive)
+ Added@lexical/selection@0.20.1-nightly.20241114.0(transitive)
+ Added@lexical/utils@0.20.1-nightly.20241114.0(transitive)
+ Addedlexical@0.20.1-nightly.20241114.0(transitive)
- Removed@lexical/clipboard@0.20.1-nightly.20241113.0(transitive)
- Removed@lexical/html@0.20.1-nightly.20241113.0(transitive)
- Removed@lexical/list@0.20.1-nightly.20241113.0(transitive)
- Removed@lexical/selection@0.20.1-nightly.20241113.0(transitive)
- Removed@lexical/utils@0.20.1-nightly.20241113.0(transitive)
- Removedlexical@0.20.1-nightly.20241113.0(transitive)