Socket
Socket
Sign inDemoInstall

@lexical/react

Package Overview
Dependencies
Maintainers
5
Versions
168
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lexical/react - npm Package Compare versions

Comparing version 0.17.2-nightly.20240830.0 to 0.17.2-nightly.20240902.0

54

LexicalTablePlugin.dev.js

@@ -54,9 +54,12 @@ /**

}, 0);
const rowNodes = node.getChildren();
for (let i = 0; i < gridMap.length; ++i) {
const rowLength = gridMap[i].length;
const rowNode = rowNodes[i];
if (!rowNode) {
continue;
}
const rowLength = gridMap[i].reduce((acc, cell) => cell ? 1 + acc : acc, 0);
if (rowLength === maxRowLength) {
continue;
}
const lastCellMap = gridMap[i][rowLength - 1];
const lastRowCell = lastCellMap.cell;
for (let j = rowLength; j < maxRowLength; ++j) {

@@ -66,7 +69,3 @@ // TODO: inherit header state from another header or body

newCell.append(lexical.$createParagraphNode());
if (lastRowCell !== null) {
lastRowCell.insertAfter(newCell);
} else {
utils.$insertFirst(lastRowCell, newCell);
}
rowNode.append(newCell);
}

@@ -78,23 +77,32 @@ }

const tableSelections = new Map();
const initializeTableNode = tableNode => {
const nodeKey = tableNode.getKey();
const tableElement = editor.getElementByKey(nodeKey);
if (tableElement && !tableSelections.has(nodeKey)) {
const tableSelection = table.applyTableHandlers(tableNode, tableElement, editor, hasTabHandler);
tableSelections.set(nodeKey, tableSelection);
}
const initializeTableNode = (tableNode, nodeKey, dom) => {
const tableElement = dom;
const tableSelection = table.applyTableHandlers(tableNode, tableElement, editor, hasTabHandler);
tableSelections.set(nodeKey, [tableSelection, tableElement]);
};
const unregisterMutationListener = editor.registerMutationListener(table.TableNode, nodeMutations => {
for (const [nodeKey, mutation] of nodeMutations) {
if (mutation === 'created') {
editor.getEditorState().read(() => {
const tableNode = lexical.$getNodeByKey(nodeKey);
if (table.$isTableNode(tableNode)) {
initializeTableNode(tableNode);
if (mutation === 'created' || mutation === 'updated') {
const tableSelection = tableSelections.get(nodeKey);
const dom = editor.getElementByKey(nodeKey);
if (!(tableSelection && dom === tableSelection[1])) {
// The update created a new DOM node, destroy the existing TableObserver
if (tableSelection) {
tableSelection[0].removeListeners();
tableSelections.delete(nodeKey);
}
});
if (dom !== null) {
// Create a new TableObserver
editor.getEditorState().read(() => {
const tableNode = lexical.$getNodeByKey(nodeKey);
if (table.$isTableNode(tableNode)) {
initializeTableNode(tableNode, nodeKey, dom);
}
});
}
}
} else if (mutation === 'destroyed') {
const tableSelection = tableSelections.get(nodeKey);
if (tableSelection !== undefined) {
tableSelection.removeListeners();
tableSelection[0].removeListeners();
tableSelections.delete(nodeKey);

@@ -111,3 +119,3 @@ }

// as it'll be reinitialized during recurring call
for (const [, tableSelection] of tableSelections) {
for (const [, [tableSelection]] of tableSelections) {
tableSelection.removeListeners();

@@ -114,0 +122,0 @@ }

@@ -9,8 +9,8 @@ /**

'use strict';var c=require("@lexical/react/LexicalComposerContext"),r=require("@lexical/table"),t=require("@lexical/utils"),u=require("lexical"),v=require("react"),w;function y(l){let m=new URLSearchParams;m.append("code",l);for(let n=1;n<arguments.length;n++)m.append("v",arguments[n]);throw Error(`Minified Lexical error #${l}; visit https://lexical.dev/docs/error?${m} for the full message or `+"use the non-minified dev environment for full errors and additional helpful warnings.");}
w=y&&y.__esModule&&Object.prototype.hasOwnProperty.call(y,"default")?y["default"]:y;
exports.TablePlugin=function({hasCellMerge:l=!0,hasCellBackgroundColor:m=!0,hasTabHandler:n=!0}){let [e]=c.useLexicalComposerContext();v.useEffect(()=>{e.hasNodes([r.TableNode,r.TableCellNode,r.TableRowNode])||w(10);return t.mergeRegister(e.registerCommand(r.INSERT_TABLE_COMMAND,({columns:a,rows:d,includeHeaders:b})=>{a=r.$createTableNodeWithDimensions(Number(d),Number(a),b);t.$insertNodeToNearestRoot(a);a=a.getFirstDescendant();u.$isTextNode(a)&&a.select();return!0},u.COMMAND_PRIORITY_EDITOR),e.registerNodeTransform(r.TableNode,
a=>{[a]=r.$computeTableMapSkipCellCheck(a,null,null);let d=a.reduce((f,k)=>Math.max(f,k.length),0);for(let f=0;f<a.length;++f){var b=a[f].length;if(b===d)continue;let k=a[f][b-1].cell;for(;b<d;++b){let g=r.$createTableCellNode(0);g.append(u.$createParagraphNode());null!==k?k.insertAfter(g):t.$insertFirst(k,g)}}}))},[e]);v.useEffect(()=>{let a=new Map,d=e.registerMutationListener(r.TableNode,b=>{for(const [f,k]of b)"created"===k?e.getEditorState().read(()=>{var g=u.$getNodeByKey(f);if(r.$isTableNode(g)){const h=
g.getKey(),p=e.getElementByKey(h);p&&!a.has(h)&&(g=r.applyTableHandlers(g,p,e,n),a.set(h,g))}}):"destroyed"===k&&(b=a.get(f),void 0!==b&&(b.removeListeners(),a.delete(f)))},{skipInitialization:!1});return()=>{d();for(let [,b]of a)b.removeListeners()}},[e,n]);v.useEffect(()=>{if(!l)return e.registerNodeTransform(r.TableCellNode,a=>{if(1<a.getColSpan()||1<a.getRowSpan()){var [,,d]=r.$getNodeTriplet(a);[a]=r.$computeTableMap(d,a,a);let f=a.length,k=a[0].length;d=d.getFirstChild();r.$isTableRowNode(d)||
w(175);let g=[];for(let h=0;h<f;h++){0!==h&&(d=d.getNextSibling(),r.$isTableRowNode(d)||w(175));let p=null;for(let x=0;x<k;x++){var b=a[h][x];let q=b.cell;if(b.startRow===h&&b.startColumn===x)p=q,g.push(q);else if(1<q.getColSpan()||1<q.getRowSpan())r.$isTableCellNode(q)||w(176),b=r.$createTableCellNode(q.__headerState),null!==p?p.insertAfter(b):t.$insertFirst(d,b)}}for(let h of g)h.setColSpan(1),h.setRowSpan(1)}})},[e,l]);v.useEffect(()=>{if(!m)return e.registerNodeTransform(r.TableCellNode,a=>{null!==
a.getBackgroundColor()&&a.setBackgroundColor(null)})},[e,m,l]);return null}
'use strict';var c=require("@lexical/react/LexicalComposerContext"),t=require("@lexical/table"),u=require("@lexical/utils"),v=require("lexical"),w=require("react"),x;function y(n){let p=new URLSearchParams;p.append("code",n);for(let q=1;q<arguments.length;q++)p.append("v",arguments[q]);throw Error(`Minified Lexical error #${n}; visit https://lexical.dev/docs/error?${p} for the full message or `+"use the non-minified dev environment for full errors and additional helpful warnings.");}
x=y&&y.__esModule&&Object.prototype.hasOwnProperty.call(y,"default")?y["default"]:y;
exports.TablePlugin=function({hasCellMerge:n=!0,hasCellBackgroundColor:p=!0,hasTabHandler:q=!0}){let [f]=c.useLexicalComposerContext();w.useEffect(()=>{f.hasNodes([t.TableNode,t.TableCellNode,t.TableRowNode])||x(10);return u.mergeRegister(f.registerCommand(t.INSERT_TABLE_COMMAND,({columns:a,rows:e,includeHeaders:b})=>{a=t.$createTableNodeWithDimensions(Number(e),Number(a),b);u.$insertNodeToNearestRoot(a);a=a.getFirstDescendant();v.$isTextNode(a)&&a.select();return!0},v.COMMAND_PRIORITY_EDITOR),f.registerNodeTransform(t.TableNode,
a=>{let [e]=t.$computeTableMapSkipCellCheck(a,null,null),b=e.reduce((h,k)=>Math.max(h,k.length),0);a=a.getChildren();for(let h=0;h<e.length;++h){let k=a[h];if(k){var g=e[h].reduce((d,l)=>l?1+d:d,0);if(g!==b)for(;g<b;++g){let d=t.$createTableCellNode(0);d.append(v.$createParagraphNode());k.append(d)}}}}))},[f]);w.useEffect(()=>{let a=new Map,e=f.registerMutationListener(t.TableNode,b=>{for(const [g,h]of b)if("created"===h||"updated"===h){b=a.get(g);const k=f.getElementByKey(g);b&&k===b[1]||(b&&(b[0].removeListeners(),
a.delete(g)),null!==k&&f.getEditorState().read(()=>{var d=v.$getNodeByKey(g);if(t.$isTableNode(d)){var l=g;const m=k;d=t.applyTableHandlers(d,m,f,q);a.set(l,[d,m])}}))}else"destroyed"===h&&(b=a.get(g),void 0!==b&&(b[0].removeListeners(),a.delete(g)))},{skipInitialization:!1});return()=>{e();for(let [,[b]]of a)b.removeListeners()}},[f,q]);w.useEffect(()=>{if(!n)return f.registerNodeTransform(t.TableCellNode,a=>{if(1<a.getColSpan()||1<a.getRowSpan()){var [,,e]=t.$getNodeTriplet(a);[a]=t.$computeTableMap(e,
a,a);let g=a.length,h=a[0].length;e=e.getFirstChild();t.$isTableRowNode(e)||x(175);let k=[];for(let d=0;d<g;d++){0!==d&&(e=e.getNextSibling(),t.$isTableRowNode(e)||x(175));let l=null;for(let m=0;m<h;m++){var b=a[d][m];let r=b.cell;if(b.startRow===d&&b.startColumn===m)l=r,k.push(r);else if(1<r.getColSpan()||1<r.getRowSpan())t.$isTableCellNode(r)||x(176),b=t.$createTableCellNode(r.__headerState),null!==l?l.insertAfter(b):u.$insertFirst(e,b)}}for(let d of k)d.setColSpan(1),d.setRowSpan(1)}})},[f,n]);
w.useEffect(()=>{if(!p)return f.registerNodeTransform(t.TableCellNode,a=>{null!==a.getBackgroundColor()&&a.setBackgroundColor(null)})},[f,p,n]);return null}

@@ -11,23 +11,23 @@ {

"license": "MIT",
"version": "0.17.2-nightly.20240830.0",
"version": "0.17.2-nightly.20240902.0",
"dependencies": {
"@lexical/clipboard": "0.17.2-nightly.20240830.0",
"@lexical/code": "0.17.2-nightly.20240830.0",
"@lexical/devtools-core": "0.17.2-nightly.20240830.0",
"@lexical/dragon": "0.17.2-nightly.20240830.0",
"@lexical/hashtag": "0.17.2-nightly.20240830.0",
"@lexical/history": "0.17.2-nightly.20240830.0",
"@lexical/link": "0.17.2-nightly.20240830.0",
"@lexical/list": "0.17.2-nightly.20240830.0",
"@lexical/mark": "0.17.2-nightly.20240830.0",
"@lexical/markdown": "0.17.2-nightly.20240830.0",
"@lexical/overflow": "0.17.2-nightly.20240830.0",
"@lexical/plain-text": "0.17.2-nightly.20240830.0",
"@lexical/rich-text": "0.17.2-nightly.20240830.0",
"@lexical/selection": "0.17.2-nightly.20240830.0",
"@lexical/table": "0.17.2-nightly.20240830.0",
"@lexical/text": "0.17.2-nightly.20240830.0",
"@lexical/utils": "0.17.2-nightly.20240830.0",
"@lexical/yjs": "0.17.2-nightly.20240830.0",
"lexical": "0.17.2-nightly.20240830.0",
"@lexical/clipboard": "0.17.2-nightly.20240902.0",
"@lexical/code": "0.17.2-nightly.20240902.0",
"@lexical/devtools-core": "0.17.2-nightly.20240902.0",
"@lexical/dragon": "0.17.2-nightly.20240902.0",
"@lexical/hashtag": "0.17.2-nightly.20240902.0",
"@lexical/history": "0.17.2-nightly.20240902.0",
"@lexical/link": "0.17.2-nightly.20240902.0",
"@lexical/list": "0.17.2-nightly.20240902.0",
"@lexical/mark": "0.17.2-nightly.20240902.0",
"@lexical/markdown": "0.17.2-nightly.20240902.0",
"@lexical/overflow": "0.17.2-nightly.20240902.0",
"@lexical/plain-text": "0.17.2-nightly.20240902.0",
"@lexical/rich-text": "0.17.2-nightly.20240902.0",
"@lexical/selection": "0.17.2-nightly.20240902.0",
"@lexical/table": "0.17.2-nightly.20240902.0",
"@lexical/text": "0.17.2-nightly.20240902.0",
"@lexical/utils": "0.17.2-nightly.20240902.0",
"@lexical/yjs": "0.17.2-nightly.20240902.0",
"lexical": "0.17.2-nightly.20240902.0",
"react-error-boundary": "^3.1.4"

@@ -34,0 +34,0 @@ },

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