@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.
- package/AutoFocusExtension.d.ts +24 -0
- package/ClearEditorExtension.d.ts +16 -0
- package/EditorStateExtension.d.ts +4 -0
- package/ExtensionRep.d.ts +91 -0
- package/HorizontalRuleExtension.d.ts +29 -0
- package/InitialStateExtension.d.ts +25 -0
- package/LICENSE +21 -0
- package/LexicalBuilder.d.ts +76 -0
- package/LexicalExtension.dev.js +1445 -0
- package/LexicalExtension.dev.mjs +1414 -0
- package/LexicalExtension.js +11 -0
- package/LexicalExtension.js.flow +202 -0
- package/LexicalExtension.mjs +42 -0
- package/LexicalExtension.node.mjs +40 -0
- package/LexicalExtension.prod.js +9 -0
- package/LexicalExtension.prod.mjs +9 -0
- package/NodeSelectionExtension.d.ts +20 -0
- package/README.md +5 -0
- package/TabIndentationExtension.d.ts +20 -0
- package/config.d.ts +25 -0
- package/deepThemeMergeInPlace.d.ts +24 -0
- package/getExtensionDependencyFromEditor.d.ts +23 -0
- package/getPeerDependencyFromEditor.d.ts +71 -0
- package/index.d.ts +22 -0
- package/namedSignals.d.ts +28 -0
- package/package.json +47 -0
- package/signals.d.ts +8 -0
- package/watchedSignal.d.ts +18 -0
|
@@ -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
|
+
export type DefaultSelection = 'rootStart' | 'rootEnd';
|
|
9
|
+
export interface AutoFocusConfig {
|
|
10
|
+
/**
|
|
11
|
+
* Where to move the selection when the editor is focused and there is no
|
|
12
|
+
* existing selection. Can be "rootStart" or "rootEnd" (the default).
|
|
13
|
+
*/
|
|
14
|
+
defaultSelection: DefaultSelection;
|
|
15
|
+
/**
|
|
16
|
+
* The initial state of disabled
|
|
17
|
+
*/
|
|
18
|
+
disabled: boolean;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* An Extension to focus the LexicalEditor when the root element is set
|
|
22
|
+
* (typically only when the editor is first created).
|
|
23
|
+
*/
|
|
24
|
+
export declare const AutoFocusExtension: import("lexical").LexicalExtension<AutoFocusConfig, "@lexical/extension/AutoFocus", import("./namedSignals").NamedSignalsOutput<AutoFocusConfig>, unknown>;
|
|
@@ -0,0 +1,16 @@
|
|
|
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 { LexicalEditor } from 'lexical';
|
|
9
|
+
export interface ClearEditorConfig {
|
|
10
|
+
$onClear: () => void;
|
|
11
|
+
}
|
|
12
|
+
export declare function registerClearEditor(editor: LexicalEditor, $onClear?: () => void): () => void;
|
|
13
|
+
/**
|
|
14
|
+
* An extension to provide an implementation of {@link CLEAR_EDITOR_COMMAND}
|
|
15
|
+
*/
|
|
16
|
+
export declare const ClearEditorExtension: import("lexical").LexicalExtension<ClearEditorConfig, "@lexical/extension/ClearEditor", import("./namedSignals").NamedSignalsOutput<ClearEditorConfig>, unknown>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An extension to provide the current EditorState as a signal
|
|
3
|
+
*/
|
|
4
|
+
export declare const EditorStateExtension: import("lexical").LexicalExtension<import("lexical").ExtensionConfigBase, "@lexical/extension/EditorState", import("@preact/signals-core").Signal<import("lexical").EditorState>, unknown>;
|
|
@@ -0,0 +1,91 @@
|
|
|
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 { LexicalBuilder } from './LexicalBuilder';
|
|
9
|
+
import type { AnyLexicalExtension, ExtensionBuildState, ExtensionInitState, ExtensionRegisterState, InitialEditorConfig, LexicalEditor, LexicalExtensionConfig, LexicalExtensionDependency, LexicalExtensionInit, LexicalExtensionOutput } from 'lexical';
|
|
10
|
+
export declare const ExtensionRepStateIds: {
|
|
11
|
+
readonly unmarked: 0;
|
|
12
|
+
readonly temporary: 1;
|
|
13
|
+
readonly permanent: 2;
|
|
14
|
+
readonly configured: 3;
|
|
15
|
+
readonly initialized: 4;
|
|
16
|
+
readonly built: 5;
|
|
17
|
+
readonly registered: 6;
|
|
18
|
+
readonly afterRegistration: 7;
|
|
19
|
+
};
|
|
20
|
+
interface UnmarkedState {
|
|
21
|
+
id: (typeof ExtensionRepStateIds)['unmarked'];
|
|
22
|
+
}
|
|
23
|
+
interface TemporaryState {
|
|
24
|
+
id: (typeof ExtensionRepStateIds)['temporary'];
|
|
25
|
+
}
|
|
26
|
+
interface PermanentState {
|
|
27
|
+
id: (typeof ExtensionRepStateIds)['permanent'];
|
|
28
|
+
}
|
|
29
|
+
interface ConfiguredState<Extension extends AnyLexicalExtension> {
|
|
30
|
+
id: (typeof ExtensionRepStateIds)['configured'];
|
|
31
|
+
config: LexicalExtensionConfig<Extension>;
|
|
32
|
+
registerState: ExtensionInitState;
|
|
33
|
+
}
|
|
34
|
+
interface InitializedState<Extension extends AnyLexicalExtension> extends Omit<ConfiguredState<Extension>, 'id' | 'registerState'> {
|
|
35
|
+
id: (typeof ExtensionRepStateIds)['initialized'];
|
|
36
|
+
initResult: LexicalExtensionInit<Extension>;
|
|
37
|
+
registerState: ExtensionBuildState<LexicalExtensionInit<Extension>>;
|
|
38
|
+
}
|
|
39
|
+
interface BuiltState<Extension extends AnyLexicalExtension> extends Omit<ConfiguredState<Extension>, 'id' | 'registerState'> {
|
|
40
|
+
id: (typeof ExtensionRepStateIds)['built'];
|
|
41
|
+
initResult: LexicalExtensionInit<Extension>;
|
|
42
|
+
output: LexicalExtensionOutput<Extension>;
|
|
43
|
+
registerState: ExtensionRegisterState<LexicalExtensionInit<Extension>, LexicalExtensionOutput<Extension>>;
|
|
44
|
+
}
|
|
45
|
+
interface RegisteredState<Extension extends AnyLexicalExtension> extends Omit<BuiltState<Extension>, 'id'> {
|
|
46
|
+
id: (typeof ExtensionRepStateIds)['registered'];
|
|
47
|
+
}
|
|
48
|
+
interface AfterRegistrationState<Extension extends AnyLexicalExtension> extends Omit<RegisteredState<Extension>, 'id'> {
|
|
49
|
+
id: (typeof ExtensionRepStateIds)['afterRegistration'];
|
|
50
|
+
}
|
|
51
|
+
export type ExtensionRepState<Extension extends AnyLexicalExtension> = UnmarkedState | TemporaryState | PermanentState | ConfiguredState<Extension> | InitializedState<Extension> | BuiltState<Extension> | RegisteredState<Extension> | AfterRegistrationState<Extension>;
|
|
52
|
+
export declare function isExactlyUnmarkedExtensionRepState<Extension extends AnyLexicalExtension>(state: ExtensionRepState<Extension>): state is UnmarkedState;
|
|
53
|
+
export declare function isExactlyPermanentExtensionRepState<Extension extends AnyLexicalExtension>(state: ExtensionRepState<Extension>): state is PermanentState;
|
|
54
|
+
export declare function applyTemporaryMark<Extension extends AnyLexicalExtension>(state: ExtensionRepState<Extension>): TemporaryState;
|
|
55
|
+
export declare function applyPermanentMark<Extension extends AnyLexicalExtension>(state: ExtensionRepState<Extension>): PermanentState;
|
|
56
|
+
export declare function applyConfiguredState<Extension extends AnyLexicalExtension>(state: PermanentState, config: LexicalExtensionConfig<Extension>, registerState: ExtensionInitState): ConfiguredState<Extension>;
|
|
57
|
+
export declare function applyInitializedState<Extension extends AnyLexicalExtension>(state: ConfiguredState<Extension>, initResult: LexicalExtensionInit<Extension>, registerState: ExtensionBuildState<LexicalExtensionInit<Extension>>): InitializedState<Extension>;
|
|
58
|
+
export declare function applyBuiltState<Extension extends AnyLexicalExtension>(state: InitializedState<Extension>, output: LexicalExtensionOutput<Extension>, registerState: ExtensionRegisterState<LexicalExtensionInit<Extension>, LexicalExtensionOutput<Extension>>): BuiltState<Extension>;
|
|
59
|
+
export declare function applyRegisteredState<Extension extends AnyLexicalExtension>(state: BuiltState<Extension>): never;
|
|
60
|
+
export declare function applyAfterRegistrationState<Extension extends AnyLexicalExtension>(state: RegisteredState<Extension>): AfterRegistrationState<Extension>;
|
|
61
|
+
export declare function rollbackToBuiltState<Extension extends AnyLexicalExtension>(state: AfterRegistrationState<Extension>): BuiltState<Extension>;
|
|
62
|
+
/**
|
|
63
|
+
* @internal
|
|
64
|
+
*/
|
|
65
|
+
export declare class ExtensionRep<Extension extends AnyLexicalExtension> {
|
|
66
|
+
builder: LexicalBuilder;
|
|
67
|
+
configs: Set<Partial<LexicalExtensionConfig<Extension>>>;
|
|
68
|
+
_dependency?: LexicalExtensionDependency<Extension>;
|
|
69
|
+
_peerNameSet?: Set<string>;
|
|
70
|
+
extension: Extension;
|
|
71
|
+
state: ExtensionRepState<Extension>;
|
|
72
|
+
_signal?: AbortSignal;
|
|
73
|
+
constructor(builder: LexicalBuilder, extension: Extension);
|
|
74
|
+
mergeConfigs(): LexicalExtensionConfig<Extension>;
|
|
75
|
+
init(editorConfig: InitialEditorConfig): void;
|
|
76
|
+
build(editor: LexicalEditor): void;
|
|
77
|
+
register(editor: LexicalEditor, signal: AbortSignal): undefined | (() => void);
|
|
78
|
+
afterRegistration(editor: LexicalEditor): undefined | (() => void);
|
|
79
|
+
getSignal(): AbortSignal;
|
|
80
|
+
getInitResult(): LexicalExtensionInit<Extension>;
|
|
81
|
+
getInitPeer<PeerExtension extends AnyLexicalExtension = never>(name: PeerExtension['name']): undefined | Omit<LexicalExtensionDependency<PeerExtension>, 'output' | 'init'>;
|
|
82
|
+
getExtensionInitDependency(): Omit<LexicalExtensionDependency<Extension>, 'output' | 'init'>;
|
|
83
|
+
getPeer<PeerExtension extends AnyLexicalExtension = never>(name: PeerExtension['name']): undefined | LexicalExtensionDependency<PeerExtension>;
|
|
84
|
+
getInitDependency<Dependency extends AnyLexicalExtension>(dep: Dependency): Omit<LexicalExtensionDependency<Dependency>, 'output' | 'init'>;
|
|
85
|
+
getDependency<Dependency extends AnyLexicalExtension>(dep: Dependency): LexicalExtensionDependency<Dependency>;
|
|
86
|
+
getState(): AfterRegistrationState<Extension>;
|
|
87
|
+
getDirectDependentNames(): ReadonlySet<string>;
|
|
88
|
+
getPeerNameSet(): ReadonlySet<string>;
|
|
89
|
+
getExtensionDependency(): LexicalExtensionDependency<Extension>;
|
|
90
|
+
}
|
|
91
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
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 { DOMConversionMap, DOMExportOutput, EditorConfig, LexicalCommand, LexicalNode, SerializedLexicalNode } from 'lexical';
|
|
9
|
+
import { DecoratorNode } from 'lexical';
|
|
10
|
+
export type SerializedHorizontalRuleNode = SerializedLexicalNode;
|
|
11
|
+
export declare const INSERT_HORIZONTAL_RULE_COMMAND: LexicalCommand<void>;
|
|
12
|
+
export declare class HorizontalRuleNode extends DecoratorNode<unknown> {
|
|
13
|
+
static getType(): string;
|
|
14
|
+
static clone(node: HorizontalRuleNode): HorizontalRuleNode;
|
|
15
|
+
static importJSON(serializedNode: SerializedHorizontalRuleNode): HorizontalRuleNode;
|
|
16
|
+
static importDOM(): DOMConversionMap | null;
|
|
17
|
+
exportDOM(): DOMExportOutput;
|
|
18
|
+
createDOM(config: EditorConfig): HTMLElement;
|
|
19
|
+
getTextContent(): string;
|
|
20
|
+
isInline(): false;
|
|
21
|
+
updateDOM(): boolean;
|
|
22
|
+
}
|
|
23
|
+
export declare function $createHorizontalRuleNode(): HorizontalRuleNode;
|
|
24
|
+
export declare function $isHorizontalRuleNode(node: LexicalNode | null | undefined): node is HorizontalRuleNode;
|
|
25
|
+
/**
|
|
26
|
+
* An extension for HorizontalRuleNode that provides an implementation that
|
|
27
|
+
* works without any React dependency.
|
|
28
|
+
*/
|
|
29
|
+
export declare const HorizontalRuleExtension: import("lexical").LexicalExtension<import("lexical").ExtensionConfigBase, "@lexical/extension/HorizontalRule", unknown, unknown>;
|
|
@@ -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 EditorSetOptions, type EditorUpdateOptions } from 'lexical';
|
|
9
|
+
export interface InitialStateConfig {
|
|
10
|
+
updateOptions: EditorUpdateOptions;
|
|
11
|
+
setOptions: EditorSetOptions;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* An extension to set the initial state of the editor from
|
|
15
|
+
* a function or serialized JSON EditorState. This is
|
|
16
|
+
* implicitly included with all editors built with
|
|
17
|
+
* Lexical Extension. This happens in the `afterRegistration`
|
|
18
|
+
* phase so your initial state may depend on registered commands,
|
|
19
|
+
* but you should not call `editor.setRootElement` earlier than
|
|
20
|
+
* this phase to avoid rendering an empty editor first.
|
|
21
|
+
*/
|
|
22
|
+
export declare const InitialStateExtension: import("lexical").LexicalExtension<InitialStateConfig, "@lexical/extension/InitialState", unknown, {
|
|
23
|
+
$initialEditorState: import("lexical").InitialEditorStateType;
|
|
24
|
+
initialized: boolean;
|
|
25
|
+
}>;
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,76 @@
|
|
|
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, type AnyLexicalExtensionArgument, type AnyNormalizedLexicalExtensionArgument, type InitialEditorConfig, type LexicalEditor, type LexicalEditorWithDispose, type LexicalExtensionConfig } from 'lexical';
|
|
9
|
+
import { ExtensionRep } from './ExtensionRep';
|
|
10
|
+
/** @internal Use a well-known symbol for dev tools purposes */
|
|
11
|
+
export declare const builderSymbol: unique symbol;
|
|
12
|
+
/**
|
|
13
|
+
* Build a LexicalEditor by combining together one or more extensions, optionally
|
|
14
|
+
* overriding some of their configuration.
|
|
15
|
+
*
|
|
16
|
+
* @param extensions - Extension arguments (extensions or extensions with config overrides)
|
|
17
|
+
* @returns An editor handle
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* A single root extension with multiple dependencies
|
|
21
|
+
*
|
|
22
|
+
* ```ts
|
|
23
|
+
* const editor = buildEditorFromExtensions(
|
|
24
|
+
* defineExtension({
|
|
25
|
+
* name: "[root]",
|
|
26
|
+
* dependencies: [
|
|
27
|
+
* RichTextExtension,
|
|
28
|
+
* configExtension(EmojiExtension, { emojiBaseUrl: "/assets/emoji" }),
|
|
29
|
+
* ],
|
|
30
|
+
* register: (editor: LexicalEditor) => {
|
|
31
|
+
* console.log("Editor Created");
|
|
32
|
+
* return () => console.log("Editor Disposed");
|
|
33
|
+
* },
|
|
34
|
+
* }),
|
|
35
|
+
* );
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* A very similar minimal configuration without the register hook
|
|
40
|
+
*
|
|
41
|
+
* ```ts
|
|
42
|
+
* const editor = buildEditorFromExtensions(
|
|
43
|
+
* RichTextExtension,
|
|
44
|
+
* configExtension(EmojiExtension, { emojiBaseUrl: "/assets/emoji" }),
|
|
45
|
+
* );
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export declare function buildEditorFromExtensions(...extensions: AnyLexicalExtensionArgument[]): LexicalEditorWithDispose;
|
|
49
|
+
interface WithBuilder {
|
|
50
|
+
[builderSymbol]?: LexicalBuilder | undefined;
|
|
51
|
+
}
|
|
52
|
+
/** @internal */
|
|
53
|
+
export declare class LexicalBuilder {
|
|
54
|
+
roots: readonly AnyNormalizedLexicalExtensionArgument[];
|
|
55
|
+
extensionNameMap: Map<string, ExtensionRep<AnyLexicalExtension>>;
|
|
56
|
+
outgoingConfigEdges: Map<string, Map<string, LexicalExtensionConfig<AnyLexicalExtension>[]>>;
|
|
57
|
+
incomingEdges: Map<string, Set<string>>;
|
|
58
|
+
conflicts: Map<string, string>;
|
|
59
|
+
_sortedExtensionReps?: readonly ExtensionRep<AnyLexicalExtension>[];
|
|
60
|
+
PACKAGE_VERSION: string;
|
|
61
|
+
constructor(roots: AnyNormalizedLexicalExtensionArgument[]);
|
|
62
|
+
static fromExtensions(extensions: AnyLexicalExtensionArgument[]): LexicalBuilder;
|
|
63
|
+
static maybeFromEditor(editor: LexicalEditor): undefined | LexicalBuilder;
|
|
64
|
+
/** Look up the editor that was created by this LexicalBuilder or throw */
|
|
65
|
+
static fromEditor(editor: LexicalEditor): LexicalBuilder;
|
|
66
|
+
constructEditor(): LexicalEditor & WithBuilder;
|
|
67
|
+
buildEditor(): LexicalEditorWithDispose;
|
|
68
|
+
hasExtensionByName(name: string): boolean;
|
|
69
|
+
getExtensionRep<Extension extends AnyLexicalExtension>(extension: Extension): ExtensionRep<Extension> | undefined;
|
|
70
|
+
addEdge(fromExtensionName: string, toExtensionName: string, configs: LexicalExtensionConfig<AnyLexicalExtension>[]): void;
|
|
71
|
+
addExtension(arg: AnyLexicalExtensionArgument): void;
|
|
72
|
+
sortedExtensionReps(): readonly ExtensionRep<AnyLexicalExtension>[];
|
|
73
|
+
registerEditor(editor: LexicalEditor): () => void;
|
|
74
|
+
buildCreateEditorArgs(): InitialEditorConfig;
|
|
75
|
+
}
|
|
76
|
+
export {};
|