UNPKG

@lexical/list

Version:

This package provides the list feature for Lexical.

10 lines (8 loc) 19.6 kB
/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ "use strict";var e=require("@lexical/utils"),t=require("lexical"),r=require("@lexical/selection");function n(e,...t){const r=new URL("https://lexical.dev/docs/error"),n=new URLSearchParams;n.append("code",e);for(const e of t)n.append("v",e);throw r.search=n.toString(),Error(`Minified Lexical error #${e}; visit ${r.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function s(e){let t=1,r=e.getParent();for(;null!=r;){if(v(r)){const e=r.getParent();if(b(e)){t++,r=e.getParent();continue}n(40)}return t}return t}function i(e){let t=e.getParent();b(t)||n(40);let r=t;for(;null!==r;)r=r.getParent(),b(r)&&(t=r);return t}function o(e){let t=[];const r=e.getChildren().filter(v);for(let e=0;e<r.length;e++){const n=r[e],s=n.getFirstChild();b(s)?t=t.concat(o(s)):t.push(n)}return t}function l(e){return v(e)&&b(e.getFirstChild())}function c(e){return L().append(e)}function a(e,t){return v(e)&&(0===t.length||1===t.length&&e.is(t[0])&&0===e.getChildrenSize())}function g(e){const r=t.$getSelection();if(null!==r){let s=r.getNodes();if(t.$isRangeSelection(r)){const i=r.getStartEndPoints();null===i&&n(143);const[o]=i,l=o.getNode(),c=l.getParent();if(t.$isRootOrShadowRoot(l)){const e=l.getFirstChild();if(e)s=e.selectStart().getNodes();else{const e=t.$createParagraphNode();l.append(e),s=e.select().getNodes()}}else if(a(l,s)){const r=A(e);if(t.$isRootOrShadowRoot(c)){l.replace(r);const e=L();t.$isElementNode(l)&&(e.setFormat(l.getFormatType()),e.setIndent(l.getIndent())),r.append(e)}else if(v(l)){const e=l.getParentOrThrow();u(r,e.getChildren()),e.replace(r)}return}}const i=new Set;for(let r=0;r<s.length;r++){const n=s[r];if(t.$isElementNode(n)&&n.isEmpty()&&!v(n)&&!i.has(n.getKey())){d(n,e);continue}let o=t.$isLeafNode(n)?n.getParent():v(n)&&n.isEmpty()?n:null;for(;null!=o;){const r=o.getKey();if(b(o)){if(!i.has(r)){const t=A(e);u(t,o.getChildren()),o.replace(t),i.add(r)}break}{const n=o.getParent();if(t.$isRootOrShadowRoot(n)&&!i.has(r)){i.add(r),d(o,e);break}o=n}}}}}function u(e,t){e.splice(e.getChildrenSize(),0,t)}function d(e,t){if(b(e))return e;const r=e.getPreviousSibling(),n=e.getNextSibling(),s=L();let i;if(u(s,e.getChildren()),b(r)&&t===r.getListType())r.append(s),b(n)&&t===n.getListType()&&(u(r,n.getChildren()),n.remove()),i=r;else if(b(n)&&t===n.getListType())n.getFirstChildOrThrow().insertBefore(s),i=n;else{const r=A(t);r.append(s),e.replace(r),i=r}return s.setFormat(e.getFormatType()),s.setIndent(e.getIndent()),e.remove(),i}function h(e,t){const r=e.getLastChild(),n=t.getFirstChild();r&&n&&l(r)&&l(n)&&(h(r.getFirstChild(),n.getFirstChild()),n.remove());const s=t.getChildren();s.length>0&&e.append(...s),t.remove()}function f(){const r=t.$getSelection();if(t.$isRangeSelection(r)){const n=new Set,s=r.getNodes(),l=r.anchor.getNode();if(a(l,s))n.add(i(l));else for(let r=0;r<s.length;r++){const o=s[r];if(t.$isLeafNode(o)){const t=e.$getNearestNodeOfType(o,T);null!=t&&n.add(i(t))}}for(const e of n){let n=e;const s=o(e);for(const e of s){const s=t.$createParagraphNode().setTextStyle(r.style).setTextFormat(r.format);u(s,e.getChildren()),n.insertAfter(s),n=s,e.__key===r.anchor.key&&t.$setPointFromCaret(r.anchor,t.$normalizeCaret(t.$getChildCaret(s,"next"))),e.__key===r.focus.key&&t.$setPointFromCaret(r.focus,t.$normalizeCaret(t.$getChildCaret(s,"next"))),e.remove()}e.remove()}}}function p(e){const t=new Set;if(l(e)||t.has(e.getKey()))return;const r=e.getParent(),n=e.getNextSibling(),s=e.getPreviousSibling();if(l(n)&&l(s)){const r=s.getFirstChild();if(b(r)){r.append(e);const s=n.getFirstChild();if(b(s)){u(r,s.getChildren()),n.remove(),t.add(n.getKey())}}}else if(l(n)){const t=n.getFirstChild();if(b(t)){const r=t.getFirstChild();null!==r&&r.insertBefore(e)}}else if(l(s)){const t=s.getFirstChild();b(t)&&t.append(e)}else if(b(r)){const t=L().setTextFormat(r.getTextFormat()).setTextStyle(r.getTextStyle()),i=A(r.getListType()).setTextFormat(r.getTextFormat()).setTextStyle(r.getTextStyle());t.append(i),i.append(e),s?s.insertAfter(t):n?n.insertBefore(t):r.append(t)}}function m(e){if(l(e))return;const t=e.getParent(),r=t?t.getParent():void 0;if(b(r?r.getParent():void 0)&&v(r)&&b(t)){const n=t?t.getFirstChild():void 0,s=t?t.getLastChild():void 0;if(e.is(n))r.insertBefore(e),t.isEmpty()&&r.remove();else if(e.is(s))r.insertAfter(e),t.isEmpty()&&r.remove();else{const n=t.getListType(),s=L(),i=A(n);s.append(i),e.getPreviousSiblings().forEach((e=>i.append(e)));const o=L(),l=A(n);o.append(l),u(l,e.getNextSiblings()),r.insertBefore(s),r.insertAfter(o),r.replace(e)}}}function _(){const e=t.$getSelection();if(!t.$isRangeSelection(e)||!e.isCollapsed())return!1;const r=e.anchor.getNode();if(!v(r)||0!==r.getChildrenSize())return!1;const s=i(r),o=r.getParent();b(o)||n(40);const l=o.getParent();let c;if(t.$isRootOrShadowRoot(l))c=t.$createParagraphNode(),s.insertAfter(c);else{if(!v(l))return!1;c=L(),l.insertAfter(c)}c.setTextStyle(e.style).setTextFormat(e.format).select();const a=r.getNextSiblings();if(a.length>0){const e=A(o.getListType());if(v(c)){const t=L();t.append(e),c.insertAfter(t)}else c.insertAfter(e);e.append(...a)}return function(e){let t=e;for(;null==t.getNextSibling()&&null==t.getPreviousSibling();){const e=t.getParent();if(null==e||!v(e)&&!b(e))break;t=e}t.remove()}(r),!0}function C(...e){const t=[];for(const r of e)if(r&&"string"==typeof r)for(const[e]of r.matchAll(/\S+/g))t.push(e);return t}function N(e,t,n){const s=r.getStyleObjectFromCSS(t.__textStyle);for(const t in s)e.style.setProperty(`--listitem-marker-${t}`,s[t]);if(n)for(const t in r.getStyleObjectFromCSS(n.__textStyle))t in s||e.style.removeProperty(`--listitem-marker-${t}`)}class T extends t.ElementNode{static getType(){return"listitem"}static clone(e){return new T(e.__value,e.__checked,e.__key)}constructor(e,t,r){super(r),this.__value=void 0===e?1:e,this.__checked=t}createDOM(e){const t=document.createElement("li"),r=this.getParent();b(r)&&"check"===r.getListType()&&y(t,this,null),t.value=this.__value,S(t,e.theme,this);const n=this.__style;return n&&(t.style.cssText=n),N(t,this,null),t}updateDOM(e,t,r){const n=this.getParent();b(n)&&"check"===n.getListType()&&y(t,this,e),t.value=this.__value,S(t,r.theme,this);const s=e.__style,i=this.__style;return s!==i&&(""===i?t.removeAttribute("style"):t.style.cssText=i),N(t,this,e),!1}static transform(){return e=>{if(v(e)||n(144),null==e.__checked)return;const t=e.getParent();b(t)&&"check"!==t.getListType()&&null!=e.getChecked()&&e.setChecked(void 0)}}static importDOM(){return{li:()=>({conversion:O,priority:0})}}static importJSON(e){return L().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setValue(e.value).setChecked(e.checked)}exportDOM(e){const t=this.createDOM(e._config);t.style.textAlign=this.getFormatType();const r=this.getDirection();return r&&(t.dir=r),{element:t}}exportJSON(){return{...super.exportJSON(),checked:this.getChecked(),value:this.getValue()}}append(...e){for(let r=0;r<e.length;r++){const n=e[r];if(t.$isElementNode(n)&&this.canMergeWith(n)){const e=n.getChildren();this.append(...e),n.remove()}else super.append(n)}return this}replace(e,r){if(v(e))return super.replace(e);this.setIndent(0);const s=this.getParentOrThrow();if(!b(s))return e;if(s.__first===this.getKey())s.insertBefore(e);else if(s.__last===this.getKey())s.insertAfter(e);else{const t=A(s.getListType());let r=this.getNextSibling();for(;r;){const e=r;r=r.getNextSibling(),t.append(e)}s.insertAfter(e),e.insertAfter(t)}return r&&(t.$isElementNode(e)||n(139),this.getChildren().forEach((t=>{e.append(t)}))),this.remove(),0===s.getChildrenSize()&&s.remove(),e}insertAfter(e,t=!0){const r=this.getParentOrThrow();if(b(r)||n(39),v(e))return super.insertAfter(e,t);const s=this.getNextSiblings();if(r.insertAfter(e,t),0!==s.length){const n=A(r.getListType());s.forEach((e=>n.append(e))),e.insertAfter(n,t)}return e}remove(e){const t=this.getPreviousSibling(),r=this.getNextSibling();super.remove(e),t&&r&&l(t)&&l(r)&&(h(t.getFirstChild(),r.getFirstChild()),r.remove())}insertNewAfter(e,t=!0){const r=L().updateFromJSON(this.exportJSON()).setChecked(!this.getChecked()&&void 0);return this.insertAfter(r,t),r}collapseAtStart(e){const r=t.$createParagraphNode();this.getChildren().forEach((e=>r.append(e)));const n=this.getParentOrThrow(),s=n.getParentOrThrow(),i=v(s);if(1===n.getChildrenSize())if(i)n.remove(),s.select();else{n.insertBefore(r),n.remove();const t=e.anchor,s=e.focus,i=r.getKey();"element"===t.type&&t.getNode().is(this)&&t.set(i,t.offset,"element"),"element"===s.type&&s.getNode().is(this)&&s.set(i,s.offset,"element")}else n.insertBefore(r),this.remove();return!0}getValue(){return this.getLatest().__value}setValue(e){const t=this.getWritable();return t.__value=e,t}getChecked(){const e=this.getLatest();let t;const r=this.getParent();return b(r)&&(t=r.getListType()),"check"===t?Boolean(e.__checked):void 0}setChecked(e){const t=this.getWritable();return t.__checked=e,t}toggleChecked(){const e=this.getWritable();return e.setChecked(!e.__checked)}getIndent(){const e=this.getParent();if(null===e||!this.isAttached())return this.getLatest().__indent;let t=e.getParentOrThrow(),r=0;for(;v(t);)t=t.getParentOrThrow().getParentOrThrow(),r++;return r}setIndent(e){"number"!=typeof e&&n(117),(e=Math.floor(e))>=0||n(199);let t=this.getIndent();for(;t!==e;)t<e?(p(this),t++):(m(this),t--);return this}canInsertAfter(e){return v(e)}canReplaceWith(e){return v(e)}canMergeWith(e){return v(e)||t.$isParagraphNode(e)}extractWithChild(e,r){if(!t.$isRangeSelection(r))return!1;const n=r.anchor.getNode(),s=r.focus.getNode();return this.isParentOf(n)&&this.isParentOf(s)&&this.getTextContent().length===r.getTextContent().length}isParentRequired(){return!0}createParentElementNode(){return A("bullet")}canMergeWhenEmpty(){return!0}}function S(t,r,n){const s=[],i=[],o=r.list,l=o?o.listitem:void 0;let c;if(o&&o.nested&&(c=o.nested.listitem),void 0!==l&&s.push(...C(l)),o){const e=n.getParent(),t=b(e)&&"check"===e.getListType(),r=n.getChecked();t&&!r||i.push(o.listitemUnchecked),t&&r||i.push(o.listitemChecked),t&&s.push(r?o.listitemChecked:o.listitemUnchecked)}if(void 0!==c){const e=C(c);n.getChildren().some((e=>b(e)))?s.push(...e):i.push(...e)}i.length>0&&e.removeClassNamesFromElement(t,...i),s.length>0&&e.addClassNamesToElement(t,...s)}function y(e,t,r,n){b(t.getFirstChild())?(e.removeAttribute("role"),e.removeAttribute("tabIndex"),e.removeAttribute("aria-checked")):(e.setAttribute("role","checkbox"),e.setAttribute("tabIndex","-1"),r&&t.__checked===r.__checked||e.setAttribute("aria-checked",t.getChecked()?"true":"false"))}function O(e){if(e.classList.contains("task-list-item"))for(const t of e.children)if("INPUT"===t.tagName)return x(t);const t=e.getAttribute("aria-checked");return{node:L("true"===t||"false"!==t&&void 0)}}function x(e){if(!("checkbox"===e.getAttribute("type")))return{node:null};return{node:L(e.hasAttribute("checked"))}}function L(e){return t.$applyNodeReplacement(new T(void 0,e))}function v(e){return e instanceof T}class P extends t.ElementNode{static getType(){return"list"}static clone(e){const t=e.__listType||R[e.__tag];return new P(t,e.__start,e.__key)}constructor(e="number",t=1,r){super(r);const n=R[e]||e;this.__listType=n,this.__tag="number"===n?"ol":"ul",this.__start=t}getTag(){return this.__tag}setListType(e){const t=this.getWritable();return t.__listType=e,t.__tag="number"===e?"ol":"ul",t}getListType(){return this.__listType}getStart(){return this.__start}setStart(e){const t=this.getWritable();return t.__start=e,t}createDOM(e,t){const r=this.__tag,n=document.createElement(r);return 1!==this.__start&&n.setAttribute("start",String(this.__start)),n.__lexicalListType=this.__listType,E(n,e.theme,this),n}updateDOM(e,t,r){return e.__tag!==this.__tag||(E(t,r.theme,this),!1)}static transform(){return e=>{b(e)||n(163),function(e){const t=e.getNextSibling();b(t)&&e.getListType()===t.getListType()&&h(e,t)}(e),function(e){const t="check"!==e.getListType();let r=e.getStart();for(const n of e.getChildren())v(n)&&(n.getValue()!==r&&n.setValue(r),t&&null!=n.getLatest().__checked&&n.setChecked(void 0),b(n.getFirstChild())||r++)}(e)}}static importDOM(){return{ol:()=>({conversion:k,priority:0}),ul:()=>({conversion:k,priority:0})}}static importJSON(e){return A().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setListType(e.listType).setStart(e.start)}exportDOM(t){const r=this.createDOM(t._config,t);return e.isHTMLElement(r)&&(1!==this.__start&&r.setAttribute("start",String(this.__start)),"check"===this.__listType&&r.setAttribute("__lexicalListType","check")),{element:r}}exportJSON(){return{...super.exportJSON(),listType:this.getListType(),start:this.getStart(),tag:this.getTag()}}canBeEmpty(){return!1}canIndent(){return!1}splice(e,r,n){let s=n;for(let e=0;e<n.length;e++){const r=n[e];v(r)||(s===n&&(s=[...n]),s[e]=L().append(!t.$isElementNode(r)||b(r)||r.isInline()?r:t.$createTextNode(r.getTextContent())))}return super.splice(e,r,s)}extractWithChild(e){return v(e)}}function E(t,r,n){const i=[],o=[],l=r.list;if(void 0!==l){const e=l[`${n.__tag}Depth`]||[],t=s(n)-1,r=t%e.length,c=e[r],a=l[n.__tag];let g;const u=l.nested,d=l.checklist;if(void 0!==u&&u.list&&(g=u.list),void 0!==a&&i.push(a),void 0!==d&&"check"===n.__listType&&i.push(d),void 0!==c){i.push(...C(c));for(let t=0;t<e.length;t++)t!==r&&o.push(n.__tag+t)}if(void 0!==g){const e=C(g);t>1?i.push(...e):o.push(...e)}}o.length>0&&e.removeClassNamesFromElement(t,...o),i.length>0&&e.addClassNamesToElement(t,...i)}function M(e){const t=[];for(let r=0;r<e.length;r++){const n=e[r];if(v(n)){t.push(n);const e=n.getChildren();e.length>1&&e.forEach((e=>{b(e)&&t.push(c(e))}))}else t.push(c(n))}return t}function k(t){const r=t.nodeName.toLowerCase();let n=null;if("ol"===r){n=A("number",t.start)}else"ul"===r&&(n=function(t){if("check"===t.getAttribute("__lexicallisttype")||t.classList.contains("contains-task-list"))return!0;for(const r of t.childNodes)if(e.isHTMLElement(r)&&r.hasAttribute("aria-checked"))return!0;return!1}(t)?A("check"):A("bullet"));return{after:M,node:n}}const R={ol:"number",ul:"bullet"};function A(e="number",r=1){return t.$applyNodeReplacement(new P(e,r))}function b(e){return e instanceof P}const F=t.createCommand("INSERT_CHECK_LIST_COMMAND");function I(t,r){const n=t.target;if(!e.isHTMLElement(n))return;const s=n.firstChild;if(e.isHTMLElement(s)&&("UL"===s.tagName||"OL"===s.tagName))return;const i=n.parentNode;if(!i||"check"!==i.__lexicalListType)return;const o=n.getBoundingClientRect(),l=t.pageX/e.calculateZoomLevel(n);("rtl"===n.dir?l<o.right&&l>o.right-20:l>o.left&&l<o.left+20)&&r()}function $(r){I(r,(()=>{if(e.isHTMLElement(r.target)){const e=r.target,n=t.getNearestEditorFromDOMNode(e);null!=n&&n.isEditable()&&n.update((()=>{const r=t.$getNearestNodeFromDOMNode(e);v(r)&&(e.focus(),r.toggleChecked())}))}}))}function D(e){I(e,(()=>{e.preventDefault()}))}function w(){const t=document.activeElement;return e.isHTMLElement(t)&&"LI"===t.tagName&&null!=t.parentNode&&"check"===t.parentNode.__lexicalListType?t:null}function W(e,r,n){const s=w();return null!=s&&r.update((()=>{const i=t.$getNearestNodeFromDOMNode(s);if(!v(i))return;const o=function(e,t){let r=t?e.getPreviousSibling():e.getNextSibling(),n=e;for(;null==r&&v(n);)n=n.getParentOrThrow().getParent(),null!=n&&(r=t?n.getPreviousSibling():n.getNextSibling());for(;v(r);){const e=t?r.getLastChild():r.getFirstChild();if(!b(e))return r;r=t?e.getLastChild():e.getFirstChild()}return null}(i,n);if(null!=o){o.selectStart();const t=r.getElementByKey(o.__key);null!=t&&(e.preventDefault(),setTimeout((()=>{t.focus()}),0))}})),!1}const K=t.createCommand("INSERT_UNORDERED_LIST_COMMAND"),Y=t.createCommand("INSERT_ORDERED_LIST_COMMAND"),J=t.createCommand("REMOVE_LIST_COMMAND");exports.$createListItemNode=L,exports.$createListNode=A,exports.$getListDepth=s,exports.$handleListInsertParagraph=_,exports.$insertList=g,exports.$isListItemNode=v,exports.$isListNode=b,exports.$removeList=f,exports.INSERT_CHECK_LIST_COMMAND=F,exports.INSERT_ORDERED_LIST_COMMAND=Y,exports.INSERT_UNORDERED_LIST_COMMAND=K,exports.ListItemNode=T,exports.ListNode=P,exports.REMOVE_LIST_COMMAND=J,exports.insertList=function(e,t){e.update((()=>g(t)))},exports.registerCheckList=function(r){return e.mergeRegister(r.registerCommand(F,(()=>(g("check"),!0)),t.COMMAND_PRIORITY_LOW),r.registerCommand(t.KEY_ARROW_DOWN_COMMAND,(e=>W(e,r,!1)),t.COMMAND_PRIORITY_LOW),r.registerCommand(t.KEY_ARROW_UP_COMMAND,(e=>W(e,r,!0)),t.COMMAND_PRIORITY_LOW),r.registerCommand(t.KEY_ESCAPE_COMMAND,(()=>{if(null!=w()){const e=r.getRootElement();return null!=e&&e.focus(),!0}return!1}),t.COMMAND_PRIORITY_LOW),r.registerCommand(t.KEY_SPACE_COMMAND,(e=>{const n=w();return!(null==n||!r.isEditable())&&(r.update((()=>{const r=t.$getNearestNodeFromDOMNode(n);v(r)&&(e.preventDefault(),r.toggleChecked())})),!0)}),t.COMMAND_PRIORITY_LOW),r.registerCommand(t.KEY_ARROW_LEFT_COMMAND,(n=>r.getEditorState().read((()=>{const s=t.$getSelection();if(t.$isRangeSelection(s)&&s.isCollapsed()){const{anchor:i}=s,o="element"===i.type;if(o||0===i.offset){const s=i.getNode(),l=e.$findMatchingParent(s,(e=>t.$isElementNode(e)&&!e.isInline()));if(v(l)){const e=l.getParent();if(b(e)&&"check"===e.getListType()&&(o||l.getFirstDescendant()===s)){const e=r.getElementByKey(l.__key);if(null!=e&&document.activeElement!==e)return e.focus(),n.preventDefault(),!0}}}}return!1}))),t.COMMAND_PRIORITY_LOW),r.registerRootListener(((e,t)=>{null!==e&&(e.addEventListener("click",$),e.addEventListener("pointerdown",D)),null!==t&&(t.removeEventListener("click",$),t.removeEventListener("pointerdown",D))})))},exports.registerList=function(r){const n=e.mergeRegister(r.registerCommand(Y,(()=>(g("number"),!0)),t.COMMAND_PRIORITY_LOW),r.registerCommand(K,(()=>(g("bullet"),!0)),t.COMMAND_PRIORITY_LOW),r.registerCommand(J,(()=>(f(),!0)),t.COMMAND_PRIORITY_LOW),r.registerCommand(t.INSERT_PARAGRAPH_COMMAND,(()=>_()),t.COMMAND_PRIORITY_LOW),r.registerNodeTransform(T,(e=>{const r=e.getFirstChild();if(r){if(t.$isTextNode(r)){const t=r.getStyle(),n=r.getFormat();e.getTextStyle()!==t&&e.setTextStyle(t),e.getTextFormat()!==n&&e.setTextFormat(n)}}else{const r=t.$getSelection();t.$isRangeSelection(r)&&(r.style!==e.getTextStyle()||r.format!==e.getTextFormat())&&r.isCollapsed()&&e.is(r.anchor.getNode())&&e.setTextStyle(r.style).setTextFormat(r.format)}})),r.registerNodeTransform(t.TextNode,(e=>{const t=e.getParent();if(v(t)&&e.is(t.getFirstChild())){const r=e.getStyle(),n=e.getFormat();r===t.getTextStyle()&&n===t.getTextFormat()||t.setTextStyle(r).setTextFormat(n)}})));return n},exports.registerListStrictIndentTransform=function(t){const r=t=>{const r=t.getParent();if(b(t.getFirstChild())||!b(r))return;const n=e.$findMatchingParent(t,(e=>v(e)&&b(e.getParent())&&v(e.getPreviousSibling())));if(null===n&&t.getIndent()>0)t.setIndent(0);else if(v(n)){const e=n.getPreviousSibling();if(v(e)){const n=function(e){let t=e,r=t.getFirstChild();for(;b(r);){const e=r.getLastChild();if(!v(e))break;t=e,r=t.getFirstChild()}return t}(e),i=n.getParent();if(b(i)){const e=s(i);e+1<s(r)&&t.setIndent(e)}}}};return t.registerNodeTransform(P,(e=>{const t=[e];for(;t.length>0;){const e=t.shift();if(b(e))for(const n of e.getChildren())if(v(n)){r(n);const e=n.getFirstChild();b(e)&&t.push(e)}}}))},exports.removeList=function(e){e.update((()=>f()))};