@lexical/extension 0.44.0 → 0.44.1-nightly.20260428.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -823,7 +823,7 @@ function maybeWithBuilder(editor) {
823
823
  function normalizeExtensionArgument(arg) {
824
824
  return Array.isArray(arg) ? arg : [arg];
825
825
  }
826
- const PACKAGE_VERSION = "0.44.0+dev.cjs";
826
+ const PACKAGE_VERSION = "0.44.1-nightly.20260428.0+dev.cjs";
827
827
 
828
828
  /** @internal */
829
829
  class LexicalBuilder {
@@ -822,7 +822,7 @@ function maybeWithBuilder(editor) {
822
822
  function normalizeExtensionArgument(arg) {
823
823
  return Array.isArray(arg) ? arg : [arg];
824
824
  }
825
- const PACKAGE_VERSION = "0.44.0+dev.esm";
825
+ const PACKAGE_VERSION = "0.44.1-nightly.20260428.0+dev.esm";
826
826
 
827
827
  /** @internal */
828
828
  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(!function(){let t=c;for(c=void 0;void 0!==t;)t.S.v===t.v&&(t.S.i=t.i),t=t.o}();void 0!==r;){let n=r;for(r=void 0,l++;void 0!==n;){const i=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&x(n))try{n.c()}catch(n){e||(t=n,e=!0)}n=i}}if(l=0,d--,e)throw t}function o(t){if(d>0)return t();f=++u,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 c,d=0,l=0,u=0,f=0,h=0;function g(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 p(t,e){this.v=t,this.i=0,this.n=void 0,this.t=void 0,this.l=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 m(t,e){return new p(t,e)}function x(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 E(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 v(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 S(t,e){p.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 y(t,e){return new S(t,e)}function N(t){const e=t.m;if(t.m=void 0,"function"==typeof e){d++;const n=s;s=void 0;try{e()}catch(e){throw t.f&=-2,t.f|=8,b(t),e}finally{s=n,i()}}}function b(t){for(let e=t.s;void 0!==e;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,N(t)}function O(t){if(s!==this)throw new Error("Out-of-order effect");v(this),s=t,this.f&=-2,8&this.f&&b(this),i()}function R(t,e){this.x=t,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=null==e?void 0:e.name}function C(t,e){const n=new R(t,e);try{n.c()}catch(t){throw n.d(),t}const i=n.d.bind(n);return i[Symbol.dispose]=i,i}function D(t,e={}){const n={};for(const i in t){const o=e[i],s=m(void 0===o?t[i]:o);n[i]=s}return n}p.prototype.brand=n,p.prototype.h=function(){return!0},p.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)}))},p.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)}))}},p.prototype.subscribe=function(t){return C(()=>{const e=this.value,n=s;s=void 0;try{t(e)}finally{s=n}},{name:"sub"})},p.prototype.valueOf=function(){return this.value},p.prototype.toString=function(){return this.value+""},p.prototype.toJSON=function(){return this.value},p.prototype.peek=function(){const t=s;s=void 0;try{return this.value}finally{s=t}},Object.defineProperty(p.prototype,"value",{get(){const t=g(this);return void 0!==t&&(t.i=this.i),this.v},set(t){if(t!==this.v){if(l>100)throw new Error("Cycle detected");!function(t){0!==d&&0===l&&t.l!==f&&(t.l=f,c={S:t,v:t.v,i:t.i,o:c})}(this),this.v=t,this.i++,h++,d++;try{for(let t=this.t;void 0!==t;t=t.x)t.t.N()}finally{i()}}}}),S.prototype=new p,S.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&&!x(this))return this.f&=-2,!0;const t=s;try{E(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,v(this),this.f&=-2,!0},S.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)}p.prototype.S.call(this,t)},S.prototype.U=function(t){if(void 0!==this.t&&(p.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)}},S.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(S.prototype,"value",{get(){if(1&this.f)throw new Error("Cycle detected");const t=g(this);if(this.h(),void 0!==t&&(t.i=this.i),16&this.f)throw this.v;return this.v}}),R.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.m=t)}finally{t()}},R.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,N(this),E(this),d++;const t=s;return s=this,O.bind(this,t)},R.prototype.N=function(){2&this.f||(this.f|=2,this.u=r,r=this)},R.prototype.d=function(){this.f|=8,1&this.f||b(this)},R.prototype.dispose=function(){this.d()};const M=t.defineExtension({build:(t,e,n)=>D(e),config:t.safeCast({defaultSelection:"rootEnd",disabled:!1}),name:"@lexical/extension/AutoFocus",register(t,e,n){const i=n.getOutput();return C(()=>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 _(e,n=w){return e.registerCommand(t.CLEAR_EDITOR_COMMAND,t=>(e.update(n),!0),t.COMMAND_PRIORITY_EDITOR)}const T=t.defineExtension({build:(t,e,n)=>D(e),config:t.safeCast({$onClear:w}),name:"@lexical/extension/ClearEditor",register(t,e,n){const{$onClear:i}=n.getOutput();return C(()=>_(t,i.value))}});function I(t){return("function"==typeof t.nodes?t.nodes():t.nodes)||[]}const $=t.createState("format",{parse:t=>"number"==typeof t?t:0});class A extends t.DecoratorNode{$config(){return this.config("decorator-text",{extends:t.DecoratorNode,stateConfigs:[{flat:!0,stateConfig:$}]})}getFormat(){return t.$getState(this,$)}getFormatFlags(e,n){return t.toggleTextFormatType(this.getFormat(),e,n)}hasFormat(e){const n=t.TEXT_TYPE_TO_FORMAT[e];return 0!==(this.getFormat()&n)}setFormat(e){return t.$setState(this,$,e)}toggleFormat(e){const n=this.getFormat(),i=t.toggleTextFormatType(n,e,null);return this.setFormat(i)}isInline(){return!0}createDOM(){return document.createElement("span")}updateDOM(){return!1}}function F(t){return t instanceof A}function P(t,e){const n=document.createElement(e);return n.appendChild(t),n}const k={b:"bold",code:"code",em:"italic",i:"italic",mark:"highlight",s:"strikethrough",strong:"bold",sub:"subscript",sup:"superscript",u:"underline"},j=t.defineExtension({name:"@lexical/extension/DecoratorText",nodes:()=>[A],register:(e,n,i)=>e.registerCommand(t.FORMAT_TEXT_COMMAND,e=>{const n=t.$getSelection();if(t.$isNodeSelection(n)||t.$isRangeSelection(n))for(const t of n.getNodes())F(t)&&t.toggleFormat(e);return!1},t.COMMAND_PRIORITY_LOW)});function L(t,e){let n;return m(t(),{unwatched(){n&&(n(),n=void 0)},watched(){this.value=t(),n=e(this)}})}const K=t.defineExtension({build:t=>L(()=>t.getEditorState(),e=>t.registerUpdateListener(t=>{e.value=t.editorState})),name:"@lexical/extension/EditorState"});function z(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 B(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]=B(n[t],i[t]);return t}return e}const U=0,Y=1,H=2,W=3,G=4,Z=5,V=6,J=7;function X(t){return t.id===U}function q(t){return t.id===H}function Q(t){return function(t){return t.id===Y}(t)||z(305,String(t.id),String(Y)),Object.assign(t,{id:H})}const tt=new Set;class et{builder;configs;_dependency;_peerNameSet;extension;state;_signal;constructor(t,e){this.builder=t,this.extension=e,this.configs=new Set,this.state={id:U}}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;q(e)||z(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:W,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:G,initResult:e,registerState:n})}(o,s,i)}build(t){const e=this.state;let n;e.id!==G&&z(307,String(e.id),String(Z)),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:Z,output:e,registerState:n})}(e,n,i)}register(t,e){this._signal=e;const n=this.state;n.id!==Z&&z(308,String(n.id),String(Z));const i=this.extension.register&&this.extension.register(t,n.config,n.registerState);return this.state=function(t){return Object.assign(t,{id:V})}(n),()=>{const t=this.state;t.id!==J&&z(309,String(n.id),String(J)),this.state=function(t){return Object.assign(t,{id:Z})}(t),i&&i()}}afterRegistration(t){const e=this.state;let n;return e.id!==V&&z(310,String(e.id),String(V)),this.extension.afterRegistration&&(n=this.extension.afterRegistration(t,e.config,e.registerState)),this.state=function(t){return Object.assign(t,{id:J})}(e),n}getSignal(){return void 0===this._signal&&z(311),this._signal}getInitResult(){void 0===this.extension.init&&z(312,this.extension.name);const t=this.state;return function(t){return t.id>=G}(t)||z(313,String(t.id),String(G)),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>=W}(t)||z(314,String(t.id),String(W)),{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&&z(315,this.extension.name,t.name),e.getExtensionInitDependency()}getDependency(t){const e=this.builder.getExtensionRep(t);return void 0===e&&z(315,this.extension.name,t.name),e.getExtensionDependency()}getState(){const t=this.state;return function(t){return t.id>=J}(t)||z(316,String(t.id),String(J)),t}getDirectDependentNames(){return this.builder.incomingEdges.get(this.extension.name)||tt}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>=Z})(t)||z(317,this.extension.name),this._dependency={config:t.config,init:t.initResult,output:t.output}}return this._dependency}}const nt={tag:t.HISTORY_MERGE_TAG};function it(){const e=t.$getRoot();e.isEmpty()&&e.append(t.$createParagraphNode())}const ot=t.defineExtension({config:t.safeCast({setOptions:nt,updateOptions:nt}),init:({$initialEditorState:t=it})=>({$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]}),st=Symbol.for("@lexical/extension/LexicalBuilder");function rt(){}function at(t){throw t}function ct(t){return Array.isArray(t)?t:[t]}const dt="0.44.0+prod.cjs";class lt{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=dt,this.roots=t;for(const e of t)this.addExtension(e)}static fromExtensions(t){const e=[ct(ot)];for(const n of t)e.push(ct(n));return new lt(e)}static maybeFromEditor(t){const e=t[st];return e&&(e.PACKAGE_VERSION!==dt&&z(292,e.PACKAGE_VERSION,dt),e instanceof lt||z(293)),e}static fromEditor(t){const e=lt.maybeFromEditor(t);return void 0===e&&z(294),e}constructEditor(){const{$initialEditorState:e,onError:n,...i}=this.buildCreateEditorArgs(),o=Object.assign(t.createEditor({...i,...n?{onError:t=>{n(t,o)}}:{}}),{[st]:this});for(const t of this.sortedExtensionReps())t.build(o);return o}buildEditor(){let e=rt;function n(){try{e()}finally{e=rt}}const i=Object.assign(this.constructEditor(),{dispose:n,[Symbol.dispose]:n});return e=t.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&&z(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&&z(296);const e=ct(t),[n]=e;"string"!=typeof n.name&&z(297,typeof n.name);let i=this.extensionNameMap.get(n.name);if(void 0!==i&&i.extension!==n&&z(298,n.name),!i){i=new et(this,n),this.extensionNameMap.set(n.name,i);const t=this.conflicts.get(n.name);"string"==typeof t&&z(299,n.name,t);for(const t of n.conflictsWith||[])this.extensionNameMap.has(t)&&z(299,n.name,t),this.conflicts.set(t,n.name);for(const t of n.dependencies||[]){const e=ct(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(q(o))return;const s=n.extension.name;var r;X(o)||z(300,s,i||"[unknown]"),X(r=o)||z(304,String(r.id),String(U)),o=Object.assign(r,{id:Y}),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=Q(o),n.state=o,t.push(n)};for(const t of this.extensionNameMap.values())X(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&&z(301,t.name);for(const t of e)n.configs.add(t)}return this._sortedExtensionReps=t,this._sortedExtensionReps}registerEditor(e){const n=this.sortedExtensionReps(),i=new AbortController,o=[()=>i.abort()],s=i.signal;for(const t of n){const n=t.register(e,s);n&&o.push(n)}for(const t of n){const n=t.afterRegistration(e);n&&o.push(n)}return t.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 I(r)){if("function"!=typeof t){const e=n.get(t.replace);e&&z(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&&B(s,r.theme)}Object.keys(s).length>0&&(t.theme=s),e.size&&(t.nodes=[...e]);const a=Object.keys(o).length>0,c=i.size>0;(a||c)&&(t.html={},a&&(t.html.import=o),c&&(t.html.export=i));for(const e of r)e.init(t);return t.onError||(t.onError=at),t}}function ut(t,e){const n=lt.maybeFromEditor(t);if(!n)return;const i=n.extensionNameMap.get(e);return i?i.getExtensionDependency():void 0}const ft=new Set,ht=t.defineExtension({build(e,n,i){const o=i.getDependency(K).output,s=m({watchedNodeKeys:new Map}),r=L(()=>{},()=>C(()=>{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),c=r&&r.isSelected()||!1;a=a||c!==(!!e&&e.has(o)),c&&(i=i||new Set,i.add(o))}}),!a&&i&&e&&i.size===e.size||(r.value=i)}));return{watchNodeKey:function(t){const e=y(()=>(r.value||ft).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:[K],name:"@lexical/extension/NodeSelection"}),gt=t.createCommand("INSERT_HORIZONTAL_RULE_COMMAND");class pt extends t.DecoratorNode{static getType(){return"horizontalrule"}static clone(t){return new pt(t.__key)}static importJSON(t){return xt().updateFromJSON(t)}static importDOM(){return{hr:()=>({conversion:mt,priority:0})}}exportDOM(){return{element:document.createElement("hr")}}createDOM(e){const n=document.createElement("hr");return t.addClassNamesToElement(n,e.theme.hr),n}getTextContent(){return"\n"}isInline(){return!1}updateDOM(){return!1}}function mt(){return{node:xt()}}function xt(){return t.$create(pt)}function Et(t){return t instanceof pt}const vt=t.defineExtension({dependencies:[K,ht],name:"@lexical/extension/HorizontalRule",nodes:()=>[pt],register(n,i,s){const{watchNodeKey:r}=s.getDependency(ht).output,a=m({nodeSelections:new Map}),c=n._config.theme.hrSelected??"selected";return t.mergeRegister(n.registerCommand(gt,n=>{const i=t.$getSelection();if(!t.$isRangeSelection(i))return!1;if(null!==i.focus.getNode()){const t=xt();e.$insertNodeToNearestRoot(t)}return!0},t.COMMAND_PRIORITY_EDITOR),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(pt,(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:m(s),selectedSignal:r(o)}))}e&&(a.value={nodeSelections:i})})}),C(()=>{const e=[];for(const{domNode:n,selectedSignal:i}of a.value.nodeSelections.values())e.push(C(()=>{const e=n.value;if(e){i.value?t.addClassNamesToElement(e,c):t.removeClassNamesFromElement(e,c)}}));return t.mergeRegister(...e)}))}});const St=t.defineExtension({build:(t,e)=>D({inheritEditableFromParent:e.inheritEditableFromParent}),config:t.safeCast({$getParentEditor:function(){const e=t.$getEditor();return lt.fromEditor(e),e},inheritEditableFromParent:!1}),init:(t,e,n)=>{const i=e.$getParentEditor();t.parentEditor=i,t.theme=t.theme||i._config.theme},name:"@lexical/extension/NestedEditor",register:(t,e,n)=>C(()=>{const e=t._parentEditor;if(e&&n.getOutput().inheritEditableFromParent.value)return t.setEditable(e.isEditable()),e.registerEditableListener(t.setEditable.bind(t))})}),yt=t.defineExtension({build:(t,e,n)=>D(e),config:t.safeCast({disabled:!1,onReposition:void 0}),name:"@lexical/utils/SelectionAlwaysOnDisplay",register:(t,n,i)=>{const o=i.getOutput();return C(()=>{if(!o.disabled.value)return e.selectionAlwaysOnDisplay(t,o.onReposition.value)})}});function Nt(t){return t.canBeEmpty()}function bt(n,i,o=Nt){return t.mergeRegister(n.registerCommand(t.KEY_TAB_COMMAND,i=>{const o=t.$getSelection();if(!t.$isRangeSelection(o))return!1;i.preventDefault();const s=function(n){if(n.getNodes().filter(e=>t.$isBlockElementNode(e)&&e.canIndent()).length>0)return!0;const i=n.anchor,o=n.focus,s=o.isBefore(i)?o:i,r=s.getNode(),a=e.$getNearestBlockElementAncestorOrThrow(r);if(a.canIndent()){const e=a.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(s))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,s=t.$getSelection();if(!t.$isRangeSelection(s))return!1;const r="function"==typeof o?o:o.peek();return e.$handleIndentAndOutdent(t=>{if(r(t)){const e=t.getIndent()+1;(!n||e<n)&&t.setIndent(e)}})},t.COMMAND_PRIORITY_CRITICAL))}const Ot=t.defineExtension({build:(t,e,n)=>D(e),config:t.safeCast({$canIndent:Nt,disabled:!1,maxIndent:null}),name:"@lexical/extension/TabIndentation",register(t,e,n){const{disabled:i,maxIndent:o,$canIndent:s}=n.getOutput();return C(()=>{if(!i.value)return bt(t,o,s)})}});exports.configExtension=t.configExtension,exports.declarePeerDependency=t.declarePeerDependency,exports.defineExtension=t.defineExtension,exports.safeCast=t.safeCast,exports.shallowMergeConfig=t.shallowMergeConfig,exports.$createHorizontalRuleNode=xt,exports.$isDecoratorTextNode=F,exports.$isHorizontalRuleNode=Et,exports.AutoFocusExtension=M,exports.ClearEditorExtension=T,exports.DecoratorTextExtension=j,exports.DecoratorTextNode=A,exports.EditorStateExtension=K,exports.HorizontalRuleExtension=vt,exports.HorizontalRuleNode=pt,exports.INSERT_HORIZONTAL_RULE_COMMAND=gt,exports.InitialStateExtension=ot,exports.LexicalBuilder=lt,exports.NestedEditorExtension=St,exports.NodeSelectionExtension=ht,exports.SelectionAlwaysOnDisplayExtension=yt,exports.TabIndentationExtension=Ot,exports.applyFormatFromStyle=function(t,e,n){const i=e.fontWeight,o=e.textDecoration.split(" "),s="700"===i||"bold"===i,r=o.includes("line-through"),a="italic"===e.fontStyle,c=o.includes("underline"),d=e.verticalAlign;return s&&!t.hasFormat("bold")&&t.toggleFormat("bold"),r&&!t.hasFormat("strikethrough")&&t.toggleFormat("strikethrough"),a&&!t.hasFormat("italic")&&t.toggleFormat("italic"),c&&!t.hasFormat("underline")&&t.toggleFormat("underline"),"sub"!==d||t.hasFormat("subscript")||t.toggleFormat("subscript"),"super"!==d||t.hasFormat("superscript")||t.toggleFormat("superscript"),n&&!t.hasFormat(n)&&t.toggleFormat(n),t},exports.applyFormatToDom=function(t,e,n=k){for(const[i,o]of Object.entries(n))t.hasFormat(o)&&(e=P(e,i));return e},exports.batch=o,exports.buildEditorFromExtensions=function(...t){return lt.fromExtensions(t).buildEditor()},exports.computed=y,exports.effect=C,exports.getExtensionDependencyFromEditor=function(t,e){const n=lt.fromEditor(t).getExtensionRep(e);return void 0===n&&z(303,e.name),n.getExtensionDependency()},exports.getKnownTypesAndNodes=function(e){const n=new Set,i=new Set;for(const o of I(e)){const e="function"==typeof o?o:o.replace;t.getStaticNodeConfig(e),n.add(e.getType()),i.add(e)}return{nodes:i,types:n}},exports.getPeerDependencyFromEditor=ut,exports.getPeerDependencyFromEditorOrThrow=function(t,e){const n=ut(t,e);return void 0===n&&z(291,e),n},exports.namedSignals=D,exports.registerClearEditor=_,exports.registerTabIndentation=bt,exports.signal=m,exports.untracked=a,exports.watchedSignal=L;
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(!function(){let t=c;for(c=void 0;void 0!==t;)t.S.v===t.v&&(t.S.i=t.i),t=t.o}();void 0!==r;){let n=r;for(r=void 0,l++;void 0!==n;){const i=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&x(n))try{n.c()}catch(n){e||(t=n,e=!0)}n=i}}if(l=0,d--,e)throw t}function o(t){if(d>0)return t();f=++u,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 c,d=0,l=0,u=0,f=0,h=0;function g(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 p(t,e){this.v=t,this.i=0,this.n=void 0,this.t=void 0,this.l=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 m(t,e){return new p(t,e)}function x(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 E(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 v(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 S(t,e){p.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 y(t,e){return new S(t,e)}function N(t){const e=t.m;if(t.m=void 0,"function"==typeof e){d++;const n=s;s=void 0;try{e()}catch(e){throw t.f&=-2,t.f|=8,b(t),e}finally{s=n,i()}}}function b(t){for(let e=t.s;void 0!==e;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,N(t)}function O(t){if(s!==this)throw new Error("Out-of-order effect");v(this),s=t,this.f&=-2,8&this.f&&b(this),i()}function R(t,e){this.x=t,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=null==e?void 0:e.name}function C(t,e){const n=new R(t,e);try{n.c()}catch(t){throw n.d(),t}const i=n.d.bind(n);return i[Symbol.dispose]=i,i}function D(t,e={}){const n={};for(const i in t){const o=e[i],s=m(void 0===o?t[i]:o);n[i]=s}return n}p.prototype.brand=n,p.prototype.h=function(){return!0},p.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)}))},p.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)}))}},p.prototype.subscribe=function(t){return C(()=>{const e=this.value,n=s;s=void 0;try{t(e)}finally{s=n}},{name:"sub"})},p.prototype.valueOf=function(){return this.value},p.prototype.toString=function(){return this.value+""},p.prototype.toJSON=function(){return this.value},p.prototype.peek=function(){const t=s;s=void 0;try{return this.value}finally{s=t}},Object.defineProperty(p.prototype,"value",{get(){const t=g(this);return void 0!==t&&(t.i=this.i),this.v},set(t){if(t!==this.v){if(l>100)throw new Error("Cycle detected");!function(t){0!==d&&0===l&&t.l!==f&&(t.l=f,c={S:t,v:t.v,i:t.i,o:c})}(this),this.v=t,this.i++,h++,d++;try{for(let t=this.t;void 0!==t;t=t.x)t.t.N()}finally{i()}}}}),S.prototype=new p,S.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&&!x(this))return this.f&=-2,!0;const t=s;try{E(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,v(this),this.f&=-2,!0},S.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)}p.prototype.S.call(this,t)},S.prototype.U=function(t){if(void 0!==this.t&&(p.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)}},S.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(S.prototype,"value",{get(){if(1&this.f)throw new Error("Cycle detected");const t=g(this);if(this.h(),void 0!==t&&(t.i=this.i),16&this.f)throw this.v;return this.v}}),R.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.m=t)}finally{t()}},R.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,N(this),E(this),d++;const t=s;return s=this,O.bind(this,t)},R.prototype.N=function(){2&this.f||(this.f|=2,this.u=r,r=this)},R.prototype.d=function(){this.f|=8,1&this.f||b(this)},R.prototype.dispose=function(){this.d()};const M=t.defineExtension({build:(t,e,n)=>D(e),config:t.safeCast({defaultSelection:"rootEnd",disabled:!1}),name:"@lexical/extension/AutoFocus",register(t,e,n){const i=n.getOutput();return C(()=>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 _(e,n=w){return e.registerCommand(t.CLEAR_EDITOR_COMMAND,t=>(e.update(n),!0),t.COMMAND_PRIORITY_EDITOR)}const T=t.defineExtension({build:(t,e,n)=>D(e),config:t.safeCast({$onClear:w}),name:"@lexical/extension/ClearEditor",register(t,e,n){const{$onClear:i}=n.getOutput();return C(()=>_(t,i.value))}});function I(t){return("function"==typeof t.nodes?t.nodes():t.nodes)||[]}const $=t.createState("format",{parse:t=>"number"==typeof t?t:0});class A extends t.DecoratorNode{$config(){return this.config("decorator-text",{extends:t.DecoratorNode,stateConfigs:[{flat:!0,stateConfig:$}]})}getFormat(){return t.$getState(this,$)}getFormatFlags(e,n){return t.toggleTextFormatType(this.getFormat(),e,n)}hasFormat(e){const n=t.TEXT_TYPE_TO_FORMAT[e];return 0!==(this.getFormat()&n)}setFormat(e){return t.$setState(this,$,e)}toggleFormat(e){const n=this.getFormat(),i=t.toggleTextFormatType(n,e,null);return this.setFormat(i)}isInline(){return!0}createDOM(){return document.createElement("span")}updateDOM(){return!1}}function F(t){return t instanceof A}function P(t,e){const n=document.createElement(e);return n.appendChild(t),n}const k={b:"bold",code:"code",em:"italic",i:"italic",mark:"highlight",s:"strikethrough",strong:"bold",sub:"subscript",sup:"superscript",u:"underline"},j=t.defineExtension({name:"@lexical/extension/DecoratorText",nodes:()=>[A],register:(e,n,i)=>e.registerCommand(t.FORMAT_TEXT_COMMAND,e=>{const n=t.$getSelection();if(t.$isNodeSelection(n)||t.$isRangeSelection(n))for(const t of n.getNodes())F(t)&&t.toggleFormat(e);return!1},t.COMMAND_PRIORITY_LOW)});function L(t,e){let n;return m(t(),{unwatched(){n&&(n(),n=void 0)},watched(){this.value=t(),n=e(this)}})}const K=t.defineExtension({build:t=>L(()=>t.getEditorState(),e=>t.registerUpdateListener(t=>{e.value=t.editorState})),name:"@lexical/extension/EditorState"});function z(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 B(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]=B(n[t],i[t]);return t}return e}const U=0,Y=1,H=2,W=3,G=4,Z=5,V=6,J=7;function X(t){return t.id===U}function q(t){return t.id===H}function Q(t){return function(t){return t.id===Y}(t)||z(305,String(t.id),String(Y)),Object.assign(t,{id:H})}const tt=new Set;class et{builder;configs;_dependency;_peerNameSet;extension;state;_signal;constructor(t,e){this.builder=t,this.extension=e,this.configs=new Set,this.state={id:U}}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;q(e)||z(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:W,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:G,initResult:e,registerState:n})}(o,s,i)}build(t){const e=this.state;let n;e.id!==G&&z(307,String(e.id),String(Z)),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:Z,output:e,registerState:n})}(e,n,i)}register(t,e){this._signal=e;const n=this.state;n.id!==Z&&z(308,String(n.id),String(Z));const i=this.extension.register&&this.extension.register(t,n.config,n.registerState);return this.state=function(t){return Object.assign(t,{id:V})}(n),()=>{const t=this.state;t.id!==J&&z(309,String(n.id),String(J)),this.state=function(t){return Object.assign(t,{id:Z})}(t),i&&i()}}afterRegistration(t){const e=this.state;let n;return e.id!==V&&z(310,String(e.id),String(V)),this.extension.afterRegistration&&(n=this.extension.afterRegistration(t,e.config,e.registerState)),this.state=function(t){return Object.assign(t,{id:J})}(e),n}getSignal(){return void 0===this._signal&&z(311),this._signal}getInitResult(){void 0===this.extension.init&&z(312,this.extension.name);const t=this.state;return function(t){return t.id>=G}(t)||z(313,String(t.id),String(G)),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>=W}(t)||z(314,String(t.id),String(W)),{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&&z(315,this.extension.name,t.name),e.getExtensionInitDependency()}getDependency(t){const e=this.builder.getExtensionRep(t);return void 0===e&&z(315,this.extension.name,t.name),e.getExtensionDependency()}getState(){const t=this.state;return function(t){return t.id>=J}(t)||z(316,String(t.id),String(J)),t}getDirectDependentNames(){return this.builder.incomingEdges.get(this.extension.name)||tt}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>=Z})(t)||z(317,this.extension.name),this._dependency={config:t.config,init:t.initResult,output:t.output}}return this._dependency}}const nt={tag:t.HISTORY_MERGE_TAG};function it(){const e=t.$getRoot();e.isEmpty()&&e.append(t.$createParagraphNode())}const ot=t.defineExtension({config:t.safeCast({setOptions:nt,updateOptions:nt}),init:({$initialEditorState:t=it})=>({$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]}),st=Symbol.for("@lexical/extension/LexicalBuilder");function rt(){}function at(t){throw t}function ct(t){return Array.isArray(t)?t:[t]}const dt="0.44.1-nightly.20260428.0+prod.cjs";class lt{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=dt,this.roots=t;for(const e of t)this.addExtension(e)}static fromExtensions(t){const e=[ct(ot)];for(const n of t)e.push(ct(n));return new lt(e)}static maybeFromEditor(t){const e=t[st];return e&&(e.PACKAGE_VERSION!==dt&&z(292,e.PACKAGE_VERSION,dt),e instanceof lt||z(293)),e}static fromEditor(t){const e=lt.maybeFromEditor(t);return void 0===e&&z(294),e}constructEditor(){const{$initialEditorState:e,onError:n,...i}=this.buildCreateEditorArgs(),o=Object.assign(t.createEditor({...i,...n?{onError:t=>{n(t,o)}}:{}}),{[st]:this});for(const t of this.sortedExtensionReps())t.build(o);return o}buildEditor(){let e=rt;function n(){try{e()}finally{e=rt}}const i=Object.assign(this.constructEditor(),{dispose:n,[Symbol.dispose]:n});return e=t.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&&z(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&&z(296);const e=ct(t),[n]=e;"string"!=typeof n.name&&z(297,typeof n.name);let i=this.extensionNameMap.get(n.name);if(void 0!==i&&i.extension!==n&&z(298,n.name),!i){i=new et(this,n),this.extensionNameMap.set(n.name,i);const t=this.conflicts.get(n.name);"string"==typeof t&&z(299,n.name,t);for(const t of n.conflictsWith||[])this.extensionNameMap.has(t)&&z(299,n.name,t),this.conflicts.set(t,n.name);for(const t of n.dependencies||[]){const e=ct(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(q(o))return;const s=n.extension.name;var r;X(o)||z(300,s,i||"[unknown]"),X(r=o)||z(304,String(r.id),String(U)),o=Object.assign(r,{id:Y}),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=Q(o),n.state=o,t.push(n)};for(const t of this.extensionNameMap.values())X(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&&z(301,t.name);for(const t of e)n.configs.add(t)}return this._sortedExtensionReps=t,this._sortedExtensionReps}registerEditor(e){const n=this.sortedExtensionReps(),i=new AbortController,o=[()=>i.abort()],s=i.signal;for(const t of n){const n=t.register(e,s);n&&o.push(n)}for(const t of n){const n=t.afterRegistration(e);n&&o.push(n)}return t.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 I(r)){if("function"!=typeof t){const e=n.get(t.replace);e&&z(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&&B(s,r.theme)}Object.keys(s).length>0&&(t.theme=s),e.size&&(t.nodes=[...e]);const a=Object.keys(o).length>0,c=i.size>0;(a||c)&&(t.html={},a&&(t.html.import=o),c&&(t.html.export=i));for(const e of r)e.init(t);return t.onError||(t.onError=at),t}}function ut(t,e){const n=lt.maybeFromEditor(t);if(!n)return;const i=n.extensionNameMap.get(e);return i?i.getExtensionDependency():void 0}const ft=new Set,ht=t.defineExtension({build(e,n,i){const o=i.getDependency(K).output,s=m({watchedNodeKeys:new Map}),r=L(()=>{},()=>C(()=>{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),c=r&&r.isSelected()||!1;a=a||c!==(!!e&&e.has(o)),c&&(i=i||new Set,i.add(o))}}),!a&&i&&e&&i.size===e.size||(r.value=i)}));return{watchNodeKey:function(t){const e=y(()=>(r.value||ft).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:[K],name:"@lexical/extension/NodeSelection"}),gt=t.createCommand("INSERT_HORIZONTAL_RULE_COMMAND");class pt extends t.DecoratorNode{static getType(){return"horizontalrule"}static clone(t){return new pt(t.__key)}static importJSON(t){return xt().updateFromJSON(t)}static importDOM(){return{hr:()=>({conversion:mt,priority:0})}}exportDOM(){return{element:document.createElement("hr")}}createDOM(e){const n=document.createElement("hr");return t.addClassNamesToElement(n,e.theme.hr),n}getTextContent(){return"\n"}isInline(){return!1}updateDOM(){return!1}}function mt(){return{node:xt()}}function xt(){return t.$create(pt)}function Et(t){return t instanceof pt}const vt=t.defineExtension({dependencies:[K,ht],name:"@lexical/extension/HorizontalRule",nodes:()=>[pt],register(n,i,s){const{watchNodeKey:r}=s.getDependency(ht).output,a=m({nodeSelections:new Map}),c=n._config.theme.hrSelected??"selected";return t.mergeRegister(n.registerCommand(gt,n=>{const i=t.$getSelection();if(!t.$isRangeSelection(i))return!1;if(null!==i.focus.getNode()){const t=xt();e.$insertNodeToNearestRoot(t)}return!0},t.COMMAND_PRIORITY_EDITOR),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(pt,(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:m(s),selectedSignal:r(o)}))}e&&(a.value={nodeSelections:i})})}),C(()=>{const e=[];for(const{domNode:n,selectedSignal:i}of a.value.nodeSelections.values())e.push(C(()=>{const e=n.value;if(e){i.value?t.addClassNamesToElement(e,c):t.removeClassNamesFromElement(e,c)}}));return t.mergeRegister(...e)}))}});const St=t.defineExtension({build:(t,e)=>D({inheritEditableFromParent:e.inheritEditableFromParent}),config:t.safeCast({$getParentEditor:function(){const e=t.$getEditor();return lt.fromEditor(e),e},inheritEditableFromParent:!1}),init:(t,e,n)=>{const i=e.$getParentEditor();t.parentEditor=i,t.theme=t.theme||i._config.theme},name:"@lexical/extension/NestedEditor",register:(t,e,n)=>C(()=>{const e=t._parentEditor;if(e&&n.getOutput().inheritEditableFromParent.value)return t.setEditable(e.isEditable()),e.registerEditableListener(t.setEditable.bind(t))})}),yt=t.defineExtension({build:(t,e,n)=>D(e),config:t.safeCast({disabled:!1,onReposition:void 0}),name:"@lexical/utils/SelectionAlwaysOnDisplay",register:(t,n,i)=>{const o=i.getOutput();return C(()=>{if(!o.disabled.value)return e.selectionAlwaysOnDisplay(t,o.onReposition.value)})}});function Nt(t){return t.canBeEmpty()}function bt(n,i,o=Nt){return t.mergeRegister(n.registerCommand(t.KEY_TAB_COMMAND,i=>{const o=t.$getSelection();if(!t.$isRangeSelection(o))return!1;i.preventDefault();const s=function(n){if(n.getNodes().filter(e=>t.$isBlockElementNode(e)&&e.canIndent()).length>0)return!0;const i=n.anchor,o=n.focus,s=o.isBefore(i)?o:i,r=s.getNode(),a=e.$getNearestBlockElementAncestorOrThrow(r);if(a.canIndent()){const e=a.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(s))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,s=t.$getSelection();if(!t.$isRangeSelection(s))return!1;const r="function"==typeof o?o:o.peek();return e.$handleIndentAndOutdent(t=>{if(r(t)){const e=t.getIndent()+1;(!n||e<n)&&t.setIndent(e)}})},t.COMMAND_PRIORITY_CRITICAL))}const Ot=t.defineExtension({build:(t,e,n)=>D(e),config:t.safeCast({$canIndent:Nt,disabled:!1,maxIndent:null}),name:"@lexical/extension/TabIndentation",register(t,e,n){const{disabled:i,maxIndent:o,$canIndent:s}=n.getOutput();return C(()=>{if(!i.value)return bt(t,o,s)})}});exports.configExtension=t.configExtension,exports.declarePeerDependency=t.declarePeerDependency,exports.defineExtension=t.defineExtension,exports.safeCast=t.safeCast,exports.shallowMergeConfig=t.shallowMergeConfig,exports.$createHorizontalRuleNode=xt,exports.$isDecoratorTextNode=F,exports.$isHorizontalRuleNode=Et,exports.AutoFocusExtension=M,exports.ClearEditorExtension=T,exports.DecoratorTextExtension=j,exports.DecoratorTextNode=A,exports.EditorStateExtension=K,exports.HorizontalRuleExtension=vt,exports.HorizontalRuleNode=pt,exports.INSERT_HORIZONTAL_RULE_COMMAND=gt,exports.InitialStateExtension=ot,exports.LexicalBuilder=lt,exports.NestedEditorExtension=St,exports.NodeSelectionExtension=ht,exports.SelectionAlwaysOnDisplayExtension=yt,exports.TabIndentationExtension=Ot,exports.applyFormatFromStyle=function(t,e,n){const i=e.fontWeight,o=e.textDecoration.split(" "),s="700"===i||"bold"===i,r=o.includes("line-through"),a="italic"===e.fontStyle,c=o.includes("underline"),d=e.verticalAlign;return s&&!t.hasFormat("bold")&&t.toggleFormat("bold"),r&&!t.hasFormat("strikethrough")&&t.toggleFormat("strikethrough"),a&&!t.hasFormat("italic")&&t.toggleFormat("italic"),c&&!t.hasFormat("underline")&&t.toggleFormat("underline"),"sub"!==d||t.hasFormat("subscript")||t.toggleFormat("subscript"),"super"!==d||t.hasFormat("superscript")||t.toggleFormat("superscript"),n&&!t.hasFormat(n)&&t.toggleFormat(n),t},exports.applyFormatToDom=function(t,e,n=k){for(const[i,o]of Object.entries(n))t.hasFormat(o)&&(e=P(e,i));return e},exports.batch=o,exports.buildEditorFromExtensions=function(...t){return lt.fromExtensions(t).buildEditor()},exports.computed=y,exports.effect=C,exports.getExtensionDependencyFromEditor=function(t,e){const n=lt.fromEditor(t).getExtensionRep(e);return void 0===n&&z(303,e.name),n.getExtensionDependency()},exports.getKnownTypesAndNodes=function(e){const n=new Set,i=new Set;for(const o of I(e)){const e="function"==typeof o?o:o.replace;t.getStaticNodeConfig(e),n.add(e.getType()),i.add(e)}return{nodes:i,types:n}},exports.getPeerDependencyFromEditor=ut,exports.getPeerDependencyFromEditorOrThrow=function(t,e){const n=ut(t,e);return void 0===n&&z(291,e),n},exports.namedSignals=D,exports.registerClearEditor=_,exports.registerTabIndentation=bt,exports.signal=m,exports.untracked=a,exports.watchedSignal=L;
@@ -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,getStaticNodeConfig as a,FORMAT_TEXT_COMMAND as d,$isNodeSelection as u,COMMAND_PRIORITY_LOW as f,DecoratorNode as l,$getState as h,toggleTextFormatType as g,$setState as p,TEXT_TYPE_TO_FORMAT as m,createState as v,shallowMergeConfig as x,RootNode as y,TextNode as E,LineBreakNode as S,TabNode as b,ParagraphNode as w,$isEditorState as N,HISTORY_MERGE_TAG as O,createEditor as R,mergeRegister as C,$getNodeByKey as D,$create as F,CLICK_COMMAND as M,isDOMNode as I,$getNodeFromDOMNode as _,addClassNamesToElement as P,createCommand as A,$createNodeSelection as j,$setSelection as k,removeClassNamesFromElement as $,$getEditor as K,KEY_TAB_COMMAND as z,OUTDENT_CONTENT_COMMAND as L,INDENT_CONTENT_COMMAND as U,INSERT_TAB_COMMAND as T,COMMAND_PRIORITY_CRITICAL as B,$isBlockElementNode as W,$createRangeSelection as G,$normalizeSelection__EXPERIMENTAL as V}from"lexical";export{configExtension,declarePeerDependency,defineExtension,safeCast,shallowMergeConfig}from"lexical";import{$insertNodeToNearestRoot as Z,selectionAlwaysOnDisplay as J,$handleIndentAndOutdent as H,$getNearestBlockElementAncestorOrThrow as q}from"@lexical/utils";const Q=Symbol.for("preact-signals");function X(){if(ot>1)return void ot--;let t,e=!1;for(!function(){let t=it;for(it=void 0;void 0!==t;)t.S.v===t.v&&(t.S.i=t.i),t=t.o}();void 0!==et;){let n=et;for(et=void 0,st++;void 0!==n;){const i=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&lt(n))try{n.c()}catch(n){e||(t=n,e=!0)}n=i}}if(st=0,ot--,e)throw t}function Y(t){if(ot>0)return t();ct=++rt,ot++;try{return t()}finally{X()}}let tt,et;function nt(t){const e=tt;tt=void 0;try{return t()}finally{tt=e}}let it,ot=0,st=0,rt=0,ct=0,at=0;function dt(t){if(void 0===tt)return;let e=t.n;return void 0===e||e.t!==tt?(e={i:0,S:t,p:tt.s,n:void 0,t:tt,e:void 0,x:void 0,r:e},void 0!==tt.s&&(tt.s.n=e),tt.s=e,t.n=e,32&tt.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=tt.s,e.n=void 0,tt.s.n=e,tt.s=e),e):void 0}function ut(t,e){this.v=t,this.i=0,this.n=void 0,this.t=void 0,this.l=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 ft(t,e){return new ut(t,e)}function lt(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 ht(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 gt(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 pt(t,e){ut.call(this,void 0),this.x=t,this.s=void 0,this.g=at-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 mt(t,e){return new pt(t,e)}function vt(t){const e=t.m;if(t.m=void 0,"function"==typeof e){ot++;const n=tt;tt=void 0;try{e()}catch(e){throw t.f&=-2,t.f|=8,xt(t),e}finally{tt=n,X()}}}function xt(t){for(let e=t.s;void 0!==e;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,vt(t)}function yt(t){if(tt!==this)throw new Error("Out-of-order effect");gt(this),tt=t,this.f&=-2,8&this.f&&xt(this),X()}function Et(t,e){this.x=t,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=null==e?void 0:e.name}function St(t,e){const n=new Et(t,e);try{n.c()}catch(t){throw n.d(),t}const i=n.d.bind(n);return i[Symbol.dispose]=i,i}function bt(t,e={}){const n={};for(const i in t){const o=e[i],s=ft(void 0===o?t[i]:o);n[i]=s}return n}ut.prototype.brand=Q,ut.prototype.h=function(){return!0},ut.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:nt(()=>{var t;null==(t=this.W)||t.call(this)}))},ut.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&&nt(()=>{var t;null==(t=this.Z)||t.call(this)}))}},ut.prototype.subscribe=function(t){return St(()=>{const e=this.value,n=tt;tt=void 0;try{t(e)}finally{tt=n}},{name:"sub"})},ut.prototype.valueOf=function(){return this.value},ut.prototype.toString=function(){return this.value+""},ut.prototype.toJSON=function(){return this.value},ut.prototype.peek=function(){const t=tt;tt=void 0;try{return this.value}finally{tt=t}},Object.defineProperty(ut.prototype,"value",{get(){const t=dt(this);return void 0!==t&&(t.i=this.i),this.v},set(t){if(t!==this.v){if(st>100)throw new Error("Cycle detected");!function(t){0!==ot&&0===st&&t.l!==ct&&(t.l=ct,it={S:t,v:t.v,i:t.i,o:it})}(this),this.v=t,this.i++,at++,ot++;try{for(let t=this.t;void 0!==t;t=t.x)t.t.N()}finally{X()}}}}),pt.prototype=new ut,pt.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===at)return!0;if(this.g=at,this.f|=1,this.i>0&&!lt(this))return this.f&=-2,!0;const t=tt;try{ht(this),tt=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 tt=t,gt(this),this.f&=-2,!0},pt.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)}ut.prototype.S.call(this,t)},pt.prototype.U=function(t){if(void 0!==this.t&&(ut.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)}},pt.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(pt.prototype,"value",{get(){if(1&this.f)throw new Error("Cycle detected");const t=dt(this);if(this.h(),void 0!==t&&(t.i=this.i),16&this.f)throw this.v;return this.v}}),Et.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.m=t)}finally{t()}},Et.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,vt(this),ht(this),ot++;const t=tt;return tt=this,yt.bind(this,t)},Et.prototype.N=function(){2&this.f||(this.f|=2,this.u=et,et=this)},Et.prototype.d=function(){this.f|=8,1&this.f||xt(this)},Et.prototype.dispose=function(){this.d()};const wt=t({build:(t,e,n)=>bt(e),config:e({defaultSelection:"rootEnd",disabled:!1}),name:"@lexical/extension/AutoFocus",register(t,e,n){const i=n.getOutput();return St(()=>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 Nt(){const t=o(),e=s(),n=r();t.clear(),t.append(n),null!==e&&n.select(),c(e)&&(e.format=0)}function Ot(t,e=Nt){return t.registerCommand(n,n=>(t.update(e),!0),i)}const Rt=t({build:(t,e,n)=>bt(e),config:e({$onClear:Nt}),name:"@lexical/extension/ClearEditor",register(t,e,n){const{$onClear:i}=n.getOutput();return St(()=>Ot(t,i.value))}});function Ct(t){const e=new Set,n=new Set;for(const i of Dt(t)){const t="function"==typeof i?i:i.replace;a(t),e.add(t.getType()),n.add(t)}return{nodes:n,types:e}}function Dt(t){return("function"==typeof t.nodes?t.nodes():t.nodes)||[]}const Ft=v("format",{parse:t=>"number"==typeof t?t:0});class Mt extends l{$config(){return this.config("decorator-text",{extends:l,stateConfigs:[{flat:!0,stateConfig:Ft}]})}getFormat(){return h(this,Ft)}getFormatFlags(t,e){return g(this.getFormat(),t,e)}hasFormat(t){const e=m[t];return 0!==(this.getFormat()&e)}setFormat(t){return p(this,Ft,t)}toggleFormat(t){const e=this.getFormat(),n=g(e,t,null);return this.setFormat(n)}isInline(){return!0}createDOM(){return document.createElement("span")}updateDOM(){return!1}}function It(t){return t instanceof Mt}function _t(t,e,n){const i=e.fontWeight,o=e.textDecoration.split(" "),s="700"===i||"bold"===i,r=o.includes("line-through"),c="italic"===e.fontStyle,a=o.includes("underline"),d=e.verticalAlign;return s&&!t.hasFormat("bold")&&t.toggleFormat("bold"),r&&!t.hasFormat("strikethrough")&&t.toggleFormat("strikethrough"),c&&!t.hasFormat("italic")&&t.toggleFormat("italic"),a&&!t.hasFormat("underline")&&t.toggleFormat("underline"),"sub"!==d||t.hasFormat("subscript")||t.toggleFormat("subscript"),"super"!==d||t.hasFormat("superscript")||t.toggleFormat("superscript"),n&&!t.hasFormat(n)&&t.toggleFormat(n),t}function Pt(t,e,n=jt){for(const[i,o]of Object.entries(n))t.hasFormat(o)&&(e=At(e,i));return e}function At(t,e){const n=document.createElement(e);return n.appendChild(t),n}const jt={b:"bold",code:"code",em:"italic",i:"italic",mark:"highlight",s:"strikethrough",strong:"bold",sub:"subscript",sup:"superscript",u:"underline"},kt=t({name:"@lexical/extension/DecoratorText",nodes:()=>[Mt],register:(t,e,n)=>t.registerCommand(d,t=>{const e=s();if(u(e)||c(e))for(const n of e.getNodes())It(n)&&n.toggleFormat(t);return!1},f)});function $t(t,e){let n;return ft(t(),{unwatched(){n&&(n(),n=void 0)},watched(){this.value=t(),n=e(this)}})}const Kt=t({build:t=>$t(()=>t.getEditorState(),e=>t.registerUpdateListener(t=>{e.value=t.editorState})),name:"@lexical/extension/EditorState"});function zt(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 Lt(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]=Lt(n[t],i[t]);return t}return e}const Ut=0,Tt=1,Bt=2,Wt=3,Gt=4,Vt=5,Zt=6,Jt=7;function Ht(t){return t.id===Ut}function qt(t){return t.id===Bt}function Qt(t){return function(t){return t.id===Tt}(t)||zt(305,String(t.id),String(Tt)),Object.assign(t,{id:Bt})}const Xt=new Set;class Yt{builder;configs;_dependency;_peerNameSet;extension;state;_signal;constructor(t,e){this.builder=t,this.extension=e,this.configs=new Set,this.state={id:Ut}}mergeConfigs(){let t=this.extension.config||{};const e=this.extension.mergeConfig?this.extension.mergeConfig.bind(this.extension):x;for(const n of this.configs)t=e(t,n);return t}init(t){const e=this.state;qt(e)||zt(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:Wt,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:Gt,initResult:e,registerState:n})}(o,s,i)}build(t){const e=this.state;let n;e.id!==Gt&&zt(307,String(e.id),String(Vt)),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:Vt,output:e,registerState:n})}(e,n,i)}register(t,e){this._signal=e;const n=this.state;n.id!==Vt&&zt(308,String(n.id),String(Vt));const i=this.extension.register&&this.extension.register(t,n.config,n.registerState);return this.state=function(t){return Object.assign(t,{id:Zt})}(n),()=>{const t=this.state;t.id!==Jt&&zt(309,String(n.id),String(Jt)),this.state=function(t){return Object.assign(t,{id:Vt})}(t),i&&i()}}afterRegistration(t){const e=this.state;let n;return e.id!==Zt&&zt(310,String(e.id),String(Zt)),this.extension.afterRegistration&&(n=this.extension.afterRegistration(t,e.config,e.registerState)),this.state=function(t){return Object.assign(t,{id:Jt})}(e),n}getSignal(){return void 0===this._signal&&zt(311),this._signal}getInitResult(){void 0===this.extension.init&&zt(312,this.extension.name);const t=this.state;return function(t){return t.id>=Gt}(t)||zt(313,String(t.id),String(Gt)),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>=Wt}(t)||zt(314,String(t.id),String(Wt)),{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&&zt(315,this.extension.name,t.name),e.getExtensionInitDependency()}getDependency(t){const e=this.builder.getExtensionRep(t);return void 0===e&&zt(315,this.extension.name,t.name),e.getExtensionDependency()}getState(){const t=this.state;return function(t){return t.id>=Jt}(t)||zt(316,String(t.id),String(Jt)),t}getDirectDependentNames(){return this.builder.incomingEdges.get(this.extension.name)||Xt}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>=Vt})(t)||zt(317,this.extension.name),this._dependency={config:t.config,init:t.initResult,output:t.output}}return this._dependency}}const te={tag:O};function ee(){const t=o();t.isEmpty()&&t.append(r())}const ne=t({config:e({setOptions:te,updateOptions:te}),init:({$initialEditorState:t=ee})=>({$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(N(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:[y,E,S,b,w]}),ie=Symbol.for("@lexical/extension/LexicalBuilder");function oe(...t){return de.fromExtensions(t).buildEditor()}function se(){}function re(t){throw t}function ce(t){return Array.isArray(t)?t:[t]}const ae="0.44.0+prod.esm";class de{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=ae,this.roots=t;for(const e of t)this.addExtension(e)}static fromExtensions(t){const e=[ce(ne)];for(const n of t)e.push(ce(n));return new de(e)}static maybeFromEditor(t){const e=t[ie];return e&&(e.PACKAGE_VERSION!==ae&&zt(292,e.PACKAGE_VERSION,ae),e instanceof de||zt(293)),e}static fromEditor(t){const e=de.maybeFromEditor(t);return void 0===e&&zt(294),e}constructEditor(){const{$initialEditorState:t,onError:e,...n}=this.buildCreateEditorArgs(),i=Object.assign(R({...n,...e?{onError:t=>{e(t,i)}}:{}}),{[ie]:this});for(const t of this.sortedExtensionReps())t.build(i);return i}buildEditor(){let t=se;function e(){try{t()}finally{t=se}}const n=Object.assign(this.constructEditor(),{dispose:e,[Symbol.dispose]:e});return t=C(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&&zt(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&&zt(296);const e=ce(t),[n]=e;"string"!=typeof n.name&&zt(297,typeof n.name);let i=this.extensionNameMap.get(n.name);if(void 0!==i&&i.extension!==n&&zt(298,n.name),!i){i=new Yt(this,n),this.extensionNameMap.set(n.name,i);const t=this.conflicts.get(n.name);"string"==typeof t&&zt(299,n.name,t);for(const t of n.conflictsWith||[])this.extensionNameMap.has(t)&&zt(299,n.name,t),this.conflicts.set(t,n.name);for(const t of n.dependencies||[]){const e=ce(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(qt(o))return;const s=n.extension.name;var r;Ht(o)||zt(300,s,i||"[unknown]"),Ht(r=o)||zt(304,String(r.id),String(Ut)),o=Object.assign(r,{id:Tt}),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=Qt(o),n.state=o,t.push(n)};for(const t of this.extensionNameMap.values())Ht(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&&zt(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 C(...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 Dt(r)){if("function"!=typeof t){const e=n.get(t.replace);e&&zt(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&&Lt(s,r.theme)}Object.keys(s).length>0&&(t.theme=s),e.size&&(t.nodes=[...e]);const c=Object.keys(o).length>0,a=i.size>0;(c||a)&&(t.html={},c&&(t.html.import=o),a&&(t.html.export=i));for(const e of r)e.init(t);return t.onError||(t.onError=re),t}}function ue(t,e){const n=de.fromEditor(t).getExtensionRep(e);return void 0===n&&zt(303,e.name),n.getExtensionDependency()}function fe(t,e){const n=de.maybeFromEditor(t);if(!n)return;const i=n.extensionNameMap.get(e);return i?i.getExtensionDependency():void 0}function le(t,e){const n=fe(t,e);return void 0===n&&zt(291,e),n}const he=new Set,ge=t({build(t,e,n){const i=n.getDependency(Kt).output,o=ft({watchedNodeKeys:new Map}),r=$t(()=>{},()=>St(()=>{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=D(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=mt(()=>(r.value||he).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:[Kt],name:"@lexical/extension/NodeSelection"}),pe=A("INSERT_HORIZONTAL_RULE_COMMAND");class me extends l{static getType(){return"horizontalrule"}static clone(t){return new me(t.__key)}static importJSON(t){return xe().updateFromJSON(t)}static importDOM(){return{hr:()=>({conversion:ve,priority:0})}}exportDOM(){return{element:document.createElement("hr")}}createDOM(t){const e=document.createElement("hr");return P(e,t.theme.hr),e}getTextContent(){return"\n"}isInline(){return!1}updateDOM(){return!1}}function ve(){return{node:xe()}}function xe(){return F(me)}function ye(t){return t instanceof me}const Ee=t({dependencies:[Kt,ge],name:"@lexical/extension/HorizontalRule",nodes:()=>[me],register(t,e,n){const{watchNodeKey:o}=n.getDependency(ge).output,r=ft({nodeSelections:new Map}),a=t._config.theme.hrSelected??"selected";return C(t.registerCommand(pe,t=>{const e=s();if(!c(e))return!1;if(null!==e.focus.getNode()){const t=xe();Z(t)}return!0},i),t.registerCommand(M,t=>{if(I(t.target)){const e=_(t.target);if(ye(e))return function(t,e=!1){const n=s(),i=t.isSelected(),o=t.getKey();let r;e&&u(n)?r=n:(r=j(),k(r)),i?r.delete(o):r.add(o)}(e,t.shiftKey),!0}return!1},f),t.registerMutationListener(me,(e,n)=>{Y(()=>{let n=!1;const{nodeSelections:i}=r.peek();for(const[s,r]of e.entries())if("destroyed"===r)i.delete(s),n=!0;else{const e=i.get(s),r=t.getElementByKey(s);e?e.domNode.value=r:(n=!0,i.set(s,{domNode:ft(r),selectedSignal:o(s)}))}n&&(r.value={nodeSelections:i})})}),St(()=>{const t=[];for(const{domNode:e,selectedSignal:n}of r.value.nodeSelections.values())t.push(St(()=>{const t=e.value;if(t){n.value?P(t,a):$(t,a)}}));return C(...t)}))}});const Se=t({build:(t,e)=>bt({inheritEditableFromParent:e.inheritEditableFromParent}),config:e({$getParentEditor:function(){const t=K();return de.fromEditor(t),t},inheritEditableFromParent:!1}),init:(t,e,n)=>{const i=e.$getParentEditor();t.parentEditor=i,t.theme=t.theme||i._config.theme},name:"@lexical/extension/NestedEditor",register:(t,e,n)=>St(()=>{const e=t._parentEditor;if(e&&n.getOutput().inheritEditableFromParent.value)return t.setEditable(e.isEditable()),e.registerEditableListener(t.setEditable.bind(t))})}),be=t({build:(t,e,n)=>bt(e),config:e({disabled:!1,onReposition:void 0}),name:"@lexical/utils/SelectionAlwaysOnDisplay",register:(t,e,n)=>{const i=n.getOutput();return St(()=>{if(!i.disabled.value)return J(t,i.onReposition.value)})}});function we(t){return t.canBeEmpty()}function Ne(t,e,n=we){return C(t.registerCommand(z,e=>{const n=s();if(!c(n))return!1;e.preventDefault();const i=function(t){if(t.getNodes().filter(t=>W(t)&&t.canIndent()).length>0)return!0;const e=t.anchor,n=t.focus,i=n.isBefore(e)?n:e,o=i.getNode(),s=q(o);if(s.canIndent()){const t=s.getKey();let e=G();if(e.anchor.set(t,0,"element"),e.focus.set(t,0,"element"),e=V(e),e.anchor.is(i))return!0}return!1}(n)?e.shiftKey?L:U:T;return t.dispatchCommand(i,void 0)},i),t.registerCommand(U,()=>{const t="number"==typeof e?e:e?e.peek():null,i=s();if(!c(i))return!1;const o="function"==typeof n?n:n.peek();return H(e=>{if(o(e)){const n=e.getIndent()+1;(!t||n<t)&&e.setIndent(n)}})},B))}const Oe=t({build:(t,e,n)=>bt(e),config:e({$canIndent:we,disabled:!1,maxIndent:null}),name:"@lexical/extension/TabIndentation",register(t,e,n){const{disabled:i,maxIndent:o,$canIndent:s}=n.getOutput();return St(()=>{if(!i.value)return Ne(t,o,s)})}});export{xe as $createHorizontalRuleNode,It as $isDecoratorTextNode,ye as $isHorizontalRuleNode,wt as AutoFocusExtension,Rt as ClearEditorExtension,kt as DecoratorTextExtension,Mt as DecoratorTextNode,Kt as EditorStateExtension,Ee as HorizontalRuleExtension,me as HorizontalRuleNode,pe as INSERT_HORIZONTAL_RULE_COMMAND,ne as InitialStateExtension,de as LexicalBuilder,Se as NestedEditorExtension,ge as NodeSelectionExtension,be as SelectionAlwaysOnDisplayExtension,Oe as TabIndentationExtension,_t as applyFormatFromStyle,Pt as applyFormatToDom,Y as batch,oe as buildEditorFromExtensions,mt as computed,St as effect,ue as getExtensionDependencyFromEditor,Ct as getKnownTypesAndNodes,fe as getPeerDependencyFromEditor,le as getPeerDependencyFromEditorOrThrow,bt as namedSignals,Ot as registerClearEditor,Ne as registerTabIndentation,ft as signal,nt as untracked,$t 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,getStaticNodeConfig as a,FORMAT_TEXT_COMMAND as d,$isNodeSelection as u,COMMAND_PRIORITY_LOW as f,DecoratorNode as l,$getState as h,toggleTextFormatType as g,$setState as p,TEXT_TYPE_TO_FORMAT as m,createState as v,shallowMergeConfig as x,RootNode as y,TextNode as E,LineBreakNode as S,TabNode as b,ParagraphNode as w,$isEditorState as N,HISTORY_MERGE_TAG as O,createEditor as R,mergeRegister as C,$getNodeByKey as D,$create as F,CLICK_COMMAND as M,isDOMNode as I,$getNodeFromDOMNode as _,addClassNamesToElement as P,createCommand as A,$createNodeSelection as j,$setSelection as k,removeClassNamesFromElement as $,$getEditor as K,KEY_TAB_COMMAND as z,OUTDENT_CONTENT_COMMAND as L,INDENT_CONTENT_COMMAND as U,INSERT_TAB_COMMAND as T,COMMAND_PRIORITY_CRITICAL as B,$isBlockElementNode as W,$createRangeSelection as G,$normalizeSelection__EXPERIMENTAL as V}from"lexical";export{configExtension,declarePeerDependency,defineExtension,safeCast,shallowMergeConfig}from"lexical";import{$insertNodeToNearestRoot as Z,selectionAlwaysOnDisplay as J,$handleIndentAndOutdent as H,$getNearestBlockElementAncestorOrThrow as q}from"@lexical/utils";const Q=Symbol.for("preact-signals");function X(){if(ot>1)return void ot--;let t,e=!1;for(!function(){let t=it;for(it=void 0;void 0!==t;)t.S.v===t.v&&(t.S.i=t.i),t=t.o}();void 0!==et;){let n=et;for(et=void 0,st++;void 0!==n;){const i=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&lt(n))try{n.c()}catch(n){e||(t=n,e=!0)}n=i}}if(st=0,ot--,e)throw t}function Y(t){if(ot>0)return t();ct=++rt,ot++;try{return t()}finally{X()}}let tt,et;function nt(t){const e=tt;tt=void 0;try{return t()}finally{tt=e}}let it,ot=0,st=0,rt=0,ct=0,at=0;function dt(t){if(void 0===tt)return;let e=t.n;return void 0===e||e.t!==tt?(e={i:0,S:t,p:tt.s,n:void 0,t:tt,e:void 0,x:void 0,r:e},void 0!==tt.s&&(tt.s.n=e),tt.s=e,t.n=e,32&tt.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=tt.s,e.n=void 0,tt.s.n=e,tt.s=e),e):void 0}function ut(t,e){this.v=t,this.i=0,this.n=void 0,this.t=void 0,this.l=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 ft(t,e){return new ut(t,e)}function lt(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 ht(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 gt(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 pt(t,e){ut.call(this,void 0),this.x=t,this.s=void 0,this.g=at-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 mt(t,e){return new pt(t,e)}function vt(t){const e=t.m;if(t.m=void 0,"function"==typeof e){ot++;const n=tt;tt=void 0;try{e()}catch(e){throw t.f&=-2,t.f|=8,xt(t),e}finally{tt=n,X()}}}function xt(t){for(let e=t.s;void 0!==e;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,vt(t)}function yt(t){if(tt!==this)throw new Error("Out-of-order effect");gt(this),tt=t,this.f&=-2,8&this.f&&xt(this),X()}function Et(t,e){this.x=t,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=null==e?void 0:e.name}function St(t,e){const n=new Et(t,e);try{n.c()}catch(t){throw n.d(),t}const i=n.d.bind(n);return i[Symbol.dispose]=i,i}function bt(t,e={}){const n={};for(const i in t){const o=e[i],s=ft(void 0===o?t[i]:o);n[i]=s}return n}ut.prototype.brand=Q,ut.prototype.h=function(){return!0},ut.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:nt(()=>{var t;null==(t=this.W)||t.call(this)}))},ut.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&&nt(()=>{var t;null==(t=this.Z)||t.call(this)}))}},ut.prototype.subscribe=function(t){return St(()=>{const e=this.value,n=tt;tt=void 0;try{t(e)}finally{tt=n}},{name:"sub"})},ut.prototype.valueOf=function(){return this.value},ut.prototype.toString=function(){return this.value+""},ut.prototype.toJSON=function(){return this.value},ut.prototype.peek=function(){const t=tt;tt=void 0;try{return this.value}finally{tt=t}},Object.defineProperty(ut.prototype,"value",{get(){const t=dt(this);return void 0!==t&&(t.i=this.i),this.v},set(t){if(t!==this.v){if(st>100)throw new Error("Cycle detected");!function(t){0!==ot&&0===st&&t.l!==ct&&(t.l=ct,it={S:t,v:t.v,i:t.i,o:it})}(this),this.v=t,this.i++,at++,ot++;try{for(let t=this.t;void 0!==t;t=t.x)t.t.N()}finally{X()}}}}),pt.prototype=new ut,pt.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===at)return!0;if(this.g=at,this.f|=1,this.i>0&&!lt(this))return this.f&=-2,!0;const t=tt;try{ht(this),tt=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 tt=t,gt(this),this.f&=-2,!0},pt.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)}ut.prototype.S.call(this,t)},pt.prototype.U=function(t){if(void 0!==this.t&&(ut.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)}},pt.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(pt.prototype,"value",{get(){if(1&this.f)throw new Error("Cycle detected");const t=dt(this);if(this.h(),void 0!==t&&(t.i=this.i),16&this.f)throw this.v;return this.v}}),Et.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.m=t)}finally{t()}},Et.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,vt(this),ht(this),ot++;const t=tt;return tt=this,yt.bind(this,t)},Et.prototype.N=function(){2&this.f||(this.f|=2,this.u=et,et=this)},Et.prototype.d=function(){this.f|=8,1&this.f||xt(this)},Et.prototype.dispose=function(){this.d()};const wt=t({build:(t,e,n)=>bt(e),config:e({defaultSelection:"rootEnd",disabled:!1}),name:"@lexical/extension/AutoFocus",register(t,e,n){const i=n.getOutput();return St(()=>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 Nt(){const t=o(),e=s(),n=r();t.clear(),t.append(n),null!==e&&n.select(),c(e)&&(e.format=0)}function Ot(t,e=Nt){return t.registerCommand(n,n=>(t.update(e),!0),i)}const Rt=t({build:(t,e,n)=>bt(e),config:e({$onClear:Nt}),name:"@lexical/extension/ClearEditor",register(t,e,n){const{$onClear:i}=n.getOutput();return St(()=>Ot(t,i.value))}});function Ct(t){const e=new Set,n=new Set;for(const i of Dt(t)){const t="function"==typeof i?i:i.replace;a(t),e.add(t.getType()),n.add(t)}return{nodes:n,types:e}}function Dt(t){return("function"==typeof t.nodes?t.nodes():t.nodes)||[]}const Ft=v("format",{parse:t=>"number"==typeof t?t:0});class Mt extends l{$config(){return this.config("decorator-text",{extends:l,stateConfigs:[{flat:!0,stateConfig:Ft}]})}getFormat(){return h(this,Ft)}getFormatFlags(t,e){return g(this.getFormat(),t,e)}hasFormat(t){const e=m[t];return 0!==(this.getFormat()&e)}setFormat(t){return p(this,Ft,t)}toggleFormat(t){const e=this.getFormat(),n=g(e,t,null);return this.setFormat(n)}isInline(){return!0}createDOM(){return document.createElement("span")}updateDOM(){return!1}}function It(t){return t instanceof Mt}function _t(t,e,n){const i=e.fontWeight,o=e.textDecoration.split(" "),s="700"===i||"bold"===i,r=o.includes("line-through"),c="italic"===e.fontStyle,a=o.includes("underline"),d=e.verticalAlign;return s&&!t.hasFormat("bold")&&t.toggleFormat("bold"),r&&!t.hasFormat("strikethrough")&&t.toggleFormat("strikethrough"),c&&!t.hasFormat("italic")&&t.toggleFormat("italic"),a&&!t.hasFormat("underline")&&t.toggleFormat("underline"),"sub"!==d||t.hasFormat("subscript")||t.toggleFormat("subscript"),"super"!==d||t.hasFormat("superscript")||t.toggleFormat("superscript"),n&&!t.hasFormat(n)&&t.toggleFormat(n),t}function Pt(t,e,n=jt){for(const[i,o]of Object.entries(n))t.hasFormat(o)&&(e=At(e,i));return e}function At(t,e){const n=document.createElement(e);return n.appendChild(t),n}const jt={b:"bold",code:"code",em:"italic",i:"italic",mark:"highlight",s:"strikethrough",strong:"bold",sub:"subscript",sup:"superscript",u:"underline"},kt=t({name:"@lexical/extension/DecoratorText",nodes:()=>[Mt],register:(t,e,n)=>t.registerCommand(d,t=>{const e=s();if(u(e)||c(e))for(const n of e.getNodes())It(n)&&n.toggleFormat(t);return!1},f)});function $t(t,e){let n;return ft(t(),{unwatched(){n&&(n(),n=void 0)},watched(){this.value=t(),n=e(this)}})}const Kt=t({build:t=>$t(()=>t.getEditorState(),e=>t.registerUpdateListener(t=>{e.value=t.editorState})),name:"@lexical/extension/EditorState"});function zt(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 Lt(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]=Lt(n[t],i[t]);return t}return e}const Ut=0,Tt=1,Bt=2,Wt=3,Gt=4,Vt=5,Zt=6,Jt=7;function Ht(t){return t.id===Ut}function qt(t){return t.id===Bt}function Qt(t){return function(t){return t.id===Tt}(t)||zt(305,String(t.id),String(Tt)),Object.assign(t,{id:Bt})}const Xt=new Set;class Yt{builder;configs;_dependency;_peerNameSet;extension;state;_signal;constructor(t,e){this.builder=t,this.extension=e,this.configs=new Set,this.state={id:Ut}}mergeConfigs(){let t=this.extension.config||{};const e=this.extension.mergeConfig?this.extension.mergeConfig.bind(this.extension):x;for(const n of this.configs)t=e(t,n);return t}init(t){const e=this.state;qt(e)||zt(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:Wt,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:Gt,initResult:e,registerState:n})}(o,s,i)}build(t){const e=this.state;let n;e.id!==Gt&&zt(307,String(e.id),String(Vt)),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:Vt,output:e,registerState:n})}(e,n,i)}register(t,e){this._signal=e;const n=this.state;n.id!==Vt&&zt(308,String(n.id),String(Vt));const i=this.extension.register&&this.extension.register(t,n.config,n.registerState);return this.state=function(t){return Object.assign(t,{id:Zt})}(n),()=>{const t=this.state;t.id!==Jt&&zt(309,String(n.id),String(Jt)),this.state=function(t){return Object.assign(t,{id:Vt})}(t),i&&i()}}afterRegistration(t){const e=this.state;let n;return e.id!==Zt&&zt(310,String(e.id),String(Zt)),this.extension.afterRegistration&&(n=this.extension.afterRegistration(t,e.config,e.registerState)),this.state=function(t){return Object.assign(t,{id:Jt})}(e),n}getSignal(){return void 0===this._signal&&zt(311),this._signal}getInitResult(){void 0===this.extension.init&&zt(312,this.extension.name);const t=this.state;return function(t){return t.id>=Gt}(t)||zt(313,String(t.id),String(Gt)),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>=Wt}(t)||zt(314,String(t.id),String(Wt)),{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&&zt(315,this.extension.name,t.name),e.getExtensionInitDependency()}getDependency(t){const e=this.builder.getExtensionRep(t);return void 0===e&&zt(315,this.extension.name,t.name),e.getExtensionDependency()}getState(){const t=this.state;return function(t){return t.id>=Jt}(t)||zt(316,String(t.id),String(Jt)),t}getDirectDependentNames(){return this.builder.incomingEdges.get(this.extension.name)||Xt}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>=Vt})(t)||zt(317,this.extension.name),this._dependency={config:t.config,init:t.initResult,output:t.output}}return this._dependency}}const te={tag:O};function ee(){const t=o();t.isEmpty()&&t.append(r())}const ne=t({config:e({setOptions:te,updateOptions:te}),init:({$initialEditorState:t=ee})=>({$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(N(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:[y,E,S,b,w]}),ie=Symbol.for("@lexical/extension/LexicalBuilder");function oe(...t){return de.fromExtensions(t).buildEditor()}function se(){}function re(t){throw t}function ce(t){return Array.isArray(t)?t:[t]}const ae="0.44.1-nightly.20260428.0+prod.esm";class de{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=ae,this.roots=t;for(const e of t)this.addExtension(e)}static fromExtensions(t){const e=[ce(ne)];for(const n of t)e.push(ce(n));return new de(e)}static maybeFromEditor(t){const e=t[ie];return e&&(e.PACKAGE_VERSION!==ae&&zt(292,e.PACKAGE_VERSION,ae),e instanceof de||zt(293)),e}static fromEditor(t){const e=de.maybeFromEditor(t);return void 0===e&&zt(294),e}constructEditor(){const{$initialEditorState:t,onError:e,...n}=this.buildCreateEditorArgs(),i=Object.assign(R({...n,...e?{onError:t=>{e(t,i)}}:{}}),{[ie]:this});for(const t of this.sortedExtensionReps())t.build(i);return i}buildEditor(){let t=se;function e(){try{t()}finally{t=se}}const n=Object.assign(this.constructEditor(),{dispose:e,[Symbol.dispose]:e});return t=C(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&&zt(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&&zt(296);const e=ce(t),[n]=e;"string"!=typeof n.name&&zt(297,typeof n.name);let i=this.extensionNameMap.get(n.name);if(void 0!==i&&i.extension!==n&&zt(298,n.name),!i){i=new Yt(this,n),this.extensionNameMap.set(n.name,i);const t=this.conflicts.get(n.name);"string"==typeof t&&zt(299,n.name,t);for(const t of n.conflictsWith||[])this.extensionNameMap.has(t)&&zt(299,n.name,t),this.conflicts.set(t,n.name);for(const t of n.dependencies||[]){const e=ce(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(qt(o))return;const s=n.extension.name;var r;Ht(o)||zt(300,s,i||"[unknown]"),Ht(r=o)||zt(304,String(r.id),String(Ut)),o=Object.assign(r,{id:Tt}),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=Qt(o),n.state=o,t.push(n)};for(const t of this.extensionNameMap.values())Ht(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&&zt(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 C(...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 Dt(r)){if("function"!=typeof t){const e=n.get(t.replace);e&&zt(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&&Lt(s,r.theme)}Object.keys(s).length>0&&(t.theme=s),e.size&&(t.nodes=[...e]);const c=Object.keys(o).length>0,a=i.size>0;(c||a)&&(t.html={},c&&(t.html.import=o),a&&(t.html.export=i));for(const e of r)e.init(t);return t.onError||(t.onError=re),t}}function ue(t,e){const n=de.fromEditor(t).getExtensionRep(e);return void 0===n&&zt(303,e.name),n.getExtensionDependency()}function fe(t,e){const n=de.maybeFromEditor(t);if(!n)return;const i=n.extensionNameMap.get(e);return i?i.getExtensionDependency():void 0}function le(t,e){const n=fe(t,e);return void 0===n&&zt(291,e),n}const he=new Set,ge=t({build(t,e,n){const i=n.getDependency(Kt).output,o=ft({watchedNodeKeys:new Map}),r=$t(()=>{},()=>St(()=>{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=D(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=mt(()=>(r.value||he).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:[Kt],name:"@lexical/extension/NodeSelection"}),pe=A("INSERT_HORIZONTAL_RULE_COMMAND");class me extends l{static getType(){return"horizontalrule"}static clone(t){return new me(t.__key)}static importJSON(t){return xe().updateFromJSON(t)}static importDOM(){return{hr:()=>({conversion:ve,priority:0})}}exportDOM(){return{element:document.createElement("hr")}}createDOM(t){const e=document.createElement("hr");return P(e,t.theme.hr),e}getTextContent(){return"\n"}isInline(){return!1}updateDOM(){return!1}}function ve(){return{node:xe()}}function xe(){return F(me)}function ye(t){return t instanceof me}const Ee=t({dependencies:[Kt,ge],name:"@lexical/extension/HorizontalRule",nodes:()=>[me],register(t,e,n){const{watchNodeKey:o}=n.getDependency(ge).output,r=ft({nodeSelections:new Map}),a=t._config.theme.hrSelected??"selected";return C(t.registerCommand(pe,t=>{const e=s();if(!c(e))return!1;if(null!==e.focus.getNode()){const t=xe();Z(t)}return!0},i),t.registerCommand(M,t=>{if(I(t.target)){const e=_(t.target);if(ye(e))return function(t,e=!1){const n=s(),i=t.isSelected(),o=t.getKey();let r;e&&u(n)?r=n:(r=j(),k(r)),i?r.delete(o):r.add(o)}(e,t.shiftKey),!0}return!1},f),t.registerMutationListener(me,(e,n)=>{Y(()=>{let n=!1;const{nodeSelections:i}=r.peek();for(const[s,r]of e.entries())if("destroyed"===r)i.delete(s),n=!0;else{const e=i.get(s),r=t.getElementByKey(s);e?e.domNode.value=r:(n=!0,i.set(s,{domNode:ft(r),selectedSignal:o(s)}))}n&&(r.value={nodeSelections:i})})}),St(()=>{const t=[];for(const{domNode:e,selectedSignal:n}of r.value.nodeSelections.values())t.push(St(()=>{const t=e.value;if(t){n.value?P(t,a):$(t,a)}}));return C(...t)}))}});const Se=t({build:(t,e)=>bt({inheritEditableFromParent:e.inheritEditableFromParent}),config:e({$getParentEditor:function(){const t=K();return de.fromEditor(t),t},inheritEditableFromParent:!1}),init:(t,e,n)=>{const i=e.$getParentEditor();t.parentEditor=i,t.theme=t.theme||i._config.theme},name:"@lexical/extension/NestedEditor",register:(t,e,n)=>St(()=>{const e=t._parentEditor;if(e&&n.getOutput().inheritEditableFromParent.value)return t.setEditable(e.isEditable()),e.registerEditableListener(t.setEditable.bind(t))})}),be=t({build:(t,e,n)=>bt(e),config:e({disabled:!1,onReposition:void 0}),name:"@lexical/utils/SelectionAlwaysOnDisplay",register:(t,e,n)=>{const i=n.getOutput();return St(()=>{if(!i.disabled.value)return J(t,i.onReposition.value)})}});function we(t){return t.canBeEmpty()}function Ne(t,e,n=we){return C(t.registerCommand(z,e=>{const n=s();if(!c(n))return!1;e.preventDefault();const i=function(t){if(t.getNodes().filter(t=>W(t)&&t.canIndent()).length>0)return!0;const e=t.anchor,n=t.focus,i=n.isBefore(e)?n:e,o=i.getNode(),s=q(o);if(s.canIndent()){const t=s.getKey();let e=G();if(e.anchor.set(t,0,"element"),e.focus.set(t,0,"element"),e=V(e),e.anchor.is(i))return!0}return!1}(n)?e.shiftKey?L:U:T;return t.dispatchCommand(i,void 0)},i),t.registerCommand(U,()=>{const t="number"==typeof e?e:e?e.peek():null,i=s();if(!c(i))return!1;const o="function"==typeof n?n:n.peek();return H(e=>{if(o(e)){const n=e.getIndent()+1;(!t||n<t)&&e.setIndent(n)}})},B))}const Oe=t({build:(t,e,n)=>bt(e),config:e({$canIndent:we,disabled:!1,maxIndent:null}),name:"@lexical/extension/TabIndentation",register(t,e,n){const{disabled:i,maxIndent:o,$canIndent:s}=n.getOutput();return St(()=>{if(!i.value)return Ne(t,o,s)})}});export{xe as $createHorizontalRuleNode,It as $isDecoratorTextNode,ye as $isHorizontalRuleNode,wt as AutoFocusExtension,Rt as ClearEditorExtension,kt as DecoratorTextExtension,Mt as DecoratorTextNode,Kt as EditorStateExtension,Ee as HorizontalRuleExtension,me as HorizontalRuleNode,pe as INSERT_HORIZONTAL_RULE_COMMAND,ne as InitialStateExtension,de as LexicalBuilder,Se as NestedEditorExtension,ge as NodeSelectionExtension,be as SelectionAlwaysOnDisplayExtension,Oe as TabIndentationExtension,_t as applyFormatFromStyle,Pt as applyFormatToDom,Y as batch,oe as buildEditorFromExtensions,mt as computed,St as effect,ue as getExtensionDependencyFromEditor,Ct as getKnownTypesAndNodes,fe as getPeerDependencyFromEditor,le as getPeerDependencyFromEditorOrThrow,bt as namedSignals,Ot as registerClearEditor,Ne as registerTabIndentation,ft as signal,nt as untracked,$t as watchedSignal};
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "extension",
7
7
  "plugin"
8
8
  ],
9
- "version": "0.44.0",
9
+ "version": "0.44.1-nightly.20260428.0",
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.44.0",
26
+ "@lexical/utils": "0.44.1-nightly.20260428.0",
27
27
  "@preact/signals-core": "^1.14.1",
28
- "lexical": "0.44.0"
28
+ "lexical": "0.44.1-nightly.20260428.0"
29
29
  },
30
30
  "exports": {
31
31
  ".": {