-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Expand file tree
/
Copy pathLexicalExtension.js.flow
More file actions
230 lines (210 loc) · 7.2 KB
/
Copy pathLexicalExtension.js.flow
File metadata and controls
230 lines (210 loc) · 7.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict
*/
/**
* LexicalExtension
*/
import type {
LexicalNode,
NodeKey,
ExtensionConfigBase,
EditorState,
AnyLexicalExtension,
AnyLexicalExtensionArgument,
LexicalEditor,
LexicalEditorWithDispose,
LexicalCommand,
LexicalExtension,
LexicalExtensionDependency,
EditorUpdateOptions,
EditorSetOptions,
InitialEditorConfig,
SerializedLexicalNode,
TextFormatType
} from 'lexical';
import {DecoratorNode} from 'lexical';
export type {
AnyLexicalExtension,
AnyLexicalExtensionArgument,
ExtensionConfigBase,
ExtensionRegisterState,
InitialEditorStateType,
LexicalEditorWithDispose,
LexicalExtension,
LexicalExtensionArgument,
LexicalExtensionConfig,
LexicalExtensionDependency,
LexicalExtensionInit,
LexicalExtensionName,
LexicalExtensionOutput,
NormalizedLexicalExtensionArgument,
NormalizedPeerDependency,
OutputComponentExtension,
} from 'lexical';
export {
configExtension,
declarePeerDependency,
defineExtension,
safeCast,
shallowMergeConfig,
} from 'lexical';
export type NamedSignalsOptions<Defaults> = {
[K in keyof Defaults]?: Defaults[K];
};
export type NamedSignalsOutput<Defaults> = {
[K in keyof Defaults]: Signal<Defaults[K]>;
};
declare export function namedSignals<Defaults>(
defaults: Defaults,
opts?: NamedSignalsOptions<Defaults>
): NamedSignalsOutput<Defaults>;
declare export class Signal<T = unknown> {
constructor(value?: T, options?: SignalOptions<T>): this;
subscribe(fn: (value: T) => void): () => void;
name?: string;
valueOf(): T;
toString(): string;
toJSON(): T;
peek(): T;
brand: symbol;
value: T;
}
export interface ReadonlySignal<T = unknown> {
+value: T;
peek(): T;
subscribe(fn: (value: T) => void): () => void;
valueOf(): T;
toString(): string;
toJSON(): T;
brand: symbol;
}
export type SignalOptions<T = unknown> = {
watched?: (this: Signal<T>) => void;
unwatched?: (this: Signal<T>) => void;
name?: string;
}
type EffectFn = ((this: {
dispose: () => void;
}) => void | (() => void)) | (() => void | (() => void));
type EffectOptions = {
name?: string;
}
declare export function batch<T>(fn: () => T): T;
declare export function computed<T>(fn: () => T, options?: SignalOptions<T>): ReadonlySignal<T>;
declare export function effect(fn: EffectFn, options?: EffectOptions): () => void;
declare export function signal<T>(value: T, options?: SignalOptions<T>): Signal<T>;
declare export function signal<T = void>(): Signal<T | void>;
declare export function untracked<T>(fn: () => T): T;
type DefaultSelection = 'rootStart' | 'rootEnd';
export type AutoFocusConfig = {
defaultSelection: DefaultSelection;
disabled: boolean;
}
declare export var AutoFocusExtension: LexicalExtension<AutoFocusConfig, "@lexical/extension/AutoFocus", NamedSignalsOutput<AutoFocusConfig>, void>;
export type ClearEditorConfig = {
$onClear: () => void;
}
declare export var ClearEditorExtension: LexicalExtension<ClearEditorConfig, "@lexical/extension/ClearEditor", NamedSignalsOutput<ClearEditorConfig>, void>;
declare export var EditorStateExtension: LexicalExtension<ExtensionConfigBase, "@lexical/extension/EditorState", Signal<EditorState>, void>;
declare export function getExtensionDependencyFromEditor<
Extension extends AnyLexicalExtension,
>(
editor: LexicalEditor,
extension: Extension,
): LexicalExtensionDependency<Extension>;
declare export function getPeerDependencyFromEditor<
Extension extends AnyLexicalExtension = empty,
>(
editor: LexicalEditor,
extensionName: Extension['name'],
): LexicalExtensionDependency<Extension> | void;
declare export function getPeerDependencyFromEditorOrThrow<
Extension extends AnyLexicalExtension = empty,
>(
editor: LexicalEditor,
extensionName: Extension['name'],
): LexicalExtensionDependency<Extension>;
export type SerializedHorizontalRuleNode = SerializedLexicalNode;
declare export class HorizontalRuleNode extends DecoratorNode<React.Node> {
static getType(): string;
static clone(node: HorizontalRuleNode): HorizontalRuleNode;
createDOM(): HTMLElement;
getTextContent(): '\n';
updateDOM(): false;
decorate(): React.Node;
}
declare export function $createHorizontalRuleNode(): HorizontalRuleNode;
declare export function $isHorizontalRuleNode(
node: ?LexicalNode,
): node is HorizontalRuleNode;
declare export var INSERT_HORIZONTAL_RULE_COMMAND: LexicalCommand<void>;
declare export var HorizontalRuleExtension: LexicalExtension<ExtensionConfigBase, "@lexical/extension/HorizontalRule", void, void>;
export type InitialStateConfig = {
updateOptions: EditorUpdateOptions;
setOptions: EditorSetOptions;
}
declare export var InitialStateExtension: LexicalExtension<InitialStateConfig, "@lexical/extension/InitialState", void, void>;
declare export function buildEditorFromExtensions(
...extensions: AnyLexicalExtensionArgument[]
): LexicalEditorWithDispose;
declare export class LexicalBuilder {
static fromExtensions(
extensions: AnyLexicalExtensionArgument[],
): LexicalBuilder;
static maybeFromEditor(editor: LexicalEditor): void | LexicalBuilder;
static fromEditor(editor: LexicalEditor): LexicalBuilder;
hasExtensionByName(name: string): boolean;
}
declare export var NodeSelectionExtension: LexicalExtension<ExtensionConfigBase, "@lexical/extension/NodeSelection", {
watchNodeKey: (key: NodeKey) => ReadonlySignal<boolean>;
}, void>;
export type TabIndentationConfig = {
disabled: boolean;
maxIndent: null | number;
}
declare export var TabIndentationExtension: LexicalExtension<TabIndentationConfig, "@lexical/extension/TabIndentation", NamedSignalsOutput<TabIndentationConfig>, void>;
export type TouchIndentationConfig = {
disabled: boolean;
swipeThreshold: number;
}
declare export var TouchIndentationExtension: LexicalExtension<TouchIndentationConfig, "@lexical/extension/TouchIndentation", NamedSignalsOutput<TouchIndentationConfig>, void>;
declare export function watchedSignal<T>(
getSnapshot: () => T,
register: (self: Signal<T>) => () => void,
): Signal<T>;
export type SerializedDecoratorTextNode = {
...SerializedLexicalNode,
format: number,
...
};
declare export class DecoratorTextNode extends DecoratorNode<unknown> {
createDOM(): HTMLElement;
getFormat(): number;
getFormatFlags(type: TextFormatType, alignWithFormat: null | number): number;
hasFormat(type: TextFormatType): boolean;
setFormat(type: number): this;
toggleFormat(type: TextFormatType): this;
isInline(): true;
};
declare export function $isDecoratorTextNode(
node: ?LexicalNode,
): node is DecoratorTextNode;
declare export var DecoratorTextExtension: LexicalExtension<ExtensionConfigBase, "@lexical/extension/DecoratorText", void, void>;
declare export function registerClearEditor(
editor: LexicalEditor,
$onClear?: () => void,
): () => void;
export type KnownTypesAndNodes = {
types: Set<string>;
nodes: Set<Class<LexicalNode>>;
};
declare export function getKnownTypesAndNodes(config: InitialEditorConfig): KnownTypesAndNodes;
declare export function registerTabIndentation(
editor: LexicalEditor,
maxIndent?: number | ReadonlySignal<null | number>,
): () => void;