Socket
Socket
Sign inDemoInstall

@lexical/utils

Package Overview
Dependencies
Maintainers
5
Versions
165
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.17.2-nightly.20240926.0 to 0.18.0

37

index.d.ts

@@ -23,6 +23,2 @@ /**

export declare const IS_SAFARI: boolean;
export type DFSNode = Readonly<{
depth: number;
node: LexicalNode;
}>;
/**

@@ -70,2 +66,6 @@ * Takes an HTML element and adds the classNames passed within an array,

}>>;
export type DFSNode = Readonly<{
depth: number;
node: LexicalNode;
}>;
/**

@@ -76,9 +76,30 @@ * "Depth-First Search" starts at the root/top node of a tree and goes as far as it can down a branch end

* It will then return all the nodes found in the search in an array of objects.
* @param startingNode - The node to start the search, if ommitted, it will start at the root node.
* @param endingNode - The node to end the search, if ommitted, it will find all descendants of the startingNode.
* @param startNode - The node to start the search, if omitted, it will start at the root node.
* @param endNode - The node to end the search, if omitted, it will find all descendants of the startingNode.
* @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 ending node) so long as it exists
* \\{depth: number, node: LexicalNode\\} It will always return at least 1 node (the start node).
*/
export declare function $dfs(startingNode?: LexicalNode, endingNode?: LexicalNode): Array<DFSNode>;
export declare function $dfs(startNode?: LexicalNode, endNode?: LexicalNode): Array<DFSNode>;
type DFSIterator = {
next: () => IteratorResult<DFSNode, void>;
[Symbol.iterator]: () => DFSIterator;
};
/**
* $dfs iterator. 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 root node.
* @param endNode - The node to end the search, if omitted, it will find all descendants of the startingNode.
* @returns An iterator, each yielded value is a DFSNode. It will always return at least 1 node (the start node).
*/
export declare function $dfsIterator(startNode?: LexicalNode, endNode?: LexicalNode): DFSIterator;
/**
* Returns the Node sibling when this exists, otherwise the closest parent sibling. For example
* R -> P -> T1, T2
* -> P2
* returns T2 for node T1, P2 for node T2, and null for node P2.
* @param node LexicalNode.
* @returns An array (tuple) containing the found Lexical node and the depth difference, or null, if this node doesn't exist.
*/
export declare function $getNextSiblingOrParentSibling(node: LexicalNode): null | [LexicalNode, number];
export declare function $getDepth(node: LexicalNode): number;
/**
* Performs a right-to-left preorder tree traversal.

@@ -85,0 +106,0 @@ * From the starting node it goes to the rightmost child, than backtracks to paret and finds new rightmost path.

@@ -388,2 +388,3 @@ /**

const IS_SAFARI = IS_SAFARI$1;
/**

@@ -480,3 +481,2 @@ * Takes an HTML element and adds the classNames passed within an array,

}
/**

@@ -487,42 +487,99 @@ * "Depth-First Search" starts at the root/top node of a tree and goes as far as it can down a branch end

* It will then return all the nodes found in the search in an array of objects.
* @param startingNode - The node to start the search, if ommitted, it will start at the root node.
* @param endingNode - The node to end the search, if ommitted, it will find all descendants of the startingNode.
* @param startNode - The node to start the search, if omitted, it will start at the root node.
* @param endNode - The node to end the search, if omitted, it will find all descendants of the startingNode.
* @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 ending node) so long as it exists
* \\{depth: number, node: LexicalNode\\} It will always return at least 1 node (the start node).
*/
function $dfs(startingNode, endingNode) {
const nodes = [];
const start = (startingNode || lexical.$getRoot()).getLatest();
const end = endingNode || (lexical.$isElementNode(start) ? start.getLastDescendant() || start : start);
function $dfs(startNode, endNode) {
return Array.from($dfsIterator(startNode, endNode));
}
const iteratorDone = {
done: true,
value: undefined
};
const iteratorNotDone = value => ({
done: false,
value
});
/**
* $dfs iterator. 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 root node.
* @param endNode - The node to end the search, if omitted, it will find all descendants of the startingNode.
* @returns An iterator, each yielded value is a DFSNode. It will always return at least 1 node (the start node).
*/
function $dfsIterator(startNode, endNode) {
const start = (startNode || lexical.$getRoot()).getLatest();
const startDepth = $getDepth(start);
const end = endNode;
let node = start;
let depth = $getDepth(node);
while (node !== null && !node.is(end)) {
nodes.push({
depth,
node
});
if (lexical.$isElementNode(node) && node.getChildrenSize() > 0) {
node = node.getFirstChild();
depth++;
} else {
// Find immediate sibling or nearest parent sibling
let sibling = null;
while (sibling === null && node !== null) {
sibling = node.getNextSibling();
if (sibling === null) {
node = node.getParent();
depth--;
} else {
node = sibling;
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 (lexical.$isElementNode(node) && node.getChildrenSize() > 0) {
node = node.getFirstChild();
depth++;
} else {
let depthDiff;
[node, depthDiff] = $getNextSiblingOrParentSibling(node) || [null, 0];
depth += depthDiff;
if (end == null && depth <= startDepth) {
node = null;
}
}
if (node === null) {
return iteratorDone;
}
return iteratorNotDone({
depth,
node
});
},
[Symbol.iterator]() {
return iterator;
}
};
return iterator;
}
/**
* Returns the Node sibling when this exists, otherwise the closest parent sibling. For example
* R -> P -> T1, T2
* -> P2
* returns T2 for node T1, P2 for node T2, and null for node P2.
* @param node LexicalNode.
* @returns An array (tuple) containing the found Lexical node and the depth difference, or null, if this node doesn't exist.
*/
function $getNextSiblingOrParentSibling(node) {
let node_ = node;
// Find immediate sibling or nearest parent sibling
let sibling = null;
let depthDiff = 0;
while (sibling === null && node_ !== null) {
sibling = node_.getNextSibling();
if (sibling === null) {
node_ = node_.getParent();
depthDiff--;
} else {
node_ = sibling;
}
}
if (node !== null && node.is(end)) {
nodes.push({
depth,
node
});
if (node_ === null) {
return null;
}
return nodes;
return [node_, depthDiff];
}

@@ -846,7 +903,10 @@ function $getDepth(node) {

exports.$dfs = $dfs;
exports.$dfsIterator = $dfsIterator;
exports.$filter = $filter;
exports.$findMatchingParent = $findMatchingParent;
exports.$getDepth = $getDepth;
exports.$getNearestBlockElementAncestorOrThrow = $getNearestBlockElementAncestorOrThrow;
exports.$getNearestNodeOfType = $getNearestNodeOfType;
exports.$getNextRightPreorderNode = $getNextRightPreorderNode;
exports.$getNextSiblingOrParentSibling = $getNextSiblingOrParentSibling;
exports.$insertFirst = $insertFirst;

@@ -853,0 +913,0 @@ exports.$insertNodeToNearestRoot = $insertNodeToNearestRoot;

@@ -11,18 +11,19 @@ /**

let E="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement,F=E&&"documentMode"in document?document.documentMode:null,G=E&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),H=E&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),I=E&&"InputEvent"in window&&!F?"getTargetRanges"in new window.InputEvent("input"):!1,J=E&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),K=E&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,
L=E&&/Android/.test(navigator.userAgent),M=E&&/^(?=.*Chrome).*/i.test(navigator.userAgent),N=E&&L&&M;function O(...a){let b=[];for(let c of a)if(c&&"string"===typeof c)for(let [e]of c.matchAll(/\S+/g))b.push(e);return b}function P(...a){return()=>{for(let b=a.length-1;0<=b;b--)a[b]();a.length=0}}let Q={attributes:!0,characterData:!0,childList:!0,subtree:!0};
function R(a,b,c){function e(){null===k&&C(182);null===n&&C(183);let {left:p,top:A}=k.getBoundingClientRect();var q=n;let r=x.createRectsFromDOMRange(a,b);t.isConnected||q.append(t);q=!1;for(let y=0;y<r.length;y++){var w=r[y];let u=h[y]||document.createElement("div"),z=u.style;"absolute"!==z.position&&(z.position="absolute",q=!0);var l=`${w.left-p}px`;z.left!==l&&(z.left=l,q=!0);l=`${w.top-A}px`;z.top!==l&&(u.style.top=l,q=!0);l=`${w.width}px`;z.width!==l&&(u.style.width=l,q=!0);w=`${w.height}px`;
z.height!==w&&(u.style.height=w,q=!0);u.parentNode!==t&&(t.append(u),q=!0);h[y]=u}for(;h.length>r.length;)h.pop();q&&c(h)}function d(){k=n=null;null!==m&&m.disconnect();m=null;t.remove();for(let p of h)p.remove();h=[]}function f(){let p=a.getRootElement();if(null===p)return d();let A=p.parentElement;if(!(A instanceof HTMLElement))return d();d();k=p;n=A;m=new MutationObserver(q=>{let r=a.getRootElement(),w=r&&r.parentElement;if(r!==k||w!==n)return f();for(let l of q)if(!t.contains(l.target))return e()});
m.observe(A,Q);e()}let k=null,n=null,m=null,h=[],t=document.createElement("div"),B=a.registerRootListener(f);return()=>{B();d()}}let S=E&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!M;function T(a,b){for(let c of b)if(a.type.startsWith(c))return!0;return!1}let U=(a,b)=>{for(;a!==g.$getRoot()&&null!=a;){if(b(a))return a;a=a.getParent()}return null};exports.$splitNode=g.$splitNode;exports.isBlockDomNode=g.isBlockDomNode;exports.isHTMLAnchorElement=g.isHTMLAnchorElement;exports.isHTMLElement=g.isHTMLElement;
exports.isInlineDomNode=g.isInlineDomNode;exports.$dfs=function(a,b){let c=[];a=(a||g.$getRoot()).getLatest();b=b||(g.$isElementNode(a)?a.getLastDescendant()||a:a);for(var e=a,d=0;null!==(e=e.getParent());)d++;for(e=d;null!==a&&!a.is(b);)if(c.push({depth:e,node:a}),g.$isElementNode(a)&&0<a.getChildrenSize())a=a.getFirstChild(),e++;else for(d=null;null===d&&null!==a;)d=a.getNextSibling(),null===d?(a=a.getParent(),e--):a=d;null!==a&&a.is(b)&&c.push({depth:e,node:a});return c};
exports.$filter=function(a,b){let c=[];for(let e=0;e<a.length;e++){let d=b(a[e]);null!==d&&c.push(d)}return c};exports.$findMatchingParent=U;exports.$getNearestBlockElementAncestorOrThrow=function(a){let b=U(a,c=>g.$isElementNode(c)&&!c.isInline());g.$isElementNode(b)||C(4,a.__key);return b};exports.$getNearestNodeOfType=function(a,b){for(;null!=a;){if(a instanceof b)return a;a=a.getParent()}return null};
exports.$getNextRightPreorderNode=function(a){if(g.$isElementNode(a)&&0<a.getChildrenSize())a=a.getLastChild();else{let b=null;for(;null===b&&null!==a;)b=a.getPreviousSibling(),a=null===b?a.getParent():b}return a};exports.$insertFirst=function(a,b){let c=a.getFirstChild();null!==c?c.insertBefore(b):a.append(b)};
exports.$insertNodeToNearestRoot=function(a){var b=g.$getSelection()||g.$getPreviousSelection();if(g.$isRangeSelection(b)){var {focus:c}=b;b=c.getNode();c=c.offset;if(g.$isRootOrShadowRoot(b))c=b.getChildAtIndex(c),null==c?b.append(a):c.insertBefore(a),a.selectNext();else{let e,d;g.$isTextNode(b)?(e=b.getParentOrThrow(),d=b.getIndexWithinParent(),0<c&&(d+=1,b.splitText(c))):(e=b,d=c);[,b]=g.$splitNode(e,d);b.insertBefore(a);b.selectStart()}}else null!=b?(b=b.getNodes(),b[b.length-1].getTopLevelElementOrThrow().insertAfter(a)):
g.$getRoot().append(a),b=g.$createParagraphNode(),a.insertAfter(b),b.select();return a.getLatest()};exports.$isEditorIsNestedEditor=function(a){return null!==a._parentEditor};exports.$restoreEditorState=function(a,b){let c=new Map,e=a._pendingEditorState;for(let [d,f]of b._nodeMap)c.set(d,g.$cloneWithProperties(f));e&&(e._nodeMap=c);a._dirtyType=2;a=b._selection;g.$setSelection(null===a?null:a.clone())};exports.$wrapNodeInElement=function(a,b){b=b();a.replace(b);b.append(a);return b};
L=E&&/Android/.test(navigator.userAgent),M=E&&/^(?=.*Chrome).*/i.test(navigator.userAgent),N=E&&L&&M;function O(...a){let b=[];for(let c of a)if(c&&"string"===typeof c)for(let [d]of c.matchAll(/\S+/g))b.push(d);return b}function P(...a){return()=>{for(let b=a.length-1;0<=b;b--)a[b]();a.length=0}}let Q={attributes:!0,characterData:!0,childList:!0,subtree:!0};
function R(a,b,c){function d(){null===h&&C(182);null===l&&C(183);let {left:p,top:A}=h.getBoundingClientRect();var q=l;let r=x.createRectsFromDOMRange(a,b);t.isConnected||q.append(t);q=!1;for(let y=0;y<r.length;y++){var w=r[y];let u=k[y]||document.createElement("div"),z=u.style;"absolute"!==z.position&&(z.position="absolute",q=!0);var m=`${w.left-p}px`;z.left!==m&&(z.left=m,q=!0);m=`${w.top-A}px`;z.top!==m&&(u.style.top=m,q=!0);m=`${w.width}px`;z.width!==m&&(u.style.width=m,q=!0);w=`${w.height}px`;
z.height!==w&&(u.style.height=w,q=!0);u.parentNode!==t&&(t.append(u),q=!0);k[y]=u}for(;k.length>r.length;)k.pop();q&&c(k)}function f(){h=l=null;null!==n&&n.disconnect();n=null;t.remove();for(let p of k)p.remove();k=[]}function e(){let p=a.getRootElement();if(null===p)return f();let A=p.parentElement;if(!(A instanceof HTMLElement))return f();f();h=p;l=A;n=new MutationObserver(q=>{let r=a.getRootElement(),w=r&&r.parentElement;if(r!==h||w!==l)return e();for(let m of q)if(!t.contains(m.target))return d()});
n.observe(A,Q);d()}let h=null,l=null,n=null,k=[],t=document.createElement("div"),B=a.registerRootListener(e);return()=>{B();f()}}let S=E&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!M;function T(a,b){for(let c of b)if(a.type.startsWith(c))return!0;return!1}let U={done:!0,value:void 0};
function V(a,b){a=(a||g.$getRoot()).getLatest();let c=W(a),d=a,f=c,e=!0,h={next(){if(null===d)return U;if(e)return e=!1,{done:!1,value:{depth:f,node:d}};if(d===b)return U;if(g.$isElementNode(d)&&0<d.getChildrenSize())d=d.getFirstChild(),f++;else{let l;[d,l]=X(d)||[null,0];f+=l;null==b&&f<=c&&(d=null)}return null===d?U:{done:!1,value:{depth:f,node:d}}},[Symbol.iterator](){return h}};return h}
function X(a){let b=null,c=0;for(;null===b&&null!==a;)b=a.getNextSibling(),null===b?(a=a.getParent(),c--):a=b;return null===a?null:[a,c]}function W(a){let b=0;for(;null!==(a=a.getParent());)b++;return b}let Y=(a,b)=>{for(;a!==g.$getRoot()&&null!=a;){if(b(a))return a;a=a.getParent()}return null};exports.$splitNode=g.$splitNode;exports.isBlockDomNode=g.isBlockDomNode;exports.isHTMLAnchorElement=g.isHTMLAnchorElement;exports.isHTMLElement=g.isHTMLElement;exports.isInlineDomNode=g.isInlineDomNode;
exports.$dfs=function(a,b){return Array.from(V(a,b))};exports.$dfsIterator=V;exports.$filter=function(a,b){let c=[];for(let d=0;d<a.length;d++){let f=b(a[d]);null!==f&&c.push(f)}return c};exports.$findMatchingParent=Y;exports.$getDepth=W;exports.$getNearestBlockElementAncestorOrThrow=function(a){let b=Y(a,c=>g.$isElementNode(c)&&!c.isInline());g.$isElementNode(b)||C(4,a.__key);return b};exports.$getNearestNodeOfType=function(a,b){for(;null!=a;){if(a instanceof b)return a;a=a.getParent()}return null};
exports.$getNextRightPreorderNode=function(a){if(g.$isElementNode(a)&&0<a.getChildrenSize())a=a.getLastChild();else{let b=null;for(;null===b&&null!==a;)b=a.getPreviousSibling(),a=null===b?a.getParent():b}return a};exports.$getNextSiblingOrParentSibling=X;exports.$insertFirst=function(a,b){let c=a.getFirstChild();null!==c?c.insertBefore(b):a.append(b)};
exports.$insertNodeToNearestRoot=function(a){var b=g.$getSelection()||g.$getPreviousSelection();if(g.$isRangeSelection(b)){var {focus:c}=b;b=c.getNode();c=c.offset;if(g.$isRootOrShadowRoot(b))c=b.getChildAtIndex(c),null==c?b.append(a):c.insertBefore(a),a.selectNext();else{let d,f;g.$isTextNode(b)?(d=b.getParentOrThrow(),f=b.getIndexWithinParent(),0<c&&(f+=1,b.splitText(c))):(d=b,f=c);[,b]=g.$splitNode(d,f);b.insertBefore(a);b.selectStart()}}else null!=b?(b=b.getNodes(),b[b.length-1].getTopLevelElementOrThrow().insertAfter(a)):
g.$getRoot().append(a),b=g.$createParagraphNode(),a.insertAfter(b),b.select();return a.getLatest()};exports.$isEditorIsNestedEditor=function(a){return null!==a._parentEditor};exports.$restoreEditorState=function(a,b){let c=new Map,d=a._pendingEditorState;for(let [f,e]of b._nodeMap)c.set(f,g.$cloneWithProperties(e));d&&(d._nodeMap=c);a._dirtyType=2;a=b._selection;g.$setSelection(null===a?null:a.clone())};exports.$wrapNodeInElement=function(a,b){b=b();a.replace(b);b.append(a);return b};
exports.CAN_USE_BEFORE_INPUT=I;exports.CAN_USE_DOM=E;exports.IS_ANDROID=L;exports.IS_ANDROID_CHROME=N;exports.IS_APPLE=G;exports.IS_APPLE_WEBKIT=S;exports.IS_CHROME=M;exports.IS_FIREFOX=H;exports.IS_IOS=K;exports.IS_SAFARI=J;exports.addClassNamesToElement=function(a,...b){b=O(...b);0<b.length&&a.classList.add(...b)};exports.calculateZoomLevel=function(a){if(H)return 1;let b=1;for(;a;)b*=Number(window.getComputedStyle(a).getPropertyValue("zoom")),a=a.parentElement;return b};exports.isMimeType=T;
exports.markSelection=function(a,b){function c(m){m.read(()=>{var h=g.$getSelection();if(g.$isRangeSelection(h)){var {anchor:t,focus:B}=h;h=t.getNode();var p=h.getKey(),A=t.offset,q=B.getNode(),r=q.getKey(),w=B.offset,l=a.getElementByKey(p),y=a.getElementByKey(r);p=null===e||null===l||A!==d||p!==e.getKey()||h!==e&&(!(e instanceof g.TextNode)||h.updateDOM(e,l,a._config));r=null===f||null===y||w!==k||r!==f.getKey()||q!==f&&(!(f instanceof g.TextNode)||q.updateDOM(f,y,a._config));if(p||r){l=a.getElementByKey(t.getNode().getKey());
var u=a.getElementByKey(B.getNode().getKey());null!==l&&null!==u&&"SPAN"===l.tagName&&"SPAN"===u.tagName&&(r=document.createRange(),B.isBefore(t)?(p=u,y=B.offset,u=l,l=t.offset):(p=l,y=t.offset,l=B.offset),p=p.firstChild,null===p&&C(181),u=u.firstChild,null===u&&C(181),r.setStart(p,y),r.setEnd(u,l),n(),n=R(a,r,z=>{for(let V of z){let v=V.style;"Highlight"!==v.background&&(v.background="Highlight");"HighlightText"!==v.color&&(v.color="HighlightText");"-1"!==v.zIndex&&(v.zIndex="-1");"none"!==v.pointerEvents&&
(v.pointerEvents="none");"-1.5px"!==v.marginTop&&(v.marginTop="-1.5px");"4px"!==v.paddingTop&&(v.paddingTop="4px");"0px"!==v.paddingBottom&&(v.paddingBottom="0px")}void 0!==b&&b(z)}))}e=h;d=A;f=q;k=w}else k=f=d=e=null,n(),n=()=>{}})}let e=null,d=null,f=null,k=null,n=()=>{};c(a.getEditorState());return P(a.registerUpdateListener(({editorState:m})=>c(m)),n,()=>{n()})};
exports.mediaFileReader=function(a,b){let c=a[Symbol.iterator]();return new Promise((e,d)=>{let f=[],k=()=>{const {done:n,value:m}=c.next();if(n)return e(f);const h=new FileReader;h.addEventListener("error",d);h.addEventListener("load",()=>{const t=h.result;"string"===typeof t&&f.push({file:m,result:t});k()});T(m,b)?h.readAsDataURL(m):k()};k()})};exports.mergeRegister=P;exports.objectKlassEquals=function(a,b){return null!==a?Object.getPrototypeOf(a).constructor.name===b.name:!1};
exports.markSelection=function(a,b){function c(n){n.read(()=>{var k=g.$getSelection();if(g.$isRangeSelection(k)){var {anchor:t,focus:B}=k;k=t.getNode();var p=k.getKey(),A=t.offset,q=B.getNode(),r=q.getKey(),w=B.offset,m=a.getElementByKey(p),y=a.getElementByKey(r);p=null===d||null===m||A!==f||p!==d.getKey()||k!==d&&(!(d instanceof g.TextNode)||k.updateDOM(d,m,a._config));r=null===e||null===y||w!==h||r!==e.getKey()||q!==e&&(!(e instanceof g.TextNode)||q.updateDOM(e,y,a._config));if(p||r){m=a.getElementByKey(t.getNode().getKey());
var u=a.getElementByKey(B.getNode().getKey());null!==m&&null!==u&&"SPAN"===m.tagName&&"SPAN"===u.tagName&&(r=document.createRange(),B.isBefore(t)?(p=u,y=B.offset,u=m,m=t.offset):(p=m,y=t.offset,m=B.offset),p=p.firstChild,null===p&&C(181),u=u.firstChild,null===u&&C(181),r.setStart(p,y),r.setEnd(u,m),l(),l=R(a,r,z=>{for(let Z of z){let v=Z.style;"Highlight"!==v.background&&(v.background="Highlight");"HighlightText"!==v.color&&(v.color="HighlightText");"-1"!==v.zIndex&&(v.zIndex="-1");"none"!==v.pointerEvents&&
(v.pointerEvents="none");"-1.5px"!==v.marginTop&&(v.marginTop="-1.5px");"4px"!==v.paddingTop&&(v.paddingTop="4px");"0px"!==v.paddingBottom&&(v.paddingBottom="0px")}void 0!==b&&b(z)}))}d=k;f=A;e=q;h=w}else h=e=f=d=null,l(),l=()=>{}})}let d=null,f=null,e=null,h=null,l=()=>{};c(a.getEditorState());return P(a.registerUpdateListener(({editorState:n})=>c(n)),l,()=>{l()})};
exports.mediaFileReader=function(a,b){let c=a[Symbol.iterator]();return new Promise((d,f)=>{let e=[],h=()=>{const {done:l,value:n}=c.next();if(l)return d(e);const k=new FileReader;k.addEventListener("error",f);k.addEventListener("load",()=>{const t=k.result;"string"===typeof t&&e.push({file:n,result:t});h()});T(n,b)?k.readAsDataURL(n):h()};h()})};exports.mergeRegister=P;exports.objectKlassEquals=function(a,b){return null!==a?Object.getPrototypeOf(a).constructor.name===b.name:!1};
exports.positionNodeOnRange=R;
exports.registerNestedElementResolver=function(a,b,c,e){return a.registerNodeTransform(b,d=>{a:{var f=d.getChildren();for(var k=0;k<f.length;k++)if(f[k]instanceof b){f=null;break a}for(f=d;null!==f;)if(k=f,f=f.getParent(),f instanceof b){f={child:k,parent:f};break a}f=null}if(null!==f){const {child:n,parent:m}=f;if(n.is(d)){e(m,d);d=n.getNextSiblings();f=d.length;m.insertAfter(n);if(0!==f){k=c(m);n.insertAfter(k);for(let h=0;h<f;h++)k.append(d[h])}m.canBeEmpty()||0!==m.getChildrenSize()||m.remove()}}})};
exports.registerNestedElementResolver=function(a,b,c,d){return a.registerNodeTransform(b,f=>{a:{var e=f.getChildren();for(var h=0;h<e.length;h++)if(e[h]instanceof b){e=null;break a}for(e=f;null!==e;)if(h=e,e=e.getParent(),e instanceof b){e={child:h,parent:e};break a}e=null}if(null!==e){const {child:l,parent:n}=e;if(l.is(f)){d(n,f);f=l.getNextSiblings();e=f.length;n.insertAfter(l);if(0!==e){h=c(n);l.insertAfter(h);for(let k=0;k<e;k++)h.append(f[k])}n.canBeEmpty()||0!==n.getChildrenSize()||n.remove()}}})};
exports.removeClassNamesFromElement=function(a,...b){b=O(...b);0<b.length&&a.classList.remove(...b)}

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

"license": "MIT",
"version": "0.17.2-nightly.20240926.0",
"version": "0.18.0",
"main": "LexicalUtils.js",
"types": "index.d.ts",
"dependencies": {
"@lexical/list": "0.17.2-nightly.20240926.0",
"@lexical/selection": "0.17.2-nightly.20240926.0",
"@lexical/table": "0.17.2-nightly.20240926.0",
"lexical": "0.17.2-nightly.20240926.0"
"@lexical/list": "0.18.0",
"@lexical/selection": "0.18.0",
"@lexical/table": "0.18.0",
"lexical": "0.18.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

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