@lexical/extension 0.37.1-nightly.20251016.0 → 0.37.1-nightly.20251020.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/LexicalBuilder.d.ts
CHANGED
|
@@ -5,10 +5,11 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
import { type AnyLexicalExtension, type AnyLexicalExtensionArgument, type AnyNormalizedLexicalExtensionArgument, type InitialEditorConfig, type LexicalEditor, type LexicalEditorWithDispose, type LexicalExtensionConfig } from 'lexical';
|
|
8
|
+
import { type AnyLexicalExtension, type AnyLexicalExtensionArgument, type AnyNormalizedLexicalExtensionArgument, type CreateEditorArgs, type InitialEditorConfig, type LexicalEditor, type LexicalEditorWithDispose, type LexicalExtensionConfig } from 'lexical';
|
|
9
9
|
import { ExtensionRep } from './ExtensionRep';
|
|
10
10
|
/** @internal Use a well-known symbol for dev tools purposes */
|
|
11
11
|
export declare const builderSymbol: unique symbol;
|
|
12
|
+
type BuildCreateEditorArgs = Omit<CreateEditorArgs, 'onError'> & Pick<InitialEditorConfig, 'onError' | '$initialEditorState'>;
|
|
12
13
|
/**
|
|
13
14
|
* Build a LexicalEditor by combining together one or more extensions, optionally
|
|
14
15
|
* overriding some of their configuration.
|
|
@@ -71,6 +72,6 @@ export declare class LexicalBuilder {
|
|
|
71
72
|
addExtension(arg: AnyLexicalExtensionArgument): void;
|
|
72
73
|
sortedExtensionReps(): readonly ExtensionRep<AnyLexicalExtension>[];
|
|
73
74
|
registerEditor(editor: LexicalEditor): () => void;
|
|
74
|
-
buildCreateEditorArgs():
|
|
75
|
+
buildCreateEditorArgs(): BuildCreateEditorArgs;
|
|
75
76
|
}
|
|
76
77
|
export {};
|
package/LexicalExtension.dev.js
CHANGED
|
@@ -154,7 +154,7 @@ const ClearEditorExtension = lexical.defineExtension({
|
|
|
154
154
|
function getKnownTypesAndNodes(config) {
|
|
155
155
|
const types = new Set();
|
|
156
156
|
const nodes = new Set();
|
|
157
|
-
for (const klassOrReplacement of config
|
|
157
|
+
for (const klassOrReplacement of getNodeConfig(config)) {
|
|
158
158
|
const klass = typeof klassOrReplacement === 'function' ? klassOrReplacement : klassOrReplacement.replace;
|
|
159
159
|
types.add(klass.getType());
|
|
160
160
|
nodes.add(klass);
|
|
@@ -164,6 +164,9 @@ function getKnownTypesAndNodes(config) {
|
|
|
164
164
|
types
|
|
165
165
|
};
|
|
166
166
|
}
|
|
167
|
+
function getNodeConfig(config) {
|
|
168
|
+
return (typeof config.nodes === 'function' ? config.nodes() : config.nodes) || [];
|
|
169
|
+
}
|
|
167
170
|
|
|
168
171
|
/**
|
|
169
172
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -613,7 +616,6 @@ const InitialStateExtension = lexical.defineExtension({
|
|
|
613
616
|
|
|
614
617
|
/** @internal Use a well-known symbol for dev tools purposes */
|
|
615
618
|
const builderSymbol = Symbol.for('@lexical/extension/LexicalBuilder');
|
|
616
|
-
|
|
617
619
|
/**
|
|
618
620
|
* Build a LexicalEditor by combining together one or more extensions, optionally
|
|
619
621
|
* overriding some of their configuration.
|
|
@@ -670,7 +672,7 @@ function maybeWithBuilder(editor) {
|
|
|
670
672
|
function normalizeExtensionArgument(arg) {
|
|
671
673
|
return Array.isArray(arg) ? arg : [arg];
|
|
672
674
|
}
|
|
673
|
-
const PACKAGE_VERSION = "0.37.1-nightly.
|
|
675
|
+
const PACKAGE_VERSION = "0.37.1-nightly.20251020.0+dev.cjs";
|
|
674
676
|
|
|
675
677
|
/** @internal */
|
|
676
678
|
class LexicalBuilder {
|
|
@@ -936,7 +938,7 @@ class LexicalBuilder {
|
|
|
936
938
|
config.$initialEditorState = extension.$initialEditorState;
|
|
937
939
|
}
|
|
938
940
|
if (extension.nodes) {
|
|
939
|
-
for (const node of extension
|
|
941
|
+
for (const node of getNodeConfig(extension)) {
|
|
940
942
|
if (typeof node !== 'function') {
|
|
941
943
|
const conflictExtension = replacedNodes.get(node.replace);
|
|
942
944
|
if (conflictExtension) {
|
package/LexicalExtension.dev.mjs
CHANGED
|
@@ -153,7 +153,7 @@ const ClearEditorExtension = defineExtension({
|
|
|
153
153
|
function getKnownTypesAndNodes(config) {
|
|
154
154
|
const types = new Set();
|
|
155
155
|
const nodes = new Set();
|
|
156
|
-
for (const klassOrReplacement of config
|
|
156
|
+
for (const klassOrReplacement of getNodeConfig(config)) {
|
|
157
157
|
const klass = typeof klassOrReplacement === 'function' ? klassOrReplacement : klassOrReplacement.replace;
|
|
158
158
|
types.add(klass.getType());
|
|
159
159
|
nodes.add(klass);
|
|
@@ -163,6 +163,9 @@ function getKnownTypesAndNodes(config) {
|
|
|
163
163
|
types
|
|
164
164
|
};
|
|
165
165
|
}
|
|
166
|
+
function getNodeConfig(config) {
|
|
167
|
+
return (typeof config.nodes === 'function' ? config.nodes() : config.nodes) || [];
|
|
168
|
+
}
|
|
166
169
|
|
|
167
170
|
/**
|
|
168
171
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -612,7 +615,6 @@ const InitialStateExtension = defineExtension({
|
|
|
612
615
|
|
|
613
616
|
/** @internal Use a well-known symbol for dev tools purposes */
|
|
614
617
|
const builderSymbol = Symbol.for('@lexical/extension/LexicalBuilder');
|
|
615
|
-
|
|
616
618
|
/**
|
|
617
619
|
* Build a LexicalEditor by combining together one or more extensions, optionally
|
|
618
620
|
* overriding some of their configuration.
|
|
@@ -669,7 +671,7 @@ function maybeWithBuilder(editor) {
|
|
|
669
671
|
function normalizeExtensionArgument(arg) {
|
|
670
672
|
return Array.isArray(arg) ? arg : [arg];
|
|
671
673
|
}
|
|
672
|
-
const PACKAGE_VERSION = "0.37.1-nightly.
|
|
674
|
+
const PACKAGE_VERSION = "0.37.1-nightly.20251020.0+dev.esm";
|
|
673
675
|
|
|
674
676
|
/** @internal */
|
|
675
677
|
class LexicalBuilder {
|
|
@@ -935,7 +937,7 @@ class LexicalBuilder {
|
|
|
935
937
|
config.$initialEditorState = extension.$initialEditorState;
|
|
936
938
|
}
|
|
937
939
|
if (extension.nodes) {
|
|
938
|
-
for (const node of extension
|
|
940
|
+
for (const node of getNodeConfig(extension)) {
|
|
939
941
|
if (typeof node !== 'function') {
|
|
940
942
|
const conflictExtension = replacedNodes.get(node.replace);
|
|
941
943
|
if (conflictExtension) {
|
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(d>1)return void d--;let t,e=!1;for(;void 0!==r;){let n=r;for(r=void 0,a++;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(a=0,d--,e)throw t}function o(t){if(d>0)return t();d++;try{return t()}finally{i()}}let s,r;function c(t){const e=s;s=void 0;try{return t()}finally{s=e}}let d=0,a=0,f=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 l(t,e){this.v=t,this.i=0,this.n=void 0,this.t=void 0,this.W=null==e?void 0:e.watched,this.Z=null==e?void 0:e.unwatched,this.name=null==e?void 0:e.name}function h(t,e){return new l(t,e)}function g(t){for(let e=t.s;void 0!==e;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return!0;return!1}function p(t){for(let e=t.s;void 0!==e;e=e.n){const n=e.S.n;if(void 0!==n&&(e.r=n),e.S.n=e,e.i=-1,void 0===e.n){t.s=e;break}}}function m(t){let e,n=t.s;for(;void 0!==n;){const t=n.p;-1===n.i?(n.S.U(n),void 0!==t&&(t.n=n.n),void 0!==n.n&&(n.n.p=t)):e=n,n.S.n=n.r,void 0!==n.r&&(n.r=void 0),n=t}t.s=e}function x(t,e){l.call(this,void 0),this.x=t,this.s=void 0,this.g=f-1,this.f=4,this.W=null==e?void 0:e.watched,this.Z=null==e?void 0:e.unwatched,this.name=null==e?void 0:e.name}function E(t,e){return new x(t,e)}function v(t){const e=t.u;if(t.u=void 0,"function"==typeof e){d++;const n=s;s=void 0;try{e()}catch(e){throw t.f&=-2,t.f|=8,S(t),e}finally{s=n,i()}}}function S(t){for(let e=t.s;void 0!==e;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,v(t)}function y(t){if(s!==this)throw new Error("Out-of-order effect");m(this),s=t,this.f&=-2,8&this.f&&S(this),i()}function N(t,e){this.x=t,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=null==e?void 0:e.name}function b(t,e){const n=new N(t,e);try{n.c()}catch(t){throw n.d(),t}const i=n.d.bind(n);return i[Symbol.dispose]=i,i}function R(t,e={}){const n={};for(const i in t){const o=e[i],s=h(void 0===o?t[i]:o);n[i]=s}return n}l.prototype.brand=n,l.prototype.h=function(){return!0},l.prototype.S=function(t){const e=this.t;e!==t&&void 0===t.e&&(t.x=e,this.t=t,void 0!==e?e.e=t:c(()=>{var t;null==(t=this.W)||t.call(this)}))},l.prototype.U=function(t){if(void 0!==this.t){const e=t.e,n=t.x;void 0!==e&&(e.x=n,t.e=void 0),void 0!==n&&(n.e=e,t.x=void 0),t===this.t&&(this.t=n,void 0===n&&c(()=>{var t;null==(t=this.Z)||t.call(this)}))}},l.prototype.subscribe=function(t){return b(()=>{const e=this.value,n=s;s=void 0;try{t(e)}finally{s=n}},{name:"sub"})},l.prototype.valueOf=function(){return this.value},l.prototype.toString=function(){return this.value+""},l.prototype.toJSON=function(){return this.value},l.prototype.peek=function(){const t=s;s=void 0;try{return this.value}finally{s=t}},Object.defineProperty(l.prototype,"value",{get(){const t=u(this);return void 0!==t&&(t.i=this.i),this.v},set(t){if(t!==this.v){if(a>100)throw new Error("Cycle detected");this.v=t,this.i++,f++,d++;try{for(let t=this.t;void 0!==t;t=t.x)t.t.N()}finally{i()}}}}),x.prototype=new l,x.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if(32==(36&this.f))return!0;if(this.f&=-5,this.g===f)return!0;if(this.g=f,this.f|=1,this.i>0&&!g(this))return this.f&=-2,!0;const t=s;try{p(this),s=this;const t=this.x();(16&this.f||this.v!==t||0===this.i)&&(this.v=t,this.f&=-17,this.i++)}catch(t){this.v=t,this.f|=16,this.i++}return s=t,m(this),this.f&=-2,!0},x.prototype.S=function(t){if(void 0===this.t){this.f|=36;for(let t=this.s;void 0!==t;t=t.n)t.S.S(t)}l.prototype.S.call(this,t)},x.prototype.U=function(t){if(void 0!==this.t&&(l.prototype.U.call(this,t),void 0===this.t)){this.f&=-33;for(let t=this.s;void 0!==t;t=t.n)t.S.U(t)}},x.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(let t=this.t;void 0!==t;t=t.x)t.t.N()}},Object.defineProperty(x.prototype,"value",{get(){if(1&this.f)throw new Error("Cycle detected");const t=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),d++;const t=s;return s=this,y.bind(this,t)},N.prototype.N=function(){2&this.f||(this.f|=2,this.o=r,r=this)},N.prototype.d=function(){this.f|=8,1&this.f||S(this)},N.prototype.dispose=function(){this.d()};const O=t.defineExtension({build:(t,e,n)=>R(e),config:t.safeCast({defaultSelection:"rootEnd",disabled:!1}),name:"@lexical/extension/AutoFocus",register(t,e,n){const i=n.getOutput();return b(()=>i.disabled.value?void 0:t.registerRootListener(e=>{t.focus(()=>{const t=document.activeElement;null===e||null!==t&&e.contains(t)||e.focus({preventScroll:!0})},{defaultSelection:i.defaultSelection.peek()})}))}});function w(){const e=t.$getRoot(),n=t.$getSelection(),i=t.$createParagraphNode();e.clear(),e.append(i),null!==n&&i.select(),t.$isRangeSelection(n)&&(n.format=0)}function C(e,n=w){return e.registerCommand(t.CLEAR_EDITOR_COMMAND,t=>(e.update(n),!0),t.COMMAND_PRIORITY_EDITOR)}const M=t.defineExtension({build:(t,e,n)=>R(e),config:t.safeCast({$onClear:w}),name:"@lexical/extension/ClearEditor",register(t,e,n){const{$onClear:i}=n.getOutput();return b(()=>C(t,i.value))}});function D(t,e){let n;return h(t(),{unwatched(){n&&(n(),n=void 0)},watched(){this.value=t(),n=e(this)}})}const _=t.defineExtension({build:t=>D(()=>t.getEditorState(),e=>t.registerUpdateListener(t=>{e.value=t.editorState})),name:"@lexical/extension/EditorState"});function I(t,...e){const n=new URL("https://lexical.dev/docs/error"),i=new URLSearchParams;i.append("code",t);for(const t of e)i.append("v",t);throw n.search=i.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function T(t,e){if(t&&e&&!Array.isArray(e)&&"object"==typeof t&&"object"==typeof e){const n=t,i=e;for(const t in i)n[t]=T(n[t],i[t]);return t}return e}const A=0,$=1,P=2,j=3,K=4,L=5,k=6,z=7;function B(t){return t.id===A}function U(t){return t.id===P}function F(t){return function(t){return t.id===$}(t)||I(305,String(t.id),String($)),Object.assign(t,{id:P})}const H=new Set;class G{builder;configs;_dependency;_peerNameSet;extension;state;_signal;constructor(t,e){this.builder=t,this.extension=e,this.configs=new Set,this.state={id:A}}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;U(e)||I(306,String(e.id));const n={getDependency:this.getInitDependency.bind(this),getDirectDependentNames:this.getDirectDependentNames.bind(this),getPeer:this.getInitPeer.bind(this),getPeerNameSet:this.getPeerNameSet.bind(this)},i={...n,getDependency:this.getDependency.bind(this),getInitResult:this.getInitResult.bind(this),getPeer:this.getPeer.bind(this)},o=function(t,e,n){return Object.assign(t,{config:e,id:j,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:K,initResult:e,registerState:n})}(o,s,i)}build(t){const e=this.state;let n;e.id!==K&&I(307,String(e.id),String(L)),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:L,output:e,registerState:n})}(e,n,i)}register(t,e){this._signal=e;const n=this.state;n.id!==L&&I(308,String(n.id),String(L));const i=this.extension.register&&this.extension.register(t,n.config,n.registerState);return this.state=function(t){return Object.assign(t,{id:k})}(n),()=>{const t=this.state;t.id!==z&&I(309,String(n.id),String(z)),this.state=function(t){return Object.assign(t,{id:L})}(t),i&&i()}}afterRegistration(t){const e=this.state;let n;return e.id!==k&&I(310,String(e.id),String(k)),this.extension.afterRegistration&&(n=this.extension.afterRegistration(t,e.config,e.registerState)),this.state=function(t){return Object.assign(t,{id:z})}(e),n}getSignal(){return void 0===this._signal&&I(311),this._signal}getInitResult(){void 0===this.extension.init&&I(312,this.extension.name);const t=this.state;return function(t){return t.id>=K}(t)||I(313,String(t.id),String(K)),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>=j}(t)||I(314,String(t.id),String(j)),{config:t.config}}getPeer(t){const e=this.builder.extensionNameMap.get(t);return e?e.getExtensionDependency():void 0}getInitDependency(t){const e=this.builder.getExtensionRep(t);return void 0===e&&I(315,this.extension.name,t.name),e.getExtensionInitDependency()}getDependency(t){const e=this.builder.getExtensionRep(t);return void 0===e&&I(315,this.extension.name,t.name),e.getExtensionDependency()}getState(){const t=this.state;return function(t){return t.id>=z}(t)||I(316,String(t.id),String(z)),t}getDirectDependentNames(){return this.builder.incomingEdges.get(this.extension.name)||H}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>=L})(t)||I(317,this.extension.name),this._dependency={config:t.config,init:t.initResult,output:t.output}}return this._dependency}}const Y={tag:t.HISTORY_MERGE_TAG};function W(){const e=t.$getRoot();e.isEmpty()&&e.append(t.$createParagraphNode())}const Z=t.defineExtension({config:t.safeCast({setOptions:Y,updateOptions:Y}),init:({$initialEditorState:t=W})=>({$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]}),V=Symbol.for("@lexical/extension/LexicalBuilder");function J(){}function q(t){throw t}function X(t){return Array.isArray(t)?t:[t]}const Q="0.37.1-nightly.20251016.0+prod.cjs";class tt{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=Q,this.roots=t;for(const e of t)this.addExtension(e)}static fromExtensions(t){const e=[X(Z)];for(const n of t)e.push(X(n));return new tt(e)}static maybeFromEditor(t){const e=t[V];return e&&(e.PACKAGE_VERSION!==Q&&I(292,e.PACKAGE_VERSION,Q),e instanceof tt||I(293)),e}static fromEditor(t){const e=tt.maybeFromEditor(t);return void 0===e&&I(294),e}constructEditor(){const{$initialEditorState:e,onError:n,...i}=this.buildCreateEditorArgs(),o=Object.assign(t.createEditor({...i,...n?{onError:t=>{n(t,o)}}:{}}),{[V]:this});for(const t of this.sortedExtensionReps())t.build(o);return o}buildEditor(){let t=J;function n(){try{t()}finally{t=J}}const i=Object.assign(this.constructEditor(),{dispose:n,[Symbol.dispose]:n});return t=e.mergeRegister(this.registerEditor(i),()=>i.setRootElement(null)),i}hasExtensionByName(t){return this.extensionNameMap.has(t)}getExtensionRep(t){const e=this.extensionNameMap.get(t.name);if(e)return e.extension!==t&&I(295,t.name),e}addEdge(t,e,n){const i=this.outgoingConfigEdges.get(t);i?i.set(e,n):this.outgoingConfigEdges.set(t,new Map([[e,n]]));const o=this.incomingEdges.get(e);o?o.add(t):this.incomingEdges.set(e,new Set([t]))}addExtension(t){void 0!==this._sortedExtensionReps&&I(296);const e=X(t),[n]=e;"string"!=typeof n.name&&I(297,typeof n.name);let i=this.extensionNameMap.get(n.name);if(void 0!==i&&i.extension!==n&&I(298,n.name),!i){i=new G(this,n),this.extensionNameMap.set(n.name,i);const t=this.conflicts.get(n.name);"string"==typeof t&&I(299,n.name,t);for(const t of n.conflictsWith||[])this.extensionNameMap.has(t)&&I(299,n.name,t),this.conflicts.set(t,n.name);for(const t of n.dependencies||[]){const e=X(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(U(o))return;const s=n.extension.name;var r;B(o)||I(300,s,i||"[unknown]"),B(r=o)||I(304,String(r.id),String(A)),o=Object.assign(r,{id:$}),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=F(o),n.state=o,t.push(n)};for(const t of this.extensionNameMap.values())B(t.state)&&e(t);for(const e of t)for(const[t,n]of this.outgoingConfigEdges.get(e.extension.name)||[])if(n.length>0){const e=this.extensionNameMap.get(t);if(e)for(const t of n)e.configs.add(t)}for(const[t,...e]of this.roots)if(e.length>0){const n=this.extensionNameMap.get(t.name);void 0===n&&I(301,t.name);for(const t of e)n.configs.add(t)}return this._sortedExtensionReps=t,this._sortedExtensionReps}registerEditor(t){const n=this.sortedExtensionReps(),i=new AbortController,o=[()=>i.abort()],s=i.signal;for(const e of n){const n=e.register(t,s);n&&o.push(n)}for(const e of n){const n=e.afterRegistration(t);n&&o.push(n)}return e.mergeRegister(...o)}buildCreateEditorArgs(){const t={},e=new Set,n=new Map,i=new Map,o={},s={},r=this.sortedExtensionReps();for(const c of r){const{extension:r}=c;if(void 0!==r.onError&&(t.onError=r.onError),void 0!==r.disableEvents&&(t.disableEvents=r.disableEvents),void 0!==r.parentEditor&&(t.parentEditor=r.parentEditor),void 0!==r.editable&&(t.editable=r.editable),void 0!==r.namespace&&(t.namespace=r.namespace),void 0!==r.$initialEditorState&&(t.$initialEditorState=r.$initialEditorState),r.nodes)for(const t of r.nodes){if("function"!=typeof t){const e=n.get(t.replace);e&&I(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&&T(s,r.theme)}Object.keys(s).length>0&&(t.theme=s),e.size&&(t.nodes=[...e]);const c=Object.keys(o).length>0,d=i.size>0;(c||d)&&(t.html={},c&&(t.html.import=o),d&&(t.html.export=i));for(const e of r)e.init(t);return t.onError||(t.onError=q),t}}function et(t,e){const n=tt.fromEditor(t).extensionNameMap.get(e);return n?n.getExtensionDependency():void 0}const nt=new Set,it=t.defineExtension({build(e,n,i){const o=i.getDependency(_).output,s=h({watchedNodeKeys:new Map}),r=D(()=>{},()=>b(()=>{const e=r.peek(),{watchedNodeKeys:n}=s.value;let i,c=!1;o.value.read(()=>{if(t.$getSelection())for(const[o,s]of n.entries()){if(0===s.size){n.delete(o);continue}const r=t.$getNodeByKey(o),d=r&&r.isSelected()||!1;c=c||d!==(!!e&&e.has(o)),d&&(i=i||new Set,i.add(o))}}),!c&&i&&e&&i.size===e.size||(r.value=i)}));return{watchNodeKey:function(t){const e=E(()=>(r.value||nt).has(t)),{watchedNodeKeys:n}=s.peek();let i=n.get(t);const o=void 0!==i;return i=i||new Set,i.add(e),o||(n.set(t,i),s.value={watchedNodeKeys:n}),e}}},dependencies:[_],name:"@lexical/extension/NodeSelection"}),ot=t.createCommand("INSERT_HORIZONTAL_RULE_COMMAND");class st extends t.DecoratorNode{static getType(){return"horizontalrule"}static clone(t){return new st(t.__key)}static importJSON(t){return ct().updateFromJSON(t)}static importDOM(){return{hr:()=>({conversion:rt,priority:0})}}exportDOM(){return{element:document.createElement("hr")}}createDOM(t){const n=document.createElement("hr");return e.addClassNamesToElement(n,t.theme.hr),n}getTextContent(){return"\n"}isInline(){return!1}updateDOM(){return!1}}function rt(){return{node:ct()}}function ct(){return t.$create(st)}function dt(t){return t instanceof st}const at=t.defineExtension({dependencies:[_,it],name:"@lexical/extension/HorizontalRule",nodes:[st],register(n,i,s){const{watchNodeKey:r}=s.getDependency(it).output,c=h({nodeSelections:new Map}),d=n._config.theme.hrSelected??"selected";return e.mergeRegister(n.registerCommand(t.CLICK_COMMAND,e=>{if(t.isDOMNode(e.target)){const n=t.$getNodeFromDOMNode(e.target);if(dt(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(st,(t,e)=>{o(()=>{let e=!1;const{nodeSelections:i}=c.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&&(c.value={nodeSelections:i})})}),b(()=>{const t=[];for(const{domNode:n,selectedSignal:i}of c.value.nodeSelections.values())t.push(b(()=>{const t=n.value;if(t){i.value?e.addClassNamesToElement(t,d):e.removeClassNamesFromElement(t,d)}}));return e.mergeRegister(...t)}))}});function ft(n,i){return e.mergeRegister(n.registerCommand(t.KEY_TAB_COMMAND,i=>{const o=t.$getSelection();if(!t.$isRangeSelection(o))return!1;i.preventDefault();const s=function(n){const i=n.getNodes();if(e.$filter(i,e=>t.$isBlockElementNode(e)&&e.canIndent()?e:null).length>0)return!0;const o=n.anchor,s=n.focus,r=s.isBefore(o)?s:o,c=r.getNode(),d=e.$getNearestBlockElementAncestorOrThrow(c);if(d.canIndent()){const e=d.getKey();let n=t.$createRangeSelection();if(n.anchor.set(e,0,"element"),n.focus.set(e,0,"element"),n=t.$normalizeSelection__EXPERIMENTAL(n),n.anchor.is(r))return!0}return!1}(o)?i.shiftKey?t.OUTDENT_CONTENT_COMMAND:t.INDENT_CONTENT_COMMAND:t.INSERT_TAB_COMMAND;return n.dispatchCommand(s,void 0)},t.COMMAND_PRIORITY_EDITOR),n.registerCommand(t.INDENT_CONTENT_COMMAND,()=>{const n="number"==typeof i?i:i?i.peek():null;if(null==n)return!1;const o=t.$getSelection();if(!t.$isRangeSelection(o))return!1;const s=o.getNodes().map(t=>e.$getNearestBlockElementAncestorOrThrow(t).getIndent());return Math.max(...s)+1>=n},t.COMMAND_PRIORITY_CRITICAL))}const ut=t.defineExtension({build:(t,e,n)=>R(e),config:t.safeCast({disabled:!1,maxIndent:null}),name:"@lexical/extension/TabIndentation",register(t,e,n){const{disabled:i,maxIndent:o}=n.getOutput();return b(()=>{if(!i.value)return ft(t,o)})}});exports.configExtension=t.configExtension,exports.declarePeerDependency=t.declarePeerDependency,exports.defineExtension=t.defineExtension,exports.safeCast=t.safeCast,exports.shallowMergeConfig=t.shallowMergeConfig,exports.$createHorizontalRuleNode=ct,exports.$isHorizontalRuleNode=dt,exports.AutoFocusExtension=O,exports.ClearEditorExtension=M,exports.EditorStateExtension=_,exports.HorizontalRuleExtension=at,exports.HorizontalRuleNode=st,exports.INSERT_HORIZONTAL_RULE_COMMAND=ot,exports.InitialStateExtension=Z,exports.LexicalBuilder=tt,exports.NodeSelectionExtension=it,exports.TabIndentationExtension=ut,exports.batch=o,exports.buildEditorFromExtensions=function(...t){return tt.fromExtensions(t).buildEditor()},exports.computed=E,exports.effect=b,exports.getExtensionDependencyFromEditor=function(t,e){const n=tt.fromEditor(t).getExtensionRep(e);return void 0===n&&I(303,e.name),n.getExtensionDependency()},exports.getKnownTypesAndNodes=function(t){const e=new Set,n=new Set;for(const i of t.nodes??[]){const t="function"==typeof i?i:i.replace;e.add(t.getType()),n.add(t)}return{nodes:n,types:e}},exports.getPeerDependencyFromEditor=et,exports.getPeerDependencyFromEditorOrThrow=function(t,e){const n=et(t,e);return void 0===n&&I(291,e),n},exports.namedSignals=R,exports.registerClearEditor=C,exports.registerTabIndentation=ft,exports.signal=h,exports.untracked=c,exports.watchedSignal=D;
|
|
9
|
+
"use strict";var t=require("lexical"),e=require("@lexical/utils");const n=Symbol.for("preact-signals");function i(){if(d>1)return void d--;let t,e=!1;for(;void 0!==r;){let n=r;for(r=void 0,a++;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(a=0,d--,e)throw t}function o(t){if(d>0)return t();d++;try{return t()}finally{i()}}let s,r;function c(t){const e=s;s=void 0;try{return t()}finally{s=e}}let d=0,a=0,f=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 l(t,e){this.v=t,this.i=0,this.n=void 0,this.t=void 0,this.W=null==e?void 0:e.watched,this.Z=null==e?void 0:e.unwatched,this.name=null==e?void 0:e.name}function h(t,e){return new l(t,e)}function g(t){for(let e=t.s;void 0!==e;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return!0;return!1}function p(t){for(let e=t.s;void 0!==e;e=e.n){const n=e.S.n;if(void 0!==n&&(e.r=n),e.S.n=e,e.i=-1,void 0===e.n){t.s=e;break}}}function m(t){let e,n=t.s;for(;void 0!==n;){const t=n.p;-1===n.i?(n.S.U(n),void 0!==t&&(t.n=n.n),void 0!==n.n&&(n.n.p=t)):e=n,n.S.n=n.r,void 0!==n.r&&(n.r=void 0),n=t}t.s=e}function x(t,e){l.call(this,void 0),this.x=t,this.s=void 0,this.g=f-1,this.f=4,this.W=null==e?void 0:e.watched,this.Z=null==e?void 0:e.unwatched,this.name=null==e?void 0:e.name}function E(t,e){return new x(t,e)}function v(t){const e=t.u;if(t.u=void 0,"function"==typeof e){d++;const n=s;s=void 0;try{e()}catch(e){throw t.f&=-2,t.f|=8,S(t),e}finally{s=n,i()}}}function S(t){for(let e=t.s;void 0!==e;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,v(t)}function y(t){if(s!==this)throw new Error("Out-of-order effect");m(this),s=t,this.f&=-2,8&this.f&&S(this),i()}function N(t,e){this.x=t,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=null==e?void 0:e.name}function b(t,e){const n=new N(t,e);try{n.c()}catch(t){throw n.d(),t}const i=n.d.bind(n);return i[Symbol.dispose]=i,i}function R(t,e={}){const n={};for(const i in t){const o=e[i],s=h(void 0===o?t[i]:o);n[i]=s}return n}l.prototype.brand=n,l.prototype.h=function(){return!0},l.prototype.S=function(t){const e=this.t;e!==t&&void 0===t.e&&(t.x=e,this.t=t,void 0!==e?e.e=t:c(()=>{var t;null==(t=this.W)||t.call(this)}))},l.prototype.U=function(t){if(void 0!==this.t){const e=t.e,n=t.x;void 0!==e&&(e.x=n,t.e=void 0),void 0!==n&&(n.e=e,t.x=void 0),t===this.t&&(this.t=n,void 0===n&&c(()=>{var t;null==(t=this.Z)||t.call(this)}))}},l.prototype.subscribe=function(t){return b(()=>{const e=this.value,n=s;s=void 0;try{t(e)}finally{s=n}},{name:"sub"})},l.prototype.valueOf=function(){return this.value},l.prototype.toString=function(){return this.value+""},l.prototype.toJSON=function(){return this.value},l.prototype.peek=function(){const t=s;s=void 0;try{return this.value}finally{s=t}},Object.defineProperty(l.prototype,"value",{get(){const t=u(this);return void 0!==t&&(t.i=this.i),this.v},set(t){if(t!==this.v){if(a>100)throw new Error("Cycle detected");this.v=t,this.i++,f++,d++;try{for(let t=this.t;void 0!==t;t=t.x)t.t.N()}finally{i()}}}}),x.prototype=new l,x.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if(32==(36&this.f))return!0;if(this.f&=-5,this.g===f)return!0;if(this.g=f,this.f|=1,this.i>0&&!g(this))return this.f&=-2,!0;const t=s;try{p(this),s=this;const t=this.x();(16&this.f||this.v!==t||0===this.i)&&(this.v=t,this.f&=-17,this.i++)}catch(t){this.v=t,this.f|=16,this.i++}return s=t,m(this),this.f&=-2,!0},x.prototype.S=function(t){if(void 0===this.t){this.f|=36;for(let t=this.s;void 0!==t;t=t.n)t.S.S(t)}l.prototype.S.call(this,t)},x.prototype.U=function(t){if(void 0!==this.t&&(l.prototype.U.call(this,t),void 0===this.t)){this.f&=-33;for(let t=this.s;void 0!==t;t=t.n)t.S.U(t)}},x.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(let t=this.t;void 0!==t;t=t.x)t.t.N()}},Object.defineProperty(x.prototype,"value",{get(){if(1&this.f)throw new Error("Cycle detected");const t=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),d++;const t=s;return s=this,y.bind(this,t)},N.prototype.N=function(){2&this.f||(this.f|=2,this.o=r,r=this)},N.prototype.d=function(){this.f|=8,1&this.f||S(this)},N.prototype.dispose=function(){this.d()};const O=t.defineExtension({build:(t,e,n)=>R(e),config:t.safeCast({defaultSelection:"rootEnd",disabled:!1}),name:"@lexical/extension/AutoFocus",register(t,e,n){const i=n.getOutput();return b(()=>i.disabled.value?void 0:t.registerRootListener(e=>{t.focus(()=>{const t=document.activeElement;null===e||null!==t&&e.contains(t)||e.focus({preventScroll:!0})},{defaultSelection:i.defaultSelection.peek()})}))}});function w(){const e=t.$getRoot(),n=t.$getSelection(),i=t.$createParagraphNode();e.clear(),e.append(i),null!==n&&i.select(),t.$isRangeSelection(n)&&(n.format=0)}function C(e,n=w){return e.registerCommand(t.CLEAR_EDITOR_COMMAND,t=>(e.update(n),!0),t.COMMAND_PRIORITY_EDITOR)}const M=t.defineExtension({build:(t,e,n)=>R(e),config:t.safeCast({$onClear:w}),name:"@lexical/extension/ClearEditor",register(t,e,n){const{$onClear:i}=n.getOutput();return b(()=>C(t,i.value))}});function D(t){return("function"==typeof t.nodes?t.nodes():t.nodes)||[]}function _(t,e){let n;return h(t(),{unwatched(){n&&(n(),n=void 0)},watched(){this.value=t(),n=e(this)}})}const I=t.defineExtension({build:t=>_(()=>t.getEditorState(),e=>t.registerUpdateListener(t=>{e.value=t.editorState})),name:"@lexical/extension/EditorState"});function T(t,...e){const n=new URL("https://lexical.dev/docs/error"),i=new URLSearchParams;i.append("code",t);for(const t of e)i.append("v",t);throw n.search=i.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function A(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]=A(n[t],i[t]);return t}return e}const $=0,P=1,j=2,K=3,L=4,k=5,z=6,B=7;function U(t){return t.id===$}function F(t){return t.id===j}function H(t){return function(t){return t.id===P}(t)||T(305,String(t.id),String(P)),Object.assign(t,{id:j})}const G=new Set;class Y{builder;configs;_dependency;_peerNameSet;extension;state;_signal;constructor(t,e){this.builder=t,this.extension=e,this.configs=new Set,this.state={id:$}}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;F(e)||T(306,String(e.id));const n={getDependency:this.getInitDependency.bind(this),getDirectDependentNames:this.getDirectDependentNames.bind(this),getPeer:this.getInitPeer.bind(this),getPeerNameSet:this.getPeerNameSet.bind(this)},i={...n,getDependency:this.getDependency.bind(this),getInitResult:this.getInitResult.bind(this),getPeer:this.getPeer.bind(this)},o=function(t,e,n){return Object.assign(t,{config:e,id:K,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:L,initResult:e,registerState:n})}(o,s,i)}build(t){const e=this.state;let n;e.id!==L&&T(307,String(e.id),String(k)),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:k,output:e,registerState:n})}(e,n,i)}register(t,e){this._signal=e;const n=this.state;n.id!==k&&T(308,String(n.id),String(k));const i=this.extension.register&&this.extension.register(t,n.config,n.registerState);return this.state=function(t){return Object.assign(t,{id:z})}(n),()=>{const t=this.state;t.id!==B&&T(309,String(n.id),String(B)),this.state=function(t){return Object.assign(t,{id:k})}(t),i&&i()}}afterRegistration(t){const e=this.state;let n;return e.id!==z&&T(310,String(e.id),String(z)),this.extension.afterRegistration&&(n=this.extension.afterRegistration(t,e.config,e.registerState)),this.state=function(t){return Object.assign(t,{id:B})}(e),n}getSignal(){return void 0===this._signal&&T(311),this._signal}getInitResult(){void 0===this.extension.init&&T(312,this.extension.name);const t=this.state;return function(t){return t.id>=L}(t)||T(313,String(t.id),String(L)),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>=K}(t)||T(314,String(t.id),String(K)),{config:t.config}}getPeer(t){const e=this.builder.extensionNameMap.get(t);return e?e.getExtensionDependency():void 0}getInitDependency(t){const e=this.builder.getExtensionRep(t);return void 0===e&&T(315,this.extension.name,t.name),e.getExtensionInitDependency()}getDependency(t){const e=this.builder.getExtensionRep(t);return void 0===e&&T(315,this.extension.name,t.name),e.getExtensionDependency()}getState(){const t=this.state;return function(t){return t.id>=B}(t)||T(316,String(t.id),String(B)),t}getDirectDependentNames(){return this.builder.incomingEdges.get(this.extension.name)||G}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>=k})(t)||T(317,this.extension.name),this._dependency={config:t.config,init:t.initResult,output:t.output}}return this._dependency}}const W={tag:t.HISTORY_MERGE_TAG};function Z(){const e=t.$getRoot();e.isEmpty()&&e.append(t.$createParagraphNode())}const V=t.defineExtension({config:t.safeCast({setOptions:W,updateOptions:W}),init:({$initialEditorState:t=Z})=>({$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]}),J=Symbol.for("@lexical/extension/LexicalBuilder");function q(){}function X(t){throw t}function Q(t){return Array.isArray(t)?t:[t]}const tt="0.37.1-nightly.20251020.0+prod.cjs";class et{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=tt,this.roots=t;for(const e of t)this.addExtension(e)}static fromExtensions(t){const e=[Q(V)];for(const n of t)e.push(Q(n));return new et(e)}static maybeFromEditor(t){const e=t[J];return e&&(e.PACKAGE_VERSION!==tt&&T(292,e.PACKAGE_VERSION,tt),e instanceof et||T(293)),e}static fromEditor(t){const e=et.maybeFromEditor(t);return void 0===e&&T(294),e}constructEditor(){const{$initialEditorState:e,onError:n,...i}=this.buildCreateEditorArgs(),o=Object.assign(t.createEditor({...i,...n?{onError:t=>{n(t,o)}}:{}}),{[J]:this});for(const t of this.sortedExtensionReps())t.build(o);return o}buildEditor(){let t=q;function n(){try{t()}finally{t=q}}const i=Object.assign(this.constructEditor(),{dispose:n,[Symbol.dispose]:n});return t=e.mergeRegister(this.registerEditor(i),()=>i.setRootElement(null)),i}hasExtensionByName(t){return this.extensionNameMap.has(t)}getExtensionRep(t){const e=this.extensionNameMap.get(t.name);if(e)return e.extension!==t&&T(295,t.name),e}addEdge(t,e,n){const i=this.outgoingConfigEdges.get(t);i?i.set(e,n):this.outgoingConfigEdges.set(t,new Map([[e,n]]));const o=this.incomingEdges.get(e);o?o.add(t):this.incomingEdges.set(e,new Set([t]))}addExtension(t){void 0!==this._sortedExtensionReps&&T(296);const e=Q(t),[n]=e;"string"!=typeof n.name&&T(297,typeof n.name);let i=this.extensionNameMap.get(n.name);if(void 0!==i&&i.extension!==n&&T(298,n.name),!i){i=new Y(this,n),this.extensionNameMap.set(n.name,i);const t=this.conflicts.get(n.name);"string"==typeof t&&T(299,n.name,t);for(const t of n.conflictsWith||[])this.extensionNameMap.has(t)&&T(299,n.name,t),this.conflicts.set(t,n.name);for(const t of n.dependencies||[]){const e=Q(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(F(o))return;const s=n.extension.name;var r;U(o)||T(300,s,i||"[unknown]"),U(r=o)||T(304,String(r.id),String($)),o=Object.assign(r,{id:P}),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=H(o),n.state=o,t.push(n)};for(const t of this.extensionNameMap.values())U(t.state)&&e(t);for(const e of t)for(const[t,n]of this.outgoingConfigEdges.get(e.extension.name)||[])if(n.length>0){const e=this.extensionNameMap.get(t);if(e)for(const t of n)e.configs.add(t)}for(const[t,...e]of this.roots)if(e.length>0){const n=this.extensionNameMap.get(t.name);void 0===n&&T(301,t.name);for(const t of e)n.configs.add(t)}return this._sortedExtensionReps=t,this._sortedExtensionReps}registerEditor(t){const n=this.sortedExtensionReps(),i=new AbortController,o=[()=>i.abort()],s=i.signal;for(const e of n){const n=e.register(t,s);n&&o.push(n)}for(const e of n){const n=e.afterRegistration(t);n&&o.push(n)}return e.mergeRegister(...o)}buildCreateEditorArgs(){const t={},e=new Set,n=new Map,i=new Map,o={},s={},r=this.sortedExtensionReps();for(const 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 D(r)){if("function"!=typeof t){const e=n.get(t.replace);e&&T(302,r.name,t.replace.name,e.extension.name),n.set(t.replace,c)}e.add(t)}if(r.html){if(r.html.export)for(const[t,e]of r.html.export.entries())i.set(t,e);r.html.import&&Object.assign(o,r.html.import)}r.theme&&A(s,r.theme)}Object.keys(s).length>0&&(t.theme=s),e.size&&(t.nodes=[...e]);const c=Object.keys(o).length>0,d=i.size>0;(c||d)&&(t.html={},c&&(t.html.import=o),d&&(t.html.export=i));for(const e of r)e.init(t);return t.onError||(t.onError=X),t}}function nt(t,e){const n=et.fromEditor(t).extensionNameMap.get(e);return n?n.getExtensionDependency():void 0}const it=new Set,ot=t.defineExtension({build(e,n,i){const o=i.getDependency(I).output,s=h({watchedNodeKeys:new Map}),r=_(()=>{},()=>b(()=>{const e=r.peek(),{watchedNodeKeys:n}=s.value;let i,c=!1;o.value.read(()=>{if(t.$getSelection())for(const[o,s]of n.entries()){if(0===s.size){n.delete(o);continue}const r=t.$getNodeByKey(o),d=r&&r.isSelected()||!1;c=c||d!==(!!e&&e.has(o)),d&&(i=i||new Set,i.add(o))}}),!c&&i&&e&&i.size===e.size||(r.value=i)}));return{watchNodeKey:function(t){const e=E(()=>(r.value||it).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:[I],name:"@lexical/extension/NodeSelection"}),st=t.createCommand("INSERT_HORIZONTAL_RULE_COMMAND");class rt extends t.DecoratorNode{static getType(){return"horizontalrule"}static clone(t){return new rt(t.__key)}static importJSON(t){return dt().updateFromJSON(t)}static importDOM(){return{hr:()=>({conversion:ct,priority:0})}}exportDOM(){return{element:document.createElement("hr")}}createDOM(t){const n=document.createElement("hr");return e.addClassNamesToElement(n,t.theme.hr),n}getTextContent(){return"\n"}isInline(){return!1}updateDOM(){return!1}}function ct(){return{node:dt()}}function dt(){return t.$create(rt)}function at(t){return t instanceof rt}const ft=t.defineExtension({dependencies:[I,ot],name:"@lexical/extension/HorizontalRule",nodes:[rt],register(n,i,s){const{watchNodeKey:r}=s.getDependency(ot).output,c=h({nodeSelections:new Map}),d=n._config.theme.hrSelected??"selected";return e.mergeRegister(n.registerCommand(t.CLICK_COMMAND,e=>{if(t.isDOMNode(e.target)){const n=t.$getNodeFromDOMNode(e.target);if(at(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(rt,(t,e)=>{o(()=>{let e=!1;const{nodeSelections:i}=c.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&&(c.value={nodeSelections:i})})}),b(()=>{const t=[];for(const{domNode:n,selectedSignal:i}of c.value.nodeSelections.values())t.push(b(()=>{const t=n.value;if(t){i.value?e.addClassNamesToElement(t,d):e.removeClassNamesFromElement(t,d)}}));return e.mergeRegister(...t)}))}});function ut(n,i){return e.mergeRegister(n.registerCommand(t.KEY_TAB_COMMAND,i=>{const o=t.$getSelection();if(!t.$isRangeSelection(o))return!1;i.preventDefault();const s=function(n){const i=n.getNodes();if(e.$filter(i,e=>t.$isBlockElementNode(e)&&e.canIndent()?e:null).length>0)return!0;const o=n.anchor,s=n.focus,r=s.isBefore(o)?s:o,c=r.getNode(),d=e.$getNearestBlockElementAncestorOrThrow(c);if(d.canIndent()){const e=d.getKey();let n=t.$createRangeSelection();if(n.anchor.set(e,0,"element"),n.focus.set(e,0,"element"),n=t.$normalizeSelection__EXPERIMENTAL(n),n.anchor.is(r))return!0}return!1}(o)?i.shiftKey?t.OUTDENT_CONTENT_COMMAND:t.INDENT_CONTENT_COMMAND:t.INSERT_TAB_COMMAND;return n.dispatchCommand(s,void 0)},t.COMMAND_PRIORITY_EDITOR),n.registerCommand(t.INDENT_CONTENT_COMMAND,()=>{const n="number"==typeof i?i:i?i.peek():null;if(null==n)return!1;const o=t.$getSelection();if(!t.$isRangeSelection(o))return!1;const s=o.getNodes().map(t=>e.$getNearestBlockElementAncestorOrThrow(t).getIndent());return Math.max(...s)+1>=n},t.COMMAND_PRIORITY_CRITICAL))}const lt=t.defineExtension({build:(t,e,n)=>R(e),config:t.safeCast({disabled:!1,maxIndent:null}),name:"@lexical/extension/TabIndentation",register(t,e,n){const{disabled:i,maxIndent:o}=n.getOutput();return b(()=>{if(!i.value)return ut(t,o)})}});exports.configExtension=t.configExtension,exports.declarePeerDependency=t.declarePeerDependency,exports.defineExtension=t.defineExtension,exports.safeCast=t.safeCast,exports.shallowMergeConfig=t.shallowMergeConfig,exports.$createHorizontalRuleNode=dt,exports.$isHorizontalRuleNode=at,exports.AutoFocusExtension=O,exports.ClearEditorExtension=M,exports.EditorStateExtension=I,exports.HorizontalRuleExtension=ft,exports.HorizontalRuleNode=rt,exports.INSERT_HORIZONTAL_RULE_COMMAND=st,exports.InitialStateExtension=V,exports.LexicalBuilder=et,exports.NodeSelectionExtension=ot,exports.TabIndentationExtension=lt,exports.batch=o,exports.buildEditorFromExtensions=function(...t){return et.fromExtensions(t).buildEditor()},exports.computed=E,exports.effect=b,exports.getExtensionDependencyFromEditor=function(t,e){const n=et.fromEditor(t).getExtensionRep(e);return void 0===n&&T(303,e.name),n.getExtensionDependency()},exports.getKnownTypesAndNodes=function(t){const e=new Set,n=new Set;for(const i of D(t)){const t="function"==typeof i?i:i.replace;e.add(t.getType()),n.add(t)}return{nodes:n,types:e}},exports.getPeerDependencyFromEditor=nt,exports.getPeerDependencyFromEditorOrThrow=function(t,e){const n=nt(t,e);return void 0===n&&T(291,e),n},exports.namedSignals=R,exports.registerClearEditor=C,exports.registerTabIndentation=ut,exports.signal=h,exports.untracked=c,exports.watchedSignal=_;
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import{defineExtension as t,safeCast as e,CLEAR_EDITOR_COMMAND as n,COMMAND_PRIORITY_EDITOR as i,$getRoot as o,$getSelection as s,$createParagraphNode as r,$isRangeSelection as c,shallowMergeConfig as d,RootNode as a,TextNode as u,LineBreakNode as f,TabNode as h,ParagraphNode as l,$isEditorState as g,HISTORY_MERGE_TAG as p,createEditor as m,$getNodeByKey as v,createCommand as x,$create as y,CLICK_COMMAND as S,isDOMNode as E,$getNodeFromDOMNode as b,COMMAND_PRIORITY_LOW as w,DecoratorNode as N,$isNodeSelection as O,$createNodeSelection as R,$setSelection as M,KEY_TAB_COMMAND as C,OUTDENT_CONTENT_COMMAND as D,INDENT_CONTENT_COMMAND as _,INSERT_TAB_COMMAND as I,COMMAND_PRIORITY_CRITICAL as j,$isBlockElementNode as A,$createRangeSelection as P,$normalizeSelection__EXPERIMENTAL as K}from"lexical";export{configExtension,declarePeerDependency,defineExtension,safeCast,shallowMergeConfig}from"lexical";import{mergeRegister as k,addClassNamesToElement as $,removeClassNamesFromElement as z,$getNearestBlockElementAncestorOrThrow as U,$filter as L}from"@lexical/utils";const T=Symbol.for("preact-signals");function B(){if(Z>1)return void Z--;let t,e=!1;for(;void 0!==V;){let n=V;for(V=void 0,J++;void 0!==n;){const i=n.o;if(n.o=void 0,n.f&=-3,!(8&n.f)&&Y(n))try{n.c()}catch(n){e||(t=n,e=!0)}n=i}}if(J=0,Z--,e)throw t}function F(t){if(Z>0)return t();Z++;try{return t()}finally{B()}}let G,V;function W(t){const e=G;G=void 0;try{return t()}finally{G=e}}let Z=0,J=0,H=0;function q(t){if(void 0===G)return;let e=t.n;return void 0===e||e.t!==G?(e={i:0,S:t,p:G.s,n:void 0,t:G,e:void 0,x:void 0,r:e},void 0!==G.s&&(G.s.n=e),G.s=e,t.n=e,32&G.f&&t.S(e),e):-1===e.i?(e.i=0,void 0!==e.n&&(e.n.p=e.p,void 0!==e.p&&(e.p.n=e.n),e.p=G.s,e.n=void 0,G.s.n=e,G.s=e),e):void 0}function Q(t,e){this.v=t,this.i=0,this.n=void 0,this.t=void 0,this.W=null==e?void 0:e.watched,this.Z=null==e?void 0:e.unwatched,this.name=null==e?void 0:e.name}function X(t,e){return new Q(t,e)}function Y(t){for(let e=t.s;void 0!==e;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return!0;return!1}function tt(t){for(let e=t.s;void 0!==e;e=e.n){const n=e.S.n;if(void 0!==n&&(e.r=n),e.S.n=e,e.i=-1,void 0===e.n){t.s=e;break}}}function et(t){let e,n=t.s;for(;void 0!==n;){const t=n.p;-1===n.i?(n.S.U(n),void 0!==t&&(t.n=n.n),void 0!==n.n&&(n.n.p=t)):e=n,n.S.n=n.r,void 0!==n.r&&(n.r=void 0),n=t}t.s=e}function nt(t,e){Q.call(this,void 0),this.x=t,this.s=void 0,this.g=H-1,this.f=4,this.W=null==e?void 0:e.watched,this.Z=null==e?void 0:e.unwatched,this.name=null==e?void 0:e.name}function it(t,e){return new nt(t,e)}function ot(t){const e=t.u;if(t.u=void 0,"function"==typeof e){Z++;const n=G;G=void 0;try{e()}catch(e){throw t.f&=-2,t.f|=8,st(t),e}finally{G=n,B()}}}function st(t){for(let e=t.s;void 0!==e;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,ot(t)}function rt(t){if(G!==this)throw new Error("Out-of-order effect");et(this),G=t,this.f&=-2,8&this.f&&st(this),B()}function ct(t,e){this.x=t,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=null==e?void 0:e.name}function dt(t,e){const n=new ct(t,e);try{n.c()}catch(t){throw n.d(),t}const i=n.d.bind(n);return i[Symbol.dispose]=i,i}function at(t,e={}){const n={};for(const i in t){const o=e[i],s=X(void 0===o?t[i]:o);n[i]=s}return n}Q.prototype.brand=T,Q.prototype.h=function(){return!0},Q.prototype.S=function(t){const e=this.t;e!==t&&void 0===t.e&&(t.x=e,this.t=t,void 0!==e?e.e=t:W(()=>{var t;null==(t=this.W)||t.call(this)}))},Q.prototype.U=function(t){if(void 0!==this.t){const e=t.e,n=t.x;void 0!==e&&(e.x=n,t.e=void 0),void 0!==n&&(n.e=e,t.x=void 0),t===this.t&&(this.t=n,void 0===n&&W(()=>{var t;null==(t=this.Z)||t.call(this)}))}},Q.prototype.subscribe=function(t){return dt(()=>{const e=this.value,n=G;G=void 0;try{t(e)}finally{G=n}},{name:"sub"})},Q.prototype.valueOf=function(){return this.value},Q.prototype.toString=function(){return this.value+""},Q.prototype.toJSON=function(){return this.value},Q.prototype.peek=function(){const t=G;G=void 0;try{return this.value}finally{G=t}},Object.defineProperty(Q.prototype,"value",{get(){const t=q(this);return void 0!==t&&(t.i=this.i),this.v},set(t){if(t!==this.v){if(J>100)throw new Error("Cycle detected");this.v=t,this.i++,H++,Z++;try{for(let t=this.t;void 0!==t;t=t.x)t.t.N()}finally{B()}}}}),nt.prototype=new Q,nt.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if(32==(36&this.f))return!0;if(this.f&=-5,this.g===H)return!0;if(this.g=H,this.f|=1,this.i>0&&!Y(this))return this.f&=-2,!0;const t=G;try{tt(this),G=this;const t=this.x();(16&this.f||this.v!==t||0===this.i)&&(this.v=t,this.f&=-17,this.i++)}catch(t){this.v=t,this.f|=16,this.i++}return G=t,et(this),this.f&=-2,!0},nt.prototype.S=function(t){if(void 0===this.t){this.f|=36;for(let t=this.s;void 0!==t;t=t.n)t.S.S(t)}Q.prototype.S.call(this,t)},nt.prototype.U=function(t){if(void 0!==this.t&&(Q.prototype.U.call(this,t),void 0===this.t)){this.f&=-33;for(let t=this.s;void 0!==t;t=t.n)t.S.U(t)}},nt.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(let t=this.t;void 0!==t;t=t.x)t.t.N()}},Object.defineProperty(nt.prototype,"value",{get(){if(1&this.f)throw new Error("Cycle detected");const t=q(this);if(this.h(),void 0!==t&&(t.i=this.i),16&this.f)throw this.v;return this.v}}),ct.prototype.c=function(){const t=this.S();try{if(8&this.f)return;if(void 0===this.x)return;const t=this.x();"function"==typeof t&&(this.u=t)}finally{t()}},ct.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,ot(this),tt(this),Z++;const t=G;return G=this,rt.bind(this,t)},ct.prototype.N=function(){2&this.f||(this.f|=2,this.o=V,V=this)},ct.prototype.d=function(){this.f|=8,1&this.f||st(this)},ct.prototype.dispose=function(){this.d()};const ut=t({build:(t,e,n)=>at(e),config:e({defaultSelection:"rootEnd",disabled:!1}),name:"@lexical/extension/AutoFocus",register(t,e,n){const i=n.getOutput();return dt(()=>i.disabled.value?void 0:t.registerRootListener(e=>{t.focus(()=>{const t=document.activeElement;null===e||null!==t&&e.contains(t)||e.focus({preventScroll:!0})},{defaultSelection:i.defaultSelection.peek()})}))}});function ft(){const t=o(),e=s(),n=r();t.clear(),t.append(n),null!==e&&n.select(),c(e)&&(e.format=0)}function ht(t,e=ft){return t.registerCommand(n,n=>(t.update(e),!0),i)}const lt=t({build:(t,e,n)=>at(e),config:e({$onClear:ft}),name:"@lexical/extension/ClearEditor",register(t,e,n){const{$onClear:i}=n.getOutput();return dt(()=>ht(t,i.value))}});function gt(t){const e=new Set,n=new Set;for(const i of t.nodes??[]){const t="function"==typeof i?i:i.replace;e.add(t.getType()),n.add(t)}return{nodes:n,types:e}}function pt(t,e){let n;return X(t(),{unwatched(){n&&(n(),n=void 0)},watched(){this.value=t(),n=e(this)}})}const mt=t({build:t=>pt(()=>t.getEditorState(),e=>t.registerUpdateListener(t=>{e.value=t.editorState})),name:"@lexical/extension/EditorState"});function vt(t,...e){const n=new URL("https://lexical.dev/docs/error"),i=new URLSearchParams;i.append("code",t);for(const t of e)i.append("v",t);throw n.search=i.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function xt(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]=xt(n[t],i[t]);return t}return e}const yt=0,St=1,Et=2,bt=3,wt=4,Nt=5,Ot=6,Rt=7;function Mt(t){return t.id===yt}function Ct(t){return t.id===Et}function Dt(t){return function(t){return t.id===St}(t)||vt(305,String(t.id),String(St)),Object.assign(t,{id:Et})}const _t=new Set;class It{builder;configs;_dependency;_peerNameSet;extension;state;_signal;constructor(t,e){this.builder=t,this.extension=e,this.configs=new Set,this.state={id:yt}}mergeConfigs(){let t=this.extension.config||{};const e=this.extension.mergeConfig?this.extension.mergeConfig.bind(this.extension):d;for(const n of this.configs)t=e(t,n);return t}init(t){const e=this.state;Ct(e)||vt(306,String(e.id));const n={getDependency:this.getInitDependency.bind(this),getDirectDependentNames:this.getDirectDependentNames.bind(this),getPeer:this.getInitPeer.bind(this),getPeerNameSet:this.getPeerNameSet.bind(this)},i={...n,getDependency:this.getDependency.bind(this),getInitResult:this.getInitResult.bind(this),getPeer:this.getPeer.bind(this)},o=function(t,e,n){return Object.assign(t,{config:e,id:bt,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:wt,initResult:e,registerState:n})}(o,s,i)}build(t){const e=this.state;let n;e.id!==wt&&vt(307,String(e.id),String(Nt)),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:Nt,output:e,registerState:n})}(e,n,i)}register(t,e){this._signal=e;const n=this.state;n.id!==Nt&&vt(308,String(n.id),String(Nt));const i=this.extension.register&&this.extension.register(t,n.config,n.registerState);return this.state=function(t){return Object.assign(t,{id:Ot})}(n),()=>{const t=this.state;t.id!==Rt&&vt(309,String(n.id),String(Rt)),this.state=function(t){return Object.assign(t,{id:Nt})}(t),i&&i()}}afterRegistration(t){const e=this.state;let n;return e.id!==Ot&&vt(310,String(e.id),String(Ot)),this.extension.afterRegistration&&(n=this.extension.afterRegistration(t,e.config,e.registerState)),this.state=function(t){return Object.assign(t,{id:Rt})}(e),n}getSignal(){return void 0===this._signal&&vt(311),this._signal}getInitResult(){void 0===this.extension.init&&vt(312,this.extension.name);const t=this.state;return function(t){return t.id>=wt}(t)||vt(313,String(t.id),String(wt)),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>=bt}(t)||vt(314,String(t.id),String(bt)),{config:t.config}}getPeer(t){const e=this.builder.extensionNameMap.get(t);return e?e.getExtensionDependency():void 0}getInitDependency(t){const e=this.builder.getExtensionRep(t);return void 0===e&&vt(315,this.extension.name,t.name),e.getExtensionInitDependency()}getDependency(t){const e=this.builder.getExtensionRep(t);return void 0===e&&vt(315,this.extension.name,t.name),e.getExtensionDependency()}getState(){const t=this.state;return function(t){return t.id>=Rt}(t)||vt(316,String(t.id),String(Rt)),t}getDirectDependentNames(){return this.builder.incomingEdges.get(this.extension.name)||_t}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>=Nt})(t)||vt(317,this.extension.name),this._dependency={config:t.config,init:t.initResult,output:t.output}}return this._dependency}}const jt={tag:p};function At(){const t=o();t.isEmpty()&&t.append(r())}const Pt=t({config:e({setOptions:jt,updateOptions:jt}),init:({$initialEditorState:t=At})=>({$initialEditorState:t,initialized:!1}),afterRegistration(t,{updateOptions:e,setOptions:n},i){const o=i.getInitResult();if(!o.initialized){o.initialized=!0;const{$initialEditorState:i}=o;if(g(i))t.setEditorState(i,n);else if("function"==typeof i)t.update(()=>{i(t)},e);else if(i&&("string"==typeof i||"object"==typeof i)){const e=t.parseEditorState(i);t.setEditorState(e,n)}}return()=>{}},name:"@lexical/extension/InitialState",nodes:[a,u,f,h,l]}),Kt=Symbol.for("@lexical/extension/LexicalBuilder");function kt(...t){return Tt.fromExtensions(t).buildEditor()}function $t(){}function zt(t){throw t}function Ut(t){return Array.isArray(t)?t:[t]}const Lt="0.37.1-nightly.20251016.0+prod.esm";class Tt{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=Lt,this.roots=t;for(const e of t)this.addExtension(e)}static fromExtensions(t){const e=[Ut(Pt)];for(const n of t)e.push(Ut(n));return new Tt(e)}static maybeFromEditor(t){const e=t[Kt];return e&&(e.PACKAGE_VERSION!==Lt&&vt(292,e.PACKAGE_VERSION,Lt),e instanceof Tt||vt(293)),e}static fromEditor(t){const e=Tt.maybeFromEditor(t);return void 0===e&&vt(294),e}constructEditor(){const{$initialEditorState:t,onError:e,...n}=this.buildCreateEditorArgs(),i=Object.assign(m({...n,...e?{onError:t=>{e(t,i)}}:{}}),{[Kt]:this});for(const t of this.sortedExtensionReps())t.build(i);return i}buildEditor(){let t=$t;function e(){try{t()}finally{t=$t}}const n=Object.assign(this.constructEditor(),{dispose:e,[Symbol.dispose]:e});return t=k(this.registerEditor(n),()=>n.setRootElement(null)),n}hasExtensionByName(t){return this.extensionNameMap.has(t)}getExtensionRep(t){const e=this.extensionNameMap.get(t.name);if(e)return e.extension!==t&&vt(295,t.name),e}addEdge(t,e,n){const i=this.outgoingConfigEdges.get(t);i?i.set(e,n):this.outgoingConfigEdges.set(t,new Map([[e,n]]));const o=this.incomingEdges.get(e);o?o.add(t):this.incomingEdges.set(e,new Set([t]))}addExtension(t){void 0!==this._sortedExtensionReps&&vt(296);const e=Ut(t),[n]=e;"string"!=typeof n.name&&vt(297,typeof n.name);let i=this.extensionNameMap.get(n.name);if(void 0!==i&&i.extension!==n&&vt(298,n.name),!i){i=new It(this,n),this.extensionNameMap.set(n.name,i);const t=this.conflicts.get(n.name);"string"==typeof t&&vt(299,n.name,t);for(const t of n.conflictsWith||[])this.extensionNameMap.has(t)&&vt(299,n.name,t),this.conflicts.set(t,n.name);for(const t of n.dependencies||[]){const e=Ut(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(Ct(o))return;const s=n.extension.name;var r;Mt(o)||vt(300,s,i||"[unknown]"),Mt(r=o)||vt(304,String(r.id),String(yt)),o=Object.assign(r,{id:St}),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=Dt(o),n.state=o,t.push(n)};for(const t of this.extensionNameMap.values())Mt(t.state)&&e(t);for(const e of t)for(const[t,n]of this.outgoingConfigEdges.get(e.extension.name)||[])if(n.length>0){const e=this.extensionNameMap.get(t);if(e)for(const t of n)e.configs.add(t)}for(const[t,...e]of this.roots)if(e.length>0){const n=this.extensionNameMap.get(t.name);void 0===n&&vt(301,t.name);for(const t of e)n.configs.add(t)}return this._sortedExtensionReps=t,this._sortedExtensionReps}registerEditor(t){const e=this.sortedExtensionReps(),n=new AbortController,i=[()=>n.abort()],o=n.signal;for(const n of e){const e=n.register(t,o);e&&i.push(e)}for(const n of e){const e=n.afterRegistration(t);e&&i.push(e)}return k(...i)}buildCreateEditorArgs(){const t={},e=new Set,n=new Map,i=new Map,o={},s={},r=this.sortedExtensionReps();for(const c of r){const{extension:r}=c;if(void 0!==r.onError&&(t.onError=r.onError),void 0!==r.disableEvents&&(t.disableEvents=r.disableEvents),void 0!==r.parentEditor&&(t.parentEditor=r.parentEditor),void 0!==r.editable&&(t.editable=r.editable),void 0!==r.namespace&&(t.namespace=r.namespace),void 0!==r.$initialEditorState&&(t.$initialEditorState=r.$initialEditorState),r.nodes)for(const t of r.nodes){if("function"!=typeof t){const e=n.get(t.replace);e&&vt(302,r.name,t.replace.name,e.extension.name),n.set(t.replace,c)}e.add(t)}if(r.html){if(r.html.export)for(const[t,e]of r.html.export.entries())i.set(t,e);r.html.import&&Object.assign(o,r.html.import)}r.theme&&xt(s,r.theme)}Object.keys(s).length>0&&(t.theme=s),e.size&&(t.nodes=[...e]);const c=Object.keys(o).length>0,d=i.size>0;(c||d)&&(t.html={},c&&(t.html.import=o),d&&(t.html.export=i));for(const e of r)e.init(t);return t.onError||(t.onError=zt),t}}function Bt(t,e){const n=Tt.fromEditor(t).getExtensionRep(e);return void 0===n&&vt(303,e.name),n.getExtensionDependency()}function Ft(t,e){const n=Tt.fromEditor(t).extensionNameMap.get(e);return n?n.getExtensionDependency():void 0}function Gt(t,e){const n=Ft(t,e);return void 0===n&&vt(291,e),n}const Vt=new Set,Wt=t({build(t,e,n){const i=n.getDependency(mt).output,o=X({watchedNodeKeys:new Map}),r=pt(()=>{},()=>dt(()=>{const t=r.peek(),{watchedNodeKeys:e}=o.value;let n,c=!1;i.value.read(()=>{if(s())for(const[i,o]of e.entries()){if(0===o.size){e.delete(i);continue}const s=v(i),r=s&&s.isSelected()||!1;c=c||r!==(!!t&&t.has(i)),r&&(n=n||new Set,n.add(i))}}),!c&&n&&t&&n.size===t.size||(r.value=n)}));return{watchNodeKey:function(t){const e=it(()=>(r.value||Vt).has(t)),{watchedNodeKeys:n}=o.peek();let i=n.get(t);const s=void 0!==i;return i=i||new Set,i.add(e),s||(n.set(t,i),o.value={watchedNodeKeys:n}),e}}},dependencies:[mt],name:"@lexical/extension/NodeSelection"}),Zt=x("INSERT_HORIZONTAL_RULE_COMMAND");class Jt extends N{static getType(){return"horizontalrule"}static clone(t){return new Jt(t.__key)}static importJSON(t){return qt().updateFromJSON(t)}static importDOM(){return{hr:()=>({conversion:Ht,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 Ht(){return{node:qt()}}function qt(){return y(Jt)}function Qt(t){return t instanceof Jt}const Xt=t({dependencies:[mt,Wt],name:"@lexical/extension/HorizontalRule",nodes:[Jt],register(t,e,n){const{watchNodeKey:i}=n.getDependency(Wt).output,o=X({nodeSelections:new Map}),r=t._config.theme.hrSelected??"selected";return k(t.registerCommand(S,t=>{if(E(t.target)){const e=b(t.target);if(Qt(e))return function(t,e=!1){const n=s(),i=t.isSelected(),o=t.getKey();let r;e&&O(n)?r=n:(r=R(),M(r)),i?r.delete(o):r.add(o)}(e,t.shiftKey),!0}return!1},w),t.registerMutationListener(Jt,(e,n)=>{F(()=>{let n=!1;const{nodeSelections:s}=o.peek();for(const[o,r]of e.entries())if("destroyed"===r)s.delete(o),n=!0;else{const e=s.get(o),r=t.getElementByKey(o);e?e.domNode.value=r:(n=!0,s.set(o,{domNode:X(r),selectedSignal:i(o)}))}n&&(o.value={nodeSelections:s})})}),dt(()=>{const t=[];for(const{domNode:e,selectedSignal:n}of o.value.nodeSelections.values())t.push(dt(()=>{const t=e.value;if(t){n.value?$(t,r):z(t,r)}}));return k(...t)}))}});function Yt(t,e){return k(t.registerCommand(C,e=>{const n=s();if(!c(n))return!1;e.preventDefault();const i=function(t){const e=t.getNodes();if(L(e,t=>A(t)&&t.canIndent()?t:null).length>0)return!0;const n=t.anchor,i=t.focus,o=i.isBefore(n)?i:n,s=o.getNode(),r=U(s);if(r.canIndent()){const t=r.getKey();let e=P();if(e.anchor.set(t,0,"element"),e.focus.set(t,0,"element"),e=K(e),e.anchor.is(o))return!0}return!1}(n)?e.shiftKey?D:_:I;return t.dispatchCommand(i,void 0)},i),t.registerCommand(_,()=>{const t="number"==typeof e?e:e?e.peek():null;if(null==t)return!1;const n=s();if(!c(n))return!1;const i=n.getNodes().map(t=>U(t).getIndent());return Math.max(...i)+1>=t},j))}const te=t({build:(t,e,n)=>at(e),config:e({disabled:!1,maxIndent:null}),name:"@lexical/extension/TabIndentation",register(t,e,n){const{disabled:i,maxIndent:o}=n.getOutput();return dt(()=>{if(!i.value)return Yt(t,o)})}});export{qt as $createHorizontalRuleNode,Qt as $isHorizontalRuleNode,ut as AutoFocusExtension,lt as ClearEditorExtension,mt as EditorStateExtension,Xt as HorizontalRuleExtension,Jt as HorizontalRuleNode,Zt as INSERT_HORIZONTAL_RULE_COMMAND,Pt as InitialStateExtension,Tt as LexicalBuilder,Wt as NodeSelectionExtension,te as TabIndentationExtension,F as batch,kt as buildEditorFromExtensions,it as computed,dt as effect,Bt as getExtensionDependencyFromEditor,gt as getKnownTypesAndNodes,Ft as getPeerDependencyFromEditor,Gt as getPeerDependencyFromEditorOrThrow,at as namedSignals,ht as registerClearEditor,Yt as registerTabIndentation,X as signal,W as untracked,pt as watchedSignal};
|
|
9
|
+
import{defineExtension as t,safeCast as e,CLEAR_EDITOR_COMMAND as n,COMMAND_PRIORITY_EDITOR as i,$getRoot as o,$getSelection as s,$createParagraphNode as r,$isRangeSelection as c,shallowMergeConfig as d,RootNode as a,TextNode as u,LineBreakNode as f,TabNode as h,ParagraphNode as l,$isEditorState as g,HISTORY_MERGE_TAG as p,createEditor as m,$getNodeByKey as v,createCommand as x,$create as y,CLICK_COMMAND as S,isDOMNode as E,$getNodeFromDOMNode as b,COMMAND_PRIORITY_LOW as w,DecoratorNode as N,$isNodeSelection as O,$createNodeSelection as R,$setSelection as M,KEY_TAB_COMMAND as C,OUTDENT_CONTENT_COMMAND as D,INDENT_CONTENT_COMMAND as _,INSERT_TAB_COMMAND as I,COMMAND_PRIORITY_CRITICAL as j,$isBlockElementNode as A,$createRangeSelection as P,$normalizeSelection__EXPERIMENTAL as K}from"lexical";export{configExtension,declarePeerDependency,defineExtension,safeCast,shallowMergeConfig}from"lexical";import{mergeRegister as k,addClassNamesToElement as $,removeClassNamesFromElement as z,$getNearestBlockElementAncestorOrThrow as U,$filter as L}from"@lexical/utils";const T=Symbol.for("preact-signals");function B(){if(Z>1)return void Z--;let t,e=!1;for(;void 0!==V;){let n=V;for(V=void 0,J++;void 0!==n;){const i=n.o;if(n.o=void 0,n.f&=-3,!(8&n.f)&&Y(n))try{n.c()}catch(n){e||(t=n,e=!0)}n=i}}if(J=0,Z--,e)throw t}function F(t){if(Z>0)return t();Z++;try{return t()}finally{B()}}let G,V;function W(t){const e=G;G=void 0;try{return t()}finally{G=e}}let Z=0,J=0,H=0;function q(t){if(void 0===G)return;let e=t.n;return void 0===e||e.t!==G?(e={i:0,S:t,p:G.s,n:void 0,t:G,e:void 0,x:void 0,r:e},void 0!==G.s&&(G.s.n=e),G.s=e,t.n=e,32&G.f&&t.S(e),e):-1===e.i?(e.i=0,void 0!==e.n&&(e.n.p=e.p,void 0!==e.p&&(e.p.n=e.n),e.p=G.s,e.n=void 0,G.s.n=e,G.s=e),e):void 0}function Q(t,e){this.v=t,this.i=0,this.n=void 0,this.t=void 0,this.W=null==e?void 0:e.watched,this.Z=null==e?void 0:e.unwatched,this.name=null==e?void 0:e.name}function X(t,e){return new Q(t,e)}function Y(t){for(let e=t.s;void 0!==e;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return!0;return!1}function tt(t){for(let e=t.s;void 0!==e;e=e.n){const n=e.S.n;if(void 0!==n&&(e.r=n),e.S.n=e,e.i=-1,void 0===e.n){t.s=e;break}}}function et(t){let e,n=t.s;for(;void 0!==n;){const t=n.p;-1===n.i?(n.S.U(n),void 0!==t&&(t.n=n.n),void 0!==n.n&&(n.n.p=t)):e=n,n.S.n=n.r,void 0!==n.r&&(n.r=void 0),n=t}t.s=e}function nt(t,e){Q.call(this,void 0),this.x=t,this.s=void 0,this.g=H-1,this.f=4,this.W=null==e?void 0:e.watched,this.Z=null==e?void 0:e.unwatched,this.name=null==e?void 0:e.name}function it(t,e){return new nt(t,e)}function ot(t){const e=t.u;if(t.u=void 0,"function"==typeof e){Z++;const n=G;G=void 0;try{e()}catch(e){throw t.f&=-2,t.f|=8,st(t),e}finally{G=n,B()}}}function st(t){for(let e=t.s;void 0!==e;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,ot(t)}function rt(t){if(G!==this)throw new Error("Out-of-order effect");et(this),G=t,this.f&=-2,8&this.f&&st(this),B()}function ct(t,e){this.x=t,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=null==e?void 0:e.name}function dt(t,e){const n=new ct(t,e);try{n.c()}catch(t){throw n.d(),t}const i=n.d.bind(n);return i[Symbol.dispose]=i,i}function at(t,e={}){const n={};for(const i in t){const o=e[i],s=X(void 0===o?t[i]:o);n[i]=s}return n}Q.prototype.brand=T,Q.prototype.h=function(){return!0},Q.prototype.S=function(t){const e=this.t;e!==t&&void 0===t.e&&(t.x=e,this.t=t,void 0!==e?e.e=t:W(()=>{var t;null==(t=this.W)||t.call(this)}))},Q.prototype.U=function(t){if(void 0!==this.t){const e=t.e,n=t.x;void 0!==e&&(e.x=n,t.e=void 0),void 0!==n&&(n.e=e,t.x=void 0),t===this.t&&(this.t=n,void 0===n&&W(()=>{var t;null==(t=this.Z)||t.call(this)}))}},Q.prototype.subscribe=function(t){return dt(()=>{const e=this.value,n=G;G=void 0;try{t(e)}finally{G=n}},{name:"sub"})},Q.prototype.valueOf=function(){return this.value},Q.prototype.toString=function(){return this.value+""},Q.prototype.toJSON=function(){return this.value},Q.prototype.peek=function(){const t=G;G=void 0;try{return this.value}finally{G=t}},Object.defineProperty(Q.prototype,"value",{get(){const t=q(this);return void 0!==t&&(t.i=this.i),this.v},set(t){if(t!==this.v){if(J>100)throw new Error("Cycle detected");this.v=t,this.i++,H++,Z++;try{for(let t=this.t;void 0!==t;t=t.x)t.t.N()}finally{B()}}}}),nt.prototype=new Q,nt.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if(32==(36&this.f))return!0;if(this.f&=-5,this.g===H)return!0;if(this.g=H,this.f|=1,this.i>0&&!Y(this))return this.f&=-2,!0;const t=G;try{tt(this),G=this;const t=this.x();(16&this.f||this.v!==t||0===this.i)&&(this.v=t,this.f&=-17,this.i++)}catch(t){this.v=t,this.f|=16,this.i++}return G=t,et(this),this.f&=-2,!0},nt.prototype.S=function(t){if(void 0===this.t){this.f|=36;for(let t=this.s;void 0!==t;t=t.n)t.S.S(t)}Q.prototype.S.call(this,t)},nt.prototype.U=function(t){if(void 0!==this.t&&(Q.prototype.U.call(this,t),void 0===this.t)){this.f&=-33;for(let t=this.s;void 0!==t;t=t.n)t.S.U(t)}},nt.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(let t=this.t;void 0!==t;t=t.x)t.t.N()}},Object.defineProperty(nt.prototype,"value",{get(){if(1&this.f)throw new Error("Cycle detected");const t=q(this);if(this.h(),void 0!==t&&(t.i=this.i),16&this.f)throw this.v;return this.v}}),ct.prototype.c=function(){const t=this.S();try{if(8&this.f)return;if(void 0===this.x)return;const t=this.x();"function"==typeof t&&(this.u=t)}finally{t()}},ct.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,ot(this),tt(this),Z++;const t=G;return G=this,rt.bind(this,t)},ct.prototype.N=function(){2&this.f||(this.f|=2,this.o=V,V=this)},ct.prototype.d=function(){this.f|=8,1&this.f||st(this)},ct.prototype.dispose=function(){this.d()};const ut=t({build:(t,e,n)=>at(e),config:e({defaultSelection:"rootEnd",disabled:!1}),name:"@lexical/extension/AutoFocus",register(t,e,n){const i=n.getOutput();return dt(()=>i.disabled.value?void 0:t.registerRootListener(e=>{t.focus(()=>{const t=document.activeElement;null===e||null!==t&&e.contains(t)||e.focus({preventScroll:!0})},{defaultSelection:i.defaultSelection.peek()})}))}});function ft(){const t=o(),e=s(),n=r();t.clear(),t.append(n),null!==e&&n.select(),c(e)&&(e.format=0)}function ht(t,e=ft){return t.registerCommand(n,n=>(t.update(e),!0),i)}const lt=t({build:(t,e,n)=>at(e),config:e({$onClear:ft}),name:"@lexical/extension/ClearEditor",register(t,e,n){const{$onClear:i}=n.getOutput();return dt(()=>ht(t,i.value))}});function gt(t){const e=new Set,n=new Set;for(const i of pt(t)){const t="function"==typeof i?i:i.replace;e.add(t.getType()),n.add(t)}return{nodes:n,types:e}}function pt(t){return("function"==typeof t.nodes?t.nodes():t.nodes)||[]}function mt(t,e){let n;return X(t(),{unwatched(){n&&(n(),n=void 0)},watched(){this.value=t(),n=e(this)}})}const vt=t({build:t=>mt(()=>t.getEditorState(),e=>t.registerUpdateListener(t=>{e.value=t.editorState})),name:"@lexical/extension/EditorState"});function xt(t,...e){const n=new URL("https://lexical.dev/docs/error"),i=new URLSearchParams;i.append("code",t);for(const t of e)i.append("v",t);throw n.search=i.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function yt(t,e){if(t&&e&&!Array.isArray(e)&&"object"==typeof t&&"object"==typeof e){const n=t,i=e;for(const t in i)n[t]=yt(n[t],i[t]);return t}return e}const St=0,Et=1,bt=2,wt=3,Nt=4,Ot=5,Rt=6,Mt=7;function Ct(t){return t.id===St}function Dt(t){return t.id===bt}function _t(t){return function(t){return t.id===Et}(t)||xt(305,String(t.id),String(Et)),Object.assign(t,{id:bt})}const It=new Set;class jt{builder;configs;_dependency;_peerNameSet;extension;state;_signal;constructor(t,e){this.builder=t,this.extension=e,this.configs=new Set,this.state={id:St}}mergeConfigs(){let t=this.extension.config||{};const e=this.extension.mergeConfig?this.extension.mergeConfig.bind(this.extension):d;for(const n of this.configs)t=e(t,n);return t}init(t){const e=this.state;Dt(e)||xt(306,String(e.id));const n={getDependency:this.getInitDependency.bind(this),getDirectDependentNames:this.getDirectDependentNames.bind(this),getPeer:this.getInitPeer.bind(this),getPeerNameSet:this.getPeerNameSet.bind(this)},i={...n,getDependency:this.getDependency.bind(this),getInitResult:this.getInitResult.bind(this),getPeer:this.getPeer.bind(this)},o=function(t,e,n){return Object.assign(t,{config:e,id:wt,registerState:n})}(e,this.mergeConfigs(),n);let s;this.state=o,this.extension.init&&(s=this.extension.init(t,o.config,n)),this.state=function(t,e,n){return Object.assign(t,{id:Nt,initResult:e,registerState:n})}(o,s,i)}build(t){const e=this.state;let n;e.id!==Nt&&xt(307,String(e.id),String(Ot)),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:Ot,output:e,registerState:n})}(e,n,i)}register(t,e){this._signal=e;const n=this.state;n.id!==Ot&&xt(308,String(n.id),String(Ot));const i=this.extension.register&&this.extension.register(t,n.config,n.registerState);return this.state=function(t){return Object.assign(t,{id:Rt})}(n),()=>{const t=this.state;t.id!==Mt&&xt(309,String(n.id),String(Mt)),this.state=function(t){return Object.assign(t,{id:Ot})}(t),i&&i()}}afterRegistration(t){const e=this.state;let n;return e.id!==Rt&&xt(310,String(e.id),String(Rt)),this.extension.afterRegistration&&(n=this.extension.afterRegistration(t,e.config,e.registerState)),this.state=function(t){return Object.assign(t,{id:Mt})}(e),n}getSignal(){return void 0===this._signal&&xt(311),this._signal}getInitResult(){void 0===this.extension.init&&xt(312,this.extension.name);const t=this.state;return function(t){return t.id>=Nt}(t)||xt(313,String(t.id),String(Nt)),t.initResult}getInitPeer(t){const e=this.builder.extensionNameMap.get(t);return e?e.getExtensionInitDependency():void 0}getExtensionInitDependency(){const t=this.state;return function(t){return t.id>=wt}(t)||xt(314,String(t.id),String(wt)),{config:t.config}}getPeer(t){const e=this.builder.extensionNameMap.get(t);return e?e.getExtensionDependency():void 0}getInitDependency(t){const e=this.builder.getExtensionRep(t);return void 0===e&&xt(315,this.extension.name,t.name),e.getExtensionInitDependency()}getDependency(t){const e=this.builder.getExtensionRep(t);return void 0===e&&xt(315,this.extension.name,t.name),e.getExtensionDependency()}getState(){const t=this.state;return function(t){return t.id>=Mt}(t)||xt(316,String(t.id),String(Mt)),t}getDirectDependentNames(){return this.builder.incomingEdges.get(this.extension.name)||It}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>=Ot})(t)||xt(317,this.extension.name),this._dependency={config:t.config,init:t.initResult,output:t.output}}return this._dependency}}const At={tag:p};function Pt(){const t=o();t.isEmpty()&&t.append(r())}const Kt=t({config:e({setOptions:At,updateOptions:At}),init:({$initialEditorState:t=Pt})=>({$initialEditorState:t,initialized:!1}),afterRegistration(t,{updateOptions:e,setOptions:n},i){const o=i.getInitResult();if(!o.initialized){o.initialized=!0;const{$initialEditorState:i}=o;if(g(i))t.setEditorState(i,n);else if("function"==typeof i)t.update(()=>{i(t)},e);else if(i&&("string"==typeof i||"object"==typeof i)){const e=t.parseEditorState(i);t.setEditorState(e,n)}}return()=>{}},name:"@lexical/extension/InitialState",nodes:[a,u,f,h,l]}),kt=Symbol.for("@lexical/extension/LexicalBuilder");function $t(...t){return Bt.fromExtensions(t).buildEditor()}function zt(){}function Ut(t){throw t}function Lt(t){return Array.isArray(t)?t:[t]}const Tt="0.37.1-nightly.20251020.0+prod.esm";class Bt{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=Tt,this.roots=t;for(const e of t)this.addExtension(e)}static fromExtensions(t){const e=[Lt(Kt)];for(const n of t)e.push(Lt(n));return new Bt(e)}static maybeFromEditor(t){const e=t[kt];return e&&(e.PACKAGE_VERSION!==Tt&&xt(292,e.PACKAGE_VERSION,Tt),e instanceof Bt||xt(293)),e}static fromEditor(t){const e=Bt.maybeFromEditor(t);return void 0===e&&xt(294),e}constructEditor(){const{$initialEditorState:t,onError:e,...n}=this.buildCreateEditorArgs(),i=Object.assign(m({...n,...e?{onError:t=>{e(t,i)}}:{}}),{[kt]:this});for(const t of this.sortedExtensionReps())t.build(i);return i}buildEditor(){let t=zt;function e(){try{t()}finally{t=zt}}const n=Object.assign(this.constructEditor(),{dispose:e,[Symbol.dispose]:e});return t=k(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&&xt(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&&xt(296);const e=Lt(t),[n]=e;"string"!=typeof n.name&&xt(297,typeof n.name);let i=this.extensionNameMap.get(n.name);if(void 0!==i&&i.extension!==n&&xt(298,n.name),!i){i=new jt(this,n),this.extensionNameMap.set(n.name,i);const t=this.conflicts.get(n.name);"string"==typeof t&&xt(299,n.name,t);for(const t of n.conflictsWith||[])this.extensionNameMap.has(t)&&xt(299,n.name,t),this.conflicts.set(t,n.name);for(const t of n.dependencies||[]){const e=Lt(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(Dt(o))return;const s=n.extension.name;var r;Ct(o)||xt(300,s,i||"[unknown]"),Ct(r=o)||xt(304,String(r.id),String(St)),o=Object.assign(r,{id:Et}),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=_t(o),n.state=o,t.push(n)};for(const t of this.extensionNameMap.values())Ct(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&&xt(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 k(...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 pt(r)){if("function"!=typeof t){const e=n.get(t.replace);e&&xt(302,r.name,t.replace.name,e.extension.name),n.set(t.replace,c)}e.add(t)}if(r.html){if(r.html.export)for(const[t,e]of r.html.export.entries())i.set(t,e);r.html.import&&Object.assign(o,r.html.import)}r.theme&&yt(s,r.theme)}Object.keys(s).length>0&&(t.theme=s),e.size&&(t.nodes=[...e]);const c=Object.keys(o).length>0,d=i.size>0;(c||d)&&(t.html={},c&&(t.html.import=o),d&&(t.html.export=i));for(const e of r)e.init(t);return t.onError||(t.onError=Ut),t}}function Ft(t,e){const n=Bt.fromEditor(t).getExtensionRep(e);return void 0===n&&xt(303,e.name),n.getExtensionDependency()}function Gt(t,e){const n=Bt.fromEditor(t).extensionNameMap.get(e);return n?n.getExtensionDependency():void 0}function Vt(t,e){const n=Gt(t,e);return void 0===n&&xt(291,e),n}const Wt=new Set,Zt=t({build(t,e,n){const i=n.getDependency(vt).output,o=X({watchedNodeKeys:new Map}),r=mt(()=>{},()=>dt(()=>{const t=r.peek(),{watchedNodeKeys:e}=o.value;let n,c=!1;i.value.read(()=>{if(s())for(const[i,o]of e.entries()){if(0===o.size){e.delete(i);continue}const s=v(i),r=s&&s.isSelected()||!1;c=c||r!==(!!t&&t.has(i)),r&&(n=n||new Set,n.add(i))}}),!c&&n&&t&&n.size===t.size||(r.value=n)}));return{watchNodeKey:function(t){const e=it(()=>(r.value||Wt).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:[vt],name:"@lexical/extension/NodeSelection"}),Jt=x("INSERT_HORIZONTAL_RULE_COMMAND");class Ht extends N{static getType(){return"horizontalrule"}static clone(t){return new Ht(t.__key)}static importJSON(t){return Qt().updateFromJSON(t)}static importDOM(){return{hr:()=>({conversion:qt,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 qt(){return{node:Qt()}}function Qt(){return y(Ht)}function Xt(t){return t instanceof Ht}const Yt=t({dependencies:[vt,Zt],name:"@lexical/extension/HorizontalRule",nodes:[Ht],register(t,e,n){const{watchNodeKey:i}=n.getDependency(Zt).output,o=X({nodeSelections:new Map}),r=t._config.theme.hrSelected??"selected";return k(t.registerCommand(S,t=>{if(E(t.target)){const e=b(t.target);if(Xt(e))return function(t,e=!1){const n=s(),i=t.isSelected(),o=t.getKey();let r;e&&O(n)?r=n:(r=R(),M(r)),i?r.delete(o):r.add(o)}(e,t.shiftKey),!0}return!1},w),t.registerMutationListener(Ht,(e,n)=>{F(()=>{let n=!1;const{nodeSelections:s}=o.peek();for(const[o,r]of e.entries())if("destroyed"===r)s.delete(o),n=!0;else{const e=s.get(o),r=t.getElementByKey(o);e?e.domNode.value=r:(n=!0,s.set(o,{domNode:X(r),selectedSignal:i(o)}))}n&&(o.value={nodeSelections:s})})}),dt(()=>{const t=[];for(const{domNode:e,selectedSignal:n}of o.value.nodeSelections.values())t.push(dt(()=>{const t=e.value;if(t){n.value?$(t,r):z(t,r)}}));return k(...t)}))}});function te(t,e){return k(t.registerCommand(C,e=>{const n=s();if(!c(n))return!1;e.preventDefault();const i=function(t){const e=t.getNodes();if(L(e,t=>A(t)&&t.canIndent()?t:null).length>0)return!0;const n=t.anchor,i=t.focus,o=i.isBefore(n)?i:n,s=o.getNode(),r=U(s);if(r.canIndent()){const t=r.getKey();let e=P();if(e.anchor.set(t,0,"element"),e.focus.set(t,0,"element"),e=K(e),e.anchor.is(o))return!0}return!1}(n)?e.shiftKey?D:_:I;return t.dispatchCommand(i,void 0)},i),t.registerCommand(_,()=>{const t="number"==typeof e?e:e?e.peek():null;if(null==t)return!1;const n=s();if(!c(n))return!1;const i=n.getNodes().map(t=>U(t).getIndent());return Math.max(...i)+1>=t},j))}const ee=t({build:(t,e,n)=>at(e),config:e({disabled:!1,maxIndent:null}),name:"@lexical/extension/TabIndentation",register(t,e,n){const{disabled:i,maxIndent:o}=n.getOutput();return dt(()=>{if(!i.value)return te(t,o)})}});export{Qt as $createHorizontalRuleNode,Xt as $isHorizontalRuleNode,ut as AutoFocusExtension,lt as ClearEditorExtension,vt as EditorStateExtension,Yt as HorizontalRuleExtension,Ht as HorizontalRuleNode,Jt as INSERT_HORIZONTAL_RULE_COMMAND,Kt as InitialStateExtension,Bt as LexicalBuilder,Zt as NodeSelectionExtension,ee as TabIndentationExtension,F as batch,$t as buildEditorFromExtensions,it as computed,dt as effect,Ft as getExtensionDependencyFromEditor,gt as getKnownTypesAndNodes,Gt as getPeerDependencyFromEditor,Vt as getPeerDependencyFromEditorOrThrow,at as namedSignals,ht as registerClearEditor,te as registerTabIndentation,X as signal,W as untracked,mt as watchedSignal};
|
package/config.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
import type { InitialEditorConfig, KlassConstructor, LexicalNode } from 'lexical';
|
|
8
|
+
import type { CreateEditorArgs, InitialEditorConfig, KlassConstructor, LexicalNode } from 'lexical';
|
|
9
9
|
export interface KnownTypesAndNodes {
|
|
10
10
|
types: Set<string>;
|
|
11
11
|
nodes: Set<KlassConstructor<typeof LexicalNode>>;
|
|
@@ -23,3 +23,4 @@ export declare function getKnownTypesAndNodes(config: InitialEditorConfig): {
|
|
|
23
23
|
nodes: Set<KlassConstructor<typeof LexicalNode>>;
|
|
24
24
|
types: Set<string>;
|
|
25
25
|
};
|
|
26
|
+
export declare function getNodeConfig(config: InitialEditorConfig): NonNullable<CreateEditorArgs['nodes']>;
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"extension",
|
|
7
7
|
"plugin"
|
|
8
8
|
],
|
|
9
|
-
"version": "0.37.1-nightly.
|
|
9
|
+
"version": "0.37.1-nightly.20251020.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.37.1-nightly.
|
|
26
|
+
"@lexical/utils": "0.37.1-nightly.20251020.0",
|
|
27
27
|
"@preact/signals-core": "^1.11.0",
|
|
28
|
-
"lexical": "0.37.1-nightly.
|
|
28
|
+
"lexical": "0.37.1-nightly.20251020.0"
|
|
29
29
|
},
|
|
30
30
|
"exports": {
|
|
31
31
|
".": {
|