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