@lexical/list 0.32.2-nightly.20250703.0 → 0.33.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.
@@ -1342,14 +1342,20 @@ function handleCheckItemEvent(event, callback) {
1342
1342
  return;
1343
1343
  }
1344
1344
  const rect = target.getBoundingClientRect();
1345
- const pageX = event.pageX / utils.calculateZoomLevel(target);
1345
+ const zoom = utils.calculateZoomLevel(target);
1346
+ const clientX = event.clientX / zoom;
1346
1347
 
1347
1348
  // Use getComputedStyle if available, otherwise fallback to 0px width
1348
1349
  const beforeStyles = window.getComputedStyle ? window.getComputedStyle(target, '::before') : {
1349
1350
  width: '0px'
1350
1351
  };
1351
1352
  const beforeWidthInPixels = parseFloat(beforeStyles.width);
1352
- if (target.dir === 'rtl' ? pageX < rect.right && pageX > rect.right - beforeWidthInPixels : pageX > rect.left && pageX < rect.left + beforeWidthInPixels) {
1353
+
1354
+ // Make click area slightly larger for touch devices to improve accessibility
1355
+ const isTouchEvent = event.pointerType === 'touch';
1356
+ const clickAreaPadding = isTouchEvent ? 32 : 0; // Add 32px padding for touch events
1357
+
1358
+ if (target.dir === 'rtl' ? clientX < rect.right + clickAreaPadding && clientX > rect.right - beforeWidthInPixels - clickAreaPadding : clientX > rect.left - clickAreaPadding && clientX < rect.left + beforeWidthInPixels + clickAreaPadding) {
1353
1359
  callback();
1354
1360
  }
1355
1361
  }
@@ -1340,14 +1340,20 @@ function handleCheckItemEvent(event, callback) {
1340
1340
  return;
1341
1341
  }
1342
1342
  const rect = target.getBoundingClientRect();
1343
- const pageX = event.pageX / calculateZoomLevel(target);
1343
+ const zoom = calculateZoomLevel(target);
1344
+ const clientX = event.clientX / zoom;
1344
1345
 
1345
1346
  // Use getComputedStyle if available, otherwise fallback to 0px width
1346
1347
  const beforeStyles = window.getComputedStyle ? window.getComputedStyle(target, '::before') : {
1347
1348
  width: '0px'
1348
1349
  };
1349
1350
  const beforeWidthInPixels = parseFloat(beforeStyles.width);
1350
- if (target.dir === 'rtl' ? pageX < rect.right && pageX > rect.right - beforeWidthInPixels : pageX > rect.left && pageX < rect.left + beforeWidthInPixels) {
1351
+
1352
+ // Make click area slightly larger for touch devices to improve accessibility
1353
+ const isTouchEvent = event.pointerType === 'touch';
1354
+ const clickAreaPadding = isTouchEvent ? 32 : 0; // Add 32px padding for touch events
1355
+
1356
+ if (target.dir === 'rtl' ? clientX < rect.right + clickAreaPadding && clientX > rect.right - beforeWidthInPixels - clickAreaPadding : clientX > rect.left - clickAreaPadding && clientX < rect.left + beforeWidthInPixels + clickAreaPadding) {
1351
1357
  callback();
1352
1358
  }
1353
1359
  }
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- "use strict";var e=require("@lexical/utils"),t=require("lexical"),r=require("@lexical/selection");function n(e,...t){const r=new URL("https://lexical.dev/docs/error"),n=new URLSearchParams;n.append("code",e);for(const e of t)n.append("v",e);throw r.search=n.toString(),Error(`Minified Lexical error #${e}; visit ${r.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function s(e){let t=1,r=e.getParent();for(;null!=r;){if(L(r)){const e=r.getParent();if(R(e)){t++,r=e.getParent();continue}n(40)}return t}return t}function i(e){let t=e.getParent();R(t)||n(40);let r=t;for(;null!==r;)r=r.getParent(),R(r)&&(t=r);return t}function o(e){let t=[];const r=e.getChildren().filter(L);for(let e=0;e<r.length;e++){const n=r[e],s=n.getFirstChild();R(s)?t=t.concat(o(s)):t.push(n)}return t}function l(e){return L(e)&&R(e.getFirstChild())}function c(e){return O().append(e)}function a(e,t){return L(e)&&(0===t.length||1===t.length&&e.is(t[0])&&0===e.getChildrenSize())}function g(e){const r=t.$getSelection();if(null!==r){let s=r.getNodes();if(t.$isRangeSelection(r)){const i=r.getStartEndPoints();null===i&&n(143);const[o]=i,l=o.getNode(),c=l.getParent();if(t.$isRootOrShadowRoot(l)){const e=l.getFirstChild();if(e)s=e.selectStart().getNodes();else{const e=t.$createParagraphNode();l.append(e),s=e.select().getNodes()}}else if(a(l,s)){const r=A(e);if(t.$isRootOrShadowRoot(c)){l.replace(r);const e=O();t.$isElementNode(l)&&(e.setFormat(l.getFormatType()),e.setIndent(l.getIndent())),r.append(e)}else if(L(l)){const e=l.getParentOrThrow();d(r,e.getChildren()),e.replace(r)}return}}const i=new Set;for(let r=0;r<s.length;r++){const n=s[r];if(t.$isElementNode(n)&&n.isEmpty()&&!L(n)&&!i.has(n.getKey())){u(n,e);continue}let o=t.$isLeafNode(n)?n.getParent():L(n)&&n.isEmpty()?n:null;for(;null!=o;){const r=o.getKey();if(R(o)){if(!i.has(r)){const t=A(e);d(t,o.getChildren()),o.replace(t),i.add(r)}break}{const n=o.getParent();if(t.$isRootOrShadowRoot(n)&&!i.has(r)){i.add(r),u(o,e);break}o=n}}}}}function d(e,t){e.splice(e.getChildrenSize(),0,t)}function u(e,t){if(R(e))return e;const r=e.getPreviousSibling(),n=e.getNextSibling(),s=O();let i;if(d(s,e.getChildren()),R(r)&&t===r.getListType())r.append(s),R(n)&&t===n.getListType()&&(d(r,n.getChildren()),n.remove()),i=r;else if(R(n)&&t===n.getListType())n.getFirstChildOrThrow().insertBefore(s),i=n;else{const r=A(t);r.append(s),e.replace(r),i=r}return s.setFormat(e.getFormatType()),s.setIndent(e.getIndent()),e.remove(),i}function h(e,t){const r=e.getLastChild(),n=t.getFirstChild();r&&n&&l(r)&&l(n)&&(h(r.getFirstChild(),n.getFirstChild()),n.remove());const s=t.getChildren();s.length>0&&e.append(...s),t.remove()}function f(){const r=t.$getSelection();if(t.$isRangeSelection(r)){const n=new Set,s=r.getNodes(),l=r.anchor.getNode();if(a(l,s))n.add(i(l));else for(let r=0;r<s.length;r++){const o=s[r];if(t.$isLeafNode(o)){const t=e.$getNearestNodeOfType(o,T);null!=t&&n.add(i(t))}}for(const e of n){let n=e;const s=o(e);for(const e of s){const s=t.$createParagraphNode().setTextStyle(r.style).setTextFormat(r.format);d(s,e.getChildren()),n.insertAfter(s),n=s,e.__key===r.anchor.key&&t.$setPointFromCaret(r.anchor,t.$normalizeCaret(t.$getChildCaret(s,"next"))),e.__key===r.focus.key&&t.$setPointFromCaret(r.focus,t.$normalizeCaret(t.$getChildCaret(s,"next"))),e.remove()}e.remove()}}}function p(e){const t="check"!==e.getListType();let r=e.getStart();for(const n of e.getChildren())L(n)&&(n.getValue()!==r&&n.setValue(r),t&&null!=n.getLatest().__checked&&n.setChecked(void 0),R(n.getFirstChild())||r++)}function m(e){const t=new Set;if(l(e)||t.has(e.getKey()))return;const r=e.getParent(),n=e.getNextSibling(),s=e.getPreviousSibling();if(l(n)&&l(s)){const r=s.getFirstChild();if(R(r)){r.append(e);const s=n.getFirstChild();if(R(s)){d(r,s.getChildren()),n.remove(),t.add(n.getKey())}}}else if(l(n)){const t=n.getFirstChild();if(R(t)){const r=t.getFirstChild();null!==r&&r.insertBefore(e)}}else if(l(s)){const t=s.getFirstChild();R(t)&&t.append(e)}else if(R(r)){const t=O().setTextFormat(e.getTextFormat()).setTextStyle(e.getTextStyle()),i=A(r.getListType()).setTextFormat(r.getTextFormat()).setTextStyle(r.getTextStyle());t.append(i),i.append(e),s?s.insertAfter(t):n?n.insertBefore(t):r.append(t)}}function _(e){if(l(e))return;const t=e.getParent(),r=t?t.getParent():void 0;if(R(r?r.getParent():void 0)&&L(r)&&R(t)){const n=t?t.getFirstChild():void 0,s=t?t.getLastChild():void 0;if(e.is(n))r.insertBefore(e),t.isEmpty()&&r.remove();else if(e.is(s))r.insertAfter(e),t.isEmpty()&&r.remove();else{const n=t.getListType(),s=O(),i=A(n);s.append(i),e.getPreviousSiblings().forEach((e=>i.append(e)));const o=O(),l=A(n);o.append(l),d(l,e.getNextSiblings()),r.insertBefore(s),r.insertAfter(o),r.replace(e)}}}function C(){const e=t.$getSelection();if(!t.$isRangeSelection(e)||!e.isCollapsed())return!1;const r=e.anchor.getNode();if(!L(r)||0!==r.getChildrenSize())return!1;const s=i(r),o=r.getParent();R(o)||n(40);const l=o.getParent();let c;if(t.$isRootOrShadowRoot(l))c=t.$createParagraphNode(),s.insertAfter(c);else{if(!L(l))return!1;c=O(),l.insertAfter(c)}c.setTextStyle(e.style).setTextFormat(e.format).select();const a=r.getNextSiblings();if(a.length>0){const e=A(o.getListType());if(L(c)){const t=O();t.append(e),c.insertAfter(t)}else c.insertAfter(e);e.append(...a)}return function(e){let t=e;for(;null==t.getNextSibling()&&null==t.getPreviousSibling();){const e=t.getParent();if(null==e||!L(e)&&!R(e))break;t=e}t.remove()}(r),!0}function N(...e){const t=[];for(const r of e)if(r&&"string"==typeof r)for(const[e]of r.matchAll(/\S+/g))t.push(e);return t}class T extends t.ElementNode{$config(){return this.config("listitem",{$transform:e=>{if(null==e.__checked)return;const t=e.getParent();R(t)&&"check"!==t.getListType()&&null!=e.getChecked()&&e.setChecked(void 0)},extends:t.ElementNode,importDOM:t.buildImportMap({li:()=>({conversion:S,priority:0})})})}constructor(e=1,t=void 0,r){super(r),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=document.createElement("li");return this.updateListItemDOM(null,t,e),t}updateListItemDOM(t,n,s){const i=this.getParent();R(i)&&"check"===i.getListType()&&function(e,t,r,n){R(t.getFirstChild())?(e.removeAttribute("role"),e.removeAttribute("tabIndex"),e.removeAttribute("aria-checked")):(e.setAttribute("role","checkbox"),e.setAttribute("tabIndex","-1"),r&&t.__checked===r.__checked||e.setAttribute("aria-checked",t.getChecked()?"true":"false"))}(n,this,t),n.value=this.__value,function(t,r,n){const s=[],i=[],o=r.list,l=o?o.listitem:void 0;let c;o&&o.nested&&(c=o.nested.listitem);void 0!==l&&s.push(...N(l));if(o){const e=n.getParent(),t=R(e)&&"check"===e.getListType(),r=n.getChecked();t&&!r||i.push(o.listitemUnchecked),t&&r||i.push(o.listitemChecked),t&&s.push(r?o.listitemChecked:o.listitemUnchecked)}if(void 0!==c){const e=N(c);n.getChildren().some((e=>R(e)))?s.push(...e):i.push(...e)}i.length>0&&e.removeClassNamesFromElement(t,...i);s.length>0&&e.addClassNamesToElement(t,...s)}(n,s.theme,this);const o=t?t.__style:"",l=this.__style;o!==l&&(""===l?n.removeAttribute("style"):n.style.cssText=l),function(e,t,n){const s=r.getStyleObjectFromCSS(t.__textStyle);for(const t in s)e.style.setProperty(`--listitem-marker-${t}`,s[t]);if(n)for(const t in r.getStyleObjectFromCSS(n.__textStyle))t in s||e.style.removeProperty(`--listitem-marker-${t}`)}(n,this,t)}updateDOM(e,t,r){const n=t;return this.updateListItemDOM(e,n,r),!1}updateFromJSON(e){return super.updateFromJSON(e).setValue(e.value).setChecked(e.checked)}exportDOM(e){const t=this.createDOM(e._config),r=this.getFormatType();r&&(t.style.textAlign=r);const n=this.getDirection();return n&&(t.dir=n),{element:t}}exportJSON(){return{...super.exportJSON(),checked:this.getChecked(),value:this.getValue()}}append(...e){for(let r=0;r<e.length;r++){const n=e[r];if(t.$isElementNode(n)&&this.canMergeWith(n)){const e=n.getChildren();this.append(...e),n.remove()}else super.append(n)}return this}replace(e,r){if(L(e))return super.replace(e);this.setIndent(0);const s=this.getParentOrThrow();if(!R(s))return e;if(s.__first===this.getKey())s.insertBefore(e);else if(s.__last===this.getKey())s.insertAfter(e);else{const t=A(s.getListType());let r=this.getNextSibling();for(;r;){const e=r;r=r.getNextSibling(),t.append(e)}s.insertAfter(e),e.insertAfter(t)}return r&&(t.$isElementNode(e)||n(139),this.getChildren().forEach((t=>{e.append(t)}))),this.remove(),0===s.getChildrenSize()&&s.remove(),e}insertAfter(e,t=!0){const r=this.getParentOrThrow();if(R(r)||n(39),L(e))return super.insertAfter(e,t);const s=this.getNextSiblings();if(r.insertAfter(e,t),0!==s.length){const n=A(r.getListType());s.forEach((e=>n.append(e))),e.insertAfter(n,t)}return e}remove(e){const t=this.getPreviousSibling(),r=this.getNextSibling();super.remove(e),t&&r&&l(t)&&l(r)&&(h(t.getFirstChild(),r.getFirstChild()),r.remove())}insertNewAfter(e,t=!0){const r=O().updateFromJSON(this.exportJSON()).setChecked(!this.getChecked()&&void 0);return this.insertAfter(r,t),r}collapseAtStart(e){const r=t.$createParagraphNode();this.getChildren().forEach((e=>r.append(e)));const n=this.getParentOrThrow(),s=n.getParentOrThrow(),i=L(s);if(1===n.getChildrenSize())if(i)n.remove(),s.select();else{n.insertBefore(r),n.remove();const t=e.anchor,s=e.focus,i=r.getKey();"element"===t.type&&t.getNode().is(this)&&t.set(i,t.offset,"element"),"element"===s.type&&s.getNode().is(this)&&s.set(i,s.offset,"element")}else n.insertBefore(r),this.remove();return!0}getValue(){return this.getLatest().__value}setValue(e){const t=this.getWritable();return t.__value=e,t}getChecked(){const e=this.getLatest();let t;const r=this.getParent();return R(r)&&(t=r.getListType()),"check"===t?Boolean(e.__checked):void 0}setChecked(e){const t=this.getWritable();return t.__checked=e,t}toggleChecked(){const e=this.getWritable();return e.setChecked(!e.__checked)}getIndent(){const e=this.getParent();if(null===e||!this.isAttached())return this.getLatest().__indent;let t=e.getParentOrThrow(),r=0;for(;L(t);)t=t.getParentOrThrow().getParentOrThrow(),r++;return r}setIndent(e){"number"!=typeof e&&n(117),(e=Math.floor(e))>=0||n(199);let t=this.getIndent();for(;t!==e;)t<e?(m(this),t++):(_(this),t--);return this}canInsertAfter(e){return L(e)}canReplaceWith(e){return L(e)}canMergeWith(e){return L(e)||t.$isParagraphNode(e)}extractWithChild(e,r){if(!t.$isRangeSelection(r))return!1;const n=r.anchor.getNode(),s=r.focus.getNode();return this.isParentOf(n)&&this.isParentOf(s)&&this.getTextContent().length===r.getTextContent().length}isParentRequired(){return!0}createParentElementNode(){return A("bullet")}canMergeWhenEmpty(){return!0}}function S(e){if(e.classList.contains("task-list-item"))for(const t of e.children)if("INPUT"===t.tagName)return y(t);const t=e.getAttribute("aria-checked");return{node:O("true"===t||"false"!==t&&void 0)}}function y(e){if(!("checkbox"===e.getAttribute("type")))return{node:null};return{node:O(e.hasAttribute("checked"))}}function O(e){return t.$applyNodeReplacement(new T(void 0,e))}function L(e){return e instanceof T}class x extends t.ElementNode{$config(){return this.config("list",{$transform:e=>{!function(e){const t=e.getNextSibling();R(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,r){super(r);const n=P[e]||e;this.__listType=n,this.__tag="number"===n?"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 r=this.__tag,n=document.createElement(r);return 1!==this.__start&&n.setAttribute("start",String(this.__start)),n.__lexicalListType=this.__listType,v(n,e.theme,this),n}updateDOM(e,t,r){return e.__tag!==this.__tag||(v(t,r.theme,this),!1)}updateFromJSON(e){return super.updateFromJSON(e).setListType(e.listType).setStart(e.start)}exportDOM(t){const r=this.createDOM(t._config,t);return e.isHTMLElement(r)&&(1!==this.__start&&r.setAttribute("start",String(this.__start)),"check"===this.__listType&&r.setAttribute("__lexicalListType","check")),{element:r}}exportJSON(){return{...super.exportJSON(),listType:this.getListType(),start:this.getStart(),tag:this.getTag()}}canBeEmpty(){return!1}canIndent(){return!1}splice(e,r,n){let s=n;for(let e=0;e<n.length;e++){const r=n[e];L(r)||(s===n&&(s=[...n]),s[e]=O().append(!t.$isElementNode(r)||R(r)||r.isInline()?r:t.$createTextNode(r.getTextContent())))}return super.splice(e,r,s)}extractWithChild(e){return L(e)}}function v(t,r,n){const i=[],o=[],l=r.list;if(void 0!==l){const e=l[`${n.__tag}Depth`]||[],t=s(n)-1,r=t%e.length,c=e[r],a=l[n.__tag];let g;const d=l.nested,u=l.checklist;if(void 0!==d&&d.list&&(g=d.list),void 0!==a&&i.push(a),void 0!==u&&"check"===n.__listType&&i.push(u),void 0!==c){i.push(...N(c));for(let t=0;t<e.length;t++)t!==r&&o.push(n.__tag+t)}if(void 0!==g){const e=N(g);t>1?i.push(...e):o.push(...e)}}o.length>0&&e.removeClassNamesFromElement(t,...o),i.length>0&&e.addClassNamesToElement(t,...i)}function M(e){const t=[];for(let r=0;r<e.length;r++){const n=e[r];if(L(n)){t.push(n);const e=n.getChildren();e.length>1&&e.forEach((e=>{R(e)&&t.push(c(e))}))}else t.push(c(n))}return t}function E(t){const r=t.nodeName.toLowerCase();let n=null;if("ol"===r){n=A("number",t.start)}else"ul"===r&&(n=function(t){if("check"===t.getAttribute("__lexicallisttype")||t.classList.contains("contains-task-list"))return!0;for(const r of t.childNodes)if(e.isHTMLElement(r)&&r.hasAttribute("aria-checked"))return!0;return!1}(t)?A("check"):A("bullet"));return{after:M,node:n}}const P={ol:"number",ul:"bullet"};function A(e="number",r=1){return t.$applyNodeReplacement(new x(e,r))}function R(e){return e instanceof x}const k=t.createCommand("INSERT_CHECK_LIST_COMMAND");function b(t,r){const n=t.target;if(!e.isHTMLElement(n))return;const s=n.firstChild;if(e.isHTMLElement(s)&&("UL"===s.tagName||"OL"===s.tagName))return;const i=n.parentNode;if(!i||"check"!==i.__lexicalListType)return;const o=n.getBoundingClientRect(),l=t.pageX/e.calculateZoomLevel(n),c=window.getComputedStyle?window.getComputedStyle(n,"::before"):{width:"0px"},a=parseFloat(c.width);("rtl"===n.dir?l<o.right&&l>o.right-a:l>o.left&&l<o.left+a)&&r()}function I(r){b(r,(()=>{if(e.isHTMLElement(r.target)){const e=r.target,n=t.getNearestEditorFromDOMNode(e);null!=n&&n.isEditable()&&n.update((()=>{const r=t.$getNearestNodeFromDOMNode(e);L(r)&&(e.focus(),r.toggleChecked())}))}}))}function F(e){b(e,(()=>{e.preventDefault()}))}function D(){const t=document.activeElement;return e.isHTMLElement(t)&&"LI"===t.tagName&&null!=t.parentNode&&"check"===t.parentNode.__lexicalListType?t:null}function $(e,r,n){const s=D();return null!=s&&r.update((()=>{const i=t.$getNearestNodeFromDOMNode(s);if(!L(i))return;const o=function(e,t){let r=t?e.getPreviousSibling():e.getNextSibling(),n=e;for(;null==r&&L(n);)n=n.getParentOrThrow().getParent(),null!=n&&(r=t?n.getPreviousSibling():n.getNextSibling());for(;L(r);){const e=t?r.getLastChild():r.getFirstChild();if(!R(e))return r;r=t?e.getLastChild():e.getFirstChild()}return null}(i,n);if(null!=o){o.selectStart();const t=r.getElementByKey(o.__key);null!=t&&(e.preventDefault(),setTimeout((()=>{t.focus()}),0))}})),!1}const w=t.createCommand("UPDATE_LIST_START_COMMAND"),W=t.createCommand("INSERT_UNORDERED_LIST_COMMAND"),K=t.createCommand("INSERT_ORDERED_LIST_COMMAND"),Y=t.createCommand("REMOVE_LIST_COMMAND");exports.$createListItemNode=O,exports.$createListNode=A,exports.$getListDepth=s,exports.$handleListInsertParagraph=C,exports.$insertList=g,exports.$isListItemNode=L,exports.$isListNode=R,exports.$removeList=f,exports.INSERT_CHECK_LIST_COMMAND=k,exports.INSERT_ORDERED_LIST_COMMAND=K,exports.INSERT_UNORDERED_LIST_COMMAND=W,exports.ListItemNode=T,exports.ListNode=x,exports.REMOVE_LIST_COMMAND=Y,exports.UPDATE_LIST_START_COMMAND=w,exports.insertList=function(e,t){e.update((()=>g(t)))},exports.registerCheckList=function(r){return e.mergeRegister(r.registerCommand(k,(()=>(g("check"),!0)),t.COMMAND_PRIORITY_LOW),r.registerCommand(t.KEY_ARROW_DOWN_COMMAND,(e=>$(e,r,!1)),t.COMMAND_PRIORITY_LOW),r.registerCommand(t.KEY_ARROW_UP_COMMAND,(e=>$(e,r,!0)),t.COMMAND_PRIORITY_LOW),r.registerCommand(t.KEY_ESCAPE_COMMAND,(()=>{if(null!=D()){const e=r.getRootElement();return null!=e&&e.focus(),!0}return!1}),t.COMMAND_PRIORITY_LOW),r.registerCommand(t.KEY_SPACE_COMMAND,(e=>{const n=D();return!(null==n||!r.isEditable())&&(r.update((()=>{const r=t.$getNearestNodeFromDOMNode(n);L(r)&&(e.preventDefault(),r.toggleChecked())})),!0)}),t.COMMAND_PRIORITY_LOW),r.registerCommand(t.KEY_ARROW_LEFT_COMMAND,(n=>r.getEditorState().read((()=>{const s=t.$getSelection();if(t.$isRangeSelection(s)&&s.isCollapsed()){const{anchor:i}=s,o="element"===i.type;if(o||0===i.offset){const s=i.getNode(),l=e.$findMatchingParent(s,(e=>t.$isElementNode(e)&&!e.isInline()));if(L(l)){const e=l.getParent();if(R(e)&&"check"===e.getListType()&&(o||l.getFirstDescendant()===s)){const e=r.getElementByKey(l.__key);if(null!=e&&document.activeElement!==e)return e.focus(),n.preventDefault(),!0}}}}return!1}))),t.COMMAND_PRIORITY_LOW),r.registerRootListener(((e,t)=>{null!==e&&(e.addEventListener("click",I),e.addEventListener("pointerdown",F)),null!==t&&(t.removeEventListener("click",I),t.removeEventListener("pointerdown",F))})))},exports.registerList=function(r){const n=e.mergeRegister(r.registerCommand(K,(()=>(g("number"),!0)),t.COMMAND_PRIORITY_LOW),r.registerCommand(w,(e=>{const{listNodeKey:r,newStart:n}=e,s=t.$getNodeByKey(r);return!!R(s)&&("number"===s.getListType()&&(s.setStart(n),p(s)),!0)}),t.COMMAND_PRIORITY_LOW),r.registerCommand(W,(()=>(g("bullet"),!0)),t.COMMAND_PRIORITY_LOW),r.registerCommand(Y,(()=>(f(),!0)),t.COMMAND_PRIORITY_LOW),r.registerCommand(t.INSERT_PARAGRAPH_COMMAND,(()=>C()),t.COMMAND_PRIORITY_LOW),r.registerNodeTransform(T,(e=>{const r=e.getFirstChild();if(r){if(t.$isTextNode(r)){const t=r.getStyle(),n=r.getFormat();e.getTextStyle()!==t&&e.setTextStyle(t),e.getTextFormat()!==n&&e.setTextFormat(n)}}else{const r=t.$getSelection();t.$isRangeSelection(r)&&(r.style!==e.getTextStyle()||r.format!==e.getTextFormat())&&r.isCollapsed()&&e.is(r.anchor.getNode())&&e.setTextStyle(r.style).setTextFormat(r.format)}})),r.registerNodeTransform(t.TextNode,(e=>{const t=e.getParent();if(L(t)&&e.is(t.getFirstChild())){const r=e.getStyle(),n=e.getFormat();r===t.getTextStyle()&&n===t.getTextFormat()||t.setTextStyle(r).setTextFormat(n)}})));return n},exports.registerListStrictIndentTransform=function(t){const r=t=>{const r=t.getParent();if(R(t.getFirstChild())||!R(r))return;const n=e.$findMatchingParent(t,(e=>L(e)&&R(e.getParent())&&L(e.getPreviousSibling())));if(null===n&&t.getIndent()>0)t.setIndent(0);else if(L(n)){const e=n.getPreviousSibling();if(L(e)){const n=function(e){let t=e,r=t.getFirstChild();for(;R(r);){const e=r.getLastChild();if(!L(e))break;t=e,r=t.getFirstChild()}return t}(e),i=n.getParent();if(R(i)){const e=s(i);e+1<s(r)&&t.setIndent(e)}}}};return t.registerNodeTransform(x,(e=>{const t=[e];for(;t.length>0;){const e=t.shift();if(R(e))for(const n of e.getChildren())if(L(n)){r(n);const e=n.getFirstChild();R(e)&&t.push(e)}}}))},exports.removeList=function(e){e.update((()=>f()))};
9
+ "use strict";var e=require("@lexical/utils"),t=require("lexical"),r=require("@lexical/selection");function n(e,...t){const r=new URL("https://lexical.dev/docs/error"),n=new URLSearchParams;n.append("code",e);for(const e of t)n.append("v",e);throw r.search=n.toString(),Error(`Minified Lexical error #${e}; visit ${r.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function s(e){let t=1,r=e.getParent();for(;null!=r;){if(L(r)){const e=r.getParent();if(R(e)){t++,r=e.getParent();continue}n(40)}return t}return t}function i(e){let t=e.getParent();R(t)||n(40);let r=t;for(;null!==r;)r=r.getParent(),R(r)&&(t=r);return t}function o(e){let t=[];const r=e.getChildren().filter(L);for(let e=0;e<r.length;e++){const n=r[e],s=n.getFirstChild();R(s)?t=t.concat(o(s)):t.push(n)}return t}function l(e){return L(e)&&R(e.getFirstChild())}function c(e){return O().append(e)}function a(e,t){return L(e)&&(0===t.length||1===t.length&&e.is(t[0])&&0===e.getChildrenSize())}function g(e){const r=t.$getSelection();if(null!==r){let s=r.getNodes();if(t.$isRangeSelection(r)){const i=r.getStartEndPoints();null===i&&n(143);const[o]=i,l=o.getNode(),c=l.getParent();if(t.$isRootOrShadowRoot(l)){const e=l.getFirstChild();if(e)s=e.selectStart().getNodes();else{const e=t.$createParagraphNode();l.append(e),s=e.select().getNodes()}}else if(a(l,s)){const r=A(e);if(t.$isRootOrShadowRoot(c)){l.replace(r);const e=O();t.$isElementNode(l)&&(e.setFormat(l.getFormatType()),e.setIndent(l.getIndent())),r.append(e)}else if(L(l)){const e=l.getParentOrThrow();d(r,e.getChildren()),e.replace(r)}return}}const i=new Set;for(let r=0;r<s.length;r++){const n=s[r];if(t.$isElementNode(n)&&n.isEmpty()&&!L(n)&&!i.has(n.getKey())){u(n,e);continue}let o=t.$isLeafNode(n)?n.getParent():L(n)&&n.isEmpty()?n:null;for(;null!=o;){const r=o.getKey();if(R(o)){if(!i.has(r)){const t=A(e);d(t,o.getChildren()),o.replace(t),i.add(r)}break}{const n=o.getParent();if(t.$isRootOrShadowRoot(n)&&!i.has(r)){i.add(r),u(o,e);break}o=n}}}}}function d(e,t){e.splice(e.getChildrenSize(),0,t)}function u(e,t){if(R(e))return e;const r=e.getPreviousSibling(),n=e.getNextSibling(),s=O();let i;if(d(s,e.getChildren()),R(r)&&t===r.getListType())r.append(s),R(n)&&t===n.getListType()&&(d(r,n.getChildren()),n.remove()),i=r;else if(R(n)&&t===n.getListType())n.getFirstChildOrThrow().insertBefore(s),i=n;else{const r=A(t);r.append(s),e.replace(r),i=r}return s.setFormat(e.getFormatType()),s.setIndent(e.getIndent()),e.remove(),i}function h(e,t){const r=e.getLastChild(),n=t.getFirstChild();r&&n&&l(r)&&l(n)&&(h(r.getFirstChild(),n.getFirstChild()),n.remove());const s=t.getChildren();s.length>0&&e.append(...s),t.remove()}function f(){const r=t.$getSelection();if(t.$isRangeSelection(r)){const n=new Set,s=r.getNodes(),l=r.anchor.getNode();if(a(l,s))n.add(i(l));else for(let r=0;r<s.length;r++){const o=s[r];if(t.$isLeafNode(o)){const t=e.$getNearestNodeOfType(o,T);null!=t&&n.add(i(t))}}for(const e of n){let n=e;const s=o(e);for(const e of s){const s=t.$createParagraphNode().setTextStyle(r.style).setTextFormat(r.format);d(s,e.getChildren()),n.insertAfter(s),n=s,e.__key===r.anchor.key&&t.$setPointFromCaret(r.anchor,t.$normalizeCaret(t.$getChildCaret(s,"next"))),e.__key===r.focus.key&&t.$setPointFromCaret(r.focus,t.$normalizeCaret(t.$getChildCaret(s,"next"))),e.remove()}e.remove()}}}function p(e){const t="check"!==e.getListType();let r=e.getStart();for(const n of e.getChildren())L(n)&&(n.getValue()!==r&&n.setValue(r),t&&null!=n.getLatest().__checked&&n.setChecked(void 0),R(n.getFirstChild())||r++)}function m(e){const t=new Set;if(l(e)||t.has(e.getKey()))return;const r=e.getParent(),n=e.getNextSibling(),s=e.getPreviousSibling();if(l(n)&&l(s)){const r=s.getFirstChild();if(R(r)){r.append(e);const s=n.getFirstChild();if(R(s)){d(r,s.getChildren()),n.remove(),t.add(n.getKey())}}}else if(l(n)){const t=n.getFirstChild();if(R(t)){const r=t.getFirstChild();null!==r&&r.insertBefore(e)}}else if(l(s)){const t=s.getFirstChild();R(t)&&t.append(e)}else if(R(r)){const t=O().setTextFormat(e.getTextFormat()).setTextStyle(e.getTextStyle()),i=A(r.getListType()).setTextFormat(r.getTextFormat()).setTextStyle(r.getTextStyle());t.append(i),i.append(e),s?s.insertAfter(t):n?n.insertBefore(t):r.append(t)}}function _(e){if(l(e))return;const t=e.getParent(),r=t?t.getParent():void 0;if(R(r?r.getParent():void 0)&&L(r)&&R(t)){const n=t?t.getFirstChild():void 0,s=t?t.getLastChild():void 0;if(e.is(n))r.insertBefore(e),t.isEmpty()&&r.remove();else if(e.is(s))r.insertAfter(e),t.isEmpty()&&r.remove();else{const n=t.getListType(),s=O(),i=A(n);s.append(i),e.getPreviousSiblings().forEach((e=>i.append(e)));const o=O(),l=A(n);o.append(l),d(l,e.getNextSiblings()),r.insertBefore(s),r.insertAfter(o),r.replace(e)}}}function C(){const e=t.$getSelection();if(!t.$isRangeSelection(e)||!e.isCollapsed())return!1;const r=e.anchor.getNode();if(!L(r)||0!==r.getChildrenSize())return!1;const s=i(r),o=r.getParent();R(o)||n(40);const l=o.getParent();let c;if(t.$isRootOrShadowRoot(l))c=t.$createParagraphNode(),s.insertAfter(c);else{if(!L(l))return!1;c=O(),l.insertAfter(c)}c.setTextStyle(e.style).setTextFormat(e.format).select();const a=r.getNextSiblings();if(a.length>0){const e=A(o.getListType());if(L(c)){const t=O();t.append(e),c.insertAfter(t)}else c.insertAfter(e);e.append(...a)}return function(e){let t=e;for(;null==t.getNextSibling()&&null==t.getPreviousSibling();){const e=t.getParent();if(null==e||!L(e)&&!R(e))break;t=e}t.remove()}(r),!0}function N(...e){const t=[];for(const r of e)if(r&&"string"==typeof r)for(const[e]of r.matchAll(/\S+/g))t.push(e);return t}class T extends t.ElementNode{$config(){return this.config("listitem",{$transform:e=>{if(null==e.__checked)return;const t=e.getParent();R(t)&&"check"!==t.getListType()&&null!=e.getChecked()&&e.setChecked(void 0)},extends:t.ElementNode,importDOM:t.buildImportMap({li:()=>({conversion:S,priority:0})})})}constructor(e=1,t=void 0,r){super(r),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=document.createElement("li");return this.updateListItemDOM(null,t,e),t}updateListItemDOM(t,n,s){const i=this.getParent();R(i)&&"check"===i.getListType()&&function(e,t,r,n){R(t.getFirstChild())?(e.removeAttribute("role"),e.removeAttribute("tabIndex"),e.removeAttribute("aria-checked")):(e.setAttribute("role","checkbox"),e.setAttribute("tabIndex","-1"),r&&t.__checked===r.__checked||e.setAttribute("aria-checked",t.getChecked()?"true":"false"))}(n,this,t),n.value=this.__value,function(t,r,n){const s=[],i=[],o=r.list,l=o?o.listitem:void 0;let c;o&&o.nested&&(c=o.nested.listitem);void 0!==l&&s.push(...N(l));if(o){const e=n.getParent(),t=R(e)&&"check"===e.getListType(),r=n.getChecked();t&&!r||i.push(o.listitemUnchecked),t&&r||i.push(o.listitemChecked),t&&s.push(r?o.listitemChecked:o.listitemUnchecked)}if(void 0!==c){const e=N(c);n.getChildren().some((e=>R(e)))?s.push(...e):i.push(...e)}i.length>0&&e.removeClassNamesFromElement(t,...i);s.length>0&&e.addClassNamesToElement(t,...s)}(n,s.theme,this);const o=t?t.__style:"",l=this.__style;o!==l&&(""===l?n.removeAttribute("style"):n.style.cssText=l),function(e,t,n){const s=r.getStyleObjectFromCSS(t.__textStyle);for(const t in s)e.style.setProperty(`--listitem-marker-${t}`,s[t]);if(n)for(const t in r.getStyleObjectFromCSS(n.__textStyle))t in s||e.style.removeProperty(`--listitem-marker-${t}`)}(n,this,t)}updateDOM(e,t,r){const n=t;return this.updateListItemDOM(e,n,r),!1}updateFromJSON(e){return super.updateFromJSON(e).setValue(e.value).setChecked(e.checked)}exportDOM(e){const t=this.createDOM(e._config),r=this.getFormatType();r&&(t.style.textAlign=r);const n=this.getDirection();return n&&(t.dir=n),{element:t}}exportJSON(){return{...super.exportJSON(),checked:this.getChecked(),value:this.getValue()}}append(...e){for(let r=0;r<e.length;r++){const n=e[r];if(t.$isElementNode(n)&&this.canMergeWith(n)){const e=n.getChildren();this.append(...e),n.remove()}else super.append(n)}return this}replace(e,r){if(L(e))return super.replace(e);this.setIndent(0);const s=this.getParentOrThrow();if(!R(s))return e;if(s.__first===this.getKey())s.insertBefore(e);else if(s.__last===this.getKey())s.insertAfter(e);else{const t=A(s.getListType());let r=this.getNextSibling();for(;r;){const e=r;r=r.getNextSibling(),t.append(e)}s.insertAfter(e),e.insertAfter(t)}return r&&(t.$isElementNode(e)||n(139),this.getChildren().forEach((t=>{e.append(t)}))),this.remove(),0===s.getChildrenSize()&&s.remove(),e}insertAfter(e,t=!0){const r=this.getParentOrThrow();if(R(r)||n(39),L(e))return super.insertAfter(e,t);const s=this.getNextSiblings();if(r.insertAfter(e,t),0!==s.length){const n=A(r.getListType());s.forEach((e=>n.append(e))),e.insertAfter(n,t)}return e}remove(e){const t=this.getPreviousSibling(),r=this.getNextSibling();super.remove(e),t&&r&&l(t)&&l(r)&&(h(t.getFirstChild(),r.getFirstChild()),r.remove())}insertNewAfter(e,t=!0){const r=O().updateFromJSON(this.exportJSON()).setChecked(!this.getChecked()&&void 0);return this.insertAfter(r,t),r}collapseAtStart(e){const r=t.$createParagraphNode();this.getChildren().forEach((e=>r.append(e)));const n=this.getParentOrThrow(),s=n.getParentOrThrow(),i=L(s);if(1===n.getChildrenSize())if(i)n.remove(),s.select();else{n.insertBefore(r),n.remove();const t=e.anchor,s=e.focus,i=r.getKey();"element"===t.type&&t.getNode().is(this)&&t.set(i,t.offset,"element"),"element"===s.type&&s.getNode().is(this)&&s.set(i,s.offset,"element")}else n.insertBefore(r),this.remove();return!0}getValue(){return this.getLatest().__value}setValue(e){const t=this.getWritable();return t.__value=e,t}getChecked(){const e=this.getLatest();let t;const r=this.getParent();return R(r)&&(t=r.getListType()),"check"===t?Boolean(e.__checked):void 0}setChecked(e){const t=this.getWritable();return t.__checked=e,t}toggleChecked(){const e=this.getWritable();return e.setChecked(!e.__checked)}getIndent(){const e=this.getParent();if(null===e||!this.isAttached())return this.getLatest().__indent;let t=e.getParentOrThrow(),r=0;for(;L(t);)t=t.getParentOrThrow().getParentOrThrow(),r++;return r}setIndent(e){"number"!=typeof e&&n(117),(e=Math.floor(e))>=0||n(199);let t=this.getIndent();for(;t!==e;)t<e?(m(this),t++):(_(this),t--);return this}canInsertAfter(e){return L(e)}canReplaceWith(e){return L(e)}canMergeWith(e){return L(e)||t.$isParagraphNode(e)}extractWithChild(e,r){if(!t.$isRangeSelection(r))return!1;const n=r.anchor.getNode(),s=r.focus.getNode();return this.isParentOf(n)&&this.isParentOf(s)&&this.getTextContent().length===r.getTextContent().length}isParentRequired(){return!0}createParentElementNode(){return A("bullet")}canMergeWhenEmpty(){return!0}}function S(e){if(e.classList.contains("task-list-item"))for(const t of e.children)if("INPUT"===t.tagName)return y(t);const t=e.getAttribute("aria-checked");return{node:O("true"===t||"false"!==t&&void 0)}}function y(e){if(!("checkbox"===e.getAttribute("type")))return{node:null};return{node:O(e.hasAttribute("checked"))}}function O(e){return t.$applyNodeReplacement(new T(void 0,e))}function L(e){return e instanceof T}class x extends t.ElementNode{$config(){return this.config("list",{$transform:e=>{!function(e){const t=e.getNextSibling();R(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,r){super(r);const n=P[e]||e;this.__listType=n,this.__tag="number"===n?"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 r=this.__tag,n=document.createElement(r);return 1!==this.__start&&n.setAttribute("start",String(this.__start)),n.__lexicalListType=this.__listType,v(n,e.theme,this),n}updateDOM(e,t,r){return e.__tag!==this.__tag||(v(t,r.theme,this),!1)}updateFromJSON(e){return super.updateFromJSON(e).setListType(e.listType).setStart(e.start)}exportDOM(t){const r=this.createDOM(t._config,t);return e.isHTMLElement(r)&&(1!==this.__start&&r.setAttribute("start",String(this.__start)),"check"===this.__listType&&r.setAttribute("__lexicalListType","check")),{element:r}}exportJSON(){return{...super.exportJSON(),listType:this.getListType(),start:this.getStart(),tag:this.getTag()}}canBeEmpty(){return!1}canIndent(){return!1}splice(e,r,n){let s=n;for(let e=0;e<n.length;e++){const r=n[e];L(r)||(s===n&&(s=[...n]),s[e]=O().append(!t.$isElementNode(r)||R(r)||r.isInline()?r:t.$createTextNode(r.getTextContent())))}return super.splice(e,r,s)}extractWithChild(e){return L(e)}}function v(t,r,n){const i=[],o=[],l=r.list;if(void 0!==l){const e=l[`${n.__tag}Depth`]||[],t=s(n)-1,r=t%e.length,c=e[r],a=l[n.__tag];let g;const d=l.nested,u=l.checklist;if(void 0!==d&&d.list&&(g=d.list),void 0!==a&&i.push(a),void 0!==u&&"check"===n.__listType&&i.push(u),void 0!==c){i.push(...N(c));for(let t=0;t<e.length;t++)t!==r&&o.push(n.__tag+t)}if(void 0!==g){const e=N(g);t>1?i.push(...e):o.push(...e)}}o.length>0&&e.removeClassNamesFromElement(t,...o),i.length>0&&e.addClassNamesToElement(t,...i)}function M(e){const t=[];for(let r=0;r<e.length;r++){const n=e[r];if(L(n)){t.push(n);const e=n.getChildren();e.length>1&&e.forEach((e=>{R(e)&&t.push(c(e))}))}else t.push(c(n))}return t}function E(t){const r=t.nodeName.toLowerCase();let n=null;if("ol"===r){n=A("number",t.start)}else"ul"===r&&(n=function(t){if("check"===t.getAttribute("__lexicallisttype")||t.classList.contains("contains-task-list"))return!0;for(const r of t.childNodes)if(e.isHTMLElement(r)&&r.hasAttribute("aria-checked"))return!0;return!1}(t)?A("check"):A("bullet"));return{after:M,node:n}}const P={ol:"number",ul:"bullet"};function A(e="number",r=1){return t.$applyNodeReplacement(new x(e,r))}function R(e){return e instanceof x}const k=t.createCommand("INSERT_CHECK_LIST_COMMAND");function b(t,r){const n=t.target;if(!e.isHTMLElement(n))return;const s=n.firstChild;if(e.isHTMLElement(s)&&("UL"===s.tagName||"OL"===s.tagName))return;const i=n.parentNode;if(!i||"check"!==i.__lexicalListType)return;const o=n.getBoundingClientRect(),l=e.calculateZoomLevel(n),c=t.clientX/l,a=window.getComputedStyle?window.getComputedStyle(n,"::before"):{width:"0px"},g=parseFloat(a.width),d="touch"===t.pointerType?32:0;("rtl"===n.dir?c<o.right+d&&c>o.right-g-d:c>o.left-d&&c<o.left+g+d)&&r()}function I(r){b(r,(()=>{if(e.isHTMLElement(r.target)){const e=r.target,n=t.getNearestEditorFromDOMNode(e);null!=n&&n.isEditable()&&n.update((()=>{const r=t.$getNearestNodeFromDOMNode(e);L(r)&&(e.focus(),r.toggleChecked())}))}}))}function F(e){b(e,(()=>{e.preventDefault()}))}function D(){const t=document.activeElement;return e.isHTMLElement(t)&&"LI"===t.tagName&&null!=t.parentNode&&"check"===t.parentNode.__lexicalListType?t:null}function $(e,r,n){const s=D();return null!=s&&r.update((()=>{const i=t.$getNearestNodeFromDOMNode(s);if(!L(i))return;const o=function(e,t){let r=t?e.getPreviousSibling():e.getNextSibling(),n=e;for(;null==r&&L(n);)n=n.getParentOrThrow().getParent(),null!=n&&(r=t?n.getPreviousSibling():n.getNextSibling());for(;L(r);){const e=t?r.getLastChild():r.getFirstChild();if(!R(e))return r;r=t?e.getLastChild():e.getFirstChild()}return null}(i,n);if(null!=o){o.selectStart();const t=r.getElementByKey(o.__key);null!=t&&(e.preventDefault(),setTimeout((()=>{t.focus()}),0))}})),!1}const w=t.createCommand("UPDATE_LIST_START_COMMAND"),W=t.createCommand("INSERT_UNORDERED_LIST_COMMAND"),K=t.createCommand("INSERT_ORDERED_LIST_COMMAND"),Y=t.createCommand("REMOVE_LIST_COMMAND");exports.$createListItemNode=O,exports.$createListNode=A,exports.$getListDepth=s,exports.$handleListInsertParagraph=C,exports.$insertList=g,exports.$isListItemNode=L,exports.$isListNode=R,exports.$removeList=f,exports.INSERT_CHECK_LIST_COMMAND=k,exports.INSERT_ORDERED_LIST_COMMAND=K,exports.INSERT_UNORDERED_LIST_COMMAND=W,exports.ListItemNode=T,exports.ListNode=x,exports.REMOVE_LIST_COMMAND=Y,exports.UPDATE_LIST_START_COMMAND=w,exports.insertList=function(e,t){e.update((()=>g(t)))},exports.registerCheckList=function(r){return e.mergeRegister(r.registerCommand(k,(()=>(g("check"),!0)),t.COMMAND_PRIORITY_LOW),r.registerCommand(t.KEY_ARROW_DOWN_COMMAND,(e=>$(e,r,!1)),t.COMMAND_PRIORITY_LOW),r.registerCommand(t.KEY_ARROW_UP_COMMAND,(e=>$(e,r,!0)),t.COMMAND_PRIORITY_LOW),r.registerCommand(t.KEY_ESCAPE_COMMAND,(()=>{if(null!=D()){const e=r.getRootElement();return null!=e&&e.focus(),!0}return!1}),t.COMMAND_PRIORITY_LOW),r.registerCommand(t.KEY_SPACE_COMMAND,(e=>{const n=D();return!(null==n||!r.isEditable())&&(r.update((()=>{const r=t.$getNearestNodeFromDOMNode(n);L(r)&&(e.preventDefault(),r.toggleChecked())})),!0)}),t.COMMAND_PRIORITY_LOW),r.registerCommand(t.KEY_ARROW_LEFT_COMMAND,(n=>r.getEditorState().read((()=>{const s=t.$getSelection();if(t.$isRangeSelection(s)&&s.isCollapsed()){const{anchor:i}=s,o="element"===i.type;if(o||0===i.offset){const s=i.getNode(),l=e.$findMatchingParent(s,(e=>t.$isElementNode(e)&&!e.isInline()));if(L(l)){const e=l.getParent();if(R(e)&&"check"===e.getListType()&&(o||l.getFirstDescendant()===s)){const e=r.getElementByKey(l.__key);if(null!=e&&document.activeElement!==e)return e.focus(),n.preventDefault(),!0}}}}return!1}))),t.COMMAND_PRIORITY_LOW),r.registerRootListener(((e,t)=>{null!==e&&(e.addEventListener("click",I),e.addEventListener("pointerdown",F)),null!==t&&(t.removeEventListener("click",I),t.removeEventListener("pointerdown",F))})))},exports.registerList=function(r){const n=e.mergeRegister(r.registerCommand(K,(()=>(g("number"),!0)),t.COMMAND_PRIORITY_LOW),r.registerCommand(w,(e=>{const{listNodeKey:r,newStart:n}=e,s=t.$getNodeByKey(r);return!!R(s)&&("number"===s.getListType()&&(s.setStart(n),p(s)),!0)}),t.COMMAND_PRIORITY_LOW),r.registerCommand(W,(()=>(g("bullet"),!0)),t.COMMAND_PRIORITY_LOW),r.registerCommand(Y,(()=>(f(),!0)),t.COMMAND_PRIORITY_LOW),r.registerCommand(t.INSERT_PARAGRAPH_COMMAND,(()=>C()),t.COMMAND_PRIORITY_LOW),r.registerNodeTransform(T,(e=>{const r=e.getFirstChild();if(r){if(t.$isTextNode(r)){const t=r.getStyle(),n=r.getFormat();e.getTextStyle()!==t&&e.setTextStyle(t),e.getTextFormat()!==n&&e.setTextFormat(n)}}else{const r=t.$getSelection();t.$isRangeSelection(r)&&(r.style!==e.getTextStyle()||r.format!==e.getTextFormat())&&r.isCollapsed()&&e.is(r.anchor.getNode())&&e.setTextStyle(r.style).setTextFormat(r.format)}})),r.registerNodeTransform(t.TextNode,(e=>{const t=e.getParent();if(L(t)&&e.is(t.getFirstChild())){const r=e.getStyle(),n=e.getFormat();r===t.getTextStyle()&&n===t.getTextFormat()||t.setTextStyle(r).setTextFormat(n)}})));return n},exports.registerListStrictIndentTransform=function(t){const r=t=>{const r=t.getParent();if(R(t.getFirstChild())||!R(r))return;const n=e.$findMatchingParent(t,(e=>L(e)&&R(e.getParent())&&L(e.getPreviousSibling())));if(null===n&&t.getIndent()>0)t.setIndent(0);else if(L(n)){const e=n.getPreviousSibling();if(L(e)){const n=function(e){let t=e,r=t.getFirstChild();for(;R(r);){const e=r.getLastChild();if(!L(e))break;t=e,r=t.getFirstChild()}return t}(e),i=n.getParent();if(R(i)){const e=s(i);e+1<s(r)&&t.setIndent(e)}}}};return t.registerNodeTransform(x,(e=>{const t=[e];for(;t.length>0;){const e=t.shift();if(R(e))for(const n of e.getChildren())if(L(n)){r(n);const e=n.getFirstChild();R(e)&&t.push(e)}}}))},exports.removeList=function(e){e.update((()=>f()))};
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- import{$getNearestNodeOfType as t,removeClassNamesFromElement as e,addClassNamesToElement as n,isHTMLElement as r,mergeRegister as i,$findMatchingParent as s,calculateZoomLevel as o}from"@lexical/utils";import{$getSelection as l,$isRangeSelection as c,$isRootOrShadowRoot as a,$createParagraphNode as g,$isElementNode as u,$isLeafNode as h,$setPointFromCaret as f,$normalizeCaret as d,$getChildCaret as p,ElementNode as m,buildImportMap as _,$isParagraphNode as y,$applyNodeReplacement as C,$createTextNode as T,createCommand as S,COMMAND_PRIORITY_LOW as v,KEY_ARROW_DOWN_COMMAND as x,KEY_ARROW_UP_COMMAND as k,KEY_ESCAPE_COMMAND as b,KEY_SPACE_COMMAND as N,$getNearestNodeFromDOMNode as L,KEY_ARROW_LEFT_COMMAND as F,getNearestEditorFromDOMNode as P,$getNodeByKey as A,INSERT_PARAGRAPH_COMMAND as O,$isTextNode as E,TextNode as w}from"lexical";import{getStyleObjectFromCSS as D}from"@lexical/selection";function I(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 M(t){let e=1,n=t.getParent();for(;null!=n;){if(nt(n)){const t=n.getParent();if(at(t)){e++,n=t.getParent();continue}I(40)}return e}return e}function R(t){let e=t.getParent();at(e)||I(40);let n=e;for(;null!==n;)n=n.getParent(),at(n)&&(e=n);return e}function B(t){let e=[];const n=t.getChildren().filter(nt);for(let t=0;t<n.length;t++){const r=n[t],i=r.getFirstChild();at(i)?e=e.concat(B(i)):e.push(r)}return e}function K(t){return nt(t)&&at(t.getFirstChild())}function W(t){return et().append(t)}function J(t,e){return nt(t)&&(0===e.length||1===e.length&&t.is(e[0])&&0===t.getChildrenSize())}function $(t){const e=l();if(null!==e){let n=e.getNodes();if(c(e)){const r=e.getStartEndPoints();null===r&&I(143);const[i]=r,s=i.getNode(),o=s.getParent();if(a(s)){const t=s.getFirstChild();if(t)n=t.selectStart().getNodes();else{const t=g();s.append(t),n=t.select().getNodes()}}else if(J(s,n)){const e=ct(t);if(a(o)){s.replace(e);const t=et();u(s)&&(t.setFormat(s.getFormatType()),t.setIndent(s.getIndent())),e.append(t)}else if(nt(s)){const t=s.getParentOrThrow();U(e,t.getChildren()),t.replace(e)}return}}const r=new Set;for(let e=0;e<n.length;e++){const i=n[e];if(u(i)&&i.isEmpty()&&!nt(i)&&!r.has(i.getKey())){V(i,t);continue}let s=h(i)?i.getParent():nt(i)&&i.isEmpty()?i:null;for(;null!=s;){const e=s.getKey();if(at(s)){if(!r.has(e)){const n=ct(t);U(n,s.getChildren()),s.replace(n),r.add(e)}break}{const n=s.getParent();if(a(n)&&!r.has(e)){r.add(e),V(s,t);break}s=n}}}}}function U(t,e){t.splice(t.getChildrenSize(),0,e)}function V(t,e){if(at(t))return t;const n=t.getPreviousSibling(),r=t.getNextSibling(),i=et();let s;if(U(i,t.getChildren()),at(n)&&e===n.getListType())n.append(i),at(r)&&e===r.getListType()&&(U(n,r.getChildren()),r.remove()),s=n;else if(at(r)&&e===r.getListType())r.getFirstChildOrThrow().insertBefore(i),s=r;else{const n=ct(e);n.append(i),t.replace(n),s=n}return i.setFormat(t.getFormatType()),i.setIndent(t.getIndent()),t.remove(),s}function z(t,e){const n=t.getLastChild(),r=e.getFirstChild();n&&r&&K(n)&&K(r)&&(z(n.getFirstChild(),r.getFirstChild()),r.remove());const i=e.getChildren();i.length>0&&t.append(...i),e.remove()}function q(){const e=l();if(c(e)){const n=new Set,r=e.getNodes(),i=e.anchor.getNode();if(J(i,r))n.add(R(i));else for(let e=0;e<r.length;e++){const i=r[e];if(h(i)){const e=t(i,Y);null!=e&&n.add(R(e))}}for(const t of n){let n=t;const r=B(t);for(const t of r){const r=g().setTextStyle(e.style).setTextFormat(e.format);U(r,t.getChildren()),n.insertAfter(r),n=r,t.__key===e.anchor.key&&f(e.anchor,d(p(r,"next"))),t.__key===e.focus.key&&f(e.focus,d(p(r,"next"))),t.remove()}t.remove()}}}function H(t){const e="check"!==t.getListType();let n=t.getStart();for(const r of t.getChildren())nt(r)&&(r.getValue()!==n&&r.setValue(n),e&&null!=r.getLatest().__checked&&r.setChecked(void 0),at(r.getFirstChild())||n++)}function X(t){const e=new Set;if(K(t)||e.has(t.getKey()))return;const n=t.getParent(),r=t.getNextSibling(),i=t.getPreviousSibling();if(K(r)&&K(i)){const n=i.getFirstChild();if(at(n)){n.append(t);const i=r.getFirstChild();if(at(i)){U(n,i.getChildren()),r.remove(),e.add(r.getKey())}}}else if(K(r)){const e=r.getFirstChild();if(at(e)){const n=e.getFirstChild();null!==n&&n.insertBefore(t)}}else if(K(i)){const e=i.getFirstChild();at(e)&&e.append(t)}else if(at(n)){const e=et().setTextFormat(t.getTextFormat()).setTextStyle(t.getTextStyle()),s=ct(n.getListType()).setTextFormat(n.getTextFormat()).setTextStyle(n.getTextStyle());e.append(s),s.append(t),i?i.insertAfter(e):r?r.insertBefore(e):n.append(e)}}function j(t){if(K(t))return;const e=t.getParent(),n=e?e.getParent():void 0;if(at(n?n.getParent():void 0)&&nt(n)&&at(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=e.getListType(),i=et(),s=ct(r);i.append(s),t.getPreviousSiblings().forEach((t=>s.append(t)));const o=et(),l=ct(r);o.append(l),U(l,t.getNextSiblings()),n.insertBefore(i),n.insertAfter(o),n.replace(t)}}}function G(){const t=l();if(!c(t)||!t.isCollapsed())return!1;const e=t.anchor.getNode();if(!nt(e)||0!==e.getChildrenSize())return!1;const n=R(e),r=e.getParent();at(r)||I(40);const i=r.getParent();let s;if(a(i))s=g(),n.insertAfter(s);else{if(!nt(i))return!1;s=et(),i.insertAfter(s)}s.setTextStyle(t.style).setTextFormat(t.format).select();const o=e.getNextSiblings();if(o.length>0){const t=ct(r.getListType());if(nt(s)){const e=et();e.append(t),s.insertAfter(e)}else s.insertAfter(t);t.append(...o)}return function(t){let e=t;for(;null==e.getNextSibling()&&null==e.getPreviousSibling();){const t=e.getParent();if(null==t||!nt(t)&&!at(t))break;e=t}e.remove()}(e),!0}function Q(...t){const e=[];for(const n of t)if(n&&"string"==typeof n)for(const[t]of n.matchAll(/\S+/g))e.push(t);return e}class Y extends m{$config(){return this.config("listitem",{$transform:t=>{if(null==t.__checked)return;const e=t.getParent();at(e)&&"check"!==e.getListType()&&null!=t.getChecked()&&t.setChecked(void 0)},extends:m,importDOM:_({li:()=>({conversion:Z,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=document.createElement("li");return this.updateListItemDOM(null,e,t),e}updateListItemDOM(t,r,i){const s=this.getParent();at(s)&&"check"===s.getListType()&&function(t,e,n,r){at(e.getFirstChild())?(t.removeAttribute("role"),t.removeAttribute("tabIndex"),t.removeAttribute("aria-checked")):(t.setAttribute("role","checkbox"),t.setAttribute("tabIndex","-1"),n&&e.__checked===n.__checked||t.setAttribute("aria-checked",e.getChecked()?"true":"false"))}(r,this,t),r.value=this.__value,function(t,r,i){const s=[],o=[],l=r.list,c=l?l.listitem:void 0;let a;l&&l.nested&&(a=l.nested.listitem);void 0!==c&&s.push(...Q(c));if(l){const t=i.getParent(),e=at(t)&&"check"===t.getListType(),n=i.getChecked();e&&!n||o.push(l.listitemUnchecked),e&&n||o.push(l.listitemChecked),e&&s.push(n?l.listitemChecked:l.listitemUnchecked)}if(void 0!==a){const t=Q(a);i.getChildren().some((t=>at(t)))?s.push(...t):o.push(...t)}o.length>0&&e(t,...o);s.length>0&&n(t,...s)}(r,i.theme,this);const o=t?t.__style:"",l=this.__style;o!==l&&(""===l?r.removeAttribute("style"):r.style.cssText=l),function(t,e,n){const r=D(e.__textStyle);for(const e in r)t.style.setProperty(`--listitem-marker-${e}`,r[e]);if(n)for(const e in D(n.__textStyle))e in r||t.style.removeProperty(`--listitem-marker-${e}`)}(r,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),{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(u(n)&&this.canMergeWith(n)){const t=n.getChildren();this.append(...t),n.remove()}else super.append(n)}return this}replace(t,e){if(nt(t))return super.replace(t);this.setIndent(0);const n=this.getParentOrThrow();if(!at(n))return t;if(n.__first===this.getKey())n.insertBefore(t);else if(n.__last===this.getKey())n.insertAfter(t);else{const e=ct(n.getListType());let r=this.getNextSibling();for(;r;){const t=r;r=r.getNextSibling(),e.append(t)}n.insertAfter(t),t.insertAfter(e)}return e&&(u(t)||I(139),this.getChildren().forEach((e=>{t.append(e)}))),this.remove(),0===n.getChildrenSize()&&n.remove(),t}insertAfter(t,e=!0){const n=this.getParentOrThrow();if(at(n)||I(39),nt(t))return super.insertAfter(t,e);const r=this.getNextSiblings();if(n.insertAfter(t,e),0!==r.length){const i=ct(n.getListType());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&&K(e)&&K(n)&&(z(e.getFirstChild(),n.getFirstChild()),n.remove())}insertNewAfter(t,e=!0){const n=et().updateFromJSON(this.exportJSON()).setChecked(!this.getChecked()&&void 0);return this.insertAfter(n,e),n}collapseAtStart(t){const e=g();this.getChildren().forEach((t=>e.append(t)));const n=this.getParentOrThrow(),r=n.getParentOrThrow(),i=nt(r);if(1===n.getChildrenSize())if(i)n.remove(),r.select();else{n.insertBefore(e),n.remove();const r=t.anchor,i=t.focus,s=e.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(e),this.remove();return!0}getValue(){return this.getLatest().__value}setValue(t){const e=this.getWritable();return e.__value=t,e}getChecked(){const t=this.getLatest();let e;const n=this.getParent();return at(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(;nt(e);)e=e.getParentOrThrow().getParentOrThrow(),n++;return n}setIndent(t){"number"!=typeof t&&I(117),(t=Math.floor(t))>=0||I(199);let e=this.getIndent();for(;e!==t;)e<t?(X(this),e++):(j(this),e--);return this}canInsertAfter(t){return nt(t)}canReplaceWith(t){return nt(t)}canMergeWith(t){return nt(t)||y(t)}extractWithChild(t,e){if(!c(e))return!1;const n=e.anchor.getNode(),r=e.focus.getNode();return this.isParentOf(n)&&this.isParentOf(r)&&this.getTextContent().length===e.getTextContent().length}isParentRequired(){return!0}createParentElementNode(){return ct("bullet")}canMergeWhenEmpty(){return!0}}function Z(t){if(t.classList.contains("task-list-item"))for(const e of t.children)if("INPUT"===e.tagName)return tt(e);const e=t.getAttribute("aria-checked");return{node:et("true"===e||"false"!==e&&void 0)}}function tt(t){if(!("checkbox"===t.getAttribute("type")))return{node:null};return{node:et(t.hasAttribute("checked"))}}function et(t){return C(new Y(void 0,t))}function nt(t){return t instanceof Y}class rt extends m{$config(){return this.config("list",{$transform:t=>{!function(t){const e=t.getNextSibling();at(e)&&t.getListType()===e.getListType()&&z(t,e)}(t),H(t)},extends:m,importDOM:_({ol:()=>({conversion:ot,priority:0}),ul:()=>({conversion:ot,priority:0})})})}constructor(t="number",e=1,n){super(n);const r=lt[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=document.createElement(n);return 1!==this.__start&&r.setAttribute("start",String(this.__start)),r.__lexicalListType=this.__listType,it(r,t.theme,this),r}updateDOM(t,e,n){return t.__tag!==this.__tag||(it(e,n.theme,this),!1)}updateFromJSON(t){return super.updateFromJSON(t).setListType(t.listType).setStart(t.start)}exportDOM(t){const e=this.createDOM(t._config,t);return r(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];nt(e)||(r===n&&(r=[...n]),r[t]=et().append(!u(e)||at(e)||e.isInline()?e:T(e.getTextContent())))}return super.splice(t,e,r)}extractWithChild(t){return nt(t)}}function it(t,r,i){const s=[],o=[],l=r.list;if(void 0!==l){const t=l[`${i.__tag}Depth`]||[],e=M(i)-1,n=e%t.length,r=t[n],c=l[i.__tag];let a;const g=l.nested,u=l.checklist;if(void 0!==g&&g.list&&(a=g.list),void 0!==c&&s.push(c),void 0!==u&&"check"===i.__listType&&s.push(u),void 0!==r){s.push(...Q(r));for(let e=0;e<t.length;e++)e!==n&&o.push(i.__tag+e)}if(void 0!==a){const t=Q(a);e>1?s.push(...t):o.push(...t)}}o.length>0&&e(t,...o),s.length>0&&n(t,...s)}function st(t){const e=[];for(let n=0;n<t.length;n++){const r=t[n];if(nt(r)){e.push(r);const t=r.getChildren();t.length>1&&t.forEach((t=>{at(t)&&e.push(W(t))}))}else e.push(W(r))}return e}function ot(t){const e=t.nodeName.toLowerCase();let n=null;if("ol"===e){n=ct("number",t.start)}else"ul"===e&&(n=function(t){if("check"===t.getAttribute("__lexicallisttype")||t.classList.contains("contains-task-list"))return!0;for(const e of t.childNodes)if(r(e)&&e.hasAttribute("aria-checked"))return!0;return!1}(t)?ct("check"):ct("bullet"));return{after:st,node:n}}const lt={ol:"number",ul:"bullet"};function ct(t="number",e=1){return C(new rt(t,e))}function at(t){return t instanceof rt}const gt=S("INSERT_CHECK_LIST_COMMAND");function ut(t){return i(t.registerCommand(gt,(()=>($("check"),!0)),v),t.registerCommand(x,(e=>mt(e,t,!1)),v),t.registerCommand(k,(e=>mt(e,t,!0)),v),t.registerCommand(b,(()=>{if(null!=pt()){const e=t.getRootElement();return null!=e&&e.focus(),!0}return!1}),v),t.registerCommand(N,(e=>{const n=pt();return!(null==n||!t.isEditable())&&(t.update((()=>{const t=L(n);nt(t)&&(e.preventDefault(),t.toggleChecked())})),!0)}),v),t.registerCommand(F,(e=>t.getEditorState().read((()=>{const n=l();if(c(n)&&n.isCollapsed()){const{anchor:r}=n,i="element"===r.type;if(i||0===r.offset){const n=r.getNode(),o=s(n,(t=>u(t)&&!t.isInline()));if(nt(o)){const r=o.getParent();if(at(r)&&"check"===r.getListType()&&(i||o.getFirstDescendant()===n)){const n=t.getElementByKey(o.__key);if(null!=n&&document.activeElement!==n)return n.focus(),e.preventDefault(),!0}}}}return!1}))),v),t.registerRootListener(((t,e)=>{null!==t&&(t.addEventListener("click",ft),t.addEventListener("pointerdown",dt)),null!==e&&(e.removeEventListener("click",ft),e.removeEventListener("pointerdown",dt))})))}function ht(t,e){const n=t.target;if(!r(n))return;const i=n.firstChild;if(r(i)&&("UL"===i.tagName||"OL"===i.tagName))return;const s=n.parentNode;if(!s||"check"!==s.__lexicalListType)return;const l=n.getBoundingClientRect(),c=t.pageX/o(n),a=window.getComputedStyle?window.getComputedStyle(n,"::before"):{width:"0px"},g=parseFloat(a.width);("rtl"===n.dir?c<l.right&&c>l.right-g:c>l.left&&c<l.left+g)&&e()}function ft(t){ht(t,(()=>{if(r(t.target)){const e=t.target,n=P(e);null!=n&&n.isEditable()&&n.update((()=>{const t=L(e);nt(t)&&(e.focus(),t.toggleChecked())}))}}))}function dt(t){ht(t,(()=>{t.preventDefault()}))}function pt(){const t=document.activeElement;return r(t)&&"LI"===t.tagName&&null!=t.parentNode&&"check"===t.parentNode.__lexicalListType?t:null}function mt(t,e,n){const r=pt();return null!=r&&e.update((()=>{const i=L(r);if(!nt(i))return;const s=function(t,e){let n=e?t.getPreviousSibling():t.getNextSibling(),r=t;for(;null==n&&nt(r);)r=r.getParentOrThrow().getParent(),null!=r&&(n=e?r.getPreviousSibling():r.getNextSibling());for(;nt(n);){const t=e?n.getLastChild():n.getFirstChild();if(!at(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}const _t=S("UPDATE_LIST_START_COMMAND"),yt=S("INSERT_UNORDERED_LIST_COMMAND"),Ct=S("INSERT_ORDERED_LIST_COMMAND"),Tt=S("REMOVE_LIST_COMMAND");function St(t){return i(t.registerCommand(Ct,(()=>($("number"),!0)),v),t.registerCommand(_t,(t=>{const{listNodeKey:e,newStart:n}=t,r=A(e);return!!at(r)&&("number"===r.getListType()&&(r.setStart(n),H(r)),!0)}),v),t.registerCommand(yt,(()=>($("bullet"),!0)),v),t.registerCommand(Tt,(()=>(q(),!0)),v),t.registerCommand(O,(()=>G()),v),t.registerNodeTransform(Y,(t=>{const e=t.getFirstChild();if(e){if(E(e)){const n=e.getStyle(),r=e.getFormat();t.getTextStyle()!==n&&t.setTextStyle(n),t.getTextFormat()!==r&&t.setTextFormat(r)}}else{const e=l();c(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(w,(t=>{const e=t.getParent();if(nt(e)&&t.is(e.getFirstChild())){const n=t.getStyle(),r=t.getFormat();n===e.getTextStyle()&&r===e.getTextFormat()||e.setTextStyle(n).setTextFormat(r)}})))}function vt(t){const e=t=>{const e=t.getParent();if(at(t.getFirstChild())||!at(e))return;const n=s(t,(t=>nt(t)&&at(t.getParent())&&nt(t.getPreviousSibling())));if(null===n&&t.getIndent()>0)t.setIndent(0);else if(nt(n)){const r=n.getPreviousSibling();if(nt(r)){const n=function(t){let e=t,n=e.getFirstChild();for(;at(n);){const t=n.getLastChild();if(!nt(t))break;e=t,n=e.getFirstChild()}return e}(r),i=n.getParent();if(at(i)){const n=M(i);n+1<M(e)&&t.setIndent(n)}}}};return t.registerNodeTransform(rt,(t=>{const n=[t];for(;n.length>0;){const t=n.shift();if(at(t))for(const r of t.getChildren())if(nt(r)){e(r);const t=r.getFirstChild();at(t)&&n.push(t)}}}))}function xt(t,e){t.update((()=>$(e)))}function kt(t){t.update((()=>q()))}export{et as $createListItemNode,ct as $createListNode,M as $getListDepth,G as $handleListInsertParagraph,$ as $insertList,nt as $isListItemNode,at as $isListNode,q as $removeList,gt as INSERT_CHECK_LIST_COMMAND,Ct as INSERT_ORDERED_LIST_COMMAND,yt as INSERT_UNORDERED_LIST_COMMAND,Y as ListItemNode,rt as ListNode,Tt as REMOVE_LIST_COMMAND,_t as UPDATE_LIST_START_COMMAND,xt as insertList,ut as registerCheckList,St as registerList,vt as registerListStrictIndentTransform,kt as removeList};
9
+ import{$getNearestNodeOfType as t,removeClassNamesFromElement as e,addClassNamesToElement as n,isHTMLElement as r,mergeRegister as i,$findMatchingParent as s,calculateZoomLevel as o}from"@lexical/utils";import{$getSelection as l,$isRangeSelection as c,$isRootOrShadowRoot as a,$createParagraphNode as g,$isElementNode as u,$isLeafNode as h,$setPointFromCaret as f,$normalizeCaret as d,$getChildCaret as p,ElementNode as m,buildImportMap as _,$isParagraphNode as y,$applyNodeReplacement as C,$createTextNode as T,createCommand as S,COMMAND_PRIORITY_LOW as v,KEY_ARROW_DOWN_COMMAND as x,KEY_ARROW_UP_COMMAND as k,KEY_ESCAPE_COMMAND as b,KEY_SPACE_COMMAND as N,$getNearestNodeFromDOMNode as L,KEY_ARROW_LEFT_COMMAND as F,getNearestEditorFromDOMNode as P,$getNodeByKey as A,INSERT_PARAGRAPH_COMMAND as O,$isTextNode as E,TextNode as w}from"lexical";import{getStyleObjectFromCSS as D}from"@lexical/selection";function I(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 M(t){let e=1,n=t.getParent();for(;null!=n;){if(nt(n)){const t=n.getParent();if(at(t)){e++,n=t.getParent();continue}I(40)}return e}return e}function R(t){let e=t.getParent();at(e)||I(40);let n=e;for(;null!==n;)n=n.getParent(),at(n)&&(e=n);return e}function B(t){let e=[];const n=t.getChildren().filter(nt);for(let t=0;t<n.length;t++){const r=n[t],i=r.getFirstChild();at(i)?e=e.concat(B(i)):e.push(r)}return e}function K(t){return nt(t)&&at(t.getFirstChild())}function W(t){return et().append(t)}function J(t,e){return nt(t)&&(0===e.length||1===e.length&&t.is(e[0])&&0===t.getChildrenSize())}function $(t){const e=l();if(null!==e){let n=e.getNodes();if(c(e)){const r=e.getStartEndPoints();null===r&&I(143);const[i]=r,s=i.getNode(),o=s.getParent();if(a(s)){const t=s.getFirstChild();if(t)n=t.selectStart().getNodes();else{const t=g();s.append(t),n=t.select().getNodes()}}else if(J(s,n)){const e=ct(t);if(a(o)){s.replace(e);const t=et();u(s)&&(t.setFormat(s.getFormatType()),t.setIndent(s.getIndent())),e.append(t)}else if(nt(s)){const t=s.getParentOrThrow();U(e,t.getChildren()),t.replace(e)}return}}const r=new Set;for(let e=0;e<n.length;e++){const i=n[e];if(u(i)&&i.isEmpty()&&!nt(i)&&!r.has(i.getKey())){V(i,t);continue}let s=h(i)?i.getParent():nt(i)&&i.isEmpty()?i:null;for(;null!=s;){const e=s.getKey();if(at(s)){if(!r.has(e)){const n=ct(t);U(n,s.getChildren()),s.replace(n),r.add(e)}break}{const n=s.getParent();if(a(n)&&!r.has(e)){r.add(e),V(s,t);break}s=n}}}}}function U(t,e){t.splice(t.getChildrenSize(),0,e)}function V(t,e){if(at(t))return t;const n=t.getPreviousSibling(),r=t.getNextSibling(),i=et();let s;if(U(i,t.getChildren()),at(n)&&e===n.getListType())n.append(i),at(r)&&e===r.getListType()&&(U(n,r.getChildren()),r.remove()),s=n;else if(at(r)&&e===r.getListType())r.getFirstChildOrThrow().insertBefore(i),s=r;else{const n=ct(e);n.append(i),t.replace(n),s=n}return i.setFormat(t.getFormatType()),i.setIndent(t.getIndent()),t.remove(),s}function z(t,e){const n=t.getLastChild(),r=e.getFirstChild();n&&r&&K(n)&&K(r)&&(z(n.getFirstChild(),r.getFirstChild()),r.remove());const i=e.getChildren();i.length>0&&t.append(...i),e.remove()}function q(){const e=l();if(c(e)){const n=new Set,r=e.getNodes(),i=e.anchor.getNode();if(J(i,r))n.add(R(i));else for(let e=0;e<r.length;e++){const i=r[e];if(h(i)){const e=t(i,Y);null!=e&&n.add(R(e))}}for(const t of n){let n=t;const r=B(t);for(const t of r){const r=g().setTextStyle(e.style).setTextFormat(e.format);U(r,t.getChildren()),n.insertAfter(r),n=r,t.__key===e.anchor.key&&f(e.anchor,d(p(r,"next"))),t.__key===e.focus.key&&f(e.focus,d(p(r,"next"))),t.remove()}t.remove()}}}function H(t){const e="check"!==t.getListType();let n=t.getStart();for(const r of t.getChildren())nt(r)&&(r.getValue()!==n&&r.setValue(n),e&&null!=r.getLatest().__checked&&r.setChecked(void 0),at(r.getFirstChild())||n++)}function X(t){const e=new Set;if(K(t)||e.has(t.getKey()))return;const n=t.getParent(),r=t.getNextSibling(),i=t.getPreviousSibling();if(K(r)&&K(i)){const n=i.getFirstChild();if(at(n)){n.append(t);const i=r.getFirstChild();if(at(i)){U(n,i.getChildren()),r.remove(),e.add(r.getKey())}}}else if(K(r)){const e=r.getFirstChild();if(at(e)){const n=e.getFirstChild();null!==n&&n.insertBefore(t)}}else if(K(i)){const e=i.getFirstChild();at(e)&&e.append(t)}else if(at(n)){const e=et().setTextFormat(t.getTextFormat()).setTextStyle(t.getTextStyle()),s=ct(n.getListType()).setTextFormat(n.getTextFormat()).setTextStyle(n.getTextStyle());e.append(s),s.append(t),i?i.insertAfter(e):r?r.insertBefore(e):n.append(e)}}function j(t){if(K(t))return;const e=t.getParent(),n=e?e.getParent():void 0;if(at(n?n.getParent():void 0)&&nt(n)&&at(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=e.getListType(),i=et(),s=ct(r);i.append(s),t.getPreviousSiblings().forEach((t=>s.append(t)));const o=et(),l=ct(r);o.append(l),U(l,t.getNextSiblings()),n.insertBefore(i),n.insertAfter(o),n.replace(t)}}}function G(){const t=l();if(!c(t)||!t.isCollapsed())return!1;const e=t.anchor.getNode();if(!nt(e)||0!==e.getChildrenSize())return!1;const n=R(e),r=e.getParent();at(r)||I(40);const i=r.getParent();let s;if(a(i))s=g(),n.insertAfter(s);else{if(!nt(i))return!1;s=et(),i.insertAfter(s)}s.setTextStyle(t.style).setTextFormat(t.format).select();const o=e.getNextSiblings();if(o.length>0){const t=ct(r.getListType());if(nt(s)){const e=et();e.append(t),s.insertAfter(e)}else s.insertAfter(t);t.append(...o)}return function(t){let e=t;for(;null==e.getNextSibling()&&null==e.getPreviousSibling();){const t=e.getParent();if(null==t||!nt(t)&&!at(t))break;e=t}e.remove()}(e),!0}function Q(...t){const e=[];for(const n of t)if(n&&"string"==typeof n)for(const[t]of n.matchAll(/\S+/g))e.push(t);return e}class Y extends m{$config(){return this.config("listitem",{$transform:t=>{if(null==t.__checked)return;const e=t.getParent();at(e)&&"check"!==e.getListType()&&null!=t.getChecked()&&t.setChecked(void 0)},extends:m,importDOM:_({li:()=>({conversion:Z,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=document.createElement("li");return this.updateListItemDOM(null,e,t),e}updateListItemDOM(t,r,i){const s=this.getParent();at(s)&&"check"===s.getListType()&&function(t,e,n,r){at(e.getFirstChild())?(t.removeAttribute("role"),t.removeAttribute("tabIndex"),t.removeAttribute("aria-checked")):(t.setAttribute("role","checkbox"),t.setAttribute("tabIndex","-1"),n&&e.__checked===n.__checked||t.setAttribute("aria-checked",e.getChecked()?"true":"false"))}(r,this,t),r.value=this.__value,function(t,r,i){const s=[],o=[],l=r.list,c=l?l.listitem:void 0;let a;l&&l.nested&&(a=l.nested.listitem);void 0!==c&&s.push(...Q(c));if(l){const t=i.getParent(),e=at(t)&&"check"===t.getListType(),n=i.getChecked();e&&!n||o.push(l.listitemUnchecked),e&&n||o.push(l.listitemChecked),e&&s.push(n?l.listitemChecked:l.listitemUnchecked)}if(void 0!==a){const t=Q(a);i.getChildren().some((t=>at(t)))?s.push(...t):o.push(...t)}o.length>0&&e(t,...o);s.length>0&&n(t,...s)}(r,i.theme,this);const o=t?t.__style:"",l=this.__style;o!==l&&(""===l?r.removeAttribute("style"):r.style.cssText=l),function(t,e,n){const r=D(e.__textStyle);for(const e in r)t.style.setProperty(`--listitem-marker-${e}`,r[e]);if(n)for(const e in D(n.__textStyle))e in r||t.style.removeProperty(`--listitem-marker-${e}`)}(r,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),{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(u(n)&&this.canMergeWith(n)){const t=n.getChildren();this.append(...t),n.remove()}else super.append(n)}return this}replace(t,e){if(nt(t))return super.replace(t);this.setIndent(0);const n=this.getParentOrThrow();if(!at(n))return t;if(n.__first===this.getKey())n.insertBefore(t);else if(n.__last===this.getKey())n.insertAfter(t);else{const e=ct(n.getListType());let r=this.getNextSibling();for(;r;){const t=r;r=r.getNextSibling(),e.append(t)}n.insertAfter(t),t.insertAfter(e)}return e&&(u(t)||I(139),this.getChildren().forEach((e=>{t.append(e)}))),this.remove(),0===n.getChildrenSize()&&n.remove(),t}insertAfter(t,e=!0){const n=this.getParentOrThrow();if(at(n)||I(39),nt(t))return super.insertAfter(t,e);const r=this.getNextSiblings();if(n.insertAfter(t,e),0!==r.length){const i=ct(n.getListType());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&&K(e)&&K(n)&&(z(e.getFirstChild(),n.getFirstChild()),n.remove())}insertNewAfter(t,e=!0){const n=et().updateFromJSON(this.exportJSON()).setChecked(!this.getChecked()&&void 0);return this.insertAfter(n,e),n}collapseAtStart(t){const e=g();this.getChildren().forEach((t=>e.append(t)));const n=this.getParentOrThrow(),r=n.getParentOrThrow(),i=nt(r);if(1===n.getChildrenSize())if(i)n.remove(),r.select();else{n.insertBefore(e),n.remove();const r=t.anchor,i=t.focus,s=e.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(e),this.remove();return!0}getValue(){return this.getLatest().__value}setValue(t){const e=this.getWritable();return e.__value=t,e}getChecked(){const t=this.getLatest();let e;const n=this.getParent();return at(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(;nt(e);)e=e.getParentOrThrow().getParentOrThrow(),n++;return n}setIndent(t){"number"!=typeof t&&I(117),(t=Math.floor(t))>=0||I(199);let e=this.getIndent();for(;e!==t;)e<t?(X(this),e++):(j(this),e--);return this}canInsertAfter(t){return nt(t)}canReplaceWith(t){return nt(t)}canMergeWith(t){return nt(t)||y(t)}extractWithChild(t,e){if(!c(e))return!1;const n=e.anchor.getNode(),r=e.focus.getNode();return this.isParentOf(n)&&this.isParentOf(r)&&this.getTextContent().length===e.getTextContent().length}isParentRequired(){return!0}createParentElementNode(){return ct("bullet")}canMergeWhenEmpty(){return!0}}function Z(t){if(t.classList.contains("task-list-item"))for(const e of t.children)if("INPUT"===e.tagName)return tt(e);const e=t.getAttribute("aria-checked");return{node:et("true"===e||"false"!==e&&void 0)}}function tt(t){if(!("checkbox"===t.getAttribute("type")))return{node:null};return{node:et(t.hasAttribute("checked"))}}function et(t){return C(new Y(void 0,t))}function nt(t){return t instanceof Y}class rt extends m{$config(){return this.config("list",{$transform:t=>{!function(t){const e=t.getNextSibling();at(e)&&t.getListType()===e.getListType()&&z(t,e)}(t),H(t)},extends:m,importDOM:_({ol:()=>({conversion:ot,priority:0}),ul:()=>({conversion:ot,priority:0})})})}constructor(t="number",e=1,n){super(n);const r=lt[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=document.createElement(n);return 1!==this.__start&&r.setAttribute("start",String(this.__start)),r.__lexicalListType=this.__listType,it(r,t.theme,this),r}updateDOM(t,e,n){return t.__tag!==this.__tag||(it(e,n.theme,this),!1)}updateFromJSON(t){return super.updateFromJSON(t).setListType(t.listType).setStart(t.start)}exportDOM(t){const e=this.createDOM(t._config,t);return r(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];nt(e)||(r===n&&(r=[...n]),r[t]=et().append(!u(e)||at(e)||e.isInline()?e:T(e.getTextContent())))}return super.splice(t,e,r)}extractWithChild(t){return nt(t)}}function it(t,r,i){const s=[],o=[],l=r.list;if(void 0!==l){const t=l[`${i.__tag}Depth`]||[],e=M(i)-1,n=e%t.length,r=t[n],c=l[i.__tag];let a;const g=l.nested,u=l.checklist;if(void 0!==g&&g.list&&(a=g.list),void 0!==c&&s.push(c),void 0!==u&&"check"===i.__listType&&s.push(u),void 0!==r){s.push(...Q(r));for(let e=0;e<t.length;e++)e!==n&&o.push(i.__tag+e)}if(void 0!==a){const t=Q(a);e>1?s.push(...t):o.push(...t)}}o.length>0&&e(t,...o),s.length>0&&n(t,...s)}function st(t){const e=[];for(let n=0;n<t.length;n++){const r=t[n];if(nt(r)){e.push(r);const t=r.getChildren();t.length>1&&t.forEach((t=>{at(t)&&e.push(W(t))}))}else e.push(W(r))}return e}function ot(t){const e=t.nodeName.toLowerCase();let n=null;if("ol"===e){n=ct("number",t.start)}else"ul"===e&&(n=function(t){if("check"===t.getAttribute("__lexicallisttype")||t.classList.contains("contains-task-list"))return!0;for(const e of t.childNodes)if(r(e)&&e.hasAttribute("aria-checked"))return!0;return!1}(t)?ct("check"):ct("bullet"));return{after:st,node:n}}const lt={ol:"number",ul:"bullet"};function ct(t="number",e=1){return C(new rt(t,e))}function at(t){return t instanceof rt}const gt=S("INSERT_CHECK_LIST_COMMAND");function ut(t){return i(t.registerCommand(gt,(()=>($("check"),!0)),v),t.registerCommand(x,(e=>mt(e,t,!1)),v),t.registerCommand(k,(e=>mt(e,t,!0)),v),t.registerCommand(b,(()=>{if(null!=pt()){const e=t.getRootElement();return null!=e&&e.focus(),!0}return!1}),v),t.registerCommand(N,(e=>{const n=pt();return!(null==n||!t.isEditable())&&(t.update((()=>{const t=L(n);nt(t)&&(e.preventDefault(),t.toggleChecked())})),!0)}),v),t.registerCommand(F,(e=>t.getEditorState().read((()=>{const n=l();if(c(n)&&n.isCollapsed()){const{anchor:r}=n,i="element"===r.type;if(i||0===r.offset){const n=r.getNode(),o=s(n,(t=>u(t)&&!t.isInline()));if(nt(o)){const r=o.getParent();if(at(r)&&"check"===r.getListType()&&(i||o.getFirstDescendant()===n)){const n=t.getElementByKey(o.__key);if(null!=n&&document.activeElement!==n)return n.focus(),e.preventDefault(),!0}}}}return!1}))),v),t.registerRootListener(((t,e)=>{null!==t&&(t.addEventListener("click",ft),t.addEventListener("pointerdown",dt)),null!==e&&(e.removeEventListener("click",ft),e.removeEventListener("pointerdown",dt))})))}function ht(t,e){const n=t.target;if(!r(n))return;const i=n.firstChild;if(r(i)&&("UL"===i.tagName||"OL"===i.tagName))return;const s=n.parentNode;if(!s||"check"!==s.__lexicalListType)return;const l=n.getBoundingClientRect(),c=o(n),a=t.clientX/c,g=window.getComputedStyle?window.getComputedStyle(n,"::before"):{width:"0px"},u=parseFloat(g.width),h="touch"===t.pointerType?32:0;("rtl"===n.dir?a<l.right+h&&a>l.right-u-h:a>l.left-h&&a<l.left+u+h)&&e()}function ft(t){ht(t,(()=>{if(r(t.target)){const e=t.target,n=P(e);null!=n&&n.isEditable()&&n.update((()=>{const t=L(e);nt(t)&&(e.focus(),t.toggleChecked())}))}}))}function dt(t){ht(t,(()=>{t.preventDefault()}))}function pt(){const t=document.activeElement;return r(t)&&"LI"===t.tagName&&null!=t.parentNode&&"check"===t.parentNode.__lexicalListType?t:null}function mt(t,e,n){const r=pt();return null!=r&&e.update((()=>{const i=L(r);if(!nt(i))return;const s=function(t,e){let n=e?t.getPreviousSibling():t.getNextSibling(),r=t;for(;null==n&&nt(r);)r=r.getParentOrThrow().getParent(),null!=r&&(n=e?r.getPreviousSibling():r.getNextSibling());for(;nt(n);){const t=e?n.getLastChild():n.getFirstChild();if(!at(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}const _t=S("UPDATE_LIST_START_COMMAND"),yt=S("INSERT_UNORDERED_LIST_COMMAND"),Ct=S("INSERT_ORDERED_LIST_COMMAND"),Tt=S("REMOVE_LIST_COMMAND");function St(t){return i(t.registerCommand(Ct,(()=>($("number"),!0)),v),t.registerCommand(_t,(t=>{const{listNodeKey:e,newStart:n}=t,r=A(e);return!!at(r)&&("number"===r.getListType()&&(r.setStart(n),H(r)),!0)}),v),t.registerCommand(yt,(()=>($("bullet"),!0)),v),t.registerCommand(Tt,(()=>(q(),!0)),v),t.registerCommand(O,(()=>G()),v),t.registerNodeTransform(Y,(t=>{const e=t.getFirstChild();if(e){if(E(e)){const n=e.getStyle(),r=e.getFormat();t.getTextStyle()!==n&&t.setTextStyle(n),t.getTextFormat()!==r&&t.setTextFormat(r)}}else{const e=l();c(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(w,(t=>{const e=t.getParent();if(nt(e)&&t.is(e.getFirstChild())){const n=t.getStyle(),r=t.getFormat();n===e.getTextStyle()&&r===e.getTextFormat()||e.setTextStyle(n).setTextFormat(r)}})))}function vt(t){const e=t=>{const e=t.getParent();if(at(t.getFirstChild())||!at(e))return;const n=s(t,(t=>nt(t)&&at(t.getParent())&&nt(t.getPreviousSibling())));if(null===n&&t.getIndent()>0)t.setIndent(0);else if(nt(n)){const r=n.getPreviousSibling();if(nt(r)){const n=function(t){let e=t,n=e.getFirstChild();for(;at(n);){const t=n.getLastChild();if(!nt(t))break;e=t,n=e.getFirstChild()}return e}(r),i=n.getParent();if(at(i)){const n=M(i);n+1<M(e)&&t.setIndent(n)}}}};return t.registerNodeTransform(rt,(t=>{const n=[t];for(;n.length>0;){const t=n.shift();if(at(t))for(const r of t.getChildren())if(nt(r)){e(r);const t=r.getFirstChild();at(t)&&n.push(t)}}}))}function xt(t,e){t.update((()=>$(e)))}function kt(t){t.update((()=>q()))}export{et as $createListItemNode,ct as $createListNode,M as $getListDepth,G as $handleListInsertParagraph,$ as $insertList,nt as $isListItemNode,at as $isListNode,q as $removeList,gt as INSERT_CHECK_LIST_COMMAND,Ct as INSERT_ORDERED_LIST_COMMAND,yt as INSERT_UNORDERED_LIST_COMMAND,Y as ListItemNode,rt as ListNode,Tt as REMOVE_LIST_COMMAND,_t as UPDATE_LIST_START_COMMAND,xt as insertList,ut as registerCheckList,St as registerList,vt as registerListStrictIndentTransform,kt as removeList};
package/package.json CHANGED
@@ -8,13 +8,13 @@
8
8
  "list"
9
9
  ],
10
10
  "license": "MIT",
11
- "version": "0.32.2-nightly.20250703.0",
11
+ "version": "0.33.0",
12
12
  "main": "LexicalList.js",
13
13
  "types": "index.d.ts",
14
14
  "dependencies": {
15
- "@lexical/selection": "0.32.2-nightly.20250703.0",
16
- "@lexical/utils": "0.32.2-nightly.20250703.0",
17
- "lexical": "0.32.2-nightly.20250703.0"
15
+ "@lexical/selection": "0.33.0",
16
+ "@lexical/utils": "0.33.0",
17
+ "lexical": "0.33.0"
18
18
  },
19
19
  "repository": {
20
20
  "type": "git",