lexical 0.3.6 → 0.3.9
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.dev.js +232 -183
- package/Lexical.js.flow +8 -2
- package/Lexical.prod.js +163 -160
- package/LexicalCommands.d.ts +4 -4
- package/LexicalConstants.d.ts +1 -0
- package/LexicalEditor.d.ts +31 -4
- package/LexicalUtils.d.ts +8 -7
- package/LexicalVersion.d.ts +1 -1
- package/README.md +1 -1
- package/index.d.ts +1 -1
- package/package.json +1 -1
package/LexicalCommands.d.ts
CHANGED
|
@@ -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>;
|
package/LexicalConstants.d.ts
CHANGED
|
@@ -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;
|
package/LexicalEditor.d.ts
CHANGED
|
@@ -31,6 +31,9 @@ export declare type EditorUpdateOptions = {
|
|
|
31
31
|
export declare type EditorSetOptions = {
|
|
32
32
|
tag?: string;
|
|
33
33
|
};
|
|
34
|
+
export declare type EditorFocusOptions = {
|
|
35
|
+
defaultSelection?: 'rootStart' | 'rootEnd';
|
|
36
|
+
};
|
|
34
37
|
export declare type EditorThemeClasses = {
|
|
35
38
|
characterLimit?: EditorThemeClassName;
|
|
36
39
|
code?: EditorThemeClassName;
|
|
@@ -103,7 +106,10 @@ export declare type UpdateListener = (arg0: {
|
|
|
103
106
|
export declare type DecoratorListener<T = never> = (decorator: Record<NodeKey, T>) => void;
|
|
104
107
|
export declare type RootListener = (rootElement: null | HTMLElement, prevRootElement: null | HTMLElement) => void;
|
|
105
108
|
export declare type TextContentListener = (text: string) => void;
|
|
106
|
-
export declare type MutationListener = (nodes: Map<NodeKey, NodeMutation
|
|
109
|
+
export declare type MutationListener = (nodes: Map<NodeKey, NodeMutation>, payload: {
|
|
110
|
+
updateTags: Set<string>;
|
|
111
|
+
dirtyLeaves: Set<string>;
|
|
112
|
+
}) => void;
|
|
107
113
|
export declare type CommandListener<P> = (payload: P, editor: LexicalEditor) => boolean;
|
|
108
114
|
export declare type ReadOnlyListener = (readOnly: boolean) => void;
|
|
109
115
|
export declare type CommandListenerPriority = 0 | 1 | 2 | 3 | 4;
|
|
@@ -112,7 +118,28 @@ export declare const COMMAND_PRIORITY_LOW = 1;
|
|
|
112
118
|
export declare const COMMAND_PRIORITY_NORMAL = 2;
|
|
113
119
|
export declare const COMMAND_PRIORITY_HIGH = 3;
|
|
114
120
|
export declare const COMMAND_PRIORITY_CRITICAL = 4;
|
|
115
|
-
export declare type LexicalCommand<
|
|
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;
|
|
116
143
|
declare type Commands = Map<LexicalCommand<unknown>, Array<Set<CommandListener<unknown>>>>;
|
|
117
144
|
declare type Listeners = {
|
|
118
145
|
decorator: Set<DecoratorListener>;
|
|
@@ -180,7 +207,7 @@ export declare class LexicalEditor {
|
|
|
180
207
|
registerMutationListener(klass: Klass<LexicalNode>, listener: MutationListener): () => void;
|
|
181
208
|
registerNodeTransform<T extends LexicalNode>(klass: Klass<T>, listener: Transform<T>): () => void;
|
|
182
209
|
hasNodes<T extends Klass<LexicalNode>>(nodes: Array<T>): boolean;
|
|
183
|
-
dispatchCommand<
|
|
210
|
+
dispatchCommand<TCommand extends LexicalCommand<unknown>, TPayload extends CommandPayloadType<TCommand>>(type: TCommand, payload: TPayload): boolean;
|
|
184
211
|
getDecorators<T>(): Record<NodeKey, T>;
|
|
185
212
|
getRootElement(): null | HTMLElement;
|
|
186
213
|
getKey(): string;
|
|
@@ -190,7 +217,7 @@ export declare class LexicalEditor {
|
|
|
190
217
|
setEditorState(editorState: EditorState, options?: EditorSetOptions): void;
|
|
191
218
|
parseEditorState(maybeStringifiedEditorState: string | SerializedEditorState, updateFn?: () => void): EditorState;
|
|
192
219
|
update(updateFn: () => void, options?: EditorUpdateOptions): void;
|
|
193
|
-
focus(callbackFn?: () => void): void;
|
|
220
|
+
focus(callbackFn?: () => void, options?: EditorFocusOptions): void;
|
|
194
221
|
blur(): void;
|
|
195
222
|
isReadOnly(): boolean;
|
|
196
223
|
setReadOnly(readOnly: boolean): void;
|
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(
|
|
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,
|
|
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,
|
|
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,
|
|
76
|
-
export declare function isMoveDown(keyCode: number, ctrlKey: 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<
|
|
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;
|
package/LexicalVersion.d.ts
CHANGED
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';
|