lexical 0.1.21 → 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.js.flow CHANGED
@@ -151,6 +151,7 @@ declare export class LexicalEditor {
151
151
  ): () => void;
152
152
  dispatchCommand<P>(command: LexicalCommand<P>, payload?: P): boolean;
153
153
  hasNodes(nodes: Array<Class<LexicalNode>>): boolean;
154
+ getKey(): string;
154
155
  getDecorators<X>(): {
155
156
  [NodeKey]: X,
156
157
  };
@@ -587,140 +588,6 @@ declare export function $getPreviousSelection():
587
588
  | NodeSelection
588
589
  | GridSelection;
589
590
 
590
- /**
591
- * Decorator State
592
- */
593
-
594
- export type DecoratorStateValue =
595
- | DecoratorMap
596
- | DecoratorEditor
597
- | DecoratorArray
598
- | null
599
- | boolean
600
- | number
601
- | string;
602
-
603
- declare export class DecoratorEditor {
604
- id: string;
605
- editorState: null | EditorState | string;
606
- editor: null | LexicalEditor;
607
-
608
- constructor(id?: string, editorState?: string | EditorState): void;
609
-
610
- init(editor: LexicalEditor): void;
611
-
612
- set(editor: LexicalEditor): void;
613
-
614
- toJSON(): $ReadOnly<{
615
- id: string,
616
- type: 'editor',
617
- editorState: null | string,
618
- }>;
619
-
620
- isEmpty(): boolean;
621
- }
622
-
623
- export type DecoratorMapObserver = (
624
- key: string,
625
- value: DecoratorStateValue,
626
- ) => void;
627
-
628
- export type DecoratorArrayObserver = (
629
- index: number,
630
- delCont: number,
631
- value: void | DecoratorStateValue,
632
- ) => void;
633
-
634
- declare export class DecoratorMap {
635
- _editor: LexicalEditor;
636
- _map: Map<string, DecoratorStateValue>;
637
-
638
- constructor(
639
- editor: LexicalEditor,
640
- map?: Map<string, DecoratorStateValue>,
641
- ): void;
642
-
643
- get(key: string): void | DecoratorStateValue;
644
-
645
- has(key: string): boolean;
646
-
647
- set(key: string, value: DecoratorStateValue): void;
648
-
649
- observe(observer: DecoratorMapObserver): () => void;
650
-
651
- destroy(): void;
652
-
653
- toJSON(): $ReadOnly<{
654
- type: 'map',
655
- map: Array<[string, DecoratorStateValue]>,
656
- }>;
657
- }
658
-
659
- declare export function createDecoratorEditor(
660
- id?: string,
661
- editorState?: string | EditorState,
662
- ): DecoratorEditor;
663
-
664
- declare export function isDecoratorEditor(
665
- obj: ?mixed,
666
- ): boolean %checks(obj instanceof DecoratorEditor);
667
-
668
- declare export function createDecoratorMap(
669
- editor: LexicalEditor,
670
- map?: Map<string, DecoratorStateValue>,
671
- ): DecoratorMap;
672
-
673
- declare export function isDecoratorMap(
674
- obj: ?mixed,
675
- ): boolean %checks(obj instanceof DecoratorMap);
676
-
677
- declare export class DecoratorArray {
678
- _editor: LexicalEditor;
679
- _observers: Set<DecoratorArrayObserver>;
680
- _array: Array<DecoratorStateValue>;
681
-
682
- constructor(editor: LexicalEditor, array?: Array<DecoratorStateValue>): void;
683
-
684
- observe(observer: DecoratorArrayObserver): () => void;
685
-
686
- map<V>(
687
- fn: (DecoratorStateValue, number, Array<DecoratorStateValue>) => V,
688
- ): Array<V>;
689
-
690
- reduce(
691
- fn: (DecoratorStateValue, DecoratorStateValue) => DecoratorStateValue,
692
- initial?: DecoratorStateValue,
693
- ): DecoratorStateValue | void;
694
-
695
- push(value: DecoratorStateValue): void;
696
-
697
- getLength(): number;
698
-
699
- splice(
700
- insertIndex: number,
701
- delCount: number,
702
- value?: DecoratorStateValue,
703
- ): void;
704
-
705
- indexOf(value: DecoratorStateValue): number;
706
-
707
- destroy(): void;
708
-
709
- toJSON(): $ReadOnly<{
710
- type: 'array',
711
- array: Array<DecoratorStateValue>,
712
- }>;
713
- }
714
-
715
- declare export function createDecoratorArray(
716
- editor: LexicalEditor,
717
- list?: Array<DecoratorStateValue>,
718
- ): DecoratorArray;
719
-
720
- declare export function isDecoratorArray(
721
- x?: mixed,
722
- ): boolean %checks(x instanceof DecoratorArray);
723
-
724
591
  /**
725
592
  * LexicalTextNode
726
593
  */
@@ -897,8 +764,7 @@ declare export function $isElementNode(
897
764
  */
898
765
 
899
766
  declare export class DecoratorNode<X> extends LexicalNode {
900
- __state: DecoratorMap;
901
- constructor(state?: DecoratorMap, key?: NodeKey): void;
767
+ constructor(key?: NodeKey): void;
902
768
  decorate(editor: LexicalEditor): X;
903
769
  isIsolated(): boolean;
904
770
  }