Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@lexical/table

Package Overview
Dependencies
Maintainers
5
Versions
238
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lexical/table - npm Package Compare versions

Comparing version 0.21.1-nightly.20241220.0 to 0.21.1-nightly.20241223.0

20

LexicalTable.prod.js

@@ -47,4 +47,4 @@ /**

a.x;this.anchorY=a.y;let {tableNode:b}=this.$lookup();a=U(b,v.$getNearestNodeFromDOMNode(a.elem,void 0));null!==a&&(a=a.getKey(),this.tableSelection=null!=this.tableSelection?this.tableSelection.clone():xa(),this.anchorCellNodeKey=a)}$formatCells(a){let b=v.$getSelection();R(b)||E(236);let c=v.$createRangeSelection(),d=c.anchor,f=c.focus,e=b.getNodes().filter(C);0<e.length||E(237);let g=e[0].getFirstChild(),n=v.$isParagraphNode(g)?g.getFormatFlags(a,null):null;e.forEach(r=>{d.set(r.getKey(),0,"element");
f.set(r.getKey(),r.getChildrenSize(),"element");c.formatText(a,n)});v.$setSelection(b);this.editor.dispatchCommand(v.SELECTION_CHANGE_COMMAND,void 0)}$clearText(){let {editor:a}=this,b=v.$getNodeByKey(this.tableNodeKey);if(!L(b))throw Error("Expected TableNode.");var c=v.$getSelection();R(c)||E(253);c=c.getNodes().filter(C);c.length===this.table.columns*this.table.rows?(b.selectPrevious(),b.remove(),v.$getRoot().selectStart()):(c.forEach(d=>{if(v.$isElementNode(d)){let f=v.$createParagraphNode(),
e=v.$createTextNode();f.append(e);d.append(f);d.getChildren().forEach(g=>{g!==f&&g.remove()})}}),Aa(a,this.table,null),v.$setSelection(null),a.dispatchCommand(v.SELECTION_CHANGE_COMMAND,void 0))}}function S(a,b){if(!b)return b;a="TABLE"===b.nodeName?b:a.getDOMSlot(b).element;"TABLE"!==a.nodeName&&E(245,b.nodeName);return a}function U(a,b){for(let c=b,d=null;null!==c;c=c.getParent()){if(a.is(c))return d;C(c)&&(d=c)}return null}
f.set(r.getKey(),r.getChildrenSize(),"element");c.formatText(a,n)});v.$setSelection(b);this.editor.dispatchCommand(v.SELECTION_CHANGE_COMMAND,void 0)}$clearText(){let {editor:a}=this,b=v.$getNodeByKey(this.tableNodeKey);if(!L(b))throw Error("Expected TableNode.");var c=v.$getSelection();R(c)||E(255);c=c.getNodes().filter(C);c.length===this.table.columns*this.table.rows?(b.selectPrevious(),b.remove()):(c.forEach(d=>{if(v.$isElementNode(d)){let f=v.$createParagraphNode(),e=v.$createTextNode();f.append(e);
d.append(f);d.getChildren().forEach(g=>{g!==f&&g.remove()})}}),Aa(a,this.table,null),v.$setSelection(null),a.dispatchCommand(v.SELECTION_CHANGE_COMMAND,void 0))}}function S(a,b){if(!b)return b;a="TABLE"===b.nodeName?b:a.getDOMSlot(b).element;"TABLE"!==a.nodeName&&E(245,b.nodeName);return a}function U(a,b){for(let c=b,d=null;null!==c;c=c.getParent()){if(a.is(c))return d;C(c)&&(d=c)}return null}
let Ba=[[v.KEY_ARROW_DOWN_COMMAND,"down"],[v.KEY_ARROW_UP_COMMAND,"up"],[v.KEY_ARROW_LEFT_COMMAND,"backward"],[v.KEY_ARROW_RIGHT_COMMAND,"forward"]],Ca=[v.DELETE_WORD_COMMAND,v.DELETE_LINE_COMMAND,v.DELETE_CHARACTER_COMMAND],Da=[v.KEY_BACKSPACE_COMMAND,v.KEY_DELETE_COMMAND];

@@ -56,8 +56,8 @@ function Ea(a,b,c,d){let f=c.getRootElement(),e=c._window;null!==f&&null!==e||E(246);let g=new za(c,a.getKey()),n=S(a,b);Fa(n,g);g.listenersToRemove.add(()=>{Ga(n)===g&&delete n.__lexicalTableSelection});let r=()=>{if(!g.isSelecting){var l=()=>{g.isSelecting=!1;e.removeEventListener("mouseup",l);e.removeEventListener("mousemove",k)},k=m=>{if(v.isDOMNode(m.target))if(1!==(m.buttons&1)&&g.isSelecting)g.isSelecting=!1,e.removeEventListener("mouseup",l),e.removeEventListener("mousemove",k);else{var q=

!0;if(v.$isRangeSelection(k)){var m=U(a,k.anchor.getNode());if(!C(m))return!1;var q=k.anchor.getNode();m=k.focus.getNode();q=a.isParentOf(q);m=a.isParentOf(m);if(q&&!m||m&&!q)return g.$clearText(),!0;m=(k=h.$findMatchingParent(k.anchor.getNode(),u=>v.$isElementNode(u)))&&h.$findMatchingParent(k,u=>v.$isElementNode(u)&&C(u.getParent()));if(!v.$isElementNode(m)||!v.$isElementNode(k))return!1;if(l===v.DELETE_LINE_COMMAND&&null===m.getPreviousSibling())return!0}return!1};for(let l of Ca)g.listenersToRemove.add(c.registerCommand(l,
b(l),v.COMMAND_PRIORITY_CRITICAL));let p=l=>{const k=v.$getSelection();if(!R(k)&&!v.$isRangeSelection(k))return!1;const m=a.isParentOf(k.anchor.getNode()),q=a.isParentOf(k.focus.getNode());if(m!==q){l=m?"focus":"anchor";const {key:u,offset:t,type:w}=k[l];a[k[m?"anchor":"focus"].isBefore(k[l])?"selectPrevious":"selectNext"]()[l].set(u,t,w);return!1}return R(k)?(l&&(l.preventDefault(),l.stopPropagation()),g.$clearText(),!0):!1};for(let l of Da)g.listenersToRemove.add(c.registerCommand(l,p,v.COMMAND_PRIORITY_CRITICAL));
g.listenersToRemove.add(c.registerCommand(v.CUT_COMMAND,l=>{let k=v.$getSelection();if(k){if(!R(k)&&!v.$isRangeSelection(k))return!1;void aa.copyToClipboard(c,h.objectKlassEquals(l,ClipboardEvent)?l:null,aa.$getClipboardDataFromSelection(k));l=p(l);return v.$isRangeSelection(k)?(k.removeText(),!0):l}return!1},v.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(v.FORMAT_TEXT_COMMAND,l=>{let k=v.$getSelection();if(!V(k,a))return!1;if(R(k))return g.$formatCells(l),!0;v.$isRangeSelection(k)&&
(l=h.$findMatchingParent(k.anchor.getNode(),m=>C(m)),C(l));return!1},v.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(v.FORMAT_ELEMENT_COMMAND,l=>{var k=v.$getSelection();if(!R(k)||!V(k,a))return!1;var m=k.anchor.getNode();k=k.focus.getNode();if(!C(m)||!C(k))return!1;let [q,u,t]=O(a,m,k);m=Math.max(u.startRow+u.cell.__rowSpan-1,t.startRow+t.cell.__rowSpan-1);k=Math.max(u.startColumn+u.cell.__colSpan-1,t.startColumn+t.cell.__colSpan-1);var w=Math.min(u.startRow,t.startRow);let D=
Math.min(u.startColumn,t.startColumn),z=new Set;for(;w<=m;w++)for(let G=D;G<=k;G++){var A=q[w][G].cell;if(!z.has(A)){z.add(A);A.setFormat(l);A=A.getChildren();for(let H=0;H<A.length;H++){let N=A[H];v.$isElementNode(N)&&!N.isInline()&&N.setFormat(l)}}}return!0},v.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(v.CONTROLLED_TEXT_INSERTION_COMMAND,l=>{var k=v.$getSelection();if(!V(k,a))return!1;if(R(k))g.$clearHighlight();else if(v.$isRangeSelection(k)){let m=h.$findMatchingParent(k.anchor.getNode(),
q=>C(q));if(!C(m))return!1;if("string"===typeof l&&(k=Ja(c,k,a)))return La(k,a,[v.$createTextNode(l)]),!0}return!1},v.COMMAND_PRIORITY_CRITICAL));d&&g.listenersToRemove.add(c.registerCommand(v.KEY_TAB_COMMAND,l=>{var k=v.$getSelection();if(!v.$isRangeSelection(k)||!k.isCollapsed()||!V(k,a))return!1;var m=Ma(k.anchor.getNode());if(null===m||!a.is(Na(m)))return!1;X(l);a:{l=l.shiftKey?"previous":"next";k="next"===l?"getNextSibling":"getPreviousSibling";let u="next"===l?"getFirstChild":"getLastChild";
var q=m[k]();if(v.$isElementNode(q))q.selectEnd();else{m=h.$findMatchingParent(m,K);null===m&&E(247);for(q=m[k]();K(q);q=q[k]()){let t=q[u]();if(v.$isElementNode(t)){t.selectEnd();break a}}k=h.$findMatchingParent(m,L);null===k&&E(248);"next"===l?k.selectNext():k.selectPrevious()}}return!0},v.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(v.FOCUS_COMMAND,()=>a.isSelected(),v.COMMAND_PRIORITY_HIGH));g.listenersToRemove.add(c.registerCommand(v.SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,
b(l),v.COMMAND_PRIORITY_CRITICAL));let p=l=>{const k=v.$getSelection();if(!R(k)&&!v.$isRangeSelection(k))return!1;const m=a.isParentOf(k.anchor.getNode()),q=a.isParentOf(k.focus.getNode());if(m!==q){l=m?"focus":"anchor";const {key:u,offset:t,type:w}=k[l];a[k[m?"anchor":"focus"].isBefore(k[l])?"selectPrevious":"selectNext"]()[l].set(u,t,w);return!1}return V(k,a)?R(k)?(l&&(l.preventDefault(),l.stopPropagation()),g.$clearText(),!0):!1:!1};for(let l of Da)g.listenersToRemove.add(c.registerCommand(l,p,
v.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(v.CUT_COMMAND,l=>{let k=v.$getSelection();if(k){if(!R(k)&&!v.$isRangeSelection(k))return!1;void aa.copyToClipboard(c,h.objectKlassEquals(l,ClipboardEvent)?l:null,aa.$getClipboardDataFromSelection(k));l=p(l);return v.$isRangeSelection(k)?(k.removeText(),!0):l}return!1},v.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(v.FORMAT_TEXT_COMMAND,l=>{let k=v.$getSelection();if(!V(k,a))return!1;if(R(k))return g.$formatCells(l),
!0;v.$isRangeSelection(k)&&(l=h.$findMatchingParent(k.anchor.getNode(),m=>C(m)),C(l));return!1},v.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(v.FORMAT_ELEMENT_COMMAND,l=>{var k=v.$getSelection();if(!R(k)||!V(k,a))return!1;var m=k.anchor.getNode();k=k.focus.getNode();if(!C(m)||!C(k))return!1;let [q,u,t]=O(a,m,k);m=Math.max(u.startRow+u.cell.__rowSpan-1,t.startRow+t.cell.__rowSpan-1);k=Math.max(u.startColumn+u.cell.__colSpan-1,t.startColumn+t.cell.__colSpan-1);var w=Math.min(u.startRow,
t.startRow);let D=Math.min(u.startColumn,t.startColumn),z=new Set;for(;w<=m;w++)for(let G=D;G<=k;G++){var A=q[w][G].cell;if(!z.has(A)){z.add(A);A.setFormat(l);A=A.getChildren();for(let H=0;H<A.length;H++){let N=A[H];v.$isElementNode(N)&&!N.isInline()&&N.setFormat(l)}}}return!0},v.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(v.CONTROLLED_TEXT_INSERTION_COMMAND,l=>{var k=v.$getSelection();if(!V(k,a))return!1;if(R(k))g.$clearHighlight();else if(v.$isRangeSelection(k)){let m=
h.$findMatchingParent(k.anchor.getNode(),q=>C(q));if(!C(m))return!1;if("string"===typeof l&&(k=Ja(c,k,a)))return La(k,a,[v.$createTextNode(l)]),!0}return!1},v.COMMAND_PRIORITY_CRITICAL));d&&g.listenersToRemove.add(c.registerCommand(v.KEY_TAB_COMMAND,l=>{var k=v.$getSelection();if(!v.$isRangeSelection(k)||!k.isCollapsed()||!V(k,a))return!1;var m=Ma(k.anchor.getNode());if(null===m||!a.is(Na(m)))return!1;X(l);a:{l=l.shiftKey?"previous":"next";k="next"===l?"getNextSibling":"getPreviousSibling";let u=
"next"===l?"getFirstChild":"getLastChild";var q=m[k]();if(v.$isElementNode(q))q.selectEnd();else{m=h.$findMatchingParent(m,K);null===m&&E(247);for(q=m[k]();K(q);q=q[k]()){let t=q[u]();if(v.$isElementNode(t)){t.selectEnd();break a}}k=h.$findMatchingParent(m,L);null===k&&E(248);"next"===l?k.selectNext():k.selectPrevious()}}return!0},v.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(v.FOCUS_COMMAND,()=>a.isSelected(),v.COMMAND_PRIORITY_HIGH));g.listenersToRemove.add(c.registerCommand(v.SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,
l=>{let {nodes:k,selection:m}=l;l=m.getStartEndPoints();var q=R(m);q=v.$isRangeSelection(m)&&null!==h.$findMatchingParent(m.anchor.getNode(),H=>C(H))&&null!==h.$findMatchingParent(m.focus.getNode(),H=>C(H))||q;if(1!==k.length||!L(k[0])||!q||null===l)return!1;var [u]=l,t=k[0];l=t.getChildren();q=t.getFirstChildOrThrow().getChildrenSize();t=t.getChildrenSize();var w=h.$findMatchingParent(u.getNode(),H=>C(H)),D=w&&h.$findMatchingParent(w,H=>K(H)),z=D&&h.$findMatchingParent(D,H=>L(H));if(!C(w)||!K(D)||

@@ -104,3 +104,3 @@ !L(z))return!1;u=D.getIndexWithinParent();var A=Math.min(z.getChildrenSize()-1,u+t-1);t=w.getIndexWithinParent();w=Math.min(D.getChildrenSize()-1,t+q-1);q=Math.min(t,w);D=Math.min(u,A);t=Math.max(t,w);u=Math.max(u,A);z=z.getChildren();for(A=0;D<=u;D++){w=z[D];if(!K(w))return!1;var G=l[A];if(!K(G))return!1;w=w.getChildren();G=G.getChildren();let H=0;for(let N=q;N<=t;N++){let P=w[N];if(!C(P))return!1;let Ka=G[H];if(!C(Ka))return!1;let Ya=P.getChildren();Ka.getChildren().forEach(ca=>{v.$isTextNode(ca)&&

function L(a){return a instanceof Z}function ib({rows:a,columns:b,includeHeaders:c}){a=ka(Number(a),Number(b),c);h.$insertNodeToNearestRoot(a);a=a.getFirstDescendant();v.$isTextNode(a)&&a.select();return!0}function jb(a){K(a.getParent())?a.isEmpty()&&a.append(v.$createParagraphNode()):a.remove()}function kb(a){L(a.getParent())?h.$unwrapAndFilterDescendants(a,C):a.remove()}
function lb(a){h.$unwrapAndFilterDescendants(a,K);let [b]=ra(a,null,null),c=b.reduce((f,e)=>Math.max(f,e.length),0);a=a.getChildren();for(let f=0;f<b.length;++f){let e=a[f];if(e){K(e)||E(254,e.constructor.name,e.getType());var d=b[f].reduce((g,n)=>n?1+g:g,0);if(d!==c)for(;d<c;++d){let g=B();g.append(v.$createParagraphNode());e.append(g)}}}}exports.$computeTableMap=O;exports.$computeTableMapSkipCellCheck=ra;exports.$createTableCellNode=B;exports.$createTableNode=la;
function lb(a){h.$unwrapAndFilterDescendants(a,K);let [b]=ra(a,null,null),c=b.reduce((f,e)=>Math.max(f,e.length),0);a=a.getChildren();for(let f=0;f<b.length;++f){let e=a[f];if(e){K(e)||E(253,e.constructor.name,e.getType());var d=b[f].reduce((g,n)=>n?1+g:g,0);if(d!==c)for(;d<c;++d){let g=B();g.append(v.$createParagraphNode());e.append(g)}}}}exports.$computeTableMap=O;exports.$computeTableMapSkipCellCheck=ra;exports.$createTableCellNode=B;exports.$createTableNode=la;
exports.$createTableNodeWithDimensions=ka;exports.$createTableRowNode=J;exports.$createTableSelection=xa;exports.$deleteTableColumn=function(a,b){let c=a.getChildren();for(let f=0;f<c.length;f++){var d=c[f];if(K(d)){d=d.getChildren();if(b>=d.length||0>b)throw Error("Table column target index out of range");d[b].remove()}}return a};

@@ -126,4 +126,4 @@ exports.$deleteTableColumn__EXPERIMENTAL=function(){var a=v.$getSelection();v.$isRangeSelection(a)||R(a)||E(188);var b=a.anchor.getNode();a=a.focus.getNode();let [c,,d]=Q(b);var [f]=Q(a);let [e,g,n]=O(d,c,f);var {startColumn:r}=g;let {startRow:p,startColumn:l}=n;b=Math.min(r,l);var k=Math.max(r+c.__colSpan-1,l+f.__colSpan-1);a=k-b+1;if(e[0].length===k-b+1)d.selectPrevious(),d.remove();else{var m=e.length;for(let q=0;q<m;q++)for(let u=b;u<=k;u++){let {cell:t,startColumn:w}=e[q][u];w<b?u===b&&t.setColSpan(t.__colSpan-

exports.registerTableCellUnmergeTransform=function(a){return a.registerNodeTransform(y,b=>{if(1<b.getColSpan()||1<b.getRowSpan()){var [,,c]=Q(b);[b]=O(c,b,b);let f=b.length,e=b[0].length;c=c.getFirstChild();K(c)||E(175);let g=[];for(let n=0;n<f;n++){0!==n&&(c=c.getNextSibling(),K(c)||E(175));let r=null;for(let p=0;p<e;p++){var d=b[n][p];let l=d.cell;if(d.startRow===n&&d.startColumn===p)r=l,g.push(l);else if(1<l.getColSpan()||1<l.getRowSpan())C(l)||E(176),d=B(l.__headerState),null!==r?r.insertAfter(d):
h.$insertFirst(c,d)}}for(let n of g)n.setColSpan(1),n.setRowSpan(1)}})};exports.registerTablePlugin=function(a){a.hasNodes([Z])||E(255);return h.mergeRegister(a.registerCommand(ea,ib,v.COMMAND_PRIORITY_EDITOR),a.registerNodeTransform(Z,lb),a.registerNodeTransform(I,kb),a.registerNodeTransform(y,jb))};
h.$insertFirst(c,d)}}for(let n of g)n.setColSpan(1),n.setRowSpan(1)}})};exports.registerTablePlugin=function(a){a.hasNodes([Z])||E(254);return h.mergeRegister(a.registerCommand(ea,ib,v.COMMAND_PRIORITY_EDITOR),a.registerNodeTransform(Z,lb),a.registerNodeTransform(I,kb),a.registerNodeTransform(y,jb))};
exports.registerTableSelectionObserver=function(a,b=!0){let c=new Map,d=(e,g,n)=>{n=S(e,n);e=Ea(e,n,a,b);c.set(g,[e,n])},f=a.registerMutationListener(Z,e=>{a.getEditorState().read(()=>{for(const [g,n]of e){const r=c.get(g);if("created"===n||"updated"===n){const {tableNode:p,tableElement:l}=ya(g);void 0===r?d(p,g,l):l!==r[1]&&(r[0].removeListeners(),c.delete(g),d(p,g,l))}else"destroyed"===n&&void 0!==r&&(r[0].removeListeners(),c.delete(g))}},{editor:a})},{skipInitialization:!1});return()=>{f();for(let [,
[e]]of c)e.removeListeners()}};exports.setScrollableTablesActive=function(a,b){b?gb.add(a):gb.delete(a)}

@@ -11,9 +11,9 @@ {

"license": "MIT",
"version": "0.21.1-nightly.20241220.0",
"version": "0.21.1-nightly.20241223.0",
"main": "LexicalTable.js",
"types": "index.d.ts",
"dependencies": {
"@lexical/clipboard": "0.21.1-nightly.20241220.0",
"@lexical/utils": "0.21.1-nightly.20241220.0",
"lexical": "0.21.1-nightly.20241220.0"
"@lexical/clipboard": "0.21.1-nightly.20241223.0",
"@lexical/utils": "0.21.1-nightly.20241223.0",
"lexical": "0.21.1-nightly.20241223.0"
},

@@ -20,0 +20,0 @@ "repository": {

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc