@lexical/list 0.51.1-nightly.20260925.0 → 0.52.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.
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- import{$getNearestNodeOfType as t,calculateZoomLevel as e}from"@lexical/utils";import{$getSelection as n,$isRangeSelection as r,$isTextNode as i,$isRootOrShadowRoot as s,$createParagraphNode as o,$copyNode as l,$isElementNode as c,$getSlotHost as a,$isLeafNode as u,$setPointFromCaret as g,$normalizeCaret as d,$getChildCaret as f,getterTableOf as h,setterTableOf as p,setterDefaultOf as m,aliasTableOf as _,$applyNodeReplacement as y,ElementNode as C,buildImportMap as v,$getSiblingCaret as x,$insertNodeToNearestRootAtCaret as S,$rewindSiblingCaret as b,$getDocument as k,setDOMStyleFromCSS as T,isHTMLElement as L,$isParagraphNode as N,nodeSchema as F,withField as P,numberValue as A,withAccessors as I,optional as O,booleanValue as E,$setFormatFromDOM as M,$setDirectionFromDOM as w,normalizeClassNames as D,removeClassNamesFromElement as $,addClassNamesToElement as R,getStyleObjectFromCSS as K,enumValue as W,aliasedValue as B,createCommand as U,mergeRegister as z,COMMAND_PRIORITY_LOW as q,KEY_ARROW_DOWN_COMMAND as V,KEY_ARROW_UP_COMMAND as J,KEY_ESCAPE_COMMAND as j,KEY_SPACE_COMMAND as H,$getNearestNodeFromDOMNode as X,KEY_ARROW_LEFT_COMMAND as G,$findMatchingParent as Z,getActiveElement as Q,registerEventListeners as Y,IS_FIREFOX as tt,registerEventListener as et,getNearestEditorFromDOMNode as nt,$addUpdateTag as rt,SKIP_SELECTION_FOCUS_TAG as it,SKIP_DOM_SELECTION_TAG as st,$createLineBreakNode as ot,$getNodeByKey as lt,INSERT_PARAGRAPH_COMMAND as ct,KEY_BACKSPACE_COMMAND as at,COMMAND_PRIORITY_BEFORE_EDITOR as ut,TextNode as gt}from"lexical";import{effect as dt}from"@lexical/extension/signals";import{namedSignals as ft}from"@lexical/extension/namedSignals";import{sel as ht,isElementOfTag as pt,$propagateTextAlignToBlockChildren as mt,$isBlockLevel as _t,CoreImportExtension as yt,DOMImportExtension as Ct,ImportOverlays as vt,defineOverlayRules as xt,createImportState as St,InlineSchema as bt}from"@lexical/html";function kt(t,...e){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",t);for(const t of e)r.append("v",t);throw n.search=r.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function Tt(t){let e=1,n=t.getParent();for(;null!=n;){if(Yt(n)){const t=n.getParent();if(oe(t)){e++,n=t.getParent();continue}kt(40)}return e}return e}function Lt(t){const e=t.getParent();oe(e)||kt(40);let n=e,r=e;for(;null!==r;)r=r.getParent(),oe(r)&&(n=r);return n}function Nt(t){let e=[];const n=t.getChildren().filter(Yt);for(let t=0;t<n.length;t++){const r=n[t],i=r.getFirstChild();oe(i)?e=e.concat(Nt(i)):e.push(r)}return e}function Ft(t){return Yt(t)&&oe(t.getFirstChild())}function Pt(t,e){return e.getValue()}function At(t,e){return Yt(t)&&(0===e.length||1===e.length&&t.is(e[0])&&0===t.getChildrenSize())}function It(t,e){return oe(t)?l(t).setListType(e):se(e)}function Ot(t){const e=n();if(null!==e){let n=e.getNodes();if(r(e)){const[r]=e.getStartEndPoints(),i=r.getNode(),l=i.getParent();if(s(i)){const t=i.getFirstChild();if(t)n=t.selectStart().getNodes();else{const t=o();i.append(t),n=t.select().getNodes()}}else if(At(i,n)){if(s(l)){const e=se(t);i.replace(e);const n=Qt();c(i)&&(n.setFormat(i.getFormatType()),n.setIndent(i.getIndent())),e.append(n)}else if(Yt(i)){const e=i.getParentOrThrow();if(null===a(e)){const n=It(e,t);Et(n,e.getChildren()),e.replace(n)}}return}}const i=new Set;for(let e=0;e<n.length;e++){const r=n[e];if(c(r)&&r.isEmpty()&&!Yt(r)&&null===a(r)&&!i.has(r.getKey())){Mt(r,t);continue}let o=u(r)?r.getParent():Yt(r)&&r.isEmpty()?r:null;for(;null!=o;){const e=o.getKey();if(oe(o)){if(!i.has(e)&&null===a(o)){const n=It(o,t);Et(n,o.getChildren()),o.replace(n),i.add(e)}break}{const n=o.getParent();if(s(n)&&!i.has(e)){i.add(e),Mt(o,t);break}o=n}}}}}function Et(t,e){t.splice(t.getChildrenSize(),0,e)}function Mt(t,e){if(oe(t))return t;const i=t.getPreviousSibling(),s=t.getNextSibling(),o=Qt();let l;if(Et(o,t.getChildren()),oe(i)&&e===i.getListType())i.append(o),oe(s)&&e===s.getListType()&&(Et(i,s.getChildren()),s.remove()),l=i;else if(oe(s)&&e===s.getListType())s.getFirstChildOrThrow().insertBefore(o),l=s;else{const n=se(e);n.append(o),t.replace(n),l=n}o.setFormat(t.getFormatType()),o.setIndent(t.getIndent());const c=n();return r(c)&&(l.getKey()===c.anchor.key&&c.anchor.set(o.getKey(),c.anchor.offset,"element"),l.getKey()===c.focus.key&&c.focus.set(o.getKey(),c.focus.offset,"element")),t.remove(),l}function wt(t,e){const n=t.getLastChild(),r=e.getFirstChild();n&&r&&Ft(n)&&Ft(r)&&n.getFirstChild().getListType()===r.getFirstChild().getListType()&&(wt(n.getFirstChild(),r.getFirstChild()),r.remove());const i=e.getChildren();i.length>0&&t.append(...i),e.remove()}function Dt(){const e=n();if(r(e)){const n=new Set,r=e.getNodes(),i=e.anchor.getNode();if(At(i,r))n.add(Lt(i));else for(let e=0;e<r.length;e++){const i=r[e];if(u(i)){const e=t(i,Ht);null!=e&&n.add(Lt(e))}}for(const t of n){if(null!==a(t))continue;let n=t;const r=Nt(t);for(const t of r){const r=o().setTextStyle(e.style).setTextFormat(e.format);r.setFormat(t.getFormatType()).setIndent(t.getIndent()).setDirection(t.getDirection()).setStyle(t.getStyle()),Et(r,t.getChildren()),n.insertAfter(r),n=r,t.__key===e.anchor.key&&g(e.anchor,d(f(r,"next"))),t.__key===e.focus.key&&g(e.focus,d(f(r,"next"))),t.remove()}t.remove()}}}function $t(t){const e="check"!==t.getListType();let n=t.getStart();for(const r of t.getChildren())Yt(r)&&(r.getValue()!==n&&r.setValue(n),e&&null!=r.getLatest().__checked&&r.setChecked(void 0),oe(r.getFirstChild())||n++)}function Rt(t){const e=new Set;if(Ft(t)||e.has(t.getKey()))return;const n=t.getParent(),r=t.getNextSibling(),i=t.getPreviousSibling();if(Ft(r)&&Ft(i)){const n=i.getFirstChild();if(oe(n)){n.append(t);const i=r.getFirstChild();oe(i)&&n.getListType()===i.getListType()&&(Et(n,i.getChildren()),r.remove(),e.add(r.getKey()))}}else if(Ft(r)){const e=r.getFirstChild();if(oe(e)){const n=e.getFirstChild();null!==n&&n.insertBefore(t)}}else if(Ft(i)){const e=i.getFirstChild();oe(e)&&e.append(t)}else if(oe(n)){const e=l(t),s=l(n);e.append(s),s.append(t),i?i.insertAfter(e):r?r.insertBefore(e):n.append(e)}}function Kt(t){if(Ft(t))return;const e=t.getParent(),n=e?e.getParent():void 0;if(oe(n?n.getParent():void 0)&&Yt(n)&&oe(e)){const r=e?e.getFirstChild():void 0,i=e?e.getLastChild():void 0;if(t.is(r))n.insertBefore(t),e.isEmpty()&&n.remove();else if(t.is(i))n.insertAfter(t),e.isEmpty()&&n.remove();else{const r=l(t),i=l(e);r.append(i),t.getPreviousSiblings().forEach(t=>i.append(t));const s=l(t),o=l(e);s.append(o),Et(o,t.getNextSiblings()),n.insertBefore(r),n.insertAfter(s),n.replace(t)}}}function Wt(t=!1){const e=n();if(!r(e)||!e.isCollapsed())return!1;const c=e.anchor.getNode();let a=null;if(Yt(c)&&0===c.getChildrenSize())a=c;else if(i(c)){const t=c.getParent();Yt(t)&&t.getChildren().every(t=>i(t)&&""===t.getTextContent().trim())&&(a=t)}if(null===a)return!1;const u=Lt(a),g=a.getParent();oe(g)||kt(40);const d=g.getParent();let f;if(s(d))f=o(),u.insertAfter(f);else{if(!Yt(d))return!1;f=l(d),d.insertAfter(f)}f.setTextStyle(e.style).setTextFormat(e.format).select();const h=a.getNextSiblings();if(h.length>0){const e=t?Pt(0,a):1,n=l(g).setStart(e);if(Yt(f)){const t=l(f);t.append(n),f.insertAfter(t)}else f.insertAfter(n);n.append(...h)}return function(t){let e=t;for(;null==e.getNextSibling()&&null==e.getPreviousSibling();){const t=e.getParent();if(null==t||!Yt(t)&&!oe(t))break;e=t}e.remove()}(a),!0}const Bt=/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/;function Ut(t,e){if("number"==typeof t)return Number.isFinite(t)?t:e;if("string"!=typeof t||!Bt.test(t))return e;const n=Number(t);return Number.isFinite(n)?n:e}function zt(t,e){t.__listType=e.__listType,t.__start=e.__start,t.__tag=e.__tag}const qt=t=>{const e=h(t,"format"),n=p(t,"format"),r=m(t,"format"),i=_(t,"listType",0);return{exportJSON:function(t){const n=t.__textFormat,r=t.__textStyle,i=(0!==n||""!==r)&&t.shouldSerializeTextStyles();return{children:[],listType:t.__listType,start:t.__start,tag:t.__tag,direction:t.__dir,format:e[t.__format],indent:t.__indent,textFormat:0!==n&&i?n:void 0,textStyle:""!==r&&i?r:void 0,type:t.__type,version:1}},exportCompactJSON:function(t){const n=t.__textFormat,r=t.__textStyle,i=(0!==n||""!==r)&&t.shouldSerializeTextStyles(),s={type:t.__type,children:[]},o=t.__listType;void 0!==o&&"number"!==o&&(s.listType=o);const l=t.__start;void 0!==l&&1!==l&&(s.start=l);const c=t.__dir;null!=c&&(s.direction=c);const a=e[t.__format];void 0!==a&&""!==a&&(s.format=a);const u=t.__indent;return void 0!==u&&0!==u&&(s.indent=u),void 0!==n&&0!==n&&i&&(s.textFormat=n),void 0!==r&&""!==r&&i&&(s.textStyle=r),s},updateFromJSON:function(t,e){const s=e.direction;t.__dir=null===s||"ltr"===s||"rtl"===s?s:null;const o=e.format;t.__format="string"==typeof o&&o in n?n[o]:r,t.__indent=function(t){const e=Ut(t,0);return e>=0&&e<=Infinity&&Number.isInteger(e)?e:0}(e.indent),t.__textFormat=Ut(e.textFormat,0);const l=e.textStyle;t.__textStyle="string"==typeof l?l:"";const c=e.listType;return t.setListType("string"==typeof c&&c in i?i[c]:"number"===c||"bullet"===c||"check"===c?c:"number"),t.__start=Ut(e.start,1),t},afterCloneFrom:zt}};function Vt(t,e){t.__checked=e.__checked,t.__value=e.__value}const Jt=t=>{const e=h(t,"format"),n=p(t,"format"),r=m(t,"format");return{exportJSON:function(t){const n=t.__textFormat,r=t.__textStyle,i=(0!==n||""!==r)&&t.shouldSerializeTextStyles();return{children:[],checked:t.getChecked(),indent:t.getIndent(),value:t.__value,direction:t.__dir,format:e[t.__format],textFormat:0!==n&&i?n:void 0,textStyle:""!==r&&i?r:void 0,type:t.__type,version:1}},exportCompactJSON:function(t){const n=t.__textFormat,r=t.__textStyle,i=(0!==n||""!==r)&&t.shouldSerializeTextStyles(),s={type:t.__type,children:[]},o=t.getChecked();void 0!==o&&(s.checked=o);const l=t.getIndent();void 0!==l&&0!==l&&(s.indent=l);const c=t.__value;void 0!==c&&1!==c&&(s.value=c);const a=t.__dir;null!=a&&(s.direction=a);const u=e[t.__format];return void 0!==u&&""!==u&&(s.format=u),void 0!==n&&0!==n&&i&&(s.textFormat=n),void 0!==r&&""!==r&&i&&(s.textStyle=r),s},updateFromJSON:function(t,e){const i=e.direction;t.__dir=null===i||"ltr"===i||"rtl"===i?i:null;const s=e.format;t.__format="string"==typeof s&&s in n?n[s]:r,t.setIndent(function(t){const e=Ut(t,NaN);return Number.isFinite(e)&&Number.isInteger(e)?e<0?0:e>128?128:e:0}(e.indent)),t.__textFormat=Ut(e.textFormat,0);const o=e.textStyle;t.__textStyle="string"==typeof o?o:"";const l=e.checked;return t.__checked=void 0===l?void 0:"boolean"==typeof l&&l,t.__value=Ut(e.value,1),t},afterCloneFrom:Vt}},jt=/* @__PURE__ */F()({checked:/* @__PURE__ */I(/* @__PURE__ */O(/* @__PURE__ */E()),{setter:{field:"__checked"}}),indent:/* @__PURE__ */A(0,{clamp:!0,integer:!0,max:128,min:0}),value:/* @__PURE__ */P(/* @__PURE__ */A(1),{field:"__value"})});class Ht extends C{__value;__checked;$config(){return this.config("listitem",{$transform:t=>{const e=t.getParent();if(oe(e))"check"!==e.getListType()&&null!=t.getChecked()&&t.setChecked(void 0);else if(e){const n=t.createParentElementNode();oe(n)||kt(340);const r=[t];for(const e of["previous","next"]){r.reverse();for(const{origin:n}of x(t,e)){if(!Yt(n))break;r.push(n)}}t.insertBefore(n),n.splice(0,0,r),s(e)||(S(n,b(x(n,"next")),{$shouldSplit:()=>!1,removeEmptyDestination:!0}),e.isEmpty()&&e.isAttached()&&e.remove())}},extends:C,generated:Jt,importDOM:v({li:()=>({conversion:Xt,priority:0})}),json:jt})}constructor(t=1,e=void 0,n){super(n),this.__value=void 0===t?1:t,this.__checked=e}createDOM(t){const e=k().createElement("li");return this.updateListItemDOM(null,e,t),e}updateListItemDOM(t,e,n){!function(t,e){const n=e.getParent();!oe(n)||"check"!==n.getListType()||oe(e.getFirstChild())?(t.removeAttribute("role"),t.removeAttribute("tabIndex"),t.removeAttribute("aria-checked")):(t.setAttribute("role","checkbox"),t.setAttribute("tabIndex","-1"),t.setAttribute("aria-checked",e.getChecked()?"true":"false"))}(e,this),e.value=this.__value,function(t,e,n){const r=e.list;if(!r)return;const i=r.listitem,s=r.nested&&r.nested.listitem,o=n.getParent(),l=oe(o)&&"check"===o.getListType(),c=n.getChecked(),a=n.getChildren().some(t=>oe(t)),u=[];void 0!==r.listitemChecked&&u.push(r.listitemChecked),void 0!==r.listitemUnchecked&&u.push(r.listitemUnchecked),void 0!==s&&u.push(...D(s)),u.length>0&&$(t,...u);const g=[];if(void 0!==i&&g.push(...D(i)),l){const t=c?r.listitemChecked:r.listitemUnchecked;void 0!==t&&g.push(t)}void 0!==s&&a&&g.push(...D(s)),g.length>0&&R(t,...g)}(e,n.theme,this);const r=t?t.__style:"",i=this.__style;r!==i&&T(e.style,i,r),function(t,e,n){const r=e.__textStyle,i=n?n.__textStyle:"";if(null!==n&&i===r)return;const s=K(r);for(const e in s)t.style.setProperty(`--listitem-marker-${e}`,s[e]);if(""!==i)for(const e in K(i))e in s||t.style.removeProperty(`--listitem-marker-${e}`)}(e,this,t)}updateDOM(t,e,n){const r=e;return this.updateListItemDOM(t,r,n),!1}exportDOM(t){const e=this.createDOM(t._config),n=this.getFormatType();n&&(e.style.textAlign=n);const r=this.getDirection();return r&&(e.dir=r),Ft(this)?{after(t){if(L(t)){const e=t.previousElementSibling;if(L(e)&&"LI"===e.nodeName){for(;t.firstChild;)e.append(t.firstChild);t.remove()}}return t},element:e}:{element:e}}append(...t){for(let e=0;e<t.length;e++){const n=t[e];if(c(n)&&this.canMergeWith(n)){const t=n.getChildren();this.append(...t),n.remove()}else super.append(n)}return this}replace(t,e){if(Yt(t))return super.replace(t);this.setIndent(0);const i=this.getParentOrThrow();if(!oe(i))return t;if(i.__first===this.getKey())i.insertBefore(t);else if(i.__last===this.getKey())i.insertAfter(t);else{const e=l(i);let n=this.getNextSibling();for(;n;){const t=n;n=n.getNextSibling(),e.append(t)}i.insertAfter(t),t.insertAfter(e)}const s=this.__key;let o=0;if(e&&(c(t)||kt(139),o=t.getChildrenSize(),t.splice(o,0,this.getChildren())),e&&c(t)){const e=n();if(r(e))for(const n of e.getStartEndPoints())n.key===s&&"element"===n.type&&n.set(t.getKey(),o+n.offset,"element")}return this.remove(),0===i.getChildrenSize()&&i.remove(),t}insertAfter(t,e=!0){const n=this.getParentOrThrow();if(oe(n)||kt(39),Yt(t))return super.insertAfter(t,e);const r=this.getNextSiblings();if(n.insertAfter(t,e),0!==r.length){const i=l(n),s=r[0];"number"===i.getListType()&&Yt(s)&&i.setStart(Pt(0,s)),r.forEach(t=>i.append(t)),t.insertAfter(i,e)}return t}remove(t){const e=this.getPreviousSibling(),n=this.getNextSibling();super.remove(t),e&&n&&Ft(e)&&Ft(n)&&e.getFirstChild().getListType()===n.getFirstChild().getListType()&&(wt(e.getFirstChild(),n.getFirstChild()),n.remove())}resetOnCopyNodeFrom(t){super.resetOnCopyNodeFrom(t),t.getChecked()&&this.setChecked(!1)}insertNewAfter(t,e=!0){const n=l(this);return this.insertAfter(n,e),n}collapseAtStart(t){if(Ft(this))return!1;const e=this.getParentOrThrow();if(Yt(e.getParentOrThrow()))return Kt(this),!0;const n=o().append(...this.getChildren()),r=this.getNextSiblings();if(r.length>0){const t=l(e);t.append(...r),e.insertAfter(t)}return e.insertAfter(n),this.remove(),0===e.getChildrenSize()&&e.remove(),n.selectStart(),!0}getValue(){return this.getLatest().__value}setValue(t){const e=this.getWritable();return e.__value=t,e}getChecked(){const t=this.getLatest();let e;const n=this.getParent();return oe(n)&&(e=n.getListType()),"check"===e?Boolean(t.__checked):void 0}setChecked(t){const e=this.getWritable();return e.__checked=t,e}toggleChecked(){const t=this.getWritable();return t.setChecked(!t.__checked)}getIndent(){const t=this.getParent();if(null===t||!this.isAttached())return this.getLatest().__indent;let e=t.getParentOrThrow(),n=0;for(;Yt(e);)e=e.getParentOrThrow().getParentOrThrow(),n++;return n}setIndent(t){"number"!=typeof t&&kt(117),(t=Math.floor(t))>=0||kt(199);const e=t;let n=this.getIndent();for(;n!==e;)n<e?(Rt(this),n++):(Kt(this),n--);return this}canInsertAfter(t){return Yt(t)}canReplaceWith(t){return Yt(t)}canMergeWith(t){return Yt(t)||N(t)}extractWithChild(t,e){if(!r(e))return!1;const n=e.anchor.getNode(),i=e.focus.getNode();return this.isParentOf(n)&&this.isParentOf(i)&&this.getTextContent().length===e.getTextContent().length}isParentRequired(){return!0}createParentElementNode(){return se("bullet")}canMergeWhenEmpty(){return!0}}function Xt(t){if(t.classList.contains("task-list-item"))for(const e of t.children)if("INPUT"===e.tagName)return Gt(e);if(t.classList.contains("joplin-checkbox"))for(const e of t.children)if(e.classList.contains("checkbox-wrapper")&&e.children.length>0&&"INPUT"===e.children[0].tagName)return Gt(e.children[0]);const e=t.getAttribute("aria-checked"),n=Qt("true"===e||"false"!==e&&void 0);return M(n,t),{after:Zt.bind(null,n),node:w(n,t)}}function Gt(t){if("checkbox"!==t.getAttribute("type"))return{node:null};const e=Qt(t.hasAttribute("checked"));return{after:Zt.bind(null,e),node:e}}function Zt(t,e){const n=e[0];return 1===e.length&&N(n)&&!t.getFormatType()&&n.getFormatType()?(t.setFormat(n.getFormatType()),n.getChildren()):e}function Qt(t){return y(new Ht(void 0,t))}function Yt(t){return t instanceof Ht}const te={ol:"number",ul:"bullet"},ee=/* @__PURE__ */F()({listType:/* @__PURE__ */I(/* @__PURE__ */B(/* @__PURE__ */W(["number","bullet","check"]),te),{getter:{field:"__listType"}}),start:/* @__PURE__ */P(/* @__PURE__ */A(1),{field:"__start"}),tag:/* @__PURE__ */I(/* @__PURE__ */W(["ul","ol"]),{getter:{field:"__tag"},setter:null})});class ne extends C{__tag;__start;__listType;$config(){return this.config("list",{$transform:t=>{!function(t){const e=t.getNextSibling();oe(e)&&t.getListType()===e.getListType()&&wt(t,e)}(t),$t(t)},extends:C,generated:qt,importDOM:v({ol:()=>({conversion:ie,priority:0}),ul:()=>({conversion:ie,priority:0})}),json:ee})}constructor(t="number",e=1,n){super(n);const r=te[t]||t;this.__listType=r,this.__tag="number"===r?"ol":"ul",this.__start=e}getTag(){return this.getLatest().__tag}setListType(t){const e=this.getWritable();return e.__listType=t,e.__tag="number"===t?"ol":"ul",e}getListType(){return this.getLatest().__listType}getStart(){return this.getLatest().__start}setStart(t){const e=this.getWritable();return e.__start=t,e}createDOM(t,e){const n=this.__tag,r=k().createElement(n);return 1!==this.__start&&r.setAttribute("start",String(this.__start)),r.__lexicalListType=this.__listType,re(r,t.theme,this),r}updateDOM(t,e,n){return t.__tag!==this.__tag||t.__listType!==this.__listType||(re(e,n.theme,this),t.__start!==this.__start&&e.setAttribute("start",String(this.__start)),!1)}exportDOM(t){const e=this.createDOM(t._config,t);if(L(e)){1!==this.__start&&e.setAttribute("start",String(this.__start)),"check"===this.__listType&&e.setAttribute("__lexicalListType","check");const t=this.getDirection();t&&(e.dir=t)}return{element:e}}canBeEmpty(){return!1}canIndent(){return!1}splice(t,e,n){let r=n;for(let t=0;t<n.length;t++){const e=n[t];if(!Yt(e)){r===n&&(r=[...n]);const i=this.createListItemNode();!c(e)||oe(e)||e.isInline()?i.append(e):i.append(...e.getChildren()),r[t]=i}}return super.splice(t,e,r)}extractWithChild(t){return Yt(t)}createListItemNode(){return Qt()}}function re(t,e,n){const r=[],i=[],s=e.list;if(void 0!==s){const t=s[`${n.__tag}Depth`]||[],e=Tt(n)-1,o=e%t.length,l=t[o],c=s[n.__tag];let a;const u=s.nested,g=s.checklist;if(void 0!==u&&u.list&&(a=u.list),void 0!==c&&r.push(c),void 0!==g&&"check"===n.__listType&&r.push(g),void 0!==l){r.push(...D(l));for(let e=0;e<t.length;e++)e!==o&&i.push(...D(t[e]))}if(void 0!==a){const t=D(a);e>1?r.push(...t):i.push(...t)}}i.length>0&&$(t,...i),r.length>0&&R(t,...r)}function ie(t){let e;if(function(t){return L(t)&&"ol"===t.nodeName.toLowerCase()}(t)){const n=t.start;e=se("number",n)}else e=function(t){if("check"===t.getAttribute("__lexicallisttype")||t.classList.contains("contains-task-list")||"1"===t.getAttribute("data-is-checklist"))return!0;for(const e of t.childNodes)if(L(e)&&e.hasAttribute("aria-checked"))return!0;return!1}(t)?se("check"):se("bullet");return w(e,t),{after:t=>function(t,e){const n=e.createListItemNode.bind(e),r=[];for(let e=0;e<t.length;e++){const i=t[e];if(Yt(i)){r.push(i);const t=i.getChildren();t.length>1&&t.forEach(t=>{oe(t)&&r.push(n().append(t))})}else r.push(n().append(i))}return r}(t,e),node:e}}function se(t="number",e=1){return y(new ne(t,e))}function oe(t){return t instanceof ne}const le=new Set([" ","Alt","ArrowDown","ArrowLeft","ArrowUp","CapsLock","Control","Escape","Meta","Shift"]),ce=/* @__PURE__ */U("INSERT_CHECK_LIST_COMMAND");function ae(t,e){const i=e&&e.disableTakeFocusOnClick||!1,s="boolean"==typeof i?()=>i:i.peek.bind(i),o=t=>{const e=t.target;if(!L(e))return!1;const n=e.__lexicalCheckListLastHandled;return void 0!==n&&t.timeStamp-n<500};let l="none";const a=t=>{l=function(t,e){let n=!1;return ue(t,()=>{n=!0,t.preventDefault(),e&&t.stopPropagation()}),n}(t,s())?"checkMark":"content"},u=()=>{"content"===l&&de(t),l="none"};return z(t.registerCommand(ce,()=>(Ot("check"),!0),q),t.registerCommand(V,e=>pe(e,t,!1),q),t.registerCommand(J,e=>pe(e,t,!0),q),t.registerCommand(j,()=>{if(null!=he(t)){const e=t.getRootElement();return null!=e&&e.focus(),!0}return!1},q),t.registerCommand(H,e=>{const n=he(t);return!(null==n||!t.isEditable()||(t.update(()=>{const t=X(n);Yt(t)&&(e.preventDefault(),t.toggleChecked())}),0))},q),t.registerCommand(G,e=>null!==he(t)?(de(t),!1):t.read("latest",()=>{const i=n();if(r(i)&&i.isCollapsed()){const{anchor:n}=i,r="element"===n.type;if(r||0===n.offset){const i=n.getNode(),s=Z(i,t=>c(t)&&!t.isInline());if(Yt(s)){const n=s.getParent();if(oe(n)&&"check"===n.getListType()&&(r||s.getFirstDescendant()===i)){const n=t.getElementByKey(s.__key);if(null!=n&&Q(n)!==n)return n.focus(),e.preventDefault(),!0}}}}return!1}),q),t.registerRootListener(e=>{if(null!==e)return z(Y(e,{click:t=>{u(),(t=>{o(t)||ge(t,s())})(t)},pointerup:t=>{u(),(t=>{"touch"===t.pointerType&&(o(t)||((t=>{const e=t.target;L(e)&&(e.__lexicalCheckListLastHandled=t.timeStamp)})(t),ge(t,s())))})(t)}}),Y(e,{beforeinput:()=>de(t),focusin:()=>{tt&&"content"===l&&de(t)},keydown:e=>{le.has(e.key)||de(t)},mousedown:a,pointerdown:a},{capture:!0}),et(e,"touchstart",a,{capture:!0,passive:!1}))}))}function ue(t,n){const r=t.target;if(!L(r))return;const i=r.firstChild;if(L(i)&&("UL"===i.tagName||"OL"===i.tagName))return;const s=r.parentNode;if(!s||"check"!==s.__lexicalListType)return;let o=null,l=null;if("clientX"in t)o=t.clientX;else if("touches"in t){const e=t.touches;e.length>0&&(o=e[0].clientX,l="touch")}if(null==o)return;const c=r.getBoundingClientRect(),a=o/e(r),u=r.ownerDocument.defaultView,g=u?u.getComputedStyle(r,"::before"):{width:"0px"},d=parseFloat(g.width),f="touch"===l||"pointerType"in t&&"touch"===t.pointerType?32:0;("rtl"===r.dir?a<c.right+f&&a>c.right-d-f:a>c.left-f&&a<c.left+d+f)&&n()}function ge(t,e){ue(t,()=>{if(L(t.target)){const n=t.target,r=nt(n);null!=r&&r.isEditable()&&r.update(()=>{const t=X(n);Yt(t)&&(e?(rt(it),rt(st)):n.focus(),t.toggleChecked())})}})}function de(t){const e=t.getRootElement(),n=e?Q(e):null;null!==e&&L(n)&&fe(n)&&e.focus({preventScroll:!0})}function fe(t){const e=t.parentNode;return"LI"===t.tagName&&null!=e&&"check"===e.__lexicalListType}function he(t){const e=t.getRootElement(),n=e?Q(e):null;return L(n)&&fe(n)?n:null}function pe(t,e,n){const r=he(e);if(null!=r){let i=null;e.update(()=>{const s=X(r);if(!Yt(s))return;const o=function(t,e){let n=e?t.getPreviousSibling():t.getNextSibling(),r=t;for(;null==n&&Yt(r);)r=r.getParentOrThrow().getParent(),null!=r&&(n=e?r.getPreviousSibling():r.getNextSibling());for(;Yt(n);){const t=e?n.getLastChild():n.getFirstChild();if(!oe(t))return n;n=e?t.getLastChild():t.getFirstChild()}return null}(s,n);null!=o&&(o.selectStart(),null!=e.getElementByKey(o.__key)&&(t.preventDefault(),i=o.__key))},{onUpdate:()=>{const t=null===i?null:e.getElementByKey(i);null!=t&&t.focus()}})}return!1}function me(t,e){const n=[];for(const r of t)if(Yt(r)){n.push(r);const t=r.getChildren();if(t.length>1)for(const r of t)oe(r)&&n.push(e.createListItemNode().append(r))}else n.push(e.createListItemNode().append(r));return n}const _e={$import:(t,e)=>{let n;var r;return n=pt(e,"ol")?se("number",e.start):(r=e).matches('[__lexicallisttype="check"], .contains-task-list, [data-is-checklist="1"]')||null!==r.querySelector(":scope > [aria-checked]")?se("check"):se("bullet"),w(n,e),[n.splice(0,0,mt(me(t.$importChildren(e),n),e))]},match:/* @__PURE__ */ht.tag("ol","ul"),name:"@lexical/list/list"};function ye(t,e){if(1!==e.length)return e;const n=e[0];return N(n)&&!t.getFormatType()&&n.getFormatType()?(t.setFormat(n.getFormatType()),n.getChildren()):e}function Ce(t){const e=t=>_t(t)&&!oe(t);if(!t.some(e))return t;const n=[];let r=[];const i=()=>{r.length>0&&(n.push(r),r=[])};for(const s of t)e(s)?(i(),n.push(c(s)?s.getChildren():[s])):r.push(s);i();const s=[];for(const t of n)s.length>0&&s.push(ot()),s.push(...t);return s}const ve={$import:(t,e)=>{const n=e.getAttribute("aria-checked"),r=Qt("true"===n||"false"!==n&&void 0);return M(r,e),w(r,e),[r.splice(0,0,Ce(ye(r,t.$importChildren(e))))]},match:/* @__PURE__ */ht.tag("li"),name:"@lexical/list/li"};function xe(t,e,n){const r=pt(n,"input")?n:n.querySelector('input[type="checkbox"]');if(!r||"checkbox"!==r.getAttribute("type"))return[];const i=Qt(r.hasAttribute("checked"));return M(i,e),w(i,e),[i.splice(0,0,Ce(ye(i,t.$importChildren(e))))]}const Se={$accepts:t=>Yt(t)||oe(t),$packageRun:t=>[Qt().splice(0,0,t)],name:"ListSchema"},be=[{$import:(t,e,n)=>{const r=e.querySelector(':scope > input[type="checkbox"]');return r?xe(t,e,r):n()},match:/* @__PURE__ */ht.tag("li").classAll("task-list-item"),name:"@lexical/list/li-task-list-item"},{$import:(t,e,n)=>{const r=e.querySelector(":scope > .checkbox-wrapper");if(!r)return n();const i=r.querySelector(':scope > input[type="checkbox"]');return i?xe(t,e,i):n()},match:/* @__PURE__ */ht.tag("li").classAll("joplin-checkbox"),name:"@lexical/list/li-joplin-checkbox"},_e,ve],ke=/* @__PURE__ */U("UPDATE_LIST_START_COMMAND"),Te=/* @__PURE__ */U("INSERT_UNORDERED_LIST_COMMAND"),Le=/* @__PURE__ */U("INSERT_ORDERED_LIST_COMMAND"),Ne=/* @__PURE__ */U("REMOVE_LIST_COMMAND");function Fe(t,e){return z(t.registerCommand(Le,()=>(Ot("number"),!0),q),t.registerCommand(ke,t=>{const{listNodeKey:e,newStart:n}=t,r=lt(e);return!!oe(r)&&("number"===r.getListType()&&(r.setStart(n),$t(r)),!0)},q),t.registerCommand(Te,()=>(Ot("bullet"),!0),q),t.registerCommand(Ne,()=>(Dt(),!0),q),t.registerCommand(ct,()=>Wt(!(!e||!e.restoreNumbering)),q),t.registerCommand(at,t=>{const e=n();if(!r(e)||!e.isCollapsed())return!1;const{anchor:i}=e;if(0!==i.offset)return!1;let s=i.getNode();for(;!Yt(s);){if(null!==s.getPreviousSibling())return!1;const t=s.getParent();if(null===t)return!1;s=t}return!(!Yt(s)||!s.collapseAtStart(e)||(t.preventDefault(),0))},ut),t.registerNodeTransform(Ht,t=>{const e=t.getFirstChild();if(e){if(i(e)){const n=e.getStyle(),r=e.getFormat();t.getTextStyle()!==n&&t.setTextStyle(n),t.getTextFormat()!==r&&t.setTextFormat(r)}}else{const e=n();r(e)&&(e.style!==t.getTextStyle()||e.format!==t.getTextFormat())&&e.isCollapsed()&&t.is(e.anchor.getNode())&&t.setTextStyle(e.style).setTextFormat(e.format)}}),t.registerNodeTransform(gt,t=>{const e=t.getParent();if(Yt(e)&&t.is(e.getFirstChild())){const n=t.getStyle(),r=t.getFormat();n===e.getTextStyle()&&r===e.getTextFormat()||e.setTextStyle(n).setTextFormat(r)}}))}function Pe(t){const e=t=>{const e=t.getParent();if(oe(t.getFirstChild())||!oe(e))return;const n=Z(t,t=>Yt(t)&&oe(t.getParent())&&Yt(t.getPreviousSibling()));if(null===n&&t.getIndent()>0)t.setIndent(0);else if(Yt(n)){const r=n.getPreviousSibling();if(Yt(r)){const n=function(t){let e=t,n=e.getFirstChild();for(;oe(n);){const t=n.getLastChild();if(!Yt(t))break;e=t,n=e.getFirstChild()}return e}(r),i=n.getParent();if(oe(i)){const n=Tt(i);n+1<Tt(e)&&t.setIndent(n)}}}};return t.registerNodeTransform(ne,t=>{const n=[t];for(;n.length>0;){const t=n.shift();if(oe(t))for(const r of t.getChildren())if(Yt(r)){e(r);const t=r.getFirstChild();oe(t)&&n.push(t)}}})}const Ae={build:(t,e,n)=>ft(e),config:{hasStrictIndent:!1,shouldPreserveNumbering:!1},dependencies:[yt,[Ct,{rules:be}]],name:"@lexical/list/List",nodes:()=>[ne,Ht],register(t,e,n){const r=n.getOutput();return z(dt(()=>Fe(t,{restoreNumbering:r.shouldPreserveNumbering.value})),dt(()=>r.hasStrictIndent.value?Pe(t):void 0))}},Ie={build:(t,e)=>ft(e),config:{disableTakeFocusOnClick:!1},dependencies:[Ae],name:"@lexical/list/CheckList",register:(t,e,n)=>ae(t,n.getOutput())},Oe={dependencies:[Ae],name:"@lexical/list/Import"},Ee=/^MsoListParagraph(CxSp(First|Middle|Last))?$/,Me=/^[A-Za-z0-9]+[.)]/,we=/Microsoft Word/i,De="data-mso-list";function $e(t){const e=(t.getAttribute(De)||"").match(/level(\d+)/);return e?parseInt(e[1],10):1}function Re(t){return t.querySelector(`span[${De}="Ignore"]`)}function Ke(t){const e=Re(t);return e?(e.textContent||"").trim():""}function We(t){return Me.test(t)?"number":"bullet"}function Be(t){const e=Re(t);if(!e)return;let n=e;for(;n.parentElement&&n.parentElement!==t&&"SPAN"===n.parentElement.nodeName;)n=n.parentElement;n.remove()}function Ue(t){return L(t)&&Ee.test(t.className)}function ze(t,e){const n=se(We(e[0].marker)),r=[{level:e[0].level,list:n}];for(const n of e){for(;r.length>1&&r[r.length-1].level>n.level;)r.pop();if(n.level>r[r.length-1].level){const t=se(We(n.marker));r[r.length-1].list.append(Qt().append(t)),r.push({level:n.level,list:t})}Be(n.el),r[r.length-1].list.append(Qt().splice(0,0,t.$importChildren(n.el,{schema:bt})))}return n}const qe=/* @__PURE__ */St("@lexical/list/word-consumed-list-items",()=>null),Ve={$import:(t,e)=>{let n=t.session.get(qe);if(null===n&&(n=new WeakSet,t.session.set(qe,n)),n.has(e))return[];const r=[];let i=e;for(;i&&Ue(i)&&(n.add(i),r.push({el:i,level:$e(i),marker:Ke(i)}),!i.classList.contains("MsoListParagraphCxSpLast")&&"MsoListParagraph"!==i.className);)i=i.nextElementSibling;return[ze(t,r)]},match:/* @__PURE__ */ht.tag("p").classAny("MsoListParagraph","MsoListParagraphCxSpFirst","MsoListParagraphCxSpMiddle","MsoListParagraphCxSpLast"),name:"@lexical/list/word-list-paragraph"},Je=/* @__PURE__ */xt([{$import:()=>[],match:/* @__PURE__ */ht.tag("o:p"),name:"@lexical/list/word-o-p"},Ve]),je={dependencies:[Ae,[Ct,{preprocess:[(t,e,n)=>{const r=t.querySelector('meta[name="Generator"]');if(r&&we.test(r.getAttribute("content")||"")){for(const e of Array.from(t.querySelectorAll('[style*="mso-list"]'))){const t=K(e.getAttribute("style")||"")["mso-list"];t&&e.setAttribute(De,t)}e.session.update(vt,t=>[...t,Je])}n()}]}]],name:"@lexical/list/WordListImport"};export{Qt as $createListItemNode,se as $createListNode,Tt as $getListDepth,Wt as $handleListInsertParagraph,Ot as $insertList,Yt as $isListItemNode,oe as $isListNode,Dt as $removeList,Ie as CheckListExtension,ce as INSERT_CHECK_LIST_COMMAND,Le as INSERT_ORDERED_LIST_COMMAND,Te as INSERT_UNORDERED_LIST_COMMAND,Ae as ListExtension,Oe as ListImportExtension,be as ListImportRules,Ht as ListItemNode,ne as ListNode,Se as ListSchema,Ne as REMOVE_LIST_COMMAND,ke as UPDATE_LIST_START_COMMAND,je as WordListImportExtension,ae as registerCheckList,Fe as registerList,Pe as registerListStrictIndentTransform};
9
+ import{$getNearestNodeOfType as t,calculateZoomLevel as e}from"@lexical/utils";import{$getSelection as n,$isRangeSelection as r,$isTextNode as i,$isRootOrShadowRoot as s,$createParagraphNode as o,$copyNode as l,$isElementNode as c,$getSlotHost as a,$isLeafNode as u,$setPointFromCaret as g,$normalizeCaret as d,$getChildCaret as f,getterTableOf as h,setterTableOf as p,setterDefaultOf as m,aliasTableOf as _,$applyNodeReplacement as y,ElementNode as C,buildImportMap as v,$getSiblingCaret as x,$insertNodeToNearestRootAtCaret as S,$rewindSiblingCaret as b,$getDocument as k,setDOMStyleFromCSS as T,isHTMLElement as L,$isParagraphNode as N,nodeSchema as F,withField as P,numberValue as A,withAccessors as I,optional as O,booleanValue as E,$setFormatFromDOM as w,$setDirectionFromDOM as M,normalizeClassNames as D,removeClassNamesFromElement as $,addClassNamesToElement as R,getStyleObjectFromCSS as K,enumValue as W,aliasedValue as B,createCommand as U,mergeRegister as z,COMMAND_PRIORITY_LOW as q,KEY_ARROW_DOWN_COMMAND as V,KEY_ARROW_UP_COMMAND as J,KEY_ESCAPE_COMMAND as j,KEY_SPACE_COMMAND as H,$getNearestNodeFromDOMNode as X,KEY_ARROW_LEFT_COMMAND as G,$findMatchingParent as Z,getActiveElement as Q,registerEventListeners as Y,IS_FIREFOX as tt,registerEventListener as et,getNearestEditorFromDOMNode as nt,$addUpdateTag as rt,SKIP_SELECTION_FOCUS_TAG as it,SKIP_DOM_SELECTION_TAG as st,$createLineBreakNode as ot,$getNodeByKey as lt,INSERT_PARAGRAPH_COMMAND as ct,KEY_BACKSPACE_COMMAND as at,COMMAND_PRIORITY_BEFORE_EDITOR as ut,TextNode as gt}from"lexical";import{effect as dt}from"@lexical/extension/signals";import{namedSignals as ft}from"@lexical/extension/namedSignals";import{sel as ht,isElementOfTag as pt,$propagateTextAlignToBlockChildren as mt,$isBlockLevel as _t,CoreImportExtension as yt,DOMImportExtension as Ct,ImportOverlays as vt,defineOverlayRules as xt,createImportState as St,InlineSchema as bt}from"@lexical/html";function kt(t,...e){throw function(t,...e){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",t);for(const t of e)r.append("v",t);return n.search=r.toString(),new Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}(t,...e)}function Tt(t){let e=1,n=t.getParent();for(;null!=n;){if(Yt(n)){const t=n.getParent();if(oe(t)){e++,n=t.getParent();continue}kt(40)}return e}return e}function Lt(t){const e=t.getParent();oe(e)||kt(40);let n=e,r=e;for(;null!==r;)r=r.getParent(),oe(r)&&(n=r);return n}function Nt(t){let e=[];const n=t.getChildren().filter(Yt);for(let t=0;t<n.length;t++){const r=n[t],i=r.getFirstChild();oe(i)?e=e.concat(Nt(i)):e.push(r)}return e}function Ft(t){return Yt(t)&&oe(t.getFirstChild())}function Pt(t,e){return e.getValue()}function At(t,e){return Yt(t)&&(0===e.length||1===e.length&&t.is(e[0])&&0===t.getChildrenSize())}function It(t,e){return oe(t)?l(t).setListType(e):se(e)}function Ot(t){const e=n();if(null!==e){let n=e.getNodes();if(r(e)){const[r]=e.getStartEndPoints(),i=r.getNode(),l=i.getParent();if(s(i)){const t=i.getFirstChild();if(t)n=t.selectStart().getNodes();else{const t=o();i.append(t),n=t.select().getNodes()}}else if(At(i,n)){if(s(l)){const e=se(t);i.replace(e);const n=Qt();c(i)&&(n.setFormat(i.getFormatType()),n.setIndent(i.getIndent())),e.append(n)}else if(Yt(i)){const e=i.getParentOrThrow();if(null===a(e)){const n=It(e,t);Et(n,e.getChildren()),e.replace(n)}}return}}const i=new Set;for(let e=0;e<n.length;e++){const r=n[e];if(c(r)&&r.isEmpty()&&!Yt(r)&&null===a(r)&&!i.has(r.getKey())){wt(r,t);continue}let o=u(r)?r.getParent():Yt(r)&&r.isEmpty()?r:null;for(;null!=o;){const e=o.getKey();if(oe(o)){if(!i.has(e)&&null===a(o)){const n=It(o,t);Et(n,o.getChildren()),o.replace(n),i.add(e)}break}{const n=o.getParent();if(s(n)&&!i.has(e)){i.add(e),wt(o,t);break}o=n}}}}}function Et(t,e){t.splice(t.getChildrenSize(),0,e)}function wt(t,e){if(oe(t))return t;const i=t.getPreviousSibling(),s=t.getNextSibling(),o=Qt();let l;if(Et(o,t.getChildren()),oe(i)&&e===i.getListType())i.append(o),oe(s)&&e===s.getListType()&&(Et(i,s.getChildren()),s.remove()),l=i;else if(oe(s)&&e===s.getListType())s.getFirstChildOrThrow().insertBefore(o),l=s;else{const n=se(e);n.append(o),t.replace(n),l=n}o.setFormat(t.getFormatType()),o.setIndent(t.getIndent());const c=n();return r(c)&&(l.getKey()===c.anchor.key&&c.anchor.set(o.getKey(),c.anchor.offset,"element"),l.getKey()===c.focus.key&&c.focus.set(o.getKey(),c.focus.offset,"element")),t.remove(),l}function Mt(t,e){const n=t.getLastChild(),r=e.getFirstChild();n&&r&&Ft(n)&&Ft(r)&&n.getFirstChild().getListType()===r.getFirstChild().getListType()&&(Mt(n.getFirstChild(),r.getFirstChild()),r.remove());const i=e.getChildren();i.length>0&&t.append(...i),e.remove()}function Dt(){const e=n();if(r(e)){const n=new Set,r=e.getNodes(),i=e.anchor.getNode();if(At(i,r))n.add(Lt(i));else for(let e=0;e<r.length;e++){const i=r[e];if(u(i)){const e=t(i,Ht);null!=e&&n.add(Lt(e))}}for(const t of n){if(null!==a(t))continue;let n=t;const r=Nt(t);for(const t of r){const r=o().setTextStyle(e.style).setTextFormat(e.format);r.setFormat(t.getFormatType()).setIndent(t.getIndent()).setDirection(t.getDirection()).setStyle(t.getStyle()),Et(r,t.getChildren()),n.insertAfter(r),n=r,t.__key===e.anchor.key&&g(e.anchor,d(f(r,"next"))),t.__key===e.focus.key&&g(e.focus,d(f(r,"next"))),t.remove()}t.remove()}}}function $t(t){const e="check"!==t.getListType();let n=t.getStart();for(const r of t.getChildren())Yt(r)&&(r.getValue()!==n&&r.setValue(n),e&&null!=r.getLatest().__checked&&r.setChecked(void 0),oe(r.getFirstChild())||n++)}function Rt(t){const e=new Set;if(Ft(t)||e.has(t.getKey()))return;const n=t.getParent(),r=t.getNextSibling(),i=t.getPreviousSibling();if(Ft(r)&&Ft(i)){const n=i.getFirstChild();if(oe(n)){n.append(t);const i=r.getFirstChild();oe(i)&&n.getListType()===i.getListType()&&(Et(n,i.getChildren()),r.remove(),e.add(r.getKey()))}}else if(Ft(r)){const e=r.getFirstChild();if(oe(e)){const n=e.getFirstChild();null!==n&&n.insertBefore(t)}}else if(Ft(i)){const e=i.getFirstChild();oe(e)&&e.append(t)}else if(oe(n)){const e=l(t),s=l(n);e.append(s),s.append(t),i?i.insertAfter(e):r?r.insertBefore(e):n.append(e)}}function Kt(t){if(Ft(t))return;const e=t.getParent(),n=e?e.getParent():void 0;if(oe(n?n.getParent():void 0)&&Yt(n)&&oe(e)){const r=e?e.getFirstChild():void 0,i=e?e.getLastChild():void 0;if(t.is(r))n.insertBefore(t),e.isEmpty()&&n.remove();else if(t.is(i))n.insertAfter(t),e.isEmpty()&&n.remove();else{const r=l(t),i=l(e);r.append(i),t.getPreviousSiblings().forEach(t=>i.append(t));const s=l(t),o=l(e);s.append(o),Et(o,t.getNextSiblings()),n.insertBefore(r),n.insertAfter(s),n.replace(t)}}}function Wt(t=!1){const e=n();if(!r(e)||!e.isCollapsed())return!1;const c=e.anchor.getNode();let a=null;if(Yt(c)&&0===c.getChildrenSize())a=c;else if(i(c)){const t=c.getParent();Yt(t)&&t.getChildren().every(t=>i(t)&&""===t.getTextContent().trim())&&(a=t)}if(null===a)return!1;const u=Lt(a),g=a.getParent();oe(g)||kt(40);const d=g.getParent();let f;if(s(d))f=o(),u.insertAfter(f);else{if(!Yt(d))return!1;f=l(d),d.insertAfter(f)}f.setTextStyle(e.style).setTextFormat(e.format).select();const h=a.getNextSiblings();if(h.length>0){const e=t?Pt(0,a):1,n=l(g).setStart(e);if(Yt(f)){const t=l(f);t.append(n),f.insertAfter(t)}else f.insertAfter(n);n.append(...h)}return function(t){let e=t;for(;null==e.getNextSibling()&&null==e.getPreviousSibling();){const t=e.getParent();if(null==t||!Yt(t)&&!oe(t))break;e=t}e.remove()}(a),!0}const Bt=/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/;function Ut(t,e){if("number"==typeof t)return Number.isFinite(t)?t:e;if("string"!=typeof t||!Bt.test(t))return e;const n=Number(t);return Number.isFinite(n)?n:e}function zt(t,e){t.__listType=e.__listType,t.__start=e.__start,t.__tag=e.__tag}const qt=t=>{const e=h(t,"format"),n=p(t,"format"),r=m(t,"format"),i=_(t,"listType",0);return{exportJSON:function(t){const n=t.__textFormat,r=t.__textStyle,i=(0!==n||""!==r)&&t.shouldSerializeTextStyles();return{children:[],listType:t.__listType,start:t.__start,tag:t.__tag,direction:t.__dir,format:e[t.__format],indent:t.__indent,textFormat:0!==n&&i?n:void 0,textStyle:""!==r&&i?r:void 0,type:t.__type,version:1}},exportCompactJSON:function(t){const n=t.__textFormat,r=t.__textStyle,i=(0!==n||""!==r)&&t.shouldSerializeTextStyles(),s={type:t.__type,children:[]},o=t.__listType;void 0!==o&&"number"!==o&&(s.listType=o);const l=t.__start;void 0!==l&&1!==l&&(s.start=l);const c=t.__dir;null!=c&&(s.direction=c);const a=e[t.__format];void 0!==a&&""!==a&&(s.format=a);const u=t.__indent;return void 0!==u&&0!==u&&(s.indent=u),void 0!==n&&0!==n&&i&&(s.textFormat=n),void 0!==r&&""!==r&&i&&(s.textStyle=r),s},updateFromJSON:function(t,e){const s=e.direction;t.__dir=null===s||"ltr"===s||"rtl"===s?s:null;const o=e.format;t.__format="string"==typeof o&&o in n?n[o]:r,t.__indent=function(t){const e=Ut(t,0);return e>=0&&e<=Infinity&&Number.isInteger(e)?e:0}(e.indent),t.__textFormat=Ut(e.textFormat,0);const l=e.textStyle;t.__textStyle="string"==typeof l?l:"";const c=e.listType;return t.setListType("string"==typeof c&&c in i?i[c]:"number"===c||"bullet"===c||"check"===c?c:"number"),t.__start=Ut(e.start,1),t},afterCloneFrom:zt}};function Vt(t,e){t.__checked=e.__checked,t.__value=e.__value}const Jt=t=>{const e=h(t,"format"),n=p(t,"format"),r=m(t,"format");return{exportJSON:function(t){const n=t.__textFormat,r=t.__textStyle,i=(0!==n||""!==r)&&t.shouldSerializeTextStyles();return{children:[],checked:t.getChecked(),indent:t.getIndent(),value:t.__value,direction:t.__dir,format:e[t.__format],textFormat:0!==n&&i?n:void 0,textStyle:""!==r&&i?r:void 0,type:t.__type,version:1}},exportCompactJSON:function(t){const n=t.__textFormat,r=t.__textStyle,i=(0!==n||""!==r)&&t.shouldSerializeTextStyles(),s={type:t.__type,children:[]},o=t.getChecked();void 0!==o&&(s.checked=o);const l=t.getIndent();void 0!==l&&0!==l&&(s.indent=l);const c=t.__value;void 0!==c&&1!==c&&(s.value=c);const a=t.__dir;null!=a&&(s.direction=a);const u=e[t.__format];return void 0!==u&&""!==u&&(s.format=u),void 0!==n&&0!==n&&i&&(s.textFormat=n),void 0!==r&&""!==r&&i&&(s.textStyle=r),s},updateFromJSON:function(t,e){const i=e.direction;t.__dir=null===i||"ltr"===i||"rtl"===i?i:null;const s=e.format;t.__format="string"==typeof s&&s in n?n[s]:r,t.setIndent(function(t){const e=Ut(t,NaN);return Number.isFinite(e)&&Number.isInteger(e)?e<0?0:e>128?128:e:0}(e.indent)),t.__textFormat=Ut(e.textFormat,0);const o=e.textStyle;t.__textStyle="string"==typeof o?o:"";const l=e.checked;return t.__checked=void 0===l?void 0:"boolean"==typeof l&&l,t.__value=Ut(e.value,1),t},afterCloneFrom:Vt}},jt=/* @__PURE__ */F()({checked:/* @__PURE__ */I(/* @__PURE__ */O(/* @__PURE__ */E()),{setter:{field:"__checked"}}),indent:/* @__PURE__ */A(0,{clamp:!0,integer:!0,max:128,min:0}),value:/* @__PURE__ */P(/* @__PURE__ */A(1),{field:"__value"})});class Ht extends C{__value;__checked;$config(){return this.config("listitem",{$transform:t=>{const e=t.getParent();if(oe(e))"check"!==e.getListType()&&null!=t.getChecked()&&t.setChecked(void 0);else if(e){const n=t.createParentElementNode();oe(n)||kt(340);const r=[t];for(const e of["previous","next"]){r.reverse();for(const{origin:n}of x(t,e)){if(!Yt(n))break;r.push(n)}}t.insertBefore(n),n.splice(0,0,r),s(e)||(S(n,b(x(n,"next")),{$shouldSplit:()=>!1,removeEmptyDestination:!0}),e.isEmpty()&&e.isAttached()&&e.remove())}},extends:C,generated:Jt,importDOM:v({li:()=>({conversion:Xt,priority:0})}),json:jt})}constructor(t=1,e=void 0,n){super(n),this.__value=void 0===t?1:t,this.__checked=e}createDOM(t){const e=k().createElement("li");return this.updateListItemDOM(null,e,t),e}updateListItemDOM(t,e,n){!function(t,e){const n=e.getParent();!oe(n)||"check"!==n.getListType()||oe(e.getFirstChild())?(t.removeAttribute("role"),t.removeAttribute("tabIndex"),t.removeAttribute("aria-checked")):(t.setAttribute("role","checkbox"),t.setAttribute("tabIndex","-1"),t.setAttribute("aria-checked",e.getChecked()?"true":"false"))}(e,this),e.value=this.__value,function(t,e,n){const r=e.list;if(!r)return;const i=r.listitem,s=r.nested&&r.nested.listitem,o=n.getParent(),l=oe(o)&&"check"===o.getListType(),c=n.getChecked(),a=n.getChildren().some(t=>oe(t)),u=[];void 0!==r.listitemChecked&&u.push(r.listitemChecked),void 0!==r.listitemUnchecked&&u.push(r.listitemUnchecked),void 0!==s&&u.push(...D(s)),u.length>0&&$(t,...u);const g=[];if(void 0!==i&&g.push(...D(i)),l){const t=c?r.listitemChecked:r.listitemUnchecked;void 0!==t&&g.push(t)}void 0!==s&&a&&g.push(...D(s)),g.length>0&&R(t,...g)}(e,n.theme,this);const r=t?t.__style:"",i=this.__style;r!==i&&T(e.style,i,r),function(t,e,n){const r=e.__textStyle,i=n?n.__textStyle:"";if(null!==n&&i===r)return;const s=K(r);for(const e in s)t.style.setProperty(`--listitem-marker-${e}`,s[e]);if(""!==i)for(const e in K(i))e in s||t.style.removeProperty(`--listitem-marker-${e}`)}(e,this,t)}updateDOM(t,e,n){const r=e;return this.updateListItemDOM(t,r,n),!1}exportDOM(t){const e=this.createDOM(t._config),n=this.getFormatType();n&&(e.style.textAlign=n);const r=this.getDirection();return r&&(e.dir=r),Ft(this)?{after(t){if(L(t)){const e=t.previousElementSibling;if(L(e)&&"LI"===e.nodeName){for(;t.firstChild;)e.append(t.firstChild);t.remove()}}return t},element:e}:{element:e}}append(...t){for(let e=0;e<t.length;e++){const n=t[e];if(c(n)&&this.canMergeWith(n)){const t=n.getChildren();this.append(...t),n.remove()}else super.append(n)}return this}replace(t,e){if(Yt(t))return super.replace(t);this.setIndent(0);const i=this.getParentOrThrow();if(!oe(i))return t;if(i.__first===this.getKey())i.insertBefore(t);else if(i.__last===this.getKey())i.insertAfter(t);else{const e=l(i);let n=this.getNextSibling();for(;n;){const t=n;n=n.getNextSibling(),e.append(t)}i.insertAfter(t),t.insertAfter(e)}const s=this.__key;let o=0;if(e&&(c(t)||kt(139),o=t.getChildrenSize(),t.splice(o,0,this.getChildren())),e&&c(t)){const e=n();if(r(e))for(const n of e.getStartEndPoints())n.key===s&&"element"===n.type&&n.set(t.getKey(),o+n.offset,"element")}return this.remove(),0===i.getChildrenSize()&&i.remove(),t}insertAfter(t,e=!0){const n=this.getParentOrThrow();if(oe(n)||kt(39),Yt(t))return super.insertAfter(t,e);const r=this.getNextSiblings();if(n.insertAfter(t,e),0!==r.length){const i=l(n),s=r[0];"number"===i.getListType()&&Yt(s)&&i.setStart(Pt(0,s)),r.forEach(t=>i.append(t)),t.insertAfter(i,e)}return t}remove(t){const e=this.getPreviousSibling(),n=this.getNextSibling();super.remove(t),e&&n&&Ft(e)&&Ft(n)&&e.getFirstChild().getListType()===n.getFirstChild().getListType()&&(Mt(e.getFirstChild(),n.getFirstChild()),n.remove())}resetOnCopyNodeFrom(t){super.resetOnCopyNodeFrom(t),t.getChecked()&&this.setChecked(!1)}insertNewAfter(t,e=!0){const n=l(this);return this.insertAfter(n,e),n}collapseAtStart(t){if(Ft(this))return!1;const e=this.getParentOrThrow();if(Yt(e.getParentOrThrow()))return Kt(this),!0;const n=o().append(...this.getChildren()),r=this.getNextSiblings();if(r.length>0){const t=l(e);t.append(...r),e.insertAfter(t)}return e.insertAfter(n),this.remove(),0===e.getChildrenSize()&&e.remove(),n.selectStart(),!0}getValue(){return this.getLatest().__value}setValue(t){const e=this.getWritable();return e.__value=t,e}getChecked(){const t=this.getLatest();let e;const n=this.getParent();return oe(n)&&(e=n.getListType()),"check"===e?Boolean(t.__checked):void 0}setChecked(t){const e=this.getWritable();return e.__checked=t,e}toggleChecked(){const t=this.getWritable();return t.setChecked(!t.__checked)}getIndent(){const t=this.getParent();if(null===t||!this.isAttached())return this.getLatest().__indent;let e=t.getParentOrThrow(),n=0;for(;Yt(e);)e=e.getParentOrThrow().getParentOrThrow(),n++;return n}setIndent(t){"number"!=typeof t&&kt(117),(t=Math.floor(t))>=0||kt(199);const e=t;let n=this.getIndent();for(;n!==e;)n<e?(Rt(this),n++):(Kt(this),n--);return this}canInsertAfter(t){return Yt(t)}canReplaceWith(t){return Yt(t)}canMergeWith(t){return Yt(t)||N(t)}extractWithChild(t,e){if(!r(e))return!1;const n=e.anchor.getNode(),i=e.focus.getNode();return this.isParentOf(n)&&this.isParentOf(i)&&this.getTextContent().length===e.getTextContent().length}isParentRequired(){return!0}createParentElementNode(){return se("bullet")}canMergeWhenEmpty(){return!0}}function Xt(t){if(t.classList.contains("task-list-item"))for(const e of t.children)if("INPUT"===e.tagName)return Gt(e);if(t.classList.contains("joplin-checkbox"))for(const e of t.children)if(e.classList.contains("checkbox-wrapper")&&e.children.length>0&&"INPUT"===e.children[0].tagName)return Gt(e.children[0]);const e=t.getAttribute("aria-checked"),n=Qt("true"===e||"false"!==e&&void 0);return w(n,t),{after:Zt.bind(null,n),node:M(n,t)}}function Gt(t){if("checkbox"!==t.getAttribute("type"))return{node:null};const e=Qt(t.hasAttribute("checked"));return{after:Zt.bind(null,e),node:e}}function Zt(t,e){const n=e[0];return 1===e.length&&N(n)&&!t.getFormatType()&&n.getFormatType()?(t.setFormat(n.getFormatType()),n.getChildren()):e}function Qt(t){return y(new Ht(void 0,t))}function Yt(t){return t instanceof Ht}const te={ol:"number",ul:"bullet"},ee=/* @__PURE__ */F()({listType:/* @__PURE__ */I(/* @__PURE__ */B(/* @__PURE__ */W(["number","bullet","check"]),te),{getter:{field:"__listType"}}),start:/* @__PURE__ */P(/* @__PURE__ */A(1),{field:"__start"}),tag:/* @__PURE__ */I(/* @__PURE__ */W(["ul","ol"]),{getter:{field:"__tag"},setter:null})});class ne extends C{__tag;__start;__listType;$config(){return this.config("list",{$transform:t=>{!function(t){const e=t.getNextSibling();oe(e)&&t.getListType()===e.getListType()&&Mt(t,e)}(t),$t(t)},extends:C,generated:qt,importDOM:v({ol:()=>({conversion:ie,priority:0}),ul:()=>({conversion:ie,priority:0})}),json:ee})}constructor(t="number",e=1,n){super(n);const r=te[t]||t;this.__listType=r,this.__tag="number"===r?"ol":"ul",this.__start=e}getTag(){return this.getLatest().__tag}setListType(t){const e=this.getWritable();return e.__listType=t,e.__tag="number"===t?"ol":"ul",e}getListType(){return this.getLatest().__listType}getStart(){return this.getLatest().__start}setStart(t){const e=this.getWritable();return e.__start=t,e}createDOM(t,e){const n=this.__tag,r=k().createElement(n);return 1!==this.__start&&r.setAttribute("start",String(this.__start)),r.__lexicalListType=this.__listType,re(r,t.theme,this),r}updateDOM(t,e,n){return t.__tag!==this.__tag||t.__listType!==this.__listType||(re(e,n.theme,this),t.__start!==this.__start&&e.setAttribute("start",String(this.__start)),!1)}exportDOM(t){const e=this.createDOM(t._config,t);if(L(e)){1!==this.__start&&e.setAttribute("start",String(this.__start)),"check"===this.__listType&&e.setAttribute("__lexicalListType","check");const t=this.getDirection();t&&(e.dir=t)}return{element:e}}canBeEmpty(){return!1}canIndent(){return!1}splice(t,e,n){let r=n;for(let t=0;t<n.length;t++){const e=n[t];if(!Yt(e)){r===n&&(r=[...n]);const i=this.createListItemNode();!c(e)||oe(e)||e.isInline()?i.append(e):i.append(...e.getChildren()),r[t]=i}}return super.splice(t,e,r)}extractWithChild(t){return Yt(t)}createListItemNode(){return Qt()}}function re(t,e,n){const r=[],i=[],s=e.list;if(void 0!==s){const t=s[`${n.__tag}Depth`]||[],e=Tt(n)-1,o=e%t.length,l=t[o],c=s[n.__tag];let a;const u=s.nested,g=s.checklist;if(void 0!==u&&u.list&&(a=u.list),void 0!==c&&r.push(c),void 0!==g&&"check"===n.__listType&&r.push(g),void 0!==l){r.push(...D(l));for(let e=0;e<t.length;e++)e!==o&&i.push(...D(t[e]))}if(void 0!==a){const t=D(a);e>1?r.push(...t):i.push(...t)}}i.length>0&&$(t,...i),r.length>0&&R(t,...r)}function ie(t){let e;if(function(t){return L(t)&&"ol"===t.nodeName.toLowerCase()}(t)){const n=t.start;e=se("number",n)}else e=function(t){if("check"===t.getAttribute("__lexicallisttype")||t.classList.contains("contains-task-list")||"1"===t.getAttribute("data-is-checklist"))return!0;for(const e of t.childNodes)if(L(e)&&e.hasAttribute("aria-checked"))return!0;return!1}(t)?se("check"):se("bullet");return M(e,t),{after:t=>function(t,e){const n=e.createListItemNode.bind(e),r=[];for(let e=0;e<t.length;e++){const i=t[e];if(Yt(i)){r.push(i);const t=i.getChildren();t.length>1&&t.forEach(t=>{oe(t)&&r.push(n().append(t))})}else r.push(n().append(i))}return r}(t,e),node:e}}function se(t="number",e=1){return y(new ne(t,e))}function oe(t){return t instanceof ne}const le=new Set([" ","Alt","ArrowDown","ArrowLeft","ArrowUp","CapsLock","Control","Escape","Meta","Shift"]),ce=/* @__PURE__ */U("INSERT_CHECK_LIST_COMMAND");function ae(t,e){const i=e&&e.disableTakeFocusOnClick||!1,s="boolean"==typeof i?()=>i:i.peek.bind(i),o=t=>{const e=t.target;if(!L(e))return!1;const n=e.__lexicalCheckListLastHandled;return void 0!==n&&t.timeStamp-n<500};let l="none";const a=t=>{l=function(t,e){let n=!1;return ue(t,()=>{n=!0,t.preventDefault(),e&&t.stopPropagation()}),n}(t,s())?"checkMark":"content"},u=()=>{"content"===l&&de(t),l="none"};return z(t.registerCommand(ce,()=>(Ot("check"),!0),q),t.registerCommand(V,e=>pe(e,t,!1),q),t.registerCommand(J,e=>pe(e,t,!0),q),t.registerCommand(j,()=>{if(null!=he(t)){const e=t.getRootElement();return null!=e&&e.focus(),!0}return!1},q),t.registerCommand(H,e=>{const n=he(t);return!(null==n||!t.isEditable()||(t.update(()=>{const t=X(n);Yt(t)&&(e.preventDefault(),t.toggleChecked())}),0))},q),t.registerCommand(G,e=>null!==he(t)?(de(t),!1):t.read("latest",()=>{const i=n();if(r(i)&&i.isCollapsed()){const{anchor:n}=i,r="element"===n.type;if(r||0===n.offset){const i=n.getNode(),s=Z(i,t=>c(t)&&!t.isInline());if(Yt(s)){const n=s.getParent();if(oe(n)&&"check"===n.getListType()&&(r||s.getFirstDescendant()===i)){const n=t.getElementByKey(s.__key);if(null!=n&&Q(n)!==n)return n.focus(),e.preventDefault(),!0}}}}return!1}),q),t.registerRootListener(e=>{if(null!==e)return z(Y(e,{click:t=>{u(),(t=>{o(t)||ge(t,s())})(t)},pointerup:t=>{u(),(t=>{"touch"===t.pointerType&&(o(t)||((t=>{const e=t.target;L(e)&&(e.__lexicalCheckListLastHandled=t.timeStamp)})(t),ge(t,s())))})(t)}}),Y(e,{beforeinput:()=>de(t),focusin:()=>{tt&&"content"===l&&de(t)},keydown:e=>{le.has(e.key)||de(t)},mousedown:a,pointerdown:a},{capture:!0}),et(e,"touchstart",a,{capture:!0,passive:!1}))}))}function ue(t,n){const r=t.target;if(!L(r))return;const i=r.firstChild;if(L(i)&&("UL"===i.tagName||"OL"===i.tagName))return;const s=r.parentNode;if(!s||"check"!==s.__lexicalListType)return;let o=null,l=null;if("clientX"in t)o=t.clientX;else if("touches"in t){const e=t.touches;e.length>0&&(o=e[0].clientX,l="touch")}if(null==o)return;const c=r.getBoundingClientRect(),a=o/e(r),u=r.ownerDocument.defaultView,g=u?u.getComputedStyle(r,"::before"):{width:"0px"},d=parseFloat(g.width),f="touch"===l||"pointerType"in t&&"touch"===t.pointerType?32:0;("rtl"===r.dir?a<c.right+f&&a>c.right-d-f:a>c.left-f&&a<c.left+d+f)&&n()}function ge(t,e){ue(t,()=>{if(L(t.target)){const n=t.target,r=nt(n);null!=r&&r.isEditable()&&r.update(()=>{const t=X(n);Yt(t)&&(e?(rt(it),rt(st)):n.focus(),t.toggleChecked())})}})}function de(t){const e=t.getRootElement(),n=e?Q(e):null;null!==e&&L(n)&&fe(n)&&e.focus({preventScroll:!0})}function fe(t){const e=t.parentNode;return"LI"===t.tagName&&null!=e&&"check"===e.__lexicalListType}function he(t){const e=t.getRootElement(),n=e?Q(e):null;return L(n)&&fe(n)?n:null}function pe(t,e,n){const r=he(e);if(null!=r){let i=null;e.update(()=>{const s=X(r);if(!Yt(s))return;const o=function(t,e){let n=e?t.getPreviousSibling():t.getNextSibling(),r=t;for(;null==n&&Yt(r);)r=r.getParentOrThrow().getParent(),null!=r&&(n=e?r.getPreviousSibling():r.getNextSibling());for(;Yt(n);){const t=e?n.getLastChild():n.getFirstChild();if(!oe(t))return n;n=e?t.getLastChild():t.getFirstChild()}return null}(s,n);null!=o&&(o.selectStart(),null!=e.getElementByKey(o.__key)&&(t.preventDefault(),i=o.__key))},{onUpdate:()=>{const t=null===i?null:e.getElementByKey(i);null!=t&&t.focus()}})}return!1}function me(t,e){const n=[];for(const r of t)if(Yt(r)){n.push(r);const t=r.getChildren();if(t.length>1)for(const r of t)oe(r)&&n.push(e.createListItemNode().append(r))}else n.push(e.createListItemNode().append(r));return n}const _e={$import:(t,e)=>{let n;var r;return n=pt(e,"ol")?se("number",e.start):(r=e).matches('[__lexicallisttype="check"], .contains-task-list, [data-is-checklist="1"]')||null!==r.querySelector(":scope > [aria-checked]")?se("check"):se("bullet"),M(n,e),[n.splice(0,0,mt(me(t.$importChildren(e),n),e))]},match:/* @__PURE__ */ht.tag("ol","ul"),name:"@lexical/list/list"};function ye(t,e){if(1!==e.length)return e;const n=e[0];return N(n)&&!t.getFormatType()&&n.getFormatType()?(t.setFormat(n.getFormatType()),n.getChildren()):e}function Ce(t){const e=t=>_t(t)&&!oe(t);if(!t.some(e))return t;const n=[];let r=[];const i=()=>{r.length>0&&(n.push(r),r=[])};for(const s of t)e(s)?(i(),n.push(c(s)?s.getChildren():[s])):r.push(s);i();const s=[];for(const t of n)s.length>0&&s.push(ot()),s.push(...t);return s}const ve={$import:(t,e)=>{const n=e.getAttribute("aria-checked"),r=Qt("true"===n||"false"!==n&&void 0);return w(r,e),M(r,e),[r.splice(0,0,Ce(ye(r,t.$importChildren(e))))]},match:/* @__PURE__ */ht.tag("li"),name:"@lexical/list/li"};function xe(t,e,n){const r=pt(n,"input")?n:n.querySelector('input[type="checkbox"]');if(!r||"checkbox"!==r.getAttribute("type"))return[];const i=Qt(r.hasAttribute("checked"));return w(i,e),M(i,e),[i.splice(0,0,Ce(ye(i,t.$importChildren(e))))]}const Se={$accepts:t=>Yt(t)||oe(t),$packageRun:t=>[Qt().splice(0,0,t)],name:"ListSchema"},be=[{$import:(t,e,n)=>{const r=e.querySelector(':scope > input[type="checkbox"]');return r?xe(t,e,r):n()},match:/* @__PURE__ */ht.tag("li").classAll("task-list-item"),name:"@lexical/list/li-task-list-item"},{$import:(t,e,n)=>{const r=e.querySelector(":scope > .checkbox-wrapper");if(!r)return n();const i=r.querySelector(':scope > input[type="checkbox"]');return i?xe(t,e,i):n()},match:/* @__PURE__ */ht.tag("li").classAll("joplin-checkbox"),name:"@lexical/list/li-joplin-checkbox"},_e,ve],ke=/* @__PURE__ */U("UPDATE_LIST_START_COMMAND"),Te=/* @__PURE__ */U("INSERT_UNORDERED_LIST_COMMAND"),Le=/* @__PURE__ */U("INSERT_ORDERED_LIST_COMMAND"),Ne=/* @__PURE__ */U("REMOVE_LIST_COMMAND");function Fe(t,e){return z(t.registerCommand(Le,()=>(Ot("number"),!0),q),t.registerCommand(ke,t=>{const{listNodeKey:e,newStart:n}=t,r=lt(e);return!!oe(r)&&("number"===r.getListType()&&(r.setStart(n),$t(r)),!0)},q),t.registerCommand(Te,()=>(Ot("bullet"),!0),q),t.registerCommand(Ne,()=>(Dt(),!0),q),t.registerCommand(ct,()=>Wt(!(!e||!e.restoreNumbering)),q),t.registerCommand(at,t=>{const e=n();if(!r(e)||!e.isCollapsed())return!1;const{anchor:i}=e;if(0!==i.offset)return!1;let s=i.getNode();for(;!Yt(s);){if(null!==s.getPreviousSibling())return!1;const t=s.getParent();if(null===t)return!1;s=t}return!(!Yt(s)||!s.collapseAtStart(e)||(t.preventDefault(),0))},ut),t.registerNodeTransform(Ht,t=>{const e=t.getFirstChild();if(e){if(i(e)){const n=e.getStyle(),r=e.getFormat();t.getTextStyle()!==n&&t.setTextStyle(n),t.getTextFormat()!==r&&t.setTextFormat(r)}}else{const e=n();r(e)&&(e.style!==t.getTextStyle()||e.format!==t.getTextFormat())&&e.isCollapsed()&&t.is(e.anchor.getNode())&&t.setTextStyle(e.style).setTextFormat(e.format)}}),t.registerNodeTransform(gt,t=>{const e=t.getParent();if(Yt(e)&&t.is(e.getFirstChild())){const n=t.getStyle(),r=t.getFormat();n===e.getTextStyle()&&r===e.getTextFormat()||e.setTextStyle(n).setTextFormat(r)}}))}function Pe(t){const e=t=>{const e=t.getParent();if(oe(t.getFirstChild())||!oe(e))return;const n=Z(t,t=>Yt(t)&&oe(t.getParent())&&Yt(t.getPreviousSibling()));if(null===n&&t.getIndent()>0)t.setIndent(0);else if(Yt(n)){const r=n.getPreviousSibling();if(Yt(r)){const n=function(t){let e=t,n=e.getFirstChild();for(;oe(n);){const t=n.getLastChild();if(!Yt(t))break;e=t,n=e.getFirstChild()}return e}(r),i=n.getParent();if(oe(i)){const n=Tt(i);n+1<Tt(e)&&t.setIndent(n)}}}};return t.registerNodeTransform(ne,t=>{const n=[t];for(;n.length>0;){const t=n.shift();if(oe(t))for(const r of t.getChildren())if(Yt(r)){e(r);const t=r.getFirstChild();oe(t)&&n.push(t)}}})}const Ae={build:(t,e,n)=>ft(e),config:{hasStrictIndent:!1,shouldPreserveNumbering:!1},dependencies:[yt,[Ct,{rules:be}]],name:"@lexical/list/List",nodes:()=>[ne,Ht],register(t,e,n){const r=n.getOutput();return z(dt(()=>Fe(t,{restoreNumbering:r.shouldPreserveNumbering.value})),dt(()=>r.hasStrictIndent.value?Pe(t):void 0))}},Ie={build:(t,e)=>ft(e),config:{disableTakeFocusOnClick:!1},dependencies:[Ae],name:"@lexical/list/CheckList",register:(t,e,n)=>ae(t,n.getOutput())},Oe={dependencies:[Ae],name:"@lexical/list/Import"},Ee=/^MsoListParagraph(CxSp(First|Middle|Last))?$/,we=/^[A-Za-z0-9]+[.)]/,Me=/Microsoft Word/i,De="data-mso-list";function $e(t){const e=(t.getAttribute(De)||"").match(/level(\d+)/);return e?parseInt(e[1],10):1}function Re(t){return t.querySelector(`span[${De}="Ignore"]`)}function Ke(t){const e=Re(t);return e?(e.textContent||"").trim():""}function We(t){return we.test(t)?"number":"bullet"}function Be(t){const e=Re(t);if(!e)return;let n=e;for(;n.parentElement&&n.parentElement!==t&&"SPAN"===n.parentElement.nodeName;)n=n.parentElement;n.remove()}function Ue(t){return L(t)&&Ee.test(t.className)}function ze(t,e){const n=se(We(e[0].marker)),r=[{level:e[0].level,list:n}];for(const n of e){for(;r.length>1&&r[r.length-1].level>n.level;)r.pop();if(n.level>r[r.length-1].level){const t=se(We(n.marker));r[r.length-1].list.append(Qt().append(t)),r.push({level:n.level,list:t})}Be(n.el),r[r.length-1].list.append(Qt().splice(0,0,t.$importChildren(n.el,{schema:bt})))}return n}const qe=/* @__PURE__ */St("@lexical/list/word-consumed-list-items",()=>null),Ve={$import:(t,e)=>{let n=t.session.get(qe);if(null===n&&(n=new WeakSet,t.session.set(qe,n)),n.has(e))return[];const r=[];let i=e;for(;i&&Ue(i)&&(n.add(i),r.push({el:i,level:$e(i),marker:Ke(i)}),!i.classList.contains("MsoListParagraphCxSpLast")&&"MsoListParagraph"!==i.className);)i=i.nextElementSibling;return[ze(t,r)]},match:/* @__PURE__ */ht.tag("p").classAny("MsoListParagraph","MsoListParagraphCxSpFirst","MsoListParagraphCxSpMiddle","MsoListParagraphCxSpLast"),name:"@lexical/list/word-list-paragraph"},Je=/* @__PURE__ */xt([{$import:()=>[],match:/* @__PURE__ */ht.tag("o:p"),name:"@lexical/list/word-o-p"},Ve]),je={dependencies:[Ae,[Ct,{preprocess:[(t,e,n)=>{const r=t.querySelector('meta[name="Generator"]');if(r&&Me.test(r.getAttribute("content")||"")){for(const e of Array.from(t.querySelectorAll('[style*="mso-list"]'))){const t=K(e.getAttribute("style")||"")["mso-list"];t&&e.setAttribute(De,t)}e.session.update(vt,t=>[...t,Je])}n()}]}]],name:"@lexical/list/WordListImport"};export{Qt as $createListItemNode,se as $createListNode,Tt as $getListDepth,Wt as $handleListInsertParagraph,Ot as $insertList,Yt as $isListItemNode,oe as $isListNode,Dt as $removeList,Ie as CheckListExtension,ce as INSERT_CHECK_LIST_COMMAND,Le as INSERT_ORDERED_LIST_COMMAND,Te as INSERT_UNORDERED_LIST_COMMAND,Ae as ListExtension,Oe as ListImportExtension,be as ListImportRules,Ht as ListItemNode,ne as ListNode,Se as ListSchema,Ne as REMOVE_LIST_COMMAND,ke as UPDATE_LIST_START_COMMAND,je as WordListImportExtension,ae as registerCheckList,Fe as registerList,Pe as registerListStrictIndentTransform};
package/package.json CHANGED
@@ -8,15 +8,15 @@
8
8
  "list"
9
9
  ],
10
10
  "license": "MIT",
11
- "version": "0.51.1-nightly.20260925.0",
11
+ "version": "0.52.0",
12
12
  "main": "./dist/LexicalList.js",
13
13
  "types": "./dist/typescript-too-old.d.ts",
14
14
  "dependencies": {
15
- "@lexical/extension": "0.51.1-nightly.20260925.0",
16
- "@lexical/html": "0.51.1-nightly.20260925.0",
17
- "@lexical/internal": "0.51.1-nightly.20260925.0",
18
- "@lexical/utils": "0.51.1-nightly.20260925.0",
19
- "lexical": "0.51.1-nightly.20260925.0"
15
+ "@lexical/extension": "0.52.0",
16
+ "@lexical/html": "0.52.0",
17
+ "@lexical/internal": "0.52.0",
18
+ "@lexical/utils": "0.52.0",
19
+ "lexical": "0.52.0"
20
20
  },
21
21
  "repository": {
22
22
  "type": "git",