@lexical/list
Advanced tools
@@ -9,2 +9,2 @@ /** | ||
| "use strict";var e=require("@lexical/utils"),t=require("lexical"),n=require("@lexical/extension"),r=require("@lexical/html");function i(e,...t){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",e);for(const e of t)r.append("v",e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function s(e){let t=1,n=e.getParent();for(;null!=n;){if(O(n)){const e=n.getParent();if(M(e)){t++,n=e.getParent();continue}i(40)}return t}return t}function o(e){let t=e.getParent();M(t)||i(40);let n=t;for(;null!==n;)n=n.getParent(),M(n)&&(t=n);return t}function l(e){let t=[];const n=e.getChildren().filter(O);for(let e=0;e<n.length;e++){const r=n[e],i=r.getFirstChild();M(i)?t=t.concat(l(i)):t.push(r)}return t}function c(e){return O(e)&&M(e.getFirstChild())}function a(e,t){return O(e)&&(0===t.length||1===t.length&&e.is(t[0])&&0===e.getChildrenSize())}function d(e){const n=t.$getSelection();if(null!==n){let r=n.getNodes();if(t.$isRangeSelection(n)){const[i]=n.getStartEndPoints(),s=i.getNode(),o=s.getParent();if(t.$isRootOrShadowRoot(s)){const e=s.getFirstChild();if(e)r=e.selectStart().getNodes();else{const e=t.$createParagraphNode();s.append(e),r=e.select().getNodes()}}else if(a(s,r)){const n=k(e);if(t.$isRootOrShadowRoot(o)){s.replace(n);const e=x();t.$isElementNode(s)&&(e.setFormat(s.getFormatType()),e.setIndent(s.getIndent())),n.append(e)}else if(O(s)){const e=s.getParentOrThrow();g(n,e.getChildren()),e.replace(n)}return}}const i=new Set;for(let n=0;n<r.length;n++){const s=r[n];if(t.$isElementNode(s)&&s.isEmpty()&&!O(s)&&!i.has(s.getKey())){u(s,e);continue}let o=t.$isLeafNode(s)?s.getParent():O(s)&&s.isEmpty()?s:null;for(;null!=o;){const n=o.getKey();if(M(o)){if(!i.has(n)){const t=k(e);g(t,o.getChildren()),o.replace(t),i.add(n)}break}{const r=o.getParent();if(t.$isRootOrShadowRoot(r)&&!i.has(n)){i.add(n),u(o,e);break}o=r}}}}}function g(e,t){e.splice(e.getChildrenSize(),0,t)}function u(e,n){if(M(e))return e;const r=e.getPreviousSibling(),i=e.getNextSibling(),s=x();let o;if(g(s,e.getChildren()),M(r)&&n===r.getListType())r.append(s),M(i)&&n===i.getListType()&&(g(r,i.getChildren()),i.remove()),o=r;else if(M(i)&&n===i.getListType())i.getFirstChildOrThrow().insertBefore(s),o=i;else{const t=k(n);t.append(s),e.replace(t),o=t}s.setFormat(e.getFormatType()),s.setIndent(e.getIndent());const l=t.$getSelection();return t.$isRangeSelection(l)&&(o.getKey()===l.anchor.key&&l.anchor.set(s.getKey(),l.anchor.offset,"element"),o.getKey()===l.focus.key&&l.focus.set(s.getKey(),l.focus.offset,"element")),e.remove(),o}function h(e,t){const n=e.getLastChild(),r=t.getFirstChild();n&&r&&c(n)&&c(r)&&(h(n.getFirstChild(),r.getFirstChild()),r.remove());const i=t.getChildren();i.length>0&&e.append(...i),t.remove()}function p(){const n=t.$getSelection();if(t.$isRangeSelection(n)){const r=new Set,i=n.getNodes(),s=n.anchor.getNode();if(a(s,i))r.add(o(s));else for(let n=0;n<i.length;n++){const s=i[n];if(t.$isLeafNode(s)){const t=e.$getNearestNodeOfType(s,N);null!=t&&r.add(o(t))}}for(const e of r){let r=e;const i=l(e);for(const e of i){const i=t.$createParagraphNode().setTextStyle(n.style).setTextFormat(n.format);g(i,e.getChildren()),r.insertAfter(i),r=i,e.__key===n.anchor.key&&t.$setPointFromCaret(n.anchor,t.$normalizeCaret(t.$getChildCaret(i,"next"))),e.__key===n.focus.key&&t.$setPointFromCaret(n.focus,t.$normalizeCaret(t.$getChildCaret(i,"next"))),e.remove()}e.remove()}}}function f(e){const t="check"!==e.getListType();let n=e.getStart();for(const r of e.getChildren())O(r)&&(r.getValue()!==n&&r.setValue(n),t&&null!=r.getLatest().__checked&&r.setChecked(void 0),M(r.getFirstChild())||n++)}function m(e){const n=new Set;if(c(e)||n.has(e.getKey()))return;const r=e.getParent(),i=e.getNextSibling(),s=e.getPreviousSibling();if(c(i)&&c(s)){const t=s.getFirstChild();if(M(t)){t.append(e);const r=i.getFirstChild();if(M(r)){g(t,r.getChildren()),i.remove(),n.add(i.getKey())}}}else if(c(i)){const t=i.getFirstChild();if(M(t)){const n=t.getFirstChild();null!==n&&n.insertBefore(e)}}else if(c(s)){const t=s.getFirstChild();M(t)&&t.append(e)}else if(M(r)){const n=t.$copyNode(e),o=t.$copyNode(r);n.append(o),o.append(e),s?s.insertAfter(n):i?i.insertBefore(n):r.append(n)}}function _(e){if(c(e))return;const n=e.getParent(),r=n?n.getParent():void 0;if(M(r?r.getParent():void 0)&&O(r)&&M(n)){const i=n?n.getFirstChild():void 0,s=n?n.getLastChild():void 0;if(e.is(i))r.insertBefore(e),n.isEmpty()&&r.remove();else if(e.is(s))r.insertAfter(e),n.isEmpty()&&r.remove();else{const i=t.$copyNode(e),s=t.$copyNode(n);i.append(s),e.getPreviousSiblings().forEach(e=>s.append(e));const o=t.$copyNode(e),l=t.$copyNode(n);o.append(l),g(l,e.getNextSiblings()),r.insertBefore(i),r.insertAfter(o),r.replace(e)}}}function C(e=!1){const n=t.$getSelection();if(!t.$isRangeSelection(n)||!n.isCollapsed())return!1;const r=n.anchor.getNode();let s=null;if(O(r)&&0===r.getChildrenSize())s=r;else if(t.$isTextNode(r)){const e=r.getParent();O(e)&&e.getChildren().every(e=>t.$isTextNode(e)&&""===e.getTextContent().trim())&&(s=e)}if(null===s)return!1;const l=o(s),c=s.getParent();M(c)||i(40);const a=c.getParent();let d;if(t.$isRootOrShadowRoot(a))d=t.$createParagraphNode(),l.insertAfter(d);else{if(!O(a))return!1;d=t.$copyNode(a),a.insertAfter(d)}d.setTextStyle(n.style).setTextFormat(n.format).select();const g=s.getNextSiblings();if(g.length>0){const n=e?function(e,t){return e.getStart()+t.getIndexWithinParent()}(c,s):1,r=t.$copyNode(c).setStart(n);if(O(d)){const e=t.$copyNode(d);e.append(r),d.insertAfter(e)}else d.insertAfter(r);r.append(...g)}return function(e){let t=e;for(;null==t.getNextSibling()&&null==t.getPreviousSibling();){const e=t.getParent();if(null==e||!O(e)&&!M(e))break;t=e}t.remove()}(s),!0}class N extends t.ElementNode{__value;__checked;$config(){return this.config("listitem",{$transform:n=>{const r=n.getParent();if(M(r))"check"!==r.getListType()&&null!=n.getChecked()&&n.setChecked(void 0);else if(r){const s=n.createParentElementNode();M(s)||i(340);const o=[n];for(const e of["previous","next"]){o.reverse();for(const{origin:r}of t.$getSiblingCaret(n,e)){if(!O(r))break;o.push(r)}}n.insertBefore(s),s.splice(0,0,o),t.$isRootOrShadowRoot(r)||(e.$insertNodeToNearestRootAtCaret(s,t.$rewindSiblingCaret(t.$getSiblingCaret(s,"next")),{$shouldSplit:()=>!1,removeEmptyDestination:!0}),r.isEmpty()&&r.isAttached()&&r.remove())}},extends:t.ElementNode,importDOM:t.buildImportMap({li:()=>({conversion:y,priority:0})})})}constructor(e=1,t=void 0,n){super(n),this.__value=void 0===e?1:e,this.__checked=t}afterCloneFrom(e){super.afterCloneFrom(e),this.__value=e.__value,this.__checked=e.__checked}createDOM(e){const t=document.createElement("li");return this.updateListItemDOM(null,t,e),t}updateListItemDOM(n,r,i){!function(e,t){const n=t.getParent();!M(n)||"check"!==n.getListType()||M(t.getFirstChild())?(e.removeAttribute("role"),e.removeAttribute("tabIndex"),e.removeAttribute("aria-checked")):(e.setAttribute("role","checkbox"),e.setAttribute("tabIndex","-1"),e.setAttribute("aria-checked",t.getChecked()?"true":"false"))}(r,this),r.value=this.__value,function(n,r,i){const s=r.list;if(!s)return;const o=s.listitem,l=s.nested&&s.nested.listitem,c=i.getParent(),a=M(c)&&"check"===c.getListType(),d=i.getChecked(),g=i.getChildren().some(e=>M(e)),u=[];void 0!==s.listitemChecked&&u.push(s.listitemChecked);void 0!==s.listitemUnchecked&&u.push(s.listitemUnchecked);void 0!==l&&u.push(...t.normalizeClassNames(l));u.length>0&&e.removeClassNamesFromElement(n,...u);const h=[];void 0!==o&&h.push(...t.normalizeClassNames(o));if(a){const e=d?s.listitemChecked:s.listitemUnchecked;void 0!==e&&h.push(e)}void 0!==l&&g&&h.push(...t.normalizeClassNames(l));h.length>0&&e.addClassNamesToElement(n,...h)}(r,i.theme,this);const s=n?n.__style:"",o=this.__style;s!==o&&t.setDOMStyleFromCSS(r.style,o,s),function(e,n,r){const i=n.__textStyle,s=r?r.__textStyle:"";if(null!==r&&s===i)return;const o=t.getStyleObjectFromCSS(i);for(const t in o)e.style.setProperty(`--listitem-marker-${t}`,o[t]);if(""!==s)for(const n in t.getStyleObjectFromCSS(s))n in o||e.style.removeProperty(`--listitem-marker-${n}`)}(r,this,n)}updateDOM(e,t,n){const r=t;return this.updateListItemDOM(e,r,n),!1}updateFromJSON(e){return super.updateFromJSON(e).setValue(e.value).setChecked(e.checked)}exportDOM(e){const n=this.createDOM(e._config),r=this.getFormatType();r&&(n.style.textAlign=r);const i=this.getDirection();return i&&(n.dir=i),c(this)?{after(e){if(t.isHTMLElement(e)){const n=e.previousElementSibling;if(t.isHTMLElement(n)&&"LI"===n.nodeName){for(;e.firstChild;)n.append(e.firstChild);e.remove()}}return e},element:n}:{element:n}}exportJSON(){return{...super.exportJSON(),checked:this.getChecked(),value:this.getValue()}}append(...e){for(let n=0;n<e.length;n++){const r=e[n];if(t.$isElementNode(r)&&this.canMergeWith(r)){const e=r.getChildren();this.append(...e),r.remove()}else super.append(r)}return this}replace(e,n){if(O(e))return super.replace(e);this.setIndent(0);const r=this.getParentOrThrow();if(!M(r))return e;if(r.__first===this.getKey())r.insertBefore(e);else if(r.__last===this.getKey())r.insertAfter(e);else{const n=t.$copyNode(r);let i=this.getNextSibling();for(;i;){const e=i;i=i.getNextSibling(),n.append(e)}r.insertAfter(e),e.insertAfter(n)}const s=this.__key;let o=0;if(n&&(t.$isElementNode(e)||i(139),o=e.getChildrenSize(),e.splice(o,0,this.getChildren())),n&&t.$isElementNode(e)){const n=t.$getSelection();if(t.$isRangeSelection(n))for(const t of n.getStartEndPoints())t.key===s&&"element"===t.type&&t.set(e.getKey(),o+t.offset,"element")}return this.remove(),0===r.getChildrenSize()&&r.remove(),e}insertAfter(e,n=!0){const r=this.getParentOrThrow();if(M(r)||i(39),O(e))return super.insertAfter(e,n);const s=this.getNextSiblings();if(r.insertAfter(e,n),0!==s.length){const i=t.$copyNode(r);s.forEach(e=>i.append(e)),e.insertAfter(i,n)}return e}remove(e){const t=this.getPreviousSibling(),n=this.getNextSibling();super.remove(e),t&&n&&c(t)&&c(n)&&(h(t.getFirstChild(),n.getFirstChild()),n.remove())}resetOnCopyNodeFrom(e){super.resetOnCopyNodeFrom(e),e.getChecked()&&this.setChecked(!1)}insertNewAfter(e,n=!0){const r=t.$copyNode(this);return this.insertAfter(r,n),r}collapseAtStart(e){const n=t.$createParagraphNode();this.getChildren().forEach(e=>n.append(e));const r=this.getParentOrThrow(),i=r.getParentOrThrow(),s=O(i);if(1===r.getChildrenSize())if(s)r.remove(),i.select();else{r.insertBefore(n),r.remove();const t=e.anchor,i=e.focus,s=n.getKey();"element"===t.type&&t.getNode().is(this)&&t.set(s,t.offset,"element"),"element"===i.type&&i.getNode().is(this)&&i.set(s,i.offset,"element")}else r.insertBefore(n),this.remove();return!0}getValue(){return this.getLatest().__value}setValue(e){const t=this.getWritable();return t.__value=e,t}getChecked(){const e=this.getLatest();let t;const n=this.getParent();return M(n)&&(t=n.getListType()),"check"===t?Boolean(e.__checked):void 0}setChecked(e){const t=this.getWritable();return t.__checked=e,t}toggleChecked(){const e=this.getWritable();return e.setChecked(!e.__checked)}getIndent(){const e=this.getParent();if(null===e||!this.isAttached())return this.getLatest().__indent;let t=e.getParentOrThrow(),n=0;for(;O(t);)t=t.getParentOrThrow().getParentOrThrow(),n++;return n}setIndent(e){"number"!=typeof e&&i(117),(e=Math.floor(e))>=0||i(199);let t=this.getIndent();for(;t!==e;)t<e?(m(this),t++):(_(this),t--);return this}canInsertAfter(e){return O(e)}canReplaceWith(e){return O(e)}canMergeWith(e){return O(e)||t.$isParagraphNode(e)}extractWithChild(e,n){if(!t.$isRangeSelection(n))return!1;const r=n.anchor.getNode(),i=n.focus.getNode();return this.isParentOf(r)&&this.isParentOf(i)&&this.getTextContent().length===n.getTextContent().length}isParentRequired(){return!0}createParentElementNode(){return k("bullet")}canMergeWhenEmpty(){return!0}}function y(e){if(e.classList.contains("task-list-item"))for(const t of e.children)if("INPUT"===t.tagName)return T(t);if(e.classList.contains("joplin-checkbox"))for(const t of e.children)if(t.classList.contains("checkbox-wrapper")&&t.children.length>0&&"INPUT"===t.children[0].tagName)return T(t.children[0]);const n=e.getAttribute("aria-checked"),r=x("true"===n||"false"!==n&&void 0);return t.$setFormatFromDOM(r,e),{after:S.bind(null,r),node:t.$setDirectionFromDOM(r,e)}}function T(e){if(!("checkbox"===e.getAttribute("type")))return{node:null};const t=x(e.hasAttribute("checked"));return{after:S.bind(null,t),node:t}}function S(e,n){const r=n[0];return 1===n.length&&t.$isParagraphNode(r)&&!e.getFormatType()&&r.getFormatType()?(e.setFormat(r.getFormatType()),r.getChildren()):n}function x(e){return t.$applyNodeReplacement(new N(void 0,e))}function O(e){return e instanceof N}class L extends t.ElementNode{__tag;__start;__listType;$config(){return this.config("list",{$transform:e=>{!function(e){const t=e.getNextSibling();M(t)&&e.getListType()===t.getListType()&&h(e,t)}(e),f(e)},extends:t.ElementNode,importDOM:t.buildImportMap({ol:()=>({conversion:E,priority:0}),ul:()=>({conversion:E,priority:0})})})}constructor(e="number",t=1,n){super(n);const r=$[e]||e;this.__listType=r,this.__tag="number"===r?"ol":"ul",this.__start=t}afterCloneFrom(e){super.afterCloneFrom(e),this.__listType=e.__listType,this.__tag=e.__tag,this.__start=e.__start}getTag(){return this.getLatest().__tag}setListType(e){const t=this.getWritable();return t.__listType=e,t.__tag="number"===e?"ol":"ul",t}getListType(){return this.getLatest().__listType}getStart(){return this.getLatest().__start}setStart(e){const t=this.getWritable();return t.__start=e,t}createDOM(e,t){const n=this.__tag,r=document.createElement(n);return 1!==this.__start&&r.setAttribute("start",String(this.__start)),r.__lexicalListType=this.__listType,v(r,e.theme,this),r}updateDOM(e,t,n){return e.__tag!==this.__tag||e.__listType!==this.__listType||(v(t,n.theme,this),e.__start!==this.__start&&t.setAttribute("start",String(this.__start)),!1)}updateFromJSON(e){return super.updateFromJSON(e).setListType(e.listType).setStart(e.start)}exportDOM(t){const n=this.createDOM(t._config,t);return e.isHTMLElement(n)&&(1!==this.__start&&n.setAttribute("start",String(this.__start)),"check"===this.__listType&&n.setAttribute("__lexicalListType","check")),{element:n}}exportJSON(){return{...super.exportJSON(),listType:this.getListType(),start:this.getStart(),tag:this.getTag()}}canBeEmpty(){return!1}canIndent(){return!1}splice(e,n,r){let i=r;for(let e=0;e<r.length;e++){const n=r[e];O(n)||(i===r&&(i=[...r]),i[e]=this.createListItemNode().append(!t.$isElementNode(n)||M(n)||n.isInline()?n:t.$createTextNode(n.getTextContent())))}return super.splice(e,n,i)}extractWithChild(e){return O(e)}createListItemNode(){return x()}}function v(n,r,i){const o=[],l=[],c=r.list;if(void 0!==c){const e=c[`${i.__tag}Depth`]||[],n=s(i)-1,r=n%e.length,a=e[r],d=c[i.__tag];let g;const u=c.nested,h=c.checklist;if(void 0!==u&&u.list&&(g=u.list),void 0!==d&&o.push(d),void 0!==h&&"check"===i.__listType&&o.push(h),void 0!==a){o.push(...t.normalizeClassNames(a));for(let t=0;t<e.length;t++)t!==r&&l.push(i.__tag+t)}if(void 0!==g){const e=t.normalizeClassNames(g);n>1?o.push(...e):l.push(...e)}}l.length>0&&e.removeClassNamesFromElement(n,...l),o.length>0&&e.addClassNamesToElement(n,...o)}function E(n){let r;if(function(t){return e.isHTMLElement(t)&&"ol"===t.nodeName.toLowerCase()}(n)){const e=n.start;r=k("number",e)}else r=function(t){if("check"===t.getAttribute("__lexicallisttype")||t.classList.contains("contains-task-list")||"1"===t.getAttribute("data-is-checklist"))return!0;for(const n of t.childNodes)if(e.isHTMLElement(n)&&n.hasAttribute("aria-checked"))return!0;return!1}(n)?k("check"):k("bullet");return t.$setDirectionFromDOM(r,n),{after:e=>function(e,t){const n=t.createListItemNode.bind(t),r=[];for(let t=0;t<e.length;t++){const i=e[t];if(O(i)){r.push(i);const e=i.getChildren();e.length>1&&e.forEach(e=>{M(e)&&r.push(n().append(e))})}else r.push(n().append(i))}return r}(e,r),node:r}}const $={ol:"number",ul:"bullet"};function k(e="number",n=1){return t.$applyNodeReplacement(new L(e,n))}function M(e){return e instanceof L}const b=t.createCommand("INSERT_CHECK_LIST_COMMAND");function P(n,r){const i=r&&r.disableTakeFocusOnClick||!1,s="boolean"==typeof i?()=>i:i.peek.bind(i),o=t=>{const n=t.target;if(!e.isHTMLElement(n))return!1;const r=n.__lexicalCheckListLastHandled;return void 0!==r&&t.timeStamp-r<500},l=t=>{const n=t.target;e.isHTMLElement(n)&&(n.__lexicalCheckListLastHandled=t.timeStamp)},c=e=>{o(e)||(l(e),F(e,s()))},a=e=>{"touch"===e.pointerType&&(o(e)||(l(e),F(e,s())))},g=e=>{!function(e,t){I(e,()=>{e.preventDefault(),t&&e.stopPropagation()})}(e,s())};return e.mergeRegister(n.registerCommand(b,()=>(d("check"),!0),t.COMMAND_PRIORITY_LOW),n.registerCommand(t.KEY_ARROW_DOWN_COMMAND,e=>A(e,n,!1),t.COMMAND_PRIORITY_LOW),n.registerCommand(t.KEY_ARROW_UP_COMMAND,e=>A(e,n,!0),t.COMMAND_PRIORITY_LOW),n.registerCommand(t.KEY_ESCAPE_COMMAND,()=>{if(null!=R()){const e=n.getRootElement();return null!=e&&e.focus(),!0}return!1},t.COMMAND_PRIORITY_LOW),n.registerCommand(t.KEY_SPACE_COMMAND,e=>{const r=R();return!(null==r||!n.isEditable())&&(n.update(()=>{const n=t.$getNearestNodeFromDOMNode(r);O(n)&&(e.preventDefault(),n.toggleChecked())}),!0)},t.COMMAND_PRIORITY_LOW),n.registerCommand(t.KEY_ARROW_LEFT_COMMAND,r=>n.getEditorState().read(()=>{const i=t.$getSelection();if(t.$isRangeSelection(i)&&i.isCollapsed()){const{anchor:s}=i,o="element"===s.type;if(o||0===s.offset){const i=s.getNode(),l=e.$findMatchingParent(i,e=>t.$isElementNode(e)&&!e.isInline());if(O(l)){const e=l.getParent();if(M(e)&&"check"===e.getListType()&&(o||l.getFirstDescendant()===i)){const e=n.getElementByKey(l.__key);if(null!=e&&document.activeElement!==e)return e.focus(),r.preventDefault(),!0}}}}return!1}),t.COMMAND_PRIORITY_LOW),n.registerRootListener(e=>{if(null!==e)return e.addEventListener("click",c),e.addEventListener("pointerup",a),e.addEventListener("pointerdown",g,{capture:!0}),e.addEventListener("mousedown",g,{capture:!0}),e.addEventListener("touchstart",g,{capture:!0,passive:!1}),()=>{e.removeEventListener("click",c),e.removeEventListener("pointerup",a),e.removeEventListener("pointerdown",g,{capture:!0}),e.removeEventListener("mousedown",g,{capture:!0}),e.removeEventListener("touchstart",g,{capture:!0})}}))}function I(t,n){const r=t.target;if(!e.isHTMLElement(r))return;const i=r.firstChild;if(e.isHTMLElement(i)&&("UL"===i.tagName||"OL"===i.tagName))return;const s=r.parentNode;if(!s||"check"!==s.__lexicalListType)return;let o=null,l=null;if("clientX"in t)o=t.clientX;else if("touches"in t){const e=t.touches;e.length>0&&(o=e[0].clientX,l="touch")}if(null==o)return;const c=r.getBoundingClientRect(),a=o/e.calculateZoomLevel(r),d=window.getComputedStyle?window.getComputedStyle(r,"::before"):{width:"0px"},g=parseFloat(d.width),u="touch"===l||"pointerType"in t&&"touch"===t.pointerType?32:0;("rtl"===r.dir?a<c.right+u&&a>c.right-g-u:a>c.left-u&&a<c.left+g+u)&&n()}function F(n,r){I(n,()=>{if(e.isHTMLElement(n.target)){const e=n.target,i=t.getNearestEditorFromDOMNode(e);null!=i&&i.isEditable()&&i.update(()=>{const n=t.$getNearestNodeFromDOMNode(e);O(n)&&(r?(t.$addUpdateTag(t.SKIP_SELECTION_FOCUS_TAG),t.$addUpdateTag(t.SKIP_DOM_SELECTION_TAG)):e.focus(),n.toggleChecked())})}})}function R(){const t=document.activeElement;return e.isHTMLElement(t)&&"LI"===t.tagName&&null!=t.parentNode&&"check"===t.parentNode.__lexicalListType?t:null}function A(e,n,r){const i=R();return null!=i&&n.update(()=>{const s=t.$getNearestNodeFromDOMNode(i);if(!O(s))return;const o=function(e,t){let n=t?e.getPreviousSibling():e.getNextSibling(),r=e;for(;null==n&&O(r);)r=r.getParentOrThrow().getParent(),null!=r&&(n=t?r.getPreviousSibling():r.getNextSibling());for(;O(n);){const e=t?n.getLastChild():n.getFirstChild();if(!M(e))return n;n=t?e.getLastChild():e.getFirstChild()}return null}(s,r);if(null!=o){o.selectStart();const t=n.getElementByKey(o.__key);null!=t&&(e.preventDefault(),setTimeout(()=>{t.focus()},0))}}),!1}const D=t.createCommand("UPDATE_LIST_START_COMMAND"),w=t.createCommand("INSERT_UNORDERED_LIST_COMMAND"),W=t.createCommand("INSERT_ORDERED_LIST_COMMAND"),K=t.createCommand("REMOVE_LIST_COMMAND");function H(n,r){return e.mergeRegister(n.registerCommand(W,()=>(d("number"),!0),t.COMMAND_PRIORITY_LOW),n.registerCommand(D,e=>{const{listNodeKey:n,newStart:r}=e,i=t.$getNodeByKey(n);return!!M(i)&&("number"===i.getListType()&&(i.setStart(r),f(i)),!0)},t.COMMAND_PRIORITY_LOW),n.registerCommand(w,()=>(d("bullet"),!0),t.COMMAND_PRIORITY_LOW),n.registerCommand(K,()=>(p(),!0),t.COMMAND_PRIORITY_LOW),n.registerCommand(t.INSERT_PARAGRAPH_COMMAND,()=>C(!!(r&&r.restoreNumbering)),t.COMMAND_PRIORITY_LOW),n.registerNodeTransform(N,e=>{const n=e.getFirstChild();if(n){if(t.$isTextNode(n)){const t=n.getStyle(),r=n.getFormat();e.getTextStyle()!==t&&e.setTextStyle(t),e.getTextFormat()!==r&&e.setTextFormat(r)}}else{const n=t.$getSelection();t.$isRangeSelection(n)&&(n.style!==e.getTextStyle()||n.format!==e.getTextFormat())&&n.isCollapsed()&&e.is(n.anchor.getNode())&&e.setTextStyle(n.style).setTextFormat(n.format)}}),n.registerNodeTransform(t.TextNode,e=>{const t=e.getParent();if(O(t)&&e.is(t.getFirstChild())){const n=e.getStyle(),r=e.getFormat();n===t.getTextStyle()&&r===t.getTextFormat()||t.setTextStyle(n).setTextFormat(r)}}))}function U(t){const n=t=>{const n=t.getParent();if(M(t.getFirstChild())||!M(n))return;const r=e.$findMatchingParent(t,e=>O(e)&&M(e.getParent())&&O(e.getPreviousSibling()));if(null===r&&t.getIndent()>0)t.setIndent(0);else if(O(r)){const e=r.getPreviousSibling();if(O(e)){const r=function(e){let t=e,n=t.getFirstChild();for(;M(n);){const e=n.getLastChild();if(!O(e))break;t=e,n=t.getFirstChild()}return t}(e),i=r.getParent();if(M(i)){const e=s(i);e+1<s(n)&&t.setIndent(e)}}}};return t.registerNodeTransform(L,e=>{const t=[e];for(;t.length>0;){const e=t.shift();if(M(e))for(const r of e.getChildren())if(O(r)){n(r);const e=r.getFirstChild();M(e)&&t.push(e)}}})}const Y=t.defineExtension({build:(e,t,r)=>n.namedSignals(t),config:t.safeCast({hasStrictIndent:!1,shouldPreserveNumbering:!1}),name:"@lexical/list/List",nodes:()=>[L,N],register(t,r,i){const s=i.getOutput();return e.mergeRegister(n.effect(()=>H(t,{restoreNumbering:s.shouldPreserveNumbering.value})),n.effect(()=>s.hasStrictIndent.value?U(t):void 0))}}),B=t.defineExtension({build:(e,t)=>n.namedSignals(t),config:t.safeCast({disableTakeFocusOnClick:!1}),dependencies:[Y],name:"@lexical/list/CheckList",register:(e,t,n)=>P(e,n.getOutput())});function z(e){const t=[];for(const n of e)if(O(n)){t.push(n);const e=n.getChildren();if(e.length>1)for(const n of e)M(n)&&t.push(x().append(n))}else t.push(x().append(n));return t}const q=r.defineImportRule({$import:(e,n)=>{let i;var s;return r.isElementOfTag(n,"ol")?i=k("number",n.start):i=(s=n).matches('[__lexicallisttype="check"], .contains-task-list, [data-is-checklist="1"]')||null!==s.querySelector(":scope > [aria-checked]")?k("check"):k("bullet"),t.$setDirectionFromDOM(i,n),[i.splice(0,0,z(e.$importChildren(n)))]},match:r.sel.tag("ol","ul"),name:"@lexical/list/list"});function J(e,n){if(1!==n.length)return n;const r=n[0];return t.$isParagraphNode(r)&&!e.getFormatType()&&r.getFormatType()?(e.setFormat(r.getFormatType()),r.getChildren()):n}const V=r.defineImportRule({$import:(e,n)=>{const r=n.getAttribute("aria-checked"),i=x("true"===r||"false"!==r&&void 0);return t.$setFormatFromDOM(i,n),t.$setDirectionFromDOM(i,n),[i.splice(0,0,J(i,e.$importChildren(n)))]},match:r.sel.tag("li"),name:"@lexical/list/li"});function j(e,n,i){const s=r.isElementOfTag(i,"input")?i:i.querySelector('input[type="checkbox"]');if(!s||"checkbox"!==s.getAttribute("type"))return[];const o=x(s.hasAttribute("checked"));return t.$setFormatFromDOM(o,n),t.$setDirectionFromDOM(o,n),[o.splice(0,0,J(o,e.$importChildren(n)))]}const G={$accepts:e=>O(e)||M(e),$packageRun:e=>[x().splice(0,0,e)],name:"ListSchema"},X=[r.defineImportRule({$import:(e,t,n)=>{const r=t.querySelector(':scope > input[type="checkbox"]');return r?j(e,t,r):n()},match:r.sel.tag("li").classAll("task-list-item"),name:"@lexical/list/li-task-list-item"}),r.defineImportRule({$import:(e,t,n)=>{const r=t.querySelector(":scope > .checkbox-wrapper");if(!r)return n();const i=r.querySelector(':scope > input[type="checkbox"]');return i?j(e,t,i):n()},match:r.sel.tag("li").classAll("joplin-checkbox"),name:"@lexical/list/li-joplin-checkbox"}),q,V],Z=t.defineExtension({dependencies:[r.CoreImportExtension,Y,t.configExtension(r.DOMImportExtension,{rules:X})],name:"@lexical/list/Import"});exports.$createListItemNode=x,exports.$createListNode=k,exports.$getListDepth=s,exports.$handleListInsertParagraph=C,exports.$insertList=d,exports.$isListItemNode=O,exports.$isListNode=M,exports.$removeList=p,exports.CheckListExtension=B,exports.INSERT_CHECK_LIST_COMMAND=b,exports.INSERT_ORDERED_LIST_COMMAND=W,exports.INSERT_UNORDERED_LIST_COMMAND=w,exports.ListExtension=Y,exports.ListImportExtension=Z,exports.ListImportRules=X,exports.ListItemNode=N,exports.ListNode=L,exports.ListSchema=G,exports.REMOVE_LIST_COMMAND=K,exports.UPDATE_LIST_START_COMMAND=D,exports.insertList=function(e,t){e.update(()=>d(t))},exports.registerCheckList=P,exports.registerList=H,exports.registerListStrictIndentTransform=U,exports.removeList=function(e){e.update(()=>p())}; | ||
| "use strict";var e=require("@lexical/utils"),t=require("lexical"),n=require("@lexical/extension"),r=require("@lexical/html");function i(e,...t){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",e);for(const e of t)r.append("v",e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function s(e){let t=1,n=e.getParent();for(;null!=n;){if(x(n)){const e=n.getParent();if(M(e)){t++,n=e.getParent();continue}i(40)}return t}return t}function o(e){let t=e.getParent();M(t)||i(40);let n=t;for(;null!==n;)n=n.getParent(),M(n)&&(t=n);return t}function l(e){let t=[];const n=e.getChildren().filter(x);for(let e=0;e<n.length;e++){const r=n[e],i=r.getFirstChild();M(i)?t=t.concat(l(i)):t.push(r)}return t}function c(e){return x(e)&&M(e.getFirstChild())}function a(e,t){return x(e)&&(0===t.length||1===t.length&&e.is(t[0])&&0===e.getChildrenSize())}function d(e){const n=t.$getSelection();if(null!==n){let r=n.getNodes();if(t.$isRangeSelection(n)){const[i]=n.getStartEndPoints(),s=i.getNode(),o=s.getParent();if(t.$isRootOrShadowRoot(s)){const e=s.getFirstChild();if(e)r=e.selectStart().getNodes();else{const e=t.$createParagraphNode();s.append(e),r=e.select().getNodes()}}else if(a(s,r)){const n=k(e);if(t.$isRootOrShadowRoot(o)){s.replace(n);const e=L();t.$isElementNode(s)&&(e.setFormat(s.getFormatType()),e.setIndent(s.getIndent())),n.append(e)}else if(x(s)){const e=s.getParentOrThrow();u(n,e.getChildren()),e.replace(n)}return}}const i=new Set;for(let n=0;n<r.length;n++){const s=r[n];if(t.$isElementNode(s)&&s.isEmpty()&&!x(s)&&!i.has(s.getKey())){g(s,e);continue}let o=t.$isLeafNode(s)?s.getParent():x(s)&&s.isEmpty()?s:null;for(;null!=o;){const n=o.getKey();if(M(o)){if(!i.has(n)){const t=k(e);u(t,o.getChildren()),o.replace(t),i.add(n)}break}{const r=o.getParent();if(t.$isRootOrShadowRoot(r)&&!i.has(n)){i.add(n),g(o,e);break}o=r}}}}}function u(e,t){e.splice(e.getChildrenSize(),0,t)}function g(e,n){if(M(e))return e;const r=e.getPreviousSibling(),i=e.getNextSibling(),s=L();let o;if(u(s,e.getChildren()),M(r)&&n===r.getListType())r.append(s),M(i)&&n===i.getListType()&&(u(r,i.getChildren()),i.remove()),o=r;else if(M(i)&&n===i.getListType())i.getFirstChildOrThrow().insertBefore(s),o=i;else{const t=k(n);t.append(s),e.replace(t),o=t}s.setFormat(e.getFormatType()),s.setIndent(e.getIndent());const l=t.$getSelection();return t.$isRangeSelection(l)&&(o.getKey()===l.anchor.key&&l.anchor.set(s.getKey(),l.anchor.offset,"element"),o.getKey()===l.focus.key&&l.focus.set(s.getKey(),l.focus.offset,"element")),e.remove(),o}function h(e,t){const n=e.getLastChild(),r=t.getFirstChild();n&&r&&c(n)&&c(r)&&(h(n.getFirstChild(),r.getFirstChild()),r.remove());const i=t.getChildren();i.length>0&&e.append(...i),t.remove()}function p(){const n=t.$getSelection();if(t.$isRangeSelection(n)){const r=new Set,i=n.getNodes(),s=n.anchor.getNode();if(a(s,i))r.add(o(s));else for(let n=0;n<i.length;n++){const s=i[n];if(t.$isLeafNode(s)){const t=e.$getNearestNodeOfType(s,N);null!=t&&r.add(o(t))}}for(const e of r){let r=e;const i=l(e);for(const e of i){const i=t.$createParagraphNode().setTextStyle(n.style).setTextFormat(n.format);u(i,e.getChildren()),r.insertAfter(i),r=i,e.__key===n.anchor.key&&t.$setPointFromCaret(n.anchor,t.$normalizeCaret(t.$getChildCaret(i,"next"))),e.__key===n.focus.key&&t.$setPointFromCaret(n.focus,t.$normalizeCaret(t.$getChildCaret(i,"next"))),e.remove()}e.remove()}}}function f(e){const t="check"!==e.getListType();let n=e.getStart();for(const r of e.getChildren())x(r)&&(r.getValue()!==n&&r.setValue(n),t&&null!=r.getLatest().__checked&&r.setChecked(void 0),M(r.getFirstChild())||n++)}function m(e){const n=new Set;if(c(e)||n.has(e.getKey()))return;const r=e.getParent(),i=e.getNextSibling(),s=e.getPreviousSibling();if(c(i)&&c(s)){const t=s.getFirstChild();if(M(t)){t.append(e);const r=i.getFirstChild();if(M(r)){u(t,r.getChildren()),i.remove(),n.add(i.getKey())}}}else if(c(i)){const t=i.getFirstChild();if(M(t)){const n=t.getFirstChild();null!==n&&n.insertBefore(e)}}else if(c(s)){const t=s.getFirstChild();M(t)&&t.append(e)}else if(M(r)){const n=t.$copyNode(e),o=t.$copyNode(r);n.append(o),o.append(e),s?s.insertAfter(n):i?i.insertBefore(n):r.append(n)}}function _(e){if(c(e))return;const n=e.getParent(),r=n?n.getParent():void 0;if(M(r?r.getParent():void 0)&&x(r)&&M(n)){const i=n?n.getFirstChild():void 0,s=n?n.getLastChild():void 0;if(e.is(i))r.insertBefore(e),n.isEmpty()&&r.remove();else if(e.is(s))r.insertAfter(e),n.isEmpty()&&r.remove();else{const i=t.$copyNode(e),s=t.$copyNode(n);i.append(s),e.getPreviousSiblings().forEach(e=>s.append(e));const o=t.$copyNode(e),l=t.$copyNode(n);o.append(l),u(l,e.getNextSiblings()),r.insertBefore(i),r.insertAfter(o),r.replace(e)}}}function C(e=!1){const n=t.$getSelection();if(!t.$isRangeSelection(n)||!n.isCollapsed())return!1;const r=n.anchor.getNode();let s=null;if(x(r)&&0===r.getChildrenSize())s=r;else if(t.$isTextNode(r)){const e=r.getParent();x(e)&&e.getChildren().every(e=>t.$isTextNode(e)&&""===e.getTextContent().trim())&&(s=e)}if(null===s)return!1;const l=o(s),c=s.getParent();M(c)||i(40);const a=c.getParent();let d;if(t.$isRootOrShadowRoot(a))d=t.$createParagraphNode(),l.insertAfter(d);else{if(!x(a))return!1;d=t.$copyNode(a),a.insertAfter(d)}d.setTextStyle(n.style).setTextFormat(n.format).select();const u=s.getNextSiblings();if(u.length>0){const n=e?function(e,t){return e.getStart()+t.getIndexWithinParent()}(c,s):1,r=t.$copyNode(c).setStart(n);if(x(d)){const e=t.$copyNode(d);e.append(r),d.insertAfter(e)}else d.insertAfter(r);r.append(...u)}return function(e){let t=e;for(;null==t.getNextSibling()&&null==t.getPreviousSibling();){const e=t.getParent();if(null==e||!x(e)&&!M(e))break;t=e}t.remove()}(s),!0}class N extends t.ElementNode{__value;__checked;$config(){return this.config("listitem",{$transform:n=>{const r=n.getParent();if(M(r))"check"!==r.getListType()&&null!=n.getChecked()&&n.setChecked(void 0);else if(r){const s=n.createParentElementNode();M(s)||i(340);const o=[n];for(const e of["previous","next"]){o.reverse();for(const{origin:r}of t.$getSiblingCaret(n,e)){if(!x(r))break;o.push(r)}}n.insertBefore(s),s.splice(0,0,o),t.$isRootOrShadowRoot(r)||(e.$insertNodeToNearestRootAtCaret(s,t.$rewindSiblingCaret(t.$getSiblingCaret(s,"next")),{$shouldSplit:()=>!1,removeEmptyDestination:!0}),r.isEmpty()&&r.isAttached()&&r.remove())}},extends:t.ElementNode,importDOM:t.buildImportMap({li:()=>({conversion:T,priority:0})})})}constructor(e=1,t=void 0,n){super(n),this.__value=void 0===e?1:e,this.__checked=t}afterCloneFrom(e){super.afterCloneFrom(e),this.__value=e.__value,this.__checked=e.__checked}createDOM(e){const t=document.createElement("li");return this.updateListItemDOM(null,t,e),t}updateListItemDOM(n,r,i){!function(e,t){const n=t.getParent();!M(n)||"check"!==n.getListType()||M(t.getFirstChild())?(e.removeAttribute("role"),e.removeAttribute("tabIndex"),e.removeAttribute("aria-checked")):(e.setAttribute("role","checkbox"),e.setAttribute("tabIndex","-1"),e.setAttribute("aria-checked",t.getChecked()?"true":"false"))}(r,this),r.value=this.__value,function(n,r,i){const s=r.list;if(!s)return;const o=s.listitem,l=s.nested&&s.nested.listitem,c=i.getParent(),a=M(c)&&"check"===c.getListType(),d=i.getChecked(),u=i.getChildren().some(e=>M(e)),g=[];void 0!==s.listitemChecked&&g.push(s.listitemChecked);void 0!==s.listitemUnchecked&&g.push(s.listitemUnchecked);void 0!==l&&g.push(...t.normalizeClassNames(l));g.length>0&&e.removeClassNamesFromElement(n,...g);const h=[];void 0!==o&&h.push(...t.normalizeClassNames(o));if(a){const e=d?s.listitemChecked:s.listitemUnchecked;void 0!==e&&h.push(e)}void 0!==l&&u&&h.push(...t.normalizeClassNames(l));h.length>0&&e.addClassNamesToElement(n,...h)}(r,i.theme,this);const s=n?n.__style:"",o=this.__style;s!==o&&t.setDOMStyleFromCSS(r.style,o,s),function(e,n,r){const i=n.__textStyle,s=r?r.__textStyle:"";if(null!==r&&s===i)return;const o=t.getStyleObjectFromCSS(i);for(const t in o)e.style.setProperty(`--listitem-marker-${t}`,o[t]);if(""!==s)for(const n in t.getStyleObjectFromCSS(s))n in o||e.style.removeProperty(`--listitem-marker-${n}`)}(r,this,n)}updateDOM(e,t,n){const r=t;return this.updateListItemDOM(e,r,n),!1}updateFromJSON(e){return super.updateFromJSON(e).setValue(e.value).setChecked(e.checked)}exportDOM(e){const n=this.createDOM(e._config),r=this.getFormatType();r&&(n.style.textAlign=r);const i=this.getDirection();return i&&(n.dir=i),c(this)?{after(e){if(t.isHTMLElement(e)){const n=e.previousElementSibling;if(t.isHTMLElement(n)&&"LI"===n.nodeName){for(;e.firstChild;)n.append(e.firstChild);e.remove()}}return e},element:n}:{element:n}}exportJSON(){return{...super.exportJSON(),checked:this.getChecked(),value:this.getValue()}}append(...e){for(let n=0;n<e.length;n++){const r=e[n];if(t.$isElementNode(r)&&this.canMergeWith(r)){const e=r.getChildren();this.append(...e),r.remove()}else super.append(r)}return this}replace(e,n){if(x(e))return super.replace(e);this.setIndent(0);const r=this.getParentOrThrow();if(!M(r))return e;if(r.__first===this.getKey())r.insertBefore(e);else if(r.__last===this.getKey())r.insertAfter(e);else{const n=t.$copyNode(r);let i=this.getNextSibling();for(;i;){const e=i;i=i.getNextSibling(),n.append(e)}r.insertAfter(e),e.insertAfter(n)}const s=this.__key;let o=0;if(n&&(t.$isElementNode(e)||i(139),o=e.getChildrenSize(),e.splice(o,0,this.getChildren())),n&&t.$isElementNode(e)){const n=t.$getSelection();if(t.$isRangeSelection(n))for(const t of n.getStartEndPoints())t.key===s&&"element"===t.type&&t.set(e.getKey(),o+t.offset,"element")}return this.remove(),0===r.getChildrenSize()&&r.remove(),e}insertAfter(e,n=!0){const r=this.getParentOrThrow();if(M(r)||i(39),x(e))return super.insertAfter(e,n);const s=this.getNextSiblings();if(r.insertAfter(e,n),0!==s.length){const i=t.$copyNode(r);s.forEach(e=>i.append(e)),e.insertAfter(i,n)}return e}remove(e){const t=this.getPreviousSibling(),n=this.getNextSibling();super.remove(e),t&&n&&c(t)&&c(n)&&(h(t.getFirstChild(),n.getFirstChild()),n.remove())}resetOnCopyNodeFrom(e){super.resetOnCopyNodeFrom(e),e.getChecked()&&this.setChecked(!1)}insertNewAfter(e,n=!0){const r=t.$copyNode(this);return this.insertAfter(r,n),r}collapseAtStart(e){const n=t.$createParagraphNode();this.getChildren().forEach(e=>n.append(e));const r=this.getParentOrThrow(),i=r.getParentOrThrow(),s=x(i);if(1===r.getChildrenSize())if(s)r.remove(),i.select();else{r.insertBefore(n),r.remove();const t=e.anchor,i=e.focus,s=n.getKey();"element"===t.type&&t.getNode().is(this)&&t.set(s,t.offset,"element"),"element"===i.type&&i.getNode().is(this)&&i.set(s,i.offset,"element")}else r.insertBefore(n),this.remove();return!0}getValue(){return this.getLatest().__value}setValue(e){const t=this.getWritable();return t.__value=e,t}getChecked(){const e=this.getLatest();let t;const n=this.getParent();return M(n)&&(t=n.getListType()),"check"===t?Boolean(e.__checked):void 0}setChecked(e){const t=this.getWritable();return t.__checked=e,t}toggleChecked(){const e=this.getWritable();return e.setChecked(!e.__checked)}getIndent(){const e=this.getParent();if(null===e||!this.isAttached())return this.getLatest().__indent;let t=e.getParentOrThrow(),n=0;for(;x(t);)t=t.getParentOrThrow().getParentOrThrow(),n++;return n}setIndent(e){"number"!=typeof e&&i(117),(e=Math.floor(e))>=0||i(199);let t=this.getIndent();for(;t!==e;)t<e?(m(this),t++):(_(this),t--);return this}canInsertAfter(e){return x(e)}canReplaceWith(e){return x(e)}canMergeWith(e){return x(e)||t.$isParagraphNode(e)}extractWithChild(e,n){if(!t.$isRangeSelection(n))return!1;const r=n.anchor.getNode(),i=n.focus.getNode();return this.isParentOf(r)&&this.isParentOf(i)&&this.getTextContent().length===n.getTextContent().length}isParentRequired(){return!0}createParentElementNode(){return k("bullet")}canMergeWhenEmpty(){return!0}}function T(e){if(e.classList.contains("task-list-item"))for(const t of e.children)if("INPUT"===t.tagName)return y(t);if(e.classList.contains("joplin-checkbox"))for(const t of e.children)if(t.classList.contains("checkbox-wrapper")&&t.children.length>0&&"INPUT"===t.children[0].tagName)return y(t.children[0]);const n=e.getAttribute("aria-checked"),r=L("true"===n||"false"!==n&&void 0);return t.$setFormatFromDOM(r,e),{after:S.bind(null,r),node:t.$setDirectionFromDOM(r,e)}}function y(e){if(!("checkbox"===e.getAttribute("type")))return{node:null};const t=L(e.hasAttribute("checked"));return{after:S.bind(null,t),node:t}}function S(e,n){const r=n[0];return 1===n.length&&t.$isParagraphNode(r)&&!e.getFormatType()&&r.getFormatType()?(e.setFormat(r.getFormatType()),r.getChildren()):n}function L(e){return t.$applyNodeReplacement(new N(void 0,e))}function x(e){return e instanceof N}class O extends t.ElementNode{__tag;__start;__listType;$config(){return this.config("list",{$transform:e=>{!function(e){const t=e.getNextSibling();M(t)&&e.getListType()===t.getListType()&&h(e,t)}(e),f(e)},extends:t.ElementNode,importDOM:t.buildImportMap({ol:()=>({conversion:E,priority:0}),ul:()=>({conversion:E,priority:0})})})}constructor(e="number",t=1,n){super(n);const r=$[e]||e;this.__listType=r,this.__tag="number"===r?"ol":"ul",this.__start=t}afterCloneFrom(e){super.afterCloneFrom(e),this.__listType=e.__listType,this.__tag=e.__tag,this.__start=e.__start}getTag(){return this.getLatest().__tag}setListType(e){const t=this.getWritable();return t.__listType=e,t.__tag="number"===e?"ol":"ul",t}getListType(){return this.getLatest().__listType}getStart(){return this.getLatest().__start}setStart(e){const t=this.getWritable();return t.__start=e,t}createDOM(e,t){const n=this.__tag,r=document.createElement(n);return 1!==this.__start&&r.setAttribute("start",String(this.__start)),r.__lexicalListType=this.__listType,v(r,e.theme,this),r}updateDOM(e,t,n){return e.__tag!==this.__tag||e.__listType!==this.__listType||(v(t,n.theme,this),e.__start!==this.__start&&t.setAttribute("start",String(this.__start)),!1)}updateFromJSON(e){return super.updateFromJSON(e).setListType(e.listType).setStart(e.start)}exportDOM(t){const n=this.createDOM(t._config,t);return e.isHTMLElement(n)&&(1!==this.__start&&n.setAttribute("start",String(this.__start)),"check"===this.__listType&&n.setAttribute("__lexicalListType","check")),{element:n}}exportJSON(){return{...super.exportJSON(),listType:this.getListType(),start:this.getStart(),tag:this.getTag()}}canBeEmpty(){return!1}canIndent(){return!1}splice(e,n,r){let i=r;for(let e=0;e<r.length;e++){const n=r[e];x(n)||(i===r&&(i=[...r]),i[e]=this.createListItemNode().append(!t.$isElementNode(n)||M(n)||n.isInline()?n:t.$createTextNode(n.getTextContent())))}return super.splice(e,n,i)}extractWithChild(e){return x(e)}createListItemNode(){return L()}}function v(n,r,i){const o=[],l=[],c=r.list;if(void 0!==c){const e=c[`${i.__tag}Depth`]||[],n=s(i)-1,r=n%e.length,a=e[r],d=c[i.__tag];let u;const g=c.nested,h=c.checklist;if(void 0!==g&&g.list&&(u=g.list),void 0!==d&&o.push(d),void 0!==h&&"check"===i.__listType&&o.push(h),void 0!==a){o.push(...t.normalizeClassNames(a));for(let t=0;t<e.length;t++)t!==r&&l.push(i.__tag+t)}if(void 0!==u){const e=t.normalizeClassNames(u);n>1?o.push(...e):l.push(...e)}}l.length>0&&e.removeClassNamesFromElement(n,...l),o.length>0&&e.addClassNamesToElement(n,...o)}function E(n){let r;if(function(t){return e.isHTMLElement(t)&&"ol"===t.nodeName.toLowerCase()}(n)){const e=n.start;r=k("number",e)}else r=function(t){if("check"===t.getAttribute("__lexicallisttype")||t.classList.contains("contains-task-list")||"1"===t.getAttribute("data-is-checklist"))return!0;for(const n of t.childNodes)if(e.isHTMLElement(n)&&n.hasAttribute("aria-checked"))return!0;return!1}(n)?k("check"):k("bullet");return t.$setDirectionFromDOM(r,n),{after:e=>function(e,t){const n=t.createListItemNode.bind(t),r=[];for(let t=0;t<e.length;t++){const i=e[t];if(x(i)){r.push(i);const e=i.getChildren();e.length>1&&e.forEach(e=>{M(e)&&r.push(n().append(e))})}else r.push(n().append(i))}return r}(e,r),node:r}}const $={ol:"number",ul:"bullet"};function k(e="number",n=1){return t.$applyNodeReplacement(new O(e,n))}function M(e){return e instanceof O}const b=t.createCommand("INSERT_CHECK_LIST_COMMAND");function P(n,r){const i=r&&r.disableTakeFocusOnClick||!1,s="boolean"==typeof i?()=>i:i.peek.bind(i),o=t=>{const n=t.target;if(!e.isHTMLElement(n))return!1;const r=n.__lexicalCheckListLastHandled;return void 0!==r&&t.timeStamp-r<500},l=t=>{const n=t.target;e.isHTMLElement(n)&&(n.__lexicalCheckListLastHandled=t.timeStamp)},c=e=>{o(e)||(l(e),A(e,s()))},a=e=>{"touch"===e.pointerType&&(o(e)||(l(e),A(e,s())))},u=e=>{!function(e,t){I(e,()=>{e.preventDefault(),t&&e.stopPropagation()})}(e,s())};return e.mergeRegister(n.registerCommand(b,()=>(d("check"),!0),t.COMMAND_PRIORITY_LOW),n.registerCommand(t.KEY_ARROW_DOWN_COMMAND,e=>R(e,n,!1),t.COMMAND_PRIORITY_LOW),n.registerCommand(t.KEY_ARROW_UP_COMMAND,e=>R(e,n,!0),t.COMMAND_PRIORITY_LOW),n.registerCommand(t.KEY_ESCAPE_COMMAND,()=>{if(null!=F()){const e=n.getRootElement();return null!=e&&e.focus(),!0}return!1},t.COMMAND_PRIORITY_LOW),n.registerCommand(t.KEY_SPACE_COMMAND,e=>{const r=F();return!(null==r||!n.isEditable())&&(n.update(()=>{const n=t.$getNearestNodeFromDOMNode(r);x(n)&&(e.preventDefault(),n.toggleChecked())}),!0)},t.COMMAND_PRIORITY_LOW),n.registerCommand(t.KEY_ARROW_LEFT_COMMAND,r=>n.getEditorState().read(()=>{const i=t.$getSelection();if(t.$isRangeSelection(i)&&i.isCollapsed()){const{anchor:s}=i,o="element"===s.type;if(o||0===s.offset){const i=s.getNode(),l=e.$findMatchingParent(i,e=>t.$isElementNode(e)&&!e.isInline());if(x(l)){const e=l.getParent();if(M(e)&&"check"===e.getListType()&&(o||l.getFirstDescendant()===i)){const e=n.getElementByKey(l.__key);if(null!=e&&document.activeElement!==e)return e.focus(),r.preventDefault(),!0}}}}return!1}),t.COMMAND_PRIORITY_LOW),n.registerRootListener(e=>{if(null!==e)return e.addEventListener("click",c),e.addEventListener("pointerup",a),e.addEventListener("pointerdown",u,{capture:!0}),e.addEventListener("mousedown",u,{capture:!0}),e.addEventListener("touchstart",u,{capture:!0,passive:!1}),()=>{e.removeEventListener("click",c),e.removeEventListener("pointerup",a),e.removeEventListener("pointerdown",u,{capture:!0}),e.removeEventListener("mousedown",u,{capture:!0}),e.removeEventListener("touchstart",u,{capture:!0})}}))}function I(t,n){const r=t.target;if(!e.isHTMLElement(r))return;const i=r.firstChild;if(e.isHTMLElement(i)&&("UL"===i.tagName||"OL"===i.tagName))return;const s=r.parentNode;if(!s||"check"!==s.__lexicalListType)return;let o=null,l=null;if("clientX"in t)o=t.clientX;else if("touches"in t){const e=t.touches;e.length>0&&(o=e[0].clientX,l="touch")}if(null==o)return;const c=r.getBoundingClientRect(),a=o/e.calculateZoomLevel(r),d=window.getComputedStyle?window.getComputedStyle(r,"::before"):{width:"0px"},u=parseFloat(d.width),g="touch"===l||"pointerType"in t&&"touch"===t.pointerType?32:0;("rtl"===r.dir?a<c.right+g&&a>c.right-u-g:a>c.left-g&&a<c.left+u+g)&&n()}function A(n,r){I(n,()=>{if(e.isHTMLElement(n.target)){const e=n.target,i=t.getNearestEditorFromDOMNode(e);null!=i&&i.isEditable()&&i.update(()=>{const n=t.$getNearestNodeFromDOMNode(e);x(n)&&(r?(t.$addUpdateTag(t.SKIP_SELECTION_FOCUS_TAG),t.$addUpdateTag(t.SKIP_DOM_SELECTION_TAG)):e.focus(),n.toggleChecked())})}})}function F(){const t=document.activeElement;return e.isHTMLElement(t)&&"LI"===t.tagName&&null!=t.parentNode&&"check"===t.parentNode.__lexicalListType?t:null}function R(e,n,r){const i=F();return null!=i&&n.update(()=>{const s=t.$getNearestNodeFromDOMNode(i);if(!x(s))return;const o=function(e,t){let n=t?e.getPreviousSibling():e.getNextSibling(),r=e;for(;null==n&&x(r);)r=r.getParentOrThrow().getParent(),null!=r&&(n=t?r.getPreviousSibling():r.getNextSibling());for(;x(n);){const e=t?n.getLastChild():n.getFirstChild();if(!M(e))return n;n=t?e.getLastChild():e.getFirstChild()}return null}(s,r);if(null!=o){o.selectStart();const t=n.getElementByKey(o.__key);null!=t&&(e.preventDefault(),setTimeout(()=>{t.focus()},0))}}),!1}const D=t.createCommand("UPDATE_LIST_START_COMMAND"),w=t.createCommand("INSERT_UNORDERED_LIST_COMMAND"),W=t.createCommand("INSERT_ORDERED_LIST_COMMAND"),K=t.createCommand("REMOVE_LIST_COMMAND");function B(n,r){return e.mergeRegister(n.registerCommand(W,()=>(d("number"),!0),t.COMMAND_PRIORITY_LOW),n.registerCommand(D,e=>{const{listNodeKey:n,newStart:r}=e,i=t.$getNodeByKey(n);return!!M(i)&&("number"===i.getListType()&&(i.setStart(r),f(i)),!0)},t.COMMAND_PRIORITY_LOW),n.registerCommand(w,()=>(d("bullet"),!0),t.COMMAND_PRIORITY_LOW),n.registerCommand(K,()=>(p(),!0),t.COMMAND_PRIORITY_LOW),n.registerCommand(t.INSERT_PARAGRAPH_COMMAND,()=>C(!!(r&&r.restoreNumbering)),t.COMMAND_PRIORITY_LOW),n.registerNodeTransform(N,e=>{const n=e.getFirstChild();if(n){if(t.$isTextNode(n)){const t=n.getStyle(),r=n.getFormat();e.getTextStyle()!==t&&e.setTextStyle(t),e.getTextFormat()!==r&&e.setTextFormat(r)}}else{const n=t.$getSelection();t.$isRangeSelection(n)&&(n.style!==e.getTextStyle()||n.format!==e.getTextFormat())&&n.isCollapsed()&&e.is(n.anchor.getNode())&&e.setTextStyle(n.style).setTextFormat(n.format)}}),n.registerNodeTransform(t.TextNode,e=>{const t=e.getParent();if(x(t)&&e.is(t.getFirstChild())){const n=e.getStyle(),r=e.getFormat();n===t.getTextStyle()&&r===t.getTextFormat()||t.setTextStyle(n).setTextFormat(r)}}))}function H(t){const n=t=>{const n=t.getParent();if(M(t.getFirstChild())||!M(n))return;const r=e.$findMatchingParent(t,e=>x(e)&&M(e.getParent())&&x(e.getPreviousSibling()));if(null===r&&t.getIndent()>0)t.setIndent(0);else if(x(r)){const e=r.getPreviousSibling();if(x(e)){const r=function(e){let t=e,n=t.getFirstChild();for(;M(n);){const e=n.getLastChild();if(!x(e))break;t=e,n=t.getFirstChild()}return t}(e),i=r.getParent();if(M(i)){const e=s(i);e+1<s(n)&&t.setIndent(e)}}}};return t.registerNodeTransform(O,e=>{const t=[e];for(;t.length>0;){const e=t.shift();if(M(e))for(const r of e.getChildren())if(x(r)){n(r);const e=r.getFirstChild();M(e)&&t.push(e)}}})}const U=t.defineExtension({build:(e,t,r)=>n.namedSignals(t),config:t.safeCast({hasStrictIndent:!1,shouldPreserveNumbering:!1}),name:"@lexical/list/List",nodes:()=>[O,N],register(t,r,i){const s=i.getOutput();return e.mergeRegister(n.effect(()=>B(t,{restoreNumbering:s.shouldPreserveNumbering.value})),n.effect(()=>s.hasStrictIndent.value?H(t):void 0))}}),Y=t.defineExtension({build:(e,t)=>n.namedSignals(t),config:t.safeCast({disableTakeFocusOnClick:!1}),dependencies:[U],name:"@lexical/list/CheckList",register:(e,t,n)=>P(e,n.getOutput())});function z(e){const t=[];for(const n of e)if(x(n)){t.push(n);const e=n.getChildren();if(e.length>1)for(const n of e)M(n)&&t.push(L().append(n))}else t.push(L().append(n));return t}const q=r.defineImportRule({$import:(e,n)=>{let i;var s;return r.isElementOfTag(n,"ol")?i=k("number",n.start):i=(s=n).matches('[__lexicallisttype="check"], .contains-task-list, [data-is-checklist="1"]')||null!==s.querySelector(":scope > [aria-checked]")?k("check"):k("bullet"),t.$setDirectionFromDOM(i,n),[i.splice(0,0,r.$propagateTextAlignToBlockChildren(z(e.$importChildren(n)),n))]},match:r.sel.tag("ol","ul"),name:"@lexical/list/list"});function J(e,n){if(1!==n.length)return n;const r=n[0];return t.$isParagraphNode(r)&&!e.getFormatType()&&r.getFormatType()?(e.setFormat(r.getFormatType()),r.getChildren()):n}function V(e){const n=e=>r.$isBlockLevel(e)&&!M(e);if(!e.some(n))return e;const i=[];let s=[];const o=()=>{s.length>0&&(i.push(s),s=[])};for(const r of e)n(r)?(o(),i.push(t.$isElementNode(r)?r.getChildren():[r])):s.push(r);o();const l=[];for(const e of i)l.length>0&&l.push(t.$createLineBreakNode()),l.push(...e);return l}const j=r.defineImportRule({$import:(e,n)=>{const r=n.getAttribute("aria-checked"),i=L("true"===r||"false"!==r&&void 0);return t.$setFormatFromDOM(i,n),t.$setDirectionFromDOM(i,n),[i.splice(0,0,V(J(i,e.$importChildren(n))))]},match:r.sel.tag("li"),name:"@lexical/list/li"});function G(e,n,i){const s=r.isElementOfTag(i,"input")?i:i.querySelector('input[type="checkbox"]');if(!s||"checkbox"!==s.getAttribute("type"))return[];const o=L(s.hasAttribute("checked"));return t.$setFormatFromDOM(o,n),t.$setDirectionFromDOM(o,n),[o.splice(0,0,V(J(o,e.$importChildren(n))))]}const X={$accepts:e=>x(e)||M(e),$packageRun:e=>[L().splice(0,0,e)],name:"ListSchema"},Z=[r.defineImportRule({$import:(e,t,n)=>{const r=t.querySelector(':scope > input[type="checkbox"]');return r?G(e,t,r):n()},match:r.sel.tag("li").classAll("task-list-item"),name:"@lexical/list/li-task-list-item"}),r.defineImportRule({$import:(e,t,n)=>{const r=t.querySelector(":scope > .checkbox-wrapper");if(!r)return n();const i=r.querySelector(':scope > input[type="checkbox"]');return i?G(e,t,i):n()},match:r.sel.tag("li").classAll("joplin-checkbox"),name:"@lexical/list/li-joplin-checkbox"}),q,j],Q=t.defineExtension({dependencies:[U,t.configExtension(r.DOMImportExtension,{rules:Z})],name:"@lexical/list/Import"});exports.$createListItemNode=L,exports.$createListNode=k,exports.$getListDepth=s,exports.$handleListInsertParagraph=C,exports.$insertList=d,exports.$isListItemNode=x,exports.$isListNode=M,exports.$removeList=p,exports.CheckListExtension=Y,exports.INSERT_CHECK_LIST_COMMAND=b,exports.INSERT_ORDERED_LIST_COMMAND=W,exports.INSERT_UNORDERED_LIST_COMMAND=w,exports.ListExtension=U,exports.ListImportExtension=Q,exports.ListImportRules=Z,exports.ListItemNode=N,exports.ListNode=O,exports.ListSchema=X,exports.REMOVE_LIST_COMMAND=K,exports.UPDATE_LIST_START_COMMAND=D,exports.insertList=function(e,t){e.update(()=>d(t))},exports.registerCheckList=P,exports.registerList=B,exports.registerListStrictIndentTransform=H,exports.removeList=function(e){e.update(()=>p())}; |
@@ -9,2 +9,2 @@ /** | ||
| import{$getNearestNodeOfType as e,$insertNodeToNearestRootAtCaret as t,removeClassNamesFromElement as n,addClassNamesToElement as r,isHTMLElement as i,mergeRegister as s,$findMatchingParent as o,calculateZoomLevel as l}from"@lexical/utils";import{$getSelection as c,$isRangeSelection as a,$isTextNode as u,$isRootOrShadowRoot as g,$createParagraphNode as h,$copyNode as d,$isElementNode as f,$isLeafNode as p,$setPointFromCaret as m,$normalizeCaret as _,$getChildCaret as y,$applyNodeReplacement as C,ElementNode as v,buildImportMap as k,$getSiblingCaret as T,$rewindSiblingCaret as b,setDOMStyleFromCSS as S,isHTMLElement as x,$isParagraphNode as L,$setFormatFromDOM as N,$setDirectionFromDOM as F,normalizeClassNames as P,getStyleObjectFromCSS as A,$createTextNode as E,createCommand as O,COMMAND_PRIORITY_LOW as I,KEY_ARROW_DOWN_COMMAND as w,KEY_ARROW_UP_COMMAND as D,KEY_ESCAPE_COMMAND as M,KEY_SPACE_COMMAND as $,$getNearestNodeFromDOMNode as R,KEY_ARROW_LEFT_COMMAND as K,getNearestEditorFromDOMNode as B,$addUpdateTag as W,SKIP_SELECTION_FOCUS_TAG as U,SKIP_DOM_SELECTION_TAG as J,$getNodeByKey as V,INSERT_PARAGRAPH_COMMAND as q,TextNode as z,defineExtension as H,safeCast as j,configExtension as X}from"lexical";import{namedSignals as G,effect as Q}from"@lexical/extension";import{CoreImportExtension as Y,DOMImportExtension as Z,defineImportRule as ee,sel as te,isElementOfTag as ne}from"@lexical/html";function re(e,...t){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",e);for(const e of t)r.append("v",e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function ie(e){let t=1,n=e.getParent();for(;null!=n;){if(be(n)){const e=n.getParent();if(Pe(e)){t++,n=e.getParent();continue}re(40)}return t}return t}function se(e){let t=e.getParent();Pe(t)||re(40);let n=t;for(;null!==n;)n=n.getParent(),Pe(n)&&(t=n);return t}function oe(e){let t=[];const n=e.getChildren().filter(be);for(let e=0;e<n.length;e++){const r=n[e],i=r.getFirstChild();Pe(i)?t=t.concat(oe(i)):t.push(r)}return t}function le(e){return be(e)&&Pe(e.getFirstChild())}function ce(e,t){return be(e)&&(0===t.length||1===t.length&&e.is(t[0])&&0===e.getChildrenSize())}function ae(e){const t=c();if(null!==t){let n=t.getNodes();if(a(t)){const[r]=t.getStartEndPoints(),i=r.getNode(),s=i.getParent();if(g(i)){const e=i.getFirstChild();if(e)n=e.selectStart().getNodes();else{const e=h();i.append(e),n=e.select().getNodes()}}else if(ce(i,n)){const t=Fe(e);if(g(s)){i.replace(t);const e=Te();f(i)&&(e.setFormat(i.getFormatType()),e.setIndent(i.getIndent())),t.append(e)}else if(be(i)){const e=i.getParentOrThrow();ue(t,e.getChildren()),e.replace(t)}return}}const r=new Set;for(let t=0;t<n.length;t++){const i=n[t];if(f(i)&&i.isEmpty()&&!be(i)&&!r.has(i.getKey())){ge(i,e);continue}let s=p(i)?i.getParent():be(i)&&i.isEmpty()?i:null;for(;null!=s;){const t=s.getKey();if(Pe(s)){if(!r.has(t)){const n=Fe(e);ue(n,s.getChildren()),s.replace(n),r.add(t)}break}{const n=s.getParent();if(g(n)&&!r.has(t)){r.add(t),ge(s,e);break}s=n}}}}}function ue(e,t){e.splice(e.getChildrenSize(),0,t)}function ge(e,t){if(Pe(e))return e;const n=e.getPreviousSibling(),r=e.getNextSibling(),i=Te();let s;if(ue(i,e.getChildren()),Pe(n)&&t===n.getListType())n.append(i),Pe(r)&&t===r.getListType()&&(ue(n,r.getChildren()),r.remove()),s=n;else if(Pe(r)&&t===r.getListType())r.getFirstChildOrThrow().insertBefore(i),s=r;else{const n=Fe(t);n.append(i),e.replace(n),s=n}i.setFormat(e.getFormatType()),i.setIndent(e.getIndent());const o=c();return a(o)&&(s.getKey()===o.anchor.key&&o.anchor.set(i.getKey(),o.anchor.offset,"element"),s.getKey()===o.focus.key&&o.focus.set(i.getKey(),o.focus.offset,"element")),e.remove(),s}function he(e,t){const n=e.getLastChild(),r=t.getFirstChild();n&&r&&le(n)&&le(r)&&(he(n.getFirstChild(),r.getFirstChild()),r.remove());const i=t.getChildren();i.length>0&&e.append(...i),t.remove()}function de(){const t=c();if(a(t)){const n=new Set,r=t.getNodes(),i=t.anchor.getNode();if(ce(i,r))n.add(se(i));else for(let t=0;t<r.length;t++){const i=r[t];if(p(i)){const t=e(i,ye);null!=t&&n.add(se(t))}}for(const e of n){let n=e;const r=oe(e);for(const e of r){const r=h().setTextStyle(t.style).setTextFormat(t.format);ue(r,e.getChildren()),n.insertAfter(r),n=r,e.__key===t.anchor.key&&m(t.anchor,_(y(r,"next"))),e.__key===t.focus.key&&m(t.focus,_(y(r,"next"))),e.remove()}e.remove()}}}function fe(e){const t="check"!==e.getListType();let n=e.getStart();for(const r of e.getChildren())be(r)&&(r.getValue()!==n&&r.setValue(n),t&&null!=r.getLatest().__checked&&r.setChecked(void 0),Pe(r.getFirstChild())||n++)}function pe(e){const t=new Set;if(le(e)||t.has(e.getKey()))return;const n=e.getParent(),r=e.getNextSibling(),i=e.getPreviousSibling();if(le(r)&&le(i)){const n=i.getFirstChild();if(Pe(n)){n.append(e);const i=r.getFirstChild();if(Pe(i)){ue(n,i.getChildren()),r.remove(),t.add(r.getKey())}}}else if(le(r)){const t=r.getFirstChild();if(Pe(t)){const n=t.getFirstChild();null!==n&&n.insertBefore(e)}}else if(le(i)){const t=i.getFirstChild();Pe(t)&&t.append(e)}else if(Pe(n)){const t=d(e),s=d(n);t.append(s),s.append(e),i?i.insertAfter(t):r?r.insertBefore(t):n.append(t)}}function me(e){if(le(e))return;const t=e.getParent(),n=t?t.getParent():void 0;if(Pe(n?n.getParent():void 0)&&be(n)&&Pe(t)){const r=t?t.getFirstChild():void 0,i=t?t.getLastChild():void 0;if(e.is(r))n.insertBefore(e),t.isEmpty()&&n.remove();else if(e.is(i))n.insertAfter(e),t.isEmpty()&&n.remove();else{const r=d(e),i=d(t);r.append(i),e.getPreviousSiblings().forEach(e=>i.append(e));const s=d(e),o=d(t);s.append(o),ue(o,e.getNextSiblings()),n.insertBefore(r),n.insertAfter(s),n.replace(e)}}}function _e(e=!1){const t=c();if(!a(t)||!t.isCollapsed())return!1;const n=t.anchor.getNode();let r=null;if(be(n)&&0===n.getChildrenSize())r=n;else if(u(n)){const e=n.getParent();be(e)&&e.getChildren().every(e=>u(e)&&""===e.getTextContent().trim())&&(r=e)}if(null===r)return!1;const i=se(r),s=r.getParent();Pe(s)||re(40);const o=s.getParent();let l;if(g(o))l=h(),i.insertAfter(l);else{if(!be(o))return!1;l=d(o),o.insertAfter(l)}l.setTextStyle(t.style).setTextFormat(t.format).select();const f=r.getNextSiblings();if(f.length>0){const t=e?function(e,t){return e.getStart()+t.getIndexWithinParent()}(s,r):1,n=d(s).setStart(t);if(be(l)){const e=d(l);e.append(n),l.insertAfter(e)}else l.insertAfter(n);n.append(...f)}return function(e){let t=e;for(;null==t.getNextSibling()&&null==t.getPreviousSibling();){const e=t.getParent();if(null==e||!be(e)&&!Pe(e))break;t=e}t.remove()}(r),!0}class ye extends v{__value;__checked;$config(){return this.config("listitem",{$transform:e=>{const n=e.getParent();if(Pe(n))"check"!==n.getListType()&&null!=e.getChecked()&&e.setChecked(void 0);else if(n){const r=e.createParentElementNode();Pe(r)||re(340);const i=[e];for(const t of["previous","next"]){i.reverse();for(const{origin:n}of T(e,t)){if(!be(n))break;i.push(n)}}e.insertBefore(r),r.splice(0,0,i),g(n)||(t(r,b(T(r,"next")),{$shouldSplit:()=>!1,removeEmptyDestination:!0}),n.isEmpty()&&n.isAttached()&&n.remove())}},extends:v,importDOM:k({li:()=>({conversion:Ce,priority:0})})})}constructor(e=1,t=void 0,n){super(n),this.__value=void 0===e?1:e,this.__checked=t}afterCloneFrom(e){super.afterCloneFrom(e),this.__value=e.__value,this.__checked=e.__checked}createDOM(e){const t=document.createElement("li");return this.updateListItemDOM(null,t,e),t}updateListItemDOM(e,t,i){!function(e,t){const n=t.getParent();!Pe(n)||"check"!==n.getListType()||Pe(t.getFirstChild())?(e.removeAttribute("role"),e.removeAttribute("tabIndex"),e.removeAttribute("aria-checked")):(e.setAttribute("role","checkbox"),e.setAttribute("tabIndex","-1"),e.setAttribute("aria-checked",t.getChecked()?"true":"false"))}(t,this),t.value=this.__value,function(e,t,i){const s=t.list;if(!s)return;const o=s.listitem,l=s.nested&&s.nested.listitem,c=i.getParent(),a=Pe(c)&&"check"===c.getListType(),u=i.getChecked(),g=i.getChildren().some(e=>Pe(e)),h=[];void 0!==s.listitemChecked&&h.push(s.listitemChecked);void 0!==s.listitemUnchecked&&h.push(s.listitemUnchecked);void 0!==l&&h.push(...P(l));h.length>0&&n(e,...h);const d=[];void 0!==o&&d.push(...P(o));if(a){const e=u?s.listitemChecked:s.listitemUnchecked;void 0!==e&&d.push(e)}void 0!==l&&g&&d.push(...P(l));d.length>0&&r(e,...d)}(t,i.theme,this);const s=e?e.__style:"",o=this.__style;s!==o&&S(t.style,o,s),function(e,t,n){const r=t.__textStyle,i=n?n.__textStyle:"";if(null!==n&&i===r)return;const s=A(r);for(const t in s)e.style.setProperty(`--listitem-marker-${t}`,s[t]);if(""!==i)for(const t in A(i))t in s||e.style.removeProperty(`--listitem-marker-${t}`)}(t,this,e)}updateDOM(e,t,n){const r=t;return this.updateListItemDOM(e,r,n),!1}updateFromJSON(e){return super.updateFromJSON(e).setValue(e.value).setChecked(e.checked)}exportDOM(e){const t=this.createDOM(e._config),n=this.getFormatType();n&&(t.style.textAlign=n);const r=this.getDirection();return r&&(t.dir=r),le(this)?{after(e){if(x(e)){const t=e.previousElementSibling;if(x(t)&&"LI"===t.nodeName){for(;e.firstChild;)t.append(e.firstChild);e.remove()}}return e},element:t}:{element:t}}exportJSON(){return{...super.exportJSON(),checked:this.getChecked(),value:this.getValue()}}append(...e){for(let t=0;t<e.length;t++){const n=e[t];if(f(n)&&this.canMergeWith(n)){const e=n.getChildren();this.append(...e),n.remove()}else super.append(n)}return this}replace(e,t){if(be(e))return super.replace(e);this.setIndent(0);const n=this.getParentOrThrow();if(!Pe(n))return e;if(n.__first===this.getKey())n.insertBefore(e);else if(n.__last===this.getKey())n.insertAfter(e);else{const t=d(n);let r=this.getNextSibling();for(;r;){const e=r;r=r.getNextSibling(),t.append(e)}n.insertAfter(e),e.insertAfter(t)}const r=this.__key;let i=0;if(t&&(f(e)||re(139),i=e.getChildrenSize(),e.splice(i,0,this.getChildren())),t&&f(e)){const t=c();if(a(t))for(const n of t.getStartEndPoints())n.key===r&&"element"===n.type&&n.set(e.getKey(),i+n.offset,"element")}return this.remove(),0===n.getChildrenSize()&&n.remove(),e}insertAfter(e,t=!0){const n=this.getParentOrThrow();if(Pe(n)||re(39),be(e))return super.insertAfter(e,t);const r=this.getNextSiblings();if(n.insertAfter(e,t),0!==r.length){const i=d(n);r.forEach(e=>i.append(e)),e.insertAfter(i,t)}return e}remove(e){const t=this.getPreviousSibling(),n=this.getNextSibling();super.remove(e),t&&n&&le(t)&&le(n)&&(he(t.getFirstChild(),n.getFirstChild()),n.remove())}resetOnCopyNodeFrom(e){super.resetOnCopyNodeFrom(e),e.getChecked()&&this.setChecked(!1)}insertNewAfter(e,t=!0){const n=d(this);return this.insertAfter(n,t),n}collapseAtStart(e){const t=h();this.getChildren().forEach(e=>t.append(e));const n=this.getParentOrThrow(),r=n.getParentOrThrow(),i=be(r);if(1===n.getChildrenSize())if(i)n.remove(),r.select();else{n.insertBefore(t),n.remove();const r=e.anchor,i=e.focus,s=t.getKey();"element"===r.type&&r.getNode().is(this)&&r.set(s,r.offset,"element"),"element"===i.type&&i.getNode().is(this)&&i.set(s,i.offset,"element")}else n.insertBefore(t),this.remove();return!0}getValue(){return this.getLatest().__value}setValue(e){const t=this.getWritable();return t.__value=e,t}getChecked(){const e=this.getLatest();let t;const n=this.getParent();return Pe(n)&&(t=n.getListType()),"check"===t?Boolean(e.__checked):void 0}setChecked(e){const t=this.getWritable();return t.__checked=e,t}toggleChecked(){const e=this.getWritable();return e.setChecked(!e.__checked)}getIndent(){const e=this.getParent();if(null===e||!this.isAttached())return this.getLatest().__indent;let t=e.getParentOrThrow(),n=0;for(;be(t);)t=t.getParentOrThrow().getParentOrThrow(),n++;return n}setIndent(e){"number"!=typeof e&&re(117),(e=Math.floor(e))>=0||re(199);let t=this.getIndent();for(;t!==e;)t<e?(pe(this),t++):(me(this),t--);return this}canInsertAfter(e){return be(e)}canReplaceWith(e){return be(e)}canMergeWith(e){return be(e)||L(e)}extractWithChild(e,t){if(!a(t))return!1;const n=t.anchor.getNode(),r=t.focus.getNode();return this.isParentOf(n)&&this.isParentOf(r)&&this.getTextContent().length===t.getTextContent().length}isParentRequired(){return!0}createParentElementNode(){return Fe("bullet")}canMergeWhenEmpty(){return!0}}function Ce(e){if(e.classList.contains("task-list-item"))for(const t of e.children)if("INPUT"===t.tagName)return ve(t);if(e.classList.contains("joplin-checkbox"))for(const t of e.children)if(t.classList.contains("checkbox-wrapper")&&t.children.length>0&&"INPUT"===t.children[0].tagName)return ve(t.children[0]);const t=e.getAttribute("aria-checked"),n=Te("true"===t||"false"!==t&&void 0);return N(n,e),{after:ke.bind(null,n),node:F(n,e)}}function ve(e){if(!("checkbox"===e.getAttribute("type")))return{node:null};const t=Te(e.hasAttribute("checked"));return{after:ke.bind(null,t),node:t}}function ke(e,t){const n=t[0];return 1===t.length&&L(n)&&!e.getFormatType()&&n.getFormatType()?(e.setFormat(n.getFormatType()),n.getChildren()):t}function Te(e){return C(new ye(void 0,e))}function be(e){return e instanceof ye}class Se extends v{__tag;__start;__listType;$config(){return this.config("list",{$transform:e=>{!function(e){const t=e.getNextSibling();Pe(t)&&e.getListType()===t.getListType()&&he(e,t)}(e),fe(e)},extends:v,importDOM:k({ol:()=>({conversion:Le,priority:0}),ul:()=>({conversion:Le,priority:0})})})}constructor(e="number",t=1,n){super(n);const r=Ne[e]||e;this.__listType=r,this.__tag="number"===r?"ol":"ul",this.__start=t}afterCloneFrom(e){super.afterCloneFrom(e),this.__listType=e.__listType,this.__tag=e.__tag,this.__start=e.__start}getTag(){return this.getLatest().__tag}setListType(e){const t=this.getWritable();return t.__listType=e,t.__tag="number"===e?"ol":"ul",t}getListType(){return this.getLatest().__listType}getStart(){return this.getLatest().__start}setStart(e){const t=this.getWritable();return t.__start=e,t}createDOM(e,t){const n=this.__tag,r=document.createElement(n);return 1!==this.__start&&r.setAttribute("start",String(this.__start)),r.__lexicalListType=this.__listType,xe(r,e.theme,this),r}updateDOM(e,t,n){return e.__tag!==this.__tag||e.__listType!==this.__listType||(xe(t,n.theme,this),e.__start!==this.__start&&t.setAttribute("start",String(this.__start)),!1)}updateFromJSON(e){return super.updateFromJSON(e).setListType(e.listType).setStart(e.start)}exportDOM(e){const t=this.createDOM(e._config,e);return i(t)&&(1!==this.__start&&t.setAttribute("start",String(this.__start)),"check"===this.__listType&&t.setAttribute("__lexicalListType","check")),{element:t}}exportJSON(){return{...super.exportJSON(),listType:this.getListType(),start:this.getStart(),tag:this.getTag()}}canBeEmpty(){return!1}canIndent(){return!1}splice(e,t,n){let r=n;for(let e=0;e<n.length;e++){const t=n[e];be(t)||(r===n&&(r=[...n]),r[e]=this.createListItemNode().append(!f(t)||Pe(t)||t.isInline()?t:E(t.getTextContent())))}return super.splice(e,t,r)}extractWithChild(e){return be(e)}createListItemNode(){return Te()}}function xe(e,t,i){const s=[],o=[],l=t.list;if(void 0!==l){const e=l[`${i.__tag}Depth`]||[],t=ie(i)-1,n=t%e.length,r=e[n],c=l[i.__tag];let a;const u=l.nested,g=l.checklist;if(void 0!==u&&u.list&&(a=u.list),void 0!==c&&s.push(c),void 0!==g&&"check"===i.__listType&&s.push(g),void 0!==r){s.push(...P(r));for(let t=0;t<e.length;t++)t!==n&&o.push(i.__tag+t)}if(void 0!==a){const e=P(a);t>1?s.push(...e):o.push(...e)}}o.length>0&&n(e,...o),s.length>0&&r(e,...s)}function Le(e){let t;if(function(e){return i(e)&&"ol"===e.nodeName.toLowerCase()}(e)){const n=e.start;t=Fe("number",n)}else t=function(e){if("check"===e.getAttribute("__lexicallisttype")||e.classList.contains("contains-task-list")||"1"===e.getAttribute("data-is-checklist"))return!0;for(const t of e.childNodes)if(i(t)&&t.hasAttribute("aria-checked"))return!0;return!1}(e)?Fe("check"):Fe("bullet");return F(t,e),{after:e=>function(e,t){const n=t.createListItemNode.bind(t),r=[];for(let t=0;t<e.length;t++){const i=e[t];if(be(i)){r.push(i);const e=i.getChildren();e.length>1&&e.forEach(e=>{Pe(e)&&r.push(n().append(e))})}else r.push(n().append(i))}return r}(e,t),node:t}}const Ne={ol:"number",ul:"bullet"};function Fe(e="number",t=1){return C(new Se(e,t))}function Pe(e){return e instanceof Se}const Ae=O("INSERT_CHECK_LIST_COMMAND");function Ee(e,t){const n=t&&t.disableTakeFocusOnClick||!1,r="boolean"==typeof n?()=>n:n.peek.bind(n),l=e=>{const t=e.target;if(!i(t))return!1;const n=t.__lexicalCheckListLastHandled;return void 0!==n&&e.timeStamp-n<500},u=e=>{const t=e.target;i(t)&&(t.__lexicalCheckListLastHandled=e.timeStamp)},g=e=>{l(e)||(u(e),Ie(e,r()))},h=e=>{"touch"===e.pointerType&&(l(e)||(u(e),Ie(e,r())))},d=e=>{!function(e,t){Oe(e,()=>{e.preventDefault(),t&&e.stopPropagation()})}(e,r())};return s(e.registerCommand(Ae,()=>(ae("check"),!0),I),e.registerCommand(w,t=>De(t,e,!1),I),e.registerCommand(D,t=>De(t,e,!0),I),e.registerCommand(M,()=>{if(null!=we()){const t=e.getRootElement();return null!=t&&t.focus(),!0}return!1},I),e.registerCommand($,t=>{const n=we();return!(null==n||!e.isEditable())&&(e.update(()=>{const e=R(n);be(e)&&(t.preventDefault(),e.toggleChecked())}),!0)},I),e.registerCommand(K,t=>e.getEditorState().read(()=>{const n=c();if(a(n)&&n.isCollapsed()){const{anchor:r}=n,i="element"===r.type;if(i||0===r.offset){const n=r.getNode(),s=o(n,e=>f(e)&&!e.isInline());if(be(s)){const r=s.getParent();if(Pe(r)&&"check"===r.getListType()&&(i||s.getFirstDescendant()===n)){const n=e.getElementByKey(s.__key);if(null!=n&&document.activeElement!==n)return n.focus(),t.preventDefault(),!0}}}}return!1}),I),e.registerRootListener(e=>{if(null!==e)return e.addEventListener("click",g),e.addEventListener("pointerup",h),e.addEventListener("pointerdown",d,{capture:!0}),e.addEventListener("mousedown",d,{capture:!0}),e.addEventListener("touchstart",d,{capture:!0,passive:!1}),()=>{e.removeEventListener("click",g),e.removeEventListener("pointerup",h),e.removeEventListener("pointerdown",d,{capture:!0}),e.removeEventListener("mousedown",d,{capture:!0}),e.removeEventListener("touchstart",d,{capture:!0})}}))}function Oe(e,t){const n=e.target;if(!i(n))return;const r=n.firstChild;if(i(r)&&("UL"===r.tagName||"OL"===r.tagName))return;const s=n.parentNode;if(!s||"check"!==s.__lexicalListType)return;let o=null,c=null;if("clientX"in e)o=e.clientX;else if("touches"in e){const t=e.touches;t.length>0&&(o=t[0].clientX,c="touch")}if(null==o)return;const a=n.getBoundingClientRect(),u=o/l(n),g=window.getComputedStyle?window.getComputedStyle(n,"::before"):{width:"0px"},h=parseFloat(g.width),d="touch"===c||"pointerType"in e&&"touch"===e.pointerType?32:0;("rtl"===n.dir?u<a.right+d&&u>a.right-h-d:u>a.left-d&&u<a.left+h+d)&&t()}function Ie(e,t){Oe(e,()=>{if(i(e.target)){const n=e.target,r=B(n);null!=r&&r.isEditable()&&r.update(()=>{const e=R(n);be(e)&&(t?(W(U),W(J)):n.focus(),e.toggleChecked())})}})}function we(){const e=document.activeElement;return i(e)&&"LI"===e.tagName&&null!=e.parentNode&&"check"===e.parentNode.__lexicalListType?e:null}function De(e,t,n){const r=we();return null!=r&&t.update(()=>{const i=R(r);if(!be(i))return;const s=function(e,t){let n=t?e.getPreviousSibling():e.getNextSibling(),r=e;for(;null==n&&be(r);)r=r.getParentOrThrow().getParent(),null!=r&&(n=t?r.getPreviousSibling():r.getNextSibling());for(;be(n);){const e=t?n.getLastChild():n.getFirstChild();if(!Pe(e))return n;n=t?e.getLastChild():e.getFirstChild()}return null}(i,n);if(null!=s){s.selectStart();const n=t.getElementByKey(s.__key);null!=n&&(e.preventDefault(),setTimeout(()=>{n.focus()},0))}}),!1}const Me=O("UPDATE_LIST_START_COMMAND"),$e=O("INSERT_UNORDERED_LIST_COMMAND"),Re=O("INSERT_ORDERED_LIST_COMMAND"),Ke=O("REMOVE_LIST_COMMAND");function Be(e,t){return s(e.registerCommand(Re,()=>(ae("number"),!0),I),e.registerCommand(Me,e=>{const{listNodeKey:t,newStart:n}=e,r=V(t);return!!Pe(r)&&("number"===r.getListType()&&(r.setStart(n),fe(r)),!0)},I),e.registerCommand($e,()=>(ae("bullet"),!0),I),e.registerCommand(Ke,()=>(de(),!0),I),e.registerCommand(q,()=>_e(!!(t&&t.restoreNumbering)),I),e.registerNodeTransform(ye,e=>{const t=e.getFirstChild();if(t){if(u(t)){const n=t.getStyle(),r=t.getFormat();e.getTextStyle()!==n&&e.setTextStyle(n),e.getTextFormat()!==r&&e.setTextFormat(r)}}else{const t=c();a(t)&&(t.style!==e.getTextStyle()||t.format!==e.getTextFormat())&&t.isCollapsed()&&e.is(t.anchor.getNode())&&e.setTextStyle(t.style).setTextFormat(t.format)}}),e.registerNodeTransform(z,e=>{const t=e.getParent();if(be(t)&&e.is(t.getFirstChild())){const n=e.getStyle(),r=e.getFormat();n===t.getTextStyle()&&r===t.getTextFormat()||t.setTextStyle(n).setTextFormat(r)}}))}function We(e){const t=e=>{const t=e.getParent();if(Pe(e.getFirstChild())||!Pe(t))return;const n=o(e,e=>be(e)&&Pe(e.getParent())&&be(e.getPreviousSibling()));if(null===n&&e.getIndent()>0)e.setIndent(0);else if(be(n)){const r=n.getPreviousSibling();if(be(r)){const n=function(e){let t=e,n=t.getFirstChild();for(;Pe(n);){const e=n.getLastChild();if(!be(e))break;t=e,n=t.getFirstChild()}return t}(r),i=n.getParent();if(Pe(i)){const n=ie(i);n+1<ie(t)&&e.setIndent(n)}}}};return e.registerNodeTransform(Se,e=>{const n=[e];for(;n.length>0;){const e=n.shift();if(Pe(e))for(const r of e.getChildren())if(be(r)){t(r);const e=r.getFirstChild();Pe(e)&&n.push(e)}}})}const Ue=H({build:(e,t,n)=>G(t),config:j({hasStrictIndent:!1,shouldPreserveNumbering:!1}),name:"@lexical/list/List",nodes:()=>[Se,ye],register(e,t,n){const r=n.getOutput();return s(Q(()=>Be(e,{restoreNumbering:r.shouldPreserveNumbering.value})),Q(()=>r.hasStrictIndent.value?We(e):void 0))}}),Je=H({build:(e,t)=>G(t),config:j({disableTakeFocusOnClick:!1}),dependencies:[Ue],name:"@lexical/list/CheckList",register:(e,t,n)=>Ee(e,n.getOutput())});function Ve(e){const t=[];for(const n of e)if(be(n)){t.push(n);const e=n.getChildren();if(e.length>1)for(const n of e)Pe(n)&&t.push(Te().append(n))}else t.push(Te().append(n));return t}const qe=ee({$import:(e,t)=>{let n;var r;return ne(t,"ol")?n=Fe("number",t.start):n=(r=t).matches('[__lexicallisttype="check"], .contains-task-list, [data-is-checklist="1"]')||null!==r.querySelector(":scope > [aria-checked]")?Fe("check"):Fe("bullet"),F(n,t),[n.splice(0,0,Ve(e.$importChildren(t)))]},match:te.tag("ol","ul"),name:"@lexical/list/list"});function ze(e,t){if(1!==t.length)return t;const n=t[0];return L(n)&&!e.getFormatType()&&n.getFormatType()?(e.setFormat(n.getFormatType()),n.getChildren()):t}const He=ee({$import:(e,t)=>{const n=t.getAttribute("aria-checked"),r=Te("true"===n||"false"!==n&&void 0);return N(r,t),F(r,t),[r.splice(0,0,ze(r,e.$importChildren(t)))]},match:te.tag("li"),name:"@lexical/list/li"});function je(e,t,n){const r=ne(n,"input")?n:n.querySelector('input[type="checkbox"]');if(!r||"checkbox"!==r.getAttribute("type"))return[];const i=Te(r.hasAttribute("checked"));return N(i,t),F(i,t),[i.splice(0,0,ze(i,e.$importChildren(t)))]}const Xe={$accepts:e=>be(e)||Pe(e),$packageRun:e=>[Te().splice(0,0,e)],name:"ListSchema"},Ge=[ee({$import:(e,t,n)=>{const r=t.querySelector(':scope > input[type="checkbox"]');return r?je(e,t,r):n()},match:te.tag("li").classAll("task-list-item"),name:"@lexical/list/li-task-list-item"}),ee({$import:(e,t,n)=>{const r=t.querySelector(":scope > .checkbox-wrapper");if(!r)return n();const i=r.querySelector(':scope > input[type="checkbox"]');return i?je(e,t,i):n()},match:te.tag("li").classAll("joplin-checkbox"),name:"@lexical/list/li-joplin-checkbox"}),qe,He],Qe=H({dependencies:[Y,Ue,X(Z,{rules:Ge})],name:"@lexical/list/Import"});function Ye(e,t){e.update(()=>ae(t))}function Ze(e){e.update(()=>de())}export{Te as $createListItemNode,Fe as $createListNode,ie as $getListDepth,_e as $handleListInsertParagraph,ae as $insertList,be as $isListItemNode,Pe as $isListNode,de as $removeList,Je as CheckListExtension,Ae as INSERT_CHECK_LIST_COMMAND,Re as INSERT_ORDERED_LIST_COMMAND,$e as INSERT_UNORDERED_LIST_COMMAND,Ue as ListExtension,Qe as ListImportExtension,Ge as ListImportRules,ye as ListItemNode,Se as ListNode,Xe as ListSchema,Ke as REMOVE_LIST_COMMAND,Me as UPDATE_LIST_START_COMMAND,Ye as insertList,Ee as registerCheckList,Be as registerList,We as registerListStrictIndentTransform,Ze as removeList}; | ||
| import{$getNearestNodeOfType as e,$insertNodeToNearestRootAtCaret as t,removeClassNamesFromElement as n,addClassNamesToElement as r,isHTMLElement as i,mergeRegister as s,$findMatchingParent as o,calculateZoomLevel as l}from"@lexical/utils";import{$getSelection as c,$isRangeSelection as a,$isTextNode as u,$isRootOrShadowRoot as h,$createParagraphNode as g,$copyNode as d,$isElementNode as f,$isLeafNode as p,$setPointFromCaret as m,$normalizeCaret as _,$getChildCaret as y,$applyNodeReplacement as C,ElementNode as v,buildImportMap as k,$getSiblingCaret as T,$rewindSiblingCaret as b,setDOMStyleFromCSS as S,isHTMLElement as x,$isParagraphNode as L,$setFormatFromDOM as N,$setDirectionFromDOM as F,normalizeClassNames as P,getStyleObjectFromCSS as A,$createTextNode as E,createCommand as O,COMMAND_PRIORITY_LOW as I,KEY_ARROW_DOWN_COMMAND as w,KEY_ARROW_UP_COMMAND as D,KEY_ESCAPE_COMMAND as M,KEY_SPACE_COMMAND as $,$getNearestNodeFromDOMNode as R,KEY_ARROW_LEFT_COMMAND as K,getNearestEditorFromDOMNode as B,$addUpdateTag as W,SKIP_SELECTION_FOCUS_TAG as U,SKIP_DOM_SELECTION_TAG as J,$getNodeByKey as V,INSERT_PARAGRAPH_COMMAND as q,TextNode as z,defineExtension as H,safeCast as j,configExtension as X,$createLineBreakNode as G}from"lexical";import{namedSignals as Q,effect as Y}from"@lexical/extension";import{DOMImportExtension as Z,defineImportRule as ee,sel as te,isElementOfTag as ne,$propagateTextAlignToBlockChildren as re,$isBlockLevel as ie}from"@lexical/html";function se(e,...t){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",e);for(const e of t)r.append("v",e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function oe(e){let t=1,n=e.getParent();for(;null!=n;){if(xe(n)){const e=n.getParent();if(Ee(e)){t++,n=e.getParent();continue}se(40)}return t}return t}function le(e){let t=e.getParent();Ee(t)||se(40);let n=t;for(;null!==n;)n=n.getParent(),Ee(n)&&(t=n);return t}function ce(e){let t=[];const n=e.getChildren().filter(xe);for(let e=0;e<n.length;e++){const r=n[e],i=r.getFirstChild();Ee(i)?t=t.concat(ce(i)):t.push(r)}return t}function ae(e){return xe(e)&&Ee(e.getFirstChild())}function ue(e,t){return xe(e)&&(0===t.length||1===t.length&&e.is(t[0])&&0===e.getChildrenSize())}function he(e){const t=c();if(null!==t){let n=t.getNodes();if(a(t)){const[r]=t.getStartEndPoints(),i=r.getNode(),s=i.getParent();if(h(i)){const e=i.getFirstChild();if(e)n=e.selectStart().getNodes();else{const e=g();i.append(e),n=e.select().getNodes()}}else if(ue(i,n)){const t=Ae(e);if(h(s)){i.replace(t);const e=Se();f(i)&&(e.setFormat(i.getFormatType()),e.setIndent(i.getIndent())),t.append(e)}else if(xe(i)){const e=i.getParentOrThrow();ge(t,e.getChildren()),e.replace(t)}return}}const r=new Set;for(let t=0;t<n.length;t++){const i=n[t];if(f(i)&&i.isEmpty()&&!xe(i)&&!r.has(i.getKey())){de(i,e);continue}let s=p(i)?i.getParent():xe(i)&&i.isEmpty()?i:null;for(;null!=s;){const t=s.getKey();if(Ee(s)){if(!r.has(t)){const n=Ae(e);ge(n,s.getChildren()),s.replace(n),r.add(t)}break}{const n=s.getParent();if(h(n)&&!r.has(t)){r.add(t),de(s,e);break}s=n}}}}}function ge(e,t){e.splice(e.getChildrenSize(),0,t)}function de(e,t){if(Ee(e))return e;const n=e.getPreviousSibling(),r=e.getNextSibling(),i=Se();let s;if(ge(i,e.getChildren()),Ee(n)&&t===n.getListType())n.append(i),Ee(r)&&t===r.getListType()&&(ge(n,r.getChildren()),r.remove()),s=n;else if(Ee(r)&&t===r.getListType())r.getFirstChildOrThrow().insertBefore(i),s=r;else{const n=Ae(t);n.append(i),e.replace(n),s=n}i.setFormat(e.getFormatType()),i.setIndent(e.getIndent());const o=c();return a(o)&&(s.getKey()===o.anchor.key&&o.anchor.set(i.getKey(),o.anchor.offset,"element"),s.getKey()===o.focus.key&&o.focus.set(i.getKey(),o.focus.offset,"element")),e.remove(),s}function fe(e,t){const n=e.getLastChild(),r=t.getFirstChild();n&&r&&ae(n)&&ae(r)&&(fe(n.getFirstChild(),r.getFirstChild()),r.remove());const i=t.getChildren();i.length>0&&e.append(...i),t.remove()}function pe(){const t=c();if(a(t)){const n=new Set,r=t.getNodes(),i=t.anchor.getNode();if(ue(i,r))n.add(le(i));else for(let t=0;t<r.length;t++){const i=r[t];if(p(i)){const t=e(i,ve);null!=t&&n.add(le(t))}}for(const e of n){let n=e;const r=ce(e);for(const e of r){const r=g().setTextStyle(t.style).setTextFormat(t.format);ge(r,e.getChildren()),n.insertAfter(r),n=r,e.__key===t.anchor.key&&m(t.anchor,_(y(r,"next"))),e.__key===t.focus.key&&m(t.focus,_(y(r,"next"))),e.remove()}e.remove()}}}function me(e){const t="check"!==e.getListType();let n=e.getStart();for(const r of e.getChildren())xe(r)&&(r.getValue()!==n&&r.setValue(n),t&&null!=r.getLatest().__checked&&r.setChecked(void 0),Ee(r.getFirstChild())||n++)}function _e(e){const t=new Set;if(ae(e)||t.has(e.getKey()))return;const n=e.getParent(),r=e.getNextSibling(),i=e.getPreviousSibling();if(ae(r)&&ae(i)){const n=i.getFirstChild();if(Ee(n)){n.append(e);const i=r.getFirstChild();if(Ee(i)){ge(n,i.getChildren()),r.remove(),t.add(r.getKey())}}}else if(ae(r)){const t=r.getFirstChild();if(Ee(t)){const n=t.getFirstChild();null!==n&&n.insertBefore(e)}}else if(ae(i)){const t=i.getFirstChild();Ee(t)&&t.append(e)}else if(Ee(n)){const t=d(e),s=d(n);t.append(s),s.append(e),i?i.insertAfter(t):r?r.insertBefore(t):n.append(t)}}function ye(e){if(ae(e))return;const t=e.getParent(),n=t?t.getParent():void 0;if(Ee(n?n.getParent():void 0)&&xe(n)&&Ee(t)){const r=t?t.getFirstChild():void 0,i=t?t.getLastChild():void 0;if(e.is(r))n.insertBefore(e),t.isEmpty()&&n.remove();else if(e.is(i))n.insertAfter(e),t.isEmpty()&&n.remove();else{const r=d(e),i=d(t);r.append(i),e.getPreviousSiblings().forEach(e=>i.append(e));const s=d(e),o=d(t);s.append(o),ge(o,e.getNextSiblings()),n.insertBefore(r),n.insertAfter(s),n.replace(e)}}}function Ce(e=!1){const t=c();if(!a(t)||!t.isCollapsed())return!1;const n=t.anchor.getNode();let r=null;if(xe(n)&&0===n.getChildrenSize())r=n;else if(u(n)){const e=n.getParent();xe(e)&&e.getChildren().every(e=>u(e)&&""===e.getTextContent().trim())&&(r=e)}if(null===r)return!1;const i=le(r),s=r.getParent();Ee(s)||se(40);const o=s.getParent();let l;if(h(o))l=g(),i.insertAfter(l);else{if(!xe(o))return!1;l=d(o),o.insertAfter(l)}l.setTextStyle(t.style).setTextFormat(t.format).select();const f=r.getNextSiblings();if(f.length>0){const t=e?function(e,t){return e.getStart()+t.getIndexWithinParent()}(s,r):1,n=d(s).setStart(t);if(xe(l)){const e=d(l);e.append(n),l.insertAfter(e)}else l.insertAfter(n);n.append(...f)}return function(e){let t=e;for(;null==t.getNextSibling()&&null==t.getPreviousSibling();){const e=t.getParent();if(null==e||!xe(e)&&!Ee(e))break;t=e}t.remove()}(r),!0}class ve extends v{__value;__checked;$config(){return this.config("listitem",{$transform:e=>{const n=e.getParent();if(Ee(n))"check"!==n.getListType()&&null!=e.getChecked()&&e.setChecked(void 0);else if(n){const r=e.createParentElementNode();Ee(r)||se(340);const i=[e];for(const t of["previous","next"]){i.reverse();for(const{origin:n}of T(e,t)){if(!xe(n))break;i.push(n)}}e.insertBefore(r),r.splice(0,0,i),h(n)||(t(r,b(T(r,"next")),{$shouldSplit:()=>!1,removeEmptyDestination:!0}),n.isEmpty()&&n.isAttached()&&n.remove())}},extends:v,importDOM:k({li:()=>({conversion:ke,priority:0})})})}constructor(e=1,t=void 0,n){super(n),this.__value=void 0===e?1:e,this.__checked=t}afterCloneFrom(e){super.afterCloneFrom(e),this.__value=e.__value,this.__checked=e.__checked}createDOM(e){const t=document.createElement("li");return this.updateListItemDOM(null,t,e),t}updateListItemDOM(e,t,i){!function(e,t){const n=t.getParent();!Ee(n)||"check"!==n.getListType()||Ee(t.getFirstChild())?(e.removeAttribute("role"),e.removeAttribute("tabIndex"),e.removeAttribute("aria-checked")):(e.setAttribute("role","checkbox"),e.setAttribute("tabIndex","-1"),e.setAttribute("aria-checked",t.getChecked()?"true":"false"))}(t,this),t.value=this.__value,function(e,t,i){const s=t.list;if(!s)return;const o=s.listitem,l=s.nested&&s.nested.listitem,c=i.getParent(),a=Ee(c)&&"check"===c.getListType(),u=i.getChecked(),h=i.getChildren().some(e=>Ee(e)),g=[];void 0!==s.listitemChecked&&g.push(s.listitemChecked);void 0!==s.listitemUnchecked&&g.push(s.listitemUnchecked);void 0!==l&&g.push(...P(l));g.length>0&&n(e,...g);const d=[];void 0!==o&&d.push(...P(o));if(a){const e=u?s.listitemChecked:s.listitemUnchecked;void 0!==e&&d.push(e)}void 0!==l&&h&&d.push(...P(l));d.length>0&&r(e,...d)}(t,i.theme,this);const s=e?e.__style:"",o=this.__style;s!==o&&S(t.style,o,s),function(e,t,n){const r=t.__textStyle,i=n?n.__textStyle:"";if(null!==n&&i===r)return;const s=A(r);for(const t in s)e.style.setProperty(`--listitem-marker-${t}`,s[t]);if(""!==i)for(const t in A(i))t in s||e.style.removeProperty(`--listitem-marker-${t}`)}(t,this,e)}updateDOM(e,t,n){const r=t;return this.updateListItemDOM(e,r,n),!1}updateFromJSON(e){return super.updateFromJSON(e).setValue(e.value).setChecked(e.checked)}exportDOM(e){const t=this.createDOM(e._config),n=this.getFormatType();n&&(t.style.textAlign=n);const r=this.getDirection();return r&&(t.dir=r),ae(this)?{after(e){if(x(e)){const t=e.previousElementSibling;if(x(t)&&"LI"===t.nodeName){for(;e.firstChild;)t.append(e.firstChild);e.remove()}}return e},element:t}:{element:t}}exportJSON(){return{...super.exportJSON(),checked:this.getChecked(),value:this.getValue()}}append(...e){for(let t=0;t<e.length;t++){const n=e[t];if(f(n)&&this.canMergeWith(n)){const e=n.getChildren();this.append(...e),n.remove()}else super.append(n)}return this}replace(e,t){if(xe(e))return super.replace(e);this.setIndent(0);const n=this.getParentOrThrow();if(!Ee(n))return e;if(n.__first===this.getKey())n.insertBefore(e);else if(n.__last===this.getKey())n.insertAfter(e);else{const t=d(n);let r=this.getNextSibling();for(;r;){const e=r;r=r.getNextSibling(),t.append(e)}n.insertAfter(e),e.insertAfter(t)}const r=this.__key;let i=0;if(t&&(f(e)||se(139),i=e.getChildrenSize(),e.splice(i,0,this.getChildren())),t&&f(e)){const t=c();if(a(t))for(const n of t.getStartEndPoints())n.key===r&&"element"===n.type&&n.set(e.getKey(),i+n.offset,"element")}return this.remove(),0===n.getChildrenSize()&&n.remove(),e}insertAfter(e,t=!0){const n=this.getParentOrThrow();if(Ee(n)||se(39),xe(e))return super.insertAfter(e,t);const r=this.getNextSiblings();if(n.insertAfter(e,t),0!==r.length){const i=d(n);r.forEach(e=>i.append(e)),e.insertAfter(i,t)}return e}remove(e){const t=this.getPreviousSibling(),n=this.getNextSibling();super.remove(e),t&&n&&ae(t)&&ae(n)&&(fe(t.getFirstChild(),n.getFirstChild()),n.remove())}resetOnCopyNodeFrom(e){super.resetOnCopyNodeFrom(e),e.getChecked()&&this.setChecked(!1)}insertNewAfter(e,t=!0){const n=d(this);return this.insertAfter(n,t),n}collapseAtStart(e){const t=g();this.getChildren().forEach(e=>t.append(e));const n=this.getParentOrThrow(),r=n.getParentOrThrow(),i=xe(r);if(1===n.getChildrenSize())if(i)n.remove(),r.select();else{n.insertBefore(t),n.remove();const r=e.anchor,i=e.focus,s=t.getKey();"element"===r.type&&r.getNode().is(this)&&r.set(s,r.offset,"element"),"element"===i.type&&i.getNode().is(this)&&i.set(s,i.offset,"element")}else n.insertBefore(t),this.remove();return!0}getValue(){return this.getLatest().__value}setValue(e){const t=this.getWritable();return t.__value=e,t}getChecked(){const e=this.getLatest();let t;const n=this.getParent();return Ee(n)&&(t=n.getListType()),"check"===t?Boolean(e.__checked):void 0}setChecked(e){const t=this.getWritable();return t.__checked=e,t}toggleChecked(){const e=this.getWritable();return e.setChecked(!e.__checked)}getIndent(){const e=this.getParent();if(null===e||!this.isAttached())return this.getLatest().__indent;let t=e.getParentOrThrow(),n=0;for(;xe(t);)t=t.getParentOrThrow().getParentOrThrow(),n++;return n}setIndent(e){"number"!=typeof e&&se(117),(e=Math.floor(e))>=0||se(199);let t=this.getIndent();for(;t!==e;)t<e?(_e(this),t++):(ye(this),t--);return this}canInsertAfter(e){return xe(e)}canReplaceWith(e){return xe(e)}canMergeWith(e){return xe(e)||L(e)}extractWithChild(e,t){if(!a(t))return!1;const n=t.anchor.getNode(),r=t.focus.getNode();return this.isParentOf(n)&&this.isParentOf(r)&&this.getTextContent().length===t.getTextContent().length}isParentRequired(){return!0}createParentElementNode(){return Ae("bullet")}canMergeWhenEmpty(){return!0}}function ke(e){if(e.classList.contains("task-list-item"))for(const t of e.children)if("INPUT"===t.tagName)return Te(t);if(e.classList.contains("joplin-checkbox"))for(const t of e.children)if(t.classList.contains("checkbox-wrapper")&&t.children.length>0&&"INPUT"===t.children[0].tagName)return Te(t.children[0]);const t=e.getAttribute("aria-checked"),n=Se("true"===t||"false"!==t&&void 0);return N(n,e),{after:be.bind(null,n),node:F(n,e)}}function Te(e){if(!("checkbox"===e.getAttribute("type")))return{node:null};const t=Se(e.hasAttribute("checked"));return{after:be.bind(null,t),node:t}}function be(e,t){const n=t[0];return 1===t.length&&L(n)&&!e.getFormatType()&&n.getFormatType()?(e.setFormat(n.getFormatType()),n.getChildren()):t}function Se(e){return C(new ve(void 0,e))}function xe(e){return e instanceof ve}class Le extends v{__tag;__start;__listType;$config(){return this.config("list",{$transform:e=>{!function(e){const t=e.getNextSibling();Ee(t)&&e.getListType()===t.getListType()&&fe(e,t)}(e),me(e)},extends:v,importDOM:k({ol:()=>({conversion:Fe,priority:0}),ul:()=>({conversion:Fe,priority:0})})})}constructor(e="number",t=1,n){super(n);const r=Pe[e]||e;this.__listType=r,this.__tag="number"===r?"ol":"ul",this.__start=t}afterCloneFrom(e){super.afterCloneFrom(e),this.__listType=e.__listType,this.__tag=e.__tag,this.__start=e.__start}getTag(){return this.getLatest().__tag}setListType(e){const t=this.getWritable();return t.__listType=e,t.__tag="number"===e?"ol":"ul",t}getListType(){return this.getLatest().__listType}getStart(){return this.getLatest().__start}setStart(e){const t=this.getWritable();return t.__start=e,t}createDOM(e,t){const n=this.__tag,r=document.createElement(n);return 1!==this.__start&&r.setAttribute("start",String(this.__start)),r.__lexicalListType=this.__listType,Ne(r,e.theme,this),r}updateDOM(e,t,n){return e.__tag!==this.__tag||e.__listType!==this.__listType||(Ne(t,n.theme,this),e.__start!==this.__start&&t.setAttribute("start",String(this.__start)),!1)}updateFromJSON(e){return super.updateFromJSON(e).setListType(e.listType).setStart(e.start)}exportDOM(e){const t=this.createDOM(e._config,e);return i(t)&&(1!==this.__start&&t.setAttribute("start",String(this.__start)),"check"===this.__listType&&t.setAttribute("__lexicalListType","check")),{element:t}}exportJSON(){return{...super.exportJSON(),listType:this.getListType(),start:this.getStart(),tag:this.getTag()}}canBeEmpty(){return!1}canIndent(){return!1}splice(e,t,n){let r=n;for(let e=0;e<n.length;e++){const t=n[e];xe(t)||(r===n&&(r=[...n]),r[e]=this.createListItemNode().append(!f(t)||Ee(t)||t.isInline()?t:E(t.getTextContent())))}return super.splice(e,t,r)}extractWithChild(e){return xe(e)}createListItemNode(){return Se()}}function Ne(e,t,i){const s=[],o=[],l=t.list;if(void 0!==l){const e=l[`${i.__tag}Depth`]||[],t=oe(i)-1,n=t%e.length,r=e[n],c=l[i.__tag];let a;const u=l.nested,h=l.checklist;if(void 0!==u&&u.list&&(a=u.list),void 0!==c&&s.push(c),void 0!==h&&"check"===i.__listType&&s.push(h),void 0!==r){s.push(...P(r));for(let t=0;t<e.length;t++)t!==n&&o.push(i.__tag+t)}if(void 0!==a){const e=P(a);t>1?s.push(...e):o.push(...e)}}o.length>0&&n(e,...o),s.length>0&&r(e,...s)}function Fe(e){let t;if(function(e){return i(e)&&"ol"===e.nodeName.toLowerCase()}(e)){const n=e.start;t=Ae("number",n)}else t=function(e){if("check"===e.getAttribute("__lexicallisttype")||e.classList.contains("contains-task-list")||"1"===e.getAttribute("data-is-checklist"))return!0;for(const t of e.childNodes)if(i(t)&&t.hasAttribute("aria-checked"))return!0;return!1}(e)?Ae("check"):Ae("bullet");return F(t,e),{after:e=>function(e,t){const n=t.createListItemNode.bind(t),r=[];for(let t=0;t<e.length;t++){const i=e[t];if(xe(i)){r.push(i);const e=i.getChildren();e.length>1&&e.forEach(e=>{Ee(e)&&r.push(n().append(e))})}else r.push(n().append(i))}return r}(e,t),node:t}}const Pe={ol:"number",ul:"bullet"};function Ae(e="number",t=1){return C(new Le(e,t))}function Ee(e){return e instanceof Le}const Oe=O("INSERT_CHECK_LIST_COMMAND");function Ie(e,t){const n=t&&t.disableTakeFocusOnClick||!1,r="boolean"==typeof n?()=>n:n.peek.bind(n),l=e=>{const t=e.target;if(!i(t))return!1;const n=t.__lexicalCheckListLastHandled;return void 0!==n&&e.timeStamp-n<500},u=e=>{const t=e.target;i(t)&&(t.__lexicalCheckListLastHandled=e.timeStamp)},h=e=>{l(e)||(u(e),De(e,r()))},g=e=>{"touch"===e.pointerType&&(l(e)||(u(e),De(e,r())))},d=e=>{!function(e,t){we(e,()=>{e.preventDefault(),t&&e.stopPropagation()})}(e,r())};return s(e.registerCommand(Oe,()=>(he("check"),!0),I),e.registerCommand(w,t=>$e(t,e,!1),I),e.registerCommand(D,t=>$e(t,e,!0),I),e.registerCommand(M,()=>{if(null!=Me()){const t=e.getRootElement();return null!=t&&t.focus(),!0}return!1},I),e.registerCommand($,t=>{const n=Me();return!(null==n||!e.isEditable())&&(e.update(()=>{const e=R(n);xe(e)&&(t.preventDefault(),e.toggleChecked())}),!0)},I),e.registerCommand(K,t=>e.getEditorState().read(()=>{const n=c();if(a(n)&&n.isCollapsed()){const{anchor:r}=n,i="element"===r.type;if(i||0===r.offset){const n=r.getNode(),s=o(n,e=>f(e)&&!e.isInline());if(xe(s)){const r=s.getParent();if(Ee(r)&&"check"===r.getListType()&&(i||s.getFirstDescendant()===n)){const n=e.getElementByKey(s.__key);if(null!=n&&document.activeElement!==n)return n.focus(),t.preventDefault(),!0}}}}return!1}),I),e.registerRootListener(e=>{if(null!==e)return e.addEventListener("click",h),e.addEventListener("pointerup",g),e.addEventListener("pointerdown",d,{capture:!0}),e.addEventListener("mousedown",d,{capture:!0}),e.addEventListener("touchstart",d,{capture:!0,passive:!1}),()=>{e.removeEventListener("click",h),e.removeEventListener("pointerup",g),e.removeEventListener("pointerdown",d,{capture:!0}),e.removeEventListener("mousedown",d,{capture:!0}),e.removeEventListener("touchstart",d,{capture:!0})}}))}function we(e,t){const n=e.target;if(!i(n))return;const r=n.firstChild;if(i(r)&&("UL"===r.tagName||"OL"===r.tagName))return;const s=n.parentNode;if(!s||"check"!==s.__lexicalListType)return;let o=null,c=null;if("clientX"in e)o=e.clientX;else if("touches"in e){const t=e.touches;t.length>0&&(o=t[0].clientX,c="touch")}if(null==o)return;const a=n.getBoundingClientRect(),u=o/l(n),h=window.getComputedStyle?window.getComputedStyle(n,"::before"):{width:"0px"},g=parseFloat(h.width),d="touch"===c||"pointerType"in e&&"touch"===e.pointerType?32:0;("rtl"===n.dir?u<a.right+d&&u>a.right-g-d:u>a.left-d&&u<a.left+g+d)&&t()}function De(e,t){we(e,()=>{if(i(e.target)){const n=e.target,r=B(n);null!=r&&r.isEditable()&&r.update(()=>{const e=R(n);xe(e)&&(t?(W(U),W(J)):n.focus(),e.toggleChecked())})}})}function Me(){const e=document.activeElement;return i(e)&&"LI"===e.tagName&&null!=e.parentNode&&"check"===e.parentNode.__lexicalListType?e:null}function $e(e,t,n){const r=Me();return null!=r&&t.update(()=>{const i=R(r);if(!xe(i))return;const s=function(e,t){let n=t?e.getPreviousSibling():e.getNextSibling(),r=e;for(;null==n&&xe(r);)r=r.getParentOrThrow().getParent(),null!=r&&(n=t?r.getPreviousSibling():r.getNextSibling());for(;xe(n);){const e=t?n.getLastChild():n.getFirstChild();if(!Ee(e))return n;n=t?e.getLastChild():e.getFirstChild()}return null}(i,n);if(null!=s){s.selectStart();const n=t.getElementByKey(s.__key);null!=n&&(e.preventDefault(),setTimeout(()=>{n.focus()},0))}}),!1}const Re=O("UPDATE_LIST_START_COMMAND"),Ke=O("INSERT_UNORDERED_LIST_COMMAND"),Be=O("INSERT_ORDERED_LIST_COMMAND"),We=O("REMOVE_LIST_COMMAND");function Ue(e,t){return s(e.registerCommand(Be,()=>(he("number"),!0),I),e.registerCommand(Re,e=>{const{listNodeKey:t,newStart:n}=e,r=V(t);return!!Ee(r)&&("number"===r.getListType()&&(r.setStart(n),me(r)),!0)},I),e.registerCommand(Ke,()=>(he("bullet"),!0),I),e.registerCommand(We,()=>(pe(),!0),I),e.registerCommand(q,()=>Ce(!!(t&&t.restoreNumbering)),I),e.registerNodeTransform(ve,e=>{const t=e.getFirstChild();if(t){if(u(t)){const n=t.getStyle(),r=t.getFormat();e.getTextStyle()!==n&&e.setTextStyle(n),e.getTextFormat()!==r&&e.setTextFormat(r)}}else{const t=c();a(t)&&(t.style!==e.getTextStyle()||t.format!==e.getTextFormat())&&t.isCollapsed()&&e.is(t.anchor.getNode())&&e.setTextStyle(t.style).setTextFormat(t.format)}}),e.registerNodeTransform(z,e=>{const t=e.getParent();if(xe(t)&&e.is(t.getFirstChild())){const n=e.getStyle(),r=e.getFormat();n===t.getTextStyle()&&r===t.getTextFormat()||t.setTextStyle(n).setTextFormat(r)}}))}function Je(e){const t=e=>{const t=e.getParent();if(Ee(e.getFirstChild())||!Ee(t))return;const n=o(e,e=>xe(e)&&Ee(e.getParent())&&xe(e.getPreviousSibling()));if(null===n&&e.getIndent()>0)e.setIndent(0);else if(xe(n)){const r=n.getPreviousSibling();if(xe(r)){const n=function(e){let t=e,n=t.getFirstChild();for(;Ee(n);){const e=n.getLastChild();if(!xe(e))break;t=e,n=t.getFirstChild()}return t}(r),i=n.getParent();if(Ee(i)){const n=oe(i);n+1<oe(t)&&e.setIndent(n)}}}};return e.registerNodeTransform(Le,e=>{const n=[e];for(;n.length>0;){const e=n.shift();if(Ee(e))for(const r of e.getChildren())if(xe(r)){t(r);const e=r.getFirstChild();Ee(e)&&n.push(e)}}})}const Ve=H({build:(e,t,n)=>Q(t),config:j({hasStrictIndent:!1,shouldPreserveNumbering:!1}),name:"@lexical/list/List",nodes:()=>[Le,ve],register(e,t,n){const r=n.getOutput();return s(Y(()=>Ue(e,{restoreNumbering:r.shouldPreserveNumbering.value})),Y(()=>r.hasStrictIndent.value?Je(e):void 0))}}),qe=H({build:(e,t)=>Q(t),config:j({disableTakeFocusOnClick:!1}),dependencies:[Ve],name:"@lexical/list/CheckList",register:(e,t,n)=>Ie(e,n.getOutput())});function ze(e){const t=[];for(const n of e)if(xe(n)){t.push(n);const e=n.getChildren();if(e.length>1)for(const n of e)Ee(n)&&t.push(Se().append(n))}else t.push(Se().append(n));return t}const He=ee({$import:(e,t)=>{let n;var r;return ne(t,"ol")?n=Ae("number",t.start):n=(r=t).matches('[__lexicallisttype="check"], .contains-task-list, [data-is-checklist="1"]')||null!==r.querySelector(":scope > [aria-checked]")?Ae("check"):Ae("bullet"),F(n,t),[n.splice(0,0,re(ze(e.$importChildren(t)),t))]},match:te.tag("ol","ul"),name:"@lexical/list/list"});function je(e,t){if(1!==t.length)return t;const n=t[0];return L(n)&&!e.getFormatType()&&n.getFormatType()?(e.setFormat(n.getFormatType()),n.getChildren()):t}function Xe(e){const t=e=>ie(e)&&!Ee(e);if(!e.some(t))return e;const n=[];let r=[];const i=()=>{r.length>0&&(n.push(r),r=[])};for(const s of e)t(s)?(i(),n.push(f(s)?s.getChildren():[s])):r.push(s);i();const s=[];for(const e of n)s.length>0&&s.push(G()),s.push(...e);return s}const Ge=ee({$import:(e,t)=>{const n=t.getAttribute("aria-checked"),r=Se("true"===n||"false"!==n&&void 0);return N(r,t),F(r,t),[r.splice(0,0,Xe(je(r,e.$importChildren(t))))]},match:te.tag("li"),name:"@lexical/list/li"});function Qe(e,t,n){const r=ne(n,"input")?n:n.querySelector('input[type="checkbox"]');if(!r||"checkbox"!==r.getAttribute("type"))return[];const i=Se(r.hasAttribute("checked"));return N(i,t),F(i,t),[i.splice(0,0,Xe(je(i,e.$importChildren(t))))]}const Ye={$accepts:e=>xe(e)||Ee(e),$packageRun:e=>[Se().splice(0,0,e)],name:"ListSchema"},Ze=[ee({$import:(e,t,n)=>{const r=t.querySelector(':scope > input[type="checkbox"]');return r?Qe(e,t,r):n()},match:te.tag("li").classAll("task-list-item"),name:"@lexical/list/li-task-list-item"}),ee({$import:(e,t,n)=>{const r=t.querySelector(":scope > .checkbox-wrapper");if(!r)return n();const i=r.querySelector(':scope > input[type="checkbox"]');return i?Qe(e,t,i):n()},match:te.tag("li").classAll("joplin-checkbox"),name:"@lexical/list/li-joplin-checkbox"}),He,Ge],et=H({dependencies:[Ve,X(Z,{rules:Ze})],name:"@lexical/list/Import"});function tt(e,t){e.update(()=>he(t))}function nt(e){e.update(()=>pe())}export{Se as $createListItemNode,Ae as $createListNode,oe as $getListDepth,Ce as $handleListInsertParagraph,he as $insertList,xe as $isListItemNode,Ee as $isListNode,pe as $removeList,qe as CheckListExtension,Oe as INSERT_CHECK_LIST_COMMAND,Be as INSERT_ORDERED_LIST_COMMAND,Ke as INSERT_UNORDERED_LIST_COMMAND,Ve as ListExtension,et as ListImportExtension,Ze as ListImportRules,ve as ListItemNode,Le as ListNode,Ye as ListSchema,We as REMOVE_LIST_COMMAND,Re as UPDATE_LIST_START_COMMAND,tt as insertList,Ie as registerCheckList,Ue as registerList,Je as registerListStrictIndentTransform,nt as removeList}; |
@@ -26,4 +26,7 @@ /** | ||
| /** | ||
| * Bundles {@link ListImportRules} (plus {@link CoreImportExtension}) into | ||
| * a single dependency. | ||
| * Bundles {@link ListImportRules} together with the runtime | ||
| * {@link ListExtension}. The application is expected to already have | ||
| * `CoreImportExtension` (or some equivalent) in its dependency graph — | ||
| * the core/text/paragraph/inline-format rules are a shared baseline, | ||
| * not something this leaf importer should re-declare. | ||
| * | ||
@@ -30,0 +33,0 @@ * @experimental |
+6
-6
@@ -11,11 +11,11 @@ { | ||
| "license": "MIT", | ||
| "version": "0.45.0", | ||
| "version": "0.45.1-dev.0", | ||
| "main": "./dist/LexicalList.js", | ||
| "types": "./dist/index.d.ts", | ||
| "dependencies": { | ||
| "@lexical/extension": "0.45.0", | ||
| "@lexical/internal": "0.45.0", | ||
| "lexical": "0.45.0", | ||
| "@lexical/utils": "0.45.0", | ||
| "@lexical/html": "0.45.0" | ||
| "@lexical/extension": "0.45.1-dev.0", | ||
| "@lexical/internal": "0.45.1-dev.0", | ||
| "@lexical/html": "0.45.1-dev.0", | ||
| "@lexical/utils": "0.45.1-dev.0", | ||
| "lexical": "0.45.1-dev.0" | ||
| }, | ||
@@ -22,0 +22,0 @@ "repository": { |
@@ -12,3 +12,4 @@ /** | ||
| import { | ||
| CoreImportExtension, | ||
| $isBlockLevel, | ||
| $propagateTextAlignToBlockChildren, | ||
| defineImportRule, | ||
@@ -20,2 +21,4 @@ DOMImportExtension, | ||
| import { | ||
| $createLineBreakNode, | ||
| $isElementNode, | ||
| $isParagraphNode, | ||
@@ -85,3 +88,17 @@ $setDirectionFromDOM, | ||
| $setDirectionFromDOM(node, el); | ||
| return [node.splice(0, 0, $normalizeListChildren(ctx.$importChildren(el)))]; | ||
| // Propagate the list's `text-align` onto each `ListItemNode` child | ||
| // (legacy `wrapContinuousInlines` did the same), so pasting | ||
| // `<ul style="text-align: left"><li>…</li></ul>` ends up with the | ||
| // alignment on the list items where the reconciler renders it as | ||
| // `style="text-align: left"`. | ||
| return [ | ||
| node.splice( | ||
| 0, | ||
| 0, | ||
| $propagateTextAlignToBlockChildren( | ||
| $normalizeListChildren(ctx.$importChildren(el)), | ||
| el, | ||
| ), | ||
| ), | ||
| ]; | ||
| }, | ||
@@ -117,2 +134,57 @@ match: sel.tag('ol', 'ul'), | ||
| /** | ||
| * Collapse block children of a `<li>` into inline-with-line-break form: a | ||
| * `ListItemNode` is an inline-level container, so any block child marks a | ||
| * boundary. Contiguous inline siblings are kept together as a single run and | ||
| * one {@link $createLineBreakNode} is inserted between runs — reproducing the | ||
| * legacy `wrapContinuousInlines` + `$unwrapArtificialNodes` shape | ||
| * (`<li>1<div>2</div>3</li>` → `1<br>2<br>3`) without the | ||
| * `ArtificialNode__DO_NOT_USE` marker. | ||
| * | ||
| * Boundaries are detected with {@link $isBlockLevel}, NOT `$isParagraphNode`: | ||
| * the `<div>`/`<section>`/… `TransparentBlockRule` happens to emit | ||
| * `ParagraphNode`s, but a `<blockquote>` (`QuoteNode`), heading | ||
| * (`HeadingNode`), or block decorator (`HorizontalRuleNode`, …) is just as | ||
| * much a block boundary and must not be silently spliced into the list item | ||
| * as-is. A nested `ListNode` is the one deliberate exception — it is a valid | ||
| * list-item child that {@link $normalizeListChildren} lifts into a sibling, | ||
| * so it is preserved here rather than unwrapped. | ||
| */ | ||
| function $flattenListItemBlocks(children: LexicalNode[]): LexicalNode[] { | ||
| const $isBoundary = (node: LexicalNode): boolean => | ||
| $isBlockLevel(node) && !$isListNode(node); | ||
| if (!children.some($isBoundary)) { | ||
| return children; | ||
| } | ||
| // Partition into segments — each maximal run of inline siblings, and each | ||
| // boundary's own content — then join the segments with a single line break. | ||
| const segments: LexicalNode[][] = []; | ||
| let inlineRun: LexicalNode[] = []; | ||
| const flushInlineRun = () => { | ||
| if (inlineRun.length > 0) { | ||
| segments.push(inlineRun); | ||
| inlineRun = []; | ||
| } | ||
| }; | ||
| for (const child of children) { | ||
| if ($isBoundary(child)) { | ||
| flushInlineRun(); | ||
| // Unwrap a block ElementNode to its inline content; a childless block | ||
| // DecoratorNode stands on its own line. | ||
| segments.push($isElementNode(child) ? child.getChildren() : [child]); | ||
| } else { | ||
| inlineRun.push(child); | ||
| } | ||
| } | ||
| flushInlineRun(); | ||
| const out: LexicalNode[] = []; | ||
| for (const segment of segments) { | ||
| if (out.length > 0) { | ||
| out.push($createLineBreakNode()); | ||
| } | ||
| out.push(...segment); | ||
| } | ||
| return out; | ||
| } | ||
| const ListItemRule = defineImportRule({ | ||
@@ -134,3 +206,8 @@ $import: (ctx, el) => { | ||
| 0, | ||
| $liftFormatFromSingleParagraph(node, ctx.$importChildren(el)), | ||
| // Lift a sole wrapping paragraph's format onto the item *before* | ||
| // flattening, otherwise the paragraph would already be unwrapped and | ||
| // its alignment lost. | ||
| $flattenListItemBlocks( | ||
| $liftFormatFromSingleParagraph(node, ctx.$importChildren(el)), | ||
| ), | ||
| ), | ||
@@ -162,3 +239,5 @@ ]; | ||
| 0, | ||
| $liftFormatFromSingleParagraph(node, ctx.$importChildren(el)), | ||
| $flattenListItemBlocks( | ||
| $liftFormatFromSingleParagraph(node, ctx.$importChildren(el)), | ||
| ), | ||
| ), | ||
@@ -232,4 +311,7 @@ ]; | ||
| /** | ||
| * Bundles {@link ListImportRules} (plus {@link CoreImportExtension}) into | ||
| * a single dependency. | ||
| * Bundles {@link ListImportRules} together with the runtime | ||
| * {@link ListExtension}. The application is expected to already have | ||
| * `CoreImportExtension` (or some equivalent) in its dependency graph — | ||
| * the core/text/paragraph/inline-format rules are a shared baseline, | ||
| * not something this leaf importer should re-declare. | ||
| * | ||
@@ -240,3 +322,2 @@ * @experimental | ||
| dependencies: [ | ||
| CoreImportExtension, | ||
| ListExtension, | ||
@@ -243,0 +324,0 @@ configExtension(DOMImportExtension, {rules: ListImportRules}), |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
330806
3.13%7540
2.94%0
-100%27
3.85%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated
Updated
Updated