@lexical/table 0.24.1-nightly.20250212.0 → 0.24.1-nightly.20250214.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LexicalTable.dev.js +27 -1
- package/LexicalTable.dev.mjs +27 -1
- package/LexicalTable.prod.js +1 -1
- package/LexicalTable.prod.mjs +1 -1
- package/LexicalTableNode.d.ts +4 -0
- package/package.json +4 -4
package/LexicalTable.dev.js
CHANGED
@@ -3212,6 +3212,15 @@ function setRowStriping(dom, config, rowStriping) {
|
|
3212
3212
|
dom.removeAttribute('data-lexical-row-striping');
|
3213
3213
|
}
|
3214
3214
|
}
|
3215
|
+
function setFrozenColumns(dom, config, frozenColumnCount) {
|
3216
|
+
if (frozenColumnCount > 0) {
|
3217
|
+
utils.addClassNamesToElement(dom, config.theme.tableFrozenColumn);
|
3218
|
+
dom.setAttribute('data-lexical-frozen-column', 'true');
|
3219
|
+
} else {
|
3220
|
+
utils.removeClassNamesFromElement(dom, config.theme.tableFrozenColumn);
|
3221
|
+
dom.removeAttribute('data-lexical-frozen-column');
|
3222
|
+
}
|
3223
|
+
}
|
3215
3224
|
function alignTableElement(dom, config, formatType) {
|
3216
3225
|
if (!config.theme.tableAlignment) {
|
3217
3226
|
return;
|
@@ -3267,6 +3276,7 @@ class TableNode extends lexical.ElementNode {
|
|
3267
3276
|
super.afterCloneFrom(prevNode);
|
3268
3277
|
this.__colWidths = prevNode.__colWidths;
|
3269
3278
|
this.__rowStriping = prevNode.__rowStriping;
|
3279
|
+
this.__frozenColumnCount = prevNode.__frozenColumnCount;
|
3270
3280
|
}
|
3271
3281
|
static importDOM() {
|
3272
3282
|
return {
|
@@ -3280,16 +3290,18 @@ class TableNode extends lexical.ElementNode {
|
|
3280
3290
|
return $createTableNode().updateFromJSON(serializedNode);
|
3281
3291
|
}
|
3282
3292
|
updateFromJSON(serializedNode) {
|
3283
|
-
return super.updateFromJSON(serializedNode).setRowStriping(serializedNode.rowStriping || false).setColWidths(serializedNode.colWidths);
|
3293
|
+
return super.updateFromJSON(serializedNode).setRowStriping(serializedNode.rowStriping || false).setFrozenColumns(serializedNode.frozenColumnCount || 0).setColWidths(serializedNode.colWidths);
|
3284
3294
|
}
|
3285
3295
|
constructor(key) {
|
3286
3296
|
super(key);
|
3287
3297
|
this.__rowStriping = false;
|
3298
|
+
this.__frozenColumnCount = 0;
|
3288
3299
|
}
|
3289
3300
|
exportJSON() {
|
3290
3301
|
return {
|
3291
3302
|
...super.exportJSON(),
|
3292
3303
|
colWidths: this.getColWidths(),
|
3304
|
+
frozenColumnCount: this.__frozenColumnCount ? this.__frozenColumnCount : undefined,
|
3293
3305
|
rowStriping: this.__rowStriping ? this.__rowStriping : undefined
|
3294
3306
|
};
|
3295
3307
|
}
|
@@ -3311,6 +3323,9 @@ class TableNode extends lexical.ElementNode {
|
|
3311
3323
|
lexical.setDOMUnmanaged(colGroup);
|
3312
3324
|
utils.addClassNamesToElement(tableElement, config.theme.table);
|
3313
3325
|
alignTableElement(tableElement, config, this.getFormatType());
|
3326
|
+
if (this.__frozenColumnCount) {
|
3327
|
+
setFrozenColumns(tableElement, config, this.__frozenColumnCount);
|
3328
|
+
}
|
3314
3329
|
if (this.__rowStriping) {
|
3315
3330
|
setRowStriping(tableElement, config, true);
|
3316
3331
|
}
|
@@ -3331,6 +3346,9 @@ class TableNode extends lexical.ElementNode {
|
|
3331
3346
|
if (prevNode.__rowStriping !== this.__rowStriping) {
|
3332
3347
|
setRowStriping(dom, config, this.__rowStriping);
|
3333
3348
|
}
|
3349
|
+
if (prevNode.__frozenColumnCount !== this.__frozenColumnCount) {
|
3350
|
+
setFrozenColumns(dom, config, this.__frozenColumnCount);
|
3351
|
+
}
|
3334
3352
|
updateColgroup(dom, config, this.getColumnCount(), this.getColWidths());
|
3335
3353
|
alignTableElement(this.getDOMSlot(dom).element, config, this.getFormatType());
|
3336
3354
|
return false;
|
@@ -3491,6 +3509,14 @@ class TableNode extends lexical.ElementNode {
|
|
3491
3509
|
self.__rowStriping = newRowStriping;
|
3492
3510
|
return self;
|
3493
3511
|
}
|
3512
|
+
setFrozenColumns(columnCount) {
|
3513
|
+
const self = this.getWritable();
|
3514
|
+
self.__frozenColumnCount = columnCount;
|
3515
|
+
return self;
|
3516
|
+
}
|
3517
|
+
getFrozenColumns() {
|
3518
|
+
return this.getLatest().__frozenColumnCount;
|
3519
|
+
}
|
3494
3520
|
canSelectBefore() {
|
3495
3521
|
return true;
|
3496
3522
|
}
|
package/LexicalTable.dev.mjs
CHANGED
@@ -3210,6 +3210,15 @@ function setRowStriping(dom, config, rowStriping) {
|
|
3210
3210
|
dom.removeAttribute('data-lexical-row-striping');
|
3211
3211
|
}
|
3212
3212
|
}
|
3213
|
+
function setFrozenColumns(dom, config, frozenColumnCount) {
|
3214
|
+
if (frozenColumnCount > 0) {
|
3215
|
+
addClassNamesToElement(dom, config.theme.tableFrozenColumn);
|
3216
|
+
dom.setAttribute('data-lexical-frozen-column', 'true');
|
3217
|
+
} else {
|
3218
|
+
removeClassNamesFromElement(dom, config.theme.tableFrozenColumn);
|
3219
|
+
dom.removeAttribute('data-lexical-frozen-column');
|
3220
|
+
}
|
3221
|
+
}
|
3213
3222
|
function alignTableElement(dom, config, formatType) {
|
3214
3223
|
if (!config.theme.tableAlignment) {
|
3215
3224
|
return;
|
@@ -3265,6 +3274,7 @@ class TableNode extends ElementNode {
|
|
3265
3274
|
super.afterCloneFrom(prevNode);
|
3266
3275
|
this.__colWidths = prevNode.__colWidths;
|
3267
3276
|
this.__rowStriping = prevNode.__rowStriping;
|
3277
|
+
this.__frozenColumnCount = prevNode.__frozenColumnCount;
|
3268
3278
|
}
|
3269
3279
|
static importDOM() {
|
3270
3280
|
return {
|
@@ -3278,16 +3288,18 @@ class TableNode extends ElementNode {
|
|
3278
3288
|
return $createTableNode().updateFromJSON(serializedNode);
|
3279
3289
|
}
|
3280
3290
|
updateFromJSON(serializedNode) {
|
3281
|
-
return super.updateFromJSON(serializedNode).setRowStriping(serializedNode.rowStriping || false).setColWidths(serializedNode.colWidths);
|
3291
|
+
return super.updateFromJSON(serializedNode).setRowStriping(serializedNode.rowStriping || false).setFrozenColumns(serializedNode.frozenColumnCount || 0).setColWidths(serializedNode.colWidths);
|
3282
3292
|
}
|
3283
3293
|
constructor(key) {
|
3284
3294
|
super(key);
|
3285
3295
|
this.__rowStriping = false;
|
3296
|
+
this.__frozenColumnCount = 0;
|
3286
3297
|
}
|
3287
3298
|
exportJSON() {
|
3288
3299
|
return {
|
3289
3300
|
...super.exportJSON(),
|
3290
3301
|
colWidths: this.getColWidths(),
|
3302
|
+
frozenColumnCount: this.__frozenColumnCount ? this.__frozenColumnCount : undefined,
|
3291
3303
|
rowStriping: this.__rowStriping ? this.__rowStriping : undefined
|
3292
3304
|
};
|
3293
3305
|
}
|
@@ -3309,6 +3321,9 @@ class TableNode extends ElementNode {
|
|
3309
3321
|
setDOMUnmanaged(colGroup);
|
3310
3322
|
addClassNamesToElement(tableElement, config.theme.table);
|
3311
3323
|
alignTableElement(tableElement, config, this.getFormatType());
|
3324
|
+
if (this.__frozenColumnCount) {
|
3325
|
+
setFrozenColumns(tableElement, config, this.__frozenColumnCount);
|
3326
|
+
}
|
3312
3327
|
if (this.__rowStriping) {
|
3313
3328
|
setRowStriping(tableElement, config, true);
|
3314
3329
|
}
|
@@ -3329,6 +3344,9 @@ class TableNode extends ElementNode {
|
|
3329
3344
|
if (prevNode.__rowStriping !== this.__rowStriping) {
|
3330
3345
|
setRowStriping(dom, config, this.__rowStriping);
|
3331
3346
|
}
|
3347
|
+
if (prevNode.__frozenColumnCount !== this.__frozenColumnCount) {
|
3348
|
+
setFrozenColumns(dom, config, this.__frozenColumnCount);
|
3349
|
+
}
|
3332
3350
|
updateColgroup(dom, config, this.getColumnCount(), this.getColWidths());
|
3333
3351
|
alignTableElement(this.getDOMSlot(dom).element, config, this.getFormatType());
|
3334
3352
|
return false;
|
@@ -3489,6 +3507,14 @@ class TableNode extends ElementNode {
|
|
3489
3507
|
self.__rowStriping = newRowStriping;
|
3490
3508
|
return self;
|
3491
3509
|
}
|
3510
|
+
setFrozenColumns(columnCount) {
|
3511
|
+
const self = this.getWritable();
|
3512
|
+
self.__frozenColumnCount = columnCount;
|
3513
|
+
return self;
|
3514
|
+
}
|
3515
|
+
getFrozenColumns() {
|
3516
|
+
return this.getLatest().__frozenColumnCount;
|
3517
|
+
}
|
3492
3518
|
canSelectBefore() {
|
3493
3519
|
return true;
|
3494
3520
|
}
|
package/LexicalTable.prod.js
CHANGED
@@ -6,4 +6,4 @@
|
|
6
6
|
*
|
7
7
|
*/
|
8
8
|
|
9
|
-
"use strict";var e=require("@lexical/utils"),t=require("lexical"),n=require("@lexical/clipboard");const o=/^(\d+(?:\.\d+)?)px$/,r={BOTH:3,COLUMN:2,NO_STATUS:0,ROW:1};class l extends t.ElementNode{static getType(){return"tablecell"}static clone(e){return new l(e.__headerState,e.__colSpan,e.__width,e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__rowSpan=e.__rowSpan,this.__backgroundColor=e.__backgroundColor,this.__verticalAlign=e.__verticalAlign}static importDOM(){return{td:e=>({conversion:s,priority:0}),th:e=>({conversion:s,priority:0})}}static importJSON(e){return a().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setHeaderStyles(e.headerState).setColSpan(e.colSpan||1).setRowSpan(e.rowSpan||1).setWidth(e.width||void 0).setBackgroundColor(e.backgroundColor||null).setVerticalAlign(e.verticalAlign||void 0)}constructor(e=r.NO_STATUS,t=1,n,o){super(o),this.__colSpan=t,this.__rowSpan=1,this.__headerState=e,this.__width=n,this.__backgroundColor=null}createDOM(t){const n=document.createElement(this.getTag());return this.__width&&(n.style.width=`${this.__width}px`),this.__colSpan>1&&(n.colSpan=this.__colSpan),this.__rowSpan>1&&(n.rowSpan=this.__rowSpan),null!==this.__backgroundColor&&(n.style.backgroundColor=this.__backgroundColor),i(this.__verticalAlign)&&(n.style.verticalAlign=this.__verticalAlign),e.addClassNamesToElement(n,t.theme.tableCell,this.hasHeader()&&t.theme.tableCellHeader),n}exportDOM(e){const n=super.exportDOM(e);if(t.isHTMLElement(n.element)){const e=n.element;e.setAttribute("data-temporary-table-cell-lexical-key",this.getKey()),e.style.border="1px solid black",this.__colSpan>1&&(e.colSpan=this.__colSpan),this.__rowSpan>1&&(e.rowSpan=this.__rowSpan),e.style.width=`${this.getWidth()||75}px`,e.style.verticalAlign=this.getVerticalAlign()||"top",e.style.textAlign="start",null===this.__backgroundColor&&this.hasHeader()&&(e.style.backgroundColor="#f2f3f5")}return n}exportJSON(){return{...super.exportJSON(),...i(this.__verticalAlign)&&{verticalAlign:this.__verticalAlign},backgroundColor:this.getBackgroundColor(),colSpan:this.__colSpan,headerState:this.__headerState,rowSpan:this.__rowSpan,width:this.getWidth()}}getColSpan(){return this.getLatest().__colSpan}setColSpan(e){const t=this.getWritable();return t.__colSpan=e,t}getRowSpan(){return this.getLatest().__rowSpan}setRowSpan(e){const t=this.getWritable();return t.__rowSpan=e,t}getTag(){return this.hasHeader()?"th":"td"}setHeaderStyles(e,t=r.BOTH){const n=this.getWritable();return n.__headerState=e&t|n.__headerState&~t,n}getHeaderStyles(){return this.getLatest().__headerState}setWidth(e){const t=this.getWritable();return t.__width=e,t}getWidth(){return this.getLatest().__width}getBackgroundColor(){return this.getLatest().__backgroundColor}setBackgroundColor(e){const t=this.getWritable();return t.__backgroundColor=e,t}getVerticalAlign(){return this.getLatest().__verticalAlign}setVerticalAlign(e){const t=this.getWritable();return t.__verticalAlign=e||void 0,t}toggleHeaderStyle(e){const t=this.getWritable();return(t.__headerState&e)===e?t.__headerState-=e:t.__headerState+=e,t}hasHeaderState(e){return(this.getHeaderStyles()&e)===e}hasHeader(){return this.getLatest().__headerState!==r.NO_STATUS}updateDOM(e){return e.__headerState!==this.__headerState||e.__width!==this.__width||e.__colSpan!==this.__colSpan||e.__rowSpan!==this.__rowSpan||e.__backgroundColor!==this.__backgroundColor||e.__verticalAlign!==this.__verticalAlign}isShadowRoot(){return!0}collapseAtStart(){return!0}canBeEmpty(){return!1}canIndent(){return!1}}function i(e){return"middle"===e||"bottom"===e}function s(e){const n=e,l=e.nodeName.toLowerCase();let s;o.test(n.style.width)&&(s=parseFloat(n.style.width));const u=a("th"===l?r.ROW:r.NO_STATUS,n.colSpan,s);u.__rowSpan=n.rowSpan;const d=n.style.backgroundColor;""!==d&&(u.__backgroundColor=d);const h=n.style.verticalAlign;i(h)&&(u.__verticalAlign=h);const g=n.style,f=(g&&g.textDecoration||"").split(" "),m="700"===g.fontWeight||"bold"===g.fontWeight,p=f.includes("line-through"),C="italic"===g.fontStyle,S=f.includes("underline");return{after:e=>(0===e.length&&e.push(t.$createParagraphNode()),e),forChild:(e,n)=>{if(c(n)&&!t.$isElementNode(e)){const n=t.$createParagraphNode();return t.$isLineBreakNode(e)&&"\n"===e.getTextContent()?null:(t.$isTextNode(e)&&(m&&e.toggleFormat("bold"),p&&e.toggleFormat("strikethrough"),C&&e.toggleFormat("italic"),S&&e.toggleFormat("underline")),n.append(e),n)}return e},node:u}}function a(e=r.NO_STATUS,n=1,o){return t.$applyNodeReplacement(new l(e,n,o))}function c(e){return e instanceof l}const u=t.createCommand("INSERT_TABLE_COMMAND");function d(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var h=d((function(e){const t=new URLSearchParams;t.append("code",e);for(let e=1;e<arguments.length;e++)t.append("v",arguments[e]);throw Error(`Minified Lexical error #${e}; visit https://lexical.dev/docs/error?${t} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}));class g extends t.ElementNode{static getType(){return"tablerow"}static clone(e){return new g(e.__height,e.__key)}static importDOM(){return{tr:e=>({conversion:f,priority:0})}}static importJSON(e){return m().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setHeight(e.height)}constructor(e,t){super(t),this.__height=e}exportJSON(){const e=this.getHeight();return{...super.exportJSON(),...void 0===e?void 0:{height:e}}}createDOM(t){const n=document.createElement("tr");return this.__height&&(n.style.height=`${this.__height}px`),e.addClassNamesToElement(n,t.theme.tableRow),n}extractWithChild(e,t,n){return"html"===n}isShadowRoot(){return!0}setHeight(e){const t=this.getWritable();return t.__height=e,t}getHeight(){return this.getLatest().__height}updateDOM(e){return e.__height!==this.__height}canBeEmpty(){return!1}canIndent(){return!1}}function f(t){const n=t;let r;return o.test(n.style.height)&&(r=parseFloat(n.style.height)),{after:t=>e.$descendantsMatching(t,c),node:m(r)}}function m(e){return t.$applyNodeReplacement(new g(e))}function p(e){return e instanceof g}const C="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,S=C&&"documentMode"in document?document.documentMode:null,_=C&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);function N(e,n,o=!0){const l=$e();for(let i=0;i<e;i++){const e=m();for(let l=0;l<n;l++){let n=r.NO_STATUS;"object"==typeof o?(0===i&&o.rows&&(n|=r.ROW),0===l&&o.columns&&(n|=r.COLUMN)):o&&(0===i&&(n|=r.ROW),0===l&&(n|=r.COLUMN));const s=a(n),c=t.$createParagraphNode();c.append(t.$createTextNode()),s.append(c),e.append(s)}l.append(e)}return l}function b(t){const n=e.$findMatchingParent(t,(e=>p(e)));if(p(n))return n;throw new Error("Expected table cell to be inside of table row.")}function w(t){const n=e.$findMatchingParent(t,(e=>Me(e)));if(Me(n))return n;throw new Error("Expected table cell to be inside of table.")}function T(e,t){const n=w(e),{x:o,y:r}=n.getCordsFromCellNode(e,t);return{above:n.getCellNodeFromCords(o,r-1,t),below:n.getCellNodeFromCords(o,r+1,t),left:n.getCellNodeFromCords(o-1,r,t),right:n.getCellNodeFromCords(o+1,r,t)}}C&&"InputEvent"in window&&!S&&new window.InputEvent("input");const y=(e,t)=>e===r.BOTH||e===t?t:r.NO_STATUS;function $(e){const t=e.getFirstDescendant();null==t?e.selectStart():t.getParentOrThrow().selectStart()}function M(e,t){const n=e.getFirstChild();null!==n?n.insertBefore(t):e.append(t)}function R(e,t,n){const[o,r,l]=x(e,t,n);return null===r&&h(207),null===l&&h(208),[o,r,l]}function x(e,t,n){const o=[];let r=null,l=null;function i(e){let t=o[e];return void 0===t&&(o[e]=t=[]),t}const s=e.getChildren();for(let e=0;e<s.length;e++){const o=s[e];p(o)||h(209);const a=i(e);for(let u=o.getFirstChild(),d=0;null!=u;u=u.getNextSibling()){for(c(u)||h(147);void 0!==a[d];)d++;const o={cell:u,startColumn:d,startRow:e},{__rowSpan:g,__colSpan:f}=u;for(let t=0;t<g&&!(e+t>=s.length);t++){const n=i(e+t);for(let e=0;e<f;e++)n[d+e]=o}null!==t&&null===r&&t.is(u)&&(r=o),null!==n&&null===l&&n.is(u)&&(l=o)}}return[o,r,l]}function O(t){let n;if(t instanceof l)n=t;else if("__type"in t){const o=e.$findMatchingParent(t,c);c(o)||h(148),n=o}else{const o=e.$findMatchingParent(t.getNode(),c);c(o)||h(148),n=o}const o=n.getParent();p(o)||h(149);const r=o.getParent();return Me(r)||h(210),[n,o,r]}function E(e,t,n){let o=Math.min(t.startColumn,n.startColumn),r=Math.min(t.startRow,n.startRow),l=Math.max(t.startColumn+t.cell.__colSpan-1,n.startColumn+n.cell.__colSpan-1),i=Math.max(t.startRow+t.cell.__rowSpan-1,n.startRow+n.cell.__rowSpan-1),s=o,a=r,c=o,u=r;function d(e){const{cell:t,startColumn:n,startRow:s}=e;o=Math.min(o,n),r=Math.min(r,s),l=Math.max(l,n+t.__colSpan-1),i=Math.max(i,s+t.__rowSpan-1)}for(;o<s||r<a||l>c||i>u;){if(o<s){const t=u-a,n=s-1;for(let o=0;o<=t;o++)d(e[a+o][n]);s=n}if(r<a){const t=c-s,n=a-1;for(let o=0;o<=t;o++)d(e[n][s+o]);a=n}if(l>c){const t=u-a,n=c+1;for(let o=0;o<=t;o++)d(e[a+o][n]);c=n}if(i>u){const t=c-s,n=u+1;for(let o=0;o<=t;o++)d(e[n][s+o]);u=n}}return{maxColumn:l,maxRow:i,minColumn:o,minRow:r}}function A(e){const[t,,n]=O(e),o=n.getChildren(),r=o.length,l=o[0].getChildren().length,i=new Array(r);for(let e=0;e<r;e++)i[e]=new Array(l);for(let e=0;e<r;e++){const n=o[e].getChildren();let r=0;for(let o=0;o<n.length;o++){for(;i[e][r];)r++;const l=n[o],s=l.__rowSpan||1,a=l.__colSpan||1;for(let t=0;t<s;t++)for(let n=0;n<a;n++)i[e+t][r+n]=l;if(t===l)return{colSpan:a,columnIndex:r,rowIndex:e,rowSpan:s};r+=a}}return null}function v(t){const[[n,o,r,l],[i,s,a,u]]=["anchor","focus"].map((n=>{const o=t[n].getNode(),r=e.$findMatchingParent(o,c);c(r)||h(238,n,o.getKey(),o.getType());const l=r.getParent();p(l)||h(239,n);const i=l.getParent();return Me(i)||h(240,n),[o,r,l,i]}));return l.is(u)||h(241),{anchorCell:o,anchorNode:n,anchorRow:r,anchorTable:l,focusCell:s,focusNode:i,focusRow:a,focusTable:u}}class F{constructor(e,t,n){this.anchor=t,this.focus=n,t._selection=this,n._selection=this,this._cachedNodes=null,this.dirty=!1,this.tableKey=e}getStartEndPoints(){return[this.anchor,this.focus]}isValid(){return"root"!==this.tableKey&&"root"!==this.anchor.key&&"element"===this.anchor.type&&"root"!==this.focus.key&&"element"===this.focus.type}isBackward(){return this.focus.isBefore(this.anchor)}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e}is(e){return P(e)&&this.tableKey===e.tableKey&&this.anchor.is(e.anchor)&&this.focus.is(e.focus)}set(e,t,n){this.dirty=this.dirty||e!==this.tableKey||t!==this.anchor.key||n!==this.focus.key,this.tableKey=e,this.anchor.key=t,this.focus.key=n,this._cachedNodes=null}clone(){return new F(this.tableKey,t.$createPoint(this.anchor.key,this.anchor.offset,this.anchor.type),t.$createPoint(this.focus.key,this.focus.offset,this.focus.type))}isCollapsed(){return!1}extract(){return this.getNodes()}insertRawText(e){}insertText(){}hasFormat(e){let n=0;this.getNodes().filter(c).forEach((e=>{const o=e.getFirstChild();t.$isParagraphNode(o)&&(n|=o.getTextFormat())}));const o=t.TEXT_TYPE_TO_FORMAT[e];return!!(n&o)}insertNodes(e){const n=this.focus.getNode();t.$isElementNode(n)||h(151);t.$normalizeSelection__EXPERIMENTAL(n.select(0,n.getChildrenSize())).insertNodes(e)}getShape(){const{anchorCell:e,focusCell:t}=v(this),n=A(e);null===n&&h(153);const o=A(t);null===o&&h(155);const r=Math.min(n.columnIndex,o.columnIndex),l=Math.max(n.columnIndex+n.colSpan-1,o.columnIndex+o.colSpan-1),i=Math.min(n.rowIndex,o.rowIndex),s=Math.max(n.rowIndex+n.rowSpan-1,o.rowIndex+o.rowSpan-1);return{fromX:Math.min(r,l),fromY:Math.min(i,s),toX:Math.max(r,l),toY:Math.max(i,s)}}getNodes(){if(!this.isValid())return[];const e=this._cachedNodes;if(null!==e)return e;const{anchorTable:n,anchorCell:o,focusCell:r}=v(this),l=r.getParents()[1];if(l!==n){if(n.isParentOf(r)){const e=l.getParent();null==e&&h(159),this.set(this.tableKey,r.getKey(),e.getKey())}else{const e=n.getParent();null==e&&h(158),this.set(this.tableKey,e.getKey(),r.getKey())}return this.getNodes()}const[i,s,a]=R(n,o,r),{minColumn:c,maxColumn:u,minRow:d,maxRow:g}=E(i,s,a),f=new Map([[n.getKey(),n]]);let m=null;for(let e=d;e<=g;e++)for(let t=c;t<=u;t++){const{cell:n}=i[e][t],o=n.getParent();p(o)||h(160),o!==m&&(f.set(o.getKey(),o),m=o),f.has(n.getKey())||I(n,(e=>{f.set(e.getKey(),e)}))}const C=Array.from(f.values());return t.isCurrentlyReadOnlyMode()||(this._cachedNodes=C),C}getTextContent(){const e=this.getNodes().filter((e=>c(e)));let t="";for(let n=0;n<e.length;n++){const o=e[n],r=o.__parent,l=(e[n+1]||{}).__parent;t+=o.getTextContent()+(l!==r?"\n":"\t")}return t}}function P(e){return e instanceof F}function D(){const e=t.$createPoint("root",0,"element"),n=t.$createPoint("root",0,"element");return new F("root",e,n)}function K(e,n,o){e.getKey(),n.getKey(),o.getKey();const r=t.$getSelection(),l=P(r)?r.clone():D();return l.set(e.getKey(),n.getKey(),o.getKey()),l}function I(e,n){const o=[[e]];for(let e=o.at(-1);void 0!==e&&o.length>0;e=o.at(-1)){const r=e.pop();void 0===r?o.pop():!1!==n(r)&&t.$isElementNode(r)&&o.push(r.getChildren())}}function k(e,n=t.$getEditor()){const o=t.$getNodeByKey(e);Me(o)||h(231,e);const r=B(o,n.getElementByKey(e));return null===r&&h(232,e),{tableElement:r,tableNode:o}}class L{constructor(e,t){this.isHighlightingCells=!1,this.anchorX=-1,this.anchorY=-1,this.focusX=-1,this.focusY=-1,this.listenersToRemove=new Set,this.tableNodeKey=t,this.editor=e,this.table={columns:0,domRows:[],rows:0},this.tableSelection=null,this.anchorCellNodeKey=null,this.focusCellNodeKey=null,this.anchorCell=null,this.focusCell=null,this.hasHijackedSelectionStyles=!1,this.isSelecting=!1,this.shouldCheckSelection=!1,this.abortController=new AbortController,this.listenerOptions={signal:this.abortController.signal},this.nextFocus=null,this.trackTable()}getTable(){return this.table}removeListeners(){this.abortController.abort("removeListeners"),Array.from(this.listenersToRemove).forEach((e=>e())),this.listenersToRemove.clear()}$lookup(){return k(this.tableNodeKey,this.editor)}trackTable(){const e=new MutationObserver((e=>{this.editor.getEditorState().read((()=>{let t=!1;for(let n=0;n<e.length;n++){const o=e[n].target.nodeName;if("TABLE"===o||"TBODY"===o||"THEAD"===o||"TR"===o){t=!0;break}}if(!t)return;const{tableNode:n,tableElement:o}=this.$lookup();this.table=V(n,o)}),{editor:this.editor})}));this.editor.getEditorState().read((()=>{const{tableNode:t,tableElement:n}=this.$lookup();this.table=V(t,n),e.observe(n,{attributes:!0,childList:!0,subtree:!0})}),{editor:this.editor})}$clearHighlight(){const e=this.editor;this.isHighlightingCells=!1,this.anchorX=-1,this.anchorY=-1,this.focusX=-1,this.focusY=-1,this.tableSelection=null,this.anchorCellNodeKey=null,this.focusCellNodeKey=null,this.anchorCell=null,this.focusCell=null,this.hasHijackedSelectionStyles=!1,this.$enableHighlightStyle();const{tableNode:n,tableElement:o}=this.$lookup();Q(e,V(n,o),null),null!==t.$getSelection()&&(t.$setSelection(null),e.dispatchCommand(t.SELECTION_CHANGE_COMMAND,void 0))}$enableHighlightStyle(){const t=this.editor,{tableElement:n}=this.$lookup();e.removeClassNamesFromElement(n,t._config.theme.tableSelection),n.classList.remove("disable-selection"),this.hasHijackedSelectionStyles=!1}$disableHighlightStyle(){const{tableElement:t}=this.$lookup();e.addClassNamesToElement(t,this.editor._config.theme.tableSelection),this.hasHijackedSelectionStyles=!0}$updateTableTableSelection(e){if(null!==e){e.tableKey!==this.tableNodeKey&&h(233,e.tableKey,this.tableNodeKey);const t=this.editor;this.tableSelection=e,this.isHighlightingCells=!0,this.$disableHighlightStyle(),this.updateDOMSelection(),Q(t,this.table,this.tableSelection)}else this.$clearHighlight()}setShouldCheckSelection(){this.shouldCheckSelection=!0}getAndClearShouldCheckSelection(){return!!this.shouldCheckSelection&&(this.shouldCheckSelection=!1,!0)}setNextFocus(e){this.nextFocus=e}getAndClearNextFocus(){const{nextFocus:e}=this;return null!==e&&(this.nextFocus=null),e}updateDOMSelection(){if(null!==this.anchorCell&&null!==this.focusCell){const e=t.getDOMSelection(this.editor._window);e&&e.rangeCount>0&&e.removeAllRanges()}}$setFocusCellForSelection(e,n=!1){const o=this.editor,{tableNode:r}=this.$lookup(),l=e.x,i=e.y;if(this.focusCell=e,this.isHighlightingCells||this.anchorX===l&&this.anchorY===i&&!n){if(l===this.focusX&&i===this.focusY)return!1}else this.isHighlightingCells=!0,this.$disableHighlightStyle();if(this.focusX=l,this.focusY=i,this.isHighlightingCells){const n=Ce(r,e.elem);if(null!=this.tableSelection&&null!=this.anchorCellNodeKey&&null!==n)return this.focusCellNodeKey=n.getKey(),this.tableSelection=K(r,this.$getAnchorTableCellOrThrow(),n),t.$setSelection(this.tableSelection),o.dispatchCommand(t.SELECTION_CHANGE_COMMAND,void 0),Q(o,this.table,this.tableSelection),!0}return!1}$getAnchorTableCell(){return this.anchorCellNodeKey?t.$getNodeByKey(this.anchorCellNodeKey):null}$getAnchorTableCellOrThrow(){const e=this.$getAnchorTableCell();return null===e&&h(234),e}$getFocusTableCell(){return this.focusCellNodeKey?t.$getNodeByKey(this.focusCellNodeKey):null}$getFocusTableCellOrThrow(){const e=this.$getFocusTableCell();return null===e&&h(235),e}$setAnchorCellForSelection(e){this.isHighlightingCells=!1,this.anchorCell=e,this.anchorX=e.x,this.anchorY=e.y;const{tableNode:t}=this.$lookup(),n=Ce(t,e.elem);if(null!==n){const e=n.getKey();this.tableSelection=null!=this.tableSelection?this.tableSelection.clone():D(),this.anchorCellNodeKey=e}}$formatCells(e){const n=t.$getSelection();P(n)||h(236);const o=t.$createRangeSelection(),r=o.anchor,l=o.focus,i=n.getNodes().filter(c);i.length>0||h(237);const s=i[0].getFirstChild(),a=t.$isParagraphNode(s)?s.getFormatFlags(e,null):null;i.forEach((t=>{r.set(t.getKey(),0,"element"),l.set(t.getKey(),t.getChildrenSize(),"element"),o.formatText(e,a)})),t.$setSelection(n),this.editor.dispatchCommand(t.SELECTION_CHANGE_COMMAND,void 0)}$clearText(){const{editor:e}=this,n=t.$getNodeByKey(this.tableNodeKey);if(!Me(n))throw new Error("Expected TableNode.");const o=t.$getSelection();P(o)||h(253);const r=o.getNodes().filter(c);if(r.length===this.table.columns*this.table.rows)return n.selectPrevious(),void n.remove();r.forEach((e=>{if(t.$isElementNode(e)){const n=t.$createParagraphNode(),o=t.$createTextNode();n.append(o),e.append(n),e.getChildren().forEach((e=>{e!==n&&e.remove()}))}})),Q(e,this.table,null),t.$setSelection(null),e.dispatchCommand(t.SELECTION_CHANGE_COMMAND,void 0)}}const H="__lexicalTableSelection",W=e=>!(1&~e.buttons);function B(e,t){if(!t)return t;const n="TABLE"===t.nodeName?t:e.getDOMSlot(t).element;return"TABLE"!==n.nodeName&&h(245,t.nodeName),n}function Y(e){return e._window}function U(e,t){for(let n=t,o=null;null!==n;n=n.getParent()){if(e.is(n))return o;c(n)&&(o=n)}return null}const X=[[t.KEY_ARROW_DOWN_COMMAND,"down"],[t.KEY_ARROW_UP_COMMAND,"up"],[t.KEY_ARROW_LEFT_COMMAND,"backward"],[t.KEY_ARROW_RIGHT_COMMAND,"forward"]],J=[t.DELETE_WORD_COMMAND,t.DELETE_LINE_COMMAND,t.DELETE_CHARACTER_COMMAND],q=[t.KEY_BACKSPACE_COMMAND,t.KEY_DELETE_COMMAND];function z(o,r,l,i){const s=l.getRootElement(),a=Y(l);null!==s&&null!==a||h(246);const u=new L(l,o.getKey()),d=B(o,r);!function(e,t){null!==G(e)&&h(205);e[H]=t}(d,u),u.listenersToRemove.add((()=>function(e,t){G(e)===t&&delete e[H]}(d,u)));d.addEventListener("mousedown",(e=>{if(0!==e.button||!t.isDOMNode(e.target)||!a)return;const n=j(e.target);null!==n&&l.update((()=>{const r=t.$getPreviousSelection();if(_&&e.shiftKey&&ie(r,o)&&(t.$isRangeSelection(r)||P(r))){const t=r.anchor.getNode(),l=U(o,r.anchor.getNode());if(l)u.$setAnchorCellForSelection(pe(u,l)),u.$setFocusCellForSelection(n),ge(e);else{(o.isBefore(t)?o.selectStart():o.selectEnd()).anchor.set(r.anchor.key,r.anchor.offset,r.anchor.type)}}else u.$setAnchorCellForSelection(n)})),(()=>{if(u.isSelecting)return;const e=()=>{u.isSelecting=!1,a.removeEventListener("mouseup",e),a.removeEventListener("mousemove",n)},n=o=>{if(!t.isDOMNode(o.target))return;if(!W(o)&&u.isSelecting)return u.isSelecting=!1,a.removeEventListener("mouseup",e),void a.removeEventListener("mousemove",n);const r=!d.contains(o.target);let i=null;if(r){for(const e of document.elementsFromPoint(o.clientX,o.clientY))if(i=d.contains(e)?j(e):null,i)break}else i=j(o.target);!i||null!==u.focusCell&&i.elem===u.focusCell.elem||(u.setNextFocus({focusCell:i,override:r}),l.dispatchCommand(t.SELECTION_CHANGE_COMMAND,void 0))};u.isSelecting=!0,a.addEventListener("mouseup",e,u.listenerOptions),a.addEventListener("mousemove",n,u.listenerOptions)})()}),u.listenerOptions);a.addEventListener("mousedown",(e=>{const n=e.target;0===e.button&&t.isDOMNode(n)&&l.update((()=>{const e=t.$getSelection();P(e)&&e.tableKey===u.tableNodeKey&&s.contains(n)&&u.$clearHighlight()}))}),u.listenerOptions);for(const[e,n]of X)u.listenersToRemove.add(l.registerCommand(e,(e=>he(l,e,n,o,u)),t.COMMAND_PRIORITY_HIGH));u.listenersToRemove.add(l.registerCommand(t.KEY_ESCAPE_COMMAND,(e=>{const n=t.$getSelection();if(P(n)){const t=U(o,n.focus.getNode());if(null!==t)return ge(e),t.selectEnd(),!0}return!1}),t.COMMAND_PRIORITY_HIGH));const g=n=>()=>{const r=t.$getSelection();if(!ie(r,o))return!1;if(P(r))return u.$clearText(),!0;if(t.$isRangeSelection(r)){if(!c(U(o,r.anchor.getNode())))return!1;const l=r.anchor.getNode(),i=r.focus.getNode(),s=o.isParentOf(l),a=o.isParentOf(i);if(s&&!a||a&&!s)return u.$clearText(),!0;const d=e.$findMatchingParent(r.anchor.getNode(),(e=>t.$isElementNode(e))),h=d&&e.$findMatchingParent(d,(e=>t.$isElementNode(e)&&c(e.getParent())));if(!t.$isElementNode(h)||!t.$isElementNode(d))return!1;if(n===t.DELETE_LINE_COMMAND&&null===h.getPreviousSibling())return!0}return!1};for(const e of J)u.listenersToRemove.add(l.registerCommand(e,g(e),t.COMMAND_PRIORITY_CRITICAL));const f=e=>{const n=t.$getSelection();if(!P(n)&&!t.$isRangeSelection(n))return!1;const r=o.isParentOf(n.anchor.getNode());if(r!==o.isParentOf(n.focus.getNode())){const e=r?"anchor":"focus",t=r?"focus":"anchor",{key:l,offset:i,type:s}=n[t];return o[n[e].isBefore(n[t])?"selectPrevious":"selectNext"]()[t].set(l,i,s),!1}return!!ie(n,o)&&(!!P(n)&&(e&&(e.preventDefault(),e.stopPropagation()),u.$clearText(),!0))};for(const e of q)u.listenersToRemove.add(l.registerCommand(e,f,t.COMMAND_PRIORITY_CRITICAL));return u.listenersToRemove.add(l.registerCommand(t.CUT_COMMAND,(o=>{const r=t.$getSelection();if(r){if(!P(r)&&!t.$isRangeSelection(r))return!1;n.copyToClipboard(l,e.objectKlassEquals(o,ClipboardEvent)?o:null,n.$getClipboardDataFromSelection(r));const i=f(o);return t.$isRangeSelection(r)?(r.removeText(),!0):i}return!1}),t.COMMAND_PRIORITY_CRITICAL)),u.listenersToRemove.add(l.registerCommand(t.FORMAT_TEXT_COMMAND,(n=>{const r=t.$getSelection();if(!ie(r,o))return!1;if(P(r))return u.$formatCells(n),!0;if(t.$isRangeSelection(r)){const t=e.$findMatchingParent(r.anchor.getNode(),(e=>c(e)));if(!c(t))return!1}return!1}),t.COMMAND_PRIORITY_CRITICAL)),u.listenersToRemove.add(l.registerCommand(t.FORMAT_ELEMENT_COMMAND,(e=>{const n=t.$getSelection();if(!P(n)||!ie(n,o))return!1;const r=n.anchor.getNode(),l=n.focus.getNode();if(!c(r)||!c(l))return!1;if(function(e,t){if(P(e)){const n=e.anchor.getNode(),o=e.focus.getNode();if(t&&n&&o){const[e]=R(t,n,o);return n.getKey()===e[0][0].cell.getKey()&&o.getKey()===e[e.length-1].at(-1).cell.getKey()}}return!1}(n,o))return o.setFormat(e),!0;const[i,s,a]=R(o,r,l),u=Math.max(s.startRow+s.cell.__rowSpan-1,a.startRow+a.cell.__rowSpan-1),d=Math.max(s.startColumn+s.cell.__colSpan-1,a.startColumn+a.cell.__colSpan-1),h=Math.min(s.startRow,a.startRow),g=Math.min(s.startColumn,a.startColumn),f=new Set;for(let n=h;n<=u;n++)for(let o=g;o<=d;o++){const r=i[n][o].cell;if(f.has(r))continue;f.add(r),r.setFormat(e);const l=r.getChildren();for(let n=0;n<l.length;n++){const o=l[n];t.$isElementNode(o)&&!o.isInline()&&o.setFormat(e)}}return!0}),t.COMMAND_PRIORITY_CRITICAL)),u.listenersToRemove.add(l.registerCommand(t.CONTROLLED_TEXT_INSERTION_COMMAND,(n=>{const r=t.$getSelection();if(!ie(r,o))return!1;if(P(r))return u.$clearHighlight(),!1;if(t.$isRangeSelection(r)){const i=e.$findMatchingParent(r.anchor.getNode(),(e=>c(e)));if(!c(i))return!1;if("string"==typeof n){const e=me(l,r,o);if(e)return fe(e,o,[t.$createTextNode(n)]),!0}}return!1}),t.COMMAND_PRIORITY_CRITICAL)),i&&u.listenersToRemove.add(l.registerCommand(t.KEY_TAB_COMMAND,(n=>{const r=t.$getSelection();if(!t.$isRangeSelection(r)||!r.isCollapsed()||!ie(r,o))return!1;const l=ue(r.anchor.getNode());return!(null===l||!o.is(de(l)))&&(ge(n),function(n,o){const r="next"===o?"getNextSibling":"getPreviousSibling",l="next"===o?"getFirstChild":"getLastChild",i=n[r]();if(t.$isElementNode(i))return i.selectEnd();const s=e.$findMatchingParent(n,p);null===s&&h(247);for(let e=s[r]();p(e);e=e[r]()){const n=e[l]();if(t.$isElementNode(n))return n.selectEnd()}const a=e.$findMatchingParent(s,Me);null===a&&h(248);"next"===o?a.selectNext():a.selectPrevious()}(l,n.shiftKey?"previous":"next"),!0)}),t.COMMAND_PRIORITY_CRITICAL)),u.listenersToRemove.add(l.registerCommand(t.FOCUS_COMMAND,(e=>o.isSelected()),t.COMMAND_PRIORITY_HIGH)),u.listenersToRemove.add(l.registerCommand(t.SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,(n=>{const{nodes:o,selection:r}=n,l=r.getStartEndPoints(),i=P(r),s=t.$isRangeSelection(r)&&null!==e.$findMatchingParent(r.anchor.getNode(),(e=>c(e)))&&null!==e.$findMatchingParent(r.focus.getNode(),(e=>c(e)))||i;if(1!==o.length||!Me(o[0])||!s||null===l)return!1;const[a]=l,u=o[0],d=u.getChildren(),h=u.getFirstChildOrThrow().getChildrenSize(),g=u.getChildrenSize(),f=e.$findMatchingParent(a.getNode(),(e=>c(e))),m=f&&e.$findMatchingParent(f,(e=>p(e))),C=m&&e.$findMatchingParent(m,(e=>Me(e)));if(!c(f)||!p(m)||!Me(C))return!1;const S=m.getIndexWithinParent(),_=Math.min(C.getChildrenSize()-1,S+g-1),N=f.getIndexWithinParent(),b=Math.min(m.getChildrenSize()-1,N+h-1),w=Math.min(N,b),T=Math.min(S,_),y=Math.max(N,b),$=Math.max(S,_),M=C.getChildren();let R=0;for(let e=T;e<=$;e++){const n=M[e];if(!p(n))return!1;const o=d[R];if(!p(o))return!1;const r=n.getChildren(),l=o.getChildren();let i=0;for(let e=w;e<=y;e++){const n=r[e];if(!c(n))return!1;const o=l[i];if(!c(o))return!1;const s=n.getChildren();o.getChildren().forEach((e=>{if(t.$isTextNode(e)){t.$createParagraphNode().append(e),n.append(e)}else n.append(e)})),s.forEach((e=>e.remove())),i++}R++}return!0}),t.COMMAND_PRIORITY_CRITICAL)),u.listenersToRemove.add(l.registerCommand(t.SELECTION_CHANGE_COMMAND,(()=>{const n=t.$getSelection(),r=t.$getPreviousSelection(),i=u.getAndClearNextFocus();if(null!==i){const{focusCell:e}=i;if(P(n)&&n.tableKey===u.tableNodeKey)return(e.x!==u.focusX||e.y!==u.focusY)&&(u.$setFocusCellForSelection(e),!0);if(e!==u.anchorCell&&ie(n,o))return u.$setFocusCellForSelection(e),!0}if(u.getAndClearShouldCheckSelection()&&t.$isRangeSelection(r)&&t.$isRangeSelection(n)&&n.isCollapsed()){const t=n.anchor.getNode(),r=o.getFirstChild(),l=ue(t);if(null!==l&&p(r)){const t=r.getFirstChild();if(c(t)&&o.is(e.$findMatchingParent(l,(e=>e.is(o)||e.is(t)))))return t.selectStart(),!0}}if(t.$isRangeSelection(n)){const{anchor:e,focus:r}=n,i=e.getNode(),s=r.getNode(),a=ue(i),c=ue(s),d=!(!a||!o.is(de(a))),h=!(!c||!o.is(de(c))),g=d!==h,f=d&&h,m=n.isBackward();if(g){const e=n.clone();if(h){const[t]=R(o,c,c),n=t[0][0].cell,r=t[t.length-1].at(-1).cell;e.focus.set(m?n.getKey():r.getKey(),m?n.getChildrenSize():r.getChildrenSize(),"element")}else if(d){const[t]=R(o,a,a),n=t[0][0].cell,r=t[t.length-1].at(-1).cell;e.anchor.set(m?r.getKey():n.getKey(),m?r.getChildrenSize():0,"element")}t.$setSelection(e),ee(l,u)}else f&&(a.is(c)||(u.$setAnchorCellForSelection(pe(u,a)),u.$setFocusCellForSelection(pe(u,c),!0)))}else if(n&&P(n)&&n.is(r)&&n.tableKey===o.getKey()){const e=t.getDOMSelection(a);if(e&&e.anchorNode&&e.focusNode){const r=t.$getNearestNodeFromDOMNode(e.focusNode),i=r&&!o.isParentOf(r),s=t.$getNearestNodeFromDOMNode(e.anchorNode),a=s&&o.isParentOf(s);if(i&&a&&e.rangeCount>0){const r=t.$createRangeSelectionFromDom(e,l);r&&(r.anchor.set(o.getKey(),n.isBackward()?o.getChildrenSize():0,"element"),e.removeAllRanges(),t.$setSelection(r))}}}return n&&!n.is(r)&&(P(n)||P(r))&&u.tableSelection&&!u.tableSelection.is(r)?(P(n)&&n.tableKey===u.tableNodeKey?u.$updateTableTableSelection(n):!P(n)&&P(r)&&r.tableKey===u.tableNodeKey&&u.$updateTableTableSelection(null),!1):(u.hasHijackedSelectionStyles&&!o.isSelected()?function(e,t){t.$enableHighlightStyle(),Z(t.table,(t=>{const n=t.elem;t.highlighted=!1,ce(e,t),n.getAttribute("style")||n.removeAttribute("style")}))}(l,u):!u.hasHijackedSelectionStyles&&o.isSelected()&&ee(l,u),!1)}),t.COMMAND_PRIORITY_CRITICAL)),u.listenersToRemove.add(l.registerCommand(t.INSERT_PARAGRAPH_COMMAND,(()=>{const e=t.$getSelection();if(!t.$isRangeSelection(e)||!e.isCollapsed()||!ie(e,o))return!1;const n=me(l,e,o);return!!n&&(fe(n,o),!0)}),t.COMMAND_PRIORITY_CRITICAL)),u}function G(e){return e[H]||null}function j(e){let t=e;for(;null!=t;){const e=t.nodeName;if("TD"===e||"TH"===e){const e=t._cell;return void 0===e?null:e}t=t.parentNode}return null}function V(e,t){const n=[],o={columns:0,domRows:n,rows:0};let r=B(e,t).querySelector("tr"),l=0,i=0;for(n.length=0;null!=r;){const e=r.nodeName;if("TD"===e||"TH"===e){const e={elem:r,hasBackgroundColor:""!==r.style.backgroundColor,highlighted:!1,x:l,y:i};r._cell=e;let t=n[i];void 0===t&&(t=n[i]=[]),t[l]=e}else{const e=r.firstChild;if(null!=e){r=e;continue}}const t=r.nextSibling;if(null!=t){l++,r=t;continue}const o=r.parentNode;if(null!=o){const e=o.nextSibling;if(null==e)break;i++,l=0,r=e}}return o.columns=l+1,o.rows=i+1,o}function Q(e,t,n){const o=new Set(n?n.getNodes():[]);Z(t,((t,n)=>{const r=t.elem;o.has(n)?(t.highlighted=!0,ae(e,t)):(t.highlighted=!1,ce(e,t),r.getAttribute("style")||r.removeAttribute("style"))}))}function Z(e,n){const{domRows:o}=e;for(let e=0;e<o.length;e++){const r=o[e];if(r)for(let o=0;o<r.length;o++){const l=r[o];if(!l)continue;const i=t.$getNearestNodeFromDOMNode(l.elem);null!==i&&n(l,i,{x:o,y:e})}}}function ee(e,t){t.$disableHighlightStyle(),Z(t.table,(t=>{t.highlighted=!0,ae(e,t)}))}const te=(e,t,n,o,r)=>{const l="forward"===r;switch(r){case"backward":case"forward":return n!==(l?e.table.columns-1:0)?se(t.getCellNodeFromCordsOrThrow(n+(l?1:-1),o,e.table),l):o!==(l?e.table.rows-1:0)?se(t.getCellNodeFromCordsOrThrow(l?0:e.table.columns-1,o+(l?1:-1),e.table),l):l?t.selectNext():t.selectPrevious(),!0;case"up":return 0!==o?se(t.getCellNodeFromCordsOrThrow(n,o-1,e.table),!1):t.selectPrevious(),!0;case"down":return o!==e.table.rows-1?se(t.getCellNodeFromCordsOrThrow(n,o+1,e.table),!0):t.selectNext(),!0;default:return!1}};function ne(e,t){let n,o;if(t.startColumn===e.minColumn)n="minColumn";else{if(t.startColumn+t.cell.__colSpan-1!==e.maxColumn)return null;n="maxColumn"}if(t.startRow===e.minRow)o="minRow";else{if(t.startRow+t.cell.__rowSpan-1!==e.maxRow)return null;o="maxRow"}return[n,o]}function oe([e,t]){return["minColumn"===e?"maxColumn":"minColumn","minRow"===t?"maxRow":"minRow"]}function re(e,t,[n,o]){const r=t[o],l=e[r];void 0===l&&h(250,o,String(r));const i=t[n],s=l[i];return void 0===s&&h(250,n,String(i)),s}function le(e,t,n,o,r){const l=E(t,n,o),i=function(e,t){const{minColumn:n,maxColumn:o,minRow:r,maxRow:l}=t;let i=1,s=1,a=1,c=1;const u=e[r],d=e[l];for(let e=n;e<=o;e++)i=Math.max(i,u[e].cell.__rowSpan),c=Math.max(c,d[e].cell.__rowSpan);for(let t=r;t<=l;t++)s=Math.max(s,e[t][n].cell.__colSpan),a=Math.max(a,e[t][o].cell.__colSpan);return{bottomSpan:c,leftSpan:s,rightSpan:a,topSpan:i}}(t,l),{topSpan:s,leftSpan:a,bottomSpan:c,rightSpan:u}=i,d=function(e,t){const n=ne(e,t);return null===n&&h(249,t.cell.getKey()),n}(l,n),[g,f]=oe(d);let m=l[g],p=l[f];"forward"===r?m+="maxColumn"===g?1:a:"backward"===r?m-="minColumn"===g?1:u:"down"===r?p+="maxRow"===f?1:s:"up"===r&&(p-="minRow"===f?1:c);const C=t[p];if(void 0===C)return!1;const S=C[m];if(void 0===S)return!1;const[_,N]=function(e,t,n){const o=E(e,t,n),r=ne(o,t);if(r)return[re(e,o,r),re(e,o,oe(r))];const l=ne(o,n);if(l)return[re(e,o,oe(l)),re(e,o,l)];const i=["minColumn","minRow"];return[re(e,o,i),re(e,o,oe(i))]}(t,n,S),b=pe(e,_.cell),w=pe(e,N.cell);return e.$setAnchorCellForSelection(b),e.$setFocusCellForSelection(w,!0),!0}function ie(e,n){if(t.$isRangeSelection(e)||P(e)){const t=n.isParentOf(e.anchor.getNode()),o=n.isParentOf(e.focus.getNode());return t&&o}return!1}function se(e,t){t?e.selectStart():e.selectEnd()}function ae(n,o){const r=o.elem,l=n._config.theme;c(t.$getNearestNodeFromDOMNode(r))||h(131),e.addClassNamesToElement(r,l.tableCellSelected)}function ce(n,o){const r=o.elem;c(t.$getNearestNodeFromDOMNode(r))||h(131);const l=n._config.theme;e.removeClassNamesFromElement(r,l.tableCellSelected)}function ue(t){const n=e.$findMatchingParent(t,c);return c(n)?n:null}function de(t){const n=e.$findMatchingParent(t,Me);return Me(n)?n:null}function he(n,o,r,l,i){if(("up"===r||"down"===r)&&function(e){const t=e.getRootElement();if(!t)return!1;return t.hasAttribute("aria-controls")&&"typeahead-menu"===t.getAttribute("aria-controls")}(n))return!1;const s=t.$getSelection();if(!ie(s,l)){if(t.$isRangeSelection(s)){if("backward"===r){if(s.focus.offset>0)return!1;const e=function(e){for(let n=e,o=e;null!==o;n=o,o=o.getParent())if(t.$isElementNode(o)){if(o!==n&&o.getFirstChild()!==n)return null;if(!o.isInline())return o}return null}(s.focus.getNode());if(!e)return!1;const n=e.getPreviousSibling();return!!Me(n)&&(ge(o),o.shiftKey?s.focus.set(n.getParentOrThrow().getKey(),n.getIndexWithinParent(),"element"):n.selectEnd(),!0)}if(o.shiftKey&&("up"===r||"down"===r)){const n=s.focus.getNode();if(!s.isCollapsed()&&("up"===r&&!s.isBackward()||"down"===r&&s.isBackward())){let i=e.$findMatchingParent(n,(e=>Me(e)));if(c(i)&&(i=e.$findMatchingParent(i,Me)),i!==l)return!1;if(!i)return!1;const a="down"===r?i.getNextSibling():i.getPreviousSibling();if(!a)return!1;let u=0;"up"===r&&t.$isElementNode(a)&&(u=a.getChildrenSize());let d=a;if("up"===r&&t.$isElementNode(a)){const e=a.getLastChild();d=e||a,u=t.$isTextNode(d)?d.getTextContentSize():0}const h=s.clone();return h.focus.set(d.getKey(),u,t.$isTextNode(d)?"text":"element"),t.$setSelection(h),ge(o),!0}if(t.$isRootOrShadowRoot(n)){const e="up"===r?s.getNodes()[s.getNodes().length-1]:s.getNodes()[0];if(e){if(null!==U(l,e)){const e=l.getFirstDescendant(),t=l.getLastDescendant();if(!e||!t)return!1;const[n]=O(e),[o]=O(t),r=l.getCordsFromCellNode(n,i.table),s=l.getCordsFromCellNode(o,i.table),a=l.getDOMCellFromCordsOrThrow(r.x,r.y,i.table),c=l.getDOMCellFromCordsOrThrow(s.x,s.y,i.table);return i.$setAnchorCellForSelection(a),i.$setFocusCellForSelection(c,!0),!0}}return!1}{let l=e.$findMatchingParent(n,(e=>t.$isElementNode(e)&&!e.isInline()));if(c(l)&&(l=e.$findMatchingParent(l,Me)),!l)return!1;const a="down"===r?l.getNextSibling():l.getPreviousSibling();if(Me(a)&&i.tableNodeKey===a.getKey()){const e=a.getFirstDescendant(),n=a.getLastDescendant();if(!e||!n)return!1;const[l]=O(e),[i]=O(n),c=s.clone();return c.focus.set(("up"===r?l:i).getKey(),"up"===r?0:i.getChildrenSize(),"element"),ge(o),t.$setSelection(c),!0}}}}return"down"===r&&we(n)&&i.setShouldCheckSelection(),!1}if(t.$isRangeSelection(s)&&s.isCollapsed()){const{anchor:a,focus:u}=s,d=e.$findMatchingParent(a.getNode(),c),h=e.$findMatchingParent(u.getNode(),c);if(!c(d)||!d.is(h))return!1;const g=de(d);if(g!==l&&null!=g){const e=B(g,n.getElementByKey(g.getKey()));if(null!=e)return i.table=V(g,e),he(n,o,r,g,i)}if("backward"===r||"forward"===r){const n=a.type,i=a.offset,c=a.getNode();if(!c)return!1;const u=s.getNodes();return(1!==u.length||!t.$isDecoratorNode(u[0]))&&(!!function(n,o,r,l){return function(e,t,n){return"element"===e&&("backward"===n?null===t.getPreviousSibling():null===t.getNextSibling())}(n,r,l)||function(n,o,r,l){const i=e.$findMatchingParent(r,(e=>t.$isElementNode(e)&&!e.isInline()));if(!i)return!1;const s="backward"===l?0===o:o===r.getTextContentSize();return"text"===n&&s&&("backward"===l?null===i.getPreviousSibling():null===i.getNextSibling())}(n,o,r,l)}(n,i,c,r)&&function(n,o,r,l,i){const[s,a]=R(l,r,r);if(!function(e,t,n){const o=e[0][0],r=e[e.length-1][e[0].length-1],{startColumn:l,startRow:i}=t;return"backward"===n?l===o.startColumn&&i===o.startRow:l===r.startColumn&&i===r.startRow}(s,a,i))return!1;const c=function(n,o,r){const l=e.$findMatchingParent(n,(e=>t.$isElementNode(e)&&!e.isInline()));if(!l)return;const i="backward"===o?l.getPreviousSibling():l.getNextSibling();return i&&Me(i)?i:"backward"===o?r.getPreviousSibling():r.getNextSibling()}(o,i,l);if(!c||Me(c))return!1;ge(n),"backward"===i?c.selectEnd():c.selectStart();return!0}(o,c,d,l,r))}const f=n.getElementByKey(d.__key),m=n.getElementByKey(a.key);if(null==m||null==f)return!1;let p;if("element"===a.type)p=m.getBoundingClientRect();else{const e=t.getDOMSelection(Y(n));if(null===e||0===e.rangeCount)return!1;p=e.getRangeAt(0).getBoundingClientRect()}const C="up"===r?d.getFirstChild():d.getLastChild();if(null==C)return!1;const S=n.getElementByKey(C.__key);if(null==S)return!1;const _=S.getBoundingClientRect();if("up"===r?_.top>p.top-p.height:p.bottom+p.height>_.bottom){ge(o);const e=l.getCordsFromCellNode(d,i.table);if(!o.shiftKey)return te(i,l,e.x,e.y,r);{const t=l.getDOMCellFromCordsOrThrow(e.x,e.y,i.table);i.$setAnchorCellForSelection(t),i.$setFocusCellForSelection(t,!0)}return!0}}else if(P(s)){const{anchor:t,focus:a}=s,u=e.$findMatchingParent(t.getNode(),c),d=e.$findMatchingParent(a.getNode(),c),[g]=s.getNodes();Me(g)||h(251);const f=B(g,n.getElementByKey(g.getKey()));if(!c(u)||!c(d)||!Me(g)||null==f)return!1;i.$updateTableTableSelection(s);const m=V(g,f),p=l.getCordsFromCellNode(u,m),C=l.getDOMCellFromCordsOrThrow(p.x,p.y,m);if(i.$setAnchorCellForSelection(C),ge(o),o.shiftKey){const[e,t,n]=R(l,u,d);return le(i,e,t,n,r)}return d.selectEnd(),!0}return!1}function ge(e){e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation()}function fe(e,n,o){const r=t.$createParagraphNode();"first"===e?n.insertBefore(r):n.insertAfter(r),r.append(...o||[]),r.selectEnd()}function me(n,o,r){const l=r.getParent();if(!l)return;const i=t.getDOMSelection(Y(n));if(!i)return;const s=i.anchorNode,a=n.getElementByKey(l.getKey()),u=B(r,n.getElementByKey(r.getKey()));if(!s||!a||!u||!a.contains(s)||u.contains(s))return;const d=e.$findMatchingParent(o.anchor.getNode(),(e=>c(e)));if(!d)return;const h=e.$findMatchingParent(d,(e=>Me(e)));if(!Me(h)||!h.is(r))return;const[g,f]=R(r,d,d),m=g[0][0],p=g[g.length-1][g[0].length-1],{startRow:C,startColumn:S}=f,_=C===m.startRow&&S===m.startColumn,N=C===p.startRow&&S===p.startColumn;return _?"first":N?"last":void 0}function pe(e,t){const{tableNode:n}=e.$lookup(),o=n.getCordsFromCellNode(t,e.table);return n.getDOMCellFromCordsOrThrow(o.x,o.y,e.table)}function Ce(e,n,o){return U(e,t.$getNearestNodeFromDOMNode(n,o))}function Se(e,t,n,o){const r=e.querySelector("colgroup");if(!r)return;const l=[];for(let e=0;e<n;e++){const t=document.createElement("col"),n=o&&o[e];n&&(t.style.width=`${n}px`),l.push(t)}r.replaceChildren(...l)}function _e(t,n,o){o?(e.addClassNamesToElement(t,n.theme.tableRowStriping),t.setAttribute("data-lexical-row-striping","true")):(e.removeClassNamesFromElement(t,n.theme.tableRowStriping),t.removeAttribute("data-lexical-row-striping"))}function Ne(t,n,o){if(!n.theme.tableAlignment)return;const r=[],l=[];for(const e of["center","right"]){const t=n.theme.tableAlignment[e];t&&(e===o?l:r).push(t)}e.removeClassNamesFromElement(t,...r),e.addClassNamesToElement(t,...l)}const be=new WeakSet;function we(e=t.$getEditor()){return be.has(e)}class Te extends t.ElementNode{static getType(){return"table"}getColWidths(){return this.getLatest().__colWidths}setColWidths(e){const t=this.getWritable();return t.__colWidths=e,t}static clone(e){return new Te(e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__colWidths=e.__colWidths,this.__rowStriping=e.__rowStriping}static importDOM(){return{table:e=>({conversion:ye,priority:1})}}static importJSON(e){return $e().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setRowStriping(e.rowStriping||!1).setColWidths(e.colWidths)}constructor(e){super(e),this.__rowStriping=!1}exportJSON(){return{...super.exportJSON(),colWidths:this.getColWidths(),rowStriping:this.__rowStriping?this.__rowStriping:void 0}}extractWithChild(e,t,n){return"html"===n}getDOMSlot(e){const t="TABLE"!==e.nodeName&&e.querySelector("table")||e;return"TABLE"!==t.nodeName&&h(229),super.getDOMSlot(t).withAfter(t.querySelector("colgroup"))}createDOM(n,o){const r=document.createElement("table"),l=document.createElement("colgroup");if(r.appendChild(l),Se(r,0,this.getColumnCount(),this.getColWidths()),t.setDOMUnmanaged(l),e.addClassNamesToElement(r,n.theme.table),Ne(r,n,this.getFormatType()),this.__rowStriping&&_e(r,n,!0),we(o)){const t=document.createElement("div"),o=n.theme.tableScrollableWrapper;return o?e.addClassNamesToElement(t,o):t.style.cssText="overflow-x: auto;",t.appendChild(r),t}return r}updateDOM(e,t,n){return e.__rowStriping!==this.__rowStriping&&_e(t,n,this.__rowStriping),Se(t,0,this.getColumnCount(),this.getColWidths()),Ne(this.getDOMSlot(t).element,n,this.getFormatType()),!1}exportDOM(t){const n=super.exportDOM(t),{element:o}=n;return{after:o=>{if(n.after&&(o=n.after(o),this.__format&&Ne(o,t._config,this.getFormatType())),e.isHTMLElement(o)&&"TABLE"!==o.nodeName&&(o=o.querySelector("table")),!e.isHTMLElement(o))return null;const[r]=x(this,null,null),l=new Map;for(const e of r)for(const t of e){const e=t.cell.getKey();l.has(e)||l.set(e,{colSpan:t.cell.getColSpan(),startColumn:t.startColumn})}const i=new Set;for(const e of o.querySelectorAll(":scope > tr > [data-temporary-table-cell-lexical-key]")){const t=e.getAttribute("data-temporary-table-cell-lexical-key");if(t){const n=l.get(t);if(e.removeAttribute("data-temporary-table-cell-lexical-key"),n){l.delete(t);for(let e=0;e<n.colSpan;e++)i.add(e+n.startColumn)}}}const s=o.querySelector(":scope > colgroup");if(s){const e=Array.from(o.querySelectorAll(":scope > colgroup > col")).filter(((e,t)=>i.has(t)));s.replaceChildren(...e)}const a=o.querySelectorAll(":scope > tr");if(a.length>0){const e=document.createElement("tbody");for(const t of a)e.appendChild(t);o.append(e)}return o},element:e.isHTMLElement(o)&&"TABLE"!==o.nodeName?o.querySelector("table"):o}}canBeEmpty(){return!1}isShadowRoot(){return!0}getCordsFromCellNode(e,t){const{rows:n,domRows:o}=t;for(let t=0;t<n;t++){const n=o[t];if(null!=n)for(let o=0;o<n.length;o++){const r=n[o];if(null==r)continue;const{elem:l}=r,i=Ce(this,l);if(null!==i&&e.is(i))return{x:o,y:t}}}throw new Error("Cell not found in table.")}getDOMCellFromCords(e,t,n){const{domRows:o}=n,r=o[t];if(null==r)return null;const l=r[e<r.length?e:r.length-1];return null==l?null:l}getDOMCellFromCordsOrThrow(e,t,n){const o=this.getDOMCellFromCords(e,t,n);if(!o)throw new Error("Cell not found at cords.");return o}getCellNodeFromCords(e,n,o){const r=this.getDOMCellFromCords(e,n,o);if(null==r)return null;const l=t.$getNearestNodeFromDOMNode(r.elem);return c(l)?l:null}getCellNodeFromCordsOrThrow(e,t,n){const o=this.getCellNodeFromCords(e,t,n);if(!o)throw new Error("Node at cords not TableCellNode.");return o}getRowStriping(){return Boolean(this.getLatest().__rowStriping)}setRowStriping(e){const t=this.getWritable();return t.__rowStriping=e,t}canSelectBefore(){return!0}canIndent(){return!1}getColumnCount(){const e=this.getFirstChild();if(!e)return 0;let t=0;return e.getChildren().forEach((e=>{c(e)&&(t+=e.getColSpan())})),t}}function ye(t){const n=$e();t.hasAttribute("data-lexical-row-striping")&&n.setRowStriping(!0);const r=t.querySelector(":scope > colgroup");if(r){let e=[];for(const t of r.querySelectorAll(":scope > col")){let n=t.style.width||"";if(!o.test(n)&&(n=t.getAttribute("width")||"",!/^\d+$/.test(n))){e=void 0;break}e.push(parseFloat(n))}e&&n.setColWidths(e)}return{after:t=>e.$descendantsMatching(t,p),node:n}}function $e(){return t.$applyNodeReplacement(new Te)}function Me(e){return e instanceof Te}function Re({rows:n,columns:o,includeHeaders:r}){const l=N(Number(n),Number(o),r);e.$insertNodeToNearestRoot(l);const i=l.getFirstDescendant();return t.$isTextNode(i)&&i.select(),!0}function xe(e){p(e.getParent())?e.isEmpty()&&e.append(t.$createParagraphNode()):e.remove()}function Oe(t){Me(t.getParent())?e.$unwrapAndFilterDescendants(t,c):t.remove()}function Ee(n){e.$unwrapAndFilterDescendants(n,p);const[o]=x(n,null,null),r=o.reduce(((e,t)=>Math.max(e,t.length)),0),l=n.getChildren();for(let e=0;e<o.length;++e){const n=l[e];if(!n)continue;p(n)||h(254,n.constructor.name,n.getType());const i=o[e].reduce(((e,t)=>t?1+e:e),0);if(i!==r)for(let e=i;e<r;++e){const e=a();e.append(t.$createParagraphNode()),n.append(e)}}}exports.$computeTableMap=R,exports.$computeTableMapSkipCellCheck=x,exports.$createTableCellNode=a,exports.$createTableNode=$e,exports.$createTableNodeWithDimensions=N,exports.$createTableRowNode=m,exports.$createTableSelection=D,exports.$createTableSelectionFrom=K,exports.$deleteTableColumn=function(e,t){const n=e.getChildren();for(let e=0;e<n.length;e++){const o=n[e];if(p(o)){const e=o.getChildren();if(t>=e.length||t<0)throw new Error("Table column target index out of range");e[t].remove()}}return e},exports.$deleteTableColumn__EXPERIMENTAL=function(){const e=t.$getSelection();t.$isRangeSelection(e)||P(e)||h(188);const n=e.anchor.getNode(),o=e.focus.getNode(),[r,,l]=O(n),[i]=O(o),[s,a,c]=R(l,r,i),{startColumn:u}=a,{startRow:d,startColumn:g}=c,f=Math.min(u,g),m=Math.max(u+r.__colSpan-1,g+i.__colSpan-1),p=m-f+1;if(s[0].length===m-f+1)return l.selectPrevious(),void l.remove();const C=s.length;for(let e=0;e<C;e++)for(let t=f;t<=m;t++){const{cell:n,startColumn:o}=s[e][t];if(o<f){if(t===f){const e=f-o;n.setColSpan(n.__colSpan-Math.min(p,n.__colSpan-e))}}else if(o+n.__colSpan-1>m){if(t===m){const e=m-o+1;n.setColSpan(n.__colSpan-e)}}else n.remove()}const S=s[d],_=u>g?S[u+r.__colSpan]:S[g+i.__colSpan];if(void 0!==_){const{cell:e}=_;$(e)}else{const e=g<u?S[g-1]:S[u-1],{cell:t}=e;$(t)}const N=l.getColWidths();if(N){const e=[...N];e.splice(f,p),l.setColWidths(e)}},exports.$deleteTableRow__EXPERIMENTAL=function(){const e=t.$getSelection();t.$isRangeSelection(e)||P(e)||h(188);const[n,o]=e.isBackward()?[e.focus.getNode(),e.anchor.getNode()]:[e.anchor.getNode(),e.focus.getNode()],[r,,l]=O(n),[i]=O(o),[s,a,c]=R(l,r,i),{startRow:u}=a,{startRow:d}=c,g=d+i.__rowSpan-1;if(s.length===g-u+1)return void l.remove();const f=s[0].length,m=r.__rowSpan,C=s[g+1],S=l.getChildAtIndex(g+1);for(let e=g;e>=u;e--){for(let t=f-1;t>=0;t--){const{cell:n,startRow:o,startColumn:r}=s[e][t];if(r===t){if(e===u&&o<u){const e=u-o;n.setRowSpan(n.__rowSpan-Math.min(m,n.__rowSpan-e))}if(o>=u&&o+n.__rowSpan-1>g){n.setRowSpan(n.__rowSpan-(g-o+1)),null===S&&h(122);let r=null;for(let n=0;n<t;n++){const t=C[n],o=t.cell;t.startRow===e+1&&(r=o),o.__colSpan>1&&(n+=o.__colSpan-1)}null===r?M(S,n):r.insertAfter(n)}}}const t=l.getChildAtIndex(e);p(t)||h(206,String(e)),t.remove()}if(void 0!==C){const{cell:e}=C[0];$(e)}else{const e=s[u-1],{cell:t}=e[0];$(t)}},exports.$findCellNode=ue,exports.$findTableNode=de,exports.$getElementForTableNode=function(e,t){const n=e.getElementByKey(t.getKey());return null===n&&h(230),V(t,n)},exports.$getNodeTriplet=O,exports.$getTableAndElementByKey=k,exports.$getTableCellNodeFromLexicalNode=function(t){const n=e.$findMatchingParent(t,(e=>c(e)));return c(n)?n:null},exports.$getTableCellNodeRect=A,exports.$getTableColumnIndexFromTableCellNode=function(e){return b(e).getChildren().findIndex((t=>t.is(e)))},exports.$getTableNodeFromLexicalNodeOrThrow=w,exports.$getTableRowIndexFromTableCellNode=function(e){const t=b(e);return w(t).getChildren().findIndex((e=>e.is(t)))},exports.$getTableRowNodeFromTableCellNodeOrThrow=b,exports.$insertTableColumn=function(e,n,o=!0,l,i){const s=e.getChildren(),u=[];for(let e=0;e<s.length;e++){const o=s[e];if(p(o))for(let e=0;e<l;e++){const e=o.getChildren();if(n>=e.length||n<0)throw new Error("Table column target index out of range");const l=e[n];c(l)||h(12);const{left:s,right:d}=T(l,i);let g=r.NO_STATUS;(s&&s.hasHeaderState(r.ROW)||d&&d.hasHeaderState(r.ROW))&&(g|=r.ROW);const f=a(g);f.append(t.$createParagraphNode()),u.push({newTableCell:f,targetCell:l})}}return u.forEach((({newTableCell:e,targetCell:t})=>{o?t.insertAfter(e):t.insertBefore(e)})),e},exports.$insertTableColumn__EXPERIMENTAL=function(e=!0){const n=t.$getSelection();t.$isRangeSelection(n)||P(n)||h(188);const o=n.anchor.getNode(),l=n.focus.getNode(),[i]=O(o),[s,,c]=O(l),[u,d,g]=R(c,s,i),f=u.length,m=e?Math.max(d.startColumn,g.startColumn):Math.min(d.startColumn,g.startColumn),C=e?m+s.__colSpan-1:m-1,S=c.getFirstChild();p(S)||h(120);let _=null;function N(e=r.NO_STATUS){const n=a(e).append(t.$createParagraphNode());return null===_&&(_=n),n}let b=S;e:for(let e=0;e<f;e++){if(0!==e){const e=b.getNextSibling();p(e)||h(121),b=e}const t=u[e],n=t[C<0?0:C].cell.__headerState,o=y(n,r.ROW);if(C<0){M(b,N(o));continue}const{cell:l,startColumn:i,startRow:s}=t[C];if(i+l.__colSpan-1<=C){let n=l,r=s,i=C;for(;r!==e&&n.__rowSpan>1;){if(i-=l.__colSpan,!(i>=0)){b.append(N(o));continue e}{const{cell:e,startRow:o}=t[i];n=e,r=o}}n.insertAfter(N(o))}else l.setColSpan(l.__colSpan+1)}null!==_&&$(_);const w=c.getColWidths();if(w){const e=[...w],t=C<0?0:C,n=e[t];e.splice(t,0,n),c.setColWidths(e)}return _},exports.$insertTableRow=function(e,n,o=!0,l,i){const s=e.getChildren();if(n>=s.length||n<0)throw new Error("Table row target index out of range");const u=s[n];if(!p(u))throw new Error("Row before insertion index does not exist.");for(let e=0;e<l;e++){const e=u.getChildren(),n=e.length,l=m();for(let o=0;o<n;o++){const n=e[o];c(n)||h(12);const{above:s,below:u}=T(n,i);let d=r.NO_STATUS;const g=s&&s.getWidth()||u&&u.getWidth()||void 0;(s&&s.hasHeaderState(r.COLUMN)||u&&u.hasHeaderState(r.COLUMN))&&(d|=r.COLUMN);const f=a(d,1,g);f.append(t.$createParagraphNode()),l.append(f)}o?u.insertAfter(l):u.insertBefore(l)}return e},exports.$insertTableRow__EXPERIMENTAL=function(e=!0){const n=t.$getSelection();t.$isRangeSelection(n)||P(n)||h(188);const o=n.anchor.getNode(),l=n.focus.getNode(),[i]=O(o),[s,,c]=O(l),[u,d,g]=R(c,s,i),f=u[0].length,{startRow:C}=g,{startRow:S}=d;let _=null;if(e){const e=Math.max(S+s.__rowSpan,C+i.__rowSpan)-1,n=u[e],o=m();for(let l=0;l<f;l++){const{cell:i,startRow:s}=n[l];if(s+i.__rowSpan-1<=e){const e=n[l].cell.__headerState,i=y(e,r.COLUMN);o.append(a(i).append(t.$createParagraphNode()))}else i.setRowSpan(i.__rowSpan+1)}const l=c.getChildAtIndex(e);p(l)||h(256),l.insertAfter(o),_=o}else{const e=Math.min(S,C),n=u[e],o=m();for(let l=0;l<f;l++){const{cell:i,startRow:s}=n[l];if(s===e){const e=n[l].cell.__headerState,i=y(e,r.COLUMN);o.append(a(i).append(t.$createParagraphNode()))}else i.setRowSpan(i.__rowSpan+1)}const l=c.getChildAtIndex(e);p(l)||h(257),l.insertBefore(o),_=o}return _},exports.$isScrollableTablesActive=we,exports.$isTableCellNode=c,exports.$isTableNode=Me,exports.$isTableRowNode=p,exports.$isTableSelection=P,exports.$removeTableRowAtIndex=function(e,t){const n=e.getChildren();if(t>=n.length||t<0)throw new Error("Expected table cell to be inside of table row.");return n[t].remove(),e},exports.$unmergeCell=function(){const e=t.$getSelection();t.$isRangeSelection(e)||P(e)||h(188);const n=e.anchor.getNode(),[o,l,i]=O(n),s=o.__colSpan,c=o.__rowSpan;if(1===s&&1===c)return;const[u,d]=R(i,o,o),{startColumn:g,startRow:f}=d,m=o.__headerState&r.COLUMN,C=Array.from({length:s},((e,t)=>{let n=m;for(let e=0;0!==n&&e<u.length;e++)n&=u[e][t+g].cell.__headerState;return n})),S=o.__headerState&r.ROW,_=Array.from({length:c},((e,t)=>{let n=S;for(let e=0;0!==n&&e<u[0].length;e++)n&=u[t+f][e].cell.__headerState;return n}));if(s>1){for(let e=1;e<s;e++)o.insertAfter(a(C[e]|_[0]).append(t.$createParagraphNode()));o.setColSpan(1)}if(c>1){let e;for(let n=1;n<c;n++){const o=f+n,r=u[o];e=(e||l).getNextSibling(),p(e)||h(125);let i=null;for(let e=0;e<g;e++){const t=r[e],n=t.cell;t.startRow===o&&(i=n),n.__colSpan>1&&(e+=n.__colSpan-1)}if(null===i)for(let o=s-1;o>=0;o--)M(e,a(C[o]|_[n]).append(t.$createParagraphNode()));else for(let e=s-1;e>=0;e--)i.insertAfter(a(C[e]|_[n]).append(t.$createParagraphNode()))}o.setRowSpan(1)}},exports.INSERT_TABLE_COMMAND=u,exports.TableCellHeaderStates=r,exports.TableCellNode=l,exports.TableNode=Te,exports.TableObserver=L,exports.TableRowNode=g,exports.applyTableHandlers=z,exports.getDOMCellFromTarget=j,exports.getTableElement=B,exports.getTableObserverFromTableElement=G,exports.registerTableCellUnmergeTransform=function(t){return t.registerNodeTransform(l,(t=>{if(t.getColSpan()>1||t.getRowSpan()>1){const[,,n]=O(t),[o]=R(n,t,t),r=o.length,l=o[0].length;let i=n.getFirstChild();p(i)||h(175);const s=[];for(let t=0;t<r;t++){0!==t&&(i=i.getNextSibling(),p(i)||h(175));let n=null;for(let r=0;r<l;r++){const l=o[t][r],u=l.cell;if(l.startRow===t&&l.startColumn===r)n=u,s.push(u);else if(u.getColSpan()>1||u.getRowSpan()>1){c(u)||h(176);const t=a(u.__headerState);null!==n?n.insertAfter(t):e.$insertFirst(i,t)}}}for(const e of s)e.setColSpan(1),e.setRowSpan(1)}}))},exports.registerTablePlugin=function(n){return n.hasNodes([Te])||h(255),e.mergeRegister(n.registerCommand(u,Re,t.COMMAND_PRIORITY_EDITOR),n.registerNodeTransform(Te,Ee),n.registerNodeTransform(g,Oe),n.registerNodeTransform(l,xe))},exports.registerTableSelectionObserver=function(e,t=!0){const n=new Map,o=(o,r,l)=>{const i=B(o,l),s=z(o,i,e,t);n.set(r,[s,i])},r=e.registerMutationListener(Te,(t=>{e.getEditorState().read((()=>{for(const[e,r]of t){const t=n.get(e);if("created"===r||"updated"===r){const{tableNode:r,tableElement:l}=k(e);void 0===t?o(r,e,l):l!==t[1]&&(t[0].removeListeners(),n.delete(e),o(r,e,l))}else"destroyed"===r&&void 0!==t&&(t[0].removeListeners(),n.delete(e))}}),{editor:e})}),{skipInitialization:!1});return()=>{r();for(const[,[e]]of n)e.removeListeners()}},exports.setScrollableTablesActive=function(e,t){t?be.add(e):be.delete(e)};
|
9
|
+
"use strict";var e=require("@lexical/utils"),t=require("lexical"),n=require("@lexical/clipboard");const o=/^(\d+(?:\.\d+)?)px$/,r={BOTH:3,COLUMN:2,NO_STATUS:0,ROW:1};class l extends t.ElementNode{static getType(){return"tablecell"}static clone(e){return new l(e.__headerState,e.__colSpan,e.__width,e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__rowSpan=e.__rowSpan,this.__backgroundColor=e.__backgroundColor,this.__verticalAlign=e.__verticalAlign}static importDOM(){return{td:e=>({conversion:i,priority:0}),th:e=>({conversion:i,priority:0})}}static importJSON(e){return a().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setHeaderStyles(e.headerState).setColSpan(e.colSpan||1).setRowSpan(e.rowSpan||1).setWidth(e.width||void 0).setBackgroundColor(e.backgroundColor||null).setVerticalAlign(e.verticalAlign||void 0)}constructor(e=r.NO_STATUS,t=1,n,o){super(o),this.__colSpan=t,this.__rowSpan=1,this.__headerState=e,this.__width=n,this.__backgroundColor=null}createDOM(t){const n=document.createElement(this.getTag());return this.__width&&(n.style.width=`${this.__width}px`),this.__colSpan>1&&(n.colSpan=this.__colSpan),this.__rowSpan>1&&(n.rowSpan=this.__rowSpan),null!==this.__backgroundColor&&(n.style.backgroundColor=this.__backgroundColor),s(this.__verticalAlign)&&(n.style.verticalAlign=this.__verticalAlign),e.addClassNamesToElement(n,t.theme.tableCell,this.hasHeader()&&t.theme.tableCellHeader),n}exportDOM(e){const n=super.exportDOM(e);if(t.isHTMLElement(n.element)){const e=n.element;e.setAttribute("data-temporary-table-cell-lexical-key",this.getKey()),e.style.border="1px solid black",this.__colSpan>1&&(e.colSpan=this.__colSpan),this.__rowSpan>1&&(e.rowSpan=this.__rowSpan),e.style.width=`${this.getWidth()||75}px`,e.style.verticalAlign=this.getVerticalAlign()||"top",e.style.textAlign="start",null===this.__backgroundColor&&this.hasHeader()&&(e.style.backgroundColor="#f2f3f5")}return n}exportJSON(){return{...super.exportJSON(),...s(this.__verticalAlign)&&{verticalAlign:this.__verticalAlign},backgroundColor:this.getBackgroundColor(),colSpan:this.__colSpan,headerState:this.__headerState,rowSpan:this.__rowSpan,width:this.getWidth()}}getColSpan(){return this.getLatest().__colSpan}setColSpan(e){const t=this.getWritable();return t.__colSpan=e,t}getRowSpan(){return this.getLatest().__rowSpan}setRowSpan(e){const t=this.getWritable();return t.__rowSpan=e,t}getTag(){return this.hasHeader()?"th":"td"}setHeaderStyles(e,t=r.BOTH){const n=this.getWritable();return n.__headerState=e&t|n.__headerState&~t,n}getHeaderStyles(){return this.getLatest().__headerState}setWidth(e){const t=this.getWritable();return t.__width=e,t}getWidth(){return this.getLatest().__width}getBackgroundColor(){return this.getLatest().__backgroundColor}setBackgroundColor(e){const t=this.getWritable();return t.__backgroundColor=e,t}getVerticalAlign(){return this.getLatest().__verticalAlign}setVerticalAlign(e){const t=this.getWritable();return t.__verticalAlign=e||void 0,t}toggleHeaderStyle(e){const t=this.getWritable();return(t.__headerState&e)===e?t.__headerState-=e:t.__headerState+=e,t}hasHeaderState(e){return(this.getHeaderStyles()&e)===e}hasHeader(){return this.getLatest().__headerState!==r.NO_STATUS}updateDOM(e){return e.__headerState!==this.__headerState||e.__width!==this.__width||e.__colSpan!==this.__colSpan||e.__rowSpan!==this.__rowSpan||e.__backgroundColor!==this.__backgroundColor||e.__verticalAlign!==this.__verticalAlign}isShadowRoot(){return!0}collapseAtStart(){return!0}canBeEmpty(){return!1}canIndent(){return!1}}function s(e){return"middle"===e||"bottom"===e}function i(e){const n=e,l=e.nodeName.toLowerCase();let i;o.test(n.style.width)&&(i=parseFloat(n.style.width));const u=a("th"===l?r.ROW:r.NO_STATUS,n.colSpan,i);u.__rowSpan=n.rowSpan;const d=n.style.backgroundColor;""!==d&&(u.__backgroundColor=d);const h=n.style.verticalAlign;s(h)&&(u.__verticalAlign=h);const g=n.style,f=(g&&g.textDecoration||"").split(" "),m="700"===g.fontWeight||"bold"===g.fontWeight,C=f.includes("line-through"),p="italic"===g.fontStyle,_=f.includes("underline");return{after:e=>(0===e.length&&e.push(t.$createParagraphNode()),e),forChild:(e,n)=>{if(c(n)&&!t.$isElementNode(e)){const n=t.$createParagraphNode();return t.$isLineBreakNode(e)&&"\n"===e.getTextContent()?null:(t.$isTextNode(e)&&(m&&e.toggleFormat("bold"),C&&e.toggleFormat("strikethrough"),p&&e.toggleFormat("italic"),_&&e.toggleFormat("underline")),n.append(e),n)}return e},node:u}}function a(e=r.NO_STATUS,n=1,o){return t.$applyNodeReplacement(new l(e,n,o))}function c(e){return e instanceof l}const u=t.createCommand("INSERT_TABLE_COMMAND");function d(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var h=d((function(e){const t=new URLSearchParams;t.append("code",e);for(let e=1;e<arguments.length;e++)t.append("v",arguments[e]);throw Error(`Minified Lexical error #${e}; visit https://lexical.dev/docs/error?${t} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}));class g extends t.ElementNode{static getType(){return"tablerow"}static clone(e){return new g(e.__height,e.__key)}static importDOM(){return{tr:e=>({conversion:f,priority:0})}}static importJSON(e){return m().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setHeight(e.height)}constructor(e,t){super(t),this.__height=e}exportJSON(){const e=this.getHeight();return{...super.exportJSON(),...void 0===e?void 0:{height:e}}}createDOM(t){const n=document.createElement("tr");return this.__height&&(n.style.height=`${this.__height}px`),e.addClassNamesToElement(n,t.theme.tableRow),n}extractWithChild(e,t,n){return"html"===n}isShadowRoot(){return!0}setHeight(e){const t=this.getWritable();return t.__height=e,t}getHeight(){return this.getLatest().__height}updateDOM(e){return e.__height!==this.__height}canBeEmpty(){return!1}canIndent(){return!1}}function f(t){const n=t;let r;return o.test(n.style.height)&&(r=parseFloat(n.style.height)),{after:t=>e.$descendantsMatching(t,c),node:m(r)}}function m(e){return t.$applyNodeReplacement(new g(e))}function C(e){return e instanceof g}const p="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,_=p&&"documentMode"in document?document.documentMode:null,S=p&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);function N(e,n,o=!0){const l=Me();for(let s=0;s<e;s++){const e=m();for(let l=0;l<n;l++){let n=r.NO_STATUS;"object"==typeof o?(0===s&&o.rows&&(n|=r.ROW),0===l&&o.columns&&(n|=r.COLUMN)):o&&(0===s&&(n|=r.ROW),0===l&&(n|=r.COLUMN));const i=a(n),c=t.$createParagraphNode();c.append(t.$createTextNode()),i.append(c),e.append(i)}l.append(e)}return l}function b(t){const n=e.$findMatchingParent(t,(e=>C(e)));if(C(n))return n;throw new Error("Expected table cell to be inside of table row.")}function w(t){const n=e.$findMatchingParent(t,(e=>Re(e)));if(Re(n))return n;throw new Error("Expected table cell to be inside of table.")}function T(e,t){const n=w(e),{x:o,y:r}=n.getCordsFromCellNode(e,t);return{above:n.getCellNodeFromCords(o,r-1,t),below:n.getCellNodeFromCords(o,r+1,t),left:n.getCellNodeFromCords(o-1,r,t),right:n.getCellNodeFromCords(o+1,r,t)}}p&&"InputEvent"in window&&!_&&new window.InputEvent("input");const y=(e,t)=>e===r.BOTH||e===t?t:r.NO_STATUS;function $(e){const t=e.getFirstDescendant();null==t?e.selectStart():t.getParentOrThrow().selectStart()}function M(e,t){const n=e.getFirstChild();null!==n?n.insertBefore(t):e.append(t)}function R(e,t,n){const[o,r,l]=x(e,t,n);return null===r&&h(207),null===l&&h(208),[o,r,l]}function x(e,t,n){const o=[];let r=null,l=null;function s(e){let t=o[e];return void 0===t&&(o[e]=t=[]),t}const i=e.getChildren();for(let e=0;e<i.length;e++){const o=i[e];C(o)||h(209);const a=s(e);for(let u=o.getFirstChild(),d=0;null!=u;u=u.getNextSibling()){for(c(u)||h(147);void 0!==a[d];)d++;const o={cell:u,startColumn:d,startRow:e},{__rowSpan:g,__colSpan:f}=u;for(let t=0;t<g&&!(e+t>=i.length);t++){const n=s(e+t);for(let e=0;e<f;e++)n[d+e]=o}null!==t&&null===r&&t.is(u)&&(r=o),null!==n&&null===l&&n.is(u)&&(l=o)}}return[o,r,l]}function E(t){let n;if(t instanceof l)n=t;else if("__type"in t){const o=e.$findMatchingParent(t,c);c(o)||h(148),n=o}else{const o=e.$findMatchingParent(t.getNode(),c);c(o)||h(148),n=o}const o=n.getParent();C(o)||h(149);const r=o.getParent();return Re(r)||h(210),[n,o,r]}function O(e,t,n){let o=Math.min(t.startColumn,n.startColumn),r=Math.min(t.startRow,n.startRow),l=Math.max(t.startColumn+t.cell.__colSpan-1,n.startColumn+n.cell.__colSpan-1),s=Math.max(t.startRow+t.cell.__rowSpan-1,n.startRow+n.cell.__rowSpan-1),i=o,a=r,c=o,u=r;function d(e){const{cell:t,startColumn:n,startRow:i}=e;o=Math.min(o,n),r=Math.min(r,i),l=Math.max(l,n+t.__colSpan-1),s=Math.max(s,i+t.__rowSpan-1)}for(;o<i||r<a||l>c||s>u;){if(o<i){const t=u-a,n=i-1;for(let o=0;o<=t;o++)d(e[a+o][n]);i=n}if(r<a){const t=c-i,n=a-1;for(let o=0;o<=t;o++)d(e[n][i+o]);a=n}if(l>c){const t=u-a,n=c+1;for(let o=0;o<=t;o++)d(e[a+o][n]);c=n}if(s>u){const t=c-i,n=u+1;for(let o=0;o<=t;o++)d(e[n][i+o]);u=n}}return{maxColumn:l,maxRow:s,minColumn:o,minRow:r}}function A(e){const[t,,n]=E(e),o=n.getChildren(),r=o.length,l=o[0].getChildren().length,s=new Array(r);for(let e=0;e<r;e++)s[e]=new Array(l);for(let e=0;e<r;e++){const n=o[e].getChildren();let r=0;for(let o=0;o<n.length;o++){for(;s[e][r];)r++;const l=n[o],i=l.__rowSpan||1,a=l.__colSpan||1;for(let t=0;t<i;t++)for(let n=0;n<a;n++)s[e+t][r+n]=l;if(t===l)return{colSpan:a,columnIndex:r,rowIndex:e,rowSpan:i};r+=a}}return null}function v(t){const[[n,o,r,l],[s,i,a,u]]=["anchor","focus"].map((n=>{const o=t[n].getNode(),r=e.$findMatchingParent(o,c);c(r)||h(238,n,o.getKey(),o.getType());const l=r.getParent();C(l)||h(239,n);const s=l.getParent();return Re(s)||h(240,n),[o,r,l,s]}));return l.is(u)||h(241),{anchorCell:o,anchorNode:n,anchorRow:r,anchorTable:l,focusCell:i,focusNode:s,focusRow:a,focusTable:u}}class F{constructor(e,t,n){this.anchor=t,this.focus=n,t._selection=this,n._selection=this,this._cachedNodes=null,this.dirty=!1,this.tableKey=e}getStartEndPoints(){return[this.anchor,this.focus]}isValid(){return"root"!==this.tableKey&&"root"!==this.anchor.key&&"element"===this.anchor.type&&"root"!==this.focus.key&&"element"===this.focus.type}isBackward(){return this.focus.isBefore(this.anchor)}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e}is(e){return P(e)&&this.tableKey===e.tableKey&&this.anchor.is(e.anchor)&&this.focus.is(e.focus)}set(e,t,n){this.dirty=this.dirty||e!==this.tableKey||t!==this.anchor.key||n!==this.focus.key,this.tableKey=e,this.anchor.key=t,this.focus.key=n,this._cachedNodes=null}clone(){return new F(this.tableKey,t.$createPoint(this.anchor.key,this.anchor.offset,this.anchor.type),t.$createPoint(this.focus.key,this.focus.offset,this.focus.type))}isCollapsed(){return!1}extract(){return this.getNodes()}insertRawText(e){}insertText(){}hasFormat(e){let n=0;this.getNodes().filter(c).forEach((e=>{const o=e.getFirstChild();t.$isParagraphNode(o)&&(n|=o.getTextFormat())}));const o=t.TEXT_TYPE_TO_FORMAT[e];return!!(n&o)}insertNodes(e){const n=this.focus.getNode();t.$isElementNode(n)||h(151);t.$normalizeSelection__EXPERIMENTAL(n.select(0,n.getChildrenSize())).insertNodes(e)}getShape(){const{anchorCell:e,focusCell:t}=v(this),n=A(e);null===n&&h(153);const o=A(t);null===o&&h(155);const r=Math.min(n.columnIndex,o.columnIndex),l=Math.max(n.columnIndex+n.colSpan-1,o.columnIndex+o.colSpan-1),s=Math.min(n.rowIndex,o.rowIndex),i=Math.max(n.rowIndex+n.rowSpan-1,o.rowIndex+o.rowSpan-1);return{fromX:Math.min(r,l),fromY:Math.min(s,i),toX:Math.max(r,l),toY:Math.max(s,i)}}getNodes(){if(!this.isValid())return[];const e=this._cachedNodes;if(null!==e)return e;const{anchorTable:n,anchorCell:o,focusCell:r}=v(this),l=r.getParents()[1];if(l!==n){if(n.isParentOf(r)){const e=l.getParent();null==e&&h(159),this.set(this.tableKey,r.getKey(),e.getKey())}else{const e=n.getParent();null==e&&h(158),this.set(this.tableKey,e.getKey(),r.getKey())}return this.getNodes()}const[s,i,a]=R(n,o,r),{minColumn:c,maxColumn:u,minRow:d,maxRow:g}=O(s,i,a),f=new Map([[n.getKey(),n]]);let m=null;for(let e=d;e<=g;e++)for(let t=c;t<=u;t++){const{cell:n}=s[e][t],o=n.getParent();C(o)||h(160),o!==m&&(f.set(o.getKey(),o),m=o),f.has(n.getKey())||I(n,(e=>{f.set(e.getKey(),e)}))}const p=Array.from(f.values());return t.isCurrentlyReadOnlyMode()||(this._cachedNodes=p),p}getTextContent(){const e=this.getNodes().filter((e=>c(e)));let t="";for(let n=0;n<e.length;n++){const o=e[n],r=o.__parent,l=(e[n+1]||{}).__parent;t+=o.getTextContent()+(l!==r?"\n":"\t")}return t}}function P(e){return e instanceof F}function D(){const e=t.$createPoint("root",0,"element"),n=t.$createPoint("root",0,"element");return new F("root",e,n)}function K(e,n,o){e.getKey(),n.getKey(),o.getKey();const r=t.$getSelection(),l=P(r)?r.clone():D();return l.set(e.getKey(),n.getKey(),o.getKey()),l}function I(e,n){const o=[[e]];for(let e=o.at(-1);void 0!==e&&o.length>0;e=o.at(-1)){const r=e.pop();void 0===r?o.pop():!1!==n(r)&&t.$isElementNode(r)&&o.push(r.getChildren())}}function k(e,n=t.$getEditor()){const o=t.$getNodeByKey(e);Re(o)||h(231,e);const r=B(o,n.getElementByKey(e));return null===r&&h(232,e),{tableElement:r,tableNode:o}}class L{constructor(e,t){this.isHighlightingCells=!1,this.anchorX=-1,this.anchorY=-1,this.focusX=-1,this.focusY=-1,this.listenersToRemove=new Set,this.tableNodeKey=t,this.editor=e,this.table={columns:0,domRows:[],rows:0},this.tableSelection=null,this.anchorCellNodeKey=null,this.focusCellNodeKey=null,this.anchorCell=null,this.focusCell=null,this.hasHijackedSelectionStyles=!1,this.isSelecting=!1,this.shouldCheckSelection=!1,this.abortController=new AbortController,this.listenerOptions={signal:this.abortController.signal},this.nextFocus=null,this.trackTable()}getTable(){return this.table}removeListeners(){this.abortController.abort("removeListeners"),Array.from(this.listenersToRemove).forEach((e=>e())),this.listenersToRemove.clear()}$lookup(){return k(this.tableNodeKey,this.editor)}trackTable(){const e=new MutationObserver((e=>{this.editor.getEditorState().read((()=>{let t=!1;for(let n=0;n<e.length;n++){const o=e[n].target.nodeName;if("TABLE"===o||"TBODY"===o||"THEAD"===o||"TR"===o){t=!0;break}}if(!t)return;const{tableNode:n,tableElement:o}=this.$lookup();this.table=V(n,o)}),{editor:this.editor})}));this.editor.getEditorState().read((()=>{const{tableNode:t,tableElement:n}=this.$lookup();this.table=V(t,n),e.observe(n,{attributes:!0,childList:!0,subtree:!0})}),{editor:this.editor})}$clearHighlight(){const e=this.editor;this.isHighlightingCells=!1,this.anchorX=-1,this.anchorY=-1,this.focusX=-1,this.focusY=-1,this.tableSelection=null,this.anchorCellNodeKey=null,this.focusCellNodeKey=null,this.anchorCell=null,this.focusCell=null,this.hasHijackedSelectionStyles=!1,this.$enableHighlightStyle();const{tableNode:n,tableElement:o}=this.$lookup();Q(e,V(n,o),null),null!==t.$getSelection()&&(t.$setSelection(null),e.dispatchCommand(t.SELECTION_CHANGE_COMMAND,void 0))}$enableHighlightStyle(){const t=this.editor,{tableElement:n}=this.$lookup();e.removeClassNamesFromElement(n,t._config.theme.tableSelection),n.classList.remove("disable-selection"),this.hasHijackedSelectionStyles=!1}$disableHighlightStyle(){const{tableElement:t}=this.$lookup();e.addClassNamesToElement(t,this.editor._config.theme.tableSelection),this.hasHijackedSelectionStyles=!0}$updateTableTableSelection(e){if(null!==e){e.tableKey!==this.tableNodeKey&&h(233,e.tableKey,this.tableNodeKey);const t=this.editor;this.tableSelection=e,this.isHighlightingCells=!0,this.$disableHighlightStyle(),this.updateDOMSelection(),Q(t,this.table,this.tableSelection)}else this.$clearHighlight()}setShouldCheckSelection(){this.shouldCheckSelection=!0}getAndClearShouldCheckSelection(){return!!this.shouldCheckSelection&&(this.shouldCheckSelection=!1,!0)}setNextFocus(e){this.nextFocus=e}getAndClearNextFocus(){const{nextFocus:e}=this;return null!==e&&(this.nextFocus=null),e}updateDOMSelection(){if(null!==this.anchorCell&&null!==this.focusCell){const e=t.getDOMSelection(this.editor._window);e&&e.rangeCount>0&&e.removeAllRanges()}}$setFocusCellForSelection(e,n=!1){const o=this.editor,{tableNode:r}=this.$lookup(),l=e.x,s=e.y;if(this.focusCell=e,this.isHighlightingCells||this.anchorX===l&&this.anchorY===s&&!n){if(l===this.focusX&&s===this.focusY)return!1}else this.isHighlightingCells=!0,this.$disableHighlightStyle();if(this.focusX=l,this.focusY=s,this.isHighlightingCells){const n=pe(r,e.elem);if(null!=this.tableSelection&&null!=this.anchorCellNodeKey&&null!==n)return this.focusCellNodeKey=n.getKey(),this.tableSelection=K(r,this.$getAnchorTableCellOrThrow(),n),t.$setSelection(this.tableSelection),o.dispatchCommand(t.SELECTION_CHANGE_COMMAND,void 0),Q(o,this.table,this.tableSelection),!0}return!1}$getAnchorTableCell(){return this.anchorCellNodeKey?t.$getNodeByKey(this.anchorCellNodeKey):null}$getAnchorTableCellOrThrow(){const e=this.$getAnchorTableCell();return null===e&&h(234),e}$getFocusTableCell(){return this.focusCellNodeKey?t.$getNodeByKey(this.focusCellNodeKey):null}$getFocusTableCellOrThrow(){const e=this.$getFocusTableCell();return null===e&&h(235),e}$setAnchorCellForSelection(e){this.isHighlightingCells=!1,this.anchorCell=e,this.anchorX=e.x,this.anchorY=e.y;const{tableNode:t}=this.$lookup(),n=pe(t,e.elem);if(null!==n){const e=n.getKey();this.tableSelection=null!=this.tableSelection?this.tableSelection.clone():D(),this.anchorCellNodeKey=e}}$formatCells(e){const n=t.$getSelection();P(n)||h(236);const o=t.$createRangeSelection(),r=o.anchor,l=o.focus,s=n.getNodes().filter(c);s.length>0||h(237);const i=s[0].getFirstChild(),a=t.$isParagraphNode(i)?i.getFormatFlags(e,null):null;s.forEach((t=>{r.set(t.getKey(),0,"element"),l.set(t.getKey(),t.getChildrenSize(),"element"),o.formatText(e,a)})),t.$setSelection(n),this.editor.dispatchCommand(t.SELECTION_CHANGE_COMMAND,void 0)}$clearText(){const{editor:e}=this,n=t.$getNodeByKey(this.tableNodeKey);if(!Re(n))throw new Error("Expected TableNode.");const o=t.$getSelection();P(o)||h(253);const r=o.getNodes().filter(c);if(r.length===this.table.columns*this.table.rows)return n.selectPrevious(),void n.remove();r.forEach((e=>{if(t.$isElementNode(e)){const n=t.$createParagraphNode(),o=t.$createTextNode();n.append(o),e.append(n),e.getChildren().forEach((e=>{e!==n&&e.remove()}))}})),Q(e,this.table,null),t.$setSelection(null),e.dispatchCommand(t.SELECTION_CHANGE_COMMAND,void 0)}}const H="__lexicalTableSelection",W=e=>!(1&~e.buttons);function B(e,t){if(!t)return t;const n="TABLE"===t.nodeName?t:e.getDOMSlot(t).element;return"TABLE"!==n.nodeName&&h(245,t.nodeName),n}function z(e){return e._window}function Y(e,t){for(let n=t,o=null;null!==n;n=n.getParent()){if(e.is(n))return o;c(n)&&(o=n)}return null}const U=[[t.KEY_ARROW_DOWN_COMMAND,"down"],[t.KEY_ARROW_UP_COMMAND,"up"],[t.KEY_ARROW_LEFT_COMMAND,"backward"],[t.KEY_ARROW_RIGHT_COMMAND,"forward"]],X=[t.DELETE_WORD_COMMAND,t.DELETE_LINE_COMMAND,t.DELETE_CHARACTER_COMMAND],J=[t.KEY_BACKSPACE_COMMAND,t.KEY_DELETE_COMMAND];function q(o,r,l,s){const i=l.getRootElement(),a=z(l);null!==i&&null!==a||h(246);const u=new L(l,o.getKey()),d=B(o,r);!function(e,t){null!==G(e)&&h(205);e[H]=t}(d,u),u.listenersToRemove.add((()=>function(e,t){G(e)===t&&delete e[H]}(d,u)));d.addEventListener("mousedown",(e=>{if(0!==e.button||!t.isDOMNode(e.target)||!a)return;const n=j(e.target);null!==n&&l.update((()=>{const r=t.$getPreviousSelection();if(S&&e.shiftKey&&se(r,o)&&(t.$isRangeSelection(r)||P(r))){const t=r.anchor.getNode(),l=Y(o,r.anchor.getNode());if(l)u.$setAnchorCellForSelection(Ce(u,l)),u.$setFocusCellForSelection(n),ge(e);else{(o.isBefore(t)?o.selectStart():o.selectEnd()).anchor.set(r.anchor.key,r.anchor.offset,r.anchor.type)}}else u.$setAnchorCellForSelection(n)})),(()=>{if(u.isSelecting)return;const e=()=>{u.isSelecting=!1,a.removeEventListener("mouseup",e),a.removeEventListener("mousemove",n)},n=o=>{if(!t.isDOMNode(o.target))return;if(!W(o)&&u.isSelecting)return u.isSelecting=!1,a.removeEventListener("mouseup",e),void a.removeEventListener("mousemove",n);const r=!d.contains(o.target);let s=null;if(r){for(const e of document.elementsFromPoint(o.clientX,o.clientY))if(s=d.contains(e)?j(e):null,s)break}else s=j(o.target);!s||null!==u.focusCell&&s.elem===u.focusCell.elem||(u.setNextFocus({focusCell:s,override:r}),l.dispatchCommand(t.SELECTION_CHANGE_COMMAND,void 0))};u.isSelecting=!0,a.addEventListener("mouseup",e,u.listenerOptions),a.addEventListener("mousemove",n,u.listenerOptions)})()}),u.listenerOptions);a.addEventListener("mousedown",(e=>{const n=e.target;0===e.button&&t.isDOMNode(n)&&l.update((()=>{const e=t.$getSelection();P(e)&&e.tableKey===u.tableNodeKey&&i.contains(n)&&u.$clearHighlight()}))}),u.listenerOptions);for(const[e,n]of U)u.listenersToRemove.add(l.registerCommand(e,(e=>he(l,e,n,o,u)),t.COMMAND_PRIORITY_HIGH));u.listenersToRemove.add(l.registerCommand(t.KEY_ESCAPE_COMMAND,(e=>{const n=t.$getSelection();if(P(n)){const t=Y(o,n.focus.getNode());if(null!==t)return ge(e),t.selectEnd(),!0}return!1}),t.COMMAND_PRIORITY_HIGH));const g=n=>()=>{const r=t.$getSelection();if(!se(r,o))return!1;if(P(r))return u.$clearText(),!0;if(t.$isRangeSelection(r)){if(!c(Y(o,r.anchor.getNode())))return!1;const l=r.anchor.getNode(),s=r.focus.getNode(),i=o.isParentOf(l),a=o.isParentOf(s);if(i&&!a||a&&!i)return u.$clearText(),!0;const d=e.$findMatchingParent(r.anchor.getNode(),(e=>t.$isElementNode(e))),h=d&&e.$findMatchingParent(d,(e=>t.$isElementNode(e)&&c(e.getParent())));if(!t.$isElementNode(h)||!t.$isElementNode(d))return!1;if(n===t.DELETE_LINE_COMMAND&&null===h.getPreviousSibling())return!0}return!1};for(const e of X)u.listenersToRemove.add(l.registerCommand(e,g(e),t.COMMAND_PRIORITY_CRITICAL));const f=e=>{const n=t.$getSelection();if(!P(n)&&!t.$isRangeSelection(n))return!1;const r=o.isParentOf(n.anchor.getNode());if(r!==o.isParentOf(n.focus.getNode())){const e=r?"anchor":"focus",t=r?"focus":"anchor",{key:l,offset:s,type:i}=n[t];return o[n[e].isBefore(n[t])?"selectPrevious":"selectNext"]()[t].set(l,s,i),!1}return!!se(n,o)&&(!!P(n)&&(e&&(e.preventDefault(),e.stopPropagation()),u.$clearText(),!0))};for(const e of J)u.listenersToRemove.add(l.registerCommand(e,f,t.COMMAND_PRIORITY_CRITICAL));return u.listenersToRemove.add(l.registerCommand(t.CUT_COMMAND,(o=>{const r=t.$getSelection();if(r){if(!P(r)&&!t.$isRangeSelection(r))return!1;n.copyToClipboard(l,e.objectKlassEquals(o,ClipboardEvent)?o:null,n.$getClipboardDataFromSelection(r));const s=f(o);return t.$isRangeSelection(r)?(r.removeText(),!0):s}return!1}),t.COMMAND_PRIORITY_CRITICAL)),u.listenersToRemove.add(l.registerCommand(t.FORMAT_TEXT_COMMAND,(n=>{const r=t.$getSelection();if(!se(r,o))return!1;if(P(r))return u.$formatCells(n),!0;if(t.$isRangeSelection(r)){const t=e.$findMatchingParent(r.anchor.getNode(),(e=>c(e)));if(!c(t))return!1}return!1}),t.COMMAND_PRIORITY_CRITICAL)),u.listenersToRemove.add(l.registerCommand(t.FORMAT_ELEMENT_COMMAND,(e=>{const n=t.$getSelection();if(!P(n)||!se(n,o))return!1;const r=n.anchor.getNode(),l=n.focus.getNode();if(!c(r)||!c(l))return!1;if(function(e,t){if(P(e)){const n=e.anchor.getNode(),o=e.focus.getNode();if(t&&n&&o){const[e]=R(t,n,o);return n.getKey()===e[0][0].cell.getKey()&&o.getKey()===e[e.length-1].at(-1).cell.getKey()}}return!1}(n,o))return o.setFormat(e),!0;const[s,i,a]=R(o,r,l),u=Math.max(i.startRow+i.cell.__rowSpan-1,a.startRow+a.cell.__rowSpan-1),d=Math.max(i.startColumn+i.cell.__colSpan-1,a.startColumn+a.cell.__colSpan-1),h=Math.min(i.startRow,a.startRow),g=Math.min(i.startColumn,a.startColumn),f=new Set;for(let n=h;n<=u;n++)for(let o=g;o<=d;o++){const r=s[n][o].cell;if(f.has(r))continue;f.add(r),r.setFormat(e);const l=r.getChildren();for(let n=0;n<l.length;n++){const o=l[n];t.$isElementNode(o)&&!o.isInline()&&o.setFormat(e)}}return!0}),t.COMMAND_PRIORITY_CRITICAL)),u.listenersToRemove.add(l.registerCommand(t.CONTROLLED_TEXT_INSERTION_COMMAND,(n=>{const r=t.$getSelection();if(!se(r,o))return!1;if(P(r))return u.$clearHighlight(),!1;if(t.$isRangeSelection(r)){const s=e.$findMatchingParent(r.anchor.getNode(),(e=>c(e)));if(!c(s))return!1;if("string"==typeof n){const e=me(l,r,o);if(e)return fe(e,o,[t.$createTextNode(n)]),!0}}return!1}),t.COMMAND_PRIORITY_CRITICAL)),s&&u.listenersToRemove.add(l.registerCommand(t.KEY_TAB_COMMAND,(n=>{const r=t.$getSelection();if(!t.$isRangeSelection(r)||!r.isCollapsed()||!se(r,o))return!1;const l=ue(r.anchor.getNode());return!(null===l||!o.is(de(l)))&&(ge(n),function(n,o){const r="next"===o?"getNextSibling":"getPreviousSibling",l="next"===o?"getFirstChild":"getLastChild",s=n[r]();if(t.$isElementNode(s))return s.selectEnd();const i=e.$findMatchingParent(n,C);null===i&&h(247);for(let e=i[r]();C(e);e=e[r]()){const n=e[l]();if(t.$isElementNode(n))return n.selectEnd()}const a=e.$findMatchingParent(i,Re);null===a&&h(248);"next"===o?a.selectNext():a.selectPrevious()}(l,n.shiftKey?"previous":"next"),!0)}),t.COMMAND_PRIORITY_CRITICAL)),u.listenersToRemove.add(l.registerCommand(t.FOCUS_COMMAND,(e=>o.isSelected()),t.COMMAND_PRIORITY_HIGH)),u.listenersToRemove.add(l.registerCommand(t.SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,(n=>{const{nodes:o,selection:r}=n,l=r.getStartEndPoints(),s=P(r),i=t.$isRangeSelection(r)&&null!==e.$findMatchingParent(r.anchor.getNode(),(e=>c(e)))&&null!==e.$findMatchingParent(r.focus.getNode(),(e=>c(e)))||s;if(1!==o.length||!Re(o[0])||!i||null===l)return!1;const[a]=l,u=o[0],d=u.getChildren(),h=u.getFirstChildOrThrow().getChildrenSize(),g=u.getChildrenSize(),f=e.$findMatchingParent(a.getNode(),(e=>c(e))),m=f&&e.$findMatchingParent(f,(e=>C(e))),p=m&&e.$findMatchingParent(m,(e=>Re(e)));if(!c(f)||!C(m)||!Re(p))return!1;const _=m.getIndexWithinParent(),S=Math.min(p.getChildrenSize()-1,_+g-1),N=f.getIndexWithinParent(),b=Math.min(m.getChildrenSize()-1,N+h-1),w=Math.min(N,b),T=Math.min(_,S),y=Math.max(N,b),$=Math.max(_,S),M=p.getChildren();let R=0;for(let e=T;e<=$;e++){const n=M[e];if(!C(n))return!1;const o=d[R];if(!C(o))return!1;const r=n.getChildren(),l=o.getChildren();let s=0;for(let e=w;e<=y;e++){const n=r[e];if(!c(n))return!1;const o=l[s];if(!c(o))return!1;const i=n.getChildren();o.getChildren().forEach((e=>{if(t.$isTextNode(e)){t.$createParagraphNode().append(e),n.append(e)}else n.append(e)})),i.forEach((e=>e.remove())),s++}R++}return!0}),t.COMMAND_PRIORITY_CRITICAL)),u.listenersToRemove.add(l.registerCommand(t.SELECTION_CHANGE_COMMAND,(()=>{const n=t.$getSelection(),r=t.$getPreviousSelection(),s=u.getAndClearNextFocus();if(null!==s){const{focusCell:e}=s;if(P(n)&&n.tableKey===u.tableNodeKey)return(e.x!==u.focusX||e.y!==u.focusY)&&(u.$setFocusCellForSelection(e),!0);if(e!==u.anchorCell&&se(n,o))return u.$setFocusCellForSelection(e),!0}if(u.getAndClearShouldCheckSelection()&&t.$isRangeSelection(r)&&t.$isRangeSelection(n)&&n.isCollapsed()){const t=n.anchor.getNode(),r=o.getFirstChild(),l=ue(t);if(null!==l&&C(r)){const t=r.getFirstChild();if(c(t)&&o.is(e.$findMatchingParent(l,(e=>e.is(o)||e.is(t)))))return t.selectStart(),!0}}if(t.$isRangeSelection(n)){const{anchor:e,focus:r}=n,s=e.getNode(),i=r.getNode(),a=ue(s),c=ue(i),d=!(!a||!o.is(de(a))),h=!(!c||!o.is(de(c))),g=d!==h,f=d&&h,m=n.isBackward();if(g){const e=n.clone();if(h){const[t]=R(o,c,c),n=t[0][0].cell,r=t[t.length-1].at(-1).cell;e.focus.set(m?n.getKey():r.getKey(),m?n.getChildrenSize():r.getChildrenSize(),"element")}else if(d){const[t]=R(o,a,a),n=t[0][0].cell,r=t[t.length-1].at(-1).cell;e.anchor.set(m?r.getKey():n.getKey(),m?r.getChildrenSize():0,"element")}t.$setSelection(e),ee(l,u)}else f&&(a.is(c)||(u.$setAnchorCellForSelection(Ce(u,a)),u.$setFocusCellForSelection(Ce(u,c),!0)))}else if(n&&P(n)&&n.is(r)&&n.tableKey===o.getKey()){const e=t.getDOMSelection(a);if(e&&e.anchorNode&&e.focusNode){const r=t.$getNearestNodeFromDOMNode(e.focusNode),s=r&&!o.isParentOf(r),i=t.$getNearestNodeFromDOMNode(e.anchorNode),a=i&&o.isParentOf(i);if(s&&a&&e.rangeCount>0){const r=t.$createRangeSelectionFromDom(e,l);r&&(r.anchor.set(o.getKey(),n.isBackward()?o.getChildrenSize():0,"element"),e.removeAllRanges(),t.$setSelection(r))}}}return n&&!n.is(r)&&(P(n)||P(r))&&u.tableSelection&&!u.tableSelection.is(r)?(P(n)&&n.tableKey===u.tableNodeKey?u.$updateTableTableSelection(n):!P(n)&&P(r)&&r.tableKey===u.tableNodeKey&&u.$updateTableTableSelection(null),!1):(u.hasHijackedSelectionStyles&&!o.isSelected()?function(e,t){t.$enableHighlightStyle(),Z(t.table,(t=>{const n=t.elem;t.highlighted=!1,ce(e,t),n.getAttribute("style")||n.removeAttribute("style")}))}(l,u):!u.hasHijackedSelectionStyles&&o.isSelected()&&ee(l,u),!1)}),t.COMMAND_PRIORITY_CRITICAL)),u.listenersToRemove.add(l.registerCommand(t.INSERT_PARAGRAPH_COMMAND,(()=>{const e=t.$getSelection();if(!t.$isRangeSelection(e)||!e.isCollapsed()||!se(e,o))return!1;const n=me(l,e,o);return!!n&&(fe(n,o),!0)}),t.COMMAND_PRIORITY_CRITICAL)),u}function G(e){return e[H]||null}function j(e){let t=e;for(;null!=t;){const e=t.nodeName;if("TD"===e||"TH"===e){const e=t._cell;return void 0===e?null:e}t=t.parentNode}return null}function V(e,t){const n=[],o={columns:0,domRows:n,rows:0};let r=B(e,t).querySelector("tr"),l=0,s=0;for(n.length=0;null!=r;){const e=r.nodeName;if("TD"===e||"TH"===e){const e={elem:r,hasBackgroundColor:""!==r.style.backgroundColor,highlighted:!1,x:l,y:s};r._cell=e;let t=n[s];void 0===t&&(t=n[s]=[]),t[l]=e}else{const e=r.firstChild;if(null!=e){r=e;continue}}const t=r.nextSibling;if(null!=t){l++,r=t;continue}const o=r.parentNode;if(null!=o){const e=o.nextSibling;if(null==e)break;s++,l=0,r=e}}return o.columns=l+1,o.rows=s+1,o}function Q(e,t,n){const o=new Set(n?n.getNodes():[]);Z(t,((t,n)=>{const r=t.elem;o.has(n)?(t.highlighted=!0,ae(e,t)):(t.highlighted=!1,ce(e,t),r.getAttribute("style")||r.removeAttribute("style"))}))}function Z(e,n){const{domRows:o}=e;for(let e=0;e<o.length;e++){const r=o[e];if(r)for(let o=0;o<r.length;o++){const l=r[o];if(!l)continue;const s=t.$getNearestNodeFromDOMNode(l.elem);null!==s&&n(l,s,{x:o,y:e})}}}function ee(e,t){t.$disableHighlightStyle(),Z(t.table,(t=>{t.highlighted=!0,ae(e,t)}))}const te=(e,t,n,o,r)=>{const l="forward"===r;switch(r){case"backward":case"forward":return n!==(l?e.table.columns-1:0)?ie(t.getCellNodeFromCordsOrThrow(n+(l?1:-1),o,e.table),l):o!==(l?e.table.rows-1:0)?ie(t.getCellNodeFromCordsOrThrow(l?0:e.table.columns-1,o+(l?1:-1),e.table),l):l?t.selectNext():t.selectPrevious(),!0;case"up":return 0!==o?ie(t.getCellNodeFromCordsOrThrow(n,o-1,e.table),!1):t.selectPrevious(),!0;case"down":return o!==e.table.rows-1?ie(t.getCellNodeFromCordsOrThrow(n,o+1,e.table),!0):t.selectNext(),!0;default:return!1}};function ne(e,t){let n,o;if(t.startColumn===e.minColumn)n="minColumn";else{if(t.startColumn+t.cell.__colSpan-1!==e.maxColumn)return null;n="maxColumn"}if(t.startRow===e.minRow)o="minRow";else{if(t.startRow+t.cell.__rowSpan-1!==e.maxRow)return null;o="maxRow"}return[n,o]}function oe([e,t]){return["minColumn"===e?"maxColumn":"minColumn","minRow"===t?"maxRow":"minRow"]}function re(e,t,[n,o]){const r=t[o],l=e[r];void 0===l&&h(250,o,String(r));const s=t[n],i=l[s];return void 0===i&&h(250,n,String(s)),i}function le(e,t,n,o,r){const l=O(t,n,o),s=function(e,t){const{minColumn:n,maxColumn:o,minRow:r,maxRow:l}=t;let s=1,i=1,a=1,c=1;const u=e[r],d=e[l];for(let e=n;e<=o;e++)s=Math.max(s,u[e].cell.__rowSpan),c=Math.max(c,d[e].cell.__rowSpan);for(let t=r;t<=l;t++)i=Math.max(i,e[t][n].cell.__colSpan),a=Math.max(a,e[t][o].cell.__colSpan);return{bottomSpan:c,leftSpan:i,rightSpan:a,topSpan:s}}(t,l),{topSpan:i,leftSpan:a,bottomSpan:c,rightSpan:u}=s,d=function(e,t){const n=ne(e,t);return null===n&&h(249,t.cell.getKey()),n}(l,n),[g,f]=oe(d);let m=l[g],C=l[f];"forward"===r?m+="maxColumn"===g?1:a:"backward"===r?m-="minColumn"===g?1:u:"down"===r?C+="maxRow"===f?1:i:"up"===r&&(C-="minRow"===f?1:c);const p=t[C];if(void 0===p)return!1;const _=p[m];if(void 0===_)return!1;const[S,N]=function(e,t,n){const o=O(e,t,n),r=ne(o,t);if(r)return[re(e,o,r),re(e,o,oe(r))];const l=ne(o,n);if(l)return[re(e,o,oe(l)),re(e,o,l)];const s=["minColumn","minRow"];return[re(e,o,s),re(e,o,oe(s))]}(t,n,_),b=Ce(e,S.cell),w=Ce(e,N.cell);return e.$setAnchorCellForSelection(b),e.$setFocusCellForSelection(w,!0),!0}function se(e,n){if(t.$isRangeSelection(e)||P(e)){const t=n.isParentOf(e.anchor.getNode()),o=n.isParentOf(e.focus.getNode());return t&&o}return!1}function ie(e,t){t?e.selectStart():e.selectEnd()}function ae(n,o){const r=o.elem,l=n._config.theme;c(t.$getNearestNodeFromDOMNode(r))||h(131),e.addClassNamesToElement(r,l.tableCellSelected)}function ce(n,o){const r=o.elem;c(t.$getNearestNodeFromDOMNode(r))||h(131);const l=n._config.theme;e.removeClassNamesFromElement(r,l.tableCellSelected)}function ue(t){const n=e.$findMatchingParent(t,c);return c(n)?n:null}function de(t){const n=e.$findMatchingParent(t,Re);return Re(n)?n:null}function he(n,o,r,l,s){if(("up"===r||"down"===r)&&function(e){const t=e.getRootElement();if(!t)return!1;return t.hasAttribute("aria-controls")&&"typeahead-menu"===t.getAttribute("aria-controls")}(n))return!1;const i=t.$getSelection();if(!se(i,l)){if(t.$isRangeSelection(i)){if("backward"===r){if(i.focus.offset>0)return!1;const e=function(e){for(let n=e,o=e;null!==o;n=o,o=o.getParent())if(t.$isElementNode(o)){if(o!==n&&o.getFirstChild()!==n)return null;if(!o.isInline())return o}return null}(i.focus.getNode());if(!e)return!1;const n=e.getPreviousSibling();return!!Re(n)&&(ge(o),o.shiftKey?i.focus.set(n.getParentOrThrow().getKey(),n.getIndexWithinParent(),"element"):n.selectEnd(),!0)}if(o.shiftKey&&("up"===r||"down"===r)){const n=i.focus.getNode();if(!i.isCollapsed()&&("up"===r&&!i.isBackward()||"down"===r&&i.isBackward())){let s=e.$findMatchingParent(n,(e=>Re(e)));if(c(s)&&(s=e.$findMatchingParent(s,Re)),s!==l)return!1;if(!s)return!1;const a="down"===r?s.getNextSibling():s.getPreviousSibling();if(!a)return!1;let u=0;"up"===r&&t.$isElementNode(a)&&(u=a.getChildrenSize());let d=a;if("up"===r&&t.$isElementNode(a)){const e=a.getLastChild();d=e||a,u=t.$isTextNode(d)?d.getTextContentSize():0}const h=i.clone();return h.focus.set(d.getKey(),u,t.$isTextNode(d)?"text":"element"),t.$setSelection(h),ge(o),!0}if(t.$isRootOrShadowRoot(n)){const e="up"===r?i.getNodes()[i.getNodes().length-1]:i.getNodes()[0];if(e){if(null!==Y(l,e)){const e=l.getFirstDescendant(),t=l.getLastDescendant();if(!e||!t)return!1;const[n]=E(e),[o]=E(t),r=l.getCordsFromCellNode(n,s.table),i=l.getCordsFromCellNode(o,s.table),a=l.getDOMCellFromCordsOrThrow(r.x,r.y,s.table),c=l.getDOMCellFromCordsOrThrow(i.x,i.y,s.table);return s.$setAnchorCellForSelection(a),s.$setFocusCellForSelection(c,!0),!0}}return!1}{let l=e.$findMatchingParent(n,(e=>t.$isElementNode(e)&&!e.isInline()));if(c(l)&&(l=e.$findMatchingParent(l,Re)),!l)return!1;const a="down"===r?l.getNextSibling():l.getPreviousSibling();if(Re(a)&&s.tableNodeKey===a.getKey()){const e=a.getFirstDescendant(),n=a.getLastDescendant();if(!e||!n)return!1;const[l]=E(e),[s]=E(n),c=i.clone();return c.focus.set(("up"===r?l:s).getKey(),"up"===r?0:s.getChildrenSize(),"element"),ge(o),t.$setSelection(c),!0}}}}return"down"===r&&Te(n)&&s.setShouldCheckSelection(),!1}if(t.$isRangeSelection(i)&&i.isCollapsed()){const{anchor:a,focus:u}=i,d=e.$findMatchingParent(a.getNode(),c),h=e.$findMatchingParent(u.getNode(),c);if(!c(d)||!d.is(h))return!1;const g=de(d);if(g!==l&&null!=g){const e=B(g,n.getElementByKey(g.getKey()));if(null!=e)return s.table=V(g,e),he(n,o,r,g,s)}if("backward"===r||"forward"===r){const n=a.type,s=a.offset,c=a.getNode();if(!c)return!1;const u=i.getNodes();return(1!==u.length||!t.$isDecoratorNode(u[0]))&&(!!function(n,o,r,l){return function(e,t,n){return"element"===e&&("backward"===n?null===t.getPreviousSibling():null===t.getNextSibling())}(n,r,l)||function(n,o,r,l){const s=e.$findMatchingParent(r,(e=>t.$isElementNode(e)&&!e.isInline()));if(!s)return!1;const i="backward"===l?0===o:o===r.getTextContentSize();return"text"===n&&i&&("backward"===l?null===s.getPreviousSibling():null===s.getNextSibling())}(n,o,r,l)}(n,s,c,r)&&function(n,o,r,l,s){const[i,a]=R(l,r,r);if(!function(e,t,n){const o=e[0][0],r=e[e.length-1][e[0].length-1],{startColumn:l,startRow:s}=t;return"backward"===n?l===o.startColumn&&s===o.startRow:l===r.startColumn&&s===r.startRow}(i,a,s))return!1;const c=function(n,o,r){const l=e.$findMatchingParent(n,(e=>t.$isElementNode(e)&&!e.isInline()));if(!l)return;const s="backward"===o?l.getPreviousSibling():l.getNextSibling();return s&&Re(s)?s:"backward"===o?r.getPreviousSibling():r.getNextSibling()}(o,s,l);if(!c||Re(c))return!1;ge(n),"backward"===s?c.selectEnd():c.selectStart();return!0}(o,c,d,l,r))}const f=n.getElementByKey(d.__key),m=n.getElementByKey(a.key);if(null==m||null==f)return!1;let C;if("element"===a.type)C=m.getBoundingClientRect();else{const e=t.getDOMSelection(z(n));if(null===e||0===e.rangeCount)return!1;C=e.getRangeAt(0).getBoundingClientRect()}const p="up"===r?d.getFirstChild():d.getLastChild();if(null==p)return!1;const _=n.getElementByKey(p.__key);if(null==_)return!1;const S=_.getBoundingClientRect();if("up"===r?S.top>C.top-C.height:C.bottom+C.height>S.bottom){ge(o);const e=l.getCordsFromCellNode(d,s.table);if(!o.shiftKey)return te(s,l,e.x,e.y,r);{const t=l.getDOMCellFromCordsOrThrow(e.x,e.y,s.table);s.$setAnchorCellForSelection(t),s.$setFocusCellForSelection(t,!0)}return!0}}else if(P(i)){const{anchor:t,focus:a}=i,u=e.$findMatchingParent(t.getNode(),c),d=e.$findMatchingParent(a.getNode(),c),[g]=i.getNodes();Re(g)||h(251);const f=B(g,n.getElementByKey(g.getKey()));if(!c(u)||!c(d)||!Re(g)||null==f)return!1;s.$updateTableTableSelection(i);const m=V(g,f),C=l.getCordsFromCellNode(u,m),p=l.getDOMCellFromCordsOrThrow(C.x,C.y,m);if(s.$setAnchorCellForSelection(p),ge(o),o.shiftKey){const[e,t,n]=R(l,u,d);return le(s,e,t,n,r)}return d.selectEnd(),!0}return!1}function ge(e){e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation()}function fe(e,n,o){const r=t.$createParagraphNode();"first"===e?n.insertBefore(r):n.insertAfter(r),r.append(...o||[]),r.selectEnd()}function me(n,o,r){const l=r.getParent();if(!l)return;const s=t.getDOMSelection(z(n));if(!s)return;const i=s.anchorNode,a=n.getElementByKey(l.getKey()),u=B(r,n.getElementByKey(r.getKey()));if(!i||!a||!u||!a.contains(i)||u.contains(i))return;const d=e.$findMatchingParent(o.anchor.getNode(),(e=>c(e)));if(!d)return;const h=e.$findMatchingParent(d,(e=>Re(e)));if(!Re(h)||!h.is(r))return;const[g,f]=R(r,d,d),m=g[0][0],C=g[g.length-1][g[0].length-1],{startRow:p,startColumn:_}=f,S=p===m.startRow&&_===m.startColumn,N=p===C.startRow&&_===C.startColumn;return S?"first":N?"last":void 0}function Ce(e,t){const{tableNode:n}=e.$lookup(),o=n.getCordsFromCellNode(t,e.table);return n.getDOMCellFromCordsOrThrow(o.x,o.y,e.table)}function pe(e,n,o){return Y(e,t.$getNearestNodeFromDOMNode(n,o))}function _e(e,t,n,o){const r=e.querySelector("colgroup");if(!r)return;const l=[];for(let e=0;e<n;e++){const t=document.createElement("col"),n=o&&o[e];n&&(t.style.width=`${n}px`),l.push(t)}r.replaceChildren(...l)}function Se(t,n,o){o?(e.addClassNamesToElement(t,n.theme.tableRowStriping),t.setAttribute("data-lexical-row-striping","true")):(e.removeClassNamesFromElement(t,n.theme.tableRowStriping),t.removeAttribute("data-lexical-row-striping"))}function Ne(t,n,o){o>0?(e.addClassNamesToElement(t,n.theme.tableFrozenColumn),t.setAttribute("data-lexical-frozen-column","true")):(e.removeClassNamesFromElement(t,n.theme.tableFrozenColumn),t.removeAttribute("data-lexical-frozen-column"))}function be(t,n,o){if(!n.theme.tableAlignment)return;const r=[],l=[];for(const e of["center","right"]){const t=n.theme.tableAlignment[e];t&&(e===o?l:r).push(t)}e.removeClassNamesFromElement(t,...r),e.addClassNamesToElement(t,...l)}const we=new WeakSet;function Te(e=t.$getEditor()){return we.has(e)}class ye extends t.ElementNode{static getType(){return"table"}getColWidths(){return this.getLatest().__colWidths}setColWidths(e){const t=this.getWritable();return t.__colWidths=e,t}static clone(e){return new ye(e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__colWidths=e.__colWidths,this.__rowStriping=e.__rowStriping,this.__frozenColumnCount=e.__frozenColumnCount}static importDOM(){return{table:e=>({conversion:$e,priority:1})}}static importJSON(e){return Me().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setRowStriping(e.rowStriping||!1).setFrozenColumns(e.frozenColumnCount||0).setColWidths(e.colWidths)}constructor(e){super(e),this.__rowStriping=!1,this.__frozenColumnCount=0}exportJSON(){return{...super.exportJSON(),colWidths:this.getColWidths(),frozenColumnCount:this.__frozenColumnCount?this.__frozenColumnCount:void 0,rowStriping:this.__rowStriping?this.__rowStriping:void 0}}extractWithChild(e,t,n){return"html"===n}getDOMSlot(e){const t="TABLE"!==e.nodeName&&e.querySelector("table")||e;return"TABLE"!==t.nodeName&&h(229),super.getDOMSlot(t).withAfter(t.querySelector("colgroup"))}createDOM(n,o){const r=document.createElement("table"),l=document.createElement("colgroup");if(r.appendChild(l),_e(r,0,this.getColumnCount(),this.getColWidths()),t.setDOMUnmanaged(l),e.addClassNamesToElement(r,n.theme.table),be(r,n,this.getFormatType()),this.__frozenColumnCount&&Ne(r,n,this.__frozenColumnCount),this.__rowStriping&&Se(r,n,!0),Te(o)){const t=document.createElement("div"),o=n.theme.tableScrollableWrapper;return o?e.addClassNamesToElement(t,o):t.style.cssText="overflow-x: auto;",t.appendChild(r),t}return r}updateDOM(e,t,n){return e.__rowStriping!==this.__rowStriping&&Se(t,n,this.__rowStriping),e.__frozenColumnCount!==this.__frozenColumnCount&&Ne(t,n,this.__frozenColumnCount),_e(t,0,this.getColumnCount(),this.getColWidths()),be(this.getDOMSlot(t).element,n,this.getFormatType()),!1}exportDOM(t){const n=super.exportDOM(t),{element:o}=n;return{after:o=>{if(n.after&&(o=n.after(o),this.__format&&be(o,t._config,this.getFormatType())),e.isHTMLElement(o)&&"TABLE"!==o.nodeName&&(o=o.querySelector("table")),!e.isHTMLElement(o))return null;const[r]=x(this,null,null),l=new Map;for(const e of r)for(const t of e){const e=t.cell.getKey();l.has(e)||l.set(e,{colSpan:t.cell.getColSpan(),startColumn:t.startColumn})}const s=new Set;for(const e of o.querySelectorAll(":scope > tr > [data-temporary-table-cell-lexical-key]")){const t=e.getAttribute("data-temporary-table-cell-lexical-key");if(t){const n=l.get(t);if(e.removeAttribute("data-temporary-table-cell-lexical-key"),n){l.delete(t);for(let e=0;e<n.colSpan;e++)s.add(e+n.startColumn)}}}const i=o.querySelector(":scope > colgroup");if(i){const e=Array.from(o.querySelectorAll(":scope > colgroup > col")).filter(((e,t)=>s.has(t)));i.replaceChildren(...e)}const a=o.querySelectorAll(":scope > tr");if(a.length>0){const e=document.createElement("tbody");for(const t of a)e.appendChild(t);o.append(e)}return o},element:e.isHTMLElement(o)&&"TABLE"!==o.nodeName?o.querySelector("table"):o}}canBeEmpty(){return!1}isShadowRoot(){return!0}getCordsFromCellNode(e,t){const{rows:n,domRows:o}=t;for(let t=0;t<n;t++){const n=o[t];if(null!=n)for(let o=0;o<n.length;o++){const r=n[o];if(null==r)continue;const{elem:l}=r,s=pe(this,l);if(null!==s&&e.is(s))return{x:o,y:t}}}throw new Error("Cell not found in table.")}getDOMCellFromCords(e,t,n){const{domRows:o}=n,r=o[t];if(null==r)return null;const l=r[e<r.length?e:r.length-1];return null==l?null:l}getDOMCellFromCordsOrThrow(e,t,n){const o=this.getDOMCellFromCords(e,t,n);if(!o)throw new Error("Cell not found at cords.");return o}getCellNodeFromCords(e,n,o){const r=this.getDOMCellFromCords(e,n,o);if(null==r)return null;const l=t.$getNearestNodeFromDOMNode(r.elem);return c(l)?l:null}getCellNodeFromCordsOrThrow(e,t,n){const o=this.getCellNodeFromCords(e,t,n);if(!o)throw new Error("Node at cords not TableCellNode.");return o}getRowStriping(){return Boolean(this.getLatest().__rowStriping)}setRowStriping(e){const t=this.getWritable();return t.__rowStriping=e,t}setFrozenColumns(e){const t=this.getWritable();return t.__frozenColumnCount=e,t}getFrozenColumns(){return this.getLatest().__frozenColumnCount}canSelectBefore(){return!0}canIndent(){return!1}getColumnCount(){const e=this.getFirstChild();if(!e)return 0;let t=0;return e.getChildren().forEach((e=>{c(e)&&(t+=e.getColSpan())})),t}}function $e(t){const n=Me();t.hasAttribute("data-lexical-row-striping")&&n.setRowStriping(!0);const r=t.querySelector(":scope > colgroup");if(r){let e=[];for(const t of r.querySelectorAll(":scope > col")){let n=t.style.width||"";if(!o.test(n)&&(n=t.getAttribute("width")||"",!/^\d+$/.test(n))){e=void 0;break}e.push(parseFloat(n))}e&&n.setColWidths(e)}return{after:t=>e.$descendantsMatching(t,C),node:n}}function Me(){return t.$applyNodeReplacement(new ye)}function Re(e){return e instanceof ye}function xe({rows:n,columns:o,includeHeaders:r}){const l=N(Number(n),Number(o),r);e.$insertNodeToNearestRoot(l);const s=l.getFirstDescendant();return t.$isTextNode(s)&&s.select(),!0}function Ee(e){C(e.getParent())?e.isEmpty()&&e.append(t.$createParagraphNode()):e.remove()}function Oe(t){Re(t.getParent())?e.$unwrapAndFilterDescendants(t,c):t.remove()}function Ae(n){e.$unwrapAndFilterDescendants(n,C);const[o]=x(n,null,null),r=o.reduce(((e,t)=>Math.max(e,t.length)),0),l=n.getChildren();for(let e=0;e<o.length;++e){const n=l[e];if(!n)continue;C(n)||h(254,n.constructor.name,n.getType());const s=o[e].reduce(((e,t)=>t?1+e:e),0);if(s!==r)for(let e=s;e<r;++e){const e=a();e.append(t.$createParagraphNode()),n.append(e)}}}exports.$computeTableMap=R,exports.$computeTableMapSkipCellCheck=x,exports.$createTableCellNode=a,exports.$createTableNode=Me,exports.$createTableNodeWithDimensions=N,exports.$createTableRowNode=m,exports.$createTableSelection=D,exports.$createTableSelectionFrom=K,exports.$deleteTableColumn=function(e,t){const n=e.getChildren();for(let e=0;e<n.length;e++){const o=n[e];if(C(o)){const e=o.getChildren();if(t>=e.length||t<0)throw new Error("Table column target index out of range");e[t].remove()}}return e},exports.$deleteTableColumn__EXPERIMENTAL=function(){const e=t.$getSelection();t.$isRangeSelection(e)||P(e)||h(188);const n=e.anchor.getNode(),o=e.focus.getNode(),[r,,l]=E(n),[s]=E(o),[i,a,c]=R(l,r,s),{startColumn:u}=a,{startRow:d,startColumn:g}=c,f=Math.min(u,g),m=Math.max(u+r.__colSpan-1,g+s.__colSpan-1),C=m-f+1;if(i[0].length===m-f+1)return l.selectPrevious(),void l.remove();const p=i.length;for(let e=0;e<p;e++)for(let t=f;t<=m;t++){const{cell:n,startColumn:o}=i[e][t];if(o<f){if(t===f){const e=f-o;n.setColSpan(n.__colSpan-Math.min(C,n.__colSpan-e))}}else if(o+n.__colSpan-1>m){if(t===m){const e=m-o+1;n.setColSpan(n.__colSpan-e)}}else n.remove()}const _=i[d],S=u>g?_[u+r.__colSpan]:_[g+s.__colSpan];if(void 0!==S){const{cell:e}=S;$(e)}else{const e=g<u?_[g-1]:_[u-1],{cell:t}=e;$(t)}const N=l.getColWidths();if(N){const e=[...N];e.splice(f,C),l.setColWidths(e)}},exports.$deleteTableRow__EXPERIMENTAL=function(){const e=t.$getSelection();t.$isRangeSelection(e)||P(e)||h(188);const[n,o]=e.isBackward()?[e.focus.getNode(),e.anchor.getNode()]:[e.anchor.getNode(),e.focus.getNode()],[r,,l]=E(n),[s]=E(o),[i,a,c]=R(l,r,s),{startRow:u}=a,{startRow:d}=c,g=d+s.__rowSpan-1;if(i.length===g-u+1)return void l.remove();const f=i[0].length,m=r.__rowSpan,p=i[g+1],_=l.getChildAtIndex(g+1);for(let e=g;e>=u;e--){for(let t=f-1;t>=0;t--){const{cell:n,startRow:o,startColumn:r}=i[e][t];if(r===t){if(e===u&&o<u){const e=u-o;n.setRowSpan(n.__rowSpan-Math.min(m,n.__rowSpan-e))}if(o>=u&&o+n.__rowSpan-1>g){n.setRowSpan(n.__rowSpan-(g-o+1)),null===_&&h(122);let r=null;for(let n=0;n<t;n++){const t=p[n],o=t.cell;t.startRow===e+1&&(r=o),o.__colSpan>1&&(n+=o.__colSpan-1)}null===r?M(_,n):r.insertAfter(n)}}}const t=l.getChildAtIndex(e);C(t)||h(206,String(e)),t.remove()}if(void 0!==p){const{cell:e}=p[0];$(e)}else{const e=i[u-1],{cell:t}=e[0];$(t)}},exports.$findCellNode=ue,exports.$findTableNode=de,exports.$getElementForTableNode=function(e,t){const n=e.getElementByKey(t.getKey());return null===n&&h(230),V(t,n)},exports.$getNodeTriplet=E,exports.$getTableAndElementByKey=k,exports.$getTableCellNodeFromLexicalNode=function(t){const n=e.$findMatchingParent(t,(e=>c(e)));return c(n)?n:null},exports.$getTableCellNodeRect=A,exports.$getTableColumnIndexFromTableCellNode=function(e){return b(e).getChildren().findIndex((t=>t.is(e)))},exports.$getTableNodeFromLexicalNodeOrThrow=w,exports.$getTableRowIndexFromTableCellNode=function(e){const t=b(e);return w(t).getChildren().findIndex((e=>e.is(t)))},exports.$getTableRowNodeFromTableCellNodeOrThrow=b,exports.$insertTableColumn=function(e,n,o=!0,l,s){const i=e.getChildren(),u=[];for(let e=0;e<i.length;e++){const o=i[e];if(C(o))for(let e=0;e<l;e++){const e=o.getChildren();if(n>=e.length||n<0)throw new Error("Table column target index out of range");const l=e[n];c(l)||h(12);const{left:i,right:d}=T(l,s);let g=r.NO_STATUS;(i&&i.hasHeaderState(r.ROW)||d&&d.hasHeaderState(r.ROW))&&(g|=r.ROW);const f=a(g);f.append(t.$createParagraphNode()),u.push({newTableCell:f,targetCell:l})}}return u.forEach((({newTableCell:e,targetCell:t})=>{o?t.insertAfter(e):t.insertBefore(e)})),e},exports.$insertTableColumn__EXPERIMENTAL=function(e=!0){const n=t.$getSelection();t.$isRangeSelection(n)||P(n)||h(188);const o=n.anchor.getNode(),l=n.focus.getNode(),[s]=E(o),[i,,c]=E(l),[u,d,g]=R(c,i,s),f=u.length,m=e?Math.max(d.startColumn,g.startColumn):Math.min(d.startColumn,g.startColumn),p=e?m+i.__colSpan-1:m-1,_=c.getFirstChild();C(_)||h(120);let S=null;function N(e=r.NO_STATUS){const n=a(e).append(t.$createParagraphNode());return null===S&&(S=n),n}let b=_;e:for(let e=0;e<f;e++){if(0!==e){const e=b.getNextSibling();C(e)||h(121),b=e}const t=u[e],n=t[p<0?0:p].cell.__headerState,o=y(n,r.ROW);if(p<0){M(b,N(o));continue}const{cell:l,startColumn:s,startRow:i}=t[p];if(s+l.__colSpan-1<=p){let n=l,r=i,s=p;for(;r!==e&&n.__rowSpan>1;){if(s-=l.__colSpan,!(s>=0)){b.append(N(o));continue e}{const{cell:e,startRow:o}=t[s];n=e,r=o}}n.insertAfter(N(o))}else l.setColSpan(l.__colSpan+1)}null!==S&&$(S);const w=c.getColWidths();if(w){const e=[...w],t=p<0?0:p,n=e[t];e.splice(t,0,n),c.setColWidths(e)}return S},exports.$insertTableRow=function(e,n,o=!0,l,s){const i=e.getChildren();if(n>=i.length||n<0)throw new Error("Table row target index out of range");const u=i[n];if(!C(u))throw new Error("Row before insertion index does not exist.");for(let e=0;e<l;e++){const e=u.getChildren(),n=e.length,l=m();for(let o=0;o<n;o++){const n=e[o];c(n)||h(12);const{above:i,below:u}=T(n,s);let d=r.NO_STATUS;const g=i&&i.getWidth()||u&&u.getWidth()||void 0;(i&&i.hasHeaderState(r.COLUMN)||u&&u.hasHeaderState(r.COLUMN))&&(d|=r.COLUMN);const f=a(d,1,g);f.append(t.$createParagraphNode()),l.append(f)}o?u.insertAfter(l):u.insertBefore(l)}return e},exports.$insertTableRow__EXPERIMENTAL=function(e=!0){const n=t.$getSelection();t.$isRangeSelection(n)||P(n)||h(188);const o=n.anchor.getNode(),l=n.focus.getNode(),[s]=E(o),[i,,c]=E(l),[u,d,g]=R(c,i,s),f=u[0].length,{startRow:p}=g,{startRow:_}=d;let S=null;if(e){const e=Math.max(_+i.__rowSpan,p+s.__rowSpan)-1,n=u[e],o=m();for(let l=0;l<f;l++){const{cell:s,startRow:i}=n[l];if(i+s.__rowSpan-1<=e){const e=n[l].cell.__headerState,s=y(e,r.COLUMN);o.append(a(s).append(t.$createParagraphNode()))}else s.setRowSpan(s.__rowSpan+1)}const l=c.getChildAtIndex(e);C(l)||h(256),l.insertAfter(o),S=o}else{const e=Math.min(_,p),n=u[e],o=m();for(let l=0;l<f;l++){const{cell:s,startRow:i}=n[l];if(i===e){const e=n[l].cell.__headerState,s=y(e,r.COLUMN);o.append(a(s).append(t.$createParagraphNode()))}else s.setRowSpan(s.__rowSpan+1)}const l=c.getChildAtIndex(e);C(l)||h(257),l.insertBefore(o),S=o}return S},exports.$isScrollableTablesActive=Te,exports.$isTableCellNode=c,exports.$isTableNode=Re,exports.$isTableRowNode=C,exports.$isTableSelection=P,exports.$removeTableRowAtIndex=function(e,t){const n=e.getChildren();if(t>=n.length||t<0)throw new Error("Expected table cell to be inside of table row.");return n[t].remove(),e},exports.$unmergeCell=function(){const e=t.$getSelection();t.$isRangeSelection(e)||P(e)||h(188);const n=e.anchor.getNode(),[o,l,s]=E(n),i=o.__colSpan,c=o.__rowSpan;if(1===i&&1===c)return;const[u,d]=R(s,o,o),{startColumn:g,startRow:f}=d,m=o.__headerState&r.COLUMN,p=Array.from({length:i},((e,t)=>{let n=m;for(let e=0;0!==n&&e<u.length;e++)n&=u[e][t+g].cell.__headerState;return n})),_=o.__headerState&r.ROW,S=Array.from({length:c},((e,t)=>{let n=_;for(let e=0;0!==n&&e<u[0].length;e++)n&=u[t+f][e].cell.__headerState;return n}));if(i>1){for(let e=1;e<i;e++)o.insertAfter(a(p[e]|S[0]).append(t.$createParagraphNode()));o.setColSpan(1)}if(c>1){let e;for(let n=1;n<c;n++){const o=f+n,r=u[o];e=(e||l).getNextSibling(),C(e)||h(125);let s=null;for(let e=0;e<g;e++){const t=r[e],n=t.cell;t.startRow===o&&(s=n),n.__colSpan>1&&(e+=n.__colSpan-1)}if(null===s)for(let o=i-1;o>=0;o--)M(e,a(p[o]|S[n]).append(t.$createParagraphNode()));else for(let e=i-1;e>=0;e--)s.insertAfter(a(p[e]|S[n]).append(t.$createParagraphNode()))}o.setRowSpan(1)}},exports.INSERT_TABLE_COMMAND=u,exports.TableCellHeaderStates=r,exports.TableCellNode=l,exports.TableNode=ye,exports.TableObserver=L,exports.TableRowNode=g,exports.applyTableHandlers=q,exports.getDOMCellFromTarget=j,exports.getTableElement=B,exports.getTableObserverFromTableElement=G,exports.registerTableCellUnmergeTransform=function(t){return t.registerNodeTransform(l,(t=>{if(t.getColSpan()>1||t.getRowSpan()>1){const[,,n]=E(t),[o]=R(n,t,t),r=o.length,l=o[0].length;let s=n.getFirstChild();C(s)||h(175);const i=[];for(let t=0;t<r;t++){0!==t&&(s=s.getNextSibling(),C(s)||h(175));let n=null;for(let r=0;r<l;r++){const l=o[t][r],u=l.cell;if(l.startRow===t&&l.startColumn===r)n=u,i.push(u);else if(u.getColSpan()>1||u.getRowSpan()>1){c(u)||h(176);const t=a(u.__headerState);null!==n?n.insertAfter(t):e.$insertFirst(s,t)}}}for(const e of i)e.setColSpan(1),e.setRowSpan(1)}}))},exports.registerTablePlugin=function(n){return n.hasNodes([ye])||h(255),e.mergeRegister(n.registerCommand(u,xe,t.COMMAND_PRIORITY_EDITOR),n.registerNodeTransform(ye,Ae),n.registerNodeTransform(g,Oe),n.registerNodeTransform(l,Ee))},exports.registerTableSelectionObserver=function(e,t=!0){const n=new Map,o=(o,r,l)=>{const s=B(o,l),i=q(o,s,e,t);n.set(r,[i,s])},r=e.registerMutationListener(ye,(t=>{e.getEditorState().read((()=>{for(const[e,r]of t){const t=n.get(e);if("created"===r||"updated"===r){const{tableNode:r,tableElement:l}=k(e);void 0===t?o(r,e,l):l!==t[1]&&(t[0].removeListeners(),n.delete(e),o(r,e,l))}else"destroyed"===r&&void 0!==t&&(t[0].removeListeners(),n.delete(e))}}),{editor:e})}),{skipInitialization:!1});return()=>{r();for(const[,[e]]of n)e.removeListeners()}},exports.setScrollableTablesActive=function(e,t){t?we.add(e):we.delete(e)};
|
package/LexicalTable.prod.mjs
CHANGED
@@ -6,4 +6,4 @@
|
|
6
6
|
*
|
7
7
|
*/
|
8
8
|
|
9
|
-
import{addClassNamesToElement as e,$descendantsMatching as t,$findMatchingParent as n,removeClassNamesFromElement as o,objectKlassEquals as r,isHTMLElement as l,$insertFirst as s,mergeRegister as i,$insertNodeToNearestRoot as c,$unwrapAndFilterDescendants as a}from"@lexical/utils";import{ElementNode as u,isHTMLElement as h,$createParagraphNode as d,$isElementNode as g,$isLineBreakNode as f,$isTextNode as m,$applyNodeReplacement as p,createCommand as S,$createTextNode as C,$getSelection as _,$isRangeSelection as w,$createPoint as b,$isParagraphNode as y,$normalizeSelection__EXPERIMENTAL as N,isCurrentlyReadOnlyMode as x,TEXT_TYPE_TO_FORMAT as v,$getNodeByKey as T,$getEditor as R,$setSelection as O,SELECTION_CHANGE_COMMAND as F,getDOMSelection as A,$createRangeSelection as k,COMMAND_PRIORITY_HIGH as K,KEY_ESCAPE_COMMAND as E,COMMAND_PRIORITY_CRITICAL as M,CUT_COMMAND as $,FORMAT_TEXT_COMMAND as L,FORMAT_ELEMENT_COMMAND as W,CONTROLLED_TEXT_INSERTION_COMMAND as H,KEY_TAB_COMMAND as P,FOCUS_COMMAND as B,SELECTION_INSERT_CLIPBOARD_NODES_COMMAND as D,$getPreviousSelection as I,$getNearestNodeFromDOMNode as U,$createRangeSelectionFromDom as J,INSERT_PARAGRAPH_COMMAND as z,$isRootOrShadowRoot as Y,$isDecoratorNode as q,KEY_ARROW_DOWN_COMMAND as X,KEY_ARROW_UP_COMMAND as j,KEY_ARROW_LEFT_COMMAND as V,KEY_ARROW_RIGHT_COMMAND as G,DELETE_WORD_COMMAND as Q,DELETE_LINE_COMMAND as Z,DELETE_CHARACTER_COMMAND as ee,KEY_BACKSPACE_COMMAND as te,KEY_DELETE_COMMAND as ne,isDOMNode as oe,setDOMUnmanaged as re,COMMAND_PRIORITY_EDITOR as le}from"lexical";import{copyToClipboard as se,$getClipboardDataFromSelection as ie}from"@lexical/clipboard";const ce=/^(\d+(?:\.\d+)?)px$/,ae={BOTH:3,COLUMN:2,NO_STATUS:0,ROW:1};class ue extends u{static getType(){return"tablecell"}static clone(e){return new ue(e.__headerState,e.__colSpan,e.__width,e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__rowSpan=e.__rowSpan,this.__backgroundColor=e.__backgroundColor,this.__verticalAlign=e.__verticalAlign}static importDOM(){return{td:e=>({conversion:de,priority:0}),th:e=>({conversion:de,priority:0})}}static importJSON(e){return ge().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setHeaderStyles(e.headerState).setColSpan(e.colSpan||1).setRowSpan(e.rowSpan||1).setWidth(e.width||void 0).setBackgroundColor(e.backgroundColor||null).setVerticalAlign(e.verticalAlign||void 0)}constructor(e=ae.NO_STATUS,t=1,n,o){super(o),this.__colSpan=t,this.__rowSpan=1,this.__headerState=e,this.__width=n,this.__backgroundColor=null}createDOM(t){const n=document.createElement(this.getTag());return this.__width&&(n.style.width=`${this.__width}px`),this.__colSpan>1&&(n.colSpan=this.__colSpan),this.__rowSpan>1&&(n.rowSpan=this.__rowSpan),null!==this.__backgroundColor&&(n.style.backgroundColor=this.__backgroundColor),he(this.__verticalAlign)&&(n.style.verticalAlign=this.__verticalAlign),e(n,t.theme.tableCell,this.hasHeader()&&t.theme.tableCellHeader),n}exportDOM(e){const t=super.exportDOM(e);if(h(t.element)){const e=t.element;e.setAttribute("data-temporary-table-cell-lexical-key",this.getKey()),e.style.border="1px solid black",this.__colSpan>1&&(e.colSpan=this.__colSpan),this.__rowSpan>1&&(e.rowSpan=this.__rowSpan),e.style.width=`${this.getWidth()||75}px`,e.style.verticalAlign=this.getVerticalAlign()||"top",e.style.textAlign="start",null===this.__backgroundColor&&this.hasHeader()&&(e.style.backgroundColor="#f2f3f5")}return t}exportJSON(){return{...super.exportJSON(),...he(this.__verticalAlign)&&{verticalAlign:this.__verticalAlign},backgroundColor:this.getBackgroundColor(),colSpan:this.__colSpan,headerState:this.__headerState,rowSpan:this.__rowSpan,width:this.getWidth()}}getColSpan(){return this.getLatest().__colSpan}setColSpan(e){const t=this.getWritable();return t.__colSpan=e,t}getRowSpan(){return this.getLatest().__rowSpan}setRowSpan(e){const t=this.getWritable();return t.__rowSpan=e,t}getTag(){return this.hasHeader()?"th":"td"}setHeaderStyles(e,t=ae.BOTH){const n=this.getWritable();return n.__headerState=e&t|n.__headerState&~t,n}getHeaderStyles(){return this.getLatest().__headerState}setWidth(e){const t=this.getWritable();return t.__width=e,t}getWidth(){return this.getLatest().__width}getBackgroundColor(){return this.getLatest().__backgroundColor}setBackgroundColor(e){const t=this.getWritable();return t.__backgroundColor=e,t}getVerticalAlign(){return this.getLatest().__verticalAlign}setVerticalAlign(e){const t=this.getWritable();return t.__verticalAlign=e||void 0,t}toggleHeaderStyle(e){const t=this.getWritable();return(t.__headerState&e)===e?t.__headerState-=e:t.__headerState+=e,t}hasHeaderState(e){return(this.getHeaderStyles()&e)===e}hasHeader(){return this.getLatest().__headerState!==ae.NO_STATUS}updateDOM(e){return e.__headerState!==this.__headerState||e.__width!==this.__width||e.__colSpan!==this.__colSpan||e.__rowSpan!==this.__rowSpan||e.__backgroundColor!==this.__backgroundColor||e.__verticalAlign!==this.__verticalAlign}isShadowRoot(){return!0}collapseAtStart(){return!0}canBeEmpty(){return!1}canIndent(){return!1}}function he(e){return"middle"===e||"bottom"===e}function de(e){const t=e,n=e.nodeName.toLowerCase();let o;ce.test(t.style.width)&&(o=parseFloat(t.style.width));const r=ge("th"===n?ae.ROW:ae.NO_STATUS,t.colSpan,o);r.__rowSpan=t.rowSpan;const l=t.style.backgroundColor;""!==l&&(r.__backgroundColor=l);const s=t.style.verticalAlign;he(s)&&(r.__verticalAlign=s);const i=t.style,c=(i&&i.textDecoration||"").split(" "),a="700"===i.fontWeight||"bold"===i.fontWeight,u=c.includes("line-through"),h="italic"===i.fontStyle,p=c.includes("underline");return{after:e=>(0===e.length&&e.push(d()),e),forChild:(e,t)=>{if(fe(t)&&!g(e)){const t=d();return f(e)&&"\n"===e.getTextContent()?null:(m(e)&&(a&&e.toggleFormat("bold"),u&&e.toggleFormat("strikethrough"),h&&e.toggleFormat("italic"),p&&e.toggleFormat("underline")),t.append(e),t)}return e},node:r}}function ge(e=ae.NO_STATUS,t=1,n){return p(new ue(e,t,n))}function fe(e){return e instanceof ue}const me=S("INSERT_TABLE_COMMAND");function pe(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Se=pe((function(e){const t=new URLSearchParams;t.append("code",e);for(let e=1;e<arguments.length;e++)t.append("v",arguments[e]);throw Error(`Minified Lexical error #${e}; visit https://lexical.dev/docs/error?${t} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}));class Ce extends u{static getType(){return"tablerow"}static clone(e){return new Ce(e.__height,e.__key)}static importDOM(){return{tr:e=>({conversion:_e,priority:0})}}static importJSON(e){return we().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setHeight(e.height)}constructor(e,t){super(t),this.__height=e}exportJSON(){const e=this.getHeight();return{...super.exportJSON(),...void 0===e?void 0:{height:e}}}createDOM(t){const n=document.createElement("tr");return this.__height&&(n.style.height=`${this.__height}px`),e(n,t.theme.tableRow),n}extractWithChild(e,t,n){return"html"===n}isShadowRoot(){return!0}setHeight(e){const t=this.getWritable();return t.__height=e,t}getHeight(){return this.getLatest().__height}updateDOM(e){return e.__height!==this.__height}canBeEmpty(){return!1}canIndent(){return!1}}function _e(e){const n=e;let o;return ce.test(n.style.height)&&(o=parseFloat(n.style.height)),{after:e=>t(e,fe),node:we(o)}}function we(e){return p(new Ce(e))}function be(e){return e instanceof Ce}const ye="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,Ne=ye&&"documentMode"in document?document.documentMode:null,xe=ye&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);function ve(e,t,n=!0){const o=Jt();for(let r=0;r<e;r++){const e=we();for(let o=0;o<t;o++){let t=ae.NO_STATUS;"object"==typeof n?(0===r&&n.rows&&(t|=ae.ROW),0===o&&n.columns&&(t|=ae.COLUMN)):n&&(0===r&&(t|=ae.ROW),0===o&&(t|=ae.COLUMN));const l=ge(t),s=d();s.append(C()),l.append(s),e.append(l)}o.append(e)}return o}function Te(e){const t=n(e,(e=>fe(e)));return fe(t)?t:null}function Re(e){const t=n(e,(e=>be(e)));if(be(t))return t;throw new Error("Expected table cell to be inside of table row.")}function Oe(e){const t=n(e,(e=>zt(e)));if(zt(t))return t;throw new Error("Expected table cell to be inside of table.")}function Fe(e){const t=Re(e);return Oe(t).getChildren().findIndex((e=>e.is(t)))}function Ae(e){return Re(e).getChildren().findIndex((t=>t.is(e)))}function ke(e,t){const n=Oe(e),{x:o,y:r}=n.getCordsFromCellNode(e,t);return{above:n.getCellNodeFromCords(o,r-1,t),below:n.getCellNodeFromCords(o,r+1,t),left:n.getCellNodeFromCords(o-1,r,t),right:n.getCellNodeFromCords(o+1,r,t)}}function Ke(e,t){const n=e.getChildren();if(t>=n.length||t<0)throw new Error("Expected table cell to be inside of table row.");return n[t].remove(),e}function Ee(e,t,n=!0,o,r){const l=e.getChildren();if(t>=l.length||t<0)throw new Error("Table row target index out of range");const s=l[t];if(!be(s))throw new Error("Row before insertion index does not exist.");for(let e=0;e<o;e++){const e=s.getChildren(),t=e.length,o=we();for(let n=0;n<t;n++){const t=e[n];fe(t)||Se(12);const{above:l,below:s}=ke(t,r);let i=ae.NO_STATUS;const c=l&&l.getWidth()||s&&s.getWidth()||void 0;(l&&l.hasHeaderState(ae.COLUMN)||s&&s.hasHeaderState(ae.COLUMN))&&(i|=ae.COLUMN);const a=ge(i,1,c);a.append(d()),o.append(a)}n?s.insertAfter(o):s.insertBefore(o)}return e}ye&&"InputEvent"in window&&!Ne&&new window.InputEvent("input");const Me=(e,t)=>e===ae.BOTH||e===t?t:ae.NO_STATUS;function $e(e=!0){const t=_();w(t)||Ge(t)||Se(188);const n=t.anchor.getNode(),o=t.focus.getNode(),[r]=Ye(n),[l,,s]=Ye(o),[i,c,a]=Je(s,l,r),u=i[0].length,{startRow:h}=a,{startRow:g}=c;let f=null;if(e){const e=Math.max(g+l.__rowSpan,h+r.__rowSpan)-1,t=i[e],n=we();for(let o=0;o<u;o++){const{cell:r,startRow:l}=t[o];if(l+r.__rowSpan-1<=e){const e=t[o].cell.__headerState,r=Me(e,ae.COLUMN);n.append(ge(r).append(d()))}else r.setRowSpan(r.__rowSpan+1)}const o=s.getChildAtIndex(e);be(o)||Se(256),o.insertAfter(n),f=n}else{const e=Math.min(g,h),t=i[e],n=we();for(let o=0;o<u;o++){const{cell:r,startRow:l}=t[o];if(l===e){const e=t[o].cell.__headerState,r=Me(e,ae.COLUMN);n.append(ge(r).append(d()))}else r.setRowSpan(r.__rowSpan+1)}const o=s.getChildAtIndex(e);be(o)||Se(257),o.insertBefore(n),f=n}return f}function Le(e,t,n=!0,o,r){const l=e.getChildren(),s=[];for(let e=0;e<l.length;e++){const n=l[e];if(be(n))for(let e=0;e<o;e++){const e=n.getChildren();if(t>=e.length||t<0)throw new Error("Table column target index out of range");const o=e[t];fe(o)||Se(12);const{left:l,right:i}=ke(o,r);let c=ae.NO_STATUS;(l&&l.hasHeaderState(ae.ROW)||i&&i.hasHeaderState(ae.ROW))&&(c|=ae.ROW);const a=ge(c);a.append(d()),s.push({newTableCell:a,targetCell:o})}}return s.forEach((({newTableCell:e,targetCell:t})=>{n?t.insertAfter(e):t.insertBefore(e)})),e}function We(e=!0){const t=_();w(t)||Ge(t)||Se(188);const n=t.anchor.getNode(),o=t.focus.getNode(),[r]=Ye(n),[l,,s]=Ye(o),[i,c,a]=Je(s,l,r),u=i.length,h=e?Math.max(c.startColumn,a.startColumn):Math.min(c.startColumn,a.startColumn),g=e?h+l.__colSpan-1:h-1,f=s.getFirstChild();be(f)||Se(120);let m=null;function p(e=ae.NO_STATUS){const t=ge(e).append(d());return null===m&&(m=t),t}let S=f;e:for(let e=0;e<u;e++){if(0!==e){const e=S.getNextSibling();be(e)||Se(121),S=e}const t=i[e],n=t[g<0?0:g].cell.__headerState,o=Me(n,ae.ROW);if(g<0){Ie(S,p(o));continue}const{cell:r,startColumn:l,startRow:s}=t[g];if(l+r.__colSpan-1<=g){let n=r,l=s,i=g;for(;l!==e&&n.__rowSpan>1;){if(i-=r.__colSpan,!(i>=0)){S.append(p(o));continue e}{const{cell:e,startRow:o}=t[i];n=e,l=o}}n.insertAfter(p(o))}else r.setColSpan(r.__colSpan+1)}null!==m&&De(m);const C=s.getColWidths();if(C){const e=[...C],t=g<0?0:g,n=e[t];e.splice(t,0,n),s.setColWidths(e)}return m}function He(e,t){const n=e.getChildren();for(let e=0;e<n.length;e++){const o=n[e];if(be(o)){const e=o.getChildren();if(t>=e.length||t<0)throw new Error("Table column target index out of range");e[t].remove()}}return e}function Pe(){const e=_();w(e)||Ge(e)||Se(188);const[t,n]=e.isBackward()?[e.focus.getNode(),e.anchor.getNode()]:[e.anchor.getNode(),e.focus.getNode()],[o,,r]=Ye(t),[l]=Ye(n),[s,i,c]=Je(r,o,l),{startRow:a}=i,{startRow:u}=c,h=u+l.__rowSpan-1;if(s.length===h-a+1)return void r.remove();const d=s[0].length,g=o.__rowSpan,f=s[h+1],m=r.getChildAtIndex(h+1);for(let e=h;e>=a;e--){for(let t=d-1;t>=0;t--){const{cell:n,startRow:o,startColumn:r}=s[e][t];if(r===t){if(e===a&&o<a){const e=a-o;n.setRowSpan(n.__rowSpan-Math.min(g,n.__rowSpan-e))}if(o>=a&&o+n.__rowSpan-1>h){n.setRowSpan(n.__rowSpan-(h-o+1)),null===m&&Se(122);let r=null;for(let n=0;n<t;n++){const t=f[n],o=t.cell;t.startRow===e+1&&(r=o),o.__colSpan>1&&(n+=o.__colSpan-1)}null===r?Ie(m,n):r.insertAfter(n)}}}const t=r.getChildAtIndex(e);be(t)||Se(206,String(e)),t.remove()}if(void 0!==f){const{cell:e}=f[0];De(e)}else{const e=s[a-1],{cell:t}=e[0];De(t)}}function Be(){const e=_();w(e)||Ge(e)||Se(188);const t=e.anchor.getNode(),n=e.focus.getNode(),[o,,r]=Ye(t),[l]=Ye(n),[s,i,c]=Je(r,o,l),{startColumn:a}=i,{startRow:u,startColumn:h}=c,d=Math.min(a,h),g=Math.max(a+o.__colSpan-1,h+l.__colSpan-1),f=g-d+1;if(s[0].length===g-d+1)return r.selectPrevious(),void r.remove();const m=s.length;for(let e=0;e<m;e++)for(let t=d;t<=g;t++){const{cell:n,startColumn:o}=s[e][t];if(o<d){if(t===d){const e=d-o;n.setColSpan(n.__colSpan-Math.min(f,n.__colSpan-e))}}else if(o+n.__colSpan-1>g){if(t===g){const e=g-o+1;n.setColSpan(n.__colSpan-e)}}else n.remove()}const p=s[u],S=a>h?p[a+o.__colSpan]:p[h+l.__colSpan];if(void 0!==S){const{cell:e}=S;De(e)}else{const e=h<a?p[h-1]:p[a-1],{cell:t}=e;De(t)}const C=r.getColWidths();if(C){const e=[...C];e.splice(d,f),r.setColWidths(e)}}function De(e){const t=e.getFirstDescendant();null==t?e.selectStart():t.getParentOrThrow().selectStart()}function Ie(e,t){const n=e.getFirstChild();null!==n?n.insertBefore(t):e.append(t)}function Ue(){const e=_();w(e)||Ge(e)||Se(188);const t=e.anchor.getNode(),[n,o,r]=Ye(t),l=n.__colSpan,s=n.__rowSpan;if(1===l&&1===s)return;const[i,c]=Je(r,n,n),{startColumn:a,startRow:u}=c,h=n.__headerState&ae.COLUMN,g=Array.from({length:l},((e,t)=>{let n=h;for(let e=0;0!==n&&e<i.length;e++)n&=i[e][t+a].cell.__headerState;return n})),f=n.__headerState&ae.ROW,m=Array.from({length:s},((e,t)=>{let n=f;for(let e=0;0!==n&&e<i[0].length;e++)n&=i[t+u][e].cell.__headerState;return n}));if(l>1){for(let e=1;e<l;e++)n.insertAfter(ge(g[e]|m[0]).append(d()));n.setColSpan(1)}if(s>1){let e;for(let t=1;t<s;t++){const n=u+t,r=i[n];e=(e||o).getNextSibling(),be(e)||Se(125);let s=null;for(let e=0;e<a;e++){const t=r[e],o=t.cell;t.startRow===n&&(s=o),o.__colSpan>1&&(e+=o.__colSpan-1)}if(null===s)for(let n=l-1;n>=0;n--)Ie(e,ge(g[n]|m[t]).append(d()));else for(let e=l-1;e>=0;e--)s.insertAfter(ge(g[e]|m[t]).append(d()))}n.setRowSpan(1)}}function Je(e,t,n){const[o,r,l]=ze(e,t,n);return null===r&&Se(207),null===l&&Se(208),[o,r,l]}function ze(e,t,n){const o=[];let r=null,l=null;function s(e){let t=o[e];return void 0===t&&(o[e]=t=[]),t}const i=e.getChildren();for(let e=0;e<i.length;e++){const o=i[e];be(o)||Se(209);const c=s(e);for(let a=o.getFirstChild(),u=0;null!=a;a=a.getNextSibling()){for(fe(a)||Se(147);void 0!==c[u];)u++;const o={cell:a,startColumn:u,startRow:e},{__rowSpan:h,__colSpan:d}=a;for(let t=0;t<h&&!(e+t>=i.length);t++){const n=s(e+t);for(let e=0;e<d;e++)n[u+e]=o}null!==t&&null===r&&t.is(a)&&(r=o),null!==n&&null===l&&n.is(a)&&(l=o)}}return[o,r,l]}function Ye(e){let t;if(e instanceof ue)t=e;else if("__type"in e){const o=n(e,fe);fe(o)||Se(148),t=o}else{const o=n(e.getNode(),fe);fe(o)||Se(148),t=o}const o=t.getParent();be(o)||Se(149);const r=o.getParent();return zt(r)||Se(210),[t,o,r]}function qe(e,t,n){let o=Math.min(t.startColumn,n.startColumn),r=Math.min(t.startRow,n.startRow),l=Math.max(t.startColumn+t.cell.__colSpan-1,n.startColumn+n.cell.__colSpan-1),s=Math.max(t.startRow+t.cell.__rowSpan-1,n.startRow+n.cell.__rowSpan-1),i=o,c=r,a=o,u=r;function h(e){const{cell:t,startColumn:n,startRow:i}=e;o=Math.min(o,n),r=Math.min(r,i),l=Math.max(l,n+t.__colSpan-1),s=Math.max(s,i+t.__rowSpan-1)}for(;o<i||r<c||l>a||s>u;){if(o<i){const t=u-c,n=i-1;for(let o=0;o<=t;o++)h(e[c+o][n]);i=n}if(r<c){const t=a-i,n=c-1;for(let o=0;o<=t;o++)h(e[n][i+o]);c=n}if(l>a){const t=u-c,n=a+1;for(let o=0;o<=t;o++)h(e[c+o][n]);a=n}if(s>u){const t=a-i,n=u+1;for(let o=0;o<=t;o++)h(e[n][i+o]);u=n}}return{maxColumn:l,maxRow:s,minColumn:o,minRow:r}}function Xe(e){const[t,,n]=Ye(e),o=n.getChildren(),r=o.length,l=o[0].getChildren().length,s=new Array(r);for(let e=0;e<r;e++)s[e]=new Array(l);for(let e=0;e<r;e++){const n=o[e].getChildren();let r=0;for(let o=0;o<n.length;o++){for(;s[e][r];)r++;const l=n[o],i=l.__rowSpan||1,c=l.__colSpan||1;for(let t=0;t<i;t++)for(let n=0;n<c;n++)s[e+t][r+n]=l;if(t===l)return{colSpan:c,columnIndex:r,rowIndex:e,rowSpan:i};r+=c}}return null}function je(e){const[[t,o,r,l],[s,i,c,a]]=["anchor","focus"].map((t=>{const o=e[t].getNode(),r=n(o,fe);fe(r)||Se(238,t,o.getKey(),o.getType());const l=r.getParent();be(l)||Se(239,t);const s=l.getParent();return zt(s)||Se(240,t),[o,r,l,s]}));return l.is(a)||Se(241),{anchorCell:o,anchorNode:t,anchorRow:r,anchorTable:l,focusCell:i,focusNode:s,focusRow:c,focusTable:a}}class Ve{constructor(e,t,n){this.anchor=t,this.focus=n,t._selection=this,n._selection=this,this._cachedNodes=null,this.dirty=!1,this.tableKey=e}getStartEndPoints(){return[this.anchor,this.focus]}isValid(){return"root"!==this.tableKey&&"root"!==this.anchor.key&&"element"===this.anchor.type&&"root"!==this.focus.key&&"element"===this.focus.type}isBackward(){return this.focus.isBefore(this.anchor)}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e}is(e){return Ge(e)&&this.tableKey===e.tableKey&&this.anchor.is(e.anchor)&&this.focus.is(e.focus)}set(e,t,n){this.dirty=this.dirty||e!==this.tableKey||t!==this.anchor.key||n!==this.focus.key,this.tableKey=e,this.anchor.key=t,this.focus.key=n,this._cachedNodes=null}clone(){return new Ve(this.tableKey,b(this.anchor.key,this.anchor.offset,this.anchor.type),b(this.focus.key,this.focus.offset,this.focus.type))}isCollapsed(){return!1}extract(){return this.getNodes()}insertRawText(e){}insertText(){}hasFormat(e){let t=0;this.getNodes().filter(fe).forEach((e=>{const n=e.getFirstChild();y(n)&&(t|=n.getTextFormat())}));const n=v[e];return!!(t&n)}insertNodes(e){const t=this.focus.getNode();g(t)||Se(151);N(t.select(0,t.getChildrenSize())).insertNodes(e)}getShape(){const{anchorCell:e,focusCell:t}=je(this),n=Xe(e);null===n&&Se(153);const o=Xe(t);null===o&&Se(155);const r=Math.min(n.columnIndex,o.columnIndex),l=Math.max(n.columnIndex+n.colSpan-1,o.columnIndex+o.colSpan-1),s=Math.min(n.rowIndex,o.rowIndex),i=Math.max(n.rowIndex+n.rowSpan-1,o.rowIndex+o.rowSpan-1);return{fromX:Math.min(r,l),fromY:Math.min(s,i),toX:Math.max(r,l),toY:Math.max(s,i)}}getNodes(){if(!this.isValid())return[];const e=this._cachedNodes;if(null!==e)return e;const{anchorTable:t,anchorCell:n,focusCell:o}=je(this),r=o.getParents()[1];if(r!==t){if(t.isParentOf(o)){const e=r.getParent();null==e&&Se(159),this.set(this.tableKey,o.getKey(),e.getKey())}else{const e=t.getParent();null==e&&Se(158),this.set(this.tableKey,e.getKey(),o.getKey())}return this.getNodes()}const[l,s,i]=Je(t,n,o),{minColumn:c,maxColumn:a,minRow:u,maxRow:h}=qe(l,s,i),d=new Map([[t.getKey(),t]]);let g=null;for(let e=u;e<=h;e++)for(let t=c;t<=a;t++){const{cell:n}=l[e][t],o=n.getParent();be(o)||Se(160),o!==g&&(d.set(o.getKey(),o),g=o),d.has(n.getKey())||et(n,(e=>{d.set(e.getKey(),e)}))}const f=Array.from(d.values());return x()||(this._cachedNodes=f),f}getTextContent(){const e=this.getNodes().filter((e=>fe(e)));let t="";for(let n=0;n<e.length;n++){const o=e[n],r=o.__parent,l=(e[n+1]||{}).__parent;t+=o.getTextContent()+(l!==r?"\n":"\t")}return t}}function Ge(e){return e instanceof Ve}function Qe(){const e=b("root",0,"element"),t=b("root",0,"element");return new Ve("root",e,t)}function Ze(e,t,n){e.getKey(),t.getKey(),n.getKey();const o=_(),r=Ge(o)?o.clone():Qe();return r.set(e.getKey(),t.getKey(),n.getKey()),r}function et(e,t){const n=[[e]];for(let e=n.at(-1);void 0!==e&&n.length>0;e=n.at(-1)){const o=e.pop();void 0===o?n.pop():!1!==t(o)&&g(o)&&n.push(o.getChildren())}}function tt(e,t=R()){const n=T(e);zt(n)||Se(231,e);const o=lt(n,t.getElementByKey(e));return null===o&&Se(232,e),{tableElement:o,tableNode:n}}class nt{constructor(e,t){this.isHighlightingCells=!1,this.anchorX=-1,this.anchorY=-1,this.focusX=-1,this.focusY=-1,this.listenersToRemove=new Set,this.tableNodeKey=t,this.editor=e,this.table={columns:0,domRows:[],rows:0},this.tableSelection=null,this.anchorCellNodeKey=null,this.focusCellNodeKey=null,this.anchorCell=null,this.focusCell=null,this.hasHijackedSelectionStyles=!1,this.isSelecting=!1,this.shouldCheckSelection=!1,this.abortController=new AbortController,this.listenerOptions={signal:this.abortController.signal},this.nextFocus=null,this.trackTable()}getTable(){return this.table}removeListeners(){this.abortController.abort("removeListeners"),Array.from(this.listenersToRemove).forEach((e=>e())),this.listenersToRemove.clear()}$lookup(){return tt(this.tableNodeKey,this.editor)}trackTable(){const e=new MutationObserver((e=>{this.editor.getEditorState().read((()=>{let t=!1;for(let n=0;n<e.length;n++){const o=e[n].target.nodeName;if("TABLE"===o||"TBODY"===o||"THEAD"===o||"TR"===o){t=!0;break}}if(!t)return;const{tableNode:n,tableElement:o}=this.$lookup();this.table=ft(n,o)}),{editor:this.editor})}));this.editor.getEditorState().read((()=>{const{tableNode:t,tableElement:n}=this.$lookup();this.table=ft(t,n),e.observe(n,{attributes:!0,childList:!0,subtree:!0})}),{editor:this.editor})}$clearHighlight(){const e=this.editor;this.isHighlightingCells=!1,this.anchorX=-1,this.anchorY=-1,this.focusX=-1,this.focusY=-1,this.tableSelection=null,this.anchorCellNodeKey=null,this.focusCellNodeKey=null,this.anchorCell=null,this.focusCell=null,this.hasHijackedSelectionStyles=!1,this.$enableHighlightStyle();const{tableNode:t,tableElement:n}=this.$lookup();mt(e,ft(t,n),null),null!==_()&&(O(null),e.dispatchCommand(F,void 0))}$enableHighlightStyle(){const e=this.editor,{tableElement:t}=this.$lookup();o(t,e._config.theme.tableSelection),t.classList.remove("disable-selection"),this.hasHijackedSelectionStyles=!1}$disableHighlightStyle(){const{tableElement:t}=this.$lookup();e(t,this.editor._config.theme.tableSelection),this.hasHijackedSelectionStyles=!0}$updateTableTableSelection(e){if(null!==e){e.tableKey!==this.tableNodeKey&&Se(233,e.tableKey,this.tableNodeKey);const t=this.editor;this.tableSelection=e,this.isHighlightingCells=!0,this.$disableHighlightStyle(),this.updateDOMSelection(),mt(t,this.table,this.tableSelection)}else this.$clearHighlight()}setShouldCheckSelection(){this.shouldCheckSelection=!0}getAndClearShouldCheckSelection(){return!!this.shouldCheckSelection&&(this.shouldCheckSelection=!1,!0)}setNextFocus(e){this.nextFocus=e}getAndClearNextFocus(){const{nextFocus:e}=this;return null!==e&&(this.nextFocus=null),e}updateDOMSelection(){if(null!==this.anchorCell&&null!==this.focusCell){const e=A(this.editor._window);e&&e.rangeCount>0&&e.removeAllRanges()}}$setFocusCellForSelection(e,t=!1){const n=this.editor,{tableNode:o}=this.$lookup(),r=e.x,l=e.y;if(this.focusCell=e,this.isHighlightingCells||this.anchorX===r&&this.anchorY===l&&!t){if(r===this.focusX&&l===this.focusY)return!1}else this.isHighlightingCells=!0,this.$disableHighlightStyle();if(this.focusX=r,this.focusY=l,this.isHighlightingCells){const t=Mt(o,e.elem);if(null!=this.tableSelection&&null!=this.anchorCellNodeKey&&null!==t)return this.focusCellNodeKey=t.getKey(),this.tableSelection=Ze(o,this.$getAnchorTableCellOrThrow(),t),O(this.tableSelection),n.dispatchCommand(F,void 0),mt(n,this.table,this.tableSelection),!0}return!1}$getAnchorTableCell(){return this.anchorCellNodeKey?T(this.anchorCellNodeKey):null}$getAnchorTableCellOrThrow(){const e=this.$getAnchorTableCell();return null===e&&Se(234),e}$getFocusTableCell(){return this.focusCellNodeKey?T(this.focusCellNodeKey):null}$getFocusTableCellOrThrow(){const e=this.$getFocusTableCell();return null===e&&Se(235),e}$setAnchorCellForSelection(e){this.isHighlightingCells=!1,this.anchorCell=e,this.anchorX=e.x,this.anchorY=e.y;const{tableNode:t}=this.$lookup(),n=Mt(t,e.elem);if(null!==n){const e=n.getKey();this.tableSelection=null!=this.tableSelection?this.tableSelection.clone():Qe(),this.anchorCellNodeKey=e}}$formatCells(e){const t=_();Ge(t)||Se(236);const n=k(),o=n.anchor,r=n.focus,l=t.getNodes().filter(fe);l.length>0||Se(237);const s=l[0].getFirstChild(),i=y(s)?s.getFormatFlags(e,null):null;l.forEach((t=>{o.set(t.getKey(),0,"element"),r.set(t.getKey(),t.getChildrenSize(),"element"),n.formatText(e,i)})),O(t),this.editor.dispatchCommand(F,void 0)}$clearText(){const{editor:e}=this,t=T(this.tableNodeKey);if(!zt(t))throw new Error("Expected TableNode.");const n=_();Ge(n)||Se(253);const o=n.getNodes().filter(fe);if(o.length===this.table.columns*this.table.rows)return t.selectPrevious(),void t.remove();o.forEach((e=>{if(g(e)){const t=d(),n=C();t.append(n),e.append(t),e.getChildren().forEach((e=>{e!==t&&e.remove()}))}})),mt(e,this.table,null),O(null),e.dispatchCommand(F,void 0)}}const ot="__lexicalTableSelection",rt=e=>!(1&~e.buttons);function lt(e,t){if(!t)return t;const n="TABLE"===t.nodeName?t:e.getDOMSlot(t).element;return"TABLE"!==n.nodeName&&Se(245,t.nodeName),n}function st(e){return e._window}function it(e,t){for(let n=t,o=null;null!==n;n=n.getParent()){if(e.is(n))return o;fe(n)&&(o=n)}return null}const ct=[[X,"down"],[j,"up"],[V,"backward"],[G,"forward"]],at=[Q,Z,ee],ut=[te,ne];function ht(e,t,o,l){const s=o.getRootElement(),i=st(o);null!==s&&null!==i||Se(246);const c=new nt(o,e.getKey()),a=lt(e,t);!function(e,t){null!==dt(e)&&Se(205);e[ot]=t}(a,c),c.listenersToRemove.add((()=>function(e,t){dt(e)===t&&delete e[ot]}(a,c)));a.addEventListener("mousedown",(t=>{if(0!==t.button||!oe(t.target)||!i)return;const n=gt(t.target);null!==n&&o.update((()=>{const o=I();if(xe&&t.shiftKey&&Nt(o,e)&&(w(o)||Ge(o))){const r=o.anchor.getNode(),l=it(e,o.anchor.getNode());if(l)c.$setAnchorCellForSelection(Et(c,l)),c.$setFocusCellForSelection(n),At(t);else{(e.isBefore(r)?e.selectStart():e.selectEnd()).anchor.set(o.anchor.key,o.anchor.offset,o.anchor.type)}}else c.$setAnchorCellForSelection(n)})),(()=>{if(c.isSelecting)return;const e=()=>{c.isSelecting=!1,i.removeEventListener("mouseup",e),i.removeEventListener("mousemove",t)},t=n=>{if(!oe(n.target))return;if(!rt(n)&&c.isSelecting)return c.isSelecting=!1,i.removeEventListener("mouseup",e),void i.removeEventListener("mousemove",t);const r=!a.contains(n.target);let l=null;if(r){for(const e of document.elementsFromPoint(n.clientX,n.clientY))if(l=a.contains(e)?gt(e):null,l)break}else l=gt(n.target);!l||null!==c.focusCell&&l.elem===c.focusCell.elem||(c.setNextFocus({focusCell:l,override:r}),o.dispatchCommand(F,void 0))};c.isSelecting=!0,i.addEventListener("mouseup",e,c.listenerOptions),i.addEventListener("mousemove",t,c.listenerOptions)})()}),c.listenerOptions);i.addEventListener("mousedown",(e=>{const t=e.target;0===e.button&&oe(t)&&o.update((()=>{const e=_();Ge(e)&&e.tableKey===c.tableNodeKey&&s.contains(t)&&c.$clearHighlight()}))}),c.listenerOptions);for(const[t,n]of ct)c.listenersToRemove.add(o.registerCommand(t,(t=>Ft(o,t,n,e,c)),K));c.listenersToRemove.add(o.registerCommand(E,(t=>{const n=_();if(Ge(n)){const o=it(e,n.focus.getNode());if(null!==o)return At(t),o.selectEnd(),!0}return!1}),K));const u=t=>()=>{const o=_();if(!Nt(o,e))return!1;if(Ge(o))return c.$clearText(),!0;if(w(o)){if(!fe(it(e,o.anchor.getNode())))return!1;const r=o.anchor.getNode(),l=o.focus.getNode(),s=e.isParentOf(r),i=e.isParentOf(l);if(s&&!i||i&&!s)return c.$clearText(),!0;const a=n(o.anchor.getNode(),(e=>g(e))),u=a&&n(a,(e=>g(e)&&fe(e.getParent())));if(!g(u)||!g(a))return!1;if(t===Z&&null===u.getPreviousSibling())return!0}return!1};for(const e of at)c.listenersToRemove.add(o.registerCommand(e,u(e),M));const h=t=>{const n=_();if(!Ge(n)&&!w(n))return!1;const o=e.isParentOf(n.anchor.getNode());if(o!==e.isParentOf(n.focus.getNode())){const t=o?"anchor":"focus",r=o?"focus":"anchor",{key:l,offset:s,type:i}=n[r];return e[n[t].isBefore(n[r])?"selectPrevious":"selectNext"]()[r].set(l,s,i),!1}return!!Nt(n,e)&&(!!Ge(n)&&(t&&(t.preventDefault(),t.stopPropagation()),c.$clearText(),!0))};for(const e of ut)c.listenersToRemove.add(o.registerCommand(e,h,M));return c.listenersToRemove.add(o.registerCommand($,(e=>{const t=_();if(t){if(!Ge(t)&&!w(t))return!1;se(o,r(e,ClipboardEvent)?e:null,ie(t));const n=h(e);return w(t)?(t.removeText(),!0):n}return!1}),M)),c.listenersToRemove.add(o.registerCommand(L,(t=>{const o=_();if(!Nt(o,e))return!1;if(Ge(o))return c.$formatCells(t),!0;if(w(o)){const e=n(o.anchor.getNode(),(e=>fe(e)));if(!fe(e))return!1}return!1}),M)),c.listenersToRemove.add(o.registerCommand(W,(t=>{const n=_();if(!Ge(n)||!Nt(n,e))return!1;const o=n.anchor.getNode(),r=n.focus.getNode();if(!fe(o)||!fe(r))return!1;if(function(e,t){if(Ge(e)){const n=e.anchor.getNode(),o=e.focus.getNode();if(t&&n&&o){const[e]=Je(t,n,o);return n.getKey()===e[0][0].cell.getKey()&&o.getKey()===e[e.length-1].at(-1).cell.getKey()}}return!1}(n,e))return e.setFormat(t),!0;const[l,s,i]=Je(e,o,r),c=Math.max(s.startRow+s.cell.__rowSpan-1,i.startRow+i.cell.__rowSpan-1),a=Math.max(s.startColumn+s.cell.__colSpan-1,i.startColumn+i.cell.__colSpan-1),u=Math.min(s.startRow,i.startRow),h=Math.min(s.startColumn,i.startColumn),d=new Set;for(let e=u;e<=c;e++)for(let n=h;n<=a;n++){const o=l[e][n].cell;if(d.has(o))continue;d.add(o),o.setFormat(t);const r=o.getChildren();for(let e=0;e<r.length;e++){const n=r[e];g(n)&&!n.isInline()&&n.setFormat(t)}}return!0}),M)),c.listenersToRemove.add(o.registerCommand(H,(t=>{const r=_();if(!Nt(r,e))return!1;if(Ge(r))return c.$clearHighlight(),!1;if(w(r)){const l=n(r.anchor.getNode(),(e=>fe(e)));if(!fe(l))return!1;if("string"==typeof t){const n=Kt(o,r,e);if(n)return kt(n,e,[C(t)]),!0}}return!1}),M)),l&&c.listenersToRemove.add(o.registerCommand(P,(t=>{const o=_();if(!w(o)||!o.isCollapsed()||!Nt(o,e))return!1;const r=Rt(o.anchor.getNode());return!(null===r||!e.is(Ot(r)))&&(At(t),function(e,t){const o="next"===t?"getNextSibling":"getPreviousSibling",r="next"===t?"getFirstChild":"getLastChild",l=e[o]();if(g(l))return l.selectEnd();const s=n(e,be);null===s&&Se(247);for(let e=s[o]();be(e);e=e[o]()){const t=e[r]();if(g(t))return t.selectEnd()}const i=n(s,zt);null===i&&Se(248);"next"===t?i.selectNext():i.selectPrevious()}(r,t.shiftKey?"previous":"next"),!0)}),M)),c.listenersToRemove.add(o.registerCommand(B,(t=>e.isSelected()),K)),c.listenersToRemove.add(o.registerCommand(D,(e=>{const{nodes:t,selection:o}=e,r=o.getStartEndPoints(),l=Ge(o),s=w(o)&&null!==n(o.anchor.getNode(),(e=>fe(e)))&&null!==n(o.focus.getNode(),(e=>fe(e)))||l;if(1!==t.length||!zt(t[0])||!s||null===r)return!1;const[i]=r,c=t[0],a=c.getChildren(),u=c.getFirstChildOrThrow().getChildrenSize(),h=c.getChildrenSize(),g=n(i.getNode(),(e=>fe(e))),f=g&&n(g,(e=>be(e))),p=f&&n(f,(e=>zt(e)));if(!fe(g)||!be(f)||!zt(p))return!1;const S=f.getIndexWithinParent(),C=Math.min(p.getChildrenSize()-1,S+h-1),_=g.getIndexWithinParent(),b=Math.min(f.getChildrenSize()-1,_+u-1),y=Math.min(_,b),N=Math.min(S,C),x=Math.max(_,b),v=Math.max(S,C),T=p.getChildren();let R=0;for(let e=N;e<=v;e++){const t=T[e];if(!be(t))return!1;const n=a[R];if(!be(n))return!1;const o=t.getChildren(),r=n.getChildren();let l=0;for(let e=y;e<=x;e++){const t=o[e];if(!fe(t))return!1;const n=r[l];if(!fe(n))return!1;const s=t.getChildren();n.getChildren().forEach((e=>{if(m(e)){d().append(e),t.append(e)}else t.append(e)})),s.forEach((e=>e.remove())),l++}R++}return!0}),M)),c.listenersToRemove.add(o.registerCommand(F,(()=>{const t=_(),r=I(),l=c.getAndClearNextFocus();if(null!==l){const{focusCell:n}=l;if(Ge(t)&&t.tableKey===c.tableNodeKey)return(n.x!==c.focusX||n.y!==c.focusY)&&(c.$setFocusCellForSelection(n),!0);if(n!==c.anchorCell&&Nt(t,e))return c.$setFocusCellForSelection(n),!0}if(c.getAndClearShouldCheckSelection()&&w(r)&&w(t)&&t.isCollapsed()){const o=t.anchor.getNode(),r=e.getFirstChild(),l=Rt(o);if(null!==l&&be(r)){const t=r.getFirstChild();if(fe(t)&&e.is(n(l,(n=>n.is(e)||n.is(t)))))return t.selectStart(),!0}}if(w(t)){const{anchor:n,focus:r}=t,l=n.getNode(),s=r.getNode(),i=Rt(l),a=Rt(s),u=!(!i||!e.is(Ot(i))),h=!(!a||!e.is(Ot(a))),d=u!==h,g=u&&h,f=t.isBackward();if(d){const n=t.clone();if(h){const[t]=Je(e,a,a),o=t[0][0].cell,r=t[t.length-1].at(-1).cell;n.focus.set(f?o.getKey():r.getKey(),f?o.getChildrenSize():r.getChildrenSize(),"element")}else if(u){const[t]=Je(e,i,i),o=t[0][0].cell,r=t[t.length-1].at(-1).cell;n.anchor.set(f?r.getKey():o.getKey(),f?r.getChildrenSize():0,"element")}O(n),St(o,c)}else g&&(i.is(a)||(c.$setAnchorCellForSelection(Et(c,i)),c.$setFocusCellForSelection(Et(c,a),!0)))}else if(t&&Ge(t)&&t.is(r)&&t.tableKey===e.getKey()){const n=A(i);if(n&&n.anchorNode&&n.focusNode){const r=U(n.focusNode),l=r&&!e.isParentOf(r),s=U(n.anchorNode),i=s&&e.isParentOf(s);if(l&&i&&n.rangeCount>0){const r=J(n,o);r&&(r.anchor.set(e.getKey(),t.isBackward()?e.getChildrenSize():0,"element"),n.removeAllRanges(),O(r))}}}return t&&!t.is(r)&&(Ge(t)||Ge(r))&&c.tableSelection&&!c.tableSelection.is(r)?(Ge(t)&&t.tableKey===c.tableNodeKey?c.$updateTableTableSelection(t):!Ge(t)&&Ge(r)&&r.tableKey===c.tableNodeKey&&c.$updateTableTableSelection(null),!1):(c.hasHijackedSelectionStyles&&!e.isSelected()?function(e,t){t.$enableHighlightStyle(),pt(t.table,(t=>{const n=t.elem;t.highlighted=!1,Tt(e,t),n.getAttribute("style")||n.removeAttribute("style")}))}(o,c):!c.hasHijackedSelectionStyles&&e.isSelected()&&St(o,c),!1)}),M)),c.listenersToRemove.add(o.registerCommand(z,(()=>{const t=_();if(!w(t)||!t.isCollapsed()||!Nt(t,e))return!1;const n=Kt(o,t,e);return!!n&&(kt(n,e),!0)}),M)),c}function dt(e){return e[ot]||null}function gt(e){let t=e;for(;null!=t;){const e=t.nodeName;if("TD"===e||"TH"===e){const e=t._cell;return void 0===e?null:e}t=t.parentNode}return null}function ft(e,t){const n=[],o={columns:0,domRows:n,rows:0};let r=lt(e,t).querySelector("tr"),l=0,s=0;for(n.length=0;null!=r;){const e=r.nodeName;if("TD"===e||"TH"===e){const e={elem:r,hasBackgroundColor:""!==r.style.backgroundColor,highlighted:!1,x:l,y:s};r._cell=e;let t=n[s];void 0===t&&(t=n[s]=[]),t[l]=e}else{const e=r.firstChild;if(null!=e){r=e;continue}}const t=r.nextSibling;if(null!=t){l++,r=t;continue}const o=r.parentNode;if(null!=o){const e=o.nextSibling;if(null==e)break;s++,l=0,r=e}}return o.columns=l+1,o.rows=s+1,o}function mt(e,t,n){const o=new Set(n?n.getNodes():[]);pt(t,((t,n)=>{const r=t.elem;o.has(n)?(t.highlighted=!0,vt(e,t)):(t.highlighted=!1,Tt(e,t),r.getAttribute("style")||r.removeAttribute("style"))}))}function pt(e,t){const{domRows:n}=e;for(let e=0;e<n.length;e++){const o=n[e];if(o)for(let n=0;n<o.length;n++){const r=o[n];if(!r)continue;const l=U(r.elem);null!==l&&t(r,l,{x:n,y:e})}}}function St(e,t){t.$disableHighlightStyle(),pt(t.table,(t=>{t.highlighted=!0,vt(e,t)}))}const Ct=(e,t,n,o,r)=>{const l="forward"===r;switch(r){case"backward":case"forward":return n!==(l?e.table.columns-1:0)?xt(t.getCellNodeFromCordsOrThrow(n+(l?1:-1),o,e.table),l):o!==(l?e.table.rows-1:0)?xt(t.getCellNodeFromCordsOrThrow(l?0:e.table.columns-1,o+(l?1:-1),e.table),l):l?t.selectNext():t.selectPrevious(),!0;case"up":return 0!==o?xt(t.getCellNodeFromCordsOrThrow(n,o-1,e.table),!1):t.selectPrevious(),!0;case"down":return o!==e.table.rows-1?xt(t.getCellNodeFromCordsOrThrow(n,o+1,e.table),!0):t.selectNext(),!0;default:return!1}};function _t(e,t){let n,o;if(t.startColumn===e.minColumn)n="minColumn";else{if(t.startColumn+t.cell.__colSpan-1!==e.maxColumn)return null;n="maxColumn"}if(t.startRow===e.minRow)o="minRow";else{if(t.startRow+t.cell.__rowSpan-1!==e.maxRow)return null;o="maxRow"}return[n,o]}function wt([e,t]){return["minColumn"===e?"maxColumn":"minColumn","minRow"===t?"maxRow":"minRow"]}function bt(e,t,[n,o]){const r=t[o],l=e[r];void 0===l&&Se(250,o,String(r));const s=t[n],i=l[s];return void 0===i&&Se(250,n,String(s)),i}function yt(e,t,n,o,r){const l=qe(t,n,o),s=function(e,t){const{minColumn:n,maxColumn:o,minRow:r,maxRow:l}=t;let s=1,i=1,c=1,a=1;const u=e[r],h=e[l];for(let e=n;e<=o;e++)s=Math.max(s,u[e].cell.__rowSpan),a=Math.max(a,h[e].cell.__rowSpan);for(let t=r;t<=l;t++)i=Math.max(i,e[t][n].cell.__colSpan),c=Math.max(c,e[t][o].cell.__colSpan);return{bottomSpan:a,leftSpan:i,rightSpan:c,topSpan:s}}(t,l),{topSpan:i,leftSpan:c,bottomSpan:a,rightSpan:u}=s,h=function(e,t){const n=_t(e,t);return null===n&&Se(249,t.cell.getKey()),n}(l,n),[d,g]=wt(h);let f=l[d],m=l[g];"forward"===r?f+="maxColumn"===d?1:c:"backward"===r?f-="minColumn"===d?1:u:"down"===r?m+="maxRow"===g?1:i:"up"===r&&(m-="minRow"===g?1:a);const p=t[m];if(void 0===p)return!1;const S=p[f];if(void 0===S)return!1;const[C,_]=function(e,t,n){const o=qe(e,t,n),r=_t(o,t);if(r)return[bt(e,o,r),bt(e,o,wt(r))];const l=_t(o,n);if(l)return[bt(e,o,wt(l)),bt(e,o,l)];const s=["minColumn","minRow"];return[bt(e,o,s),bt(e,o,wt(s))]}(t,n,S),w=Et(e,C.cell),b=Et(e,_.cell);return e.$setAnchorCellForSelection(w),e.$setFocusCellForSelection(b,!0),!0}function Nt(e,t){if(w(e)||Ge(e)){const n=t.isParentOf(e.anchor.getNode()),o=t.isParentOf(e.focus.getNode());return n&&o}return!1}function xt(e,t){t?e.selectStart():e.selectEnd()}function vt(t,n){const o=n.elem,r=t._config.theme;fe(U(o))||Se(131),e(o,r.tableCellSelected)}function Tt(e,t){const n=t.elem;fe(U(n))||Se(131);const r=e._config.theme;o(n,r.tableCellSelected)}function Rt(e){const t=n(e,fe);return fe(t)?t:null}function Ot(e){const t=n(e,zt);return zt(t)?t:null}function Ft(e,t,o,r,l){if(("up"===o||"down"===o)&&function(e){const t=e.getRootElement();if(!t)return!1;return t.hasAttribute("aria-controls")&&"typeahead-menu"===t.getAttribute("aria-controls")}(e))return!1;const s=_();if(!Nt(s,r)){if(w(s)){if("backward"===o){if(s.focus.offset>0)return!1;const e=function(e){for(let t=e,n=e;null!==n;t=n,n=n.getParent())if(g(n)){if(n!==t&&n.getFirstChild()!==t)return null;if(!n.isInline())return n}return null}(s.focus.getNode());if(!e)return!1;const n=e.getPreviousSibling();return!!zt(n)&&(At(t),t.shiftKey?s.focus.set(n.getParentOrThrow().getKey(),n.getIndexWithinParent(),"element"):n.selectEnd(),!0)}if(t.shiftKey&&("up"===o||"down"===o)){const e=s.focus.getNode();if(!s.isCollapsed()&&("up"===o&&!s.isBackward()||"down"===o&&s.isBackward())){let l=n(e,(e=>zt(e)));if(fe(l)&&(l=n(l,zt)),l!==r)return!1;if(!l)return!1;const i="down"===o?l.getNextSibling():l.getPreviousSibling();if(!i)return!1;let c=0;"up"===o&&g(i)&&(c=i.getChildrenSize());let a=i;if("up"===o&&g(i)){const e=i.getLastChild();a=e||i,c=m(a)?a.getTextContentSize():0}const u=s.clone();return u.focus.set(a.getKey(),c,m(a)?"text":"element"),O(u),At(t),!0}if(Y(e)){const e="up"===o?s.getNodes()[s.getNodes().length-1]:s.getNodes()[0];if(e){if(null!==it(r,e)){const e=r.getFirstDescendant(),t=r.getLastDescendant();if(!e||!t)return!1;const[n]=Ye(e),[o]=Ye(t),s=r.getCordsFromCellNode(n,l.table),i=r.getCordsFromCellNode(o,l.table),c=r.getDOMCellFromCordsOrThrow(s.x,s.y,l.table),a=r.getDOMCellFromCordsOrThrow(i.x,i.y,l.table);return l.$setAnchorCellForSelection(c),l.$setFocusCellForSelection(a,!0),!0}}return!1}{let r=n(e,(e=>g(e)&&!e.isInline()));if(fe(r)&&(r=n(r,zt)),!r)return!1;const i="down"===o?r.getNextSibling():r.getPreviousSibling();if(zt(i)&&l.tableNodeKey===i.getKey()){const e=i.getFirstDescendant(),n=i.getLastDescendant();if(!e||!n)return!1;const[r]=Ye(e),[l]=Ye(n),c=s.clone();return c.focus.set(("up"===o?r:l).getKey(),"up"===o?0:l.getChildrenSize(),"element"),At(t),O(c),!0}}}}return"down"===o&&Pt(e)&&l.setShouldCheckSelection(),!1}if(w(s)&&s.isCollapsed()){const{anchor:i,focus:c}=s,a=n(i.getNode(),fe),u=n(c.getNode(),fe);if(!fe(a)||!a.is(u))return!1;const h=Ot(a);if(h!==r&&null!=h){const n=lt(h,e.getElementByKey(h.getKey()));if(null!=n)return l.table=ft(h,n),Ft(e,t,o,h,l)}if("backward"===o||"forward"===o){const e=i.type,l=i.offset,c=i.getNode();if(!c)return!1;const u=s.getNodes();return(1!==u.length||!q(u[0]))&&(!!function(e,t,o,r){return function(e,t,n){return"element"===e&&("backward"===n?null===t.getPreviousSibling():null===t.getNextSibling())}(e,o,r)||function(e,t,o,r){const l=n(o,(e=>g(e)&&!e.isInline()));if(!l)return!1;const s="backward"===r?0===t:t===o.getTextContentSize();return"text"===e&&s&&("backward"===r?null===l.getPreviousSibling():null===l.getNextSibling())}(e,t,o,r)}(e,l,c,o)&&function(e,t,o,r,l){const[s,i]=Je(r,o,o);if(!function(e,t,n){const o=e[0][0],r=e[e.length-1][e[0].length-1],{startColumn:l,startRow:s}=t;return"backward"===n?l===o.startColumn&&s===o.startRow:l===r.startColumn&&s===r.startRow}(s,i,l))return!1;const c=function(e,t,o){const r=n(e,(e=>g(e)&&!e.isInline()));if(!r)return;const l="backward"===t?r.getPreviousSibling():r.getNextSibling();return l&&zt(l)?l:"backward"===t?o.getPreviousSibling():o.getNextSibling()}(t,l,r);if(!c||zt(c))return!1;At(e),"backward"===l?c.selectEnd():c.selectStart();return!0}(t,c,a,r,o))}const d=e.getElementByKey(a.__key),f=e.getElementByKey(i.key);if(null==f||null==d)return!1;let m;if("element"===i.type)m=f.getBoundingClientRect();else{const t=A(st(e));if(null===t||0===t.rangeCount)return!1;m=t.getRangeAt(0).getBoundingClientRect()}const p="up"===o?a.getFirstChild():a.getLastChild();if(null==p)return!1;const S=e.getElementByKey(p.__key);if(null==S)return!1;const C=S.getBoundingClientRect();if("up"===o?C.top>m.top-m.height:m.bottom+m.height>C.bottom){At(t);const e=r.getCordsFromCellNode(a,l.table);if(!t.shiftKey)return Ct(l,r,e.x,e.y,o);{const t=r.getDOMCellFromCordsOrThrow(e.x,e.y,l.table);l.$setAnchorCellForSelection(t),l.$setFocusCellForSelection(t,!0)}return!0}}else if(Ge(s)){const{anchor:i,focus:c}=s,a=n(i.getNode(),fe),u=n(c.getNode(),fe),[h]=s.getNodes();zt(h)||Se(251);const d=lt(h,e.getElementByKey(h.getKey()));if(!fe(a)||!fe(u)||!zt(h)||null==d)return!1;l.$updateTableTableSelection(s);const g=ft(h,d),f=r.getCordsFromCellNode(a,g),m=r.getDOMCellFromCordsOrThrow(f.x,f.y,g);if(l.$setAnchorCellForSelection(m),At(t),t.shiftKey){const[e,t,n]=Je(r,a,u);return yt(l,e,t,n,o)}return u.selectEnd(),!0}return!1}function At(e){e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation()}function kt(e,t,n){const o=d();"first"===e?t.insertBefore(o):t.insertAfter(o),o.append(...n||[]),o.selectEnd()}function Kt(e,t,o){const r=o.getParent();if(!r)return;const l=A(st(e));if(!l)return;const s=l.anchorNode,i=e.getElementByKey(r.getKey()),c=lt(o,e.getElementByKey(o.getKey()));if(!s||!i||!c||!i.contains(s)||c.contains(s))return;const a=n(t.anchor.getNode(),(e=>fe(e)));if(!a)return;const u=n(a,(e=>zt(e)));if(!zt(u)||!u.is(o))return;const[h,d]=Je(o,a,a),g=h[0][0],f=h[h.length-1][h[0].length-1],{startRow:m,startColumn:p}=d,S=m===g.startRow&&p===g.startColumn,C=m===f.startRow&&p===f.startColumn;return S?"first":C?"last":void 0}function Et(e,t){const{tableNode:n}=e.$lookup(),o=n.getCordsFromCellNode(t,e.table);return n.getDOMCellFromCordsOrThrow(o.x,o.y,e.table)}function Mt(e,t,n){return it(e,U(t,n))}function $t(e,t,n,o){const r=e.querySelector("colgroup");if(!r)return;const l=[];for(let e=0;e<n;e++){const t=document.createElement("col"),n=o&&o[e];n&&(t.style.width=`${n}px`),l.push(t)}r.replaceChildren(...l)}function Lt(t,n,r){r?(e(t,n.theme.tableRowStriping),t.setAttribute("data-lexical-row-striping","true")):(o(t,n.theme.tableRowStriping),t.removeAttribute("data-lexical-row-striping"))}function Wt(t,n,r){if(!n.theme.tableAlignment)return;const l=[],s=[];for(const e of["center","right"]){const t=n.theme.tableAlignment[e];t&&(e===r?s:l).push(t)}o(t,...l),e(t,...s)}const Ht=new WeakSet;function Pt(e=R()){return Ht.has(e)}function Bt(e,t){t?Ht.add(e):Ht.delete(e)}class Dt extends u{static getType(){return"table"}getColWidths(){return this.getLatest().__colWidths}setColWidths(e){const t=this.getWritable();return t.__colWidths=e,t}static clone(e){return new Dt(e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__colWidths=e.__colWidths,this.__rowStriping=e.__rowStriping}static importDOM(){return{table:e=>({conversion:Ut,priority:1})}}static importJSON(e){return Jt().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setRowStriping(e.rowStriping||!1).setColWidths(e.colWidths)}constructor(e){super(e),this.__rowStriping=!1}exportJSON(){return{...super.exportJSON(),colWidths:this.getColWidths(),rowStriping:this.__rowStriping?this.__rowStriping:void 0}}extractWithChild(e,t,n){return"html"===n}getDOMSlot(e){const t="TABLE"!==e.nodeName&&e.querySelector("table")||e;return"TABLE"!==t.nodeName&&Se(229),super.getDOMSlot(t).withAfter(t.querySelector("colgroup"))}createDOM(t,n){const o=document.createElement("table"),r=document.createElement("colgroup");if(o.appendChild(r),$t(o,0,this.getColumnCount(),this.getColWidths()),re(r),e(o,t.theme.table),Wt(o,t,this.getFormatType()),this.__rowStriping&&Lt(o,t,!0),Pt(n)){const n=document.createElement("div"),r=t.theme.tableScrollableWrapper;return r?e(n,r):n.style.cssText="overflow-x: auto;",n.appendChild(o),n}return o}updateDOM(e,t,n){return e.__rowStriping!==this.__rowStriping&&Lt(t,n,this.__rowStriping),$t(t,0,this.getColumnCount(),this.getColWidths()),Wt(this.getDOMSlot(t).element,n,this.getFormatType()),!1}exportDOM(e){const t=super.exportDOM(e),{element:n}=t;return{after:n=>{if(t.after&&(n=t.after(n),this.__format&&Wt(n,e._config,this.getFormatType())),l(n)&&"TABLE"!==n.nodeName&&(n=n.querySelector("table")),!l(n))return null;const[o]=ze(this,null,null),r=new Map;for(const e of o)for(const t of e){const e=t.cell.getKey();r.has(e)||r.set(e,{colSpan:t.cell.getColSpan(),startColumn:t.startColumn})}const s=new Set;for(const e of n.querySelectorAll(":scope > tr > [data-temporary-table-cell-lexical-key]")){const t=e.getAttribute("data-temporary-table-cell-lexical-key");if(t){const n=r.get(t);if(e.removeAttribute("data-temporary-table-cell-lexical-key"),n){r.delete(t);for(let e=0;e<n.colSpan;e++)s.add(e+n.startColumn)}}}const i=n.querySelector(":scope > colgroup");if(i){const e=Array.from(n.querySelectorAll(":scope > colgroup > col")).filter(((e,t)=>s.has(t)));i.replaceChildren(...e)}const c=n.querySelectorAll(":scope > tr");if(c.length>0){const e=document.createElement("tbody");for(const t of c)e.appendChild(t);n.append(e)}return n},element:l(n)&&"TABLE"!==n.nodeName?n.querySelector("table"):n}}canBeEmpty(){return!1}isShadowRoot(){return!0}getCordsFromCellNode(e,t){const{rows:n,domRows:o}=t;for(let t=0;t<n;t++){const n=o[t];if(null!=n)for(let o=0;o<n.length;o++){const r=n[o];if(null==r)continue;const{elem:l}=r,s=Mt(this,l);if(null!==s&&e.is(s))return{x:o,y:t}}}throw new Error("Cell not found in table.")}getDOMCellFromCords(e,t,n){const{domRows:o}=n,r=o[t];if(null==r)return null;const l=r[e<r.length?e:r.length-1];return null==l?null:l}getDOMCellFromCordsOrThrow(e,t,n){const o=this.getDOMCellFromCords(e,t,n);if(!o)throw new Error("Cell not found at cords.");return o}getCellNodeFromCords(e,t,n){const o=this.getDOMCellFromCords(e,t,n);if(null==o)return null;const r=U(o.elem);return fe(r)?r:null}getCellNodeFromCordsOrThrow(e,t,n){const o=this.getCellNodeFromCords(e,t,n);if(!o)throw new Error("Node at cords not TableCellNode.");return o}getRowStriping(){return Boolean(this.getLatest().__rowStriping)}setRowStriping(e){const t=this.getWritable();return t.__rowStriping=e,t}canSelectBefore(){return!0}canIndent(){return!1}getColumnCount(){const e=this.getFirstChild();if(!e)return 0;let t=0;return e.getChildren().forEach((e=>{fe(e)&&(t+=e.getColSpan())})),t}}function It(e,t){const n=e.getElementByKey(t.getKey());return null===n&&Se(230),ft(t,n)}function Ut(e){const n=Jt();e.hasAttribute("data-lexical-row-striping")&&n.setRowStriping(!0);const o=e.querySelector(":scope > colgroup");if(o){let e=[];for(const t of o.querySelectorAll(":scope > col")){let n=t.style.width||"";if(!ce.test(n)&&(n=t.getAttribute("width")||"",!/^\d+$/.test(n))){e=void 0;break}e.push(parseFloat(n))}e&&n.setColWidths(e)}return{after:e=>t(e,be),node:n}}function Jt(){return p(new Dt)}function zt(e){return e instanceof Dt}function Yt({rows:e,columns:t,includeHeaders:n}){const o=ve(Number(e),Number(t),n);c(o);const r=o.getFirstDescendant();return m(r)&&r.select(),!0}function qt(e){be(e.getParent())?e.isEmpty()&&e.append(d()):e.remove()}function Xt(e){zt(e.getParent())?a(e,fe):e.remove()}function jt(e){a(e,be);const[t]=ze(e,null,null),n=t.reduce(((e,t)=>Math.max(e,t.length)),0),o=e.getChildren();for(let e=0;e<t.length;++e){const r=o[e];if(!r)continue;be(r)||Se(254,r.constructor.name,r.getType());const l=t[e].reduce(((e,t)=>t?1+e:e),0);if(l!==n)for(let e=l;e<n;++e){const e=ge();e.append(d()),r.append(e)}}}function Vt(e){return e.registerNodeTransform(ue,(e=>{if(e.getColSpan()>1||e.getRowSpan()>1){const[,,t]=Ye(e),[n]=Je(t,e,e),o=n.length,r=n[0].length;let l=t.getFirstChild();be(l)||Se(175);const i=[];for(let e=0;e<o;e++){0!==e&&(l=l.getNextSibling(),be(l)||Se(175));let t=null;for(let o=0;o<r;o++){const r=n[e][o],c=r.cell;if(r.startRow===e&&r.startColumn===o)t=c,i.push(c);else if(c.getColSpan()>1||c.getRowSpan()>1){fe(c)||Se(176);const e=ge(c.__headerState);null!==t?t.insertAfter(e):s(l,e)}}}for(const e of i)e.setColSpan(1),e.setRowSpan(1)}}))}function Gt(e,t=!0){const n=new Map,o=(o,r,l)=>{const s=lt(o,l),i=ht(o,s,e,t);n.set(r,[i,s])},r=e.registerMutationListener(Dt,(t=>{e.getEditorState().read((()=>{for(const[e,r]of t){const t=n.get(e);if("created"===r||"updated"===r){const{tableNode:r,tableElement:l}=tt(e);void 0===t?o(r,e,l):l!==t[1]&&(t[0].removeListeners(),n.delete(e),o(r,e,l))}else"destroyed"===r&&void 0!==t&&(t[0].removeListeners(),n.delete(e))}}),{editor:e})}),{skipInitialization:!1});return()=>{r();for(const[,[e]]of n)e.removeListeners()}}function Qt(e){return e.hasNodes([Dt])||Se(255),i(e.registerCommand(me,Yt,le),e.registerNodeTransform(Dt,jt),e.registerNodeTransform(Ce,Xt),e.registerNodeTransform(ue,qt))}export{Je as $computeTableMap,ze as $computeTableMapSkipCellCheck,ge as $createTableCellNode,Jt as $createTableNode,ve as $createTableNodeWithDimensions,we as $createTableRowNode,Qe as $createTableSelection,Ze as $createTableSelectionFrom,He as $deleteTableColumn,Be as $deleteTableColumn__EXPERIMENTAL,Pe as $deleteTableRow__EXPERIMENTAL,Rt as $findCellNode,Ot as $findTableNode,It as $getElementForTableNode,Ye as $getNodeTriplet,tt as $getTableAndElementByKey,Te as $getTableCellNodeFromLexicalNode,Xe as $getTableCellNodeRect,Ae as $getTableColumnIndexFromTableCellNode,Oe as $getTableNodeFromLexicalNodeOrThrow,Fe as $getTableRowIndexFromTableCellNode,Re as $getTableRowNodeFromTableCellNodeOrThrow,Le as $insertTableColumn,We as $insertTableColumn__EXPERIMENTAL,Ee as $insertTableRow,$e as $insertTableRow__EXPERIMENTAL,Pt as $isScrollableTablesActive,fe as $isTableCellNode,zt as $isTableNode,be as $isTableRowNode,Ge as $isTableSelection,Ke as $removeTableRowAtIndex,Ue as $unmergeCell,me as INSERT_TABLE_COMMAND,ae as TableCellHeaderStates,ue as TableCellNode,Dt as TableNode,nt as TableObserver,Ce as TableRowNode,ht as applyTableHandlers,gt as getDOMCellFromTarget,lt as getTableElement,dt as getTableObserverFromTableElement,Vt as registerTableCellUnmergeTransform,Qt as registerTablePlugin,Gt as registerTableSelectionObserver,Bt as setScrollableTablesActive};
|
9
|
+
import{addClassNamesToElement as e,$descendantsMatching as t,$findMatchingParent as n,removeClassNamesFromElement as o,objectKlassEquals as r,isHTMLElement as l,$insertFirst as s,mergeRegister as i,$insertNodeToNearestRoot as c,$unwrapAndFilterDescendants as a}from"@lexical/utils";import{ElementNode as u,isHTMLElement as h,$createParagraphNode as d,$isElementNode as g,$isLineBreakNode as f,$isTextNode as m,$applyNodeReplacement as p,createCommand as C,$createTextNode as S,$getSelection as _,$isRangeSelection as w,$createPoint as b,$isParagraphNode as y,$normalizeSelection__EXPERIMENTAL as N,isCurrentlyReadOnlyMode as x,TEXT_TYPE_TO_FORMAT as v,$getNodeByKey as T,$getEditor as F,$setSelection as R,SELECTION_CHANGE_COMMAND as O,getDOMSelection as A,$createRangeSelection as k,COMMAND_PRIORITY_HIGH as K,KEY_ESCAPE_COMMAND as E,COMMAND_PRIORITY_CRITICAL as M,CUT_COMMAND as $,FORMAT_TEXT_COMMAND as L,FORMAT_ELEMENT_COMMAND as W,CONTROLLED_TEXT_INSERTION_COMMAND as H,KEY_TAB_COMMAND as P,FOCUS_COMMAND as B,SELECTION_INSERT_CLIPBOARD_NODES_COMMAND as D,$getPreviousSelection as z,$getNearestNodeFromDOMNode as I,$createRangeSelectionFromDom as U,INSERT_PARAGRAPH_COMMAND as J,$isRootOrShadowRoot as Y,$isDecoratorNode as q,KEY_ARROW_DOWN_COMMAND as X,KEY_ARROW_UP_COMMAND as j,KEY_ARROW_LEFT_COMMAND as V,KEY_ARROW_RIGHT_COMMAND as G,DELETE_WORD_COMMAND as Q,DELETE_LINE_COMMAND as Z,DELETE_CHARACTER_COMMAND as ee,KEY_BACKSPACE_COMMAND as te,KEY_DELETE_COMMAND as ne,isDOMNode as oe,setDOMUnmanaged as re,COMMAND_PRIORITY_EDITOR as le}from"lexical";import{copyToClipboard as se,$getClipboardDataFromSelection as ie}from"@lexical/clipboard";const ce=/^(\d+(?:\.\d+)?)px$/,ae={BOTH:3,COLUMN:2,NO_STATUS:0,ROW:1};class ue extends u{static getType(){return"tablecell"}static clone(e){return new ue(e.__headerState,e.__colSpan,e.__width,e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__rowSpan=e.__rowSpan,this.__backgroundColor=e.__backgroundColor,this.__verticalAlign=e.__verticalAlign}static importDOM(){return{td:e=>({conversion:de,priority:0}),th:e=>({conversion:de,priority:0})}}static importJSON(e){return ge().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setHeaderStyles(e.headerState).setColSpan(e.colSpan||1).setRowSpan(e.rowSpan||1).setWidth(e.width||void 0).setBackgroundColor(e.backgroundColor||null).setVerticalAlign(e.verticalAlign||void 0)}constructor(e=ae.NO_STATUS,t=1,n,o){super(o),this.__colSpan=t,this.__rowSpan=1,this.__headerState=e,this.__width=n,this.__backgroundColor=null}createDOM(t){const n=document.createElement(this.getTag());return this.__width&&(n.style.width=`${this.__width}px`),this.__colSpan>1&&(n.colSpan=this.__colSpan),this.__rowSpan>1&&(n.rowSpan=this.__rowSpan),null!==this.__backgroundColor&&(n.style.backgroundColor=this.__backgroundColor),he(this.__verticalAlign)&&(n.style.verticalAlign=this.__verticalAlign),e(n,t.theme.tableCell,this.hasHeader()&&t.theme.tableCellHeader),n}exportDOM(e){const t=super.exportDOM(e);if(h(t.element)){const e=t.element;e.setAttribute("data-temporary-table-cell-lexical-key",this.getKey()),e.style.border="1px solid black",this.__colSpan>1&&(e.colSpan=this.__colSpan),this.__rowSpan>1&&(e.rowSpan=this.__rowSpan),e.style.width=`${this.getWidth()||75}px`,e.style.verticalAlign=this.getVerticalAlign()||"top",e.style.textAlign="start",null===this.__backgroundColor&&this.hasHeader()&&(e.style.backgroundColor="#f2f3f5")}return t}exportJSON(){return{...super.exportJSON(),...he(this.__verticalAlign)&&{verticalAlign:this.__verticalAlign},backgroundColor:this.getBackgroundColor(),colSpan:this.__colSpan,headerState:this.__headerState,rowSpan:this.__rowSpan,width:this.getWidth()}}getColSpan(){return this.getLatest().__colSpan}setColSpan(e){const t=this.getWritable();return t.__colSpan=e,t}getRowSpan(){return this.getLatest().__rowSpan}setRowSpan(e){const t=this.getWritable();return t.__rowSpan=e,t}getTag(){return this.hasHeader()?"th":"td"}setHeaderStyles(e,t=ae.BOTH){const n=this.getWritable();return n.__headerState=e&t|n.__headerState&~t,n}getHeaderStyles(){return this.getLatest().__headerState}setWidth(e){const t=this.getWritable();return t.__width=e,t}getWidth(){return this.getLatest().__width}getBackgroundColor(){return this.getLatest().__backgroundColor}setBackgroundColor(e){const t=this.getWritable();return t.__backgroundColor=e,t}getVerticalAlign(){return this.getLatest().__verticalAlign}setVerticalAlign(e){const t=this.getWritable();return t.__verticalAlign=e||void 0,t}toggleHeaderStyle(e){const t=this.getWritable();return(t.__headerState&e)===e?t.__headerState-=e:t.__headerState+=e,t}hasHeaderState(e){return(this.getHeaderStyles()&e)===e}hasHeader(){return this.getLatest().__headerState!==ae.NO_STATUS}updateDOM(e){return e.__headerState!==this.__headerState||e.__width!==this.__width||e.__colSpan!==this.__colSpan||e.__rowSpan!==this.__rowSpan||e.__backgroundColor!==this.__backgroundColor||e.__verticalAlign!==this.__verticalAlign}isShadowRoot(){return!0}collapseAtStart(){return!0}canBeEmpty(){return!1}canIndent(){return!1}}function he(e){return"middle"===e||"bottom"===e}function de(e){const t=e,n=e.nodeName.toLowerCase();let o;ce.test(t.style.width)&&(o=parseFloat(t.style.width));const r=ge("th"===n?ae.ROW:ae.NO_STATUS,t.colSpan,o);r.__rowSpan=t.rowSpan;const l=t.style.backgroundColor;""!==l&&(r.__backgroundColor=l);const s=t.style.verticalAlign;he(s)&&(r.__verticalAlign=s);const i=t.style,c=(i&&i.textDecoration||"").split(" "),a="700"===i.fontWeight||"bold"===i.fontWeight,u=c.includes("line-through"),h="italic"===i.fontStyle,p=c.includes("underline");return{after:e=>(0===e.length&&e.push(d()),e),forChild:(e,t)=>{if(fe(t)&&!g(e)){const t=d();return f(e)&&"\n"===e.getTextContent()?null:(m(e)&&(a&&e.toggleFormat("bold"),u&&e.toggleFormat("strikethrough"),h&&e.toggleFormat("italic"),p&&e.toggleFormat("underline")),t.append(e),t)}return e},node:r}}function ge(e=ae.NO_STATUS,t=1,n){return p(new ue(e,t,n))}function fe(e){return e instanceof ue}const me=C("INSERT_TABLE_COMMAND");function pe(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Ce=pe((function(e){const t=new URLSearchParams;t.append("code",e);for(let e=1;e<arguments.length;e++)t.append("v",arguments[e]);throw Error(`Minified Lexical error #${e}; visit https://lexical.dev/docs/error?${t} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}));class Se extends u{static getType(){return"tablerow"}static clone(e){return new Se(e.__height,e.__key)}static importDOM(){return{tr:e=>({conversion:_e,priority:0})}}static importJSON(e){return we().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setHeight(e.height)}constructor(e,t){super(t),this.__height=e}exportJSON(){const e=this.getHeight();return{...super.exportJSON(),...void 0===e?void 0:{height:e}}}createDOM(t){const n=document.createElement("tr");return this.__height&&(n.style.height=`${this.__height}px`),e(n,t.theme.tableRow),n}extractWithChild(e,t,n){return"html"===n}isShadowRoot(){return!0}setHeight(e){const t=this.getWritable();return t.__height=e,t}getHeight(){return this.getLatest().__height}updateDOM(e){return e.__height!==this.__height}canBeEmpty(){return!1}canIndent(){return!1}}function _e(e){const n=e;let o;return ce.test(n.style.height)&&(o=parseFloat(n.style.height)),{after:e=>t(e,fe),node:we(o)}}function we(e){return p(new Se(e))}function be(e){return e instanceof Se}const ye="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,Ne=ye&&"documentMode"in document?document.documentMode:null,xe=ye&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);function ve(e,t,n=!0){const o=Jt();for(let r=0;r<e;r++){const e=we();for(let o=0;o<t;o++){let t=ae.NO_STATUS;"object"==typeof n?(0===r&&n.rows&&(t|=ae.ROW),0===o&&n.columns&&(t|=ae.COLUMN)):n&&(0===r&&(t|=ae.ROW),0===o&&(t|=ae.COLUMN));const l=ge(t),s=d();s.append(S()),l.append(s),e.append(l)}o.append(e)}return o}function Te(e){const t=n(e,(e=>fe(e)));return fe(t)?t:null}function Fe(e){const t=n(e,(e=>be(e)));if(be(t))return t;throw new Error("Expected table cell to be inside of table row.")}function Re(e){const t=n(e,(e=>Yt(e)));if(Yt(t))return t;throw new Error("Expected table cell to be inside of table.")}function Oe(e){const t=Fe(e);return Re(t).getChildren().findIndex((e=>e.is(t)))}function Ae(e){return Fe(e).getChildren().findIndex((t=>t.is(e)))}function ke(e,t){const n=Re(e),{x:o,y:r}=n.getCordsFromCellNode(e,t);return{above:n.getCellNodeFromCords(o,r-1,t),below:n.getCellNodeFromCords(o,r+1,t),left:n.getCellNodeFromCords(o-1,r,t),right:n.getCellNodeFromCords(o+1,r,t)}}function Ke(e,t){const n=e.getChildren();if(t>=n.length||t<0)throw new Error("Expected table cell to be inside of table row.");return n[t].remove(),e}function Ee(e,t,n=!0,o,r){const l=e.getChildren();if(t>=l.length||t<0)throw new Error("Table row target index out of range");const s=l[t];if(!be(s))throw new Error("Row before insertion index does not exist.");for(let e=0;e<o;e++){const e=s.getChildren(),t=e.length,o=we();for(let n=0;n<t;n++){const t=e[n];fe(t)||Ce(12);const{above:l,below:s}=ke(t,r);let i=ae.NO_STATUS;const c=l&&l.getWidth()||s&&s.getWidth()||void 0;(l&&l.hasHeaderState(ae.COLUMN)||s&&s.hasHeaderState(ae.COLUMN))&&(i|=ae.COLUMN);const a=ge(i,1,c);a.append(d()),o.append(a)}n?s.insertAfter(o):s.insertBefore(o)}return e}ye&&"InputEvent"in window&&!Ne&&new window.InputEvent("input");const Me=(e,t)=>e===ae.BOTH||e===t?t:ae.NO_STATUS;function $e(e=!0){const t=_();w(t)||Ge(t)||Ce(188);const n=t.anchor.getNode(),o=t.focus.getNode(),[r]=Ye(n),[l,,s]=Ye(o),[i,c,a]=Ue(s,l,r),u=i[0].length,{startRow:h}=a,{startRow:g}=c;let f=null;if(e){const e=Math.max(g+l.__rowSpan,h+r.__rowSpan)-1,t=i[e],n=we();for(let o=0;o<u;o++){const{cell:r,startRow:l}=t[o];if(l+r.__rowSpan-1<=e){const e=t[o].cell.__headerState,r=Me(e,ae.COLUMN);n.append(ge(r).append(d()))}else r.setRowSpan(r.__rowSpan+1)}const o=s.getChildAtIndex(e);be(o)||Ce(256),o.insertAfter(n),f=n}else{const e=Math.min(g,h),t=i[e],n=we();for(let o=0;o<u;o++){const{cell:r,startRow:l}=t[o];if(l===e){const e=t[o].cell.__headerState,r=Me(e,ae.COLUMN);n.append(ge(r).append(d()))}else r.setRowSpan(r.__rowSpan+1)}const o=s.getChildAtIndex(e);be(o)||Ce(257),o.insertBefore(n),f=n}return f}function Le(e,t,n=!0,o,r){const l=e.getChildren(),s=[];for(let e=0;e<l.length;e++){const n=l[e];if(be(n))for(let e=0;e<o;e++){const e=n.getChildren();if(t>=e.length||t<0)throw new Error("Table column target index out of range");const o=e[t];fe(o)||Ce(12);const{left:l,right:i}=ke(o,r);let c=ae.NO_STATUS;(l&&l.hasHeaderState(ae.ROW)||i&&i.hasHeaderState(ae.ROW))&&(c|=ae.ROW);const a=ge(c);a.append(d()),s.push({newTableCell:a,targetCell:o})}}return s.forEach((({newTableCell:e,targetCell:t})=>{n?t.insertAfter(e):t.insertBefore(e)})),e}function We(e=!0){const t=_();w(t)||Ge(t)||Ce(188);const n=t.anchor.getNode(),o=t.focus.getNode(),[r]=Ye(n),[l,,s]=Ye(o),[i,c,a]=Ue(s,l,r),u=i.length,h=e?Math.max(c.startColumn,a.startColumn):Math.min(c.startColumn,a.startColumn),g=e?h+l.__colSpan-1:h-1,f=s.getFirstChild();be(f)||Ce(120);let m=null;function p(e=ae.NO_STATUS){const t=ge(e).append(d());return null===m&&(m=t),t}let C=f;e:for(let e=0;e<u;e++){if(0!==e){const e=C.getNextSibling();be(e)||Ce(121),C=e}const t=i[e],n=t[g<0?0:g].cell.__headerState,o=Me(n,ae.ROW);if(g<0){ze(C,p(o));continue}const{cell:r,startColumn:l,startRow:s}=t[g];if(l+r.__colSpan-1<=g){let n=r,l=s,i=g;for(;l!==e&&n.__rowSpan>1;){if(i-=r.__colSpan,!(i>=0)){C.append(p(o));continue e}{const{cell:e,startRow:o}=t[i];n=e,l=o}}n.insertAfter(p(o))}else r.setColSpan(r.__colSpan+1)}null!==m&&De(m);const S=s.getColWidths();if(S){const e=[...S],t=g<0?0:g,n=e[t];e.splice(t,0,n),s.setColWidths(e)}return m}function He(e,t){const n=e.getChildren();for(let e=0;e<n.length;e++){const o=n[e];if(be(o)){const e=o.getChildren();if(t>=e.length||t<0)throw new Error("Table column target index out of range");e[t].remove()}}return e}function Pe(){const e=_();w(e)||Ge(e)||Ce(188);const[t,n]=e.isBackward()?[e.focus.getNode(),e.anchor.getNode()]:[e.anchor.getNode(),e.focus.getNode()],[o,,r]=Ye(t),[l]=Ye(n),[s,i,c]=Ue(r,o,l),{startRow:a}=i,{startRow:u}=c,h=u+l.__rowSpan-1;if(s.length===h-a+1)return void r.remove();const d=s[0].length,g=o.__rowSpan,f=s[h+1],m=r.getChildAtIndex(h+1);for(let e=h;e>=a;e--){for(let t=d-1;t>=0;t--){const{cell:n,startRow:o,startColumn:r}=s[e][t];if(r===t){if(e===a&&o<a){const e=a-o;n.setRowSpan(n.__rowSpan-Math.min(g,n.__rowSpan-e))}if(o>=a&&o+n.__rowSpan-1>h){n.setRowSpan(n.__rowSpan-(h-o+1)),null===m&&Ce(122);let r=null;for(let n=0;n<t;n++){const t=f[n],o=t.cell;t.startRow===e+1&&(r=o),o.__colSpan>1&&(n+=o.__colSpan-1)}null===r?ze(m,n):r.insertAfter(n)}}}const t=r.getChildAtIndex(e);be(t)||Ce(206,String(e)),t.remove()}if(void 0!==f){const{cell:e}=f[0];De(e)}else{const e=s[a-1],{cell:t}=e[0];De(t)}}function Be(){const e=_();w(e)||Ge(e)||Ce(188);const t=e.anchor.getNode(),n=e.focus.getNode(),[o,,r]=Ye(t),[l]=Ye(n),[s,i,c]=Ue(r,o,l),{startColumn:a}=i,{startRow:u,startColumn:h}=c,d=Math.min(a,h),g=Math.max(a+o.__colSpan-1,h+l.__colSpan-1),f=g-d+1;if(s[0].length===g-d+1)return r.selectPrevious(),void r.remove();const m=s.length;for(let e=0;e<m;e++)for(let t=d;t<=g;t++){const{cell:n,startColumn:o}=s[e][t];if(o<d){if(t===d){const e=d-o;n.setColSpan(n.__colSpan-Math.min(f,n.__colSpan-e))}}else if(o+n.__colSpan-1>g){if(t===g){const e=g-o+1;n.setColSpan(n.__colSpan-e)}}else n.remove()}const p=s[u],C=a>h?p[a+o.__colSpan]:p[h+l.__colSpan];if(void 0!==C){const{cell:e}=C;De(e)}else{const e=h<a?p[h-1]:p[a-1],{cell:t}=e;De(t)}const S=r.getColWidths();if(S){const e=[...S];e.splice(d,f),r.setColWidths(e)}}function De(e){const t=e.getFirstDescendant();null==t?e.selectStart():t.getParentOrThrow().selectStart()}function ze(e,t){const n=e.getFirstChild();null!==n?n.insertBefore(t):e.append(t)}function Ie(){const e=_();w(e)||Ge(e)||Ce(188);const t=e.anchor.getNode(),[n,o,r]=Ye(t),l=n.__colSpan,s=n.__rowSpan;if(1===l&&1===s)return;const[i,c]=Ue(r,n,n),{startColumn:a,startRow:u}=c,h=n.__headerState&ae.COLUMN,g=Array.from({length:l},((e,t)=>{let n=h;for(let e=0;0!==n&&e<i.length;e++)n&=i[e][t+a].cell.__headerState;return n})),f=n.__headerState&ae.ROW,m=Array.from({length:s},((e,t)=>{let n=f;for(let e=0;0!==n&&e<i[0].length;e++)n&=i[t+u][e].cell.__headerState;return n}));if(l>1){for(let e=1;e<l;e++)n.insertAfter(ge(g[e]|m[0]).append(d()));n.setColSpan(1)}if(s>1){let e;for(let t=1;t<s;t++){const n=u+t,r=i[n];e=(e||o).getNextSibling(),be(e)||Ce(125);let s=null;for(let e=0;e<a;e++){const t=r[e],o=t.cell;t.startRow===n&&(s=o),o.__colSpan>1&&(e+=o.__colSpan-1)}if(null===s)for(let n=l-1;n>=0;n--)ze(e,ge(g[n]|m[t]).append(d()));else for(let e=l-1;e>=0;e--)s.insertAfter(ge(g[e]|m[t]).append(d()))}n.setRowSpan(1)}}function Ue(e,t,n){const[o,r,l]=Je(e,t,n);return null===r&&Ce(207),null===l&&Ce(208),[o,r,l]}function Je(e,t,n){const o=[];let r=null,l=null;function s(e){let t=o[e];return void 0===t&&(o[e]=t=[]),t}const i=e.getChildren();for(let e=0;e<i.length;e++){const o=i[e];be(o)||Ce(209);const c=s(e);for(let a=o.getFirstChild(),u=0;null!=a;a=a.getNextSibling()){for(fe(a)||Ce(147);void 0!==c[u];)u++;const o={cell:a,startColumn:u,startRow:e},{__rowSpan:h,__colSpan:d}=a;for(let t=0;t<h&&!(e+t>=i.length);t++){const n=s(e+t);for(let e=0;e<d;e++)n[u+e]=o}null!==t&&null===r&&t.is(a)&&(r=o),null!==n&&null===l&&n.is(a)&&(l=o)}}return[o,r,l]}function Ye(e){let t;if(e instanceof ue)t=e;else if("__type"in e){const o=n(e,fe);fe(o)||Ce(148),t=o}else{const o=n(e.getNode(),fe);fe(o)||Ce(148),t=o}const o=t.getParent();be(o)||Ce(149);const r=o.getParent();return Yt(r)||Ce(210),[t,o,r]}function qe(e,t,n){let o=Math.min(t.startColumn,n.startColumn),r=Math.min(t.startRow,n.startRow),l=Math.max(t.startColumn+t.cell.__colSpan-1,n.startColumn+n.cell.__colSpan-1),s=Math.max(t.startRow+t.cell.__rowSpan-1,n.startRow+n.cell.__rowSpan-1),i=o,c=r,a=o,u=r;function h(e){const{cell:t,startColumn:n,startRow:i}=e;o=Math.min(o,n),r=Math.min(r,i),l=Math.max(l,n+t.__colSpan-1),s=Math.max(s,i+t.__rowSpan-1)}for(;o<i||r<c||l>a||s>u;){if(o<i){const t=u-c,n=i-1;for(let o=0;o<=t;o++)h(e[c+o][n]);i=n}if(r<c){const t=a-i,n=c-1;for(let o=0;o<=t;o++)h(e[n][i+o]);c=n}if(l>a){const t=u-c,n=a+1;for(let o=0;o<=t;o++)h(e[c+o][n]);a=n}if(s>u){const t=a-i,n=u+1;for(let o=0;o<=t;o++)h(e[n][i+o]);u=n}}return{maxColumn:l,maxRow:s,minColumn:o,minRow:r}}function Xe(e){const[t,,n]=Ye(e),o=n.getChildren(),r=o.length,l=o[0].getChildren().length,s=new Array(r);for(let e=0;e<r;e++)s[e]=new Array(l);for(let e=0;e<r;e++){const n=o[e].getChildren();let r=0;for(let o=0;o<n.length;o++){for(;s[e][r];)r++;const l=n[o],i=l.__rowSpan||1,c=l.__colSpan||1;for(let t=0;t<i;t++)for(let n=0;n<c;n++)s[e+t][r+n]=l;if(t===l)return{colSpan:c,columnIndex:r,rowIndex:e,rowSpan:i};r+=c}}return null}function je(e){const[[t,o,r,l],[s,i,c,a]]=["anchor","focus"].map((t=>{const o=e[t].getNode(),r=n(o,fe);fe(r)||Ce(238,t,o.getKey(),o.getType());const l=r.getParent();be(l)||Ce(239,t);const s=l.getParent();return Yt(s)||Ce(240,t),[o,r,l,s]}));return l.is(a)||Ce(241),{anchorCell:o,anchorNode:t,anchorRow:r,anchorTable:l,focusCell:i,focusNode:s,focusRow:c,focusTable:a}}class Ve{constructor(e,t,n){this.anchor=t,this.focus=n,t._selection=this,n._selection=this,this._cachedNodes=null,this.dirty=!1,this.tableKey=e}getStartEndPoints(){return[this.anchor,this.focus]}isValid(){return"root"!==this.tableKey&&"root"!==this.anchor.key&&"element"===this.anchor.type&&"root"!==this.focus.key&&"element"===this.focus.type}isBackward(){return this.focus.isBefore(this.anchor)}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e}is(e){return Ge(e)&&this.tableKey===e.tableKey&&this.anchor.is(e.anchor)&&this.focus.is(e.focus)}set(e,t,n){this.dirty=this.dirty||e!==this.tableKey||t!==this.anchor.key||n!==this.focus.key,this.tableKey=e,this.anchor.key=t,this.focus.key=n,this._cachedNodes=null}clone(){return new Ve(this.tableKey,b(this.anchor.key,this.anchor.offset,this.anchor.type),b(this.focus.key,this.focus.offset,this.focus.type))}isCollapsed(){return!1}extract(){return this.getNodes()}insertRawText(e){}insertText(){}hasFormat(e){let t=0;this.getNodes().filter(fe).forEach((e=>{const n=e.getFirstChild();y(n)&&(t|=n.getTextFormat())}));const n=v[e];return!!(t&n)}insertNodes(e){const t=this.focus.getNode();g(t)||Ce(151);N(t.select(0,t.getChildrenSize())).insertNodes(e)}getShape(){const{anchorCell:e,focusCell:t}=je(this),n=Xe(e);null===n&&Ce(153);const o=Xe(t);null===o&&Ce(155);const r=Math.min(n.columnIndex,o.columnIndex),l=Math.max(n.columnIndex+n.colSpan-1,o.columnIndex+o.colSpan-1),s=Math.min(n.rowIndex,o.rowIndex),i=Math.max(n.rowIndex+n.rowSpan-1,o.rowIndex+o.rowSpan-1);return{fromX:Math.min(r,l),fromY:Math.min(s,i),toX:Math.max(r,l),toY:Math.max(s,i)}}getNodes(){if(!this.isValid())return[];const e=this._cachedNodes;if(null!==e)return e;const{anchorTable:t,anchorCell:n,focusCell:o}=je(this),r=o.getParents()[1];if(r!==t){if(t.isParentOf(o)){const e=r.getParent();null==e&&Ce(159),this.set(this.tableKey,o.getKey(),e.getKey())}else{const e=t.getParent();null==e&&Ce(158),this.set(this.tableKey,e.getKey(),o.getKey())}return this.getNodes()}const[l,s,i]=Ue(t,n,o),{minColumn:c,maxColumn:a,minRow:u,maxRow:h}=qe(l,s,i),d=new Map([[t.getKey(),t]]);let g=null;for(let e=u;e<=h;e++)for(let t=c;t<=a;t++){const{cell:n}=l[e][t],o=n.getParent();be(o)||Ce(160),o!==g&&(d.set(o.getKey(),o),g=o),d.has(n.getKey())||et(n,(e=>{d.set(e.getKey(),e)}))}const f=Array.from(d.values());return x()||(this._cachedNodes=f),f}getTextContent(){const e=this.getNodes().filter((e=>fe(e)));let t="";for(let n=0;n<e.length;n++){const o=e[n],r=o.__parent,l=(e[n+1]||{}).__parent;t+=o.getTextContent()+(l!==r?"\n":"\t")}return t}}function Ge(e){return e instanceof Ve}function Qe(){const e=b("root",0,"element"),t=b("root",0,"element");return new Ve("root",e,t)}function Ze(e,t,n){e.getKey(),t.getKey(),n.getKey();const o=_(),r=Ge(o)?o.clone():Qe();return r.set(e.getKey(),t.getKey(),n.getKey()),r}function et(e,t){const n=[[e]];for(let e=n.at(-1);void 0!==e&&n.length>0;e=n.at(-1)){const o=e.pop();void 0===o?n.pop():!1!==t(o)&&g(o)&&n.push(o.getChildren())}}function tt(e,t=F()){const n=T(e);Yt(n)||Ce(231,e);const o=lt(n,t.getElementByKey(e));return null===o&&Ce(232,e),{tableElement:o,tableNode:n}}class nt{constructor(e,t){this.isHighlightingCells=!1,this.anchorX=-1,this.anchorY=-1,this.focusX=-1,this.focusY=-1,this.listenersToRemove=new Set,this.tableNodeKey=t,this.editor=e,this.table={columns:0,domRows:[],rows:0},this.tableSelection=null,this.anchorCellNodeKey=null,this.focusCellNodeKey=null,this.anchorCell=null,this.focusCell=null,this.hasHijackedSelectionStyles=!1,this.isSelecting=!1,this.shouldCheckSelection=!1,this.abortController=new AbortController,this.listenerOptions={signal:this.abortController.signal},this.nextFocus=null,this.trackTable()}getTable(){return this.table}removeListeners(){this.abortController.abort("removeListeners"),Array.from(this.listenersToRemove).forEach((e=>e())),this.listenersToRemove.clear()}$lookup(){return tt(this.tableNodeKey,this.editor)}trackTable(){const e=new MutationObserver((e=>{this.editor.getEditorState().read((()=>{let t=!1;for(let n=0;n<e.length;n++){const o=e[n].target.nodeName;if("TABLE"===o||"TBODY"===o||"THEAD"===o||"TR"===o){t=!0;break}}if(!t)return;const{tableNode:n,tableElement:o}=this.$lookup();this.table=ft(n,o)}),{editor:this.editor})}));this.editor.getEditorState().read((()=>{const{tableNode:t,tableElement:n}=this.$lookup();this.table=ft(t,n),e.observe(n,{attributes:!0,childList:!0,subtree:!0})}),{editor:this.editor})}$clearHighlight(){const e=this.editor;this.isHighlightingCells=!1,this.anchorX=-1,this.anchorY=-1,this.focusX=-1,this.focusY=-1,this.tableSelection=null,this.anchorCellNodeKey=null,this.focusCellNodeKey=null,this.anchorCell=null,this.focusCell=null,this.hasHijackedSelectionStyles=!1,this.$enableHighlightStyle();const{tableNode:t,tableElement:n}=this.$lookup();mt(e,ft(t,n),null),null!==_()&&(R(null),e.dispatchCommand(O,void 0))}$enableHighlightStyle(){const e=this.editor,{tableElement:t}=this.$lookup();o(t,e._config.theme.tableSelection),t.classList.remove("disable-selection"),this.hasHijackedSelectionStyles=!1}$disableHighlightStyle(){const{tableElement:t}=this.$lookup();e(t,this.editor._config.theme.tableSelection),this.hasHijackedSelectionStyles=!0}$updateTableTableSelection(e){if(null!==e){e.tableKey!==this.tableNodeKey&&Ce(233,e.tableKey,this.tableNodeKey);const t=this.editor;this.tableSelection=e,this.isHighlightingCells=!0,this.$disableHighlightStyle(),this.updateDOMSelection(),mt(t,this.table,this.tableSelection)}else this.$clearHighlight()}setShouldCheckSelection(){this.shouldCheckSelection=!0}getAndClearShouldCheckSelection(){return!!this.shouldCheckSelection&&(this.shouldCheckSelection=!1,!0)}setNextFocus(e){this.nextFocus=e}getAndClearNextFocus(){const{nextFocus:e}=this;return null!==e&&(this.nextFocus=null),e}updateDOMSelection(){if(null!==this.anchorCell&&null!==this.focusCell){const e=A(this.editor._window);e&&e.rangeCount>0&&e.removeAllRanges()}}$setFocusCellForSelection(e,t=!1){const n=this.editor,{tableNode:o}=this.$lookup(),r=e.x,l=e.y;if(this.focusCell=e,this.isHighlightingCells||this.anchorX===r&&this.anchorY===l&&!t){if(r===this.focusX&&l===this.focusY)return!1}else this.isHighlightingCells=!0,this.$disableHighlightStyle();if(this.focusX=r,this.focusY=l,this.isHighlightingCells){const t=Mt(o,e.elem);if(null!=this.tableSelection&&null!=this.anchorCellNodeKey&&null!==t)return this.focusCellNodeKey=t.getKey(),this.tableSelection=Ze(o,this.$getAnchorTableCellOrThrow(),t),R(this.tableSelection),n.dispatchCommand(O,void 0),mt(n,this.table,this.tableSelection),!0}return!1}$getAnchorTableCell(){return this.anchorCellNodeKey?T(this.anchorCellNodeKey):null}$getAnchorTableCellOrThrow(){const e=this.$getAnchorTableCell();return null===e&&Ce(234),e}$getFocusTableCell(){return this.focusCellNodeKey?T(this.focusCellNodeKey):null}$getFocusTableCellOrThrow(){const e=this.$getFocusTableCell();return null===e&&Ce(235),e}$setAnchorCellForSelection(e){this.isHighlightingCells=!1,this.anchorCell=e,this.anchorX=e.x,this.anchorY=e.y;const{tableNode:t}=this.$lookup(),n=Mt(t,e.elem);if(null!==n){const e=n.getKey();this.tableSelection=null!=this.tableSelection?this.tableSelection.clone():Qe(),this.anchorCellNodeKey=e}}$formatCells(e){const t=_();Ge(t)||Ce(236);const n=k(),o=n.anchor,r=n.focus,l=t.getNodes().filter(fe);l.length>0||Ce(237);const s=l[0].getFirstChild(),i=y(s)?s.getFormatFlags(e,null):null;l.forEach((t=>{o.set(t.getKey(),0,"element"),r.set(t.getKey(),t.getChildrenSize(),"element"),n.formatText(e,i)})),R(t),this.editor.dispatchCommand(O,void 0)}$clearText(){const{editor:e}=this,t=T(this.tableNodeKey);if(!Yt(t))throw new Error("Expected TableNode.");const n=_();Ge(n)||Ce(253);const o=n.getNodes().filter(fe);if(o.length===this.table.columns*this.table.rows)return t.selectPrevious(),void t.remove();o.forEach((e=>{if(g(e)){const t=d(),n=S();t.append(n),e.append(t),e.getChildren().forEach((e=>{e!==t&&e.remove()}))}})),mt(e,this.table,null),R(null),e.dispatchCommand(O,void 0)}}const ot="__lexicalTableSelection",rt=e=>!(1&~e.buttons);function lt(e,t){if(!t)return t;const n="TABLE"===t.nodeName?t:e.getDOMSlot(t).element;return"TABLE"!==n.nodeName&&Ce(245,t.nodeName),n}function st(e){return e._window}function it(e,t){for(let n=t,o=null;null!==n;n=n.getParent()){if(e.is(n))return o;fe(n)&&(o=n)}return null}const ct=[[X,"down"],[j,"up"],[V,"backward"],[G,"forward"]],at=[Q,Z,ee],ut=[te,ne];function ht(e,t,o,l){const s=o.getRootElement(),i=st(o);null!==s&&null!==i||Ce(246);const c=new nt(o,e.getKey()),a=lt(e,t);!function(e,t){null!==dt(e)&&Ce(205);e[ot]=t}(a,c),c.listenersToRemove.add((()=>function(e,t){dt(e)===t&&delete e[ot]}(a,c)));a.addEventListener("mousedown",(t=>{if(0!==t.button||!oe(t.target)||!i)return;const n=gt(t.target);null!==n&&o.update((()=>{const o=z();if(xe&&t.shiftKey&&Nt(o,e)&&(w(o)||Ge(o))){const r=o.anchor.getNode(),l=it(e,o.anchor.getNode());if(l)c.$setAnchorCellForSelection(Et(c,l)),c.$setFocusCellForSelection(n),At(t);else{(e.isBefore(r)?e.selectStart():e.selectEnd()).anchor.set(o.anchor.key,o.anchor.offset,o.anchor.type)}}else c.$setAnchorCellForSelection(n)})),(()=>{if(c.isSelecting)return;const e=()=>{c.isSelecting=!1,i.removeEventListener("mouseup",e),i.removeEventListener("mousemove",t)},t=n=>{if(!oe(n.target))return;if(!rt(n)&&c.isSelecting)return c.isSelecting=!1,i.removeEventListener("mouseup",e),void i.removeEventListener("mousemove",t);const r=!a.contains(n.target);let l=null;if(r){for(const e of document.elementsFromPoint(n.clientX,n.clientY))if(l=a.contains(e)?gt(e):null,l)break}else l=gt(n.target);!l||null!==c.focusCell&&l.elem===c.focusCell.elem||(c.setNextFocus({focusCell:l,override:r}),o.dispatchCommand(O,void 0))};c.isSelecting=!0,i.addEventListener("mouseup",e,c.listenerOptions),i.addEventListener("mousemove",t,c.listenerOptions)})()}),c.listenerOptions);i.addEventListener("mousedown",(e=>{const t=e.target;0===e.button&&oe(t)&&o.update((()=>{const e=_();Ge(e)&&e.tableKey===c.tableNodeKey&&s.contains(t)&&c.$clearHighlight()}))}),c.listenerOptions);for(const[t,n]of ct)c.listenersToRemove.add(o.registerCommand(t,(t=>Ot(o,t,n,e,c)),K));c.listenersToRemove.add(o.registerCommand(E,(t=>{const n=_();if(Ge(n)){const o=it(e,n.focus.getNode());if(null!==o)return At(t),o.selectEnd(),!0}return!1}),K));const u=t=>()=>{const o=_();if(!Nt(o,e))return!1;if(Ge(o))return c.$clearText(),!0;if(w(o)){if(!fe(it(e,o.anchor.getNode())))return!1;const r=o.anchor.getNode(),l=o.focus.getNode(),s=e.isParentOf(r),i=e.isParentOf(l);if(s&&!i||i&&!s)return c.$clearText(),!0;const a=n(o.anchor.getNode(),(e=>g(e))),u=a&&n(a,(e=>g(e)&&fe(e.getParent())));if(!g(u)||!g(a))return!1;if(t===Z&&null===u.getPreviousSibling())return!0}return!1};for(const e of at)c.listenersToRemove.add(o.registerCommand(e,u(e),M));const h=t=>{const n=_();if(!Ge(n)&&!w(n))return!1;const o=e.isParentOf(n.anchor.getNode());if(o!==e.isParentOf(n.focus.getNode())){const t=o?"anchor":"focus",r=o?"focus":"anchor",{key:l,offset:s,type:i}=n[r];return e[n[t].isBefore(n[r])?"selectPrevious":"selectNext"]()[r].set(l,s,i),!1}return!!Nt(n,e)&&(!!Ge(n)&&(t&&(t.preventDefault(),t.stopPropagation()),c.$clearText(),!0))};for(const e of ut)c.listenersToRemove.add(o.registerCommand(e,h,M));return c.listenersToRemove.add(o.registerCommand($,(e=>{const t=_();if(t){if(!Ge(t)&&!w(t))return!1;se(o,r(e,ClipboardEvent)?e:null,ie(t));const n=h(e);return w(t)?(t.removeText(),!0):n}return!1}),M)),c.listenersToRemove.add(o.registerCommand(L,(t=>{const o=_();if(!Nt(o,e))return!1;if(Ge(o))return c.$formatCells(t),!0;if(w(o)){const e=n(o.anchor.getNode(),(e=>fe(e)));if(!fe(e))return!1}return!1}),M)),c.listenersToRemove.add(o.registerCommand(W,(t=>{const n=_();if(!Ge(n)||!Nt(n,e))return!1;const o=n.anchor.getNode(),r=n.focus.getNode();if(!fe(o)||!fe(r))return!1;if(function(e,t){if(Ge(e)){const n=e.anchor.getNode(),o=e.focus.getNode();if(t&&n&&o){const[e]=Ue(t,n,o);return n.getKey()===e[0][0].cell.getKey()&&o.getKey()===e[e.length-1].at(-1).cell.getKey()}}return!1}(n,e))return e.setFormat(t),!0;const[l,s,i]=Ue(e,o,r),c=Math.max(s.startRow+s.cell.__rowSpan-1,i.startRow+i.cell.__rowSpan-1),a=Math.max(s.startColumn+s.cell.__colSpan-1,i.startColumn+i.cell.__colSpan-1),u=Math.min(s.startRow,i.startRow),h=Math.min(s.startColumn,i.startColumn),d=new Set;for(let e=u;e<=c;e++)for(let n=h;n<=a;n++){const o=l[e][n].cell;if(d.has(o))continue;d.add(o),o.setFormat(t);const r=o.getChildren();for(let e=0;e<r.length;e++){const n=r[e];g(n)&&!n.isInline()&&n.setFormat(t)}}return!0}),M)),c.listenersToRemove.add(o.registerCommand(H,(t=>{const r=_();if(!Nt(r,e))return!1;if(Ge(r))return c.$clearHighlight(),!1;if(w(r)){const l=n(r.anchor.getNode(),(e=>fe(e)));if(!fe(l))return!1;if("string"==typeof t){const n=Kt(o,r,e);if(n)return kt(n,e,[S(t)]),!0}}return!1}),M)),l&&c.listenersToRemove.add(o.registerCommand(P,(t=>{const o=_();if(!w(o)||!o.isCollapsed()||!Nt(o,e))return!1;const r=Ft(o.anchor.getNode());return!(null===r||!e.is(Rt(r)))&&(At(t),function(e,t){const o="next"===t?"getNextSibling":"getPreviousSibling",r="next"===t?"getFirstChild":"getLastChild",l=e[o]();if(g(l))return l.selectEnd();const s=n(e,be);null===s&&Ce(247);for(let e=s[o]();be(e);e=e[o]()){const t=e[r]();if(g(t))return t.selectEnd()}const i=n(s,Yt);null===i&&Ce(248);"next"===t?i.selectNext():i.selectPrevious()}(r,t.shiftKey?"previous":"next"),!0)}),M)),c.listenersToRemove.add(o.registerCommand(B,(t=>e.isSelected()),K)),c.listenersToRemove.add(o.registerCommand(D,(e=>{const{nodes:t,selection:o}=e,r=o.getStartEndPoints(),l=Ge(o),s=w(o)&&null!==n(o.anchor.getNode(),(e=>fe(e)))&&null!==n(o.focus.getNode(),(e=>fe(e)))||l;if(1!==t.length||!Yt(t[0])||!s||null===r)return!1;const[i]=r,c=t[0],a=c.getChildren(),u=c.getFirstChildOrThrow().getChildrenSize(),h=c.getChildrenSize(),g=n(i.getNode(),(e=>fe(e))),f=g&&n(g,(e=>be(e))),p=f&&n(f,(e=>Yt(e)));if(!fe(g)||!be(f)||!Yt(p))return!1;const C=f.getIndexWithinParent(),S=Math.min(p.getChildrenSize()-1,C+h-1),_=g.getIndexWithinParent(),b=Math.min(f.getChildrenSize()-1,_+u-1),y=Math.min(_,b),N=Math.min(C,S),x=Math.max(_,b),v=Math.max(C,S),T=p.getChildren();let F=0;for(let e=N;e<=v;e++){const t=T[e];if(!be(t))return!1;const n=a[F];if(!be(n))return!1;const o=t.getChildren(),r=n.getChildren();let l=0;for(let e=y;e<=x;e++){const t=o[e];if(!fe(t))return!1;const n=r[l];if(!fe(n))return!1;const s=t.getChildren();n.getChildren().forEach((e=>{if(m(e)){d().append(e),t.append(e)}else t.append(e)})),s.forEach((e=>e.remove())),l++}F++}return!0}),M)),c.listenersToRemove.add(o.registerCommand(O,(()=>{const t=_(),r=z(),l=c.getAndClearNextFocus();if(null!==l){const{focusCell:n}=l;if(Ge(t)&&t.tableKey===c.tableNodeKey)return(n.x!==c.focusX||n.y!==c.focusY)&&(c.$setFocusCellForSelection(n),!0);if(n!==c.anchorCell&&Nt(t,e))return c.$setFocusCellForSelection(n),!0}if(c.getAndClearShouldCheckSelection()&&w(r)&&w(t)&&t.isCollapsed()){const o=t.anchor.getNode(),r=e.getFirstChild(),l=Ft(o);if(null!==l&&be(r)){const t=r.getFirstChild();if(fe(t)&&e.is(n(l,(n=>n.is(e)||n.is(t)))))return t.selectStart(),!0}}if(w(t)){const{anchor:n,focus:r}=t,l=n.getNode(),s=r.getNode(),i=Ft(l),a=Ft(s),u=!(!i||!e.is(Rt(i))),h=!(!a||!e.is(Rt(a))),d=u!==h,g=u&&h,f=t.isBackward();if(d){const n=t.clone();if(h){const[t]=Ue(e,a,a),o=t[0][0].cell,r=t[t.length-1].at(-1).cell;n.focus.set(f?o.getKey():r.getKey(),f?o.getChildrenSize():r.getChildrenSize(),"element")}else if(u){const[t]=Ue(e,i,i),o=t[0][0].cell,r=t[t.length-1].at(-1).cell;n.anchor.set(f?r.getKey():o.getKey(),f?r.getChildrenSize():0,"element")}R(n),Ct(o,c)}else g&&(i.is(a)||(c.$setAnchorCellForSelection(Et(c,i)),c.$setFocusCellForSelection(Et(c,a),!0)))}else if(t&&Ge(t)&&t.is(r)&&t.tableKey===e.getKey()){const n=A(i);if(n&&n.anchorNode&&n.focusNode){const r=I(n.focusNode),l=r&&!e.isParentOf(r),s=I(n.anchorNode),i=s&&e.isParentOf(s);if(l&&i&&n.rangeCount>0){const r=U(n,o);r&&(r.anchor.set(e.getKey(),t.isBackward()?e.getChildrenSize():0,"element"),n.removeAllRanges(),R(r))}}}return t&&!t.is(r)&&(Ge(t)||Ge(r))&&c.tableSelection&&!c.tableSelection.is(r)?(Ge(t)&&t.tableKey===c.tableNodeKey?c.$updateTableTableSelection(t):!Ge(t)&&Ge(r)&&r.tableKey===c.tableNodeKey&&c.$updateTableTableSelection(null),!1):(c.hasHijackedSelectionStyles&&!e.isSelected()?function(e,t){t.$enableHighlightStyle(),pt(t.table,(t=>{const n=t.elem;t.highlighted=!1,Tt(e,t),n.getAttribute("style")||n.removeAttribute("style")}))}(o,c):!c.hasHijackedSelectionStyles&&e.isSelected()&&Ct(o,c),!1)}),M)),c.listenersToRemove.add(o.registerCommand(J,(()=>{const t=_();if(!w(t)||!t.isCollapsed()||!Nt(t,e))return!1;const n=Kt(o,t,e);return!!n&&(kt(n,e),!0)}),M)),c}function dt(e){return e[ot]||null}function gt(e){let t=e;for(;null!=t;){const e=t.nodeName;if("TD"===e||"TH"===e){const e=t._cell;return void 0===e?null:e}t=t.parentNode}return null}function ft(e,t){const n=[],o={columns:0,domRows:n,rows:0};let r=lt(e,t).querySelector("tr"),l=0,s=0;for(n.length=0;null!=r;){const e=r.nodeName;if("TD"===e||"TH"===e){const e={elem:r,hasBackgroundColor:""!==r.style.backgroundColor,highlighted:!1,x:l,y:s};r._cell=e;let t=n[s];void 0===t&&(t=n[s]=[]),t[l]=e}else{const e=r.firstChild;if(null!=e){r=e;continue}}const t=r.nextSibling;if(null!=t){l++,r=t;continue}const o=r.parentNode;if(null!=o){const e=o.nextSibling;if(null==e)break;s++,l=0,r=e}}return o.columns=l+1,o.rows=s+1,o}function mt(e,t,n){const o=new Set(n?n.getNodes():[]);pt(t,((t,n)=>{const r=t.elem;o.has(n)?(t.highlighted=!0,vt(e,t)):(t.highlighted=!1,Tt(e,t),r.getAttribute("style")||r.removeAttribute("style"))}))}function pt(e,t){const{domRows:n}=e;for(let e=0;e<n.length;e++){const o=n[e];if(o)for(let n=0;n<o.length;n++){const r=o[n];if(!r)continue;const l=I(r.elem);null!==l&&t(r,l,{x:n,y:e})}}}function Ct(e,t){t.$disableHighlightStyle(),pt(t.table,(t=>{t.highlighted=!0,vt(e,t)}))}const St=(e,t,n,o,r)=>{const l="forward"===r;switch(r){case"backward":case"forward":return n!==(l?e.table.columns-1:0)?xt(t.getCellNodeFromCordsOrThrow(n+(l?1:-1),o,e.table),l):o!==(l?e.table.rows-1:0)?xt(t.getCellNodeFromCordsOrThrow(l?0:e.table.columns-1,o+(l?1:-1),e.table),l):l?t.selectNext():t.selectPrevious(),!0;case"up":return 0!==o?xt(t.getCellNodeFromCordsOrThrow(n,o-1,e.table),!1):t.selectPrevious(),!0;case"down":return o!==e.table.rows-1?xt(t.getCellNodeFromCordsOrThrow(n,o+1,e.table),!0):t.selectNext(),!0;default:return!1}};function _t(e,t){let n,o;if(t.startColumn===e.minColumn)n="minColumn";else{if(t.startColumn+t.cell.__colSpan-1!==e.maxColumn)return null;n="maxColumn"}if(t.startRow===e.minRow)o="minRow";else{if(t.startRow+t.cell.__rowSpan-1!==e.maxRow)return null;o="maxRow"}return[n,o]}function wt([e,t]){return["minColumn"===e?"maxColumn":"minColumn","minRow"===t?"maxRow":"minRow"]}function bt(e,t,[n,o]){const r=t[o],l=e[r];void 0===l&&Ce(250,o,String(r));const s=t[n],i=l[s];return void 0===i&&Ce(250,n,String(s)),i}function yt(e,t,n,o,r){const l=qe(t,n,o),s=function(e,t){const{minColumn:n,maxColumn:o,minRow:r,maxRow:l}=t;let s=1,i=1,c=1,a=1;const u=e[r],h=e[l];for(let e=n;e<=o;e++)s=Math.max(s,u[e].cell.__rowSpan),a=Math.max(a,h[e].cell.__rowSpan);for(let t=r;t<=l;t++)i=Math.max(i,e[t][n].cell.__colSpan),c=Math.max(c,e[t][o].cell.__colSpan);return{bottomSpan:a,leftSpan:i,rightSpan:c,topSpan:s}}(t,l),{topSpan:i,leftSpan:c,bottomSpan:a,rightSpan:u}=s,h=function(e,t){const n=_t(e,t);return null===n&&Ce(249,t.cell.getKey()),n}(l,n),[d,g]=wt(h);let f=l[d],m=l[g];"forward"===r?f+="maxColumn"===d?1:c:"backward"===r?f-="minColumn"===d?1:u:"down"===r?m+="maxRow"===g?1:i:"up"===r&&(m-="minRow"===g?1:a);const p=t[m];if(void 0===p)return!1;const C=p[f];if(void 0===C)return!1;const[S,_]=function(e,t,n){const o=qe(e,t,n),r=_t(o,t);if(r)return[bt(e,o,r),bt(e,o,wt(r))];const l=_t(o,n);if(l)return[bt(e,o,wt(l)),bt(e,o,l)];const s=["minColumn","minRow"];return[bt(e,o,s),bt(e,o,wt(s))]}(t,n,C),w=Et(e,S.cell),b=Et(e,_.cell);return e.$setAnchorCellForSelection(w),e.$setFocusCellForSelection(b,!0),!0}function Nt(e,t){if(w(e)||Ge(e)){const n=t.isParentOf(e.anchor.getNode()),o=t.isParentOf(e.focus.getNode());return n&&o}return!1}function xt(e,t){t?e.selectStart():e.selectEnd()}function vt(t,n){const o=n.elem,r=t._config.theme;fe(I(o))||Ce(131),e(o,r.tableCellSelected)}function Tt(e,t){const n=t.elem;fe(I(n))||Ce(131);const r=e._config.theme;o(n,r.tableCellSelected)}function Ft(e){const t=n(e,fe);return fe(t)?t:null}function Rt(e){const t=n(e,Yt);return Yt(t)?t:null}function Ot(e,t,o,r,l){if(("up"===o||"down"===o)&&function(e){const t=e.getRootElement();if(!t)return!1;return t.hasAttribute("aria-controls")&&"typeahead-menu"===t.getAttribute("aria-controls")}(e))return!1;const s=_();if(!Nt(s,r)){if(w(s)){if("backward"===o){if(s.focus.offset>0)return!1;const e=function(e){for(let t=e,n=e;null!==n;t=n,n=n.getParent())if(g(n)){if(n!==t&&n.getFirstChild()!==t)return null;if(!n.isInline())return n}return null}(s.focus.getNode());if(!e)return!1;const n=e.getPreviousSibling();return!!Yt(n)&&(At(t),t.shiftKey?s.focus.set(n.getParentOrThrow().getKey(),n.getIndexWithinParent(),"element"):n.selectEnd(),!0)}if(t.shiftKey&&("up"===o||"down"===o)){const e=s.focus.getNode();if(!s.isCollapsed()&&("up"===o&&!s.isBackward()||"down"===o&&s.isBackward())){let l=n(e,(e=>Yt(e)));if(fe(l)&&(l=n(l,Yt)),l!==r)return!1;if(!l)return!1;const i="down"===o?l.getNextSibling():l.getPreviousSibling();if(!i)return!1;let c=0;"up"===o&&g(i)&&(c=i.getChildrenSize());let a=i;if("up"===o&&g(i)){const e=i.getLastChild();a=e||i,c=m(a)?a.getTextContentSize():0}const u=s.clone();return u.focus.set(a.getKey(),c,m(a)?"text":"element"),R(u),At(t),!0}if(Y(e)){const e="up"===o?s.getNodes()[s.getNodes().length-1]:s.getNodes()[0];if(e){if(null!==it(r,e)){const e=r.getFirstDescendant(),t=r.getLastDescendant();if(!e||!t)return!1;const[n]=Ye(e),[o]=Ye(t),s=r.getCordsFromCellNode(n,l.table),i=r.getCordsFromCellNode(o,l.table),c=r.getDOMCellFromCordsOrThrow(s.x,s.y,l.table),a=r.getDOMCellFromCordsOrThrow(i.x,i.y,l.table);return l.$setAnchorCellForSelection(c),l.$setFocusCellForSelection(a,!0),!0}}return!1}{let r=n(e,(e=>g(e)&&!e.isInline()));if(fe(r)&&(r=n(r,Yt)),!r)return!1;const i="down"===o?r.getNextSibling():r.getPreviousSibling();if(Yt(i)&&l.tableNodeKey===i.getKey()){const e=i.getFirstDescendant(),n=i.getLastDescendant();if(!e||!n)return!1;const[r]=Ye(e),[l]=Ye(n),c=s.clone();return c.focus.set(("up"===o?r:l).getKey(),"up"===o?0:l.getChildrenSize(),"element"),At(t),R(c),!0}}}}return"down"===o&&Bt(e)&&l.setShouldCheckSelection(),!1}if(w(s)&&s.isCollapsed()){const{anchor:i,focus:c}=s,a=n(i.getNode(),fe),u=n(c.getNode(),fe);if(!fe(a)||!a.is(u))return!1;const h=Rt(a);if(h!==r&&null!=h){const n=lt(h,e.getElementByKey(h.getKey()));if(null!=n)return l.table=ft(h,n),Ot(e,t,o,h,l)}if("backward"===o||"forward"===o){const e=i.type,l=i.offset,c=i.getNode();if(!c)return!1;const u=s.getNodes();return(1!==u.length||!q(u[0]))&&(!!function(e,t,o,r){return function(e,t,n){return"element"===e&&("backward"===n?null===t.getPreviousSibling():null===t.getNextSibling())}(e,o,r)||function(e,t,o,r){const l=n(o,(e=>g(e)&&!e.isInline()));if(!l)return!1;const s="backward"===r?0===t:t===o.getTextContentSize();return"text"===e&&s&&("backward"===r?null===l.getPreviousSibling():null===l.getNextSibling())}(e,t,o,r)}(e,l,c,o)&&function(e,t,o,r,l){const[s,i]=Ue(r,o,o);if(!function(e,t,n){const o=e[0][0],r=e[e.length-1][e[0].length-1],{startColumn:l,startRow:s}=t;return"backward"===n?l===o.startColumn&&s===o.startRow:l===r.startColumn&&s===r.startRow}(s,i,l))return!1;const c=function(e,t,o){const r=n(e,(e=>g(e)&&!e.isInline()));if(!r)return;const l="backward"===t?r.getPreviousSibling():r.getNextSibling();return l&&Yt(l)?l:"backward"===t?o.getPreviousSibling():o.getNextSibling()}(t,l,r);if(!c||Yt(c))return!1;At(e),"backward"===l?c.selectEnd():c.selectStart();return!0}(t,c,a,r,o))}const d=e.getElementByKey(a.__key),f=e.getElementByKey(i.key);if(null==f||null==d)return!1;let m;if("element"===i.type)m=f.getBoundingClientRect();else{const t=A(st(e));if(null===t||0===t.rangeCount)return!1;m=t.getRangeAt(0).getBoundingClientRect()}const p="up"===o?a.getFirstChild():a.getLastChild();if(null==p)return!1;const C=e.getElementByKey(p.__key);if(null==C)return!1;const S=C.getBoundingClientRect();if("up"===o?S.top>m.top-m.height:m.bottom+m.height>S.bottom){At(t);const e=r.getCordsFromCellNode(a,l.table);if(!t.shiftKey)return St(l,r,e.x,e.y,o);{const t=r.getDOMCellFromCordsOrThrow(e.x,e.y,l.table);l.$setAnchorCellForSelection(t),l.$setFocusCellForSelection(t,!0)}return!0}}else if(Ge(s)){const{anchor:i,focus:c}=s,a=n(i.getNode(),fe),u=n(c.getNode(),fe),[h]=s.getNodes();Yt(h)||Ce(251);const d=lt(h,e.getElementByKey(h.getKey()));if(!fe(a)||!fe(u)||!Yt(h)||null==d)return!1;l.$updateTableTableSelection(s);const g=ft(h,d),f=r.getCordsFromCellNode(a,g),m=r.getDOMCellFromCordsOrThrow(f.x,f.y,g);if(l.$setAnchorCellForSelection(m),At(t),t.shiftKey){const[e,t,n]=Ue(r,a,u);return yt(l,e,t,n,o)}return u.selectEnd(),!0}return!1}function At(e){e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation()}function kt(e,t,n){const o=d();"first"===e?t.insertBefore(o):t.insertAfter(o),o.append(...n||[]),o.selectEnd()}function Kt(e,t,o){const r=o.getParent();if(!r)return;const l=A(st(e));if(!l)return;const s=l.anchorNode,i=e.getElementByKey(r.getKey()),c=lt(o,e.getElementByKey(o.getKey()));if(!s||!i||!c||!i.contains(s)||c.contains(s))return;const a=n(t.anchor.getNode(),(e=>fe(e)));if(!a)return;const u=n(a,(e=>Yt(e)));if(!Yt(u)||!u.is(o))return;const[h,d]=Ue(o,a,a),g=h[0][0],f=h[h.length-1][h[0].length-1],{startRow:m,startColumn:p}=d,C=m===g.startRow&&p===g.startColumn,S=m===f.startRow&&p===f.startColumn;return C?"first":S?"last":void 0}function Et(e,t){const{tableNode:n}=e.$lookup(),o=n.getCordsFromCellNode(t,e.table);return n.getDOMCellFromCordsOrThrow(o.x,o.y,e.table)}function Mt(e,t,n){return it(e,I(t,n))}function $t(e,t,n,o){const r=e.querySelector("colgroup");if(!r)return;const l=[];for(let e=0;e<n;e++){const t=document.createElement("col"),n=o&&o[e];n&&(t.style.width=`${n}px`),l.push(t)}r.replaceChildren(...l)}function Lt(t,n,r){r?(e(t,n.theme.tableRowStriping),t.setAttribute("data-lexical-row-striping","true")):(o(t,n.theme.tableRowStriping),t.removeAttribute("data-lexical-row-striping"))}function Wt(t,n,r){r>0?(e(t,n.theme.tableFrozenColumn),t.setAttribute("data-lexical-frozen-column","true")):(o(t,n.theme.tableFrozenColumn),t.removeAttribute("data-lexical-frozen-column"))}function Ht(t,n,r){if(!n.theme.tableAlignment)return;const l=[],s=[];for(const e of["center","right"]){const t=n.theme.tableAlignment[e];t&&(e===r?s:l).push(t)}o(t,...l),e(t,...s)}const Pt=new WeakSet;function Bt(e=F()){return Pt.has(e)}function Dt(e,t){t?Pt.add(e):Pt.delete(e)}class zt extends u{static getType(){return"table"}getColWidths(){return this.getLatest().__colWidths}setColWidths(e){const t=this.getWritable();return t.__colWidths=e,t}static clone(e){return new zt(e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__colWidths=e.__colWidths,this.__rowStriping=e.__rowStriping,this.__frozenColumnCount=e.__frozenColumnCount}static importDOM(){return{table:e=>({conversion:Ut,priority:1})}}static importJSON(e){return Jt().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setRowStriping(e.rowStriping||!1).setFrozenColumns(e.frozenColumnCount||0).setColWidths(e.colWidths)}constructor(e){super(e),this.__rowStriping=!1,this.__frozenColumnCount=0}exportJSON(){return{...super.exportJSON(),colWidths:this.getColWidths(),frozenColumnCount:this.__frozenColumnCount?this.__frozenColumnCount:void 0,rowStriping:this.__rowStriping?this.__rowStriping:void 0}}extractWithChild(e,t,n){return"html"===n}getDOMSlot(e){const t="TABLE"!==e.nodeName&&e.querySelector("table")||e;return"TABLE"!==t.nodeName&&Ce(229),super.getDOMSlot(t).withAfter(t.querySelector("colgroup"))}createDOM(t,n){const o=document.createElement("table"),r=document.createElement("colgroup");if(o.appendChild(r),$t(o,0,this.getColumnCount(),this.getColWidths()),re(r),e(o,t.theme.table),Ht(o,t,this.getFormatType()),this.__frozenColumnCount&&Wt(o,t,this.__frozenColumnCount),this.__rowStriping&&Lt(o,t,!0),Bt(n)){const n=document.createElement("div"),r=t.theme.tableScrollableWrapper;return r?e(n,r):n.style.cssText="overflow-x: auto;",n.appendChild(o),n}return o}updateDOM(e,t,n){return e.__rowStriping!==this.__rowStriping&&Lt(t,n,this.__rowStriping),e.__frozenColumnCount!==this.__frozenColumnCount&&Wt(t,n,this.__frozenColumnCount),$t(t,0,this.getColumnCount(),this.getColWidths()),Ht(this.getDOMSlot(t).element,n,this.getFormatType()),!1}exportDOM(e){const t=super.exportDOM(e),{element:n}=t;return{after:n=>{if(t.after&&(n=t.after(n),this.__format&&Ht(n,e._config,this.getFormatType())),l(n)&&"TABLE"!==n.nodeName&&(n=n.querySelector("table")),!l(n))return null;const[o]=Je(this,null,null),r=new Map;for(const e of o)for(const t of e){const e=t.cell.getKey();r.has(e)||r.set(e,{colSpan:t.cell.getColSpan(),startColumn:t.startColumn})}const s=new Set;for(const e of n.querySelectorAll(":scope > tr > [data-temporary-table-cell-lexical-key]")){const t=e.getAttribute("data-temporary-table-cell-lexical-key");if(t){const n=r.get(t);if(e.removeAttribute("data-temporary-table-cell-lexical-key"),n){r.delete(t);for(let e=0;e<n.colSpan;e++)s.add(e+n.startColumn)}}}const i=n.querySelector(":scope > colgroup");if(i){const e=Array.from(n.querySelectorAll(":scope > colgroup > col")).filter(((e,t)=>s.has(t)));i.replaceChildren(...e)}const c=n.querySelectorAll(":scope > tr");if(c.length>0){const e=document.createElement("tbody");for(const t of c)e.appendChild(t);n.append(e)}return n},element:l(n)&&"TABLE"!==n.nodeName?n.querySelector("table"):n}}canBeEmpty(){return!1}isShadowRoot(){return!0}getCordsFromCellNode(e,t){const{rows:n,domRows:o}=t;for(let t=0;t<n;t++){const n=o[t];if(null!=n)for(let o=0;o<n.length;o++){const r=n[o];if(null==r)continue;const{elem:l}=r,s=Mt(this,l);if(null!==s&&e.is(s))return{x:o,y:t}}}throw new Error("Cell not found in table.")}getDOMCellFromCords(e,t,n){const{domRows:o}=n,r=o[t];if(null==r)return null;const l=r[e<r.length?e:r.length-1];return null==l?null:l}getDOMCellFromCordsOrThrow(e,t,n){const o=this.getDOMCellFromCords(e,t,n);if(!o)throw new Error("Cell not found at cords.");return o}getCellNodeFromCords(e,t,n){const o=this.getDOMCellFromCords(e,t,n);if(null==o)return null;const r=I(o.elem);return fe(r)?r:null}getCellNodeFromCordsOrThrow(e,t,n){const o=this.getCellNodeFromCords(e,t,n);if(!o)throw new Error("Node at cords not TableCellNode.");return o}getRowStriping(){return Boolean(this.getLatest().__rowStriping)}setRowStriping(e){const t=this.getWritable();return t.__rowStriping=e,t}setFrozenColumns(e){const t=this.getWritable();return t.__frozenColumnCount=e,t}getFrozenColumns(){return this.getLatest().__frozenColumnCount}canSelectBefore(){return!0}canIndent(){return!1}getColumnCount(){const e=this.getFirstChild();if(!e)return 0;let t=0;return e.getChildren().forEach((e=>{fe(e)&&(t+=e.getColSpan())})),t}}function It(e,t){const n=e.getElementByKey(t.getKey());return null===n&&Ce(230),ft(t,n)}function Ut(e){const n=Jt();e.hasAttribute("data-lexical-row-striping")&&n.setRowStriping(!0);const o=e.querySelector(":scope > colgroup");if(o){let e=[];for(const t of o.querySelectorAll(":scope > col")){let n=t.style.width||"";if(!ce.test(n)&&(n=t.getAttribute("width")||"",!/^\d+$/.test(n))){e=void 0;break}e.push(parseFloat(n))}e&&n.setColWidths(e)}return{after:e=>t(e,be),node:n}}function Jt(){return p(new zt)}function Yt(e){return e instanceof zt}function qt({rows:e,columns:t,includeHeaders:n}){const o=ve(Number(e),Number(t),n);c(o);const r=o.getFirstDescendant();return m(r)&&r.select(),!0}function Xt(e){be(e.getParent())?e.isEmpty()&&e.append(d()):e.remove()}function jt(e){Yt(e.getParent())?a(e,fe):e.remove()}function Vt(e){a(e,be);const[t]=Je(e,null,null),n=t.reduce(((e,t)=>Math.max(e,t.length)),0),o=e.getChildren();for(let e=0;e<t.length;++e){const r=o[e];if(!r)continue;be(r)||Ce(254,r.constructor.name,r.getType());const l=t[e].reduce(((e,t)=>t?1+e:e),0);if(l!==n)for(let e=l;e<n;++e){const e=ge();e.append(d()),r.append(e)}}}function Gt(e){return e.registerNodeTransform(ue,(e=>{if(e.getColSpan()>1||e.getRowSpan()>1){const[,,t]=Ye(e),[n]=Ue(t,e,e),o=n.length,r=n[0].length;let l=t.getFirstChild();be(l)||Ce(175);const i=[];for(let e=0;e<o;e++){0!==e&&(l=l.getNextSibling(),be(l)||Ce(175));let t=null;for(let o=0;o<r;o++){const r=n[e][o],c=r.cell;if(r.startRow===e&&r.startColumn===o)t=c,i.push(c);else if(c.getColSpan()>1||c.getRowSpan()>1){fe(c)||Ce(176);const e=ge(c.__headerState);null!==t?t.insertAfter(e):s(l,e)}}}for(const e of i)e.setColSpan(1),e.setRowSpan(1)}}))}function Qt(e,t=!0){const n=new Map,o=(o,r,l)=>{const s=lt(o,l),i=ht(o,s,e,t);n.set(r,[i,s])},r=e.registerMutationListener(zt,(t=>{e.getEditorState().read((()=>{for(const[e,r]of t){const t=n.get(e);if("created"===r||"updated"===r){const{tableNode:r,tableElement:l}=tt(e);void 0===t?o(r,e,l):l!==t[1]&&(t[0].removeListeners(),n.delete(e),o(r,e,l))}else"destroyed"===r&&void 0!==t&&(t[0].removeListeners(),n.delete(e))}}),{editor:e})}),{skipInitialization:!1});return()=>{r();for(const[,[e]]of n)e.removeListeners()}}function Zt(e){return e.hasNodes([zt])||Ce(255),i(e.registerCommand(me,qt,le),e.registerNodeTransform(zt,Vt),e.registerNodeTransform(Se,jt),e.registerNodeTransform(ue,Xt))}export{Ue as $computeTableMap,Je as $computeTableMapSkipCellCheck,ge as $createTableCellNode,Jt as $createTableNode,ve as $createTableNodeWithDimensions,we as $createTableRowNode,Qe as $createTableSelection,Ze as $createTableSelectionFrom,He as $deleteTableColumn,Be as $deleteTableColumn__EXPERIMENTAL,Pe as $deleteTableRow__EXPERIMENTAL,Ft as $findCellNode,Rt as $findTableNode,It as $getElementForTableNode,Ye as $getNodeTriplet,tt as $getTableAndElementByKey,Te as $getTableCellNodeFromLexicalNode,Xe as $getTableCellNodeRect,Ae as $getTableColumnIndexFromTableCellNode,Re as $getTableNodeFromLexicalNodeOrThrow,Oe as $getTableRowIndexFromTableCellNode,Fe as $getTableRowNodeFromTableCellNodeOrThrow,Le as $insertTableColumn,We as $insertTableColumn__EXPERIMENTAL,Ee as $insertTableRow,$e as $insertTableRow__EXPERIMENTAL,Bt as $isScrollableTablesActive,fe as $isTableCellNode,Yt as $isTableNode,be as $isTableRowNode,Ge as $isTableSelection,Ke as $removeTableRowAtIndex,Ie as $unmergeCell,me as INSERT_TABLE_COMMAND,ae as TableCellHeaderStates,ue as TableCellNode,zt as TableNode,nt as TableObserver,Se as TableRowNode,ht as applyTableHandlers,gt as getDOMCellFromTarget,lt as getTableElement,dt as getTableObserverFromTableElement,Gt as registerTableCellUnmergeTransform,Zt as registerTablePlugin,Qt as registerTableSelectionObserver,Dt as setScrollableTablesActive};
|
package/LexicalTableNode.d.ts
CHANGED
@@ -11,6 +11,7 @@ import { TableDOMCell, TableDOMTable } from './LexicalTableObserver';
|
|
11
11
|
export type SerializedTableNode = Spread<{
|
12
12
|
colWidths?: readonly number[];
|
13
13
|
rowStriping?: boolean;
|
14
|
+
frozenColumnCount?: number;
|
14
15
|
}, SerializedElementNode>;
|
15
16
|
export declare function $isScrollableTablesActive(editor?: LexicalEditor): boolean;
|
16
17
|
export declare function setScrollableTablesActive(editor: LexicalEditor, active: boolean): void;
|
@@ -18,6 +19,7 @@ export declare function setScrollableTablesActive(editor: LexicalEditor, active:
|
|
18
19
|
export declare class TableNode extends ElementNode {
|
19
20
|
/** @internal */
|
20
21
|
__rowStriping: boolean;
|
22
|
+
__frozenColumnCount: number;
|
21
23
|
__colWidths?: readonly number[];
|
22
24
|
static getType(): string;
|
23
25
|
getColWidths(): readonly number[] | undefined;
|
@@ -46,6 +48,8 @@ export declare class TableNode extends ElementNode {
|
|
46
48
|
getCellNodeFromCordsOrThrow(x: number, y: number, table: TableDOMTable): TableCellNode;
|
47
49
|
getRowStriping(): boolean;
|
48
50
|
setRowStriping(newRowStriping: boolean): this;
|
51
|
+
setFrozenColumns(columnCount: number): this;
|
52
|
+
getFrozenColumns(): number;
|
49
53
|
canSelectBefore(): true;
|
50
54
|
canIndent(): false;
|
51
55
|
getColumnCount(): number;
|
package/package.json
CHANGED
@@ -8,13 +8,13 @@
|
|
8
8
|
"table"
|
9
9
|
],
|
10
10
|
"license": "MIT",
|
11
|
-
"version": "0.24.1-nightly.
|
11
|
+
"version": "0.24.1-nightly.20250214.0",
|
12
12
|
"main": "LexicalTable.js",
|
13
13
|
"types": "index.d.ts",
|
14
14
|
"dependencies": {
|
15
|
-
"@lexical/clipboard": "0.24.1-nightly.
|
16
|
-
"@lexical/utils": "0.24.1-nightly.
|
17
|
-
"lexical": "0.24.1-nightly.
|
15
|
+
"@lexical/clipboard": "0.24.1-nightly.20250214.0",
|
16
|
+
"@lexical/utils": "0.24.1-nightly.20250214.0",
|
17
|
+
"lexical": "0.24.1-nightly.20250214.0"
|
18
18
|
},
|
19
19
|
"repository": {
|
20
20
|
"type": "git",
|