@lexical/extension 0.35.1-nightly.20250925.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.
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ 'use strict'
10
+ const LexicalExtension = process.env.NODE_ENV !== 'production' ? require('./LexicalExtension.dev.js') : require('./LexicalExtension.prod.js');
11
+ module.exports = LexicalExtension;
@@ -0,0 +1,202 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict
8
+ */
9
+
10
+ /**
11
+ * LexicalExtension
12
+ */
13
+ import type {
14
+ LexicalNode,
15
+ NodeKey,
16
+ ExtensionConfigBase,
17
+ EditorState,
18
+ AnyLexicalExtension,
19
+ AnyLexicalExtensionArgument,
20
+ LexicalEditor,
21
+ LexicalEditorWithDispose,
22
+ LexicalCommand,
23
+ LexicalExtension,
24
+ LexicalExtensionDependency,
25
+ EditorUpdateOptions,
26
+ EditorSetOptions,
27
+ InitialEditorConfig,
28
+ SerializedLexicalNode,
29
+ } from 'lexical';
30
+ import {DecoratorNode} from 'lexical';
31
+ export type {
32
+ AnyLexicalExtension,
33
+ AnyLexicalExtensionArgument,
34
+ ExtensionConfigBase,
35
+ ExtensionRegisterState,
36
+ InitialEditorStateType,
37
+ LexicalEditorWithDispose,
38
+ LexicalExtension,
39
+ LexicalExtensionArgument,
40
+ LexicalExtensionConfig,
41
+ LexicalExtensionDependency,
42
+ LexicalExtensionInit,
43
+ LexicalExtensionName,
44
+ LexicalExtensionOutput,
45
+ NormalizedLexicalExtensionArgument,
46
+ NormalizedPeerDependency,
47
+ OutputComponentExtension,
48
+ } from 'lexical';
49
+ export {
50
+ configExtension,
51
+ declarePeerDependency,
52
+ defineExtension,
53
+ safeCast,
54
+ shallowMergeConfig,
55
+ } from 'lexical';
56
+
57
+ export type NamedSignalsOptions<Defaults> = {
58
+ [K in keyof Defaults]?: Defaults[K];
59
+ };
60
+ export type NamedSignalsOutput<Defaults> = {
61
+ [K in keyof Defaults]: Signal<Defaults[K]>;
62
+ };
63
+
64
+ declare export function namedSignals<Defaults>(
65
+ defaults: Defaults,
66
+ opts?: NamedSignalsOptions<Defaults>
67
+ ): NamedSignalsOutput<Defaults>;
68
+
69
+ declare export class Signal<T = mixed> {
70
+ constructor(value?: T, options?: SignalOptions<T>): this;
71
+ subscribe(fn: (value: T) => void): () => void;
72
+ name?: string;
73
+ valueOf(): T;
74
+ toString(): string;
75
+ toJSON(): T;
76
+ peek(): T;
77
+ brand: symbol;
78
+ value: T;
79
+ }
80
+ export interface ReadonlySignal<T = mixed> {
81
+ +value: T;
82
+ peek(): T;
83
+ subscribe(fn: (value: T) => void): () => void;
84
+ valueOf(): T;
85
+ toString(): string;
86
+ toJSON(): T;
87
+ brand: symbol;
88
+ }
89
+ export type SignalOptions<T = mixed> = {
90
+ watched?: (this: Signal<T>) => void;
91
+ unwatched?: (this: Signal<T>) => void;
92
+ name?: string;
93
+ }
94
+ type EffectFn = ((this: {
95
+ dispose: () => void;
96
+ }) => void | (() => void)) | (() => void | (() => void));
97
+ type EffectOptions = {
98
+ name?: string;
99
+ }
100
+ declare export function batch<T>(fn: () => T): T;
101
+ declare export function computed<T>(fn: () => T, options?: SignalOptions<T>): ReadonlySignal<T>;
102
+ declare export function effect(fn: EffectFn, options?: EffectOptions): () => void;
103
+ declare export function signal<T>(value: T, options?: SignalOptions<T>): Signal<T>;
104
+ declare export function signal<T = void>(): Signal<T | void>;
105
+ declare export function untracked<T>(fn: () => T): T;
106
+
107
+ type DefaultSelection = 'rootStart' | 'rootEnd';
108
+ export type AutoFocusConfig = {
109
+ defaultSelection: DefaultSelection;
110
+ disabled: boolean;
111
+ }
112
+ declare export var AutoFocusExtension: LexicalExtension<AutoFocusConfig, "@lexical/extension/AutoFocus", NamedSignalsOutput<AutoFocusConfig>, void>;
113
+ export type ClearEditorConfig = {
114
+ $onClear: () => void;
115
+ }
116
+ declare export var ClearEditorExtension: LexicalExtension<ClearEditorConfig, "@lexical/extension/ClearEditor", NamedSignalsOutput<ClearEditorConfig>, void>;
117
+ declare export var EditorStateExtension: LexicalExtension<ExtensionConfigBase, "@lexical/extension/EditorState", Signal<EditorState>, void>;
118
+ declare export function getExtensionDependencyFromEditor<
119
+ Extension: AnyLexicalExtension,
120
+ >(
121
+ editor: LexicalEditor,
122
+ extension: Extension,
123
+ ): LexicalExtensionDependency<Extension>;
124
+ declare export function getPeerDependencyFromEditor<
125
+ Extension: AnyLexicalExtension = empty,
126
+ >(
127
+ editor: LexicalEditor,
128
+ extensionName: Extension['name'],
129
+ ): LexicalExtensionDependency<Extension> | void;
130
+ declare export function getPeerDependencyFromEditorOrThrow<
131
+ Extension: AnyLexicalExtension = empty,
132
+ >(
133
+ editor: LexicalEditor,
134
+ extensionName: Extension['name'],
135
+ ): LexicalExtensionDependency<Extension>;
136
+
137
+ export type SerializedHorizontalRuleNode = SerializedLexicalNode;
138
+ declare export class HorizontalRuleNode extends DecoratorNode<React.Node> {
139
+ static getType(): string;
140
+ static clone(node: HorizontalRuleNode): HorizontalRuleNode;
141
+ createDOM(): HTMLElement;
142
+ getTextContent(): '\n';
143
+ updateDOM(): false;
144
+ decorate(): React.Node;
145
+ }
146
+
147
+ declare export function $createHorizontalRuleNode(): HorizontalRuleNode;
148
+ declare export function $isHorizontalRuleNode(
149
+ node: ?LexicalNode,
150
+ ): node is HorizontalRuleNode;
151
+
152
+ declare export var INSERT_HORIZONTAL_RULE_COMMAND: LexicalCommand<void>;
153
+ declare export var HorizontalRuleExtension: LexicalExtension<ExtensionConfigBase, "@lexical/extension/HorizontalRule", void, void>;
154
+
155
+ export type InitialStateConfig = {
156
+ updateOptions: EditorUpdateOptions;
157
+ setOptions: EditorSetOptions;
158
+ }
159
+ declare export var InitialStateExtension: LexicalExtension<InitialStateConfig, "@lexical/extension/InitialState", void, void>;
160
+
161
+ declare export function buildEditorFromExtensions(
162
+ ...extensions: AnyLexicalExtensionArgument[]
163
+ ): LexicalEditorWithDispose;
164
+
165
+ declare export class LexicalBuilder {
166
+ static fromExtensions(
167
+ extensions: AnyLexicalExtensionArgument[],
168
+ ): LexicalBuilder;
169
+ static maybeFromEditor(editor: LexicalEditor): void | LexicalBuilder;
170
+ static fromEditor(editor: LexicalEditor): LexicalBuilder;
171
+ hasExtensionByName(name: string): boolean;
172
+ }
173
+
174
+ declare export var NodeSelectionExtension: LexicalExtension<ExtensionConfigBase, "@lexical/extension/NodeSelection", {
175
+ watchNodeKey: (key: NodeKey) => ReadonlySignal<boolean>;
176
+ }, void>;
177
+
178
+ export type TabIndentationConfig = {
179
+ disabled: boolean;
180
+ maxIndent: null | number;
181
+ }
182
+ declare export var TabIndentationExtension: LexicalExtension<TabIndentationConfig, "@lexical/extension/TabIndentation", NamedSignalsOutput<TabIndentationConfig>, void>;
183
+ declare export function watchedSignal<T>(
184
+ getSnapshot: () => T,
185
+ register: (self: Signal<T>) => () => void,
186
+ ): Signal<T>;
187
+
188
+ declare export function registerClearEditor(
189
+ editor: LexicalEditor,
190
+ $onClear?: () => void,
191
+ ): () => void;
192
+
193
+ export type KnownTypesAndNodes = {
194
+ types: Set<string>;
195
+ nodes: Set<Class<LexicalNode>>;
196
+ };
197
+ declare export function getKnownTypesAndNodes(config: InitialEditorConfig): KnownTypesAndNodes;
198
+
199
+ declare export function registerTabIndentation(
200
+ editor: LexicalEditor,
201
+ maxIndent?: number | ReadonlySignal<null | number>,
202
+ ): () => void;
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ import * as modDev from './LexicalExtension.dev.mjs';
10
+ import * as modProd from './LexicalExtension.prod.mjs';
11
+ const mod = process.env.NODE_ENV !== 'production' ? modDev : modProd;
12
+ export const $createHorizontalRuleNode = mod.$createHorizontalRuleNode;
13
+ export const $isHorizontalRuleNode = mod.$isHorizontalRuleNode;
14
+ export const AutoFocusExtension = mod.AutoFocusExtension;
15
+ export const ClearEditorExtension = mod.ClearEditorExtension;
16
+ export const EditorStateExtension = mod.EditorStateExtension;
17
+ export const HorizontalRuleExtension = mod.HorizontalRuleExtension;
18
+ export const HorizontalRuleNode = mod.HorizontalRuleNode;
19
+ export const INSERT_HORIZONTAL_RULE_COMMAND = mod.INSERT_HORIZONTAL_RULE_COMMAND;
20
+ export const InitialStateExtension = mod.InitialStateExtension;
21
+ export const LexicalBuilder = mod.LexicalBuilder;
22
+ export const NodeSelectionExtension = mod.NodeSelectionExtension;
23
+ export const TabIndentationExtension = mod.TabIndentationExtension;
24
+ export const batch = mod.batch;
25
+ export const buildEditorFromExtensions = mod.buildEditorFromExtensions;
26
+ export const computed = mod.computed;
27
+ export const configExtension = mod.configExtension;
28
+ export const declarePeerDependency = mod.declarePeerDependency;
29
+ export const defineExtension = mod.defineExtension;
30
+ export const effect = mod.effect;
31
+ export const getExtensionDependencyFromEditor = mod.getExtensionDependencyFromEditor;
32
+ export const getKnownTypesAndNodes = mod.getKnownTypesAndNodes;
33
+ export const getPeerDependencyFromEditor = mod.getPeerDependencyFromEditor;
34
+ export const getPeerDependencyFromEditorOrThrow = mod.getPeerDependencyFromEditorOrThrow;
35
+ export const namedSignals = mod.namedSignals;
36
+ export const registerClearEditor = mod.registerClearEditor;
37
+ export const registerTabIndentation = mod.registerTabIndentation;
38
+ export const safeCast = mod.safeCast;
39
+ export const shallowMergeConfig = mod.shallowMergeConfig;
40
+ export const signal = mod.signal;
41
+ export const untracked = mod.untracked;
42
+ export const watchedSignal = mod.watchedSignal;
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ const mod = await (process.env.NODE_ENV !== 'production' ? import('./LexicalExtension.dev.mjs') : import('./LexicalExtension.prod.mjs'));
10
+ export const $createHorizontalRuleNode = mod.$createHorizontalRuleNode;
11
+ export const $isHorizontalRuleNode = mod.$isHorizontalRuleNode;
12
+ export const AutoFocusExtension = mod.AutoFocusExtension;
13
+ export const ClearEditorExtension = mod.ClearEditorExtension;
14
+ export const EditorStateExtension = mod.EditorStateExtension;
15
+ export const HorizontalRuleExtension = mod.HorizontalRuleExtension;
16
+ export const HorizontalRuleNode = mod.HorizontalRuleNode;
17
+ export const INSERT_HORIZONTAL_RULE_COMMAND = mod.INSERT_HORIZONTAL_RULE_COMMAND;
18
+ export const InitialStateExtension = mod.InitialStateExtension;
19
+ export const LexicalBuilder = mod.LexicalBuilder;
20
+ export const NodeSelectionExtension = mod.NodeSelectionExtension;
21
+ export const TabIndentationExtension = mod.TabIndentationExtension;
22
+ export const batch = mod.batch;
23
+ export const buildEditorFromExtensions = mod.buildEditorFromExtensions;
24
+ export const computed = mod.computed;
25
+ export const configExtension = mod.configExtension;
26
+ export const declarePeerDependency = mod.declarePeerDependency;
27
+ export const defineExtension = mod.defineExtension;
28
+ export const effect = mod.effect;
29
+ export const getExtensionDependencyFromEditor = mod.getExtensionDependencyFromEditor;
30
+ export const getKnownTypesAndNodes = mod.getKnownTypesAndNodes;
31
+ export const getPeerDependencyFromEditor = mod.getPeerDependencyFromEditor;
32
+ export const getPeerDependencyFromEditorOrThrow = mod.getPeerDependencyFromEditorOrThrow;
33
+ export const namedSignals = mod.namedSignals;
34
+ export const registerClearEditor = mod.registerClearEditor;
35
+ export const registerTabIndentation = mod.registerTabIndentation;
36
+ export const safeCast = mod.safeCast;
37
+ export const shallowMergeConfig = mod.shallowMergeConfig;
38
+ export const signal = mod.signal;
39
+ export const untracked = mod.untracked;
40
+ export const watchedSignal = mod.watchedSignal;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ "use strict";var t=require("lexical"),e=require("@lexical/utils");const n=Symbol.for("preact-signals");function i(){if(d>1)return void d--;let t,e=!1;for(;void 0!==r;){let n=r;for(r=void 0,c++;void 0!==n;){const i=n.o;if(n.o=void 0,n.f&=-3,!(8&n.f)&&g(n))try{n.c()}catch(n){e||(t=n,e=!0)}n=i}}if(c=0,d--,e)throw t}function o(t){if(d>0)return t();d++;try{return t()}finally{i()}}let s,r;function a(t){const e=s;s=void 0;try{return t()}finally{s=e}}let d=0,c=0,u=0;function f(t){if(void 0===s)return;let e=t.n;return void 0===e||e.t!==s?(e={i:0,S:t,p:s.s,n:void 0,t:s,e:void 0,x:void 0,r:e},void 0!==s.s&&(s.s.n=e),s.s=e,t.n=e,32&s.f&&t.S(e),e):-1===e.i?(e.i=0,void 0!==e.n&&(e.n.p=e.p,void 0!==e.p&&(e.p.n=e.n),e.p=s.s,e.n=void 0,s.s.n=e,s.s=e),e):void 0}function l(t,e){this.v=t,this.i=0,this.n=void 0,this.t=void 0,this.W=null==e?void 0:e.watched,this.Z=null==e?void 0:e.unwatched,this.name=null==e?void 0:e.name}function h(t,e){return new l(t,e)}function g(t){for(let e=t.s;void 0!==e;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return!0;return!1}function p(t){for(let e=t.s;void 0!==e;e=e.n){const n=e.S.n;if(void 0!==n&&(e.r=n),e.S.n=e,e.i=-1,void 0===e.n){t.s=e;break}}}function m(t){let e,n=t.s;for(;void 0!==n;){const t=n.p;-1===n.i?(n.S.U(n),void 0!==t&&(t.n=n.n),void 0!==n.n&&(n.n.p=t)):e=n,n.S.n=n.r,void 0!==n.r&&(n.r=void 0),n=t}t.s=e}function x(t,e){l.call(this,void 0),this.x=t,this.s=void 0,this.g=u-1,this.f=4,this.W=null==e?void 0:e.watched,this.Z=null==e?void 0:e.unwatched,this.name=null==e?void 0:e.name}function E(t,e){return new x(t,e)}function v(t){const e=t.u;if(t.u=void 0,"function"==typeof e){d++;const n=s;s=void 0;try{e()}catch(e){throw t.f&=-2,t.f|=8,S(t),e}finally{s=n,i()}}}function S(t){for(let e=t.s;void 0!==e;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,v(t)}function y(t){if(s!==this)throw new Error("Out-of-order effect");m(this),s=t,this.f&=-2,8&this.f&&S(this),i()}function N(t,e){this.x=t,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=null==e?void 0:e.name}function b(t,e){const n=new N(t,e);try{n.c()}catch(t){throw n.d(),t}const i=n.d.bind(n);return i[Symbol.dispose]=i,i}function R(t,e={}){const n={};for(const i in t){const o=e[i],s=h(void 0===o?t[i]:o);n[i]=s}return n}l.prototype.brand=n,l.prototype.h=function(){return!0},l.prototype.S=function(t){const e=this.t;e!==t&&void 0===t.e&&(t.x=e,this.t=t,void 0!==e?e.e=t:a((()=>{var t;null==(t=this.W)||t.call(this)})))},l.prototype.U=function(t){if(void 0!==this.t){const e=t.e,n=t.x;void 0!==e&&(e.x=n,t.e=void 0),void 0!==n&&(n.e=e,t.x=void 0),t===this.t&&(this.t=n,void 0===n&&a((()=>{var t;null==(t=this.Z)||t.call(this)})))}},l.prototype.subscribe=function(t){return b((()=>{const e=this.value,n=s;s=void 0;try{t(e)}finally{s=n}}),{name:"sub"})},l.prototype.valueOf=function(){return this.value},l.prototype.toString=function(){return this.value+""},l.prototype.toJSON=function(){return this.value},l.prototype.peek=function(){const t=s;s=void 0;try{return this.value}finally{s=t}},Object.defineProperty(l.prototype,"value",{get(){const t=f(this);return void 0!==t&&(t.i=this.i),this.v},set(t){if(t!==this.v){if(c>100)throw new Error("Cycle detected");this.v=t,this.i++,u++,d++;try{for(let t=this.t;void 0!==t;t=t.x)t.t.N()}finally{i()}}}}),x.prototype=new l,x.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if(32==(36&this.f))return!0;if(this.f&=-5,this.g===u)return!0;if(this.g=u,this.f|=1,this.i>0&&!g(this))return this.f&=-2,!0;const t=s;try{p(this),s=this;const t=this.x();(16&this.f||this.v!==t||0===this.i)&&(this.v=t,this.f&=-17,this.i++)}catch(t){this.v=t,this.f|=16,this.i++}return s=t,m(this),this.f&=-2,!0},x.prototype.S=function(t){if(void 0===this.t){this.f|=36;for(let t=this.s;void 0!==t;t=t.n)t.S.S(t)}l.prototype.S.call(this,t)},x.prototype.U=function(t){if(void 0!==this.t&&(l.prototype.U.call(this,t),void 0===this.t)){this.f&=-33;for(let t=this.s;void 0!==t;t=t.n)t.S.U(t)}},x.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(let t=this.t;void 0!==t;t=t.x)t.t.N()}},Object.defineProperty(x.prototype,"value",{get(){if(1&this.f)throw new Error("Cycle detected");const t=f(this);if(this.h(),void 0!==t&&(t.i=this.i),16&this.f)throw this.v;return this.v}}),N.prototype.c=function(){const t=this.S();try{if(8&this.f)return;if(void 0===this.x)return;const t=this.x();"function"==typeof t&&(this.u=t)}finally{t()}},N.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,v(this),p(this),d++;const t=s;return s=this,y.bind(this,t)},N.prototype.N=function(){2&this.f||(this.f|=2,this.o=r,r=this)},N.prototype.d=function(){this.f|=8,1&this.f||S(this)},N.prototype.dispose=function(){this.d()};const O=t.defineExtension({build:(t,e,n)=>R(e),config:t.safeCast({defaultSelection:"rootEnd",disabled:!1}),name:"@lexical/extension/AutoFocus",register(t,e,n){const i=n.getOutput();return b((()=>i.disabled.value?void 0:t.registerRootListener((e=>{t.focus((()=>{const t=document.activeElement;null===e||null!==t&&e.contains(t)||e.focus({preventScroll:!0})}),{defaultSelection:i.defaultSelection.peek()})}))))}});function w(){const e=t.$getRoot(),n=t.$getSelection(),i=t.$createParagraphNode();e.clear(),e.append(i),null!==n&&i.select(),t.$isRangeSelection(n)&&(n.format=0)}function C(e,n=w){return e.registerCommand(t.CLEAR_EDITOR_COMMAND,(t=>(e.update(n),!0)),t.COMMAND_PRIORITY_EDITOR)}const M=t.defineExtension({build:(t,e,n)=>R(e),config:t.safeCast({$onClear:w}),name:"@lexical/extension/ClearEditor",register(t,e,n){const{$onClear:i}=n.getOutput();return b((()=>C(t,i.value)))}});function D(t,e){let n;return h(t(),{unwatched(){n&&(n(),n=void 0)},watched(){this.value=t(),n=e(this)}})}const _=t.defineExtension({build:t=>D((()=>t.getEditorState()),(e=>t.registerUpdateListener((t=>{e.value=t.editorState})))),name:"@lexical/extension/EditorState"});function I(t,...e){const n=new URL("https://lexical.dev/docs/error"),i=new URLSearchParams;i.append("code",t);for(const t of e)i.append("v",t);throw n.search=i.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function T(t,e){if(t&&e&&!Array.isArray(e)&&"object"==typeof t&&"object"==typeof e){const n=t,i=e;for(const t in i)n[t]=T(n[t],i[t]);return t}return e}const A={unmarked:0,temporary:1,permanent:2,configured:3,initialized:4,built:5,registered:6,afterRegistration:7};function $(t){return t.id===A.unmarked}function P(t){return t.id===A.permanent}function k(t){return function(t){return t.id===A.temporary}(t)||I(305,String(t.id),String(A.temporary)),Object.assign(t,{id:A.permanent})}const z=new Set;class j{builder;configs;_dependency;_peerNameSet;extension;state;_signal;constructor(t,e){this.builder=t,this.extension=e,this.configs=new Set,this.state={id:A.unmarked}}mergeConfigs(){let e=this.extension.config||{};const n=this.extension.mergeConfig?this.extension.mergeConfig.bind(this.extension):t.shallowMergeConfig;for(const t of this.configs)e=n(e,t);return e}init(t){const e=this.state;P(e)||I(306,String(e.id));const n={getDependency:this.getInitDependency.bind(this),getDirectDependentNames:this.getDirectDependentNames.bind(this),getPeer:this.getInitPeer.bind(this),getPeerNameSet:this.getPeerNameSet.bind(this)},i={...n,getDependency:this.getDependency.bind(this),getInitResult:this.getInitResult.bind(this),getPeer:this.getPeer.bind(this)},o=function(t,e,n){return Object.assign(t,{config:e,id:A.configured,registerState:n})}(e,this.mergeConfigs(),n);let s;this.state=o,this.extension.init&&(s=this.extension.init(t,o.config,n)),this.state=function(t,e,n){return Object.assign(t,{id:A.initialized,initResult:e,registerState:n})}(o,s,i)}build(t){const e=this.state;let n;e.id!==A.initialized&&I(307,String(e.id),String(A.built)),this.extension.build&&(n=this.extension.build(t,e.config,e.registerState));const i={...e.registerState,getOutput:()=>n,getSignal:this.getSignal.bind(this)};this.state=function(t,e,n){return Object.assign(t,{id:A.built,output:e,registerState:n})}(e,n,i)}register(t,e){this._signal=e;const n=this.state;n.id!==A.built&&I(308,String(n.id),String(A.built));const i=this.extension.register&&this.extension.register(t,n.config,n.registerState);return this.state=function(t){return Object.assign(t,{id:A.registered})}(n),()=>{const t=this.state;t.id!==A.afterRegistration&&I(309,String(n.id),String(A.afterRegistration)),this.state=function(t){return Object.assign(t,{id:A.built})}(t),i&&i()}}afterRegistration(t){const e=this.state;let n;return e.id!==A.registered&&I(310,String(e.id),String(A.registered)),this.extension.afterRegistration&&(n=this.extension.afterRegistration(t,e.config,e.registerState)),this.state=function(t){return Object.assign(t,{id:A.afterRegistration})}(e),n}getSignal(){return void 0===this._signal&&I(311),this._signal}getInitResult(){void 0===this.extension.init&&I(312,this.extension.name);const t=this.state;return function(t){return t.id>=A.initialized}(t)||I(313,String(t.id),String(A.initialized)),t.initResult}getInitPeer(t){const e=this.builder.extensionNameMap.get(t);return e?e.getExtensionInitDependency():void 0}getExtensionInitDependency(){const t=this.state;return function(t){return t.id>=A.configured}(t)||I(314,String(t.id),String(A.configured)),{config:t.config}}getPeer(t){const e=this.builder.extensionNameMap.get(t);return e?e.getExtensionDependency():void 0}getInitDependency(t){const e=this.builder.getExtensionRep(t);return void 0===e&&I(315,this.extension.name,t.name),e.getExtensionInitDependency()}getDependency(t){const e=this.builder.getExtensionRep(t);return void 0===e&&I(315,this.extension.name,t.name),e.getExtensionDependency()}getState(){const t=this.state;return function(t){return t.id>=A.afterRegistration}(t)||I(316,String(t.id),String(A.afterRegistration)),t}getDirectDependentNames(){return this.builder.incomingEdges.get(this.extension.name)||z}getPeerNameSet(){let t=this._peerNameSet;return t||(t=new Set((this.extension.peerDependencies||[]).map((([t])=>t))),this._peerNameSet=t),t}getExtensionDependency(){if(!this._dependency){const t=this.state;(function(t){return t.id>=A.built})(t)||I(317,this.extension.name),this._dependency={config:t.config,init:t.initResult,output:t.output}}return this._dependency}}const K={tag:t.HISTORY_MERGE_TAG};function L(){const e=t.$getRoot();e.isEmpty()&&e.append(t.$createParagraphNode())}const B=t.defineExtension({config:t.safeCast({setOptions:K,updateOptions:K}),init:({$initialEditorState:t=L})=>({$initialEditorState:t,initialized:!1}),afterRegistration(e,{updateOptions:n,setOptions:i},o){const s=o.getInitResult();if(!s.initialized){s.initialized=!0;const{$initialEditorState:o}=s;if(t.$isEditorState(o))e.setEditorState(o,i);else if("function"==typeof o)e.update((()=>{o(e)}),n);else if(o&&("string"==typeof o||"object"==typeof o)){const t=e.parseEditorState(o);e.setEditorState(t,i)}}return()=>{}},name:"@lexical/extension/InitialState",nodes:[t.RootNode,t.TextNode,t.LineBreakNode,t.TabNode,t.ParagraphNode]}),U=Symbol.for("@lexical/extension/LexicalBuilder");function F(){}function H(t){throw t}function G(t){return Array.isArray(t)?t:[t]}const Y="0.35.1-nightly.20250925.0+prod.cjs";class W{roots;extensionNameMap;outgoingConfigEdges;incomingEdges;conflicts;_sortedExtensionReps;PACKAGE_VERSION;constructor(t){this.outgoingConfigEdges=new Map,this.incomingEdges=new Map,this.extensionNameMap=new Map,this.conflicts=new Map,this.PACKAGE_VERSION=Y,this.roots=t;for(const e of t)this.addExtension(e)}static fromExtensions(t){const e=[G(B)];for(const n of t)e.push(G(n));return new W(e)}static maybeFromEditor(t){const e=t[U];return e&&(e.PACKAGE_VERSION!==Y&&I(293,e.PACKAGE_VERSION,Y),e instanceof W||I(294)),e}static fromEditor(t){const e=W.maybeFromEditor(t);return void 0===e&&I(295),e}constructEditor(){const{$initialEditorState:e,onError:n,...i}=this.buildCreateEditorArgs(),o=Object.assign(t.createEditor({...i,...n?{onError:t=>{n(t,o)}}:{}}),{[U]:this});for(const t of this.sortedExtensionReps())t.build(o);return o}buildEditor(){let t=F;function n(){try{t()}finally{t=F}}const i=Object.assign(this.constructEditor(),{dispose:n,[Symbol.dispose]:n});return t=e.mergeRegister(this.registerEditor(i),(()=>i.setRootElement(null))),i}hasExtensionByName(t){return this.extensionNameMap.has(t)}getExtensionRep(t){const e=this.extensionNameMap.get(t.name);if(e)return e.extension!==t&&I(296,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(297);const e=G(t),[n]=e;"string"!=typeof n.name&&I(298,typeof n.name);let i=this.extensionNameMap.get(n.name);if(void 0!==i&&i.extension!==n&&I(299,n.name),!i){i=new j(this,n),this.extensionNameMap.set(n.name,i);const t=this.conflicts.get(n.name);"string"==typeof t&&I(300,n.name,t);for(const t of n.conflictsWith||[])this.extensionNameMap.has(t)&&I(300,n.name,t),this.conflicts.set(t,n.name);for(const t of n.dependencies||[]){const e=G(t);this.addEdge(n.name,e[0].name,e.slice(1)),this.addExtension(e)}for(const[t,e]of n.peerDependencies||[])this.addEdge(n.name,t,e?[e]:[])}}sortedExtensionReps(){if(this._sortedExtensionReps)return this._sortedExtensionReps;const t=[],e=(n,i)=>{let o=n.state;if(P(o))return;const s=n.extension.name;var r;$(o)||I(301,s,i||"[unknown]"),$(r=o)||I(304,String(r.id),String(A.unmarked)),o=Object.assign(r,{id:A.temporary}),n.state=o;const a=this.outgoingConfigEdges.get(s);if(a)for(const t of a.keys()){const n=this.extensionNameMap.get(t);n&&e(n,s)}o=k(o),n.state=o,t.push(n)};for(const t of this.extensionNameMap.values())$(t.state)&&e(t);for(const e of t)for(const[t,n]of this.outgoingConfigEdges.get(e.extension.name)||[])if(n.length>0){const e=this.extensionNameMap.get(t);if(e)for(const t of n)e.configs.add(t)}for(const[t,...e]of this.roots)if(e.length>0){const n=this.extensionNameMap.get(t.name);void 0===n&&I(302,t.name);for(const t of e)n.configs.add(t)}return this._sortedExtensionReps=t,this._sortedExtensionReps}registerEditor(t){const n=this.sortedExtensionReps(),i=new AbortController,o=[()=>i.abort()],s=i.signal;for(const e of n){const n=e.register(t,s);n&&o.push(n)}for(const e of n){const n=e.afterRegistration(t);n&&o.push(n)}return e.mergeRegister(...o)}buildCreateEditorArgs(){const t={},e=new Set,n=new Map,i=new Map,o={},s={},r=this.sortedExtensionReps();for(const a of r){const{extension:r}=a;if(void 0!==r.onError&&(t.onError=r.onError),void 0!==r.disableEvents&&(t.disableEvents=r.disableEvents),void 0!==r.parentEditor&&(t.parentEditor=r.parentEditor),void 0!==r.editable&&(t.editable=r.editable),void 0!==r.namespace&&(t.namespace=r.namespace),void 0!==r.$initialEditorState&&(t.$initialEditorState=r.$initialEditorState),r.nodes)for(const t of r.nodes){if("function"!=typeof t){const e=n.get(t.replace);e&&I(303,r.name,t.replace.name,e.extension.name),n.set(t.replace,a)}e.add(t)}if(r.html){if(r.html.export)for(const[t,e]of r.html.export.entries())i.set(t,e);r.html.import&&Object.assign(o,r.html.import)}r.theme&&T(s,r.theme)}Object.keys(s).length>0&&(t.theme=s),e.size&&(t.nodes=[...e]);const a=Object.keys(o).length>0,d=i.size>0;(a||d)&&(t.html={},a&&(t.html.import=o),d&&(t.html.export=i));for(const e of r)e.init(t);return t.onError||(t.onError=H),t}}function Z(t,e){const n=W.fromEditor(t).extensionNameMap.get(e);return n?n.getExtensionDependency():void 0}const V=new Set,J=t.defineExtension({build(e,n,i){const o=i.getDependency(_).output,s=h({watchedNodeKeys:new Map}),r=D((()=>{}),(()=>b((()=>{const e=r.peek(),{watchedNodeKeys:n}=s.value;let i,a=!1;o.value.read((()=>{if(t.$getSelection())for(const[o,s]of n.entries()){if(0===s.size){n.delete(o);continue}const r=t.$getNodeByKey(o),d=r&&r.isSelected()||!1;a=a||d!==(!!e&&e.has(o)),d&&(i=i||new Set,i.add(o))}})),!a&&i&&e&&i.size===e.size||(r.value=i)}))));return{watchNodeKey:function(t){const e=E((()=>(r.value||V).has(t))),{watchedNodeKeys:n}=s.peek();let i=n.get(t);const o=void 0!==i;return i=i||new Set,i.add(e),o||(n.set(t,i),s.value={watchedNodeKeys:n}),e}}},dependencies:[_],name:"@lexical/extension/NodeSelection"}),q=t.createCommand("INSERT_HORIZONTAL_RULE_COMMAND");class X extends t.DecoratorNode{static getType(){return"horizontalrule"}static clone(t){return new X(t.__key)}static importJSON(t){return tt().updateFromJSON(t)}static importDOM(){return{hr:()=>({conversion:Q,priority:0})}}exportDOM(){return{element:document.createElement("hr")}}createDOM(t){const n=document.createElement("hr");return e.addClassNamesToElement(n,t.theme.hr),n}getTextContent(){return"\n"}isInline(){return!1}updateDOM(){return!1}}function Q(){return{node:tt()}}function tt(){return t.$create(X)}function et(t){return t instanceof X}const nt=t.defineExtension({dependencies:[_,J],name:"@lexical/extension/HorizontalRule",nodes:[X],register(n,i,s){const{watchNodeKey:r}=s.getDependency(J).output,a=h({nodeSelections:new Map}),d=n._config.theme.hrSelected??"selected";return e.mergeRegister(n.registerCommand(t.CLICK_COMMAND,(e=>{if(t.isDOMNode(e.target)){const n=t.$getNodeFromDOMNode(e.target);if(et(n))return function(e,n=!1){const i=t.$getSelection(),o=e.isSelected(),s=e.getKey();let r;n&&t.$isNodeSelection(i)?r=i:(r=t.$createNodeSelection(),t.$setSelection(r)),o?r.delete(s):r.add(s)}(n,e.shiftKey),!0}return!1}),t.COMMAND_PRIORITY_LOW),n.registerMutationListener(X,((t,e)=>{o((()=>{let e=!1;const{nodeSelections:i}=a.peek();for(const[o,s]of t.entries())if("destroyed"===s)i.delete(o),e=!0;else{const t=i.get(o),s=n.getElementByKey(o);t?t.domNode.value=s:(e=!0,i.set(o,{domNode:h(s),selectedSignal:r(o)}))}e&&(a.value={nodeSelections:i})}))})),b((()=>{const t=[];for(const{domNode:n,selectedSignal:i}of a.value.nodeSelections.values())t.push(b((()=>{const t=n.value;if(t){i.value?e.addClassNamesToElement(t,d):e.removeClassNamesFromElement(t,d)}})));return e.mergeRegister(...t)})))}});function it(n,i){return e.mergeRegister(n.registerCommand(t.KEY_TAB_COMMAND,(i=>{const o=t.$getSelection();if(!t.$isRangeSelection(o))return!1;i.preventDefault();const s=function(n){const i=n.getNodes();if(e.$filter(i,(e=>t.$isBlockElementNode(e)&&e.canIndent()?e:null)).length>0)return!0;const o=n.anchor,s=n.focus,r=s.isBefore(o)?s:o,a=r.getNode(),d=e.$getNearestBlockElementAncestorOrThrow(a);if(d.canIndent()){const e=d.getKey();let n=t.$createRangeSelection();if(n.anchor.set(e,0,"element"),n.focus.set(e,0,"element"),n=t.$normalizeSelection__EXPERIMENTAL(n),n.anchor.is(r))return!0}return!1}(o)?i.shiftKey?t.OUTDENT_CONTENT_COMMAND:t.INDENT_CONTENT_COMMAND:t.INSERT_TAB_COMMAND;return n.dispatchCommand(s,void 0)}),t.COMMAND_PRIORITY_EDITOR),n.registerCommand(t.INDENT_CONTENT_COMMAND,(()=>{const n="number"==typeof i?i:i?i.peek():null;if(null==n)return!1;const o=t.$getSelection();if(!t.$isRangeSelection(o))return!1;const s=o.getNodes().map((t=>e.$getNearestBlockElementAncestorOrThrow(t).getIndent()));return Math.max(...s)+1>=n}),t.COMMAND_PRIORITY_CRITICAL))}const ot=t.defineExtension({build:(t,e,n)=>R(e),config:t.safeCast({disabled:!1,maxIndent:null}),name:"@lexical/extension/TabIndentation",register(t,e,n){const{disabled:i,maxIndent:o}=n.getOutput();return b((()=>{if(!i.value)return it(t,o)}))}});exports.configExtension=t.configExtension,exports.declarePeerDependency=t.declarePeerDependency,exports.defineExtension=t.defineExtension,exports.safeCast=t.safeCast,exports.shallowMergeConfig=t.shallowMergeConfig,exports.$createHorizontalRuleNode=tt,exports.$isHorizontalRuleNode=et,exports.AutoFocusExtension=O,exports.ClearEditorExtension=M,exports.EditorStateExtension=_,exports.HorizontalRuleExtension=nt,exports.HorizontalRuleNode=X,exports.INSERT_HORIZONTAL_RULE_COMMAND=q,exports.InitialStateExtension=B,exports.LexicalBuilder=W,exports.NodeSelectionExtension=J,exports.TabIndentationExtension=ot,exports.batch=o,exports.buildEditorFromExtensions=function(...t){return W.fromExtensions(t).buildEditor()},exports.computed=E,exports.effect=b,exports.getExtensionDependencyFromEditor=function(t,e){const n=W.fromEditor(t).getExtensionRep(e);return void 0===n&&I(291,e.name),n.getExtensionDependency()},exports.getKnownTypesAndNodes=function(t){const e=new Set,n=new Set;for(const i of t.nodes??[]){const t="function"==typeof i?i:i.replace;e.add(t.getType()),n.add(t)}return{nodes:n,types:e}},exports.getPeerDependencyFromEditor=Z,exports.getPeerDependencyFromEditorOrThrow=function(t,e){const n=Z(t,e);return void 0===n&&I(292,e),n},exports.namedSignals=R,exports.registerClearEditor=C,exports.registerTabIndentation=it,exports.signal=h,exports.untracked=a,exports.watchedSignal=D;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ import{defineExtension as t,safeCast as e,CLEAR_EDITOR_COMMAND as n,COMMAND_PRIORITY_EDITOR as i,$getRoot as o,$getSelection as s,$createParagraphNode as r,$isRangeSelection as c,shallowMergeConfig as d,RootNode as a,TextNode as u,LineBreakNode as f,TabNode as h,ParagraphNode as l,$isEditorState as g,HISTORY_MERGE_TAG as p,createEditor as m,$getNodeByKey as v,createCommand as y,$create as x,CLICK_COMMAND as S,isDOMNode as E,$getNodeFromDOMNode as b,COMMAND_PRIORITY_LOW as w,DecoratorNode as N,$isNodeSelection as R,$createNodeSelection as O,$setSelection as M,KEY_TAB_COMMAND as C,OUTDENT_CONTENT_COMMAND as D,INDENT_CONTENT_COMMAND as _,INSERT_TAB_COMMAND as I,COMMAND_PRIORITY_CRITICAL as j,$isBlockElementNode as A,$createRangeSelection as k,$normalizeSelection__EXPERIMENTAL as P}from"lexical";export{configExtension,declarePeerDependency,defineExtension,safeCast,shallowMergeConfig}from"lexical";import{mergeRegister as z,addClassNamesToElement as K,removeClassNamesFromElement as $,$getNearestBlockElementAncestorOrThrow as U,$filter as L}from"@lexical/utils";const T=Symbol.for("preact-signals");function B(){if(Z>1)return void Z--;let t,e=!1;for(;void 0!==V;){let n=V;for(V=void 0,J++;void 0!==n;){const i=n.o;if(n.o=void 0,n.f&=-3,!(8&n.f)&&Y(n))try{n.c()}catch(n){e||(t=n,e=!0)}n=i}}if(J=0,Z--,e)throw t}function F(t){if(Z>0)return t();Z++;try{return t()}finally{B()}}let G,V;function W(t){const e=G;G=void 0;try{return t()}finally{G=e}}let Z=0,J=0,H=0;function q(t){if(void 0===G)return;let e=t.n;return void 0===e||e.t!==G?(e={i:0,S:t,p:G.s,n:void 0,t:G,e:void 0,x:void 0,r:e},void 0!==G.s&&(G.s.n=e),G.s=e,t.n=e,32&G.f&&t.S(e),e):-1===e.i?(e.i=0,void 0!==e.n&&(e.n.p=e.p,void 0!==e.p&&(e.p.n=e.n),e.p=G.s,e.n=void 0,G.s.n=e,G.s=e),e):void 0}function Q(t,e){this.v=t,this.i=0,this.n=void 0,this.t=void 0,this.W=null==e?void 0:e.watched,this.Z=null==e?void 0:e.unwatched,this.name=null==e?void 0:e.name}function X(t,e){return new Q(t,e)}function Y(t){for(let e=t.s;void 0!==e;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return!0;return!1}function tt(t){for(let e=t.s;void 0!==e;e=e.n){const n=e.S.n;if(void 0!==n&&(e.r=n),e.S.n=e,e.i=-1,void 0===e.n){t.s=e;break}}}function et(t){let e,n=t.s;for(;void 0!==n;){const t=n.p;-1===n.i?(n.S.U(n),void 0!==t&&(t.n=n.n),void 0!==n.n&&(n.n.p=t)):e=n,n.S.n=n.r,void 0!==n.r&&(n.r=void 0),n=t}t.s=e}function nt(t,e){Q.call(this,void 0),this.x=t,this.s=void 0,this.g=H-1,this.f=4,this.W=null==e?void 0:e.watched,this.Z=null==e?void 0:e.unwatched,this.name=null==e?void 0:e.name}function it(t,e){return new nt(t,e)}function ot(t){const e=t.u;if(t.u=void 0,"function"==typeof e){Z++;const n=G;G=void 0;try{e()}catch(e){throw t.f&=-2,t.f|=8,st(t),e}finally{G=n,B()}}}function st(t){for(let e=t.s;void 0!==e;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,ot(t)}function rt(t){if(G!==this)throw new Error("Out-of-order effect");et(this),G=t,this.f&=-2,8&this.f&&st(this),B()}function ct(t,e){this.x=t,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=null==e?void 0:e.name}function dt(t,e){const n=new ct(t,e);try{n.c()}catch(t){throw n.d(),t}const i=n.d.bind(n);return i[Symbol.dispose]=i,i}function at(t,e={}){const n={};for(const i in t){const o=e[i],s=X(void 0===o?t[i]:o);n[i]=s}return n}Q.prototype.brand=T,Q.prototype.h=function(){return!0},Q.prototype.S=function(t){const e=this.t;e!==t&&void 0===t.e&&(t.x=e,this.t=t,void 0!==e?e.e=t:W((()=>{var t;null==(t=this.W)||t.call(this)})))},Q.prototype.U=function(t){if(void 0!==this.t){const e=t.e,n=t.x;void 0!==e&&(e.x=n,t.e=void 0),void 0!==n&&(n.e=e,t.x=void 0),t===this.t&&(this.t=n,void 0===n&&W((()=>{var t;null==(t=this.Z)||t.call(this)})))}},Q.prototype.subscribe=function(t){return dt((()=>{const e=this.value,n=G;G=void 0;try{t(e)}finally{G=n}}),{name:"sub"})},Q.prototype.valueOf=function(){return this.value},Q.prototype.toString=function(){return this.value+""},Q.prototype.toJSON=function(){return this.value},Q.prototype.peek=function(){const t=G;G=void 0;try{return this.value}finally{G=t}},Object.defineProperty(Q.prototype,"value",{get(){const t=q(this);return void 0!==t&&(t.i=this.i),this.v},set(t){if(t!==this.v){if(J>100)throw new Error("Cycle detected");this.v=t,this.i++,H++,Z++;try{for(let t=this.t;void 0!==t;t=t.x)t.t.N()}finally{B()}}}}),nt.prototype=new Q,nt.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if(32==(36&this.f))return!0;if(this.f&=-5,this.g===H)return!0;if(this.g=H,this.f|=1,this.i>0&&!Y(this))return this.f&=-2,!0;const t=G;try{tt(this),G=this;const t=this.x();(16&this.f||this.v!==t||0===this.i)&&(this.v=t,this.f&=-17,this.i++)}catch(t){this.v=t,this.f|=16,this.i++}return G=t,et(this),this.f&=-2,!0},nt.prototype.S=function(t){if(void 0===this.t){this.f|=36;for(let t=this.s;void 0!==t;t=t.n)t.S.S(t)}Q.prototype.S.call(this,t)},nt.prototype.U=function(t){if(void 0!==this.t&&(Q.prototype.U.call(this,t),void 0===this.t)){this.f&=-33;for(let t=this.s;void 0!==t;t=t.n)t.S.U(t)}},nt.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(let t=this.t;void 0!==t;t=t.x)t.t.N()}},Object.defineProperty(nt.prototype,"value",{get(){if(1&this.f)throw new Error("Cycle detected");const t=q(this);if(this.h(),void 0!==t&&(t.i=this.i),16&this.f)throw this.v;return this.v}}),ct.prototype.c=function(){const t=this.S();try{if(8&this.f)return;if(void 0===this.x)return;const t=this.x();"function"==typeof t&&(this.u=t)}finally{t()}},ct.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,ot(this),tt(this),Z++;const t=G;return G=this,rt.bind(this,t)},ct.prototype.N=function(){2&this.f||(this.f|=2,this.o=V,V=this)},ct.prototype.d=function(){this.f|=8,1&this.f||st(this)},ct.prototype.dispose=function(){this.d()};const ut=t({build:(t,e,n)=>at(e),config:e({defaultSelection:"rootEnd",disabled:!1}),name:"@lexical/extension/AutoFocus",register(t,e,n){const i=n.getOutput();return dt((()=>i.disabled.value?void 0:t.registerRootListener((e=>{t.focus((()=>{const t=document.activeElement;null===e||null!==t&&e.contains(t)||e.focus({preventScroll:!0})}),{defaultSelection:i.defaultSelection.peek()})}))))}});function ft(){const t=o(),e=s(),n=r();t.clear(),t.append(n),null!==e&&n.select(),c(e)&&(e.format=0)}function ht(t,e=ft){return t.registerCommand(n,(n=>(t.update(e),!0)),i)}const lt=t({build:(t,e,n)=>at(e),config:e({$onClear:ft}),name:"@lexical/extension/ClearEditor",register(t,e,n){const{$onClear:i}=n.getOutput();return dt((()=>ht(t,i.value)))}});function gt(t){const e=new Set,n=new Set;for(const i of t.nodes??[]){const t="function"==typeof i?i:i.replace;e.add(t.getType()),n.add(t)}return{nodes:n,types:e}}function pt(t,e){let n;return X(t(),{unwatched(){n&&(n(),n=void 0)},watched(){this.value=t(),n=e(this)}})}const mt=t({build:t=>pt((()=>t.getEditorState()),(e=>t.registerUpdateListener((t=>{e.value=t.editorState})))),name:"@lexical/extension/EditorState"});function vt(t,...e){const n=new URL("https://lexical.dev/docs/error"),i=new URLSearchParams;i.append("code",t);for(const t of e)i.append("v",t);throw n.search=i.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function yt(t,e){if(t&&e&&!Array.isArray(e)&&"object"==typeof t&&"object"==typeof e){const n=t,i=e;for(const t in i)n[t]=yt(n[t],i[t]);return t}return e}const xt={unmarked:0,temporary:1,permanent:2,configured:3,initialized:4,built:5,registered:6,afterRegistration:7};function St(t){return t.id===xt.unmarked}function Et(t){return t.id===xt.permanent}function bt(t){return function(t){return t.id===xt.temporary}(t)||vt(305,String(t.id),String(xt.temporary)),Object.assign(t,{id:xt.permanent})}const wt=new Set;class Nt{builder;configs;_dependency;_peerNameSet;extension;state;_signal;constructor(t,e){this.builder=t,this.extension=e,this.configs=new Set,this.state={id:xt.unmarked}}mergeConfigs(){let t=this.extension.config||{};const e=this.extension.mergeConfig?this.extension.mergeConfig.bind(this.extension):d;for(const n of this.configs)t=e(t,n);return t}init(t){const e=this.state;Et(e)||vt(306,String(e.id));const n={getDependency:this.getInitDependency.bind(this),getDirectDependentNames:this.getDirectDependentNames.bind(this),getPeer:this.getInitPeer.bind(this),getPeerNameSet:this.getPeerNameSet.bind(this)},i={...n,getDependency:this.getDependency.bind(this),getInitResult:this.getInitResult.bind(this),getPeer:this.getPeer.bind(this)},o=function(t,e,n){return Object.assign(t,{config:e,id:xt.configured,registerState:n})}(e,this.mergeConfigs(),n);let s;this.state=o,this.extension.init&&(s=this.extension.init(t,o.config,n)),this.state=function(t,e,n){return Object.assign(t,{id:xt.initialized,initResult:e,registerState:n})}(o,s,i)}build(t){const e=this.state;let n;e.id!==xt.initialized&&vt(307,String(e.id),String(xt.built)),this.extension.build&&(n=this.extension.build(t,e.config,e.registerState));const i={...e.registerState,getOutput:()=>n,getSignal:this.getSignal.bind(this)};this.state=function(t,e,n){return Object.assign(t,{id:xt.built,output:e,registerState:n})}(e,n,i)}register(t,e){this._signal=e;const n=this.state;n.id!==xt.built&&vt(308,String(n.id),String(xt.built));const i=this.extension.register&&this.extension.register(t,n.config,n.registerState);return this.state=function(t){return Object.assign(t,{id:xt.registered})}(n),()=>{const t=this.state;t.id!==xt.afterRegistration&&vt(309,String(n.id),String(xt.afterRegistration)),this.state=function(t){return Object.assign(t,{id:xt.built})}(t),i&&i()}}afterRegistration(t){const e=this.state;let n;return e.id!==xt.registered&&vt(310,String(e.id),String(xt.registered)),this.extension.afterRegistration&&(n=this.extension.afterRegistration(t,e.config,e.registerState)),this.state=function(t){return Object.assign(t,{id:xt.afterRegistration})}(e),n}getSignal(){return void 0===this._signal&&vt(311),this._signal}getInitResult(){void 0===this.extension.init&&vt(312,this.extension.name);const t=this.state;return function(t){return t.id>=xt.initialized}(t)||vt(313,String(t.id),String(xt.initialized)),t.initResult}getInitPeer(t){const e=this.builder.extensionNameMap.get(t);return e?e.getExtensionInitDependency():void 0}getExtensionInitDependency(){const t=this.state;return function(t){return t.id>=xt.configured}(t)||vt(314,String(t.id),String(xt.configured)),{config:t.config}}getPeer(t){const e=this.builder.extensionNameMap.get(t);return e?e.getExtensionDependency():void 0}getInitDependency(t){const e=this.builder.getExtensionRep(t);return void 0===e&&vt(315,this.extension.name,t.name),e.getExtensionInitDependency()}getDependency(t){const e=this.builder.getExtensionRep(t);return void 0===e&&vt(315,this.extension.name,t.name),e.getExtensionDependency()}getState(){const t=this.state;return function(t){return t.id>=xt.afterRegistration}(t)||vt(316,String(t.id),String(xt.afterRegistration)),t}getDirectDependentNames(){return this.builder.incomingEdges.get(this.extension.name)||wt}getPeerNameSet(){let t=this._peerNameSet;return t||(t=new Set((this.extension.peerDependencies||[]).map((([t])=>t))),this._peerNameSet=t),t}getExtensionDependency(){if(!this._dependency){const t=this.state;(function(t){return t.id>=xt.built})(t)||vt(317,this.extension.name),this._dependency={config:t.config,init:t.initResult,output:t.output}}return this._dependency}}const Rt={tag:p};function Ot(){const t=o();t.isEmpty()&&t.append(r())}const Mt=t({config:e({setOptions:Rt,updateOptions:Rt}),init:({$initialEditorState:t=Ot})=>({$initialEditorState:t,initialized:!1}),afterRegistration(t,{updateOptions:e,setOptions:n},i){const o=i.getInitResult();if(!o.initialized){o.initialized=!0;const{$initialEditorState:i}=o;if(g(i))t.setEditorState(i,n);else if("function"==typeof i)t.update((()=>{i(t)}),e);else if(i&&("string"==typeof i||"object"==typeof i)){const e=t.parseEditorState(i);t.setEditorState(e,n)}}return()=>{}},name:"@lexical/extension/InitialState",nodes:[a,u,f,h,l]}),Ct=Symbol.for("@lexical/extension/LexicalBuilder");function Dt(...t){return kt.fromExtensions(t).buildEditor()}function _t(){}function It(t){throw t}function jt(t){return Array.isArray(t)?t:[t]}const At="0.35.1-nightly.20250925.0+prod.esm";class kt{roots;extensionNameMap;outgoingConfigEdges;incomingEdges;conflicts;_sortedExtensionReps;PACKAGE_VERSION;constructor(t){this.outgoingConfigEdges=new Map,this.incomingEdges=new Map,this.extensionNameMap=new Map,this.conflicts=new Map,this.PACKAGE_VERSION=At,this.roots=t;for(const e of t)this.addExtension(e)}static fromExtensions(t){const e=[jt(Mt)];for(const n of t)e.push(jt(n));return new kt(e)}static maybeFromEditor(t){const e=t[Ct];return e&&(e.PACKAGE_VERSION!==At&&vt(293,e.PACKAGE_VERSION,At),e instanceof kt||vt(294)),e}static fromEditor(t){const e=kt.maybeFromEditor(t);return void 0===e&&vt(295),e}constructEditor(){const{$initialEditorState:t,onError:e,...n}=this.buildCreateEditorArgs(),i=Object.assign(m({...n,...e?{onError:t=>{e(t,i)}}:{}}),{[Ct]:this});for(const t of this.sortedExtensionReps())t.build(i);return i}buildEditor(){let t=_t;function e(){try{t()}finally{t=_t}}const n=Object.assign(this.constructEditor(),{dispose:e,[Symbol.dispose]:e});return t=z(this.registerEditor(n),(()=>n.setRootElement(null))),n}hasExtensionByName(t){return this.extensionNameMap.has(t)}getExtensionRep(t){const e=this.extensionNameMap.get(t.name);if(e)return e.extension!==t&&vt(296,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(297);const e=jt(t),[n]=e;"string"!=typeof n.name&&vt(298,typeof n.name);let i=this.extensionNameMap.get(n.name);if(void 0!==i&&i.extension!==n&&vt(299,n.name),!i){i=new Nt(this,n),this.extensionNameMap.set(n.name,i);const t=this.conflicts.get(n.name);"string"==typeof t&&vt(300,n.name,t);for(const t of n.conflictsWith||[])this.extensionNameMap.has(t)&&vt(300,n.name,t),this.conflicts.set(t,n.name);for(const t of n.dependencies||[]){const e=jt(t);this.addEdge(n.name,e[0].name,e.slice(1)),this.addExtension(e)}for(const[t,e]of n.peerDependencies||[])this.addEdge(n.name,t,e?[e]:[])}}sortedExtensionReps(){if(this._sortedExtensionReps)return this._sortedExtensionReps;const t=[],e=(n,i)=>{let o=n.state;if(Et(o))return;const s=n.extension.name;var r;St(o)||vt(301,s,i||"[unknown]"),St(r=o)||vt(304,String(r.id),String(xt.unmarked)),o=Object.assign(r,{id:xt.temporary}),n.state=o;const c=this.outgoingConfigEdges.get(s);if(c)for(const t of c.keys()){const n=this.extensionNameMap.get(t);n&&e(n,s)}o=bt(o),n.state=o,t.push(n)};for(const t of this.extensionNameMap.values())St(t.state)&&e(t);for(const e of t)for(const[t,n]of this.outgoingConfigEdges.get(e.extension.name)||[])if(n.length>0){const e=this.extensionNameMap.get(t);if(e)for(const t of n)e.configs.add(t)}for(const[t,...e]of this.roots)if(e.length>0){const n=this.extensionNameMap.get(t.name);void 0===n&&vt(302,t.name);for(const t of e)n.configs.add(t)}return this._sortedExtensionReps=t,this._sortedExtensionReps}registerEditor(t){const e=this.sortedExtensionReps(),n=new AbortController,i=[()=>n.abort()],o=n.signal;for(const n of e){const e=n.register(t,o);e&&i.push(e)}for(const n of e){const e=n.afterRegistration(t);e&&i.push(e)}return z(...i)}buildCreateEditorArgs(){const t={},e=new Set,n=new Map,i=new Map,o={},s={},r=this.sortedExtensionReps();for(const c of r){const{extension:r}=c;if(void 0!==r.onError&&(t.onError=r.onError),void 0!==r.disableEvents&&(t.disableEvents=r.disableEvents),void 0!==r.parentEditor&&(t.parentEditor=r.parentEditor),void 0!==r.editable&&(t.editable=r.editable),void 0!==r.namespace&&(t.namespace=r.namespace),void 0!==r.$initialEditorState&&(t.$initialEditorState=r.$initialEditorState),r.nodes)for(const t of r.nodes){if("function"!=typeof t){const e=n.get(t.replace);e&&vt(303,r.name,t.replace.name,e.extension.name),n.set(t.replace,c)}e.add(t)}if(r.html){if(r.html.export)for(const[t,e]of r.html.export.entries())i.set(t,e);r.html.import&&Object.assign(o,r.html.import)}r.theme&&yt(s,r.theme)}Object.keys(s).length>0&&(t.theme=s),e.size&&(t.nodes=[...e]);const c=Object.keys(o).length>0,d=i.size>0;(c||d)&&(t.html={},c&&(t.html.import=o),d&&(t.html.export=i));for(const e of r)e.init(t);return t.onError||(t.onError=It),t}}function Pt(t,e){const n=kt.fromEditor(t).getExtensionRep(e);return void 0===n&&vt(291,e.name),n.getExtensionDependency()}function zt(t,e){const n=kt.fromEditor(t).extensionNameMap.get(e);return n?n.getExtensionDependency():void 0}function Kt(t,e){const n=zt(t,e);return void 0===n&&vt(292,e),n}const $t=new Set,Ut=t({build(t,e,n){const i=n.getDependency(mt).output,o=X({watchedNodeKeys:new Map}),r=pt((()=>{}),(()=>dt((()=>{const t=r.peek(),{watchedNodeKeys:e}=o.value;let n,c=!1;i.value.read((()=>{if(s())for(const[i,o]of e.entries()){if(0===o.size){e.delete(i);continue}const s=v(i),r=s&&s.isSelected()||!1;c=c||r!==(!!t&&t.has(i)),r&&(n=n||new Set,n.add(i))}})),!c&&n&&t&&n.size===t.size||(r.value=n)}))));return{watchNodeKey:function(t){const e=it((()=>(r.value||$t).has(t))),{watchedNodeKeys:n}=o.peek();let i=n.get(t);const s=void 0!==i;return i=i||new Set,i.add(e),s||(n.set(t,i),o.value={watchedNodeKeys:n}),e}}},dependencies:[mt],name:"@lexical/extension/NodeSelection"}),Lt=y("INSERT_HORIZONTAL_RULE_COMMAND");class Tt extends N{static getType(){return"horizontalrule"}static clone(t){return new Tt(t.__key)}static importJSON(t){return Ft().updateFromJSON(t)}static importDOM(){return{hr:()=>({conversion:Bt,priority:0})}}exportDOM(){return{element:document.createElement("hr")}}createDOM(t){const e=document.createElement("hr");return K(e,t.theme.hr),e}getTextContent(){return"\n"}isInline(){return!1}updateDOM(){return!1}}function Bt(){return{node:Ft()}}function Ft(){return x(Tt)}function Gt(t){return t instanceof Tt}const Vt=t({dependencies:[mt,Ut],name:"@lexical/extension/HorizontalRule",nodes:[Tt],register(t,e,n){const{watchNodeKey:i}=n.getDependency(Ut).output,o=X({nodeSelections:new Map}),r=t._config.theme.hrSelected??"selected";return z(t.registerCommand(S,(t=>{if(E(t.target)){const e=b(t.target);if(Gt(e))return function(t,e=!1){const n=s(),i=t.isSelected(),o=t.getKey();let r;e&&R(n)?r=n:(r=O(),M(r)),i?r.delete(o):r.add(o)}(e,t.shiftKey),!0}return!1}),w),t.registerMutationListener(Tt,((e,n)=>{F((()=>{let n=!1;const{nodeSelections:s}=o.peek();for(const[o,r]of e.entries())if("destroyed"===r)s.delete(o),n=!0;else{const e=s.get(o),r=t.getElementByKey(o);e?e.domNode.value=r:(n=!0,s.set(o,{domNode:X(r),selectedSignal:i(o)}))}n&&(o.value={nodeSelections:s})}))})),dt((()=>{const t=[];for(const{domNode:e,selectedSignal:n}of o.value.nodeSelections.values())t.push(dt((()=>{const t=e.value;if(t){n.value?K(t,r):$(t,r)}})));return z(...t)})))}});function Wt(t,e){return z(t.registerCommand(C,(e=>{const n=s();if(!c(n))return!1;e.preventDefault();const i=function(t){const e=t.getNodes();if(L(e,(t=>A(t)&&t.canIndent()?t:null)).length>0)return!0;const n=t.anchor,i=t.focus,o=i.isBefore(n)?i:n,s=o.getNode(),r=U(s);if(r.canIndent()){const t=r.getKey();let e=k();if(e.anchor.set(t,0,"element"),e.focus.set(t,0,"element"),e=P(e),e.anchor.is(o))return!0}return!1}(n)?e.shiftKey?D:_:I;return t.dispatchCommand(i,void 0)}),i),t.registerCommand(_,(()=>{const t="number"==typeof e?e:e?e.peek():null;if(null==t)return!1;const n=s();if(!c(n))return!1;const i=n.getNodes().map((t=>U(t).getIndent()));return Math.max(...i)+1>=t}),j))}const Zt=t({build:(t,e,n)=>at(e),config:e({disabled:!1,maxIndent:null}),name:"@lexical/extension/TabIndentation",register(t,e,n){const{disabled:i,maxIndent:o}=n.getOutput();return dt((()=>{if(!i.value)return Wt(t,o)}))}});export{Ft as $createHorizontalRuleNode,Gt as $isHorizontalRuleNode,ut as AutoFocusExtension,lt as ClearEditorExtension,mt as EditorStateExtension,Vt as HorizontalRuleExtension,Tt as HorizontalRuleNode,Lt as INSERT_HORIZONTAL_RULE_COMMAND,Mt as InitialStateExtension,kt as LexicalBuilder,Ut as NodeSelectionExtension,Zt as TabIndentationExtension,F as batch,Dt as buildEditorFromExtensions,it as computed,dt as effect,Pt as getExtensionDependencyFromEditor,gt as getKnownTypesAndNodes,zt as getPeerDependencyFromEditor,Kt as getPeerDependencyFromEditorOrThrow,at as namedSignals,ht as registerClearEditor,Wt as registerTabIndentation,X as signal,W as untracked,pt as watchedSignal};
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ import { type NodeKey } from 'lexical';
9
+ import { ReadonlySignal } from './signals';
10
+ /**
11
+ * An extension that provides a `watchNodeKey` output that
12
+ * returns a signal for the selection state of a node.
13
+ *
14
+ * Typically used for tracking whether a DecoratorNode is
15
+ * currently selected or not. A framework independent
16
+ * alternative to {@link useLexicalNodeSelection}.
17
+ */
18
+ export declare const NodeSelectionExtension: import("lexical").LexicalExtension<import("lexical").ExtensionConfigBase, "@lexical/extension/NodeSelection", {
19
+ watchNodeKey: (key: NodeKey) => ReadonlySignal<boolean>;
20
+ }, unknown>;
package/README.md ADDED
@@ -0,0 +1,5 @@
1
+ # `@lexical/extension`
2
+
3
+ [![See API Documentation](https://lexical.dev/img/see-api-documentation.svg)](https://lexical.dev/docs/api/modules/lexical_extension)
4
+
5
+ This package provides the extension functionality for Lexical.
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ import type { LexicalEditor } from 'lexical';
9
+ import { type ReadonlySignal } from './signals';
10
+ export declare function registerTabIndentation(editor: LexicalEditor, maxIndent?: number | ReadonlySignal<null | number>): () => void;
11
+ export interface TabIndentationConfig {
12
+ disabled: boolean;
13
+ maxIndent: null | number;
14
+ }
15
+ /**
16
+ * This extension adds the ability to indent content using the tab key. Generally, we don't
17
+ * recommend using this plugin as it could negatively affect accessibility for keyboard
18
+ * users, causing focus to become trapped within the editor.
19
+ */
20
+ export declare const TabIndentationExtension: import("lexical").LexicalExtension<TabIndentationConfig, "@lexical/extension/TabIndentation", import("./namedSignals").NamedSignalsOutput<TabIndentationConfig>, unknown>;
package/config.d.ts ADDED
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ import type { InitialEditorConfig, KlassConstructor, LexicalNode } from 'lexical';
9
+ export interface KnownTypesAndNodes {
10
+ types: Set<string>;
11
+ nodes: Set<KlassConstructor<typeof LexicalNode>>;
12
+ }
13
+ /**
14
+ * @experimental
15
+ * Get the sets of nodes and types registered in the
16
+ * {@link InitialEditorConfig}. This is to be used when an extension
17
+ * needs to register optional behavior if some node or type is present.
18
+ *
19
+ * @param config The InitialEditorConfig (accessible from an extension's init)
20
+ * @returns The known types and nodes as Sets
21
+ */
22
+ export declare function getKnownTypesAndNodes(config: InitialEditorConfig): {
23
+ nodes: Set<KlassConstructor<typeof LexicalNode>>;
24
+ types: Set<string>;
25
+ };
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ /**
9
+ * Recursively merge the given theme configuration in-place.
10
+ *
11
+ * @returns If `a` and `b` are both objects (and `b` is not an Array) then
12
+ * all keys in `b` are merged into `a` then `a` is returned.
13
+ * Otherwise `b` is returned.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * const a = { a: "a", nested: { a: 1 } };
18
+ * const b = { b: "b", nested: { b: 2 } };
19
+ * const rval = deepThemeMergeInPlace(a, b);
20
+ * expect(a).toBe(rval);
21
+ * expect(a).toEqual({ a: "a", b: "b", nested: { a: 1, b: 2 } });
22
+ * ```
23
+ */
24
+ export declare function deepThemeMergeInPlace(a: unknown, b: unknown): unknown;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ import type { AnyLexicalExtension, LexicalEditor, LexicalExtensionDependency } from 'lexical';
9
+ /**
10
+ * @experimental
11
+ * Get the finalized config and output of an Extension that was used to build the editor.
12
+ *
13
+ * This is useful in the implementation of a LexicalNode or in other
14
+ * situations where you have an editor reference but it's not easy to
15
+ * pass the config or {@link ExtensionRegisterState} around.
16
+ *
17
+ * It will throw if the Editor was not built using this Extension.
18
+ *
19
+ * @param editor - The editor that was built using extension
20
+ * @param extension - The concrete reference to an Extension used to build this editor
21
+ * @returns The config and output for that Extension
22
+ */
23
+ export declare function getExtensionDependencyFromEditor<Extension extends AnyLexicalExtension>(editor: LexicalEditor, extension: Extension): LexicalExtensionDependency<Extension>;
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ import type { AnyLexicalExtension, LexicalEditor, LexicalExtensionDependency } from 'lexical';
9
+ /**
10
+ * @experimental
11
+ * Get the finalized config and output of an Extension that was used to build the
12
+ * editor by name.
13
+ *
14
+ * This can be used from the implementation of a LexicalNode or in other
15
+ * situation where you have an editor reference but it's not easy to pass the
16
+ * config around. Use this version if you do not have a concrete reference to
17
+ * the Extension for some reason (e.g. it is an optional peer dependency, or you
18
+ * are avoiding a circular import).
19
+ *
20
+ * Both the explicit Extension type and the name are required.
21
+ *
22
+ * @example
23
+ * ```tsx
24
+ * import type { HistoryExtension } from "@lexical/history";
25
+ * getPeerDependencyFromEditor<typeof HistoryExtension>(editor, "@lexical/history/History");
26
+ * ```
27
+
28
+ * @param editor - The editor that may have been built using extension
29
+ * @param extensionName - The name of the Extension
30
+ * @returns The config and output of the Extension or undefined
31
+ */
32
+ export declare function getPeerDependencyFromEditor<Extension extends AnyLexicalExtension = never>(editor: LexicalEditor, extensionName: Extension['name']): LexicalExtensionDependency<Extension> | undefined;
33
+ /**
34
+ * Get the finalized config and output of an Extension that was used to build the
35
+ * editor by name.
36
+ *
37
+ * This can be used from the implementation of a LexicalNode or in other
38
+ * situation where you have an editor reference but it's not easy to pass the
39
+ * config around. Use this version if you do not have a concrete reference to
40
+ * the Extension for some reason (e.g. it is an optional peer dependency, or you
41
+ * are avoiding a circular import).
42
+ *
43
+ * Both the explicit Extension type and the name are required.
44
+ *
45
+ * @example
46
+ * ```tsx
47
+ * import type { EmojiExtension } from "./EmojiExtension";
48
+ * export class EmojiNode extends TextNode {
49
+ * // other implementation details not included
50
+ * createDOM(
51
+ * config: EditorConfig,
52
+ * editor?: LexicalEditor | undefined
53
+ * ): HTMLElement {
54
+ * const dom = super.createDOM(config, editor);
55
+ * addClassNamesToElement(
56
+ * dom,
57
+ * getPeerDependencyFromEditorOrThrow<typeof EmojiExtension>(
58
+ * editor || $getEditor(),
59
+ * "@lexical/playground/emoji",
60
+ * ).config.emojiClass,
61
+ * );
62
+ * return dom;
63
+ * }
64
+ * }
65
+ * ```
66
+
67
+ * @param editor - The editor that may have been built using extension
68
+ * @param extensionName - The name of the Extension
69
+ * @returns The config and output of the Extension
70
+ */
71
+ export declare function getPeerDependencyFromEditorOrThrow<Extension extends AnyLexicalExtension = never>(editor: LexicalEditor, extensionName: Extension['name']): LexicalExtensionDependency<Extension>;
package/index.d.ts ADDED
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ export { type AutoFocusConfig, AutoFocusExtension } from './AutoFocusExtension';
9
+ export { type ClearEditorConfig, ClearEditorExtension, registerClearEditor, } from './ClearEditorExtension';
10
+ export { getKnownTypesAndNodes, type KnownTypesAndNodes } from './config';
11
+ export { EditorStateExtension } from './EditorStateExtension';
12
+ export { getExtensionDependencyFromEditor } from './getExtensionDependencyFromEditor';
13
+ export { getPeerDependencyFromEditor, getPeerDependencyFromEditorOrThrow, } from './getPeerDependencyFromEditor';
14
+ export { $createHorizontalRuleNode, $isHorizontalRuleNode, HorizontalRuleExtension, HorizontalRuleNode, INSERT_HORIZONTAL_RULE_COMMAND, type SerializedHorizontalRuleNode, } from './HorizontalRuleExtension';
15
+ export { type InitialStateConfig, InitialStateExtension, } from './InitialStateExtension';
16
+ export { buildEditorFromExtensions, LexicalBuilder } from './LexicalBuilder';
17
+ export { namedSignals, type NamedSignalsOptions, type NamedSignalsOutput, } from './namedSignals';
18
+ export { NodeSelectionExtension } from './NodeSelectionExtension';
19
+ export { batch, computed, effect, type ReadonlySignal, type Signal, signal, type SignalOptions, untracked, } from './signals';
20
+ export { registerTabIndentation, type TabIndentationConfig, TabIndentationExtension, } from './TabIndentationExtension';
21
+ export { watchedSignal } from './watchedSignal';
22
+ export { type AnyLexicalExtension, type AnyLexicalExtensionArgument, configExtension, declarePeerDependency, defineExtension, type ExtensionConfigBase, type ExtensionRegisterState, type InitialEditorStateType, type LexicalEditorWithDispose, type LexicalExtension, type LexicalExtensionArgument, type LexicalExtensionConfig, type LexicalExtensionDependency, type LexicalExtensionInit, type LexicalExtensionName, type LexicalExtensionOutput, type NormalizedLexicalExtensionArgument, type NormalizedPeerDependency, type OutputComponentExtension, safeCast, shallowMergeConfig, } from 'lexical';