New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@lexical/utils

Package Overview
Dependencies
Maintainers
5
Versions
258
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lexical/utils - npm Package Compare versions

Comparing version 0.23.2-nightly.20250129.0 to 0.23.2-nightly.20250130.0

17

index.d.ts

@@ -81,2 +81,11 @@ /**

export declare function $dfs(startNode?: LexicalNode, endNode?: LexicalNode): Array<DFSNode>;
/**
* A function which will return exactly the reversed order of $dfs. That means that the tree is traversed
* from right to left, starting at the leaf and working towards the root.
* @param startNode - The node to start the search. If omitted, it will start at the last leaf node in the tree.
* @param endNode - The node to end the search. If omitted, it will work backwards all the way to the root node
* @returns An array of objects of all the nodes found by the search, including their depth into the tree.
* \\{depth: number, node: LexicalNode\\} It will always return at least 1 node (the start node).
*/
export declare function $reverseDfs(startNode?: LexicalNode, endNode?: LexicalNode): Array<DFSNode>;
type DFSIterator = {

@@ -113,2 +122,10 @@ next: () => IteratorResult<DFSNode, void>;

/**
* An iterator which will traverse the tree in exactly the reversed order of $dfsIterator. Tree traversal is done
* on the fly as new values are requested with O(1) memory.
* @param startNode - The node to start the search. If omitted, it will start at the last leaf node in the tree.
* @param endNode - The node to end the search. If omitted, it will work backwards all the way to the root node
* @returns An iterator, each yielded value is a DFSNode. It will always return at least 1 node (the start node).
*/
export declare function $reverseDfsIterator(startNode?: LexicalNode, endNode?: LexicalNode): DFSIterator;
/**
* Takes a node and traverses up its ancestors (toward the root node)

@@ -115,0 +132,0 @@ * in order to find a specific type of node.

@@ -542,2 +542,14 @@ /**

}
/**
* A function which will return exactly the reversed order of $dfs. That means that the tree is traversed
* from right to left, starting at the leaf and working towards the root.
* @param startNode - The node to start the search. If omitted, it will start at the last leaf node in the tree.
* @param endNode - The node to end the search. If omitted, it will work backwards all the way to the root node
* @returns An array of objects of all the nodes found by the search, including their depth into the tree.
* \\{depth: number, node: LexicalNode\\} It will always return at least 1 node (the start node).
*/
function $reverseDfs(startNode, endNode) {
return Array.from($reverseDfsIterator(startNode, endNode));
}
const iteratorDone = {

@@ -669,2 +681,75 @@ done: true,

/**
* An iterator which will traverse the tree in exactly the reversed order of $dfsIterator. Tree traversal is done
* on the fly as new values are requested with O(1) memory.
* @param startNode - The node to start the search. If omitted, it will start at the last leaf node in the tree.
* @param endNode - The node to end the search. If omitted, it will work backwards all the way to the root node
* @returns An iterator, each yielded value is a DFSNode. It will always return at least 1 node (the start node).
*/
function $reverseDfsIterator(startNode, endNode) {
const start = (startNode || lexical.$getRoot().getLastDescendant() || lexical.$getRoot()).getLatest();
const startDepth = $getDepth(start);
const end = endNode || lexical.$getRoot();
let node = start;
let depth = startDepth;
let isFirstNext = true;
const iterator = {
next() {
if (node === null) {
return iteratorDone;
}
if (isFirstNext) {
isFirstNext = false;
return iteratorNotDone({
depth,
node
});
}
if (node === end) {
return iteratorDone;
}
if (node.getPreviousSibling()) {
let depthDiff;
[node, depthDiff] = $getPreviousSiblingsLastDescendantOrPreviousSibling(node) || [null, 0];
depth += depthDiff;
} else {
node = node.getParent();
depth--;
}
if (node === null) {
return iteratorDone;
}
return iteratorNotDone({
depth,
node
});
},
[Symbol.iterator]() {
return iterator;
}
};
return iterator;
}
/**
* Returns the previous sibling's last descendant (when it exists) or the previous sibling.
* R -> P -> T1
* -> T2
* -> P2
* returns T1 for node T2, T2 for node P2, and null for node T1 or P.
* @param node LexicalNode.
* @returns an array (tuple) coontaining the found Lexical node and the depth difference, or null, if this node doesn't exist.
*/
function $getPreviousSiblingsLastDescendantOrPreviousSibling(node) {
let _node = node.getPreviousSibling();
let depthDiff = 0;
while (lexical.$isElementNode(_node) && _node.getChildrenSize() > 0) {
_node = _node.getLastChild();
depthDiff++;
}
if (_node === null) {
return null;
}
return [_node, depthDiff];
}
/**
* Takes a node and traverses up its ancestors (toward the root node)

@@ -1109,2 +1194,4 @@ * in order to find a specific type of node.

exports.$restoreEditorState = $restoreEditorState;
exports.$reverseDfs = $reverseDfs;
exports.$reverseDfsIterator = $reverseDfsIterator;
exports.$unwrapAndFilterDescendants = $unwrapAndFilterDescendants;

@@ -1111,0 +1198,0 @@ exports.$unwrapNode = $unwrapNode;

2

LexicalUtils.prod.js

@@ -9,2 +9,2 @@ /**

"use strict";var e=require("lexical"),t=require("@lexical/selection");function n(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var o=n((function(e){const t=new URLSearchParams;t.append("code",e);for(let e=1;e<arguments.length;e++)t.append("v",arguments[e]);throw Error(`Minified Lexical error #${e}; visit https://lexical.dev/docs/error?${t} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}));const r="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,l=r&&"documentMode"in document?document.documentMode:null,i=r&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),s=r&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),u=!(!r||!("InputEvent"in window)||l)&&"getTargetRanges"in new window.InputEvent("input"),c=r&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),d=r&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,a=r&&/Android/.test(navigator.userAgent),f=r&&/^(?=.*Chrome).*/i.test(navigator.userAgent),p=r&&a&&f,g=r&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!f;function m(...e){const t=[];for(const n of e)if(n&&"string"==typeof n)for(const[e]of n.matchAll(/\S+/g))t.push(e);return t}function h(...e){return()=>{for(let t=e.length-1;t>=0;t--)e[t]();e.length=0}}function x(e){return`${e}px`}const E={attributes:!0,characterData:!0,childList:!0,subtree:!0};function v(n,r,l){let i=null,s=null,u=null,c=[];const d=document.createElement("div");function a(){null===i&&o(182),null===s&&o(183);const{left:e,top:u}=s.getBoundingClientRect(),a=t.createRectsFromDOMRange(n,r);var f,p;d.isConnected||(p=d,(f=s).insertBefore(p,f.firstChild));let g=!1;for(let t=0;t<a.length;t++){const n=a[t],o=c[t]||document.createElement("div"),r=o.style;"absolute"!==r.position&&(r.position="absolute",g=!0);const l=x(n.left-e);r.left!==l&&(r.left=l,g=!0);const i=x(n.top-u);r.top!==i&&(o.style.top=i,g=!0);const s=x(n.width);r.width!==s&&(o.style.width=s,g=!0);const f=x(n.height);r.height!==f&&(o.style.height=f,g=!0),o.parentNode!==d&&(d.append(o),g=!0),c[t]=o}for(;c.length>a.length;)c.pop();g&&l(c)}function f(){s=null,i=null,null!==u&&u.disconnect(),u=null,d.remove();for(const e of c)e.remove();c=[]}d.style.position="relative";const p=n.registerRootListener((function t(){const o=n.getRootElement();if(null===o)return f();const r=o.parentElement;if(!e.isHTMLElement(r))return f();f(),i=o,s=r,u=new MutationObserver((e=>{const o=n.getRootElement(),r=o&&o.parentElement;if(o!==i||r!==s)return t();for(const t of e)if(!d.contains(t.target))return a()})),u.observe(r,E),a()}));return()=>{p(),f()}}function S(t,n,o){if("text"!==t.type&&e.$isElementNode(n)){const e=n.getDOMSlot(o);return[e.element,e.getFirstChildOffset()+t.offset]}return[e.getDOMTextNode(o)||o,t.offset]}function N(t,n){let o=null,r=null,l=null,i=null,s=null,u=null,c=()=>{};function d(d){d.read((()=>{const d=e.$getSelection();if(!e.$isRangeSelection(d))return o=null,l=null,i=null,u=null,c(),void(c=()=>{});const{anchor:a,focus:f}=d,p=a.getNode(),g=p.getKey(),m=a.offset,h=f.getNode(),E=h.getKey(),N=f.offset,$=t.getElementByKey(g),y=t.getElementByKey(E),w=null===o||$!==r||m!==l||g!==o.getKey(),R=null===i||y!==s||N!==u||E!==i.getKey();if((w||R)&&null!==$&&null!==y){const e=function(e,t,n,o,r,l,i){const s=(e._window?e._window.document:document).createRange();return l.isBefore(n)?(s.setStart(...S(r,l,i)),s.setEnd(...S(t,n,o))):(s.setStart(...S(t,n,o)),s.setEnd(...S(r,l,i))),s}(t,a,p,$,f,h,y);c(),c=v(t,e,(e=>{if(void 0===n)for(const t of e){const e=t.style;"Highlight"!==e.background&&(e.background="Highlight"),"HighlightText"!==e.color&&(e.color="HighlightText"),e.marginTop!==x(-1.5)&&(e.marginTop=x(-1.5)),e.paddingTop!==x(4)&&(e.paddingTop=x(4)),e.paddingBottom!==x(0)&&(e.paddingBottom=x(0))}else n(e)}))}o=p,r=$,l=m,i=h,s=y,u=N}))}return d(t.getEditorState()),h(t.registerUpdateListener((({editorState:e})=>d(e))),(()=>{c()}))}const $=u,y=r,w=a,R=p,P=i,A=g,T=f,b=s,I=d,_=c;function C(e,t){for(const n of t)if(e.type.startsWith(n))return!0;return!1}const L={done:!0,value:void 0},O=e=>({done:!1,value:e});function M(t,n){const o=(t||e.$getRoot()).getLatest(),r=D(o),l=n;let i=o,s=r,u=!0;const c={next(){if(null===i)return L;if(u)return u=!1,O({depth:s,node:i});if(i===l)return L;if(e.$isElementNode(i)&&i.getChildrenSize()>0)i=i.getFirstChild(),s++;else{let e;[i,e]=B(i)||[null,0],s+=e,null==l&&s<=r&&(i=null)}return null===i?L:O({depth:s,node:i})},[Symbol.iterator]:()=>c};return c}function B(e){let t=e,n=null,o=0;for(;null===n&&null!==t;)n=t.getNextSibling(),null===n?(t=t.getParent(),o--):t=n;return null===t?null:[t,o]}function D(e){let t=e,n=0;for(;null!==(t=t.getParent());)n++;return n}const F=(t,n)=>{let o=t;for(;o!==e.$getRoot()&&null!=o;){if(n(o))return o;o=o.getParent()}return null};let H=!(b||!y)&&void 0;function K(t,n,o){let r=!1;for(const l of U(t))n(l)?null!==o&&o(l):(r=!0,e.$isElementNode(l)&&K(l,n,o||(e=>l.insertAfter(e))),l.remove());return r}function k(e){return{[Symbol.iterator]:()=>z(e.getFirstChild(),(e=>e.getNextSibling()))}}function U(e){return{[Symbol.iterator]:()=>z(e.getLastChild(),(e=>e.getPreviousSibling()))}}function z(e,t){let n=e;return{next(){if(null===n)return L;const e=O(n);return n=t(n),e}}}exports.$splitNode=e.$splitNode,exports.isBlockDomNode=e.isBlockDomNode,exports.isHTMLAnchorElement=e.isHTMLAnchorElement,exports.isHTMLElement=e.isHTMLElement,exports.isInlineDomNode=e.isInlineDomNode,exports.$descendantsMatching=function(t,n){const o=[],r=[...t].reverse();for(let t=r.pop();void 0!==t;t=r.pop())if(n(t))o.push(t);else if(e.$isElementNode(t))for(const e of U(t))r.push(e);return o},exports.$dfs=function(e,t){return Array.from(M(e,t))},exports.$dfsIterator=M,exports.$filter=function(e,t){const n=[];for(let o=0;o<e.length;o++){const r=t(e[o]);null!==r&&n.push(r)}return n},exports.$findMatchingParent=F,exports.$firstToLastIterator=k,exports.$getDepth=D,exports.$getNearestBlockElementAncestorOrThrow=function(t){const n=F(t,(t=>e.$isElementNode(t)&&!t.isInline()));return e.$isElementNode(n)||o(4,t.__key),n},exports.$getNearestNodeOfType=function(e,t){let n=e;for(;null!=n;){if(n instanceof t)return n;n=n.getParent()}return null},exports.$getNextRightPreorderNode=function(t){let n=t;if(e.$isElementNode(n)&&n.getChildrenSize()>0)n=n.getLastChild();else{let e=null;for(;null===e&&null!==n;)e=n.getPreviousSibling(),n=null===e?n.getParent():e}return n},exports.$getNextSiblingOrParentSibling=B,exports.$insertFirst=function(e,t){const n=e.getFirstChild();null!==n?n.insertBefore(t):e.append(t)},exports.$insertNodeToNearestRoot=function(t){const n=e.$getSelection()||e.$getPreviousSelection();if(e.$isRangeSelection(n)){const{focus:o}=n,r=o.getNode(),l=o.offset;if(e.$isRootOrShadowRoot(r)){const e=r.getChildAtIndex(l);null==e?r.append(t):e.insertBefore(t),t.selectNext()}else{let n,o;e.$isTextNode(r)?(n=r.getParentOrThrow(),o=r.getIndexWithinParent(),l>0&&(o+=1,r.splitText(l))):(n=r,o=l);const[,i]=e.$splitNode(n,o);i.insertBefore(t),i.selectStart()}}else{if(null!=n){const e=n.getNodes();e[e.length-1].getTopLevelElementOrThrow().insertAfter(t)}else{e.$getRoot().append(t)}const o=e.$createParagraphNode();t.insertAfter(o),o.select()}return t.getLatest()},exports.$isEditorIsNestedEditor=function(e){return null!==e._parentEditor},exports.$lastToFirstIterator=U,exports.$restoreEditorState=function(t,n){const o=new Map,r=t._pendingEditorState;for(const[t,r]of n._nodeMap)o.set(t,e.$cloneWithProperties(r));r&&(r._nodeMap=o),t._dirtyType=2;const l=n._selection;e.$setSelection(null===l?null:l.clone())},exports.$unwrapAndFilterDescendants=function(e,t){return K(e,t,null)},exports.$unwrapNode=function(e){for(const t of k(e))e.insertBefore(t);e.remove()},exports.$wrapNodeInElement=function(e,t){const n=t();return e.replace(n),n.append(e),n},exports.CAN_USE_BEFORE_INPUT=$,exports.CAN_USE_DOM=y,exports.IS_ANDROID=w,exports.IS_ANDROID_CHROME=R,exports.IS_APPLE=P,exports.IS_APPLE_WEBKIT=A,exports.IS_CHROME=T,exports.IS_FIREFOX=b,exports.IS_IOS=I,exports.IS_SAFARI=_,exports.addClassNamesToElement=function(e,...t){const n=m(...t);n.length>0&&e.classList.add(...n)},exports.calculateZoomLevel=function(e){let t=1;if(function(){if(void 0===H){const e=document.createElement("div");e.style.cssText="position: absolute; opacity: 0; width: 100px; left: -1000px;",document.body.appendChild(e);const t=e.getBoundingClientRect();e.style.setProperty("zoom","2"),H=e.getBoundingClientRect().width===t.width,document.body.removeChild(e)}return H}())for(;e;)t*=Number(window.getComputedStyle(e).getPropertyValue("zoom")),e=e.parentElement;return t},exports.isMimeType=C,exports.markSelection=N,exports.mediaFileReader=function(e,t){const n=e[Symbol.iterator]();return new Promise(((e,o)=>{const r=[],l=()=>{const{done:i,value:s}=n.next();if(i)return e(r);const u=new FileReader;u.addEventListener("error",o),u.addEventListener("load",(()=>{const e=u.result;"string"==typeof e&&r.push({file:s,result:e}),l()})),C(s,t)?u.readAsDataURL(s):l()};l()}))},exports.mergeRegister=h,exports.objectKlassEquals=function(e,t){return null!==e&&Object.getPrototypeOf(e).constructor.name===t.name},exports.positionNodeOnRange=v,exports.registerNestedElementResolver=function(e,t,n,o){const r=e=>e instanceof t;return e.registerNodeTransform(t,(e=>{const t=(e=>{const t=e.getChildren();for(let e=0;e<t.length;e++){const n=t[e];if(r(n))return null}let n=e,o=e;for(;null!==n;)if(o=n,n=n.getParent(),r(n))return{child:o,parent:n};return null})(e);if(null!==t){const{child:r,parent:l}=t;if(r.is(e)){o(l,e);const t=r.getNextSiblings(),i=t.length;if(l.insertAfter(r),0!==i){const e=n(l);r.insertAfter(e);for(let n=0;n<i;n++)e.append(t[n])}l.canBeEmpty()||0!==l.getChildrenSize()||l.remove()}}}))},exports.removeClassNamesFromElement=function(e,...t){const n=m(...t);n.length>0&&e.classList.remove(...n)},exports.selectionAlwaysOnDisplay=function(e){let t=null;const n=()=>{const n=getSelection(),o=n&&n.anchorNode,r=e.getRootElement();null!==o&&null!==r&&r.contains(o)?null!==t&&(t(),t=null):null===t&&(t=N(e))};return document.addEventListener("selectionchange",n),()=>{null!==t&&t(),document.removeEventListener("selectionchange",n)}};
"use strict";var e=require("lexical"),t=require("@lexical/selection");function n(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var o=n((function(e){const t=new URLSearchParams;t.append("code",e);for(let e=1;e<arguments.length;e++)t.append("v",arguments[e]);throw Error(`Minified Lexical error #${e}; visit https://lexical.dev/docs/error?${t} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}));const r="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,l=r&&"documentMode"in document?document.documentMode:null,i=r&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),s=r&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),u=!(!r||!("InputEvent"in window)||l)&&"getTargetRanges"in new window.InputEvent("input"),c=r&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),d=r&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,a=r&&/Android/.test(navigator.userAgent),f=r&&/^(?=.*Chrome).*/i.test(navigator.userAgent),g=r&&a&&f,p=r&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!f;function m(...e){const t=[];for(const n of e)if(n&&"string"==typeof n)for(const[e]of n.matchAll(/\S+/g))t.push(e);return t}function h(...e){return()=>{for(let t=e.length-1;t>=0;t--)e[t]();e.length=0}}function x(e){return`${e}px`}const v={attributes:!0,characterData:!0,childList:!0,subtree:!0};function E(n,r,l){let i=null,s=null,u=null,c=[];const d=document.createElement("div");function a(){null===i&&o(182),null===s&&o(183);const{left:e,top:u}=s.getBoundingClientRect(),a=t.createRectsFromDOMRange(n,r);var f,g;d.isConnected||(g=d,(f=s).insertBefore(g,f.firstChild));let p=!1;for(let t=0;t<a.length;t++){const n=a[t],o=c[t]||document.createElement("div"),r=o.style;"absolute"!==r.position&&(r.position="absolute",p=!0);const l=x(n.left-e);r.left!==l&&(r.left=l,p=!0);const i=x(n.top-u);r.top!==i&&(o.style.top=i,p=!0);const s=x(n.width);r.width!==s&&(o.style.width=s,p=!0);const f=x(n.height);r.height!==f&&(o.style.height=f,p=!0),o.parentNode!==d&&(d.append(o),p=!0),c[t]=o}for(;c.length>a.length;)c.pop();p&&l(c)}function f(){s=null,i=null,null!==u&&u.disconnect(),u=null,d.remove();for(const e of c)e.remove();c=[]}d.style.position="relative";const g=n.registerRootListener((function t(){const o=n.getRootElement();if(null===o)return f();const r=o.parentElement;if(!e.isHTMLElement(r))return f();f(),i=o,s=r,u=new MutationObserver((e=>{const o=n.getRootElement(),r=o&&o.parentElement;if(o!==i||r!==s)return t();for(const t of e)if(!d.contains(t.target))return a()})),u.observe(r,v),a()}));return()=>{g(),f()}}function S(t,n,o){if("text"!==t.type&&e.$isElementNode(n)){const e=n.getDOMSlot(o);return[e.element,e.getFirstChildOffset()+t.offset]}return[e.getDOMTextNode(o)||o,t.offset]}function $(t,n){let o=null,r=null,l=null,i=null,s=null,u=null,c=()=>{};function d(d){d.read((()=>{const d=e.$getSelection();if(!e.$isRangeSelection(d))return o=null,l=null,i=null,u=null,c(),void(c=()=>{});const{anchor:a,focus:f}=d,g=a.getNode(),p=g.getKey(),m=a.offset,h=f.getNode(),v=h.getKey(),$=f.offset,N=t.getElementByKey(p),y=t.getElementByKey(v),w=null===o||N!==r||m!==l||p!==o.getKey(),R=null===i||y!==s||$!==u||v!==i.getKey();if((w||R)&&null!==N&&null!==y){const e=function(e,t,n,o,r,l,i){const s=(e._window?e._window.document:document).createRange();return l.isBefore(n)?(s.setStart(...S(r,l,i)),s.setEnd(...S(t,n,o))):(s.setStart(...S(t,n,o)),s.setEnd(...S(r,l,i))),s}(t,a,g,N,f,h,y);c(),c=E(t,e,(e=>{if(void 0===n)for(const t of e){const e=t.style;"Highlight"!==e.background&&(e.background="Highlight"),"HighlightText"!==e.color&&(e.color="HighlightText"),e.marginTop!==x(-1.5)&&(e.marginTop=x(-1.5)),e.paddingTop!==x(4)&&(e.paddingTop=x(4)),e.paddingBottom!==x(0)&&(e.paddingBottom=x(0))}else n(e)}))}o=g,r=N,l=m,i=h,s=y,u=$}))}return d(t.getEditorState()),h(t.registerUpdateListener((({editorState:e})=>d(e))),(()=>{c()}))}const N=u,y=r,w=a,R=g,P=i,A=p,b=f,T=s,L=d,C=c;function I(e,t){for(const n of t)if(e.type.startsWith(n))return!0;return!1}const _={done:!0,value:void 0},O=e=>({done:!1,value:e});function M(t,n){const o=(t||e.$getRoot()).getLatest(),r=B(o),l=n;let i=o,s=r,u=!0;const c={next(){if(null===i)return _;if(u)return u=!1,O({depth:s,node:i});if(i===l)return _;if(e.$isElementNode(i)&&i.getChildrenSize()>0)i=i.getFirstChild(),s++;else{let e;[i,e]=D(i)||[null,0],s+=e,null==l&&s<=r&&(i=null)}return null===i?_:O({depth:s,node:i})},[Symbol.iterator]:()=>c};return c}function D(e){let t=e,n=null,o=0;for(;null===n&&null!==t;)n=t.getNextSibling(),null===n?(t=t.getParent(),o--):t=n;return null===t?null:[t,o]}function B(e){let t=e,n=0;for(;null!==(t=t.getParent());)n++;return n}function F(t,n){const o=(t||e.$getRoot().getLastDescendant()||e.$getRoot()).getLatest(),r=B(o),l=n||e.$getRoot();let i=o,s=r,u=!0;const c={next(){if(null===i)return _;if(u)return u=!1,O({depth:s,node:i});if(i===l)return _;if(i.getPreviousSibling()){let t;[i,t]=function(t){let n=t.getPreviousSibling(),o=0;for(;e.$isElementNode(n)&&n.getChildrenSize()>0;)n=n.getLastChild(),o++;if(null===n)return null;return[n,o]}(i)||[null,0],s+=t}else i=i.getParent(),s--;return null===i?_:O({depth:s,node:i})},[Symbol.iterator]:()=>c};return c}const H=(t,n)=>{let o=t;for(;o!==e.$getRoot()&&null!=o;){if(n(o))return o;o=o.getParent()}return null};let K=!(T||!y)&&void 0;function k(t,n,o){let r=!1;for(const l of U(t))n(l)?null!==o&&o(l):(r=!0,e.$isElementNode(l)&&k(l,n,o||(e=>l.insertAfter(e))),l.remove());return r}function z(e){return{[Symbol.iterator]:()=>W(e.getFirstChild(),(e=>e.getNextSibling()))}}function U(e){return{[Symbol.iterator]:()=>W(e.getLastChild(),(e=>e.getPreviousSibling()))}}function W(e,t){let n=e;return{next(){if(null===n)return _;const e=O(n);return n=t(n),e}}}exports.$splitNode=e.$splitNode,exports.isBlockDomNode=e.isBlockDomNode,exports.isHTMLAnchorElement=e.isHTMLAnchorElement,exports.isHTMLElement=e.isHTMLElement,exports.isInlineDomNode=e.isInlineDomNode,exports.$descendantsMatching=function(t,n){const o=[],r=[...t].reverse();for(let t=r.pop();void 0!==t;t=r.pop())if(n(t))o.push(t);else if(e.$isElementNode(t))for(const e of U(t))r.push(e);return o},exports.$dfs=function(e,t){return Array.from(M(e,t))},exports.$dfsIterator=M,exports.$filter=function(e,t){const n=[];for(let o=0;o<e.length;o++){const r=t(e[o]);null!==r&&n.push(r)}return n},exports.$findMatchingParent=H,exports.$firstToLastIterator=z,exports.$getDepth=B,exports.$getNearestBlockElementAncestorOrThrow=function(t){const n=H(t,(t=>e.$isElementNode(t)&&!t.isInline()));return e.$isElementNode(n)||o(4,t.__key),n},exports.$getNearestNodeOfType=function(e,t){let n=e;for(;null!=n;){if(n instanceof t)return n;n=n.getParent()}return null},exports.$getNextRightPreorderNode=function(t){let n=t;if(e.$isElementNode(n)&&n.getChildrenSize()>0)n=n.getLastChild();else{let e=null;for(;null===e&&null!==n;)e=n.getPreviousSibling(),n=null===e?n.getParent():e}return n},exports.$getNextSiblingOrParentSibling=D,exports.$insertFirst=function(e,t){const n=e.getFirstChild();null!==n?n.insertBefore(t):e.append(t)},exports.$insertNodeToNearestRoot=function(t){const n=e.$getSelection()||e.$getPreviousSelection();if(e.$isRangeSelection(n)){const{focus:o}=n,r=o.getNode(),l=o.offset;if(e.$isRootOrShadowRoot(r)){const e=r.getChildAtIndex(l);null==e?r.append(t):e.insertBefore(t),t.selectNext()}else{let n,o;e.$isTextNode(r)?(n=r.getParentOrThrow(),o=r.getIndexWithinParent(),l>0&&(o+=1,r.splitText(l))):(n=r,o=l);const[,i]=e.$splitNode(n,o);i.insertBefore(t),i.selectStart()}}else{if(null!=n){const e=n.getNodes();e[e.length-1].getTopLevelElementOrThrow().insertAfter(t)}else{e.$getRoot().append(t)}const o=e.$createParagraphNode();t.insertAfter(o),o.select()}return t.getLatest()},exports.$isEditorIsNestedEditor=function(e){return null!==e._parentEditor},exports.$lastToFirstIterator=U,exports.$restoreEditorState=function(t,n){const o=new Map,r=t._pendingEditorState;for(const[t,r]of n._nodeMap)o.set(t,e.$cloneWithProperties(r));r&&(r._nodeMap=o),t._dirtyType=2;const l=n._selection;e.$setSelection(null===l?null:l.clone())},exports.$reverseDfs=function(e,t){return Array.from(F(e,t))},exports.$reverseDfsIterator=F,exports.$unwrapAndFilterDescendants=function(e,t){return k(e,t,null)},exports.$unwrapNode=function(e){for(const t of z(e))e.insertBefore(t);e.remove()},exports.$wrapNodeInElement=function(e,t){const n=t();return e.replace(n),n.append(e),n},exports.CAN_USE_BEFORE_INPUT=N,exports.CAN_USE_DOM=y,exports.IS_ANDROID=w,exports.IS_ANDROID_CHROME=R,exports.IS_APPLE=P,exports.IS_APPLE_WEBKIT=A,exports.IS_CHROME=b,exports.IS_FIREFOX=T,exports.IS_IOS=L,exports.IS_SAFARI=C,exports.addClassNamesToElement=function(e,...t){const n=m(...t);n.length>0&&e.classList.add(...n)},exports.calculateZoomLevel=function(e){let t=1;if(function(){if(void 0===K){const e=document.createElement("div");e.style.cssText="position: absolute; opacity: 0; width: 100px; left: -1000px;",document.body.appendChild(e);const t=e.getBoundingClientRect();e.style.setProperty("zoom","2"),K=e.getBoundingClientRect().width===t.width,document.body.removeChild(e)}return K}())for(;e;)t*=Number(window.getComputedStyle(e).getPropertyValue("zoom")),e=e.parentElement;return t},exports.isMimeType=I,exports.markSelection=$,exports.mediaFileReader=function(e,t){const n=e[Symbol.iterator]();return new Promise(((e,o)=>{const r=[],l=()=>{const{done:i,value:s}=n.next();if(i)return e(r);const u=new FileReader;u.addEventListener("error",o),u.addEventListener("load",(()=>{const e=u.result;"string"==typeof e&&r.push({file:s,result:e}),l()})),I(s,t)?u.readAsDataURL(s):l()};l()}))},exports.mergeRegister=h,exports.objectKlassEquals=function(e,t){return null!==e&&Object.getPrototypeOf(e).constructor.name===t.name},exports.positionNodeOnRange=E,exports.registerNestedElementResolver=function(e,t,n,o){const r=e=>e instanceof t;return e.registerNodeTransform(t,(e=>{const t=(e=>{const t=e.getChildren();for(let e=0;e<t.length;e++){const n=t[e];if(r(n))return null}let n=e,o=e;for(;null!==n;)if(o=n,n=n.getParent(),r(n))return{child:o,parent:n};return null})(e);if(null!==t){const{child:r,parent:l}=t;if(r.is(e)){o(l,e);const t=r.getNextSiblings(),i=t.length;if(l.insertAfter(r),0!==i){const e=n(l);r.insertAfter(e);for(let n=0;n<i;n++)e.append(t[n])}l.canBeEmpty()||0!==l.getChildrenSize()||l.remove()}}}))},exports.removeClassNamesFromElement=function(e,...t){const n=m(...t);n.length>0&&e.classList.remove(...n)},exports.selectionAlwaysOnDisplay=function(e){let t=null;const n=()=>{const n=getSelection(),o=n&&n.anchorNode,r=e.getRootElement();null!==o&&null!==r&&r.contains(o)?null!==t&&(t(),t=null):null===t&&(t=$(e))};return document.addEventListener("selectionchange",n),()=>{null!==t&&t(),document.removeEventListener("selectionchange",n)}};

@@ -11,10 +11,10 @@ {

"license": "MIT",
"version": "0.23.2-nightly.20250129.0",
"version": "0.23.2-nightly.20250130.0",
"main": "LexicalUtils.js",
"types": "index.d.ts",
"dependencies": {
"@lexical/list": "0.23.2-nightly.20250129.0",
"@lexical/selection": "0.23.2-nightly.20250129.0",
"@lexical/table": "0.23.2-nightly.20250129.0",
"lexical": "0.23.2-nightly.20250129.0"
"@lexical/list": "0.23.2-nightly.20250130.0",
"@lexical/selection": "0.23.2-nightly.20250130.0",
"@lexical/table": "0.23.2-nightly.20250130.0",
"lexical": "0.23.2-nightly.20250130.0"
},

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

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