@lexical/table
Advanced tools
Comparing version 0.16.2-nightly.20240726.0 to 0.16.2-nightly.20240729.0
@@ -86,13 +86,12 @@ /** | ||
h.$findMatchingParent(l.anchor.getNode(),u=>A(u));if(!A(n))return!1;var q=l.anchor.getNode();n=l.focus.getNode();q=a.isParentOf(q);n=a.isParentOf(n);if(q&&!n||n&&!q)return g.clearText(),!0;n=(l=h.$findMatchingParent(l.anchor.getNode(),u=>v.$isElementNode(u)))&&h.$findMatchingParent(l,u=>v.$isElementNode(u)&&A(u.getParent()));if(!v.$isElementNode(n)||!v.$isElementNode(l))return!1;if(k===v.DELETE_LINE_COMMAND&&null===n.getPreviousSibling())return!0}return!1};[v.DELETE_WORD_COMMAND,v.DELETE_LINE_COMMAND, | ||
v.DELETE_CHARACTER_COMMAND].forEach(k=>{g.listenersToRemove.add(c.registerCommand(k,t(k),v.COMMAND_PRIORITY_CRITICAL))});b=k=>{var l=v.$getSelection();if(!U(l,a)){if(k=l?l.getNodes():null)if(k=k.find(n=>N(n)&&n.getKey()===g.tableNodeKey),N(k)){l=k.getParent();if(!l)return!1;const n=k.getNextSibling()||k.getPreviousSibling();k.remove();n?n.selectStart():l.selectStart()}return!0}if(R(l))return k.preventDefault(),k.stopPropagation(),g.clearText(),!0;v.$isRangeSelection(l)&&(k=h.$findMatchingParent(l.anchor.getNode(), | ||
n=>A(n)),A(k));return!1};g.listenersToRemove.add(c.registerCommand(v.KEY_BACKSPACE_COMMAND,b,v.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(v.KEY_DELETE_COMMAND,b,v.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(v.FORMAT_TEXT_COMMAND,k=>{let l=v.$getSelection();if(!U(l,a))return!1;if(R(l))return g.formatCells(k),!0;v.$isRangeSelection(l)&&(k=h.$findMatchingParent(l.anchor.getNode(),n=>A(n)),A(k));return!1},v.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(v.FORMAT_ELEMENT_COMMAND, | ||
k=>{var l=v.$getSelection();if(!R(l)||!U(l,a))return!1;var n=l.anchor.getNode();l=l.focus.getNode();if(!A(n)||!A(l))return!1;let [q,u,w]=P(a,n,l);n=Math.max(u.startRow,w.startRow);l=Math.max(u.startColumn,w.startColumn);var B=Math.min(u.startRow,w.startRow);let E=Math.min(u.startColumn,w.startColumn);for(;B<=n;B++)for(let H=E;H<=l;H++){var F=q[B][H].cell;F.setFormat(k);F=F.getChildren();for(let L=0;L<F.length;L++){let M=F[L];v.$isElementNode(M)&&!M.isInline()&&M.setFormat(k)}}return!0},v.COMMAND_PRIORITY_CRITICAL)); | ||
g.listenersToRemove.add(c.registerCommand(v.CONTROLLED_TEXT_INSERTION_COMMAND,k=>{var l=v.$getSelection();if(!U(l,a))return!1;if(R(l))g.clearHighlight();else if(v.$isRangeSelection(l)){let n=h.$findMatchingParent(l.anchor.getNode(),q=>A(q));if(!A(n))return!1;if("string"===typeof k&&(l=Ka(c,l,a)))return Ja(l,a,[v.$createTextNode(k)]),!0}return!1},v.COMMAND_PRIORITY_CRITICAL));d&&g.listenersToRemove.add(c.registerCommand(v.KEY_TAB_COMMAND,k=>{var l=v.$getSelection();if(!v.$isRangeSelection(l)||!l.isCollapsed()|| | ||
!U(l,a))return!1;l=Da(l.anchor.getNode());if(null===l)return!1;Z(k);l=a.getCordsFromCellNode(l,g.table);Aa(g,a,l.x,l.y,k.shiftKey?"backward":"forward");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,k=>{let {nodes:l,selection:n}=k;k=n.getStartEndPoints();var q=R(n);q=v.$isRangeSelection(n)&&null!==h.$findMatchingParent(n.anchor.getNode(), | ||
J=>A(J))&&null!==h.$findMatchingParent(n.focus.getNode(),J=>A(J))||q;if(1!==l.length||!N(l[0])||!q||null===k)return!1;var [u]=k,w=l[0];k=w.getChildren();q=w.getFirstChildOrThrow().getChildrenSize();w=w.getChildrenSize();var B=h.$findMatchingParent(u.getNode(),J=>A(J)),E=(u=B&&h.$findMatchingParent(B,J=>G(J)))&&h.$findMatchingParent(u,J=>N(J));if(!A(B)||!G(u)||!N(E))return!1;var F=u.getIndexWithinParent(),H=Math.min(E.getChildrenSize()-1,F+w-1);w=B.getIndexWithinParent();B=Math.min(u.getChildrenSize()- | ||
1,w+q-1);q=Math.min(w,B);u=Math.min(F,H);w=Math.max(w,B);F=Math.max(F,H);E=E.getChildren();H=0;let L,M;for(B=u;B<=F;B++){var fa=E[B];if(!G(fa))return!1;var ha=k[H];if(!G(ha))return!1;fa=fa.getChildren();ha=ha.getChildren();let J=0;for(let W=q;W<=w;W++){let X=fa[W];if(!A(X))return!1;let Ca=ha[J];if(!A(Ca))return!1;B===u&&W===q?L=X.getKey():B===F&&W===w&&(M=X.getKey());let Oa=X.getChildren();Ca.getChildren().forEach(Y=>{v.$isTextNode(Y)&&v.$createParagraphNode().append(Y);X.append(Y)});Oa.forEach(Y=> | ||
Y.remove());J++}H++}L&&M&&(k=ra(),k.set(l[0].getKey(),L,M),v.$setSelection(k));return!0},v.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(v.SELECTION_CHANGE_COMMAND,()=>{let k=v.$getSelection(),l=v.$getPreviousSelection();if(v.$isRangeSelection(k)){let {anchor:B,focus:E}=k;var n=B.getNode(),q=E.getNode();n=Da(n);var u=Da(q);q=!(!n||!a.is(T(n)));var w=!(!u||!a.is(T(u)));let F=q!==w,H=q&&w;q=k.isBackward();F?(n=k.clone(),w?([w]=P(a,u,u),u=w[0][0].cell,w=w[w.length-1].at(-1).cell, | ||
n.focus.set(q?u.getKey():w.getKey(),q?u.getChildrenSize():w.getChildrenSize(),"element")):n.anchor.set(a.getParentOrThrow().getKey(),q?a.getIndexWithinParent()+1:a.getIndexWithinParent(),"element"),v.$setSelection(n),ya(c,g)):H&&!n.is(u)&&(g.setAnchorCellForSelection(e(n)),g.setFocusCellForSelection(e(u),!0),g.isSelecting||setTimeout(()=>{let {onMouseUp:L,onMouseMove:M}=r();g.isSelecting=!0;m.addEventListener("mouseup",L);m.addEventListener("mousemove",M)},0))}else k&&R(k)&&k.is(l)&&k.tableKey=== | ||
a.getKey()&&(q=ea?(c._window||window).getSelection():null)&&q.anchorNode&&q.focusNode&&(n=(n=v.$getNearestNodeFromDOMNode(q.focusNode))&&!a.is(T(n)),u=(u=v.$getNearestNodeFromDOMNode(q.anchorNode))&&a.is(T(u)),n&&u&&0<q.rangeCount&&(n=v.$createRangeSelectionFromDom(q,c)))&&(n.anchor.set(a.getKey(),k.isBackward()?a.getChildrenSize():0,"element"),q.removeAllRanges(),v.$setSelection(n));if(k&&!k.is(l)&&(R(k)||R(l))&&g.tableSelection&&!g.tableSelection.is(l))return R(k)&&k.tableKey===g.tableNodeKey?g.updateTableTableSelection(k): | ||
!R(k)&&R(l)&&l.tableKey===g.tableNodeKey&&g.updateTableTableSelection(null),!1;g.hasHijackedSelectionStyles&&!a.isSelected()?za(c,g):!g.hasHijackedSelectionStyles&&a.isSelected()&&ya(c,g);return!1},v.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(v.INSERT_PARAGRAPH_COMMAND,()=>{var k=v.$getSelection();return v.$isRangeSelection(k)&&k.isCollapsed()&&U(k,a)?(k=Ka(c,k,a))?(Ja(k,a),!0):!1:!1},v.COMMAND_PRIORITY_CRITICAL));return g};exports.getDOMCellFromTarget=ua; | ||
exports.getTableObserverFromTableElement=function(a){return a.__lexicalTableSelection} | ||
v.DELETE_CHARACTER_COMMAND].forEach(k=>{g.listenersToRemove.add(c.registerCommand(k,t(k),v.COMMAND_PRIORITY_CRITICAL))});b=k=>{const l=v.$getSelection();if(!U(l,a)){if(k=l?l.getNodes():null)if(k=k.find(n=>N(n)&&n.getKey()===g.tableNodeKey),N(k)){if(!k.getParent())return!1;k.remove()}return!1}if(R(l))return k.preventDefault(),k.stopPropagation(),g.clearText(),!0;v.$isRangeSelection(l)&&(k=h.$findMatchingParent(l.anchor.getNode(),n=>A(n)),A(k));return!1};g.listenersToRemove.add(c.registerCommand(v.KEY_BACKSPACE_COMMAND, | ||
b,v.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(v.KEY_DELETE_COMMAND,b,v.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(v.FORMAT_TEXT_COMMAND,k=>{let l=v.$getSelection();if(!U(l,a))return!1;if(R(l))return g.formatCells(k),!0;v.$isRangeSelection(l)&&(k=h.$findMatchingParent(l.anchor.getNode(),n=>A(n)),A(k));return!1},v.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(v.FORMAT_ELEMENT_COMMAND,k=>{var l=v.$getSelection();if(!R(l)|| | ||
!U(l,a))return!1;var n=l.anchor.getNode();l=l.focus.getNode();if(!A(n)||!A(l))return!1;let [q,u,w]=P(a,n,l);n=Math.max(u.startRow,w.startRow);l=Math.max(u.startColumn,w.startColumn);var B=Math.min(u.startRow,w.startRow);let E=Math.min(u.startColumn,w.startColumn);for(;B<=n;B++)for(let H=E;H<=l;H++){var F=q[B][H].cell;F.setFormat(k);F=F.getChildren();for(let L=0;L<F.length;L++){let M=F[L];v.$isElementNode(M)&&!M.isInline()&&M.setFormat(k)}}return!0},v.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(v.CONTROLLED_TEXT_INSERTION_COMMAND, | ||
k=>{var l=v.$getSelection();if(!U(l,a))return!1;if(R(l))g.clearHighlight();else if(v.$isRangeSelection(l)){let n=h.$findMatchingParent(l.anchor.getNode(),q=>A(q));if(!A(n))return!1;if("string"===typeof k&&(l=Ka(c,l,a)))return Ja(l,a,[v.$createTextNode(k)]),!0}return!1},v.COMMAND_PRIORITY_CRITICAL));d&&g.listenersToRemove.add(c.registerCommand(v.KEY_TAB_COMMAND,k=>{var l=v.$getSelection();if(!v.$isRangeSelection(l)||!l.isCollapsed()||!U(l,a))return!1;l=Da(l.anchor.getNode());if(null===l)return!1;Z(k); | ||
l=a.getCordsFromCellNode(l,g.table);Aa(g,a,l.x,l.y,k.shiftKey?"backward":"forward");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,k=>{let {nodes:l,selection:n}=k;k=n.getStartEndPoints();var q=R(n);q=v.$isRangeSelection(n)&&null!==h.$findMatchingParent(n.anchor.getNode(),J=>A(J))&&null!==h.$findMatchingParent(n.focus.getNode(), | ||
J=>A(J))||q;if(1!==l.length||!N(l[0])||!q||null===k)return!1;var [u]=k,w=l[0];k=w.getChildren();q=w.getFirstChildOrThrow().getChildrenSize();w=w.getChildrenSize();var B=h.$findMatchingParent(u.getNode(),J=>A(J)),E=(u=B&&h.$findMatchingParent(B,J=>G(J)))&&h.$findMatchingParent(u,J=>N(J));if(!A(B)||!G(u)||!N(E))return!1;var F=u.getIndexWithinParent(),H=Math.min(E.getChildrenSize()-1,F+w-1);w=B.getIndexWithinParent();B=Math.min(u.getChildrenSize()-1,w+q-1);q=Math.min(w,B);u=Math.min(F,H);w=Math.max(w, | ||
B);F=Math.max(F,H);E=E.getChildren();H=0;let L,M;for(B=u;B<=F;B++){var fa=E[B];if(!G(fa))return!1;var ha=k[H];if(!G(ha))return!1;fa=fa.getChildren();ha=ha.getChildren();let J=0;for(let W=q;W<=w;W++){let X=fa[W];if(!A(X))return!1;let Ca=ha[J];if(!A(Ca))return!1;B===u&&W===q?L=X.getKey():B===F&&W===w&&(M=X.getKey());let Oa=X.getChildren();Ca.getChildren().forEach(Y=>{v.$isTextNode(Y)&&v.$createParagraphNode().append(Y);X.append(Y)});Oa.forEach(Y=>Y.remove());J++}H++}L&&M&&(k=ra(),k.set(l[0].getKey(), | ||
L,M),v.$setSelection(k));return!0},v.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(v.SELECTION_CHANGE_COMMAND,()=>{let k=v.$getSelection(),l=v.$getPreviousSelection();if(v.$isRangeSelection(k)){let {anchor:B,focus:E}=k;var n=B.getNode(),q=E.getNode();n=Da(n);var u=Da(q);q=!(!n||!a.is(T(n)));var w=!(!u||!a.is(T(u)));let F=q!==w,H=q&&w;q=k.isBackward();F?(n=k.clone(),w?([w]=P(a,u,u),u=w[0][0].cell,w=w[w.length-1].at(-1).cell,n.focus.set(q?u.getKey():w.getKey(),q?u.getChildrenSize(): | ||
w.getChildrenSize(),"element")):n.anchor.set(a.getParentOrThrow().getKey(),q?a.getIndexWithinParent()+1:a.getIndexWithinParent(),"element"),v.$setSelection(n),ya(c,g)):H&&!n.is(u)&&(g.setAnchorCellForSelection(e(n)),g.setFocusCellForSelection(e(u),!0),g.isSelecting||setTimeout(()=>{let {onMouseUp:L,onMouseMove:M}=r();g.isSelecting=!0;m.addEventListener("mouseup",L);m.addEventListener("mousemove",M)},0))}else k&&R(k)&&k.is(l)&&k.tableKey===a.getKey()&&(q=ea?(c._window||window).getSelection():null)&& | ||
q.anchorNode&&q.focusNode&&(n=(n=v.$getNearestNodeFromDOMNode(q.focusNode))&&!a.is(T(n)),u=(u=v.$getNearestNodeFromDOMNode(q.anchorNode))&&a.is(T(u)),n&&u&&0<q.rangeCount&&(n=v.$createRangeSelectionFromDom(q,c)))&&(n.anchor.set(a.getKey(),k.isBackward()?a.getChildrenSize():0,"element"),q.removeAllRanges(),v.$setSelection(n));if(k&&!k.is(l)&&(R(k)||R(l))&&g.tableSelection&&!g.tableSelection.is(l))return R(k)&&k.tableKey===g.tableNodeKey?g.updateTableTableSelection(k):!R(k)&&R(l)&&l.tableKey===g.tableNodeKey&& | ||
g.updateTableTableSelection(null),!1;g.hasHijackedSelectionStyles&&!a.isSelected()?za(c,g):!g.hasHijackedSelectionStyles&&a.isSelected()&&ya(c,g);return!1},v.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(v.INSERT_PARAGRAPH_COMMAND,()=>{var k=v.$getSelection();return v.$isRangeSelection(k)&&k.isCollapsed()&&U(k,a)?(k=Ka(c,k,a))?(Ja(k,a),!0):!1:!1},v.COMMAND_PRIORITY_CRITICAL));return g};exports.getDOMCellFromTarget=ua;exports.getTableObserverFromTableElement=function(a){return a.__lexicalTableSelection} |
@@ -11,8 +11,8 @@ { | ||
"license": "MIT", | ||
"version": "0.16.2-nightly.20240726.0", | ||
"version": "0.16.2-nightly.20240729.0", | ||
"main": "LexicalTable.js", | ||
"types": "index.d.ts", | ||
"dependencies": { | ||
"@lexical/utils": "0.16.2-nightly.20240726.0", | ||
"lexical": "0.16.2-nightly.20240726.0" | ||
"@lexical/utils": "0.16.2-nightly.20240729.0", | ||
"lexical": "0.16.2-nightly.20240729.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
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
316789
6265
+ Added@lexical/list@0.16.2-nightly.20240729.0(transitive)
+ Added@lexical/selection@0.16.2-nightly.20240729.0(transitive)
+ Added@lexical/utils@0.16.2-nightly.20240729.0(transitive)
+ Addedlexical@0.16.2-nightly.20240729.0(transitive)
- Removed@lexical/list@0.16.2-nightly.20240726.0(transitive)
- Removed@lexical/selection@0.16.2-nightly.20240726.0(transitive)
- Removed@lexical/utils@0.16.2-nightly.20240726.0(transitive)
- Removedlexical@0.16.2-nightly.20240726.0(transitive)