New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@lexical/list

Package Overview
Dependencies
Maintainers
5
Versions
297
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.21.1-nightly.20241212.0 to 0.21.1-nightly.20241213.0

51

LexicalList.dev.js

@@ -504,3 +504,2 @@ /**

// Only run this code on empty list items
const anchor = selection.anchor.getNode();

@@ -541,2 +540,3 @@ if (!$isListItemNode(anchor) || anchor.getChildrenSize() !== 0) {

}
// Don't leave hanging nested empty lists

@@ -576,3 +576,3 @@ $removeHighestEmptyListParent(anchor);

/** @noInheritDoc */
class ListItemNode extends lexical.ParagraphNode {
class ListItemNode extends lexical.ElementNode {
/** @internal */

@@ -604,5 +604,2 @@

updateDOM(prevNode, dom, config) {
if (super.updateDOM(prevNode, dom, config)) {
return true;
}
const parent = this.getParent();

@@ -647,8 +644,2 @@ if ($isListNode(parent) && parent.getListType() === 'check') {

node.setDirection(serializedNode.direction);
if (typeof serializedNode.textFormat === 'number') {
node.setTextFormat(serializedNode.textFormat);
}
if (typeof serializedNode.textStyle === 'string') {
node.setTextStyle(serializedNode.textStyle);
}
return node;

@@ -735,2 +726,4 @@ }

const siblings = this.getNextSiblings();
// Split the lists and insert the node in between them
listNode.insertAfter(node, restoreSelection);

@@ -753,15 +746,8 @@ if (siblings.length !== 0) {

}
insertNewAfter(selection, restoreSelection = true) {
insertNewAfter(_, restoreSelection = true) {
const newElement = $createListItemNode(this.__checked == null ? undefined : false);
const format = selection.format;
newElement.setTextFormat(format);
newElement.setFormat(this.getFormatType());
this.insertAfter(newElement, restoreSelection);
return newElement;
}
collapseAtStart() {
const selection = lexical.$getSelection();
if (!lexical.$isRangeSelection(selection)) {
return false;
}
collapseAtStart(selection) {
const paragraph = lexical.$createParagraphNode();

@@ -771,8 +757,8 @@ const children = this.getChildren();

const listNode = this.getParentOrThrow();
const listNodeParent = listNode.getParent();
if (!$isListNode(listNode)) {
return false;
}
const listNodeParent = listNode.getParentOrThrow();
const isIndented = $isListItemNode(listNodeParent);
if (listNode.getChildrenSize() === 1) {
if ($isListItemNode(listNodeParent)) {
if (isIndented) {
// if the list node is nested, we just want to remove it,
// effectively unindenting it.
listNode.remove();

@@ -783,4 +769,17 @@ listNodeParent.select();

listNode.remove();
paragraph.select();
// If we have selection on the list item, we'll need to move it
// to the paragraph
const anchor = selection.anchor;
const focus = selection.focus;
const key = paragraph.getKey();
if (anchor.type === 'element' && anchor.getNode().is(this)) {
anchor.set(key, anchor.offset, 'element');
}
if (focus.type === 'element' && focus.getNode().is(this)) {
focus.set(key, focus.offset, 'element');
}
}
} else {
listNode.insertBefore(paragraph);
this.remove();
}

@@ -787,0 +786,0 @@ return true;

@@ -21,11 +21,11 @@ /**

f.insertAfter(d),d.append(...a));for(;null==b.getNextSibling()&&null==b.getPreviousSibling();){f=b.getParent();if(null==f||!q(b)&&!r(b))break;b=f}b.remove();return!0}function K(...a){let b=[];for(let c of a)if(c&&"string"===typeof c)for(let [d]of c.matchAll(/\S+/g))b.push(d);return b}
class H extends h.ParagraphNode{static getType(){return"listitem"}static clone(a){return new H(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();r(c)&&"check"===c.getListType()&&L(b,this,null);b.value=this.__value;M(b,a.theme,this);return b}updateDOM(a,b,c){if(super.updateDOM(a,b,c))return!0;let d=this.getParent();r(d)&&"check"===d.getListType()&&L(b,this,a);b.value=this.__value;
M(b,c.theme,this);return!1}static transform(){return a=>{q(a)||l(144);if(null!=a.__checked){var b=a.getParent();r(b)&&"check"!==b.getListType()&&null!=a.getChecked()&&a.setChecked(void 0)}}}static importDOM(){return{li:()=>({conversion:N,priority:0})}}static importJSON(a){let b=x();b.setChecked(a.checked);b.setValue(a.value);b.setFormat(a.format);b.setDirection(a.direction);"number"===typeof a.textFormat&&b.setTextFormat(a.textFormat);"string"===typeof a.textStyle&&b.setTextStyle(a.textStyle);return b}exportDOM(a){a=
this.createDOM(a._config);a.style.textAlign=this.getFormatType();return{element:a}}exportJSON(){return{...super.exportJSON(),checked:this.getChecked(),type:"listitem",value:this.getValue(),version:1}}append(...a){for(let b=0;b<a.length;b++){let c=a[b];if(h.$isElementNode(c)&&this.canMergeWith(c)){let d=c.getChildren();this.append(...d);c.remove()}else super.append(c)}return this}replace(a,b){if(q(a))return super.replace(a);this.setIndent(0);let c=this.getParentOrThrow();if(!r(c))return a;if(c.__first===
this.getKey())c.insertBefore(a);else if(c.__last===this.getKey())c.insertAfter(a);else{let d=A(c.getListType()),e=this.getNextSibling();for(;e;){let f=e;e=e.getNextSibling();d.append(f)}c.insertAfter(a);a.insertAfter(d)}b&&(h.$isElementNode(a)||l(139),this.getChildren().forEach(d=>{a.append(d)}));this.remove();0===c.getChildrenSize()&&c.remove();return a}insertAfter(a,b=!0){let c=this.getParentOrThrow();r(c)||l(39);if(q(a))return super.insertAfter(a,b);let d=this.getNextSiblings();c.insertAfter(a,
b);if(0!==d.length){let e=A(c.getListType());d.forEach(f=>e.append(f));a.insertAfter(e,b)}return a}remove(a){let b=this.getPreviousSibling(),c=this.getNextSibling();super.remove(a);b&&c&&v(b)&&v(c)&&(F(b.getFirstChild(),c.getFirstChild()),c.remove())}insertNewAfter(a,b=!0){let c=x(null==this.__checked?void 0:!1);c.setTextFormat(a.format);c.setFormat(this.getFormatType());this.insertAfter(c,b);return c}collapseAtStart(){var a=h.$getSelection();if(!h.$isRangeSelection(a))return!1;let b=h.$createParagraphNode();
this.getChildren().forEach(d=>b.append(d));a=this.getParentOrThrow();let c=a.getParent();if(!r(a))return!1;1===a.getChildrenSize()&&(q(c)?(a.remove(),c.select()):(a.insertBefore(b),a.remove(),b.select()));return!0}getValue(){return this.getLatest().__value}setValue(a){this.getWritable().__value=a}getChecked(){let a=this.getLatest(),b,c=this.getParent();r(c)&&(b=c.getListType());return"check"===b?!!a.__checked:void 0}setChecked(a){this.getWritable().__checked=a}toggleChecked(){this.setChecked(!this.__checked)}getIndent(){var a=
this.getParent();if(null===a)return this.getLatest().__indent;a=a.getParentOrThrow();let b=0;for(;q(a);)a=a.getParentOrThrow().getParentOrThrow(),b++;return b}setIndent(a){"number"!==typeof a&&l(117);a=Math.floor(a);0<=a||l(199);let b=this.getIndent();for(;b!==a;)if(b<a){var c=new Set;if(!v(this)&&!c.has(this.getKey())){var d=this.getParent(),e=this.getNextSibling(),f=this.getPreviousSibling();if(v(e)&&v(f))d=f.getFirstChild(),r(d)&&(d.append(this),f=e.getFirstChild(),r(f)&&(f=f.getChildren(),B(d,
f),e.remove(),c.add(e.getKey())));else if(v(e))e=e.getFirstChild(),r(e)&&(e=e.getFirstChild(),null!==e&&e.insertBefore(this));else if(v(f))e=f.getFirstChild(),r(e)&&e.append(this);else if(r(d)){c=x();let k=A(d.getListType());c.append(k);k.append(this);f?f.insertAfter(c):e?e.insertBefore(c):d.append(c)}}b++}else I(this),b--;return this}canInsertAfter(a){return q(a)}canReplaceWith(a){return q(a)}canMergeWith(a){return q(a)||h.$isParagraphNode(a)}extractWithChild(a,b){if(!h.$isRangeSelection(b))return!1;
a=b.anchor.getNode();let c=b.focus.getNode();return this.isParentOf(a)&&this.isParentOf(c)&&this.getTextContent().length===b.getTextContent().length}isParentRequired(){return!0}createParentElementNode(){return A("bullet")}canMergeWhenEmpty(){return!0}}
class H extends h.ElementNode{static getType(){return"listitem"}static clone(a){return new H(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();r(c)&&"check"===c.getListType()&&L(b,this,null);b.value=this.__value;M(b,a.theme,this);return b}updateDOM(a,b,c){let d=this.getParent();r(d)&&"check"===d.getListType()&&L(b,this,a);b.value=this.__value;M(b,c.theme,this);return!1}static transform(){return a=>
{q(a)||l(144);if(null!=a.__checked){var b=a.getParent();r(b)&&"check"!==b.getListType()&&null!=a.getChecked()&&a.setChecked(void 0)}}}static importDOM(){return{li:()=>({conversion:N,priority:0})}}static importJSON(a){let b=x();b.setChecked(a.checked);b.setValue(a.value);b.setFormat(a.format);b.setDirection(a.direction);return b}exportDOM(a){a=this.createDOM(a._config);a.style.textAlign=this.getFormatType();return{element:a}}exportJSON(){return{...super.exportJSON(),checked:this.getChecked(),type:"listitem",
value:this.getValue(),version:1}}append(...a){for(let b=0;b<a.length;b++){let c=a[b];if(h.$isElementNode(c)&&this.canMergeWith(c)){let d=c.getChildren();this.append(...d);c.remove()}else super.append(c)}return this}replace(a,b){if(q(a))return super.replace(a);this.setIndent(0);let c=this.getParentOrThrow();if(!r(c))return a;if(c.__first===this.getKey())c.insertBefore(a);else if(c.__last===this.getKey())c.insertAfter(a);else{let d=A(c.getListType()),e=this.getNextSibling();for(;e;){let f=e;e=e.getNextSibling();
d.append(f)}c.insertAfter(a);a.insertAfter(d)}b&&(h.$isElementNode(a)||l(139),this.getChildren().forEach(d=>{a.append(d)}));this.remove();0===c.getChildrenSize()&&c.remove();return a}insertAfter(a,b=!0){let c=this.getParentOrThrow();r(c)||l(39);if(q(a))return super.insertAfter(a,b);let d=this.getNextSiblings();c.insertAfter(a,b);if(0!==d.length){let e=A(c.getListType());d.forEach(f=>e.append(f));a.insertAfter(e,b)}return a}remove(a){let b=this.getPreviousSibling(),c=this.getNextSibling();super.remove(a);
b&&c&&v(b)&&v(c)&&(F(b.getFirstChild(),c.getFirstChild()),c.remove())}insertNewAfter(a,b=!0){a=x(null==this.__checked?void 0:!1);this.insertAfter(a,b);return a}collapseAtStart(a){let b=h.$createParagraphNode();this.getChildren().forEach(f=>b.append(f));var c=this.getParentOrThrow(),d=c.getParentOrThrow();let e=q(d);1===c.getChildrenSize()?e?(c.remove(),d.select()):(c.insertBefore(b),c.remove(),c=a.anchor,a=a.focus,d=b.getKey(),"element"===c.type&&c.getNode().is(this)&&c.set(d,c.offset,"element"),
"element"===a.type&&a.getNode().is(this)&&a.set(d,a.offset,"element")):(c.insertBefore(b),this.remove());return!0}getValue(){return this.getLatest().__value}setValue(a){this.getWritable().__value=a}getChecked(){let a=this.getLatest(),b,c=this.getParent();r(c)&&(b=c.getListType());return"check"===b?!!a.__checked:void 0}setChecked(a){this.getWritable().__checked=a}toggleChecked(){this.setChecked(!this.__checked)}getIndent(){var a=this.getParent();if(null===a)return this.getLatest().__indent;a=a.getParentOrThrow();
let b=0;for(;q(a);)a=a.getParentOrThrow().getParentOrThrow(),b++;return b}setIndent(a){"number"!==typeof a&&l(117);a=Math.floor(a);0<=a||l(199);let b=this.getIndent();for(;b!==a;)if(b<a){var c=new Set;if(!v(this)&&!c.has(this.getKey())){var d=this.getParent(),e=this.getNextSibling(),f=this.getPreviousSibling();if(v(e)&&v(f))d=f.getFirstChild(),r(d)&&(d.append(this),f=e.getFirstChild(),r(f)&&(f=f.getChildren(),B(d,f),e.remove(),c.add(e.getKey())));else if(v(e))e=e.getFirstChild(),r(e)&&(e=e.getFirstChild(),
null!==e&&e.insertBefore(this));else if(v(f))e=f.getFirstChild(),r(e)&&e.append(this);else if(r(d)){c=x();let k=A(d.getListType());c.append(k);k.append(this);f?f.insertAfter(c):e?e.insertBefore(c):d.append(c)}}b++}else I(this),b--;return this}canInsertAfter(a){return q(a)}canReplaceWith(a){return q(a)}canMergeWith(a){return q(a)||h.$isParagraphNode(a)}extractWithChild(a,b){if(!h.$isRangeSelection(b))return!1;a=b.anchor.getNode();let c=b.focus.getNode();return this.isParentOf(a)&&this.isParentOf(c)&&
this.getTextContent().length===b.getTextContent().length}isParentRequired(){return!0}createParentElementNode(){return A("bullet")}canMergeWhenEmpty(){return!0}}
function M(a,b,c){let d=[],e=[];var f=(b=b.list)?b.listitem:void 0;if(b&&b.nested)var k=b.nested.listitem;void 0!==f&&d.push(...K(f));if(b){f=c.getParent();f=r(f)&&"check"===f.getListType();let m=c.getChecked();f&&!m||e.push(b.listitemUnchecked);f&&m||e.push(b.listitemChecked);f&&d.push(m?b.listitemChecked:b.listitemUnchecked)}void 0!==k&&(k=K(k),c.getChildren().some(m=>r(m))?d.push(...k):e.push(...k));0<e.length&&g.removeClassNamesFromElement(a,...e);0<d.length&&g.addClassNamesToElement(a,...d)}

@@ -32,0 +32,0 @@ function L(a,b,c){r(b.getFirstChild())?(a.removeAttribute("role"),a.removeAttribute("tabIndex"),a.removeAttribute("aria-checked")):(a.setAttribute("role","checkbox"),a.setAttribute("tabIndex","-1"),c&&b.__checked===c.__checked||a.setAttribute("aria-checked",b.getChecked()?"true":"false"))}

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

*/
import { BaseSelection, DOMConversionMap, DOMExportOutput, EditorConfig, ElementNode, LexicalEditor, LexicalNode, NodeKey, ParagraphNode, RangeSelection, SerializedParagraphNode, Spread } from 'lexical';
import type { BaseSelection, DOMConversionMap, DOMExportOutput, EditorConfig, LexicalNode, NodeKey, ParagraphNode, RangeSelection, SerializedElementNode, Spread } from 'lexical';
import { ElementNode, LexicalEditor } from 'lexical';
export type SerializedListItemNode = Spread<{
checked: boolean | undefined;
value: number;
}, SerializedParagraphNode>;
}, SerializedElementNode>;
/** @noInheritDoc */
export declare class ListItemNode extends ParagraphNode {
export declare class ListItemNode extends ElementNode {
/** @internal */

@@ -24,3 +25,3 @@ __value: number;

createDOM(config: EditorConfig): HTMLElement;
updateDOM(prevNode: this, dom: HTMLElement, config: EditorConfig): boolean;
updateDOM(prevNode: ListItemNode, dom: HTMLElement, config: EditorConfig): boolean;
static transform(): (node: LexicalNode) => void;

@@ -35,4 +36,4 @@ static importDOM(): DOMConversionMap | null;

remove(preserveEmptyParent?: boolean): void;
insertNewAfter(selection: RangeSelection, restoreSelection?: boolean): ListItemNode | ParagraphNode;
collapseAtStart(): boolean;
insertNewAfter(_: RangeSelection, restoreSelection?: boolean): ListItemNode | ParagraphNode;
collapseAtStart(selection: RangeSelection): true;
getValue(): number;

@@ -39,0 +40,0 @@ setValue(value: number): void;

@@ -11,8 +11,8 @@ {

"license": "MIT",
"version": "0.21.1-nightly.20241212.0",
"version": "0.21.1-nightly.20241213.0",
"main": "LexicalList.js",
"types": "index.d.ts",
"dependencies": {
"@lexical/utils": "0.21.1-nightly.20241212.0",
"lexical": "0.21.1-nightly.20241212.0"
"@lexical/utils": "0.21.1-nightly.20241213.0",
"lexical": "0.21.1-nightly.20241213.0"
},

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

@@ -8,3 +8,3 @@ /**

*/
import { type LexicalNode, type Spread } from 'lexical';
import type { LexicalNode, Spread } from 'lexical';
import { ListItemNode, ListNode } from './';

@@ -11,0 +11,0 @@ /**

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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