@react-fabric/lexical 1.0.0-beta.9 → 1.0.2
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/{src/editor/Lexical.module.css → css/_lexical.css} +79 -13
- package/css/styles.css +24 -0
- package/dist/cjs/{packages/lexical/src/editor → editor}/LexicalEditor.js +98 -45
- package/dist/cjs/{packages/lexical/src/hooks → hooks}/useFormatWatcher.js +147 -140
- package/dist/cjs/i18n/ar/lexical.json.js +30 -0
- package/dist/cjs/i18n/en/lexical.json.js +30 -0
- package/{src/plugins/StickyPlugin.ts → dist/cjs/i18n/index.js} +10 -15
- package/dist/cjs/index.js +36 -0
- package/dist/cjs/plugins/CommentPlugin.js +481 -0
- package/dist/cjs/{packages/lexical/src/plugins → plugins}/DraggableBlockPlugin.js +17 -20
- package/dist/cjs/{packages/lexical/src/plugins → plugins}/ToolbarPlugin.js +58 -37
- package/dist/esm/{packages/lexical/src/editor → editor}/LexicalEditor.js +101 -48
- package/dist/esm/{packages/lexical/src/hooks → hooks}/useFormatWatcher.js +95 -88
- package/dist/esm/i18n/ar/lexical.json.js +25 -0
- package/dist/esm/i18n/en/lexical.json.js +25 -0
- package/dist/esm/i18n/index.js +33 -0
- package/dist/esm/index.js +34 -0
- package/dist/esm/plugins/CommentPlugin.js +481 -0
- package/dist/esm/{packages/lexical/src/plugins → plugins}/DraggableBlockPlugin.js +15 -18
- package/dist/esm/{packages/lexical/src/plugins → plugins}/ToolbarPlugin.js +59 -38
- package/dist/types/editor/LexicalEditor.d.ts +33 -4
- package/dist/types/hooks/useFormatWatcher.d.ts +7 -4
- package/dist/types/i18n/index.d.ts +1 -0
- package/dist/types/index.d.ts +27 -0
- package/dist/types/plugins/CommentPlugin.d.ts +5 -0
- package/dist/types/plugins/DraggableBlockPlugin.d.ts +3 -2
- package/dist/types/plugins/ToolbarPlugin.d.ts +1 -1
- package/dist/types/utils/index.d.ts +3 -6
- package/package.json +18 -18
- package/src/editor/LexicalEditor.tsx +95 -55
- package/src/hooks/useFormatWatcher.ts +50 -74
- package/src/i18n/ar/lexical.json +18 -0
- package/src/i18n/en/lexical.json +18 -0
- package/src/i18n/index.ts +28 -0
- package/src/index.ts +24 -17
- package/src/plugins/CommentPlugin.tsx +523 -0
- package/src/plugins/DraggableBlockPlugin.tsx +23 -68
- package/src/plugins/ToolbarPlugin.tsx +83 -131
- package/src/utils/index.ts +12 -108
- package/dist/cjs/_virtual/prism.js +0 -5
- package/dist/cjs/editor/Lexical.module.css +0 -1
- package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.dev.js +0 -432
- package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.js +0 -21
- package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.prod.js +0 -27
- package/dist/cjs/node_modules/@lexical/code/LexicalCode.dev.js +0 -1139
- package/dist/cjs/node_modules/@lexical/code/LexicalCode.js +0 -25
- package/dist/cjs/node_modules/@lexical/code/LexicalCode.prod.js +0 -50
- package/dist/cjs/node_modules/@lexical/html/LexicalHtml.dev.js +0 -245
- package/dist/cjs/node_modules/@lexical/html/LexicalHtml.js +0 -19
- package/dist/cjs/node_modules/@lexical/html/LexicalHtml.prod.js +0 -18
- package/dist/cjs/node_modules/@lexical/link/LexicalLink.dev.js +0 -471
- package/dist/cjs/node_modules/@lexical/link/LexicalLink.js +0 -17
- package/dist/cjs/node_modules/@lexical/link/LexicalLink.prod.js +0 -24
- package/dist/cjs/node_modules/@lexical/list/LexicalList.dev.js +0 -1275
- package/dist/cjs/node_modules/@lexical/list/LexicalList.js +0 -29
- package/dist/cjs/node_modules/@lexical/list/LexicalList.prod.js +0 -29
- package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.dev.js +0 -789
- package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.js +0 -29
- package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.prod.js +0 -26
- package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.dev.js +0 -976
- package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.js +0 -35
- package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.prod.js +0 -35
- package/dist/cjs/node_modules/@lexical/table/LexicalTable.dev.js +0 -2792
- package/dist/cjs/node_modules/@lexical/table/LexicalTable.js +0 -23
- package/dist/cjs/node_modules/@lexical/table/LexicalTable.prod.js +0 -55
- package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.dev.js +0 -888
- package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.js +0 -35
- package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.prod.js +0 -66
- package/dist/cjs/node_modules/@mdi/js/mdi.js +0 -8
- package/dist/cjs/node_modules/prismjs/components/prism-c.js +0 -82
- package/dist/cjs/node_modules/prismjs/components/prism-clike.js +0 -33
- package/dist/cjs/node_modules/prismjs/components/prism-cpp.js +0 -101
- package/dist/cjs/node_modules/prismjs/components/prism-css.js +0 -66
- package/dist/cjs/node_modules/prismjs/components/prism-java.js +0 -126
- package/dist/cjs/node_modules/prismjs/components/prism-javascript.js +0 -174
- package/dist/cjs/node_modules/prismjs/components/prism-markdown.js +0 -417
- package/dist/cjs/node_modules/prismjs/components/prism-markup.js +0 -188
- package/dist/cjs/node_modules/prismjs/components/prism-objectivec.js +0 -14
- package/dist/cjs/node_modules/prismjs/components/prism-powershell.js +0 -60
- package/dist/cjs/node_modules/prismjs/components/prism-python.js +0 -67
- package/dist/cjs/node_modules/prismjs/components/prism-rust.js +0 -130
- package/dist/cjs/node_modules/prismjs/components/prism-sql.js +0 -34
- package/dist/cjs/node_modules/prismjs/components/prism-swift.js +0 -150
- package/dist/cjs/node_modules/prismjs/components/prism-typescript.js +0 -62
- package/dist/cjs/node_modules/prismjs/prism.js +0 -1951
- package/dist/cjs/packages/lexical/src/components/StickyComponent.js +0 -221
- package/dist/cjs/packages/lexical/src/index.js +0 -7
- package/dist/cjs/packages/lexical/src/nodes/StickyNode.js +0 -218
- package/dist/cjs/packages/lexical/src/plugins/StickyPlugin.js +0 -20
- package/dist/esm/_virtual/prism.js +0 -5
- package/dist/esm/editor/Lexical.module.css +0 -1
- package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.dev.js +0 -423
- package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.js +0 -19
- package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.prod.js +0 -18
- package/dist/esm/node_modules/@lexical/code/LexicalCode.dev.js +0 -1121
- package/dist/esm/node_modules/@lexical/code/LexicalCode.js +0 -21
- package/dist/esm/node_modules/@lexical/code/LexicalCode.prod.js +0 -32
- package/dist/esm/node_modules/@lexical/html/LexicalHtml.dev.js +0 -244
- package/dist/esm/node_modules/@lexical/html/LexicalHtml.js +0 -18
- package/dist/esm/node_modules/@lexical/html/LexicalHtml.prod.js +0 -17
- package/dist/esm/node_modules/@lexical/link/LexicalLink.dev.js +0 -463
- package/dist/esm/node_modules/@lexical/link/LexicalLink.js +0 -17
- package/dist/esm/node_modules/@lexical/link/LexicalLink.prod.js +0 -16
- package/dist/esm/node_modules/@lexical/list/LexicalList.dev.js +0 -1262
- package/dist/esm/node_modules/@lexical/list/LexicalList.js +0 -23
- package/dist/esm/node_modules/@lexical/list/LexicalList.prod.js +0 -16
- package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.dev.js +0 -781
- package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.js +0 -23
- package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.prod.js +0 -18
- package/dist/esm/node_modules/@lexical/selection/LexicalSelection.dev.js +0 -957
- package/dist/esm/node_modules/@lexical/selection/LexicalSelection.js +0 -26
- package/dist/esm/node_modules/@lexical/selection/LexicalSelection.prod.js +0 -16
- package/dist/esm/node_modules/@lexical/table/LexicalTable.dev.js +0 -2754
- package/dist/esm/node_modules/@lexical/table/LexicalTable.js +0 -20
- package/dist/esm/node_modules/@lexical/table/LexicalTable.prod.js +0 -17
- package/dist/esm/node_modules/@lexical/utils/LexicalUtils.dev.js +0 -839
- package/dist/esm/node_modules/@lexical/utils/LexicalUtils.js +0 -26
- package/dist/esm/node_modules/@lexical/utils/LexicalUtils.prod.js +0 -17
- package/dist/esm/node_modules/@mdi/js/mdi.js +0 -7
- package/dist/esm/node_modules/prismjs/components/prism-c.js +0 -82
- package/dist/esm/node_modules/prismjs/components/prism-clike.js +0 -33
- package/dist/esm/node_modules/prismjs/components/prism-cpp.js +0 -101
- package/dist/esm/node_modules/prismjs/components/prism-css.js +0 -66
- package/dist/esm/node_modules/prismjs/components/prism-java.js +0 -126
- package/dist/esm/node_modules/prismjs/components/prism-javascript.js +0 -174
- package/dist/esm/node_modules/prismjs/components/prism-markdown.js +0 -417
- package/dist/esm/node_modules/prismjs/components/prism-markup.js +0 -188
- package/dist/esm/node_modules/prismjs/components/prism-objectivec.js +0 -14
- package/dist/esm/node_modules/prismjs/components/prism-powershell.js +0 -60
- package/dist/esm/node_modules/prismjs/components/prism-python.js +0 -67
- package/dist/esm/node_modules/prismjs/components/prism-rust.js +0 -130
- package/dist/esm/node_modules/prismjs/components/prism-sql.js +0 -34
- package/dist/esm/node_modules/prismjs/components/prism-swift.js +0 -150
- package/dist/esm/node_modules/prismjs/components/prism-typescript.js +0 -62
- package/dist/esm/node_modules/prismjs/prism.js +0 -1951
- package/dist/esm/packages/lexical/src/components/StickyComponent.js +0 -221
- package/dist/esm/packages/lexical/src/index.js +0 -3
- package/dist/esm/packages/lexical/src/nodes/StickyNode.js +0 -216
- package/dist/esm/packages/lexical/src/plugins/StickyPlugin.js +0 -20
- package/dist/types/components/StickyComponent.d.ts +0 -9
- package/dist/types/nodes/StickyNode.d.ts +0 -35
- package/dist/types/plugins/StickyPlugin.d.ts +0 -1
- package/src/components/StickyComponent.tsx +0 -271
- package/src/nodes/StickyNode.tsx +0 -249
- /package/dist/cjs/{packages/lexical/src/editor → editor}/theme.js +0 -0
- /package/dist/cjs/{packages/lexical/src/utils → utils}/index.js +0 -0
- /package/dist/esm/{packages/lexical/src/editor → editor}/theme.js +0 -0
- /package/dist/esm/{packages/lexical/src/utils → utils}/index.js +0 -0
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var LexicalTable_dev = require('./LexicalTable.dev.js');
|
|
4
|
-
var LexicalTable_prod = require('./LexicalTable.prod.js');
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
8
|
-
*
|
|
9
|
-
* This source code is licensed under the MIT license found in the
|
|
10
|
-
* LICENSE file in the root directory of this source tree.
|
|
11
|
-
*
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
const mod = process.env.NODE_ENV === 'development' ? LexicalTable_dev : LexicalTable_prod;
|
|
15
|
-
const $isTableNode = mod.$isTableNode;
|
|
16
|
-
const TableCellNode = mod.TableCellNode;
|
|
17
|
-
const TableNode = mod.TableNode;
|
|
18
|
-
const TableRowNode = mod.TableRowNode;
|
|
19
|
-
|
|
20
|
-
exports.$isTableNode = $isTableNode;
|
|
21
|
-
exports.TableCellNode = TableCellNode;
|
|
22
|
-
exports.TableNode = TableNode;
|
|
23
|
-
exports.TableRowNode = TableRowNode;
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var LexicalUtils = require('../utils/LexicalUtils.js');
|
|
4
|
-
var lexical = require('lexical');
|
|
5
|
-
var LexicalClipboard = require('../clipboard/LexicalClipboard.js');
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
9
|
-
*
|
|
10
|
-
* This source code is licensed under the MIT license found in the
|
|
11
|
-
* LICENSE file in the root directory of this source tree.
|
|
12
|
-
*
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
const G=/^(\d+(?:\.\d+)?)px$/,Q={BOTH:3,COLUMN:2,NO_STATUS:0,ROW:1};class V extends lexical.ElementNode{static getType(){return "tablecell"}static clone(e){const t=new V(e.__headerState,e.__colSpan,e.__width,e.__key);return t.__rowSpan=e.__rowSpan,t.__backgroundColor=e.__backgroundColor,t}static importDOM(){return {td:e=>({conversion:Z,priority:0}),th:e=>({conversion:Z,priority:0})}}static importJSON(e){const t=e.colSpan||1,n=e.rowSpan||1,o=ee(e.headerState,t,e.width||void 0);return o.__rowSpan=n,o.__backgroundColor=e.backgroundColor||null,o}constructor(e=Q.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),LexicalUtils.addClassNamesToElement(n,t.theme.tableCell,this.hasHeader()&&t.theme.tableCellHeader),n}exportDOM(e){const{element:t}=super.exportDOM(e);if(t){const e=t;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="top",e.style.textAlign="start";const n=this.getBackgroundColor();null!==n?e.style.backgroundColor=n:this.hasHeader()&&(e.style.backgroundColor="#f2f3f5");}return {element:t}}exportJSON(){return {...super.exportJSON(),backgroundColor:this.getBackgroundColor(),colSpan:this.__colSpan,headerState:this.__headerState,rowSpan:this.__rowSpan,type:"tablecell",width:this.getWidth()}}getColSpan(){return this.__colSpan}setColSpan(e){return this.getWritable().__colSpan=e,this}getRowSpan(){return this.__rowSpan}setRowSpan(e){return this.getWritable().__rowSpan=e,this}getTag(){return this.hasHeader()?"th":"td"}setHeaderStyles(e){return this.getWritable().__headerState=e,this.__headerState}getHeaderStyles(){return this.getLatest().__headerState}setWidth(e){return this.getWritable().__width=e,this.__width}getWidth(){return this.getLatest().__width}getBackgroundColor(){return this.getLatest().__backgroundColor}setBackgroundColor(e){this.getWritable().__backgroundColor=e;}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!==Q.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}isShadowRoot(){return !0}collapseAtStart(){return !0}canBeEmpty(){return !1}canIndent(){return !1}}function Z(e){const t=e,n=e.nodeName.toLowerCase();let o;G.test(t.style.width)&&(o=parseFloat(t.style.width));const r=ee("th"===n?Q.ROW:Q.NO_STATUS,t.colSpan,o);r.__rowSpan=t.rowSpan;const l=t.style.backgroundColor;""!==l&&(r.__backgroundColor=l);const d=t.style,u=d.textDecoration.split(" "),h="700"===d.fontWeight||"bold"===d.fontWeight,g=u.includes("line-through"),f="italic"===d.fontStyle,m=u.includes("underline");return {after:e=>(0===e.length&&e.push(lexical.$createParagraphNode()),e),forChild:(e,t)=>{if(te(t)&&!lexical.$isElementNode(e)){const t=lexical.$createParagraphNode();return lexical.$isLineBreakNode(e)&&"\n"===e.getTextContent()?null:(lexical.$isTextNode(e)&&(h&&e.toggleFormat("bold"),g&&e.toggleFormat("strikethrough"),f&&e.toggleFormat("italic"),m&&e.toggleFormat("underline")),t.append(e),t)}return e},node:r}}function ee(e,t=1,n){return lexical.$applyNodeReplacement(new V(e,t,n))}function te(e){return e instanceof V}const ne=lexical.createCommand("INSERT_TABLE_COMMAND");class oe extends lexical.ElementNode{static getType(){return "tablerow"}static clone(e){return new oe(e.__height,e.__key)}static importDOM(){return {tr:e=>({conversion:re,priority:0})}}static importJSON(e){return le(e.height)}constructor(e,t){super(t),this.__height=e;}exportJSON(){return {...super.exportJSON(),...this.getHeight()&&{height:this.getHeight()},type:"tablerow",version:1}}createDOM(t){const n=document.createElement("tr");return this.__height&&(n.style.height=`${this.__height}px`),LexicalUtils.addClassNamesToElement(n,t.theme.tableRow),n}isShadowRoot(){return !0}setHeight(e){return this.getWritable().__height=e,this.__height}getHeight(){return this.getLatest().__height}updateDOM(e){return e.__height!==this.__height}canBeEmpty(){return !1}canIndent(){return !1}}function re(e){const t=e;let n;return G.test(t.style.height)&&(n=parseFloat(t.style.height)),{node:le(n)}}function le(e){return lexical.$applyNodeReplacement(new oe(e))}function se(e){return e instanceof oe}function ie(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ce=ie((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.`)}));const ae="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement;function de(e,t,n=!0){const o=at();for(let r=0;r<e;r++){const e=le();for(let o=0;o<t;o++){let t=Q.NO_STATUS;"object"==typeof n?(0===r&&n.rows&&(t|=Q.ROW),0===o&&n.columns&&(t|=Q.COLUMN)):n&&(0===r&&(t|=Q.ROW),0===o&&(t|=Q.COLUMN));const l=ee(t),i=lexical.$createParagraphNode();i.append(lexical.$createTextNode()),l.append(i),e.append(l);}o.append(e);}return o}function ue(e){const n=LexicalUtils.$findMatchingParent(e,(e=>te(e)));return te(n)?n:null}function he(e){const n=LexicalUtils.$findMatchingParent(e,(e=>se(e)));if(se(n))return n;throw new Error("Expected table cell to be inside of table row.")}function ge(e){const n=LexicalUtils.$findMatchingParent(e,(e=>dt(e)));if(dt(n))return n;throw new Error("Expected table cell to be inside of table.")}function fe(e){const t=he(e);return ge(t).getChildren().findIndex((e=>e.is(t)))}function me(e){return he(e).getChildren().findIndex((t=>t.is(e)))}function pe(e,t){const n=ge(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 Ce(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 Se(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 i=l[t];if(!se(i))throw new Error("Row before insertion index does not exist.");for(let e=0;e<o;e++){const e=i.getChildren(),t=e.length,o=le();for(let n=0;n<t;n++){const t=e[n];te(t)||ce(12);const{above:l,below:i}=pe(t,r);let c=Q.NO_STATUS;const a=l&&l.getWidth()||i&&i.getWidth()||void 0;(l&&l.hasHeaderState(Q.COLUMN)||i&&i.hasHeaderState(Q.COLUMN))&&(c|=Q.COLUMN);const d=ee(c,1,a);d.append(lexical.$createParagraphNode()),o.append(d);}n?i.insertAfter(o):i.insertBefore(o);}return e}const _e=(e,t)=>e===Q.BOTH||e===t?t:Q.NO_STATUS;function we(e=!0){const t=lexical.$getSelection();lexical.$isRangeSelection(t)||Ae(t)||ce(188);const n=t.focus.getNode(),[o,,r]=Ke(n),[l,i]=Me(r,o,o),c=l[0].length,{startRow:a}=i;if(e){const e=a+o.__rowSpan-1,t=l[e],n=le();for(let o=0;o<c;o++){const{cell:r,startRow:l}=t[o];if(l+r.__rowSpan-1<=e){const e=t[o].cell.__headerState,r=_e(e,Q.COLUMN);n.append(ee(r).append(lexical.$createParagraphNode()));}else r.setRowSpan(r.__rowSpan+1);}const i=r.getChildAtIndex(e);se(i)||ce(145),i.insertAfter(n);}else {const e=l[a],t=le();for(let n=0;n<c;n++){const{cell:o,startRow:r}=e[n];if(r===a){const o=e[n].cell.__headerState,r=_e(o,Q.COLUMN);t.append(ee(r).append(lexical.$createParagraphNode()));}else o.setRowSpan(o.__rowSpan+1);}const n=r.getChildAtIndex(a);se(n)||ce(145),n.insertBefore(t);}}function be(e,t,n=!0,o,r){const l=e.getChildren(),i=[];for(let e=0;e<l.length;e++){const n=l[e];if(se(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];te(o)||ce(12);const{left:l,right:c}=pe(o,r);let a=Q.NO_STATUS;(l&&l.hasHeaderState(Q.ROW)||c&&c.hasHeaderState(Q.ROW))&&(a|=Q.ROW);const d=ee(a);d.append(lexical.$createParagraphNode()),i.push({newTableCell:d,targetCell:o});}}return i.forEach((({newTableCell:e,targetCell:t})=>{n?t.insertAfter(e):t.insertBefore(e);})),e}function ye(e=!0){const t=lexical.$getSelection();lexical.$isRangeSelection(t)||Ae(t)||ce(188);const n=t.anchor.getNode(),o=t.focus.getNode(),[r]=Ke(n),[l,,i]=Ke(o),[c,a,d]=Me(i,l,r),u=c.length,h=e?Math.max(a.startColumn,d.startColumn):Math.min(a.startColumn,d.startColumn),m=e?h+l.__colSpan-1:h-1,p=i.getFirstChild();se(p)||ce(120);let C=null;function S(e=Q.NO_STATUS){const t=ee(e).append(lexical.$createParagraphNode());return null===C&&(C=t),t}let _=p;e:for(let e=0;e<u;e++){if(0!==e){const e=_.getNextSibling();se(e)||ce(121),_=e;}const t=c[e],n=t[m<0?0:m].cell.__headerState,o=_e(n,Q.ROW);if(m<0){Ee(_,S(o));continue}const{cell:r,startColumn:l,startRow:s}=t[m];if(l+r.__colSpan-1<=m){let n=r,l=s,i=m;for(;l!==e&&n.__rowSpan>1;){if(i-=r.__colSpan,!(i>=0)){_.append(S(o));continue e}{const{cell:e,startRow:o}=t[i];n=e,l=o;}}n.insertAfter(S(o));}else r.setColSpan(r.__colSpan+1);}null!==C&&ve(C);}function Ne(e,t){const n=e.getChildren();for(let e=0;e<n.length;e++){const o=n[e];if(se(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 Te(){const e=lexical.$getSelection();lexical.$isRangeSelection(e)||Ae(e)||ce(188);const t=e.anchor.getNode(),n=e.focus.getNode(),[o,,r]=Ke(t),[l]=Ke(n),[s,i,c]=Me(r,o,l),{startRow:a}=i,{startRow:d}=c,u=d+l.__rowSpan-1;if(s.length===u-a+1)return void r.remove();const h=s[0].length,m=s[u+1],p=r.getChildAtIndex(u+1);for(let e=u;e>=a;e--){for(let t=h-1;t>=0;t--){const{cell:n,startRow:o,startColumn:r}=s[e][t];if(r===t&&(e===a&&o<a&&n.setRowSpan(n.__rowSpan-(o-a)),o>=a&&o+n.__rowSpan-1>u))if(n.setRowSpan(n.__rowSpan-(u-o+1)),null===p&&ce(122),0===t)Ee(p,n);else {const{cell:e}=m[t-1];e.insertAfter(n);}}const t=r.getChildAtIndex(e);se(t)||ce(123,String(e)),t.remove();}if(void 0!==m){const{cell:e}=m[0];ve(e);}else {const e=s[a-1],{cell:t}=e[0];ve(t);}}function xe(){const e=lexical.$getSelection();lexical.$isRangeSelection(e)||Ae(e)||ce(188);const t=e.anchor.getNode(),n=e.focus.getNode(),[o,,r]=Ke(t),[l]=Ke(n),[s,i,c]=Me(r,o,l),{startColumn:a}=i,{startRow:d,startColumn:u}=c,h=Math.min(a,u),m=Math.max(a+o.__colSpan-1,u+l.__colSpan-1),p=m-h+1;if(s[0].length===m-h+1)return r.selectPrevious(),void r.remove();const C=s.length;for(let e=0;e<C;e++)for(let t=h;t<=m;t++){const{cell:n,startColumn:o}=s[e][t];if(o<h){if(t===h){const e=h-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],_=a>u?S[a+o.__colSpan]:S[u+l.__colSpan];if(void 0!==_){const{cell:e}=_;ve(e);}else {const e=u<a?S[u-1]:S[a-1],{cell:t}=e;ve(t);}}function ve(e){const t=e.getFirstDescendant();null==t?e.selectStart():t.getParentOrThrow().selectStart();}function Ee(e,t){const n=e.getFirstChild();null!==n?n.insertBefore(t):e.append(t);}function Oe(){const e=lexical.$getSelection();lexical.$isRangeSelection(e)||Ae(e)||ce(188);const t=e.anchor.getNode(),[n,o,r]=Ke(t),l=n.__colSpan,i=n.__rowSpan;if(l>1){for(let e=1;e<l;e++)n.insertAfter(ee(Q.NO_STATUS).append(lexical.$createParagraphNode()));n.setColSpan(1);}if(i>1){const[e,t]=Me(r,n,n),{startColumn:c,startRow:a}=t;let d;for(let t=1;t<i;t++){const n=a+t,r=e[n];d=(d||o).getNextSibling(),se(d)||ce(125);let i=null;for(let e=0;e<c;e++){const t=r[e],o=t.cell;t.startRow===n&&(i=o),o.__colSpan>1&&(e+=o.__colSpan-1);}if(null===i)for(let e=0;e<l;e++)Ee(d,ee(Q.NO_STATUS).append(lexical.$createParagraphNode()));else for(let e=0;e<l;e++)i.insertAfter(ee(Q.NO_STATUS).append(lexical.$createParagraphNode()));}n.setRowSpan(1);}}function Me(e,t,n){const[o,r,l]=Re(e,t,n);return null===r&&ce(110),null===l&&ce(111),[o,r,l]}function Re(e,t,n){const o=[];let r=null,l=null;function s(e,s,i){const c={cell:i,startColumn:s,startRow:e},a=i.__rowSpan,d=i.__colSpan;for(let t=0;t<a;t++){void 0===o[e+t]&&(o[e+t]=[]);for(let n=0;n<d;n++)o[e+t][s+n]=c;}null!==t&&t.is(i)&&(r=c),null!==n&&n.is(i)&&(l=c);}function i(e,t){return void 0===o[e]||void 0===o[e][t]}const c=e.getChildren();for(let e=0;e<c.length;e++){const t=c[e];se(t)||ce(146);const n=t.getChildren();let o=0;for(const t of n){for(te(t)||ce(147);!i(e,o);)o++;s(e,o,t),o+=t.__colSpan;}}return [o,r,l]}function Ke(e){let n;if(e instanceof V)n=e;else if("__type"in e){const o=LexicalUtils.$findMatchingParent(e,te);te(o)||ce(148),n=o;}else {const o=LexicalUtils.$findMatchingParent(e.getNode(),te);te(o)||ce(148),n=o;}const o=n.getParent();se(o)||ce(149);const r=o.getParent();return dt(r)||ce(150),[n,o,r]}function Fe(e){const[t,,n]=Ke(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}class ke{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]}isBackward(){return this.focus.isBefore(this.anchor)}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e;}is(e){return !!Ae(e)&&(this.tableKey===e.tableKey&&this.anchor.is(e.anchor)&&this.focus.is(e.focus))}set(e,t,n){this.dirty=!0,this.tableKey=e,this.anchor.key=t,this.focus.key=n,this._cachedNodes=null;}clone(){return new ke(this.tableKey,this.anchor,this.focus)}isCollapsed(){return !1}extract(){return this.getNodes()}insertRawText(e){}insertText(){}insertNodes(e){const t=this.focus.getNode();lexical.$isElementNode(t)||ce(151);lexical.$normalizeSelection__EXPERIMENTAL(t.select(0,t.getChildrenSize())).insertNodes(e);}getShape(){const e=lexical.$getNodeByKey(this.anchor.key);te(e)||ce(152);const t=Fe(e);null===t&&ce(153);const n=lexical.$getNodeByKey(this.focus.key);te(n)||ce(154);const o=Fe(n);null===o&&ce(155);const r=Math.min(t.columnIndex,o.columnIndex),l=Math.max(t.columnIndex,o.columnIndex),s=Math.min(t.rowIndex,o.rowIndex),i=Math.max(t.rowIndex,o.rowIndex);return {fromX:Math.min(r,l),fromY:Math.min(s,i),toX:Math.max(r,l),toY:Math.max(s,i)}}getNodes(){const e=this._cachedNodes;if(null!==e)return e;const n=this.anchor.getNode(),o=this.focus.getNode(),r=LexicalUtils.$findMatchingParent(n,te),l=LexicalUtils.$findMatchingParent(o,te);te(r)||ce(152),te(l)||ce(154);const s=r.getParent();se(s)||ce(156);const i=s.getParent();dt(i)||ce(157);const c=l.getParents()[1];if(c!==i){if(i.isParentOf(l)){const e=c.getParent();null==e&&ce(159),this.set(this.tableKey,l.getKey(),e.getKey());}else {const e=i.getParent();null==e&&ce(158),this.set(this.tableKey,e.getKey(),l.getKey());}return this.getNodes()}const[a,d,u]=Me(i,r,l);let h=Math.min(d.startColumn,u.startColumn),g=Math.min(d.startRow,u.startRow),f=Math.max(d.startColumn+d.cell.__colSpan-1,u.startColumn+u.cell.__colSpan-1),m=Math.max(d.startRow+d.cell.__rowSpan-1,u.startRow+u.cell.__rowSpan-1),p=h,C=g,_=h,w=g;function b(e){const{cell:t,startColumn:n,startRow:o}=e;h=Math.min(h,n),g=Math.min(g,o),f=Math.max(f,n+t.__colSpan-1),m=Math.max(m,o+t.__rowSpan-1);}for(;h<p||g<C||f>_||m>w;){if(h<p){const e=w-C,t=p-1;for(let n=0;n<=e;n++)b(a[C+n][t]);p=t;}if(g<C){const e=_-p,t=C-1;for(let n=0;n<=e;n++)b(a[t][p+n]);C=t;}if(f>_){const e=w-C,t=_+1;for(let n=0;n<=e;n++)b(a[C+n][t]);_=t;}if(m>w){const e=_-p,t=w+1;for(let n=0;n<=e;n++)b(a[t][p+n]);w=t;}}const y=[i];let N=null;for(let e=g;e<=m;e++)for(let t=h;t<=f;t++){const{cell:n}=a[e][t],o=n.getParent();se(o)||ce(160),o!==N&&y.push(o),y.push(n,...De(n)),N=o;}return lexical.isCurrentlyReadOnlyMode()||(this._cachedNodes=y),y}getTextContent(){const e=this.getNodes().filter((e=>te(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 Ae(e){return e instanceof ke}function He(){const e=lexical.$createPoint("root",0,"element"),t=lexical.$createPoint("root",0,"element");return new ke("root",e,t)}function De(e){const t=[],n=[e];for(;n.length>0;){const o=n.pop();void 0===o&&ce(112),lexical.$isElementNode(o)&&n.unshift(...o.getChildren()),o!==e&&t.push(o);}return t}class Pe{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.trackTable(),this.isSelecting=!1;}getTable(){return this.table}removeListeners(){Array.from(this.listenersToRemove).forEach((e=>e()));}trackTable(){const e=new MutationObserver((e=>{this.editor.update((()=>{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 n=this.editor.getElementByKey(this.tableNodeKey);if(!n)throw new Error("Expected to find TableElement in DOM");this.table=ze(n);}));}));this.editor.update((()=>{const t=this.editor.getElementByKey(this.tableNodeKey);if(!t)throw new Error("Expected to find TableElement in DOM");this.table=ze(t),e.observe(t,{attributes:!0,childList:!0,subtree:!0});}));}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(),e.update((()=>{if(!dt(lexical.$getNodeByKey(this.tableNodeKey)))throw new Error("Expected TableNode.");const t=e.getElementByKey(this.tableNodeKey);if(!t)throw new Error("Expected to find TableElement in DOM");const n=ze(t);Ye(e,n,null),lexical.$setSelection(null),e.dispatchCommand(lexical.SELECTION_CHANGE_COMMAND,void 0);}));}enableHighlightStyle(){const e=this.editor;e.update((()=>{const t=e.getElementByKey(this.tableNodeKey);if(!t)throw new Error("Expected to find TableElement in DOM");LexicalUtils.removeClassNamesFromElement(t,e._config.theme.tableSelection),t.classList.remove("disable-selection"),this.hasHijackedSelectionStyles=!1;}));}disableHighlightStyle(){const t=this.editor;t.update((()=>{const n=t.getElementByKey(this.tableNodeKey);if(!n)throw new Error("Expected to find TableElement in DOM");LexicalUtils.addClassNamesToElement(n,t._config.theme.tableSelection),this.hasHijackedSelectionStyles=!0;}));}updateTableTableSelection(e){if(null!==e&&e.tableKey===this.tableNodeKey){const t=this.editor;this.tableSelection=e,this.isHighlightingCells=!0,this.disableHighlightStyle(),Ye(t,this.table,this.tableSelection);}else null==e?this.clearHighlight():(this.tableNodeKey=e.tableKey,this.updateTableTableSelection(e));}setFocusCellForSelection(e,t=!1){const n=this.editor;n.update((()=>{const o=lexical.$getNodeByKey(this.tableNodeKey);if(!dt(o))throw new Error("Expected TableNode.");if(!n.getElementByKey(this.tableNodeKey))throw new Error("Expected to find TableElement in DOM");const r=e.x,l=e.y;if(this.focusCell=e,null!==this.anchorCell){const e=Le(n._window);e&&e.setBaseAndExtent(this.anchorCell.elem,0,this.focusCell.elem,0);}if(this.isHighlightingCells||this.anchorX===r&&this.anchorY===l&&!t){if(r===this.focusX&&l===this.focusY)return}else this.isHighlightingCells=!0,this.disableHighlightStyle();if(this.focusX=r,this.focusY=l,this.isHighlightingCells){const t=lexical.$getNearestNodeFromDOMNode(e.elem);if(null!=this.tableSelection&&null!=this.anchorCellNodeKey&&te(t)&&o.is(tt(t))){const e=t.getKey();this.tableSelection=this.tableSelection.clone()||He(),this.focusCellNodeKey=e,this.tableSelection.set(this.tableNodeKey,this.anchorCellNodeKey,this.focusCellNodeKey),lexical.$setSelection(this.tableSelection),n.dispatchCommand(lexical.SELECTION_CHANGE_COMMAND,void 0),Ye(n,this.table,this.tableSelection);}}}));}setAnchorCellForSelection(e){this.isHighlightingCells=!1,this.anchorCell=e,this.anchorX=e.x,this.anchorY=e.y,this.editor.update((()=>{const t=lexical.$getNearestNodeFromDOMNode(e.elem);if(te(t)){const e=t.getKey();this.tableSelection=null!=this.tableSelection?this.tableSelection.clone():He(),this.anchorCellNodeKey=e;}}));}formatCells(e){this.editor.update((()=>{const t=lexical.$getSelection();Ae(t)||ce(11);const n=lexical.$createRangeSelection(),o=n.anchor,r=n.focus;t.getNodes().forEach((t=>{te(t)&&0!==t.getTextContentSize()&&(o.set(t.getKey(),0,"element"),r.set(t.getKey(),t.getChildrenSize(),"element"),n.formatText(e));})),lexical.$setSelection(t),this.editor.dispatchCommand(lexical.SELECTION_CHANGE_COMMAND,void 0);}));}clearText(){const e=this.editor;e.update((()=>{const t=lexical.$getNodeByKey(this.tableNodeKey);if(!dt(t))throw new Error("Expected TableNode.");const n=lexical.$getSelection();Ae(n)||ce(11);const o=n.getNodes().filter(te);if(o.length!==this.table.columns*this.table.rows)o.forEach((e=>{if(lexical.$isElementNode(e)){const t=lexical.$createParagraphNode(),n=lexical.$createTextNode();t.append(n),e.append(t),e.getChildren().forEach((e=>{e!==t&&e.remove();}));}})),Ye(e,this.table,null),lexical.$setSelection(null),e.dispatchCommand(lexical.SELECTION_CHANGE_COMMAND,void 0);else {t.selectPrevious(),t.remove();lexical.$getRoot().selectStart();}}));}}const Be="__lexicalTableSelection",Le=e=>ae?(e||window).getSelection():null;function Ie(e,n,r,l){const c=r.getRootElement();if(null===c)throw new Error("No root element.");const d=new Pe(r,e.getKey()),u=r._window||window;!function(e,t){e[Be]=t;}(n,d);const m=()=>{const e=()=>{d.isSelecting=!1,u.removeEventListener("mouseup",e),u.removeEventListener("mousemove",t);},t=n=>{setTimeout((()=>{if(1&~n.buttons&&d.isSelecting)return d.isSelecting=!1,u.removeEventListener("mouseup",e),void u.removeEventListener("mousemove",t);const o=Ue(n.target);null===o||d.anchorX===o.x&&d.anchorY===o.y||(n.preventDefault(),d.setFocusCellForSelection(o));}),0);};return {onMouseMove:t,onMouseUp:e}};n.addEventListener("mousedown",(e=>{setTimeout((()=>{if(0!==e.button)return;if(!u)return;const t=Ue(e.target);null!==t&&(ot(e),d.setAnchorCellForSelection(t));const{onMouseUp:n,onMouseMove:o}=m();d.isSelecting=!0,u.addEventListener("mouseup",n),u.addEventListener("mousemove",o);}),0);}));const p=e=>{0===e.button&&r.update((()=>{const t=lexical.$getSelection(),n=e.target;Ae(t)&&t.tableKey===d.tableNodeKey&&c.contains(n)&&d.clearHighlight();}));};u.addEventListener("mousedown",p),d.listenersToRemove.add((()=>u.removeEventListener("mousedown",p))),d.listenersToRemove.add(r.registerCommand(lexical.KEY_ARROW_DOWN_COMMAND,(t=>nt(r,t,"down",e,d)),lexical.COMMAND_PRIORITY_HIGH)),d.listenersToRemove.add(r.registerCommand(lexical.KEY_ARROW_UP_COMMAND,(t=>nt(r,t,"up",e,d)),lexical.COMMAND_PRIORITY_HIGH)),d.listenersToRemove.add(r.registerCommand(lexical.KEY_ARROW_LEFT_COMMAND,(t=>nt(r,t,"backward",e,d)),lexical.COMMAND_PRIORITY_HIGH)),d.listenersToRemove.add(r.registerCommand(lexical.KEY_ARROW_RIGHT_COMMAND,(t=>nt(r,t,"forward",e,d)),lexical.COMMAND_PRIORITY_HIGH)),d.listenersToRemove.add(r.registerCommand(lexical.KEY_ESCAPE_COMMAND,(e=>{const n=lexical.$getSelection();if(Ae(n)){const o=LexicalUtils.$findMatchingParent(n.focus.getNode(),te);if(te(o))return ot(e),o.selectEnd(),!0}return !1}),lexical.COMMAND_PRIORITY_HIGH));[lexical.DELETE_WORD_COMMAND,lexical.DELETE_LINE_COMMAND,lexical.DELETE_CHARACTER_COMMAND].forEach((n=>{d.listenersToRemove.add(r.registerCommand(n,(n=>()=>{const o=lexical.$getSelection();if(!qe(o,e))return !1;if(Ae(o))return d.clearText(),!0;if(lexical.$isRangeSelection(o)){const r=LexicalUtils.$findMatchingParent(o.anchor.getNode(),(e=>te(e)));if(!te(r))return !1;const l=o.anchor.getNode(),s=o.focus.getNode(),c=e.isParentOf(l),a=e.isParentOf(s);if(c&&!a||a&&!c)return d.clearText(),!0;const u=LexicalUtils.$findMatchingParent(o.anchor.getNode(),(e=>lexical.$isElementNode(e))),h=u&&LexicalUtils.$findMatchingParent(u,(e=>lexical.$isElementNode(e)&&te(e.getParent())));if(!lexical.$isElementNode(h)||!lexical.$isElementNode(u))return !1;if(n===lexical.DELETE_LINE_COMMAND&&null===h.getPreviousSibling())return !0}return !1})(n),lexical.COMMAND_PRIORITY_CRITICAL));}));const C=n=>{const o=lexical.$getSelection();if(!qe(o,e)){const e=o?o.getNodes():null;if(e){const t=e.find((e=>dt(e)&&e.getKey()===d.tableNodeKey));if(dt(t)){if(!t.getParent())return !1;t.remove();}}return !1}if(Ae(o))return n&&(n.preventDefault(),n.stopPropagation()),d.clearText(),!0;if(lexical.$isRangeSelection(o)){const e=LexicalUtils.$findMatchingParent(o.anchor.getNode(),(e=>te(e)));if(!te(e))return !1}return !1};function S(t){const n=e.getCordsFromCellNode(t,d.table);return e.getDOMCellFromCordsOrThrow(n.x,n.y,d.table)}return d.listenersToRemove.add(r.registerCommand(lexical.KEY_BACKSPACE_COMMAND,C,lexical.COMMAND_PRIORITY_CRITICAL)),d.listenersToRemove.add(r.registerCommand(lexical.KEY_DELETE_COMMAND,C,lexical.COMMAND_PRIORITY_CRITICAL)),d.listenersToRemove.add(r.registerCommand(lexical.CUT_COMMAND,(e=>{const t=lexical.$getSelection();if(t){if(!Ae(t)&&!lexical.$isRangeSelection(t))return !1;LexicalClipboard.copyToClipboard(r,LexicalUtils.objectKlassEquals(e,ClipboardEvent)?e:null,LexicalClipboard.$getClipboardDataFromSelection(t));const n=C(e);return lexical.$isRangeSelection(t)&&t.removeText(),n}return !1}),lexical.COMMAND_PRIORITY_CRITICAL)),d.listenersToRemove.add(r.registerCommand(lexical.FORMAT_TEXT_COMMAND,(n=>{const o=lexical.$getSelection();if(!qe(o,e))return !1;if(Ae(o))return d.formatCells(n),!0;if(lexical.$isRangeSelection(o)){const e=LexicalUtils.$findMatchingParent(o.anchor.getNode(),(e=>te(e)));if(!te(e))return !1}return !1}),lexical.COMMAND_PRIORITY_CRITICAL)),d.listenersToRemove.add(r.registerCommand(lexical.FORMAT_ELEMENT_COMMAND,(t=>{const n=lexical.$getSelection();if(!Ae(n)||!qe(n,e))return !1;const o=n.anchor.getNode(),r=n.focus.getNode();if(!te(o)||!te(r))return !1;const[l,s,c]=Me(e,o,r),a=Math.max(s.startRow,c.startRow),d=Math.max(s.startColumn,c.startColumn),u=Math.min(s.startRow,c.startRow),h=Math.min(s.startColumn,c.startColumn);for(let e=u;e<=a;e++)for(let n=h;n<=d;n++){const o=l[e][n].cell;o.setFormat(t);const r=o.getChildren();for(let e=0;e<r.length;e++){const n=r[e];lexical.$isElementNode(n)&&!n.isInline()&&n.setFormat(t);}}return !0}),lexical.COMMAND_PRIORITY_CRITICAL)),d.listenersToRemove.add(r.registerCommand(lexical.CONTROLLED_TEXT_INSERTION_COMMAND,(n=>{const o=lexical.$getSelection();if(!qe(o,e))return !1;if(Ae(o))return d.clearHighlight(),!1;if(lexical.$isRangeSelection(o)){const l=LexicalUtils.$findMatchingParent(o.anchor.getNode(),(e=>te(e)));if(!te(l))return !1;if("string"==typeof n){const t=lt(r,o,e);if(t)return rt(t,e,[lexical.$createTextNode(n)]),!0}}return !1}),lexical.COMMAND_PRIORITY_CRITICAL)),l&&d.listenersToRemove.add(r.registerCommand(lexical.KEY_TAB_COMMAND,(t=>{const n=lexical.$getSelection();if(!lexical.$isRangeSelection(n)||!n.isCollapsed()||!qe(n,e))return !1;const o=et(n.anchor.getNode());if(null===o)return !1;ot(t);const r=e.getCordsFromCellNode(o,d.table);return $e(d,e,r.x,r.y,t.shiftKey?"backward":"forward"),!0}),lexical.COMMAND_PRIORITY_CRITICAL)),d.listenersToRemove.add(r.registerCommand(lexical.FOCUS_COMMAND,(t=>e.isSelected()),lexical.COMMAND_PRIORITY_HIGH)),d.listenersToRemove.add(r.registerCommand(lexical.SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,(e=>{const{nodes:n,selection:o}=e,r=o.getStartEndPoints(),l=Ae(o),i=lexical.$isRangeSelection(o)&&null!==LexicalUtils.$findMatchingParent(o.anchor.getNode(),(e=>te(e)))&&null!==LexicalUtils.$findMatchingParent(o.focus.getNode(),(e=>te(e)))||l;if(1!==n.length||!dt(n[0])||!i||null===r)return !1;const[c]=r,d=n[0],u=d.getChildren(),h=d.getFirstChildOrThrow().getChildrenSize(),g=d.getChildrenSize(),m=LexicalUtils.$findMatchingParent(c.getNode(),(e=>te(e))),p=m&&LexicalUtils.$findMatchingParent(m,(e=>se(e))),C=p&&LexicalUtils.$findMatchingParent(p,(e=>dt(e)));if(!te(m)||!se(p)||!dt(C))return !1;const S=p.getIndexWithinParent(),_=Math.min(C.getChildrenSize()-1,S+g-1),w=m.getIndexWithinParent(),b=Math.min(p.getChildrenSize()-1,w+h-1),y=Math.min(w,b),N=Math.min(S,_),T=Math.max(w,b),x=Math.max(S,_),v=C.getChildren();let E=0;for(let e=N;e<=x;e++){const t=v[e];if(!se(t))return !1;const n=u[E];if(!se(n))return !1;const o=t.getChildren(),r=n.getChildren();let l=0;for(let e=y;e<=T;e++){const t=o[e];if(!te(t))return !1;const n=r[l];if(!te(n))return !1;const i=t.getChildren();n.getChildren().forEach((e=>{if(lexical.$isTextNode(e)){lexical.$createParagraphNode().append(e),t.append(e);}else t.append(e);})),i.forEach((e=>e.remove())),l++;}E++;}return !0}),lexical.COMMAND_PRIORITY_CRITICAL)),d.listenersToRemove.add(r.registerCommand(lexical.SELECTION_CHANGE_COMMAND,(()=>{const t=lexical.$getSelection(),n=lexical.$getPreviousSelection();if(lexical.$isRangeSelection(t)){const{anchor:n,focus:o}=t,l=n.getNode(),s=o.getNode(),i=et(l),c=et(s),a=!(!i||!e.is(tt(i))),h=!(!c||!e.is(tt(c))),g=a!==h,f=a&&h,p=t.isBackward();if(g){const n=t.clone();if(h){const[t]=Me(e,c,c),o=t[0][0].cell,r=t[t.length-1].at(-1).cell;n.focus.set(p?o.getKey():r.getKey(),p?o.getChildrenSize():r.getChildrenSize(),"element");}lexical.$setSelection(n),Je(r,d);}else f&&(i.is(c)||(d.setAnchorCellForSelection(S(i)),d.setFocusCellForSelection(S(c),!0),d.isSelecting||setTimeout((()=>{const{onMouseUp:e,onMouseMove:t}=m();d.isSelecting=!0,u.addEventListener("mouseup",e),u.addEventListener("mousemove",t);}),0)));}else if(t&&Ae(t)&&t.is(n)&&t.tableKey===e.getKey()){const n=Le(r._window);if(n&&n.anchorNode&&n.focusNode){const o=lexical.$getNearestNodeFromDOMNode(n.focusNode),l=o&&!e.is(tt(o)),s=lexical.$getNearestNodeFromDOMNode(n.anchorNode),i=s&&e.is(tt(s));if(l&&i&&n.rangeCount>0){const o=lexical.$createRangeSelectionFromDom(n,r);o&&(o.anchor.set(e.getKey(),t.isBackward()?e.getChildrenSize():0,"element"),n.removeAllRanges(),lexical.$setSelection(o));}}}return t&&!t.is(n)&&(Ae(t)||Ae(n))&&d.tableSelection&&!d.tableSelection.is(n)?(Ae(t)&&t.tableKey===d.tableNodeKey?d.updateTableTableSelection(t):!Ae(t)&&Ae(n)&&n.tableKey===d.tableNodeKey&&d.updateTableTableSelection(null),!1):(d.hasHijackedSelectionStyles&&!e.isSelected()?function(e,t){t.enableHighlightStyle(),Xe(t.table,(t=>{const n=t.elem;t.highlighted=!1,Ze(e,t),n.getAttribute("style")||n.removeAttribute("style");}));}(r,d):!d.hasHijackedSelectionStyles&&e.isSelected()&&Je(r,d),!1)}),lexical.COMMAND_PRIORITY_CRITICAL)),d.listenersToRemove.add(r.registerCommand(lexical.INSERT_PARAGRAPH_COMMAND,(()=>{const t=lexical.$getSelection();if(!lexical.$isRangeSelection(t)||!t.isCollapsed()||!qe(t,e))return !1;const n=lt(r,t,e);return !!n&&(rt(n,e),!0)}),lexical.COMMAND_PRIORITY_CRITICAL)),d}function We(e){return e[Be]}function Ue(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 ze(e){const t=[],n={columns:0,domRows:t,rows:0};let o=e.firstChild,r=0,l=0;for(t.length=0;null!=o;){const e=o.nodeName;if("TD"===e||"TH"===e){const e={elem:o,hasBackgroundColor:""!==o.style.backgroundColor,highlighted:!1,x:r,y:l};o._cell=e;let n=t[l];void 0===n&&(n=t[l]=[]),n[r]=e;}else {const e=o.firstChild;if(null!=e){o=e;continue}}const n=o.nextSibling;if(null!=n){r++,o=n;continue}const s=o.parentNode;if(null!=s){const e=s.nextSibling;if(null==e)break;l++,r=0,o=e;}}return n.columns=r+1,n.rows=l+1,n}function Ye(e,t,n){const o=new Set(n?n.getNodes():[]);Xe(t,((t,n)=>{const r=t.elem;o.has(n)?(t.highlighted=!0,Ve(e,t)):(t.highlighted=!1,Ze(e,t),r.getAttribute("style")||r.removeAttribute("style"));}));}function Xe(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=lexical.$getNearestNodeFromDOMNode(r.elem);null!==l&&t(r,l,{x:n,y:e});}}}function Je(e,t){t.disableHighlightStyle(),Xe(t.table,(t=>{t.highlighted=!0,Ve(e,t);}));}const $e=(e,t,n,o,r)=>{const l="forward"===r;switch(r){case"backward":case"forward":return n!==(l?e.table.columns-1:0)?Ge(t.getCellNodeFromCordsOrThrow(n+(l?1:-1),o,e.table),l):o!==(l?e.table.rows-1:0)?Ge(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?Ge(t.getCellNodeFromCordsOrThrow(n,o-1,e.table),!1):t.selectPrevious(),!0;case"down":return o!==e.table.rows-1?Ge(t.getCellNodeFromCordsOrThrow(n,o+1,e.table),!0):t.selectNext(),!0;default:return !1}},je=(e,t,n,o,r)=>{const l="forward"===r;switch(r){case"backward":case"forward":return n!==(l?e.table.columns-1:0)&&e.setFocusCellForSelection(t.getDOMCellFromCordsOrThrow(n+(l?1:-1),o,e.table)),!0;case"up":return 0!==o&&(e.setFocusCellForSelection(t.getDOMCellFromCordsOrThrow(n,o-1,e.table)),!0);case"down":return o!==e.table.rows-1&&(e.setFocusCellForSelection(t.getDOMCellFromCordsOrThrow(n,o+1,e.table)),!0);default:return !1}};function qe(e,t){if(lexical.$isRangeSelection(e)||Ae(e)){const n=t.isParentOf(e.anchor.getNode()),o=t.isParentOf(e.focus.getNode());return n&&o}return !1}function Ge(e,t){t?e.selectStart():e.selectEnd();}const Qe="172,206,247";function Ve(e,t){const n=t.elem,o=lexical.$getNearestNodeFromDOMNode(n);te(o)||ce(131);null===o.getBackgroundColor()?n.style.setProperty("background-color",`rgb(${Qe})`):n.style.setProperty("background-image",`linear-gradient(to right, rgba(${Qe},0.85), rgba(${Qe},0.85))`),n.style.setProperty("caret-color","transparent");}function Ze(e,t){const n=t.elem,o=lexical.$getNearestNodeFromDOMNode(n);te(o)||ce(131);null===o.getBackgroundColor()&&n.style.removeProperty("background-color"),n.style.removeProperty("background-image"),n.style.removeProperty("caret-color");}function et(e){const n=LexicalUtils.$findMatchingParent(e,te);return te(n)?n:null}function tt(e){const n=LexicalUtils.$findMatchingParent(e,dt);return dt(n)?n:null}function nt(e,n,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=lexical.$getSelection();if(!qe(s,r)){if(lexical.$isRangeSelection(s)){if(s.isCollapsed()&&"backward"===o){const e=s.anchor.type,o=s.anchor.offset;if("element"!==e&&("text"!==e||0!==o))return !1;const r=s.anchor.getNode();if(!r)return !1;const l=LexicalUtils.$findMatchingParent(r,(e=>lexical.$isElementNode(e)&&!e.isInline()));if(!l)return !1;const c=l.getPreviousSibling();return !(!c||!dt(c))&&(ot(n),c.selectEnd(),!0)}if(n.shiftKey&&("up"===o||"down"===o)){const e=s.focus.getNode();if(lexical.$isRootOrShadowRoot(e)){const e=s.getNodes()[0];if(e){const n=LexicalUtils.$findMatchingParent(e,te);if(n&&r.isParentOf(n)){const e=r.getFirstDescendant(),t=r.getLastDescendant();if(!e||!t)return !1;const[n]=Ke(e),[o]=Ke(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}{const n=LexicalUtils.$findMatchingParent(e,(e=>lexical.$isElementNode(e)&&!e.isInline()));if(!n)return !1;const r="down"===o?n.getNextSibling():n.getPreviousSibling();if(dt(r)&&l.tableNodeKey===r.getKey()){const e=r.getFirstDescendant(),t=r.getLastDescendant();if(!e||!t)return !1;const[n]=Ke(e),[l]=Ke(t),i=s.clone();return i.focus.set(("up"===o?n:l).getKey(),"up"===o?0:l.getChildrenSize(),"element"),lexical.$setSelection(i),!0}}}}return !1}if(lexical.$isRangeSelection(s)&&s.isCollapsed()){const{anchor:c,focus:a}=s,d=LexicalUtils.$findMatchingParent(c.getNode(),te),u=LexicalUtils.$findMatchingParent(a.getNode(),te);if(!te(d)||!d.is(u))return !1;const h=tt(d);if(h!==r&&null!=h){const t=e.getElementByKey(h.getKey());if(null!=t)return l.table=ze(t),nt(e,n,o,h,l)}if("backward"===o||"forward"===o){const e=c.type,l=c.offset,a=c.getNode();if(!a)return !1;const d=s.getNodes();return (1!==d.length||!lexical.$isDecoratorNode(d[0]))&&(!!function(e,n,o,r){return function(e,t,n){return "element"===e&&("backward"===n?null===t.getPreviousSibling():null===t.getNextSibling())}(e,o,r)||function(e,n,o,r){const l=LexicalUtils.$findMatchingParent(o,(e=>lexical.$isElementNode(e)&&!e.isInline()));if(!l)return !1;const s="backward"===r?0===n:n===o.getTextContentSize();return "text"===e&&s&&("backward"===r?null===l.getPreviousSibling():null===l.getNextSibling())}(e,n,o,r)}(e,l,a,o)&&function(e,n,o,r){const l=LexicalUtils.$findMatchingParent(n,te);if(!te(l))return !1;const[s,c]=Me(o,l,l);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,c,r))return !1;const a=function(e,n,o){const r=LexicalUtils.$findMatchingParent(e,(e=>lexical.$isElementNode(e)&&!e.isInline()));if(!r)return;const l="backward"===n?r.getPreviousSibling():r.getNextSibling();return l&&dt(l)?l:"backward"===n?o.getPreviousSibling():o.getNextSibling()}(n,r,o);if(!a||dt(a))return !1;ot(e),"backward"===r?a.selectEnd():a.selectStart();return !0}(n,a,r,o))}const g=e.getElementByKey(d.__key),f=e.getElementByKey(c.key);if(null==f||null==g)return !1;let m;if("element"===c.type)m=f.getBoundingClientRect();else {const e=window.getSelection();if(null===e||0===e.rangeCount)return !1;m=e.getRangeAt(0).getBoundingClientRect();}const p="up"===o?d.getFirstChild():d.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){ot(n);const e=r.getCordsFromCellNode(d,l.table);if(!n.shiftKey)return $e(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(Ae(s)){const{anchor:i,focus:c}=s,a=LexicalUtils.$findMatchingParent(i.getNode(),te),d=LexicalUtils.$findMatchingParent(c.getNode(),te),[u]=s.getNodes(),h=e.getElementByKey(u.getKey());if(!te(a)||!te(d)||!dt(u)||null==h)return !1;l.updateTableTableSelection(s);const g=ze(h),f=r.getCordsFromCellNode(a,g),m=r.getDOMCellFromCordsOrThrow(f.x,f.y,g);if(l.setAnchorCellForSelection(m),ot(n),n.shiftKey){const e=r.getCordsFromCellNode(d,g);return je(l,u,e.x,e.y,o)}return d.selectEnd(),!0}return !1}function ot(e){e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation();}function rt(e,t,n){const o=lexical.$createParagraphNode();"first"===e?t.insertBefore(o):t.insertAfter(o),o.append(...n||[]),o.selectEnd();}function lt(e,n,o){const r=o.getParent();if(!r)return;const l=e.getElementByKey(r.getKey());if(!l)return;const s=window.getSelection();if(!s||s.anchorNode!==l)return;const i=LexicalUtils.$findMatchingParent(n.anchor.getNode(),(e=>te(e)));if(!i)return;const c=LexicalUtils.$findMatchingParent(i,(e=>dt(e)));if(!dt(c)||!c.is(o))return;const[a,d]=Me(o,i,i),u=a[0][0],h=a[a.length-1][a[0].length-1],{startRow:g,startColumn:f}=d,m=g===u.startRow&&f===u.startColumn,p=g===h.startRow&&f===h.startColumn;return m?"first":p?"last":void 0}class st extends lexical.ElementNode{static getType(){return "table"}static clone(e){return new st(e.__key)}static importDOM(){return {table:e=>({conversion:ct,priority:1})}}static importJSON(e){return at()}constructor(e){super(e);}exportJSON(){return {...super.exportJSON(),type:"table",version:1}}createDOM(t,n){const o=document.createElement("table");return LexicalUtils.addClassNamesToElement(o,t.theme.table),o}updateDOM(){return !1}exportDOM(e){return {...super.exportDOM(e),after:e=>{if(e){const t=e.cloneNode(),n=document.createElement("colgroup"),o=document.createElement("tbody");LexicalUtils.isHTMLElement(e)&&o.append(...e.children);const l=this.getFirstChildOrThrow();if(!se(l))throw new Error("Expected to find row node.");const s=l.getChildrenSize();for(let e=0;e<s;e++){const e=document.createElement("col");n.append(e);}return t.replaceChildren(n,o),t}}}}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)continue;const r=n.findIndex((t=>{if(!t)return;const{elem:n}=t;return lexical.$getNearestNodeFromDOMNode(n)===e}));if(-1!==r)return {x:r,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=lexical.$getNearestNodeFromDOMNode(o.elem);return te(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}canSelectBefore(){return !0}canIndent(){return !1}}function it(e,t){const n=e.getElementByKey(t.getKey());if(null==n)throw new Error("Table Element Not Found");return ze(n)}function ct(e){return {node:at()}}function at(){return lexical.$applyNodeReplacement(new st)}function dt(e){return e instanceof st}
|
|
16
|
-
|
|
17
|
-
exports.$computeTableMap = Me;
|
|
18
|
-
exports.$computeTableMapSkipCellCheck = Re;
|
|
19
|
-
exports.$createTableCellNode = ee;
|
|
20
|
-
exports.$createTableNode = at;
|
|
21
|
-
exports.$createTableNodeWithDimensions = de;
|
|
22
|
-
exports.$createTableRowNode = le;
|
|
23
|
-
exports.$createTableSelection = He;
|
|
24
|
-
exports.$deleteTableColumn = Ne;
|
|
25
|
-
exports.$deleteTableColumn__EXPERIMENTAL = xe;
|
|
26
|
-
exports.$deleteTableRow__EXPERIMENTAL = Te;
|
|
27
|
-
exports.$findCellNode = et;
|
|
28
|
-
exports.$findTableNode = tt;
|
|
29
|
-
exports.$getElementForTableNode = it;
|
|
30
|
-
exports.$getNodeTriplet = Ke;
|
|
31
|
-
exports.$getTableCellNodeFromLexicalNode = ue;
|
|
32
|
-
exports.$getTableCellNodeRect = Fe;
|
|
33
|
-
exports.$getTableColumnIndexFromTableCellNode = me;
|
|
34
|
-
exports.$getTableNodeFromLexicalNodeOrThrow = ge;
|
|
35
|
-
exports.$getTableRowIndexFromTableCellNode = fe;
|
|
36
|
-
exports.$getTableRowNodeFromTableCellNodeOrThrow = he;
|
|
37
|
-
exports.$insertTableColumn = be;
|
|
38
|
-
exports.$insertTableColumn__EXPERIMENTAL = ye;
|
|
39
|
-
exports.$insertTableRow = Se;
|
|
40
|
-
exports.$insertTableRow__EXPERIMENTAL = we;
|
|
41
|
-
exports.$isTableCellNode = te;
|
|
42
|
-
exports.$isTableNode = dt;
|
|
43
|
-
exports.$isTableRowNode = se;
|
|
44
|
-
exports.$isTableSelection = Ae;
|
|
45
|
-
exports.$removeTableRowAtIndex = Ce;
|
|
46
|
-
exports.$unmergeCell = Oe;
|
|
47
|
-
exports.INSERT_TABLE_COMMAND = ne;
|
|
48
|
-
exports.TableCellHeaderStates = Q;
|
|
49
|
-
exports.TableCellNode = V;
|
|
50
|
-
exports.TableNode = st;
|
|
51
|
-
exports.TableObserver = Pe;
|
|
52
|
-
exports.TableRowNode = oe;
|
|
53
|
-
exports.applyTableHandlers = Ie;
|
|
54
|
-
exports.getDOMCellFromTarget = Ue;
|
|
55
|
-
exports.getTableObserverFromTableElement = We;
|