Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@lexical/utils

Package Overview
Dependencies
Maintainers
5
Versions
190
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.14.5 to 0.15.0

23

index.d.ts

@@ -12,5 +12,13 @@ /**

export { default as positionNodeOnRange } from './positionNodeOnRange';
export { $splitNode, isHTMLAnchorElement, isHTMLElement } from 'lexical';
export { CAN_USE_DOM } from 'shared/canUseDOM';
export { CAN_USE_BEFORE_INPUT, IS_ANDROID, IS_ANDROID_CHROME, IS_APPLE, IS_APPLE_WEBKIT, IS_CHROME, IS_FIREFOX, IS_IOS, IS_SAFARI, } from 'shared/environment';
export { $splitNode, isBlockDomNode, isHTMLAnchorElement, isHTMLElement, isInlineDomNode, } from 'lexical';
export declare const CAN_USE_BEFORE_INPUT: boolean;
export declare const CAN_USE_DOM: boolean;
export declare const IS_ANDROID: boolean;
export declare const IS_ANDROID_CHROME: boolean;
export declare const IS_APPLE: boolean;
export declare const IS_APPLE_WEBKIT: boolean;
export declare const IS_CHROME: boolean;
export declare const IS_FIREFOX: boolean;
export declare const IS_IOS: boolean;
export declare const IS_SAFARI: boolean;
export type DFSNode = Readonly<{

@@ -74,2 +82,11 @@ depth: number;

/**
* Performs a right-to-left preorder tree traversal.
* From the starting node it goes to the rightmost child, than backtracks to paret and finds new rightmost path.
* It will return the next node in traversal sequence after the startingNode.
* The traversal is similar to $dfs functions above, but the nodes are visited right-to-left, not left-to-right.
* @param startingNode - The node to start the search.
* @returns The next node in pre-order right to left traversal sequence or `null`, if the node does not exist
*/
export declare function $getNextRightPreorderNode(startingNode: LexicalNode): LexicalNode | null;
/**
* Takes a node and traverses up its ancestors (toward the root node)

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

@@ -6,3 +6,5 @@ /**

* LICENSE file in the root directory of this source tree.
*
*/
'use strict';

@@ -21,3 +23,3 @@

const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined';
const CAN_USE_DOM$1 = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined';

@@ -31,17 +33,18 @@ /**

*/
const documentMode = CAN_USE_DOM && 'documentMode' in document ? document.documentMode : null;
const IS_APPLE = CAN_USE_DOM && /Mac|iPod|iPhone|iPad/.test(navigator.platform);
const IS_FIREFOX = CAN_USE_DOM && /^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);
const CAN_USE_BEFORE_INPUT = CAN_USE_DOM && 'InputEvent' in window && !documentMode ? 'getTargetRanges' in new window.InputEvent('input') : false;
const IS_SAFARI = CAN_USE_DOM && /Version\/[\d.]+.*Safari/.test(navigator.userAgent);
const IS_IOS = CAN_USE_DOM && /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
const IS_ANDROID = CAN_USE_DOM && /Android/.test(navigator.userAgent);
const documentMode = CAN_USE_DOM$1 && 'documentMode' in document ? document.documentMode : null;
const IS_APPLE$1 = CAN_USE_DOM$1 && /Mac|iPod|iPhone|iPad/.test(navigator.platform);
const IS_FIREFOX$1 = CAN_USE_DOM$1 && /^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);
const CAN_USE_BEFORE_INPUT$1 = CAN_USE_DOM$1 && 'InputEvent' in window && !documentMode ? 'getTargetRanges' in new window.InputEvent('input') : false;
const IS_SAFARI$1 = CAN_USE_DOM$1 && /Version\/[\d.]+.*Safari/.test(navigator.userAgent);
const IS_IOS$1 = CAN_USE_DOM$1 && /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
const IS_ANDROID$1 = CAN_USE_DOM$1 && /Android/.test(navigator.userAgent);
// Keep these in case we need to use them in the future.
// export const IS_WINDOWS: boolean = CAN_USE_DOM && /Win/.test(navigator.platform);
const IS_CHROME = CAN_USE_DOM && /^(?=.*Chrome).*/i.test(navigator.userAgent);
const IS_CHROME$1 = CAN_USE_DOM$1 && /^(?=.*Chrome).*/i.test(navigator.userAgent);
// export const canUseTextInputEvent: boolean = CAN_USE_DOM && 'TextEvent' in window && !documentMode;
const IS_ANDROID_CHROME = CAN_USE_DOM && IS_ANDROID && IS_CHROME;
const IS_APPLE_WEBKIT = CAN_USE_DOM && /AppleWebKit\/[\d.]+/.test(navigator.userAgent) && !IS_CHROME;
const IS_ANDROID_CHROME$1 = CAN_USE_DOM$1 && IS_ANDROID$1 && IS_CHROME$1;
const IS_APPLE_WEBKIT$1 = CAN_USE_DOM$1 && /AppleWebKit\/[\d.]+/.test(navigator.userAgent) && !IS_CHROME$1;

@@ -123,2 +126,3 @@ /**

*/
const mutationObserverConfig = {

@@ -251,2 +255,3 @@ attributes: true,

*/
function markSelection(editor, onReposition) {

@@ -369,2 +374,14 @@ let previousAnchorNode = null;

*/
// Hotfix to export these with inlined types #5918
const CAN_USE_BEFORE_INPUT = CAN_USE_BEFORE_INPUT$1;
const CAN_USE_DOM = CAN_USE_DOM$1;
const IS_ANDROID = IS_ANDROID$1;
const IS_ANDROID_CHROME = IS_ANDROID_CHROME$1;
const IS_APPLE = IS_APPLE$1;
const IS_APPLE_WEBKIT = IS_APPLE_WEBKIT$1;
const IS_CHROME = IS_CHROME$1;
const IS_FIREFOX = IS_FIREFOX$1;
const IS_IOS = IS_IOS$1;
const IS_SAFARI = IS_SAFARI$1;
/**

@@ -475,3 +492,3 @@ * Takes an HTML element and adds the classNames passed within an array,

const start = (startingNode || lexical.$getRoot()).getLatest();
const end = endingNode || (lexical.$isElementNode(start) ? start.getLastDescendant() : start);
const end = endingNode || (lexical.$isElementNode(start) ? start.getLastDescendant() || start : start);
let node = start;

@@ -519,2 +536,28 @@ let depth = $getDepth(node);

/**
* Performs a right-to-left preorder tree traversal.
* From the starting node it goes to the rightmost child, than backtracks to paret and finds new rightmost path.
* It will return the next node in traversal sequence after the startingNode.
* The traversal is similar to $dfs functions above, but the nodes are visited right-to-left, not left-to-right.
* @param startingNode - The node to start the search.
* @returns The next node in pre-order right to left traversal sequence or `null`, if the node does not exist
*/
function $getNextRightPreorderNode(startingNode) {
let node = startingNode;
if (lexical.$isElementNode(node) && node.getChildrenSize() > 0) {
node = node.getLastChild();
} else {
let sibling = null;
while (sibling === null && node !== null) {
sibling = node.getPreviousSibling();
if (sibling === null) {
node = node.getParent();
} else {
node = sibling;
}
}
}
return node;
}
/**
* Takes a node and traverses up its ancestors (toward the root node)

@@ -607,3 +650,3 @@ * in order to find a specific type of node.

};
const elementNodeTransform = node => {
const $elementNodeTransform = node => {
const match = $findMatch(node);

@@ -636,3 +679,3 @@ if (match !== null) {

};
return editor.registerNodeTransform(targetNode, elementNodeTransform);
return editor.registerNodeTransform(targetNode, $elementNodeTransform);
}

@@ -798,4 +841,6 @@

exports.$splitNode = lexical.$splitNode;
exports.isBlockDomNode = lexical.isBlockDomNode;
exports.isHTMLAnchorElement = lexical.isHTMLAnchorElement;
exports.isHTMLElement = lexical.isHTMLElement;
exports.isInlineDomNode = lexical.isInlineDomNode;
exports.$dfs = $dfs;

@@ -806,2 +851,3 @@ exports.$filter = $filter;

exports.$getNearestNodeOfType = $getNearestNodeOfType;
exports.$getNextRightPreorderNode = $getNextRightPreorderNode;
exports.$insertFirst = $insertFirst;

@@ -808,0 +854,0 @@ exports.$insertNodeToNearestRoot = $insertNodeToNearestRoot;

@@ -6,5 +6,7 @@ /**

* LICENSE file in the root directory of this source tree.
*
*/
'use strict'
const LexicalUtils = process.env.NODE_ENV === 'development' ? require('./LexicalUtils.dev.js') : require('./LexicalUtils.prod.js');
module.exports = LexicalUtils;

34

LexicalUtils.prod.js

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

* LICENSE file in the root directory of this source tree.
*
*/
'use strict';var h=require("@lexical/selection"),x=require("lexical");function C(a){let b=new URLSearchParams;b.append("code",a);for(let c=1;c<arguments.length;c++)b.append("v",arguments[c]);throw Error(`Minified Lexical error #${a}; visit https://lexical.dev/docs/error?${b} for the full message or `+"use the non-minified dev environment for full errors and additional helpful warnings.");}
let D="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement,E=D&&"documentMode"in document?document.documentMode:null,F=D&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),G=D&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),H=D&&"InputEvent"in window&&!E?"getTargetRanges"in new window.InputEvent("input"):!1,I=D&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),J=D&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,
K=D&&/Android/.test(navigator.userAgent),L=D&&/^(?=.*Chrome).*/i.test(navigator.userAgent),M=D&&K&&L,N=D&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!L;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()=>{a.forEach(b=>b())}}let Q={attributes:!0,characterData:!0,childList:!0,subtree:!0};
function R(a,b,c){function e(){if(null===g)throw Error("Unexpected null rootDOMNode");if(null===n)throw Error("Unexpected null parentDOMNode");let {left:p,top:A}=g.getBoundingClientRect();var q=n;let r=h.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 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);k[y]=u}for(;k.length>r.length;)k.pop();q&&c(k)}function d(){g=n=null;null!==m&&m.disconnect();m=null;t.remove();for(let p of k)p.remove();k=[]}function f(){let p=a.getRootElement();if(null===p)return d();let A=p.parentElement;if(!(A instanceof HTMLElement))return d();d();g=p;n=A;m=new MutationObserver(q=>{let r=a.getRootElement(),w=r&&r.parentElement;
if(r!==g||w!==n)return f();for(let l of q)if(!t.contains(l.target))return e()});m.observe(A,Q);e()}let g=null,n=null,m=null,k=[],t=document.createElement("div"),B=a.registerRootListener(f);return()=>{B();d()}}function S(a,b){for(let c of b)if(a.type.startsWith(c))return!0;return!1}let T=(a,b)=>{for(;a!==x.$getRoot()&&null!=a;){if(b(a))return a;a=a.getParent()}return null};exports.$splitNode=x.$splitNode;exports.isHTMLAnchorElement=x.isHTMLAnchorElement;exports.isHTMLElement=x.isHTMLElement;
exports.$dfs=function(a,b){let c=[];a=(a||x.$getRoot()).getLatest();b=b||(x.$isElementNode(a)?a.getLastDescendant():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}),x.$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=T;exports.$getNearestBlockElementAncestorOrThrow=function(a){let b=T(a,c=>x.$isElementNode(c)&&!c.isInline());x.$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.$insertFirst=function(a,b){let c=a.getFirstChild();null!==c?c.insertBefore(b):a.append(b)};
'use strict';var g=require("@lexical/selection"),x=require("lexical"),C;function D(a){let b=new URLSearchParams;b.append("code",a);for(let c=1;c<arguments.length;c++)b.append("v",arguments[c]);throw Error(`Minified Lexical error #${a}; visit https://lexical.dev/docs/error?${b} for the full message or `+"use the non-minified dev environment for full errors and additional helpful warnings.");}C=D&&D.__esModule&&Object.prototype.hasOwnProperty.call(D,"default")?D["default"]:D;
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()=>{a.forEach(b=>b())}}let Q={attributes:!0,characterData:!0,childList:!0,subtree:!0};
function R(a,b,c){function e(){null===h&&C(182);null===n&&C(183);let {left:p,top:A}=h.getBoundingClientRect();var q=n;let r=g.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 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);k[y]=u}for(;k.length>r.length;)k.pop();q&&c(k)}function d(){h=n=null;null!==m&&m.disconnect();m=null;t.remove();for(let p of k)p.remove();k=[]}function f(){let p=a.getRootElement();if(null===p)return d();let A=p.parentElement;if(!(A instanceof HTMLElement))return d();d();h=p;n=A;m=new MutationObserver(q=>{let r=a.getRootElement(),w=r&&r.parentElement;if(r!==h||w!==n)return f();for(let l of q)if(!t.contains(l.target))return e()});
m.observe(A,Q);e()}let h=null,n=null,m=null,k=[],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!==x.$getRoot()&&null!=a;){if(b(a))return a;a=a.getParent()}return null};exports.$splitNode=x.$splitNode;exports.isBlockDomNode=x.isBlockDomNode;exports.isHTMLAnchorElement=x.isHTMLAnchorElement;exports.isHTMLElement=x.isHTMLElement;
exports.isInlineDomNode=x.isInlineDomNode;exports.$dfs=function(a,b){let c=[];a=(a||x.$getRoot()).getLatest();b=b||(x.$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}),x.$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=>x.$isElementNode(c)&&!c.isInline());x.$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(x.$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=x.$getSelection()||x.$getPreviousSelection();if(x.$isRangeSelection(b)){var {focus:c}=b;b=c.getNode();c=c.offset;if(x.$isRootOrShadowRoot(b))c=b.getChildAtIndex(c),null==c?b.append(a):c.insertBefore(a),a.selectNext();else{let e,d;x.$isTextNode(b)?(e=b.getParentOrThrow(),d=b.getIndexWithinParent(),0<c&&(d+=1,b.splitText(c))):(e=b,d=c);[,b]=x.$splitNode(e,d);b.insertBefore(a);b.selectStart()}}else null!=b?(b=b.getNodes(),b[b.length-1].getTopLevelElementOrThrow().insertAfter(a)):
x.$getRoot().append(a),b=x.$createParagraphNode(),a.insertAfter(b),b.select();return a.getLatest()};exports.$restoreEditorState=function(a,b){let c=new Map,e=a._pendingEditorState;for(let [d,f]of b._nodeMap){let g=h.$cloneWithProperties(f);if(x.$isTextNode(g)){if(!x.$isTextNode(f))throw Error("Expected node be a TextNode");g.__text=f.__text}c.set(d,g)}e&&(e._nodeMap=c);a._dirtyType=2;a=b._selection;x.$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=H;exports.CAN_USE_DOM=D;exports.IS_ANDROID=K;exports.IS_ANDROID_CHROME=M;exports.IS_APPLE=F;exports.IS_APPLE_WEBKIT=N;exports.IS_CHROME=L;exports.IS_FIREFOX=G;exports.IS_IOS=J;exports.IS_SAFARI=I;exports.addClassNamesToElement=function(a,...b){b=O(...b);0<b.length&&a.classList.add(...b)};
exports.calculateZoomLevel=function(a){if(G)return 1;let b=1;for(;a;)b*=Number(window.getComputedStyle(a).getPropertyValue("zoom")),a=a.parentElement;return b};exports.isMimeType=S;
exports.markSelection=function(a,b){function c(m){m.read(()=>{var k=x.$getSelection();if(x.$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,l=a.getElementByKey(p),y=a.getElementByKey(r);p=null===e||null===l||A!==d||p!==e.getKey()||k!==e&&(!(e instanceof x.TextNode)||k.updateDOM(e,l,a._config));r=null===f||null===y||w!==g||r!==f.getKey()||q!==f&&(!(f instanceof x.TextNode)||q.updateDOM(f,y,a._config));if(p||r){l=a.getElementByKey(t.getNode().getKey());
var u=a.getElementByKey(B.getNode().getKey());if(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;if(null===p)throw Error("Expected text node to be first child of span");u=u.firstChild;if(null===u)throw Error("Expected text node to be first child of span");r.setStart(p,y);r.setEnd(u,l);n();n=R(a,r,z=>{for(let U of z){let v=U.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=k;d=A;f=q;g=w}else g=f=d=e=null,n(),n=()=>{}})}let e=null,d=null,f=null,g=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=[],g=()=>{const {done:n,value:m}=c.next();if(n)return e(f);const k=new FileReader;k.addEventListener("error",d);k.addEventListener("load",()=>{const t=k.result;"string"===typeof t&&f.push({file:m,result:t});g()});S(m,b)?k.readAsDataURL(m):g()};g()})};exports.mergeRegister=P;exports.objectKlassEquals=function(a,b){return null!==a?Object.getPrototypeOf(a).constructor.name===b.name:!1};
x.$getRoot().append(a),b=x.$createParagraphNode(),a.insertAfter(b),b.select();return a.getLatest()};exports.$restoreEditorState=function(a,b){let c=new Map,e=a._pendingEditorState;for(let [d,f]of b._nodeMap){let h=g.$cloneWithProperties(f);x.$isTextNode(h)&&(x.$isTextNode(f)||C(180),h.__text=f.__text);c.set(d,h)}e&&(e._nodeMap=c);a._dirtyType=2;a=b._selection;x.$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 k=x.$getSelection();if(x.$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,l=a.getElementByKey(p),y=a.getElementByKey(r);p=null===e||null===l||A!==d||p!==e.getKey()||k!==e&&(!(e instanceof x.TextNode)||k.updateDOM(e,l,a._config));r=null===f||null===y||w!==h||r!==f.getKey()||q!==f&&(!(f instanceof x.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=k;d=A;f=q;h=w}else h=f=d=e=null,n(),n=()=>{}})}let e=null,d=null,f=null,h=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=[],h=()=>{const {done:n,value:m}=c.next();if(n)return e(f);const k=new FileReader;k.addEventListener("error",d);k.addEventListener("load",()=>{const t=k.result;"string"===typeof t&&f.push({file:m,result:t});h()});T(m,b)?k.readAsDataURL(m):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 g=0;g<f.length;g++)if(f[g]instanceof b){f=null;break a}for(f=d;null!==f;)if(g=f,f=f.getParent(),f instanceof b){f={child:g,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){g=c(m);n.insertAfter(g);for(let k=0;k<f;k++)g.append(d[k])}m.canBeEmpty()||0!==m.getChildrenSize()||m.remove()}}})};
exports.registerNestedElementResolver=function(a,b,c,e){return a.registerNodeTransform(b,d=>{a:{var f=d.getChildren();for(var h=0;h<f.length;h++)if(f[h]instanceof b){f=null;break a}for(f=d;null!==f;)if(h=f,f=f.getParent(),f instanceof b){f={child:h,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){h=c(m);n.insertAfter(h);for(let k=0;k<f;k++)h.append(d[k])}m.canBeEmpty()||0!==m.getChildrenSize()||m.remove()}}})};
exports.removeClassNamesFromElement=function(a,...b){b=O(...b);0<b.length&&a.classList.remove(...b)}

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

"license": "MIT",
"version": "0.14.5",
"version": "0.15.0",
"main": "LexicalUtils.js",
"types": "index.d.ts",
"dependencies": {
"@lexical/list": "0.14.5",
"@lexical/selection": "0.14.5",
"@lexical/table": "0.14.5",
"lexical": "0.14.5"
"@lexical/list": "0.15.0",
"@lexical/selection": "0.15.0",
"@lexical/table": "0.15.0",
"lexical": "0.15.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