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

@lexical/list

Package Overview
Dependencies
Maintainers
2
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.1.10 to 0.1.11

144

LexicalList.dev.js

@@ -87,25 +87,3 @@ /**

}
function $isLastItemInList(listItem) {
let isLast = true;
const firstChild = listItem.getFirstChild();
if (list.$isListNode(firstChild)) {
return false;
}
let parent = listItem;
while (parent !== null) {
if (list.$isListItemNode(parent)) {
if (parent.getNextSiblings().length > 0) {
isLast = false;
}
}
parent = parent.getParent();
}
return isLast;
} // This should probably be $getAllChildrenOfType
function $getAllListItems(node) {

@@ -158,3 +136,24 @@ let listItemNodes = []; //$FlowFixMe - the result of this will always be an array of ListItemNodes.

}
function $removeHighestEmptyListParent(sublist) {
// Nodes may be repeatedly indented, to create deeply nested lists that each
// contain just one bullet.
// Our goal is to remove these (empty) deeply nested lists. The easiest
// way to do that is crawl back up the tree until we find a node that has siblings
// (e.g. is actually part of the list contents) and delete that, or delete
// the root of the list (if no list nodes have siblings.)
let emptyListPtr = sublist;
while (emptyListPtr.getNextSibling() == null && emptyListPtr.getPreviousSibling() == null) {
const parent = emptyListPtr.getParent();
if (parent == null || !(list.$isListItemNode(emptyListPtr) || list.$isListNode(emptyListPtr))) {
break;
}
emptyListPtr = parent;
}
emptyListPtr.remove();
}
/**

@@ -480,3 +479,61 @@ * Copyright (c) Meta Platforms, Inc. and affiliates.

}
function $handleListInsertParagraph() {
const selection = lexical.$getSelection();
if (selection === null || !selection.isCollapsed()) {
return false;
} // Only run this code on empty list items
const anchor = selection.anchor.getNode();
if (!list.$isListItemNode(anchor) || anchor.getTextContent() !== '') {
return false;
}
const topListNode = $getTopListNode(anchor);
const parent = anchor.getParent();
if (!list.$isListNode(parent)) {
throw Error(`A ListItemNode must have a ListNode for a parent.`);
}
const grandparent = parent.getParent();
let replacementNode;
if (lexical.$isRootNode(grandparent)) {
replacementNode = lexical.$createParagraphNode();
topListNode.insertAfter(replacementNode);
} else if (list.$isListItemNode(grandparent)) {
replacementNode = list.$createListItemNode();
grandparent.insertAfter(replacementNode);
} else {
return false;
}
replacementNode.select();
const nextSiblings = anchor.getNextSiblings();
if (nextSiblings.length > 0) {
const newList = list.$createListNode(parent.getTag());
if (lexical.$isParagraphNode(replacementNode)) {
replacementNode.insertAfter(newList);
} else {
const newListItem = list.$createListItemNode();
newListItem.append(newList);
replacementNode.insertAfter(newListItem);
}
nextSiblings.forEach(sibling => {
sibling.remove();
newList.append(sibling);
});
} // Don't leave hanging nested empty lists
$removeHighestEmptyListParent(anchor);
return true;
}
/**

@@ -649,42 +706,4 @@ * Copyright (c) Meta Platforms, Inc. and affiliates.

insertNewAfter() {
const nextSibling = this.getNextSibling();
const prevSibling = this.getPreviousSibling();
const list$1 = $getTopListNode(this);
const isLast = $isLastItemInList(this);
let newElement;
if (lexical.$isElementNode(list$1) && this.getTextContent() === '' && (prevSibling === null || nextSibling === null) && isLast) {
if (nextSibling === null) {
newElement = lexical.$createParagraphNode();
list$1.insertAfter(newElement);
} else {
newElement = lexical.$createParagraphNode();
list$1.insertBefore(newElement);
} // The naive approach would be to remove this list item and then the list, if it's empty.
// However, nodes may be repeatedly indented, to create deeply nested lists that each
// contain just one bullet.
// Our goal is to remove these (now-empty) deeply nested lists. The easiest way to do that
// is crawl back up the tree until we find a node that has siblings (e.g. is actually part
// of the list contents) and delete that, or delete the root of the list (if no list nodes
// have siblings.)
let emptyListPtr = this;
while (emptyListPtr.getNextSibling() == null && emptyListPtr.getPreviousSibling() == null) {
const parent = emptyListPtr.getParent();
if (parent == null || !($isListItemNode(emptyListPtr) || list.$isListNode(emptyListPtr))) {
break;
}
emptyListPtr = parent;
}
emptyListPtr.remove();
} else {
newElement = $createListItemNode();
this.insertAfter(newElement);
}
const newElement = $createListItemNode();
this.insertAfter(newElement);
return newElement;

@@ -1027,2 +1046,3 @@ }

exports.$createListNode = $createListNode;
exports.$handleListInsertParagraph = $handleListInsertParagraph;
exports.$isListItemNode = $isListItemNode;

@@ -1029,0 +1049,0 @@ exports.$isListNode = $isListNode;

@@ -7,24 +7,25 @@ /**

*/
var f=require("@lexical/list"),k=require("lexical");function n(b,a){for(;null!=b&&!(b instanceof a);)b=b.getParent();return b}function p(b){throw Error(`Minified Lexical error #${b}; see codes.json for the full message or `+"use the non-minified dev environment for full errors and additional helpful warnings.");}function r(b){b=b.getParent();f.$isListNode(b)||p(2);let a=b;for(;null!==a;)a=a.getParent(),f.$isListNode(a)&&(b=a);return b}
function t(b){let a=[];b=b.getChildren().filter(f.$isListItemNode);for(let c=0;c<b.length;c++){const d=b[c],e=d.getFirstChild();f.$isListNode(e)?a=a.concat(t(e)):a.push(d)}return a}function u(b){return f.$isListItemNode(b)&&f.$isListNode(b.getFirstChild())}
function v(b,a){if(f.$isListNode(b))return b;const c=b.getPreviousSibling(),d=b.getNextSibling(),e=f.$createListItemNode();if(f.$isListNode(c)&&a===c.getTag())return e.append(b),c.append(e),f.$isListNode(d)&&a===d.getTag()&&(c.append(...d.getChildren()),d.remove()),c;if(f.$isListNode(d)&&a===d.getTag())return e.append(b),d.getFirstChildOrThrow().insertBefore(e),d;a=f.$createListNode(a);a.append(e);b.replace(a);e.append(b);return a}
function w(b){b.forEach(a=>{if(!u(a)){var c=a.getParent(),d=a.getNextSibling(),e=a.getPreviousSibling();if(u(d)&&u(e))e=e.getFirstChild(),f.$isListNode(e)&&(e.append(a),a=d.getFirstChild(),f.$isListNode(a)&&(d=a.getChildren(),e.append(...d),a.remove()),e.getChildren().forEach(g=>g.markDirty()));else if(u(d))d=d.getFirstChild(),f.$isListNode(d)&&(e=d.getFirstChild(),null!==e&&e.insertBefore(a),d.getChildren().forEach(g=>g.markDirty()));else if(u(e))d=e.getFirstChild(),f.$isListNode(d)&&(d.append(a),
var f=require("@lexical/list"),k=require("lexical");function n(b){throw Error(`Minified Lexical error #${b}; see codes.json for the full message or `+"use the non-minified dev environment for full errors and additional helpful warnings.");}function p(b,a){for(;null!=b&&!(b instanceof a);)b=b.getParent();return b}function q(b){b=b.getParent();f.$isListNode(b)||n(2);let a=b;for(;null!==a;)a=a.getParent(),f.$isListNode(a)&&(b=a);return b}
function t(b){let a=[];b=b.getChildren().filter(f.$isListItemNode);for(let c=0;c<b.length;c++){const d=b[c],e=d.getFirstChild();f.$isListNode(e)?a=a.concat(t(e)):a.push(d)}return a}function u(b){return f.$isListItemNode(b)&&f.$isListNode(b.getFirstChild())}function v(b){for(;null==b.getNextSibling()&&null==b.getPreviousSibling();){const a=b.getParent();if(null==a||!f.$isListItemNode(b)&&!f.$isListNode(b))break;b=a}b.remove()}
function w(b,a){if(f.$isListNode(b))return b;const c=b.getPreviousSibling(),d=b.getNextSibling(),e=f.$createListItemNode();if(f.$isListNode(c)&&a===c.getTag())return e.append(b),c.append(e),f.$isListNode(d)&&a===d.getTag()&&(c.append(...d.getChildren()),d.remove()),c;if(f.$isListNode(d)&&a===d.getTag())return e.append(b),d.getFirstChildOrThrow().insertBefore(e),d;a=f.$createListNode(a);a.append(e);b.replace(a);e.append(b);return a}
function x(b){b.forEach(a=>{if(!u(a)){var c=a.getParent(),d=a.getNextSibling(),e=a.getPreviousSibling();if(u(d)&&u(e))e=e.getFirstChild(),f.$isListNode(e)&&(e.append(a),a=d.getFirstChild(),f.$isListNode(a)&&(d=a.getChildren(),e.append(...d),a.remove()),e.getChildren().forEach(g=>g.markDirty()));else if(u(d))d=d.getFirstChild(),f.$isListNode(d)&&(e=d.getFirstChild(),null!==e&&e.insertBefore(a),d.getChildren().forEach(g=>g.markDirty()));else if(u(e))d=e.getFirstChild(),f.$isListNode(d)&&(d.append(a),
d.getChildren().forEach(g=>g.markDirty()));else if(f.$isListNode(c)){const g=f.$createListItemNode(),h=f.$createListNode(c.getTag());g.append(h);h.append(a);e?e.insertAfter(g):d?d.insertBefore(g):c.append(g)}f.$isListNode(c)&&c.getChildren().forEach(g=>g.markDirty())}})}
function x(b){b.forEach(a=>{if(!u(a)){var c=a.getParent(),d=c?c.getParent():void 0,e=d?d.getParent():void 0;if(f.$isListNode(e)&&f.$isListItemNode(d)&&f.$isListNode(c)){var g=c?c.getFirstChild():void 0,h=c?c.getLastChild():void 0;if(a.is(g))d.insertBefore(a),c.isEmpty()&&d.remove();else if(a.is(h))d.insertAfter(a),c.isEmpty()&&d.remove();else{var l=c.getTag();g=f.$createListItemNode();const m=f.$createListNode(l);g.append(m);a.getPreviousSiblings().forEach(q=>m.append(q));h=f.$createListItemNode();
function y(b){b.forEach(a=>{if(!u(a)){var c=a.getParent(),d=c?c.getParent():void 0,e=d?d.getParent():void 0;if(f.$isListNode(e)&&f.$isListItemNode(d)&&f.$isListNode(c)){var g=c?c.getFirstChild():void 0,h=c?c.getLastChild():void 0;if(a.is(g))d.insertBefore(a),c.isEmpty()&&d.remove();else if(a.is(h))d.insertAfter(a),c.isEmpty()&&d.remove();else{var l=c.getTag();g=f.$createListItemNode();const m=f.$createListNode(l);g.append(m);a.getPreviousSiblings().forEach(r=>m.append(r));h=f.$createListItemNode();
l=f.$createListNode(l);h.append(l);l.append(...a.getNextSiblings());d.insertBefore(g);d.insertAfter(h);d.replace(a)}c.getChildren().forEach(m=>m.markDirty());e.getChildren().forEach(m=>m.markDirty())}}})}
function y(b){var a=k.$getSelection();if(!k.$isRangeSelection(a))return!1;var c=a.getNodes(),d=[];0===c.length&&c.push(a.anchor.getNode());if(1===c.length){a:{for(c=c[0];null!==c;){if(f.$isListItemNode(c))break a;c=c.getParent()}c=null}null!==c&&(d=[c])}else{d=new Set;for(a=0;a<c.length;a++){const e=c[a];f.$isListItemNode(e)&&d.add(e)}d=Array.from(d)}return 0<d.length?("indent"===b?w(d):x(d),!0):!1}function z(b,...a){a.forEach(c=>{null!=c&&"string"===typeof c&&b.classList.add(...c.split(" "))})}
function A(b,...a){a.forEach(c=>{b.classList.remove(...c.split(" "))})}
class B extends k.ElementNode{static getType(){return"listitem"}static clone(b){return new B(b.__key)}constructor(b){super(b)}createDOM(b){const a=document.createElement("li");a.value=C(this);D(a,b.theme,this);return a}updateDOM(b,a,c){a.value=C(this);D(a,c.theme,this);return!1}static convertDOM(){return{li:()=>({conversion:E,priority:0})}}append(...b){for(let a=0;a<b.length;a++){const c=b[a];if(k.$isElementNode(c)&&this.canMergeWith(c)){const d=c.getChildren();this.append(...d);c.remove()}else super.append(c)}return this}replace(b){if(F(b))return super.replace(b);
const a=this.getParentOrThrow();if(f.$isListNode(a)){var c=a.__children;const e=c.length;var d=c.indexOf(this.__key);if(0===d)a.insertBefore(b);else if(d===e-1)a.insertAfter(b);else{c=f.$createListNode(a.__tag);const g=a.getChildren();for(d+=1;d<e;d++)c.append(g[d]);a.insertAfter(b);b.insertAfter(c)}this.remove();1===e&&a.remove()}return b}insertAfter(b){var a=this.getNextSiblings();if(F(b))return a.forEach(d=>d.markDirty()),super.insertAfter(b);var c=this.getParentOrThrow();f.$isListNode(c)||p(1);
if(f.$isListNode(b)&&b.getTag()===c.getTag()){a=b;b=b.getChildren();for(c=b.length-1;0<=c;c--)a=b[c],this.insertAfter(a);return a}c.insertAfter(b);if(0!==a.length){const d=f.$createListNode(c.getTag());a.forEach(e=>d.append(e));b.insertAfter(d)}return b}insertNewAfter(){var b=this.getNextSibling(),a=this.getPreviousSibling(),c=r(this);var d=!0;var e=this.getFirstChild();if(f.$isListNode(e))d=!1;else for(e=this;null!==e;)f.$isListItemNode(e)&&0<e.getNextSiblings().length&&(d=!1),e=e.getParent();if(k.$isElementNode(c)&&
""===this.getTextContent()&&(null===a||null===b)&&d){null===b?(b=k.$createParagraphNode(),c.insertAfter(b)):(b=k.$createParagraphNode(),c.insertBefore(b));for(c=this;null==c.getNextSibling()&&null==c.getPreviousSibling();){a=c.getParent();if(null==a||!F(c)&&!f.$isListNode(c))break;c=a}c.remove()}else b=G(),this.insertAfter(b);return b}collapseAtStart(b){const a=k.$createParagraphNode();this.getChildren().forEach(g=>a.append(g));var c=this.getParentOrThrow(),d=c.getParentOrThrow();const e=F(d);1===
c.getChildrenSize()?e?(c.remove(),d.select()):(c.replace(a),c=b.anchor,b=b.focus,d=a.getKey(),"element"===c.type&&c.getNode().is(this)&&c.set(d,c.offset,"element"),"element"===b.type&&b.getNode().is(this)&&b.set(d,b.offset,"element")):(c.insertBefore(a),this.remove());return!0}getIndent(){let b=this.getParentOrThrow().getParentOrThrow(),a=0;for(;F(b);)b=b.getParentOrThrow().getParentOrThrow(),a++;return a}setIndent(b){let a=this.getIndent();for(;a!==b;)a<b?(w([this]),a++):(x([this]),a--);return this}insertBefore(b){const a=
this.getNextSiblings();F(b)&&a.forEach(c=>c.markDirty());return super.insertBefore(b)}canInsertAfter(b){return F(b)}canReplaceWith(b){return F(b)}canMergeWith(b){return k.$isParagraphNode(b)||F(b)}}function C(b){var a=b.getParent();let c=1;null!=a&&(f.$isListNode(a)?c=a.__start:p(47));b=b.getPreviousSiblings();for(a=0;a<b.length;a++){const d=b[a];F(d)&&!f.$isListNode(d.getFirstChild())&&c++}return c}
function D(b,a,c){const d=[],e=[],g=(a=a.list)?a.listitem:void 0;if(a&&a.nested)var h=a.nested.listitem;void 0!==g&&(a=g.split(" "),d.push(...a));void 0!==h&&(h=h.split(" "),c.getChildren().some(l=>f.$isListNode(l))?d.push(...h):e.push(...h));0<d.length&&z(b,...d);0<e.length&&A(b,...e)}function E(){return{node:G()}}function G(){return new B}function F(b){return b instanceof B}
class H extends k.ElementNode{static getType(){return"list"}static clone(b){return new H(b.__tag,b.__start,b.__key)}constructor(b,a,c){super(c);this.__tag=b;this.__start=a}getTag(){return this.__tag}createDOM(b){const a=document.createElement(this.__tag);1!==this.__start&&a.setAttribute("start",String(this.__start));I(a,b.theme,this);return a}updateDOM(b,a,c){if(b.__tag!==this.__tag)return!0;I(a,c.theme,this);return!1}static convertDOM(){return{ol:()=>({conversion:J,priority:0}),ul:()=>({conversion:J,
priority:0})}}canBeEmpty(){return!1}append(...b){for(let c=0;c<b.length;c++){var a=b[c];if(f.$isListItemNode(a))super.append(a);else{const d=f.$createListItemNode();K(a)?d.append(a):(a=k.$createTextNode(a.getTextContent()),d.append(a));super.append(d)}}return this}}
function I(b,a,c){const d=[],e=[];a=a.list;if(void 0!==a){a:{var g=1;for(var h=c.getParent();null!=h;){if(f.$isListItemNode(h)){h=h.getParent();if(f.$isListNode(h)){g++;h=h.getParent();continue}p(2)}break a}}h=g%5;const l=a[c.__tag+(0===h?5:h)],m=a[c.__tag];let q;a=a.nested;void 0!==a&&a.list&&(q=a.list);void 0!==m&&d.push(m);if(void 0!==l)for(a=l.split(" "),d.push(...a),a=1;6>a;a++)a!==h&&e.push(c.__tag+a);void 0!==q&&(c=q.split(" "),1<g?d.push(...c):e.push(...c))}0<d.length&&z(b,...d);0<e.length&&
A(b,...e)}function J(b){b=b.nodeName.toLowerCase();let a=null;if("ol"===b||"ul"===b)a=L(b);return{node:a}}function L(b,a=1){return new H(b,a)}function K(b){return b instanceof H}exports.$createListItemNode=G;exports.$createListNode=L;exports.$isListItemNode=F;exports.$isListNode=K;exports.ListItemNode=B;exports.ListNode=H;exports.indentList=function(){return y("indent")};
exports.insertList=function(b,a){b.update(()=>{var c=k.$getSelection();if(k.$isRangeSelection(c)){var d=c.getNodes();c=c.anchor.getNode();var e=c.getParent();if(0===d.length)d=f.$createListNode(a),k.$isRootNode(e)?(c.replace(d),c=f.$createListItemNode(),d.append(c)):f.$isListItemNode(c)&&(c=c.getParentOrThrow(),d.append(...c.getChildren()),c.replace(d));else for(c=new Set,e=0;e<d.length;e++){var g=d[e];if(k.$isElementNode(g)&&g.isEmpty()&&!c.has(g.getKey()))v(g,a);else if(k.$isLeafNode(g))for(g=g.getParent();null!=
g;){const l=g.getKey();if(f.$isListNode(g)){if(!c.has(l)){var h=f.$createListNode(a);h.append(...g.getChildren());g.replace(h);c.add(l)}break}else{h=g.getParent();if(k.$isRootNode(h)&&!c.has(l)){c.add(l);v(g,a);break}g=h}}}}})};exports.outdentList=function(){return y("outdent")};
exports.removeList=function(b){b.update(()=>{var a=k.$getSelection();if(k.$isRangeSelection(a)){const d=new Set,e=a.getNodes();a=a.anchor.getNode();if(0===e.length&&f.$isListItemNode(a))d.add(r(a));else for(a=0;a<e.length;a++){var c=e[a];k.$isLeafNode(c)&&(c=n(c,f.ListItemNode),null!=c&&d.add(r(c)))}d.forEach(g=>{let h=g;t(g).forEach(l=>{if(null!=l){const m=k.$createParagraphNode();m.append(...l.getChildren());h.insertAfter(m);h=m;l.remove()}});g.remove()})}})};
function z(b){var a=k.$getSelection();if(!k.$isRangeSelection(a))return!1;var c=a.getNodes(),d=[];0===c.length&&c.push(a.anchor.getNode());if(1===c.length){a:{for(c=c[0];null!==c;){if(f.$isListItemNode(c))break a;c=c.getParent()}c=null}null!==c&&(d=[c])}else{d=new Set;for(a=0;a<c.length;a++){const e=c[a];f.$isListItemNode(e)&&d.add(e)}d=Array.from(d)}return 0<d.length?("indent"===b?x(d):y(d),!0):!1}function A(b,...a){a.forEach(c=>{null!=c&&"string"===typeof c&&b.classList.add(...c.split(" "))})}
function B(b,...a){a.forEach(c=>{b.classList.remove(...c.split(" "))})}
class C extends k.ElementNode{static getType(){return"listitem"}static clone(b){return new C(b.__key)}constructor(b){super(b)}createDOM(b){const a=document.createElement("li");a.value=D(this);E(a,b.theme,this);return a}updateDOM(b,a,c){a.value=D(this);E(a,c.theme,this);return!1}static convertDOM(){return{li:()=>({conversion:F,priority:0})}}append(...b){for(let a=0;a<b.length;a++){const c=b[a];if(k.$isElementNode(c)&&this.canMergeWith(c)){const d=c.getChildren();this.append(...d);c.remove()}else super.append(c)}return this}replace(b){if(G(b))return super.replace(b);
const a=this.getParentOrThrow();if(f.$isListNode(a)){var c=a.__children;const e=c.length;var d=c.indexOf(this.__key);if(0===d)a.insertBefore(b);else if(d===e-1)a.insertAfter(b);else{c=f.$createListNode(a.__tag);const g=a.getChildren();for(d+=1;d<e;d++)c.append(g[d]);a.insertAfter(b);b.insertAfter(c)}this.remove();1===e&&a.remove()}return b}insertAfter(b){var a=this.getNextSiblings();if(G(b))return a.forEach(d=>d.markDirty()),super.insertAfter(b);var c=this.getParentOrThrow();f.$isListNode(c)||n(1);
if(f.$isListNode(b)&&b.getTag()===c.getTag()){a=b;b=b.getChildren();for(c=b.length-1;0<=c;c--)a=b[c],this.insertAfter(a);return a}c.insertAfter(b);if(0!==a.length){const d=f.$createListNode(c.getTag());a.forEach(e=>d.append(e));b.insertAfter(d)}return b}insertNewAfter(){const b=H();this.insertAfter(b);return b}collapseAtStart(b){const a=k.$createParagraphNode();this.getChildren().forEach(g=>a.append(g));var c=this.getParentOrThrow(),d=c.getParentOrThrow();const e=G(d);1===c.getChildrenSize()?e?(c.remove(),
d.select()):(c.replace(a),c=b.anchor,b=b.focus,d=a.getKey(),"element"===c.type&&c.getNode().is(this)&&c.set(d,c.offset,"element"),"element"===b.type&&b.getNode().is(this)&&b.set(d,b.offset,"element")):(c.insertBefore(a),this.remove());return!0}getIndent(){let b=this.getParentOrThrow().getParentOrThrow(),a=0;for(;G(b);)b=b.getParentOrThrow().getParentOrThrow(),a++;return a}setIndent(b){let a=this.getIndent();for(;a!==b;)a<b?(x([this]),a++):(y([this]),a--);return this}insertBefore(b){const a=this.getNextSiblings();
G(b)&&a.forEach(c=>c.markDirty());return super.insertBefore(b)}canInsertAfter(b){return G(b)}canReplaceWith(b){return G(b)}canMergeWith(b){return k.$isParagraphNode(b)||G(b)}}function D(b){var a=b.getParent();let c=1;null!=a&&(f.$isListNode(a)?c=a.__start:n(47));b=b.getPreviousSiblings();for(a=0;a<b.length;a++){const d=b[a];G(d)&&!f.$isListNode(d.getFirstChild())&&c++}return c}
function E(b,a,c){const d=[],e=[],g=(a=a.list)?a.listitem:void 0;if(a&&a.nested)var h=a.nested.listitem;void 0!==g&&(a=g.split(" "),d.push(...a));void 0!==h&&(h=h.split(" "),c.getChildren().some(l=>f.$isListNode(l))?d.push(...h):e.push(...h));0<d.length&&A(b,...d);0<e.length&&B(b,...e)}function F(){return{node:H()}}function H(){return new C}function G(b){return b instanceof C}
class I extends k.ElementNode{static getType(){return"list"}static clone(b){return new I(b.__tag,b.__start,b.__key)}constructor(b,a,c){super(c);this.__tag=b;this.__start=a}getTag(){return this.__tag}createDOM(b){const a=document.createElement(this.__tag);1!==this.__start&&a.setAttribute("start",String(this.__start));J(a,b.theme,this);return a}updateDOM(b,a,c){if(b.__tag!==this.__tag)return!0;J(a,c.theme,this);return!1}static convertDOM(){return{ol:()=>({conversion:K,priority:0}),ul:()=>({conversion:K,
priority:0})}}canBeEmpty(){return!1}append(...b){for(let c=0;c<b.length;c++){var a=b[c];if(f.$isListItemNode(a))super.append(a);else{const d=f.$createListItemNode();L(a)?d.append(a):(a=k.$createTextNode(a.getTextContent()),d.append(a));super.append(d)}}return this}}
function J(b,a,c){const d=[],e=[];a=a.list;if(void 0!==a){a:{var g=1;for(var h=c.getParent();null!=h;){if(f.$isListItemNode(h)){h=h.getParent();if(f.$isListNode(h)){g++;h=h.getParent();continue}n(2)}break a}}h=g%5;const l=a[c.__tag+(0===h?5:h)],m=a[c.__tag];let r;a=a.nested;void 0!==a&&a.list&&(r=a.list);void 0!==m&&d.push(m);if(void 0!==l)for(a=l.split(" "),d.push(...a),a=1;6>a;a++)a!==h&&e.push(c.__tag+a);void 0!==r&&(c=r.split(" "),1<g?d.push(...c):e.push(...c))}0<d.length&&A(b,...d);0<e.length&&
B(b,...e)}function K(b){b=b.nodeName.toLowerCase();let a=null;if("ol"===b||"ul"===b)a=M(b);return{node:a}}function M(b,a=1){return new I(b,a)}function L(b){return b instanceof I}exports.$createListItemNode=H;exports.$createListNode=M;
exports.$handleListInsertParagraph=function(){var b=k.$getSelection();if(null===b||!b.isCollapsed())return!1;b=b.anchor.getNode();if(!f.$isListItemNode(b)||""!==b.getTextContent())return!1;var a=q(b),c=b.getParent();f.$isListNode(c)||n(2);const d=c.getParent();let e;if(k.$isRootNode(d))e=k.$createParagraphNode(),a.insertAfter(e);else if(f.$isListItemNode(d))e=f.$createListItemNode(),d.insertAfter(e);else return!1;e.select();a=b.getNextSiblings();if(0<a.length){const g=f.$createListNode(c.getTag());
k.$isParagraphNode(e)?e.insertAfter(g):(c=f.$createListItemNode(),c.append(g),e.insertAfter(c));a.forEach(h=>{h.remove();g.append(h)})}v(b);return!0};exports.$isListItemNode=G;exports.$isListNode=L;exports.ListItemNode=C;exports.ListNode=I;exports.indentList=function(){return z("indent")};
exports.insertList=function(b,a){b.update(()=>{var c=k.$getSelection();if(k.$isRangeSelection(c)){var d=c.getNodes();c=c.anchor.getNode();var e=c.getParent();if(0===d.length)d=f.$createListNode(a),k.$isRootNode(e)?(c.replace(d),c=f.$createListItemNode(),d.append(c)):f.$isListItemNode(c)&&(c=c.getParentOrThrow(),d.append(...c.getChildren()),c.replace(d));else for(c=new Set,e=0;e<d.length;e++){var g=d[e];if(k.$isElementNode(g)&&g.isEmpty()&&!c.has(g.getKey()))w(g,a);else if(k.$isLeafNode(g))for(g=g.getParent();null!=
g;){const l=g.getKey();if(f.$isListNode(g)){if(!c.has(l)){var h=f.$createListNode(a);h.append(...g.getChildren());g.replace(h);c.add(l)}break}else{h=g.getParent();if(k.$isRootNode(h)&&!c.has(l)){c.add(l);w(g,a);break}g=h}}}}})};exports.outdentList=function(){return z("outdent")};
exports.removeList=function(b){b.update(()=>{var a=k.$getSelection();if(k.$isRangeSelection(a)){const d=new Set,e=a.getNodes();a=a.anchor.getNode();if(0===e.length&&f.$isListItemNode(a))d.add(q(a));else for(a=0;a<e.length;a++){var c=e[a];k.$isLeafNode(c)&&(c=p(c,f.ListItemNode),null!=c&&d.add(q(c)))}d.forEach(g=>{let h=g;t(g).forEach(l=>{if(null!=l){const m=k.$createParagraphNode();m.append(...l.getChildren());h.insertAfter(m);h=m;l.remove()}});g.remove()})}})};

@@ -15,6 +15,6 @@ {

"license": "MIT",
"version": "0.1.10",
"version": "0.1.11",
"main": "LexicalList.js",
"peerDependencies": {
"lexical": "0.1.10"
"lexical": "0.1.11"
},

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