@lexical/table
Advanced tools
Comparing version 0.21.1-nightly.20241217.0 to 0.21.1-nightly.20241218.0
@@ -47,3 +47,3 @@ /** | ||
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(), | ||
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(),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} | ||
@@ -103,3 +103,3 @@ 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]; | ||
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}; | ||
@@ -125,4 +125,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.20241217.0", | ||
"version": "0.21.1-nightly.20241218.0", | ||
"main": "LexicalTable.js", | ||
"types": "index.d.ts", | ||
"dependencies": { | ||
"@lexical/clipboard": "0.21.1-nightly.20241217.0", | ||
"@lexical/utils": "0.21.1-nightly.20241217.0", | ||
"lexical": "0.21.1-nightly.20241217.0" | ||
"@lexical/clipboard": "0.21.1-nightly.20241218.0", | ||
"@lexical/utils": "0.21.1-nightly.20241218.0", | ||
"lexical": "0.21.1-nightly.20241218.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.21.1-nightly.20241218.0(transitive)
+ Added@lexical/html@0.21.1-nightly.20241218.0(transitive)
+ Added@lexical/list@0.21.1-nightly.20241218.0(transitive)
+ Added@lexical/selection@0.21.1-nightly.20241218.0(transitive)
+ Added@lexical/utils@0.21.1-nightly.20241218.0(transitive)
+ Addedlexical@0.21.1-nightly.20241218.0(transitive)
- Removed@lexical/clipboard@0.21.1-nightly.20241217.0(transitive)
- Removed@lexical/html@0.21.1-nightly.20241217.0(transitive)
- Removed@lexical/list@0.21.1-nightly.20241217.0(transitive)
- Removed@lexical/selection@0.21.1-nightly.20241217.0(transitive)
- Removed@lexical/utils@0.21.1-nightly.20241217.0(transitive)
- Removedlexical@0.21.1-nightly.20241217.0(transitive)