@lexical/table
Advanced tools
Comparing version 0.17.2-nightly.20240924.0 to 0.17.2-nightly.20240925.0
@@ -22,5 +22,5 @@ /** | ||
function ha(a){a=h.$findMatchingParent(a,b=>K(b));if(K(a))return a;throw Error("Expected table cell to be inside of table row.");}function ia(a){a=h.$findMatchingParent(a,b=>M(b));if(M(a))return a;throw Error("Expected table cell to be inside of table.");}function ja(a,b){let c=ia(a),{x:d,y:e}=c.getCordsFromCellNode(a,b);return{above:c.getCellNodeFromCords(d,e-1,b),below:c.getCellNodeFromCords(d,e+1,b),left:c.getCellNodeFromCords(d-1,e,b),right:c.getCellNodeFromCords(d+1,e,b)}} | ||
let ka=(a,b)=>a===x.BOTH||a===b?b:x.NO_STATUS;function N(a){let b=a.getFirstDescendant();null==b?a.selectStart():b.getParentOrThrow().selectStart()}function la(a,b){let c=a.getFirstChild();null!==c?c.insertBefore(b):a.append(b)}function O(a,b,c){let [d,e,f]=ma(a,b,c);null===e&&E(206);null===f&&E(207);return[d,e,f]} | ||
function ma(a,b,c){function d(p){let t=e[p];void 0===t&&(e[p]=t=[]);return t}let e=[],f=null,g=null;a=a.getChildren();for(let p=0;p<a.length;p++){var m=a[p];K(m)||E(208);for(let t=m.getFirstChild(),u=0;null!=t;t=t.getNextSibling()){C(t)||E(147);for(m=d(p);void 0!==m[u];)u++;m={cell:t,startColumn:u,startRow:p};let {__rowSpan:k,__colSpan:l}=t;for(let n=0;n<k&&!(p+n>=a.length);n++){let r=d(p+n);for(let q=0;q<l;q++)r[u+q]=m}null!==b&&null===f&&b.is(t)&&(f=m);null!==c&&null===g&&c.is(t)&&(g=m)}}return[e, | ||
f,g]}function P(a){a instanceof y||("__type"in a?(a=h.$findMatchingParent(a,C),C(a)||E(148)):(a=h.$findMatchingParent(a.getNode(),C),C(a)||E(148)));let b=a.getParent();K(b)||E(149);let c=b.getParent();M(c)||E(209);return[a,b,c]} | ||
let ka=(a,b)=>a===x.BOTH||a===b?b:x.NO_STATUS;function N(a){let b=a.getFirstDescendant();null==b?a.selectStart():b.getParentOrThrow().selectStart()}function la(a,b){let c=a.getFirstChild();null!==c?c.insertBefore(b):a.append(b)}function O(a,b,c){let [d,e,f]=ma(a,b,c);null===e&&E(207);null===f&&E(208);return[d,e,f]} | ||
function ma(a,b,c){function d(p){let t=e[p];void 0===t&&(e[p]=t=[]);return t}let e=[],f=null,g=null;a=a.getChildren();for(let p=0;p<a.length;p++){var m=a[p];K(m)||E(209);for(let t=m.getFirstChild(),u=0;null!=t;t=t.getNextSibling()){C(t)||E(147);for(m=d(p);void 0!==m[u];)u++;m={cell:t,startColumn:u,startRow:p};let {__rowSpan:k,__colSpan:l}=t;for(let n=0;n<k&&!(p+n>=a.length);n++){let r=d(p+n);for(let q=0;q<l;q++)r[u+q]=m}null!==b&&null===f&&b.is(t)&&(f=m);null!==c&&null===g&&c.is(t)&&(g=m)}}return[e, | ||
f,g]}function P(a){a instanceof y||("__type"in a?(a=h.$findMatchingParent(a,C),C(a)||E(148)):(a=h.$findMatchingParent(a.getNode(),C),C(a)||E(148)));let b=a.getParent();K(b)||E(149);let c=b.getParent();M(c)||E(210);return[a,b,c]} | ||
function oa(a){let [b,,c]=P(a);a=c.getChildren();let d=a.length;var e=a[0].getChildren().length;let f=Array(d);for(var g=0;g<d;g++)f[g]=Array(e);for(e=0;e<d;e++){g=a[e].getChildren();let m=0;for(let p=0;p<g.length;p++){for(;f[e][m];)m++;let t=g[p],u=t.__rowSpan||1,k=t.__colSpan||1;for(let l=0;l<u;l++)for(let n=0;n<k;n++)f[e+l][m+n]=t;if(b===t)return{colSpan:k,columnIndex:m,rowIndex:e,rowSpan:u};m+=k}}return null} | ||
@@ -43,3 +43,3 @@ class pa{constructor(a,b,c){this.anchor=b;this.focus=c;b._selection=this;c._selection=this;this._cachedNodes=null;this.dirty=!1;this.tableKey=a}getStartEndPoints(){return[this.anchor,this.focus]}isBackward(){return this.focus.isBefore(this.anchor)}getCachedNodes(){return this._cachedNodes}setCachedNodes(a){this._cachedNodes=a}is(a){return Q(a)?this.tableKey===a.tableKey&&this.anchor.is(a.anchor)&&this.focus.is(a.focus):!1}set(a,b,c){this.dirty=!0;this.tableKey=a;this.anchor.key=b;this.focus.key=c; | ||
0,"element");e.set(p.getKey(),p.getChildrenSize(),"element");c.formatText(a,m)});w.$setSelection(b);this.editor.dispatchCommand(w.SELECTION_CHANGE_COMMAND,void 0)})}clearText(){let a=this.editor;a.update(()=>{let b=w.$getNodeByKey(this.tableNodeKey);if(!M(b))throw Error("Expected TableNode.");var c=w.$getSelection();Q(c)||E(11);c=c.getNodes().filter(C);c.length===this.table.columns*this.table.rows?(b.selectPrevious(),b.remove(),w.$getRoot().selectStart()):(c.forEach(d=>{if(w.$isElementNode(d)){let e= | ||
w.$createParagraphNode(),f=w.$createTextNode();e.append(f);d.append(e);d.getChildren().forEach(g=>{g!==e&&g.remove()})}}),S(a,this.table,null),w.$setSelection(null),a.dispatchCommand(w.SELECTION_CHANGE_COMMAND,void 0))})}}function ta(a,b){null!==ua(a)&&E(210);a.__lexicalTableSelection=b}function ua(a){return a.__lexicalTableSelection||null}function va(a){for(;null!=a;){let b=a.nodeName;if("TD"===b||"TH"===b){a=a._cell;if(void 0===a)break;return a}a=a.parentNode}return null} | ||
w.$createParagraphNode(),f=w.$createTextNode();e.append(f);d.append(e);d.getChildren().forEach(g=>{g!==e&&g.remove()})}}),S(a,this.table,null),w.$setSelection(null),a.dispatchCommand(w.SELECTION_CHANGE_COMMAND,void 0))})}}function ta(a,b){null!==ua(a)&&E(205);a.__lexicalTableSelection=b}function ua(a){return a.__lexicalTableSelection||null}function va(a){for(;null!=a;){let b=a.nodeName;if("TD"===b||"TH"===b){a=a._cell;if(void 0===a)break;return a}a=a.parentNode}return null} | ||
function R(a){let b=[],c={columns:0,domRows:b,rows:0};var d=a.querySelector("tr");let e=a=0;for(b.length=0;null!=d;){var f=d.nodeName;if("TD"===f||"TH"===f){f=d;f={elem:f,hasBackgroundColor:""!==f.style.backgroundColor,highlighted:!1,x:a,y:e};d._cell=f;let g=b[e];void 0===g&&(g=b[e]=[]);g[a]=f}else if(f=d.firstChild,null!=f){d=f;continue}f=d.nextSibling;if(null!=f)a++,d=f;else if(f=d.parentNode,null!=f){d=f.nextSibling;if(null==d)break;e++;a=0}}c.columns=a+1;c.rows=e+1;return c} | ||
@@ -76,3 +76,3 @@ function S(a,b,c){let d=new Set(c?c.getNodes():[]);wa(b,(e,f)=>{let g=e.elem;d.has(f)?(e.highlighted=!0,xa(a,e)):(e.highlighted=!1,ya(a,e),g.getAttribute("style")||g.removeAttribute("style"))})}function wa(a,b){({domRows:a}=a);for(let c=0;c<a.length;c++){let d=a[c];if(d)for(let e=0;e<d.length;e++){let f=d[e];if(!f)continue;let g=w.$getNearestNodeFromDOMNode(f.elem);null!==g&&b(f,g,{x:e,y:c})}}}function za(a,b){b.disableHighlightStyle();wa(b.table,c=>{c.highlighted=!0;xa(a,c)})} | ||
exports.$deleteTableRow__EXPERIMENTAL=function(){var a=w.$getSelection();w.$isRangeSelection(a)||Q(a)||E(188);var b=a.anchor.getNode();a=a.focus.getNode();let [c,,d]=P(b);[a]=P(a);let [e,f,g]=O(d,c,a);({startRow:b}=f);var {startRow:m}=g;a=m+a.__rowSpan-1;if(e.length===a-b+1)d.remove();else{m=e[0].length;var p=e[a+1],t=d.getChildAtIndex(a+1);for(let k=a;k>=b;k--){for(var u=m-1;0<=u;u--){let {cell:l,startRow:n,startColumn:r}=e[k][u];if(r===u&&(k===b&&n<b&&l.setRowSpan(l.__rowSpan-(n-b)),n>=b&&n+l.__rowSpan- | ||
1>a))if(l.setRowSpan(l.__rowSpan-(a-n+1)),null===t&&E(122),0===u)la(t,l);else{let {cell:q}=p[u-1];q.insertAfter(l)}}u=d.getChildAtIndex(k);K(u)||E(205,String(k));u.remove()}void 0!==p?({cell:b}=p[0],N(b)):({cell:b}=e[b-1][0],N(b))}};exports.$findCellNode=X;exports.$findTableNode=T;exports.$getElementForTableNode=function(a,b){a=a.getElementByKey(b.getKey());if(null==a)throw Error("Table Element Not Found");return R(a)};exports.$getNodeTriplet=P; | ||
1>a))if(l.setRowSpan(l.__rowSpan-(a-n+1)),null===t&&E(122),0===u)la(t,l);else{let {cell:q}=p[u-1];q.insertAfter(l)}}u=d.getChildAtIndex(k);K(u)||E(206,String(k));u.remove()}void 0!==p?({cell:b}=p[0],N(b)):({cell:b}=e[b-1][0],N(b))}};exports.$findCellNode=X;exports.$findTableNode=T;exports.$getElementForTableNode=function(a,b){a=a.getElementByKey(b.getKey());if(null==a)throw Error("Table Element Not Found");return R(a)};exports.$getNodeTriplet=P; | ||
exports.$getTableCellNodeFromLexicalNode=function(a){a=h.$findMatchingParent(a,b=>C(b));return C(a)?a:null};exports.$getTableCellNodeRect=oa;exports.$getTableColumnIndexFromTableCellNode=function(a){return ha(a).getChildren().findIndex(b=>b.is(a))};exports.$getTableNodeFromLexicalNodeOrThrow=ia;exports.$getTableRowIndexFromTableCellNode=function(a){let b=ha(a);return ia(b).getChildren().findIndex(c=>c.is(b))};exports.$getTableRowNodeFromTableCellNodeOrThrow=ha; | ||
@@ -79,0 +79,0 @@ exports.$insertTableColumn=function(a,b,c=!0,d,e){let f=a.getChildren(),g=[];for(let t=0;t<f.length;t++){let u=f[t];if(K(u))for(let k=0;k<d;k++){var m=u.getChildren();if(b>=m.length||0>b)throw Error("Table column target index out of range");m=m[b];C(m)||E(12);let {left:l,right:n}=ja(m,e);var p=x.NO_STATUS;if(l&&l.hasHeaderState(x.ROW)||n&&n.hasHeaderState(x.ROW))p|=x.ROW;p=B(p);p.append(w.$createParagraphNode());g.push({newTableCell:p,targetCell:m})}}g.forEach(({newTableCell:t,targetCell:u})=>{c? |
@@ -11,9 +11,9 @@ { | ||
"license": "MIT", | ||
"version": "0.17.2-nightly.20240924.0", | ||
"version": "0.17.2-nightly.20240925.0", | ||
"main": "LexicalTable.js", | ||
"types": "index.d.ts", | ||
"dependencies": { | ||
"@lexical/clipboard": "0.17.2-nightly.20240924.0", | ||
"@lexical/utils": "0.17.2-nightly.20240924.0", | ||
"lexical": "0.17.2-nightly.20240924.0" | ||
"@lexical/clipboard": "0.17.2-nightly.20240925.0", | ||
"@lexical/utils": "0.17.2-nightly.20240925.0", | ||
"lexical": "0.17.2-nightly.20240925.0" | ||
}, | ||
@@ -20,0 +20,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
+ Added@lexical/clipboard@0.17.2-nightly.20240925.0(transitive)
+ Added@lexical/html@0.17.2-nightly.20240925.0(transitive)
+ Added@lexical/list@0.17.2-nightly.20240925.0(transitive)
+ Added@lexical/selection@0.17.2-nightly.20240925.0(transitive)
+ Added@lexical/utils@0.17.2-nightly.20240925.0(transitive)
+ Addedlexical@0.17.2-nightly.20240925.0(transitive)
- Removed@lexical/clipboard@0.17.2-nightly.20240924.0(transitive)
- Removed@lexical/html@0.17.2-nightly.20240924.0(transitive)
- Removed@lexical/list@0.17.2-nightly.20240924.0(transitive)
- Removed@lexical/selection@0.17.2-nightly.20240924.0(transitive)
- Removed@lexical/utils@0.17.2-nightly.20240924.0(transitive)
- Removedlexical@0.17.2-nightly.20240924.0(transitive)