Files
standardnotes-app-web/.yarn/patches/@lexical-list-npm-0.15.0-53c9adf3b8.patch
2024-05-12 22:42:07 +05:30

69 lines
33 KiB
Diff

diff --git a/LexicalList.dev.js b/LexicalList.dev.js
index 288577130186ce7539f9c6e93cb6073f33ca7346..6b7255d6d9ed512c754b26659ba4f192d1134238 100644
--- a/LexicalList.dev.js
+++ b/LexicalList.dev.js
@@ -786,7 +786,14 @@ class ListItemNode extends lexical.ElementNode {
}
getChecked() {
const self = this.getLatest();
- return self.__checked;
+ const parent = this.getParent();
+ if (!$isListNode(parent)) {
+ {
+ throw Error(`getChecked: list node is not parent of list item node`);
+ }
+ }
+ const listType = parent.getListType();
+ return listType === 'check' ? Boolean(self.__checked) : undefined;
}
setChecked(checked) {
const self = this.getWritable();
diff --git a/LexicalList.dev.mjs b/LexicalList.dev.mjs
index ea9b98569d9ec9e00a44cebb528d077d1a09c329..02a1f75aa98ea24a0145db4a5cac7d742df5fdc7 100644
--- a/LexicalList.dev.mjs
+++ b/LexicalList.dev.mjs
@@ -784,7 +784,14 @@ class ListItemNode extends ElementNode {
}
getChecked() {
const self = this.getLatest();
- return self.__checked;
+ const parent = this.getParent();
+ if (!$isListNode(parent)) {
+ {
+ throw Error(`getChecked: list node is not parent of list item node`);
+ }
+ }
+ const listType = parent.getListType();
+ return listType === 'check' ? Boolean(self.__checked) : undefined;
}
setChecked(checked) {
const self = this.getWritable();
diff --git a/LexicalList.prod.js b/LexicalList.prod.js
index 2e2b842e237a0bac6b5b33462a987a36f276e048..4f3786be432e1e9e6fff27cde202747fd14b0518 100644
--- a/LexicalList.prod.js
+++ b/LexicalList.prod.js
@@ -18,9 +18,10 @@ class I extends g.ElementNode{static getType(){return"listitem"}static clone(a){
value:this.getValue(),version:1}}append(...a){for(let b=0;b<a.length;b++){let c=a[b];if(g.$isElementNode(c)&&this.canMergeWith(c)){let d=c.getChildren();this.append(...d);c.remove()}else super.append(c)}return this}replace(a,b){if(q(a))return super.replace(a);this.setIndent(0);let c=this.getParentOrThrow();if(!r(c))return a;if(c.__first===this.getKey())c.insertBefore(a);else if(c.__last===this.getKey())c.insertAfter(a);else{let d=E(c.getListType()),e=this.getNextSibling();for(;e;){let f=e;e=e.getNextSibling();
d.append(f)}c.insertAfter(a);a.insertAfter(d)}b&&(g.$isElementNode(a)||l(139),this.getChildren().forEach(d=>{a.append(d)}));this.remove();0===c.getChildrenSize()&&c.remove();return a}insertAfter(a,b=!0){let c=this.getParentOrThrow();r(c)||l(39);if(q(a))return super.insertAfter(a,b);let d=this.getNextSiblings();c.insertAfter(a,b);if(0!==d.length){let e=E(c.getListType());d.forEach(f=>e.append(f));a.insertAfter(e,b)}return a}remove(a){let b=this.getPreviousSibling(),c=this.getNextSibling();super.remove(a);
b&&c&&v(b)&&v(c)&&(F(b.getFirstChild(),c.getFirstChild()),c.remove())}insertNewAfter(a,b=!0){a=y(null==this.__checked?void 0:!1);this.insertAfter(a,b);return a}collapseAtStart(a){let b=g.$createParagraphNode();this.getChildren().forEach(f=>b.append(f));var c=this.getParentOrThrow(),d=c.getParentOrThrow();let e=q(d);1===c.getChildrenSize()?e?(c.remove(),d.select()):(c.insertBefore(b),c.remove(),c=a.anchor,a=a.focus,d=b.getKey(),"element"===c.type&&c.getNode().is(this)&&c.set(d,c.offset,"element"),
-"element"===a.type&&a.getNode().is(this)&&a.set(d,a.offset,"element")):(c.insertBefore(b),this.remove());return!0}getValue(){return this.getLatest().__value}setValue(a){this.getWritable().__value=a}getChecked(){return this.getLatest().__checked}setChecked(a){this.getWritable().__checked=a}toggleChecked(){this.setChecked(!this.__checked)}getIndent(){var a=this.getParent();if(null===a)return this.getLatest().__indent;a=a.getParentOrThrow();let b=0;for(;q(a);)a=a.getParentOrThrow().getParentOrThrow(),
-b++;return b}setIndent(a){"number"===typeof a&&-1<a||l(117);let b=this.getIndent();for(;b!==a;)if(b<a){var c=new Set;if(!v(this)&&!c.has(this.getKey())){var d=this.getParent(),e=this.getNextSibling(),f=this.getPreviousSibling();if(v(e)&&v(f))d=f.getFirstChild(),r(d)&&(d.append(this),f=e.getFirstChild(),r(f)&&(f=f.getChildren(),A(d,f),e.remove(),c.add(e.getKey())));else if(v(e))e=e.getFirstChild(),r(e)&&(e=e.getFirstChild(),null!==e&&e.insertBefore(this));else if(v(f))e=f.getFirstChild(),r(e)&&e.append(this);
-else if(r(d)){c=y();let k=E(d.getListType());c.append(k);k.append(this);f?f.insertAfter(c):e?e.insertBefore(c):d.append(c)}}b++}else G(this),b--;return this}canInsertAfter(a){return q(a)}canReplaceWith(a){return q(a)}canMergeWith(a){return g.$isParagraphNode(a)||q(a)}extractWithChild(a,b){if(!g.$isRangeSelection(b))return!1;a=b.anchor.getNode();let c=b.focus.getNode();return this.isParentOf(a)&&this.isParentOf(c)&&this.getTextContent().length===b.getTextContent().length}isParentRequired(){return!0}createParentElementNode(){return E("bullet")}}
+"element"===a.type&&a.getNode().is(this)&&a.set(d,a.offset,"element")):(c.insertBefore(b),this.remove());return!0}getValue(){return this.getLatest().__value}setValue(a){this.getWritable().__value=a}getChecked(){let a=this.getLatest(),b=this.getParent();r(b)||l(188);return"check"===b.getListType()?!!a.__checked:void 0}setChecked(a){this.getWritable().__checked=a}toggleChecked(){this.setChecked(!this.__checked)}getIndent(){var a=this.getParent();if(null===a)return this.getLatest().__indent;a=a.getParentOrThrow();
+let b=0;for(;q(a);)a=a.getParentOrThrow().getParentOrThrow(),b++;return b}setIndent(a){"number"===typeof a&&-1<a||l(117);let b=this.getIndent();for(;b!==a;)if(b<a){var c=new Set;if(!v(this)&&!c.has(this.getKey())){var d=this.getParent(),e=this.getNextSibling(),f=this.getPreviousSibling();if(v(e)&&v(f))d=f.getFirstChild(),r(d)&&(d.append(this),f=e.getFirstChild(),r(f)&&(f=f.getChildren(),A(d,f),e.remove(),c.add(e.getKey())));else if(v(e))e=e.getFirstChild(),r(e)&&(e=e.getFirstChild(),null!==e&&e.insertBefore(this));
+else if(v(f))e=f.getFirstChild(),r(e)&&e.append(this);else if(r(d)){c=y();let k=E(d.getListType());c.append(k);k.append(this);f?f.insertAfter(c):e?e.insertBefore(c):d.append(c)}}b++}else G(this),b--;return this}canInsertAfter(a){return q(a)}canReplaceWith(a){return q(a)}canMergeWith(a){return g.$isParagraphNode(a)||q(a)}extractWithChild(a,b){if(!g.$isRangeSelection(b))return!1;a=b.anchor.getNode();let c=b.focus.getNode();return this.isParentOf(a)&&this.isParentOf(c)&&this.getTextContent().length===
+b.getTextContent().length}isParentRequired(){return!0}createParentElementNode(){return E("bullet")}}
function K(a,b,c){let d=[],e=[];var f=(b=b.list)?b.listitem:void 0;if(b&&b.nested)var k=b.nested.listitem;void 0!==f&&d.push(...H(f));if(b){f=c.getParent();f=r(f)&&"check"===f.getListType();let m=c.getChecked();f&&!m||e.push(b.listitemUnchecked);f&&m||e.push(b.listitemChecked);f&&d.push(m?b.listitemChecked:b.listitemUnchecked)}void 0!==k&&(k=H(k),c.getChildren().some(m=>r(m))?d.push(...k):e.push(...k));0<e.length&&h.removeClassNamesFromElement(a,...e);0<d.length&&h.addClassNamesToElement(a,...d)}
function J(a,b,c){r(b.getFirstChild())?(a.removeAttribute("role"),a.removeAttribute("tabIndex"),a.removeAttribute("aria-checked")):(a.setAttribute("role","checkbox"),a.setAttribute("tabIndex","-1"),c&&b.__checked===c.__checked||a.setAttribute("aria-checked",b.getChecked()?"true":"false"))}function L(a){a=h.isHTMLElement(a)&&"true"===a.getAttribute("aria-checked");return{node:y(a)}}function y(a){return g.$applyNodeReplacement(new I(void 0,a))}function q(a){return a instanceof I}
class M extends g.ElementNode{static getType(){return"list"}static clone(a){return new M(a.__listType||P[a.__tag],a.__start,a.__key)}constructor(a,b,c){super(c);this.__listType=a=P[a]||a;this.__tag="number"===a?"ol":"ul";this.__start=b}getTag(){return this.__tag}setListType(a){let b=this.getWritable();b.__listType=a;b.__tag="number"===a?"ol":"ul"}getListType(){return this.__listType}getStart(){return this.__start}createDOM(a){let b=document.createElement(this.__tag);1!==this.__start&&b.setAttribute("start",
diff --git a/LexicalList.prod.mjs b/LexicalList.prod.mjs
index 9cf3e024d5cdd334d32a49fcadadf2442585c5af..01b0ab8c27e39db188df0ba2390be7feb4b36b5a 100644
--- a/LexicalList.prod.mjs
+++ b/LexicalList.prod.mjs
@@ -6,4 +6,4 @@
*
*/
-import{$getSelection as e,$isRangeSelection as t,$isRootOrShadowRoot as n,$isElementNode as r,$isLeafNode as i,$createParagraphNode as s,$isParagraphNode as o,ElementNode as c,$applyNodeReplacement as l,$createTextNode as h,createCommand as a}from"lexical";import{$getNearestNodeOfType as u,removeClassNamesFromElement as g,addClassNamesToElement as d,isHTMLElement as f}from"@lexical/utils";function p(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var _=p((function(e){const t=new URLSearchParams;t.append("code",e);for(let e=1;e<arguments.length;e++)t.append("v",arguments[e]);throw Error(`Minified Lexical error #${e}; visit https://lexical.dev/docs/error?${t} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}));function m(e){let t=1,n=e.getParent();for(;null!=n;){if(R(n)){const e=n.getParent();if(U(e)){t++,n=e.getParent();continue}_(40)}return t}return t}function v(e){let t=e.getParent();U(t)||_(40);let n=t;for(;null!==n;)n=n.getParent(),U(n)&&(t=n);return t}function y(e){let t=[];const n=e.getChildren().filter(R);for(let e=0;e<n.length;e++){const r=n[e],i=r.getFirstChild();U(i)?t=t.concat(y(i)):t.push(r)}return t}function C(e){return R(e)&&U(e.getFirstChild())}function T(e){return I().append(e)}function k(e,t){return R(e)&&(0===t.length||1===t.length&&e.is(t[0])&&0===e.getChildrenSize())}function S(s,o){s.update((()=>{const s=e();if(null!==s){const e=s.getNodes();if(t(s)){const t=s.getStartEndPoints();null===t&&_(143);const[i]=t,c=i.getNode(),l=c.getParent();if(k(c,e)){const e=z(o);if(n(l)){c.replace(e);const t=I();r(c)&&(t.setFormat(c.getFormatType()),t.setIndent(c.getIndent())),e.append(t)}else if(R(c)){const t=c.getParentOrThrow();b(e,t.getChildren()),t.replace(e)}return}}const c=new Set;for(let t=0;t<e.length;t++){const s=e[t];if(!r(s)||!s.isEmpty()||R(s)||c.has(s.getKey())){if(i(s)){let e=s.getParent();for(;null!=e;){const t=e.getKey();if(U(e)){if(!c.has(t)){const n=z(o);b(n,e.getChildren()),e.replace(n),c.add(t)}break}{const r=e.getParent();if(n(r)&&!c.has(t)){c.add(t),P(e,o);break}e=r}}}}else P(s,o)}}}))}function b(e,t){e.splice(e.getChildrenSize(),0,t)}function P(e,t){if(U(e))return e;const n=e.getPreviousSibling(),r=e.getNextSibling(),i=I();if(i.setFormat(e.getFormatType()),i.setIndent(e.getIndent()),b(i,e.getChildren()),U(n)&&t===n.getListType())return n.append(i),e.remove(),U(r)&&t===r.getListType()&&(b(n,r.getChildren()),r.remove()),n;if(U(r)&&t===r.getListType())return r.getFirstChildOrThrow().insertBefore(i),e.remove(),r;{const n=z(t);return n.append(i),e.replace(n),n}}function x(e,t){const n=e.getLastChild(),r=t.getFirstChild();n&&r&&C(n)&&C(r)&&(x(n.getFirstChild(),r.getFirstChild()),r.remove());const i=t.getChildren();i.length>0&&e.append(...i),t.remove()}function A(n){n.update((()=>{const n=e();if(t(n)){const e=new Set,t=n.getNodes(),r=n.anchor.getNode();if(k(r,t))e.add(v(r));else for(let n=0;n<t.length;n++){const r=t[n];if(i(r)){const t=u(r,F);null!=t&&e.add(v(t))}}for(const t of e){let e=t;const r=y(t);for(const t of r){const r=s();b(r,t.getChildren()),e.insertAfter(r),e=r,t.__key===n.anchor.key&&n.anchor.set(r.getKey(),0,"element"),t.__key===n.focus.key&&n.focus.set(r.getKey(),0,"element"),t.remove()}t.remove()}}}))}function N(e){const t=new Set;if(C(e)||t.has(e.getKey()))return;const n=e.getParent(),r=e.getNextSibling(),i=e.getPreviousSibling();if(C(r)&&C(i)){const n=i.getFirstChild();if(U(n)){n.append(e);const i=r.getFirstChild();if(U(i)){b(n,i.getChildren()),r.remove(),t.add(r.getKey())}}}else if(C(r)){const t=r.getFirstChild();if(U(t)){const n=t.getFirstChild();null!==n&&n.insertBefore(e)}}else if(C(i)){const t=i.getFirstChild();U(t)&&t.append(e)}else if(U(n)){const t=I(),s=z(n.getListType());t.append(s),s.append(e),i?i.insertAfter(t):r?r.insertBefore(t):n.append(t)}}function O(e){if(C(e))return;const t=e.getParent(),n=t?t.getParent():void 0;if(U(n?n.getParent():void 0)&&R(n)&&U(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=t.getListType(),i=I(),s=z(r);i.append(s),e.getPreviousSiblings().forEach((e=>s.append(e)));const o=I(),c=z(r);o.append(c),b(c,e.getNextSiblings()),n.insertBefore(i),n.insertAfter(o),n.replace(e)}}}function L(){const r=e();if(!t(r)||!r.isCollapsed())return!1;const i=r.anchor.getNode();if(!R(i)||0!==i.getChildrenSize())return!1;const c=v(i),l=i.getParent();U(l)||_(40);const h=l.getParent();let a;if(n(h))a=s(),c.insertAfter(a);else{if(!R(h))return!1;a=I(),h.insertAfter(a)}a.select();const u=i.getNextSiblings();if(u.length>0){const e=z(l.getListType());if(o(a))a.insertAfter(e);else{const t=I();t.append(e),a.insertAfter(t)}u.forEach((t=>{t.remove(),e.append(t)}))}return function(e){let t=e;for(;null==t.getNextSibling()&&null==t.getPreviousSibling();){const e=t.getParent();if(null==e||!R(t)&&!U(t))break;t=e}t.remove()}(i),!0}function E(...e){const t=[];for(const n of e)if(n&&"string"==typeof n)for(const[e]of n.matchAll(/\S+/g))t.push(e);return t}class F extends c{static getType(){return"listitem"}static clone(e){return new F(e.__value,e.__checked,e.__key)}constructor(e,t,n){super(n),this.__value=void 0===e?1:e,this.__checked=t}createDOM(e){const t=document.createElement("li"),n=this.getParent();return U(n)&&"check"===n.getListType()&&w(t,this,null),t.value=this.__value,M(t,e.theme,this),t}updateDOM(e,t,n){const r=this.getParent();return U(r)&&"check"===r.getListType()&&w(t,this,e),t.value=this.__value,M(t,n.theme,this),!1}static transform(){return e=>{if(R(e)||_(144),null==e.__checked)return;const t=e.getParent();U(t)&&"check"!==t.getListType()&&null!=e.getChecked()&&e.setChecked(void 0)}}static importDOM(){return{li:e=>({conversion:D,priority:0})}}static importJSON(e){const t=I();return t.setChecked(e.checked),t.setValue(e.value),t.setFormat(e.format),t.setDirection(e.direction),t}exportDOM(e){const t=this.createDOM(e._config);return t.style.textAlign=this.getFormatType(),{element:t}}exportJSON(){return{...super.exportJSON(),checked:this.getChecked(),type:"listitem",value:this.getValue(),version:1}}append(...e){for(let t=0;t<e.length;t++){const n=e[t];if(r(n)&&this.canMergeWith(n)){const e=n.getChildren();this.append(...e),n.remove()}else super.append(n)}return this}replace(e,t){if(R(e))return super.replace(e);this.setIndent(0);const n=this.getParentOrThrow();if(!U(n))return e;if(n.__first===this.getKey())n.insertBefore(e);else if(n.__last===this.getKey())n.insertAfter(e);else{const t=z(n.getListType());let r=this.getNextSibling();for(;r;){const e=r;r=r.getNextSibling(),t.append(e)}n.insertAfter(e),e.insertAfter(t)}return t&&(r(e)||_(139),this.getChildren().forEach((t=>{e.append(t)}))),this.remove(),0===n.getChildrenSize()&&n.remove(),e}insertAfter(e,t=!0){const n=this.getParentOrThrow();if(U(n)||_(39),R(e))return super.insertAfter(e,t);const r=this.getNextSiblings();if(n.insertAfter(e,t),0!==r.length){const i=z(n.getListType());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&&C(t)&&C(n)&&(x(t.getFirstChild(),n.getFirstChild()),n.remove())}insertNewAfter(e,t=!0){const n=I(null==this.__checked&&void 0);return this.insertAfter(n,t),n}collapseAtStart(e){const t=s();this.getChildren().forEach((e=>t.append(e)));const n=this.getParentOrThrow(),r=n.getParentOrThrow(),i=R(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){this.getWritable().__value=e}getChecked(){return this.getLatest().__checked}setChecked(e){this.getWritable().__checked=e}toggleChecked(){this.setChecked(!this.__checked)}getIndent(){const e=this.getParent();if(null===e)return this.getLatest().__indent;let t=e.getParentOrThrow(),n=0;for(;R(t);)t=t.getParentOrThrow().getParentOrThrow(),n++;return n}setIndent(e){"number"==typeof e&&e>-1||_(117);let t=this.getIndent();for(;t!==e;)t<e?(N(this),t++):(O(this),t--);return this}canInsertAfter(e){return R(e)}canReplaceWith(e){return R(e)}canMergeWith(e){return o(e)||R(e)}extractWithChild(e,n){if(!t(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 z("bullet")}}function M(e,t,n){const r=[],i=[],s=t.list,o=s?s.listitem:void 0;let c;if(s&&s.nested&&(c=s.nested.listitem),void 0!==o&&r.push(...E(o)),s){const e=n.getParent(),t=U(e)&&"check"===e.getListType(),o=n.getChecked();t&&!o||i.push(s.listitemUnchecked),t&&o||i.push(s.listitemChecked),t&&r.push(o?s.listitemChecked:s.listitemUnchecked)}if(void 0!==c){const e=E(c);n.getChildren().some((e=>U(e)))?r.push(...e):i.push(...e)}i.length>0&&g(e,...i),r.length>0&&d(e,...r)}function w(e,t,n,r){U(t.getFirstChild())?(e.removeAttribute("role"),e.removeAttribute("tabIndex"),e.removeAttribute("aria-checked")):(e.setAttribute("role","checkbox"),e.setAttribute("tabIndex","-1"),n&&t.__checked===n.__checked||e.setAttribute("aria-checked",t.getChecked()?"true":"false"))}function D(e){return{node:I(f(e)&&"true"===e.getAttribute("aria-checked"))}}function I(e){return l(new F(void 0,e))}function R(e){return e instanceof F}class K extends c{static getType(){return"list"}static clone(e){const t=e.__listType||J[e.__tag];return new K(t,e.__start,e.__key)}constructor(e,t,n){super(n);const r=J[e]||e;this.__listType=r,this.__tag="number"===r?"ol":"ul",this.__start=t}getTag(){return this.__tag}setListType(e){const t=this.getWritable();t.__listType=e,t.__tag="number"===e?"ol":"ul"}getListType(){return this.__listType}getStart(){return this.__start}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,B(r,e.theme,this),r}updateDOM(e,t,n){return e.__tag!==this.__tag||(B(t,n.theme,this),!1)}static transform(){return e=>{U(e)||_(163),function(e){const t=e.getNextSibling();U(t)&&e.getListType()===t.getListType()&&x(e,t)}(e),function(e){const t="check"!==e.getListType();let n=e.getStart();for(const r of e.getChildren())R(r)&&(r.getValue()!==n&&r.setValue(n),t&&null!=r.getChecked()&&r.setChecked(void 0),U(r.getFirstChild())||n++)}(e)}}static importDOM(){return{ol:e=>({conversion:V,priority:0}),ul:e=>({conversion:V,priority:0})}}static importJSON(e){const t=z(e.listType,e.start);return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}exportDOM(e){const{element:t}=super.exportDOM(e);return t&&f(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(),type:"list",version:1}}canBeEmpty(){return!1}canIndent(){return!1}append(...e){for(let t=0;t<e.length;t++){const n=e[t];if(R(n))super.append(n);else{const e=I();if(U(n))e.append(n);else if(r(n)){const t=h(n.getTextContent());e.append(t)}else e.append(n);super.append(e)}}return this}extractWithChild(e){return R(e)}}function B(e,t,n){const r=[],i=[],s=t.list;if(void 0!==s){const e=s[`${n.__tag}Depth`]||[],t=m(n)-1,o=t%e.length,c=e[o],l=s[n.__tag];let h;const a=s.nested,u=s.checklist;if(void 0!==a&&a.list&&(h=a.list),void 0!==l&&r.push(l),void 0!==u&&"check"===n.__listType&&r.push(u),void 0!==c){r.push(...E(c));for(let t=0;t<e.length;t++)t!==o&&i.push(n.__tag+t)}if(void 0!==h){const e=E(h);t>1?r.push(...e):i.push(...e)}}i.length>0&&g(e,...i),r.length>0&&d(e,...r)}function W(e){const t=[];for(let n=0;n<e.length;n++){const r=e[n];if(R(r)){t.push(r);const e=r.getChildren();e.length>1&&e.forEach((e=>{U(e)&&t.push(T(e))}))}else t.push(T(r))}return t}function V(e){const t=e.nodeName.toLowerCase();let n=null;if("ol"===t){n=z("number",e.start)}else"ul"===t&&(n=f(e)&&"check"===e.getAttribute("__lexicallisttype")?z("check"):z("bullet"));return{after:W,node:n}}const J={ol:"number",ul:"bullet"};function z(e,t=1){return l(new K(e,t))}function U(e){return e instanceof K}const $=a("INSERT_UNORDERED_LIST_COMMAND"),j=a("INSERT_ORDERED_LIST_COMMAND"),q=a("INSERT_CHECK_LIST_COMMAND"),H=a("REMOVE_LIST_COMMAND");export{I as $createListItemNode,z as $createListNode,m as $getListDepth,L as $handleListInsertParagraph,R as $isListItemNode,U as $isListNode,q as INSERT_CHECK_LIST_COMMAND,j as INSERT_ORDERED_LIST_COMMAND,$ as INSERT_UNORDERED_LIST_COMMAND,F as ListItemNode,K as ListNode,H as REMOVE_LIST_COMMAND,S as insertList,A as removeList};
+import{$getSelection as e,$isRangeSelection as t,$isRootOrShadowRoot as n,$isElementNode as r,$isLeafNode as i,$createParagraphNode as s,$isParagraphNode as o,ElementNode as c,$applyNodeReplacement as l,$createTextNode as h,createCommand as a}from"lexical";import{$getNearestNodeOfType as u,removeClassNamesFromElement as g,addClassNamesToElement as d,isHTMLElement as f}from"@lexical/utils";function p(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var _=p((function(e){const t=new URLSearchParams;t.append("code",e);for(let e=1;e<arguments.length;e++)t.append("v",arguments[e]);throw Error(`Minified Lexical error #${e}; visit https://lexical.dev/docs/error?${t} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}));function m(e){let t=1,n=e.getParent();for(;null!=n;){if(R(n)){const e=n.getParent();if(U(e)){t++,n=e.getParent();continue}_(40)}return t}return t}function v(e){let t=e.getParent();U(t)||_(40);let n=t;for(;null!==n;)n=n.getParent(),U(n)&&(t=n);return t}function y(e){let t=[];const n=e.getChildren().filter(R);for(let e=0;e<n.length;e++){const r=n[e],i=r.getFirstChild();U(i)?t=t.concat(y(i)):t.push(r)}return t}function C(e){return R(e)&&U(e.getFirstChild())}function T(e){return I().append(e)}function k(e,t){return R(e)&&(0===t.length||1===t.length&&e.is(t[0])&&0===e.getChildrenSize())}function S(s,o){s.update((()=>{const s=e();if(null!==s){const e=s.getNodes();if(t(s)){const t=s.getStartEndPoints();null===t&&_(143);const[i]=t,c=i.getNode(),l=c.getParent();if(k(c,e)){const e=z(o);if(n(l)){c.replace(e);const t=I();r(c)&&(t.setFormat(c.getFormatType()),t.setIndent(c.getIndent())),e.append(t)}else if(R(c)){const t=c.getParentOrThrow();b(e,t.getChildren()),t.replace(e)}return}}const c=new Set;for(let t=0;t<e.length;t++){const s=e[t];if(!r(s)||!s.isEmpty()||R(s)||c.has(s.getKey())){if(i(s)){let e=s.getParent();for(;null!=e;){const t=e.getKey();if(U(e)){if(!c.has(t)){const n=z(o);b(n,e.getChildren()),e.replace(n),c.add(t)}break}{const r=e.getParent();if(n(r)&&!c.has(t)){c.add(t),P(e,o);break}e=r}}}}else P(s,o)}}}))}function b(e,t){e.splice(e.getChildrenSize(),0,t)}function P(e,t){if(U(e))return e;const n=e.getPreviousSibling(),r=e.getNextSibling(),i=I();if(i.setFormat(e.getFormatType()),i.setIndent(e.getIndent()),b(i,e.getChildren()),U(n)&&t===n.getListType())return n.append(i),e.remove(),U(r)&&t===r.getListType()&&(b(n,r.getChildren()),r.remove()),n;if(U(r)&&t===r.getListType())return r.getFirstChildOrThrow().insertBefore(i),e.remove(),r;{const n=z(t);return n.append(i),e.replace(n),n}}function x(e,t){const n=e.getLastChild(),r=t.getFirstChild();n&&r&&C(n)&&C(r)&&(x(n.getFirstChild(),r.getFirstChild()),r.remove());const i=t.getChildren();i.length>0&&e.append(...i),t.remove()}function A(n){n.update((()=>{const n=e();if(t(n)){const e=new Set,t=n.getNodes(),r=n.anchor.getNode();if(k(r,t))e.add(v(r));else for(let n=0;n<t.length;n++){const r=t[n];if(i(r)){const t=u(r,F);null!=t&&e.add(v(t))}}for(const t of e){let e=t;const r=y(t);for(const t of r){const r=s();b(r,t.getChildren()),e.insertAfter(r),e=r,t.__key===n.anchor.key&&n.anchor.set(r.getKey(),0,"element"),t.__key===n.focus.key&&n.focus.set(r.getKey(),0,"element"),t.remove()}t.remove()}}}))}function N(e){const t=new Set;if(C(e)||t.has(e.getKey()))return;const n=e.getParent(),r=e.getNextSibling(),i=e.getPreviousSibling();if(C(r)&&C(i)){const n=i.getFirstChild();if(U(n)){n.append(e);const i=r.getFirstChild();if(U(i)){b(n,i.getChildren()),r.remove(),t.add(r.getKey())}}}else if(C(r)){const t=r.getFirstChild();if(U(t)){const n=t.getFirstChild();null!==n&&n.insertBefore(e)}}else if(C(i)){const t=i.getFirstChild();U(t)&&t.append(e)}else if(U(n)){const t=I(),s=z(n.getListType());t.append(s),s.append(e),i?i.insertAfter(t):r?r.insertBefore(t):n.append(t)}}function O(e){if(C(e))return;const t=e.getParent(),n=t?t.getParent():void 0;if(U(n?n.getParent():void 0)&&R(n)&&U(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=t.getListType(),i=I(),s=z(r);i.append(s),e.getPreviousSiblings().forEach((e=>s.append(e)));const o=I(),c=z(r);o.append(c),b(c,e.getNextSiblings()),n.insertBefore(i),n.insertAfter(o),n.replace(e)}}}function L(){const r=e();if(!t(r)||!r.isCollapsed())return!1;const i=r.anchor.getNode();if(!R(i)||0!==i.getChildrenSize())return!1;const c=v(i),l=i.getParent();U(l)||_(40);const h=l.getParent();let a;if(n(h))a=s(),c.insertAfter(a);else{if(!R(h))return!1;a=I(),h.insertAfter(a)}a.select();const u=i.getNextSiblings();if(u.length>0){const e=z(l.getListType());if(o(a))a.insertAfter(e);else{const t=I();t.append(e),a.insertAfter(t)}u.forEach((t=>{t.remove(),e.append(t)}))}return function(e){let t=e;for(;null==t.getNextSibling()&&null==t.getPreviousSibling();){const e=t.getParent();if(null==e||!R(t)&&!U(t))break;t=e}t.remove()}(i),!0}function E(...e){const t=[];for(const n of e)if(n&&"string"==typeof n)for(const[e]of n.matchAll(/\S+/g))t.push(e);return t}class F extends c{static getType(){return"listitem"}static clone(e){return new F(e.__value,e.__checked,e.__key)}constructor(e,t,n){super(n),this.__value=void 0===e?1:e,this.__checked=t}createDOM(e){const t=document.createElement("li"),n=this.getParent();return U(n)&&"check"===n.getListType()&&w(t,this,null),t.value=this.__value,M(t,e.theme,this),t}updateDOM(e,t,n){const r=this.getParent();return U(r)&&"check"===r.getListType()&&w(t,this,e),t.value=this.__value,M(t,n.theme,this),!1}static transform(){return e=>{if(R(e)||_(144),null==e.__checked)return;const t=e.getParent();U(t)&&"check"!==t.getListType()&&null!=e.getChecked()&&e.setChecked(void 0)}}static importDOM(){return{li:e=>({conversion:D,priority:0})}}static importJSON(e){const t=I();return t.setChecked(e.checked),t.setValue(e.value),t.setFormat(e.format),t.setDirection(e.direction),t}exportDOM(e){const t=this.createDOM(e._config);return t.style.textAlign=this.getFormatType(),{element:t}}exportJSON(){return{...super.exportJSON(),checked:this.getChecked(),type:"listitem",value:this.getValue(),version:1}}append(...e){for(let t=0;t<e.length;t++){const n=e[t];if(r(n)&&this.canMergeWith(n)){const e=n.getChildren();this.append(...e),n.remove()}else super.append(n)}return this}replace(e,t){if(R(e))return super.replace(e);this.setIndent(0);const n=this.getParentOrThrow();if(!U(n))return e;if(n.__first===this.getKey())n.insertBefore(e);else if(n.__last===this.getKey())n.insertAfter(e);else{const t=z(n.getListType());let r=this.getNextSibling();for(;r;){const e=r;r=r.getNextSibling(),t.append(e)}n.insertAfter(e),e.insertAfter(t)}return t&&(r(e)||_(139),this.getChildren().forEach((t=>{e.append(t)}))),this.remove(),0===n.getChildrenSize()&&n.remove(),e}insertAfter(e,t=!0){const n=this.getParentOrThrow();if(U(n)||_(39),R(e))return super.insertAfter(e,t);const r=this.getNextSiblings();if(n.insertAfter(e,t),0!==r.length){const i=z(n.getListType());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&&C(t)&&C(n)&&(x(t.getFirstChild(),n.getFirstChild()),n.remove())}insertNewAfter(e,t=!0){const n=I(null==this.__checked&&void 0);return this.insertAfter(n,t),n}collapseAtStart(e){const t=s();this.getChildren().forEach((e=>t.append(e)));const n=this.getParentOrThrow(),r=n.getParentOrThrow(),i=R(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){this.getWritable().__value=e}getChecked(){const e=this.getLatest(),t=this.getParent();U(t)||_(188);return"check"===t.getListType()?Boolean(e.__checked):void 0}setChecked(e){this.getWritable().__checked=e}toggleChecked(){this.setChecked(!this.__checked)}getIndent(){const e=this.getParent();if(null===e)return this.getLatest().__indent;let t=e.getParentOrThrow(),n=0;for(;R(t);)t=t.getParentOrThrow().getParentOrThrow(),n++;return n}setIndent(e){"number"==typeof e&&e>-1||_(117);let t=this.getIndent();for(;t!==e;)t<e?(N(this),t++):(O(this),t--);return this}canInsertAfter(e){return R(e)}canReplaceWith(e){return R(e)}canMergeWith(e){return o(e)||R(e)}extractWithChild(e,n){if(!t(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 z("bullet")}}function M(e,t,n){const r=[],i=[],s=t.list,o=s?s.listitem:void 0;let c;if(s&&s.nested&&(c=s.nested.listitem),void 0!==o&&r.push(...E(o)),s){const e=n.getParent(),t=U(e)&&"check"===e.getListType(),o=n.getChecked();t&&!o||i.push(s.listitemUnchecked),t&&o||i.push(s.listitemChecked),t&&r.push(o?s.listitemChecked:s.listitemUnchecked)}if(void 0!==c){const e=E(c);n.getChildren().some((e=>U(e)))?r.push(...e):i.push(...e)}i.length>0&&g(e,...i),r.length>0&&d(e,...r)}function w(e,t,n,r){U(t.getFirstChild())?(e.removeAttribute("role"),e.removeAttribute("tabIndex"),e.removeAttribute("aria-checked")):(e.setAttribute("role","checkbox"),e.setAttribute("tabIndex","-1"),n&&t.__checked===n.__checked||e.setAttribute("aria-checked",t.getChecked()?"true":"false"))}function D(e){return{node:I(f(e)&&"true"===e.getAttribute("aria-checked"))}}function I(e){return l(new F(void 0,e))}function R(e){return e instanceof F}class B extends c{static getType(){return"list"}static clone(e){const t=e.__listType||J[e.__tag];return new B(t,e.__start,e.__key)}constructor(e,t,n){super(n);const r=J[e]||e;this.__listType=r,this.__tag="number"===r?"ol":"ul",this.__start=t}getTag(){return this.__tag}setListType(e){const t=this.getWritable();t.__listType=e,t.__tag="number"===e?"ol":"ul"}getListType(){return this.__listType}getStart(){return this.__start}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,K(r,e.theme,this),r}updateDOM(e,t,n){return e.__tag!==this.__tag||(K(t,n.theme,this),!1)}static transform(){return e=>{U(e)||_(163),function(e){const t=e.getNextSibling();U(t)&&e.getListType()===t.getListType()&&x(e,t)}(e),function(e){const t="check"!==e.getListType();let n=e.getStart();for(const r of e.getChildren())R(r)&&(r.getValue()!==n&&r.setValue(n),t&&null!=r.getChecked()&&r.setChecked(void 0),U(r.getFirstChild())||n++)}(e)}}static importDOM(){return{ol:e=>({conversion:V,priority:0}),ul:e=>({conversion:V,priority:0})}}static importJSON(e){const t=z(e.listType,e.start);return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}exportDOM(e){const{element:t}=super.exportDOM(e);return t&&f(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(),type:"list",version:1}}canBeEmpty(){return!1}canIndent(){return!1}append(...e){for(let t=0;t<e.length;t++){const n=e[t];if(R(n))super.append(n);else{const e=I();if(U(n))e.append(n);else if(r(n)){const t=h(n.getTextContent());e.append(t)}else e.append(n);super.append(e)}}return this}extractWithChild(e){return R(e)}}function K(e,t,n){const r=[],i=[],s=t.list;if(void 0!==s){const e=s[`${n.__tag}Depth`]||[],t=m(n)-1,o=t%e.length,c=e[o],l=s[n.__tag];let h;const a=s.nested,u=s.checklist;if(void 0!==a&&a.list&&(h=a.list),void 0!==l&&r.push(l),void 0!==u&&"check"===n.__listType&&r.push(u),void 0!==c){r.push(...E(c));for(let t=0;t<e.length;t++)t!==o&&i.push(n.__tag+t)}if(void 0!==h){const e=E(h);t>1?r.push(...e):i.push(...e)}}i.length>0&&g(e,...i),r.length>0&&d(e,...r)}function W(e){const t=[];for(let n=0;n<e.length;n++){const r=e[n];if(R(r)){t.push(r);const e=r.getChildren();e.length>1&&e.forEach((e=>{U(e)&&t.push(T(e))}))}else t.push(T(r))}return t}function V(e){const t=e.nodeName.toLowerCase();let n=null;if("ol"===t){n=z("number",e.start)}else"ul"===t&&(n=f(e)&&"check"===e.getAttribute("__lexicallisttype")?z("check"):z("bullet"));return{after:W,node:n}}const J={ol:"number",ul:"bullet"};function z(e,t=1){return l(new B(e,t))}function U(e){return e instanceof B}const $=a("INSERT_UNORDERED_LIST_COMMAND"),j=a("INSERT_ORDERED_LIST_COMMAND"),q=a("INSERT_CHECK_LIST_COMMAND"),H=a("REMOVE_LIST_COMMAND");export{I as $createListItemNode,z as $createListNode,m as $getListDepth,L as $handleListInsertParagraph,R as $isListItemNode,U as $isListNode,q as INSERT_CHECK_LIST_COMMAND,j as INSERT_ORDERED_LIST_COMMAND,$ as INSERT_UNORDERED_LIST_COMMAND,F as ListItemNode,B as ListNode,H as REMOVE_LIST_COMMAND,S as insertList,A as removeList};