lexical 0.1.19 → 0.2.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/Lexical.d.ts +12 -106
- package/Lexical.dev.js +3644 -3836
- package/Lexical.js.flow +13 -143
- package/Lexical.prod.js +158 -161
- package/package.json +1 -1
package/Lexical.js.flow
CHANGED
|
@@ -76,20 +76,17 @@ type RootListener = (
|
|
|
76
76
|
type TextContentListener = (text: string) => void;
|
|
77
77
|
type ErrorHandler = (error: Error) => void;
|
|
78
78
|
type MutationListener = (nodes: Map<NodeKey, NodeMutation>) => void;
|
|
79
|
-
type CommandListener<P> = (payload: P, editor: LexicalEditor) => boolean;
|
|
80
79
|
export type ReadOnlyListener = (readOnly: boolean) => void;
|
|
81
|
-
|
|
82
|
-
// $FlowFixMe
|
|
83
|
-
type InternalCommandListener = CommandListener<any>;
|
|
84
|
-
|
|
85
80
|
type Listeners = {
|
|
86
81
|
decorator: Set<DecoratorListener>,
|
|
87
82
|
mutation: MutationListeners,
|
|
88
83
|
textcontent: Set<TextContentListener>,
|
|
89
84
|
root: Set<RootListener>,
|
|
90
85
|
update: Set<UpdateListener>,
|
|
91
|
-
command: Map<string, Array<Set<InternalCommandListener>>>,
|
|
92
86
|
};
|
|
87
|
+
type CommandListener<P> = (payload: P, editor: LexicalEditor) => boolean;
|
|
88
|
+
// $FlowFixMe[unclear-type]
|
|
89
|
+
type Commands = Map<LexicalCommand<any>, Array<Set<CommandListener<any>>>>;
|
|
93
90
|
type RegisteredNodes = Map<string, RegisteredNode>;
|
|
94
91
|
type RegisteredNode = {
|
|
95
92
|
klass: Class<LexicalNode>,
|
|
@@ -114,6 +111,7 @@ declare export class LexicalEditor {
|
|
|
114
111
|
_updating: boolean;
|
|
115
112
|
_keyToDOMMap: Map<NodeKey, HTMLElement>;
|
|
116
113
|
_listeners: Listeners;
|
|
114
|
+
_commands: Commands;
|
|
117
115
|
_nodes: RegisteredNodes;
|
|
118
116
|
_onError: ErrorHandler;
|
|
119
117
|
_decorators: {
|
|
@@ -153,6 +151,7 @@ declare export class LexicalEditor {
|
|
|
153
151
|
): () => void;
|
|
154
152
|
dispatchCommand<P>(command: LexicalCommand<P>, payload?: P): boolean;
|
|
155
153
|
hasNodes(nodes: Array<Class<LexicalNode>>): boolean;
|
|
154
|
+
getKey(): string;
|
|
156
155
|
getDecorators<X>(): {
|
|
157
156
|
[NodeKey]: X,
|
|
158
157
|
};
|
|
@@ -319,6 +318,10 @@ export type DOMConversionOutput = {
|
|
|
319
318
|
forChild?: DOMChildConversion,
|
|
320
319
|
node: LexicalNode | null,
|
|
321
320
|
};
|
|
321
|
+
export type DOMExportOutput = {
|
|
322
|
+
after?: (generatedElement: ?HTMLElement) => ?HTMLElement,
|
|
323
|
+
element?: HTMLElement | null,
|
|
324
|
+
};
|
|
322
325
|
export type NodeKey = string;
|
|
323
326
|
declare export class LexicalNode {
|
|
324
327
|
__type: string;
|
|
@@ -326,8 +329,9 @@ declare export class LexicalNode {
|
|
|
326
329
|
__parent: null | NodeKey;
|
|
327
330
|
static getType(): string;
|
|
328
331
|
static clone(data: $FlowFixMe): LexicalNode;
|
|
329
|
-
static
|
|
332
|
+
static importDOM(): DOMConversionMap | null;
|
|
330
333
|
constructor(key?: NodeKey): void;
|
|
334
|
+
exportDOM(editor: LexicalEditor): DOMExportOutput;
|
|
331
335
|
getType(): string;
|
|
332
336
|
isAttached(): boolean;
|
|
333
337
|
isSelected(): boolean;
|
|
@@ -447,6 +451,7 @@ declare export class GridSelection implements BaseSelection {
|
|
|
447
451
|
insertRawText(): void;
|
|
448
452
|
insertText(): void;
|
|
449
453
|
isCollapsed(): false;
|
|
454
|
+
isBackward(): boolean;
|
|
450
455
|
getShape(): GridSelectionShape;
|
|
451
456
|
getNodes(): Array<LexicalNode>;
|
|
452
457
|
getTextContent(): string;
|
|
@@ -583,140 +588,6 @@ declare export function $getPreviousSelection():
|
|
|
583
588
|
| NodeSelection
|
|
584
589
|
| GridSelection;
|
|
585
590
|
|
|
586
|
-
/**
|
|
587
|
-
* Decorator State
|
|
588
|
-
*/
|
|
589
|
-
|
|
590
|
-
export type DecoratorStateValue =
|
|
591
|
-
| DecoratorMap
|
|
592
|
-
| DecoratorEditor
|
|
593
|
-
| DecoratorArray
|
|
594
|
-
| null
|
|
595
|
-
| boolean
|
|
596
|
-
| number
|
|
597
|
-
| string;
|
|
598
|
-
|
|
599
|
-
declare export class DecoratorEditor {
|
|
600
|
-
id: string;
|
|
601
|
-
editorState: null | EditorState | string;
|
|
602
|
-
editor: null | LexicalEditor;
|
|
603
|
-
|
|
604
|
-
constructor(id?: string, editorState?: string | EditorState): void;
|
|
605
|
-
|
|
606
|
-
init(editor: LexicalEditor): void;
|
|
607
|
-
|
|
608
|
-
set(editor: LexicalEditor): void;
|
|
609
|
-
|
|
610
|
-
toJSON(): $ReadOnly<{
|
|
611
|
-
id: string,
|
|
612
|
-
type: 'editor',
|
|
613
|
-
editorState: null | string,
|
|
614
|
-
}>;
|
|
615
|
-
|
|
616
|
-
isEmpty(): boolean;
|
|
617
|
-
}
|
|
618
|
-
|
|
619
|
-
export type DecoratorMapObserver = (
|
|
620
|
-
key: string,
|
|
621
|
-
value: DecoratorStateValue,
|
|
622
|
-
) => void;
|
|
623
|
-
|
|
624
|
-
export type DecoratorArrayObserver = (
|
|
625
|
-
index: number,
|
|
626
|
-
delCont: number,
|
|
627
|
-
value: void | DecoratorStateValue,
|
|
628
|
-
) => void;
|
|
629
|
-
|
|
630
|
-
declare export class DecoratorMap {
|
|
631
|
-
_editor: LexicalEditor;
|
|
632
|
-
_map: Map<string, DecoratorStateValue>;
|
|
633
|
-
|
|
634
|
-
constructor(
|
|
635
|
-
editor: LexicalEditor,
|
|
636
|
-
map?: Map<string, DecoratorStateValue>,
|
|
637
|
-
): void;
|
|
638
|
-
|
|
639
|
-
get(key: string): void | DecoratorStateValue;
|
|
640
|
-
|
|
641
|
-
has(key: string): boolean;
|
|
642
|
-
|
|
643
|
-
set(key: string, value: DecoratorStateValue): void;
|
|
644
|
-
|
|
645
|
-
observe(observer: DecoratorMapObserver): () => void;
|
|
646
|
-
|
|
647
|
-
destroy(): void;
|
|
648
|
-
|
|
649
|
-
toJSON(): $ReadOnly<{
|
|
650
|
-
type: 'map',
|
|
651
|
-
map: Array<[string, DecoratorStateValue]>,
|
|
652
|
-
}>;
|
|
653
|
-
}
|
|
654
|
-
|
|
655
|
-
declare export function createDecoratorEditor(
|
|
656
|
-
id?: string,
|
|
657
|
-
editorState?: string | EditorState,
|
|
658
|
-
): DecoratorEditor;
|
|
659
|
-
|
|
660
|
-
declare export function isDecoratorEditor(
|
|
661
|
-
obj: ?mixed,
|
|
662
|
-
): boolean %checks(obj instanceof DecoratorEditor);
|
|
663
|
-
|
|
664
|
-
declare export function createDecoratorMap(
|
|
665
|
-
editor: LexicalEditor,
|
|
666
|
-
map?: Map<string, DecoratorStateValue>,
|
|
667
|
-
): DecoratorMap;
|
|
668
|
-
|
|
669
|
-
declare export function isDecoratorMap(
|
|
670
|
-
obj: ?mixed,
|
|
671
|
-
): boolean %checks(obj instanceof DecoratorMap);
|
|
672
|
-
|
|
673
|
-
declare export class DecoratorArray {
|
|
674
|
-
_editor: LexicalEditor;
|
|
675
|
-
_observers: Set<DecoratorArrayObserver>;
|
|
676
|
-
_array: Array<DecoratorStateValue>;
|
|
677
|
-
|
|
678
|
-
constructor(editor: LexicalEditor, array?: Array<DecoratorStateValue>): void;
|
|
679
|
-
|
|
680
|
-
observe(observer: DecoratorArrayObserver): () => void;
|
|
681
|
-
|
|
682
|
-
map<V>(
|
|
683
|
-
fn: (DecoratorStateValue, number, Array<DecoratorStateValue>) => V,
|
|
684
|
-
): Array<V>;
|
|
685
|
-
|
|
686
|
-
reduce(
|
|
687
|
-
fn: (DecoratorStateValue, DecoratorStateValue) => DecoratorStateValue,
|
|
688
|
-
initial?: DecoratorStateValue,
|
|
689
|
-
): DecoratorStateValue | void;
|
|
690
|
-
|
|
691
|
-
push(value: DecoratorStateValue): void;
|
|
692
|
-
|
|
693
|
-
getLength(): number;
|
|
694
|
-
|
|
695
|
-
splice(
|
|
696
|
-
insertIndex: number,
|
|
697
|
-
delCount: number,
|
|
698
|
-
value?: DecoratorStateValue,
|
|
699
|
-
): void;
|
|
700
|
-
|
|
701
|
-
indexOf(value: DecoratorStateValue): number;
|
|
702
|
-
|
|
703
|
-
destroy(): void;
|
|
704
|
-
|
|
705
|
-
toJSON(): $ReadOnly<{
|
|
706
|
-
type: 'array',
|
|
707
|
-
array: Array<DecoratorStateValue>,
|
|
708
|
-
}>;
|
|
709
|
-
}
|
|
710
|
-
|
|
711
|
-
declare export function createDecoratorArray(
|
|
712
|
-
editor: LexicalEditor,
|
|
713
|
-
list?: Array<DecoratorStateValue>,
|
|
714
|
-
): DecoratorArray;
|
|
715
|
-
|
|
716
|
-
declare export function isDecoratorArray(
|
|
717
|
-
x?: mixed,
|
|
718
|
-
): boolean %checks(x instanceof DecoratorArray);
|
|
719
|
-
|
|
720
591
|
/**
|
|
721
592
|
* LexicalTextNode
|
|
722
593
|
*/
|
|
@@ -893,8 +764,7 @@ declare export function $isElementNode(
|
|
|
893
764
|
*/
|
|
894
765
|
|
|
895
766
|
declare export class DecoratorNode<X> extends LexicalNode {
|
|
896
|
-
|
|
897
|
-
constructor(state?: DecoratorMap, key?: NodeKey): void;
|
|
767
|
+
constructor(key?: NodeKey): void;
|
|
898
768
|
decorate(editor: LexicalEditor): X;
|
|
899
769
|
isIsolated(): boolean;
|
|
900
770
|
}
|