lexical 0.2.0 → 0.2.3

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
@@ -31,11 +31,12 @@ export var KEY_ARROW_RIGHT_COMMAND: LexicalCommand<KeyboardEvent>;
31
31
  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
- export var KEY_ENTER_COMMAND: LexicalCommand<KeyboardEvent>;
34
+ export var KEY_ENTER_COMMAND: LexicalCommand<KeyboardEvent | null>;
35
35
  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 CommandListenerEditorPriority = 0;
226
- export type CommandListenerLowPriority = 1;
227
- export type CommandListenerNormalPriority = 2;
228
- export type CommandListenerHighPriority = 3;
229
- export type CommandListenerCriticalPriority = 4;
230
- type CommandListenerPriority =
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: ?(LexicalNode | null),
302
- ) => ?(LexicalNode | void | null);
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: ?HTMLElement) => ?HTMLElement;
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;
@@ -569,8 +564,8 @@ export declare class TextNode extends LexicalNode {
569
564
  __style: string;
570
565
  __mode: 0 | 1 | 2 | 3;
571
566
  __detail: number;
572
- getType(): string;
573
- clone(node: any): TextNode;
567
+ static getType(): string;
568
+ static clone(node: any): TextNode;
574
569
  constructor(text: string, key?: NodeKey);
575
570
  getFormat(): number;
576
571
  getStyle(): string;
@@ -623,8 +618,8 @@ export function $isTextNode(node: LexicalNode | null | undefined): boolean;
623
618
  * LexicalLineBreakNode
624
619
  */
625
620
  export declare class LineBreakNode extends LexicalNode {
626
- getType(): string;
627
- clone(node: LineBreakNode): LineBreakNode;
621
+ static getType(): string;
622
+ static clone(node: LineBreakNode): LineBreakNode;
628
623
  constructor(key?: NodeKey);
629
624
  getTextContent(): '\n';
630
625
  createDOM(): HTMLElement;
@@ -638,8 +633,8 @@ export function $isLineBreakNode(node: LexicalNode | null | undefined): boolean;
638
633
  */
639
634
  export declare class RootNode extends ElementNode {
640
635
  __cachedText: null | string;
641
- getType(): string;
642
- clone(): RootNode;
636
+ static getType(): string;
637
+ static clone(): RootNode;
643
638
  constructor();
644
639
  getTextContent(includeInert?: boolean, includeDirectionless?: false): string;
645
640
  select(): RangeSelection;
@@ -723,8 +718,8 @@ export function $isDecoratorNode(node: LexicalNode | null | undefined): boolean;
723
718
  * LexicalHorizontalRuleNode
724
719
  */
725
720
  export declare class HorizontalRuleNode extends LexicalNode {
726
- getType(): string;
727
- clone(node: HorizontalRuleNode): HorizontalRuleNode;
721
+ static getType(): string;
722
+ static clone(node: HorizontalRuleNode): HorizontalRuleNode;
728
723
  constructor(key?: NodeKey);
729
724
  createDOM(): HTMLElement;
730
725
  updateDOM(): false;