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

@lexical/utils

Package Overview
Dependencies
Maintainers
3
Versions
192
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.1.19 to 0.1.20

5

LexicalUtils.d.ts

@@ -8,3 +8,3 @@ /**

*/
import type {LexicalNode} from 'lexical';
import type {LexicalNode, ElementNode} from 'lexical';
export type DFSNode = $ReadOnly<{

@@ -41,1 +41,4 @@ depth: number;

declare function mergeRegister(...func: Array<Func>): () => void;
declare function $getNearestBlockElementAncestorOrThrow(
startNode: LexicalNode,
): ElementNode;

@@ -98,2 +98,13 @@ /**

}
function $getNearestBlockElementAncestorOrThrow(startNode) {
const blockNode = $findMatchingParent(startNode, node => lexical.$isElementNode(node) && !node.isInline());
if (!lexical.$isElementNode(blockNode)) {
{
throw Error(`Expected node ${startNode.__key} to have closest block element node.`);
}
}
return blockNode;
}
function $findMatchingParent(startingNode, findFn) {

@@ -120,2 +131,3 @@ let curr = startingNode;

exports.$findMatchingParent = $findMatchingParent;
exports.$getNearestBlockElementAncestorOrThrow = $getNearestBlockElementAncestorOrThrow;
exports.$getNearestNodeOfType = $getNearestNodeOfType;

@@ -122,0 +134,0 @@ exports.addClassNamesToElement = addClassNamesToElement;

6

LexicalUtils.prod.js

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

*/
var f=require("lexical");exports.$dfs=function(a,b){const c=[];a=(a||f.$getRoot()).getLatest();b=b||(f.$isElementNode(a)?a.getLastDescendant():a);for(var d=a,e=0;null!==(d=d.getParent());)e++;for(d=e;null!==a&&!a.is(b);)if(c.push({depth:d,node:a}),f.$isElementNode(a)&&0<a.getChildrenSize())a=a.getFirstChild(),d++;else for(e=null;null===e&&null!==a;)e=a.getNextSibling(),null===e?(a=a.getParent(),d--):a=e;null!==a&&a.is(b)&&c.push({depth:d,node:a});return c};
exports.$findMatchingParent=function(a,b){for(;a!==f.$getRoot()&&null!=a;){if(b(a))return a;a=a.getParent()}return null};exports.$getNearestNodeOfType=function(a,b){for(;null!=a&&!(a instanceof b);)a=a.getParent();return a};exports.addClassNamesToElement=function(a,...b){b.forEach(c=>{null!=c&&"string"===typeof c&&a.classList.add(...c.split(" "))})};exports.mergeRegister=function(...a){return()=>{a.forEach(b=>b())}};exports.removeClassNamesFromElement=function(a,...b){b.forEach(c=>{a.classList.remove(...c.split(" "))})};
var f=require("lexical");function g(a,b){for(;a!==f.$getRoot()&&null!=a;){if(b(a))return a;a=a.getParent()}return null}
exports.$dfs=function(a,b){const c=[];a=(a||f.$getRoot()).getLatest();b=b||(f.$isElementNode(a)?a.getLastDescendant():a);for(var d=a,e=0;null!==(d=d.getParent());)e++;for(d=e;null!==a&&!a.is(b);)if(c.push({depth:d,node:a}),f.$isElementNode(a)&&0<a.getChildrenSize())a=a.getFirstChild(),d++;else for(e=null;null===e&&null!==a;)e=a.getNextSibling(),null===e?(a=a.getParent(),d--):a=e;null!==a&&a.is(b)&&c.push({depth:d,node:a});return c};exports.$findMatchingParent=g;
exports.$getNearestBlockElementAncestorOrThrow=function(a){const b=g(a,c=>f.$isElementNode(c)&&!c.isInline());if(!f.$isElementNode(b))throw Error(`Expected node ${a.__key} to have closest block element node.`);return b};exports.$getNearestNodeOfType=function(a,b){for(;null!=a&&!(a instanceof b);)a=a.getParent();return a};exports.addClassNamesToElement=function(a,...b){b.forEach(c=>{null!=c&&"string"===typeof c&&a.classList.add(...c.split(" "))})};
exports.mergeRegister=function(...a){return()=>{a.forEach(b=>b())}};exports.removeClassNamesFromElement=function(a,...b){b.forEach(c=>{a.classList.remove(...c.split(" "))})};

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

"license": "MIT",
"version": "0.1.19",
"version": "0.1.20",
"main": "LexicalUtils.js",
"peerDependencies": {
"lexical": "0.1.19"
"lexical": "0.1.20"
},
"dependencies": {
"@lexical/list": "0.1.19",
"@lexical/table": "0.1.19"
"@lexical/list": "0.1.20",
"@lexical/table": "0.1.20"
},

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

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