@lexical/extension
Advanced tools
@@ -832,3 +832,3 @@ /** | ||
| } | ||
| const PACKAGE_VERSION = "0.41.1-nightly.20260316.0+dev.cjs"; | ||
| const PACKAGE_VERSION = "0.41.1-nightly.20260317.0+dev.cjs"; | ||
@@ -835,0 +835,0 @@ /** @internal */ |
@@ -831,3 +831,3 @@ /** | ||
| } | ||
| const PACKAGE_VERSION = "0.41.1-nightly.20260316.0+dev.esm"; | ||
| const PACKAGE_VERSION = "0.41.1-nightly.20260317.0+dev.esm"; | ||
@@ -834,0 +834,0 @@ /** @internal */ |
@@ -9,2 +9,2 @@ /** | ||
| "use strict";var t=require("lexical"),e=require("@lexical/utils");const n=Symbol.for("preact-signals");function i(){if(c>1)return void c--;let t,e=!1;for(;void 0!==r;){let n=r;for(r=void 0,d++;void 0!==n;){const i=n.o;if(n.o=void 0,n.f&=-3,!(8&n.f)&&g(n))try{n.c()}catch(n){e||(t=n,e=!0)}n=i}}if(d=0,c--,e)throw t}function o(t){if(c>0)return t();c++;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=0,d=0,u=0;function l(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 f(t,e){this.v=t,this.i=0,this.n=void 0,this.t=void 0,this.W=null==e?void 0:e.watched,this.Z=null==e?void 0:e.unwatched,this.name=null==e?void 0:e.name}function h(t,e){return new f(t,e)}function g(t){for(let e=t.s;void 0!==e;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return!0;return!1}function p(t){for(let e=t.s;void 0!==e;e=e.n){const n=e.S.n;if(void 0!==n&&(e.r=n),e.S.n=e,e.i=-1,void 0===e.n){t.s=e;break}}}function m(t){let e,n=t.s;for(;void 0!==n;){const t=n.p;-1===n.i?(n.S.U(n),void 0!==t&&(t.n=n.n),void 0!==n.n&&(n.n.p=t)):e=n,n.S.n=n.r,void 0!==n.r&&(n.r=void 0),n=t}t.s=e}function x(t,e){f.call(this,void 0),this.x=t,this.s=void 0,this.g=u-1,this.f=4,this.W=null==e?void 0:e.watched,this.Z=null==e?void 0:e.unwatched,this.name=null==e?void 0:e.name}function E(t,e){return new x(t,e)}function v(t){const e=t.u;if(t.u=void 0,"function"==typeof e){c++;const n=s;s=void 0;try{e()}catch(e){throw t.f&=-2,t.f|=8,S(t),e}finally{s=n,i()}}}function S(t){for(let e=t.s;void 0!==e;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,v(t)}function y(t){if(s!==this)throw new Error("Out-of-order effect");m(this),s=t,this.f&=-2,8&this.f&&S(this),i()}function N(t,e){this.x=t,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=null==e?void 0:e.name}function b(t,e){const n=new N(t,e);try{n.c()}catch(t){throw n.d(),t}const i=n.d.bind(n);return i[Symbol.dispose]=i,i}function O(t,e={}){const n={};for(const i in t){const o=e[i],s=h(void 0===o?t[i]:o);n[i]=s}return n}f.prototype.brand=n,f.prototype.h=function(){return!0},f.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)}))},f.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)}))}},f.prototype.subscribe=function(t){return b(()=>{const e=this.value,n=s;s=void 0;try{t(e)}finally{s=n}},{name:"sub"})},f.prototype.valueOf=function(){return this.value},f.prototype.toString=function(){return this.value+""},f.prototype.toJSON=function(){return this.value},f.prototype.peek=function(){const t=s;s=void 0;try{return this.value}finally{s=t}},Object.defineProperty(f.prototype,"value",{get(){const t=l(this);return void 0!==t&&(t.i=this.i),this.v},set(t){if(t!==this.v){if(d>100)throw new Error("Cycle detected");this.v=t,this.i++,u++,c++;try{for(let t=this.t;void 0!==t;t=t.x)t.t.N()}finally{i()}}}}),x.prototype=new f,x.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if(32==(36&this.f))return!0;if(this.f&=-5,this.g===u)return!0;if(this.g=u,this.f|=1,this.i>0&&!g(this))return this.f&=-2,!0;const t=s;try{p(this),s=this;const t=this.x();(16&this.f||this.v!==t||0===this.i)&&(this.v=t,this.f&=-17,this.i++)}catch(t){this.v=t,this.f|=16,this.i++}return s=t,m(this),this.f&=-2,!0},x.prototype.S=function(t){if(void 0===this.t){this.f|=36;for(let t=this.s;void 0!==t;t=t.n)t.S.S(t)}f.prototype.S.call(this,t)},x.prototype.U=function(t){if(void 0!==this.t&&(f.prototype.U.call(this,t),void 0===this.t)){this.f&=-33;for(let t=this.s;void 0!==t;t=t.n)t.S.U(t)}},x.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(let t=this.t;void 0!==t;t=t.x)t.t.N()}},Object.defineProperty(x.prototype,"value",{get(){if(1&this.f)throw new Error("Cycle detected");const t=l(this);if(this.h(),void 0!==t&&(t.i=this.i),16&this.f)throw this.v;return this.v}}),N.prototype.c=function(){const t=this.S();try{if(8&this.f)return;if(void 0===this.x)return;const t=this.x();"function"==typeof t&&(this.u=t)}finally{t()}},N.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,v(this),p(this),c++;const t=s;return s=this,y.bind(this,t)},N.prototype.N=function(){2&this.f||(this.f|=2,this.o=r,r=this)},N.prototype.d=function(){this.f|=8,1&this.f||S(this)},N.prototype.dispose=function(){this.d()};const R=t.defineExtension({build:(t,e,n)=>O(e),config:t.safeCast({defaultSelection:"rootEnd",disabled:!1}),name:"@lexical/extension/AutoFocus",register(t,e,n){const i=n.getOutput();return b(()=>i.disabled.value?void 0:t.registerRootListener(e=>{t.focus(()=>{const t=document.activeElement;null===e||null!==t&&e.contains(t)||e.focus({preventScroll:!0})},{defaultSelection:i.defaultSelection.peek()})}))}});function C(){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 M(e,n=C){return e.registerCommand(t.CLEAR_EDITOR_COMMAND,t=>(e.update(n),!0),t.COMMAND_PRIORITY_EDITOR)}const D=t.defineExtension({build:(t,e,n)=>O(e),config:t.safeCast({$onClear:C}),name:"@lexical/extension/ClearEditor",register(t,e,n){const{$onClear:i}=n.getOutput();return b(()=>M(t,i.value))}});function w(t){return("function"==typeof t.nodes?t.nodes():t.nodes)||[]}const _=t.createState("format",{parse:t=>"number"==typeof t?t:0});class T 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 I(t){return t instanceof T}function A(t,e){const n=document.createElement(e);return n.appendChild(t),n}const $={b:"bold",code:"code",em:"italic",i:"italic",mark:"highlight",s:"strikethrough",strong:"bold",sub:"subscript",sup:"superscript",u:"underline"},F=t.defineExtension({name:"@lexical/extension/DecoratorText",nodes:()=>[T],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())I(t)&&t.toggleFormat(e);return!1},t.COMMAND_PRIORITY_LOW)});function P(t,e){let n;return h(t(),{unwatched(){n&&(n(),n=void 0)},watched(){this.value=t(),n=e(this)}})}const k=t.defineExtension({build:t=>P(()=>t.getEditorState(),e=>t.registerUpdateListener(t=>{e.value=t.editorState})),name:"@lexical/extension/EditorState"});function j(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 K(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]=K(n[t],i[t]);return t}return e}const L=0,z=1,B=2,U=3,H=4,Y=5,W=6,G=7;function Z(t){return t.id===L}function V(t){return t.id===B}function J(t){return function(t){return t.id===z}(t)||j(305,String(t.id),String(z)),Object.assign(t,{id:B})}const X=new Set;class q{builder;configs;_dependency;_peerNameSet;extension;state;_signal;constructor(t,e){this.builder=t,this.extension=e,this.configs=new Set,this.state={id:L}}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;V(e)||j(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:U,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:H,initResult:e,registerState:n})}(o,s,i)}build(t){const e=this.state;let n;e.id!==H&&j(307,String(e.id),String(Y)),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:Y,output:e,registerState:n})}(e,n,i)}register(t,e){this._signal=e;const n=this.state;n.id!==Y&&j(308,String(n.id),String(Y));const i=this.extension.register&&this.extension.register(t,n.config,n.registerState);return this.state=function(t){return Object.assign(t,{id:W})}(n),()=>{const t=this.state;t.id!==G&&j(309,String(n.id),String(G)),this.state=function(t){return Object.assign(t,{id:Y})}(t),i&&i()}}afterRegistration(t){const e=this.state;let n;return e.id!==W&&j(310,String(e.id),String(W)),this.extension.afterRegistration&&(n=this.extension.afterRegistration(t,e.config,e.registerState)),this.state=function(t){return Object.assign(t,{id:G})}(e),n}getSignal(){return void 0===this._signal&&j(311),this._signal}getInitResult(){void 0===this.extension.init&&j(312,this.extension.name);const t=this.state;return function(t){return t.id>=H}(t)||j(313,String(t.id),String(H)),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>=U}(t)||j(314,String(t.id),String(U)),{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&&j(315,this.extension.name,t.name),e.getExtensionInitDependency()}getDependency(t){const e=this.builder.getExtensionRep(t);return void 0===e&&j(315,this.extension.name,t.name),e.getExtensionDependency()}getState(){const t=this.state;return function(t){return t.id>=G}(t)||j(316,String(t.id),String(G)),t}getDirectDependentNames(){return this.builder.incomingEdges.get(this.extension.name)||X}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>=Y})(t)||j(317,this.extension.name),this._dependency={config:t.config,init:t.initResult,output:t.output}}return this._dependency}}const Q={tag:t.HISTORY_MERGE_TAG};function tt(){const e=t.$getRoot();e.isEmpty()&&e.append(t.$createParagraphNode())}const et=t.defineExtension({config:t.safeCast({setOptions:Q,updateOptions:Q}),init:({$initialEditorState:t=tt})=>({$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]}),nt=Symbol.for("@lexical/extension/LexicalBuilder");function it(){}function ot(t){throw t}function st(t){return Array.isArray(t)?t:[t]}const rt="0.41.1-nightly.20260316.0+prod.cjs";class at{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=rt,this.roots=t;for(const e of t)this.addExtension(e)}static fromExtensions(t){const e=[st(et)];for(const n of t)e.push(st(n));return new at(e)}static maybeFromEditor(t){const e=t[nt];return e&&(e.PACKAGE_VERSION!==rt&&j(292,e.PACKAGE_VERSION,rt),e instanceof at||j(293)),e}static fromEditor(t){const e=at.maybeFromEditor(t);return void 0===e&&j(294),e}constructEditor(){const{$initialEditorState:e,onError:n,...i}=this.buildCreateEditorArgs(),o=Object.assign(t.createEditor({...i,...n?{onError:t=>{n(t,o)}}:{}}),{[nt]:this});for(const t of this.sortedExtensionReps())t.build(o);return o}buildEditor(){let e=it;function n(){try{e()}finally{e=it}}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&&j(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&&j(296);const e=st(t),[n]=e;"string"!=typeof n.name&&j(297,typeof n.name);let i=this.extensionNameMap.get(n.name);if(void 0!==i&&i.extension!==n&&j(298,n.name),!i){i=new q(this,n),this.extensionNameMap.set(n.name,i);const t=this.conflicts.get(n.name);"string"==typeof t&&j(299,n.name,t);for(const t of n.conflictsWith||[])this.extensionNameMap.has(t)&&j(299,n.name,t),this.conflicts.set(t,n.name);for(const t of n.dependencies||[]){const e=st(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(V(o))return;const s=n.extension.name;var r;Z(o)||j(300,s,i||"[unknown]"),Z(r=o)||j(304,String(r.id),String(L)),o=Object.assign(r,{id:z}),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=J(o),n.state=o,t.push(n)};for(const t of this.extensionNameMap.values())Z(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&&j(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 w(r)){if("function"!=typeof t){const e=n.get(t.replace);e&&j(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&&K(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=ot),t}}function ct(t,e){const n=at.fromEditor(t).extensionNameMap.get(e);return n?n.getExtensionDependency():void 0}const dt=new Set,ut=t.defineExtension({build(e,n,i){const o=i.getDependency(k).output,s=h({watchedNodeKeys:new Map}),r=P(()=>{},()=>b(()=>{const e=r.peek(),{watchedNodeKeys:n}=s.value;let i,a=!1;o.value.read(()=>{if(t.$getSelection())for(const[o,s]of n.entries()){if(0===s.size){n.delete(o);continue}const r=t.$getNodeByKey(o),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=E(()=>(r.value||dt).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"}),lt=t.createCommand("INSERT_HORIZONTAL_RULE_COMMAND");class ft extends t.DecoratorNode{static getType(){return"horizontalrule"}static clone(t){return new ft(t.__key)}static importJSON(t){return gt().updateFromJSON(t)}static importDOM(){return{hr:()=>({conversion:ht,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 ht(){return{node:gt()}}function gt(){return t.$create(ft)}function pt(t){return t instanceof ft}const mt=t.defineExtension({dependencies:[k,ut],name:"@lexical/extension/HorizontalRule",nodes:()=>[ft],register(e,n,i){const{watchNodeKey:s}=i.getDependency(ut).output,r=h({nodeSelections:new Map}),a=e._config.theme.hrSelected??"selected";return t.mergeRegister(e.registerCommand(t.CLICK_COMMAND,e=>{if(t.isDOMNode(e.target)){const n=t.$getNodeFromDOMNode(e.target);if(pt(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),e.registerMutationListener(ft,(t,n)=>{o(()=>{let n=!1;const{nodeSelections:i}=r.peek();for(const[o,r]of t.entries())if("destroyed"===r)i.delete(o),n=!0;else{const t=i.get(o),r=e.getElementByKey(o);t?t.domNode.value=r:(n=!0,i.set(o,{domNode:h(r),selectedSignal:s(o)}))}n&&(r.value={nodeSelections:i})})}),b(()=>{const e=[];for(const{domNode:n,selectedSignal:i}of r.value.nodeSelections.values())e.push(b(()=>{const e=n.value;if(e){i.value?t.addClassNamesToElement(e,a):t.removeClassNamesFromElement(e,a)}}));return t.mergeRegister(...e)}))}});function xt(t){return t.canBeEmpty()}function Et(n,i,o=xt){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 vt=t.defineExtension({build:(t,e,n)=>O(e),config:t.safeCast({$canIndent:xt,disabled:!1,maxIndent:null}),name:"@lexical/extension/TabIndentation",register(t,e,n){const{disabled:i,maxIndent:o,$canIndent:s}=n.getOutput();return b(()=>{if(!i.value)return Et(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=gt,exports.$isDecoratorTextNode=I,exports.$isHorizontalRuleNode=pt,exports.AutoFocusExtension=R,exports.ClearEditorExtension=D,exports.DecoratorTextExtension=F,exports.DecoratorTextNode=T,exports.EditorStateExtension=k,exports.HorizontalRuleExtension=mt,exports.HorizontalRuleNode=ft,exports.INSERT_HORIZONTAL_RULE_COMMAND=lt,exports.InitialStateExtension=et,exports.LexicalBuilder=at,exports.NodeSelectionExtension=ut,exports.TabIndentationExtension=vt,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=$){for(const[i,o]of Object.entries(n))t.hasFormat(o)&&(e=A(e,i));return e},exports.batch=o,exports.buildEditorFromExtensions=function(...t){return at.fromExtensions(t).buildEditor()},exports.computed=E,exports.effect=b,exports.getExtensionDependencyFromEditor=function(t,e){const n=at.fromEditor(t).getExtensionRep(e);return void 0===n&&j(303,e.name),n.getExtensionDependency()},exports.getKnownTypesAndNodes=function(t){const e=new Set,n=new Set;for(const i of w(t)){const t="function"==typeof i?i:i.replace;e.add(t.getType()),n.add(t)}return{nodes:n,types:e}},exports.getPeerDependencyFromEditor=ct,exports.getPeerDependencyFromEditorOrThrow=function(t,e){const n=ct(t,e);return void 0===n&&j(291,e),n},exports.namedSignals=O,exports.registerClearEditor=M,exports.registerTabIndentation=Et,exports.signal=h,exports.untracked=a,exports.watchedSignal=P; | ||
| "use strict";var t=require("lexical"),e=require("@lexical/utils");const n=Symbol.for("preact-signals");function i(){if(c>1)return void c--;let t,e=!1;for(;void 0!==r;){let n=r;for(r=void 0,d++;void 0!==n;){const i=n.o;if(n.o=void 0,n.f&=-3,!(8&n.f)&&g(n))try{n.c()}catch(n){e||(t=n,e=!0)}n=i}}if(d=0,c--,e)throw t}function o(t){if(c>0)return t();c++;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=0,d=0,u=0;function l(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 f(t,e){this.v=t,this.i=0,this.n=void 0,this.t=void 0,this.W=null==e?void 0:e.watched,this.Z=null==e?void 0:e.unwatched,this.name=null==e?void 0:e.name}function h(t,e){return new f(t,e)}function g(t){for(let e=t.s;void 0!==e;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return!0;return!1}function p(t){for(let e=t.s;void 0!==e;e=e.n){const n=e.S.n;if(void 0!==n&&(e.r=n),e.S.n=e,e.i=-1,void 0===e.n){t.s=e;break}}}function m(t){let e,n=t.s;for(;void 0!==n;){const t=n.p;-1===n.i?(n.S.U(n),void 0!==t&&(t.n=n.n),void 0!==n.n&&(n.n.p=t)):e=n,n.S.n=n.r,void 0!==n.r&&(n.r=void 0),n=t}t.s=e}function x(t,e){f.call(this,void 0),this.x=t,this.s=void 0,this.g=u-1,this.f=4,this.W=null==e?void 0:e.watched,this.Z=null==e?void 0:e.unwatched,this.name=null==e?void 0:e.name}function E(t,e){return new x(t,e)}function v(t){const e=t.u;if(t.u=void 0,"function"==typeof e){c++;const n=s;s=void 0;try{e()}catch(e){throw t.f&=-2,t.f|=8,S(t),e}finally{s=n,i()}}}function S(t){for(let e=t.s;void 0!==e;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,v(t)}function y(t){if(s!==this)throw new Error("Out-of-order effect");m(this),s=t,this.f&=-2,8&this.f&&S(this),i()}function N(t,e){this.x=t,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=null==e?void 0:e.name}function b(t,e){const n=new N(t,e);try{n.c()}catch(t){throw n.d(),t}const i=n.d.bind(n);return i[Symbol.dispose]=i,i}function O(t,e={}){const n={};for(const i in t){const o=e[i],s=h(void 0===o?t[i]:o);n[i]=s}return n}f.prototype.brand=n,f.prototype.h=function(){return!0},f.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)}))},f.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)}))}},f.prototype.subscribe=function(t){return b(()=>{const e=this.value,n=s;s=void 0;try{t(e)}finally{s=n}},{name:"sub"})},f.prototype.valueOf=function(){return this.value},f.prototype.toString=function(){return this.value+""},f.prototype.toJSON=function(){return this.value},f.prototype.peek=function(){const t=s;s=void 0;try{return this.value}finally{s=t}},Object.defineProperty(f.prototype,"value",{get(){const t=l(this);return void 0!==t&&(t.i=this.i),this.v},set(t){if(t!==this.v){if(d>100)throw new Error("Cycle detected");this.v=t,this.i++,u++,c++;try{for(let t=this.t;void 0!==t;t=t.x)t.t.N()}finally{i()}}}}),x.prototype=new f,x.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if(32==(36&this.f))return!0;if(this.f&=-5,this.g===u)return!0;if(this.g=u,this.f|=1,this.i>0&&!g(this))return this.f&=-2,!0;const t=s;try{p(this),s=this;const t=this.x();(16&this.f||this.v!==t||0===this.i)&&(this.v=t,this.f&=-17,this.i++)}catch(t){this.v=t,this.f|=16,this.i++}return s=t,m(this),this.f&=-2,!0},x.prototype.S=function(t){if(void 0===this.t){this.f|=36;for(let t=this.s;void 0!==t;t=t.n)t.S.S(t)}f.prototype.S.call(this,t)},x.prototype.U=function(t){if(void 0!==this.t&&(f.prototype.U.call(this,t),void 0===this.t)){this.f&=-33;for(let t=this.s;void 0!==t;t=t.n)t.S.U(t)}},x.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(let t=this.t;void 0!==t;t=t.x)t.t.N()}},Object.defineProperty(x.prototype,"value",{get(){if(1&this.f)throw new Error("Cycle detected");const t=l(this);if(this.h(),void 0!==t&&(t.i=this.i),16&this.f)throw this.v;return this.v}}),N.prototype.c=function(){const t=this.S();try{if(8&this.f)return;if(void 0===this.x)return;const t=this.x();"function"==typeof t&&(this.u=t)}finally{t()}},N.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,v(this),p(this),c++;const t=s;return s=this,y.bind(this,t)},N.prototype.N=function(){2&this.f||(this.f|=2,this.o=r,r=this)},N.prototype.d=function(){this.f|=8,1&this.f||S(this)},N.prototype.dispose=function(){this.d()};const R=t.defineExtension({build:(t,e,n)=>O(e),config:t.safeCast({defaultSelection:"rootEnd",disabled:!1}),name:"@lexical/extension/AutoFocus",register(t,e,n){const i=n.getOutput();return b(()=>i.disabled.value?void 0:t.registerRootListener(e=>{t.focus(()=>{const t=document.activeElement;null===e||null!==t&&e.contains(t)||e.focus({preventScroll:!0})},{defaultSelection:i.defaultSelection.peek()})}))}});function C(){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 M(e,n=C){return e.registerCommand(t.CLEAR_EDITOR_COMMAND,t=>(e.update(n),!0),t.COMMAND_PRIORITY_EDITOR)}const D=t.defineExtension({build:(t,e,n)=>O(e),config:t.safeCast({$onClear:C}),name:"@lexical/extension/ClearEditor",register(t,e,n){const{$onClear:i}=n.getOutput();return b(()=>M(t,i.value))}});function w(t){return("function"==typeof t.nodes?t.nodes():t.nodes)||[]}const _=t.createState("format",{parse:t=>"number"==typeof t?t:0});class T 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 I(t){return t instanceof T}function A(t,e){const n=document.createElement(e);return n.appendChild(t),n}const $={b:"bold",code:"code",em:"italic",i:"italic",mark:"highlight",s:"strikethrough",strong:"bold",sub:"subscript",sup:"superscript",u:"underline"},F=t.defineExtension({name:"@lexical/extension/DecoratorText",nodes:()=>[T],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())I(t)&&t.toggleFormat(e);return!1},t.COMMAND_PRIORITY_LOW)});function P(t,e){let n;return h(t(),{unwatched(){n&&(n(),n=void 0)},watched(){this.value=t(),n=e(this)}})}const k=t.defineExtension({build:t=>P(()=>t.getEditorState(),e=>t.registerUpdateListener(t=>{e.value=t.editorState})),name:"@lexical/extension/EditorState"});function j(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 K(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]=K(n[t],i[t]);return t}return e}const L=0,z=1,B=2,U=3,H=4,Y=5,W=6,G=7;function Z(t){return t.id===L}function V(t){return t.id===B}function J(t){return function(t){return t.id===z}(t)||j(305,String(t.id),String(z)),Object.assign(t,{id:B})}const X=new Set;class q{builder;configs;_dependency;_peerNameSet;extension;state;_signal;constructor(t,e){this.builder=t,this.extension=e,this.configs=new Set,this.state={id:L}}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;V(e)||j(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:U,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:H,initResult:e,registerState:n})}(o,s,i)}build(t){const e=this.state;let n;e.id!==H&&j(307,String(e.id),String(Y)),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:Y,output:e,registerState:n})}(e,n,i)}register(t,e){this._signal=e;const n=this.state;n.id!==Y&&j(308,String(n.id),String(Y));const i=this.extension.register&&this.extension.register(t,n.config,n.registerState);return this.state=function(t){return Object.assign(t,{id:W})}(n),()=>{const t=this.state;t.id!==G&&j(309,String(n.id),String(G)),this.state=function(t){return Object.assign(t,{id:Y})}(t),i&&i()}}afterRegistration(t){const e=this.state;let n;return e.id!==W&&j(310,String(e.id),String(W)),this.extension.afterRegistration&&(n=this.extension.afterRegistration(t,e.config,e.registerState)),this.state=function(t){return Object.assign(t,{id:G})}(e),n}getSignal(){return void 0===this._signal&&j(311),this._signal}getInitResult(){void 0===this.extension.init&&j(312,this.extension.name);const t=this.state;return function(t){return t.id>=H}(t)||j(313,String(t.id),String(H)),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>=U}(t)||j(314,String(t.id),String(U)),{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&&j(315,this.extension.name,t.name),e.getExtensionInitDependency()}getDependency(t){const e=this.builder.getExtensionRep(t);return void 0===e&&j(315,this.extension.name,t.name),e.getExtensionDependency()}getState(){const t=this.state;return function(t){return t.id>=G}(t)||j(316,String(t.id),String(G)),t}getDirectDependentNames(){return this.builder.incomingEdges.get(this.extension.name)||X}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>=Y})(t)||j(317,this.extension.name),this._dependency={config:t.config,init:t.initResult,output:t.output}}return this._dependency}}const Q={tag:t.HISTORY_MERGE_TAG};function tt(){const e=t.$getRoot();e.isEmpty()&&e.append(t.$createParagraphNode())}const et=t.defineExtension({config:t.safeCast({setOptions:Q,updateOptions:Q}),init:({$initialEditorState:t=tt})=>({$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]}),nt=Symbol.for("@lexical/extension/LexicalBuilder");function it(){}function ot(t){throw t}function st(t){return Array.isArray(t)?t:[t]}const rt="0.41.1-nightly.20260317.0+prod.cjs";class at{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=rt,this.roots=t;for(const e of t)this.addExtension(e)}static fromExtensions(t){const e=[st(et)];for(const n of t)e.push(st(n));return new at(e)}static maybeFromEditor(t){const e=t[nt];return e&&(e.PACKAGE_VERSION!==rt&&j(292,e.PACKAGE_VERSION,rt),e instanceof at||j(293)),e}static fromEditor(t){const e=at.maybeFromEditor(t);return void 0===e&&j(294),e}constructEditor(){const{$initialEditorState:e,onError:n,...i}=this.buildCreateEditorArgs(),o=Object.assign(t.createEditor({...i,...n?{onError:t=>{n(t,o)}}:{}}),{[nt]:this});for(const t of this.sortedExtensionReps())t.build(o);return o}buildEditor(){let e=it;function n(){try{e()}finally{e=it}}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&&j(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&&j(296);const e=st(t),[n]=e;"string"!=typeof n.name&&j(297,typeof n.name);let i=this.extensionNameMap.get(n.name);if(void 0!==i&&i.extension!==n&&j(298,n.name),!i){i=new q(this,n),this.extensionNameMap.set(n.name,i);const t=this.conflicts.get(n.name);"string"==typeof t&&j(299,n.name,t);for(const t of n.conflictsWith||[])this.extensionNameMap.has(t)&&j(299,n.name,t),this.conflicts.set(t,n.name);for(const t of n.dependencies||[]){const e=st(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(V(o))return;const s=n.extension.name;var r;Z(o)||j(300,s,i||"[unknown]"),Z(r=o)||j(304,String(r.id),String(L)),o=Object.assign(r,{id:z}),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=J(o),n.state=o,t.push(n)};for(const t of this.extensionNameMap.values())Z(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&&j(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 w(r)){if("function"!=typeof t){const e=n.get(t.replace);e&&j(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&&K(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=ot),t}}function ct(t,e){const n=at.fromEditor(t).extensionNameMap.get(e);return n?n.getExtensionDependency():void 0}const dt=new Set,ut=t.defineExtension({build(e,n,i){const o=i.getDependency(k).output,s=h({watchedNodeKeys:new Map}),r=P(()=>{},()=>b(()=>{const e=r.peek(),{watchedNodeKeys:n}=s.value;let i,a=!1;o.value.read(()=>{if(t.$getSelection())for(const[o,s]of n.entries()){if(0===s.size){n.delete(o);continue}const r=t.$getNodeByKey(o),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=E(()=>(r.value||dt).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"}),lt=t.createCommand("INSERT_HORIZONTAL_RULE_COMMAND");class ft extends t.DecoratorNode{static getType(){return"horizontalrule"}static clone(t){return new ft(t.__key)}static importJSON(t){return gt().updateFromJSON(t)}static importDOM(){return{hr:()=>({conversion:ht,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 ht(){return{node:gt()}}function gt(){return t.$create(ft)}function pt(t){return t instanceof ft}const mt=t.defineExtension({dependencies:[k,ut],name:"@lexical/extension/HorizontalRule",nodes:()=>[ft],register(e,n,i){const{watchNodeKey:s}=i.getDependency(ut).output,r=h({nodeSelections:new Map}),a=e._config.theme.hrSelected??"selected";return t.mergeRegister(e.registerCommand(t.CLICK_COMMAND,e=>{if(t.isDOMNode(e.target)){const n=t.$getNodeFromDOMNode(e.target);if(pt(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),e.registerMutationListener(ft,(t,n)=>{o(()=>{let n=!1;const{nodeSelections:i}=r.peek();for(const[o,r]of t.entries())if("destroyed"===r)i.delete(o),n=!0;else{const t=i.get(o),r=e.getElementByKey(o);t?t.domNode.value=r:(n=!0,i.set(o,{domNode:h(r),selectedSignal:s(o)}))}n&&(r.value={nodeSelections:i})})}),b(()=>{const e=[];for(const{domNode:n,selectedSignal:i}of r.value.nodeSelections.values())e.push(b(()=>{const e=n.value;if(e){i.value?t.addClassNamesToElement(e,a):t.removeClassNamesFromElement(e,a)}}));return t.mergeRegister(...e)}))}});function xt(t){return t.canBeEmpty()}function Et(n,i,o=xt){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 vt=t.defineExtension({build:(t,e,n)=>O(e),config:t.safeCast({$canIndent:xt,disabled:!1,maxIndent:null}),name:"@lexical/extension/TabIndentation",register(t,e,n){const{disabled:i,maxIndent:o,$canIndent:s}=n.getOutput();return b(()=>{if(!i.value)return Et(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=gt,exports.$isDecoratorTextNode=I,exports.$isHorizontalRuleNode=pt,exports.AutoFocusExtension=R,exports.ClearEditorExtension=D,exports.DecoratorTextExtension=F,exports.DecoratorTextNode=T,exports.EditorStateExtension=k,exports.HorizontalRuleExtension=mt,exports.HorizontalRuleNode=ft,exports.INSERT_HORIZONTAL_RULE_COMMAND=lt,exports.InitialStateExtension=et,exports.LexicalBuilder=at,exports.NodeSelectionExtension=ut,exports.TabIndentationExtension=vt,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=$){for(const[i,o]of Object.entries(n))t.hasFormat(o)&&(e=A(e,i));return e},exports.batch=o,exports.buildEditorFromExtensions=function(...t){return at.fromExtensions(t).buildEditor()},exports.computed=E,exports.effect=b,exports.getExtensionDependencyFromEditor=function(t,e){const n=at.fromEditor(t).getExtensionRep(e);return void 0===n&&j(303,e.name),n.getExtensionDependency()},exports.getKnownTypesAndNodes=function(t){const e=new Set,n=new Set;for(const i of w(t)){const t="function"==typeof i?i:i.replace;e.add(t.getType()),n.add(t)}return{nodes:n,types:e}},exports.getPeerDependencyFromEditor=ct,exports.getPeerDependencyFromEditorOrThrow=function(t,e){const n=ct(t,e);return void 0===n&&j(291,e),n},exports.namedSignals=O,exports.registerClearEditor=M,exports.registerTabIndentation=Et,exports.signal=h,exports.untracked=a,exports.watchedSignal=P; |
@@ -9,2 +9,2 @@ /** | ||
| 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,FORMAT_TEXT_COMMAND as a,$isNodeSelection as d,COMMAND_PRIORITY_LOW as u,DecoratorNode as f,$getState as h,toggleTextFormatType as l,$setState as g,TEXT_TYPE_TO_FORMAT as p,createState as m,shallowMergeConfig as v,RootNode as x,TextNode as y,LineBreakNode as S,TabNode as E,ParagraphNode as b,$isEditorState as w,HISTORY_MERGE_TAG as N,createEditor as O,mergeRegister as R,$getNodeByKey as C,$create as D,CLICK_COMMAND as M,isDOMNode as F,$getNodeFromDOMNode as I,addClassNamesToElement as _,createCommand as j,$createNodeSelection as A,$setSelection as k,removeClassNamesFromElement as P,KEY_TAB_COMMAND as K,OUTDENT_CONTENT_COMMAND as $,INDENT_CONTENT_COMMAND as z,INSERT_TAB_COMMAND as U,COMMAND_PRIORITY_CRITICAL as L,$isBlockElementNode as T,$createRangeSelection as B,$normalizeSelection__EXPERIMENTAL as W}from"lexical";export{configExtension,declarePeerDependency,defineExtension,safeCast,shallowMergeConfig}from"lexical";import{$handleIndentAndOutdent as G,$getNearestBlockElementAncestorOrThrow as V}from"@lexical/utils";const Z=Symbol.for("preact-signals");function J(){if(Y>1)return void Y--;let t,e=!1;for(;void 0!==Q;){let n=Q;for(Q=void 0,tt++;void 0!==n;){const i=n.o;if(n.o=void 0,n.f&=-3,!(8&n.f)&&st(n))try{n.c()}catch(n){e||(t=n,e=!0)}n=i}}if(tt=0,Y--,e)throw t}function H(t){if(Y>0)return t();Y++;try{return t()}finally{J()}}let q,Q;function X(t){const e=q;q=void 0;try{return t()}finally{q=e}}let Y=0,tt=0,et=0;function nt(t){if(void 0===q)return;let e=t.n;return void 0===e||e.t!==q?(e={i:0,S:t,p:q.s,n:void 0,t:q,e:void 0,x:void 0,r:e},void 0!==q.s&&(q.s.n=e),q.s=e,t.n=e,32&q.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=q.s,e.n=void 0,q.s.n=e,q.s=e),e):void 0}function it(t,e){this.v=t,this.i=0,this.n=void 0,this.t=void 0,this.W=null==e?void 0:e.watched,this.Z=null==e?void 0:e.unwatched,this.name=null==e?void 0:e.name}function ot(t,e){return new it(t,e)}function st(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 rt(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 ct(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 at(t,e){it.call(this,void 0),this.x=t,this.s=void 0,this.g=et-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 dt(t,e){return new at(t,e)}function ut(t){const e=t.u;if(t.u=void 0,"function"==typeof e){Y++;const n=q;q=void 0;try{e()}catch(e){throw t.f&=-2,t.f|=8,ft(t),e}finally{q=n,J()}}}function ft(t){for(let e=t.s;void 0!==e;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,ut(t)}function ht(t){if(q!==this)throw new Error("Out-of-order effect");ct(this),q=t,this.f&=-2,8&this.f&&ft(this),J()}function lt(t,e){this.x=t,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=null==e?void 0:e.name}function gt(t,e){const n=new lt(t,e);try{n.c()}catch(t){throw n.d(),t}const i=n.d.bind(n);return i[Symbol.dispose]=i,i}function pt(t,e={}){const n={};for(const i in t){const o=e[i],s=ot(void 0===o?t[i]:o);n[i]=s}return n}it.prototype.brand=Z,it.prototype.h=function(){return!0},it.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:X(()=>{var t;null==(t=this.W)||t.call(this)}))},it.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&&X(()=>{var t;null==(t=this.Z)||t.call(this)}))}},it.prototype.subscribe=function(t){return gt(()=>{const e=this.value,n=q;q=void 0;try{t(e)}finally{q=n}},{name:"sub"})},it.prototype.valueOf=function(){return this.value},it.prototype.toString=function(){return this.value+""},it.prototype.toJSON=function(){return this.value},it.prototype.peek=function(){const t=q;q=void 0;try{return this.value}finally{q=t}},Object.defineProperty(it.prototype,"value",{get(){const t=nt(this);return void 0!==t&&(t.i=this.i),this.v},set(t){if(t!==this.v){if(tt>100)throw new Error("Cycle detected");this.v=t,this.i++,et++,Y++;try{for(let t=this.t;void 0!==t;t=t.x)t.t.N()}finally{J()}}}}),at.prototype=new it,at.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===et)return!0;if(this.g=et,this.f|=1,this.i>0&&!st(this))return this.f&=-2,!0;const t=q;try{rt(this),q=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 q=t,ct(this),this.f&=-2,!0},at.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)}it.prototype.S.call(this,t)},at.prototype.U=function(t){if(void 0!==this.t&&(it.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)}},at.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(at.prototype,"value",{get(){if(1&this.f)throw new Error("Cycle detected");const t=nt(this);if(this.h(),void 0!==t&&(t.i=this.i),16&this.f)throw this.v;return this.v}}),lt.prototype.c=function(){const t=this.S();try{if(8&this.f)return;if(void 0===this.x)return;const t=this.x();"function"==typeof t&&(this.u=t)}finally{t()}},lt.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,ut(this),rt(this),Y++;const t=q;return q=this,ht.bind(this,t)},lt.prototype.N=function(){2&this.f||(this.f|=2,this.o=Q,Q=this)},lt.prototype.d=function(){this.f|=8,1&this.f||ft(this)},lt.prototype.dispose=function(){this.d()};const mt=t({build:(t,e,n)=>pt(e),config:e({defaultSelection:"rootEnd",disabled:!1}),name:"@lexical/extension/AutoFocus",register(t,e,n){const i=n.getOutput();return gt(()=>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 vt(){const t=o(),e=s(),n=r();t.clear(),t.append(n),null!==e&&n.select(),c(e)&&(e.format=0)}function xt(t,e=vt){return t.registerCommand(n,n=>(t.update(e),!0),i)}const yt=t({build:(t,e,n)=>pt(e),config:e({$onClear:vt}),name:"@lexical/extension/ClearEditor",register(t,e,n){const{$onClear:i}=n.getOutput();return gt(()=>xt(t,i.value))}});function St(t){const e=new Set,n=new Set;for(const i of Et(t)){const t="function"==typeof i?i:i.replace;e.add(t.getType()),n.add(t)}return{nodes:n,types:e}}function Et(t){return("function"==typeof t.nodes?t.nodes():t.nodes)||[]}const bt=m("format",{parse:t=>"number"==typeof t?t:0});class wt extends f{$config(){return this.config("decorator-text",{extends:f,stateConfigs:[{flat:!0,stateConfig:bt}]})}getFormat(){return h(this,bt)}getFormatFlags(t,e){return l(this.getFormat(),t,e)}hasFormat(t){const e=p[t];return 0!==(this.getFormat()&e)}setFormat(t){return g(this,bt,t)}toggleFormat(t){const e=this.getFormat(),n=l(e,t,null);return this.setFormat(n)}isInline(){return!0}createDOM(){return document.createElement("span")}updateDOM(){return!1}}function Nt(t){return t instanceof wt}function Ot(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 Rt(t,e,n=Dt){for(const[i,o]of Object.entries(n))t.hasFormat(o)&&(e=Ct(e,i));return e}function Ct(t,e){const n=document.createElement(e);return n.appendChild(t),n}const Dt={b:"bold",code:"code",em:"italic",i:"italic",mark:"highlight",s:"strikethrough",strong:"bold",sub:"subscript",sup:"superscript",u:"underline"},Mt=t({name:"@lexical/extension/DecoratorText",nodes:()=>[wt],register:(t,e,n)=>t.registerCommand(a,t=>{const e=s();if(d(e)||c(e))for(const n of e.getNodes())Nt(n)&&n.toggleFormat(t);return!1},u)});function Ft(t,e){let n;return ot(t(),{unwatched(){n&&(n(),n=void 0)},watched(){this.value=t(),n=e(this)}})}const It=t({build:t=>Ft(()=>t.getEditorState(),e=>t.registerUpdateListener(t=>{e.value=t.editorState})),name:"@lexical/extension/EditorState"});function _t(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 jt(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]=jt(n[t],i[t]);return t}return e}const At=0,kt=1,Pt=2,Kt=3,$t=4,zt=5,Ut=6,Lt=7;function Tt(t){return t.id===At}function Bt(t){return t.id===Pt}function Wt(t){return function(t){return t.id===kt}(t)||_t(305,String(t.id),String(kt)),Object.assign(t,{id:Pt})}const Gt=new Set;class Vt{builder;configs;_dependency;_peerNameSet;extension;state;_signal;constructor(t,e){this.builder=t,this.extension=e,this.configs=new Set,this.state={id:At}}mergeConfigs(){let t=this.extension.config||{};const e=this.extension.mergeConfig?this.extension.mergeConfig.bind(this.extension):v;for(const n of this.configs)t=e(t,n);return t}init(t){const e=this.state;Bt(e)||_t(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:Kt,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:$t,initResult:e,registerState:n})}(o,s,i)}build(t){const e=this.state;let n;e.id!==$t&&_t(307,String(e.id),String(zt)),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:zt,output:e,registerState:n})}(e,n,i)}register(t,e){this._signal=e;const n=this.state;n.id!==zt&&_t(308,String(n.id),String(zt));const i=this.extension.register&&this.extension.register(t,n.config,n.registerState);return this.state=function(t){return Object.assign(t,{id:Ut})}(n),()=>{const t=this.state;t.id!==Lt&&_t(309,String(n.id),String(Lt)),this.state=function(t){return Object.assign(t,{id:zt})}(t),i&&i()}}afterRegistration(t){const e=this.state;let n;return e.id!==Ut&&_t(310,String(e.id),String(Ut)),this.extension.afterRegistration&&(n=this.extension.afterRegistration(t,e.config,e.registerState)),this.state=function(t){return Object.assign(t,{id:Lt})}(e),n}getSignal(){return void 0===this._signal&&_t(311),this._signal}getInitResult(){void 0===this.extension.init&&_t(312,this.extension.name);const t=this.state;return function(t){return t.id>=$t}(t)||_t(313,String(t.id),String($t)),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>=Kt}(t)||_t(314,String(t.id),String(Kt)),{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&&_t(315,this.extension.name,t.name),e.getExtensionInitDependency()}getDependency(t){const e=this.builder.getExtensionRep(t);return void 0===e&&_t(315,this.extension.name,t.name),e.getExtensionDependency()}getState(){const t=this.state;return function(t){return t.id>=Lt}(t)||_t(316,String(t.id),String(Lt)),t}getDirectDependentNames(){return this.builder.incomingEdges.get(this.extension.name)||Gt}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>=zt})(t)||_t(317,this.extension.name),this._dependency={config:t.config,init:t.initResult,output:t.output}}return this._dependency}}const Zt={tag:N};function Jt(){const t=o();t.isEmpty()&&t.append(r())}const Ht=t({config:e({setOptions:Zt,updateOptions:Zt}),init:({$initialEditorState:t=Jt})=>({$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(w(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:[x,y,S,E,b]}),qt=Symbol.for("@lexical/extension/LexicalBuilder");function Qt(...t){return ne.fromExtensions(t).buildEditor()}function Xt(){}function Yt(t){throw t}function te(t){return Array.isArray(t)?t:[t]}const ee="0.41.1-nightly.20260316.0+prod.esm";class ne{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=ee,this.roots=t;for(const e of t)this.addExtension(e)}static fromExtensions(t){const e=[te(Ht)];for(const n of t)e.push(te(n));return new ne(e)}static maybeFromEditor(t){const e=t[qt];return e&&(e.PACKAGE_VERSION!==ee&&_t(292,e.PACKAGE_VERSION,ee),e instanceof ne||_t(293)),e}static fromEditor(t){const e=ne.maybeFromEditor(t);return void 0===e&&_t(294),e}constructEditor(){const{$initialEditorState:t,onError:e,...n}=this.buildCreateEditorArgs(),i=Object.assign(O({...n,...e?{onError:t=>{e(t,i)}}:{}}),{[qt]:this});for(const t of this.sortedExtensionReps())t.build(i);return i}buildEditor(){let t=Xt;function e(){try{t()}finally{t=Xt}}const n=Object.assign(this.constructEditor(),{dispose:e,[Symbol.dispose]:e});return t=R(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&&_t(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&&_t(296);const e=te(t),[n]=e;"string"!=typeof n.name&&_t(297,typeof n.name);let i=this.extensionNameMap.get(n.name);if(void 0!==i&&i.extension!==n&&_t(298,n.name),!i){i=new Vt(this,n),this.extensionNameMap.set(n.name,i);const t=this.conflicts.get(n.name);"string"==typeof t&&_t(299,n.name,t);for(const t of n.conflictsWith||[])this.extensionNameMap.has(t)&&_t(299,n.name,t),this.conflicts.set(t,n.name);for(const t of n.dependencies||[]){const e=te(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(Bt(o))return;const s=n.extension.name;var r;Tt(o)||_t(300,s,i||"[unknown]"),Tt(r=o)||_t(304,String(r.id),String(At)),o=Object.assign(r,{id:kt}),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=Wt(o),n.state=o,t.push(n)};for(const t of this.extensionNameMap.values())Tt(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&&_t(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 R(...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 Et(r)){if("function"!=typeof t){const e=n.get(t.replace);e&&_t(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&&jt(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=Yt),t}}function ie(t,e){const n=ne.fromEditor(t).getExtensionRep(e);return void 0===n&&_t(303,e.name),n.getExtensionDependency()}function oe(t,e){const n=ne.fromEditor(t).extensionNameMap.get(e);return n?n.getExtensionDependency():void 0}function se(t,e){const n=oe(t,e);return void 0===n&&_t(291,e),n}const re=new Set,ce=t({build(t,e,n){const i=n.getDependency(It).output,o=ot({watchedNodeKeys:new Map}),r=Ft(()=>{},()=>gt(()=>{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=C(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=dt(()=>(r.value||re).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:[It],name:"@lexical/extension/NodeSelection"}),ae=j("INSERT_HORIZONTAL_RULE_COMMAND");class de extends f{static getType(){return"horizontalrule"}static clone(t){return new de(t.__key)}static importJSON(t){return fe().updateFromJSON(t)}static importDOM(){return{hr:()=>({conversion:ue,priority:0})}}exportDOM(){return{element:document.createElement("hr")}}createDOM(t){const e=document.createElement("hr");return _(e,t.theme.hr),e}getTextContent(){return"\n"}isInline(){return!1}updateDOM(){return!1}}function ue(){return{node:fe()}}function fe(){return D(de)}function he(t){return t instanceof de}const le=t({dependencies:[It,ce],name:"@lexical/extension/HorizontalRule",nodes:()=>[de],register(t,e,n){const{watchNodeKey:i}=n.getDependency(ce).output,o=ot({nodeSelections:new Map}),r=t._config.theme.hrSelected??"selected";return R(t.registerCommand(M,t=>{if(F(t.target)){const e=I(t.target);if(he(e))return function(t,e=!1){const n=s(),i=t.isSelected(),o=t.getKey();let r;e&&d(n)?r=n:(r=A(),k(r)),i?r.delete(o):r.add(o)}(e,t.shiftKey),!0}return!1},u),t.registerMutationListener(de,(e,n)=>{H(()=>{let n=!1;const{nodeSelections:s}=o.peek();for(const[o,r]of e.entries())if("destroyed"===r)s.delete(o),n=!0;else{const e=s.get(o),r=t.getElementByKey(o);e?e.domNode.value=r:(n=!0,s.set(o,{domNode:ot(r),selectedSignal:i(o)}))}n&&(o.value={nodeSelections:s})})}),gt(()=>{const t=[];for(const{domNode:e,selectedSignal:n}of o.value.nodeSelections.values())t.push(gt(()=>{const t=e.value;if(t){n.value?_(t,r):P(t,r)}}));return R(...t)}))}});function ge(t){return t.canBeEmpty()}function pe(t,e,n=ge){return R(t.registerCommand(K,e=>{const n=s();if(!c(n))return!1;e.preventDefault();const i=function(t){if(t.getNodes().filter(t=>T(t)&&t.canIndent()).length>0)return!0;const e=t.anchor,n=t.focus,i=n.isBefore(e)?n:e,o=i.getNode(),s=V(o);if(s.canIndent()){const t=s.getKey();let e=B();if(e.anchor.set(t,0,"element"),e.focus.set(t,0,"element"),e=W(e),e.anchor.is(i))return!0}return!1}(n)?e.shiftKey?$:z:U;return t.dispatchCommand(i,void 0)},i),t.registerCommand(z,()=>{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 G(e=>{if(o(e)){const n=e.getIndent()+1;(!t||n<t)&&e.setIndent(n)}})},L))}const me=t({build:(t,e,n)=>pt(e),config:e({$canIndent:ge,disabled:!1,maxIndent:null}),name:"@lexical/extension/TabIndentation",register(t,e,n){const{disabled:i,maxIndent:o,$canIndent:s}=n.getOutput();return gt(()=>{if(!i.value)return pe(t,o,s)})}});export{fe as $createHorizontalRuleNode,Nt as $isDecoratorTextNode,he as $isHorizontalRuleNode,mt as AutoFocusExtension,yt as ClearEditorExtension,Mt as DecoratorTextExtension,wt as DecoratorTextNode,It as EditorStateExtension,le as HorizontalRuleExtension,de as HorizontalRuleNode,ae as INSERT_HORIZONTAL_RULE_COMMAND,Ht as InitialStateExtension,ne as LexicalBuilder,ce as NodeSelectionExtension,me as TabIndentationExtension,Ot as applyFormatFromStyle,Rt as applyFormatToDom,H as batch,Qt as buildEditorFromExtensions,dt as computed,gt as effect,ie as getExtensionDependencyFromEditor,St as getKnownTypesAndNodes,oe as getPeerDependencyFromEditor,se as getPeerDependencyFromEditorOrThrow,pt as namedSignals,xt as registerClearEditor,pe as registerTabIndentation,ot as signal,X as untracked,Ft as watchedSignal}; | ||
| 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,FORMAT_TEXT_COMMAND as a,$isNodeSelection as d,COMMAND_PRIORITY_LOW as u,DecoratorNode as f,$getState as h,toggleTextFormatType as l,$setState as g,TEXT_TYPE_TO_FORMAT as p,createState as m,shallowMergeConfig as v,RootNode as x,TextNode as y,LineBreakNode as S,TabNode as E,ParagraphNode as b,$isEditorState as w,HISTORY_MERGE_TAG as N,createEditor as O,mergeRegister as R,$getNodeByKey as C,$create as D,CLICK_COMMAND as M,isDOMNode as F,$getNodeFromDOMNode as I,addClassNamesToElement as _,createCommand as j,$createNodeSelection as A,$setSelection as k,removeClassNamesFromElement as P,KEY_TAB_COMMAND as K,OUTDENT_CONTENT_COMMAND as $,INDENT_CONTENT_COMMAND as z,INSERT_TAB_COMMAND as U,COMMAND_PRIORITY_CRITICAL as L,$isBlockElementNode as T,$createRangeSelection as B,$normalizeSelection__EXPERIMENTAL as W}from"lexical";export{configExtension,declarePeerDependency,defineExtension,safeCast,shallowMergeConfig}from"lexical";import{$handleIndentAndOutdent as G,$getNearestBlockElementAncestorOrThrow as V}from"@lexical/utils";const Z=Symbol.for("preact-signals");function J(){if(Y>1)return void Y--;let t,e=!1;for(;void 0!==Q;){let n=Q;for(Q=void 0,tt++;void 0!==n;){const i=n.o;if(n.o=void 0,n.f&=-3,!(8&n.f)&&st(n))try{n.c()}catch(n){e||(t=n,e=!0)}n=i}}if(tt=0,Y--,e)throw t}function H(t){if(Y>0)return t();Y++;try{return t()}finally{J()}}let q,Q;function X(t){const e=q;q=void 0;try{return t()}finally{q=e}}let Y=0,tt=0,et=0;function nt(t){if(void 0===q)return;let e=t.n;return void 0===e||e.t!==q?(e={i:0,S:t,p:q.s,n:void 0,t:q,e:void 0,x:void 0,r:e},void 0!==q.s&&(q.s.n=e),q.s=e,t.n=e,32&q.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=q.s,e.n=void 0,q.s.n=e,q.s=e),e):void 0}function it(t,e){this.v=t,this.i=0,this.n=void 0,this.t=void 0,this.W=null==e?void 0:e.watched,this.Z=null==e?void 0:e.unwatched,this.name=null==e?void 0:e.name}function ot(t,e){return new it(t,e)}function st(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 rt(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 ct(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 at(t,e){it.call(this,void 0),this.x=t,this.s=void 0,this.g=et-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 dt(t,e){return new at(t,e)}function ut(t){const e=t.u;if(t.u=void 0,"function"==typeof e){Y++;const n=q;q=void 0;try{e()}catch(e){throw t.f&=-2,t.f|=8,ft(t),e}finally{q=n,J()}}}function ft(t){for(let e=t.s;void 0!==e;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,ut(t)}function ht(t){if(q!==this)throw new Error("Out-of-order effect");ct(this),q=t,this.f&=-2,8&this.f&&ft(this),J()}function lt(t,e){this.x=t,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=null==e?void 0:e.name}function gt(t,e){const n=new lt(t,e);try{n.c()}catch(t){throw n.d(),t}const i=n.d.bind(n);return i[Symbol.dispose]=i,i}function pt(t,e={}){const n={};for(const i in t){const o=e[i],s=ot(void 0===o?t[i]:o);n[i]=s}return n}it.prototype.brand=Z,it.prototype.h=function(){return!0},it.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:X(()=>{var t;null==(t=this.W)||t.call(this)}))},it.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&&X(()=>{var t;null==(t=this.Z)||t.call(this)}))}},it.prototype.subscribe=function(t){return gt(()=>{const e=this.value,n=q;q=void 0;try{t(e)}finally{q=n}},{name:"sub"})},it.prototype.valueOf=function(){return this.value},it.prototype.toString=function(){return this.value+""},it.prototype.toJSON=function(){return this.value},it.prototype.peek=function(){const t=q;q=void 0;try{return this.value}finally{q=t}},Object.defineProperty(it.prototype,"value",{get(){const t=nt(this);return void 0!==t&&(t.i=this.i),this.v},set(t){if(t!==this.v){if(tt>100)throw new Error("Cycle detected");this.v=t,this.i++,et++,Y++;try{for(let t=this.t;void 0!==t;t=t.x)t.t.N()}finally{J()}}}}),at.prototype=new it,at.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===et)return!0;if(this.g=et,this.f|=1,this.i>0&&!st(this))return this.f&=-2,!0;const t=q;try{rt(this),q=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 q=t,ct(this),this.f&=-2,!0},at.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)}it.prototype.S.call(this,t)},at.prototype.U=function(t){if(void 0!==this.t&&(it.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)}},at.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(at.prototype,"value",{get(){if(1&this.f)throw new Error("Cycle detected");const t=nt(this);if(this.h(),void 0!==t&&(t.i=this.i),16&this.f)throw this.v;return this.v}}),lt.prototype.c=function(){const t=this.S();try{if(8&this.f)return;if(void 0===this.x)return;const t=this.x();"function"==typeof t&&(this.u=t)}finally{t()}},lt.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,ut(this),rt(this),Y++;const t=q;return q=this,ht.bind(this,t)},lt.prototype.N=function(){2&this.f||(this.f|=2,this.o=Q,Q=this)},lt.prototype.d=function(){this.f|=8,1&this.f||ft(this)},lt.prototype.dispose=function(){this.d()};const mt=t({build:(t,e,n)=>pt(e),config:e({defaultSelection:"rootEnd",disabled:!1}),name:"@lexical/extension/AutoFocus",register(t,e,n){const i=n.getOutput();return gt(()=>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 vt(){const t=o(),e=s(),n=r();t.clear(),t.append(n),null!==e&&n.select(),c(e)&&(e.format=0)}function xt(t,e=vt){return t.registerCommand(n,n=>(t.update(e),!0),i)}const yt=t({build:(t,e,n)=>pt(e),config:e({$onClear:vt}),name:"@lexical/extension/ClearEditor",register(t,e,n){const{$onClear:i}=n.getOutput();return gt(()=>xt(t,i.value))}});function St(t){const e=new Set,n=new Set;for(const i of Et(t)){const t="function"==typeof i?i:i.replace;e.add(t.getType()),n.add(t)}return{nodes:n,types:e}}function Et(t){return("function"==typeof t.nodes?t.nodes():t.nodes)||[]}const bt=m("format",{parse:t=>"number"==typeof t?t:0});class wt extends f{$config(){return this.config("decorator-text",{extends:f,stateConfigs:[{flat:!0,stateConfig:bt}]})}getFormat(){return h(this,bt)}getFormatFlags(t,e){return l(this.getFormat(),t,e)}hasFormat(t){const e=p[t];return 0!==(this.getFormat()&e)}setFormat(t){return g(this,bt,t)}toggleFormat(t){const e=this.getFormat(),n=l(e,t,null);return this.setFormat(n)}isInline(){return!0}createDOM(){return document.createElement("span")}updateDOM(){return!1}}function Nt(t){return t instanceof wt}function Ot(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 Rt(t,e,n=Dt){for(const[i,o]of Object.entries(n))t.hasFormat(o)&&(e=Ct(e,i));return e}function Ct(t,e){const n=document.createElement(e);return n.appendChild(t),n}const Dt={b:"bold",code:"code",em:"italic",i:"italic",mark:"highlight",s:"strikethrough",strong:"bold",sub:"subscript",sup:"superscript",u:"underline"},Mt=t({name:"@lexical/extension/DecoratorText",nodes:()=>[wt],register:(t,e,n)=>t.registerCommand(a,t=>{const e=s();if(d(e)||c(e))for(const n of e.getNodes())Nt(n)&&n.toggleFormat(t);return!1},u)});function Ft(t,e){let n;return ot(t(),{unwatched(){n&&(n(),n=void 0)},watched(){this.value=t(),n=e(this)}})}const It=t({build:t=>Ft(()=>t.getEditorState(),e=>t.registerUpdateListener(t=>{e.value=t.editorState})),name:"@lexical/extension/EditorState"});function _t(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 jt(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]=jt(n[t],i[t]);return t}return e}const At=0,kt=1,Pt=2,Kt=3,$t=4,zt=5,Ut=6,Lt=7;function Tt(t){return t.id===At}function Bt(t){return t.id===Pt}function Wt(t){return function(t){return t.id===kt}(t)||_t(305,String(t.id),String(kt)),Object.assign(t,{id:Pt})}const Gt=new Set;class Vt{builder;configs;_dependency;_peerNameSet;extension;state;_signal;constructor(t,e){this.builder=t,this.extension=e,this.configs=new Set,this.state={id:At}}mergeConfigs(){let t=this.extension.config||{};const e=this.extension.mergeConfig?this.extension.mergeConfig.bind(this.extension):v;for(const n of this.configs)t=e(t,n);return t}init(t){const e=this.state;Bt(e)||_t(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:Kt,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:$t,initResult:e,registerState:n})}(o,s,i)}build(t){const e=this.state;let n;e.id!==$t&&_t(307,String(e.id),String(zt)),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:zt,output:e,registerState:n})}(e,n,i)}register(t,e){this._signal=e;const n=this.state;n.id!==zt&&_t(308,String(n.id),String(zt));const i=this.extension.register&&this.extension.register(t,n.config,n.registerState);return this.state=function(t){return Object.assign(t,{id:Ut})}(n),()=>{const t=this.state;t.id!==Lt&&_t(309,String(n.id),String(Lt)),this.state=function(t){return Object.assign(t,{id:zt})}(t),i&&i()}}afterRegistration(t){const e=this.state;let n;return e.id!==Ut&&_t(310,String(e.id),String(Ut)),this.extension.afterRegistration&&(n=this.extension.afterRegistration(t,e.config,e.registerState)),this.state=function(t){return Object.assign(t,{id:Lt})}(e),n}getSignal(){return void 0===this._signal&&_t(311),this._signal}getInitResult(){void 0===this.extension.init&&_t(312,this.extension.name);const t=this.state;return function(t){return t.id>=$t}(t)||_t(313,String(t.id),String($t)),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>=Kt}(t)||_t(314,String(t.id),String(Kt)),{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&&_t(315,this.extension.name,t.name),e.getExtensionInitDependency()}getDependency(t){const e=this.builder.getExtensionRep(t);return void 0===e&&_t(315,this.extension.name,t.name),e.getExtensionDependency()}getState(){const t=this.state;return function(t){return t.id>=Lt}(t)||_t(316,String(t.id),String(Lt)),t}getDirectDependentNames(){return this.builder.incomingEdges.get(this.extension.name)||Gt}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>=zt})(t)||_t(317,this.extension.name),this._dependency={config:t.config,init:t.initResult,output:t.output}}return this._dependency}}const Zt={tag:N};function Jt(){const t=o();t.isEmpty()&&t.append(r())}const Ht=t({config:e({setOptions:Zt,updateOptions:Zt}),init:({$initialEditorState:t=Jt})=>({$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(w(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:[x,y,S,E,b]}),qt=Symbol.for("@lexical/extension/LexicalBuilder");function Qt(...t){return ne.fromExtensions(t).buildEditor()}function Xt(){}function Yt(t){throw t}function te(t){return Array.isArray(t)?t:[t]}const ee="0.41.1-nightly.20260317.0+prod.esm";class ne{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=ee,this.roots=t;for(const e of t)this.addExtension(e)}static fromExtensions(t){const e=[te(Ht)];for(const n of t)e.push(te(n));return new ne(e)}static maybeFromEditor(t){const e=t[qt];return e&&(e.PACKAGE_VERSION!==ee&&_t(292,e.PACKAGE_VERSION,ee),e instanceof ne||_t(293)),e}static fromEditor(t){const e=ne.maybeFromEditor(t);return void 0===e&&_t(294),e}constructEditor(){const{$initialEditorState:t,onError:e,...n}=this.buildCreateEditorArgs(),i=Object.assign(O({...n,...e?{onError:t=>{e(t,i)}}:{}}),{[qt]:this});for(const t of this.sortedExtensionReps())t.build(i);return i}buildEditor(){let t=Xt;function e(){try{t()}finally{t=Xt}}const n=Object.assign(this.constructEditor(),{dispose:e,[Symbol.dispose]:e});return t=R(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&&_t(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&&_t(296);const e=te(t),[n]=e;"string"!=typeof n.name&&_t(297,typeof n.name);let i=this.extensionNameMap.get(n.name);if(void 0!==i&&i.extension!==n&&_t(298,n.name),!i){i=new Vt(this,n),this.extensionNameMap.set(n.name,i);const t=this.conflicts.get(n.name);"string"==typeof t&&_t(299,n.name,t);for(const t of n.conflictsWith||[])this.extensionNameMap.has(t)&&_t(299,n.name,t),this.conflicts.set(t,n.name);for(const t of n.dependencies||[]){const e=te(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(Bt(o))return;const s=n.extension.name;var r;Tt(o)||_t(300,s,i||"[unknown]"),Tt(r=o)||_t(304,String(r.id),String(At)),o=Object.assign(r,{id:kt}),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=Wt(o),n.state=o,t.push(n)};for(const t of this.extensionNameMap.values())Tt(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&&_t(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 R(...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 Et(r)){if("function"!=typeof t){const e=n.get(t.replace);e&&_t(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&&jt(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=Yt),t}}function ie(t,e){const n=ne.fromEditor(t).getExtensionRep(e);return void 0===n&&_t(303,e.name),n.getExtensionDependency()}function oe(t,e){const n=ne.fromEditor(t).extensionNameMap.get(e);return n?n.getExtensionDependency():void 0}function se(t,e){const n=oe(t,e);return void 0===n&&_t(291,e),n}const re=new Set,ce=t({build(t,e,n){const i=n.getDependency(It).output,o=ot({watchedNodeKeys:new Map}),r=Ft(()=>{},()=>gt(()=>{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=C(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=dt(()=>(r.value||re).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:[It],name:"@lexical/extension/NodeSelection"}),ae=j("INSERT_HORIZONTAL_RULE_COMMAND");class de extends f{static getType(){return"horizontalrule"}static clone(t){return new de(t.__key)}static importJSON(t){return fe().updateFromJSON(t)}static importDOM(){return{hr:()=>({conversion:ue,priority:0})}}exportDOM(){return{element:document.createElement("hr")}}createDOM(t){const e=document.createElement("hr");return _(e,t.theme.hr),e}getTextContent(){return"\n"}isInline(){return!1}updateDOM(){return!1}}function ue(){return{node:fe()}}function fe(){return D(de)}function he(t){return t instanceof de}const le=t({dependencies:[It,ce],name:"@lexical/extension/HorizontalRule",nodes:()=>[de],register(t,e,n){const{watchNodeKey:i}=n.getDependency(ce).output,o=ot({nodeSelections:new Map}),r=t._config.theme.hrSelected??"selected";return R(t.registerCommand(M,t=>{if(F(t.target)){const e=I(t.target);if(he(e))return function(t,e=!1){const n=s(),i=t.isSelected(),o=t.getKey();let r;e&&d(n)?r=n:(r=A(),k(r)),i?r.delete(o):r.add(o)}(e,t.shiftKey),!0}return!1},u),t.registerMutationListener(de,(e,n)=>{H(()=>{let n=!1;const{nodeSelections:s}=o.peek();for(const[o,r]of e.entries())if("destroyed"===r)s.delete(o),n=!0;else{const e=s.get(o),r=t.getElementByKey(o);e?e.domNode.value=r:(n=!0,s.set(o,{domNode:ot(r),selectedSignal:i(o)}))}n&&(o.value={nodeSelections:s})})}),gt(()=>{const t=[];for(const{domNode:e,selectedSignal:n}of o.value.nodeSelections.values())t.push(gt(()=>{const t=e.value;if(t){n.value?_(t,r):P(t,r)}}));return R(...t)}))}});function ge(t){return t.canBeEmpty()}function pe(t,e,n=ge){return R(t.registerCommand(K,e=>{const n=s();if(!c(n))return!1;e.preventDefault();const i=function(t){if(t.getNodes().filter(t=>T(t)&&t.canIndent()).length>0)return!0;const e=t.anchor,n=t.focus,i=n.isBefore(e)?n:e,o=i.getNode(),s=V(o);if(s.canIndent()){const t=s.getKey();let e=B();if(e.anchor.set(t,0,"element"),e.focus.set(t,0,"element"),e=W(e),e.anchor.is(i))return!0}return!1}(n)?e.shiftKey?$:z:U;return t.dispatchCommand(i,void 0)},i),t.registerCommand(z,()=>{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 G(e=>{if(o(e)){const n=e.getIndent()+1;(!t||n<t)&&e.setIndent(n)}})},L))}const me=t({build:(t,e,n)=>pt(e),config:e({$canIndent:ge,disabled:!1,maxIndent:null}),name:"@lexical/extension/TabIndentation",register(t,e,n){const{disabled:i,maxIndent:o,$canIndent:s}=n.getOutput();return gt(()=>{if(!i.value)return pe(t,o,s)})}});export{fe as $createHorizontalRuleNode,Nt as $isDecoratorTextNode,he as $isHorizontalRuleNode,mt as AutoFocusExtension,yt as ClearEditorExtension,Mt as DecoratorTextExtension,wt as DecoratorTextNode,It as EditorStateExtension,le as HorizontalRuleExtension,de as HorizontalRuleNode,ae as INSERT_HORIZONTAL_RULE_COMMAND,Ht as InitialStateExtension,ne as LexicalBuilder,ce as NodeSelectionExtension,me as TabIndentationExtension,Ot as applyFormatFromStyle,Rt as applyFormatToDom,H as batch,Qt as buildEditorFromExtensions,dt as computed,gt as effect,ie as getExtensionDependencyFromEditor,St as getKnownTypesAndNodes,oe as getPeerDependencyFromEditor,se as getPeerDependencyFromEditorOrThrow,pt as namedSignals,xt as registerClearEditor,pe as registerTabIndentation,ot as signal,X as untracked,Ft as watchedSignal}; |
+3
-3
@@ -9,3 +9,3 @@ { | ||
| ], | ||
| "version": "0.41.1-nightly.20260316.0", | ||
| "version": "0.41.1-nightly.20260317.0", | ||
| "license": "MIT", | ||
@@ -27,5 +27,5 @@ "repository": { | ||
| "dependencies": { | ||
| "@lexical/utils": "0.41.1-nightly.20260316.0", | ||
| "@lexical/utils": "0.41.1-nightly.20260317.0", | ||
| "@preact/signals-core": "^1.11.0", | ||
| "lexical": "0.41.1-nightly.20260316.0" | ||
| "lexical": "0.41.1-nightly.20260317.0" | ||
| }, | ||
@@ -32,0 +32,0 @@ "exports": { |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed