@lexical/list 0.27.0 → 0.27.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -642,6 +642,10 @@ class ListItemNode extends lexical.ElementNode {
642
642
  exportDOM(editor) {
643
643
  const element = this.createDOM(editor._config);
644
644
  element.style.textAlign = this.getFormatType();
645
+ const direction = this.getDirection();
646
+ if (direction) {
647
+ element.dir = direction;
648
+ }
645
649
  return {
646
650
  element
647
651
  };
@@ -640,6 +640,10 @@ class ListItemNode extends ElementNode {
640
640
  exportDOM(editor) {
641
641
  const element = this.createDOM(editor._config);
642
642
  element.style.textAlign = this.getFormatType();
643
+ const direction = this.getDirection();
644
+ if (direction) {
645
+ element.dir = direction;
646
+ }
643
647
  return {
644
648
  element
645
649
  };
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- "use strict";var e=require("@lexical/utils"),t=require("lexical");function r(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 n(e){let t=1,n=e.getParent();for(;null!=n;){if(v(n)){const e=n.getParent();if(E(e)){t++,n=e.getParent();continue}r(40)}return t}return t}function s(e){let t=e.getParent();E(t)||r(40);let n=t;for(;null!==n;)n=n.getParent(),E(n)&&(t=n);return t}function i(e){let t=[];const r=e.getChildren().filter(v);for(let e=0;e<r.length;e++){const n=r[e],s=n.getFirstChild();E(s)?t=t.concat(i(s)):t.push(n)}return t}function o(e){return v(e)&&E(e.getFirstChild())}function l(e){return x().append(e)}function a(e,t){return v(e)&&(0===t.length||1===t.length&&e.is(t[0])&&0===e.getChildrenSize())}function c(e){const n=t.$getSelection();if(null!==n){let s=n.getNodes();if(t.$isRangeSelection(n)){const i=n.getStartEndPoints();null===i&&r(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=x();t.$isElementNode(l)&&(e.setFormat(l.getFormatType()),e.setIndent(l.getIndent())),r.append(e)}else if(v(l)){const e=l.getParentOrThrow();h(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())){if(t.$isLeafNode(n)){let r=n.getParent();for(;null!=r;){const n=r.getKey();if(E(r)){if(!i.has(n)){const t=A(e);h(t,r.getChildren()),r.replace(t),i.add(n)}break}{const s=r.getParent();if(t.$isRootOrShadowRoot(s)&&!i.has(n)){i.add(n),g(r,e);break}r=s}}}}else g(n,e)}}}function h(e,t){e.splice(e.getChildrenSize(),0,t)}function g(e,t){if(E(e))return e;const r=e.getPreviousSibling(),n=e.getNextSibling(),s=x();let i;if(h(s,e.getChildren()),E(r)&&t===r.getListType())r.append(s),E(n)&&t===n.getListType()&&(h(r,n.getChildren()),n.remove()),i=r;else if(E(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 d(e,t){const r=e.getLastChild(),n=t.getFirstChild();r&&n&&o(r)&&o(n)&&(d(r.getFirstChild(),n.getFirstChild()),n.remove());const s=t.getChildren();s.length>0&&e.append(...s),t.remove()}function u(){const r=t.$getSelection();if(t.$isRangeSelection(r)){const n=new Set,o=r.getNodes(),l=r.anchor.getNode();if(a(l,o))n.add(s(l));else for(let r=0;r<o.length;r++){const i=o[r];if(t.$isLeafNode(i)){const t=e.$getNearestNodeOfType(i,T);null!=t&&n.add(s(t))}}for(const e of n){let n=e;const s=i(e);for(const e of s){const s=t.$createParagraphNode().setTextStyle(r.style).setTextFormat(r.format);h(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(o(e)||t.has(e.getKey()))return;const r=e.getParent(),n=e.getNextSibling(),s=e.getPreviousSibling();if(o(n)&&o(s)){const r=s.getFirstChild();if(E(r)){r.append(e);const s=n.getFirstChild();if(E(s)){h(r,s.getChildren()),n.remove(),t.add(n.getKey())}}}else if(o(n)){const t=n.getFirstChild();if(E(t)){const r=t.getFirstChild();null!==r&&r.insertBefore(e)}}else if(o(s)){const t=s.getFirstChild();E(t)&&t.append(e)}else if(E(r)){const t=x().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 f(e){if(o(e))return;const t=e.getParent(),r=t?t.getParent():void 0;if(E(r?r.getParent():void 0)&&v(r)&&E(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=x(),i=A(n);s.append(i),e.getPreviousSiblings().forEach((e=>i.append(e)));const o=x(),l=A(n);o.append(l),h(l,e.getNextSiblings()),r.insertBefore(s),r.insertAfter(o),r.replace(e)}}}function m(){const e=t.$getSelection();if(!t.$isRangeSelection(e)||!e.isCollapsed())return!1;const n=e.anchor.getNode();if(!v(n)||0!==n.getChildrenSize())return!1;const i=s(n),o=n.getParent();E(o)||r(40);const l=o.getParent();let a;if(t.$isRootOrShadowRoot(l))a=t.$createParagraphNode(),i.insertAfter(a);else{if(!v(l))return!1;a=x(),l.insertAfter(a)}a.setTextStyle(e.style).setTextFormat(e.format).select();const c=n.getNextSiblings();if(c.length>0){const e=A(o.getListType());if(v(a)){const t=x();t.append(e),a.insertAfter(t)}else a.insertAfter(e);e.append(...c)}return function(e){let t=e;for(;null==t.getNextSibling()&&null==t.getPreviousSibling();){const e=t.getParent();if(null==e||!v(e)&&!E(e))break;t=e}t.remove()}(n),!0}function _(...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}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();E(r)&&"check"===r.getListType()&&N(t,this,null),t.value=this.__value,C(t,e.theme,this);const n=this.__style||this.__textStyle;return n&&(t.style.cssText=n),t}updateDOM(e,t,r){const n=this.getParent();E(n)&&"check"===n.getListType()&&N(t,this,e),t.value=this.__value,C(t,r.theme,this);const s=e.__style||e.__textStyle,i=this.__style||this.__textStyle;return s!==i&&(t.style.cssText=i,""===i&&t.removeAttribute("style")),!1}static transform(){return e=>{if(v(e)||r(144),null==e.__checked)return;const t=e.getParent();E(t)&&"check"!==t.getListType()&&null!=e.getChecked()&&e.setChecked(void 0)}}static importDOM(){return{li:()=>({conversion:S,priority:0})}}static importJSON(e){return x().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setValue(e.value).setChecked(e.checked)}exportDOM(e){const t=this.createDOM(e._config);return t.style.textAlign=this.getFormatType(),{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,n){if(v(e))return super.replace(e);this.setIndent(0);const s=this.getParentOrThrow();if(!E(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 n&&(t.$isElementNode(e)||r(139),this.getChildren().forEach((t=>{e.append(t)}))),this.remove(),0===s.getChildrenSize()&&s.remove(),e}insertAfter(e,t=!0){const n=this.getParentOrThrow();if(E(n)||r(39),v(e))return super.insertAfter(e,t);const s=this.getNextSiblings();if(n.insertAfter(e,t),0!==s.length){const r=A(n.getListType());s.forEach((e=>r.append(e))),e.insertAfter(r,t)}return e}remove(e){const t=this.getPreviousSibling(),r=this.getNextSibling();super.remove(e),t&&r&&o(t)&&o(r)&&(d(t.getFirstChild(),r.getFirstChild()),r.remove())}insertNewAfter(e,t=!0){const r=x().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 E(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&&r(117),(e=Math.floor(e))>=0||r(199);let t=this.getIndent();for(;t!==e;)t<e?(p(this),t++):(f(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 C(t,r,n){const s=[],i=[],o=r.list,l=o?o.listitem:void 0;let a;if(o&&o.nested&&(a=o.nested.listitem),void 0!==l&&s.push(..._(l)),o){const e=n.getParent(),t=E(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!==a){const e=_(a);n.getChildren().some((e=>E(e)))?s.push(...e):i.push(...e)}i.length>0&&e.removeClassNamesFromElement(t,...i),s.length>0&&e.addClassNamesToElement(t,...s)}function N(e,t,r,n){E(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 S(e){if(e.classList.contains("task-list-item"))for(const t of e.children)if("INPUT"===t.tagName)return y(t);const t=e.getAttribute("aria-checked");return{node:x("true"===t||"false"!==t&&void 0)}}function y(e){if(!("checkbox"===e.getAttribute("type")))return{node:null};return{node:x(e.hasAttribute("checked"))}}function x(e){return t.$applyNodeReplacement(new T(void 0,e))}function v(e){return e instanceof T}class O extends t.ElementNode{static getType(){return"list"}static clone(e){const t=e.__listType||b[e.__tag];return new O(t,e.__start,e.__key)}constructor(e="number",t=1,r){super(r);const n=b[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,L(n,e.theme,this),n}updateDOM(e,t,r){return e.__tag!==this.__tag||(L(t,r.theme,this),!1)}static transform(){return e=>{E(e)||r(163),function(e){const t=e.getNextSibling();E(t)&&e.getListType()===t.getListType()&&d(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),E(n.getFirstChild())||r++)}(e)}}static importDOM(){return{ol:()=>({conversion:P,priority:0}),ul:()=>({conversion:P,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}append(...e){for(let r=0;r<e.length;r++){const n=e[r];if(v(n))super.append(n);else{const e=x();if(E(n))e.append(n);else if(t.$isElementNode(n))if(n.isInline())e.append(n);else{const r=t.$createTextNode(n.getTextContent());e.append(r)}else e.append(n);super.append(e)}}return this}extractWithChild(e){return v(e)}}function L(t,r,s){const i=[],o=[],l=r.list;if(void 0!==l){const e=l[`${s.__tag}Depth`]||[],t=n(s)-1,r=t%e.length,a=e[r],c=l[s.__tag];let h;const g=l.nested,d=l.checklist;if(void 0!==g&&g.list&&(h=g.list),void 0!==c&&i.push(c),void 0!==d&&"check"===s.__listType&&i.push(d),void 0!==a){i.push(..._(a));for(let t=0;t<e.length;t++)t!==r&&o.push(s.__tag+t)}if(void 0!==h){const e=_(h);t>1?i.push(...e):o.push(...e)}}o.length>0&&e.removeClassNamesFromElement(t,...o),i.length>0&&e.addClassNamesToElement(t,...i)}function k(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=>{E(e)&&t.push(l(e))}))}else t.push(l(n))}return t}function P(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:k,node:n}}const b={ol:"number",ul:"bullet"};function A(e="number",r=1){return t.$applyNodeReplacement(new O(e,r))}function E(e){return e instanceof O}const F=t.createCommand("INSERT_UNORDERED_LIST_COMMAND"),R=t.createCommand("INSERT_ORDERED_LIST_COMMAND"),$=t.createCommand("INSERT_CHECK_LIST_COMMAND"),M=t.createCommand("REMOVE_LIST_COMMAND");exports.$createListItemNode=x,exports.$createListNode=A,exports.$getListDepth=n,exports.$handleListInsertParagraph=m,exports.$insertList=c,exports.$isListItemNode=v,exports.$isListNode=E,exports.$removeList=u,exports.INSERT_CHECK_LIST_COMMAND=$,exports.INSERT_ORDERED_LIST_COMMAND=R,exports.INSERT_UNORDERED_LIST_COMMAND=F,exports.ListItemNode=T,exports.ListNode=O,exports.REMOVE_LIST_COMMAND=M,exports.insertList=function(e,t){e.update((()=>c(t)))},exports.registerList=function(r){return e.mergeRegister(r.registerCommand(R,(()=>(c("number"),!0)),t.COMMAND_PRIORITY_LOW),r.registerCommand(F,(()=>(c("bullet"),!0)),t.COMMAND_PRIORITY_LOW),r.registerCommand(M,(()=>(u(),!0)),t.COMMAND_PRIORITY_LOW),r.registerCommand(t.INSERT_PARAGRAPH_COMMAND,(()=>m()),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)}})))},exports.removeList=function(e){e.update((()=>u()))};
9
+ "use strict";var e=require("@lexical/utils"),t=require("lexical");function r(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 n(e){let t=1,n=e.getParent();for(;null!=n;){if(v(n)){const e=n.getParent();if(E(e)){t++,n=e.getParent();continue}r(40)}return t}return t}function s(e){let t=e.getParent();E(t)||r(40);let n=t;for(;null!==n;)n=n.getParent(),E(n)&&(t=n);return t}function i(e){let t=[];const r=e.getChildren().filter(v);for(let e=0;e<r.length;e++){const n=r[e],s=n.getFirstChild();E(s)?t=t.concat(i(s)):t.push(n)}return t}function o(e){return v(e)&&E(e.getFirstChild())}function l(e){return x().append(e)}function a(e,t){return v(e)&&(0===t.length||1===t.length&&e.is(t[0])&&0===e.getChildrenSize())}function c(e){const n=t.$getSelection();if(null!==n){let s=n.getNodes();if(t.$isRangeSelection(n)){const i=n.getStartEndPoints();null===i&&r(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=x();t.$isElementNode(l)&&(e.setFormat(l.getFormatType()),e.setIndent(l.getIndent())),r.append(e)}else if(v(l)){const e=l.getParentOrThrow();h(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())){if(t.$isLeafNode(n)){let r=n.getParent();for(;null!=r;){const n=r.getKey();if(E(r)){if(!i.has(n)){const t=A(e);h(t,r.getChildren()),r.replace(t),i.add(n)}break}{const s=r.getParent();if(t.$isRootOrShadowRoot(s)&&!i.has(n)){i.add(n),g(r,e);break}r=s}}}}else g(n,e)}}}function h(e,t){e.splice(e.getChildrenSize(),0,t)}function g(e,t){if(E(e))return e;const r=e.getPreviousSibling(),n=e.getNextSibling(),s=x();let i;if(h(s,e.getChildren()),E(r)&&t===r.getListType())r.append(s),E(n)&&t===n.getListType()&&(h(r,n.getChildren()),n.remove()),i=r;else if(E(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 d(e,t){const r=e.getLastChild(),n=t.getFirstChild();r&&n&&o(r)&&o(n)&&(d(r.getFirstChild(),n.getFirstChild()),n.remove());const s=t.getChildren();s.length>0&&e.append(...s),t.remove()}function u(){const r=t.$getSelection();if(t.$isRangeSelection(r)){const n=new Set,o=r.getNodes(),l=r.anchor.getNode();if(a(l,o))n.add(s(l));else for(let r=0;r<o.length;r++){const i=o[r];if(t.$isLeafNode(i)){const t=e.$getNearestNodeOfType(i,T);null!=t&&n.add(s(t))}}for(const e of n){let n=e;const s=i(e);for(const e of s){const s=t.$createParagraphNode().setTextStyle(r.style).setTextFormat(r.format);h(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(o(e)||t.has(e.getKey()))return;const r=e.getParent(),n=e.getNextSibling(),s=e.getPreviousSibling();if(o(n)&&o(s)){const r=s.getFirstChild();if(E(r)){r.append(e);const s=n.getFirstChild();if(E(s)){h(r,s.getChildren()),n.remove(),t.add(n.getKey())}}}else if(o(n)){const t=n.getFirstChild();if(E(t)){const r=t.getFirstChild();null!==r&&r.insertBefore(e)}}else if(o(s)){const t=s.getFirstChild();E(t)&&t.append(e)}else if(E(r)){const t=x().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 f(e){if(o(e))return;const t=e.getParent(),r=t?t.getParent():void 0;if(E(r?r.getParent():void 0)&&v(r)&&E(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=x(),i=A(n);s.append(i),e.getPreviousSiblings().forEach((e=>i.append(e)));const o=x(),l=A(n);o.append(l),h(l,e.getNextSiblings()),r.insertBefore(s),r.insertAfter(o),r.replace(e)}}}function m(){const e=t.$getSelection();if(!t.$isRangeSelection(e)||!e.isCollapsed())return!1;const n=e.anchor.getNode();if(!v(n)||0!==n.getChildrenSize())return!1;const i=s(n),o=n.getParent();E(o)||r(40);const l=o.getParent();let a;if(t.$isRootOrShadowRoot(l))a=t.$createParagraphNode(),i.insertAfter(a);else{if(!v(l))return!1;a=x(),l.insertAfter(a)}a.setTextStyle(e.style).setTextFormat(e.format).select();const c=n.getNextSiblings();if(c.length>0){const e=A(o.getListType());if(v(a)){const t=x();t.append(e),a.insertAfter(t)}else a.insertAfter(e);e.append(...c)}return function(e){let t=e;for(;null==t.getNextSibling()&&null==t.getPreviousSibling();){const e=t.getParent();if(null==e||!v(e)&&!E(e))break;t=e}t.remove()}(n),!0}function _(...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}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();E(r)&&"check"===r.getListType()&&N(t,this,null),t.value=this.__value,C(t,e.theme,this);const n=this.__style||this.__textStyle;return n&&(t.style.cssText=n),t}updateDOM(e,t,r){const n=this.getParent();E(n)&&"check"===n.getListType()&&N(t,this,e),t.value=this.__value,C(t,r.theme,this);const s=e.__style||e.__textStyle,i=this.__style||this.__textStyle;return s!==i&&(t.style.cssText=i,""===i&&t.removeAttribute("style")),!1}static transform(){return e=>{if(v(e)||r(144),null==e.__checked)return;const t=e.getParent();E(t)&&"check"!==t.getListType()&&null!=e.getChecked()&&e.setChecked(void 0)}}static importDOM(){return{li:()=>({conversion:S,priority:0})}}static importJSON(e){return x().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,n){if(v(e))return super.replace(e);this.setIndent(0);const s=this.getParentOrThrow();if(!E(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 n&&(t.$isElementNode(e)||r(139),this.getChildren().forEach((t=>{e.append(t)}))),this.remove(),0===s.getChildrenSize()&&s.remove(),e}insertAfter(e,t=!0){const n=this.getParentOrThrow();if(E(n)||r(39),v(e))return super.insertAfter(e,t);const s=this.getNextSiblings();if(n.insertAfter(e,t),0!==s.length){const r=A(n.getListType());s.forEach((e=>r.append(e))),e.insertAfter(r,t)}return e}remove(e){const t=this.getPreviousSibling(),r=this.getNextSibling();super.remove(e),t&&r&&o(t)&&o(r)&&(d(t.getFirstChild(),r.getFirstChild()),r.remove())}insertNewAfter(e,t=!0){const r=x().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 E(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&&r(117),(e=Math.floor(e))>=0||r(199);let t=this.getIndent();for(;t!==e;)t<e?(p(this),t++):(f(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 C(t,r,n){const s=[],i=[],o=r.list,l=o?o.listitem:void 0;let a;if(o&&o.nested&&(a=o.nested.listitem),void 0!==l&&s.push(..._(l)),o){const e=n.getParent(),t=E(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!==a){const e=_(a);n.getChildren().some((e=>E(e)))?s.push(...e):i.push(...e)}i.length>0&&e.removeClassNamesFromElement(t,...i),s.length>0&&e.addClassNamesToElement(t,...s)}function N(e,t,r,n){E(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 S(e){if(e.classList.contains("task-list-item"))for(const t of e.children)if("INPUT"===t.tagName)return y(t);const t=e.getAttribute("aria-checked");return{node:x("true"===t||"false"!==t&&void 0)}}function y(e){if(!("checkbox"===e.getAttribute("type")))return{node:null};return{node:x(e.hasAttribute("checked"))}}function x(e){return t.$applyNodeReplacement(new T(void 0,e))}function v(e){return e instanceof T}class O extends t.ElementNode{static getType(){return"list"}static clone(e){const t=e.__listType||b[e.__tag];return new O(t,e.__start,e.__key)}constructor(e="number",t=1,r){super(r);const n=b[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,L(n,e.theme,this),n}updateDOM(e,t,r){return e.__tag!==this.__tag||(L(t,r.theme,this),!1)}static transform(){return e=>{E(e)||r(163),function(e){const t=e.getNextSibling();E(t)&&e.getListType()===t.getListType()&&d(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),E(n.getFirstChild())||r++)}(e)}}static importDOM(){return{ol:()=>({conversion:P,priority:0}),ul:()=>({conversion:P,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}append(...e){for(let r=0;r<e.length;r++){const n=e[r];if(v(n))super.append(n);else{const e=x();if(E(n))e.append(n);else if(t.$isElementNode(n))if(n.isInline())e.append(n);else{const r=t.$createTextNode(n.getTextContent());e.append(r)}else e.append(n);super.append(e)}}return this}extractWithChild(e){return v(e)}}function L(t,r,s){const i=[],o=[],l=r.list;if(void 0!==l){const e=l[`${s.__tag}Depth`]||[],t=n(s)-1,r=t%e.length,a=e[r],c=l[s.__tag];let h;const g=l.nested,d=l.checklist;if(void 0!==g&&g.list&&(h=g.list),void 0!==c&&i.push(c),void 0!==d&&"check"===s.__listType&&i.push(d),void 0!==a){i.push(..._(a));for(let t=0;t<e.length;t++)t!==r&&o.push(s.__tag+t)}if(void 0!==h){const e=_(h);t>1?i.push(...e):o.push(...e)}}o.length>0&&e.removeClassNamesFromElement(t,...o),i.length>0&&e.addClassNamesToElement(t,...i)}function k(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=>{E(e)&&t.push(l(e))}))}else t.push(l(n))}return t}function P(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:k,node:n}}const b={ol:"number",ul:"bullet"};function A(e="number",r=1){return t.$applyNodeReplacement(new O(e,r))}function E(e){return e instanceof O}const F=t.createCommand("INSERT_UNORDERED_LIST_COMMAND"),R=t.createCommand("INSERT_ORDERED_LIST_COMMAND"),$=t.createCommand("INSERT_CHECK_LIST_COMMAND"),M=t.createCommand("REMOVE_LIST_COMMAND");exports.$createListItemNode=x,exports.$createListNode=A,exports.$getListDepth=n,exports.$handleListInsertParagraph=m,exports.$insertList=c,exports.$isListItemNode=v,exports.$isListNode=E,exports.$removeList=u,exports.INSERT_CHECK_LIST_COMMAND=$,exports.INSERT_ORDERED_LIST_COMMAND=R,exports.INSERT_UNORDERED_LIST_COMMAND=F,exports.ListItemNode=T,exports.ListNode=O,exports.REMOVE_LIST_COMMAND=M,exports.insertList=function(e,t){e.update((()=>c(t)))},exports.registerList=function(r){return e.mergeRegister(r.registerCommand(R,(()=>(c("number"),!0)),t.COMMAND_PRIORITY_LOW),r.registerCommand(F,(()=>(c("bullet"),!0)),t.COMMAND_PRIORITY_LOW),r.registerCommand(M,(()=>(u(),!0)),t.COMMAND_PRIORITY_LOW),r.registerCommand(t.INSERT_PARAGRAPH_COMMAND,(()=>m()),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)}})))},exports.removeList=function(e){e.update((()=>u()))};
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- import{$getNearestNodeOfType as t,removeClassNamesFromElement as e,addClassNamesToElement as r,isHTMLElement as n,mergeRegister as s}from"@lexical/utils";import{$getSelection as i,$isRangeSelection as o,$isRootOrShadowRoot as l,$createParagraphNode as c,$isElementNode as a,$isLeafNode as h,$setPointFromCaret as g,$normalizeCaret as u,$getChildCaret as d,ElementNode as f,$isParagraphNode as p,$applyNodeReplacement as _,$createTextNode as m,createCommand as y,COMMAND_PRIORITY_LOW as T,INSERT_PARAGRAPH_COMMAND as S,$isTextNode as C,TextNode as x}from"lexical";function v(t,...e){const r=new URL("https://lexical.dev/docs/error"),n=new URLSearchParams;n.append("code",t);for(const t of e)n.append("v",t);throw r.search=n.toString(),Error(`Minified Lexical error #${t}; visit ${r.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function k(t){let e=1,r=t.getParent();for(;null!=r;){if($(r)){const t=r.getParent();if(Y(t)){e++,r=t.getParent();continue}v(40)}return e}return e}function b(t){let e=t.getParent();Y(e)||v(40);let r=e;for(;null!==r;)r=r.getParent(),Y(r)&&(e=r);return e}function N(t){let e=[];const r=t.getChildren().filter($);for(let t=0;t<r.length;t++){const n=r[t],s=n.getFirstChild();Y(s)?e=e.concat(N(s)):e.push(n)}return e}function F(t){return $(t)&&Y(t.getFirstChild())}function O(t){return z().append(t)}function P(t,e){return $(t)&&(0===e.length||1===e.length&&t.is(e[0])&&0===t.getChildrenSize())}function A(t){const e=i();if(null!==e){let r=e.getNodes();if(o(e)){const n=e.getStartEndPoints();null===n&&v(143);const[s]=n,i=s.getNode(),o=i.getParent();if(l(i)){const t=i.getFirstChild();if(t)r=t.selectStart().getNodes();else{const t=c();i.append(t),r=t.select().getNodes()}}else if(P(i,r)){const e=X(t);if(l(o)){i.replace(e);const t=z();a(i)&&(t.setFormat(i.getFormatType()),t.setIndent(i.getIndent())),e.append(t)}else if($(i)){const t=i.getParentOrThrow();L(e,t.getChildren()),t.replace(e)}return}}const n=new Set;for(let e=0;e<r.length;e++){const s=r[e];if(!a(s)||!s.isEmpty()||$(s)||n.has(s.getKey())){if(h(s)){let e=s.getParent();for(;null!=e;){const r=e.getKey();if(Y(e)){if(!n.has(r)){const s=X(t);L(s,e.getChildren()),e.replace(s),n.add(r)}break}{const s=e.getParent();if(l(s)&&!n.has(r)){n.add(r),E(e,t);break}e=s}}}}else E(s,t)}}}function L(t,e){t.splice(t.getChildrenSize(),0,e)}function E(t,e){if(Y(t))return t;const r=t.getPreviousSibling(),n=t.getNextSibling(),s=z();let i;if(L(s,t.getChildren()),Y(r)&&e===r.getListType())r.append(s),Y(n)&&e===n.getListType()&&(L(r,n.getChildren()),n.remove()),i=r;else if(Y(n)&&e===n.getListType())n.getFirstChildOrThrow().insertBefore(s),i=n;else{const r=X(e);r.append(s),t.replace(r),i=r}return s.setFormat(t.getFormatType()),s.setIndent(t.getIndent()),t.remove(),i}function M(t,e){const r=t.getLastChild(),n=e.getFirstChild();r&&n&&F(r)&&F(n)&&(M(r.getFirstChild(),n.getFirstChild()),n.remove());const s=e.getChildren();s.length>0&&t.append(...s),e.remove()}function w(){const e=i();if(o(e)){const r=new Set,n=e.getNodes(),s=e.anchor.getNode();if(P(s,n))r.add(b(s));else for(let e=0;e<n.length;e++){const s=n[e];if(h(s)){const e=t(s,W);null!=e&&r.add(b(e))}}for(const t of r){let r=t;const n=N(t);for(const t of n){const n=c().setTextStyle(e.style).setTextFormat(e.format);L(n,t.getChildren()),r.insertAfter(n),r=n,t.__key===e.anchor.key&&g(e.anchor,u(d(n,"next"))),t.__key===e.focus.key&&g(e.focus,u(d(n,"next"))),t.remove()}t.remove()}}}function I(t){const e=new Set;if(F(t)||e.has(t.getKey()))return;const r=t.getParent(),n=t.getNextSibling(),s=t.getPreviousSibling();if(F(n)&&F(s)){const r=s.getFirstChild();if(Y(r)){r.append(t);const s=n.getFirstChild();if(Y(s)){L(r,s.getChildren()),n.remove(),e.add(n.getKey())}}}else if(F(n)){const e=n.getFirstChild();if(Y(e)){const r=e.getFirstChild();null!==r&&r.insertBefore(t)}}else if(F(s)){const e=s.getFirstChild();Y(e)&&e.append(t)}else if(Y(r)){const e=z().setTextFormat(r.getTextFormat()).setTextStyle(r.getTextStyle()),i=X(r.getListType()).setTextFormat(r.getTextFormat()).setTextStyle(r.getTextStyle());e.append(i),i.append(t),s?s.insertAfter(e):n?n.insertBefore(e):r.append(e)}}function D(t){if(F(t))return;const e=t.getParent(),r=e?e.getParent():void 0;if(Y(r?r.getParent():void 0)&&$(r)&&Y(e)){const n=e?e.getFirstChild():void 0,s=e?e.getLastChild():void 0;if(t.is(n))r.insertBefore(t),e.isEmpty()&&r.remove();else if(t.is(s))r.insertAfter(t),e.isEmpty()&&r.remove();else{const n=e.getListType(),s=z(),i=X(n);s.append(i),t.getPreviousSiblings().forEach((t=>i.append(t)));const o=z(),l=X(n);o.append(l),L(l,t.getNextSiblings()),r.insertBefore(s),r.insertAfter(o),r.replace(t)}}}function J(){const t=i();if(!o(t)||!t.isCollapsed())return!1;const e=t.anchor.getNode();if(!$(e)||0!==e.getChildrenSize())return!1;const r=b(e),n=e.getParent();Y(n)||v(40);const s=n.getParent();let a;if(l(s))a=c(),r.insertAfter(a);else{if(!$(s))return!1;a=z(),s.insertAfter(a)}a.setTextStyle(t.style).setTextFormat(t.format).select();const h=e.getNextSiblings();if(h.length>0){const t=X(n.getListType());if($(a)){const e=z();e.append(t),a.insertAfter(e)}else a.insertAfter(t);t.append(...h)}return function(t){let e=t;for(;null==e.getNextSibling()&&null==e.getPreviousSibling();){const t=e.getParent();if(null==t||!$(t)&&!Y(t))break;e=t}e.remove()}(e),!0}function R(...t){const e=[];for(const r of t)if(r&&"string"==typeof r)for(const[t]of r.matchAll(/\S+/g))e.push(t);return e}class W extends f{static getType(){return"listitem"}static clone(t){return new W(t.__value,t.__checked,t.__key)}constructor(t,e,r){super(r),this.__value=void 0===t?1:t,this.__checked=e}createDOM(t){const e=document.createElement("li"),r=this.getParent();Y(r)&&"check"===r.getListType()&&K(e,this,null),e.value=this.__value,B(e,t.theme,this);const n=this.__style||this.__textStyle;return n&&(e.style.cssText=n),e}updateDOM(t,e,r){const n=this.getParent();Y(n)&&"check"===n.getListType()&&K(e,this,t),e.value=this.__value,B(e,r.theme,this);const s=t.__style||t.__textStyle,i=this.__style||this.__textStyle;return s!==i&&(e.style.cssText=i,""===i&&e.removeAttribute("style")),!1}static transform(){return t=>{if($(t)||v(144),null==t.__checked)return;const e=t.getParent();Y(e)&&"check"!==e.getListType()&&null!=t.getChecked()&&t.setChecked(void 0)}}static importDOM(){return{li:()=>({conversion:V,priority:0})}}static importJSON(t){return z().updateFromJSON(t)}updateFromJSON(t){return super.updateFromJSON(t).setValue(t.value).setChecked(t.checked)}exportDOM(t){const e=this.createDOM(t._config);return e.style.textAlign=this.getFormatType(),{element:e}}exportJSON(){return{...super.exportJSON(),checked:this.getChecked(),value:this.getValue()}}append(...t){for(let e=0;e<t.length;e++){const r=t[e];if(a(r)&&this.canMergeWith(r)){const t=r.getChildren();this.append(...t),r.remove()}else super.append(r)}return this}replace(t,e){if($(t))return super.replace(t);this.setIndent(0);const r=this.getParentOrThrow();if(!Y(r))return t;if(r.__first===this.getKey())r.insertBefore(t);else if(r.__last===this.getKey())r.insertAfter(t);else{const e=X(r.getListType());let n=this.getNextSibling();for(;n;){const t=n;n=n.getNextSibling(),e.append(t)}r.insertAfter(t),t.insertAfter(e)}return e&&(a(t)||v(139),this.getChildren().forEach((e=>{t.append(e)}))),this.remove(),0===r.getChildrenSize()&&r.remove(),t}insertAfter(t,e=!0){const r=this.getParentOrThrow();if(Y(r)||v(39),$(t))return super.insertAfter(t,e);const n=this.getNextSiblings();if(r.insertAfter(t,e),0!==n.length){const s=X(r.getListType());n.forEach((t=>s.append(t))),t.insertAfter(s,e)}return t}remove(t){const e=this.getPreviousSibling(),r=this.getNextSibling();super.remove(t),e&&r&&F(e)&&F(r)&&(M(e.getFirstChild(),r.getFirstChild()),r.remove())}insertNewAfter(t,e=!0){const r=z().updateFromJSON(this.exportJSON()).setChecked(!this.getChecked()&&void 0);return this.insertAfter(r,e),r}collapseAtStart(t){const e=c();this.getChildren().forEach((t=>e.append(t)));const r=this.getParentOrThrow(),n=r.getParentOrThrow(),s=$(n);if(1===r.getChildrenSize())if(s)r.remove(),n.select();else{r.insertBefore(e),r.remove();const n=t.anchor,s=t.focus,i=e.getKey();"element"===n.type&&n.getNode().is(this)&&n.set(i,n.offset,"element"),"element"===s.type&&s.getNode().is(this)&&s.set(i,s.offset,"element")}else r.insertBefore(e),this.remove();return!0}getValue(){return this.getLatest().__value}setValue(t){const e=this.getWritable();return e.__value=t,e}getChecked(){const t=this.getLatest();let e;const r=this.getParent();return Y(r)&&(e=r.getListType()),"check"===e?Boolean(t.__checked):void 0}setChecked(t){const e=this.getWritable();return e.__checked=t,e}toggleChecked(){const t=this.getWritable();return t.setChecked(!t.__checked)}getIndent(){const t=this.getParent();if(null===t||!this.isAttached())return this.getLatest().__indent;let e=t.getParentOrThrow(),r=0;for(;$(e);)e=e.getParentOrThrow().getParentOrThrow(),r++;return r}setIndent(t){"number"!=typeof t&&v(117),(t=Math.floor(t))>=0||v(199);let e=this.getIndent();for(;e!==t;)e<t?(I(this),e++):(D(this),e--);return this}canInsertAfter(t){return $(t)}canReplaceWith(t){return $(t)}canMergeWith(t){return $(t)||p(t)}extractWithChild(t,e){if(!o(e))return!1;const r=e.anchor.getNode(),n=e.focus.getNode();return this.isParentOf(r)&&this.isParentOf(n)&&this.getTextContent().length===e.getTextContent().length}isParentRequired(){return!0}createParentElementNode(){return X("bullet")}canMergeWhenEmpty(){return!0}}function B(t,n,s){const i=[],o=[],l=n.list,c=l?l.listitem:void 0;let a;if(l&&l.nested&&(a=l.nested.listitem),void 0!==c&&i.push(...R(c)),l){const t=s.getParent(),e=Y(t)&&"check"===t.getListType(),r=s.getChecked();e&&!r||o.push(l.listitemUnchecked),e&&r||o.push(l.listitemChecked),e&&i.push(r?l.listitemChecked:l.listitemUnchecked)}if(void 0!==a){const t=R(a);s.getChildren().some((t=>Y(t)))?i.push(...t):o.push(...t)}o.length>0&&e(t,...o),i.length>0&&r(t,...i)}function K(t,e,r,n){Y(e.getFirstChild())?(t.removeAttribute("role"),t.removeAttribute("tabIndex"),t.removeAttribute("aria-checked")):(t.setAttribute("role","checkbox"),t.setAttribute("tabIndex","-1"),r&&e.__checked===r.__checked||t.setAttribute("aria-checked",e.getChecked()?"true":"false"))}function V(t){if(t.classList.contains("task-list-item"))for(const e of t.children)if("INPUT"===e.tagName)return U(e);const e=t.getAttribute("aria-checked");return{node:z("true"===e||"false"!==e&&void 0)}}function U(t){if(!("checkbox"===t.getAttribute("type")))return{node:null};return{node:z(t.hasAttribute("checked"))}}function z(t){return _(new W(void 0,t))}function $(t){return t instanceof W}class q extends f{static getType(){return"list"}static clone(t){const e=t.__listType||Q[t.__tag];return new q(e,t.__start,t.__key)}constructor(t="number",e=1,r){super(r);const n=Q[t]||t;this.__listType=n,this.__tag="number"===n?"ol":"ul",this.__start=e}getTag(){return this.__tag}setListType(t){const e=this.getWritable();return e.__listType=t,e.__tag="number"===t?"ol":"ul",e}getListType(){return this.__listType}getStart(){return this.__start}setStart(t){const e=this.getWritable();return e.__start=t,e}createDOM(t,e){const r=this.__tag,n=document.createElement(r);return 1!==this.__start&&n.setAttribute("start",String(this.__start)),n.__lexicalListType=this.__listType,H(n,t.theme,this),n}updateDOM(t,e,r){return t.__tag!==this.__tag||(H(e,r.theme,this),!1)}static transform(){return t=>{Y(t)||v(163),function(t){const e=t.getNextSibling();Y(e)&&t.getListType()===e.getListType()&&M(t,e)}(t),function(t){const e="check"!==t.getListType();let r=t.getStart();for(const n of t.getChildren())$(n)&&(n.getValue()!==r&&n.setValue(r),e&&null!=n.getLatest().__checked&&n.setChecked(void 0),Y(n.getFirstChild())||r++)}(t)}}static importDOM(){return{ol:()=>({conversion:G,priority:0}),ul:()=>({conversion:G,priority:0})}}static importJSON(t){return X().updateFromJSON(t)}updateFromJSON(t){return super.updateFromJSON(t).setListType(t.listType).setStart(t.start)}exportDOM(t){const e=this.createDOM(t._config,t);return n(e)&&(1!==this.__start&&e.setAttribute("start",String(this.__start)),"check"===this.__listType&&e.setAttribute("__lexicalListType","check")),{element:e}}exportJSON(){return{...super.exportJSON(),listType:this.getListType(),start:this.getStart(),tag:this.getTag()}}canBeEmpty(){return!1}canIndent(){return!1}append(...t){for(let e=0;e<t.length;e++){const r=t[e];if($(r))super.append(r);else{const t=z();if(Y(r))t.append(r);else if(a(r))if(r.isInline())t.append(r);else{const e=m(r.getTextContent());t.append(e)}else t.append(r);super.append(t)}}return this}extractWithChild(t){return $(t)}}function H(t,n,s){const i=[],o=[],l=n.list;if(void 0!==l){const t=l[`${s.__tag}Depth`]||[],e=k(s)-1,r=e%t.length,n=t[r],c=l[s.__tag];let a;const h=l.nested,g=l.checklist;if(void 0!==h&&h.list&&(a=h.list),void 0!==c&&i.push(c),void 0!==g&&"check"===s.__listType&&i.push(g),void 0!==n){i.push(...R(n));for(let e=0;e<t.length;e++)e!==r&&o.push(s.__tag+e)}if(void 0!==a){const t=R(a);e>1?i.push(...t):o.push(...t)}}o.length>0&&e(t,...o),i.length>0&&r(t,...i)}function j(t){const e=[];for(let r=0;r<t.length;r++){const n=t[r];if($(n)){e.push(n);const t=n.getChildren();t.length>1&&t.forEach((t=>{Y(t)&&e.push(O(t))}))}else e.push(O(n))}return e}function G(t){const e=t.nodeName.toLowerCase();let r=null;if("ol"===e){r=X("number",t.start)}else"ul"===e&&(r=function(t){if("check"===t.getAttribute("__lexicallisttype")||t.classList.contains("contains-task-list"))return!0;for(const e of t.childNodes)if(n(e)&&e.hasAttribute("aria-checked"))return!0;return!1}(t)?X("check"):X("bullet"));return{after:j,node:r}}const Q={ol:"number",ul:"bullet"};function X(t="number",e=1){return _(new q(t,e))}function Y(t){return t instanceof q}const Z=y("INSERT_UNORDERED_LIST_COMMAND"),tt=y("INSERT_ORDERED_LIST_COMMAND"),et=y("INSERT_CHECK_LIST_COMMAND"),rt=y("REMOVE_LIST_COMMAND");function nt(t){return s(t.registerCommand(tt,(()=>(A("number"),!0)),T),t.registerCommand(Z,(()=>(A("bullet"),!0)),T),t.registerCommand(rt,(()=>(w(),!0)),T),t.registerCommand(S,(()=>J()),T),t.registerNodeTransform(W,(t=>{const e=t.getFirstChild();if(e){if(C(e)){const r=e.getStyle(),n=e.getFormat();t.getTextStyle()!==r&&t.setTextStyle(r),t.getTextFormat()!==n&&t.setTextFormat(n)}}else{const e=i();o(e)&&(e.style!==t.getTextStyle()||e.format!==t.getTextFormat())&&e.isCollapsed()&&t.is(e.anchor.getNode())&&t.setTextStyle(e.style).setTextFormat(e.format)}})),t.registerNodeTransform(x,(t=>{const e=t.getParent();if($(e)&&t.is(e.getFirstChild())){const r=t.getStyle(),n=t.getFormat();r===e.getTextStyle()&&n===e.getTextFormat()||e.setTextStyle(r).setTextFormat(n)}})))}function st(t,e){t.update((()=>A(e)))}function it(t){t.update((()=>w()))}export{z as $createListItemNode,X as $createListNode,k as $getListDepth,J as $handleListInsertParagraph,A as $insertList,$ as $isListItemNode,Y as $isListNode,w as $removeList,et as INSERT_CHECK_LIST_COMMAND,tt as INSERT_ORDERED_LIST_COMMAND,Z as INSERT_UNORDERED_LIST_COMMAND,W as ListItemNode,q as ListNode,rt as REMOVE_LIST_COMMAND,st as insertList,nt as registerList,it as removeList};
9
+ import{$getNearestNodeOfType as t,removeClassNamesFromElement as e,addClassNamesToElement as r,isHTMLElement as n,mergeRegister as s}from"@lexical/utils";import{$getSelection as i,$isRangeSelection as o,$isRootOrShadowRoot as l,$createParagraphNode as c,$isElementNode as a,$isLeafNode as h,$setPointFromCaret as g,$normalizeCaret as u,$getChildCaret as d,ElementNode as f,$isParagraphNode as p,$applyNodeReplacement as _,$createTextNode as m,createCommand as y,COMMAND_PRIORITY_LOW as T,INSERT_PARAGRAPH_COMMAND as S,$isTextNode as C,TextNode as x}from"lexical";function v(t,...e){const r=new URL("https://lexical.dev/docs/error"),n=new URLSearchParams;n.append("code",t);for(const t of e)n.append("v",t);throw r.search=n.toString(),Error(`Minified Lexical error #${t}; visit ${r.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function k(t){let e=1,r=t.getParent();for(;null!=r;){if($(r)){const t=r.getParent();if(Y(t)){e++,r=t.getParent();continue}v(40)}return e}return e}function b(t){let e=t.getParent();Y(e)||v(40);let r=e;for(;null!==r;)r=r.getParent(),Y(r)&&(e=r);return e}function N(t){let e=[];const r=t.getChildren().filter($);for(let t=0;t<r.length;t++){const n=r[t],s=n.getFirstChild();Y(s)?e=e.concat(N(s)):e.push(n)}return e}function F(t){return $(t)&&Y(t.getFirstChild())}function O(t){return z().append(t)}function P(t,e){return $(t)&&(0===e.length||1===e.length&&t.is(e[0])&&0===t.getChildrenSize())}function A(t){const e=i();if(null!==e){let r=e.getNodes();if(o(e)){const n=e.getStartEndPoints();null===n&&v(143);const[s]=n,i=s.getNode(),o=i.getParent();if(l(i)){const t=i.getFirstChild();if(t)r=t.selectStart().getNodes();else{const t=c();i.append(t),r=t.select().getNodes()}}else if(P(i,r)){const e=X(t);if(l(o)){i.replace(e);const t=z();a(i)&&(t.setFormat(i.getFormatType()),t.setIndent(i.getIndent())),e.append(t)}else if($(i)){const t=i.getParentOrThrow();L(e,t.getChildren()),t.replace(e)}return}}const n=new Set;for(let e=0;e<r.length;e++){const s=r[e];if(!a(s)||!s.isEmpty()||$(s)||n.has(s.getKey())){if(h(s)){let e=s.getParent();for(;null!=e;){const r=e.getKey();if(Y(e)){if(!n.has(r)){const s=X(t);L(s,e.getChildren()),e.replace(s),n.add(r)}break}{const s=e.getParent();if(l(s)&&!n.has(r)){n.add(r),E(e,t);break}e=s}}}}else E(s,t)}}}function L(t,e){t.splice(t.getChildrenSize(),0,e)}function E(t,e){if(Y(t))return t;const r=t.getPreviousSibling(),n=t.getNextSibling(),s=z();let i;if(L(s,t.getChildren()),Y(r)&&e===r.getListType())r.append(s),Y(n)&&e===n.getListType()&&(L(r,n.getChildren()),n.remove()),i=r;else if(Y(n)&&e===n.getListType())n.getFirstChildOrThrow().insertBefore(s),i=n;else{const r=X(e);r.append(s),t.replace(r),i=r}return s.setFormat(t.getFormatType()),s.setIndent(t.getIndent()),t.remove(),i}function M(t,e){const r=t.getLastChild(),n=e.getFirstChild();r&&n&&F(r)&&F(n)&&(M(r.getFirstChild(),n.getFirstChild()),n.remove());const s=e.getChildren();s.length>0&&t.append(...s),e.remove()}function w(){const e=i();if(o(e)){const r=new Set,n=e.getNodes(),s=e.anchor.getNode();if(P(s,n))r.add(b(s));else for(let e=0;e<n.length;e++){const s=n[e];if(h(s)){const e=t(s,W);null!=e&&r.add(b(e))}}for(const t of r){let r=t;const n=N(t);for(const t of n){const n=c().setTextStyle(e.style).setTextFormat(e.format);L(n,t.getChildren()),r.insertAfter(n),r=n,t.__key===e.anchor.key&&g(e.anchor,u(d(n,"next"))),t.__key===e.focus.key&&g(e.focus,u(d(n,"next"))),t.remove()}t.remove()}}}function I(t){const e=new Set;if(F(t)||e.has(t.getKey()))return;const r=t.getParent(),n=t.getNextSibling(),s=t.getPreviousSibling();if(F(n)&&F(s)){const r=s.getFirstChild();if(Y(r)){r.append(t);const s=n.getFirstChild();if(Y(s)){L(r,s.getChildren()),n.remove(),e.add(n.getKey())}}}else if(F(n)){const e=n.getFirstChild();if(Y(e)){const r=e.getFirstChild();null!==r&&r.insertBefore(t)}}else if(F(s)){const e=s.getFirstChild();Y(e)&&e.append(t)}else if(Y(r)){const e=z().setTextFormat(r.getTextFormat()).setTextStyle(r.getTextStyle()),i=X(r.getListType()).setTextFormat(r.getTextFormat()).setTextStyle(r.getTextStyle());e.append(i),i.append(t),s?s.insertAfter(e):n?n.insertBefore(e):r.append(e)}}function D(t){if(F(t))return;const e=t.getParent(),r=e?e.getParent():void 0;if(Y(r?r.getParent():void 0)&&$(r)&&Y(e)){const n=e?e.getFirstChild():void 0,s=e?e.getLastChild():void 0;if(t.is(n))r.insertBefore(t),e.isEmpty()&&r.remove();else if(t.is(s))r.insertAfter(t),e.isEmpty()&&r.remove();else{const n=e.getListType(),s=z(),i=X(n);s.append(i),t.getPreviousSiblings().forEach((t=>i.append(t)));const o=z(),l=X(n);o.append(l),L(l,t.getNextSiblings()),r.insertBefore(s),r.insertAfter(o),r.replace(t)}}}function J(){const t=i();if(!o(t)||!t.isCollapsed())return!1;const e=t.anchor.getNode();if(!$(e)||0!==e.getChildrenSize())return!1;const r=b(e),n=e.getParent();Y(n)||v(40);const s=n.getParent();let a;if(l(s))a=c(),r.insertAfter(a);else{if(!$(s))return!1;a=z(),s.insertAfter(a)}a.setTextStyle(t.style).setTextFormat(t.format).select();const h=e.getNextSiblings();if(h.length>0){const t=X(n.getListType());if($(a)){const e=z();e.append(t),a.insertAfter(e)}else a.insertAfter(t);t.append(...h)}return function(t){let e=t;for(;null==e.getNextSibling()&&null==e.getPreviousSibling();){const t=e.getParent();if(null==t||!$(t)&&!Y(t))break;e=t}e.remove()}(e),!0}function R(...t){const e=[];for(const r of t)if(r&&"string"==typeof r)for(const[t]of r.matchAll(/\S+/g))e.push(t);return e}class W extends f{static getType(){return"listitem"}static clone(t){return new W(t.__value,t.__checked,t.__key)}constructor(t,e,r){super(r),this.__value=void 0===t?1:t,this.__checked=e}createDOM(t){const e=document.createElement("li"),r=this.getParent();Y(r)&&"check"===r.getListType()&&K(e,this,null),e.value=this.__value,B(e,t.theme,this);const n=this.__style||this.__textStyle;return n&&(e.style.cssText=n),e}updateDOM(t,e,r){const n=this.getParent();Y(n)&&"check"===n.getListType()&&K(e,this,t),e.value=this.__value,B(e,r.theme,this);const s=t.__style||t.__textStyle,i=this.__style||this.__textStyle;return s!==i&&(e.style.cssText=i,""===i&&e.removeAttribute("style")),!1}static transform(){return t=>{if($(t)||v(144),null==t.__checked)return;const e=t.getParent();Y(e)&&"check"!==e.getListType()&&null!=t.getChecked()&&t.setChecked(void 0)}}static importDOM(){return{li:()=>({conversion:V,priority:0})}}static importJSON(t){return z().updateFromJSON(t)}updateFromJSON(t){return super.updateFromJSON(t).setValue(t.value).setChecked(t.checked)}exportDOM(t){const e=this.createDOM(t._config);e.style.textAlign=this.getFormatType();const r=this.getDirection();return r&&(e.dir=r),{element:e}}exportJSON(){return{...super.exportJSON(),checked:this.getChecked(),value:this.getValue()}}append(...t){for(let e=0;e<t.length;e++){const r=t[e];if(a(r)&&this.canMergeWith(r)){const t=r.getChildren();this.append(...t),r.remove()}else super.append(r)}return this}replace(t,e){if($(t))return super.replace(t);this.setIndent(0);const r=this.getParentOrThrow();if(!Y(r))return t;if(r.__first===this.getKey())r.insertBefore(t);else if(r.__last===this.getKey())r.insertAfter(t);else{const e=X(r.getListType());let n=this.getNextSibling();for(;n;){const t=n;n=n.getNextSibling(),e.append(t)}r.insertAfter(t),t.insertAfter(e)}return e&&(a(t)||v(139),this.getChildren().forEach((e=>{t.append(e)}))),this.remove(),0===r.getChildrenSize()&&r.remove(),t}insertAfter(t,e=!0){const r=this.getParentOrThrow();if(Y(r)||v(39),$(t))return super.insertAfter(t,e);const n=this.getNextSiblings();if(r.insertAfter(t,e),0!==n.length){const s=X(r.getListType());n.forEach((t=>s.append(t))),t.insertAfter(s,e)}return t}remove(t){const e=this.getPreviousSibling(),r=this.getNextSibling();super.remove(t),e&&r&&F(e)&&F(r)&&(M(e.getFirstChild(),r.getFirstChild()),r.remove())}insertNewAfter(t,e=!0){const r=z().updateFromJSON(this.exportJSON()).setChecked(!this.getChecked()&&void 0);return this.insertAfter(r,e),r}collapseAtStart(t){const e=c();this.getChildren().forEach((t=>e.append(t)));const r=this.getParentOrThrow(),n=r.getParentOrThrow(),s=$(n);if(1===r.getChildrenSize())if(s)r.remove(),n.select();else{r.insertBefore(e),r.remove();const n=t.anchor,s=t.focus,i=e.getKey();"element"===n.type&&n.getNode().is(this)&&n.set(i,n.offset,"element"),"element"===s.type&&s.getNode().is(this)&&s.set(i,s.offset,"element")}else r.insertBefore(e),this.remove();return!0}getValue(){return this.getLatest().__value}setValue(t){const e=this.getWritable();return e.__value=t,e}getChecked(){const t=this.getLatest();let e;const r=this.getParent();return Y(r)&&(e=r.getListType()),"check"===e?Boolean(t.__checked):void 0}setChecked(t){const e=this.getWritable();return e.__checked=t,e}toggleChecked(){const t=this.getWritable();return t.setChecked(!t.__checked)}getIndent(){const t=this.getParent();if(null===t||!this.isAttached())return this.getLatest().__indent;let e=t.getParentOrThrow(),r=0;for(;$(e);)e=e.getParentOrThrow().getParentOrThrow(),r++;return r}setIndent(t){"number"!=typeof t&&v(117),(t=Math.floor(t))>=0||v(199);let e=this.getIndent();for(;e!==t;)e<t?(I(this),e++):(D(this),e--);return this}canInsertAfter(t){return $(t)}canReplaceWith(t){return $(t)}canMergeWith(t){return $(t)||p(t)}extractWithChild(t,e){if(!o(e))return!1;const r=e.anchor.getNode(),n=e.focus.getNode();return this.isParentOf(r)&&this.isParentOf(n)&&this.getTextContent().length===e.getTextContent().length}isParentRequired(){return!0}createParentElementNode(){return X("bullet")}canMergeWhenEmpty(){return!0}}function B(t,n,s){const i=[],o=[],l=n.list,c=l?l.listitem:void 0;let a;if(l&&l.nested&&(a=l.nested.listitem),void 0!==c&&i.push(...R(c)),l){const t=s.getParent(),e=Y(t)&&"check"===t.getListType(),r=s.getChecked();e&&!r||o.push(l.listitemUnchecked),e&&r||o.push(l.listitemChecked),e&&i.push(r?l.listitemChecked:l.listitemUnchecked)}if(void 0!==a){const t=R(a);s.getChildren().some((t=>Y(t)))?i.push(...t):o.push(...t)}o.length>0&&e(t,...o),i.length>0&&r(t,...i)}function K(t,e,r,n){Y(e.getFirstChild())?(t.removeAttribute("role"),t.removeAttribute("tabIndex"),t.removeAttribute("aria-checked")):(t.setAttribute("role","checkbox"),t.setAttribute("tabIndex","-1"),r&&e.__checked===r.__checked||t.setAttribute("aria-checked",e.getChecked()?"true":"false"))}function V(t){if(t.classList.contains("task-list-item"))for(const e of t.children)if("INPUT"===e.tagName)return U(e);const e=t.getAttribute("aria-checked");return{node:z("true"===e||"false"!==e&&void 0)}}function U(t){if(!("checkbox"===t.getAttribute("type")))return{node:null};return{node:z(t.hasAttribute("checked"))}}function z(t){return _(new W(void 0,t))}function $(t){return t instanceof W}class q extends f{static getType(){return"list"}static clone(t){const e=t.__listType||Q[t.__tag];return new q(e,t.__start,t.__key)}constructor(t="number",e=1,r){super(r);const n=Q[t]||t;this.__listType=n,this.__tag="number"===n?"ol":"ul",this.__start=e}getTag(){return this.__tag}setListType(t){const e=this.getWritable();return e.__listType=t,e.__tag="number"===t?"ol":"ul",e}getListType(){return this.__listType}getStart(){return this.__start}setStart(t){const e=this.getWritable();return e.__start=t,e}createDOM(t,e){const r=this.__tag,n=document.createElement(r);return 1!==this.__start&&n.setAttribute("start",String(this.__start)),n.__lexicalListType=this.__listType,H(n,t.theme,this),n}updateDOM(t,e,r){return t.__tag!==this.__tag||(H(e,r.theme,this),!1)}static transform(){return t=>{Y(t)||v(163),function(t){const e=t.getNextSibling();Y(e)&&t.getListType()===e.getListType()&&M(t,e)}(t),function(t){const e="check"!==t.getListType();let r=t.getStart();for(const n of t.getChildren())$(n)&&(n.getValue()!==r&&n.setValue(r),e&&null!=n.getLatest().__checked&&n.setChecked(void 0),Y(n.getFirstChild())||r++)}(t)}}static importDOM(){return{ol:()=>({conversion:G,priority:0}),ul:()=>({conversion:G,priority:0})}}static importJSON(t){return X().updateFromJSON(t)}updateFromJSON(t){return super.updateFromJSON(t).setListType(t.listType).setStart(t.start)}exportDOM(t){const e=this.createDOM(t._config,t);return n(e)&&(1!==this.__start&&e.setAttribute("start",String(this.__start)),"check"===this.__listType&&e.setAttribute("__lexicalListType","check")),{element:e}}exportJSON(){return{...super.exportJSON(),listType:this.getListType(),start:this.getStart(),tag:this.getTag()}}canBeEmpty(){return!1}canIndent(){return!1}append(...t){for(let e=0;e<t.length;e++){const r=t[e];if($(r))super.append(r);else{const t=z();if(Y(r))t.append(r);else if(a(r))if(r.isInline())t.append(r);else{const e=m(r.getTextContent());t.append(e)}else t.append(r);super.append(t)}}return this}extractWithChild(t){return $(t)}}function H(t,n,s){const i=[],o=[],l=n.list;if(void 0!==l){const t=l[`${s.__tag}Depth`]||[],e=k(s)-1,r=e%t.length,n=t[r],c=l[s.__tag];let a;const h=l.nested,g=l.checklist;if(void 0!==h&&h.list&&(a=h.list),void 0!==c&&i.push(c),void 0!==g&&"check"===s.__listType&&i.push(g),void 0!==n){i.push(...R(n));for(let e=0;e<t.length;e++)e!==r&&o.push(s.__tag+e)}if(void 0!==a){const t=R(a);e>1?i.push(...t):o.push(...t)}}o.length>0&&e(t,...o),i.length>0&&r(t,...i)}function j(t){const e=[];for(let r=0;r<t.length;r++){const n=t[r];if($(n)){e.push(n);const t=n.getChildren();t.length>1&&t.forEach((t=>{Y(t)&&e.push(O(t))}))}else e.push(O(n))}return e}function G(t){const e=t.nodeName.toLowerCase();let r=null;if("ol"===e){r=X("number",t.start)}else"ul"===e&&(r=function(t){if("check"===t.getAttribute("__lexicallisttype")||t.classList.contains("contains-task-list"))return!0;for(const e of t.childNodes)if(n(e)&&e.hasAttribute("aria-checked"))return!0;return!1}(t)?X("check"):X("bullet"));return{after:j,node:r}}const Q={ol:"number",ul:"bullet"};function X(t="number",e=1){return _(new q(t,e))}function Y(t){return t instanceof q}const Z=y("INSERT_UNORDERED_LIST_COMMAND"),tt=y("INSERT_ORDERED_LIST_COMMAND"),et=y("INSERT_CHECK_LIST_COMMAND"),rt=y("REMOVE_LIST_COMMAND");function nt(t){return s(t.registerCommand(tt,(()=>(A("number"),!0)),T),t.registerCommand(Z,(()=>(A("bullet"),!0)),T),t.registerCommand(rt,(()=>(w(),!0)),T),t.registerCommand(S,(()=>J()),T),t.registerNodeTransform(W,(t=>{const e=t.getFirstChild();if(e){if(C(e)){const r=e.getStyle(),n=e.getFormat();t.getTextStyle()!==r&&t.setTextStyle(r),t.getTextFormat()!==n&&t.setTextFormat(n)}}else{const e=i();o(e)&&(e.style!==t.getTextStyle()||e.format!==t.getTextFormat())&&e.isCollapsed()&&t.is(e.anchor.getNode())&&t.setTextStyle(e.style).setTextFormat(e.format)}})),t.registerNodeTransform(x,(t=>{const e=t.getParent();if($(e)&&t.is(e.getFirstChild())){const r=t.getStyle(),n=t.getFormat();r===e.getTextStyle()&&n===e.getTextFormat()||e.setTextStyle(r).setTextFormat(n)}})))}function st(t,e){t.update((()=>A(e)))}function it(t){t.update((()=>w()))}export{z as $createListItemNode,X as $createListNode,k as $getListDepth,J as $handleListInsertParagraph,A as $insertList,$ as $isListItemNode,Y as $isListNode,w as $removeList,et as INSERT_CHECK_LIST_COMMAND,tt as INSERT_ORDERED_LIST_COMMAND,Z as INSERT_UNORDERED_LIST_COMMAND,W as ListItemNode,q as ListNode,rt as REMOVE_LIST_COMMAND,st as insertList,nt as registerList,it as removeList};
package/package.json CHANGED
@@ -8,12 +8,12 @@
8
8
  "list"
9
9
  ],
10
10
  "license": "MIT",
11
- "version": "0.27.0",
11
+ "version": "0.27.1",
12
12
  "main": "LexicalList.js",
13
13
  "types": "index.d.ts",
14
14
  "dependencies": {
15
- "@lexical/utils": "0.27.0",
16
- "lexical": "0.27.0"
15
+ "@lexical/utils": "0.27.1",
16
+ "lexical": "0.27.1"
17
17
  },
18
18
  "repository": {
19
19
  "type": "git",