@lexical/list 0.45.0 → 0.45.1-dev.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.
@@ -1885,7 +1885,12 @@ const ListRule = html.defineImportRule({
1885
1885
  node = $createListNode('bullet');
1886
1886
  }
1887
1887
  lexical.$setDirectionFromDOM(node, el);
1888
- return [node.splice(0, 0, $normalizeListChildren(ctx.$importChildren(el)))];
1888
+ // Propagate the list's `text-align` onto each `ListItemNode` child
1889
+ // (legacy `wrapContinuousInlines` did the same), so pasting
1890
+ // `<ul style="text-align: left"><li>…</li></ul>` ends up with the
1891
+ // alignment on the list items where the reconciler renders it as
1892
+ // `style="text-align: left"`.
1893
+ return [node.splice(0, 0, html.$propagateTextAlignToBlockChildren($normalizeListChildren(ctx.$importChildren(el)), el))];
1889
1894
  },
1890
1895
  match: html.sel.tag('ol', 'ul'),
1891
1896
  name: '@lexical/list/list'
@@ -1908,6 +1913,60 @@ function $liftFormatFromSingleParagraph(listItemNode, children) {
1908
1913
  }
1909
1914
  return children;
1910
1915
  }
1916
+
1917
+ /**
1918
+ * Collapse block children of a `<li>` into inline-with-line-break form: a
1919
+ * `ListItemNode` is an inline-level container, so any block child marks a
1920
+ * boundary. Contiguous inline siblings are kept together as a single run and
1921
+ * one {@link $createLineBreakNode} is inserted between runs — reproducing the
1922
+ * legacy `wrapContinuousInlines` + `$unwrapArtificialNodes` shape
1923
+ * (`<li>1<div>2</div>3</li>` → `1<br>2<br>3`) without the
1924
+ * `ArtificialNode__DO_NOT_USE` marker.
1925
+ *
1926
+ * Boundaries are detected with {@link $isBlockLevel}, NOT `$isParagraphNode`:
1927
+ * the `<div>`/`<section>`/… `TransparentBlockRule` happens to emit
1928
+ * `ParagraphNode`s, but a `<blockquote>` (`QuoteNode`), heading
1929
+ * (`HeadingNode`), or block decorator (`HorizontalRuleNode`, …) is just as
1930
+ * much a block boundary and must not be silently spliced into the list item
1931
+ * as-is. A nested `ListNode` is the one deliberate exception — it is a valid
1932
+ * list-item child that {@link $normalizeListChildren} lifts into a sibling,
1933
+ * so it is preserved here rather than unwrapped.
1934
+ */
1935
+ function $flattenListItemBlocks(children) {
1936
+ const $isBoundary = node => html.$isBlockLevel(node) && !$isListNode(node);
1937
+ if (!children.some($isBoundary)) {
1938
+ return children;
1939
+ }
1940
+ // Partition into segments — each maximal run of inline siblings, and each
1941
+ // boundary's own content — then join the segments with a single line break.
1942
+ const segments = [];
1943
+ let inlineRun = [];
1944
+ const flushInlineRun = () => {
1945
+ if (inlineRun.length > 0) {
1946
+ segments.push(inlineRun);
1947
+ inlineRun = [];
1948
+ }
1949
+ };
1950
+ for (const child of children) {
1951
+ if ($isBoundary(child)) {
1952
+ flushInlineRun();
1953
+ // Unwrap a block ElementNode to its inline content; a childless block
1954
+ // DecoratorNode stands on its own line.
1955
+ segments.push(lexical.$isElementNode(child) ? child.getChildren() : [child]);
1956
+ } else {
1957
+ inlineRun.push(child);
1958
+ }
1959
+ }
1960
+ flushInlineRun();
1961
+ const out = [];
1962
+ for (const segment of segments) {
1963
+ if (out.length > 0) {
1964
+ out.push(lexical.$createLineBreakNode());
1965
+ }
1966
+ out.push(...segment);
1967
+ }
1968
+ return out;
1969
+ }
1911
1970
  const ListItemRule = html.defineImportRule({
1912
1971
  $import: (ctx, el) => {
1913
1972
  const ariaChecked = el.getAttribute('aria-checked');
@@ -1915,7 +1974,11 @@ const ListItemRule = html.defineImportRule({
1915
1974
  const node = $createListItemNode(checked);
1916
1975
  lexical.$setFormatFromDOM(node, el);
1917
1976
  lexical.$setDirectionFromDOM(node, el);
1918
- return [node.splice(0, 0, $liftFormatFromSingleParagraph(node, ctx.$importChildren(el)))];
1977
+ return [node.splice(0, 0,
1978
+ // Lift a sole wrapping paragraph's format onto the item *before*
1979
+ // flattening, otherwise the paragraph would already be unwrapped and
1980
+ // its alignment lost.
1981
+ $flattenListItemBlocks($liftFormatFromSingleParagraph(node, ctx.$importChildren(el))))];
1919
1982
  },
1920
1983
  match: html.sel.tag('li'),
1921
1984
  name: '@lexical/list/li'
@@ -1929,7 +1992,7 @@ function $buildChecklistItem(ctx, el, checkboxOwner) {
1929
1992
  const node = $createListItemNode(checked);
1930
1993
  lexical.$setFormatFromDOM(node, el);
1931
1994
  lexical.$setDirectionFromDOM(node, el);
1932
- return [node.splice(0, 0, $liftFormatFromSingleParagraph(node, ctx.$importChildren(el)))];
1995
+ return [node.splice(0, 0, $flattenListItemBlocks($liftFormatFromSingleParagraph(node, ctx.$importChildren(el))))];
1933
1996
  }
1934
1997
  const TaskListItemRule = html.defineImportRule({
1935
1998
  $import: (ctx, el, $next) => {
@@ -1990,13 +2053,16 @@ const ListImportRules = [
1990
2053
  TaskListItemRule, JoplinChecklistItemRule, ListRule, ListItemRule];
1991
2054
 
1992
2055
  /**
1993
- * Bundles {@link ListImportRules} (plus {@link CoreImportExtension}) into
1994
- * a single dependency.
2056
+ * Bundles {@link ListImportRules} together with the runtime
2057
+ * {@link ListExtension}. The application is expected to already have
2058
+ * `CoreImportExtension` (or some equivalent) in its dependency graph —
2059
+ * the core/text/paragraph/inline-format rules are a shared baseline,
2060
+ * not something this leaf importer should re-declare.
1995
2061
  *
1996
2062
  * @experimental
1997
2063
  */
1998
2064
  const ListImportExtension = lexical.defineExtension({
1999
- dependencies: [html.CoreImportExtension, ListExtension, lexical.configExtension(html.DOMImportExtension, {
2065
+ dependencies: [ListExtension, lexical.configExtension(html.DOMImportExtension, {
2000
2066
  rules: ListImportRules
2001
2067
  })],
2002
2068
  name: '@lexical/list/Import'
@@ -7,9 +7,9 @@
7
7
  */
8
8
 
9
9
  import { $getNearestNodeOfType, $insertNodeToNearestRootAtCaret, removeClassNamesFromElement, addClassNamesToElement, isHTMLElement as isHTMLElement$1, mergeRegister, $findMatchingParent, calculateZoomLevel } from '@lexical/utils';
10
- import { $getSelection, $isRangeSelection, $isTextNode, $isRootOrShadowRoot, $createParagraphNode, $copyNode, $isElementNode, $isLeafNode, $setPointFromCaret, $normalizeCaret, $getChildCaret, $applyNodeReplacement, ElementNode, buildImportMap, $getSiblingCaret, $rewindSiblingCaret, setDOMStyleFromCSS, isHTMLElement, $isParagraphNode, $setFormatFromDOM, $setDirectionFromDOM, normalizeClassNames, getStyleObjectFromCSS, $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, $addUpdateTag, SKIP_SELECTION_FOCUS_TAG, SKIP_DOM_SELECTION_TAG, $getNodeByKey, INSERT_PARAGRAPH_COMMAND, TextNode, defineExtension, safeCast, configExtension } from 'lexical';
10
+ import { $getSelection, $isRangeSelection, $isTextNode, $isRootOrShadowRoot, $createParagraphNode, $copyNode, $isElementNode, $isLeafNode, $setPointFromCaret, $normalizeCaret, $getChildCaret, $applyNodeReplacement, ElementNode, buildImportMap, $getSiblingCaret, $rewindSiblingCaret, setDOMStyleFromCSS, isHTMLElement, $isParagraphNode, $setFormatFromDOM, $setDirectionFromDOM, normalizeClassNames, getStyleObjectFromCSS, $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, $addUpdateTag, SKIP_SELECTION_FOCUS_TAG, SKIP_DOM_SELECTION_TAG, $getNodeByKey, INSERT_PARAGRAPH_COMMAND, TextNode, defineExtension, safeCast, configExtension, $createLineBreakNode } from 'lexical';
11
11
  import { namedSignals, effect } from '@lexical/extension';
12
- import { CoreImportExtension, DOMImportExtension, defineImportRule, sel, isElementOfTag } from '@lexical/html';
12
+ import { DOMImportExtension, defineImportRule, sel, isElementOfTag, $propagateTextAlignToBlockChildren, $isBlockLevel } from '@lexical/html';
13
13
 
14
14
  /**
15
15
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -1883,7 +1883,12 @@ const ListRule = defineImportRule({
1883
1883
  node = $createListNode('bullet');
1884
1884
  }
1885
1885
  $setDirectionFromDOM(node, el);
1886
- return [node.splice(0, 0, $normalizeListChildren(ctx.$importChildren(el)))];
1886
+ // Propagate the list's `text-align` onto each `ListItemNode` child
1887
+ // (legacy `wrapContinuousInlines` did the same), so pasting
1888
+ // `<ul style="text-align: left"><li>…</li></ul>` ends up with the
1889
+ // alignment on the list items where the reconciler renders it as
1890
+ // `style="text-align: left"`.
1891
+ return [node.splice(0, 0, $propagateTextAlignToBlockChildren($normalizeListChildren(ctx.$importChildren(el)), el))];
1887
1892
  },
1888
1893
  match: sel.tag('ol', 'ul'),
1889
1894
  name: '@lexical/list/list'
@@ -1906,6 +1911,60 @@ function $liftFormatFromSingleParagraph(listItemNode, children) {
1906
1911
  }
1907
1912
  return children;
1908
1913
  }
1914
+
1915
+ /**
1916
+ * Collapse block children of a `<li>` into inline-with-line-break form: a
1917
+ * `ListItemNode` is an inline-level container, so any block child marks a
1918
+ * boundary. Contiguous inline siblings are kept together as a single run and
1919
+ * one {@link $createLineBreakNode} is inserted between runs — reproducing the
1920
+ * legacy `wrapContinuousInlines` + `$unwrapArtificialNodes` shape
1921
+ * (`<li>1<div>2</div>3</li>` → `1<br>2<br>3`) without the
1922
+ * `ArtificialNode__DO_NOT_USE` marker.
1923
+ *
1924
+ * Boundaries are detected with {@link $isBlockLevel}, NOT `$isParagraphNode`:
1925
+ * the `<div>`/`<section>`/… `TransparentBlockRule` happens to emit
1926
+ * `ParagraphNode`s, but a `<blockquote>` (`QuoteNode`), heading
1927
+ * (`HeadingNode`), or block decorator (`HorizontalRuleNode`, …) is just as
1928
+ * much a block boundary and must not be silently spliced into the list item
1929
+ * as-is. A nested `ListNode` is the one deliberate exception — it is a valid
1930
+ * list-item child that {@link $normalizeListChildren} lifts into a sibling,
1931
+ * so it is preserved here rather than unwrapped.
1932
+ */
1933
+ function $flattenListItemBlocks(children) {
1934
+ const $isBoundary = node => $isBlockLevel(node) && !$isListNode(node);
1935
+ if (!children.some($isBoundary)) {
1936
+ return children;
1937
+ }
1938
+ // Partition into segments — each maximal run of inline siblings, and each
1939
+ // boundary's own content — then join the segments with a single line break.
1940
+ const segments = [];
1941
+ let inlineRun = [];
1942
+ const flushInlineRun = () => {
1943
+ if (inlineRun.length > 0) {
1944
+ segments.push(inlineRun);
1945
+ inlineRun = [];
1946
+ }
1947
+ };
1948
+ for (const child of children) {
1949
+ if ($isBoundary(child)) {
1950
+ flushInlineRun();
1951
+ // Unwrap a block ElementNode to its inline content; a childless block
1952
+ // DecoratorNode stands on its own line.
1953
+ segments.push($isElementNode(child) ? child.getChildren() : [child]);
1954
+ } else {
1955
+ inlineRun.push(child);
1956
+ }
1957
+ }
1958
+ flushInlineRun();
1959
+ const out = [];
1960
+ for (const segment of segments) {
1961
+ if (out.length > 0) {
1962
+ out.push($createLineBreakNode());
1963
+ }
1964
+ out.push(...segment);
1965
+ }
1966
+ return out;
1967
+ }
1909
1968
  const ListItemRule = defineImportRule({
1910
1969
  $import: (ctx, el) => {
1911
1970
  const ariaChecked = el.getAttribute('aria-checked');
@@ -1913,7 +1972,11 @@ const ListItemRule = defineImportRule({
1913
1972
  const node = $createListItemNode(checked);
1914
1973
  $setFormatFromDOM(node, el);
1915
1974
  $setDirectionFromDOM(node, el);
1916
- return [node.splice(0, 0, $liftFormatFromSingleParagraph(node, ctx.$importChildren(el)))];
1975
+ return [node.splice(0, 0,
1976
+ // Lift a sole wrapping paragraph's format onto the item *before*
1977
+ // flattening, otherwise the paragraph would already be unwrapped and
1978
+ // its alignment lost.
1979
+ $flattenListItemBlocks($liftFormatFromSingleParagraph(node, ctx.$importChildren(el))))];
1917
1980
  },
1918
1981
  match: sel.tag('li'),
1919
1982
  name: '@lexical/list/li'
@@ -1927,7 +1990,7 @@ function $buildChecklistItem(ctx, el, checkboxOwner) {
1927
1990
  const node = $createListItemNode(checked);
1928
1991
  $setFormatFromDOM(node, el);
1929
1992
  $setDirectionFromDOM(node, el);
1930
- return [node.splice(0, 0, $liftFormatFromSingleParagraph(node, ctx.$importChildren(el)))];
1993
+ return [node.splice(0, 0, $flattenListItemBlocks($liftFormatFromSingleParagraph(node, ctx.$importChildren(el))))];
1931
1994
  }
1932
1995
  const TaskListItemRule = defineImportRule({
1933
1996
  $import: (ctx, el, $next) => {
@@ -1988,13 +2051,16 @@ const ListImportRules = [
1988
2051
  TaskListItemRule, JoplinChecklistItemRule, ListRule, ListItemRule];
1989
2052
 
1990
2053
  /**
1991
- * Bundles {@link ListImportRules} (plus {@link CoreImportExtension}) into
1992
- * a single dependency.
2054
+ * Bundles {@link ListImportRules} together with the runtime
2055
+ * {@link ListExtension}. The application is expected to already have
2056
+ * `CoreImportExtension` (or some equivalent) in its dependency graph —
2057
+ * the core/text/paragraph/inline-format rules are a shared baseline,
2058
+ * not something this leaf importer should re-declare.
1993
2059
  *
1994
2060
  * @experimental
1995
2061
  */
1996
2062
  const ListImportExtension = defineExtension({
1997
- dependencies: [CoreImportExtension, ListExtension, configExtension(DOMImportExtension, {
2063
+ dependencies: [ListExtension, configExtension(DOMImportExtension, {
1998
2064
  rules: ListImportRules
1999
2065
  })],
2000
2066
  name: '@lexical/list/Import'
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- "use strict";var e=require("@lexical/utils"),t=require("lexical"),n=require("@lexical/extension"),r=require("@lexical/html");function i(e,...t){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",e);for(const e of t)r.append("v",e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function s(e){let t=1,n=e.getParent();for(;null!=n;){if(O(n)){const e=n.getParent();if(M(e)){t++,n=e.getParent();continue}i(40)}return t}return t}function o(e){let t=e.getParent();M(t)||i(40);let n=t;for(;null!==n;)n=n.getParent(),M(n)&&(t=n);return t}function l(e){let t=[];const n=e.getChildren().filter(O);for(let e=0;e<n.length;e++){const r=n[e],i=r.getFirstChild();M(i)?t=t.concat(l(i)):t.push(r)}return t}function c(e){return O(e)&&M(e.getFirstChild())}function a(e,t){return O(e)&&(0===t.length||1===t.length&&e.is(t[0])&&0===e.getChildrenSize())}function d(e){const n=t.$getSelection();if(null!==n){let r=n.getNodes();if(t.$isRangeSelection(n)){const[i]=n.getStartEndPoints(),s=i.getNode(),o=s.getParent();if(t.$isRootOrShadowRoot(s)){const e=s.getFirstChild();if(e)r=e.selectStart().getNodes();else{const e=t.$createParagraphNode();s.append(e),r=e.select().getNodes()}}else if(a(s,r)){const n=k(e);if(t.$isRootOrShadowRoot(o)){s.replace(n);const e=x();t.$isElementNode(s)&&(e.setFormat(s.getFormatType()),e.setIndent(s.getIndent())),n.append(e)}else if(O(s)){const e=s.getParentOrThrow();g(n,e.getChildren()),e.replace(n)}return}}const i=new Set;for(let n=0;n<r.length;n++){const s=r[n];if(t.$isElementNode(s)&&s.isEmpty()&&!O(s)&&!i.has(s.getKey())){u(s,e);continue}let o=t.$isLeafNode(s)?s.getParent():O(s)&&s.isEmpty()?s:null;for(;null!=o;){const n=o.getKey();if(M(o)){if(!i.has(n)){const t=k(e);g(t,o.getChildren()),o.replace(t),i.add(n)}break}{const r=o.getParent();if(t.$isRootOrShadowRoot(r)&&!i.has(n)){i.add(n),u(o,e);break}o=r}}}}}function g(e,t){e.splice(e.getChildrenSize(),0,t)}function u(e,n){if(M(e))return e;const r=e.getPreviousSibling(),i=e.getNextSibling(),s=x();let o;if(g(s,e.getChildren()),M(r)&&n===r.getListType())r.append(s),M(i)&&n===i.getListType()&&(g(r,i.getChildren()),i.remove()),o=r;else if(M(i)&&n===i.getListType())i.getFirstChildOrThrow().insertBefore(s),o=i;else{const t=k(n);t.append(s),e.replace(t),o=t}s.setFormat(e.getFormatType()),s.setIndent(e.getIndent());const l=t.$getSelection();return t.$isRangeSelection(l)&&(o.getKey()===l.anchor.key&&l.anchor.set(s.getKey(),l.anchor.offset,"element"),o.getKey()===l.focus.key&&l.focus.set(s.getKey(),l.focus.offset,"element")),e.remove(),o}function h(e,t){const n=e.getLastChild(),r=t.getFirstChild();n&&r&&c(n)&&c(r)&&(h(n.getFirstChild(),r.getFirstChild()),r.remove());const i=t.getChildren();i.length>0&&e.append(...i),t.remove()}function p(){const n=t.$getSelection();if(t.$isRangeSelection(n)){const r=new Set,i=n.getNodes(),s=n.anchor.getNode();if(a(s,i))r.add(o(s));else for(let n=0;n<i.length;n++){const s=i[n];if(t.$isLeafNode(s)){const t=e.$getNearestNodeOfType(s,N);null!=t&&r.add(o(t))}}for(const e of r){let r=e;const i=l(e);for(const e of i){const i=t.$createParagraphNode().setTextStyle(n.style).setTextFormat(n.format);g(i,e.getChildren()),r.insertAfter(i),r=i,e.__key===n.anchor.key&&t.$setPointFromCaret(n.anchor,t.$normalizeCaret(t.$getChildCaret(i,"next"))),e.__key===n.focus.key&&t.$setPointFromCaret(n.focus,t.$normalizeCaret(t.$getChildCaret(i,"next"))),e.remove()}e.remove()}}}function f(e){const t="check"!==e.getListType();let n=e.getStart();for(const r of e.getChildren())O(r)&&(r.getValue()!==n&&r.setValue(n),t&&null!=r.getLatest().__checked&&r.setChecked(void 0),M(r.getFirstChild())||n++)}function m(e){const n=new Set;if(c(e)||n.has(e.getKey()))return;const r=e.getParent(),i=e.getNextSibling(),s=e.getPreviousSibling();if(c(i)&&c(s)){const t=s.getFirstChild();if(M(t)){t.append(e);const r=i.getFirstChild();if(M(r)){g(t,r.getChildren()),i.remove(),n.add(i.getKey())}}}else if(c(i)){const t=i.getFirstChild();if(M(t)){const n=t.getFirstChild();null!==n&&n.insertBefore(e)}}else if(c(s)){const t=s.getFirstChild();M(t)&&t.append(e)}else if(M(r)){const n=t.$copyNode(e),o=t.$copyNode(r);n.append(o),o.append(e),s?s.insertAfter(n):i?i.insertBefore(n):r.append(n)}}function _(e){if(c(e))return;const n=e.getParent(),r=n?n.getParent():void 0;if(M(r?r.getParent():void 0)&&O(r)&&M(n)){const i=n?n.getFirstChild():void 0,s=n?n.getLastChild():void 0;if(e.is(i))r.insertBefore(e),n.isEmpty()&&r.remove();else if(e.is(s))r.insertAfter(e),n.isEmpty()&&r.remove();else{const i=t.$copyNode(e),s=t.$copyNode(n);i.append(s),e.getPreviousSiblings().forEach(e=>s.append(e));const o=t.$copyNode(e),l=t.$copyNode(n);o.append(l),g(l,e.getNextSiblings()),r.insertBefore(i),r.insertAfter(o),r.replace(e)}}}function C(e=!1){const n=t.$getSelection();if(!t.$isRangeSelection(n)||!n.isCollapsed())return!1;const r=n.anchor.getNode();let s=null;if(O(r)&&0===r.getChildrenSize())s=r;else if(t.$isTextNode(r)){const e=r.getParent();O(e)&&e.getChildren().every(e=>t.$isTextNode(e)&&""===e.getTextContent().trim())&&(s=e)}if(null===s)return!1;const l=o(s),c=s.getParent();M(c)||i(40);const a=c.getParent();let d;if(t.$isRootOrShadowRoot(a))d=t.$createParagraphNode(),l.insertAfter(d);else{if(!O(a))return!1;d=t.$copyNode(a),a.insertAfter(d)}d.setTextStyle(n.style).setTextFormat(n.format).select();const g=s.getNextSiblings();if(g.length>0){const n=e?function(e,t){return e.getStart()+t.getIndexWithinParent()}(c,s):1,r=t.$copyNode(c).setStart(n);if(O(d)){const e=t.$copyNode(d);e.append(r),d.insertAfter(e)}else d.insertAfter(r);r.append(...g)}return function(e){let t=e;for(;null==t.getNextSibling()&&null==t.getPreviousSibling();){const e=t.getParent();if(null==e||!O(e)&&!M(e))break;t=e}t.remove()}(s),!0}class N extends t.ElementNode{__value;__checked;$config(){return this.config("listitem",{$transform:n=>{const r=n.getParent();if(M(r))"check"!==r.getListType()&&null!=n.getChecked()&&n.setChecked(void 0);else if(r){const s=n.createParentElementNode();M(s)||i(340);const o=[n];for(const e of["previous","next"]){o.reverse();for(const{origin:r}of t.$getSiblingCaret(n,e)){if(!O(r))break;o.push(r)}}n.insertBefore(s),s.splice(0,0,o),t.$isRootOrShadowRoot(r)||(e.$insertNodeToNearestRootAtCaret(s,t.$rewindSiblingCaret(t.$getSiblingCaret(s,"next")),{$shouldSplit:()=>!1,removeEmptyDestination:!0}),r.isEmpty()&&r.isAttached()&&r.remove())}},extends:t.ElementNode,importDOM:t.buildImportMap({li:()=>({conversion:y,priority:0})})})}constructor(e=1,t=void 0,n){super(n),this.__value=void 0===e?1:e,this.__checked=t}afterCloneFrom(e){super.afterCloneFrom(e),this.__value=e.__value,this.__checked=e.__checked}createDOM(e){const t=document.createElement("li");return this.updateListItemDOM(null,t,e),t}updateListItemDOM(n,r,i){!function(e,t){const n=t.getParent();!M(n)||"check"!==n.getListType()||M(t.getFirstChild())?(e.removeAttribute("role"),e.removeAttribute("tabIndex"),e.removeAttribute("aria-checked")):(e.setAttribute("role","checkbox"),e.setAttribute("tabIndex","-1"),e.setAttribute("aria-checked",t.getChecked()?"true":"false"))}(r,this),r.value=this.__value,function(n,r,i){const s=r.list;if(!s)return;const o=s.listitem,l=s.nested&&s.nested.listitem,c=i.getParent(),a=M(c)&&"check"===c.getListType(),d=i.getChecked(),g=i.getChildren().some(e=>M(e)),u=[];void 0!==s.listitemChecked&&u.push(s.listitemChecked);void 0!==s.listitemUnchecked&&u.push(s.listitemUnchecked);void 0!==l&&u.push(...t.normalizeClassNames(l));u.length>0&&e.removeClassNamesFromElement(n,...u);const h=[];void 0!==o&&h.push(...t.normalizeClassNames(o));if(a){const e=d?s.listitemChecked:s.listitemUnchecked;void 0!==e&&h.push(e)}void 0!==l&&g&&h.push(...t.normalizeClassNames(l));h.length>0&&e.addClassNamesToElement(n,...h)}(r,i.theme,this);const s=n?n.__style:"",o=this.__style;s!==o&&t.setDOMStyleFromCSS(r.style,o,s),function(e,n,r){const i=n.__textStyle,s=r?r.__textStyle:"";if(null!==r&&s===i)return;const o=t.getStyleObjectFromCSS(i);for(const t in o)e.style.setProperty(`--listitem-marker-${t}`,o[t]);if(""!==s)for(const n in t.getStyleObjectFromCSS(s))n in o||e.style.removeProperty(`--listitem-marker-${n}`)}(r,this,n)}updateDOM(e,t,n){const r=t;return this.updateListItemDOM(e,r,n),!1}updateFromJSON(e){return super.updateFromJSON(e).setValue(e.value).setChecked(e.checked)}exportDOM(e){const n=this.createDOM(e._config),r=this.getFormatType();r&&(n.style.textAlign=r);const i=this.getDirection();return i&&(n.dir=i),c(this)?{after(e){if(t.isHTMLElement(e)){const n=e.previousElementSibling;if(t.isHTMLElement(n)&&"LI"===n.nodeName){for(;e.firstChild;)n.append(e.firstChild);e.remove()}}return e},element:n}:{element:n}}exportJSON(){return{...super.exportJSON(),checked:this.getChecked(),value:this.getValue()}}append(...e){for(let n=0;n<e.length;n++){const r=e[n];if(t.$isElementNode(r)&&this.canMergeWith(r)){const e=r.getChildren();this.append(...e),r.remove()}else super.append(r)}return this}replace(e,n){if(O(e))return super.replace(e);this.setIndent(0);const r=this.getParentOrThrow();if(!M(r))return e;if(r.__first===this.getKey())r.insertBefore(e);else if(r.__last===this.getKey())r.insertAfter(e);else{const n=t.$copyNode(r);let i=this.getNextSibling();for(;i;){const e=i;i=i.getNextSibling(),n.append(e)}r.insertAfter(e),e.insertAfter(n)}const s=this.__key;let o=0;if(n&&(t.$isElementNode(e)||i(139),o=e.getChildrenSize(),e.splice(o,0,this.getChildren())),n&&t.$isElementNode(e)){const n=t.$getSelection();if(t.$isRangeSelection(n))for(const t of n.getStartEndPoints())t.key===s&&"element"===t.type&&t.set(e.getKey(),o+t.offset,"element")}return this.remove(),0===r.getChildrenSize()&&r.remove(),e}insertAfter(e,n=!0){const r=this.getParentOrThrow();if(M(r)||i(39),O(e))return super.insertAfter(e,n);const s=this.getNextSiblings();if(r.insertAfter(e,n),0!==s.length){const i=t.$copyNode(r);s.forEach(e=>i.append(e)),e.insertAfter(i,n)}return e}remove(e){const t=this.getPreviousSibling(),n=this.getNextSibling();super.remove(e),t&&n&&c(t)&&c(n)&&(h(t.getFirstChild(),n.getFirstChild()),n.remove())}resetOnCopyNodeFrom(e){super.resetOnCopyNodeFrom(e),e.getChecked()&&this.setChecked(!1)}insertNewAfter(e,n=!0){const r=t.$copyNode(this);return this.insertAfter(r,n),r}collapseAtStart(e){const n=t.$createParagraphNode();this.getChildren().forEach(e=>n.append(e));const r=this.getParentOrThrow(),i=r.getParentOrThrow(),s=O(i);if(1===r.getChildrenSize())if(s)r.remove(),i.select();else{r.insertBefore(n),r.remove();const t=e.anchor,i=e.focus,s=n.getKey();"element"===t.type&&t.getNode().is(this)&&t.set(s,t.offset,"element"),"element"===i.type&&i.getNode().is(this)&&i.set(s,i.offset,"element")}else r.insertBefore(n),this.remove();return!0}getValue(){return this.getLatest().__value}setValue(e){const t=this.getWritable();return t.__value=e,t}getChecked(){const e=this.getLatest();let t;const n=this.getParent();return M(n)&&(t=n.getListType()),"check"===t?Boolean(e.__checked):void 0}setChecked(e){const t=this.getWritable();return t.__checked=e,t}toggleChecked(){const e=this.getWritable();return e.setChecked(!e.__checked)}getIndent(){const e=this.getParent();if(null===e||!this.isAttached())return this.getLatest().__indent;let t=e.getParentOrThrow(),n=0;for(;O(t);)t=t.getParentOrThrow().getParentOrThrow(),n++;return n}setIndent(e){"number"!=typeof e&&i(117),(e=Math.floor(e))>=0||i(199);let t=this.getIndent();for(;t!==e;)t<e?(m(this),t++):(_(this),t--);return this}canInsertAfter(e){return O(e)}canReplaceWith(e){return O(e)}canMergeWith(e){return O(e)||t.$isParagraphNode(e)}extractWithChild(e,n){if(!t.$isRangeSelection(n))return!1;const r=n.anchor.getNode(),i=n.focus.getNode();return this.isParentOf(r)&&this.isParentOf(i)&&this.getTextContent().length===n.getTextContent().length}isParentRequired(){return!0}createParentElementNode(){return k("bullet")}canMergeWhenEmpty(){return!0}}function y(e){if(e.classList.contains("task-list-item"))for(const t of e.children)if("INPUT"===t.tagName)return T(t);if(e.classList.contains("joplin-checkbox"))for(const t of e.children)if(t.classList.contains("checkbox-wrapper")&&t.children.length>0&&"INPUT"===t.children[0].tagName)return T(t.children[0]);const n=e.getAttribute("aria-checked"),r=x("true"===n||"false"!==n&&void 0);return t.$setFormatFromDOM(r,e),{after:S.bind(null,r),node:t.$setDirectionFromDOM(r,e)}}function T(e){if(!("checkbox"===e.getAttribute("type")))return{node:null};const t=x(e.hasAttribute("checked"));return{after:S.bind(null,t),node:t}}function S(e,n){const r=n[0];return 1===n.length&&t.$isParagraphNode(r)&&!e.getFormatType()&&r.getFormatType()?(e.setFormat(r.getFormatType()),r.getChildren()):n}function x(e){return t.$applyNodeReplacement(new N(void 0,e))}function O(e){return e instanceof N}class L extends t.ElementNode{__tag;__start;__listType;$config(){return this.config("list",{$transform:e=>{!function(e){const t=e.getNextSibling();M(t)&&e.getListType()===t.getListType()&&h(e,t)}(e),f(e)},extends:t.ElementNode,importDOM:t.buildImportMap({ol:()=>({conversion:E,priority:0}),ul:()=>({conversion:E,priority:0})})})}constructor(e="number",t=1,n){super(n);const r=$[e]||e;this.__listType=r,this.__tag="number"===r?"ol":"ul",this.__start=t}afterCloneFrom(e){super.afterCloneFrom(e),this.__listType=e.__listType,this.__tag=e.__tag,this.__start=e.__start}getTag(){return this.getLatest().__tag}setListType(e){const t=this.getWritable();return t.__listType=e,t.__tag="number"===e?"ol":"ul",t}getListType(){return this.getLatest().__listType}getStart(){return this.getLatest().__start}setStart(e){const t=this.getWritable();return t.__start=e,t}createDOM(e,t){const n=this.__tag,r=document.createElement(n);return 1!==this.__start&&r.setAttribute("start",String(this.__start)),r.__lexicalListType=this.__listType,v(r,e.theme,this),r}updateDOM(e,t,n){return e.__tag!==this.__tag||e.__listType!==this.__listType||(v(t,n.theme,this),e.__start!==this.__start&&t.setAttribute("start",String(this.__start)),!1)}updateFromJSON(e){return super.updateFromJSON(e).setListType(e.listType).setStart(e.start)}exportDOM(t){const n=this.createDOM(t._config,t);return e.isHTMLElement(n)&&(1!==this.__start&&n.setAttribute("start",String(this.__start)),"check"===this.__listType&&n.setAttribute("__lexicalListType","check")),{element:n}}exportJSON(){return{...super.exportJSON(),listType:this.getListType(),start:this.getStart(),tag:this.getTag()}}canBeEmpty(){return!1}canIndent(){return!1}splice(e,n,r){let i=r;for(let e=0;e<r.length;e++){const n=r[e];O(n)||(i===r&&(i=[...r]),i[e]=this.createListItemNode().append(!t.$isElementNode(n)||M(n)||n.isInline()?n:t.$createTextNode(n.getTextContent())))}return super.splice(e,n,i)}extractWithChild(e){return O(e)}createListItemNode(){return x()}}function v(n,r,i){const o=[],l=[],c=r.list;if(void 0!==c){const e=c[`${i.__tag}Depth`]||[],n=s(i)-1,r=n%e.length,a=e[r],d=c[i.__tag];let g;const u=c.nested,h=c.checklist;if(void 0!==u&&u.list&&(g=u.list),void 0!==d&&o.push(d),void 0!==h&&"check"===i.__listType&&o.push(h),void 0!==a){o.push(...t.normalizeClassNames(a));for(let t=0;t<e.length;t++)t!==r&&l.push(i.__tag+t)}if(void 0!==g){const e=t.normalizeClassNames(g);n>1?o.push(...e):l.push(...e)}}l.length>0&&e.removeClassNamesFromElement(n,...l),o.length>0&&e.addClassNamesToElement(n,...o)}function E(n){let r;if(function(t){return e.isHTMLElement(t)&&"ol"===t.nodeName.toLowerCase()}(n)){const e=n.start;r=k("number",e)}else r=function(t){if("check"===t.getAttribute("__lexicallisttype")||t.classList.contains("contains-task-list")||"1"===t.getAttribute("data-is-checklist"))return!0;for(const n of t.childNodes)if(e.isHTMLElement(n)&&n.hasAttribute("aria-checked"))return!0;return!1}(n)?k("check"):k("bullet");return t.$setDirectionFromDOM(r,n),{after:e=>function(e,t){const n=t.createListItemNode.bind(t),r=[];for(let t=0;t<e.length;t++){const i=e[t];if(O(i)){r.push(i);const e=i.getChildren();e.length>1&&e.forEach(e=>{M(e)&&r.push(n().append(e))})}else r.push(n().append(i))}return r}(e,r),node:r}}const $={ol:"number",ul:"bullet"};function k(e="number",n=1){return t.$applyNodeReplacement(new L(e,n))}function M(e){return e instanceof L}const b=t.createCommand("INSERT_CHECK_LIST_COMMAND");function P(n,r){const i=r&&r.disableTakeFocusOnClick||!1,s="boolean"==typeof i?()=>i:i.peek.bind(i),o=t=>{const n=t.target;if(!e.isHTMLElement(n))return!1;const r=n.__lexicalCheckListLastHandled;return void 0!==r&&t.timeStamp-r<500},l=t=>{const n=t.target;e.isHTMLElement(n)&&(n.__lexicalCheckListLastHandled=t.timeStamp)},c=e=>{o(e)||(l(e),F(e,s()))},a=e=>{"touch"===e.pointerType&&(o(e)||(l(e),F(e,s())))},g=e=>{!function(e,t){I(e,()=>{e.preventDefault(),t&&e.stopPropagation()})}(e,s())};return e.mergeRegister(n.registerCommand(b,()=>(d("check"),!0),t.COMMAND_PRIORITY_LOW),n.registerCommand(t.KEY_ARROW_DOWN_COMMAND,e=>A(e,n,!1),t.COMMAND_PRIORITY_LOW),n.registerCommand(t.KEY_ARROW_UP_COMMAND,e=>A(e,n,!0),t.COMMAND_PRIORITY_LOW),n.registerCommand(t.KEY_ESCAPE_COMMAND,()=>{if(null!=R()){const e=n.getRootElement();return null!=e&&e.focus(),!0}return!1},t.COMMAND_PRIORITY_LOW),n.registerCommand(t.KEY_SPACE_COMMAND,e=>{const r=R();return!(null==r||!n.isEditable())&&(n.update(()=>{const n=t.$getNearestNodeFromDOMNode(r);O(n)&&(e.preventDefault(),n.toggleChecked())}),!0)},t.COMMAND_PRIORITY_LOW),n.registerCommand(t.KEY_ARROW_LEFT_COMMAND,r=>n.getEditorState().read(()=>{const i=t.$getSelection();if(t.$isRangeSelection(i)&&i.isCollapsed()){const{anchor:s}=i,o="element"===s.type;if(o||0===s.offset){const i=s.getNode(),l=e.$findMatchingParent(i,e=>t.$isElementNode(e)&&!e.isInline());if(O(l)){const e=l.getParent();if(M(e)&&"check"===e.getListType()&&(o||l.getFirstDescendant()===i)){const e=n.getElementByKey(l.__key);if(null!=e&&document.activeElement!==e)return e.focus(),r.preventDefault(),!0}}}}return!1}),t.COMMAND_PRIORITY_LOW),n.registerRootListener(e=>{if(null!==e)return e.addEventListener("click",c),e.addEventListener("pointerup",a),e.addEventListener("pointerdown",g,{capture:!0}),e.addEventListener("mousedown",g,{capture:!0}),e.addEventListener("touchstart",g,{capture:!0,passive:!1}),()=>{e.removeEventListener("click",c),e.removeEventListener("pointerup",a),e.removeEventListener("pointerdown",g,{capture:!0}),e.removeEventListener("mousedown",g,{capture:!0}),e.removeEventListener("touchstart",g,{capture:!0})}}))}function I(t,n){const r=t.target;if(!e.isHTMLElement(r))return;const i=r.firstChild;if(e.isHTMLElement(i)&&("UL"===i.tagName||"OL"===i.tagName))return;const s=r.parentNode;if(!s||"check"!==s.__lexicalListType)return;let o=null,l=null;if("clientX"in t)o=t.clientX;else if("touches"in t){const e=t.touches;e.length>0&&(o=e[0].clientX,l="touch")}if(null==o)return;const c=r.getBoundingClientRect(),a=o/e.calculateZoomLevel(r),d=window.getComputedStyle?window.getComputedStyle(r,"::before"):{width:"0px"},g=parseFloat(d.width),u="touch"===l||"pointerType"in t&&"touch"===t.pointerType?32:0;("rtl"===r.dir?a<c.right+u&&a>c.right-g-u:a>c.left-u&&a<c.left+g+u)&&n()}function F(n,r){I(n,()=>{if(e.isHTMLElement(n.target)){const e=n.target,i=t.getNearestEditorFromDOMNode(e);null!=i&&i.isEditable()&&i.update(()=>{const n=t.$getNearestNodeFromDOMNode(e);O(n)&&(r?(t.$addUpdateTag(t.SKIP_SELECTION_FOCUS_TAG),t.$addUpdateTag(t.SKIP_DOM_SELECTION_TAG)):e.focus(),n.toggleChecked())})}})}function R(){const t=document.activeElement;return e.isHTMLElement(t)&&"LI"===t.tagName&&null!=t.parentNode&&"check"===t.parentNode.__lexicalListType?t:null}function A(e,n,r){const i=R();return null!=i&&n.update(()=>{const s=t.$getNearestNodeFromDOMNode(i);if(!O(s))return;const o=function(e,t){let n=t?e.getPreviousSibling():e.getNextSibling(),r=e;for(;null==n&&O(r);)r=r.getParentOrThrow().getParent(),null!=r&&(n=t?r.getPreviousSibling():r.getNextSibling());for(;O(n);){const e=t?n.getLastChild():n.getFirstChild();if(!M(e))return n;n=t?e.getLastChild():e.getFirstChild()}return null}(s,r);if(null!=o){o.selectStart();const t=n.getElementByKey(o.__key);null!=t&&(e.preventDefault(),setTimeout(()=>{t.focus()},0))}}),!1}const D=t.createCommand("UPDATE_LIST_START_COMMAND"),w=t.createCommand("INSERT_UNORDERED_LIST_COMMAND"),W=t.createCommand("INSERT_ORDERED_LIST_COMMAND"),K=t.createCommand("REMOVE_LIST_COMMAND");function H(n,r){return e.mergeRegister(n.registerCommand(W,()=>(d("number"),!0),t.COMMAND_PRIORITY_LOW),n.registerCommand(D,e=>{const{listNodeKey:n,newStart:r}=e,i=t.$getNodeByKey(n);return!!M(i)&&("number"===i.getListType()&&(i.setStart(r),f(i)),!0)},t.COMMAND_PRIORITY_LOW),n.registerCommand(w,()=>(d("bullet"),!0),t.COMMAND_PRIORITY_LOW),n.registerCommand(K,()=>(p(),!0),t.COMMAND_PRIORITY_LOW),n.registerCommand(t.INSERT_PARAGRAPH_COMMAND,()=>C(!!(r&&r.restoreNumbering)),t.COMMAND_PRIORITY_LOW),n.registerNodeTransform(N,e=>{const n=e.getFirstChild();if(n){if(t.$isTextNode(n)){const t=n.getStyle(),r=n.getFormat();e.getTextStyle()!==t&&e.setTextStyle(t),e.getTextFormat()!==r&&e.setTextFormat(r)}}else{const n=t.$getSelection();t.$isRangeSelection(n)&&(n.style!==e.getTextStyle()||n.format!==e.getTextFormat())&&n.isCollapsed()&&e.is(n.anchor.getNode())&&e.setTextStyle(n.style).setTextFormat(n.format)}}),n.registerNodeTransform(t.TextNode,e=>{const t=e.getParent();if(O(t)&&e.is(t.getFirstChild())){const n=e.getStyle(),r=e.getFormat();n===t.getTextStyle()&&r===t.getTextFormat()||t.setTextStyle(n).setTextFormat(r)}}))}function U(t){const n=t=>{const n=t.getParent();if(M(t.getFirstChild())||!M(n))return;const r=e.$findMatchingParent(t,e=>O(e)&&M(e.getParent())&&O(e.getPreviousSibling()));if(null===r&&t.getIndent()>0)t.setIndent(0);else if(O(r)){const e=r.getPreviousSibling();if(O(e)){const r=function(e){let t=e,n=t.getFirstChild();for(;M(n);){const e=n.getLastChild();if(!O(e))break;t=e,n=t.getFirstChild()}return t}(e),i=r.getParent();if(M(i)){const e=s(i);e+1<s(n)&&t.setIndent(e)}}}};return t.registerNodeTransform(L,e=>{const t=[e];for(;t.length>0;){const e=t.shift();if(M(e))for(const r of e.getChildren())if(O(r)){n(r);const e=r.getFirstChild();M(e)&&t.push(e)}}})}const Y=t.defineExtension({build:(e,t,r)=>n.namedSignals(t),config:t.safeCast({hasStrictIndent:!1,shouldPreserveNumbering:!1}),name:"@lexical/list/List",nodes:()=>[L,N],register(t,r,i){const s=i.getOutput();return e.mergeRegister(n.effect(()=>H(t,{restoreNumbering:s.shouldPreserveNumbering.value})),n.effect(()=>s.hasStrictIndent.value?U(t):void 0))}}),B=t.defineExtension({build:(e,t)=>n.namedSignals(t),config:t.safeCast({disableTakeFocusOnClick:!1}),dependencies:[Y],name:"@lexical/list/CheckList",register:(e,t,n)=>P(e,n.getOutput())});function z(e){const t=[];for(const n of e)if(O(n)){t.push(n);const e=n.getChildren();if(e.length>1)for(const n of e)M(n)&&t.push(x().append(n))}else t.push(x().append(n));return t}const q=r.defineImportRule({$import:(e,n)=>{let i;var s;return r.isElementOfTag(n,"ol")?i=k("number",n.start):i=(s=n).matches('[__lexicallisttype="check"], .contains-task-list, [data-is-checklist="1"]')||null!==s.querySelector(":scope > [aria-checked]")?k("check"):k("bullet"),t.$setDirectionFromDOM(i,n),[i.splice(0,0,z(e.$importChildren(n)))]},match:r.sel.tag("ol","ul"),name:"@lexical/list/list"});function J(e,n){if(1!==n.length)return n;const r=n[0];return t.$isParagraphNode(r)&&!e.getFormatType()&&r.getFormatType()?(e.setFormat(r.getFormatType()),r.getChildren()):n}const V=r.defineImportRule({$import:(e,n)=>{const r=n.getAttribute("aria-checked"),i=x("true"===r||"false"!==r&&void 0);return t.$setFormatFromDOM(i,n),t.$setDirectionFromDOM(i,n),[i.splice(0,0,J(i,e.$importChildren(n)))]},match:r.sel.tag("li"),name:"@lexical/list/li"});function j(e,n,i){const s=r.isElementOfTag(i,"input")?i:i.querySelector('input[type="checkbox"]');if(!s||"checkbox"!==s.getAttribute("type"))return[];const o=x(s.hasAttribute("checked"));return t.$setFormatFromDOM(o,n),t.$setDirectionFromDOM(o,n),[o.splice(0,0,J(o,e.$importChildren(n)))]}const G={$accepts:e=>O(e)||M(e),$packageRun:e=>[x().splice(0,0,e)],name:"ListSchema"},X=[r.defineImportRule({$import:(e,t,n)=>{const r=t.querySelector(':scope > input[type="checkbox"]');return r?j(e,t,r):n()},match:r.sel.tag("li").classAll("task-list-item"),name:"@lexical/list/li-task-list-item"}),r.defineImportRule({$import:(e,t,n)=>{const r=t.querySelector(":scope > .checkbox-wrapper");if(!r)return n();const i=r.querySelector(':scope > input[type="checkbox"]');return i?j(e,t,i):n()},match:r.sel.tag("li").classAll("joplin-checkbox"),name:"@lexical/list/li-joplin-checkbox"}),q,V],Z=t.defineExtension({dependencies:[r.CoreImportExtension,Y,t.configExtension(r.DOMImportExtension,{rules:X})],name:"@lexical/list/Import"});exports.$createListItemNode=x,exports.$createListNode=k,exports.$getListDepth=s,exports.$handleListInsertParagraph=C,exports.$insertList=d,exports.$isListItemNode=O,exports.$isListNode=M,exports.$removeList=p,exports.CheckListExtension=B,exports.INSERT_CHECK_LIST_COMMAND=b,exports.INSERT_ORDERED_LIST_COMMAND=W,exports.INSERT_UNORDERED_LIST_COMMAND=w,exports.ListExtension=Y,exports.ListImportExtension=Z,exports.ListImportRules=X,exports.ListItemNode=N,exports.ListNode=L,exports.ListSchema=G,exports.REMOVE_LIST_COMMAND=K,exports.UPDATE_LIST_START_COMMAND=D,exports.insertList=function(e,t){e.update(()=>d(t))},exports.registerCheckList=P,exports.registerList=H,exports.registerListStrictIndentTransform=U,exports.removeList=function(e){e.update(()=>p())};
9
+ "use strict";var e=require("@lexical/utils"),t=require("lexical"),n=require("@lexical/extension"),r=require("@lexical/html");function i(e,...t){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",e);for(const e of t)r.append("v",e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function s(e){let t=1,n=e.getParent();for(;null!=n;){if(x(n)){const e=n.getParent();if(M(e)){t++,n=e.getParent();continue}i(40)}return t}return t}function o(e){let t=e.getParent();M(t)||i(40);let n=t;for(;null!==n;)n=n.getParent(),M(n)&&(t=n);return t}function l(e){let t=[];const n=e.getChildren().filter(x);for(let e=0;e<n.length;e++){const r=n[e],i=r.getFirstChild();M(i)?t=t.concat(l(i)):t.push(r)}return t}function c(e){return x(e)&&M(e.getFirstChild())}function a(e,t){return x(e)&&(0===t.length||1===t.length&&e.is(t[0])&&0===e.getChildrenSize())}function d(e){const n=t.$getSelection();if(null!==n){let r=n.getNodes();if(t.$isRangeSelection(n)){const[i]=n.getStartEndPoints(),s=i.getNode(),o=s.getParent();if(t.$isRootOrShadowRoot(s)){const e=s.getFirstChild();if(e)r=e.selectStart().getNodes();else{const e=t.$createParagraphNode();s.append(e),r=e.select().getNodes()}}else if(a(s,r)){const n=k(e);if(t.$isRootOrShadowRoot(o)){s.replace(n);const e=L();t.$isElementNode(s)&&(e.setFormat(s.getFormatType()),e.setIndent(s.getIndent())),n.append(e)}else if(x(s)){const e=s.getParentOrThrow();u(n,e.getChildren()),e.replace(n)}return}}const i=new Set;for(let n=0;n<r.length;n++){const s=r[n];if(t.$isElementNode(s)&&s.isEmpty()&&!x(s)&&!i.has(s.getKey())){g(s,e);continue}let o=t.$isLeafNode(s)?s.getParent():x(s)&&s.isEmpty()?s:null;for(;null!=o;){const n=o.getKey();if(M(o)){if(!i.has(n)){const t=k(e);u(t,o.getChildren()),o.replace(t),i.add(n)}break}{const r=o.getParent();if(t.$isRootOrShadowRoot(r)&&!i.has(n)){i.add(n),g(o,e);break}o=r}}}}}function u(e,t){e.splice(e.getChildrenSize(),0,t)}function g(e,n){if(M(e))return e;const r=e.getPreviousSibling(),i=e.getNextSibling(),s=L();let o;if(u(s,e.getChildren()),M(r)&&n===r.getListType())r.append(s),M(i)&&n===i.getListType()&&(u(r,i.getChildren()),i.remove()),o=r;else if(M(i)&&n===i.getListType())i.getFirstChildOrThrow().insertBefore(s),o=i;else{const t=k(n);t.append(s),e.replace(t),o=t}s.setFormat(e.getFormatType()),s.setIndent(e.getIndent());const l=t.$getSelection();return t.$isRangeSelection(l)&&(o.getKey()===l.anchor.key&&l.anchor.set(s.getKey(),l.anchor.offset,"element"),o.getKey()===l.focus.key&&l.focus.set(s.getKey(),l.focus.offset,"element")),e.remove(),o}function h(e,t){const n=e.getLastChild(),r=t.getFirstChild();n&&r&&c(n)&&c(r)&&(h(n.getFirstChild(),r.getFirstChild()),r.remove());const i=t.getChildren();i.length>0&&e.append(...i),t.remove()}function p(){const n=t.$getSelection();if(t.$isRangeSelection(n)){const r=new Set,i=n.getNodes(),s=n.anchor.getNode();if(a(s,i))r.add(o(s));else for(let n=0;n<i.length;n++){const s=i[n];if(t.$isLeafNode(s)){const t=e.$getNearestNodeOfType(s,N);null!=t&&r.add(o(t))}}for(const e of r){let r=e;const i=l(e);for(const e of i){const i=t.$createParagraphNode().setTextStyle(n.style).setTextFormat(n.format);u(i,e.getChildren()),r.insertAfter(i),r=i,e.__key===n.anchor.key&&t.$setPointFromCaret(n.anchor,t.$normalizeCaret(t.$getChildCaret(i,"next"))),e.__key===n.focus.key&&t.$setPointFromCaret(n.focus,t.$normalizeCaret(t.$getChildCaret(i,"next"))),e.remove()}e.remove()}}}function f(e){const t="check"!==e.getListType();let n=e.getStart();for(const r of e.getChildren())x(r)&&(r.getValue()!==n&&r.setValue(n),t&&null!=r.getLatest().__checked&&r.setChecked(void 0),M(r.getFirstChild())||n++)}function m(e){const n=new Set;if(c(e)||n.has(e.getKey()))return;const r=e.getParent(),i=e.getNextSibling(),s=e.getPreviousSibling();if(c(i)&&c(s)){const t=s.getFirstChild();if(M(t)){t.append(e);const r=i.getFirstChild();if(M(r)){u(t,r.getChildren()),i.remove(),n.add(i.getKey())}}}else if(c(i)){const t=i.getFirstChild();if(M(t)){const n=t.getFirstChild();null!==n&&n.insertBefore(e)}}else if(c(s)){const t=s.getFirstChild();M(t)&&t.append(e)}else if(M(r)){const n=t.$copyNode(e),o=t.$copyNode(r);n.append(o),o.append(e),s?s.insertAfter(n):i?i.insertBefore(n):r.append(n)}}function _(e){if(c(e))return;const n=e.getParent(),r=n?n.getParent():void 0;if(M(r?r.getParent():void 0)&&x(r)&&M(n)){const i=n?n.getFirstChild():void 0,s=n?n.getLastChild():void 0;if(e.is(i))r.insertBefore(e),n.isEmpty()&&r.remove();else if(e.is(s))r.insertAfter(e),n.isEmpty()&&r.remove();else{const i=t.$copyNode(e),s=t.$copyNode(n);i.append(s),e.getPreviousSiblings().forEach(e=>s.append(e));const o=t.$copyNode(e),l=t.$copyNode(n);o.append(l),u(l,e.getNextSiblings()),r.insertBefore(i),r.insertAfter(o),r.replace(e)}}}function C(e=!1){const n=t.$getSelection();if(!t.$isRangeSelection(n)||!n.isCollapsed())return!1;const r=n.anchor.getNode();let s=null;if(x(r)&&0===r.getChildrenSize())s=r;else if(t.$isTextNode(r)){const e=r.getParent();x(e)&&e.getChildren().every(e=>t.$isTextNode(e)&&""===e.getTextContent().trim())&&(s=e)}if(null===s)return!1;const l=o(s),c=s.getParent();M(c)||i(40);const a=c.getParent();let d;if(t.$isRootOrShadowRoot(a))d=t.$createParagraphNode(),l.insertAfter(d);else{if(!x(a))return!1;d=t.$copyNode(a),a.insertAfter(d)}d.setTextStyle(n.style).setTextFormat(n.format).select();const u=s.getNextSiblings();if(u.length>0){const n=e?function(e,t){return e.getStart()+t.getIndexWithinParent()}(c,s):1,r=t.$copyNode(c).setStart(n);if(x(d)){const e=t.$copyNode(d);e.append(r),d.insertAfter(e)}else d.insertAfter(r);r.append(...u)}return function(e){let t=e;for(;null==t.getNextSibling()&&null==t.getPreviousSibling();){const e=t.getParent();if(null==e||!x(e)&&!M(e))break;t=e}t.remove()}(s),!0}class N extends t.ElementNode{__value;__checked;$config(){return this.config("listitem",{$transform:n=>{const r=n.getParent();if(M(r))"check"!==r.getListType()&&null!=n.getChecked()&&n.setChecked(void 0);else if(r){const s=n.createParentElementNode();M(s)||i(340);const o=[n];for(const e of["previous","next"]){o.reverse();for(const{origin:r}of t.$getSiblingCaret(n,e)){if(!x(r))break;o.push(r)}}n.insertBefore(s),s.splice(0,0,o),t.$isRootOrShadowRoot(r)||(e.$insertNodeToNearestRootAtCaret(s,t.$rewindSiblingCaret(t.$getSiblingCaret(s,"next")),{$shouldSplit:()=>!1,removeEmptyDestination:!0}),r.isEmpty()&&r.isAttached()&&r.remove())}},extends:t.ElementNode,importDOM:t.buildImportMap({li:()=>({conversion:T,priority:0})})})}constructor(e=1,t=void 0,n){super(n),this.__value=void 0===e?1:e,this.__checked=t}afterCloneFrom(e){super.afterCloneFrom(e),this.__value=e.__value,this.__checked=e.__checked}createDOM(e){const t=document.createElement("li");return this.updateListItemDOM(null,t,e),t}updateListItemDOM(n,r,i){!function(e,t){const n=t.getParent();!M(n)||"check"!==n.getListType()||M(t.getFirstChild())?(e.removeAttribute("role"),e.removeAttribute("tabIndex"),e.removeAttribute("aria-checked")):(e.setAttribute("role","checkbox"),e.setAttribute("tabIndex","-1"),e.setAttribute("aria-checked",t.getChecked()?"true":"false"))}(r,this),r.value=this.__value,function(n,r,i){const s=r.list;if(!s)return;const o=s.listitem,l=s.nested&&s.nested.listitem,c=i.getParent(),a=M(c)&&"check"===c.getListType(),d=i.getChecked(),u=i.getChildren().some(e=>M(e)),g=[];void 0!==s.listitemChecked&&g.push(s.listitemChecked);void 0!==s.listitemUnchecked&&g.push(s.listitemUnchecked);void 0!==l&&g.push(...t.normalizeClassNames(l));g.length>0&&e.removeClassNamesFromElement(n,...g);const h=[];void 0!==o&&h.push(...t.normalizeClassNames(o));if(a){const e=d?s.listitemChecked:s.listitemUnchecked;void 0!==e&&h.push(e)}void 0!==l&&u&&h.push(...t.normalizeClassNames(l));h.length>0&&e.addClassNamesToElement(n,...h)}(r,i.theme,this);const s=n?n.__style:"",o=this.__style;s!==o&&t.setDOMStyleFromCSS(r.style,o,s),function(e,n,r){const i=n.__textStyle,s=r?r.__textStyle:"";if(null!==r&&s===i)return;const o=t.getStyleObjectFromCSS(i);for(const t in o)e.style.setProperty(`--listitem-marker-${t}`,o[t]);if(""!==s)for(const n in t.getStyleObjectFromCSS(s))n in o||e.style.removeProperty(`--listitem-marker-${n}`)}(r,this,n)}updateDOM(e,t,n){const r=t;return this.updateListItemDOM(e,r,n),!1}updateFromJSON(e){return super.updateFromJSON(e).setValue(e.value).setChecked(e.checked)}exportDOM(e){const n=this.createDOM(e._config),r=this.getFormatType();r&&(n.style.textAlign=r);const i=this.getDirection();return i&&(n.dir=i),c(this)?{after(e){if(t.isHTMLElement(e)){const n=e.previousElementSibling;if(t.isHTMLElement(n)&&"LI"===n.nodeName){for(;e.firstChild;)n.append(e.firstChild);e.remove()}}return e},element:n}:{element:n}}exportJSON(){return{...super.exportJSON(),checked:this.getChecked(),value:this.getValue()}}append(...e){for(let n=0;n<e.length;n++){const r=e[n];if(t.$isElementNode(r)&&this.canMergeWith(r)){const e=r.getChildren();this.append(...e),r.remove()}else super.append(r)}return this}replace(e,n){if(x(e))return super.replace(e);this.setIndent(0);const r=this.getParentOrThrow();if(!M(r))return e;if(r.__first===this.getKey())r.insertBefore(e);else if(r.__last===this.getKey())r.insertAfter(e);else{const n=t.$copyNode(r);let i=this.getNextSibling();for(;i;){const e=i;i=i.getNextSibling(),n.append(e)}r.insertAfter(e),e.insertAfter(n)}const s=this.__key;let o=0;if(n&&(t.$isElementNode(e)||i(139),o=e.getChildrenSize(),e.splice(o,0,this.getChildren())),n&&t.$isElementNode(e)){const n=t.$getSelection();if(t.$isRangeSelection(n))for(const t of n.getStartEndPoints())t.key===s&&"element"===t.type&&t.set(e.getKey(),o+t.offset,"element")}return this.remove(),0===r.getChildrenSize()&&r.remove(),e}insertAfter(e,n=!0){const r=this.getParentOrThrow();if(M(r)||i(39),x(e))return super.insertAfter(e,n);const s=this.getNextSiblings();if(r.insertAfter(e,n),0!==s.length){const i=t.$copyNode(r);s.forEach(e=>i.append(e)),e.insertAfter(i,n)}return e}remove(e){const t=this.getPreviousSibling(),n=this.getNextSibling();super.remove(e),t&&n&&c(t)&&c(n)&&(h(t.getFirstChild(),n.getFirstChild()),n.remove())}resetOnCopyNodeFrom(e){super.resetOnCopyNodeFrom(e),e.getChecked()&&this.setChecked(!1)}insertNewAfter(e,n=!0){const r=t.$copyNode(this);return this.insertAfter(r,n),r}collapseAtStart(e){const n=t.$createParagraphNode();this.getChildren().forEach(e=>n.append(e));const r=this.getParentOrThrow(),i=r.getParentOrThrow(),s=x(i);if(1===r.getChildrenSize())if(s)r.remove(),i.select();else{r.insertBefore(n),r.remove();const t=e.anchor,i=e.focus,s=n.getKey();"element"===t.type&&t.getNode().is(this)&&t.set(s,t.offset,"element"),"element"===i.type&&i.getNode().is(this)&&i.set(s,i.offset,"element")}else r.insertBefore(n),this.remove();return!0}getValue(){return this.getLatest().__value}setValue(e){const t=this.getWritable();return t.__value=e,t}getChecked(){const e=this.getLatest();let t;const n=this.getParent();return M(n)&&(t=n.getListType()),"check"===t?Boolean(e.__checked):void 0}setChecked(e){const t=this.getWritable();return t.__checked=e,t}toggleChecked(){const e=this.getWritable();return e.setChecked(!e.__checked)}getIndent(){const e=this.getParent();if(null===e||!this.isAttached())return this.getLatest().__indent;let t=e.getParentOrThrow(),n=0;for(;x(t);)t=t.getParentOrThrow().getParentOrThrow(),n++;return n}setIndent(e){"number"!=typeof e&&i(117),(e=Math.floor(e))>=0||i(199);let t=this.getIndent();for(;t!==e;)t<e?(m(this),t++):(_(this),t--);return this}canInsertAfter(e){return x(e)}canReplaceWith(e){return x(e)}canMergeWith(e){return x(e)||t.$isParagraphNode(e)}extractWithChild(e,n){if(!t.$isRangeSelection(n))return!1;const r=n.anchor.getNode(),i=n.focus.getNode();return this.isParentOf(r)&&this.isParentOf(i)&&this.getTextContent().length===n.getTextContent().length}isParentRequired(){return!0}createParentElementNode(){return k("bullet")}canMergeWhenEmpty(){return!0}}function T(e){if(e.classList.contains("task-list-item"))for(const t of e.children)if("INPUT"===t.tagName)return y(t);if(e.classList.contains("joplin-checkbox"))for(const t of e.children)if(t.classList.contains("checkbox-wrapper")&&t.children.length>0&&"INPUT"===t.children[0].tagName)return y(t.children[0]);const n=e.getAttribute("aria-checked"),r=L("true"===n||"false"!==n&&void 0);return t.$setFormatFromDOM(r,e),{after:S.bind(null,r),node:t.$setDirectionFromDOM(r,e)}}function y(e){if(!("checkbox"===e.getAttribute("type")))return{node:null};const t=L(e.hasAttribute("checked"));return{after:S.bind(null,t),node:t}}function S(e,n){const r=n[0];return 1===n.length&&t.$isParagraphNode(r)&&!e.getFormatType()&&r.getFormatType()?(e.setFormat(r.getFormatType()),r.getChildren()):n}function L(e){return t.$applyNodeReplacement(new N(void 0,e))}function x(e){return e instanceof N}class O extends t.ElementNode{__tag;__start;__listType;$config(){return this.config("list",{$transform:e=>{!function(e){const t=e.getNextSibling();M(t)&&e.getListType()===t.getListType()&&h(e,t)}(e),f(e)},extends:t.ElementNode,importDOM:t.buildImportMap({ol:()=>({conversion:E,priority:0}),ul:()=>({conversion:E,priority:0})})})}constructor(e="number",t=1,n){super(n);const r=$[e]||e;this.__listType=r,this.__tag="number"===r?"ol":"ul",this.__start=t}afterCloneFrom(e){super.afterCloneFrom(e),this.__listType=e.__listType,this.__tag=e.__tag,this.__start=e.__start}getTag(){return this.getLatest().__tag}setListType(e){const t=this.getWritable();return t.__listType=e,t.__tag="number"===e?"ol":"ul",t}getListType(){return this.getLatest().__listType}getStart(){return this.getLatest().__start}setStart(e){const t=this.getWritable();return t.__start=e,t}createDOM(e,t){const n=this.__tag,r=document.createElement(n);return 1!==this.__start&&r.setAttribute("start",String(this.__start)),r.__lexicalListType=this.__listType,v(r,e.theme,this),r}updateDOM(e,t,n){return e.__tag!==this.__tag||e.__listType!==this.__listType||(v(t,n.theme,this),e.__start!==this.__start&&t.setAttribute("start",String(this.__start)),!1)}updateFromJSON(e){return super.updateFromJSON(e).setListType(e.listType).setStart(e.start)}exportDOM(t){const n=this.createDOM(t._config,t);return e.isHTMLElement(n)&&(1!==this.__start&&n.setAttribute("start",String(this.__start)),"check"===this.__listType&&n.setAttribute("__lexicalListType","check")),{element:n}}exportJSON(){return{...super.exportJSON(),listType:this.getListType(),start:this.getStart(),tag:this.getTag()}}canBeEmpty(){return!1}canIndent(){return!1}splice(e,n,r){let i=r;for(let e=0;e<r.length;e++){const n=r[e];x(n)||(i===r&&(i=[...r]),i[e]=this.createListItemNode().append(!t.$isElementNode(n)||M(n)||n.isInline()?n:t.$createTextNode(n.getTextContent())))}return super.splice(e,n,i)}extractWithChild(e){return x(e)}createListItemNode(){return L()}}function v(n,r,i){const o=[],l=[],c=r.list;if(void 0!==c){const e=c[`${i.__tag}Depth`]||[],n=s(i)-1,r=n%e.length,a=e[r],d=c[i.__tag];let u;const g=c.nested,h=c.checklist;if(void 0!==g&&g.list&&(u=g.list),void 0!==d&&o.push(d),void 0!==h&&"check"===i.__listType&&o.push(h),void 0!==a){o.push(...t.normalizeClassNames(a));for(let t=0;t<e.length;t++)t!==r&&l.push(i.__tag+t)}if(void 0!==u){const e=t.normalizeClassNames(u);n>1?o.push(...e):l.push(...e)}}l.length>0&&e.removeClassNamesFromElement(n,...l),o.length>0&&e.addClassNamesToElement(n,...o)}function E(n){let r;if(function(t){return e.isHTMLElement(t)&&"ol"===t.nodeName.toLowerCase()}(n)){const e=n.start;r=k("number",e)}else r=function(t){if("check"===t.getAttribute("__lexicallisttype")||t.classList.contains("contains-task-list")||"1"===t.getAttribute("data-is-checklist"))return!0;for(const n of t.childNodes)if(e.isHTMLElement(n)&&n.hasAttribute("aria-checked"))return!0;return!1}(n)?k("check"):k("bullet");return t.$setDirectionFromDOM(r,n),{after:e=>function(e,t){const n=t.createListItemNode.bind(t),r=[];for(let t=0;t<e.length;t++){const i=e[t];if(x(i)){r.push(i);const e=i.getChildren();e.length>1&&e.forEach(e=>{M(e)&&r.push(n().append(e))})}else r.push(n().append(i))}return r}(e,r),node:r}}const $={ol:"number",ul:"bullet"};function k(e="number",n=1){return t.$applyNodeReplacement(new O(e,n))}function M(e){return e instanceof O}const b=t.createCommand("INSERT_CHECK_LIST_COMMAND");function P(n,r){const i=r&&r.disableTakeFocusOnClick||!1,s="boolean"==typeof i?()=>i:i.peek.bind(i),o=t=>{const n=t.target;if(!e.isHTMLElement(n))return!1;const r=n.__lexicalCheckListLastHandled;return void 0!==r&&t.timeStamp-r<500},l=t=>{const n=t.target;e.isHTMLElement(n)&&(n.__lexicalCheckListLastHandled=t.timeStamp)},c=e=>{o(e)||(l(e),A(e,s()))},a=e=>{"touch"===e.pointerType&&(o(e)||(l(e),A(e,s())))},u=e=>{!function(e,t){I(e,()=>{e.preventDefault(),t&&e.stopPropagation()})}(e,s())};return e.mergeRegister(n.registerCommand(b,()=>(d("check"),!0),t.COMMAND_PRIORITY_LOW),n.registerCommand(t.KEY_ARROW_DOWN_COMMAND,e=>R(e,n,!1),t.COMMAND_PRIORITY_LOW),n.registerCommand(t.KEY_ARROW_UP_COMMAND,e=>R(e,n,!0),t.COMMAND_PRIORITY_LOW),n.registerCommand(t.KEY_ESCAPE_COMMAND,()=>{if(null!=F()){const e=n.getRootElement();return null!=e&&e.focus(),!0}return!1},t.COMMAND_PRIORITY_LOW),n.registerCommand(t.KEY_SPACE_COMMAND,e=>{const r=F();return!(null==r||!n.isEditable())&&(n.update(()=>{const n=t.$getNearestNodeFromDOMNode(r);x(n)&&(e.preventDefault(),n.toggleChecked())}),!0)},t.COMMAND_PRIORITY_LOW),n.registerCommand(t.KEY_ARROW_LEFT_COMMAND,r=>n.getEditorState().read(()=>{const i=t.$getSelection();if(t.$isRangeSelection(i)&&i.isCollapsed()){const{anchor:s}=i,o="element"===s.type;if(o||0===s.offset){const i=s.getNode(),l=e.$findMatchingParent(i,e=>t.$isElementNode(e)&&!e.isInline());if(x(l)){const e=l.getParent();if(M(e)&&"check"===e.getListType()&&(o||l.getFirstDescendant()===i)){const e=n.getElementByKey(l.__key);if(null!=e&&document.activeElement!==e)return e.focus(),r.preventDefault(),!0}}}}return!1}),t.COMMAND_PRIORITY_LOW),n.registerRootListener(e=>{if(null!==e)return e.addEventListener("click",c),e.addEventListener("pointerup",a),e.addEventListener("pointerdown",u,{capture:!0}),e.addEventListener("mousedown",u,{capture:!0}),e.addEventListener("touchstart",u,{capture:!0,passive:!1}),()=>{e.removeEventListener("click",c),e.removeEventListener("pointerup",a),e.removeEventListener("pointerdown",u,{capture:!0}),e.removeEventListener("mousedown",u,{capture:!0}),e.removeEventListener("touchstart",u,{capture:!0})}}))}function I(t,n){const r=t.target;if(!e.isHTMLElement(r))return;const i=r.firstChild;if(e.isHTMLElement(i)&&("UL"===i.tagName||"OL"===i.tagName))return;const s=r.parentNode;if(!s||"check"!==s.__lexicalListType)return;let o=null,l=null;if("clientX"in t)o=t.clientX;else if("touches"in t){const e=t.touches;e.length>0&&(o=e[0].clientX,l="touch")}if(null==o)return;const c=r.getBoundingClientRect(),a=o/e.calculateZoomLevel(r),d=window.getComputedStyle?window.getComputedStyle(r,"::before"):{width:"0px"},u=parseFloat(d.width),g="touch"===l||"pointerType"in t&&"touch"===t.pointerType?32:0;("rtl"===r.dir?a<c.right+g&&a>c.right-u-g:a>c.left-g&&a<c.left+u+g)&&n()}function A(n,r){I(n,()=>{if(e.isHTMLElement(n.target)){const e=n.target,i=t.getNearestEditorFromDOMNode(e);null!=i&&i.isEditable()&&i.update(()=>{const n=t.$getNearestNodeFromDOMNode(e);x(n)&&(r?(t.$addUpdateTag(t.SKIP_SELECTION_FOCUS_TAG),t.$addUpdateTag(t.SKIP_DOM_SELECTION_TAG)):e.focus(),n.toggleChecked())})}})}function F(){const t=document.activeElement;return e.isHTMLElement(t)&&"LI"===t.tagName&&null!=t.parentNode&&"check"===t.parentNode.__lexicalListType?t:null}function R(e,n,r){const i=F();return null!=i&&n.update(()=>{const s=t.$getNearestNodeFromDOMNode(i);if(!x(s))return;const o=function(e,t){let n=t?e.getPreviousSibling():e.getNextSibling(),r=e;for(;null==n&&x(r);)r=r.getParentOrThrow().getParent(),null!=r&&(n=t?r.getPreviousSibling():r.getNextSibling());for(;x(n);){const e=t?n.getLastChild():n.getFirstChild();if(!M(e))return n;n=t?e.getLastChild():e.getFirstChild()}return null}(s,r);if(null!=o){o.selectStart();const t=n.getElementByKey(o.__key);null!=t&&(e.preventDefault(),setTimeout(()=>{t.focus()},0))}}),!1}const D=t.createCommand("UPDATE_LIST_START_COMMAND"),w=t.createCommand("INSERT_UNORDERED_LIST_COMMAND"),W=t.createCommand("INSERT_ORDERED_LIST_COMMAND"),K=t.createCommand("REMOVE_LIST_COMMAND");function B(n,r){return e.mergeRegister(n.registerCommand(W,()=>(d("number"),!0),t.COMMAND_PRIORITY_LOW),n.registerCommand(D,e=>{const{listNodeKey:n,newStart:r}=e,i=t.$getNodeByKey(n);return!!M(i)&&("number"===i.getListType()&&(i.setStart(r),f(i)),!0)},t.COMMAND_PRIORITY_LOW),n.registerCommand(w,()=>(d("bullet"),!0),t.COMMAND_PRIORITY_LOW),n.registerCommand(K,()=>(p(),!0),t.COMMAND_PRIORITY_LOW),n.registerCommand(t.INSERT_PARAGRAPH_COMMAND,()=>C(!!(r&&r.restoreNumbering)),t.COMMAND_PRIORITY_LOW),n.registerNodeTransform(N,e=>{const n=e.getFirstChild();if(n){if(t.$isTextNode(n)){const t=n.getStyle(),r=n.getFormat();e.getTextStyle()!==t&&e.setTextStyle(t),e.getTextFormat()!==r&&e.setTextFormat(r)}}else{const n=t.$getSelection();t.$isRangeSelection(n)&&(n.style!==e.getTextStyle()||n.format!==e.getTextFormat())&&n.isCollapsed()&&e.is(n.anchor.getNode())&&e.setTextStyle(n.style).setTextFormat(n.format)}}),n.registerNodeTransform(t.TextNode,e=>{const t=e.getParent();if(x(t)&&e.is(t.getFirstChild())){const n=e.getStyle(),r=e.getFormat();n===t.getTextStyle()&&r===t.getTextFormat()||t.setTextStyle(n).setTextFormat(r)}}))}function H(t){const n=t=>{const n=t.getParent();if(M(t.getFirstChild())||!M(n))return;const r=e.$findMatchingParent(t,e=>x(e)&&M(e.getParent())&&x(e.getPreviousSibling()));if(null===r&&t.getIndent()>0)t.setIndent(0);else if(x(r)){const e=r.getPreviousSibling();if(x(e)){const r=function(e){let t=e,n=t.getFirstChild();for(;M(n);){const e=n.getLastChild();if(!x(e))break;t=e,n=t.getFirstChild()}return t}(e),i=r.getParent();if(M(i)){const e=s(i);e+1<s(n)&&t.setIndent(e)}}}};return t.registerNodeTransform(O,e=>{const t=[e];for(;t.length>0;){const e=t.shift();if(M(e))for(const r of e.getChildren())if(x(r)){n(r);const e=r.getFirstChild();M(e)&&t.push(e)}}})}const U=t.defineExtension({build:(e,t,r)=>n.namedSignals(t),config:t.safeCast({hasStrictIndent:!1,shouldPreserveNumbering:!1}),name:"@lexical/list/List",nodes:()=>[O,N],register(t,r,i){const s=i.getOutput();return e.mergeRegister(n.effect(()=>B(t,{restoreNumbering:s.shouldPreserveNumbering.value})),n.effect(()=>s.hasStrictIndent.value?H(t):void 0))}}),Y=t.defineExtension({build:(e,t)=>n.namedSignals(t),config:t.safeCast({disableTakeFocusOnClick:!1}),dependencies:[U],name:"@lexical/list/CheckList",register:(e,t,n)=>P(e,n.getOutput())});function z(e){const t=[];for(const n of e)if(x(n)){t.push(n);const e=n.getChildren();if(e.length>1)for(const n of e)M(n)&&t.push(L().append(n))}else t.push(L().append(n));return t}const q=r.defineImportRule({$import:(e,n)=>{let i;var s;return r.isElementOfTag(n,"ol")?i=k("number",n.start):i=(s=n).matches('[__lexicallisttype="check"], .contains-task-list, [data-is-checklist="1"]')||null!==s.querySelector(":scope > [aria-checked]")?k("check"):k("bullet"),t.$setDirectionFromDOM(i,n),[i.splice(0,0,r.$propagateTextAlignToBlockChildren(z(e.$importChildren(n)),n))]},match:r.sel.tag("ol","ul"),name:"@lexical/list/list"});function J(e,n){if(1!==n.length)return n;const r=n[0];return t.$isParagraphNode(r)&&!e.getFormatType()&&r.getFormatType()?(e.setFormat(r.getFormatType()),r.getChildren()):n}function V(e){const n=e=>r.$isBlockLevel(e)&&!M(e);if(!e.some(n))return e;const i=[];let s=[];const o=()=>{s.length>0&&(i.push(s),s=[])};for(const r of e)n(r)?(o(),i.push(t.$isElementNode(r)?r.getChildren():[r])):s.push(r);o();const l=[];for(const e of i)l.length>0&&l.push(t.$createLineBreakNode()),l.push(...e);return l}const j=r.defineImportRule({$import:(e,n)=>{const r=n.getAttribute("aria-checked"),i=L("true"===r||"false"!==r&&void 0);return t.$setFormatFromDOM(i,n),t.$setDirectionFromDOM(i,n),[i.splice(0,0,V(J(i,e.$importChildren(n))))]},match:r.sel.tag("li"),name:"@lexical/list/li"});function G(e,n,i){const s=r.isElementOfTag(i,"input")?i:i.querySelector('input[type="checkbox"]');if(!s||"checkbox"!==s.getAttribute("type"))return[];const o=L(s.hasAttribute("checked"));return t.$setFormatFromDOM(o,n),t.$setDirectionFromDOM(o,n),[o.splice(0,0,V(J(o,e.$importChildren(n))))]}const X={$accepts:e=>x(e)||M(e),$packageRun:e=>[L().splice(0,0,e)],name:"ListSchema"},Z=[r.defineImportRule({$import:(e,t,n)=>{const r=t.querySelector(':scope > input[type="checkbox"]');return r?G(e,t,r):n()},match:r.sel.tag("li").classAll("task-list-item"),name:"@lexical/list/li-task-list-item"}),r.defineImportRule({$import:(e,t,n)=>{const r=t.querySelector(":scope > .checkbox-wrapper");if(!r)return n();const i=r.querySelector(':scope > input[type="checkbox"]');return i?G(e,t,i):n()},match:r.sel.tag("li").classAll("joplin-checkbox"),name:"@lexical/list/li-joplin-checkbox"}),q,j],Q=t.defineExtension({dependencies:[U,t.configExtension(r.DOMImportExtension,{rules:Z})],name:"@lexical/list/Import"});exports.$createListItemNode=L,exports.$createListNode=k,exports.$getListDepth=s,exports.$handleListInsertParagraph=C,exports.$insertList=d,exports.$isListItemNode=x,exports.$isListNode=M,exports.$removeList=p,exports.CheckListExtension=Y,exports.INSERT_CHECK_LIST_COMMAND=b,exports.INSERT_ORDERED_LIST_COMMAND=W,exports.INSERT_UNORDERED_LIST_COMMAND=w,exports.ListExtension=U,exports.ListImportExtension=Q,exports.ListImportRules=Z,exports.ListItemNode=N,exports.ListNode=O,exports.ListSchema=X,exports.REMOVE_LIST_COMMAND=K,exports.UPDATE_LIST_START_COMMAND=D,exports.insertList=function(e,t){e.update(()=>d(t))},exports.registerCheckList=P,exports.registerList=B,exports.registerListStrictIndentTransform=H,exports.removeList=function(e){e.update(()=>p())};
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- import{$getNearestNodeOfType as e,$insertNodeToNearestRootAtCaret as t,removeClassNamesFromElement as n,addClassNamesToElement as r,isHTMLElement as i,mergeRegister as s,$findMatchingParent as o,calculateZoomLevel as l}from"@lexical/utils";import{$getSelection as c,$isRangeSelection as a,$isTextNode as u,$isRootOrShadowRoot as g,$createParagraphNode as h,$copyNode as d,$isElementNode as f,$isLeafNode as p,$setPointFromCaret as m,$normalizeCaret as _,$getChildCaret as y,$applyNodeReplacement as C,ElementNode as v,buildImportMap as k,$getSiblingCaret as T,$rewindSiblingCaret as b,setDOMStyleFromCSS as S,isHTMLElement as x,$isParagraphNode as L,$setFormatFromDOM as N,$setDirectionFromDOM as F,normalizeClassNames as P,getStyleObjectFromCSS as A,$createTextNode as E,createCommand as O,COMMAND_PRIORITY_LOW as I,KEY_ARROW_DOWN_COMMAND as w,KEY_ARROW_UP_COMMAND as D,KEY_ESCAPE_COMMAND as M,KEY_SPACE_COMMAND as $,$getNearestNodeFromDOMNode as R,KEY_ARROW_LEFT_COMMAND as K,getNearestEditorFromDOMNode as B,$addUpdateTag as W,SKIP_SELECTION_FOCUS_TAG as U,SKIP_DOM_SELECTION_TAG as J,$getNodeByKey as V,INSERT_PARAGRAPH_COMMAND as q,TextNode as z,defineExtension as H,safeCast as j,configExtension as X}from"lexical";import{namedSignals as G,effect as Q}from"@lexical/extension";import{CoreImportExtension as Y,DOMImportExtension as Z,defineImportRule as ee,sel as te,isElementOfTag as ne}from"@lexical/html";function re(e,...t){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",e);for(const e of t)r.append("v",e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function ie(e){let t=1,n=e.getParent();for(;null!=n;){if(be(n)){const e=n.getParent();if(Pe(e)){t++,n=e.getParent();continue}re(40)}return t}return t}function se(e){let t=e.getParent();Pe(t)||re(40);let n=t;for(;null!==n;)n=n.getParent(),Pe(n)&&(t=n);return t}function oe(e){let t=[];const n=e.getChildren().filter(be);for(let e=0;e<n.length;e++){const r=n[e],i=r.getFirstChild();Pe(i)?t=t.concat(oe(i)):t.push(r)}return t}function le(e){return be(e)&&Pe(e.getFirstChild())}function ce(e,t){return be(e)&&(0===t.length||1===t.length&&e.is(t[0])&&0===e.getChildrenSize())}function ae(e){const t=c();if(null!==t){let n=t.getNodes();if(a(t)){const[r]=t.getStartEndPoints(),i=r.getNode(),s=i.getParent();if(g(i)){const e=i.getFirstChild();if(e)n=e.selectStart().getNodes();else{const e=h();i.append(e),n=e.select().getNodes()}}else if(ce(i,n)){const t=Fe(e);if(g(s)){i.replace(t);const e=Te();f(i)&&(e.setFormat(i.getFormatType()),e.setIndent(i.getIndent())),t.append(e)}else if(be(i)){const e=i.getParentOrThrow();ue(t,e.getChildren()),e.replace(t)}return}}const r=new Set;for(let t=0;t<n.length;t++){const i=n[t];if(f(i)&&i.isEmpty()&&!be(i)&&!r.has(i.getKey())){ge(i,e);continue}let s=p(i)?i.getParent():be(i)&&i.isEmpty()?i:null;for(;null!=s;){const t=s.getKey();if(Pe(s)){if(!r.has(t)){const n=Fe(e);ue(n,s.getChildren()),s.replace(n),r.add(t)}break}{const n=s.getParent();if(g(n)&&!r.has(t)){r.add(t),ge(s,e);break}s=n}}}}}function ue(e,t){e.splice(e.getChildrenSize(),0,t)}function ge(e,t){if(Pe(e))return e;const n=e.getPreviousSibling(),r=e.getNextSibling(),i=Te();let s;if(ue(i,e.getChildren()),Pe(n)&&t===n.getListType())n.append(i),Pe(r)&&t===r.getListType()&&(ue(n,r.getChildren()),r.remove()),s=n;else if(Pe(r)&&t===r.getListType())r.getFirstChildOrThrow().insertBefore(i),s=r;else{const n=Fe(t);n.append(i),e.replace(n),s=n}i.setFormat(e.getFormatType()),i.setIndent(e.getIndent());const o=c();return a(o)&&(s.getKey()===o.anchor.key&&o.anchor.set(i.getKey(),o.anchor.offset,"element"),s.getKey()===o.focus.key&&o.focus.set(i.getKey(),o.focus.offset,"element")),e.remove(),s}function he(e,t){const n=e.getLastChild(),r=t.getFirstChild();n&&r&&le(n)&&le(r)&&(he(n.getFirstChild(),r.getFirstChild()),r.remove());const i=t.getChildren();i.length>0&&e.append(...i),t.remove()}function de(){const t=c();if(a(t)){const n=new Set,r=t.getNodes(),i=t.anchor.getNode();if(ce(i,r))n.add(se(i));else for(let t=0;t<r.length;t++){const i=r[t];if(p(i)){const t=e(i,ye);null!=t&&n.add(se(t))}}for(const e of n){let n=e;const r=oe(e);for(const e of r){const r=h().setTextStyle(t.style).setTextFormat(t.format);ue(r,e.getChildren()),n.insertAfter(r),n=r,e.__key===t.anchor.key&&m(t.anchor,_(y(r,"next"))),e.__key===t.focus.key&&m(t.focus,_(y(r,"next"))),e.remove()}e.remove()}}}function fe(e){const t="check"!==e.getListType();let n=e.getStart();for(const r of e.getChildren())be(r)&&(r.getValue()!==n&&r.setValue(n),t&&null!=r.getLatest().__checked&&r.setChecked(void 0),Pe(r.getFirstChild())||n++)}function pe(e){const t=new Set;if(le(e)||t.has(e.getKey()))return;const n=e.getParent(),r=e.getNextSibling(),i=e.getPreviousSibling();if(le(r)&&le(i)){const n=i.getFirstChild();if(Pe(n)){n.append(e);const i=r.getFirstChild();if(Pe(i)){ue(n,i.getChildren()),r.remove(),t.add(r.getKey())}}}else if(le(r)){const t=r.getFirstChild();if(Pe(t)){const n=t.getFirstChild();null!==n&&n.insertBefore(e)}}else if(le(i)){const t=i.getFirstChild();Pe(t)&&t.append(e)}else if(Pe(n)){const t=d(e),s=d(n);t.append(s),s.append(e),i?i.insertAfter(t):r?r.insertBefore(t):n.append(t)}}function me(e){if(le(e))return;const t=e.getParent(),n=t?t.getParent():void 0;if(Pe(n?n.getParent():void 0)&&be(n)&&Pe(t)){const r=t?t.getFirstChild():void 0,i=t?t.getLastChild():void 0;if(e.is(r))n.insertBefore(e),t.isEmpty()&&n.remove();else if(e.is(i))n.insertAfter(e),t.isEmpty()&&n.remove();else{const r=d(e),i=d(t);r.append(i),e.getPreviousSiblings().forEach(e=>i.append(e));const s=d(e),o=d(t);s.append(o),ue(o,e.getNextSiblings()),n.insertBefore(r),n.insertAfter(s),n.replace(e)}}}function _e(e=!1){const t=c();if(!a(t)||!t.isCollapsed())return!1;const n=t.anchor.getNode();let r=null;if(be(n)&&0===n.getChildrenSize())r=n;else if(u(n)){const e=n.getParent();be(e)&&e.getChildren().every(e=>u(e)&&""===e.getTextContent().trim())&&(r=e)}if(null===r)return!1;const i=se(r),s=r.getParent();Pe(s)||re(40);const o=s.getParent();let l;if(g(o))l=h(),i.insertAfter(l);else{if(!be(o))return!1;l=d(o),o.insertAfter(l)}l.setTextStyle(t.style).setTextFormat(t.format).select();const f=r.getNextSiblings();if(f.length>0){const t=e?function(e,t){return e.getStart()+t.getIndexWithinParent()}(s,r):1,n=d(s).setStart(t);if(be(l)){const e=d(l);e.append(n),l.insertAfter(e)}else l.insertAfter(n);n.append(...f)}return function(e){let t=e;for(;null==t.getNextSibling()&&null==t.getPreviousSibling();){const e=t.getParent();if(null==e||!be(e)&&!Pe(e))break;t=e}t.remove()}(r),!0}class ye extends v{__value;__checked;$config(){return this.config("listitem",{$transform:e=>{const n=e.getParent();if(Pe(n))"check"!==n.getListType()&&null!=e.getChecked()&&e.setChecked(void 0);else if(n){const r=e.createParentElementNode();Pe(r)||re(340);const i=[e];for(const t of["previous","next"]){i.reverse();for(const{origin:n}of T(e,t)){if(!be(n))break;i.push(n)}}e.insertBefore(r),r.splice(0,0,i),g(n)||(t(r,b(T(r,"next")),{$shouldSplit:()=>!1,removeEmptyDestination:!0}),n.isEmpty()&&n.isAttached()&&n.remove())}},extends:v,importDOM:k({li:()=>({conversion:Ce,priority:0})})})}constructor(e=1,t=void 0,n){super(n),this.__value=void 0===e?1:e,this.__checked=t}afterCloneFrom(e){super.afterCloneFrom(e),this.__value=e.__value,this.__checked=e.__checked}createDOM(e){const t=document.createElement("li");return this.updateListItemDOM(null,t,e),t}updateListItemDOM(e,t,i){!function(e,t){const n=t.getParent();!Pe(n)||"check"!==n.getListType()||Pe(t.getFirstChild())?(e.removeAttribute("role"),e.removeAttribute("tabIndex"),e.removeAttribute("aria-checked")):(e.setAttribute("role","checkbox"),e.setAttribute("tabIndex","-1"),e.setAttribute("aria-checked",t.getChecked()?"true":"false"))}(t,this),t.value=this.__value,function(e,t,i){const s=t.list;if(!s)return;const o=s.listitem,l=s.nested&&s.nested.listitem,c=i.getParent(),a=Pe(c)&&"check"===c.getListType(),u=i.getChecked(),g=i.getChildren().some(e=>Pe(e)),h=[];void 0!==s.listitemChecked&&h.push(s.listitemChecked);void 0!==s.listitemUnchecked&&h.push(s.listitemUnchecked);void 0!==l&&h.push(...P(l));h.length>0&&n(e,...h);const d=[];void 0!==o&&d.push(...P(o));if(a){const e=u?s.listitemChecked:s.listitemUnchecked;void 0!==e&&d.push(e)}void 0!==l&&g&&d.push(...P(l));d.length>0&&r(e,...d)}(t,i.theme,this);const s=e?e.__style:"",o=this.__style;s!==o&&S(t.style,o,s),function(e,t,n){const r=t.__textStyle,i=n?n.__textStyle:"";if(null!==n&&i===r)return;const s=A(r);for(const t in s)e.style.setProperty(`--listitem-marker-${t}`,s[t]);if(""!==i)for(const t in A(i))t in s||e.style.removeProperty(`--listitem-marker-${t}`)}(t,this,e)}updateDOM(e,t,n){const r=t;return this.updateListItemDOM(e,r,n),!1}updateFromJSON(e){return super.updateFromJSON(e).setValue(e.value).setChecked(e.checked)}exportDOM(e){const t=this.createDOM(e._config),n=this.getFormatType();n&&(t.style.textAlign=n);const r=this.getDirection();return r&&(t.dir=r),le(this)?{after(e){if(x(e)){const t=e.previousElementSibling;if(x(t)&&"LI"===t.nodeName){for(;e.firstChild;)t.append(e.firstChild);e.remove()}}return e},element:t}:{element:t}}exportJSON(){return{...super.exportJSON(),checked:this.getChecked(),value:this.getValue()}}append(...e){for(let t=0;t<e.length;t++){const n=e[t];if(f(n)&&this.canMergeWith(n)){const e=n.getChildren();this.append(...e),n.remove()}else super.append(n)}return this}replace(e,t){if(be(e))return super.replace(e);this.setIndent(0);const n=this.getParentOrThrow();if(!Pe(n))return e;if(n.__first===this.getKey())n.insertBefore(e);else if(n.__last===this.getKey())n.insertAfter(e);else{const t=d(n);let r=this.getNextSibling();for(;r;){const e=r;r=r.getNextSibling(),t.append(e)}n.insertAfter(e),e.insertAfter(t)}const r=this.__key;let i=0;if(t&&(f(e)||re(139),i=e.getChildrenSize(),e.splice(i,0,this.getChildren())),t&&f(e)){const t=c();if(a(t))for(const n of t.getStartEndPoints())n.key===r&&"element"===n.type&&n.set(e.getKey(),i+n.offset,"element")}return this.remove(),0===n.getChildrenSize()&&n.remove(),e}insertAfter(e,t=!0){const n=this.getParentOrThrow();if(Pe(n)||re(39),be(e))return super.insertAfter(e,t);const r=this.getNextSiblings();if(n.insertAfter(e,t),0!==r.length){const i=d(n);r.forEach(e=>i.append(e)),e.insertAfter(i,t)}return e}remove(e){const t=this.getPreviousSibling(),n=this.getNextSibling();super.remove(e),t&&n&&le(t)&&le(n)&&(he(t.getFirstChild(),n.getFirstChild()),n.remove())}resetOnCopyNodeFrom(e){super.resetOnCopyNodeFrom(e),e.getChecked()&&this.setChecked(!1)}insertNewAfter(e,t=!0){const n=d(this);return this.insertAfter(n,t),n}collapseAtStart(e){const t=h();this.getChildren().forEach(e=>t.append(e));const n=this.getParentOrThrow(),r=n.getParentOrThrow(),i=be(r);if(1===n.getChildrenSize())if(i)n.remove(),r.select();else{n.insertBefore(t),n.remove();const r=e.anchor,i=e.focus,s=t.getKey();"element"===r.type&&r.getNode().is(this)&&r.set(s,r.offset,"element"),"element"===i.type&&i.getNode().is(this)&&i.set(s,i.offset,"element")}else n.insertBefore(t),this.remove();return!0}getValue(){return this.getLatest().__value}setValue(e){const t=this.getWritable();return t.__value=e,t}getChecked(){const e=this.getLatest();let t;const n=this.getParent();return Pe(n)&&(t=n.getListType()),"check"===t?Boolean(e.__checked):void 0}setChecked(e){const t=this.getWritable();return t.__checked=e,t}toggleChecked(){const e=this.getWritable();return e.setChecked(!e.__checked)}getIndent(){const e=this.getParent();if(null===e||!this.isAttached())return this.getLatest().__indent;let t=e.getParentOrThrow(),n=0;for(;be(t);)t=t.getParentOrThrow().getParentOrThrow(),n++;return n}setIndent(e){"number"!=typeof e&&re(117),(e=Math.floor(e))>=0||re(199);let t=this.getIndent();for(;t!==e;)t<e?(pe(this),t++):(me(this),t--);return this}canInsertAfter(e){return be(e)}canReplaceWith(e){return be(e)}canMergeWith(e){return be(e)||L(e)}extractWithChild(e,t){if(!a(t))return!1;const n=t.anchor.getNode(),r=t.focus.getNode();return this.isParentOf(n)&&this.isParentOf(r)&&this.getTextContent().length===t.getTextContent().length}isParentRequired(){return!0}createParentElementNode(){return Fe("bullet")}canMergeWhenEmpty(){return!0}}function Ce(e){if(e.classList.contains("task-list-item"))for(const t of e.children)if("INPUT"===t.tagName)return ve(t);if(e.classList.contains("joplin-checkbox"))for(const t of e.children)if(t.classList.contains("checkbox-wrapper")&&t.children.length>0&&"INPUT"===t.children[0].tagName)return ve(t.children[0]);const t=e.getAttribute("aria-checked"),n=Te("true"===t||"false"!==t&&void 0);return N(n,e),{after:ke.bind(null,n),node:F(n,e)}}function ve(e){if(!("checkbox"===e.getAttribute("type")))return{node:null};const t=Te(e.hasAttribute("checked"));return{after:ke.bind(null,t),node:t}}function ke(e,t){const n=t[0];return 1===t.length&&L(n)&&!e.getFormatType()&&n.getFormatType()?(e.setFormat(n.getFormatType()),n.getChildren()):t}function Te(e){return C(new ye(void 0,e))}function be(e){return e instanceof ye}class Se extends v{__tag;__start;__listType;$config(){return this.config("list",{$transform:e=>{!function(e){const t=e.getNextSibling();Pe(t)&&e.getListType()===t.getListType()&&he(e,t)}(e),fe(e)},extends:v,importDOM:k({ol:()=>({conversion:Le,priority:0}),ul:()=>({conversion:Le,priority:0})})})}constructor(e="number",t=1,n){super(n);const r=Ne[e]||e;this.__listType=r,this.__tag="number"===r?"ol":"ul",this.__start=t}afterCloneFrom(e){super.afterCloneFrom(e),this.__listType=e.__listType,this.__tag=e.__tag,this.__start=e.__start}getTag(){return this.getLatest().__tag}setListType(e){const t=this.getWritable();return t.__listType=e,t.__tag="number"===e?"ol":"ul",t}getListType(){return this.getLatest().__listType}getStart(){return this.getLatest().__start}setStart(e){const t=this.getWritable();return t.__start=e,t}createDOM(e,t){const n=this.__tag,r=document.createElement(n);return 1!==this.__start&&r.setAttribute("start",String(this.__start)),r.__lexicalListType=this.__listType,xe(r,e.theme,this),r}updateDOM(e,t,n){return e.__tag!==this.__tag||e.__listType!==this.__listType||(xe(t,n.theme,this),e.__start!==this.__start&&t.setAttribute("start",String(this.__start)),!1)}updateFromJSON(e){return super.updateFromJSON(e).setListType(e.listType).setStart(e.start)}exportDOM(e){const t=this.createDOM(e._config,e);return i(t)&&(1!==this.__start&&t.setAttribute("start",String(this.__start)),"check"===this.__listType&&t.setAttribute("__lexicalListType","check")),{element:t}}exportJSON(){return{...super.exportJSON(),listType:this.getListType(),start:this.getStart(),tag:this.getTag()}}canBeEmpty(){return!1}canIndent(){return!1}splice(e,t,n){let r=n;for(let e=0;e<n.length;e++){const t=n[e];be(t)||(r===n&&(r=[...n]),r[e]=this.createListItemNode().append(!f(t)||Pe(t)||t.isInline()?t:E(t.getTextContent())))}return super.splice(e,t,r)}extractWithChild(e){return be(e)}createListItemNode(){return Te()}}function xe(e,t,i){const s=[],o=[],l=t.list;if(void 0!==l){const e=l[`${i.__tag}Depth`]||[],t=ie(i)-1,n=t%e.length,r=e[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(...P(r));for(let t=0;t<e.length;t++)t!==n&&o.push(i.__tag+t)}if(void 0!==a){const e=P(a);t>1?s.push(...e):o.push(...e)}}o.length>0&&n(e,...o),s.length>0&&r(e,...s)}function Le(e){let t;if(function(e){return i(e)&&"ol"===e.nodeName.toLowerCase()}(e)){const n=e.start;t=Fe("number",n)}else t=function(e){if("check"===e.getAttribute("__lexicallisttype")||e.classList.contains("contains-task-list")||"1"===e.getAttribute("data-is-checklist"))return!0;for(const t of e.childNodes)if(i(t)&&t.hasAttribute("aria-checked"))return!0;return!1}(e)?Fe("check"):Fe("bullet");return F(t,e),{after:e=>function(e,t){const n=t.createListItemNode.bind(t),r=[];for(let t=0;t<e.length;t++){const i=e[t];if(be(i)){r.push(i);const e=i.getChildren();e.length>1&&e.forEach(e=>{Pe(e)&&r.push(n().append(e))})}else r.push(n().append(i))}return r}(e,t),node:t}}const Ne={ol:"number",ul:"bullet"};function Fe(e="number",t=1){return C(new Se(e,t))}function Pe(e){return e instanceof Se}const Ae=O("INSERT_CHECK_LIST_COMMAND");function Ee(e,t){const n=t&&t.disableTakeFocusOnClick||!1,r="boolean"==typeof n?()=>n:n.peek.bind(n),l=e=>{const t=e.target;if(!i(t))return!1;const n=t.__lexicalCheckListLastHandled;return void 0!==n&&e.timeStamp-n<500},u=e=>{const t=e.target;i(t)&&(t.__lexicalCheckListLastHandled=e.timeStamp)},g=e=>{l(e)||(u(e),Ie(e,r()))},h=e=>{"touch"===e.pointerType&&(l(e)||(u(e),Ie(e,r())))},d=e=>{!function(e,t){Oe(e,()=>{e.preventDefault(),t&&e.stopPropagation()})}(e,r())};return s(e.registerCommand(Ae,()=>(ae("check"),!0),I),e.registerCommand(w,t=>De(t,e,!1),I),e.registerCommand(D,t=>De(t,e,!0),I),e.registerCommand(M,()=>{if(null!=we()){const t=e.getRootElement();return null!=t&&t.focus(),!0}return!1},I),e.registerCommand($,t=>{const n=we();return!(null==n||!e.isEditable())&&(e.update(()=>{const e=R(n);be(e)&&(t.preventDefault(),e.toggleChecked())}),!0)},I),e.registerCommand(K,t=>e.getEditorState().read(()=>{const n=c();if(a(n)&&n.isCollapsed()){const{anchor:r}=n,i="element"===r.type;if(i||0===r.offset){const n=r.getNode(),s=o(n,e=>f(e)&&!e.isInline());if(be(s)){const r=s.getParent();if(Pe(r)&&"check"===r.getListType()&&(i||s.getFirstDescendant()===n)){const n=e.getElementByKey(s.__key);if(null!=n&&document.activeElement!==n)return n.focus(),t.preventDefault(),!0}}}}return!1}),I),e.registerRootListener(e=>{if(null!==e)return e.addEventListener("click",g),e.addEventListener("pointerup",h),e.addEventListener("pointerdown",d,{capture:!0}),e.addEventListener("mousedown",d,{capture:!0}),e.addEventListener("touchstart",d,{capture:!0,passive:!1}),()=>{e.removeEventListener("click",g),e.removeEventListener("pointerup",h),e.removeEventListener("pointerdown",d,{capture:!0}),e.removeEventListener("mousedown",d,{capture:!0}),e.removeEventListener("touchstart",d,{capture:!0})}}))}function Oe(e,t){const n=e.target;if(!i(n))return;const r=n.firstChild;if(i(r)&&("UL"===r.tagName||"OL"===r.tagName))return;const s=n.parentNode;if(!s||"check"!==s.__lexicalListType)return;let o=null,c=null;if("clientX"in e)o=e.clientX;else if("touches"in e){const t=e.touches;t.length>0&&(o=t[0].clientX,c="touch")}if(null==o)return;const a=n.getBoundingClientRect(),u=o/l(n),g=window.getComputedStyle?window.getComputedStyle(n,"::before"):{width:"0px"},h=parseFloat(g.width),d="touch"===c||"pointerType"in e&&"touch"===e.pointerType?32:0;("rtl"===n.dir?u<a.right+d&&u>a.right-h-d:u>a.left-d&&u<a.left+h+d)&&t()}function Ie(e,t){Oe(e,()=>{if(i(e.target)){const n=e.target,r=B(n);null!=r&&r.isEditable()&&r.update(()=>{const e=R(n);be(e)&&(t?(W(U),W(J)):n.focus(),e.toggleChecked())})}})}function we(){const e=document.activeElement;return i(e)&&"LI"===e.tagName&&null!=e.parentNode&&"check"===e.parentNode.__lexicalListType?e:null}function De(e,t,n){const r=we();return null!=r&&t.update(()=>{const i=R(r);if(!be(i))return;const s=function(e,t){let n=t?e.getPreviousSibling():e.getNextSibling(),r=e;for(;null==n&&be(r);)r=r.getParentOrThrow().getParent(),null!=r&&(n=t?r.getPreviousSibling():r.getNextSibling());for(;be(n);){const e=t?n.getLastChild():n.getFirstChild();if(!Pe(e))return n;n=t?e.getLastChild():e.getFirstChild()}return null}(i,n);if(null!=s){s.selectStart();const n=t.getElementByKey(s.__key);null!=n&&(e.preventDefault(),setTimeout(()=>{n.focus()},0))}}),!1}const Me=O("UPDATE_LIST_START_COMMAND"),$e=O("INSERT_UNORDERED_LIST_COMMAND"),Re=O("INSERT_ORDERED_LIST_COMMAND"),Ke=O("REMOVE_LIST_COMMAND");function Be(e,t){return s(e.registerCommand(Re,()=>(ae("number"),!0),I),e.registerCommand(Me,e=>{const{listNodeKey:t,newStart:n}=e,r=V(t);return!!Pe(r)&&("number"===r.getListType()&&(r.setStart(n),fe(r)),!0)},I),e.registerCommand($e,()=>(ae("bullet"),!0),I),e.registerCommand(Ke,()=>(de(),!0),I),e.registerCommand(q,()=>_e(!!(t&&t.restoreNumbering)),I),e.registerNodeTransform(ye,e=>{const t=e.getFirstChild();if(t){if(u(t)){const n=t.getStyle(),r=t.getFormat();e.getTextStyle()!==n&&e.setTextStyle(n),e.getTextFormat()!==r&&e.setTextFormat(r)}}else{const t=c();a(t)&&(t.style!==e.getTextStyle()||t.format!==e.getTextFormat())&&t.isCollapsed()&&e.is(t.anchor.getNode())&&e.setTextStyle(t.style).setTextFormat(t.format)}}),e.registerNodeTransform(z,e=>{const t=e.getParent();if(be(t)&&e.is(t.getFirstChild())){const n=e.getStyle(),r=e.getFormat();n===t.getTextStyle()&&r===t.getTextFormat()||t.setTextStyle(n).setTextFormat(r)}}))}function We(e){const t=e=>{const t=e.getParent();if(Pe(e.getFirstChild())||!Pe(t))return;const n=o(e,e=>be(e)&&Pe(e.getParent())&&be(e.getPreviousSibling()));if(null===n&&e.getIndent()>0)e.setIndent(0);else if(be(n)){const r=n.getPreviousSibling();if(be(r)){const n=function(e){let t=e,n=t.getFirstChild();for(;Pe(n);){const e=n.getLastChild();if(!be(e))break;t=e,n=t.getFirstChild()}return t}(r),i=n.getParent();if(Pe(i)){const n=ie(i);n+1<ie(t)&&e.setIndent(n)}}}};return e.registerNodeTransform(Se,e=>{const n=[e];for(;n.length>0;){const e=n.shift();if(Pe(e))for(const r of e.getChildren())if(be(r)){t(r);const e=r.getFirstChild();Pe(e)&&n.push(e)}}})}const Ue=H({build:(e,t,n)=>G(t),config:j({hasStrictIndent:!1,shouldPreserveNumbering:!1}),name:"@lexical/list/List",nodes:()=>[Se,ye],register(e,t,n){const r=n.getOutput();return s(Q(()=>Be(e,{restoreNumbering:r.shouldPreserveNumbering.value})),Q(()=>r.hasStrictIndent.value?We(e):void 0))}}),Je=H({build:(e,t)=>G(t),config:j({disableTakeFocusOnClick:!1}),dependencies:[Ue],name:"@lexical/list/CheckList",register:(e,t,n)=>Ee(e,n.getOutput())});function Ve(e){const t=[];for(const n of e)if(be(n)){t.push(n);const e=n.getChildren();if(e.length>1)for(const n of e)Pe(n)&&t.push(Te().append(n))}else t.push(Te().append(n));return t}const qe=ee({$import:(e,t)=>{let n;var r;return ne(t,"ol")?n=Fe("number",t.start):n=(r=t).matches('[__lexicallisttype="check"], .contains-task-list, [data-is-checklist="1"]')||null!==r.querySelector(":scope > [aria-checked]")?Fe("check"):Fe("bullet"),F(n,t),[n.splice(0,0,Ve(e.$importChildren(t)))]},match:te.tag("ol","ul"),name:"@lexical/list/list"});function ze(e,t){if(1!==t.length)return t;const n=t[0];return L(n)&&!e.getFormatType()&&n.getFormatType()?(e.setFormat(n.getFormatType()),n.getChildren()):t}const He=ee({$import:(e,t)=>{const n=t.getAttribute("aria-checked"),r=Te("true"===n||"false"!==n&&void 0);return N(r,t),F(r,t),[r.splice(0,0,ze(r,e.$importChildren(t)))]},match:te.tag("li"),name:"@lexical/list/li"});function je(e,t,n){const r=ne(n,"input")?n:n.querySelector('input[type="checkbox"]');if(!r||"checkbox"!==r.getAttribute("type"))return[];const i=Te(r.hasAttribute("checked"));return N(i,t),F(i,t),[i.splice(0,0,ze(i,e.$importChildren(t)))]}const Xe={$accepts:e=>be(e)||Pe(e),$packageRun:e=>[Te().splice(0,0,e)],name:"ListSchema"},Ge=[ee({$import:(e,t,n)=>{const r=t.querySelector(':scope > input[type="checkbox"]');return r?je(e,t,r):n()},match:te.tag("li").classAll("task-list-item"),name:"@lexical/list/li-task-list-item"}),ee({$import:(e,t,n)=>{const r=t.querySelector(":scope > .checkbox-wrapper");if(!r)return n();const i=r.querySelector(':scope > input[type="checkbox"]');return i?je(e,t,i):n()},match:te.tag("li").classAll("joplin-checkbox"),name:"@lexical/list/li-joplin-checkbox"}),qe,He],Qe=H({dependencies:[Y,Ue,X(Z,{rules:Ge})],name:"@lexical/list/Import"});function Ye(e,t){e.update(()=>ae(t))}function Ze(e){e.update(()=>de())}export{Te as $createListItemNode,Fe as $createListNode,ie as $getListDepth,_e as $handleListInsertParagraph,ae as $insertList,be as $isListItemNode,Pe as $isListNode,de as $removeList,Je as CheckListExtension,Ae as INSERT_CHECK_LIST_COMMAND,Re as INSERT_ORDERED_LIST_COMMAND,$e as INSERT_UNORDERED_LIST_COMMAND,Ue as ListExtension,Qe as ListImportExtension,Ge as ListImportRules,ye as ListItemNode,Se as ListNode,Xe as ListSchema,Ke as REMOVE_LIST_COMMAND,Me as UPDATE_LIST_START_COMMAND,Ye as insertList,Ee as registerCheckList,Be as registerList,We as registerListStrictIndentTransform,Ze as removeList};
9
+ import{$getNearestNodeOfType as e,$insertNodeToNearestRootAtCaret as t,removeClassNamesFromElement as n,addClassNamesToElement as r,isHTMLElement as i,mergeRegister as s,$findMatchingParent as o,calculateZoomLevel as l}from"@lexical/utils";import{$getSelection as c,$isRangeSelection as a,$isTextNode as u,$isRootOrShadowRoot as h,$createParagraphNode as g,$copyNode as d,$isElementNode as f,$isLeafNode as p,$setPointFromCaret as m,$normalizeCaret as _,$getChildCaret as y,$applyNodeReplacement as C,ElementNode as v,buildImportMap as k,$getSiblingCaret as T,$rewindSiblingCaret as b,setDOMStyleFromCSS as S,isHTMLElement as x,$isParagraphNode as L,$setFormatFromDOM as N,$setDirectionFromDOM as F,normalizeClassNames as P,getStyleObjectFromCSS as A,$createTextNode as E,createCommand as O,COMMAND_PRIORITY_LOW as I,KEY_ARROW_DOWN_COMMAND as w,KEY_ARROW_UP_COMMAND as D,KEY_ESCAPE_COMMAND as M,KEY_SPACE_COMMAND as $,$getNearestNodeFromDOMNode as R,KEY_ARROW_LEFT_COMMAND as K,getNearestEditorFromDOMNode as B,$addUpdateTag as W,SKIP_SELECTION_FOCUS_TAG as U,SKIP_DOM_SELECTION_TAG as J,$getNodeByKey as V,INSERT_PARAGRAPH_COMMAND as q,TextNode as z,defineExtension as H,safeCast as j,configExtension as X,$createLineBreakNode as G}from"lexical";import{namedSignals as Q,effect as Y}from"@lexical/extension";import{DOMImportExtension as Z,defineImportRule as ee,sel as te,isElementOfTag as ne,$propagateTextAlignToBlockChildren as re,$isBlockLevel as ie}from"@lexical/html";function se(e,...t){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",e);for(const e of t)r.append("v",e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function oe(e){let t=1,n=e.getParent();for(;null!=n;){if(xe(n)){const e=n.getParent();if(Ee(e)){t++,n=e.getParent();continue}se(40)}return t}return t}function le(e){let t=e.getParent();Ee(t)||se(40);let n=t;for(;null!==n;)n=n.getParent(),Ee(n)&&(t=n);return t}function ce(e){let t=[];const n=e.getChildren().filter(xe);for(let e=0;e<n.length;e++){const r=n[e],i=r.getFirstChild();Ee(i)?t=t.concat(ce(i)):t.push(r)}return t}function ae(e){return xe(e)&&Ee(e.getFirstChild())}function ue(e,t){return xe(e)&&(0===t.length||1===t.length&&e.is(t[0])&&0===e.getChildrenSize())}function he(e){const t=c();if(null!==t){let n=t.getNodes();if(a(t)){const[r]=t.getStartEndPoints(),i=r.getNode(),s=i.getParent();if(h(i)){const e=i.getFirstChild();if(e)n=e.selectStart().getNodes();else{const e=g();i.append(e),n=e.select().getNodes()}}else if(ue(i,n)){const t=Ae(e);if(h(s)){i.replace(t);const e=Se();f(i)&&(e.setFormat(i.getFormatType()),e.setIndent(i.getIndent())),t.append(e)}else if(xe(i)){const e=i.getParentOrThrow();ge(t,e.getChildren()),e.replace(t)}return}}const r=new Set;for(let t=0;t<n.length;t++){const i=n[t];if(f(i)&&i.isEmpty()&&!xe(i)&&!r.has(i.getKey())){de(i,e);continue}let s=p(i)?i.getParent():xe(i)&&i.isEmpty()?i:null;for(;null!=s;){const t=s.getKey();if(Ee(s)){if(!r.has(t)){const n=Ae(e);ge(n,s.getChildren()),s.replace(n),r.add(t)}break}{const n=s.getParent();if(h(n)&&!r.has(t)){r.add(t),de(s,e);break}s=n}}}}}function ge(e,t){e.splice(e.getChildrenSize(),0,t)}function de(e,t){if(Ee(e))return e;const n=e.getPreviousSibling(),r=e.getNextSibling(),i=Se();let s;if(ge(i,e.getChildren()),Ee(n)&&t===n.getListType())n.append(i),Ee(r)&&t===r.getListType()&&(ge(n,r.getChildren()),r.remove()),s=n;else if(Ee(r)&&t===r.getListType())r.getFirstChildOrThrow().insertBefore(i),s=r;else{const n=Ae(t);n.append(i),e.replace(n),s=n}i.setFormat(e.getFormatType()),i.setIndent(e.getIndent());const o=c();return a(o)&&(s.getKey()===o.anchor.key&&o.anchor.set(i.getKey(),o.anchor.offset,"element"),s.getKey()===o.focus.key&&o.focus.set(i.getKey(),o.focus.offset,"element")),e.remove(),s}function fe(e,t){const n=e.getLastChild(),r=t.getFirstChild();n&&r&&ae(n)&&ae(r)&&(fe(n.getFirstChild(),r.getFirstChild()),r.remove());const i=t.getChildren();i.length>0&&e.append(...i),t.remove()}function pe(){const t=c();if(a(t)){const n=new Set,r=t.getNodes(),i=t.anchor.getNode();if(ue(i,r))n.add(le(i));else for(let t=0;t<r.length;t++){const i=r[t];if(p(i)){const t=e(i,ve);null!=t&&n.add(le(t))}}for(const e of n){let n=e;const r=ce(e);for(const e of r){const r=g().setTextStyle(t.style).setTextFormat(t.format);ge(r,e.getChildren()),n.insertAfter(r),n=r,e.__key===t.anchor.key&&m(t.anchor,_(y(r,"next"))),e.__key===t.focus.key&&m(t.focus,_(y(r,"next"))),e.remove()}e.remove()}}}function me(e){const t="check"!==e.getListType();let n=e.getStart();for(const r of e.getChildren())xe(r)&&(r.getValue()!==n&&r.setValue(n),t&&null!=r.getLatest().__checked&&r.setChecked(void 0),Ee(r.getFirstChild())||n++)}function _e(e){const t=new Set;if(ae(e)||t.has(e.getKey()))return;const n=e.getParent(),r=e.getNextSibling(),i=e.getPreviousSibling();if(ae(r)&&ae(i)){const n=i.getFirstChild();if(Ee(n)){n.append(e);const i=r.getFirstChild();if(Ee(i)){ge(n,i.getChildren()),r.remove(),t.add(r.getKey())}}}else if(ae(r)){const t=r.getFirstChild();if(Ee(t)){const n=t.getFirstChild();null!==n&&n.insertBefore(e)}}else if(ae(i)){const t=i.getFirstChild();Ee(t)&&t.append(e)}else if(Ee(n)){const t=d(e),s=d(n);t.append(s),s.append(e),i?i.insertAfter(t):r?r.insertBefore(t):n.append(t)}}function ye(e){if(ae(e))return;const t=e.getParent(),n=t?t.getParent():void 0;if(Ee(n?n.getParent():void 0)&&xe(n)&&Ee(t)){const r=t?t.getFirstChild():void 0,i=t?t.getLastChild():void 0;if(e.is(r))n.insertBefore(e),t.isEmpty()&&n.remove();else if(e.is(i))n.insertAfter(e),t.isEmpty()&&n.remove();else{const r=d(e),i=d(t);r.append(i),e.getPreviousSiblings().forEach(e=>i.append(e));const s=d(e),o=d(t);s.append(o),ge(o,e.getNextSiblings()),n.insertBefore(r),n.insertAfter(s),n.replace(e)}}}function Ce(e=!1){const t=c();if(!a(t)||!t.isCollapsed())return!1;const n=t.anchor.getNode();let r=null;if(xe(n)&&0===n.getChildrenSize())r=n;else if(u(n)){const e=n.getParent();xe(e)&&e.getChildren().every(e=>u(e)&&""===e.getTextContent().trim())&&(r=e)}if(null===r)return!1;const i=le(r),s=r.getParent();Ee(s)||se(40);const o=s.getParent();let l;if(h(o))l=g(),i.insertAfter(l);else{if(!xe(o))return!1;l=d(o),o.insertAfter(l)}l.setTextStyle(t.style).setTextFormat(t.format).select();const f=r.getNextSiblings();if(f.length>0){const t=e?function(e,t){return e.getStart()+t.getIndexWithinParent()}(s,r):1,n=d(s).setStart(t);if(xe(l)){const e=d(l);e.append(n),l.insertAfter(e)}else l.insertAfter(n);n.append(...f)}return function(e){let t=e;for(;null==t.getNextSibling()&&null==t.getPreviousSibling();){const e=t.getParent();if(null==e||!xe(e)&&!Ee(e))break;t=e}t.remove()}(r),!0}class ve extends v{__value;__checked;$config(){return this.config("listitem",{$transform:e=>{const n=e.getParent();if(Ee(n))"check"!==n.getListType()&&null!=e.getChecked()&&e.setChecked(void 0);else if(n){const r=e.createParentElementNode();Ee(r)||se(340);const i=[e];for(const t of["previous","next"]){i.reverse();for(const{origin:n}of T(e,t)){if(!xe(n))break;i.push(n)}}e.insertBefore(r),r.splice(0,0,i),h(n)||(t(r,b(T(r,"next")),{$shouldSplit:()=>!1,removeEmptyDestination:!0}),n.isEmpty()&&n.isAttached()&&n.remove())}},extends:v,importDOM:k({li:()=>({conversion:ke,priority:0})})})}constructor(e=1,t=void 0,n){super(n),this.__value=void 0===e?1:e,this.__checked=t}afterCloneFrom(e){super.afterCloneFrom(e),this.__value=e.__value,this.__checked=e.__checked}createDOM(e){const t=document.createElement("li");return this.updateListItemDOM(null,t,e),t}updateListItemDOM(e,t,i){!function(e,t){const n=t.getParent();!Ee(n)||"check"!==n.getListType()||Ee(t.getFirstChild())?(e.removeAttribute("role"),e.removeAttribute("tabIndex"),e.removeAttribute("aria-checked")):(e.setAttribute("role","checkbox"),e.setAttribute("tabIndex","-1"),e.setAttribute("aria-checked",t.getChecked()?"true":"false"))}(t,this),t.value=this.__value,function(e,t,i){const s=t.list;if(!s)return;const o=s.listitem,l=s.nested&&s.nested.listitem,c=i.getParent(),a=Ee(c)&&"check"===c.getListType(),u=i.getChecked(),h=i.getChildren().some(e=>Ee(e)),g=[];void 0!==s.listitemChecked&&g.push(s.listitemChecked);void 0!==s.listitemUnchecked&&g.push(s.listitemUnchecked);void 0!==l&&g.push(...P(l));g.length>0&&n(e,...g);const d=[];void 0!==o&&d.push(...P(o));if(a){const e=u?s.listitemChecked:s.listitemUnchecked;void 0!==e&&d.push(e)}void 0!==l&&h&&d.push(...P(l));d.length>0&&r(e,...d)}(t,i.theme,this);const s=e?e.__style:"",o=this.__style;s!==o&&S(t.style,o,s),function(e,t,n){const r=t.__textStyle,i=n?n.__textStyle:"";if(null!==n&&i===r)return;const s=A(r);for(const t in s)e.style.setProperty(`--listitem-marker-${t}`,s[t]);if(""!==i)for(const t in A(i))t in s||e.style.removeProperty(`--listitem-marker-${t}`)}(t,this,e)}updateDOM(e,t,n){const r=t;return this.updateListItemDOM(e,r,n),!1}updateFromJSON(e){return super.updateFromJSON(e).setValue(e.value).setChecked(e.checked)}exportDOM(e){const t=this.createDOM(e._config),n=this.getFormatType();n&&(t.style.textAlign=n);const r=this.getDirection();return r&&(t.dir=r),ae(this)?{after(e){if(x(e)){const t=e.previousElementSibling;if(x(t)&&"LI"===t.nodeName){for(;e.firstChild;)t.append(e.firstChild);e.remove()}}return e},element:t}:{element:t}}exportJSON(){return{...super.exportJSON(),checked:this.getChecked(),value:this.getValue()}}append(...e){for(let t=0;t<e.length;t++){const n=e[t];if(f(n)&&this.canMergeWith(n)){const e=n.getChildren();this.append(...e),n.remove()}else super.append(n)}return this}replace(e,t){if(xe(e))return super.replace(e);this.setIndent(0);const n=this.getParentOrThrow();if(!Ee(n))return e;if(n.__first===this.getKey())n.insertBefore(e);else if(n.__last===this.getKey())n.insertAfter(e);else{const t=d(n);let r=this.getNextSibling();for(;r;){const e=r;r=r.getNextSibling(),t.append(e)}n.insertAfter(e),e.insertAfter(t)}const r=this.__key;let i=0;if(t&&(f(e)||se(139),i=e.getChildrenSize(),e.splice(i,0,this.getChildren())),t&&f(e)){const t=c();if(a(t))for(const n of t.getStartEndPoints())n.key===r&&"element"===n.type&&n.set(e.getKey(),i+n.offset,"element")}return this.remove(),0===n.getChildrenSize()&&n.remove(),e}insertAfter(e,t=!0){const n=this.getParentOrThrow();if(Ee(n)||se(39),xe(e))return super.insertAfter(e,t);const r=this.getNextSiblings();if(n.insertAfter(e,t),0!==r.length){const i=d(n);r.forEach(e=>i.append(e)),e.insertAfter(i,t)}return e}remove(e){const t=this.getPreviousSibling(),n=this.getNextSibling();super.remove(e),t&&n&&ae(t)&&ae(n)&&(fe(t.getFirstChild(),n.getFirstChild()),n.remove())}resetOnCopyNodeFrom(e){super.resetOnCopyNodeFrom(e),e.getChecked()&&this.setChecked(!1)}insertNewAfter(e,t=!0){const n=d(this);return this.insertAfter(n,t),n}collapseAtStart(e){const t=g();this.getChildren().forEach(e=>t.append(e));const n=this.getParentOrThrow(),r=n.getParentOrThrow(),i=xe(r);if(1===n.getChildrenSize())if(i)n.remove(),r.select();else{n.insertBefore(t),n.remove();const r=e.anchor,i=e.focus,s=t.getKey();"element"===r.type&&r.getNode().is(this)&&r.set(s,r.offset,"element"),"element"===i.type&&i.getNode().is(this)&&i.set(s,i.offset,"element")}else n.insertBefore(t),this.remove();return!0}getValue(){return this.getLatest().__value}setValue(e){const t=this.getWritable();return t.__value=e,t}getChecked(){const e=this.getLatest();let t;const n=this.getParent();return Ee(n)&&(t=n.getListType()),"check"===t?Boolean(e.__checked):void 0}setChecked(e){const t=this.getWritable();return t.__checked=e,t}toggleChecked(){const e=this.getWritable();return e.setChecked(!e.__checked)}getIndent(){const e=this.getParent();if(null===e||!this.isAttached())return this.getLatest().__indent;let t=e.getParentOrThrow(),n=0;for(;xe(t);)t=t.getParentOrThrow().getParentOrThrow(),n++;return n}setIndent(e){"number"!=typeof e&&se(117),(e=Math.floor(e))>=0||se(199);let t=this.getIndent();for(;t!==e;)t<e?(_e(this),t++):(ye(this),t--);return this}canInsertAfter(e){return xe(e)}canReplaceWith(e){return xe(e)}canMergeWith(e){return xe(e)||L(e)}extractWithChild(e,t){if(!a(t))return!1;const n=t.anchor.getNode(),r=t.focus.getNode();return this.isParentOf(n)&&this.isParentOf(r)&&this.getTextContent().length===t.getTextContent().length}isParentRequired(){return!0}createParentElementNode(){return Ae("bullet")}canMergeWhenEmpty(){return!0}}function ke(e){if(e.classList.contains("task-list-item"))for(const t of e.children)if("INPUT"===t.tagName)return Te(t);if(e.classList.contains("joplin-checkbox"))for(const t of e.children)if(t.classList.contains("checkbox-wrapper")&&t.children.length>0&&"INPUT"===t.children[0].tagName)return Te(t.children[0]);const t=e.getAttribute("aria-checked"),n=Se("true"===t||"false"!==t&&void 0);return N(n,e),{after:be.bind(null,n),node:F(n,e)}}function Te(e){if(!("checkbox"===e.getAttribute("type")))return{node:null};const t=Se(e.hasAttribute("checked"));return{after:be.bind(null,t),node:t}}function be(e,t){const n=t[0];return 1===t.length&&L(n)&&!e.getFormatType()&&n.getFormatType()?(e.setFormat(n.getFormatType()),n.getChildren()):t}function Se(e){return C(new ve(void 0,e))}function xe(e){return e instanceof ve}class Le extends v{__tag;__start;__listType;$config(){return this.config("list",{$transform:e=>{!function(e){const t=e.getNextSibling();Ee(t)&&e.getListType()===t.getListType()&&fe(e,t)}(e),me(e)},extends:v,importDOM:k({ol:()=>({conversion:Fe,priority:0}),ul:()=>({conversion:Fe,priority:0})})})}constructor(e="number",t=1,n){super(n);const r=Pe[e]||e;this.__listType=r,this.__tag="number"===r?"ol":"ul",this.__start=t}afterCloneFrom(e){super.afterCloneFrom(e),this.__listType=e.__listType,this.__tag=e.__tag,this.__start=e.__start}getTag(){return this.getLatest().__tag}setListType(e){const t=this.getWritable();return t.__listType=e,t.__tag="number"===e?"ol":"ul",t}getListType(){return this.getLatest().__listType}getStart(){return this.getLatest().__start}setStart(e){const t=this.getWritable();return t.__start=e,t}createDOM(e,t){const n=this.__tag,r=document.createElement(n);return 1!==this.__start&&r.setAttribute("start",String(this.__start)),r.__lexicalListType=this.__listType,Ne(r,e.theme,this),r}updateDOM(e,t,n){return e.__tag!==this.__tag||e.__listType!==this.__listType||(Ne(t,n.theme,this),e.__start!==this.__start&&t.setAttribute("start",String(this.__start)),!1)}updateFromJSON(e){return super.updateFromJSON(e).setListType(e.listType).setStart(e.start)}exportDOM(e){const t=this.createDOM(e._config,e);return i(t)&&(1!==this.__start&&t.setAttribute("start",String(this.__start)),"check"===this.__listType&&t.setAttribute("__lexicalListType","check")),{element:t}}exportJSON(){return{...super.exportJSON(),listType:this.getListType(),start:this.getStart(),tag:this.getTag()}}canBeEmpty(){return!1}canIndent(){return!1}splice(e,t,n){let r=n;for(let e=0;e<n.length;e++){const t=n[e];xe(t)||(r===n&&(r=[...n]),r[e]=this.createListItemNode().append(!f(t)||Ee(t)||t.isInline()?t:E(t.getTextContent())))}return super.splice(e,t,r)}extractWithChild(e){return xe(e)}createListItemNode(){return Se()}}function Ne(e,t,i){const s=[],o=[],l=t.list;if(void 0!==l){const e=l[`${i.__tag}Depth`]||[],t=oe(i)-1,n=t%e.length,r=e[n],c=l[i.__tag];let a;const u=l.nested,h=l.checklist;if(void 0!==u&&u.list&&(a=u.list),void 0!==c&&s.push(c),void 0!==h&&"check"===i.__listType&&s.push(h),void 0!==r){s.push(...P(r));for(let t=0;t<e.length;t++)t!==n&&o.push(i.__tag+t)}if(void 0!==a){const e=P(a);t>1?s.push(...e):o.push(...e)}}o.length>0&&n(e,...o),s.length>0&&r(e,...s)}function Fe(e){let t;if(function(e){return i(e)&&"ol"===e.nodeName.toLowerCase()}(e)){const n=e.start;t=Ae("number",n)}else t=function(e){if("check"===e.getAttribute("__lexicallisttype")||e.classList.contains("contains-task-list")||"1"===e.getAttribute("data-is-checklist"))return!0;for(const t of e.childNodes)if(i(t)&&t.hasAttribute("aria-checked"))return!0;return!1}(e)?Ae("check"):Ae("bullet");return F(t,e),{after:e=>function(e,t){const n=t.createListItemNode.bind(t),r=[];for(let t=0;t<e.length;t++){const i=e[t];if(xe(i)){r.push(i);const e=i.getChildren();e.length>1&&e.forEach(e=>{Ee(e)&&r.push(n().append(e))})}else r.push(n().append(i))}return r}(e,t),node:t}}const Pe={ol:"number",ul:"bullet"};function Ae(e="number",t=1){return C(new Le(e,t))}function Ee(e){return e instanceof Le}const Oe=O("INSERT_CHECK_LIST_COMMAND");function Ie(e,t){const n=t&&t.disableTakeFocusOnClick||!1,r="boolean"==typeof n?()=>n:n.peek.bind(n),l=e=>{const t=e.target;if(!i(t))return!1;const n=t.__lexicalCheckListLastHandled;return void 0!==n&&e.timeStamp-n<500},u=e=>{const t=e.target;i(t)&&(t.__lexicalCheckListLastHandled=e.timeStamp)},h=e=>{l(e)||(u(e),De(e,r()))},g=e=>{"touch"===e.pointerType&&(l(e)||(u(e),De(e,r())))},d=e=>{!function(e,t){we(e,()=>{e.preventDefault(),t&&e.stopPropagation()})}(e,r())};return s(e.registerCommand(Oe,()=>(he("check"),!0),I),e.registerCommand(w,t=>$e(t,e,!1),I),e.registerCommand(D,t=>$e(t,e,!0),I),e.registerCommand(M,()=>{if(null!=Me()){const t=e.getRootElement();return null!=t&&t.focus(),!0}return!1},I),e.registerCommand($,t=>{const n=Me();return!(null==n||!e.isEditable())&&(e.update(()=>{const e=R(n);xe(e)&&(t.preventDefault(),e.toggleChecked())}),!0)},I),e.registerCommand(K,t=>e.getEditorState().read(()=>{const n=c();if(a(n)&&n.isCollapsed()){const{anchor:r}=n,i="element"===r.type;if(i||0===r.offset){const n=r.getNode(),s=o(n,e=>f(e)&&!e.isInline());if(xe(s)){const r=s.getParent();if(Ee(r)&&"check"===r.getListType()&&(i||s.getFirstDescendant()===n)){const n=e.getElementByKey(s.__key);if(null!=n&&document.activeElement!==n)return n.focus(),t.preventDefault(),!0}}}}return!1}),I),e.registerRootListener(e=>{if(null!==e)return e.addEventListener("click",h),e.addEventListener("pointerup",g),e.addEventListener("pointerdown",d,{capture:!0}),e.addEventListener("mousedown",d,{capture:!0}),e.addEventListener("touchstart",d,{capture:!0,passive:!1}),()=>{e.removeEventListener("click",h),e.removeEventListener("pointerup",g),e.removeEventListener("pointerdown",d,{capture:!0}),e.removeEventListener("mousedown",d,{capture:!0}),e.removeEventListener("touchstart",d,{capture:!0})}}))}function we(e,t){const n=e.target;if(!i(n))return;const r=n.firstChild;if(i(r)&&("UL"===r.tagName||"OL"===r.tagName))return;const s=n.parentNode;if(!s||"check"!==s.__lexicalListType)return;let o=null,c=null;if("clientX"in e)o=e.clientX;else if("touches"in e){const t=e.touches;t.length>0&&(o=t[0].clientX,c="touch")}if(null==o)return;const a=n.getBoundingClientRect(),u=o/l(n),h=window.getComputedStyle?window.getComputedStyle(n,"::before"):{width:"0px"},g=parseFloat(h.width),d="touch"===c||"pointerType"in e&&"touch"===e.pointerType?32:0;("rtl"===n.dir?u<a.right+d&&u>a.right-g-d:u>a.left-d&&u<a.left+g+d)&&t()}function De(e,t){we(e,()=>{if(i(e.target)){const n=e.target,r=B(n);null!=r&&r.isEditable()&&r.update(()=>{const e=R(n);xe(e)&&(t?(W(U),W(J)):n.focus(),e.toggleChecked())})}})}function Me(){const e=document.activeElement;return i(e)&&"LI"===e.tagName&&null!=e.parentNode&&"check"===e.parentNode.__lexicalListType?e:null}function $e(e,t,n){const r=Me();return null!=r&&t.update(()=>{const i=R(r);if(!xe(i))return;const s=function(e,t){let n=t?e.getPreviousSibling():e.getNextSibling(),r=e;for(;null==n&&xe(r);)r=r.getParentOrThrow().getParent(),null!=r&&(n=t?r.getPreviousSibling():r.getNextSibling());for(;xe(n);){const e=t?n.getLastChild():n.getFirstChild();if(!Ee(e))return n;n=t?e.getLastChild():e.getFirstChild()}return null}(i,n);if(null!=s){s.selectStart();const n=t.getElementByKey(s.__key);null!=n&&(e.preventDefault(),setTimeout(()=>{n.focus()},0))}}),!1}const Re=O("UPDATE_LIST_START_COMMAND"),Ke=O("INSERT_UNORDERED_LIST_COMMAND"),Be=O("INSERT_ORDERED_LIST_COMMAND"),We=O("REMOVE_LIST_COMMAND");function Ue(e,t){return s(e.registerCommand(Be,()=>(he("number"),!0),I),e.registerCommand(Re,e=>{const{listNodeKey:t,newStart:n}=e,r=V(t);return!!Ee(r)&&("number"===r.getListType()&&(r.setStart(n),me(r)),!0)},I),e.registerCommand(Ke,()=>(he("bullet"),!0),I),e.registerCommand(We,()=>(pe(),!0),I),e.registerCommand(q,()=>Ce(!!(t&&t.restoreNumbering)),I),e.registerNodeTransform(ve,e=>{const t=e.getFirstChild();if(t){if(u(t)){const n=t.getStyle(),r=t.getFormat();e.getTextStyle()!==n&&e.setTextStyle(n),e.getTextFormat()!==r&&e.setTextFormat(r)}}else{const t=c();a(t)&&(t.style!==e.getTextStyle()||t.format!==e.getTextFormat())&&t.isCollapsed()&&e.is(t.anchor.getNode())&&e.setTextStyle(t.style).setTextFormat(t.format)}}),e.registerNodeTransform(z,e=>{const t=e.getParent();if(xe(t)&&e.is(t.getFirstChild())){const n=e.getStyle(),r=e.getFormat();n===t.getTextStyle()&&r===t.getTextFormat()||t.setTextStyle(n).setTextFormat(r)}}))}function Je(e){const t=e=>{const t=e.getParent();if(Ee(e.getFirstChild())||!Ee(t))return;const n=o(e,e=>xe(e)&&Ee(e.getParent())&&xe(e.getPreviousSibling()));if(null===n&&e.getIndent()>0)e.setIndent(0);else if(xe(n)){const r=n.getPreviousSibling();if(xe(r)){const n=function(e){let t=e,n=t.getFirstChild();for(;Ee(n);){const e=n.getLastChild();if(!xe(e))break;t=e,n=t.getFirstChild()}return t}(r),i=n.getParent();if(Ee(i)){const n=oe(i);n+1<oe(t)&&e.setIndent(n)}}}};return e.registerNodeTransform(Le,e=>{const n=[e];for(;n.length>0;){const e=n.shift();if(Ee(e))for(const r of e.getChildren())if(xe(r)){t(r);const e=r.getFirstChild();Ee(e)&&n.push(e)}}})}const Ve=H({build:(e,t,n)=>Q(t),config:j({hasStrictIndent:!1,shouldPreserveNumbering:!1}),name:"@lexical/list/List",nodes:()=>[Le,ve],register(e,t,n){const r=n.getOutput();return s(Y(()=>Ue(e,{restoreNumbering:r.shouldPreserveNumbering.value})),Y(()=>r.hasStrictIndent.value?Je(e):void 0))}}),qe=H({build:(e,t)=>Q(t),config:j({disableTakeFocusOnClick:!1}),dependencies:[Ve],name:"@lexical/list/CheckList",register:(e,t,n)=>Ie(e,n.getOutput())});function ze(e){const t=[];for(const n of e)if(xe(n)){t.push(n);const e=n.getChildren();if(e.length>1)for(const n of e)Ee(n)&&t.push(Se().append(n))}else t.push(Se().append(n));return t}const He=ee({$import:(e,t)=>{let n;var r;return ne(t,"ol")?n=Ae("number",t.start):n=(r=t).matches('[__lexicallisttype="check"], .contains-task-list, [data-is-checklist="1"]')||null!==r.querySelector(":scope > [aria-checked]")?Ae("check"):Ae("bullet"),F(n,t),[n.splice(0,0,re(ze(e.$importChildren(t)),t))]},match:te.tag("ol","ul"),name:"@lexical/list/list"});function je(e,t){if(1!==t.length)return t;const n=t[0];return L(n)&&!e.getFormatType()&&n.getFormatType()?(e.setFormat(n.getFormatType()),n.getChildren()):t}function Xe(e){const t=e=>ie(e)&&!Ee(e);if(!e.some(t))return e;const n=[];let r=[];const i=()=>{r.length>0&&(n.push(r),r=[])};for(const s of e)t(s)?(i(),n.push(f(s)?s.getChildren():[s])):r.push(s);i();const s=[];for(const e of n)s.length>0&&s.push(G()),s.push(...e);return s}const Ge=ee({$import:(e,t)=>{const n=t.getAttribute("aria-checked"),r=Se("true"===n||"false"!==n&&void 0);return N(r,t),F(r,t),[r.splice(0,0,Xe(je(r,e.$importChildren(t))))]},match:te.tag("li"),name:"@lexical/list/li"});function Qe(e,t,n){const r=ne(n,"input")?n:n.querySelector('input[type="checkbox"]');if(!r||"checkbox"!==r.getAttribute("type"))return[];const i=Se(r.hasAttribute("checked"));return N(i,t),F(i,t),[i.splice(0,0,Xe(je(i,e.$importChildren(t))))]}const Ye={$accepts:e=>xe(e)||Ee(e),$packageRun:e=>[Se().splice(0,0,e)],name:"ListSchema"},Ze=[ee({$import:(e,t,n)=>{const r=t.querySelector(':scope > input[type="checkbox"]');return r?Qe(e,t,r):n()},match:te.tag("li").classAll("task-list-item"),name:"@lexical/list/li-task-list-item"}),ee({$import:(e,t,n)=>{const r=t.querySelector(":scope > .checkbox-wrapper");if(!r)return n();const i=r.querySelector(':scope > input[type="checkbox"]');return i?Qe(e,t,i):n()},match:te.tag("li").classAll("joplin-checkbox"),name:"@lexical/list/li-joplin-checkbox"}),He,Ge],et=H({dependencies:[Ve,X(Z,{rules:Ze})],name:"@lexical/list/Import"});function tt(e,t){e.update(()=>he(t))}function nt(e){e.update(()=>pe())}export{Se as $createListItemNode,Ae as $createListNode,oe as $getListDepth,Ce as $handleListInsertParagraph,he as $insertList,xe as $isListItemNode,Ee as $isListNode,pe as $removeList,qe as CheckListExtension,Oe as INSERT_CHECK_LIST_COMMAND,Be as INSERT_ORDERED_LIST_COMMAND,Ke as INSERT_UNORDERED_LIST_COMMAND,Ve as ListExtension,et as ListImportExtension,Ze as ListImportRules,ve as ListItemNode,Le as ListNode,Ye as ListSchema,We as REMOVE_LIST_COMMAND,Re as UPDATE_LIST_START_COMMAND,tt as insertList,Ie as registerCheckList,Ue as registerList,Je as registerListStrictIndentTransform,nt as removeList};
@@ -23,8 +23,11 @@ export declare const ListSchema: ChildSchema;
23
23
  */
24
24
  export declare const ListImportRules: (import("@lexical/html").DOMImportRule<import("@lexical/html").ElementSelectorBuilder<HTMLOListElement | HTMLUListElement, Record<string, never>>> | import("@lexical/html").DOMImportRule<import("@lexical/html").ElementSelectorBuilder<HTMLLIElement, Record<string, never>>>)[];
25
25
  /**
26
- * Bundles {@link ListImportRules} (plus {@link CoreImportExtension}) into
27
- * a single dependency.
26
+ * Bundles {@link ListImportRules} together with the runtime
27
+ * {@link ListExtension}. The application is expected to already have
28
+ * `CoreImportExtension` (or some equivalent) in its dependency graph —
29
+ * the core/text/paragraph/inline-format rules are a shared baseline,
30
+ * not something this leaf importer should re-declare.
28
31
  *
29
32
  * @experimental
30
33
  */
package/package.json CHANGED
@@ -8,15 +8,15 @@
8
8
  "list"
9
9
  ],
10
10
  "license": "MIT",
11
- "version": "0.45.0",
11
+ "version": "0.45.1-dev.0",
12
12
  "main": "./dist/LexicalList.js",
13
13
  "types": "./dist/index.d.ts",
14
14
  "dependencies": {
15
- "@lexical/extension": "0.45.0",
16
- "@lexical/internal": "0.45.0",
17
- "lexical": "0.45.0",
18
- "@lexical/utils": "0.45.0",
19
- "@lexical/html": "0.45.0"
15
+ "@lexical/extension": "0.45.1-dev.0",
16
+ "@lexical/internal": "0.45.1-dev.0",
17
+ "@lexical/html": "0.45.1-dev.0",
18
+ "@lexical/utils": "0.45.1-dev.0",
19
+ "lexical": "0.45.1-dev.0"
20
20
  },
21
21
  "repository": {
22
22
  "type": "git",
@@ -9,13 +9,16 @@
9
9
  import type {ChildSchema, DOMImportContext} from '@lexical/html';
10
10
 
11
11
  import {
12
- CoreImportExtension,
12
+ $isBlockLevel,
13
+ $propagateTextAlignToBlockChildren,
13
14
  defineImportRule,
14
15
  DOMImportExtension,
15
16
  isElementOfTag,
16
17
  sel,
17
18
  } from '@lexical/html';
18
19
  import {
20
+ $createLineBreakNode,
21
+ $isElementNode,
19
22
  $isParagraphNode,
20
23
  $setDirectionFromDOM,
21
24
  $setFormatFromDOM,
@@ -80,7 +83,21 @@ const ListRule = defineImportRule({
80
83
  node = $createListNode('bullet');
81
84
  }
82
85
  $setDirectionFromDOM(node, el);
83
- return [node.splice(0, 0, $normalizeListChildren(ctx.$importChildren(el)))];
86
+ // Propagate the list's `text-align` onto each `ListItemNode` child
87
+ // (legacy `wrapContinuousInlines` did the same), so pasting
88
+ // `<ul style="text-align: left"><li>…</li></ul>` ends up with the
89
+ // alignment on the list items where the reconciler renders it as
90
+ // `style="text-align: left"`.
91
+ return [
92
+ node.splice(
93
+ 0,
94
+ 0,
95
+ $propagateTextAlignToBlockChildren(
96
+ $normalizeListChildren(ctx.$importChildren(el)),
97
+ el,
98
+ ),
99
+ ),
100
+ ];
84
101
  },
85
102
  match: sel.tag('ol', 'ul'),
86
103
  name: '@lexical/list/list',
@@ -111,6 +128,61 @@ function $liftFormatFromSingleParagraph(
111
128
  return children;
112
129
  }
113
130
 
131
+ /**
132
+ * Collapse block children of a `<li>` into inline-with-line-break form: a
133
+ * `ListItemNode` is an inline-level container, so any block child marks a
134
+ * boundary. Contiguous inline siblings are kept together as a single run and
135
+ * one {@link $createLineBreakNode} is inserted between runs — reproducing the
136
+ * legacy `wrapContinuousInlines` + `$unwrapArtificialNodes` shape
137
+ * (`<li>1<div>2</div>3</li>` → `1<br>2<br>3`) without the
138
+ * `ArtificialNode__DO_NOT_USE` marker.
139
+ *
140
+ * Boundaries are detected with {@link $isBlockLevel}, NOT `$isParagraphNode`:
141
+ * the `<div>`/`<section>`/… `TransparentBlockRule` happens to emit
142
+ * `ParagraphNode`s, but a `<blockquote>` (`QuoteNode`), heading
143
+ * (`HeadingNode`), or block decorator (`HorizontalRuleNode`, …) is just as
144
+ * much a block boundary and must not be silently spliced into the list item
145
+ * as-is. A nested `ListNode` is the one deliberate exception — it is a valid
146
+ * list-item child that {@link $normalizeListChildren} lifts into a sibling,
147
+ * so it is preserved here rather than unwrapped.
148
+ */
149
+ function $flattenListItemBlocks(children: LexicalNode[]): LexicalNode[] {
150
+ const $isBoundary = (node: LexicalNode): boolean =>
151
+ $isBlockLevel(node) && !$isListNode(node);
152
+ if (!children.some($isBoundary)) {
153
+ return children;
154
+ }
155
+ // Partition into segments — each maximal run of inline siblings, and each
156
+ // boundary's own content — then join the segments with a single line break.
157
+ const segments: LexicalNode[][] = [];
158
+ let inlineRun: LexicalNode[] = [];
159
+ const flushInlineRun = () => {
160
+ if (inlineRun.length > 0) {
161
+ segments.push(inlineRun);
162
+ inlineRun = [];
163
+ }
164
+ };
165
+ for (const child of children) {
166
+ if ($isBoundary(child)) {
167
+ flushInlineRun();
168
+ // Unwrap a block ElementNode to its inline content; a childless block
169
+ // DecoratorNode stands on its own line.
170
+ segments.push($isElementNode(child) ? child.getChildren() : [child]);
171
+ } else {
172
+ inlineRun.push(child);
173
+ }
174
+ }
175
+ flushInlineRun();
176
+ const out: LexicalNode[] = [];
177
+ for (const segment of segments) {
178
+ if (out.length > 0) {
179
+ out.push($createLineBreakNode());
180
+ }
181
+ out.push(...segment);
182
+ }
183
+ return out;
184
+ }
185
+
114
186
  const ListItemRule = defineImportRule({
115
187
  $import: (ctx, el) => {
116
188
  const ariaChecked = el.getAttribute('aria-checked');
@@ -127,7 +199,12 @@ const ListItemRule = defineImportRule({
127
199
  node.splice(
128
200
  0,
129
201
  0,
130
- $liftFormatFromSingleParagraph(node, ctx.$importChildren(el)),
202
+ // Lift a sole wrapping paragraph's format onto the item *before*
203
+ // flattening, otherwise the paragraph would already be unwrapped and
204
+ // its alignment lost.
205
+ $flattenListItemBlocks(
206
+ $liftFormatFromSingleParagraph(node, ctx.$importChildren(el)),
207
+ ),
131
208
  ),
132
209
  ];
133
210
  },
@@ -154,7 +231,9 @@ function $buildChecklistItem(
154
231
  node.splice(
155
232
  0,
156
233
  0,
157
- $liftFormatFromSingleParagraph(node, ctx.$importChildren(el)),
234
+ $flattenListItemBlocks(
235
+ $liftFormatFromSingleParagraph(node, ctx.$importChildren(el)),
236
+ ),
158
237
  ),
159
238
  ];
160
239
  }
@@ -223,14 +302,16 @@ export const ListImportRules = [
223
302
  ];
224
303
 
225
304
  /**
226
- * Bundles {@link ListImportRules} (plus {@link CoreImportExtension}) into
227
- * a single dependency.
305
+ * Bundles {@link ListImportRules} together with the runtime
306
+ * {@link ListExtension}. The application is expected to already have
307
+ * `CoreImportExtension` (or some equivalent) in its dependency graph —
308
+ * the core/text/paragraph/inline-format rules are a shared baseline,
309
+ * not something this leaf importer should re-declare.
228
310
  *
229
311
  * @experimental
230
312
  */
231
313
  export const ListImportExtension = defineExtension({
232
314
  dependencies: [
233
- CoreImportExtension,
234
315
  ListExtension,
235
316
  configExtension(DOMImportExtension, {rules: ListImportRules}),
236
317
  ],