@lexical/list 0.47.1-nightly.20260715.0 → 0.48.0

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.
@@ -815,37 +815,28 @@ class ListItemNode extends lexical.ElementNode {
815
815
  return newElement;
816
816
  }
817
817
  collapseAtStart(selection) {
818
- const paragraph = lexical.$createParagraphNode();
819
- const children = this.getChildren();
820
- children.forEach(child => paragraph.append(child));
818
+ if (isNestedListNode(this)) {
819
+ return false;
820
+ }
821
821
  const listNode = this.getParentOrThrow();
822
822
  const listNodeParent = listNode.getParentOrThrow();
823
- const isIndented = $isListItemNode(listNodeParent);
824
- if (listNode.getChildrenSize() === 1) {
825
- if (isIndented) {
826
- // if the list node is nested, we just want to remove it,
827
- // effectively unindenting it.
828
- listNode.remove();
829
- listNodeParent.select();
830
- } else {
831
- listNode.insertBefore(paragraph);
832
- listNode.remove();
833
- // If we have selection on the list item, we'll need to move it
834
- // to the paragraph
835
- const anchor = selection.anchor;
836
- const focus = selection.focus;
837
- const key = paragraph.getKey();
838
- if (anchor.type === 'element' && anchor.getNode().is(this)) {
839
- anchor.set(key, anchor.offset, 'element');
840
- }
841
- if (focus.type === 'element' && focus.getNode().is(this)) {
842
- focus.set(key, focus.offset, 'element');
843
- }
844
- }
845
- } else {
846
- listNode.insertBefore(paragraph);
847
- this.remove();
823
+ if ($isListItemNode(listNodeParent)) {
824
+ $handleOutdent(this);
825
+ return true;
826
+ }
827
+ const paragraph = lexical.$createParagraphNode().append(...this.getChildren());
828
+ const nextSiblings = this.getNextSiblings();
829
+ if (nextSiblings.length > 0) {
830
+ const newList = lexical.$copyNode(listNode);
831
+ newList.append(...nextSiblings);
832
+ listNode.insertAfter(newList);
833
+ }
834
+ listNode.insertAfter(paragraph);
835
+ this.remove();
836
+ if (listNode.getChildrenSize() === 0) {
837
+ listNode.remove();
848
838
  }
839
+ paragraph.selectStart();
849
840
  return true;
850
841
  }
851
842
  getValue() {
@@ -1920,16 +1911,36 @@ function registerList(editor, options) {
1920
1911
  }, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(lexical.INSERT_PARAGRAPH_COMMAND, () => {
1921
1912
  const shouldRestore = options && options.restoreNumbering;
1922
1913
  return $handleListInsertParagraph(!!shouldRestore);
1923
- }, lexical.COMMAND_PRIORITY_LOW),
1924
- // Runs just before the rich-text handler at COMMAND_PRIORITY_EDITOR that
1925
- // calls deleteCharacter. Lower-priority handlers (link, mark, etc.) still
1926
- // see Backspace first; only the editor-priority merge-block path is what
1927
- // we intercept here.
1928
- editor.registerCommand(lexical.KEY_BACKSPACE_COMMAND, event => {
1914
+ }, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(lexical.KEY_BACKSPACE_COMMAND, event => {
1929
1915
  if ($handleListItemBackspaceAdjacentToDecorator()) {
1930
1916
  event.preventDefault();
1931
1917
  return true;
1932
1918
  }
1919
+ const selection = lexical.$getSelection();
1920
+ if (!lexical.$isRangeSelection(selection) || !selection.isCollapsed()) {
1921
+ return false;
1922
+ }
1923
+ const {
1924
+ anchor
1925
+ } = selection;
1926
+ if (anchor.offset !== 0) {
1927
+ return false;
1928
+ }
1929
+ let current = anchor.getNode();
1930
+ while (!$isListItemNode(current)) {
1931
+ if (current.getPreviousSibling() !== null) {
1932
+ return false;
1933
+ }
1934
+ const parent = current.getParent();
1935
+ if (parent === null) {
1936
+ return false;
1937
+ }
1938
+ current = parent;
1939
+ }
1940
+ if ($isListItemNode(current) && current.collapseAtStart(selection)) {
1941
+ event.preventDefault();
1942
+ return true;
1943
+ }
1933
1944
  return false;
1934
1945
  }, lexical.COMMAND_PRIORITY_BEFORE_EDITOR), editor.registerNodeTransform(ListItemNode, node => {
1935
1946
  const firstChild = node.getFirstChild();
@@ -813,37 +813,28 @@ class ListItemNode extends ElementNode {
813
813
  return newElement;
814
814
  }
815
815
  collapseAtStart(selection) {
816
- const paragraph = $createParagraphNode();
817
- const children = this.getChildren();
818
- children.forEach(child => paragraph.append(child));
816
+ if (isNestedListNode(this)) {
817
+ return false;
818
+ }
819
819
  const listNode = this.getParentOrThrow();
820
820
  const listNodeParent = listNode.getParentOrThrow();
821
- const isIndented = $isListItemNode(listNodeParent);
822
- if (listNode.getChildrenSize() === 1) {
823
- if (isIndented) {
824
- // if the list node is nested, we just want to remove it,
825
- // effectively unindenting it.
826
- listNode.remove();
827
- listNodeParent.select();
828
- } else {
829
- listNode.insertBefore(paragraph);
830
- listNode.remove();
831
- // If we have selection on the list item, we'll need to move it
832
- // to the paragraph
833
- const anchor = selection.anchor;
834
- const focus = selection.focus;
835
- const key = paragraph.getKey();
836
- if (anchor.type === 'element' && anchor.getNode().is(this)) {
837
- anchor.set(key, anchor.offset, 'element');
838
- }
839
- if (focus.type === 'element' && focus.getNode().is(this)) {
840
- focus.set(key, focus.offset, 'element');
841
- }
842
- }
843
- } else {
844
- listNode.insertBefore(paragraph);
845
- this.remove();
821
+ if ($isListItemNode(listNodeParent)) {
822
+ $handleOutdent(this);
823
+ return true;
824
+ }
825
+ const paragraph = $createParagraphNode().append(...this.getChildren());
826
+ const nextSiblings = this.getNextSiblings();
827
+ if (nextSiblings.length > 0) {
828
+ const newList = $copyNode(listNode);
829
+ newList.append(...nextSiblings);
830
+ listNode.insertAfter(newList);
831
+ }
832
+ listNode.insertAfter(paragraph);
833
+ this.remove();
834
+ if (listNode.getChildrenSize() === 0) {
835
+ listNode.remove();
846
836
  }
837
+ paragraph.selectStart();
847
838
  return true;
848
839
  }
849
840
  getValue() {
@@ -1918,16 +1909,36 @@ function registerList(editor, options) {
1918
1909
  }, COMMAND_PRIORITY_LOW), editor.registerCommand(INSERT_PARAGRAPH_COMMAND, () => {
1919
1910
  const shouldRestore = options && options.restoreNumbering;
1920
1911
  return $handleListInsertParagraph(!!shouldRestore);
1921
- }, COMMAND_PRIORITY_LOW),
1922
- // Runs just before the rich-text handler at COMMAND_PRIORITY_EDITOR that
1923
- // calls deleteCharacter. Lower-priority handlers (link, mark, etc.) still
1924
- // see Backspace first; only the editor-priority merge-block path is what
1925
- // we intercept here.
1926
- editor.registerCommand(KEY_BACKSPACE_COMMAND, event => {
1912
+ }, COMMAND_PRIORITY_LOW), editor.registerCommand(KEY_BACKSPACE_COMMAND, event => {
1927
1913
  if ($handleListItemBackspaceAdjacentToDecorator()) {
1928
1914
  event.preventDefault();
1929
1915
  return true;
1930
1916
  }
1917
+ const selection = $getSelection();
1918
+ if (!$isRangeSelection(selection) || !selection.isCollapsed()) {
1919
+ return false;
1920
+ }
1921
+ const {
1922
+ anchor
1923
+ } = selection;
1924
+ if (anchor.offset !== 0) {
1925
+ return false;
1926
+ }
1927
+ let current = anchor.getNode();
1928
+ while (!$isListItemNode(current)) {
1929
+ if (current.getPreviousSibling() !== null) {
1930
+ return false;
1931
+ }
1932
+ const parent = current.getParent();
1933
+ if (parent === null) {
1934
+ return false;
1935
+ }
1936
+ current = parent;
1937
+ }
1938
+ if ($isListItemNode(current) && current.collapseAtStart(selection)) {
1939
+ event.preventDefault();
1940
+ return true;
1941
+ }
1931
1942
  return false;
1932
1943
  }, COMMAND_PRIORITY_BEFORE_EDITOR), editor.registerNodeTransform(ListItemNode, node => {
1933
1944
  const firstChild = node.getFirstChild();
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- "use strict";var e=require("@lexical/utils"),t=require("lexical"),n=require("@lexical/extension"),r=require("@lexical/html");function i(e,...t){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",e);for(const e of t)r.append("v",e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.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,n=e.getParent();for(;null!=n;){if(x(n)){const e=n.getParent();if(k(e)){t++,n=e.getParent();continue}i(40)}return t}return t}function o(e){const t=e.getParent();k(t)||i(40);let n=t,r=t;for(;null!==r;)r=r.getParent(),k(r)&&(n=r);return n}function l(e){let t=[];const n=e.getChildren().filter(x);for(let e=0;e<n.length;e++){const r=n[e],i=r.getFirstChild();k(i)?t=t.concat(l(i)):t.push(r)}return t}function c(e){return x(e)&&k(e.getFirstChild())}function a(e,t){return x(e)&&(0===t.length||1===t.length&&e.is(t[0])&&0===e.getChildrenSize())}function g(e){const n=t.$getSelection();if(null!==n){let r=n.getNodes();if(t.$isRangeSelection(n)){const[i]=n.getStartEndPoints(),s=i.getNode(),o=s.getParent();if(t.$isRootOrShadowRoot(s)){const e=s.getFirstChild();if(e)r=e.selectStart().getNodes();else{const e=t.$createParagraphNode();s.append(e),r=e.select().getNodes()}}else if(a(s,r)){const n=v(e);if(t.$isRootOrShadowRoot(o)){s.replace(n);const e=O();t.$isElementNode(s)&&(e.setFormat(s.getFormatType()),e.setIndent(s.getIndent())),n.append(e)}else if(x(s)){const e=s.getParentOrThrow();u(n,e.getChildren()),e.replace(n)}return}}const i=new Set;for(let n=0;n<r.length;n++){const s=r[n];if(t.$isElementNode(s)&&s.isEmpty()&&!x(s)&&!i.has(s.getKey())){d(s,e);continue}let o=t.$isLeafNode(s)?s.getParent():x(s)&&s.isEmpty()?s:null;for(;null!=o;){const n=o.getKey();if(k(o)){if(!i.has(n)){const t=v(e);u(t,o.getChildren()),o.replace(t),i.add(n)}break}{const r=o.getParent();if(t.$isRootOrShadowRoot(r)&&!i.has(n)){i.add(n),d(o,e);break}o=r}}}}}function u(e,t){e.splice(e.getChildrenSize(),0,t)}function d(e,n){if(k(e))return e;const r=e.getPreviousSibling(),i=e.getNextSibling(),s=O();let o;if(u(s,e.getChildren()),k(r)&&n===r.getListType())r.append(s),k(i)&&n===i.getListType()&&(u(r,i.getChildren()),i.remove()),o=r;else if(k(i)&&n===i.getListType())i.getFirstChildOrThrow().insertBefore(s),o=i;else{const t=v(n);t.append(s),e.replace(t),o=t}s.setFormat(e.getFormatType()),s.setIndent(e.getIndent());const l=t.$getSelection();return t.$isRangeSelection(l)&&(o.getKey()===l.anchor.key&&l.anchor.set(s.getKey(),l.anchor.offset,"element"),o.getKey()===l.focus.key&&l.focus.set(s.getKey(),l.focus.offset,"element")),e.remove(),o}function h(e,t){const n=e.getLastChild(),r=t.getFirstChild();n&&r&&c(n)&&c(r)&&(h(n.getFirstChild(),r.getFirstChild()),r.remove());const i=t.getChildren();i.length>0&&e.append(...i),t.remove()}function f(){const n=t.$getSelection();if(t.$isRangeSelection(n)){const r=new Set,i=n.getNodes(),s=n.anchor.getNode();if(a(s,i))r.add(o(s));else for(let n=0;n<i.length;n++){const s=i[n];if(t.$isLeafNode(s)){const t=e.$getNearestNodeOfType(s,N);null!=t&&r.add(o(t))}}for(const e of r){let r=e;const i=l(e);for(const e of i){const i=t.$createParagraphNode().setTextStyle(n.style).setTextFormat(n.format);u(i,e.getChildren()),r.insertAfter(i),r=i,e.__key===n.anchor.key&&t.$setPointFromCaret(n.anchor,t.$normalizeCaret(t.$getChildCaret(i,"next"))),e.__key===n.focus.key&&t.$setPointFromCaret(n.focus,t.$normalizeCaret(t.$getChildCaret(i,"next"))),e.remove()}e.remove()}}}function p(e){const t="check"!==e.getListType();let n=e.getStart();for(const r of e.getChildren())x(r)&&(r.getValue()!==n&&r.setValue(n),t&&null!=r.getLatest().__checked&&r.setChecked(void 0),k(r.getFirstChild())||n++)}function m(e){const n=new Set;if(c(e)||n.has(e.getKey()))return;const r=e.getParent(),i=e.getNextSibling(),s=e.getPreviousSibling();if(c(i)&&c(s)){const t=s.getFirstChild();if(k(t)){t.append(e);const r=i.getFirstChild();if(k(r)){u(t,r.getChildren()),i.remove(),n.add(i.getKey())}}}else if(c(i)){const t=i.getFirstChild();if(k(t)){const n=t.getFirstChild();null!==n&&n.insertBefore(e)}}else if(c(s)){const t=s.getFirstChild();k(t)&&t.append(e)}else if(k(r)){const n=t.$copyNode(e),o=t.$copyNode(r);n.append(o),o.append(e),s?s.insertAfter(n):i?i.insertBefore(n):r.append(n)}}function _(e){if(c(e))return;const n=e.getParent(),r=n?n.getParent():void 0;if(k(r?r.getParent():void 0)&&x(r)&&k(n)){const i=n?n.getFirstChild():void 0,s=n?n.getLastChild():void 0;if(e.is(i))r.insertBefore(e),n.isEmpty()&&r.remove();else if(e.is(s))r.insertAfter(e),n.isEmpty()&&r.remove();else{const i=t.$copyNode(e),s=t.$copyNode(n);i.append(s),e.getPreviousSiblings().forEach(e=>s.append(e));const o=t.$copyNode(e),l=t.$copyNode(n);o.append(l),u(l,e.getNextSiblings()),r.insertBefore(i),r.insertAfter(o),r.replace(e)}}}function C(e=!1){const n=t.$getSelection();if(!t.$isRangeSelection(n)||!n.isCollapsed())return!1;const r=n.anchor.getNode();let s=null;if(x(r)&&0===r.getChildrenSize())s=r;else if(t.$isTextNode(r)){const e=r.getParent();x(e)&&e.getChildren().every(e=>t.$isTextNode(e)&&""===e.getTextContent().trim())&&(s=e)}if(null===s)return!1;const l=o(s),c=s.getParent();k(c)||i(40);const a=c.getParent();let g;if(t.$isRootOrShadowRoot(a))g=t.$createParagraphNode(),l.insertAfter(g);else{if(!x(a))return!1;g=t.$copyNode(a),a.insertAfter(g)}g.setTextStyle(n.style).setTextFormat(n.format).select();const u=s.getNextSiblings();if(u.length>0){const n=e?function(e,t){return e.getStart()+t.getIndexWithinParent()}(c,s):1,r=t.$copyNode(c).setStart(n);if(x(g)){const e=t.$copyNode(g);e.append(r),g.insertAfter(e)}else g.insertAfter(r);r.append(...u)}return function(e){let t=e;for(;null==t.getNextSibling()&&null==t.getPreviousSibling();){const e=t.getParent();if(null==e||!x(e)&&!k(e))break;t=e}t.remove()}(s),!0}class N extends t.ElementNode{__value;__checked;$config(){return this.config("listitem",{$transform:e=>{const n=e.getParent();if(k(n))"check"!==n.getListType()&&null!=e.getChecked()&&e.setChecked(void 0);else if(n){const r=e.createParentElementNode();k(r)||i(340);const s=[e];for(const n of["previous","next"]){s.reverse();for(const{origin:r}of t.$getSiblingCaret(e,n)){if(!x(r))break;s.push(r)}}e.insertBefore(r),r.splice(0,0,s),t.$isRootOrShadowRoot(n)||(t.$insertNodeToNearestRootAtCaret(r,t.$rewindSiblingCaret(t.$getSiblingCaret(r,"next")),{$shouldSplit:()=>!1,removeEmptyDestination:!0}),n.isEmpty()&&n.isAttached()&&n.remove())}},extends:t.ElementNode,importDOM:t.buildImportMap({li:()=>({conversion:T,priority:0})})})}constructor(e=1,t=void 0,n){super(n),this.__value=void 0===e?1:e,this.__checked=t}afterCloneFrom(e){super.afterCloneFrom(e),this.__value=e.__value,this.__checked=e.__checked}createDOM(e){const n=t.$getDocument().createElement("li");return this.updateListItemDOM(null,n,e),n}updateListItemDOM(e,n,r){!function(e,t){const n=t.getParent();!k(n)||"check"!==n.getListType()||k(t.getFirstChild())?(e.removeAttribute("role"),e.removeAttribute("tabIndex"),e.removeAttribute("aria-checked")):(e.setAttribute("role","checkbox"),e.setAttribute("tabIndex","-1"),e.setAttribute("aria-checked",t.getChecked()?"true":"false"))}(n,this),n.value=this.__value,function(e,n,r){const i=n.list;if(!i)return;const s=i.listitem,o=i.nested&&i.nested.listitem,l=r.getParent(),c=k(l)&&"check"===l.getListType(),a=r.getChecked(),g=r.getChildren().some(e=>k(e)),u=[];void 0!==i.listitemChecked&&u.push(i.listitemChecked);void 0!==i.listitemUnchecked&&u.push(i.listitemUnchecked);void 0!==o&&u.push(...t.normalizeClassNames(o));u.length>0&&t.removeClassNamesFromElement(e,...u);const d=[];void 0!==s&&d.push(...t.normalizeClassNames(s));if(c){const e=a?i.listitemChecked:i.listitemUnchecked;void 0!==e&&d.push(e)}void 0!==o&&g&&d.push(...t.normalizeClassNames(o));d.length>0&&t.addClassNamesToElement(e,...d)}(n,r.theme,this);const i=e?e.__style:"",s=this.__style;i!==s&&t.setDOMStyleFromCSS(n.style,s,i),function(e,n,r){const i=n.__textStyle,s=r?r.__textStyle:"";if(null!==r&&s===i)return;const o=t.getStyleObjectFromCSS(i);for(const t in o)e.style.setProperty(`--listitem-marker-${t}`,o[t]);if(""!==s)for(const n in t.getStyleObjectFromCSS(s))n in o||e.style.removeProperty(`--listitem-marker-${n}`)}(n,this,e)}updateDOM(e,t,n){const r=t;return this.updateListItemDOM(e,r,n),!1}updateFromJSON(e){return super.updateFromJSON(e).setValue(e.value).setChecked(e.checked)}exportDOM(e){const n=this.createDOM(e._config),r=this.getFormatType();r&&(n.style.textAlign=r);const i=this.getDirection();return i&&(n.dir=i),c(this)?{after(e){if(t.isHTMLElement(e)){const n=e.previousElementSibling;if(t.isHTMLElement(n)&&"LI"===n.nodeName){for(;e.firstChild;)n.append(e.firstChild);e.remove()}}return e},element:n}:{element:n}}exportJSON(){return{...super.exportJSON(),checked:this.getChecked(),value:this.getValue()}}append(...e){for(let n=0;n<e.length;n++){const r=e[n];if(t.$isElementNode(r)&&this.canMergeWith(r)){const e=r.getChildren();this.append(...e),r.remove()}else super.append(r)}return this}replace(e,n){if(x(e))return super.replace(e);this.setIndent(0);const r=this.getParentOrThrow();if(!k(r))return e;if(r.__first===this.getKey())r.insertBefore(e);else if(r.__last===this.getKey())r.insertAfter(e);else{const n=t.$copyNode(r);let i=this.getNextSibling();for(;i;){const e=i;i=i.getNextSibling(),n.append(e)}r.insertAfter(e),e.insertAfter(n)}const s=this.__key;let o=0;if(n&&(t.$isElementNode(e)||i(139),o=e.getChildrenSize(),e.splice(o,0,this.getChildren())),n&&t.$isElementNode(e)){const n=t.$getSelection();if(t.$isRangeSelection(n))for(const t of n.getStartEndPoints())t.key===s&&"element"===t.type&&t.set(e.getKey(),o+t.offset,"element")}return this.remove(),0===r.getChildrenSize()&&r.remove(),e}insertAfter(e,n=!0){const r=this.getParentOrThrow();if(k(r)||i(39),x(e))return super.insertAfter(e,n);const s=this.getNextSiblings();if(r.insertAfter(e,n),0!==s.length){const i=t.$copyNode(r);s.forEach(e=>i.append(e)),e.insertAfter(i,n)}return e}remove(e){const t=this.getPreviousSibling(),n=this.getNextSibling();super.remove(e),t&&n&&c(t)&&c(n)&&(h(t.getFirstChild(),n.getFirstChild()),n.remove())}resetOnCopyNodeFrom(e){super.resetOnCopyNodeFrom(e),e.getChecked()&&this.setChecked(!1)}insertNewAfter(e,n=!0){const r=t.$copyNode(this);return this.insertAfter(r,n),r}collapseAtStart(e){const n=t.$createParagraphNode();this.getChildren().forEach(e=>n.append(e));const r=this.getParentOrThrow(),i=r.getParentOrThrow(),s=x(i);if(1===r.getChildrenSize())if(s)r.remove(),i.select();else{r.insertBefore(n),r.remove();const t=e.anchor,i=e.focus,s=n.getKey();"element"===t.type&&t.getNode().is(this)&&t.set(s,t.offset,"element"),"element"===i.type&&i.getNode().is(this)&&i.set(s,i.offset,"element")}else r.insertBefore(n),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 n=this.getParent();return k(n)&&(t=n.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(),n=0;for(;x(t);)t=t.getParentOrThrow().getParentOrThrow(),n++;return n}setIndent(e){"number"!=typeof e&&i(117),(e=Math.floor(e))>=0||i(199);let t=this.getIndent();for(;t!==e;)t<e?(m(this),t++):(_(this),t--);return this}canInsertAfter(e){return x(e)}canReplaceWith(e){return x(e)}canMergeWith(e){return x(e)||t.$isParagraphNode(e)}extractWithChild(e,n){if(!t.$isRangeSelection(n))return!1;const r=n.anchor.getNode(),i=n.focus.getNode();return this.isParentOf(r)&&this.isParentOf(i)&&this.getTextContent().length===n.getTextContent().length}isParentRequired(){return!0}createParentElementNode(){return v("bullet")}canMergeWhenEmpty(){return!0}}function T(e){if(e.classList.contains("task-list-item"))for(const t of e.children)if("INPUT"===t.tagName)return y(t);if(e.classList.contains("joplin-checkbox"))for(const t of e.children)if(t.classList.contains("checkbox-wrapper")&&t.children.length>0&&"INPUT"===t.children[0].tagName)return y(t.children[0]);const n=e.getAttribute("aria-checked"),r=O("true"===n||"false"!==n&&void 0);return t.$setFormatFromDOM(r,e),{after:S.bind(null,r),node:t.$setDirectionFromDOM(r,e)}}function y(e){if(!("checkbox"===e.getAttribute("type")))return{node:null};const t=O(e.hasAttribute("checked"));return{after:S.bind(null,t),node:t}}function S(e,n){const r=n[0];return 1===n.length&&t.$isParagraphNode(r)&&!e.getFormatType()&&r.getFormatType()?(e.setFormat(r.getFormatType()),r.getChildren()):n}function O(e){return t.$applyNodeReplacement(new N(void 0,e))}function x(e){return e instanceof N}class L extends t.ElementNode{__tag;__start;__listType;$config(){return this.config("list",{$transform:e=>{!function(e){const t=e.getNextSibling();k(t)&&e.getListType()===t.getListType()&&h(e,t)}(e),p(e)},extends:t.ElementNode,importDOM:t.buildImportMap({ol:()=>({conversion:E,priority:0}),ul:()=>({conversion:E,priority:0})})})}constructor(e="number",t=1,n){super(n);const r=M[e]||e;this.__listType=r,this.__tag="number"===r?"ol":"ul",this.__start=t}afterCloneFrom(e){super.afterCloneFrom(e),this.__listType=e.__listType,this.__tag=e.__tag,this.__start=e.__start}getTag(){return this.getLatest().__tag}setListType(e){const t=this.getWritable();return t.__listType=e,t.__tag="number"===e?"ol":"ul",t}getListType(){return this.getLatest().__listType}getStart(){return this.getLatest().__start}setStart(e){const t=this.getWritable();return t.__start=e,t}createDOM(e,n){const r=this.__tag,i=t.$getDocument().createElement(r);return 1!==this.__start&&i.setAttribute("start",String(this.__start)),i.__lexicalListType=this.__listType,$(i,e.theme,this),i}updateDOM(e,t,n){return e.__tag!==this.__tag||e.__listType!==this.__listType||($(t,n.theme,this),e.__start!==this.__start&&t.setAttribute("start",String(this.__start)),!1)}updateFromJSON(e){return super.updateFromJSON(e).setListType(e.listType).setStart(e.start)}exportDOM(e){const n=this.createDOM(e._config,e);return t.isHTMLElement(n)&&(1!==this.__start&&n.setAttribute("start",String(this.__start)),"check"===this.__listType&&n.setAttribute("__lexicalListType","check")),{element:n}}exportJSON(){return{...super.exportJSON(),listType:this.getListType(),start:this.getStart(),tag:this.getTag()}}canBeEmpty(){return!1}canIndent(){return!1}splice(e,n,r){let i=r;for(let e=0;e<r.length;e++){const n=r[e];x(n)||(i===r&&(i=[...r]),i[e]=this.createListItemNode().append(!t.$isElementNode(n)||k(n)||n.isInline()?n:t.$createTextNode(n.getTextContent())))}return super.splice(e,n,i)}extractWithChild(e){return x(e)}createListItemNode(){return O()}}function $(e,n,r){const i=[],o=[],l=n.list;if(void 0!==l){const e=l[`${r.__tag}Depth`]||[],n=s(r)-1,c=n%e.length,a=e[c],g=l[r.__tag];let u;const d=l.nested,h=l.checklist;if(void 0!==d&&d.list&&(u=d.list),void 0!==g&&i.push(g),void 0!==h&&"check"===r.__listType&&i.push(h),void 0!==a){i.push(...t.normalizeClassNames(a));for(let t=0;t<e.length;t++)t!==c&&o.push(r.__tag+t)}if(void 0!==u){const e=t.normalizeClassNames(u);n>1?i.push(...e):o.push(...e)}}o.length>0&&t.removeClassNamesFromElement(e,...o),i.length>0&&t.addClassNamesToElement(e,...i)}function E(e){let n;if(function(e){return t.isHTMLElement(e)&&"ol"===e.nodeName.toLowerCase()}(e)){const t=e.start;n=v("number",t)}else n=function(e){if("check"===e.getAttribute("__lexicallisttype")||e.classList.contains("contains-task-list")||"1"===e.getAttribute("data-is-checklist"))return!0;for(const n of e.childNodes)if(t.isHTMLElement(n)&&n.hasAttribute("aria-checked"))return!0;return!1}(e)?v("check"):v("bullet");return t.$setDirectionFromDOM(n,e),{after:e=>function(e,t){const n=t.createListItemNode.bind(t),r=[];for(let t=0;t<e.length;t++){const i=e[t];if(x(i)){r.push(i);const e=i.getChildren();e.length>1&&e.forEach(e=>{k(e)&&r.push(n().append(e))})}else r.push(n().append(i))}return r}(e,n),node:n}}const M={ol:"number",ul:"bullet"};function v(e="number",n=1){return t.$applyNodeReplacement(new L(e,n))}function k(e){return e instanceof L}const b=/* @__PURE__ */t.createCommand("INSERT_CHECK_LIST_COMMAND");function P(e,n){const r=n&&n.disableTakeFocusOnClick||!1,i="boolean"==typeof r?()=>r:r.peek.bind(r),s=e=>{const n=e.target;if(!t.isHTMLElement(n))return!1;const r=n.__lexicalCheckListLastHandled;return void 0!==r&&e.timeStamp-r<500},o=e=>{const n=e.target;t.isHTMLElement(n)&&(n.__lexicalCheckListLastHandled=e.timeStamp)},l=e=>{s(e)||(o(e),R(e,i()))},c=e=>{"touch"===e.pointerType&&(s(e)||(o(e),R(e,i())))},a=e=>{!function(e,t){I(e,()=>{e.preventDefault(),t&&e.stopPropagation()})}(e,i())};return t.mergeRegister(e.registerCommand(b,()=>(g("check"),!0),t.COMMAND_PRIORITY_LOW),e.registerCommand(t.KEY_ARROW_DOWN_COMMAND,t=>D(t,e,!1),t.COMMAND_PRIORITY_LOW),e.registerCommand(t.KEY_ARROW_UP_COMMAND,t=>D(t,e,!0),t.COMMAND_PRIORITY_LOW),e.registerCommand(t.KEY_ESCAPE_COMMAND,()=>{if(null!=A(e)){const t=e.getRootElement();return null!=t&&t.focus(),!0}return!1},t.COMMAND_PRIORITY_LOW),e.registerCommand(t.KEY_SPACE_COMMAND,n=>{const r=A(e);return!(null==r||!e.isEditable())&&(e.update(()=>{const e=t.$getNearestNodeFromDOMNode(r);x(e)&&(n.preventDefault(),e.toggleChecked())}),!0)},t.COMMAND_PRIORITY_LOW),e.registerCommand(t.KEY_ARROW_LEFT_COMMAND,n=>e.read("latest",()=>{const r=t.$getSelection();if(t.$isRangeSelection(r)&&r.isCollapsed()){const{anchor:i}=r,s="element"===i.type;if(s||0===i.offset){const r=i.getNode(),o=t.$findMatchingParent(r,e=>t.$isElementNode(e)&&!e.isInline());if(x(o)){const i=o.getParent();if(k(i)&&"check"===i.getListType()&&(s||o.getFirstDescendant()===r)){const r=e.getElementByKey(o.__key);if(null!=r&&t.getActiveElement(r)!==r)return r.focus(),n.preventDefault(),!0}}}}return!1}),t.COMMAND_PRIORITY_LOW),e.registerRootListener(e=>{if(null!==e)return t.mergeRegister(t.registerEventListeners(e,{click:l,pointerup:c}),t.registerEventListeners(e,{mousedown:a,pointerdown:a},{capture:!0}),t.registerEventListener(e,"touchstart",a,{capture:!0,passive:!1}))}))}function I(n,r){const i=n.target;if(!t.isHTMLElement(i))return;const s=i.firstChild;if(t.isHTMLElement(s)&&("UL"===s.tagName||"OL"===s.tagName))return;const o=i.parentNode;if(!o||"check"!==o.__lexicalListType)return;let l=null,c=null;if("clientX"in n)l=n.clientX;else if("touches"in n){const e=n.touches;e.length>0&&(l=e[0].clientX,c="touch")}if(null==l)return;const a=i.getBoundingClientRect(),g=l/e.calculateZoomLevel(i),u=i.ownerDocument.defaultView,d=u?u.getComputedStyle(i,"::before"):{width:"0px"},h=parseFloat(d.width),f="touch"===c||"pointerType"in n&&"touch"===n.pointerType?32:0;("rtl"===i.dir?g<a.right+f&&g>a.right-h-f:g>a.left-f&&g<a.left+h+f)&&r()}function R(e,n){I(e,()=>{if(t.isHTMLElement(e.target)){const r=e.target,i=t.getNearestEditorFromDOMNode(r);null!=i&&i.isEditable()&&i.update(()=>{const e=t.$getNearestNodeFromDOMNode(r);x(e)&&(n?(t.$addUpdateTag(t.SKIP_SELECTION_FOCUS_TAG),t.$addUpdateTag(t.SKIP_DOM_SELECTION_TAG)):r.focus(),e.toggleChecked())})}})}function A(e){const n=e.getRootElement(),r=n?t.getActiveElement(n):null;return t.isHTMLElement(r)&&"LI"===r.tagName&&null!=r.parentNode&&"check"===r.parentNode.__lexicalListType?r:null}function D(e,n,r){const i=A(n);return null!=i&&n.update(()=>{const s=t.$getNearestNodeFromDOMNode(i);if(!x(s))return;const o=function(e,t){let n=t?e.getPreviousSibling():e.getNextSibling(),r=e;for(;null==n&&x(r);)r=r.getParentOrThrow().getParent(),null!=r&&(n=t?r.getPreviousSibling():r.getNextSibling());for(;x(n);){const e=t?n.getLastChild():n.getFirstChild();if(!k(e))return n;n=t?e.getLastChild():e.getFirstChild()}return null}(s,r);if(null!=o){o.selectStart();const t=n.getElementByKey(o.__key);null!=t&&(e.preventDefault(),setTimeout(()=>{t.focus()},0))}}),!1}function F(e){const t=[];for(const n of e)if(x(n)){t.push(n);const e=n.getChildren();if(e.length>1)for(const n of e)k(n)&&t.push(O().append(n))}else t.push(O().append(n));return t}const w=/* @__PURE__ */r.defineImportRule({$import:(e,n)=>{let i;var s;return r.isElementOfTag(n,"ol")?i=v("number",n.start):i=(s=n).matches('[__lexicallisttype="check"], .contains-task-list, [data-is-checklist="1"]')||null!==s.querySelector(":scope > [aria-checked]")?v("check"):v("bullet"),t.$setDirectionFromDOM(i,n),[i.splice(0,0,r.$propagateTextAlignToBlockChildren(F(e.$importChildren(n)),n))]},match:r.sel.tag("ol","ul"),name:"@lexical/list/list"});function K(e,n){if(1!==n.length)return n;const r=n[0];return t.$isParagraphNode(r)&&!e.getFormatType()&&r.getFormatType()?(e.setFormat(r.getFormatType()),r.getChildren()):n}function W(e){const n=e=>r.$isBlockLevel(e)&&!k(e);if(!e.some(n))return e;const i=[];let s=[];const o=()=>{s.length>0&&(i.push(s),s=[])};for(const r of e)n(r)?(o(),i.push(t.$isElementNode(r)?r.getChildren():[r])):s.push(r);o();const l=[];for(const e of i)l.length>0&&l.push(t.$createLineBreakNode()),l.push(...e);return l}const B=/* @__PURE__ */r.defineImportRule({$import:(e,n)=>{const r=n.getAttribute("aria-checked"),i=O("true"===r||"false"!==r&&void 0);return t.$setFormatFromDOM(i,n),t.$setDirectionFromDOM(i,n),[i.splice(0,0,W(K(i,e.$importChildren(n))))]},match:r.sel.tag("li"),name:"@lexical/list/li"});function Y(e,n,i){const s=r.isElementOfTag(i,"input")?i:i.querySelector('input[type="checkbox"]');if(!s||"checkbox"!==s.getAttribute("type"))return[];const o=O(s.hasAttribute("checked"));return t.$setFormatFromDOM(o,n),t.$setDirectionFromDOM(o,n),[o.splice(0,0,W(K(o,e.$importChildren(n))))]}const H={$accepts:e=>x(e)||k(e),$packageRun:e=>[O().splice(0,0,e)],name:"ListSchema"},U=[/* @__PURE__ */r.defineImportRule({$import:(e,t,n)=>{const r=t.querySelector(':scope > input[type="checkbox"]');return r?Y(e,t,r):n()},match:r.sel.tag("li").classAll("task-list-item"),name:"@lexical/list/li-task-list-item"}),/* @__PURE__ */r.defineImportRule({$import:(e,t,n)=>{const r=t.querySelector(":scope > .checkbox-wrapper");if(!r)return n();const i=r.querySelector(':scope > input[type="checkbox"]');return i?Y(e,t,i):n()},match:r.sel.tag("li").classAll("joplin-checkbox"),name:"@lexical/list/li-joplin-checkbox"}),w,B],z=/* @__PURE__ */t.createCommand("UPDATE_LIST_START_COMMAND"),q=/* @__PURE__ */t.createCommand("INSERT_UNORDERED_LIST_COMMAND"),V=/* @__PURE__ */t.createCommand("INSERT_ORDERED_LIST_COMMAND"),J=/* @__PURE__ */t.createCommand("REMOVE_LIST_COMMAND");function j(e,n){return t.mergeRegister(e.registerCommand(V,()=>(g("number"),!0),t.COMMAND_PRIORITY_LOW),e.registerCommand(z,e=>{const{listNodeKey:n,newStart:r}=e,i=t.$getNodeByKey(n);return!!k(i)&&("number"===i.getListType()&&(i.setStart(r),p(i)),!0)},t.COMMAND_PRIORITY_LOW),e.registerCommand(q,()=>(g("bullet"),!0),t.COMMAND_PRIORITY_LOW),e.registerCommand(J,()=>(f(),!0),t.COMMAND_PRIORITY_LOW),e.registerCommand(t.INSERT_PARAGRAPH_COMMAND,()=>C(!!(n&&n.restoreNumbering)),t.COMMAND_PRIORITY_LOW),e.registerCommand(t.KEY_BACKSPACE_COMMAND,e=>!!function(){const e=t.$getSelection();if(!t.$isRangeSelection(e)||!e.isCollapsed()||0!==e.anchor.offset)return!1;const n=e.anchor.getNode(),r=t.$findMatchingParent(n,x);if(!x(r))return!1;const i=r.getFirstDescendant();if(null===i)return!1;if(!r.is(n)&&!i.is(n))return!1;const s=r.getParent();if(!k(s)||!r.is(s.getFirstChild()))return!1;const o=s.getPreviousSibling();if(!t.$isDecoratorNode(o)||o.isIsolated()||!o.isKeyboardSelectable()&&o.isInline())return!1;const l=t.$createParagraphNode().append(...r.getChildren());s.insertBefore(l),r.remove(),s.isEmpty()&&s.remove();return l.selectStart(),!0}()&&(e.preventDefault(),!0),t.COMMAND_PRIORITY_BEFORE_EDITOR),e.registerNodeTransform(N,e=>{const n=e.getFirstChild();if(n){if(t.$isTextNode(n)){const t=n.getStyle(),r=n.getFormat();e.getTextStyle()!==t&&e.setTextStyle(t),e.getTextFormat()!==r&&e.setTextFormat(r)}}else{const n=t.$getSelection();t.$isRangeSelection(n)&&(n.style!==e.getTextStyle()||n.format!==e.getTextFormat())&&n.isCollapsed()&&e.is(n.anchor.getNode())&&e.setTextStyle(n.style).setTextFormat(n.format)}}),e.registerNodeTransform(t.TextNode,e=>{const t=e.getParent();if(x(t)&&e.is(t.getFirstChild())){const n=e.getStyle(),r=e.getFormat();n===t.getTextStyle()&&r===t.getTextFormat()||t.setTextStyle(n).setTextFormat(r)}}))}function G(e){const n=e=>{const n=e.getParent();if(k(e.getFirstChild())||!k(n))return;const r=t.$findMatchingParent(e,e=>x(e)&&k(e.getParent())&&x(e.getPreviousSibling()));if(null===r&&e.getIndent()>0)e.setIndent(0);else if(x(r)){const t=r.getPreviousSibling();if(x(t)){const r=function(e){let t=e,n=t.getFirstChild();for(;k(n);){const e=n.getLastChild();if(!x(e))break;t=e,n=t.getFirstChild()}return t}(t),i=r.getParent();if(k(i)){const t=s(i);t+1<s(n)&&e.setIndent(t)}}}};return e.registerNodeTransform(L,e=>{const t=[e];for(;t.length>0;){const e=t.shift();if(k(e))for(const r of e.getChildren())if(x(r)){n(r);const e=r.getFirstChild();k(e)&&t.push(e)}}})}const X=/* @__PURE__ */t.defineExtension({build:(e,t,r)=>n.namedSignals(t),config:/* @__PURE__ */t.safeCast({hasStrictIndent:!1,shouldPreserveNumbering:!1}),dependencies:[r.CoreImportExtension,/* @__PURE__ */t.configExtension(r.DOMImportExtension,{rules:U})],name:"@lexical/list/List",nodes:()=>[L,N],register(e,r,i){const s=i.getOutput();return t.mergeRegister(n.effect(()=>j(e,{restoreNumbering:s.shouldPreserveNumbering.value})),n.effect(()=>s.hasStrictIndent.value?G(e):void 0))}}),Z=/* @__PURE__ */t.defineExtension({build:(e,t)=>n.namedSignals(t),config:/* @__PURE__ */t.safeCast({disableTakeFocusOnClick:!1}),dependencies:[X],name:"@lexical/list/CheckList",register:(e,t,n)=>P(e,n.getOutput())}),Q=/* @__PURE__ */t.defineExtension({dependencies:[X],name:"@lexical/list/Import"});exports.$createListItemNode=O,exports.$createListNode=v,exports.$getListDepth=s,exports.$handleListInsertParagraph=C,exports.$insertList=g,exports.$isListItemNode=x,exports.$isListNode=k,exports.$removeList=f,exports.CheckListExtension=Z,exports.INSERT_CHECK_LIST_COMMAND=b,exports.INSERT_ORDERED_LIST_COMMAND=V,exports.INSERT_UNORDERED_LIST_COMMAND=q,exports.ListExtension=X,exports.ListImportExtension=Q,exports.ListImportRules=U,exports.ListItemNode=N,exports.ListNode=L,exports.ListSchema=H,exports.REMOVE_LIST_COMMAND=J,exports.UPDATE_LIST_START_COMMAND=z,exports.registerCheckList=P,exports.registerList=j,exports.registerListStrictIndentTransform=G;
9
+ "use strict";var e=require("@lexical/utils"),t=require("lexical"),n=require("@lexical/extension"),r=require("@lexical/html");function i(e,...t){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",e);for(const e of t)r.append("v",e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.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,n=e.getParent();for(;null!=n;){if(x(n)){const e=n.getParent();if(b(e)){t++,n=e.getParent();continue}i(40)}return t}return t}function o(e){const t=e.getParent();b(t)||i(40);let n=t,r=t;for(;null!==r;)r=r.getParent(),b(r)&&(n=r);return n}function l(e){let t=[];const n=e.getChildren().filter(x);for(let e=0;e<n.length;e++){const r=n[e],i=r.getFirstChild();b(i)?t=t.concat(l(i)):t.push(r)}return t}function c(e){return x(e)&&b(e.getFirstChild())}function a(e,t){return x(e)&&(0===t.length||1===t.length&&e.is(t[0])&&0===e.getChildrenSize())}function g(e){const n=t.$getSelection();if(null!==n){let r=n.getNodes();if(t.$isRangeSelection(n)){const[i]=n.getStartEndPoints(),s=i.getNode(),o=s.getParent();if(t.$isRootOrShadowRoot(s)){const e=s.getFirstChild();if(e)r=e.selectStart().getNodes();else{const e=t.$createParagraphNode();s.append(e),r=e.select().getNodes()}}else if(a(s,r)){const n=M(e);if(t.$isRootOrShadowRoot(o)){s.replace(n);const e=O();t.$isElementNode(s)&&(e.setFormat(s.getFormatType()),e.setIndent(s.getIndent())),n.append(e)}else if(x(s)){const e=s.getParentOrThrow();u(n,e.getChildren()),e.replace(n)}return}}const i=new Set;for(let n=0;n<r.length;n++){const s=r[n];if(t.$isElementNode(s)&&s.isEmpty()&&!x(s)&&!i.has(s.getKey())){d(s,e);continue}let o=t.$isLeafNode(s)?s.getParent():x(s)&&s.isEmpty()?s:null;for(;null!=o;){const n=o.getKey();if(b(o)){if(!i.has(n)){const t=M(e);u(t,o.getChildren()),o.replace(t),i.add(n)}break}{const r=o.getParent();if(t.$isRootOrShadowRoot(r)&&!i.has(n)){i.add(n),d(o,e);break}o=r}}}}}function u(e,t){e.splice(e.getChildrenSize(),0,t)}function d(e,n){if(b(e))return e;const r=e.getPreviousSibling(),i=e.getNextSibling(),s=O();let o;if(u(s,e.getChildren()),b(r)&&n===r.getListType())r.append(s),b(i)&&n===i.getListType()&&(u(r,i.getChildren()),i.remove()),o=r;else if(b(i)&&n===i.getListType())i.getFirstChildOrThrow().insertBefore(s),o=i;else{const t=M(n);t.append(s),e.replace(t),o=t}s.setFormat(e.getFormatType()),s.setIndent(e.getIndent());const l=t.$getSelection();return t.$isRangeSelection(l)&&(o.getKey()===l.anchor.key&&l.anchor.set(s.getKey(),l.anchor.offset,"element"),o.getKey()===l.focus.key&&l.focus.set(s.getKey(),l.focus.offset,"element")),e.remove(),o}function h(e,t){const n=e.getLastChild(),r=t.getFirstChild();n&&r&&c(n)&&c(r)&&(h(n.getFirstChild(),r.getFirstChild()),r.remove());const i=t.getChildren();i.length>0&&e.append(...i),t.remove()}function f(){const n=t.$getSelection();if(t.$isRangeSelection(n)){const r=new Set,i=n.getNodes(),s=n.anchor.getNode();if(a(s,i))r.add(o(s));else for(let n=0;n<i.length;n++){const s=i[n];if(t.$isLeafNode(s)){const t=e.$getNearestNodeOfType(s,N);null!=t&&r.add(o(t))}}for(const e of r){let r=e;const i=l(e);for(const e of i){const i=t.$createParagraphNode().setTextStyle(n.style).setTextFormat(n.format);u(i,e.getChildren()),r.insertAfter(i),r=i,e.__key===n.anchor.key&&t.$setPointFromCaret(n.anchor,t.$normalizeCaret(t.$getChildCaret(i,"next"))),e.__key===n.focus.key&&t.$setPointFromCaret(n.focus,t.$normalizeCaret(t.$getChildCaret(i,"next"))),e.remove()}e.remove()}}}function p(e){const t="check"!==e.getListType();let n=e.getStart();for(const r of e.getChildren())x(r)&&(r.getValue()!==n&&r.setValue(n),t&&null!=r.getLatest().__checked&&r.setChecked(void 0),b(r.getFirstChild())||n++)}function m(e){const n=new Set;if(c(e)||n.has(e.getKey()))return;const r=e.getParent(),i=e.getNextSibling(),s=e.getPreviousSibling();if(c(i)&&c(s)){const t=s.getFirstChild();if(b(t)){t.append(e);const r=i.getFirstChild();if(b(r)){u(t,r.getChildren()),i.remove(),n.add(i.getKey())}}}else if(c(i)){const t=i.getFirstChild();if(b(t)){const n=t.getFirstChild();null!==n&&n.insertBefore(e)}}else if(c(s)){const t=s.getFirstChild();b(t)&&t.append(e)}else if(b(r)){const n=t.$copyNode(e),o=t.$copyNode(r);n.append(o),o.append(e),s?s.insertAfter(n):i?i.insertBefore(n):r.append(n)}}function _(e){if(c(e))return;const n=e.getParent(),r=n?n.getParent():void 0;if(b(r?r.getParent():void 0)&&x(r)&&b(n)){const i=n?n.getFirstChild():void 0,s=n?n.getLastChild():void 0;if(e.is(i))r.insertBefore(e),n.isEmpty()&&r.remove();else if(e.is(s))r.insertAfter(e),n.isEmpty()&&r.remove();else{const i=t.$copyNode(e),s=t.$copyNode(n);i.append(s),e.getPreviousSiblings().forEach(e=>s.append(e));const o=t.$copyNode(e),l=t.$copyNode(n);o.append(l),u(l,e.getNextSiblings()),r.insertBefore(i),r.insertAfter(o),r.replace(e)}}}function C(e=!1){const n=t.$getSelection();if(!t.$isRangeSelection(n)||!n.isCollapsed())return!1;const r=n.anchor.getNode();let s=null;if(x(r)&&0===r.getChildrenSize())s=r;else if(t.$isTextNode(r)){const e=r.getParent();x(e)&&e.getChildren().every(e=>t.$isTextNode(e)&&""===e.getTextContent().trim())&&(s=e)}if(null===s)return!1;const l=o(s),c=s.getParent();b(c)||i(40);const a=c.getParent();let g;if(t.$isRootOrShadowRoot(a))g=t.$createParagraphNode(),l.insertAfter(g);else{if(!x(a))return!1;g=t.$copyNode(a),a.insertAfter(g)}g.setTextStyle(n.style).setTextFormat(n.format).select();const u=s.getNextSiblings();if(u.length>0){const n=e?function(e,t){return e.getStart()+t.getIndexWithinParent()}(c,s):1,r=t.$copyNode(c).setStart(n);if(x(g)){const e=t.$copyNode(g);e.append(r),g.insertAfter(e)}else g.insertAfter(r);r.append(...u)}return function(e){let t=e;for(;null==t.getNextSibling()&&null==t.getPreviousSibling();){const e=t.getParent();if(null==e||!x(e)&&!b(e))break;t=e}t.remove()}(s),!0}class N extends t.ElementNode{__value;__checked;$config(){return this.config("listitem",{$transform:e=>{const n=e.getParent();if(b(n))"check"!==n.getListType()&&null!=e.getChecked()&&e.setChecked(void 0);else if(n){const r=e.createParentElementNode();b(r)||i(340);const s=[e];for(const n of["previous","next"]){s.reverse();for(const{origin:r}of t.$getSiblingCaret(e,n)){if(!x(r))break;s.push(r)}}e.insertBefore(r),r.splice(0,0,s),t.$isRootOrShadowRoot(n)||(t.$insertNodeToNearestRootAtCaret(r,t.$rewindSiblingCaret(t.$getSiblingCaret(r,"next")),{$shouldSplit:()=>!1,removeEmptyDestination:!0}),n.isEmpty()&&n.isAttached()&&n.remove())}},extends:t.ElementNode,importDOM:t.buildImportMap({li:()=>({conversion:S,priority:0})})})}constructor(e=1,t=void 0,n){super(n),this.__value=void 0===e?1:e,this.__checked=t}afterCloneFrom(e){super.afterCloneFrom(e),this.__value=e.__value,this.__checked=e.__checked}createDOM(e){const n=t.$getDocument().createElement("li");return this.updateListItemDOM(null,n,e),n}updateListItemDOM(e,n,r){!function(e,t){const n=t.getParent();!b(n)||"check"!==n.getListType()||b(t.getFirstChild())?(e.removeAttribute("role"),e.removeAttribute("tabIndex"),e.removeAttribute("aria-checked")):(e.setAttribute("role","checkbox"),e.setAttribute("tabIndex","-1"),e.setAttribute("aria-checked",t.getChecked()?"true":"false"))}(n,this),n.value=this.__value,function(e,n,r){const i=n.list;if(!i)return;const s=i.listitem,o=i.nested&&i.nested.listitem,l=r.getParent(),c=b(l)&&"check"===l.getListType(),a=r.getChecked(),g=r.getChildren().some(e=>b(e)),u=[];void 0!==i.listitemChecked&&u.push(i.listitemChecked);void 0!==i.listitemUnchecked&&u.push(i.listitemUnchecked);void 0!==o&&u.push(...t.normalizeClassNames(o));u.length>0&&t.removeClassNamesFromElement(e,...u);const d=[];void 0!==s&&d.push(...t.normalizeClassNames(s));if(c){const e=a?i.listitemChecked:i.listitemUnchecked;void 0!==e&&d.push(e)}void 0!==o&&g&&d.push(...t.normalizeClassNames(o));d.length>0&&t.addClassNamesToElement(e,...d)}(n,r.theme,this);const i=e?e.__style:"",s=this.__style;i!==s&&t.setDOMStyleFromCSS(n.style,s,i),function(e,n,r){const i=n.__textStyle,s=r?r.__textStyle:"";if(null!==r&&s===i)return;const o=t.getStyleObjectFromCSS(i);for(const t in o)e.style.setProperty(`--listitem-marker-${t}`,o[t]);if(""!==s)for(const n in t.getStyleObjectFromCSS(s))n in o||e.style.removeProperty(`--listitem-marker-${n}`)}(n,this,e)}updateDOM(e,t,n){const r=t;return this.updateListItemDOM(e,r,n),!1}updateFromJSON(e){return super.updateFromJSON(e).setValue(e.value).setChecked(e.checked)}exportDOM(e){const n=this.createDOM(e._config),r=this.getFormatType();r&&(n.style.textAlign=r);const i=this.getDirection();return i&&(n.dir=i),c(this)?{after(e){if(t.isHTMLElement(e)){const n=e.previousElementSibling;if(t.isHTMLElement(n)&&"LI"===n.nodeName){for(;e.firstChild;)n.append(e.firstChild);e.remove()}}return e},element:n}:{element:n}}exportJSON(){return{...super.exportJSON(),checked:this.getChecked(),value:this.getValue()}}append(...e){for(let n=0;n<e.length;n++){const r=e[n];if(t.$isElementNode(r)&&this.canMergeWith(r)){const e=r.getChildren();this.append(...e),r.remove()}else super.append(r)}return this}replace(e,n){if(x(e))return super.replace(e);this.setIndent(0);const r=this.getParentOrThrow();if(!b(r))return e;if(r.__first===this.getKey())r.insertBefore(e);else if(r.__last===this.getKey())r.insertAfter(e);else{const n=t.$copyNode(r);let i=this.getNextSibling();for(;i;){const e=i;i=i.getNextSibling(),n.append(e)}r.insertAfter(e),e.insertAfter(n)}const s=this.__key;let o=0;if(n&&(t.$isElementNode(e)||i(139),o=e.getChildrenSize(),e.splice(o,0,this.getChildren())),n&&t.$isElementNode(e)){const n=t.$getSelection();if(t.$isRangeSelection(n))for(const t of n.getStartEndPoints())t.key===s&&"element"===t.type&&t.set(e.getKey(),o+t.offset,"element")}return this.remove(),0===r.getChildrenSize()&&r.remove(),e}insertAfter(e,n=!0){const r=this.getParentOrThrow();if(b(r)||i(39),x(e))return super.insertAfter(e,n);const s=this.getNextSiblings();if(r.insertAfter(e,n),0!==s.length){const i=t.$copyNode(r);s.forEach(e=>i.append(e)),e.insertAfter(i,n)}return e}remove(e){const t=this.getPreviousSibling(),n=this.getNextSibling();super.remove(e),t&&n&&c(t)&&c(n)&&(h(t.getFirstChild(),n.getFirstChild()),n.remove())}resetOnCopyNodeFrom(e){super.resetOnCopyNodeFrom(e),e.getChecked()&&this.setChecked(!1)}insertNewAfter(e,n=!0){const r=t.$copyNode(this);return this.insertAfter(r,n),r}collapseAtStart(e){if(c(this))return!1;const n=this.getParentOrThrow();if(x(n.getParentOrThrow()))return _(this),!0;const r=t.$createParagraphNode().append(...this.getChildren()),i=this.getNextSiblings();if(i.length>0){const e=t.$copyNode(n);e.append(...i),n.insertAfter(e)}return n.insertAfter(r),this.remove(),0===n.getChildrenSize()&&n.remove(),r.selectStart(),!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 n=this.getParent();return b(n)&&(t=n.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(),n=0;for(;x(t);)t=t.getParentOrThrow().getParentOrThrow(),n++;return n}setIndent(e){"number"!=typeof e&&i(117),(e=Math.floor(e))>=0||i(199);let t=this.getIndent();for(;t!==e;)t<e?(m(this),t++):(_(this),t--);return this}canInsertAfter(e){return x(e)}canReplaceWith(e){return x(e)}canMergeWith(e){return x(e)||t.$isParagraphNode(e)}extractWithChild(e,n){if(!t.$isRangeSelection(n))return!1;const r=n.anchor.getNode(),i=n.focus.getNode();return this.isParentOf(r)&&this.isParentOf(i)&&this.getTextContent().length===n.getTextContent().length}isParentRequired(){return!0}createParentElementNode(){return M("bullet")}canMergeWhenEmpty(){return!0}}function S(e){if(e.classList.contains("task-list-item"))for(const t of e.children)if("INPUT"===t.tagName)return T(t);if(e.classList.contains("joplin-checkbox"))for(const t of e.children)if(t.classList.contains("checkbox-wrapper")&&t.children.length>0&&"INPUT"===t.children[0].tagName)return T(t.children[0]);const n=e.getAttribute("aria-checked"),r=O("true"===n||"false"!==n&&void 0);return t.$setFormatFromDOM(r,e),{after:y.bind(null,r),node:t.$setDirectionFromDOM(r,e)}}function T(e){if(!("checkbox"===e.getAttribute("type")))return{node:null};const t=O(e.hasAttribute("checked"));return{after:y.bind(null,t),node:t}}function y(e,n){const r=n[0];return 1===n.length&&t.$isParagraphNode(r)&&!e.getFormatType()&&r.getFormatType()?(e.setFormat(r.getFormatType()),r.getChildren()):n}function O(e){return t.$applyNodeReplacement(new N(void 0,e))}function x(e){return e instanceof N}class $ extends t.ElementNode{__tag;__start;__listType;$config(){return this.config("list",{$transform:e=>{!function(e){const t=e.getNextSibling();b(t)&&e.getListType()===t.getListType()&&h(e,t)}(e),p(e)},extends:t.ElementNode,importDOM:t.buildImportMap({ol:()=>({conversion:E,priority:0}),ul:()=>({conversion:E,priority:0})})})}constructor(e="number",t=1,n){super(n);const r=v[e]||e;this.__listType=r,this.__tag="number"===r?"ol":"ul",this.__start=t}afterCloneFrom(e){super.afterCloneFrom(e),this.__listType=e.__listType,this.__tag=e.__tag,this.__start=e.__start}getTag(){return this.getLatest().__tag}setListType(e){const t=this.getWritable();return t.__listType=e,t.__tag="number"===e?"ol":"ul",t}getListType(){return this.getLatest().__listType}getStart(){return this.getLatest().__start}setStart(e){const t=this.getWritable();return t.__start=e,t}createDOM(e,n){const r=this.__tag,i=t.$getDocument().createElement(r);return 1!==this.__start&&i.setAttribute("start",String(this.__start)),i.__lexicalListType=this.__listType,L(i,e.theme,this),i}updateDOM(e,t,n){return e.__tag!==this.__tag||e.__listType!==this.__listType||(L(t,n.theme,this),e.__start!==this.__start&&t.setAttribute("start",String(this.__start)),!1)}updateFromJSON(e){return super.updateFromJSON(e).setListType(e.listType).setStart(e.start)}exportDOM(e){const n=this.createDOM(e._config,e);return t.isHTMLElement(n)&&(1!==this.__start&&n.setAttribute("start",String(this.__start)),"check"===this.__listType&&n.setAttribute("__lexicalListType","check")),{element:n}}exportJSON(){return{...super.exportJSON(),listType:this.getListType(),start:this.getStart(),tag:this.getTag()}}canBeEmpty(){return!1}canIndent(){return!1}splice(e,n,r){let i=r;for(let e=0;e<r.length;e++){const n=r[e];x(n)||(i===r&&(i=[...r]),i[e]=this.createListItemNode().append(!t.$isElementNode(n)||b(n)||n.isInline()?n:t.$createTextNode(n.getTextContent())))}return super.splice(e,n,i)}extractWithChild(e){return x(e)}createListItemNode(){return O()}}function L(e,n,r){const i=[],o=[],l=n.list;if(void 0!==l){const e=l[`${r.__tag}Depth`]||[],n=s(r)-1,c=n%e.length,a=e[c],g=l[r.__tag];let u;const d=l.nested,h=l.checklist;if(void 0!==d&&d.list&&(u=d.list),void 0!==g&&i.push(g),void 0!==h&&"check"===r.__listType&&i.push(h),void 0!==a){i.push(...t.normalizeClassNames(a));for(let t=0;t<e.length;t++)t!==c&&o.push(r.__tag+t)}if(void 0!==u){const e=t.normalizeClassNames(u);n>1?i.push(...e):o.push(...e)}}o.length>0&&t.removeClassNamesFromElement(e,...o),i.length>0&&t.addClassNamesToElement(e,...i)}function E(e){let n;if(function(e){return t.isHTMLElement(e)&&"ol"===e.nodeName.toLowerCase()}(e)){const t=e.start;n=M("number",t)}else n=function(e){if("check"===e.getAttribute("__lexicallisttype")||e.classList.contains("contains-task-list")||"1"===e.getAttribute("data-is-checklist"))return!0;for(const n of e.childNodes)if(t.isHTMLElement(n)&&n.hasAttribute("aria-checked"))return!0;return!1}(e)?M("check"):M("bullet");return t.$setDirectionFromDOM(n,e),{after:e=>function(e,t){const n=t.createListItemNode.bind(t),r=[];for(let t=0;t<e.length;t++){const i=e[t];if(x(i)){r.push(i);const e=i.getChildren();e.length>1&&e.forEach(e=>{b(e)&&r.push(n().append(e))})}else r.push(n().append(i))}return r}(e,n),node:n}}const v={ol:"number",ul:"bullet"};function M(e="number",n=1){return t.$applyNodeReplacement(new $(e,n))}function b(e){return e instanceof $}const k=/* @__PURE__ */t.createCommand("INSERT_CHECK_LIST_COMMAND");function P(e,n){const r=n&&n.disableTakeFocusOnClick||!1,i="boolean"==typeof r?()=>r:r.peek.bind(r),s=e=>{const n=e.target;if(!t.isHTMLElement(n))return!1;const r=n.__lexicalCheckListLastHandled;return void 0!==r&&e.timeStamp-r<500},o=e=>{const n=e.target;t.isHTMLElement(n)&&(n.__lexicalCheckListLastHandled=e.timeStamp)},l=e=>{s(e)||(o(e),I(e,i()))},c=e=>{"touch"===e.pointerType&&(s(e)||(o(e),I(e,i())))},a=e=>{!function(e,t){A(e,()=>{e.preventDefault(),t&&e.stopPropagation()})}(e,i())};return t.mergeRegister(e.registerCommand(k,()=>(g("check"),!0),t.COMMAND_PRIORITY_LOW),e.registerCommand(t.KEY_ARROW_DOWN_COMMAND,t=>D(t,e,!1),t.COMMAND_PRIORITY_LOW),e.registerCommand(t.KEY_ARROW_UP_COMMAND,t=>D(t,e,!0),t.COMMAND_PRIORITY_LOW),e.registerCommand(t.KEY_ESCAPE_COMMAND,()=>{if(null!=R(e)){const t=e.getRootElement();return null!=t&&t.focus(),!0}return!1},t.COMMAND_PRIORITY_LOW),e.registerCommand(t.KEY_SPACE_COMMAND,n=>{const r=R(e);return!(null==r||!e.isEditable())&&(e.update(()=>{const e=t.$getNearestNodeFromDOMNode(r);x(e)&&(n.preventDefault(),e.toggleChecked())}),!0)},t.COMMAND_PRIORITY_LOW),e.registerCommand(t.KEY_ARROW_LEFT_COMMAND,n=>e.read("latest",()=>{const r=t.$getSelection();if(t.$isRangeSelection(r)&&r.isCollapsed()){const{anchor:i}=r,s="element"===i.type;if(s||0===i.offset){const r=i.getNode(),o=t.$findMatchingParent(r,e=>t.$isElementNode(e)&&!e.isInline());if(x(o)){const i=o.getParent();if(b(i)&&"check"===i.getListType()&&(s||o.getFirstDescendant()===r)){const r=e.getElementByKey(o.__key);if(null!=r&&t.getActiveElement(r)!==r)return r.focus(),n.preventDefault(),!0}}}}return!1}),t.COMMAND_PRIORITY_LOW),e.registerRootListener(e=>{if(null!==e)return t.mergeRegister(t.registerEventListeners(e,{click:l,pointerup:c}),t.registerEventListeners(e,{mousedown:a,pointerdown:a},{capture:!0}),t.registerEventListener(e,"touchstart",a,{capture:!0,passive:!1}))}))}function A(n,r){const i=n.target;if(!t.isHTMLElement(i))return;const s=i.firstChild;if(t.isHTMLElement(s)&&("UL"===s.tagName||"OL"===s.tagName))return;const o=i.parentNode;if(!o||"check"!==o.__lexicalListType)return;let l=null,c=null;if("clientX"in n)l=n.clientX;else if("touches"in n){const e=n.touches;e.length>0&&(l=e[0].clientX,c="touch")}if(null==l)return;const a=i.getBoundingClientRect(),g=l/e.calculateZoomLevel(i),u=i.ownerDocument.defaultView,d=u?u.getComputedStyle(i,"::before"):{width:"0px"},h=parseFloat(d.width),f="touch"===c||"pointerType"in n&&"touch"===n.pointerType?32:0;("rtl"===i.dir?g<a.right+f&&g>a.right-h-f:g>a.left-f&&g<a.left+h+f)&&r()}function I(e,n){A(e,()=>{if(t.isHTMLElement(e.target)){const r=e.target,i=t.getNearestEditorFromDOMNode(r);null!=i&&i.isEditable()&&i.update(()=>{const e=t.$getNearestNodeFromDOMNode(r);x(e)&&(n?(t.$addUpdateTag(t.SKIP_SELECTION_FOCUS_TAG),t.$addUpdateTag(t.SKIP_DOM_SELECTION_TAG)):r.focus(),e.toggleChecked())})}})}function R(e){const n=e.getRootElement(),r=n?t.getActiveElement(n):null;return t.isHTMLElement(r)&&"LI"===r.tagName&&null!=r.parentNode&&"check"===r.parentNode.__lexicalListType?r:null}function D(e,n,r){const i=R(n);return null!=i&&n.update(()=>{const s=t.$getNearestNodeFromDOMNode(i);if(!x(s))return;const o=function(e,t){let n=t?e.getPreviousSibling():e.getNextSibling(),r=e;for(;null==n&&x(r);)r=r.getParentOrThrow().getParent(),null!=r&&(n=t?r.getPreviousSibling():r.getNextSibling());for(;x(n);){const e=t?n.getLastChild():n.getFirstChild();if(!b(e))return n;n=t?e.getLastChild():e.getFirstChild()}return null}(s,r);if(null!=o){o.selectStart();const t=n.getElementByKey(o.__key);null!=t&&(e.preventDefault(),setTimeout(()=>{t.focus()},0))}}),!1}function F(e){const t=[];for(const n of e)if(x(n)){t.push(n);const e=n.getChildren();if(e.length>1)for(const n of e)b(n)&&t.push(O().append(n))}else t.push(O().append(n));return t}const w=/* @__PURE__ */r.defineImportRule({$import:(e,n)=>{let i;var s;return r.isElementOfTag(n,"ol")?i=M("number",n.start):i=(s=n).matches('[__lexicallisttype="check"], .contains-task-list, [data-is-checklist="1"]')||null!==s.querySelector(":scope > [aria-checked]")?M("check"):M("bullet"),t.$setDirectionFromDOM(i,n),[i.splice(0,0,r.$propagateTextAlignToBlockChildren(F(e.$importChildren(n)),n))]},match:r.sel.tag("ol","ul"),name:"@lexical/list/list"});function K(e,n){if(1!==n.length)return n;const r=n[0];return t.$isParagraphNode(r)&&!e.getFormatType()&&r.getFormatType()?(e.setFormat(r.getFormatType()),r.getChildren()):n}function W(e){const n=e=>r.$isBlockLevel(e)&&!b(e);if(!e.some(n))return e;const i=[];let s=[];const o=()=>{s.length>0&&(i.push(s),s=[])};for(const r of e)n(r)?(o(),i.push(t.$isElementNode(r)?r.getChildren():[r])):s.push(r);o();const l=[];for(const e of i)l.length>0&&l.push(t.$createLineBreakNode()),l.push(...e);return l}const B=/* @__PURE__ */r.defineImportRule({$import:(e,n)=>{const r=n.getAttribute("aria-checked"),i=O("true"===r||"false"!==r&&void 0);return t.$setFormatFromDOM(i,n),t.$setDirectionFromDOM(i,n),[i.splice(0,0,W(K(i,e.$importChildren(n))))]},match:r.sel.tag("li"),name:"@lexical/list/li"});function Y(e,n,i){const s=r.isElementOfTag(i,"input")?i:i.querySelector('input[type="checkbox"]');if(!s||"checkbox"!==s.getAttribute("type"))return[];const o=O(s.hasAttribute("checked"));return t.$setFormatFromDOM(o,n),t.$setDirectionFromDOM(o,n),[o.splice(0,0,W(K(o,e.$importChildren(n))))]}const H={$accepts:e=>x(e)||b(e),$packageRun:e=>[O().splice(0,0,e)],name:"ListSchema"},U=[/* @__PURE__ */r.defineImportRule({$import:(e,t,n)=>{const r=t.querySelector(':scope > input[type="checkbox"]');return r?Y(e,t,r):n()},match:r.sel.tag("li").classAll("task-list-item"),name:"@lexical/list/li-task-list-item"}),/* @__PURE__ */r.defineImportRule({$import:(e,t,n)=>{const r=t.querySelector(":scope > .checkbox-wrapper");if(!r)return n();const i=r.querySelector(':scope > input[type="checkbox"]');return i?Y(e,t,i):n()},match:r.sel.tag("li").classAll("joplin-checkbox"),name:"@lexical/list/li-joplin-checkbox"}),w,B],z=/* @__PURE__ */t.createCommand("UPDATE_LIST_START_COMMAND"),q=/* @__PURE__ */t.createCommand("INSERT_UNORDERED_LIST_COMMAND"),V=/* @__PURE__ */t.createCommand("INSERT_ORDERED_LIST_COMMAND"),J=/* @__PURE__ */t.createCommand("REMOVE_LIST_COMMAND");function j(e,n){return t.mergeRegister(e.registerCommand(V,()=>(g("number"),!0),t.COMMAND_PRIORITY_LOW),e.registerCommand(z,e=>{const{listNodeKey:n,newStart:r}=e,i=t.$getNodeByKey(n);return!!b(i)&&("number"===i.getListType()&&(i.setStart(r),p(i)),!0)},t.COMMAND_PRIORITY_LOW),e.registerCommand(q,()=>(g("bullet"),!0),t.COMMAND_PRIORITY_LOW),e.registerCommand(J,()=>(f(),!0),t.COMMAND_PRIORITY_LOW),e.registerCommand(t.INSERT_PARAGRAPH_COMMAND,()=>C(!!(n&&n.restoreNumbering)),t.COMMAND_PRIORITY_LOW),e.registerCommand(t.KEY_BACKSPACE_COMMAND,e=>{if(function(){const e=t.$getSelection();if(!t.$isRangeSelection(e)||!e.isCollapsed()||0!==e.anchor.offset)return!1;const n=e.anchor.getNode(),r=t.$findMatchingParent(n,x);if(!x(r))return!1;const i=r.getFirstDescendant();if(null===i)return!1;if(!r.is(n)&&!i.is(n))return!1;const s=r.getParent();if(!b(s)||!r.is(s.getFirstChild()))return!1;const o=s.getPreviousSibling();if(!t.$isDecoratorNode(o)||o.isIsolated()||!o.isKeyboardSelectable()&&o.isInline())return!1;const l=t.$createParagraphNode().append(...r.getChildren());s.insertBefore(l),r.remove(),s.isEmpty()&&s.remove();return l.selectStart(),!0}())return e.preventDefault(),!0;const n=t.$getSelection();if(!t.$isRangeSelection(n)||!n.isCollapsed())return!1;const{anchor:r}=n;if(0!==r.offset)return!1;let i=r.getNode();for(;!x(i);){if(null!==i.getPreviousSibling())return!1;const e=i.getParent();if(null===e)return!1;i=e}return!(!x(i)||!i.collapseAtStart(n))&&(e.preventDefault(),!0)},t.COMMAND_PRIORITY_BEFORE_EDITOR),e.registerNodeTransform(N,e=>{const n=e.getFirstChild();if(n){if(t.$isTextNode(n)){const t=n.getStyle(),r=n.getFormat();e.getTextStyle()!==t&&e.setTextStyle(t),e.getTextFormat()!==r&&e.setTextFormat(r)}}else{const n=t.$getSelection();t.$isRangeSelection(n)&&(n.style!==e.getTextStyle()||n.format!==e.getTextFormat())&&n.isCollapsed()&&e.is(n.anchor.getNode())&&e.setTextStyle(n.style).setTextFormat(n.format)}}),e.registerNodeTransform(t.TextNode,e=>{const t=e.getParent();if(x(t)&&e.is(t.getFirstChild())){const n=e.getStyle(),r=e.getFormat();n===t.getTextStyle()&&r===t.getTextFormat()||t.setTextStyle(n).setTextFormat(r)}}))}function G(e){const n=e=>{const n=e.getParent();if(b(e.getFirstChild())||!b(n))return;const r=t.$findMatchingParent(e,e=>x(e)&&b(e.getParent())&&x(e.getPreviousSibling()));if(null===r&&e.getIndent()>0)e.setIndent(0);else if(x(r)){const t=r.getPreviousSibling();if(x(t)){const r=function(e){let t=e,n=t.getFirstChild();for(;b(n);){const e=n.getLastChild();if(!x(e))break;t=e,n=t.getFirstChild()}return t}(t),i=r.getParent();if(b(i)){const t=s(i);t+1<s(n)&&e.setIndent(t)}}}};return e.registerNodeTransform($,e=>{const t=[e];for(;t.length>0;){const e=t.shift();if(b(e))for(const r of e.getChildren())if(x(r)){n(r);const e=r.getFirstChild();b(e)&&t.push(e)}}})}const X=/* @__PURE__ */t.defineExtension({build:(e,t,r)=>n.namedSignals(t),config:/* @__PURE__ */t.safeCast({hasStrictIndent:!1,shouldPreserveNumbering:!1}),dependencies:[r.CoreImportExtension,/* @__PURE__ */t.configExtension(r.DOMImportExtension,{rules:U})],name:"@lexical/list/List",nodes:()=>[$,N],register(e,r,i){const s=i.getOutput();return t.mergeRegister(n.effect(()=>j(e,{restoreNumbering:s.shouldPreserveNumbering.value})),n.effect(()=>s.hasStrictIndent.value?G(e):void 0))}}),Z=/* @__PURE__ */t.defineExtension({build:(e,t)=>n.namedSignals(t),config:/* @__PURE__ */t.safeCast({disableTakeFocusOnClick:!1}),dependencies:[X],name:"@lexical/list/CheckList",register:(e,t,n)=>P(e,n.getOutput())}),Q=/* @__PURE__ */t.defineExtension({dependencies:[X],name:"@lexical/list/Import"});exports.$createListItemNode=O,exports.$createListNode=M,exports.$getListDepth=s,exports.$handleListInsertParagraph=C,exports.$insertList=g,exports.$isListItemNode=x,exports.$isListNode=b,exports.$removeList=f,exports.CheckListExtension=Z,exports.INSERT_CHECK_LIST_COMMAND=k,exports.INSERT_ORDERED_LIST_COMMAND=V,exports.INSERT_UNORDERED_LIST_COMMAND=q,exports.ListExtension=X,exports.ListImportExtension=Q,exports.ListImportRules=U,exports.ListItemNode=N,exports.ListNode=$,exports.ListSchema=H,exports.REMOVE_LIST_COMMAND=J,exports.UPDATE_LIST_START_COMMAND=z,exports.registerCheckList=P,exports.registerList=j,exports.registerListStrictIndentTransform=G;
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- import{$getNearestNodeOfType as e,calculateZoomLevel as t}from"@lexical/utils";import{$getSelection as n,$isRangeSelection as r,$isTextNode as i,$isRootOrShadowRoot as s,$createParagraphNode as o,$copyNode as l,$isElementNode as c,$isLeafNode as a,$setPointFromCaret as u,$normalizeCaret as g,$getChildCaret as h,$applyNodeReplacement as f,ElementNode as d,buildImportMap as p,$getSiblingCaret as m,$insertNodeToNearestRootAtCaret as _,$rewindSiblingCaret as y,$getDocument as C,setDOMStyleFromCSS as k,isHTMLElement as b,$isParagraphNode as v,$setFormatFromDOM as T,$setDirectionFromDOM as S,normalizeClassNames as x,removeClassNamesFromElement as N,addClassNamesToElement as F,getStyleObjectFromCSS as P,$createTextNode as L,createCommand as A,mergeRegister as O,COMMAND_PRIORITY_LOW as I,KEY_ARROW_DOWN_COMMAND as E,KEY_ARROW_UP_COMMAND as D,KEY_ESCAPE_COMMAND as w,KEY_SPACE_COMMAND as M,$getNearestNodeFromDOMNode as $,KEY_ARROW_LEFT_COMMAND as R,$findMatchingParent as K,getActiveElement as B,registerEventListeners as W,registerEventListener as U,getNearestEditorFromDOMNode as J,$addUpdateTag as V,SKIP_SELECTION_FOCUS_TAG as q,SKIP_DOM_SELECTION_TAG as z,$createLineBreakNode as j,$getNodeByKey as H,INSERT_PARAGRAPH_COMMAND as X,KEY_BACKSPACE_COMMAND as G,COMMAND_PRIORITY_BEFORE_EDITOR as Q,TextNode as Y,$isDecoratorNode as Z,defineExtension as ee,safeCast as te,configExtension as ne}from"lexical";import{namedSignals as re,effect as ie}from"@lexical/extension";import{defineImportRule as se,sel as oe,isElementOfTag as le,$propagateTextAlignToBlockChildren as ce,$isBlockLevel as ae,CoreImportExtension as ue,DOMImportExtension as ge}from"@lexical/html";function he(e,...t){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",e);for(const e of t)r.append("v",e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function fe(e){let t=1,n=e.getParent();for(;null!=n;){if(Ie(n)){const e=n.getParent();if(Re(e)){t++,n=e.getParent();continue}he(40)}return t}return t}function de(e){const t=e.getParent();Re(t)||he(40);let n=t,r=t;for(;null!==r;)r=r.getParent(),Re(r)&&(n=r);return n}function pe(e){let t=[];const n=e.getChildren().filter(Ie);for(let e=0;e<n.length;e++){const r=n[e],i=r.getFirstChild();Re(i)?t=t.concat(pe(i)):t.push(r)}return t}function me(e){return Ie(e)&&Re(e.getFirstChild())}function _e(e,t){return Ie(e)&&(0===t.length||1===t.length&&e.is(t[0])&&0===e.getChildrenSize())}function ye(e){const t=n();if(null!==t){let n=t.getNodes();if(r(t)){const[r]=t.getStartEndPoints(),i=r.getNode(),l=i.getParent();if(s(i)){const e=i.getFirstChild();if(e)n=e.selectStart().getNodes();else{const e=o();i.append(e),n=e.select().getNodes()}}else if(_e(i,n)){const t=$e(e);if(s(l)){i.replace(t);const e=Oe();c(i)&&(e.setFormat(i.getFormatType()),e.setIndent(i.getIndent())),t.append(e)}else if(Ie(i)){const e=i.getParentOrThrow();Ce(t,e.getChildren()),e.replace(t)}return}}const i=new Set;for(let t=0;t<n.length;t++){const r=n[t];if(c(r)&&r.isEmpty()&&!Ie(r)&&!i.has(r.getKey())){ke(r,e);continue}let o=a(r)?r.getParent():Ie(r)&&r.isEmpty()?r:null;for(;null!=o;){const t=o.getKey();if(Re(o)){if(!i.has(t)){const n=$e(e);Ce(n,o.getChildren()),o.replace(n),i.add(t)}break}{const n=o.getParent();if(s(n)&&!i.has(t)){i.add(t),ke(o,e);break}o=n}}}}}function Ce(e,t){e.splice(e.getChildrenSize(),0,t)}function ke(e,t){if(Re(e))return e;const i=e.getPreviousSibling(),s=e.getNextSibling(),o=Oe();let l;if(Ce(o,e.getChildren()),Re(i)&&t===i.getListType())i.append(o),Re(s)&&t===s.getListType()&&(Ce(i,s.getChildren()),s.remove()),l=i;else if(Re(s)&&t===s.getListType())s.getFirstChildOrThrow().insertBefore(o),l=s;else{const n=$e(t);n.append(o),e.replace(n),l=n}o.setFormat(e.getFormatType()),o.setIndent(e.getIndent());const c=n();return r(c)&&(l.getKey()===c.anchor.key&&c.anchor.set(o.getKey(),c.anchor.offset,"element"),l.getKey()===c.focus.key&&c.focus.set(o.getKey(),c.focus.offset,"element")),e.remove(),l}function be(e,t){const n=e.getLastChild(),r=t.getFirstChild();n&&r&&me(n)&&me(r)&&(be(n.getFirstChild(),r.getFirstChild()),r.remove());const i=t.getChildren();i.length>0&&e.append(...i),t.remove()}function ve(){const t=n();if(r(t)){const n=new Set,r=t.getNodes(),i=t.anchor.getNode();if(_e(i,r))n.add(de(i));else for(let t=0;t<r.length;t++){const i=r[t];if(a(i)){const t=e(i,Fe);null!=t&&n.add(de(t))}}for(const e of n){let n=e;const r=pe(e);for(const e of r){const r=o().setTextStyle(t.style).setTextFormat(t.format);Ce(r,e.getChildren()),n.insertAfter(r),n=r,e.__key===t.anchor.key&&u(t.anchor,g(h(r,"next"))),e.__key===t.focus.key&&u(t.focus,g(h(r,"next"))),e.remove()}e.remove()}}}function Te(e){const t="check"!==e.getListType();let n=e.getStart();for(const r of e.getChildren())Ie(r)&&(r.getValue()!==n&&r.setValue(n),t&&null!=r.getLatest().__checked&&r.setChecked(void 0),Re(r.getFirstChild())||n++)}function Se(e){const t=new Set;if(me(e)||t.has(e.getKey()))return;const n=e.getParent(),r=e.getNextSibling(),i=e.getPreviousSibling();if(me(r)&&me(i)){const n=i.getFirstChild();if(Re(n)){n.append(e);const i=r.getFirstChild();if(Re(i)){Ce(n,i.getChildren()),r.remove(),t.add(r.getKey())}}}else if(me(r)){const t=r.getFirstChild();if(Re(t)){const n=t.getFirstChild();null!==n&&n.insertBefore(e)}}else if(me(i)){const t=i.getFirstChild();Re(t)&&t.append(e)}else if(Re(n)){const t=l(e),s=l(n);t.append(s),s.append(e),i?i.insertAfter(t):r?r.insertBefore(t):n.append(t)}}function xe(e){if(me(e))return;const t=e.getParent(),n=t?t.getParent():void 0;if(Re(n?n.getParent():void 0)&&Ie(n)&&Re(t)){const r=t?t.getFirstChild():void 0,i=t?t.getLastChild():void 0;if(e.is(r))n.insertBefore(e),t.isEmpty()&&n.remove();else if(e.is(i))n.insertAfter(e),t.isEmpty()&&n.remove();else{const r=l(e),i=l(t);r.append(i),e.getPreviousSiblings().forEach(e=>i.append(e));const s=l(e),o=l(t);s.append(o),Ce(o,e.getNextSiblings()),n.insertBefore(r),n.insertAfter(s),n.replace(e)}}}function Ne(e=!1){const t=n();if(!r(t)||!t.isCollapsed())return!1;const c=t.anchor.getNode();let a=null;if(Ie(c)&&0===c.getChildrenSize())a=c;else if(i(c)){const e=c.getParent();Ie(e)&&e.getChildren().every(e=>i(e)&&""===e.getTextContent().trim())&&(a=e)}if(null===a)return!1;const u=de(a),g=a.getParent();Re(g)||he(40);const h=g.getParent();let f;if(s(h))f=o(),u.insertAfter(f);else{if(!Ie(h))return!1;f=l(h),h.insertAfter(f)}f.setTextStyle(t.style).setTextFormat(t.format).select();const d=a.getNextSiblings();if(d.length>0){const t=e?function(e,t){return e.getStart()+t.getIndexWithinParent()}(g,a):1,n=l(g).setStart(t);if(Ie(f)){const e=l(f);e.append(n),f.insertAfter(e)}else f.insertAfter(n);n.append(...d)}return function(e){let t=e;for(;null==t.getNextSibling()&&null==t.getPreviousSibling();){const e=t.getParent();if(null==e||!Ie(e)&&!Re(e))break;t=e}t.remove()}(a),!0}class Fe extends d{__value;__checked;$config(){return this.config("listitem",{$transform:e=>{const t=e.getParent();if(Re(t))"check"!==t.getListType()&&null!=e.getChecked()&&e.setChecked(void 0);else if(t){const n=e.createParentElementNode();Re(n)||he(340);const r=[e];for(const t of["previous","next"]){r.reverse();for(const{origin:n}of m(e,t)){if(!Ie(n))break;r.push(n)}}e.insertBefore(n),n.splice(0,0,r),s(t)||(_(n,y(m(n,"next")),{$shouldSplit:()=>!1,removeEmptyDestination:!0}),t.isEmpty()&&t.isAttached()&&t.remove())}},extends:d,importDOM:p({li:()=>({conversion:Pe,priority:0})})})}constructor(e=1,t=void 0,n){super(n),this.__value=void 0===e?1:e,this.__checked=t}afterCloneFrom(e){super.afterCloneFrom(e),this.__value=e.__value,this.__checked=e.__checked}createDOM(e){const t=C().createElement("li");return this.updateListItemDOM(null,t,e),t}updateListItemDOM(e,t,n){!function(e,t){const n=t.getParent();!Re(n)||"check"!==n.getListType()||Re(t.getFirstChild())?(e.removeAttribute("role"),e.removeAttribute("tabIndex"),e.removeAttribute("aria-checked")):(e.setAttribute("role","checkbox"),e.setAttribute("tabIndex","-1"),e.setAttribute("aria-checked",t.getChecked()?"true":"false"))}(t,this),t.value=this.__value,function(e,t,n){const r=t.list;if(!r)return;const i=r.listitem,s=r.nested&&r.nested.listitem,o=n.getParent(),l=Re(o)&&"check"===o.getListType(),c=n.getChecked(),a=n.getChildren().some(e=>Re(e)),u=[];void 0!==r.listitemChecked&&u.push(r.listitemChecked);void 0!==r.listitemUnchecked&&u.push(r.listitemUnchecked);void 0!==s&&u.push(...x(s));u.length>0&&N(e,...u);const g=[];void 0!==i&&g.push(...x(i));if(l){const e=c?r.listitemChecked:r.listitemUnchecked;void 0!==e&&g.push(e)}void 0!==s&&a&&g.push(...x(s));g.length>0&&F(e,...g)}(t,n.theme,this);const r=e?e.__style:"",i=this.__style;r!==i&&k(t.style,i,r),function(e,t,n){const r=t.__textStyle,i=n?n.__textStyle:"";if(null!==n&&i===r)return;const s=P(r);for(const t in s)e.style.setProperty(`--listitem-marker-${t}`,s[t]);if(""!==i)for(const t in P(i))t in s||e.style.removeProperty(`--listitem-marker-${t}`)}(t,this,e)}updateDOM(e,t,n){const r=t;return this.updateListItemDOM(e,r,n),!1}updateFromJSON(e){return super.updateFromJSON(e).setValue(e.value).setChecked(e.checked)}exportDOM(e){const t=this.createDOM(e._config),n=this.getFormatType();n&&(t.style.textAlign=n);const r=this.getDirection();return r&&(t.dir=r),me(this)?{after(e){if(b(e)){const t=e.previousElementSibling;if(b(t)&&"LI"===t.nodeName){for(;e.firstChild;)t.append(e.firstChild);e.remove()}}return e},element:t}:{element:t}}exportJSON(){return{...super.exportJSON(),checked:this.getChecked(),value:this.getValue()}}append(...e){for(let t=0;t<e.length;t++){const n=e[t];if(c(n)&&this.canMergeWith(n)){const e=n.getChildren();this.append(...e),n.remove()}else super.append(n)}return this}replace(e,t){if(Ie(e))return super.replace(e);this.setIndent(0);const i=this.getParentOrThrow();if(!Re(i))return e;if(i.__first===this.getKey())i.insertBefore(e);else if(i.__last===this.getKey())i.insertAfter(e);else{const t=l(i);let n=this.getNextSibling();for(;n;){const e=n;n=n.getNextSibling(),t.append(e)}i.insertAfter(e),e.insertAfter(t)}const s=this.__key;let o=0;if(t&&(c(e)||he(139),o=e.getChildrenSize(),e.splice(o,0,this.getChildren())),t&&c(e)){const t=n();if(r(t))for(const n of t.getStartEndPoints())n.key===s&&"element"===n.type&&n.set(e.getKey(),o+n.offset,"element")}return this.remove(),0===i.getChildrenSize()&&i.remove(),e}insertAfter(e,t=!0){const n=this.getParentOrThrow();if(Re(n)||he(39),Ie(e))return super.insertAfter(e,t);const r=this.getNextSiblings();if(n.insertAfter(e,t),0!==r.length){const i=l(n);r.forEach(e=>i.append(e)),e.insertAfter(i,t)}return e}remove(e){const t=this.getPreviousSibling(),n=this.getNextSibling();super.remove(e),t&&n&&me(t)&&me(n)&&(be(t.getFirstChild(),n.getFirstChild()),n.remove())}resetOnCopyNodeFrom(e){super.resetOnCopyNodeFrom(e),e.getChecked()&&this.setChecked(!1)}insertNewAfter(e,t=!0){const n=l(this);return this.insertAfter(n,t),n}collapseAtStart(e){const t=o();this.getChildren().forEach(e=>t.append(e));const n=this.getParentOrThrow(),r=n.getParentOrThrow(),i=Ie(r);if(1===n.getChildrenSize())if(i)n.remove(),r.select();else{n.insertBefore(t),n.remove();const r=e.anchor,i=e.focus,s=t.getKey();"element"===r.type&&r.getNode().is(this)&&r.set(s,r.offset,"element"),"element"===i.type&&i.getNode().is(this)&&i.set(s,i.offset,"element")}else n.insertBefore(t),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 n=this.getParent();return Re(n)&&(t=n.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(),n=0;for(;Ie(t);)t=t.getParentOrThrow().getParentOrThrow(),n++;return n}setIndent(e){"number"!=typeof e&&he(117),(e=Math.floor(e))>=0||he(199);let t=this.getIndent();for(;t!==e;)t<e?(Se(this),t++):(xe(this),t--);return this}canInsertAfter(e){return Ie(e)}canReplaceWith(e){return Ie(e)}canMergeWith(e){return Ie(e)||v(e)}extractWithChild(e,t){if(!r(t))return!1;const n=t.anchor.getNode(),i=t.focus.getNode();return this.isParentOf(n)&&this.isParentOf(i)&&this.getTextContent().length===t.getTextContent().length}isParentRequired(){return!0}createParentElementNode(){return $e("bullet")}canMergeWhenEmpty(){return!0}}function Pe(e){if(e.classList.contains("task-list-item"))for(const t of e.children)if("INPUT"===t.tagName)return Le(t);if(e.classList.contains("joplin-checkbox"))for(const t of e.children)if(t.classList.contains("checkbox-wrapper")&&t.children.length>0&&"INPUT"===t.children[0].tagName)return Le(t.children[0]);const t=e.getAttribute("aria-checked"),n=Oe("true"===t||"false"!==t&&void 0);return T(n,e),{after:Ae.bind(null,n),node:S(n,e)}}function Le(e){if(!("checkbox"===e.getAttribute("type")))return{node:null};const t=Oe(e.hasAttribute("checked"));return{after:Ae.bind(null,t),node:t}}function Ae(e,t){const n=t[0];return 1===t.length&&v(n)&&!e.getFormatType()&&n.getFormatType()?(e.setFormat(n.getFormatType()),n.getChildren()):t}function Oe(e){return f(new Fe(void 0,e))}function Ie(e){return e instanceof Fe}class Ee extends d{__tag;__start;__listType;$config(){return this.config("list",{$transform:e=>{!function(e){const t=e.getNextSibling();Re(t)&&e.getListType()===t.getListType()&&be(e,t)}(e),Te(e)},extends:d,importDOM:p({ol:()=>({conversion:we,priority:0}),ul:()=>({conversion:we,priority:0})})})}constructor(e="number",t=1,n){super(n);const r=Me[e]||e;this.__listType=r,this.__tag="number"===r?"ol":"ul",this.__start=t}afterCloneFrom(e){super.afterCloneFrom(e),this.__listType=e.__listType,this.__tag=e.__tag,this.__start=e.__start}getTag(){return this.getLatest().__tag}setListType(e){const t=this.getWritable();return t.__listType=e,t.__tag="number"===e?"ol":"ul",t}getListType(){return this.getLatest().__listType}getStart(){return this.getLatest().__start}setStart(e){const t=this.getWritable();return t.__start=e,t}createDOM(e,t){const n=this.__tag,r=C().createElement(n);return 1!==this.__start&&r.setAttribute("start",String(this.__start)),r.__lexicalListType=this.__listType,De(r,e.theme,this),r}updateDOM(e,t,n){return e.__tag!==this.__tag||e.__listType!==this.__listType||(De(t,n.theme,this),e.__start!==this.__start&&t.setAttribute("start",String(this.__start)),!1)}updateFromJSON(e){return super.updateFromJSON(e).setListType(e.listType).setStart(e.start)}exportDOM(e){const t=this.createDOM(e._config,e);return b(t)&&(1!==this.__start&&t.setAttribute("start",String(this.__start)),"check"===this.__listType&&t.setAttribute("__lexicalListType","check")),{element:t}}exportJSON(){return{...super.exportJSON(),listType:this.getListType(),start:this.getStart(),tag:this.getTag()}}canBeEmpty(){return!1}canIndent(){return!1}splice(e,t,n){let r=n;for(let e=0;e<n.length;e++){const t=n[e];Ie(t)||(r===n&&(r=[...n]),r[e]=this.createListItemNode().append(!c(t)||Re(t)||t.isInline()?t:L(t.getTextContent())))}return super.splice(e,t,r)}extractWithChild(e){return Ie(e)}createListItemNode(){return Oe()}}function De(e,t,n){const r=[],i=[],s=t.list;if(void 0!==s){const e=s[`${n.__tag}Depth`]||[],t=fe(n)-1,o=t%e.length,l=e[o],c=s[n.__tag];let a;const u=s.nested,g=s.checklist;if(void 0!==u&&u.list&&(a=u.list),void 0!==c&&r.push(c),void 0!==g&&"check"===n.__listType&&r.push(g),void 0!==l){r.push(...x(l));for(let t=0;t<e.length;t++)t!==o&&i.push(n.__tag+t)}if(void 0!==a){const e=x(a);t>1?r.push(...e):i.push(...e)}}i.length>0&&N(e,...i),r.length>0&&F(e,...r)}function we(e){let t;if(function(e){return b(e)&&"ol"===e.nodeName.toLowerCase()}(e)){const n=e.start;t=$e("number",n)}else t=function(e){if("check"===e.getAttribute("__lexicallisttype")||e.classList.contains("contains-task-list")||"1"===e.getAttribute("data-is-checklist"))return!0;for(const t of e.childNodes)if(b(t)&&t.hasAttribute("aria-checked"))return!0;return!1}(e)?$e("check"):$e("bullet");return S(t,e),{after:e=>function(e,t){const n=t.createListItemNode.bind(t),r=[];for(let t=0;t<e.length;t++){const i=e[t];if(Ie(i)){r.push(i);const e=i.getChildren();e.length>1&&e.forEach(e=>{Re(e)&&r.push(n().append(e))})}else r.push(n().append(i))}return r}(e,t),node:t}}const Me={ol:"number",ul:"bullet"};function $e(e="number",t=1){return f(new Ee(e,t))}function Re(e){return e instanceof Ee}const Ke=/* @__PURE__ */A("INSERT_CHECK_LIST_COMMAND");function Be(e,t){const i=t&&t.disableTakeFocusOnClick||!1,s="boolean"==typeof i?()=>i:i.peek.bind(i),o=e=>{const t=e.target;if(!b(t))return!1;const n=t.__lexicalCheckListLastHandled;return void 0!==n&&e.timeStamp-n<500},l=e=>{const t=e.target;b(t)&&(t.__lexicalCheckListLastHandled=e.timeStamp)},a=e=>{o(e)||(l(e),Ue(e,s()))},u=e=>{"touch"===e.pointerType&&(o(e)||(l(e),Ue(e,s())))},g=e=>{!function(e,t){We(e,()=>{e.preventDefault(),t&&e.stopPropagation()})}(e,s())};return O(e.registerCommand(Ke,()=>(ye("check"),!0),I),e.registerCommand(E,t=>Ve(t,e,!1),I),e.registerCommand(D,t=>Ve(t,e,!0),I),e.registerCommand(w,()=>{if(null!=Je(e)){const t=e.getRootElement();return null!=t&&t.focus(),!0}return!1},I),e.registerCommand(M,t=>{const n=Je(e);return!(null==n||!e.isEditable())&&(e.update(()=>{const e=$(n);Ie(e)&&(t.preventDefault(),e.toggleChecked())}),!0)},I),e.registerCommand(R,t=>e.read("latest",()=>{const i=n();if(r(i)&&i.isCollapsed()){const{anchor:n}=i,r="element"===n.type;if(r||0===n.offset){const i=n.getNode(),s=K(i,e=>c(e)&&!e.isInline());if(Ie(s)){const n=s.getParent();if(Re(n)&&"check"===n.getListType()&&(r||s.getFirstDescendant()===i)){const n=e.getElementByKey(s.__key);if(null!=n&&B(n)!==n)return n.focus(),t.preventDefault(),!0}}}}return!1}),I),e.registerRootListener(e=>{if(null!==e)return O(W(e,{click:a,pointerup:u}),W(e,{mousedown:g,pointerdown:g},{capture:!0}),U(e,"touchstart",g,{capture:!0,passive:!1}))}))}function We(e,n){const r=e.target;if(!b(r))return;const i=r.firstChild;if(b(i)&&("UL"===i.tagName||"OL"===i.tagName))return;const s=r.parentNode;if(!s||"check"!==s.__lexicalListType)return;let o=null,l=null;if("clientX"in e)o=e.clientX;else if("touches"in e){const t=e.touches;t.length>0&&(o=t[0].clientX,l="touch")}if(null==o)return;const c=r.getBoundingClientRect(),a=o/t(r),u=r.ownerDocument.defaultView,g=u?u.getComputedStyle(r,"::before"):{width:"0px"},h=parseFloat(g.width),f="touch"===l||"pointerType"in e&&"touch"===e.pointerType?32:0;("rtl"===r.dir?a<c.right+f&&a>c.right-h-f:a>c.left-f&&a<c.left+h+f)&&n()}function Ue(e,t){We(e,()=>{if(b(e.target)){const n=e.target,r=J(n);null!=r&&r.isEditable()&&r.update(()=>{const e=$(n);Ie(e)&&(t?(V(q),V(z)):n.focus(),e.toggleChecked())})}})}function Je(e){const t=e.getRootElement(),n=t?B(t):null;return b(n)&&"LI"===n.tagName&&null!=n.parentNode&&"check"===n.parentNode.__lexicalListType?n:null}function Ve(e,t,n){const r=Je(t);return null!=r&&t.update(()=>{const i=$(r);if(!Ie(i))return;const s=function(e,t){let n=t?e.getPreviousSibling():e.getNextSibling(),r=e;for(;null==n&&Ie(r);)r=r.getParentOrThrow().getParent(),null!=r&&(n=t?r.getPreviousSibling():r.getNextSibling());for(;Ie(n);){const e=t?n.getLastChild():n.getFirstChild();if(!Re(e))return n;n=t?e.getLastChild():e.getFirstChild()}return null}(i,n);if(null!=s){s.selectStart();const n=t.getElementByKey(s.__key);null!=n&&(e.preventDefault(),setTimeout(()=>{n.focus()},0))}}),!1}function qe(e){const t=[];for(const n of e)if(Ie(n)){t.push(n);const e=n.getChildren();if(e.length>1)for(const n of e)Re(n)&&t.push(Oe().append(n))}else t.push(Oe().append(n));return t}const ze=/* @__PURE__ */se({$import:(e,t)=>{let n;var r;return le(t,"ol")?n=$e("number",t.start):n=(r=t).matches('[__lexicallisttype="check"], .contains-task-list, [data-is-checklist="1"]')||null!==r.querySelector(":scope > [aria-checked]")?$e("check"):$e("bullet"),S(n,t),[n.splice(0,0,ce(qe(e.$importChildren(t)),t))]},match:oe.tag("ol","ul"),name:"@lexical/list/list"});function je(e,t){if(1!==t.length)return t;const n=t[0];return v(n)&&!e.getFormatType()&&n.getFormatType()?(e.setFormat(n.getFormatType()),n.getChildren()):t}function He(e){const t=e=>ae(e)&&!Re(e);if(!e.some(t))return e;const n=[];let r=[];const i=()=>{r.length>0&&(n.push(r),r=[])};for(const s of e)t(s)?(i(),n.push(c(s)?s.getChildren():[s])):r.push(s);i();const s=[];for(const e of n)s.length>0&&s.push(j()),s.push(...e);return s}const Xe=/* @__PURE__ */se({$import:(e,t)=>{const n=t.getAttribute("aria-checked"),r=Oe("true"===n||"false"!==n&&void 0);return T(r,t),S(r,t),[r.splice(0,0,He(je(r,e.$importChildren(t))))]},match:oe.tag("li"),name:"@lexical/list/li"});function Ge(e,t,n){const r=le(n,"input")?n:n.querySelector('input[type="checkbox"]');if(!r||"checkbox"!==r.getAttribute("type"))return[];const i=Oe(r.hasAttribute("checked"));return T(i,t),S(i,t),[i.splice(0,0,He(je(i,e.$importChildren(t))))]}const Qe={$accepts:e=>Ie(e)||Re(e),$packageRun:e=>[Oe().splice(0,0,e)],name:"ListSchema"},Ye=[/* @__PURE__ */se({$import:(e,t,n)=>{const r=t.querySelector(':scope > input[type="checkbox"]');return r?Ge(e,t,r):n()},match:oe.tag("li").classAll("task-list-item"),name:"@lexical/list/li-task-list-item"}),/* @__PURE__ */se({$import:(e,t,n)=>{const r=t.querySelector(":scope > .checkbox-wrapper");if(!r)return n();const i=r.querySelector(':scope > input[type="checkbox"]');return i?Ge(e,t,i):n()},match:oe.tag("li").classAll("joplin-checkbox"),name:"@lexical/list/li-joplin-checkbox"}),ze,Xe],Ze=/* @__PURE__ */A("UPDATE_LIST_START_COMMAND"),et=/* @__PURE__ */A("INSERT_UNORDERED_LIST_COMMAND"),tt=/* @__PURE__ */A("INSERT_ORDERED_LIST_COMMAND"),nt=/* @__PURE__ */A("REMOVE_LIST_COMMAND");function rt(e,t){return O(e.registerCommand(tt,()=>(ye("number"),!0),I),e.registerCommand(Ze,e=>{const{listNodeKey:t,newStart:n}=e,r=H(t);return!!Re(r)&&("number"===r.getListType()&&(r.setStart(n),Te(r)),!0)},I),e.registerCommand(et,()=>(ye("bullet"),!0),I),e.registerCommand(nt,()=>(ve(),!0),I),e.registerCommand(X,()=>Ne(!!(t&&t.restoreNumbering)),I),e.registerCommand(G,e=>!!function(){const e=n();if(!r(e)||!e.isCollapsed()||0!==e.anchor.offset)return!1;const t=e.anchor.getNode(),i=K(t,Ie);if(!Ie(i))return!1;const s=i.getFirstDescendant();if(null===s)return!1;if(!i.is(t)&&!s.is(t))return!1;const l=i.getParent();if(!Re(l)||!i.is(l.getFirstChild()))return!1;const c=l.getPreviousSibling();if(!Z(c)||c.isIsolated()||!c.isKeyboardSelectable()&&c.isInline())return!1;const a=o().append(...i.getChildren());l.insertBefore(a),i.remove(),l.isEmpty()&&l.remove();return a.selectStart(),!0}()&&(e.preventDefault(),!0),Q),e.registerNodeTransform(Fe,e=>{const t=e.getFirstChild();if(t){if(i(t)){const n=t.getStyle(),r=t.getFormat();e.getTextStyle()!==n&&e.setTextStyle(n),e.getTextFormat()!==r&&e.setTextFormat(r)}}else{const t=n();r(t)&&(t.style!==e.getTextStyle()||t.format!==e.getTextFormat())&&t.isCollapsed()&&e.is(t.anchor.getNode())&&e.setTextStyle(t.style).setTextFormat(t.format)}}),e.registerNodeTransform(Y,e=>{const t=e.getParent();if(Ie(t)&&e.is(t.getFirstChild())){const n=e.getStyle(),r=e.getFormat();n===t.getTextStyle()&&r===t.getTextFormat()||t.setTextStyle(n).setTextFormat(r)}}))}function it(e){const t=e=>{const t=e.getParent();if(Re(e.getFirstChild())||!Re(t))return;const n=K(e,e=>Ie(e)&&Re(e.getParent())&&Ie(e.getPreviousSibling()));if(null===n&&e.getIndent()>0)e.setIndent(0);else if(Ie(n)){const r=n.getPreviousSibling();if(Ie(r)){const n=function(e){let t=e,n=t.getFirstChild();for(;Re(n);){const e=n.getLastChild();if(!Ie(e))break;t=e,n=t.getFirstChild()}return t}(r),i=n.getParent();if(Re(i)){const n=fe(i);n+1<fe(t)&&e.setIndent(n)}}}};return e.registerNodeTransform(Ee,e=>{const n=[e];for(;n.length>0;){const e=n.shift();if(Re(e))for(const r of e.getChildren())if(Ie(r)){t(r);const e=r.getFirstChild();Re(e)&&n.push(e)}}})}const st=/* @__PURE__ */ee({build:(e,t,n)=>re(t),config:/* @__PURE__ */te({hasStrictIndent:!1,shouldPreserveNumbering:!1}),dependencies:[ue,/* @__PURE__ */ne(ge,{rules:Ye})],name:"@lexical/list/List",nodes:()=>[Ee,Fe],register(e,t,n){const r=n.getOutput();return O(ie(()=>rt(e,{restoreNumbering:r.shouldPreserveNumbering.value})),ie(()=>r.hasStrictIndent.value?it(e):void 0))}}),ot=/* @__PURE__ */ee({build:(e,t)=>re(t),config:/* @__PURE__ */te({disableTakeFocusOnClick:!1}),dependencies:[st],name:"@lexical/list/CheckList",register:(e,t,n)=>Be(e,n.getOutput())}),lt=/* @__PURE__ */ee({dependencies:[st],name:"@lexical/list/Import"});export{Oe as $createListItemNode,$e as $createListNode,fe as $getListDepth,Ne as $handleListInsertParagraph,ye as $insertList,Ie as $isListItemNode,Re as $isListNode,ve as $removeList,ot as CheckListExtension,Ke as INSERT_CHECK_LIST_COMMAND,tt as INSERT_ORDERED_LIST_COMMAND,et as INSERT_UNORDERED_LIST_COMMAND,st as ListExtension,lt as ListImportExtension,Ye as ListImportRules,Fe as ListItemNode,Ee as ListNode,Qe as ListSchema,nt as REMOVE_LIST_COMMAND,Ze as UPDATE_LIST_START_COMMAND,Be as registerCheckList,rt as registerList,it as registerListStrictIndentTransform};
9
+ import{$getNearestNodeOfType as t,calculateZoomLevel as e}from"@lexical/utils";import{$getSelection as n,$isRangeSelection as r,$isTextNode as i,$isRootOrShadowRoot as s,$createParagraphNode as o,$copyNode as l,$isElementNode as c,$isLeafNode as a,$setPointFromCaret as u,$normalizeCaret as g,$getChildCaret as h,$applyNodeReplacement as f,ElementNode as d,buildImportMap as p,$getSiblingCaret as m,$insertNodeToNearestRootAtCaret as _,$rewindSiblingCaret as y,$getDocument as C,setDOMStyleFromCSS as k,isHTMLElement as b,$isParagraphNode as S,$setFormatFromDOM as v,$setDirectionFromDOM as T,normalizeClassNames as x,removeClassNamesFromElement as N,addClassNamesToElement as P,getStyleObjectFromCSS as F,$createTextNode as L,createCommand as A,mergeRegister as O,COMMAND_PRIORITY_LOW as I,KEY_ARROW_DOWN_COMMAND as E,KEY_ARROW_UP_COMMAND as D,KEY_ESCAPE_COMMAND as w,KEY_SPACE_COMMAND as M,$getNearestNodeFromDOMNode as $,KEY_ARROW_LEFT_COMMAND as R,$findMatchingParent as K,getActiveElement as B,registerEventListeners as W,registerEventListener as U,getNearestEditorFromDOMNode as J,$addUpdateTag as V,SKIP_SELECTION_FOCUS_TAG as q,SKIP_DOM_SELECTION_TAG as z,$createLineBreakNode as j,$getNodeByKey as H,INSERT_PARAGRAPH_COMMAND as X,KEY_BACKSPACE_COMMAND as G,COMMAND_PRIORITY_BEFORE_EDITOR as Q,TextNode as Y,$isDecoratorNode as Z,defineExtension as tt,safeCast as et,configExtension as nt}from"lexical";import{namedSignals as rt,effect as it}from"@lexical/extension";import{defineImportRule as st,sel as ot,isElementOfTag as lt,$propagateTextAlignToBlockChildren as ct,$isBlockLevel as at,CoreImportExtension as ut,DOMImportExtension as gt}from"@lexical/html";function ht(t,...e){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",t);for(const t of e)r.append("v",t);throw n.search=r.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function ft(t){let e=1,n=t.getParent();for(;null!=n;){if(It(n)){const t=n.getParent();if(Rt(t)){e++,n=t.getParent();continue}ht(40)}return e}return e}function dt(t){const e=t.getParent();Rt(e)||ht(40);let n=e,r=e;for(;null!==r;)r=r.getParent(),Rt(r)&&(n=r);return n}function pt(t){let e=[];const n=t.getChildren().filter(It);for(let t=0;t<n.length;t++){const r=n[t],i=r.getFirstChild();Rt(i)?e=e.concat(pt(i)):e.push(r)}return e}function mt(t){return It(t)&&Rt(t.getFirstChild())}function _t(t,e){return It(t)&&(0===e.length||1===e.length&&t.is(e[0])&&0===t.getChildrenSize())}function yt(t){const e=n();if(null!==e){let n=e.getNodes();if(r(e)){const[r]=e.getStartEndPoints(),i=r.getNode(),l=i.getParent();if(s(i)){const t=i.getFirstChild();if(t)n=t.selectStart().getNodes();else{const t=o();i.append(t),n=t.select().getNodes()}}else if(_t(i,n)){const e=$t(t);if(s(l)){i.replace(e);const t=Ot();c(i)&&(t.setFormat(i.getFormatType()),t.setIndent(i.getIndent())),e.append(t)}else if(It(i)){const t=i.getParentOrThrow();Ct(e,t.getChildren()),t.replace(e)}return}}const i=new Set;for(let e=0;e<n.length;e++){const r=n[e];if(c(r)&&r.isEmpty()&&!It(r)&&!i.has(r.getKey())){kt(r,t);continue}let o=a(r)?r.getParent():It(r)&&r.isEmpty()?r:null;for(;null!=o;){const e=o.getKey();if(Rt(o)){if(!i.has(e)){const n=$t(t);Ct(n,o.getChildren()),o.replace(n),i.add(e)}break}{const n=o.getParent();if(s(n)&&!i.has(e)){i.add(e),kt(o,t);break}o=n}}}}}function Ct(t,e){t.splice(t.getChildrenSize(),0,e)}function kt(t,e){if(Rt(t))return t;const i=t.getPreviousSibling(),s=t.getNextSibling(),o=Ot();let l;if(Ct(o,t.getChildren()),Rt(i)&&e===i.getListType())i.append(o),Rt(s)&&e===s.getListType()&&(Ct(i,s.getChildren()),s.remove()),l=i;else if(Rt(s)&&e===s.getListType())s.getFirstChildOrThrow().insertBefore(o),l=s;else{const n=$t(e);n.append(o),t.replace(n),l=n}o.setFormat(t.getFormatType()),o.setIndent(t.getIndent());const c=n();return r(c)&&(l.getKey()===c.anchor.key&&c.anchor.set(o.getKey(),c.anchor.offset,"element"),l.getKey()===c.focus.key&&c.focus.set(o.getKey(),c.focus.offset,"element")),t.remove(),l}function bt(t,e){const n=t.getLastChild(),r=e.getFirstChild();n&&r&&mt(n)&&mt(r)&&(bt(n.getFirstChild(),r.getFirstChild()),r.remove());const i=e.getChildren();i.length>0&&t.append(...i),e.remove()}function St(){const e=n();if(r(e)){const n=new Set,r=e.getNodes(),i=e.anchor.getNode();if(_t(i,r))n.add(dt(i));else for(let e=0;e<r.length;e++){const i=r[e];if(a(i)){const e=t(i,Pt);null!=e&&n.add(dt(e))}}for(const t of n){let n=t;const r=pt(t);for(const t of r){const r=o().setTextStyle(e.style).setTextFormat(e.format);Ct(r,t.getChildren()),n.insertAfter(r),n=r,t.__key===e.anchor.key&&u(e.anchor,g(h(r,"next"))),t.__key===e.focus.key&&u(e.focus,g(h(r,"next"))),t.remove()}t.remove()}}}function vt(t){const e="check"!==t.getListType();let n=t.getStart();for(const r of t.getChildren())It(r)&&(r.getValue()!==n&&r.setValue(n),e&&null!=r.getLatest().__checked&&r.setChecked(void 0),Rt(r.getFirstChild())||n++)}function Tt(t){const e=new Set;if(mt(t)||e.has(t.getKey()))return;const n=t.getParent(),r=t.getNextSibling(),i=t.getPreviousSibling();if(mt(r)&&mt(i)){const n=i.getFirstChild();if(Rt(n)){n.append(t);const i=r.getFirstChild();if(Rt(i)){Ct(n,i.getChildren()),r.remove(),e.add(r.getKey())}}}else if(mt(r)){const e=r.getFirstChild();if(Rt(e)){const n=e.getFirstChild();null!==n&&n.insertBefore(t)}}else if(mt(i)){const e=i.getFirstChild();Rt(e)&&e.append(t)}else if(Rt(n)){const e=l(t),s=l(n);e.append(s),s.append(t),i?i.insertAfter(e):r?r.insertBefore(e):n.append(e)}}function xt(t){if(mt(t))return;const e=t.getParent(),n=e?e.getParent():void 0;if(Rt(n?n.getParent():void 0)&&It(n)&&Rt(e)){const r=e?e.getFirstChild():void 0,i=e?e.getLastChild():void 0;if(t.is(r))n.insertBefore(t),e.isEmpty()&&n.remove();else if(t.is(i))n.insertAfter(t),e.isEmpty()&&n.remove();else{const r=l(t),i=l(e);r.append(i),t.getPreviousSiblings().forEach(t=>i.append(t));const s=l(t),o=l(e);s.append(o),Ct(o,t.getNextSiblings()),n.insertBefore(r),n.insertAfter(s),n.replace(t)}}}function Nt(t=!1){const e=n();if(!r(e)||!e.isCollapsed())return!1;const c=e.anchor.getNode();let a=null;if(It(c)&&0===c.getChildrenSize())a=c;else if(i(c)){const t=c.getParent();It(t)&&t.getChildren().every(t=>i(t)&&""===t.getTextContent().trim())&&(a=t)}if(null===a)return!1;const u=dt(a),g=a.getParent();Rt(g)||ht(40);const h=g.getParent();let f;if(s(h))f=o(),u.insertAfter(f);else{if(!It(h))return!1;f=l(h),h.insertAfter(f)}f.setTextStyle(e.style).setTextFormat(e.format).select();const d=a.getNextSiblings();if(d.length>0){const e=t?function(t,e){return t.getStart()+e.getIndexWithinParent()}(g,a):1,n=l(g).setStart(e);if(It(f)){const t=l(f);t.append(n),f.insertAfter(t)}else f.insertAfter(n);n.append(...d)}return function(t){let e=t;for(;null==e.getNextSibling()&&null==e.getPreviousSibling();){const t=e.getParent();if(null==t||!It(t)&&!Rt(t))break;e=t}e.remove()}(a),!0}class Pt extends d{__value;__checked;$config(){return this.config("listitem",{$transform:t=>{const e=t.getParent();if(Rt(e))"check"!==e.getListType()&&null!=t.getChecked()&&t.setChecked(void 0);else if(e){const n=t.createParentElementNode();Rt(n)||ht(340);const r=[t];for(const e of["previous","next"]){r.reverse();for(const{origin:n}of m(t,e)){if(!It(n))break;r.push(n)}}t.insertBefore(n),n.splice(0,0,r),s(e)||(_(n,y(m(n,"next")),{$shouldSplit:()=>!1,removeEmptyDestination:!0}),e.isEmpty()&&e.isAttached()&&e.remove())}},extends:d,importDOM:p({li:()=>({conversion:Ft,priority:0})})})}constructor(t=1,e=void 0,n){super(n),this.__value=void 0===t?1:t,this.__checked=e}afterCloneFrom(t){super.afterCloneFrom(t),this.__value=t.__value,this.__checked=t.__checked}createDOM(t){const e=C().createElement("li");return this.updateListItemDOM(null,e,t),e}updateListItemDOM(t,e,n){!function(t,e){const n=e.getParent();!Rt(n)||"check"!==n.getListType()||Rt(e.getFirstChild())?(t.removeAttribute("role"),t.removeAttribute("tabIndex"),t.removeAttribute("aria-checked")):(t.setAttribute("role","checkbox"),t.setAttribute("tabIndex","-1"),t.setAttribute("aria-checked",e.getChecked()?"true":"false"))}(e,this),e.value=this.__value,function(t,e,n){const r=e.list;if(!r)return;const i=r.listitem,s=r.nested&&r.nested.listitem,o=n.getParent(),l=Rt(o)&&"check"===o.getListType(),c=n.getChecked(),a=n.getChildren().some(t=>Rt(t)),u=[];void 0!==r.listitemChecked&&u.push(r.listitemChecked);void 0!==r.listitemUnchecked&&u.push(r.listitemUnchecked);void 0!==s&&u.push(...x(s));u.length>0&&N(t,...u);const g=[];void 0!==i&&g.push(...x(i));if(l){const t=c?r.listitemChecked:r.listitemUnchecked;void 0!==t&&g.push(t)}void 0!==s&&a&&g.push(...x(s));g.length>0&&P(t,...g)}(e,n.theme,this);const r=t?t.__style:"",i=this.__style;r!==i&&k(e.style,i,r),function(t,e,n){const r=e.__textStyle,i=n?n.__textStyle:"";if(null!==n&&i===r)return;const s=F(r);for(const e in s)t.style.setProperty(`--listitem-marker-${e}`,s[e]);if(""!==i)for(const e in F(i))e in s||t.style.removeProperty(`--listitem-marker-${e}`)}(e,this,t)}updateDOM(t,e,n){const r=e;return this.updateListItemDOM(t,r,n),!1}updateFromJSON(t){return super.updateFromJSON(t).setValue(t.value).setChecked(t.checked)}exportDOM(t){const e=this.createDOM(t._config),n=this.getFormatType();n&&(e.style.textAlign=n);const r=this.getDirection();return r&&(e.dir=r),mt(this)?{after(t){if(b(t)){const e=t.previousElementSibling;if(b(e)&&"LI"===e.nodeName){for(;t.firstChild;)e.append(t.firstChild);t.remove()}}return t},element:e}:{element:e}}exportJSON(){return{...super.exportJSON(),checked:this.getChecked(),value:this.getValue()}}append(...t){for(let e=0;e<t.length;e++){const n=t[e];if(c(n)&&this.canMergeWith(n)){const t=n.getChildren();this.append(...t),n.remove()}else super.append(n)}return this}replace(t,e){if(It(t))return super.replace(t);this.setIndent(0);const i=this.getParentOrThrow();if(!Rt(i))return t;if(i.__first===this.getKey())i.insertBefore(t);else if(i.__last===this.getKey())i.insertAfter(t);else{const e=l(i);let n=this.getNextSibling();for(;n;){const t=n;n=n.getNextSibling(),e.append(t)}i.insertAfter(t),t.insertAfter(e)}const s=this.__key;let o=0;if(e&&(c(t)||ht(139),o=t.getChildrenSize(),t.splice(o,0,this.getChildren())),e&&c(t)){const e=n();if(r(e))for(const n of e.getStartEndPoints())n.key===s&&"element"===n.type&&n.set(t.getKey(),o+n.offset,"element")}return this.remove(),0===i.getChildrenSize()&&i.remove(),t}insertAfter(t,e=!0){const n=this.getParentOrThrow();if(Rt(n)||ht(39),It(t))return super.insertAfter(t,e);const r=this.getNextSiblings();if(n.insertAfter(t,e),0!==r.length){const i=l(n);r.forEach(t=>i.append(t)),t.insertAfter(i,e)}return t}remove(t){const e=this.getPreviousSibling(),n=this.getNextSibling();super.remove(t),e&&n&&mt(e)&&mt(n)&&(bt(e.getFirstChild(),n.getFirstChild()),n.remove())}resetOnCopyNodeFrom(t){super.resetOnCopyNodeFrom(t),t.getChecked()&&this.setChecked(!1)}insertNewAfter(t,e=!0){const n=l(this);return this.insertAfter(n,e),n}collapseAtStart(t){if(mt(this))return!1;const e=this.getParentOrThrow();if(It(e.getParentOrThrow()))return xt(this),!0;const n=o().append(...this.getChildren()),r=this.getNextSiblings();if(r.length>0){const t=l(e);t.append(...r),e.insertAfter(t)}return e.insertAfter(n),this.remove(),0===e.getChildrenSize()&&e.remove(),n.selectStart(),!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 n=this.getParent();return Rt(n)&&(e=n.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(),n=0;for(;It(e);)e=e.getParentOrThrow().getParentOrThrow(),n++;return n}setIndent(t){"number"!=typeof t&&ht(117),(t=Math.floor(t))>=0||ht(199);let e=this.getIndent();for(;e!==t;)e<t?(Tt(this),e++):(xt(this),e--);return this}canInsertAfter(t){return It(t)}canReplaceWith(t){return It(t)}canMergeWith(t){return It(t)||S(t)}extractWithChild(t,e){if(!r(e))return!1;const n=e.anchor.getNode(),i=e.focus.getNode();return this.isParentOf(n)&&this.isParentOf(i)&&this.getTextContent().length===e.getTextContent().length}isParentRequired(){return!0}createParentElementNode(){return $t("bullet")}canMergeWhenEmpty(){return!0}}function Ft(t){if(t.classList.contains("task-list-item"))for(const e of t.children)if("INPUT"===e.tagName)return Lt(e);if(t.classList.contains("joplin-checkbox"))for(const e of t.children)if(e.classList.contains("checkbox-wrapper")&&e.children.length>0&&"INPUT"===e.children[0].tagName)return Lt(e.children[0]);const e=t.getAttribute("aria-checked"),n=Ot("true"===e||"false"!==e&&void 0);return v(n,t),{after:At.bind(null,n),node:T(n,t)}}function Lt(t){if(!("checkbox"===t.getAttribute("type")))return{node:null};const e=Ot(t.hasAttribute("checked"));return{after:At.bind(null,e),node:e}}function At(t,e){const n=e[0];return 1===e.length&&S(n)&&!t.getFormatType()&&n.getFormatType()?(t.setFormat(n.getFormatType()),n.getChildren()):e}function Ot(t){return f(new Pt(void 0,t))}function It(t){return t instanceof Pt}class Et extends d{__tag;__start;__listType;$config(){return this.config("list",{$transform:t=>{!function(t){const e=t.getNextSibling();Rt(e)&&t.getListType()===e.getListType()&&bt(t,e)}(t),vt(t)},extends:d,importDOM:p({ol:()=>({conversion:wt,priority:0}),ul:()=>({conversion:wt,priority:0})})})}constructor(t="number",e=1,n){super(n);const r=Mt[t]||t;this.__listType=r,this.__tag="number"===r?"ol":"ul",this.__start=e}afterCloneFrom(t){super.afterCloneFrom(t),this.__listType=t.__listType,this.__tag=t.__tag,this.__start=t.__start}getTag(){return this.getLatest().__tag}setListType(t){const e=this.getWritable();return e.__listType=t,e.__tag="number"===t?"ol":"ul",e}getListType(){return this.getLatest().__listType}getStart(){return this.getLatest().__start}setStart(t){const e=this.getWritable();return e.__start=t,e}createDOM(t,e){const n=this.__tag,r=C().createElement(n);return 1!==this.__start&&r.setAttribute("start",String(this.__start)),r.__lexicalListType=this.__listType,Dt(r,t.theme,this),r}updateDOM(t,e,n){return t.__tag!==this.__tag||t.__listType!==this.__listType||(Dt(e,n.theme,this),t.__start!==this.__start&&e.setAttribute("start",String(this.__start)),!1)}updateFromJSON(t){return super.updateFromJSON(t).setListType(t.listType).setStart(t.start)}exportDOM(t){const e=this.createDOM(t._config,t);return b(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}splice(t,e,n){let r=n;for(let t=0;t<n.length;t++){const e=n[t];It(e)||(r===n&&(r=[...n]),r[t]=this.createListItemNode().append(!c(e)||Rt(e)||e.isInline()?e:L(e.getTextContent())))}return super.splice(t,e,r)}extractWithChild(t){return It(t)}createListItemNode(){return Ot()}}function Dt(t,e,n){const r=[],i=[],s=e.list;if(void 0!==s){const t=s[`${n.__tag}Depth`]||[],e=ft(n)-1,o=e%t.length,l=t[o],c=s[n.__tag];let a;const u=s.nested,g=s.checklist;if(void 0!==u&&u.list&&(a=u.list),void 0!==c&&r.push(c),void 0!==g&&"check"===n.__listType&&r.push(g),void 0!==l){r.push(...x(l));for(let e=0;e<t.length;e++)e!==o&&i.push(n.__tag+e)}if(void 0!==a){const t=x(a);e>1?r.push(...t):i.push(...t)}}i.length>0&&N(t,...i),r.length>0&&P(t,...r)}function wt(t){let e;if(function(t){return b(t)&&"ol"===t.nodeName.toLowerCase()}(t)){const n=t.start;e=$t("number",n)}else e=function(t){if("check"===t.getAttribute("__lexicallisttype")||t.classList.contains("contains-task-list")||"1"===t.getAttribute("data-is-checklist"))return!0;for(const e of t.childNodes)if(b(e)&&e.hasAttribute("aria-checked"))return!0;return!1}(t)?$t("check"):$t("bullet");return T(e,t),{after:t=>function(t,e){const n=e.createListItemNode.bind(e),r=[];for(let e=0;e<t.length;e++){const i=t[e];if(It(i)){r.push(i);const t=i.getChildren();t.length>1&&t.forEach(t=>{Rt(t)&&r.push(n().append(t))})}else r.push(n().append(i))}return r}(t,e),node:e}}const Mt={ol:"number",ul:"bullet"};function $t(t="number",e=1){return f(new Et(t,e))}function Rt(t){return t instanceof Et}const Kt=/* @__PURE__ */A("INSERT_CHECK_LIST_COMMAND");function Bt(t,e){const i=e&&e.disableTakeFocusOnClick||!1,s="boolean"==typeof i?()=>i:i.peek.bind(i),o=t=>{const e=t.target;if(!b(e))return!1;const n=e.__lexicalCheckListLastHandled;return void 0!==n&&t.timeStamp-n<500},l=t=>{const e=t.target;b(e)&&(e.__lexicalCheckListLastHandled=t.timeStamp)},a=t=>{o(t)||(l(t),Ut(t,s()))},u=t=>{"touch"===t.pointerType&&(o(t)||(l(t),Ut(t,s())))},g=t=>{!function(t,e){Wt(t,()=>{t.preventDefault(),e&&t.stopPropagation()})}(t,s())};return O(t.registerCommand(Kt,()=>(yt("check"),!0),I),t.registerCommand(E,e=>Vt(e,t,!1),I),t.registerCommand(D,e=>Vt(e,t,!0),I),t.registerCommand(w,()=>{if(null!=Jt(t)){const e=t.getRootElement();return null!=e&&e.focus(),!0}return!1},I),t.registerCommand(M,e=>{const n=Jt(t);return!(null==n||!t.isEditable())&&(t.update(()=>{const t=$(n);It(t)&&(e.preventDefault(),t.toggleChecked())}),!0)},I),t.registerCommand(R,e=>t.read("latest",()=>{const i=n();if(r(i)&&i.isCollapsed()){const{anchor:n}=i,r="element"===n.type;if(r||0===n.offset){const i=n.getNode(),s=K(i,t=>c(t)&&!t.isInline());if(It(s)){const n=s.getParent();if(Rt(n)&&"check"===n.getListType()&&(r||s.getFirstDescendant()===i)){const n=t.getElementByKey(s.__key);if(null!=n&&B(n)!==n)return n.focus(),e.preventDefault(),!0}}}}return!1}),I),t.registerRootListener(t=>{if(null!==t)return O(W(t,{click:a,pointerup:u}),W(t,{mousedown:g,pointerdown:g},{capture:!0}),U(t,"touchstart",g,{capture:!0,passive:!1}))}))}function Wt(t,n){const r=t.target;if(!b(r))return;const i=r.firstChild;if(b(i)&&("UL"===i.tagName||"OL"===i.tagName))return;const s=r.parentNode;if(!s||"check"!==s.__lexicalListType)return;let o=null,l=null;if("clientX"in t)o=t.clientX;else if("touches"in t){const e=t.touches;e.length>0&&(o=e[0].clientX,l="touch")}if(null==o)return;const c=r.getBoundingClientRect(),a=o/e(r),u=r.ownerDocument.defaultView,g=u?u.getComputedStyle(r,"::before"):{width:"0px"},h=parseFloat(g.width),f="touch"===l||"pointerType"in t&&"touch"===t.pointerType?32:0;("rtl"===r.dir?a<c.right+f&&a>c.right-h-f:a>c.left-f&&a<c.left+h+f)&&n()}function Ut(t,e){Wt(t,()=>{if(b(t.target)){const n=t.target,r=J(n);null!=r&&r.isEditable()&&r.update(()=>{const t=$(n);It(t)&&(e?(V(q),V(z)):n.focus(),t.toggleChecked())})}})}function Jt(t){const e=t.getRootElement(),n=e?B(e):null;return b(n)&&"LI"===n.tagName&&null!=n.parentNode&&"check"===n.parentNode.__lexicalListType?n:null}function Vt(t,e,n){const r=Jt(e);return null!=r&&e.update(()=>{const i=$(r);if(!It(i))return;const s=function(t,e){let n=e?t.getPreviousSibling():t.getNextSibling(),r=t;for(;null==n&&It(r);)r=r.getParentOrThrow().getParent(),null!=r&&(n=e?r.getPreviousSibling():r.getNextSibling());for(;It(n);){const t=e?n.getLastChild():n.getFirstChild();if(!Rt(t))return n;n=e?t.getLastChild():t.getFirstChild()}return null}(i,n);if(null!=s){s.selectStart();const n=e.getElementByKey(s.__key);null!=n&&(t.preventDefault(),setTimeout(()=>{n.focus()},0))}}),!1}function qt(t){const e=[];for(const n of t)if(It(n)){e.push(n);const t=n.getChildren();if(t.length>1)for(const n of t)Rt(n)&&e.push(Ot().append(n))}else e.push(Ot().append(n));return e}const zt=/* @__PURE__ */st({$import:(t,e)=>{let n;var r;return lt(e,"ol")?n=$t("number",e.start):n=(r=e).matches('[__lexicallisttype="check"], .contains-task-list, [data-is-checklist="1"]')||null!==r.querySelector(":scope > [aria-checked]")?$t("check"):$t("bullet"),T(n,e),[n.splice(0,0,ct(qt(t.$importChildren(e)),e))]},match:ot.tag("ol","ul"),name:"@lexical/list/list"});function jt(t,e){if(1!==e.length)return e;const n=e[0];return S(n)&&!t.getFormatType()&&n.getFormatType()?(t.setFormat(n.getFormatType()),n.getChildren()):e}function Ht(t){const e=t=>at(t)&&!Rt(t);if(!t.some(e))return t;const n=[];let r=[];const i=()=>{r.length>0&&(n.push(r),r=[])};for(const s of t)e(s)?(i(),n.push(c(s)?s.getChildren():[s])):r.push(s);i();const s=[];for(const t of n)s.length>0&&s.push(j()),s.push(...t);return s}const Xt=/* @__PURE__ */st({$import:(t,e)=>{const n=e.getAttribute("aria-checked"),r=Ot("true"===n||"false"!==n&&void 0);return v(r,e),T(r,e),[r.splice(0,0,Ht(jt(r,t.$importChildren(e))))]},match:ot.tag("li"),name:"@lexical/list/li"});function Gt(t,e,n){const r=lt(n,"input")?n:n.querySelector('input[type="checkbox"]');if(!r||"checkbox"!==r.getAttribute("type"))return[];const i=Ot(r.hasAttribute("checked"));return v(i,e),T(i,e),[i.splice(0,0,Ht(jt(i,t.$importChildren(e))))]}const Qt={$accepts:t=>It(t)||Rt(t),$packageRun:t=>[Ot().splice(0,0,t)],name:"ListSchema"},Yt=[/* @__PURE__ */st({$import:(t,e,n)=>{const r=e.querySelector(':scope > input[type="checkbox"]');return r?Gt(t,e,r):n()},match:ot.tag("li").classAll("task-list-item"),name:"@lexical/list/li-task-list-item"}),/* @__PURE__ */st({$import:(t,e,n)=>{const r=e.querySelector(":scope > .checkbox-wrapper");if(!r)return n();const i=r.querySelector(':scope > input[type="checkbox"]');return i?Gt(t,e,i):n()},match:ot.tag("li").classAll("joplin-checkbox"),name:"@lexical/list/li-joplin-checkbox"}),zt,Xt],Zt=/* @__PURE__ */A("UPDATE_LIST_START_COMMAND"),te=/* @__PURE__ */A("INSERT_UNORDERED_LIST_COMMAND"),ee=/* @__PURE__ */A("INSERT_ORDERED_LIST_COMMAND"),ne=/* @__PURE__ */A("REMOVE_LIST_COMMAND");function re(t,e){return O(t.registerCommand(ee,()=>(yt("number"),!0),I),t.registerCommand(Zt,t=>{const{listNodeKey:e,newStart:n}=t,r=H(e);return!!Rt(r)&&("number"===r.getListType()&&(r.setStart(n),vt(r)),!0)},I),t.registerCommand(te,()=>(yt("bullet"),!0),I),t.registerCommand(ne,()=>(St(),!0),I),t.registerCommand(X,()=>Nt(!!(e&&e.restoreNumbering)),I),t.registerCommand(G,t=>{if(function(){const t=n();if(!r(t)||!t.isCollapsed()||0!==t.anchor.offset)return!1;const e=t.anchor.getNode(),i=K(e,It);if(!It(i))return!1;const s=i.getFirstDescendant();if(null===s)return!1;if(!i.is(e)&&!s.is(e))return!1;const l=i.getParent();if(!Rt(l)||!i.is(l.getFirstChild()))return!1;const c=l.getPreviousSibling();if(!Z(c)||c.isIsolated()||!c.isKeyboardSelectable()&&c.isInline())return!1;const a=o().append(...i.getChildren());l.insertBefore(a),i.remove(),l.isEmpty()&&l.remove();return a.selectStart(),!0}())return t.preventDefault(),!0;const e=n();if(!r(e)||!e.isCollapsed())return!1;const{anchor:i}=e;if(0!==i.offset)return!1;let s=i.getNode();for(;!It(s);){if(null!==s.getPreviousSibling())return!1;const t=s.getParent();if(null===t)return!1;s=t}return!(!It(s)||!s.collapseAtStart(e))&&(t.preventDefault(),!0)},Q),t.registerNodeTransform(Pt,t=>{const e=t.getFirstChild();if(e){if(i(e)){const n=e.getStyle(),r=e.getFormat();t.getTextStyle()!==n&&t.setTextStyle(n),t.getTextFormat()!==r&&t.setTextFormat(r)}}else{const e=n();r(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(Y,t=>{const e=t.getParent();if(It(e)&&t.is(e.getFirstChild())){const n=t.getStyle(),r=t.getFormat();n===e.getTextStyle()&&r===e.getTextFormat()||e.setTextStyle(n).setTextFormat(r)}}))}function ie(t){const e=t=>{const e=t.getParent();if(Rt(t.getFirstChild())||!Rt(e))return;const n=K(t,t=>It(t)&&Rt(t.getParent())&&It(t.getPreviousSibling()));if(null===n&&t.getIndent()>0)t.setIndent(0);else if(It(n)){const r=n.getPreviousSibling();if(It(r)){const n=function(t){let e=t,n=e.getFirstChild();for(;Rt(n);){const t=n.getLastChild();if(!It(t))break;e=t,n=e.getFirstChild()}return e}(r),i=n.getParent();if(Rt(i)){const n=ft(i);n+1<ft(e)&&t.setIndent(n)}}}};return t.registerNodeTransform(Et,t=>{const n=[t];for(;n.length>0;){const t=n.shift();if(Rt(t))for(const r of t.getChildren())if(It(r)){e(r);const t=r.getFirstChild();Rt(t)&&n.push(t)}}})}const se=/* @__PURE__ */tt({build:(t,e,n)=>rt(e),config:/* @__PURE__ */et({hasStrictIndent:!1,shouldPreserveNumbering:!1}),dependencies:[ut,/* @__PURE__ */nt(gt,{rules:Yt})],name:"@lexical/list/List",nodes:()=>[Et,Pt],register(t,e,n){const r=n.getOutput();return O(it(()=>re(t,{restoreNumbering:r.shouldPreserveNumbering.value})),it(()=>r.hasStrictIndent.value?ie(t):void 0))}}),oe=/* @__PURE__ */tt({build:(t,e)=>rt(e),config:/* @__PURE__ */et({disableTakeFocusOnClick:!1}),dependencies:[se],name:"@lexical/list/CheckList",register:(t,e,n)=>Bt(t,n.getOutput())}),le=/* @__PURE__ */tt({dependencies:[se],name:"@lexical/list/Import"});export{Ot as $createListItemNode,$t as $createListNode,ft as $getListDepth,Nt as $handleListInsertParagraph,yt as $insertList,It as $isListItemNode,Rt as $isListNode,St as $removeList,oe as CheckListExtension,Kt as INSERT_CHECK_LIST_COMMAND,ee as INSERT_ORDERED_LIST_COMMAND,te as INSERT_UNORDERED_LIST_COMMAND,se as ListExtension,le as ListImportExtension,Yt as ListImportRules,Pt as ListItemNode,Et as ListNode,Qt as ListSchema,ne as REMOVE_LIST_COMMAND,Zt as UPDATE_LIST_START_COMMAND,Bt as registerCheckList,re as registerList,ie as registerListStrictIndentTransform};
@@ -43,7 +43,7 @@ export declare class ListItemNode extends ElementNode {
43
43
  remove(preserveEmptyParent?: boolean): void;
44
44
  resetOnCopyNodeFrom(original: this): void;
45
45
  insertNewAfter(_: RangeSelection, restoreSelection?: boolean): ListItemNode | ParagraphNode;
46
- collapseAtStart(selection: RangeSelection): true;
46
+ collapseAtStart(selection: RangeSelection): boolean;
47
47
  getValue(): number;
48
48
  setValue(value: number): this;
49
49
  getChecked(): boolean | undefined;
package/package.json CHANGED
@@ -8,15 +8,15 @@
8
8
  "list"
9
9
  ],
10
10
  "license": "MIT",
11
- "version": "0.47.1-nightly.20260715.0",
11
+ "version": "0.48.0",
12
12
  "main": "./dist/LexicalList.js",
13
13
  "types": "./dist/typescript-too-old.d.ts",
14
14
  "dependencies": {
15
- "@lexical/html": "0.47.1-nightly.20260715.0",
16
- "@lexical/extension": "0.47.1-nightly.20260715.0",
17
- "@lexical/internal": "0.47.1-nightly.20260715.0",
18
- "@lexical/utils": "0.47.1-nightly.20260715.0",
19
- "lexical": "0.47.1-nightly.20260715.0"
15
+ "@lexical/extension": "0.48.0",
16
+ "@lexical/html": "0.48.0",
17
+ "@lexical/internal": "0.48.0",
18
+ "lexical": "0.48.0",
19
+ "@lexical/utils": "0.48.0"
20
20
  },
21
21
  "repository": {
22
22
  "type": "git",
@@ -397,41 +397,33 @@ export class ListItemNode extends ElementNode {
397
397
  return newElement;
398
398
  }
399
399
 
400
- collapseAtStart(selection: RangeSelection): true {
401
- const paragraph = $createParagraphNode();
402
- const children = this.getChildren();
403
- children.forEach(child => paragraph.append(child));
400
+ collapseAtStart(selection: RangeSelection): boolean {
401
+ if (isNestedListNode(this)) {
402
+ return false;
403
+ }
404
+
404
405
  const listNode = this.getParentOrThrow();
405
406
  const listNodeParent = listNode.getParentOrThrow();
406
- const isIndented = $isListItemNode(listNodeParent);
407
-
408
- if (listNode.getChildrenSize() === 1) {
409
- if (isIndented) {
410
- // if the list node is nested, we just want to remove it,
411
- // effectively unindenting it.
412
- listNode.remove();
413
- listNodeParent.select();
414
- } else {
415
- listNode.insertBefore(paragraph);
416
- listNode.remove();
417
- // If we have selection on the list item, we'll need to move it
418
- // to the paragraph
419
- const anchor = selection.anchor;
420
- const focus = selection.focus;
421
- const key = paragraph.getKey();
422
-
423
- if (anchor.type === 'element' && anchor.getNode().is(this)) {
424
- anchor.set(key, anchor.offset, 'element');
425
- }
426
407
 
427
- if (focus.type === 'element' && focus.getNode().is(this)) {
428
- focus.set(key, focus.offset, 'element');
429
- }
430
- }
431
- } else {
432
- listNode.insertBefore(paragraph);
433
- this.remove();
408
+ if ($isListItemNode(listNodeParent)) {
409
+ $handleOutdent(this);
410
+ return true;
411
+ }
412
+
413
+ const paragraph = $createParagraphNode().append(...this.getChildren());
414
+
415
+ const nextSiblings = this.getNextSiblings();
416
+ if (nextSiblings.length > 0) {
417
+ const newList = $copyNode(listNode);
418
+ newList.append(...nextSiblings);
419
+ listNode.insertAfter(newList);
420
+ }
421
+ listNode.insertAfter(paragraph);
422
+ this.remove();
423
+ if (listNode.getChildrenSize() === 0) {
424
+ listNode.remove();
434
425
  }
426
+ paragraph.selectStart();
435
427
 
436
428
  return true;
437
429
  }
@@ -21,6 +21,7 @@ import {
21
21
  KEY_BACKSPACE_COMMAND,
22
22
  type LexicalCommand,
23
23
  type LexicalEditor,
24
+ type LexicalNode,
24
25
  mergeRegister,
25
26
  type NodeKey,
26
27
  TextNode,
@@ -104,10 +105,6 @@ export function registerList(
104
105
  },
105
106
  COMMAND_PRIORITY_LOW,
106
107
  ),
107
- // Runs just before the rich-text handler at COMMAND_PRIORITY_EDITOR that
108
- // calls deleteCharacter. Lower-priority handlers (link, mark, etc.) still
109
- // see Backspace first; only the editor-priority merge-block path is what
110
- // we intercept here.
111
108
  editor.registerCommand(
112
109
  KEY_BACKSPACE_COMMAND,
113
110
  event => {
@@ -115,6 +112,29 @@ export function registerList(
115
112
  event.preventDefault();
116
113
  return true;
117
114
  }
115
+ const selection = $getSelection();
116
+ if (!$isRangeSelection(selection) || !selection.isCollapsed()) {
117
+ return false;
118
+ }
119
+ const {anchor} = selection;
120
+ if (anchor.offset !== 0) {
121
+ return false;
122
+ }
123
+ let current: LexicalNode = anchor.getNode();
124
+ while (!$isListItemNode(current)) {
125
+ if (current.getPreviousSibling() !== null) {
126
+ return false;
127
+ }
128
+ const parent = current.getParent();
129
+ if (parent === null) {
130
+ return false;
131
+ }
132
+ current = parent;
133
+ }
134
+ if ($isListItemNode(current) && current.collapseAtStart(selection)) {
135
+ event.preventDefault();
136
+ return true;
137
+ }
118
138
  return false;
119
139
  },
120
140
  COMMAND_PRIORITY_BEFORE_EDITOR,