lexical 0.2.5 → 0.2.8
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/Lexical.d.ts +29 -19
- package/Lexical.dev.js +265 -340
- package/Lexical.js.flow +19 -12
- package/Lexical.prod.js +158 -160
- package/package.json +1 -1
package/Lexical.d.ts
CHANGED
|
@@ -32,6 +32,7 @@ export var KEY_ARROW_LEFT_COMMAND: LexicalCommand<KeyboardEvent>;
|
|
|
32
32
|
export var KEY_ARROW_UP_COMMAND: LexicalCommand<KeyboardEvent>;
|
|
33
33
|
export var KEY_ARROW_DOWN_COMMAND: LexicalCommand<KeyboardEvent>;
|
|
34
34
|
export var KEY_ENTER_COMMAND: LexicalCommand<KeyboardEvent | null>;
|
|
35
|
+
export var KEY_SPACE_COMMAND: LexicalCommand<KeyboardEvent>;
|
|
35
36
|
export var KEY_BACKSPACE_COMMAND: LexicalCommand<KeyboardEvent>;
|
|
36
37
|
export var KEY_ESCAPE_COMMAND: LexicalCommand<KeyboardEvent>;
|
|
37
38
|
export var KEY_DELETE_COMMAND: LexicalCommand<KeyboardEvent>;
|
|
@@ -63,7 +64,7 @@ export declare function createCommand<T>(): LexicalCommand<T>;
|
|
|
63
64
|
*/
|
|
64
65
|
type ErrorHandler = (error: Error) => void;
|
|
65
66
|
type MutationListeners = Map<MutationListener, Class<LexicalNode>>;
|
|
66
|
-
export type NodeMutation = 'created' | 'destroyed';
|
|
67
|
+
export type NodeMutation = 'created' | 'updated' | 'destroyed';
|
|
67
68
|
type UpdateListener = (arg0: {
|
|
68
69
|
tags: Set<string>;
|
|
69
70
|
prevEditorState: EditorState;
|
|
@@ -127,6 +128,7 @@ export declare class LexicalEditor {
|
|
|
127
128
|
_observer: null | MutationObserver;
|
|
128
129
|
_key: string;
|
|
129
130
|
_readOnly: boolean;
|
|
131
|
+
_headless: boolean;
|
|
130
132
|
isComposing(): boolean;
|
|
131
133
|
registerUpdateListener(listener: UpdateListener): () => void;
|
|
132
134
|
registerRootListener(listener: RootListener): () => void;
|
|
@@ -146,15 +148,18 @@ export declare class LexicalEditor {
|
|
|
146
148
|
klass: Class<T>,
|
|
147
149
|
listener: Transform<T>,
|
|
148
150
|
): () => void;
|
|
149
|
-
dispatchCommand<P>(type:
|
|
151
|
+
dispatchCommand<P>(type: LexicalCommand<P>, payload: P): boolean;
|
|
150
152
|
hasNodes(nodes: Array<Class<LexicalNode>>): boolean;
|
|
153
|
+
getKey(): string;
|
|
151
154
|
getDecorators<X>(): Record<NodeKey, X>;
|
|
152
155
|
getRootElement(): null | HTMLElement;
|
|
153
156
|
setRootElement(rootElement: null | HTMLElement): void;
|
|
154
157
|
getElementByKey(key: NodeKey): null | HTMLElement;
|
|
155
158
|
getEditorState(): EditorState;
|
|
156
159
|
setEditorState(editorState: EditorState, options?: EditorSetOptions): void;
|
|
157
|
-
parseEditorState(
|
|
160
|
+
parseEditorState(
|
|
161
|
+
maybeStringifiedEditorState: string | ParsedEditorState,
|
|
162
|
+
): EditorState;
|
|
158
163
|
update(updateFn: () => void, options?: EditorUpdateOptions): boolean;
|
|
159
164
|
focus(callbackFn?: () => void): void;
|
|
160
165
|
blur(): void;
|
|
@@ -178,11 +183,12 @@ type TextNodeThemeClasses = {
|
|
|
178
183
|
underlineStrikethrough?: EditorThemeClassName;
|
|
179
184
|
italic?: EditorThemeClassName;
|
|
180
185
|
code?: EditorThemeClassName;
|
|
186
|
+
subscript?: EditorThemeClassName;
|
|
187
|
+
superscript?: EditorThemeClassName;
|
|
181
188
|
};
|
|
182
189
|
export type EditorThemeClasses = {
|
|
183
190
|
ltr?: EditorThemeClassName;
|
|
184
191
|
rtl?: EditorThemeClassName;
|
|
185
|
-
root?: EditorThemeClassName;
|
|
186
192
|
text?: TextNodeThemeClasses;
|
|
187
193
|
paragraph?: EditorThemeClassName;
|
|
188
194
|
image?: EditorThemeClassName;
|
|
@@ -192,6 +198,8 @@ export type EditorThemeClasses = {
|
|
|
192
198
|
ol?: EditorThemeClassName;
|
|
193
199
|
olDepth?: Array<EditorThemeClassName>;
|
|
194
200
|
listitem?: EditorThemeClassName;
|
|
201
|
+
listitemChecked?: EditorThemeClassName;
|
|
202
|
+
listitemUnchecked?: EditorThemeClassName;
|
|
195
203
|
nested?: {
|
|
196
204
|
list?: EditorThemeClassName;
|
|
197
205
|
listitem?: EditorThemeClassName;
|
|
@@ -201,6 +209,8 @@ export type EditorThemeClasses = {
|
|
|
201
209
|
tableRow?: EditorThemeClassName;
|
|
202
210
|
tableCell?: EditorThemeClassName;
|
|
203
211
|
tableCellHeader?: EditorThemeClassName;
|
|
212
|
+
mark?: EditorThemeClassName;
|
|
213
|
+
markOverlap?: EditorThemeClassName;
|
|
204
214
|
link?: EditorThemeClassName;
|
|
205
215
|
quote?: EditorThemeClassName;
|
|
206
216
|
code?: EditorThemeClassName;
|
|
@@ -240,7 +250,7 @@ export function createEditor(editorConfig?: {
|
|
|
240
250
|
editorState?: EditorState;
|
|
241
251
|
theme?: EditorThemeClasses;
|
|
242
252
|
parentEditor?: LexicalEditor;
|
|
243
|
-
nodes?:
|
|
253
|
+
nodes?: ReadonlyArray<Class<LexicalNode>>;
|
|
244
254
|
onError: (error: Error) => void;
|
|
245
255
|
disableEvents?: boolean;
|
|
246
256
|
readOnly?: boolean;
|
|
@@ -298,8 +308,8 @@ export type DOMConversionFn = (
|
|
|
298
308
|
) => DOMConversionOutput;
|
|
299
309
|
export type DOMChildConversion = (
|
|
300
310
|
lexicalNode: LexicalNode,
|
|
301
|
-
parentLexicalNode: LexicalNode | null,
|
|
302
|
-
) => LexicalNode |
|
|
311
|
+
parentLexicalNode: LexicalNode | null | undefined,
|
|
312
|
+
) => LexicalNode | null;
|
|
303
313
|
export type DOMConversionMap = Record<
|
|
304
314
|
NodeName,
|
|
305
315
|
(node: Node) => DOMConversion | null
|
|
@@ -344,10 +354,7 @@ export declare class LexicalNode {
|
|
|
344
354
|
isParentOf(targetNode: LexicalNode): boolean;
|
|
345
355
|
getNodesBetween(targetNode: LexicalNode): Array<LexicalNode>;
|
|
346
356
|
isDirty(): boolean;
|
|
347
|
-
isComposing(): boolean;
|
|
348
|
-
// $FlowFixMe
|
|
349
357
|
getLatest<T extends LexicalNode>(): T;
|
|
350
|
-
// $FlowFixMe
|
|
351
358
|
getWritable<T extends LexicalNode>(): T;
|
|
352
359
|
getTextContent(includeInert?: boolean, includeDirectionless?: false): string;
|
|
353
360
|
getTextContentSize(
|
|
@@ -558,24 +565,19 @@ export type TextFormatType =
|
|
|
558
565
|
| 'subscript'
|
|
559
566
|
| 'superscript';
|
|
560
567
|
type TextModeType = 'normal' | 'token' | 'segmented' | 'inert';
|
|
561
|
-
export type TextMark = {end: null | number; id: string; start: null | number};
|
|
562
568
|
|
|
563
|
-
export type TextMarks = Array<TextMark>;
|
|
564
569
|
export declare class TextNode extends LexicalNode {
|
|
565
570
|
__text: string;
|
|
566
571
|
__format: number;
|
|
567
572
|
__style: string;
|
|
568
573
|
__mode: 0 | 1 | 2 | 3;
|
|
569
574
|
__detail: number;
|
|
570
|
-
__marks: null | TextMarks;
|
|
571
575
|
static getType(): string;
|
|
572
576
|
static clone(node: any): TextNode;
|
|
573
577
|
constructor(text: string, key?: NodeKey);
|
|
574
|
-
getMark(id: string): null | TextMark;
|
|
575
|
-
setMark(id: string, start: null | number, end: null | number): void;
|
|
576
|
-
deleteMark(id: string): void;
|
|
577
578
|
getFormat(): number;
|
|
578
579
|
getStyle(): string;
|
|
580
|
+
isComposing(): boolean;
|
|
579
581
|
isToken(): boolean;
|
|
580
582
|
isSegmented(): boolean;
|
|
581
583
|
isInert(): boolean;
|
|
@@ -615,10 +617,11 @@ export declare class TextNode extends LexicalNode {
|
|
|
615
617
|
canInsertTextAfter(): boolean;
|
|
616
618
|
splitText(...splitOffsets: Array<number>): Array<TextNode>;
|
|
617
619
|
mergeWithSibling(target: TextNode): TextNode;
|
|
620
|
+
isTextEntity(): boolean;
|
|
618
621
|
}
|
|
619
622
|
export function $createTextNode(text?: string): TextNode;
|
|
620
623
|
export function $isTextNode(
|
|
621
|
-
node: LexicalNode | null | undefined,
|
|
624
|
+
node: TextNode | LexicalNode | null | undefined,
|
|
622
625
|
): node is TextNode;
|
|
623
626
|
|
|
624
627
|
/**
|
|
@@ -699,10 +702,15 @@ export declare class ElementNode extends LexicalNode {
|
|
|
699
702
|
canInsertTab(): boolean;
|
|
700
703
|
canIndent(): boolean;
|
|
701
704
|
collapseAtStart(selection: RangeSelection): boolean;
|
|
702
|
-
excludeFromCopy(): boolean;
|
|
705
|
+
excludeFromCopy(destination: 'clone' | 'html'): boolean;
|
|
703
706
|
canExtractContents(): boolean;
|
|
704
707
|
canReplaceWith(replacement: LexicalNode): boolean;
|
|
705
708
|
canInsertAfter(node: LexicalNode): boolean;
|
|
709
|
+
extractWithChild(
|
|
710
|
+
child: LexicalNode,
|
|
711
|
+
selection: RangeSelection | NodeSelection | GridSelection,
|
|
712
|
+
destination: 'clone' | 'html',
|
|
713
|
+
): boolean;
|
|
706
714
|
canBeEmpty(): boolean;
|
|
707
715
|
canInsertTextBefore(): boolean;
|
|
708
716
|
canInsertTextAfter(): boolean;
|
|
@@ -771,7 +779,9 @@ export function $getNearestNodeFromDOMNode(
|
|
|
771
779
|
): LexicalNode | null;
|
|
772
780
|
export function $getNodeByKey<N extends LexicalNode>(key: NodeKey): N | null;
|
|
773
781
|
export function $getRoot(): RootNode;
|
|
774
|
-
export function $isLeafNode(
|
|
782
|
+
export function $isLeafNode(
|
|
783
|
+
node: LexicalNode | null | undefined,
|
|
784
|
+
): node is TextNode | LineBreakNode | DecoratorNode<unknown>;
|
|
775
785
|
export function $setCompositionKey(compositionKey: null | NodeKey): void;
|
|
776
786
|
export function $setSelection(
|
|
777
787
|
selection: null | RangeSelection | NodeSelection | GridSelection,
|