lexical 0.2.9 → 0.3.2
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 +144 -93
- package/Lexical.dev.js +4160 -4045
- package/Lexical.js.flow +122 -83
- package/Lexical.prod.js +170 -167
- package/package.json +1 -1
package/Lexical.d.ts
CHANGED
|
@@ -6,20 +6,23 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import {
|
|
9
|
+
import {Spread} from 'libdefs/globals';
|
|
10
|
+
import {Class} from 'utility-types';
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* LexicalCommands
|
|
13
14
|
*/
|
|
14
15
|
|
|
15
|
-
export type LexicalCommand<P> =
|
|
16
|
+
export type LexicalCommand<P> = Readonly<{}>;
|
|
16
17
|
|
|
17
18
|
export var SELECTION_CHANGE_COMMAND: LexicalCommand<void>;
|
|
18
19
|
export var CLICK_COMMAND: LexicalCommand<MouseEvent>;
|
|
19
20
|
export var DELETE_CHARACTER_COMMAND: LexicalCommand<boolean>;
|
|
20
21
|
export var INSERT_LINE_BREAK_COMMAND: LexicalCommand<boolean>;
|
|
21
22
|
export var INSERT_PARAGRAPH_COMMAND: LexicalCommand<void>;
|
|
22
|
-
export var
|
|
23
|
+
export var CONTROLLED_TEXT_INSERTION_COMMAND: LexicalCommand<
|
|
24
|
+
InputEvent | string
|
|
25
|
+
>;
|
|
23
26
|
export var PASTE_COMMAND: LexicalCommand<ClipboardEvent>;
|
|
24
27
|
export var REMOVE_TEXT_COMMAND: LexicalCommand<void>;
|
|
25
28
|
export var DELETE_WORD_COMMAND: LexicalCommand<boolean>;
|
|
@@ -28,7 +31,9 @@ export var FORMAT_TEXT_COMMAND: LexicalCommand<TextFormatType>;
|
|
|
28
31
|
export var UNDO_COMMAND: LexicalCommand<void>;
|
|
29
32
|
export var REDO_COMMAND: LexicalCommand<void>;
|
|
30
33
|
export var KEY_ARROW_RIGHT_COMMAND: LexicalCommand<KeyboardEvent>;
|
|
34
|
+
export var MOVE_TO_END: LexicalCommand<KeyboardEvent>;
|
|
31
35
|
export var KEY_ARROW_LEFT_COMMAND: LexicalCommand<KeyboardEvent>;
|
|
36
|
+
export var MOVE_TO_START: LexicalCommand<KeyboardEvent>;
|
|
32
37
|
export var KEY_ARROW_UP_COMMAND: LexicalCommand<KeyboardEvent>;
|
|
33
38
|
export var KEY_ARROW_DOWN_COMMAND: LexicalCommand<KeyboardEvent>;
|
|
34
39
|
export var KEY_ENTER_COMMAND: LexicalCommand<KeyboardEvent | null>;
|
|
@@ -43,6 +48,7 @@ export var OUTDENT_CONTENT_COMMAND: LexicalCommand<void>;
|
|
|
43
48
|
export var DROP_COMMAND: LexicalCommand<DragEvent>;
|
|
44
49
|
export var FORMAT_ELEMENT_COMMAND: LexicalCommand<ElementFormatType>;
|
|
45
50
|
export var DRAGSTART_COMMAND: LexicalCommand<DragEvent>;
|
|
51
|
+
export var DRAGOVER_COMMAND: LexicalCommand<DragEvent>;
|
|
46
52
|
export var DRAGEND_COMMAND: LexicalCommand<DragEvent>;
|
|
47
53
|
export var COPY_COMMAND: LexicalCommand<ClipboardEvent>;
|
|
48
54
|
export var CUT_COMMAND: LexicalCommand<ClipboardEvent>;
|
|
@@ -55,6 +61,7 @@ export var BLUR_COMMAND: LexicalCommand<FocusEvent>;
|
|
|
55
61
|
export var INSERT_TABLE_COMMAND: LexicalCommand<{
|
|
56
62
|
rows: string;
|
|
57
63
|
columns: string;
|
|
64
|
+
includeHeaders?: boolean;
|
|
58
65
|
}>;
|
|
59
66
|
|
|
60
67
|
export declare function createCommand<T>(): LexicalCommand<T>;
|
|
@@ -89,7 +96,6 @@ type Listeners = {
|
|
|
89
96
|
update: Set<UpdateListener>;
|
|
90
97
|
};
|
|
91
98
|
type CommandListener<P> = (payload: P, editor: LexicalEditor) => boolean;
|
|
92
|
-
// $FlowFixMe[unclear-type]
|
|
93
99
|
type Commands = Map<LexicalCommand<any>, Array<Set<CommandListener<any>>>>;
|
|
94
100
|
type RegisteredNodes = Map<string, RegisteredNode>;
|
|
95
101
|
type RegisteredNode = {
|
|
@@ -158,13 +164,15 @@ export declare class LexicalEditor {
|
|
|
158
164
|
getEditorState(): EditorState;
|
|
159
165
|
setEditorState(editorState: EditorState, options?: EditorSetOptions): void;
|
|
160
166
|
parseEditorState(
|
|
161
|
-
maybeStringifiedEditorState: string |
|
|
167
|
+
maybeStringifiedEditorState: string | SerializedEditorState,
|
|
168
|
+
updateFn?: () => void,
|
|
162
169
|
): EditorState;
|
|
163
170
|
update(updateFn: () => void, options?: EditorUpdateOptions): boolean;
|
|
164
171
|
focus(callbackFn?: () => void): void;
|
|
165
172
|
blur(): void;
|
|
166
173
|
isReadOnly(): boolean;
|
|
167
174
|
setReadOnly(readOnly: boolean): void;
|
|
175
|
+
toJSON(): SerializedEditor;
|
|
168
176
|
}
|
|
169
177
|
type EditorUpdateOptions = {
|
|
170
178
|
onUpdate?: () => void;
|
|
@@ -186,12 +194,14 @@ type TextNodeThemeClasses = {
|
|
|
186
194
|
subscript?: EditorThemeClassName;
|
|
187
195
|
superscript?: EditorThemeClassName;
|
|
188
196
|
};
|
|
197
|
+
|
|
189
198
|
export type EditorThemeClasses = {
|
|
190
199
|
ltr?: EditorThemeClassName;
|
|
191
200
|
rtl?: EditorThemeClassName;
|
|
192
201
|
text?: TextNodeThemeClasses;
|
|
193
202
|
paragraph?: EditorThemeClassName;
|
|
194
203
|
image?: EditorThemeClassName;
|
|
204
|
+
characterLimit?: EditorThemeClassName;
|
|
195
205
|
list?: {
|
|
196
206
|
ul?: EditorThemeClassName;
|
|
197
207
|
ulDepth?: Array<EditorThemeClassName>;
|
|
@@ -226,18 +236,23 @@ export type EditorThemeClasses = {
|
|
|
226
236
|
// Handle other generic values
|
|
227
237
|
[key: string]:
|
|
228
238
|
| EditorThemeClassName
|
|
229
|
-
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
239
|
+
| TextNodeThemeClasses
|
|
240
|
+
| {
|
|
241
|
+
[key: string]:
|
|
242
|
+
| Array<EditorThemeClassName>
|
|
243
|
+
| EditorThemeClassName
|
|
244
|
+
| TextNodeThemeClasses
|
|
245
|
+
| {
|
|
246
|
+
[key: string]: EditorThemeClassName;
|
|
247
|
+
};
|
|
248
|
+
};
|
|
235
249
|
};
|
|
250
|
+
|
|
236
251
|
export type EditorConfig = {
|
|
237
|
-
namespace: string;
|
|
238
252
|
theme: EditorThemeClasses;
|
|
239
253
|
disableEvents?: boolean;
|
|
240
254
|
};
|
|
255
|
+
|
|
241
256
|
export type CommandListenerPriority = 0 | 1 | 2 | 3 | 4;
|
|
242
257
|
export const COMMAND_PRIORITY_EDITOR = 0;
|
|
243
258
|
export const COMMAND_PRIORITY_LOW = 1;
|
|
@@ -246,7 +261,6 @@ export const COMMAND_PRIORITY_HIGH = 3;
|
|
|
246
261
|
export const COMMAND_PRIORITY_CRITICAL = 4;
|
|
247
262
|
export type IntentionallyMarkedAsDirtyElement = boolean;
|
|
248
263
|
export function createEditor(editorConfig?: {
|
|
249
|
-
namespace?: string;
|
|
250
264
|
editorState?: EditorState;
|
|
251
265
|
theme?: EditorThemeClasses;
|
|
252
266
|
parentEditor?: LexicalEditor;
|
|
@@ -259,25 +273,7 @@ export function createEditor(editorConfig?: {
|
|
|
259
273
|
/**
|
|
260
274
|
* LexicalEditorState
|
|
261
275
|
*/
|
|
262
|
-
|
|
263
|
-
_selection: null | {
|
|
264
|
-
anchor: {
|
|
265
|
-
key: string;
|
|
266
|
-
offset: number;
|
|
267
|
-
type: 'text' | 'element';
|
|
268
|
-
};
|
|
269
|
-
focus: {
|
|
270
|
-
key: string;
|
|
271
|
-
offset: number;
|
|
272
|
-
type: 'text' | 'element';
|
|
273
|
-
};
|
|
274
|
-
};
|
|
275
|
-
_nodeMap: Array<[NodeKey, ParsedNode]>;
|
|
276
|
-
};
|
|
277
|
-
type JSONEditorState = {
|
|
278
|
-
_nodeMap: Array<[NodeKey, LexicalNode]>;
|
|
279
|
-
_selection: null | ParsedSelection;
|
|
280
|
-
};
|
|
276
|
+
|
|
281
277
|
export interface EditorState {
|
|
282
278
|
_nodeMap: NodeMap;
|
|
283
279
|
_selection: null | RangeSelection | NodeSelection | GridSelection;
|
|
@@ -289,7 +285,7 @@ export interface EditorState {
|
|
|
289
285
|
);
|
|
290
286
|
isEmpty(): boolean;
|
|
291
287
|
read<V>(callbackFn: () => V): V;
|
|
292
|
-
toJSON(
|
|
288
|
+
toJSON(): SerializedEditorState;
|
|
293
289
|
clone(
|
|
294
290
|
selection?: RangeSelection | NodeSelection | GridSelection | null,
|
|
295
291
|
): EditorState;
|
|
@@ -329,8 +325,10 @@ export declare class LexicalNode {
|
|
|
329
325
|
__type: string;
|
|
330
326
|
__key: NodeKey;
|
|
331
327
|
__parent: null | NodeKey;
|
|
328
|
+
static getType: () => string;
|
|
332
329
|
getType(): string;
|
|
333
330
|
clone(data: any): LexicalNode;
|
|
331
|
+
exportJSON(): SerializedLexicalNode;
|
|
334
332
|
importDOM(): DOMConversionMap | null;
|
|
335
333
|
constructor(key?: NodeKey);
|
|
336
334
|
getType(): string;
|
|
@@ -338,24 +336,24 @@ export declare class LexicalNode {
|
|
|
338
336
|
isSelected(): boolean;
|
|
339
337
|
getKey(): NodeKey;
|
|
340
338
|
getIndexWithinParent(): number;
|
|
341
|
-
getParent():
|
|
342
|
-
getParentOrThrow():
|
|
343
|
-
getTopLevelElement():
|
|
344
|
-
getTopLevelElementOrThrow(): ElementNode;
|
|
345
|
-
getParents(): Array<
|
|
339
|
+
getParent<T extends ElementNode>(): T | null;
|
|
340
|
+
getParentOrThrow<T extends ElementNode>(): T;
|
|
341
|
+
getTopLevelElement(): ElementNode | this | null;
|
|
342
|
+
getTopLevelElementOrThrow(): ElementNode | this;
|
|
343
|
+
getParents<T extends ElementNode>(): Array<T>;
|
|
346
344
|
getParentKeys(): Array<NodeKey>;
|
|
347
|
-
getPreviousSibling():
|
|
348
|
-
getPreviousSiblings(): Array<
|
|
349
|
-
getNextSibling():
|
|
350
|
-
getNextSiblings(): Array<
|
|
351
|
-
getCommonAncestor(node: LexicalNode):
|
|
345
|
+
getPreviousSibling<T extends LexicalNode>(): T | null;
|
|
346
|
+
getPreviousSiblings<T extends LexicalNode>(): Array<T>;
|
|
347
|
+
getNextSibling<T extends LexicalNode>(): T | null;
|
|
348
|
+
getNextSiblings<T extends LexicalNode>(): Array<T>;
|
|
349
|
+
getCommonAncestor<T extends ElementNode>(node: LexicalNode): T | null;
|
|
352
350
|
is(object: LexicalNode | null | undefined): boolean;
|
|
353
351
|
isBefore(targetNode: LexicalNode): boolean;
|
|
354
352
|
isParentOf(targetNode: LexicalNode): boolean;
|
|
355
353
|
getNodesBetween(targetNode: LexicalNode): Array<LexicalNode>;
|
|
356
354
|
isDirty(): boolean;
|
|
357
|
-
getLatest
|
|
358
|
-
getWritable
|
|
355
|
+
getLatest(): this;
|
|
356
|
+
getWritable(): this;
|
|
359
357
|
getTextContent(includeInert?: boolean, includeDirectionless?: false): string;
|
|
360
358
|
getTextContentSize(
|
|
361
359
|
includeInert?: boolean,
|
|
@@ -363,43 +361,17 @@ export declare class LexicalNode {
|
|
|
363
361
|
): number;
|
|
364
362
|
exportDOM(editor: LexicalEditor): DOMExportOutput;
|
|
365
363
|
createDOM(config: EditorConfig, editor: LexicalEditor): HTMLElement;
|
|
366
|
-
updateDOM(prevNode:
|
|
364
|
+
updateDOM(prevNode: unknown, dom: HTMLElement, config: EditorConfig): boolean;
|
|
367
365
|
remove(preserveEmptyParent?: boolean): void;
|
|
368
366
|
replace<N extends LexicalNode>(replaceWith: N): N;
|
|
369
367
|
insertAfter(nodeToInsert: LexicalNode): LexicalNode;
|
|
370
368
|
insertBefore(nodeToInsert: LexicalNode): LexicalNode;
|
|
371
|
-
selectPrevious(anchorOffset?: number, focusOffset?: number):
|
|
372
|
-
selectNext(anchorOffset?: number, focusOffset?: number):
|
|
369
|
+
selectPrevious(anchorOffset?: number, focusOffset?: number): RangeSelection;
|
|
370
|
+
selectNext(anchorOffset?: number, focusOffset?: number): RangeSelection;
|
|
373
371
|
markDirty(): void;
|
|
374
372
|
}
|
|
375
373
|
export type NodeMap = Map<NodeKey, LexicalNode>;
|
|
376
374
|
|
|
377
|
-
/**
|
|
378
|
-
* LexicalParsing
|
|
379
|
-
*/
|
|
380
|
-
export type ParsedNode = {
|
|
381
|
-
__key: NodeKey;
|
|
382
|
-
__type: string;
|
|
383
|
-
__parent: null | NodeKey;
|
|
384
|
-
};
|
|
385
|
-
export type ParsedNodeMap = Map<NodeKey, ParsedNode>;
|
|
386
|
-
export function $createNodeFromParse(
|
|
387
|
-
parsedNode: ParsedNode,
|
|
388
|
-
parsedNodeMap: ParsedNodeMap,
|
|
389
|
-
): LexicalNode;
|
|
390
|
-
type ParsedSelection = {
|
|
391
|
-
anchor: {
|
|
392
|
-
key: NodeKey;
|
|
393
|
-
offset: number;
|
|
394
|
-
type: 'text' | 'element';
|
|
395
|
-
};
|
|
396
|
-
focus: {
|
|
397
|
-
key: NodeKey;
|
|
398
|
-
offset: number;
|
|
399
|
-
type: 'text' | 'element';
|
|
400
|
-
};
|
|
401
|
-
};
|
|
402
|
-
|
|
403
375
|
/**
|
|
404
376
|
* LexicalSelection
|
|
405
377
|
*/
|
|
@@ -476,7 +448,6 @@ export declare class RangeSelection {
|
|
|
476
448
|
focusOffset: number,
|
|
477
449
|
): void;
|
|
478
450
|
getTextContent(): string;
|
|
479
|
-
// $FlowFixMe DOM API
|
|
480
451
|
applyDOMRange(range: StaticRange): void;
|
|
481
452
|
clone(): RangeSelection;
|
|
482
453
|
toggleFormat(format: TextFormatType): void;
|
|
@@ -535,7 +506,6 @@ declare class _Point {
|
|
|
535
506
|
getNode(): LexicalNode;
|
|
536
507
|
set(key: NodeKey, offset: number, type: 'text' | 'element'): void;
|
|
537
508
|
}
|
|
538
|
-
|
|
539
509
|
export function $createRangeSelection(): RangeSelection;
|
|
540
510
|
export function $createNodeSelection(): NodeSelection;
|
|
541
511
|
export function $createGridSelection(): GridSelection;
|
|
@@ -587,9 +557,7 @@ export declare class TextNode extends LexicalNode {
|
|
|
587
557
|
isSimpleText(): boolean;
|
|
588
558
|
getTextContent(includeInert?: boolean, includeDirectionless?: false): string;
|
|
589
559
|
getFormatFlags(type: TextFormatType, alignWithFormat: null | number): number;
|
|
590
|
-
// $FlowFixMe
|
|
591
560
|
createDOM(config: EditorConfig): HTMLElement;
|
|
592
|
-
// $FlowFixMe
|
|
593
561
|
updateDOM(
|
|
594
562
|
prevNode: TextNode,
|
|
595
563
|
dom: HTMLElement,
|
|
@@ -604,7 +572,10 @@ export declare class TextNode extends LexicalNode {
|
|
|
604
572
|
toggleFormat(type: TextFormatType): TextNode;
|
|
605
573
|
toggleDirectionless(): TextNode;
|
|
606
574
|
toggleUnmergeable(): TextNode;
|
|
607
|
-
setMode(type: TextModeType):
|
|
575
|
+
setMode(type: TextModeType): this;
|
|
576
|
+
setDetail(detail: number): TextNode;
|
|
577
|
+
getDetail(): number;
|
|
578
|
+
getMode(): TextModeType;
|
|
608
579
|
setTextContent(text: string): TextNode;
|
|
609
580
|
select(_anchorOffset?: number, _focusOffset?: number): RangeSelection;
|
|
610
581
|
spliceText(
|
|
@@ -618,6 +589,8 @@ export declare class TextNode extends LexicalNode {
|
|
|
618
589
|
splitText(...splitOffsets: Array<number>): Array<TextNode>;
|
|
619
590
|
mergeWithSibling(target: TextNode): TextNode;
|
|
620
591
|
isTextEntity(): boolean;
|
|
592
|
+
static importJSON(serializedTextNode: SerializedTextNode): TextNode;
|
|
593
|
+
exportJSON(): SerializedTextNode;
|
|
621
594
|
}
|
|
622
595
|
export function $createTextNode(text?: string): TextNode;
|
|
623
596
|
export function $isTextNode(
|
|
@@ -634,6 +607,10 @@ export declare class LineBreakNode extends LexicalNode {
|
|
|
634
607
|
getTextContent(): '\n';
|
|
635
608
|
createDOM(): HTMLElement;
|
|
636
609
|
updateDOM(): false;
|
|
610
|
+
static importJSON(
|
|
611
|
+
serializedLineBreakNode: SerializedLexicalNode,
|
|
612
|
+
): LineBreakNode;
|
|
613
|
+
exportJSON(): SerializedLexicalNode;
|
|
637
614
|
}
|
|
638
615
|
export function $createLineBreakNode(): LineBreakNode;
|
|
639
616
|
export function $isLineBreakNode(
|
|
@@ -652,11 +629,13 @@ export declare class RootNode extends ElementNode {
|
|
|
652
629
|
select(): RangeSelection;
|
|
653
630
|
remove(): void;
|
|
654
631
|
replace<N extends LexicalNode>(node: N): N;
|
|
655
|
-
insertBefore():
|
|
656
|
-
insertAfter(
|
|
632
|
+
insertBefore<T extends LexicalNode>(nodeToInsert: T): T;
|
|
633
|
+
insertAfter<T extends LexicalNode>(nodeToInsert: T): T;
|
|
657
634
|
updateDOM(prevNode: RootNode, dom: HTMLElement): false;
|
|
658
|
-
append(...nodesToAppend: Array<LexicalNode>):
|
|
635
|
+
append(...nodesToAppend: Array<LexicalNode>): this;
|
|
659
636
|
canBeEmpty(): false;
|
|
637
|
+
static importJSON(serializedRootNode: SerializedRootNode): RootNode;
|
|
638
|
+
exportJSON(): SerializedElementNode;
|
|
660
639
|
}
|
|
661
640
|
export function $isRootNode(
|
|
662
641
|
node: LexicalNode | null | undefined,
|
|
@@ -665,7 +644,7 @@ export function $isRootNode(
|
|
|
665
644
|
/**
|
|
666
645
|
* LexicalElementNode
|
|
667
646
|
*/
|
|
668
|
-
export type ElementFormatType = 'left' | 'center' | 'right' | 'justify';
|
|
647
|
+
export type ElementFormatType = 'left' | 'center' | 'right' | 'justify' | '';
|
|
669
648
|
export declare class ElementNode extends LexicalNode {
|
|
670
649
|
__children: Array<NodeKey>;
|
|
671
650
|
__format: number;
|
|
@@ -673,28 +652,30 @@ export declare class ElementNode extends LexicalNode {
|
|
|
673
652
|
__dir: 'ltr' | 'rtl' | null;
|
|
674
653
|
constructor(key?: NodeKey);
|
|
675
654
|
getFormat(): number;
|
|
655
|
+
getFormatType(): ElementFormatType;
|
|
676
656
|
getIndent(): number;
|
|
677
|
-
getChildren(): Array<
|
|
657
|
+
getChildren<T extends LexicalNode>(): Array<T>;
|
|
658
|
+
getChildren<T extends Array<LexicalNode>>(): T;
|
|
678
659
|
getChildrenKeys(): Array<NodeKey>;
|
|
679
660
|
getChildrenSize(): number;
|
|
680
661
|
isEmpty(): boolean;
|
|
681
662
|
isDirty(): boolean;
|
|
682
663
|
getAllTextNodes(includeInert?: boolean): Array<TextNode>;
|
|
683
|
-
getFirstDescendant(): null |
|
|
684
|
-
getLastDescendant(): null |
|
|
685
|
-
getDescendantByIndex(index: number):
|
|
664
|
+
getFirstDescendant<T extends LexicalNode>(): null | T;
|
|
665
|
+
getLastDescendant<T extends LexicalNode>(): null | T;
|
|
666
|
+
getDescendantByIndex<T extends LexicalNode>(index: number): null | T;
|
|
686
667
|
getFirstChild<T extends LexicalNode>(): null | T;
|
|
687
668
|
getFirstChildOrThrow<T extends LexicalNode>(): T;
|
|
688
|
-
getLastChild(): null |
|
|
689
|
-
getChildAtIndex(index: number): null |
|
|
669
|
+
getLastChild<T extends LexicalNode>(): null | T;
|
|
670
|
+
getChildAtIndex<T extends LexicalNode>(index: number): null | T;
|
|
690
671
|
getTextContent(includeInert?: boolean, includeDirectionless?: false): string;
|
|
691
672
|
getDirection(): 'ltr' | 'rtl' | null;
|
|
692
673
|
hasFormat(type: ElementFormatType): boolean;
|
|
693
674
|
select(_anchorOffset?: number, _focusOffset?: number): RangeSelection;
|
|
694
675
|
selectStart(): RangeSelection;
|
|
695
676
|
selectEnd(): RangeSelection;
|
|
696
|
-
clear():
|
|
697
|
-
append(...nodesToAppend: Array<LexicalNode>):
|
|
677
|
+
clear(): this;
|
|
678
|
+
append(...nodesToAppend: Array<LexicalNode>): this;
|
|
698
679
|
setDirection(direction: 'ltr' | 'rtl' | null): ElementNode;
|
|
699
680
|
setFormat(type: ElementFormatType): ElementNode;
|
|
700
681
|
setIndent(indentLevel: number): ElementNode;
|
|
@@ -720,7 +701,8 @@ export declare class ElementNode extends LexicalNode {
|
|
|
720
701
|
start: number,
|
|
721
702
|
deleteCount: number,
|
|
722
703
|
nodesToInsert: Array<LexicalNode>,
|
|
723
|
-
):
|
|
704
|
+
): this;
|
|
705
|
+
exportJSON(): SerializedElementNode;
|
|
724
706
|
}
|
|
725
707
|
export function $isElementNode(
|
|
726
708
|
node: LexicalNode | null | undefined,
|
|
@@ -729,7 +711,7 @@ export function $isElementNode(
|
|
|
729
711
|
/**
|
|
730
712
|
* LexicalDecoratorNode
|
|
731
713
|
*/
|
|
732
|
-
export declare class DecoratorNode<X> extends LexicalNode {
|
|
714
|
+
export declare class DecoratorNode<X = unknown> extends LexicalNode {
|
|
733
715
|
constructor(key?: NodeKey);
|
|
734
716
|
decorate(editor: LexicalEditor): X;
|
|
735
717
|
isIsolated(): boolean;
|
|
@@ -750,6 +732,10 @@ export declare class ParagraphNode extends ElementNode {
|
|
|
750
732
|
updateDOM(prevNode: ParagraphNode, dom: HTMLElement): boolean;
|
|
751
733
|
insertNewAfter(): ParagraphNode;
|
|
752
734
|
collapseAtStart(): boolean;
|
|
735
|
+
static importJSON(
|
|
736
|
+
serializedParagraphNode: SerializedElementNode,
|
|
737
|
+
): ParagraphNode;
|
|
738
|
+
exportJSON(): SerializedElementNode;
|
|
753
739
|
}
|
|
754
740
|
export function $createParagraphNode(): ParagraphNode;
|
|
755
741
|
export function $isParagraphNode(
|
|
@@ -774,6 +760,8 @@ export function $isGridCellNode(
|
|
|
774
760
|
/**
|
|
775
761
|
* LexicalUtils
|
|
776
762
|
*/
|
|
763
|
+
export function $hasUpdateTag(tag: string): boolean;
|
|
764
|
+
export function $addUpdateTag(tag: string): void;
|
|
777
765
|
export function $getNearestNodeFromDOMNode(
|
|
778
766
|
startingDOM: Node,
|
|
779
767
|
): LexicalNode | null;
|
|
@@ -792,7 +780,70 @@ export function $getDecoratorNode(
|
|
|
792
780
|
isBackward: boolean,
|
|
793
781
|
): null | LexicalNode;
|
|
794
782
|
|
|
783
|
+
export type EventHandler = (event: Event, editor: LexicalEditor) => void;
|
|
784
|
+
|
|
795
785
|
/**
|
|
796
786
|
* LexicalVersion
|
|
797
787
|
*/
|
|
798
788
|
export declare var VERSION: string;
|
|
789
|
+
|
|
790
|
+
/**
|
|
791
|
+
* Serialization/Deserialization
|
|
792
|
+
* */
|
|
793
|
+
interface InternalSerializedNode {
|
|
794
|
+
children?: Array<InternalSerializedNode>;
|
|
795
|
+
type: string;
|
|
796
|
+
version: number;
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
export function $parseSerializedNode<
|
|
800
|
+
SerializedNode extends InternalSerializedNode,
|
|
801
|
+
>(serializedNode: SerializedNode): LexicalNode;
|
|
802
|
+
|
|
803
|
+
export type SerializedLexicalNode = {
|
|
804
|
+
type: string;
|
|
805
|
+
version: number;
|
|
806
|
+
};
|
|
807
|
+
|
|
808
|
+
export type SerializedEditor = {
|
|
809
|
+
editorState: SerializedEditorState;
|
|
810
|
+
};
|
|
811
|
+
|
|
812
|
+
export type SerializedTextNode = Spread<
|
|
813
|
+
{
|
|
814
|
+
detail: number;
|
|
815
|
+
format: number;
|
|
816
|
+
mode: TextModeType;
|
|
817
|
+
style: string;
|
|
818
|
+
text: string;
|
|
819
|
+
},
|
|
820
|
+
SerializedLexicalNode
|
|
821
|
+
>;
|
|
822
|
+
|
|
823
|
+
export type SerializedElementNode = Spread<
|
|
824
|
+
{
|
|
825
|
+
children: Array<SerializedLexicalNode>;
|
|
826
|
+
direction: 'ltr' | 'rtl' | null;
|
|
827
|
+
format: ElementFormatType;
|
|
828
|
+
indent: number;
|
|
829
|
+
},
|
|
830
|
+
SerializedLexicalNode
|
|
831
|
+
>;
|
|
832
|
+
|
|
833
|
+
export type SerializedRootNode = Spread<
|
|
834
|
+
{
|
|
835
|
+
type: 'root';
|
|
836
|
+
},
|
|
837
|
+
SerializedElementNode
|
|
838
|
+
>;
|
|
839
|
+
|
|
840
|
+
export type SerializedGridCellNode = Spread<
|
|
841
|
+
{
|
|
842
|
+
colSpan: number;
|
|
843
|
+
},
|
|
844
|
+
SerializedElementNode
|
|
845
|
+
>;
|
|
846
|
+
|
|
847
|
+
export interface SerializedEditorState {
|
|
848
|
+
root: SerializedRootNode;
|
|
849
|
+
}
|