@lexical/extension 0.36.0 → 0.36.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -670,7 +670,7 @@ function maybeWithBuilder(editor) {
670
670
  function normalizeExtensionArgument(arg) {
671
671
  return Array.isArray(arg) ? arg : [arg];
672
672
  }
673
- const PACKAGE_VERSION = "0.36.0+dev.cjs";
673
+ const PACKAGE_VERSION = "0.36.1+dev.cjs";
674
674
 
675
675
  /** @internal */
676
676
  class LexicalBuilder {
@@ -669,7 +669,7 @@ function maybeWithBuilder(editor) {
669
669
  function normalizeExtensionArgument(arg) {
670
670
  return Array.isArray(arg) ? arg : [arg];
671
671
  }
672
- const PACKAGE_VERSION = "0.36.0+dev.esm";
672
+ const PACKAGE_VERSION = "0.36.1+dev.esm";
673
673
 
674
674
  /** @internal */
675
675
  class LexicalBuilder {
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- "use strict";var t=require("lexical"),e=require("@lexical/utils");const n=Symbol.for("preact-signals");function i(){if(d>1)return void d--;let t,e=!1;for(;void 0!==r;){let n=r;for(r=void 0,c++;void 0!==n;){const i=n.o;if(n.o=void 0,n.f&=-3,!(8&n.f)&&g(n))try{n.c()}catch(n){e||(t=n,e=!0)}n=i}}if(c=0,d--,e)throw t}function o(t){if(d>0)return t();d++;try{return t()}finally{i()}}let s,r;function a(t){const e=s;s=void 0;try{return t()}finally{s=e}}let d=0,c=0,u=0;function f(t){if(void 0===s)return;let e=t.n;return void 0===e||e.t!==s?(e={i:0,S:t,p:s.s,n:void 0,t:s,e:void 0,x:void 0,r:e},void 0!==s.s&&(s.s.n=e),s.s=e,t.n=e,32&s.f&&t.S(e),e):-1===e.i?(e.i=0,void 0!==e.n&&(e.n.p=e.p,void 0!==e.p&&(e.p.n=e.n),e.p=s.s,e.n=void 0,s.s.n=e,s.s=e),e):void 0}function l(t,e){this.v=t,this.i=0,this.n=void 0,this.t=void 0,this.W=null==e?void 0:e.watched,this.Z=null==e?void 0:e.unwatched,this.name=null==e?void 0:e.name}function h(t,e){return new l(t,e)}function g(t){for(let e=t.s;void 0!==e;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return!0;return!1}function p(t){for(let e=t.s;void 0!==e;e=e.n){const n=e.S.n;if(void 0!==n&&(e.r=n),e.S.n=e,e.i=-1,void 0===e.n){t.s=e;break}}}function m(t){let e,n=t.s;for(;void 0!==n;){const t=n.p;-1===n.i?(n.S.U(n),void 0!==t&&(t.n=n.n),void 0!==n.n&&(n.n.p=t)):e=n,n.S.n=n.r,void 0!==n.r&&(n.r=void 0),n=t}t.s=e}function x(t,e){l.call(this,void 0),this.x=t,this.s=void 0,this.g=u-1,this.f=4,this.W=null==e?void 0:e.watched,this.Z=null==e?void 0:e.unwatched,this.name=null==e?void 0:e.name}function E(t,e){return new x(t,e)}function v(t){const e=t.u;if(t.u=void 0,"function"==typeof e){d++;const n=s;s=void 0;try{e()}catch(e){throw t.f&=-2,t.f|=8,S(t),e}finally{s=n,i()}}}function S(t){for(let e=t.s;void 0!==e;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,v(t)}function y(t){if(s!==this)throw new Error("Out-of-order effect");m(this),s=t,this.f&=-2,8&this.f&&S(this),i()}function N(t,e){this.x=t,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=null==e?void 0:e.name}function b(t,e){const n=new N(t,e);try{n.c()}catch(t){throw n.d(),t}const i=n.d.bind(n);return i[Symbol.dispose]=i,i}function R(t,e={}){const n={};for(const i in t){const o=e[i],s=h(void 0===o?t[i]:o);n[i]=s}return n}l.prototype.brand=n,l.prototype.h=function(){return!0},l.prototype.S=function(t){const e=this.t;e!==t&&void 0===t.e&&(t.x=e,this.t=t,void 0!==e?e.e=t:a((()=>{var t;null==(t=this.W)||t.call(this)})))},l.prototype.U=function(t){if(void 0!==this.t){const e=t.e,n=t.x;void 0!==e&&(e.x=n,t.e=void 0),void 0!==n&&(n.e=e,t.x=void 0),t===this.t&&(this.t=n,void 0===n&&a((()=>{var t;null==(t=this.Z)||t.call(this)})))}},l.prototype.subscribe=function(t){return b((()=>{const e=this.value,n=s;s=void 0;try{t(e)}finally{s=n}}),{name:"sub"})},l.prototype.valueOf=function(){return this.value},l.prototype.toString=function(){return this.value+""},l.prototype.toJSON=function(){return this.value},l.prototype.peek=function(){const t=s;s=void 0;try{return this.value}finally{s=t}},Object.defineProperty(l.prototype,"value",{get(){const t=f(this);return void 0!==t&&(t.i=this.i),this.v},set(t){if(t!==this.v){if(c>100)throw new Error("Cycle detected");this.v=t,this.i++,u++,d++;try{for(let t=this.t;void 0!==t;t=t.x)t.t.N()}finally{i()}}}}),x.prototype=new l,x.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if(32==(36&this.f))return!0;if(this.f&=-5,this.g===u)return!0;if(this.g=u,this.f|=1,this.i>0&&!g(this))return this.f&=-2,!0;const t=s;try{p(this),s=this;const t=this.x();(16&this.f||this.v!==t||0===this.i)&&(this.v=t,this.f&=-17,this.i++)}catch(t){this.v=t,this.f|=16,this.i++}return s=t,m(this),this.f&=-2,!0},x.prototype.S=function(t){if(void 0===this.t){this.f|=36;for(let t=this.s;void 0!==t;t=t.n)t.S.S(t)}l.prototype.S.call(this,t)},x.prototype.U=function(t){if(void 0!==this.t&&(l.prototype.U.call(this,t),void 0===this.t)){this.f&=-33;for(let t=this.s;void 0!==t;t=t.n)t.S.U(t)}},x.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(let t=this.t;void 0!==t;t=t.x)t.t.N()}},Object.defineProperty(x.prototype,"value",{get(){if(1&this.f)throw new Error("Cycle detected");const t=f(this);if(this.h(),void 0!==t&&(t.i=this.i),16&this.f)throw this.v;return this.v}}),N.prototype.c=function(){const t=this.S();try{if(8&this.f)return;if(void 0===this.x)return;const t=this.x();"function"==typeof t&&(this.u=t)}finally{t()}},N.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,v(this),p(this),d++;const t=s;return s=this,y.bind(this,t)},N.prototype.N=function(){2&this.f||(this.f|=2,this.o=r,r=this)},N.prototype.d=function(){this.f|=8,1&this.f||S(this)},N.prototype.dispose=function(){this.d()};const O=t.defineExtension({build:(t,e,n)=>R(e),config:t.safeCast({defaultSelection:"rootEnd",disabled:!1}),name:"@lexical/extension/AutoFocus",register(t,e,n){const i=n.getOutput();return b((()=>i.disabled.value?void 0:t.registerRootListener((e=>{t.focus((()=>{const t=document.activeElement;null===e||null!==t&&e.contains(t)||e.focus({preventScroll:!0})}),{defaultSelection:i.defaultSelection.peek()})}))))}});function w(){const e=t.$getRoot(),n=t.$getSelection(),i=t.$createParagraphNode();e.clear(),e.append(i),null!==n&&i.select(),t.$isRangeSelection(n)&&(n.format=0)}function C(e,n=w){return e.registerCommand(t.CLEAR_EDITOR_COMMAND,(t=>(e.update(n),!0)),t.COMMAND_PRIORITY_EDITOR)}const M=t.defineExtension({build:(t,e,n)=>R(e),config:t.safeCast({$onClear:w}),name:"@lexical/extension/ClearEditor",register(t,e,n){const{$onClear:i}=n.getOutput();return b((()=>C(t,i.value)))}});function D(t,e){let n;return h(t(),{unwatched(){n&&(n(),n=void 0)},watched(){this.value=t(),n=e(this)}})}const _=t.defineExtension({build:t=>D((()=>t.getEditorState()),(e=>t.registerUpdateListener((t=>{e.value=t.editorState})))),name:"@lexical/extension/EditorState"});function I(t,...e){const n=new URL("https://lexical.dev/docs/error"),i=new URLSearchParams;i.append("code",t);for(const t of e)i.append("v",t);throw n.search=i.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function T(t,e){if(t&&e&&!Array.isArray(e)&&"object"==typeof t&&"object"==typeof e){const n=t,i=e;for(const t in i)n[t]=T(n[t],i[t]);return t}return e}const A={unmarked:0,temporary:1,permanent:2,configured:3,initialized:4,built:5,registered:6,afterRegistration:7};function $(t){return t.id===A.unmarked}function P(t){return t.id===A.permanent}function k(t){return function(t){return t.id===A.temporary}(t)||I(305,String(t.id),String(A.temporary)),Object.assign(t,{id:A.permanent})}const z=new Set;class j{builder;configs;_dependency;_peerNameSet;extension;state;_signal;constructor(t,e){this.builder=t,this.extension=e,this.configs=new Set,this.state={id:A.unmarked}}mergeConfigs(){let e=this.extension.config||{};const n=this.extension.mergeConfig?this.extension.mergeConfig.bind(this.extension):t.shallowMergeConfig;for(const t of this.configs)e=n(e,t);return e}init(t){const e=this.state;P(e)||I(306,String(e.id));const n={getDependency:this.getInitDependency.bind(this),getDirectDependentNames:this.getDirectDependentNames.bind(this),getPeer:this.getInitPeer.bind(this),getPeerNameSet:this.getPeerNameSet.bind(this)},i={...n,getDependency:this.getDependency.bind(this),getInitResult:this.getInitResult.bind(this),getPeer:this.getPeer.bind(this)},o=function(t,e,n){return Object.assign(t,{config:e,id:A.configured,registerState:n})}(e,this.mergeConfigs(),n);let s;this.state=o,this.extension.init&&(s=this.extension.init(t,o.config,n)),this.state=function(t,e,n){return Object.assign(t,{id:A.initialized,initResult:e,registerState:n})}(o,s,i)}build(t){const e=this.state;let n;e.id!==A.initialized&&I(307,String(e.id),String(A.built)),this.extension.build&&(n=this.extension.build(t,e.config,e.registerState));const i={...e.registerState,getOutput:()=>n,getSignal:this.getSignal.bind(this)};this.state=function(t,e,n){return Object.assign(t,{id:A.built,output:e,registerState:n})}(e,n,i)}register(t,e){this._signal=e;const n=this.state;n.id!==A.built&&I(308,String(n.id),String(A.built));const i=this.extension.register&&this.extension.register(t,n.config,n.registerState);return this.state=function(t){return Object.assign(t,{id:A.registered})}(n),()=>{const t=this.state;t.id!==A.afterRegistration&&I(309,String(n.id),String(A.afterRegistration)),this.state=function(t){return Object.assign(t,{id:A.built})}(t),i&&i()}}afterRegistration(t){const e=this.state;let n;return e.id!==A.registered&&I(310,String(e.id),String(A.registered)),this.extension.afterRegistration&&(n=this.extension.afterRegistration(t,e.config,e.registerState)),this.state=function(t){return Object.assign(t,{id:A.afterRegistration})}(e),n}getSignal(){return void 0===this._signal&&I(311),this._signal}getInitResult(){void 0===this.extension.init&&I(312,this.extension.name);const t=this.state;return function(t){return t.id>=A.initialized}(t)||I(313,String(t.id),String(A.initialized)),t.initResult}getInitPeer(t){const e=this.builder.extensionNameMap.get(t);return e?e.getExtensionInitDependency():void 0}getExtensionInitDependency(){const t=this.state;return function(t){return t.id>=A.configured}(t)||I(314,String(t.id),String(A.configured)),{config:t.config}}getPeer(t){const e=this.builder.extensionNameMap.get(t);return e?e.getExtensionDependency():void 0}getInitDependency(t){const e=this.builder.getExtensionRep(t);return void 0===e&&I(315,this.extension.name,t.name),e.getExtensionInitDependency()}getDependency(t){const e=this.builder.getExtensionRep(t);return void 0===e&&I(315,this.extension.name,t.name),e.getExtensionDependency()}getState(){const t=this.state;return function(t){return t.id>=A.afterRegistration}(t)||I(316,String(t.id),String(A.afterRegistration)),t}getDirectDependentNames(){return this.builder.incomingEdges.get(this.extension.name)||z}getPeerNameSet(){let t=this._peerNameSet;return t||(t=new Set((this.extension.peerDependencies||[]).map((([t])=>t))),this._peerNameSet=t),t}getExtensionDependency(){if(!this._dependency){const t=this.state;(function(t){return t.id>=A.built})(t)||I(317,this.extension.name),this._dependency={config:t.config,init:t.initResult,output:t.output}}return this._dependency}}const K={tag:t.HISTORY_MERGE_TAG};function L(){const e=t.$getRoot();e.isEmpty()&&e.append(t.$createParagraphNode())}const B=t.defineExtension({config:t.safeCast({setOptions:K,updateOptions:K}),init:({$initialEditorState:t=L})=>({$initialEditorState:t,initialized:!1}),afterRegistration(e,{updateOptions:n,setOptions:i},o){const s=o.getInitResult();if(!s.initialized){s.initialized=!0;const{$initialEditorState:o}=s;if(t.$isEditorState(o))e.setEditorState(o,i);else if("function"==typeof o)e.update((()=>{o(e)}),n);else if(o&&("string"==typeof o||"object"==typeof o)){const t=e.parseEditorState(o);e.setEditorState(t,i)}}return()=>{}},name:"@lexical/extension/InitialState",nodes:[t.RootNode,t.TextNode,t.LineBreakNode,t.TabNode,t.ParagraphNode]}),U=Symbol.for("@lexical/extension/LexicalBuilder");function F(){}function H(t){throw t}function G(t){return Array.isArray(t)?t:[t]}const Y="0.36.0+prod.cjs";class W{roots;extensionNameMap;outgoingConfigEdges;incomingEdges;conflicts;_sortedExtensionReps;PACKAGE_VERSION;constructor(t){this.outgoingConfigEdges=new Map,this.incomingEdges=new Map,this.extensionNameMap=new Map,this.conflicts=new Map,this.PACKAGE_VERSION=Y,this.roots=t;for(const e of t)this.addExtension(e)}static fromExtensions(t){const e=[G(B)];for(const n of t)e.push(G(n));return new W(e)}static maybeFromEditor(t){const e=t[U];return e&&(e.PACKAGE_VERSION!==Y&&I(292,e.PACKAGE_VERSION,Y),e instanceof W||I(293)),e}static fromEditor(t){const e=W.maybeFromEditor(t);return void 0===e&&I(294),e}constructEditor(){const{$initialEditorState:e,onError:n,...i}=this.buildCreateEditorArgs(),o=Object.assign(t.createEditor({...i,...n?{onError:t=>{n(t,o)}}:{}}),{[U]:this});for(const t of this.sortedExtensionReps())t.build(o);return o}buildEditor(){let t=F;function n(){try{t()}finally{t=F}}const i=Object.assign(this.constructEditor(),{dispose:n,[Symbol.dispose]:n});return t=e.mergeRegister(this.registerEditor(i),(()=>i.setRootElement(null))),i}hasExtensionByName(t){return this.extensionNameMap.has(t)}getExtensionRep(t){const e=this.extensionNameMap.get(t.name);if(e)return e.extension!==t&&I(295,t.name),e}addEdge(t,e,n){const i=this.outgoingConfigEdges.get(t);i?i.set(e,n):this.outgoingConfigEdges.set(t,new Map([[e,n]]));const o=this.incomingEdges.get(e);o?o.add(t):this.incomingEdges.set(e,new Set([t]))}addExtension(t){void 0!==this._sortedExtensionReps&&I(296);const e=G(t),[n]=e;"string"!=typeof n.name&&I(297,typeof n.name);let i=this.extensionNameMap.get(n.name);if(void 0!==i&&i.extension!==n&&I(298,n.name),!i){i=new j(this,n),this.extensionNameMap.set(n.name,i);const t=this.conflicts.get(n.name);"string"==typeof t&&I(299,n.name,t);for(const t of n.conflictsWith||[])this.extensionNameMap.has(t)&&I(299,n.name,t),this.conflicts.set(t,n.name);for(const t of n.dependencies||[]){const e=G(t);this.addEdge(n.name,e[0].name,e.slice(1)),this.addExtension(e)}for(const[t,e]of n.peerDependencies||[])this.addEdge(n.name,t,e?[e]:[])}}sortedExtensionReps(){if(this._sortedExtensionReps)return this._sortedExtensionReps;const t=[],e=(n,i)=>{let o=n.state;if(P(o))return;const s=n.extension.name;var r;$(o)||I(300,s,i||"[unknown]"),$(r=o)||I(304,String(r.id),String(A.unmarked)),o=Object.assign(r,{id:A.temporary}),n.state=o;const a=this.outgoingConfigEdges.get(s);if(a)for(const t of a.keys()){const n=this.extensionNameMap.get(t);n&&e(n,s)}o=k(o),n.state=o,t.push(n)};for(const t of this.extensionNameMap.values())$(t.state)&&e(t);for(const e of t)for(const[t,n]of this.outgoingConfigEdges.get(e.extension.name)||[])if(n.length>0){const e=this.extensionNameMap.get(t);if(e)for(const t of n)e.configs.add(t)}for(const[t,...e]of this.roots)if(e.length>0){const n=this.extensionNameMap.get(t.name);void 0===n&&I(301,t.name);for(const t of e)n.configs.add(t)}return this._sortedExtensionReps=t,this._sortedExtensionReps}registerEditor(t){const n=this.sortedExtensionReps(),i=new AbortController,o=[()=>i.abort()],s=i.signal;for(const e of n){const n=e.register(t,s);n&&o.push(n)}for(const e of n){const n=e.afterRegistration(t);n&&o.push(n)}return e.mergeRegister(...o)}buildCreateEditorArgs(){const t={},e=new Set,n=new Map,i=new Map,o={},s={},r=this.sortedExtensionReps();for(const a of r){const{extension:r}=a;if(void 0!==r.onError&&(t.onError=r.onError),void 0!==r.disableEvents&&(t.disableEvents=r.disableEvents),void 0!==r.parentEditor&&(t.parentEditor=r.parentEditor),void 0!==r.editable&&(t.editable=r.editable),void 0!==r.namespace&&(t.namespace=r.namespace),void 0!==r.$initialEditorState&&(t.$initialEditorState=r.$initialEditorState),r.nodes)for(const t of r.nodes){if("function"!=typeof t){const e=n.get(t.replace);e&&I(302,r.name,t.replace.name,e.extension.name),n.set(t.replace,a)}e.add(t)}if(r.html){if(r.html.export)for(const[t,e]of r.html.export.entries())i.set(t,e);r.html.import&&Object.assign(o,r.html.import)}r.theme&&T(s,r.theme)}Object.keys(s).length>0&&(t.theme=s),e.size&&(t.nodes=[...e]);const a=Object.keys(o).length>0,d=i.size>0;(a||d)&&(t.html={},a&&(t.html.import=o),d&&(t.html.export=i));for(const e of r)e.init(t);return t.onError||(t.onError=H),t}}function Z(t,e){const n=W.fromEditor(t).extensionNameMap.get(e);return n?n.getExtensionDependency():void 0}const V=new Set,J=t.defineExtension({build(e,n,i){const o=i.getDependency(_).output,s=h({watchedNodeKeys:new Map}),r=D((()=>{}),(()=>b((()=>{const e=r.peek(),{watchedNodeKeys:n}=s.value;let i,a=!1;o.value.read((()=>{if(t.$getSelection())for(const[o,s]of n.entries()){if(0===s.size){n.delete(o);continue}const r=t.$getNodeByKey(o),d=r&&r.isSelected()||!1;a=a||d!==(!!e&&e.has(o)),d&&(i=i||new Set,i.add(o))}})),!a&&i&&e&&i.size===e.size||(r.value=i)}))));return{watchNodeKey:function(t){const e=E((()=>(r.value||V).has(t))),{watchedNodeKeys:n}=s.peek();let i=n.get(t);const o=void 0!==i;return i=i||new Set,i.add(e),o||(n.set(t,i),s.value={watchedNodeKeys:n}),e}}},dependencies:[_],name:"@lexical/extension/NodeSelection"}),q=t.createCommand("INSERT_HORIZONTAL_RULE_COMMAND");class X extends t.DecoratorNode{static getType(){return"horizontalrule"}static clone(t){return new X(t.__key)}static importJSON(t){return tt().updateFromJSON(t)}static importDOM(){return{hr:()=>({conversion:Q,priority:0})}}exportDOM(){return{element:document.createElement("hr")}}createDOM(t){const n=document.createElement("hr");return e.addClassNamesToElement(n,t.theme.hr),n}getTextContent(){return"\n"}isInline(){return!1}updateDOM(){return!1}}function Q(){return{node:tt()}}function tt(){return t.$create(X)}function et(t){return t instanceof X}const nt=t.defineExtension({dependencies:[_,J],name:"@lexical/extension/HorizontalRule",nodes:[X],register(n,i,s){const{watchNodeKey:r}=s.getDependency(J).output,a=h({nodeSelections:new Map}),d=n._config.theme.hrSelected??"selected";return e.mergeRegister(n.registerCommand(t.CLICK_COMMAND,(e=>{if(t.isDOMNode(e.target)){const n=t.$getNodeFromDOMNode(e.target);if(et(n))return function(e,n=!1){const i=t.$getSelection(),o=e.isSelected(),s=e.getKey();let r;n&&t.$isNodeSelection(i)?r=i:(r=t.$createNodeSelection(),t.$setSelection(r)),o?r.delete(s):r.add(s)}(n,e.shiftKey),!0}return!1}),t.COMMAND_PRIORITY_LOW),n.registerMutationListener(X,((t,e)=>{o((()=>{let e=!1;const{nodeSelections:i}=a.peek();for(const[o,s]of t.entries())if("destroyed"===s)i.delete(o),e=!0;else{const t=i.get(o),s=n.getElementByKey(o);t?t.domNode.value=s:(e=!0,i.set(o,{domNode:h(s),selectedSignal:r(o)}))}e&&(a.value={nodeSelections:i})}))})),b((()=>{const t=[];for(const{domNode:n,selectedSignal:i}of a.value.nodeSelections.values())t.push(b((()=>{const t=n.value;if(t){i.value?e.addClassNamesToElement(t,d):e.removeClassNamesFromElement(t,d)}})));return e.mergeRegister(...t)})))}});function it(n,i){return e.mergeRegister(n.registerCommand(t.KEY_TAB_COMMAND,(i=>{const o=t.$getSelection();if(!t.$isRangeSelection(o))return!1;i.preventDefault();const s=function(n){const i=n.getNodes();if(e.$filter(i,(e=>t.$isBlockElementNode(e)&&e.canIndent()?e:null)).length>0)return!0;const o=n.anchor,s=n.focus,r=s.isBefore(o)?s:o,a=r.getNode(),d=e.$getNearestBlockElementAncestorOrThrow(a);if(d.canIndent()){const e=d.getKey();let n=t.$createRangeSelection();if(n.anchor.set(e,0,"element"),n.focus.set(e,0,"element"),n=t.$normalizeSelection__EXPERIMENTAL(n),n.anchor.is(r))return!0}return!1}(o)?i.shiftKey?t.OUTDENT_CONTENT_COMMAND:t.INDENT_CONTENT_COMMAND:t.INSERT_TAB_COMMAND;return n.dispatchCommand(s,void 0)}),t.COMMAND_PRIORITY_EDITOR),n.registerCommand(t.INDENT_CONTENT_COMMAND,(()=>{const n="number"==typeof i?i:i?i.peek():null;if(null==n)return!1;const o=t.$getSelection();if(!t.$isRangeSelection(o))return!1;const s=o.getNodes().map((t=>e.$getNearestBlockElementAncestorOrThrow(t).getIndent()));return Math.max(...s)+1>=n}),t.COMMAND_PRIORITY_CRITICAL))}const ot=t.defineExtension({build:(t,e,n)=>R(e),config:t.safeCast({disabled:!1,maxIndent:null}),name:"@lexical/extension/TabIndentation",register(t,e,n){const{disabled:i,maxIndent:o}=n.getOutput();return b((()=>{if(!i.value)return it(t,o)}))}});exports.configExtension=t.configExtension,exports.declarePeerDependency=t.declarePeerDependency,exports.defineExtension=t.defineExtension,exports.safeCast=t.safeCast,exports.shallowMergeConfig=t.shallowMergeConfig,exports.$createHorizontalRuleNode=tt,exports.$isHorizontalRuleNode=et,exports.AutoFocusExtension=O,exports.ClearEditorExtension=M,exports.EditorStateExtension=_,exports.HorizontalRuleExtension=nt,exports.HorizontalRuleNode=X,exports.INSERT_HORIZONTAL_RULE_COMMAND=q,exports.InitialStateExtension=B,exports.LexicalBuilder=W,exports.NodeSelectionExtension=J,exports.TabIndentationExtension=ot,exports.batch=o,exports.buildEditorFromExtensions=function(...t){return W.fromExtensions(t).buildEditor()},exports.computed=E,exports.effect=b,exports.getExtensionDependencyFromEditor=function(t,e){const n=W.fromEditor(t).getExtensionRep(e);return void 0===n&&I(303,e.name),n.getExtensionDependency()},exports.getKnownTypesAndNodes=function(t){const e=new Set,n=new Set;for(const i of t.nodes??[]){const t="function"==typeof i?i:i.replace;e.add(t.getType()),n.add(t)}return{nodes:n,types:e}},exports.getPeerDependencyFromEditor=Z,exports.getPeerDependencyFromEditorOrThrow=function(t,e){const n=Z(t,e);return void 0===n&&I(291,e),n},exports.namedSignals=R,exports.registerClearEditor=C,exports.registerTabIndentation=it,exports.signal=h,exports.untracked=a,exports.watchedSignal=D;
9
+ "use strict";var t=require("lexical"),e=require("@lexical/utils");const n=Symbol.for("preact-signals");function i(){if(d>1)return void d--;let t,e=!1;for(;void 0!==r;){let n=r;for(r=void 0,c++;void 0!==n;){const i=n.o;if(n.o=void 0,n.f&=-3,!(8&n.f)&&g(n))try{n.c()}catch(n){e||(t=n,e=!0)}n=i}}if(c=0,d--,e)throw t}function o(t){if(d>0)return t();d++;try{return t()}finally{i()}}let s,r;function a(t){const e=s;s=void 0;try{return t()}finally{s=e}}let d=0,c=0,u=0;function f(t){if(void 0===s)return;let e=t.n;return void 0===e||e.t!==s?(e={i:0,S:t,p:s.s,n:void 0,t:s,e:void 0,x:void 0,r:e},void 0!==s.s&&(s.s.n=e),s.s=e,t.n=e,32&s.f&&t.S(e),e):-1===e.i?(e.i=0,void 0!==e.n&&(e.n.p=e.p,void 0!==e.p&&(e.p.n=e.n),e.p=s.s,e.n=void 0,s.s.n=e,s.s=e),e):void 0}function l(t,e){this.v=t,this.i=0,this.n=void 0,this.t=void 0,this.W=null==e?void 0:e.watched,this.Z=null==e?void 0:e.unwatched,this.name=null==e?void 0:e.name}function h(t,e){return new l(t,e)}function g(t){for(let e=t.s;void 0!==e;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return!0;return!1}function p(t){for(let e=t.s;void 0!==e;e=e.n){const n=e.S.n;if(void 0!==n&&(e.r=n),e.S.n=e,e.i=-1,void 0===e.n){t.s=e;break}}}function m(t){let e,n=t.s;for(;void 0!==n;){const t=n.p;-1===n.i?(n.S.U(n),void 0!==t&&(t.n=n.n),void 0!==n.n&&(n.n.p=t)):e=n,n.S.n=n.r,void 0!==n.r&&(n.r=void 0),n=t}t.s=e}function x(t,e){l.call(this,void 0),this.x=t,this.s=void 0,this.g=u-1,this.f=4,this.W=null==e?void 0:e.watched,this.Z=null==e?void 0:e.unwatched,this.name=null==e?void 0:e.name}function E(t,e){return new x(t,e)}function v(t){const e=t.u;if(t.u=void 0,"function"==typeof e){d++;const n=s;s=void 0;try{e()}catch(e){throw t.f&=-2,t.f|=8,S(t),e}finally{s=n,i()}}}function S(t){for(let e=t.s;void 0!==e;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,v(t)}function y(t){if(s!==this)throw new Error("Out-of-order effect");m(this),s=t,this.f&=-2,8&this.f&&S(this),i()}function N(t,e){this.x=t,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=null==e?void 0:e.name}function b(t,e){const n=new N(t,e);try{n.c()}catch(t){throw n.d(),t}const i=n.d.bind(n);return i[Symbol.dispose]=i,i}function R(t,e={}){const n={};for(const i in t){const o=e[i],s=h(void 0===o?t[i]:o);n[i]=s}return n}l.prototype.brand=n,l.prototype.h=function(){return!0},l.prototype.S=function(t){const e=this.t;e!==t&&void 0===t.e&&(t.x=e,this.t=t,void 0!==e?e.e=t:a((()=>{var t;null==(t=this.W)||t.call(this)})))},l.prototype.U=function(t){if(void 0!==this.t){const e=t.e,n=t.x;void 0!==e&&(e.x=n,t.e=void 0),void 0!==n&&(n.e=e,t.x=void 0),t===this.t&&(this.t=n,void 0===n&&a((()=>{var t;null==(t=this.Z)||t.call(this)})))}},l.prototype.subscribe=function(t){return b((()=>{const e=this.value,n=s;s=void 0;try{t(e)}finally{s=n}}),{name:"sub"})},l.prototype.valueOf=function(){return this.value},l.prototype.toString=function(){return this.value+""},l.prototype.toJSON=function(){return this.value},l.prototype.peek=function(){const t=s;s=void 0;try{return this.value}finally{s=t}},Object.defineProperty(l.prototype,"value",{get(){const t=f(this);return void 0!==t&&(t.i=this.i),this.v},set(t){if(t!==this.v){if(c>100)throw new Error("Cycle detected");this.v=t,this.i++,u++,d++;try{for(let t=this.t;void 0!==t;t=t.x)t.t.N()}finally{i()}}}}),x.prototype=new l,x.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if(32==(36&this.f))return!0;if(this.f&=-5,this.g===u)return!0;if(this.g=u,this.f|=1,this.i>0&&!g(this))return this.f&=-2,!0;const t=s;try{p(this),s=this;const t=this.x();(16&this.f||this.v!==t||0===this.i)&&(this.v=t,this.f&=-17,this.i++)}catch(t){this.v=t,this.f|=16,this.i++}return s=t,m(this),this.f&=-2,!0},x.prototype.S=function(t){if(void 0===this.t){this.f|=36;for(let t=this.s;void 0!==t;t=t.n)t.S.S(t)}l.prototype.S.call(this,t)},x.prototype.U=function(t){if(void 0!==this.t&&(l.prototype.U.call(this,t),void 0===this.t)){this.f&=-33;for(let t=this.s;void 0!==t;t=t.n)t.S.U(t)}},x.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(let t=this.t;void 0!==t;t=t.x)t.t.N()}},Object.defineProperty(x.prototype,"value",{get(){if(1&this.f)throw new Error("Cycle detected");const t=f(this);if(this.h(),void 0!==t&&(t.i=this.i),16&this.f)throw this.v;return this.v}}),N.prototype.c=function(){const t=this.S();try{if(8&this.f)return;if(void 0===this.x)return;const t=this.x();"function"==typeof t&&(this.u=t)}finally{t()}},N.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,v(this),p(this),d++;const t=s;return s=this,y.bind(this,t)},N.prototype.N=function(){2&this.f||(this.f|=2,this.o=r,r=this)},N.prototype.d=function(){this.f|=8,1&this.f||S(this)},N.prototype.dispose=function(){this.d()};const O=t.defineExtension({build:(t,e,n)=>R(e),config:t.safeCast({defaultSelection:"rootEnd",disabled:!1}),name:"@lexical/extension/AutoFocus",register(t,e,n){const i=n.getOutput();return b((()=>i.disabled.value?void 0:t.registerRootListener((e=>{t.focus((()=>{const t=document.activeElement;null===e||null!==t&&e.contains(t)||e.focus({preventScroll:!0})}),{defaultSelection:i.defaultSelection.peek()})}))))}});function w(){const e=t.$getRoot(),n=t.$getSelection(),i=t.$createParagraphNode();e.clear(),e.append(i),null!==n&&i.select(),t.$isRangeSelection(n)&&(n.format=0)}function C(e,n=w){return e.registerCommand(t.CLEAR_EDITOR_COMMAND,(t=>(e.update(n),!0)),t.COMMAND_PRIORITY_EDITOR)}const M=t.defineExtension({build:(t,e,n)=>R(e),config:t.safeCast({$onClear:w}),name:"@lexical/extension/ClearEditor",register(t,e,n){const{$onClear:i}=n.getOutput();return b((()=>C(t,i.value)))}});function D(t,e){let n;return h(t(),{unwatched(){n&&(n(),n=void 0)},watched(){this.value=t(),n=e(this)}})}const _=t.defineExtension({build:t=>D((()=>t.getEditorState()),(e=>t.registerUpdateListener((t=>{e.value=t.editorState})))),name:"@lexical/extension/EditorState"});function I(t,...e){const n=new URL("https://lexical.dev/docs/error"),i=new URLSearchParams;i.append("code",t);for(const t of e)i.append("v",t);throw n.search=i.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function T(t,e){if(t&&e&&!Array.isArray(e)&&"object"==typeof t&&"object"==typeof e){const n=t,i=e;for(const t in i)n[t]=T(n[t],i[t]);return t}return e}const A={unmarked:0,temporary:1,permanent:2,configured:3,initialized:4,built:5,registered:6,afterRegistration:7};function $(t){return t.id===A.unmarked}function P(t){return t.id===A.permanent}function k(t){return function(t){return t.id===A.temporary}(t)||I(305,String(t.id),String(A.temporary)),Object.assign(t,{id:A.permanent})}const z=new Set;class j{builder;configs;_dependency;_peerNameSet;extension;state;_signal;constructor(t,e){this.builder=t,this.extension=e,this.configs=new Set,this.state={id:A.unmarked}}mergeConfigs(){let e=this.extension.config||{};const n=this.extension.mergeConfig?this.extension.mergeConfig.bind(this.extension):t.shallowMergeConfig;for(const t of this.configs)e=n(e,t);return e}init(t){const e=this.state;P(e)||I(306,String(e.id));const n={getDependency:this.getInitDependency.bind(this),getDirectDependentNames:this.getDirectDependentNames.bind(this),getPeer:this.getInitPeer.bind(this),getPeerNameSet:this.getPeerNameSet.bind(this)},i={...n,getDependency:this.getDependency.bind(this),getInitResult:this.getInitResult.bind(this),getPeer:this.getPeer.bind(this)},o=function(t,e,n){return Object.assign(t,{config:e,id:A.configured,registerState:n})}(e,this.mergeConfigs(),n);let s;this.state=o,this.extension.init&&(s=this.extension.init(t,o.config,n)),this.state=function(t,e,n){return Object.assign(t,{id:A.initialized,initResult:e,registerState:n})}(o,s,i)}build(t){const e=this.state;let n;e.id!==A.initialized&&I(307,String(e.id),String(A.built)),this.extension.build&&(n=this.extension.build(t,e.config,e.registerState));const i={...e.registerState,getOutput:()=>n,getSignal:this.getSignal.bind(this)};this.state=function(t,e,n){return Object.assign(t,{id:A.built,output:e,registerState:n})}(e,n,i)}register(t,e){this._signal=e;const n=this.state;n.id!==A.built&&I(308,String(n.id),String(A.built));const i=this.extension.register&&this.extension.register(t,n.config,n.registerState);return this.state=function(t){return Object.assign(t,{id:A.registered})}(n),()=>{const t=this.state;t.id!==A.afterRegistration&&I(309,String(n.id),String(A.afterRegistration)),this.state=function(t){return Object.assign(t,{id:A.built})}(t),i&&i()}}afterRegistration(t){const e=this.state;let n;return e.id!==A.registered&&I(310,String(e.id),String(A.registered)),this.extension.afterRegistration&&(n=this.extension.afterRegistration(t,e.config,e.registerState)),this.state=function(t){return Object.assign(t,{id:A.afterRegistration})}(e),n}getSignal(){return void 0===this._signal&&I(311),this._signal}getInitResult(){void 0===this.extension.init&&I(312,this.extension.name);const t=this.state;return function(t){return t.id>=A.initialized}(t)||I(313,String(t.id),String(A.initialized)),t.initResult}getInitPeer(t){const e=this.builder.extensionNameMap.get(t);return e?e.getExtensionInitDependency():void 0}getExtensionInitDependency(){const t=this.state;return function(t){return t.id>=A.configured}(t)||I(314,String(t.id),String(A.configured)),{config:t.config}}getPeer(t){const e=this.builder.extensionNameMap.get(t);return e?e.getExtensionDependency():void 0}getInitDependency(t){const e=this.builder.getExtensionRep(t);return void 0===e&&I(315,this.extension.name,t.name),e.getExtensionInitDependency()}getDependency(t){const e=this.builder.getExtensionRep(t);return void 0===e&&I(315,this.extension.name,t.name),e.getExtensionDependency()}getState(){const t=this.state;return function(t){return t.id>=A.afterRegistration}(t)||I(316,String(t.id),String(A.afterRegistration)),t}getDirectDependentNames(){return this.builder.incomingEdges.get(this.extension.name)||z}getPeerNameSet(){let t=this._peerNameSet;return t||(t=new Set((this.extension.peerDependencies||[]).map((([t])=>t))),this._peerNameSet=t),t}getExtensionDependency(){if(!this._dependency){const t=this.state;(function(t){return t.id>=A.built})(t)||I(317,this.extension.name),this._dependency={config:t.config,init:t.initResult,output:t.output}}return this._dependency}}const K={tag:t.HISTORY_MERGE_TAG};function L(){const e=t.$getRoot();e.isEmpty()&&e.append(t.$createParagraphNode())}const B=t.defineExtension({config:t.safeCast({setOptions:K,updateOptions:K}),init:({$initialEditorState:t=L})=>({$initialEditorState:t,initialized:!1}),afterRegistration(e,{updateOptions:n,setOptions:i},o){const s=o.getInitResult();if(!s.initialized){s.initialized=!0;const{$initialEditorState:o}=s;if(t.$isEditorState(o))e.setEditorState(o,i);else if("function"==typeof o)e.update((()=>{o(e)}),n);else if(o&&("string"==typeof o||"object"==typeof o)){const t=e.parseEditorState(o);e.setEditorState(t,i)}}return()=>{}},name:"@lexical/extension/InitialState",nodes:[t.RootNode,t.TextNode,t.LineBreakNode,t.TabNode,t.ParagraphNode]}),U=Symbol.for("@lexical/extension/LexicalBuilder");function F(){}function H(t){throw t}function G(t){return Array.isArray(t)?t:[t]}const Y="0.36.1+prod.cjs";class W{roots;extensionNameMap;outgoingConfigEdges;incomingEdges;conflicts;_sortedExtensionReps;PACKAGE_VERSION;constructor(t){this.outgoingConfigEdges=new Map,this.incomingEdges=new Map,this.extensionNameMap=new Map,this.conflicts=new Map,this.PACKAGE_VERSION=Y,this.roots=t;for(const e of t)this.addExtension(e)}static fromExtensions(t){const e=[G(B)];for(const n of t)e.push(G(n));return new W(e)}static maybeFromEditor(t){const e=t[U];return e&&(e.PACKAGE_VERSION!==Y&&I(292,e.PACKAGE_VERSION,Y),e instanceof W||I(293)),e}static fromEditor(t){const e=W.maybeFromEditor(t);return void 0===e&&I(294),e}constructEditor(){const{$initialEditorState:e,onError:n,...i}=this.buildCreateEditorArgs(),o=Object.assign(t.createEditor({...i,...n?{onError:t=>{n(t,o)}}:{}}),{[U]:this});for(const t of this.sortedExtensionReps())t.build(o);return o}buildEditor(){let t=F;function n(){try{t()}finally{t=F}}const i=Object.assign(this.constructEditor(),{dispose:n,[Symbol.dispose]:n});return t=e.mergeRegister(this.registerEditor(i),(()=>i.setRootElement(null))),i}hasExtensionByName(t){return this.extensionNameMap.has(t)}getExtensionRep(t){const e=this.extensionNameMap.get(t.name);if(e)return e.extension!==t&&I(295,t.name),e}addEdge(t,e,n){const i=this.outgoingConfigEdges.get(t);i?i.set(e,n):this.outgoingConfigEdges.set(t,new Map([[e,n]]));const o=this.incomingEdges.get(e);o?o.add(t):this.incomingEdges.set(e,new Set([t]))}addExtension(t){void 0!==this._sortedExtensionReps&&I(296);const e=G(t),[n]=e;"string"!=typeof n.name&&I(297,typeof n.name);let i=this.extensionNameMap.get(n.name);if(void 0!==i&&i.extension!==n&&I(298,n.name),!i){i=new j(this,n),this.extensionNameMap.set(n.name,i);const t=this.conflicts.get(n.name);"string"==typeof t&&I(299,n.name,t);for(const t of n.conflictsWith||[])this.extensionNameMap.has(t)&&I(299,n.name,t),this.conflicts.set(t,n.name);for(const t of n.dependencies||[]){const e=G(t);this.addEdge(n.name,e[0].name,e.slice(1)),this.addExtension(e)}for(const[t,e]of n.peerDependencies||[])this.addEdge(n.name,t,e?[e]:[])}}sortedExtensionReps(){if(this._sortedExtensionReps)return this._sortedExtensionReps;const t=[],e=(n,i)=>{let o=n.state;if(P(o))return;const s=n.extension.name;var r;$(o)||I(300,s,i||"[unknown]"),$(r=o)||I(304,String(r.id),String(A.unmarked)),o=Object.assign(r,{id:A.temporary}),n.state=o;const a=this.outgoingConfigEdges.get(s);if(a)for(const t of a.keys()){const n=this.extensionNameMap.get(t);n&&e(n,s)}o=k(o),n.state=o,t.push(n)};for(const t of this.extensionNameMap.values())$(t.state)&&e(t);for(const e of t)for(const[t,n]of this.outgoingConfigEdges.get(e.extension.name)||[])if(n.length>0){const e=this.extensionNameMap.get(t);if(e)for(const t of n)e.configs.add(t)}for(const[t,...e]of this.roots)if(e.length>0){const n=this.extensionNameMap.get(t.name);void 0===n&&I(301,t.name);for(const t of e)n.configs.add(t)}return this._sortedExtensionReps=t,this._sortedExtensionReps}registerEditor(t){const n=this.sortedExtensionReps(),i=new AbortController,o=[()=>i.abort()],s=i.signal;for(const e of n){const n=e.register(t,s);n&&o.push(n)}for(const e of n){const n=e.afterRegistration(t);n&&o.push(n)}return e.mergeRegister(...o)}buildCreateEditorArgs(){const t={},e=new Set,n=new Map,i=new Map,o={},s={},r=this.sortedExtensionReps();for(const a of r){const{extension:r}=a;if(void 0!==r.onError&&(t.onError=r.onError),void 0!==r.disableEvents&&(t.disableEvents=r.disableEvents),void 0!==r.parentEditor&&(t.parentEditor=r.parentEditor),void 0!==r.editable&&(t.editable=r.editable),void 0!==r.namespace&&(t.namespace=r.namespace),void 0!==r.$initialEditorState&&(t.$initialEditorState=r.$initialEditorState),r.nodes)for(const t of r.nodes){if("function"!=typeof t){const e=n.get(t.replace);e&&I(302,r.name,t.replace.name,e.extension.name),n.set(t.replace,a)}e.add(t)}if(r.html){if(r.html.export)for(const[t,e]of r.html.export.entries())i.set(t,e);r.html.import&&Object.assign(o,r.html.import)}r.theme&&T(s,r.theme)}Object.keys(s).length>0&&(t.theme=s),e.size&&(t.nodes=[...e]);const a=Object.keys(o).length>0,d=i.size>0;(a||d)&&(t.html={},a&&(t.html.import=o),d&&(t.html.export=i));for(const e of r)e.init(t);return t.onError||(t.onError=H),t}}function Z(t,e){const n=W.fromEditor(t).extensionNameMap.get(e);return n?n.getExtensionDependency():void 0}const V=new Set,J=t.defineExtension({build(e,n,i){const o=i.getDependency(_).output,s=h({watchedNodeKeys:new Map}),r=D((()=>{}),(()=>b((()=>{const e=r.peek(),{watchedNodeKeys:n}=s.value;let i,a=!1;o.value.read((()=>{if(t.$getSelection())for(const[o,s]of n.entries()){if(0===s.size){n.delete(o);continue}const r=t.$getNodeByKey(o),d=r&&r.isSelected()||!1;a=a||d!==(!!e&&e.has(o)),d&&(i=i||new Set,i.add(o))}})),!a&&i&&e&&i.size===e.size||(r.value=i)}))));return{watchNodeKey:function(t){const e=E((()=>(r.value||V).has(t))),{watchedNodeKeys:n}=s.peek();let i=n.get(t);const o=void 0!==i;return i=i||new Set,i.add(e),o||(n.set(t,i),s.value={watchedNodeKeys:n}),e}}},dependencies:[_],name:"@lexical/extension/NodeSelection"}),q=t.createCommand("INSERT_HORIZONTAL_RULE_COMMAND");class X extends t.DecoratorNode{static getType(){return"horizontalrule"}static clone(t){return new X(t.__key)}static importJSON(t){return tt().updateFromJSON(t)}static importDOM(){return{hr:()=>({conversion:Q,priority:0})}}exportDOM(){return{element:document.createElement("hr")}}createDOM(t){const n=document.createElement("hr");return e.addClassNamesToElement(n,t.theme.hr),n}getTextContent(){return"\n"}isInline(){return!1}updateDOM(){return!1}}function Q(){return{node:tt()}}function tt(){return t.$create(X)}function et(t){return t instanceof X}const nt=t.defineExtension({dependencies:[_,J],name:"@lexical/extension/HorizontalRule",nodes:[X],register(n,i,s){const{watchNodeKey:r}=s.getDependency(J).output,a=h({nodeSelections:new Map}),d=n._config.theme.hrSelected??"selected";return e.mergeRegister(n.registerCommand(t.CLICK_COMMAND,(e=>{if(t.isDOMNode(e.target)){const n=t.$getNodeFromDOMNode(e.target);if(et(n))return function(e,n=!1){const i=t.$getSelection(),o=e.isSelected(),s=e.getKey();let r;n&&t.$isNodeSelection(i)?r=i:(r=t.$createNodeSelection(),t.$setSelection(r)),o?r.delete(s):r.add(s)}(n,e.shiftKey),!0}return!1}),t.COMMAND_PRIORITY_LOW),n.registerMutationListener(X,((t,e)=>{o((()=>{let e=!1;const{nodeSelections:i}=a.peek();for(const[o,s]of t.entries())if("destroyed"===s)i.delete(o),e=!0;else{const t=i.get(o),s=n.getElementByKey(o);t?t.domNode.value=s:(e=!0,i.set(o,{domNode:h(s),selectedSignal:r(o)}))}e&&(a.value={nodeSelections:i})}))})),b((()=>{const t=[];for(const{domNode:n,selectedSignal:i}of a.value.nodeSelections.values())t.push(b((()=>{const t=n.value;if(t){i.value?e.addClassNamesToElement(t,d):e.removeClassNamesFromElement(t,d)}})));return e.mergeRegister(...t)})))}});function it(n,i){return e.mergeRegister(n.registerCommand(t.KEY_TAB_COMMAND,(i=>{const o=t.$getSelection();if(!t.$isRangeSelection(o))return!1;i.preventDefault();const s=function(n){const i=n.getNodes();if(e.$filter(i,(e=>t.$isBlockElementNode(e)&&e.canIndent()?e:null)).length>0)return!0;const o=n.anchor,s=n.focus,r=s.isBefore(o)?s:o,a=r.getNode(),d=e.$getNearestBlockElementAncestorOrThrow(a);if(d.canIndent()){const e=d.getKey();let n=t.$createRangeSelection();if(n.anchor.set(e,0,"element"),n.focus.set(e,0,"element"),n=t.$normalizeSelection__EXPERIMENTAL(n),n.anchor.is(r))return!0}return!1}(o)?i.shiftKey?t.OUTDENT_CONTENT_COMMAND:t.INDENT_CONTENT_COMMAND:t.INSERT_TAB_COMMAND;return n.dispatchCommand(s,void 0)}),t.COMMAND_PRIORITY_EDITOR),n.registerCommand(t.INDENT_CONTENT_COMMAND,(()=>{const n="number"==typeof i?i:i?i.peek():null;if(null==n)return!1;const o=t.$getSelection();if(!t.$isRangeSelection(o))return!1;const s=o.getNodes().map((t=>e.$getNearestBlockElementAncestorOrThrow(t).getIndent()));return Math.max(...s)+1>=n}),t.COMMAND_PRIORITY_CRITICAL))}const ot=t.defineExtension({build:(t,e,n)=>R(e),config:t.safeCast({disabled:!1,maxIndent:null}),name:"@lexical/extension/TabIndentation",register(t,e,n){const{disabled:i,maxIndent:o}=n.getOutput();return b((()=>{if(!i.value)return it(t,o)}))}});exports.configExtension=t.configExtension,exports.declarePeerDependency=t.declarePeerDependency,exports.defineExtension=t.defineExtension,exports.safeCast=t.safeCast,exports.shallowMergeConfig=t.shallowMergeConfig,exports.$createHorizontalRuleNode=tt,exports.$isHorizontalRuleNode=et,exports.AutoFocusExtension=O,exports.ClearEditorExtension=M,exports.EditorStateExtension=_,exports.HorizontalRuleExtension=nt,exports.HorizontalRuleNode=X,exports.INSERT_HORIZONTAL_RULE_COMMAND=q,exports.InitialStateExtension=B,exports.LexicalBuilder=W,exports.NodeSelectionExtension=J,exports.TabIndentationExtension=ot,exports.batch=o,exports.buildEditorFromExtensions=function(...t){return W.fromExtensions(t).buildEditor()},exports.computed=E,exports.effect=b,exports.getExtensionDependencyFromEditor=function(t,e){const n=W.fromEditor(t).getExtensionRep(e);return void 0===n&&I(303,e.name),n.getExtensionDependency()},exports.getKnownTypesAndNodes=function(t){const e=new Set,n=new Set;for(const i of t.nodes??[]){const t="function"==typeof i?i:i.replace;e.add(t.getType()),n.add(t)}return{nodes:n,types:e}},exports.getPeerDependencyFromEditor=Z,exports.getPeerDependencyFromEditorOrThrow=function(t,e){const n=Z(t,e);return void 0===n&&I(291,e),n},exports.namedSignals=R,exports.registerClearEditor=C,exports.registerTabIndentation=it,exports.signal=h,exports.untracked=a,exports.watchedSignal=D;
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- import{defineExtension as t,safeCast as e,CLEAR_EDITOR_COMMAND as n,COMMAND_PRIORITY_EDITOR as i,$getRoot as o,$getSelection as s,$createParagraphNode as r,$isRangeSelection as c,shallowMergeConfig as d,RootNode as a,TextNode as u,LineBreakNode as f,TabNode as h,ParagraphNode as l,$isEditorState as g,HISTORY_MERGE_TAG as p,createEditor as m,$getNodeByKey as v,createCommand as y,$create as x,CLICK_COMMAND as S,isDOMNode as E,$getNodeFromDOMNode as b,COMMAND_PRIORITY_LOW as w,DecoratorNode as N,$isNodeSelection as R,$createNodeSelection as O,$setSelection as M,KEY_TAB_COMMAND as C,OUTDENT_CONTENT_COMMAND as D,INDENT_CONTENT_COMMAND as _,INSERT_TAB_COMMAND as I,COMMAND_PRIORITY_CRITICAL as j,$isBlockElementNode as A,$createRangeSelection as k,$normalizeSelection__EXPERIMENTAL as P}from"lexical";export{configExtension,declarePeerDependency,defineExtension,safeCast,shallowMergeConfig}from"lexical";import{mergeRegister as z,addClassNamesToElement as K,removeClassNamesFromElement as $,$getNearestBlockElementAncestorOrThrow as U,$filter as L}from"@lexical/utils";const T=Symbol.for("preact-signals");function B(){if(Z>1)return void Z--;let t,e=!1;for(;void 0!==V;){let n=V;for(V=void 0,J++;void 0!==n;){const i=n.o;if(n.o=void 0,n.f&=-3,!(8&n.f)&&Y(n))try{n.c()}catch(n){e||(t=n,e=!0)}n=i}}if(J=0,Z--,e)throw t}function F(t){if(Z>0)return t();Z++;try{return t()}finally{B()}}let G,V;function W(t){const e=G;G=void 0;try{return t()}finally{G=e}}let Z=0,J=0,H=0;function q(t){if(void 0===G)return;let e=t.n;return void 0===e||e.t!==G?(e={i:0,S:t,p:G.s,n:void 0,t:G,e:void 0,x:void 0,r:e},void 0!==G.s&&(G.s.n=e),G.s=e,t.n=e,32&G.f&&t.S(e),e):-1===e.i?(e.i=0,void 0!==e.n&&(e.n.p=e.p,void 0!==e.p&&(e.p.n=e.n),e.p=G.s,e.n=void 0,G.s.n=e,G.s=e),e):void 0}function Q(t,e){this.v=t,this.i=0,this.n=void 0,this.t=void 0,this.W=null==e?void 0:e.watched,this.Z=null==e?void 0:e.unwatched,this.name=null==e?void 0:e.name}function X(t,e){return new Q(t,e)}function Y(t){for(let e=t.s;void 0!==e;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return!0;return!1}function tt(t){for(let e=t.s;void 0!==e;e=e.n){const n=e.S.n;if(void 0!==n&&(e.r=n),e.S.n=e,e.i=-1,void 0===e.n){t.s=e;break}}}function et(t){let e,n=t.s;for(;void 0!==n;){const t=n.p;-1===n.i?(n.S.U(n),void 0!==t&&(t.n=n.n),void 0!==n.n&&(n.n.p=t)):e=n,n.S.n=n.r,void 0!==n.r&&(n.r=void 0),n=t}t.s=e}function nt(t,e){Q.call(this,void 0),this.x=t,this.s=void 0,this.g=H-1,this.f=4,this.W=null==e?void 0:e.watched,this.Z=null==e?void 0:e.unwatched,this.name=null==e?void 0:e.name}function it(t,e){return new nt(t,e)}function ot(t){const e=t.u;if(t.u=void 0,"function"==typeof e){Z++;const n=G;G=void 0;try{e()}catch(e){throw t.f&=-2,t.f|=8,st(t),e}finally{G=n,B()}}}function st(t){for(let e=t.s;void 0!==e;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,ot(t)}function rt(t){if(G!==this)throw new Error("Out-of-order effect");et(this),G=t,this.f&=-2,8&this.f&&st(this),B()}function ct(t,e){this.x=t,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=null==e?void 0:e.name}function dt(t,e){const n=new ct(t,e);try{n.c()}catch(t){throw n.d(),t}const i=n.d.bind(n);return i[Symbol.dispose]=i,i}function at(t,e={}){const n={};for(const i in t){const o=e[i],s=X(void 0===o?t[i]:o);n[i]=s}return n}Q.prototype.brand=T,Q.prototype.h=function(){return!0},Q.prototype.S=function(t){const e=this.t;e!==t&&void 0===t.e&&(t.x=e,this.t=t,void 0!==e?e.e=t:W((()=>{var t;null==(t=this.W)||t.call(this)})))},Q.prototype.U=function(t){if(void 0!==this.t){const e=t.e,n=t.x;void 0!==e&&(e.x=n,t.e=void 0),void 0!==n&&(n.e=e,t.x=void 0),t===this.t&&(this.t=n,void 0===n&&W((()=>{var t;null==(t=this.Z)||t.call(this)})))}},Q.prototype.subscribe=function(t){return dt((()=>{const e=this.value,n=G;G=void 0;try{t(e)}finally{G=n}}),{name:"sub"})},Q.prototype.valueOf=function(){return this.value},Q.prototype.toString=function(){return this.value+""},Q.prototype.toJSON=function(){return this.value},Q.prototype.peek=function(){const t=G;G=void 0;try{return this.value}finally{G=t}},Object.defineProperty(Q.prototype,"value",{get(){const t=q(this);return void 0!==t&&(t.i=this.i),this.v},set(t){if(t!==this.v){if(J>100)throw new Error("Cycle detected");this.v=t,this.i++,H++,Z++;try{for(let t=this.t;void 0!==t;t=t.x)t.t.N()}finally{B()}}}}),nt.prototype=new Q,nt.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if(32==(36&this.f))return!0;if(this.f&=-5,this.g===H)return!0;if(this.g=H,this.f|=1,this.i>0&&!Y(this))return this.f&=-2,!0;const t=G;try{tt(this),G=this;const t=this.x();(16&this.f||this.v!==t||0===this.i)&&(this.v=t,this.f&=-17,this.i++)}catch(t){this.v=t,this.f|=16,this.i++}return G=t,et(this),this.f&=-2,!0},nt.prototype.S=function(t){if(void 0===this.t){this.f|=36;for(let t=this.s;void 0!==t;t=t.n)t.S.S(t)}Q.prototype.S.call(this,t)},nt.prototype.U=function(t){if(void 0!==this.t&&(Q.prototype.U.call(this,t),void 0===this.t)){this.f&=-33;for(let t=this.s;void 0!==t;t=t.n)t.S.U(t)}},nt.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(let t=this.t;void 0!==t;t=t.x)t.t.N()}},Object.defineProperty(nt.prototype,"value",{get(){if(1&this.f)throw new Error("Cycle detected");const t=q(this);if(this.h(),void 0!==t&&(t.i=this.i),16&this.f)throw this.v;return this.v}}),ct.prototype.c=function(){const t=this.S();try{if(8&this.f)return;if(void 0===this.x)return;const t=this.x();"function"==typeof t&&(this.u=t)}finally{t()}},ct.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,ot(this),tt(this),Z++;const t=G;return G=this,rt.bind(this,t)},ct.prototype.N=function(){2&this.f||(this.f|=2,this.o=V,V=this)},ct.prototype.d=function(){this.f|=8,1&this.f||st(this)},ct.prototype.dispose=function(){this.d()};const ut=t({build:(t,e,n)=>at(e),config:e({defaultSelection:"rootEnd",disabled:!1}),name:"@lexical/extension/AutoFocus",register(t,e,n){const i=n.getOutput();return dt((()=>i.disabled.value?void 0:t.registerRootListener((e=>{t.focus((()=>{const t=document.activeElement;null===e||null!==t&&e.contains(t)||e.focus({preventScroll:!0})}),{defaultSelection:i.defaultSelection.peek()})}))))}});function ft(){const t=o(),e=s(),n=r();t.clear(),t.append(n),null!==e&&n.select(),c(e)&&(e.format=0)}function ht(t,e=ft){return t.registerCommand(n,(n=>(t.update(e),!0)),i)}const lt=t({build:(t,e,n)=>at(e),config:e({$onClear:ft}),name:"@lexical/extension/ClearEditor",register(t,e,n){const{$onClear:i}=n.getOutput();return dt((()=>ht(t,i.value)))}});function gt(t){const e=new Set,n=new Set;for(const i of t.nodes??[]){const t="function"==typeof i?i:i.replace;e.add(t.getType()),n.add(t)}return{nodes:n,types:e}}function pt(t,e){let n;return X(t(),{unwatched(){n&&(n(),n=void 0)},watched(){this.value=t(),n=e(this)}})}const mt=t({build:t=>pt((()=>t.getEditorState()),(e=>t.registerUpdateListener((t=>{e.value=t.editorState})))),name:"@lexical/extension/EditorState"});function vt(t,...e){const n=new URL("https://lexical.dev/docs/error"),i=new URLSearchParams;i.append("code",t);for(const t of e)i.append("v",t);throw n.search=i.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function yt(t,e){if(t&&e&&!Array.isArray(e)&&"object"==typeof t&&"object"==typeof e){const n=t,i=e;for(const t in i)n[t]=yt(n[t],i[t]);return t}return e}const xt={unmarked:0,temporary:1,permanent:2,configured:3,initialized:4,built:5,registered:6,afterRegistration:7};function St(t){return t.id===xt.unmarked}function Et(t){return t.id===xt.permanent}function bt(t){return function(t){return t.id===xt.temporary}(t)||vt(305,String(t.id),String(xt.temporary)),Object.assign(t,{id:xt.permanent})}const wt=new Set;class Nt{builder;configs;_dependency;_peerNameSet;extension;state;_signal;constructor(t,e){this.builder=t,this.extension=e,this.configs=new Set,this.state={id:xt.unmarked}}mergeConfigs(){let t=this.extension.config||{};const e=this.extension.mergeConfig?this.extension.mergeConfig.bind(this.extension):d;for(const n of this.configs)t=e(t,n);return t}init(t){const e=this.state;Et(e)||vt(306,String(e.id));const n={getDependency:this.getInitDependency.bind(this),getDirectDependentNames:this.getDirectDependentNames.bind(this),getPeer:this.getInitPeer.bind(this),getPeerNameSet:this.getPeerNameSet.bind(this)},i={...n,getDependency:this.getDependency.bind(this),getInitResult:this.getInitResult.bind(this),getPeer:this.getPeer.bind(this)},o=function(t,e,n){return Object.assign(t,{config:e,id:xt.configured,registerState:n})}(e,this.mergeConfigs(),n);let s;this.state=o,this.extension.init&&(s=this.extension.init(t,o.config,n)),this.state=function(t,e,n){return Object.assign(t,{id:xt.initialized,initResult:e,registerState:n})}(o,s,i)}build(t){const e=this.state;let n;e.id!==xt.initialized&&vt(307,String(e.id),String(xt.built)),this.extension.build&&(n=this.extension.build(t,e.config,e.registerState));const i={...e.registerState,getOutput:()=>n,getSignal:this.getSignal.bind(this)};this.state=function(t,e,n){return Object.assign(t,{id:xt.built,output:e,registerState:n})}(e,n,i)}register(t,e){this._signal=e;const n=this.state;n.id!==xt.built&&vt(308,String(n.id),String(xt.built));const i=this.extension.register&&this.extension.register(t,n.config,n.registerState);return this.state=function(t){return Object.assign(t,{id:xt.registered})}(n),()=>{const t=this.state;t.id!==xt.afterRegistration&&vt(309,String(n.id),String(xt.afterRegistration)),this.state=function(t){return Object.assign(t,{id:xt.built})}(t),i&&i()}}afterRegistration(t){const e=this.state;let n;return e.id!==xt.registered&&vt(310,String(e.id),String(xt.registered)),this.extension.afterRegistration&&(n=this.extension.afterRegistration(t,e.config,e.registerState)),this.state=function(t){return Object.assign(t,{id:xt.afterRegistration})}(e),n}getSignal(){return void 0===this._signal&&vt(311),this._signal}getInitResult(){void 0===this.extension.init&&vt(312,this.extension.name);const t=this.state;return function(t){return t.id>=xt.initialized}(t)||vt(313,String(t.id),String(xt.initialized)),t.initResult}getInitPeer(t){const e=this.builder.extensionNameMap.get(t);return e?e.getExtensionInitDependency():void 0}getExtensionInitDependency(){const t=this.state;return function(t){return t.id>=xt.configured}(t)||vt(314,String(t.id),String(xt.configured)),{config:t.config}}getPeer(t){const e=this.builder.extensionNameMap.get(t);return e?e.getExtensionDependency():void 0}getInitDependency(t){const e=this.builder.getExtensionRep(t);return void 0===e&&vt(315,this.extension.name,t.name),e.getExtensionInitDependency()}getDependency(t){const e=this.builder.getExtensionRep(t);return void 0===e&&vt(315,this.extension.name,t.name),e.getExtensionDependency()}getState(){const t=this.state;return function(t){return t.id>=xt.afterRegistration}(t)||vt(316,String(t.id),String(xt.afterRegistration)),t}getDirectDependentNames(){return this.builder.incomingEdges.get(this.extension.name)||wt}getPeerNameSet(){let t=this._peerNameSet;return t||(t=new Set((this.extension.peerDependencies||[]).map((([t])=>t))),this._peerNameSet=t),t}getExtensionDependency(){if(!this._dependency){const t=this.state;(function(t){return t.id>=xt.built})(t)||vt(317,this.extension.name),this._dependency={config:t.config,init:t.initResult,output:t.output}}return this._dependency}}const Rt={tag:p};function Ot(){const t=o();t.isEmpty()&&t.append(r())}const Mt=t({config:e({setOptions:Rt,updateOptions:Rt}),init:({$initialEditorState:t=Ot})=>({$initialEditorState:t,initialized:!1}),afterRegistration(t,{updateOptions:e,setOptions:n},i){const o=i.getInitResult();if(!o.initialized){o.initialized=!0;const{$initialEditorState:i}=o;if(g(i))t.setEditorState(i,n);else if("function"==typeof i)t.update((()=>{i(t)}),e);else if(i&&("string"==typeof i||"object"==typeof i)){const e=t.parseEditorState(i);t.setEditorState(e,n)}}return()=>{}},name:"@lexical/extension/InitialState",nodes:[a,u,f,h,l]}),Ct=Symbol.for("@lexical/extension/LexicalBuilder");function Dt(...t){return kt.fromExtensions(t).buildEditor()}function _t(){}function It(t){throw t}function jt(t){return Array.isArray(t)?t:[t]}const At="0.36.0+prod.esm";class kt{roots;extensionNameMap;outgoingConfigEdges;incomingEdges;conflicts;_sortedExtensionReps;PACKAGE_VERSION;constructor(t){this.outgoingConfigEdges=new Map,this.incomingEdges=new Map,this.extensionNameMap=new Map,this.conflicts=new Map,this.PACKAGE_VERSION=At,this.roots=t;for(const e of t)this.addExtension(e)}static fromExtensions(t){const e=[jt(Mt)];for(const n of t)e.push(jt(n));return new kt(e)}static maybeFromEditor(t){const e=t[Ct];return e&&(e.PACKAGE_VERSION!==At&&vt(292,e.PACKAGE_VERSION,At),e instanceof kt||vt(293)),e}static fromEditor(t){const e=kt.maybeFromEditor(t);return void 0===e&&vt(294),e}constructEditor(){const{$initialEditorState:t,onError:e,...n}=this.buildCreateEditorArgs(),i=Object.assign(m({...n,...e?{onError:t=>{e(t,i)}}:{}}),{[Ct]:this});for(const t of this.sortedExtensionReps())t.build(i);return i}buildEditor(){let t=_t;function e(){try{t()}finally{t=_t}}const n=Object.assign(this.constructEditor(),{dispose:e,[Symbol.dispose]:e});return t=z(this.registerEditor(n),(()=>n.setRootElement(null))),n}hasExtensionByName(t){return this.extensionNameMap.has(t)}getExtensionRep(t){const e=this.extensionNameMap.get(t.name);if(e)return e.extension!==t&&vt(295,t.name),e}addEdge(t,e,n){const i=this.outgoingConfigEdges.get(t);i?i.set(e,n):this.outgoingConfigEdges.set(t,new Map([[e,n]]));const o=this.incomingEdges.get(e);o?o.add(t):this.incomingEdges.set(e,new Set([t]))}addExtension(t){void 0!==this._sortedExtensionReps&&vt(296);const e=jt(t),[n]=e;"string"!=typeof n.name&&vt(297,typeof n.name);let i=this.extensionNameMap.get(n.name);if(void 0!==i&&i.extension!==n&&vt(298,n.name),!i){i=new Nt(this,n),this.extensionNameMap.set(n.name,i);const t=this.conflicts.get(n.name);"string"==typeof t&&vt(299,n.name,t);for(const t of n.conflictsWith||[])this.extensionNameMap.has(t)&&vt(299,n.name,t),this.conflicts.set(t,n.name);for(const t of n.dependencies||[]){const e=jt(t);this.addEdge(n.name,e[0].name,e.slice(1)),this.addExtension(e)}for(const[t,e]of n.peerDependencies||[])this.addEdge(n.name,t,e?[e]:[])}}sortedExtensionReps(){if(this._sortedExtensionReps)return this._sortedExtensionReps;const t=[],e=(n,i)=>{let o=n.state;if(Et(o))return;const s=n.extension.name;var r;St(o)||vt(300,s,i||"[unknown]"),St(r=o)||vt(304,String(r.id),String(xt.unmarked)),o=Object.assign(r,{id:xt.temporary}),n.state=o;const c=this.outgoingConfigEdges.get(s);if(c)for(const t of c.keys()){const n=this.extensionNameMap.get(t);n&&e(n,s)}o=bt(o),n.state=o,t.push(n)};for(const t of this.extensionNameMap.values())St(t.state)&&e(t);for(const e of t)for(const[t,n]of this.outgoingConfigEdges.get(e.extension.name)||[])if(n.length>0){const e=this.extensionNameMap.get(t);if(e)for(const t of n)e.configs.add(t)}for(const[t,...e]of this.roots)if(e.length>0){const n=this.extensionNameMap.get(t.name);void 0===n&&vt(301,t.name);for(const t of e)n.configs.add(t)}return this._sortedExtensionReps=t,this._sortedExtensionReps}registerEditor(t){const e=this.sortedExtensionReps(),n=new AbortController,i=[()=>n.abort()],o=n.signal;for(const n of e){const e=n.register(t,o);e&&i.push(e)}for(const n of e){const e=n.afterRegistration(t);e&&i.push(e)}return z(...i)}buildCreateEditorArgs(){const t={},e=new Set,n=new Map,i=new Map,o={},s={},r=this.sortedExtensionReps();for(const c of r){const{extension:r}=c;if(void 0!==r.onError&&(t.onError=r.onError),void 0!==r.disableEvents&&(t.disableEvents=r.disableEvents),void 0!==r.parentEditor&&(t.parentEditor=r.parentEditor),void 0!==r.editable&&(t.editable=r.editable),void 0!==r.namespace&&(t.namespace=r.namespace),void 0!==r.$initialEditorState&&(t.$initialEditorState=r.$initialEditorState),r.nodes)for(const t of r.nodes){if("function"!=typeof t){const e=n.get(t.replace);e&&vt(302,r.name,t.replace.name,e.extension.name),n.set(t.replace,c)}e.add(t)}if(r.html){if(r.html.export)for(const[t,e]of r.html.export.entries())i.set(t,e);r.html.import&&Object.assign(o,r.html.import)}r.theme&&yt(s,r.theme)}Object.keys(s).length>0&&(t.theme=s),e.size&&(t.nodes=[...e]);const c=Object.keys(o).length>0,d=i.size>0;(c||d)&&(t.html={},c&&(t.html.import=o),d&&(t.html.export=i));for(const e of r)e.init(t);return t.onError||(t.onError=It),t}}function Pt(t,e){const n=kt.fromEditor(t).getExtensionRep(e);return void 0===n&&vt(303,e.name),n.getExtensionDependency()}function zt(t,e){const n=kt.fromEditor(t).extensionNameMap.get(e);return n?n.getExtensionDependency():void 0}function Kt(t,e){const n=zt(t,e);return void 0===n&&vt(291,e),n}const $t=new Set,Ut=t({build(t,e,n){const i=n.getDependency(mt).output,o=X({watchedNodeKeys:new Map}),r=pt((()=>{}),(()=>dt((()=>{const t=r.peek(),{watchedNodeKeys:e}=o.value;let n,c=!1;i.value.read((()=>{if(s())for(const[i,o]of e.entries()){if(0===o.size){e.delete(i);continue}const s=v(i),r=s&&s.isSelected()||!1;c=c||r!==(!!t&&t.has(i)),r&&(n=n||new Set,n.add(i))}})),!c&&n&&t&&n.size===t.size||(r.value=n)}))));return{watchNodeKey:function(t){const e=it((()=>(r.value||$t).has(t))),{watchedNodeKeys:n}=o.peek();let i=n.get(t);const s=void 0!==i;return i=i||new Set,i.add(e),s||(n.set(t,i),o.value={watchedNodeKeys:n}),e}}},dependencies:[mt],name:"@lexical/extension/NodeSelection"}),Lt=y("INSERT_HORIZONTAL_RULE_COMMAND");class Tt extends N{static getType(){return"horizontalrule"}static clone(t){return new Tt(t.__key)}static importJSON(t){return Ft().updateFromJSON(t)}static importDOM(){return{hr:()=>({conversion:Bt,priority:0})}}exportDOM(){return{element:document.createElement("hr")}}createDOM(t){const e=document.createElement("hr");return K(e,t.theme.hr),e}getTextContent(){return"\n"}isInline(){return!1}updateDOM(){return!1}}function Bt(){return{node:Ft()}}function Ft(){return x(Tt)}function Gt(t){return t instanceof Tt}const Vt=t({dependencies:[mt,Ut],name:"@lexical/extension/HorizontalRule",nodes:[Tt],register(t,e,n){const{watchNodeKey:i}=n.getDependency(Ut).output,o=X({nodeSelections:new Map}),r=t._config.theme.hrSelected??"selected";return z(t.registerCommand(S,(t=>{if(E(t.target)){const e=b(t.target);if(Gt(e))return function(t,e=!1){const n=s(),i=t.isSelected(),o=t.getKey();let r;e&&R(n)?r=n:(r=O(),M(r)),i?r.delete(o):r.add(o)}(e,t.shiftKey),!0}return!1}),w),t.registerMutationListener(Tt,((e,n)=>{F((()=>{let n=!1;const{nodeSelections:s}=o.peek();for(const[o,r]of e.entries())if("destroyed"===r)s.delete(o),n=!0;else{const e=s.get(o),r=t.getElementByKey(o);e?e.domNode.value=r:(n=!0,s.set(o,{domNode:X(r),selectedSignal:i(o)}))}n&&(o.value={nodeSelections:s})}))})),dt((()=>{const t=[];for(const{domNode:e,selectedSignal:n}of o.value.nodeSelections.values())t.push(dt((()=>{const t=e.value;if(t){n.value?K(t,r):$(t,r)}})));return z(...t)})))}});function Wt(t,e){return z(t.registerCommand(C,(e=>{const n=s();if(!c(n))return!1;e.preventDefault();const i=function(t){const e=t.getNodes();if(L(e,(t=>A(t)&&t.canIndent()?t:null)).length>0)return!0;const n=t.anchor,i=t.focus,o=i.isBefore(n)?i:n,s=o.getNode(),r=U(s);if(r.canIndent()){const t=r.getKey();let e=k();if(e.anchor.set(t,0,"element"),e.focus.set(t,0,"element"),e=P(e),e.anchor.is(o))return!0}return!1}(n)?e.shiftKey?D:_:I;return t.dispatchCommand(i,void 0)}),i),t.registerCommand(_,(()=>{const t="number"==typeof e?e:e?e.peek():null;if(null==t)return!1;const n=s();if(!c(n))return!1;const i=n.getNodes().map((t=>U(t).getIndent()));return Math.max(...i)+1>=t}),j))}const Zt=t({build:(t,e,n)=>at(e),config:e({disabled:!1,maxIndent:null}),name:"@lexical/extension/TabIndentation",register(t,e,n){const{disabled:i,maxIndent:o}=n.getOutput();return dt((()=>{if(!i.value)return Wt(t,o)}))}});export{Ft as $createHorizontalRuleNode,Gt as $isHorizontalRuleNode,ut as AutoFocusExtension,lt as ClearEditorExtension,mt as EditorStateExtension,Vt as HorizontalRuleExtension,Tt as HorizontalRuleNode,Lt as INSERT_HORIZONTAL_RULE_COMMAND,Mt as InitialStateExtension,kt as LexicalBuilder,Ut as NodeSelectionExtension,Zt as TabIndentationExtension,F as batch,Dt as buildEditorFromExtensions,it as computed,dt as effect,Pt as getExtensionDependencyFromEditor,gt as getKnownTypesAndNodes,zt as getPeerDependencyFromEditor,Kt as getPeerDependencyFromEditorOrThrow,at as namedSignals,ht as registerClearEditor,Wt as registerTabIndentation,X as signal,W as untracked,pt as watchedSignal};
9
+ import{defineExtension as t,safeCast as e,CLEAR_EDITOR_COMMAND as n,COMMAND_PRIORITY_EDITOR as i,$getRoot as o,$getSelection as s,$createParagraphNode as r,$isRangeSelection as c,shallowMergeConfig as d,RootNode as a,TextNode as u,LineBreakNode as f,TabNode as h,ParagraphNode as l,$isEditorState as g,HISTORY_MERGE_TAG as p,createEditor as m,$getNodeByKey as v,createCommand as y,$create as x,CLICK_COMMAND as S,isDOMNode as E,$getNodeFromDOMNode as b,COMMAND_PRIORITY_LOW as w,DecoratorNode as N,$isNodeSelection as R,$createNodeSelection as O,$setSelection as M,KEY_TAB_COMMAND as C,OUTDENT_CONTENT_COMMAND as D,INDENT_CONTENT_COMMAND as _,INSERT_TAB_COMMAND as I,COMMAND_PRIORITY_CRITICAL as j,$isBlockElementNode as A,$createRangeSelection as k,$normalizeSelection__EXPERIMENTAL as P}from"lexical";export{configExtension,declarePeerDependency,defineExtension,safeCast,shallowMergeConfig}from"lexical";import{mergeRegister as z,addClassNamesToElement as K,removeClassNamesFromElement as $,$getNearestBlockElementAncestorOrThrow as U,$filter as L}from"@lexical/utils";const T=Symbol.for("preact-signals");function B(){if(Z>1)return void Z--;let t,e=!1;for(;void 0!==V;){let n=V;for(V=void 0,J++;void 0!==n;){const i=n.o;if(n.o=void 0,n.f&=-3,!(8&n.f)&&Y(n))try{n.c()}catch(n){e||(t=n,e=!0)}n=i}}if(J=0,Z--,e)throw t}function F(t){if(Z>0)return t();Z++;try{return t()}finally{B()}}let G,V;function W(t){const e=G;G=void 0;try{return t()}finally{G=e}}let Z=0,J=0,H=0;function q(t){if(void 0===G)return;let e=t.n;return void 0===e||e.t!==G?(e={i:0,S:t,p:G.s,n:void 0,t:G,e:void 0,x:void 0,r:e},void 0!==G.s&&(G.s.n=e),G.s=e,t.n=e,32&G.f&&t.S(e),e):-1===e.i?(e.i=0,void 0!==e.n&&(e.n.p=e.p,void 0!==e.p&&(e.p.n=e.n),e.p=G.s,e.n=void 0,G.s.n=e,G.s=e),e):void 0}function Q(t,e){this.v=t,this.i=0,this.n=void 0,this.t=void 0,this.W=null==e?void 0:e.watched,this.Z=null==e?void 0:e.unwatched,this.name=null==e?void 0:e.name}function X(t,e){return new Q(t,e)}function Y(t){for(let e=t.s;void 0!==e;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return!0;return!1}function tt(t){for(let e=t.s;void 0!==e;e=e.n){const n=e.S.n;if(void 0!==n&&(e.r=n),e.S.n=e,e.i=-1,void 0===e.n){t.s=e;break}}}function et(t){let e,n=t.s;for(;void 0!==n;){const t=n.p;-1===n.i?(n.S.U(n),void 0!==t&&(t.n=n.n),void 0!==n.n&&(n.n.p=t)):e=n,n.S.n=n.r,void 0!==n.r&&(n.r=void 0),n=t}t.s=e}function nt(t,e){Q.call(this,void 0),this.x=t,this.s=void 0,this.g=H-1,this.f=4,this.W=null==e?void 0:e.watched,this.Z=null==e?void 0:e.unwatched,this.name=null==e?void 0:e.name}function it(t,e){return new nt(t,e)}function ot(t){const e=t.u;if(t.u=void 0,"function"==typeof e){Z++;const n=G;G=void 0;try{e()}catch(e){throw t.f&=-2,t.f|=8,st(t),e}finally{G=n,B()}}}function st(t){for(let e=t.s;void 0!==e;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,ot(t)}function rt(t){if(G!==this)throw new Error("Out-of-order effect");et(this),G=t,this.f&=-2,8&this.f&&st(this),B()}function ct(t,e){this.x=t,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=null==e?void 0:e.name}function dt(t,e){const n=new ct(t,e);try{n.c()}catch(t){throw n.d(),t}const i=n.d.bind(n);return i[Symbol.dispose]=i,i}function at(t,e={}){const n={};for(const i in t){const o=e[i],s=X(void 0===o?t[i]:o);n[i]=s}return n}Q.prototype.brand=T,Q.prototype.h=function(){return!0},Q.prototype.S=function(t){const e=this.t;e!==t&&void 0===t.e&&(t.x=e,this.t=t,void 0!==e?e.e=t:W((()=>{var t;null==(t=this.W)||t.call(this)})))},Q.prototype.U=function(t){if(void 0!==this.t){const e=t.e,n=t.x;void 0!==e&&(e.x=n,t.e=void 0),void 0!==n&&(n.e=e,t.x=void 0),t===this.t&&(this.t=n,void 0===n&&W((()=>{var t;null==(t=this.Z)||t.call(this)})))}},Q.prototype.subscribe=function(t){return dt((()=>{const e=this.value,n=G;G=void 0;try{t(e)}finally{G=n}}),{name:"sub"})},Q.prototype.valueOf=function(){return this.value},Q.prototype.toString=function(){return this.value+""},Q.prototype.toJSON=function(){return this.value},Q.prototype.peek=function(){const t=G;G=void 0;try{return this.value}finally{G=t}},Object.defineProperty(Q.prototype,"value",{get(){const t=q(this);return void 0!==t&&(t.i=this.i),this.v},set(t){if(t!==this.v){if(J>100)throw new Error("Cycle detected");this.v=t,this.i++,H++,Z++;try{for(let t=this.t;void 0!==t;t=t.x)t.t.N()}finally{B()}}}}),nt.prototype=new Q,nt.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if(32==(36&this.f))return!0;if(this.f&=-5,this.g===H)return!0;if(this.g=H,this.f|=1,this.i>0&&!Y(this))return this.f&=-2,!0;const t=G;try{tt(this),G=this;const t=this.x();(16&this.f||this.v!==t||0===this.i)&&(this.v=t,this.f&=-17,this.i++)}catch(t){this.v=t,this.f|=16,this.i++}return G=t,et(this),this.f&=-2,!0},nt.prototype.S=function(t){if(void 0===this.t){this.f|=36;for(let t=this.s;void 0!==t;t=t.n)t.S.S(t)}Q.prototype.S.call(this,t)},nt.prototype.U=function(t){if(void 0!==this.t&&(Q.prototype.U.call(this,t),void 0===this.t)){this.f&=-33;for(let t=this.s;void 0!==t;t=t.n)t.S.U(t)}},nt.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(let t=this.t;void 0!==t;t=t.x)t.t.N()}},Object.defineProperty(nt.prototype,"value",{get(){if(1&this.f)throw new Error("Cycle detected");const t=q(this);if(this.h(),void 0!==t&&(t.i=this.i),16&this.f)throw this.v;return this.v}}),ct.prototype.c=function(){const t=this.S();try{if(8&this.f)return;if(void 0===this.x)return;const t=this.x();"function"==typeof t&&(this.u=t)}finally{t()}},ct.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,ot(this),tt(this),Z++;const t=G;return G=this,rt.bind(this,t)},ct.prototype.N=function(){2&this.f||(this.f|=2,this.o=V,V=this)},ct.prototype.d=function(){this.f|=8,1&this.f||st(this)},ct.prototype.dispose=function(){this.d()};const ut=t({build:(t,e,n)=>at(e),config:e({defaultSelection:"rootEnd",disabled:!1}),name:"@lexical/extension/AutoFocus",register(t,e,n){const i=n.getOutput();return dt((()=>i.disabled.value?void 0:t.registerRootListener((e=>{t.focus((()=>{const t=document.activeElement;null===e||null!==t&&e.contains(t)||e.focus({preventScroll:!0})}),{defaultSelection:i.defaultSelection.peek()})}))))}});function ft(){const t=o(),e=s(),n=r();t.clear(),t.append(n),null!==e&&n.select(),c(e)&&(e.format=0)}function ht(t,e=ft){return t.registerCommand(n,(n=>(t.update(e),!0)),i)}const lt=t({build:(t,e,n)=>at(e),config:e({$onClear:ft}),name:"@lexical/extension/ClearEditor",register(t,e,n){const{$onClear:i}=n.getOutput();return dt((()=>ht(t,i.value)))}});function gt(t){const e=new Set,n=new Set;for(const i of t.nodes??[]){const t="function"==typeof i?i:i.replace;e.add(t.getType()),n.add(t)}return{nodes:n,types:e}}function pt(t,e){let n;return X(t(),{unwatched(){n&&(n(),n=void 0)},watched(){this.value=t(),n=e(this)}})}const mt=t({build:t=>pt((()=>t.getEditorState()),(e=>t.registerUpdateListener((t=>{e.value=t.editorState})))),name:"@lexical/extension/EditorState"});function vt(t,...e){const n=new URL("https://lexical.dev/docs/error"),i=new URLSearchParams;i.append("code",t);for(const t of e)i.append("v",t);throw n.search=i.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function yt(t,e){if(t&&e&&!Array.isArray(e)&&"object"==typeof t&&"object"==typeof e){const n=t,i=e;for(const t in i)n[t]=yt(n[t],i[t]);return t}return e}const xt={unmarked:0,temporary:1,permanent:2,configured:3,initialized:4,built:5,registered:6,afterRegistration:7};function St(t){return t.id===xt.unmarked}function Et(t){return t.id===xt.permanent}function bt(t){return function(t){return t.id===xt.temporary}(t)||vt(305,String(t.id),String(xt.temporary)),Object.assign(t,{id:xt.permanent})}const wt=new Set;class Nt{builder;configs;_dependency;_peerNameSet;extension;state;_signal;constructor(t,e){this.builder=t,this.extension=e,this.configs=new Set,this.state={id:xt.unmarked}}mergeConfigs(){let t=this.extension.config||{};const e=this.extension.mergeConfig?this.extension.mergeConfig.bind(this.extension):d;for(const n of this.configs)t=e(t,n);return t}init(t){const e=this.state;Et(e)||vt(306,String(e.id));const n={getDependency:this.getInitDependency.bind(this),getDirectDependentNames:this.getDirectDependentNames.bind(this),getPeer:this.getInitPeer.bind(this),getPeerNameSet:this.getPeerNameSet.bind(this)},i={...n,getDependency:this.getDependency.bind(this),getInitResult:this.getInitResult.bind(this),getPeer:this.getPeer.bind(this)},o=function(t,e,n){return Object.assign(t,{config:e,id:xt.configured,registerState:n})}(e,this.mergeConfigs(),n);let s;this.state=o,this.extension.init&&(s=this.extension.init(t,o.config,n)),this.state=function(t,e,n){return Object.assign(t,{id:xt.initialized,initResult:e,registerState:n})}(o,s,i)}build(t){const e=this.state;let n;e.id!==xt.initialized&&vt(307,String(e.id),String(xt.built)),this.extension.build&&(n=this.extension.build(t,e.config,e.registerState));const i={...e.registerState,getOutput:()=>n,getSignal:this.getSignal.bind(this)};this.state=function(t,e,n){return Object.assign(t,{id:xt.built,output:e,registerState:n})}(e,n,i)}register(t,e){this._signal=e;const n=this.state;n.id!==xt.built&&vt(308,String(n.id),String(xt.built));const i=this.extension.register&&this.extension.register(t,n.config,n.registerState);return this.state=function(t){return Object.assign(t,{id:xt.registered})}(n),()=>{const t=this.state;t.id!==xt.afterRegistration&&vt(309,String(n.id),String(xt.afterRegistration)),this.state=function(t){return Object.assign(t,{id:xt.built})}(t),i&&i()}}afterRegistration(t){const e=this.state;let n;return e.id!==xt.registered&&vt(310,String(e.id),String(xt.registered)),this.extension.afterRegistration&&(n=this.extension.afterRegistration(t,e.config,e.registerState)),this.state=function(t){return Object.assign(t,{id:xt.afterRegistration})}(e),n}getSignal(){return void 0===this._signal&&vt(311),this._signal}getInitResult(){void 0===this.extension.init&&vt(312,this.extension.name);const t=this.state;return function(t){return t.id>=xt.initialized}(t)||vt(313,String(t.id),String(xt.initialized)),t.initResult}getInitPeer(t){const e=this.builder.extensionNameMap.get(t);return e?e.getExtensionInitDependency():void 0}getExtensionInitDependency(){const t=this.state;return function(t){return t.id>=xt.configured}(t)||vt(314,String(t.id),String(xt.configured)),{config:t.config}}getPeer(t){const e=this.builder.extensionNameMap.get(t);return e?e.getExtensionDependency():void 0}getInitDependency(t){const e=this.builder.getExtensionRep(t);return void 0===e&&vt(315,this.extension.name,t.name),e.getExtensionInitDependency()}getDependency(t){const e=this.builder.getExtensionRep(t);return void 0===e&&vt(315,this.extension.name,t.name),e.getExtensionDependency()}getState(){const t=this.state;return function(t){return t.id>=xt.afterRegistration}(t)||vt(316,String(t.id),String(xt.afterRegistration)),t}getDirectDependentNames(){return this.builder.incomingEdges.get(this.extension.name)||wt}getPeerNameSet(){let t=this._peerNameSet;return t||(t=new Set((this.extension.peerDependencies||[]).map((([t])=>t))),this._peerNameSet=t),t}getExtensionDependency(){if(!this._dependency){const t=this.state;(function(t){return t.id>=xt.built})(t)||vt(317,this.extension.name),this._dependency={config:t.config,init:t.initResult,output:t.output}}return this._dependency}}const Rt={tag:p};function Ot(){const t=o();t.isEmpty()&&t.append(r())}const Mt=t({config:e({setOptions:Rt,updateOptions:Rt}),init:({$initialEditorState:t=Ot})=>({$initialEditorState:t,initialized:!1}),afterRegistration(t,{updateOptions:e,setOptions:n},i){const o=i.getInitResult();if(!o.initialized){o.initialized=!0;const{$initialEditorState:i}=o;if(g(i))t.setEditorState(i,n);else if("function"==typeof i)t.update((()=>{i(t)}),e);else if(i&&("string"==typeof i||"object"==typeof i)){const e=t.parseEditorState(i);t.setEditorState(e,n)}}return()=>{}},name:"@lexical/extension/InitialState",nodes:[a,u,f,h,l]}),Ct=Symbol.for("@lexical/extension/LexicalBuilder");function Dt(...t){return kt.fromExtensions(t).buildEditor()}function _t(){}function It(t){throw t}function jt(t){return Array.isArray(t)?t:[t]}const At="0.36.1+prod.esm";class kt{roots;extensionNameMap;outgoingConfigEdges;incomingEdges;conflicts;_sortedExtensionReps;PACKAGE_VERSION;constructor(t){this.outgoingConfigEdges=new Map,this.incomingEdges=new Map,this.extensionNameMap=new Map,this.conflicts=new Map,this.PACKAGE_VERSION=At,this.roots=t;for(const e of t)this.addExtension(e)}static fromExtensions(t){const e=[jt(Mt)];for(const n of t)e.push(jt(n));return new kt(e)}static maybeFromEditor(t){const e=t[Ct];return e&&(e.PACKAGE_VERSION!==At&&vt(292,e.PACKAGE_VERSION,At),e instanceof kt||vt(293)),e}static fromEditor(t){const e=kt.maybeFromEditor(t);return void 0===e&&vt(294),e}constructEditor(){const{$initialEditorState:t,onError:e,...n}=this.buildCreateEditorArgs(),i=Object.assign(m({...n,...e?{onError:t=>{e(t,i)}}:{}}),{[Ct]:this});for(const t of this.sortedExtensionReps())t.build(i);return i}buildEditor(){let t=_t;function e(){try{t()}finally{t=_t}}const n=Object.assign(this.constructEditor(),{dispose:e,[Symbol.dispose]:e});return t=z(this.registerEditor(n),(()=>n.setRootElement(null))),n}hasExtensionByName(t){return this.extensionNameMap.has(t)}getExtensionRep(t){const e=this.extensionNameMap.get(t.name);if(e)return e.extension!==t&&vt(295,t.name),e}addEdge(t,e,n){const i=this.outgoingConfigEdges.get(t);i?i.set(e,n):this.outgoingConfigEdges.set(t,new Map([[e,n]]));const o=this.incomingEdges.get(e);o?o.add(t):this.incomingEdges.set(e,new Set([t]))}addExtension(t){void 0!==this._sortedExtensionReps&&vt(296);const e=jt(t),[n]=e;"string"!=typeof n.name&&vt(297,typeof n.name);let i=this.extensionNameMap.get(n.name);if(void 0!==i&&i.extension!==n&&vt(298,n.name),!i){i=new Nt(this,n),this.extensionNameMap.set(n.name,i);const t=this.conflicts.get(n.name);"string"==typeof t&&vt(299,n.name,t);for(const t of n.conflictsWith||[])this.extensionNameMap.has(t)&&vt(299,n.name,t),this.conflicts.set(t,n.name);for(const t of n.dependencies||[]){const e=jt(t);this.addEdge(n.name,e[0].name,e.slice(1)),this.addExtension(e)}for(const[t,e]of n.peerDependencies||[])this.addEdge(n.name,t,e?[e]:[])}}sortedExtensionReps(){if(this._sortedExtensionReps)return this._sortedExtensionReps;const t=[],e=(n,i)=>{let o=n.state;if(Et(o))return;const s=n.extension.name;var r;St(o)||vt(300,s,i||"[unknown]"),St(r=o)||vt(304,String(r.id),String(xt.unmarked)),o=Object.assign(r,{id:xt.temporary}),n.state=o;const c=this.outgoingConfigEdges.get(s);if(c)for(const t of c.keys()){const n=this.extensionNameMap.get(t);n&&e(n,s)}o=bt(o),n.state=o,t.push(n)};for(const t of this.extensionNameMap.values())St(t.state)&&e(t);for(const e of t)for(const[t,n]of this.outgoingConfigEdges.get(e.extension.name)||[])if(n.length>0){const e=this.extensionNameMap.get(t);if(e)for(const t of n)e.configs.add(t)}for(const[t,...e]of this.roots)if(e.length>0){const n=this.extensionNameMap.get(t.name);void 0===n&&vt(301,t.name);for(const t of e)n.configs.add(t)}return this._sortedExtensionReps=t,this._sortedExtensionReps}registerEditor(t){const e=this.sortedExtensionReps(),n=new AbortController,i=[()=>n.abort()],o=n.signal;for(const n of e){const e=n.register(t,o);e&&i.push(e)}for(const n of e){const e=n.afterRegistration(t);e&&i.push(e)}return z(...i)}buildCreateEditorArgs(){const t={},e=new Set,n=new Map,i=new Map,o={},s={},r=this.sortedExtensionReps();for(const c of r){const{extension:r}=c;if(void 0!==r.onError&&(t.onError=r.onError),void 0!==r.disableEvents&&(t.disableEvents=r.disableEvents),void 0!==r.parentEditor&&(t.parentEditor=r.parentEditor),void 0!==r.editable&&(t.editable=r.editable),void 0!==r.namespace&&(t.namespace=r.namespace),void 0!==r.$initialEditorState&&(t.$initialEditorState=r.$initialEditorState),r.nodes)for(const t of r.nodes){if("function"!=typeof t){const e=n.get(t.replace);e&&vt(302,r.name,t.replace.name,e.extension.name),n.set(t.replace,c)}e.add(t)}if(r.html){if(r.html.export)for(const[t,e]of r.html.export.entries())i.set(t,e);r.html.import&&Object.assign(o,r.html.import)}r.theme&&yt(s,r.theme)}Object.keys(s).length>0&&(t.theme=s),e.size&&(t.nodes=[...e]);const c=Object.keys(o).length>0,d=i.size>0;(c||d)&&(t.html={},c&&(t.html.import=o),d&&(t.html.export=i));for(const e of r)e.init(t);return t.onError||(t.onError=It),t}}function Pt(t,e){const n=kt.fromEditor(t).getExtensionRep(e);return void 0===n&&vt(303,e.name),n.getExtensionDependency()}function zt(t,e){const n=kt.fromEditor(t).extensionNameMap.get(e);return n?n.getExtensionDependency():void 0}function Kt(t,e){const n=zt(t,e);return void 0===n&&vt(291,e),n}const $t=new Set,Ut=t({build(t,e,n){const i=n.getDependency(mt).output,o=X({watchedNodeKeys:new Map}),r=pt((()=>{}),(()=>dt((()=>{const t=r.peek(),{watchedNodeKeys:e}=o.value;let n,c=!1;i.value.read((()=>{if(s())for(const[i,o]of e.entries()){if(0===o.size){e.delete(i);continue}const s=v(i),r=s&&s.isSelected()||!1;c=c||r!==(!!t&&t.has(i)),r&&(n=n||new Set,n.add(i))}})),!c&&n&&t&&n.size===t.size||(r.value=n)}))));return{watchNodeKey:function(t){const e=it((()=>(r.value||$t).has(t))),{watchedNodeKeys:n}=o.peek();let i=n.get(t);const s=void 0!==i;return i=i||new Set,i.add(e),s||(n.set(t,i),o.value={watchedNodeKeys:n}),e}}},dependencies:[mt],name:"@lexical/extension/NodeSelection"}),Lt=y("INSERT_HORIZONTAL_RULE_COMMAND");class Tt extends N{static getType(){return"horizontalrule"}static clone(t){return new Tt(t.__key)}static importJSON(t){return Ft().updateFromJSON(t)}static importDOM(){return{hr:()=>({conversion:Bt,priority:0})}}exportDOM(){return{element:document.createElement("hr")}}createDOM(t){const e=document.createElement("hr");return K(e,t.theme.hr),e}getTextContent(){return"\n"}isInline(){return!1}updateDOM(){return!1}}function Bt(){return{node:Ft()}}function Ft(){return x(Tt)}function Gt(t){return t instanceof Tt}const Vt=t({dependencies:[mt,Ut],name:"@lexical/extension/HorizontalRule",nodes:[Tt],register(t,e,n){const{watchNodeKey:i}=n.getDependency(Ut).output,o=X({nodeSelections:new Map}),r=t._config.theme.hrSelected??"selected";return z(t.registerCommand(S,(t=>{if(E(t.target)){const e=b(t.target);if(Gt(e))return function(t,e=!1){const n=s(),i=t.isSelected(),o=t.getKey();let r;e&&R(n)?r=n:(r=O(),M(r)),i?r.delete(o):r.add(o)}(e,t.shiftKey),!0}return!1}),w),t.registerMutationListener(Tt,((e,n)=>{F((()=>{let n=!1;const{nodeSelections:s}=o.peek();for(const[o,r]of e.entries())if("destroyed"===r)s.delete(o),n=!0;else{const e=s.get(o),r=t.getElementByKey(o);e?e.domNode.value=r:(n=!0,s.set(o,{domNode:X(r),selectedSignal:i(o)}))}n&&(o.value={nodeSelections:s})}))})),dt((()=>{const t=[];for(const{domNode:e,selectedSignal:n}of o.value.nodeSelections.values())t.push(dt((()=>{const t=e.value;if(t){n.value?K(t,r):$(t,r)}})));return z(...t)})))}});function Wt(t,e){return z(t.registerCommand(C,(e=>{const n=s();if(!c(n))return!1;e.preventDefault();const i=function(t){const e=t.getNodes();if(L(e,(t=>A(t)&&t.canIndent()?t:null)).length>0)return!0;const n=t.anchor,i=t.focus,o=i.isBefore(n)?i:n,s=o.getNode(),r=U(s);if(r.canIndent()){const t=r.getKey();let e=k();if(e.anchor.set(t,0,"element"),e.focus.set(t,0,"element"),e=P(e),e.anchor.is(o))return!0}return!1}(n)?e.shiftKey?D:_:I;return t.dispatchCommand(i,void 0)}),i),t.registerCommand(_,(()=>{const t="number"==typeof e?e:e?e.peek():null;if(null==t)return!1;const n=s();if(!c(n))return!1;const i=n.getNodes().map((t=>U(t).getIndent()));return Math.max(...i)+1>=t}),j))}const Zt=t({build:(t,e,n)=>at(e),config:e({disabled:!1,maxIndent:null}),name:"@lexical/extension/TabIndentation",register(t,e,n){const{disabled:i,maxIndent:o}=n.getOutput();return dt((()=>{if(!i.value)return Wt(t,o)}))}});export{Ft as $createHorizontalRuleNode,Gt as $isHorizontalRuleNode,ut as AutoFocusExtension,lt as ClearEditorExtension,mt as EditorStateExtension,Vt as HorizontalRuleExtension,Tt as HorizontalRuleNode,Lt as INSERT_HORIZONTAL_RULE_COMMAND,Mt as InitialStateExtension,kt as LexicalBuilder,Ut as NodeSelectionExtension,Zt as TabIndentationExtension,F as batch,Dt as buildEditorFromExtensions,it as computed,dt as effect,Pt as getExtensionDependencyFromEditor,gt as getKnownTypesAndNodes,zt as getPeerDependencyFromEditor,Kt as getPeerDependencyFromEditorOrThrow,at as namedSignals,ht as registerClearEditor,Wt as registerTabIndentation,X as signal,W as untracked,pt as watchedSignal};
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "extension",
7
7
  "plugin"
8
8
  ],
9
- "version": "0.36.0",
9
+ "version": "0.36.1",
10
10
  "license": "MIT",
11
11
  "repository": {
12
12
  "type": "git",
@@ -23,9 +23,9 @@
23
23
  "sideEffects": false,
24
24
  "module": "LexicalExtension.mjs",
25
25
  "dependencies": {
26
- "@lexical/utils": "0.36.0",
26
+ "@lexical/utils": "0.36.1",
27
27
  "@preact/signals-core": "^1.11.0",
28
- "lexical": "0.36.0"
28
+ "lexical": "0.36.1"
29
29
  },
30
30
  "exports": {
31
31
  ".": {