@lexical/list 0.32.2-nightly.20250620.0 → 0.32.2-nightly.20250623.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.
@@ -579,17 +579,39 @@ class ListItemNode extends lexical.ElementNode {
579
579
 
580
580
  /** @internal */
581
581
 
582
- static getType() {
583
- return 'listitem';
584
- }
585
- static clone(node) {
586
- return new ListItemNode(node.__value, node.__checked, node.__key);
582
+ /** @internal */
583
+ $config() {
584
+ return this.config('listitem', {
585
+ $transform: node => {
586
+ if (node.__checked == null) {
587
+ return;
588
+ }
589
+ const parent = node.getParent();
590
+ if ($isListNode(parent)) {
591
+ if (parent.getListType() !== 'check' && node.getChecked() != null) {
592
+ node.setChecked(undefined);
593
+ }
594
+ }
595
+ },
596
+ extends: lexical.ElementNode,
597
+ importDOM: lexical.buildImportMap({
598
+ li: () => ({
599
+ conversion: $convertListItemElement,
600
+ priority: 0
601
+ })
602
+ })
603
+ });
587
604
  }
588
- constructor(value, checked, key) {
605
+ constructor(value = 1, checked = undefined, key) {
589
606
  super(key);
590
607
  this.__value = value === undefined ? 1 : value;
591
608
  this.__checked = checked;
592
609
  }
610
+ afterCloneFrom(prevNode) {
611
+ super.afterCloneFrom(prevNode);
612
+ this.__value = prevNode.__value;
613
+ this.__checked = prevNode.__checked;
614
+ }
593
615
  createDOM(config) {
594
616
  const element = document.createElement('li');
595
617
  this.updateListItemDOM(null, element, config);
@@ -619,33 +641,6 @@ class ListItemNode extends lexical.ElementNode {
619
641
  this.updateListItemDOM(prevNode, element, config);
620
642
  return false;
621
643
  }
622
- static transform() {
623
- return node => {
624
- if (!$isListItemNode(node)) {
625
- formatDevErrorMessage(`node is not a ListItemNode`);
626
- }
627
- if (node.__checked == null) {
628
- return;
629
- }
630
- const parent = node.getParent();
631
- if ($isListNode(parent)) {
632
- if (parent.getListType() !== 'check' && node.getChecked() != null) {
633
- node.setChecked(undefined);
634
- }
635
- }
636
- };
637
- }
638
- static importDOM() {
639
- return {
640
- li: () => ({
641
- conversion: $convertListItemElement,
642
- priority: 0
643
- })
644
- };
645
- }
646
- static importJSON(serializedNode) {
647
- return $createListItemNode().updateFromJSON(serializedNode);
648
- }
649
644
  updateFromJSON(serializedNode) {
650
645
  return super.updateFromJSON(serializedNode).setValue(serializedNode.value).setChecked(serializedNode.checked);
651
646
  }
@@ -985,6 +980,14 @@ function $isListItemNode(node) {
985
980
  return node instanceof ListItemNode;
986
981
  }
987
982
 
983
+ /**
984
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
985
+ *
986
+ * This source code is licensed under the MIT license found in the
987
+ * LICENSE file in the root directory of this source tree.
988
+ *
989
+ */
990
+
988
991
  /** @noInheritDoc */
989
992
  class ListNode extends lexical.ElementNode {
990
993
  /** @internal */
@@ -993,12 +996,25 @@ class ListNode extends lexical.ElementNode {
993
996
 
994
997
  /** @internal */
995
998
 
996
- static getType() {
997
- return 'list';
998
- }
999
- static clone(node) {
1000
- const listType = node.__listType || TAG_TO_LIST_TYPE[node.__tag];
1001
- return new ListNode(listType, node.__start, node.__key);
999
+ /** @internal */
1000
+ $config() {
1001
+ return this.config('list', {
1002
+ $transform: node => {
1003
+ mergeNextSiblingListIfSameType(node);
1004
+ updateChildrenListItemValue(node);
1005
+ },
1006
+ extends: lexical.ElementNode,
1007
+ importDOM: lexical.buildImportMap({
1008
+ ol: () => ({
1009
+ conversion: $convertListNode,
1010
+ priority: 0
1011
+ }),
1012
+ ul: () => ({
1013
+ conversion: $convertListNode,
1014
+ priority: 0
1015
+ })
1016
+ })
1017
+ });
1002
1018
  }
1003
1019
  constructor(listType = 'number', start = 1, key) {
1004
1020
  super(key);
@@ -1007,8 +1023,14 @@ class ListNode extends lexical.ElementNode {
1007
1023
  this.__tag = _listType === 'number' ? 'ol' : 'ul';
1008
1024
  this.__start = start;
1009
1025
  }
1026
+ afterCloneFrom(prevNode) {
1027
+ super.afterCloneFrom(prevNode);
1028
+ this.__listType = prevNode.__listType;
1029
+ this.__tag = prevNode.__tag;
1030
+ this.__start = prevNode.__start;
1031
+ }
1010
1032
  getTag() {
1011
- return this.__tag;
1033
+ return this.getLatest().__tag;
1012
1034
  }
1013
1035
  setListType(type) {
1014
1036
  const writable = this.getWritable();
@@ -1017,10 +1039,10 @@ class ListNode extends lexical.ElementNode {
1017
1039
  return writable;
1018
1040
  }
1019
1041
  getListType() {
1020
- return this.__listType;
1042
+ return this.getLatest().__listType;
1021
1043
  }
1022
1044
  getStart() {
1023
- return this.__start;
1045
+ return this.getLatest().__start;
1024
1046
  }
1025
1047
  setStart(start) {
1026
1048
  const self = this.getWritable();
@@ -1048,30 +1070,6 @@ class ListNode extends lexical.ElementNode {
1048
1070
  $setListThemeClassNames(dom, config.theme, this);
1049
1071
  return false;
1050
1072
  }
1051
- static transform() {
1052
- return node => {
1053
- if (!$isListNode(node)) {
1054
- formatDevErrorMessage(`node is not a ListNode`);
1055
- }
1056
- mergeNextSiblingListIfSameType(node);
1057
- updateChildrenListItemValue(node);
1058
- };
1059
- }
1060
- static importDOM() {
1061
- return {
1062
- ol: () => ({
1063
- conversion: $convertListNode,
1064
- priority: 0
1065
- }),
1066
- ul: () => ({
1067
- conversion: $convertListNode,
1068
- priority: 0
1069
- })
1070
- };
1071
- }
1072
- static importJSON(serializedNode) {
1073
- return $createListNode().updateFromJSON(serializedNode);
1074
- }
1075
1073
  updateFromJSON(serializedNode) {
1076
1074
  return super.updateFromJSON(serializedNode).setListType(serializedNode.listType).setStart(serializedNode.start);
1077
1075
  }
@@ -7,7 +7,7 @@
7
7
  */
8
8
 
9
9
  import { $getNearestNodeOfType, removeClassNamesFromElement, addClassNamesToElement, isHTMLElement, mergeRegister, $findMatchingParent, calculateZoomLevel } from '@lexical/utils';
10
- import { $getSelection, $isRangeSelection, $isRootOrShadowRoot, $createParagraphNode, $isElementNode, $isLeafNode, $setPointFromCaret, $normalizeCaret, $getChildCaret, ElementNode, $isParagraphNode, $applyNodeReplacement, $createTextNode, createCommand, COMMAND_PRIORITY_LOW, KEY_ARROW_DOWN_COMMAND, KEY_ARROW_UP_COMMAND, KEY_ESCAPE_COMMAND, KEY_SPACE_COMMAND, $getNearestNodeFromDOMNode, KEY_ARROW_LEFT_COMMAND, getNearestEditorFromDOMNode, INSERT_PARAGRAPH_COMMAND, $isTextNode, TextNode } from 'lexical';
10
+ import { $getSelection, $isRangeSelection, $isRootOrShadowRoot, $createParagraphNode, $isElementNode, $isLeafNode, $setPointFromCaret, $normalizeCaret, $getChildCaret, ElementNode, buildImportMap, $isParagraphNode, $applyNodeReplacement, $createTextNode, createCommand, COMMAND_PRIORITY_LOW, KEY_ARROW_DOWN_COMMAND, KEY_ARROW_UP_COMMAND, KEY_ESCAPE_COMMAND, KEY_SPACE_COMMAND, $getNearestNodeFromDOMNode, KEY_ARROW_LEFT_COMMAND, getNearestEditorFromDOMNode, INSERT_PARAGRAPH_COMMAND, $isTextNode, TextNode } from 'lexical';
11
11
  import { getStyleObjectFromCSS } from '@lexical/selection';
12
12
 
13
13
  /**
@@ -577,17 +577,39 @@ class ListItemNode extends ElementNode {
577
577
 
578
578
  /** @internal */
579
579
 
580
- static getType() {
581
- return 'listitem';
582
- }
583
- static clone(node) {
584
- return new ListItemNode(node.__value, node.__checked, node.__key);
580
+ /** @internal */
581
+ $config() {
582
+ return this.config('listitem', {
583
+ $transform: node => {
584
+ if (node.__checked == null) {
585
+ return;
586
+ }
587
+ const parent = node.getParent();
588
+ if ($isListNode(parent)) {
589
+ if (parent.getListType() !== 'check' && node.getChecked() != null) {
590
+ node.setChecked(undefined);
591
+ }
592
+ }
593
+ },
594
+ extends: ElementNode,
595
+ importDOM: buildImportMap({
596
+ li: () => ({
597
+ conversion: $convertListItemElement,
598
+ priority: 0
599
+ })
600
+ })
601
+ });
585
602
  }
586
- constructor(value, checked, key) {
603
+ constructor(value = 1, checked = undefined, key) {
587
604
  super(key);
588
605
  this.__value = value === undefined ? 1 : value;
589
606
  this.__checked = checked;
590
607
  }
608
+ afterCloneFrom(prevNode) {
609
+ super.afterCloneFrom(prevNode);
610
+ this.__value = prevNode.__value;
611
+ this.__checked = prevNode.__checked;
612
+ }
591
613
  createDOM(config) {
592
614
  const element = document.createElement('li');
593
615
  this.updateListItemDOM(null, element, config);
@@ -617,33 +639,6 @@ class ListItemNode extends ElementNode {
617
639
  this.updateListItemDOM(prevNode, element, config);
618
640
  return false;
619
641
  }
620
- static transform() {
621
- return node => {
622
- if (!$isListItemNode(node)) {
623
- formatDevErrorMessage(`node is not a ListItemNode`);
624
- }
625
- if (node.__checked == null) {
626
- return;
627
- }
628
- const parent = node.getParent();
629
- if ($isListNode(parent)) {
630
- if (parent.getListType() !== 'check' && node.getChecked() != null) {
631
- node.setChecked(undefined);
632
- }
633
- }
634
- };
635
- }
636
- static importDOM() {
637
- return {
638
- li: () => ({
639
- conversion: $convertListItemElement,
640
- priority: 0
641
- })
642
- };
643
- }
644
- static importJSON(serializedNode) {
645
- return $createListItemNode().updateFromJSON(serializedNode);
646
- }
647
642
  updateFromJSON(serializedNode) {
648
643
  return super.updateFromJSON(serializedNode).setValue(serializedNode.value).setChecked(serializedNode.checked);
649
644
  }
@@ -983,6 +978,14 @@ function $isListItemNode(node) {
983
978
  return node instanceof ListItemNode;
984
979
  }
985
980
 
981
+ /**
982
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
983
+ *
984
+ * This source code is licensed under the MIT license found in the
985
+ * LICENSE file in the root directory of this source tree.
986
+ *
987
+ */
988
+
986
989
  /** @noInheritDoc */
987
990
  class ListNode extends ElementNode {
988
991
  /** @internal */
@@ -991,12 +994,25 @@ class ListNode extends ElementNode {
991
994
 
992
995
  /** @internal */
993
996
 
994
- static getType() {
995
- return 'list';
996
- }
997
- static clone(node) {
998
- const listType = node.__listType || TAG_TO_LIST_TYPE[node.__tag];
999
- return new ListNode(listType, node.__start, node.__key);
997
+ /** @internal */
998
+ $config() {
999
+ return this.config('list', {
1000
+ $transform: node => {
1001
+ mergeNextSiblingListIfSameType(node);
1002
+ updateChildrenListItemValue(node);
1003
+ },
1004
+ extends: ElementNode,
1005
+ importDOM: buildImportMap({
1006
+ ol: () => ({
1007
+ conversion: $convertListNode,
1008
+ priority: 0
1009
+ }),
1010
+ ul: () => ({
1011
+ conversion: $convertListNode,
1012
+ priority: 0
1013
+ })
1014
+ })
1015
+ });
1000
1016
  }
1001
1017
  constructor(listType = 'number', start = 1, key) {
1002
1018
  super(key);
@@ -1005,8 +1021,14 @@ class ListNode extends ElementNode {
1005
1021
  this.__tag = _listType === 'number' ? 'ol' : 'ul';
1006
1022
  this.__start = start;
1007
1023
  }
1024
+ afterCloneFrom(prevNode) {
1025
+ super.afterCloneFrom(prevNode);
1026
+ this.__listType = prevNode.__listType;
1027
+ this.__tag = prevNode.__tag;
1028
+ this.__start = prevNode.__start;
1029
+ }
1008
1030
  getTag() {
1009
- return this.__tag;
1031
+ return this.getLatest().__tag;
1010
1032
  }
1011
1033
  setListType(type) {
1012
1034
  const writable = this.getWritable();
@@ -1015,10 +1037,10 @@ class ListNode extends ElementNode {
1015
1037
  return writable;
1016
1038
  }
1017
1039
  getListType() {
1018
- return this.__listType;
1040
+ return this.getLatest().__listType;
1019
1041
  }
1020
1042
  getStart() {
1021
- return this.__start;
1043
+ return this.getLatest().__start;
1022
1044
  }
1023
1045
  setStart(start) {
1024
1046
  const self = this.getWritable();
@@ -1046,30 +1068,6 @@ class ListNode extends ElementNode {
1046
1068
  $setListThemeClassNames(dom, config.theme, this);
1047
1069
  return false;
1048
1070
  }
1049
- static transform() {
1050
- return node => {
1051
- if (!$isListNode(node)) {
1052
- formatDevErrorMessage(`node is not a ListNode`);
1053
- }
1054
- mergeNextSiblingListIfSameType(node);
1055
- updateChildrenListItemValue(node);
1056
- };
1057
- }
1058
- static importDOM() {
1059
- return {
1060
- ol: () => ({
1061
- conversion: $convertListNode,
1062
- priority: 0
1063
- }),
1064
- ul: () => ({
1065
- conversion: $convertListNode,
1066
- priority: 0
1067
- })
1068
- };
1069
- }
1070
- static importJSON(serializedNode) {
1071
- return $createListNode().updateFromJSON(serializedNode);
1072
- }
1073
1071
  updateFromJSON(serializedNode) {
1074
1072
  return super.updateFromJSON(serializedNode).setListType(serializedNode.listType).setStart(serializedNode.start);
1075
1073
  }
@@ -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(O(r)){const e=r.getParent();if(k(e)){t++,r=e.getParent();continue}n(40)}return t}return t}function i(e){let t=e.getParent();k(t)||n(40);let r=t;for(;null!==r;)r=r.getParent(),k(r)&&(t=r);return t}function o(e){let t=[];const r=e.getChildren().filter(O);for(let e=0;e<r.length;e++){const n=r[e],s=n.getFirstChild();k(s)?t=t.concat(o(s)):t.push(n)}return t}function l(e){return O(e)&&k(e.getFirstChild())}function c(e){return y().append(e)}function a(e,t){return O(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=E(e);if(t.$isRootOrShadowRoot(c)){l.replace(r);const e=y();t.$isElementNode(l)&&(e.setFormat(l.getFormatType()),e.setIndent(l.getIndent())),r.append(e)}else if(O(l)){const e=l.getParentOrThrow();u(r,e.getChildren()),e.replace(r)}return}}const i=new Set;for(let r=0;r<s.length;r++){const n=s[r];if(t.$isElementNode(n)&&n.isEmpty()&&!O(n)&&!i.has(n.getKey())){d(n,e);continue}let o=t.$isLeafNode(n)?n.getParent():O(n)&&n.isEmpty()?n:null;for(;null!=o;){const r=o.getKey();if(k(o)){if(!i.has(r)){const t=E(e);u(t,o.getChildren()),o.replace(t),i.add(r)}break}{const n=o.getParent();if(t.$isRootOrShadowRoot(n)&&!i.has(r)){i.add(r),d(o,e);break}o=n}}}}}function u(e,t){e.splice(e.getChildrenSize(),0,t)}function d(e,t){if(k(e))return e;const r=e.getPreviousSibling(),n=e.getNextSibling(),s=y();let i;if(u(s,e.getChildren()),k(r)&&t===r.getListType())r.append(s),k(n)&&t===n.getListType()&&(u(r,n.getChildren()),n.remove()),i=r;else if(k(n)&&t===n.getListType())n.getFirstChildOrThrow().insertBefore(s),i=n;else{const r=E(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,N);null!=t&&n.add(i(t))}}for(const e of n){let n=e;const s=o(e);for(const e of s){const s=t.$createParagraphNode().setTextStyle(r.style).setTextFormat(r.format);u(s,e.getChildren()),n.insertAfter(s),n=s,e.__key===r.anchor.key&&t.$setPointFromCaret(r.anchor,t.$normalizeCaret(t.$getChildCaret(s,"next"))),e.__key===r.focus.key&&t.$setPointFromCaret(r.focus,t.$normalizeCaret(t.$getChildCaret(s,"next"))),e.remove()}e.remove()}}}function p(e){const t=new Set;if(l(e)||t.has(e.getKey()))return;const r=e.getParent(),n=e.getNextSibling(),s=e.getPreviousSibling();if(l(n)&&l(s)){const r=s.getFirstChild();if(k(r)){r.append(e);const s=n.getFirstChild();if(k(s)){u(r,s.getChildren()),n.remove(),t.add(n.getKey())}}}else if(l(n)){const t=n.getFirstChild();if(k(t)){const r=t.getFirstChild();null!==r&&r.insertBefore(e)}}else if(l(s)){const t=s.getFirstChild();k(t)&&t.append(e)}else if(k(r)){const t=y().setTextFormat(e.getTextFormat()).setTextStyle(e.getTextStyle()),i=E(r.getListType()).setTextFormat(r.getTextFormat()).setTextStyle(r.getTextStyle());t.append(i),i.append(e),s?s.insertAfter(t):n?n.insertBefore(t):r.append(t)}}function m(e){if(l(e))return;const t=e.getParent(),r=t?t.getParent():void 0;if(k(r?r.getParent():void 0)&&O(r)&&k(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=y(),i=E(n);s.append(i),e.getPreviousSiblings().forEach((e=>i.append(e)));const o=y(),l=E(n);o.append(l),u(l,e.getNextSiblings()),r.insertBefore(s),r.insertAfter(o),r.replace(e)}}}function _(){const e=t.$getSelection();if(!t.$isRangeSelection(e)||!e.isCollapsed())return!1;const r=e.anchor.getNode();if(!O(r)||0!==r.getChildrenSize())return!1;const s=i(r),o=r.getParent();k(o)||n(40);const l=o.getParent();let c;if(t.$isRootOrShadowRoot(l))c=t.$createParagraphNode(),s.insertAfter(c);else{if(!O(l))return!1;c=y(),l.insertAfter(c)}c.setTextStyle(e.style).setTextFormat(e.format).select();const a=r.getNextSiblings();if(a.length>0){const e=E(o.getListType());if(O(c)){const t=y();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||!O(e)&&!k(e))break;t=e}t.remove()}(r),!0}function C(...e){const t=[];for(const r of e)if(r&&"string"==typeof r)for(const[e]of r.matchAll(/\S+/g))t.push(e);return t}class N extends t.ElementNode{static getType(){return"listitem"}static clone(e){return new N(e.__value,e.__checked,e.__key)}constructor(e,t,r){super(r),this.__value=void 0===e?1:e,this.__checked=t}createDOM(e){const t=document.createElement("li");return this.updateListItemDOM(null,t,e),t}updateListItemDOM(t,n,s){const i=this.getParent();k(i)&&"check"===i.getListType()&&function(e,t,r,n){k(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(...C(l));if(o){const e=n.getParent(),t=k(e)&&"check"===e.getListType(),r=n.getChecked();t&&!r||i.push(o.listitemUnchecked),t&&r||i.push(o.listitemChecked),t&&s.push(r?o.listitemChecked:o.listitemUnchecked)}if(void 0!==c){const e=C(c);n.getChildren().some((e=>k(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}static transform(){return e=>{if(O(e)||n(144),null==e.__checked)return;const t=e.getParent();k(t)&&"check"!==t.getListType()&&null!=e.getChecked()&&e.setChecked(void 0)}}static importDOM(){return{li:()=>({conversion:T,priority:0})}}static importJSON(e){return y().updateFromJSON(e)}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(O(e))return super.replace(e);this.setIndent(0);const s=this.getParentOrThrow();if(!k(s))return e;if(s.__first===this.getKey())s.insertBefore(e);else if(s.__last===this.getKey())s.insertAfter(e);else{const t=E(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(k(r)||n(39),O(e))return super.insertAfter(e,t);const s=this.getNextSiblings();if(r.insertAfter(e,t),0!==s.length){const n=E(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=y().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=O(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 k(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(;O(t);)t=t.getParentOrThrow().getParentOrThrow(),r++;return r}setIndent(e){"number"!=typeof e&&n(117),(e=Math.floor(e))>=0||n(199);let t=this.getIndent();for(;t!==e;)t<e?(p(this),t++):(m(this),t--);return this}canInsertAfter(e){return O(e)}canReplaceWith(e){return O(e)}canMergeWith(e){return O(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 E("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 S(t);const t=e.getAttribute("aria-checked");return{node:y("true"===t||"false"!==t&&void 0)}}function S(e){if(!("checkbox"===e.getAttribute("type")))return{node:null};return{node:y(e.hasAttribute("checked"))}}function y(e){return t.$applyNodeReplacement(new N(void 0,e))}function O(e){return e instanceof N}class x extends t.ElementNode{static getType(){return"list"}static clone(e){const t=e.__listType||P[e.__tag];return new x(t,e.__start,e.__key)}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}getTag(){return this.__tag}setListType(e){const t=this.getWritable();return t.__listType=e,t.__tag="number"===e?"ol":"ul",t}getListType(){return this.__listType}getStart(){return this.__start}setStart(e){const t=this.getWritable();return t.__start=e,t}createDOM(e,t){const r=this.__tag,n=document.createElement(r);return 1!==this.__start&&n.setAttribute("start",String(this.__start)),n.__lexicalListType=this.__listType,L(n,e.theme,this),n}updateDOM(e,t,r){return e.__tag!==this.__tag||(L(t,r.theme,this),!1)}static transform(){return e=>{k(e)||n(163),function(e){const t=e.getNextSibling();k(t)&&e.getListType()===t.getListType()&&h(e,t)}(e),function(e){const t="check"!==e.getListType();let r=e.getStart();for(const n of e.getChildren())O(n)&&(n.getValue()!==r&&n.setValue(r),t&&null!=n.getLatest().__checked&&n.setChecked(void 0),k(n.getFirstChild())||r++)}(e)}}static importDOM(){return{ol:()=>({conversion:M,priority:0}),ul:()=>({conversion:M,priority:0})}}static importJSON(e){return E().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setListType(e.listType).setStart(e.start)}exportDOM(t){const r=this.createDOM(t._config,t);return e.isHTMLElement(r)&&(1!==this.__start&&r.setAttribute("start",String(this.__start)),"check"===this.__listType&&r.setAttribute("__lexicalListType","check")),{element:r}}exportJSON(){return{...super.exportJSON(),listType:this.getListType(),start:this.getStart(),tag:this.getTag()}}canBeEmpty(){return!1}canIndent(){return!1}splice(e,r,n){let s=n;for(let e=0;e<n.length;e++){const r=n[e];O(r)||(s===n&&(s=[...n]),s[e]=y().append(!t.$isElementNode(r)||k(r)||r.isInline()?r:t.$createTextNode(r.getTextContent())))}return super.splice(e,r,s)}extractWithChild(e){return O(e)}}function L(t,r,n){const i=[],o=[],l=r.list;if(void 0!==l){const e=l[`${n.__tag}Depth`]||[],t=s(n)-1,r=t%e.length,c=e[r],a=l[n.__tag];let g;const u=l.nested,d=l.checklist;if(void 0!==u&&u.list&&(g=u.list),void 0!==a&&i.push(a),void 0!==d&&"check"===n.__listType&&i.push(d),void 0!==c){i.push(...C(c));for(let t=0;t<e.length;t++)t!==r&&o.push(n.__tag+t)}if(void 0!==g){const e=C(g);t>1?i.push(...e):o.push(...e)}}o.length>0&&e.removeClassNamesFromElement(t,...o),i.length>0&&e.addClassNamesToElement(t,...i)}function v(e){const t=[];for(let r=0;r<e.length;r++){const n=e[r];if(O(n)){t.push(n);const e=n.getChildren();e.length>1&&e.forEach((e=>{k(e)&&t.push(c(e))}))}else t.push(c(n))}return t}function M(t){const r=t.nodeName.toLowerCase();let n=null;if("ol"===r){n=E("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)?E("check"):E("bullet"));return{after:v,node:n}}const P={ol:"number",ul:"bullet"};function E(e="number",r=1){return t.$applyNodeReplacement(new x(e,r))}function k(e){return e instanceof x}const R=t.createCommand("INSERT_CHECK_LIST_COMMAND");function A(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 b(r){A(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);O(r)&&(e.focus(),r.toggleChecked())}))}}))}function F(e){A(e,(()=>{e.preventDefault()}))}function I(){const t=document.activeElement;return e.isHTMLElement(t)&&"LI"===t.tagName&&null!=t.parentNode&&"check"===t.parentNode.__lexicalListType?t:null}function D(e,r,n){const s=I();return null!=s&&r.update((()=>{const i=t.$getNearestNodeFromDOMNode(s);if(!O(i))return;const o=function(e,t){let r=t?e.getPreviousSibling():e.getNextSibling(),n=e;for(;null==r&&O(n);)n=n.getParentOrThrow().getParent(),null!=n&&(r=t?n.getPreviousSibling():n.getNextSibling());for(;O(r);){const e=t?r.getLastChild():r.getFirstChild();if(!k(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 $=t.createCommand("INSERT_UNORDERED_LIST_COMMAND"),w=t.createCommand("INSERT_ORDERED_LIST_COMMAND"),W=t.createCommand("REMOVE_LIST_COMMAND");exports.$createListItemNode=y,exports.$createListNode=E,exports.$getListDepth=s,exports.$handleListInsertParagraph=_,exports.$insertList=g,exports.$isListItemNode=O,exports.$isListNode=k,exports.$removeList=f,exports.INSERT_CHECK_LIST_COMMAND=R,exports.INSERT_ORDERED_LIST_COMMAND=w,exports.INSERT_UNORDERED_LIST_COMMAND=$,exports.ListItemNode=N,exports.ListNode=x,exports.REMOVE_LIST_COMMAND=W,exports.insertList=function(e,t){e.update((()=>g(t)))},exports.registerCheckList=function(r){return e.mergeRegister(r.registerCommand(R,(()=>(g("check"),!0)),t.COMMAND_PRIORITY_LOW),r.registerCommand(t.KEY_ARROW_DOWN_COMMAND,(e=>D(e,r,!1)),t.COMMAND_PRIORITY_LOW),r.registerCommand(t.KEY_ARROW_UP_COMMAND,(e=>D(e,r,!0)),t.COMMAND_PRIORITY_LOW),r.registerCommand(t.KEY_ESCAPE_COMMAND,(()=>{if(null!=I()){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=I();return!(null==n||!r.isEditable())&&(r.update((()=>{const r=t.$getNearestNodeFromDOMNode(n);O(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(O(l)){const e=l.getParent();if(k(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",b),e.addEventListener("pointerdown",F)),null!==t&&(t.removeEventListener("click",b),t.removeEventListener("pointerdown",F))})))},exports.registerList=function(r){const n=e.mergeRegister(r.registerCommand(w,(()=>(g("number"),!0)),t.COMMAND_PRIORITY_LOW),r.registerCommand($,(()=>(g("bullet"),!0)),t.COMMAND_PRIORITY_LOW),r.registerCommand(W,(()=>(f(),!0)),t.COMMAND_PRIORITY_LOW),r.registerCommand(t.INSERT_PARAGRAPH_COMMAND,(()=>_()),t.COMMAND_PRIORITY_LOW),r.registerNodeTransform(N,(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(O(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(k(t.getFirstChild())||!k(r))return;const n=e.$findMatchingParent(t,(e=>O(e)&&k(e.getParent())&&O(e.getPreviousSibling())));if(null===n&&t.getIndent()>0)t.setIndent(0);else if(O(n)){const e=n.getPreviousSibling();if(O(e)){const n=function(e){let t=e,r=t.getFirstChild();for(;k(r);){const e=r.getLastChild();if(!O(e))break;t=e,r=t.getFirstChild()}return t}(e),i=n.getParent();if(k(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(k(e))for(const n of e.getChildren())if(O(n)){r(n);const e=n.getFirstChild();k(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(O(r)){const e=r.getParent();if(k(e)){t++,r=e.getParent();continue}n(40)}return t}return t}function i(e){let t=e.getParent();k(t)||n(40);let r=t;for(;null!==r;)r=r.getParent(),k(r)&&(t=r);return t}function o(e){let t=[];const r=e.getChildren().filter(O);for(let e=0;e<r.length;e++){const n=r[e],s=n.getFirstChild();k(s)?t=t.concat(o(s)):t.push(n)}return t}function l(e){return O(e)&&k(e.getFirstChild())}function c(e){return y().append(e)}function a(e,t){return O(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=P(e);if(t.$isRootOrShadowRoot(c)){l.replace(r);const e=y();t.$isElementNode(l)&&(e.setFormat(l.getFormatType()),e.setIndent(l.getIndent())),r.append(e)}else if(O(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()&&!O(n)&&!i.has(n.getKey())){u(n,e);continue}let o=t.$isLeafNode(n)?n.getParent():O(n)&&n.isEmpty()?n:null;for(;null!=o;){const r=o.getKey();if(k(o)){if(!i.has(r)){const t=P(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(k(e))return e;const r=e.getPreviousSibling(),n=e.getNextSibling(),s=y();let i;if(d(s,e.getChildren()),k(r)&&t===r.getListType())r.append(s),k(n)&&t===n.getListType()&&(d(r,n.getChildren()),n.remove()),i=r;else if(k(n)&&t===n.getListType())n.getFirstChildOrThrow().insertBefore(s),i=n;else{const r=P(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,N);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=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(k(r)){r.append(e);const s=n.getFirstChild();if(k(s)){d(r,s.getChildren()),n.remove(),t.add(n.getKey())}}}else if(l(n)){const t=n.getFirstChild();if(k(t)){const r=t.getFirstChild();null!==r&&r.insertBefore(e)}}else if(l(s)){const t=s.getFirstChild();k(t)&&t.append(e)}else if(k(r)){const t=y().setTextFormat(e.getTextFormat()).setTextStyle(e.getTextStyle()),i=P(r.getListType()).setTextFormat(r.getTextFormat()).setTextStyle(r.getTextStyle());t.append(i),i.append(e),s?s.insertAfter(t):n?n.insertBefore(t):r.append(t)}}function m(e){if(l(e))return;const t=e.getParent(),r=t?t.getParent():void 0;if(k(r?r.getParent():void 0)&&O(r)&&k(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=y(),i=P(n);s.append(i),e.getPreviousSiblings().forEach((e=>i.append(e)));const o=y(),l=P(n);o.append(l),d(l,e.getNextSiblings()),r.insertBefore(s),r.insertAfter(o),r.replace(e)}}}function _(){const e=t.$getSelection();if(!t.$isRangeSelection(e)||!e.isCollapsed())return!1;const r=e.anchor.getNode();if(!O(r)||0!==r.getChildrenSize())return!1;const s=i(r),o=r.getParent();k(o)||n(40);const l=o.getParent();let c;if(t.$isRootOrShadowRoot(l))c=t.$createParagraphNode(),s.insertAfter(c);else{if(!O(l))return!1;c=y(),l.insertAfter(c)}c.setTextStyle(e.style).setTextFormat(e.format).select();const a=r.getNextSiblings();if(a.length>0){const e=P(o.getListType());if(O(c)){const t=y();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||!O(e)&&!k(e))break;t=e}t.remove()}(r),!0}function C(...e){const t=[];for(const r of e)if(r&&"string"==typeof r)for(const[e]of r.matchAll(/\S+/g))t.push(e);return t}class N extends t.ElementNode{$config(){return this.config("listitem",{$transform:e=>{if(null==e.__checked)return;const t=e.getParent();k(t)&&"check"!==t.getListType()&&null!=e.getChecked()&&e.setChecked(void 0)},extends:t.ElementNode,importDOM:t.buildImportMap({li:()=>({conversion:T,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();k(i)&&"check"===i.getListType()&&function(e,t,r,n){k(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(...C(l));if(o){const e=n.getParent(),t=k(e)&&"check"===e.getListType(),r=n.getChecked();t&&!r||i.push(o.listitemUnchecked),t&&r||i.push(o.listitemChecked),t&&s.push(r?o.listitemChecked:o.listitemUnchecked)}if(void 0!==c){const e=C(c);n.getChildren().some((e=>k(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(O(e))return super.replace(e);this.setIndent(0);const s=this.getParentOrThrow();if(!k(s))return e;if(s.__first===this.getKey())s.insertBefore(e);else if(s.__last===this.getKey())s.insertAfter(e);else{const t=P(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(k(r)||n(39),O(e))return super.insertAfter(e,t);const s=this.getNextSiblings();if(r.insertAfter(e,t),0!==s.length){const n=P(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=y().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=O(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 k(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(;O(t);)t=t.getParentOrThrow().getParentOrThrow(),r++;return r}setIndent(e){"number"!=typeof e&&n(117),(e=Math.floor(e))>=0||n(199);let t=this.getIndent();for(;t!==e;)t<e?(p(this),t++):(m(this),t--);return this}canInsertAfter(e){return O(e)}canReplaceWith(e){return O(e)}canMergeWith(e){return O(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 P("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 S(t);const t=e.getAttribute("aria-checked");return{node:y("true"===t||"false"!==t&&void 0)}}function S(e){if(!("checkbox"===e.getAttribute("type")))return{node:null};return{node:y(e.hasAttribute("checked"))}}function y(e){return t.$applyNodeReplacement(new N(void 0,e))}function O(e){return e instanceof N}class L extends t.ElementNode{$config(){return this.config("list",{$transform:e=>{!function(e){const t=e.getNextSibling();k(t)&&e.getListType()===t.getListType()&&h(e,t)}(e),function(e){const t="check"!==e.getListType();let r=e.getStart();for(const n of e.getChildren())O(n)&&(n.getValue()!==r&&n.setValue(r),t&&null!=n.getLatest().__checked&&n.setChecked(void 0),k(n.getFirstChild())||r++)}(e)},extends:t.ElementNode,importDOM:t.buildImportMap({ol:()=>({conversion:M,priority:0}),ul:()=>({conversion:M,priority:0})})})}constructor(e="number",t=1,r){super(r);const n=E[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,x(n,e.theme,this),n}updateDOM(e,t,r){return e.__tag!==this.__tag||(x(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];O(r)||(s===n&&(s=[...n]),s[e]=y().append(!t.$isElementNode(r)||k(r)||r.isInline()?r:t.$createTextNode(r.getTextContent())))}return super.splice(e,r,s)}extractWithChild(e){return O(e)}}function x(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(...C(c));for(let t=0;t<e.length;t++)t!==r&&o.push(n.__tag+t)}if(void 0!==g){const e=C(g);t>1?i.push(...e):o.push(...e)}}o.length>0&&e.removeClassNamesFromElement(t,...o),i.length>0&&e.addClassNamesToElement(t,...i)}function v(e){const t=[];for(let r=0;r<e.length;r++){const n=e[r];if(O(n)){t.push(n);const e=n.getChildren();e.length>1&&e.forEach((e=>{k(e)&&t.push(c(e))}))}else t.push(c(n))}return t}function M(t){const r=t.nodeName.toLowerCase();let n=null;if("ol"===r){n=P("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)?P("check"):P("bullet"));return{after:v,node:n}}const E={ol:"number",ul:"bullet"};function P(e="number",r=1){return t.$applyNodeReplacement(new L(e,r))}function k(e){return e instanceof L}const R=t.createCommand("INSERT_CHECK_LIST_COMMAND");function A(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 b(r){A(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);O(r)&&(e.focus(),r.toggleChecked())}))}}))}function F(e){A(e,(()=>{e.preventDefault()}))}function I(){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=I();return null!=s&&r.update((()=>{const i=t.$getNearestNodeFromDOMNode(s);if(!O(i))return;const o=function(e,t){let r=t?e.getPreviousSibling():e.getNextSibling(),n=e;for(;null==r&&O(n);)n=n.getParentOrThrow().getParent(),null!=n&&(r=t?n.getPreviousSibling():n.getNextSibling());for(;O(r);){const e=t?r.getLastChild():r.getFirstChild();if(!k(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 D=t.createCommand("INSERT_UNORDERED_LIST_COMMAND"),w=t.createCommand("INSERT_ORDERED_LIST_COMMAND"),W=t.createCommand("REMOVE_LIST_COMMAND");exports.$createListItemNode=y,exports.$createListNode=P,exports.$getListDepth=s,exports.$handleListInsertParagraph=_,exports.$insertList=g,exports.$isListItemNode=O,exports.$isListNode=k,exports.$removeList=f,exports.INSERT_CHECK_LIST_COMMAND=R,exports.INSERT_ORDERED_LIST_COMMAND=w,exports.INSERT_UNORDERED_LIST_COMMAND=D,exports.ListItemNode=N,exports.ListNode=L,exports.REMOVE_LIST_COMMAND=W,exports.insertList=function(e,t){e.update((()=>g(t)))},exports.registerCheckList=function(r){return e.mergeRegister(r.registerCommand(R,(()=>(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!=I()){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=I();return!(null==n||!r.isEditable())&&(r.update((()=>{const r=t.$getNearestNodeFromDOMNode(n);O(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(O(l)){const e=l.getParent();if(k(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",b),e.addEventListener("pointerdown",F)),null!==t&&(t.removeEventListener("click",b),t.removeEventListener("pointerdown",F))})))},exports.registerList=function(r){const n=e.mergeRegister(r.registerCommand(w,(()=>(g("number"),!0)),t.COMMAND_PRIORITY_LOW),r.registerCommand(D,(()=>(g("bullet"),!0)),t.COMMAND_PRIORITY_LOW),r.registerCommand(W,(()=>(f(),!0)),t.COMMAND_PRIORITY_LOW),r.registerCommand(t.INSERT_PARAGRAPH_COMMAND,(()=>_()),t.COMMAND_PRIORITY_LOW),r.registerNodeTransform(N,(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(O(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(k(t.getFirstChild())||!k(r))return;const n=e.$findMatchingParent(t,(e=>O(e)&&k(e.getParent())&&O(e.getPreviousSibling())));if(null===n&&t.getIndent()>0)t.setIndent(0);else if(O(n)){const e=n.getPreviousSibling();if(O(e)){const n=function(e){let t=e,r=t.getFirstChild();for(;k(r);){const e=r.getLastChild();if(!O(e))break;t=e,r=t.getFirstChild()}return t}(e),i=n.getParent();if(k(i)){const e=s(i);e+1<s(r)&&t.setIndent(e)}}}};return t.registerNodeTransform(L,(e=>{const t=[e];for(;t.length>0;){const e=t.shift();if(k(e))for(const n of e.getChildren())if(O(n)){r(n);const e=n.getFirstChild();k(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 u,$isElementNode as g,$isLeafNode as h,$setPointFromCaret as d,$normalizeCaret as f,$getChildCaret as p,ElementNode as m,$isParagraphNode as _,$applyNodeReplacement as y,$createTextNode as C,createCommand as T,COMMAND_PRIORITY_LOW as S,KEY_ARROW_DOWN_COMMAND as v,KEY_ARROW_UP_COMMAND as x,KEY_ESCAPE_COMMAND as k,KEY_SPACE_COMMAND as b,$getNearestNodeFromDOMNode as N,KEY_ARROW_LEFT_COMMAND as L,getNearestEditorFromDOMNode as F,INSERT_PARAGRAPH_COMMAND as P,$isTextNode as O,TextNode as A}from"lexical";import{getStyleObjectFromCSS as E}from"@lexical/selection";function w(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 I(t){let e=1,n=t.getParent();for(;null!=n;){if(Z(n)){const t=n.getParent();if(ot(t)){e++,n=t.getParent();continue}w(40)}return e}return e}function D(t){let e=t.getParent();ot(e)||w(40);let n=e;for(;null!==n;)n=n.getParent(),ot(n)&&(e=n);return e}function M(t){let e=[];const n=t.getChildren().filter(Z);for(let t=0;t<n.length;t++){const r=n[t],i=r.getFirstChild();ot(i)?e=e.concat(M(i)):e.push(r)}return e}function R(t){return Z(t)&&ot(t.getFirstChild())}function J(t){return Y().append(t)}function B(t,e){return Z(t)&&(0===e.length||1===e.length&&t.is(e[0])&&0===t.getChildrenSize())}function W(t){const e=l();if(null!==e){let n=e.getNodes();if(c(e)){const r=e.getStartEndPoints();null===r&&w(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=u();s.append(t),n=t.select().getNodes()}}else if(B(s,n)){const e=st(t);if(a(o)){s.replace(e);const t=Y();g(s)&&(t.setFormat(s.getFormatType()),t.setIndent(s.getIndent())),e.append(t)}else if(Z(s)){const t=s.getParentOrThrow();K(e,t.getChildren()),t.replace(e)}return}}const r=new Set;for(let e=0;e<n.length;e++){const i=n[e];if(g(i)&&i.isEmpty()&&!Z(i)&&!r.has(i.getKey())){U(i,t);continue}let s=h(i)?i.getParent():Z(i)&&i.isEmpty()?i:null;for(;null!=s;){const e=s.getKey();if(ot(s)){if(!r.has(e)){const n=st(t);K(n,s.getChildren()),s.replace(n),r.add(e)}break}{const n=s.getParent();if(a(n)&&!r.has(e)){r.add(e),U(s,t);break}s=n}}}}}function K(t,e){t.splice(t.getChildrenSize(),0,e)}function U(t,e){if(ot(t))return t;const n=t.getPreviousSibling(),r=t.getNextSibling(),i=Y();let s;if(K(i,t.getChildren()),ot(n)&&e===n.getListType())n.append(i),ot(r)&&e===r.getListType()&&(K(n,r.getChildren()),r.remove()),s=n;else if(ot(r)&&e===r.getListType())r.getFirstChildOrThrow().insertBefore(i),s=r;else{const n=st(e);n.append(i),t.replace(n),s=n}return i.setFormat(t.getFormatType()),i.setIndent(t.getIndent()),t.remove(),s}function V(t,e){const n=t.getLastChild(),r=e.getFirstChild();n&&r&&R(n)&&R(r)&&(V(n.getFirstChild(),r.getFirstChild()),r.remove());const i=e.getChildren();i.length>0&&t.append(...i),e.remove()}function z(){const e=l();if(c(e)){const n=new Set,r=e.getNodes(),i=e.anchor.getNode();if(B(i,r))n.add(D(i));else for(let e=0;e<r.length;e++){const i=r[e];if(h(i)){const e=t(i,j);null!=e&&n.add(D(e))}}for(const t of n){let n=t;const r=M(t);for(const t of r){const r=u().setTextStyle(e.style).setTextFormat(e.format);K(r,t.getChildren()),n.insertAfter(r),n=r,t.__key===e.anchor.key&&d(e.anchor,f(p(r,"next"))),t.__key===e.focus.key&&d(e.focus,f(p(r,"next"))),t.remove()}t.remove()}}}function $(t){const e=new Set;if(R(t)||e.has(t.getKey()))return;const n=t.getParent(),r=t.getNextSibling(),i=t.getPreviousSibling();if(R(r)&&R(i)){const n=i.getFirstChild();if(ot(n)){n.append(t);const i=r.getFirstChild();if(ot(i)){K(n,i.getChildren()),r.remove(),e.add(r.getKey())}}}else if(R(r)){const e=r.getFirstChild();if(ot(e)){const n=e.getFirstChild();null!==n&&n.insertBefore(t)}}else if(R(i)){const e=i.getFirstChild();ot(e)&&e.append(t)}else if(ot(n)){const e=Y().setTextFormat(t.getTextFormat()).setTextStyle(t.getTextStyle()),s=st(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 q(t){if(R(t))return;const e=t.getParent(),n=e?e.getParent():void 0;if(ot(n?n.getParent():void 0)&&Z(n)&&ot(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=Y(),s=st(r);i.append(s),t.getPreviousSiblings().forEach((t=>s.append(t)));const o=Y(),l=st(r);o.append(l),K(l,t.getNextSiblings()),n.insertBefore(i),n.insertAfter(o),n.replace(t)}}}function H(){const t=l();if(!c(t)||!t.isCollapsed())return!1;const e=t.anchor.getNode();if(!Z(e)||0!==e.getChildrenSize())return!1;const n=D(e),r=e.getParent();ot(r)||w(40);const i=r.getParent();let s;if(a(i))s=u(),n.insertAfter(s);else{if(!Z(i))return!1;s=Y(),i.insertAfter(s)}s.setTextStyle(t.style).setTextFormat(t.format).select();const o=e.getNextSiblings();if(o.length>0){const t=st(r.getListType());if(Z(s)){const e=Y();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||!Z(t)&&!ot(t))break;e=t}e.remove()}(e),!0}function X(...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 j extends m{static getType(){return"listitem"}static clone(t){return new j(t.__value,t.__checked,t.__key)}constructor(t,e,n){super(n),this.__value=void 0===t?1:t,this.__checked=e}createDOM(t){const e=document.createElement("li");return this.updateListItemDOM(null,e,t),e}updateListItemDOM(t,r,i){const s=this.getParent();ot(s)&&"check"===s.getListType()&&function(t,e,n,r){ot(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(...X(c));if(l){const t=i.getParent(),e=ot(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=X(a);i.getChildren().some((t=>ot(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=E(e.__textStyle);for(const e in r)t.style.setProperty(`--listitem-marker-${e}`,r[e]);if(n)for(const e in E(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}static transform(){return t=>{if(Z(t)||w(144),null==t.__checked)return;const e=t.getParent();ot(e)&&"check"!==e.getListType()&&null!=t.getChecked()&&t.setChecked(void 0)}}static importDOM(){return{li:()=>({conversion:G,priority:0})}}static importJSON(t){return Y().updateFromJSON(t)}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(g(n)&&this.canMergeWith(n)){const t=n.getChildren();this.append(...t),n.remove()}else super.append(n)}return this}replace(t,e){if(Z(t))return super.replace(t);this.setIndent(0);const n=this.getParentOrThrow();if(!ot(n))return t;if(n.__first===this.getKey())n.insertBefore(t);else if(n.__last===this.getKey())n.insertAfter(t);else{const e=st(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&&(g(t)||w(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(ot(n)||w(39),Z(t))return super.insertAfter(t,e);const r=this.getNextSiblings();if(n.insertAfter(t,e),0!==r.length){const i=st(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&&R(e)&&R(n)&&(V(e.getFirstChild(),n.getFirstChild()),n.remove())}insertNewAfter(t,e=!0){const n=Y().updateFromJSON(this.exportJSON()).setChecked(!this.getChecked()&&void 0);return this.insertAfter(n,e),n}collapseAtStart(t){const e=u();this.getChildren().forEach((t=>e.append(t)));const n=this.getParentOrThrow(),r=n.getParentOrThrow(),i=Z(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 ot(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(;Z(e);)e=e.getParentOrThrow().getParentOrThrow(),n++;return n}setIndent(t){"number"!=typeof t&&w(117),(t=Math.floor(t))>=0||w(199);let e=this.getIndent();for(;e!==t;)e<t?($(this),e++):(q(this),e--);return this}canInsertAfter(t){return Z(t)}canReplaceWith(t){return Z(t)}canMergeWith(t){return Z(t)||_(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 st("bullet")}canMergeWhenEmpty(){return!0}}function G(t){if(t.classList.contains("task-list-item"))for(const e of t.children)if("INPUT"===e.tagName)return Q(e);const e=t.getAttribute("aria-checked");return{node:Y("true"===e||"false"!==e&&void 0)}}function Q(t){if(!("checkbox"===t.getAttribute("type")))return{node:null};return{node:Y(t.hasAttribute("checked"))}}function Y(t){return y(new j(void 0,t))}function Z(t){return t instanceof j}class tt extends m{static getType(){return"list"}static clone(t){const e=t.__listType||it[t.__tag];return new tt(e,t.__start,t.__key)}constructor(t="number",e=1,n){super(n);const r=it[t]||t;this.__listType=r,this.__tag="number"===r?"ol":"ul",this.__start=e}getTag(){return this.__tag}setListType(t){const e=this.getWritable();return e.__listType=t,e.__tag="number"===t?"ol":"ul",e}getListType(){return this.__listType}getStart(){return this.__start}setStart(t){const e=this.getWritable();return e.__start=t,e}createDOM(t,e){const n=this.__tag,r=document.createElement(n);return 1!==this.__start&&r.setAttribute("start",String(this.__start)),r.__lexicalListType=this.__listType,et(r,t.theme,this),r}updateDOM(t,e,n){return t.__tag!==this.__tag||(et(e,n.theme,this),!1)}static transform(){return t=>{ot(t)||w(163),function(t){const e=t.getNextSibling();ot(e)&&t.getListType()===e.getListType()&&V(t,e)}(t),function(t){const e="check"!==t.getListType();let n=t.getStart();for(const r of t.getChildren())Z(r)&&(r.getValue()!==n&&r.setValue(n),e&&null!=r.getLatest().__checked&&r.setChecked(void 0),ot(r.getFirstChild())||n++)}(t)}}static importDOM(){return{ol:()=>({conversion:rt,priority:0}),ul:()=>({conversion:rt,priority:0})}}static importJSON(t){return st().updateFromJSON(t)}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];Z(e)||(r===n&&(r=[...n]),r[t]=Y().append(!g(e)||ot(e)||e.isInline()?e:C(e.getTextContent())))}return super.splice(t,e,r)}extractWithChild(t){return Z(t)}}function et(t,r,i){const s=[],o=[],l=r.list;if(void 0!==l){const t=l[`${i.__tag}Depth`]||[],e=I(i)-1,n=e%t.length,r=t[n],c=l[i.__tag];let a;const u=l.nested,g=l.checklist;if(void 0!==u&&u.list&&(a=u.list),void 0!==c&&s.push(c),void 0!==g&&"check"===i.__listType&&s.push(g),void 0!==r){s.push(...X(r));for(let e=0;e<t.length;e++)e!==n&&o.push(i.__tag+e)}if(void 0!==a){const t=X(a);e>1?s.push(...t):o.push(...t)}}o.length>0&&e(t,...o),s.length>0&&n(t,...s)}function nt(t){const e=[];for(let n=0;n<t.length;n++){const r=t[n];if(Z(r)){e.push(r);const t=r.getChildren();t.length>1&&t.forEach((t=>{ot(t)&&e.push(J(t))}))}else e.push(J(r))}return e}function rt(t){const e=t.nodeName.toLowerCase();let n=null;if("ol"===e){n=st("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)?st("check"):st("bullet"));return{after:nt,node:n}}const it={ol:"number",ul:"bullet"};function st(t="number",e=1){return y(new tt(t,e))}function ot(t){return t instanceof tt}const lt=T("INSERT_CHECK_LIST_COMMAND");function ct(t){return i(t.registerCommand(lt,(()=>(W("check"),!0)),S),t.registerCommand(v,(e=>dt(e,t,!1)),S),t.registerCommand(x,(e=>dt(e,t,!0)),S),t.registerCommand(k,(()=>{if(null!=ht()){const e=t.getRootElement();return null!=e&&e.focus(),!0}return!1}),S),t.registerCommand(b,(e=>{const n=ht();return!(null==n||!t.isEditable())&&(t.update((()=>{const t=N(n);Z(t)&&(e.preventDefault(),t.toggleChecked())})),!0)}),S),t.registerCommand(L,(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=>g(t)&&!t.isInline()));if(Z(o)){const r=o.getParent();if(ot(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}))),S),t.registerRootListener(((t,e)=>{null!==t&&(t.addEventListener("click",ut),t.addEventListener("pointerdown",gt)),null!==e&&(e.removeEventListener("click",ut),e.removeEventListener("pointerdown",gt))})))}function at(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"},u=parseFloat(a.width);("rtl"===n.dir?c<l.right&&c>l.right-u:c>l.left&&c<l.left+u)&&e()}function ut(t){at(t,(()=>{if(r(t.target)){const e=t.target,n=F(e);null!=n&&n.isEditable()&&n.update((()=>{const t=N(e);Z(t)&&(e.focus(),t.toggleChecked())}))}}))}function gt(t){at(t,(()=>{t.preventDefault()}))}function ht(){const t=document.activeElement;return r(t)&&"LI"===t.tagName&&null!=t.parentNode&&"check"===t.parentNode.__lexicalListType?t:null}function dt(t,e,n){const r=ht();return null!=r&&e.update((()=>{const i=N(r);if(!Z(i))return;const s=function(t,e){let n=e?t.getPreviousSibling():t.getNextSibling(),r=t;for(;null==n&&Z(r);)r=r.getParentOrThrow().getParent(),null!=r&&(n=e?r.getPreviousSibling():r.getNextSibling());for(;Z(n);){const t=e?n.getLastChild():n.getFirstChild();if(!ot(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 ft=T("INSERT_UNORDERED_LIST_COMMAND"),pt=T("INSERT_ORDERED_LIST_COMMAND"),mt=T("REMOVE_LIST_COMMAND");function _t(t){return i(t.registerCommand(pt,(()=>(W("number"),!0)),S),t.registerCommand(ft,(()=>(W("bullet"),!0)),S),t.registerCommand(mt,(()=>(z(),!0)),S),t.registerCommand(P,(()=>H()),S),t.registerNodeTransform(j,(t=>{const e=t.getFirstChild();if(e){if(O(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(A,(t=>{const e=t.getParent();if(Z(e)&&t.is(e.getFirstChild())){const n=t.getStyle(),r=t.getFormat();n===e.getTextStyle()&&r===e.getTextFormat()||e.setTextStyle(n).setTextFormat(r)}})))}function yt(t){const e=t=>{const e=t.getParent();if(ot(t.getFirstChild())||!ot(e))return;const n=s(t,(t=>Z(t)&&ot(t.getParent())&&Z(t.getPreviousSibling())));if(null===n&&t.getIndent()>0)t.setIndent(0);else if(Z(n)){const r=n.getPreviousSibling();if(Z(r)){const n=function(t){let e=t,n=e.getFirstChild();for(;ot(n);){const t=n.getLastChild();if(!Z(t))break;e=t,n=e.getFirstChild()}return e}(r),i=n.getParent();if(ot(i)){const n=I(i);n+1<I(e)&&t.setIndent(n)}}}};return t.registerNodeTransform(tt,(t=>{const n=[t];for(;n.length>0;){const t=n.shift();if(ot(t))for(const r of t.getChildren())if(Z(r)){e(r);const t=r.getFirstChild();ot(t)&&n.push(t)}}}))}function Ct(t,e){t.update((()=>W(e)))}function Tt(t){t.update((()=>z()))}export{Y as $createListItemNode,st as $createListNode,I as $getListDepth,H as $handleListInsertParagraph,W as $insertList,Z as $isListItemNode,ot as $isListNode,z as $removeList,lt as INSERT_CHECK_LIST_COMMAND,pt as INSERT_ORDERED_LIST_COMMAND,ft as INSERT_UNORDERED_LIST_COMMAND,j as ListItemNode,tt as ListNode,mt as REMOVE_LIST_COMMAND,Ct as insertList,ct as registerCheckList,_t as registerList,yt as registerListStrictIndentTransform,Tt 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 v,COMMAND_PRIORITY_LOW as S,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,INSERT_PARAGRAPH_COMMAND as O,$isTextNode as A,TextNode as E}from"lexical";import{getStyleObjectFromCSS as w}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 D(t){let e=1,n=t.getParent();for(;null!=n;){if(tt(n)){const t=n.getParent();if(lt(t)){e++,n=t.getParent();continue}I(40)}return e}return e}function M(t){let e=t.getParent();lt(e)||I(40);let n=e;for(;null!==n;)n=n.getParent(),lt(n)&&(e=n);return e}function R(t){let e=[];const n=t.getChildren().filter(tt);for(let t=0;t<n.length;t++){const r=n[t],i=r.getFirstChild();lt(i)?e=e.concat(R(i)):e.push(r)}return e}function B(t){return tt(t)&&lt(t.getFirstChild())}function W(t){return Z().append(t)}function J(t,e){return tt(t)&&(0===e.length||1===e.length&&t.is(e[0])&&0===t.getChildrenSize())}function K(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=ot(t);if(a(o)){s.replace(e);const t=Z();u(s)&&(t.setFormat(s.getFormatType()),t.setIndent(s.getIndent())),e.append(t)}else if(tt(s)){const t=s.getParentOrThrow();$(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()&&!tt(i)&&!r.has(i.getKey())){U(i,t);continue}let s=h(i)?i.getParent():tt(i)&&i.isEmpty()?i:null;for(;null!=s;){const e=s.getKey();if(lt(s)){if(!r.has(e)){const n=ot(t);$(n,s.getChildren()),s.replace(n),r.add(e)}break}{const n=s.getParent();if(a(n)&&!r.has(e)){r.add(e),U(s,t);break}s=n}}}}}function $(t,e){t.splice(t.getChildrenSize(),0,e)}function U(t,e){if(lt(t))return t;const n=t.getPreviousSibling(),r=t.getNextSibling(),i=Z();let s;if($(i,t.getChildren()),lt(n)&&e===n.getListType())n.append(i),lt(r)&&e===r.getListType()&&($(n,r.getChildren()),r.remove()),s=n;else if(lt(r)&&e===r.getListType())r.getFirstChildOrThrow().insertBefore(i),s=r;else{const n=ot(e);n.append(i),t.replace(n),s=n}return i.setFormat(t.getFormatType()),i.setIndent(t.getIndent()),t.remove(),s}function V(t,e){const n=t.getLastChild(),r=e.getFirstChild();n&&r&&B(n)&&B(r)&&(V(n.getFirstChild(),r.getFirstChild()),r.remove());const i=e.getChildren();i.length>0&&t.append(...i),e.remove()}function z(){const e=l();if(c(e)){const n=new Set,r=e.getNodes(),i=e.anchor.getNode();if(J(i,r))n.add(M(i));else for(let e=0;e<r.length;e++){const i=r[e];if(h(i)){const e=t(i,G);null!=e&&n.add(M(e))}}for(const t of n){let n=t;const r=R(t);for(const t of r){const r=g().setTextStyle(e.style).setTextFormat(e.format);$(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 q(t){const e=new Set;if(B(t)||e.has(t.getKey()))return;const n=t.getParent(),r=t.getNextSibling(),i=t.getPreviousSibling();if(B(r)&&B(i)){const n=i.getFirstChild();if(lt(n)){n.append(t);const i=r.getFirstChild();if(lt(i)){$(n,i.getChildren()),r.remove(),e.add(r.getKey())}}}else if(B(r)){const e=r.getFirstChild();if(lt(e)){const n=e.getFirstChild();null!==n&&n.insertBefore(t)}}else if(B(i)){const e=i.getFirstChild();lt(e)&&e.append(t)}else if(lt(n)){const e=Z().setTextFormat(t.getTextFormat()).setTextStyle(t.getTextStyle()),s=ot(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 H(t){if(B(t))return;const e=t.getParent(),n=e?e.getParent():void 0;if(lt(n?n.getParent():void 0)&&tt(n)&&lt(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=Z(),s=ot(r);i.append(s),t.getPreviousSiblings().forEach((t=>s.append(t)));const o=Z(),l=ot(r);o.append(l),$(l,t.getNextSiblings()),n.insertBefore(i),n.insertAfter(o),n.replace(t)}}}function X(){const t=l();if(!c(t)||!t.isCollapsed())return!1;const e=t.anchor.getNode();if(!tt(e)||0!==e.getChildrenSize())return!1;const n=M(e),r=e.getParent();lt(r)||I(40);const i=r.getParent();let s;if(a(i))s=g(),n.insertAfter(s);else{if(!tt(i))return!1;s=Z(),i.insertAfter(s)}s.setTextStyle(t.style).setTextFormat(t.format).select();const o=e.getNextSiblings();if(o.length>0){const t=ot(r.getListType());if(tt(s)){const e=Z();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||!tt(t)&&!lt(t))break;e=t}e.remove()}(e),!0}function j(...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 G extends m{$config(){return this.config("listitem",{$transform:t=>{if(null==t.__checked)return;const e=t.getParent();lt(e)&&"check"!==e.getListType()&&null!=t.getChecked()&&t.setChecked(void 0)},extends:m,importDOM:_({li:()=>({conversion:Q,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();lt(s)&&"check"===s.getListType()&&function(t,e,n,r){lt(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(...j(c));if(l){const t=i.getParent(),e=lt(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=j(a);i.getChildren().some((t=>lt(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=w(e.__textStyle);for(const e in r)t.style.setProperty(`--listitem-marker-${e}`,r[e]);if(n)for(const e in w(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(tt(t))return super.replace(t);this.setIndent(0);const n=this.getParentOrThrow();if(!lt(n))return t;if(n.__first===this.getKey())n.insertBefore(t);else if(n.__last===this.getKey())n.insertAfter(t);else{const e=ot(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(lt(n)||I(39),tt(t))return super.insertAfter(t,e);const r=this.getNextSiblings();if(n.insertAfter(t,e),0!==r.length){const i=ot(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&&B(e)&&B(n)&&(V(e.getFirstChild(),n.getFirstChild()),n.remove())}insertNewAfter(t,e=!0){const n=Z().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=tt(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 lt(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(;tt(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?(q(this),e++):(H(this),e--);return this}canInsertAfter(t){return tt(t)}canReplaceWith(t){return tt(t)}canMergeWith(t){return tt(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 ot("bullet")}canMergeWhenEmpty(){return!0}}function Q(t){if(t.classList.contains("task-list-item"))for(const e of t.children)if("INPUT"===e.tagName)return Y(e);const e=t.getAttribute("aria-checked");return{node:Z("true"===e||"false"!==e&&void 0)}}function Y(t){if(!("checkbox"===t.getAttribute("type")))return{node:null};return{node:Z(t.hasAttribute("checked"))}}function Z(t){return C(new G(void 0,t))}function tt(t){return t instanceof G}class et extends m{$config(){return this.config("list",{$transform:t=>{!function(t){const e=t.getNextSibling();lt(e)&&t.getListType()===e.getListType()&&V(t,e)}(t),function(t){const e="check"!==t.getListType();let n=t.getStart();for(const r of t.getChildren())tt(r)&&(r.getValue()!==n&&r.setValue(n),e&&null!=r.getLatest().__checked&&r.setChecked(void 0),lt(r.getFirstChild())||n++)}(t)},extends:m,importDOM:_({ol:()=>({conversion:it,priority:0}),ul:()=>({conversion:it,priority:0})})})}constructor(t="number",e=1,n){super(n);const r=st[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,nt(r,t.theme,this),r}updateDOM(t,e,n){return t.__tag!==this.__tag||(nt(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];tt(e)||(r===n&&(r=[...n]),r[t]=Z().append(!u(e)||lt(e)||e.isInline()?e:T(e.getTextContent())))}return super.splice(t,e,r)}extractWithChild(t){return tt(t)}}function nt(t,r,i){const s=[],o=[],l=r.list;if(void 0!==l){const t=l[`${i.__tag}Depth`]||[],e=D(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(...j(r));for(let e=0;e<t.length;e++)e!==n&&o.push(i.__tag+e)}if(void 0!==a){const t=j(a);e>1?s.push(...t):o.push(...t)}}o.length>0&&e(t,...o),s.length>0&&n(t,...s)}function rt(t){const e=[];for(let n=0;n<t.length;n++){const r=t[n];if(tt(r)){e.push(r);const t=r.getChildren();t.length>1&&t.forEach((t=>{lt(t)&&e.push(W(t))}))}else e.push(W(r))}return e}function it(t){const e=t.nodeName.toLowerCase();let n=null;if("ol"===e){n=ot("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)?ot("check"):ot("bullet"));return{after:rt,node:n}}const st={ol:"number",ul:"bullet"};function ot(t="number",e=1){return C(new et(t,e))}function lt(t){return t instanceof et}const ct=v("INSERT_CHECK_LIST_COMMAND");function at(t){return i(t.registerCommand(ct,(()=>(K("check"),!0)),S),t.registerCommand(x,(e=>dt(e,t,!1)),S),t.registerCommand(k,(e=>dt(e,t,!0)),S),t.registerCommand(b,(()=>{if(null!=ft()){const e=t.getRootElement();return null!=e&&e.focus(),!0}return!1}),S),t.registerCommand(N,(e=>{const n=ft();return!(null==n||!t.isEditable())&&(t.update((()=>{const t=L(n);tt(t)&&(e.preventDefault(),t.toggleChecked())})),!0)}),S),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(tt(o)){const r=o.getParent();if(lt(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}))),S),t.registerRootListener(((t,e)=>{null!==t&&(t.addEventListener("click",ut),t.addEventListener("pointerdown",ht)),null!==e&&(e.removeEventListener("click",ut),e.removeEventListener("pointerdown",ht))})))}function gt(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 ut(t){gt(t,(()=>{if(r(t.target)){const e=t.target,n=P(e);null!=n&&n.isEditable()&&n.update((()=>{const t=L(e);tt(t)&&(e.focus(),t.toggleChecked())}))}}))}function ht(t){gt(t,(()=>{t.preventDefault()}))}function ft(){const t=document.activeElement;return r(t)&&"LI"===t.tagName&&null!=t.parentNode&&"check"===t.parentNode.__lexicalListType?t:null}function dt(t,e,n){const r=ft();return null!=r&&e.update((()=>{const i=L(r);if(!tt(i))return;const s=function(t,e){let n=e?t.getPreviousSibling():t.getNextSibling(),r=t;for(;null==n&&tt(r);)r=r.getParentOrThrow().getParent(),null!=r&&(n=e?r.getPreviousSibling():r.getNextSibling());for(;tt(n);){const t=e?n.getLastChild():n.getFirstChild();if(!lt(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 pt=v("INSERT_UNORDERED_LIST_COMMAND"),mt=v("INSERT_ORDERED_LIST_COMMAND"),_t=v("REMOVE_LIST_COMMAND");function yt(t){return i(t.registerCommand(mt,(()=>(K("number"),!0)),S),t.registerCommand(pt,(()=>(K("bullet"),!0)),S),t.registerCommand(_t,(()=>(z(),!0)),S),t.registerCommand(O,(()=>X()),S),t.registerNodeTransform(G,(t=>{const e=t.getFirstChild();if(e){if(A(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(E,(t=>{const e=t.getParent();if(tt(e)&&t.is(e.getFirstChild())){const n=t.getStyle(),r=t.getFormat();n===e.getTextStyle()&&r===e.getTextFormat()||e.setTextStyle(n).setTextFormat(r)}})))}function Ct(t){const e=t=>{const e=t.getParent();if(lt(t.getFirstChild())||!lt(e))return;const n=s(t,(t=>tt(t)&&lt(t.getParent())&&tt(t.getPreviousSibling())));if(null===n&&t.getIndent()>0)t.setIndent(0);else if(tt(n)){const r=n.getPreviousSibling();if(tt(r)){const n=function(t){let e=t,n=e.getFirstChild();for(;lt(n);){const t=n.getLastChild();if(!tt(t))break;e=t,n=e.getFirstChild()}return e}(r),i=n.getParent();if(lt(i)){const n=D(i);n+1<D(e)&&t.setIndent(n)}}}};return t.registerNodeTransform(et,(t=>{const n=[t];for(;n.length>0;){const t=n.shift();if(lt(t))for(const r of t.getChildren())if(tt(r)){e(r);const t=r.getFirstChild();lt(t)&&n.push(t)}}}))}function Tt(t,e){t.update((()=>K(e)))}function vt(t){t.update((()=>z()))}export{Z as $createListItemNode,ot as $createListNode,D as $getListDepth,X as $handleListInsertParagraph,K as $insertList,tt as $isListItemNode,lt as $isListNode,z as $removeList,ct as INSERT_CHECK_LIST_COMMAND,mt as INSERT_ORDERED_LIST_COMMAND,pt as INSERT_UNORDERED_LIST_COMMAND,G as ListItemNode,et as ListNode,_t as REMOVE_LIST_COMMAND,Tt as insertList,at as registerCheckList,yt as registerList,Ct as registerListStrictIndentTransform,vt as removeList};
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
- import type { BaseSelection, DOMConversionMap, DOMExportOutput, EditorConfig, LexicalNode, LexicalUpdateJSON, NodeKey, ParagraphNode, RangeSelection, SerializedElementNode, Spread } from 'lexical';
8
+ import type { BaseSelection, DOMExportOutput, EditorConfig, LexicalNode, LexicalUpdateJSON, NodeKey, ParagraphNode, RangeSelection, SerializedElementNode, Spread } from 'lexical';
9
9
  import { ElementNode, LexicalEditor } from 'lexical';
10
10
  export type SerializedListItemNode = Spread<{
11
11
  checked: boolean | undefined;
@@ -17,15 +17,17 @@ export declare class ListItemNode extends ElementNode {
17
17
  __value: number;
18
18
  /** @internal */
19
19
  __checked?: boolean;
20
- static getType(): string;
21
- static clone(node: ListItemNode): ListItemNode;
22
- constructor(value?: number, checked?: boolean, key?: NodeKey);
20
+ /** @internal */
21
+ $config(): import("lexical").StaticNodeConfigRecord<"listitem", {
22
+ $transform: (node: ListItemNode) => void;
23
+ extends: typeof ElementNode;
24
+ importDOM: import("lexical").DOMConversionMap<HTMLElement>;
25
+ }>;
26
+ constructor(value?: number, checked?: undefined | boolean, key?: NodeKey);
27
+ afterCloneFrom(prevNode: this): void;
23
28
  createDOM(config: EditorConfig): HTMLElement;
24
29
  updateListItemDOM(prevNode: ListItemNode | null, dom: HTMLLIElement, config: EditorConfig): void;
25
30
  updateDOM(prevNode: ListItemNode, dom: HTMLElement, config: EditorConfig): boolean;
26
- static transform(): (node: LexicalNode) => void;
27
- static importDOM(): DOMConversionMap | null;
28
- static importJSON(serializedNode: SerializedListItemNode): ListItemNode;
29
31
  updateFromJSON(serializedNode: LexicalUpdateJSON<SerializedListItemNode>): this;
30
32
  exportDOM(editor: LexicalEditor): DOMExportOutput;
31
33
  exportJSON(): SerializedListItemNode;
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
- import { DOMConversionMap, DOMExportOutput, EditorConfig, ElementNode, LexicalEditor, LexicalNode, LexicalUpdateJSON, NodeKey, SerializedElementNode, Spread } from 'lexical';
8
+ import { DOMExportOutput, EditorConfig, ElementNode, LexicalEditor, LexicalNode, LexicalUpdateJSON, NodeKey, SerializedElementNode, Spread } from 'lexical';
9
9
  export type SerializedListNode = Spread<{
10
10
  listType: ListType;
11
11
  start: number;
@@ -21,9 +21,14 @@ export declare class ListNode extends ElementNode {
21
21
  __start: number;
22
22
  /** @internal */
23
23
  __listType: ListType;
24
- static getType(): string;
25
- static clone(node: ListNode): ListNode;
24
+ /** @internal */
25
+ $config(): import("lexical").StaticNodeConfigRecord<"list", {
26
+ $transform: (node: ListNode) => void;
27
+ extends: typeof ElementNode;
28
+ importDOM: import("lexical").DOMConversionMap<HTMLElement>;
29
+ }>;
26
30
  constructor(listType?: ListType, start?: number, key?: NodeKey);
31
+ afterCloneFrom(prevNode: this): void;
27
32
  getTag(): ListNodeTagType;
28
33
  setListType(type: ListType): this;
29
34
  getListType(): ListType;
@@ -31,9 +36,6 @@ export declare class ListNode extends ElementNode {
31
36
  setStart(start: number): this;
32
37
  createDOM(config: EditorConfig, _editor?: LexicalEditor): HTMLElement;
33
38
  updateDOM(prevNode: this, dom: HTMLElement, config: EditorConfig): boolean;
34
- static transform(): (node: LexicalNode) => void;
35
- static importDOM(): DOMConversionMap | null;
36
- static importJSON(serializedNode: SerializedListNode): ListNode;
37
39
  updateFromJSON(serializedNode: LexicalUpdateJSON<SerializedListNode>): this;
38
40
  exportDOM(editor: LexicalEditor): DOMExportOutput;
39
41
  exportJSON(): SerializedListNode;
package/package.json CHANGED
@@ -8,13 +8,13 @@
8
8
  "list"
9
9
  ],
10
10
  "license": "MIT",
11
- "version": "0.32.2-nightly.20250620.0",
11
+ "version": "0.32.2-nightly.20250623.0",
12
12
  "main": "LexicalList.js",
13
13
  "types": "index.d.ts",
14
14
  "dependencies": {
15
- "@lexical/selection": "0.32.2-nightly.20250620.0",
16
- "@lexical/utils": "0.32.2-nightly.20250620.0",
17
- "lexical": "0.32.2-nightly.20250620.0"
15
+ "@lexical/selection": "0.32.2-nightly.20250623.0",
16
+ "@lexical/utils": "0.32.2-nightly.20250623.0",
17
+ "lexical": "0.32.2-nightly.20250623.0"
18
18
  },
19
19
  "repository": {
20
20
  "type": "git",