@lexical/list
Advanced tools
Comparing version 0.17.1-nightly.20240802.0 to 0.17.1-nightly.20240805.0
@@ -348,3 +348,3 @@ /** | ||
} | ||
if (isNotChecklist && child.getChecked() != null) { | ||
if (isNotChecklist && child.getLatest().__checked != null) { | ||
child.setChecked(undefined); | ||
@@ -790,3 +790,8 @@ } | ||
const self = this.getLatest(); | ||
return self.__checked; | ||
let listType; | ||
const parent = this.getParent(); | ||
if ($isListNode(parent)) { | ||
listType = parent.getListType(); | ||
} | ||
return listType === 'check' ? Boolean(self.__checked) : undefined; | ||
} | ||
@@ -858,2 +863,5 @@ setChecked(checked) { | ||
} | ||
canMergeWhenEmpty() { | ||
return true; | ||
} | ||
} | ||
@@ -860,0 +868,0 @@ function $setListItemThemeClassNames(dom, editorThemeClasses, node) { |
@@ -21,5 +21,6 @@ /** | ||
b&&c&&v(b)&&v(c)&&(F(b.getFirstChild(),c.getFirstChild()),c.remove())}insertNewAfter(a,b=!0){a=y(null==this.__checked?void 0:!1);this.insertAfter(a,b);return a}collapseAtStart(a){let b=g.$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(){return this.getLatest().__checked}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&&-1<a||l(117);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(),A(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=y();let k=E(d.getListType());c.append(k);k.append(this);f?f.insertAfter(c):e?e.insertBefore(c):d.append(c)}}b++}else G(this),b--;return this}canInsertAfter(a){return q(a)}canReplaceWith(a){return q(a)}canMergeWith(a){return g.$isParagraphNode(a)||q(a)}extractWithChild(a,b){if(!g.$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 E("bullet")}} | ||
"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&&-1<a||l(117);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(),A(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=y();let k=E(d.getListType());c.append(k);k.append(this);f?f.insertAfter(c):e?e.insertBefore(c):d.append(c)}}b++}else G(this),b--;return this}canInsertAfter(a){return q(a)}canReplaceWith(a){return q(a)}canMergeWith(a){return g.$isParagraphNode(a)||q(a)}extractWithChild(a,b){if(!g.$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 E("bullet")}canMergeWhenEmpty(){return!0}} | ||
function K(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(...H(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=H(k),c.getChildren().some(m=>r(m))?d.push(...k):e.push(...k));0<e.length&&h.removeClassNamesFromElement(a,...e);0<d.length&&h.addClassNamesToElement(a,...d)} | ||
@@ -29,5 +30,5 @@ function J(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"))} | ||
class M extends g.ElementNode{static getType(){return"list"}static clone(a){return new M(a.__listType||P[a.__tag],a.__start,a.__key)}constructor(a,b,c){super(c);this.__listType=a=P[a]||a;this.__tag="number"===a?"ol":"ul";this.__start=b}getTag(){return this.__tag}setListType(a){let b=this.getWritable();b.__listType=a;b.__tag="number"===a?"ol":"ul"}getListType(){return this.__listType}getStart(){return this.__start}createDOM(a){let b=document.createElement(this.__tag);1!==this.__start&&b.setAttribute("start", | ||
String(this.__start));b.__lexicalListType=this.__listType;Q(b,a.theme,this);return b}updateDOM(a,b,c){if(a.__tag!==this.__tag)return!0;Q(b,c.theme,this);return!1}static transform(){return a=>{r(a)||l(163);var b=a.getNextSibling();r(b)&&a.getListType()===b.getListType()&&F(a,b);b="check"!==a.getListType();let c=a.getStart();for(let d of a.getChildren())q(d)&&(d.getValue()!==c&&d.setValue(c),b&&null!=d.getChecked()&&d.setChecked(void 0),r(d.getFirstChild())||c++)}}static importDOM(){return{ol:()=>({conversion:R, | ||
priority:0}),ul:()=>({conversion:R,priority:0})}}static importJSON(a){let b=E(a.listType,a.start);b.setFormat(a.format);b.setIndent(a.indent);b.setDirection(a.direction);return b}exportDOM(a){({element:a}=super.exportDOM(a));a&&h.isHTMLElement(a)&&(1!==this.__start&&a.setAttribute("start",String(this.__start)),"check"===this.__listType&&a.setAttribute("__lexicalListType","check"));return{element:a}}exportJSON(){return{...super.exportJSON(),listType:this.getListType(),start:this.getStart(),tag:this.getTag(), | ||
type:"list",version:1}}canBeEmpty(){return!1}canIndent(){return!1}append(...a){for(let c=0;c<a.length;c++){var b=a[c];if(q(b))super.append(b);else{let d=y();r(b)?d.append(b):g.$isElementNode(b)?(b=g.$createTextNode(b.getTextContent()),d.append(b)):d.append(b);super.append(d)}}return this}extractWithChild(a){return q(a)}} | ||
String(this.__start));b.__lexicalListType=this.__listType;Q(b,a.theme,this);return b}updateDOM(a,b,c){if(a.__tag!==this.__tag)return!0;Q(b,c.theme,this);return!1}static transform(){return a=>{r(a)||l(163);var b=a.getNextSibling();r(b)&&a.getListType()===b.getListType()&&F(a,b);b="check"!==a.getListType();let c=a.getStart();for(let d of a.getChildren())q(d)&&(d.getValue()!==c&&d.setValue(c),b&&null!=d.getLatest().__checked&&d.setChecked(void 0),r(d.getFirstChild())||c++)}}static importDOM(){return{ol:()=> | ||
({conversion:R,priority:0}),ul:()=>({conversion:R,priority:0})}}static importJSON(a){let b=E(a.listType,a.start);b.setFormat(a.format);b.setIndent(a.indent);b.setDirection(a.direction);return b}exportDOM(a){({element:a}=super.exportDOM(a));a&&h.isHTMLElement(a)&&(1!==this.__start&&a.setAttribute("start",String(this.__start)),"check"===this.__listType&&a.setAttribute("__lexicalListType","check"));return{element:a}}exportJSON(){return{...super.exportJSON(),listType:this.getListType(),start:this.getStart(), | ||
tag:this.getTag(),type:"list",version:1}}canBeEmpty(){return!1}canIndent(){return!1}append(...a){for(let c=0;c<a.length;c++){var b=a[c];if(q(b))super.append(b);else{let d=y();r(b)?d.append(b):g.$isElementNode(b)?(b=g.$createTextNode(b.getTextContent()),d.append(b)):d.append(b);super.append(d)}}return this}extractWithChild(a){return q(a)}} | ||
function Q(a,b,c){let d=[],e=[];var f=b.list;if(void 0!==f){let m=f[`${c.__tag}Depth`]||[];b=p(c)-1;let N=b%m.length;var k=m[N];let O=f[c.__tag],B,C=f.nested;f=f.checklist;void 0!==C&&C.list&&(B=C.list);void 0!==O&&d.push(O);void 0!==f&&"check"===c.__listType&&d.push(f);if(void 0!==k)for(d.push(...H(k)),k=0;k<m.length;k++)k!==N&&e.push(c.__tag+k);void 0!==B&&(c=H(B),1<b?d.push(...c):e.push(...c))}0<e.length&&h.removeClassNamesFromElement(a,...e);0<d.length&&h.addClassNamesToElement(a,...d)} | ||
@@ -34,0 +35,0 @@ function S(a){let b=[];for(let d=0;d<a.length;d++){var c=a[d];q(c)?(b.push(c),c=c.getChildren(),1<c.length&&c.forEach(e=>{r(e)&&b.push(x(e))})):b.push(x(c))}return b} |
@@ -51,2 +51,3 @@ /** | ||
createParentElementNode(): ElementNode; | ||
canMergeWhenEmpty(): true; | ||
} | ||
@@ -53,0 +54,0 @@ /** |
@@ -11,8 +11,8 @@ { | ||
"license": "MIT", | ||
"version": "0.17.1-nightly.20240802.0", | ||
"version": "0.17.1-nightly.20240805.0", | ||
"main": "LexicalList.js", | ||
"types": "index.d.ts", | ||
"dependencies": { | ||
"@lexical/utils": "0.17.1-nightly.20240802.0", | ||
"lexical": "0.17.1-nightly.20240802.0" | ||
"@lexical/utils": "0.17.1-nightly.20240805.0", | ||
"lexical": "0.17.1-nightly.20240805.0" | ||
}, | ||
@@ -19,0 +19,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
136807
2879
+ Added@lexical/selection@0.17.1-nightly.20240805.0(transitive)
+ Added@lexical/table@0.17.1-nightly.20240805.0(transitive)
+ Added@lexical/utils@0.17.1-nightly.20240805.0(transitive)
+ Addedlexical@0.17.1-nightly.20240805.0(transitive)
- Removed@lexical/selection@0.17.1-nightly.20240802.0(transitive)
- Removed@lexical/table@0.17.1-nightly.20240802.0(transitive)
- Removed@lexical/utils@0.17.1-nightly.20240802.0(transitive)
- Removedlexical@0.17.1-nightly.20240802.0(transitive)