Socket
Socket
Sign inDemoInstall

@lexical/table

Package Overview
Dependencies
Maintainers
5
Versions
184
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.16.1-nightly.20240618.0 to 0.16.1-nightly.20240619.0

2

index.d.ts

@@ -21,3 +21,3 @@ /**

export type { HTMLTableElementWithWithTableSelectionState } from './LexicalTableSelectionHelpers';
export { applyTableHandlers, getDOMCellFromTarget, getTableObserverFromTableElement, } from './LexicalTableSelectionHelpers';
export { $findCellNode, $findTableNode, applyTableHandlers, getDOMCellFromTarget, getTableObserverFromTableElement, } from './LexicalTableSelectionHelpers';
export { $computeTableMap, $computeTableMapSkipCellCheck, $createTableNodeWithDimensions, $deleteTableColumn, $deleteTableColumn__EXPERIMENTAL, $deleteTableRow__EXPERIMENTAL, $getNodeTriplet, $getTableCellNodeFromLexicalNode, $getTableCellNodeRect, $getTableColumnIndexFromTableCellNode, $getTableNodeFromLexicalNodeOrThrow, $getTableRowIndexFromTableCellNode, $getTableRowNodeFromTableCellNodeOrThrow, $insertTableColumn, $insertTableColumn__EXPERIMENTAL, $insertTableRow, $insertTableRow__EXPERIMENTAL, $removeTableRowAtIndex, $unmergeCell, } from './LexicalTableUtils';

@@ -19,3 +19,3 @@ /**

a.theme.tableRow);return b}isShadowRoot(){return!0}setHeight(a){this.getWritable().__height=a;return this.__height}getHeight(){return this.getLatest().__height}updateDOM(a){return a.__height!==this.__height}canBeEmpty(){return!1}canIndent(){return!1}}function da(a){let b=void 0;aa.test(a.style.height)&&(b=parseFloat(a.style.height));return{node:D(b)}}function D(a){return u.$applyNodeReplacement(new C(a))}function H(a){return a instanceof C}var J;
function K(a){let b=new URLSearchParams;b.append("code",a);for(let c=1;c<arguments.length;c++)b.append("v",arguments[c]);throw Error(`Minified Lexical error #${a}; visit https://lexical.dev/docs/error?${b} for the full message or `+"use the non-minified dev environment for full errors and additional helpful warnings.");}J=K&&K.__esModule&&Object.prototype.hasOwnProperty.call(K,"default")?K["default"]:K;let ha="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement;
function K(a){let b=new URLSearchParams;b.append("code",a);for(let c=1;c<arguments.length;c++)b.append("v",arguments[c]);throw Error(`Minified Lexical error #${a}; visit https://lexical.dev/docs/error?${b} for the full message or `+"use the non-minified dev environment for full errors and additional helpful warnings.");}J=K&&K.__esModule&&Object.prototype.hasOwnProperty.call(K,"default")?K["default"]:K;let ea="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement;
function ia(a){a=h.$findMatchingParent(a,b=>H(b));if(H(a))return a;throw Error("Expected table cell to be inside of table row.");}function ja(a){a=h.$findMatchingParent(a,b=>N(b));if(N(a))return a;throw Error("Expected table cell to be inside of table.");}function ka(a,b){let c=ja(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)}}

@@ -37,3 +37,3 @@ let la=(a,b)=>a===x.BOTH||a===b?b:x.NO_STATUS;function O(a){let b=a.getFirstDescendant();null==b?a.selectStart():b.getParentOrThrow().selectStart()}function ma(a,b){let c=a.getFirstChild();null!==c?c.insertBefore(b):a.append(b)}function P(a,b,c){let [d,e,g]=na(a,b,c);null===e&&J(110);null===g&&J(111);return[d,e,g]}

this.hasHijackedSelectionStyles=!0})}updateTableTableSelection(a){if(null!==a&&a.tableKey===this.tableNodeKey){let b=this.editor;this.tableSelection=a;this.isHighlightingCells=!0;this.disableHighlightStyle();ta(b,this.table,this.tableSelection)}else null==a?this.clearHighlight():(this.tableNodeKey=a.tableKey,this.updateTableTableSelection(a))}setFocusCellForSelection(a,b=!1){let c=this.editor;c.update(()=>{var d=u.$getNodeByKey(this.tableNodeKey);if(!N(d))throw Error("Expected TableNode.");if(!c.getElementByKey(this.tableNodeKey))throw Error("Expected to find TableElement in DOM");
var e=a.x;let g=a.y;this.focusCell=a;if(null!==this.anchorCell){let f=ha?(c._window||window).getSelection():null;f&&f.setBaseAndExtent(this.anchorCell.elem,0,this.focusCell.elem,0)}if(!this.isHighlightingCells&&(this.anchorX!==e||this.anchorY!==g||b))this.isHighlightingCells=!0,this.disableHighlightStyle();else if(e===this.focusX&&g===this.focusY)return;this.focusX=e;this.focusY=g;this.isHighlightingCells&&(e=u.$getNearestNodeFromDOMNode(a.elem),null!=this.tableSelection&&null!=this.anchorCellNodeKey&&
var e=a.x;let g=a.y;this.focusCell=a;if(null!==this.anchorCell){let f=ea?(c._window||window).getSelection():null;f&&f.setBaseAndExtent(this.anchorCell.elem,0,this.focusCell.elem,0)}if(!this.isHighlightingCells&&(this.anchorX!==e||this.anchorY!==g||b))this.isHighlightingCells=!0,this.disableHighlightStyle();else if(e===this.focusX&&g===this.focusY)return;this.focusX=e;this.focusY=g;this.isHighlightingCells&&(e=u.$getNearestNodeFromDOMNode(a.elem),null!=this.tableSelection&&null!=this.anchorCellNodeKey&&
A(e)&&d.is(T(e))&&(d=e.getKey(),this.tableSelection=this.tableSelection.clone()||ra(),this.focusCellNodeKey=d,this.tableSelection.set(this.tableNodeKey,this.anchorCellNodeKey,this.focusCellNodeKey),u.$setSelection(this.tableSelection),c.dispatchCommand(u.SELECTION_CHANGE_COMMAND,void 0),ta(c,this.table,this.tableSelection)))})}setAnchorCellForSelection(a){this.isHighlightingCells=!1;this.anchorCell=a;this.anchorX=a.x;this.anchorY=a.y;this.editor.update(()=>{var b=u.$getNearestNodeFromDOMNode(a.elem);

@@ -69,3 +69,3 @@ A(b)&&(b=b.getKey(),this.tableSelection=null!=this.tableSelection?this.tableSelection.clone():ra(),this.anchorCellNodeKey=b)})}formatCells(a){this.editor.update(()=>{let b=u.$getSelection();R(b)||J(11);let c=u.$createRangeSelection(),d=c.anchor,e=c.focus;b.getNodes().forEach(g=>{A(g)&&0!==g.getTextContentSize()&&(d.set(g.getKey(),0,"element"),e.set(g.getKey(),g.getChildrenSize(),"element"),c.formatText(a))});u.$setSelection(b);this.editor.dispatchCommand(u.SELECTION_CHANGE_COMMAND,void 0)})}clearText(){let a=

exports.$deleteTableRow__EXPERIMENTAL=function(){var a=u.$getSelection();u.$isRangeSelection(a)||R(a)||J(118);var b=a.anchor.getNode();a=a.focus.getNode();let [c,,d]=Q(b);[a]=Q(a);let [e,g,f]=P(d,c,a);({startRow:b}=g);var {startRow:m}=f;a=m+a.__rowSpan-1;if(e.length===a-b+1)d.remove();else{m=e[0].length;var q=e[a+1],p=d.getChildAtIndex(a+1);for(let k=a;k>=b;k--){for(var t=m-1;0<=t;t--){let {cell:l,startRow:n,startColumn:r}=e[k][t];if(r===t&&(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===p&&J(122),0===t)ma(p,l);else{let {cell:v}=q[t-1];v.insertAfter(l)}}t=d.getChildAtIndex(k);H(t)||J(123,String(k));t.remove()}void 0!==q?({cell:b}=q[0],O(b)):({cell:b}=e[b-1][0],O(b))}};exports.$getElementForTableNode=function(a,b){a=a.getElementByKey(b.getKey());if(null==a)throw Error("Table Element Not Found");return S(a)};exports.$getNodeTriplet=Q;
1>a))if(l.setRowSpan(l.__rowSpan-(a-n+1)),null===p&&J(122),0===t)ma(p,l);else{let {cell:v}=q[t-1];v.insertAfter(l)}}t=d.getChildAtIndex(k);H(t)||J(123,String(k));t.remove()}void 0!==q?({cell:b}=q[0],O(b)):({cell:b}=e[b-1][0],O(b))}};exports.$findCellNode=Da;exports.$findTableNode=T;exports.$getElementForTableNode=function(a,b){a=a.getElementByKey(b.getKey());if(null==a)throw Error("Table Element Not Found");return S(a)};exports.$getNodeTriplet=Q;
exports.$getTableCellNodeFromLexicalNode=function(a){a=h.$findMatchingParent(a,b=>A(b));return A(a)?a:null};exports.$getTableCellNodeRect=oa;exports.$getTableColumnIndexFromTableCellNode=function(a){return ia(a).getChildren().findIndex(b=>b.is(a))};exports.$getTableNodeFromLexicalNodeOrThrow=ja;exports.$getTableRowIndexFromTableCellNode=function(a){let b=ia(a);return ja(b).getChildren().findIndex(c=>c.is(b))};exports.$getTableRowNodeFromTableCellNodeOrThrow=ia;

@@ -92,7 +92,7 @@ exports.$insertTableColumn=function(a,b,c=!0,d,e){let g=a.getChildren(),f=[];for(let p=0;p<g.length;p++){let t=g[p];if(H(t))for(let k=0;k<d;k++){var m=t.getChildren();if(b>=m.length||0>b)throw Error("Table column target index out of range");m=m[b];A(m)||J(12);let {left:l,right:n}=ka(m,e);var q=x.NO_STATUS;if(l&&l.hasHeaderState(x.ROW)||n&&n.hasHeaderState(x.ROW))q|=x.ROW;q=z(q);q.append(u.$createParagraphNode());f.push({newTableCell:q,targetCell:m})}}f.forEach(({newTableCell:p,targetCell:t})=>{c?

"forward");return!0},u.COMMAND_PRIORITY_CRITICAL));f.listenersToRemove.add(c.registerCommand(u.FOCUS_COMMAND,()=>a.isSelected(),u.COMMAND_PRIORITY_HIGH));f.listenersToRemove.add(c.registerCommand(u.SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,k=>{let {nodes:l,selection:n}=k;k=n.getStartEndPoints();var r=R(n);r=u.$isRangeSelection(n)&&null!==h.$findMatchingParent(n.anchor.getNode(),I=>A(I))&&null!==h.$findMatchingParent(n.focus.getNode(),I=>A(I))||r;if(1!==l.length||!N(l[0])||!r||null===k)return!1;var [v]=
k,w=l[0];k=w.getChildren();r=w.getFirstChildOrThrow().getChildrenSize();w=w.getChildrenSize();var B=h.$findMatchingParent(v.getNode(),I=>A(I)),E=(v=B&&h.$findMatchingParent(B,I=>H(I)))&&h.$findMatchingParent(v,I=>N(I));if(!A(B)||!H(v)||!N(E))return!1;var F=v.getIndexWithinParent(),G=Math.min(E.getChildrenSize()-1,F+w-1);w=B.getIndexWithinParent();B=Math.min(v.getChildrenSize()-1,w+r-1);r=Math.min(w,B);v=Math.min(F,G);w=Math.max(w,B);F=Math.max(F,G);E=E.getChildren();G=0;let L,M;for(B=v;B<=F;B++){var ea=
E[B];if(!H(ea))return!1;var fa=k[G];if(!H(fa))return!1;ea=ea.getChildren();fa=fa.getChildren();let I=0;for(let W=r;W<=w;W++){let X=ea[W];if(!A(X))return!1;let Ca=fa[I];if(!A(Ca))return!1;B===v&&W===r?L=X.getKey():B===F&&W===w&&(M=X.getKey());let Oa=X.getChildren();Ca.getChildren().forEach(Y=>{u.$isTextNode(Y)&&u.$createParagraphNode().append(Y);X.append(Y)});Oa.forEach(Y=>Y.remove());I++}G++}L&&M&&(k=ra(),k.set(l[0].getKey(),L,M),u.$setSelection(k));return!0},u.COMMAND_PRIORITY_CRITICAL));f.listenersToRemove.add(c.registerCommand(u.SELECTION_CHANGE_COMMAND,
k,w=l[0];k=w.getChildren();r=w.getFirstChildOrThrow().getChildrenSize();w=w.getChildrenSize();var B=h.$findMatchingParent(v.getNode(),I=>A(I)),E=(v=B&&h.$findMatchingParent(B,I=>H(I)))&&h.$findMatchingParent(v,I=>N(I));if(!A(B)||!H(v)||!N(E))return!1;var F=v.getIndexWithinParent(),G=Math.min(E.getChildrenSize()-1,F+w-1);w=B.getIndexWithinParent();B=Math.min(v.getChildrenSize()-1,w+r-1);r=Math.min(w,B);v=Math.min(F,G);w=Math.max(w,B);F=Math.max(F,G);E=E.getChildren();G=0;let L,M;for(B=v;B<=F;B++){var fa=
E[B];if(!H(fa))return!1;var ha=k[G];if(!H(ha))return!1;fa=fa.getChildren();ha=ha.getChildren();let I=0;for(let W=r;W<=w;W++){let X=fa[W];if(!A(X))return!1;let Ca=ha[I];if(!A(Ca))return!1;B===v&&W===r?L=X.getKey():B===F&&W===w&&(M=X.getKey());let Oa=X.getChildren();Ca.getChildren().forEach(Y=>{u.$isTextNode(Y)&&u.$createParagraphNode().append(Y);X.append(Y)});Oa.forEach(Y=>Y.remove());I++}G++}L&&M&&(k=ra(),k.set(l[0].getKey(),L,M),u.$setSelection(k));return!0},u.COMMAND_PRIORITY_CRITICAL));f.listenersToRemove.add(c.registerCommand(u.SELECTION_CHANGE_COMMAND,
()=>{let k=u.$getSelection(),l=u.$getPreviousSelection();if(u.$isRangeSelection(k)){let {anchor:B,focus:E}=k;var n=B.getNode(),r=E.getNode();n=Da(n);var v=Da(r),w=!(!n||!a.is(T(n)));r=!(!v||!a.is(T(v)));let F=w!==r,G=w&&r;w=k.isBackward();F?(n=k.clone(),r?n.focus.set(a.getParentOrThrow().getKey(),a.getIndexWithinParent(),"element"):n.anchor.set(a.getParentOrThrow().getKey(),w?a.getIndexWithinParent()+1:a.getIndexWithinParent(),"element"),u.$setSelection(n),ya(c,f)):G&&!n.is(v)&&(f.setAnchorCellForSelection(e(n)),
f.setFocusCellForSelection(e(v),!0),f.isSelecting||setTimeout(()=>{let {onMouseUp:L,onMouseMove:M}=q();f.isSelecting=!0;m.addEventListener("mouseup",L);m.addEventListener("mousemove",M)},0))}else k&&R(k)&&k.is(l)&&k.tableKey===a.getKey()&&(n=ha?(c._window||window).getSelection():null)&&n.anchorNode&&n.focusNode&&(r=(r=u.$getNearestNodeFromDOMNode(n.focusNode))&&!a.is(T(r)),v=(v=u.$getNearestNodeFromDOMNode(n.anchorNode))&&a.is(T(v)),r&&v&&0<n.rangeCount&&(r=u.$createRangeSelectionFromDom(n,c)))&&
f.setFocusCellForSelection(e(v),!0),f.isSelecting||setTimeout(()=>{let {onMouseUp:L,onMouseMove:M}=q();f.isSelecting=!0;m.addEventListener("mouseup",L);m.addEventListener("mousemove",M)},0))}else k&&R(k)&&k.is(l)&&k.tableKey===a.getKey()&&(n=ea?(c._window||window).getSelection():null)&&n.anchorNode&&n.focusNode&&(r=(r=u.$getNearestNodeFromDOMNode(n.focusNode))&&!a.is(T(r)),v=(v=u.$getNearestNodeFromDOMNode(n.anchorNode))&&a.is(T(v)),r&&v&&0<n.rangeCount&&(r=u.$createRangeSelectionFromDom(n,c)))&&
(r.anchor.set(a.getKey(),k.isBackward()?a.getChildrenSize():0,"element"),n.removeAllRanges(),u.$setSelection(r));if(k&&!k.is(l)&&(R(k)||R(l))&&f.tableSelection&&!f.tableSelection.is(l))return R(k)&&k.tableKey===f.tableNodeKey?f.updateTableTableSelection(k):!R(k)&&R(l)&&l.tableKey===f.tableNodeKey&&f.updateTableTableSelection(null),!1;f.hasHijackedSelectionStyles&&!a.isSelected()?za(c,f):!f.hasHijackedSelectionStyles&&a.isSelected()&&ya(c,f);return!1},u.COMMAND_PRIORITY_CRITICAL));f.listenersToRemove.add(c.registerCommand(u.INSERT_PARAGRAPH_COMMAND,
()=>{var k=u.$getSelection();return u.$isRangeSelection(k)&&k.isCollapsed()&&U(k,a)?(k=Ka(c,k,a))?(Ja(k,a),!0):!1:!1},u.COMMAND_PRIORITY_CRITICAL));return f};exports.getDOMCellFromTarget=ua;exports.getTableObserverFromTableElement=function(a){return a.__lexicalTableSelection}

@@ -8,2 +8,3 @@ /**

*/
import type { TableCellNode } from './LexicalTableCellNode';
import type { TableNode } from './LexicalTableNode';

@@ -30,3 +31,4 @@ import type { TableDOMCell } from './LexicalTableObserver';

export declare function $removeHighlightStyleToTable(editor: LexicalEditor, tableObserver: TableObserver): void;
export declare function $findCellNode(node: LexicalNode): null | TableCellNode;
export declare function $findTableNode(node: LexicalNode): null | TableNode;
export {};

@@ -11,8 +11,8 @@ {

"license": "MIT",
"version": "0.16.1-nightly.20240618.0",
"version": "0.16.1-nightly.20240619.0",
"main": "LexicalTable.js",
"types": "index.d.ts",
"dependencies": {
"@lexical/utils": "0.16.1-nightly.20240618.0",
"lexical": "0.16.1-nightly.20240618.0"
"@lexical/utils": "0.16.1-nightly.20240619.0",
"lexical": "0.16.1-nightly.20240619.0"
},

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

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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