lexical 0.4.0 → 0.5.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.js.flow CHANGED
@@ -357,11 +357,8 @@ declare export class LexicalNode {
357
357
  getLatest<T: LexicalNode>(this: T): T;
358
358
  // $FlowFixMe
359
359
  getWritable<T: LexicalNode>(this: T): T;
360
- getTextContent(includeInert?: boolean, includeDirectionless?: false): string;
361
- getTextContentSize(
362
- includeInert?: boolean,
363
- includeDirectionless?: false,
364
- ): number;
360
+ getTextContent(includeDirectionless?: boolean): string;
361
+ getTextContentSize(includeDirectionless?: boolean): number;
365
362
  createDOM(config: EditorConfig, editor: LexicalEditor): HTMLElement;
366
363
  updateDOM(
367
364
  // $FlowFixMe
@@ -418,36 +415,24 @@ declare export class GridSelection implements BaseSelection {
418
415
  getTextContent(): string;
419
416
  }
420
417
 
421
- declare export function $isGridSelection(
418
+ declare export function DEPRECATED_$isGridSelection(
422
419
  x: ?mixed,
423
420
  ): boolean %checks(x instanceof GridSelection);
424
421
 
425
422
  declare export class NodeSelection implements BaseSelection {
426
423
  _nodes: Set<NodeKey>;
427
424
  dirty: boolean;
428
-
429
425
  constructor(objects: Set<NodeKey>): void;
430
-
431
426
  is(selection: null | RangeSelection | NodeSelection | GridSelection): boolean;
432
-
433
427
  add(key: NodeKey): void;
434
-
435
428
  delete(key: NodeKey): void;
436
-
437
429
  clear(): void;
438
-
439
430
  has(key: NodeKey): boolean;
440
-
441
431
  clone(): NodeSelection;
442
-
443
432
  extract(): Array<LexicalNode>;
444
-
445
433
  insertRawText(): void;
446
-
447
434
  insertText(): void;
448
-
449
435
  getNodes(): Array<LexicalNode>;
450
-
451
436
  getTextContent(): string;
452
437
  }
453
438
 
@@ -533,7 +518,7 @@ declare class _Point {
533
518
 
534
519
  declare export function $createRangeSelection(): RangeSelection;
535
520
  declare export function $createNodeSelection(): NodeSelection;
536
- declare export function $createGridSelection(): GridSelection;
521
+ declare export function DEPRECATED_$createGridSelection(): GridSelection;
537
522
  declare export function $isRangeSelection(
538
523
  x: ?mixed,
539
524
  ): boolean %checks(x instanceof RangeSelection);
@@ -547,6 +532,10 @@ declare export function $getPreviousSelection():
547
532
  | RangeSelection
548
533
  | NodeSelection
549
534
  | GridSelection;
535
+ declare export function $insertNodes(
536
+ nodes: Array<LexicalNode>,
537
+ selectStart?: boolean,
538
+ ): boolean;
550
539
 
551
540
  /**
552
541
  * LexicalTextNode
@@ -560,7 +549,7 @@ export type TextFormatType =
560
549
  | 'code'
561
550
  | 'subscript'
562
551
  | 'superscript';
563
- type TextModeType = 'normal' | 'token' | 'segmented' | 'inert';
552
+ type TextModeType = 'normal' | 'token' | 'segmented';
564
553
 
565
554
  declare export class TextNode extends LexicalNode {
566
555
  __text: string;
@@ -576,12 +565,11 @@ declare export class TextNode extends LexicalNode {
576
565
  isComposing(): boolean;
577
566
  isToken(): boolean;
578
567
  isSegmented(): boolean;
579
- isInert(): boolean;
580
568
  isDirectionless(): boolean;
581
569
  isUnmergeable(): boolean;
582
570
  hasFormat(type: TextFormatType): boolean;
583
571
  isSimpleText(): boolean;
584
- getTextContent(includeInert?: boolean, includeDirectionless?: false): string;
572
+ getTextContent(): string;
585
573
  getFormatFlags(type: TextFormatType, alignWithFormat: null | number): number;
586
574
  createDOM(config: EditorConfig): HTMLElement;
587
575
  updateDOM(
@@ -653,7 +641,7 @@ declare export class RootNode extends ElementNode {
653
641
  static getType(): string;
654
642
  static clone(): RootNode;
655
643
  constructor(): void;
656
- getTextContent(includeInert?: boolean, includeDirectionless?: false): string;
644
+ getTextContent(): string;
657
645
  select(): RangeSelection;
658
646
  remove(): void;
659
647
  replace<N: LexicalNode>(node: N): N;
@@ -686,15 +674,16 @@ declare export class ElementNode extends LexicalNode {
686
674
  getChildrenSize(): number;
687
675
  isEmpty(): boolean;
688
676
  isDirty(): boolean;
689
- getAllTextNodes(includeInert?: boolean): Array<TextNode>;
677
+ getAllTextNodes(): Array<TextNode>;
690
678
  getFirstDescendant<T: LexicalNode>(): null | T;
691
679
  getLastDescendant<T: LexicalNode>(): null | T;
692
680
  getDescendantByIndex<T: LexicalNode>(index: number): null | T;
693
681
  getFirstChild<T: LexicalNode>(): null | T;
694
682
  getFirstChildOrThrow<T: LexicalNode>(): T;
695
683
  getLastChild<T: LexicalNode>(): null | T;
684
+ getLastChildOrThrow<T: LexicalNode>(): T;
696
685
  getChildAtIndex<T: LexicalNode>(index: number): null | T;
697
- getTextContent(includeInert?: boolean, includeDirectionless?: false): string;
686
+ getTextContent(): string;
698
687
  getDirection(): 'ltr' | 'rtl' | null;
699
688
  hasFormat(type: ElementFormatType): boolean;
700
689
  select(_anchorOffset?: number, _focusOffset?: number): RangeSelection;
@@ -722,6 +711,7 @@ declare export class ElementNode extends LexicalNode {
722
711
  canInsertTextBefore(): boolean;
723
712
  canInsertTextAfter(): boolean;
724
713
  isInline(): boolean;
714
+ isShadowRoot(): boolean;
725
715
  canSelectionRemove(): boolean;
726
716
  splice(
727
717
  start: number,
@@ -742,7 +732,7 @@ declare export class DecoratorNode<X> extends LexicalNode {
742
732
  constructor(key?: NodeKey): void;
743
733
  decorate(editor: LexicalEditor, config: EditorConfig): X;
744
734
  isIsolated(): boolean;
745
- isTopLevel(): boolean;
735
+ isInline(): boolean;
746
736
  }
747
737
  declare export function $isDecoratorNode(
748
738
  node: ?LexicalNode,
@@ -769,31 +759,32 @@ declare export function $isParagraphNode(
769
759
  node: ?LexicalNode,
770
760
  ): boolean %checks(node instanceof ParagraphNode);
771
761
 
772
- declare export class GridNode extends ElementNode {}
762
+ declare export class deprecated_GridNode extends ElementNode {}
773
763
 
774
- declare export function $isGridNode(
764
+ declare export function DEPRECATED_$isGridNode(
775
765
  node: ?LexicalNode,
776
- ): boolean %checks(node instanceof GridNode);
766
+ ): boolean %checks(node instanceof deprecated_GridNode);
777
767
 
778
- declare export class GridRowNode extends ElementNode {}
768
+ declare export class deprecated_GridRowNode extends ElementNode {}
779
769
 
780
- declare export function $isGridRowNode(
770
+ declare export function DEPRECATED_$isGridRowNode(
781
771
  node: ?LexicalNode,
782
- ): boolean %checks(node instanceof GridRowNode);
772
+ ): boolean %checks(node instanceof deprecated_GridRowNode);
783
773
 
784
- declare export class GridCellNode extends ElementNode {
774
+ declare export class deprecated_GridCellNode extends ElementNode {
785
775
  __colSpan: number;
786
776
 
787
777
  constructor(colSpan: number, key?: NodeKey): void;
788
778
  }
789
779
 
790
- declare export function $isGridCellNode(
780
+ declare export function DEPRECATED_$isGridCellNode(
791
781
  node: ?LexicalNode,
792
- ): boolean %checks(node instanceof GridCellNode);
782
+ ): boolean %checks(node instanceof deprecated_GridCellNode);
793
783
 
794
784
  /**
795
785
  * LexicalUtils
796
786
  */
787
+ export type EventHandler = (event: Event, editor: LexicalEditor) => void;
797
788
  declare export function $hasUpdateTag(tag: string): boolean;
798
789
  declare export function $addUpdateTag(tag: string): void;
799
790
  declare export function $getNearestNodeFromDOMNode(
@@ -818,7 +809,17 @@ declare export function $getDecoratorNode(
818
809
  isBackward: boolean,
819
810
  ): null | LexicalNode;
820
811
  declare export function generateRandomKey(): string;
821
- export type EventHandler = (event: Event, editor: LexicalEditor) => void;
812
+ declare export function $isInlineElementOrDecoratorNode(
813
+ node: LexicalNode,
814
+ ): boolean %checks(node instanceof ElementNode ||
815
+ node instanceof DecoratorNode);
816
+ declare export function $isRootOrShadowRoot(
817
+ node: LexicalNode,
818
+ ): boolean %checks(node instanceof RootNode || node instanceof ElementNode);
819
+ declare export function $hasAncestor(
820
+ child: LexicalNode,
821
+ targetNode: LexicalNode,
822
+ ): boolean;
822
823
 
823
824
  /**
824
825
  * LexicalVersion