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

@lexical/utils

Package Overview
Dependencies
Maintainers
6
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.7.7 to 0.7.8

7

LexicalUtils.dev.js

@@ -255,5 +255,10 @@ /**

const FULL_RECONCILE = 2;
const nodeMap = new Map(editorState._nodeMap);
const nodeMap = new Map();
const activeEditorState = editor._pendingEditorState;
for (const [key, node] of editorState._nodeMap) {
// @ts-ignore
nodeMap.set(key, node.constructor.clone(node));
}
if (activeEditorState) {

@@ -260,0 +265,0 @@ activeEditorState._nodeMap = nodeMap;

14

LexicalUtils.prod.js

@@ -8,10 +8,10 @@ /**

'use strict';var h=require("lexical");function p(a){throw Error(`Minified Lexical error #${a}; visit https://lexical.dev/docs/error?code=${a} for the full message or `+"use the non-minified dev environment for full errors and additional helpful warnings.");}function q(a,b){for(let c of b)if(a.type.startsWith(c))return!0;return!1}function r(a,b){for(;a!==h.$getRoot()&&null!=a;){if(b(a))return a;a=a.getParent()}return null}
function t(a,b){let c=a.getChildAtIndex(b);null==c&&(c=a);h.$isRootOrShadowRoot(a)&&p(102);let e=f=>{const m=f.getParentOrThrow(),l=h.$isRootOrShadowRoot(m),k=f!==c||l?h.$copyNode(f):f;if(l)return f.insertAfter(k),[f,k,k];const [n,u,v]=e(m);f=f.getNextSiblings();v.append(k,...f);return[n,u,k]},[d,g]=e(c);return[d,g]}
exports.$dfs=function(a,b){let c=[];a=(a||h.$getRoot()).getLatest();b=b||(h.$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}),h.$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.$findMatchingParent=r;
function t(a,b){let c=a.getChildAtIndex(b);null==c&&(c=a);h.$isRootOrShadowRoot(a)&&p(102);let f=g=>{const m=g.getParentOrThrow(),l=h.$isRootOrShadowRoot(m),k=g!==c||l?h.$copyNode(g):g;if(l)return g.insertAfter(k),[g,k,k];const [n,u,v]=f(m);g=g.getNextSiblings();v.append(k,...g);return[n,u,k]},[d,e]=f(c);return[d,e]}
exports.$dfs=function(a,b){let c=[];a=(a||h.$getRoot()).getLatest();b=b||(h.$isElementNode(a)?a.getLastDescendant():a);for(var f=a,d=0;null!==(f=f.getParent());)d++;for(f=d;null!==a&&!a.is(b);)if(c.push({depth:f,node:a}),h.$isElementNode(a)&&0<a.getChildrenSize())a=a.getFirstChild(),f++;else for(d=null;null===d&&null!==a;)d=a.getNextSibling(),null===d?(a=a.getParent(),f--):a=d;null!==a&&a.is(b)&&c.push({depth:f,node:a});return c};exports.$findMatchingParent=r;
exports.$getNearestBlockElementAncestorOrThrow=function(a){a=r(a,b=>h.$isElementNode(b)&&!b.isInline());h.$isElementNode(a)||p(4);return a};exports.$getNearestNodeOfType=function(a,b){for(;null!=a;){if(a instanceof b)return a;a=a.getParent()}return null};
exports.$insertNodeToNearestRoot=function(a){var b=h.$getSelection();if(h.$isRangeSelection(b)){var {focus:c}=b;b=c.getNode();c=c.offset;if(h.$isRootOrShadowRoot(b))c=b.getChildAtIndex(c),null==c?b.append(a):c.insertBefore(a),a.selectNext();else{let e,d;h.$isTextNode(b)?(e=b.getParentOrThrow(),d=b.getIndexWithinParent(),0<c&&(d+=1,b.splitText(c))):(e=b,d=c);[,b]=t(e,d);b.insertBefore(a);b.selectStart()}}else h.$isNodeSelection(b)||h.DEPRECATED_$isGridSelection(b)?(b=b.getNodes(),b[b.length-1].getTopLevelElementOrThrow().insertAfter(a)):
h.$getRoot().append(a),b=h.$createParagraphNode(),a.insertAfter(b),b.select();return a.getLatest()};exports.$restoreEditorState=function(a,b){let c=new Map(b._nodeMap),e=a._pendingEditorState;e&&(e._nodeMap=c);a._dirtyType=2;a=b._selection;h.$setSelection(null===a?null:a.clone())};exports.$splitNode=t;exports.$wrapNodeInElement=function(a,b){b=b();a.replace(b);b.append(a);return b};
exports.addClassNamesToElement=function(a,...b){b.forEach(c=>{"string"===typeof c&&(c=c.split(" ").filter(e=>""!==e),a.classList.add(...c))})};exports.isMimeType=q;
exports.mediaFileReader=function(a,b){let c=a[Symbol.iterator]();return new Promise((e,d)=>{let g=[],f=()=>{const {done:m,value:l}=c.next();if(m)return e(g);const k=new FileReader;k.addEventListener("error",d);k.addEventListener("load",()=>{const n=k.result;"string"===typeof n&&g.push({file:l,result:n});f()});q(l,b)?k.readAsDataURL(l):f()};f()})};exports.mergeRegister=function(...a){return()=>{a.forEach(b=>b())}};
exports.registerNestedElementResolver=function(a,b,c,e){return a.registerNodeTransform(b,d=>{a:{var g=d.getChildren();for(var f=0;f<g.length;f++)if(g[f]instanceof b){g=null;break a}for(g=d;null!==g;)if(f=g,g=g.getParent(),g instanceof b){g={child:f,parent:g};break a}g=null}if(null!==g){const {child:m,parent:l}=g;if(m.is(d)){e(l,d);d=m.getNextSiblings();g=d.length;l.insertAfter(m);if(0!==g){f=c(l);m.insertAfter(f);for(let k=0;k<g;k++)f.append(d[k])}l.canBeEmpty()||0!==l.getChildrenSize()||l.remove()}}})};
exports.$insertNodeToNearestRoot=function(a){var b=h.$getSelection();if(h.$isRangeSelection(b)){var {focus:c}=b;b=c.getNode();c=c.offset;if(h.$isRootOrShadowRoot(b))c=b.getChildAtIndex(c),null==c?b.append(a):c.insertBefore(a),a.selectNext();else{let f,d;h.$isTextNode(b)?(f=b.getParentOrThrow(),d=b.getIndexWithinParent(),0<c&&(d+=1,b.splitText(c))):(f=b,d=c);[,b]=t(f,d);b.insertBefore(a);b.selectStart()}}else h.$isNodeSelection(b)||h.DEPRECATED_$isGridSelection(b)?(b=b.getNodes(),b[b.length-1].getTopLevelElementOrThrow().insertAfter(a)):
h.$getRoot().append(a),b=h.$createParagraphNode(),a.insertAfter(b),b.select();return a.getLatest()};exports.$restoreEditorState=function(a,b){let c=new Map,f=a._pendingEditorState;for(let [d,e]of b._nodeMap)c.set(d,e.constructor.clone(e));f&&(f._nodeMap=c);a._dirtyType=2;a=b._selection;h.$setSelection(null===a?null:a.clone())};exports.$splitNode=t;exports.$wrapNodeInElement=function(a,b){b=b();a.replace(b);b.append(a);return b};
exports.addClassNamesToElement=function(a,...b){b.forEach(c=>{"string"===typeof c&&(c=c.split(" ").filter(f=>""!==f),a.classList.add(...c))})};exports.isMimeType=q;
exports.mediaFileReader=function(a,b){let c=a[Symbol.iterator]();return new Promise((f,d)=>{let e=[],g=()=>{const {done:m,value:l}=c.next();if(m)return f(e);const k=new FileReader;k.addEventListener("error",d);k.addEventListener("load",()=>{const n=k.result;"string"===typeof n&&e.push({file:l,result:n});g()});q(l,b)?k.readAsDataURL(l):g()};g()})};exports.mergeRegister=function(...a){return()=>{a.forEach(b=>b())}};
exports.registerNestedElementResolver=function(a,b,c,f){return a.registerNodeTransform(b,d=>{a:{var e=d.getChildren();for(var g=0;g<e.length;g++)if(e[g]instanceof b){e=null;break a}for(e=d;null!==e;)if(g=e,e=e.getParent(),e instanceof b){e={child:g,parent:e};break a}e=null}if(null!==e){const {child:m,parent:l}=e;if(m.is(d)){f(l,d);d=m.getNextSiblings();e=d.length;l.insertAfter(m);if(0!==e){g=c(l);m.insertAfter(g);for(let k=0;k<e;k++)g.append(d[k])}l.canBeEmpty()||0!==l.getChildrenSize()||l.remove()}}})};
exports.removeClassNamesFromElement=function(a,...b){b.forEach(c=>{"string"===typeof c&&a.classList.remove(...c.split(" "))})}

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

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

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

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