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
199
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.17.0 to 0.17.1-nightly.20240802.0

18

LexicalTable.prod.js

@@ -32,11 +32,11 @@ /**

class sa{constructor(a,b){this.isHighlightingCells=!1;this.focusY=this.focusX=this.anchorY=this.anchorX=-1;this.listenersToRemove=new Set;this.tableNodeKey=b;this.editor=a;this.table={columns:0,domRows:[],rows:0};this.focusCell=this.anchorCell=this.focusCellNodeKey=this.anchorCellNodeKey=this.tableSelection=null;this.hasHijackedSelectionStyles=!1;this.trackTable();this.isSelecting=!1}getTable(){return this.table}removeListeners(){Array.from(this.listenersToRemove).forEach(a=>a())}trackTable(){let a=
new MutationObserver(b=>{this.editor.update(()=>{var c=!1;for(let d=0;d<b.length;d++){const e=b[d].target.nodeName;if("TABLE"===e||"TBODY"===e||"THEAD"===e||"TR"===e){c=!0;break}}if(c){c=this.editor.getElementByKey(this.tableNodeKey);if(!c)throw Error("Expected to find TableElement in DOM");this.table=S(c)}})});this.editor.update(()=>{let b=this.editor.getElementByKey(this.tableNodeKey);if(!b)throw Error("Expected to find TableElement in DOM");this.table=S(b);a.observe(b,{childList:!0,subtree:!0})})}clearHighlight(){let a=
this.editor;this.isHighlightingCells=!1;this.focusY=this.focusX=this.anchorY=this.anchorX=-1;this.focusCell=this.anchorCell=this.focusCellNodeKey=this.anchorCellNodeKey=this.tableSelection=null;this.hasHijackedSelectionStyles=!1;this.enableHighlightStyle();a.update(()=>{var b=v.$getNodeByKey(this.tableNodeKey);if(!N(b))throw Error("Expected TableNode.");b=a.getElementByKey(this.tableNodeKey);if(!b)throw Error("Expected to find TableElement in DOM");b=S(b);ta(a,b,null);v.$setSelection(null);a.dispatchCommand(v.SELECTION_CHANGE_COMMAND,
void 0)})}enableHighlightStyle(){let a=this.editor;a.update(()=>{let b=a.getElementByKey(this.tableNodeKey);if(!b)throw Error("Expected to find TableElement in DOM");h.removeClassNamesFromElement(b,a._config.theme.tableSelection);b.classList.remove("disable-selection");this.hasHijackedSelectionStyles=!1})}disableHighlightStyle(){let a=this.editor;a.update(()=>{let b=a.getElementByKey(this.tableNodeKey);if(!b)throw Error("Expected to find TableElement in DOM");h.addClassNamesToElement(b,a._config.theme.tableSelection);
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=v.$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 f=a.y;this.focusCell=a;if(null!==this.anchorCell){let g=ea?(c._window||window).getSelection():null;g&&g.setBaseAndExtent(this.anchorCell.elem,0,this.focusCell.elem,0)}if(!this.isHighlightingCells&&(this.anchorX!==e||this.anchorY!==f||b))this.isHighlightingCells=!0,this.disableHighlightStyle();else if(e===this.focusX&&f===this.focusY)return;this.focusX=e;this.focusY=f;this.isHighlightingCells&&(e=v.$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),v.$setSelection(this.tableSelection),c.dispatchCommand(v.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=v.$getNearestNodeFromDOMNode(a.elem);
A(b)&&(b=b.getKey(),this.tableSelection=null!=this.tableSelection?this.tableSelection.clone():ra(),this.anchorCellNodeKey=b)})}formatCells(a){this.editor.update(()=>{let b=v.$getSelection();R(b)||I(11);let c=v.$createRangeSelection(),d=c.anchor,e=c.focus;b.getNodes().forEach(f=>{A(f)&&0!==f.getTextContentSize()&&(d.set(f.getKey(),0,"element"),e.set(f.getKey(),f.getChildrenSize(),"element"),c.formatText(a))});v.$setSelection(b);this.editor.dispatchCommand(v.SELECTION_CHANGE_COMMAND,void 0)})}clearText(){let a=
this.editor;a.update(()=>{let b=v.$getNodeByKey(this.tableNodeKey);if(!N(b))throw Error("Expected TableNode.");var c=v.$getSelection();R(c)||I(11);c=c.getNodes().filter(A);c.length===this.table.columns*this.table.rows?(b.selectPrevious(),b.remove(),v.$getRoot().selectStart()):(c.forEach(d=>{if(v.$isElementNode(d)){let e=v.$createParagraphNode(),f=v.$createTextNode();e.append(f);d.append(e);d.getChildren().forEach(g=>{g!==e&&g.remove()})}}),ta(a,this.table,null),v.$setSelection(null),a.dispatchCommand(v.SELECTION_CHANGE_COMMAND,
void 0))})}}function ua(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}
new MutationObserver(b=>{this.editor.update(()=>{var c=!1;for(let d=0;d<b.length;d++){const e=b[d].target.nodeName;if("TABLE"===e||"TBODY"===e||"THEAD"===e||"TR"===e){c=!0;break}}if(c){c=this.editor.getElementByKey(this.tableNodeKey);if(!c)throw Error("Expected to find TableElement in DOM");this.table=S(c)}})});this.editor.update(()=>{let b=this.editor.getElementByKey(this.tableNodeKey);if(!b)throw Error("Expected to find TableElement in DOM");this.table=S(b);a.observe(b,{attributes:!0,childList:!0,
subtree:!0})})}clearHighlight(){let a=this.editor;this.isHighlightingCells=!1;this.focusY=this.focusX=this.anchorY=this.anchorX=-1;this.focusCell=this.anchorCell=this.focusCellNodeKey=this.anchorCellNodeKey=this.tableSelection=null;this.hasHijackedSelectionStyles=!1;this.enableHighlightStyle();a.update(()=>{var b=v.$getNodeByKey(this.tableNodeKey);if(!N(b))throw Error("Expected TableNode.");b=a.getElementByKey(this.tableNodeKey);if(!b)throw Error("Expected to find TableElement in DOM");b=S(b);ta(a,
b,null);v.$setSelection(null);a.dispatchCommand(v.SELECTION_CHANGE_COMMAND,void 0)})}enableHighlightStyle(){let a=this.editor;a.update(()=>{let b=a.getElementByKey(this.tableNodeKey);if(!b)throw Error("Expected to find TableElement in DOM");h.removeClassNamesFromElement(b,a._config.theme.tableSelection);b.classList.remove("disable-selection");this.hasHijackedSelectionStyles=!1})}disableHighlightStyle(){let a=this.editor;a.update(()=>{let b=a.getElementByKey(this.tableNodeKey);if(!b)throw Error("Expected to find TableElement in DOM");
h.addClassNamesToElement(b,a._config.theme.tableSelection);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=v.$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 f=a.y;this.focusCell=a;if(null!==this.anchorCell){let g=ea?(c._window||window).getSelection():null;g&&g.setBaseAndExtent(this.anchorCell.elem,0,this.focusCell.elem,0)}if(!this.isHighlightingCells&&(this.anchorX!==e||this.anchorY!==f||b))this.isHighlightingCells=!0,this.disableHighlightStyle();else if(e===this.focusX&&f===this.focusY)return;this.focusX=
e;this.focusY=f;this.isHighlightingCells&&(e=v.$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),v.$setSelection(this.tableSelection),c.dispatchCommand(v.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=v.$getNearestNodeFromDOMNode(a.elem);A(b)&&(b=b.getKey(),this.tableSelection=null!=this.tableSelection?this.tableSelection.clone():ra(),this.anchorCellNodeKey=b)})}formatCells(a){this.editor.update(()=>{let b=v.$getSelection();R(b)||I(11);let c=v.$createRangeSelection(),d=c.anchor,e=c.focus;b.getNodes().forEach(f=>{A(f)&&0!==f.getTextContentSize()&&(d.set(f.getKey(),0,"element"),e.set(f.getKey(),f.getChildrenSize(),
"element"),c.formatText(a))});v.$setSelection(b);this.editor.dispatchCommand(v.SELECTION_CHANGE_COMMAND,void 0)})}clearText(){let a=this.editor;a.update(()=>{let b=v.$getNodeByKey(this.tableNodeKey);if(!N(b))throw Error("Expected TableNode.");var c=v.$getSelection();R(c)||I(11);c=c.getNodes().filter(A);c.length===this.table.columns*this.table.rows?(b.selectPrevious(),b.remove(),v.$getRoot().selectStart()):(c.forEach(d=>{if(v.$isElementNode(d)){let e=v.$createParagraphNode(),f=v.$createTextNode();
e.append(f);d.append(e);d.getChildren().forEach(g=>{g!==e&&g.remove()})}}),ta(a,this.table,null),v.$setSelection(null),a.dispatchCommand(v.SELECTION_CHANGE_COMMAND,void 0))})}}function ua(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 S(a){let b=[],c={columns:0,domRows:b,rows:0};var d=a.firstChild;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}

@@ -43,0 +43,0 @@ function ta(a,b,c){let d=new Set(c?c.getNodes():[]);va(b,(e,f)=>{let g=e.elem;d.has(f)?(e.highlighted=!0,wa(a,e)):(e.highlighted=!1,xa(a,e),g.getAttribute("style")||g.removeAttribute("style"))})}function va(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=v.$getNearestNodeFromDOMNode(f.elem);null!==g&&b(f,g,{x:e,y:c})}}}function ya(a,b){b.disableHighlightStyle();va(b.table,c=>{c.highlighted=!0;wa(a,c)})}

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

"license": "MIT",
"version": "0.17.0",
"version": "0.17.1-nightly.20240802.0",
"main": "LexicalTable.js",
"types": "index.d.ts",
"dependencies": {
"@lexical/utils": "0.17.0",
"lexical": "0.17.0"
"@lexical/utils": "0.17.1-nightly.20240802.0",
"lexical": "0.17.1-nightly.20240802.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

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