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
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.6.4 to 0.6.5

15

LexicalUtils.dev.js

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

const children = parsedNode.__children;
let prevNode = null;
for (let i = 0; i < children.length; i++) {
const childKey = children[i];
if (i === 0) {
node.__first = childKey;
} else if (i === children.length - 1) {
node.__last = childKey;
}
const parsedChild = parsedNodeMap.get(childKey);

@@ -310,3 +318,10 @@

if (prevNode !== null) {
child.__prev = prevNode.__key;
prevNode.__next = newChildKey;
}
node.__children.push(newChildKey);
prevNode = child;
}

@@ -313,0 +328,0 @@ }

24

LexicalUtils.prod.js

@@ -7,14 +7,14 @@ /**

*/
'use strict';var l=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 d of b)if(a.type.startsWith(d))return!0;return!1}function r(a,b){for(;a!==l.$getRoot()&&null!=a;){if(b(a))return a;a=a.getParent()}return null}
function t(a,b,d,g,f){var c=d._nodes.get(a.__type);void 0===c&&p(5);for(var e in a){var k=a[e];if(null!=k&&"object"===typeof k&&(k=k.editorState,null!=k)){var h=l.createEditor({namespace:k.namespace});h._nodes=d._nodes;h._parentEditor=d._parentEditor;h._pendingEditorState=u(h,k);a[e]=h}}c=c.klass;e=a.__key;a.__key=void 0;c=c.clone(a);a.__key=e;e=c.__key;f._nodeMap.set(e,c);c.__parent=g;if(l.$isElementNode(c)){g=a.__children;for(k=0;k<g.length;k++)h=b.get(g[k]),void 0!==h&&(h=t(h,b,d,e,f).__key,c.__children.push(h));
c.__indent=a.__indent;c.__format=a.__format;c.__dir=a.__dir}else l.$isTextNode(c)&&(c.__format=a.__format,c.__style=a.__style,c.__mode=a.__mode,c.__detail=a.__detail);return c}
function v(a,b){let d=b._editorState.constructor,g=new Map,f=new d(g),c=new Map(a._nodeMap),e=c.get("root");a=b._updating;try{b._updating=!1,b.update(()=>{let k=b._dirtyElements,h=b._dirtyLeaves,m=b._dirtyType;b._dirtyElements=new Map;b._dirtyLeaves=new Set;b._dirtyType=0;try{t(e,c,b,null,f)}finally{b._dirtyElements=k,b._dirtyLeaves=h,b._dirtyType=m}})}finally{b._updating=a}f._readOnly=!0;return f}function u(a,b){b="string"===typeof b?JSON.parse(b):b;return v(b,a)}
function w(a,b){let d=a.getChildAtIndex(b);null==d&&(d=a);if(l.$isRootOrShadowRoot(a))throw Error("Can not call $splitNode() on root element");let g=e=>{const k=e.getParentOrThrow(),h=l.$isRootOrShadowRoot(k),m=e!==d||h?l.$copyNode(e):e;if(h)return e.insertAfter(m),[e,m,m];const [n,x,y]=g(k);e=e.getNextSiblings();y.append(m,...e);return[n,x,m]},[f,c]=g(d);return[f,c]}
exports.$dfs=function(a,b){let d=[];a=(a||l.$getRoot()).getLatest();b=b||(l.$isElementNode(a)?a.getLastDescendant():a);for(var g=a,f=0;null!==(g=g.getParent());)f++;for(g=f;null!==a&&!a.is(b);)if(d.push({depth:g,node:a}),l.$isElementNode(a)&&0<a.getChildrenSize())a=a.getFirstChild(),g++;else for(f=null;null===f&&null!==a;)f=a.getNextSibling(),null===f?(a=a.getParent(),g--):a=f;null!==a&&a.is(b)&&d.push({depth:g,node:a});return d};exports.$findMatchingParent=r;
exports.$getNearestBlockElementAncestorOrThrow=function(a){a=r(a,b=>l.$isElementNode(b)&&!b.isInline());l.$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=l.$getSelection();if(l.$isRangeSelection(b)){var {focus:d}=b;b=d.getNode();d=d.offset;if(l.$isRootOrShadowRoot(b))d=b.getChildAtIndex(d),null==d?b.append(a):d.insertBefore(a),a.selectNext();else{let g,f;l.$isTextNode(b)?(g=b.getParentOrThrow(),f=b.getIndexWithinParent(),0<d&&(f+=1,b.splitText(d))):(g=b,f=d);[,b]=w(g,f);b.insertBefore(a);b.selectStart()}}else l.$isNodeSelection(b)||l.DEPRECATED_$isGridSelection(b)?(b=b.getNodes(),b[b.length-1].getTopLevelElementOrThrow().insertAfter(a)):
l.$getRoot().append(a),b=l.$createParagraphNode(),a.insertAfter(b),b.select();return a.getLatest()};exports.$restoreEditorState=function(a,b){let d=new Map(b._nodeMap),g=a._pendingEditorState;g&&(g._nodeMap=d);a._dirtyType=2;a=b._selection;l.$setSelection(null===a?null:a.clone())};exports.$splitNode=w;exports.$wrapNodeInElement=function(a,b){b=b();a.replace(b);b.append(a);return b};
exports.addClassNamesToElement=function(a,...b){b.forEach(d=>{"string"===typeof d&&(d=d.split(" ").filter(g=>""!==g),a.classList.add(...d))})};exports.isMimeType=q;
exports.mediaFileReader=function(a,b){let d=a[Symbol.iterator]();return new Promise((g,f)=>{let c=[],e=()=>{const {done:k,value:h}=d.next();if(k)return g(c);const m=new FileReader;m.addEventListener("error",f);m.addEventListener("load",()=>{const n=m.result;"string"===typeof n&&c.push({file:h,result:n});e()});q(h,b)?m.readAsDataURL(h):e()};e()})};exports.mergeRegister=function(...a){return()=>{a.forEach(b=>b())}};
exports.registerNestedElementResolver=function(a,b,d,g){return a.registerNodeTransform(b,f=>{a:{var c=f.getChildren();for(var e=0;e<c.length;e++)if(c[e]instanceof b){c=null;break a}for(c=f;null!==c;)if(e=c,c=c.getParent(),c instanceof b){c={child:e,parent:c};break a}c=null}if(null!==c){const {child:k,parent:h}=c;if(k.is(f)){g(h,f);f=k.getNextSiblings();c=f.length;h.insertAfter(k);if(0!==c){e=d(h);k.insertAfter(e);for(let m=0;m<c;m++)e.append(f[m])}h.canBeEmpty()||0!==h.getChildrenSize()||h.remove()}}})};
'use strict';var m=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 d of b)if(a.type.startsWith(d))return!0;return!1}function r(a,b){for(;a!==m.$getRoot()&&null!=a;){if(b(a))return a;a=a.getParent()}return null}
function t(a,b,d,f,g){var c=d._nodes.get(a.__type);void 0===c&&p(5);for(var e in a){var l=a[e];if(null!=l&&"object"===typeof l&&(l=l.editorState,null!=l)){var h=m.createEditor({namespace:l.namespace});h._nodes=d._nodes;h._parentEditor=d._parentEditor;h._pendingEditorState=u(h,l);a[e]=h}}c=c.klass;e=a.__key;a.__key=void 0;c=c.clone(a);a.__key=e;e=c.__key;g._nodeMap.set(e,c);c.__parent=f;if(m.$isElementNode(c)){f=a.__children;l=null;for(h=0;h<f.length;h++){var k=f[h];0===h?c.__first=k:h===f.length-
1&&(c.__last=k);k=b.get(k);if(void 0!==k){k=t(k,b,d,e,g);let n=k.__key;null!==l&&(k.__prev=l.__key,l.__next=n);c.__children.push(n);l=k}}c.__indent=a.__indent;c.__format=a.__format;c.__dir=a.__dir}else m.$isTextNode(c)&&(c.__format=a.__format,c.__style=a.__style,c.__mode=a.__mode,c.__detail=a.__detail);return c}
function v(a,b){let d=b._editorState.constructor,f=new Map,g=new d(f),c=new Map(a._nodeMap),e=c.get("root");a=b._updating;try{b._updating=!1,b.update(()=>{let l=b._dirtyElements,h=b._dirtyLeaves,k=b._dirtyType;b._dirtyElements=new Map;b._dirtyLeaves=new Set;b._dirtyType=0;try{t(e,c,b,null,g)}finally{b._dirtyElements=l,b._dirtyLeaves=h,b._dirtyType=k}})}finally{b._updating=a}g._readOnly=!0;return g}function u(a,b){b="string"===typeof b?JSON.parse(b):b;return v(b,a)}
function w(a,b){let d=a.getChildAtIndex(b);null==d&&(d=a);if(m.$isRootOrShadowRoot(a))throw Error("Can not call $splitNode() on root element");let f=e=>{const l=e.getParentOrThrow(),h=m.$isRootOrShadowRoot(l),k=e!==d||h?m.$copyNode(e):e;if(h)return e.insertAfter(k),[e,k,k];const [n,x,y]=f(l);e=e.getNextSiblings();y.append(k,...e);return[n,x,k]},[g,c]=f(d);return[g,c]}
exports.$dfs=function(a,b){let d=[];a=(a||m.$getRoot()).getLatest();b=b||(m.$isElementNode(a)?a.getLastDescendant():a);for(var f=a,g=0;null!==(f=f.getParent());)g++;for(f=g;null!==a&&!a.is(b);)if(d.push({depth:f,node:a}),m.$isElementNode(a)&&0<a.getChildrenSize())a=a.getFirstChild(),f++;else for(g=null;null===g&&null!==a;)g=a.getNextSibling(),null===g?(a=a.getParent(),f--):a=g;null!==a&&a.is(b)&&d.push({depth:f,node:a});return d};exports.$findMatchingParent=r;
exports.$getNearestBlockElementAncestorOrThrow=function(a){a=r(a,b=>m.$isElementNode(b)&&!b.isInline());m.$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=m.$getSelection();if(m.$isRangeSelection(b)){var {focus:d}=b;b=d.getNode();d=d.offset;if(m.$isRootOrShadowRoot(b))d=b.getChildAtIndex(d),null==d?b.append(a):d.insertBefore(a),a.selectNext();else{let f,g;m.$isTextNode(b)?(f=b.getParentOrThrow(),g=b.getIndexWithinParent(),0<d&&(g+=1,b.splitText(d))):(f=b,g=d);[,b]=w(f,g);b.insertBefore(a);b.selectStart()}}else m.$isNodeSelection(b)||m.DEPRECATED_$isGridSelection(b)?(b=b.getNodes(),b[b.length-1].getTopLevelElementOrThrow().insertAfter(a)):
m.$getRoot().append(a),b=m.$createParagraphNode(),a.insertAfter(b),b.select();return a.getLatest()};exports.$restoreEditorState=function(a,b){let d=new Map(b._nodeMap),f=a._pendingEditorState;f&&(f._nodeMap=d);a._dirtyType=2;a=b._selection;m.$setSelection(null===a?null:a.clone())};exports.$splitNode=w;exports.$wrapNodeInElement=function(a,b){b=b();a.replace(b);b.append(a);return b};
exports.addClassNamesToElement=function(a,...b){b.forEach(d=>{"string"===typeof d&&(d=d.split(" ").filter(f=>""!==f),a.classList.add(...d))})};exports.isMimeType=q;
exports.mediaFileReader=function(a,b){let d=a[Symbol.iterator]();return new Promise((f,g)=>{let c=[],e=()=>{const {done:l,value:h}=d.next();if(l)return f(c);const k=new FileReader;k.addEventListener("error",g);k.addEventListener("load",()=>{const n=k.result;"string"===typeof n&&c.push({file:h,result:n});e()});q(h,b)?k.readAsDataURL(h):e()};e()})};exports.mergeRegister=function(...a){return()=>{a.forEach(b=>b())}};
exports.registerNestedElementResolver=function(a,b,d,f){return a.registerNodeTransform(b,g=>{a:{var c=g.getChildren();for(var e=0;e<c.length;e++)if(c[e]instanceof b){c=null;break a}for(c=g;null!==c;)if(e=c,c=c.getParent(),c instanceof b){c={child:e,parent:c};break a}c=null}if(null!==c){const {child:l,parent:h}=c;if(l.is(g)){f(h,g);g=l.getNextSiblings();c=g.length;h.insertAfter(l);if(0!==c){e=d(h);l.insertAfter(e);for(let k=0;k<c;k++)e.append(g[k])}h.canBeEmpty()||0!==h.getChildrenSize()||h.remove()}}})};
exports.removeClassNamesFromElement=function(a,...b){b.forEach(d=>{"string"===typeof d&&a.classList.remove(...d.split(" "))})};exports.unstable_convertLegacyJSONEditorState=u

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

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

@@ -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