@lexical/utils
Advanced tools
Comparing version 0.1.16 to 0.1.17
@@ -111,21 +111,13 @@ /** | ||
} | ||
function $areSiblingsNullOrSpace(node) { | ||
return $isPreviousSiblingNullOrSpace(node) && $isNextSiblingNullOrSpace(node); | ||
function mergeRegister(...func) { | ||
return () => { | ||
func.forEach(f => f()); | ||
}; | ||
} | ||
function $isPreviousSiblingNullOrSpace(node) { | ||
const previousSibling = node.getPreviousSibling(); | ||
return previousSibling === null || lexical.$isLineBreakNode(previousSibling) || lexical.$isTextNode(previousSibling) && previousSibling.isSimpleText() && previousSibling.getTextContent().endsWith(' '); | ||
} | ||
function $isNextSiblingNullOrSpace(node) { | ||
const nextSibling = node.getNextSibling(); | ||
return nextSibling === null || lexical.$isLineBreakNode(nextSibling) || lexical.$isTextNode(nextSibling) && nextSibling.isSimpleText() && nextSibling.getTextContent().startsWith(' '); | ||
} | ||
exports.$areSiblingsNullOrSpace = $areSiblingsNullOrSpace; | ||
exports.$dfs = $dfs; | ||
exports.$findMatchingParent = $findMatchingParent; | ||
exports.$getNearestNodeOfType = $getNearestNodeOfType; | ||
exports.$isNextSiblingNullOrSpace = $isNextSiblingNullOrSpace; | ||
exports.$isPreviousSiblingNullOrSpace = $isPreviousSiblingNullOrSpace; | ||
exports.addClassNamesToElement = addClassNamesToElement; | ||
exports.mergeRegister = mergeRegister; | ||
exports.removeClassNamesFromElement = removeClassNamesFromElement; |
@@ -7,4 +7,3 @@ /** | ||
*/ | ||
var d=require("lexical");function g(a){a=a.getPreviousSibling();return null===a||d.$isLineBreakNode(a)||d.$isTextNode(a)&&a.isSimpleText()&&a.getTextContent().endsWith(" ")}function h(a){a=a.getNextSibling();return null===a||d.$isLineBreakNode(a)||d.$isTextNode(a)&&a.isSimpleText()&&a.getTextContent().startsWith(" ")}exports.$areSiblingsNullOrSpace=function(a){return g(a)&&h(a)}; | ||
exports.$dfs=function(a,b){const c=[];a=(a||d.$getRoot()).getLatest();b=b||(d.$isElementNode(a)?a.getLastDescendant():a);for(var e=a,f=0;null!==(e=e.getParent());)f++;for(e=f;null!==a&&!a.is(b);)if(c.push({depth:e,node:a}),d.$isElementNode(a)&&0<a.getChildrenSize())a=a.getFirstChild(),e++;else for(f=null;null===f&&null!==a;)f=a.getNextSibling(),null===f?(a=a.getParent(),e--):a=f;null!==a&&a.is(b)&&c.push({depth:e,node:a});return c}; | ||
exports.$findMatchingParent=function(a,b){for(;a!==d.$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.$isNextSiblingNullOrSpace=h;exports.$isPreviousSiblingNullOrSpace=g;exports.addClassNamesToElement=function(a,...b){b.forEach(c=>{null!=c&&"string"===typeof c&&a.classList.add(...c.split(" "))})};exports.removeClassNamesFromElement=function(a,...b){b.forEach(c=>{a.classList.remove(...c.split(" "))})}; | ||
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(" "))})}; |
{ | ||
"name": "@lexical/utils", | ||
"author": { | ||
"name": "Dominic Gannaway", | ||
"email": "dg@domgan.com" | ||
}, | ||
"description": "This package contains misc utilities for Lexical.", | ||
@@ -15,10 +11,10 @@ "keywords": [ | ||
"license": "MIT", | ||
"version": "0.1.16", | ||
"version": "0.1.17", | ||
"main": "LexicalUtils.js", | ||
"peerDependencies": { | ||
"lexical": "0.1.16" | ||
"lexical": "0.1.17" | ||
}, | ||
"dependencies": { | ||
"@lexical/list": "0.1.16", | ||
"@lexical/table": "0.1.16" | ||
"@lexical/list": "0.1.17", | ||
"@lexical/table": "0.1.17" | ||
}, | ||
@@ -25,0 +21,0 @@ "repository": { |
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
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
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
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
8460
8
161
2
+ Added@lexical/list@0.1.17(transitive)
+ Added@lexical/table@0.1.17(transitive)
+ Addedlexical@0.1.17(transitive)
- Removed@lexical/list@0.1.16(transitive)
- Removed@lexical/table@0.1.16(transitive)
- Removedlexical@0.1.16(transitive)
Updated@lexical/list@0.1.17
Updated@lexical/table@0.1.17