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

@lexical/list

Package Overview
Dependencies
Maintainers
6
Versions
201
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lexical/list - npm Package Compare versions

Comparing version 0.3.8 to 0.3.9

34

LexicalList.dev.js

@@ -309,16 +309,30 @@ /**

listNodes.forEach(listNode => {
for (const listNode of listNodes) {
let insertionPoint = listNode;
const listItems = $getAllListItems(listNode);
listItems.forEach(listItemNode => {
if (listItemNode != null) {
const paragraph = lexical.$createParagraphNode();
append(paragraph, listItemNode.getChildren());
insertionPoint.insertAfter(paragraph);
insertionPoint = paragraph;
listItemNode.remove();
for (const listItemNode of listItems) {
const paragraph = lexical.$createParagraphNode();
append(paragraph, listItemNode.getChildren());
insertionPoint.insertAfter(paragraph);
insertionPoint = paragraph; // When the anchor and focus fall on the textNode
// we don't have to change the selection because the textNode will be appended to
// the newly generated paragraph.
// When selection is in empty nested list item, selection is actually on the listItemNode.
// When the corresponding listItemNode is deleted and replaced by the newly generated paragraph
// we should manually set the selection's focus and anchor to the newly generated paragraph.
if (listItemNode.__key === selection.anchor.key) {
selection.anchor.set(paragraph.getKey(), 0, 'element');
}
});
if (listItemNode.__key === selection.focus.key) {
selection.focus.set(paragraph.getKey(), 0, 'element');
}
listItemNode.remove();
}
listNode.remove();
});
}
}

@@ -325,0 +339,0 @@ });

@@ -8,9 +8,9 @@ /**

'use strict';var h=require("lexical"),l=require("@lexical/utils");function m(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 n(a){let b=1;for(a=a.getParent();null!=a;){if(p(a)){a=a.getParent();if(q(a)){b++;a=a.getParent();continue}m(40)}break}return b}
function t(a){a=a.getParent();q(a)||m(40);let b=a;for(;null!==b;)b=b.getParent(),q(b)&&(a=b);return a}function u(a){let b=[];a=a.getChildren().filter(p);for(let c=0;c<a.length;c++){let d=a[c],e=d.getFirstChild();q(e)?b=b.concat(u(e)):b.push(d)}return b}function v(a){return p(a)&&q(a.getFirstChild())}function w(a){for(;null==a.getNextSibling()&&null==a.getPreviousSibling();){let b=a.getParent();if(null==b||!p(a)&&!q(a))break;a=b}a.remove()}function x(a){return z().append(a)}
function r(a){a=a.getParent();q(a)||m(40);let b=a;for(;null!==b;)b=b.getParent(),q(b)&&(a=b);return a}function t(a){let b=[];a=a.getChildren().filter(p);for(let c=0;c<a.length;c++){let d=a[c],e=d.getFirstChild();q(e)?b=b.concat(t(e)):b.push(d)}return b}function u(a){return p(a)&&q(a.getFirstChild())}function v(a){for(;null==a.getNextSibling()&&null==a.getPreviousSibling();){let b=a.getParent();if(null==b||!p(a)&&!q(a))break;a=b}a.remove()}function w(a){return z().append(a)}
function A(a,b){return p(a)&&(0===b.length||1===b.length&&a.is(b[0])&&0===a.getChildrenSize())}function C(a,b){a.splice(a.getChildrenSize(),0,b)}
function D(a,b){if(q(a))return a;let c=a.getPreviousSibling(),d=a.getNextSibling(),e=z();C(e,a.getChildren());if(q(c)&&b===c.getListType())return c.append(e),a.remove(),q(d)&&b===d.getListType()&&(C(c,d.getChildren()),d.remove()),c;if(q(d)&&b===d.getListType())return d.getFirstChildOrThrow().insertBefore(e),a.remove(),d;b=E(b);b.append(e);a.replace(b);F(b);return b}
function F(a,b){(b||a.getChildren()).forEach(c=>{let d=c.getValue();var e=c.getParent();var f=1;null!=e&&(q(e)?f=e.getStart():m(44));e=c.getPreviousSiblings();for(let g=0;g<e.length;g++){let k=e[g];p(k)&&!q(k.getFirstChild())&&f++}d!==f&&c.setValue(f)})}
function G(a){let b=new Set;a.forEach(c=>{if(!v(c)&&!b.has(c.getKey())){var d=c.getParent(),e=c.getNextSibling(),f=c.getPreviousSibling();if(v(e)&&v(f))f=f.getFirstChild(),q(f)&&(f.append(c),c=e.getFirstChild(),q(c)&&(c=c.getChildren(),C(f,c),e.remove(),b.add(e.getKey())),F(f));else if(v(e))e=e.getFirstChild(),q(e)&&(f=e.getFirstChild(),null!==f&&f.insertBefore(c),F(e));else if(v(f))e=f.getFirstChild(),q(e)&&(e.append(c),F(e));else if(q(d)){let g=z(),k=E(d.getListType());g.append(k);k.append(c);f?
function G(a){let b=new Set;a.forEach(c=>{if(!u(c)&&!b.has(c.getKey())){var d=c.getParent(),e=c.getNextSibling(),f=c.getPreviousSibling();if(u(e)&&u(f))f=f.getFirstChild(),q(f)&&(f.append(c),c=e.getFirstChild(),q(c)&&(c=c.getChildren(),C(f,c),e.remove(),b.add(e.getKey())),F(f));else if(u(e))e=e.getFirstChild(),q(e)&&(f=e.getFirstChild(),null!==f&&f.insertBefore(c),F(e));else if(u(f))e=f.getFirstChild(),q(e)&&(e.append(c),F(e));else if(q(d)){let g=z(),k=E(d.getListType());g.append(k);k.append(c);f?
f.insertAfter(g):e?e.insertBefore(g):d.append(g)}q(d)&&F(d)}})}
function H(a){a.forEach(b=>{if(!v(b)){var c=b.getParent(),d=c?c.getParent():void 0,e=d?d.getParent():void 0;if(q(e)&&p(d)&&q(c)){var f=c?c.getFirstChild():void 0,g=c?c.getLastChild():void 0;if(b.is(f))d.insertBefore(b),c.isEmpty()&&d.remove();else if(b.is(g))d.insertAfter(b),c.isEmpty()&&d.remove();else{var k=c.getListType();f=z();let r=E(k);f.append(r);b.getPreviousSiblings().forEach(y=>r.append(y));g=z();k=E(k);g.append(k);C(k,b.getNextSiblings());d.insertBefore(f);d.insertAfter(g);d.replace(b)}F(c);
function H(a){a.forEach(b=>{if(!u(b)){var c=b.getParent(),d=c?c.getParent():void 0,e=d?d.getParent():void 0;if(q(e)&&p(d)&&q(c)){var f=c?c.getFirstChild():void 0,g=c?c.getLastChild():void 0;if(b.is(f))d.insertBefore(b),c.isEmpty()&&d.remove();else if(b.is(g))d.insertAfter(b),c.isEmpty()&&d.remove();else{var k=c.getListType();f=z();let x=E(k);f.append(x);b.getPreviousSiblings().forEach(y=>x.append(y));g=z();k=E(k);g.append(k);C(k,b.getNextSiblings());d.insertBefore(f);d.insertAfter(g);d.replace(b)}F(c);
F(e)}}})}function I(a){var b=h.$getSelection();if(h.$isRangeSelection(b)){var c=b.getNodes(),d=[];0===c.length&&c.push(b.anchor.getNode());if(1===c.length){a:{for(c=c[0];null!==c;){if(p(c))break a;c=c.getParent()}c=null}null!==c&&(d=[c])}else{d=new Set;for(b=0;b<c.length;b++){let e=c[b];p(e)&&d.add(e)}d=Array.from(d)}0<d.length&&("indent"===a?G(d):H(d))}}

@@ -29,9 +29,10 @@ class J extends h.ElementNode{static getType(){return"listitem"}static clone(a){return new J(a.__value,a.__checked,a.__key)}constructor(a,b,c){super(c);this.__value=void 0===a?1:a;this.__checked=b}createDOM(a){let b=document.createElement("li"),c=this.getParent();q(c)&&(F(c),K(b,this,null,c));b.value=this.__value;L(b,a.theme,this);return b}updateDOM(a,b,c){let d=this.getParent();q(d)&&(F(d),K(b,this,a,d));b.value=this.__value;L(b,c.theme,this);return!1}static importDOM(){return{li:()=>({conversion:M,

0;c<a.length;c++){var b=a[c];if(p(b))super.append(b);else{let d=z();q(b)?d.append(b):(b=h.$createTextNode(b.getTextContent()),d.append(b));super.append(d)}}return this}extractWithChild(a){return p(a)}}
function P(a,b,c){let d=[],e=[];var f=b.list;if(void 0!==f){let k=f[`${c.__tag}Depth`]||[];b=n(c)-1;let r=b%k.length;var g=k[r];let y=f[c.__tag],B;f=f.nested;void 0!==f&&f.list&&(B=f.list);void 0!==y&&d.push(y);if(void 0!==g)for(g=g.split(" "),d.push(...g),g=0;g<k.length;g++)g!==r&&e.push(c.__tag+g);void 0!==B&&(c=B.split(" "),1<b?d.push(...c):e.push(...c))}0<e.length&&l.removeClassNamesFromElement(a,...e);0<d.length&&l.addClassNamesToElement(a,...d)}
function R(a){let b=[];for(let c=0;c<a.length;c++){let d=a[c];p(d)?(b.push(d),d.getChildren().forEach(e=>{q(e)&&b.push(x(e))})):b.push(x(d))}return b}function Q(a){a=a.nodeName.toLowerCase();let b=null;"ol"===a?b=E("number"):"ul"===a&&(b=E("bullet"));return{after:R,node:b}}let O={ol:"number",ul:"bullet"};function E(a,b=1){return new N(a,b)}function q(a){return a instanceof N}let S=h.createCommand(),T=h.createCommand(),U=h.createCommand(),V=h.createCommand();exports.$createListItemNode=z;
function P(a,b,c){let d=[],e=[];var f=b.list;if(void 0!==f){let k=f[`${c.__tag}Depth`]||[];b=n(c)-1;let x=b%k.length;var g=k[x];let y=f[c.__tag],B;f=f.nested;void 0!==f&&f.list&&(B=f.list);void 0!==y&&d.push(y);if(void 0!==g)for(g=g.split(" "),d.push(...g),g=0;g<k.length;g++)g!==x&&e.push(c.__tag+g);void 0!==B&&(c=B.split(" "),1<b?d.push(...c):e.push(...c))}0<e.length&&l.removeClassNamesFromElement(a,...e);0<d.length&&l.addClassNamesToElement(a,...d)}
function R(a){let b=[];for(let c=0;c<a.length;c++){let d=a[c];p(d)?(b.push(d),d.getChildren().forEach(e=>{q(e)&&b.push(w(e))})):b.push(w(d))}return b}function Q(a){a=a.nodeName.toLowerCase();let b=null;"ol"===a?b=E("number"):"ul"===a&&(b=E("bullet"));return{after:R,node:b}}let O={ol:"number",ul:"bullet"};function E(a,b=1){return new N(a,b)}function q(a){return a instanceof N}let S=h.createCommand(),T=h.createCommand(),U=h.createCommand(),V=h.createCommand();exports.$createListItemNode=z;
exports.$createListNode=E;exports.$getListDepth=n;
exports.$handleListInsertParagraph=function(){var a=h.$getSelection();if(!h.$isRangeSelection(a)||!a.isCollapsed())return!1;a=a.anchor.getNode();if(!p(a)||""!==a.getTextContent())return!1;var b=t(a),c=a.getParent();q(c)||m(40);let d=c.getParent(),e;if(h.$isRootNode(d))e=h.$createParagraphNode(),b.insertAfter(e);else if(p(d))e=z(),d.insertAfter(e);else return!1;e.select();b=a.getNextSiblings();if(0<b.length){let f=E(c.getListType());h.$isParagraphNode(e)?e.insertAfter(f):(c=z(),c.append(f),e.insertAfter(c));
b.forEach(g=>{g.remove();f.append(g)})}w(a);return!0};exports.$isListItemNode=p;exports.$isListNode=q;exports.INSERT_CHECK_LIST_COMMAND=U;exports.INSERT_ORDERED_LIST_COMMAND=T;exports.INSERT_UNORDERED_LIST_COMMAND=S;exports.ListItemNode=J;exports.ListNode=N;exports.REMOVE_LIST_COMMAND=V;exports.indentList=function(){I("indent")};
exports.$handleListInsertParagraph=function(){var a=h.$getSelection();if(!h.$isRangeSelection(a)||!a.isCollapsed())return!1;a=a.anchor.getNode();if(!p(a)||""!==a.getTextContent())return!1;var b=r(a),c=a.getParent();q(c)||m(40);let d=c.getParent(),e;if(h.$isRootNode(d))e=h.$createParagraphNode(),b.insertAfter(e);else if(p(d))e=z(),d.insertAfter(e);else return!1;e.select();b=a.getNextSiblings();if(0<b.length){let f=E(c.getListType());h.$isParagraphNode(e)?e.insertAfter(f):(c=z(),c.append(f),e.insertAfter(c));
b.forEach(g=>{g.remove();f.append(g)})}v(a);return!0};exports.$isListItemNode=p;exports.$isListNode=q;exports.INSERT_CHECK_LIST_COMMAND=U;exports.INSERT_ORDERED_LIST_COMMAND=T;exports.INSERT_UNORDERED_LIST_COMMAND=S;exports.ListItemNode=J;exports.ListNode=N;exports.REMOVE_LIST_COMMAND=V;exports.indentList=function(){I("indent")};
exports.insertList=function(a,b){a.update(()=>{var c=h.$getSelection();if(h.$isRangeSelection(c)){var d=c.getNodes();c=c.anchor.getNode();var e=c.getParent();if(A(c,d))d=E(b),h.$isRootNode(e)?(c.replace(d),c=z(),d.append(c)):p(c)&&(c=c.getParentOrThrow(),C(d,c.getChildren()),c.replace(d));else for(c=new Set,e=0;e<d.length;e++){var f=d[e];if(h.$isElementNode(f)&&f.isEmpty()&&!c.has(f.getKey()))D(f,b);else if(h.$isLeafNode(f))for(f=f.getParent();null!=f;){let k=f.getKey();if(q(f)){if(!c.has(k)){var g=
E(b);C(g,f.getChildren());f.replace(g);F(g);c.add(k)}break}else{g=f.getParent();if(h.$isRootNode(g)&&!c.has(k)){c.add(k);D(f,b);break}f=g}}}}})};exports.outdentList=function(){I("outdent")};
exports.removeList=function(a){a.update(()=>{var b=h.$getSelection();if(h.$isRangeSelection(b)){let d=new Set,e=b.getNodes();b=b.anchor.getNode();if(A(b,e))d.add(t(b));else for(b=0;b<e.length;b++){var c=e[b];h.$isLeafNode(c)&&(c=l.$getNearestNodeOfType(c,J),null!=c&&d.add(t(c)))}d.forEach(f=>{let g=f;u(f).forEach(k=>{if(null!=k){let r=h.$createParagraphNode();C(r,k.getChildren());g.insertAfter(r);g=r;k.remove()}});f.remove()})}})}
exports.removeList=function(a){a.update(()=>{let b=h.$getSelection();if(h.$isRangeSelection(b)){var c=new Set,d=b.getNodes(),e=b.anchor.getNode();if(A(e,d))c.add(r(e));else for(e=0;e<d.length;e++){var f=d[e];h.$isLeafNode(f)&&(f=l.$getNearestNodeOfType(f,J),null!=f&&c.add(r(f)))}for(let g of c){c=g;d=t(g);for(let k of d)d=h.$createParagraphNode(),C(d,k.getChildren()),c.insertAfter(d),c=d,k.__key===b.anchor.key&&b.anchor.set(d.getKey(),0,"element"),k.__key===b.focus.key&&b.focus.set(d.getKey(),0,"element"),
k.remove();g.remove()}}})}

@@ -11,9 +11,9 @@ {

"license": "MIT",
"version": "0.3.8",
"version": "0.3.9",
"main": "LexicalList.js",
"peerDependencies": {
"lexical": "0.3.8"
"lexical": "0.3.9"
},
"dependencies": {
"@lexical/utils": "0.3.8"
"@lexical/utils": "0.3.9"
},

@@ -20,0 +20,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