lexical 0.2.1 → 0.2.4
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 +57 -37
- package/Lexical.dev.js +4459 -4379
- package/Lexical.js.flow +9 -13
- package/Lexical.prod.js +141 -139
- package/package.json +1 -1
package/Lexical.d.ts
CHANGED
|
@@ -36,6 +36,7 @@ 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>;
|
|
38
38
|
export var KEY_TAB_COMMAND: LexicalCommand<KeyboardEvent>;
|
|
39
|
+
export var KEY_MODIFIER_COMMAND: LexicalCommand<KeyboardEvent>;
|
|
39
40
|
export var INDENT_CONTENT_COMMAND: LexicalCommand<void>;
|
|
40
41
|
export var OUTDENT_CONTENT_COMMAND: LexicalCommand<void>;
|
|
41
42
|
export var DROP_COMMAND: LexicalCommand<DragEvent>;
|
|
@@ -53,7 +54,6 @@ export var INSERT_TABLE_COMMAND: LexicalCommand<{
|
|
|
53
54
|
rows: string;
|
|
54
55
|
columns: string;
|
|
55
56
|
}>;
|
|
56
|
-
export var READ_ONLY_COMMAND: LexicalCommand<void>;
|
|
57
57
|
|
|
58
58
|
export declare function createCommand<T>(): LexicalCommand<T>;
|
|
59
59
|
|
|
@@ -145,7 +145,7 @@ export declare class LexicalEditor {
|
|
|
145
145
|
klass: Class<T>,
|
|
146
146
|
listener: Transform<T>,
|
|
147
147
|
): () => void;
|
|
148
|
-
dispatchCommand(type: string, payload: P): boolean;
|
|
148
|
+
dispatchCommand<P>(type: string, payload: P): boolean;
|
|
149
149
|
hasNodes(nodes: Array<Class<LexicalNode>>): boolean;
|
|
150
150
|
getDecorators<X>(): Record<NodeKey, X>;
|
|
151
151
|
getRootElement(): null | HTMLElement;
|
|
@@ -222,17 +222,12 @@ export type EditorConfig<EditorContext> = {
|
|
|
222
222
|
context: EditorContext;
|
|
223
223
|
disableEvents?: boolean;
|
|
224
224
|
};
|
|
225
|
-
export type
|
|
226
|
-
export
|
|
227
|
-
export
|
|
228
|
-
export
|
|
229
|
-
export
|
|
230
|
-
|
|
231
|
-
| CommandListenerEditorPriority
|
|
232
|
-
| CommandListenerLowPriority
|
|
233
|
-
| CommandListenerNormalPriority
|
|
234
|
-
| CommandListenerHighPriority
|
|
235
|
-
| CommandListenerCriticalPriority;
|
|
225
|
+
export type CommandListenerPriority = 0 | 1 | 2 | 3 | 4;
|
|
226
|
+
export const COMMAND_PRIORITY_EDITOR = 0;
|
|
227
|
+
export const COMMAND_PRIORITY_LOW = 1;
|
|
228
|
+
export const COMMAND_PRIORITY_NORMAL = 2;
|
|
229
|
+
export const COMMAND_PRIORITY_HIGH = 3;
|
|
230
|
+
export const COMMAND_PRIORITY_CRITICAL = 4;
|
|
236
231
|
export type IntentionallyMarkedAsDirtyElement = boolean;
|
|
237
232
|
export function createEditor<EditorContext>(editorConfig?: {
|
|
238
233
|
namespace?: string;
|
|
@@ -298,8 +293,8 @@ export type DOMConversionFn = (
|
|
|
298
293
|
) => DOMConversionOutput;
|
|
299
294
|
export type DOMChildConversion = (
|
|
300
295
|
lexicalNode: LexicalNode,
|
|
301
|
-
parentLexicalNode:
|
|
302
|
-
) =>
|
|
296
|
+
parentLexicalNode: LexicalNode | null,
|
|
297
|
+
) => LexicalNode | void | null;
|
|
303
298
|
export type DOMConversionMap = Record<
|
|
304
299
|
NodeName,
|
|
305
300
|
(node: Node) => DOMConversion | null
|
|
@@ -311,7 +306,7 @@ export type DOMConversionOutput = {
|
|
|
311
306
|
node: LexicalNode | null;
|
|
312
307
|
};
|
|
313
308
|
export type DOMExportOutput = {
|
|
314
|
-
after?: (generatedElement:
|
|
309
|
+
after?: (generatedElement: HTMLElement | null) => HTMLElement | null;
|
|
315
310
|
element: HTMLElement | null;
|
|
316
311
|
};
|
|
317
312
|
export type NodeKey = string;
|
|
@@ -366,7 +361,7 @@ export declare class LexicalNode {
|
|
|
366
361
|
dom: HTMLElement,
|
|
367
362
|
config: EditorConfig<EditorContext>,
|
|
368
363
|
): boolean;
|
|
369
|
-
remove(): void;
|
|
364
|
+
remove(preserveEmptyParent?: boolean): void;
|
|
370
365
|
replace<N extends LexicalNode>(replaceWith: N): N;
|
|
371
366
|
insertAfter(nodeToInsert: LexicalNode): LexicalNode;
|
|
372
367
|
insertBefore(nodeToInsert: LexicalNode): LexicalNode;
|
|
@@ -440,7 +435,9 @@ export declare class GridSelection {
|
|
|
440
435
|
getNodes(): Array<LexicalNode>;
|
|
441
436
|
getTextContent(): string;
|
|
442
437
|
}
|
|
443
|
-
export function $isGridSelection(
|
|
438
|
+
export function $isGridSelection(
|
|
439
|
+
x: unknown | null | undefined,
|
|
440
|
+
): x is GridSelection;
|
|
444
441
|
export declare class NodeSelection {
|
|
445
442
|
_nodes: Set<NodeKey>;
|
|
446
443
|
dirty: boolean;
|
|
@@ -457,7 +454,9 @@ export declare class NodeSelection {
|
|
|
457
454
|
getNodes(): Array<LexicalNode>;
|
|
458
455
|
getTextContent(): string;
|
|
459
456
|
}
|
|
460
|
-
export function $isNodeSelection(
|
|
457
|
+
export function $isNodeSelection(
|
|
458
|
+
x: unknown | null | undefined,
|
|
459
|
+
): x is NodeSelection;
|
|
461
460
|
export declare class RangeSelection {
|
|
462
461
|
anchor: PointType;
|
|
463
462
|
focus: PointType;
|
|
@@ -539,7 +538,9 @@ declare class _Point {
|
|
|
539
538
|
export function $createRangeSelection(): RangeSelection;
|
|
540
539
|
export function $createNodeSelection(): NodeSelection;
|
|
541
540
|
export function $createGridSelection(): GridSelection;
|
|
542
|
-
export function $isRangeSelection(
|
|
541
|
+
export function $isRangeSelection(
|
|
542
|
+
x: unknown | null | undefined,
|
|
543
|
+
): x is RangeSelection;
|
|
543
544
|
export function $getSelection():
|
|
544
545
|
| null
|
|
545
546
|
| RangeSelection
|
|
@@ -569,8 +570,8 @@ export declare class TextNode extends LexicalNode {
|
|
|
569
570
|
__style: string;
|
|
570
571
|
__mode: 0 | 1 | 2 | 3;
|
|
571
572
|
__detail: number;
|
|
572
|
-
getType(): string;
|
|
573
|
-
clone(node: any): TextNode;
|
|
573
|
+
static getType(): string;
|
|
574
|
+
static clone(node: any): TextNode;
|
|
574
575
|
constructor(text: string, key?: NodeKey);
|
|
575
576
|
getFormat(): number;
|
|
576
577
|
getStyle(): string;
|
|
@@ -617,29 +618,33 @@ export declare class TextNode extends LexicalNode {
|
|
|
617
618
|
mergeWithSibling(target: TextNode): TextNode;
|
|
618
619
|
}
|
|
619
620
|
export function $createTextNode(text?: string): TextNode;
|
|
620
|
-
export function $isTextNode(
|
|
621
|
+
export function $isTextNode(
|
|
622
|
+
node: LexicalNode | null | undefined,
|
|
623
|
+
): node is TextNode;
|
|
621
624
|
|
|
622
625
|
/**
|
|
623
626
|
* LexicalLineBreakNode
|
|
624
627
|
*/
|
|
625
628
|
export declare class LineBreakNode extends LexicalNode {
|
|
626
|
-
getType(): string;
|
|
627
|
-
clone(node: LineBreakNode): LineBreakNode;
|
|
629
|
+
static getType(): string;
|
|
630
|
+
static clone(node: LineBreakNode): LineBreakNode;
|
|
628
631
|
constructor(key?: NodeKey);
|
|
629
632
|
getTextContent(): '\n';
|
|
630
633
|
createDOM(): HTMLElement;
|
|
631
634
|
updateDOM(): false;
|
|
632
635
|
}
|
|
633
636
|
export function $createLineBreakNode(): LineBreakNode;
|
|
634
|
-
export function $isLineBreakNode(
|
|
637
|
+
export function $isLineBreakNode(
|
|
638
|
+
node: LexicalNode | null | undefined,
|
|
639
|
+
): node is LineBreakNode;
|
|
635
640
|
|
|
636
641
|
/**
|
|
637
642
|
* LexicalRootNode
|
|
638
643
|
*/
|
|
639
644
|
export declare class RootNode extends ElementNode {
|
|
640
645
|
__cachedText: null | string;
|
|
641
|
-
getType(): string;
|
|
642
|
-
clone(): RootNode;
|
|
646
|
+
static getType(): string;
|
|
647
|
+
static clone(): RootNode;
|
|
643
648
|
constructor();
|
|
644
649
|
getTextContent(includeInert?: boolean, includeDirectionless?: false): string;
|
|
645
650
|
select(): RangeSelection;
|
|
@@ -651,7 +656,9 @@ export declare class RootNode extends ElementNode {
|
|
|
651
656
|
append(...nodesToAppend: Array<LexicalNode>): ElementNode;
|
|
652
657
|
canBeEmpty(): false;
|
|
653
658
|
}
|
|
654
|
-
export function $isRootNode(
|
|
659
|
+
export function $isRootNode(
|
|
660
|
+
node: LexicalNode | null | undefined,
|
|
661
|
+
): node is RootNode;
|
|
655
662
|
|
|
656
663
|
/**
|
|
657
664
|
* LexicalElementNode
|
|
@@ -707,7 +714,9 @@ export declare class ElementNode extends LexicalNode {
|
|
|
707
714
|
nodesToInsert: Array<LexicalNode>,
|
|
708
715
|
): ElementNode;
|
|
709
716
|
}
|
|
710
|
-
export function $isElementNode(
|
|
717
|
+
export function $isElementNode(
|
|
718
|
+
node: LexicalNode | null | undefined,
|
|
719
|
+
): node is ElementNode;
|
|
711
720
|
|
|
712
721
|
/**
|
|
713
722
|
* LexicalDecoratorNode
|
|
@@ -716,15 +725,18 @@ export declare class DecoratorNode<X> extends LexicalNode {
|
|
|
716
725
|
constructor(key?: NodeKey);
|
|
717
726
|
decorate(editor: LexicalEditor): X;
|
|
718
727
|
isIsolated(): boolean;
|
|
728
|
+
isTopLevel(): boolean;
|
|
719
729
|
}
|
|
720
|
-
export function $isDecoratorNode(
|
|
730
|
+
export function $isDecoratorNode(
|
|
731
|
+
node: LexicalNode | null | undefined,
|
|
732
|
+
): node is DecoratorNode<unknown>;
|
|
721
733
|
|
|
722
734
|
/**
|
|
723
735
|
* LexicalHorizontalRuleNode
|
|
724
736
|
*/
|
|
725
737
|
export declare class HorizontalRuleNode extends LexicalNode {
|
|
726
|
-
getType(): string;
|
|
727
|
-
clone(node: HorizontalRuleNode): HorizontalRuleNode;
|
|
738
|
+
static getType(): string;
|
|
739
|
+
static clone(node: HorizontalRuleNode): HorizontalRuleNode;
|
|
728
740
|
constructor(key?: NodeKey);
|
|
729
741
|
createDOM(): HTMLElement;
|
|
730
742
|
updateDOM(): false;
|
|
@@ -747,16 +759,24 @@ export declare class ParagraphNode extends ElementNode {
|
|
|
747
759
|
collapseAtStart(): boolean;
|
|
748
760
|
}
|
|
749
761
|
export function $createParagraphNode(): ParagraphNode;
|
|
750
|
-
export function $isParagraphNode(
|
|
762
|
+
export function $isParagraphNode(
|
|
763
|
+
node: LexicalNode | null | undefined,
|
|
764
|
+
): node is ParagraphNode;
|
|
751
765
|
export declare class GridNode extends ElementNode {}
|
|
752
|
-
export function $isGridNode(
|
|
766
|
+
export function $isGridNode(
|
|
767
|
+
node: LexicalNode | null | undefined,
|
|
768
|
+
): node is GridNode;
|
|
753
769
|
export declare class GridRowNode extends ElementNode {}
|
|
754
|
-
export function $isGridRowNode(
|
|
770
|
+
export function $isGridRowNode(
|
|
771
|
+
node: LexicalNode | null | undefined,
|
|
772
|
+
): node is GridRowNode;
|
|
755
773
|
export declare class GridCellNode extends ElementNode {
|
|
756
774
|
__colSpan: number;
|
|
757
775
|
constructor(colSpan: number, key?: NodeKey);
|
|
758
776
|
}
|
|
759
|
-
export function $isGridCellNode(
|
|
777
|
+
export function $isGridCellNode(
|
|
778
|
+
node: LexicalNode | null | undefined,
|
|
779
|
+
): node is GridCellNode;
|
|
760
780
|
|
|
761
781
|
/**
|
|
762
782
|
* LexicalUtils
|