lexical 0.1.20 → 0.2.1
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 +13 -107
- package/Lexical.dev.js +3664 -3824
- package/Lexical.js.flow +14 -144
- package/Lexical.prod.js +159 -160
- package/README.md +3 -3
- package/package.json +2 -2
package/Lexical.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ export var KEY_ARROW_RIGHT_COMMAND: LexicalCommand<KeyboardEvent>;
|
|
|
31
31
|
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
|
-
export var KEY_ENTER_COMMAND: LexicalCommand<KeyboardEvent>;
|
|
34
|
+
export var KEY_ENTER_COMMAND: LexicalCommand<KeyboardEvent | null>;
|
|
35
35
|
export var KEY_BACKSPACE_COMMAND: LexicalCommand<KeyboardEvent>;
|
|
36
36
|
export var KEY_ESCAPE_COMMAND: LexicalCommand<KeyboardEvent>;
|
|
37
37
|
export var KEY_DELETE_COMMAND: LexicalCommand<KeyboardEvent>;
|
|
@@ -78,19 +78,17 @@ type RootListener = (
|
|
|
78
78
|
) => void;
|
|
79
79
|
type TextContentListener = (text: string) => void;
|
|
80
80
|
type MutationListener = (nodes: Map<NodeKey, NodeMutation>) => void;
|
|
81
|
-
type CommandListener<P> = (payload: P, editor: LexicalEditor) => boolean;
|
|
82
81
|
export type ReadOnlyListener = (readOnly: boolean) => void;
|
|
83
|
-
|
|
84
|
-
type InternalCommandListener = CommandListener<any>;
|
|
85
|
-
|
|
86
82
|
type Listeners = {
|
|
87
83
|
decorator: Set<DecoratorListener>;
|
|
88
84
|
mutation: MutationListeners;
|
|
89
85
|
textcontent: Set<TextContentListener>;
|
|
90
86
|
root: Set<RootListener>;
|
|
91
87
|
update: Set<UpdateListener>;
|
|
92
|
-
command: Map<string, Array<Set<InternalCommandListener>>>;
|
|
93
88
|
};
|
|
89
|
+
type CommandListener<P> = (payload: P, editor: LexicalEditor) => boolean;
|
|
90
|
+
// $FlowFixMe[unclear-type]
|
|
91
|
+
type Commands = Map<LexicalCommand<any>, Array<Set<CommandListener<any>>>>;
|
|
94
92
|
type RegisteredNodes = Map<string, RegisteredNode>;
|
|
95
93
|
type RegisteredNode = {
|
|
96
94
|
klass: Class<LexicalNode>;
|
|
@@ -113,6 +111,7 @@ export declare class LexicalEditor {
|
|
|
113
111
|
_updating: boolean;
|
|
114
112
|
_keyToDOMMap: Map<NodeKey, HTMLElement>;
|
|
115
113
|
_listeners: Listeners;
|
|
114
|
+
_commands: Commands;
|
|
116
115
|
_nodes: RegisteredNodes;
|
|
117
116
|
_onError: ErrorHandler;
|
|
118
117
|
_decorators: Record<NodeKey, unknown>;
|
|
@@ -311,6 +310,10 @@ export type DOMConversionOutput = {
|
|
|
311
310
|
forChild?: DOMChildConversion;
|
|
312
311
|
node: LexicalNode | null;
|
|
313
312
|
};
|
|
313
|
+
export type DOMExportOutput = {
|
|
314
|
+
after?: (generatedElement: ?HTMLElement) => ?HTMLElement;
|
|
315
|
+
element: HTMLElement | null;
|
|
316
|
+
};
|
|
314
317
|
export type NodeKey = string;
|
|
315
318
|
export declare class LexicalNode {
|
|
316
319
|
__type: string;
|
|
@@ -318,7 +321,7 @@ export declare class LexicalNode {
|
|
|
318
321
|
__parent: null | NodeKey;
|
|
319
322
|
getType(): string;
|
|
320
323
|
clone(data: any): LexicalNode;
|
|
321
|
-
|
|
324
|
+
importDOM(): DOMConversionMap | null;
|
|
322
325
|
constructor(key?: NodeKey);
|
|
323
326
|
getType(): string;
|
|
324
327
|
isAttached(): boolean;
|
|
@@ -351,6 +354,7 @@ export declare class LexicalNode {
|
|
|
351
354
|
includeInert?: boolean,
|
|
352
355
|
includeDirectionless?: false,
|
|
353
356
|
): number;
|
|
357
|
+
exportDOM(editor: LexicalEditor): DOMExportOutput;
|
|
354
358
|
// $FlowFixMe
|
|
355
359
|
createDOM<EditorContext extends Record<string, any>>(
|
|
356
360
|
config: EditorConfig<EditorContext>,
|
|
@@ -429,6 +433,7 @@ export declare class GridSelection {
|
|
|
429
433
|
clone(): GridSelection;
|
|
430
434
|
extract(): Array<LexicalNode>;
|
|
431
435
|
isCollapsed(): boolean;
|
|
436
|
+
isBackward(): boolean;
|
|
432
437
|
insertRawText(): void;
|
|
433
438
|
insertText(): void;
|
|
434
439
|
getShape(): GridSelectionShape;
|
|
@@ -546,104 +551,6 @@ export function $getPreviousSelection():
|
|
|
546
551
|
| NodeSelection
|
|
547
552
|
| GridSelection;
|
|
548
553
|
|
|
549
|
-
/**
|
|
550
|
-
* Decorator State
|
|
551
|
-
*/
|
|
552
|
-
export type DecoratorStateValue =
|
|
553
|
-
| DecoratorMap
|
|
554
|
-
| DecoratorEditor
|
|
555
|
-
| DecoratorArray
|
|
556
|
-
| null
|
|
557
|
-
| boolean
|
|
558
|
-
| number
|
|
559
|
-
| string;
|
|
560
|
-
export declare class DecoratorEditor {
|
|
561
|
-
id: string;
|
|
562
|
-
editorState: null | EditorState | string;
|
|
563
|
-
editor: null | LexicalEditor;
|
|
564
|
-
constructor(id?: string, editorState?: string | EditorState);
|
|
565
|
-
init(editor: LexicalEditor): void;
|
|
566
|
-
set(editor: LexicalEditor): void;
|
|
567
|
-
toJSON(): $ReadOnly<{
|
|
568
|
-
id: string;
|
|
569
|
-
type: 'editor';
|
|
570
|
-
editorState: null | string;
|
|
571
|
-
}>;
|
|
572
|
-
isEmpty(): boolean;
|
|
573
|
-
}
|
|
574
|
-
export type DecoratorMapObserver = (
|
|
575
|
-
key: string,
|
|
576
|
-
value: DecoratorStateValue,
|
|
577
|
-
) => void;
|
|
578
|
-
export type DecoratorArrayObserver = (
|
|
579
|
-
index: number,
|
|
580
|
-
delCont: number,
|
|
581
|
-
value: void | DecoratorStateValue,
|
|
582
|
-
) => void;
|
|
583
|
-
export declare class DecoratorMap {
|
|
584
|
-
_editor: LexicalEditor;
|
|
585
|
-
_map: Map<string, DecoratorStateValue>;
|
|
586
|
-
constructor(editor: LexicalEditor, map?: Map<string, DecoratorStateValue>);
|
|
587
|
-
get(key: string): void | DecoratorStateValue;
|
|
588
|
-
has(key: string): boolean;
|
|
589
|
-
set(key: string, value: DecoratorStateValue): void;
|
|
590
|
-
observe(observer: DecoratorMapObserver): () => void;
|
|
591
|
-
destroy(): void;
|
|
592
|
-
toJSON(): {
|
|
593
|
-
type: 'map';
|
|
594
|
-
map: Array<[string, DecoratorStateValue]>;
|
|
595
|
-
};
|
|
596
|
-
}
|
|
597
|
-
export function createDecoratorEditor(
|
|
598
|
-
id?: string,
|
|
599
|
-
editorState?: string | EditorState,
|
|
600
|
-
): DecoratorEditor;
|
|
601
|
-
export function isDecoratorEditor(obj: unknown | null | undefined): boolean;
|
|
602
|
-
export function createDecoratorMap(
|
|
603
|
-
editor: LexicalEditor,
|
|
604
|
-
map?: Map<string, DecoratorStateValue>,
|
|
605
|
-
): DecoratorMap;
|
|
606
|
-
export function isDecoratorMap(obj: unknown | null | undefined): boolean;
|
|
607
|
-
export declare class DecoratorArray {
|
|
608
|
-
_editor: LexicalEditor;
|
|
609
|
-
_observers: Set<DecoratorArrayObserver>;
|
|
610
|
-
_array: Array<DecoratorStateValue>;
|
|
611
|
-
constructor(editor: LexicalEditor, array?: Array<DecoratorStateValue>);
|
|
612
|
-
observe(observer: DecoratorArrayObserver): () => void;
|
|
613
|
-
map<V>(
|
|
614
|
-
fn: (
|
|
615
|
-
arg0: DecoratorStateValue,
|
|
616
|
-
arg1: number,
|
|
617
|
-
arg2: Array<DecoratorStateValue>,
|
|
618
|
-
) => V,
|
|
619
|
-
): Array<V>;
|
|
620
|
-
reduce(
|
|
621
|
-
fn: (
|
|
622
|
-
arg0: DecoratorStateValue,
|
|
623
|
-
arg1: DecoratorStateValue,
|
|
624
|
-
) => DecoratorStateValue,
|
|
625
|
-
initial?: DecoratorStateValue,
|
|
626
|
-
): DecoratorStateValue | void;
|
|
627
|
-
push(value: DecoratorStateValue): void;
|
|
628
|
-
getLength(): number;
|
|
629
|
-
splice(
|
|
630
|
-
insertIndex: number,
|
|
631
|
-
delCount: number,
|
|
632
|
-
value?: DecoratorStateValue,
|
|
633
|
-
): void;
|
|
634
|
-
indexOf(value: DecoratorStateValue): number;
|
|
635
|
-
destroy(): void;
|
|
636
|
-
toJSON(): {
|
|
637
|
-
type: 'array';
|
|
638
|
-
array: Array<DecoratorStateValue>;
|
|
639
|
-
};
|
|
640
|
-
}
|
|
641
|
-
export function createDecoratorArray(
|
|
642
|
-
editor: LexicalEditor,
|
|
643
|
-
list?: Array<DecoratorStateValue>,
|
|
644
|
-
): DecoratorArray;
|
|
645
|
-
export function isDecoratorArray(x?: unknown): boolean;
|
|
646
|
-
|
|
647
554
|
/**
|
|
648
555
|
* LexicalTextNode
|
|
649
556
|
*/
|
|
@@ -806,8 +713,7 @@ export function $isElementNode(node: LexicalNode | null | undefined): boolean;
|
|
|
806
713
|
* LexicalDecoratorNode
|
|
807
714
|
*/
|
|
808
715
|
export declare class DecoratorNode<X> extends LexicalNode {
|
|
809
|
-
|
|
810
|
-
constructor(state?: DecoratorMap, key?: NodeKey);
|
|
716
|
+
constructor(key?: NodeKey);
|
|
811
717
|
decorate(editor: LexicalEditor): X;
|
|
812
718
|
isIsolated(): boolean;
|
|
813
719
|
}
|