lexical 0.3.7 → 0.3.10

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.
@@ -12,8 +12,8 @@ export declare const CLICK_COMMAND: LexicalCommand<MouseEvent>;
12
12
  export declare const DELETE_CHARACTER_COMMAND: LexicalCommand<boolean>;
13
13
  export declare const INSERT_LINE_BREAK_COMMAND: LexicalCommand<boolean>;
14
14
  export declare const INSERT_PARAGRAPH_COMMAND: LexicalCommand<void>;
15
- export declare const CONTROLLED_TEXT_INSERTION_COMMAND: LexicalCommand<string>;
16
- export declare const PASTE_COMMAND: LexicalCommand<ClipboardEvent>;
15
+ export declare const CONTROLLED_TEXT_INSERTION_COMMAND: LexicalCommand<InputEvent | string>;
16
+ export declare const PASTE_COMMAND: LexicalCommand<ClipboardEvent | InputEvent>;
17
17
  export declare const REMOVE_TEXT_COMMAND: LexicalCommand<void>;
18
18
  export declare const DELETE_WORD_COMMAND: LexicalCommand<boolean>;
19
19
  export declare const DELETE_LINE_COMMAND: LexicalCommand<boolean>;
@@ -39,8 +39,8 @@ export declare const FORMAT_ELEMENT_COMMAND: LexicalCommand<ElementFormatType>;
39
39
  export declare const DRAGSTART_COMMAND: LexicalCommand<DragEvent>;
40
40
  export declare const DRAGOVER_COMMAND: LexicalCommand<DragEvent>;
41
41
  export declare const DRAGEND_COMMAND: LexicalCommand<DragEvent>;
42
- export declare const COPY_COMMAND: LexicalCommand<ClipboardEvent>;
43
- export declare const CUT_COMMAND: LexicalCommand<ClipboardEvent>;
42
+ export declare const COPY_COMMAND: LexicalCommand<ClipboardEvent | KeyboardEvent>;
43
+ export declare const CUT_COMMAND: LexicalCommand<ClipboardEvent | KeyboardEvent>;
44
44
  export declare const CLEAR_EDITOR_COMMAND: LexicalCommand<void>;
45
45
  export declare const CLEAR_HISTORY_COMMAND: LexicalCommand<void>;
46
46
  export declare const CAN_REDO_COMMAND: LexicalCommand<boolean>;
@@ -23,6 +23,7 @@ export declare const IS_UNDERLINE: number;
23
23
  export declare const IS_CODE: number;
24
24
  export declare const IS_SUBSCRIPT: number;
25
25
  export declare const IS_SUPERSCRIPT: number;
26
+ export declare const IS_ALL_FORMATTING: number;
26
27
  export declare const IS_DIRECTIONLESS = 1;
27
28
  export declare const IS_UNMERGEABLE: number;
28
29
  export declare const IS_ALIGN_LEFT = 1;
@@ -106,7 +106,10 @@ export declare type UpdateListener = (arg0: {
106
106
  export declare type DecoratorListener<T = never> = (decorator: Record<NodeKey, T>) => void;
107
107
  export declare type RootListener = (rootElement: null | HTMLElement, prevRootElement: null | HTMLElement) => void;
108
108
  export declare type TextContentListener = (text: string) => void;
109
- export declare type MutationListener = (nodes: Map<NodeKey, NodeMutation>) => void;
109
+ export declare type MutationListener = (nodes: Map<NodeKey, NodeMutation>, payload: {
110
+ updateTags: Set<string>;
111
+ dirtyLeaves: Set<string>;
112
+ }) => void;
110
113
  export declare type CommandListener<P> = (payload: P, editor: LexicalEditor) => boolean;
111
114
  export declare type ReadOnlyListener = (readOnly: boolean) => void;
112
115
  export declare type CommandListenerPriority = 0 | 1 | 2 | 3 | 4;
@@ -115,7 +118,28 @@ export declare const COMMAND_PRIORITY_LOW = 1;
115
118
  export declare const COMMAND_PRIORITY_NORMAL = 2;
116
119
  export declare const COMMAND_PRIORITY_HIGH = 3;
117
120
  export declare const COMMAND_PRIORITY_CRITICAL = 4;
118
- export declare type LexicalCommand<T = never> = Readonly<Record<string, unknown>>;
121
+ export declare type LexicalCommand<TPayload> = Record<string, never>;
122
+ /**
123
+ * Type helper for extracting the payload type from a command.
124
+ *
125
+ * @example
126
+ * ```ts
127
+ * const MY_COMMAND = createCommand<SomeType>();
128
+ *
129
+ * // ...
130
+ *
131
+ * editor.registerCommand(MY_COMMAND, payload => {
132
+ * // Type of `payload` is inferred here. But lets say we want to extract a function to delegate to
133
+ * handleMyCommand(editor, payload);
134
+ * return true;
135
+ * });
136
+ *
137
+ * function handleMyCommand(editor: LexicalEditor, payload: CommandPayloadType<typeof MY_COMMAND>) {
138
+ * // `payload` is of type `SomeType`, extracted from the command.
139
+ * }
140
+ * ```
141
+ */
142
+ export declare type CommandPayloadType<TCommand extends LexicalCommand<unknown>> = TCommand extends LexicalCommand<infer TPayload> ? TPayload : never;
119
143
  declare type Commands = Map<LexicalCommand<unknown>, Array<Set<CommandListener<unknown>>>>;
120
144
  declare type Listeners = {
121
145
  decorator: Set<DecoratorListener>;
@@ -183,7 +207,7 @@ export declare class LexicalEditor {
183
207
  registerMutationListener(klass: Klass<LexicalNode>, listener: MutationListener): () => void;
184
208
  registerNodeTransform<T extends LexicalNode>(klass: Klass<T>, listener: Transform<T>): () => void;
185
209
  hasNodes<T extends Klass<LexicalNode>>(nodes: Array<T>): boolean;
186
- dispatchCommand<P>(type: LexicalCommand<P>, payload: P): boolean;
210
+ dispatchCommand<TCommand extends LexicalCommand<unknown>, TPayload extends CommandPayloadType<TCommand>>(type: TCommand, payload: TPayload): boolean;
187
211
  getDecorators<T>(): Record<NodeKey, T>;
188
212
  getRootElement(): null | HTMLElement;
189
213
  getKey(): string;
package/LexicalUtils.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
- import type { EditorThemeClasses, Klass, LexicalCommand, MutatedNodes, MutationListeners, NodeMutation, RegisteredNode, RegisteredNodes } from './LexicalEditor';
8
+ import type { CommandPayloadType, EditorThemeClasses, Klass, LexicalCommand, MutatedNodes, MutationListeners, NodeMutation, RegisteredNode, RegisteredNodes } from './LexicalEditor';
9
9
  import type { EditorState } from './LexicalEditorState';
10
10
  import type { LexicalNode, NodeKey } from './LexicalNode';
11
11
  import type { GridSelection, NodeSelection, PointType, RangeSelection } from './LexicalSelection';
@@ -48,7 +48,7 @@ export declare function getTextNodeOffset(node: TextNode, moveSelectionToEnd: bo
48
48
  export declare function doesContainGrapheme(str: string): boolean;
49
49
  export declare function getEditorsToPropagate(editor: LexicalEditor): Array<LexicalEditor>;
50
50
  export declare function createUID(): string;
51
- export declare function $updateSelectedTextFromDOM(editor: LexicalEditor, isCompositionEnd: boolean, data?: string): void;
51
+ export declare function $updateSelectedTextFromDOM(isCompositionEnd: boolean, data?: string): void;
52
52
  export declare function $updateTextNodeFromDOMContent(textNode: TextNode, textContent: string, anchorOffset: null | number, focusOffset: null | number, compositionEnd: boolean): void;
53
53
  export declare function $shouldPreventDefaultAndInsertText(selection: RangeSelection, text: string): boolean;
54
54
  export declare function isTab(keyCode: number, altKey: boolean, ctrlKey: boolean, metaKey: boolean): boolean;
@@ -68,12 +68,12 @@ export declare function isUndo(keyCode: number, shiftKey: boolean, metaKey: bool
68
68
  export declare function isRedo(keyCode: number, shiftKey: boolean, metaKey: boolean, ctrlKey: boolean): boolean;
69
69
  export declare function isCopy(keyCode: number, shiftKey: boolean, metaKey: boolean, ctrlKey: boolean): boolean;
70
70
  export declare function isCut(keyCode: number, shiftKey: boolean, metaKey: boolean, ctrlKey: boolean): boolean;
71
- export declare function isMoveBackward(keyCode: number, ctrlKey: boolean, shiftKey: boolean, altKey: boolean, metaKey: boolean): boolean;
71
+ export declare function isMoveBackward(keyCode: number, ctrlKey: boolean, altKey: boolean, metaKey: boolean): boolean;
72
72
  export declare function isMoveToStart(keyCode: number, ctrlKey: boolean, shiftKey: boolean, altKey: boolean, metaKey: boolean): boolean;
73
- export declare function isMoveForward(keyCode: number, ctrlKey: boolean, shiftKey: boolean, altKey: boolean, metaKey: boolean): boolean;
73
+ export declare function isMoveForward(keyCode: number, ctrlKey: boolean, altKey: boolean, metaKey: boolean): boolean;
74
74
  export declare function isMoveToEnd(keyCode: number, ctrlKey: boolean, shiftKey: boolean, altKey: boolean, metaKey: boolean): boolean;
75
- export declare function isMoveUp(keyCode: number, ctrlKey: boolean, shiftKey: boolean, altKey: boolean, metaKey: boolean): boolean;
76
- export declare function isMoveDown(keyCode: number, ctrlKey: boolean, shiftKey: boolean, altKey: boolean, metaKey: boolean): boolean;
75
+ export declare function isMoveUp(keyCode: number, ctrlKey: boolean, metaKey: boolean): boolean;
76
+ export declare function isMoveDown(keyCode: number, ctrlKey: boolean, metaKey: boolean): boolean;
77
77
  export declare function isModifier(ctrlKey: boolean, shiftKey: boolean, altKey: boolean, metaKey: boolean): boolean;
78
78
  export declare function isSpace(keyCode: number): boolean;
79
79
  export declare function controlOrMeta(metaKey: boolean, ctrlKey: boolean): boolean;
@@ -86,9 +86,10 @@ export declare function setMutatedNode(mutatedNodes: MutatedNodes, registeredNod
86
86
  export declare function $nodesOfType<T extends LexicalNode>(klass: Klass<T>): Array<LexicalNode>;
87
87
  export declare function $getDecoratorNode(focus: PointType, isBackward: boolean): null | LexicalNode;
88
88
  export declare function isFirefoxClipboardEvents(): boolean;
89
- export declare function dispatchCommand<P>(editor: LexicalEditor, type: LexicalCommand<P>, payload: P): boolean;
89
+ export declare function dispatchCommand<TCommand extends LexicalCommand<unknown>, TPayload extends CommandPayloadType<TCommand>>(editor: LexicalEditor, type: TCommand, payload: TPayload): boolean;
90
90
  export declare function $textContentRequiresDoubleLinebreakAtEnd(node: ElementNode): boolean;
91
91
  export declare function getElementByKeyOrThrow(editor: LexicalEditor, key: NodeKey): HTMLElement;
92
92
  export declare function scrollIntoViewIfNeeded(editor: LexicalEditor, anchor: PointType, rootElement: HTMLElement, tags: Set<string>): void;
93
93
  export declare function $hasUpdateTag(tag: string): boolean;
94
94
  export declare function $addUpdateTag(tag: string): void;
95
+ export declare function $maybeMoveChildrenSelectionToParent(parentNode: LexicalNode, offset?: number): RangeSelection | NodeSelection | GridSelection | null;
@@ -5,4 +5,4 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
- export declare const VERSION = "0.3.7";
8
+ export declare const VERSION = "0.3.10";
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # `lexical`
2
2
 
3
- Lexical is an extensible JavaScript web text-editor framework with an emphasis on reliability, accessibility and performance. Lexical aims to provide a best-in-class developer experience, so you can easily prototype and build features with confidence. Combined with a highly extensible architecture, Lexical allows developers to create unique text editing experiences that scale in size and functionality.
3
+ Lexical is an extensible JavaScript web text-editor framework with an emphasis on reliability, accessibility, and performance. Lexical aims to provide a best-in-class developer experience, so you can easily prototype and build features with confidence. Combined with a highly extensible architecture, Lexical allows developers to create unique text editing experiences that scale in size and functionality.
4
4
 
5
5
  The core of Lexical is a dependency-free text editor engine that allows for powerful, simple and complex,
6
6
  editor implementations to be built on top. Lexical's engine provides three main parts:
package/index.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
- export type { CommandListenerPriority, EditorConfig, EditorThemeClasses, IntentionallyMarkedAsDirtyElement, Klass, LexicalCommand, LexicalEditor, NodeMutation, ReadOnlyListener, SerializedEditor, Spread, } from './LexicalEditor';
8
+ export type { CommandListenerPriority, CommandPayloadType, EditorConfig, EditorThemeClasses, IntentionallyMarkedAsDirtyElement, Klass, LexicalCommand, LexicalEditor, MutationListener, NodeMutation, ReadOnlyListener, SerializedEditor, Spread, } from './LexicalEditor';
9
9
  export type { EditorState, SerializedEditorState } from './LexicalEditorState';
10
10
  export type { DOMChildConversion, DOMConversion, DOMConversionFn, DOMConversionMap, DOMConversionOutput, DOMExportOutput, LexicalNode, NodeKey, NodeMap, SerializedLexicalNode, } from './LexicalNode';
11
11
  export type { BaseSelection, ElementPointType as ElementPoint, GridSelection, GridSelectionShape, NodeSelection, Point, RangeSelection, TextPointType as TextPoint, } from './LexicalSelection';
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "rich-text"
10
10
  ],
11
11
  "license": "MIT",
12
- "version": "0.3.7",
12
+ "version": "0.3.10",
13
13
  "main": "Lexical.js",
14
14
  "repository": {
15
15
  "type": "git",