lexical 0.2.5 → 0.2.6

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 CHANGED
@@ -32,6 +32,7 @@ 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
34
  export var KEY_ENTER_COMMAND: LexicalCommand<KeyboardEvent | null>;
35
+ export var KEY_SPACE_COMMAND: LexicalCommand<KeyboardEvent>;
35
36
  export var KEY_BACKSPACE_COMMAND: LexicalCommand<KeyboardEvent>;
36
37
  export var KEY_ESCAPE_COMMAND: LexicalCommand<KeyboardEvent>;
37
38
  export var KEY_DELETE_COMMAND: LexicalCommand<KeyboardEvent>;
@@ -63,7 +64,7 @@ export declare function createCommand<T>(): LexicalCommand<T>;
63
64
  */
64
65
  type ErrorHandler = (error: Error) => void;
65
66
  type MutationListeners = Map<MutationListener, Class<LexicalNode>>;
66
- export type NodeMutation = 'created' | 'destroyed';
67
+ export type NodeMutation = 'created' | 'updated' | 'destroyed';
67
68
  type UpdateListener = (arg0: {
68
69
  tags: Set<string>;
69
70
  prevEditorState: EditorState;
@@ -146,7 +147,7 @@ export declare class LexicalEditor {
146
147
  klass: Class<T>,
147
148
  listener: Transform<T>,
148
149
  ): () => void;
149
- dispatchCommand<P>(type: string, payload: P): boolean;
150
+ dispatchCommand<P>(type: LexicalCommand<P>, payload: P): boolean;
150
151
  hasNodes(nodes: Array<Class<LexicalNode>>): boolean;
151
152
  getDecorators<X>(): Record<NodeKey, X>;
152
153
  getRootElement(): null | HTMLElement;
@@ -154,7 +155,9 @@ export declare class LexicalEditor {
154
155
  getElementByKey(key: NodeKey): null | HTMLElement;
155
156
  getEditorState(): EditorState;
156
157
  setEditorState(editorState: EditorState, options?: EditorSetOptions): void;
157
- parseEditorState(stringifiedEditorState: string): EditorState;
158
+ parseEditorState(
159
+ maybeStringifiedEditorState: string | ParsedEditorState,
160
+ ): EditorState;
158
161
  update(updateFn: () => void, options?: EditorUpdateOptions): boolean;
159
162
  focus(callbackFn?: () => void): void;
160
163
  blur(): void;
@@ -178,11 +181,12 @@ type TextNodeThemeClasses = {
178
181
  underlineStrikethrough?: EditorThemeClassName;
179
182
  italic?: EditorThemeClassName;
180
183
  code?: EditorThemeClassName;
184
+ subscript?: EditorThemeClassName;
185
+ superscript?: EditorThemeClassName;
181
186
  };
182
187
  export type EditorThemeClasses = {
183
188
  ltr?: EditorThemeClassName;
184
189
  rtl?: EditorThemeClassName;
185
- root?: EditorThemeClassName;
186
190
  text?: TextNodeThemeClasses;
187
191
  paragraph?: EditorThemeClassName;
188
192
  image?: EditorThemeClassName;
@@ -192,6 +196,8 @@ export type EditorThemeClasses = {
192
196
  ol?: EditorThemeClassName;
193
197
  olDepth?: Array<EditorThemeClassName>;
194
198
  listitem?: EditorThemeClassName;
199
+ listitemChecked?: EditorThemeClassName;
200
+ listitemUnchecked?: EditorThemeClassName;
195
201
  nested?: {
196
202
  list?: EditorThemeClassName;
197
203
  listitem?: EditorThemeClassName;
@@ -201,6 +207,8 @@ export type EditorThemeClasses = {
201
207
  tableRow?: EditorThemeClassName;
202
208
  tableCell?: EditorThemeClassName;
203
209
  tableCellHeader?: EditorThemeClassName;
210
+ mark?: EditorThemeClassName;
211
+ markOverlap?: EditorThemeClassName;
204
212
  link?: EditorThemeClassName;
205
213
  quote?: EditorThemeClassName;
206
214
  code?: EditorThemeClassName;
@@ -298,8 +306,8 @@ export type DOMConversionFn = (
298
306
  ) => DOMConversionOutput;
299
307
  export type DOMChildConversion = (
300
308
  lexicalNode: LexicalNode,
301
- parentLexicalNode: LexicalNode | null,
302
- ) => LexicalNode | void | null;
309
+ parentLexicalNode: LexicalNode | null | undefined,
310
+ ) => LexicalNode | null;
303
311
  export type DOMConversionMap = Record<
304
312
  NodeName,
305
313
  (node: Node) => DOMConversion | null
@@ -344,7 +352,6 @@ export declare class LexicalNode {
344
352
  isParentOf(targetNode: LexicalNode): boolean;
345
353
  getNodesBetween(targetNode: LexicalNode): Array<LexicalNode>;
346
354
  isDirty(): boolean;
347
- isComposing(): boolean;
348
355
  // $FlowFixMe
349
356
  getLatest<T extends LexicalNode>(): T;
350
357
  // $FlowFixMe
@@ -558,24 +565,19 @@ export type TextFormatType =
558
565
  | 'subscript'
559
566
  | 'superscript';
560
567
  type TextModeType = 'normal' | 'token' | 'segmented' | 'inert';
561
- export type TextMark = {end: null | number; id: string; start: null | number};
562
568
 
563
- export type TextMarks = Array<TextMark>;
564
569
  export declare class TextNode extends LexicalNode {
565
570
  __text: string;
566
571
  __format: number;
567
572
  __style: string;
568
573
  __mode: 0 | 1 | 2 | 3;
569
574
  __detail: number;
570
- __marks: null | TextMarks;
571
575
  static getType(): string;
572
576
  static clone(node: any): TextNode;
573
577
  constructor(text: string, key?: NodeKey);
574
- getMark(id: string): null | TextMark;
575
- setMark(id: string, start: null | number, end: null | number): void;
576
- deleteMark(id: string): void;
577
578
  getFormat(): number;
578
579
  getStyle(): string;
580
+ isComposing(): boolean;
579
581
  isToken(): boolean;
580
582
  isSegmented(): boolean;
581
583
  isInert(): boolean;
@@ -618,7 +620,7 @@ export declare class TextNode extends LexicalNode {
618
620
  }
619
621
  export function $createTextNode(text?: string): TextNode;
620
622
  export function $isTextNode(
621
- node: LexicalNode | null | undefined,
623
+ node: TextNode | LexicalNode | null | undefined,
622
624
  ): node is TextNode;
623
625
 
624
626
  /**
@@ -699,10 +701,15 @@ export declare class ElementNode extends LexicalNode {
699
701
  canInsertTab(): boolean;
700
702
  canIndent(): boolean;
701
703
  collapseAtStart(selection: RangeSelection): boolean;
702
- excludeFromCopy(): boolean;
704
+ excludeFromCopy(destination: 'clone' | 'html'): boolean;
703
705
  canExtractContents(): boolean;
704
706
  canReplaceWith(replacement: LexicalNode): boolean;
705
707
  canInsertAfter(node: LexicalNode): boolean;
708
+ extractWithChild(
709
+ child: LexicalNode,
710
+ selection: RangeSelection | NodeSelection | GridSelection,
711
+ destination: 'clone' | 'html',
712
+ ): boolean;
706
713
  canBeEmpty(): boolean;
707
714
  canInsertTextBefore(): boolean;
708
715
  canInsertTextAfter(): boolean;
@@ -771,7 +778,9 @@ export function $getNearestNodeFromDOMNode(
771
778
  ): LexicalNode | null;
772
779
  export function $getNodeByKey<N extends LexicalNode>(key: NodeKey): N | null;
773
780
  export function $getRoot(): RootNode;
774
- export function $isLeafNode(node: LexicalNode | null | undefined): boolean;
781
+ export function $isLeafNode(
782
+ node: LexicalNode | null | undefined,
783
+ ): node is TextNode | LineBreakNode | DecoratorNode<unknown>;
775
784
  export function $setCompositionKey(compositionKey: null | NodeKey): void;
776
785
  export function $setSelection(
777
786
  selection: null | RangeSelection | NodeSelection | GridSelection,